@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"});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 i{constructor(e){this.id=e,this.parentItem=null,this.groups=[],this.menuElement=null,this.shown=!1,this.mouseOver=0}}class s{constructor(){this.items=[]}}class r{constructor(e,t,i,s,r){this.id=e,this.getTitle=t,this.doAction=i,this.getEnabled=s,this.getShown=r,this.itemElement=null,this.subMenu=null,this.enabled=!0}}class n{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 i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}fire(e,t){const i=this._eventSubs[e];if(i)for(let e=0,s=i.length;e<s;e++)i[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 i(n);for(let i=0,n=e.length;i<n;i++){const n=e[i],o=new s;A.groups.push(o);for(let e=0,i=n.length;e<i;e++){const i=n[e],s=i.items,a=s&&s.length>0,l=this._getNextId(),c=i.getTitle||(()=>i.title||""),h=i.doAction||i.callback||(()=>{}),u=i.getEnabled||(()=>!0),d=i.getShown||(()=>!0),f=new r(l,c,h,u,d);if(f.parentMenu=A,o.items.push(f),a){const e=t(s);f.subMenu=e,e.parentItem=f}this._itemList.push(f),this._itemMap[f.id]=f}}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 i=t.groups;for(let t=0,s=i.length;t<s;t++){const s=i[t].items;for(let t=0,i=s.length;t<i;t++){const i=s[t].subMenu;i&&e(i)}}};e(this._rootMenu)}_createMenuUI(e){const t=e.groups,i=[],s=document.createElement("div");if(s.classList.add("xeokit-context-menu",e.id),s.style.zIndex=3e5,s.style.position="absolute",i.push("<ul>"),t)for(let e=0,s=t.length;e<s;e++){const r=e,n=s,A=t[e].items;if(A)for(let e=0,t=A.length;e<t;e++){const s=A[e],o=s.subMenu,a=s.title||"";o?(i.push('<li id="'+s.id+'" class="xeokit-context-menu-item xeokit-context-menu-submenu">'+a+"</li>"),r===n-1||e<t-1||i.push('<li id="'+s.id+'" class="xeokit-context-menu-item-separator"></li>')):(i.push('<li id="'+s.id+'" class="xeokit-context-menu-item">'+a+"</li>"),r===n-1||e<t-1||i.push('<li id="'+s.id+'" class="xeokit-context-menu-item-separator"></li>'))}}i.push("</ul>");const r=i.join("");s.innerHTML=r,this._parentNode.appendChild(s),e.menuElement=s,s.style["border-radius"]="4px",s.style.display="none",s.style["z-index"]=3e5,s.style.background="white",s.style.border="1px solid black",s.style["box-shadow"]="0 4px 5px 0 gray",s.oncontextmenu=e=>{e.preventDefault()};const n=this;let A=null;if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e].items;if(i)for(let e=0,t=i.length;e<t;e++){const t=i[e],s=t.subMenu;t.itemElement=this._parentNode.querySelector(`#${t.id}`),t.itemElement?(t.itemElement.addEventListener("mouseenter",(e=>{e.preventDefault();const i=t.subMenu;if(!i)return void(A&&(n._hideMenu(A.id),A=null));if(A&&A.id!==i.id&&(n._hideMenu(A.id),A=null),!1===t.enabled)return;const s=t.itemElement,r=i.menuElement,o=s.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(i.id,o.right+window.scrollX-5,o.top+window.scrollY-1);else if(h)n._showMenu(i.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(i.id,o.right-5-(l-t),o.top+window.scrollY-1):n._showMenu(i.id,o.left-e,o.top+window.scrollY-1)}A=i})),s||(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],i=t.itemElement;if(!i)continue;const s=t.getShown;if(!s||!s(this._context))continue;const r=t.getTitle(this._context);t.subMenu,i.innerText=r}}_updateItemsEnabledStatus(){if(this._context)for(let e=0,t=this._itemList.length;e<t;e++){const t=this._itemList[e],i=t.itemElement;if(!i)continue;const s=t.getEnabled;if(!s)continue;const r=t.getShown;if(!r)continue;const n=r(this._context);if(t.shown=n,!n){i.style.display="none";continue}i.style.display="";const A=s(this._context);t.enabled=A,A?i.classList.remove("disabled"):i.classList.add("disabled")}}_updateSubMenuInfo(){if(!this._context)return;let e,t,i,s,r,n;this._itemList.forEach((A=>{A.subMenu&&(e=A.itemElement,t=e.getBoundingClientRect(),i=A.subMenu.menuElement,s={visibility:i.style.visibility,display:i.style.display},i.style.display="block",i.style.visibility="hidden",n=A.subMenu.menuElement.getBoundingClientRect().width,i.style.visibility=s.visibility,i.style.display=s.display,r=t.right+n>window.innerWidth,e.setAttribute("data-submenuposition",r?"left":"right"))}))}_showMenu(e,t,i){const s=this._menuMap[e];if(!s)return void console.error("Menu not found: "+e);if(s.shown)return;const r=s.menuElement;r&&(this._showMenuElement(r,t,i),s.shown=!0)}_hideMenu(e){const t=this._menuMap[e];if(!t)return void console.error("Menu not found: "+e);if(!t.shown)return;const i=t.menuElement;i&&(this._hideMenuElement(i),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,i){e.style.display="block";const s=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;i+s>A&&(i=A-s),t+r>o&&(t=o-r),e.style.left=t-n.left-window.scrollX+"px",e.style.top=i-n.top-window.scrollY+"px"}_hideMenuElement(e){e.style.display="none"}}class A{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(),i=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`,i&&(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 s=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,this._canvasPos[0]-s/2,this._canvasPos[1]-s/2,s,s,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,i]=e?["greenyellow","green"]:["pink","red"];this._lensCursorDiv.style.background=t,this._lensCursorDiv.style.border=this._lensParams.cursorBorder+"px solid "+i}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)}}function o(e,t,i=2){const s=t&&t.length,r=s?t[0]*i:e.length;let n=a(e,0,r,i,!0);const A=[];if(!n||n.next===n.prev)return A;let o,l,h;if(s&&(n=function(e,t,i,s){const r=[];for(let i=0,n=t.length;i<n;i++){const A=a(e,t[i]*s,i<n-1?t[i+1]*s:e.length,s,!1);A===A.next&&(A.steiner=!0),r.push(b(A))}r.sort(p);for(let e=0;e<r.length;e++)i=g(r[e],i);return i}(e,t,n,i)),e.length>80*i){o=1/0,l=1/0;let t=-1/0,s=-1/0;for(let n=i;n<r;n+=i){const i=e[n],r=e[n+1];i<o&&(o=i),r<l&&(l=r),i>t&&(t=i),r>s&&(s=r)}h=Math.max(t-o,s-l),h=0!==h?32767/h:0}return c(n,A,i,o,l,h,0),A}function a(e,t,i,s,r){let n;if(r===function(e,t,i,s){let r=0;for(let n=t,A=i-s;n<i;n+=s)r+=(e[A]-e[n])*(e[n+1]+e[A+1]),A=n;return r}(e,t,i,s)>0)for(let r=t;r<i;r+=s)n=I(r/s|0,e[r],e[r+1],n);else for(let r=i-s;r>=t;r-=s)n=I(r/s|0,e[r],e[r+1],n);return n&&C(n,n.next)&&(T(n),n=n.next),n}function l(e,t){if(!e)return e;t||(t=e);let i,s=e;do{if(i=!1,s.steiner||!C(s,s.next)&&0!==v(s.prev,s,s.next))s=s.next;else{if(T(s),s=t=s.prev,s===s.next)break;i=!0}}while(i||s!==t);return t}function c(e,t,i,s,r,n,A){if(!e)return;!A&&n&&function(e,t,i,s){let r=e;do{0===r.z&&(r.z=_(r.x,r.y,t,i,s)),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,i=1;do{let s,r=e;e=null;let n=null;for(t=0;r;){t++;let A=r,o=0;for(let e=0;e<i&&(o++,A=A.nextZ,A);e++);let a=i;for(;o>0||a>0&&A;)0!==o&&(0===a||!A||r.z<=A.z)?(s=r,r=r.nextZ,o--):(s=A,A=A.nextZ,a--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;r=A}n.nextZ=null,i*=2}while(t>1)}(r)}(e,s,r,n);let o=e;for(;e.prev!==e.next;){const a=e.prev,p=e.next;if(n?u(e,s,r,n):h(e))t.push(a.i,e.i,p.i),T(e),e=p.next,o=p.next;else if((e=p)===o){A?1===A?c(e=d(l(e),t),t,i,s,r,n,2):2===A&&f(e,t,i,s,r,n):c(l(e),t,i,s,r,n,1);break}}}function h(e){const t=e.prev,i=e,s=e.next;if(v(t,i,s)>=0)return!1;const r=t.x,n=i.x,A=s.x,o=t.y,a=i.y,l=s.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 f=s.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=h&&f.y<=d&&y(r,o,n,a,A,l,f.x,f.y)&&v(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function u(e,t,i,s){const r=e.prev,n=e,A=e.next;if(v(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),f=Math.min(c,h,u),p=Math.max(o,a,l),g=Math.max(c,h,u),m=_(d,f,t,i,s),b=_(p,g,t,i,s);let B=e.prevZ,w=e.nextZ;for(;B&&B.z>=m&&w&&w.z<=b;){if(B.x>=d&&B.x<=p&&B.y>=f&&B.y<=g&&B!==r&&B!==A&&y(o,c,a,h,l,u,B.x,B.y)&&v(B.prev,B,B.next)>=0)return!1;if(B=B.prevZ,w.x>=d&&w.x<=p&&w.y>=f&&w.y<=g&&w!==r&&w!==A&&y(o,c,a,h,l,u,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;B&&B.z>=m;){if(B.x>=d&&B.x<=p&&B.y>=f&&B.y<=g&&B!==r&&B!==A&&y(o,c,a,h,l,u,B.x,B.y)&&v(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;w&&w.z<=b;){if(w.x>=d&&w.x<=p&&w.y>=f&&w.y<=g&&w!==r&&w!==A&&y(o,c,a,h,l,u,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function d(e,t){let i=e;do{const s=i.prev,r=i.next.next;!C(s,r)&&M(s,i,i.next,r)&&U(s,r)&&U(r,s)&&(t.push(s.i,i.i,r.i),T(i),T(i.next),i=e=r),i=i.next}while(i!==e);return l(i)}function f(e,t,i,s,r,n){let A=e;do{let e=A.next.next;for(;e!==A.prev;){if(A.i!==e.i&&w(A,e)){let o=x(A,e);return A=l(A,A.next),o=l(o,o.next),c(A,t,i,s,r,n,0),void c(o,t,i,s,r,n,0)}e=e.next}A=A.next}while(A!==e)}function p(e,t){let i=e.x-t.x;if(0===i&&(i=e.y-t.y,0===i)){i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return i}function g(e,t){const i=function(e,t){let i=t;const s=e.x,r=e.y;let n,A=-1/0;if(C(e,i))return i;do{if(C(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>A&&(A=e,n=i.x<i.next.x?i:i.next,e===s))return n}i=i.next}while(i!==t);if(!n)return null;const o=n,a=n.x,l=n.y;let c=1/0;i=n;do{if(s>=i.x&&i.x>=a&&s!==i.x&&B(r<l?s:A,r,a,l,r<l?A:s,r,i.x,i.y)){const t=Math.abs(r-i.y)/(s-i.x);U(i,e)&&(t<c||t===c&&(i.x>n.x||i.x===n.x&&m(n,i)))&&(n=i,c=t)}i=i.next}while(i!==o);return n}(e,t);if(!i)return t;const s=x(i,e);return l(s,s.next),l(i,i.next)}function m(e,t){return v(e.prev,e,t.prev)<0&&v(t.next,e,e.next)<0}function _(e,t,i,s,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function b(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function B(e,t,i,s,r,n,A,o){return(r-A)*(t-o)>=(e-A)*(n-o)&&(e-A)*(s-o)>=(i-A)*(t-o)&&(i-A)*(n-o)>=(r-A)*(s-o)}function y(e,t,i,s,r,n,A,o){return!(e===A&&t===o)&&B(e,t,i,s,r,n,A,o)}function w(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&M(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(U(e,t)&&U(t,e)&&function(e,t){let i=e,s=!1;const r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==e);return s}(e,t)&&(v(e.prev,e,t.prev)||v(e,t.prev,t))||C(e,t)&&v(e.prev,e,e.next)>0&&v(t.prev,t,t.next)>0)}function v(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function C(e,t){return e.x===t.x&&e.y===t.y}function M(e,t,i,s){const r=F(v(e,t,i)),n=F(v(e,t,s)),A=F(v(i,s,e)),o=F(v(i,s,t));return r!==n&&A!==o||(!(0!==r||!E(e,i,t))||(!(0!==n||!E(e,s,t))||(!(0!==A||!E(i,e,s))||!(0!==o||!E(i,t,s)))))}function E(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function F(e){return e>0?1:e<0?-1:0}function U(e,t){return v(e.prev,e,e.next)<0?v(e,t,e.next)>=0&&v(e,e.prev,t)>=0:v(e,t,e.prev)<0||v(e,e.next,t)<0}function x(e,t){const i=P(e.i,e.x,e.y),s=P(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function I(e,t,i,s){const r=P(e,t,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function T(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 P(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}let S=!0,D=S?Float64Array:Float32Array;const k=new D(3),Q=new D(16),R=new D(16),O=new D(4),V={setDoublePrecisionEnabled(e){S=e,D=S?Float64Array:Float32Array},getDoublePrecisionEnabled:()=>S,MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:1e7,DEGTORAD:.0174532925,RADTODEG:57.295779513,unglobalizeObjectId(e,t){const i=t.indexOf("#");return i===e.length&&t.startsWith(e)?t.substring(i+1):t},globalizeObjectId:(e,t)=>e+"#"+t,safeInv(e){const t=1/e;return isNaN(t)||!isFinite(t)?1:t},vec2:e=>new D(e||2),vec3:e=>new D(e||3),vec4:e=>new D(e||4),mat3:e=>new D(e||9),mat3ToMat4:(e,t=new D(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 D(e||16),mat4ToMat3:(e,t=new D(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,i){const s=new D(2);for(let r=0,n=e.length;r<n;r++)V.splitDouble(e[r],s),t[r]=s[0],i[r]=s[1]},splitDouble(e,t){const i=D.from([e])[0],s=e-i;t[0]=i,t[1]=s},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,i=4294967295*Math.random()|0,s=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&i]}${e[i>>8&255]}-${e[i>>16&15|64]}${e[i>>24&255]}-${e[63&s|128]}${e[s>>8&255]}-${e[s>>16&255]}${e[s>>24&255]}${e[255&r]}${e[r>>8&255]}${e[r>>16&255]}${e[r>>24&255]}`}})(),clamp:(e,t,i)=>Math.max(t,Math.min(i,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,i)=>(i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i),addVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i),addVec3:(e,t,i)=>(i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i),addVec3Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i),subVec4:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i),subVec3:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i),subVec2:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i),geometricMeanVec2(...e){const t=new D(e[0]);for(let i=1;i<e.length;i++)t[0]+=e[i][0],t[1]+=e[i][1];return t[0]/=e.length,t[1]/=e.length,t},subVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i),subScalarVec4:(e,t,i)=>(i||(i=e),i[0]=t-e[0],i[1]=t-e[1],i[2]=t-e[2],i[3]=t-e[3],i),mulVec4:(e,t,i)=>(i||(i=e),i[0]=e[0]*t[0],i[1]=e[1]*t[1],i[2]=e[2]*t[2],i[3]=e[3]*t[3],i),mulVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i),mulVec3Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i),mulVec2Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i),divVec3:(e,t,i)=>(i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i),divVec4:(e,t,i)=>(i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i[3]=e[3]/t[3],i),divScalarVec3:(e,t,i)=>(i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i),divVec3Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i),divVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i[3]=e[3]/t,i),divScalarVec4:(e,t,i)=>(i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i[3]=e/t[3],i),dotVec4:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],cross3Vec4(e,t){const i=e[0],s=e[1],r=e[2],n=t[0],A=t[1],o=t[2];return[s*o-r*A,r*n-i*o,i*A-s*n,0]},cross3Vec3(e,t,i){i||(i=e);const s=e[0],r=e[1],n=e[2],A=t[0],o=t[1],a=t[2];return i[0]=r*a-n*o,i[1]=n*A-s*a,i[2]=s*o-r*A,i},sqLenVec4:e=>V.dotVec4(e,e),lenVec4:e=>Math.sqrt(V.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=>V.dotVec3(e,e),sqLenVec2:e=>V.dotVec2(e,e),lenVec3:e=>Math.sqrt(V.sqLenVec3(e)),distVec3:(()=>{const e=new D(3);return(t,i)=>V.lenVec3(V.subVec3(t,i,e))})(),lenVec2:e=>Math.sqrt(V.sqLenVec2(e)),distVec2:(()=>{const e=new D(2);return(t,i)=>V.lenVec2(V.subVec2(t,i,e))})(),rcpVec3:(e,t)=>V.divScalarVec3(1,e,t),normalizeVec4(e,t){const i=1/V.lenVec4(e);return V.mulVec4Scalar(e,i,t)},normalizeVec3(e,t){const i=1/V.lenVec3(e);return V.mulVec3Scalar(e,i,t)},normalizeVec2(e,t){const i=1/V.lenVec2(e);return V.mulVec2Scalar(e,i,t)},angleVec3(e,t){let i=V.dotVec3(e,t)/Math.sqrt(V.sqLenVec3(e)*V.sqLenVec3(t));return i=i<-1?-1:i>1?1:i,Math.acos(i)},vec3FromMat4Scale:(()=>{const e=new D(3);return(t,i)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],i[0]=V.lenVec3(e),e[0]=t[4],e[1]=t[5],e[2]=t[6],i[1]=V.lenVec3(e),e[0]=t[8],e[1]=t[9],e[2]=t[10],i[2]=V.lenVec3(e),i)})(),vecToArray:(()=>{function e(e){return Math.round(1e5*e)/1e5}return t=>{for(let i=0,s=(t=Array.prototype.slice.call(t)).length;i<s;i++)t[i]=e(t[i]);return t}})(),xyzArrayToObject:e=>({x:e[0],y:e[1],z:e[2]}),xyzObjectToArray:(e,t)=>((t=t||V.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:()=>V.m4s(0),setMat4ToOnes:()=>V.m4s(1),diagonalMat4v:e=>new D([e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,e[3]]),diagonalMat4c:(e,t,i,s)=>V.diagonalMat4v([e,t,i,s]),diagonalMat4s:e=>V.diagonalMat4c(e,e,e,e),identityMat4:(e=new D(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 D(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,i)=>(i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i[4]=e[4]+t[4],i[5]=e[5]+t[5],i[6]=e[6]+t[6],i[7]=e[7]+t[7],i[8]=e[8]+t[8],i[9]=e[9]+t[9],i[10]=e[10]+t[10],i[11]=e[11]+t[11],i[12]=e[12]+t[12],i[13]=e[13]+t[13],i[14]=e[14]+t[14],i[15]=e[15]+t[15],i),addMat4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i[4]=e[4]+t,i[5]=e[5]+t,i[6]=e[6]+t,i[7]=e[7]+t,i[8]=e[8]+t,i[9]=e[9]+t,i[10]=e[10]+t,i[11]=e[11]+t,i[12]=e[12]+t,i[13]=e[13]+t,i[14]=e[14]+t,i[15]=e[15]+t,i),addScalarMat4:(e,t,i)=>V.addMat4Scalar(t,e,i),subMat4:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i[4]=e[4]-t[4],i[5]=e[5]-t[5],i[6]=e[6]-t[6],i[7]=e[7]-t[7],i[8]=e[8]-t[8],i[9]=e[9]-t[9],i[10]=e[10]-t[10],i[11]=e[11]-t[11],i[12]=e[12]-t[12],i[13]=e[13]-t[13],i[14]=e[14]-t[14],i[15]=e[15]-t[15],i),subMat4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i[4]=e[4]-t,i[5]=e[5]-t,i[6]=e[6]-t,i[7]=e[7]-t,i[8]=e[8]-t,i[9]=e[9]-t,i[10]=e[10]-t,i[11]=e[11]-t,i[12]=e[12]-t,i[13]=e[13]-t,i[14]=e[14]-t,i[15]=e[15]-t,i),subScalarMat4:(e,t,i)=>(i||(i=t),i[0]=e-t[0],i[1]=e-t[1],i[2]=e-t[2],i[3]=e-t[3],i[4]=e-t[4],i[5]=e-t[5],i[6]=e-t[6],i[7]=e-t[7],i[8]=e-t[8],i[9]=e-t[9],i[10]=e-t[10],i[11]=e-t[11],i[12]=e-t[12],i[13]=e-t[13],i[14]=e-t[14],i[15]=e-t[15],i),mulMat4(e,t,i){i||(i=e);const s=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],f=e[11],p=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],U=t[9],x=t[10],I=t[11],T=t[12],P=t[13],S=t[14],D=t[15];return i[0]=b*s+B*o+y*h+w*p,i[1]=b*r+B*a+y*u+w*g,i[2]=b*n+B*l+y*d+w*m,i[3]=b*A+B*c+y*f+w*_,i[4]=v*s+C*o+M*h+E*p,i[5]=v*r+C*a+M*u+E*g,i[6]=v*n+C*l+M*d+E*m,i[7]=v*A+C*c+M*f+E*_,i[8]=F*s+U*o+x*h+I*p,i[9]=F*r+U*a+x*u+I*g,i[10]=F*n+U*l+x*d+I*m,i[11]=F*A+U*c+x*f+I*_,i[12]=T*s+P*o+S*h+D*p,i[13]=T*r+P*a+S*u+D*g,i[14]=T*n+P*l+S*d+D*m,i[15]=T*A+P*c+S*f+D*_,i},mulMat3(e,t,i){i||(i=new D(9));const s=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],f=t[6],p=t[1],g=t[4],m=t[7],_=t[2],b=t[5],B=t[8];return i[0]=s*u+r*p+n*_,i[3]=s*d+r*g+n*b,i[6]=s*f+r*m+n*B,i[1]=A*u+o*p+a*_,i[4]=A*d+o*g+a*b,i[7]=A*f+o*m+a*B,i[2]=l*u+c*p+h*_,i[5]=l*d+c*g+h*b,i[8]=l*f+c*m+h*B,i},mulMat4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i[4]=e[4]*t,i[5]=e[5]*t,i[6]=e[6]*t,i[7]=e[7]*t,i[8]=e[8]*t,i[9]=e[9]*t,i[10]=e[10]*t,i[11]=e[11]*t,i[12]=e[12]*t,i[13]=e[13]*t,i[14]=e[14]*t,i[15]=e[15]*t,i),mulMat4v4(e,t,i=V.vec4()){const s=t[0],r=t[1],n=t[2],A=t[3];return i[0]=e[0]*s+e[4]*r+e[8]*n+e[12]*A,i[1]=e[1]*s+e[5]*r+e[9]*n+e[13]*A,i[2]=e[2]*s+e[6]*r+e[10]*n+e[14]*A,i[3]=e[3]*s+e[7]*r+e[11]*n+e[15]*A,i},transposeMat4(e,t){const i=e[4],s=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]=i,e[2]=r,e[3]=A,e[4]=t,e[6]=o,e[7]=n,e[8]=a,e[9]=c,e[11]=s,e[12]=l,e[13]=h,e[14]=u,e}return t[0]=e[0],t[1]=i,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]=s,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3(e,t){if(t===e){const i=e[1],s=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=s,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],i=e[1],s=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],f=e[13],p=e[14],g=e[15];return d*c*o*r-l*f*o*r-d*A*h*r+n*f*h*r+l*A*p*r-n*c*p*r-d*c*s*a+l*f*s*a+d*i*h*a-t*f*h*a-l*i*p*a+t*c*p*a+d*A*s*u-n*f*s*u-d*i*o*u+t*f*o*u+n*i*p*u-t*A*p*u-l*A*s*g+n*c*s*g+l*i*o*g-t*c*o*g-n*i*h*g+t*A*h*g},inverseMat4(e,t){t||(t=e);const i=e[0],s=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],f=e[12],p=e[13],g=e[14],m=e[15],_=i*o-s*A,b=i*a-r*A,B=i*l-n*A,y=s*a-r*o,w=s*l-n*o,v=r*l-n*a,C=c*p-h*f,M=c*g-u*f,E=c*m-d*f,F=h*g-u*p,U=h*m-d*p,x=u*m-d*g,I=1/(_*x-b*U+B*F+y*E-w*M+v*C);return t[0]=(o*x-a*U+l*F)*I,t[1]=(-s*x+r*U-n*F)*I,t[2]=(p*v-g*w+m*y)*I,t[3]=(-h*v+u*w-d*y)*I,t[4]=(-A*x+a*E-l*M)*I,t[5]=(i*x-r*E+n*M)*I,t[6]=(-f*v+g*B-m*b)*I,t[7]=(c*v-u*B+d*b)*I,t[8]=(A*U-o*E+l*C)*I,t[9]=(-i*U+s*E-n*C)*I,t[10]=(f*w-p*B+m*_)*I,t[11]=(-c*w+h*B-d*_)*I,t[12]=(-A*F+o*M-a*C)*I,t[13]=(i*F-s*M+r*C)*I,t[14]=(-f*y+p*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 i=t||V.identityMat4();return i[12]=e[0],i[13]=e[1],i[14]=e[2],i},translationMat3v(e,t){const i=t||V.identityMat3();return i[6]=e[0],i[7]=e[1],i},translationMat4c:(()=>{const e=new D(3);return(t,i,s,r)=>(e[0]=t,e[1]=i,e[2]=s,V.translationMat4v(e,r))})(),translationMat4s:(e,t)=>V.translationMat4c(e,e,e,t),translateMat4v:(e,t)=>V.translateMat4c(e[0],e[1],e[2],t),translateMat4c(e,t,i,s){const r=s[3];s[0]+=r*e,s[1]+=r*t,s[2]+=r*i;const n=s[7];s[4]+=n*e,s[5]+=n*t,s[6]+=n*i;const A=s[11];s[8]+=A*e,s[9]+=A*t,s[10]+=A*i;const o=s[15];return s[12]+=o*e,s[13]+=o*t,s[14]+=o*i,s},setMat4Translation:(e,t,i)=>(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=e[15],i),rotationMat4v(e,t,i){const s=V.normalizeVec4([t[0],t[1],t[2],0],[]),r=Math.sin(e),n=Math.cos(e),A=1-n,o=s[0],a=s[1],l=s[2];let c,h,u,d,f,p;return c=o*a,h=a*l,u=l*o,d=o*r,f=a*r,p=l*r,(i=i||V.mat4())[0]=A*o*o+n,i[1]=A*c+p,i[2]=A*u-f,i[3]=0,i[4]=A*c-p,i[5]=A*a*a+n,i[6]=A*h+d,i[7]=0,i[8]=A*u+f,i[9]=A*h-d,i[10]=A*l*l+n,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},rotationMat4c:(e,t,i,s,r)=>V.rotationMat4v(e,[t,i,s],r),scalingMat4v:(e,t=V.identityMat4())=>(t[0]=e[0],t[5]=e[1],t[10]=e[2],t),scalingMat3v:(e,t=V.identityMat3())=>(t[0]=e[0],t[4]=e[1],t),scalingMat4c:(()=>{const e=new D(3);return(t,i,s,r)=>(e[0]=t,e[1]=i,e[2]=s,V.scalingMat4v(e,r))})(),scaleMat4c:(e,t,i,s)=>(s[0]*=e,s[4]*=t,s[8]*=i,s[1]*=e,s[5]*=t,s[9]*=i,s[2]*=e,s[6]*=t,s[10]*=i,s[3]*=e,s[7]*=t,s[11]*=i,s),scaleMat4v(e,t){const i=e[0],s=e[1],r=e[2];return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,t},scalingMat4s:e=>V.scalingMat4c(e,e,e),rotationTranslationMat4(e,t,i=V.mat4()){const s=e[0],r=e[1],n=e[2],A=e[3],o=s+s,a=r+r,l=n+n,c=s*o,h=s*a,u=s*l,d=r*a,f=r*l,p=n*l,g=A*o,m=A*a,_=A*l;return i[0]=1-(d+p),i[1]=h+_,i[2]=u-m,i[3]=0,i[4]=h-_,i[5]=1-(c+p),i[6]=f+g,i[7]=0,i[8]=u+m,i[9]=f-g,i[10]=1-(c+d),i[11]=0,i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=1,i},mat4ToEuler(e,t,i=V.vec4()){const s=V.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?(i[1]=Math.asin(s(A,-1,1)),Math.abs(A)<.99999?(i[0]=Math.atan2(-l,u),i[2]=Math.atan2(-n,r)):(i[0]=Math.atan2(h,a),i[2]=0)):"YXZ"===t?(i[0]=Math.asin(-s(l,-1,1)),Math.abs(l)<.99999?(i[1]=Math.atan2(A,u),i[2]=Math.atan2(o,a)):(i[1]=Math.atan2(-c,r),i[2]=0)):"ZXY"===t?(i[0]=Math.asin(s(h,-1,1)),Math.abs(h)<.99999?(i[1]=Math.atan2(-c,u),i[2]=Math.atan2(-n,a)):(i[1]=0,i[2]=Math.atan2(o,r))):"ZYX"===t?(i[1]=Math.asin(-s(c,-1,1)),Math.abs(c)<.99999?(i[0]=Math.atan2(h,u),i[2]=Math.atan2(o,r)):(i[0]=0,i[2]=Math.atan2(-n,a))):"YZX"===t?(i[2]=Math.asin(s(o,-1,1)),Math.abs(o)<.99999?(i[0]=Math.atan2(-l,a),i[1]=Math.atan2(-c,r)):(i[0]=0,i[1]=Math.atan2(A,u))):"XZY"===t&&(i[2]=Math.asin(-s(n,-1,1)),Math.abs(n)<.99999?(i[0]=Math.atan2(h,a),i[1]=Math.atan2(A,r)):(i[0]=Math.atan2(-l,u),i[1]=0)),i[0]*=V.RADTODEG,i[1]*=V.RADTODEG,i[2]*=V.RADTODEG,i},composeMat4:(e,t,i,s=V.mat4())=>(V.quaternionToRotationMat4(t,s),V.scaleMat4v(i,s),V.translateMat4v(e,s),s),decomposeMat4:(()=>{const e=new D(3),t=new D(16);return function(i,s,r,n){e[0]=i[0],e[1]=i[1],e[2]=i[2];let A=V.lenVec3(e);e[0]=i[4],e[1]=i[5],e[2]=i[6];const o=V.lenVec3(e);e[8]=i[8],e[9]=i[9],e[10]=i[10];const a=V.lenVec3(e);V.determinantMat4(i)<0&&(A=-A),s[0]=i[12],s[1]=i[13],s[2]=i[14],t.set(i);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,V.mat4ToQuaternion(t,r),n[0]=A,n[1]=o,n[2]=a,this}})(),getColMat4(e,t){const i=4*t;return[e[i],e[i+1],e[i+2],e[i+3]]},setRowMat4(e,t,i){e[t]=i[0],e[t+4]=i[1],e[t+8]=i[2],e[t+12]=i[3]},lookAtMat4v(e,t,i,s){s||(s=V.mat4());const r=e[0],n=e[1],A=e[2],o=i[0],a=i[1],l=i[2],c=t[0],h=t[1],u=t[2];if(r===c&&n===h&&A===u)return V.identityMat4();let d,f,p,g,m,_,b,B,y,w;return d=r-c,f=n-h,p=A-u,w=1/Math.sqrt(d*d+f*f+p*p),d*=w,f*=w,p*=w,g=a*p-l*f,m=l*d-o*p,_=o*f-a*d,w=Math.sqrt(g*g+m*m+_*_),w?(w=1/w,g*=w,m*=w,_*=w):(g=0,m=0,_=0),b=f*_-p*m,B=p*g-d*_,y=d*m-f*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),s[0]=g,s[1]=b,s[2]=d,s[3]=0,s[4]=m,s[5]=B,s[6]=f,s[7]=0,s[8]=_,s[9]=y,s[10]=p,s[11]=0,s[12]=-(g*r+m*n+_*A),s[13]=-(b*r+B*n+y*A),s[14]=-(d*r+f*n+p*A),s[15]=1,s},lookAtMat4c:(e,t,i,s,r,n,A,o,a)=>V.lookAtMat4v([e,t,i],[s,r,n],[A,o,a],[]),orthoMat4c(e,t,i,s,r,n,A){A||(A=V.mat4());const o=t-e,a=s-i,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]=-(s+i)/a,A[14]=-(n+r)/l,A[15]=1,A},frustumMat4v(e,t,i){i||(i=V.mat4());const s=[e[0],e[1],e[2],0],r=[t[0],t[1],t[2],0];V.addVec4(r,s,Q),V.subVec4(r,s,R);const n=2*s[2],A=R[0],o=R[1],a=R[2];return i[0]=n/A,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=n/o,i[6]=0,i[7]=0,i[8]=Q[0]/A,i[9]=Q[1]/o,i[10]=-Q[2]/a,i[11]=-1,i[12]=0,i[13]=0,i[14]=-n*r[2]/a,i[15]=0,i},frustumMat4(e,t,i,s,r,n,A){A||(A=V.mat4());const o=t-e,a=s-i,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]=(s+i)/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,i,s,r){const n=[],A=[];return n[2]=i,A[2]=s,A[1]=n[2]*Math.tan(e/2),n[1]=-A[1],A[0]=A[1]*t,n[0]=-A[0],V.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,i=V.vec3()){const s=t[0],r=t[1],n=t[2];return i[0]=e[0]*s+e[4]*r+e[8]*n+e[12],i[1]=e[1]*s+e[5]*r+e[9]*n+e[13],i[2]=e[2]*s+e[6]*r+e[10]*n+e[14],i},transformPoint4:(e,t,i=V.vec4())=>(i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],i),transformPoints3(e,t,i){const s=i||[],r=t.length;let n,A,o,a;const l=e[0],c=e[1],h=e[2],u=e[3],d=e[4],f=e[5],p=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=s[e]||(s[e]=[0,0,0]),M[0]=l*n+d*A+m*o+y,M[1]=c*n+f*A+_*o+w,M[2]=h*n+p*A+b*o+v,M[3]=u*n+g*A+B*o+C;return s.length=r,s},transformPositions3(e,t,i=t){let s;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 f=e[8],p=e[9],g=e[10];e[11];const m=e[12],_=e[13],b=e[14];for(e[15],s=0;s<r;s+=3)n=t[s+0],A=t[s+1],o=t[s+2],i[s+0]=a*n+h*A+f*o+m,i[s+1]=l*n+u*A+p*o+_,i[s+2]=c*n+d*A+g*o+b;return i},transformPositions4(e,t,i=t){let s;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],f=e[6],p=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(s=0;s<r;s+=4)n=t[s+0],A=t[s+1],o=t[s+2],i[s+0]=a*n+u*A+g*o+B,i[s+1]=l*n+d*A+m*o+y,i[s+2]=c*n+f*A+_*o+w,i[s+3]=h*n+p*A+b*o+v;return i},transformVec3(e,t,i){const s=t[0],r=t[1],n=t[2];return(i=i||this.vec3())[0]=e[0]*s+e[4]*r+e[8]*n,i[1]=e[1]*s+e[5]*r+e[9]*n,i[2]=e[2]*s+e[6]*r+e[10]*n,i},transformVec4(e,t,i){const s=t[0],r=t[1],n=t[2],A=t[3];return(i=i||V.vec4())[0]=e[0]*s+e[4]*r+e[8]*n+e[12]*A,i[1]=e[1]*s+e[5]*r+e[9]*n+e[13]*A,i[2]=e[2]*s+e[6]*r+e[10]*n+e[14]*A,i[3]=e[3]*s+e[7]*r+e[11]*n+e[15]*A,i},rotateVec2(e,t,i,s=e){const r=Math.cos(i),n=Math.sin(i),A=e[0]-t[0],o=e[1]-t[1];return s[0]=A*r-o*n+t[0],s[1]=A*n+o*r+t[1],e},rotateVec3X(e,t,i,s){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(i)-r[2]*Math.sin(i),n[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},rotateVec3Y(e,t,i,s){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(i)+r[0]*Math.cos(i),n[1]=r[1],n[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},rotateVec3Z(e,t,i,s){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(i)-r[1]*Math.sin(i),n[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),n[2]=r[2],s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},projectVec4(e,t){const i=1/e[3];return(t=t||V.vec2())[0]=e[0]*i,t[1]=e[1]*i,t},unprojectVec3:(()=>{const e=new D(16),t=new D(16),i=new D(16);return function(s,r,n,A){return this.transformVec3(this.mulMat4(this.inverseMat4(r,e),this.inverseMat4(n,t),i),s,A)}})(),lerpVec3(e,t,i,s,r,n){const A=n||V.vec3(),o=(e-t)/(i-t);return A[0]=s[0]+o*(r[0]-s[0]),A[1]=s[1]+o*(r[1]-s[1]),A[2]=s[2]+o*(r[2]-s[2]),A},lerpMat4(e,t,i,s,r,n){const A=n||V.mat4(),o=(e-t)/(i-t);return A[0]=s[0]+o*(r[0]-s[0]),A[1]=s[1]+o*(r[1]-s[1]),A[2]=s[2]+o*(r[2]-s[2]),A[3]=s[3]+o*(r[3]-s[3]),A[4]=s[4]+o*(r[4]-s[4]),A[5]=s[5]+o*(r[5]-s[5]),A[6]=s[6]+o*(r[6]-s[6]),A[7]=s[7]+o*(r[7]-s[7]),A[8]=s[8]+o*(r[8]-s[8]),A[9]=s[9]+o*(r[9]-s[9]),A[10]=s[10]+o*(r[10]-s[10]),A[11]=s[11]+o*(r[11]-s[11]),A[12]=s[12]+o*(r[12]-s[12]),A[13]=s[13]+o*(r[13]-s[13]),A[14]=s[14]+o*(r[14]-s[14]),A[15]=s[15]+o*(r[15]-s[15]),A},flatten(e){const t=[];let i,s,r,n,A;for(i=0,s=e.length;i<s;i++)for(A=e[i],r=0,n=A.length;r<n;r++)t.push(A[r]);return t},identityQuaternion:(e=V.vec4())=>(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e),eulerToQuaternion(e,t,i=V.vec4()){const s=e[0]*V.DEGTORAD/2,r=e[1]*V.DEGTORAD/2,n=e[2]*V.DEGTORAD/2,A=Math.cos(s),o=Math.cos(r),a=Math.cos(n),l=Math.sin(s),c=Math.sin(r),h=Math.sin(n);return"XYZ"===t?(i[0]=l*o*a+A*c*h,i[1]=A*c*a-l*o*h,i[2]=A*o*h+l*c*a,i[3]=A*o*a-l*c*h):"YXZ"===t?(i[0]=l*o*a+A*c*h,i[1]=A*c*a-l*o*h,i[2]=A*o*h-l*c*a,i[3]=A*o*a+l*c*h):"ZXY"===t?(i[0]=l*o*a-A*c*h,i[1]=A*c*a+l*o*h,i[2]=A*o*h+l*c*a,i[3]=A*o*a-l*c*h):"ZYX"===t?(i[0]=l*o*a-A*c*h,i[1]=A*c*a+l*o*h,i[2]=A*o*h-l*c*a,i[3]=A*o*a+l*c*h):"YZX"===t?(i[0]=l*o*a+A*c*h,i[1]=A*c*a+l*o*h,i[2]=A*o*h-l*c*a,i[3]=A*o*a-l*c*h):"XZY"===t&&(i[0]=l*o*a-A*c*h,i[1]=A*c*a-l*o*h,i[2]=A*o*h+l*c*a,i[3]=A*o*a+l*c*h),i},mat4ToQuaternion(e,t=V.vec4()){const i=e[0],s=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=i+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-s)*h):i>A&&i>c?(h=2*Math.sqrt(1+i-A-c),t[3]=(l-o)/h,t[0]=.25*h,t[1]=(s+n)/h,t[2]=(r+a)/h):A>c?(h=2*Math.sqrt(1+A-i-c),t[3]=(r-a)/h,t[0]=(s+n)/h,t[1]=.25*h,t[2]=(o+l)/h):(h=2*Math.sqrt(1+c-i-A),t[3]=(n-s)/h,t[0]=(r+a)/h,t[1]=(o+l)/h,t[2]=.25*h),t},vec3PairToQuaternion(e,t,i=V.vec4()){const s=Math.sqrt(V.dotVec3(e,e)*V.dotVec3(t,t));let r=s+V.dotVec3(e,t);return r<1e-8*s?(r=0,Math.abs(e[0])>Math.abs(e[2])?(i[0]=-e[1],i[1]=e[0],i[2]=0):(i[0]=0,i[1]=-e[2],i[2]=e[1])):V.cross3Vec3(e,t,i),i[3]=r,V.normalizeQuaternion(i)},angleAxisToQuaternion(e,t=V.vec4()){const i=e[3]/2,s=Math.sin(i);return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=Math.cos(i),t},quaternionToEuler:(()=>{const e=new D(16);return(t,i,s)=>(s=s||V.vec3(),V.quaternionToRotationMat4(t,e),V.mat4ToEuler(e,i,s),s)})(),mulQuaternions(e,t,i=V.vec4()){const s=e[0],r=e[1],n=e[2],A=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return i[0]=A*o+s*c+r*l-n*a,i[1]=A*a+r*c+n*o-s*l,i[2]=A*l+n*c+s*a-r*o,i[3]=A*c-s*o-r*a-n*l,i},vec3ApplyQuaternion(e,t,i=V.vec3()){const s=t[0],r=t[1],n=t[2],A=e[0],o=e[1],a=e[2],l=e[3],c=l*s+o*n-a*r,h=l*r+a*s-A*n,u=l*n+A*r-o*s,d=-A*s-o*r-a*n;return i[0]=c*l+d*-A+h*-a-u*-o,i[1]=h*l+d*-o+u*-A-c*-a,i[2]=u*l+d*-a+c*-o-h*-A,i},quaternionToMat4(e,t){t=V.identityMat4(t);const i=e[0],s=e[1],r=e[2],n=e[3],A=2*i,o=2*s,a=2*r,l=A*n,c=o*n,h=a*n,u=A*i,d=o*i,f=a*i,p=o*s,g=a*s,m=a*r;return t[0]=1-(p+m),t[1]=d+h,t[2]=f-c,t[4]=d-h,t[5]=1-(u+m),t[6]=g+l,t[8]=f+c,t[9]=g-l,t[10]=1-(u+p),t},quaternionToRotationMat4(e,t){const i=e[0],s=e[1],r=e[2],n=e[3],A=i+i,o=s+s,a=r+r,l=i*A,c=i*o,h=i*a,u=s*o,d=s*a,f=r*a,p=n*A,g=n*o,m=n*a;return t[0]=1-(u+f),t[4]=c-m,t[8]=h+g,t[1]=c+m,t[5]=1-(l+f),t[9]=d-p,t[2]=h-g,t[6]=d+p,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 i=V.lenVec4([e[0],e[1],e[2],e[3]]);return t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i,t[3]=e[3]/i,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)=>V.normalizeQuaternion(V.conjugateQuaternion(e,t)),quaternionToAngleAxis(e,t=V.vec4()){const i=(e=V.normalizeQuaternion(e,O))[3],s=2*Math.acos(i),r=Math.sqrt(1-i*i);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]=s,t},AABB3:e=>new D(e||6),AABB2:e=>new D(e||4),OBB3:e=>new D(e||32),OBB2:e=>new D(e||16),Sphere3:(e,t,i,s)=>new D([e,t,i,s]),transformOBB3(e,t,i=t){let s;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],f=e[6],p=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(s=0;s<r;s+=4)n=t[s+0],A=t[s+1],o=t[s+2],i[s+0]=a*n+u*A+g*o+B,i[s+1]=l*n+d*A+m*o+y,i[s+2]=c*n+f*A+_*o+w,i[s+3]=h*n+p*A+b*o+v;return i},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 D(3),t=new D(3),i=new D(3);return s=>(e[0]=s[0],e[1]=s[1],e[2]=s[2],t[0]=s[3],t[1]=s[4],t[2]=s[5],V.subVec3(t,e,i),Math.abs(V.lenVec3(i)))})(),getAABB3DiagPoint:(()=>{const e=new D(3),t=new D(3),i=new D(3);return(s,r)=>{e[0]=s[0],e[1]=s[1],e[2]=s[2],t[0]=s[3],t[1]=s[4],t[2]=s[5];const n=V.subVec3(t,e,i),A=r[0]-s[0],o=s[3]-r[0],a=r[1]-s[1],l=s[4]-r[1],c=r[2]-s[2],h=s[5]-r[2];return n[0]+=A>o?A:o,n[1]+=a>l?a:l,n[2]+=c>h?c:h,Math.abs(V.lenVec3(n))}})(),getAABB3Area:e=>(e[3]-e[0])*(e[4]-e[1])*(e[5]-e[2]),getAABB3Center(e,t){const i=t||V.vec3();return i[0]=(e[0]+e[3])/2,i[1]=(e[1]+e[4])/2,i[2]=(e[2]+e[5])/2,i},getAABB2Center(e,t){const i=t||V.vec2();return i[0]=(e[2]+e[0])/2,i[1]=(e[3]+e[1])/2,i},collapseAABB3:(e=V.AABB3())=>(e[0]=V.MAX_DOUBLE,e[1]=V.MAX_DOUBLE,e[2]=V.MAX_DOUBLE,e[3]=V.MIN_DOUBLE,e[4]=V.MIN_DOUBLE,e[5]=V.MIN_DOUBLE,e),AABB3ToOBB3:(e,t=V.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 D(3);return(t,i,s)=>{i=i||V.AABB3();let r,n,A,o=V.MAX_DOUBLE,a=V.MAX_DOUBLE,l=V.MAX_DOUBLE,c=V.MIN_DOUBLE,h=V.MIN_DOUBLE,u=V.MIN_DOUBLE;for(let i=0,d=t.length;i<d;i+=3)s?(e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],V.decompressPosition(e,s,e),r=e[0],n=e[1],A=e[2]):(r=t[i+0],n=t[i+1],A=t[i+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 i[0]=o,i[1]=a,i[2]=l,i[3]=c,i[4]=h,i[5]=u,i}})(),OBB3ToAABB3(e,t=V.AABB3()){let i,s,r,n=V.MAX_DOUBLE,A=V.MAX_DOUBLE,o=V.MAX_DOUBLE,a=V.MIN_DOUBLE,l=V.MIN_DOUBLE,c=V.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t+=4)i=e[t+0],s=e[t+1],r=e[t+2],i<n&&(n=i),s<A&&(A=s),r<o&&(o=r),i>a&&(a=i),s>l&&(l=s),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=V.AABB3()){let i,s,r,n=V.MAX_DOUBLE,A=V.MAX_DOUBLE,o=V.MAX_DOUBLE,a=V.MIN_DOUBLE,l=V.MIN_DOUBLE,c=V.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t++)i=e[t][0],s=e[t][1],r=e[t][2],i<n&&(n=i),s<A&&(A=s),r<o&&(o=r),i>a&&(a=i),s>l&&(l=s),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 D(3);return(t,i)=>{i=i||V.vec4();let s,r=0,n=0,A=0;const o=t.length;for(s=0;s<o;s++)r+=t[s][0],n+=t[s][1],A+=t[s][2];i[0]=r/o,i[1]=n/o,i[2]=A/o;let a,l=0;for(s=0;s<o;s++)a=Math.abs(V.lenVec3(V.subVec3(t[s],i,e))),a>l&&(l=a);return i[3]=l,i}})(),positions3ToSphere3:(()=>{const e=new D(3),t=new D(3);return(i,s)=>{s=s||V.vec4();let r,n=0,A=0,o=0;const a=i.length;let l=0;for(r=0;r<a;r+=3)n+=i[r],A+=i[r+1],o+=i[r+2];const c=a/3;let h;for(s[0]=n/c,s[1]=A/c,s[2]=o/c,r=0;r<a;r+=3)e[0]=i[r],e[1]=i[r+1],e[2]=i[r+2],h=Math.abs(V.lenVec3(V.subVec3(e,s,t))),h>l&&(l=h);return s[3]=l,s}})(),OBB3ToSphere3:(()=>{const e=new D(3),t=new D(3);return(i,s)=>{s=s||V.vec4();let r,n=0,A=0,o=0;const a=i.length,l=a/4;for(r=0;r<a;r+=4)n+=i[r+0],A+=i[r+1],o+=i[r+2];s[0]=n/l,s[1]=A/l,s[2]=o/l;let c,h=0;for(r=0;r<a;r+=4)e[0]=i[r+0],e[1]=i[r+1],e[2]=i[r+2],c=Math.abs(V.lenVec3(V.subVec3(e,s,t))),c>h&&(h=c);return s[3]=h,s}})(),getSphere3Center:(e,t=V.vec3())=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t),getPositionsCenter(e,t=V.vec3()){let i=0,s=0,r=0;for(var n=0,A=e.length;n<A;n+=3)i+=e[n+0],s+=e[n+1],r+=e[n+2];const o=e.length/3;return t[0]=i/o,t[1]=s/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 i,s,r,n=0,A=t.length;n<A;n+=3)i=t[n],s=t[n+1],r=t[n+2],e[0]>i&&(e[0]=i),e[1]>s&&(e[1]=s),e[2]>r&&(e[2]=r),e[3]<i&&(e[3]=i),e[4]<s&&(e[4]=s),e[5]<r&&(e[5]=r);return e},collapseAABB2:(e=V.AABB2())=>(e[0]=V.MAX_DOUBLE,e[1]=V.MAX_DOUBLE,e[2]=V.MIN_DOUBLE,e[3]=V.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,i){let s,r;e[0]>0?(s=e[0]*i[0],r=e[0]*i[3]):(s=e[0]*i[3],r=e[0]*i[0]),e[1]>0?(s+=e[1]*i[1],r+=e[1]*i[4]):(s+=e[1]*i[4],r+=e[1]*i[1]),e[2]>0?(s+=e[2]*i[2],r+=e[2]*i[5]):(s+=e[2]*i[5],r+=e[2]*i[2]);if(s<=-t&&r<=-t)return-1;return s>=-t&&r>=-t?1:0},OBB3ToAABB2(e,t=V.AABB2()){let i,s,r,n,A=V.MAX_DOUBLE,o=V.MAX_DOUBLE,a=V.MIN_DOUBLE,l=V.MIN_DOUBLE;for(let t=0,c=e.length;t<c;t+=4)i=e[t+0],s=e[t+1],r=e[t+3]||1,n=1/r,i*=n,s*=n,i<A&&(A=i),s<o&&(o=s),i>a&&(a=i),s>l&&(l=s);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,i,s=e){const r=.5*(e[0]+1),n=.5*(e[1]+1),A=.5*(e[2]+1),o=.5*(e[3]+1);return s[0]=Math.floor(r*t),s[1]=i-Math.floor(o*i),s[2]=Math.floor(A*t),s[3]=i-Math.floor(n*i),s},tangentQuadraticBezier:(e,t,i,s)=>2*(1-e)*(i-t)+2*e*(s-i),tangentQuadraticBezier3:(e,t,i,s,r)=>-3*t*(1-e)*(1-e)+3*i*(1-e)*(1-e)-6*e*i*(1-e)+6*e*s*(1-e)-3*e*e*s+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,i,s,r){const n=.5*(i-e),A=.5*(s-t),o=r*r;return(2*t-2*i+n+A)*(r*o)+(-3*t+3*i-2*n-A)*o+n*r+t},b2p0(e,t){const i=1-e;return i*i*t},b2p1:(e,t)=>2*(1-e)*e*t,b2p2:(e,t)=>e*e*t,b2(e,t,i,s){return this.b2p0(e,t)+this.b2p1(e,i)+this.b2p2(e,s)},b3p0(e,t){const i=1-e;return i*i*i*t},b3p1(e,t){const i=1-e;return 3*i*i*e*t},b3p2:(e,t)=>3*(1-e)*e*e*t,b3p3:(e,t)=>e*e*e*t,b3(e,t,i,s,r){return this.b3p0(e,t)+this.b3p1(e,i)+this.b3p2(e,s)+this.b3p3(e,r)},triangleNormal(e,t,i,s=V.vec3()){const r=t[0]-e[0],n=t[1]-e[1],A=t[2]-e[2],o=i[0]-e[0],a=i[1]-e[1],l=i[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?(s[0]=0,s[1]=0,s[2]=0):(s[0]=c/d,s[1]=h/d,s[2]=u/d),s},rayTriangleIntersect:(()=>{const e=new D(3),t=new D(3),i=new D(3),s=new D(3),r=new D(3);return(n,A,o,a,l,c)=>{c=c||V.vec3();const h=V.subVec3(a,o,e),u=V.subVec3(l,o,t),d=V.cross3Vec3(A,u,i),f=V.dotVec3(h,d);if(f<1e-6)return null;const p=V.subVec3(n,o,s),g=V.dotVec3(p,d);if(g<0||g>f)return null;const m=V.cross3Vec3(p,h,r),_=V.dotVec3(A,m);if(_<0||g+_>f)return null;const b=V.dotVec3(u,m)/f;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 D(3),t=new D(3),i=new D(3),s=new D(3);return(r,n,A,o,a,l)=>{l=l||V.vec3(),n=V.normalizeVec3(n,e);const c=V.subVec3(o,A,t),h=V.subVec3(a,A,i),u=V.cross3Vec3(c,h,s);V.normalizeVec3(u,u);const d=-V.dotVec3(A,u),f=-(V.dotVec3(r,u)+d)/V.dotVec3(n,u);return l[0]=r[0]+f*n[0],l[1]=r[1]+f*n[1],l[2]=r[2]+f*n[2],l}})(),cartesianToBarycentric:(()=>{const e=new D(3),t=new D(3),i=new D(3);return(s,r,n,A,o)=>{const a=V.subVec3(A,r,e),l=V.subVec3(n,r,t),c=V.subVec3(s,r,i),h=V.dotVec3(a,a),u=V.dotVec3(a,l),d=V.dotVec3(a,c),f=V.dotVec3(l,l),p=V.dotVec3(l,c),g=h*f-u*u;if(0===g)return null;const m=1/g,_=(f*d-u*p)*m,b=(h*p-u*d)*m;return o[0]=1-_-b,o[1]=b,o[2]=_,o}})(),barycentricInsideTriangle(e){const t=e[1],i=e[2];return i>=0&&t>=0&&i+t<1},barycentricToCartesian(e,t,i,s,r=V.vec3()){const n=e[0],A=e[1],o=e[2];return r[0]=t[0]*n+i[0]*A+s[0]*o,r[1]=t[1]*n+i[1]*A+s[1]*o,r[2]=t[2]*n+i[2]*A+s[2]*o,r},mergeVertices(e,t,i,s){const r={},n=[],A=[],o=t?[]:null,a=i?[]:null,l=[];let c,h,u,d;const f=1e4;let p,g,m=0;for(p=0,g=e.length;p<g;p+=3)c=e[p],h=e[p+1],u=e[p+2],d=`${Math.round(c*f)}_${Math.round(h*f)}_${Math.round(u*f)}`,void 0===r[d]&&(r[d]=A.length/3,A.push(c),A.push(h),A.push(u),t&&(o.push(t[p]),o.push(t[p+1]),o.push(t[p+2])),i&&(a.push(i[m]),a.push(i[m+1]))),n[p/3]=r[d],m+=2;for(p=0,g=s.length;p<g;p++)l[p]=n[s[p]];const _={positions:A,indices:l};return o&&(_.normals=o),a&&(_.uv=a),_},buildNormals:(()=>{const e=new D(3),t=new D(3),i=new D(3),s=new D(3),r=new D(3),n=new D(3);return(A,o,a)=>{let l,c;const h=new Array(A.length/3);let u,d,f,p,g,m,_;for(l=0,c=o.length;l<c;l+=3){u=o[l],d=o[l+1],f=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],i[0]=A[3*f],i[1]=A[3*f+1],i[2]=A[3*f+2],V.subVec3(t,e,s),V.subVec3(i,e,r);const a=V.vec3();V.normalizeVec3(V.cross3Vec3(s,r,n),a),h[u]||(h[u]=[]),h[d]||(h[d]=[]),h[f]||(h[f]=[]),h[u].push(a),h[d].push(a),h[f].push(a)}for(a=a&&a.length===A.length?a:new Float32Array(A.length),l=0,c=h.length;l<c;l++){p=h[l].length,g=0,m=0,_=0;for(let e=0;e<p;e++)g+=h[l][e][0],m+=h[l][e][1],_+=h[l][e][2];a[3*l]=g/p,a[3*l+1]=m/p,a[3*l+2]=_/p}return a}})(),buildTangents:(()=>{const e=new D(3),t=new D(3),i=new D(3),s=new D(3),r=new D(3),n=new D(3),A=new D(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),f=l.subarray(2*u,2*u+2);u=a[h+1];const p=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=V.subVec3(p,d,e),B=V.subVec3(m,d,t),y=V.subVec2(g,f,i),w=V.subVec2(_,f,s),v=1/(y[0]*w[1]-y[1]*w[0]),C=V.mulVec3Scalar(V.subVec3(V.mulVec3Scalar(b,w[1],r),V.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,i){const s=t.length,r=i?new Uint16Array(9*s):new Float32Array(9*s),n=new Uint8Array(12*s);let A,o,a,l,c,h,u=0,d=0,f=0;for(let i=0;i<s;i+=3)h=u>>24&255,c=u>>16&255,l=u>>8&255,a=255&u,o=t[i],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[f++]=a,n[f++]=l,n[f++]=c,n[f++]=h,o=t[i+1],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[f++]=a,n[f++]=l,n[f++]=c,n[f++]=h,o=t[i+2],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[f++]=a,n[f++]=l,n[f++]=c,n[f++]=h,u++;return{positions:r,colors:n}},faceToVertexNormals(e,t,i={}){const s=i.smoothNormalsAngleThreshold||20,r={},n=[],A={};let o,a,l,c,h;const u=1e4;let d,f,p,g,m,_;for(f=0,g=e.length;f<g;f+=3){d=f/3,a=e[f],l=e[f+1],c=e[f+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 i=V.normalizeVec3([t[f],t[f+1],t[f+2]]);n[d]=i,o=V.vec4([i[0],i[1],i[2],1]),A[d]=o}for(h in r)if(r.hasOwnProperty(h)){const e=r[h],t=e.length;for(f=0;f<t;f++){const i=e[f];for(o=A[i],p=0;p<t;p++){if(f===p)continue;const t=e[p];m=n[i],_=n[t];Math.abs(V.angleVec3(m,_)/V.DEGTORAD)<s&&(o[0]+=_[0],o[1]+=_[1],o[2]+=_[2],o[3]+=1)}}}for(f=0,g=t.length;f<g;f+=3)o=A[f/3],t[f+0]=o[0]/o[3],t[f+1]=o[1]/o[3],t[f+2]=o[2]/o[3]},transformRay:(()=>{const e=new D(4),t=new D(4);return(i,s,r,n,A)=>{e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=1,V.transformVec4(i,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],V.transformVec3(i,e,t),V.normalizeVec3(t),A[0]=t[0],A[1]=t[1],A[2]=t[2]}})(),canvasPosToWorldRay:(()=>{const e=new D(16),t=new D(4),i=new D(4),s=(t,i,s,r,n)=>{n[0]=t,n[1]=i,n[2]=s,n[3]=1,V.transformVec4(e,n,n),r||V.mulVec4Scalar(n,1/n[3])};return(r,n,A,o,a,l,c)=>{const h="ortho"===o;V.mulMat4(A,n,e),V.inverseMat4(e,e);const u=2*a[0]/r.clientWidth-1,d=1-2*a[1]/r.clientHeight;s(u,d,-1,h,t),s(u,d,1,h,i),l[0]=t[0],l[1]=t[1],l[2]=t[2],V.subVec3(i,t,c),V.normalizeVec3(c)}})(),canvasPosToLocalRay:(()=>{const e=new D(3),t=new D(3);return(i,s,r,n,A,o,a,l)=>{V.canvasPosToWorldRay(i,s,r,n,o,e,t),V.worldRayToLocalRay(A,e,t,a,l)}})(),worldRayToLocalRay:(()=>{const e=new D(16),t=new D(4),i=new D(4);return(s,r,n,A,o)=>{const a=V.inverseMat4(s,e);t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,V.transformVec4(a,t,i),A[0]=i[0],A[1]=i[1],A[2]=i[2],V.transformVec3(a,n,o)}})(),buildKDTree:(()=>{const e=new Float32Array;function t(i,s,r,n){const A=new D(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=i.length;a<l;++a){var c=3*i[a];for(let e=0;e<3;++e){const t=3*s[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(i.length<20||n>10)return o.triangles=i,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(i.length);let f=0;const p=new Array(i.length);let g=0;for(a=0,l=i.length;a<l;++a){const e=s[c=3*i[a]],t=3*s[c+1],n=3*s[c+2];r[3*e+h]<=u||r[t+h]<=u||r[n+h]<=u?d[f++]=i[a]:p[g++]=i[a]}return d.length=f,p.length=g,o.left=t(d,s,r,n+1),o.right=t(p,s,r,n+1),o}return(e,i)=>{const s=e.length/3,r=new Array(s);for(let e=0;e<s;++e)r[e]=e;return t(r,e,i,0)}})(),decompressPosition(e,t,i){(i=i||e)[0]=e[0]*t[0]+t[12],i[1]=e[1]*t[5]+t[13],i[2]=e[2]*t[10]+t[14]},decompressPositions(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[12],i[s+1]=e[s+1]*t[5]+t[13],i[s+2]=e[s+2]*t[10]+t[14];return i},decompressUV(e,t,i){i[0]=e[0]*t[0]+t[6],i[1]=e[1]*t[4]+t[7]},decompressUVs(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[6],i[s+1]=e[s+1]*t[4]+t[7];return i},octDecodeVec2(e,t){let i=e[0],s=e[1];i=(2*i+1)/255,s=(2*s+1)/255;const r=1-Math.abs(i)-Math.abs(s);r<0&&(i=(1-Math.abs(s))*(i>=0?1:-1),s=(1-Math.abs(i))*(s>=0?1:-1));const n=Math.sqrt(i*i+s*s+r*r);return t[0]=i/n,t[1]=s/n,t[2]=r/n,t},octDecodeVec2s(e,t){for(let i=0,s=0,r=e.length;i<r;i+=2){let r=e[i+0],n=e[i+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[s+0]=r/o,t[s+1]=n/o,t[s+2]=A/o,s+=3}return t}};V.buildEdgeIndices=function(){const e=[],t=[],i=[],s=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=V.vec3(),c=V.vec3(),h=V.vec3(),u=V.vec3(),d=V.vec3(),f=V.vec3(),p=V.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,f=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]=f/3,e[f++]=o,e[f++]=a,e[f++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)s[u]=t[n[u]],i[s[u]]=n[u]}(g,m),function(t,i){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*s[g],m=3*s[g+1],_=3*s[g+2];i?(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],V.decompressPosition(A,i,l),V.decompressPosition(o,i,c),V.decompressPosition(a,i,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]),V.subVec3(h,c,u),V.subVec3(l,c,d),V.cross3Vec3(u,d,f),V.normalizeVec3(f,p);const b=r[n]||(r[n]={normal:V.vec3()});b.normal[0]=p[0],b.normal[1]=p[1],b.normal[2]=p[2],n++}}(m.length,_);const B=[],y=Math.cos(V.DEGTORAD*b),w={};let v,C,M,E,F,U,x,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let i=0;i<3;i++)v=s[e+i],C=s[e+(i+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)U=w[F],void 0!==U.face2&&(x=r[U.face1].normal,I=r[U.face2].normal,T=V.dotVec3(x,I),T>y)||(P=i[U.index1],S=i[U.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}(),V.planeClipsPositions3=function(e,t,i,s=3){for(let r=0,n=i.length;r<n;r+=s){if(k[0]=i[r+0]-e[0],k[1]=i[r+1]-e[1],k[2]=i[r+2]-e[2],k[0]*t[0]+k[1]*t[1]+k[2]*t[2]<0)return!0}return!1},V.planeIntersectsAABB3=(e,t)=>{const i=[t[0],t[1],t[2]],s=[t[3],t[4],t[5]],r=[[i[0],i[1],i[2]],[s[0],i[1],i[2]],[i[0],s[1],i[2]],[s[0],s[1],i[2]],[i[0],i[1],s[2]],[s[0],i[1],s[2]],[i[0],s[1],s[2]],[s[0],s[1],s[2]]];let n=!1,A=!1;for(const t of r){const i=e.dist+V.dotVec3(e.dir,t);if(i>0&&(n=!0),i<0&&(A=!0),n&&A)return!0}return!1},V.makeSectionPlaneSlicer=function(){const e=V.vec2(),t=V.vec2(),i=V.vec2(),s=V.vec2(),r=V.vec3(),n=V.vec3(),A=V.vec3();V.vec3();const a=[V.vec3(),V.vec3(),V.vec3()],l=[null,null,null],c=[null,null,null],h=[null,null,null],u=[1,0,0],d=[0,1,0],f=[0,0,1],p=function(){const e=V.vec3();return(t,i)=>V.sqLenVec3(V.subVec3(t,i,e))}(),g=e=>{const t=[];for(let i=0;i<e;++i)t.push(i);return t},m=(e,t,i)=>(i[1]-e[1])*(t[0]-e[0])>(t[1]-e[1])*(i[0]-e[0]);return function(_){const b=V.vec3ApplyQuaternion(_.quaternion,u,V.vec3()),B=V.vec3ApplyQuaternion(_.quaternion,d,V.vec3()),y=V.vec3ApplyQuaternion(_.quaternion,f,V.vec3());return function(u,d={}){const f=V.subVec3(u.origin,_.pos,V.vec3()),w=V.dotVec3(y,f),v=[],C=[null],M=(e,t)=>{const i=C.length,s=new Float64Array(5);return s.set(e),t&&(V.addVec3(f,e,r),s[3]=-V.dotVec3(b,r),s[4]=V.dotVec3(B,r)),C.push(s),i},E=(e,t)=>{const i=C[e];return t[0]=i[3],t[1]=i[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],i),n=E(l[t],s);if(m(A,r,n)!==m(h,r,n)&&m(A,h,r)!==m(A,h,n))return!1;const[a,d]=r,[f,p]=n,g=o-a,_=c-d,b=f-a,B=p-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!=p>c&&g<_*b/B&&(u=!u)}if(!u)return!1}return!0},U={indices:[],normals:[]},x=!d.onlyPosSliceWithUV&&{indices:[],normals:[]},I=(e,t,i)=>{if(e){const s=C[t[0]];i||=V.normalizeVec3(V.cross3Vec3(V.subVec3(C[t[1]],s,r),V.subVec3(C[t[2]],s,n),r),r);for(let s=0;s<3;++s)e.indices.push(t[s]),e.normals.push(i[0],i[1],i[2])}},T=(e,t)=>{const i=3*u.indices[e];return t[0]=u.positions[i+0],t[1]=u.positions[i+1],t[2]=u.positions[i+2],t};for(let e=0;e<u.indices.length;e+=3){const t=T(e+0,a[0]),i=T(e+1,a[1]),s=T(e+2,a[2]);if(V.compareVec3(t,i)||V.compareVec3(i,s)||V.compareVec3(s,t))continue;const n=w+V.dotVec3(y,t),A=w+V.dotVec3(y,i),o=w+V.dotVec3(y,s);if(0!==n||0!==A||0!==o){const e=n*A<=0&&M(V.lerpVec3(n/(n-A),0,1,t,i,r),!0),a=A*o<=0&&M(V.lerpVec3(A/(A-o),0,1,i,s,r),!0),u=o*n<=0&&M(V.lerpVec3(o/(o-n),0,1,s,t,r),!0),f=!d.onlyPosSliceWithUV&&c;if(f&&(f[0]=M(t),f[1]=M(i),f[2]=M(s)),e?a||u:a&&u){if(v.push(e?[e,a||u]:[a,u]),f)if(0===n&&0===A)I(o>0?U:x,f);else if(0===n&&0===o)I(A>0?U:x,f);else if(0===A&&0===o)I(n>0?U:x,f);else{const t=(e?n:A)>0,i=t?U:x,s=t?x:U,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(i,[f[o[0]],r[o[0]],f[o[2]]]),I(i,[r[o[0]],r[o[1]],f[o[2]]]),I(s,[r[o[0]],f[o[1]],r[o[1]]])):(I(i,[f[o[0]],r[o[0]],r[o[2]]]),I(s,[r[o[0]],f[o[1]],f[o[2]]]),I(s,[r[o[0]],f[o[2]],r[o[2]]]))}}else f&&(n>=0&&A>=0&&o>=0?I(U,f):n<=0&&A<=0&&o<=0&&I(x,f))}}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]],i={distSq:p(C[e[0]],t),idx:-1,side:-1};if(v.forEach(((e,s)=>{const r=p(C[e[0]],t),n=p(C[e[1]],t),A=Math.min(r,n);i.distSq>A&&(i.distSq=A,i.idx=s,i.side=n<r?1:0)})),!(i.distSq<1e-20)){P.pop();break}{const s=i.idx>=0&&v[i.idx];if(C[s?s[i.side]:e[0]]=t,!s)break;{v.splice(i.idx,1);const t=s[1-i.side];if(!(p(C[t],C[e[0]])>1e-20))break;e.push(t)}}}}const S=P.filter((e=>e.length>2)).map(((i,s)=>{let r=0;const n=V.collapseAABB2(V.AABB2());for(let s=0;s<i.length;s++)E(i[s],e),V.expandAABB2Point2(n,e),E(i[(s+1)%i.length],t),r+=e[0]*t[1]-t[0]*e[1];return{boundingBox:n,doubleArea:Math.abs(r),endPoints:i}})).sort(((e,t)=>t.doubleArea-e.doubleArea));for(;S.length>0;){const t=[],i=[],s=s=>s.endPoints.forEach((s=>{E(s,e),t.push(e[0],e[1]),i.push(s)})),r=S.shift();s(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,s(e),a.push(e),S.splice(c,1)):++c}const h=o(t,a.map((e=>e.index)));for(let e=0;e<h.length;e+=3){const t=l;t[0]=i[h[e+0]],t[1]=i[h[e+1]],t[2]=i[h[e+2]];const s=C[t[0]];V.subVec3(C[t[1]],s,n),V.subVec3(C[t[2]],s,A),V.normalizeVec3(V.cross3Vec3(n,A,A),A);const r=V.dotVec3(A,y)<=0;I(r?U:x,t,A);const o=t[0];t[0]=t[2],t[2]=o,I(r?x:U,t,V.negateVec3(A,A))}}const D=e=>e&&e.indices.length>0&&function(){const t=[],i=d.onlyPosSliceWithUV&&[];return e.indices.forEach((e=>{const s=C[e];t.push(s[0],s[1],s[2]),i&&i.push(s[3],s[4])})),{indices:g(e.indices.length),positions:t,normals:e.normals,uv:i}}();return{pos:D(U),neg:D(x)}}}}();const L=new Float32Array(3);class H{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 i=e.objects[t];this._insertEntity(this._root,i,1)}this._needsRebuild=!1}_insertEntity(e,t,i){const s=t.aabb;if(i>=this._maxTreeDepth)return e.entities=e.entities||[],void e.entities.push(t);if(e.left&&V.containsAABB3(e.left.aabb,s))return void this._insertEntity(e.left,t,i+1);if(e.right&&V.containsAABB3(e.right.aabb,s))return void this._insertEntity(e.right,t,i+1);const r=e.aabb;L[0]=r[3]-r[0],L[1]=r[4]-r[1],L[2]=r[5]-r[2];let n=0;if(L[1]>L[n]&&(n=1),L[2]>L[n]&&(n=2),!e.left){const A=r.slice();if(A[n+3]=(r[n]+r[n+3])/2,e.left={aabb:A},V.containsAABB3(A,s))return void this._insertEntity(e.left,t,i+1)}if(!e.right){const A=r.slice();if(A[n]=(r[n]+r[n+3])/2,e.right={aabb:A},V.containsAABB3(A,s))return void this._insertEntity(e.right,t,i+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}}class N{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 G={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 j=[["0",10],["A",26],["a",26],["_",1],["$",1]].map((function(e){for(var t=[],i=e[0].charCodeAt(0),s=i+e[1],r=i;r<s;++r)t.push(r);return String.fromCharCode.apply(null,t)})).join("");function W(e,t){return(t&&4!==t?[0,6]:[0,6,12,18]).map((function(t){return j.substr(parseInt(e/(1<<t))%64,1)})).reverse().join("")}const z=function(){for(var e={},t=window.location.search.substring(1).split("&"),i=0;i<t.length;i++){var s=t[i].split("=");if(void 0===e[s[0]])e[s[0]]=decodeURIComponent(s[1]);else if("string"==typeof e[s[0]]){var r=[e[s[0]],decodeURIComponent(s[1])];e[s[0]]=r}else e[s[0]].push(decodeURIComponent(s[1]))}return e}();const X={xmlToJson:function e(t,i){if(t.nodeType===t.TEXT_NODE){var s=t.nodeValue;if(null===s.match(/^\s+$/))return s}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[i[A.nodeName]||A.nodeName]=A.nodeValue}for(var o=0;o<t.childNodes.length;o++){(n=e(t.childNodes[o],i))&&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 W(t[0],2)+[1,4,7,10,13].map((function(e){return W((t[e]<<16)+(t[e+1]<<8)+t[e+2])})).join("")},findNodeOfType:function(e,t){var i=[],s=function(e){e.type===t&&i.push(e),(e.children||[]).forEach((function(e){s(e)}))};return s(e),i},timeout:function(e){return new Promise((function(t,i){setTimeout(t,e)}))},httpRequest:function(e){return new Promise((function(t,i){var s=new XMLHttpRequest;s.open(e.method||"GET",e.url,!0),s.onload=function(e){4===s.readyState&&(200===s.status?t(s.responseXML):i(s.statusText))},s.send(null)}))},loadJSON:function(e,t,i){var s=e=>{};t=t||s,i=i||s;var r=new XMLHttpRequest;r.overrideMimeType("application/json"),r.open("GET",e,!0),r.addEventListener("load",(function(e){var s=e.target.response;if(200===this.status){var r;try{r=JSON.parse(s)}catch(e){i(`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(s))}catch(e){i(`utils.loadJSON(): Failed to parse JSON response - ${e}`)}}else i(e)}),!1),r.addEventListener("error",(function(e){i(e)}),!1),r.send(null)},loadArraybuffer:function(e,t,i){var s=e=>{};t=t||s,i=i||s;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),i=new Uint8Array(e);for(var A=0;A<n.length;A++)i[A]=n.charCodeAt(A);ie.scheduleTask((()=>{t(e)}))}catch(e){ie.scheduleTask((()=>{i(e)}))}}else{const s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i("loadArrayBuffer error : "+s.response))},s.send(null)}},queryString:z,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 X.isString(e)||X.isNumeric(e)},isSameComponent:function(e,t){return!(!e||!t)&&(X.isNumeric(e)||X.isString(e)?`${e}`:e.id)===(X.isNumeric(t)||X.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 X.apply(e,{})},apply:function(e,t){for(const i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},apply2:function(e,t){for(const i in e)e.hasOwnProperty(i)&&void 0!==e[i]&&null!==e[i]&&(t[i]=e[i]);return t},applyIf:function(e,t){for(const i in e)e.hasOwnProperty(i)&&(void 0!==t[i]&&null!==t[i]||(t[i]=e[i]));return t},isEmptyObject:function(e){for(const t in e)if(e.hasOwnProperty(t))return!1;return!0},inQuotes:function(e){return X.isNumeric(e)?`${e}`:`'${e}'`},concat:function(e,t){const i=new e.constructor(e.length+t.length);return i.set(e),i.set(t,e.length),i},flattenParentChildHierarchy:function(e){var t=[];return function e(i){i.id=i.uuid,delete i.oid,t.push(i);var s=i.children;if(s)for(var r=0,n=s.length;r<n;r++){s[r].parent=i.id,e(s[r])}i.children=[]}(e),t}},K={},Z=new e,J=new N,Y={sceneId:null,time:null,startTime:null,prevTime:null,deltaTime:null},$=[];let q,ee=0,te=0;const ie=new function(){this.version="1.0.0",this.scenes={},this._superTypes={},this._addScene=function(e){if(e.id){if(ie.scenes[e.id])return void console.error(`[ERROR] Scene ${X.inQuotes(e.id)} already exists`)}else e.id=Z.addItem({});ie.scenes[e.id]=e;const t=e.ticksPerOcclusionTest,i=e.ticksPerRender;K[e.id]={ticksPerOcclusionTest:t,ticksPerRender:i,renderCountdown:i},G.components.scenes++,e.once("destroyed",(()=>{Z.removeItem(e.id),delete ie.scenes[e.id],delete K[e.id],G.components.scenes--}))},this.clear=function(){let e;for(const t in ie.scenes)ie.scenes.hasOwnProperty(t)&&(e=ie.scenes[t],"default.scene"===t?e.clear():(e.destroy(),delete ie.scenes[e.id]))},this.scheduleTask=function(e,t=null){J.push(e),J.push(t)},this.runTasks=function(e=-1){let t,i,s=(new Date).getTime(),r=0;for(;J.length>0&&(e<0||s<e);)t=J.shift(),i=J.shift(),i?t.call(i):t(),s=(new Date).getTime(),r++;return r},this.getNumTasks=function(){return J.length}},se=function(){let e=Date.now();if(q=e-ee,ee>0&&q>0){var t=1e3/q;te+=t,$.push(t),$.length>=30&&(te-=$.shift()),G.frame.fps=Math.round(te/$.length)}for(let e in ie.scenes)ie.scenes[e].compile();ne(e),ee=e};!function(e,t){let i=Date.now()+t;(function s(){const r=Date.now()-i;e(),i+=t,setTimeout(s,Math.max(0,t-r))})()}((()=>{se()}),100);const re=function(){let e=Date.now();if(q=e-ee,ee>0&&q>0){var t=1e3/q;te+=t,$.push(t),$.length>=30&&(te-=$.shift()),G.frame.fps=Math.round(te/$.length)}ne(e),function(e){for(var t in Y.time=e,ie.scenes)if(ie.scenes.hasOwnProperty(t)){var i=ie.scenes[t];Y.sceneId=t,Y.startTime=i.startTime,Y.deltaTime=null!=Y.prevTime?Y.time-Y.prevTime:0,i.fire("tick",Y,!0)}Y.prevTime=e}(e),function(){const e=ie.scenes,t=!1;let i,s,r,n,A;for(A in e)e.hasOwnProperty(A)&&(i=e[A],s=K[A],s||(s=K[A]={}),r=i.ticksPerOcclusionTest,s.ticksPerOcclusionTest!==r&&(s.ticksPerOcclusionTest=r,s.renderCountdown=r),--i.occlusionTestCountdown<=0&&(i.doOcclusionTest(),i.occlusionTestCountdown=r),n=i.ticksPerRender,s.ticksPerRender!==n&&(s.ticksPerRender=n,s.renderCountdown=n),0==--s.renderCountdown&&(i.render(t),s.renderCountdown=n))}(),void 0!==window.requestPostAnimationFrame?window.requestPostAnimationFrame(se):requestAnimationFrame(re)};function ne(e){const t=ie.runTasks(e+10),i=ie.getNumTasks();G.frame.tasksRun=t,G.frame.tasksScheduled=i,G.frame.tasksBudget=10}re();class Ae{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 Ae))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,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={},this._eventSubsNum={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];let r;if(s)for(const i in s)s.hasOwnProperty(i)&&(r=s[i],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,i,s){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:i,scope:s||this},this._subIdEvents[n]=t;const A=this._events[t];return void 0!==A&&i.call(s||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 i=this._eventSubs[t];i&&(delete i[e],this._eventSubsNum[t]--),this._subIdMap.removeItem(e)}}once(e,t,i){const s=this,r=this.on(e,(function(e){s.off(r),t.call(i||this,e)}),i)}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+" "+X.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 i=e.component;const s=e.sceneDefault,r=e.sceneSingleton,n=e.type,A=e.on,o=!1!==e.recompiles;if(i&&(X.isNumeric(i)||X.isString(i))){const e=i;if(i=this.scene.components[e],!i)return void this.error("Component not found: "+X.inQuotes(e))}if(!i)if(!0===r){const e=this.scene.types[n];for(const t in e)if(e.hasOwnProperty){i=e[t];break}if(!i)return this.error("Scene has no default component for '"+t+"'"),null}else if(!0===s&&(i=this.scene[t],!i))return this.error("Scene has no default component for '"+t+"'"),null;if(i){if(i.scene.id!==this.scene.id)return void this.error("Not in same scene: "+i.type+" "+X.inQuotes(i.id));if(n&&!i.isType(n))return void this.error("Expected a "+n+" type or subtype: "+i.type+" "+X.inQuotes(i.id))}this._attachments||(this._attachments={});const a=this._attached[t];let l,c,h;if(a){if(i&&a.id===i.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 s=e.params.onDetached;s&&(X.isFunction(s)?s(a):s.scope?s.callback.call(s.scope,a):s.callback(a)),e.managingLifecycle&&a.destroy()}if(i){const s={params:e,component:i,subs:[],managingLifecycle:false};s.subs.push(i.once("destroyed",(function(){s.params.component=null,this._attach(s.params)}),this)),o&&s.subs.push(i.on("dirty",(function(){this.fire("dirty",this)}),this)),this._attached[t]=i,this._attachments[i.id]=s;const r=e.onAttached;if(r&&(X.isFunction(r)?r(i):r.scope?r.callback.call(r.scope,i):r.callback(i)),A){let e,t,r,n;for(e in A)if(A.hasOwnProperty(e)){if(t=A[e],X.isFunction(t)?(r=t,n=null):(r=t.callback,n=t.scope),!r)continue;s.subs.push(i.on(e,r,n))}}}return o&&this.fire("dirty",this),this.fire(t,i),i}_checkComponent(e,t){if(!t.isComponent){if(!X.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(!X.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 i=0,s=e.length;i<s;i++)if(e[i]===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():ie.scheduleTask(this._doUpdate,this))}_doUpdate(){this._updateScheduled&&(this._updateScheduled=!1,this._update&&this._update())}scheduleTask(e){ie.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,i,s,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],i=t.component,s=t.subs,r=0,n=s.length;r<n;r++)i.off(s[r]);t.managingLifecycle&&i.destroy()}if(this._ownedComponents)for(e in this._ownedComponents)this._ownedComponents.hasOwnProperty(e)&&(i=this._ownedComponents[e],i.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 oe=V.vec3(),ae=V.vec3(),le=V.mat4();class ce{constructor(){this.normal=V.vec3(),this.offset=0,this.testVertex=V.vec3()}set(e,t,i,s){const r=1/Math.sqrt(e*e+t*t+i*i);this.normal[0]=e*r,this.normal[1]=t*r,this.normal[2]=i*r,this.offset=s*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 he{constructor(){this.planes=[new ce,new ce,new ce,new ce,new ce,new ce]}}function ue(e,t,i){const s=V.mulMat4(i,t,le),r=s[0],n=s[1],A=s[2],o=s[3],a=s[4],l=s[5],c=s[6],h=s[7],u=s[8],d=s[9],f=s[10],p=s[11],g=s[12],m=s[13],_=s[14],b=s[15];e.planes[0].set(o-r,h-a,p-u,b-g),e.planes[1].set(o+r,h+a,p+u,b+g),e.planes[2].set(o-n,h-l,p-d,b-m),e.planes[3].set(o+n,h+l,p+d,b+m),e.planes[4].set(o-A,h-c,p-f,b-_),e.planes[5].set(o+A,h+c,p+f,b+_)}function de(e,t){let i=he.INSIDE;const s=oe,r=ae;s[0]=t[0],s[1]=t[1],s[2]=t[2],r[0]=t[3],r[1]=t[4],r[2]=t[5];const n=[s,r];for(let t=0;t<6;++t){const s=e.planes[t];if(s.normal[0]*n[s.testVertex[0]][0]+s.normal[1]*n[s.testVertex[1]][1]+s.normal[2]*n[s.testVertex[2]][2]+s.offset<0)return he.OUTSIDE;s.normal[0]*n[1-s.testVertex[0]][0]+s.normal[1]*n[1-s.testVertex[1]][1]+s.normal[2]*n[1-s.testVertex[2]][2]+s.offset<0&&(i=he.INTERSECT)}return i}he.INSIDE=0,he.INTERSECT=1,he.OUTSIDE=2;class fe extends Ae{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=V.vec2(),this._canvasMarqueeCorner2=V.vec2(),this._canvasMarquee=V.AABB2(),this._marqueeFrustum=new he,this._marqueeFrustumProjMat=V.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!==fe.PICK_MODE_INSIDE&&e!==fe.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===fe.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=(i,s=he.INTERSECT)=>{if(s===he.INTERSECT&&(s=de(this._marqueeFrustum,i.aabb)),s!==he.OUTSIDE){if(i.entities){const t=i.entities;for(let i=0,s=t.length;i<s;i++){const s=t[i];if(!s.visible)continue;const r=s.aabb;if(this._pickMode===fe.PICK_MODE_INSIDE){de(this._marqueeFrustum,r)===he.INSIDE&&e.push(s.id)}else{de(this._marqueeFrustum,r)!==he.OUTSIDE&&e.push(s.id)}}}i.left&&t(i.left,s),i.right&&t(i.right,s)}};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,i=e.clientHeight,s=e.clientLeft,r=e.clientTop,n=2/t,A=2/i,o=e.clientHeight/e.clientWidth,a=(this._canvasMarquee[0]-s)*n-1,l=(this._canvasMarquee[2]-s)*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);V.frustumMat4(a,l,c*o,h*o,u,1e4,this._marqueeFrustumProjMat),ue(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)}}fe.PICK_MODE_INTERSECTS=0,fe.PICK_MODE_INSIDE=1;class pe extends Ae{constructor(e){super(e.marqueePicker,e);const t=e.marqueePicker,i=t.viewer.scene.canvas.canvas;let s,r,n,A,o,a,l,c=!1,h=!1,u=!1;i.addEventListener("mousedown",(e=>{this.getActive()&&0===e.button&&(l=setTimeout((function(){const n=t.viewer.scene.input;n.keyDown[n.KEY_CTRL]||t.clear(),s=e.pageX,r=e.pageY,o=e.offsetX,t.setMarqueeCorner1([s,r]),c=!0,t.viewer.cameraControl.pointerEnabled=!1,t.setMarqueeVisible(!0),i.style.cursor="crosshair"}),400),h=!0)})),i.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 i=Math.abs(n-s),o=Math.abs(A-r);c=!1,t.viewer.cameraControl.pointerEnabled=!0,u&&(u=!1),(i>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),i.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?fe.PICK_MODE_INSIDE:fe.PICK_MODE_INTERSECTS)))}))}setActive(e){this._active!==e&&(this._active=e,this.fire("active",this._active))}getActive(){return this._active}destroy(){}}class ge{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 i;const s=e=>{if(!this._running)return;i||(i=e);const r=e-i,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(s)};this._running=!0,requestAnimationFrame(s),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 me{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 i=this._messages[this._locale];if(!i)return null;const s=_e(e,i);return s?t?be(s,t):s:null}translatePlurals(e,t,i){const s=this._messages[this._locale];if(!s)return null;let r=_e(e,s);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=be(r,[t]),i&&(r=be(r,i)),r):null}fire(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];if(s)for(const e in s)if(s.hasOwnProperty(e)){s[e].callback(t)}}on(t,i){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let s=this._eventSubs[t];s||(s={},this._eventSubs[t]=s);const r=this._eventSubIDMap.addItem();s[r]={callback:i},this._eventSubEvents[r]=t;const n=this._events[t];return void 0!==n&&i(n),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}function _e(e,t){if(t[e])return t[e];const i=e.split(".");let s=t;for(let e=0,t=i.length;s&&e<t;e++){s=s[i[e]]}return s}function be(e,t=[]){return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,i){return"{{"===e?"{":"}}"===e?"}":t[i]}))}class Be extends Ae{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 i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),n=this.getPoint(s),A=V.subVec3(n,r,[]);return V.normalizeVec3(A,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}_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,i,s=[],r=this.getPoint(0),n=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),n+=V.lenVec3(V.subVec3(t,r,[])),s.push(n),r=t;return this.cacheArcLengths=s,s}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var i,s=this._getLengths(),r=0,n=s.length;i=t||e*s[n-1];for(var A,o=0,a=n-1;o<=a;)if((A=s[r=Math.floor(o+(a-o)/2)]-i)<0)o=r+1;else{if(!(A>0)){a=r;break}a=r-1}if(s[r=a]===i)return r/(n-1);var l=s[r];return(r+(i-l)/(s[r+1]-l))/(n-1)}}class ye extends Be{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 i=(t.length-1)*e,s=Math.floor(i),r=i-s,n=t[0===s?s:s-1],A=t[s],o=t[s>t.length-2?t.length-1:s+1],a=t[s>t.length-3?t.length-1:s+2],l=V.vec3();return l[0]=V.catmullRomInterpolate(n[0],A[0],o[0],a[0],r),l[1]=V.catmullRomInterpolate(n[1],A[1],o[1],a[1],r),l[2]=V.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 we=V.vec3();class ve extends Ae{get type(){return"CameraPath"}constructor(e,t={}){super(e,t),this._frames=[],this._eyeCurve=new ye(this),this._lookCurve=new ye(this),this._upCurve=new ye(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,i,s){const r={t:e,eye:t.slice(0),look:i.slice(0),up:s.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 i=0,s=e.length;i<s;i++)t=e[i],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,we),t.look=this._lookCurve.getPoint(e,we),t.up=this._upCurve.getPoint(e,we)}sampleFrame(e,t,i,s){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,s)}smoothFrameTimes(e){if(0===this._frames.length)return;const t=V.vec3();var i=0;this._frames[0].t=0;const s=[];for(let e=1,n=this._frames.length;e<n;e++){var r=V.lenVec3(V.subVec3(this._frames[e].eye,this._frames[e-1].eye,t));s[e]=r,i+=r}for(let t=1,r=this._frames.length;t<r;t++){const r=s[t]/i*e;this._frames[t].t=this._frames[t-1].t+r}}clearFrames(){this._frames=[],this._eyeCurve.points=[],this._lookCurve.points=[],this._upCurve.points=[]}}const Ce=V.vec3(),Me=V.vec3(),Ee=V.vec3(),Fe=V.vec3(),Ue=V.vec3();class xe extends Ae{get type(){return"CameraFlightAnimation"}constructor(e,t={}){super(e,t),this._look1=V.vec3(),this._eye1=V.vec3(),this._up1=V.vec3(),this._look2=V.vec3(),this._eye2=V.vec3(),this._up2=V.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,i){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=i;const s=this.scene.camera,r=!!e.projection&&e.projection!==s.projection;let n,A,o,a,l;if(this._eye1[0]=s.eye[0],this._eye1[1]=s.eye[1],this._eye1[2]=s.eye[2],this._look1[0]=s.look[0],this._look1[1]=s.look[1],this._look1[2]=s.look[2],this._up1[0]=s.up[0],this._up1[1]=s.up[1],this._up1[2]=s.up[2],this._orthoScale1=s.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 s=e;if((X.isNumeric(s)||X.isString(s))&&(l=s,s=this.scene.components[l],!s))return this.error("Component not found: "+X.inQuotes(l)),void(t&&(i?t.call(i):t()));r||(n=s.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=V.getAABB3Center(n);this._look2=c||t;const i=V.subVec3(this._eye1,this._look1,Ce),s=V.normalizeVec3(i),r=c?V.getAABB3DiagPoint(n,c):V.getAABB3Diag(n),A=e.fitFOV||this._fitFOV,o=Math.abs(r/Math.tan(A*V.DEGTORAD));this._orthoScale2=1.1*r,this._eye2[0]=this._look2[0]+s[0]*o,this._eye2[1]=this._look2[1]+s[1]*o,this._eye2[2]=this._look2[2]+s[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"!==s.projection&&(this._projection2="ortho",this._projMatrix1=s.projMatrix.slice(),this._projMatrix2=s.ortho.matrix.slice(),s.projection="customProjection"),"perspective"===e.projection&&"perspective"!==s.projection&&(this._projection2="perspective",this._projMatrix1=s.projMatrix.slice(),this._projMatrix2=s.perspective.matrix.slice(),s.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,ie.scheduleTask(this._update,this)}jumpTo(e){this._jumpTo(e)}_jumpTo(e){this._flying&&this.stop();const t=this.scene.camera;var i,s,r,n,A;if(e.aabb)i=e.aabb;else if(6===e.length)i=e;else if(e.eye||e.look||e.up)r=e.eye,n=e.look,A=e.up;else{let t=e;if((X.isNumeric(t)||X.isString(t))&&(s=t,t=this.scene.components[s],!t))return void this.error("Component not found: "+X.inQuotes(s));i=t.aabb||this.scene.aabb}const o=e.poi;if(i){if(i[3]<=i[0]||i[4]<=i[1]||i[5]<=i[2])return;var a=o?V.getAABB3DiagPoint(i,o):V.getAABB3Diag(i);let s;n=o||V.getAABB3Center(i,n),this._trail?V.subVec3(t.look,n,Ue):V.subVec3(t.eye,t.look,Ue),V.normalizeVec3(Ue);s=(void 0!==e.fit?e.fit:this._fit)?Math.abs(a/Math.tan((e.fitFOV||this._fitFOV)*V.DEGTORAD)):V.lenVec3(V.subVec3(t.eye,t.look,Ce)),V.mulVec3Scalar(Ue,s),t.eye=V.addVec3(n,Ue,Ce),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 i=this.easing?xe._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(V.subVec3(s.eye,s.look,Ue),s.eye=V.lerpVec3(i,0,1,this._eye1,this._eye2,Ee),s.look=V.subVec3(Ee,Ue,Me)):this._flyingLook&&(s.look=V.lerpVec3(i,0,1,this._look1,this._look2,Me),s.up=V.lerpVec3(i,0,1,this._up1,this._up2,Fe)):this._flyingEyeLookUp&&(s.eye=V.lerpVec3(i,0,1,this._eye1,this._eye2,Ee),s.look=V.lerpVec3(i,0,1,this._look1,this._look2,Me),s.up=V.lerpVec3(i,0,1,this._up1,this._up2,Fe)),this._projection2){const t="ortho"===this._projection2?xe._easeOutExpo(e,0,1,1):xe._easeInCubic(e,0,1,1);s.customProjection.matrix=V.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();ie.scheduleTask(this._update,this)}static _ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}static _easeInCubic(e,t,i,s){return i*(e/=s)*e*e+t}static _easeOutExpo(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+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 Ie extends Ae{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new xe(this),this._t=0,this.state=Ie.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,i;const s=performance.now(),r=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==r)switch(this.state){case Ie.SCRUBBING:return;case Ie.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=Ie.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case Ie.PLAYING_TO:i=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=Ie.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}_ease(e,t,i,s){return-i*(e/=s)*(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=Ie.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=Ie.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const i=this._cameraPath;if(!i)return;const s=i.frames[e];s?(this.state=Ie.SCRUBBING,this._cameraFlightAnimation.flyTo(s,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=Ie.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=Ie.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=Ie.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}Ie.STOPPED=0,Ie.SCRUBBING=1,Ie.PLAYING=2,Ie.PLAYING_TO=3;class Te extends Ae{get type(){return"Geometry"}get isGeometry(){return!0}constructor(e,t={}){super(e,t),G.memory.meshes++}destroy(){super.destroy(),G.memory.meshes--}}const Pe=new e({});class Se{constructor(e){this.id=Pe.addItem({});for(const t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}destroy(){Pe.removeItem(this.id)}}class De{constructor(e,t,i,s,r,n,A,o,a){switch(this._gl=e,this.type=t,this.allocated=!1,i.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=s,this.numItems=0,this.itemSize=r,this.normalized=!!A,this.stride=o||0,this.offset=a||0,this._allocate(i)}_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 ke=function(){const e=[],t=[],i=[],s=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=V.vec3(),c=V.vec3(),h=V.vec3(),u=V.vec3(),d=V.vec3(),f=V.vec3(),p=V.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,f=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]=f/3,e[f++]=o,e[f++]=a,e[f++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)s[u]=t[n[u]],i[s[u]]=n[u]}(g,m),function(t,i){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*s[g],m=3*s[g+1],_=3*s[g+2];i?(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],V.decompressPosition(A,i,l),V.decompressPosition(o,i,c),V.decompressPosition(a,i,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]),V.subVec3(h,c,u),V.subVec3(l,c,d),V.cross3Vec3(u,d,f),V.normalizeVec3(f,p);const b=r[n]||(r[n]={normal:V.vec3()});b.normal[0]=p[0],b.normal[1]=p[1],b.normal[2]=p[2],n++}}(m.length,_);const B=[],y=Math.cos(V.DEGTORAD*b),w={};let v,C,M,E,F,U,x,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let i=0;i<3;i++)v=s[e+i],C=s[e+(i+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)U=w[F],void 0!==U.face2&&(x=r[U.face1].normal,I=r[U.face2].normal,T=V.dotVec3(x,I),T>y)||(P=i[U.index1],S=i[U.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}();const Qe=function(){const e=V.mat4(),t=V.mat4();return function(i,s){s=s||V.mat4();const r=i[0],n=i[1],A=i[2],o=i[3]-r,a=i[4]-n,l=i[5]-A,c=65535;return V.identityMat4(e),V.translationMat4v(i,e),V.identityMat4(t),V.scalingMat4v([o/c,a/c,l/c],t),V.mulMat4(e,t,s),s}}();var Re=function(){const e=V.mat4(),t=V.mat4();return function(i,s,r){const n=new Uint16Array(i.length),A=new Float32Array([r[0]!==s[0]?65535/(r[0]-s[0]):0,r[1]!==s[1]?65535/(r[1]-s[1]):0,r[2]!==s[2]?65535/(r[2]-s[2]):0]);let o;for(o=0;o<i.length;o+=3)n[o+0]=Math.max(0,Math.min(65535,Math.floor((i[o+0]-s[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((i[o+1]-s[1])*A[1]))),n[o+2]=Math.max(0,Math.min(65535,Math.floor((i[o+2]-s[2])*A[2])));V.identityMat4(e),V.translationMat4v(s,e),V.identityMat4(t),V.scalingMat4v([(r[0]-s[0])/65535,(r[1]-s[1])/65535,(r[2]-s[2])/65535],t);return{quantized:n,decodeMatrix:V.mulMat4(e,t,V.identityMat4())}}}();var Oe=function(){const e=V.mat3(),t=V.mat3();return function(i,s,r){const n=new Uint16Array(i.length),A=new Float32Array([65535/(r[0]-s[0]),65535/(r[1]-s[1])]);let o;for(o=0;o<i.length;o+=2)n[o+0]=Math.max(0,Math.min(65535,Math.floor((i[o+0]-s[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((i[o+1]-s[1])*A[1])));V.identityMat3(e),V.translationMat3v(s,e),V.identityMat3(t),V.scalingMat3v([(r[0]-s[0])/65535,(r[1]-s[1])/65535],t);return{quantized:n,decodeMatrix:V.mulMat3(e,t,V.identityMat3())}}}();function Ve(e,t,i,s){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[i](127.5*r+(r<0?-1:0)),Math[s](127.5*n+(n<0?-1:0))])}function Le(e){let t=e[0],i=e[1];t/=t<0?127:128,i/=i<0?127:128;const s=1-Math.abs(t)-Math.abs(i);s<0&&(t=(1-Math.abs(i))*(t>=0?1:-1),i=(1-Math.abs(t))*(i>=0?1:-1));const r=Math.sqrt(t*t+i*i+s*s);return[t/r,i/r,s/r]}function He(e,t,i){return e[t]*i[0]+e[t+1]*i[1]+e[t+2]*i[2]}const Ne={getPositionsBounds:function(e){const t=new Float32Array(3),i=new Float32Array(3);let s,r;for(s=0;s<3;s++)t[s]=Number.MAX_VALUE,i[s]=-Number.MAX_VALUE;for(s=0;s<e.length;s+=3)for(r=0;r<3;r++)t[r]=Math.min(t[r],e[s+r]),i[r]=Math.max(i[r],e[s+r]);return{min:t,max:i}},createPositionsDecodeMatrix:Qe,compressPositions:Re,compressPosition:function(e,t,i){const s=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]);i[0]=Math.max(0,Math.min(65535,Math.floor((e[0]-t[0])*s[0]))),i[1]=Math.max(0,Math.min(65535,Math.floor((e[1]-t[1])*s[1]))),i[2]=Math.max(0,Math.min(65535,Math.floor((e[2]-t[2])*s[2])))},decompressPositions:function(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[12],i[s+1]=e[s+1]*t[5]+t[13],i[s+2]=e[s+2]*t[10]+t[14];return i},decompressPosition:function(e,t,i){return i[0]=e[0]*t[0]+t[12],i[1]=e[1]*t[5]+t[13],i[2]=e[2]*t[10]+t[14],i},decompressAABB:function(e,t,i=e){return i[0]=e[0]*t[0]+t[12],i[1]=e[1]*t[5]+t[13],i[2]=e[2]*t[10]+t[14],i[3]=e[3]*t[0]+t[12],i[4]=e[4]*t[5]+t[13],i[5]=e[5]*t[10]+t[14],i},getUVBounds:function(e){const t=new Float32Array(2),i=new Float32Array(2);let s,r;for(s=0;s<2;s++)t[s]=Number.MAX_VALUE,i[s]=-Number.MAX_VALUE;for(s=0;s<e.length;s+=2)for(r=0;r<2;r++)t[r]=Math.min(t[r],e[s+r]),i[r]=Math.max(i[r],e[s+r]);return{min:t,max:i}},compressUVs:Oe,decompressUVs:function(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[6],i[s+1]=e[s+1]*t[4]+t[7];return i},decompressUV:function(e,t,i){i[0]=e[0]*t[0]+t[6],i[1]=e[1]*t[4]+t[7]},compressNormals:function(e){const t=new Int8Array(e.length);let i,s,r,n,A;for(let o=0;o<e.length;o+=3)r=i=Ve(e,o,"floor","floor"),s=Le(i),n=A=He(e,o,s),i=Ve(e,o,"ceil","floor"),s=Le(i),n=He(e,o,s),n>A&&(r=i,A=n),i=Ve(e,o,"floor","ceil"),s=Le(i),n=He(e,o,s),n>A&&(r=i,A=n),i=Ve(e,o,"ceil","ceil"),s=Le(i),n=He(e,o,s),n>A&&(r=i,A=n),t[o]=r[0],t[o+1]=r[1];return t},decompressNormals:function(e,t){for(let i=0,s=0,r=e.length;i<r;i+=2){let r=e[i+0],n=e[i+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[s+0]=r/o,t[s+1]=n/o,t[s+2]=A/o,s+=3}return t},decompressNormal:function(e,t){let i=e[0],s=e[1];i=(2*i+1)/255,s=(2*s+1)/255;const r=1-Math.abs(i)-Math.abs(s);r<0&&(i=(1-Math.abs(s))*(i>=0?1:-1),s=(1-Math.abs(i))*(s>=0?1:-1));const n=Math.sqrt(i*i+s*s+r*r);return t[0]=i/n,t[1]=s/n,t[2]=r/n,t}},Ge=G.memory,je=V.AABB3();class We extends Te{get type(){return"ReadableGeometry"}get isReadableGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new Se({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 i=this._state,s=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":i.primitive=s.POINTS,i.primitiveName=t.primitive;break;case"lines":i.primitive=s.LINES,i.primitiveName=t.primitive;break;case"line-loop":i.primitive=s.LINE_LOOP,i.primitiveName=t.primitive;break;case"line-strip":i.primitive=s.LINE_STRIP,i.primitiveName=t.primitive;break;case"triangles":i.primitive=s.TRIANGLES,i.primitiveName=t.primitive;break;case"triangle-strip":i.primitive=s.TRIANGLE_STRIP,i.primitiveName=t.primitive;break;case"triangle-fan":i.primitive=s.TRIANGLE_FAN,i.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'."),i.primitive=s.TRIANGLES,i.primitiveName=t.primitive}if(t.positions)if(this._state.compressGeometry){const e=Ne.getPositionsBounds(t.positions),s=Ne.compressPositions(t.positions,e.min,e.max);i.positions=s.quantized,i.positionsDecodeMatrix=s.decodeMatrix}else i.positions=t.positions.constructor===Float32Array?t.positions:new Float32Array(t.positions);if(t.colors&&(i.colors=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors)),t.uv)if(this._state.compressGeometry){const e=Ne.getUVBounds(t.uv),s=Ne.compressUVs(t.uv,e.min,e.max);i.uv=s.quantized,i.uvDecodeMatrix=s.decodeMatrix}else i.uv=t.uv.constructor===Float32Array?t.uv:new Float32Array(t.uv);if(t.normals&&(this._state.compressGeometry?i.normals=Ne.compressNormals(t.normals):i.normals=t.normals.constructor===Float32Array?t.normals:new Float32Array(t.normals)),t.indices&&(i.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(),Ge.meshes++,i.indices&&(i.indicesBuf=new De(s,s.ELEMENT_ARRAY_BUFFER,i.indices,i.indices.length,1,s.STATIC_DRAW),Ge.indices+=i.indicesBuf.numItems),i.positions&&(i.positionsBuf=new De(s,s.ARRAY_BUFFER,i.positions,i.positions.length,3,s.STATIC_DRAW),Ge.positions+=i.positionsBuf.numItems),i.normals){let e=i.compressGeometry;i.normalsBuf=new De(s,s.ARRAY_BUFFER,i.normals,i.normals.length,3,s.STATIC_DRAW,e),Ge.normals+=i.normalsBuf.numItems}i.colors&&(i.colorsBuf=new De(s,s.ARRAY_BUFFER,i.colors,i.colors.length,4,s.STATIC_DRAW),Ge.colors+=i.colorsBuf.numItems),i.uv&&(i.uvBuf=new De(s,s.ARRAY_BUFFER,i.uv,i.uv.length,2,s.STATIC_DRAW),Ge.uvs+=i.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,i=ke(e.positions,e.indices,e.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new De(t,t.ELEMENT_ARRAY_BUFFER,i,i.length,1,t.STATIC_DRAW),Ge.indices+=this._edgeIndicesBuf.numItems}_buildPickTriangleVBOs(){const e=this._state;if(!e.positions||!e.indices)return;const t=this.scene.canvas.gl,i=V.buildPickTriangles(e.positions,e.indices,e.compressGeometry),s=i.positions,r=i.colors;this._pickTrianglePositionsBuf=new De(t,t.ARRAY_BUFFER,s,s.length,3,t.STATIC_DRAW),this._pickTriangleColorsBuf=new De(t,t.ARRAY_BUFFER,r,r.length,4,t.STATIC_DRAW,!0),Ge.positions+=this._pickTrianglePositionsBuf.numItems,Ge.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),Ne.decompressPositions(this._state.positions,this._state.positionsDecodeMatrix,this._decompressedPositions)),this._decompressedPositions):this._state.positions:null}set positions(e){const t=this._state,i=t.positions;if(i)if(i.length===e.length){if(this._state.compressGeometry){const i=Ne.getPositionsBounds(e),s=Ne.compressPositions(e,i.min,i.max);e=s.quantized,t.positionsDecodeMatrix=s.decodeMatrix}i.set(e),t.positionsBuf&&t.positionsBuf.setData(i),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),Ne.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,i=t.normals;i?i.length===e.length?(i.set(e),t.normalsBuf&&t.normalsBuf.setData(i),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),Ne.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,i=t.uv;i?i.length===e.length?(i.set(e),t.uvBuf&&t.uvBuf.setData(i),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,i=t.colors;i?i.length===e.length?(i.set(e),t.colorsBuf&&t.colorsBuf.setData(i),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=V.AABB3()),V.positions3ToAABB3(this._state.positions,this._aabb,this._state.positionsDecodeMatrix),this._aabbDirty=!1),this._aabb}get obb(){return this._obbDirty&&(this._obb||(this._obb=V.OBB3()),V.positions3ToAABB3(this._state.positions,je,this._state.positionsDecodeMatrix),V.AABB3ToOBB3(je,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,i=(i,s)=>{const r=3*e[i];for(let e=0;e<3;++e)s[e]=t[r+e];return s},s=[V.vec3(),V.vec3(),V.vec3(),V.vec3()];let r=0;const n=V.vec3([0,0,0]);for(let t=0;t<e.length;t+=3){const e=i(t,s[0]),A=i(t+1,s[1]),o=i(t+2,s[2]);V.addVec3(e,A,s[3]),V.addVec3(o,s[3],s[3]);const a=V.lenVec3(V.cross3Vec3(V.subVec3(A,e,s[1]),V.subVec3(o,e,s[2]),s[0]))/2;r+=a,V.mulVec3Scalar(s[3],a,s[3]),V.addVec3(n,s[3],n)}this._metrics={surfaceArea:r,centroid:V.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(),Ge.meshes--}}const ze=G.memory,Xe=V.AABB3();class Ke extends Te{get type(){return"VBOGeometry"}get isVBOGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new Se({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=V.OBB3();const i=this._state,s=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":i.primitive=s.POINTS,i.primitiveName=t.primitive;break;case"lines":i.primitive=s.LINES,i.primitiveName=t.primitive;break;case"line-loop":i.primitive=s.LINE_LOOP,i.primitiveName=t.primitive;break;case"line-strip":i.primitive=s.LINE_STRIP,i.primitiveName=t.primitive;break;case"triangles":i.primitive=s.TRIANGLES,i.primitiveName=t.primitive;break;case"triangle-strip":i.primitive=s.TRIANGLE_STRIP,i.primitiveName=t.primitive;break;case"triangle-fan":i.primitive=s.TRIANGLE_FAN,i.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'."),i.primitive=s.TRIANGLES,i.primitiveName=t.primitive}if(t.positions)if(t.indices){var r;if(t.positionsDecodeMatrix);else{const e=Ne.getPositionsBounds(t.positions),n=Ne.compressPositions(t.positions,e.min,e.max);r=n.quantized,i.positionsDecodeMatrix=n.decodeMatrix,i.positionsBuf=new De(s,s.ARRAY_BUFFER,r,r.length,3,s.STATIC_DRAW),ze.positions+=i.positionsBuf.numItems,V.positions3ToAABB3(t.positions,this._aabb),V.positions3ToAABB3(r,Xe,i.positionsDecodeMatrix),V.AABB3ToOBB3(Xe,this._obb)}if(t.colors){const e=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors);i.colorsBuf=new De(s,s.ARRAY_BUFFER,e,e.length,4,s.STATIC_DRAW),ze.colors+=i.colorsBuf.numItems}if(t.uv){const e=Ne.getUVBounds(t.uv),r=Ne.compressUVs(t.uv,e.min,e.max),n=r.quantized;i.uvDecodeMatrix=r.decodeMatrix,i.uvBuf=new De(s,s.ARRAY_BUFFER,n,n.length,2,s.STATIC_DRAW),ze.uvs+=i.uvBuf.numItems}if(t.normals){const e=Ne.compressNormals(t.normals);let r=i.compressGeometry;i.normalsBuf=new De(s,s.ARRAY_BUFFER,e,e.length,3,s.STATIC_DRAW,r),ze.normals+=i.normalsBuf.numItems}{const e=t.indices.constructor===Uint32Array||t.indices.constructor===Uint16Array?t.indices:new Uint32Array(t.indices);i.indicesBuf=new De(s,s.ELEMENT_ARRAY_BUFFER,e,e.length,1,s.STATIC_DRAW),ze.indices+=i.indicesBuf.numItems;const n=ke(r,e,i.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new De(s,s.ELEMENT_ARRAY_BUFFER,n,n.length,1,s.STATIC_DRAW),"triangles"===this._state.primitiveName&&(this._numTriangles=t.indices.length/3)}this._buildHash(),ze.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(),ze.meshes--}}var Ze={};function Je(e,t={}){return new Promise((function(i,s){t.src||(console.error("load3DSGeometry: Parameter expected: src"),s());var r=e.canvas.spinner;r.processes++,X.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("load3DSGeometry: no data loaded"),r.processes--,s());var n=Ze.parse.from3DS(e).edit.objects[0].mesh,A=n.vertices,o=n.uvt,a=n.indices;r.processes--,i(X.apply(t,{primitive:"triangles",positions:A,normals:null,uv:o,indices:a}))}),(function(e){console.error("load3DSGeometry: "+e),r.processes--,s()}))}))}function Ye(e,t={}){return new Promise((function(i,s){t.src||(console.error("loadOBJGeometry: Parameter expected: src"),s());var r=e.canvas.spinner;r.processes++,X.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("loadOBJGeometry: no data loaded"),r.processes--,s());for(var n=Ze.parse.fromOBJ(e),A=Ze.edit.unwrap(n.i_verts,n.c_verts,3),o=Ze.edit.unwrap(n.i_norms,n.c_norms,3),a=Ze.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--,i(X.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--,s()}))}))}function $e(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let i=e.ySize||1;i<0&&(console.error("negative ySize not allowed - will invert"),i*=-1);let s=e.zSize||1;s<0&&(console.error("negative zSize not allowed - will invert"),s*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-i+A,c=-s+o,h=t+n,u=i+A,d=s+o;return X.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 qe(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let i=e.ySize||1;i<0&&(console.error("negative ySize not allowed - will invert"),i*=-1);let s=e.zSize||1;s<0&&(console.error("negative zSize not allowed - will invert"),s*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-i+A,c=-s+o,h=t+n,u=i+A,d=s+o;return X.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 et(e={}){return qe({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})}function tt(e={}){let t=e.radiusTop||1;t<0&&(console.error("negative radiusTop not allowed - will invert"),t*=-1);let i=e.radiusBottom||1;i<0&&(console.error("negative radiusBottom not allowed - will invert"),i*=-1);let s=e.height||1;s<0&&(console.error("negative height not allowed - will invert"),s*=-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=s/2,u=s/n,d=2*Math.PI/r,f=1/r,p=(t-i)/n,g=[],m=[],_=[],b=[];let B,y,w,v,C,M,E,F,U,x,I;const T=(90-180*Math.atan(s/(i-t))/Math.PI)/90;for(B=0;B<=n;B++)for(C=t-B*p,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*f),_.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(U=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),x=.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(x),_.push(I),g.push(t*w+a),g.push(h+l),g.push(t*v+c);for(y=0;y<r;y++)o=U,E=U+1+y,b.push(E),b.push(E+1),b.push(o)}if(!A&&i>0){for(U=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),x=.5*Math.sin(y*d)+.5,I=.5*Math.cos(y*d)+.5,m.push(i*w),m.push(-1),m.push(i*v),_.push(x),_.push(I),g.push(i*w+a),g.push(0-h+l),g.push(i*v+c);for(y=0;y<r;y++)o=U,E=U+1+y,b.push(o),b.push(E+1),b.push(E)}return X.apply(e,{positions:g,normals:m,uv:_,indices:b})}function it(e={}){let t=e.size||1;t<0&&(console.error("negative size not allowed - will invert"),t*=-1);let i=e.divisions||1;i<0&&(console.error("negative divisions not allowed - will invert"),i*=-1),i<1&&(i=1),t=t||10,i=i||10;const s=t/i,r=t/2,n=[],A=[];let o=0;for(let e=0,t=-r;e<=i;e++,t+=s)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 X.apply(e,{primitive:"lines",positions:n,indices:A})}function st(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let i=e.zSize||1;i<0&&(console.error("negative zSize not allowed - will invert"),i*=-1);let s=e.xSegments||1;s<0&&(console.error("negative xSegments not allowed - will invert"),s*=-1),s<1&&(s=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=i/2,h=Math.floor(s)||1,u=Math.floor(r)||1,d=h+1,f=u+1,p=t/h,g=i/u,m=new Float32Array(d*f*3),_=new Float32Array(d*f*3),b=new Float32Array(d*f*2);let B,y,w,v,C,M,E,F=0,U=0;for(B=0;B<f;B++){const e=B*g-c;for(y=0;y<d;y++)w=y*p-l,m[F]=w+A,m[F+1]=o,m[F+2]=-e+a,_[F+1]=1,b[U]=y/h,b[U+1]=(u-B)/u,F+=3,U+=2}F=0;const x=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,x[F]=E,x[F+1]=C,x[F+2]=v,x[F+3]=E,x[F+4]=M,x[F+5]=C,F+=6;return X.apply(e,{positions:m,normals:_,uv:b,indices:x})}function rt(e={}){const t=e.lod||1,i=e.center?e.center[0]:0,s=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,f,p,g,m,_,b,B,y,w,v,C,M,E;for(u=0;u<=A;u++)for(f=u*Math.PI/A,p=Math.sin(f),g=Math.cos(f),d=0;d<=o;d++)m=2*d*Math.PI/o,_=Math.sin(m),b=Math.cos(m),B=b*p,y=g,w=_*p,v=1-d/o,C=u/A,l.push(B),l.push(y),l.push(w),c.push(v),c.push(C),a.push(i+n*B),a.push(s+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 X.apply(e,{positions:a,normals:l,uv:c,indices:h})}function nt(e={}){let t=e.radius||1;t<0&&(console.error("negative radius not allowed - will invert"),t*=-1),t*=.5;let i=e.tube||.3;i<0&&(console.error("negative tube not allowed - will invert"),i*=-1);let s=e.radialSegments||32;s<0&&(console.error("negative radialSegments not allowed - will invert"),s*=-1),s<4&&(s=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 f,p,g,m,_,b,B,y,w,v,C,M;for(y=0;y<=r;y++)for(B=0;B<=s;B++)f=B/s*n,p=.785398+y/r*Math.PI*2,o=t*Math.cos(f),a=t*Math.sin(f),g=(t+i*Math.cos(p))*Math.cos(f),m=(t+i*Math.cos(p))*Math.sin(f),_=i*Math.sin(p),c.push(g+o),c.push(m+a),c.push(_+l),u.push(1-B/s),u.push(y/r),b=V.normalizeVec3(V.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<=s;B++)w=(s+1)*y+B-1,v=(s+1)*(y-1)+B-1,C=(s+1)*(y-1)+B,M=(s+1)*y+B,d.push(w),d.push(v),d.push(C),d.push(C),d.push(M),d.push(w);return X.apply(e,{positions:c,normals:h,uv:u,indices:d})}Ze.load=function(e,t){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(e){t(e.target.response)},i.send()},Ze.save=function(e,t){var i="data:application/octet-stream;base64,"+btoa(Ze.parse._buffToStr(e));window.location.href=i},Ze.clone=function(e){return JSON.parse(JSON.stringify(e))},Ze.bin={},Ze.bin.f=new Float32Array(1),Ze.bin.fb=new Uint8Array(Ze.bin.f.buffer),Ze.bin.rf=function(e,t){for(var i=Ze.bin.f,s=Ze.bin.fb,r=0;r<4;r++)s[r]=e[t+r];return i[0]},Ze.bin.rsl=function(e,t){return e[t]|e[t+1]<<8},Ze.bin.ril=function(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},Ze.bin.rASCII0=function(e,t){for(var i="";0!=e[t];)i+=String.fromCharCode(e[t++]);return i},Ze.bin.wf=function(e,t,i){new Float32Array(e.buffer,t,1)[0]=i},Ze.bin.wsl=function(e,t,i){e[t]=i,e[t+1]=i>>8},Ze.bin.wil=function(e,t,i){e[t]=i,e[t+1]=i>>8,e[t+2]=i>>16,e[t+3]},Ze.parse={},Ze.parse._buffToStr=function(e){for(var t=new Uint8Array(e),i="",s=0;s<t.length;s++)i=i.concat(String.fromCharCode(t[s]));return i},Ze.parse._strToBuff=function(e){for(var t=new ArrayBuffer(e.length),i=new Uint8Array(t),s=0;s<e.length;s++)i[s]=e.charCodeAt(s);return t},Ze.parse._readLine=function(e,t){for(var i="";10!=e[t];)i+=String.fromCharCode(e[t++]);return i},Ze.parse.fromJSON=function(e){return JSON.parse(Ze.parse._buffToStr(e))},Ze.parse.toJSON=function(e){var t=JSON.stringify(e);return Ze.parse._strToBuff(t)},Ze.parse.fromOBJ=function(e){for(var t={groups:{},c_verts:[],c_uvt:[],c_norms:[],i_verts:[],i_uvt:[],i_norms:[]},i={from:0,to:0},s=0,r=new Uint8Array(e);s<r.length;){var n=Ze.parse._readLine(r,s);s+=n.length+1;var A=(n=(n=n.replace(/ +(?= )/g,"")).replace(/(^\s+|\s+$)/g,"")).split(" ");if("g"==A[0]&&(i.to=t.i_verts.length,null==t.groups[A[1]]&&(t.groups[A[1]]={from:t.i_verts.length,to:0}),i=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,f=parseInt(h[0])-1,p=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),f<0&&(f=w+f+1),p<0&&(p=w+p+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,f,p),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,U=parseInt(M[2])-1;E<0&&(E=w+E+1),F<0&&(F=v+F+1),U<0&&(U=C+U+1),t.i_verts.push(d,p,E),t.i_uvt.push(g,_,F),t.i_norms.push(b,y,U)}}}return i.to=t.i_verts.length,t},Ze.parse.fromMD2=function(e){e=new Uint8Array(e);var t={},i={};i.ident=Ze.bin.ril(e,0),i.version=Ze.bin.ril(e,4),i.skinwidth=Ze.bin.ril(e,8),i.skinheight=Ze.bin.ril(e,12),i.framesize=Ze.bin.ril(e,16),i.num_skins=Ze.bin.ril(e,20),i.num_vertices=Ze.bin.ril(e,24),i.num_st=Ze.bin.ril(e,28),i.num_tris=Ze.bin.ril(e,32),i.num_glcmds=Ze.bin.ril(e,36),i.num_frames=Ze.bin.ril(e,40),i.offset_skins=Ze.bin.ril(e,44),i.offset_st=Ze.bin.ril(e,48),i.offset_tris=Ze.bin.ril(e,52),i.offset_frames=Ze.bin.ril(e,56),i.offset_glcmds=Ze.bin.ril(e,60),i.offset_end=Ze.bin.ril(e,64);var s=i.offset_st;t.c_uvt=[];for(var r=0;r<i.num_st;r++){var n=Ze.bin.rsl(e,s)/i.skinwidth,A=Ze.bin.rsl(e,s+2)/i.skinheight;t.c_uvt.push(n,A),s+=4}s=i.offset_tris;var o=[],a=[];t.i_verts=o,t.i_uvt=a;for(r=0;r<i.num_tris;r++)o.push(Ze.bin.rsl(e,s),Ze.bin.rsl(e,s+2),Ze.bin.rsl(e,s+4)),a.push(Ze.bin.rsl(e,s+6),Ze.bin.rsl(e,s+8),Ze.bin.rsl(e,s+10)),s+=12;s=i.offset_skins;t.skins=[];for(r=0;r<i.num_skins;r++)t.skins.push(Ze.bin.rASCII0(e,s)),s+=64;s=i.offset_frames;t.frames=[];var l=Ze.parse.fromMD2._normals;for(r=0;r<i.num_frames;r++){var c={},h=Ze.bin.rf(e,s),u=Ze.bin.rf(e,s+4),d=Ze.bin.rf(e,s+8);s+=12;var f=Ze.bin.rf(e,s),p=Ze.bin.rf(e,s+4),g=Ze.bin.rf(e,s+8);s+=12,c.name=Ze.bin.rASCII0(e,s),s+=16,c.verts=[],c.norms=[];for(var m=0;m<i.num_vertices;m++)c.verts.push(e[s]*h+f,e[s+1]*u+p,e[s+2]*d+g),c.norms.push(l[3*e[s+3]],l[3*e[s+3]+1],l[3*e[s+3]+2]),s+=4;t.frames.push(c)}return t},Ze.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],Ze.parse.fromCollada=function(e){var t=Ze.parse._buffToStr(e),i=(new DOMParser).parseFromString(t,"text/xml"),s={},r=(i=i.childNodes[0]).getElementsByTagName("asset")[0],n=i.getElementsByTagName("library_geometries")[0],A=i.getElementsByTagName("library_images")[0],o=i.getElementsByTagName("library_materials")[0],a=i.getElementsByTagName("library_effects")[0];return r&&(s.asset=Ze.parse.fromCollada._asset(r)),n&&(s.geometries=Ze.parse.fromCollada._libGeometries(n)),A&&(s.images=Ze.parse.fromCollada._libImages(A)),o&&(s.materials=Ze.parse.fromCollada._libMaterials(o)),a&&(s.effects=Ze.parse.fromCollada._libEffects(a)),s},Ze.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}},Ze.parse.fromCollada._libGeometries=function(e){e=e.getElementsByTagName("geometry");for(var t=[],i=0;i<e.length;i++){var s=e[i],r=Ze.parse.fromCollada._getMesh(s.getElementsByTagName("mesh")[0]);t.push(r)}return t},Ze.parse.fromCollada._getMesh=function(e){for(var t={},i=e.getElementsByTagName("source"),s=t.sources={},r=0;r<i.length;r++){for(var n=i[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]);s[i[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 f=u[a];o=[];d[parseInt(f.getAttribute("offset"))]=o;var p=f.getAttribute("semantic");c["s_"+p]="VERTEX"==p?e.getElementsByTagName("vertices")[0].getElementsByTagName("input")[0].getAttribute("source").substring(1):f.getAttribute("source").substring(1),c["i_"+p]=o,s[c["s_"+p]]}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},Ze.parse.fromCollada._libImages=function(e){e=e.getElementsByTagName("image");for(var t={},i=0;i<e.length;i++)t[e[i].getAttribute("id")]=e[i].getElementsByTagName("init_from")[0].textContent;return t},Ze.parse.fromCollada._libMaterials=function(e){e=e.getElementsByTagName("material");for(var t={},i=0;i<e.length;i++)t[e[i].getAttribute("name")]=e[i].getElementsByTagName("instance_effect")[0].getAttribute("url").substring(1);return t},Ze.parse.fromCollada._libEffects=function(e){e=e.getElementsByTagName("effect");for(var t={},i=0;i<e.length;i++){for(var s={},r=e[i].getElementsByTagName("newparam"),n=0;n<r.length;n++){var A=r[n].getElementsByTagName("surface")[0];A&&(s.surface=A.getElementsByTagName("init_from")[0].textContent)}t[e[i].getAttribute("id")]=s}return t},Ze.parse.from3DS=function(e){e=new Uint8Array(e);var t={};if(19789!=Ze.bin.rsl(e,0))return null;for(var i=Ze.bin.ril(e,2),s=6;s<i;){var r=Ze.bin.rsl(e,s),n=Ze.bin.ril(e,s+2);15677==r&&(t.edit=Ze.parse.from3DS._edit3ds(e,s,n)),45056==r&&(t.keyf=Ze.parse.from3DS._keyf3ds(e,s,n)),s+=n}return t},Ze.parse.from3DS._edit3ds=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);16384==n&&(null==s.objects&&(s.objects=[]),s.objects.push(Ze.parse.from3DS._edit_object(e,r,A))),r+=A}return s},Ze.parse.from3DS._keyf3ds=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);45058==n&&(null==s.desc&&(s.desc=[]),s.desc.push(Ze.parse.from3DS._keyf_objdes(e,r,A))),r+=A}return s},Ze.parse.from3DS._keyf_objdes=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);45072==n&&(s.hierarchy=Ze.parse.from3DS._keyf_objhierarch(e,r,A)),45073==n&&(s.dummy_name=Ze.bin.rASCII0(e,r+6)),r+=A}return s},Ze.parse.from3DS._keyf_objhierarch=function(e,t,i){var s={},r=t+6;return s.name=Ze.bin.rASCII0(e,r),r+=s.name.length+1,s.hierarchy=Ze.bin.rsl(e,r+4),s},Ze.parse.from3DS._edit_object=function(e,t,i){var s={},r=t+6;for(s.name=Ze.bin.rASCII0(e,r),r+=s.name.length+1;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);16640==n&&(s.mesh=Ze.parse.from3DS._obj_trimesh(e,r,A)),r+=A}return s},Ze.parse.from3DS._obj_trimesh=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);16656==n&&(s.vertices=Ze.parse.from3DS._tri_vertexl(e,r,A)),16672==n&&(s.indices=Ze.parse.from3DS._tri_facel1(e,r,A)),16704==n&&(s.uvt=Ze.parse.from3DS._tri_mappingcoors(e,r,A)),16736==n&&(s.local=Ze.parse.from3DS._tri_local(e,r,A)),r+=A}return s},Ze.parse.from3DS._tri_vertexl=function(e,t,i){var s=[],r=t+6,n=Ze.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)s.push(Ze.bin.rf(e,r)),s.push(Ze.bin.rf(e,r+4)),s.push(Ze.bin.rf(e,r+8)),r+=12;return s},Ze.parse.from3DS._tri_facel1=function(e,t,i){var s=[],r=t+6,n=Ze.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)s.push(Ze.bin.rsl(e,r)),s.push(Ze.bin.rsl(e,r+2)),s.push(Ze.bin.rsl(e,r+4)),r+=8;return s},Ze.parse.from3DS._tri_mappingcoors=function(e,t,i){var s=[],r=t+6,n=Ze.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)s.push(Ze.bin.rf(e,r)),s.push(1-Ze.bin.rf(e,r+4)),r+=8;return s},Ze.parse.from3DS._tri_local=function(e,t,i){var s={},r=t+6;return s.X=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s.Y=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s.Z=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s.C=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s},Ze.parse.fromBIV=function(e){e=new Uint8Array(e);var t={},i={};return i.id=Ze.bin.ril(e,0),i.verS=Ze.bin.ril(e,4),i.texS=Ze.bin.ril(e,8),i.indS=Ze.bin.ril(e,12),i.verO=Ze.bin.ril(e,16),i.verL=Ze.bin.ril(e,20),i.texO=Ze.bin.ril(e,24),i.texL=Ze.bin.ril(e,28),i.indO=Ze.bin.ril(e,32),i.indL=Ze.bin.ril(e,36),0!=i.verO&&(t.vertices=Ze.parse.fromBIV._readFloats(e,i.verO,i.verL)),0!=i.texO&&(t.uvt=Ze.parse.fromBIV._readFloats(e,i.texO,i.texL)),0!=i.indO&&(t.indices=Ze.parse.fromBIV._readInts(e,i.indO,i.indL,i.indS)),t},Ze.parse.toBIV=function(e){for(var t=0,i=0;i<e.indices.length;i++)t=Math.max(t,e.indices[i]);var s=32;t<=65535&&(s=16);var r=40;e.vertices&&(r+=4*e.vertices.length),e.uvt&&(r+=4*e.uvt.length),e.indices&&(r+=e.indices.length*s/8);var n=new Uint8Array(r);Ze.bin.wil(n,0,1769365870),Ze.bin.wil(n,4,32),Ze.bin.wil(n,8,32),Ze.bin.wil(n,12,s);var A=40;return e.vertices&&(Ze.bin.wil(n,16,A),Ze.bin.wil(n,20,4*e.vertices.length),Ze.parse.fromBIV._writeFloats(n,A,e.vertices),A+=4*e.vertices.length),e.uvt&&(Ze.bin.wil(n,24,A),Ze.bin.wil(n,28,4*e.uvt.length),Ze.parse.fromBIV._writeFloats(n,A,e.uvt),A+=4*e.uvt.length),e.indices&&(Ze.bin.wil(n,32,A),Ze.bin.wil(n,36,4*e.indices.length),Ze.parse.fromBIV._writeInts(n,A,e.indices,s)),n.buffer},Ze.parse.fromBIV._readFloats=function(e,t,i){for(var s=[],r=0;r<i/4;r++)s.push(Ze.bin.rf(e,t+4*r));return s},Ze.parse.fromBIV._writeFloats=function(e,t,i){for(var s=0;s<i.length;s++)Ze.bin.wf(e,t+4*s,i[s])},Ze.parse.fromBIV._readInts=function(e,t,i,s){for(var r=[],n=0;n<i/4;n++)16==s&&r.push(Ze.bin.rsl(e,t+2*n)),32==s&&r.push(Ze.bin.ril(e,t+4*n));return r},Ze.parse.fromBIV._writeInts=function(e,t,i,s){for(var r=0;r<i.length;r++)16==s&&Ze.bin.wsl(e,t+2*r,i[r]),32==s&&Ze.bin.wil(e,t+4*r,i[r])},Ze.gen={},Ze.gen.Plane=function(e,t,i,s){i||(i=1),s||(s=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(i*a/e,s*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},Ze.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]}},Ze.gen.Sphere=function(e,t){for(var i={verts:[],inds:[],uvt:[]},s=e+1,r=t+1,n=0;n<r;n++)for(var A=0;A<s;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);i.verts.push(l,c,h),i.uvt.push(A/e,n/t),n<t&&A<e&&i.inds.push(s*n+A,s*n+A+1,s*(n+1)+A,s*n+A+1,s*(n+1)+A,s*(n+1)+A+1)}return i},Ze.mat={},Ze.mat.scale=function(e,t,i){return[e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1]},Ze.mat.translate=function(e,t,i){return[1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1]},Ze.mat.rotateDeg=function(e,t,i){var s=Math.PI/180;return Ze.mat.rotate(e*s,t*s,i*s)},Ze.mat.rotate=function(e,t,i){var s=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r=e,n=t,A=i,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 s[0]=a*l,s[1]=-a*u,s[2]=h,s[4]=o*u+c*h*l,s[5]=o*l-c*h*u,s[6]=-c*a,s[8]=c*u-o*h*l,s[9]=c*l+o*h*u,s[10]=o*a,s},Ze.edit={},Ze.edit.interpolate=function(e,t,i,s){for(var r=0;r<e.length;r++)i[r]=e[r]+s*(t[r]-e[r])},Ze.edit.transform=function(e,t){for(var i=0;i<e.length;i+=3){var s=e[i],r=e[i+1],n=e[i+2];e[i+0]=t[0]*s+t[4]*r+t[8]*n+t[12],e[i+1]=t[1]*s+t[5]*r+t[9]*n+t[13],e[i+2]=t[2]*s+t[6]*r+t[10]*n+t[14]}},Ze.edit.unwrap=function(e,t,i){for(var s=new Array(Math.floor(e.length/3)*i),r=0;r<e.length;r++)for(var n=0;n<i;n++)s[r*i+n]=t[e[r]*i+n];return s},Ze.edit.remap=function(e,t,i,s){for(var r=new Array(i.length),n=0;n<e.length;n++)for(var A=0;A<s;A++)r[t[n]*s+A]=i[e[n]*s+A];return r},Ze.utils={},Ze.utils.getAABB=function(e){var t,i,s,r,n,A;r=n=A=-(t=i=s=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<i&&(i=l),l>n&&(n=l),c<s&&(s=c),l>A&&(A=c)}return{min:{x:t,y:i,z:s},max:{x:r,y:n,z:A}}};const At={" ":{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 ot(e={}){var t=e.origin||[0,0,0],i=t[0],s=t[1],r=t[2],n=e.size||1,A=[],o=[],a=e.text;X.isNumeric(a)&&(a=""+a);for(var l,c,h,u,d,f,p,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=At[c.charAt(v)]){d=1,f=-1,p=-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+i),A.push(B+m[1]*n*y+s),A.push(0+r),-1===f?f=b:(-1===p||(f=p),p=b),b++,d?d=!1:(o.push(f),o.push(p))):d=1;l+=u.width*y*n}B-=35*y*n}return X.apply(e,{primitive:"lines",positions:A,indices:o})}function at(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 i=[];for(let e=0;e<t-1;e++)i.push(e),i.push(e+1);return X.apply(e,{primitive:"lines",positions:e.points,indices:i})}function lt(e={}){let t=e.curve.getPoints(e.divisions).map((e=>[...e])).flat();return at({id:e.id,points:t})}function ct(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=[],i=[],s=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-s)**2+(o-r)**2+(a-n)**2),c=[(A-s)/l,(o-r)/l,(a-n)/l];if(e.pattern){let h=e.pattern.length,u=!1,d=0,f=0,p=0,g=[s,r,n],m=e.pattern[f];for(i.push(g[0],g[1],g[2]);m<=l-d;){let s=[c[0]*m,c[1]*m,c[2]*m],r=[g[0]+s[0],g[1]+s[1],g[2]+s[2]];i.push(r[0],r[1],r[2]),u||(t.push(p),t.push(p+1)),u=!u,p+=1,g=r,f+=1,f>=h&&(f=0),d+=m,m=e.pattern[f]}e.extendToEnd&&(i.push(A,o,a),t.push(t.length-2),t.push(t.length-1))}else t.push(0),t.push(1),i.push(s,r,n,A,o,a);return X.apply(e,{primitive:"lines",positions:i,indices:t})}const ht=V.vec4(4),ut=V.vec4(),dt=V.vec4(),ft=V.vec3([1,0,0]),pt=V.vec3([0,1,0]),gt=V.vec3([0,0,1]),mt=V.vec3(3),_t=V.vec3(3),bt=V.identityMat4();class Bt extends Ae{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=V.vec3(),this._quaternion=V.identityQuaternion(),this._rotation=V.vec3(),this._position=V.vec3(),this._offset=V.vec3(),this._localMatrix=V.identityMat4(),this._worldMatrix=V.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 i=0,s=e.length;i<s;i++)this.addChild(e[i],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=V.vec3()),this._origin.set(e)):this._origin&&(this._origin=null);for(let t=0,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;t++)this._children[t].edges=e}get edges(){return this._edges}set culled(e){e=!!e,this._culled=e;for(let t=0,i=this._children.length;t<i;t++)this._children[t].culled=e}get culled(){return this._culled}set clippable(e){e=!1!==e,this._clippable=e;for(let t=0,i=this._children.length;t<i;t++)this._children[t].clippable=e}get clippable(){return this._clippable}set collidable(e){e=!1!==e,this._collidable=e;for(let t=0,i=this._children.length;t<i;t++)this._children[t].collidable=e}get collidable(){return this._collidable}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,i=this._children.length;t<i;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,i=this._children.length;e<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;t++)this._children[t].castsShadow=e}get castsShadow(){return this._castsShadow}set receivesShadow(e){e=!!e,this._receivesShadow=e;for(let t=0,i=this._children.length;t<i;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)V.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,i=e.length;t<i;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_setSubtreeAABBsDirty(e){if(e._aabbDirty=!0,e._children)for(let t=0,i=e._children.length;t<i;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=V.AABB3()),this._buildAABB)this._buildAABB(this.worldMatrix,this._aabb);else{let e;V.collapseAABB3(this._aabb);for(let t=0,i=this._children.length;t<i;t++)e=this._children[t],e.collidable&&V.expandAABB3(this._aabb,e.aabb)}this._aabbDirty=!1}addChild(e,t){if(X.isNumeric(e)||X.isString(e)){const t=e;if(!(e=this.scene.component[t]))return void this.warn("Component not found: "+X.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,i=this._children.length;t<i;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,i=this._children.length;t<i;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(X.isNumeric(e)||X.isString(e)){const t=e;if(!(e=this.scene.components[t]))return void this.warn("Node not found: "+X.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]),V.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]),V.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=V.identityMat4()),this._localMatrix.set(e||bt),V.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=V.identityMat4()),V.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 ht[0]=e[0],ht[1]=e[1],ht[2]=e[2],ht[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(ht,ut),V.mulQuaternions(this.quaternion,ut,dt),this.quaternion=dt,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return ht[0]=e[0],ht[1]=e[1],ht[2]=e[2],ht[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(ht,ut),V.mulQuaternions(ut,this.quaternion,ut),this}rotateX(e){return this.rotate(ft,e)}rotateY(e){return this.rotate(pt,e)}rotateZ(e){return this.rotate(gt,e)}translate(e,t){return V.vec3ApplyQuaternion(this.quaternion,e,mt),V.mulVec3Scalar(mt,t,_t),V.addVec3(this.position,_t,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(ft,e)}translateY(e){return this.translate(pt,e)}translateZ(e){return this.translate(gt,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 i=0,s=e.length;i<s;i++)t=e[i],t.destroy()}this._children=[],this._setAABBDirty(),this.scene._aabbDirty=!0}}const yt=V.vec3(),wt=function(){const e=new Float64Array(16),t=new Float64Array(4),i=new Float64Array(4);return function(s,r,n){return n=n||e,t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,V.transformVec4(s,t,i),V.setMat4Translation(s,i,n),n.slice()}}();function vt(e,t,i){const s=Float32Array.from([e[0]])[0],r=e[0]-s,n=Float32Array.from([e[1]])[0],A=e[1]-n,o=Float32Array.from([e[2]])[0],a=e[2]-o;t[0]=s,t[1]=n,t[2]=o,i[0]=r,i[1]=A,i[2]=a}function Ct(e,t,i,s=1e3){const r=V.getPositionsCenter(e,yt),n=Math.round(r[0]/s)*s,A=Math.round(r[1]/s)*s,o=Math.round(r[2]/s)*s;i[0]=n,i[1]=A,i[2]=o;const a=0!==i[0]||0!==i[1]||0!==i[2];if(a)for(let i=0,s=e.length;i<s;i+=3)t[i+0]=e[i+0]-n,t[i+1]=e[i+1]-A,t[i+2]=e[i+2]-o;return a}const Mt=1e3,Et=1001,Ft=1002,Ut=1003,xt=1004,It=1004,Tt=1005,Pt=1005,St=1006,Dt=1007,kt=1007,Qt=1008,Rt=1008,Ot=1009,Vt=1010,Lt=1011,Ht=1012,Nt=1013,Gt=1014,jt=1015,Wt=1016,zt=1017,Xt=1018,Kt=1020,Zt=1021,Jt=1022,Yt=1023,$t=1024,qt=1025,ei=1026,ti=1027,ii=1028,si=1029,ri=1030,ni=1031,Ai=1033,oi=33776,ai=33777,li=33778,ci=33779,hi=35840,ui=35841,di=35842,fi=35843,pi=36196,gi=37492,mi=37496,_i=37808,bi=37809,Bi=37810,yi=37811,wi=37812,vi=37813,Ci=37814,Mi=37815,Ei=37816,Fi=37817,Ui=37818,xi=37819,Ii=37820,Ti=37821,Pi=36492,Si=3e3,Di=3001,ki=1e4,Qi=10001,Ri=10002,Oi=10003,Vi=new e({}),Li=V.vec3(),Hi=V.vec4(),Ni={3001:"sRGBToLinear"},Gi=function(){const e=[],t=[],i=[],s=[],r=[],n=[],A=[],o=(t,i)=>{let s=!1;return e.push((e=>s&&i(t,e))),{toString:()=>(s=!0,t)}},a={createAttribute:function(t,i){let s=!1;e.push((e=>s&&e.push(`in ${t} ${i};`)));const A={toString:()=>(s=!0,i)};return r.push((e=>{const t=s&&e(i);return t&&n.push(t.attributeHash),A.setInputValue=t,null})),A},createFragmentDefinition:(e,t)=>{let i=!1;return s.push((s=>i&&t(e,s))),{toString:()=>(i=!0,e)}},createOutput:(e,t,s)=>{let r=!1;return i.push((i=>r&&i.push(`layout(location = ${s||0}) out ${e} ${t};`))),{toString:()=>(r=!0,t)}},createUniform:(t,s,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${s};`);e.push(o),i.push(o);const a={toString:()=>(n=!0,s)};return A.push((e=>{const t=n&&e(s);return r?t&&(e=>r(t,e)):(a.setInputValue=t,null)})),a},createUniformArray:(t,s,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${s}[${r}];`);e.push(o),i.push(o);const a={toString:()=>(n=!0,s)};return A.push((e=>(a.setInputValue=n&&e(s),null))),a},createUniformBlock:(t,s,r)=>{let n=!1;const o=Object.keys(s),a=e=>{n&&(e.push(`uniform ${t} {`),o.forEach((t=>e.push(` ${s[t]} ${t};`))),e.push("};"))};e.push(a),i.push(a);const l={};return o.forEach((e=>l[e]={toString:()=>(n=!0,e)})),A.push((e=>{const i=n&&e(t);return r?i&&(e=>r(i,e)):(l.setInputValue=i,null)})),l},createVarying:(s,r,n,A)=>{let o=!1;const a=A?A+" ":"";return e.push((e=>o&&e.push(`${a}out ${s} ${r};`))),t.push((e=>o&&e.push(`${r} = ${n()};`))),i.push((e=>o&&e.push(`${a}in ${s} ${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:i=>{e.setInputValue(i.pickClipPos),t.setInputValue(i.pickClipPosInv)},transformedClipPos:()=>`vec4((${u}.xy / ${u}.w - ${e}) * ${t} * ${u}.w, ${u}.zw)`}}(),f=d?d.transformedClipPos():u,p=[],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?p.push(`gl_FragDepth = ${c.testPerspectiveForGl_FragDepth?`${g} == 0.0 ? gl_FragCoord.z : `:""}log2(${h(_)}) * ${m} * 0.5;`):c.cleanerEdges&&p.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 i=0;i<e;++i)t.push(i);return t}(B.getNumAllocatedSectionPlanes()).map((e=>{const t=(t,i,s)=>a.createUniform(t,`sectionPlane${i}${e}`,((t,i)=>{const r=B.sectionPlanes,n=r.length,A=(i.mesh.layerIndex||0)*n,o=e<n&&i.mesh.renderFlags.sectionPlanesActivePerLayer[A+e];return s(t,o,r[e],i.mesh.origin)}));return{act:t("bool","Active",((e,t)=>e(t?1:0))),dir:t("vec3","Dir",((e,t,i)=>t&&e(i.dir))),pos:t("vec3","Pos",((e,t,i,s)=>t&&e(s?V.mulVec3Scalar(V.normalizeVec3(i.dir,Li),-(V.dotVec3(i.dir,s)+i.dist),Li):i.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=i=>(t.needed=!0,`(sliced ? ${e} : ${i})`);return t}():e=>e,C=c.getGammaFactor,M=a.createUniform("float","gammaFactor",(e=>e(C())));c.appendFragmentOutputs(p,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 i=a.createVarying("highp vec3","vHighpWorldPosition",(()=>`${c.worldPositionAttribute}.xyz`));if(e.push(` float dist = ${y(i)};`),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 s.forEach((t=>t(e))),e}(),U=[...function(){const e=[];return i.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,...p,"}"],x=[`gl_Position = ${f};`,...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,...x,"}"],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(U),k=(e,t)=>{const i=t.join("\n"),s=o.createShader(e);return o.shaderSource(s,i),o.compileShader(s),o.getShaderParameter(s,o.COMPILE_STATUS)?[s]:[null,["Failed to compile",o.getShaderInfoLog(s),i.split("\n").map(((e,t)=>t+1+": "+e+"\n")).join("")]]},[Q,R]=k(o.VERTEX_SHADER,S),[O,L]=k(o.FRAGMENT_SHADER,D),H=e=>(console.error(e.join("\n")),[null,e]);if(R)return H(["Vertex shader error"].concat(R));if(L)return H(["Fragment shader error"].concat(L));{const e=o.createProgram();if(e){if(o.attachShader(e,Q),o.attachShader(e,O),o.linkProgram(e),o.getProgramParameter(e,o.LINK_STATUS)){const t=zi(o,e);r.forEach((e=>e(t)));const i=A.map((e=>e(t))).filter((e=>e)),s=Vi.addItem({});return[{id:s,bind:()=>o.useProgram(e),inputSetters:{attributesHash:n.sort().join(", "),setUniforms:(e,t)=>{d&&d.setClipPosInputValue(e),i.forEach((e=>e(t)))}},destroy:()=>{Vi.removeItem(s),o.deleteProgram(e),o.deleteShader(Q),o.deleteShader(O)}}]}return H(["",o.getProgramInfoLog(this.program),"","Vertex shader:","",...S,"","Fragment shader:","",...D])}return H(["Failed to allocate program"])}}}},ji=function(e,t){const i=e.createUniform("vec4","lightAmbient",(e=>e(t.getAmbientColorAndIntensity()))),s=t.lights,r=s.map(((t,i)=>{const r={color:e.createUniform("vec4",`lightColor${i}`,(e=>{const t=s[i];Hi[0]=t.color[0],Hi[1]=t.color[1],Hi[2]=t.color[2],Hi[3]=t.intensity,e(Hi)})),position:e.createUniform("vec3",`lightPos${i}`,(e=>e(s[i].pos))),direction:e.createUniform("vec3",`lightDir${i}`,(e=>e(s[i].dir))),shadowProjMatrix:e.createUniform("mat4",`shadowProjMatrix${i}`,(e=>e(s[i].getShadowViewMatrix()))),shadowViewMatrix:e.createUniform("mat4",`shadowViewMatrix${i}`,(e=>e(s[i].getShadowViewMatrix()))),shadowMap:e.createUniform("sampler2D",`shadowMap${i}`,(e=>e(s[i].getShadowRenderBuf().colorTextures[0])))},n=e=>({glslLight:{isViewSpace:"view"===t.space,getColor:()=>`${r.color}.rgb * ${r.color}.a`,getDirection:(t,i)=>`normalize(${e(t,i)})`,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,i)=>{const s=()=>{const e=i();return e.length>0&&e[0]},r=s();return r&&Wi(e,"samplerCube",t,r.encoding,(e=>{const t=s();t&&e(t.texture)}))},A=n("light",(()=>t.lightMaps)),o=n("reflection",(()=>t.reflectionMaps));return{getHash:()=>t.getHash(),getAmbientColor:()=>`${i}.rgb * ${i}.a`,directionalLights:r.map((e=>e.glslLight)),getIrradiance:A&&(e=>`${A(e)}.rgb`),getReflection:o&&((e,t)=>`${o(e,t)}.rgb`)}},Wi=(e,t,i,s,r)=>{const n=e.createUniform(t,i+"Map",r);return(e,t)=>{const i=t?`texture(${n}, ${e}, ${t})`:`texture(${n}, ${e})`;return 3e3!==s?`${Ni[s]}(${i})`:i}},zi=function(e,t){const i={},s=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<s;++r){const n=e.getActiveAttrib(t,r),A=e.getAttribLocation(t,n.name);i[n.name]=function(t){t.bindAtLocation(A),e.enableVertexAttribArray(A);const i=t.attributeDivisor;i&&e.vertexAttribDivisor(A,i)},i[n.name].attributeHash=`${A.toString().padStart(1+Math.floor(Math.log10(s)),"0")}:${n.name}`}const r=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<r;++s){const r=e.getActiveUniformBlockName(t,s),n=e.getUniformBlockIndex(t,r),A=s;e.uniformBlockBinding(t,n,A);const o=e.createBuffer();i[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 s=0;s<n;++s){const r=e.getActiveUniform(t,s);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++;i[n]=function(i){const s=i.bind(t);return s&&e.uniform1i(o,t),s}}else i[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=i[e];if(!t)throw`Missing input "${e}"`;return t}},Xi=V.vec4(),Ki=V.vec4();class Zi{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 Ji=V.OBB3(),Yi=V.vec4(),$i=V.vec4(),qi=V.vec4(),es=V.vec3([1,0,0]),ts=V.vec3([0,1,0]),is=V.vec3([0,0,1]),ss=V.vec3(3),rs=V.vec3(3),ns=V.identityMat4(),As=new e({}),os={};class as extends Ae{constructor(e,t={}){super(e,t),this.renderOrder=t.renderOrder||0,this.originalSystemId=t.originalSystemId||this.id,this.renderFlags=new Zi,this._state=new Se({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:V.vec3(),origin:null,originHash:null,isUI:t.isUI});const i=t.material?this._checkComponent2(["PhongMaterial","MetallicMaterial","SpecularMaterial","LambertMaterial"],t.material):this.scene.material,s=this,r=e=>{let t=null;const i=()=>{if(!t){const i=Gi(),r=i.programVariables.createAttribute,n=s._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(i.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,s.scene.canvas.canvas.id,s.scene._sectionPlanesState.getHash(),s._geometry._state.hash].concat(h.getHash()).join(";");if(!(u in os)){const e=cs(s,A,{decodedUv:c,worldNormal:a,viewNormal:l},h,i);if(e.errors)return void console.log(e.errors.join("\n"));const t=As.addItem({});os[u]={drawMesh:e.drawMesh,id:t,useCount:0,delete:()=>{As.removeItem(t),e.destroy(),delete os[u],G.memory.programs--}},G.memory.programs++}t=os[u],t.useCount++}};return{get:i,getId:()=>t.id,put:()=>{t&&(0==--t.useCount&&t.delete(),t=null)},drawMesh:(e,s,r)=>{i(),t&&t.drawMesh(e,s,r)}}},n=s.scene,A=e=>(t,i)=>function(e,t,i,s,r){const n=r&&ji(t,s._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=i.attributes,t=r&&[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(i.viewMatrix,e.position.view)}), 0.0) * ${t.getColor()})`)):[]);return`vec4(${A}${t?` * (${t.join(" + ")})`:""}, ${o})`})),l=t.createOutput("vec4","outColor");return{getHash:()=>[e,s.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};`)}}(s._state.hash,t,i,n,e);this._renderers={_drawRenderer:r(((e,t)=>"LambertMaterial"===i.type?function(e,t,i,s,r){const n=ji(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=i.attributes,t=[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(i.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(),s._state.hash],programName:"Lambert",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t)=>e.push(`${h} = ${t?t(c):c};`)}}(s._state.drawHash,e,t,i,n):function(e,t,i,s,r){const n=s._state,A="PhongMaterial"===n.type,o="MetallicMaterial"===n.type,a="SpecularMaterial"===n.type,l=i.attributes,c=ji(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,i,r)=>{const n=(i,s,n)=>t.createUniform(i,e+"Fresnel"+s,((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(s)&&((e,t)=>`mix(${l+i}, ${c+i}, ${u}(${e}, ${t}, ${A}, ${o}, ${a}))`)},f=d("diffuse","",(e=>e._diffuseFresnel)),p=d("specular","",(e=>e._specularFresnel)),g=d("emissive","",(e=>e._emissiveFresnel)),m=d("alpha",".r",(e=>e._alphaFresnel)),_=(e,i)=>{const r=l.uv&&i(s),n=r&&Wi(t,"sampler2D",e,r.encoding,((e,t)=>e(i(t.material)._state.texture)));return n&&function(){const s=r._state.matrix&&t.createUniform("mat4",e+"MapMatrix",((e,t)=>e(i(t.material)._state.matrix))),A=s?e=>`(${s} * ${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)),U=_("specular",(e=>e._specularMap)),x=_("glossiness",(e=>e._glossinessMap)),I=_("specularGlossiness",(e=>e._specularGlossinessMap)),T=_("normal",(e=>e._normalMap)),P=(e,i,r)=>{const n=r(s);return("float"===i?null!=n:n)&&t.createUniform(i,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?(Xi[0]=t,Xi[1]=1===e.alphaMode?1:0,Xi[2]=e.alphaCutoff,Xi):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,s)=>({vViewLightReverseDir:t.createVarying("vec3",`vViewLightReverseDir${s}`,(()=>e.getDirection(i.viewMatrix,null))),vShadowPosFromLight:t.createVarying("vec3",`vShadowPosFromLight${s}`,(()=>`(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(),s._state.hash],programName:"Draw",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t,s)=>{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)&&U&&e.push(`specular *= ${U(W)}.rgb;`),a&&x&&e.push(`glossiness *= ${x(W)}.r;`),a&&I&&(e.push("vec4 specGlossTexel = "+I(W)+";"),e.push("specular *= specGlossTexel.rgb;"),e.push("glossiness *= specGlossTexel.a;"));const t=`normalize(${X})`,s=(A||o||a)&&T?`${ee}(${j}, ${t}, ${T.getTexCoordExpression(W)}, ${T(W)})`:t;if(e.push(`vec3 viewNormal = ${s};`),e.push(`vec3 viewEyeDir = normalize(-${j});`),f&&e.push(`diffuseColor *= ${f("viewEyeDir","viewNormal")};`),p&&e.push(`specular *= ${p("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)",s=A?`0.2 * PI * ${c.getReflection(t)}`:function(){const e=`${q}(viewNormal, viewEyeDir, specular, roughness)`,s=`normalize((vec4(${t}, 0.0) * ${i.viewMatrix}).xyz)`;return`${e} * ${c.getReflection(s,"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 += ${s};`)}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,i)=>{if(t.shadowParameters){const s="0.007";e.push(`fragmentDepth = ${K[i].vShadowPosFromLight}.z - ${s};`),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[i].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${i} = ${t.getColor()}${t.shadowParameters?" * shadow":""};`),e.push(`vec3 lightDirection${i} = ${t.isViewSpace?t.getDirection(null,j):K[i].vViewLightReverseDir};`);const s=`${Y}(dot(viewNormal, lightDirection${i}))`;e.push(`vec3 irradiance${i} = ${s} * lightColor${i};`),e.push(`reflDiff += irradiance${i};`);const r=A?`lightColor${i} * specular * pow(max(dot(reflect(-lightDirection${i}, -viewNormal), viewEyeDir), 0.0), shininess)`:`irradiance${i} * PI * ${$}(lightDirection${i}, 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"};`)}}}(s._state.drawHash,e,t,i,n))),_shadowRenderer:r((e=>function(e,t){const i=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("}")})),s=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Shadow",setsLineWidth:!0,useShadowView:!0,dontBillboardAnything:!0,dontGetLogDepth:!0,appendFragmentOutputs:(e,t,r)=>e.push(`${s} = ${i}(${r}.z);`)}}(s._state.hash,e))),_emphasisEdgesRenderer:r(A(!1)),_emphasisFillRenderer:r(A(!0)),_pickMeshRenderer:r((e=>function(e,t){const i=t.createUniform("vec4","pickColor",((e,t)=>{var i=t.meshPickID;Ki[0]=255&i,Ki[1]=i>>8&255,Ki[2]=i>>16&255,Ki[3]=i>>24&255,V.mulVec4Scalar(Ki,1/255,Ki),e(Ki)})),s=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickMesh",isPick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${s} = ${i};`)}}(s._state.hash,e))),_pickTriangleRenderer:r(((e,t)=>function(e,t,i){const s=t.createVarying("vec4","vColor",(()=>i.attributes.pickColor)),r=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickTriangle",isPick:!0,trianglePick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${r} = ${s};`)}}(s._state.hash,e,t))),_occlusionRenderer:r((e=>function(e,t){const i=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Occlusion",skipIfTransparent:!0,appendFragmentOutputs:e=>e.push(`${i} = vec4(0.0, 0.0, 1.0, 1.0);`)}}(s._state.pickOcclusionHash,e)))},this._geometry=t.geometry?this._checkComponent2(["ReadableGeometry","VBOGeometry"],t.geometry):this.scene.geometry,this._material=i,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=V.vec3(),this._quaternion=V.identityQuaternion(),this._rotation=V.vec3(),this._position=V.vec3(),this._worldMatrix=V.identityMat4(),this._worldNormalMatrix=V.identityMat4(),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,this._worldNormalMatrixDirty=!0;const o=t.origin||t.rtcCenter;if(o&&(this._state.origin=V.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]),V.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]),V.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=V.identityMat4()),V.composeMat4(this._position,this._quaternion,this._scale,this.__localMatrix),this._localMatrixDirty=!1),this.__localMatrix}set matrix(e){this.__localMatrix||(this.__localMatrix=V.identityMat4()),this.__localMatrix.set(e||ns),V.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=V.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 i=!!e;this.scene._objectColorizeUpdated(this,i),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 i=null!=e;t[3]=i?e:1,this.scene._objectOpacityUpdated(this,i),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,i=[e.canvas.canvas.id,e._sectionPlanesState.getHash()];t.stationary&&i.push("/s"),"none"===t.billboard?i.push("/n"):"spherical"===t.billboard?i.push("/s"):"cylindrical"===t.billboard&&i.push("/c"),i.push(";");const s=i.concat([e.gammaOutput?"go":"",e._lightsState.getHash(),t.receivesShadow?"/rs":""]).join("");this._state.drawHash!==s&&(this._state.drawHash=s,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=i.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)V.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,i=e.length;t<i;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_buildWorldNormalMatrix(){this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldNormalMatrix||(this._worldNormalMatrix=V.mat4()),V.transposeMat4(this._worldMatrix,this._worldNormalMatrix),V.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=V.AABB3()),this._buildAABB(this.worldMatrix,this._aabb),this._aabbDirty=!1}_buildAABB(e,t){V.transformOBB3(e,this._geometry.obb,Ji),V.OBB3ToAABB3(Ji,t);const i=this._state.offset;if(t[0]+=i[0],t[1]+=i[1],t[2]+=i[2],t[3]+=i[0],t[4]+=i[1],t[5]+=i[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 Yi[0]=e[0],Yi[1]=e[1],Yi[2]=e[2],Yi[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(Yi,$i),V.mulQuaternions(this.quaternion,$i,qi),this.quaternion=qi,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return Yi[0]=e[0],Yi[1]=e[1],Yi[2]=e[2],Yi[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(Yi,$i),V.mulQuaternions($i,this.quaternion,$i),this}rotateX(e){return this.rotate(es,e)}rotateY(e){return this.rotate(ts,e)}rotateZ(e){return this.rotate(is,e)}translate(e,t){return V.vec3ApplyQuaternion(this.quaternion,e,ss),V.mulVec3Scalar(ss,t,rs),V.addVec3(this.position,rs,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(es,e)}translateY(e){return this.translate(ts,e)}translateZ(e){return this.translate(is,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 i=0;i<t;i++){const t=e[i],s=this.renderFlags;if(t.active)if(this._state.origin){const e=V.planeAABB3Intersect(t.dir,t.dist,this.aabb);if(-1===e)return!1;const r=0===e;s.sectionPlanesActivePerLayer[i]=r}else s.sectionPlanesActivePerLayer[i]=!0;else s.sectionPlanesActivePerLayer[i]=!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,i,s){ls(this,e,t,i,s)}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 ls=function(){const e=V.vec3(),t=V.vec3(),i=V.vec3(),s=V.vec3(),r=V.vec3(),n=V.vec3(),A=V.vec4(),o=V.vec3(),a=V.vec3(),l=V.vec3(),c=V.vec3(),h=V.vec3(),u=V.vec3(),d=V.vec3(),f=V.vec3(),p=V.vec3(),g=V.vec4(),m=V.vec4(),_=V.vec4(),b=V.vec3(),B=V.vec3(),y=V.vec3(),w=V.vec3(),v=V.vec3(),C=V.vec3(),M=V.vec3(),E=V.vec3(),F=V.vec3(),U=V.vec3(),x=V.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],R=j[H+1],O=j[H+2];n[0]=Q,n[1]=R,n[2]=O,D.indices=n,z=3*Q,X=3*R,K=3*O}else z=3*H,X=z+3,K=X+3;if(i[0]=W[z+0],i[1]=W[z+1],i[2]=W[z+2],s[0]=W[X+0],s[1]=W[X+1],s[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&&(Ne.decompressPosition(i,e,i),Ne.decompressPosition(s,e,s),Ne.decompressPosition(r,e,r))}D.canvasPos?V.canvasPosToLocalRay(G.canvas,I.origin?wt(T,I.origin):T,P,S,I.worldMatrix,D.canvasPos,e,t):D.origin&&D.direction&&V.worldRayToLocalRay(I.worldMatrix,D.origin,D.direction,e,t),V.normalizeVec3(t),V.rayPlaneIntersect(e,t,i,s,r,A),D.localPos=A,D.position=A,g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=1,V.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,V.transformVec4(N.matrix,m,_),a[0]=_[0],a[1]=_[1],a[2]=_[2],D.viewPos=a,V.cartesianToBarycentric(A,i,s,r,l),D.bary=l;const Z=L.normals;if(Z){if(L.compressGeometry){const e=3*Q,t=3*R,i=3*O;Ne.decompressNormal(Z.subarray(e,e+2),c),Ne.decompressNormal(Z.subarray(t,t+2),h),Ne.decompressNormal(Z.subarray(i,i+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=V.addVec3(V.addVec3(V.mulVec3Scalar(c,l[0],b),V.mulVec3Scalar(h,l[1],B),y),V.mulVec3Scalar(u,l[2],w),v);D.worldNormal=V.normalizeVec3(V.transformVec3(I.worldNormalMatrix,e,C))}const J=L.uv;if(J){if(d[0]=J[2*Q],d[1]=J[2*Q+1],f[0]=J[2*R],f[1]=J[2*R+1],p[0]=J[2*O],p[1]=J[2*O+1],L.compressGeometry){const e=L.uvDecodeMatrix;e&&(Ne.decompressUV(d,e,d),Ne.decompressUV(f,e,f),Ne.decompressUV(p,e,p))}D.uv=V.addVec3(V.addVec3(V.mulVec2Scalar(d,l[0],M),V.mulVec2Scalar(f,l[1],E),F),V.mulVec2Scalar(p,l[2],U),x)}}}}}(),cs=(e,t,i,s,r)=>{const n=r.programVariables,A=i.decodedUv,o=i.worldNormal,a=i.viewNormal,l=e.scene,c=l.canvas.gl,h=e._state.background,u=e._geometry._state,d=u.compressGeometry,f="points"===u.primitiveName,p=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=!s.dontBillboardAnything&&("spherical"===M||"cylindrical"===M),F=e.stationary,U=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)))),x=function(){const e=U&&n.createVertexDefinition("billboard",U);return t=>e?`${e}(${t})`:t}(),I=function(){const e=U&&n.createFragmentDefinition("billboard",U);return t=>e?`${e}(${t})`:t}(),T=[];s.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,s.programName,{appendFragmentOutputs:(e,t,i,r)=>{T.forEach((t=>e.push(t))),s.appendFragmentOutputs(e,t,i,r)},clippableTest:()=>S,clippingCaps:s.clippingCaps,clipPos:h?"clipPos.xyww":P,crossSections:l.crossSections,discardPoints:f&&s.discardPoints,getGammaFactor:l.gammaOutput&&(()=>l.gammaFactor),getLogDepth:!s.dontGetLogDepth&&l.logarithmicDepthBufferEnabled&&(e=>e),getPointSize:s.setupPointSize&&f&&(()=>p),getVertexData:function(){const e=a&&a.needed&&`vec3 ${a} = normalize((${x(v)} * vec4(${o}, 0.0)).xyz);`,i=[];if(i.push(`vec4 localPosition = vec4(${t.position}, 1.0);`),d&&i.push(`localPosition = ${B} * localPosition;`),i.push(`vec4 worldPosition = ${x(g)} * localPosition;`),i.push(`worldPosition.xyz = worldPosition.xyz + ${_};`),s.dontBillboardAnything?i.push(`vec4 viewPosition = ${w} * worldPosition;`):(i.push(`mat4 viewMatrix1 = ${w};`),F?i.push("viewMatrix1[3].xyz = vec3(0.0, 0.0, 0.0);"):h&&i.push("viewMatrix1[3] = vec4(0.0, 0.0, 0.0, 1.0);"),i.push(`mat4 viewMatrix2 = ${x("viewMatrix1")};`),i.push(`vec4 viewPosition = ${E?`${x(`viewMatrix1 * ${g}`)} * localPosition`:"viewMatrix2 * worldPosition"};`)),A&&A.needed&&i.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;i.push(`vec3 ${o} = (${x(m)} * vec4(${e}, 0.0)).xyz;`)}return e&&i.push(e),i.push(`vec4 clipPos = ${C} * viewPosition;`),i},projMatrix:C,sectionPlanesState:l._sectionPlanesState,testPerspectiveForGl_FragDepth:!0,usePickClipPos:s.isPick,worldPositionAttribute:"worldPosition"});if(k)return{errors:k};{const e=D.inputSetters;let i=null,r=null;return{destroy:()=>D.destroy(),drawMesh:(n,A,o)=>{if(s.skipIfTransparent&&o.alpha<1)return;const a=o._state,l=A._state,u=A._geometry,d=u._state,f=n.viewParams,M=s.canActAsBackground&&h;n.lastProgramId!==D.id&&(n.lastProgramId=D.id,D.bind(),n.useProgram++,i=null,r=null,M&&c.depthFunc(c.LEQUAL)),a.id!==i&&(n.backfaces!==a.backfaces&&(a.backfaces?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE),n.backfaces=a.backfaces),s.dontSetFrontFace||n.frontface===a.frontface||(c.frontFace(a.frontface?c.CCW:c.CW),n.frontface=a.frontface),s.drawEdges&&n.lineWidth!==a.edgeWidth&&(c.lineWidth(a.edgeWidth),n.lineWidth=a.edgeWidth),s.setsLineWidth&&n.lineWidth!==a.lineWidth&&(c.lineWidth(a.lineWidth),n.lineWidth=a.lineWidth),i=a.id);const E=!s.useShadowView&&A.origin;((t,i)=>{const s=(e,t)=>e.setInputValue&&e.setInputValue(t);s(p,o.pointSize),s(g,A.worldMatrix),s(m,A.worldNormalMatrix),s(_,A.offset),s(b,A.scale),s(B,d.positionsDecodeMatrix),s(y,d.uvDecodeMatrix),s(w,i),s(v,f.viewNormalMatrix),s(C,t),s(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:f.far}})})(f.projMatrix,E?n.getRTCViewMatrix(l.originHash,E):f.viewMatrix);const F=e=>{const i=(e,t)=>{e&&e.setInputValue&&t&&(e.setInputValue(t),n.bindArray++)};i(t.position,(e||d).positionsBuf),i(t.color,d.colorsBuf),i(t.pickColor,e&&e.pickColorsBuf),i(t.uv,d.uvBuf),i(t.normal,d.normalsBuf)};if(s.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(s.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 hs extends Ae{get type(){return"Material"}constructor(e,t={}){super(e,t),G.memory.materials++}destroy(){super.destroy(),G.memory.materials--}}const us={opaque:0,mask:1,blend:2},ds=["opaque","mask","blend"];class fs extends hs{get type(){return"PhongMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"PhongMaterial",ambient:V.vec3([1,1,1]),diffuse:V.vec3([1,1,1]),specular:V.vec3([1,1,1]),emissive:V.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=us[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 ds[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 ps(e,t){if(void 0===e._cachedExtensions&&(e._cachedExtensions={}),void 0!==e._cachedExtensions[t])return e._cachedExtensions[t];let i;switch(t){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(t)}return e._cachedExtensions[t]=i,i}function gs(e,t,i=null){let s;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===i){const t=ps(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(s=ps(e,"WEBGL_compressed_texture_s3tc"),null===s)return null;if(33776===r)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===r)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===r)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===r)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===r||35841===r||35842===r||35843===r){const t=ps(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=ps(e,"WEBGL_compressed_texture_etc1");return null!==t?t.COMPRESSED_RGB_ETC1_WEBGL:null}if(37492===r||37496===r){const t=ps(e,"WEBGL_compressed_texture_etc");if(null===t)return null;if(37492===r)return 3001===i?t.COMPRESSED_SRGB8_ETC2:t.COMPRESSED_RGB8_ETC2;if(37496===r)return 3001===i?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=ps(e,"WEBGL_compressed_texture_astc");if(null===t)return null;if(37808===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:t.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:t.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:t.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:t.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:t.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:t.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:t.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:t.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:t.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:t.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:t.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:t.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:t.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:t.COMPRESSED_RGBA_ASTC_12x12_KHR}if(36492===r){const t=ps(e,"EXT_texture_compression_bptc");if(null===t)return null;if(36492===r)return 3001===i?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 ms=new Uint8Array([0,0,0,1]);class _s{constructor({gl:e,target:t,format:i,type:s,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=i||1023,this.type=s||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?(ms[0]=Math.floor(255*e[0]),ms[1]=Math.floor(255*e[1]),ms[2]=Math.floor(255*e[2]),ms[3]=Math.floor(255*(void 0!==e[3]?e[3]:1))):(ms[0]=0,ms[1]=0,ms[2]=0,ms[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 i=0,s=e.length;i<s;i++)t.texImage2D(e[i],0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ms)}else t.texImage2D(this.target,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ms);t.bindTexture(this.target,null)}setTarget(e){this.target=e||this.gl.TEXTURE_2D}setImage(e,t={}){const i=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 s=!1;i.bindTexture(this.target,this.texture);const r=i.getParameter(i.UNPACK_FLIP_Y_WEBGL);i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,this.flipY);const n=i.getParameter(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL);i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);const A=i.getParameter(i.UNPACK_ALIGNMENT);i.pixelStorei(i.UNPACK_ALIGNMENT,this.unpackAlignment);const o=i.getParameter(i.UNPACK_COLORSPACE_CONVERSION_WEBGL);i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);const a=gs(i,this.minFilter);i.texParameteri(this.target,i.TEXTURE_MIN_FILTER,a),a!==i.NEAREST_MIPMAP_NEAREST&&a!==i.LINEAR_MIPMAP_NEAREST&&a!==i.NEAREST_MIPMAP_LINEAR&&a!==i.LINEAR_MIPMAP_LINEAR||(s=!0);const l=gs(i,this.magFilter);l&&i.texParameteri(this.target,i.TEXTURE_MAG_FILTER,l);const c=gs(i,this.wrapS);c&&i.texParameteri(this.target,i.TEXTURE_WRAP_S,c);const h=gs(i,this.wrapT);h&&i.texParameteri(this.target,i.TEXTURE_WRAP_T,h);const u=gs(i,this.format,this.encoding),d=gs(i,this.type),f=bs(i,this.internalFormat,u,d,this.encoding,!1);if(this.target===i.TEXTURE_CUBE_MAP){if(X.isArray(e)){const t=e,s=[i.TEXTURE_CUBE_MAP_POSITIVE_X,i.TEXTURE_CUBE_MAP_NEGATIVE_X,i.TEXTURE_CUBE_MAP_POSITIVE_Y,i.TEXTURE_CUBE_MAP_NEGATIVE_Y,i.TEXTURE_CUBE_MAP_POSITIVE_Z,i.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(let e=0,r=s.length;e<r;e++)i.texImage2D(s[e],0,f,u,d,t[e])}}else i.texImage2D(i.TEXTURE_2D,0,f,u,d,e);s&&i.generateMipmap(this.target),i.bindTexture(this.target,null),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,r),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n),i.pixelStorei(i.UNPACK_ALIGNMENT,A),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,o)}setCompressedData({mipmaps:e,props:t={}}){const i=this.gl,s=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),i.activeTexture(i.TEXTURE0+0),i.bindTexture(this.target,this.texture);let r=e.length>1;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,this.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,this.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);const n=gs(i,this.wrapS);n&&i.texParameteri(this.target,i.TEXTURE_WRAP_S,n);const A=gs(i,this.wrapT);if(A&&i.texParameteri(this.target,i.TEXTURE_WRAP_T,A),this.type===i.TEXTURE_3D||this.type===i.TEXTURE_2D_ARRAY){const e=gs(i,this.wrapR);e&&i.texParameteri(this.target,i.TEXTURE_WRAP_R,e),i.texParameteri(this.type,i.TEXTURE_WRAP_R,e)}r?(i.texParameteri(this.target,i.TEXTURE_MIN_FILTER,Bs(i,this.minFilter)),i.texParameteri(this.target,i.TEXTURE_MAG_FILTER,Bs(i,this.magFilter))):(i.texParameteri(this.target,i.TEXTURE_MIN_FILTER,gs(i,this.minFilter)),i.texParameteri(this.target,i.TEXTURE_MAG_FILTER,gs(i,this.magFilter)));const o=gs(i,this.format,this.encoding),a=gs(i,this.type),l=bs(i,this.internalFormat,o,a,this.encoding,!1);i.texStorage2D(i.TEXTURE_2D,s,l,e[0].width,e[0].height);for(let t=0,s=e.length;t<s;t++){const s=e[t];1023!==this.format?null!==o?i.compressedTexSubImage2D(i.TEXTURE_2D,t,0,0,s.width,s.height,o,s.data):console.warn("Attempt to load unsupported compressed texture format in .setCompressedData()"):i.texSubImage2D(i.TEXTURE_2D,t,0,0,s.width,s.height,o,a,s.data)}i.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 i=gs(t,e.minFilter);i&&(this.minFilter=e.minFilter,t.texParameteri(this.target,t.TEXTURE_MIN_FILTER,i),i!==t.NEAREST_MIPMAP_NEAREST&&i!==t.LINEAR_MIPMAP_NEAREST&&i!==t.NEAREST_MIPMAP_LINEAR&&i!==t.LINEAR_MIPMAP_LINEAR||t.generateMipmap(this.target))}if(void 0!==e.magFilter){const i=gs(t,e.magFilter);i&&(this.magFilter=e.magFilter,t.texParameteri(this.target,t.TEXTURE_MAG_FILTER,i))}if(void 0!==e.wrapS){const i=gs(t,e.wrapS);i&&(this.wrapS=e.wrapS,t.texParameteri(this.target,t.TEXTURE_WRAP_S,i))}if(void 0!==e.wrapT){const i=gs(t,e.wrapT);i&&(this.wrapT=e.wrapT,t.texParameteri(this.target,t.TEXTURE_WRAP_T,i))}}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 bs(e,t,i,s,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=i;return i===e.RED&&(s===e.FLOAT&&(A=e.R32F),s===e.HALF_FLOAT&&(A=e.R16F),s===e.UNSIGNED_BYTE&&(A=e.R8)),i===e.RG&&(s===e.FLOAT&&(A=e.RG32F),s===e.HALF_FLOAT&&(A=e.RG16F),s===e.UNSIGNED_BYTE&&(A=e.RG8)),i===e.RGBA&&(s===e.FLOAT&&(A=e.RGBA32F),s===e.HALF_FLOAT&&(A=e.RGBA16F),s===e.UNSIGNED_BYTE&&(A=3001===r&&!1===n?e.SRGB8_ALPHA8:e.RGBA8),s===e.UNSIGNED_SHORT_4_4_4_4&&(A=e.RGBA4),s===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||ps(e,"EXT_color_buffer_float"),A}function Bs(e,t){return 1003===t||1004===t||1005===t?e.NEAREST:e.LINEAR}function ys(e){if(!ws(e.width)||!ws(e.height)){const t=document.createElement("canvas");t.width=vs(e.width),t.height=vs(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function ws(e){return 0==(e&e-1)}function vs(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class Cs extends Ae{get type(){return"Texture"}constructor(e,t={}){super(e,t),this._state=new Se({texture:new _s({gl:this.scene.canvas.gl}),matrix:V.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=V.vec2([0,0]),this._scale=V.vec2([1,1]),this._rotate=V.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),G.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,i;0===this._translate[0]&&0===this._translate[1]||(t=V.translationMat4v([this._translate[0],this._translate[1],0],this._state.matrix)),1===this._scale[0]&&1===this._scale[1]||(i=V.scalingMat4v([this._scale[0],this._scale[1],1]),t=t?V.mulMat4(t,i):i),0!==this._rotate&&(i=V.rotationMat4v(.0174532925*this._rotate,[0,0,1]),t=t?V.mulMat4(t,i):i),t&&(e.matrix=t),this._matrixDirty=!1}this.glRedraw()}set image(e){this._image=ys(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 i=new Image;i.onload=function(){i=ys(i),t._state.texture.setImage(i,t._state),t.scene.loading--,t.glRedraw(),t.scene.canvas.spinner.processes--},i.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(),G.memory.textures--}}const Ms=V.vec3(),Es=V.vec3();V.vec3();const Fs=V.vec3([0,-1,0]),Us=V.vec4([0,0,0,1]);class xs extends Ae{constructor(e,t={}){super(e,t),this._src=null,this._image=null,this._pos=V.vec3(),this._origin=V.vec3(),this._rtcPos=V.vec3(),this._dir=V.vec3(),this._size=1,this._imageSize=V.vec2(),this._texture=new Cs(this),this._plane=new as(this,{geometry:new We(this,st({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new fs(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 as(this,{geometry:new We(this,it({size:1,divisions:10})),material:new fs(this,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:t.clippable}),this._node=new Bt(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]),vt(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,i=[-this._dir[0],-this._dir[1],-this._dir[2]];V.subVec3(t,this.position,Ms);const s=-V.dotVec3(i,Ms);V.normalizeVec3(i),V.mulVec3Scalar(i,s,Es),V.vec3PairToQuaternion(Fs,e,Us),this._node.quaternion=Us}}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],i=this._imageSize[1];if(t>i){const s=i/t;this._node.scale=[e,1,e*s]}else{const s=t/i;this._node.scale=[e*s,1,e]}}}class Is extends hs{get type(){return"LambertMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"LambertMaterial",ambient:V.vec3([1,1,1]),color:V.vec3([1,1,1]),emissive:V.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 Ts={opaque:0,mask:1,blend:2},Ps=["opaque","mask","blend"];class Ss extends hs{get type(){return"MetallicMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"MetallicMaterial",baseColor:V.vec4([1,1,1]),emissive:V.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=Ts[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 Ps[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 Ds={opaque:0,mask:1,blend:2},ks=["opaque","mask","blend"];class Qs extends hs{get type(){return"SpecularMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"SpecularMaterial",diffuse:V.vec3([1,1,1]),emissive:V.vec3([0,0,0]),specular:V.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=Ds[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 ks[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 Rs={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 Os extends hs{get type(){return"EmphasisMaterial"}get presets(){return Rs}constructor(e,t={}){super(e,t),this._state=new Se({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=Rs[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(Rs).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 Vs={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 Ls extends hs{get type(){return"EdgeMaterial"}get presets(){return Vs}constructor(e,t={}){super(e,t),this._state=new Se({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=Vs[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(Vs).join(", "))}get preset(){return this._preset}destroy(){super.destroy(),this._state.destroy()}}class Hs extends Ae{get type(){return"Fresnel"}constructor(e,t={}){super(e,t),this._state=new Se({edgeColor:V.vec3([0,0,0]),centerColor:V.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()}}class Ns extends Ae{constructor(e,t={}){super(e,t),this._type=t.type||(t.src?t.src.split(".").pop():null)||"jpg",this._pos=V.vec3(t.pos||[0,0,0]),this._up=V.vec3(t.up||[0,1,0]),this._normal=V.vec3(t.normal||[0,0,1]),this._height=t.height||1,this._origin=V.vec3(),this._rtcPos=V.vec3(),this._imageSize=V.vec2(),this._texture=new Cs(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 Bt(this,{matrix:V.inverseMat4(V.lookAtMat4v(this._pos,V.subVec3(this._pos,this._normal,V.mat4()),this._up,V.mat4())),children:[this._bitmapMesh=new as(this,{scale:[1,1,1],rotation:[-90,0,0],collidable:t.collidable,pickable:t.pickable,opacity:t.opacity,clippable:t.clippable,geometry:new We(this,st({center:[0,0,0],xSize:1,zSize:1,xSegments:2,zSegments:2})),material:new fs(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 Gs=(e,t)=>{const i=[];let s=[];function r(e,i){let s,r;for(let n=0;n<3;n++)if(s=t[3*e+n],r=t[3*i+n],s!==r)return r-s;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]),i[n[e]]=A;for(let t=0,r=e.length;t<r;t+=3){const r=i[e[t]],n=i[e[t+1]],A=i[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)),s[t+0]=[o,a],s[t+1]=[a,l],o>l){const e=l;l=o,o=e}s[t+2]=[l,o]}function o(e,t){let i,s;for(let r=0;r<2;r++)if(i=e[r],s=t[r],s!==i)return s-i;return 0}s=s.slice(0,e.length),s.sort(o);let a=0;for(let e=0;e<s.length;e++)if(0===e||0!==o(s[e],s[e-1])){if(0!==e&&2!==a)return!1;a=1}else a++;return!(s.length>0&&2!==a)},js=V.vec3(),Ws=V.vec3(),zs=V.vec3();class Xs{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&&!Gs(t,e))return-1;let i=0;for(let s=0;s<this.lenIndices;s+=3){const r=3*t[s],n=3*t[s+1],A=3*t[s+2];js[0]=e[r],js[1]=e[r+1],js[2]=e[r+2],Ws[0]=e[n],Ws[1]=e[n+1],Ws[2]=e[n+2],zs[0]=e[A],zs[1]=e[A+1],zs[2]=e[A+2],V.cross3Vec3(js,Ws,js),i+=V.dotVec3(js,zs)}return i/6}}const Ks=new Xs,Zs=V.vec3(),Js=V.vec3(),Ys=V.vec3(),$s=V.vec3(),qs=V.vec3(),er=V.vec3();class tr{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 i=0;for(let s=0;s<this.lenIndices;s+=3){const r=3*t[s],n=3*t[s+1],A=3*t[s+2];Zs[0]=e[r],Zs[1]=e[r+1],Zs[2]=e[r+2],Js[0]=e[n],Js[1]=e[n+1],Js[2]=e[n+2],Ys[0]=e[A],Ys[1]=e[A+1],Ys[2]=e[A+2],V.subVec3(Zs,Js,$s),V.subVec3(Ys,Js,qs),i+=.5*V.lenVec3(V.cross3Vec3($s,qs,er))}return i}}const ir=new tr,sr=V.OBB3(),rr=V.OBB3(),nr=V.OBB3();class Ar{constructor(e,t,i,s,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=V.AABB3(),this._aabbWorldDirty=!1,this.layer=A,this.portionId=o,this._color=new Uint8Array([i[0],i[1],i[2],s]),this._colorize=new Uint8Array([i[0],i[1],i[2],s]),this._colorizing=!1,this._transparent=s<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 i=e<255,s=this._transparent!==i;this._color[3]=e,this._colorize[3]=e,this._transparent=i,this._colorizing?this.layer.setColor(this.portionId,this._colorize):this.layer.setColor(this.portionId,this._color),s&&this.layer.setTransparent(this.portionId,t,i)}_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,i,s){return this.layer.precisionRayPickSurface(this.portionId,e,t,i,s)}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":Ks.reset(),Ks.setPrimitive(this.layer.primitive),this.getEachVertex((e=>{Ks.addVertex(e)})),this.getEachIndex((e=>{Ks.addIndex(e)})),this._volume=Ks.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":ir.reset(),this.getEachVertex((e=>{ir.addVertex(e)})),this.getEachIndex((e=>{ir.addIndex(e)})),this._surfaceArea=ir.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&&(V.AABB3ToOBB3(this._aabbLocal,sr),this.transform?(V.transformOBB3(this.transform.worldMatrix,sr,rr),V.transformOBB3(this.model.worldMatrix,rr,nr),V.OBB3ToAABB3(nr,this._aabbWorld)):(V.transformOBB3(this.model.worldMatrix,sr,rr),V.OBB3ToAABB3(rr,this._aabbWorld)),this._aabbWorldDirty=!1),this._aabbWorld}_destroy(){this.model.scene._renderer.putPickID(this.pickId),this.layer=null}}const or=1,ar=4,lr=8,cr=16,hr=32,ur=256,dr=512,fr=1024,pr=2048,gr=function(e,t,i,s){const r=s&&e.createUniform("vec4","edgeColor",((e,t)=>e(t.legacyFrameCtx.programColor))),n=t.attributes.color,A=!s&&e.createVarying("vec4","vColor",(()=>`vec4(${n}.rgb * 0.5, ${n}.a)`)),o=e.createOutput("vec4","outColor");return{programName:s?"Edges":"EdgesColor",getLogDepth:i&&(e=>e),renderPassFlag:2,appendFragmentOutputs:e=>e.push(`${o} = ${r||A};`)}},mr=function(e,t){const i=e.createOutput("vec4","outColor");return{programName:"Occlusion",getLogDepth:!1,renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${i} = vec4(0.0, 0.0, 1.0, 1.0);`)}},_r=function(e,t,i,s){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:i&&(e=>e),renderPassFlag:1,appendFragmentOutputs:(e,t,i,o)=>{e.push(`${A} = ${s?r:o(`vec4(${r}.rgb, min(${r}.a, ${n}))`)};`)}}},br=V.vec2(),Br=V.vec3(),yr=V.vec4(),wr=V.mat4(),vr=V.vec3([0,0,0]),Cr=0,Mr=1,Er=2,Fr=3,Ur=4,xr=5,Ir=6,Tr=7,Pr=8,Sr=9,Dr=10,kr=11,Qr=e=>[V.safeInv(e[0]),V.safeInv(e[1]),V.safeInv(e[2])],Rr=(e,t,i,s,r)=>{const n=!!(e&or),A=!!(e&ur),o=!!(e&dr),a=!!(e&fr),l=!!(e&pr),c=!!(e&lr),h=!!(e&ar);let u,d;u=!n||h||A||o&&!s.highlightMaterial.glowThrough||a&&!s.selectedMaterial.glowThrough?Cr:t?Er:Mr,d=!n||h?Cr:a?Ur:o?Fr:A?xr:Cr;let f=0;f=i&&n&&!h?a?Sr:o?Pr:A?Dr:l?t?Tr:Ir:Cr:Cr;const p=n&&!h&&c?kr:Cr;r[0]=u,r[1]=d,r[2]=f,r[3]=p},Or=function(){const e={};return function(t,i,s,r,n,A,o,a){const l=[i,"points"===s||"lines"===s?s:"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=Gi(),o=A.programVariables,l=a(o,n);return r(o,l.geometryParameters,(function(r,a){const c=t.pointsMaterial,h="points"===s&&!n,u=()=>[t._sectionPlanesState.getHash()].concat(h?[c.hash]:[]).concat(r.getHash?r.getHash():[]).join(";"),d=u(),f=()=>d===u(),p=l.geometryParameters,g=r.incrementDrawState,m=r.isShadowProgram,_=p.attributes,b=_.position.world,B="clipPos",[y,w]=A.buildProgram(e,i+" "+s+" "+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 i=o.createUniform("float","nearPlaneHeight",((e,t)=>e(t.legacyFrameCtx.nearPlaneHeight))),s=`${Math.floor(c.minPerspectivePointSize)}.0`,r=`${Math.floor(c.maxPerspectivePointSize)}.0`;e.push(`clamp((${i} * ${t}) / gl_Position.w, ${s}, ${r})`)}else e.push(t)}else n&&n.vertices&&e.push("1.0");return r.incPointSizeBy10&&"points"===s&&e.push("10.0"),e.length>0&&(()=>e.join(" + "))}(),getVertexData:()=>{const e=_.color,t=_.flags[r.renderPassFlag],i=o.createUniform("int","renderPass",((e,t)=>e(t.renderPass))),n=[`if (${m?`(${t} <= 0) || (${e}.a < 1.0)`:`${t} != ${i}`}) {`,` 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"===s&&c.filterIntensity?function(){const t=o.createUniform("vec2","intensityRange",(e=>{br[0]=c.minIntensity,br[1]=c.maxIntensity,e(br)}));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=p.attributes.position.view;return A.push(`vec4 ${a} = ${p.viewMatrix} * ${b};`),A.push(`vec4 clipPos = ${p.projMatrix} * ${a};`),A},projMatrix:p.projMatrix,sectionPlanesState:t._sectionPlanesState,testPerspectiveForGl_FragDepth:"points"!==s&&"lines"!==s||n,usePickClipPos:a,worldPositionAttribute:b});return w?(console.error(w),{getValid:f,destroy:()=>{},drawLayer:(e,t,i)=>{}}):{getValid:f,destroy:()=>y.destroy(),drawLayer:(e,t,i)=>{e.lastProgramId!==y.id&&(e.lastProgramId=y.id,y.bind());const s=t.origin,r=t.model,A=e.viewParams,o=Br;V.transformPoint3(r.matrix,s,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:i,view:{eye:A.eye,far:A.far,projMatrix:c,viewMatrix:V.compareVec3(o,vr)?a:wt(a,o,wr),viewNormalMatrix:A.viewNormalMatrix}};y.inputSetters.setUniforms(e,h),t.drawCalls[n?n.vertices?"drawVertices":"drawEdges":"drawSurface"](y.inputSetters.attributesHash,l.layerTypeInputs,{projMatrix:c,viewMatrix:V.compareVec3(o,vr)?a:wt(a,o,wr),viewNormalMatrix:A.viewNormalMatrix,eye:A.eye}),g&&e.drawElements++}}}))};let l=A&&o();return{drawLayer:(e,t,i)=>{l||(l=o()),l.drawLayer(e,t,i)},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),f=(e,i,r,n)=>function(e,t,i,s,r,n){const A=e.createVarying("vec4","vColor",(()=>{const e=t.attributes,i="points"===n?`vec4(${e.color}.rgb, 1.0)`:`${e.color}`;return s?`vec4(${[s.getAmbientColor()].concat(s.directionalLights.map((i=>`max(dot(${e.normal.view}, ${i.getDirection(t.viewMatrix,e.position.view)}), 0.0) * ${i.getColor()}`))).join(" + ")}, 1) * ${i}`:i})),o=e.createOutput("vec4","outColor");return{programName:"Color",getHash:()=>[s?s.getHash():"-",r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:i&&(e=>"points"!==n&&"lines"!==n?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e),renderPassFlag:0,appendFragmentOutputs:(e,t,i,s)=>{"points"===n||"lines"===n?e.push(`${o} = ${A};`):(e.push(`vec4 fragColor = ${s(A)};`),e.push(`${o} = ${r?`vec4(fragColor.rgb * ${r.getAmbient(i)}, fragColor.a)`:"fragColor"};`))},filterIntensityRange:!0,incrementDrawState:!0}}(e,i,t.logarithmicDepthBufferEnabled,r,n,s),p=(e,i,s)=>s(function(e,t,i){const s=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:i&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,appendFragmentOutputs:e=>{e.push(`float zNormalizedDepth = abs((${r} + ${n}.z) / (${s} - ${r}));`),e.push(`${A} = ${o}(zNormalizedDepth);`)}}}(e,i,t.logarithmicDepthBufferEnabled),!0),g=(e,i,s)=>s(function(e,t,i){const s=e.createVarying("vec4","vPickColor",(()=>`${t.attributes.pickColor} / 255.0`)),r=e.createOutput("vec4","outPickColor");return{programName:"PickMesh",getLogDepth:i&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,dontCullOnAlphaZero:!0,appendFragmentOutputs:e=>e.push(`${r} = ${s};`)}}(e,i,t.logarithmicDepthBufferEnabled),!0),m=(e,i,s,r)=>s(function(e,t,i,s){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:s?"PickNormalsFlat":"PickNormals",getLogDepth:i&&(e=>e),renderPassFlag:3,appendFragmentOutputs:e=>{const t=s?`normalize(cross(dFdx(${r}), dFdy(${r})))`:n;e.push(`${A} = ivec4(${t} * float(${V.MAX_INT}), 1.0);`)}}}(e,i,t.logarithmicDepthBufferEnabled,r),!0),_=(e,t,i,s,r)=>i(function(e,t,i,s){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:i?"SnapInit":"Snap",getLogDepth:e=>i?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e,renderPassFlag:3,vertexCullX:!i&&"2.0",dontCullOnAlphaZero:!i,appendFragmentOutputs:e=>{e.push(`${a} = ivec4(${A} * ${n}.xyz, ${i?"-":""}${r});`),i&&(e.push(`${l} = ${s?"ivec4(1.0)":`ivec4(normalize(cross(dFdx(${A}), dFdy(${A}))) * float(${V.MAX_INT}), 1.0)`};`),e.push(`${c} = uvec4(${o});`))}}}(e,t,s,r),!0);c[h]="points"===s?{colorRenderers:{"sao-":{vertex:d(((e,t,i)=>i(f(e,t,null,null))))}},occlusionRenderer:d(((e,i,s)=>s(mr(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:d(p),pickMeshRenderer:d(g),silhouetteRenderer:d(((e,i,s)=>s(_r(e,i,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,i)=>_(e,t,i,!0,!0))),snapVertexRenderer:d(((e,t,i)=>_(e,t,i,!1,!0)),{vertices:!0})}:"lines"===s?{colorRenderers:{"sao-":{vertex:d(((e,t,i)=>i(f(e,t,null,null))))}},silhouetteRenderer:d(((e,i,s)=>s(_r(e,i,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,i)=>_(e,t,i,!0,!1))),snapEdgeRenderer:d(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!1}),snapVertexRenderer:d(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!0})}:{colorRenderers:function(){const e=e=>ji(e,t._lightsState),i=e=>{const t=e.createUniform("vec4","uSAOParams",((e,t)=>e(t.legacyFrameCtx.saoParams))),i=Wi(e,"sampler2D","uOcclusionTexture",3e3,((e,t)=>e(t.legacyFrameCtx.occlusionTexture)));return{getAmbient:e=>{const s=`${t}.w`;return`(smoothstep(${`${t}.z`}, 1.0, dot(${i(`${e}.xy / ${t}.xy`)}, (255. / 256.) / vec4(256. * 256. * 256., 256. * 256., 256., 1.))) * ${s})`}}},s=function(s){const r=(r,n,A)=>function(e,t,i,s,r,n,A){const o=Wi(e,"sampler2D","uColorMap",3001,((e,t)=>{const i=t.layerTextureSet.colorTexture;i&&e(i.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:()=>[s.getHash(),r?"sao":"nosao",!!A,n?"alphaCutoffYes":"alphaCutoffNo"],getLogDepth:i.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,i,n,A)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${c}), dFdy(${c})));`),e.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);"),s.directionalLights.forEach((i=>{e.push(`reflectedColor += max(dot(viewNormal, ${i.getDirection(t.viewMatrix,c)}), 0.0) * ${i.getColor()};`)})),e.push(`vec4 color = vec4(${s.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);`),i&&e.push(`${d} = ${i(d)};`)},incrementDrawState:!0}}(r,n,t,e(r),s&&i(r),A,t.gammaOutput);return{PBR:n&&d(((r,n,A)=>A(function(e,t,i,s,r){const n=(t,i,s)=>Wi(e,"sampler2D",t,i?3001:3e3,((e,t)=>{const i=s(t.layerTextureSet);i&&e(i.texture)})),A=t.attributes,o=s.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`)),f=e.createVarying("vec3","vViewNormal",(()=>A.normal.view)),p=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:()=>[s.getHash(),r?"sao":"nosao",!!i.gammaOutput],getLogDepth:i.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,clippingCaps:i._sectionPlanesState.clippingCaps&&b,incrementDrawState:!0,appendFragmentOutputs:(e,i,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 = ${p}.rgb;`),e.push(`float opacity = ${p}.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(${f}), ${g}, ${h(g)});`),e.push(`vec3 viewEyeDir = normalize(${d});`),o&&e.push(`reflDiff += ${o(`normalize(${_})`)};`),s.getReflection){const i=`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=s.getReflection(i,n),o=`${w}(viewNormal, viewEyeDir, specularColor, specularRoughness)`;e.push(`reflSpec += ${A} * ${o};`)}s.directionalLights.forEach(((i,s)=>{e.push(`vec3 lightDirection${s} = -${i.getDirection(t.viewMatrix,d)};`);const r=`${B}(dot(viewNormal, lightDirection${s}))`;e.push(`vec3 irradiance${s} = ${r} * ${i.getColor()};`),e.push(`reflDiff += irradiance${s};`),e.push(`reflSpec += irradiance${s} * PI * ${y}(lightDirection${s}, viewNormal, viewEyeDir, specularColor, specularRoughness);`)})),e.push(`vec3 emissiveColor = ${c(g)}.rgb;`),e.push(`float aoFactor = ${u(g)}.r;`);const A=`${s.getAmbientColor()} * baseColor * opacity * rgb`;e.push(`vec3 outgoingLight = emissiveColor + reflDiff * diffuseColor + reflSpec + ${A};`),e.push(`${b} = vec4(outgoingLight * aoFactor${r?` * ${r.getAmbient(n)}`:""}, opacity);`),i&&e.push(`${b} = ${i(b)};`)}}}(r,n,t,e(r),s&&i(r))))),texture:A&&{"alphaCutoff-":d(((e,t,i)=>i(r(e,t,!1)))),"alphaCutoff+":d(((e,t,i)=>i(r(e,t,!0))))},vertex:d(o?(t,r,n)=>n(f(t,r,e(t),s&&i(t))):(r,n,A)=>A(function(e,t,i,s,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:()=>[s.getHash(),r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:i&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,i,n,l)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${A}), dFdy(${A})));`);const c=[s.getAmbientColor()].concat(s.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),s&&i(r))))}};return{"sao-":s(!1),"sao+":r&&s(!0)}}(),depthRenderer:d(((e,i,s)=>s(function(e,t,i){const s=e.createVarying("highp vec2","vHighPrecisionZW",(()=>`${t.attributes.position.clip}.zw`)),r=e.createOutput("vec4","outColor");return{programName:"Depth",getLogDepth:i&&(e=>e),renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${r} = vec4(vec3((1.0 - ${s}[0] / ${s}[1]) / 2.0), 1.0);`)}}(e,i,t.logarithmicDepthBufferEnabled)))),edgesRenderers:{uniform:d(((e,i,s)=>s(gr(e,i,t.logarithmicDepthBufferEnabled,!0))),{vertices:!1}),vertex:d(((e,i,s)=>s(gr(e,i,t.logarithmicDepthBufferEnabled,!1))),{vertices:!1})},occlusionRenderer:d(((e,i,s)=>s(mr(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:u(p),pickMeshRenderer:u(g),pickNormalsFlatRenderer:u(((e,t,i)=>m(e,t,i,!0))),pickNormalsRenderer:u(((e,t,i)=>m(e,t,i,!1))),shadowRenderer:d(((e,i,s)=>s(function(e,t){const i=e.createOutput("vec4","outColor"),s=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(`${i} = ${s}(${r}.z);`)}}(e,t)))),silhouetteRenderer:u(((e,i,s)=>s(_r(e,i,t.logarithmicDepthBufferEnabled,!1)))),snapInitRenderer:u(((e,t,i)=>_(e,t,i,!0,!1))),snapEdgeRenderer:u(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!1}),snapVertexRenderer:u(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!0})};const b=e=>{!function t(i){i.revalidate?i.revalidate(e):Object.values(i).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 Vr{constructor(e,t,i){this.model=e,this.primitive=t,this.origin=i,this._meshes=[],this._aabb=V.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 i={count:0,fromFlags:(s,r)=>{s&e?(i.count++,this.model[t]++):r||(i.count--,this.model[t]--)}};this._countsByFlag[e]=i};e(or,"numVisibleLayerPortions"),e(ar,"numCulledLayerPortions"),e(lr,"numPickableLayerPortions"),e(cr,"numClippableLayerPortions"),e(ur,"numXRayedLayerPortions"),e(dr,"numHighlightedLayerPortions"),e(fr,"numSelectedLayerPortions"),this._renderers.edgesRenderers&&e(pr,"numEdgesLayerPortions"),this._countsByFlagArr=Object.values(this._countsByFlag),this._numTransparentLayerPortions=0}}aabbChanged(){this._aabbDirty=!0}getAABB(){return this._aabbDirty&&(V.collapseAABB3(this._aabb),this._meshes.forEach((e=>V.expandAABB3(this._aabb,e.aabb))),this._aabbDirty=!1),this._aabb}__drawLayer(e,t,i,s){if(this._countsByFlag[ar].count<this._portions.length&&this._countsByFlag[or].count>0){const e="points"!==this.primitive&&"lines"!==this.primitive&&[Mr,Er,kr,Fr,Ur,xr];if(e&&e.includes(s)){const e=!0;if(t.backfaces!==e){const i=this.model.scene.canvas.gl;i.disable(i.CULL_FACE),t.backfaces=e}}t.textureUnit=0,i.drawLayer(t,this,s)}}__setVec4FromMaterialColorAlpha(e,t,i){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=t,i}__drawColor(e,t,i){if((i?this._numTransparentLayerPortions<this._portions.length:this._numTransparentLayerPortions>0)&&this._countsByFlag[ur].count<this._portions.length){const s=i&&t.withSAO&&this._renderers.colorRenderers["sao+"]||this._renderers.colorRenderers["sao-"],r=t.pbrEnabled&&s.PBR?s.PBR:t.colorTextureEnabled&&s.texture?s.texture[this.layerTextureSet&&"number"==typeof this.layerTextureSet.alphaCutoff?"alphaCutoff+":"alphaCutoff-"]:s.vertex,n=i?Mr:Er;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 i=this._renderers.depthRenderer;i&&this._numTransparentLayerPortions<this._portions.length&&this._countsByFlag[ur].count<this._portions.length&&this.__drawLayer(e,t,i,Mr)}__drawSilhouette(e,t,i,s){t.programColor=this.__setVec4FromMaterialColorAlpha(i.fillColor,i.fillAlpha,yr),this.__drawLayer(e,t,this._renderers.silhouetteRenderer,s)}drawSilhouetteXRayed(e,t){this._countsByFlag[ur].count>0&&this.__drawSilhouette(e,t,this.model.scene.xrayMaterial,xr)}drawSilhouetteHighlighted(e,t){this._countsByFlag[dr].count>0&&this.__drawSilhouette(e,t,this.model.scene.highlightMaterial,Fr)}drawSilhouetteSelected(e,t){this._countsByFlag[fr].count>0&&this.__drawSilhouette(e,t,this.model.scene.selectedMaterial,Ur)}__drawVertexEdges(e,t,i){const s=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.vertex;s&&this._countsByFlag[pr].count>0&&this.__drawLayer(e,t,s,i)}drawEdgesColorOpaque(e,t){this._compiledPortions.edgesColorOpaqueAllowed()&&this.__drawVertexEdges(e,t,Ir)}drawEdgesColorTransparent(e,t){this._numTransparentLayerPortions>0&&this.__drawVertexEdges(e,t,Tr)}__drawUniformEdges(e,t,i,s){const r=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.uniform;r&&(t.programColor=this.__setVec4FromMaterialColorAlpha(i.edgeColor,i.edgeAlpha,yr),this.__drawLayer(e,t,r,s))}drawEdgesHighlighted(e,t){this._countsByFlag[dr].count>0&&this.__drawUniformEdges(e,t,this.model.scene.highlightMaterial,Pr)}drawEdgesSelected(e,t){this._countsByFlag[fr].count>0&&this.__drawUniformEdges(e,t,this.model.scene.selectedMaterial,Sr)}drawEdgesXRayed(e,t){this._countsByFlag[ur].count>0&&this.__drawUniformEdges(e,t,this.model.scene.xrayMaterial,Dr)}__drawPick(e,t,i){i&&this.__drawLayer(e,t,i,kr)}drawPickMesh(e,t){this.__drawPick(e,t,this._renderers.pickMeshRenderer)}drawPickDepths(e,t){this.__drawPick(e,t,this._renderers.pickDepthRenderer)}drawPickNormals(e,t){const i=this._renderers.pickNormalsFlatRenderer;this.__drawPick(e,t,i)}drawSnap(e,t,i){t.snapPickOrigin=[0,0,0];const s=this.getAABB();t.snapPickCoordinateScale=V.mulVec3Scalar(Qr([s[3]-s[0],s[4]-s[1],s[5]-s[2]]),V.MAX_INT);const r=i?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:Qr(t.snapPickCoordinateScale)})}drawOcclusion(e,t){const i=this._renderers.occlusionRenderer;i&&this.__drawLayer(e,t,i,Mr)}drawShadow(e,t){const i=this._renderers.shadowRenderer;i&&this.__drawLayer(e,t,i,Mr)}initFlags(e,t,i){this._countsByFlagArr.forEach((e=>e.fromFlags(t,!0))),i&&(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++);const s="points"!==this.primitive;this._setFlags(e,t,i,s),this._compiledPortions.setFlags2(e,t,s)}flushInitFlags(){this._compiledPortions.setDeferredFlags()}setVisible(e,t,i){this._countsByFlag[or].fromFlags(t),this._setFlags(e,t,i)}setCulled(e,t,i){this._countsByFlag[ar].fromFlags(t),this._setFlags(e,t,i)}setPickable(e,t,i){this._countsByFlag[lr].fromFlags(t),this._setFlags(e,t,i)}setClippable(e,t){this._countsByFlag[cr].fromFlags(t),this._compiledPortions.setClippableFlags(e,t)}setCollidable(e,t){}setXRayed(e,t,i){this._countsByFlag[ur].fromFlags(t),this._setFlags(e,t,i)}setHighlighted(e,t,i){this._countsByFlag[dr].fromFlags(t),this._setFlags(e,t,i)}setSelected(e,t,i){this._countsByFlag[fr].fromFlags(t),this._setFlags(e,t,i)}setEdges(e,t,i){this._countsByFlag[pr]&&(this._countsByFlag[pr].fromFlags(t),this._setFlags(e,t,i))}setTransparent(e,t,i){i?(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++):(this._numTransparentLayerPortions--,this.model.numTransparentLayerPortions--),this._setFlags(e,t,i)}destroy(){this._compiledPortions&&this._compiledPortions.destroy()}}let Lr=65536,Hr=5e6;class Nr{constructor(){}set doublePrecisionEnabled(e){V.setDoublePrecisionEnabled(e)}get doublePrecisionEnabled(){return V.getDoublePrecisionEnabled()}set maxDataTextureHeight(e){(e=1024*Math.ceil(e/1024))>4096?e=4096:e<1024&&(e=1024),Lr=e}get maxDataTextureHeight(){return Lr}set maxGeometryBatchSize(e){e<1e5?e=1e5:e>5e6&&(e=5e6),Hr=e}get maxGeometryBatchSize(){return Hr}}const Gr=e=>{const t=[];for(let i=0;i<e;++i)t.push(i);return t},jr={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(jr,null,4));let e=0;Object.keys(jr).forEach((t=>{t.startsWith("size")&&(e+=jr[t])})),console.log(`Total size ${e} bytes (${(e/1e3/1e3).toFixed(2)} MB)`),console.log(`Avg bytes / triangle: ${(e/jr.totalPolygons).toFixed(2)}`);let t={};Object.keys(jr).forEach((i=>{i.startsWith("size")&&(t[i]=`${(jr[i]/e*100).toFixed(2)} % of total`)})),console.log(JSON.stringify({percentualRamUsage:t},null,4))};const Wr=new Nr,zr=Wr.maxDataTextureHeight,Xr=V.vec3(),Kr=V.vec3(),Zr=V.vec4();V.vec4();const Jr=new Float32Array(16),Yr=new Uint8Array(4),$r=V.identityMat4();class qr extends Vr{constructor(e,t,i){super(e,t,i),jr.numberOfLayers++,this._sortId=`TriDTX-${jr.numberOfLayers}`;const s=e.scene.canvas.gl,r=(e,t)=>{const i=[];let r=0;const A=[];let o=0;const a=[];let l=0;const c=[];let h=0;return{len:()=>o,accumulateIndices:(s,u)=>{const d=s&&s.length>0&&function(){const t=r/3;r+=s.length,i.push(s);const a=s.length/3;return i=>{const s=o;o+=3*a,n.perObjectIndexBaseOffsets.push(s/3-t);for(let e=0;e<a;e+=8)A.push(i);jr[e]+=a,jr.totalPolygons+=a}}(),f=u&&function(){const e=l/2;l+=u.length,a.push(u);const i=u.length/2;return s=>{const r=h;h+=2*i,n.perObjectEdgeIndexBaseOffsets.push(r/2-e);for(let e=0;e<i;e+=8)c.push(s);jr[t]+=i,jr.totalEdges+=i}}();return jr.numberOfGeometries++,{numTriangles:s?s.length/3:0,accumulateSubPortionId:e=>{d&&d(e),f&&f(e)}}},createDrawers:(e,t)=>{const n=function(t,i){return t.length>0?e([t],t.length,1,s.UNSIGNED_SHORT,"sizeDataTexturePortionIds"):i},u=n(A,{texture:null}),d=r>0&&e(i,r,3,t,"sizeDataTextureIndices"),f=n(c),p=l>0&&e(a,l,2,t,"sizeDataTextureEdgeIndices");return{indices:function(e,t){o>0&&(e.perPrimIndices.setInputValue(d),e.perPrimIdPorIds.setInputValue(u),s.drawArrays(t,0,o))},edges:function(e,t){h>0&&(e.perPrimIndices.setInputValue(p),e.perPrimIdPorIds.setInputValue(f),s.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&&jr.cannotCreatePortion.because10BitsObjectId++;let i=this._portions.length+t<=65536;const s=void 0!==e.geometryId&&null!==e.geometryId?`${e.geometryId}#0`:`${e.id}#0`;if(!this._bucketGeometries[s]){const t=this._buffer,s=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*zr||s+n>4096*zr)&&jr.cannotCreatePortion.becauseTextureSize++,i&&=this._numVertices+r<=4096*zr&&s+n<=4096*zr}return i}createPortion(e,t){const i=this._buffer,s=t.buckets.map(((e,s)=>{const r=(t.geometryId??t.id)+"#"+s;if(!(r in this._bucketGeometries)){const t=(e,t,i)=>{if(e){const s=8*Math.ceil(e.length/t/8)*t,r=new Uint32Array(s);return r.set(e),jr[i]+=2*(r.length-e.length),r}return e};e.indices=t(e.indices,3,"overheadSizeAlignementIndices"),e.edgeIndices=t(e.edgeIndices,2,"overheadSizeAlignementEdgeIndices");const s=e.positionsCompressed;i.positionsCompressed.push(s);const n=s.length/3;this._numVertices+=n;const A=i.lenPositionsCompressed/3;i.lenPositionsCompressed+=s.length,this._bucketGeometries[r]={vertexBase:A,geometryData:function(){const t=e.indices,s=e.edgeIndices;return n<=256?i.geometry8Bits.accumulateIndices(t,s):n<=65536?i.geometry16Bits.accumulateIndices(t,s):i.geometry32Bits.accumulateIndices(t,s)}()}}const n=this._bucketGeometries[r];i.perObjectPositionsDecodeMatrices.push(t.positionsDecodeMatrix),i.perObjectInstancePositioningMatrices.push(t.meshMatrix||$r),i.perObjectSolid.push(!!t.solid),i.perObjectPickColors.push(t.pickColor),i.perObjectVertexBases.push(n.vertexBase);const A=t.colors,o=t.color;i.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}),jr.numberOfPortions++,a})),r=this._portionToSubPortionsMap.length;return this._portionToSubPortionsMap.push(s),this.model.numPortions++,this._meshes.push(e),r}compilePortions(){const e=this._buffer,t=this.model,i=this._portions.length,s=this.origin,r=this._portionToSubPortionsMap,n=this._primitive,A=this._sortId,o=this._subPortionReadableGeometries,a=t.scene,l=a.canvas.gl,c=en(l,i,32,l.UNSIGNED_BYTE,512,(t=>{const s=e=>[e>>24&255,e>>16&255,e>>8&255,255&e];for(let r=0;r<i;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(s(e.perObjectVertexBases[r]),32*r+16),t.set(s(e.perObjectIndexBaseOffsets[r]),32*r+20),t.set(s(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,i,s,r,n,A){return en(l,t,i,s,r,(t=>{for(let i=0,s=0,r=e.length;i<r;i++){const r=e[i];t.set(r,s),s+=r.length}}),n,A)},d=function(e,t,i){const s=e.length;if(0===s)throw"num "+t+" matrices===0";return u(e,s,16,l.FLOAT,512,t,i)},f=d(e.perObjectInstancePositioningMatrices,"sizeDataInstancesMatrices",!0),p=f.textureData,g=d(e.perObjectPositionsDecodeMatrices,"sizeDataPositionDecodeMatrices",!1),m=function(e,t,i,s,r){return u(e,t/i,i,s,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})),U=(e,i)=>{const s=r[e];if(s)for(let e=0,t=s.length;e<t;e++)i(s[e]);else t.error("portion not found: "+e)},x=(e,t,i,s)=>{const r=w||s;r?v=!0:++M>=10&&E(),h.setData(i,e,t,!r)},I=(e,t,i=!1)=>{Yr.set([t&cr?255:0,0,1,2]),U(e,(e=>x(e,3,Yr,i)))};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,i,s=!1)=>{Rr(t,i,!0,a,Yr),U(e,(e=>x(e,2,Yr,s)))},setFlags2:I,setDeferredFlags:()=>{},setColor:(e,t)=>{Yr.set(t),U(e,(e=>x(e,0,Yr,!1)))},setMatrix:(e,t)=>{U(e,(e=>{const i=w;i?v=!0:++M>=10&&E(),Jr.set(t),p.setData(Jr,e,0,!i)}))},setOffset:(e,t)=>{},getEachIndex:(e,t)=>{o&&U(e,(e=>o[e].indices.forEach((e=>t(e)))))},getEachVertex:(e,i)=>{o&&U(e,(e=>{const r=o[e],n=r.positionsCompressed,A=r.positionsDecodeMatrix,a=Zr;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,V.decompressPosition(a,A),V.mulMat4v4(t.worldMatrix,a,a),V.addVec3(s,a,a),i(a)}))},precisionRayPickSurface:(e,t,i,s,r)=>!1,renderers:Or(a,"dtx",n,t.saoEnabled,!1,!1,!0,((e,t)=>tn(e,!t))),drawCalls:function(){const e=function(e){const i=(e,t)=>e.setInputValue&&e.setInputValue(t);return(r,n,A)=>{i(n.worldMatrix,t.rotationMatrix),i(n.viewMatrix,A.viewMatrix),i(n.projMatrix,A.projMatrix);const o=V.transformPoint3(t.matrix,s,Xr);i(n.uCameraEyeRtc,V.subVec3(A.eye,o,Kr)),i(n.perObjPosDecode,g),i(n.perVertIdCoords,_),i(n.perObjColsFlags,c),i(n.perObjectMatrix,f),e(n)}},i=function(t){return e((e=>{b.edges(e,t),B.edges(e,t),y.edges(e,t)}))};return{drawVertices:i(l.POINTS),drawEdges:i(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 en=function(e,t,i,s,r,n,A,o){if(i>4&&i%4>0)throw"Unhandled data size "+i;const a=Math.ceil(i/4),l=i/a,[c,h,u]=function(){switch(s){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 "+s}}(),d=r*a,f=Math.ceil(t/r);if(0===f)throw"texture height===0";const p=new c(d*f*l);jr[A]+=p.byteLength,jr.numberOfTextures++,n(p);const g=e.createTexture();return e.bindTexture(e.TEXTURE_2D,g),e.texStorage2D(e.TEXTURE_2D,1,h,d,f),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,f,u,s,p),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(p.set(t,n*i+A*l),o){e.bindTexture(e.TEXTURE_2D,g);const i=n%r*a+A,o=Math.floor(n/r),c=t.length/l;e.texSubImage2D(e.TEXTURE_2D,0,i,o,c,1,u,s,t)}},reloadData(){e.bindTexture(e.TEXTURE_2D,g),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,f,u,s,p)}}}},tn=function(e,t){const i=(t,i)=>{const s=e.createUniform(t,i),r=e=>`texelFetch(${s}, ${e}, 0)`;return r.map=s,r},s=i("highp usampler2D","perPrimIndices"),r=i("mediump usampler2D","perPrimIdPorIds"),n=i("highp sampler2D","perObjPosDecode"),A=i("mediump usampler2D","perVertIdCoords"),o=i("lowp usampler2D","perObjColsFlags"),a=i("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},f=d("colorA"),p=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:f,flags:Gr(4).map((e=>`int(flags[${e}])`)),metallicRoughness:null,normal:{view:m,world:g},pickColor:p,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)};`),f.needed&&e.push(`vec4 ${f} = vec4(${_(0)}) / 255.0;`)},appendVertexData:e=>{const i=e=>a(`ivec2(objectIndexCoords.x*4+${e}, objectIndexCoords.y)`);e.push(`mat4 objectInstanceMatrix = mat4(${i(0)}, ${i(1)}, ${i(2)}, ${i(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(${s("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;p.needed&&e.push(`vec4 pickColor = vec4(${_(1)});`),e.push(`vec4 worldPosition = ${l} * (objectDecodeAndInstanceMatrix * vec4(position, 1.0));`)},layerTypeInputs:{perPrimIndices:s.map,perPrimIdPorIds:r.map,perObjPosDecode:n.map,perVertIdCoords:A.map,perObjColsFlags:o.map,perObjectMatrix:a.map,worldMatrix:l,viewMatrix:c,projMatrix:h,uCameraEyeRtc:u}}},sn=V.mat4(),rn=V.mat4();function nn(e,t,i){const s=e.length,r=new Uint16Array(s),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,f=h/c,p=e=>e>=0?e:0;for(let t=0;t<s;t+=3)r[t+0]=Math.floor(p(e[t+0]-n)*u),r[t+1]=Math.floor(p(e[t+1]-A)*d),r[t+2]=Math.floor(p(e[t+2]-o)*f);return V.identityMat4(sn),V.translationMat4v(t,sn),V.identityMat4(rn),V.scalingMat4v([a/h,l/h,c/h],rn),V.mulMat4(sn,rn,i),r}function An(e,t){const i=e[0],s=e[1],r=e[2],n=e[3]-i||1,A=e[4]-s||1,o=e[5]-r||1,a=65525;return V.identityMat4(sn),V.translationMat4v(e,sn),V.identityMat4(rn),V.scalingMat4v([n/a,A/a,o/a],rn),V.mulMat4(sn,rn,t),t}function on(e,t,i){let s=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=s,t=r;e=(1-Math.abs(r))*(s>=0?1:-1),t=(1-Math.abs(s))*(r>=0?1:-1),s=e,r=t}return new Int8Array([Math[t](127.5*s+(s<0?-1:0)),Math[i](127.5*r+(r<0?-1:0))])}function an(e){let t=e[0],i=e[1];t/=t<0?127:128,i/=i<0?127:128;const s=1-Math.abs(t)-Math.abs(i);s<0&&(t=(1-Math.abs(i))*(t>=0?1:-1),i=(1-Math.abs(t))*(i>=0?1:-1));const r=Math.sqrt(t*t+i*i+s*s);return[t/r,i/r,s/r]}const ln=new Float32Array(1),cn=new Float32Array(4),hn=new Float32Array(3),un=V.mat4(),dn=V.vec4([0,0,0,1]),fn=V.vec4(),pn=V.vec3(),gn=V.vec3(),mn=V.vec3(),_n=V.vec3(),bn=V.vec3(),Bn=V.vec3(),yn=V.vec3(),wn=new Uint8Array(4),vn=new Float32Array(96),Cn=function(e){const t=[];for(let i=0;i<e;++i)t.push(i);return t},Mn=function(e,t){e.set(t);let i=t.length;const s=e.length;for(;i<s;){const t=Math.min(i,s-i);e.set(e.subarray(0,t),i),i+=t}},En=function(){let e=0;const t=new Map;return{acquire:()=>e++,release:()=>{e--,0===e&&t.clear()},getTypeArray:function(e,i){t.has(e)||t.set(e,{});const s=t.get(e);return i in s||(s[i]=new e(i)),s[i]}}}();class Fn extends Vr{constructor(e,t,i,s){super(e,t,i);const r=!!s.geometry;this._maxVerts=s.maxGeometryBatchSize;const n=r?s.geometry.positionsDecodeMatrix:s.positionsDecodeMatrix;this._positionsDecodeMatrix=n&&V.mat4(n),this._cfgUvDecodeMatrix=s.uvDecodeMatrix&&V.mat3(s.uvDecodeMatrix),this._instancedGeometry=s.geometry,this._textureSet=s.textureSet,this._modelAABB=!r&&V.collapseAABB3(),this._portions=[];const A=function(){let e=0;const t=[];return{length:()=>e,append:function(i,s=1,r=1,n=0){e+=s*i.length,t.push({data:i,times:s,denormalizeScale:r,increment:n})},compileBuffer:function(e){let i=0;t.forEach((e=>{i+=e.times*e.data.length}));const s=new e(i);let r=0;return t.forEach((e=>{const t=e.data,i=e.denormalizeScale,n=e.increment,A=s.subarray(r);if(1===i&&0===n)A.set(t);else for(let e=0;e<t.length;++e)A[e]=n+t[e]*i;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})),s}}};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 i=this._buffer,s=this._instancedGeometry,r=this.model,n=this._portions.length,A=this.primitive,o=!!this._positionsDecodeMatrix,a=r.scene,l=t.meshMatrix,c=(s,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:s,portionSize:o,retainedGeometry:a.readableGeometryEnabled&&"points"!==A&&"lines"!==A&&{indices:l,quantizedPositions:c,offset:a.entityOffsetsEnabled&&V.vec3(),matrix:h&&h.slice(),inverseMatrix:null,normalMatrix:null}};return"points"!==A&&"lines"!==A&&i.metallicRoughness.append([t.metallic??0,t.roughness??255],o),"lines"!==A&&i.pickColors.append(t.pickColor.slice(0,4),o),this._portions.push(d),r.numPortions++,this._meshes.push(e),n};if(s){if(i.modelMatrixCol.forEach(((e,t)=>e.append([l[t+0],l[t+4],l[t+8],l[t+12]]))),"points"!==A){const e=t.color;i.colors.append([e[0],e[1],e[2],t.opacity??255])}if("points"!==A&&"lines"!==A&&s.normals){const e=V.inverseMat4(V.transposeMat4(l,V.mat4()));i.modelNormalMatrixCol.forEach(((t,i)=>t.append([e[i+0],e[i+4],e[i+8],e[i+12]])))}return c(n,1,s.indices,s.positionsCompressed,l)}{const e=i.positions.length()/3,s=o?t.positionsCompressed:t.positions;if(!s)throw(o?"positionsCompressed":"positions")+" expected";i.positions.append(s);const r=s.length/3,n=t.indices;n&&i.indices.append(n,1,1,e);const a=t.normalsCompressed,h=t.normals;if(a&&a.length>0)i.normals.append(a);else if(h&&h.length>0){const e=un;l?(V.transposeMat4(l,e),V.inverseMat4(e,e)):V.identityMat4(e);const t=[];!function(e,t,i,s,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<i;h+=3)u[0]=t[h],u[1]=t[h+1],u[2]=t[h+2],V.transformVec3(e,u,d),V.normalizeVec3(d,d),a=A=on(d,"floor","floor"),o=an(A),l=c=n(d,o),A=on(d,"ceil","floor"),o=an(A),l=n(d,o),l>c&&(a=A,c=l),A=on(d,"floor","ceil"),o=an(A),l=n(d,o),l>c&&(a=A,c=l),A=on(d,"ceil","ceil"),o=an(A),l=n(d,o),l>c&&(a=A,c=l),s[r+h+0]=a[0],s[r+h+1]=a[1],s[r+h+2]=0}(e,h,h.length,t,0),i.normals.append(t)}const u=t.colors,d=t.colorsCompressed,f=t.color;if(u)if("points"===A)i.colors.append(u,1,255);else{const e=[];for(let t=0,i=u.length;t<i;t+=3)e.push(255*u[t]),e.push(255*u[t+1]),e.push(255*u[t+2]),e.push(255);i.colors.append(e)}else if(d)if("points"===A)i.colors.append(d);else{const e=[];for(let t=0,i=d.length;t<i;t+=3)e.push(d[t]),e.push(d[t+1]),e.push(d[t+2]),e.push(255);i.colors.append(e)}else f&&i.colors.append([f[0],f[1],f[2],"points"===A?1:t.opacity],r);const p=e=>e&&e.length>0&&e,g=p(t.uv)||p(t.uvCompressed);g&&i.uv.append(g);const m=t.edgeIndices;return m&&i.edgeIndices.append(m,1,1,e),V.expandAABB3(this._modelAABB,t.aabb),c(e,r,n)}}compilePortions(){const e=this._buffer,t=this._instancedGeometry,i=this.model,s=this._modelAABB,r=this.origin,n=this._portions,A=this.primitive,o=this._textureSet;let a=this._positionsDecodeMatrix;const l=this._cfgUvDecodeMatrix,c=i.scene,h=c.canvas.gl,u=!!t,d=[],f=(e,t,i,s)=>{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,s)};l(t);const c=t.BYTES_PER_ELEMENT,u=t.length/i;return{bindBuffer:a,getData:(t=0,s=u-t)=>{a();const A=new r(s*i);return h.getBufferSubData(e,t*n*i,A,0,s*i),A},numItems:u,setData:l,setSubData:(t,i)=>{a(),h.bufferSubData(e,i*c,t)},type:A}}return null},p=(e,t,i,s=!1,r=!1)=>{const n=f(h.ARRAY_BUFFER,e,t,i);return n&&{getData:n.getData,numItems:n.numItems,setData:n.setData,setSubData:n.setSubData,attributeDivisor:s&&1,bindAtLocation:e=>{n.bindBuffer(),h.vertexAttribPointer(e,t,n.type,!!r,0,0)}}},g=e=>{const t=f(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),_=p(new Float32Array(m),1,h.DYNAMIC_DRAW,u),b=(e,t)=>p(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&&p(new Float32Array(3*m),3,h.DYNAMIC_DRAW,u),w=p(e.metallicRoughness.compileBuffer(Uint8Array),2,h.STATIC_DRAW,u),v=p(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):nn(e.positions.compileBuffer(Float64Array),s,a=V.mat4()),U=F&&p(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 x=u&&e.modelMatrixCol.map((e=>p(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),I=!u&&e.normals.compileBuffer(Int8Array),T=I&&p(I,3,h.STATIC_DRAW,!1,!0),P=x&&T&&e.modelNormalMatrixCol.map((e=>p(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),S=u?"points"!==A&&"lines"!==A&&t.uvCompressed&&{buf:p(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:p(t,2,h.STATIC_DRAW),mat:l};{const e=Ne.getUVBounds(t),i=Ne.compressUVs(t,e.min,e.max);return{buf:p(i.quantized,2,h.STATIC_DRAW),mat:V.mat3(i.decodeMatrix)}}}();this._buffer=null,En.acquire(),d.push((()=>En.release()));let D=null;const k=(e,i,s,r=!1)=>{Rr(i,s,"points"!==A&&"lines"!==A,c,wn);const o=i&cr?1:0;let a=0;a|=wn[0],a|=wn[1]<<4,a|=wn[2]<<8,a|=wn[3]<<12,a|=o<<16,ln[0]=a;const l=n[e],h=l.portionBase,u=l.portionSize;if(r&&!t)D||(D=new Float32Array(m)),Mn(D.subarray(h,h+u),ln);else if(_){const e=En.getTypeArray(Float32Array,u);Mn(e,ln),_.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,i)=>{},setDeferredFlags:()=>{D&&(_.setData(D),D=null)},setColor:(e,t)=>{if(B){const i=n[e],s=En.getTypeArray(Uint8Array,4*i.portionSize);Mn(s,t.slice(0,4)),B.setSubData(s,4*i.portionBase)}},setMatrix:(e,t)=>{x&&x.forEach(((i,s)=>{cn[0]=t[s+0],cn[1]=t[s+4],cn[2]=t[s+8],cn[3]=t[s+12],i.setSubData(cn,4*e)}))},setOffset:(e,t)=>{if(c.entityOffsetsEnabled){const i=n[e];if(y){hn.set(t);const e=En.getTypeArray(Float32Array,3*i.portionSize);Mn(e,hn),y.setSubData(e,3*i.portionBase)}i.retainedGeometry&&i.retainedGeometry.offset.set(t)}else i.error("Entity#offset not enabled for this Viewer")},getEachIndex:(e,t)=>{const i=n[e].retainedGeometry;i&&i.indices.forEach((e=>t(e)))},getEachVertex:(e,t)=>{const s=n[e].retainedGeometry;if(s){const e=fn;r?e.set(r,0):e[0]=e[1]=e[2]=0,e[3]=1;const n=i.matrix;V.mulMat4v4(n,e,e);const A=s.quantizedPositions,o=dn;for(let i=0,r=A.length;i<r;i+=3)o[0]=A[i],o[1]=A[i+1],o[2]=A[i+2],V.decompressPosition(o,a),s.matrix&&V.transformPoint3(s.matrix,o,o),o[3]=1,V.mulMat4v4(n,o,o),V.addVec3(e,o,o),t(o)}},readGeometryData:"points"!==A&&"lines"!==A&&(e=>{const t=!u&&n[e],s=t?E.getData(t.indicesBaseIndex,t.numIndices).map((e=>e-t.portionBase)):E.getData(),A=i.matrix,o=V.vec4();o.set(r,0),o[3]=1,V.mulMat4v4(A,o,o);const l=x&&V.mat4();if(l){const t=x[0].getData(e,1),i=x[1].getData(e,1),s=x[2].getData(e,1);l.set([t[0],i[0],s[0],0,t[1],i[1],s[1],0,t[2],i[2],s[2],0,t[3],i[3],s[3],1])}const c=V.mat4();V.mulMat4(A,l?V.mulMat4(l,a,c):a,c),c[12]+=o[0],c[13]+=o[1],c[14]+=o[2];const h=t?U.getData(t.portionBase,t.portionSize):U.getData();return{indices:s,positions:V.transformPositions3(c,h,new Float64Array(h.length))}}),precisionRayPickSurface:(e,t,s,A,o)=>{const l=n[e].retainedGeometry;if(l){l.matrix&&!l.inverseMatrix&&(l.inverseMatrix=V.inverseMat4(l.matrix,V.mat4())),o&&l.inverseMatrix&&!l.normalMatrix&&(l.normalMatrix=V.transposeMat4(l.inverseMatrix,V.mat4()));const e=l.quantizedPositions,n=l.indices,c=l.offset,h=pn,u=gn;h.set(r?V.subVec3(t,r,mn):t),u.set(s),c&&V.subVec3(h,c),V.transformRay(i.worldNormalMatrix,h,u,h,u),l.inverseMatrix&&V.transformRay(l.inverseMatrix,h,u,h,u);const d=_n,f=bn,p=Bn;let g=!1,m=0;const _=yn;for(let s=0,b=n.length;s<b;s+=3){const b=3*n[s],B=3*n[s+1],y=3*n[s+2];if(d[0]=e[b],d[1]=e[b+1],d[2]=e[b+2],f[0]=e[B],f[1]=e[B+1],f[2]=e[B+2],p[0]=e[y],p[1]=e[y+1],p[2]=e[y+2],V.decompressPosition(d,a),V.decompressPosition(f,a),V.decompressPosition(p,a),V.rayTriangleIntersect(h,u,d,f,p,_)){l.matrix&&V.transformPoint3(l.matrix,_,_),V.transformPoint3(i.worldMatrix,_,_),c&&V.addVec3(_,c),r&&V.addVec3(_,r);const e=Math.abs(V.lenVec3(V.subVec3(_,t,[])));(!g||e>m)&&(m=e,A.set(_),o&&V.triangleNormal(d,f,p,o),g=!0)}}return g&&o&&(l.normalMatrix&&V.transformVec3(l.normalMatrix,o,o),V.transformVec3(i.worldNormalMatrix,o,o),V.normalizeVec3(o)),g}return!1},layerTextureSet:o,renderers:Or(c,u?"instancing":"batching",A,i.saoEnabled,i.pbrEnabled&&S&&o&&o.colorTexture&&T&&w&&o.metallicRoughnessTexture,i.colorTextureEnabled&&S&&o&&o.colorTexture,!!T,(e=>xn(e,u&&{hasModelNormalMat:!!P},c.entityOffsetsEnabled))),drawCalls:function(){const e={},t=t=>(s,r,o)=>{let l=0;vn.set(i.rotationMatrix,0),vn.set(o.viewMatrix,l+=16),vn.set(o.projMatrix,l+=16),vn.set(a,l+=16),r.needNormal()&&(vn.set(i.worldNormalMatrix,l+=16),vn.set(o.viewNormalMatrix,l+=16)),r.matrices.setInputValue(vn),r.uvDecodeMatrix.setInputValue&&r.uvDecodeMatrix.setInputValue(S.mat),s in e||(e[s]=[null,null,null]);const c=e[s],f=t?t.vertices?0:1:2;if(!c[f]){const e=h.createVertexArray();h.bindVertexArray(e);const i=(e,t)=>{e&&e.setInputValue&&t&&e.setInputValue(t)},s=r.attributes;i(s.position,U),i(s.normal,T),i(s.color,B),i(s.pickColor,v),i(s.uV,S&&S.buf),i(s.metallicRoughness,w),i(s.flags,_),i(s.offset,y),s.modelMatrixCol&&s.modelMatrixCol.forEach(((e,t)=>i(e,x[t]))),s.modelNormalMatrixCol&&s.modelNormalMatrixCol.forEach(((e,t)=>i(e,P[t])));const o=function(){const e=()=>{u?h.drawArraysInstanced(h.POINTS,0,U.numItems,n.length):h.drawArrays(h.POINTS,0,U.numItems)},i=(e,t)=>{t.bindIndicesBuffer();const i=t.indicesCount,s=t.indicesType;return()=>{u?h.drawElementsInstanced(e,i,s,0,n.length):h.drawElements(e,i,s,0)}};return"points"===A?e:"lines"===A?t&&t.vertices?e:i(h.LINES,E):t&&t.vertices?e:t?C?i(h.LINES,C):()=>{}:i(h.TRIANGLES,E)}();h.bindVertexArray(null),d.push((()=>h.deleteVertexArray(e))),c[f]=()=>{h.bindVertexArray(e),o(),h.bindVertexArray(null)}}c[f]()};return{drawVertices:t({vertices:!0}),drawEdges:t({}),drawSurface:t(null)}}(),destroy:()=>{d.forEach((e=>e())),d.length=0}}}}const Un=function(e){const t={toString:()=>(t.needed=!0,e)};return t},xn=function(e,t,i){const s=e.createAttribute,r={position:s("vec3","positionA"),normal:s("vec3","normalA"),color:s("vec4","colorA"),pickColor:s("vec4","pickColor"),uV:s("vec2","uvApremul"),metallicRoughness:s("vec2","metallicRoughness"),flags:s("float","flagsA"),offset:i&&s("vec3","offset"),modelMatrixCol:t&&Cn(3).map((e=>s("vec4","modelMatrixCol"+e))),modelNormalMatrixCol:t&&t.hasModelNormalMat&&Cn(3).map((e=>s("vec4","modelNormalMatrixCol"+e)))},n=Un("aUv"),A=Un("viewNormal"),o=Un("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:Cn(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 i=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)${i?" * "+i:""});`),r.offset&&t.push(`worldPosition.xyz = worldPosition.xyz + ${r.offset};`),l()){const i=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)${i||""};`),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 In{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 Tn{constructor(e){this.id=e.id,this.texture=e.texture}destroy(){this.texture&&(this.texture.destroy(),this.texture=null)}}const Pn={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 Sn{constructor(e,t,i){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=i}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,i=this.handlers.length;t<i;t+=2){const i=this.handlers[t],s=this.handlers[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return s}return null}}const Dn=new Sn;class kn{constructor(e){this.manager=void 0!==e?e:Dn,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise((function(s,r){i.load(e,s,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 Qn={};class Rn extends kn{constructor(e){super(e)}load(e,t,i,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Pn.get(e);if(void 0!==r)return this.manager.itemStart(e),ie.scheduleTask((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Qn[e])return void Qn[e].push({onLoad:t,onProgress:i,onError:s});Qn[e]=[],Qn[e].push({onLoad:t,onProgress:i,onError:s});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 i=Qn[e],s=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(){s.read().then((({done:s,value:r})=>{if(s)e.close();else{o+=r.byteLength;const s=new ProgressEvent("progress",{lengthComputable:A,loaded:o,total:n});for(let e=0,t=i.length;e<t;e++){const t=i[e];t.onProgress&&t.onProgress(s)}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),i=t&&t[1]?t[1].toLowerCase():void 0,s=new TextDecoder(i);return e.arrayBuffer().then((e=>s.decode(e)))}}})).then((t=>{Pn.add(e,t);const i=Qn[e];delete Qn[e];for(let e=0,s=i.length;e<s;e++){const s=i[e];s.onLoad&&s.onLoad(t)}})).catch((t=>{const i=Qn[e];if(void 0===i)throw this.manager.itemError(e),t;delete Qn[e];for(let e=0,s=i.length;e<s;e++){const s=i[e];s.onError&&s.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 On{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 i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:t,msg:i,transfer:s}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(i,s)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((i=>{const s=this._getIdleWorker();-1!==s?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=i,this.workers[s].postMessage(e,t)):this.queue.push({resolve:i,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 Vn=0;class Ln{constructor({viewer:e,transcoderPath:t,workerLimit:i}){this._transcoderPath=t||"https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/basis/",this._transcoderBinary=null,this._transcoderPending=null,this._workerPool=new On,this._workerSourceURL="",i&&this._workerPool.setWorkerLimit(i);const s=e.capabilities;this._workerConfig={astcSupported:s.astcSupported,etc1Supported:s.etc1Supported,etc2Supported:s.etc2Supported,dxtSupported:s.dxtSupported,bptcSupported:s.bptcSupported,pvrtcSupported:s.pvrtcSupported},this._supportedFileTypes=["xkt2"]}_init(){if(!this._transcoderPending){const e=new Rn;e.setPath(this._transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new Rn;i.setPath(this._transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const s=i.loadAsync("basis_transcoder.wasm");this._transcoderPending=Promise.all([t,s]).then((([e,t])=>{const i=Ln.BasisWorker.toString(),s=["/* constants */","let _EngineFormat = "+JSON.stringify(Ln.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(Ln.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Ln.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this._workerSourceURL=URL.createObjectURL(new Blob([s])),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}))})),Vn>0&&console.warn("KTX2TextureTranscoder: Multiple active KTX2TextureTranscoder may cause performance issues. Use a single KTX2TextureTranscoder instance, or call .dispose() on old instances."),Vn++}return this._transcoderPending}transcode(e,t,i={}){return new Promise(((s,r)=>{const n=i;this._init().then((()=>this._workerPool.postMessage({type:"transcode",buffers:e,taskConfig:n},e))).then((e=>{const i=e.data,{mipmaps:n,width:A,height:o,format:a,type:l,error:c,dfdTransferFn:h,dfdFlags:u}=i;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)}}),s()}))}))}destroy(){URL.revokeObjectURL(this._workerSourceURL),this._workerPool.destroy(),Vn--}}Ln.BasisFormat={ETC1S:0,UASTC_4x4:1},Ln.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},Ln.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},Ln.BasisWorker=function(){let e,t,i;const s=_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=>{i={wasmBinary:h,onRuntimeInitialized:e},BASIS(i)})).then((()=>{i.initializeBasis(),void 0===i.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:f,dfdFlags:p}=function(t){const A=new i.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(),f=A.getLevels(),p=A.getHasAlpha(),g=A.getDFDTransferFunc(),m=A.getDFDFlags(),{transcoderFormat:_,engineFormat:b}=function(t,i,A,c){let h,u;const d=t===n.ETC1S?o:a;for(let s=0;s<d.length;s++){const r=d[s];if(e[r.if]&&(r.basisFormat.includes(t)&&!(c&&r.transcoderFormat.length<2)&&(!r.needsPowerOfTwo||l(i)&&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=s.RGBAFormat,{transcoderFormat:h,engineFormat:u}}(h,u,d,p);if(!u||!d||!f)throw c(),new Error("KTX2TextureTranscoder: Invalid texture");if(!A.startTranscoding())throw c(),new Error("KTX2TextureTranscoder: .startTranscoding failed");const B=[];for(let e=0;e<f;e++){const t=A.getImageLevelInfo(e,0,0),i=t.origWidth,s=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:i,height:s})}return c(),{width:u,height:d,hasAlpha:p,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:f,dfdFlags:p},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:[s.RGBA_ASTC_4x4_Format,s.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:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[s.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:[s.RGB_PVRTC_4BPPV1_Format,s.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 Hn={};function Nn(e){const t=e.scene.id;let i=Hn[t];return i||(i=new Ln({viewer:e}),Hn[t]=i,e.scene.on("destroyed",(()=>{delete Hn[t],i.destroy()}))),i}
|
|
7
|
+
"undefined"!=typeof window&&(window.__XEOKIT__={version:"2.6.99",commit:"916f60d2984c01eda311e05589b978ba8b5ad37c",built:"2025-12-09T13:35:43.419Z"});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 i{constructor(e){this.id=e,this.parentItem=null,this.groups=[],this.menuElement=null,this.shown=!1,this.mouseOver=0}}class s{constructor(){this.items=[]}}class r{constructor(e,t,i,s,r){this.id=e,this.getTitle=t,this.doAction=i,this.getEnabled=s,this.getShown=r,this.itemElement=null,this.subMenu=null,this.enabled=!0}}class n{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 i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}fire(e,t){const i=this._eventSubs[e];if(i)for(let e=0,s=i.length;e<s;e++)i[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 i(n);for(let i=0,n=e.length;i<n;i++){const n=e[i],o=new s;A.groups.push(o);for(let e=0,i=n.length;e<i;e++){const i=n[e],s=i.items,a=s&&s.length>0,l=this._getNextId(),c=i.getTitle||(()=>i.title||""),h=i.doAction||i.callback||(()=>{}),u=i.getEnabled||(()=>!0),d=i.getShown||(()=>!0),f=new r(l,c,h,u,d);if(f.parentMenu=A,o.items.push(f),a){const e=t(s);f.subMenu=e,e.parentItem=f}this._itemList.push(f),this._itemMap[f.id]=f}}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 i=t.groups;for(let t=0,s=i.length;t<s;t++){const s=i[t].items;for(let t=0,i=s.length;t<i;t++){const i=s[t].subMenu;i&&e(i)}}};e(this._rootMenu)}_createMenuUI(e){const t=e.groups,i=[],s=document.createElement("div");if(s.classList.add("xeokit-context-menu",e.id),s.style.zIndex=3e5,s.style.position="absolute",i.push("<ul>"),t)for(let e=0,s=t.length;e<s;e++){const r=e,n=s,A=t[e].items;if(A)for(let e=0,t=A.length;e<t;e++){const s=A[e],o=s.subMenu,a=s.title||"";o?(i.push('<li id="'+s.id+'" class="xeokit-context-menu-item xeokit-context-menu-submenu">'+a+"</li>"),r===n-1||e<t-1||i.push('<li id="'+s.id+'" class="xeokit-context-menu-item-separator"></li>')):(i.push('<li id="'+s.id+'" class="xeokit-context-menu-item">'+a+"</li>"),r===n-1||e<t-1||i.push('<li id="'+s.id+'" class="xeokit-context-menu-item-separator"></li>'))}}i.push("</ul>");const r=i.join("");s.innerHTML=r,this._parentNode.appendChild(s),e.menuElement=s,s.style["border-radius"]="4px",s.style.display="none",s.style["z-index"]=3e5,s.style.background="white",s.style.border="1px solid black",s.style["box-shadow"]="0 4px 5px 0 gray",s.oncontextmenu=e=>{e.preventDefault()};const n=this;let A=null;if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e].items;if(i)for(let e=0,t=i.length;e<t;e++){const t=i[e],s=t.subMenu;t.itemElement=this._parentNode.querySelector(`#${t.id}`),t.itemElement?(t.itemElement.addEventListener("mouseenter",(e=>{e.preventDefault();const i=t.subMenu;if(!i)return void(A&&(n._hideMenu(A.id),A=null));if(A&&A.id!==i.id&&(n._hideMenu(A.id),A=null),!1===t.enabled)return;const s=t.itemElement,r=i.menuElement,o=s.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(i.id,o.right+window.scrollX-5,o.top+window.scrollY-1);else if(h)n._showMenu(i.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(i.id,o.right-5-(l-t),o.top+window.scrollY-1):n._showMenu(i.id,o.left-e,o.top+window.scrollY-1)}A=i})),s||(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],i=t.itemElement;if(!i)continue;const s=t.getShown;if(!s||!s(this._context))continue;const r=t.getTitle(this._context);t.subMenu,i.innerText=r}}_updateItemsEnabledStatus(){if(this._context)for(let e=0,t=this._itemList.length;e<t;e++){const t=this._itemList[e],i=t.itemElement;if(!i)continue;const s=t.getEnabled;if(!s)continue;const r=t.getShown;if(!r)continue;const n=r(this._context);if(t.shown=n,!n){i.style.display="none";continue}i.style.display="";const A=s(this._context);t.enabled=A,A?i.classList.remove("disabled"):i.classList.add("disabled")}}_updateSubMenuInfo(){if(!this._context)return;let e,t,i,s,r,n;this._itemList.forEach((A=>{A.subMenu&&(e=A.itemElement,t=e.getBoundingClientRect(),i=A.subMenu.menuElement,s={visibility:i.style.visibility,display:i.style.display},i.style.display="block",i.style.visibility="hidden",n=A.subMenu.menuElement.getBoundingClientRect().width,i.style.visibility=s.visibility,i.style.display=s.display,r=t.right+n>window.innerWidth,e.setAttribute("data-submenuposition",r?"left":"right"))}))}_showMenu(e,t,i){const s=this._menuMap[e];if(!s)return void console.error("Menu not found: "+e);if(s.shown)return;const r=s.menuElement;r&&(this._showMenuElement(r,t,i),s.shown=!0)}_hideMenu(e){const t=this._menuMap[e];if(!t)return void console.error("Menu not found: "+e);if(!t.shown)return;const i=t.menuElement;i&&(this._hideMenuElement(i),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,i){e.style.display="block";const s=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;i+s>A&&(i=A-s),t+r>o&&(t=o-r),e.style.left=t-n.left-window.scrollX+"px",e.style.top=i-n.top-window.scrollY+"px"}_hideMenuElement(e){e.style.display="none"}}class A{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(),i=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`,i&&(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 s=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,this._canvasPos[0]-s/2,this._canvasPos[1]-s/2,s,s,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,i]=e?["greenyellow","green"]:["pink","red"];this._lensCursorDiv.style.background=t,this._lensCursorDiv.style.border=this._lensParams.cursorBorder+"px solid "+i}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)}}function o(e,t,i=2){const s=t&&t.length,r=s?t[0]*i:e.length;let n=a(e,0,r,i,!0);const A=[];if(!n||n.next===n.prev)return A;let o,l,h;if(s&&(n=function(e,t,i,s){const r=[];for(let i=0,n=t.length;i<n;i++){const A=a(e,t[i]*s,i<n-1?t[i+1]*s:e.length,s,!1);A===A.next&&(A.steiner=!0),r.push(b(A))}r.sort(p);for(let e=0;e<r.length;e++)i=g(r[e],i);return i}(e,t,n,i)),e.length>80*i){o=1/0,l=1/0;let t=-1/0,s=-1/0;for(let n=i;n<r;n+=i){const i=e[n],r=e[n+1];i<o&&(o=i),r<l&&(l=r),i>t&&(t=i),r>s&&(s=r)}h=Math.max(t-o,s-l),h=0!==h?32767/h:0}return c(n,A,i,o,l,h,0),A}function a(e,t,i,s,r){let n;if(r===function(e,t,i,s){let r=0;for(let n=t,A=i-s;n<i;n+=s)r+=(e[A]-e[n])*(e[n+1]+e[A+1]),A=n;return r}(e,t,i,s)>0)for(let r=t;r<i;r+=s)n=I(r/s|0,e[r],e[r+1],n);else for(let r=i-s;r>=t;r-=s)n=I(r/s|0,e[r],e[r+1],n);return n&&C(n,n.next)&&(T(n),n=n.next),n}function l(e,t){if(!e)return e;t||(t=e);let i,s=e;do{if(i=!1,s.steiner||!C(s,s.next)&&0!==v(s.prev,s,s.next))s=s.next;else{if(T(s),s=t=s.prev,s===s.next)break;i=!0}}while(i||s!==t);return t}function c(e,t,i,s,r,n,A){if(!e)return;!A&&n&&function(e,t,i,s){let r=e;do{0===r.z&&(r.z=_(r.x,r.y,t,i,s)),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,i=1;do{let s,r=e;e=null;let n=null;for(t=0;r;){t++;let A=r,o=0;for(let e=0;e<i&&(o++,A=A.nextZ,A);e++);let a=i;for(;o>0||a>0&&A;)0!==o&&(0===a||!A||r.z<=A.z)?(s=r,r=r.nextZ,o--):(s=A,A=A.nextZ,a--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;r=A}n.nextZ=null,i*=2}while(t>1)}(r)}(e,s,r,n);let o=e;for(;e.prev!==e.next;){const a=e.prev,p=e.next;if(n?u(e,s,r,n):h(e))t.push(a.i,e.i,p.i),T(e),e=p.next,o=p.next;else if((e=p)===o){A?1===A?c(e=d(l(e),t),t,i,s,r,n,2):2===A&&f(e,t,i,s,r,n):c(l(e),t,i,s,r,n,1);break}}}function h(e){const t=e.prev,i=e,s=e.next;if(v(t,i,s)>=0)return!1;const r=t.x,n=i.x,A=s.x,o=t.y,a=i.y,l=s.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 f=s.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=h&&f.y<=d&&y(r,o,n,a,A,l,f.x,f.y)&&v(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function u(e,t,i,s){const r=e.prev,n=e,A=e.next;if(v(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),f=Math.min(c,h,u),p=Math.max(o,a,l),g=Math.max(c,h,u),m=_(d,f,t,i,s),b=_(p,g,t,i,s);let B=e.prevZ,w=e.nextZ;for(;B&&B.z>=m&&w&&w.z<=b;){if(B.x>=d&&B.x<=p&&B.y>=f&&B.y<=g&&B!==r&&B!==A&&y(o,c,a,h,l,u,B.x,B.y)&&v(B.prev,B,B.next)>=0)return!1;if(B=B.prevZ,w.x>=d&&w.x<=p&&w.y>=f&&w.y<=g&&w!==r&&w!==A&&y(o,c,a,h,l,u,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;B&&B.z>=m;){if(B.x>=d&&B.x<=p&&B.y>=f&&B.y<=g&&B!==r&&B!==A&&y(o,c,a,h,l,u,B.x,B.y)&&v(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;w&&w.z<=b;){if(w.x>=d&&w.x<=p&&w.y>=f&&w.y<=g&&w!==r&&w!==A&&y(o,c,a,h,l,u,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function d(e,t){let i=e;do{const s=i.prev,r=i.next.next;!C(s,r)&&M(s,i,i.next,r)&&U(s,r)&&U(r,s)&&(t.push(s.i,i.i,r.i),T(i),T(i.next),i=e=r),i=i.next}while(i!==e);return l(i)}function f(e,t,i,s,r,n){let A=e;do{let e=A.next.next;for(;e!==A.prev;){if(A.i!==e.i&&w(A,e)){let o=x(A,e);return A=l(A,A.next),o=l(o,o.next),c(A,t,i,s,r,n,0),void c(o,t,i,s,r,n,0)}e=e.next}A=A.next}while(A!==e)}function p(e,t){let i=e.x-t.x;if(0===i&&(i=e.y-t.y,0===i)){i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return i}function g(e,t){const i=function(e,t){let i=t;const s=e.x,r=e.y;let n,A=-1/0;if(C(e,i))return i;do{if(C(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>A&&(A=e,n=i.x<i.next.x?i:i.next,e===s))return n}i=i.next}while(i!==t);if(!n)return null;const o=n,a=n.x,l=n.y;let c=1/0;i=n;do{if(s>=i.x&&i.x>=a&&s!==i.x&&B(r<l?s:A,r,a,l,r<l?A:s,r,i.x,i.y)){const t=Math.abs(r-i.y)/(s-i.x);U(i,e)&&(t<c||t===c&&(i.x>n.x||i.x===n.x&&m(n,i)))&&(n=i,c=t)}i=i.next}while(i!==o);return n}(e,t);if(!i)return t;const s=x(i,e);return l(s,s.next),l(i,i.next)}function m(e,t){return v(e.prev,e,t.prev)<0&&v(t.next,e,e.next)<0}function _(e,t,i,s,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function b(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function B(e,t,i,s,r,n,A,o){return(r-A)*(t-o)>=(e-A)*(n-o)&&(e-A)*(s-o)>=(i-A)*(t-o)&&(i-A)*(n-o)>=(r-A)*(s-o)}function y(e,t,i,s,r,n,A,o){return!(e===A&&t===o)&&B(e,t,i,s,r,n,A,o)}function w(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&M(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(U(e,t)&&U(t,e)&&function(e,t){let i=e,s=!1;const r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==e);return s}(e,t)&&(v(e.prev,e,t.prev)||v(e,t.prev,t))||C(e,t)&&v(e.prev,e,e.next)>0&&v(t.prev,t,t.next)>0)}function v(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function C(e,t){return e.x===t.x&&e.y===t.y}function M(e,t,i,s){const r=F(v(e,t,i)),n=F(v(e,t,s)),A=F(v(i,s,e)),o=F(v(i,s,t));return r!==n&&A!==o||(!(0!==r||!E(e,i,t))||(!(0!==n||!E(e,s,t))||(!(0!==A||!E(i,e,s))||!(0!==o||!E(i,t,s)))))}function E(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function F(e){return e>0?1:e<0?-1:0}function U(e,t){return v(e.prev,e,e.next)<0?v(e,t,e.next)>=0&&v(e,e.prev,t)>=0:v(e,t,e.prev)<0||v(e,e.next,t)<0}function x(e,t){const i=P(e.i,e.x,e.y),s=P(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function I(e,t,i,s){const r=P(e,t,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function T(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 P(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}let S=!0,D=S?Float64Array:Float32Array;const k=new D(3),Q=new D(16),R=new D(16),O=new D(4),V={setDoublePrecisionEnabled(e){S=e,D=S?Float64Array:Float32Array},getDoublePrecisionEnabled:()=>S,MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:1e7,DEGTORAD:.0174532925,RADTODEG:57.295779513,unglobalizeObjectId(e,t){const i=t.indexOf("#");return i===e.length&&t.startsWith(e)?t.substring(i+1):t},globalizeObjectId:(e,t)=>e+"#"+t,safeInv(e){const t=1/e;return isNaN(t)||!isFinite(t)?1:t},vec2:e=>new D(e||2),vec3:e=>new D(e||3),vec4:e=>new D(e||4),mat3:e=>new D(e||9),mat3ToMat4:(e,t=new D(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 D(e||16),mat4ToMat3:(e,t=new D(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,i){const s=new D(2);for(let r=0,n=e.length;r<n;r++)V.splitDouble(e[r],s),t[r]=s[0],i[r]=s[1]},splitDouble(e,t){const i=D.from([e])[0],s=e-i;t[0]=i,t[1]=s},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,i=4294967295*Math.random()|0,s=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&i]}${e[i>>8&255]}-${e[i>>16&15|64]}${e[i>>24&255]}-${e[63&s|128]}${e[s>>8&255]}-${e[s>>16&255]}${e[s>>24&255]}${e[255&r]}${e[r>>8&255]}${e[r>>16&255]}${e[r>>24&255]}`}})(),clamp:(e,t,i)=>Math.max(t,Math.min(i,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,i)=>(i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i),addVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i),addVec3:(e,t,i)=>(i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i),addVec3Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i),subVec4:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i),subVec3:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i),subVec2:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i),geometricMeanVec2(...e){const t=new D(e[0]);for(let i=1;i<e.length;i++)t[0]+=e[i][0],t[1]+=e[i][1];return t[0]/=e.length,t[1]/=e.length,t},subVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i),subScalarVec4:(e,t,i)=>(i||(i=e),i[0]=t-e[0],i[1]=t-e[1],i[2]=t-e[2],i[3]=t-e[3],i),mulVec4:(e,t,i)=>(i||(i=e),i[0]=e[0]*t[0],i[1]=e[1]*t[1],i[2]=e[2]*t[2],i[3]=e[3]*t[3],i),mulVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i),mulVec3Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i),mulVec2Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i),divVec3:(e,t,i)=>(i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i),divVec4:(e,t,i)=>(i||(i=e),i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i[3]=e[3]/t[3],i),divScalarVec3:(e,t,i)=>(i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i),divVec3Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i),divVec4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]/t,i[1]=e[1]/t,i[2]=e[2]/t,i[3]=e[3]/t,i),divScalarVec4:(e,t,i)=>(i||(i=t),i[0]=e/t[0],i[1]=e/t[1],i[2]=e/t[2],i[3]=e/t[3],i),dotVec4:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],cross3Vec4(e,t){const i=e[0],s=e[1],r=e[2],n=t[0],A=t[1],o=t[2];return[s*o-r*A,r*n-i*o,i*A-s*n,0]},cross3Vec3(e,t,i){i||(i=e);const s=e[0],r=e[1],n=e[2],A=t[0],o=t[1],a=t[2];return i[0]=r*a-n*o,i[1]=n*A-s*a,i[2]=s*o-r*A,i},sqLenVec4:e=>V.dotVec4(e,e),lenVec4:e=>Math.sqrt(V.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=>V.dotVec3(e,e),sqLenVec2:e=>V.dotVec2(e,e),lenVec3:e=>Math.sqrt(V.sqLenVec3(e)),distVec3:(()=>{const e=new D(3);return(t,i)=>V.lenVec3(V.subVec3(t,i,e))})(),lenVec2:e=>Math.sqrt(V.sqLenVec2(e)),distVec2:(()=>{const e=new D(2);return(t,i)=>V.lenVec2(V.subVec2(t,i,e))})(),rcpVec3:(e,t)=>V.divScalarVec3(1,e,t),normalizeVec4(e,t){const i=1/V.lenVec4(e);return V.mulVec4Scalar(e,i,t)},normalizeVec3(e,t){const i=1/V.lenVec3(e);return V.mulVec3Scalar(e,i,t)},normalizeVec2(e,t){const i=1/V.lenVec2(e);return V.mulVec2Scalar(e,i,t)},angleVec3(e,t){let i=V.dotVec3(e,t)/Math.sqrt(V.sqLenVec3(e)*V.sqLenVec3(t));return i=i<-1?-1:i>1?1:i,Math.acos(i)},vec3FromMat4Scale:(()=>{const e=new D(3);return(t,i)=>(e[0]=t[0],e[1]=t[1],e[2]=t[2],i[0]=V.lenVec3(e),e[0]=t[4],e[1]=t[5],e[2]=t[6],i[1]=V.lenVec3(e),e[0]=t[8],e[1]=t[9],e[2]=t[10],i[2]=V.lenVec3(e),i)})(),vecToArray:(()=>{function e(e){return Math.round(1e5*e)/1e5}return t=>{for(let i=0,s=(t=Array.prototype.slice.call(t)).length;i<s;i++)t[i]=e(t[i]);return t}})(),xyzArrayToObject:e=>({x:e[0],y:e[1],z:e[2]}),xyzObjectToArray:(e,t)=>((t=t||V.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:()=>V.m4s(0),setMat4ToOnes:()=>V.m4s(1),diagonalMat4v:e=>new D([e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,e[3]]),diagonalMat4c:(e,t,i,s)=>V.diagonalMat4v([e,t,i,s]),diagonalMat4s:e=>V.diagonalMat4c(e,e,e,e),identityMat4:(e=new D(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 D(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,i)=>(i||(i=e),i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i[3]=e[3]+t[3],i[4]=e[4]+t[4],i[5]=e[5]+t[5],i[6]=e[6]+t[6],i[7]=e[7]+t[7],i[8]=e[8]+t[8],i[9]=e[9]+t[9],i[10]=e[10]+t[10],i[11]=e[11]+t[11],i[12]=e[12]+t[12],i[13]=e[13]+t[13],i[14]=e[14]+t[14],i[15]=e[15]+t[15],i),addMat4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]+t,i[1]=e[1]+t,i[2]=e[2]+t,i[3]=e[3]+t,i[4]=e[4]+t,i[5]=e[5]+t,i[6]=e[6]+t,i[7]=e[7]+t,i[8]=e[8]+t,i[9]=e[9]+t,i[10]=e[10]+t,i[11]=e[11]+t,i[12]=e[12]+t,i[13]=e[13]+t,i[14]=e[14]+t,i[15]=e[15]+t,i),addScalarMat4:(e,t,i)=>V.addMat4Scalar(t,e,i),subMat4:(e,t,i)=>(i||(i=e),i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i[3]=e[3]-t[3],i[4]=e[4]-t[4],i[5]=e[5]-t[5],i[6]=e[6]-t[6],i[7]=e[7]-t[7],i[8]=e[8]-t[8],i[9]=e[9]-t[9],i[10]=e[10]-t[10],i[11]=e[11]-t[11],i[12]=e[12]-t[12],i[13]=e[13]-t[13],i[14]=e[14]-t[14],i[15]=e[15]-t[15],i),subMat4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]-t,i[1]=e[1]-t,i[2]=e[2]-t,i[3]=e[3]-t,i[4]=e[4]-t,i[5]=e[5]-t,i[6]=e[6]-t,i[7]=e[7]-t,i[8]=e[8]-t,i[9]=e[9]-t,i[10]=e[10]-t,i[11]=e[11]-t,i[12]=e[12]-t,i[13]=e[13]-t,i[14]=e[14]-t,i[15]=e[15]-t,i),subScalarMat4:(e,t,i)=>(i||(i=t),i[0]=e-t[0],i[1]=e-t[1],i[2]=e-t[2],i[3]=e-t[3],i[4]=e-t[4],i[5]=e-t[5],i[6]=e-t[6],i[7]=e-t[7],i[8]=e-t[8],i[9]=e-t[9],i[10]=e-t[10],i[11]=e-t[11],i[12]=e-t[12],i[13]=e-t[13],i[14]=e-t[14],i[15]=e-t[15],i),mulMat4(e,t,i){i||(i=e);const s=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],f=e[11],p=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],U=t[9],x=t[10],I=t[11],T=t[12],P=t[13],S=t[14],D=t[15];return i[0]=b*s+B*o+y*h+w*p,i[1]=b*r+B*a+y*u+w*g,i[2]=b*n+B*l+y*d+w*m,i[3]=b*A+B*c+y*f+w*_,i[4]=v*s+C*o+M*h+E*p,i[5]=v*r+C*a+M*u+E*g,i[6]=v*n+C*l+M*d+E*m,i[7]=v*A+C*c+M*f+E*_,i[8]=F*s+U*o+x*h+I*p,i[9]=F*r+U*a+x*u+I*g,i[10]=F*n+U*l+x*d+I*m,i[11]=F*A+U*c+x*f+I*_,i[12]=T*s+P*o+S*h+D*p,i[13]=T*r+P*a+S*u+D*g,i[14]=T*n+P*l+S*d+D*m,i[15]=T*A+P*c+S*f+D*_,i},mulMat3(e,t,i){i||(i=new D(9));const s=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],f=t[6],p=t[1],g=t[4],m=t[7],_=t[2],b=t[5],B=t[8];return i[0]=s*u+r*p+n*_,i[3]=s*d+r*g+n*b,i[6]=s*f+r*m+n*B,i[1]=A*u+o*p+a*_,i[4]=A*d+o*g+a*b,i[7]=A*f+o*m+a*B,i[2]=l*u+c*p+h*_,i[5]=l*d+c*g+h*b,i[8]=l*f+c*m+h*B,i},mulMat4Scalar:(e,t,i)=>(i||(i=e),i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i[4]=e[4]*t,i[5]=e[5]*t,i[6]=e[6]*t,i[7]=e[7]*t,i[8]=e[8]*t,i[9]=e[9]*t,i[10]=e[10]*t,i[11]=e[11]*t,i[12]=e[12]*t,i[13]=e[13]*t,i[14]=e[14]*t,i[15]=e[15]*t,i),mulMat4v4(e,t,i=V.vec4()){const s=t[0],r=t[1],n=t[2],A=t[3];return i[0]=e[0]*s+e[4]*r+e[8]*n+e[12]*A,i[1]=e[1]*s+e[5]*r+e[9]*n+e[13]*A,i[2]=e[2]*s+e[6]*r+e[10]*n+e[14]*A,i[3]=e[3]*s+e[7]*r+e[11]*n+e[15]*A,i},transposeMat4(e,t){const i=e[4],s=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]=i,e[2]=r,e[3]=A,e[4]=t,e[6]=o,e[7]=n,e[8]=a,e[9]=c,e[11]=s,e[12]=l,e[13]=h,e[14]=u,e}return t[0]=e[0],t[1]=i,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]=s,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3(e,t){if(t===e){const i=e[1],s=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=s,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],i=e[1],s=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],f=e[13],p=e[14],g=e[15];return d*c*o*r-l*f*o*r-d*A*h*r+n*f*h*r+l*A*p*r-n*c*p*r-d*c*s*a+l*f*s*a+d*i*h*a-t*f*h*a-l*i*p*a+t*c*p*a+d*A*s*u-n*f*s*u-d*i*o*u+t*f*o*u+n*i*p*u-t*A*p*u-l*A*s*g+n*c*s*g+l*i*o*g-t*c*o*g-n*i*h*g+t*A*h*g},inverseMat4(e,t){t||(t=e);const i=e[0],s=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],f=e[12],p=e[13],g=e[14],m=e[15],_=i*o-s*A,b=i*a-r*A,B=i*l-n*A,y=s*a-r*o,w=s*l-n*o,v=r*l-n*a,C=c*p-h*f,M=c*g-u*f,E=c*m-d*f,F=h*g-u*p,U=h*m-d*p,x=u*m-d*g,I=1/(_*x-b*U+B*F+y*E-w*M+v*C);return t[0]=(o*x-a*U+l*F)*I,t[1]=(-s*x+r*U-n*F)*I,t[2]=(p*v-g*w+m*y)*I,t[3]=(-h*v+u*w-d*y)*I,t[4]=(-A*x+a*E-l*M)*I,t[5]=(i*x-r*E+n*M)*I,t[6]=(-f*v+g*B-m*b)*I,t[7]=(c*v-u*B+d*b)*I,t[8]=(A*U-o*E+l*C)*I,t[9]=(-i*U+s*E-n*C)*I,t[10]=(f*w-p*B+m*_)*I,t[11]=(-c*w+h*B-d*_)*I,t[12]=(-A*F+o*M-a*C)*I,t[13]=(i*F-s*M+r*C)*I,t[14]=(-f*y+p*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 i=t||V.identityMat4();return i[12]=e[0],i[13]=e[1],i[14]=e[2],i},translationMat3v(e,t){const i=t||V.identityMat3();return i[6]=e[0],i[7]=e[1],i},translationMat4c:(()=>{const e=new D(3);return(t,i,s,r)=>(e[0]=t,e[1]=i,e[2]=s,V.translationMat4v(e,r))})(),translationMat4s:(e,t)=>V.translationMat4c(e,e,e,t),translateMat4v:(e,t)=>V.translateMat4c(e[0],e[1],e[2],t),translateMat4c(e,t,i,s){const r=s[3];s[0]+=r*e,s[1]+=r*t,s[2]+=r*i;const n=s[7];s[4]+=n*e,s[5]+=n*t,s[6]+=n*i;const A=s[11];s[8]+=A*e,s[9]+=A*t,s[10]+=A*i;const o=s[15];return s[12]+=o*e,s[13]+=o*t,s[14]+=o*i,s},setMat4Translation:(e,t,i)=>(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=e[15],i),rotationMat4v(e,t,i){const s=V.normalizeVec4([t[0],t[1],t[2],0],[]),r=Math.sin(e),n=Math.cos(e),A=1-n,o=s[0],a=s[1],l=s[2];let c,h,u,d,f,p;return c=o*a,h=a*l,u=l*o,d=o*r,f=a*r,p=l*r,(i=i||V.mat4())[0]=A*o*o+n,i[1]=A*c+p,i[2]=A*u-f,i[3]=0,i[4]=A*c-p,i[5]=A*a*a+n,i[6]=A*h+d,i[7]=0,i[8]=A*u+f,i[9]=A*h-d,i[10]=A*l*l+n,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},rotationMat4c:(e,t,i,s,r)=>V.rotationMat4v(e,[t,i,s],r),scalingMat4v:(e,t=V.identityMat4())=>(t[0]=e[0],t[5]=e[1],t[10]=e[2],t),scalingMat3v:(e,t=V.identityMat3())=>(t[0]=e[0],t[4]=e[1],t),scalingMat4c:(()=>{const e=new D(3);return(t,i,s,r)=>(e[0]=t,e[1]=i,e[2]=s,V.scalingMat4v(e,r))})(),scaleMat4c:(e,t,i,s)=>(s[0]*=e,s[4]*=t,s[8]*=i,s[1]*=e,s[5]*=t,s[9]*=i,s[2]*=e,s[6]*=t,s[10]*=i,s[3]*=e,s[7]*=t,s[11]*=i,s),scaleMat4v(e,t){const i=e[0],s=e[1],r=e[2];return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,t},scalingMat4s:e=>V.scalingMat4c(e,e,e),rotationTranslationMat4(e,t,i=V.mat4()){const s=e[0],r=e[1],n=e[2],A=e[3],o=s+s,a=r+r,l=n+n,c=s*o,h=s*a,u=s*l,d=r*a,f=r*l,p=n*l,g=A*o,m=A*a,_=A*l;return i[0]=1-(d+p),i[1]=h+_,i[2]=u-m,i[3]=0,i[4]=h-_,i[5]=1-(c+p),i[6]=f+g,i[7]=0,i[8]=u+m,i[9]=f-g,i[10]=1-(c+d),i[11]=0,i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=1,i},mat4ToEuler(e,t,i=V.vec4()){const s=V.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?(i[1]=Math.asin(s(A,-1,1)),Math.abs(A)<.99999?(i[0]=Math.atan2(-l,u),i[2]=Math.atan2(-n,r)):(i[0]=Math.atan2(h,a),i[2]=0)):"YXZ"===t?(i[0]=Math.asin(-s(l,-1,1)),Math.abs(l)<.99999?(i[1]=Math.atan2(A,u),i[2]=Math.atan2(o,a)):(i[1]=Math.atan2(-c,r),i[2]=0)):"ZXY"===t?(i[0]=Math.asin(s(h,-1,1)),Math.abs(h)<.99999?(i[1]=Math.atan2(-c,u),i[2]=Math.atan2(-n,a)):(i[1]=0,i[2]=Math.atan2(o,r))):"ZYX"===t?(i[1]=Math.asin(-s(c,-1,1)),Math.abs(c)<.99999?(i[0]=Math.atan2(h,u),i[2]=Math.atan2(o,r)):(i[0]=0,i[2]=Math.atan2(-n,a))):"YZX"===t?(i[2]=Math.asin(s(o,-1,1)),Math.abs(o)<.99999?(i[0]=Math.atan2(-l,a),i[1]=Math.atan2(-c,r)):(i[0]=0,i[1]=Math.atan2(A,u))):"XZY"===t&&(i[2]=Math.asin(-s(n,-1,1)),Math.abs(n)<.99999?(i[0]=Math.atan2(h,a),i[1]=Math.atan2(A,r)):(i[0]=Math.atan2(-l,u),i[1]=0)),i[0]*=V.RADTODEG,i[1]*=V.RADTODEG,i[2]*=V.RADTODEG,i},composeMat4:(e,t,i,s=V.mat4())=>(V.quaternionToRotationMat4(t,s),V.scaleMat4v(i,s),V.translateMat4v(e,s),s),decomposeMat4:(()=>{const e=new D(3),t=new D(16);return function(i,s,r,n){e[0]=i[0],e[1]=i[1],e[2]=i[2];let A=V.lenVec3(e);e[0]=i[4],e[1]=i[5],e[2]=i[6];const o=V.lenVec3(e);e[0]=i[8],e[1]=i[9],e[2]=i[10];const a=V.lenVec3(e);V.determinantMat4(i)<0&&(A=-A),s[0]=i[12],s[1]=i[13],s[2]=i[14],t.set(i);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,V.mat4ToQuaternion(t,r),n[0]=A,n[1]=o,n[2]=a,this}})(),getColMat4(e,t){const i=4*t;return[e[i],e[i+1],e[i+2],e[i+3]]},setRowMat4(e,t,i){e[t]=i[0],e[t+4]=i[1],e[t+8]=i[2],e[t+12]=i[3]},lookAtMat4v(e,t,i,s){s||(s=V.mat4());const r=e[0],n=e[1],A=e[2],o=i[0],a=i[1],l=i[2],c=t[0],h=t[1],u=t[2];if(r===c&&n===h&&A===u)return V.identityMat4();let d,f,p,g,m,_,b,B,y,w;return d=r-c,f=n-h,p=A-u,w=1/Math.sqrt(d*d+f*f+p*p),d*=w,f*=w,p*=w,g=a*p-l*f,m=l*d-o*p,_=o*f-a*d,w=Math.sqrt(g*g+m*m+_*_),w?(w=1/w,g*=w,m*=w,_*=w):(g=0,m=0,_=0),b=f*_-p*m,B=p*g-d*_,y=d*m-f*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),s[0]=g,s[1]=b,s[2]=d,s[3]=0,s[4]=m,s[5]=B,s[6]=f,s[7]=0,s[8]=_,s[9]=y,s[10]=p,s[11]=0,s[12]=-(g*r+m*n+_*A),s[13]=-(b*r+B*n+y*A),s[14]=-(d*r+f*n+p*A),s[15]=1,s},lookAtMat4c:(e,t,i,s,r,n,A,o,a)=>V.lookAtMat4v([e,t,i],[s,r,n],[A,o,a],[]),orthoMat4c(e,t,i,s,r,n,A){A||(A=V.mat4());const o=t-e,a=s-i,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]=-(s+i)/a,A[14]=-(n+r)/l,A[15]=1,A},frustumMat4v(e,t,i){i||(i=V.mat4());const s=[e[0],e[1],e[2],0],r=[t[0],t[1],t[2],0];V.addVec4(r,s,Q),V.subVec4(r,s,R);const n=2*s[2],A=R[0],o=R[1],a=R[2];return i[0]=n/A,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=n/o,i[6]=0,i[7]=0,i[8]=Q[0]/A,i[9]=Q[1]/o,i[10]=-Q[2]/a,i[11]=-1,i[12]=0,i[13]=0,i[14]=-n*r[2]/a,i[15]=0,i},frustumMat4(e,t,i,s,r,n,A){A||(A=V.mat4());const o=t-e,a=s-i,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]=(s+i)/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,i,s,r){const n=[],A=[];return n[2]=i,A[2]=s,A[1]=n[2]*Math.tan(e/2),n[1]=-A[1],A[0]=A[1]*t,n[0]=-A[0],V.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,i=V.vec3()){const s=t[0],r=t[1],n=t[2];return i[0]=e[0]*s+e[4]*r+e[8]*n+e[12],i[1]=e[1]*s+e[5]*r+e[9]*n+e[13],i[2]=e[2]*s+e[6]*r+e[10]*n+e[14],i},transformPoint4:(e,t,i=V.vec4())=>(i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],i),transformPoints3(e,t,i){const s=i||[],r=t.length;let n,A,o,a;const l=e[0],c=e[1],h=e[2],u=e[3],d=e[4],f=e[5],p=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=s[e]||(s[e]=[0,0,0]),M[0]=l*n+d*A+m*o+y,M[1]=c*n+f*A+_*o+w,M[2]=h*n+p*A+b*o+v,M[3]=u*n+g*A+B*o+C;return s.length=r,s},transformPositions3(e,t,i=t){let s;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 f=e[8],p=e[9],g=e[10];e[11];const m=e[12],_=e[13],b=e[14];for(e[15],s=0;s<r;s+=3)n=t[s+0],A=t[s+1],o=t[s+2],i[s+0]=a*n+h*A+f*o+m,i[s+1]=l*n+u*A+p*o+_,i[s+2]=c*n+d*A+g*o+b;return i},transformPositions4(e,t,i=t){let s;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],f=e[6],p=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(s=0;s<r;s+=4)n=t[s+0],A=t[s+1],o=t[s+2],i[s+0]=a*n+u*A+g*o+B,i[s+1]=l*n+d*A+m*o+y,i[s+2]=c*n+f*A+_*o+w,i[s+3]=h*n+p*A+b*o+v;return i},transformVec3(e,t,i){const s=t[0],r=t[1],n=t[2];return(i=i||this.vec3())[0]=e[0]*s+e[4]*r+e[8]*n,i[1]=e[1]*s+e[5]*r+e[9]*n,i[2]=e[2]*s+e[6]*r+e[10]*n,i},transformVec4(e,t,i){const s=t[0],r=t[1],n=t[2],A=t[3];return(i=i||V.vec4())[0]=e[0]*s+e[4]*r+e[8]*n+e[12]*A,i[1]=e[1]*s+e[5]*r+e[9]*n+e[13]*A,i[2]=e[2]*s+e[6]*r+e[10]*n+e[14]*A,i[3]=e[3]*s+e[7]*r+e[11]*n+e[15]*A,i},rotateVec2(e,t,i,s=e){const r=Math.cos(i),n=Math.sin(i),A=e[0]-t[0],o=e[1]-t[1];return s[0]=A*r-o*n+t[0],s[1]=A*n+o*r+t[1],e},rotateVec3X(e,t,i,s){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(i)-r[2]*Math.sin(i),n[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},rotateVec3Y(e,t,i,s){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(i)+r[0]*Math.cos(i),n[1]=r[1],n[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},rotateVec3Z(e,t,i,s){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(i)-r[1]*Math.sin(i),n[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),n[2]=r[2],s[0]=n[0]+t[0],s[1]=n[1]+t[1],s[2]=n[2]+t[2],s},projectVec4(e,t){const i=1/e[3];return(t=t||V.vec2())[0]=e[0]*i,t[1]=e[1]*i,t},unprojectVec3:(()=>{const e=new D(16),t=new D(16),i=new D(16);return function(s,r,n,A){return this.transformVec3(this.mulMat4(this.inverseMat4(r,e),this.inverseMat4(n,t),i),s,A)}})(),lerpVec3(e,t,i,s,r,n){const A=n||V.vec3(),o=(e-t)/(i-t);return A[0]=s[0]+o*(r[0]-s[0]),A[1]=s[1]+o*(r[1]-s[1]),A[2]=s[2]+o*(r[2]-s[2]),A},lerpMat4(e,t,i,s,r,n){const A=n||V.mat4(),o=(e-t)/(i-t);return A[0]=s[0]+o*(r[0]-s[0]),A[1]=s[1]+o*(r[1]-s[1]),A[2]=s[2]+o*(r[2]-s[2]),A[3]=s[3]+o*(r[3]-s[3]),A[4]=s[4]+o*(r[4]-s[4]),A[5]=s[5]+o*(r[5]-s[5]),A[6]=s[6]+o*(r[6]-s[6]),A[7]=s[7]+o*(r[7]-s[7]),A[8]=s[8]+o*(r[8]-s[8]),A[9]=s[9]+o*(r[9]-s[9]),A[10]=s[10]+o*(r[10]-s[10]),A[11]=s[11]+o*(r[11]-s[11]),A[12]=s[12]+o*(r[12]-s[12]),A[13]=s[13]+o*(r[13]-s[13]),A[14]=s[14]+o*(r[14]-s[14]),A[15]=s[15]+o*(r[15]-s[15]),A},flatten(e){const t=[];let i,s,r,n,A;for(i=0,s=e.length;i<s;i++)for(A=e[i],r=0,n=A.length;r<n;r++)t.push(A[r]);return t},identityQuaternion:(e=V.vec4())=>(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e),eulerToQuaternion(e,t,i=V.vec4()){const s=e[0]*V.DEGTORAD/2,r=e[1]*V.DEGTORAD/2,n=e[2]*V.DEGTORAD/2,A=Math.cos(s),o=Math.cos(r),a=Math.cos(n),l=Math.sin(s),c=Math.sin(r),h=Math.sin(n);return"XYZ"===t?(i[0]=l*o*a+A*c*h,i[1]=A*c*a-l*o*h,i[2]=A*o*h+l*c*a,i[3]=A*o*a-l*c*h):"YXZ"===t?(i[0]=l*o*a+A*c*h,i[1]=A*c*a-l*o*h,i[2]=A*o*h-l*c*a,i[3]=A*o*a+l*c*h):"ZXY"===t?(i[0]=l*o*a-A*c*h,i[1]=A*c*a+l*o*h,i[2]=A*o*h+l*c*a,i[3]=A*o*a-l*c*h):"ZYX"===t?(i[0]=l*o*a-A*c*h,i[1]=A*c*a+l*o*h,i[2]=A*o*h-l*c*a,i[3]=A*o*a+l*c*h):"YZX"===t?(i[0]=l*o*a+A*c*h,i[1]=A*c*a+l*o*h,i[2]=A*o*h-l*c*a,i[3]=A*o*a-l*c*h):"XZY"===t&&(i[0]=l*o*a-A*c*h,i[1]=A*c*a-l*o*h,i[2]=A*o*h+l*c*a,i[3]=A*o*a+l*c*h),i},mat4ToQuaternion(e,t=V.vec4()){const i=e[0],s=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=i+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-s)*h):i>A&&i>c?(h=2*Math.sqrt(1+i-A-c),t[3]=(l-o)/h,t[0]=.25*h,t[1]=(s+n)/h,t[2]=(r+a)/h):A>c?(h=2*Math.sqrt(1+A-i-c),t[3]=(r-a)/h,t[0]=(s+n)/h,t[1]=.25*h,t[2]=(o+l)/h):(h=2*Math.sqrt(1+c-i-A),t[3]=(n-s)/h,t[0]=(r+a)/h,t[1]=(o+l)/h,t[2]=.25*h),t},vec3PairToQuaternion(e,t,i=V.vec4()){const s=Math.sqrt(V.dotVec3(e,e)*V.dotVec3(t,t));let r=s+V.dotVec3(e,t);return r<1e-8*s?(r=0,Math.abs(e[0])>Math.abs(e[2])?(i[0]=-e[1],i[1]=e[0],i[2]=0):(i[0]=0,i[1]=-e[2],i[2]=e[1])):V.cross3Vec3(e,t,i),i[3]=r,V.normalizeQuaternion(i)},angleAxisToQuaternion(e,t=V.vec4()){const i=e[3]/2,s=Math.sin(i);return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=Math.cos(i),t},quaternionToEuler:(()=>{const e=new D(16);return(t,i,s)=>(s=s||V.vec3(),V.quaternionToRotationMat4(t,e),V.mat4ToEuler(e,i,s),s)})(),mulQuaternions(e,t,i=V.vec4()){const s=e[0],r=e[1],n=e[2],A=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return i[0]=A*o+s*c+r*l-n*a,i[1]=A*a+r*c+n*o-s*l,i[2]=A*l+n*c+s*a-r*o,i[3]=A*c-s*o-r*a-n*l,i},vec3ApplyQuaternion(e,t,i=V.vec3()){const s=t[0],r=t[1],n=t[2],A=e[0],o=e[1],a=e[2],l=e[3],c=l*s+o*n-a*r,h=l*r+a*s-A*n,u=l*n+A*r-o*s,d=-A*s-o*r-a*n;return i[0]=c*l+d*-A+h*-a-u*-o,i[1]=h*l+d*-o+u*-A-c*-a,i[2]=u*l+d*-a+c*-o-h*-A,i},quaternionToMat4(e,t){t=V.identityMat4(t);const i=e[0],s=e[1],r=e[2],n=e[3],A=2*i,o=2*s,a=2*r,l=A*n,c=o*n,h=a*n,u=A*i,d=o*i,f=a*i,p=o*s,g=a*s,m=a*r;return t[0]=1-(p+m),t[1]=d+h,t[2]=f-c,t[4]=d-h,t[5]=1-(u+m),t[6]=g+l,t[8]=f+c,t[9]=g-l,t[10]=1-(u+p),t},quaternionToRotationMat4(e,t){const i=e[0],s=e[1],r=e[2],n=e[3],A=i+i,o=s+s,a=r+r,l=i*A,c=i*o,h=i*a,u=s*o,d=s*a,f=r*a,p=n*A,g=n*o,m=n*a;return t[0]=1-(u+f),t[4]=c-m,t[8]=h+g,t[1]=c+m,t[5]=1-(l+f),t[9]=d-p,t[2]=h-g,t[6]=d+p,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 i=V.lenVec4([e[0],e[1],e[2],e[3]]);return t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i,t[3]=e[3]/i,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)=>V.normalizeQuaternion(V.conjugateQuaternion(e,t)),quaternionToAngleAxis(e,t=V.vec4()){const i=(e=V.normalizeQuaternion(e,O))[3],s=2*Math.acos(i),r=Math.sqrt(1-i*i);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]=s,t},AABB3:e=>new D(e||6),AABB2:e=>new D(e||4),OBB3:e=>new D(e||32),OBB2:e=>new D(e||16),Sphere3:(e,t,i,s)=>new D([e,t,i,s]),transformOBB3(e,t,i=t){let s;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],f=e[6],p=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(s=0;s<r;s+=4)n=t[s+0],A=t[s+1],o=t[s+2],i[s+0]=a*n+u*A+g*o+B,i[s+1]=l*n+d*A+m*o+y,i[s+2]=c*n+f*A+_*o+w,i[s+3]=h*n+p*A+b*o+v;return i},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 D(3),t=new D(3),i=new D(3);return s=>(e[0]=s[0],e[1]=s[1],e[2]=s[2],t[0]=s[3],t[1]=s[4],t[2]=s[5],V.subVec3(t,e,i),Math.abs(V.lenVec3(i)))})(),getAABB3DiagPoint:(()=>{const e=new D(3),t=new D(3),i=new D(3);return(s,r)=>{e[0]=s[0],e[1]=s[1],e[2]=s[2],t[0]=s[3],t[1]=s[4],t[2]=s[5];const n=V.subVec3(t,e,i),A=r[0]-s[0],o=s[3]-r[0],a=r[1]-s[1],l=s[4]-r[1],c=r[2]-s[2],h=s[5]-r[2];return n[0]+=A>o?A:o,n[1]+=a>l?a:l,n[2]+=c>h?c:h,Math.abs(V.lenVec3(n))}})(),getAABB3Area:e=>(e[3]-e[0])*(e[4]-e[1])*(e[5]-e[2]),getAABB3Center(e,t){const i=t||V.vec3();return i[0]=(e[0]+e[3])/2,i[1]=(e[1]+e[4])/2,i[2]=(e[2]+e[5])/2,i},getAABB2Center(e,t){const i=t||V.vec2();return i[0]=(e[2]+e[0])/2,i[1]=(e[3]+e[1])/2,i},collapseAABB3:(e=V.AABB3())=>(e[0]=V.MAX_DOUBLE,e[1]=V.MAX_DOUBLE,e[2]=V.MAX_DOUBLE,e[3]=V.MIN_DOUBLE,e[4]=V.MIN_DOUBLE,e[5]=V.MIN_DOUBLE,e),AABB3ToOBB3:(e,t=V.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 D(3);return(t,i,s)=>{i=i||V.AABB3();let r,n,A,o=V.MAX_DOUBLE,a=V.MAX_DOUBLE,l=V.MAX_DOUBLE,c=V.MIN_DOUBLE,h=V.MIN_DOUBLE,u=V.MIN_DOUBLE;for(let i=0,d=t.length;i<d;i+=3)s?(e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],V.decompressPosition(e,s,e),r=e[0],n=e[1],A=e[2]):(r=t[i+0],n=t[i+1],A=t[i+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 i[0]=o,i[1]=a,i[2]=l,i[3]=c,i[4]=h,i[5]=u,i}})(),OBB3ToAABB3(e,t=V.AABB3()){let i,s,r,n=V.MAX_DOUBLE,A=V.MAX_DOUBLE,o=V.MAX_DOUBLE,a=V.MIN_DOUBLE,l=V.MIN_DOUBLE,c=V.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t+=4)i=e[t+0],s=e[t+1],r=e[t+2],i<n&&(n=i),s<A&&(A=s),r<o&&(o=r),i>a&&(a=i),s>l&&(l=s),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=V.AABB3()){let i,s,r,n=V.MAX_DOUBLE,A=V.MAX_DOUBLE,o=V.MAX_DOUBLE,a=V.MIN_DOUBLE,l=V.MIN_DOUBLE,c=V.MIN_DOUBLE;for(let t=0,h=e.length;t<h;t++)i=e[t][0],s=e[t][1],r=e[t][2],i<n&&(n=i),s<A&&(A=s),r<o&&(o=r),i>a&&(a=i),s>l&&(l=s),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 D(3);return(t,i)=>{i=i||V.vec4();let s,r=0,n=0,A=0;const o=t.length;for(s=0;s<o;s++)r+=t[s][0],n+=t[s][1],A+=t[s][2];i[0]=r/o,i[1]=n/o,i[2]=A/o;let a,l=0;for(s=0;s<o;s++)a=Math.abs(V.lenVec3(V.subVec3(t[s],i,e))),a>l&&(l=a);return i[3]=l,i}})(),positions3ToSphere3:(()=>{const e=new D(3),t=new D(3);return(i,s)=>{s=s||V.vec4();let r,n=0,A=0,o=0;const a=i.length;let l=0;for(r=0;r<a;r+=3)n+=i[r],A+=i[r+1],o+=i[r+2];const c=a/3;let h;for(s[0]=n/c,s[1]=A/c,s[2]=o/c,r=0;r<a;r+=3)e[0]=i[r],e[1]=i[r+1],e[2]=i[r+2],h=Math.abs(V.lenVec3(V.subVec3(e,s,t))),h>l&&(l=h);return s[3]=l,s}})(),OBB3ToSphere3:(()=>{const e=new D(3),t=new D(3);return(i,s)=>{s=s||V.vec4();let r,n=0,A=0,o=0;const a=i.length,l=a/4;for(r=0;r<a;r+=4)n+=i[r+0],A+=i[r+1],o+=i[r+2];s[0]=n/l,s[1]=A/l,s[2]=o/l;let c,h=0;for(r=0;r<a;r+=4)e[0]=i[r+0],e[1]=i[r+1],e[2]=i[r+2],c=Math.abs(V.lenVec3(V.subVec3(e,s,t))),c>h&&(h=c);return s[3]=h,s}})(),getSphere3Center:(e,t=V.vec3())=>(t[0]=e[0],t[1]=e[1],t[2]=e[2],t),getPositionsCenter(e,t=V.vec3()){let i=0,s=0,r=0;for(var n=0,A=e.length;n<A;n+=3)i+=e[n+0],s+=e[n+1],r+=e[n+2];const o=e.length/3;return t[0]=i/o,t[1]=s/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 i,s,r,n=0,A=t.length;n<A;n+=3)i=t[n],s=t[n+1],r=t[n+2],e[0]>i&&(e[0]=i),e[1]>s&&(e[1]=s),e[2]>r&&(e[2]=r),e[3]<i&&(e[3]=i),e[4]<s&&(e[4]=s),e[5]<r&&(e[5]=r);return e},collapseAABB2:(e=V.AABB2())=>(e[0]=V.MAX_DOUBLE,e[1]=V.MAX_DOUBLE,e[2]=V.MIN_DOUBLE,e[3]=V.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,i){let s,r;e[0]>0?(s=e[0]*i[0],r=e[0]*i[3]):(s=e[0]*i[3],r=e[0]*i[0]),e[1]>0?(s+=e[1]*i[1],r+=e[1]*i[4]):(s+=e[1]*i[4],r+=e[1]*i[1]),e[2]>0?(s+=e[2]*i[2],r+=e[2]*i[5]):(s+=e[2]*i[5],r+=e[2]*i[2]);if(s<=-t&&r<=-t)return-1;return s>=-t&&r>=-t?1:0},OBB3ToAABB2(e,t=V.AABB2()){let i,s,r,n,A=V.MAX_DOUBLE,o=V.MAX_DOUBLE,a=V.MIN_DOUBLE,l=V.MIN_DOUBLE;for(let t=0,c=e.length;t<c;t+=4)i=e[t+0],s=e[t+1],r=e[t+3]||1,n=1/r,i*=n,s*=n,i<A&&(A=i),s<o&&(o=s),i>a&&(a=i),s>l&&(l=s);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,i,s=e){const r=.5*(e[0]+1),n=.5*(e[1]+1),A=.5*(e[2]+1),o=.5*(e[3]+1);return s[0]=Math.floor(r*t),s[1]=i-Math.floor(o*i),s[2]=Math.floor(A*t),s[3]=i-Math.floor(n*i),s},tangentQuadraticBezier:(e,t,i,s)=>2*(1-e)*(i-t)+2*e*(s-i),tangentQuadraticBezier3:(e,t,i,s,r)=>-3*t*(1-e)*(1-e)+3*i*(1-e)*(1-e)-6*e*i*(1-e)+6*e*s*(1-e)-3*e*e*s+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,i,s,r){const n=.5*(i-e),A=.5*(s-t),o=r*r;return(2*t-2*i+n+A)*(r*o)+(-3*t+3*i-2*n-A)*o+n*r+t},b2p0(e,t){const i=1-e;return i*i*t},b2p1:(e,t)=>2*(1-e)*e*t,b2p2:(e,t)=>e*e*t,b2(e,t,i,s){return this.b2p0(e,t)+this.b2p1(e,i)+this.b2p2(e,s)},b3p0(e,t){const i=1-e;return i*i*i*t},b3p1(e,t){const i=1-e;return 3*i*i*e*t},b3p2:(e,t)=>3*(1-e)*e*e*t,b3p3:(e,t)=>e*e*e*t,b3(e,t,i,s,r){return this.b3p0(e,t)+this.b3p1(e,i)+this.b3p2(e,s)+this.b3p3(e,r)},triangleNormal(e,t,i,s=V.vec3()){const r=t[0]-e[0],n=t[1]-e[1],A=t[2]-e[2],o=i[0]-e[0],a=i[1]-e[1],l=i[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?(s[0]=0,s[1]=0,s[2]=0):(s[0]=c/d,s[1]=h/d,s[2]=u/d),s},rayTriangleIntersect:(()=>{const e=new D(3),t=new D(3),i=new D(3),s=new D(3),r=new D(3);return(n,A,o,a,l,c)=>{c=c||V.vec3();const h=V.subVec3(a,o,e),u=V.subVec3(l,o,t),d=V.cross3Vec3(A,u,i),f=V.dotVec3(h,d);if(f<1e-6)return null;const p=V.subVec3(n,o,s),g=V.dotVec3(p,d);if(g<0||g>f)return null;const m=V.cross3Vec3(p,h,r),_=V.dotVec3(A,m);if(_<0||g+_>f)return null;const b=V.dotVec3(u,m)/f;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 D(3),t=new D(3),i=new D(3),s=new D(3);return(r,n,A,o,a,l)=>{l=l||V.vec3(),n=V.normalizeVec3(n,e);const c=V.subVec3(o,A,t),h=V.subVec3(a,A,i),u=V.cross3Vec3(c,h,s);V.normalizeVec3(u,u);const d=-V.dotVec3(A,u),f=-(V.dotVec3(r,u)+d)/V.dotVec3(n,u);return l[0]=r[0]+f*n[0],l[1]=r[1]+f*n[1],l[2]=r[2]+f*n[2],l}})(),cartesianToBarycentric:(()=>{const e=new D(3),t=new D(3),i=new D(3);return(s,r,n,A,o)=>{const a=V.subVec3(A,r,e),l=V.subVec3(n,r,t),c=V.subVec3(s,r,i),h=V.dotVec3(a,a),u=V.dotVec3(a,l),d=V.dotVec3(a,c),f=V.dotVec3(l,l),p=V.dotVec3(l,c),g=h*f-u*u;if(0===g)return null;const m=1/g,_=(f*d-u*p)*m,b=(h*p-u*d)*m;return o[0]=1-_-b,o[1]=b,o[2]=_,o}})(),barycentricInsideTriangle(e){const t=e[1],i=e[2];return i>=0&&t>=0&&i+t<1},barycentricToCartesian(e,t,i,s,r=V.vec3()){const n=e[0],A=e[1],o=e[2];return r[0]=t[0]*n+i[0]*A+s[0]*o,r[1]=t[1]*n+i[1]*A+s[1]*o,r[2]=t[2]*n+i[2]*A+s[2]*o,r},mergeVertices(e,t,i,s){const r={},n=[],A=[],o=t?[]:null,a=i?[]:null,l=[];let c,h,u,d;const f=1e4;let p,g,m=0;for(p=0,g=e.length;p<g;p+=3)c=e[p],h=e[p+1],u=e[p+2],d=`${Math.round(c*f)}_${Math.round(h*f)}_${Math.round(u*f)}`,void 0===r[d]&&(r[d]=A.length/3,A.push(c),A.push(h),A.push(u),t&&(o.push(t[p]),o.push(t[p+1]),o.push(t[p+2])),i&&(a.push(i[m]),a.push(i[m+1]))),n[p/3]=r[d],m+=2;for(p=0,g=s.length;p<g;p++)l[p]=n[s[p]];const _={positions:A,indices:l};return o&&(_.normals=o),a&&(_.uv=a),_},buildNormals:(()=>{const e=new D(3),t=new D(3),i=new D(3),s=new D(3),r=new D(3),n=new D(3);return(A,o,a)=>{let l,c;const h=new Array(A.length/3);let u,d,f,p,g,m,_;for(l=0,c=o.length;l<c;l+=3){u=o[l],d=o[l+1],f=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],i[0]=A[3*f],i[1]=A[3*f+1],i[2]=A[3*f+2],V.subVec3(t,e,s),V.subVec3(i,e,r);const a=V.vec3();V.normalizeVec3(V.cross3Vec3(s,r,n),a),h[u]||(h[u]=[]),h[d]||(h[d]=[]),h[f]||(h[f]=[]),h[u].push(a),h[d].push(a),h[f].push(a)}for(a=a&&a.length===A.length?a:new Float32Array(A.length),l=0,c=h.length;l<c;l++){p=h[l].length,g=0,m=0,_=0;for(let e=0;e<p;e++)g+=h[l][e][0],m+=h[l][e][1],_+=h[l][e][2];a[3*l]=g/p,a[3*l+1]=m/p,a[3*l+2]=_/p}return a}})(),buildTangents:(()=>{const e=new D(3),t=new D(3),i=new D(3),s=new D(3),r=new D(3),n=new D(3),A=new D(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),f=l.subarray(2*u,2*u+2);u=a[h+1];const p=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=V.subVec3(p,d,e),B=V.subVec3(m,d,t),y=V.subVec2(g,f,i),w=V.subVec2(_,f,s),v=1/(y[0]*w[1]-y[1]*w[0]),C=V.mulVec3Scalar(V.subVec3(V.mulVec3Scalar(b,w[1],r),V.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,i){const s=t.length,r=i?new Uint16Array(9*s):new Float32Array(9*s),n=new Uint8Array(12*s);let A,o,a,l,c,h,u=0,d=0,f=0;for(let i=0;i<s;i+=3)h=u>>24&255,c=u>>16&255,l=u>>8&255,a=255&u,o=t[i],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[f++]=a,n[f++]=l,n[f++]=c,n[f++]=h,o=t[i+1],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[f++]=a,n[f++]=l,n[f++]=c,n[f++]=h,o=t[i+2],A=3*o,r[d++]=e[A],r[d++]=e[A+1],r[d++]=e[A+2],n[f++]=a,n[f++]=l,n[f++]=c,n[f++]=h,u++;return{positions:r,colors:n}},faceToVertexNormals(e,t,i={}){const s=i.smoothNormalsAngleThreshold||20,r={},n=[],A={};let o,a,l,c,h;const u=1e4;let d,f,p,g,m,_;for(f=0,g=e.length;f<g;f+=3){d=f/3,a=e[f],l=e[f+1],c=e[f+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 i=V.normalizeVec3([t[f],t[f+1],t[f+2]]);n[d]=i,o=V.vec4([i[0],i[1],i[2],1]),A[d]=o}for(h in r)if(r.hasOwnProperty(h)){const e=r[h],t=e.length;for(f=0;f<t;f++){const i=e[f];for(o=A[i],p=0;p<t;p++){if(f===p)continue;const t=e[p];m=n[i],_=n[t];Math.abs(V.angleVec3(m,_)/V.DEGTORAD)<s&&(o[0]+=_[0],o[1]+=_[1],o[2]+=_[2],o[3]+=1)}}}for(f=0,g=t.length;f<g;f+=3)o=A[f/3],t[f+0]=o[0]/o[3],t[f+1]=o[1]/o[3],t[f+2]=o[2]/o[3]},transformRay:(()=>{const e=new D(4),t=new D(4);return(i,s,r,n,A)=>{e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=1,V.transformVec4(i,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],V.transformVec3(i,e,t),V.normalizeVec3(t),A[0]=t[0],A[1]=t[1],A[2]=t[2]}})(),canvasPosToWorldRay:(()=>{const e=new D(16),t=new D(4),i=new D(4),s=(t,i,s,r,n)=>{n[0]=t,n[1]=i,n[2]=s,n[3]=1,V.transformVec4(e,n,n),r||V.mulVec4Scalar(n,1/n[3])};return(r,n,A,o,a,l,c)=>{const h="ortho"===o;V.mulMat4(A,n,e),V.inverseMat4(e,e);const u=2*a[0]/r.clientWidth-1,d=1-2*a[1]/r.clientHeight;s(u,d,-1,h,t),s(u,d,1,h,i),l[0]=t[0],l[1]=t[1],l[2]=t[2],V.subVec3(i,t,c),V.normalizeVec3(c)}})(),canvasPosToLocalRay:(()=>{const e=new D(3),t=new D(3);return(i,s,r,n,A,o,a,l)=>{V.canvasPosToWorldRay(i,s,r,n,o,e,t),V.worldRayToLocalRay(A,e,t,a,l)}})(),worldRayToLocalRay:(()=>{const e=new D(16),t=new D(4),i=new D(4);return(s,r,n,A,o)=>{const a=V.inverseMat4(s,e);t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,V.transformVec4(a,t,i),A[0]=i[0],A[1]=i[1],A[2]=i[2],V.transformVec3(a,n,o)}})(),buildKDTree:(()=>{const e=new Float32Array;function t(i,s,r,n){const A=new D(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=i.length;a<l;++a){var c=3*i[a];for(let e=0;e<3;++e){const t=3*s[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(i.length<20||n>10)return o.triangles=i,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(i.length);let f=0;const p=new Array(i.length);let g=0;for(a=0,l=i.length;a<l;++a){const e=s[c=3*i[a]],t=3*s[c+1],n=3*s[c+2];r[3*e+h]<=u||r[t+h]<=u||r[n+h]<=u?d[f++]=i[a]:p[g++]=i[a]}return d.length=f,p.length=g,o.left=t(d,s,r,n+1),o.right=t(p,s,r,n+1),o}return(e,i)=>{const s=e.length/3,r=new Array(s);for(let e=0;e<s;++e)r[e]=e;return t(r,e,i,0)}})(),decompressPosition(e,t,i){(i=i||e)[0]=e[0]*t[0]+t[12],i[1]=e[1]*t[5]+t[13],i[2]=e[2]*t[10]+t[14]},decompressPositions(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[12],i[s+1]=e[s+1]*t[5]+t[13],i[s+2]=e[s+2]*t[10]+t[14];return i},decompressUV(e,t,i){i[0]=e[0]*t[0]+t[6],i[1]=e[1]*t[4]+t[7]},decompressUVs(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[6],i[s+1]=e[s+1]*t[4]+t[7];return i},octDecodeVec2(e,t){let i=e[0],s=e[1];i=(2*i+1)/255,s=(2*s+1)/255;const r=1-Math.abs(i)-Math.abs(s);r<0&&(i=(1-Math.abs(s))*(i>=0?1:-1),s=(1-Math.abs(i))*(s>=0?1:-1));const n=Math.sqrt(i*i+s*s+r*r);return t[0]=i/n,t[1]=s/n,t[2]=r/n,t},octDecodeVec2s(e,t){for(let i=0,s=0,r=e.length;i<r;i+=2){let r=e[i+0],n=e[i+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[s+0]=r/o,t[s+1]=n/o,t[s+2]=A/o,s+=3}return t}};V.buildEdgeIndices=function(){const e=[],t=[],i=[],s=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=V.vec3(),c=V.vec3(),h=V.vec3(),u=V.vec3(),d=V.vec3(),f=V.vec3(),p=V.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,f=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]=f/3,e[f++]=o,e[f++]=a,e[f++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)s[u]=t[n[u]],i[s[u]]=n[u]}(g,m),function(t,i){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*s[g],m=3*s[g+1],_=3*s[g+2];i?(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],V.decompressPosition(A,i,l),V.decompressPosition(o,i,c),V.decompressPosition(a,i,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]),V.subVec3(h,c,u),V.subVec3(l,c,d),V.cross3Vec3(u,d,f),V.normalizeVec3(f,p);const b=r[n]||(r[n]={normal:V.vec3()});b.normal[0]=p[0],b.normal[1]=p[1],b.normal[2]=p[2],n++}}(m.length,_);const B=[],y=Math.cos(V.DEGTORAD*b),w={};let v,C,M,E,F,U,x,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let i=0;i<3;i++)v=s[e+i],C=s[e+(i+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)U=w[F],void 0!==U.face2&&(x=r[U.face1].normal,I=r[U.face2].normal,T=V.dotVec3(x,I),T>y)||(P=i[U.index1],S=i[U.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}(),V.planeClipsPositions3=function(e,t,i,s=3){for(let r=0,n=i.length;r<n;r+=s){if(k[0]=i[r+0]-e[0],k[1]=i[r+1]-e[1],k[2]=i[r+2]-e[2],k[0]*t[0]+k[1]*t[1]+k[2]*t[2]<0)return!0}return!1},V.planeIntersectsAABB3=(e,t)=>{const i=[t[0],t[1],t[2]],s=[t[3],t[4],t[5]],r=[[i[0],i[1],i[2]],[s[0],i[1],i[2]],[i[0],s[1],i[2]],[s[0],s[1],i[2]],[i[0],i[1],s[2]],[s[0],i[1],s[2]],[i[0],s[1],s[2]],[s[0],s[1],s[2]]];let n=!1,A=!1;for(const t of r){const i=e.dist+V.dotVec3(e.dir,t);if(i>0&&(n=!0),i<0&&(A=!0),n&&A)return!0}return!1},V.makeSectionPlaneSlicer=function(){const e=V.vec2(),t=V.vec2(),i=V.vec2(),s=V.vec2(),r=V.vec3(),n=V.vec3(),A=V.vec3();V.vec3();const a=[V.vec3(),V.vec3(),V.vec3()],l=[null,null,null],c=[null,null,null],h=[null,null,null],u=[1,0,0],d=[0,1,0],f=[0,0,1],p=function(){const e=V.vec3();return(t,i)=>V.sqLenVec3(V.subVec3(t,i,e))}(),g=e=>{const t=[];for(let i=0;i<e;++i)t.push(i);return t},m=(e,t,i)=>(i[1]-e[1])*(t[0]-e[0])>(t[1]-e[1])*(i[0]-e[0]);return function(_){const b=V.vec3ApplyQuaternion(_.quaternion,u,V.vec3()),B=V.vec3ApplyQuaternion(_.quaternion,d,V.vec3()),y=V.vec3ApplyQuaternion(_.quaternion,f,V.vec3());return function(u,d={}){const f=V.subVec3(u.origin,_.pos,V.vec3()),w=V.dotVec3(y,f),v=[],C=[null],M=(e,t)=>{const i=C.length,s=new Float64Array(5);return s.set(e),t&&(V.addVec3(f,e,r),s[3]=-V.dotVec3(b,r),s[4]=V.dotVec3(B,r)),C.push(s),i},E=(e,t)=>{const i=C[e];return t[0]=i[3],t[1]=i[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],i),n=E(l[t],s);if(m(A,r,n)!==m(h,r,n)&&m(A,h,r)!==m(A,h,n))return!1;const[a,d]=r,[f,p]=n,g=o-a,_=c-d,b=f-a,B=p-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!=p>c&&g<_*b/B&&(u=!u)}if(!u)return!1}return!0},U={indices:[],normals:[]},x=!d.onlyPosSliceWithUV&&{indices:[],normals:[]},I=(e,t,i)=>{if(e){const s=C[t[0]];i||=V.normalizeVec3(V.cross3Vec3(V.subVec3(C[t[1]],s,r),V.subVec3(C[t[2]],s,n),r),r);for(let s=0;s<3;++s)e.indices.push(t[s]),e.normals.push(i[0],i[1],i[2])}},T=(e,t)=>{const i=3*u.indices[e];return t[0]=u.positions[i+0],t[1]=u.positions[i+1],t[2]=u.positions[i+2],t};for(let e=0;e<u.indices.length;e+=3){const t=T(e+0,a[0]),i=T(e+1,a[1]),s=T(e+2,a[2]);if(V.compareVec3(t,i)||V.compareVec3(i,s)||V.compareVec3(s,t))continue;const n=w+V.dotVec3(y,t),A=w+V.dotVec3(y,i),o=w+V.dotVec3(y,s);if(0!==n||0!==A||0!==o){const e=n*A<=0&&M(V.lerpVec3(n/(n-A),0,1,t,i,r),!0),a=A*o<=0&&M(V.lerpVec3(A/(A-o),0,1,i,s,r),!0),u=o*n<=0&&M(V.lerpVec3(o/(o-n),0,1,s,t,r),!0),f=!d.onlyPosSliceWithUV&&c;if(f&&(f[0]=M(t),f[1]=M(i),f[2]=M(s)),e?a||u:a&&u){if(v.push(e?[e,a||u]:[a,u]),f)if(0===n&&0===A)I(o>0?U:x,f);else if(0===n&&0===o)I(A>0?U:x,f);else if(0===A&&0===o)I(n>0?U:x,f);else{const t=(e?n:A)>0,i=t?U:x,s=t?x:U,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(i,[f[o[0]],r[o[0]],f[o[2]]]),I(i,[r[o[0]],r[o[1]],f[o[2]]]),I(s,[r[o[0]],f[o[1]],r[o[1]]])):(I(i,[f[o[0]],r[o[0]],r[o[2]]]),I(s,[r[o[0]],f[o[1]],f[o[2]]]),I(s,[r[o[0]],f[o[2]],r[o[2]]]))}}else f&&(n>=0&&A>=0&&o>=0?I(U,f):n<=0&&A<=0&&o<=0&&I(x,f))}}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]],i={distSq:p(C[e[0]],t),idx:-1,side:-1};if(v.forEach(((e,s)=>{const r=p(C[e[0]],t),n=p(C[e[1]],t),A=Math.min(r,n);i.distSq>A&&(i.distSq=A,i.idx=s,i.side=n<r?1:0)})),!(i.distSq<1e-20)){P.pop();break}{const s=i.idx>=0&&v[i.idx];if(C[s?s[i.side]:e[0]]=t,!s)break;{v.splice(i.idx,1);const t=s[1-i.side];if(!(p(C[t],C[e[0]])>1e-20))break;e.push(t)}}}}const S=P.filter((e=>e.length>2)).map(((i,s)=>{let r=0;const n=V.collapseAABB2(V.AABB2());for(let s=0;s<i.length;s++)E(i[s],e),V.expandAABB2Point2(n,e),E(i[(s+1)%i.length],t),r+=e[0]*t[1]-t[0]*e[1];return{boundingBox:n,doubleArea:Math.abs(r),endPoints:i}})).sort(((e,t)=>t.doubleArea-e.doubleArea));for(;S.length>0;){const t=[],i=[],s=s=>s.endPoints.forEach((s=>{E(s,e),t.push(e[0],e[1]),i.push(s)})),r=S.shift();s(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,s(e),a.push(e),S.splice(c,1)):++c}const h=o(t,a.map((e=>e.index)));for(let e=0;e<h.length;e+=3){const t=l;t[0]=i[h[e+0]],t[1]=i[h[e+1]],t[2]=i[h[e+2]];const s=C[t[0]];V.subVec3(C[t[1]],s,n),V.subVec3(C[t[2]],s,A),V.normalizeVec3(V.cross3Vec3(n,A,A),A);const r=V.dotVec3(A,y)<=0;I(r?U:x,t,A);const o=t[0];t[0]=t[2],t[2]=o,I(r?x:U,t,V.negateVec3(A,A))}}const D=e=>e&&e.indices.length>0&&function(){const t=[],i=d.onlyPosSliceWithUV&&[];return e.indices.forEach((e=>{const s=C[e];t.push(s[0],s[1],s[2]),i&&i.push(s[3],s[4])})),{indices:g(e.indices.length),positions:t,normals:e.normals,uv:i}}();return{pos:D(U),neg:D(x)}}}}();const L=new Float32Array(3);class H{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 i=e.objects[t];this._insertEntity(this._root,i,1)}this._needsRebuild=!1}_insertEntity(e,t,i){const s=t.aabb;if(i>=this._maxTreeDepth)return e.entities=e.entities||[],void e.entities.push(t);if(e.left&&V.containsAABB3(e.left.aabb,s))return void this._insertEntity(e.left,t,i+1);if(e.right&&V.containsAABB3(e.right.aabb,s))return void this._insertEntity(e.right,t,i+1);const r=e.aabb;L[0]=r[3]-r[0],L[1]=r[4]-r[1],L[2]=r[5]-r[2];let n=0;if(L[1]>L[n]&&(n=1),L[2]>L[n]&&(n=2),!e.left){const A=r.slice();if(A[n+3]=(r[n]+r[n+3])/2,e.left={aabb:A},V.containsAABB3(A,s))return void this._insertEntity(e.left,t,i+1)}if(!e.right){const A=r.slice();if(A[n]=(r[n]+r[n+3])/2,e.right={aabb:A},V.containsAABB3(A,s))return void this._insertEntity(e.right,t,i+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}}class N{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 G={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 j=[["0",10],["A",26],["a",26],["_",1],["$",1]].map((function(e){for(var t=[],i=e[0].charCodeAt(0),s=i+e[1],r=i;r<s;++r)t.push(r);return String.fromCharCode.apply(null,t)})).join("");function W(e,t){return(t&&4!==t?[0,6]:[0,6,12,18]).map((function(t){return j.substr(parseInt(e/(1<<t))%64,1)})).reverse().join("")}const z=function(){for(var e={},t=window.location.search.substring(1).split("&"),i=0;i<t.length;i++){var s=t[i].split("=");if(void 0===e[s[0]])e[s[0]]=decodeURIComponent(s[1]);else if("string"==typeof e[s[0]]){var r=[e[s[0]],decodeURIComponent(s[1])];e[s[0]]=r}else e[s[0]].push(decodeURIComponent(s[1]))}return e}();const X={xmlToJson:function e(t,i){if(t.nodeType===t.TEXT_NODE){var s=t.nodeValue;if(null===s.match(/^\s+$/))return s}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[i[A.nodeName]||A.nodeName]=A.nodeValue}for(var o=0;o<t.childNodes.length;o++){(n=e(t.childNodes[o],i))&&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 W(t[0],2)+[1,4,7,10,13].map((function(e){return W((t[e]<<16)+(t[e+1]<<8)+t[e+2])})).join("")},findNodeOfType:function(e,t){var i=[],s=function(e){e.type===t&&i.push(e),(e.children||[]).forEach((function(e){s(e)}))};return s(e),i},timeout:function(e){return new Promise((function(t,i){setTimeout(t,e)}))},httpRequest:function(e){return new Promise((function(t,i){var s=new XMLHttpRequest;s.open(e.method||"GET",e.url,!0),s.onload=function(e){4===s.readyState&&(200===s.status?t(s.responseXML):i(s.statusText))},s.send(null)}))},loadJSON:function(e,t,i){var s=e=>{};t=t||s,i=i||s;var r=new XMLHttpRequest;r.overrideMimeType("application/json"),r.open("GET",e,!0),r.addEventListener("load",(function(e){var s=e.target.response;if(200===this.status){var r;try{r=JSON.parse(s)}catch(e){i(`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(s))}catch(e){i(`utils.loadJSON(): Failed to parse JSON response - ${e}`)}}else i(e)}),!1),r.addEventListener("error",(function(e){i(e)}),!1),r.send(null)},loadArraybuffer:function(e,t,i){var s=e=>{};t=t||s,i=i||s;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),i=new Uint8Array(e);for(var A=0;A<n.length;A++)i[A]=n.charCodeAt(A);ie.scheduleTask((()=>{t(e)}))}catch(e){ie.scheduleTask((()=>{i(e)}))}}else{const s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i("loadArrayBuffer error : "+s.response))},s.send(null)}},queryString:z,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 X.isString(e)||X.isNumeric(e)},isSameComponent:function(e,t){return!(!e||!t)&&(X.isNumeric(e)||X.isString(e)?`${e}`:e.id)===(X.isNumeric(t)||X.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 X.apply(e,{})},apply:function(e,t){for(const i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},apply2:function(e,t){for(const i in e)e.hasOwnProperty(i)&&void 0!==e[i]&&null!==e[i]&&(t[i]=e[i]);return t},applyIf:function(e,t){for(const i in e)e.hasOwnProperty(i)&&(void 0!==t[i]&&null!==t[i]||(t[i]=e[i]));return t},isEmptyObject:function(e){for(const t in e)if(e.hasOwnProperty(t))return!1;return!0},inQuotes:function(e){return X.isNumeric(e)?`${e}`:`'${e}'`},concat:function(e,t){const i=new e.constructor(e.length+t.length);return i.set(e),i.set(t,e.length),i},flattenParentChildHierarchy:function(e){var t=[];return function e(i){i.id=i.uuid,delete i.oid,t.push(i);var s=i.children;if(s)for(var r=0,n=s.length;r<n;r++){s[r].parent=i.id,e(s[r])}i.children=[]}(e),t}},K={},Z=new e,J=new N,Y={sceneId:null,time:null,startTime:null,prevTime:null,deltaTime:null},$=[];let q,ee=0,te=0;const ie=new function(){this.version="1.0.0",this.scenes={},this._superTypes={},this._addScene=function(e){if(e.id){if(ie.scenes[e.id])return void console.error(`[ERROR] Scene ${X.inQuotes(e.id)} already exists`)}else e.id=Z.addItem({});ie.scenes[e.id]=e;const t=e.ticksPerOcclusionTest,i=e.ticksPerRender;K[e.id]={ticksPerOcclusionTest:t,ticksPerRender:i,renderCountdown:i},G.components.scenes++,e.once("destroyed",(()=>{Z.removeItem(e.id),delete ie.scenes[e.id],delete K[e.id],G.components.scenes--}))},this.clear=function(){let e;for(const t in ie.scenes)ie.scenes.hasOwnProperty(t)&&(e=ie.scenes[t],"default.scene"===t?e.clear():(e.destroy(),delete ie.scenes[e.id]))},this.scheduleTask=function(e,t=null){J.push(e),J.push(t)},this.runTasks=function(e=-1){let t,i,s=(new Date).getTime(),r=0;for(;J.length>0&&(e<0||s<e);)t=J.shift(),i=J.shift(),i?t.call(i):t(),s=(new Date).getTime(),r++;return r},this.getNumTasks=function(){return J.length}},se=function(){let e=Date.now();if(q=e-ee,ee>0&&q>0){var t=1e3/q;te+=t,$.push(t),$.length>=30&&(te-=$.shift()),G.frame.fps=Math.round(te/$.length)}for(let e in ie.scenes)ie.scenes[e].compile();ne(e),ee=e};!function(e,t){let i=Date.now()+t;(function s(){const r=Date.now()-i;e(),i+=t,setTimeout(s,Math.max(0,t-r))})()}((()=>{se()}),100);const re=function(){let e=Date.now();if(q=e-ee,ee>0&&q>0){var t=1e3/q;te+=t,$.push(t),$.length>=30&&(te-=$.shift()),G.frame.fps=Math.round(te/$.length)}ne(e),function(e){for(var t in Y.time=e,ie.scenes)if(ie.scenes.hasOwnProperty(t)){var i=ie.scenes[t];Y.sceneId=t,Y.startTime=i.startTime,Y.deltaTime=null!=Y.prevTime?Y.time-Y.prevTime:0,i.fire("tick",Y,!0)}Y.prevTime=e}(e),function(){const e=ie.scenes,t=!1;let i,s,r,n,A;for(A in e)e.hasOwnProperty(A)&&(i=e[A],s=K[A],s||(s=K[A]={}),r=i.ticksPerOcclusionTest,s.ticksPerOcclusionTest!==r&&(s.ticksPerOcclusionTest=r,s.renderCountdown=r),--i.occlusionTestCountdown<=0&&(i.doOcclusionTest(),i.occlusionTestCountdown=r),n=i.ticksPerRender,s.ticksPerRender!==n&&(s.ticksPerRender=n,s.renderCountdown=n),0==--s.renderCountdown&&(i.render(t),s.renderCountdown=n))}(),void 0!==window.requestPostAnimationFrame?window.requestPostAnimationFrame(se):requestAnimationFrame(re)};function ne(e){const t=ie.runTasks(e+10),i=ie.getNumTasks();G.frame.tasksRun=t,G.frame.tasksScheduled=i,G.frame.tasksBudget=10}re();class Ae{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 Ae))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,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={},this._eventSubsNum={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];let r;if(s)for(const i in s)s.hasOwnProperty(i)&&(r=s[i],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,i,s){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:i,scope:s||this},this._subIdEvents[n]=t;const A=this._events[t];return void 0!==A&&i.call(s||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 i=this._eventSubs[t];i&&(delete i[e],this._eventSubsNum[t]--),this._subIdMap.removeItem(e)}}once(e,t,i){const s=this,r=this.on(e,(function(e){s.off(r),t.call(i||this,e)}),i)}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+" "+X.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 i=e.component;const s=e.sceneDefault,r=e.sceneSingleton,n=e.type,A=e.on,o=!1!==e.recompiles;if(i&&(X.isNumeric(i)||X.isString(i))){const e=i;if(i=this.scene.components[e],!i)return void this.error("Component not found: "+X.inQuotes(e))}if(!i)if(!0===r){const e=this.scene.types[n];for(const t in e)if(e.hasOwnProperty){i=e[t];break}if(!i)return this.error("Scene has no default component for '"+t+"'"),null}else if(!0===s&&(i=this.scene[t],!i))return this.error("Scene has no default component for '"+t+"'"),null;if(i){if(i.scene.id!==this.scene.id)return void this.error("Not in same scene: "+i.type+" "+X.inQuotes(i.id));if(n&&!i.isType(n))return void this.error("Expected a "+n+" type or subtype: "+i.type+" "+X.inQuotes(i.id))}this._attachments||(this._attachments={});const a=this._attached[t];let l,c,h;if(a){if(i&&a.id===i.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 s=e.params.onDetached;s&&(X.isFunction(s)?s(a):s.scope?s.callback.call(s.scope,a):s.callback(a)),e.managingLifecycle&&a.destroy()}if(i){const s={params:e,component:i,subs:[],managingLifecycle:false};s.subs.push(i.once("destroyed",(function(){s.params.component=null,this._attach(s.params)}),this)),o&&s.subs.push(i.on("dirty",(function(){this.fire("dirty",this)}),this)),this._attached[t]=i,this._attachments[i.id]=s;const r=e.onAttached;if(r&&(X.isFunction(r)?r(i):r.scope?r.callback.call(r.scope,i):r.callback(i)),A){let e,t,r,n;for(e in A)if(A.hasOwnProperty(e)){if(t=A[e],X.isFunction(t)?(r=t,n=null):(r=t.callback,n=t.scope),!r)continue;s.subs.push(i.on(e,r,n))}}}return o&&this.fire("dirty",this),this.fire(t,i),i}_checkComponent(e,t){if(!t.isComponent){if(!X.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(!X.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 i=0,s=e.length;i<s;i++)if(e[i]===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():ie.scheduleTask(this._doUpdate,this))}_doUpdate(){this._updateScheduled&&(this._updateScheduled=!1,this._update&&this._update())}scheduleTask(e){ie.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,i,s,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],i=t.component,s=t.subs,r=0,n=s.length;r<n;r++)i.off(s[r]);t.managingLifecycle&&i.destroy()}if(this._ownedComponents)for(e in this._ownedComponents)this._ownedComponents.hasOwnProperty(e)&&(i=this._ownedComponents[e],i.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 oe=V.vec3(),ae=V.vec3(),le=V.mat4();class ce{constructor(){this.normal=V.vec3(),this.offset=0,this.testVertex=V.vec3()}set(e,t,i,s){const r=1/Math.sqrt(e*e+t*t+i*i);this.normal[0]=e*r,this.normal[1]=t*r,this.normal[2]=i*r,this.offset=s*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 he{constructor(){this.planes=[new ce,new ce,new ce,new ce,new ce,new ce]}}function ue(e,t,i){const s=V.mulMat4(i,t,le),r=s[0],n=s[1],A=s[2],o=s[3],a=s[4],l=s[5],c=s[6],h=s[7],u=s[8],d=s[9],f=s[10],p=s[11],g=s[12],m=s[13],_=s[14],b=s[15];e.planes[0].set(o-r,h-a,p-u,b-g),e.planes[1].set(o+r,h+a,p+u,b+g),e.planes[2].set(o-n,h-l,p-d,b-m),e.planes[3].set(o+n,h+l,p+d,b+m),e.planes[4].set(o-A,h-c,p-f,b-_),e.planes[5].set(o+A,h+c,p+f,b+_)}function de(e,t){let i=he.INSIDE;const s=oe,r=ae;s[0]=t[0],s[1]=t[1],s[2]=t[2],r[0]=t[3],r[1]=t[4],r[2]=t[5];const n=[s,r];for(let t=0;t<6;++t){const s=e.planes[t];if(s.normal[0]*n[s.testVertex[0]][0]+s.normal[1]*n[s.testVertex[1]][1]+s.normal[2]*n[s.testVertex[2]][2]+s.offset<0)return he.OUTSIDE;s.normal[0]*n[1-s.testVertex[0]][0]+s.normal[1]*n[1-s.testVertex[1]][1]+s.normal[2]*n[1-s.testVertex[2]][2]+s.offset<0&&(i=he.INTERSECT)}return i}he.INSIDE=0,he.INTERSECT=1,he.OUTSIDE=2;class fe extends Ae{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=V.vec2(),this._canvasMarqueeCorner2=V.vec2(),this._canvasMarquee=V.AABB2(),this._marqueeFrustum=new he,this._marqueeFrustumProjMat=V.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!==fe.PICK_MODE_INSIDE&&e!==fe.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===fe.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=(i,s=he.INTERSECT)=>{if(s===he.INTERSECT&&(s=de(this._marqueeFrustum,i.aabb)),s!==he.OUTSIDE){if(i.entities){const t=i.entities;for(let i=0,s=t.length;i<s;i++){const s=t[i];if(!s.visible)continue;const r=s.aabb;if(this._pickMode===fe.PICK_MODE_INSIDE){de(this._marqueeFrustum,r)===he.INSIDE&&e.push(s.id)}else{de(this._marqueeFrustum,r)!==he.OUTSIDE&&e.push(s.id)}}}i.left&&t(i.left,s),i.right&&t(i.right,s)}};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,i=e.clientHeight,s=e.clientLeft,r=e.clientTop,n=2/t,A=2/i,o=e.clientHeight/e.clientWidth,a=(this._canvasMarquee[0]-s)*n-1,l=(this._canvasMarquee[2]-s)*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);V.frustumMat4(a,l,c*o,h*o,u,1e4,this._marqueeFrustumProjMat),ue(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)}}fe.PICK_MODE_INTERSECTS=0,fe.PICK_MODE_INSIDE=1;class pe extends Ae{constructor(e){super(e.marqueePicker,e);const t=e.marqueePicker,i=t.viewer.scene.canvas.canvas;let s,r,n,A,o,a,l,c=!1,h=!1,u=!1;i.addEventListener("mousedown",(e=>{this.getActive()&&0===e.button&&(l=setTimeout((function(){const n=t.viewer.scene.input;n.keyDown[n.KEY_CTRL]||t.clear(),s=e.pageX,r=e.pageY,o=e.offsetX,t.setMarqueeCorner1([s,r]),c=!0,t.viewer.cameraControl.pointerEnabled=!1,t.setMarqueeVisible(!0),i.style.cursor="crosshair"}),400),h=!0)})),i.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 i=Math.abs(n-s),o=Math.abs(A-r);c=!1,t.viewer.cameraControl.pointerEnabled=!0,u&&(u=!1),(i>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),i.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?fe.PICK_MODE_INSIDE:fe.PICK_MODE_INTERSECTS)))}))}setActive(e){this._active!==e&&(this._active=e,this.fire("active",this._active))}getActive(){return this._active}destroy(){}}class ge{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 i;const s=e=>{if(!this._running)return;i||(i=e);const r=e-i,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(s)};this._running=!0,requestAnimationFrame(s),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 me{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 i=this._messages[this._locale];if(!i)return null;const s=_e(e,i);return s?t?be(s,t):s:null}translatePlurals(e,t,i){const s=this._messages[this._locale];if(!s)return null;let r=_e(e,s);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=be(r,[t]),i&&(r=be(r,i)),r):null}fire(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];if(s)for(const e in s)if(s.hasOwnProperty(e)){s[e].callback(t)}}on(t,i){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let s=this._eventSubs[t];s||(s={},this._eventSubs[t]=s);const r=this._eventSubIDMap.addItem();s[r]={callback:i},this._eventSubEvents[r]=t;const n=this._events[t];return void 0!==n&&i(n),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}function _e(e,t){if(t[e])return t[e];const i=e.split(".");let s=t;for(let e=0,t=i.length;s&&e<t;e++){s=s[i[e]]}return s}function be(e,t=[]){return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,i){return"{{"===e?"{":"}}"===e?"}":t[i]}))}class Be extends Ae{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 i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),n=this.getPoint(s),A=V.subVec3(n,r,[]);return V.normalizeVec3(A,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}_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,i,s=[],r=this.getPoint(0),n=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),n+=V.lenVec3(V.subVec3(t,r,[])),s.push(n),r=t;return this.cacheArcLengths=s,s}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var i,s=this._getLengths(),r=0,n=s.length;i=t||e*s[n-1];for(var A,o=0,a=n-1;o<=a;)if((A=s[r=Math.floor(o+(a-o)/2)]-i)<0)o=r+1;else{if(!(A>0)){a=r;break}a=r-1}if(s[r=a]===i)return r/(n-1);var l=s[r];return(r+(i-l)/(s[r+1]-l))/(n-1)}}class ye extends Be{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 i=(t.length-1)*e,s=Math.floor(i),r=i-s,n=t[0===s?s:s-1],A=t[s],o=t[s>t.length-2?t.length-1:s+1],a=t[s>t.length-3?t.length-1:s+2],l=V.vec3();return l[0]=V.catmullRomInterpolate(n[0],A[0],o[0],a[0],r),l[1]=V.catmullRomInterpolate(n[1],A[1],o[1],a[1],r),l[2]=V.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 we=V.vec3();class ve extends Ae{get type(){return"CameraPath"}constructor(e,t={}){super(e,t),this._frames=[],this._eyeCurve=new ye(this),this._lookCurve=new ye(this),this._upCurve=new ye(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,i,s){const r={t:e,eye:t.slice(0),look:i.slice(0),up:s.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 i=0,s=e.length;i<s;i++)t=e[i],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,we),t.look=this._lookCurve.getPoint(e,we),t.up=this._upCurve.getPoint(e,we)}sampleFrame(e,t,i,s){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,s)}smoothFrameTimes(e){if(0===this._frames.length)return;const t=V.vec3();var i=0;this._frames[0].t=0;const s=[];for(let e=1,n=this._frames.length;e<n;e++){var r=V.lenVec3(V.subVec3(this._frames[e].eye,this._frames[e-1].eye,t));s[e]=r,i+=r}for(let t=1,r=this._frames.length;t<r;t++){const r=s[t]/i*e;this._frames[t].t=this._frames[t-1].t+r}}clearFrames(){this._frames=[],this._eyeCurve.points=[],this._lookCurve.points=[],this._upCurve.points=[]}}const Ce=V.vec3(),Me=V.vec3(),Ee=V.vec3(),Fe=V.vec3(),Ue=V.vec3();class xe extends Ae{get type(){return"CameraFlightAnimation"}constructor(e,t={}){super(e,t),this._look1=V.vec3(),this._eye1=V.vec3(),this._up1=V.vec3(),this._look2=V.vec3(),this._eye2=V.vec3(),this._up2=V.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,i){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=i;const s=this.scene.camera,r=!!e.projection&&e.projection!==s.projection;let n,A,o,a,l;if(this._eye1[0]=s.eye[0],this._eye1[1]=s.eye[1],this._eye1[2]=s.eye[2],this._look1[0]=s.look[0],this._look1[1]=s.look[1],this._look1[2]=s.look[2],this._up1[0]=s.up[0],this._up1[1]=s.up[1],this._up1[2]=s.up[2],this._orthoScale1=s.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 s=e;if((X.isNumeric(s)||X.isString(s))&&(l=s,s=this.scene.components[l],!s))return this.error("Component not found: "+X.inQuotes(l)),void(t&&(i?t.call(i):t()));r||(n=s.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=V.getAABB3Center(n);this._look2=c||t;const i=V.subVec3(this._eye1,this._look1,Ce),s=V.normalizeVec3(i),r=c?V.getAABB3DiagPoint(n,c):V.getAABB3Diag(n),A=e.fitFOV||this._fitFOV,o=Math.abs(r/Math.tan(A*V.DEGTORAD));this._orthoScale2=1.1*r,this._eye2[0]=this._look2[0]+s[0]*o,this._eye2[1]=this._look2[1]+s[1]*o,this._eye2[2]=this._look2[2]+s[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"!==s.projection&&(this._projection2="ortho",this._projMatrix1=s.projMatrix.slice(),this._projMatrix2=s.ortho.matrix.slice(),s.projection="customProjection"),"perspective"===e.projection&&"perspective"!==s.projection&&(this._projection2="perspective",this._projMatrix1=s.projMatrix.slice(),this._projMatrix2=s.perspective.matrix.slice(),s.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,ie.scheduleTask(this._update,this)}jumpTo(e){this._jumpTo(e)}_jumpTo(e){this._flying&&this.stop();const t=this.scene.camera;var i,s,r,n,A;if(e.aabb)i=e.aabb;else if(6===e.length)i=e;else if(e.eye||e.look||e.up)r=e.eye,n=e.look,A=e.up;else{let t=e;if((X.isNumeric(t)||X.isString(t))&&(s=t,t=this.scene.components[s],!t))return void this.error("Component not found: "+X.inQuotes(s));i=t.aabb||this.scene.aabb}const o=e.poi;if(i){if(i[3]<=i[0]||i[4]<=i[1]||i[5]<=i[2])return;var a=o?V.getAABB3DiagPoint(i,o):V.getAABB3Diag(i);let s;n=o||V.getAABB3Center(i,n),this._trail?V.subVec3(t.look,n,Ue):V.subVec3(t.eye,t.look,Ue),V.normalizeVec3(Ue);s=(void 0!==e.fit?e.fit:this._fit)?Math.abs(a/Math.tan((e.fitFOV||this._fitFOV)*V.DEGTORAD)):V.lenVec3(V.subVec3(t.eye,t.look,Ce)),V.mulVec3Scalar(Ue,s),t.eye=V.addVec3(n,Ue,Ce),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 i=this.easing?xe._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(V.subVec3(s.eye,s.look,Ue),s.eye=V.lerpVec3(i,0,1,this._eye1,this._eye2,Ee),s.look=V.subVec3(Ee,Ue,Me)):this._flyingLook&&(s.look=V.lerpVec3(i,0,1,this._look1,this._look2,Me),s.up=V.lerpVec3(i,0,1,this._up1,this._up2,Fe)):this._flyingEyeLookUp&&(s.eye=V.lerpVec3(i,0,1,this._eye1,this._eye2,Ee),s.look=V.lerpVec3(i,0,1,this._look1,this._look2,Me),s.up=V.lerpVec3(i,0,1,this._up1,this._up2,Fe)),this._projection2){const t="ortho"===this._projection2?xe._easeOutExpo(e,0,1,1):xe._easeInCubic(e,0,1,1);s.customProjection.matrix=V.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();ie.scheduleTask(this._update,this)}static _ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}static _easeInCubic(e,t,i,s){return i*(e/=s)*e*e+t}static _easeOutExpo(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+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 Ie extends Ae{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new xe(this),this._t=0,this.state=Ie.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,i;const s=performance.now(),r=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==r)switch(this.state){case Ie.SCRUBBING:return;case Ie.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=Ie.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case Ie.PLAYING_TO:i=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=Ie.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}_ease(e,t,i,s){return-i*(e/=s)*(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=Ie.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=Ie.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const i=this._cameraPath;if(!i)return;const s=i.frames[e];s?(this.state=Ie.SCRUBBING,this._cameraFlightAnimation.flyTo(s,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=Ie.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=Ie.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=Ie.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}Ie.STOPPED=0,Ie.SCRUBBING=1,Ie.PLAYING=2,Ie.PLAYING_TO=3;class Te extends Ae{get type(){return"Geometry"}get isGeometry(){return!0}constructor(e,t={}){super(e,t),G.memory.meshes++}destroy(){super.destroy(),G.memory.meshes--}}const Pe=new e({});class Se{constructor(e){this.id=Pe.addItem({});for(const t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}destroy(){Pe.removeItem(this.id)}}class De{constructor(e,t,i,s,r,n,A,o,a){switch(this._gl=e,this.type=t,this.allocated=!1,i.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=s,this.numItems=0,this.itemSize=r,this.normalized=!!A,this.stride=o||0,this.offset=a||0,this._allocate(i)}_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 ke=function(){const e=[],t=[],i=[],s=[],r=[];let n=0;const A=new Uint16Array(3),o=new Uint16Array(3),a=new Uint16Array(3),l=V.vec3(),c=V.vec3(),h=V.vec3(),u=V.vec3(),d=V.vec3(),f=V.vec3(),p=V.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,f=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]=f/3,e[f++]=o,e[f++]=a,e[f++]=l),t[u/3]=A[c];for(u=0,d=n.length;u<d;u++)s[u]=t[n[u]],i[s[u]]=n[u]}(g,m),function(t,i){n=0;for(let g=0,m=t;g<m;g+=3){const t=3*s[g],m=3*s[g+1],_=3*s[g+2];i?(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],V.decompressPosition(A,i,l),V.decompressPosition(o,i,c),V.decompressPosition(a,i,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]),V.subVec3(h,c,u),V.subVec3(l,c,d),V.cross3Vec3(u,d,f),V.normalizeVec3(f,p);const b=r[n]||(r[n]={normal:V.vec3()});b.normal[0]=p[0],b.normal[1]=p[1],b.normal[2]=p[2],n++}}(m.length,_);const B=[],y=Math.cos(V.DEGTORAD*b),w={};let v,C,M,E,F,U,x,I,T,P,S,D=!1;for(let e=0,t=m.length;e<t;e+=3){const t=e/3;for(let i=0;i<3;i++)v=s[e+i],C=s[e+(i+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)U=w[F],void 0!==U.face2&&(x=r[U.face1].normal,I=r[U.face2].normal,T=V.dotVec3(x,I),T>y)||(P=i[U.index1],S=i[U.index2],(!D&&P>65535||S>65535)&&(D=!0),B.push(P),B.push(S));return D?new Uint32Array(B):new Uint16Array(B)}}();const Qe=function(){const e=V.mat4(),t=V.mat4();return function(i,s){s=s||V.mat4();const r=i[0],n=i[1],A=i[2],o=i[3]-r,a=i[4]-n,l=i[5]-A,c=65535;return V.identityMat4(e),V.translationMat4v(i,e),V.identityMat4(t),V.scalingMat4v([o/c,a/c,l/c],t),V.mulMat4(e,t,s),s}}();var Re=function(){const e=V.mat4(),t=V.mat4();return function(i,s,r){const n=new Uint16Array(i.length),A=new Float32Array([r[0]!==s[0]?65535/(r[0]-s[0]):0,r[1]!==s[1]?65535/(r[1]-s[1]):0,r[2]!==s[2]?65535/(r[2]-s[2]):0]);let o;for(o=0;o<i.length;o+=3)n[o+0]=Math.max(0,Math.min(65535,Math.floor((i[o+0]-s[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((i[o+1]-s[1])*A[1]))),n[o+2]=Math.max(0,Math.min(65535,Math.floor((i[o+2]-s[2])*A[2])));V.identityMat4(e),V.translationMat4v(s,e),V.identityMat4(t),V.scalingMat4v([(r[0]-s[0])/65535,(r[1]-s[1])/65535,(r[2]-s[2])/65535],t);return{quantized:n,decodeMatrix:V.mulMat4(e,t,V.identityMat4())}}}();var Oe=function(){const e=V.mat3(),t=V.mat3();return function(i,s,r){const n=new Uint16Array(i.length),A=new Float32Array([65535/(r[0]-s[0]),65535/(r[1]-s[1])]);let o;for(o=0;o<i.length;o+=2)n[o+0]=Math.max(0,Math.min(65535,Math.floor((i[o+0]-s[0])*A[0]))),n[o+1]=Math.max(0,Math.min(65535,Math.floor((i[o+1]-s[1])*A[1])));V.identityMat3(e),V.translationMat3v(s,e),V.identityMat3(t),V.scalingMat3v([(r[0]-s[0])/65535,(r[1]-s[1])/65535],t);return{quantized:n,decodeMatrix:V.mulMat3(e,t,V.identityMat3())}}}();function Ve(e,t,i,s){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[i](127.5*r+(r<0?-1:0)),Math[s](127.5*n+(n<0?-1:0))])}function Le(e){let t=e[0],i=e[1];t/=t<0?127:128,i/=i<0?127:128;const s=1-Math.abs(t)-Math.abs(i);s<0&&(t=(1-Math.abs(i))*(t>=0?1:-1),i=(1-Math.abs(t))*(i>=0?1:-1));const r=Math.sqrt(t*t+i*i+s*s);return[t/r,i/r,s/r]}function He(e,t,i){return e[t]*i[0]+e[t+1]*i[1]+e[t+2]*i[2]}const Ne={getPositionsBounds:function(e){const t=new Float32Array(3),i=new Float32Array(3);let s,r;for(s=0;s<3;s++)t[s]=Number.MAX_VALUE,i[s]=-Number.MAX_VALUE;for(s=0;s<e.length;s+=3)for(r=0;r<3;r++)t[r]=Math.min(t[r],e[s+r]),i[r]=Math.max(i[r],e[s+r]);return{min:t,max:i}},createPositionsDecodeMatrix:Qe,compressPositions:Re,compressPosition:function(e,t,i){const s=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]);i[0]=Math.max(0,Math.min(65535,Math.floor((e[0]-t[0])*s[0]))),i[1]=Math.max(0,Math.min(65535,Math.floor((e[1]-t[1])*s[1]))),i[2]=Math.max(0,Math.min(65535,Math.floor((e[2]-t[2])*s[2])))},decompressPositions:function(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[12],i[s+1]=e[s+1]*t[5]+t[13],i[s+2]=e[s+2]*t[10]+t[14];return i},decompressPosition:function(e,t,i){return i[0]=e[0]*t[0]+t[12],i[1]=e[1]*t[5]+t[13],i[2]=e[2]*t[10]+t[14],i},decompressAABB:function(e,t,i=e){return i[0]=e[0]*t[0]+t[12],i[1]=e[1]*t[5]+t[13],i[2]=e[2]*t[10]+t[14],i[3]=e[3]*t[0]+t[12],i[4]=e[4]*t[5]+t[13],i[5]=e[5]*t[10]+t[14],i},getUVBounds:function(e){const t=new Float32Array(2),i=new Float32Array(2);let s,r;for(s=0;s<2;s++)t[s]=Number.MAX_VALUE,i[s]=-Number.MAX_VALUE;for(s=0;s<e.length;s+=2)for(r=0;r<2;r++)t[r]=Math.min(t[r],e[s+r]),i[r]=Math.max(i[r],e[s+r]);return{min:t,max:i}},compressUVs:Oe,decompressUVs:function(e,t,i=new Float32Array(e.length)){for(let s=0,r=e.length;s<r;s+=3)i[s+0]=e[s+0]*t[0]+t[6],i[s+1]=e[s+1]*t[4]+t[7];return i},decompressUV:function(e,t,i){i[0]=e[0]*t[0]+t[6],i[1]=e[1]*t[4]+t[7]},compressNormals:function(e){const t=new Int8Array(e.length);let i,s,r,n,A;for(let o=0;o<e.length;o+=3)r=i=Ve(e,o,"floor","floor"),s=Le(i),n=A=He(e,o,s),i=Ve(e,o,"ceil","floor"),s=Le(i),n=He(e,o,s),n>A&&(r=i,A=n),i=Ve(e,o,"floor","ceil"),s=Le(i),n=He(e,o,s),n>A&&(r=i,A=n),i=Ve(e,o,"ceil","ceil"),s=Le(i),n=He(e,o,s),n>A&&(r=i,A=n),t[o]=r[0],t[o+1]=r[1];return t},decompressNormals:function(e,t){for(let i=0,s=0,r=e.length;i<r;i+=2){let r=e[i+0],n=e[i+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[s+0]=r/o,t[s+1]=n/o,t[s+2]=A/o,s+=3}return t},decompressNormal:function(e,t){let i=e[0],s=e[1];i=(2*i+1)/255,s=(2*s+1)/255;const r=1-Math.abs(i)-Math.abs(s);r<0&&(i=(1-Math.abs(s))*(i>=0?1:-1),s=(1-Math.abs(i))*(s>=0?1:-1));const n=Math.sqrt(i*i+s*s+r*r);return t[0]=i/n,t[1]=s/n,t[2]=r/n,t}},Ge=G.memory,je=V.AABB3();class We extends Te{get type(){return"ReadableGeometry"}get isReadableGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new Se({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 i=this._state,s=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":i.primitive=s.POINTS,i.primitiveName=t.primitive;break;case"lines":i.primitive=s.LINES,i.primitiveName=t.primitive;break;case"line-loop":i.primitive=s.LINE_LOOP,i.primitiveName=t.primitive;break;case"line-strip":i.primitive=s.LINE_STRIP,i.primitiveName=t.primitive;break;case"triangles":i.primitive=s.TRIANGLES,i.primitiveName=t.primitive;break;case"triangle-strip":i.primitive=s.TRIANGLE_STRIP,i.primitiveName=t.primitive;break;case"triangle-fan":i.primitive=s.TRIANGLE_FAN,i.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'."),i.primitive=s.TRIANGLES,i.primitiveName=t.primitive}if(t.positions)if(this._state.compressGeometry){const e=Ne.getPositionsBounds(t.positions),s=Ne.compressPositions(t.positions,e.min,e.max);i.positions=s.quantized,i.positionsDecodeMatrix=s.decodeMatrix}else i.positions=t.positions.constructor===Float32Array?t.positions:new Float32Array(t.positions);if(t.colors&&(i.colors=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors)),t.uv)if(this._state.compressGeometry){const e=Ne.getUVBounds(t.uv),s=Ne.compressUVs(t.uv,e.min,e.max);i.uv=s.quantized,i.uvDecodeMatrix=s.decodeMatrix}else i.uv=t.uv.constructor===Float32Array?t.uv:new Float32Array(t.uv);if(t.normals&&(this._state.compressGeometry?i.normals=Ne.compressNormals(t.normals):i.normals=t.normals.constructor===Float32Array?t.normals:new Float32Array(t.normals)),t.indices&&(i.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(),Ge.meshes++,i.indices&&(i.indicesBuf=new De(s,s.ELEMENT_ARRAY_BUFFER,i.indices,i.indices.length,1,s.STATIC_DRAW),Ge.indices+=i.indicesBuf.numItems),i.positions&&(i.positionsBuf=new De(s,s.ARRAY_BUFFER,i.positions,i.positions.length,3,s.STATIC_DRAW),Ge.positions+=i.positionsBuf.numItems),i.normals){let e=i.compressGeometry;i.normalsBuf=new De(s,s.ARRAY_BUFFER,i.normals,i.normals.length,3,s.STATIC_DRAW,e),Ge.normals+=i.normalsBuf.numItems}i.colors&&(i.colorsBuf=new De(s,s.ARRAY_BUFFER,i.colors,i.colors.length,4,s.STATIC_DRAW),Ge.colors+=i.colorsBuf.numItems),i.uv&&(i.uvBuf=new De(s,s.ARRAY_BUFFER,i.uv,i.uv.length,2,s.STATIC_DRAW),Ge.uvs+=i.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,i=ke(e.positions,e.indices,e.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new De(t,t.ELEMENT_ARRAY_BUFFER,i,i.length,1,t.STATIC_DRAW),Ge.indices+=this._edgeIndicesBuf.numItems}_buildPickTriangleVBOs(){const e=this._state;if(!e.positions||!e.indices)return;const t=this.scene.canvas.gl,i=V.buildPickTriangles(e.positions,e.indices,e.compressGeometry),s=i.positions,r=i.colors;this._pickTrianglePositionsBuf=new De(t,t.ARRAY_BUFFER,s,s.length,3,t.STATIC_DRAW),this._pickTriangleColorsBuf=new De(t,t.ARRAY_BUFFER,r,r.length,4,t.STATIC_DRAW,!0),Ge.positions+=this._pickTrianglePositionsBuf.numItems,Ge.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),Ne.decompressPositions(this._state.positions,this._state.positionsDecodeMatrix,this._decompressedPositions)),this._decompressedPositions):this._state.positions:null}set positions(e){const t=this._state,i=t.positions;if(i)if(i.length===e.length){if(this._state.compressGeometry){const i=Ne.getPositionsBounds(e),s=Ne.compressPositions(e,i.min,i.max);e=s.quantized,t.positionsDecodeMatrix=s.decodeMatrix}i.set(e),t.positionsBuf&&t.positionsBuf.setData(i),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),Ne.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,i=t.normals;i?i.length===e.length?(i.set(e),t.normalsBuf&&t.normalsBuf.setData(i),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),Ne.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,i=t.uv;i?i.length===e.length?(i.set(e),t.uvBuf&&t.uvBuf.setData(i),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,i=t.colors;i?i.length===e.length?(i.set(e),t.colorsBuf&&t.colorsBuf.setData(i),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=V.AABB3()),V.positions3ToAABB3(this._state.positions,this._aabb,this._state.positionsDecodeMatrix),this._aabbDirty=!1),this._aabb}get obb(){return this._obbDirty&&(this._obb||(this._obb=V.OBB3()),V.positions3ToAABB3(this._state.positions,je,this._state.positionsDecodeMatrix),V.AABB3ToOBB3(je,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,i=(i,s)=>{const r=3*e[i];for(let e=0;e<3;++e)s[e]=t[r+e];return s},s=[V.vec3(),V.vec3(),V.vec3(),V.vec3()];let r=0;const n=V.vec3([0,0,0]);for(let t=0;t<e.length;t+=3){const e=i(t,s[0]),A=i(t+1,s[1]),o=i(t+2,s[2]);V.addVec3(e,A,s[3]),V.addVec3(o,s[3],s[3]);const a=V.lenVec3(V.cross3Vec3(V.subVec3(A,e,s[1]),V.subVec3(o,e,s[2]),s[0]))/2;r+=a,V.mulVec3Scalar(s[3],a,s[3]),V.addVec3(n,s[3],n)}this._metrics={surfaceArea:r,centroid:V.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(),Ge.meshes--}}const ze=G.memory,Xe=V.AABB3();class Ke extends Te{get type(){return"VBOGeometry"}get isVBOGeometry(){return!0}constructor(e,t={}){super(e,t),this._state=new Se({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=V.OBB3();const i=this._state,s=this.scene.canvas.gl;switch(t.primitive=t.primitive||"triangles",t.primitive){case"points":i.primitive=s.POINTS,i.primitiveName=t.primitive;break;case"lines":i.primitive=s.LINES,i.primitiveName=t.primitive;break;case"line-loop":i.primitive=s.LINE_LOOP,i.primitiveName=t.primitive;break;case"line-strip":i.primitive=s.LINE_STRIP,i.primitiveName=t.primitive;break;case"triangles":i.primitive=s.TRIANGLES,i.primitiveName=t.primitive;break;case"triangle-strip":i.primitive=s.TRIANGLE_STRIP,i.primitiveName=t.primitive;break;case"triangle-fan":i.primitive=s.TRIANGLE_FAN,i.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'."),i.primitive=s.TRIANGLES,i.primitiveName=t.primitive}if(t.positions)if(t.indices){var r;if(t.positionsDecodeMatrix);else{const e=Ne.getPositionsBounds(t.positions),n=Ne.compressPositions(t.positions,e.min,e.max);r=n.quantized,i.positionsDecodeMatrix=n.decodeMatrix,i.positionsBuf=new De(s,s.ARRAY_BUFFER,r,r.length,3,s.STATIC_DRAW),ze.positions+=i.positionsBuf.numItems,V.positions3ToAABB3(t.positions,this._aabb),V.positions3ToAABB3(r,Xe,i.positionsDecodeMatrix),V.AABB3ToOBB3(Xe,this._obb)}if(t.colors){const e=t.colors.constructor===Float32Array?t.colors:new Float32Array(t.colors);i.colorsBuf=new De(s,s.ARRAY_BUFFER,e,e.length,4,s.STATIC_DRAW),ze.colors+=i.colorsBuf.numItems}if(t.uv){const e=Ne.getUVBounds(t.uv),r=Ne.compressUVs(t.uv,e.min,e.max),n=r.quantized;i.uvDecodeMatrix=r.decodeMatrix,i.uvBuf=new De(s,s.ARRAY_BUFFER,n,n.length,2,s.STATIC_DRAW),ze.uvs+=i.uvBuf.numItems}if(t.normals){const e=Ne.compressNormals(t.normals);let r=i.compressGeometry;i.normalsBuf=new De(s,s.ARRAY_BUFFER,e,e.length,3,s.STATIC_DRAW,r),ze.normals+=i.normalsBuf.numItems}{const e=t.indices.constructor===Uint32Array||t.indices.constructor===Uint16Array?t.indices:new Uint32Array(t.indices);i.indicesBuf=new De(s,s.ELEMENT_ARRAY_BUFFER,e,e.length,1,s.STATIC_DRAW),ze.indices+=i.indicesBuf.numItems;const n=ke(r,e,i.positionsDecodeMatrix,this._edgeThreshold);this._edgeIndicesBuf=new De(s,s.ELEMENT_ARRAY_BUFFER,n,n.length,1,s.STATIC_DRAW),"triangles"===this._state.primitiveName&&(this._numTriangles=t.indices.length/3)}this._buildHash(),ze.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(),ze.meshes--}}var Ze={};function Je(e,t={}){return new Promise((function(i,s){t.src||(console.error("load3DSGeometry: Parameter expected: src"),s());var r=e.canvas.spinner;r.processes++,X.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("load3DSGeometry: no data loaded"),r.processes--,s());var n=Ze.parse.from3DS(e).edit.objects[0].mesh,A=n.vertices,o=n.uvt,a=n.indices;r.processes--,i(X.apply(t,{primitive:"triangles",positions:A,normals:null,uv:o,indices:a}))}),(function(e){console.error("load3DSGeometry: "+e),r.processes--,s()}))}))}function Ye(e,t={}){return new Promise((function(i,s){t.src||(console.error("loadOBJGeometry: Parameter expected: src"),s());var r=e.canvas.spinner;r.processes++,X.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("loadOBJGeometry: no data loaded"),r.processes--,s());for(var n=Ze.parse.fromOBJ(e),A=Ze.edit.unwrap(n.i_verts,n.c_verts,3),o=Ze.edit.unwrap(n.i_norms,n.c_norms,3),a=Ze.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--,i(X.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--,s()}))}))}function $e(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let i=e.ySize||1;i<0&&(console.error("negative ySize not allowed - will invert"),i*=-1);let s=e.zSize||1;s<0&&(console.error("negative zSize not allowed - will invert"),s*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-i+A,c=-s+o,h=t+n,u=i+A,d=s+o;return X.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 qe(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let i=e.ySize||1;i<0&&(console.error("negative ySize not allowed - will invert"),i*=-1);let s=e.zSize||1;s<0&&(console.error("negative zSize not allowed - will invert"),s*=-1);const r=e.center,n=r?r[0]:0,A=r?r[1]:0,o=r?r[2]:0,a=-t+n,l=-i+A,c=-s+o,h=t+n,u=i+A,d=s+o;return X.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 et(e={}){return qe({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})}function tt(e={}){let t=e.radiusTop||1;t<0&&(console.error("negative radiusTop not allowed - will invert"),t*=-1);let i=e.radiusBottom||1;i<0&&(console.error("negative radiusBottom not allowed - will invert"),i*=-1);let s=e.height||1;s<0&&(console.error("negative height not allowed - will invert"),s*=-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=s/2,u=s/n,d=2*Math.PI/r,f=1/r,p=(t-i)/n,g=[],m=[],_=[],b=[];let B,y,w,v,C,M,E,F,U,x,I;const T=(90-180*Math.atan(s/(i-t))/Math.PI)/90;for(B=0;B<=n;B++)for(C=t-B*p,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*f),_.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(U=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),x=.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(x),_.push(I),g.push(t*w+a),g.push(h+l),g.push(t*v+c);for(y=0;y<r;y++)o=U,E=U+1+y,b.push(E),b.push(E+1),b.push(o)}if(!A&&i>0){for(U=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),x=.5*Math.sin(y*d)+.5,I=.5*Math.cos(y*d)+.5,m.push(i*w),m.push(-1),m.push(i*v),_.push(x),_.push(I),g.push(i*w+a),g.push(0-h+l),g.push(i*v+c);for(y=0;y<r;y++)o=U,E=U+1+y,b.push(o),b.push(E+1),b.push(E)}return X.apply(e,{positions:g,normals:m,uv:_,indices:b})}function it(e={}){let t=e.size||1;t<0&&(console.error("negative size not allowed - will invert"),t*=-1);let i=e.divisions||1;i<0&&(console.error("negative divisions not allowed - will invert"),i*=-1),i<1&&(i=1),t=t||10,i=i||10;const s=t/i,r=t/2,n=[],A=[];let o=0;for(let e=0,t=-r;e<=i;e++,t+=s)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 X.apply(e,{primitive:"lines",positions:n,indices:A})}function st(e={}){let t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);let i=e.zSize||1;i<0&&(console.error("negative zSize not allowed - will invert"),i*=-1);let s=e.xSegments||1;s<0&&(console.error("negative xSegments not allowed - will invert"),s*=-1),s<1&&(s=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=i/2,h=Math.floor(s)||1,u=Math.floor(r)||1,d=h+1,f=u+1,p=t/h,g=i/u,m=new Float32Array(d*f*3),_=new Float32Array(d*f*3),b=new Float32Array(d*f*2);let B,y,w,v,C,M,E,F=0,U=0;for(B=0;B<f;B++){const e=B*g-c;for(y=0;y<d;y++)w=y*p-l,m[F]=w+A,m[F+1]=o,m[F+2]=-e+a,_[F+1]=1,b[U]=y/h,b[U+1]=(u-B)/u,F+=3,U+=2}F=0;const x=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,x[F]=E,x[F+1]=C,x[F+2]=v,x[F+3]=E,x[F+4]=M,x[F+5]=C,F+=6;return X.apply(e,{positions:m,normals:_,uv:b,indices:x})}function rt(e={}){const t=e.lod||1,i=e.center?e.center[0]:0,s=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,f,p,g,m,_,b,B,y,w,v,C,M,E;for(u=0;u<=A;u++)for(f=u*Math.PI/A,p=Math.sin(f),g=Math.cos(f),d=0;d<=o;d++)m=2*d*Math.PI/o,_=Math.sin(m),b=Math.cos(m),B=b*p,y=g,w=_*p,v=1-d/o,C=u/A,l.push(B),l.push(y),l.push(w),c.push(v),c.push(C),a.push(i+n*B),a.push(s+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 X.apply(e,{positions:a,normals:l,uv:c,indices:h})}function nt(e={}){let t=e.radius||1;t<0&&(console.error("negative radius not allowed - will invert"),t*=-1),t*=.5;let i=e.tube||.3;i<0&&(console.error("negative tube not allowed - will invert"),i*=-1);let s=e.radialSegments||32;s<0&&(console.error("negative radialSegments not allowed - will invert"),s*=-1),s<4&&(s=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 f,p,g,m,_,b,B,y,w,v,C,M;for(y=0;y<=r;y++)for(B=0;B<=s;B++)f=B/s*n,p=.785398+y/r*Math.PI*2,o=t*Math.cos(f),a=t*Math.sin(f),g=(t+i*Math.cos(p))*Math.cos(f),m=(t+i*Math.cos(p))*Math.sin(f),_=i*Math.sin(p),c.push(g+o),c.push(m+a),c.push(_+l),u.push(1-B/s),u.push(y/r),b=V.normalizeVec3(V.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<=s;B++)w=(s+1)*y+B-1,v=(s+1)*(y-1)+B-1,C=(s+1)*(y-1)+B,M=(s+1)*y+B,d.push(w),d.push(v),d.push(C),d.push(C),d.push(M),d.push(w);return X.apply(e,{positions:c,normals:h,uv:u,indices:d})}Ze.load=function(e,t){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(e){t(e.target.response)},i.send()},Ze.save=function(e,t){var i="data:application/octet-stream;base64,"+btoa(Ze.parse._buffToStr(e));window.location.href=i},Ze.clone=function(e){return JSON.parse(JSON.stringify(e))},Ze.bin={},Ze.bin.f=new Float32Array(1),Ze.bin.fb=new Uint8Array(Ze.bin.f.buffer),Ze.bin.rf=function(e,t){for(var i=Ze.bin.f,s=Ze.bin.fb,r=0;r<4;r++)s[r]=e[t+r];return i[0]},Ze.bin.rsl=function(e,t){return e[t]|e[t+1]<<8},Ze.bin.ril=function(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},Ze.bin.rASCII0=function(e,t){for(var i="";0!=e[t];)i+=String.fromCharCode(e[t++]);return i},Ze.bin.wf=function(e,t,i){new Float32Array(e.buffer,t,1)[0]=i},Ze.bin.wsl=function(e,t,i){e[t]=i,e[t+1]=i>>8},Ze.bin.wil=function(e,t,i){e[t]=i,e[t+1]=i>>8,e[t+2]=i>>16,e[t+3]},Ze.parse={},Ze.parse._buffToStr=function(e){for(var t=new Uint8Array(e),i="",s=0;s<t.length;s++)i=i.concat(String.fromCharCode(t[s]));return i},Ze.parse._strToBuff=function(e){for(var t=new ArrayBuffer(e.length),i=new Uint8Array(t),s=0;s<e.length;s++)i[s]=e.charCodeAt(s);return t},Ze.parse._readLine=function(e,t){for(var i="";10!=e[t];)i+=String.fromCharCode(e[t++]);return i},Ze.parse.fromJSON=function(e){return JSON.parse(Ze.parse._buffToStr(e))},Ze.parse.toJSON=function(e){var t=JSON.stringify(e);return Ze.parse._strToBuff(t)},Ze.parse.fromOBJ=function(e){for(var t={groups:{},c_verts:[],c_uvt:[],c_norms:[],i_verts:[],i_uvt:[],i_norms:[]},i={from:0,to:0},s=0,r=new Uint8Array(e);s<r.length;){var n=Ze.parse._readLine(r,s);s+=n.length+1;var A=(n=(n=n.replace(/ +(?= )/g,"")).replace(/(^\s+|\s+$)/g,"")).split(" ");if("g"==A[0]&&(i.to=t.i_verts.length,null==t.groups[A[1]]&&(t.groups[A[1]]={from:t.i_verts.length,to:0}),i=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,f=parseInt(h[0])-1,p=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),f<0&&(f=w+f+1),p<0&&(p=w+p+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,f,p),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,U=parseInt(M[2])-1;E<0&&(E=w+E+1),F<0&&(F=v+F+1),U<0&&(U=C+U+1),t.i_verts.push(d,p,E),t.i_uvt.push(g,_,F),t.i_norms.push(b,y,U)}}}return i.to=t.i_verts.length,t},Ze.parse.fromMD2=function(e){e=new Uint8Array(e);var t={},i={};i.ident=Ze.bin.ril(e,0),i.version=Ze.bin.ril(e,4),i.skinwidth=Ze.bin.ril(e,8),i.skinheight=Ze.bin.ril(e,12),i.framesize=Ze.bin.ril(e,16),i.num_skins=Ze.bin.ril(e,20),i.num_vertices=Ze.bin.ril(e,24),i.num_st=Ze.bin.ril(e,28),i.num_tris=Ze.bin.ril(e,32),i.num_glcmds=Ze.bin.ril(e,36),i.num_frames=Ze.bin.ril(e,40),i.offset_skins=Ze.bin.ril(e,44),i.offset_st=Ze.bin.ril(e,48),i.offset_tris=Ze.bin.ril(e,52),i.offset_frames=Ze.bin.ril(e,56),i.offset_glcmds=Ze.bin.ril(e,60),i.offset_end=Ze.bin.ril(e,64);var s=i.offset_st;t.c_uvt=[];for(var r=0;r<i.num_st;r++){var n=Ze.bin.rsl(e,s)/i.skinwidth,A=Ze.bin.rsl(e,s+2)/i.skinheight;t.c_uvt.push(n,A),s+=4}s=i.offset_tris;var o=[],a=[];t.i_verts=o,t.i_uvt=a;for(r=0;r<i.num_tris;r++)o.push(Ze.bin.rsl(e,s),Ze.bin.rsl(e,s+2),Ze.bin.rsl(e,s+4)),a.push(Ze.bin.rsl(e,s+6),Ze.bin.rsl(e,s+8),Ze.bin.rsl(e,s+10)),s+=12;s=i.offset_skins;t.skins=[];for(r=0;r<i.num_skins;r++)t.skins.push(Ze.bin.rASCII0(e,s)),s+=64;s=i.offset_frames;t.frames=[];var l=Ze.parse.fromMD2._normals;for(r=0;r<i.num_frames;r++){var c={},h=Ze.bin.rf(e,s),u=Ze.bin.rf(e,s+4),d=Ze.bin.rf(e,s+8);s+=12;var f=Ze.bin.rf(e,s),p=Ze.bin.rf(e,s+4),g=Ze.bin.rf(e,s+8);s+=12,c.name=Ze.bin.rASCII0(e,s),s+=16,c.verts=[],c.norms=[];for(var m=0;m<i.num_vertices;m++)c.verts.push(e[s]*h+f,e[s+1]*u+p,e[s+2]*d+g),c.norms.push(l[3*e[s+3]],l[3*e[s+3]+1],l[3*e[s+3]+2]),s+=4;t.frames.push(c)}return t},Ze.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],Ze.parse.fromCollada=function(e){var t=Ze.parse._buffToStr(e),i=(new DOMParser).parseFromString(t,"text/xml"),s={},r=(i=i.childNodes[0]).getElementsByTagName("asset")[0],n=i.getElementsByTagName("library_geometries")[0],A=i.getElementsByTagName("library_images")[0],o=i.getElementsByTagName("library_materials")[0],a=i.getElementsByTagName("library_effects")[0];return r&&(s.asset=Ze.parse.fromCollada._asset(r)),n&&(s.geometries=Ze.parse.fromCollada._libGeometries(n)),A&&(s.images=Ze.parse.fromCollada._libImages(A)),o&&(s.materials=Ze.parse.fromCollada._libMaterials(o)),a&&(s.effects=Ze.parse.fromCollada._libEffects(a)),s},Ze.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}},Ze.parse.fromCollada._libGeometries=function(e){e=e.getElementsByTagName("geometry");for(var t=[],i=0;i<e.length;i++){var s=e[i],r=Ze.parse.fromCollada._getMesh(s.getElementsByTagName("mesh")[0]);t.push(r)}return t},Ze.parse.fromCollada._getMesh=function(e){for(var t={},i=e.getElementsByTagName("source"),s=t.sources={},r=0;r<i.length;r++){for(var n=i[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]);s[i[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 f=u[a];o=[];d[parseInt(f.getAttribute("offset"))]=o;var p=f.getAttribute("semantic");c["s_"+p]="VERTEX"==p?e.getElementsByTagName("vertices")[0].getElementsByTagName("input")[0].getAttribute("source").substring(1):f.getAttribute("source").substring(1),c["i_"+p]=o,s[c["s_"+p]]}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},Ze.parse.fromCollada._libImages=function(e){e=e.getElementsByTagName("image");for(var t={},i=0;i<e.length;i++)t[e[i].getAttribute("id")]=e[i].getElementsByTagName("init_from")[0].textContent;return t},Ze.parse.fromCollada._libMaterials=function(e){e=e.getElementsByTagName("material");for(var t={},i=0;i<e.length;i++)t[e[i].getAttribute("name")]=e[i].getElementsByTagName("instance_effect")[0].getAttribute("url").substring(1);return t},Ze.parse.fromCollada._libEffects=function(e){e=e.getElementsByTagName("effect");for(var t={},i=0;i<e.length;i++){for(var s={},r=e[i].getElementsByTagName("newparam"),n=0;n<r.length;n++){var A=r[n].getElementsByTagName("surface")[0];A&&(s.surface=A.getElementsByTagName("init_from")[0].textContent)}t[e[i].getAttribute("id")]=s}return t},Ze.parse.from3DS=function(e){e=new Uint8Array(e);var t={};if(19789!=Ze.bin.rsl(e,0))return null;for(var i=Ze.bin.ril(e,2),s=6;s<i;){var r=Ze.bin.rsl(e,s),n=Ze.bin.ril(e,s+2);15677==r&&(t.edit=Ze.parse.from3DS._edit3ds(e,s,n)),45056==r&&(t.keyf=Ze.parse.from3DS._keyf3ds(e,s,n)),s+=n}return t},Ze.parse.from3DS._edit3ds=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);16384==n&&(null==s.objects&&(s.objects=[]),s.objects.push(Ze.parse.from3DS._edit_object(e,r,A))),r+=A}return s},Ze.parse.from3DS._keyf3ds=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);45058==n&&(null==s.desc&&(s.desc=[]),s.desc.push(Ze.parse.from3DS._keyf_objdes(e,r,A))),r+=A}return s},Ze.parse.from3DS._keyf_objdes=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);45072==n&&(s.hierarchy=Ze.parse.from3DS._keyf_objhierarch(e,r,A)),45073==n&&(s.dummy_name=Ze.bin.rASCII0(e,r+6)),r+=A}return s},Ze.parse.from3DS._keyf_objhierarch=function(e,t,i){var s={},r=t+6;return s.name=Ze.bin.rASCII0(e,r),r+=s.name.length+1,s.hierarchy=Ze.bin.rsl(e,r+4),s},Ze.parse.from3DS._edit_object=function(e,t,i){var s={},r=t+6;for(s.name=Ze.bin.rASCII0(e,r),r+=s.name.length+1;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);16640==n&&(s.mesh=Ze.parse.from3DS._obj_trimesh(e,r,A)),r+=A}return s},Ze.parse.from3DS._obj_trimesh=function(e,t,i){for(var s={},r=t+6;r<t+i;){var n=Ze.bin.rsl(e,r),A=Ze.bin.ril(e,r+2);16656==n&&(s.vertices=Ze.parse.from3DS._tri_vertexl(e,r,A)),16672==n&&(s.indices=Ze.parse.from3DS._tri_facel1(e,r,A)),16704==n&&(s.uvt=Ze.parse.from3DS._tri_mappingcoors(e,r,A)),16736==n&&(s.local=Ze.parse.from3DS._tri_local(e,r,A)),r+=A}return s},Ze.parse.from3DS._tri_vertexl=function(e,t,i){var s=[],r=t+6,n=Ze.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)s.push(Ze.bin.rf(e,r)),s.push(Ze.bin.rf(e,r+4)),s.push(Ze.bin.rf(e,r+8)),r+=12;return s},Ze.parse.from3DS._tri_facel1=function(e,t,i){var s=[],r=t+6,n=Ze.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)s.push(Ze.bin.rsl(e,r)),s.push(Ze.bin.rsl(e,r+2)),s.push(Ze.bin.rsl(e,r+4)),r+=8;return s},Ze.parse.from3DS._tri_mappingcoors=function(e,t,i){var s=[],r=t+6,n=Ze.bin.rsl(e,r);r+=2;for(var A=0;A<n;A++)s.push(Ze.bin.rf(e,r)),s.push(1-Ze.bin.rf(e,r+4)),r+=8;return s},Ze.parse.from3DS._tri_local=function(e,t,i){var s={},r=t+6;return s.X=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s.Y=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s.Z=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s.C=[Ze.bin.rf(e,r),Ze.bin.rf(e,r+4),Ze.bin.rf(e,r+8)],r+=12,s},Ze.parse.fromBIV=function(e){e=new Uint8Array(e);var t={},i={};return i.id=Ze.bin.ril(e,0),i.verS=Ze.bin.ril(e,4),i.texS=Ze.bin.ril(e,8),i.indS=Ze.bin.ril(e,12),i.verO=Ze.bin.ril(e,16),i.verL=Ze.bin.ril(e,20),i.texO=Ze.bin.ril(e,24),i.texL=Ze.bin.ril(e,28),i.indO=Ze.bin.ril(e,32),i.indL=Ze.bin.ril(e,36),0!=i.verO&&(t.vertices=Ze.parse.fromBIV._readFloats(e,i.verO,i.verL)),0!=i.texO&&(t.uvt=Ze.parse.fromBIV._readFloats(e,i.texO,i.texL)),0!=i.indO&&(t.indices=Ze.parse.fromBIV._readInts(e,i.indO,i.indL,i.indS)),t},Ze.parse.toBIV=function(e){for(var t=0,i=0;i<e.indices.length;i++)t=Math.max(t,e.indices[i]);var s=32;t<=65535&&(s=16);var r=40;e.vertices&&(r+=4*e.vertices.length),e.uvt&&(r+=4*e.uvt.length),e.indices&&(r+=e.indices.length*s/8);var n=new Uint8Array(r);Ze.bin.wil(n,0,1769365870),Ze.bin.wil(n,4,32),Ze.bin.wil(n,8,32),Ze.bin.wil(n,12,s);var A=40;return e.vertices&&(Ze.bin.wil(n,16,A),Ze.bin.wil(n,20,4*e.vertices.length),Ze.parse.fromBIV._writeFloats(n,A,e.vertices),A+=4*e.vertices.length),e.uvt&&(Ze.bin.wil(n,24,A),Ze.bin.wil(n,28,4*e.uvt.length),Ze.parse.fromBIV._writeFloats(n,A,e.uvt),A+=4*e.uvt.length),e.indices&&(Ze.bin.wil(n,32,A),Ze.bin.wil(n,36,4*e.indices.length),Ze.parse.fromBIV._writeInts(n,A,e.indices,s)),n.buffer},Ze.parse.fromBIV._readFloats=function(e,t,i){for(var s=[],r=0;r<i/4;r++)s.push(Ze.bin.rf(e,t+4*r));return s},Ze.parse.fromBIV._writeFloats=function(e,t,i){for(var s=0;s<i.length;s++)Ze.bin.wf(e,t+4*s,i[s])},Ze.parse.fromBIV._readInts=function(e,t,i,s){for(var r=[],n=0;n<i/4;n++)16==s&&r.push(Ze.bin.rsl(e,t+2*n)),32==s&&r.push(Ze.bin.ril(e,t+4*n));return r},Ze.parse.fromBIV._writeInts=function(e,t,i,s){for(var r=0;r<i.length;r++)16==s&&Ze.bin.wsl(e,t+2*r,i[r]),32==s&&Ze.bin.wil(e,t+4*r,i[r])},Ze.gen={},Ze.gen.Plane=function(e,t,i,s){i||(i=1),s||(s=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(i*a/e,s*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},Ze.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]}},Ze.gen.Sphere=function(e,t){for(var i={verts:[],inds:[],uvt:[]},s=e+1,r=t+1,n=0;n<r;n++)for(var A=0;A<s;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);i.verts.push(l,c,h),i.uvt.push(A/e,n/t),n<t&&A<e&&i.inds.push(s*n+A,s*n+A+1,s*(n+1)+A,s*n+A+1,s*(n+1)+A,s*(n+1)+A+1)}return i},Ze.mat={},Ze.mat.scale=function(e,t,i){return[e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1]},Ze.mat.translate=function(e,t,i){return[1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1]},Ze.mat.rotateDeg=function(e,t,i){var s=Math.PI/180;return Ze.mat.rotate(e*s,t*s,i*s)},Ze.mat.rotate=function(e,t,i){var s=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r=e,n=t,A=i,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 s[0]=a*l,s[1]=-a*u,s[2]=h,s[4]=o*u+c*h*l,s[5]=o*l-c*h*u,s[6]=-c*a,s[8]=c*u-o*h*l,s[9]=c*l+o*h*u,s[10]=o*a,s},Ze.edit={},Ze.edit.interpolate=function(e,t,i,s){for(var r=0;r<e.length;r++)i[r]=e[r]+s*(t[r]-e[r])},Ze.edit.transform=function(e,t){for(var i=0;i<e.length;i+=3){var s=e[i],r=e[i+1],n=e[i+2];e[i+0]=t[0]*s+t[4]*r+t[8]*n+t[12],e[i+1]=t[1]*s+t[5]*r+t[9]*n+t[13],e[i+2]=t[2]*s+t[6]*r+t[10]*n+t[14]}},Ze.edit.unwrap=function(e,t,i){for(var s=new Array(Math.floor(e.length/3)*i),r=0;r<e.length;r++)for(var n=0;n<i;n++)s[r*i+n]=t[e[r]*i+n];return s},Ze.edit.remap=function(e,t,i,s){for(var r=new Array(i.length),n=0;n<e.length;n++)for(var A=0;A<s;A++)r[t[n]*s+A]=i[e[n]*s+A];return r},Ze.utils={},Ze.utils.getAABB=function(e){var t,i,s,r,n,A;r=n=A=-(t=i=s=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<i&&(i=l),l>n&&(n=l),c<s&&(s=c),l>A&&(A=c)}return{min:{x:t,y:i,z:s},max:{x:r,y:n,z:A}}};const At={" ":{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 ot(e={}){var t=e.origin||[0,0,0],i=t[0],s=t[1],r=t[2],n=e.size||1,A=[],o=[],a=e.text;X.isNumeric(a)&&(a=""+a);for(var l,c,h,u,d,f,p,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=At[c.charAt(v)]){d=1,f=-1,p=-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+i),A.push(B+m[1]*n*y+s),A.push(0+r),-1===f?f=b:(-1===p||(f=p),p=b),b++,d?d=!1:(o.push(f),o.push(p))):d=1;l+=u.width*y*n}B-=35*y*n}return X.apply(e,{primitive:"lines",positions:A,indices:o})}function at(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 i=[];for(let e=0;e<t-1;e++)i.push(e),i.push(e+1);return X.apply(e,{primitive:"lines",positions:e.points,indices:i})}function lt(e={}){let t=e.curve.getPoints(e.divisions).map((e=>[...e])).flat();return at({id:e.id,points:t})}function ct(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=[],i=[],s=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-s)**2+(o-r)**2+(a-n)**2),c=[(A-s)/l,(o-r)/l,(a-n)/l];if(e.pattern){let h=e.pattern.length,u=!1,d=0,f=0,p=0,g=[s,r,n],m=e.pattern[f];for(i.push(g[0],g[1],g[2]);m<=l-d;){let s=[c[0]*m,c[1]*m,c[2]*m],r=[g[0]+s[0],g[1]+s[1],g[2]+s[2]];i.push(r[0],r[1],r[2]),u||(t.push(p),t.push(p+1)),u=!u,p+=1,g=r,f+=1,f>=h&&(f=0),d+=m,m=e.pattern[f]}e.extendToEnd&&(i.push(A,o,a),t.push(t.length-2),t.push(t.length-1))}else t.push(0),t.push(1),i.push(s,r,n,A,o,a);return X.apply(e,{primitive:"lines",positions:i,indices:t})}const ht=V.vec4(4),ut=V.vec4(),dt=V.vec4(),ft=V.vec3([1,0,0]),pt=V.vec3([0,1,0]),gt=V.vec3([0,0,1]),mt=V.vec3(3),_t=V.vec3(3),bt=V.identityMat4();class Bt extends Ae{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=V.vec3(),this._quaternion=V.identityQuaternion(),this._rotation=V.vec3(),this._position=V.vec3(),this._offset=V.vec3(),this._localMatrix=V.identityMat4(),this._worldMatrix=V.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 i=0,s=e.length;i<s;i++)this.addChild(e[i],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=V.vec3()),this._origin.set(e)):this._origin&&(this._origin=null);for(let t=0,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;t++)this._children[t].edges=e}get edges(){return this._edges}set culled(e){e=!!e,this._culled=e;for(let t=0,i=this._children.length;t<i;t++)this._children[t].culled=e}get culled(){return this._culled}set clippable(e){e=!1!==e,this._clippable=e;for(let t=0,i=this._children.length;t<i;t++)this._children[t].clippable=e}get clippable(){return this._clippable}set collidable(e){e=!1!==e,this._collidable=e;for(let t=0,i=this._children.length;t<i;t++)this._children[t].collidable=e}get collidable(){return this._collidable}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,i=this._children.length;t<i;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,i=this._children.length;e<i;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,i=this._children.length;t<i;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,i=this._children.length;t<i;t++)this._children[t].castsShadow=e}get castsShadow(){return this._castsShadow}set receivesShadow(e){e=!!e,this._receivesShadow=e;for(let t=0,i=this._children.length;t<i;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)V.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,i=e.length;t<i;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_setSubtreeAABBsDirty(e){if(e._aabbDirty=!0,e._children)for(let t=0,i=e._children.length;t<i;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=V.AABB3()),this._buildAABB)this._buildAABB(this.worldMatrix,this._aabb);else{let e;V.collapseAABB3(this._aabb);for(let t=0,i=this._children.length;t<i;t++)e=this._children[t],e.collidable&&V.expandAABB3(this._aabb,e.aabb)}this._aabbDirty=!1}addChild(e,t){if(X.isNumeric(e)||X.isString(e)){const t=e;if(!(e=this.scene.component[t]))return void this.warn("Component not found: "+X.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,i=this._children.length;t<i;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,i=this._children.length;t<i;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(X.isNumeric(e)||X.isString(e)){const t=e;if(!(e=this.scene.components[t]))return void this.warn("Node not found: "+X.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]),V.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]),V.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=V.identityMat4()),this._localMatrix.set(e||bt),V.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=V.identityMat4()),V.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 ht[0]=e[0],ht[1]=e[1],ht[2]=e[2],ht[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(ht,ut),V.mulQuaternions(this.quaternion,ut,dt),this.quaternion=dt,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return ht[0]=e[0],ht[1]=e[1],ht[2]=e[2],ht[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(ht,ut),V.mulQuaternions(ut,this.quaternion,ut),this}rotateX(e){return this.rotate(ft,e)}rotateY(e){return this.rotate(pt,e)}rotateZ(e){return this.rotate(gt,e)}translate(e,t){return V.vec3ApplyQuaternion(this.quaternion,e,mt),V.mulVec3Scalar(mt,t,_t),V.addVec3(this.position,_t,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(ft,e)}translateY(e){return this.translate(pt,e)}translateZ(e){return this.translate(gt,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 i=0,s=e.length;i<s;i++)t=e[i],t.destroy()}this._children=[],this._setAABBDirty(),this.scene._aabbDirty=!0}}const yt=V.vec3(),wt=function(){const e=new Float64Array(16),t=new Float64Array(4),i=new Float64Array(4);return function(s,r,n){return n=n||e,t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=1,V.transformVec4(s,t,i),V.setMat4Translation(s,i,n),n.slice()}}();function vt(e,t,i){const s=Float32Array.from([e[0]])[0],r=e[0]-s,n=Float32Array.from([e[1]])[0],A=e[1]-n,o=Float32Array.from([e[2]])[0],a=e[2]-o;t[0]=s,t[1]=n,t[2]=o,i[0]=r,i[1]=A,i[2]=a}function Ct(e,t,i,s=1e3){const r=V.getPositionsCenter(e,yt),n=Math.round(r[0]/s)*s,A=Math.round(r[1]/s)*s,o=Math.round(r[2]/s)*s;i[0]=n,i[1]=A,i[2]=o;const a=0!==i[0]||0!==i[1]||0!==i[2];if(a)for(let i=0,s=e.length;i<s;i+=3)t[i+0]=e[i+0]-n,t[i+1]=e[i+1]-A,t[i+2]=e[i+2]-o;return a}const Mt=1e3,Et=1001,Ft=1002,Ut=1003,xt=1004,It=1004,Tt=1005,Pt=1005,St=1006,Dt=1007,kt=1007,Qt=1008,Rt=1008,Ot=1009,Vt=1010,Lt=1011,Ht=1012,Nt=1013,Gt=1014,jt=1015,Wt=1016,zt=1017,Xt=1018,Kt=1020,Zt=1021,Jt=1022,Yt=1023,$t=1024,qt=1025,ei=1026,ti=1027,ii=1028,si=1029,ri=1030,ni=1031,Ai=1033,oi=33776,ai=33777,li=33778,ci=33779,hi=35840,ui=35841,di=35842,fi=35843,pi=36196,gi=37492,mi=37496,_i=37808,bi=37809,Bi=37810,yi=37811,wi=37812,vi=37813,Ci=37814,Mi=37815,Ei=37816,Fi=37817,Ui=37818,xi=37819,Ii=37820,Ti=37821,Pi=36492,Si=3e3,Di=3001,ki=1e4,Qi=10001,Ri=10002,Oi=10003,Vi=new e({}),Li=V.vec3(),Hi=V.vec4(),Ni={3001:"sRGBToLinear"},Gi=function(){const e=[],t=[],i=[],s=[],r=[],n=[],A=[],o=(t,i)=>{let s=!1;return e.push((e=>s&&i(t,e))),{toString:()=>(s=!0,t)}},a={createAttribute:function(t,i){let s=!1;e.push((e=>s&&e.push(`in ${t} ${i};`)));const A={toString:()=>(s=!0,i)};return r.push((e=>{const t=s&&e(i);return t&&n.push(t.attributeHash),A.setInputValue=t,null})),A},createFragmentDefinition:(e,t)=>{let i=!1;return s.push((s=>i&&t(e,s))),{toString:()=>(i=!0,e)}},createOutput:(e,t,s)=>{let r=!1;return i.push((i=>r&&i.push(`layout(location = ${s||0}) out ${e} ${t};`))),{toString:()=>(r=!0,t)}},createUniform:(t,s,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${s};`);e.push(o),i.push(o);const a={toString:()=>(n=!0,s)};return A.push((e=>{const t=n&&e(s);return r?t&&(e=>r(t,e)):(a.setInputValue=t,null)})),a},createUniformArray:(t,s,r)=>{let n=!1;const o=e=>n&&e.push(`uniform ${t} ${s}[${r}];`);e.push(o),i.push(o);const a={toString:()=>(n=!0,s)};return A.push((e=>(a.setInputValue=n&&e(s),null))),a},createUniformBlock:(t,s,r)=>{let n=!1;const o=Object.keys(s),a=e=>{n&&(e.push(`uniform ${t} {`),o.forEach((t=>e.push(` ${s[t]} ${t};`))),e.push("};"))};e.push(a),i.push(a);const l={};return o.forEach((e=>l[e]={toString:()=>(n=!0,e)})),A.push((e=>{const i=n&&e(t);return r?i&&(e=>r(i,e)):(l.setInputValue=i,null)})),l},createVarying:(s,r,n,A)=>{let o=!1;const a=A?A+" ":"";return e.push((e=>o&&e.push(`${a}out ${s} ${r};`))),t.push((e=>o&&e.push(`${r} = ${n()};`))),i.push((e=>o&&e.push(`${a}in ${s} ${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:i=>{e.setInputValue(i.pickClipPos),t.setInputValue(i.pickClipPosInv)},transformedClipPos:()=>`vec4((${u}.xy / ${u}.w - ${e}) * ${t} * ${u}.w, ${u}.zw)`}}(),f=d?d.transformedClipPos():u,p=[],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?p.push(`gl_FragDepth = ${c.testPerspectiveForGl_FragDepth?`${g} == 0.0 ? gl_FragCoord.z : `:""}log2(${h(_)}) * ${m} * 0.5;`):c.cleanerEdges&&p.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 i=0;i<e;++i)t.push(i);return t}(B.getNumAllocatedSectionPlanes()).map((e=>{const t=(t,i,s)=>a.createUniform(t,`sectionPlane${i}${e}`,((t,i)=>{const r=B.sectionPlanes,n=r.length,A=(i.mesh.layerIndex||0)*n,o=e<n&&i.mesh.renderFlags.sectionPlanesActivePerLayer[A+e];return s(t,o,r[e],i.mesh.origin)}));return{act:t("bool","Active",((e,t)=>e(t?1:0))),dir:t("vec3","Dir",((e,t,i)=>t&&e(i.dir))),pos:t("vec3","Pos",((e,t,i,s)=>t&&e(s?V.mulVec3Scalar(V.normalizeVec3(i.dir,Li),-(V.dotVec3(i.dir,s)+i.dist),Li):i.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=i=>(t.needed=!0,`(sliced ? ${e} : ${i})`);return t}():e=>e,C=c.getGammaFactor,M=a.createUniform("float","gammaFactor",(e=>e(C())));c.appendFragmentOutputs(p,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 i=a.createVarying("highp vec3","vHighpWorldPosition",(()=>`${c.worldPositionAttribute}.xyz`));if(e.push(` float dist = ${y(i)};`),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 s.forEach((t=>t(e))),e}(),U=[...function(){const e=[];return i.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,...p,"}"],x=[`gl_Position = ${f};`,...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,...x,"}"],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(U),k=(e,t)=>{const i=t.join("\n"),s=o.createShader(e);return o.shaderSource(s,i),o.compileShader(s),o.getShaderParameter(s,o.COMPILE_STATUS)?[s]:[null,["Failed to compile",o.getShaderInfoLog(s),i.split("\n").map(((e,t)=>t+1+": "+e+"\n")).join("")]]},[Q,R]=k(o.VERTEX_SHADER,S),[O,L]=k(o.FRAGMENT_SHADER,D),H=e=>(console.error(e.join("\n")),[null,e]);if(R)return H(["Vertex shader error"].concat(R));if(L)return H(["Fragment shader error"].concat(L));{const e=o.createProgram();if(e){if(o.attachShader(e,Q),o.attachShader(e,O),o.linkProgram(e),o.getProgramParameter(e,o.LINK_STATUS)){const t=zi(o,e);r.forEach((e=>e(t)));const i=A.map((e=>e(t))).filter((e=>e)),s=Vi.addItem({});return[{id:s,bind:()=>o.useProgram(e),inputSetters:{attributesHash:n.sort().join(", "),setUniforms:(e,t)=>{d&&d.setClipPosInputValue(e),i.forEach((e=>e(t)))}},destroy:()=>{Vi.removeItem(s),o.deleteProgram(e),o.deleteShader(Q),o.deleteShader(O)}}]}return H(["",o.getProgramInfoLog(this.program),"","Vertex shader:","",...S,"","Fragment shader:","",...D])}return H(["Failed to allocate program"])}}}},ji=function(e,t){const i=e.createUniform("vec4","lightAmbient",(e=>e(t.getAmbientColorAndIntensity()))),s=t.lights,r=s.map(((t,i)=>{const r={color:e.createUniform("vec4",`lightColor${i}`,(e=>{const t=s[i];Hi[0]=t.color[0],Hi[1]=t.color[1],Hi[2]=t.color[2],Hi[3]=t.intensity,e(Hi)})),position:e.createUniform("vec3",`lightPos${i}`,(e=>e(s[i].pos))),direction:e.createUniform("vec3",`lightDir${i}`,(e=>e(s[i].dir))),shadowProjMatrix:e.createUniform("mat4",`shadowProjMatrix${i}`,(e=>e(s[i].getShadowViewMatrix()))),shadowViewMatrix:e.createUniform("mat4",`shadowViewMatrix${i}`,(e=>e(s[i].getShadowViewMatrix()))),shadowMap:e.createUniform("sampler2D",`shadowMap${i}`,(e=>e(s[i].getShadowRenderBuf().colorTextures[0])))},n=e=>({glslLight:{isViewSpace:"view"===t.space,getColor:()=>`${r.color}.rgb * ${r.color}.a`,getDirection:(t,i)=>`normalize(${e(t,i)})`,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,i)=>{const s=()=>{const e=i();return e.length>0&&e[0]},r=s();return r&&Wi(e,"samplerCube",t,r.encoding,(e=>{const t=s();t&&e(t.texture)}))},A=n("light",(()=>t.lightMaps)),o=n("reflection",(()=>t.reflectionMaps));return{getHash:()=>t.getHash(),getAmbientColor:()=>`${i}.rgb * ${i}.a`,directionalLights:r.map((e=>e.glslLight)),getIrradiance:A&&(e=>`${A(e)}.rgb`),getReflection:o&&((e,t)=>`${o(e,t)}.rgb`)}},Wi=(e,t,i,s,r)=>{const n=e.createUniform(t,i+"Map",r);return(e,t)=>{const i=t?`texture(${n}, ${e}, ${t})`:`texture(${n}, ${e})`;return 3e3!==s?`${Ni[s]}(${i})`:i}},zi=function(e,t){const i={},s=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<s;++r){const n=e.getActiveAttrib(t,r),A=e.getAttribLocation(t,n.name);i[n.name]=function(t){t.bindAtLocation(A),e.enableVertexAttribArray(A);const i=t.attributeDivisor;i&&e.vertexAttribDivisor(A,i)},i[n.name].attributeHash=`${A.toString().padStart(1+Math.floor(Math.log10(s)),"0")}:${n.name}`}const r=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<r;++s){const r=e.getActiveUniformBlockName(t,s),n=e.getUniformBlockIndex(t,r),A=s;e.uniformBlockBinding(t,n,A);const o=e.createBuffer();i[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 s=0;s<n;++s){const r=e.getActiveUniform(t,s);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++;i[n]=function(i){const s=i.bind(t);return s&&e.uniform1i(o,t),s}}else i[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=i[e];if(!t)throw`Missing input "${e}"`;return t}},Xi=V.vec4(),Ki=V.vec4();class Zi{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 Ji=V.OBB3(),Yi=V.vec4(),$i=V.vec4(),qi=V.vec4(),es=V.vec3([1,0,0]),ts=V.vec3([0,1,0]),is=V.vec3([0,0,1]),ss=V.vec3(3),rs=V.vec3(3),ns=V.identityMat4(),As=new e({}),os={};class as extends Ae{constructor(e,t={}){super(e,t),this.renderOrder=t.renderOrder||0,this.originalSystemId=t.originalSystemId||this.id,this.renderFlags=new Zi,this._state=new Se({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:V.vec3(),origin:null,originHash:null,isUI:t.isUI});const i=t.material?this._checkComponent2(["PhongMaterial","MetallicMaterial","SpecularMaterial","LambertMaterial"],t.material):this.scene.material,s=this,r=e=>{let t=null;const i=()=>{if(!t){const i=Gi(),r=i.programVariables.createAttribute,n=s._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(i.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,s.scene.canvas.canvas.id,s.scene._sectionPlanesState.getHash(),s._geometry._state.hash].concat(h.getHash()).join(";");if(!(u in os)){const e=cs(s,A,{decodedUv:c,worldNormal:a,viewNormal:l},h,i);if(e.errors)return void console.log(e.errors.join("\n"));const t=As.addItem({});os[u]={drawMesh:e.drawMesh,id:t,useCount:0,delete:()=>{As.removeItem(t),e.destroy(),delete os[u],G.memory.programs--}},G.memory.programs++}t=os[u],t.useCount++}};return{get:i,getId:()=>t.id,put:()=>{t&&(0==--t.useCount&&t.delete(),t=null)},drawMesh:(e,s,r)=>{i(),t&&t.drawMesh(e,s,r)}}},n=s.scene,A=e=>(t,i)=>function(e,t,i,s,r){const n=r&&ji(t,s._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=i.attributes,t=r&&[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(i.viewMatrix,e.position.view)}), 0.0) * ${t.getColor()})`)):[]);return`vec4(${A}${t?` * (${t.join(" + ")})`:""}, ${o})`})),l=t.createOutput("vec4","outColor");return{getHash:()=>[e,s.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};`)}}(s._state.hash,t,i,n,e);this._renderers={_drawRenderer:r(((e,t)=>"LambertMaterial"===i.type?function(e,t,i,s,r){const n=ji(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=i.attributes,t=[n.getAmbientColor()].concat(e.normal?n.directionalLights.map((t=>`(max(dot(${e.normal.view}, ${t.getDirection(i.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(),s._state.hash],programName:"Lambert",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t)=>e.push(`${h} = ${t?t(c):c};`)}}(s._state.drawHash,e,t,i,n):function(e,t,i,s,r){const n=s._state,A="PhongMaterial"===n.type,o="MetallicMaterial"===n.type,a="SpecularMaterial"===n.type,l=i.attributes,c=ji(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,i,r)=>{const n=(i,s,n)=>t.createUniform(i,e+"Fresnel"+s,((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(s)&&((e,t)=>`mix(${l+i}, ${c+i}, ${u}(${e}, ${t}, ${A}, ${o}, ${a}))`)},f=d("diffuse","",(e=>e._diffuseFresnel)),p=d("specular","",(e=>e._specularFresnel)),g=d("emissive","",(e=>e._emissiveFresnel)),m=d("alpha",".r",(e=>e._alphaFresnel)),_=(e,i)=>{const r=l.uv&&i(s),n=r&&Wi(t,"sampler2D",e,r.encoding,((e,t)=>e(i(t.material)._state.texture)));return n&&function(){const s=r._state.matrix&&t.createUniform("mat4",e+"MapMatrix",((e,t)=>e(i(t.material)._state.matrix))),A=s?e=>`(${s} * ${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)),U=_("specular",(e=>e._specularMap)),x=_("glossiness",(e=>e._glossinessMap)),I=_("specularGlossiness",(e=>e._specularGlossinessMap)),T=_("normal",(e=>e._normalMap)),P=(e,i,r)=>{const n=r(s);return("float"===i?null!=n:n)&&t.createUniform(i,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?(Xi[0]=t,Xi[1]=1===e.alphaMode?1:0,Xi[2]=e.alphaCutoff,Xi):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,s)=>({vViewLightReverseDir:t.createVarying("vec3",`vViewLightReverseDir${s}`,(()=>e.getDirection(i.viewMatrix,null))),vShadowPosFromLight:t.createVarying("vec3",`vShadowPosFromLight${s}`,(()=>`(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(),s._state.hash],programName:"Draw",canActAsBackground:!0,discardPoints:!0,setupPointSize:!0,setsLineWidth:!0,appendFragmentOutputs:(e,t,s)=>{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)&&U&&e.push(`specular *= ${U(W)}.rgb;`),a&&x&&e.push(`glossiness *= ${x(W)}.r;`),a&&I&&(e.push("vec4 specGlossTexel = "+I(W)+";"),e.push("specular *= specGlossTexel.rgb;"),e.push("glossiness *= specGlossTexel.a;"));const t=`normalize(${X})`,s=(A||o||a)&&T?`${ee}(${j}, ${t}, ${T.getTexCoordExpression(W)}, ${T(W)})`:t;if(e.push(`vec3 viewNormal = ${s};`),e.push(`vec3 viewEyeDir = normalize(-${j});`),f&&e.push(`diffuseColor *= ${f("viewEyeDir","viewNormal")};`),p&&e.push(`specular *= ${p("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)",s=A?`0.2 * PI * ${c.getReflection(t)}`:function(){const e=`${q}(viewNormal, viewEyeDir, specular, roughness)`,s=`normalize((vec4(${t}, 0.0) * ${i.viewMatrix}).xyz)`;return`${e} * ${c.getReflection(s,"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 += ${s};`)}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,i)=>{if(t.shadowParameters){const s="0.007";e.push(`fragmentDepth = ${K[i].vShadowPosFromLight}.z - ${s};`),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[i].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${i} = ${t.getColor()}${t.shadowParameters?" * shadow":""};`),e.push(`vec3 lightDirection${i} = ${t.isViewSpace?t.getDirection(null,j):K[i].vViewLightReverseDir};`);const s=`${Y}(dot(viewNormal, lightDirection${i}))`;e.push(`vec3 irradiance${i} = ${s} * lightColor${i};`),e.push(`reflDiff += irradiance${i};`);const r=A?`lightColor${i} * specular * pow(max(dot(reflect(-lightDirection${i}, -viewNormal), viewEyeDir), 0.0), shininess)`:`irradiance${i} * PI * ${$}(lightDirection${i}, 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"};`)}}}(s._state.drawHash,e,t,i,n))),_shadowRenderer:r((e=>function(e,t){const i=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("}")})),s=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Shadow",setsLineWidth:!0,useShadowView:!0,dontBillboardAnything:!0,dontGetLogDepth:!0,appendFragmentOutputs:(e,t,r)=>e.push(`${s} = ${i}(${r}.z);`)}}(s._state.hash,e))),_emphasisEdgesRenderer:r(A(!1)),_emphasisFillRenderer:r(A(!0)),_pickMeshRenderer:r((e=>function(e,t){const i=t.createUniform("vec4","pickColor",((e,t)=>{var i=t.meshPickID;Ki[0]=255&i,Ki[1]=i>>8&255,Ki[2]=i>>16&255,Ki[3]=i>>24&255,V.mulVec4Scalar(Ki,1/255,Ki),e(Ki)})),s=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickMesh",isPick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${s} = ${i};`)}}(s._state.hash,e))),_pickTriangleRenderer:r(((e,t)=>function(e,t,i){const s=t.createVarying("vec4","vColor",(()=>i.attributes.pickColor)),r=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"PickTriangle",isPick:!0,trianglePick:!0,dontBillboardAnything:!0,appendFragmentOutputs:e=>e.push(`${r} = ${s};`)}}(s._state.hash,e,t))),_occlusionRenderer:r((e=>function(e,t){const i=t.createOutput("vec4","outColor");return{getHash:()=>[e],programName:"Occlusion",skipIfTransparent:!0,appendFragmentOutputs:e=>e.push(`${i} = vec4(0.0, 0.0, 1.0, 1.0);`)}}(s._state.pickOcclusionHash,e)))},this._geometry=t.geometry?this._checkComponent2(["ReadableGeometry","VBOGeometry"],t.geometry):this.scene.geometry,this._material=i,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=V.vec3(),this._quaternion=V.identityQuaternion(),this._rotation=V.vec3(),this._position=V.vec3(),this._worldMatrix=V.identityMat4(),this._worldNormalMatrix=V.identityMat4(),this._localMatrixDirty=!0,this._worldMatrixDirty=!0,this._worldNormalMatrixDirty=!0;const o=t.origin||t.rtcCenter;if(o&&(this._state.origin=V.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]),V.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]),V.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=V.identityMat4()),V.composeMat4(this._position,this._quaternion,this._scale,this.__localMatrix),this._localMatrixDirty=!1),this.__localMatrix}set matrix(e){this.__localMatrix||(this.__localMatrix=V.identityMat4()),this.__localMatrix.set(e||ns),V.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=V.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 i=!!e;this.scene._objectColorizeUpdated(this,i),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 i=null!=e;t[3]=i?e:1,this.scene._objectOpacityUpdated(this,i),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,i=[e.canvas.canvas.id,e._sectionPlanesState.getHash()];t.stationary&&i.push("/s"),"none"===t.billboard?i.push("/n"):"spherical"===t.billboard?i.push("/s"):"cylindrical"===t.billboard&&i.push("/c"),i.push(";");const s=i.concat([e.gammaOutput?"go":"",e._lightsState.getHash(),t.receivesShadow?"/rs":""]).join("");this._state.drawHash!==s&&(this._state.drawHash=s,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=i.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)V.mulMat4(this._parentNode.worldMatrix,e,this._worldMatrix);else for(let t=0,i=e.length;t<i;t++)this._worldMatrix[t]=e[t];this._worldMatrixDirty=!1}_buildWorldNormalMatrix(){this._worldMatrixDirty&&this._buildWorldMatrix(),this._worldNormalMatrix||(this._worldNormalMatrix=V.mat4()),V.transposeMat4(this._worldMatrix,this._worldNormalMatrix),V.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=V.AABB3()),this._buildAABB(this.worldMatrix,this._aabb),this._aabbDirty=!1}_buildAABB(e,t){V.transformOBB3(e,this._geometry.obb,Ji),V.OBB3ToAABB3(Ji,t);const i=this._state.offset;if(t[0]+=i[0],t[1]+=i[1],t[2]+=i[2],t[3]+=i[0],t[4]+=i[1],t[5]+=i[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 Yi[0]=e[0],Yi[1]=e[1],Yi[2]=e[2],Yi[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(Yi,$i),V.mulQuaternions(this.quaternion,$i,qi),this.quaternion=qi,this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}rotateOnWorldAxis(e,t){return Yi[0]=e[0],Yi[1]=e[1],Yi[2]=e[2],Yi[3]=t*V.DEGTORAD,V.angleAxisToQuaternion(Yi,$i),V.mulQuaternions($i,this.quaternion,$i),this}rotateX(e){return this.rotate(es,e)}rotateY(e){return this.rotate(ts,e)}rotateZ(e){return this.rotate(is,e)}translate(e,t){return V.vec3ApplyQuaternion(this.quaternion,e,ss),V.mulVec3Scalar(ss,t,rs),V.addVec3(this.position,rs,this.position),this._setLocalMatrixDirty(),this._setAABBDirty(),this.glRedraw(),this}translateX(e){return this.translate(es,e)}translateY(e){return this.translate(ts,e)}translateZ(e){return this.translate(is,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 i=0;i<t;i++){const t=e[i],s=this.renderFlags;if(t.active)if(this._state.origin){const e=V.planeAABB3Intersect(t.dir,t.dist,this.aabb);if(-1===e)return!1;const r=0===e;s.sectionPlanesActivePerLayer[i]=r}else s.sectionPlanesActivePerLayer[i]=!0;else s.sectionPlanesActivePerLayer[i]=!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,i,s){ls(this,e,t,i,s)}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 ls=function(){const e=V.vec3(),t=V.vec3(),i=V.vec3(),s=V.vec3(),r=V.vec3(),n=V.vec3(),A=V.vec4(),o=V.vec3(),a=V.vec3(),l=V.vec3(),c=V.vec3(),h=V.vec3(),u=V.vec3(),d=V.vec3(),f=V.vec3(),p=V.vec3(),g=V.vec4(),m=V.vec4(),_=V.vec4(),b=V.vec3(),B=V.vec3(),y=V.vec3(),w=V.vec3(),v=V.vec3(),C=V.vec3(),M=V.vec3(),E=V.vec3(),F=V.vec3(),U=V.vec3(),x=V.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],R=j[H+1],O=j[H+2];n[0]=Q,n[1]=R,n[2]=O,D.indices=n,z=3*Q,X=3*R,K=3*O}else z=3*H,X=z+3,K=X+3;if(i[0]=W[z+0],i[1]=W[z+1],i[2]=W[z+2],s[0]=W[X+0],s[1]=W[X+1],s[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&&(Ne.decompressPosition(i,e,i),Ne.decompressPosition(s,e,s),Ne.decompressPosition(r,e,r))}D.canvasPos?V.canvasPosToLocalRay(G.canvas,I.origin?wt(T,I.origin):T,P,S,I.worldMatrix,D.canvasPos,e,t):D.origin&&D.direction&&V.worldRayToLocalRay(I.worldMatrix,D.origin,D.direction,e,t),V.normalizeVec3(t),V.rayPlaneIntersect(e,t,i,s,r,A),D.localPos=A,D.position=A,g[0]=A[0],g[1]=A[1],g[2]=A[2],g[3]=1,V.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,V.transformVec4(N.matrix,m,_),a[0]=_[0],a[1]=_[1],a[2]=_[2],D.viewPos=a,V.cartesianToBarycentric(A,i,s,r,l),D.bary=l;const Z=L.normals;if(Z){if(L.compressGeometry){const e=3*Q,t=3*R,i=3*O;Ne.decompressNormal(Z.subarray(e,e+2),c),Ne.decompressNormal(Z.subarray(t,t+2),h),Ne.decompressNormal(Z.subarray(i,i+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=V.addVec3(V.addVec3(V.mulVec3Scalar(c,l[0],b),V.mulVec3Scalar(h,l[1],B),y),V.mulVec3Scalar(u,l[2],w),v);D.worldNormal=V.normalizeVec3(V.transformVec3(I.worldNormalMatrix,e,C))}const J=L.uv;if(J){if(d[0]=J[2*Q],d[1]=J[2*Q+1],f[0]=J[2*R],f[1]=J[2*R+1],p[0]=J[2*O],p[1]=J[2*O+1],L.compressGeometry){const e=L.uvDecodeMatrix;e&&(Ne.decompressUV(d,e,d),Ne.decompressUV(f,e,f),Ne.decompressUV(p,e,p))}D.uv=V.addVec3(V.addVec3(V.mulVec2Scalar(d,l[0],M),V.mulVec2Scalar(f,l[1],E),F),V.mulVec2Scalar(p,l[2],U),x)}}}}}(),cs=(e,t,i,s,r)=>{const n=r.programVariables,A=i.decodedUv,o=i.worldNormal,a=i.viewNormal,l=e.scene,c=l.canvas.gl,h=e._state.background,u=e._geometry._state,d=u.compressGeometry,f="points"===u.primitiveName,p=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=!s.dontBillboardAnything&&("spherical"===M||"cylindrical"===M),F=e.stationary,U=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)))),x=function(){const e=U&&n.createVertexDefinition("billboard",U);return t=>e?`${e}(${t})`:t}(),I=function(){const e=U&&n.createFragmentDefinition("billboard",U);return t=>e?`${e}(${t})`:t}(),T=[];s.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,s.programName,{appendFragmentOutputs:(e,t,i,r)=>{T.forEach((t=>e.push(t))),s.appendFragmentOutputs(e,t,i,r)},clippableTest:()=>S,clippingCaps:s.clippingCaps,clipPos:h?"clipPos.xyww":P,crossSections:l.crossSections,discardPoints:f&&s.discardPoints,getGammaFactor:l.gammaOutput&&(()=>l.gammaFactor),getLogDepth:!s.dontGetLogDepth&&l.logarithmicDepthBufferEnabled&&(e=>e),getPointSize:s.setupPointSize&&f&&(()=>p),getVertexData:function(){const e=a&&a.needed&&`vec3 ${a} = normalize((${x(v)} * vec4(${o}, 0.0)).xyz);`,i=[];if(i.push(`vec4 localPosition = vec4(${t.position}, 1.0);`),d&&i.push(`localPosition = ${B} * localPosition;`),i.push(`vec4 worldPosition = ${x(g)} * localPosition;`),i.push(`worldPosition.xyz = worldPosition.xyz + ${_};`),s.dontBillboardAnything?i.push(`vec4 viewPosition = ${w} * worldPosition;`):(i.push(`mat4 viewMatrix1 = ${w};`),F?i.push("viewMatrix1[3].xyz = vec3(0.0, 0.0, 0.0);"):h&&i.push("viewMatrix1[3] = vec4(0.0, 0.0, 0.0, 1.0);"),i.push(`mat4 viewMatrix2 = ${x("viewMatrix1")};`),i.push(`vec4 viewPosition = ${E?`${x(`viewMatrix1 * ${g}`)} * localPosition`:"viewMatrix2 * worldPosition"};`)),A&&A.needed&&i.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;i.push(`vec3 ${o} = (${x(m)} * vec4(${e}, 0.0)).xyz;`)}return e&&i.push(e),i.push(`vec4 clipPos = ${C} * viewPosition;`),i},projMatrix:C,sectionPlanesState:l._sectionPlanesState,testPerspectiveForGl_FragDepth:!0,usePickClipPos:s.isPick,worldPositionAttribute:"worldPosition"});if(k)return{errors:k};{const e=D.inputSetters;let i=null,r=null;return{destroy:()=>D.destroy(),drawMesh:(n,A,o)=>{if(s.skipIfTransparent&&o.alpha<1)return;const a=o._state,l=A._state,u=A._geometry,d=u._state,f=n.viewParams,M=s.canActAsBackground&&h;n.lastProgramId!==D.id&&(n.lastProgramId=D.id,D.bind(),n.useProgram++,i=null,r=null,M&&c.depthFunc(c.LEQUAL)),a.id!==i&&(n.backfaces!==a.backfaces&&(a.backfaces?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE),n.backfaces=a.backfaces),s.dontSetFrontFace||n.frontface===a.frontface||(c.frontFace(a.frontface?c.CCW:c.CW),n.frontface=a.frontface),s.drawEdges&&n.lineWidth!==a.edgeWidth&&(c.lineWidth(a.edgeWidth),n.lineWidth=a.edgeWidth),s.setsLineWidth&&n.lineWidth!==a.lineWidth&&(c.lineWidth(a.lineWidth),n.lineWidth=a.lineWidth),i=a.id);const E=!s.useShadowView&&A.origin;((t,i)=>{const s=(e,t)=>e.setInputValue&&e.setInputValue(t);s(p,o.pointSize),s(g,A.worldMatrix),s(m,A.worldNormalMatrix),s(_,A.offset),s(b,A.scale),s(B,d.positionsDecodeMatrix),s(y,d.uvDecodeMatrix),s(w,i),s(v,f.viewNormalMatrix),s(C,t),s(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:f.far}})})(f.projMatrix,E?n.getRTCViewMatrix(l.originHash,E):f.viewMatrix);const F=e=>{const i=(e,t)=>{e&&e.setInputValue&&t&&(e.setInputValue(t),n.bindArray++)};i(t.position,(e||d).positionsBuf),i(t.color,d.colorsBuf),i(t.pickColor,e&&e.pickColorsBuf),i(t.uv,d.uvBuf),i(t.normal,d.normalsBuf)};if(s.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(s.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 hs extends Ae{get type(){return"Material"}constructor(e,t={}){super(e,t),G.memory.materials++}destroy(){super.destroy(),G.memory.materials--}}const us={opaque:0,mask:1,blend:2},ds=["opaque","mask","blend"];class fs extends hs{get type(){return"PhongMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"PhongMaterial",ambient:V.vec3([1,1,1]),diffuse:V.vec3([1,1,1]),specular:V.vec3([1,1,1]),emissive:V.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=us[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 ds[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 ps(e,t){if(void 0===e._cachedExtensions&&(e._cachedExtensions={}),void 0!==e._cachedExtensions[t])return e._cachedExtensions[t];let i;switch(t){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(t)}return e._cachedExtensions[t]=i,i}function gs(e,t,i=null){let s;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===i){const t=ps(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(s=ps(e,"WEBGL_compressed_texture_s3tc"),null===s)return null;if(33776===r)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===r)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===r)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===r)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===r||35841===r||35842===r||35843===r){const t=ps(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=ps(e,"WEBGL_compressed_texture_etc1");return null!==t?t.COMPRESSED_RGB_ETC1_WEBGL:null}if(37492===r||37496===r){const t=ps(e,"WEBGL_compressed_texture_etc");if(null===t)return null;if(37492===r)return 3001===i?t.COMPRESSED_SRGB8_ETC2:t.COMPRESSED_RGB8_ETC2;if(37496===r)return 3001===i?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=ps(e,"WEBGL_compressed_texture_astc");if(null===t)return null;if(37808===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:t.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:t.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:t.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:t.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:t.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:t.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:t.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:t.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:t.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:t.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:t.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:t.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:t.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===r)return 3001===i?t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:t.COMPRESSED_RGBA_ASTC_12x12_KHR}if(36492===r){const t=ps(e,"EXT_texture_compression_bptc");if(null===t)return null;if(36492===r)return 3001===i?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 ms=new Uint8Array([0,0,0,1]);class _s{constructor({gl:e,target:t,format:i,type:s,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=i||1023,this.type=s||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?(ms[0]=Math.floor(255*e[0]),ms[1]=Math.floor(255*e[1]),ms[2]=Math.floor(255*e[2]),ms[3]=Math.floor(255*(void 0!==e[3]?e[3]:1))):(ms[0]=0,ms[1]=0,ms[2]=0,ms[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 i=0,s=e.length;i<s;i++)t.texImage2D(e[i],0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ms)}else t.texImage2D(this.target,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ms);t.bindTexture(this.target,null)}setTarget(e){this.target=e||this.gl.TEXTURE_2D}setImage(e,t={}){const i=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 s=!1;i.bindTexture(this.target,this.texture);const r=i.getParameter(i.UNPACK_FLIP_Y_WEBGL);i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,this.flipY);const n=i.getParameter(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL);i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);const A=i.getParameter(i.UNPACK_ALIGNMENT);i.pixelStorei(i.UNPACK_ALIGNMENT,this.unpackAlignment);const o=i.getParameter(i.UNPACK_COLORSPACE_CONVERSION_WEBGL);i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);const a=gs(i,this.minFilter);i.texParameteri(this.target,i.TEXTURE_MIN_FILTER,a),a!==i.NEAREST_MIPMAP_NEAREST&&a!==i.LINEAR_MIPMAP_NEAREST&&a!==i.NEAREST_MIPMAP_LINEAR&&a!==i.LINEAR_MIPMAP_LINEAR||(s=!0);const l=gs(i,this.magFilter);l&&i.texParameteri(this.target,i.TEXTURE_MAG_FILTER,l);const c=gs(i,this.wrapS);c&&i.texParameteri(this.target,i.TEXTURE_WRAP_S,c);const h=gs(i,this.wrapT);h&&i.texParameteri(this.target,i.TEXTURE_WRAP_T,h);const u=gs(i,this.format,this.encoding),d=gs(i,this.type),f=bs(i,this.internalFormat,u,d,this.encoding,!1);if(this.target===i.TEXTURE_CUBE_MAP){if(X.isArray(e)){const t=e,s=[i.TEXTURE_CUBE_MAP_POSITIVE_X,i.TEXTURE_CUBE_MAP_NEGATIVE_X,i.TEXTURE_CUBE_MAP_POSITIVE_Y,i.TEXTURE_CUBE_MAP_NEGATIVE_Y,i.TEXTURE_CUBE_MAP_POSITIVE_Z,i.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(let e=0,r=s.length;e<r;e++)i.texImage2D(s[e],0,f,u,d,t[e])}}else i.texImage2D(i.TEXTURE_2D,0,f,u,d,e);s&&i.generateMipmap(this.target),i.bindTexture(this.target,null),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,r),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n),i.pixelStorei(i.UNPACK_ALIGNMENT,A),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,o)}setCompressedData({mipmaps:e,props:t={}}){const i=this.gl,s=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),i.activeTexture(i.TEXTURE0+0),i.bindTexture(this.target,this.texture);let r=e.length>1;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,this.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,this.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);const n=gs(i,this.wrapS);n&&i.texParameteri(this.target,i.TEXTURE_WRAP_S,n);const A=gs(i,this.wrapT);if(A&&i.texParameteri(this.target,i.TEXTURE_WRAP_T,A),this.type===i.TEXTURE_3D||this.type===i.TEXTURE_2D_ARRAY){const e=gs(i,this.wrapR);e&&i.texParameteri(this.target,i.TEXTURE_WRAP_R,e),i.texParameteri(this.type,i.TEXTURE_WRAP_R,e)}r?(i.texParameteri(this.target,i.TEXTURE_MIN_FILTER,Bs(i,this.minFilter)),i.texParameteri(this.target,i.TEXTURE_MAG_FILTER,Bs(i,this.magFilter))):(i.texParameteri(this.target,i.TEXTURE_MIN_FILTER,gs(i,this.minFilter)),i.texParameteri(this.target,i.TEXTURE_MAG_FILTER,gs(i,this.magFilter)));const o=gs(i,this.format,this.encoding),a=gs(i,this.type),l=bs(i,this.internalFormat,o,a,this.encoding,!1);i.texStorage2D(i.TEXTURE_2D,s,l,e[0].width,e[0].height);for(let t=0,s=e.length;t<s;t++){const s=e[t];1023!==this.format?null!==o?i.compressedTexSubImage2D(i.TEXTURE_2D,t,0,0,s.width,s.height,o,s.data):console.warn("Attempt to load unsupported compressed texture format in .setCompressedData()"):i.texSubImage2D(i.TEXTURE_2D,t,0,0,s.width,s.height,o,a,s.data)}i.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 i=gs(t,e.minFilter);i&&(this.minFilter=e.minFilter,t.texParameteri(this.target,t.TEXTURE_MIN_FILTER,i),i!==t.NEAREST_MIPMAP_NEAREST&&i!==t.LINEAR_MIPMAP_NEAREST&&i!==t.NEAREST_MIPMAP_LINEAR&&i!==t.LINEAR_MIPMAP_LINEAR||t.generateMipmap(this.target))}if(void 0!==e.magFilter){const i=gs(t,e.magFilter);i&&(this.magFilter=e.magFilter,t.texParameteri(this.target,t.TEXTURE_MAG_FILTER,i))}if(void 0!==e.wrapS){const i=gs(t,e.wrapS);i&&(this.wrapS=e.wrapS,t.texParameteri(this.target,t.TEXTURE_WRAP_S,i))}if(void 0!==e.wrapT){const i=gs(t,e.wrapT);i&&(this.wrapT=e.wrapT,t.texParameteri(this.target,t.TEXTURE_WRAP_T,i))}}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 bs(e,t,i,s,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=i;return i===e.RED&&(s===e.FLOAT&&(A=e.R32F),s===e.HALF_FLOAT&&(A=e.R16F),s===e.UNSIGNED_BYTE&&(A=e.R8)),i===e.RG&&(s===e.FLOAT&&(A=e.RG32F),s===e.HALF_FLOAT&&(A=e.RG16F),s===e.UNSIGNED_BYTE&&(A=e.RG8)),i===e.RGBA&&(s===e.FLOAT&&(A=e.RGBA32F),s===e.HALF_FLOAT&&(A=e.RGBA16F),s===e.UNSIGNED_BYTE&&(A=3001===r&&!1===n?e.SRGB8_ALPHA8:e.RGBA8),s===e.UNSIGNED_SHORT_4_4_4_4&&(A=e.RGBA4),s===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||ps(e,"EXT_color_buffer_float"),A}function Bs(e,t){return 1003===t||1004===t||1005===t?e.NEAREST:e.LINEAR}function ys(e){if(!ws(e.width)||!ws(e.height)){const t=document.createElement("canvas");t.width=vs(e.width),t.height=vs(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function ws(e){return 0==(e&e-1)}function vs(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class Cs extends Ae{get type(){return"Texture"}constructor(e,t={}){super(e,t),this._state=new Se({texture:new _s({gl:this.scene.canvas.gl}),matrix:V.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=V.vec2([0,0]),this._scale=V.vec2([1,1]),this._rotate=V.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),G.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,i;0===this._translate[0]&&0===this._translate[1]||(t=V.translationMat4v([this._translate[0],this._translate[1],0],this._state.matrix)),1===this._scale[0]&&1===this._scale[1]||(i=V.scalingMat4v([this._scale[0],this._scale[1],1]),t=t?V.mulMat4(t,i):i),0!==this._rotate&&(i=V.rotationMat4v(.0174532925*this._rotate,[0,0,1]),t=t?V.mulMat4(t,i):i),t&&(e.matrix=t),this._matrixDirty=!1}this.glRedraw()}set image(e){this._image=ys(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 i=new Image;i.onload=function(){i=ys(i),t._state.texture.setImage(i,t._state),t.scene.loading--,t.glRedraw(),t.scene.canvas.spinner.processes--},i.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(),G.memory.textures--}}const Ms=V.vec3(),Es=V.vec3();V.vec3();const Fs=V.vec3([0,-1,0]),Us=V.vec4([0,0,0,1]);class xs extends Ae{constructor(e,t={}){super(e,t),this._src=null,this._image=null,this._pos=V.vec3(),this._origin=V.vec3(),this._rtcPos=V.vec3(),this._dir=V.vec3(),this._size=1,this._imageSize=V.vec2(),this._texture=new Cs(this),this._plane=new as(this,{geometry:new We(this,st({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new fs(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 as(this,{geometry:new We(this,it({size:1,divisions:10})),material:new fs(this,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:t.clippable}),this._node=new Bt(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]),vt(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,i=[-this._dir[0],-this._dir[1],-this._dir[2]];V.subVec3(t,this.position,Ms);const s=-V.dotVec3(i,Ms);V.normalizeVec3(i),V.mulVec3Scalar(i,s,Es),V.vec3PairToQuaternion(Fs,e,Us),this._node.quaternion=Us}}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],i=this._imageSize[1];if(t>i){const s=i/t;this._node.scale=[e,1,e*s]}else{const s=t/i;this._node.scale=[e*s,1,e]}}}class Is extends hs{get type(){return"LambertMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"LambertMaterial",ambient:V.vec3([1,1,1]),color:V.vec3([1,1,1]),emissive:V.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 Ts={opaque:0,mask:1,blend:2},Ps=["opaque","mask","blend"];class Ss extends hs{get type(){return"MetallicMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"MetallicMaterial",baseColor:V.vec4([1,1,1]),emissive:V.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=Ts[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 Ps[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 Ds={opaque:0,mask:1,blend:2},ks=["opaque","mask","blend"];class Qs extends hs{get type(){return"SpecularMaterial"}constructor(e,t={}){super(e,t),this._state=new Se({type:"SpecularMaterial",diffuse:V.vec3([1,1,1]),emissive:V.vec3([0,0,0]),specular:V.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=Ds[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 ks[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 Rs={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 Os extends hs{get type(){return"EmphasisMaterial"}get presets(){return Rs}constructor(e,t={}){super(e,t),this._state=new Se({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=Rs[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(Rs).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 Vs={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 Ls extends hs{get type(){return"EdgeMaterial"}get presets(){return Vs}constructor(e,t={}){super(e,t),this._state=new Se({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=Vs[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(Vs).join(", "))}get preset(){return this._preset}destroy(){super.destroy(),this._state.destroy()}}class Hs extends Ae{get type(){return"Fresnel"}constructor(e,t={}){super(e,t),this._state=new Se({edgeColor:V.vec3([0,0,0]),centerColor:V.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()}}class Ns extends Ae{constructor(e,t={}){super(e,t),this._type=t.type||(t.src?t.src.split(".").pop():null)||"jpg",this._pos=V.vec3(t.pos||[0,0,0]),this._up=V.vec3(t.up||[0,1,0]),this._normal=V.vec3(t.normal||[0,0,1]),this._height=t.height||1,this._origin=V.vec3(),this._rtcPos=V.vec3(),this._imageSize=V.vec2(),this._texture=new Cs(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 Bt(this,{matrix:V.inverseMat4(V.lookAtMat4v(this._pos,V.subVec3(this._pos,this._normal,V.mat4()),this._up,V.mat4())),children:[this._bitmapMesh=new as(this,{scale:[1,1,1],rotation:[-90,0,0],collidable:t.collidable,pickable:t.pickable,opacity:t.opacity,clippable:t.clippable,geometry:new We(this,st({center:[0,0,0],xSize:1,zSize:1,xSegments:2,zSegments:2})),material:new fs(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 Gs=(e,t)=>{const i=[];let s=[];function r(e,i){let s,r;for(let n=0;n<3;n++)if(s=t[3*e+n],r=t[3*i+n],s!==r)return r-s;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]),i[n[e]]=A;for(let t=0,r=e.length;t<r;t+=3){const r=i[e[t]],n=i[e[t+1]],A=i[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)),s[t+0]=[o,a],s[t+1]=[a,l],o>l){const e=l;l=o,o=e}s[t+2]=[l,o]}function o(e,t){let i,s;for(let r=0;r<2;r++)if(i=e[r],s=t[r],s!==i)return s-i;return 0}s=s.slice(0,e.length),s.sort(o);let a=0;for(let e=0;e<s.length;e++)if(0===e||0!==o(s[e],s[e-1])){if(0!==e&&2!==a)return!1;a=1}else a++;return!(s.length>0&&2!==a)},js=V.vec3(),Ws=V.vec3(),zs=V.vec3();class Xs{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&&!Gs(t,e))return-1;let i=0;for(let s=0;s<this.lenIndices;s+=3){const r=3*t[s],n=3*t[s+1],A=3*t[s+2];js[0]=e[r],js[1]=e[r+1],js[2]=e[r+2],Ws[0]=e[n],Ws[1]=e[n+1],Ws[2]=e[n+2],zs[0]=e[A],zs[1]=e[A+1],zs[2]=e[A+2],V.cross3Vec3(js,Ws,js),i+=V.dotVec3(js,zs)}return i/6}}const Ks=new Xs,Zs=V.vec3(),Js=V.vec3(),Ys=V.vec3(),$s=V.vec3(),qs=V.vec3(),er=V.vec3();class tr{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 i=0;for(let s=0;s<this.lenIndices;s+=3){const r=3*t[s],n=3*t[s+1],A=3*t[s+2];Zs[0]=e[r],Zs[1]=e[r+1],Zs[2]=e[r+2],Js[0]=e[n],Js[1]=e[n+1],Js[2]=e[n+2],Ys[0]=e[A],Ys[1]=e[A+1],Ys[2]=e[A+2],V.subVec3(Zs,Js,$s),V.subVec3(Ys,Js,qs),i+=.5*V.lenVec3(V.cross3Vec3($s,qs,er))}return i}}const ir=new tr,sr=V.OBB3(),rr=V.OBB3(),nr=V.OBB3();class Ar{constructor(e,t,i,s,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=V.AABB3(),this._aabbWorldDirty=!1,this.layer=A,this.portionId=o,this._color=new Uint8Array([i[0],i[1],i[2],s]),this._colorize=new Uint8Array([i[0],i[1],i[2],s]),this._colorizing=!1,this._transparent=s<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 i=e<255,s=this._transparent!==i;this._color[3]=e,this._colorize[3]=e,this._transparent=i,this._colorizing?this.layer.setColor(this.portionId,this._colorize):this.layer.setColor(this.portionId,this._color),s&&this.layer.setTransparent(this.portionId,t,i)}_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,i,s){return this.layer.precisionRayPickSurface(this.portionId,e,t,i,s)}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":Ks.reset(),Ks.setPrimitive(this.layer.primitive),this.getEachVertex((e=>{Ks.addVertex(e)})),this.getEachIndex((e=>{Ks.addIndex(e)})),this._volume=Ks.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":ir.reset(),this.getEachVertex((e=>{ir.addVertex(e)})),this.getEachIndex((e=>{ir.addIndex(e)})),this._surfaceArea=ir.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&&(V.AABB3ToOBB3(this._aabbLocal,sr),this.transform?(V.transformOBB3(this.transform.worldMatrix,sr,rr),V.transformOBB3(this.model.worldMatrix,rr,nr),V.OBB3ToAABB3(nr,this._aabbWorld)):(V.transformOBB3(this.model.worldMatrix,sr,rr),V.OBB3ToAABB3(rr,this._aabbWorld)),this._aabbWorldDirty=!1),this._aabbWorld}_destroy(){this.model.scene._renderer.putPickID(this.pickId),this.layer=null}}const or=1,ar=4,lr=8,cr=16,hr=32,ur=256,dr=512,fr=1024,pr=2048,gr=function(e,t,i,s){const r=s&&e.createUniform("vec4","edgeColor",((e,t)=>e(t.legacyFrameCtx.programColor))),n=t.attributes.color,A=!s&&e.createVarying("vec4","vColor",(()=>`vec4(${n}.rgb * 0.5, ${n}.a)`)),o=e.createOutput("vec4","outColor");return{programName:s?"Edges":"EdgesColor",getLogDepth:i&&(e=>e),renderPassFlag:2,appendFragmentOutputs:e=>e.push(`${o} = ${r||A};`)}},mr=function(e,t){const i=e.createOutput("vec4","outColor");return{programName:"Occlusion",getLogDepth:!1,renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${i} = vec4(0.0, 0.0, 1.0, 1.0);`)}},_r=function(e,t,i,s){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:i&&(e=>e),renderPassFlag:1,appendFragmentOutputs:(e,t,i,o)=>{e.push(`${A} = ${s?r:o(`vec4(${r}.rgb, min(${r}.a, ${n}))`)};`)}}},br=V.vec2(),Br=V.vec3(),yr=V.vec4(),wr=V.mat4(),vr=V.vec3([0,0,0]),Cr=0,Mr=1,Er=2,Fr=3,Ur=4,xr=5,Ir=6,Tr=7,Pr=8,Sr=9,Dr=10,kr=11,Qr=e=>[V.safeInv(e[0]),V.safeInv(e[1]),V.safeInv(e[2])],Rr=(e,t,i,s,r)=>{const n=!!(e&or),A=!!(e&ur),o=!!(e&dr),a=!!(e&fr),l=!!(e&pr),c=!!(e&lr),h=!!(e&ar);let u,d;u=!n||h||A||o&&!s.highlightMaterial.glowThrough||a&&!s.selectedMaterial.glowThrough?Cr:t?Er:Mr,d=!n||h?Cr:a?Ur:o?Fr:A?xr:Cr;let f=0;f=i&&n&&!h?a?Sr:o?Pr:A?Dr:l?t?Tr:Ir:Cr:Cr;const p=n&&!h&&c?kr:Cr;r[0]=u,r[1]=d,r[2]=f,r[3]=p},Or=function(){const e={};return function(t,i,s,r,n,A,o,a){const l=[i,"points"===s||"lines"===s?s:"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=Gi(),o=A.programVariables,l=a(o,n);return r(o,l.geometryParameters,(function(r,a){const c=t.pointsMaterial,h="points"===s&&!n,u=()=>[t._sectionPlanesState.getHash()].concat(h?[c.hash]:[]).concat(r.getHash?r.getHash():[]).join(";"),d=u(),f=()=>d===u(),p=l.geometryParameters,g=r.incrementDrawState,m=r.isShadowProgram,_=p.attributes,b=_.position.world,B="clipPos",[y,w]=A.buildProgram(e,i+" "+s+" "+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 i=o.createUniform("float","nearPlaneHeight",((e,t)=>e(t.legacyFrameCtx.nearPlaneHeight))),s=`${Math.floor(c.minPerspectivePointSize)}.0`,r=`${Math.floor(c.maxPerspectivePointSize)}.0`;e.push(`clamp((${i} * ${t}) / gl_Position.w, ${s}, ${r})`)}else e.push(t)}else n&&n.vertices&&e.push("1.0");return r.incPointSizeBy10&&"points"===s&&e.push("10.0"),e.length>0&&(()=>e.join(" + "))}(),getVertexData:()=>{const e=_.color,t=_.flags[r.renderPassFlag],i=o.createUniform("int","renderPass",((e,t)=>e(t.renderPass))),n=[`if (${m?`(${t} <= 0) || (${e}.a < 1.0)`:`${t} != ${i}`}) {`,` 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"===s&&c.filterIntensity?function(){const t=o.createUniform("vec2","intensityRange",(e=>{br[0]=c.minIntensity,br[1]=c.maxIntensity,e(br)}));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=p.attributes.position.view;return A.push(`vec4 ${a} = ${p.viewMatrix} * ${b};`),A.push(`vec4 clipPos = ${p.projMatrix} * ${a};`),A},projMatrix:p.projMatrix,sectionPlanesState:t._sectionPlanesState,testPerspectiveForGl_FragDepth:"points"!==s&&"lines"!==s||n,usePickClipPos:a,worldPositionAttribute:b});return w?(console.error(w),{getValid:f,destroy:()=>{},drawLayer:(e,t,i)=>{}}):{getValid:f,destroy:()=>y.destroy(),drawLayer:(e,t,i)=>{e.lastProgramId!==y.id&&(e.lastProgramId=y.id,y.bind());const s=t.origin,r=t.model,A=e.viewParams,o=Br;V.transformPoint3(r.matrix,s,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:i,view:{eye:A.eye,far:A.far,projMatrix:c,viewMatrix:V.compareVec3(o,vr)?a:wt(a,o,wr),viewNormalMatrix:A.viewNormalMatrix}};y.inputSetters.setUniforms(e,h),t.drawCalls[n?n.vertices?"drawVertices":"drawEdges":"drawSurface"](y.inputSetters.attributesHash,l.layerTypeInputs,{projMatrix:c,viewMatrix:V.compareVec3(o,vr)?a:wt(a,o,wr),viewNormalMatrix:A.viewNormalMatrix,eye:A.eye}),g&&e.drawElements++}}}))};let l=A&&o();return{drawLayer:(e,t,i)=>{l||(l=o()),l.drawLayer(e,t,i)},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),f=(e,i,r,n)=>function(e,t,i,s,r,n){const A=e.createVarying("vec4","vColor",(()=>{const e=t.attributes,i="points"===n?`vec4(${e.color}.rgb, 1.0)`:`${e.color}`;return s?`vec4(${[s.getAmbientColor()].concat(s.directionalLights.map((i=>`max(dot(${e.normal.view}, ${i.getDirection(t.viewMatrix,e.position.view)}), 0.0) * ${i.getColor()}`))).join(" + ")}, 1) * ${i}`:i})),o=e.createOutput("vec4","outColor");return{programName:"Color",getHash:()=>[s?s.getHash():"-",r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:i&&(e=>"points"!==n&&"lines"!==n?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e),renderPassFlag:0,appendFragmentOutputs:(e,t,i,s)=>{"points"===n||"lines"===n?e.push(`${o} = ${A};`):(e.push(`vec4 fragColor = ${s(A)};`),e.push(`${o} = ${r?`vec4(fragColor.rgb * ${r.getAmbient(i)}, fragColor.a)`:"fragColor"};`))},filterIntensityRange:!0,incrementDrawState:!0}}(e,i,t.logarithmicDepthBufferEnabled,r,n,s),p=(e,i,s)=>s(function(e,t,i){const s=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:i&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,appendFragmentOutputs:e=>{e.push(`float zNormalizedDepth = abs((${r} + ${n}.z) / (${s} - ${r}));`),e.push(`${A} = ${o}(zNormalizedDepth);`)}}}(e,i,t.logarithmicDepthBufferEnabled),!0),g=(e,i,s)=>s(function(e,t,i){const s=e.createVarying("vec4","vPickColor",(()=>`${t.attributes.pickColor} / 255.0`)),r=e.createOutput("vec4","outPickColor");return{programName:"PickMesh",getLogDepth:i&&(e=>e),renderPassFlag:3,incPointSizeBy10:!0,dontCullOnAlphaZero:!0,appendFragmentOutputs:e=>e.push(`${r} = ${s};`)}}(e,i,t.logarithmicDepthBufferEnabled),!0),m=(e,i,s,r)=>s(function(e,t,i,s){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:s?"PickNormalsFlat":"PickNormals",getLogDepth:i&&(e=>e),renderPassFlag:3,appendFragmentOutputs:e=>{const t=s?`normalize(cross(dFdx(${r}), dFdy(${r})))`:n;e.push(`${A} = ivec4(${t} * float(${V.MAX_INT}), 1.0);`)}}}(e,i,t.logarithmicDepthBufferEnabled,r),!0),_=(e,t,i,s,r)=>i(function(e,t,i,s){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:i?"SnapInit":"Snap",getLogDepth:e=>i?`${e} + length(vec2(dFdx(${e}), dFdy(${e})))`:e,renderPassFlag:3,vertexCullX:!i&&"2.0",dontCullOnAlphaZero:!i,appendFragmentOutputs:e=>{e.push(`${a} = ivec4(${A} * ${n}.xyz, ${i?"-":""}${r});`),i&&(e.push(`${l} = ${s?"ivec4(1.0)":`ivec4(normalize(cross(dFdx(${A}), dFdy(${A}))) * float(${V.MAX_INT}), 1.0)`};`),e.push(`${c} = uvec4(${o});`))}}}(e,t,s,r),!0);c[h]="points"===s?{colorRenderers:{"sao-":{vertex:d(((e,t,i)=>i(f(e,t,null,null))))}},occlusionRenderer:d(((e,i,s)=>s(mr(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:d(p),pickMeshRenderer:d(g),silhouetteRenderer:d(((e,i,s)=>s(_r(e,i,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,i)=>_(e,t,i,!0,!0))),snapVertexRenderer:d(((e,t,i)=>_(e,t,i,!1,!0)),{vertices:!0})}:"lines"===s?{colorRenderers:{"sao-":{vertex:d(((e,t,i)=>i(f(e,t,null,null))))}},silhouetteRenderer:d(((e,i,s)=>s(_r(e,i,t.logarithmicDepthBufferEnabled,!0)))),snapInitRenderer:d(((e,t,i)=>_(e,t,i,!0,!1))),snapEdgeRenderer:d(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!1}),snapVertexRenderer:d(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!0})}:{colorRenderers:function(){const e=e=>ji(e,t._lightsState),i=e=>{const t=e.createUniform("vec4","uSAOParams",((e,t)=>e(t.legacyFrameCtx.saoParams))),i=Wi(e,"sampler2D","uOcclusionTexture",3e3,((e,t)=>e(t.legacyFrameCtx.occlusionTexture)));return{getAmbient:e=>{const s=`${t}.w`;return`(smoothstep(${`${t}.z`}, 1.0, dot(${i(`${e}.xy / ${t}.xy`)}, (255. / 256.) / vec4(256. * 256. * 256., 256. * 256., 256., 1.))) * ${s})`}}},s=function(s){const r=(r,n,A)=>function(e,t,i,s,r,n,A){const o=Wi(e,"sampler2D","uColorMap",3001,((e,t)=>{const i=t.layerTextureSet.colorTexture;i&&e(i.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:()=>[s.getHash(),r?"sao":"nosao",!!A,n?"alphaCutoffYes":"alphaCutoffNo"],getLogDepth:i.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,i,n,A)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${c}), dFdy(${c})));`),e.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);"),s.directionalLights.forEach((i=>{e.push(`reflectedColor += max(dot(viewNormal, ${i.getDirection(t.viewMatrix,c)}), 0.0) * ${i.getColor()};`)})),e.push(`vec4 color = vec4(${s.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);`),i&&e.push(`${d} = ${i(d)};`)},incrementDrawState:!0}}(r,n,t,e(r),s&&i(r),A,t.gammaOutput);return{PBR:n&&d(((r,n,A)=>A(function(e,t,i,s,r){const n=(t,i,s)=>Wi(e,"sampler2D",t,i?3001:3e3,((e,t)=>{const i=s(t.layerTextureSet);i&&e(i.texture)})),A=t.attributes,o=s.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`)),f=e.createVarying("vec3","vViewNormal",(()=>A.normal.view)),p=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:()=>[s.getHash(),r?"sao":"nosao",!!i.gammaOutput],getLogDepth:i.logarithmicDepthBufferEnabled&&(e=>e),renderPassFlag:0,clippingCaps:i._sectionPlanesState.clippingCaps&&b,incrementDrawState:!0,appendFragmentOutputs:(e,i,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 = ${p}.rgb;`),e.push(`float opacity = ${p}.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(${f}), ${g}, ${h(g)});`),e.push(`vec3 viewEyeDir = normalize(${d});`),o&&e.push(`reflDiff += ${o(`normalize(${_})`)};`),s.getReflection){const i=`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=s.getReflection(i,n),o=`${w}(viewNormal, viewEyeDir, specularColor, specularRoughness)`;e.push(`reflSpec += ${A} * ${o};`)}s.directionalLights.forEach(((i,s)=>{e.push(`vec3 lightDirection${s} = -${i.getDirection(t.viewMatrix,d)};`);const r=`${B}(dot(viewNormal, lightDirection${s}))`;e.push(`vec3 irradiance${s} = ${r} * ${i.getColor()};`),e.push(`reflDiff += irradiance${s};`),e.push(`reflSpec += irradiance${s} * PI * ${y}(lightDirection${s}, viewNormal, viewEyeDir, specularColor, specularRoughness);`)})),e.push(`vec3 emissiveColor = ${c(g)}.rgb;`),e.push(`float aoFactor = ${u(g)}.r;`);const A=`${s.getAmbientColor()} * baseColor * opacity * rgb`;e.push(`vec3 outgoingLight = emissiveColor + reflDiff * diffuseColor + reflSpec + ${A};`),e.push(`${b} = vec4(outgoingLight * aoFactor${r?` * ${r.getAmbient(n)}`:""}, opacity);`),i&&e.push(`${b} = ${i(b)};`)}}}(r,n,t,e(r),s&&i(r))))),texture:A&&{"alphaCutoff-":d(((e,t,i)=>i(r(e,t,!1)))),"alphaCutoff+":d(((e,t,i)=>i(r(e,t,!0))))},vertex:d(o?(t,r,n)=>n(f(t,r,e(t),s&&i(t))):(r,n,A)=>A(function(e,t,i,s,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:()=>[s.getHash(),r?"sao":"nosao"],cleanerEdges:!0,getLogDepth:i&&(e=>e),renderPassFlag:0,appendFragmentOutputs:(e,i,n,l)=>{e.push(`vec3 viewNormal = normalize(cross(dFdx(${A}), dFdy(${A})));`);const c=[s.getAmbientColor()].concat(s.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),s&&i(r))))}};return{"sao-":s(!1),"sao+":r&&s(!0)}}(),depthRenderer:d(((e,i,s)=>s(function(e,t,i){const s=e.createVarying("highp vec2","vHighPrecisionZW",(()=>`${t.attributes.position.clip}.zw`)),r=e.createOutput("vec4","outColor");return{programName:"Depth",getLogDepth:i&&(e=>e),renderPassFlag:0,appendFragmentOutputs:e=>e.push(`${r} = vec4(vec3((1.0 - ${s}[0] / ${s}[1]) / 2.0), 1.0);`)}}(e,i,t.logarithmicDepthBufferEnabled)))),edgesRenderers:{uniform:d(((e,i,s)=>s(gr(e,i,t.logarithmicDepthBufferEnabled,!0))),{vertices:!1}),vertex:d(((e,i,s)=>s(gr(e,i,t.logarithmicDepthBufferEnabled,!1))),{vertices:!1})},occlusionRenderer:d(((e,i,s)=>s(mr(e,t.logarithmicDepthBufferEnabled)))),pickDepthRenderer:u(p),pickMeshRenderer:u(g),pickNormalsFlatRenderer:u(((e,t,i)=>m(e,t,i,!0))),pickNormalsRenderer:u(((e,t,i)=>m(e,t,i,!1))),shadowRenderer:d(((e,i,s)=>s(function(e,t){const i=e.createOutput("vec4","outColor"),s=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(`${i} = ${s}(${r}.z);`)}}(e,t)))),silhouetteRenderer:u(((e,i,s)=>s(_r(e,i,t.logarithmicDepthBufferEnabled,!1)))),snapInitRenderer:u(((e,t,i)=>_(e,t,i,!0,!1))),snapEdgeRenderer:u(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!1}),snapVertexRenderer:u(((e,t,i)=>_(e,t,i,!1,!1)),{vertices:!0})};const b=e=>{!function t(i){i.revalidate?i.revalidate(e):Object.values(i).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 Vr{constructor(e,t,i){this.model=e,this.primitive=t,this.origin=i,this._meshes=[],this._aabb=V.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 i={count:0,fromFlags:(s,r)=>{s&e?(i.count++,this.model[t]++):r||(i.count--,this.model[t]--)}};this._countsByFlag[e]=i};e(or,"numVisibleLayerPortions"),e(ar,"numCulledLayerPortions"),e(lr,"numPickableLayerPortions"),e(cr,"numClippableLayerPortions"),e(ur,"numXRayedLayerPortions"),e(dr,"numHighlightedLayerPortions"),e(fr,"numSelectedLayerPortions"),this._renderers.edgesRenderers&&e(pr,"numEdgesLayerPortions"),this._countsByFlagArr=Object.values(this._countsByFlag),this._numTransparentLayerPortions=0}}aabbChanged(){this._aabbDirty=!0}getAABB(){return this._aabbDirty&&(V.collapseAABB3(this._aabb),this._meshes.forEach((e=>V.expandAABB3(this._aabb,e.aabb))),this._aabbDirty=!1),this._aabb}__drawLayer(e,t,i,s){if(this._countsByFlag[ar].count<this._portions.length&&this._countsByFlag[or].count>0){const e="points"!==this.primitive&&"lines"!==this.primitive&&[Mr,Er,kr,Fr,Ur,xr];if(e&&e.includes(s)){const e=!0;if(t.backfaces!==e){const i=this.model.scene.canvas.gl;i.disable(i.CULL_FACE),t.backfaces=e}}t.textureUnit=0,i.drawLayer(t,this,s)}}__setVec4FromMaterialColorAlpha(e,t,i){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=t,i}__drawColor(e,t,i){if((i?this._numTransparentLayerPortions<this._portions.length:this._numTransparentLayerPortions>0)&&this._countsByFlag[ur].count<this._portions.length){const s=i&&t.withSAO&&this._renderers.colorRenderers["sao+"]||this._renderers.colorRenderers["sao-"],r=t.pbrEnabled&&s.PBR?s.PBR:t.colorTextureEnabled&&s.texture?s.texture[this.layerTextureSet&&"number"==typeof this.layerTextureSet.alphaCutoff?"alphaCutoff+":"alphaCutoff-"]:s.vertex,n=i?Mr:Er;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 i=this._renderers.depthRenderer;i&&this._numTransparentLayerPortions<this._portions.length&&this._countsByFlag[ur].count<this._portions.length&&this.__drawLayer(e,t,i,Mr)}__drawSilhouette(e,t,i,s){t.programColor=this.__setVec4FromMaterialColorAlpha(i.fillColor,i.fillAlpha,yr),this.__drawLayer(e,t,this._renderers.silhouetteRenderer,s)}drawSilhouetteXRayed(e,t){this._countsByFlag[ur].count>0&&this.__drawSilhouette(e,t,this.model.scene.xrayMaterial,xr)}drawSilhouetteHighlighted(e,t){this._countsByFlag[dr].count>0&&this.__drawSilhouette(e,t,this.model.scene.highlightMaterial,Fr)}drawSilhouetteSelected(e,t){this._countsByFlag[fr].count>0&&this.__drawSilhouette(e,t,this.model.scene.selectedMaterial,Ur)}__drawVertexEdges(e,t,i){const s=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.vertex;s&&this._countsByFlag[pr].count>0&&this.__drawLayer(e,t,s,i)}drawEdgesColorOpaque(e,t){this._compiledPortions.edgesColorOpaqueAllowed()&&this.__drawVertexEdges(e,t,Ir)}drawEdgesColorTransparent(e,t){this._numTransparentLayerPortions>0&&this.__drawVertexEdges(e,t,Tr)}__drawUniformEdges(e,t,i,s){const r=this._renderers.edgesRenderers&&this._renderers.edgesRenderers.uniform;r&&(t.programColor=this.__setVec4FromMaterialColorAlpha(i.edgeColor,i.edgeAlpha,yr),this.__drawLayer(e,t,r,s))}drawEdgesHighlighted(e,t){this._countsByFlag[dr].count>0&&this.__drawUniformEdges(e,t,this.model.scene.highlightMaterial,Pr)}drawEdgesSelected(e,t){this._countsByFlag[fr].count>0&&this.__drawUniformEdges(e,t,this.model.scene.selectedMaterial,Sr)}drawEdgesXRayed(e,t){this._countsByFlag[ur].count>0&&this.__drawUniformEdges(e,t,this.model.scene.xrayMaterial,Dr)}__drawPick(e,t,i){i&&this.__drawLayer(e,t,i,kr)}drawPickMesh(e,t){this.__drawPick(e,t,this._renderers.pickMeshRenderer)}drawPickDepths(e,t){this.__drawPick(e,t,this._renderers.pickDepthRenderer)}drawPickNormals(e,t){const i=this._renderers.pickNormalsFlatRenderer;this.__drawPick(e,t,i)}drawSnap(e,t,i){t.snapPickOrigin=[0,0,0];const s=this.getAABB();t.snapPickCoordinateScale=V.mulVec3Scalar(Qr([s[3]-s[0],s[4]-s[1],s[5]-s[2]]),V.MAX_INT);const r=i?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:Qr(t.snapPickCoordinateScale)})}drawOcclusion(e,t){const i=this._renderers.occlusionRenderer;i&&this.__drawLayer(e,t,i,Mr)}drawShadow(e,t){const i=this._renderers.shadowRenderer;i&&this.__drawLayer(e,t,i,Mr)}initFlags(e,t,i){this._countsByFlagArr.forEach((e=>e.fromFlags(t,!0))),i&&(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++);const s="points"!==this.primitive;this._setFlags(e,t,i,s),this._compiledPortions.setFlags2(e,t,s)}flushInitFlags(){this._compiledPortions.setDeferredFlags()}setVisible(e,t,i){this._countsByFlag[or].fromFlags(t),this._setFlags(e,t,i)}setCulled(e,t,i){this._countsByFlag[ar].fromFlags(t),this._setFlags(e,t,i)}setPickable(e,t,i){this._countsByFlag[lr].fromFlags(t),this._setFlags(e,t,i)}setClippable(e,t){this._countsByFlag[cr].fromFlags(t),this._compiledPortions.setClippableFlags(e,t)}setCollidable(e,t){}setXRayed(e,t,i){this._countsByFlag[ur].fromFlags(t),this._setFlags(e,t,i)}setHighlighted(e,t,i){this._countsByFlag[dr].fromFlags(t),this._setFlags(e,t,i)}setSelected(e,t,i){this._countsByFlag[fr].fromFlags(t),this._setFlags(e,t,i)}setEdges(e,t,i){this._countsByFlag[pr]&&(this._countsByFlag[pr].fromFlags(t),this._setFlags(e,t,i))}setTransparent(e,t,i){i?(this._numTransparentLayerPortions++,this.model.numTransparentLayerPortions++):(this._numTransparentLayerPortions--,this.model.numTransparentLayerPortions--),this._setFlags(e,t,i)}destroy(){this._compiledPortions&&this._compiledPortions.destroy()}}let Lr=65536,Hr=5e6;class Nr{constructor(){}set doublePrecisionEnabled(e){V.setDoublePrecisionEnabled(e)}get doublePrecisionEnabled(){return V.getDoublePrecisionEnabled()}set maxDataTextureHeight(e){(e=1024*Math.ceil(e/1024))>4096?e=4096:e<1024&&(e=1024),Lr=e}get maxDataTextureHeight(){return Lr}set maxGeometryBatchSize(e){e<1e5?e=1e5:e>5e6&&(e=5e6),Hr=e}get maxGeometryBatchSize(){return Hr}}const Gr=e=>{const t=[];for(let i=0;i<e;++i)t.push(i);return t},jr={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(jr,null,4));let e=0;Object.keys(jr).forEach((t=>{t.startsWith("size")&&(e+=jr[t])})),console.log(`Total size ${e} bytes (${(e/1e3/1e3).toFixed(2)} MB)`),console.log(`Avg bytes / triangle: ${(e/jr.totalPolygons).toFixed(2)}`);let t={};Object.keys(jr).forEach((i=>{i.startsWith("size")&&(t[i]=`${(jr[i]/e*100).toFixed(2)} % of total`)})),console.log(JSON.stringify({percentualRamUsage:t},null,4))};const Wr=new Nr,zr=Wr.maxDataTextureHeight,Xr=V.vec3(),Kr=V.vec3(),Zr=V.vec4();V.vec4();const Jr=new Float32Array(16),Yr=new Uint8Array(4),$r=V.identityMat4();class qr extends Vr{constructor(e,t,i){super(e,t,i),jr.numberOfLayers++,this._sortId=`TriDTX-${jr.numberOfLayers}`;const s=e.scene.canvas.gl,r=(e,t)=>{const i=[];let r=0;const A=[];let o=0;const a=[];let l=0;const c=[];let h=0;return{len:()=>o,accumulateIndices:(s,u)=>{const d=s&&s.length>0&&function(){const t=r/3;r+=s.length,i.push(s);const a=s.length/3;return i=>{const s=o;o+=3*a,n.perObjectIndexBaseOffsets.push(s/3-t);for(let e=0;e<a;e+=8)A.push(i);jr[e]+=a,jr.totalPolygons+=a}}(),f=u&&function(){const e=l/2;l+=u.length,a.push(u);const i=u.length/2;return s=>{const r=h;h+=2*i,n.perObjectEdgeIndexBaseOffsets.push(r/2-e);for(let e=0;e<i;e+=8)c.push(s);jr[t]+=i,jr.totalEdges+=i}}();return jr.numberOfGeometries++,{numTriangles:s?s.length/3:0,accumulateSubPortionId:e=>{d&&d(e),f&&f(e)}}},createDrawers:(e,t)=>{const n=function(t,i){return t.length>0?e([t],t.length,1,s.UNSIGNED_SHORT,"sizeDataTexturePortionIds"):i},u=n(A,{texture:null}),d=r>0&&e(i,r,3,t,"sizeDataTextureIndices"),f=n(c),p=l>0&&e(a,l,2,t,"sizeDataTextureEdgeIndices");return{indices:function(e,t){o>0&&(e.perPrimIndices.setInputValue(d),e.perPrimIdPorIds.setInputValue(u),s.drawArrays(t,0,o))},edges:function(e,t){h>0&&(e.perPrimIndices.setInputValue(p),e.perPrimIdPorIds.setInputValue(f),s.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&&jr.cannotCreatePortion.because10BitsObjectId++;let i=this._portions.length+t<=65536;const s=void 0!==e.geometryId&&null!==e.geometryId?`${e.geometryId}#0`:`${e.id}#0`;if(!this._bucketGeometries[s]){const t=this._buffer,s=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*zr||s+n>4096*zr)&&jr.cannotCreatePortion.becauseTextureSize++,i&&=this._numVertices+r<=4096*zr&&s+n<=4096*zr}return i}createPortion(e,t){const i=this._buffer,s=t.buckets.map(((e,s)=>{const r=(t.geometryId??t.id)+"#"+s;if(!(r in this._bucketGeometries)){const t=(e,t,i)=>{if(e){const s=8*Math.ceil(e.length/t/8)*t,r=new Uint32Array(s);return r.set(e),jr[i]+=2*(r.length-e.length),r}return e};e.indices=t(e.indices,3,"overheadSizeAlignementIndices"),e.edgeIndices=t(e.edgeIndices,2,"overheadSizeAlignementEdgeIndices");const s=e.positionsCompressed;i.positionsCompressed.push(s);const n=s.length/3;this._numVertices+=n;const A=i.lenPositionsCompressed/3;i.lenPositionsCompressed+=s.length,this._bucketGeometries[r]={vertexBase:A,geometryData:function(){const t=e.indices,s=e.edgeIndices;return n<=256?i.geometry8Bits.accumulateIndices(t,s):n<=65536?i.geometry16Bits.accumulateIndices(t,s):i.geometry32Bits.accumulateIndices(t,s)}()}}const n=this._bucketGeometries[r];i.perObjectPositionsDecodeMatrices.push(t.positionsDecodeMatrix),i.perObjectInstancePositioningMatrices.push(t.meshMatrix||$r),i.perObjectSolid.push(!!t.solid),i.perObjectPickColors.push(t.pickColor),i.perObjectVertexBases.push(n.vertexBase);const A=t.colors,o=t.color;i.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}),jr.numberOfPortions++,a})),r=this._portionToSubPortionsMap.length;return this._portionToSubPortionsMap.push(s),this.model.numPortions++,this._meshes.push(e),r}compilePortions(){const e=this._buffer,t=this.model,i=this._portions.length,s=this.origin,r=this._portionToSubPortionsMap,n=this._primitive,A=this._sortId,o=this._subPortionReadableGeometries,a=t.scene,l=a.canvas.gl,c=en(l,i,32,l.UNSIGNED_BYTE,512,(t=>{const s=e=>[e>>24&255,e>>16&255,e>>8&255,255&e];for(let r=0;r<i;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(s(e.perObjectVertexBases[r]),32*r+16),t.set(s(e.perObjectIndexBaseOffsets[r]),32*r+20),t.set(s(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,i,s,r,n,A){return en(l,t,i,s,r,(t=>{for(let i=0,s=0,r=e.length;i<r;i++){const r=e[i];t.set(r,s),s+=r.length}}),n,A)},d=function(e,t,i){const s=e.length;if(0===s)throw"num "+t+" matrices===0";return u(e,s,16,l.FLOAT,512,t,i)},f=d(e.perObjectInstancePositioningMatrices,"sizeDataInstancesMatrices",!0),p=f.textureData,g=d(e.perObjectPositionsDecodeMatrices,"sizeDataPositionDecodeMatrices",!1),m=function(e,t,i,s,r){return u(e,t/i,i,s,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})),U=(e,i)=>{const s=r[e];if(s)for(let e=0,t=s.length;e<t;e++)i(s[e]);else t.error("portion not found: "+e)},x=(e,t,i,s)=>{const r=w||s;r?v=!0:++M>=10&&E(),h.setData(i,e,t,!r)},I=(e,t,i=!1)=>{Yr.set([t&cr?255:0,0,1,2]),U(e,(e=>x(e,3,Yr,i)))};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,i,s=!1)=>{Rr(t,i,!0,a,Yr),U(e,(e=>x(e,2,Yr,s)))},setFlags2:I,setDeferredFlags:()=>{},setColor:(e,t)=>{Yr.set(t),U(e,(e=>x(e,0,Yr,!1)))},setMatrix:(e,t)=>{U(e,(e=>{const i=w;i?v=!0:++M>=10&&E(),Jr.set(t),p.setData(Jr,e,0,!i)}))},setOffset:(e,t)=>{},getEachIndex:(e,t)=>{o&&U(e,(e=>o[e].indices.forEach((e=>t(e)))))},getEachVertex:(e,i)=>{o&&U(e,(e=>{const r=o[e],n=r.positionsCompressed,A=r.positionsDecodeMatrix,a=Zr;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,V.decompressPosition(a,A),V.mulMat4v4(t.worldMatrix,a,a),V.addVec3(s,a,a),i(a)}))},precisionRayPickSurface:(e,t,i,s,r)=>!1,renderers:Or(a,"dtx",n,t.saoEnabled,!1,!1,!0,((e,t)=>tn(e,!t))),drawCalls:function(){const e=function(e){const i=(e,t)=>e.setInputValue&&e.setInputValue(t);return(r,n,A)=>{i(n.worldMatrix,t.rotationMatrix),i(n.viewMatrix,A.viewMatrix),i(n.projMatrix,A.projMatrix);const o=V.transformPoint3(t.matrix,s,Xr);i(n.uCameraEyeRtc,V.subVec3(A.eye,o,Kr)),i(n.perObjPosDecode,g),i(n.perVertIdCoords,_),i(n.perObjColsFlags,c),i(n.perObjectMatrix,f),e(n)}},i=function(t){return e((e=>{b.edges(e,t),B.edges(e,t),y.edges(e,t)}))};return{drawVertices:i(l.POINTS),drawEdges:i(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 en=function(e,t,i,s,r,n,A,o){if(i>4&&i%4>0)throw"Unhandled data size "+i;const a=Math.ceil(i/4),l=i/a,[c,h,u]=function(){switch(s){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 "+s}}(),d=r*a,f=Math.ceil(t/r);if(0===f)throw"texture height===0";const p=new c(d*f*l);jr[A]+=p.byteLength,jr.numberOfTextures++,n(p);const g=e.createTexture();return e.bindTexture(e.TEXTURE_2D,g),e.texStorage2D(e.TEXTURE_2D,1,h,d,f),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,f,u,s,p),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(p.set(t,n*i+A*l),o){e.bindTexture(e.TEXTURE_2D,g);const i=n%r*a+A,o=Math.floor(n/r),c=t.length/l;e.texSubImage2D(e.TEXTURE_2D,0,i,o,c,1,u,s,t)}},reloadData(){e.bindTexture(e.TEXTURE_2D,g),e.texSubImage2D(e.TEXTURE_2D,0,0,0,d,f,u,s,p)}}}},tn=function(e,t){const i=(t,i)=>{const s=e.createUniform(t,i),r=e=>`texelFetch(${s}, ${e}, 0)`;return r.map=s,r},s=i("highp usampler2D","perPrimIndices"),r=i("mediump usampler2D","perPrimIdPorIds"),n=i("highp sampler2D","perObjPosDecode"),A=i("mediump usampler2D","perVertIdCoords"),o=i("lowp usampler2D","perObjColsFlags"),a=i("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},f=d("colorA"),p=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:f,flags:Gr(4).map((e=>`int(flags[${e}])`)),metallicRoughness:null,normal:{view:m,world:g},pickColor:p,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)};`),f.needed&&e.push(`vec4 ${f} = vec4(${_(0)}) / 255.0;`)},appendVertexData:e=>{const i=e=>a(`ivec2(objectIndexCoords.x*4+${e}, objectIndexCoords.y)`);e.push(`mat4 objectInstanceMatrix = mat4(${i(0)}, ${i(1)}, ${i(2)}, ${i(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(${s("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;p.needed&&e.push(`vec4 pickColor = vec4(${_(1)});`),e.push(`vec4 worldPosition = ${l} * (objectDecodeAndInstanceMatrix * vec4(position, 1.0));`)},layerTypeInputs:{perPrimIndices:s.map,perPrimIdPorIds:r.map,perObjPosDecode:n.map,perVertIdCoords:A.map,perObjColsFlags:o.map,perObjectMatrix:a.map,worldMatrix:l,viewMatrix:c,projMatrix:h,uCameraEyeRtc:u}}},sn=V.mat4(),rn=V.mat4();function nn(e,t,i){const s=e.length,r=new Uint16Array(s),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,f=h/c,p=e=>e>=0?e:0;for(let t=0;t<s;t+=3)r[t+0]=Math.floor(p(e[t+0]-n)*u),r[t+1]=Math.floor(p(e[t+1]-A)*d),r[t+2]=Math.floor(p(e[t+2]-o)*f);return V.identityMat4(sn),V.translationMat4v(t,sn),V.identityMat4(rn),V.scalingMat4v([a/h,l/h,c/h],rn),V.mulMat4(sn,rn,i),r}function An(e,t){const i=e[0],s=e[1],r=e[2],n=e[3]-i||1,A=e[4]-s||1,o=e[5]-r||1,a=65525;return V.identityMat4(sn),V.translationMat4v(e,sn),V.identityMat4(rn),V.scalingMat4v([n/a,A/a,o/a],rn),V.mulMat4(sn,rn,t),t}function on(e,t,i){let s=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=s,t=r;e=(1-Math.abs(r))*(s>=0?1:-1),t=(1-Math.abs(s))*(r>=0?1:-1),s=e,r=t}return new Int8Array([Math[t](127.5*s+(s<0?-1:0)),Math[i](127.5*r+(r<0?-1:0))])}function an(e){let t=e[0],i=e[1];t/=t<0?127:128,i/=i<0?127:128;const s=1-Math.abs(t)-Math.abs(i);s<0&&(t=(1-Math.abs(i))*(t>=0?1:-1),i=(1-Math.abs(t))*(i>=0?1:-1));const r=Math.sqrt(t*t+i*i+s*s);return[t/r,i/r,s/r]}const ln=new Float32Array(1),cn=new Float32Array(4),hn=new Float32Array(3),un=V.mat4(),dn=V.vec4([0,0,0,1]),fn=V.vec4(),pn=V.vec3(),gn=V.vec3(),mn=V.vec3(),_n=V.vec3(),bn=V.vec3(),Bn=V.vec3(),yn=V.vec3(),wn=new Uint8Array(4),vn=new Float32Array(96),Cn=function(e){const t=[];for(let i=0;i<e;++i)t.push(i);return t},Mn=function(e,t){e.set(t);let i=t.length;const s=e.length;for(;i<s;){const t=Math.min(i,s-i);e.set(e.subarray(0,t),i),i+=t}},En=function(){let e=0;const t=new Map;return{acquire:()=>e++,release:()=>{e--,0===e&&t.clear()},getTypeArray:function(e,i){t.has(e)||t.set(e,{});const s=t.get(e);return i in s||(s[i]=new e(i)),s[i]}}}();class Fn extends Vr{constructor(e,t,i,s){super(e,t,i);const r=!!s.geometry;this._maxVerts=s.maxGeometryBatchSize;const n=r?s.geometry.positionsDecodeMatrix:s.positionsDecodeMatrix;this._positionsDecodeMatrix=n&&V.mat4(n),this._cfgUvDecodeMatrix=s.uvDecodeMatrix&&V.mat3(s.uvDecodeMatrix),this._instancedGeometry=s.geometry,this._textureSet=s.textureSet,this._modelAABB=!r&&V.collapseAABB3(),this._portions=[];const A=function(){let e=0;const t=[];return{length:()=>e,append:function(i,s=1,r=1,n=0){e+=s*i.length,t.push({data:i,times:s,denormalizeScale:r,increment:n})},compileBuffer:function(e){let i=0;t.forEach((e=>{i+=e.times*e.data.length}));const s=new e(i);let r=0;return t.forEach((e=>{const t=e.data,i=e.denormalizeScale,n=e.increment,A=s.subarray(r);if(1===i&&0===n)A.set(t);else for(let e=0;e<t.length;++e)A[e]=n+t[e]*i;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})),s}}};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 i=this._buffer,s=this._instancedGeometry,r=this.model,n=this._portions.length,A=this.primitive,o=!!this._positionsDecodeMatrix,a=r.scene,l=t.meshMatrix,c=(s,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:s,portionSize:o,retainedGeometry:a.readableGeometryEnabled&&"points"!==A&&"lines"!==A&&{indices:l,quantizedPositions:c,offset:a.entityOffsetsEnabled&&V.vec3(),matrix:h&&h.slice(),inverseMatrix:null,normalMatrix:null}};return"points"!==A&&"lines"!==A&&i.metallicRoughness.append([t.metallic??0,t.roughness??255],o),"lines"!==A&&i.pickColors.append(t.pickColor.slice(0,4),o),this._portions.push(d),r.numPortions++,this._meshes.push(e),n};if(s){if(i.modelMatrixCol.forEach(((e,t)=>e.append([l[t+0],l[t+4],l[t+8],l[t+12]]))),"points"!==A){const e=t.color;i.colors.append([e[0],e[1],e[2],t.opacity??255])}if("points"!==A&&"lines"!==A&&s.normals){const e=V.inverseMat4(V.transposeMat4(l,V.mat4()));i.modelNormalMatrixCol.forEach(((t,i)=>t.append([e[i+0],e[i+4],e[i+8],e[i+12]])))}return c(n,1,s.indices,s.positionsCompressed,l)}{const e=i.positions.length()/3,s=o?t.positionsCompressed:t.positions;if(!s)throw(o?"positionsCompressed":"positions")+" expected";i.positions.append(s);const r=s.length/3,n=t.indices;n&&i.indices.append(n,1,1,e);const a=t.normalsCompressed,h=t.normals;if(a&&a.length>0)i.normals.append(a);else if(h&&h.length>0){const e=un;l?(V.transposeMat4(l,e),V.inverseMat4(e,e)):V.identityMat4(e);const t=[];!function(e,t,i,s,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<i;h+=3)u[0]=t[h],u[1]=t[h+1],u[2]=t[h+2],V.transformVec3(e,u,d),V.normalizeVec3(d,d),a=A=on(d,"floor","floor"),o=an(A),l=c=n(d,o),A=on(d,"ceil","floor"),o=an(A),l=n(d,o),l>c&&(a=A,c=l),A=on(d,"floor","ceil"),o=an(A),l=n(d,o),l>c&&(a=A,c=l),A=on(d,"ceil","ceil"),o=an(A),l=n(d,o),l>c&&(a=A,c=l),s[r+h+0]=a[0],s[r+h+1]=a[1],s[r+h+2]=0}(e,h,h.length,t,0),i.normals.append(t)}const u=t.colors,d=t.colorsCompressed,f=t.color;if(u)if("points"===A)i.colors.append(u,1,255);else{const e=[];for(let t=0,i=u.length;t<i;t+=3)e.push(255*u[t]),e.push(255*u[t+1]),e.push(255*u[t+2]),e.push(255);i.colors.append(e)}else if(d)if("points"===A)i.colors.append(d);else{const e=[];for(let t=0,i=d.length;t<i;t+=3)e.push(d[t]),e.push(d[t+1]),e.push(d[t+2]),e.push(255);i.colors.append(e)}else f&&i.colors.append([f[0],f[1],f[2],"points"===A?1:t.opacity],r);const p=e=>e&&e.length>0&&e,g=p(t.uv)||p(t.uvCompressed);g&&i.uv.append(g);const m=t.edgeIndices;return m&&i.edgeIndices.append(m,1,1,e),V.expandAABB3(this._modelAABB,t.aabb),c(e,r,n)}}compilePortions(){const e=this._buffer,t=this._instancedGeometry,i=this.model,s=this._modelAABB,r=this.origin,n=this._portions,A=this.primitive,o=this._textureSet;let a=this._positionsDecodeMatrix;const l=this._cfgUvDecodeMatrix,c=i.scene,h=c.canvas.gl,u=!!t,d=[],f=(e,t,i,s)=>{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,s)};l(t);const c=t.BYTES_PER_ELEMENT,u=t.length/i;return{bindBuffer:a,getData:(t=0,s=u-t)=>{a();const A=new r(s*i);return h.getBufferSubData(e,t*n*i,A,0,s*i),A},numItems:u,setData:l,setSubData:(t,i)=>{a(),h.bufferSubData(e,i*c,t)},type:A}}return null},p=(e,t,i,s=!1,r=!1)=>{const n=f(h.ARRAY_BUFFER,e,t,i);return n&&{getData:n.getData,numItems:n.numItems,setData:n.setData,setSubData:n.setSubData,attributeDivisor:s&&1,bindAtLocation:e=>{n.bindBuffer(),h.vertexAttribPointer(e,t,n.type,!!r,0,0)}}},g=e=>{const t=f(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),_=p(new Float32Array(m),1,h.DYNAMIC_DRAW,u),b=(e,t)=>p(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&&p(new Float32Array(3*m),3,h.DYNAMIC_DRAW,u),w=p(e.metallicRoughness.compileBuffer(Uint8Array),2,h.STATIC_DRAW,u),v=p(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):nn(e.positions.compileBuffer(Float64Array),s,a=V.mat4()),U=F&&p(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 x=u&&e.modelMatrixCol.map((e=>p(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),I=!u&&e.normals.compileBuffer(Int8Array),T=I&&p(I,3,h.STATIC_DRAW,!1,!0),P=x&&T&&e.modelNormalMatrixCol.map((e=>p(e.compileBuffer(Float32Array),4,h.STATIC_DRAW,!0))),S=u?"points"!==A&&"lines"!==A&&t.uvCompressed&&{buf:p(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:p(t,2,h.STATIC_DRAW),mat:l};{const e=Ne.getUVBounds(t),i=Ne.compressUVs(t,e.min,e.max);return{buf:p(i.quantized,2,h.STATIC_DRAW),mat:V.mat3(i.decodeMatrix)}}}();this._buffer=null,En.acquire(),d.push((()=>En.release()));let D=null;const k=(e,i,s,r=!1)=>{Rr(i,s,"points"!==A&&"lines"!==A,c,wn);const o=i&cr?1:0;let a=0;a|=wn[0],a|=wn[1]<<4,a|=wn[2]<<8,a|=wn[3]<<12,a|=o<<16,ln[0]=a;const l=n[e],h=l.portionBase,u=l.portionSize;if(r&&!t)D||(D=new Float32Array(m)),Mn(D.subarray(h,h+u),ln);else if(_){const e=En.getTypeArray(Float32Array,u);Mn(e,ln),_.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,i)=>{},setDeferredFlags:()=>{D&&(_.setData(D),D=null)},setColor:(e,t)=>{if(B){const i=n[e],s=En.getTypeArray(Uint8Array,4*i.portionSize);Mn(s,t.slice(0,4)),B.setSubData(s,4*i.portionBase)}},setMatrix:(e,t)=>{x&&x.forEach(((i,s)=>{cn[0]=t[s+0],cn[1]=t[s+4],cn[2]=t[s+8],cn[3]=t[s+12],i.setSubData(cn,4*e)}))},setOffset:(e,t)=>{if(c.entityOffsetsEnabled){const i=n[e];if(y){hn.set(t);const e=En.getTypeArray(Float32Array,3*i.portionSize);Mn(e,hn),y.setSubData(e,3*i.portionBase)}i.retainedGeometry&&i.retainedGeometry.offset.set(t)}else i.error("Entity#offset not enabled for this Viewer")},getEachIndex:(e,t)=>{const i=n[e].retainedGeometry;i&&i.indices.forEach((e=>t(e)))},getEachVertex:(e,t)=>{const s=n[e].retainedGeometry;if(s){const e=fn;r?e.set(r,0):e[0]=e[1]=e[2]=0,e[3]=1;const n=i.matrix;V.mulMat4v4(n,e,e);const A=s.quantizedPositions,o=dn;for(let i=0,r=A.length;i<r;i+=3)o[0]=A[i],o[1]=A[i+1],o[2]=A[i+2],V.decompressPosition(o,a),s.matrix&&V.transformPoint3(s.matrix,o,o),o[3]=1,V.mulMat4v4(n,o,o),V.addVec3(e,o,o),t(o)}},readGeometryData:"points"!==A&&"lines"!==A&&(e=>{const t=!u&&n[e],s=t?E.getData(t.indicesBaseIndex,t.numIndices).map((e=>e-t.portionBase)):E.getData(),A=i.matrix,o=V.vec4();o.set(r,0),o[3]=1,V.mulMat4v4(A,o,o);const l=x&&V.mat4();if(l){const t=x[0].getData(e,1),i=x[1].getData(e,1),s=x[2].getData(e,1);l.set([t[0],i[0],s[0],0,t[1],i[1],s[1],0,t[2],i[2],s[2],0,t[3],i[3],s[3],1])}const c=V.mat4();V.mulMat4(A,l?V.mulMat4(l,a,c):a,c),c[12]+=o[0],c[13]+=o[1],c[14]+=o[2];const h=t?U.getData(t.portionBase,t.portionSize):U.getData();return{indices:s,positions:V.transformPositions3(c,h,new Float64Array(h.length))}}),precisionRayPickSurface:(e,t,s,A,o)=>{const l=n[e].retainedGeometry;if(l){l.matrix&&!l.inverseMatrix&&(l.inverseMatrix=V.inverseMat4(l.matrix,V.mat4())),o&&l.inverseMatrix&&!l.normalMatrix&&(l.normalMatrix=V.transposeMat4(l.inverseMatrix,V.mat4()));const e=l.quantizedPositions,n=l.indices,c=l.offset,h=pn,u=gn;h.set(r?V.subVec3(t,r,mn):t),u.set(s),c&&V.subVec3(h,c),V.transformRay(i.worldNormalMatrix,h,u,h,u),l.inverseMatrix&&V.transformRay(l.inverseMatrix,h,u,h,u);const d=_n,f=bn,p=Bn;let g=!1,m=0;const _=yn;for(let s=0,b=n.length;s<b;s+=3){const b=3*n[s],B=3*n[s+1],y=3*n[s+2];if(d[0]=e[b],d[1]=e[b+1],d[2]=e[b+2],f[0]=e[B],f[1]=e[B+1],f[2]=e[B+2],p[0]=e[y],p[1]=e[y+1],p[2]=e[y+2],V.decompressPosition(d,a),V.decompressPosition(f,a),V.decompressPosition(p,a),V.rayTriangleIntersect(h,u,d,f,p,_)){l.matrix&&V.transformPoint3(l.matrix,_,_),V.transformPoint3(i.worldMatrix,_,_),c&&V.addVec3(_,c),r&&V.addVec3(_,r);const e=Math.abs(V.lenVec3(V.subVec3(_,t,[])));(!g||e>m)&&(m=e,A.set(_),o&&V.triangleNormal(d,f,p,o),g=!0)}}return g&&o&&(l.normalMatrix&&V.transformVec3(l.normalMatrix,o,o),V.transformVec3(i.worldNormalMatrix,o,o),V.normalizeVec3(o)),g}return!1},layerTextureSet:o,renderers:Or(c,u?"instancing":"batching",A,i.saoEnabled,i.pbrEnabled&&S&&o&&o.colorTexture&&T&&w&&o.metallicRoughnessTexture,i.colorTextureEnabled&&S&&o&&o.colorTexture,!!T,(e=>xn(e,u&&{hasModelNormalMat:!!P},c.entityOffsetsEnabled))),drawCalls:function(){const e={},t=t=>(s,r,o)=>{let l=0;vn.set(i.rotationMatrix,0),vn.set(o.viewMatrix,l+=16),vn.set(o.projMatrix,l+=16),vn.set(a,l+=16),r.needNormal()&&(vn.set(i.worldNormalMatrix,l+=16),vn.set(o.viewNormalMatrix,l+=16)),r.matrices.setInputValue(vn),r.uvDecodeMatrix.setInputValue&&r.uvDecodeMatrix.setInputValue(S.mat),s in e||(e[s]=[null,null,null]);const c=e[s],f=t?t.vertices?0:1:2;if(!c[f]){const e=h.createVertexArray();h.bindVertexArray(e);const i=(e,t)=>{e&&e.setInputValue&&t&&e.setInputValue(t)},s=r.attributes;i(s.position,U),i(s.normal,T),i(s.color,B),i(s.pickColor,v),i(s.uV,S&&S.buf),i(s.metallicRoughness,w),i(s.flags,_),i(s.offset,y),s.modelMatrixCol&&s.modelMatrixCol.forEach(((e,t)=>i(e,x[t]))),s.modelNormalMatrixCol&&s.modelNormalMatrixCol.forEach(((e,t)=>i(e,P[t])));const o=function(){const e=()=>{u?h.drawArraysInstanced(h.POINTS,0,U.numItems,n.length):h.drawArrays(h.POINTS,0,U.numItems)},i=(e,t)=>{t.bindIndicesBuffer();const i=t.indicesCount,s=t.indicesType;return()=>{u?h.drawElementsInstanced(e,i,s,0,n.length):h.drawElements(e,i,s,0)}};return"points"===A?e:"lines"===A?t&&t.vertices?e:i(h.LINES,E):t&&t.vertices?e:t?C?i(h.LINES,C):()=>{}:i(h.TRIANGLES,E)}();h.bindVertexArray(null),d.push((()=>h.deleteVertexArray(e))),c[f]=()=>{h.bindVertexArray(e),o(),h.bindVertexArray(null)}}c[f]()};return{drawVertices:t({vertices:!0}),drawEdges:t({}),drawSurface:t(null)}}(),destroy:()=>{d.forEach((e=>e())),d.length=0}}}}const Un=function(e){const t={toString:()=>(t.needed=!0,e)};return t},xn=function(e,t,i){const s=e.createAttribute,r={position:s("vec3","positionA"),normal:s("vec3","normalA"),color:s("vec4","colorA"),pickColor:s("vec4","pickColor"),uV:s("vec2","uvApremul"),metallicRoughness:s("vec2","metallicRoughness"),flags:s("float","flagsA"),offset:i&&s("vec3","offset"),modelMatrixCol:t&&Cn(3).map((e=>s("vec4","modelMatrixCol"+e))),modelNormalMatrixCol:t&&t.hasModelNormalMat&&Cn(3).map((e=>s("vec4","modelNormalMatrixCol"+e)))},n=Un("aUv"),A=Un("viewNormal"),o=Un("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:Cn(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 i=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)${i?" * "+i:""});`),r.offset&&t.push(`worldPosition.xyz = worldPosition.xyz + ${r.offset};`),l()){const i=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)${i||""};`),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 In{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 Tn{constructor(e){this.id=e.id,this.texture=e.texture}destroy(){this.texture&&(this.texture.destroy(),this.texture=null)}}const Pn={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 Sn{constructor(e,t,i){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=i}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,i=this.handlers.length;t<i;t+=2){const i=this.handlers[t],s=this.handlers[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return s}return null}}const Dn=new Sn;class kn{constructor(e){this.manager=void 0!==e?e:Dn,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise((function(s,r){i.load(e,s,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 Qn={};class Rn extends kn{constructor(e){super(e)}load(e,t,i,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Pn.get(e);if(void 0!==r)return this.manager.itemStart(e),ie.scheduleTask((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Qn[e])return void Qn[e].push({onLoad:t,onProgress:i,onError:s});Qn[e]=[],Qn[e].push({onLoad:t,onProgress:i,onError:s});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 i=Qn[e],s=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(){s.read().then((({done:s,value:r})=>{if(s)e.close();else{o+=r.byteLength;const s=new ProgressEvent("progress",{lengthComputable:A,loaded:o,total:n});for(let e=0,t=i.length;e<t;e++){const t=i[e];t.onProgress&&t.onProgress(s)}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),i=t&&t[1]?t[1].toLowerCase():void 0,s=new TextDecoder(i);return e.arrayBuffer().then((e=>s.decode(e)))}}})).then((t=>{Pn.add(e,t);const i=Qn[e];delete Qn[e];for(let e=0,s=i.length;e<s;e++){const s=i[e];s.onLoad&&s.onLoad(t)}})).catch((t=>{const i=Qn[e];if(void 0===i)throw this.manager.itemError(e),t;delete Qn[e];for(let e=0,s=i.length;e<s;e++){const s=i[e];s.onError&&s.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 On{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 i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:t,msg:i,transfer:s}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(i,s)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((i=>{const s=this._getIdleWorker();-1!==s?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=i,this.workers[s].postMessage(e,t)):this.queue.push({resolve:i,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 Vn=0;class Ln{constructor({viewer:e,transcoderPath:t,workerLimit:i}){this._transcoderPath=t||"https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/basis/",this._transcoderBinary=null,this._transcoderPending=null,this._workerPool=new On,this._workerSourceURL="",i&&this._workerPool.setWorkerLimit(i);const s=e.capabilities;this._workerConfig={astcSupported:s.astcSupported,etc1Supported:s.etc1Supported,etc2Supported:s.etc2Supported,dxtSupported:s.dxtSupported,bptcSupported:s.bptcSupported,pvrtcSupported:s.pvrtcSupported},this._supportedFileTypes=["xkt2"]}_init(){if(!this._transcoderPending){const e=new Rn;e.setPath(this._transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new Rn;i.setPath(this._transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const s=i.loadAsync("basis_transcoder.wasm");this._transcoderPending=Promise.all([t,s]).then((([e,t])=>{const i=Ln.BasisWorker.toString(),s=["/* constants */","let _EngineFormat = "+JSON.stringify(Ln.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(Ln.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Ln.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this._workerSourceURL=URL.createObjectURL(new Blob([s])),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}))})),Vn>0&&console.warn("KTX2TextureTranscoder: Multiple active KTX2TextureTranscoder may cause performance issues. Use a single KTX2TextureTranscoder instance, or call .dispose() on old instances."),Vn++}return this._transcoderPending}transcode(e,t,i={}){return new Promise(((s,r)=>{const n=i;this._init().then((()=>this._workerPool.postMessage({type:"transcode",buffers:e,taskConfig:n},e))).then((e=>{const i=e.data,{mipmaps:n,width:A,height:o,format:a,type:l,error:c,dfdTransferFn:h,dfdFlags:u}=i;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)}}),s()}))}))}destroy(){URL.revokeObjectURL(this._workerSourceURL),this._workerPool.destroy(),Vn--}}Ln.BasisFormat={ETC1S:0,UASTC_4x4:1},Ln.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},Ln.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},Ln.BasisWorker=function(){let e,t,i;const s=_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=>{i={wasmBinary:h,onRuntimeInitialized:e},BASIS(i)})).then((()=>{i.initializeBasis(),void 0===i.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:f,dfdFlags:p}=function(t){const A=new i.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(),f=A.getLevels(),p=A.getHasAlpha(),g=A.getDFDTransferFunc(),m=A.getDFDFlags(),{transcoderFormat:_,engineFormat:b}=function(t,i,A,c){let h,u;const d=t===n.ETC1S?o:a;for(let s=0;s<d.length;s++){const r=d[s];if(e[r.if]&&(r.basisFormat.includes(t)&&!(c&&r.transcoderFormat.length<2)&&(!r.needsPowerOfTwo||l(i)&&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=s.RGBAFormat,{transcoderFormat:h,engineFormat:u}}(h,u,d,p);if(!u||!d||!f)throw c(),new Error("KTX2TextureTranscoder: Invalid texture");if(!A.startTranscoding())throw c(),new Error("KTX2TextureTranscoder: .startTranscoding failed");const B=[];for(let e=0;e<f;e++){const t=A.getImageLevelInfo(e,0,0),i=t.origWidth,s=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:i,height:s})}return c(),{width:u,height:d,hasAlpha:p,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:f,dfdFlags:p},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:[s.RGBA_ASTC_4x4_Format,s.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:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[s.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:[s.RGB_PVRTC_4BPPV1_Format,s.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 Hn={};function Nn(e){const t=e.scene.id;let i=Hn[t];return i||(i=new Ln({viewer:e}),Hn[t]=i,e.scene.on("destroyed",(()=>{delete Hn[t],i.destroy()}))),i}
|
|
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 _f=function(e,t){return _f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},_f(e,t)};function bf(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}_f(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var Bf=function(){return Bf=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Bf.apply(this,arguments)};function yf(e,t,i,s){return new(i||(i=Promise))((function(r,n){function A(e){try{a(s.next(e))}catch(e){n(e)}}function o(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(A,o)}a((s=s.apply(e,t||[])).next())}))}function wf(e,t){var i,s,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(i)throw new TypeError("Generator is already executing.");for(;A;)try{if(i=1,s&&(r=2&n[0]?s.return:n[0]?s.throw||((r=s.return)&&r.call(s),0):s.next)&&!(r=r.call(s,n[1])).done)return r;switch(s=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++,s=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],s=0}finally{i=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}}function vf(e,t,i){if(i||2===arguments.length)for(var s,r=0,n=t.length;r<n;r++)!s&&r in t||(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||t)}for(var Cf=function(){function e(e,t,i,s){this.left=e,this.top=t,this.width=i,this.height=s}return e.prototype.add=function(t,i,s,r){return new e(this.left+t,this.top+i,this.width+s,this.height+r)},e.fromClientRect=function(t,i){return new e(i.left+t.windowBounds.left,i.top+t.windowBounds.top,i.width,i.height)},e.fromDOMRectList=function(t,i){var s=Array.from(i).find((function(e){return 0!==e.width}));return s?new e(s.left+t.windowBounds.left,s.top+t.windowBounds.top,s.width,s.height):e.EMPTY},e.EMPTY=new e(0,0,0,0),e}(),Mf=function(e,t){return Cf.fromClientRect(e,t.getBoundingClientRect())},Ef=function(e){for(var t=[],i=0,s=e.length;i<s;){var r=e.charCodeAt(i++);if(r>=55296&&r<=56319&&i<s){var n=e.charCodeAt(i++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),i--)}else t.push(r)}return t},Ff=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var i=e.length;if(!i)return"";for(var s=[],r=-1,n="";++r<i;){var A=e[r];A<=65535?s.push(A):(A-=65536,s.push(55296+(A>>10),A%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},Uf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),If=0;If<Uf.length;If++)xf[Uf.charCodeAt(If)]=If;for(var Tf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Sf=0;Sf<Tf.length;Sf++)Pf[Tf.charCodeAt(Sf)]=Sf;for(var Df=function(e,t,i){return e.slice?e.slice(t,i):new Uint16Array(Array.prototype.slice.call(e,t,i))},kf=function(){function e(e,t,i,s,r,n){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=s,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}(),Qf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Of=0;Of<Qf.length;Of++)Rf[Qf.charCodeAt(Of)]=Of;var Vf=10,Lf=13,Hf=15,Nf=17,Gf=18,jf=19,Wf=20,zf=21,Xf=22,Kf=24,Zf=25,Jf=26,Yf=27,$f=28,qf=30,ep=32,tp=33,ip=34,sp=35,rp=37,np=38,Ap=39,op=40,ap=42,lp=[9001,65288],cp=function(e,t){var i,s,r,n=function(e){var t,i,s,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)i=Pf[e.charCodeAt(t)],s=Pf[e.charCodeAt(t+1)],r=Pf[e.charCodeAt(t+2)],n=Pf[e.charCodeAt(t+3)],c[a++]=i<<2|s>>4,c[a++]=(15&s)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=4)i.push(e[s+3]<<24|e[s+2]<<16|e[s+1]<<8|e[s]);return i}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=2)i.push(e[s+1]<<8|e[s]);return i}(n):new Uint16Array(n),a=Df(o,12,A[4]/2),l=2===A[5]?Df(o,(24+A[4])/2):(i=A,s=Math.ceil((24+A[4])/4),i.slice?i.slice(s,r):new Uint32Array(Array.prototype.slice.call(i,s,r)));return new kf(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=="),hp=[qf,36],up=[1,2,3,5],dp=[Vf,8],fp=[Yf,Jf],pp=up.concat(dp),gp=[np,Ap,op,ip,sp],mp=[Hf,Lf],_p=function(e,t,i,s){var r=s[i];if(Array.isArray(e)?-1!==e.indexOf(r):e===r)for(var n=i;n<=s.length;){if((a=s[++n])===t)return!0;if(a!==Vf)break}if(r===Vf)for(n=i;n>0;){var A=s[--n];if(Array.isArray(e)?-1!==e.indexOf(A):e===A)for(var o=i;o<=s.length;){var a;if((a=s[++o])===t)return!0;if(a!==Vf)break}if(A!==Vf)break}return!1},bp=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==Vf)return s;i--}return 0},Bp=function(e,t,i,s,r){if(0===i[s])return"×";var n=s-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!==up.indexOf(a))return"!";if(-1!==up.indexOf(c))return"×";if(-1!==dp.indexOf(c))return"×";if(8===bp(n,t))return"÷";if(11===cp.get(e[n]))return"×";if((a===ep||a===tp)&&11===cp.get(e[o]))return"×";if(7===a||7===c)return"×";if(9===a)return"×";if(-1===[Vf,Lf,Hf].indexOf(a)&&9===c)return"×";if(-1!==[Nf,Gf,jf,Kf,$f].indexOf(c))return"×";if(bp(n,t)===Xf)return"×";if(_p(23,Xf,n,t))return"×";if(_p([Nf,Gf],zf,n,t))return"×";if(_p(12,12,n,t))return"×";if(a===Vf)return"÷";if(23===a||23===c)return"×";if(16===c||16===a)return"÷";if(-1!==[Lf,Hf,zf].indexOf(c)||14===a)return"×";if(36===l&&-1!==mp.indexOf(a))return"×";if(a===$f&&36===c)return"×";if(c===Wf)return"×";if(-1!==hp.indexOf(c)&&a===Zf||-1!==hp.indexOf(a)&&c===Zf)return"×";if(a===Yf&&-1!==[rp,ep,tp].indexOf(c)||-1!==[rp,ep,tp].indexOf(a)&&c===Jf)return"×";if(-1!==hp.indexOf(a)&&-1!==fp.indexOf(c)||-1!==fp.indexOf(a)&&-1!==hp.indexOf(c))return"×";if(-1!==[Yf,Jf].indexOf(a)&&(c===Zf||-1!==[Xf,Hf].indexOf(c)&&t[o+1]===Zf)||-1!==[Xf,Hf].indexOf(a)&&c===Zf||a===Zf&&-1!==[Zf,$f,Kf].indexOf(c))return"×";if(-1!==[Zf,$f,Kf,Nf,Gf].indexOf(c))for(var h=n;h>=0;){if((u=t[h])===Zf)return"×";if(-1===[$f,Kf].indexOf(u))break;h--}if(-1!==[Yf,Jf].indexOf(c))for(h=-1!==[Nf,Gf].indexOf(a)?A:n;h>=0;){var u;if((u=t[h])===Zf)return"×";if(-1===[$f,Kf].indexOf(u))break;h--}if(np===a&&-1!==[np,Ap,ip,sp].indexOf(c)||-1!==[Ap,ip].indexOf(a)&&-1!==[Ap,op].indexOf(c)||-1!==[op,sp].indexOf(a)&&c===op)return"×";if(-1!==gp.indexOf(a)&&-1!==[Wf,Jf].indexOf(c)||-1!==gp.indexOf(c)&&a===Yf)return"×";if(-1!==hp.indexOf(a)&&-1!==hp.indexOf(c))return"×";if(a===Kf&&-1!==hp.indexOf(c))return"×";if(-1!==hp.concat(Zf).indexOf(a)&&c===Xf&&-1===lp.indexOf(e[o])||-1!==hp.concat(Zf).indexOf(c)&&a===Gf)return"×";if(41===a&&41===c){for(var d=i[n],f=1;d>0&&41===t[--d];)f++;if(f%2!=0)return"×"}return a===ep&&c===tp?"×":"÷"},yp=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,n){var A=cp.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 s.push(n),i.push(16);if(4===A||11===A){if(0===n)return s.push(n),i.push(qf);var o=i[n-1];return-1===pp.indexOf(o)?(s.push(s[n-1]),i.push(o)):(s.push(n),i.push(qf))}return s.push(n),31===A?i.push("strict"===t?zf:rp):A===ap||29===A?i.push(qf):43===A?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(rp):i.push(qf):void i.push(A)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],n=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[Zf,qf,ap].indexOf(e)?rp:e})));var A="keep-all"===t.wordBreak?n.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,A]},wp=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return Ff.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),vp=function(e){return e>=48&&e<=57},Cp=function(e){return vp(e)||e>=65&&e<=70||e>=97&&e<=102},Mp=function(e){return 10===e||9===e||32===e},Ep=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},Fp=function(e){return Ep(e)||vp(e)||45===e},Up=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},xp=function(e,t){return 92===e&&10!==t},Ip=function(e,t,i){return 45===e?Ep(t)||xp(t,i):!!Ep(e)||!(92!==e||!xp(e,t))},Tp=function(e,t,i){return 43===e||45===e?!!vp(t)||46===t&&vp(i):vp(46===e?t:e)},Pp=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];vp(e[t]);)s.push(e[t++]);var r=s.length?parseInt(Ff.apply(void 0,s),10):0;46===e[t]&&t++;for(var n=[];vp(e[t]);)n.push(e[t++]);var A=n.length,o=A?parseInt(Ff.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=[];vp(e[t]);)l.push(e[t++]);var c=l.length?parseInt(Ff.apply(void 0,l),10):0;return i*(r+o*Math.pow(10,-A))*Math.pow(10,a*c)},Sp={type:2},Dp={type:3},kp={type:4},Qp={type:13},Rp={type:8},Op={type:21},Vp={type:9},Lp={type:10},Hp={type:11},Np={type:12},Gp={type:14},jp={type:23},Wp={type:1},zp={type:25},Xp={type:24},Kp={type:26},Zp={type:27},Jp={type:28},Yp={type:29},$p={type:31},qp={type:32},eg=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(Ef(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==qp;)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),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(Fp(t)||xp(i,s)){var r=Ip(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Qp;break;case 39:return this.consumeStringToken(39);case 40:return Sp;case 41:return Dp;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Gp;break;case 43:if(Tp(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return kp;case 45:var n=e,A=this.peekCodePoint(0),o=this.peekCodePoint(1);if(Tp(n,A,o))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Ip(n,A,o))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===A&&62===o)return this.consumeCodePoint(),this.consumeCodePoint(),Xp;break;case 46:if(Tp(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 Kp;case 59:return Zp;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),zp;break;case 64:var l=this.peekCodePoint(0),c=this.peekCodePoint(1),h=this.peekCodePoint(2);if(Ip(l,c,h))return{type:7,value:this.consumeName()};break;case 91:return Jp;case 92:if(xp(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return Yp;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Rp;break;case 123:return Hp;case 125:return Np;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!Cp(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Vp;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Op;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Lp;break;case-1:return qp}return Mp(e)?(this.consumeWhiteSpace(),$p):vp(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Ep(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:Ff(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();Cp(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(Ff.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(Ff.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(Ff.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&Cp(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Cp(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(Ff.apply(void 0,r),16)}}return{type:30,start:s,end:s}},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 i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),jp)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:Ff.apply(void 0,e)};if(Mp(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:Ff.apply(void 0,e)}):(this.consumeBadUrlRemnants(),jp);if(34===s||39===s||40===s||Up(s))return this.consumeBadUrlRemnants(),jp;if(92===s){if(!xp(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),jp;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;Mp(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;xp(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=Ff.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Wp;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):xp(s,r)&&(t+=this.consumeStringSlice(i),t+=Ff(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());vp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&vp(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;vp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&vp(r)||vp(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;vp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Pp(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),n=this.peekCodePoint(2);return Ip(s,r,n)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Cp(e)){for(var t=Ff(e);Cp(this.peekCodePoint(0))&&t.length<6;)t+=Ff(this.consumeCodePoint());Mp(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(Fp(t))e+=Ff(t);else{if(!xp(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=Ff(this.consumeEscapedCodePoint())}}},e}(),tg=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new eg;return i.write(t),new e(i.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:[]},i=this.consumeToken();;){if(32===i.type||cg(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?qp:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),ig=function(e){return 15===e.type},sg=function(e){return 17===e.type},rg=function(e){return 20===e.type},ng=function(e){return 0===e.type},Ag=function(e,t){return rg(e)&&e.value===t},og=function(e){return 31!==e.type},ag=function(e){return 31!==e.type&&4!==e.type},lg=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},cg=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},hg=function(e){return 17===e.type||15===e.type},ug=function(e){return 16===e.type||hg(e)},dg=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},fg={type:17,number:0,flags:4},pg={type:16,number:50,flags:4},gg={type:16,number:100,flags:4},mg=function(e,t,i){var s=e[0],r=e[1];return[_g(s,t),_g(void 0!==r?r:s,i)]},_g=function(e,t){if(16===e.type)return e.number/100*t;if(ig(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},bg=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")},Bg=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},yg=function(e){switch(e.filter(rg).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[fg,fg];case"to top":case"bottom":return wg(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[fg,gg];case"to right":case"left":return wg(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[gg,gg];case"to bottom":case"top":return wg(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[gg,fg];case"to left":case"right":return wg(270)}return 0},wg=function(e){return Math.PI*e/180},vg=function(e,t){if(18===t.type){var i=Tg[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);return Eg(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),1)}if(4===t.value.length){s=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 Eg(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),parseInt(A+A,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6);return Eg(parseInt(s,16),parseInt(r,16),parseInt(n,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6),A=t.value.substring(6,8);return Eg(parseInt(s,16),parseInt(r,16),parseInt(n,16),parseInt(A,16)/255)}}if(20===t.type){var o=Sg[t.value.toUpperCase()];if(void 0!==o)return o}return Sg.TRANSPARENT},Cg=function(e){return 0==(255&e)},Mg=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},Eg=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},Fg=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},Ug=function(e,t){var i=t.filter(ag);if(3===i.length){var s=i.map(Fg),r=s[0],n=s[1],A=s[2];return Eg(r,n,A,1)}if(4===i.length){var o=i.map(Fg),a=(r=o[0],n=o[1],A=o[2],o[3]);return Eg(r,n,A,a)}return 0};function xg(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var Ig=function(e,t){var i=t.filter(ag),s=i[0],r=i[1],n=i[2],A=i[3],o=(17===s.type?wg(s.number):bg(e,s))/(2*Math.PI),a=ug(r)?r.number/100:0,l=ug(n)?n.number/100:0,c=void 0!==A&&ug(A)?_g(A,1):1;if(0===a)return Eg(255*l,255*l,255*l,1);var h=l<=.5?l*(a+1):l+a-l*a,u=2*l-h,d=xg(u,h,o+1/3),f=xg(u,h,o),p=xg(u,h,o-1/3);return Eg(255*d,255*f,255*p,c)},Tg={hsl:Ig,hsla:Ig,rgb:Ug,rgba:Ug},Pg=function(e,t){return vg(e,tg.create(t).parseComponentValue())},Sg={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},Dg={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(rg(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},kg={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Qg=function(e,t){var i=vg(e,t[0]),s=t[1];return s&&ug(s)?{color:i,stop:s}:{color:i,stop:null}},Rg=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=fg),null===s.stop&&(s.stop=gg);for(var r=[],n=0,A=0;A<e.length;A++){var o=e[A].stop;if(null!==o){var a=_g(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,i){return{color:e.color,stop:Math.max(Math.min(1,r[i]/t),0)}}))},Og=function(e,t,i){var s="number"==typeof e?e:function(e,t,i){var s=t/2,r=i/2,n=_g(e[0],t)-s,A=r-_g(e[1],i);return(Math.atan2(A,n)+2*Math.PI)%(2*Math.PI)}(e,t,i),r=Math.abs(t*Math.sin(s))+Math.abs(i*Math.cos(s)),n=t/2,A=i/2,o=r/2,a=Math.sin(s-Math.PI/2)*o,l=Math.cos(s-Math.PI/2)*o;return[r,n-l,n+l,A-a,A+a]},Vg=function(e,t){return Math.sqrt(e*e+t*t)},Lg=function(e,t,i,s,r){return[[0,0],[0,t],[e,0],[e,t]].reduce((function(e,t){var n=t[0],A=t[1],o=Vg(i-n,s-A);return(r?o<e.optimumDistance:o>e.optimumDistance)?{optimumCorner:t,optimumDistance:o}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},Hg=function(e,t){var i=wg(180),s=[];return lg(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(i=yg(t));if(Bg(n))return void(i=(bg(e,n)+wg(270))%wg(360))}var A=Qg(e,t);s.push(A)})),{angle:i,stops:s,type:1}},Ng=function(e,t){var i=0,s=3,r=[],n=[];return lg(t).forEach((function(t,A){var o=!0;if(0===A?o=t.reduce((function(e,t){if(rg(t))switch(t.value){case"center":return n.push(pg),!1;case"top":case"left":return n.push(fg),!1;case"right":case"bottom":return n.push(gg),!1}else if(ug(t)||hg(t))return n.push(t),!1;return e}),o):1===A&&(o=t.reduce((function(e,t){if(rg(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(hg(t)||ug(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),o)),o){var a=Qg(e,t);r.push(a)}})),{size:s,shape:i,stops:r,position:n,type:2}},Gg=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Wg[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var jg,Wg={"linear-gradient":function(e,t){var i=wg(180),s=[];return lg(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&"to"===n.value)return void(i=yg(t));if(Bg(n))return void(i=bg(e,n))}var A=Qg(e,t);s.push(A)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":Hg,"-ms-linear-gradient":Hg,"-o-linear-gradient":Hg,"-webkit-linear-gradient":Hg,"radial-gradient":function(e,t){var i=0,s=3,r=[],n=[];return lg(t).forEach((function(t,A){var o=!0;if(0===A){var a=!1;o=t.reduce((function(e,t){if(a)if(rg(t))switch(t.value){case"center":return n.push(pg),e;case"top":case"left":return n.push(fg),e;case"right":case"bottom":return n.push(gg),e}else(ug(t)||hg(t))&&n.push(t);else if(rg(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return a=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(hg(t)||ug(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),o)}if(o){var l=Qg(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:n,type:2}},"-moz-radial-gradient":Ng,"-ms-radial-gradient":Ng,"-o-radial-gradient":Ng,"-webkit-radial-gradient":Ng,"-webkit-gradient":function(e,t){var i=wg(180),s=[],r=1;return lg(t).forEach((function(t,i){var n=t[0];if(0===i){if(rg(n)&&"linear"===n.value)return void(r=1);if(rg(n)&&"radial"===n.value)return void(r=2)}if(18===n.type)if("from"===n.name){var A=vg(e,n.values[0]);s.push({stop:fg,color:A})}else if("to"===n.name){A=vg(e,n.values[0]);s.push({stop:gg,color:A})}else if("color-stop"===n.name){var o=n.values.filter(ag);if(2===o.length){A=vg(e,o[1]);var a=o[0];sg(a)&&s.push({stop:{type:16,number:100*a.number,flags:a.flags},color:A})}}})),1===r?{angle:(i+wg(180))%wg(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},zg={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return ag(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Wg[e.name])}(e)})).map((function(t){return Gg(e,t)}))}},Xg={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(rg(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Kg={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return lg(t).map((function(e){return e.filter(ug)})).map(dg)}},Zg={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return lg(t).map((function(e){return e.filter(rg).map((function(e){return e.value})).join(" ")})).map(Jg)}},Jg=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"}(jg||(jg={}));var Yg,$g={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return lg(t).map((function(e){return e.filter(qg)}))}},qg=function(e){return rg(e)||ug(e)},em=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},tm=em("top"),im=em("right"),sm=em("bottom"),rm=em("left"),nm=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return dg(t.filter(ug))}}},Am=nm("top-left"),om=nm("top-right"),am=nm("bottom-right"),lm=nm("bottom-left"),cm=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}}},hm=cm("top"),um=cm("right"),dm=cm("bottom"),fm=cm("left"),pm=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return ig(t)?t.number:0}}},gm=pm("top"),mm=pm("right"),_m=pm("bottom"),bm=pm("left"),Bm={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ym={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},wm={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(rg).reduce((function(e,t){return e|vm(t.value)}),0)}},vm=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},Cm={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}},Mm={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"}(Yg||(Yg={}));var Em,Fm={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?Yg.STRICT:Yg.NORMAL}},Um={name:"line-height",initialValue:"normal",prefix:!1,type:4},xm=function(e,t){return rg(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:ug(e)?_g(e,t):t},Im={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:Gg(e,t)}},Tm={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Pm={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}}},Sm=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Dm=Sm("top"),km=Sm("right"),Qm=Sm("bottom"),Rm=Sm("left"),Om={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(rg).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}}))}},Vm={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Lm=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Hm=Lm("top"),Nm=Lm("right"),Gm=Lm("bottom"),jm=Lm("left"),Wm={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}}},zm={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}},Xm={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Ag(t[0],"none")?[]:lg(t).map((function(t){for(var i={color:Sg.TRANSPARENT,offsetX:fg,offsetY:fg,blur:fg},s=0,r=0;r<t.length;r++){var n=t[r];hg(n)?(0===s?i.offsetX=n:1===s?i.offsetY=n:i.blur=n,s++):i.color=vg(e,n)}return i}))}},Km={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}},Zm={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 i=Jm[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported transform function "'+t.name+'"');return i(t.values)}return null}},Jm={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})),i=t[0],s=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?[i,s,r,n,A,o]:null}},Ym={type:16,number:50,flags:4},$m=[Ym,Ym],qm={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(e,t){var i=t.filter(ug);return 2!==i.length?$m:[i[0],i[1]]}},e_={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"}(Em||(Em={}));for(var t_={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){switch(t){case"break-all":return Em.BREAK_ALL;case"keep-all":return Em.KEEP_ALL;default:return Em.NORMAL}}},i_={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(e,t){if(20===t.type)return{auto:!0,order:0};if(sg(t))return{auto:!1,order:t.number};throw new Error("Invalid z-index number parsed")}},s_=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")},r_={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(e,t){return sg(t)?t.number:1}},n_={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},A_={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(e,t){return t.filter(rg).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}))}},o_={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(e,t){var i=[],s=[];return t.forEach((function(e){switch(e.type){case 20:case 0:i.push(e.value);break;case 17:i.push(e.number.toString());break;case 4:s.push(i.join(" ")),i.length=0}})),i.length&&s.push(i.join(" ")),s.map((function(e){return-1===e.indexOf(" ")?e:"'"+e+"'"}))}},a_={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},l_={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(e,t){return sg(t)?t.number:rg(t)&&"bold"===t.value?700:400}},c_={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return t.filter(rg).map((function(e){return e.value}))}},h_={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"}}},u_=function(e,t){return 0!=(e&t)},d_={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t}},f_={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var i=t[0];if(20===i.type&&"none"===i.value)return null;for(var s=[],r=t.filter(og),n=0;n<r.length;n++){var A=r[n],o=r[n+1];if(20===A.type){var a=o&&sg(o)?o.number:1;s.push({counter:A.value,increment:a})}}return s}},p_={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return[];for(var i=[],s=t.filter(og),r=0;r<s.length;r++){var n=s[r],A=s[r+1];if(rg(n)&&"none"!==n.value){var o=A&&sg(A)?A.number:0;i.push({counter:n.value,reset:o})}}return i}},g_={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(e,t){return t.filter(ig).map((function(t){return s_(e,t)}))}},m_={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var i=t[0];if(20===i.type&&"none"===i.value)return null;var s=[],r=t.filter(ng);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;s.push({open:A,close:o})}return s}},__=function(e,t,i){if(!e)return"";var s=e[Math.min(t,e.length-1)];return s?i?s.open:s.close:""},b_={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Ag(t[0],"none")?[]:lg(t).map((function(t){for(var i={color:255,offsetX:fg,offsetY:fg,blur:fg,spread:fg,inset:!1},s=0,r=0;r<t.length;r++){var n=t[r];Ag(n,"inset")?i.inset=!0:hg(n)?(0===s?i.offsetX=n:1===s?i.offsetY=n:2===s?i.blur=n:i.spread=n,s++):i.color=vg(e,n)}return i}))}},B_={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(e,t){var i=[];return t.filter(rg).forEach((function(e){switch(e.value){case"stroke":i.push(1);break;case"fill":i.push(0);break;case"markers":i.push(2)}})),[0,1,2].forEach((function(e){-1===i.indexOf(e)&&i.push(e)})),i}},y_={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},w_={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return ig(t)?t.number:0}},v_=function(){function e(e,t){var i,s;this.animationDuration=E_(e,g_,t.animationDuration),this.backgroundClip=E_(e,Dg,t.backgroundClip),this.backgroundColor=E_(e,kg,t.backgroundColor),this.backgroundImage=E_(e,zg,t.backgroundImage),this.backgroundOrigin=E_(e,Xg,t.backgroundOrigin),this.backgroundPosition=E_(e,Kg,t.backgroundPosition),this.backgroundRepeat=E_(e,Zg,t.backgroundRepeat),this.backgroundSize=E_(e,$g,t.backgroundSize),this.borderTopColor=E_(e,tm,t.borderTopColor),this.borderRightColor=E_(e,im,t.borderRightColor),this.borderBottomColor=E_(e,sm,t.borderBottomColor),this.borderLeftColor=E_(e,rm,t.borderLeftColor),this.borderTopLeftRadius=E_(e,Am,t.borderTopLeftRadius),this.borderTopRightRadius=E_(e,om,t.borderTopRightRadius),this.borderBottomRightRadius=E_(e,am,t.borderBottomRightRadius),this.borderBottomLeftRadius=E_(e,lm,t.borderBottomLeftRadius),this.borderTopStyle=E_(e,hm,t.borderTopStyle),this.borderRightStyle=E_(e,um,t.borderRightStyle),this.borderBottomStyle=E_(e,dm,t.borderBottomStyle),this.borderLeftStyle=E_(e,fm,t.borderLeftStyle),this.borderTopWidth=E_(e,gm,t.borderTopWidth),this.borderRightWidth=E_(e,mm,t.borderRightWidth),this.borderBottomWidth=E_(e,_m,t.borderBottomWidth),this.borderLeftWidth=E_(e,bm,t.borderLeftWidth),this.boxShadow=E_(e,b_,t.boxShadow),this.color=E_(e,Bm,t.color),this.direction=E_(e,ym,t.direction),this.display=E_(e,wm,t.display),this.float=E_(e,Cm,t.cssFloat),this.fontFamily=E_(e,o_,t.fontFamily),this.fontSize=E_(e,a_,t.fontSize),this.fontStyle=E_(e,h_,t.fontStyle),this.fontVariant=E_(e,c_,t.fontVariant),this.fontWeight=E_(e,l_,t.fontWeight),this.letterSpacing=E_(e,Mm,t.letterSpacing),this.lineBreak=E_(e,Fm,t.lineBreak),this.lineHeight=E_(e,Um,t.lineHeight),this.listStyleImage=E_(e,Im,t.listStyleImage),this.listStylePosition=E_(e,Tm,t.listStylePosition),this.listStyleType=E_(e,Pm,t.listStyleType),this.marginTop=E_(e,Dm,t.marginTop),this.marginRight=E_(e,km,t.marginRight),this.marginBottom=E_(e,Qm,t.marginBottom),this.marginLeft=E_(e,Rm,t.marginLeft),this.opacity=E_(e,r_,t.opacity);var r=E_(e,Om,t.overflow);this.overflowX=r[0],this.overflowY=r[r.length>1?1:0],this.overflowWrap=E_(e,Vm,t.overflowWrap),this.paddingTop=E_(e,Hm,t.paddingTop),this.paddingRight=E_(e,Nm,t.paddingRight),this.paddingBottom=E_(e,Gm,t.paddingBottom),this.paddingLeft=E_(e,jm,t.paddingLeft),this.paintOrder=E_(e,B_,t.paintOrder),this.position=E_(e,zm,t.position),this.textAlign=E_(e,Wm,t.textAlign),this.textDecorationColor=E_(e,n_,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=E_(e,A_,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=E_(e,Xm,t.textShadow),this.textTransform=E_(e,Km,t.textTransform),this.transform=E_(e,Zm,t.transform),this.transformOrigin=E_(e,qm,t.transformOrigin),this.visibility=E_(e,e_,t.visibility),this.webkitTextStrokeColor=E_(e,y_,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=E_(e,w_,t.webkitTextStrokeWidth),this.wordBreak=E_(e,t_,t.wordBreak),this.zIndex=E_(e,i_,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return Cg(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 u_(this.display,4)||u_(this.display,33554432)||u_(this.display,268435456)||u_(this.display,536870912)||u_(this.display,67108864)||u_(this.display,134217728)},e}(),C_=function(e,t){this.content=E_(e,d_,t.content),this.quotes=E_(e,m_,t.quotes)},M_=function(e,t){this.counterIncrement=E_(e,f_,t.counterIncrement),this.counterReset=E_(e,p_,t.counterReset)},E_=function(e,t,i){var s=new eg,r=null!=i?i.toString():t.initialValue;s.write(r);var n=new tg(s.read());switch(t.type){case 2:var A=n.parseComponentValue();return t.parse(e,rg(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 bg(e,n.parseComponentValue());case"color":return vg(e,n.parseComponentValue());case"image":return Gg(e,n.parseComponentValue());case"length":var o=n.parseComponentValue();return hg(o)?o:fg;case"length-percentage":var a=n.parseComponentValue();return ug(a)?a:fg;case"time":return s_(e,n.parseComponentValue())}}},F_=function(e,t){var i=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===i||t===i},U_=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,F_(t,3),this.styles=new v_(e,window.getComputedStyle(t,null)),Ub(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=Mf(this.context,t),F_(t,4)&&(this.flags|=16)},x_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",I_="undefined"==typeof Uint8Array?[]:new Uint8Array(256),T_=0;T_<x_.length;T_++)I_[x_.charCodeAt(T_)]=T_;for(var P_=function(e,t,i){return e.slice?e.slice(t,i):new Uint16Array(Array.prototype.slice.call(e,t,i))},S_=function(){function e(e,t,i,s,r,n){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=s,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}(),D_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k_="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Q_=0;Q_<D_.length;Q_++)k_[D_.charCodeAt(Q_)]=Q_;var R_,O_=8,V_=9,L_=11,H_=12,N_=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var i=e.length;if(!i)return"";for(var s=[],r=-1,n="";++r<i;){var A=e[r];A<=65535?s.push(A):(A-=65536,s.push(55296+(A>>10),A%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},G_=function(e,t){var i,s,r,n=function(e){var t,i,s,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)i=I_[e.charCodeAt(t)],s=I_[e.charCodeAt(t+1)],r=I_[e.charCodeAt(t+2)],n=I_[e.charCodeAt(t+3)],c[a++]=i<<2|s>>4,c[a++]=(15&s)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=4)i.push(e[s+3]<<24|e[s+2]<<16|e[s+1]<<8|e[s]);return i}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=2)i.push(e[s+1]<<8|e[s]);return i}(n):new Uint16Array(n),a=P_(o,12,A[4]/2),l=2===A[5]?P_(o,(24+A[4])/2):(i=A,s=Math.ceil((24+A[4])/4),i.slice?i.slice(s,r):new Uint32Array(Array.prototype.slice.call(i,s,r)));return new S_(A[0],A[1],A[2],A[3],a,l)}("AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA="),j_=function(e){return G_.get(e)},W_=function(e,t,i){var s=i-2,r=t[s],n=t[i-1],A=t[i];if(2===n&&3===A)return"×";if(2===n||3===n||4===n)return"÷";if(2===A||3===A||4===A)return"÷";if(n===O_&&-1!==[O_,V_,L_,H_].indexOf(A))return"×";if(!(n!==L_&&n!==V_||A!==V_&&10!==A))return"×";if((n===H_||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[--s];if(14===r)return"×"}if(15===n&&15===A){for(var o=0;15===r;)o++,r=t[--s];if(o%2==0)return"×"}return"÷"},z_=function(e){var t=function(e){for(var t=[],i=0,s=e.length;i<s;){var r=e.charCodeAt(i++);if(r>=55296&&r<=56319&&i<s){var n=e.charCodeAt(i++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),i--)}else t.push(r)}return t}(e),i=t.length,s=0,r=0,n=t.map(j_);return{next:function(){if(s>=i)return{done:!0,value:null};for(var e="×";s<i&&"×"===(e=W_(0,n,++s)););if("×"!==e||s===i){var A=N_.apply(null,t.slice(r,s));return r=s,{value:A,done:!1}}return{done:!0,value:null}}}},X_=function(e){return 0===e[0]&&255===e[1]&&0===e[2]&&255===e[3]},K_=function(e,t,i,s,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",i.toString()),o.setAttributeNS(null,"y",s.toString()),o.setAttributeNS(null,"externalResourcesRequired","true"),A.appendChild(o),o.appendChild(r),A},Z_=function(e){return new Promise((function(t,i){var s=new Image;s.onload=function(){return t(s)},s.onerror=i,s.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},J_={get SUPPORT_RANGE_BOUNDS(){var e=function(e){if(e.createRange){var t=e.createRange();if(t.getBoundingClientRect){var i=e.createElement("boundtest");i.style.height="123px",i.style.display="block",e.body.appendChild(i),t.selectNode(i);var s=t.getBoundingClientRect(),r=Math.round(s.height);if(e.body.removeChild(i),123===r)return!0}}return!1}(document);return Object.defineProperty(J_,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=J_.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 i=e.createRange();t.innerHTML="function"==typeof"".repeat?"👨".repeat(10):"";var s=t.firstChild,r=Ef(s.data).map((function(e){return Ff(e)})),n=0,A={},o=r.every((function(e,t){i.setStart(s,n),i.setEnd(s,n+e.length);var r=i.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(J_,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(J_,"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"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,n=t.toDataURL();r.src=n;var A=K_(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),Z_(A).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var A=e.createElement("div");return A.style.backgroundImage="url("+n+")",A.style.height="100px",X_(r)?Z_(K_(i,i,0,0,A)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),X_(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(J_,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(J_,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(J_,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(J_,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(J_,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Y_=function(e,t){this.text=e,this.bounds=t},$_=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var n=Mf(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),n}}return Cf.EMPTY},q_=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},eb=function(e){if(J_.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,i=z_(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},tb=function(e,t){return 0!==t.letterSpacing?eb(e):function(e,t){if(J_.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return sb(e,t)}(e,t)},ib=[32,160,4961,65792,65793,4153,4241],sb=function(e,t){for(var i,s=function(e,t){var i=Ef(e),s=yp(i,t),r=s[0],n=s[1],A=s[2],o=i.length,a=0,l=0;return{next:function(){if(l>=o)return{done:!0,value:null};for(var e="×";l<o&&"×"===(e=Bp(i,n,r,++l,A)););if("×"!==e||l===o){var t=new wp(i,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(i.value){var e=i.value.slice(),t=Ef(e),s="";t.forEach((function(e){-1===ib.indexOf(e)?s+=Ff(e):(s.length&&r.push(s),r.push(Ff(e)),s="")})),s.length&&r.push(s)}};!(i=s.next()).done;)n();return r},rb=function(e,t,i){this.text=nb(t.data,i.textTransform),this.textBounds=function(e,t,i,s){var r=tb(t,i),n=[],A=0;return r.forEach((function(t){if(i.textDecorationLine.length||t.trim().length>0)if(J_.SUPPORT_RANGE_BOUNDS){var r=q_(s,A,t.length).getClientRects();if(r.length>1){var o=eb(t),a=0;o.forEach((function(t){n.push(new Y_(t,Cf.fromDOMRectList(e,q_(s,a+A,t.length).getClientRects()))),a+=t.length}))}else n.push(new Y_(t,Cf.fromDOMRectList(e,r)))}else{var l=s.splitText(t.length);n.push(new Y_(t,$_(e,s))),s=l}else J_.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));A+=t.length})),n}(e,this.text,i,t)},nb=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Ab,ob);case 2:return e.toUpperCase();default:return e}},Ab=/(^|\s|:|-|\(|\))([a-z])/g,ob=function(e,t,i){return e.length>0?t+i.toUpperCase():e},ab=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return bf(t,e),t}(U_),lb=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return bf(t,e),t}(U_),cb=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,n=Mf(t,i);return i.setAttribute("width",n.width+"px"),i.setAttribute("height",n.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return bf(t,e),t}(U_),hb=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return bf(t,e),t}(U_),ub=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return bf(t,e),t}(U_),db=[{type:15,flags:0,unit:"px",number:3}],fb=[{type:16,flags:0,number:50}],pb="password",gb=function(e){function t(t,i){var s,r,n,A=e.call(this,t,i)||this;switch(A.type=i.type.toLowerCase(),A.checked=i.checked,A.value=0===(r=(s=i).type===pb?new Array(s.value.length+1).join("•"):s.value).length?s.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 Cf(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width<n.height?new Cf(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=db;break;case"radio":A.styles.borderTopRightRadius=A.styles.borderTopLeftRadius=A.styles.borderBottomRightRadius=A.styles.borderBottomLeftRadius=fb}return A}return bf(t,e),t}(U_),mb=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=i.options[i.selectedIndex||0];return s.value=r&&r.text||"",s}return bf(t,e),t}(U_),_b=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return bf(t,e),t}(U_),bb=function(e){function t(t,i){var s=e.call(this,t,i)||this;s.src=i.src,s.width=parseInt(i.width,10)||0,s.height=parseInt(i.height,10)||0,s.backgroundColor=s.styles.backgroundColor;try{if(i.contentWindow&&i.contentWindow.document&&i.contentWindow.document.documentElement){s.tree=vb(t,i.contentWindow.document.documentElement);var r=i.contentWindow.document.documentElement?Pg(t,getComputedStyle(i.contentWindow.document.documentElement).backgroundColor):Sg.TRANSPARENT,n=i.contentWindow.document.body?Pg(t,getComputedStyle(i.contentWindow.document.body).backgroundColor):Sg.TRANSPARENT;s.backgroundColor=Cg(r)?Cg(n)?s.styles.backgroundColor:n:r}}catch(e){}return s}return bf(t,e),t}(U_),Bb=["OL","UL","MENU"],yb=function(e,t,i,s){for(var r=t.firstChild,n=void 0;r;r=n)if(n=r.nextSibling,Eb(r)&&r.data.trim().length>0)i.textNodes.push(new rb(e,r,i.styles));else if(Fb(r))if(Nb(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return yb(e,t,i,s)}));else{var A=wb(e,r);A.styles.isVisible()&&(Cb(r,A,s)?A.flags|=4:Mb(A.styles)&&(A.flags|=2),-1!==Bb.indexOf(r.tagName)&&(A.flags|=8),i.elements.push(A),r.slot,r.shadowRoot?yb(e,r.shadowRoot,A,s):Lb(r)||Sb(r)||Hb(r)||yb(e,r,A,s))}},wb=function(e,t){return Rb(t)?new ab(e,t):kb(t)?new lb(e,t):Sb(t)?new cb(e,t):Ib(t)?new hb(e,t):Tb(t)?new ub(e,t):Pb(t)?new gb(e,t):Hb(t)?new mb(e,t):Lb(t)?new _b(e,t):Ob(t)?new bb(e,t):new U_(e,t)},vb=function(e,t){var i=wb(e,t);return i.flags|=4,yb(e,t,i,i),i},Cb=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||Db(e)&&i.styles.isTransparent()},Mb=function(e){return e.isPositioned()||e.isFloating()},Eb=function(e){return e.nodeType===Node.TEXT_NODE},Fb=function(e){return e.nodeType===Node.ELEMENT_NODE},Ub=function(e){return Fb(e)&&void 0!==e.style&&!xb(e)},xb=function(e){return"object"==typeof e.className},Ib=function(e){return"LI"===e.tagName},Tb=function(e){return"OL"===e.tagName},Pb=function(e){return"INPUT"===e.tagName},Sb=function(e){return"svg"===e.tagName},Db=function(e){return"BODY"===e.tagName},kb=function(e){return"CANVAS"===e.tagName},Qb=function(e){return"VIDEO"===e.tagName},Rb=function(e){return"IMG"===e.tagName},Ob=function(e){return"IFRAME"===e.tagName},Vb=function(e){return"STYLE"===e.tagName},Lb=function(e){return"TEXTAREA"===e.tagName},Hb=function(e){return"SELECT"===e.tagName},Nb=function(e){return"SLOT"===e.tagName},Gb=function(e){return e.tagName.indexOf("-")>0},jb=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,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var n=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];n.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),n},e}(),Wb={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"]},zb={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:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Xb={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:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Kb={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:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Zb=function(e,t,i,s,r,n){return e<t||e>i?eB(e,r,n.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+n},Jb=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},Yb=function(e,t,i,s,r){var n=i-t+1;return(e<0?"-":"")+(Jb(Math.abs(e),n,s,(function(e){return Ff(Math.floor(e%n)+t)}))+r)},$b=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return Jb(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},qb=function(e,t,i,s,r,n){if(e<-9999||e>9999)return eB(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&&u_(n,1)&&""!==o?o=t[l]+o:l>1||1===l&&0===a||1===l&&1===a&&u_(n,2)||1===l&&1===a&&u_(n,4)&&e>100||1===l&&a>1&&u_(n,8)?o=t[l]+(a>0?i[a-1]:"")+o:1===l&&a>0&&(o=i[a-1]+o),A=Math.floor(A/10)}return(e<0?s:"")+o},eB=function(e,t,i){var s=i?". ":"",r=i?"、":"",n=i?", ":"",A=i?" ":"";switch(t){case 0:return"•"+A;case 1:return"◦"+A;case 2:return"◾"+A;case 5:var o=Yb(e,48,57,!0,s);return o.length<4?"0"+o:o;case 4:return $b(e,"〇一二三四五六七八九",r);case 6:return Zb(e,1,3999,Wb,3,s).toLowerCase();case 7:return Zb(e,1,3999,Wb,3,s);case 8:return Yb(e,945,969,!1,s);case 9:return Yb(e,97,122,!1,s);case 10:return Yb(e,65,90,!1,s);case 11:return Yb(e,1632,1641,!0,s);case 12:case 49:return Zb(e,1,9999,zb,3,s);case 35:return Zb(e,1,9999,zb,3,s).toLowerCase();case 13:return Yb(e,2534,2543,!0,s);case 14:case 30:return Yb(e,6112,6121,!0,s);case 15:return $b(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return $b(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return qb(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return qb(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return qb(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return qb(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return qb(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return qb(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return qb(e,"영일이삼사오육칠팔구","십백천만","마이너스",n,7);case 33:return qb(e,"零一二三四五六七八九","十百千萬","마이너스",n,0);case 32:return qb(e,"零壹貳參四五六七八九","拾百千","마이너스",n,7);case 18:return Yb(e,2406,2415,!0,s);case 20:return Zb(e,1,19999,Kb,3,s);case 21:return Yb(e,2790,2799,!0,s);case 22:return Yb(e,2662,2671,!0,s);case 22:return Zb(e,1,10999,Xb,3,s);case 23:return $b(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return $b(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return Yb(e,3302,3311,!0,s);case 28:return $b(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return $b(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return Yb(e,3792,3801,!0,s);case 37:return Yb(e,6160,6169,!0,s);case 38:return Yb(e,4160,4169,!0,s);case 39:return Yb(e,2918,2927,!0,s);case 40:return Yb(e,1776,1785,!0,s);case 43:return Yb(e,3046,3055,!0,s);case 44:return Yb(e,3174,3183,!0,s);case 45:return Yb(e,3664,3673,!0,s);case 46:return Yb(e,3872,3881,!0,s);default:return Yb(e,48,57,!0,s)}},tB=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new jb,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 i=this,s=sB(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,n=e.defaultView.pageYOffset,A=s.contentWindow,o=A.document,a=AB(s).then((function(){return yf(i,void 0,void 0,(function(){var e,i;return wf(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(hB),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===(i=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,nB(o)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(o,i)})).then((function(){return s}))]:[2,s]}}))}))}));return o.open(),o.write(lB(document.doctype)+"<html></html>"),cB(this.referenceElement.ownerDocument,r,n),o.replaceChild(o.adoptNode(this.documentElement),o.documentElement),o.close(),a},e.prototype.createElementClone=function(e){if(F_(e,2),kb(e))return this.createCanvasClone(e);if(Qb(e))return this.createVideoClone(e);if(Vb(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Rb(t)&&(Rb(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),Gb(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return aB(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}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 i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),n=s.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 s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){Fb(t)&&("SCRIPT"===t.tagName||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&Fb(t)&&Vb(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(Fb(r)&&Nb(r)&&"function"==typeof r.assignedNodes){var n=r.assignedNodes();n.length&&n.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(Eb(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&Fb(e)&&(Ub(e)||xb(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),n=i.getComputedStyle(e,":before"),A=i.getComputedStyle(e,":after");this.referenceElement===e&&Ub(s)&&(this.clonedReferenceElement=s),Db(s)&&fB(s);var o=this.counters.parse(new M_(this.context,r)),a=this.resolvePseudoContent(e,s,n,R_.BEFORE);Gb(e)&&(t=!0),Qb(e)||this.cloneChildNodes(e,s,t),a&&s.insertBefore(a,s.firstChild);var l=this.resolvePseudoContent(e,s,A,R_.AFTER);return l&&s.appendChild(l),this.counters.pop(o),(r&&(this.options.copyStyles||xb(e))&&!Ob(e)||t)&&aB(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(Lb(e)||Hb(e))&&(Lb(s)||Hb(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var n=i.content,A=t.ownerDocument;if(A&&n&&"none"!==n&&"-moz-alt-content"!==n&&"none"!==i.display){this.counters.parse(new M_(this.context,i));var o=new C_(this.context,i),a=A.createElement("html2canvaspseudoelement");aB(i,a),o.content.forEach((function(t){if(0===t.type)a.appendChild(A.createTextNode(t.value));else if(22===t.type){var i=A.createElement("img");i.src=t.value,i.style.opacity="1",a.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(rg);s.length&&a.appendChild(A.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var n=t.values.filter(ag),l=n[0],c=n[1];if(l&&rg(l)){var h=r.counters.getCounterValue(l.value),u=c&&rg(c)?Pm.parse(r.context,c.value):3;a.appendChild(A.createTextNode(eB(h,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(ag),f=(l=d[0],d[1]);c=d[2];if(l&&rg(l)){var p=r.counters.getCounterValues(l.value),g=c&&rg(c)?Pm.parse(r.context,c.value):3,m=f&&0===f.type?f.value:"",_=p.map((function(e){return eB(e,g,!1)})).join(m);a.appendChild(A.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":a.appendChild(A.createTextNode(__(o.quotes,r.quoteDepth++,!0)));break;case"close-quote":a.appendChild(A.createTextNode(__(o.quotes,--r.quoteDepth,!1)));break;default:a.appendChild(A.createTextNode(t.value))}})),a.className=uB+" "+dB;var l=s===R_.BEFORE?" "+uB:" "+dB;return xb(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"}(R_||(R_={}));var iB,sB=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},rB=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},nB=function(e){return Promise.all([].slice.call(e.images,0).map(rB))},AB=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},oB=["all","d","content"],aB=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===oB.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},lB=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},cB=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},hB=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},uB="___html2canvas___pseudoelement_before",dB="___html2canvas___pseudoelement_after",fB=function(e){pB(e,"."+uB+':before{\n content: "" !important;\n display: none !important;\n}\n .'+dB+':after{\n content: "" !important;\n display: none !important;\n}')},pB=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},gB=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.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}(),mB=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:CB(e)||yB(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 yf(this,void 0,void 0,(function(){var t,i,s,r,n=this;return wf(this,(function(A){switch(A.label){case 0:return t=gB.isSameOrigin(e),i=!wB(e)&&!0===this._options.useCORS&&J_.SUPPORT_CORS_IMAGES&&!t,s=!wB(e)&&!t&&!CB(e)&&"string"==typeof this._options.proxy&&J_.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||wB(e)||CB(e)||s||i?(r=e,s?[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 s=new Image;s.onload=function(){return e(s)},s.onerror=t,(vB(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),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,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,n){var A=J_.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 "+s+" with status code "+o.status)},o.onerror=n;var a=i.indexOf("?")>-1?"&":"?";if(o.open("GET",""+i+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 "+s)}}o.send()}))},e}(),_B=/^data:image\/svg\+xml/i,bB=/^data:image\/.*;base64,/i,BB=/^data:image\/.*/i,yB=function(e){return J_.SUPPORT_SVG_DRAWING||!MB(e)},wB=function(e){return BB.test(e)},vB=function(e){return bB.test(e)},CB=function(e){return"blob"===e.substr(0,4)},MB=function(e){return"svg"===e.substr(-3).toLowerCase()||_B.test(e)},EB=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),FB=function(e,t,i){return new EB(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},UB=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=FB(this.start,this.startControl,t),r=FB(this.startControl,this.endControl,t),n=FB(this.endControl,this.end,t),A=FB(s,r,t),o=FB(r,n,t),a=FB(A,o,t);return i?new e(this.start,s,A,a):new e(a,o,n,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),xB=function(e){return 1===e.type},IB=function(e){var t=e.styles,i=e.bounds,s=mg(t.borderTopLeftRadius,i.width,i.height),r=s[0],n=s[1],A=mg(t.borderTopRightRadius,i.width,i.height),o=A[0],a=A[1],l=mg(t.borderBottomRightRadius,i.width,i.height),c=l[0],h=l[1],u=mg(t.borderBottomLeftRadius,i.width,i.height),d=u[0],f=u[1],p=[];p.push((r+o)/i.width),p.push((d+c)/i.width),p.push((n+f)/i.height),p.push((a+h)/i.height);var g=Math.max.apply(Math,p);g>1&&(r/=g,n/=g,o/=g,a/=g,c/=g,h/=g,d/=g,f/=g);var m=i.width-o,_=i.height-h,b=i.width-c,B=i.height-f,y=t.borderTopWidth,w=t.borderRightWidth,v=t.borderBottomWidth,C=t.borderLeftWidth,M=_g(t.paddingTop,e.bounds.width),E=_g(t.paddingRight,e.bounds.width),F=_g(t.paddingBottom,e.bounds.width),U=_g(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||n>0?TB(i.left+C/3,i.top+y/3,r-C/3,n-y/3,iB.TOP_LEFT):new EB(i.left+C/3,i.top+y/3),this.topRightBorderDoubleOuterBox=r>0||n>0?TB(i.left+m,i.top+y/3,o-w/3,a-y/3,iB.TOP_RIGHT):new EB(i.left+i.width-w/3,i.top+y/3),this.bottomRightBorderDoubleOuterBox=c>0||h>0?TB(i.left+b,i.top+_,c-w/3,h-v/3,iB.BOTTOM_RIGHT):new EB(i.left+i.width-w/3,i.top+i.height-v/3),this.bottomLeftBorderDoubleOuterBox=d>0||f>0?TB(i.left+C/3,i.top+B,d-C/3,f-v/3,iB.BOTTOM_LEFT):new EB(i.left+C/3,i.top+i.height-v/3),this.topLeftBorderDoubleInnerBox=r>0||n>0?TB(i.left+2*C/3,i.top+2*y/3,r-2*C/3,n-2*y/3,iB.TOP_LEFT):new EB(i.left+2*C/3,i.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||n>0?TB(i.left+m,i.top+2*y/3,o-2*w/3,a-2*y/3,iB.TOP_RIGHT):new EB(i.left+i.width-2*w/3,i.top+2*y/3),this.bottomRightBorderDoubleInnerBox=c>0||h>0?TB(i.left+b,i.top+_,c-2*w/3,h-2*v/3,iB.BOTTOM_RIGHT):new EB(i.left+i.width-2*w/3,i.top+i.height-2*v/3),this.bottomLeftBorderDoubleInnerBox=d>0||f>0?TB(i.left+2*C/3,i.top+B,d-2*C/3,f-2*v/3,iB.BOTTOM_LEFT):new EB(i.left+2*C/3,i.top+i.height-2*v/3),this.topLeftBorderStroke=r>0||n>0?TB(i.left+C/2,i.top+y/2,r-C/2,n-y/2,iB.TOP_LEFT):new EB(i.left+C/2,i.top+y/2),this.topRightBorderStroke=r>0||n>0?TB(i.left+m,i.top+y/2,o-w/2,a-y/2,iB.TOP_RIGHT):new EB(i.left+i.width-w/2,i.top+y/2),this.bottomRightBorderStroke=c>0||h>0?TB(i.left+b,i.top+_,c-w/2,h-v/2,iB.BOTTOM_RIGHT):new EB(i.left+i.width-w/2,i.top+i.height-v/2),this.bottomLeftBorderStroke=d>0||f>0?TB(i.left+C/2,i.top+B,d-C/2,f-v/2,iB.BOTTOM_LEFT):new EB(i.left+C/2,i.top+i.height-v/2),this.topLeftBorderBox=r>0||n>0?TB(i.left,i.top,r,n,iB.TOP_LEFT):new EB(i.left,i.top),this.topRightBorderBox=o>0||a>0?TB(i.left+m,i.top,o,a,iB.TOP_RIGHT):new EB(i.left+i.width,i.top),this.bottomRightBorderBox=c>0||h>0?TB(i.left+b,i.top+_,c,h,iB.BOTTOM_RIGHT):new EB(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||f>0?TB(i.left,i.top+B,d,f,iB.BOTTOM_LEFT):new EB(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||n>0?TB(i.left+C,i.top+y,Math.max(0,r-C),Math.max(0,n-y),iB.TOP_LEFT):new EB(i.left+C,i.top+y),this.topRightPaddingBox=o>0||a>0?TB(i.left+Math.min(m,i.width-w),i.top+y,m>i.width+w?0:Math.max(0,o-w),Math.max(0,a-y),iB.TOP_RIGHT):new EB(i.left+i.width-w,i.top+y),this.bottomRightPaddingBox=c>0||h>0?TB(i.left+Math.min(b,i.width-C),i.top+Math.min(_,i.height-v),Math.max(0,c-w),Math.max(0,h-v),iB.BOTTOM_RIGHT):new EB(i.left+i.width-w,i.top+i.height-v),this.bottomLeftPaddingBox=d>0||f>0?TB(i.left+C,i.top+Math.min(B,i.height-v),Math.max(0,d-C),Math.max(0,f-v),iB.BOTTOM_LEFT):new EB(i.left+C,i.top+i.height-v),this.topLeftContentBox=r>0||n>0?TB(i.left+C+U,i.top+y+M,Math.max(0,r-(C+U)),Math.max(0,n-(y+M)),iB.TOP_LEFT):new EB(i.left+C+U,i.top+y+M),this.topRightContentBox=o>0||a>0?TB(i.left+Math.min(m,i.width+C+U),i.top+y+M,m>i.width+C+U?0:o-C+U,a-(y+M),iB.TOP_RIGHT):new EB(i.left+i.width-(w+E),i.top+y+M),this.bottomRightContentBox=c>0||h>0?TB(i.left+Math.min(b,i.width-(C+U)),i.top+Math.min(_,i.height+y+M),Math.max(0,c-(w+E)),h-(v+F),iB.BOTTOM_RIGHT):new EB(i.left+i.width-(w+E),i.top+i.height-(v+F)),this.bottomLeftContentBox=d>0||f>0?TB(i.left+C+U,i.top+B,Math.max(0,d-(C+U)),f-(v+F),iB.BOTTOM_LEFT):new EB(i.left+C+U,i.top+i.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"}(iB||(iB={}));var TB=function(e,t,i,s,r){var n=(Math.sqrt(2)-1)/3*4,A=i*n,o=s*n,a=e+i,l=t+s;switch(r){case iB.TOP_LEFT:return new UB(new EB(e,l),new EB(e,l-o),new EB(a-A,t),new EB(a,t));case iB.TOP_RIGHT:return new UB(new EB(e,t),new EB(e+A,t),new EB(a,l-o),new EB(a,l));case iB.BOTTOM_RIGHT:return new UB(new EB(a,t),new EB(a,t+o),new EB(e+A,l),new EB(e,l));case iB.BOTTOM_LEFT:default:return new UB(new EB(a,l),new EB(a-A,l),new EB(e,t+o),new EB(e,t))}},PB=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},SB=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},DB=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},kB=function(e,t){this.path=e,this.target=t,this.type=1},QB=function(e){this.opacity=e,this.type=2,this.target=6},RB=function(e){return 1===e.type},OB=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},VB=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},LB=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new IB(this.container),this.container.styles.opacity<1&&this.effects.push(new QB(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new DB(i,s,r))}if(0!==this.container.styles.overflowX){var n=PB(this.curves),A=SB(this.curves);OB(n,A)?this.effects.push(new kB(n,6)):(this.effects.push(new kB(n,2)),this.effects.push(new kB(A,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!RB(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var n=PB(i.curves),A=SB(i.curves);OB(n,A)||s.unshift(new kB(A,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return u_(t.target,e)}))},e}(),HB=function(e,t,i,s){e.container.elements.forEach((function(r){var n=u_(r.flags,4),A=u_(r.flags,2),o=new LB(r,e);u_(r.styles.display,2048)&&s.push(o);var a=u_(r.flags,8)?[]:s;if(n||A){var l=n||r.styles.isPositioned()?i:t,c=new VB(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);HB(o,c,n?c:i,a)}else r.styles.isInlineLevel()?t.inlineLevel.push(o):t.nonInlineLevel.push(o),HB(o,t,i,a);u_(r.flags,8)&&NB(r,a)}))},NB=function(e,t){for(var i=e instanceof ub?e.start:1,s=e instanceof ub&&e.reversed,r=0;r<t.length;r++){var n=t[r];n.container instanceof hb&&"number"==typeof n.container.value&&0!==n.container.value&&(i=n.container.value),n.listValue=eB(i,n.container.styles.listStyleType,!0),i+=s?-1:1}},GB=function(e,t){switch(t){case 0:return WB(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return WB(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return WB(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return WB(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},jB=function(e,t){var i=[];return xB(e)?i.push(e.subdivide(.5,!1)):i.push(e),xB(t)?i.push(t.subdivide(.5,!0)):i.push(t),i},WB=function(e,t,i,s){var r=[];return xB(e)?r.push(e.subdivide(.5,!1)):r.push(e),xB(i)?r.push(i.subdivide(.5,!0)):r.push(i),xB(s)?r.push(s.subdivide(.5,!0).reverse()):r.push(s),xB(t)?r.push(t.subdivide(.5,!1).reverse()):r.push(t),r},zB=function(e){var t=e.bounds,i=e.styles;return t.add(i.borderLeftWidth,i.borderTopWidth,-(i.borderRightWidth+i.borderLeftWidth),-(i.borderTopWidth+i.borderBottomWidth))},XB=function(e){var t=e.styles,i=e.bounds,s=_g(t.paddingLeft,i.width),r=_g(t.paddingRight,i.width),n=_g(t.paddingTop,i.width),A=_g(t.paddingBottom,i.width);return i.add(s+t.borderLeftWidth,n+t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth+s+r),-(t.borderTopWidth+t.borderBottomWidth+n+A))},KB=function(e,t,i){var s=function(e,t){return 0===e?t.bounds:2===e?XB(t):zB(t)}($B(e.styles.backgroundOrigin,t),e),r=function(e,t){return 0===e?t.bounds:2===e?XB(t):zB(t)}($B(e.styles.backgroundClip,t),e),n=YB($B(e.styles.backgroundSize,t),i,s),A=n[0],o=n[1],a=mg($B(e.styles.backgroundPosition,t),s.width-A,s.height-o);return[qB($B(e.styles.backgroundRepeat,t),a,n,s,r),Math.round(s.left+a[0]),Math.round(s.top+a[1]),A,o]},ZB=function(e){return rg(e)&&e.value===jg.AUTO},JB=function(e){return"number"==typeof e},YB=function(e,t,i){var s=t[0],r=t[1],n=t[2],A=e[0],o=e[1];if(!A)return[0,0];if(ug(A)&&o&&ug(o))return[_g(A,i.width),_g(o,i.height)];var a=JB(n);if(rg(A)&&(A.value===jg.CONTAIN||A.value===jg.COVER))return JB(n)?i.width/i.height<n!=(A.value===jg.COVER)?[i.width,i.width/n]:[i.height*n,i.height]:[i.width,i.height];var l=JB(s),c=JB(r),h=l||c;if(ZB(A)&&(!o||ZB(o)))return l&&c?[s,r]:a||h?h&&a?[l?s:r*n,c?r:s/n]:[l?s:i.width,c?r:i.height]:[i.width,i.height];if(a){var u=0,d=0;return ug(A)?u=_g(A,i.width):ug(o)&&(d=_g(o,i.height)),ZB(A)?u=d*n:o&&!ZB(o)||(d=u/n),[u,d]}var f=null,p=null;if(ug(A)?f=_g(A,i.width):o&&ug(o)&&(p=_g(o,i.height)),null===f||o&&!ZB(o)||(p=l&&c?f/s*r:i.height),null!==p&&ZB(A)&&(f=l&&c?p/r*s:i.width),null!==f&&null!==p)return[f,p];throw new Error("Unable to calculate background-size for element")},$B=function(e,t){var i=e[t];return void 0===i?e[0]:i},qB=function(e,t,i,s,r){var n=t[0],A=t[1],o=i[0],a=i[1];switch(e){case 2:return[new EB(Math.round(s.left),Math.round(s.top+A)),new EB(Math.round(s.left+s.width),Math.round(s.top+A)),new EB(Math.round(s.left+s.width),Math.round(a+s.top+A)),new EB(Math.round(s.left),Math.round(a+s.top+A))];case 3:return[new EB(Math.round(s.left+n),Math.round(s.top)),new EB(Math.round(s.left+n+o),Math.round(s.top)),new EB(Math.round(s.left+n+o),Math.round(s.height+s.top)),new EB(Math.round(s.left+n),Math.round(s.height+s.top))];case 1:return[new EB(Math.round(s.left+n),Math.round(s.top+A)),new EB(Math.round(s.left+n+o),Math.round(s.top+A)),new EB(Math.round(s.left+n+o),Math.round(s.top+A+a)),new EB(Math.round(s.left+n),Math.round(s.top+A+a))];default:return[new EB(Math.round(r.left),Math.round(r.top)),new EB(Math.round(r.left+r.width),Math.round(r.top)),new EB(Math.round(r.left+r.width),Math.round(r.height+r.top)),new EB(Math.round(r.left),Math.round(r.height+r.top))]}},ey=function(){function e(e){this._data={},this._document=e}return e.prototype.parseMetrics=function(e,t){var i=this._document.createElement("div"),s=this._document.createElement("img"),r=this._document.createElement("span"),n=this._document.body;i.style.visibility="hidden",i.style.fontFamily=e,i.style.fontSize=t,i.style.margin="0",i.style.padding="0",i.style.whiteSpace="nowrap",n.appendChild(i),s.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",s.width=1,s.height=1,s.style.margin="0",s.style.padding="0",s.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")),i.appendChild(r),i.appendChild(s);var A=s.offsetTop-r.offsetTop+2;i.removeChild(r),i.appendChild(this._document.createTextNode("Hidden Text")),i.style.lineHeight="normal",s.style.verticalAlign="super";var o=s.offsetTop-i.offsetTop+2;return n.removeChild(i),{baseline:A,middle:o}},e.prototype.getMetrics=function(e,t){var i=e+" "+t;return void 0===this._data[i]&&(this._data[i]=this.parseMetrics(e,t)),this._data[i]},e}(),ty=function(e,t){this.context=e,this.options=t},iy=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s._activeEffects=[],s.canvas=i.canvas?i.canvas:document.createElement("canvas"),s.ctx=s.canvas.getContext("2d"),i.canvas||(s.canvas.width=Math.floor(i.width*i.scale),s.canvas.height=Math.floor(i.height*i.scale),s.canvas.style.width=i.width+"px",s.canvas.style.height=i.height+"px"),s.fontMetrics=new ey(document),s.ctx.scale(s.options.scale,s.options.scale),s.ctx.translate(-i.x,-i.y),s.ctx.textBaseline="bottom",s._activeEffects=[],s.context.logger.debug("Canvas renderer initialized ("+i.width+"x"+i.height+") with scale "+i.scale),s}return bf(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)),RB(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 yf(this,void 0,void 0,(function(){return wf(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 yf(this,void 0,void 0,(function(){return wf(this,(function(t){switch(t.label){case 0:return u_(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,i){var s=this;0===t?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+i):eb(e.text).reduce((function(t,r){return s.ctx.fillText(r,t,e.bounds.top+i),t+s.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(""),i=oy(e.fontFamily).join(", "),s=ig(e.fontSize)?""+e.fontSize.number+e.fontSize.unit:e.fontSize.number+"px";return[[e.fontStyle,t,e.fontWeight,s,i].join(" "),i,s]},t.prototype.renderTextNode=function(e,t){return yf(this,void 0,void 0,(function(){var i,s,r,n,A,o,a,l,c=this;return wf(this,(function(h){return i=this.createFontStyle(t),s=i[0],r=i[1],n=i[2],this.ctx.font=s,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(i){switch(i){case 0:c.ctx.fillStyle=Mg(t.color),c.renderTextWithLetterSpacing(e,t.letterSpacing,o);var s=t.textShadow;s.length&&e.text.trim().length&&(s.slice(0).reverse().forEach((function(i){c.ctx.shadowColor=Mg(i.color),c.ctx.shadowOffsetX=i.offsetX.number*c.options.scale,c.ctx.shadowOffsetY=i.offsetY.number*c.options.scale,c.ctx.shadowBlur=i.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=Mg(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=Mg(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,i){if(i&&e.intrinsicWidth>0&&e.intrinsicHeight>0){var s=XB(e),r=SB(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return yf(this,void 0,void 0,(function(){var i,s,r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b;return wf(this,(function(B){switch(B.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,n=0,A=i.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(!(i instanceof ab))return[3,8];B.label=5;case 5:return B.trys.push([5,7,,8]),[4,this.context.cache.match(i.src)];case 6:return g=B.sent(),this.renderReplacedElement(i,s,g),[3,8];case 7:return B.sent(),this.context.logger.error("Error loading image "+i.src),[3,8];case 8:if(i instanceof lb&&this.renderReplacedElement(i,s,i.canvas),!(i instanceof cb))return[3,12];B.label=9;case 9:return B.trys.push([9,11,,12]),[4,this.context.cache.match(i.svg)];case 10:return g=B.sent(),this.renderReplacedElement(i,s,g),[3,12];case 11:return B.sent(),this.context.logger.error("Error loading svg "+i.svg.substring(0,255)),[3,12];case 12:return i instanceof bb&&i.tree?[4,new t(this.context,{scale:this.options.scale,backgroundColor:i.backgroundColor,x:0,y:0,width:i.width,height:i.height}).render(i.tree)]:[3,14];case 13:a=B.sent(),i.width&&i.height&&this.ctx.drawImage(a,0,0,i.width,i.height,i.bounds.left,i.bounds.top,i.bounds.width,i.bounds.height),B.label=14;case 14:if(i instanceof gb&&(l=Math.min(i.bounds.width,i.bounds.height),"checkbox"===i.type?i.checked&&(this.ctx.save(),this.path([new EB(i.bounds.left+.39363*l,i.bounds.top+.79*l),new EB(i.bounds.left+.16*l,i.bounds.top+.5549*l),new EB(i.bounds.left+.27347*l,i.bounds.top+.44071*l),new EB(i.bounds.left+.39694*l,i.bounds.top+.5649*l),new EB(i.bounds.left+.72983*l,i.bounds.top+.23*l),new EB(i.bounds.left+.84*l,i.bounds.top+.34085*l),new EB(i.bounds.left+.39363*l,i.bounds.top+.79*l)]),this.ctx.fillStyle=Mg(707406591),this.ctx.fill(),this.ctx.restore()):"radio"===i.type&&i.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(i.bounds.left+l/2,i.bounds.top+l/2,l/4,0,2*Math.PI,!0),this.ctx.fillStyle=Mg(707406591),this.ctx.fill(),this.ctx.restore())),sy(i)&&i.value.length){switch(c=this.createFontStyle(r),_=c[0],h=c[1],u=this.fontMetrics.getMetrics(_,h).baseline,this.ctx.font=_,this.ctx.fillStyle=Mg(r.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=ny(i.styles.textAlign),b=XB(i),d=0,i.styles.textAlign){case 1:d+=b.width/2;break;case 2:d+=b.width}f=b.add(d,0,0,-b.height/2+1),this.ctx.save(),this.path([new EB(b.left,b.top),new EB(b.left+b.width,b.top),new EB(b.left+b.width,b.top+b.height),new EB(b.left,b.top+b.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new Y_(i.value,f),r.letterSpacing,u),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!u_(i.styles.display,2048))return[3,20];if(null===i.styles.listStyleImage)return[3,19];if(0!==(p=i.styles.listStyleImage).type)return[3,18];g=void 0,m=p.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,i.bounds.left-(g.width+10),i.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!==i.styles.listStyleType&&(_=this.createFontStyle(r)[0],this.ctx.font=_,this.ctx.fillStyle=Mg(r.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",b=new Cf(i.bounds.left,i.bounds.top+_g(i.styles.paddingTop,i.bounds.width),i.bounds.width,xm(r.lineHeight,r.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new Y_(e.listValue,b),r.letterSpacing,xm(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 yf(this,void 0,void 0,(function(){var t,i,s,r,n,A,o,a,l,c,h,u,d,f,p;return wf(this,(function(g){switch(g.label){case 0:return u_(e.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(e.element)];case 1:g.sent(),t=0,i=e.negativeZIndex,g.label=2;case 2:return t<i.length?(p=i[t],[4,this.renderStack(p)]):[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(),s=0,r=e.nonInlineLevel,g.label=7;case 7:return s<r.length?(p=r[s],[4,this.renderNode(p)]):[3,10];case 8:g.sent(),g.label=9;case 9:return s++,[3,7];case 10:n=0,A=e.nonPositionedFloats,g.label=11;case 11:return n<A.length?(p=A[n],[4,this.renderStack(p)]):[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?(p=a[o],[4,this.renderStack(p)]):[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?(p=c[l],[4,this.renderNode(p)]):[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?(p=u[h],[4,this.renderStack(p)]):[3,26];case 24:g.sent(),g.label=25;case 25:return h++,[3,23];case 26:d=0,f=e.positiveZIndex,g.label=27;case 27:return d<f.length?(p=f[d],[4,this.renderStack(p)]):[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,i){var s=xB(e)?e.start:e;0===i?t.ctx.moveTo(s.x,s.y):t.ctx.lineTo(s.x,s.y),xB(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,i,s){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(i,s),this.ctx.fill(),this.ctx.translate(-i,-s)},t.prototype.resizeImage=function(e,t,i){var s;if(e.width===t&&e.height===i)return e;var r=(null!==(s=this.canvas.ownerDocument)&&void 0!==s?s:document).createElement("canvas");return r.width=Math.max(1,t),r.height=Math.max(1,i),r.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t,i),r},t.prototype.renderBackgroundImage=function(e){return yf(this,void 0,void 0,(function(){var t,i,s,r,n,A;return wf(this,(function(o){switch(o.label){case 0:t=e.styles.backgroundImage.length-1,i=function(i){var r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B,y,w,v,C,M,E,F,U,x,I,T,P,S,D;return wf(this,(function(k){switch(k.label){case 0:if(0!==i.type)return[3,5];r=void 0,n=i.url,k.label=1;case 1:return k.trys.push([1,3,,4]),[4,s.context.cache.match(n)];case 2:return r=k.sent(),[3,4];case 3:return k.sent(),s.context.logger.error("Error loading background-image "+n),[3,4];case 4:return r&&(A=KB(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=s.ctx.createPattern(s.resizeImage(r,w,v),"repeat"),s.renderRepeat(b,m,M,E)),[3,6];case 5:1===i.type?(o=KB(e,t,[null,null,null]),b=o[0],M=o[1],E=o[2],w=o[3],v=o[4],a=Og(i.angle,w,v),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],(f=document.createElement("canvas")).width=w,f.height=v,p=f.getContext("2d"),g=p.createLinearGradient(c,u,h,d),Rg(i.stops,l).forEach((function(e){return g.addColorStop(e.stop,Mg(e.color))})),p.fillStyle=g,p.fillRect(0,0,w,v),w>0&&v>0&&(m=s.ctx.createPattern(f,"repeat"),s.renderRepeat(b,m,M,E))):function(e){return 2===e.type}(i)&&(_=KB(e,t,[null,null,null]),b=_[0],B=_[1],y=_[2],w=_[3],v=_[4],C=0===i.position.length?[pg]:i.position,M=_g(C[0],w),E=_g(C[C.length-1],v),F=function(e,t,i,s,r){var n=0,A=0;switch(e.size){case 0:0===e.shape?n=A=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.min(Math.abs(t),Math.abs(t-s)),A=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)n=A=Math.min(Vg(t,i),Vg(t,i-r),Vg(t-s,i),Vg(t-s,i-r));else if(1===e.shape){var o=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),a=Lg(s,r,t,i,!0),l=a[0],c=a[1];A=o*(n=Vg(l-t,(c-i)/o))}break;case 1:0===e.shape?n=A=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.max(Math.abs(t),Math.abs(t-s)),A=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)n=A=Math.max(Vg(t,i),Vg(t,i-r),Vg(t-s,i),Vg(t-s,i-r));else if(1===e.shape){o=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var h=Lg(s,r,t,i,!1);l=h[0],c=h[1],A=o*(n=Vg(l-t,(c-i)/o))}}return Array.isArray(e.size)&&(n=_g(e.size[0],s),A=2===e.size.length?_g(e.size[1],r):n),[n,A]}(i,M,E,w,v),U=F[0],x=F[1],U>0&&x>0&&(I=s.ctx.createRadialGradient(B+M,y+E,0,B+M,y+E,U),Rg(i.stops,2*U).forEach((function(e){return I.addColorStop(e.stop,Mg(e.color))})),s.path(b),s.ctx.fillStyle=I,U!==x?(T=e.bounds.left+.5*e.bounds.width,P=e.bounds.top+.5*e.bounds.height,D=1/(S=x/U),s.ctx.save(),s.ctx.translate(T,P),s.ctx.transform(1,0,0,S,0,0),s.ctx.translate(-T,-P),s.ctx.fillRect(B,D*(y-P)+P,w,v*D),s.ctx.restore()):s.ctx.fill())),k.label=6;case 6:return t--,[2]}}))},s=this,r=0,n=e.styles.backgroundImage.slice(0).reverse(),o.label=1;case 1:return r<n.length?(A=n[r],[5,i(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,i){return yf(this,void 0,void 0,(function(){return wf(this,(function(s){return this.path(GB(i,t)),this.ctx.fillStyle=Mg(e),this.ctx.fill(),[2]}))}))},t.prototype.renderDoubleBorder=function(e,t,i,s){return yf(this,void 0,void 0,(function(){var r,n;return wf(this,(function(A){switch(A.label){case 0:return t<3?[4,this.renderSolidBorder(e,i,s)]:[3,2];case 1:return A.sent(),[2];case 2:return r=function(e,t){switch(t){case 0:return WB(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return WB(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return WB(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return WB(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}}(s,i),this.path(r),this.ctx.fillStyle=Mg(e),this.ctx.fill(),n=function(e,t){switch(t){case 0:return WB(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return WB(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return WB(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return WB(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}}(s,i),this.path(n),this.ctx.fill(),[2]}}))}))},t.prototype.renderNodeBackgroundAndBorders=function(e){return yf(this,void 0,void 0,(function(){var t,i,s,r,n,A,o,a,l=this;return wf(this,(function(c){switch(c.label){case 0:return this.applyEffects(e.getEffects(2)),t=e.container.styles,i=!Cg(t.backgroundColor)||t.backgroundImage.length,s=[{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=ry($B(t.backgroundClip,0),e.curves),i||t.boxShadow.length?(this.ctx.save(),this.path(r),this.ctx.clip(),Cg(t.backgroundColor)||(this.ctx.fillStyle=Mg(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 i,s,r,n,A,o=PB(e.curves),a=t.inset?0:1e4,c=(i=o,s=-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),i.map((function(e,t){switch(t){case 0:return e.add(s,r);case 1:return e.add(s+n,r);case 2:return e.add(s+n,r+A);case 3:return e.add(s,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=Mg(t.color),l.ctx.shadowBlur=t.blur.number,l.ctx.fillStyle=t.inset?Mg(t.color):"rgba(0,0,0,1)",l.ctx.fill(),l.ctx.restore()})),c.label=2;case 2:n=0,A=0,o=s,c.label=3;case 3:return A<o.length?0!==(a=o[A]).style&&!Cg(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,i,s,r){return yf(this,void 0,void 0,(function(){var n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B;return wf(this,(function(y){return this.ctx.save(),n=function(e,t){switch(t){case 0:return jB(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return jB(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return jB(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return jB(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),A=GB(s,i),2===r&&(this.path(A),this.ctx.clip()),xB(A[0])?(o=A[0].start.x,a=A[0].start.y):(o=A[0].x,a=A[0].y),xB(A[1])?(l=A[1].end.x,c=A[1].end.y):(l=A[1].x,c=A[1].y),h=0===i||2===i?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),f=!0,h<=2*u?f=!1:h<=2*u+d?(u*=p=h/(2*u+d),d*=p):(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:_),f&&(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=Mg(e),this.ctx.stroke(),this.ctx.setLineDash([]),2===r&&(xB(A[0])&&(b=A[3],B=A[0],this.ctx.beginPath(),this.formatPath([new EB(b.end.x,b.end.y),new EB(B.start.x,B.start.y)]),this.ctx.stroke()),xB(A[1])&&(b=A[1],B=A[2],this.ctx.beginPath(),this.formatPath([new EB(b.end.x,b.end.y),new EB(B.start.x,B.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]}))}))},t.prototype.render=function(e){return yf(this,void 0,void 0,(function(){var t;return wf(this,(function(i){switch(i.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=Mg(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),s=new LB(e,null),r=new VB(s),HB(s,r,r,n=[]),NB(s.container,n),t=r,[4,this.renderStack(t)];case 1:return i.sent(),this.applyEffects([]),[2,this.canvas]}var s,r,n}))}))},t}(ty),sy=function(e){return e instanceof _b||(e instanceof mb||e instanceof gb&&"radio"!==e.type&&"checkbox"!==e.type)},ry=function(e,t){switch(e){case 0:return PB(t);case 2:return function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]}(t);default:return SB(t)}},ny=function(e){switch(e){case 1:return"center";case 2:return"right";default:return"left"}},Ay=["-apple-system","system-ui"],oy=function(e){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?e.filter((function(e){return-1===Ay.indexOf(e)})):e},ay=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i.canvas?i.canvas:document.createElement("canvas"),s.ctx=s.canvas.getContext("2d"),s.options=i,s.canvas.width=Math.floor(i.width*i.scale),s.canvas.height=Math.floor(i.height*i.scale),s.canvas.style.width=i.width+"px",s.canvas.style.height=i.height+"px",s.ctx.scale(s.options.scale,s.options.scale),s.ctx.translate(-i.x,-i.y),s.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+i.width+"x"+i.height+" at "+i.x+","+i.y+") with scale "+i.scale),s}return bf(t,e),t.prototype.render=function(e){return yf(this,void 0,void 0,(function(){var t,i;return wf(this,(function(s){switch(s.label){case 0:return t=K_(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),[4,ly(t)];case 1:return i=s.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=Mg(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(i,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}}))}))},t}(ty),ly=function(e){return new Promise((function(t,i){var s=new Image;s.onload=function(){t(s)},s.onerror=i,s.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},cy=function(){function e(e){var t=e.id,i=e.enabled;this.id=t,this.enabled=i,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,vf([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,vf([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,vf([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,vf([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.instances={},e}(),hy=function(){function e(t,i){var s;this.windowBounds=i,this.instanceName="#"+e.instanceCount++,this.logger=new cy({id:this.instanceName,enabled:t.logging}),this.cache=null!==(s=t.cache)&&void 0!==s?s:new mB(this,t)}return e.instanceCount=1,e}();"undefined"!=typeof window&&gB.setContext(window);var uy=function(e,t){return yf(void 0,void 0,void 0,(function(){var i,s,r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B,y,w,v,C,M,E,F,U,x,I,T,P,S,D,k,Q,R,O,V;return wf(this,(function(L){switch(L.label){case 0:if(!e||"object"!=typeof e)return[2,Promise.reject("Invalid element provided as first argument")];if(!(i=e.ownerDocument))throw new Error("Element is not attached to a Document");if(!(s=i.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=Bf({logging:null===(E=t.logging)||void 0===E||E,cache:t.cache},r),A={windowWidth:null!==(F=t.windowWidth)&&void 0!==F?F:s.innerWidth,windowHeight:null!==(U=t.windowHeight)&&void 0!==U?U:s.innerHeight,scrollX:null!==(x=t.scrollX)&&void 0!==x?x:s.pageXOffset,scrollY:null!==(I=t.scrollY)&&void 0!==I?I:s.pageYOffset},o=new Cf(A.scrollX,A.scrollY,A.windowWidth,A.windowHeight),a=new hy(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 tB(a,e,c),(u=h.clonedReferenceElement)?[4,h.toIFrame(i,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=L.sent(),f=Db(u)||"HTML"===u.tagName?function(e){var t=e.body,i=e.documentElement;if(!t||!i)throw new Error("Unable to get document size");var s=Math.max(Math.max(t.scrollWidth,i.scrollWidth),Math.max(t.offsetWidth,i.offsetWidth),Math.max(t.clientWidth,i.clientWidth)),r=Math.max(Math.max(t.scrollHeight,i.scrollHeight),Math.max(t.offsetHeight,i.offsetHeight),Math.max(t.clientHeight,i.clientHeight));return new Cf(0,0,s,r)}(u.ownerDocument):Mf(a,u),p=f.width,g=f.height,m=f.left,_=f.top,b=dy(a,u,t.backgroundColor),B={canvas:t.canvas,backgroundColor:b,scale:null!==(D=null!==(S=t.scale)&&void 0!==S?S:s.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(p),height:null!==(O=t.height)&&void 0!==O?O:Math.ceil(g)},l?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new ay(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 "+p+"x"+g+" using computed rendering"),a.logger.debug("Starting DOM parsing"),w=vb(a,u),b===w.styles.backgroundColor&&(w.styles.backgroundColor=Sg.TRANSPARENT),a.logger.debug("Starting renderer for element at "+B.x+","+B.y+" with size "+B.width+"x"+B.height),[4,new iy(a,B).render(w)];case 4:y=L.sent(),L.label=5;case 5:return(null===(V=t.removeContainer)||void 0===V||V)&&(tB.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,y]}}))}))},dy=function(e,t,i){var s=t.ownerDocument,r=s.documentElement?Pg(e,getComputedStyle(s.documentElement).backgroundColor):Sg.TRANSPARENT,n=s.body?Pg(e,getComputedStyle(s.body).backgroundColor):Sg.TRANSPARENT,A="string"==typeof i?Pg(e,i):null===i?Sg.TRANSPARENT:4294967295;return t===s.documentElement?Cg(r)?Cg(n)?A:n:r:A};function fy(e,t,i=(()=>{})){if(!e||!t)return;let s=null;let r,n;const A=e=>{if(e.preventDefault(),s&&(clearTimeout(s),s=null),e.touches.length>1)return;const i=e.touches[0];r=i.clientX,n=i.clientY,s=setTimeout((()=>{e.clientX=i.clientX,e.clientY=i.clientY,t(e),clearTimeout(s),s=null}),500)},o=e=>{e.touches.length>1&&s&&(clearTimeout(s),s=null)},a=e=>{if(!s)return;const t=e.touches[0],i=Math.abs(t.clientX-r),A=Math.abs(t.clientY-n);(i>3||A>3)&&(clearTimeout(s),s=null)},l=e=>{e.preventDefault(),s&&(i(e),clearTimeout(s),s=null)},c=e=>{t(e),e.preventDefault(),e.stopPropagation()};return $A.isIphoneOrIpadSafari()?(e.addEventListener("touchstart",A),e.addEventListener("touchmove",a),e.addEventListener("touchend",l),window.addEventListener("touchstart",o)):e.addEventListener("contextmenu",c),function(){$A.isIphoneOrIpadSafari()?(e.removeEventListener("touchstart",A),e.removeEventListener("touchmove",a),e.removeEventListener("touchend",l),window.removeEventListener("touchstart",o)):e.removeEventListener("contextmenu",c)}}class py{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 i=this._dot,s=i.style;s["border-radius"]="25px",s.border="solid 2px white",s.background="lightgreen",s.position="absolute",s["z-index"]=void 0===t.zIndex?"40000005":t.zIndex,s.width="8px",s.height="8px",s.visibility=this._visible?"visible":"hidden",s.top="0px",s.left="0px",s["box-shadow"]="0 2px 5px 0 #182A3D;",s.opacity=1,s["pointer-events"]="none",t.onContextMenu,e.appendChild(i);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",(i=>{t.onMouseOver(i,this),e.dispatchEvent(new MouseEvent("mouseover",i))})),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){fy(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 i=this._dot.style;i.left=Math.round(e)-6+"px",i.top=Math.round(t)-6+"px";var s=this._dotClickable.style;s.left=Math.round(e)-14+"px",s.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 gy{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 i=this._label,s=i.style;if(s["border-radius"]="5px",s.color="white",s.padding="4px",s.border="solid 1px",s.background="lightgreen",s.position="absolute",s["z-index"]=void 0===t.zIndex?"5000005":t.zIndex,s.width="auto",s.height="auto",s.visibility="visible",s.top="0px",s.left="0px",s["pointer-events"]="all",s.opacity=1,t.onContextMenu,i.innerText="",e.appendChild(i),this.setPos(t.x||0,t.y||0),this.setFillColor(t.fillColor),this.setBorderColor(t.fillColor),this.setText(t.text),t.onMouseOver&&i.addEventListener("mouseover",(e=>{t.onMouseOver(e,this),e.preventDefault()})),t.onMouseLeave&&i.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this),e.preventDefault()})),t.onMouseWheel&&i.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&i.addEventListener("mousedown",(e=>{t.onMouseDown(e,this),e.stopPropagation()})),t.onMouseUp&&i.addEventListener("mouseup",(e=>{t.onMouseUp(e,this),e.stopPropagation()})),t.onMouseMove&&i.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onContextMenu){fy(i,(e=>{t.onContextMenu(e,this)}))}}setPos(e,t){this._x=e,this._y=t;var i=this._label.style;i.left=Math.round(e)-20+"px",i.top=Math.round(t)-12+"px"}setPosOnWire(e,t,i,s){var r=e+.5*(i-e),n=t+.5*(s-t),A=this._label.style;A.left=Math.round(r)-20+"px",A.top=Math.round(n)-12+"px"}setPosBetweenWires(e,t,i,s,r,n){var A=(e+i+r)/3,o=(t+s+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 my{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 i=this._wire,s=i.style;s.border="solid "+this._thickness+"px "+this._color,s.position="absolute",s["z-index"]=void 0===t.zIndex?"2000001":t.zIndex,s.width="0px",s.height="0px",s.visibility="visible",s.top="0px",s.left="0px",s["-webkit-transform-origin"]="0 0",s["-moz-transform-origin"]="0 0",s["-ms-transform-origin"]="0 0",s["-o-transform-origin"]="0 0",s["transform-origin"]="0 0",s["-webkit-transform"]="rotate(0deg)",s["-moz-transform"]="rotate(0deg)",s["-ms-transform"]="rotate(0deg)",s["-o-transform"]="rotate(0deg)",s.transform="rotate(0deg)",s.opacity=1,s["pointer-events"]="none",t.onContextMenu,e.appendChild(i);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){fy(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,i=this._wire.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._thickness+"px, -"+this._thickness+"px)";var s=this._wireClickable.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._thicknessClickable+"px, -"+this._thicknessClickable+"px)"}setStartAndEnd(e,t,i,s){this._x1=e,this._y1=t,this._x2=i,this._y2=s,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 _y=V.vec2(),by=V.vec2(),By=V.vec2(),yy=V.vec2(),wy=V.vec3(),vy=V.vec3(),Cy=V.vec4(),My=V.vec4(),Ey=V.vec4(),Fy=V.vec4(),Uy=V.mat4(),xy={origin:V.vec3(),direction:V.vec3()},Iy=()=>{},Ty=function(e,t,i,s){const r=(e-V.dotVec3(i,t))/V.dotVec3(s,t);if(r<0)return null;{const e=V.vec3();return V.mulVec3Scalar(s,r,e),V.addVec3(i,e,e),e}};function Py(e,t,i){const s=e.getBoundingClientRect(),r=t.getBoundingClientRect();i[0]+=s.left-r.left,i[1]+=s.top-r.top}const Sy=(e,t,i)=>{Uy.set(e.viewMatrix),Uy.set(e.projMatrix),i.set(t),i[3]=1,V.mulMat4v4(e.viewMatrix,i,i),V.mulMat4v4(e.projMatrix,i,i)},Dy=(e,t,i,s)=>{s[0]=.5*(1+i[0])*e.offsetWidth,s[1]=.5*(1-i[1])*e.offsetHeight,Py(e,t,s)},ky=(e,t,i,s,r,n)=>{const A=e.camera,o=e.canvas.canvas;if(V.distVec3(i,s)<.001)return!1;const a=V.subVec3(s,i,wy);let l=0,c=1;for(let t of e._sectionPlanesState.sectionPlanes){const e=V.dotVec3(t.dir,V.subVec3(t.pos,s,vy)),r=V.dotVec3(t.dir,V.subVec3(t.pos,i,vy));if(r>0&&e>0)return!1;if(r>0||e>0){const e=V.dotVec3(t.dir,a);if(Math.abs(e)>=1e-6){const i=V.dotVec3(t.dir,vy)/e;r>0?l=Math.max(l,i):c=Math.min(c,i)}}}const h=Cy,u=My;Sy(A,l>0?V.addVec3(i,V.mulVec3Scalar(a,l,vy),vy):i,h),Sy(A,c<1?V.addVec3(i,V.mulVec3Scalar(a,c,vy),vy):s,u);const d=h[2]/h[3]<-1||h[3]<0,f=u[2]/u[3]<-1||u[3]<0;if(d&&f)return!1;const p=(h[3]+h[2])/(h[3]+h[2]-(u[3]+u[2]));if(p>0&&p<1){const e=V.subVec4(u,h,Ey);V.mulVec4Scalar(e,p,e),V.addVec4(h,e,d?h:u)}V.mulVec4Scalar(h,1/h[3]),V.mulVec4Scalar(u,1/u[3]);let g=0,m=1;for(let e=0;e<2;++e){const t=u[e]-h[e],i=(-1-h[e])/t,s=(1-h[e])/t;t>0?(g=Math.max(g,i),m=Math.min(m,s)):t<0?(g=Math.max(g,s),m=Math.min(m,i)):h[0]<-1?g=-window.Infinity:h[0]>1&&(m=window.Infinity)}if(g>=m)return!1;const _=V.subVec4(u,h,Ey);return V.addVec4(h,V.mulVec4Scalar(_,m,Fy),u),V.addVec4(h,V.mulVec4Scalar(_,g,Fy),h),V.mulVec4Scalar(h,1/h[3]),V.mulVec4Scalar(u,1/u[3]),Dy(o,t,h,r),Dy(o,t,u,n),!0};class Qy extends PA{constructor(e,t,i,s={}){const r=e.camera;super(e,t),this.__visible=!0;const n=(e,t)=>i=>{e&&e(i),this.fire(t,i,!0)};this._dot=new py(i,{borderColor:s.borderColor,fillColor:s.fillColor,zIndex:s.zIndex,onMouseOver:n(s.onMouseOver,"mouseover"),onMouseLeave:n(s.onMouseLeave,"mouseleave"),onMouseWheel:n(s.onMouseWheel,"wheel"),onMouseDown:n(s.onMouseDown,"mousedown"),onMouseUp:n(s.onMouseUp,"mouseup"),onMouseMove:n(s.onMouseMove,"mousemove"),onTouchstart:n(s.onTouchstart,"touchstart"),onTouchmove:n(s.onTouchmove,"touchmove"),onTouchend:n(s.onTouchend,"touchend"),onContextMenu:n(s.onContextMenu,"contextmenu")});const A=()=>{if(!this.__visible)return;const t=Ey;((e,t)=>{t.set(e),t[3]=1,V.mulMat4v4(r.viewMatrix,t,t),V.mulMat4v4(r.projMatrix,t,t)})(this.worldPos,t),V.mulVec3Scalar(t,1/t[3]);const s=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=>V.dotVec3(e.dir,V.subVec3(e.pos,this.worldPos,wy))>0));this._dot.setCulled(s),s||((t=>{const s=e.canvas.canvas;t[0]=.5*(1+t[0])*s.offsetWidth,t[1]=.5*(1-t[1])*s.offsetHeight,Py(s,i,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 Ry{constructor(e,t,i){const s=e.camera;this._label=new gy(t,i),this._start=V.vec3(),this._mid=V.vec3(),this._end=V.vec3(),this._yOff=0,this.__visible=!0,this._updatePos=()=>{Sy(s,this._start,Cy),V.mulVec4Scalar(Cy,1/Cy[3]),Dy(e.canvas.canvas,t,Cy,_y),this._label.setPos(_y[0],_y[1])};const r=(e,t,i)=>{e[0]+=t[0],e[1]+=t[1],V.mulVec2Scalar(e,.5),this._label.setPos(e[0],e[1]+i)};this._updatePosBetween=()=>{const i=ky(e,t,this._start,this._mid,_y,by),s=ky(e,t,this._end,this._mid,By,yy);this._label.setCulled(!(i||s)),i&&s?(by[0]+=yy[0],by[1]+=yy[1],V.mulVec2Scalar(by,.5),by[0]+=_y[0]+By[0],by[1]+=_y[1]+By[1],V.mulVec2Scalar(by,1/3),this._label.setPos(by[0],by[1])):i?r(_y,by,0):s&&r(By,yy,0)},this._updatePosOnWire=()=>{const i=ky(e,t,this._start,this._end,_y,by)&&V.distVec2(_y,by)>=this._labelMinAxisLength;this._label.setCulled(!i),i&&r(_y,by,this._yOff)};let n=()=>{};this._setUpdatePositions=e=>{n=e,this._updatePositions()},this._updatePositions=()=>{this.__visible&&n()};const A=s.on("viewMatrix",this._updatePositions),o=s.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=()=>{s.off(A),s.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,i,s){this._start.set(e),this._end.set(t),this._yOff=i,this._labelMinAxisLength=s,this._setUpdatePositions(this._updatePosOnWire)}setPosBetween(e,t,i){this._start.set(e),this._mid.set(t),this._end.set(i),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 Oy{constructor(e,t,i){const s=e.camera;this._wire=new my(t,i),this._start=V.vec3(),this._end=V.vec3(),this.__visible=!0,this._updatePositions=()=>{if(!this.__visible)return;const i=ky(e,t,this._start,this._end,_y,by);this._wire.setCulled(!i),i&&this._wire.setStartAndEnd(_y[0],_y[1],by[0],by[1])};const r=s.on("viewMatrix",this._updatePositions),n=s.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=()=>{s.off(r),s.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 Vy=function(e,t){const i=new Qy(e,{},e.canvas.canvas.parentNode,{borderColor:"white",fillColor:t,zIndex:100});return{update:function(e){e&&(i.worldPos=e),i.setVisible(!!e)},setFillColor:e=>i.setFillColor(e),setHighlighted:e=>i.setHighlighted(e),getCanvasPos:()=>i.canvasPos,getWorldPos:()=>i.worldPos,destroy:()=>i.destroy()}},Ly=function(e,t){const i=new Oy(e,e.canvas.canvas.ownerDocument.body,{color:t,thickness:1,thicknessClickable:6});return i.setVisible(!1),{update:(e,t)=>{t&&i.setEnds(e,t),i.setVisible(!!t)},setColor:e=>i.setColor(e),destroy:()=>i.destroy()}};function Hy(e,t){const i=function(e,i){if(e in t)return t[e];if(void 0!==i)return i;throw"config missing: "+e},s=i("viewer"),r=i("ray2WorldPos"),n=i("handleMouseEvents",!1),A=i("handleTouchEvents",!1),o=i("onStart",Iy),a=i("onMove",Iy),l=i("onEnd",Iy),c=s.scene,h=c.canvas.canvas,u=e=>{const t=V.vec2([e.clientX,e.clientY]);Py(h.ownerDocument.documentElement,h,t),a(t,(e=>{const t=V.vec3(),i=V.vec3();return V.canvasPosToWorldRay(h,c.camera.viewMatrix,c.camera.projMatrix,c.camera.projection,e,t,i),r(t,i,e)})(t))};let d=null;const f=function(e){const t=d.matchesEvent(e);t&&u(t)},p=function(t){const i=d.matchesEvent(t);i&&(e.setOpacity(b),d.cleanup(),u(i),l())},g=function(t,i){d&&d.cleanup(),e.setOpacity(1),e.setClickable(!1),s.cameraControl.active=!1,d={matchesEvent:t,cleanup:function(){d=null,e.setClickable(!0),s.cameraControl.active=!0,i()}},o()},m=[],_=function(t,i){const s=e.on(t,i);m.push((()=>e.off(s)))};if(n&&(_("mouseover",(()=>!d&&e.setOpacity(1))),_("mouseleave",(()=>!d&&e.setOpacity(b))),_("mousedown",(e=>{1===e.which&&(h.addEventListener("mousemove",f),h.addEventListener("mouseup",p),g((e=>1===e.which&&e),(()=>{h.removeEventListener("mousemove",f),h.removeEventListener("mouseup",p)})))}))),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(),f(e)})),_("touchend",(e=>{e.preventDefault(),p(e)}))}const b=.8;return e.setOpacity(b),function(){d&&d.cleanup(),m.forEach((e=>e())),e.setOpacity(1)}}function Ny(e){const t=function(t,i){if(t in e)return e[t];if(void 0!==i)return i;throw"config missing: "+t},i=t("viewer"),s=t("handleMouseEvents",!1),r=t("handleTouchEvents",!1),n=t("pointerLens",null),A=t("dots"),o=t("ray2WorldPos"),a=t("onEnd",Iy),l=n?function(e){n.visible=!!e,e&&(n.canvasPos=e)}:()=>{},c=A.map((e=>{let t;return Hy(e,{handleMouseEvents:s,handleTouchEvents:r,viewer:i,ray2WorldPos:(e,i,s)=>o(e,i,s)||t,onStart:()=>{t=e.worldPos.slice(),h(!1,e)},onMove:(t,i)=>{l(t),e.worldPos=i},onEnd:()=>{a(t,e)||(e.worldPos=t),l(null),h(!0,e)}})})),h=(e,t)=>A.forEach((i=>i!==t&&i.setClickable(e)));return h(!0),function(){c.forEach((e=>e())),l(null)}}const Gy=function(e,t,i){return function(s,r,n){const A=e.scene,o=A.canvas.canvas,a=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Py(o.ownerDocument.documentElement,o,t),t),l=e=>{const t=V.vec3(),s=V.vec3();return V.canvasPosToWorldRay(o,A.camera.viewMatrix,A.camera.projMatrix,A.camera.projection,e,t,s),i(t,s)};let c=null;const h=()=>{};let u,d=h;const f=function(){t.stop(),clearTimeout(c),e.cameraControl.active=!0,d=h,u=null},p=function(){f(),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",m),o.removeEventListener("touchend",_)},g=function(i){const n=i.touches;if(1!==n.length)f(),s();else{const i=n[0],s=a(i,V.vec2());l(s)&&(u=i.identifier,d=e=>{V.distVec2(s,e)>20&&f()},c=setTimeout((function(){t.start(s),c=setTimeout((function(){t.stop(),e.cameraControl.active=!1,d=e=>{r(e,l(e))},d(s)}),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,V.vec2()))};o.addEventListener("touchmove",m,{passive:!0});const _=function(e){const t=[...e.changedTouches].find((e=>e.identifier===u));if(t){p();const e=a(t,V.vec2());n(e,l(e))}};return o.addEventListener("touchend",_,{passive:!0}),p}},jy=function(e){const t=[];for(let i=0;i<e.length;++i)t.push(i);const i=function(){const i=V.vec2(),s=V.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]];V.subVec2(A,o,i),V.subVec2(a,o,s);const l=V.dotVec2(i,s)/Math.sqrt(V.sqLenVec2(i)*V.sqLenVec2(s)),c=Math.acos(Math.max(-1,Math.min(l,1)));r+=i[0]*s[1]-i[1]*s[0]>=0?c:2*Math.PI-c}return r<t.length*Math.PI}(),s=function(){const e=(e,t,i)=>(e[0]-i[0])*(t[1]-i[1])-(t[0]-i[0])*(e[1]-i[1]);return(t,i,s,r)=>{const n=e(t,i,s),A=e(t,s,r),o=e(t,r,i);return!((n<0||A<0||o<0)&&(n>0||A>0||o>0))}}(),r=[],n=(i?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=V.vec2(),o=V.vec2();for(;n.length>2;){let t=0;for(;;){if(t>=n.length)throw`isCCW = ${i}; earIdx = ${t}; len = ${n.length}`;const r=n[t],a=e[r.prev.idx],l=e[r.idx],c=e[r.next.idx];if(V.subVec2(a,l,A),V.subVec2(c,l,o),A[0]*o[1]-A[1]*o[0]>=0&&n.every((t=>t===r||t===r.prev||t===r.next||!s(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,i]},Wy=function(e,t){const i=(t,i)=>(i[0]=t.clientX,i[1]=t.clientY,Py(e.ownerDocument.documentElement,e,i),i);let s=!1;const r=[],n=()=>r.forEach((e=>e())),A=(t,i)=>{e.addEventListener(t,i),r.push((()=>e.removeEventListener(t,i)))},o=V.vec2();return A("mousedown",(function(e){1===e.which&&(s=!0,t(i(e,o)))})),A("mousemove",(function(e){i(e,_y),s&&V.distVec2(o,_y)>4&&(s=!1),(s||1&!e.buttons)&&t(_y)})),A("mouseup",(function(e){if(1===e.which&&s){const s=t(i(e,_y));s&&(n(),s())}})),n},zy=function(e,t,i,s){const r=V.vec2(),n=(t,i)=>(i[0]=t.clientX,i[1]=t.clientY,Py(e.ownerDocument.documentElement,e,i),i);let A,o=null,a=Iy;const l=function(){clearTimeout(o),i.stop(),t.active=!0,a=Iy,A=null},c=[],h=()=>c.forEach((e=>e())),u=(t,i)=>{e.addEventListener(t,i,{passive:!0}),c.push((()=>e.removeEventListener(t,i)))};return u("touchstart",(function(e){const c=e.touches;if(1!==c.length)l(),s(null);else{const e=c[0];n(e,r),A=e.identifier,a=e=>{V.distVec2(r,e)>20&&l()},o=setTimeout((function(){i.start(r),o=setTimeout((function(){i.stop(),t.active=!1,a=s,a(r)}),300)}),250)}})),u("touchmove",(function(e){const t=[...e.changedTouches].find((e=>e.identifier===A));t&&a(n(t,_y))})),u("touchend",(function(e){const t=[...e.changedTouches].find((e=>e.identifier===A));if(t){const e=s(n(t,_y));l(),e?(h(),e()):s(null)}})),()=>{l(),h()}},Xy=function(e,t,i,s,r,n){const A=e.canvas.canvas,o=t?function(e,i){t.visible=!!e,e&&(t.canvasPos=e,t.snapped=!!i)}:()=>{},a=function(){const e=(e,t,i)=>t[0]<=Math.max(e[0],i[0])&&t[0]>=Math.min(e[0],i[0])&&t[1]<=Math.max(e[1],i[1])&&t[1]>=Math.min(e[1],i[1]),t=(e,t,i)=>{const s=(t[1]-e[1])*(i[0]-t[0])-(t[0]-e[0])*(i[1]-t[1]);return 0===s?0:s>0?1:2};return function(i,s){const r=s?1:0,n=i[(i.length-2+r)%i.length],A=i[(i.length-1+r)%i.length];for(let s=r;s<i.length-2-1+r;++s){const r=i[s],o=i[s+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=V.normalizeVec3(V.subVec3(e[1],e[0],V.vec3())),i=V.normalizeVec3(V.subVec3(e[2],e[0],wy)),s=V.normalizeVec3(V.cross3Vec3(t,i,V.vec3())),r=V.normalizeVec3(V.cross3Vec3(s,t,V.vec3()));return{normal:s,origin:V.vec3(e[0]),u:t,v:r}}(),c=[];let h;return function t(){const u=l(c);let d=!1;const f=i((t=>{const i=t&&(e=>{const t=s(e),i=t&&t.entity&&(!u||t.snapped)&&t.worldPos;if(u){const t=V.dotVec3(u.normal,u.origin),s=i?t-V.dotVec3(i,u.normal):window.Infinity;if(Math.abs(s)<1e-4){const e=V.vec3();return{worldPos:V.addVec3(i,V.mulVec3Scalar(u.normal,s,e),e),snapped:!0}}return{worldPos:Ty(t,u.normal,e.origin,e.direction),snapped:!1}}return{worldPos:i,snapped:t&&t.snapped}})(((t,i)=>(V.canvasPosToWorldRay(A,e.camera.viewMatrix,e.camera.projMatrix,e.camera.projection,t,i.origin,i.direction),i))(t,xy)),r=i&&i.worldPos;return p(r,t,i&&i.snapped)})),p=(i,s,A)=>{const h=i?e.camera.projectWorldPos(i):s,f=c.length>0&&function(){const t=c[0];return{canvasPos:e.camera.projectWorldPos(t),worldPos:t}}(),p=c.length>=3&&(h&&V.distVec2(h,f.canvasPos)<10||i&&V.compareVec3(i,f.worldPos));o(p?f.canvasPos:h,p||A);const g=s&&(!i||(c.length<3?c.some((e=>V.compareVec3(e,i))):V.compareVec3(c[c.length-1],i))),m=c.concat(p||!i||g?[]:[i]),_=!g&&(u||l(m)),b=_&&m.map((e=>(V.subVec3(e,_.origin,wy),V.vec2([V.dotVec3(wy,_.u),V.dotVec3(wy,_.v)])))),B=!(g||b&&a(b,p)),y=B&&b&&(p||!a(b,!0))&&function(){try{const[e,t,i]=jy(b);return{faces:t,vertices:e.map((e=>V.addVec3(_.origin,V.addVec3(V.mulVec3Scalar(_.u,e[0],wy),V.mulVec3Scalar(_.v,e[1],vy),wy),V.vec3())))}}catch(e){return console.warn("e",e),!1}}();return r(m,p,B,y),d=B&&(p?()=>{o(null),n()}:()=>{c.push(V.vec3(i)),o(null),t()})};h={closePolygon:()=>{const e=c.length>=3&&p(c[0]);return e&&(f(),e()),!!e},placeVertex:()=>(d&&(f(),d()),!!d),popVertex:()=>c.length>0&&(f(),c.pop(),t(),!0),removePressListener:f,updateOnChange:()=>p()}}(),{cancel:()=>{h.removePressListener(),o(null)},closePolygon:()=>h.closePolygon(),placeVertex:()=>h.placeVertex(),popVertex:()=>h.popVertex(),updateOnChange:()=>h.updateOnChange()}};class Ky{constructor(e){this.language="en",this.localeService=e.localeService||new me,this.scene=new qo(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 Ga(this,this.scene),this.id=e.id||this.scene.id,this.camera=this.scene.camera,this.cameraFlight=new xe(this.scene,{duration:.5}),this.cameraControl=new Oa(this.scene,{doublePickFlyTo:!0}),this._plugins=[],this._eventSubs={}}get capabilities(){return this.scene.capabilities}on(e,t){let i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}fire(e,t){const i=this._eventSubs[e];if(i)for(let e=0,s=i.length;e<s;e++)i[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,i=this._plugins.length;t<i;t++){const i=this._plugins[t];if(i===e)return i.clear&&i.clear(),void this._plugins.splice(t,1)}}sendToPlugins(e,t){for(let i=0,s=this._plugins.length;i<s;i++){const s=this._plugins[i];s.send&&s.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,i=this.scene.canvas.canvas,s=i.clientWidth,r=i.clientHeight,n=!e.includeGizmos;t&&(i.width=e.width?Math.floor(e.width):i.width,i.height=e.height?Math.floor(e.height):i.height),this.beginSnapshot(),n&&this.sendToPlugins("snapshotStarting");const A=this.scene._renderer.snapshot.renderSnapshotToCanvas();return t&&(i.width=s,i.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),i={},s=[];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&&(i[e.id]||(i[e.id]=!0,s.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=s.length;e<t;e++){const t=s[e];await(A=t,o={canvas:n,backgroundColor:null,scale:n.width/t.clientWidth},void 0===o&&(o={}),uy(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,i=e.length;t<i;t++){e[t].destroy()}this.scene.destroy()}}async function Zy(e,t){if(!t.src||!Array.isArray(t.src)||6!==t.src.length)throw new Error("src requires path to 6 images");const[i,s,r,n,A,o]=t.src;if(!(i&&s&&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,i)=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>t(s),s.onerror=()=>i(new Error(`Failed to load image: ${e}`)),s.src=e}));try{const[h,u,d,f,p,g]=await Promise.all([c(i),c(s),c(r),c(n),c(A),c(o)]),m=h.width;if(u.width!==m||d.width!==m||f.width!==m||p.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(f,1*m,2*m,m,m),l.drawImage(p,1*m,1*m,m,m),l.drawImage(g,3*m,1*m,m,m);return new Cs(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}}function Jy(e,t){return new as(e,{geometry:new We(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 fs(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})}function Yy(e,t){const i=new We(e,rt({center:[0,0,0],radius:1,heightSegments:60,widthSegments:60})),s=new fs(e,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:t,backfaces:!0});return new as(e,{geometry:i,background:!0,rotation:[0,0,180],material:s,visible:!0,pickable:!1,clippable:!1,collidable:!1})}const $y=V.vec3(),qy=V.vec3();class ew extends Ae{constructor(e,t={}){const i=e.viewer.scene;super(i,t),this.plugin=e;const s=t.container;if(!s)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e){const t=[];let i=!1!==e;return{reg:e=>t.push(e),get:()=>i,set:e=>{i=!1!==e,t.forEach((e=>e(i)))}}};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=i.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 i=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(i))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},f=(t,r,n)=>{const f=new Oy(i,s,{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(f,n),{setEnds:(e,t)=>f.setEnds(e,t),setColor:e=>f.setColor(e)}};this._originWire=f(this._color||"blue",1,[this._visible,this._originWireVisible]),this._targetWire=f(this._color||"red",1,[this._visible,this._targetWireVisible]);this._angleLabel=((t,r,n)=>{const f=new Ry(i,s,{fillColor:t,zIndex:e.zIndex+r,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(f,n),{setFillColor:e=>f.setFillColor(e),setPosOnWire:(e,t,i)=>f.setPosOnWire(e,t,i),setPosBetween:(e,t,i)=>f.setPosBetween(e,t,i),setText:e=>f.setText(e)}})(this._color||"#00BBFF",2,[this._visible,this._angleVisible,this._labelsVisible]);const p=(t,r)=>{const n=new Qy(i,t,s,{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=p(t.origin,[this._visible,this._originVisible]),this._cornerDot=p(t.corner,[this._visible,this._cornerVisible]),this._targetDot=p(t.target,[this._visible,this._targetVisible]),this._update()}_update(){if(!this._targetDot)return;const e=this._originDot.worldPos,t=this._cornerDot.worldPos,i=this._targetDot.worldPos;this._originWire.setEnds(e,t),this._targetWire.setEnds(t,i),this._angleLabel.setPosBetween(e,t,i),V.subVec3(e,t,$y),V.subVec3(i,t,qy),V.lenVec3($y)>0&&V.lenVec3(qy)>0?(V.normalizeVec3($y),V.normalizeVec3(qy),this._angle=Math.abs(V.angleVec3($y,qy))*V.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 tw extends Ae{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class iw extends tw{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,i=this.angleMeasurementsPlugin.viewer.cameraControl,s=this.pointerLens;let r=!1,n=null,A=0,o=0;const a=V.vec3(),l=V.vec2();this._currentAngleMeasurement=null;const c=V.vec2(),h=e=>{e.snappedToVertex||e.snappedToEdge?(s&&(s.visible=!0,s.canvasPos=e.canvasPos,s.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,s.snapped=!0),this.markerDiv.style.background="greenyellow",this.markerDiv.style.border="2px solid green"):(s&&(s.visible=!0,s.canvasPos=e.canvasPos,s.snappedCanvasPos=e.canvasPos,s.snapped=!1),this.markerDiv.style.background="pink",this.markerDiv.style.border="2px solid red");const i=e.snappedCanvasPos||e.canvasPos;switch(r=!0,n=e.entity,a.set(e.worldPos),l.set(i),this._mouseState){case 0:if(this._canvasToPagePos)this._canvasToPagePos(t,i,c),this.markerDiv.style.left=c[0]-5+"px",this.markerDiv.style.top=c[1]-5+"px";else{const e=V.vec2(i);Py(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=i.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=i.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:V.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,s&&(s.visible=!0,s.canvasPos=e.canvasPos,s.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,s.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=i.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=i.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()}}class sw extends qA{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 iw(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,i=e.corner,s=e.target,r=new ew(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},corner:{entity:i.entity,worldPos:i.worldPos},target:{entity:s.entity,worldPos:s.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,i]of Object.entries(this.measurements))i.labelShown=e}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t<i;t++)this.destroyMeasurement(e[t])}destroy(){this.clear(),super.destroy()}}const rw=V.vec2();class nw extends tw{constructor(e,t={}){super(e.viewer.scene),this.pointerLens=t.pointerLens,this.pointerCircle=new ge(e.viewer),this._active=!1;const i=document.createElement("div"),s=this.scene.canvas.canvas;s.parentNode.insertBefore(i,s),i.style.background="black",i.style.border="2px solid blue",i.style.borderRadius="10px",i.style.width="5px",i.style.height="5px",i.style.margin="-200px -200px",i.style.zIndex="100",i.style.position="absolute",i.style.pointerEvents="none",this.markerDiv=i,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,i=t.canvas.canvas;e.pointerLens;const s=V.vec3(),r=20;let n=null;this._touchState=0;const A=V.vec2(),o=V.vec2(),a=V.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,Py(i.ownerDocument.documentElement,i,t),t),f=(e,t)=>(t.set(e),Py(i,i.ownerDocument.documentElement,t),t);i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const a=i.touches.length;if(1!==a)return void(n&&(clearTimeout(n),n=null));const h=i.touches[0];switch(d(h,A),o.set(A),this._touchState){case 0:if(1!==a&&null!==n)return void u();const i=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(f(i.snappedCanvasPos,rw));else{const e=t.pick({canvasPos:o,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(f(e.canvasPos,rw))}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=i.canvasPos,this.pointerLens.snapped=!0),this._currentAngleMeasurement?this._currentAngleMeasurement.origin.worldPos=s:(this._currentAngleMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:i.worldPos,entity:i.entity},corner:{worldPos:i.worldPos,entity:i.entity},target:{worldPos:i.worldPos,entity:i.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(f(e.snappedCanvasPos,rw)),s.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(f(e.canvasPos,rw)),s.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(f(e.snappedCanvasPos,rw)),s.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(f(e.canvasPos,rw)),s.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}),i.addEventListener("touchmove",(e=>{this.pointerCircle.stop();const i=e.touches.length;if(1!==i||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),s.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),s.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!==i&&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!==i&&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}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const c=i.changedTouches[0];if(c.identifier!==l)return;n&&(clearTimeout(n),n=null),d(c,a);const u=a[0],f=a[1];switch(this._touchState){case 1:{if(1!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<A[1]-r)return void(this._touchState=0);const i=t.pick({canvasPos:o,pickSurface:!0});i&&i.worldPos?(this._currentAngleMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:i.worldPos},corner:{worldPos:i.worldPos},target:{worldPos:i.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!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<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!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<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()}}class Aw extends Ae{constructor(e,t,i,s){const r=e.plugin.viewer;super(r.scene);const n=Ny({viewer:r,handleMouseEvents:i,handleTouchEvents:s,pointerLens:t.pointerLens,dots:[e.origin,e.corner,e.target],ray2WorldPos:(e,i,s)=>{const n=e=>{const t=r.scene.pick({canvasPos:s,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const i=!V.compareVec3(e,t.worldPos);return i&&this.fire("edited"),i}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}class ow extends Aw{constructor(e,t){super(e,t,!0,!1)}}class aw extends Aw{constructor(e,t){super(e,t,!1,!0)}}const lw=V.vec3(),cw=V.vec3(),hw=V.vec3(),uw=e=>e+"px";class dw extends PA{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=fy(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>";X.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)})),fy(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>";X.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],i=e[1]+this.canvasPos[1];if(this._marker.style.top=uw(i-12),this._label.style.top=uw(i-17),"legacy"===this._markerAlign)this._marker.style.left=uw(t-12),this._label.style.left=uw(t+40);else{const e=this._curMarkerWidth,i=t+("right"===this._markerAlign?-1:"center"===this._markerAlign?0:1)*(e/2-12);this._marker.style.left=uw(i-e/2);const s=this._curLabelWidth,r=Math.sign(this._labelPosition);this._label.style.left=uw(i+r*(e/2+Math.abs(this._labelPosition)+s/2)-s/2)}const s=90005+Math.floor(this._viewPos[2])+1;this._marker.style["z-index"]=s,this._label.style["z-index"]=s}_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 i=this._values[t];e=e.replace(new RegExp("{{"+t+"}}","g"),i)}return e}setFromPickResult(e){if(e.worldPos&&e.worldNormal){const t=V.normalizeVec3(e.worldNormal,lw),i=this.plugin&&this.plugin.surfaceOffset||0,s=V.mulVec3Scalar(t,i,cw),r=V.addVec3(e.worldPos,s,hw);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 i=e[t];this.setField(t,i)}}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()}}class fw extends qA{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 i=null;e.labelElementId&&((i=document.getElementById(e.labelElementId))||this.error("Can't find DOM element for 'labelElementId' value '"+e.labelElementId+"' - defaulting to internally-generated empty DIV"));const s=new dw(this.viewer.scene,{id:e.id,plugin:this,container:this._container,markerElement:t,labelElement:i,markerHTML:e.markerHTML||this._markerHTML,labelHTML:e.labelHTML||this._labelHTML,occludable:e.occludable,values:X.apply(e.values,X.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?s.setFromPickResult(e.pickResult):(s.entity=e.entity,s.worldPos=e.worldPos),this.annotations[s.id]=s,s.on("destroyed",(()=>{delete this.annotations[s.id],this.fire("annotationDestroyed",s.id)})),this.fire("annotationCreated",s.id),s}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,i=e.length;t<i;t++)this.destroyAnnotation(e[t])}destroy(){this.clear(),super.destroy()}}class pw extends qA{constructor(e,t){super("AxisGizmo",e,t=t||{});const i=e.scene.camera;t.canvasId||t.canvasElement||this.error("Config expected: either 'canvasId' or 'canvasElement'");try{this._axisGizmoScene=new qo(e,{canvasId:t.canvasId,canvasElement:t.canvasElement,transparent:!0})}catch(e){return void this.error(e)}const s=this._axisGizmoScene;s.clearLights(),new BA(s,{color:[.45,.45,.5],intensity:.9}),new wA(s,{dir:[-.5,.5,-.6],color:[.8,.8,.7],intensity:1,space:"view"}),new wA(s,{dir:[.5,-.5,-.6],color:[.8,.8,.8],intensity:1,space:"view"});const r=s.camera;i.on("matrix",(function(){const e=i.eye,t=i.look,s=i.up,n=V.mulVec3Scalar(V.normalizeVec3(V.subVec3(e,t,[])),22);r.look=[0,0,0],r.eye=n,r.up=s}));const n=new We(s,tt({radiusTop:.01,radiusBottom:.6,height:1.7,radialSegments:20,heightSegments:1,openEnded:!1})),A=new We(s,tt({radiusTop:.2,radiusBottom:.2,height:4.5,radialSegments:20,heightSegments:1,openEnded:!1})),o=new fs(s,{diffuse:[1,.3,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),a=new fs(s,{emissive:[1,.3,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),l=new fs(s,{diffuse:[.3,1,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),c=new fs(s,{emissive:[.3,1,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),h=new fs(s,{diffuse:[.3,.3,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),u=new fs(s,{emissive:[.3,.3,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),d=new fs(s,{diffuse:[.5,.5,.5],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2});this._meshes=[new as(s,{geometry:new We(s,rt({radius:9,heightSegments:60,widthSegments:60})),material:new fs(s,{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 as(s,{geometry:new We(s,rt({radius:1})),material:d,pickable:!1,collidable:!1,visible:!1!==t.visible}),new as(s,{geometry:n,material:o,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[5,0,0],rotation:[0,0,-90]}),new as(s,{geometry:A,material:o,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[2,0,0],rotation:[0,0,90]}),new as(s,{geometry:new We(s,ot({text:"X",size:1.5})),material:a,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[7,0,0],billboard:"spherical"}),new as(s,{geometry:n,material:l,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,5,0]}),new as(s,{geometry:A,material:l,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,2,0]}),new as(s,{geometry:new We(s,ot({text:"Y",size:1.5})),material:c,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,7,0],billboard:"spherical"}),new as(s,{geometry:n,material:h,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,0,5],rotation:[90,0,0]}),new as(s,{geometry:A,material:h,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,0,2],rotation:[90,0,0]}),new as(s,{geometry:new We(s,ot({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()}}const gw=V.vec3(),mw=V.vec3(),_w=V.vec3(),bw=V.vec3();class Bw extends qA{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,i=t.camera,s=t.realWorldOffset,r=!0===e.reverseClippingPlanes;let n={},A=V.normalizeVec3(V.subVec3(i.look,i.eye,V.vec3())),o=i.eye,a=i.up;i.yUp&&(A=vw(A),o=vw(o),a=vw(a));const l=yw(V.addVec3(o,s));"ortho"===i.projection?n.orthogonal_camera={camera_view_point:l,camera_direction:yw(A),camera_up_vector:yw(a),view_to_world_scale:i.ortho.scale}:n.perspective_camera={camera_view_point:l,camera_direction:yw(A),camera_up_vector:yw(a),field_of_view:i.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?V.negateVec3(t.dir,V.vec3()):t.dir,i.yUp&&(o=vw(o),A=vw(A)),V.addVec3(o,s),o=yw(o),A=yw(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 i=t.positions,s=t.indices;for(let e=0,t=s.length/2;e<t;e++){const t=s[2*e],r=s[2*e+1];n.lines.push({start_point:{x:i[3*t+0],y:i[3*t+1],z:i[3*t+2]},end_point:{x:i[3*r+0],y:i[3*r+1],z:i[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;i.yUp&&(r=vw(r),A=vw(A),o=vw(o)),V.addVec3(r,s),n.bitmaps||(n.bitmaps=[]),n.bitmaps.push({bitmap_type:t.type,bitmap_data:t.imageData,location:yw(r),normal:yw(A),up:yw(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),f=new Set(t.xrayedObjectIds),p=new Set(t.colorizedObjectIds),g=Object.values(t.objects).filter((e=>d.has(e.id)||p.has(e.id)||f.has(e.id))).reduce(((e,i)=>{let s,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}(i.colorize);i.xrayed?(s=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,s=Math.round(255*s).toString(16).padStart(2,"0"),r=s+r):d.has(i.id)&&(s=Math.round(255*i.opacity).toString(16).padStart(2,"0"),r=s+r),e[r]||(e[r]=[]);const n=i.id,A=i.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,i=[];for(let s=0,r=e.length;s<r;s++){const r=e[s],n=t.objects[r];if(n){const e={ifc_guid:n.originalSystemId,originating_system:this.originatingSystem};n.originalSystemId!==r&&(e.authoring_tool_id=r),i.push(e)}}return i}setViewpoint(e,t={}){if(!e)return;const i=this.viewer,s=i.scene,r=s.camera,n=!1!==t.rayCast,A=!1!==t.immediate,o=!1!==t.reset,a=s.realWorldOffset,l=!0===t.reverseClippingPlanes;if(s.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){let t=ww(e.location,gw),i=ww(e.direction,gw);l&&V.negateVec3(i),V.subVec3(t,a),r.yUp&&(t=Cw(t),i=Cw(i)),new ZA(s,{pos:t,dir:i})})),s.clearLines(),e.lines&&e.lines.length>0){const t=[],i=[];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),i.push(r++),i.push(r++))})),new _A(s,{positions:t,indices:i,clippable:!1,collidable:!0})}if(s.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){const t=e.bitmap_type||"jpg",i=e.bitmap_data;let n=ww(e.location,mw),A=ww(e.normal,_w),o=ww(e.up,bw),a=e.height||1;t&&i&&n&&A&&o&&(r.yUp&&(n=Cw(n),A=Cw(A),o=Cw(o)),new Ns(s,{src:i,type:t,pos:n,normal:A,up:o,clippable:!1,collidable:!0,height:a}))})),o&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),s.setObjectsHighlighted(s.highlightedObjectIds,!1),s.setObjectsSelected(s.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(s.setObjectsVisible(s.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!1))))):(s.setObjectsVisible(s.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&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcSpace"),!1),void 0!==r.spaces_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcSpace"),!0),r.space_boundaries_visible,!1===r.openings_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcOpening"),!0),r.space_boundaries_translucent,void 0!==r.openings_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(s.setObjectsSelected(s.selectedObjectIds,!1),e.components.selection.forEach((e=>this._withBCFComponent(t,e,(e=>e.selected=!0))))),e.components.translucency&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),e.components.translucency.forEach((e=>this._withBCFComponent(t,e,(e=>e.xrayed=!0))))),e.components.coloring&&(s.setObjectsColorized(s.colorizedObjectIds,null),e.components.coloring.forEach((e=>{let i=e.color,s=0,r=!1;8===i.length&&(s=parseInt(i.substring(0,2),16)/255,s<=1&&s>=.95&&(s=1),i=i.substring(2),r=!0);const n=[parseInt(i.substring(0,2),16)/255,parseInt(i.substring(2,4),16)/255,parseInt(i.substring(4,6),16)/255];e.components.map((e=>this._withBCFComponent(t,e,(e=>{e.colorize=n,r&&(e.opacity=s)}))))})))}if(e.perspective_camera||e.orthogonal_camera){let o,l,c,h;if(e.perspective_camera?(o=ww(e.perspective_camera.camera_view_point,gw),l=ww(e.perspective_camera.camera_direction,gw),c=ww(e.perspective_camera.camera_up_vector,gw),r.perspective.fov=e.perspective_camera.field_of_view,h="perspective"):(o=ww(e.orthogonal_camera.camera_view_point,gw),l=ww(e.orthogonal_camera.camera_direction,gw),c=ww(e.orthogonal_camera.camera_up_vector,gw),r.ortho.scale=e.orthogonal_camera.view_to_world_scale,h="ortho"),V.subVec3(o,a),r.yUp&&(o=Cw(o),l=Cw(l),c=Cw(c)),n){const e=s.pick({pickSurface:!0,origin:o,direction:l});l=e?e.worldPos:V.addVec3(o,l,gw)}else l=V.addVec3(o,l,gw);A?(r.eye=o,r.look=l,r.up=c,r.projection=h):i.cameraFlight.flyTo({eye:o,look:l,up:c,duration:t.duration,projection:h})}}_withBCFComponent(e,t,i){const s=this.viewer,r=s.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 i(A);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[n])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}}if(t.ifc_guid){const n=t.ifc_guid,A=r.objects[n];if(A)return void i(A);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[n])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}Object.keys(r.models).forEach((t=>{const A=V.globalizeObjectId(t,n),o=r.objects[A];if(o)i(o);else if(e.updateCompositeObjects){s.metaScene.metaObjects[A]&&r.withObjects(s.metaScene.getObjectIDsInSubtree(A),i)}}))}}destroy(){super.destroy()}}function yw(e){return{x:e[0],y:e[1],z:e[2]}}function ww(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function vw(e){return new Float64Array([e[0],-e[2],e[1]])}function Cw(e){return new Float64Array([e[0],e[2],-e[1]])}const Mw=V.vec3(),Ew=V.vec3(),Fw=V.vec3();V.vec4(),V.vec4(),V.vec4();class Uw extends Ae{constructor(e,t={}){const i=e.viewer.scene;super(i,t),this.plugin=e;const s=t.container;if(!s)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e,t){const i=[];let s=void 0!==e?Boolean(e):t;return{reg:e=>i.push(e),get:()=>s,set:e=>{s=void 0!==e?Boolean(e):t,i.forEach((e=>e(s)))}}};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=V.identityMat4(),this.approximate=t.approximate,this._labelStringFormat=e=>{const t=this.plugin.viewer.scene.metrics,i=t.scale,s=t.unitsInfo[t.units].abbrev;return(this.approximate?" ~ ":" = ")+(e*i).toFixed(2)+s};const n=i.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=i.metrics.on("units",(()=>this._update()));this._cleanups.push((()=>i.metrics.off(t)))})),this._drawables=[];const d=(e,t)=>{const i=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(i))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},f=(t,r,n)=>{const f=new Oy(i,s,{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(f,n),{setEnds:(e,t)=>f.setEnds(e,t),setColor:e=>f.setColor(e)}};this._lengthWire=f(this._color,2,[this._visible,this._wireVisible]),this._xAxisWire=f("red",1,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible]),this._yAxisWire=f("green",1,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible]),this._zAxisWire=f("blue",1,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible]);const p=(t,r,n)=>{const f=new Ry(i,s,{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(f,n),{setFillColor:e=>f.setFillColor(e),setPosOnWire:(e,t,i,s)=>f.setPosOnWire(e,t,i,s),setPosBetween:(e,t,i)=>f.setPosBetween(e,t,i),setText:e=>f.setText(e.replace(/ /g," "))}};this._lengthLabel=p(this._color,4,[this._visible,this._wireVisible,this._labelsVisible,this._clickable,this._axisEnabled,this._lengthLabelEnabled]),this._xAxisLabel=p("red",3,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible,this._labelsVisible,this._clickable,this._xLabelEnabled]),this._yAxisLabel=p("green",3,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible,this._labelsVisible,this._clickable,this._yLabelEnabled]),this._zAxisLabel=p("blue",3,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible,this._labelsVisible,this._clickable,this._zLabelEnabled]);const g=(t,r)=>{const n=new Qy(i,t,s,{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,i=this._axesBasis,s=V.subVec3(t,e,Mw),r=V.transformVec3(i,s,s),n=this._useRotationAdjustment.get()&&Math.abs(s[1])>0,A=(i,s)=>{const r=this.plugin.viewer.scene.metrics,A=r.scale;r.unitsInfo[r.units].abbrev;const o=(i,s,r,n)=>{this._labelsOnWires.get()?i.setPosOnWire(s,r,0,this.plugin.labelMinAxisLength):i.setPosOnWire(e,t,35*n,0)};this._xAxisWire.setEnds(e,i),o(this._xAxisLabel,e,i,1),this._xAxisLabel.setText("X"+this._labelStringFormat(V.distVec3(e,i))),this._yAxisWire.setEnds(i,s),o(this._yAxisLabel,i,s,2),this._yAxisLabel.setText("Y"+this._labelStringFormat(V.distVec3(i,s))),this._zAxisWire.setEnds(s,t),o(this._zAxisLabel,s,t,3),this._zAxisLabel.setText((n?"":"Z")+this._labelStringFormat(V.distVec3(s,t))),this._lengthWire.setEnds(e,t),o(this._lengthLabel,e,t,0);const a=V.distVec3(e,t);this._length=a*A,this._lengthLabel.setText(this._labelStringFormat(a))};n?(Fw[0]=e[0],Fw[1]=t[1],Fw[2]=e[2],A(e,Fw)):(Ew[0]=e[0]+i[0]*r[0],Ew[1]=e[1]+i[4]*r[0],Ew[2]=e[2]+i[8]*r[0],Fw[0]=Ew[0]+i[1]*r[1],Fw[1]=Ew[1]+i[5]*r[1],Fw[2]=Ew[2]+i[9]*r[1],A(Ew,Fw))}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 xw extends Ae{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class Iw extends xw{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,i=e.viewer.cameraControl,s=t.canvas.canvas;t.input;let r=!1;const n=V.vec3(),A=V.vec2();let o,a;let l=null;this._mouseState=0;const c=V.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(s,t,c),this._markerDiv.style.left=c[0]-5+"px",this._markerDiv.style.top=c[1]-5+"px";else{const e=V.vec2(t);Py(s,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";s.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=i.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=i.on("hoverSurface",(e=>{this._snapping||h(e)})),s.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(o=e.clientX,a=e.clientY)}),s.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:V.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),s.style.cursor="default"};this._onHoverSnapOrSurfaceOff=i.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=i.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()}}class Tw extends qA{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 Iw(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,i=e.target,s=new Uw(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:i.entity,worldPos:i.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[s.id]=s,s.clickable=!0,s.on("destroyed",(()=>{delete this._measurements[s.id]})),this.fire("measurementCreated",s),s}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,i]of Object.entries(this.measurements))i.labelShown=e}setAxisVisible(e){for(const[t,i]of Object.entries(this.measurements))i.axisVisible=e;this.defaultAxisVisible=e}getAxisVisible(){return this.defaultAxisVisible}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t<i;t++)this.destroyMeasurement(e[t])}destroy(){this.clear(),super.destroy()}}const Pw=V.vec2();class Sw extends xw{constructor(e,t={}){super(e.viewer.scene),this.pointerLens=t.pointerLens,this.pointerCircle=new ge(e.viewer),this._active=!1;const i=document.createElement("div"),s=this.scene.canvas.canvas;s.parentNode.insertBefore(i,s),i.style.background="black",i.style.border="2px solid blue",i.style.borderRadius="10px",i.style.width="5px",i.style.height="5px",i.style.margin="-200px -200px",i.style.zIndex="100",i.style.position="absolute",i.style.pointerEvents="none",this.markerDiv=i,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,i=t.canvas.canvas;e.pointerLens;const s=V.vec3(),r=20;let n=null;this._touchState=0;const A=V.vec2(),o=V.vec2(),a=V.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,Py(i.ownerDocument.documentElement,i,t),t),f=(e,t)=>(t.set(e),Py(i,i.ownerDocument.documentElement,t),t);i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const a=i.touches.length;if(1!==a)return void(n&&(clearTimeout(n),n=null));const h=i.touches[0];switch(d(h,A),o.set(A),this._touchState){case 0:if(1!==a&&null!==n)return void u();const i=t.pick({canvasPos:o,snapping:this._snapping,snapToEdge:this._snapping});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(f(i.snappedCanvasPos,Pw));else{const e=t.pick({canvasPos:o,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(f(e.canvasPos,Pw))}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=i.canvasPos,this.pointerLens.snapped=!0),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=s:(this._currentDistanceMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:s,entity:i.entity},target:{worldPos:s,entity:i.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(f(e.snappedCanvasPos,Pw)),s.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(f(e.canvasPos,Pw)),s.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}),i.addEventListener("touchmove",(i=>{this.pointerCircle.stop();const r=i.touches.length;if(1!==r||1!==i.changedTouches.length)return void(n&&(clearTimeout(n),n=null));const A=i.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),s.set(a.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=a.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:V.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),s.set(c.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=c.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:V.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}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const c=i.changedTouches[0];if(c.identifier!==l)return;n&&(clearTimeout(n),n=null),d(c,a);const u=a[0],f=a[1];switch(this._touchState){case 1:{if(1!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<A[1]-r)return void(this._touchState=0);const i=t.pick({canvasPos:o,pickSurface:!0});i&&i.worldPos?(this._currentDistanceMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:i.worldPos,entity:i.entity},target:{worldPos:i.worldPos,entity:i.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!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<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()}}class Dw extends Ae{constructor(e,t,i,s){const r=e.plugin.viewer;super(r.scene);const n=Ny({viewer:r,handleMouseEvents:i,handleTouchEvents:s,pointerLens:t.pointerLens,dots:[e.origin,e.target],ray2WorldPos:(e,i,s)=>{const n=e=>{const t=r.scene.pick({canvasPos:s,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const i=!V.compareVec3(e,t.worldPos);return i&&this.fire("edited"),i}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}class kw extends Dw{constructor(e,t){super(e,t,!0,!1)}}class Qw extends Dw{constructor(e,t){super(e,t,!1,!0)}}class Rw extends qA{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 i=1e3*this._delayBeforeRestoreSeconds,s=!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(),s=!1};this._onCameraMatrix=e.scene.camera.on("matrix",(()=>{i=1e3*this._delayBeforeRestoreSeconds,s||(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()),s=!0)})),this._onSceneTick=e.scene.on("tick",(e=>{s&&(i-=e.deltaTime,(!this._delayBeforeRestore||i<=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()}}class Ow{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,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getGLTF(e,t,i){X.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getGLB(e,t,i){X.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getArrayBuffer(e,t,i,s){!function(e,t,i,s){var r=()=>{};i=i||r,s=s||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);ie.scheduleTask((function(){i(e)}))}catch(e){ie.scheduleTask((function(){s(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?i(A.response):s("loadArrayBuffer error : "+A.response))},A.send(null)}}(this._cacheBusterURL(e),t,(e=>{i(e)}),(function(e){s(e)}))}}class Vw{constructor(e){}load(e,t,i,s,r,n,A){!function(e,t,i,s,r,n,A){const o=e.viewer.scene.canvas.spinner;o.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(a=>{s.basePath=Lw(t),Hw(e,t,a,i,s,r,n,A),o.processes--}),(e=>{o.processes--,A(e)})):e.dataSource.getGLTF(t,(a=>{s.basePath=Lw(t),Hw(e,t,a,i,s,r,n,A),o.processes--}),(e=>{o.processes--,A(e)}))}(e,t,i,s=s||{},r,(function(){ie.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,i,s,r,n,A){Hw(e,"",t,i,s=s||{},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 Lw(e){const t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}function Hw(e,t,i,s,r,n,A,o){const a=e.viewer.scene.canvas.spinner;a.processes++,Lc(i,Xd,{baseUri:r.basePath}).then((i=>{const o=function(e,t){return(new rf).postProcess(e,t)}(i),l={src:t,entityId:r.entityId,metaModelJSON:s,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 i=0,s=t.length;i<s;i++)Nw(e,t[i])}(l),function(e){const t=e.gltfData.materials;if(t)for(let i=0,s=t.length;i<s;i++){const s=t[i];s._textureSetId=Gw(e,s),s._attributes=jw(e,s)}}(l),r.autoMetaModel&&l.metaObjects.push({id:n.id,type:"Default",name:n.id}),Ww(l),n.finalize(),r.autoMetaModel&&e.viewer.metaScene.createMetaModel(n.id,{metaObjects:l.metaObjects}),a.processes--,A()})).catch((e=>{o&&o(e)}))}function Nw(e,t){if(!t.source||!t.source.image)return;const i="texture-"+e.nextId++;let s=1005;switch(t.sampler.minFilter){case 9728:s=1003;break;case 9729:s=1006;break;case 9984:s=1004;break;case 9985:s=1007;break;case 9986:s=1005;break;case 9987:s=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:i,image:t.source.image,flipY:!!t.flipY,minFilter:s,magFilter:r,wrapS:n,wrapT:A,wrapR:o,encoding:3001}),t._textureId=i}function Gw(e,t){const i={};switch(t.normalTexture&&(i.normalTextureId=t.normalTexture.texture._textureId),t.occlusionTexture&&(i.occlusionTextureId=t.occlusionTexture.texture._textureId),t.emissiveTexture&&(i.emissiveTextureId=t.emissiveTexture.texture._textureId),t.alphaMode){case"OPAQUE":break;case"MASK":const e=t.alphaCutoff;i.alphaCutoff=void 0!==e?e:.5}const s=t.pbrMetallicRoughness;if(t.pbrMetallicRoughness){const r=t.pbrMetallicRoughness,n=r.baseColorTexture||r.colorTexture;n&&(n.texture?i.colorTextureId=n.texture._textureId:i.colorTextureId=e.gltfData.textures[n.index]._textureId),s.metallicRoughnessTexture&&(i.metallicRoughnessTextureId=s.metallicRoughnessTexture.texture._textureId)}const r=t.extensions;if(r){const t=r.KHR_materials_pbrSpecularGlossiness;if(t){t.specularTexture;const s=t.specularColorTexture;null!=s&&(i.colorTextureId=e.gltfData.textures[s.index]._textureId)}}return void 0!==i.normalTextureId||void 0!==i.occlusionTextureId||void 0!==i.emissiveTextureId||void 0!==i.colorTextureId||void 0!==i.metallicRoughnessTextureId?(i.id=`textureSet-${e.nextId++};`,e.sceneModel.createTextureSet(i),i.id):null}function jw(e,t){const i=t.extensions,s={color:new Float32Array([1,1,1,1]),opacity:1,metallic:0,roughness:1,doubleSided:!0};if(i){const e=i.KHR_materials_pbrSpecularGlossiness;if(e){const t=e.diffuseFactor;null!=t&&s.color.set(t)}const t=i.KHR_materials_common;if(t){const e=t.technique,i=t.values||{},r="BLINN"===e,n="PHONG"===e,A="LAMBERT"===e,o=i.diffuse;o&&(r||n||A)&&(X.isString(o)||s.color.set(o));const a=i.transparency;null!=a&&(s.opacity=a);const l=i.transparent;null!=l&&(s.opacity=l)}}const r=t.pbrMetallicRoughness;if(r){const e=r.baseColorFactor;e&&(s.color[0]=e[0],s.color[1]=e[1],s.color[2]=e[2],s.opacity=e[3]);const t=r.metallicFactor;null!=t&&(s.metallic=t);const i=r.roughnessFactor;null!=i&&(s.roughness=i)}return s.doubleSided=!1!==t.doubleSided,s}function Ww(e){const t=e.gltfData,i=t.scene||t.scenes[0];if(!i)return void function(e,t){e.plugin.error(t)}(e,"glTF has no default scene");const s=i.nodes;if(!s)return;!function e(t){t.forEach((t=>{const i=t.mesh;i&&(i.instances||=0,i.instances+=1),t.children&&e(t.children)}))}(s);const r=[];let n=null;!function t(i,s,A){i.forEach((i=>{const o=i.name;let a=null!=o&&o||0===s&&"entity-"+e.nextId++;if(a){for(;e.sceneModel.objects[a];)a="entity-"+e.nextId++;r.push(n),n=[]}const l=function(e,t){let i;e.matrix&&(i=e.matrix,t=t?V.mulMat4(t,i,V.mat4()):i);e.translation&&(i=V.translationMat4v(e.translation),t=t?V.mulMat4(t,i,V.mat4()):i);e.rotation&&(i=V.quaternionToMat4(e.rotation),t=t?V.mulMat4(t,i,V.mat4()):i);e.scale&&(i=V.scalingMat4v(e.scale),t=t?V.mulMat4(t,i,V.mat4()):i);return t}(i,A);if(i.mesh&&function(e,t,i,s){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),i?V.transformPositions3(i,A.localPositions,A.positions):A.positions.set(A.localPositions);const c=V.vec3();Ct(A.positions,A.positions,c)&&(A.origin=c),t.sceneModel.createMesh(A),s.push(A.id)}}(i,e,l,n),i.children&&t(i.children,s+1,l),a){if(n.length>0){const t=e.globalizeObjectIds?V.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()}}))}(s,0,null)}const zw={DEFAULT:{}};class Xw extends qA{constructor(e,t={}){super("GLTFLoader",e,t),this._sceneModelLoader=new Vw(this,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new Ow}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||zw}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 mA(this.viewer.scene,X.apply(e,{isModel:!0,dtxEnabled:e.dtxEnabled})),i=t.id;if(!e.src&&!e.gltf)return this.error("load() param expected: src or gltf"),t;if(e.metaModelSrc||e.metaModelJSON){const s=s=>{this.viewer.metaScene.createMetaModel(i,s,{}),this.viewer.scene.canvas.spinner.processes--,e.src?this._sceneModelLoader.load(this,e.src,s,e,t):this._sceneModelLoader.parse(this,e.gltf,s,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--,s(e)}),(e=>{this.error(`load(): Failed to load model metadata for model '${i} from '${t}' - ${e}`),this.viewer.scene.canvas.spinner.processes--}))}else e.metaModelJSON&&s(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(i)})),t}destroy(){super.destroy()}}function Kw(e,t,i={}){const s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",n=i.textColor||"black",A=i.canvasElement||document.body,o=500,a=o+o/3,l=a/24,c=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.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]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.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++)V.normalizeVec3(h[e].dir,h[e].dir),V.normalizeVec3(h[e].up,h[e].up);for(let e=0,t=u.length;e<t;e++)V.normalizeVec3(u[e].dir,u[e].dir),V.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=s,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 f=this._textureCanvas.getContext("2d");let p=!1;function g(){for(let e=0,t=c.length;e<t;e++){const t=c[e],i=t.boundary,s=Math.round(i[0]*l),r=Math.round(i[1]*l),n=Math.round(i[2]*l),A=Math.round(i[3]*l);f.fillStyle=t.color,f.fillRect(s,r,n,A)}for(let t=0,a=d.length;t<a;t++){let a,c,h,u;const p=d[t],g=p.boundaries;for(var e=0,i=g.length;e<i;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),p.highlighted&&(f.fillStyle=p.highlighted?r:p.color||s,f.fillRect(a,c,h,u))}if(p.label){f.fillStyle=n,f.font="60px sans-serif",f.textAlign="center";var A=a+.5*h,o=c+.7*u;f.fillText(m(p.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"},i={"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":"FRONT","NavCube.back":"BACK","NavCube.right":"RIGHT","NavCube.left":"LEFT","NavCube.top":"TOP","NavCube.bottom":"BOTTOM"};return function(r){const n=p?i:t,A=n?n[r]:null;return A?e.localeService.translate(A)||s[A]||A:r}}();this.setZUp=function(){p=!0,d=h,this.clear()},this.setYUp=function(){p=!1,d=u,this.clear()},this.clear=function(){f.fillStyle=s,f.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,i=o-e[1]*o;for(var s=0,r=d.length;s<r;s++){const e=d[s].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&&i>=r[1]*l&&i<=(r[1]+r[3])*l)return s}}return-1},this.setAreaHighlighted=function(e,t){var i=d[e];if(!i)throw"Area not found: "+e;i.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 Zw=V.vec3(),Jw=V.vec3();V.mat4();class Yw extends qA{constructor(e,t={}){super("NavCube",e,t),e.navCube=this;try{this._navCubeScene=new qo(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 i=this._navCubeScene;i.clearLights(),new wA(i,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new wA(i,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new wA(i,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._navCubeCamera=i.camera,this._navCubeCamera.ortho.scale=7,this._navCubeCamera.ortho.near=.1,this._navCubeCamera.ortho.far=2e3,i.edgeMaterial.edgeColor=[.2,.2,.2],i.edgeMaterial.edgeAlpha=.6,this._zUp=Boolean(e.camera.zUp);var s=this;this.setIsProjectNorth(t.isProjectNorth),this.setProjectNorthOffsetAngle(t.projectNorthOffsetAngle);const r=function(){const e=V.mat4();return function(t,i,r){return V.identityMat4(e),V.rotationMat4v(t*s._projectNorthOffsetAngle*V.DEGTORAD,[0,1,0],e),V.transformVec3(e,i,r)}}();this._synchCamera=function(){var t=V.rotationMat4c(-90*V.DEGTORAD,1,0,0),i=V.vec3(),n=V.vec3(),A=V.vec3();return function(){var o=e.camera.eye,a=e.camera.look,l=e.camera.up;i=V.mulVec3Scalar(V.normalizeVec3(V.subVec3(o,a,i)),5),s._isProjectNorth&&s._projectNorthOffsetAngle&&(i=r(-1,i,Zw),l=r(-1,l,Jw)),s._zUp?(V.transformVec3(t,i,n),V.transformVec3(t,l,A),s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=V.transformVec3(t,i,n),s._navCubeCamera.up=V.transformPoint3(t,l,A)):(s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=i,s._navCubeCamera.up=l)}}(),this._cubeTextureCanvas=new Kw(e,i,t),this._cubeSampler=new Cs(i,{image:this._cubeTextureCanvas.getImage(),flipY:!0,wrapS:1001,wrapT:1001}),this._cubeMesh=new as(i,{geometry:new We(i,{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 fs(i,{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 as(i,{geometry:new We(i,tt({center:[0,0,0],radiusTop:.001,radiusBottom:1.4,height:.01,radialSegments:20,heightSegments:1,openEnded:!0})),material:new fs(i,{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,i){var s=(t-a)*-f,r=(i-l)*-f;e.camera.orbitYaw(s),e.camera.orbitPitch(-r),a=t,l=i}function o(e){const{left:t,top:i}=s._navCubeCanvas.getBoundingClientRect();return[e.clientX-t,e.clientY-i]}var a,l,c=null,h=null,u=!1,d=!1,f=.5;s._navCubeCanvas.addEventListener("mouseenter",s._onMouseEnter=function(e){d=!0}),s._navCubeCanvas.addEventListener("mouseleave",s._onMouseLeave=function(e){d=!1}),s._navCubeCanvas.addEventListener("mousedown",s._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}),s=i.pick({canvasPos:t});u=!!s}}),s._navCubeCanvas.addEventListener("mouseup",s._onMouseUp=function(e){if(1===e.which&&(u=!1,null!==c)){var t=o({clientX:e.clientX,clientY:e.clientY}),A=i.pick({canvasPos:t,pickSurface:!0});if(A&&A.uv){var a=s._cubeTextureCanvas.getArea(A.uv);if(a>=0&&(s._navCubeCanvas.style.cursor="pointer",n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),a>=0)){if(s._cubeTextureCanvas.setAreaHighlighted(a,!0),n=a,s._repaint(),e.x<c-3||e.x>c+3||e.y<h-3||e.y>h+3)return;var l=s._cubeTextureCanvas.getAreaDir(a);if(l){var d=s._cubeTextureCanvas.getAreaUp(a);s._isProjectNorth&&s._projectNorthOffsetAngle&&(l=r(1,l,Zw),d=r(1,d,Jw)),p(l,d,(function(){n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),s._navCubeCanvas.style.cursor="pointer",n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),a>=0&&(s._cubeTextureCanvas.setAreaHighlighted(a,!1),n=-1,s._repaint())}))}}}}}),s._navCubeCanvas.addEventListener("mousemove",s._onMouseMove=function(e){if(n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),1!==e.buttons||u){if(u){var t=e.clientX,r=e.clientY;return s._navCubeCanvas.style.cursor="move",void A(t,r)}if(d){var a=o({clientX:e.clientX,clientY:e.clientY}),l=i.pick({canvasPos:a,pickSurface:!0});if(l){if(l.uv){s._navCubeCanvas.style.cursor="pointer";var c=s._cubeTextureCanvas.getArea(l.uv);if(c===n)return;n>=0&&s._cubeTextureCanvas.setAreaHighlighted(n,!1),c>=0&&(s._cubeTextureCanvas.setAreaHighlighted(c,!0),s._repaint(),n=c)}}else s._navCubeCanvas.style.cursor="default",n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1)}}}),s._navCubeCanvas.addEventListener("touchstart",s._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}),s=i.pick({canvasPos:t});u=!!s}},{passive:!1}),s._navCubeCanvas.addEventListener("touchmove",s._onTouchMove=function(e){e.preventDefault();var t=e.touches[0],i=t.clientX,r=t.clientY,n=document.elementFromPoint(i,r);(d=s._navCubeCanvas===n)&&u&&A(i,r)},{passive:!1}),s._navCubeCanvas.addEventListener("touchend",s._onTouchEnd=function(e){u=!1});var p=function(){var t=V.vec3();return function(i,r,n){var A=s._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,o=V.getAABB3Diag(A);V.getAABB3Center(A,t);var a=Math.abs(o/Math.tan(s._cameraFitFOV*V.DEGTORAD));e.cameraControl.pivotPos=t,s._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-a*i[0],t[1]-a*i[1],t[2]-a*i[2]],up:r||[0,1,0],orthoScale:1.1*o,fitFOV:s._cameraFitFOV,duration:s._cameraFlyDuration},n):e.cameraFlight.jumpTo({look:t,eye:[t[0]-a*i[0],t[1]-a*i[1],t[2]-a*i[2]],up:r||[0,1,0],orthoScale:1.1*o,fitFOV:s._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()}}const $w=V.vec3();class qw{load(e,t,i={}){var s=e.scene.canvas.spinner;s.processes++,ev(e,t,(function(t){!function(e,t,i){for(var s=t.basePath,r=Object.keys(t.materialLibraries),n=r.length,A=0,o=n;A<o;A++)iv(e,s,s+r[A],(function(){0==--n&&i()}))}(e,t,(function(){rv(e,t),s.processes--,ie.scheduleTask((function(){e.fire("loaded",!0,!1)}))}))}))}parse(e,t,i,s){if(t){var r=tv(e,t,null);i&&sv(e,i,s),rv(e,r),e.src=null,e.fire("loaded",!0,!1)}else this.warn("load() param expected: objText")}}var ev=function(e,t,i){nv(t,(function(s){var r=tv(e,s,t);i(r)}),(function(t){e.error(t)}))},tv=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(i,s,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!==s.indexOf("\r\n")&&(s=s.replace("\r\n","\n"));for(var a=s.split("\n"),l="",u="",d="",f=[],p="function"==typeof"".trimLeft,g=0,m=a.length;g<m;g++)if(l=a[g],0!==(l=p?l.trimLeft():l.trim()).length&&"#"!==(u=l.charAt(0)))if("v"===u)if(" "===(d=l.charAt(1))&&null!==(f=e.vertex_pattern.exec(l)))o.positions.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));else if("n"===d&&null!==(f=e.normal_pattern.exec(l)))o.normals.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));else{if("t"!==d||null===(f=e.uv_pattern.exec(l)))return void i.error("Unexpected vertex/normal/uv line: '"+l+"'");o.uv.push(parseFloat(f[1]),parseFloat(f[2]))}else if("f"===u)if(null!==(f=e.face_vertex_uv_normal.exec(l)))c(o,f[1],f[4],f[7],f[10],f[2],f[5],f[8],f[11],f[3],f[6],f[9],f[12]);else if(null!==(f=e.face_vertex_uv.exec(l)))c(o,f[1],f[3],f[5],f[7],f[2],f[4],f[6],f[8]);else if(null!==(f=e.face_vertex_normal.exec(l)))c(o,f[1],f[3],f[5],f[7],void 0,void 0,void 0,void 0,f[2],f[4],f[6],f[8]);else{if(null===(f=e.face_vertex.exec(l)))return void i.error("Unexpected face line: '"+l+"'");c(o,f[1],f[2],f[3],f[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!==(f=e.object_pattern.exec(l))){t(o,C=f[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===(f=e.smoothing_pattern.exec(l))){if("\0"===l)continue;return void i.error("Unexpected line: '"+l+"'")}var M=f[1].trim().toLowerCase();o.object.material.smooth="1"===M||"on"===M}return o};function t(e,t,i){if(e.object&&!1===e.object.fromDeclaration)return e.object.id=t,void(e.object.fromDeclaration=!1!==i);e.object={id:t||"",geometry:{positions:[],normals:[],uv:[]},material:{id:"",smooth:!0},fromDeclaration:!1!==i},e.objects.push(e.object)}function i(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function s(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function n(e,t,i,s){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[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function A(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function o(e,t,i,s){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[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function a(e,t,i,s){var r=e.uv,n=e.object.geometry.uv;n.push(r[t+0]),n.push(r[t+1]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[s+0]),n.push(r[s+1])}function l(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,A,l,c,h,u,d,f,p,g,m,_){var b,B=e.positions.length,y=i(t,B),w=i(A,B),v=i(l,B);if(void 0===c?n(e,y,w,v):(n(e,y,w,b=i(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(f,C)),a(e,w,v,b))}if(void 0!==p){var M=e.normals.length;y=s(p,M),w=p===g?y:s(g,M),v=p===m?y:s(m,M),void 0===c?o(e,y,w,v):(o(e,y,w,b=s(_,M)),o(e,w,v,b))}}function h(e,t,s){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,i(t[a],n));for(var h=0,u=s.length;h<u;h++)l(e,r(s[h],o))}}();var iv=function(e,t,i,s){nv(i,(function(i){sv(e,i,t),s()}),(function(t){e.error(t),s()}))},sv=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 f=0;f<h.length;f++)if(0!==(A=h[f].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":i(e,u),u={id:l},d=!0;break;case"ka":u.ambient=s(l);break;case"kd":u.diffuse=s(l);break;case"ks":u.specular=s(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&&i(e,u)};function t(e,t,i,s){var r={},n=i.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=s||"linear",new Cs(e,r).id}function i(e,t){new fs(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function rv(e,t){for(var i=0,s=t.objects.length;i<s;i++){var r=t.objects[i],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 s=$w;Ct(n.positions,n.positions,s);var l,c=new We(e,A),h=r.material.id;h&&""!==h?(l=e.scene.components[h])||e.error("Material not found: "+h):l=new fs(e,{diffuse:[.6,.6,.6],backfaces:!0});var u=new as(e,{id:e.id+"#"+r.id,origin:0!==s[0]||0!==s[1]||0!==s[2]?s:null,isObject:!0,geometry:c,material:l,pickable:!0});e.addChild(u)}}function nv(e,t,i){var s=new XMLHttpRequest;s.open("GET",e,!0),s.addEventListener("load",(function(e){var s=e.target.response;200===this.status?t&&t(s):0===this.status?(console.warn("loadFile: HTTP Status 0 received."),t&&t(s)):i&&i(e)}),!1),s.addEventListener("error",(function(e){i&&i(e)}),!1),s.send(null)}class Av extends qA{constructor(e,t){super("OBJLoader",e,t),this._sceneGraphLoader=new qw}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 Bt(this.viewer.scene,X.apply(e,{isModel:!0}));const i=t.id,s=e.src;if(!s)return this.error("load() param expected: src"),t;if(e.metaModelSrc){const r=e.metaModelSrc;X.loadJSON(r,(r=>{this.viewer.metaScene.createMetaModel(i,r),this._sceneGraphLoader.load(t,s,e)}),(e=>{this.error(`load(): Failed to load model modelMetadata for model '${i} from '${r}' - ${e}`)}))}else this._sceneGraphLoader.load(t,s,e);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}}class ov{constructor(e){const t=e.cameraControl,i=e.scene,s=i.canvas.canvas,r=!1,n=.09,A=.01,o=new Bt(i,{position:[0,0,0],scale:[5,5,5],isObject:!1}),a=V.vec3();this._setPosition=function(){const e=V.vec3(),t=V.vec3();return function(i){a.set(i),vt(i,e,t),o.origin=e,o.position=t}}(),this._setQuaternion=e=>{o.quaternion=e};const l=(e,t)=>new We(o,tt({radiusTop:.001,radiusBottom:e,radialSegments:32,heightSegments:1,height:t,openEnded:!1})),c=(e,t,i)=>new We(o,tt({radiusTop:e,radiusBottom:e,radialSegments:i,heightSegments:1,height:t,openEnded:!1})),h=(e,t,i)=>new We(o,nt({radius:.8,tube:e,radialSegments:64,tubeSegments:i,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 Os(o,{edges:!1,fill:!0,fillColor:e,fillAlpha:t}),f=new fs(o,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),p={},g=(e,t)=>{V.mulVec3Scalar(e,-1,V.vec3());const n=(e=>new fs(o,{diffuse:e,emissive:e,ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}))(e),A=V.quaternionToRotationMat4(t,V.identityMat4());V.mulMat4(V.rotationMat4v(Math.PI,[0,1,0],V.mat4()),A,A);const l=V.scaleMat4v([.6,.6,.6],V.identityMat4()),c=(e,t)=>{const i=V.translateMat4v(e,V.identityMat4()),s=V.identityMat4();return V.mulMat4(i,t,s),V.mulMat4(A,s,s),V.mulMat4(s,l,V.identityMat4())},h=o.addChild(new as(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 as(o,{geometry:u.curveHandle,material:f,matrix:A,pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isUI:!0,isObject:!1}),r),m=o.addChild(new as(o,{geometry:u.arrowHead,material:n,matrix:c([.8,.07,0],V.rotationMat4v(180*V.DEGTORAD,[0,0,1],V.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),_=o.addChild(new as(o,{geometry:u.arrowHead,material:n,matrix:c([.07,.8,0],V.rotationMat4v(90*V.DEGTORAD,[0,0,1],V.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),b=o.addChild(new as(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=V.quaternionToRotationMat4(V.vec3PairToQuaternion([0,1,0],e),V.identityMat4());V.mulMat4(V.rotationMat4v(Math.PI,[0,1,0],V.mat4()),B,B);const y=e=>V.mulMat4(B,V.translateMat4c(0,e,0,V.identityMat4()),V.identityMat4()),w=y(1.1),v=y(.5),C=o.addChild(new as(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 as(o,{geometry:u.arrowHeadHandle,material:f,matrix:w,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),E=o.addChild(new as(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 as(o,{geometry:u.axisHandle,material:f,matrix:v,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),U=o.addChild(new as(o,{geometry:u.arrowHeadBig,material:n,matrix:w,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),x=(e,t)=>V.vec3ApplyQuaternion(o.quaternion,e,t),I=function(){const t=V.vec3(),r=V.vec3(),n=V.vec3();return(A,o)=>{x(e,t);const l=a,c=t;V.canvasPosToWorldRay(s,i.camera.viewMatrix,i.camera.projMatrix,i.camera.projection,A,r,n);const h=V.dotVec3(c,n),u=V.subVec3(r,l,o),d=V.dotVec3(u,c),f=V.dotVec3(u,n),p=1-h*h;if(Math.abs(p)>1e-10){const e=(d-h*f)/p;return V.addVec3(l,V.mulVec3Scalar(c,e,o),o),!0}return!1}}(),T=V.vec3(),P=V.vec3();p[M.id]=p[F.id]={setActivated:e=>U.visible=e,initDragAction:e=>I(e,T)&&V.subVec3(T,a,T)&&(e=>{I(e,P)&&(V.subVec3(P,T,P),this._setPosition(P),this._handlers&&this._handlers.onPosition(P))})},p[g.id]={setActivated:e=>b.visible=e,initDragAction:t=>{const s=function(){const t=i.camera.projectWorldPos(a);x(e,P),V.transformVec3(i.camera.normalMatrix,P,P);const s=Math.sign(P[2]);return e=>{const i=e[0]-t[0],r=e[1]-t[1];return s*Math.atan2(-r,i)}}();let r=s(t);return t=>{const i=s(t);o.rotate(e,180*(i-r)/Math.PI),this._handlers&&this._handlers.onQuaternion(o.quaternion),r=i}}};let S=!1,D=!1,k=!1;const Q=()=>{const e=k&&S;M.visible=F.visible=C.visible=E.visible=!!e,e||(U.visible=!1)},R=()=>{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,R()},set visible(e){k=e,Q(),R()}}};this._displayMeshes={center:o.addChild(new as(o,{geometry:new We(o,rt({radius:.05})),material:new fs(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],V.vec3PairToQuaternion([1,0,0],[0,0,1])),y:g([0,1,0],V.eulerToQuaternion([90,0,0],"XYZ")),z:g([0,0,1],V.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))},s=i.on("tick",(()=>{const s=i.camera,r=Math.abs(V.distVec3(s.eye,a));"perspective"===s.projection?r!==e&&t(.07*r*Math.tan(s.perspective.fov*V.DEGTORAD)):"ortho"===s.projection&&t(s.ortho.scale/10),e=r}));m.push((()=>i.off(s)))}{let e=null,r=null;m.push((()=>{r&&r.cleanup()}));const n=V.vec2(),A=(e,t)=>{t[0]=e.pageX,t[1]=e.pageY,Py(s.ownerDocument.documentElement,s,t)},o=e=>{A(e,n);const t=i.pick({canvasPos:n}),s=t&&t.entity,r=s&&s.id;return r in p&&p[r]},a=(e,i)=>{const s=o(i(e));if(s){r&&r.cleanup();const e=s.initDragAction(n);return e&&(t.pointerEnabled=!1,s.setActivated(!0),r={onChange:t=>{const s=i(t);s&&(A(s,n),e(n))},cleanup:function(){r=null,t.pointerEnabled=!0,s.setActivated(!1)}}),!!e}return!1},l=(e,t)=>{s.addEventListener(e,t),m.push((()=>s.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 i=o(t);i?(i.setActivated(!0),e=()=>i.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 p)delete p[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 av{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new as(t,{id:i.id,geometry:new We(t,$e({xSize:.5,ySize:.5,zSize:.001})),material:new fs(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Ls(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Os(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Os(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=V.vec3([0,0,0]),t=V.vec3(),i=V.vec3([0,0,1]),s=V.vec4(4),r=V.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];V.subVec3(n,this._sectionPlane.pos,e);const o=-V.dotVec3(A,e);V.normalizeVec3(A),V.mulVec3Scalar(A,o,t);const a=V.vec3PairToQuaternion(i,this._sectionPlane.dir,s);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 lv{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 qo(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new wA(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new wA(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new wA(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=V.rotationMat4c(-90*V.DEGTORAD,1,0,0),i=V.vec3(),s=V.vec3(),r=V.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;V.mulVec3Scalar(V.normalizeVec3(V.subVec3(n,A,i)),7),this._zUp?(V.transformVec3(t,i,s),V.transformVec3(t,o,r),e.look=[0,0,0],e.eye=V.transformVec3(t,i,s),e.up=V.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=i,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 i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new av(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.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 cv=V.AABB3(),hv=V.vec3();class uv extends qA{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 lv(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;cv.set(this.viewer.scene.aabb),V.getAABB3Center(cv,hv),cv[0]+=t[0]-hv[0],cv[1]+=t[1]-hv[1],cv[2]+=t[2]-hv[2],cv[3]+=t[0]-hv[0],cv[4]+=t[1]-hv[1],cv[5]+=t[2]-hv[2],this.viewer.cameraFlight.flyTo({aabb:cv,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 ZA(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 Bt(e,{isObject:!1});return t.addChild(new as(t,{geometry:new We(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 fs(t,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new Os(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 as(t,{geometry:new We(t,nt({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new fs(t,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new Os(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=V.vec3(),i=V.vec3();return function(s){vt(s,e,i),t.origin=e,t.position=i}}(),setQuaternion:e=>{t.quaternion=e},setScale:e=>{t.scale=e},setVisible:e=>{t.visible=e},destroy:()=>{t.destroy()}}}();let i=()=>{};const s=new ov(this.viewer);let r=!1,n=!1,A=null;const o=()=>{const e=n&&!r;t.setVisible(e),s.setHandlers(e&&A)};return{_destroy:()=>{i(),s.destroy(),t.destroy()},setCulled:e=>{r=e,o()},setVisible:e=>{n=e,o()},_setSectionPlane:e=>{if(i(),e){let r=!1;A={onPosition:i=>{t.setPosition(i),e.pos=i},onQuaternion:i=>{t.setQuaternion(i),r=!0,e.quaternion=i},onScreenScale:e=>{t.setScale(e)}};const n=()=>{t.setPosition(e.pos),s.setPosition(e.pos)},o=()=>{t.setQuaternion(e.quaternion),s.setQuaternion(e.quaternion)};n(),o();const a=e.on("pos",n),l=e.on("dir",(()=>{r?r=!1:o()}));i=()=>{e.off(a),e.off(l),i=()=>{}}}}}})();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,i=e.length;t<i;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)}}class dv{constructor(e,t,i,s,r,n){this.plugin=e,this.storeyId=r,this.modelId=s,this.storeyAABB=i.slice(),this.aabb=this.storeyAABB,this.modelAABB=t.slice(),this.numObjects=n}}class fv{constructor(e,t,i,s,r,n){this.storeyId=e,this.imageData=t,this.format=i,this.width=s,this.height=r}}const pv=V.vec3(),gv=V.mat4();class mv extends qA{constructor(e,t={}){super("StoreyViews",e),this._objectsMemento=new OA,this._cameraMemento=new DA,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,i=t.scene,s=t.metaScene,r=s.metaModels[e],n=i.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=s.metaObjects[A].getObjectIDsInSubtree(),a=i.getAABB(o),l=Math.random()>.5?o.length:0,c=new dv(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,i=this.viewer.camera.worldUp,s=i[0]>i[1]&&i[0]>i[2],r=!s&&i[1]>i[0]&&i[1]>i[2];let n;!s&&!r&&i[2]>i[0]&&(i[2],i[1]),n=s?0:r?1:2;for(let i=0,s=e.length;i<s;i++){const s=t.metaObjects[e[i].storeyId].attributes.elevation;if(isNaN(s))return;const r=e[i].storeyAABB;if(r[n]=Math.max(r[1],parseFloat(s)),i>0){const s=t.metaObjects[e[i-1].storeyId].attributes.elevation;r[4]=Math.min(r[n+3],parseFloat(s))}this.storeys[e[i].storeyId].storeyAABB=r}}_deregisterModelStoreys(e){const t=this.modelStoreys[e];if(t){const i=this.viewer.scene;for(let e in t)if(t.hasOwnProperty(e)){const s=t[e],r=i.models[s.modelId];r&&r.off(s._onModelDestroyed),delete this.storeys[e],this._storeysList=null}delete this.modelStoreys[e]}}get fitStoreyMaps(){return this._fitStoreyMaps}gotoStoreyCamera(e,t={}){const i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());const s=this.viewer,r=s.scene.camera,n=i.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=V.getAABB3Center(n),o=V.getAABB3Diag(n),a=Math.abs(o/Math.tan(45*V.DEGTORAD)),l=1.3*o,c=pv;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?s.cameraFlight.flyTo(X.apply(t,{eye:c,look:A,up:h,orthoScale:l}),(()=>{t.done()})):(s.cameraFlight.jumpTo(X.apply(t,{eye:c,look:A,up:h,orthoScale:l})),s.camera.ortho.scale=l)}showStoreyObjects(e,t={}){if(!this.storeys[e])return void this.error("IfcBuildingStorey not found with this ID: "+e);const i=this.viewer,s=i.scene;i.metaScene.metaObjects[e]&&(t.hideOthers&&s.setObjectsVisible(i.scene.visibleObjectIds,!1),this.withStoreyObjects(e,((e,t)=>{e&&(e.visible=!0)})))}withStoreyObjects(e,t){const i=this.viewer,s=i.scene,r=i.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],i=r.metaObjects[e],n=s.objects[e];n&&t(n,i)}}createStoreyMap(e,t={}){const i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";const s=this.viewer,r=s.scene,n=t.format||"png",A=this._fitStoreyMaps?i.storeyAABB:i.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,X.apply(t,{hideOthers:!0})),l&&this._toggleSectionPlanes(!1),this._arrangeStoreyMapCamera(i);const d=s.getSnapshot({width:c,height:h,format:n});return this._objectsMemento.restoreObjects(r,u),this._cameraMemento.restoreCamera(r),l&&this._toggleSectionPlanes(!0),new fv(e,d,n,c,h,a)}_toggleSectionPlanes(e){const t=this.viewer.scene.sectionPlanes;for(const i in t)t[i].active=e}_arrangeStoreyMapCamera(e){const t=this.viewer,i=t.scene.camera,s=this._fitStoreyMaps?e.storeyAABB:e.modelAABB,r=V.getAABB3Center(s),n=pv;n[0]=r[0]+.5*i.worldUp[0],n[1]=r[1]+.5*i.worldUp[1],n[2]=r[2]+.5*i.worldUp[2];const A=i.worldForward;t.cameraFlight.jumpTo({eye:n,look:r,up:A});const o=(s[3]-s[0])/2,a=(s[4]-s[1])/2,l=(s[5]-s[2])/2,c=-o,h=+o,u=-a,d=+a,f=-l,p=+l;t.camera.customProjection.matrix=V.orthoMat4c(c,h,f,p,u,d,gv),t.camera.projection="customProjection"}pickStoreyMap(e,t,i={}){const s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),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,f=V.vec3([a+h*n,l+.5*u,c+d*A]),p=V.vec3([0,-1,0]),g=V.addVec3(f,p,pv),m=this.viewer.camera.worldForward,_=V.lookAtMat4v(f,g,m,gv);return this.viewer.scene.pick({pickSurface:i.pickSurface,pickInvisible:!0,matrix:_})}storeyMapToWorldPos(e,t,i={}){const s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),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 V.vec3([a+h*n,l+.5*u,c+d*A])}getStoreyContainingWorldPos(e,t=null){const i=t?this._filterStoreys(t):this.storeys;for(let t in i){const s=i[t];if(V.point3AABB3AbsoluteIntersect(s.storeyAABB,e))return t}return null}getStoreyInVerticalRange(e,t=null){const i=t?this._filterStoreys(t):this.storeys;for(let t in i){const s=i[t],r=[0,0,0,0,0,0],n=[0,0,0];if(r[1]=s.storeyAABB[1],r[4]=s.storeyAABB[4],n[1]=e[1],V.point3AABB3AbsoluteIntersect(r,n))return t}return null}isPositionAboveOrBelowBuilding(e,t=null){const i=t?this._filterStoreys(t):this.storeys,s=Object.keys(i);if(s.length<=0)return null;const r=[s[0],s[s.length-1]];return e[1]<i[r[0]].storeyAABB[1]?r[0]:e[1]>i[r[1]].storeyAABB[4]?r[1]:null}worldPosToStoreyMap(e,t,i){const s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),!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],f=!d&&u[1]>u[0]&&u[1]>u[2];!d&&!f&&u[2]>u[0]&&(u[2],u[1]);const p=e.width/l,g=f?e.height/h:e.height/c;return i[0]=Math.floor(e.width-(t[0]-A)*p),i[1]=Math.floor(e.height-(t[2]-a)*g),i[0]>=0&&i[0]<e.width&&i[1]>=0&&i[1]<=e.height}worldDirToStoreyMap(e,t,i){const s=this.viewer.camera,r=s.eye,n=s.look,A=V.subVec3(n,r,pv),o=s.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?(i[0]=A[1],i[1]=A[2]):l?(i[0]=A[0],i[1]=A[2]):(i[0]=A[0],i[1]=A[1]),V.normalizeVec2(i)}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,i)=>{let s=0;s=e.xUp?0:e.yUp?1:2;const r=this.viewer.metaScene,n=r.metaObjects[t.storeyId],A=r.metaObjects[i.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[s]>i.aabb[s]?-1:t.aabb[s]<i.aabb[s]?1:0})}_filterStoreys(e){return Object.fromEntries(Object.entries(this.storeys).filter((([t,i])=>i.modelId===e)))}}const _v=new Float64Array([0,0,1]),bv=new Float64Array(4);class Bv{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=V.vec3(),this._origin=V.vec3(),this._rtcPos=V.vec3(),this._baseDir=V.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),vt(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=V.vec3PairToQuaternion(_v,e,bv)}_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,i=.01;this._rootNode=new Bt(t,{position:[0,0,0],scale:[5,5,5]});const s=this._rootNode,r={arrowHead:new We(s,tt({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new We(s,tt({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new We(s,tt({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},n={red:new fs(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new fs(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new fs(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Os(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new as(s,{geometry:new We(s,{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 fs(s,{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:s.addChild(new as(s,{geometry:new We(s,nt({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new fs(s,{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:s.addChild(new as(s,{geometry:new We(s,rt({radius:.05})),material:n.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new as(s,{geometry:r.arrowHead,material:n.blue,matrix:function(){const e=V.translateMat4c(0,1.1,0,V.identityMat4()),t=V.rotationMat4v(-90*V.DEGTORAD,[.8,0,0],V.identityMat4());return V.mulMat4(t,e,V.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new as(s,{geometry:r.axis,material:n.blue,matrix:function(){const e=V.translateMat4c(0,.5,0,V.identityMat4()),t=V.rotationMat4v(-90*V.DEGTORAD,[1,0,0],V.identityMat4());return V.mulMat4(t,e,V.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new as(s,{geometry:new We(s,nt({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new fs(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Os(s,{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:s.addChild(new as(s,{geometry:r.arrowHeadBig,material:n.blue,matrix:function(){const e=V.translateMat4c(0,1.1,0,V.identityMat4()),t=V.rotationMat4v(-90*V.DEGTORAD,[.8,0,0],V.identityMat4());return V.mulMat4(t,e,V.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=V.vec2(),i=this._viewer.camera,s=this._viewer.scene;let r=0,n=!1;{const t=V.vec3([0,0,0]);let A=-1;this._onCameraViewMatrix=s.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=s.camera.on("projMatrix",(()=>{})),this._onSceneTick=s.on("tick",(()=>{n=!1;const a=Math.abs(V.lenVec3(V.subVec3(s.camera.eye,this._pos,t)));if(a!==A&&"perspective"===i.projection){const t=.07*(Math.tan(i.perspective.fov*V.DEGTORAD)*a);e.scale=[t,t,t],A=a}if("ortho"===i.projection){const t=i.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 i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,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,i=this._sectionPlane.dir;V.addVec3(t,V.mulVec3Scalar(i,.1*e*this._plugin.getDragSensitivity(),V.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=i=>{if(i.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===i.which)){e=!0;var s=A(i);t[0]=s[0],t[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=i=>{if(!this._visible)return;if(!e)return;if(n)return;var s=A(i);const r=s[0],a=s[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,i=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,i=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!==i&&(r+=t-i),i=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=i=>{i.stopPropagation(),i.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class yv{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new as(t,{id:i.id,geometry:new We(t,$e({xSize:.5,ySize:.5,zSize:.001})),material:new fs(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Ls(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Os(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Os(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=V.vec3([0,0,0]),t=V.vec3(),i=V.vec3([0,0,1]),s=V.vec4(4),r=V.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];V.subVec3(n,this._sectionPlane.pos,e);const o=-V.dotVec3(A,e);V.normalizeVec3(A),V.mulVec3Scalar(A,o,t);const a=V.vec3PairToQuaternion(i,this._sectionPlane.dir,s);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 wv{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 qo(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new wA(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new wA(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new wA(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=V.rotationMat4c(-90*V.DEGTORAD,1,0,0),i=V.vec3(),s=V.vec3(),r=V.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;V.mulVec3Scalar(V.normalizeVec3(V.subVec3(n,A,i)),7),this._zUp?(V.transformVec3(t,i,s),V.transformVec3(t,o,r),e.look=[0,0,0],e.eye=V.transformVec3(t,i,s),e.up=V.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=i,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 i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new yv(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.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 vv=V.AABB3(),Cv=V.vec3();class Mv extends qA{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 wv(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;vv.set(this.viewer.scene.aabb),V.getAABB3Center(vv,Cv),vv[0]+=t[0]-Cv[0],vv[1]+=t[1]-Cv[1],vv[2]+=t[2]-Cv[2],vv[3]+=t[0]-Cv[0],vv[4]+=t[1]-Cv[1],vv[5]+=t[2]-Cv[2],this.viewer.cameraFlight.flyTo({aabb:vv,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 ZA(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 Bv(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,i=e.length;t<i;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)}}class Ev{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,i){e=this._cacheBusterURL(e);const s=new XMLHttpRequest;s.overrideMimeType("application/json"),s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i(s.statusText))},s.send(null)}}const Fv=V.vec3();class Uv{load(e,t,i,s,r,n){s=s||{};const A=e.viewer.scene.canvas.spinner;A.processes++,e.dataSource.getSTL(i,(function(i){!function(e,t,i,s){try{const r=Dv(i);xv(r)?Iv(e,r,t,s):Tv(e,Sv(i),t,s)}catch(e){t.fire("error",e)}}(e,t,i,s);try{const n=Dv(i);xv(n)?Iv(e,n,t,s):Tv(e,Sv(i),t,s),A.processes--,ie.scheduleTask((function(){t.fire("loaded",!0,!1)})),r&&r()}catch(i){A.processes--,e.error(i),n&&n(i),t.fire("error",i)}}),(function(i){A.processes--,e.error(i),n&&n(i),t.fire("error",i)}))}parse(e,t,i,s){const r=e.viewer.scene.canvas.spinner;r.processes++;try{const n=Dv(i);xv(n)?Iv(e,n,t,s):Tv(e,Sv(i),t,s),r.processes--,ie.scheduleTask((function(){t.fire("loaded",!0,!1)}))}catch(e){r.processes--,t.fire("error",e)}}}function xv(e){const t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;const i=[115,111,108,105,100];for(var s=0;s<5;s++)if(i[s]!==t.getUint8(s,!1))return!0;return!1}function Iv(e,t,i,s){const r=new DataView(t),n=r.getUint32(80,!0);let A,o,a,l,c,h,u,d=!1,f=null,p=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 Ss(i,{roughness:.5});let b=[],B=[],y=s.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!==f||o!==p||a!==g)&&(null!==f&&(m=!0),f=A,p=o,g=a)}for(let e=1;e<=3;e++){let i=t+12*e;b.push(r.getFloat32(i,!0)),b.push(r.getFloat32(i+4,!0)),b.push(r.getFloat32(i+8,!0)),B.push(n,w,v),d&&l.push(A,o,a,1)}y&&m&&(Pv(i,b,B,l,_,s),b=[],B=[],l=l?[]:null,m=!1)}b.length>0&&Pv(i,b,B,l,_,s)}function Tv(e,t,i,s){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,f,p,g,m;for(;null!==(f=r.exec(t));){for(p=0,g=0,m=f[0];null!==(f=a.exec(m));)h=parseFloat(f[1]),u=parseFloat(f[2]),d=parseFloat(f[3]),g++;for(;null!==(f=o.exec(m));)l.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),c.push(h,u,d),p++;1!==g&&e.error("Error in normal of face "+n),3!==p&&e.error("Error in positions of face "+n),n++}Pv(i,l,c,null,new Ss(i,{roughness:.5}),s)}function Pv(e,t,i,s,r,n){const A=new Int32Array(t.length/3);for(let e=0,t=A.length;e<t;e++)A[e]=e;i=i&&i.length>0?i:null,s=s&&s.length>0?s:null,n.smoothNormals&&V.faceToVertexNormals(t,i,n);const o=Fv;Ct(t,t,o);const a=new We(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:A}),l=new as(e,{origin:0!==o[0]||0!==o[1]||0!==o[2]?o:null,geometry:a,material:r,edges:n.edges});e.addChild(l)}function Sv(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,s=e.length;i<s;i++)t+=String.fromCharCode(e[i]);return decodeURIComponent(escape(t))}(new Uint8Array(e)):e}function Dv(e){if("string"==typeof e){const t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=255&e.charCodeAt(i);return t.buffer||t}return e}class kv extends qA{constructor(e,t={}){super("STLLoader",e,t),this._sceneGraphLoader=new Uv,this.dataSource=t.dataSource}set dataSource(e){this._dataSource=e||new Ev}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 Bt(this.viewer.scene,X.apply(e,{isModel:!0})),i=e.src,s=e.stl;return i||s?(i?this._sceneGraphLoader.load(this,t,i,e):this._sceneGraphLoader.parse(this,t,s,e),t):(this.error("load() param expected: either 'src' or 'stl'"),t)}}class Qv{constructor(e){this._treeViewContainer=e}createRootNode(){return document.createElement("ul")}createNodeElement(e,t,i,s,r){const n=document.createElement("li");if(n.id=e.nodeId,e.xrayed&&n.classList.add("xrayed-node"),e.children.length>0){const i=document.createElement("a");i.href="#",i.id=`switch-${e.nodeId}`,i.textContent="+",i.classList.add("plus"),t&&i.addEventListener("click",t),n.appendChild(i)}const A=document.createElement("input");A.id=`checkbox-${e.nodeId}`,A.type="checkbox",A.checked=e.checked,A.style["pointer-events"]="all",i&&A.addEventListener("change",i),n.appendChild(A);const o=document.createElement("span");return o.textContent=e.title,n.appendChild(o),s&&fy(o,s),r&&(o.onclick=r),n}createDisabledNodeElement(e){const t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);const s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}addChildren(e,t){const i=document.createElement("ul");t.forEach((e=>{i.appendChild(e)})),e.parentElement.appendChild(i)}expand(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}collapse(e,t,i){if(!e)return;const s=e.parentElement;if(!s)return;const r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),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,i=!1){const s=this._treeViewContainer.querySelector(`[id="checkbox-${e}"]`);s&&(t!==s.checked&&(s.checked=t),i!==s.indeterminate&&(s.indeterminate=i,i&&(s.checked=!1)))}setXRayed(e,t){const i=this._treeViewContainer.querySelector(`[id="${e}"]`);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}setHighlighted(e,t){const i=this._treeViewContainer.querySelector(`[id="${e}"]`);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}const Rv=[];class Ov extends qA{constructor(e,t={}){super("TreeViewPlugin",e),this.errors=[],this.valid=!0;const i=t.containerElement||document.getElementById(t.containerElementId);if(i instanceof HTMLElement){for(let e=0;;e++)if(!Rv[e]){Rv[e]=this,this._index=e,this._id=`tree-${e}`;break}if(this._containerElement=i,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 Qv(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,i=this._objectNodes[t];if(!i)return;const s=e.visible;if(!(s!==i.checked))return;this._muteTreeEvents=!0,i.checked=s,s?i.numVisibleEntities++:i.numVisibleEntities--,this._renderService.setCheckbox(i.nodeId,s);let r=i.parent;for(;r;){r.checked=s,s?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,i=this._objectNodes[t];if(!i)return;this._muteTreeEvents=!0;const s=e.xrayed;s!==i.xrayed&&(i.xrayed=s,this._renderService.setXRayed(i.nodeId,s),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,i=this._renderService.isChecked(t),s=this._renderService.getIdFromCheckbox(t),r=this._nodeNodes[s],n=this._viewer.scene.objects;let A=0;this._withNodeTree(r,(e=>{const t=e.objectId,s=n[t],r=0===e.children.length;e.numVisibleEntities=i?e.numEntities:0,r&&i!==e.checked&&A++,e.checked=i,this._renderService.setCheckbox(e.nodeId,i),s&&(s.visible=i)}));let o=r.parent;for(;o;){i?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,i=e.length;t<i;t++){const i=e[t];this.viewer.metaScene.metaModels[i].finalized&&this.addModel(i)}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 i=this.viewer.scene.models[e];if(!i)throw"Model not found: "+e;const s=this.viewer.metaScene.metaModels[e];s?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=s,t&&t.rootName&&(this._rootNames[e]=t.rootName),i.on("destroyed",(()=>{this.removeModel(i.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 i=t.nodeId,s=this._renderService.getSwitchElement(i);if(s)return this._expandSwitchElement(s),s.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(i,!0),this._showListItemElementId=i}unShowNode(){this._showListItemElementId&&(this._renderService.setHighlighted(this._showListItemElementId,!1),this._showListItemElementId=null)}expandToDepth(e){this.collapse();const t=(i,s)=>{if(s===e)return;const r=this._renderService.getSwitchElement(i.nodeId);if(r){this._expandSwitchElement(r);const e=i.children;for(var n=0,A=e.length;n<A;n++){const i=e[n];t(i,s+1)}}};for(let e=0,i=this._rootNodes.length;e<i;e++){const i=this._rootNodes[e];t(i,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 i=e.children;if(i)for(let e=0,s=i.length;e<s;e++)this.withNodeTree(i[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 Rv[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,i){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 i in t){const s=t[i],r=s.type,n=s.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 i=this.viewer.scene,s=e.children,r=e.id,n=i.objects[r];if(e._countEntities=0,n&&e._countEntities++,s)for(let t=0,i=s.length;t<i;t++){const i=s[t];i._countEntities=this._findEmptyNodes2(i),e._countEntities+=i._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,i,s,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)i={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(i):this._rootNodes.push(i),this._objectNodes[i.objectId]=i,this._nodeNodes[i.nodeId]=i;else if("IfcBuildingStorey"===n){if(!i)return void this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");s={nodeId:`${this._id}-${a}`,objectId:a,title:A&&""!==A&&"Undefined"!==A&&"Default"!==A?A:n,type:n,parent:i,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},i.children.push(s),this._objectNodes[s.objectId]=s,this._nodeNodes[s.nodeId]=s,r={}}else if(s){if(this._viewer.scene.objects[a]){let e=(r=r||{})[n];e||(e={nodeId:`${this._id}-${s.objectId}-${n}`,objectId:`${s.objectId}-${n}`,title:n,type:n,parent:s,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},s.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,i,s,r)}}_createTypesNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._createTypesNodes2(e[t],null,null)}_createTypesNodes2(e,t,i){if(this._pruneEmptyNodes&&0===e._countEntities)return;const s=e.type,r=e.name,n=e.children,A=e.id;if(e.parent){if(t){if(this._viewer.scene.objects[A]){let e=i[s];e||(e={nodeId:`${this._id}-${t.objectId}-${s}`,objectId:`${t.objectId}-${s}`,title:s,type:s,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,i[s]=e);const n={nodeId:`${this._id}-${A}`,objectId:A,title:r&&""!==r&&"Default"!==r?r:s,type:s,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:s),type:s,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,i={};if(n)for(let e=0,s=n.length;e<s;e++){const s=n[e];this._createTypesNodes2(s,t,i)}}_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 i=e.type,s=e.name||i,r=e.children,n=e.id,A={nodeId:`${this._id}-${n}`,objectId:n,title:t?s&&""!==s&&"Undefined"!==s&&"Default"!==s?s:i:0===e.metaModels.length?s:this._rootNames[e.metaModels[0].id]||s,type:i,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 i=t[0];"storeys"!==this._hierarchy&&"containment"!==this._hierarchy||"IfcBuildingStorey"!==i.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,i=t.length;e<i;e++){const i=t[e];this._sortChildren(i)}}_getSpatialSortFunc(){const e=this.viewer.scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=(t,i)=>{e.xUp||e.yUp;const s=this.viewer.metaScene,r=s.metaObjects[t.objectId],n=s.metaObjects[i.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 i=e.title.toUpperCase(),s=t.title.toUpperCase();return i<s?-1:i>s?1:0}_synchNodesToEntities(){const e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,i=this._viewer.scene.objects;for(let s=0,r=e.length;s<r;s++){const r=e[s];if(t[r]){const e=this._objectNodes[r];if(e){const t=i[r];if(t){const i=t.visible;e.numEntities=1,e.xrayed=t.xrayed,i?(e.numVisibleEntities=1,e.checked=!0):(e.numVisibleEntities=0,e.checked=!1);let s=e.parent;for(;s;)s.numEntities++,i&&(s.numVisibleEntities++,s.checked=!0),s=s.parent}}}}}_withNodeTree(e,t){t(e);const i=e.children;if(i)for(let e=0,s=i.length;e<s;e++)this._withNodeTree(i[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),i=this._nodeNodes[t].children.map((e=>this._createNodeElement(e)));this._renderService.addChildren(e,i),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)}}class Vv{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 i=e.models[t];i&&this._addModel(i)})),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 i=e[t];this._objects[this._numObjects++]=i}this._lenObjectsChangedList=0,this._dirty=!1}_applyChanges(){if(this._lenObjectsChangedList>0){for(let e=0;e<this._lenObjectsChangedList;e++){const t=this._objectsChangedList[e],i=this._objects[t],s=this._objectsViewCulled[t],r=this._objectsDetailCulled[t],n=s||r;i.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 Lv={};const Hv=new Float32Array(3);class Nv extends qA{constructor(e,t={}){super("ViewCull",e),this._objectCullStates=function(e){const t=e.id;let i=Lv[t];return i||(i=new Vv(e),Lv[t]=i,e.on("destroyed",(()=>{delete Lv[t],i._destroy()}))),i}(e.scene),this._maxTreeDepth=t.maxTreeDepth||8,this._modelInfos={},this._frustum=new he,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;ue(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}_buildKDTree(){const e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:he.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,i,s){const r=t.aabb;if(s>=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(i),void V.expandAABB3(e.aabb,r);if(e.left&&V.containsAABB3(e.left.aabb,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1);if(e.right&&V.containsAABB3(e.right.aabb,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1);const n=e.aabb;Hv[0]=n[3]-n[0],Hv[1]=n[4]-n[1],Hv[2]=n[5]-n[2];let A=0;if(Hv[1]>Hv[A]&&(A=1),Hv[2]>Hv[A]&&(A=2),!e.left){const o=n.slice();if(o[A+3]=(n[A]+n[A+3])/2,e.left={aabb:o,intersection:he.INTERSECT},V.containsAABB3(o,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1)}if(!e.right){const o=n.slice();if(o[A]=(n[A]+n[A+3])/2,e.right={aabb:o,intersection:he.INTERSECT},V.containsAABB3(o,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1)}e.objects=e.objects||[],e.objects.push(i),V.expandAABB3(e.aabb,r)}_visitKDNode(e,t=he.INTERSECT){if(t!==he.INTERSECT&&e.intersects===t)return;t===he.INTERSECT&&(t=de(this._frustum,e.aabb),e.intersects=t);const i=t===he.OUTSIDE,s=e.objects;if(s&&s.length>0)for(let e=0,t=s.length;e<t;e++){const t=s[e];this._objectCullStates.setObjectViewCulled(t,i)}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}}class Gv{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,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getMetaModel(e,t,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getXKT(e,t,i){var s=()=>{};t=t||s,i=i||s;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),i=new Uint8Array(e);for(var A=0;A<n.length;A++)i[A]=n.charCodeAt(A);t(e)}catch(e){i(e)}}else{const s=new XMLHttpRequest;s.open("GET",this._cacheBusterURL(e),!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i("getXKT error : "+s.response))},s.send(null)}}}
|
|
42
|
+
***************************************************************************** */var _f=function(e,t){return _f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},_f(e,t)};function bf(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}_f(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var Bf=function(){return Bf=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Bf.apply(this,arguments)};function yf(e,t,i,s){return new(i||(i=Promise))((function(r,n){function A(e){try{a(s.next(e))}catch(e){n(e)}}function o(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(A,o)}a((s=s.apply(e,t||[])).next())}))}function wf(e,t){var i,s,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(i)throw new TypeError("Generator is already executing.");for(;A;)try{if(i=1,s&&(r=2&n[0]?s.return:n[0]?s.throw||((r=s.return)&&r.call(s),0):s.next)&&!(r=r.call(s,n[1])).done)return r;switch(s=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++,s=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],s=0}finally{i=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}}function vf(e,t,i){if(i||2===arguments.length)for(var s,r=0,n=t.length;r<n;r++)!s&&r in t||(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||t)}for(var Cf=function(){function e(e,t,i,s){this.left=e,this.top=t,this.width=i,this.height=s}return e.prototype.add=function(t,i,s,r){return new e(this.left+t,this.top+i,this.width+s,this.height+r)},e.fromClientRect=function(t,i){return new e(i.left+t.windowBounds.left,i.top+t.windowBounds.top,i.width,i.height)},e.fromDOMRectList=function(t,i){var s=Array.from(i).find((function(e){return 0!==e.width}));return s?new e(s.left+t.windowBounds.left,s.top+t.windowBounds.top,s.width,s.height):e.EMPTY},e.EMPTY=new e(0,0,0,0),e}(),Mf=function(e,t){return Cf.fromClientRect(e,t.getBoundingClientRect())},Ef=function(e){for(var t=[],i=0,s=e.length;i<s;){var r=e.charCodeAt(i++);if(r>=55296&&r<=56319&&i<s){var n=e.charCodeAt(i++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),i--)}else t.push(r)}return t},Ff=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var i=e.length;if(!i)return"";for(var s=[],r=-1,n="";++r<i;){var A=e[r];A<=65535?s.push(A):(A-=65536,s.push(55296+(A>>10),A%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},Uf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),If=0;If<Uf.length;If++)xf[Uf.charCodeAt(If)]=If;for(var Tf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Sf=0;Sf<Tf.length;Sf++)Pf[Tf.charCodeAt(Sf)]=Sf;for(var Df=function(e,t,i){return e.slice?e.slice(t,i):new Uint16Array(Array.prototype.slice.call(e,t,i))},kf=function(){function e(e,t,i,s,r,n){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=s,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}(),Qf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Of=0;Of<Qf.length;Of++)Rf[Qf.charCodeAt(Of)]=Of;var Vf=10,Lf=13,Hf=15,Nf=17,Gf=18,jf=19,Wf=20,zf=21,Xf=22,Kf=24,Zf=25,Jf=26,Yf=27,$f=28,qf=30,ep=32,tp=33,ip=34,sp=35,rp=37,np=38,Ap=39,op=40,ap=42,lp=[9001,65288],cp=function(e,t){var i,s,r,n=function(e){var t,i,s,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)i=Pf[e.charCodeAt(t)],s=Pf[e.charCodeAt(t+1)],r=Pf[e.charCodeAt(t+2)],n=Pf[e.charCodeAt(t+3)],c[a++]=i<<2|s>>4,c[a++]=(15&s)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=4)i.push(e[s+3]<<24|e[s+2]<<16|e[s+1]<<8|e[s]);return i}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=2)i.push(e[s+1]<<8|e[s]);return i}(n):new Uint16Array(n),a=Df(o,12,A[4]/2),l=2===A[5]?Df(o,(24+A[4])/2):(i=A,s=Math.ceil((24+A[4])/4),i.slice?i.slice(s,r):new Uint32Array(Array.prototype.slice.call(i,s,r)));return new kf(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=="),hp=[qf,36],up=[1,2,3,5],dp=[Vf,8],fp=[Yf,Jf],pp=up.concat(dp),gp=[np,Ap,op,ip,sp],mp=[Hf,Lf],_p=function(e,t,i,s){var r=s[i];if(Array.isArray(e)?-1!==e.indexOf(r):e===r)for(var n=i;n<=s.length;){if((a=s[++n])===t)return!0;if(a!==Vf)break}if(r===Vf)for(n=i;n>0;){var A=s[--n];if(Array.isArray(e)?-1!==e.indexOf(A):e===A)for(var o=i;o<=s.length;){var a;if((a=s[++o])===t)return!0;if(a!==Vf)break}if(A!==Vf)break}return!1},bp=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==Vf)return s;i--}return 0},Bp=function(e,t,i,s,r){if(0===i[s])return"×";var n=s-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!==up.indexOf(a))return"!";if(-1!==up.indexOf(c))return"×";if(-1!==dp.indexOf(c))return"×";if(8===bp(n,t))return"÷";if(11===cp.get(e[n]))return"×";if((a===ep||a===tp)&&11===cp.get(e[o]))return"×";if(7===a||7===c)return"×";if(9===a)return"×";if(-1===[Vf,Lf,Hf].indexOf(a)&&9===c)return"×";if(-1!==[Nf,Gf,jf,Kf,$f].indexOf(c))return"×";if(bp(n,t)===Xf)return"×";if(_p(23,Xf,n,t))return"×";if(_p([Nf,Gf],zf,n,t))return"×";if(_p(12,12,n,t))return"×";if(a===Vf)return"÷";if(23===a||23===c)return"×";if(16===c||16===a)return"÷";if(-1!==[Lf,Hf,zf].indexOf(c)||14===a)return"×";if(36===l&&-1!==mp.indexOf(a))return"×";if(a===$f&&36===c)return"×";if(c===Wf)return"×";if(-1!==hp.indexOf(c)&&a===Zf||-1!==hp.indexOf(a)&&c===Zf)return"×";if(a===Yf&&-1!==[rp,ep,tp].indexOf(c)||-1!==[rp,ep,tp].indexOf(a)&&c===Jf)return"×";if(-1!==hp.indexOf(a)&&-1!==fp.indexOf(c)||-1!==fp.indexOf(a)&&-1!==hp.indexOf(c))return"×";if(-1!==[Yf,Jf].indexOf(a)&&(c===Zf||-1!==[Xf,Hf].indexOf(c)&&t[o+1]===Zf)||-1!==[Xf,Hf].indexOf(a)&&c===Zf||a===Zf&&-1!==[Zf,$f,Kf].indexOf(c))return"×";if(-1!==[Zf,$f,Kf,Nf,Gf].indexOf(c))for(var h=n;h>=0;){if((u=t[h])===Zf)return"×";if(-1===[$f,Kf].indexOf(u))break;h--}if(-1!==[Yf,Jf].indexOf(c))for(h=-1!==[Nf,Gf].indexOf(a)?A:n;h>=0;){var u;if((u=t[h])===Zf)return"×";if(-1===[$f,Kf].indexOf(u))break;h--}if(np===a&&-1!==[np,Ap,ip,sp].indexOf(c)||-1!==[Ap,ip].indexOf(a)&&-1!==[Ap,op].indexOf(c)||-1!==[op,sp].indexOf(a)&&c===op)return"×";if(-1!==gp.indexOf(a)&&-1!==[Wf,Jf].indexOf(c)||-1!==gp.indexOf(c)&&a===Yf)return"×";if(-1!==hp.indexOf(a)&&-1!==hp.indexOf(c))return"×";if(a===Kf&&-1!==hp.indexOf(c))return"×";if(-1!==hp.concat(Zf).indexOf(a)&&c===Xf&&-1===lp.indexOf(e[o])||-1!==hp.concat(Zf).indexOf(c)&&a===Gf)return"×";if(41===a&&41===c){for(var d=i[n],f=1;d>0&&41===t[--d];)f++;if(f%2!=0)return"×"}return a===ep&&c===tp?"×":"÷"},yp=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,n){var A=cp.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 s.push(n),i.push(16);if(4===A||11===A){if(0===n)return s.push(n),i.push(qf);var o=i[n-1];return-1===pp.indexOf(o)?(s.push(s[n-1]),i.push(o)):(s.push(n),i.push(qf))}return s.push(n),31===A?i.push("strict"===t?zf:rp):A===ap||29===A?i.push(qf):43===A?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(rp):i.push(qf):void i.push(A)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],n=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[Zf,qf,ap].indexOf(e)?rp:e})));var A="keep-all"===t.wordBreak?n.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,A]},wp=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return Ff.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),vp=function(e){return e>=48&&e<=57},Cp=function(e){return vp(e)||e>=65&&e<=70||e>=97&&e<=102},Mp=function(e){return 10===e||9===e||32===e},Ep=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},Fp=function(e){return Ep(e)||vp(e)||45===e},Up=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},xp=function(e,t){return 92===e&&10!==t},Ip=function(e,t,i){return 45===e?Ep(t)||xp(t,i):!!Ep(e)||!(92!==e||!xp(e,t))},Tp=function(e,t,i){return 43===e||45===e?!!vp(t)||46===t&&vp(i):vp(46===e?t:e)},Pp=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];vp(e[t]);)s.push(e[t++]);var r=s.length?parseInt(Ff.apply(void 0,s),10):0;46===e[t]&&t++;for(var n=[];vp(e[t]);)n.push(e[t++]);var A=n.length,o=A?parseInt(Ff.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=[];vp(e[t]);)l.push(e[t++]);var c=l.length?parseInt(Ff.apply(void 0,l),10):0;return i*(r+o*Math.pow(10,-A))*Math.pow(10,a*c)},Sp={type:2},Dp={type:3},kp={type:4},Qp={type:13},Rp={type:8},Op={type:21},Vp={type:9},Lp={type:10},Hp={type:11},Np={type:12},Gp={type:14},jp={type:23},Wp={type:1},zp={type:25},Xp={type:24},Kp={type:26},Zp={type:27},Jp={type:28},Yp={type:29},$p={type:31},qp={type:32},eg=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(Ef(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==qp;)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),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(Fp(t)||xp(i,s)){var r=Ip(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Qp;break;case 39:return this.consumeStringToken(39);case 40:return Sp;case 41:return Dp;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Gp;break;case 43:if(Tp(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return kp;case 45:var n=e,A=this.peekCodePoint(0),o=this.peekCodePoint(1);if(Tp(n,A,o))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Ip(n,A,o))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===A&&62===o)return this.consumeCodePoint(),this.consumeCodePoint(),Xp;break;case 46:if(Tp(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 Kp;case 59:return Zp;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),zp;break;case 64:var l=this.peekCodePoint(0),c=this.peekCodePoint(1),h=this.peekCodePoint(2);if(Ip(l,c,h))return{type:7,value:this.consumeName()};break;case 91:return Jp;case 92:if(xp(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return Yp;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Rp;break;case 123:return Hp;case 125:return Np;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!Cp(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Vp;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Op;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Lp;break;case-1:return qp}return Mp(e)?(this.consumeWhiteSpace(),$p):vp(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Ep(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:Ff(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();Cp(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(Ff.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(Ff.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(Ff.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&Cp(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Cp(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(Ff.apply(void 0,r),16)}}return{type:30,start:s,end:s}},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 i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),jp)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:Ff.apply(void 0,e)};if(Mp(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:Ff.apply(void 0,e)}):(this.consumeBadUrlRemnants(),jp);if(34===s||39===s||40===s||Up(s))return this.consumeBadUrlRemnants(),jp;if(92===s){if(!xp(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),jp;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;Mp(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;xp(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=Ff.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Wp;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):xp(s,r)&&(t+=this.consumeStringSlice(i),t+=Ff(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());vp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&vp(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;vp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&vp(r)||vp(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;vp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Pp(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),n=this.peekCodePoint(2);return Ip(s,r,n)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Cp(e)){for(var t=Ff(e);Cp(this.peekCodePoint(0))&&t.length<6;)t+=Ff(this.consumeCodePoint());Mp(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(Fp(t))e+=Ff(t);else{if(!xp(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=Ff(this.consumeEscapedCodePoint())}}},e}(),tg=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new eg;return i.write(t),new e(i.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:[]},i=this.consumeToken();;){if(32===i.type||cg(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?qp:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),ig=function(e){return 15===e.type},sg=function(e){return 17===e.type},rg=function(e){return 20===e.type},ng=function(e){return 0===e.type},Ag=function(e,t){return rg(e)&&e.value===t},og=function(e){return 31!==e.type},ag=function(e){return 31!==e.type&&4!==e.type},lg=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},cg=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},hg=function(e){return 17===e.type||15===e.type},ug=function(e){return 16===e.type||hg(e)},dg=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},fg={type:17,number:0,flags:4},pg={type:16,number:50,flags:4},gg={type:16,number:100,flags:4},mg=function(e,t,i){var s=e[0],r=e[1];return[_g(s,t),_g(void 0!==r?r:s,i)]},_g=function(e,t){if(16===e.type)return e.number/100*t;if(ig(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},bg=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")},Bg=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},yg=function(e){switch(e.filter(rg).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[fg,fg];case"to top":case"bottom":return wg(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[fg,gg];case"to right":case"left":return wg(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[gg,gg];case"to bottom":case"top":return wg(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[gg,fg];case"to left":case"right":return wg(270)}return 0},wg=function(e){return Math.PI*e/180},vg=function(e,t){if(18===t.type){var i=Tg[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);return Eg(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),1)}if(4===t.value.length){s=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 Eg(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),parseInt(A+A,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6);return Eg(parseInt(s,16),parseInt(r,16),parseInt(n,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6),A=t.value.substring(6,8);return Eg(parseInt(s,16),parseInt(r,16),parseInt(n,16),parseInt(A,16)/255)}}if(20===t.type){var o=Sg[t.value.toUpperCase()];if(void 0!==o)return o}return Sg.TRANSPARENT},Cg=function(e){return 0==(255&e)},Mg=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},Eg=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},Fg=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},Ug=function(e,t){var i=t.filter(ag);if(3===i.length){var s=i.map(Fg),r=s[0],n=s[1],A=s[2];return Eg(r,n,A,1)}if(4===i.length){var o=i.map(Fg),a=(r=o[0],n=o[1],A=o[2],o[3]);return Eg(r,n,A,a)}return 0};function xg(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var Ig=function(e,t){var i=t.filter(ag),s=i[0],r=i[1],n=i[2],A=i[3],o=(17===s.type?wg(s.number):bg(e,s))/(2*Math.PI),a=ug(r)?r.number/100:0,l=ug(n)?n.number/100:0,c=void 0!==A&&ug(A)?_g(A,1):1;if(0===a)return Eg(255*l,255*l,255*l,1);var h=l<=.5?l*(a+1):l+a-l*a,u=2*l-h,d=xg(u,h,o+1/3),f=xg(u,h,o),p=xg(u,h,o-1/3);return Eg(255*d,255*f,255*p,c)},Tg={hsl:Ig,hsla:Ig,rgb:Ug,rgba:Ug},Pg=function(e,t){return vg(e,tg.create(t).parseComponentValue())},Sg={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},Dg={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(rg(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},kg={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Qg=function(e,t){var i=vg(e,t[0]),s=t[1];return s&&ug(s)?{color:i,stop:s}:{color:i,stop:null}},Rg=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=fg),null===s.stop&&(s.stop=gg);for(var r=[],n=0,A=0;A<e.length;A++){var o=e[A].stop;if(null!==o){var a=_g(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,i){return{color:e.color,stop:Math.max(Math.min(1,r[i]/t),0)}}))},Og=function(e,t,i){var s="number"==typeof e?e:function(e,t,i){var s=t/2,r=i/2,n=_g(e[0],t)-s,A=r-_g(e[1],i);return(Math.atan2(A,n)+2*Math.PI)%(2*Math.PI)}(e,t,i),r=Math.abs(t*Math.sin(s))+Math.abs(i*Math.cos(s)),n=t/2,A=i/2,o=r/2,a=Math.sin(s-Math.PI/2)*o,l=Math.cos(s-Math.PI/2)*o;return[r,n-l,n+l,A-a,A+a]},Vg=function(e,t){return Math.sqrt(e*e+t*t)},Lg=function(e,t,i,s,r){return[[0,0],[0,t],[e,0],[e,t]].reduce((function(e,t){var n=t[0],A=t[1],o=Vg(i-n,s-A);return(r?o<e.optimumDistance:o>e.optimumDistance)?{optimumCorner:t,optimumDistance:o}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},Hg=function(e,t){var i=wg(180),s=[];return lg(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(i=yg(t));if(Bg(n))return void(i=(bg(e,n)+wg(270))%wg(360))}var A=Qg(e,t);s.push(A)})),{angle:i,stops:s,type:1}},Ng=function(e,t){var i=0,s=3,r=[],n=[];return lg(t).forEach((function(t,A){var o=!0;if(0===A?o=t.reduce((function(e,t){if(rg(t))switch(t.value){case"center":return n.push(pg),!1;case"top":case"left":return n.push(fg),!1;case"right":case"bottom":return n.push(gg),!1}else if(ug(t)||hg(t))return n.push(t),!1;return e}),o):1===A&&(o=t.reduce((function(e,t){if(rg(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(hg(t)||ug(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),o)),o){var a=Qg(e,t);r.push(a)}})),{size:s,shape:i,stops:r,position:n,type:2}},Gg=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Wg[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var jg,Wg={"linear-gradient":function(e,t){var i=wg(180),s=[];return lg(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&"to"===n.value)return void(i=yg(t));if(Bg(n))return void(i=bg(e,n))}var A=Qg(e,t);s.push(A)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":Hg,"-ms-linear-gradient":Hg,"-o-linear-gradient":Hg,"-webkit-linear-gradient":Hg,"radial-gradient":function(e,t){var i=0,s=3,r=[],n=[];return lg(t).forEach((function(t,A){var o=!0;if(0===A){var a=!1;o=t.reduce((function(e,t){if(a)if(rg(t))switch(t.value){case"center":return n.push(pg),e;case"top":case"left":return n.push(fg),e;case"right":case"bottom":return n.push(gg),e}else(ug(t)||hg(t))&&n.push(t);else if(rg(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return a=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(hg(t)||ug(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),o)}if(o){var l=Qg(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:n,type:2}},"-moz-radial-gradient":Ng,"-ms-radial-gradient":Ng,"-o-radial-gradient":Ng,"-webkit-radial-gradient":Ng,"-webkit-gradient":function(e,t){var i=wg(180),s=[],r=1;return lg(t).forEach((function(t,i){var n=t[0];if(0===i){if(rg(n)&&"linear"===n.value)return void(r=1);if(rg(n)&&"radial"===n.value)return void(r=2)}if(18===n.type)if("from"===n.name){var A=vg(e,n.values[0]);s.push({stop:fg,color:A})}else if("to"===n.name){A=vg(e,n.values[0]);s.push({stop:gg,color:A})}else if("color-stop"===n.name){var o=n.values.filter(ag);if(2===o.length){A=vg(e,o[1]);var a=o[0];sg(a)&&s.push({stop:{type:16,number:100*a.number,flags:a.flags},color:A})}}})),1===r?{angle:(i+wg(180))%wg(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},zg={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return ag(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Wg[e.name])}(e)})).map((function(t){return Gg(e,t)}))}},Xg={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(rg(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Kg={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return lg(t).map((function(e){return e.filter(ug)})).map(dg)}},Zg={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return lg(t).map((function(e){return e.filter(rg).map((function(e){return e.value})).join(" ")})).map(Jg)}},Jg=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"}(jg||(jg={}));var Yg,$g={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return lg(t).map((function(e){return e.filter(qg)}))}},qg=function(e){return rg(e)||ug(e)},em=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},tm=em("top"),im=em("right"),sm=em("bottom"),rm=em("left"),nm=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return dg(t.filter(ug))}}},Am=nm("top-left"),om=nm("top-right"),am=nm("bottom-right"),lm=nm("bottom-left"),cm=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}}},hm=cm("top"),um=cm("right"),dm=cm("bottom"),fm=cm("left"),pm=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return ig(t)?t.number:0}}},gm=pm("top"),mm=pm("right"),_m=pm("bottom"),bm=pm("left"),Bm={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ym={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},wm={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(rg).reduce((function(e,t){return e|vm(t.value)}),0)}},vm=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},Cm={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}},Mm={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"}(Yg||(Yg={}));var Em,Fm={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?Yg.STRICT:Yg.NORMAL}},Um={name:"line-height",initialValue:"normal",prefix:!1,type:4},xm=function(e,t){return rg(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:ug(e)?_g(e,t):t},Im={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:Gg(e,t)}},Tm={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Pm={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}}},Sm=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Dm=Sm("top"),km=Sm("right"),Qm=Sm("bottom"),Rm=Sm("left"),Om={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(rg).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}}))}},Vm={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Lm=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Hm=Lm("top"),Nm=Lm("right"),Gm=Lm("bottom"),jm=Lm("left"),Wm={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}}},zm={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}},Xm={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Ag(t[0],"none")?[]:lg(t).map((function(t){for(var i={color:Sg.TRANSPARENT,offsetX:fg,offsetY:fg,blur:fg},s=0,r=0;r<t.length;r++){var n=t[r];hg(n)?(0===s?i.offsetX=n:1===s?i.offsetY=n:i.blur=n,s++):i.color=vg(e,n)}return i}))}},Km={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}},Zm={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 i=Jm[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported transform function "'+t.name+'"');return i(t.values)}return null}},Jm={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})),i=t[0],s=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?[i,s,r,n,A,o]:null}},Ym={type:16,number:50,flags:4},$m=[Ym,Ym],qm={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(e,t){var i=t.filter(ug);return 2!==i.length?$m:[i[0],i[1]]}},e_={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"}(Em||(Em={}));for(var t_={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){switch(t){case"break-all":return Em.BREAK_ALL;case"keep-all":return Em.KEEP_ALL;default:return Em.NORMAL}}},i_={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(e,t){if(20===t.type)return{auto:!0,order:0};if(sg(t))return{auto:!1,order:t.number};throw new Error("Invalid z-index number parsed")}},s_=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")},r_={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(e,t){return sg(t)?t.number:1}},n_={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},A_={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(e,t){return t.filter(rg).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}))}},o_={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(e,t){var i=[],s=[];return t.forEach((function(e){switch(e.type){case 20:case 0:i.push(e.value);break;case 17:i.push(e.number.toString());break;case 4:s.push(i.join(" ")),i.length=0}})),i.length&&s.push(i.join(" ")),s.map((function(e){return-1===e.indexOf(" ")?e:"'"+e+"'"}))}},a_={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},l_={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(e,t){return sg(t)?t.number:rg(t)&&"bold"===t.value?700:400}},c_={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return t.filter(rg).map((function(e){return e.value}))}},h_={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"}}},u_=function(e,t){return 0!=(e&t)},d_={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t}},f_={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var i=t[0];if(20===i.type&&"none"===i.value)return null;for(var s=[],r=t.filter(og),n=0;n<r.length;n++){var A=r[n],o=r[n+1];if(20===A.type){var a=o&&sg(o)?o.number:1;s.push({counter:A.value,increment:a})}}return s}},p_={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return[];for(var i=[],s=t.filter(og),r=0;r<s.length;r++){var n=s[r],A=s[r+1];if(rg(n)&&"none"!==n.value){var o=A&&sg(A)?A.number:0;i.push({counter:n.value,reset:o})}}return i}},g_={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(e,t){return t.filter(ig).map((function(t){return s_(e,t)}))}},m_={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(e,t){if(0===t.length)return null;var i=t[0];if(20===i.type&&"none"===i.value)return null;var s=[],r=t.filter(ng);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;s.push({open:A,close:o})}return s}},__=function(e,t,i){if(!e)return"";var s=e[Math.min(t,e.length-1)];return s?i?s.open:s.close:""},b_={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Ag(t[0],"none")?[]:lg(t).map((function(t){for(var i={color:255,offsetX:fg,offsetY:fg,blur:fg,spread:fg,inset:!1},s=0,r=0;r<t.length;r++){var n=t[r];Ag(n,"inset")?i.inset=!0:hg(n)?(0===s?i.offsetX=n:1===s?i.offsetY=n:2===s?i.blur=n:i.spread=n,s++):i.color=vg(e,n)}return i}))}},B_={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(e,t){var i=[];return t.filter(rg).forEach((function(e){switch(e.value){case"stroke":i.push(1);break;case"fill":i.push(0);break;case"markers":i.push(2)}})),[0,1,2].forEach((function(e){-1===i.indexOf(e)&&i.push(e)})),i}},y_={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},w_={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return ig(t)?t.number:0}},v_=function(){function e(e,t){var i,s;this.animationDuration=E_(e,g_,t.animationDuration),this.backgroundClip=E_(e,Dg,t.backgroundClip),this.backgroundColor=E_(e,kg,t.backgroundColor),this.backgroundImage=E_(e,zg,t.backgroundImage),this.backgroundOrigin=E_(e,Xg,t.backgroundOrigin),this.backgroundPosition=E_(e,Kg,t.backgroundPosition),this.backgroundRepeat=E_(e,Zg,t.backgroundRepeat),this.backgroundSize=E_(e,$g,t.backgroundSize),this.borderTopColor=E_(e,tm,t.borderTopColor),this.borderRightColor=E_(e,im,t.borderRightColor),this.borderBottomColor=E_(e,sm,t.borderBottomColor),this.borderLeftColor=E_(e,rm,t.borderLeftColor),this.borderTopLeftRadius=E_(e,Am,t.borderTopLeftRadius),this.borderTopRightRadius=E_(e,om,t.borderTopRightRadius),this.borderBottomRightRadius=E_(e,am,t.borderBottomRightRadius),this.borderBottomLeftRadius=E_(e,lm,t.borderBottomLeftRadius),this.borderTopStyle=E_(e,hm,t.borderTopStyle),this.borderRightStyle=E_(e,um,t.borderRightStyle),this.borderBottomStyle=E_(e,dm,t.borderBottomStyle),this.borderLeftStyle=E_(e,fm,t.borderLeftStyle),this.borderTopWidth=E_(e,gm,t.borderTopWidth),this.borderRightWidth=E_(e,mm,t.borderRightWidth),this.borderBottomWidth=E_(e,_m,t.borderBottomWidth),this.borderLeftWidth=E_(e,bm,t.borderLeftWidth),this.boxShadow=E_(e,b_,t.boxShadow),this.color=E_(e,Bm,t.color),this.direction=E_(e,ym,t.direction),this.display=E_(e,wm,t.display),this.float=E_(e,Cm,t.cssFloat),this.fontFamily=E_(e,o_,t.fontFamily),this.fontSize=E_(e,a_,t.fontSize),this.fontStyle=E_(e,h_,t.fontStyle),this.fontVariant=E_(e,c_,t.fontVariant),this.fontWeight=E_(e,l_,t.fontWeight),this.letterSpacing=E_(e,Mm,t.letterSpacing),this.lineBreak=E_(e,Fm,t.lineBreak),this.lineHeight=E_(e,Um,t.lineHeight),this.listStyleImage=E_(e,Im,t.listStyleImage),this.listStylePosition=E_(e,Tm,t.listStylePosition),this.listStyleType=E_(e,Pm,t.listStyleType),this.marginTop=E_(e,Dm,t.marginTop),this.marginRight=E_(e,km,t.marginRight),this.marginBottom=E_(e,Qm,t.marginBottom),this.marginLeft=E_(e,Rm,t.marginLeft),this.opacity=E_(e,r_,t.opacity);var r=E_(e,Om,t.overflow);this.overflowX=r[0],this.overflowY=r[r.length>1?1:0],this.overflowWrap=E_(e,Vm,t.overflowWrap),this.paddingTop=E_(e,Hm,t.paddingTop),this.paddingRight=E_(e,Nm,t.paddingRight),this.paddingBottom=E_(e,Gm,t.paddingBottom),this.paddingLeft=E_(e,jm,t.paddingLeft),this.paintOrder=E_(e,B_,t.paintOrder),this.position=E_(e,zm,t.position),this.textAlign=E_(e,Wm,t.textAlign),this.textDecorationColor=E_(e,n_,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=E_(e,A_,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=E_(e,Xm,t.textShadow),this.textTransform=E_(e,Km,t.textTransform),this.transform=E_(e,Zm,t.transform),this.transformOrigin=E_(e,qm,t.transformOrigin),this.visibility=E_(e,e_,t.visibility),this.webkitTextStrokeColor=E_(e,y_,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=E_(e,w_,t.webkitTextStrokeWidth),this.wordBreak=E_(e,t_,t.wordBreak),this.zIndex=E_(e,i_,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return Cg(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 u_(this.display,4)||u_(this.display,33554432)||u_(this.display,268435456)||u_(this.display,536870912)||u_(this.display,67108864)||u_(this.display,134217728)},e}(),C_=function(e,t){this.content=E_(e,d_,t.content),this.quotes=E_(e,m_,t.quotes)},M_=function(e,t){this.counterIncrement=E_(e,f_,t.counterIncrement),this.counterReset=E_(e,p_,t.counterReset)},E_=function(e,t,i){var s=new eg,r=null!=i?i.toString():t.initialValue;s.write(r);var n=new tg(s.read());switch(t.type){case 2:var A=n.parseComponentValue();return t.parse(e,rg(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 bg(e,n.parseComponentValue());case"color":return vg(e,n.parseComponentValue());case"image":return Gg(e,n.parseComponentValue());case"length":var o=n.parseComponentValue();return hg(o)?o:fg;case"length-percentage":var a=n.parseComponentValue();return ug(a)?a:fg;case"time":return s_(e,n.parseComponentValue())}}},F_=function(e,t){var i=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===i||t===i},U_=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,F_(t,3),this.styles=new v_(e,window.getComputedStyle(t,null)),Ub(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=Mf(this.context,t),F_(t,4)&&(this.flags|=16)},x_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",I_="undefined"==typeof Uint8Array?[]:new Uint8Array(256),T_=0;T_<x_.length;T_++)I_[x_.charCodeAt(T_)]=T_;for(var P_=function(e,t,i){return e.slice?e.slice(t,i):new Uint16Array(Array.prototype.slice.call(e,t,i))},S_=function(){function e(e,t,i,s,r,n){this.initialValue=e,this.errorValue=t,this.highStart=i,this.highValueIndex=s,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}(),D_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k_="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Q_=0;Q_<D_.length;Q_++)k_[D_.charCodeAt(Q_)]=Q_;var R_,O_=8,V_=9,L_=11,H_=12,N_=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var i=e.length;if(!i)return"";for(var s=[],r=-1,n="";++r<i;){var A=e[r];A<=65535?s.push(A):(A-=65536,s.push(55296+(A>>10),A%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},G_=function(e,t){var i,s,r,n=function(e){var t,i,s,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)i=I_[e.charCodeAt(t)],s=I_[e.charCodeAt(t+1)],r=I_[e.charCodeAt(t+2)],n=I_[e.charCodeAt(t+3)],c[a++]=i<<2|s>>4,c[a++]=(15&s)<<4|r>>2,c[a++]=(3&r)<<6|63&n;return l}(e),A=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=4)i.push(e[s+3]<<24|e[s+2]<<16|e[s+1]<<8|e[s]);return i}(n):new Uint32Array(n),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s<t;s+=2)i.push(e[s+1]<<8|e[s]);return i}(n):new Uint16Array(n),a=P_(o,12,A[4]/2),l=2===A[5]?P_(o,(24+A[4])/2):(i=A,s=Math.ceil((24+A[4])/4),i.slice?i.slice(s,r):new Uint32Array(Array.prototype.slice.call(i,s,r)));return new S_(A[0],A[1],A[2],A[3],a,l)}("AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA="),j_=function(e){return G_.get(e)},W_=function(e,t,i){var s=i-2,r=t[s],n=t[i-1],A=t[i];if(2===n&&3===A)return"×";if(2===n||3===n||4===n)return"÷";if(2===A||3===A||4===A)return"÷";if(n===O_&&-1!==[O_,V_,L_,H_].indexOf(A))return"×";if(!(n!==L_&&n!==V_||A!==V_&&10!==A))return"×";if((n===H_||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[--s];if(14===r)return"×"}if(15===n&&15===A){for(var o=0;15===r;)o++,r=t[--s];if(o%2==0)return"×"}return"÷"},z_=function(e){var t=function(e){for(var t=[],i=0,s=e.length;i<s;){var r=e.charCodeAt(i++);if(r>=55296&&r<=56319&&i<s){var n=e.charCodeAt(i++);56320==(64512&n)?t.push(((1023&r)<<10)+(1023&n)+65536):(t.push(r),i--)}else t.push(r)}return t}(e),i=t.length,s=0,r=0,n=t.map(j_);return{next:function(){if(s>=i)return{done:!0,value:null};for(var e="×";s<i&&"×"===(e=W_(0,n,++s)););if("×"!==e||s===i){var A=N_.apply(null,t.slice(r,s));return r=s,{value:A,done:!1}}return{done:!0,value:null}}}},X_=function(e){return 0===e[0]&&255===e[1]&&0===e[2]&&255===e[3]},K_=function(e,t,i,s,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",i.toString()),o.setAttributeNS(null,"y",s.toString()),o.setAttributeNS(null,"externalResourcesRequired","true"),A.appendChild(o),o.appendChild(r),A},Z_=function(e){return new Promise((function(t,i){var s=new Image;s.onload=function(){return t(s)},s.onerror=i,s.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},J_={get SUPPORT_RANGE_BOUNDS(){var e=function(e){if(e.createRange){var t=e.createRange();if(t.getBoundingClientRect){var i=e.createElement("boundtest");i.style.height="123px",i.style.display="block",e.body.appendChild(i),t.selectNode(i);var s=t.getBoundingClientRect(),r=Math.round(s.height);if(e.body.removeChild(i),123===r)return!0}}return!1}(document);return Object.defineProperty(J_,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=J_.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 i=e.createRange();t.innerHTML="function"==typeof"".repeat?"👨".repeat(10):"";var s=t.firstChild,r=Ef(s.data).map((function(e){return Ff(e)})),n=0,A={},o=r.every((function(e,t){i.setStart(s,n),i.setEnd(s,n+e.length);var r=i.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(J_,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(J_,"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"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,n=t.toDataURL();r.src=n;var A=K_(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),Z_(A).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var A=e.createElement("div");return A.style.backgroundImage="url("+n+")",A.style.height="100px",X_(r)?Z_(K_(i,i,0,0,A)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),X_(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(J_,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(J_,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(J_,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(J_,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(J_,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Y_=function(e,t){this.text=e,this.bounds=t},$_=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var n=Mf(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),n}}return Cf.EMPTY},q_=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},eb=function(e){if(J_.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,i=z_(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},tb=function(e,t){return 0!==t.letterSpacing?eb(e):function(e,t){if(J_.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return sb(e,t)}(e,t)},ib=[32,160,4961,65792,65793,4153,4241],sb=function(e,t){for(var i,s=function(e,t){var i=Ef(e),s=yp(i,t),r=s[0],n=s[1],A=s[2],o=i.length,a=0,l=0;return{next:function(){if(l>=o)return{done:!0,value:null};for(var e="×";l<o&&"×"===(e=Bp(i,n,r,++l,A)););if("×"!==e||l===o){var t=new wp(i,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(i.value){var e=i.value.slice(),t=Ef(e),s="";t.forEach((function(e){-1===ib.indexOf(e)?s+=Ff(e):(s.length&&r.push(s),r.push(Ff(e)),s="")})),s.length&&r.push(s)}};!(i=s.next()).done;)n();return r},rb=function(e,t,i){this.text=nb(t.data,i.textTransform),this.textBounds=function(e,t,i,s){var r=tb(t,i),n=[],A=0;return r.forEach((function(t){if(i.textDecorationLine.length||t.trim().length>0)if(J_.SUPPORT_RANGE_BOUNDS){var r=q_(s,A,t.length).getClientRects();if(r.length>1){var o=eb(t),a=0;o.forEach((function(t){n.push(new Y_(t,Cf.fromDOMRectList(e,q_(s,a+A,t.length).getClientRects()))),a+=t.length}))}else n.push(new Y_(t,Cf.fromDOMRectList(e,r)))}else{var l=s.splitText(t.length);n.push(new Y_(t,$_(e,s))),s=l}else J_.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));A+=t.length})),n}(e,this.text,i,t)},nb=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Ab,ob);case 2:return e.toUpperCase();default:return e}},Ab=/(^|\s|:|-|\(|\))([a-z])/g,ob=function(e,t,i){return e.length>0?t+i.toUpperCase():e},ab=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return bf(t,e),t}(U_),lb=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return bf(t,e),t}(U_),cb=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,n=Mf(t,i);return i.setAttribute("width",n.width+"px"),i.setAttribute("height",n.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return bf(t,e),t}(U_),hb=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return bf(t,e),t}(U_),ub=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return bf(t,e),t}(U_),db=[{type:15,flags:0,unit:"px",number:3}],fb=[{type:16,flags:0,number:50}],pb="password",gb=function(e){function t(t,i){var s,r,n,A=e.call(this,t,i)||this;switch(A.type=i.type.toLowerCase(),A.checked=i.checked,A.value=0===(r=(s=i).type===pb?new Array(s.value.length+1).join("•"):s.value).length?s.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 Cf(n.left+(n.width-n.height)/2,n.top,n.height,n.height):n.width<n.height?new Cf(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=db;break;case"radio":A.styles.borderTopRightRadius=A.styles.borderTopLeftRadius=A.styles.borderBottomRightRadius=A.styles.borderBottomLeftRadius=fb}return A}return bf(t,e),t}(U_),mb=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=i.options[i.selectedIndex||0];return s.value=r&&r.text||"",s}return bf(t,e),t}(U_),_b=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return bf(t,e),t}(U_),bb=function(e){function t(t,i){var s=e.call(this,t,i)||this;s.src=i.src,s.width=parseInt(i.width,10)||0,s.height=parseInt(i.height,10)||0,s.backgroundColor=s.styles.backgroundColor;try{if(i.contentWindow&&i.contentWindow.document&&i.contentWindow.document.documentElement){s.tree=vb(t,i.contentWindow.document.documentElement);var r=i.contentWindow.document.documentElement?Pg(t,getComputedStyle(i.contentWindow.document.documentElement).backgroundColor):Sg.TRANSPARENT,n=i.contentWindow.document.body?Pg(t,getComputedStyle(i.contentWindow.document.body).backgroundColor):Sg.TRANSPARENT;s.backgroundColor=Cg(r)?Cg(n)?s.styles.backgroundColor:n:r}}catch(e){}return s}return bf(t,e),t}(U_),Bb=["OL","UL","MENU"],yb=function(e,t,i,s){for(var r=t.firstChild,n=void 0;r;r=n)if(n=r.nextSibling,Eb(r)&&r.data.trim().length>0)i.textNodes.push(new rb(e,r,i.styles));else if(Fb(r))if(Nb(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return yb(e,t,i,s)}));else{var A=wb(e,r);A.styles.isVisible()&&(Cb(r,A,s)?A.flags|=4:Mb(A.styles)&&(A.flags|=2),-1!==Bb.indexOf(r.tagName)&&(A.flags|=8),i.elements.push(A),r.slot,r.shadowRoot?yb(e,r.shadowRoot,A,s):Lb(r)||Sb(r)||Hb(r)||yb(e,r,A,s))}},wb=function(e,t){return Rb(t)?new ab(e,t):kb(t)?new lb(e,t):Sb(t)?new cb(e,t):Ib(t)?new hb(e,t):Tb(t)?new ub(e,t):Pb(t)?new gb(e,t):Hb(t)?new mb(e,t):Lb(t)?new _b(e,t):Ob(t)?new bb(e,t):new U_(e,t)},vb=function(e,t){var i=wb(e,t);return i.flags|=4,yb(e,t,i,i),i},Cb=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||Db(e)&&i.styles.isTransparent()},Mb=function(e){return e.isPositioned()||e.isFloating()},Eb=function(e){return e.nodeType===Node.TEXT_NODE},Fb=function(e){return e.nodeType===Node.ELEMENT_NODE},Ub=function(e){return Fb(e)&&void 0!==e.style&&!xb(e)},xb=function(e){return"object"==typeof e.className},Ib=function(e){return"LI"===e.tagName},Tb=function(e){return"OL"===e.tagName},Pb=function(e){return"INPUT"===e.tagName},Sb=function(e){return"svg"===e.tagName},Db=function(e){return"BODY"===e.tagName},kb=function(e){return"CANVAS"===e.tagName},Qb=function(e){return"VIDEO"===e.tagName},Rb=function(e){return"IMG"===e.tagName},Ob=function(e){return"IFRAME"===e.tagName},Vb=function(e){return"STYLE"===e.tagName},Lb=function(e){return"TEXTAREA"===e.tagName},Hb=function(e){return"SELECT"===e.tagName},Nb=function(e){return"SLOT"===e.tagName},Gb=function(e){return e.tagName.indexOf("-")>0},jb=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,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var n=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];n.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),n},e}(),Wb={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"]},zb={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:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Xb={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:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Kb={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:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Zb=function(e,t,i,s,r,n){return e<t||e>i?eB(e,r,n.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+n},Jb=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},Yb=function(e,t,i,s,r){var n=i-t+1;return(e<0?"-":"")+(Jb(Math.abs(e),n,s,(function(e){return Ff(Math.floor(e%n)+t)}))+r)},$b=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return Jb(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},qb=function(e,t,i,s,r,n){if(e<-9999||e>9999)return eB(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&&u_(n,1)&&""!==o?o=t[l]+o:l>1||1===l&&0===a||1===l&&1===a&&u_(n,2)||1===l&&1===a&&u_(n,4)&&e>100||1===l&&a>1&&u_(n,8)?o=t[l]+(a>0?i[a-1]:"")+o:1===l&&a>0&&(o=i[a-1]+o),A=Math.floor(A/10)}return(e<0?s:"")+o},eB=function(e,t,i){var s=i?". ":"",r=i?"、":"",n=i?", ":"",A=i?" ":"";switch(t){case 0:return"•"+A;case 1:return"◦"+A;case 2:return"◾"+A;case 5:var o=Yb(e,48,57,!0,s);return o.length<4?"0"+o:o;case 4:return $b(e,"〇一二三四五六七八九",r);case 6:return Zb(e,1,3999,Wb,3,s).toLowerCase();case 7:return Zb(e,1,3999,Wb,3,s);case 8:return Yb(e,945,969,!1,s);case 9:return Yb(e,97,122,!1,s);case 10:return Yb(e,65,90,!1,s);case 11:return Yb(e,1632,1641,!0,s);case 12:case 49:return Zb(e,1,9999,zb,3,s);case 35:return Zb(e,1,9999,zb,3,s).toLowerCase();case 13:return Yb(e,2534,2543,!0,s);case 14:case 30:return Yb(e,6112,6121,!0,s);case 15:return $b(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return $b(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return qb(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return qb(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return qb(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return qb(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return qb(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return qb(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return qb(e,"영일이삼사오육칠팔구","십백천만","마이너스",n,7);case 33:return qb(e,"零一二三四五六七八九","十百千萬","마이너스",n,0);case 32:return qb(e,"零壹貳參四五六七八九","拾百千","마이너스",n,7);case 18:return Yb(e,2406,2415,!0,s);case 20:return Zb(e,1,19999,Kb,3,s);case 21:return Yb(e,2790,2799,!0,s);case 22:return Yb(e,2662,2671,!0,s);case 22:return Zb(e,1,10999,Xb,3,s);case 23:return $b(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return $b(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return Yb(e,3302,3311,!0,s);case 28:return $b(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return $b(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return Yb(e,3792,3801,!0,s);case 37:return Yb(e,6160,6169,!0,s);case 38:return Yb(e,4160,4169,!0,s);case 39:return Yb(e,2918,2927,!0,s);case 40:return Yb(e,1776,1785,!0,s);case 43:return Yb(e,3046,3055,!0,s);case 44:return Yb(e,3174,3183,!0,s);case 45:return Yb(e,3664,3673,!0,s);case 46:return Yb(e,3872,3881,!0,s);default:return Yb(e,48,57,!0,s)}},tB=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new jb,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 i=this,s=sB(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,n=e.defaultView.pageYOffset,A=s.contentWindow,o=A.document,a=AB(s).then((function(){return yf(i,void 0,void 0,(function(){var e,i;return wf(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(hB),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===(i=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,nB(o)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(o,i)})).then((function(){return s}))]:[2,s]}}))}))}));return o.open(),o.write(lB(document.doctype)+"<html></html>"),cB(this.referenceElement.ownerDocument,r,n),o.replaceChild(o.adoptNode(this.documentElement),o.documentElement),o.close(),a},e.prototype.createElementClone=function(e){if(F_(e,2),kb(e))return this.createCanvasClone(e);if(Qb(e))return this.createVideoClone(e);if(Vb(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Rb(t)&&(Rb(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),Gb(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return aB(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}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 i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),n=s.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 s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){Fb(t)&&("SCRIPT"===t.tagName||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&Fb(t)&&Vb(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(Fb(r)&&Nb(r)&&"function"==typeof r.assignedNodes){var n=r.assignedNodes();n.length&&n.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(Eb(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&Fb(e)&&(Ub(e)||xb(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),n=i.getComputedStyle(e,":before"),A=i.getComputedStyle(e,":after");this.referenceElement===e&&Ub(s)&&(this.clonedReferenceElement=s),Db(s)&&fB(s);var o=this.counters.parse(new M_(this.context,r)),a=this.resolvePseudoContent(e,s,n,R_.BEFORE);Gb(e)&&(t=!0),Qb(e)||this.cloneChildNodes(e,s,t),a&&s.insertBefore(a,s.firstChild);var l=this.resolvePseudoContent(e,s,A,R_.AFTER);return l&&s.appendChild(l),this.counters.pop(o),(r&&(this.options.copyStyles||xb(e))&&!Ob(e)||t)&&aB(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(Lb(e)||Hb(e))&&(Lb(s)||Hb(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var n=i.content,A=t.ownerDocument;if(A&&n&&"none"!==n&&"-moz-alt-content"!==n&&"none"!==i.display){this.counters.parse(new M_(this.context,i));var o=new C_(this.context,i),a=A.createElement("html2canvaspseudoelement");aB(i,a),o.content.forEach((function(t){if(0===t.type)a.appendChild(A.createTextNode(t.value));else if(22===t.type){var i=A.createElement("img");i.src=t.value,i.style.opacity="1",a.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(rg);s.length&&a.appendChild(A.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var n=t.values.filter(ag),l=n[0],c=n[1];if(l&&rg(l)){var h=r.counters.getCounterValue(l.value),u=c&&rg(c)?Pm.parse(r.context,c.value):3;a.appendChild(A.createTextNode(eB(h,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(ag),f=(l=d[0],d[1]);c=d[2];if(l&&rg(l)){var p=r.counters.getCounterValues(l.value),g=c&&rg(c)?Pm.parse(r.context,c.value):3,m=f&&0===f.type?f.value:"",_=p.map((function(e){return eB(e,g,!1)})).join(m);a.appendChild(A.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":a.appendChild(A.createTextNode(__(o.quotes,r.quoteDepth++,!0)));break;case"close-quote":a.appendChild(A.createTextNode(__(o.quotes,--r.quoteDepth,!1)));break;default:a.appendChild(A.createTextNode(t.value))}})),a.className=uB+" "+dB;var l=s===R_.BEFORE?" "+uB:" "+dB;return xb(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"}(R_||(R_={}));var iB,sB=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},rB=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},nB=function(e){return Promise.all([].slice.call(e.images,0).map(rB))},AB=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},oB=["all","d","content"],aB=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===oB.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},lB=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},cB=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},hB=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},uB="___html2canvas___pseudoelement_before",dB="___html2canvas___pseudoelement_after",fB=function(e){pB(e,"."+uB+':before{\n content: "" !important;\n display: none !important;\n}\n .'+dB+':after{\n content: "" !important;\n display: none !important;\n}')},pB=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},gB=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.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}(),mB=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:CB(e)||yB(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 yf(this,void 0,void 0,(function(){var t,i,s,r,n=this;return wf(this,(function(A){switch(A.label){case 0:return t=gB.isSameOrigin(e),i=!wB(e)&&!0===this._options.useCORS&&J_.SUPPORT_CORS_IMAGES&&!t,s=!wB(e)&&!t&&!CB(e)&&"string"==typeof this._options.proxy&&J_.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||wB(e)||CB(e)||s||i?(r=e,s?[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 s=new Image;s.onload=function(){return e(s)},s.onerror=t,(vB(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),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,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,n){var A=J_.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 "+s+" with status code "+o.status)},o.onerror=n;var a=i.indexOf("?")>-1?"&":"?";if(o.open("GET",""+i+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 "+s)}}o.send()}))},e}(),_B=/^data:image\/svg\+xml/i,bB=/^data:image\/.*;base64,/i,BB=/^data:image\/.*/i,yB=function(e){return J_.SUPPORT_SVG_DRAWING||!MB(e)},wB=function(e){return BB.test(e)},vB=function(e){return bB.test(e)},CB=function(e){return"blob"===e.substr(0,4)},MB=function(e){return"svg"===e.substr(-3).toLowerCase()||_B.test(e)},EB=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),FB=function(e,t,i){return new EB(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},UB=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=FB(this.start,this.startControl,t),r=FB(this.startControl,this.endControl,t),n=FB(this.endControl,this.end,t),A=FB(s,r,t),o=FB(r,n,t),a=FB(A,o,t);return i?new e(this.start,s,A,a):new e(a,o,n,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),xB=function(e){return 1===e.type},IB=function(e){var t=e.styles,i=e.bounds,s=mg(t.borderTopLeftRadius,i.width,i.height),r=s[0],n=s[1],A=mg(t.borderTopRightRadius,i.width,i.height),o=A[0],a=A[1],l=mg(t.borderBottomRightRadius,i.width,i.height),c=l[0],h=l[1],u=mg(t.borderBottomLeftRadius,i.width,i.height),d=u[0],f=u[1],p=[];p.push((r+o)/i.width),p.push((d+c)/i.width),p.push((n+f)/i.height),p.push((a+h)/i.height);var g=Math.max.apply(Math,p);g>1&&(r/=g,n/=g,o/=g,a/=g,c/=g,h/=g,d/=g,f/=g);var m=i.width-o,_=i.height-h,b=i.width-c,B=i.height-f,y=t.borderTopWidth,w=t.borderRightWidth,v=t.borderBottomWidth,C=t.borderLeftWidth,M=_g(t.paddingTop,e.bounds.width),E=_g(t.paddingRight,e.bounds.width),F=_g(t.paddingBottom,e.bounds.width),U=_g(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||n>0?TB(i.left+C/3,i.top+y/3,r-C/3,n-y/3,iB.TOP_LEFT):new EB(i.left+C/3,i.top+y/3),this.topRightBorderDoubleOuterBox=r>0||n>0?TB(i.left+m,i.top+y/3,o-w/3,a-y/3,iB.TOP_RIGHT):new EB(i.left+i.width-w/3,i.top+y/3),this.bottomRightBorderDoubleOuterBox=c>0||h>0?TB(i.left+b,i.top+_,c-w/3,h-v/3,iB.BOTTOM_RIGHT):new EB(i.left+i.width-w/3,i.top+i.height-v/3),this.bottomLeftBorderDoubleOuterBox=d>0||f>0?TB(i.left+C/3,i.top+B,d-C/3,f-v/3,iB.BOTTOM_LEFT):new EB(i.left+C/3,i.top+i.height-v/3),this.topLeftBorderDoubleInnerBox=r>0||n>0?TB(i.left+2*C/3,i.top+2*y/3,r-2*C/3,n-2*y/3,iB.TOP_LEFT):new EB(i.left+2*C/3,i.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||n>0?TB(i.left+m,i.top+2*y/3,o-2*w/3,a-2*y/3,iB.TOP_RIGHT):new EB(i.left+i.width-2*w/3,i.top+2*y/3),this.bottomRightBorderDoubleInnerBox=c>0||h>0?TB(i.left+b,i.top+_,c-2*w/3,h-2*v/3,iB.BOTTOM_RIGHT):new EB(i.left+i.width-2*w/3,i.top+i.height-2*v/3),this.bottomLeftBorderDoubleInnerBox=d>0||f>0?TB(i.left+2*C/3,i.top+B,d-2*C/3,f-2*v/3,iB.BOTTOM_LEFT):new EB(i.left+2*C/3,i.top+i.height-2*v/3),this.topLeftBorderStroke=r>0||n>0?TB(i.left+C/2,i.top+y/2,r-C/2,n-y/2,iB.TOP_LEFT):new EB(i.left+C/2,i.top+y/2),this.topRightBorderStroke=r>0||n>0?TB(i.left+m,i.top+y/2,o-w/2,a-y/2,iB.TOP_RIGHT):new EB(i.left+i.width-w/2,i.top+y/2),this.bottomRightBorderStroke=c>0||h>0?TB(i.left+b,i.top+_,c-w/2,h-v/2,iB.BOTTOM_RIGHT):new EB(i.left+i.width-w/2,i.top+i.height-v/2),this.bottomLeftBorderStroke=d>0||f>0?TB(i.left+C/2,i.top+B,d-C/2,f-v/2,iB.BOTTOM_LEFT):new EB(i.left+C/2,i.top+i.height-v/2),this.topLeftBorderBox=r>0||n>0?TB(i.left,i.top,r,n,iB.TOP_LEFT):new EB(i.left,i.top),this.topRightBorderBox=o>0||a>0?TB(i.left+m,i.top,o,a,iB.TOP_RIGHT):new EB(i.left+i.width,i.top),this.bottomRightBorderBox=c>0||h>0?TB(i.left+b,i.top+_,c,h,iB.BOTTOM_RIGHT):new EB(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||f>0?TB(i.left,i.top+B,d,f,iB.BOTTOM_LEFT):new EB(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||n>0?TB(i.left+C,i.top+y,Math.max(0,r-C),Math.max(0,n-y),iB.TOP_LEFT):new EB(i.left+C,i.top+y),this.topRightPaddingBox=o>0||a>0?TB(i.left+Math.min(m,i.width-w),i.top+y,m>i.width+w?0:Math.max(0,o-w),Math.max(0,a-y),iB.TOP_RIGHT):new EB(i.left+i.width-w,i.top+y),this.bottomRightPaddingBox=c>0||h>0?TB(i.left+Math.min(b,i.width-C),i.top+Math.min(_,i.height-v),Math.max(0,c-w),Math.max(0,h-v),iB.BOTTOM_RIGHT):new EB(i.left+i.width-w,i.top+i.height-v),this.bottomLeftPaddingBox=d>0||f>0?TB(i.left+C,i.top+Math.min(B,i.height-v),Math.max(0,d-C),Math.max(0,f-v),iB.BOTTOM_LEFT):new EB(i.left+C,i.top+i.height-v),this.topLeftContentBox=r>0||n>0?TB(i.left+C+U,i.top+y+M,Math.max(0,r-(C+U)),Math.max(0,n-(y+M)),iB.TOP_LEFT):new EB(i.left+C+U,i.top+y+M),this.topRightContentBox=o>0||a>0?TB(i.left+Math.min(m,i.width+C+U),i.top+y+M,m>i.width+C+U?0:o-C+U,a-(y+M),iB.TOP_RIGHT):new EB(i.left+i.width-(w+E),i.top+y+M),this.bottomRightContentBox=c>0||h>0?TB(i.left+Math.min(b,i.width-(C+U)),i.top+Math.min(_,i.height+y+M),Math.max(0,c-(w+E)),h-(v+F),iB.BOTTOM_RIGHT):new EB(i.left+i.width-(w+E),i.top+i.height-(v+F)),this.bottomLeftContentBox=d>0||f>0?TB(i.left+C+U,i.top+B,Math.max(0,d-(C+U)),f-(v+F),iB.BOTTOM_LEFT):new EB(i.left+C+U,i.top+i.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"}(iB||(iB={}));var TB=function(e,t,i,s,r){var n=(Math.sqrt(2)-1)/3*4,A=i*n,o=s*n,a=e+i,l=t+s;switch(r){case iB.TOP_LEFT:return new UB(new EB(e,l),new EB(e,l-o),new EB(a-A,t),new EB(a,t));case iB.TOP_RIGHT:return new UB(new EB(e,t),new EB(e+A,t),new EB(a,l-o),new EB(a,l));case iB.BOTTOM_RIGHT:return new UB(new EB(a,t),new EB(a,t+o),new EB(e+A,l),new EB(e,l));case iB.BOTTOM_LEFT:default:return new UB(new EB(a,l),new EB(a-A,l),new EB(e,t+o),new EB(e,t))}},PB=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},SB=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},DB=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},kB=function(e,t){this.path=e,this.target=t,this.type=1},QB=function(e){this.opacity=e,this.type=2,this.target=6},RB=function(e){return 1===e.type},OB=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},VB=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},LB=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new IB(this.container),this.container.styles.opacity<1&&this.effects.push(new QB(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new DB(i,s,r))}if(0!==this.container.styles.overflowX){var n=PB(this.curves),A=SB(this.curves);OB(n,A)?this.effects.push(new kB(n,6)):(this.effects.push(new kB(n,2)),this.effects.push(new kB(A,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!RB(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var n=PB(i.curves),A=SB(i.curves);OB(n,A)||s.unshift(new kB(A,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return u_(t.target,e)}))},e}(),HB=function(e,t,i,s){e.container.elements.forEach((function(r){var n=u_(r.flags,4),A=u_(r.flags,2),o=new LB(r,e);u_(r.styles.display,2048)&&s.push(o);var a=u_(r.flags,8)?[]:s;if(n||A){var l=n||r.styles.isPositioned()?i:t,c=new VB(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);HB(o,c,n?c:i,a)}else r.styles.isInlineLevel()?t.inlineLevel.push(o):t.nonInlineLevel.push(o),HB(o,t,i,a);u_(r.flags,8)&&NB(r,a)}))},NB=function(e,t){for(var i=e instanceof ub?e.start:1,s=e instanceof ub&&e.reversed,r=0;r<t.length;r++){var n=t[r];n.container instanceof hb&&"number"==typeof n.container.value&&0!==n.container.value&&(i=n.container.value),n.listValue=eB(i,n.container.styles.listStyleType,!0),i+=s?-1:1}},GB=function(e,t){switch(t){case 0:return WB(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return WB(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return WB(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return WB(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},jB=function(e,t){var i=[];return xB(e)?i.push(e.subdivide(.5,!1)):i.push(e),xB(t)?i.push(t.subdivide(.5,!0)):i.push(t),i},WB=function(e,t,i,s){var r=[];return xB(e)?r.push(e.subdivide(.5,!1)):r.push(e),xB(i)?r.push(i.subdivide(.5,!0)):r.push(i),xB(s)?r.push(s.subdivide(.5,!0).reverse()):r.push(s),xB(t)?r.push(t.subdivide(.5,!1).reverse()):r.push(t),r},zB=function(e){var t=e.bounds,i=e.styles;return t.add(i.borderLeftWidth,i.borderTopWidth,-(i.borderRightWidth+i.borderLeftWidth),-(i.borderTopWidth+i.borderBottomWidth))},XB=function(e){var t=e.styles,i=e.bounds,s=_g(t.paddingLeft,i.width),r=_g(t.paddingRight,i.width),n=_g(t.paddingTop,i.width),A=_g(t.paddingBottom,i.width);return i.add(s+t.borderLeftWidth,n+t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth+s+r),-(t.borderTopWidth+t.borderBottomWidth+n+A))},KB=function(e,t,i){var s=function(e,t){return 0===e?t.bounds:2===e?XB(t):zB(t)}($B(e.styles.backgroundOrigin,t),e),r=function(e,t){return 0===e?t.bounds:2===e?XB(t):zB(t)}($B(e.styles.backgroundClip,t),e),n=YB($B(e.styles.backgroundSize,t),i,s),A=n[0],o=n[1],a=mg($B(e.styles.backgroundPosition,t),s.width-A,s.height-o);return[qB($B(e.styles.backgroundRepeat,t),a,n,s,r),Math.round(s.left+a[0]),Math.round(s.top+a[1]),A,o]},ZB=function(e){return rg(e)&&e.value===jg.AUTO},JB=function(e){return"number"==typeof e},YB=function(e,t,i){var s=t[0],r=t[1],n=t[2],A=e[0],o=e[1];if(!A)return[0,0];if(ug(A)&&o&&ug(o))return[_g(A,i.width),_g(o,i.height)];var a=JB(n);if(rg(A)&&(A.value===jg.CONTAIN||A.value===jg.COVER))return JB(n)?i.width/i.height<n!=(A.value===jg.COVER)?[i.width,i.width/n]:[i.height*n,i.height]:[i.width,i.height];var l=JB(s),c=JB(r),h=l||c;if(ZB(A)&&(!o||ZB(o)))return l&&c?[s,r]:a||h?h&&a?[l?s:r*n,c?r:s/n]:[l?s:i.width,c?r:i.height]:[i.width,i.height];if(a){var u=0,d=0;return ug(A)?u=_g(A,i.width):ug(o)&&(d=_g(o,i.height)),ZB(A)?u=d*n:o&&!ZB(o)||(d=u/n),[u,d]}var f=null,p=null;if(ug(A)?f=_g(A,i.width):o&&ug(o)&&(p=_g(o,i.height)),null===f||o&&!ZB(o)||(p=l&&c?f/s*r:i.height),null!==p&&ZB(A)&&(f=l&&c?p/r*s:i.width),null!==f&&null!==p)return[f,p];throw new Error("Unable to calculate background-size for element")},$B=function(e,t){var i=e[t];return void 0===i?e[0]:i},qB=function(e,t,i,s,r){var n=t[0],A=t[1],o=i[0],a=i[1];switch(e){case 2:return[new EB(Math.round(s.left),Math.round(s.top+A)),new EB(Math.round(s.left+s.width),Math.round(s.top+A)),new EB(Math.round(s.left+s.width),Math.round(a+s.top+A)),new EB(Math.round(s.left),Math.round(a+s.top+A))];case 3:return[new EB(Math.round(s.left+n),Math.round(s.top)),new EB(Math.round(s.left+n+o),Math.round(s.top)),new EB(Math.round(s.left+n+o),Math.round(s.height+s.top)),new EB(Math.round(s.left+n),Math.round(s.height+s.top))];case 1:return[new EB(Math.round(s.left+n),Math.round(s.top+A)),new EB(Math.round(s.left+n+o),Math.round(s.top+A)),new EB(Math.round(s.left+n+o),Math.round(s.top+A+a)),new EB(Math.round(s.left+n),Math.round(s.top+A+a))];default:return[new EB(Math.round(r.left),Math.round(r.top)),new EB(Math.round(r.left+r.width),Math.round(r.top)),new EB(Math.round(r.left+r.width),Math.round(r.height+r.top)),new EB(Math.round(r.left),Math.round(r.height+r.top))]}},ey=function(){function e(e){this._data={},this._document=e}return e.prototype.parseMetrics=function(e,t){var i=this._document.createElement("div"),s=this._document.createElement("img"),r=this._document.createElement("span"),n=this._document.body;i.style.visibility="hidden",i.style.fontFamily=e,i.style.fontSize=t,i.style.margin="0",i.style.padding="0",i.style.whiteSpace="nowrap",n.appendChild(i),s.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",s.width=1,s.height=1,s.style.margin="0",s.style.padding="0",s.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")),i.appendChild(r),i.appendChild(s);var A=s.offsetTop-r.offsetTop+2;i.removeChild(r),i.appendChild(this._document.createTextNode("Hidden Text")),i.style.lineHeight="normal",s.style.verticalAlign="super";var o=s.offsetTop-i.offsetTop+2;return n.removeChild(i),{baseline:A,middle:o}},e.prototype.getMetrics=function(e,t){var i=e+" "+t;return void 0===this._data[i]&&(this._data[i]=this.parseMetrics(e,t)),this._data[i]},e}(),ty=function(e,t){this.context=e,this.options=t},iy=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s._activeEffects=[],s.canvas=i.canvas?i.canvas:document.createElement("canvas"),s.ctx=s.canvas.getContext("2d"),i.canvas||(s.canvas.width=Math.floor(i.width*i.scale),s.canvas.height=Math.floor(i.height*i.scale),s.canvas.style.width=i.width+"px",s.canvas.style.height=i.height+"px"),s.fontMetrics=new ey(document),s.ctx.scale(s.options.scale,s.options.scale),s.ctx.translate(-i.x,-i.y),s.ctx.textBaseline="bottom",s._activeEffects=[],s.context.logger.debug("Canvas renderer initialized ("+i.width+"x"+i.height+") with scale "+i.scale),s}return bf(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)),RB(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 yf(this,void 0,void 0,(function(){return wf(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 yf(this,void 0,void 0,(function(){return wf(this,(function(t){switch(t.label){case 0:return u_(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,i){var s=this;0===t?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+i):eb(e.text).reduce((function(t,r){return s.ctx.fillText(r,t,e.bounds.top+i),t+s.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(""),i=oy(e.fontFamily).join(", "),s=ig(e.fontSize)?""+e.fontSize.number+e.fontSize.unit:e.fontSize.number+"px";return[[e.fontStyle,t,e.fontWeight,s,i].join(" "),i,s]},t.prototype.renderTextNode=function(e,t){return yf(this,void 0,void 0,(function(){var i,s,r,n,A,o,a,l,c=this;return wf(this,(function(h){return i=this.createFontStyle(t),s=i[0],r=i[1],n=i[2],this.ctx.font=s,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(i){switch(i){case 0:c.ctx.fillStyle=Mg(t.color),c.renderTextWithLetterSpacing(e,t.letterSpacing,o);var s=t.textShadow;s.length&&e.text.trim().length&&(s.slice(0).reverse().forEach((function(i){c.ctx.shadowColor=Mg(i.color),c.ctx.shadowOffsetX=i.offsetX.number*c.options.scale,c.ctx.shadowOffsetY=i.offsetY.number*c.options.scale,c.ctx.shadowBlur=i.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=Mg(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=Mg(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,i){if(i&&e.intrinsicWidth>0&&e.intrinsicHeight>0){var s=XB(e),r=SB(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return yf(this,void 0,void 0,(function(){var i,s,r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b;return wf(this,(function(B){switch(B.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,n=0,A=i.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(!(i instanceof ab))return[3,8];B.label=5;case 5:return B.trys.push([5,7,,8]),[4,this.context.cache.match(i.src)];case 6:return g=B.sent(),this.renderReplacedElement(i,s,g),[3,8];case 7:return B.sent(),this.context.logger.error("Error loading image "+i.src),[3,8];case 8:if(i instanceof lb&&this.renderReplacedElement(i,s,i.canvas),!(i instanceof cb))return[3,12];B.label=9;case 9:return B.trys.push([9,11,,12]),[4,this.context.cache.match(i.svg)];case 10:return g=B.sent(),this.renderReplacedElement(i,s,g),[3,12];case 11:return B.sent(),this.context.logger.error("Error loading svg "+i.svg.substring(0,255)),[3,12];case 12:return i instanceof bb&&i.tree?[4,new t(this.context,{scale:this.options.scale,backgroundColor:i.backgroundColor,x:0,y:0,width:i.width,height:i.height}).render(i.tree)]:[3,14];case 13:a=B.sent(),i.width&&i.height&&this.ctx.drawImage(a,0,0,i.width,i.height,i.bounds.left,i.bounds.top,i.bounds.width,i.bounds.height),B.label=14;case 14:if(i instanceof gb&&(l=Math.min(i.bounds.width,i.bounds.height),"checkbox"===i.type?i.checked&&(this.ctx.save(),this.path([new EB(i.bounds.left+.39363*l,i.bounds.top+.79*l),new EB(i.bounds.left+.16*l,i.bounds.top+.5549*l),new EB(i.bounds.left+.27347*l,i.bounds.top+.44071*l),new EB(i.bounds.left+.39694*l,i.bounds.top+.5649*l),new EB(i.bounds.left+.72983*l,i.bounds.top+.23*l),new EB(i.bounds.left+.84*l,i.bounds.top+.34085*l),new EB(i.bounds.left+.39363*l,i.bounds.top+.79*l)]),this.ctx.fillStyle=Mg(707406591),this.ctx.fill(),this.ctx.restore()):"radio"===i.type&&i.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(i.bounds.left+l/2,i.bounds.top+l/2,l/4,0,2*Math.PI,!0),this.ctx.fillStyle=Mg(707406591),this.ctx.fill(),this.ctx.restore())),sy(i)&&i.value.length){switch(c=this.createFontStyle(r),_=c[0],h=c[1],u=this.fontMetrics.getMetrics(_,h).baseline,this.ctx.font=_,this.ctx.fillStyle=Mg(r.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=ny(i.styles.textAlign),b=XB(i),d=0,i.styles.textAlign){case 1:d+=b.width/2;break;case 2:d+=b.width}f=b.add(d,0,0,-b.height/2+1),this.ctx.save(),this.path([new EB(b.left,b.top),new EB(b.left+b.width,b.top),new EB(b.left+b.width,b.top+b.height),new EB(b.left,b.top+b.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new Y_(i.value,f),r.letterSpacing,u),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!u_(i.styles.display,2048))return[3,20];if(null===i.styles.listStyleImage)return[3,19];if(0!==(p=i.styles.listStyleImage).type)return[3,18];g=void 0,m=p.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,i.bounds.left-(g.width+10),i.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!==i.styles.listStyleType&&(_=this.createFontStyle(r)[0],this.ctx.font=_,this.ctx.fillStyle=Mg(r.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",b=new Cf(i.bounds.left,i.bounds.top+_g(i.styles.paddingTop,i.bounds.width),i.bounds.width,xm(r.lineHeight,r.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new Y_(e.listValue,b),r.letterSpacing,xm(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 yf(this,void 0,void 0,(function(){var t,i,s,r,n,A,o,a,l,c,h,u,d,f,p;return wf(this,(function(g){switch(g.label){case 0:return u_(e.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(e.element)];case 1:g.sent(),t=0,i=e.negativeZIndex,g.label=2;case 2:return t<i.length?(p=i[t],[4,this.renderStack(p)]):[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(),s=0,r=e.nonInlineLevel,g.label=7;case 7:return s<r.length?(p=r[s],[4,this.renderNode(p)]):[3,10];case 8:g.sent(),g.label=9;case 9:return s++,[3,7];case 10:n=0,A=e.nonPositionedFloats,g.label=11;case 11:return n<A.length?(p=A[n],[4,this.renderStack(p)]):[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?(p=a[o],[4,this.renderStack(p)]):[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?(p=c[l],[4,this.renderNode(p)]):[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?(p=u[h],[4,this.renderStack(p)]):[3,26];case 24:g.sent(),g.label=25;case 25:return h++,[3,23];case 26:d=0,f=e.positiveZIndex,g.label=27;case 27:return d<f.length?(p=f[d],[4,this.renderStack(p)]):[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,i){var s=xB(e)?e.start:e;0===i?t.ctx.moveTo(s.x,s.y):t.ctx.lineTo(s.x,s.y),xB(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,i,s){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(i,s),this.ctx.fill(),this.ctx.translate(-i,-s)},t.prototype.resizeImage=function(e,t,i){var s;if(e.width===t&&e.height===i)return e;var r=(null!==(s=this.canvas.ownerDocument)&&void 0!==s?s:document).createElement("canvas");return r.width=Math.max(1,t),r.height=Math.max(1,i),r.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t,i),r},t.prototype.renderBackgroundImage=function(e){return yf(this,void 0,void 0,(function(){var t,i,s,r,n,A;return wf(this,(function(o){switch(o.label){case 0:t=e.styles.backgroundImage.length-1,i=function(i){var r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B,y,w,v,C,M,E,F,U,x,I,T,P,S,D;return wf(this,(function(k){switch(k.label){case 0:if(0!==i.type)return[3,5];r=void 0,n=i.url,k.label=1;case 1:return k.trys.push([1,3,,4]),[4,s.context.cache.match(n)];case 2:return r=k.sent(),[3,4];case 3:return k.sent(),s.context.logger.error("Error loading background-image "+n),[3,4];case 4:return r&&(A=KB(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=s.ctx.createPattern(s.resizeImage(r,w,v),"repeat"),s.renderRepeat(b,m,M,E)),[3,6];case 5:1===i.type?(o=KB(e,t,[null,null,null]),b=o[0],M=o[1],E=o[2],w=o[3],v=o[4],a=Og(i.angle,w,v),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],(f=document.createElement("canvas")).width=w,f.height=v,p=f.getContext("2d"),g=p.createLinearGradient(c,u,h,d),Rg(i.stops,l).forEach((function(e){return g.addColorStop(e.stop,Mg(e.color))})),p.fillStyle=g,p.fillRect(0,0,w,v),w>0&&v>0&&(m=s.ctx.createPattern(f,"repeat"),s.renderRepeat(b,m,M,E))):function(e){return 2===e.type}(i)&&(_=KB(e,t,[null,null,null]),b=_[0],B=_[1],y=_[2],w=_[3],v=_[4],C=0===i.position.length?[pg]:i.position,M=_g(C[0],w),E=_g(C[C.length-1],v),F=function(e,t,i,s,r){var n=0,A=0;switch(e.size){case 0:0===e.shape?n=A=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.min(Math.abs(t),Math.abs(t-s)),A=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)n=A=Math.min(Vg(t,i),Vg(t,i-r),Vg(t-s,i),Vg(t-s,i-r));else if(1===e.shape){var o=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),a=Lg(s,r,t,i,!0),l=a[0],c=a[1];A=o*(n=Vg(l-t,(c-i)/o))}break;case 1:0===e.shape?n=A=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.max(Math.abs(t),Math.abs(t-s)),A=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)n=A=Math.max(Vg(t,i),Vg(t,i-r),Vg(t-s,i),Vg(t-s,i-r));else if(1===e.shape){o=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var h=Lg(s,r,t,i,!1);l=h[0],c=h[1],A=o*(n=Vg(l-t,(c-i)/o))}}return Array.isArray(e.size)&&(n=_g(e.size[0],s),A=2===e.size.length?_g(e.size[1],r):n),[n,A]}(i,M,E,w,v),U=F[0],x=F[1],U>0&&x>0&&(I=s.ctx.createRadialGradient(B+M,y+E,0,B+M,y+E,U),Rg(i.stops,2*U).forEach((function(e){return I.addColorStop(e.stop,Mg(e.color))})),s.path(b),s.ctx.fillStyle=I,U!==x?(T=e.bounds.left+.5*e.bounds.width,P=e.bounds.top+.5*e.bounds.height,D=1/(S=x/U),s.ctx.save(),s.ctx.translate(T,P),s.ctx.transform(1,0,0,S,0,0),s.ctx.translate(-T,-P),s.ctx.fillRect(B,D*(y-P)+P,w,v*D),s.ctx.restore()):s.ctx.fill())),k.label=6;case 6:return t--,[2]}}))},s=this,r=0,n=e.styles.backgroundImage.slice(0).reverse(),o.label=1;case 1:return r<n.length?(A=n[r],[5,i(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,i){return yf(this,void 0,void 0,(function(){return wf(this,(function(s){return this.path(GB(i,t)),this.ctx.fillStyle=Mg(e),this.ctx.fill(),[2]}))}))},t.prototype.renderDoubleBorder=function(e,t,i,s){return yf(this,void 0,void 0,(function(){var r,n;return wf(this,(function(A){switch(A.label){case 0:return t<3?[4,this.renderSolidBorder(e,i,s)]:[3,2];case 1:return A.sent(),[2];case 2:return r=function(e,t){switch(t){case 0:return WB(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return WB(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return WB(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return WB(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}}(s,i),this.path(r),this.ctx.fillStyle=Mg(e),this.ctx.fill(),n=function(e,t){switch(t){case 0:return WB(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return WB(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return WB(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return WB(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}}(s,i),this.path(n),this.ctx.fill(),[2]}}))}))},t.prototype.renderNodeBackgroundAndBorders=function(e){return yf(this,void 0,void 0,(function(){var t,i,s,r,n,A,o,a,l=this;return wf(this,(function(c){switch(c.label){case 0:return this.applyEffects(e.getEffects(2)),t=e.container.styles,i=!Cg(t.backgroundColor)||t.backgroundImage.length,s=[{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=ry($B(t.backgroundClip,0),e.curves),i||t.boxShadow.length?(this.ctx.save(),this.path(r),this.ctx.clip(),Cg(t.backgroundColor)||(this.ctx.fillStyle=Mg(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 i,s,r,n,A,o=PB(e.curves),a=t.inset?0:1e4,c=(i=o,s=-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),i.map((function(e,t){switch(t){case 0:return e.add(s,r);case 1:return e.add(s+n,r);case 2:return e.add(s+n,r+A);case 3:return e.add(s,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=Mg(t.color),l.ctx.shadowBlur=t.blur.number,l.ctx.fillStyle=t.inset?Mg(t.color):"rgba(0,0,0,1)",l.ctx.fill(),l.ctx.restore()})),c.label=2;case 2:n=0,A=0,o=s,c.label=3;case 3:return A<o.length?0!==(a=o[A]).style&&!Cg(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,i,s,r){return yf(this,void 0,void 0,(function(){var n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B;return wf(this,(function(y){return this.ctx.save(),n=function(e,t){switch(t){case 0:return jB(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return jB(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return jB(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return jB(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),A=GB(s,i),2===r&&(this.path(A),this.ctx.clip()),xB(A[0])?(o=A[0].start.x,a=A[0].start.y):(o=A[0].x,a=A[0].y),xB(A[1])?(l=A[1].end.x,c=A[1].end.y):(l=A[1].x,c=A[1].y),h=0===i||2===i?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),f=!0,h<=2*u?f=!1:h<=2*u+d?(u*=p=h/(2*u+d),d*=p):(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:_),f&&(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=Mg(e),this.ctx.stroke(),this.ctx.setLineDash([]),2===r&&(xB(A[0])&&(b=A[3],B=A[0],this.ctx.beginPath(),this.formatPath([new EB(b.end.x,b.end.y),new EB(B.start.x,B.start.y)]),this.ctx.stroke()),xB(A[1])&&(b=A[1],B=A[2],this.ctx.beginPath(),this.formatPath([new EB(b.end.x,b.end.y),new EB(B.start.x,B.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]}))}))},t.prototype.render=function(e){return yf(this,void 0,void 0,(function(){var t;return wf(this,(function(i){switch(i.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=Mg(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),s=new LB(e,null),r=new VB(s),HB(s,r,r,n=[]),NB(s.container,n),t=r,[4,this.renderStack(t)];case 1:return i.sent(),this.applyEffects([]),[2,this.canvas]}var s,r,n}))}))},t}(ty),sy=function(e){return e instanceof _b||(e instanceof mb||e instanceof gb&&"radio"!==e.type&&"checkbox"!==e.type)},ry=function(e,t){switch(e){case 0:return PB(t);case 2:return function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]}(t);default:return SB(t)}},ny=function(e){switch(e){case 1:return"center";case 2:return"right";default:return"left"}},Ay=["-apple-system","system-ui"],oy=function(e){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?e.filter((function(e){return-1===Ay.indexOf(e)})):e},ay=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i.canvas?i.canvas:document.createElement("canvas"),s.ctx=s.canvas.getContext("2d"),s.options=i,s.canvas.width=Math.floor(i.width*i.scale),s.canvas.height=Math.floor(i.height*i.scale),s.canvas.style.width=i.width+"px",s.canvas.style.height=i.height+"px",s.ctx.scale(s.options.scale,s.options.scale),s.ctx.translate(-i.x,-i.y),s.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+i.width+"x"+i.height+" at "+i.x+","+i.y+") with scale "+i.scale),s}return bf(t,e),t.prototype.render=function(e){return yf(this,void 0,void 0,(function(){var t,i;return wf(this,(function(s){switch(s.label){case 0:return t=K_(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),[4,ly(t)];case 1:return i=s.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=Mg(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(i,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}}))}))},t}(ty),ly=function(e){return new Promise((function(t,i){var s=new Image;s.onload=function(){t(s)},s.onerror=i,s.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},cy=function(){function e(e){var t=e.id,i=e.enabled;this.id=t,this.enabled=i,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,vf([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,vf([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,vf([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,vf([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},e.instances={},e}(),hy=function(){function e(t,i){var s;this.windowBounds=i,this.instanceName="#"+e.instanceCount++,this.logger=new cy({id:this.instanceName,enabled:t.logging}),this.cache=null!==(s=t.cache)&&void 0!==s?s:new mB(this,t)}return e.instanceCount=1,e}();"undefined"!=typeof window&&gB.setContext(window);var uy=function(e,t){return yf(void 0,void 0,void 0,(function(){var i,s,r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B,y,w,v,C,M,E,F,U,x,I,T,P,S,D,k,Q,R,O,V;return wf(this,(function(L){switch(L.label){case 0:if(!e||"object"!=typeof e)return[2,Promise.reject("Invalid element provided as first argument")];if(!(i=e.ownerDocument))throw new Error("Element is not attached to a Document");if(!(s=i.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=Bf({logging:null===(E=t.logging)||void 0===E||E,cache:t.cache},r),A={windowWidth:null!==(F=t.windowWidth)&&void 0!==F?F:s.innerWidth,windowHeight:null!==(U=t.windowHeight)&&void 0!==U?U:s.innerHeight,scrollX:null!==(x=t.scrollX)&&void 0!==x?x:s.pageXOffset,scrollY:null!==(I=t.scrollY)&&void 0!==I?I:s.pageYOffset},o=new Cf(A.scrollX,A.scrollY,A.windowWidth,A.windowHeight),a=new hy(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 tB(a,e,c),(u=h.clonedReferenceElement)?[4,h.toIFrame(i,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=L.sent(),f=Db(u)||"HTML"===u.tagName?function(e){var t=e.body,i=e.documentElement;if(!t||!i)throw new Error("Unable to get document size");var s=Math.max(Math.max(t.scrollWidth,i.scrollWidth),Math.max(t.offsetWidth,i.offsetWidth),Math.max(t.clientWidth,i.clientWidth)),r=Math.max(Math.max(t.scrollHeight,i.scrollHeight),Math.max(t.offsetHeight,i.offsetHeight),Math.max(t.clientHeight,i.clientHeight));return new Cf(0,0,s,r)}(u.ownerDocument):Mf(a,u),p=f.width,g=f.height,m=f.left,_=f.top,b=dy(a,u,t.backgroundColor),B={canvas:t.canvas,backgroundColor:b,scale:null!==(D=null!==(S=t.scale)&&void 0!==S?S:s.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(p),height:null!==(O=t.height)&&void 0!==O?O:Math.ceil(g)},l?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new ay(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 "+p+"x"+g+" using computed rendering"),a.logger.debug("Starting DOM parsing"),w=vb(a,u),b===w.styles.backgroundColor&&(w.styles.backgroundColor=Sg.TRANSPARENT),a.logger.debug("Starting renderer for element at "+B.x+","+B.y+" with size "+B.width+"x"+B.height),[4,new iy(a,B).render(w)];case 4:y=L.sent(),L.label=5;case 5:return(null===(V=t.removeContainer)||void 0===V||V)&&(tB.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,y]}}))}))},dy=function(e,t,i){var s=t.ownerDocument,r=s.documentElement?Pg(e,getComputedStyle(s.documentElement).backgroundColor):Sg.TRANSPARENT,n=s.body?Pg(e,getComputedStyle(s.body).backgroundColor):Sg.TRANSPARENT,A="string"==typeof i?Pg(e,i):null===i?Sg.TRANSPARENT:4294967295;return t===s.documentElement?Cg(r)?Cg(n)?A:n:r:A};function fy(e,t,i=(()=>{})){if(!e||!t)return;let s=null;let r,n;const A=e=>{if(e.preventDefault(),s&&(clearTimeout(s),s=null),e.touches.length>1)return;const i=e.touches[0];r=i.clientX,n=i.clientY,s=setTimeout((()=>{e.clientX=i.clientX,e.clientY=i.clientY,t(e),clearTimeout(s),s=null}),500)},o=e=>{e.touches.length>1&&s&&(clearTimeout(s),s=null)},a=e=>{if(!s)return;const t=e.touches[0],i=Math.abs(t.clientX-r),A=Math.abs(t.clientY-n);(i>3||A>3)&&(clearTimeout(s),s=null)},l=e=>{e.preventDefault(),s&&(i(e),clearTimeout(s),s=null)},c=e=>{t(e),e.preventDefault(),e.stopPropagation()};return $A.isIphoneOrIpadSafari()?(e.addEventListener("touchstart",A),e.addEventListener("touchmove",a),e.addEventListener("touchend",l),window.addEventListener("touchstart",o)):e.addEventListener("contextmenu",c),function(){$A.isIphoneOrIpadSafari()?(e.removeEventListener("touchstart",A),e.removeEventListener("touchmove",a),e.removeEventListener("touchend",l),window.removeEventListener("touchstart",o)):e.removeEventListener("contextmenu",c)}}class py{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 i=this._dot,s=i.style;s["border-radius"]="25px",s.border="solid 2px white",s.background="lightgreen",s.position="absolute",s["z-index"]=void 0===t.zIndex?"40000005":t.zIndex,s.width="8px",s.height="8px",s.visibility=this._visible?"visible":"hidden",s.top="0px",s.left="0px",s["box-shadow"]="0 2px 5px 0 #182A3D;",s.opacity=1,s["pointer-events"]="none",t.onContextMenu,e.appendChild(i);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",(i=>{t.onMouseOver(i,this),e.dispatchEvent(new MouseEvent("mouseover",i))})),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){fy(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 i=this._dot.style;i.left=Math.round(e)-6+"px",i.top=Math.round(t)-6+"px";var s=this._dotClickable.style;s.left=Math.round(e)-14+"px",s.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 gy{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 i=this._label,s=i.style;if(s["border-radius"]="5px",s.color="white",s.padding="4px",s.border="solid 1px",s.background="lightgreen",s.position="absolute",s["z-index"]=void 0===t.zIndex?"5000005":t.zIndex,s.width="auto",s.height="auto",s.visibility="visible",s.top="0px",s.left="0px",s["pointer-events"]="all",s.opacity=1,t.onContextMenu,i.innerText="",e.appendChild(i),this.setPos(t.x||0,t.y||0),this.setFillColor(t.fillColor),this.setBorderColor(t.fillColor),this.setText(t.text),t.onMouseOver&&i.addEventListener("mouseover",(e=>{t.onMouseOver(e,this),e.preventDefault()})),t.onMouseLeave&&i.addEventListener("mouseleave",(e=>{t.onMouseLeave(e,this),e.preventDefault()})),t.onMouseWheel&&i.addEventListener("wheel",(e=>{t.onMouseWheel(e,this)})),t.onMouseDown&&i.addEventListener("mousedown",(e=>{t.onMouseDown(e,this),e.stopPropagation()})),t.onMouseUp&&i.addEventListener("mouseup",(e=>{t.onMouseUp(e,this),e.stopPropagation()})),t.onMouseMove&&i.addEventListener("mousemove",(e=>{t.onMouseMove(e,this)})),t.onContextMenu){fy(i,(e=>{t.onContextMenu(e,this)}))}}setPos(e,t){this._x=e,this._y=t;var i=this._label.style;i.left=Math.round(e)-20+"px",i.top=Math.round(t)-12+"px"}setPosOnWire(e,t,i,s){var r=e+.5*(i-e),n=t+.5*(s-t),A=this._label.style;A.left=Math.round(r)-20+"px",A.top=Math.round(n)-12+"px"}setPosBetweenWires(e,t,i,s,r,n){var A=(e+i+r)/3,o=(t+s+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 my{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 i=this._wire,s=i.style;s.border="solid "+this._thickness+"px "+this._color,s.position="absolute",s["z-index"]=void 0===t.zIndex?"2000001":t.zIndex,s.width="0px",s.height="0px",s.visibility="visible",s.top="0px",s.left="0px",s["-webkit-transform-origin"]="0 0",s["-moz-transform-origin"]="0 0",s["-ms-transform-origin"]="0 0",s["-o-transform-origin"]="0 0",s["transform-origin"]="0 0",s["-webkit-transform"]="rotate(0deg)",s["-moz-transform"]="rotate(0deg)",s["-ms-transform"]="rotate(0deg)",s["-o-transform"]="rotate(0deg)",s.transform="rotate(0deg)",s.opacity=1,s["pointer-events"]="none",t.onContextMenu,e.appendChild(i);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){fy(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,i=this._wire.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._thickness+"px, -"+this._thickness+"px)";var s=this._wireClickable.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._thicknessClickable+"px, -"+this._thicknessClickable+"px)"}setStartAndEnd(e,t,i,s){this._x1=e,this._y1=t,this._x2=i,this._y2=s,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 _y=V.vec2(),by=V.vec2(),By=V.vec2(),yy=V.vec2(),wy=V.vec3(),vy=V.vec3(),Cy=V.vec4(),My=V.vec4(),Ey=V.vec4(),Fy=V.vec4(),Uy=V.mat4(),xy={origin:V.vec3(),direction:V.vec3()},Iy=()=>{},Ty=function(e,t,i,s){const r=(e-V.dotVec3(i,t))/V.dotVec3(s,t);if(r<0)return null;{const e=V.vec3();return V.mulVec3Scalar(s,r,e),V.addVec3(i,e,e),e}};function Py(e,t,i){const s=e.getBoundingClientRect(),r=t.getBoundingClientRect();i[0]+=s.left-r.left,i[1]+=s.top-r.top}const Sy=(e,t,i)=>{Uy.set(e.viewMatrix),Uy.set(e.projMatrix),i.set(t),i[3]=1,V.mulMat4v4(e.viewMatrix,i,i),V.mulMat4v4(e.projMatrix,i,i)},Dy=(e,t,i,s)=>{s[0]=.5*(1+i[0])*e.offsetWidth,s[1]=.5*(1-i[1])*e.offsetHeight,Py(e,t,s)},ky=(e,t,i,s,r,n)=>{const A=e.camera,o=e.canvas.canvas;if(V.distVec3(i,s)<.001)return!1;const a=V.subVec3(s,i,wy);let l=0,c=1;for(let t of e._sectionPlanesState.sectionPlanes){const e=V.dotVec3(t.dir,V.subVec3(t.pos,s,vy)),r=V.dotVec3(t.dir,V.subVec3(t.pos,i,vy));if(r>0&&e>0)return!1;if(r>0||e>0){const e=V.dotVec3(t.dir,a);if(Math.abs(e)>=1e-6){const i=V.dotVec3(t.dir,vy)/e;r>0?l=Math.max(l,i):c=Math.min(c,i)}}}const h=Cy,u=My;Sy(A,l>0?V.addVec3(i,V.mulVec3Scalar(a,l,vy),vy):i,h),Sy(A,c<1?V.addVec3(i,V.mulVec3Scalar(a,c,vy),vy):s,u);const d=h[2]/h[3]<-1||h[3]<0,f=u[2]/u[3]<-1||u[3]<0;if(d&&f)return!1;const p=(h[3]+h[2])/(h[3]+h[2]-(u[3]+u[2]));if(p>0&&p<1){const e=V.subVec4(u,h,Ey);V.mulVec4Scalar(e,p,e),V.addVec4(h,e,d?h:u)}V.mulVec4Scalar(h,1/h[3]),V.mulVec4Scalar(u,1/u[3]);let g=0,m=1;for(let e=0;e<2;++e){const t=u[e]-h[e],i=(-1-h[e])/t,s=(1-h[e])/t;t>0?(g=Math.max(g,i),m=Math.min(m,s)):t<0?(g=Math.max(g,s),m=Math.min(m,i)):h[0]<-1?g=-window.Infinity:h[0]>1&&(m=window.Infinity)}if(g>=m)return!1;const _=V.subVec4(u,h,Ey);return V.addVec4(h,V.mulVec4Scalar(_,m,Fy),u),V.addVec4(h,V.mulVec4Scalar(_,g,Fy),h),V.mulVec4Scalar(h,1/h[3]),V.mulVec4Scalar(u,1/u[3]),Dy(o,t,h,r),Dy(o,t,u,n),!0};class Qy extends PA{constructor(e,t,i,s={}){const r=e.camera;super(e,t),this.__visible=!0;const n=(e,t)=>i=>{e&&e(i),this.fire(t,i,!0)};this._dot=new py(i,{borderColor:s.borderColor,fillColor:s.fillColor,zIndex:s.zIndex,onMouseOver:n(s.onMouseOver,"mouseover"),onMouseLeave:n(s.onMouseLeave,"mouseleave"),onMouseWheel:n(s.onMouseWheel,"wheel"),onMouseDown:n(s.onMouseDown,"mousedown"),onMouseUp:n(s.onMouseUp,"mouseup"),onMouseMove:n(s.onMouseMove,"mousemove"),onTouchstart:n(s.onTouchstart,"touchstart"),onTouchmove:n(s.onTouchmove,"touchmove"),onTouchend:n(s.onTouchend,"touchend"),onContextMenu:n(s.onContextMenu,"contextmenu")});const A=()=>{if(!this.__visible)return;const t=Ey;((e,t)=>{t.set(e),t[3]=1,V.mulMat4v4(r.viewMatrix,t,t),V.mulMat4v4(r.projMatrix,t,t)})(this.worldPos,t),V.mulVec3Scalar(t,1/t[3]);const s=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=>V.dotVec3(e.dir,V.subVec3(e.pos,this.worldPos,wy))>0));this._dot.setCulled(s),s||((t=>{const s=e.canvas.canvas;t[0]=.5*(1+t[0])*s.offsetWidth,t[1]=.5*(1-t[1])*s.offsetHeight,Py(s,i,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 Ry{constructor(e,t,i){const s=e.camera;this._label=new gy(t,i),this._start=V.vec3(),this._mid=V.vec3(),this._end=V.vec3(),this._yOff=0,this.__visible=!0,this._updatePos=()=>{Sy(s,this._start,Cy),V.mulVec4Scalar(Cy,1/Cy[3]),Dy(e.canvas.canvas,t,Cy,_y),this._label.setPos(_y[0],_y[1])};const r=(e,t,i)=>{e[0]+=t[0],e[1]+=t[1],V.mulVec2Scalar(e,.5),this._label.setPos(e[0],e[1]+i)};this._updatePosBetween=()=>{const i=ky(e,t,this._start,this._mid,_y,by),s=ky(e,t,this._end,this._mid,By,yy);this._label.setCulled(!(i||s)),i&&s?(by[0]+=yy[0],by[1]+=yy[1],V.mulVec2Scalar(by,.5),by[0]+=_y[0]+By[0],by[1]+=_y[1]+By[1],V.mulVec2Scalar(by,1/3),this._label.setPos(by[0],by[1])):i?r(_y,by,0):s&&r(By,yy,0)},this._updatePosOnWire=()=>{const i=ky(e,t,this._start,this._end,_y,by)&&V.distVec2(_y,by)>=this._labelMinAxisLength;this._label.setCulled(!i),i&&r(_y,by,this._yOff)};let n=()=>{};this._setUpdatePositions=e=>{n=e,this._updatePositions()},this._updatePositions=()=>{this.__visible&&n()};const A=s.on("viewMatrix",this._updatePositions),o=s.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=()=>{s.off(A),s.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,i,s){this._start.set(e),this._end.set(t),this._yOff=i,this._labelMinAxisLength=s,this._setUpdatePositions(this._updatePosOnWire)}setPosBetween(e,t,i){this._start.set(e),this._mid.set(t),this._end.set(i),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 Oy{constructor(e,t,i){const s=e.camera;this._wire=new my(t,i),this._start=V.vec3(),this._end=V.vec3(),this.__visible=!0,this._updatePositions=()=>{if(!this.__visible)return;const i=ky(e,t,this._start,this._end,_y,by);this._wire.setCulled(!i),i&&this._wire.setStartAndEnd(_y[0],_y[1],by[0],by[1])};const r=s.on("viewMatrix",this._updatePositions),n=s.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=()=>{s.off(r),s.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 Vy=function(e,t){const i=new Qy(e,{},e.canvas.canvas.parentNode,{borderColor:"white",fillColor:t,zIndex:100});return{update:function(e){e&&(i.worldPos=e),i.setVisible(!!e)},setFillColor:e=>i.setFillColor(e),setHighlighted:e=>i.setHighlighted(e),getCanvasPos:()=>i.canvasPos,getWorldPos:()=>i.worldPos,destroy:()=>i.destroy()}},Ly=function(e,t){const i=new Oy(e,e.canvas.canvas.ownerDocument.body,{color:t,thickness:1,thicknessClickable:6});return i.setVisible(!1),{update:(e,t)=>{t&&i.setEnds(e,t),i.setVisible(!!t)},setColor:e=>i.setColor(e),destroy:()=>i.destroy()}};function Hy(e,t){const i=function(e,i){if(e in t)return t[e];if(void 0!==i)return i;throw"config missing: "+e},s=i("viewer"),r=i("ray2WorldPos"),n=i("handleMouseEvents",!1),A=i("handleTouchEvents",!1),o=i("onStart",Iy),a=i("onMove",Iy),l=i("onEnd",Iy),c=s.scene,h=c.canvas.canvas,u=e=>{const t=V.vec2([e.clientX,e.clientY]);Py(h.ownerDocument.documentElement,h,t),a(t,(e=>{const t=V.vec3(),i=V.vec3();return V.canvasPosToWorldRay(h,c.camera.viewMatrix,c.camera.projMatrix,c.camera.projection,e,t,i),r(t,i,e)})(t))};let d=null;const f=function(e){const t=d.matchesEvent(e);t&&u(t)},p=function(t){const i=d.matchesEvent(t);i&&(e.setOpacity(b),d.cleanup(),u(i),l())},g=function(t,i){d&&d.cleanup(),e.setOpacity(1),e.setClickable(!1),s.cameraControl.active=!1,d={matchesEvent:t,cleanup:function(){d=null,e.setClickable(!0),s.cameraControl.active=!0,i()}},o()},m=[],_=function(t,i){const s=e.on(t,i);m.push((()=>e.off(s)))};if(n&&(_("mouseover",(()=>!d&&e.setOpacity(1))),_("mouseleave",(()=>!d&&e.setOpacity(b))),_("mousedown",(e=>{1===e.which&&(h.addEventListener("mousemove",f),h.addEventListener("mouseup",p),g((e=>1===e.which&&e),(()=>{h.removeEventListener("mousemove",f),h.removeEventListener("mouseup",p)})))}))),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(),f(e)})),_("touchend",(e=>{e.preventDefault(),p(e)}))}const b=.8;return e.setOpacity(b),function(){d&&d.cleanup(),m.forEach((e=>e())),e.setOpacity(1)}}function Ny(e){const t=function(t,i){if(t in e)return e[t];if(void 0!==i)return i;throw"config missing: "+t},i=t("viewer"),s=t("handleMouseEvents",!1),r=t("handleTouchEvents",!1),n=t("pointerLens",null),A=t("dots"),o=t("ray2WorldPos"),a=t("onEnd",Iy),l=n?function(e){n.visible=!!e,e&&(n.canvasPos=e)}:()=>{},c=A.map((e=>{let t;return Hy(e,{handleMouseEvents:s,handleTouchEvents:r,viewer:i,ray2WorldPos:(e,i,s)=>o(e,i,s)||t,onStart:()=>{t=e.worldPos.slice(),h(!1,e)},onMove:(t,i)=>{l(t),e.worldPos=i},onEnd:()=>{a(t,e)||(e.worldPos=t),l(null),h(!0,e)}})})),h=(e,t)=>A.forEach((i=>i!==t&&i.setClickable(e)));return h(!0),function(){c.forEach((e=>e())),l(null)}}const Gy=function(e,t,i){return function(s,r,n){const A=e.scene,o=A.canvas.canvas,a=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Py(o.ownerDocument.documentElement,o,t),t),l=e=>{const t=V.vec3(),s=V.vec3();return V.canvasPosToWorldRay(o,A.camera.viewMatrix,A.camera.projMatrix,A.camera.projection,e,t,s),i(t,s)};let c=null;const h=()=>{};let u,d=h;const f=function(){t.stop(),clearTimeout(c),e.cameraControl.active=!0,d=h,u=null},p=function(){f(),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",m),o.removeEventListener("touchend",_)},g=function(i){const n=i.touches;if(1!==n.length)f(),s();else{const i=n[0],s=a(i,V.vec2());l(s)&&(u=i.identifier,d=e=>{V.distVec2(s,e)>20&&f()},c=setTimeout((function(){t.start(s),c=setTimeout((function(){t.stop(),e.cameraControl.active=!1,d=e=>{r(e,l(e))},d(s)}),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,V.vec2()))};o.addEventListener("touchmove",m,{passive:!0});const _=function(e){const t=[...e.changedTouches].find((e=>e.identifier===u));if(t){p();const e=a(t,V.vec2());n(e,l(e))}};return o.addEventListener("touchend",_,{passive:!0}),p}},jy=function(e){const t=[];for(let i=0;i<e.length;++i)t.push(i);const i=function(){const i=V.vec2(),s=V.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]];V.subVec2(A,o,i),V.subVec2(a,o,s);const l=V.dotVec2(i,s)/Math.sqrt(V.sqLenVec2(i)*V.sqLenVec2(s)),c=Math.acos(Math.max(-1,Math.min(l,1)));r+=i[0]*s[1]-i[1]*s[0]>=0?c:2*Math.PI-c}return r<t.length*Math.PI}(),s=function(){const e=(e,t,i)=>(e[0]-i[0])*(t[1]-i[1])-(t[0]-i[0])*(e[1]-i[1]);return(t,i,s,r)=>{const n=e(t,i,s),A=e(t,s,r),o=e(t,r,i);return!((n<0||A<0||o<0)&&(n>0||A>0||o>0))}}(),r=[],n=(i?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=V.vec2(),o=V.vec2();for(;n.length>2;){let t=0;for(;;){if(t>=n.length)throw`isCCW = ${i}; earIdx = ${t}; len = ${n.length}`;const r=n[t],a=e[r.prev.idx],l=e[r.idx],c=e[r.next.idx];if(V.subVec2(a,l,A),V.subVec2(c,l,o),A[0]*o[1]-A[1]*o[0]>=0&&n.every((t=>t===r||t===r.prev||t===r.next||!s(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,i]},Wy=function(e,t){const i=(t,i)=>(i[0]=t.clientX,i[1]=t.clientY,Py(e.ownerDocument.documentElement,e,i),i);let s=!1;const r=[],n=()=>r.forEach((e=>e())),A=(t,i)=>{e.addEventListener(t,i),r.push((()=>e.removeEventListener(t,i)))},o=V.vec2();return A("mousedown",(function(e){1===e.which&&(s=!0,t(i(e,o)))})),A("mousemove",(function(e){i(e,_y),s&&V.distVec2(o,_y)>4&&(s=!1),(s||1&!e.buttons)&&t(_y)})),A("mouseup",(function(e){if(1===e.which&&s){const s=t(i(e,_y));s&&(n(),s())}})),n},zy=function(e,t,i,s){const r=V.vec2(),n=(t,i)=>(i[0]=t.clientX,i[1]=t.clientY,Py(e.ownerDocument.documentElement,e,i),i);let A,o=null,a=Iy;const l=function(){clearTimeout(o),i.stop(),t.active=!0,a=Iy,A=null},c=[],h=()=>c.forEach((e=>e())),u=(t,i)=>{e.addEventListener(t,i,{passive:!0}),c.push((()=>e.removeEventListener(t,i)))};return u("touchstart",(function(e){const c=e.touches;if(1!==c.length)l(),s(null);else{const e=c[0];n(e,r),A=e.identifier,a=e=>{V.distVec2(r,e)>20&&l()},o=setTimeout((function(){i.start(r),o=setTimeout((function(){i.stop(),t.active=!1,a=s,a(r)}),300)}),250)}})),u("touchmove",(function(e){const t=[...e.changedTouches].find((e=>e.identifier===A));t&&a(n(t,_y))})),u("touchend",(function(e){const t=[...e.changedTouches].find((e=>e.identifier===A));if(t){const e=s(n(t,_y));l(),e?(h(),e()):s(null)}})),()=>{l(),h()}},Xy=function(e,t,i,s,r,n){const A=e.canvas.canvas,o=t?function(e,i){t.visible=!!e,e&&(t.canvasPos=e,t.snapped=!!i)}:()=>{},a=function(){const e=(e,t,i)=>t[0]<=Math.max(e[0],i[0])&&t[0]>=Math.min(e[0],i[0])&&t[1]<=Math.max(e[1],i[1])&&t[1]>=Math.min(e[1],i[1]),t=(e,t,i)=>{const s=(t[1]-e[1])*(i[0]-t[0])-(t[0]-e[0])*(i[1]-t[1]);return 0===s?0:s>0?1:2};return function(i,s){const r=s?1:0,n=i[(i.length-2+r)%i.length],A=i[(i.length-1+r)%i.length];for(let s=r;s<i.length-2-1+r;++s){const r=i[s],o=i[s+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=V.normalizeVec3(V.subVec3(e[1],e[0],V.vec3())),i=V.normalizeVec3(V.subVec3(e[2],e[0],wy)),s=V.normalizeVec3(V.cross3Vec3(t,i,V.vec3())),r=V.normalizeVec3(V.cross3Vec3(s,t,V.vec3()));return{normal:s,origin:V.vec3(e[0]),u:t,v:r}}(),c=[];let h;return function t(){const u=l(c);let d=!1;const f=i((t=>{const i=t&&(e=>{const t=s(e),i=t&&t.entity&&(!u||t.snapped)&&t.worldPos;if(u){const t=V.dotVec3(u.normal,u.origin),s=i?t-V.dotVec3(i,u.normal):window.Infinity;if(Math.abs(s)<1e-4){const e=V.vec3();return{worldPos:V.addVec3(i,V.mulVec3Scalar(u.normal,s,e),e),snapped:!0}}return{worldPos:Ty(t,u.normal,e.origin,e.direction),snapped:!1}}return{worldPos:i,snapped:t&&t.snapped}})(((t,i)=>(V.canvasPosToWorldRay(A,e.camera.viewMatrix,e.camera.projMatrix,e.camera.projection,t,i.origin,i.direction),i))(t,xy)),r=i&&i.worldPos;return p(r,t,i&&i.snapped)})),p=(i,s,A)=>{const h=i?e.camera.projectWorldPos(i):s,f=c.length>0&&function(){const t=c[0];return{canvasPos:e.camera.projectWorldPos(t),worldPos:t}}(),p=c.length>=3&&(h&&V.distVec2(h,f.canvasPos)<10||i&&V.compareVec3(i,f.worldPos));o(p?f.canvasPos:h,p||A);const g=s&&(!i||(c.length<3?c.some((e=>V.compareVec3(e,i))):V.compareVec3(c[c.length-1],i))),m=c.concat(p||!i||g?[]:[i]),_=!g&&(u||l(m)),b=_&&m.map((e=>(V.subVec3(e,_.origin,wy),V.vec2([V.dotVec3(wy,_.u),V.dotVec3(wy,_.v)])))),B=!(g||b&&a(b,p)),y=B&&b&&(p||!a(b,!0))&&function(){try{const[e,t,i]=jy(b);return{faces:t,vertices:e.map((e=>V.addVec3(_.origin,V.addVec3(V.mulVec3Scalar(_.u,e[0],wy),V.mulVec3Scalar(_.v,e[1],vy),wy),V.vec3())))}}catch(e){return console.warn("e",e),!1}}();return r(m,p,B,y),d=B&&(p?()=>{o(null),n()}:()=>{c.push(V.vec3(i)),o(null),t()})};h={closePolygon:()=>{const e=c.length>=3&&p(c[0]);return e&&(f(),e()),!!e},placeVertex:()=>(d&&(f(),d()),!!d),popVertex:()=>c.length>0&&(f(),c.pop(),t(),!0),removePressListener:f,updateOnChange:()=>p()}}(),{cancel:()=>{h.removePressListener(),o(null)},closePolygon:()=>h.closePolygon(),placeVertex:()=>h.placeVertex(),popVertex:()=>h.popVertex(),updateOnChange:()=>h.updateOnChange()}};class Ky{constructor(e){this.language="en",this.localeService=e.localeService||new me,this.scene=new qo(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 Ga(this,this.scene),this.id=e.id||this.scene.id,this.camera=this.scene.camera,this.cameraFlight=new xe(this.scene,{duration:.5}),this.cameraControl=new Oa(this.scene,{doublePickFlyTo:!0}),this._plugins=[],this._eventSubs={}}get capabilities(){return this.scene.capabilities}on(e,t){let i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}fire(e,t){const i=this._eventSubs[e];if(i)for(let e=0,s=i.length;e<s;e++)i[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,i=this._plugins.length;t<i;t++){const i=this._plugins[t];if(i===e)return i.clear&&i.clear(),void this._plugins.splice(t,1)}}sendToPlugins(e,t){for(let i=0,s=this._plugins.length;i<s;i++){const s=this._plugins[i];s.send&&s.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,i=this.scene.canvas.canvas,s=i.clientWidth,r=i.clientHeight,n=!e.includeGizmos;t&&(i.width=e.width?Math.floor(e.width):i.width,i.height=e.height?Math.floor(e.height):i.height),this.beginSnapshot(),n&&this.sendToPlugins("snapshotStarting");const A=this.scene._renderer.snapshot.renderSnapshotToCanvas();return t&&(i.width=s,i.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),i={},s=[];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&&(i[e.id]||(i[e.id]=!0,s.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=s.length;e<t;e++){const t=s[e];await(A=t,o={canvas:n,backgroundColor:null,scale:n.width/t.clientWidth},void 0===o&&(o={}),uy(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,i=e.length;t<i;t++){e[t].destroy()}this.scene.destroy()}}async function Zy(e,t){if(!t.src||!Array.isArray(t.src)||6!==t.src.length)throw new Error("src requires path to 6 images");const[i,s,r,n,A,o]=t.src;if(!(i&&s&&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,i)=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>t(s),s.onerror=()=>i(new Error(`Failed to load image: ${e}`)),s.src=e}));try{const[h,u,d,f,p,g]=await Promise.all([c(i),c(s),c(r),c(n),c(A),c(o)]),m=h.width;if(u.width!==m||d.width!==m||f.width!==m||p.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(f,1*m,2*m,m,m),l.drawImage(p,1*m,1*m,m,m),l.drawImage(g,3*m,1*m,m,m);return new Cs(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}}function Jy(e,t){return new as(e,{geometry:new We(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 fs(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})}function Yy(e,t){const i=new We(e,rt({center:[0,0,0],radius:1,heightSegments:60,widthSegments:60})),s=new fs(e,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:t,backfaces:!0});return new as(e,{geometry:i,background:!0,rotation:[0,0,180],material:s,visible:!0,pickable:!1,clippable:!1,collidable:!1})}const $y=V.vec3(),qy=V.vec3();class ew extends Ae{constructor(e,t={}){const i=e.viewer.scene;super(i,t),this.plugin=e;const s=t.container;if(!s)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e){const t=[];let i=!1!==e;return{reg:e=>t.push(e),get:()=>i,set:e=>{i=!1!==e,t.forEach((e=>e(i)))}}};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=i.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 i=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(i))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},f=(t,r,n)=>{const f=new Oy(i,s,{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(f,n),{setEnds:(e,t)=>f.setEnds(e,t),setColor:e=>f.setColor(e)}};this._originWire=f(this._color||"blue",1,[this._visible,this._originWireVisible]),this._targetWire=f(this._color||"red",1,[this._visible,this._targetWireVisible]);this._angleLabel=((t,r,n)=>{const f=new Ry(i,s,{fillColor:t,zIndex:e.zIndex+r,onMouseOver:A,onMouseLeave:o,onMouseWheel:u,onMouseDown:l,onMouseUp:c,onMouseMove:h,onContextMenu:a});return d(f,n),{setFillColor:e=>f.setFillColor(e),setPosOnWire:(e,t,i)=>f.setPosOnWire(e,t,i),setPosBetween:(e,t,i)=>f.setPosBetween(e,t,i),setText:e=>f.setText(e)}})(this._color||"#00BBFF",2,[this._visible,this._angleVisible,this._labelsVisible]);const p=(t,r)=>{const n=new Qy(i,t,s,{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=p(t.origin,[this._visible,this._originVisible]),this._cornerDot=p(t.corner,[this._visible,this._cornerVisible]),this._targetDot=p(t.target,[this._visible,this._targetVisible]),this._update()}_update(){if(!this._targetDot)return;const e=this._originDot.worldPos,t=this._cornerDot.worldPos,i=this._targetDot.worldPos;this._originWire.setEnds(e,t),this._targetWire.setEnds(t,i),this._angleLabel.setPosBetween(e,t,i),V.subVec3(e,t,$y),V.subVec3(i,t,qy),V.lenVec3($y)>0&&V.lenVec3(qy)>0?(V.normalizeVec3($y),V.normalizeVec3(qy),this._angle=Math.abs(V.angleVec3($y,qy))*V.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 tw extends Ae{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class iw extends tw{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,i=this.angleMeasurementsPlugin.viewer.cameraControl,s=this.pointerLens;let r=!1,n=null,A=0,o=0;const a=V.vec3(),l=V.vec2();this._currentAngleMeasurement=null;const c=V.vec2(),h=e=>{e.snappedToVertex||e.snappedToEdge?(s&&(s.visible=!0,s.canvasPos=e.canvasPos,s.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,s.snapped=!0),this.markerDiv.style.background="greenyellow",this.markerDiv.style.border="2px solid green"):(s&&(s.visible=!0,s.canvasPos=e.canvasPos,s.snappedCanvasPos=e.canvasPos,s.snapped=!1),this.markerDiv.style.background="pink",this.markerDiv.style.border="2px solid red");const i=e.snappedCanvasPos||e.canvasPos;switch(r=!0,n=e.entity,a.set(e.worldPos),l.set(i),this._mouseState){case 0:if(this._canvasToPagePos)this._canvasToPagePos(t,i,c),this.markerDiv.style.left=c[0]-5+"px",this.markerDiv.style.top=c[1]-5+"px";else{const e=V.vec2(i);Py(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=i.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=i.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:V.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,s&&(s.visible=!0,s.canvasPos=e.canvasPos,s.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,s.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=i.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=i.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()}}class sw extends qA{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 iw(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,i=e.corner,s=e.target,r=new ew(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},corner:{entity:i.entity,worldPos:i.worldPos},target:{entity:s.entity,worldPos:s.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,i]of Object.entries(this.measurements))i.labelShown=e}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t<i;t++)this.destroyMeasurement(e[t])}destroy(){this.clear(),super.destroy()}}const rw=V.vec2();class nw extends tw{constructor(e,t={}){super(e.viewer.scene),this.pointerLens=t.pointerLens,this.pointerCircle=new ge(e.viewer),this._active=!1;const i=document.createElement("div"),s=this.scene.canvas.canvas;s.parentNode.insertBefore(i,s),i.style.background="black",i.style.border="2px solid blue",i.style.borderRadius="10px",i.style.width="5px",i.style.height="5px",i.style.margin="-200px -200px",i.style.zIndex="100",i.style.position="absolute",i.style.pointerEvents="none",this.markerDiv=i,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,i=t.canvas.canvas;e.pointerLens;const s=V.vec3(),r=20;let n=null;this._touchState=0;const A=V.vec2(),o=V.vec2(),a=V.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,Py(i.ownerDocument.documentElement,i,t),t),f=(e,t)=>(t.set(e),Py(i,i.ownerDocument.documentElement,t),t);i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const a=i.touches.length;if(1!==a)return void(n&&(clearTimeout(n),n=null));const h=i.touches[0];switch(d(h,A),o.set(A),this._touchState){case 0:if(1!==a&&null!==n)return void u();const i=t.pick({canvasPos:o,snapToVertex:this._snapping,snapToEdge:this._snapping});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(f(i.snappedCanvasPos,rw));else{const e=t.pick({canvasPos:o,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(f(e.canvasPos,rw))}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=i.canvasPos,this.pointerLens.snapped=!0),this._currentAngleMeasurement?this._currentAngleMeasurement.origin.worldPos=s:(this._currentAngleMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:i.worldPos,entity:i.entity},corner:{worldPos:i.worldPos,entity:i.entity},target:{worldPos:i.worldPos,entity:i.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(f(e.snappedCanvasPos,rw)),s.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(f(e.canvasPos,rw)),s.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(f(e.snappedCanvasPos,rw)),s.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(f(e.canvasPos,rw)),s.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}),i.addEventListener("touchmove",(e=>{this.pointerCircle.stop();const i=e.touches.length;if(1!==i||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),s.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),s.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!==i&&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!==i&&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}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const c=i.changedTouches[0];if(c.identifier!==l)return;n&&(clearTimeout(n),n=null),d(c,a);const u=a[0],f=a[1];switch(this._touchState){case 1:{if(1!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<A[1]-r)return void(this._touchState=0);const i=t.pick({canvasPos:o,pickSurface:!0});i&&i.worldPos?(this._currentAngleMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:i.worldPos},corner:{worldPos:i.worldPos},target:{worldPos:i.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!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<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!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<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()}}class Aw extends Ae{constructor(e,t,i,s){const r=e.plugin.viewer;super(r.scene);const n=Ny({viewer:r,handleMouseEvents:i,handleTouchEvents:s,pointerLens:t.pointerLens,dots:[e.origin,e.corner,e.target],ray2WorldPos:(e,i,s)=>{const n=e=>{const t=r.scene.pick({canvasPos:s,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const i=!V.compareVec3(e,t.worldPos);return i&&this.fire("edited"),i}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}class ow extends Aw{constructor(e,t){super(e,t,!0,!1)}}class aw extends Aw{constructor(e,t){super(e,t,!1,!0)}}const lw=V.vec3(),cw=V.vec3(),hw=V.vec3(),uw=e=>e+"px";class dw extends PA{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=fy(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>";X.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)})),fy(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>";X.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],i=e[1]+this.canvasPos[1];if(this._marker.style.top=uw(i-12),this._label.style.top=uw(i-17),"legacy"===this._markerAlign)this._marker.style.left=uw(t-12),this._label.style.left=uw(t+40);else{const e=this._curMarkerWidth,i=t+("right"===this._markerAlign?-1:"center"===this._markerAlign?0:1)*(e/2-12);this._marker.style.left=uw(i-e/2);const s=this._curLabelWidth,r=Math.sign(this._labelPosition);this._label.style.left=uw(i+r*(e/2+Math.abs(this._labelPosition)+s/2)-s/2)}const s=90005+Math.floor(this._viewPos[2])+1;this._marker.style["z-index"]=s,this._label.style["z-index"]=s}_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 i=this._values[t];e=e.replace(new RegExp("{{"+t+"}}","g"),i)}return e}setFromPickResult(e){if(e.worldPos&&e.worldNormal){const t=V.normalizeVec3(e.worldNormal,lw),i=this.plugin&&this.plugin.surfaceOffset||0,s=V.mulVec3Scalar(t,i,cw),r=V.addVec3(e.worldPos,s,hw);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 i=e[t];this.setField(t,i)}}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()}}class fw extends qA{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 i=null;e.labelElementId&&((i=document.getElementById(e.labelElementId))||this.error("Can't find DOM element for 'labelElementId' value '"+e.labelElementId+"' - defaulting to internally-generated empty DIV"));const s=new dw(this.viewer.scene,{id:e.id,plugin:this,container:this._container,markerElement:t,labelElement:i,markerHTML:e.markerHTML||this._markerHTML,labelHTML:e.labelHTML||this._labelHTML,occludable:e.occludable,values:X.apply(e.values,X.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?s.setFromPickResult(e.pickResult):(s.entity=e.entity,s.worldPos=e.worldPos),this.annotations[s.id]=s,s.on("destroyed",(()=>{delete this.annotations[s.id],this.fire("annotationDestroyed",s.id)})),this.fire("annotationCreated",s.id),s}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,i=e.length;t<i;t++)this.destroyAnnotation(e[t])}destroy(){this.clear(),super.destroy()}}class pw extends qA{constructor(e,t){super("AxisGizmo",e,t=t||{});const i=e.scene.camera;t.canvasId||t.canvasElement||this.error("Config expected: either 'canvasId' or 'canvasElement'");try{this._axisGizmoScene=new qo(e,{canvasId:t.canvasId,canvasElement:t.canvasElement,transparent:!0})}catch(e){return void this.error(e)}const s=this._axisGizmoScene;s.clearLights(),new BA(s,{color:[.45,.45,.5],intensity:.9}),new wA(s,{dir:[-.5,.5,-.6],color:[.8,.8,.7],intensity:1,space:"view"}),new wA(s,{dir:[.5,-.5,-.6],color:[.8,.8,.8],intensity:1,space:"view"});const r=s.camera;i.on("matrix",(function(){const e=i.eye,t=i.look,s=i.up,n=V.mulVec3Scalar(V.normalizeVec3(V.subVec3(e,t,[])),22);r.look=[0,0,0],r.eye=n,r.up=s}));const n=new We(s,tt({radiusTop:.01,radiusBottom:.6,height:1.7,radialSegments:20,heightSegments:1,openEnded:!1})),A=new We(s,tt({radiusTop:.2,radiusBottom:.2,height:4.5,radialSegments:20,heightSegments:1,openEnded:!1})),o=new fs(s,{diffuse:[1,.3,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),a=new fs(s,{emissive:[1,.3,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),l=new fs(s,{diffuse:[.3,1,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),c=new fs(s,{emissive:[.3,1,.3],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),h=new fs(s,{diffuse:[.3,.3,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),u=new fs(s,{emissive:[.3,.3,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),d=new fs(s,{diffuse:[.5,.5,.5],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2});this._meshes=[new as(s,{geometry:new We(s,rt({radius:9,heightSegments:60,widthSegments:60})),material:new fs(s,{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 as(s,{geometry:new We(s,rt({radius:1})),material:d,pickable:!1,collidable:!1,visible:!1!==t.visible}),new as(s,{geometry:n,material:o,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[5,0,0],rotation:[0,0,-90]}),new as(s,{geometry:A,material:o,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[2,0,0],rotation:[0,0,90]}),new as(s,{geometry:new We(s,ot({text:"X",size:1.5})),material:a,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[7,0,0],billboard:"spherical"}),new as(s,{geometry:n,material:l,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,5,0]}),new as(s,{geometry:A,material:l,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,2,0]}),new as(s,{geometry:new We(s,ot({text:"Y",size:1.5})),material:c,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,7,0],billboard:"spherical"}),new as(s,{geometry:n,material:h,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,0,5],rotation:[90,0,0]}),new as(s,{geometry:A,material:h,pickable:!1,collidable:!1,visible:!1!==t.visible,position:[0,0,2],rotation:[90,0,0]}),new as(s,{geometry:new We(s,ot({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()}}const gw=V.vec3(),mw=V.vec3(),_w=V.vec3(),bw=V.vec3();class Bw extends qA{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,i=t.camera,s=t.realWorldOffset,r=!0===e.reverseClippingPlanes;let n={},A=V.normalizeVec3(V.subVec3(i.look,i.eye,V.vec3())),o=i.eye,a=i.up;i.yUp&&(A=vw(A),o=vw(o),a=vw(a));const l=yw(V.addVec3(o,s));"ortho"===i.projection?n.orthogonal_camera={camera_view_point:l,camera_direction:yw(A),camera_up_vector:yw(a),view_to_world_scale:i.ortho.scale}:n.perspective_camera={camera_view_point:l,camera_direction:yw(A),camera_up_vector:yw(a),field_of_view:i.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?V.negateVec3(t.dir,V.vec3()):t.dir,i.yUp&&(o=vw(o),A=vw(A)),V.addVec3(o,s),o=yw(o),A=yw(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 i=t.positions,s=t.indices;for(let e=0,t=s.length/2;e<t;e++){const t=s[2*e],r=s[2*e+1];n.lines.push({start_point:{x:i[3*t+0],y:i[3*t+1],z:i[3*t+2]},end_point:{x:i[3*r+0],y:i[3*r+1],z:i[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;i.yUp&&(r=vw(r),A=vw(A),o=vw(o)),V.addVec3(r,s),n.bitmaps||(n.bitmaps=[]),n.bitmaps.push({bitmap_type:t.type,bitmap_data:t.imageData,location:yw(r),normal:yw(A),up:yw(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),f=new Set(t.xrayedObjectIds),p=new Set(t.colorizedObjectIds),g=Object.values(t.objects).filter((e=>d.has(e.id)||p.has(e.id)||f.has(e.id))).reduce(((e,i)=>{let s,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}(i.colorize);i.xrayed?(s=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,s=Math.round(255*s).toString(16).padStart(2,"0"),r=s+r):d.has(i.id)&&(s=Math.round(255*i.opacity).toString(16).padStart(2,"0"),r=s+r),e[r]||(e[r]=[]);const n=i.id,A=i.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,i=[];for(let s=0,r=e.length;s<r;s++){const r=e[s],n=t.objects[r];if(n){const e={ifc_guid:n.originalSystemId,originating_system:this.originatingSystem};n.originalSystemId!==r&&(e.authoring_tool_id=r),i.push(e)}}return i}setViewpoint(e,t={}){if(!e)return;const i=this.viewer,s=i.scene,r=s.camera,n=!1!==t.rayCast,A=!1!==t.immediate,o=!1!==t.reset,a=s.realWorldOffset,l=!0===t.reverseClippingPlanes;if(s.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){let t=ww(e.location,gw),i=ww(e.direction,gw);l&&V.negateVec3(i),V.subVec3(t,a),r.yUp&&(t=Cw(t),i=Cw(i)),new ZA(s,{pos:t,dir:i})})),s.clearLines(),e.lines&&e.lines.length>0){const t=[],i=[];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),i.push(r++),i.push(r++))})),new _A(s,{positions:t,indices:i,clippable:!1,collidable:!0})}if(s.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){const t=e.bitmap_type||"jpg",i=e.bitmap_data;let n=ww(e.location,mw),A=ww(e.normal,_w),o=ww(e.up,bw),a=e.height||1;t&&i&&n&&A&&o&&(r.yUp&&(n=Cw(n),A=Cw(A),o=Cw(o)),new Ns(s,{src:i,type:t,pos:n,normal:A,up:o,clippable:!1,collidable:!0,height:a}))})),o&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),s.setObjectsHighlighted(s.highlightedObjectIds,!1),s.setObjectsSelected(s.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(s.setObjectsVisible(s.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!1))))):(s.setObjectsVisible(s.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&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcSpace"),!1),void 0!==r.spaces_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcSpace"),!0),r.space_boundaries_visible,!1===r.openings_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcOpening"),!0),r.space_boundaries_translucent,void 0!==r.openings_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(s.setObjectsSelected(s.selectedObjectIds,!1),e.components.selection.forEach((e=>this._withBCFComponent(t,e,(e=>e.selected=!0))))),e.components.translucency&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),e.components.translucency.forEach((e=>this._withBCFComponent(t,e,(e=>e.xrayed=!0))))),e.components.coloring&&(s.setObjectsColorized(s.colorizedObjectIds,null),e.components.coloring.forEach((e=>{let i=e.color,s=0,r=!1;8===i.length&&(s=parseInt(i.substring(0,2),16)/255,s<=1&&s>=.95&&(s=1),i=i.substring(2),r=!0);const n=[parseInt(i.substring(0,2),16)/255,parseInt(i.substring(2,4),16)/255,parseInt(i.substring(4,6),16)/255];e.components.map((e=>this._withBCFComponent(t,e,(e=>{e.colorize=n,r&&(e.opacity=s)}))))})))}if(e.perspective_camera||e.orthogonal_camera){let o,l,c,h;if(e.perspective_camera?(o=ww(e.perspective_camera.camera_view_point,gw),l=ww(e.perspective_camera.camera_direction,gw),c=ww(e.perspective_camera.camera_up_vector,gw),r.perspective.fov=e.perspective_camera.field_of_view,h="perspective"):(o=ww(e.orthogonal_camera.camera_view_point,gw),l=ww(e.orthogonal_camera.camera_direction,gw),c=ww(e.orthogonal_camera.camera_up_vector,gw),r.ortho.scale=e.orthogonal_camera.view_to_world_scale,h="ortho"),V.subVec3(o,a),r.yUp&&(o=Cw(o),l=Cw(l),c=Cw(c)),n){const e=s.pick({pickSurface:!0,origin:o,direction:l});l=e?e.worldPos:V.addVec3(o,l,gw)}else l=V.addVec3(o,l,gw);A?(r.eye=o,r.look=l,r.up=c,r.projection=h):i.cameraFlight.flyTo({eye:o,look:l,up:c,duration:t.duration,projection:h})}}_withBCFComponent(e,t,i){const s=this.viewer,r=s.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 i(A);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[n])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}}if(t.ifc_guid){const n=t.ifc_guid,A=r.objects[n];if(A)return void i(A);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[n])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}Object.keys(r.models).forEach((t=>{const A=V.globalizeObjectId(t,n),o=r.objects[A];if(o)i(o);else if(e.updateCompositeObjects){s.metaScene.metaObjects[A]&&r.withObjects(s.metaScene.getObjectIDsInSubtree(A),i)}}))}}destroy(){super.destroy()}}function yw(e){return{x:e[0],y:e[1],z:e[2]}}function ww(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function vw(e){return new Float64Array([e[0],-e[2],e[1]])}function Cw(e){return new Float64Array([e[0],e[2],-e[1]])}const Mw=V.vec3(),Ew=V.vec3(),Fw=V.vec3();V.vec4(),V.vec4(),V.vec4();class Uw extends Ae{constructor(e,t={}){const i=e.viewer.scene;super(i,t),this.plugin=e;const s=t.container;if(!s)throw"config missing: container";this._color=t.color||e.defaultColor;const r=function(e,t){const i=[];let s=void 0!==e?Boolean(e):t;return{reg:e=>i.push(e),get:()=>s,set:e=>{s=void 0!==e?Boolean(e):t,i.forEach((e=>e(s)))}}};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=V.identityMat4(),this.approximate=t.approximate,this._labelStringFormat=e=>{const t=this.plugin.viewer.scene.metrics,i=t.scale,s=t.unitsInfo[t.units].abbrev;return(this.approximate?" ~ ":" = ")+(e*i).toFixed(2)+s};const n=i.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=i.metrics.on("units",(()=>this._update()));this._cleanups.push((()=>i.metrics.off(t)))})),this._drawables=[];const d=(e,t)=>{const i=()=>e.setVisible(t.every((e=>e.get())));t.forEach((e=>e.reg(i))),this._drawables.push(e),this._cleanups.push((()=>e.destroy()))},f=(t,r,n)=>{const f=new Oy(i,s,{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(f,n),{setEnds:(e,t)=>f.setEnds(e,t),setColor:e=>f.setColor(e)}};this._lengthWire=f(this._color,2,[this._visible,this._wireVisible]),this._xAxisWire=f("red",1,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible]),this._yAxisWire=f("green",1,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible]),this._zAxisWire=f("blue",1,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible]);const p=(t,r,n)=>{const f=new Ry(i,s,{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(f,n),{setFillColor:e=>f.setFillColor(e),setPosOnWire:(e,t,i,s)=>f.setPosOnWire(e,t,i,s),setPosBetween:(e,t,i)=>f.setPosBetween(e,t,i),setText:e=>f.setText(e.replace(/ /g," "))}};this._lengthLabel=p(this._color,4,[this._visible,this._wireVisible,this._labelsVisible,this._clickable,this._axisEnabled,this._lengthLabelEnabled]),this._xAxisLabel=p("red",3,[this._visible,this._axisEnabled,this._axisVisible,this._xAxisVisible,this._labelsVisible,this._clickable,this._xLabelEnabled]),this._yAxisLabel=p("green",3,[this._visible,this._axisEnabled,this._axisVisible,this._yAxisVisible,this._labelsVisible,this._clickable,this._yLabelEnabled]),this._zAxisLabel=p("blue",3,[this._visible,this._axisEnabled,this._axisVisible,this._zAxisVisible,this._labelsVisible,this._clickable,this._zLabelEnabled]);const g=(t,r)=>{const n=new Qy(i,t,s,{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,i=this._axesBasis,s=V.subVec3(t,e,Mw),r=V.transformVec3(i,s,s),n=this._useRotationAdjustment.get()&&Math.abs(s[1])>0,A=(i,s)=>{const r=this.plugin.viewer.scene.metrics,A=r.scale;r.unitsInfo[r.units].abbrev;const o=(i,s,r,n)=>{this._labelsOnWires.get()?i.setPosOnWire(s,r,0,this.plugin.labelMinAxisLength):i.setPosOnWire(e,t,35*n,0)};this._xAxisWire.setEnds(e,i),o(this._xAxisLabel,e,i,1),this._xAxisLabel.setText("X"+this._labelStringFormat(V.distVec3(e,i))),this._yAxisWire.setEnds(i,s),o(this._yAxisLabel,i,s,2),this._yAxisLabel.setText("Y"+this._labelStringFormat(V.distVec3(i,s))),this._zAxisWire.setEnds(s,t),o(this._zAxisLabel,s,t,3),this._zAxisLabel.setText((n?"":"Z")+this._labelStringFormat(V.distVec3(s,t))),this._lengthWire.setEnds(e,t),o(this._lengthLabel,e,t,0);const a=V.distVec3(e,t);this._length=a*A,this._lengthLabel.setText(this._labelStringFormat(a))};n?(Fw[0]=e[0],Fw[1]=t[1],Fw[2]=e[2],A(e,Fw)):(Ew[0]=e[0]+i[0]*r[0],Ew[1]=e[1]+i[4]*r[0],Ew[2]=e[2]+i[8]*r[0],Fw[0]=Ew[0]+i[1]*r[1],Fw[1]=Ew[1]+i[5]*r[1],Fw[2]=Ew[2]+i[9]*r[1],A(Ew,Fw))}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 xw extends Ae{get active(){}set snapping(e){}get snapping(){return!0}activate(){}deactivate(){}reset(){}get currentMeasurement(){return null}destroy(){}}class Iw extends xw{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,i=e.viewer.cameraControl,s=t.canvas.canvas;t.input;let r=!1;const n=V.vec3(),A=V.vec2();let o,a;let l=null;this._mouseState=0;const c=V.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(s,t,c),this._markerDiv.style.left=c[0]-5+"px",this._markerDiv.style.top=c[1]-5+"px";else{const e=V.vec2(t);Py(s,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";s.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=i.on("hoverSnapOrSurface",(e=>{this._snapping&&h(e)})),this._onHoverSurface=i.on("hoverSurface",(e=>{this._snapping||h(e)})),s.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(o=e.clientX,a=e.clientY)}),s.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:V.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),s.style.cursor="default"};this._onHoverSnapOrSurfaceOff=i.on("hoverSnapOrSurfaceOff",(e=>{this._snapping&&u(e)})),this._onHoverOff=i.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()}}class Tw extends qA{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 Iw(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,i=e.target,s=new Uw(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:i.entity,worldPos:i.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[s.id]=s,s.clickable=!0,s.on("destroyed",(()=>{delete this._measurements[s.id]})),this.fire("measurementCreated",s),s}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,i]of Object.entries(this.measurements))i.labelShown=e}setAxisVisible(e){for(const[t,i]of Object.entries(this.measurements))i.axisVisible=e;this.defaultAxisVisible=e}getAxisVisible(){return this.defaultAxisVisible}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t<i;t++)this.destroyMeasurement(e[t])}destroy(){this.clear(),super.destroy()}}const Pw=V.vec2();class Sw extends xw{constructor(e,t={}){super(e.viewer.scene),this.pointerLens=t.pointerLens,this.pointerCircle=new ge(e.viewer),this._active=!1;const i=document.createElement("div"),s=this.scene.canvas.canvas;s.parentNode.insertBefore(i,s),i.style.background="black",i.style.border="2px solid blue",i.style.borderRadius="10px",i.style.width="5px",i.style.height="5px",i.style.margin="-200px -200px",i.style.zIndex="100",i.style.position="absolute",i.style.pointerEvents="none",this.markerDiv=i,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,i=t.canvas.canvas;e.pointerLens;const s=V.vec3(),r=20;let n=null;this._touchState=0;const A=V.vec2(),o=V.vec2(),a=V.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,Py(i.ownerDocument.documentElement,i,t),t),f=(e,t)=>(t.set(e),Py(i,i.ownerDocument.documentElement,t),t);i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const a=i.touches.length;if(1!==a)return void(n&&(clearTimeout(n),n=null));const h=i.touches[0];switch(d(h,A),o.set(A),this._touchState){case 0:if(1!==a&&null!==n)return void u();const i=t.pick({canvasPos:o,snapping:this._snapping,snapToEdge:this._snapping});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(f(i.snappedCanvasPos,Pw));else{const e=t.pick({canvasPos:o,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(f(e.canvasPos,Pw))}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=i.canvasPos,this.pointerLens.snapped=!0),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=s:(this._currentDistanceMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:s,entity:i.entity},target:{worldPos:s,entity:i.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(f(e.snappedCanvasPos,Pw)),s.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(f(e.canvasPos,Pw)),s.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}),i.addEventListener("touchmove",(i=>{this.pointerCircle.stop();const r=i.touches.length;if(1!==r||1!==i.changedTouches.length)return void(n&&(clearTimeout(n),n=null));const A=i.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),s.set(a.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=a.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:V.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),s.set(c.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=c.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:V.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}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const c=i.changedTouches[0];if(c.identifier!==l)return;n&&(clearTimeout(n),n=null),d(c,a);const u=a[0],f=a[1];switch(this._touchState){case 1:{if(1!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<A[1]-r)return void(this._touchState=0);const i=t.pick({canvasPos:o,pickSurface:!0});i&&i.worldPos?(this._currentDistanceMeasurement=e.createMeasurement({id:V.createUUID(),origin:{worldPos:i.worldPos,entity:i.entity},target:{worldPos:i.worldPos,entity:i.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!==s||u>A[0]+r||u<A[0]-r||f>A[1]+r||f<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()}}class Dw extends Ae{constructor(e,t,i,s){const r=e.plugin.viewer;super(r.scene);const n=Ny({viewer:r,handleMouseEvents:i,handleTouchEvents:s,pointerLens:t.pointerLens,dots:[e.origin,e.target],ray2WorldPos:(e,i,s)=>{const n=e=>{const t=r.scene.pick({canvasPos:s,snapToEdge:e,snapToVertex:e,pickSurface:!0});return t&&t.worldPos?t.worldPos:e&&n(!1)};return n(!!t.snapping)},onEnd:(e,t)=>{const i=!V.compareVec3(e,t.worldPos);return i&&this.fire("edited"),i}}),A=e.on("destroyed",n);this._deactivate=function(){e.off("destroyed",A),n()}}deactivate(){this._deactivate(),super.destroy()}}class kw extends Dw{constructor(e,t){super(e,t,!0,!1)}}class Qw extends Dw{constructor(e,t){super(e,t,!1,!0)}}class Rw extends qA{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 i=1e3*this._delayBeforeRestoreSeconds,s=!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(),s=!1};this._onCameraMatrix=e.scene.camera.on("matrix",(()=>{i=1e3*this._delayBeforeRestoreSeconds,s||(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()),s=!0)})),this._onSceneTick=e.scene.on("tick",(e=>{s&&(i-=e.deltaTime,(!this._delayBeforeRestore||i<=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()}}class Ow{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,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getGLTF(e,t,i){X.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getGLB(e,t,i){X.loadArraybuffer(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getArrayBuffer(e,t,i,s){!function(e,t,i,s){var r=()=>{};i=i||r,s=s||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);ie.scheduleTask((function(){i(e)}))}catch(e){ie.scheduleTask((function(){s(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?i(A.response):s("loadArrayBuffer error : "+A.response))},A.send(null)}}(this._cacheBusterURL(e),t,(e=>{i(e)}),(function(e){s(e)}))}}class Vw{constructor(e){}load(e,t,i,s,r,n,A){!function(e,t,i,s,r,n,A){const o=e.viewer.scene.canvas.spinner;o.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(a=>{s.basePath=Lw(t),Hw(e,t,a,i,s,r,n,A),o.processes--}),(e=>{o.processes--,A(e)})):e.dataSource.getGLTF(t,(a=>{s.basePath=Lw(t),Hw(e,t,a,i,s,r,n,A),o.processes--}),(e=>{o.processes--,A(e)}))}(e,t,i,s=s||{},r,(function(){ie.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,i,s,r,n,A){Hw(e,"",t,i,s=s||{},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 Lw(e){const t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}function Hw(e,t,i,s,r,n,A,o){const a=e.viewer.scene.canvas.spinner;a.processes++,Lc(i,Xd,{...r.parseOptions||{},baseUri:r.basePath}).then((i=>{const o=function(e,t){return(new rf).postProcess(e,t)}(i),l={src:t,entityId:r.entityId,metaModelJSON:s,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 i=0,s=t.length;i<s;i++)Nw(e,t[i])}(l),function(e){const t=e.gltfData.materials;if(t)for(let i=0,s=t.length;i<s;i++){const s=t[i];s._textureSetId=Gw(e,s),s._attributes=jw(e,s)}}(l),r.autoMetaModel&&l.metaObjects.push({id:n.id,type:"Default",name:n.id}),Ww(l),n.finalize(),r.autoMetaModel&&e.viewer.metaScene.createMetaModel(n.id,{metaObjects:l.metaObjects}),a.processes--,A()})).catch((e=>{o&&o(e)}))}function Nw(e,t){if(!t.source||!t.source.image)return;const i="texture-"+e.nextId++;let s=1005;switch(t.sampler.minFilter){case 9728:s=1003;break;case 9729:s=1006;break;case 9984:s=1004;break;case 9985:s=1007;break;case 9986:s=1005;break;case 9987:s=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:i,image:t.source.image,flipY:!!t.flipY,minFilter:s,magFilter:r,wrapS:n,wrapT:A,wrapR:o,encoding:3001}),t._textureId=i}function Gw(e,t){const i={};switch(t.normalTexture&&(i.normalTextureId=t.normalTexture.texture._textureId),t.occlusionTexture&&(i.occlusionTextureId=t.occlusionTexture.texture._textureId),t.emissiveTexture&&(i.emissiveTextureId=t.emissiveTexture.texture._textureId),t.alphaMode){case"OPAQUE":break;case"MASK":const e=t.alphaCutoff;i.alphaCutoff=void 0!==e?e:.5}const s=t.pbrMetallicRoughness;if(t.pbrMetallicRoughness){const r=t.pbrMetallicRoughness,n=r.baseColorTexture||r.colorTexture;n&&(n.texture?i.colorTextureId=n.texture._textureId:i.colorTextureId=e.gltfData.textures[n.index]._textureId),s.metallicRoughnessTexture&&(i.metallicRoughnessTextureId=s.metallicRoughnessTexture.texture._textureId)}const r=t.extensions;if(r){const t=r.KHR_materials_pbrSpecularGlossiness;if(t){t.specularTexture;const s=t.specularColorTexture;null!=s&&(i.colorTextureId=e.gltfData.textures[s.index]._textureId)}}return void 0!==i.normalTextureId||void 0!==i.occlusionTextureId||void 0!==i.emissiveTextureId||void 0!==i.colorTextureId||void 0!==i.metallicRoughnessTextureId?(i.id=`textureSet-${e.nextId++};`,e.sceneModel.createTextureSet(i),i.id):null}function jw(e,t){const i=t.extensions,s={color:new Float32Array([1,1,1,1]),opacity:1,metallic:0,roughness:1,doubleSided:!0};if(i){const e=i.KHR_materials_pbrSpecularGlossiness;if(e){const t=e.diffuseFactor;null!=t&&s.color.set(t)}const t=i.KHR_materials_common;if(t){const e=t.technique,i=t.values||{},r="BLINN"===e,n="PHONG"===e,A="LAMBERT"===e,o=i.diffuse;o&&(r||n||A)&&(X.isString(o)||s.color.set(o));const a=i.transparency;null!=a&&(s.opacity=a);const l=i.transparent;null!=l&&(s.opacity=l)}}const r=t.pbrMetallicRoughness;if(r){const e=r.baseColorFactor;e&&(s.color[0]=e[0],s.color[1]=e[1],s.color[2]=e[2],s.opacity=e[3]);const t=r.metallicFactor;null!=t&&(s.metallic=t);const i=r.roughnessFactor;null!=i&&(s.roughness=i)}return s.doubleSided=!1!==t.doubleSided,s}function Ww(e){const t=e.gltfData,i=t.scene||t.scenes[0];if(!i)return void function(e,t){e.plugin.error(t)}(e,"glTF has no default scene");const s=i.nodes;if(!s)return;!function e(t){t.forEach((t=>{const i=t.mesh;i&&(i.instances||=0,i.instances+=1),t.children&&e(t.children)}))}(s);const r=[];let n=null;!function t(i,s,A){i.forEach((i=>{const o=i.name;let a=null!=o&&o||0===s&&"entity-"+e.nextId++;if(a){for(;e.sceneModel.objects[a];)a="entity-"+e.nextId++;r.push(n),n=[]}const l=function(e,t){let i;e.matrix&&(i=e.matrix,t=t?V.mulMat4(t,i,V.mat4()):i);e.translation&&(i=V.translationMat4v(e.translation),t=t?V.mulMat4(t,i,V.mat4()):i);e.rotation&&(i=V.quaternionToMat4(e.rotation),t=t?V.mulMat4(t,i,V.mat4()):i);e.scale&&(i=V.scalingMat4v(e.scale),t=t?V.mulMat4(t,i,V.mat4()):i);return t}(i,A);if(i.mesh&&function(e,t,i,s){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),i?V.transformPositions3(i,A.localPositions,A.positions):A.positions.set(A.localPositions);const c=V.vec3();Ct(A.positions,A.positions,c)&&(A.origin=c),t.sceneModel.createMesh(A),s.push(A.id)}}(i,e,l,n),i.children&&t(i.children,s+1,l),a){if(n.length>0){const t=e.globalizeObjectIds?V.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()}}))}(s,0,null)}const zw={DEFAULT:{}};class Xw extends qA{constructor(e,t={}){super("GLTFLoader",e,t),this._sceneModelLoader=new Vw(this,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new Ow}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||zw}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 mA(this.viewer.scene,X.apply(e,{isModel:!0,dtxEnabled:e.dtxEnabled})),i=t.id;if(!e.src&&!e.gltf)return this.error("load() param expected: src or gltf"),t;if(e.metaModelSrc||e.metaModelJSON){const s=s=>{this.viewer.metaScene.createMetaModel(i,s,{}),this.viewer.scene.canvas.spinner.processes--,e.src?this._sceneModelLoader.load(this,e.src,s,e,t):this._sceneModelLoader.parse(this,e.gltf,s,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--,s(e)}),(e=>{this.error(`load(): Failed to load model metadata for model '${i} from '${t}' - ${e}`),this.viewer.scene.canvas.spinner.processes--}))}else e.metaModelJSON&&s(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(i)})),t}destroy(){super.destroy()}}function Kw(e,t,i={}){const s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",n=i.textColor||"black",A=i.canvasElement||document.body,o=500,a=o+o/3,l=a/24,c=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.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]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.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++)V.normalizeVec3(h[e].dir,h[e].dir),V.normalizeVec3(h[e].up,h[e].up);for(let e=0,t=u.length;e<t;e++)V.normalizeVec3(u[e].dir,u[e].dir),V.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=s,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 f=this._textureCanvas.getContext("2d");let p=!1;function g(){for(let e=0,t=c.length;e<t;e++){const t=c[e],i=t.boundary,s=Math.round(i[0]*l),r=Math.round(i[1]*l),n=Math.round(i[2]*l),A=Math.round(i[3]*l);f.fillStyle=t.color,f.fillRect(s,r,n,A)}for(let t=0,a=d.length;t<a;t++){let a,c,h,u;const p=d[t],g=p.boundaries;for(var e=0,i=g.length;e<i;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),p.highlighted&&(f.fillStyle=p.highlighted?r:p.color||s,f.fillRect(a,c,h,u))}if(p.label){f.fillStyle=n,f.font="60px sans-serif",f.textAlign="center";var A=a+.5*h,o=c+.7*u;f.fillText(m(p.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"},i={"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":"FRONT","NavCube.back":"BACK","NavCube.right":"RIGHT","NavCube.left":"LEFT","NavCube.top":"TOP","NavCube.bottom":"BOTTOM"};return function(r){const n=p?i:t,A=n?n[r]:null;return A?e.localeService.translate(A)||s[A]||A:r}}();this.setZUp=function(){p=!0,d=h,this.clear()},this.setYUp=function(){p=!1,d=u,this.clear()},this.clear=function(){f.fillStyle=s,f.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,i=o-e[1]*o;for(var s=0,r=d.length;s<r;s++){const e=d[s].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&&i>=r[1]*l&&i<=(r[1]+r[3])*l)return s}}return-1},this.setAreaHighlighted=function(e,t){var i=d[e];if(!i)throw"Area not found: "+e;i.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 Zw=V.vec3(),Jw=V.vec3();V.mat4();class Yw extends qA{constructor(e,t={}){super("NavCube",e,t),e.navCube=this;try{this._navCubeScene=new qo(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 i=this._navCubeScene;i.clearLights(),new wA(i,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new wA(i,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new wA(i,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._navCubeCamera=i.camera,this._navCubeCamera.ortho.scale=7,this._navCubeCamera.ortho.near=.1,this._navCubeCamera.ortho.far=2e3,i.edgeMaterial.edgeColor=[.2,.2,.2],i.edgeMaterial.edgeAlpha=.6,this._zUp=Boolean(e.camera.zUp);var s=this;this.setIsProjectNorth(t.isProjectNorth),this.setProjectNorthOffsetAngle(t.projectNorthOffsetAngle);const r=function(){const e=V.mat4();return function(t,i,r){return V.identityMat4(e),V.rotationMat4v(t*s._projectNorthOffsetAngle*V.DEGTORAD,[0,1,0],e),V.transformVec3(e,i,r)}}();this._synchCamera=function(){var t=V.rotationMat4c(-90*V.DEGTORAD,1,0,0),i=V.vec3(),n=V.vec3(),A=V.vec3();return function(){var o=e.camera.eye,a=e.camera.look,l=e.camera.up;i=V.mulVec3Scalar(V.normalizeVec3(V.subVec3(o,a,i)),5),s._isProjectNorth&&s._projectNorthOffsetAngle&&(i=r(-1,i,Zw),l=r(-1,l,Jw)),s._zUp?(V.transformVec3(t,i,n),V.transformVec3(t,l,A),s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=V.transformVec3(t,i,n),s._navCubeCamera.up=V.transformPoint3(t,l,A)):(s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=i,s._navCubeCamera.up=l)}}(),this._cubeTextureCanvas=new Kw(e,i,t),this._cubeSampler=new Cs(i,{image:this._cubeTextureCanvas.getImage(),flipY:!0,wrapS:1001,wrapT:1001}),this._cubeMesh=new as(i,{geometry:new We(i,{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 fs(i,{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 as(i,{geometry:new We(i,tt({center:[0,0,0],radiusTop:.001,radiusBottom:1.4,height:.01,radialSegments:20,heightSegments:1,openEnded:!0})),material:new fs(i,{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,i){var s=(t-a)*-f,r=(i-l)*-f;e.camera.orbitYaw(s),e.camera.orbitPitch(-r),a=t,l=i}function o(e){const{left:t,top:i}=s._navCubeCanvas.getBoundingClientRect();return[e.clientX-t,e.clientY-i]}var a,l,c=null,h=null,u=!1,d=!1,f=.5;s._navCubeCanvas.addEventListener("mouseenter",s._onMouseEnter=function(e){d=!0}),s._navCubeCanvas.addEventListener("mouseleave",s._onMouseLeave=function(e){d=!1}),s._navCubeCanvas.addEventListener("mousedown",s._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}),s=i.pick({canvasPos:t});u=!!s}}),s._navCubeCanvas.addEventListener("mouseup",s._onMouseUp=function(e){if(1===e.which&&(u=!1,null!==c)){var t=o({clientX:e.clientX,clientY:e.clientY}),A=i.pick({canvasPos:t,pickSurface:!0});if(A&&A.uv){var a=s._cubeTextureCanvas.getArea(A.uv);if(a>=0&&(s._navCubeCanvas.style.cursor="pointer",n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),a>=0)){if(s._cubeTextureCanvas.setAreaHighlighted(a,!0),n=a,s._repaint(),e.x<c-3||e.x>c+3||e.y<h-3||e.y>h+3)return;var l=s._cubeTextureCanvas.getAreaDir(a);if(l){var d=s._cubeTextureCanvas.getAreaUp(a);s._isProjectNorth&&s._projectNorthOffsetAngle&&(l=r(1,l,Zw),d=r(1,d,Jw)),p(l,d,(function(){n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),s._navCubeCanvas.style.cursor="pointer",n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),a>=0&&(s._cubeTextureCanvas.setAreaHighlighted(a,!1),n=-1,s._repaint())}))}}}}}),s._navCubeCanvas.addEventListener("mousemove",s._onMouseMove=function(e){if(n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1),1!==e.buttons||u){if(u){var t=e.clientX,r=e.clientY;return s._navCubeCanvas.style.cursor="move",void A(t,r)}if(d){var a=o({clientX:e.clientX,clientY:e.clientY}),l=i.pick({canvasPos:a,pickSurface:!0});if(l){if(l.uv){s._navCubeCanvas.style.cursor="pointer";var c=s._cubeTextureCanvas.getArea(l.uv);if(c===n)return;n>=0&&s._cubeTextureCanvas.setAreaHighlighted(n,!1),c>=0&&(s._cubeTextureCanvas.setAreaHighlighted(c,!0),s._repaint(),n=c)}}else s._navCubeCanvas.style.cursor="default",n>=0&&(s._cubeTextureCanvas.setAreaHighlighted(n,!1),s._repaint(),n=-1)}}}),s._navCubeCanvas.addEventListener("touchstart",s._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}),s=i.pick({canvasPos:t});u=!!s}},{passive:!1}),s._navCubeCanvas.addEventListener("touchmove",s._onTouchMove=function(e){e.preventDefault();var t=e.touches[0],i=t.clientX,r=t.clientY,n=document.elementFromPoint(i,r);(d=s._navCubeCanvas===n)&&u&&A(i,r)},{passive:!1}),s._navCubeCanvas.addEventListener("touchend",s._onTouchEnd=function(e){u=!1});var p=function(){var t=V.vec3();return function(i,r,n){var A=s._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,o=V.getAABB3Diag(A);V.getAABB3Center(A,t);var a=Math.abs(o/Math.tan(s._cameraFitFOV*V.DEGTORAD));e.cameraControl.pivotPos=t,s._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-a*i[0],t[1]-a*i[1],t[2]-a*i[2]],up:r||[0,1,0],orthoScale:1.1*o,fitFOV:s._cameraFitFOV,duration:s._cameraFlyDuration},n):e.cameraFlight.jumpTo({look:t,eye:[t[0]-a*i[0],t[1]-a*i[1],t[2]-a*i[2]],up:r||[0,1,0],orthoScale:1.1*o,fitFOV:s._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()}}const $w=V.vec3();class qw{load(e,t,i={}){var s=e.scene.canvas.spinner;s.processes++,ev(e,t,(function(t){!function(e,t,i){for(var s=t.basePath,r=Object.keys(t.materialLibraries),n=r.length,A=0,o=n;A<o;A++)iv(e,s,s+r[A],(function(){0==--n&&i()}))}(e,t,(function(){rv(e,t),s.processes--,ie.scheduleTask((function(){e.fire("loaded",!0,!1)}))}))}))}parse(e,t,i,s){if(t){var r=tv(e,t,null);i&&sv(e,i,s),rv(e,r),e.src=null,e.fire("loaded",!0,!1)}else this.warn("load() param expected: objText")}}var ev=function(e,t,i){nv(t,(function(s){var r=tv(e,s,t);i(r)}),(function(t){e.error(t)}))},tv=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(i,s,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!==s.indexOf("\r\n")&&(s=s.replace("\r\n","\n"));for(var a=s.split("\n"),l="",u="",d="",f=[],p="function"==typeof"".trimLeft,g=0,m=a.length;g<m;g++)if(l=a[g],0!==(l=p?l.trimLeft():l.trim()).length&&"#"!==(u=l.charAt(0)))if("v"===u)if(" "===(d=l.charAt(1))&&null!==(f=e.vertex_pattern.exec(l)))o.positions.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));else if("n"===d&&null!==(f=e.normal_pattern.exec(l)))o.normals.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));else{if("t"!==d||null===(f=e.uv_pattern.exec(l)))return void i.error("Unexpected vertex/normal/uv line: '"+l+"'");o.uv.push(parseFloat(f[1]),parseFloat(f[2]))}else if("f"===u)if(null!==(f=e.face_vertex_uv_normal.exec(l)))c(o,f[1],f[4],f[7],f[10],f[2],f[5],f[8],f[11],f[3],f[6],f[9],f[12]);else if(null!==(f=e.face_vertex_uv.exec(l)))c(o,f[1],f[3],f[5],f[7],f[2],f[4],f[6],f[8]);else if(null!==(f=e.face_vertex_normal.exec(l)))c(o,f[1],f[3],f[5],f[7],void 0,void 0,void 0,void 0,f[2],f[4],f[6],f[8]);else{if(null===(f=e.face_vertex.exec(l)))return void i.error("Unexpected face line: '"+l+"'");c(o,f[1],f[2],f[3],f[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!==(f=e.object_pattern.exec(l))){t(o,C=f[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===(f=e.smoothing_pattern.exec(l))){if("\0"===l)continue;return void i.error("Unexpected line: '"+l+"'")}var M=f[1].trim().toLowerCase();o.object.material.smooth="1"===M||"on"===M}return o};function t(e,t,i){if(e.object&&!1===e.object.fromDeclaration)return e.object.id=t,void(e.object.fromDeclaration=!1!==i);e.object={id:t||"",geometry:{positions:[],normals:[],uv:[]},material:{id:"",smooth:!0},fromDeclaration:!1!==i},e.objects.push(e.object)}function i(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function s(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function n(e,t,i,s){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[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function A(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function o(e,t,i,s){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[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function a(e,t,i,s){var r=e.uv,n=e.object.geometry.uv;n.push(r[t+0]),n.push(r[t+1]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[s+0]),n.push(r[s+1])}function l(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,A,l,c,h,u,d,f,p,g,m,_){var b,B=e.positions.length,y=i(t,B),w=i(A,B),v=i(l,B);if(void 0===c?n(e,y,w,v):(n(e,y,w,b=i(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(f,C)),a(e,w,v,b))}if(void 0!==p){var M=e.normals.length;y=s(p,M),w=p===g?y:s(g,M),v=p===m?y:s(m,M),void 0===c?o(e,y,w,v):(o(e,y,w,b=s(_,M)),o(e,w,v,b))}}function h(e,t,s){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,i(t[a],n));for(var h=0,u=s.length;h<u;h++)l(e,r(s[h],o))}}();var iv=function(e,t,i,s){nv(i,(function(i){sv(e,i,t),s()}),(function(t){e.error(t),s()}))},sv=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 f=0;f<h.length;f++)if(0!==(A=h[f].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":i(e,u),u={id:l},d=!0;break;case"ka":u.ambient=s(l);break;case"kd":u.diffuse=s(l);break;case"ks":u.specular=s(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&&i(e,u)};function t(e,t,i,s){var r={},n=i.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=s||"linear",new Cs(e,r).id}function i(e,t){new fs(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function rv(e,t){for(var i=0,s=t.objects.length;i<s;i++){var r=t.objects[i],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 s=$w;Ct(n.positions,n.positions,s);var l,c=new We(e,A),h=r.material.id;h&&""!==h?(l=e.scene.components[h])||e.error("Material not found: "+h):l=new fs(e,{diffuse:[.6,.6,.6],backfaces:!0});var u=new as(e,{id:e.id+"#"+r.id,origin:0!==s[0]||0!==s[1]||0!==s[2]?s:null,isObject:!0,geometry:c,material:l,pickable:!0});e.addChild(u)}}function nv(e,t,i){var s=new XMLHttpRequest;s.open("GET",e,!0),s.addEventListener("load",(function(e){var s=e.target.response;200===this.status?t&&t(s):0===this.status?(console.warn("loadFile: HTTP Status 0 received."),t&&t(s)):i&&i(e)}),!1),s.addEventListener("error",(function(e){i&&i(e)}),!1),s.send(null)}class Av extends qA{constructor(e,t){super("OBJLoader",e,t),this._sceneGraphLoader=new qw}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 Bt(this.viewer.scene,X.apply(e,{isModel:!0}));const i=t.id,s=e.src;if(!s)return this.error("load() param expected: src"),t;if(e.metaModelSrc){const r=e.metaModelSrc;X.loadJSON(r,(r=>{this.viewer.metaScene.createMetaModel(i,r),this._sceneGraphLoader.load(t,s,e)}),(e=>{this.error(`load(): Failed to load model modelMetadata for model '${i} from '${r}' - ${e}`)}))}else this._sceneGraphLoader.load(t,s,e);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}}class ov{constructor(e){const t=e.cameraControl,i=e.scene,s=i.canvas.canvas,r=!1,n=.09,A=.01,o=new Bt(i,{position:[0,0,0],scale:[5,5,5],isObject:!1}),a=V.vec3();this._setPosition=function(){const e=V.vec3(),t=V.vec3();return function(i){a.set(i),vt(i,e,t),o.origin=e,o.position=t}}(),this._setQuaternion=e=>{o.quaternion=e};const l=(e,t)=>new We(o,tt({radiusTop:.001,radiusBottom:e,radialSegments:32,heightSegments:1,height:t,openEnded:!1})),c=(e,t,i)=>new We(o,tt({radiusTop:e,radiusBottom:e,radialSegments:i,heightSegments:1,height:t,openEnded:!1})),h=(e,t,i)=>new We(o,nt({radius:.8,tube:e,radialSegments:64,tubeSegments:i,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 Os(o,{edges:!1,fill:!0,fillColor:e,fillAlpha:t}),f=new fs(o,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),p={},g=(e,t)=>{V.mulVec3Scalar(e,-1,V.vec3());const n=(e=>new fs(o,{diffuse:e,emissive:e,ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}))(e),A=V.quaternionToRotationMat4(t,V.identityMat4());V.mulMat4(V.rotationMat4v(Math.PI,[0,1,0],V.mat4()),A,A);const l=V.scaleMat4v([.6,.6,.6],V.identityMat4()),c=(e,t)=>{const i=V.translateMat4v(e,V.identityMat4()),s=V.identityMat4();return V.mulMat4(i,t,s),V.mulMat4(A,s,s),V.mulMat4(s,l,V.identityMat4())},h=o.addChild(new as(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 as(o,{geometry:u.curveHandle,material:f,matrix:A,pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isUI:!0,isObject:!1}),r),m=o.addChild(new as(o,{geometry:u.arrowHead,material:n,matrix:c([.8,.07,0],V.rotationMat4v(180*V.DEGTORAD,[0,0,1],V.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),_=o.addChild(new as(o,{geometry:u.arrowHead,material:n,matrix:c([.07,.8,0],V.rotationMat4v(90*V.DEGTORAD,[0,0,1],V.identityMat4())),pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),b=o.addChild(new as(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=V.quaternionToRotationMat4(V.vec3PairToQuaternion([0,1,0],e),V.identityMat4());V.mulMat4(V.rotationMat4v(Math.PI,[0,1,0],V.mat4()),B,B);const y=e=>V.mulMat4(B,V.translateMat4c(0,e,0,V.identityMat4()),V.identityMat4()),w=y(1.1),v=y(.5),C=o.addChild(new as(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 as(o,{geometry:u.arrowHeadHandle,material:f,matrix:w,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),E=o.addChild(new as(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 as(o,{geometry:u.axisHandle,material:f,matrix:v,pickable:!0,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),U=o.addChild(new as(o,{geometry:u.arrowHeadBig,material:n,matrix:w,pickable:!1,collidable:!0,clippable:!1,visible:!1,isUI:!0,isObject:!1}),r),x=(e,t)=>V.vec3ApplyQuaternion(o.quaternion,e,t),I=function(){const t=V.vec3(),r=V.vec3(),n=V.vec3();return(A,o)=>{x(e,t);const l=a,c=t;V.canvasPosToWorldRay(s,i.camera.viewMatrix,i.camera.projMatrix,i.camera.projection,A,r,n);const h=V.dotVec3(c,n),u=V.subVec3(r,l,o),d=V.dotVec3(u,c),f=V.dotVec3(u,n),p=1-h*h;if(Math.abs(p)>1e-10){const e=(d-h*f)/p;return V.addVec3(l,V.mulVec3Scalar(c,e,o),o),!0}return!1}}(),T=V.vec3(),P=V.vec3();p[M.id]=p[F.id]={setActivated:e=>U.visible=e,initDragAction:e=>I(e,T)&&V.subVec3(T,a,T)&&(e=>{I(e,P)&&(V.subVec3(P,T,P),this._setPosition(P),this._handlers&&this._handlers.onPosition(P))})},p[g.id]={setActivated:e=>b.visible=e,initDragAction:t=>{const s=function(){const t=i.camera.projectWorldPos(a);x(e,P),V.transformVec3(i.camera.normalMatrix,P,P);const s=Math.sign(P[2]);return e=>{const i=e[0]-t[0],r=e[1]-t[1];return s*Math.atan2(-r,i)}}();let r=s(t);return t=>{const i=s(t);o.rotate(e,180*(i-r)/Math.PI),this._handlers&&this._handlers.onQuaternion(o.quaternion),r=i}}};let S=!1,D=!1,k=!1;const Q=()=>{const e=k&&S;M.visible=F.visible=C.visible=E.visible=!!e,e||(U.visible=!1)},R=()=>{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,R()},set visible(e){k=e,Q(),R()}}};this._displayMeshes={center:o.addChild(new as(o,{geometry:new We(o,rt({radius:.05})),material:new fs(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],V.vec3PairToQuaternion([1,0,0],[0,0,1])),y:g([0,1,0],V.eulerToQuaternion([90,0,0],"XYZ")),z:g([0,0,1],V.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))},s=i.on("tick",(()=>{const s=i.camera,r=Math.abs(V.distVec3(s.eye,a));"perspective"===s.projection?r!==e&&t(.07*r*Math.tan(s.perspective.fov*V.DEGTORAD)):"ortho"===s.projection&&t(s.ortho.scale/10),e=r}));m.push((()=>i.off(s)))}{let e=null,r=null;m.push((()=>{r&&r.cleanup()}));const n=V.vec2(),A=(e,t)=>{t[0]=e.pageX,t[1]=e.pageY,Py(s.ownerDocument.documentElement,s,t)},o=e=>{A(e,n);const t=i.pick({canvasPos:n}),s=t&&t.entity,r=s&&s.id;return r in p&&p[r]},a=(e,i)=>{const s=o(i(e));if(s){r&&r.cleanup();const e=s.initDragAction(n);return e&&(t.pointerEnabled=!1,s.setActivated(!0),r={onChange:t=>{const s=i(t);s&&(A(s,n),e(n))},cleanup:function(){r=null,t.pointerEnabled=!0,s.setActivated(!1)}}),!!e}return!1},l=(e,t)=>{s.addEventListener(e,t),m.push((()=>s.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 i=o(t);i?(i.setActivated(!0),e=()=>i.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 p)delete p[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 av{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new as(t,{id:i.id,geometry:new We(t,$e({xSize:.5,ySize:.5,zSize:.001})),material:new fs(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Ls(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Os(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Os(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=V.vec3([0,0,0]),t=V.vec3(),i=V.vec3([0,0,1]),s=V.vec4(4),r=V.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];V.subVec3(n,this._sectionPlane.pos,e);const o=-V.dotVec3(A,e);V.normalizeVec3(A),V.mulVec3Scalar(A,o,t);const a=V.vec3PairToQuaternion(i,this._sectionPlane.dir,s);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 lv{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 qo(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new wA(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new wA(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new wA(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=V.rotationMat4c(-90*V.DEGTORAD,1,0,0),i=V.vec3(),s=V.vec3(),r=V.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;V.mulVec3Scalar(V.normalizeVec3(V.subVec3(n,A,i)),7),this._zUp?(V.transformVec3(t,i,s),V.transformVec3(t,o,r),e.look=[0,0,0],e.eye=V.transformVec3(t,i,s),e.up=V.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=i,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 i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new av(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.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 cv=V.AABB3(),hv=V.vec3();class uv extends qA{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 lv(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;cv.set(this.viewer.scene.aabb),V.getAABB3Center(cv,hv),cv[0]+=t[0]-hv[0],cv[1]+=t[1]-hv[1],cv[2]+=t[2]-hv[2],cv[3]+=t[0]-hv[0],cv[4]+=t[1]-hv[1],cv[5]+=t[2]-hv[2],this.viewer.cameraFlight.flyTo({aabb:cv,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 ZA(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 Bt(e,{isObject:!1});return t.addChild(new as(t,{geometry:new We(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 fs(t,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new Os(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 as(t,{geometry:new We(t,nt({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new fs(t,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new Os(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=V.vec3(),i=V.vec3();return function(s){vt(s,e,i),t.origin=e,t.position=i}}(),setQuaternion:e=>{t.quaternion=e},setScale:e=>{t.scale=e},setVisible:e=>{t.visible=e},destroy:()=>{t.destroy()}}}();let i=()=>{};const s=new ov(this.viewer);let r=!1,n=!1,A=null;const o=()=>{const e=n&&!r;t.setVisible(e),s.setHandlers(e&&A)};return{_destroy:()=>{i(),s.destroy(),t.destroy()},setCulled:e=>{r=e,o()},setVisible:e=>{n=e,o()},_setSectionPlane:e=>{if(i(),e){let r=!1;A={onPosition:i=>{t.setPosition(i),e.pos=i},onQuaternion:i=>{t.setQuaternion(i),r=!0,e.quaternion=i},onScreenScale:e=>{t.setScale(e)}};const n=()=>{t.setPosition(e.pos),s.setPosition(e.pos)},o=()=>{t.setQuaternion(e.quaternion),s.setQuaternion(e.quaternion)};n(),o();const a=e.on("pos",n),l=e.on("dir",(()=>{r?r=!1:o()}));i=()=>{e.off(a),e.off(l),i=()=>{}}}}}})();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,i=e.length;t<i;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)}}class dv{constructor(e,t,i,s,r,n){this.plugin=e,this.storeyId=r,this.modelId=s,this.storeyAABB=i.slice(),this.aabb=this.storeyAABB,this.modelAABB=t.slice(),this.numObjects=n}}class fv{constructor(e,t,i,s,r,n){this.storeyId=e,this.imageData=t,this.format=i,this.width=s,this.height=r}}const pv=V.vec3(),gv=V.mat4();class mv extends qA{constructor(e,t={}){super("StoreyViews",e),this._objectsMemento=new OA,this._cameraMemento=new DA,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,i=t.scene,s=t.metaScene,r=s.metaModels[e],n=i.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=s.metaObjects[A].getObjectIDsInSubtree(),a=i.getAABB(o),l=Math.random()>.5?o.length:0,c=new dv(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,i=this.viewer.camera.worldUp,s=i[0]>i[1]&&i[0]>i[2],r=!s&&i[1]>i[0]&&i[1]>i[2];let n;!s&&!r&&i[2]>i[0]&&(i[2],i[1]),n=s?0:r?1:2;for(let i=0,s=e.length;i<s;i++){const s=t.metaObjects[e[i].storeyId].attributes.elevation;if(isNaN(s))return;const r=e[i].storeyAABB;if(r[n]=Math.max(r[1],parseFloat(s)),i>0){const s=t.metaObjects[e[i-1].storeyId].attributes.elevation;r[4]=Math.min(r[n+3],parseFloat(s))}this.storeys[e[i].storeyId].storeyAABB=r}}_deregisterModelStoreys(e){const t=this.modelStoreys[e];if(t){const i=this.viewer.scene;for(let e in t)if(t.hasOwnProperty(e)){const s=t[e],r=i.models[s.modelId];r&&r.off(s._onModelDestroyed),delete this.storeys[e],this._storeysList=null}delete this.modelStoreys[e]}}get fitStoreyMaps(){return this._fitStoreyMaps}gotoStoreyCamera(e,t={}){const i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());const s=this.viewer,r=s.scene.camera,n=i.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=V.getAABB3Center(n),o=V.getAABB3Diag(n),a=Math.abs(o/Math.tan(45*V.DEGTORAD)),l=1.3*o,c=pv;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?s.cameraFlight.flyTo(X.apply(t,{eye:c,look:A,up:h,orthoScale:l}),(()=>{t.done()})):(s.cameraFlight.jumpTo(X.apply(t,{eye:c,look:A,up:h,orthoScale:l})),s.camera.ortho.scale=l)}showStoreyObjects(e,t={}){if(!this.storeys[e])return void this.error("IfcBuildingStorey not found with this ID: "+e);const i=this.viewer,s=i.scene;i.metaScene.metaObjects[e]&&(t.hideOthers&&s.setObjectsVisible(i.scene.visibleObjectIds,!1),this.withStoreyObjects(e,((e,t)=>{e&&(e.visible=!0)})))}withStoreyObjects(e,t){const i=this.viewer,s=i.scene,r=i.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],i=r.metaObjects[e],n=s.objects[e];n&&t(n,i)}}createStoreyMap(e,t={}){const i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";const s=this.viewer,r=s.scene,n=t.format||"png",A=this._fitStoreyMaps?i.storeyAABB:i.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,X.apply(t,{hideOthers:!0})),l&&this._toggleSectionPlanes(!1),this._arrangeStoreyMapCamera(i);const d=s.getSnapshot({width:c,height:h,format:n});return this._objectsMemento.restoreObjects(r,u),this._cameraMemento.restoreCamera(r),l&&this._toggleSectionPlanes(!0),new fv(e,d,n,c,h,a)}_toggleSectionPlanes(e){const t=this.viewer.scene.sectionPlanes;for(const i in t)t[i].active=e}_arrangeStoreyMapCamera(e){const t=this.viewer,i=t.scene.camera,s=this._fitStoreyMaps?e.storeyAABB:e.modelAABB,r=V.getAABB3Center(s),n=pv;n[0]=r[0]+.5*i.worldUp[0],n[1]=r[1]+.5*i.worldUp[1],n[2]=r[2]+.5*i.worldUp[2];const A=i.worldForward;t.cameraFlight.jumpTo({eye:n,look:r,up:A});const o=(s[3]-s[0])/2,a=(s[4]-s[1])/2,l=(s[5]-s[2])/2,c=-o,h=+o,u=-a,d=+a,f=-l,p=+l;t.camera.customProjection.matrix=V.orthoMat4c(c,h,f,p,u,d,gv),t.camera.projection="customProjection"}pickStoreyMap(e,t,i={}){const s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),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,f=V.vec3([a+h*n,l+.5*u,c+d*A]),p=V.vec3([0,-1,0]),g=V.addVec3(f,p,pv),m=this.viewer.camera.worldForward,_=V.lookAtMat4v(f,g,m,gv);return this.viewer.scene.pick({pickSurface:i.pickSurface,pickInvisible:!0,matrix:_})}storeyMapToWorldPos(e,t,i={}){const s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),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 V.vec3([a+h*n,l+.5*u,c+d*A])}getStoreyContainingWorldPos(e,t=null){const i=t?this._filterStoreys(t):this.storeys;for(let t in i){const s=i[t];if(V.point3AABB3AbsoluteIntersect(s.storeyAABB,e))return t}return null}getStoreyInVerticalRange(e,t=null){const i=t?this._filterStoreys(t):this.storeys;for(let t in i){const s=i[t],r=[0,0,0,0,0,0],n=[0,0,0];if(r[1]=s.storeyAABB[1],r[4]=s.storeyAABB[4],n[1]=e[1],V.point3AABB3AbsoluteIntersect(r,n))return t}return null}isPositionAboveOrBelowBuilding(e,t=null){const i=t?this._filterStoreys(t):this.storeys,s=Object.keys(i);if(s.length<=0)return null;const r=[s[0],s[s.length-1]];return e[1]<i[r[0]].storeyAABB[1]?r[0]:e[1]>i[r[1]].storeyAABB[4]?r[1]:null}worldPosToStoreyMap(e,t,i){const s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),!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],f=!d&&u[1]>u[0]&&u[1]>u[2];!d&&!f&&u[2]>u[0]&&(u[2],u[1]);const p=e.width/l,g=f?e.height/h:e.height/c;return i[0]=Math.floor(e.width-(t[0]-A)*p),i[1]=Math.floor(e.height-(t[2]-a)*g),i[0]>=0&&i[0]<e.width&&i[1]>=0&&i[1]<=e.height}worldDirToStoreyMap(e,t,i){const s=this.viewer.camera,r=s.eye,n=s.look,A=V.subVec3(n,r,pv),o=s.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?(i[0]=A[1],i[1]=A[2]):l?(i[0]=A[0],i[1]=A[2]):(i[0]=A[0],i[1]=A[1]),V.normalizeVec2(i)}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,i)=>{let s=0;s=e.xUp?0:e.yUp?1:2;const r=this.viewer.metaScene,n=r.metaObjects[t.storeyId],A=r.metaObjects[i.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[s]>i.aabb[s]?-1:t.aabb[s]<i.aabb[s]?1:0})}_filterStoreys(e){return Object.fromEntries(Object.entries(this.storeys).filter((([t,i])=>i.modelId===e)))}}const _v=new Float64Array([0,0,1]),bv=new Float64Array(4);class Bv{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=V.vec3(),this._origin=V.vec3(),this._rtcPos=V.vec3(),this._baseDir=V.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),vt(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=V.vec3PairToQuaternion(_v,e,bv)}_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,i=.01;this._rootNode=new Bt(t,{position:[0,0,0],scale:[5,5,5]});const s=this._rootNode,r={arrowHead:new We(s,tt({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new We(s,tt({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new We(s,tt({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},n={red:new fs(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new fs(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new fs(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Os(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new as(s,{geometry:new We(s,{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 fs(s,{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:s.addChild(new as(s,{geometry:new We(s,nt({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new fs(s,{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:s.addChild(new as(s,{geometry:new We(s,rt({radius:.05})),material:n.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new as(s,{geometry:r.arrowHead,material:n.blue,matrix:function(){const e=V.translateMat4c(0,1.1,0,V.identityMat4()),t=V.rotationMat4v(-90*V.DEGTORAD,[.8,0,0],V.identityMat4());return V.mulMat4(t,e,V.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new as(s,{geometry:r.axis,material:n.blue,matrix:function(){const e=V.translateMat4c(0,.5,0,V.identityMat4()),t=V.rotationMat4v(-90*V.DEGTORAD,[1,0,0],V.identityMat4());return V.mulMat4(t,e,V.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new as(s,{geometry:new We(s,nt({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new fs(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Os(s,{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:s.addChild(new as(s,{geometry:r.arrowHeadBig,material:n.blue,matrix:function(){const e=V.translateMat4c(0,1.1,0,V.identityMat4()),t=V.rotationMat4v(-90*V.DEGTORAD,[.8,0,0],V.identityMat4());return V.mulMat4(t,e,V.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=V.vec2(),i=this._viewer.camera,s=this._viewer.scene;let r=0,n=!1;{const t=V.vec3([0,0,0]);let A=-1;this._onCameraViewMatrix=s.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=s.camera.on("projMatrix",(()=>{})),this._onSceneTick=s.on("tick",(()=>{n=!1;const a=Math.abs(V.lenVec3(V.subVec3(s.camera.eye,this._pos,t)));if(a!==A&&"perspective"===i.projection){const t=.07*(Math.tan(i.perspective.fov*V.DEGTORAD)*a);e.scale=[t,t,t],A=a}if("ortho"===i.projection){const t=i.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 i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,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,i=this._sectionPlane.dir;V.addVec3(t,V.mulVec3Scalar(i,.1*e*this._plugin.getDragSensitivity(),V.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=i=>{if(i.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===i.which)){e=!0;var s=A(i);t[0]=s[0],t[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=i=>{if(!this._visible)return;if(!e)return;if(n)return;var s=A(i);const r=s[0],a=s[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,i=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,i=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!==i&&(r+=t-i),i=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=i=>{i.stopPropagation(),i.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class yv{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new as(t,{id:i.id,geometry:new We(t,$e({xSize:.5,ySize:.5,zSize:.001})),material:new fs(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Ls(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Os(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Os(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=V.vec3([0,0,0]),t=V.vec3(),i=V.vec3([0,0,1]),s=V.vec4(4),r=V.vec3(),n=()=>{const n=this._sectionPlane.scene.center,A=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];V.subVec3(n,this._sectionPlane.pos,e);const o=-V.dotVec3(A,e);V.normalizeVec3(A),V.mulVec3Scalar(A,o,t);const a=V.vec3PairToQuaternion(i,this._sectionPlane.dir,s);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 wv{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 qo(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new wA(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new wA(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new wA(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=V.rotationMat4c(-90*V.DEGTORAD,1,0,0),i=V.vec3(),s=V.vec3(),r=V.vec3();this._synchCamera=()=>{const n=this._viewer.camera.eye,A=this._viewer.camera.look,o=this._viewer.camera.up;V.mulVec3Scalar(V.normalizeVec3(V.subVec3(n,A,i)),7),this._zUp?(V.transformVec3(t,i,s),V.transformVec3(t,o,r),e.look=[0,0,0],e.eye=V.transformVec3(t,i,s),e.up=V.transformPoint3(t,o,r)):(e.look=[0,0,0],e.eye=i,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 i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new yv(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.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 vv=V.AABB3(),Cv=V.vec3();class Mv extends qA{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 wv(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;vv.set(this.viewer.scene.aabb),V.getAABB3Center(vv,Cv),vv[0]+=t[0]-Cv[0],vv[1]+=t[1]-Cv[1],vv[2]+=t[2]-Cv[2],vv[3]+=t[0]-Cv[0],vv[4]+=t[1]-Cv[1],vv[5]+=t[2]-Cv[2],this.viewer.cameraFlight.flyTo({aabb:vv,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 ZA(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 Bv(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,i=e.length;t<i;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)}}class Ev{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,i){e=this._cacheBusterURL(e);const s=new XMLHttpRequest;s.overrideMimeType("application/json"),s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i(s.statusText))},s.send(null)}}const Fv=V.vec3();class Uv{load(e,t,i,s,r,n){s=s||{};const A=e.viewer.scene.canvas.spinner;A.processes++,e.dataSource.getSTL(i,(function(i){!function(e,t,i,s){try{const r=Dv(i);xv(r)?Iv(e,r,t,s):Tv(e,Sv(i),t,s)}catch(e){t.fire("error",e)}}(e,t,i,s);try{const n=Dv(i);xv(n)?Iv(e,n,t,s):Tv(e,Sv(i),t,s),A.processes--,ie.scheduleTask((function(){t.fire("loaded",!0,!1)})),r&&r()}catch(i){A.processes--,e.error(i),n&&n(i),t.fire("error",i)}}),(function(i){A.processes--,e.error(i),n&&n(i),t.fire("error",i)}))}parse(e,t,i,s){const r=e.viewer.scene.canvas.spinner;r.processes++;try{const n=Dv(i);xv(n)?Iv(e,n,t,s):Tv(e,Sv(i),t,s),r.processes--,ie.scheduleTask((function(){t.fire("loaded",!0,!1)}))}catch(e){r.processes--,t.fire("error",e)}}}function xv(e){const t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;const i=[115,111,108,105,100];for(var s=0;s<5;s++)if(i[s]!==t.getUint8(s,!1))return!0;return!1}function Iv(e,t,i,s){const r=new DataView(t),n=r.getUint32(80,!0);let A,o,a,l,c,h,u,d=!1,f=null,p=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 Ss(i,{roughness:.5});let b=[],B=[],y=s.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!==f||o!==p||a!==g)&&(null!==f&&(m=!0),f=A,p=o,g=a)}for(let e=1;e<=3;e++){let i=t+12*e;b.push(r.getFloat32(i,!0)),b.push(r.getFloat32(i+4,!0)),b.push(r.getFloat32(i+8,!0)),B.push(n,w,v),d&&l.push(A,o,a,1)}y&&m&&(Pv(i,b,B,l,_,s),b=[],B=[],l=l?[]:null,m=!1)}b.length>0&&Pv(i,b,B,l,_,s)}function Tv(e,t,i,s){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,f,p,g,m;for(;null!==(f=r.exec(t));){for(p=0,g=0,m=f[0];null!==(f=a.exec(m));)h=parseFloat(f[1]),u=parseFloat(f[2]),d=parseFloat(f[3]),g++;for(;null!==(f=o.exec(m));)l.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),c.push(h,u,d),p++;1!==g&&e.error("Error in normal of face "+n),3!==p&&e.error("Error in positions of face "+n),n++}Pv(i,l,c,null,new Ss(i,{roughness:.5}),s)}function Pv(e,t,i,s,r,n){const A=new Int32Array(t.length/3);for(let e=0,t=A.length;e<t;e++)A[e]=e;i=i&&i.length>0?i:null,s=s&&s.length>0?s:null,n.smoothNormals&&V.faceToVertexNormals(t,i,n);const o=Fv;Ct(t,t,o);const a=new We(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:A}),l=new as(e,{origin:0!==o[0]||0!==o[1]||0!==o[2]?o:null,geometry:a,material:r,edges:n.edges});e.addChild(l)}function Sv(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,s=e.length;i<s;i++)t+=String.fromCharCode(e[i]);return decodeURIComponent(escape(t))}(new Uint8Array(e)):e}function Dv(e){if("string"==typeof e){const t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=255&e.charCodeAt(i);return t.buffer||t}return e}class kv extends qA{constructor(e,t={}){super("STLLoader",e,t),this._sceneGraphLoader=new Uv,this.dataSource=t.dataSource}set dataSource(e){this._dataSource=e||new Ev}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 Bt(this.viewer.scene,X.apply(e,{isModel:!0})),i=e.src,s=e.stl;return i||s?(i?this._sceneGraphLoader.load(this,t,i,e):this._sceneGraphLoader.parse(this,t,s,e),t):(this.error("load() param expected: either 'src' or 'stl'"),t)}}class Qv{constructor(e){this._treeViewContainer=e}createRootNode(){return document.createElement("ul")}createNodeElement(e,t,i,s,r){const n=document.createElement("li");if(n.id=e.nodeId,e.xrayed&&n.classList.add("xrayed-node"),e.children.length>0){const i=document.createElement("a");i.href="#",i.id=`switch-${e.nodeId}`,i.textContent="+",i.classList.add("plus"),t&&i.addEventListener("click",t),n.appendChild(i)}const A=document.createElement("input");A.id=`checkbox-${e.nodeId}`,A.type="checkbox",A.checked=e.checked,A.style["pointer-events"]="all",i&&A.addEventListener("change",i),n.appendChild(A);const o=document.createElement("span");return o.textContent=e.title,n.appendChild(o),s&&fy(o,s),r&&(o.onclick=r),n}createDisabledNodeElement(e){const t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);const s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}addChildren(e,t){const i=document.createElement("ul");t.forEach((e=>{i.appendChild(e)})),e.parentElement.appendChild(i)}expand(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}collapse(e,t,i){if(!e)return;const s=e.parentElement;if(!s)return;const r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),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,i=!1){const s=this._treeViewContainer.querySelector(`[id="checkbox-${e}"]`);s&&(t!==s.checked&&(s.checked=t),i!==s.indeterminate&&(s.indeterminate=i,i&&(s.checked=!1)))}setXRayed(e,t){const i=this._treeViewContainer.querySelector(`[id="${e}"]`);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}setHighlighted(e,t){const i=this._treeViewContainer.querySelector(`[id="${e}"]`);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}const Rv=[];class Ov extends qA{constructor(e,t={}){super("TreeViewPlugin",e),this.errors=[],this.valid=!0;const i=t.containerElement||document.getElementById(t.containerElementId);if(i instanceof HTMLElement){for(let e=0;;e++)if(!Rv[e]){Rv[e]=this,this._index=e,this._id=`tree-${e}`;break}if(this._containerElement=i,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 Qv(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,i=this._objectNodes[t];if(!i)return;const s=e.visible;if(!(s!==i.checked))return;this._muteTreeEvents=!0,i.checked=s,s?i.numVisibleEntities++:i.numVisibleEntities--,this._renderService.setCheckbox(i.nodeId,s);let r=i.parent;for(;r;){r.checked=s,s?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,i=this._objectNodes[t];if(!i)return;this._muteTreeEvents=!0;const s=e.xrayed;s!==i.xrayed&&(i.xrayed=s,this._renderService.setXRayed(i.nodeId,s),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,i=this._renderService.isChecked(t),s=this._renderService.getIdFromCheckbox(t),r=this._nodeNodes[s],n=this._viewer.scene.objects;let A=0;this._withNodeTree(r,(e=>{const t=e.objectId,s=n[t],r=0===e.children.length;e.numVisibleEntities=i?e.numEntities:0,r&&i!==e.checked&&A++,e.checked=i,this._renderService.setCheckbox(e.nodeId,i),s&&(s.visible=i)}));let o=r.parent;for(;o;){i?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,i=e.length;t<i;t++){const i=e[t];this.viewer.metaScene.metaModels[i].finalized&&this.addModel(i)}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 i=this.viewer.scene.models[e];if(!i)throw"Model not found: "+e;const s=this.viewer.metaScene.metaModels[e];s?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=s,t&&t.rootName&&(this._rootNames[e]=t.rootName),i.on("destroyed",(()=>{this.removeModel(i.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 i=t.nodeId,s=this._renderService.getSwitchElement(i);if(s)return this._expandSwitchElement(s),s.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(i,!0),this._showListItemElementId=i}unShowNode(){this._showListItemElementId&&(this._renderService.setHighlighted(this._showListItemElementId,!1),this._showListItemElementId=null)}expandToDepth(e){this.collapse();const t=(i,s)=>{if(s===e)return;const r=this._renderService.getSwitchElement(i.nodeId);if(r){this._expandSwitchElement(r);const e=i.children;for(var n=0,A=e.length;n<A;n++){const i=e[n];t(i,s+1)}}};for(let e=0,i=this._rootNodes.length;e<i;e++){const i=this._rootNodes[e];t(i,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 i=e.children;if(i)for(let e=0,s=i.length;e<s;e++)this.withNodeTree(i[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 Rv[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,i){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 i in t){const s=t[i],r=s.type,n=s.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 i=this.viewer.scene,s=e.children,r=e.id,n=i.objects[r];if(e._countEntities=0,n&&e._countEntities++,s)for(let t=0,i=s.length;t<i;t++){const i=s[t];i._countEntities=this._findEmptyNodes2(i),e._countEntities+=i._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,i,s,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)i={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(i):this._rootNodes.push(i),this._objectNodes[i.objectId]=i,this._nodeNodes[i.nodeId]=i;else if("IfcBuildingStorey"===n){if(!i)return void this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");s={nodeId:`${this._id}-${a}`,objectId:a,title:A&&""!==A&&"Undefined"!==A&&"Default"!==A?A:n,type:n,parent:i,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},i.children.push(s),this._objectNodes[s.objectId]=s,this._nodeNodes[s.nodeId]=s,r={}}else if(s){if(this._viewer.scene.objects[a]){let e=(r=r||{})[n];e||(e={nodeId:`${this._id}-${s.objectId}-${n}`,objectId:`${s.objectId}-${n}`,title:n,type:n,parent:s,numEntities:0,numVisibleEntities:0,checked:!1,xrayed:!1,children:[]},s.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,i,s,r)}}_createTypesNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._createTypesNodes2(e[t],null,null)}_createTypesNodes2(e,t,i){if(this._pruneEmptyNodes&&0===e._countEntities)return;const s=e.type,r=e.name,n=e.children,A=e.id;if(e.parent){if(t){if(this._viewer.scene.objects[A]){let e=i[s];e||(e={nodeId:`${this._id}-${t.objectId}-${s}`,objectId:`${t.objectId}-${s}`,title:s,type:s,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,i[s]=e);const n={nodeId:`${this._id}-${A}`,objectId:A,title:r&&""!==r&&"Default"!==r?r:s,type:s,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:s),type:s,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,i={};if(n)for(let e=0,s=n.length;e<s;e++){const s=n[e];this._createTypesNodes2(s,t,i)}}_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 i=e.type,s=e.name||i,r=e.children,n=e.id,A={nodeId:`${this._id}-${n}`,objectId:n,title:t?s&&""!==s&&"Undefined"!==s&&"Default"!==s?s:i:0===e.metaModels.length?s:this._rootNames[e.metaModels[0].id]||s,type:i,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 i=t[0];"storeys"!==this._hierarchy&&"containment"!==this._hierarchy||"IfcBuildingStorey"!==i.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,i=t.length;e<i;e++){const i=t[e];this._sortChildren(i)}}_getSpatialSortFunc(){const e=this.viewer.scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=(t,i)=>{e.xUp||e.yUp;const s=this.viewer.metaScene,r=s.metaObjects[t.objectId],n=s.metaObjects[i.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 i=e.title.toUpperCase(),s=t.title.toUpperCase();return i<s?-1:i>s?1:0}_synchNodesToEntities(){const e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,i=this._viewer.scene.objects;for(let s=0,r=e.length;s<r;s++){const r=e[s];if(t[r]){const e=this._objectNodes[r];if(e){const t=i[r];if(t){const i=t.visible;e.numEntities=1,e.xrayed=t.xrayed,i?(e.numVisibleEntities=1,e.checked=!0):(e.numVisibleEntities=0,e.checked=!1);let s=e.parent;for(;s;)s.numEntities++,i&&(s.numVisibleEntities++,s.checked=!0),s=s.parent}}}}}_withNodeTree(e,t){t(e);const i=e.children;if(i)for(let e=0,s=i.length;e<s;e++)this._withNodeTree(i[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),i=this._nodeNodes[t].children.map((e=>this._createNodeElement(e)));this._renderService.addChildren(e,i),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)}}class Vv{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 i=e.models[t];i&&this._addModel(i)})),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 i=e[t];this._objects[this._numObjects++]=i}this._lenObjectsChangedList=0,this._dirty=!1}_applyChanges(){if(this._lenObjectsChangedList>0){for(let e=0;e<this._lenObjectsChangedList;e++){const t=this._objectsChangedList[e],i=this._objects[t],s=this._objectsViewCulled[t],r=this._objectsDetailCulled[t],n=s||r;i.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 Lv={};const Hv=new Float32Array(3);class Nv extends qA{constructor(e,t={}){super("ViewCull",e),this._objectCullStates=function(e){const t=e.id;let i=Lv[t];return i||(i=new Vv(e),Lv[t]=i,e.on("destroyed",(()=>{delete Lv[t],i._destroy()}))),i}(e.scene),this._maxTreeDepth=t.maxTreeDepth||8,this._modelInfos={},this._frustum=new he,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;ue(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}_buildKDTree(){const e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:he.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,i,s){const r=t.aabb;if(s>=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(i),void V.expandAABB3(e.aabb,r);if(e.left&&V.containsAABB3(e.left.aabb,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1);if(e.right&&V.containsAABB3(e.right.aabb,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1);const n=e.aabb;Hv[0]=n[3]-n[0],Hv[1]=n[4]-n[1],Hv[2]=n[5]-n[2];let A=0;if(Hv[1]>Hv[A]&&(A=1),Hv[2]>Hv[A]&&(A=2),!e.left){const o=n.slice();if(o[A+3]=(n[A]+n[A+3])/2,e.left={aabb:o,intersection:he.INTERSECT},V.containsAABB3(o,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1)}if(!e.right){const o=n.slice();if(o[A]=(n[A]+n[A+3])/2,e.right={aabb:o,intersection:he.INTERSECT},V.containsAABB3(o,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1)}e.objects=e.objects||[],e.objects.push(i),V.expandAABB3(e.aabb,r)}_visitKDNode(e,t=he.INTERSECT){if(t!==he.INTERSECT&&e.intersects===t)return;t===he.INTERSECT&&(t=de(this._frustum,e.aabb),e.intersects=t);const i=t===he.OUTSIDE,s=e.objects;if(s&&s.length>0)for(let e=0,t=s.length;e<t;e++){const t=s[e];this._objectCullStates.setObjectViewCulled(t,i)}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}}class Gv{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,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getMetaModel(e,t,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}getXKT(e,t,i){var s=()=>{};t=t||s,i=i||s;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),i=new Uint8Array(e);for(var A=0;A<n.length;A++)i[A]=n.charCodeAt(A);t(e)}catch(e){i(e)}}else{const s=new XMLHttpRequest;s.open("GET",this._cacheBusterURL(e),!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i("getXKT error : "+s.response))},s.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 i=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]),s=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,i,s,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=r,this.has_stree=e&&e.length}let d,f,p;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,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,_(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},B=(e,t,i)=>{b(e,i[2*t],i[2*t+1])},y=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},w=(e,t,i)=>{const s=new Array(16);let r,n,A=0;for(r=1;r<=15;r++)A=A+i[r-1]<<1,s[r]=A;for(n=0;n<=t;n++){let t=e[2*n+1];0!==t&&(e[2*n]=y(s[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,i,s)=>{const r=2*t,n=2*i;return e[r]<e[n]||e[r]===e[n]&&s[t]<=s[i]},E=(e,t,i)=>{const s=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r<e.heap_len&&M(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!M(t,s,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=s},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=i[o],0!==a&&(A-=c[o],b(e,A,a)),n--,o=m(n),B(e,o,r),a=s[o],0!==a&&(n-=h[o],b(e,n,a)))}while(u<e.sym_next);B(e,256,t)},U=(e,t)=>{const i=t.dyn_tree,s=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!==i[2*A]?(e.heap[++e.heap_len]=l=A,e.depth[A]=0):i[2*A+1]=0;for(;e.heap_len<2;)a=e.heap[++e.heap_len]=l<2?++l:0,i[2*a]=1,e.depth[a]=0,e.opt_len--,r&&(e.static_len-=s[2*a+1]);for(t.max_code=l,A=e.heap_len>>1;A>=1;A--)E(e,i,A);a=n;do{A=e.heap[1],e.heap[1]=e.heap[e.heap_len--],E(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=A,e.heap[--e.heap_max]=o,i[2*a]=i[2*A]+i[2*o],e.depth[a]=(e.depth[A]>=e.depth[o]?e.depth[A]:e.depth[o])+1,i[2*A+1]=i[2*o+1]=a,e.heap[1]=a++,E(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,s=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,f,p=0;for(u=0;u<=15;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)c=e.heap[l],u=i[2*i[2*c+1]+1]+1,u>a&&(u=a,p++),i[2*c+1]=u,c>s||(e.bl_count[u]++,d=0,c>=o&&(d=A[c-o]),f=i[2*c],e.opt_len+=f*(u+d),n&&(e.static_len+=f*(r[2*c+1]+d)));if(0!==p){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]--,p-=2}while(p>0);for(u=a;0!==u;u--)for(c=e.bl_count[u];0!==c;)h=e.heap[--l],h>s||(i[2*h+1]!==u&&(e.opt_len+=(u-i[2*h+1])*i[2*h],i[2*h+1]=u),c--)}})(e,t),w(i,l,e.bl_count)},x=(e,t,i)=>{let s,r,n=-1,A=t[1],o=0,a=7,l=4;for(0===A&&(a=138,l=3),t[2*(i+1)+1]=65535,s=0;s<=i;s++)r=A,A=t[2*(s+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,i)=>{let s,r,n=-1,A=t[1],o=0,a=7,l=4;for(0===A&&(a=138,l=3),s=0;s<=i;s++)if(r=A,A=t[2*(s+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,i,s)=>{b(e,0+(s?1:0),3),C(e),_(e,i),_(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};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<<i[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<<s[g];e++)a[m++]=g;for(m>>=7;g<30;g++)for(h[g]=m<<7,e=0;e<1<<s[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,i,257,286,15),f=new u(o,s,0,30,15),p=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,f),e.bl_desc=new g(e.bl_tree,p),e.bi_buf=0,e.bi_valid=0,v(e)},_tr_stored_block:P,_tr_flush_block:(e,t,i,s)=>{let r,a,l=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&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)),U(e,e.l_desc),U(e,e.d_desc),l=(e=>{let t;for(x(e,e.dyn_ltree,e.l_desc.max_code),x(e,e.dyn_dtree,e.d_desc.max_code),U(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=i+5,i+4<=r&&-1!==t?P(e,t,i,s):4===e.strategy||a===r?(b(e,2+(s?1:0),3),F(e,A,o)):(b(e,4+(s?1:0),3),((e,t,i,s)=>{let r;for(b(e,t-257,5),b(e,i-1,5),b(e,s-4,4),r=0;r<s;r++)b(e,e.bl_tree[2*n[r]+1],3);I(e,e.dyn_ltree,t-1),I(e,e.dyn_dtree,i-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),s&&C(e)},_tr_tally:(e,t,i)=>(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++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(l[i]+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,i,s)=>{let r=65535&e|0,n=e>>>16&65535|0,A=0;for(;0!==i;){A=i>2e3?2e3:i,i-=A;do{r=r+t[s++]|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 i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Q=(e,t,i,s)=>{const r=k,n=s+i;e^=-1;for(let i=s;i<n;i++)e=e>>>8^r[255&(e^t[i])];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:ie,Z_RLE:se,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),fe=e=>2*e-(e>4?9:0),pe=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ge=e=>{let t,i,s,r=e.w_size;t=e.hash_size,s=t;do{i=e.head[--s],e.head[s]=i>=r?i-r:0}while(--t);t=r,s=t;do{i=e.prev[--s],e.prev[s]=i>=r?i-r:0}while(--t)};let me=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const _e=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,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,i,s)=>{let r=e.avail_in;return r>s&&(r=s),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=D(e.adler,t,r,i):2===e.state.wrap&&(e.adler=Q(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},ve=(e,t)=>{let i,s,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],f=l[n+A];e.prev_length>=e.good_match&&(r>>=2),o>e.lookahead&&(o=e.lookahead);do{if(i=t,l[i+A]===f&&l[i+A-1]===d&&l[i]===l[n]&&l[++i]===l[n+1]){n+=2,i++;do{}while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<u);if(s=ae-(u-n),n=u-ae,s>A){if(e.match_start=t,A=s,s>=o)break;d=l[n+A-1],f=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 i,s,r;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-le)&&(e.window.set(e.window.subarray(t,t+t-s),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ge(e),s+=t),0===e.strm.avail_in)break;if(i=we(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,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 i,s,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(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r)break;if(r=e.strm.avail_out-r,s=e.strstart-e.block_start,i>s+e.strm.avail_in&&(i=s+e.strm.avail_in),i>r&&(i=r),i<n&&(0===i&&t!==X||t===j||i!==s+e.strm.avail_in))break;A=t===X&&i===s+e.strm.avail_in?1:0,L(e,0,0,A),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,_e(e.strm),s&&(s>i&&(s=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,i-=s),i&&(we(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}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,s=e.strstart-e.block_start,(s>=n||(s||t===X)&&t!==j&&0===e.strm.avail_in&&s<=r)&&(i=s>r?r:s,A=t===X&&0===e.strm.avail_in&&i===s?1:0,L(e,e.block_start,i,A),e.block_start+=i,_e(e.strm)),A?3:1)},Ee=(e,t)=>{let i,s;for(;;){if(e.lookahead<le){if(Ce(e),e.lookahead<le&&t===j)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-le&&(e.match_length=ve(e,i)),e.match_length>=3)if(s=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]),i=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 s=N(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(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 i,s,r;for(;;){if(e.lookahead<le){if(Ce(e),e.lookahead<le&&t===j)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=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!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-le&&(e.match_length=ve(e,i),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,s=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]),i=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++,s&&(be(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(s=N(e,0,e.window[e.strstart-1]),s&&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&&(s=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 Ue(e,t,i,s,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=r}const xe=[new Ue(0,0,0,0,Me),new Ue(4,4,8,4,Ee),new Ue(4,5,16,8,Ee),new Ue(4,6,32,32,Ee),new Ue(4,4,16,16,Fe),new Ue(8,16,32,32,Fe),new Ue(8,16,128,128,Fe),new Ue(8,32,128,256,Fe),new Ue(32,128,258,1024,Fe),new Ue(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),pe(this.dyn_ltree),pe(this.dyn_dtree),pe(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),pe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),pe(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 i;return t===Z&&((i=e.state).window_size=2*i.w_size,pe(i.head),i.max_lazy_match=xe[i.level].max_lazy,i.good_match=xe[i.level].good_length,i.nice_match=xe[i.level].nice_length,i.max_chain_length=xe[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},De=(e,t,i,s,r,n)=>{if(!e)return Y;let A=1;if(t===ee&&(t=6),s<0?(A=0,s=-s):s>15&&(A=2,s-=16),r<1||r>9||i!==oe||s<8||s>15||t<0||t>9||n<0||n>re||8===s&&1!==A)return de(e,Y);8===s&&(s=9);const o=new Ie;return e.state=o,o.strm=e,o.status=ce,o.wrap=A,o.gzhead=null,o.w_bits=s,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=i,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 i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===ue&&t!==X)return de(e,0===e.avail_out?q:Y);const s=i.last_flush;if(i.last_flush=t,0!==i.pending){if(_e(e),0===e.avail_out)return i.last_flush=-1,Z}else if(0===e.avail_in&&fe(t)<=fe(s)&&t!==X)return de(e,q);if(i.status===ue&&0!==e.avail_in)return de(e,q);if(i.status===ce&&0===i.wrap&&(i.status=he),i.status===ce){let t=oe+(i.w_bits-8<<4)<<8,s=-1;if(s=i.strategy>=ie||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=s<<6,0!==i.strstart&&(t|=32),t+=31-t%31,ye(i,t),0!==i.strstart&&(ye(i,e.adler>>>16),ye(i,65535&e.adler)),e.adler=1,i.status=he,_e(e),0!==i.pending)return i.last_flush=-1,Z}if(57===i.status)if(e.adler=0,Be(i,31),Be(i,139),Be(i,8),i.gzhead)Be(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Be(i,255&i.gzhead.time),Be(i,i.gzhead.time>>8&255),Be(i,i.gzhead.time>>16&255),Be(i,i.gzhead.time>>24&255),Be(i,9===i.level?2:i.strategy>=ie||i.level<2?4:0),Be(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(Be(i,255&i.gzhead.extra.length),Be(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Q(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(Be(i,0),Be(i,0),Be(i,0),Be(i,0),Be(i,0),Be(i,9===i.level?2:i.strategy>=ie||i.level<2?4:0),Be(i,3),i.status=he,_e(e),0!==i.pending)return i.last_flush=-1,Z;if(69===i.status){if(i.gzhead.extra){let t=i.pending,s=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+s>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Q(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,_e(e),0!==i.pending)return i.last_flush=-1,Z;t=0,s-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+s),i.pending),i.pending+=s,i.gzhead.hcrc&&i.pending>t&&(e.adler=Q(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(e.adler=Q(e.adler,i.pending_buf,i.pending-s,s)),_e(e),0!==i.pending)return i.last_flush=-1,Z;s=0}t=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,Be(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>s&&(e.adler=Q(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(e.adler=Q(e.adler,i.pending_buf,i.pending-s,s)),_e(e),0!==i.pending)return i.last_flush=-1,Z;s=0}t=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,Be(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>s&&(e.adler=Q(e.adler,i.pending_buf,i.pending-s,s))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(_e(e),0!==i.pending))return i.last_flush=-1,Z;Be(i,255&e.adler),Be(i,e.adler>>8&255),e.adler=0}if(i.status=he,_e(e),0!==i.pending)return i.last_flush=-1,Z}if(0!==e.avail_in||0!==i.lookahead||t!==j&&i.status!==ue){let s=0===i.level?Me(i,t):i.strategy===ie?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(Ce(e),0===e.lookahead)){if(t===j)return 1;break}if(e.match_length=0,i=N(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(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})(i,t):i.strategy===se?((e,t)=>{let i,s,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,s=A[r],s===A[++r]&&s===A[++r]&&s===A[++r])){n=e.strstart+ae;do{}while(s===A[++r]&&s===A[++r]&&s===A[++r]&&s===A[++r]&&s===A[++r]&&s===A[++r]&&s===A[++r]&&s===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?(i=N(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=N(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(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})(i,t):xe[i.level].func(i,t);if(3!==s&&4!==s||(i.status=ue),1===s||3===s)return 0===e.avail_out&&(i.last_flush=-1),Z;if(2===s&&(t===W?G(i):t!==K&&(L(i,0,0,!1),t===z&&(pe(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),_e(e),0===e.avail_out))return i.last_flush=-1,Z}return t!==X?Z:i.wrap<=0?J:(2===i.wrap?(Be(i,255&e.adler),Be(i,e.adler>>8&255),Be(i,e.adler>>16&255),Be(i,e.adler>>24&255),Be(i,255&e.total_in),Be(i,e.total_in>>8&255),Be(i,e.total_in>>16&255),Be(i,e.total_in>>24&255)):(ye(i,e.adler>>>16),ye(i,65535&e.adler)),_e(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.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 i=t.length;if(Te(e))return Y;const s=e.state,r=s.wrap;if(2===r||1===r&&s.status!==ce||s.lookahead)return Y;if(1===r&&(e.adler=D(e.adler,t,i,0)),s.wrap=0,i>=s.w_size){0===r&&(pe(s.head),s.strstart=0,s.block_start=0,s.insert=0);let e=new Uint8Array(s.w_size);e.set(t.subarray(i-s.w_size,i),0),t=e,i=s.w_size}const n=e.avail_in,A=e.next_in,o=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,Ce(s);s.lookahead>=3;){let e=s.strstart,t=s.lookahead-2;do{s.ins_h=me(s,s.ins_h,s.window[e+3-1]),s.prev[e&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=e,e++}while(--t);s.strstart=e,s.lookahead=2,Ce(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,e.next_in=A,e.input=o,e.avail_in=n,s.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 i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Le(i,t)&&(e[t]=i[t])}}return e},Ne=e=>{let t=0;for(let i=0,s=e.length;i<s;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,s=0,r=e.length;t<r;t++){let r=e[t];i.set(r,s),s+=r.length}return i};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,i,s,r,n,A=e.length,o=0;for(r=0;r<A;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<A&&(s=e.charCodeAt(r+1),56320==(64512&s)&&(i=65536+(i-55296<<10)+(s-56320),r++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),n=0,r=0;n<o;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<A&&(s=e.charCodeAt(r+1),56320==(64512&s)&&(i=65536+(i-55296<<10)+(s-56320),r++)),i<128?t[n++]=i:i<2048?(t[n++]=192|i>>>6,t[n++]=128|63&i):i<65536?(t[n++]=224|i>>>12,t[n++]=128|i>>>6&63,t[n++]=128|63&i):(t[n++]=240|i>>>18,t[n++]=128|i>>>12&63,t[n++]=128|i>>>6&63,t[n++]=128|63&i);return t},ze=(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let s,r;const n=new Array(2*i);for(r=0,s=0;s<i;){let t=e[s++];if(t<128){n[r++]=t;continue}let A=je[t];if(A>4)n[r++]=65533,s+=A-1;else{for(t&=2===A?31:3===A?15:7;A>1&&s<i;)t=t<<6|63&e[s++],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 i="";for(let s=0;s<t;s++)i+=String.fromCharCode(e[s]);return i})(n,r)},Xe=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+je[e[i]]>t?i: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:it,Z_DEFAULT_STRATEGY:st,Z_DEFLATED:rt}=O;function nt(e){this.options=He({level:it,method:rt,chunkSize:16384,windowBits:15,memLevel:8,strategy:st},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 i=ke(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==et)throw new Error(R[i]);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,i=Ve(this.strm,e),i!==et)throw new Error(R[i]);this._dict_set=!0}}function At(e,t){const i=new nt(t);if(i.push(e,!0),i.err)throw i.msg||R[i.err];return i.result}nt.prototype.push=function(e,t){const i=this.strm,s=this.options.chunkSize;let r,n;if(this.ended)return!1;for(n=t===~~t?t:!0===t?qe:Je,"string"==typeof e?i.input=We(e):"[object ArrayBuffer]"===Ze.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(n===Ye||n===$e)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Re(i,n),r===tt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Oe(this.strm),this.onEnd(r),this.ended=!0,r===et;if(0!==i.avail_out){if(n>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.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 i,s,r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B,y,w,v,C,M;const E=e.state;i=e.next_in,C=e.input,s=i+(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,f=E.lencode,p=E.distcode,g=(1<<E.lenbits)-1,m=(1<<E.distbits)-1;e:do{d<15&&(u+=C[i++]<<d,d+=8,u+=C[i++]<<d,d+=8),_=f[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)){_=f[(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[i++]<<d,d+=8),B+=u&(1<<b)-1,u>>>=b,d-=b),d<15&&(u+=C[i++]<<d,d+=8,u+=C[i++]<<d,d+=8),_=p[u&m];i:for(;;){if(b=_>>>24,u>>>=b,d-=b,b=_>>>16&255,!(16&b)){if(0==(64&b)){_=p[(65535&_)+(u&(1<<b)-1)];continue i}e.msg="invalid distance code",E.mode=at;break e}if(y=65535&_,b&=15,d<b&&(u+=C[i++]<<d,d+=8,d<b&&(u+=C[i++]<<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(i<s&&r<A);B=d>>3,i-=B,d-=B<<3,u&=(1<<d)-1,e.next_in=i,e.next_out=r,e.avail_in=i<s?s-i+5:5-(i-s),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 ft=(e,t,i,s,r,n,A,o)=>{const a=o.bits;let l,c,h,u,d,f,p=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 U,x,I,T=null;for(p=0;p<=15;p++)E[p]=0;for(g=0;g<s;g++)E[t[i+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,p=1;p<=15;p++)if(w<<=1,w-=E[p],w<0)return-1;if(w>0&&(0===e||1!==_))return-1;for(F[1]=0,p=1;p<15;p++)F[p+1]=F[p]+E[p];for(g=0;g<s;g++)0!==t[i+g]&&(A[F[t[i+g]]++]=g);if(0===e?(M=T=A,f=20):1===e?(M=ct,T=ht,f=257):(M=ut,T=dt,f=0),C=0,g=0,p=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(;;){U=p-y,A[g]+1<f?(x=0,I=A[g]):A[g]>=f?(x=T[A[g]-f],I=M[A[g]-f]):(x=96,I=0),l=1<<p-y,c=1<<B,m=c;do{c-=l,r[d+(C>>y)+c]=U<<24|x<<16|I|0}while(0!==c);for(l=1<<p-1;C&l;)l>>=1;if(0!==l?(C&=l-1,C+=l):C=0,g++,0==--E[p]){if(p===_)break;p=t[i+A[g]]}if(p>b&&(C&u)!==h){for(0===y&&(y=b),d+=m,B=p-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]=p-y<<24|64<<16|0),o.bits=b,0};const{Z_FINISH:pt,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,Ut=16191,xt=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 i;if(Rt(e))return yt;const s=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?yt:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,Vt(e))},Ht=(e,t)=>{if(!e)return yt;const i=new Qt;e.state=i,i.strm=e,i.window=null,i.mode=Et;const s=Lt(e,t);return s!==_t&&(e.state=null),s};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(ft(1,e.lens,0,288,Nt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ft(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,i,s)=>{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)),s>=n.wsize?(n.window.set(t.subarray(i-n.wsize,i),0),n.wnext=0,n.whave=n.wsize):(r=n.wsize-n.wnext,r>s&&(r=s),n.window.set(t.subarray(i-s,i-s+r),n.wnext),(s-=r)?(n.window.set(t.subarray(i-s,i),0),n.wnext=s,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 i,s,r,n,A,o,a,l,c,h,u,d,f,p,g,m,_,b,B,y,w,v,C=0;const M=new Uint8Array(4);let E,F;const U=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;i=e.state,i.mode===Ut&&(i.mode=xt),A=e.next_out,r=e.output,a=e.avail_out,n=e.next_in,s=e.input,o=e.avail_in,l=i.hold,c=i.bits,h=o,u=a,v=_t;e:for(;;)switch(i.mode){case Et:if(0===i.wrap){i.mode=xt;break}for(;c<16;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(2&i.wrap&&35615===l){0===i.wbits&&(i.wbits=15),i.check=0,M[0]=255&l,M[1]=l>>>8&255,i.check=Q(i.check,M,2,0),l=0,c=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=Dt;break}if((15&l)!==Mt){e.msg="unknown compression method",i.mode=Dt;break}if(l>>>=4,c-=4,w=8+(15&l),0===i.wbits&&(i.wbits=w),w>15||w>i.wbits){e.msg="invalid window size",i.mode=Dt;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=512&l?16189:Ut,l=0,c=0;break;case 16181:for(;c<16;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(i.flags=l,(255&i.flags)!==Mt){e.msg="unknown compression method",i.mode=Dt;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=Dt;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&4&i.wrap&&(M[0]=255&l,M[1]=l>>>8&255,i.check=Q(i.check,M,2,0)),l=0,c=0,i.mode=16182;case 16182:for(;c<32;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}i.head&&(i.head.time=l),512&i.flags&&4&i.wrap&&(M[0]=255&l,M[1]=l>>>8&255,M[2]=l>>>16&255,M[3]=l>>>24&255,i.check=Q(i.check,M,4,0)),l=0,c=0,i.mode=16183;case 16183:for(;c<16;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&4&i.wrap&&(M[0]=255&l,M[1]=l>>>8&255,i.check=Q(i.check,M,2,0)),l=0,c=0,i.mode=16184;case 16184:if(1024&i.flags){for(;c<16;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&4&i.wrap&&(M[0]=255&l,M[1]=l>>>8&255,i.check=Q(i.check,M,2,0)),l=0,c=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(d=i.length,d>o&&(d=o),d&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(s.subarray(n,n+d),w)),512&i.flags&&4&i.wrap&&(i.check=Q(i.check,s,d,n)),o-=d,n+=d,i.length-=d),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===o)break e;d=0;do{w=s[n+d++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&d<o);if(512&i.flags&&4&i.wrap&&(i.check=Q(i.check,s,d,n)),o-=d,n+=d,w)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===o)break e;d=0;do{w=s[n+d++],i.head&&w&&i.length<65536&&(i.head.comment+=String.fromCharCode(w))}while(w&&d<o);if(512&i.flags&&4&i.wrap&&(i.check=Q(i.check,s,d,n)),o-=d,n+=d,w)break e}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;c<16;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(4&i.wrap&&l!==(65535&i.check)){e.msg="header crc mismatch",i.mode=Dt;break}l=0,c=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Ut;break;case 16189:for(;c<32;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}e.adler=i.check=kt(l),l=0,c=0,i.mode=Ft;case Ft:if(0===i.havedict)return e.next_out=A,e.avail_out=a,e.next_in=n,e.avail_in=o,i.hold=l,i.bits=c,Bt;e.adler=i.check=1,i.mode=Ut;case Ut:if(t===gt||t===mt)break e;case xt:if(i.last){l>>>=7&c,c-=7&c,i.mode=St;break}for(;c<3;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}switch(i.last=1&l,l>>>=1,c-=1,3&l){case 0:i.mode=16193;break;case 1:if(Wt(i),i.mode=Tt,t===mt){l>>>=2,c-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.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+=s[n++]<<c,c+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",i.mode=Dt;break}if(i.length=65535&l,l=0,c=0,i.mode=It,t===mt)break e;case It:i.mode=16195;case 16195:if(d=i.length,d){if(d>o&&(d=o),d>a&&(d=a),0===d)break e;r.set(s.subarray(n,n+d),A),o-=d,n+=d,a-=d,A+=d,i.length-=d;break}i.mode=Ut;break;case 16196:for(;c<14;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(i.nlen=257+(31&l),l>>>=5,c-=5,i.ndist=1+(31&l),l>>>=5,c-=5,i.ncode=4+(15&l),l>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Dt;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;c<3;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}i.lens[U[i.have++]]=7&l,l>>>=3,c-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,E={bits:i.lenbits},v=ft(0,i.lens,0,19,i.lencode,0,i.work,E),i.lenbits=E.bits,v){e.msg="invalid code lengths set",i.mode=Dt;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;C=i.lencode[l&(1<<i.lenbits)-1],g=C>>>24,m=C>>>16&255,_=65535&C,!(g<=c);){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(_<16)l>>>=g,c-=g,i.lens[i.have++]=_;else{if(16===_){for(F=g+2;c<F;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(l>>>=g,c-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=Dt;break}w=i.lens[i.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+=s[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+=s[n++]<<c,c+=8}l>>>=g,c-=g,w=0,d=11+(127&l),l>>>=7,c-=7}if(i.have+d>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Dt;break}for(;d--;)i.lens[i.have++]=w}}if(i.mode===Dt)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Dt;break}if(i.lenbits=9,E={bits:i.lenbits},v=ft(1,i.lens,0,i.nlen,i.lencode,0,i.work,E),i.lenbits=E.bits,v){e.msg="invalid literal/lengths set",i.mode=Dt;break}if(i.distbits=6,i.distcode=i.distdyn,E={bits:i.distbits},v=ft(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,E),i.distbits=E.bits,v){e.msg="invalid distances set",i.mode=Dt;break}if(i.mode=Tt,t===mt)break e;case Tt:i.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,i.hold=l,i.bits=c,lt(e,u),A=e.next_out,r=e.output,a=e.avail_out,n=e.next_in,s=e.input,o=e.avail_in,l=i.hold,c=i.bits,i.mode===Ut&&(i.back=-1);break}for(i.back=0;C=i.lencode[l&(1<<i.lenbits)-1],g=C>>>24,m=C>>>16&255,_=65535&C,!(g<=c);){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(m&&0==(240&m)){for(b=g,B=m,y=_;C=i.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+=s[n++]<<c,c+=8}l>>>=b,c-=b,i.back+=b}if(l>>>=g,c-=g,i.back+=g,i.length=_,0===m){i.mode=16205;break}if(32&m){i.back=-1,i.mode=Ut;break}if(64&m){e.msg="invalid literal/length code",i.mode=Dt;break}i.extra=15&m,i.mode=16201;case 16201:if(i.extra){for(F=i.extra;c<F;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;C=i.distcode[l&(1<<i.distbits)-1],g=C>>>24,m=C>>>16&255,_=65535&C,!(g<=c);){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(0==(240&m)){for(b=g,B=m,y=_;C=i.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+=s[n++]<<c,c+=8}l>>>=b,c-=b,i.back+=b}if(l>>>=g,c-=g,i.back+=g,64&m){e.msg="invalid distance code",i.mode=Dt;break}i.offset=_,i.extra=15&m,i.mode=16203;case 16203:if(i.extra){for(F=i.extra;c<F;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Dt;break}i.mode=16204;case 16204:if(0===a)break e;if(d=u-a,i.offset>d){if(d=i.offset-d,d>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Dt;break}d>i.wnext?(d-=i.wnext,f=i.wsize-d):f=i.wnext-d,d>i.length&&(d=i.length),p=i.window}else p=r,f=A-i.offset,d=i.length;d>a&&(d=a),a-=d,i.length-=d;do{r[A++]=p[f++]}while(--d);0===i.length&&(i.mode=Pt);break;case 16205:if(0===a)break e;r[A++]=i.length,a--,i.mode=Pt;break;case St:if(i.wrap){for(;c<32;){if(0===o)break e;o--,l|=s[n++]<<c,c+=8}if(u-=a,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Q(i.check,r,u,A-u):D(i.check,r,u,A-u)),u=a,4&i.wrap&&(i.flags?l:kt(l))!==i.check){e.msg="incorrect data check",i.mode=Dt;break}l=0,c=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;c<32;){if(0===o)break e;o--,l+=s[n++]<<c,c+=8}if(4&i.wrap&&l!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=Dt;break}l=0,c=0}i.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,i.hold=l,i.bits=c,(i.wsize||u!==e.avail_out&&i.mode<Dt&&(i.mode<St||t!==pt))&&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,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Q(i.check,r,u,e.next_out-u):D(i.check,r,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===Ut?128:0)+(i.mode===Tt||i.mode===It?256:0),(0===h&&0===u||t===pt)&&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 i=e.state;return 0==(2&i.wrap)?yt:(i.head=t,t.done=!1,_t)},$t=(e,t)=>{const i=t.length;let s,r,n;return Rt(e)?yt:(s=e.state,0!==s.wrap&&s.mode!==Ft?yt:s.mode===Ft&&(r=1,r=D(r,t,i,0),r!==s.check)?wt:(n=zt(e,t,i,i),n?(s.mode=16210,vt):(s.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 ei=Object.prototype.toString,{Z_NO_FLUSH:ti,Z_FINISH:ii,Z_OK:si,Z_STREAM_END:ri,Z_NEED_DICT:ni,Z_STREAM_ERROR:Ai,Z_DATA_ERROR:oi,Z_MEM_ERROR:ai}=O;function li(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 i=Kt(this.strm,t.windowBits);if(i!==si)throw new Error(R[i]);if(this.header=new qt,Yt(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=We(t.dictionary):"[object ArrayBuffer]"===ei.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=$t(this.strm,t.dictionary),i!==si)))throw new Error(R[i])}function ci(e,t){const i=new li(t);if(i.push(e),i.err)throw i.msg||R[i.err];return i.result}li.prototype.push=function(e,t){const i=this.strm,s=this.options.chunkSize,r=this.options.dictionary;let n,A,o;if(this.ended)return!1;for(A=t===~~t?t:!0===t?ii:ti,"[object ArrayBuffer]"===ei.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),n=Zt(i,A),n===ni&&r&&(n=$t(i,r),n===si?n=Zt(i,A):n===oi&&(n=ni));i.avail_in>0&&n===ri&&i.state.wrap>0&&0!==e[i.next_in];)Xt(i),n=Zt(i,A);switch(n){case Ai:case oi:case ni:case ai:return this.onEnd(n),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||n===ri))if("string"===this.options.to){let e=Xe(i.output,i.next_out),t=i.next_out-e,r=ze(i.output,e);i.next_out=t,i.avail_out=s-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(n!==si||0!==o){if(n===ri)return n=Jt(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},li.prototype.onData=function(e){this.chunks.push(e)},li.prototype.onEnd=function(e){e===si&&("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 hi={Inflate:li,inflate:ci,inflateRaw:function(e,t){return(t=t||{}).raw=!0,ci(e,t)},ungzip:ci,constants:O};const{Deflate:ui,deflate:di,deflateRaw:fi,gzip:pi}=ot,{Inflate:gi,inflate:mi,inflateRaw:_i,ungzip:bi}=hi;var Bi=ui,yi=di,wi=fi,vi=pi,Ci=gi,Mi=mi,Ei=_i,Fi=bi,Ui=O,xi={Deflate:Bi,deflate:yi,deflateRaw:wi,gzip:vi,Inflate:Ci,inflate:Mi,inflateRaw:Ei,ungzip:Fi,constants:Ui};e.Deflate=Bi,e.Inflate=Ci,e.constants=Ui,e.default=xi,e.deflate=yi,e.deflateRaw=wi,e.gzip=vi,e.inflate=Mi,e.inflateRaw=Ei,e.ungzip=Fi,Object.defineProperty(e,"__esModule",{value:!0})}));var jv=Object.freeze({__proto__:null});let Wv=window.pako||jv;Wv.inflate||(Wv=Wv.default);const zv=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 Xv={version:1,parse:function(e,t,i,s,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]}}(i),o=function(e){return{positions:new Uint16Array(Wv.inflate(e.positions).buffer),normals:new Int8Array(Wv.inflate(e.normals).buffer),indices:new Uint32Array(Wv.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Wv.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(Wv.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(Wv.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(Wv.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(Wv.inflate(e.meshColors).buffer),entityIDs:Wv.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(Wv.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(Wv.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(Wv.inflate(e.positionsDecodeMatrix).buffer)}}(A);!function(e,t,i,s,r,n){n.getNextId(),s.positionsCompression="precompressed",s.normalsCompression="precompressed";const A=i.positions,o=i.normals,a=i.indices,l=i.edgeIndices,c=i.meshPositions,h=i.meshIndices,u=i.meshEdgesIndices,d=i.meshColors,f=JSON.parse(i.entityIDs),p=i.entityMeshes,g=i.entityIsObjects,m=c.length,_=p.length;for(let r=0;r<_;r++){const n=f[r],b=t.globalizeObjectIds?V.globalizeObjectId(s.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=p[r],t=v?p.length:p[r+1];e<t;e++){const t=e===m-1,r=b+".mesh."+e,n=zv(d.subarray(4*e,4*e+3)),f=d[4*e+3]/255;s.createMesh(X.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:i.positionsDecodeMatrix,color:n,opacity:f})),C.push(r)}s.createEntity(X.apply(y,{id:b,isObject:1===g[r],meshIds:C}))}}(e,t,o,s,0,n)}};let Kv=window.pako||jv;Kv.inflate||(Kv=Kv.default);const Zv=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 Jv={version:2,parse:function(e,t,i,s,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]}}(i),o=function(e){return{positions:new Uint16Array(Kv.inflate(e.positions).buffer),normals:new Int8Array(Kv.inflate(e.normals).buffer),indices:new Uint32Array(Kv.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Kv.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(Kv.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(Kv.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(Kv.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(Kv.inflate(e.meshColors).buffer),entityIDs:Kv.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(Kv.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(Kv.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(Kv.inflate(e.positionsDecodeMatrix).buffer),entityMeshIds:new Uint32Array(Kv.inflate(e.entityMeshIds).buffer),entityMatrices:new Float32Array(Kv.inflate(e.entityMatrices).buffer),entityUsesInstancing:new Uint8Array(Kv.inflate(e.entityUsesInstancing).buffer)}}(A);!function(e,t,i,s,r,n){const A=n.getNextId();s.positionsCompression="precompressed",s.normalsCompression="precompressed";const o=i.positions,a=i.normals,l=i.indices,c=i.edgeIndices,h=i.meshPositions,u=i.meshIndices,d=i.meshEdgesIndices,f=i.meshColors,p=JSON.parse(i.entityIDs),g=i.entityMeshes,m=i.entityIsObjects,_=i.entityMeshIds,b=i.entityMatrices,B=i.entityUsesInstancing,y=h.length,w=g.length,v={};for(let r=0;r<w;r++){const C=p[r],M=t.globalizeObjectIds?V.globalizeObjectId(s.id,C):C,E=e.metaScene.metaObjects[M],F={},U={},x=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&&(U.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(U.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],p=t===y-1,g=n.getNextId(),m=Zv(f.subarray(4*t,4*t+3)),b=f[4*t+3]/255,w=o.subarray(h[t],p?o.length:h[t+1]),C=a.subarray(h[t],p?o.length:h[t+1]),M=l.subarray(u[t],p?l.length:u[t+1]),E=c.subarray(d[t],p?c.length:d[t+1]);if(1===B[r]){const e=`${A}.geometry.${g}.${t}`;e in v||(s.createGeometry({id:e,positionsCompressed:w,normalsCompressed:C,indices:M,edgeIndices:E,primitive:"triangles",positionsDecodeMatrix:i.positionsDecodeMatrix}),v[e]=!0),s.createMesh(X.apply(U,{id:g,color:m,opacity:b,matrix:x,geometryId:e})),T.push(g)}else s.createMesh(X.apply(U,{id:g,primitive:"triangles",positionsCompressed:w,normalsCompressed:C,indices:M,edgeIndices:E,positionsDecodeMatrix:i.positionsDecodeMatrix,color:m,opacity:b})),T.push(g)}T.length&&s.createEntity(X.apply(F,{id:M,isObject:1===m[r],meshIds:T}))}}(e,t,o,s,0,n)}};let Yv=window.pako||jv;Yv.inflate||(Yv=Yv.default);const $v=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 qv={version:3,parse:function(e,t,i,s,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]}}(i),o=function(e){return{positions:new Uint16Array(Yv.inflate(e.positions).buffer),normals:new Int8Array(Yv.inflate(e.normals).buffer),indices:new Uint32Array(Yv.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Yv.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(Yv.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(Yv.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(Yv.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(Yv.inflate(e.meshColors).buffer),entityIDs:Yv.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(Yv.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(Yv.inflate(e.entityIsObjects).buffer),instancedPositionsDecodeMatrix:new Float32Array(Yv.inflate(e.instancedPositionsDecodeMatrix).buffer),batchedPositionsDecodeMatrix:new Float32Array(Yv.inflate(e.batchedPositionsDecodeMatrix).buffer),entityMeshIds:new Uint32Array(Yv.inflate(e.entityMeshIds).buffer),entityMatrices:new Float32Array(Yv.inflate(e.entityMatrices).buffer),entityUsesInstancing:new Uint8Array(Yv.inflate(e.entityUsesInstancing).buffer)}}(A);!function(e,t,i,s,r,n){const A=n.getNextId();s.positionsCompression="precompressed",s.normalsCompression="precompressed";const o=i.positions,a=i.normals,l=i.indices,c=i.edgeIndices,h=i.meshPositions,u=i.meshIndices,d=i.meshEdgesIndices,f=i.meshColors,p=JSON.parse(i.entityIDs),g=i.entityMeshes,m=i.entityIsObjects,_=i.entityMeshIds,b=i.entityMatrices,B=i.entityUsesInstancing,y=h.length,w=g.length,v={};for(let r=0;r<w;r++){const n=p[r],x=t.globalizeObjectIds?V.globalizeObjectId(s.id,n):n,I=e.metaScene.metaObjects[x],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}.${x}.mesh.${C}`,p=$v(f.subarray(4*C,4*C+3)),g=f[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]),U=c.subarray(d[C],t?c.length:d[C+1]);if(1===B[r]){const e=`${A}.geometry.${n}.${C}`;e in v||(s.createGeometry({id:e,positionsCompressed:M,normalsCompressed:E,indices:F,edgeIndices:U,primitive:"triangles",positionsDecodeMatrix:i.instancedPositionsDecodeMatrix}),v[e]=!0),s.createMesh(X.apply(P,{id:n,color:p,opacity:g,matrix:S,geometryId:e})),k.push(n)}else s.createMesh(X.apply(P,{id:n,primitive:"triangles",positionsCompressed:M,normalsCompressed:E,indices:F,edgeIndices:U,positionsDecodeMatrix:i.batchedPositionsDecodeMatrix,color:p,opacity:g})),k.push(n)}k.length&&s.createEntity(X.apply(T,{id:x,isObject:1===m[r],meshIds:k}))}}(e,t,o,s,0,n)}};let eC=window.pako||jv;eC.inflate||(eC=eC.default);const tC=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 iC={version:4,parse:function(e,t,i,s,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]}}(i),o=function(e){return{positions:new Uint16Array(eC.inflate(e.positions).buffer),normals:new Int8Array(eC.inflate(e.normals).buffer),indices:new Uint32Array(eC.inflate(e.indices).buffer),edgeIndices:new Uint32Array(eC.inflate(e.edgeIndices).buffer),decodeMatrices:new Float32Array(eC.inflate(e.decodeMatrices).buffer),matrices:new Float32Array(eC.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(eC.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(eC.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(eC.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveDecodeMatricesPortion:new Uint32Array(eC.inflate(e.eachPrimitiveDecodeMatricesPortion).buffer),eachPrimitiveColor:new Uint8Array(eC.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(eC.inflate(e.primitiveInstances).buffer),eachEntityId:eC.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(eC.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(eC.inflate(e.eachEntityMatricesPortion).buffer)}}(A);!function(e,t,i,s,r,n){const A=n.getNextId();s.positionsCompression="precompressed",s.normalsCompression="precompressed";const o=i.positions,a=i.normals,l=i.indices,c=i.edgeIndices,h=i.decodeMatrices,u=i.matrices,d=i.eachPrimitivePositionsAndNormalsPortion,f=i.eachPrimitiveIndicesPortion,p=i.eachPrimitiveEdgeIndicesPortion,g=i.eachPrimitiveDecodeMatricesPortion,m=i.eachPrimitiveColor,_=i.primitiveInstances,b=JSON.parse(i.eachEntityId),B=i.eachEntityPrimitiveInstancesPortion,y=i.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,i=e===t,s=B[e],r=i?B[t]:B[e+1];for(let t=s;t<r;t++){const i=_[t];C[i]>1||(F[i]=e)}}for(let e=0;e<w;e++){const t=M[e],i=t===w-1,r=C[t]>1,n=tC(m.subarray(4*t,4*t+3)),u=m[4*t+3]/255,_=o.subarray(d[t],i?o.length:d[t+1]),B=a.subarray(d[t],i?a.length:d[t+1]),y=l.subarray(f[t],i?l.length:f[t+1]),v=c.subarray(p[t],i?c.length:p[t+1]),E=h.subarray(g[t],g[t]+16);if(r){const e=`${A}-geometry.${t}`;s.createGeometry({id:e,primitive:"triangles",positionsCompressed:_,normalsCompressed:B,indices:y,edgeIndices:v,positionsDecodeMatrix:E})}else{const e=`${A}-${t}`;b[F[t]];const i={};s.createMesh(X.apply(i,{id:e,primitive:"triangles",positionsCompressed:_,normalsCompressed:B,indices:y,edgeIndices:v,positionsDecodeMatrix:E,color:n,opacity:u}))}}let U=0;for(let e=0;e<E;e++){const t=E-1,i=e===t,r=b[e],n=B[e],o=i?B[t]:B[e+1],a=[];for(let t=n;t<o;t++){const i=_[t];if(C[i]>1){const t={},r=`${A}-instance.${U++}`,n=`${A}-geometry.${i}`,o=16*y[e],l=u.subarray(o,o+16);s.createMesh(X.apply(t,{id:r,geometryId:n,matrix:l})),a.push(r)}else a.push(i)}if(a.length>0){const e={};s.createEntity(X.apply(e,{id:r,isObject:!0,meshIds:a}))}}}(0,0,o,s,0,n)}};let sC=window.pako||jv;sC.inflate||(sC=sC.default);const rC=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 nC={version:5,parse:function(e,t,i,s,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]}}(i),o=function(e){return{positions:new Float32Array(sC.inflate(e.positions).buffer),normals:new Int8Array(sC.inflate(e.normals).buffer),indices:new Uint32Array(sC.inflate(e.indices).buffer),edgeIndices:new Uint32Array(sC.inflate(e.edgeIndices).buffer),matrices:new Float32Array(sC.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(sC.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(sC.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(sC.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveColor:new Uint8Array(sC.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(sC.inflate(e.primitiveInstances).buffer),eachEntityId:sC.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(sC.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(sC.inflate(e.eachEntityMatricesPortion).buffer)}}(A);!function(e,t,i,s,r,n){const A=n.getNextId();s.positionsCompression="disabled",s.normalsCompression="precompressed";const o=i.positions,a=i.normals,l=i.indices,c=i.edgeIndices,h=i.matrices,u=i.eachPrimitivePositionsAndNormalsPortion,d=i.eachPrimitiveIndicesPortion,f=i.eachPrimitiveEdgeIndicesPortion,p=i.eachPrimitiveColor,g=i.primitiveInstances,m=JSON.parse(i.eachEntityId),_=i.eachEntityPrimitiveInstancesPortion,b=i.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,i=e===t,s=_[e],r=i?_[t]:_[e+1];for(let t=s;t<r;t++){const i=g[t];w[i]>1||(C[i]=e)}}for(let e=0;e<B;e++){const t=e===B-1,i=w[e]>1,r=rC(p.subarray(4*e,4*e+3)),n=p[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(f[e],t?c.length:f[e+1]);if(i){const t=`${A}-geometry.${e}`;s.createGeometry({id:t,primitive:"triangles",positionsCompressed:h,normalsCompressed:g,indices:_,edgeIndices:b})}else{const t=e;m[C[e]];const i={};s.createMesh(X.apply(i,{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,i=e===t,r=m[e],n=_[e],A=i?_[t]:_[e+1],o=[];for(let t=n;t<A;t++){const i=g[t];if(w[i]>1){const t={},r="instance."+M++,n="geometry"+i,A=16*b[e],a=h.subarray(A,A+16);s.createMesh(X.apply(t,{id:r,geometryId:n,matrix:a})),o.push(r)}else o.push(i)}if(o.length>0){const e={};s.createEntity(X.apply(e,{id:r,isObject:!0,meshIds:o}))}}}(0,0,o,s,0,n)}};let AC=window.pako||jv;AC.inflate||(AC=AC.default);const oC=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 aC={version:6,parse:function(e,t,i,s,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]}}(i),o=function(e){function t(e,t){return 0===e.length?[]:AC.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:AC.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,i,s,r,n){const A=n.getNextId(),o=i.positions,a=i.normals,l=i.indices,c=i.edgeIndices,h=i.matrices,u=i.reusedPrimitivesDecodeMatrix,d=i.eachPrimitivePositionsAndNormalsPortion,f=i.eachPrimitiveIndicesPortion,p=i.eachPrimitiveEdgeIndicesPortion,g=i.eachPrimitiveColorAndOpacity,m=i.primitiveInstances,_=JSON.parse(i.eachEntityId),b=i.eachEntityPrimitiveInstancesPortion,B=i.eachEntityMatricesPortion,y=i.eachTileAABB,w=i.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 U=V.vec3(),x=V.AABB3();for(let i=0;i<E;i++){const r=i===E-1,C=w[i],I=r?M:w[i+1],T=6*i,P=y.subarray(T,T+6);V.getAABB3Center(P,U),x[0]=P[0]-U[0],x[1]=P[1]-U[1],x[2]=P[2]-U[2],x[3]=P[3]-U[0],x[4]=P[4]-U[1],x[5]=P[5]-U[2];const S=Ne.createPositionsDecodeMatrix(x),D={};for(let r=C;r<I;r++){const y=_[r],w=t.globalizeObjectIds?V.globalizeObjectId(s.id,y):y,C=B[r],E=h.slice(C,C+16),x=r===M-1,I=b[r],T=x?m.length:b[r+1],P=[],k=e.metaScene.metaObjects[w],Q={},R={};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&&(R.color=e.colorize),void 0!==e.opacity&&null!==e.opacity&&(R.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(f[t],h?l.length:f[t+1]),y=c.subarray(p[t],h?c.length:p[t+1]),w=oC(g.subarray(4*t,4*t+3)),C=g[4*t+3]/255,M=n.getNextId();if(r){const e=`${A}-geometry.${i}.${t}`;D[e]||(s.createGeometry({id:e,primitive:"triangles",positionsCompressed:_,indices:B,edgeIndices:y,positionsDecodeMatrix:u}),D[e]=!0),s.createMesh(X.apply(R,{id:M,geometryId:e,origin:U,matrix:E,color:w,opacity:C})),P.push(M)}else s.createMesh(X.apply(R,{id:M,origin:U,primitive:"triangles",positionsCompressed:_,normalsCompressed:b,indices:B,edgeIndices:y,positionsDecodeMatrix:S,color:w,opacity:C})),P.push(M)}P.length>0&&s.createEntity(X.apply(Q,{id:w,isObject:!0,meshIds:P}))}}}(e,t,o,s,0,n)}};let lC=window.pako||jv;lC.inflate||(lC=lC.default);const cC=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 hC(e){const t=[];for(let i=0,s=e.length;i<s;i+=3)t.push(e[i]),t.push(e[i+1]),t.push(e[i+2]),t.push(1);return t}const uC={version:7,parse:function(e,t,i,s,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]}}(i),o=function(e){function t(e,t){return 0===e.length?[]:lC.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:lC.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,i,s,r,n){const A=n.getNextId(),o=i.positions,a=i.normals,l=i.colors,c=i.indices,h=i.edgeIndices,u=i.matrices,d=i.reusedGeometriesDecodeMatrix,f=i.eachGeometryPrimitiveType,p=i.eachGeometryPositionsPortion,g=i.eachGeometryNormalsPortion,m=i.eachGeometryColorsPortion,_=i.eachGeometryIndicesPortion,b=i.eachGeometryEdgeIndicesPortion,B=i.eachMeshGeometriesPortion,y=i.eachMeshMatricesPortion,w=i.eachMeshMaterial,v=JSON.parse(i.eachEntityId),C=i.eachEntityMeshesPortion,M=i.eachTileAABB,E=i.eachTileEntitiesPortion,F=p.length,U=B.length,x=v.length,I=E.length,T=new Uint32Array(F);for(let e=0;e<U;e++){const t=B[e];void 0!==T[t]?T[t]++:T[t]=1}const P=V.vec3(),S=V.AABB3();for(let i=0;i<I;i++){const r=i===I-1,U=E[i],D=r?x:E[i+1],k=6*i,Q=M.subarray(k,k+6);V.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 R=Ne.createPositionsDecodeMatrix(S),O={};for(let r=U;r<D;r++){const M=v[r],E=t.globalizeObjectIds?V.globalizeObjectId(s.id,M):M,U=r===x-1,I=C[r],S=U?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=cC(w.subarray(6*e,6*e+3)),M=w[6*e+3]/255,E=w[6*e+4]/255,U=w[6*e+5]/255,x=n.getNextId();if(r){const r=y[e],n=u.slice(r,r+16),B=`${A}-geometry.${i}.${t}`;if(!O[B]){let e,i,r,n,A,u;switch(f[t]){case 0:e="solid",i=o.subarray(p[t],v?o.length:p[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",i=o.subarray(p[t],v?o.length:p[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",i=o.subarray(p[t],v?o.length:p[t+1]),n=hC(l.subarray(m[t],v?l.length:m[t+1]));break;case 3:e="lines",i=o.subarray(p[t],v?o.length:p[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]);break;default:continue}s.createGeometry({id:B,primitive:e,positionsCompressed:i,normalsCompressed:r,colors:n,indices:A,edgeIndices:u,positionsDecodeMatrix:d}),O[B]=!0}s.createMesh(X.apply(L,{id:x,geometryId:B,origin:P,matrix:n,color:C,metallic:E,roughness:U,opacity:M})),D.push(x)}else{let e,i,r,n,A,u;switch(f[t]){case 0:e="solid",i=o.subarray(p[t],v?o.length:p[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",i=o.subarray(p[t],v?o.length:p[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",i=o.subarray(p[t],v?o.length:p[t+1]),n=hC(l.subarray(m[t],v?l.length:m[t+1]));break;case 3:e="lines",i=o.subarray(p[t],v?o.length:p[t+1]),A=c.subarray(_[t],v?c.length:_[t+1]);break;default:continue}s.createMesh(X.apply(L,{id:x,origin:P,primitive:e,positionsCompressed:i,normalsCompressed:r,colors:n,indices:A,edgeIndices:u,positionsDecodeMatrix:R,color:C,metallic:E,roughness:U,opacity:M})),D.push(x)}}D.length>0&&s.createEntity(X.apply(Q,{id:E,isObject:!0,meshIds:D}))}}}(e,t,o,s,0,n)}};let dC=window.pako||jv;dC.inflate||(dC=dC.default);const fC=V.vec4(),pC=V.vec4();const gC=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 mC(e){const t=[];for(let i=0,s=e.length;i<s;i+=3)t.push(e[i]),t.push(e[i+1]),t.push(e[i+2]),t.push(1);return t}const _C={version:8,parse:function(e,t,i,s,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]}}(i),o=function(e){function t(e,t){return 0===e.length?[]:dC.inflate(e,t).buffer}return{types:dC.inflate(e.types,{to:"string"}),eachMetaObjectId:dC.inflate(e.eachMetaObjectId,{to:"string"}),eachMetaObjectType:new Uint32Array(t(e.eachMetaObjectType)),eachMetaObjectName:dC.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,i,s,r,n){const A=n.getNextId(),o=JSON.parse(i.types),a=JSON.parse(i.eachMetaObjectId),l=i.eachMetaObjectType,c=JSON.parse(i.eachMetaObjectName),h=i.eachMetaObjectParent,u=i.positions,d=i.normals,f=i.colors,p=i.indices,g=i.edgeIndices,m=i.matrices,_=i.reusedGeometriesDecodeMatrix,b=i.eachGeometryPrimitiveType,B=i.eachGeometryPositionsPortion,y=i.eachGeometryNormalsPortion,w=i.eachGeometryColorsPortion,v=i.eachGeometryIndicesPortion,C=i.eachGeometryEdgeIndicesPortion,M=i.eachMeshGeometriesPortion,E=i.eachMeshMatricesPortion,F=i.eachMeshMaterial,U=i.eachEntityMetaObject,x=i.eachEntityMeshesPortion,I=i.eachTileAABB,T=i.eachTileEntitiesPortion,P=a.length,S=B.length,D=M.length,k=U.length,Q=T.length;if(r){const e={metaObjects:[]};for(let t=0;t<P;t++){const i=a[t],s=o[l[t]]||"default",r=c[t],n=h[t],A=n!==t?a[n]:null;e.metaObjects.push({id:i,type:s,name:r,parent:A})}r.loadData(e,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds})}const R=new Uint32Array(S);for(let e=0;e<D;e++){const t=M[e];void 0!==R[t]?R[t]++:R[t]=1}const O=V.vec3(),L=V.AABB3(),H={};for(let i=0;i<Q;i++){const r=i===Q-1,o=T[i],l=r?k:T[i+1],c=6*i,h=I.subarray(c,c+6);V.getAABB3Center(h,O),L[0]=h[0]-O[0],L[1]=h[1]-O[1],L[2]=h[2]-O[2],L[3]=h[3]-O[0],L[4]=h[4]-O[1],L[5]=h[5]-O[2];const P=Ne.createPositionsDecodeMatrix(L),D={};for(let r=o;r<l;r++){const o=a[U[r]],l=t.globalizeObjectIds?V.globalizeObjectId(s.id,o):o,c=r===k-1,h=x[r],I=c?M.length:x[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=R[r]>1,a=r===S-1,l=gC(F.subarray(6*e,6*e+3)),c=F[6*e+3]/255,h=F[6*e+4]/255,U=F[6*e+5]/255,x=n.getNextId();if(o){const n=E[e],o=m.slice(n,n+16),M=`${A}-geometry.${i}.${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=p.subarray(v[r],a?p.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=p.subarray(v[r],a?p.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=mC(f.subarray(w[r],a?f.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=p.subarray(v[r],a?p.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 i=0,s=e.length;i<s;i+=3)t[i+0]=e[i+0]*_[0]+_[12],t[i+1]=e[i+1]*_[5]+_[13],t[i+2]=e[i+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 i=0,s=e.length;i<s;i+=3)fC[0]=e[i+0],fC[1]=e[i+1],fC[2]=e[i+2],fC[3]=1,V.transformVec4(o,fC,pC),Ne.compressPosition(pC,L,fC),t[i+0]=fC[0],t[i+1]=fC[1],t[i+2]=fC[2];s.createMesh(X.apply(G,{id:x,origin:O,primitive:F.primitiveName,positionsCompressed:t,normalsCompressed:F.geometryNormals,colorsCompressed:F.geometryColors,indices:F.geometryIndices,edgeIndices:F.geometryEdgeIndices,positionsDecodeMatrix:P,color:l,metallic:h,roughness:U,opacity:c})),T.push(x)}else D[M]||(s.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),s.createMesh(X.apply(G,{id:x,geometryId:M,origin:O,matrix:o,color:l,metallic:h,roughness:U,opacity:c})),T.push(x)}else{let e,t,i,n,A,o,m=!1;switch(b[r]){case 0:e="solid",t=u.subarray(B[r],a?u.length:B[r+1]),i=d.subarray(y[r],a?d.length:y[r+1]),A=p.subarray(v[r],a?p.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]),i=d.subarray(y[r],a?d.length:y[r+1]),A=p.subarray(v[r],a?p.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=mC(f.subarray(w[r],a?f.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=p.subarray(v[r],a?p.length:v[r+1]),m=t.length>0&&A.length>0;break;default:continue}m&&(s.createMesh(X.apply(G,{id:x,origin:O,primitive:e,positionsCompressed:t,normalsCompressed:i,colorsCompressed:n,indices:A,edgeIndices:o,positionsDecodeMatrix:P,color:l,metallic:h,roughness:U,opacity:c})),T.push(x))}}T.length>0&&s.createEntity(X.apply(N,{id:l,isObject:!0,meshIds:T}))}}}(e,t,o,s,r,n)}};let bC=window.pako||jv;bC.inflate||(bC=bC.default);const BC=V.vec4(),yC=V.vec4();const wC=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 vC={version:9,parse:function(e,t,i,s,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]}}(i),o=function(e){function t(e,t){return 0===e.length?[]:bC.inflate(e,t).buffer}return{metadata:JSON.parse(bC.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(bC.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,i,s,r,n){const A=n.getNextId(),o=i.metadata,a=i.positions,l=i.normals,c=i.colors,h=i.indices,u=i.edgeIndices,d=i.matrices,f=i.reusedGeometriesDecodeMatrix,p=i.eachGeometryPrimitiveType,g=i.eachGeometryPositionsPortion,m=i.eachGeometryNormalsPortion,_=i.eachGeometryColorsPortion,b=i.eachGeometryIndicesPortion,B=i.eachGeometryEdgeIndicesPortion,y=i.eachMeshGeometriesPortion,w=i.eachMeshMatricesPortion,v=i.eachMeshMaterial,C=i.eachEntityId,M=i.eachEntityMeshesPortion,E=i.eachTileAABB,F=i.eachTileEntitiesPortion,U=g.length,x=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(U);for(let e=0;e<x;e++){const t=y[e];void 0!==P[t]?P[t]++:P[t]=1}const S=V.vec3(),D=V.AABB3(),k={};for(let i=0;i<T;i++){const r=i===T-1,o=F[i],x=r?I-1:F[i+1]-1,Q=6*i,R=E.subarray(Q,Q+6);V.getAABB3Center(R,S),D[0]=R[0]-S[0],D[1]=R[1]-S[1],D[2]=R[2]-S[2],D[3]=R[3]-S[0],D[4]=R[4]-S[1],D[5]=R[5]-S[2];const O=Ne.createPositionsDecodeMatrix(D),L={};for(let r=o;r<=x;r++){const o=C[r],E=t.globalizeObjectIds?V.globalizeObjectId(s.id,o):o,F=r===I-1,x=M[r],T=F?y.length-1:M[r+1]-1,Q=[],R=e.metaScene.metaObjects[E],H={},N={};if(R){if(t.excludeTypesMap&&R.type&&t.excludeTypesMap[R.type])continue;if(t.includeTypesMap&&R.type&&!t.includeTypesMap[R.type])continue;if(t.includeIdsMap&&R.id&&!t.includeIdsMap[R.id])continue;const e=t.objectDefaults?t.objectDefaults[R.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=x;e<=T;e++){const r=y[e],o=P[r]>1,C=r===U-1,M=wC(v.subarray(6*e,6*e+3)),E=v[6*e+3]/255,F=v[6*e+4]/255,x=v[6*e+5]/255,I=n.getNextId();if(o){const n=w[e],o=d.slice(n,n+16),y=`${A}-geometry.${i}.${r}`;let v=k[y];if(!v){v={batchThisMesh:!t.reuseGeometries};let e=!1;switch(p[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 i=0,s=e.length;i<s;i+=3)t[i+0]=e[i+0]*f[0]+f[12],t[i+1]=e[i+1]*f[5]+f[13],t[i+2]=e[i+2]*f[10]+f[14];v.geometryPositions=null,k[y]=v}}if(v)if(v.batchThisMesh){const e=v.decompressedPositions,t=v.transformedAndRecompressedPositions;for(let i=0,s=e.length;i<s;i+=3)BC[0]=e[i+0],BC[1]=e[i+1],BC[2]=e[i+2],BC[3]=1,V.transformVec4(o,BC,yC),Ne.compressPosition(yC,D,BC),t[i+0]=BC[0],t[i+1]=BC[1],t[i+2]=BC[2];s.createMesh(X.apply(N,{id:I,origin:S,primitive:v.primitiveName,positionsCompressed:t,normalsCompressed:v.geometryNormals,colorsCompressed:v.geometryColors,indices:v.geometryIndices,edgeIndices:v.geometryEdgeIndices,positionsDecodeMatrix:O,color:M,metallic:F,roughness:x,opacity:E})),Q.push(I)}else L[y]||(s.createGeometry({id:y,primitive:v.primitiveName,positionsCompressed:v.geometryPositions,normalsCompressed:v.geometryNormals,colorsCompressed:v.geometryColors,indices:v.geometryIndices,edgeIndices:v.geometryEdgeIndices,positionsDecodeMatrix:f}),L[y]=!0),s.createMesh(X.apply(N,{id:I,geometryId:y,origin:S,matrix:o,color:M,metallic:F,roughness:x,opacity:E})),Q.push(I)}else{let e,t,i,n,A,o,d=!1;switch(p[r]){case 0:e="solid",t=a.subarray(g[r],C?a.length:g[r+1]),i=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]),i=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&&(s.createMesh(X.apply(N,{id:I,origin:S,primitive:e,positionsCompressed:t,normalsCompressed:i,colorsCompressed:n,indices:A,edgeIndices:o,positionsDecodeMatrix:O,color:M,metallic:F,roughness:x,opacity:E})),Q.push(I))}}Q.length>0&&s.createEntity(X.apply(H,{id:E,isObject:!0,meshIds:Q}))}}}(e,t,o,s,r,n)}};let CC=window.pako||jv;CC.inflate||(CC=CC.default);const MC=V.vec4(),EC=V.vec4();const FC=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 UC(e,t){const i=[];if(t.length>1)for(let e=0,s=t.length-1;e<s;e++)i.push(t[e]),i.push(t[e+1]);else if(e.length>1)for(let t=0,s=e.length/3-1;t<s;t++)i.push(t),i.push(t+1);return i}!function(){const e=document.createElement("canvas"),t=e.getContext("2d")}();const xC={version:10,parse:function(e,t,i,s,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++]}}(i),o=function(e){function t(e,t){return 0===e.length?[]:CC.inflate(e,t).buffer}return{metadata:JSON.parse(CC.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(CC.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,i,s,r,n){const A=n.getNextId(),o=i.metadata,a=i.textureData,l=i.eachTextureDataPortion,c=i.eachTextureAttributes,h=i.positions,u=i.normals,d=i.colors,f=i.uvs,p=i.indices,g=i.edgeIndices,m=i.eachTextureSetTextures,_=i.matrices,b=i.reusedGeometriesDecodeMatrix,B=i.eachGeometryPrimitiveType,y=i.eachGeometryPositionsPortion,w=i.eachGeometryNormalsPortion,v=i.eachGeometryColorsPortion,C=i.eachGeometryUVsPortion,M=i.eachGeometryIndicesPortion,E=i.eachGeometryEdgeIndicesPortion,F=i.eachMeshGeometriesPortion,U=i.eachMeshMatricesPortion,x=i.eachMeshTextureSet,I=i.eachMeshMaterialAttributes,T=i.eachEntityId,P=i.eachEntityMeshesPortion,S=i.eachTileAABB,D=i.eachTileEntitiesPortion,k=l.length,Q=m.length/5,R=y.length,O=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,i=l[e],r=t?a.length:l[e+1],n=r-i>0,o=9*e,h=1===c[o+0],u=c[o+1];c[o+2],c[o+3];const d=c[o+4],f=c[o+5],p=c[o+6],g=c[o+7],m=c[o+8];if(n){const t=new Uint8Array(a.subarray(i,r)).buffer,n=`${A}-texture-${e}`;if(h)s.createTexture({id:n,buffers:[t],minFilter:d,magFilter:f,wrapS:p,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),i=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=i,s.createTexture({id:n,image:r,minFilter:d,magFilter:f,wrapS:p,wrapT:g,wrapR:m})}}}for(let e=0;e<Q;e++){const t=5*e,i=`${A}-textureSet-${e}`,r=m[t+0],n=m[t+1],o=m[t+2],a=m[t+3],l=m[t+4];s.createTextureSet({id:i,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(R);for(let e=0;e<O;e++){const t=F[e];void 0!==N[t]?N[t]++:N[t]=1}const G=V.vec3(),j=V.AABB3(),W={};for(let i=0;i<H;i++){const r=i===H-1,o=D[i],a=r?L-1:D[i+1]-1,l=6*i,c=S.subarray(l,l+6);V.getAABB3Center(c,G),j[0]=c[0]-G[0],j[1]=c[1]-G[1],j[2]=c[2]-G[2],j[3]=c[3]-G[0],j[4]=c[4]-G[1],j[5]=c[5]-G[2];const m=Ne.createPositionsDecodeMatrix(j),k={};for(let r=o;r<=a;r++){const o=T[r],a=t.globalizeObjectIds?V.globalizeObjectId(s.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],O={},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&&(O.visible=!1),!1===e.pickable&&(O.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===R-1,l=x[e],c=l>=0?`${A}-textureSet-${l}`:null,T=FC(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,O=n.getNextId();if(o){const n=U[e],o=_.slice(n,n+16),l=`${A}-geometry.${i}.${r}`;let F=W[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=f.subarray(C[r],a?f.length:C[r+1]),F.geometryIndices=p.subarray(M[r],a?p.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=f.subarray(C[r],a?f.length:C[r+1]),F.geometryIndices=p.subarray(M[r],a?p.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=p.subarray(M[r],a?p.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=UC(F.geometryPositions,p.subarray(M[r],a?p.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 i=0,s=e.length;i<s;i+=3)t[i+0]=e[i+0]*b[0]+b[12],t[i+1]=e[i+1]*b[5]+b[13],t[i+2]=e[i+2]*b[10]+b[14];F.geometryPositions=null,W[l]=F}}if(F)if(F.batchThisMesh){const e=F.decompressedPositions,t=F.transformedAndRecompressedPositions;for(let i=0,s=e.length;i<s;i+=3)MC[0]=e[i+0],MC[1]=e[i+1],MC[2]=e[i+2],MC[3]=1,V.transformVec4(o,MC,EC),Ne.compressPosition(EC,j,MC),t[i+0]=MC[0],t[i+1]=MC[1],t[i+2]=MC[2];s.createMesh(X.apply(H,{id:O,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(O)}else k[l]||(s.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),s.createMesh(X.apply(H,{id:O,geometryId:l,textureSetId:c,matrix:o,color:T,metallic:S,roughness:Q,opacity:P,origin:G})),D.push(O)}else{let e,t,i,n,A,o,l,_=!1;switch(B[r]){case 0:e="solid",t=h.subarray(y[r],a?h.length:y[r+1]),i=u.subarray(w[r],a?u.length:w[r+1]),n=f.subarray(C[r],a?f.length:C[r+1]),o=p.subarray(M[r],a?p.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]),i=u.subarray(w[r],a?u.length:w[r+1]),n=f.subarray(C[r],a?f.length:C[r+1]),o=p.subarray(M[r],a?p.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=p.subarray(M[r],a?p.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=UC(t,p.subarray(M[r],a?p.length:M[r+1])),_=t.length>0&&o.length>0;break;default:continue}_&&(s.createMesh(X.apply(H,{id:O,textureSetId:c,origin:G,primitive:e,positionsCompressed:t,normalsCompressed:i,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(O))}}D.length>0&&s.createEntity(X.apply(O,{id:a,isObject:!0,meshIds:D}))}}}(e,t,o,s,r,n)}},IC=V.vec4(),TC=V.vec4();const PC=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 SC(e,t){const i=[];if(t.length>1)for(let e=0,s=t.length-1;e<s;e++)i.push(t[e]),i.push(t[e+1]);else if(e.length>1)for(let t=0,s=e.length/3-1;t<s;t++)i.push(t),i.push(t+1);return i}!function(){const e=document.createElement("canvas"),t=e.getContext("2d")}();const DC={version:11,parseArrayBuffer:function(e,t,i,s,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]}(),i=function(){let i=0;const s=new DataView(e);return function(r){const n=1+2*i++,A=s.getUint32(4*n,!0),o=s.getUint32(4*(n+1),!0),a=r.BYTES_PER_ELEMENT;if(t&&a>1){const t=new Uint8Array(e,A,o),i=a/2,s=t.length/a;for(let e=0;e<s;e++){const s=e*a;for(let e=0;e<i;e++){const i=s+e,r=s-e+a-1,n=t[i];t[i]=t[r],t[r]=n}}}return new r(e,A,o/a)}}(),s=function(){const e=new TextDecoder;return()=>JSON.parse(e.decode(i(Uint8Array)))}();return{metadata:s(),textureData:i(Uint8Array),eachTextureDataPortion:i(Uint32Array),eachTextureAttributes:i(Uint16Array),positions:i(Uint16Array),normals:i(Int8Array),colors:i(Uint8Array),uvs:i(Float32Array),indices:i(Uint32Array),edgeIndices:i(Uint32Array),eachTextureSetTextures:i(Int32Array),matrices:i(Float32Array),reusedGeometriesDecodeMatrix:i(Float32Array),eachGeometryPrimitiveType:i(Uint8Array),eachGeometryPositionsPortion:i(Uint32Array),eachGeometryNormalsPortion:i(Uint32Array),eachGeometryColorsPortion:i(Uint32Array),eachGeometryUVsPortion:i(Uint32Array),eachGeometryIndicesPortion:i(Uint32Array),eachGeometryEdgeIndicesPortion:i(Uint32Array),eachMeshGeometriesPortion:i(Uint32Array),eachMeshMatricesPortion:i(Uint32Array),eachMeshTextureSet:i(Int32Array),eachMeshMaterialAttributes:i(Uint8Array),eachEntityId:s(),eachEntityMeshesPortion:i(Uint32Array),eachTileAABB:i(Float64Array),eachTileEntitiesPortion:i(Uint32Array)}}(i);!function(e,t,i,s,r,n){const A=n.getNextId(),o=i.metadata,a=i.textureData,l=i.eachTextureDataPortion,c=i.eachTextureAttributes,h=i.positions,u=i.normals,d=i.colors,f=i.uvs,p=i.indices,g=i.edgeIndices,m=i.eachTextureSetTextures,_=i.matrices,b=i.reusedGeometriesDecodeMatrix,B=i.eachGeometryPrimitiveType,y=i.eachGeometryPositionsPortion,w=i.eachGeometryNormalsPortion,v=i.eachGeometryColorsPortion,C=i.eachGeometryUVsPortion,M=i.eachGeometryIndicesPortion,E=i.eachGeometryEdgeIndicesPortion,F=i.eachMeshGeometriesPortion,U=i.eachMeshMatricesPortion,x=i.eachMeshTextureSet,I=i.eachMeshMaterialAttributes,T=i.eachEntityId,P=i.eachEntityMeshesPortion,S=i.eachTileAABB,D=i.eachTileEntitiesPortion,k=l.length,Q=m.length/5,R=y.length,O=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,i=l[e],r=t?a.length:l[e+1],n=r-i>0,o=9*e,h=1===c[o+0],u=c[o+1];c[o+2],c[o+3];const d=c[o+4],f=c[o+5],p=c[o+6],g=c[o+7],m=c[o+8];if(n){const t=new Uint8Array(a.subarray(i,r)).buffer,n=`${A}-texture-${e}`;if(h)s.createTexture({id:n,buffers:[t],minFilter:d,magFilter:f,wrapS:p,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),i=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=i,s.createTexture({id:n,image:r,minFilter:d,magFilter:f,wrapS:p,wrapT:g,wrapR:m})}}}for(let e=0;e<Q;e++){const t=5*e,i=`${A}-textureSet-${e}`,r=m[t+0],n=m[t+1],o=m[t+2],a=m[t+3],l=m[t+4];s.createTextureSet({id:i,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(R);for(let e=0;e<O;e++){const t=F[e];void 0!==N[t]?N[t]++:N[t]=1}const G=V.vec3(),j=V.AABB3(),W={};for(let i=0;i<H;i++){const r=i===H-1,o=D[i],a=r?L-1:D[i+1]-1,l=6*i,c=S.subarray(l,l+6);V.getAABB3Center(c,G),j[0]=c[0]-G[0],j[1]=c[1]-G[1],j[2]=c[2]-G[2],j[3]=c[3]-G[0],j[4]=c[4]-G[1],j[5]=c[5]-G[2];const m=Ne.createPositionsDecodeMatrix(j),k={};for(let r=o;r<=a;r++){const o=T[r],a=t.globalizeObjectIds?V.globalizeObjectId(s.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],O={},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&&(O.visible=!1),!1===e.pickable&&(O.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===R-1,l=x[e],c=l>=0?`${A}-textureSet-${l}`:null,T=PC(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,O=n.getNextId();if(o){const n=U[e],o=_.slice(n,n+16),l=`${A}-geometry.${i}.${r}`;let F=W[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=f.subarray(C[r],a?f.length:C[r+1]),F.geometryIndices=p.subarray(M[r],a?p.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=f.subarray(C[r],a?f.length:C[r+1]),F.geometryIndices=p.subarray(M[r],a?p.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=p.subarray(M[r],a?p.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=SC(F.geometryPositions,p.subarray(M[r],a?p.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 i=0,s=e.length;i<s;i+=3)t[i+0]=e[i+0]*b[0]+b[12],t[i+1]=e[i+1]*b[5]+b[13],t[i+2]=e[i+2]*b[10]+b[14];F.geometryPositions=null,W[l]=F}}if(F)if(F.batchThisMesh){const e=F.decompressedPositions,t=F.transformedAndRecompressedPositions;for(let i=0,s=e.length;i<s;i+=3)IC[0]=e[i+0],IC[1]=e[i+1],IC[2]=e[i+2],IC[3]=1,V.transformVec4(o,IC,TC),Ne.compressPosition(TC,j,IC),t[i+0]=IC[0],t[i+1]=IC[1],t[i+2]=IC[2];s.createMesh(X.apply(H,{id:O,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(O)}else k[l]||(s.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),s.createMesh(X.apply(H,{id:O,geometryId:l,textureSetId:c,matrix:o,color:T,metallic:S,roughness:Q,opacity:P,origin:G})),D.push(O)}else{let e,t,i,n,A,o,l,_=!1;switch(B[r]){case 0:e="solid",t=h.subarray(y[r],a?h.length:y[r+1]),i=u.subarray(w[r],a?u.length:w[r+1]),n=f.subarray(C[r],a?f.length:C[r+1]),o=p.subarray(M[r],a?p.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]),i=u.subarray(w[r],a?u.length:w[r+1]),n=f.subarray(C[r],a?f.length:C[r+1]),o=p.subarray(M[r],a?p.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=p.subarray(M[r],a?p.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=SC(t,p.subarray(M[r],a?p.length:M[r+1])),_=t.length>0&&o.length>0;break;default:continue}_&&(s.createMesh(X.apply(H,{id:O,textureSetId:c,origin:G,primitive:e,positionsCompressed:t,normalsCompressed:i,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(O))}}D.length>0&&s.createEntity(X.apply(O,{id:a,isObject:!0,meshIds:D}))}}}(e,t,A,s,r,n)}};let kC=window.pako||jv;kC.inflate||(kC=kC.default);const QC=V.vec4(),RC=V.vec4();const OC=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 VC(e,t,i,s,r,n){const A=n.getNextId(),o=i.metadata,a=i.textureData,l=i.eachTextureDataPortion,c=i.eachTextureAttributes,h=i.positions,u=i.normals,d=i.colors,f=i.uvs,p=i.indices,g=i.edgeIndices,m=i.eachTextureSetTextures,_=i.matrices,b=i.reusedGeometriesDecodeMatrix,B=i.eachGeometryPrimitiveType,y=i.eachGeometryAxisLabel,w=i.eachGeometryPositionsPortion,v=i.eachGeometryNormalsPortion,C=i.eachGeometryColorsPortion,M=i.eachGeometryUVsPortion,E=i.eachGeometryIndicesPortion,F=i.eachGeometryEdgeIndicesPortion,U=i.eachMeshGeometriesPortion,x=i.eachMeshMatricesPortion,I=i.eachMeshTextureSet,T=i.eachMeshMaterialAttributes,P=i.eachEntityId,S=i.eachEntityMeshesPortion,D=i.eachTileAABB,k=i.eachTileEntitiesPortion,Q=l.length,R=m.length/5,O=w.length,L=U.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,i=l[e],r=t?a.length:l[e+1],n=r-i>0,o=9*e,h=1===c[o+0],u=c[o+1];c[o+2],c[o+3];const d=c[o+4],f=c[o+5],p=c[o+6],g=c[o+7],m=c[o+8];if(n){const t=new Uint8Array(a.subarray(i,r)).buffer,n=`${A}-texture-${e}`;if(h)s.createTexture({id:n,buffers:[t],minFilter:d,magFilter:f,wrapS:p,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),i=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=i,s.createTexture({id:n,image:r,minFilter:d,magFilter:f,wrapS:p,wrapT:g,wrapR:m})}}}for(let e=0;e<R;e++){const t=5*e,i=`${A}-textureSet-${e}`,r=m[t+0],n=m[t+1],o=m[t+2],a=m[t+3],l=m[t+4];s.createTextureSet({id:i,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(O);for(let e=0;e<L;e++){const t=U[e];void 0!==G[t]?G[t]++:G[t]=1}const j=V.vec3(),W=V.AABB3(),z={};for(let i=0;i<N;i++){const r=i===N-1,o=k[i],a=r?H-1:k[i+1]-1,l=6*i,c=D.subarray(l,l+6);V.getAABB3Center(c,j),W[0]=c[0]-j[0],W[1]=c[1]-j[1],W[2]=c[2]-j[2],W[3]=c[3]-j[0],W[4]=c[4]-j[1],W[5]=c[5]-j[2];const m=Ne.createPositionsDecodeMatrix(W),Q={};for(let r=o;r<=a;r++){const o=P[r],a=t.globalizeObjectIds?V.globalizeObjectId(s.id,o):o,l=r===H-1,c=S[r],D=l?U.length-1:S[r+1]-1,k=[],R=e.metaScene.metaObjects[a],L={},N={};if(R){if(t.excludeTypesMap&&R.type&&t.excludeTypesMap[R.type])continue;if(t.includeTypesMap&&R.type&&!t.includeTypesMap[R.type])continue;if(t.includeIdsMap&&R.id&&!t.includeIdsMap[R.id])continue;const e=t.objectDefaults?t.objectDefaults[R.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=U[e],o=G[r]>1,a=r===O-1,l=I[e],c=l>=0?`${A}-textureSet-${l}`:null,P=OC(T.subarray(6*e,6*e+3)),S=T[6*e+3]/255,D=T[6*e+4]/255,R=T[6*e+5]/255,L=n.getNextId();if(o){const n=x[e],o=_.slice(n,n+16),l=`${A}-geometry.${i}.${r}`;let U=z[l];if(!U){U={batchThisMesh:!t.reuseGeometries};const e=B[r],i=y[r];let s,n=!1;switch(e){case 0:U.primitiveName="solid",U.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),U.geometryNormals=u.subarray(v[r],a?u.length:v[r+1]),U.geometryUVs=f.subarray(M[r],a?f.length:M[r+1]),U.geometryIndices=p.subarray(E[r],a?p.length:E[r+1]),U.geometryEdgeIndices=g.subarray(F[r],a?g.length:F[r+1]),n=U.geometryPositions.length>0&&U.geometryIndices.length>0;break;case 1:U.primitiveName="surface",U.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),U.geometryNormals=u.subarray(v[r],a?u.length:v[r+1]),U.geometryUVs=f.subarray(M[r],a?f.length:M[r+1]),U.geometryIndices=p.subarray(E[r],a?p.length:E[r+1]),U.geometryEdgeIndices=g.subarray(F[r],a?g.length:F[r+1]),n=U.geometryPositions.length>0&&U.geometryIndices.length>0;break;case 2:U.primitiveName="points",U.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),U.geometryColors=d.subarray(C[r],a?d.length:C[r+1]),n=U.geometryPositions.length>0;break;case 3:U.primitiveName="lines",U.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),U.geometryIndices=p.subarray(E[r],a?p.length:E[r+1]),n=U.geometryPositions.length>0&&U.geometryIndices.length>0;break;case 4:U.primitiveName="lines",U.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),U.geometryIndices=LC(U.geometryPositions,p.subarray(E[r],a?p.length:E[r+1])),n=U.geometryPositions.length>0&&U.geometryIndices.length>0;break;case 7:U.primitiveName="lines",U.geometryPositions=h.subarray(w[r],a?h.length:w[r+1]),U.decompressedPositions=Ne.decompressPositions(U.geometryPositions,b),s=ot({origin:U.decompressedPositions,text:i,size:2}),U.decompressedPositions=s.positions,U.geometryIndices=s.indices,U.geometryPositions=null,n=U.decompressedPositions.length>0&&U.geometryIndices.length>0;break;default:continue}if(n||(U=null),U&&(U.geometryPositions&&U.geometryPositions.length,U.batchThisMesh)){if(7===e)U.transformedAndRecompressedPositions=new Uint16Array(U.decompressedPositions.length);else{U.decompressedPositions=new Float32Array(U.geometryPositions.length),U.transformedAndRecompressedPositions=new Uint16Array(U.geometryPositions.length);const e=U.geometryPositions,t=U.decompressedPositions;for(let i=0,s=e.length;i<s;i+=3)t[i+0]=e[i+0]*b[0]+b[12],t[i+1]=e[i+1]*b[5]+b[13],t[i+2]=e[i+2]*b[10]+b[14];U.geometryPositions=null}z[l]=U}}if(U)if(U.batchThisMesh){const e=U.decompressedPositions,t=U.transformedAndRecompressedPositions;for(let i=0,s=e.length;i<s;i+=3)QC[0]=e[i+0],QC[1]=e[i+1],QC[2]=e[i+2],QC[3]=1,V.transformVec4(o,QC,RC),Ne.compressPosition(RC,W,QC),t[i+0]=QC[0],t[i+1]=QC[1],t[i+2]=QC[2];s.createMesh(X.apply(N,{id:L,textureSetId:c,origin:j,primitive:U.primitiveName,positionsCompressed:t,normalsCompressed:U.geometryNormals,uv:U.geometryUVs,colorsCompressed:U.geometryColors,indices:U.geometryIndices,edgeIndices:U.geometryEdgeIndices,positionsDecodeMatrix:m,color:P,metallic:D,roughness:R,opacity:S})),k.push(L)}else{if(!Q[l]){let e={id:l,primitive:U.primitiveName,normalsCompressed:U.geometryNormals,uv:U.geometryUVs,colorsCompressed:U.geometryColors,indices:U.geometryIndices,edgeIndices:U.geometryEdgeIndices};e=U.geometryPositions?{...e,positionsCompressed:U.geometryPositions,positionsDecodeMatrix:b}:{...e,positions:U.decompressedPositions},s.createGeometry(e),Q[l]=!0}s.createMesh(X.apply(N,{id:L,geometryId:l,textureSetId:c,matrix:o,color:P,metallic:D,roughness:R,opacity:S,origin:j})),k.push(L)}}else{const e=B[r],t=y[r];let i,n,A,o,l,_,b,U,x=!1;switch(e){case 0:i="solid",n=h.subarray(w[r],a?h.length:w[r+1]),A=u.subarray(v[r],a?u.length:v[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),_=p.subarray(E[r],a?p.length:E[r+1]),b=g.subarray(F[r],a?g.length:F[r+1]),x=n.length>0&&_.length>0;break;case 1:i="surface",n=h.subarray(w[r],a?h.length:w[r+1]),A=u.subarray(v[r],a?u.length:v[r+1]),o=f.subarray(M[r],a?f.length:M[r+1]),_=p.subarray(E[r],a?p.length:E[r+1]),b=g.subarray(F[r],a?g.length:F[r+1]),x=n.length>0&&_.length>0;break;case 2:i="points",n=h.subarray(w[r],a?h.length:w[r+1]),l=d.subarray(C[r],a?d.length:C[r+1]),x=n.length>0;break;case 3:i="lines",n=h.subarray(w[r],a?h.length:w[r+1]),_=p.subarray(E[r],a?p.length:E[r+1]),x=n.length>0&&_.length>0;break;case 4:i="lines",n=h.subarray(w[r],a?h.length:w[r+1]),_=LC(n,p.subarray(E[r],a?p.length:E[r+1])),x=n.length>0&&_.length>0;break;case 7:i="lines",n=h.subarray(w[r],a?h.length:w[r+1]),n=Ne.decompressPositions(n,m),U=ot({origin:n,text:t,size:2}),n=U.positions,_=U.indices,x=n.length>0&&_.length>0;break;default:continue}if(x){let t=X.apply(N,{id:L,textureSetId:c,origin:j,primitive:i,normalsCompressed:A,uv:o&&o.length>0?o:null,colorsCompressed:l,indices:_,edgeIndices:b,color:P,metallic:D,roughness:R,opacity:S});t=7!==e?{...t,positionsCompressed:n,positionsDecodeMatrix:m}:{...t,positions:n},s.createMesh(t),k.push(L)}}}k.length>0&&s.createEntity(X.apply(L,{id:a,isObject:!0,meshIds:k}))}}}function LC(e,t){const i=[];if(t.length>1)for(let e=0,s=t.length-1;e<s;e++)i.push(t[e]),i.push(t[e+1]);else if(e.length>1)for(let t=0,s=e.length/3-1;t<s;t++)i.push(t),i.push(t+1);return i}!function(){const e=document.createElement("canvas"),t=e.getContext("2d")}();const HC={version:12,parseArrayBuffer:function(e,t,i,s,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]}(),i=function(){let i=0;const s=new DataView(e);return function(r){const n=1+2*i++,A=s.getUint32(4*n,!0),o=s.getUint32(4*(n+1),!0),a=r.BYTES_PER_ELEMENT;if(t&&a>1){const t=new Uint8Array(e,A,o),i=a/2,s=t.length/a;for(let e=0;e<s;e++){const s=e*a;for(let e=0;e<i;e++){const i=s+e,r=s-e+a-1,n=t[i];t[i]=t[r],t[r]=n}}}return new r(e,A,o/a)}}(),s=function(){const e=new TextDecoder;return()=>JSON.parse(e.decode(i(Uint8Array)))}();return{metadata:s(),textureData:i(Uint8Array),eachTextureDataPortion:i(Uint32Array),eachTextureAttributes:i(Uint16Array),positions:i(Uint16Array),normals:i(Int8Array),colors:i(Uint8Array),uvs:i(Float32Array),indices:i(Uint32Array),edgeIndices:i(Uint32Array),eachTextureSetTextures:i(Int32Array),matrices:i(Float32Array),reusedGeometriesDecodeMatrix:i(Float32Array),eachGeometryPrimitiveType:i(Uint8Array),eachGeometryAxisLabel:s(),eachGeometryPositionsPortion:i(Uint32Array),eachGeometryNormalsPortion:i(Uint32Array),eachGeometryColorsPortion:i(Uint32Array),eachGeometryUVsPortion:i(Uint32Array),eachGeometryIndicesPortion:i(Uint32Array),eachGeometryEdgeIndicesPortion:i(Uint32Array),eachMeshGeometriesPortion:i(Uint32Array),eachMeshMatricesPortion:i(Uint32Array),eachMeshTextureSet:i(Int32Array),eachMeshMaterialAttributes:i(Uint8Array),eachEntityId:s(),eachEntityMeshesPortion:i(Uint32Array),eachTileAABB:i(Float64Array),eachTileEntitiesPortion:i(Uint32Array)}}(i);VC(e,t,A,s,r,n)},parse:function(e,t,i,s,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++]}}(i),o=function(e){function t(e,t){return 0===e.length?[]:kC.inflate(e,t).buffer}return{metadata:JSON.parse(kC.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(kC.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(kC.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(A);VC(e,t,o,s,r,n)}},NC={};NC[Xv.version]=Xv,NC[Jv.version]=Jv,NC[qv.version]=qv,NC[iC.version]=iC,NC[nC.version]=nC,NC[aC.version]=aC,NC[uC.version]=uC,NC[_C.version]=_C,NC[vC.version]=vC,NC[xC.version]=xC,NC[DC.version]=DC,NC[HC.version]=HC;class GC extends qA{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(NC)}get textureTranscoder(){return this._textureTranscoder}set textureTranscoder(e){this._textureTranscoder=e}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new Gv}get objectDefaults(){return this._objectDefaults}set objectDefaults(e){this._objectDefaults=e||zw}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={},i=e.includeTypes||this._includeTypes,s=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,i){t.includeTypesMap={};for(let e=0,s=i.length;e<s;e++)t.includeTypesMap[i[e]]=!0}if(s){t.excludeTypesMap={};for(let e=0,i=s.length;e<i;e++)t.excludeTypesMap[s[e]]=!0}if(r){t.includeIdsMap={};for(let e=0,i=r.length;e<i;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 mA(this.viewer.scene,X.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 Na({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:i,excludeTypes:s,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:i,excludeTypes:s,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:i,excludeTypes:s,globalizeObjectIds:t.globalizeObjectIds}),l++,this.scheduleTask(c,200)}),o)};c()},o=(e,i,s)=>{let n=0;const o=()=>{A.destroyed||n>=e.length?i():this._dataSource.getXKT(`${r}${e[n]}`,(e=>{this._parseModel(e,t,A,null,u),A.preFinalize(),n++,this.scheduleTask(o,200)}),s)};o()},h=(e,i,s)=>{let n=0;const o=()=>{A.destroyed||n>=e.length?i():this._dataSource.getXKT(`${r}${e[n]}`,(e=>{this._parseModel(e,t,A,a,u),A.preFinalize(),n++,this.scheduleTask(o,200)}),s)};o()};if(e.manifest){const t=e.manifest,i=t.xktFiles;if(!i||0===i.length)return void c("load(): Failed to load model manifest - manifest not valid");const s=t.metaModelFiles;s?n(s,(()=>{o(i,l,c)}),c):h(i,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 i=e.metaModelFiles;i?n(i,(()=>{o(t,l,c)}),c):h(t,l,c)}),c)}return A}_loadModel(e,t,i,s,r,n,A){this._dataSource.getXKT(e,(e=>{this._parseModel(e,t,i,s,r),i.preFinalize(),n()}),A)}async _parseModel(e,t,i,s,r){if(i.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=NC[a];if(!c)return void this.error("Unsupported .XKT file version: "+a+" - this XKTLoaderPlugin supports versions "+Object.keys(NC));if(!l)return void c.parseArrayBuffer(this.viewer,t,e,i,s,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,i,s,r)}}var jC={};!function(e){var t,i="File format is not recognized.",s="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 i,s;return i=new ArrayBuffer(e),s=new Uint8Array(i),t&&s.set(t,0),{buffer:i,array:s,view:new DataView(i)}}function c(){}function h(e){var t,i=this;i.size=0,i.init=function(s,r){var n=new Blob([e],{type:A});(t=new d(n)).init((function(){i.size=t.size,s()}),r)},i.readUint8Array=function(e,i,s,r){t.readUint8Array(e,i,s,r)}}function u(t){var i,s=this;s.size=0,s.init=function(e){for(var r=t.length;"="==t.charAt(r-1);)r--;i=t.indexOf(",")+1,s.size=Math.floor(.75*(r-i)),e()},s.readUint8Array=function(s,r,n){var A,o=l(r),a=4*Math.floor(s/3),c=4*Math.ceil((s+r)/3),h=e.atob(t.substring(a+i,c+i)),u=s-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(i){t.size=e.size,i()},t.readUint8Array=function(t,i,s,r){var n=new FileReader;n.onload=function(e){s(new Uint8Array(e.target.result))},n.onerror=r;try{n.readAsArrayBuffer(function(e,t,i){if(t<0||i<0||t+i>e.size)throw new RangeError("offset:"+t+", length:"+i+", size:"+e.size);return e.slice?e.slice(t,t+i):e.webkitSlice?e.webkitSlice(t,t+i):e.mozSlice?e.mozSlice(t,t+i):e.msSlice?e.msSlice(t,t+i):void 0}(e,t,i))}catch(e){r(e)}}}function f(){}function p(e){var i,s=this;s.init=function(e){i=new Blob([],{type:A}),e()},s.writeUint8Array=function(e,s){i=new Blob([i,t?e:e.buffer],{type:A}),s()},s.getData=function(t,s){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=s,r.readAsText(i,e)}}function g(t){var i=this,s="",r="";i.init=function(e){s+="data:"+(t||"")+";base64,",e()},i.writeUint8Array=function(t,i){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?s+=e.btoa(o):r=o,i()},i.getData=function(t){t(s+e.btoa(r))}}function m(e){var i,s=this;s.init=function(t){i=new Blob([],{type:e}),t()},s.writeUint8Array=function(s,r){i=new Blob([i,t?s:s.buffer],{type:e}),r()},s.getData=function(e){e(i)}}function _(e,t,i,s,r,A,o,a,l,c){var h,u,d,f=0,p=t.sn;function g(){e.removeEventListener("message",m,!1),a(u,d)}function m(t){var i=t.data,r=i.data,n=i.error;if(n)return n.toString=function(){return"Error: "+this.message},void l(n);if(i.sn===p)switch("number"==typeof i.codecTime&&(e.codecTime+=i.codecTime),"number"==typeof i.crcTime&&(e.crcTime+=i.crcTime),i.type){case"append":r?(u+=r.length,s.writeUint8Array(r,(function(){_()}),c)):_();break;case"flush":d=i.crc,r?(u+=r.length,s.writeUint8Array(r,(function(){g()}),c)):g();break;case"progress":o&&o(h+i.loaded,A);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",i)}}function _(){(h=f*n)<=A?i.readUint8Array(r+h,Math.min(n,A-h),(function(i){o&&o(h,A);var s=0===h?t:{sn:p};s.type="append",s.data=i;try{e.postMessage(s,[i.buffer])}catch(t){e.postMessage(s)}f++}),l):e.postMessage({sn:p,type:"flush"})}u=0,e.addEventListener("message",m,!1),_()}function b(e,t,i,s,r,A,a,l,c,h){var u,d=0,f=0,p="input"===A,g="output"===A,m=new o;!function A(){var o;if((u=d*n)<r)t.readUint8Array(s+u,Math.min(n,r-u),(function(t){var s;try{s=e.append(t,(function(e){a&&a(u+e,r)}))}catch(e){return void c(e)}s?(f+=s.length,i.writeUint8Array(s,(function(){d++,setTimeout(A,1)}),h),g&&m.append(s)):(d++,setTimeout(A,1)),p&&m.append(t),a&&a(u,r)}),c);else{try{o=e.flush()}catch(e){return void c(e)}o?(g&&m.append(o),f+=o.length,i.writeUint8Array(o,(function(){l(f,m.get())}),h)):l(f,m.get())}}()}function B(t,i,s,r,n,A,o,l,c,h,u){var d="input";e.zip.useWebWorkers&&o?_(t,{sn:i,codecClass:"NOOP",crcType:d},s,r,n,A,c,l,h,u):b(new a,s,r,n,A,d,c,l,h,u)}function y(e){var t,i,s="",r=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "];for(t=0;t<e.length;t++)s+=(i=255&e.charCodeAt(t))>127?r[i-128]:String.fromCharCode(i);return s}function w(e){return decodeURIComponent(escape(e))}function v(e){var t,i="";for(t=0;t<e.length;t++)i+=String.fromCharCode(e[t]);return i}function C(e,t,i,s,r){e.version=t.view.getUint16(i,!0),e.bitFlag=t.view.getUint16(i+2,!0),e.compressionMethod=t.view.getUint16(i+4,!0),e.lastModDateRaw=t.view.getUint32(i+6,!0),e.lastModDate=function(e){var t=(4294901760&e)>>16,i=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&i)>>11,(2016&i)>>5,2*(31&i),0)}catch(e){}}(e.lastModDateRaw),1!=(1&e.bitFlag)?((s||8!=(8&e.bitFlag))&&(e.crc32=t.view.getUint32(i+10,!0),e.compressedSize=t.view.getUint32(i+14,!0),e.uncompressedSize=t.view.getUint32(i+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(i+22,!0),e.extraFieldLength=t.view.getUint16(i+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(s,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."):s.getData((function(e){n(e)}))}function d(e){A(e||r)}function f(e){A(e||"Error while writing file data.")}t.readUint8Array(h.offset,30,(function(r){var n,p=l(r.length,r);1347093252==p.view.getUint32(0)?(C(h,p,4,!1,A),n=h.offset+30+h.filenameLength+h.extraFieldLength,s.init((function(){0===h.compressionMethod?B(h._worker,o++,t,s,n,h.compressedSize,c,u,a,d,f):function(t,i,s,r,n,A,o,a,l,c,h){var u=o?"output":"none";e.zip.useWebWorkers?_(t,{sn:i,codecClass:"Inflater",crcType:u},s,r,n,A,l,a,c,h):b(new e.zip.Inflater,s,r,n,A,u,l,a,c,h)}(h._worker,o++,t,s,n,h.compressedSize,c,u,a,d,f)}),f)):A(i)}),d)};var c={getEntries:function(e){var r=this._worker;!function(e){t.size<22?A(i):r(22,(function(){r(Math.min(65558,t.size),(function(){A(i)}))}));function r(i,r){t.readUint8Array(t.size-i,i,(function(t){for(var i=t.length-22;i>=0;i--)if(80===t[i]&&75===t[i+1]&&5===t[i+2]&&6===t[i+3])return void e(new DataView(t.buffer,i,22));r()}),(function(){A(s)}))}}((function(n){var o,c;o=n.getUint32(16,!0),c=n.getUint16(8,!0),o<0||o>=t.size?A(i):t.readUint8Array(o,t.size-o,(function(t){var s,n,o,h,u=0,d=[],f=l(t.length,t);for(s=0;s<c;s++){if((n=new a)._worker=r,1347092738!=f.view.getUint32(u))return void A(i);C(n,f,u+6,!0,A),n.commentLength=f.view.getUint16(u+32,!0),n.directory=16==(16&f.view.getUint8(u+38)),n.offset=f.view.getUint32(u+42,!0),o=v(f.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(f.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(s)}))}))},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,i=[];for(t=0;t<e.length;t++)i.push(e.charCodeAt(t));return i}function U(t,i,s,n){var A={},o=[],a=0,c=0;function h(e){s(e||"Error while writing zip file.")}function u(e){s(e||r)}var d={add:function(i,r,d,f,p){var g,m,y,w=this._worker;function v(e,i){var s=l(16);a+=e||0,s.view.setUint32(0,1347094280),void 0!==i&&(g.view.setUint32(10,i,!0),s.view.setUint32(4,i,!0)),r&&(s.view.setUint32(8,e,!0),g.view.setUint32(14,e,!0),s.view.setUint32(12,r.size,!0),g.view.setUint32(18,r.size,!0)),t.writeUint8Array(s.array,(function(){a+=16,d()}),h)}function C(){p=p||{},i=i.trim(),p.directory&&"/"!=i.charAt(i.length-1)&&(i+="/"),A.hasOwnProperty(i)?s("File already exists."):(m=F(E(i)),o.push(i),function(e){var s;y=p.lastModDate||new Date,g=l(26),A[i]={headerArray:g.array,directory:p.directory,filename:m,offset:a,comment:F(E(p.comment||""))},g.view.setUint32(0,335546376),p.version&&g.view.setUint8(0,p.version),n||0===p.level||p.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),(s=l(30+m.length)).view.setUint32(0,1347093252),s.array.set(g.array,4),s.array.set(m,30),a+=s.array.length,t.writeUint8Array(s.array,e,h)}((function(){r?n||0===p.level?B(w,c++,r,t,0,r.size,!0,v,f,u,h):function(t,i,s,r,n,A,o,a,l){var c="input";e.zip.useWebWorkers?_(t,{sn:i,options:{level:n},codecClass:"Deflater",crcType:c},s,r,0,s.size,o,A,a,l):b(new e.zip.Deflater,s,r,0,s.size,c,o,A,a,l)}(w,c++,r,t,p.level,v,f,u,h):v()})))}r?r.init(C,u):C()},close:function(e){this._worker&&(this._worker.terminate(),this._worker=null);var i,s,r,n=0,c=0;for(s=0;s<o.length;s++)n+=46+(r=A[o[s]]).filename.length+r.comment.length;for(i=l(n+22),s=0;s<o.length;s++)r=A[o[s]],i.view.setUint32(c,1347092738),i.view.setUint16(c+4,5120),i.array.set(r.headerArray,c+6),i.view.setUint16(c+32,r.comment.length,!0),r.directory&&i.view.setUint8(c+38,16),i.view.setUint32(c+42,r.offset,!0),i.array.set(r.filename,c+46),i.array.set(r.comment,c+46+r.filename.length),c+=46+r.filename.length+r.comment.length;i.view.setUint32(c,1347093766),i.view.setUint16(c+8,o.length,!0),i.view.setUint16(c+10,o.length,!0),i.view.setUint32(c+12,n,!0),i.view.setUint32(c+16,a,!0),t.writeUint8Array(i.array,(function(){t.getData(e)}),h)},_worker:null};e.zip.useWebWorkers?I("deflater",(function(e){d._worker=e,i(d)}),(function(e){s(e)})):i(d)}o.prototype.append=function(e){for(var t=0|this.crc,i=this.table,s=0,r=0|e.length;s<r;s++)t=t>>>8^i[255&(t^e[s])];this.crc=t},o.prototype.get=function(){return~this.crc},o.prototype.table=function(){var e,t,i,s=[];for(e=0;e<256;e++){for(i=e,t=0;t<8;t++)1&i?i=i>>>1^3988292384:i>>>=1;s[e]=i}return s}(),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,f.prototype.getData=function(e){e(this.data)},p.prototype=new f,p.prototype.constructor=p,g.prototype=new f,g.prototype.constructor=g,m.prototype=new f,m.prototype.constructor=m;var x={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function I(t,i,s){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 s(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=x[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 s(r.error);"importScripts"===r.type&&(n.removeEventListener("message",e),n.removeEventListener("error",A),i(n))})),n.addEventListener("error",A)}else s(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function A(e){n.terminate(),s(e)}}function T(e){console.error(e)}e.zip={Reader:c,Writer:f,BlobReader:d,Data64URIReader:u,TextReader:h,BlobWriter:m,Data64URIWriter:g,TextWriter:p,createReader:function(e,t,i){i=i||T,e.init((function(){M(e,t,i)}),i)},createWriter:function(e,t,i,s){i=i||T,s=!!s,e.init((function(){U(e,t,i,s)}),i)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(jC);const WC=jC.zip;!function(e){var t,i,s=e.Reader,r=e.Writer;try{i=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function n(e){var t=this;function i(i,s){var r;t.data?i():((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),i()}),!1),r.addEventListener("error",s,!1),r.open("GET",e),r.responseType="arraybuffer",r.send())}t.size=0,t.init=function(s,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?s():i(s,r)}),!1),n.addEventListener("error",r,!1),n.open("HEAD",e),n.send()}else i(s,r)},t.readUint8Array=function(e,s,r,n){i((function(){r(new Uint8Array(t.data.subarray(e,e+s)))}),n)}}function A(e){var t=this;t.size=0,t.init=function(i,s){var r=new XMLHttpRequest;r.addEventListener("load",(function(){t.size=Number(r.getResponseHeader("Content-Length")),"bytes"==r.getResponseHeader("Accept-Ranges")?i():s("HTTP Range not supported.")}),!1),r.addEventListener("error",s,!1),r.open("HEAD",e),r.send()},t.readUint8Array=function(t,i,s,r){!function(t,i,s,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="arraybuffer",n.setRequestHeader("Range","bytes="+t+"-"+(t+i-1)),n.addEventListener("load",(function(){s(n.response)}),!1),n.addEventListener("error",r,!1),n.send()}(t,i,(function(e){s(new Uint8Array(e))}),r)}}function o(e){var t=this;t.size=0,t.init=function(i,s){t.size=e.byteLength,i()},t.readUint8Array=function(t,i,s,r){s(new Uint8Array(e.slice(t,t+i)))}}function a(){var e,t=this;t.init=function(t,i){e=new Uint8Array,t()},t.writeUint8Array=function(t,i,s){var r=new Uint8Array(e.length+t.length);r.set(e),r.set(t,e.length),e=r,i()},t.getData=function(t){t(e.buffer)}}function l(e,t){var s,r=this;r.init=function(t,i){e.createWriter((function(e){s=e,t()}),i)},r.writeUint8Array=function(e,r,n){var A=new Blob([i?e:e.buffer],{type:t});s.onwrite=function(){s.onwrite=null,r()},s.onerror=n,s.write(A)},r.getData=function(t){e.file(t)}}n.prototype=new s,n.prototype.constructor=n,A.prototype=new s,A.prototype.constructor=A,o.prototype=new s,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(i,s,r){return function(i,s,r,n){if(i.directory)return n?new t(i.fs,s,r,i):new e.fs.ZipFileEntry(i.fs,s,r,i);throw"Parent entry is not a directory."}(this,i,{data:s,Reader:r?A:n})},t.prototype.importHttpContent=function(e,t,i,s){this.importZip(t?new A(e):new n(e),i,s)},e.fs.FS.prototype.importHttpContent=function(e,i,s,r){this.entries=[],this.root=new t(this),this.root.importHttpContent(e,i,s,r)})}(WC);const zC=["4.2"];class XC{constructor(e,t={}){this.supportedSchemas=zC,this._xrayOpacity=.7,this._src=null,this._options=t,this.viewpoint=null,t.workerScriptsPath?(WC.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,i,s,r,n){switch(s.materialType){case"MetallicMaterial":t._defaultMaterial=new Ss(t,{baseColor:[1,1,1],metallic:.6,roughness:.6});break;case"SpecularMaterial":t._defaultMaterial=new Qs(t,{diffuse:[1,1,1],specular:V.vec3([1,1,1]),glossiness:.5});break;default:t._defaultMaterial=new fs(t,{reflectivity:.75,shiness:100,diffuse:[1,1,1]})}t._wireframeMaterial=new Is(t,{color:[0,0,0],lineWidth:2});var A=t.scene.canvas.spinner;A.processes++,KC(e,t,i,s,(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 KC=function(e,t,i,s,r,n){!function(e,t,i){var s=new iM;s.load(e,(function(){t(s)}),(function(e){i("Error loading ZIP archive: "+e)}))}(i,(function(i){ZC(e,i,s,t,r,n)}),n)},ZC=function(){return function(t,i,s,r,n){var A={plugin:t,zip:i,edgeThreshold:30,materialType:s.materialType,scene:r.scene,modelNode:r,info:{references:{}},materials:{}};s.createMetaModel&&(A.metaModelData={modelId:r.id,metaObjects:[{name:r.id,type:"Default",id:r.id}]}),r.scene.loading++,function(t,i){t.zip.getFile("Manifest.xml",(function(s,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,i)}}))}(A,(function(){A.metaModelData&&t.viewer.metaScene.createMetaModel(r.id,A.metaModelData),r.scene.loading--,n()}))};function e(e,i,s){for(var r=i.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(i,r){t(e,r,s)}))}}}function t(e,t,s){for(var r=t.children,n=0,A=r.length;n<A;n++){var o=r[n];if("Model_3dxml"===o.type)i(e,o,s)}}function i(e,t,i){for(var r=t.children,o=0,a=r.length;o<a;o++){var l=r[o];switch(l.type){case"Header":s(e,l);break;case"ProductStructure":n(e,l,i);break;case"DefaultView":A(e,l)}}}function s(e,t){for(var i=t.children,s={},n=0,A=i.length;n<A;n++){var o=i[n];switch(o.type){case"SchemaVersion":s.schemaVersion=o.children[0],r(e,s.schemaVersion)||e.plugin.error("Schema version not supported: "+s.schemaVersion+" - supported versions are: "+zC.join(","));break;case"Title":s.title=o.children[0];break;case"Author":s.author=o.children[0];break;case"Created":s.created=o.children[0]}}e.modelNode.meta=s}function r(e,t){for(var i=0,s=zC.length;i<s;i++)if(t===zC[i])return!0;return!1}function n(e,t,i){!function(e,t,i){for(var s={},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=sM(l.associatedFile);!function(){var t=l.id;e.zip.getFile(c,(function(r,A){var a=r.getElementsByTagName("MaterialId");JC(e,a,(function(){var r={id:t};o(e,A,r),s[t]=r,0==--n&&i(s)}))}),(function(e){}))}()}}}(e,t,(function(s){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":f=m.children[0]}}A[c.id]={type:"InstanceRep",id:c.id,name:c.name,isAggregatedBy:d,isInstanceOf:f,referenceReps:{}};break;case"Instance3D":var d,f,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":f=m.children[0];break;case"RelativeMatrix":g=m.children[0]}}o[c.id]={type:"Instance3D",id:c.id,name:c.name,isAggregatedBy:d,isInstanceOf:f,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=s[(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,i){for(var s in t.instance3Ds)C(e,t.instance3Ds[s],i);for(var s in t.instanceReps)M(e,t.instanceReps[s],i)}function C(e,t,i){if(t.relativeMatrix){var s=p(t.relativeMatrix,12),r=[s[9],s[10],s[11]],n=s.slice(0,9),A=V.mat3ToMat4(n,V.identityMat4()),o=new Bt(e.modelNode,{position:r});e.metaModelData&&e.metaModelData.metaObjects.push({id:o.id,type:"Default",name:t.name,parent:i?i.id:e.modelNode.id}),i?i.addChild(o,!0):e.modelNode.addChild(o,!0),i=o,o=new Bt(e.modelNode,{matrix:A}),e.metaModelData&&e.metaModelData.metaObjects.push({id:o.id,type:"Default",name:t.name,parent:i?i.id:e.modelNode.id}),i.addChild(o,!0),i=o}else{o=new Bt(e.modelNode,{});e.metaModelData&&e.metaModelData.metaObjects.push({id:o.id,type:"Default",name:t.name,parent:i?i.id:e.modelNode.id}),i?i.addChild(o,!0):e.modelNode.addChild(o,!0),i=o}for(var a in t.reference3Ds)v(e,t.reference3Ds[a],i)}function M(e,t,i){if(t.referenceReps)for(var s in t.referenceReps){var r=t.referenceReps[s];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 as(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:i?i.id:e.modelNode.id}),i?i.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 i()}alert("No root Reference3D element found in this modelNode - can't load."),i()}))}function A(e,t){for(var i=t.children,s=0,r=i.length;s<r;s++){var n=i[s];if("Viewpoint"===n.type){var A=n.children;e.modelNode.viewpoint={};for(var o=0,a=A.length;o<a;o++){var l=A[s];switch(l.type){case"Position":e.modelNode.viewpoint.eye=p(l.children[0],3);break;case"Sight":e.modelNode.viewpoint.look=p(l.children[0],3);break;case"Up":e.modelNode.viewpoint.up=p(l.children[0],3)}}}}}function o(e,t,i){for(var s=t.children,r=0,n=s.length;r<n;r++){var A=s[r];if("XMLRepresentation"===A.type)a(e,A,i)}}function a(e,t,i){for(var s=t.children,r=0,n=s.length;r<n;r++){var A=s[r];if("Root"===A.type)l(e,A,i)}}function l(e,t,i){t["xsi:type"];for(var s=t.children,r=0,n=s.length;r<n;r++){var A=s[r];if("Rep"===A.type)c(e,A,i)}}function c(e,t,i){t["xsi:type"];for(var s={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,i);break;case"Edges":break;case"Faces":s.primitive="triangles",h(e,o,s);break;case"VertexBuffer":f(e,o,s);break;case"SurfaceAttributes":g(e,o,s)}}if(s.positions){var a=new We(e.modelNode,s);i[a.id]={geometry:a,color:s.color||[1,1,1,1],materialId:s.materialId}}}function h(e,t,i){for(var s=t.children,r=0,n=s.length;r<n;r++){var A=s[r];if("Face"===A.type)u(e,A,i)}}function u(e,t,i){var s=t.strips;if(s){var r=function(e){for(var t=e.split(","),i=[],s=0,r=t.length;s<r;s++){var n=t[s].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]));i.push(o)}}return i}(s);if(r.length>0){i.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]);i.indices=n}}else{var h=t.triangles;h&&(i.primitive="triangles",i.indices=function(e){e=e.trim().split(" ");for(var t=new Int32Array(e.length),i=0,s=e.length;i<s;i++){var r=e[i];t[i]=parseInt(r)}return t}(h))}var u=t.children;for(A=0,o=u.length;A<o;A++){var f=u[A];if("SurfaceAttributes"===f.type)g(e,f,i)}}function d(e){for(var t=[],i=0,s=e.length;i<s-2;i++)1&i?(t.push(e[i]),t.push(e[i+2]),t.push(e[i+1])):(t.push(e[i]),t.push(e[i+1]),t.push(e[i+2]));return t}function f(e,t,i){for(var s=t.children,r=0,n=s.length;r<n;r++){var A=s[r];switch(A.type){case"Positions":i.positions=p(A.children[0],3);break;case"Normals":i.normals=p(A.children[0],3);break;case"TextureCoordinates":i.uv=p(A.children[0],2)}}}function p(e,t){e=e.split(",");for(var i=new Float32Array(e.length*t),s=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]&&(i[s++]=parseFloat(A[o]));return i}function g(e,t,i){i.color=[1,1,1,1];for(var s,r,n=t.children,A=0,o=n.length;A<o;A++){var a=n[A];switch(a.type){case"Color":i.color[0]=a.red,i.color[1]=a.green,i.color[2]=a.blue,i.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=(s=u.id,r=void 0,-1!==(r=s.lastIndexOf("#"))?s.substring(r+1):s);e.materials[d]||e.plugin.error("material not found: "+d),i.materialId=d}}}}}}();function JC(e,t,i){var s={};!function r(n,A){if(n>=t.length)i();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)),s[o]?r(n+1):function(e,t,i){e.zip.getFile(t,(function(t,s){!function(e,t,i){for(var s,r=t.children,n=0,A=r.length;n<A;n++)"Model_3dxml"===(s=r[n]).type&&YC(e,s,i)}(e,s,i)}))}(e,o,(function(){s[o]=!0,r(n+1)}))}}(0)}function YC(e,t,i){for(var s,r=t.children,n=0,A=r.length;n<A;n++)"CATMaterialRef"===(s=r[n]).type&&$C(e,s,i)}function $C(e,t,i){for(var s={},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]}}s[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=sM(d.associatedFile);e.zip.getFile(r,(function(r,A){e.materials[s[t]]=qC(e,A),0==--n&&i()}),(function(e){}))}()}}function qC(e,t){for(var i=t.children,s=0,r=i.length;s<r;s++){var n=i[s];if("Osm"===n.type)return eM(e,n)}}function eM(e,t){for(var i=t.children,s=0,r=i.length;s<r;s++){var n=i[s];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=tM(a.Value,c.ambient);break;case"DiffuseColor":h.diffuse=tM(a.Value,c.diffuse);break;case"EmissiveColor":h.emissive=tM(a.Value,c.emissive);break;case"SpecularColor":h.specular=tM(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 Ss(e.modelNode,{baseColor:h.diffuse,metallic:.7,roughness:.5,emissive:h.emissive,alpha:h.alpha,alphaMode:h.alphaMode});break;case"SpecularMaterial":l=new Qs(e.modelNode,{diffuse:h.diffuse,specular:h.specular,glossiness:.5,emissive:h.emissive,alpha:h.alpha,alphaMode:h.alphaMode});break;default:l=new fs(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 tM(e,t){t=void 0!==t?t:.5;var i=e.indexOf("["),s=e.indexOf("]");e=(e=e.substring(i+1,s-i)).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 iM=function(){var e={};function t(e,i){if(e.nodeType===e.TEXT_NODE){var s=e.nodeValue;if(null===s.match(/^\s+$/))return s}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[i[A.nodeName]||A.nodeName]=A.nodeValue}for(var o=0;o<e.childNodes.length;o++){(n=t(e.childNodes[o],i))&&r.children.push(n)}return r}}this.load=function(t,i,s){WC.createReader(new WC.HttpReader(t),(function(t){t.getEntries((function(t){if(t.length>0)for(var s=0,r=t.length;s<r;s++){var n=t[s];e[n.filename]=n}i()}))}),s)},this.getFile=function(i,s,r){var n=e[i];if(!n){var A="ZIP entry not found: "+i;return console.error(A),void(r&&r(A))}n.getData(new WC.TextWriter,(function(e){var i=(new DOMParser).parseFromString(e,"text/xml"),r=t(i,{});s(i,r)}))},this.destroy=function(){undefined.close((function(){}))}};function sM(e){var t="urn:3DXML:";return 0===e.indexOf(t)?e.substring(t.length):e}class rM extends qA{constructor(e,t={}){super("XML3DLoader",e,t),t.workerScriptsPath?(this._workerScriptsPath=t.workerScriptsPath,this._loader=new XC(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 Bt(this.viewer.scene,X.apply(e,{isModel:!0})),i=e.src;return i?(this._loader.load(this,t,i,e),t):(this.error("load() param expected: src"),t)}}class nM{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,i){e=this._cacheBusterURL(e);var s=()=>{};t=t||s,i=i||s;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),i=new Uint8Array(e);for(var A=0;A<n.length;A++)i[A]=n.charCodeAt(A);t(e)}catch(e){i(e)}}else{const s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i("getXKT error : "+s.response))},s.send(null)}}}class AM extends qA{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 nM}get objectDefaults(){return this._objectDefaults}set objectDefaults(e){this._objectDefaults=e||zw}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 mA(this.viewer.scene,X.apply(e,{isModel:!0}));if(!e.src&&!e.ifc)return this.error("load() param expected: src or IFC"),t;const i={autoNormals:!0};if(!1!==e.loadMetadata){const t=e.includeTypes||this._includeTypes,s=e.excludeTypes||this._excludeTypes,r=e.objectDefaults||this._objectDefaults;if(t){i.includeTypesMap={};for(let e=0,s=t.length;e<s;e++)i.includeTypesMap[t[e]]=!0}if(s){i.excludeTypesMap={};for(let e=0,t=s.length;e<t;e++)i.excludeTypesMap[s[e]]=!0}r&&(i.objectDefaults=r),i.excludeUnclassifiedObjects=void 0!==e.excludeUnclassifiedObjects?!!e.excludeUnclassifiedObjects:this._excludeUnclassifiedObjects,i.globalizeObjectIds=void 0!==e.globalizeObjectIds?!!e.globalizeObjectIds:this._globalizeObjectIds}try{e.src?this._loadModel(e.src,e,i,t):this._parseModel(e.ifc,e,i,t)}catch(e){this.error(e),t.fire("error",e)}return t}_loadModel(e,t,i,s){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getIFC(t.src,(e=>{this._parseModel(e,t,i,s),r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){if(s.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:s,loadMetadata:l,metadata:l?{id:"",projectId:""+a,author:"",createdAt:"",schema:"",creatingApplication:"",metaObjects:[],propertySets:[]}:null,metaObjects:{},options:i,log:function(e){},nextId:0,stats:r};if(l){if(i.includeTypes){c.includeTypes={};for(let e=0,t=i.includeTypes.length;e<t;e++)c.includeTypes[i.includeTypes[e]]=!0}if(i.excludeTypes){c.excludeTypes={};for(let e=0,t=i.excludeTypes.length;e<t;e++)c.excludeTypes[i.excludeTypes[e]]=!0}this._parseMetaObjects(c),this._parsePropertySets(c)}if(this._parseGeometry(c),s.finalize(),l){const e=s.id;this.viewer.metaScene.createMetaModel(e,c.metadata,i)}s.scene.once("tick",(()=>{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}_parseMetaObjects(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCPROJECT).get(0),i=this._ifcAPI.GetLine(e.modelID,t);this._parseSpatialChildren(e,i)}_parseSpatialChildren(e,t,i){const s=this._ifcAPI.GetNameFromTypeCode(t.type);if(e.includeTypes&&!e.includeTypes[s])return;if(e.excludeTypes&&e.excludeTypes[s])return;this._createMetaObject(e,t,i);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,i){const s=t.GlobalId.value,r=this._ifcAPI.GetNameFromTypeCode(t.type),n={id:s,name:t.Name&&""!==t.Name.value?t.Name.value:r,type:r,parent:i};e.metadata.metaObjects.push(n),e.metaObjects[s]=n,e.stats.numMetaObjects++}_parseRelatedItemsOfType(e,t,i,s,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[i];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[s];if(Array.isArray(t))t.forEach((t=>{const i=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,i,n)}));else{const i=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,i,n)}}}}_parsePropertySets(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCRELDEFINESBYPROPERTIES);for(let i=0;i<t.size();i++){let s=t.get(i),r=this._ifcAPI.GetLine(e.modelID,s,!0);if(r){const t=r.RelatingPropertyDefinition;if(!t)continue;const i=t.GlobalId.value,s=t.HasProperties;if(s&&s.length>0){const n="Default",A=t.Name.value,o=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],i=t.Name,r=t.NominalValue;if(i&&r){const e={name:i.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:i,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,s=l.length;t<s;t++){const s=l[t].GlobalId.value,r=e.metaObjects[s];r&&(r.propertySetIds||(r.propertySetIds=[]),r.propertySetIds.push(i))}}}}}_parseGeometry(e){this._ifcAPI.StreamAllMeshes(e.modelID,(t=>{const i=t.expressID,s=t.geometries,r=[],n=this._ifcAPI.GetLine(e.modelID,i).GlobalId.value;if(e.loadMetadata){const t=n,i=e.metaObjects[t];if(e.includeTypes&&(!i||!e.includeTypes[i.type]))return;if(e.excludeTypes&&(!i||e.excludeTypes[i.type]))return}const A=V.mat4(),o=V.vec3();for(let t=0,i=s.size();t<i;t++){const i=s.get(t),n=this._ifcAPI.GetGeometry(e.modelID,i.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,i=a.length/6;e<i;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(i.flatTransformation),V.transformPositions3(A,c);const u=Ct(c,c,o);if(!e.options.autoNormals)for(let e=0,t=0,i=a.length/6;e<i;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:[i.color.x,i.color.y,i.color.z],opacity:i.color.w}),r.push(d)}const a=e.options.globalizeObjectIds?V.globalizeObjectId(e.sceneModel.id,n):n;e.sceneModel.createEntity({id:a,meshIds:r,isObject:!0}),e.stats.numObjects++}))}}class oM extends qA{constructor(e,t={}){super("ifcLoader",e,t),this.gltfLoader=new Xw(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:i,metaData:s}=await this.cxConverterModule.ifc2gltf(t,{remote:!0,progressCallback:e.progressCallback,progressTextCallback:e.progressTextCallback});return this.gltfLoader.load({id:"myModel",gltf:i,metaModelJSON:s})}}class aM{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,i){e=this._cacheBusterURL(e);var s=()=>{};t=t||s,i=i||s;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),i=new Uint8Array(e);for(var A=0;A<n.length;A++)i[A]=n.charCodeAt(A);t(e)}catch(e){i(e)}}else{const s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="text",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i("getIFC error : "+s.response))},s.send(null)}}}class lM extends qA{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 aM}get dataSource(){return this._dataSource}get globalizeObjectIds(){return this._globalizeObjectIds}set globalizeObjectIds(e){this._globalizeObjectIds=!!e}async load(e={}){let{id:t,backfaces:i=!0,dtxEnabled:s=!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 mA(this.viewer.scene,{id:t,isModel:!0,globalizeObjectIds:h,backfaces:i,dtxEnabled:s,position:r,rotation:n,origin:A,edges:l,saoEnabled:c}),f=d.id;if(!e.src&&!e.text)return this.error("load() expected 'src' or 'text'"),d;this.viewer.scene.canvas.spinner.processes++;const p=e=>{const t=this.ifcopenshell.file.from_string(e),i={loadMetadataPropertySets:!1!==a,globalizeObjectIds:h||this._globalizeObjectIds,geometryCache:new Map,ifc:t,sceneModel:d};if(u&&(i.excludeTypes=u),this._loadIFCGeometry(i),!1!==o){const e=this._loadIFCMetaModel(i,t);this.viewer.metaScene.createMetaModel(f,e)}this.viewer.scene.canvas.spinner.processes--};return e.src?(this.viewer.scene.canvas.spinner.processes++,this._dataSource.getIFC(e.src,(e=>{p(e),this.viewer.scene.canvas.spinner.processes--}),(e=>{this.viewer.scene.canvas.spinner.processes--,this.error(e)}))):p(e.text),d.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(f)})),d}_loadIFCGeometry(e){const{ifc:t,sceneModel:i}=e,{ifcopenshell_geom:s}=this,r=s.settings();r.set(r.WELD_VERTICES,!1);const n=s.iterator.callKwargs({settings:r,file_or_filename:t,exclude:e.excludeTypes,geometry_library:"hybrid-cgal-simple-opencascade"});if(n.initialize())do{const i=n.get();if(i){const s=t.by_id(i.id);this._parseIFCEntity(e,i,s)}}while(n.next());i.finalize(),i.scene.once("tick",(()=>{i.destroyed||(i.scene.fire("modelLoaded",i.id),i.fire("loaded",!0,!1))}))}_parseIFCEntity(e,t,i){const{sceneModel:s,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]])),i=[],s=t.slice(12,15);var r;return Ct(s,s,i),t.set(s,12),{origin:i,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}))),i=function(e){const t={};for(let i=0;i<e.length;i++){const s=e[i];null==s||s<0||(t[s]||=[]).push(i)}return t}(new Int32Array(t.geometry.material_ids.toJs())),A=new Map;for(const[e,r]of Object.entries(i)){if(!r||0===r.length)continue;const i=new Float32Array(t.geometry.verts.toJs()),o=new Uint32Array(t.geometry.edges.toJs()),a=new Uint32Array(t.geometry.faces.toJs()),l=Number(e),c=hM(r,a),h=cM(n,l);s.createGeometry({id:h,primitive:"triangles",positions:i,indices:c,edgeIndices:o}),A.set(l,h)}r.set(n,{subGeoms:A,materials:e,mapping:new Map(Object.entries(i).map((([e,t])=>[Number(e),new Uint32Array(t)])))})}const l=r.get(n),c=[];for(const[e,t]of l.subGeoms.entries()){const i=l.materials[e]||{diffuse:[.6,.6,.6],transparency:0},r=Math.random().toString(36).substr(2,9),n=i.diffuse;s.createMesh({id:r,geometryId:t,origin:o,matrix:a,color:[n[0],n[1],n[2]],opacity:1-i.transparency}),c.push(r)}s.createEntity({id:e.globalizeObjectIds?V.globalizeObjectId(e.sceneModel.id,i.GlobalId):i.GlobalId,isObject:!0,meshIds:c})}_loadIFCMetaModel(e,t){const i=new Set,s=[],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||i.has(o))return!1;i.add(o);const a=e.globalizeObjectIds,l=e.sceneModel.id,c=[];if(e.loadMetadataPropertySets){const e=["HasAssociations","IsDefinedBy","IsDecomposedBy","ContainsElements"];for(const i of e){const e=t[i];if(e&&e.length>0){for(let t=0;t<e.length;t++){const i=e.get(t);if(i.is_a&&"IfcRelDefinesByProperties"===i.is_a()){const e=i.RelatingPropertyDefinition;if(e&&e.is_a&&["IfcPropertySet","IfcElementQuantity"].includes(e.is_a())){const t=e.GlobalId?String(e.GlobalId):null,i=e.Name?String(e.Name):"",s=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),i=t.Name?String(t.Name):"";let s="",r=t.is_a?String(t.is_a()):"";if(t.is_a&&"IfcPropertySingleValue"===t.is_a())try{s=t.NominalValue?String(t.NominalValue.wrappedValue):""}catch{s=""}else if(t.is_a&&"IfcPropertyEnumeratedValue"===t.is_a())try{const e=t.EnumerationValues;if(e&&e.length>0){const t=[];for(let i=0;i<e.length;i++)t.push(String(e.get(i).wrappedValue));s=t.join(", ")}}catch{s=""}else if(t.is_a&&"IfcQuantityArea"===t.is_a())s=t.AreaValue?String(t.AreaValue):"";else if(t.is_a&&"IfcQuantityLength"===t.is_a())s=t.LengthValue?String(t.LengthValue):"";else if(t.is_a&&"IfcQuantityVolume"===t.is_a())s=t.VolumeValue?String(t.VolumeValue):"";else try{s=t.NominalValue?String(t.NominalValue):""}catch{s=""}n.push({name:i,value:s,type:r}),t.destroy?.()}A.destroy?.()}r.push({id:t,name:i,type:s,properties:n}),c.push(t),e.destroy?.()}i.destroy?.()}}e.destroy?.()}}}return s.push({id:a?V.globalizeObjectId(l,o):o,type:String(t.is_a()),parent:n?a?V.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 i=a.get(e),s=i.RelatedObjects;if(s){for(let e=0;e<s.length;e++){const i=s.get(e);o(i,t),i.destroy?.()}s.destroy?.()}i.destroy?.()}const l=t.ContainsElements;if(l)for(let e=0;e<l.length;e++){const i=l.get(e),s=i.RelatedElements;if(s){for(let e=0;e<s.length;e++){const i=s.get(e);o(i,t),i.destroy?.()}s.destroy?.()}i.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,i=e?.ThePerson,s=e?.TheOrganization,r=i?.GivenName?n(i.GivenName):"",A=i?.FamilyName?n(i.FamilyName):"",o=r||A?[r,A].filter(Boolean).join(" "):"";l=[o,s?.Name?n(s.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,i=e?.ApplicationFullName?n(e.ApplicationFullName):e?.ApplicationIdentifier?n(e.ApplicationIdentifier):"";u=[i,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 i=0;i<t.length;i++)e.push(n(t.get(i)));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 i=t.by_type("IfcRoot");for(let t=0;t<i.length;t++){const s=i.get(t),r=s?.OwnerHistory,n=r?.CreationDate;"number"==typeof n&&isFinite(n)&&n>0&&n<e&&(e=n),s.destroy?.()}i.destroy?.(),isFinite(e)&&(c=new Date(1e3*e).toISOString())}catch{}const f=t.by_type("IfcProject");for(let e=0;e<f.length;e++){const t=f.get(e);o(t,null),t.destroy?.()}return f.destroy?.(),{id:"",projectId:a,author:l,createdAt:c,schema:h,creatingApplication:u,metaObjects:s,propertySets:r}}destroy(){super.destroy()}}function cM(e,t){return`${e}:${t}#geom`}function hM(e,t){const i=new Uint32Array(3*e.length);let s=0;for(const r of e){const e=3*r;i[s++]=t[e+0],i[s++]=t[e+1],i[s++]=t[e+2]}return i}class uM{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,i){e=this._cacheBusterURL(e);var s=()=>{};t=t||s,i=i||s;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),i=new Uint8Array(e);for(var A=0;A<n.length;A++)i[A]=n.charCodeAt(A);t(e)}catch(e){i(e)}}else{const s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i("getLAS error : "+s.response))},s.send(null)}}getManifest(e,t,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}}const dM=[{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}],fM=[{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}],pM=e=>{let t=0,i=0,s=0;const r=new DataView(e),n=new Uint8Array(6e3),A=({item:s,format:n,size:A})=>{let o,a;switch(n){case"char":return a=new Uint8Array(e,t,A),t+=A,o=mM(a),[s,o];case"uShort":return o=r.getUint16(t,!0),t+=A,[s,o];case"uLong":return o=r.getUint32(t,!0),"NumberOfVariableLengthRecords"===s&&(i=o),t+=A,[s,o];case"uChar":return o=r.getUint8(t),t+=A,[s,o];case"double":return o=r.getFloat64(t,!0),t+=A,[s,o];default:t+=A}};return(()=>{const e={};dM.forEach((t=>{const i=A({...t});if(void 0!==i){if("FileSignature"===i[0]&&"LASF"!==i[1])throw new Error("Ivalid FileSignature. Is this a LAS/LAZ file");e[i[0]]=i[1]}}));const r=[];let o=i;for(;o--;){const e={};fM.forEach((i=>{const r=A({...i});e[r[0]]=r[1],"UserId"===r[0]&&"LASF_Projection"===r[1]&&(s=t-18+54)})),r.push(e)}const a=(e=>{if(void 0===e)return;const t=s+e.RecordLengthAfterHeader,i=n.slice(s,t),r=gM(i),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})()},gM=e=>{let t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let t=0;t<e.length;++t)i[t]=e[t];return t},mM=e=>{let t="";return e.forEach((e=>{let i=String.fromCharCode(e);"\0"!==i&&(t+=i)})),t.trim()};class _M extends qA{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 uM}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 mA(this.viewer.scene,X.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 i={las:{skip:this._skip,fp64:this._fp64,colorDepth:this._colorDepth}},s=this.viewer.scene.canvas.spinner,r=()=>{t.scene.once("tick",(()=>{t.destroyed||(t.scene.fire("modelLoaded",t.id),t.fire("loaded",!0,!1))})),s.processes--},n=e=>{s.processes--,this.error(e),t.fire("error",e)};if(e.src)this._loadModel(e.src,e,i,t);else if(e.las)s.processes++,this._parseModel(e.las,e,i,t).then(r,n);else if(e.manifest||e.manifestSrc){const s=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(`${s}${A[o]}`,(s=>{const n=X.apply(e,{isManifest:!0,index:o});this._parseModel(s,n,i,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 i=e.lasFiles||e.lazFiles;!i||i.length<=0?this.error("load(): Failed to load model manifest - manifest not valid"):A(i)};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,i,s){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getLAS(t.src,(e=>{this._parseModel(e,t,i,s).then((()=>{s.scene.once("tick",(()=>{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))})),r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){const r=e=>{const t=e.value;if(this._center){const e=V.vec3(),i=t.length;for(let i=0,s=t.length;i<s;i+=3)e[0]+=t[i+0],e[1]+=t[i+1],e[2]+=t[i+2];e[0]/=i,e[1]/=i,e[2]/=i;for(let i=0,s=t.length;i<s;i+=3)t[i+0]-=e[0],t[i+1]-=e[1],t[i+2]-=e[2]}if(this._rotateX&&t)for(let e=0,i=t.length;e<i;e+=3){const i=t[e+1];t[e+1]=t[e+2],t[e+2]=i}if(this._rotate){const e=V.identityQuaternion(),i=V.mat4();V.eulerToQuaternion(this._rotate,"XYZ",e),V.quaternionToRotationMat4(e,i);const s=V.vec3();for(let e=0,r=t.length;e<r;e+=3)s[0]=t[e+0],s[1]=t[e+1],s[2]=t[e+2],V.transformPoint3(i,s,s),t[e+0]=s[0],t[e+1]=s[1],t[e+2]=s[2]}if(this._transform){const e=V.mat4(this._transform),i=V.vec3();for(let s=0,r=t.length;s<r;s+=3)i[0]=t[s+0],i[1]=t[s+1],i[2]=t[s+2],V.transformPoint3(e,i,i),t[s+0]=i[0],t[s+1]=i[1],t[s+2]=i[2]}return t};function n(e,t){const i=e.value,s=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+=s,t+=4)A[t+0]=i[n+0],A[t+1]=i[n+1],A[t+2]=i[n+2],A[t+3]=Math.round(r[e]/65536*255);return A}function A(e){const t=e.value,i=4*t.length,s=new Uint8Array(i);for(let e=0,i=0,r=t.length;e<r;e++,i+=4)s[i+0]=0,s[i+1]=0,s[i+2]=0,s[i+3]=Math.round(t[e]/65536*255);return s}return new Promise(((o,a)=>{if(s.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=pM(e);Lc(e,mf,i).then((e=>{const c=e.attributes,h=e.loaderData,u=void 0!==h.pointsFormatId?h.pointsFormatId:-1;if(!c.POSITION)return s.finalize(),void a("No positions found in file");let d,f;switch(u){case 0:d=r(c.POSITION),f=A(c.intensity);break;case 1:if(!c.intensity)return s.finalize(),void a("No positions found in file");d=r(c.POSITION),f=A(c.intensity);break;case 2:case 3:if(!c.intensity)return s.finalize(),void a("No positions found in file");d=r(c.POSITION),f=n(c.COLOR_0,c.intensity)}const p=bM(d,15e5),g=bM(f,2e6),m=[];for(let e=0,i=p.length;e<i;e++){const i=`${t.isManifest?"model"+t.index:""}pointsMesh${e}`;m.push(i),s.createMesh({id:i,primitive:"points",positions:p[e],colorsCompressed:e<g.length?g[e]:null})}const _=t.entityId||V.createUUID();if(s.createEntity({id:_,meshIds:m,isObject:!0}),s.finalize(),t.metaModelJSON){const e=s.id;this.viewer.metaScene.createMetaModel(e,t.metaModelJSON,i)}else if(!1!==t.loadMetadata){const e=V.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=s.id;this.viewer.metaScene.createMetaModel(r,t,i)}o()}))}catch(e){s.finalize(),a(e)}}))}}function bM(e,t){if(t>=e.length)return[e];let i=[];for(let s=0;s<e.length;s+=t)i.push(e.slice(s,s+t));return i}class BM{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,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}}const yM=V.vec2(),wM=V.vec3(),vM=V.vec3(),CM=V.vec3();class MM extends qA{constructor(e,t={}){super("cityJSONLoader",e,t),this.dataSource=t.dataSource}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new BM}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 mA(this.viewer.scene,X.apply(e,{isModel:!0,edges:!0}));if(!e.src&&!e.cityJSON)return this.error("load() param expected: src or cityJSON"),t;const i={};if(e.src)this._loadModel(e.src,e,i,t);else{const s=this.viewer.scene.canvas.spinner;s.processes++,this._parseModel(e.cityJSON,e,i,t),s.processes--}return t}_loadModel(e,t,i,s){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getCityJSON(t.src,(e=>{this._parseModel(e,t,i,s),r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){if(s.destroyed)return;const r=e.transform?this._transformVertices(e.vertices,e.transform,i.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:V.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:s,loadMetadata:A,metadata:a,rootMetaObject:o,nextId:0,stats:n};if(this._parseCityJSON(l),s.finalize(),A){const e=s.id;this.viewer.metaScene.createMetaModel(e,l.metadata,i)}s.scene.once("tick",(()=>{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}_transformVertices(e,t,i){const s=[],r=t.scale||V.vec3([1,1,1]),n=t.translate||V.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];i?s.push([A,a,o]):s.push([A,o,a])}return s}_parseCityJSON(e){const t=e.data.CityObjects;for(const i in t)if(t.hasOwnProperty(i)){const s=t[i];this._parseCityObject(e,s,i)}}_parseCityObject(e,t,i){const s=e.sceneModel,r=e.data;if(e.loadMetadata){const s=i,r=t.type,n=r+" : "+i,A=t.parents?t.parents[0]:e.rootMetaObject.id;e.metadata.metaObjects.push({id:s,name:n,type:r,parent:A})}if(e.stats.numMetaObjects++,!(t.geometry&&t.geometry.length>0))return;const n=[];for(let i=0,s=t.geometry.length;i<s;i++){const s=t.geometry[i];let A,o;const a=r.appearance;if(a){const e=a.materials;if(e){const t=s.material;if(t){const s=Object.keys(t);if(s.length>0){const r=t[s[0]];if(void 0!==r.value)A=e[r.value];else{const t=r.values;if(t){o=[];for(let s=0,r=t.length;s<r;s++){const s=e[t[i]];o.push(s)}}}}}}}o?this._parseGeometrySurfacesWithOwnMaterials(e,s,o,n):this._parseGeometrySurfacesWithSharedMaterial(e,s,A,n)}n.length>0&&(s.createEntity({id:i,meshIds:n,isObject:!0}),e.stats.numObjects++)}_parseGeometrySurfacesWithOwnMaterials(e,t,i,s){switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":const r=t.boundaries;this._parseSurfacesWithOwnMaterials(e,i,r,s);break;case"Solid":const n=t.boundaries;for(let t=0;t<n.length;t++){const r=n[t];this._parseSurfacesWithOwnMaterials(e,i,r,s)}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,i,n,s)}}}_parseSurfacesWithOwnMaterials(e,t,i,s){const r=e.vertices,n=e.sceneModel;for(let A=0;A<i.length;A++){const a=i[A],l=t[A]||{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 i=this._extractLocalIndices(e,a[t],u,d);c.push(...i)}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,V.vec3());let i=[];for(let s=0;s<e.length;s++)this._to2D(e[s],t,yM),i.unshift(yM[0]),i.unshift(yM[1]);const s=o(i,h,2);for(let e=0;e<s.length;e+=3)d.indices.unshift(c[s[e]]),d.indices.unshift(c[s[e+1]]),d.indices.unshift(c[s[e+2]])}const f=""+e.nextId++;n.createMesh({id:f,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}),s.push(f),e.stats.numGeometries++,e.stats.numVertices+=d.positions.length/3,e.stats.numTriangles+=d.indices.length/3}}_parseGeometrySurfacesWithSharedMaterial(e,t,i,s){const r=e.sceneModel,n=[],A={positions:[],indices:[]};switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":const i=t.boundaries;this._parseSurfacesWithSharedMaterial(e,i,n,A);break;case"Solid":const s=t.boundaries;for(let t=0;t<s.length;t++){const i=s[t];this._parseSurfacesWithSharedMaterial(e,i,n,A)}break;case"MultiSolid":case"CompositeSolid":const r=t.boundaries;for(let t=0;t<r.length;t++)for(let i=0;i<r[t].length;i++){const s=r[t][i];this._parseSurfacesWithSharedMaterial(e,s,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:i&&i.diffuseColor?i.diffuseColor:[.8,.8,.8],opacity:1}),s.push(t),e.stats.numGeometries++,e.stats.numVertices+=A.positions.length/3,e.stats.numTriangles+=A.indices.length/3}}_parseSurfacesWithSharedMaterial(e,t,i,s){const r=e.vertices;for(let n=0;n<t.length;n++){let A=[],a=[];for(let r=0;r<t[n].length;r++){A.length>0&&a.push(A.length);const o=this._extractLocalIndices(e,t[n][r],i,s);A.push(...o)}if(3===A.length)s.indices.push(A[0]),s.indices.push(A[1]),s.indices.push(A[2]);else if(A.length>3){let e=[];for(let t=0;t<A.length;t++)e.push({x:r[i[A[t]]][0],y:r[i[A[t]]][1],z:r[i[A[t]]][2]});const t=this._getNormalOfPositions(e,V.vec3());let n=[];for(let i=0;i<e.length;i++)this._to2D(e[i],t,yM),n.unshift(yM[0]),n.unshift(yM[1]);const l=o(n,a,2);for(let e=0;e<l.length;e+=3)s.indices.unshift(A[l[e]]),s.indices.unshift(A[l[e+1]]),s.indices.unshift(A[l[e+2]])}}}_extractLocalIndices(e,t,i,s){const r=e.vertices,n=[];for(let e=0,A=t.length;e<A;e++){const A=t[e];if(i.includes(A)){const e=i.indexOf(A);n.push(e)}else s.positions.push(r[A][0]),s.positions.push(r[A][1]),s.positions.push(r[A][2]),n.push(i.length),i.push(A)}return n}_getNormalOfPositions(e,t){for(let i=0;i<e.length;i++){let s=i+1;s===e.length&&(s=0),t[0]+=(e[i].y-e[s].y)*(e[i].z+e[s].z),t[1]+=(e[i].z-e[s].z)*(e[i].x+e[s].x),t[2]+=(e[i].x-e[s].x)*(e[i].y+e[s].y)}return V.normalizeVec3(t)}_to2D(e,t,i){const s=wM,r=vM,n=CM;s[0]=e.x,s[1]=e.y,s[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;V.lenVec3(V.subVec3(n,r))<.01&&(n[0]+=1,n[1]+=2,n[2]+=3);const A=V.dotVec3(n,r),o=V.mulVec3Scalar(r,A,V.vec3());n[0]-=o[0],n[1]-=o[1],n[2]-=o[2],V.normalizeVec3(n);const a=V.cross3Vec3(r,n,V.vec3()),l=V.dotVec3(s,n),c=V.dotVec3(s,a);i[0]=l,i[1]=c}}class EM{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,i){X.loadJSON(this._cacheBusterURL(e),(e=>{t(e)}),(function(e){i(e)}))}}class FM extends qA{constructor(e,t={}){super("DotBIMLoader",e,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new EM}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||zw}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 mA(this.viewer.scene,X.apply(e,{isModel:!0,backfaces:e.backfaces,dtxEnabled:e.dtxEnabled,rotation:e.rotation,origin:e.origin})),i=t.id;if(!e.src&&!e.dotBIM)return this.error("load() param expected: src or dotBIM"),t;const s=e.objectDefaults||this._objectDefaults||zw;let r,n;if(e.includeTypes){r={};for(let t=0,i=e.includeTypes.length;t<i;t++)r[e.includeTypes[t]]=!0}if(e.excludeTypes){n={},r||(r={});for(let t=0,i=e.excludeTypes.length;t<i;t++)r[e.excludeTypes[t]]=!0}const A=e=>{const t=e.fileData,A=e.sceneModel,o={},a=V.createUUID(),l=V.createUUID(),c=V.createUUID(),h=V.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,i)=>{if(o[e])return;const s=t.meshes.find((e=>e.mesh_id===i.mesh_id));A.createGeometry({id:e,primitive:"triangles",positions:s.coordinates,indices:s.indices}),o[e]=!0},f=t.elements;for(let e=0,i=f.length;e<i;e++){const i=f[e],o=i.type;if(n&&n[o])continue;if(r&&!r[o])continue;const a=i.info,l=void 0!==i.guid?`${i.guid}`:void 0!==a&&void 0!==a.id?a.id:e,c=i.mesh_id,p=i.vector,g=i.rotation,m=s?s[o]||s.DEFAULT:null;let _=!0,b=!0;if(void 0===i.face_colors){d(c,i);const e=`${l}-mesh-${c}`;let t=i.color?[i.color.r/255,i.color.g/255,i.color.b/255]:[1,1,1],s=i.color?i.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&&(s=m.opacity)),A.createMesh({id:e,geometryId:c,color:t,opacity:s,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:p?[p.x,p.y,p.z]:void 0}),A.createEntity({id:l,meshIds:[e],visible:_,pickable:b,isObject:!0})}else{let e=i.face_colors,s={},r=0,n=t.meshes.find((e=>e.mesh_id===i.mesh_id));for(let t=0,i=e.length;t<i;t+=4){let i=[e[t],e[t+1],e[t+2],e[t+3]];void 0===s[i]&&(s[i]=[]);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],f=n.indices[r+2],p=n.coordinates[3*f],g=n.coordinates[3*f+1],m=n.coordinates[3*f+2];s[i].push(o,a,l,h,u,d,p,g,m),r+=3}let o=[];for(const[e,t]of Object.entries(s)){A.createGeometry({id:`${c}-${e}`,primitive:"triangles",positions:t,indices:[...Array(t.length/3).keys()]});const i=`${l}-mesh-${c}-${e}`,s=e.split(",").map(Number);let r=[s[0]/255,s[1]/255,s[2]/255],n=s[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:i,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:p?[p.x,p.y,p.z]:void 0}),o.push(i)}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:`${i.type} ${l}`,type:i.type,parent:h,propertySetIds:[l]})}A.finalize(),this.viewer.metaScene.createMetaModel(i,u),A.scene.once("tick",(()=>{A.destroyed||(A.scene.fire("modelLoaded",A.id),A.fire("loaded",!0,!1))}))};if(e.src){const i=e.src;this.viewer.scene.canvas.spinner.processes++,this._dataSource.getDotBIM(i,(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 i={fileData:e.dotBIM,sceneModel:t,nextId:0,error:function(e){}};A(i)}return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}}const UM=function(e){const t=t=>parseInt(e.substr(t+1,2),16)/255;return[t(0),t(2),t(4)]},xM=function(e,t,i){let s=null;const r=r=>{if(r){s&&s.destroy();try{const[n,A]=jy(r.map((e=>[e[0],e[2]]))),o=[].concat(...n.map((e=>[e[0],r[0][1],e[1]]))),a=[].concat(...A);s=new as(e,{pickable:!1,geometry:new We(e,{positions:o,indices:a,normals:V.buildNormals(o,a)}),material:new fs(e,{alpha:void 0!==i?i:.5,backfaces:!0,diffuse:UM(t)})})}catch(e){s=null}}s&&(s.visible=!!r)};return r(null),{updateBase:r,destroy:()=>s&&s.destroy()}},IM=function(e,t){return function(i,s,r){const n=e.scene,A=n.canvas.canvas,o=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Py(A.ownerDocument.documentElement,A,t),t),a=e=>{const i=V.vec3(),s=V.vec3();return V.canvasPosToWorldRay(A,n.camera.viewMatrix,n.camera.projMatrix,n.camera.projection,e,i,s),t(i,s)};let l=!1;const c=function(){l=!1},h=function(){c(),A.removeEventListener("mousedown",d),A.removeEventListener("mousemove",f),e.cameraControl.off(p),A.removeEventListener("mouseup",g)},u=V.vec2(),d=function(e){1===e.which&&(o(e,u),l=!0)};A.addEventListener("mousedown",d);const f=function(e){const t=o(e,V.vec2());l&&V.distVec2(u,t)>20&&(c(),i())};A.addEventListener("mousemove",f);const p=e.cameraControl.on("rayMove",(e=>{const t=e.canvasPos;s(t,a(t))})),g=function(e){if(1===e.which&&l){h();const t=o(e,V.vec2());r(t,a(t))}};return A.addEventListener("mouseup",g),h}},TM=function(e,t,i,s){const r=-(V.dotVec3(i,t)-e)/V.dotVec3(s,t);{const e=V.vec3();return V.mulVec3Scalar(s,r,e),V.addVec3(i,e,e),e}};class PM extends Ae{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(),i=this._geometry.height<0,s=this._geometry.altitude+(i?this._geometry.height:0),r=this._geometry.height*(i?-1:1),[n,A,o]=jy(t),a=[],l=[],c=e=>{const t=a.length;for(let t of n)a.push([t[0],s+(e?r:0),t[1]]);for(let i of A)l.push(...(e?i:i.slice(0).reverse()).map((e=>e+t)))};c(!1),c(!0);for(let e=0;e<n.length;++e){const t=n[e],i=n[(n.length+e+(o?1:-1))%n.length],A=s,c=s+r,h=a.length;a.push([t[0],A,t[1]],[i[0],A,i[1]],[i[0],c,i[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),f=h(1),p=h(2),g=u(0),m=u(1),_=u(2);this._center=V.vec3([(d+g)/2,(f+m)/2,(p+_)/2]);const b=[].concat(...a.map((e=>V.subVec3(e,this._center,e))));this._zoneMesh=new as(e,{origin:this._center,edges:this._edges,geometry:new We(e,{positions:b,indices:l,normals:V.buildNormals(b,l)}),material:new fs(e,{alpha:this._alpha,backfaces:!0,diffuse:UM(this._color)}),visible:this._visible}),this._zoneMesh.highlighted=this._highlighted,this._zoneMesh.zone=this;{const e=V.vec2(),t=V.vec2();let i=0;for(let s of A){const r=n[s[0]],A=n[s[1]],o=n[s[2]];V.subVec2(A,r,e),V.subVec2(o,r,t),i+=Math.abs(e[0]*t[1]-e[1]*t[0])}this._baseArea=i/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 i=this._zoneMesh.geometry,s=[V.vec3(),V.vec3(),V.vec3()],r=V.vec3();for(let n=0;n<i.indices.length;n+=3){for(let e=0;e<3;++e){const t=s[e],r=3*i.indices[n+e];for(let e=0;e<3;++e)t[e]=i.positions[r+e]}e+=V.dotVec3(s[0],V.cross3Vec3(s[1],s[2],r)),V.subVec3(s[1],s[0],s[1]),V.subVec3(s[2],s[0],s[2]),t+=V.lenVec3(V.cross3Vec3(s[1],s[2],r))}this._metrics={area:t/2,volume:e/6}}return this._metrics}sectionedAverage(e){const t=this._geometry.planeCoordinates.slice();let i=[];{const e=this._geometry.height,s=this._geometry.altitude,r=s+Math.max(0,e),n=s+Math.min(0,e),A=e=>{const s=t.map((t=>[t[0],e?r:n,t[1]]));i.push(e?s:s.slice(0).reverse())};A(!0),A(!1);const o=(e,i)=>[t[e][0],i,t[e][1]];for(let e=0;e<t.length;++e){const s=(e+1)%t.length;i.push([o(e,n),o(s,n),o(s,r),o(e,r)])}}for(const t of e){const e=t.dir,r=t.dist,n=[];for(const t of i){const i=1e-5,A=0,o=1,a=2,l=3;let c=0;const h=[];for(let s=0;s<t.length;s++){const n=V.dotVec3(e,t[s])+r,l=n<-i?a:n>i?o:A;c|=l,h.push(l)}switch(c){case A:case o:n.push(t);break;case a:break;case l:const i=[];for(let n=0;n<t.length;n++){var s=(n+1)%t.length;const A=h[n],o=h[s],c=t[n],u=t[s];if(A!==a&&i.push(c),(A|o)===l){const t=V.vec3();V.subVec3(u,c,t);const s=-(r+V.dotVec3(e,c))/V.dotVec3(e,t),n=[0,0,0];V.lerpVec3(s,0,1,c,u,n),i.push(n)}}i.length>=3&&n.push(i)}}i=n}if(0===i.length)return null;{const e=V.vec3([0,0,0]),t=new Set;for(const s of i)for(const i of s){const s=i.map((e=>e.toFixed(3))).join(":");t.has(s)||(t.add(s),V.addVec3(e,i,e))}return V.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=UM(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:V.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 SM extends Ae{constructor(e,t,i){super(e.viewer.scene),this.zonesPlugin=e,this.pointerLens=t.pointerLens,this.createSelect3dPoint=i,this._deactivate=null}get active(){return!!this._deactivate}activate(e,t,i,s){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"),i=n("color","#008000"),s=n("alpha",.5)}const r=this.zonesPlugin,n=r.viewer,A=n.scene,o=this,a=this.createSelect3dPoint(n,((t,i)=>TM(e,V.vec3([0,1,0]),t,i)));!function n(){const l=xM(A,i,s),c=function(e,t,i,s,r,n){const A=Vy(e,t),o=Vy(e,t),a=i?function(e){i.visible=!!e,e&&(i.canvasPos=e)}:()=>{};let l=s((()=>{a(null),A.update(null)}),((e,t)=>{a(e),A.update(t)}),(function(e,t){A.update(t),l=s((function(){a(null),o.update(null),r(null)}),(function(e,i){a(e),o.update(i),r(V.distVec3(t,i)>.01&&[t,i])}),(function(e,i){o.update(i),A.destroy(),o.destroy(),a(null),n([t,i])}))}));return{deactivate:function(){l(),A.destroy(),o.destroy(),a(null)}}}(A,i,o.pointerLens,a,(e=>{if(e){const t=e[0],i=e[1],s=e=>Math.min(t[e],i[e]),r=e=>Math.max(t[e],i[e]),n=s(0),A=s(1),o=s(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,i,s,r,n,A){const o=i=>Math.min(e[i],t[i]),a=i=>Math.max(e[i],t[i]),l=o(0),c=o(2),h=a(0),u=a(2);return A.createZone({id:V.createUUID(),geometry:{planeCoordinates:[[l,u],[h,u],[h,c],[l,c]],altitude:i,height:s},alpha:n,color:r})}(A[0],A[1],e,t,i,s,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()}}class DM extends SM{constructor(e,t={}){super(e,t,((e,t)=>IM(e,t)))}}class kM extends SM{constructor(e,t={}){const i=new ge(e.viewer);super(e,t,((e,t)=>Gy(e,i,t))),this.pointerCircle=i}destroy(){this.pointerCircle.destroy(),super.destroy()}}class QM extends qA{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 PM(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()}}const RM=function(e,t,i,s,r,n,A,o,a){const l=n?function(e){n.visible=!!e,e&&(n.canvasPos=e)}:()=>{};let c;const h=[()=>l(null)],u=xM(e,s,r);return h.push((()=>u.destroy())),function n(d){const f=Vy(e,s),p=d.length>0&&Ly(e,s),g=p&&d[d.length-1].getWorldPos();h.push((()=>{f.destroy(),p&&p.destroy()}));const m=d.length>0&&d[0],_=function(e){const t=m&&m.getCanvasPos();return t&&V.distVec2(t,e)<10&&{canvasPos:t,worldPos:m.getWorldPos()}},b=function(){const e=(e,t,i)=>t[0]<=Math.max(e[0],i[0])&&t[0]>=Math.min(e[0],i[0])&&t[1]<=Math.max(e[1],i[1])&&t[1]>=Math.min(e[1],i[1]),t=(e,t,i)=>{const s=(t[1]-e[1])*(i[0]-t[0])-(t[0]-e[0])*(i[1]-t[1]);return 0===s?0:s>0?1:2};return function(i,s){const r=i[i.length-2],n=i[i.length-1];for(let A=s?1:0;A<i.length-2-1;++A){const s=i[A],o=i[A+1],a=t(r,n,s),l=t(r,n,o),c=t(s,o,r),h=t(s,o,n);if(a!==l&&c!==h||0===a&&e(r,s,n)||0===l&&e(r,o,n)||0===c&&e(s,r,o)||0===h&&e(s,n,o))return!0}return!1}}();c=o((()=>{l(null),f.update(null),p&&p.update(g,null),u.updateBase(d.length>2?d.map((e=>e.getWorldPos())):null)}),((e,t)=>{const i=d.length>2&&_(e);if(m&&m.setHighlighted(!!i),l(i?i.canvasPos:e),f.update(!i&&t),p&&p.update(g,i?i.worldPos:t),d.length>=2){const e=d.map((e=>e.getWorldPos())).concat(i?[]:[t]),s=b(e.map((e=>[e[0],e[2]])),i);u.updateBase(s?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?(f.update(o),h.forEach((e=>e())),a(A.createZone({id:V.createUUID(),geometry:{planeCoordinates:m,altitude:t,height:i},alpha:r,color:s}))):(f.update(o),p&&p.update(g,o),n(d.concat(f)))}))}([]),{closeSurface:function(){throw"TODO"},deactivate:function(){c(),h.forEach((e=>e()))}}};class OM extends Ae{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,i,s){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"),i=n("color","#008000"),s=n("alpha",.5)}if(this._action)return;const r=this.zonesPlugin,n=r.viewer,A=n.scene,o=this,a=IM(n,(function(t,i){return TM(e,V.vec3([0,1,0]),t,i)}));!function n(){o._action=RM(A,e,t,i,s,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()}}class VM extends Ae{constructor(e,t={}){super(e.viewer.scene),this.zonesPlugin=e,this.pointerLens=t.pointerLens,this.pointerCircle=new ge(e.viewer),this._action=null}get active(){return!!this._action}activate(e,t,i,s){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"),i=n("color","#008000"),s=n("alpha",.5)}if(this._action)return;const r=this.zonesPlugin,n=r.viewer,A=n.scene,o=this,a=Gy(n,this.pointerCircle,(function(t,i){return TM(e,V.vec3([0,1,0]),t,i)}));!function n(){o._action=RM(A,e,t,i,s,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()}}class LM extends Ae{constructor(e,t,i,s){const r=e.plugin.viewer,n=r.scene;super(n);const A=e._geometry.altitude,o=e._geometry.planeCoordinates.map((t=>{const i=n.canvas.canvas.ownerDocument.body,s=new Qy(n,{},i,{fillColor:e._color});return s.worldPos=V.vec3([t[0],A,t[1]]),s.on("worldPos",(function(){t[0]=s.worldPos[0],t[1]=s.worldPos[2];try{e._rebuildMesh()}catch(t){e._zoneMesh&&(e._zoneMesh.destroy(),e._zoneMesh=null)}})),s})),a=Ny({viewer:r,handleMouseEvents:i,handleTouchEvents:s,pointerLens:t&&t.pointerLens,dots:o,ray2WorldPos:(e,t)=>TM(A,V.vec3([0,1,0]),e,t),onEnd:(t,i)=>(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 HM extends LM{constructor(e,t){super(e,t,!0,!1)}}class NM extends LM{constructor(e,t){super(e,t,!1,!0)}}class GM extends Ae{constructor(e,t,i,s){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=V.vec3(),i=V.vec3();return V.canvasPosToWorldRay(A,n.camera.viewMatrix,n.camera.projMatrix,n.camera.projection,e,t,i),s=t,r=i,TM(a,V.vec3([0,1,0]),s,r);var s,r},u=(e,t)=>(t[0]=e.clientX,t[1]=e.clientY,Py(A.ownerDocument.documentElement,A,t),t),d=function(e,t){const i=e=>{e.preventDefault(),t(e)};return A.addEventListener(e,i),()=>A.removeEventListener(e,i)};let f=()=>{};const p=function(t,i,s,n){const a=n(t),l=u(a,V.vec2()),p=r.scene.pick({canvasPos:l,includeEntities:[e._zoneMesh.id]});if((p&&p.entity&&p.entity.zone)===e){f(),A.style.cursor="move",r.cameraControl.active=!1;const t=function(){const t=e._geometry.planeCoordinates.map((e=>e.slice())),i=h(l),s=V.vec2([i[0],i[2]]),r=V.vec2();return function(i){const n=h(i);r[0]=n[0],r[1]=n[2],V.subVec2(s,r,r),e._geometry.planeCoordinates.forEach(((e,i)=>{V.subVec2(t[i],r,e)}));try{e._rebuildMesh()}catch(t){e._zoneMesh&&(e._zoneMesh.destroy(),e._zoneMesh=null)}}}(),a=d(i,(function(e){const i=n(e);if(i){const e=u(i,V.vec2());t(e),c(e)}})),p=d(s,(function(e){const i=n(e);if(i){const e=u(i,V.vec2());t(e),c(null),f(),o.fire("translated")}}));f=function(){f=()=>{},A.style.cursor="default",r.cameraControl.active=!0,a(),p()}}},g=[];i&&g.push(d("mousedown",(e=>{1===e.which&&p(e,"mousemove","mouseup",(e=>1===e.which&&e))}))),s&&g.push(d("touchstart",(e=>{if(1===e.touches.length){const t=e.touches[0].identifier;p(e,"touchmove","touchend",(e=>[...e.changedTouches].find((e=>e.identifier===t))))}})));const m=function(){f(),g.forEach((e=>e())),c(null)},_=e.on("destroyed",m);this._deactivate=function(){e.off("destroyed",_),m()}}deactivate(){this._deactivate(),super.destroy()}}class jM extends GM{constructor(e,t){super(e,t,!0,!1)}}class WM extends GM{constructor(e,t){super(e,t,!1,!0)}}export{Zt as AlphaFormat,BA as AmbientLight,ow as AngleMeasurementEditMouseControl,aw as AngleMeasurementEditTouchControl,tw as AngleMeasurementsControl,iw as AngleMeasurementsMouseControl,sw as AngleMeasurementsPlugin,nw as AngleMeasurementsTouchControl,fw as AnnotationsPlugin,pw as AxisGizmoPlugin,Bw as BCFViewpointsPlugin,Ns as Bitmap,Vt as ByteType,DA as CameraMemento,ve as CameraPath,Ie as CameraPathAnimation,MM as CityJSONLoaderPlugin,Et as ClampToEdgeWrapping,Ae as Component,Oi as CompressedMediaType,Nr as Configs,n as ContextMenu,VA as CubicBezierCurve,Be as Curve,oM as CxConverterIFCLoaderPlugin,Dn as DefaultLoadingManager,ei as DepthFormat,ti as DepthStencilFormat,wA as DirLight,Dw as DistanceMeasurementEditControl,kw as DistanceMeasurementEditMouseControl,Qw as DistanceMeasurementEditTouchControl,xw as DistanceMeasurementsControl,Iw as DistanceMeasurementsMouseControl,Tw as DistanceMeasurementsPlugin,Sw as DistanceMeasurementsTouchControl,Qy as Dot3D,EM as DotBIMDefaultDataSource,FM as DotBIMLoaderPlugin,Ls as EdgeMaterial,Os as EmphasisMaterial,Mv as FaceAlignedSectionPlanesPlugin,Rw as FastNavPlugin,jt as FloatType,Hs as Fresnel,he as Frustum,ce as FrustumPlane,ki as GIFMediaType,Ow as GLTFDefaultDataSource,Xw as GLTFLoaderPlugin,Wt as HalfFloatType,aM as IFCOpenShellDefaultDataSource,lM as IFCOpenShellLoaderPlugin,xs as ImagePlane,Nt as IntType,Qi as JPEGMediaType,Ln as KTX2TextureTranscoder,_M as LASLoaderPlugin,Ry as Label3D,Is as LambertMaterial,xA as LightMap,_A as LineSet,Si as LinearEncoding,St as LinearFilter,Rt as LinearMipMapLinearFilter,kt as LinearMipMapNearestFilter,Qt as LinearMipmapLinearFilter,Dt as LinearMipmapNearestFilter,kn as Loader,Sn as LoadingManager,me as LocaleService,qt as LuminanceAlphaFormat,$t as LuminanceFormat,e as Map,PA as Marker,fe as MarqueePicker,pe as MarqueePickerMouseControl,as as Mesh,tr as MeshSurfaceArea,Xs as MeshVolume,Ss as MetallicMaterial,Ft as MirroredRepeatWrapping,QA as ModelMemento,Yw as NavCubePlugin,Ut as NearestFilter,Pt as NearestMipMapLinearFilter,xt as NearestMipMapNearestFilter,Tt as NearestMipmapLinearFilter,It as NearestMipmapNearestFilter,Bt as Node,Av as OBJLoaderPlugin,H as ObjectsKdTree3,OA as ObjectsMemento,Ri as PNGMediaType,LA as Path,NA as PerformanceModel,fs as PhongMaterial,YA as PickResult,qA as Plugin,vA as PointLight,ge as PointerCircle,A as PointerLens,HA as QuadraticBezierCurve,N as Queue,Yt as RGBAFormat,Ai as RGBAIntegerFormat,xi as RGBA_ASTC_10x10_Format,Ei as RGBA_ASTC_10x5_Format,Fi as RGBA_ASTC_10x6_Format,Ui as RGBA_ASTC_10x8_Format,Ii as RGBA_ASTC_12x10_Format,Ti as RGBA_ASTC_12x12_Format,_i as RGBA_ASTC_4x4_Format,bi as RGBA_ASTC_5x4_Format,Bi as RGBA_ASTC_5x5_Format,yi as RGBA_ASTC_6x5_Format,wi as RGBA_ASTC_6x6_Format,vi as RGBA_ASTC_8x5_Format,Ci as RGBA_ASTC_8x6_Format,Mi as RGBA_ASTC_8x8_Format,Pi as RGBA_BPTC_Format,mi as RGBA_ETC2_EAC_Format,fi as RGBA_PVRTC_2BPPV1_Format,di as RGBA_PVRTC_4BPPV1_Format,ai as RGBA_S3TC_DXT1_Format,li as RGBA_S3TC_DXT3_Format,ci as RGBA_S3TC_DXT5_Format,Jt as RGBFormat,pi as RGB_ETC1_Format,gi as RGB_ETC2_Format,ui as RGB_PVRTC_2BPPV1_Format,hi as RGB_PVRTC_4BPPV1_Format,oi as RGB_S3TC_DXT1_Format,ri as RGFormat,ni as RGIntegerFormat,We as ReadableGeometry,ii as RedFormat,si as RedIntegerFormat,UA as ReflectionMap,Mt as RepeatWrapping,Ev as STLDefaultDataSource,kv as STLLoaderPlugin,mA as SceneModel,Ar as SceneModelMesh,aA as SceneModelTransform,ZA as SectionPlane,uv as SectionPlanesPlugin,Lt as ShortType,Qs as SpecularMaterial,ye as SplineCurve,SA as SpriteMarker,mv as StoreyViewsPlugin,Cs as Texture,JA as TextureTranscoder,ov as TransformControl,Ov as TreeViewPlugin,Ot as UnsignedByteType,Kt as UnsignedInt248Type,Gt as UnsignedIntType,zt as UnsignedShort4444Type,Xt as UnsignedShort5551Type,Ht as UnsignedShortType,Ke as VBOGeometry,Nv as ViewCullPlugin,Ky as Viewer,AM as WebIFCLoaderPlugin,Oy as Wire3D,On as WorkerPool,Gv as XKTDefaultDataSource,GC as XKTLoaderPlugin,rM as XML3DLoaderPlugin,LM as ZoneEditControl,HM as ZoneEditMouseControl,NM as ZoneEditTouchControl,GM as ZoneTranslateControl,jM as ZoneTranslateMouseControl,WM as ZoneTranslateTouchControl,DM as ZonesMouseControl,QM as ZonesPlugin,OM as ZonesPolysurfaceMouseControl,VM as ZonesPolysurfaceTouchControl,kM as ZonesTouchControl,Hy as activateDraggableDot,Ny as activateDraggableDots,Wy as addMousePressListener,zy as addTouchPressListener,$e as buildBoxGeometry,qe as buildBoxLinesGeometry,et as buildBoxLinesGeometryFromAABB,tt as buildCylinderGeometry,it as buildGridGeometry,ct as buildLineGeometry,st as buildPlaneGeometry,at as buildPolylineGeometry,lt as buildPolylineGeometryFromCurve,rt as buildSphereGeometry,nt as buildTorusGeometry,ot as buildVectorTextGeometry,Zy as createCombinedTexture,wt as createRTCViewMat,Jy as createSkyboxMesh,Yy as createSphereMapMesh,de as frustumIntersectsAABB3,Nn as getKTX2TextureTranscoder,Gs as isTriangleMeshSolid,Je as load3DSGeometry,Ye as loadOBJGeometry,Vy as marker3D,V as math,ir as meshSurfaceArea,Ks as meshVolume,$A as os,Di as sRGBEncoding,ue as setFrustum,Xy as startPolygonCreate,G as stats,Gy as touchPointSelector,Py as transformToNode,jy as triangulateEarClipping,X as utils,Ly as wire3D,vt as worldToRTCPos,Ct as worldToRTCPositions};
|