function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = []
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
import{_ as Dd,l as CA,d as Ld,r as Ht,o as Fd,i as Nd,w as BA,a as rt,c as Et,b as as,e as kd,f as yA,F as Pr,g as wA,h as Ud,j as xA,k as Pd,u as Ne,t as vA,s as Ct,m as Gd,n as Gr,p as Od,q as Hd}from"./index-C38YWWqK.js";import{C as Vh,A as $d,a as iA,L as Br,F as Lt,S as be,b as ie,B as Hi,c as Se,d as Ke,T as Vd,e as Sa,f as qh,g as Ni,h as qd,P as zh,D as Kh,M as Xe,i as It,V as ce,j as le,k as R,I as zd,l as Kd,O as Xi,m as Yh,n as Yd,o as Jd,p as de,q as Js,R as Nt,r as jd,s as zn,t as Wd,u as Ar,v as kt,w as $i,x as Xd,y as ge,z as Zd,E as eg,G as tg,H as sg,J as Kn,K as Vi,N as cr,Q as yr,U as ig,W as ng,X as rg,Y as nA,Z as QA,_ as wr,$ as js,a0 as xr,a1 as vr,a2 as Qr,a3 as Pe,a4 as Sr,a5 as Jh,a6 as qi,a7 as og,a8 as Ze,a9 as SA,aa as bA,ab as TA,ac as Ae,ad as br,ae as ag,af as Ag,ag as ve,ah as cg,ai as ki,aj as _e,ak as lg,al as hg,am as ug,an as dg,ao as gg,ap as fg,aq as pg,ar as mg,as as Ig,at as it,au as De,av as jh,aw as Eg,ax as Cg,ay as Bg,az as lr,aA as Qi,aB as Si,aC as MA,aD as Tr,aE as Ws,aF as $s,aG as yg,aH as Ut,aI as rA,aJ as Wh,aK as wg,aL as xg,aM as Xh,aN as vg,aO as Yn,aP as oA,aQ as Zh,aR as zi,aS as hr,aT as Qg,aU as Sg,aV as bg,aW as Tg,aX as Mg,aY as RA,aZ as eu,a_ as Rg,a$ as sn,b0 as tu,b1 as Mr,b2 as _g,b3 as _A,b4 as Dg,b5 as DA,b6 as Lg,b7 as Fg,b8 as ts,b9 as Ng,ba as kg,bb as Ug,bc as su,bd as iu,be as Pg,bf as nu,bg as pt,bh as Gg}from"./three.module-BOGuGDOF.js";import{V as Og,a as Hg}from"./VList-Dg2jGgBj.js";/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const Jn=window,aA=Jn.ShadowRoot&&(Jn.ShadyCSS===void 0||Jn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ru=Symbol(),LA=new WeakMap;let $g=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==ru)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(aA&&e===void 0){const s=t!==void 0&&t.length===1;s&&(e=LA.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&LA.set(t,e))}return e}toString(){return this.cssText}};const Vg=o=>new $g(typeof o=="string"?o:o+"",void 0,ru),qg=(o,e)=>{aA?o.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):e.forEach(t=>{const s=document.createElement("style"),i=Jn.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=t.cssText,o.appendChild(s)})},FA=aA?o=>o:o=>o instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return Vg(t)})(o):o;/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var Or;const ur=window,NA=ur.trustedTypes,zg=NA?NA.emptyScript:"",kA=ur.reactiveElementPolyfillSupport,ba={toAttribute(o,e){switch(e){case Boolean:o=o?zg:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,e){let t=o;switch(e){case Boolean:t=o!==null;break;case Number:t=o===null?null:Number(o);break;case Object:case Array:try{t=JSON.parse(o)}catch{t=null}}return t}},ou=(o,e)=>e!==o&&(e==e||o==o),Hr={attribute:!0,type:String,converter:ba,reflect:!1,hasChanged:ou},Ta="finalized";let es=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),((t=this.h)!==null&&t!==void 0?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach((t,s)=>{const i=this._$Ep(s,t);i!==void 0&&(this._$Ev.set(i,s),e.push(i))}),e}static createProperty(e,t=Hr){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const s=typeof e=="symbol"?Symbol():"__"+e,i=this.getPropertyDescriptor(e,s,t);i!==void 0&&Object.defineProperty(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){return{get(){return this[t]},set(i){const n=this[e];this[t]=i,this.requestUpdate(e,n,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Hr}static finalize(){if(this.hasOwnProperty(Ta))return!1;this[Ta]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,s=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of s)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const i of s)t.unshift(FA(i))}else e!==void 0&&t.push(FA(e));return t}static _$Ep(e,t){const s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(t=>t(this))}addController(e){var t,s;((t=this._$ES)!==null&&t!==void 0?t:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((s=e.hostConnected)===null||s===void 0||s.call(e))}removeController(e){var t;(t=this._$ES)===null||t===void 0||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])})}createRenderRoot(){var e;const t=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return qg(t,this.constructor.elementStyles),t}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(t=>{var s;return(s=t.hostConnected)===null||s===void 0?void 0:s.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(t=>{var s;return(s=t.hostDisconnected)===null||s===void 0?void 0:s.call(t)})}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$EO(e,t,s=Hr){var i;const n=this.constructor._$Ep(e,s);if(n!==void 0&&s.reflect===!0){const r=(((i=s.converter)===null||i===void 0?void 0:i.toAttribute)!==void 0?s.converter:ba).toAttribute(t,s.type);this._$El=e,r==null?this.removeAttribute(n):this.setAttribute(n,r),this._$El=null}}_$AK(e,t){var s;const i=this.constructor,n=i._$Ev.get(e);if(n!==void 0&&this._$El!==n){const r=i.getPropertyOptions(n),a=typeof r.converter=="function"?{fromAttribute:r.converter}:((s=r.converter)===null||s===void 0?void 0:s.fromAttribute)!==void 0?r.converter:ba;this._$El=n,this[n]=a.fromAttribute(t,r.type),this._$El=null}}requestUpdate(e,t,s){let i=!0;e!==void 0&&(((s=s||this.constructor.getPropertyOptions(e)).hasChanged||ou)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),s.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,s))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((i,n)=>this[n]=i),this._$Ei=void 0);let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var n;return(n=i.hostUpdate)===null||n===void 0?void 0:n.call(i)}),this.update(s)):this._$Ek()}catch(i){throw t=!1,this._$Ek(),i}t&&this._$AE(s)}willUpdate(e){}_$AE(e){var t;(t=this._$ES)===null||t===void 0||t.forEach(s=>{var i;return(i=s.hostUpdated)===null||i===void 0?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((t,s)=>this._$EO(s,this[s],t)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};es[Ta]=!0,es.elementProperties=new Map,es.elementStyles=[],es.shadowRootOptions={mode:"open"},kA==null||kA({ReactiveElement:es}),((Or=ur.reactiveElementVersions)!==null&&Or!==void 0?Or:ur.reactiveElementVersions=[]).push("1.6.3");/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var $r;const dr=window,Vs=dr.trustedTypes,UA=Vs?Vs.createPolicy("lit-html",{createHTML:o=>o}):void 0,Ma="$lit$",Tt=`lit$${(Math.random()+"").slice(9)}$`,au="?"+Tt,Kg=`<${au}>`,is=document,Ki=()=>is.createComment(""),Yi=o=>o===null||typeof o!="object"&&typeof o!="function",Au=Array.isArray,Yg=o=>Au(o)||typeof(o==null?void 0:o[Symbol.iterator])=="function",Vr=`[ 	
\f\r]`,ei=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,PA=/-->/g,GA=/>/g,$t=RegExp(`>|${Vr}(?:([^\\s"'>=/]+)(${Vr}*=${Vr}*(?:[^ 	
\f\r"'\`<>=]|("|')|))|$)`,"g"),OA=/'/g,HA=/"/g,cu=/^(?:script|style|textarea|title)$/i,Jg=o=>(e,...t)=>({_$litType$:o,strings:e,values:t}),Rr=Jg(1),qs=Symbol.for("lit-noChange"),oe=Symbol.for("lit-nothing"),$A=new WeakMap,ss=is.createTreeWalker(is,129,null,!1);function lu(o,e){if(!Array.isArray(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return UA!==void 0?UA.createHTML(e):e}const jg=(o,e)=>{const t=o.length-1,s=[];let i,n=e===2?"<svg>":"",r=ei;for(let a=0;a<t;a++){const A=o[a];let c,l,h=-1,u=0;for(;u<A.length&&(r.lastIndex=u,l=r.exec(A),l!==null);)u=r.lastIndex,r===ei?l[1]==="!--"?r=PA:l[1]!==void 0?r=GA:l[2]!==void 0?(cu.test(l[2])&&(i=RegExp("</"+l[2],"g")),r=$t):l[3]!==void 0&&(r=$t):r===$t?l[0]===">"?(r=i??ei,h=-1):l[1]===void 0?h=-2:(h=r.lastIndex-l[2].length,c=l[1],r=l[3]===void 0?$t:l[3]==='"'?HA:OA):r===HA||r===OA?r=$t:r===PA||r===GA?r=ei:(r=$t,i=void 0);const d=r===$t&&o[a+1].startsWith("/>")?" ":"";n+=r===ei?A+Kg:h>=0?(s.push(c),A.slice(0,h)+Ma+A.slice(h)+Tt+d):A+Tt+(h===-2?(s.push(void 0),a):d)}return[lu(o,n+(o[t]||"<?>")+(e===2?"</svg>":"")),s]};class Ji{constructor({strings:e,_$litType$:t},s){let i;this.parts=[];let n=0,r=0;const a=e.length-1,A=this.parts,[c,l]=jg(e,t);if(this.el=Ji.createElement(c,s),ss.currentNode=this.el.content,t===2){const h=this.el.content,u=h.firstChild;u.remove(),h.append(...u.childNodes)}for(;(i=ss.nextNode())!==null&&A.length<a;){if(i.nodeType===1){if(i.hasAttributes()){const h=[];for(const u of i.getAttributeNames())if(u.endsWith(Ma)||u.startsWith(Tt)){const d=l[r++];if(h.push(u),d!==void 0){const g=i.getAttribute(d.toLowerCase()+Ma).split(Tt),p=/([.?@])?(.*)/.exec(d);A.push({type:1,index:n,name:p[2],strings:g,ctor:p[1]==="."?Xg:p[1]==="?"?ef:p[1]==="@"?tf:_r})}else A.push({type:6,index:n})}for(const u of h)i.removeAttribute(u)}if(cu.test(i.tagName)){const h=i.textContent.split(Tt),u=h.length-1;if(u>0){i.textContent=Vs?Vs.emptyScript:"";for(let d=0;d<u;d++)i.append(h[d],Ki()),ss.nextNode(),A.push({type:2,index:++n});i.append(h[u],Ki())}}}else if(i.nodeType===8)if(i.data===au)A.push({type:2,index:n});else{let h=-1;for(;(h=i.data.indexOf(Tt,h+1))!==-1;)A.push({type:7,index:n}),h+=Tt.length-1}n++}}static createElement(e,t){const s=is.createElement("template");return s.innerHTML=e,s}}function zs(o,e,t=o,s){var i,n,r,a;if(e===qs)return e;let A=s!==void 0?(i=t._$Co)===null||i===void 0?void 0:i[s]:t._$Cl;const c=Yi(e)?void 0:e._$litDirective$;return(A==null?void 0:A.constructor)!==c&&((n=A==null?void 0:A._$AO)===null||n===void 0||n.call(A,!1),c===void 0?A=void 0:(A=new c(o),A._$AT(o,t,s)),s!==void 0?((r=(a=t)._$Co)!==null&&r!==void 0?r:a._$Co=[])[s]=A:t._$Cl=A),A!==void 0&&(e=zs(o,A._$AS(o,e.values),A,s)),e}class Wg{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:s},parts:i}=this._$AD,n=((t=e==null?void 0:e.creationScope)!==null&&t!==void 0?t:is).importNode(s,!0);ss.currentNode=n;let r=ss.nextNode(),a=0,A=0,c=i[0];for(;c!==void 0;){if(a===c.index){let l;c.type===2?l=new Zi(r,r.nextSibling,this,e):c.type===1?l=new c.ctor(r,c.name,c.strings,this,e):c.type===6&&(l=new sf(r,this,e)),this._$AV.push(l),c=i[++A]}a!==(c==null?void 0:c.index)&&(r=ss.nextNode(),a++)}return ss.currentNode=is,n}v(e){let t=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}}class Zi{constructor(e,t,s,i){var n;this.type=2,this._$AH=oe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=i,this._$Cp=(n=i==null?void 0:i.isConnected)===null||n===void 0||n}get _$AU(){var e,t;return(t=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&t!==void 0?t:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=zs(this,e,t),Yi(e)?e===oe||e==null||e===""?(this._$AH!==oe&&this._$AR(),this._$AH=oe):e!==this._$AH&&e!==qs&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):Yg(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==oe&&Yi(this._$AH)?this._$AA.nextSibling.data=e:this.$(is.createTextNode(e)),this._$AH=e}g(e){var t;const{values:s,_$litType$:i}=e,n=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Ji.createElement(lu(i.h,i.h[0]),this.options)),i);if(((t=this._$AH)===null||t===void 0?void 0:t._$AD)===n)this._$AH.v(s);else{const r=new Wg(n,this),a=r.u(this.options);r.v(s),this.$(a),this._$AH=r}}_$AC(e){let t=$A.get(e.strings);return t===void 0&&$A.set(e.strings,t=new Ji(e)),t}T(e){Au(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,i=0;for(const n of e)i===t.length?t.push(s=new Zi(this.k(Ki()),this.k(Ki()),this,this.options)):s=t[i],s._$AI(n),i++;i<t.length&&(this._$AR(s&&s._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var s;for((s=this._$AP)===null||s===void 0||s.call(this,!1,!0,t);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cp=e,(t=this._$AP)===null||t===void 0||t.call(this,e))}}class _r{constructor(e,t,s,i,n){this.type=1,this._$AH=oe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=oe}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,s,i){const n=this.strings;let r=!1;if(n===void 0)e=zs(this,e,t,0),r=!Yi(e)||e!==this._$AH&&e!==qs,r&&(this._$AH=e);else{const a=e;let A,c;for(e=n[0],A=0;A<n.length-1;A++)c=zs(this,a[s+A],t,A),c===qs&&(c=this._$AH[A]),r||(r=!Yi(c)||c!==this._$AH[A]),c===oe?e=oe:e!==oe&&(e+=(c??"")+n[A+1]),this._$AH[A]=c}r&&!i&&this.j(e)}j(e){e===oe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Xg extends _r{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===oe?void 0:e}}const Zg=Vs?Vs.emptyScript:"";class ef extends _r{constructor(){super(...arguments),this.type=4}j(e){e&&e!==oe?this.element.setAttribute(this.name,Zg):this.element.removeAttribute(this.name)}}class tf extends _r{constructor(e,t,s,i,n){super(e,t,s,i,n),this.type=5}_$AI(e,t=this){var s;if((e=(s=zs(this,e,t,0))!==null&&s!==void 0?s:oe)===qs)return;const i=this._$AH,n=e===oe&&i!==oe||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==oe&&(i===oe||n);n&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,s;typeof this._$AH=="function"?this._$AH.call((s=(t=this.options)===null||t===void 0?void 0:t.host)!==null&&s!==void 0?s:this.element,e):this._$AH.handleEvent(e)}}class sf{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){zs(this,e)}}const VA=dr.litHtmlPolyfillSupport;VA==null||VA(Ji,Zi),(($r=dr.litHtmlVersions)!==null&&$r!==void 0?$r:dr.litHtmlVersions=[]).push("2.8.0");const hu=(o,e,t)=>{var s,i;const n=(s=t==null?void 0:t.renderBefore)!==null&&s!==void 0?s:e;let r=n._$litPart$;if(r===void 0){const a=(i=t==null?void 0:t.renderBefore)!==null&&i!==void 0?i:null;n._$litPart$=r=new Zi(e.insertBefore(Ki(),a),a,void 0,t??{})}return r._$AI(o),r};/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var qr,zr;class jn extends es{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const s=super.createRenderRoot();return(e=(t=this.renderOptions).renderBefore)!==null&&e!==void 0||(t.renderBefore=s.firstChild),s}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=hu(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!1)}render(){return qs}}jn.finalized=!0,jn._$litElement$=!0,(qr=globalThis.litElementHydrateSupport)===null||qr===void 0||qr.call(globalThis,{LitElement:jn});const qA=globalThis.litElementPolyfillSupport;qA==null||qA({LitElement:jn});((zr=globalThis.litElementVersions)!==null&&zr!==void 0?zr:globalThis.litElementVersions=[]).push("3.3.3");/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const nf=(o,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(t){t.createProperty(e.key,o)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){typeof e.initializer=="function"&&(this[e.key]=e.initializer.call(this))},finisher(t){t.createProperty(e.key,o)}},rf=(o,e,t)=>{e.constructor.createProperty(t,o)};function U(o){return(e,t)=>t!==void 0?rf(o,e,t):nf(o,e)}/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var Kr;((Kr=window.HTMLSlotElement)===null||Kr===void 0?void 0:Kr.prototype.assignedElements)!=null;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const uu=navigator.xr!=null&&self.XRSession!=null&&navigator.xr.isSessionSupported!=null,du=uu&&self.XRSession.prototype.requestHitTestSource!=null,Yr=self.ResizeObserver!=null,Jr=self.IntersectionObserver!=null,gu=du;(()=>{const o=navigator.userAgent||navigator.vendor||self.opera;let e=!1;return(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(o)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(o.substr(0,4)))&&(e=!0),e})();const of=/android/i.test(navigator.userAgent),af=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,Af=/firefox/i.test(navigator.userAgent),cf=/OculusBrowser/.test(navigator.userAgent),lf=of&&!Af&&!cf,hf=!!(window.webkit&&window.webkit.messageHandlers),zA=(()=>{if(af){if(hf)return!!/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent);{const o=document.createElement("a");return!!(o.relList&&o.relList.supports&&o.relList.supports("ar"))}}else return!1})();/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const fu=o=>o&&o!=="null"?uf(o):null,KA=()=>{if(gu)return;const o=[];throw uu||o.push("WebXR Device API"),du||o.push("WebXR Hit Test API"),new Error(`The following APIs are required for AR, but are missing in this browser: ${o.join(", ")}`)},uf=o=>new URL(o,window.location.toString()).toString(),df=(o,e)=>{let t=null;const s=(...i)=>{t==null&&(o(...i),t=self.setTimeout(()=>t=null,e))};return s.flush=()=>{t!=null&&(self.clearTimeout(t),t=null)},s},YA=(o,e)=>{let t=null;return(...s)=>{t!=null&&self.clearTimeout(t),t=self.setTimeout(()=>{t=null,o(...s)},e)}},We=(o,e,t)=>Math.max(e,Math.min(t,o)),gf=1,Ra=(()=>{const o=(()=>{var e;if(!((e=document.documentElement.getAttribute("itemtype"))===null||e===void 0)&&e.includes("schema.org/SearchResultsPage"))return!0;const t=document.head!=null?Array.from(document.head.querySelectorAll("meta")):[];for(const s of t)if(s.name==="viewport")return!0;return!1})();return o||console.warn('No <meta name="viewport"> detected; <model-viewer> will cap pixel density at 1.'),()=>o?window.devicePixelRatio:gf})(),pu=(()=>{const o="model-viewer-debug-mode",e=new RegExp(`[?&]${o}(&|$)`);return()=>self.ModelViewerElement&&self.ModelViewerElement.debugMode||self.location&&self.location.search&&self.location.search.match(e)})(),ff=(o=0)=>new Promise(e=>setTimeout(e,o)),pf=(o,e,t=null)=>new Promise(s=>{function i(n){(!t||t(n))&&(s(n),o.removeEventListener(e,i))}o.addEventListener(e,i)});/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Vt=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const mf=.5,If=0,Ef=1,Cf=1,bi=Symbol("currentEnvironmentMap"),Ti=Symbol("currentBackground"),gr=Symbol("updateEnvironment"),nn=Symbol("cancelEnvironmentUpdate"),Bf=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=If,this.shadowSoftness=Ef,this.exposure=Cf,this.toneMapping="auto",this.skyboxHeight="0",this[e]=null,this[t]=null,this[s]=null}updated(r){super.updated(r),r.has("shadowIntensity")&&(this[D].setShadowIntensity(this.shadowIntensity*mf),this[me]()),r.has("shadowSoftness")&&(this[D].setShadowSoftness(this.shadowSoftness),this[me]()),r.has("exposure")&&(this[D].exposure=this.exposure,this[me]()),r.has("toneMapping")&&(this[D].toneMapping=this.toneMapping==="commerce"?Vh:this.toneMapping==="agx"?$d:iA,this[me]()),(r.has("environmentImage")||r.has("skyboxImage"))&&this[Ks]()&&this[gr](),r.has("skyboxHeight")&&(this[D].setGroundedSkybox(),this[me]())}hasBakedShadow(){return this[D].bakedShadows.size>0}async[(e=bi,t=Ti,s=nn,gr)](){const{skyboxImage:r,environmentImage:a}=this;this[nn]!=null&&(this[nn](),this[nn]=null);const{textureUtils:A}=this[q];if(A==null)return;const c=this[ns].beginActivity("environment-update");try{const{environmentMap:l,skybox:h}=await A.generateEnvironmentMapAndSkybox(fu(r),a,u=>c(We(u,0,1)));this[bi]!==l&&(this[bi]=l,this.dispatchEvent(new CustomEvent("environment-change"))),h!=null?this[Ti]=h.name===l.name?l:h:this[Ti]=null,this[D].setEnvironmentAndSkybox(this[bi],this[Ti])}catch(l){if(l instanceof Error)throw this[D].setEnvironmentAndSkybox(null,null),l}finally{c(1)}}}return Vt([U({type:String,attribute:"environment-image"})],i.prototype,"environmentImage",void 0),Vt([U({type:String,attribute:"skybox-image"})],i.prototype,"skyboxImage",void 0),Vt([U({type:Number,attribute:"shadow-intensity"})],i.prototype,"shadowIntensity",void 0),Vt([U({type:Number,attribute:"shadow-softness"})],i.prototype,"shadowSoftness",void 0),Vt([U({type:Number})],i.prototype,"exposure",void 0),Vt([U({type:String,attribute:"tone-mapping"})],i.prototype,"toneMapping",void 0),Vt([U({type:String,attribute:"skybox-height"})],i.prototype,"skyboxHeight",void 0),i};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const yf=Rr`
<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000">
    <!-- NOTE(cdata): This SVG filter is a stop-gap until we can implement
         support for dynamic re-coloring of UI components -->
    <defs>
      <filter id="drop-shadow" x="-100%" y="-100%" width="300%" height="300%">
        <feGaussianBlur in="SourceAlpha" stdDeviation="1"/>
        <feOffset dx="0" dy="0" result="offsetblur"/>
        <feFlood flood-color="#000000"/>
        <feComposite in2="offsetblur" operator="in"/>
        <feMerge>
          <feMergeNode/>
          <feMergeNode in="SourceGraphic"/>
        </feMerge>
      </filter>
    </defs>
    <path filter="url(#drop-shadow)" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
    <path d="M0 0h24v24H0z" fill="none"/>
</svg>`;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const wf=Rr`
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="36">
    <defs>
        <path id="A" d="M.001.232h24.997V36H.001z" />
    </defs>
    <g transform="translate(-11 -4)" fill="none" fill-rule="evenodd">
        <path fill-opacity="0" fill="#fff" d="M0 0h44v44H0z" />
        <g transform="translate(11 3)">
            <path d="M8.733 11.165c.04-1.108.766-2.027 1.743-2.307a2.54 2.54 0 0 1 .628-.089c.16 0 .314.017.463.044 1.088.2 1.9 1.092 1.9 2.16v8.88h1.26c2.943-1.39 5-4.45 5-8.025a9.01 9.01 0 0 0-1.9-5.56l-.43-.5c-.765-.838-1.683-1.522-2.712-2-1.057-.49-2.226-.77-3.46-.77s-2.4.278-3.46.77c-1.03.478-1.947 1.162-2.71 2l-.43.5a9.01 9.01 0 0 0-1.9 5.56 9.04 9.04 0 0 0 .094 1.305c.03.21.088.41.13.617l.136.624c.083.286.196.56.305.832l.124.333a8.78 8.78 0 0 0 .509.953l.065.122a8.69 8.69 0 0 0 3.521 3.191l1.11.537v-9.178z" fill-opacity=".5" fill="#e4e4e4" />
            <path d="M22.94 26.218l-2.76 7.74c-.172.485-.676.8-1.253.8H12.24c-1.606 0-3.092-.68-3.98-1.82-1.592-2.048-3.647-3.822-6.11-5.27-.095-.055-.15-.137-.152-.23-.004-.1.046-.196.193-.297.56-.393 1.234-.6 1.926-.6a3.43 3.43 0 0 1 .691.069l4.922.994V10.972c0-.663.615-1.203 1.37-1.203s1.373.54 1.373 1.203v9.882h2.953c.273 0 .533.073.757.21l6.257 3.874c.027.017.045.042.07.06.41.296.586.77.426 1.22M4.1 16.614c-.024-.04-.042-.083-.065-.122a8.69 8.69 0 0 1-.509-.953c-.048-.107-.08-.223-.124-.333l-.305-.832c-.058-.202-.09-.416-.136-.624l-.13-.617a9.03 9.03 0 0 1-.094-1.305c0-2.107.714-4.04 1.9-5.56l.43-.5c.764-.84 1.682-1.523 2.71-2 1.058-.49 2.226-.77 3.46-.77s2.402.28 3.46.77c1.03.477 1.947 1.16 2.712 2l.428.5a9 9 0 0 1 1.901 5.559c0 3.577-2.056 6.636-5 8.026h-1.26v-8.882c0-1.067-.822-1.96-1.9-2.16-.15-.028-.304-.044-.463-.044-.22 0-.427.037-.628.09-.977.28-1.703 1.198-1.743 2.306v9.178l-1.11-.537C6.18 19.098 4.96 18 4.1 16.614M22.97 24.09l-6.256-3.874c-.102-.063-.218-.098-.33-.144 2.683-1.8 4.354-4.855 4.354-8.243 0-.486-.037-.964-.104-1.43a9.97 9.97 0 0 0-1.57-4.128l-.295-.408-.066-.092a10.05 10.05 0 0 0-.949-1.078c-.342-.334-.708-.643-1.094-.922-1.155-.834-2.492-1.412-3.94-1.65l-.732-.088-.748-.03a9.29 9.29 0 0 0-1.482.119c-1.447.238-2.786.816-3.94 1.65a9.33 9.33 0 0 0-.813.686 9.59 9.59 0 0 0-.845.877l-.385.437-.36.5-.288.468-.418.778-.04.09c-.593 1.28-.93 2.71-.93 4.222 0 3.832 2.182 7.342 5.56 8.938l1.437.68v4.946L5 25.64a4.44 4.44 0 0 0-.888-.086c-.017 0-.034.003-.05.003-.252.004-.503.033-.75.08a5.08 5.08 0 0 0-.237.056c-.193.046-.382.107-.568.18-.075.03-.15.057-.225.1-.25.114-.494.244-.723.405a1.31 1.31 0 0 0-.566 1.122 1.28 1.28 0 0 0 .645 1.051C4 29.925 5.96 31.614 7.473 33.563a5.06 5.06 0 0 0 .434.491c1.086 1.082 2.656 1.713 4.326 1.715h6.697c.748-.001 1.43-.333 1.858-.872.142-.18.256-.38.336-.602l2.757-7.74c.094-.26.13-.53.112-.794s-.088-.52-.203-.76a2.19 2.19 0 0 0-.821-.91" fill-opacity=".6" fill="#000" />
            <path d="M22.444 24.94l-6.257-3.874a1.45 1.45 0 0 0-.757-.211h-2.953v-9.88c0-.663-.616-1.203-1.373-1.203s-1.37.54-1.37 1.203v16.643l-4.922-.994a3.44 3.44 0 0 0-.692-.069 3.35 3.35 0 0 0-1.925.598c-.147.102-.198.198-.194.298.004.094.058.176.153.23 2.462 1.448 4.517 3.22 6.11 5.27.887 1.14 2.373 1.82 3.98 1.82h6.686c.577 0 1.08-.326 1.253-.8l2.76-7.74c.16-.448-.017-.923-.426-1.22-.025-.02-.043-.043-.07-.06z" fill="#fff" />
            <g transform="translate(0 .769)">
                <mask id="B" fill="#fff">
                    <use xlink:href="#A" />
                </mask>
                <path d="M23.993 24.992a1.96 1.96 0 0 1-.111.794l-2.758 7.74c-.08.22-.194.423-.336.602-.427.54-1.11.87-1.857.872h-6.698c-1.67-.002-3.24-.633-4.326-1.715-.154-.154-.3-.318-.434-.49C5.96 30.846 4 29.157 1.646 27.773c-.385-.225-.626-.618-.645-1.05a1.31 1.31 0 0 1 .566-1.122 4.56 4.56 0 0 1 .723-.405l.225-.1a4.3 4.3 0 0 1 .568-.18l.237-.056c.248-.046.5-.075.75-.08.018 0 .034-.003.05-.003.303-.001.597.027.89.086l3.722.752V20.68l-1.436-.68c-3.377-1.596-5.56-5.106-5.56-8.938 0-1.51.336-2.94.93-4.222.015-.03.025-.06.04-.09.127-.267.268-.525.418-.778.093-.16.186-.316.288-.468.063-.095.133-.186.2-.277L3.773 5c.118-.155.26-.29.385-.437.266-.3.544-.604.845-.877a9.33 9.33 0 0 1 .813-.686C6.97 2.167 8.31 1.59 9.757 1.35a9.27 9.27 0 0 1 1.481-.119 8.82 8.82 0 0 1 .748.031c.247.02.49.05.733.088 1.448.238 2.786.816 3.94 1.65.387.28.752.588 1.094.922a9.94 9.94 0 0 1 .949 1.078l.066.092c.102.133.203.268.295.408a9.97 9.97 0 0 1 1.571 4.128c.066.467.103.945.103 1.43 0 3.388-1.67 6.453-4.353 8.243.11.046.227.08.33.144l6.256 3.874c.37.23.645.55.82.9.115.24.185.498.203.76m.697-1.195c-.265-.55-.677-1.007-1.194-1.326l-5.323-3.297c2.255-2.037 3.564-4.97 3.564-8.114 0-2.19-.637-4.304-1.84-6.114-.126-.188-.26-.37-.4-.552-.645-.848-1.402-1.6-2.252-2.204C15.472.91 13.393.232 11.238.232A10.21 10.21 0 0 0 5.23 2.19c-.848.614-1.606 1.356-2.253 2.205-.136.18-.272.363-.398.55C1.374 6.756.737 8.87.737 11.06c0 4.218 2.407 8.08 6.133 9.842l.863.41v3.092l-2.525-.51c-.356-.07-.717-.106-1.076-.106a5.45 5.45 0 0 0-3.14.996c-.653.46-1.022 1.202-.99 1.983a2.28 2.28 0 0 0 1.138 1.872c2.24 1.318 4.106 2.923 5.543 4.772 1.26 1.62 3.333 2.59 5.55 2.592h6.698c1.42-.001 2.68-.86 3.134-2.138l2.76-7.74c.272-.757.224-1.584-.134-2.325" fill-opacity=".05" fill="#000" mask="url(#B)" />
            </g>
        </g>
    </g>
</svg>`;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const xf=Rr`
<svg version="1.1" id="view_x5F_in_x5F_AR_x5F_icon"
	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px"
	 viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<rect id="Bounding_Box" x="0" y="0" fill="none" width="24" height="24"/>
<g id="Art_layer">
	<path d="M3,4c0-0.55,0.45-1,1-1h2V1H4C2.35,1,1,2.35,1,4v2h2V4z"/>
	<path d="M20,3c0.55,0,1,0.45,1,1v2h2V4c0-1.65-1.35-3-3-3h-2v2H20z"/>
	<path d="M4,21c-0.55,0-1-0.45-1-1v-2H1v2c0,1.65,1.35,3,3,3h2v-2H4z"/>
	<path d="M20,21c0.55,0,1-0.45,1-1v-2h2v2c0,1.65-1.35,3-3,3h-2v-2H20z"/>
	<g>
		<path d="M18.25,7.6l-5.5-3.18c-0.46-0.27-1.04-0.27-1.5,0L5.75,7.6C5.29,7.87,5,8.36,5,8.9v6.35c0,0.54,0.29,1.03,0.75,1.3
			l5.5,3.18c0.46,0.27,1.04,0.27,1.5,0l5.5-3.18c0.46-0.27,0.75-0.76,0.75-1.3V8.9C19,8.36,18.71,7.87,18.25,7.6z M7,14.96v-4.62
			l4,2.32v4.61L7,14.96z M12,10.93L8,8.61l4-2.31l4,2.31L12,10.93z M13,17.27v-4.61l4-2.32v4.62L13,17.27z"/>
	</g>
</g>
</svg>`;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const vf=Rr`
<style>
:host {
  display: block;
  position: relative;
  contain: strict;
  width: 300px;
  height: 150px;
}

.container {
  position: relative;
  overflow: hidden;
}

.userInput {
  width: 100%;
  height: 100%;
  display: none;
  position: relative;
  outline-offset: -1px;
  outline-width: 1px;
}

canvas {
  position: absolute;
  display: none;
  pointer-events: none;
  /* NOTE(cdata): Chrome 76 and below apparently have a bug
   * that causes our canvas not to display pixels unless it is
   * on its own render layer
   * @see https://github.com/google/model-viewer/pull/755#issuecomment-536597893
   */
  transform: translateZ(0);
}

.show {
  display: block;
}

/* Adapted from HTML5 Boilerplate
 *
 * @see https://github.com/h5bp/html5-boilerplate/blob/ceb4620c78fc82e13534fc44202a3f168754873f/dist/css/main.css#L122-L133 */
.screen-reader-only {
  border: 0;
  left: 0;
  top: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
  pointer-events: none;
}

.slot {
  position: absolute;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.slot > * {
  pointer-events: initial;
}

.annotation-wrapper ::slotted(*) {
  opacity: var(--max-hotspot-opacity, 1);
  transition: opacity 0.3s;
}

.pointer-tumbling .annotation-wrapper ::slotted(*) {
  pointer-events: none;
}

.annotation-wrapper ::slotted(*) {
  pointer-events: initial;
}

.annotation-wrapper.hide ::slotted(*) {
  opacity: var(--min-hotspot-opacity, 0.25);
}

.slot.poster {
  display: none;
  background-color: inherit;
}

.slot.poster.show {
  display: inherit;
}

.slot.poster > * {
  pointer-events: initial;
}

.slot.poster:not(.show) > * {
  pointer-events: none;
}

#default-poster {
  width: 100%;
  height: 100%;
  /* The default poster is a <button> so we need to set display
   * to prevent it from being affected by text-align: */
  display: block;
  position: absolute;
  border: none;
  padding: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff0;
}

#default-progress-bar {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

#default-progress-bar > .bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--progress-bar-height, 5px);
  background-color: var(--progress-bar-color, rgba(0, 0, 0, 0.4));
  transition: transform 0.09s;
  transform-origin: top left;
  transform: scaleX(0);
  overflow: hidden;
}

#default-progress-bar > .bar.hide {
  transition: opacity 0.3s 1s;
  opacity: 0;
}

.centered {
  align-items: center;
  justify-content: center;
}

.cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.slot.interaction-prompt {
  display: var(--interaction-prompt-display, flex);
  overflow: hidden;
  opacity: 0;
  will-change: opacity;
  transition: opacity 0.3s;
}

.slot.interaction-prompt.visible {
  opacity: 1;
}

.animated-container {
  will-change: transform, opacity;
  opacity: 0;
  transition: opacity 0.3s;
}

.slot.interaction-prompt > * {
  pointer-events: none;
}

.slot.ar-button {
  -moz-user-select: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;

  display: var(--ar-button-display, block);
}

.slot.ar-button:not(.enabled) {
  display: none;
}

.fab {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  cursor: pointer;
  background-color: #fff;
  box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15);
  border-radius: 100px;
}

.fab > * {
  opacity: 0.87;
}

#default-ar-button {
  position: absolute;
  bottom: 16px;
  right: 16px;
  transform: scale(var(--ar-button-scale, 1));
  transform-origin: bottom right;
}

.slot.pan-target {
  display: block;
  position: absolute;
  width: 0;
  height: 0;
  left: 50%;
  top: 50%;
  transform: translate3d(-50%, -50%, 0);
  background-color: transparent;
  opacity: 0;
  transition: opacity 0.3s;
}

#default-pan-target {
  width: 6px;
  height: 6px;
  border-radius: 6px;
  border: 1px solid white;
  box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.8);
}

.slot.default {
  pointer-events: none;
}

.slot.progress-bar {
  pointer-events: none;
}

.slot.exit-webxr-ar-button {
  pointer-events: none;
}

.slot.exit-webxr-ar-button:not(.enabled) {
  display: none;
}

#default-exit-webxr-ar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  right: 16px;
  width: 40px;
  height: 40px;
  box-sizing: border-box;
}

#default-exit-webxr-ar-button > svg {
  fill: #fff;
}
</style>
<div class="container">
  <div class="userInput" tabindex="0" role="img"
      aria-label="3D model">
      <div class="slot canvas">
        <slot name="canvas">
          <canvas></canvas>
        </slot>
      </div>

  </div>

  <!-- NOTE(cdata): We need to wrap slots because browsers without ShadowDOM
        will have their <slot> elements removed by ShadyCSS -->
  <div class="slot poster">
    <slot name="poster">
      <button type="button" id="default-poster" aria-hidden="true" aria-label="Loading 3D model"></button>
    </slot>
  </div>

  <div class="slot ar-button">
    <slot name="ar-button">
      <a id="default-ar-button" part="default-ar-button" class="fab"
          tabindex="2"
          role="button"
          href="javascript:void(0);"
          aria-label="View in your space">
        ${xf}
      </a>
    </slot>
  </div>

  <div class="slot pan-target">
    <slot name="pan-target">
      <div id="default-pan-target">
      </div>
    </slot>
  </div>

  <div class="slot interaction-prompt cover centered">
    <div id="prompt" class="animated-container">
      <slot name="interaction-prompt" aria-hidden="true">
        ${wf}
      </slot>
    </div>
  </div>

  <div id="finger0" class="animated-container cover">
    <slot name="finger0" aria-hidden="true">
    </slot>
  </div>
  <div id="finger1" class="animated-container cover">
    <slot name="finger1" aria-hidden="true">
    </slot>
  </div>

  <div class="slot default">
    <slot></slot>

    <div class="slot progress-bar">
      <slot name="progress-bar">
        <div id="default-progress-bar" aria-hidden="true">
          <div class="bar" part="default-progress-bar"></div>
        </div>
      </slot>
    </div>

    <div class="slot exit-webxr-ar-button">
      <slot name="exit-webxr-ar-button">
        <a id="default-exit-webxr-ar-button" part="default-exit-webxr-ar-button"
            tabindex="3"
            aria-label="Exit AR"
            aria-hidden="true">
          ${yf}
        </a>
      </slot>
    </div>
  </div>
</div>
<div class="screen-reader-only" role="region" aria-label="Live announcements">
  <span id="status" role="status"></span>
</div>`,Qf=o=>{hu(vf,o)},jr=new WeakMap;class Sf extends Br{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,i){const n=new Lt(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,r=>{this.parse(r,t,i)},s,i)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,be).catch(s)}decodeDracoFile(e,t,s,i,n=ie,r=()=>{}){const a={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:n};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const s=JSON.stringify(t);if(jr.has(e)){const A=jr.get(e);if(A.key===s)return A.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const n=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(n,r).then(A=>(i=A,new Promise((c,l)=>{i._callbacks[n]={resolve:c,reject:l},i.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(A=>this._createGeometry(A.geometry));return a.catch(()=>!0).then(()=>{i&&n&&this._releaseTask(i,n)}),jr.set(e,{key:s,promise:a}),a}_createGeometry(e){const t=new Hi;e.index&&t.setIndex(new Se(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const i=e.attributes[s],n=i.name,r=i.array,a=i.itemSize,A=new Se(r,a);n==="color"&&(this._assignVertexColorSpace(A,i.vertexColorSpace),A.normalized=!(r instanceof Float32Array)),t.setAttribute(n,A)}return t}_assignVertexColorSpace(e,t){if(t!==be)return;const s=new Ke;for(let i=0,n=e.count;i<n;i++)s.fromBufferAttribute(e,i).convertSRGBToLinear(),e.setXYZ(i,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new Lt(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((i,n)=>{s.load(e,i,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(s=>{const i=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const n=bf.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(n){const r=n.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,n){return i._taskLoad>n._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function bf(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(l){o.onModuleLoaded=function(h){l({draco:h})},DracoDecoderModule(o)});break;case"decode":const A=a.buffer,c=a.taskConfig;e.then(l=>{const h=l.draco,u=new h.Decoder;try{const d=t(h,u,new Int8Array(A),c),g=d.attributes.map(p=>p.array.buffer);d.index&&g.push(d.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:d},g)}catch(d){console.error(d),self.postMessage({type:"error",id:a.id,error:d.message})}finally{h.destroy(u)}});break}};function t(r,a,A,c){const l=c.attributeIDs,h=c.attributeTypes;let u,d;const g=a.GetEncodedGeometryType(A);if(g===r.TRIANGULAR_MESH)u=new r.Mesh,d=a.DecodeArrayToMesh(A,A.byteLength,u);else if(g===r.POINT_CLOUD)u=new r.PointCloud,d=a.DecodeArrayToPointCloud(A,A.byteLength,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const p={index:null,attributes:[]};for(const f in l){const m=self[h[f]];let E,w;if(c.useUniqueIDs)w=l[f],E=a.GetAttributeByUniqueId(u,w);else{if(w=a.GetAttributeId(u,r[l[f]]),w===-1)continue;E=a.GetAttribute(u,w)}const I=i(r,a,u,f,m,E);f==="color"&&(I.vertexColorSpace=c.vertexColorSpace),p.attributes.push(I)}return g===r.TRIANGULAR_MESH&&(p.index=s(r,a,u)),r.destroy(u),p}function s(r,a,A){const l=A.num_faces()*3,h=l*4,u=r._malloc(h);a.GetTrianglesUInt32Array(A,h,u);const d=new Uint32Array(r.HEAPF32.buffer,u,l).slice();return r._free(u),{array:d,itemSize:1}}function i(r,a,A,c,l,h){const u=h.num_components(),g=A.num_points()*u,p=g*l.BYTES_PER_ELEMENT,f=n(r,l),m=r._malloc(p);a.GetAttributeDataArrayForAllPoints(A,h,f,p,m);const E=new l(r.HEAPF32.buffer,m,g).slice();return r._free(m),{name:c,array:E,itemSize:u}}function n(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}function JA(o,e){if(e===Vd)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===Sa||e===qh){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let A=0;A<a.count;A++)r.push(A);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const s=t.count-2,i=[];if(e===Sa)for(let r=1;r<=s;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const n=o.clone();return n.setIndex(i),n.clearGroups(),n}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Tf extends Br{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Lf(t)}),this.register(function(t){return new $f(t)}),this.register(function(t){return new Vf(t)}),this.register(function(t){return new qf(t)}),this.register(function(t){return new Nf(t)}),this.register(function(t){return new kf(t)}),this.register(function(t){return new Uf(t)}),this.register(function(t){return new Pf(t)}),this.register(function(t){return new Df(t)}),this.register(function(t){return new Gf(t)}),this.register(function(t){return new Ff(t)}),this.register(function(t){return new Hf(t)}),this.register(function(t){return new Of(t)}),this.register(function(t){return new Rf(t)}),this.register(function(t){return new zf(t)}),this.register(function(t){return new Kf(t)})}load(e,t,s,i){const n=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=Ni.extractUrlBase(e);r=Ni.resolveURL(c,this.path)}else r=Ni.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),n.manager.itemError(e),n.manager.itemEnd(e)},A=new Lt(this.manager);A.setPath(this.path),A.setResponseType("arraybuffer"),A.setRequestHeader(this.requestHeader),A.setWithCredentials(this.withCredentials),A.load(e,function(c){try{n.parse(c,r,function(l){t(l),n.manager.itemEnd(e)},a)}catch(l){a(l)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,i){let n;const r={},a={},A=new TextDecoder;if(typeof e=="string")n=JSON.parse(e);else if(e instanceof ArrayBuffer)if(A.decode(new Uint8Array(e,0,4))===mu){try{r[H.KHR_BINARY_GLTF]=new Yf(e)}catch(h){i&&i(h);return}n=JSON.parse(r[H.KHR_BINARY_GLTF].content)}else n=JSON.parse(A.decode(e));else n=e;if(n.asset===void 0||n.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new ap(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const h=this.pluginCallbacks[l](c);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,r[h.name]=!0}if(n.extensionsUsed)for(let l=0;l<n.extensionsUsed.length;++l){const h=n.extensionsUsed[l],u=n.extensionsRequired||[];switch(h){case H.KHR_MATERIALS_UNLIT:r[h]=new _f;break;case H.KHR_DRACO_MESH_COMPRESSION:r[h]=new Jf(n,this.dracoLoader);break;case H.KHR_TEXTURE_TRANSFORM:r[h]=new jf;break;case H.KHR_MESH_QUANTIZATION:r[h]=new Wf;break;default:u.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,i)}parseAsync(e,t){const s=this;return new Promise(function(i,n){s.parse(e,t,i,n)})}}function Mf(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const H={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Rf{constructor(e){this.parser=e,this.name=H.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s<i;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&n.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let i=t.cache.get(s);if(i)return i;const n=t.json,A=((n.extensions&&n.extensions[this.name]||{}).lights||[])[e];let c;const l=new Ke(16777215);A.color!==void 0&&l.setRGB(A.color[0],A.color[1],A.color[2],ie);const h=A.range!==void 0?A.range:0;switch(A.type){case"directional":c=new Kh(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new zh(l),c.distance=h;break;case"spot":c=new qd(l),c.distance=h,A.spot=A.spot||{},A.spot.innerConeAngle=A.spot.innerConeAngle!==void 0?A.spot.innerConeAngle:0,A.spot.outerConeAngle=A.spot.outerConeAngle!==void 0?A.spot.outerConeAngle:Math.PI/4,c.angle=A.spot.outerConeAngle,c.penumbra=1-A.spot.innerConeAngle/A.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+A.type)}return c.position.set(0,0,0),c.decay=2,Qt(c,A),A.intensity!==void 0&&(c.intensity=A.intensity),c.name=t.createUniqueName(A.name||"light_"+e),i=Promise.resolve(c),t.cache.add(s,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],a=(n.extensions&&n.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(A){return s._getNodeRef(t.cache,a,A)})}}let _f=class{constructor(){this.name=H.KHR_MATERIALS_UNLIT}getMaterialType(){return Xe}extendParams(e,t,s){const i=[];e.color=new Ke(1,1,1),e.opacity=1;const n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){const r=n.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],ie),e.opacity=r[3]}n.baseColorTexture!==void 0&&i.push(s.assignTexture(e,"map",n.baseColorTexture,be))}return Promise.all(i)}},Df=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return n!==void 0&&(t.emissiveIntensity=n),Promise.resolve()}},Lf=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&n.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&n.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(n.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ce(a,a)}return Promise.all(n)}},Ff=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&n.push(s.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&n.push(s.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(n)}},Nf=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[];t.sheenColor=new Ke(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],ie)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&n.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,be)),r.sheenRoughnessTexture!==void 0&&n.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(n)}},kf=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&n.push(s.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(n)}},Uf=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&n.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new Ke().setRGB(a[0],a[1],a[2],ie),Promise.all(n)}},Pf=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return t.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}},Gf=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&n.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new Ke().setRGB(a[0],a[1],a[2],ie),r.specularColorTexture!==void 0&&n.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,be)),Promise.all(n)}},Of=class{constructor(e){this.parser=e,this.name=H.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&n.push(s.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(n)}},Hf=class{constructor(e){this.parser=e,this.name=H.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:It}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&n.push(s.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(n)}};class $f{constructor(e){this.parser=e,this.name=H.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,i=s.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const n=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,r)}}class Vf{constructor(e){this.parser=e,this.name=H.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const r=n.extensions[t],a=i.images[r.source];let A=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(A=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,r.source,A);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class qf{constructor(e){this.parser=e,this.name=H.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const r=n.extensions[t],a=i.images[r.source];let A=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(A=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,r.source,A);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class zf{constructor(e){this.name=H.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const i=s.extensions[this.name],n=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(a){const A=i.byteOffset||0,c=i.byteLength||0,l=i.count,h=i.byteStride,u=new Uint8Array(a,A,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(l,h,u,i.mode,i.filter).then(function(d){return d.buffer}):r.ready.then(function(){const d=new ArrayBuffer(l*h);return r.decodeGltfBuffer(new Uint8Array(d),l,h,u,i.mode,i.filter),d})})}else return null}}let Kf=class{constructor(e){this.name=H.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const i=t.meshes[s.mesh];for(const c of i.primitives)if(c.mode!==Ue.TRIANGLES&&c.mode!==Ue.TRIANGLE_STRIP&&c.mode!==Ue.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],A={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(l=>(A[c]=l,A[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const l=c.pop(),h=l.isGroup?l.children:[l],u=c[0].count,d=[];for(const g of h){const p=new le,f=new R,m=new wr,E=new R(1,1,1),w=new zd(g.geometry,g.material,u);for(let I=0;I<u;I++)A.TRANSLATION&&f.fromBufferAttribute(A.TRANSLATION,I),A.ROTATION&&m.fromBufferAttribute(A.ROTATION,I),A.SCALE&&E.fromBufferAttribute(A.SCALE,I),w.setMatrixAt(I,p.compose(f,m,E));for(const I in A)if(I==="_COLOR_0"){const C=A[I];w.instanceColor=new Kd(C.array,C.itemSize,C.normalized)}else I!=="TRANSLATION"&&I!=="ROTATION"&&I!=="SCALE"&&g.geometry.setAttribute(I,A[I]);Xi.prototype.copy.call(w,g),this.parser.assignFinalMaterial(w),d.push(w)}return l.isGroup?(l.clear(),l.add(...d),l):d[0]}))}};const mu="glTF",ti=12,jA={JSON:1313821514,BIN:5130562};class Yf{constructor(e){this.name=H.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ti),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==mu)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ti,n=new DataView(e,ti);let r=0;for(;r<i;){const a=n.getUint32(r,!0);r+=4;const A=n.getUint32(r,!0);if(r+=4,A===jA.JSON){const c=new Uint8Array(e,ti+r,a);this.content=s.decode(c)}else if(A===jA.BIN){const c=ti+r;this.body=e.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Jf{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=H.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,i=this.dracoLoader,n=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},A={},c={};for(const l in r){const h=_a[l]||l.toLowerCase();a[h]=r[l]}for(const l in e.attributes){const h=_a[l]||l.toLowerCase();if(r[l]!==void 0){const u=s.accessors[e.attributes[l]],d=Os[u.componentType];c[h]=d.name,A[h]=u.normalized===!0}}return t.getDependency("bufferView",n).then(function(l){return new Promise(function(h,u){i.decodeDracoFile(l,function(d){for(const g in d.attributes){const p=d.attributes[g],f=A[g];f!==void 0&&(p.normalized=f)}h(d)},a,c,ie,u)})})}}class jf{constructor(){this.name=H.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Wf{constructor(){this.name=H.KHR_MESH_QUANTIZATION}}class Iu extends ag{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let r=0;r!==i;r++)t[r]=s[n+r];return t}interpolate_(e,t,s,i){const n=this.resultBuffer,r=this.sampleValues,a=this.valueSize,A=a*2,c=a*3,l=i-t,h=(s-t)/l,u=h*h,d=u*h,g=e*c,p=g-c,f=-2*d+3*u,m=d-u,E=1-f,w=m-u+h;for(let I=0;I!==a;I++){const C=r[p+I+a],x=r[p+I+A]*l,B=r[g+I+a],y=r[g+I]*l;n[I]=E*C+w*x+f*B+m*y}return n}}const Xf=new wr;class Zf extends Iu{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return Xf.fromArray(n).normalize().toArray(n),n}}const Ue={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Os={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WA={9728:js,9729:de,9984:xr,9985:vr,9986:Qr,9987:Js},XA={33071:Pe,33648:Sr,10497:Nt},Wr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},_a={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Bt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ep={CUBICSPLINE:void 0,LINEAR:nA,STEP:Jh},Xr={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function tp(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new Ar({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:qi})),o.DefaultMaterial}function qt(o,e,t){for(const s in t.extensions)o[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Qt(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function sp(o,e,t){let s=!1,i=!1,n=!1;for(let c=0,l=e.length;c<l;c++){const h=e[c];if(h.POSITION!==void 0&&(s=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(n=!0),s&&i&&n)break}if(!s&&!i&&!n)return Promise.resolve(o);const r=[],a=[],A=[];for(let c=0,l=e.length;c<l;c++){const h=e[c];if(s){const u=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):o.attributes.position;r.push(u)}if(i){const u=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):o.attributes.normal;a.push(u)}if(n){const u=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):o.attributes.color;A.push(u)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(A)]).then(function(c){const l=c[0],h=c[1],u=c[2];return s&&(o.morphAttributes.position=l),i&&(o.morphAttributes.normal=h),n&&(o.morphAttributes.color=u),o.morphTargetsRelative=!0,o})}function ip(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let s=0,i=t.length;s<i;s++)o.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function np(o){let e;const t=o.extensions&&o.extensions[H.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Zr(t.attributes):e=o.indices+":"+Zr(o.attributes)+":"+o.mode,o.targets!==void 0)for(let s=0,i=o.targets.length;s<i;s++)e+=":"+Zr(o.targets[s]);return e}function Zr(o){let e="";const t=Object.keys(o).sort();for(let s=0,i=t.length;s<i;s++)e+=t[s]+":"+o[t[s]]+";";return e}function Da(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function rp(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const op=new le;class ap{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Mf,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,i=!1,n=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,n=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||i&&n<98?this.textureLoader=new Yh(this.options.manager):this.textureLoader=new Yd(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Lt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,i=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:s,userData:{}};return qt(n,a,i),Qt(a,i),Promise.all(s._invokeAll(function(A){return A.afterRoot&&A.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let i=0,n=t.length;i<n;i++){const r=t[i].joints;for(let a=0,A=r.length;a<A;a++)e[r[a]].isBone=!0}for(let i=0,n=e.length;i<n;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const i=s.clone(),n=(r,a)=>{const A=this.associations.get(r);A!=null&&this.associations.set(a,A);for(const[c,l]of r.children.entries())n(l,a.children[c])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const i=e(t[s]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let i=0;i<t.length;i++){const n=e(t[i]);n&&s.push(n)}return s}getDependency(e,t){const s=e+":"+t;let i=this.cache.get(s);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(n){return n.loadNode&&n.loadNode(t)});break;case"mesh":i=this._invokeOne(function(n){return n.loadMesh&&n.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(n){return n.loadBufferView&&n.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(n){return n.loadMaterial&&n.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(n){return n.loadTexture&&n.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(n){return n.loadAnimation&&n.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(s,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(n,r){return s.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[H.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(n,r){s.load(Ni.resolveURL(t.uri,i.path),n,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const i=t.byteLength||0,n=t.byteOffset||0;return s.slice(n,n+i)})}loadAccessor(e){const t=this,s=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const r=Wr[i.type],a=Os[i.componentType],A=i.normalized===!0,c=new a(i.count*r);return Promise.resolve(new Se(c,r,A))}const n=[];return i.bufferView!==void 0?n.push(this.getDependency("bufferView",i.bufferView)):n.push(null),i.sparse!==void 0&&(n.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(n).then(function(r){const a=r[0],A=Wr[i.type],c=Os[i.componentType],l=c.BYTES_PER_ELEMENT,h=l*A,u=i.byteOffset||0,d=i.bufferView!==void 0?s.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let p,f;if(d&&d!==h){const m=Math.floor(u/d),E="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+m+":"+i.count;let w=t.cache.get(E);w||(p=new c(a,m*d,i.count*d/l),w=new Jd(p,d/l),t.cache.add(E,w)),f=new og(w,A,u%d/l,g)}else a===null?p=new c(i.count*A):p=new c(a,u,i.count*A),f=new Se(p,A,g);if(i.sparse!==void 0){const m=Wr.SCALAR,E=Os[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,I=i.sparse.values.byteOffset||0,C=new E(r[1],w,i.sparse.count*m),x=new c(r[2],I,i.sparse.count*A);a!==null&&(f=new Se(f.array.slice(),f.itemSize,f.normalized));for(let B=0,y=C.length;B<y;B++){const v=C[B];if(f.setX(v,x[B*A]),A>=2&&f.setY(v,x[B*A+1]),A>=3&&f.setZ(v,x[B*A+2]),A>=4&&f.setW(v,x[B*A+3]),A>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f})}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let a=this.textureLoader;if(r.uri){const A=s.manager.getHandler(r.uri);A!==null&&(a=A)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,s){const i=this,n=this.json,r=n.textures[e],a=n.images[t],A=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[A])return this.textureCache[A];const c=this.loadImageSource(t,s).then(function(l){l.flipY=!1,l.name=r.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const u=(n.samplers||{})[r.sampler]||{};return l.magFilter=WA[u.magFilter]||de,l.minFilter=WA[u.minFilter]||Js,l.wrapS=XA[u.wrapS]||Nt,l.wrapT=XA[u.wrapT]||Nt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[A]=c,c}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=i.images[e],a=self.URL||self.webkitURL;let A=r.uri||"",c=!1;if(r.bufferView!==void 0)A=s.getDependency("bufferView",r.bufferView).then(function(h){c=!0;const u=new Blob([h],{type:r.mimeType});return A=a.createObjectURL(u),A});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(A).then(function(h){return new Promise(function(u,d){let g=u;t.isImageBitmapLoader===!0&&(g=function(p){const f=new Ze(p);f.needsUpdate=!0,u(f)}),t.load(Ni.resolveURL(h,n.path),g,void 0,d)})}).then(function(h){return c===!0&&a.revokeObjectURL(A),h.userData.mimeType=r.mimeType||rp(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",A),h});return this.sourceCache[e]=l,l}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),n.extensions[H.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[H.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const A=n.associations.get(r);r=n.extensions[H.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),n.associations.set(r,A)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=t.attributes.tangent===void 0,n=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let A=this.cache.get(a);A||(A=new jd,zn.prototype.copy.call(A,s),A.color.copy(s.color),A.map=s.map,A.sizeAttenuation=!1,this.cache.add(a,A)),s=A}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let A=this.cache.get(a);A||(A=new Wd,zn.prototype.copy.call(A,s),A.color.copy(s.color),A.map=s.map,this.cache.add(a,A)),s=A}if(i||n||r){let a="ClonedMaterial:"+s.uuid+":";i&&(a+="derivative-tangents:"),n&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let A=this.cache.get(a);A||(A=s.clone(),n&&(A.vertexColors=!0),r&&(A.flatShading=!0),i&&(A.normalScale&&(A.normalScale.y*=-1),A.clearcoatNormalScale&&(A.clearcoatNormalScale.y*=-1)),this.cache.add(a,A),this.associations.set(A,this.associations.get(s))),s=A}e.material=s}getMaterialType(){return Ar}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let r;const a={},A=n.extensions||{},c=[];if(A[H.KHR_MATERIALS_UNLIT]){const h=i[H.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),c.push(h.extendParams(a,n,t))}else{const h=n.pbrMetallicRoughness||{};if(a.color=new Ke(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){const u=h.baseColorFactor;a.color.setRGB(u[0],u[1],u[2],ie),a.opacity=u[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",h.baseColorTexture,be)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(u){return u.getMaterialType&&u.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(u){return u.extendMaterialParams&&u.extendMaterialParams(e,a)})))}n.doubleSided===!0&&(a.side=kt);const l=n.alphaMode||Xr.OPAQUE;if(l===Xr.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===Xr.MASK&&(a.alphaTest=n.alphaCutoff!==void 0?n.alphaCutoff:.5)),n.normalTexture!==void 0&&r!==Xe&&(c.push(t.assignTexture(a,"normalMap",n.normalTexture)),a.normalScale=new ce(1,1),n.normalTexture.scale!==void 0)){const h=n.normalTexture.scale;a.normalScale.set(h,h)}if(n.occlusionTexture!==void 0&&r!==Xe&&(c.push(t.assignTexture(a,"aoMap",n.occlusionTexture)),n.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=n.occlusionTexture.strength)),n.emissiveFactor!==void 0&&r!==Xe){const h=n.emissiveFactor;a.emissive=new Ke().setRGB(h[0],h[1],h[2],ie)}return n.emissiveTexture!==void 0&&r!==Xe&&c.push(t.assignTexture(a,"emissiveMap",n.emissiveTexture,be)),Promise.all(c).then(function(){const h=new r(a);return n.name&&(h.name=n.name),Qt(h,n),t.associations.set(h,{materials:e}),n.extensions&&qt(i,h,n),h})}createUniqueName(e){const t=$i.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(a){return s[H.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(A){return ZA(A,a,t)})}const r=[];for(let a=0,A=e.length;a<A;a++){const c=e[a],l=np(c),h=i[l];if(h)r.push(h.promise);else{let u;c.extensions&&c.extensions[H.KHR_DRACO_MESH_COMPRESSION]?u=n(c):u=ZA(new Hi,c,t),i[l]={primitive:c,promise:u},r.push(u)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,i=this.extensions,n=s.meshes[e],r=n.primitives,a=[];for(let A=0,c=r.length;A<c;A++){const l=r[A].material===void 0?tp(this.cache):this.getDependency("material",r[A].material);a.push(l)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(A){const c=A.slice(0,A.length-1),l=A[A.length-1],h=[];for(let d=0,g=l.length;d<g;d++){const p=l[d],f=r[d];let m;const E=c[d];if(f.mode===Ue.TRIANGLES||f.mode===Ue.TRIANGLE_STRIP||f.mode===Ue.TRIANGLE_FAN||f.mode===void 0)m=n.isSkinnedMesh===!0?new Xd(p,E):new ge(p,E),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),f.mode===Ue.TRIANGLE_STRIP?m.geometry=JA(m.geometry,qh):f.mode===Ue.TRIANGLE_FAN&&(m.geometry=JA(m.geometry,Sa));else if(f.mode===Ue.LINES)m=new Zd(p,E);else if(f.mode===Ue.LINE_STRIP)m=new eg(p,E);else if(f.mode===Ue.LINE_LOOP)m=new tg(p,E);else if(f.mode===Ue.POINTS)m=new sg(p,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);Object.keys(m.geometry.morphAttributes).length>0&&ip(m,n),m.name=t.createUniqueName(n.name||"mesh_"+e),Qt(m,n),f.extensions&&qt(i,m,f),t.assignFinalMaterial(m),h.push(m)}for(let d=0,g=h.length;d<g;d++)t.associations.set(h[d],{meshes:e,primitives:d});if(h.length===1)return n.extensions&&qt(i,h[0],n),h[0];const u=new Kn;n.extensions&&qt(i,u,n),t.associations.set(u,{meshes:e});for(let d=0,g=h.length;d<g;d++)u.add(h[d]);return u})}loadCamera(e){let t;const s=this.json.cameras[e],i=s[s.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new Vi(cr.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):s.type==="orthographic"&&(t=new yr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Qt(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let i=0,n=t.joints.length;i<n;i++)s.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(i){const n=i.pop(),r=i,a=[],A=[];for(let c=0,l=r.length;c<l;c++){const h=r[c];if(h){a.push(h);const u=new le;n!==null&&u.fromArray(n.array,c*16),A.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new ig(a,A)})}loadAnimation(e){const t=this.json,s=this,i=t.animations[e],n=i.name?i.name:"animation_"+e,r=[],a=[],A=[],c=[],l=[];for(let h=0,u=i.channels.length;h<u;h++){const d=i.channels[h],g=i.samplers[d.sampler],p=d.target,f=p.node,m=i.parameters!==void 0?i.parameters[g.input]:g.input,E=i.parameters!==void 0?i.parameters[g.output]:g.output;p.node!==void 0&&(r.push(this.getDependency("node",f)),a.push(this.getDependency("accessor",m)),A.push(this.getDependency("accessor",E)),c.push(g),l.push(p))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(A),Promise.all(c),Promise.all(l)]).then(function(h){const u=h[0],d=h[1],g=h[2],p=h[3],f=h[4],m=[];for(let E=0,w=u.length;E<w;E++){const I=u[E],C=d[E],x=g[E],B=p[E],y=f[E];if(I===void 0)continue;I.updateMatrix&&I.updateMatrix();const v=s._createAnimationTracks(I,C,x,B,y);if(v)for(let Q=0;Q<v.length;Q++)m.push(v[Q])}return new ng(n,void 0,m)})}createNodeMesh(e){const t=this.json,s=this,i=t.nodes[e];return i.mesh===void 0?null:s.getDependency("mesh",i.mesh).then(function(n){const r=s._getNodeRef(s.meshCache,i.mesh,n);return i.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let A=0,c=i.weights.length;A<c;A++)a.morphTargetInfluences[A]=i.weights[A]}),r})}loadNode(e){const t=this.json,s=this,i=t.nodes[e],n=s._loadNodeShallow(e),r=[],a=i.children||[];for(let c=0,l=a.length;c<l;c++)r.push(s.getDependency("node",a[c]));const A=i.skin===void 0?Promise.resolve(null):s.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),A]).then(function(c){const l=c[0],h=c[1],u=c[2];u!==null&&l.traverse(function(d){d.isSkinnedMesh&&d.bind(u,op)});for(let d=0,g=h.length;d<g;d++)l.add(h[d]);return l})}_loadNodeShallow(e){const t=this.json,s=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const n=t.nodes[e],r=n.name?i.createUniqueName(n.name):"",a=[],A=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return A&&a.push(A),n.camera!==void 0&&a.push(i.getDependency("camera",n.camera).then(function(c){return i._getNodeRef(i.cameraCache,n.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(n.isBone===!0?l=new rg:c.length>1?l=new Kn:c.length===1?l=c[0]:l=new Xi,l!==c[0])for(let h=0,u=c.length;h<u;h++)l.add(c[h]);if(n.name&&(l.userData.name=n.name,l.name=r),Qt(l,n),n.extensions&&qt(s,l,n),n.matrix!==void 0){const h=new le;h.fromArray(n.matrix),l.applyMatrix4(h)}else n.translation!==void 0&&l.position.fromArray(n.translation),n.rotation!==void 0&&l.quaternion.fromArray(n.rotation),n.scale!==void 0&&l.scale.fromArray(n.scale);return i.associations.has(l)||i.associations.set(l,{}),i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],i=this,n=new Kn;s.name&&(n.name=i.createUniqueName(s.name)),Qt(n,s),s.extensions&&qt(t,n,s);const r=s.nodes||[],a=[];for(let A=0,c=r.length;A<c;A++)a.push(i.getDependency("node",r[A]));return Promise.all(a).then(function(A){for(let l=0,h=A.length;l<h;l++)n.add(A[l]);const c=l=>{const h=new Map;for(const[u,d]of i.associations)(u instanceof zn||u instanceof Ze)&&h.set(u,d);return l.traverse(u=>{const d=i.associations.get(u);d!=null&&h.set(u,d)}),h};return i.associations=c(n),n})}_createAnimationTracks(e,t,s,i,n){const r=[],a=e.name?e.name:e.uuid,A=[];Bt[n.path]===Bt.weights?e.traverse(function(u){u.morphTargetInfluences&&A.push(u.name?u.name:u.uuid)}):A.push(a);let c;switch(Bt[n.path]){case Bt.weights:c=bA;break;case Bt.rotation:c=TA;break;case Bt.position:case Bt.scale:c=SA;break;default:switch(s.itemSize){case 1:c=bA;break;case 2:case 3:default:c=SA;break}break}const l=i.interpolation!==void 0?ep[i.interpolation]:nA,h=this._getArrayFromAccessor(s);for(let u=0,d=A.length;u<d;u++){const g=new c(A[u]+"."+Bt[n.path],t.array,h,l);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),r.push(g)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=Da(t.constructor),i=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=t[n]*s;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const i=this instanceof TA?Zf:Iu;return new i(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ap(o,e,t){const s=e.attributes,i=new Ae;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],A=a.min,c=a.max;if(A!==void 0&&c!==void 0){if(i.set(new R(A[0],A[1],A[2]),new R(c[0],c[1],c[2])),a.normalized){const l=Da(Os[a.componentType]);i.min.multiplyScalar(l),i.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const n=e.targets;if(n!==void 0){const a=new R,A=new R;for(let c=0,l=n.length;c<l;c++){const h=n[c];if(h.POSITION!==void 0){const u=t.json.accessors[h.POSITION],d=u.min,g=u.max;if(d!==void 0&&g!==void 0){if(A.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),A.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),A.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),u.normalized){const p=Da(Os[u.componentType]);A.multiplyScalar(p)}a.max(A)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new br;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function ZA(o,e,t){const s=e.attributes,i=[];function n(r,a){return t.getDependency("accessor",r).then(function(A){o.setAttribute(a,A)})}for(const r in s){const a=_a[r]||r.toLowerCase();a in o.attributes||i.push(n(s[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});i.push(r)}return QA.workingColorSpace!==ie&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${QA.workingColorSpace}" not supported.`),Qt(o,e),Ap(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?sp(o,e.targets,t):o})}class cp{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const s=this.workersResolve[e];if(s&&s(t),this.queue.length){const{resolve:i,msg:n,transfer:r}=this.queue.shift();this.workersResolve[e]=i,this.workers[e].postMessage(n,r)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(s=>{const i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=s,this.workers[i].postMessage(e,t)):this.queue.push({resolve:s,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const lp=0,ec=2,hp=1,tc=2,up=0,dp=1,gp=10,fp=0,Eu=9,Cu=15,Bu=16,yu=22,wu=37,xu=43,vu=76,Qu=83,Su=97,bu=100,Tu=103,Mu=109,Ru=165,_u=166;class pp{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class si{constructor(e,t,s,i){this._dataView=new DataView(e.buffer,e.byteOffset+t,s),this._littleEndian=i,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const s=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==t&&i<e;)i++,this._offset++;return i<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+s,i)}}const Ee=[171,75,84,88,32,50,48,187,13,10,26,10];function sc(o){return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function mp(o){const e=new Uint8Array(o.buffer,o.byteOffset,Ee.length);if(e[0]!==Ee[0]||e[1]!==Ee[1]||e[2]!==Ee[2]||e[3]!==Ee[3]||e[4]!==Ee[4]||e[5]!==Ee[5]||e[6]!==Ee[6]||e[7]!==Ee[7]||e[8]!==Ee[8]||e[9]!==Ee[9]||e[10]!==Ee[10]||e[11]!==Ee[11])throw new Error("Missing KTX 2.0 identifier.");const t=new pp,s=17*Uint32Array.BYTES_PER_ELEMENT,i=new si(o,Ee.length,s,!0);t.vkFormat=i._nextUint32(),t.typeSize=i._nextUint32(),t.pixelWidth=i._nextUint32(),t.pixelHeight=i._nextUint32(),t.pixelDepth=i._nextUint32(),t.layerCount=i._nextUint32(),t.faceCount=i._nextUint32();const n=i._nextUint32();t.supercompressionScheme=i._nextUint32();const r=i._nextUint32(),a=i._nextUint32(),A=i._nextUint32(),c=i._nextUint32(),l=i._nextUint64(),h=i._nextUint64(),u=new si(o,Ee.length+s,3*n*8,!0);for(let N=0;N<n;N++)t.levels.push({levelData:new Uint8Array(o.buffer,o.byteOffset+u._nextUint64(),u._nextUint64()),uncompressedByteLength:u._nextUint64()});const d=new si(o,r,a,!0),g={vendorId:d._skip(4)._nextUint16(),descriptorType:d._nextUint16(),versionNumber:d._nextUint16(),descriptorBlockSize:d._nextUint16(),colorModel:d._nextUint8(),colorPrimaries:d._nextUint8(),transferFunction:d._nextUint8(),flags:d._nextUint8(),texelBlockDimension:[d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8()],bytesPlane:[d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8()],samples:[]},p=(g.descriptorBlockSize/4-6)/4;for(let N=0;N<p;N++){const P={bitOffset:d._nextUint16(),bitLength:d._nextUint8(),channelType:d._nextUint8(),samplePosition:[d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&P.channelType?(P.sampleLower=d._nextInt32(),P.sampleUpper=d._nextInt32()):(P.sampleLower=d._nextUint32(),P.sampleUpper=d._nextUint32()),g.samples[N]=P}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(g);const f=new si(o,A,c,!0);for(;f._offset<c;){const N=f._nextUint32(),P=f._scan(N),$=sc(P),V=f._scan(N-P.byteLength);t.keyValue[$]=$.match(/^ktx/i)?sc(V):V,f._offset%4&&f._skip(4-f._offset%4)}if(h<=0)return t;const m=new si(o,l,h,!0),E=m._nextUint16(),w=m._nextUint16(),I=m._nextUint32(),C=m._nextUint32(),x=m._nextUint32(),B=m._nextUint32(),y=[];for(let N=0;N<n;N++)y.push({imageFlags:m._nextUint32(),rgbSliceByteOffset:m._nextUint32(),rgbSliceByteLength:m._nextUint32(),alphaSliceByteOffset:m._nextUint32(),alphaSliceByteLength:m._nextUint32()});const v=l+m._offset,Q=v+I,b=Q+C,S=b+x,M=new Uint8Array(o.buffer,o.byteOffset+v,I),T=new Uint8Array(o.buffer,o.byteOffset+Q,C),_=new Uint8Array(o.buffer,o.byteOffset+b,x),L=new Uint8Array(o.buffer,o.byteOffset+S,B);return t.globalData={endpointCount:E,selectorCount:w,imageDescs:y,endpointsData:M,selectorsData:T,tablesData:_,extendedData:L},t}let eo,dt,La;const to={env:{emscripten_notify_memory_growth:function(o){La=new Uint8Array(dt.exports.memory.buffer)}}};class Ip{init(){return eo||(eo=typeof fetch<"u"?fetch("data:application/wasm;base64,"+ic).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,to)).then(this._init):WebAssembly.instantiate(Buffer.from(ic,"base64"),to).then(this._init),eo)}_init(e){dt=e.instance,to.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!dt)throw new Error("ZSTDDecoder: Await .init() before decoding.");const s=e.byteLength,i=dt.exports.malloc(s);La.set(e,i),t=t||Number(dt.exports.ZSTD_findDecompressedSize(i,s));const n=dt.exports.malloc(t),r=dt.exports.ZSTD_decompress(n,t,i,s),a=La.slice(n,n+r);return dt.exports.free(i),dt.exports.free(n),a}}const ic=" ",so=new WeakMap;let io=0,no;class et extends Br{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new cp,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new Lt(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),s=new Lt(this.manager);s.setPath(this.transcoderPath),s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials);const i=s.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,i]).then(([n,r])=>{const a=et.BasisWorker.toString(),A=["/* constants */","let _EngineFormat = "+JSON.stringify(et.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(et.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(et.BasisFormat),"/* basis_transcoder.js */",n,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([A])),this.transcoderBinary=r,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),l=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:l},[l]),c})}),io>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),io++}return this.transcoderPending}load(e,t,s,i){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const n=new Lt(this.manager);n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials),n.load(e,r=>{if(so.has(r))return so.get(r).promise.then(t).catch(i);this._createTexture(r).then(a=>t?t(a):null).catch(i)},s,i)}_createTextureFrom(e,t){const{faces:s,width:i,height:n,format:r,type:a,error:A,dfdFlags:c}=e;if(a==="error")return Promise.reject(A);let l;if(t.faceCount===6)l=new Ag(s,r,ve);else{const h=s[0].mipmaps;l=t.layerCount>1?new cg(h,i,n,t.layerCount,r,ve):new ki(h,i,n,r,ve)}return l.minFilter=s[0].mipmaps.length===1?de:Js,l.magFilter=de,l.generateMipmaps=!1,l.needsUpdate=!0,l.colorSpace=Du(t),l.premultiplyAlpha=!!(c&hp),l}async _createTexture(e,t={}){const s=mp(new Uint8Array(e));if(s.vkFormat!==fp)return Cp(s);const i=t,n=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:i},[e])).then(r=>this._createTextureFrom(r.data,s));return so.set(e,{promise:n}),n}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),io--,this}}et.BasisFormat={ETC1S:0,UASTC_4x4:1};et.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};et.EngineFormat={RGBAFormat:_e,RGBA_ASTC_4x4_Format:lg,RGBA_BPTC_Format:hg,RGBA_ETC2_EAC_Format:ug,RGBA_PVRTC_4BPPV1_Format:dg,RGBA_S3TC_DXT5_Format:gg,RGB_ETC1_Format:fg,RGB_ETC2_Format:pg,RGB_PVRTC_4BPPV1_Format:mg,RGB_S3TC_DXT1_Format:Ig};et.BasisWorker=function(){let o,e,t;const s=_EngineFormat,i=_TranscoderFormat,n=_BasisFormat;self.addEventListener("message",function(g){const p=g.data;switch(p.type){case"init":o=p.config,r(p.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:f,buffers:m,width:E,height:w,hasAlpha:I,format:C,dfdFlags:x}=a(p.buffer);self.postMessage({type:"transcode",id:p.id,faces:f,width:E,height:w,hasAlpha:I,format:C,dfdFlags:x},m)}catch(f){console.error(f),self.postMessage({type:"error",id:p.id,error:f.message})}});break}});function r(g){e=new Promise(p=>{t={wasmBinary:g,onRuntimeInitialized:p},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(g){const p=new t.KTX2File(new Uint8Array(g));function f(){p.close(),p.delete()}if(!p.isValid())throw f(),new Error("THREE.KTX2Loader:	Invalid or unsupported .ktx2 file");const m=p.isUASTC()?n.UASTC_4x4:n.ETC1S,E=p.getWidth(),w=p.getHeight(),I=p.getLayers()||1,C=p.getLevels(),x=p.getFaces(),B=p.getHasAlpha(),y=p.getDFDFlags(),{transcoderFormat:v,engineFormat:Q}=h(m,E,w,B);if(!E||!w||!C)throw f(),new Error("THREE.KTX2Loader:	Invalid texture");if(!p.startTranscoding())throw f(),new Error("THREE.KTX2Loader: .startTranscoding failed");const b=[],S=[];for(let M=0;M<x;M++){const T=[];for(let _=0;_<C;_++){const L=[];let N,P;for(let V=0;V<I;V++){const Y=p.getImageLevelInfo(_,V,M);M===0&&_===0&&V===0&&(Y.origWidth%4!==0||Y.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),C>1?(N=Y.origWidth,P=Y.origHeight):(N=Y.width,P=Y.height);const te=new Uint8Array(p.getImageTranscodedSizeInBytes(_,V,0,v));if(!p.transcodeImage(te,_,V,M,v,0,-1,-1))throw f(),new Error("THREE.KTX2Loader: .transcodeImage failed.");L.push(te)}const $=d(L);T.push({data:$,width:N,height:P}),S.push($.buffer)}b.push({mipmaps:T,width:E,height:w,format:Q})}return f(),{faces:b,buffers:S,width:E,height:w,hasAlpha:B,format:Q,dfdFlags:y}}const A=[{if:"astcSupported",basisFormat:[n.UASTC_4x4],transcoderFormat:[i.ASTC_4x4,i.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:[i.BC7_M5,i.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:[i.BC1,i.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:[i.ETC1,i.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:[i.ETC1],engineFormat:[s.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[i.PVRTC1_4_RGB,i.PVRTC1_4_RGBA],engineFormat:[s.RGB_PVRTC_4BPPV1_Format,s.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],c=A.sort(function(g,p){return g.priorityETC1S-p.priorityETC1S}),l=A.sort(function(g,p){return g.priorityUASTC-p.priorityUASTC});function h(g,p,f,m){let E,w;const I=g===n.ETC1S?c:l;for(let C=0;C<I.length;C++){const x=I[C];if(o[x.if]&&x.basisFormat.includes(g)&&!(m&&x.transcoderFormat.length<2)&&!(x.needsPowerOfTwo&&!(u(p)&&u(f))))return E=x.transcoderFormat[m?1:0],w=x.engineFormat[m?1:0],{transcoderFormat:E,engineFormat:w}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),E=i.RGBA32,w=s.RGBAFormat,{transcoderFormat:E,engineFormat:w}}function u(g){return g<=2?!0:(g&g-1)===0&&g!==0}function d(g){if(g.length===1)return g[0];let p=0;for(let E=0;E<g.length;E++){const w=g[E];p+=w.byteLength}const f=new Uint8Array(p);let m=0;for(let E=0;E<g.length;E++){const w=g[E];f.set(w,m),m+=w.byteLength}return f}};const Ep=new Set([_e,Qi,Si]),ro={[Mu]:_e,[Su]:_e,[wu]:_e,[xu]:_e,[Tu]:Qi,[Qu]:Qi,[Bu]:Qi,[yu]:Qi,[bu]:Si,[vu]:Si,[Cu]:Si,[Eu]:Si,[_u]:MA,[Ru]:MA},oo={[Mu]:it,[Su]:De,[wu]:ve,[xu]:ve,[Tu]:it,[Qu]:De,[Bu]:ve,[yu]:ve,[bu]:it,[vu]:De,[Cu]:ve,[Eu]:ve,[_u]:ve,[Ru]:ve};async function Cp(o){const{vkFormat:e}=o;if(ro[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;o.supercompressionScheme===ec&&(no||(no=new Promise(async n=>{const r=new Ip;await r.init(),n(r)})),t=await no);const s=[];for(let n=0;n<o.levels.length;n++){const r=Math.max(1,o.pixelWidth>>n),a=Math.max(1,o.pixelHeight>>n),A=o.pixelDepth?Math.max(1,o.pixelDepth>>n):0,c=o.levels[n];let l;if(o.supercompressionScheme===lp)l=c.levelData;else if(o.supercompressionScheme===ec)l=t.decode(c.levelData,c.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let h;oo[e]===it?h=new Float32Array(l.buffer,l.byteOffset,l.byteLength/Float32Array.BYTES_PER_ELEMENT):oo[e]===De?h=new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT):h=l,s.push({data:h,width:r,height:a,depth:A})}let i;if(Ep.has(ro[e]))i=o.pixelDepth===0?new jh(s[0].data,o.pixelWidth,o.pixelHeight):new Eg(s[0].data,o.pixelWidth,o.pixelHeight,o.pixelDepth);else{if(o.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");i=new ki(s,o.pixelWidth,o.pixelHeight)}return i.mipmaps=s,i.type=oo[e],i.format=ro[e],i.colorSpace=Du(o),i.needsUpdate=!0,Promise.resolve(i)}function Du(o){const e=o.dataFormatDescriptor[0];return e.colorPrimaries===dp?e.transferFunction===tc?be:ie:e.colorPrimaries===gp?e.transferFunction===tc?Cg:Bg:e.colorPrimaries===up?lr:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),lr)}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var nc,rc;const qe=Symbol("retainerCount"),ot=Symbol("recentlyUsed"),rn=Symbol("evict"),ii=Symbol("evictionThreshold"),ao=Symbol("cache");class Bp{constructor(e,t=5){this[nc]=new Map,this[rc]=[],this[ao]=e,this[ii]=t}set evictionThreshold(e){this[ii]=e,this[rn]()}get evictionThreshold(){return this[ii]}get cache(){return this[ao]}retainerCount(e){return this[qe].get(e)||0}reset(){this[qe].clear(),this[ot]=[]}retain(e){this[qe].has(e)||this[qe].set(e,0),this[qe].set(e,this[qe].get(e)+1);const t=this[ot].indexOf(e);t!==-1&&this[ot].splice(t,1),this[ot].unshift(e),this[rn]()}release(e){this[qe].has(e)&&this[qe].set(e,Math.max(this[qe].get(e)-1,0)),this[rn]()}[(nc=qe,rc=ot,rn)](){if(!(this[ot].length<this[ii]))for(let e=this[ot].length-1;e>=this[ii];--e){const t=this[ot][e];this[qe].get(t)===0&&(this[ao].delete(t),this[ot].splice(e,1))}}}/* @license
 * Copyright 2021 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const yp=o=>{const e=[],t=new Set;for(const s of o){let i=s,n=0;for(;t.has(i);)i=s+"."+ ++n;t.add(i),e.push(i)}return e},wp=o=>{const e=new Map;for(const t of o.mappings)for(const s of t.variants)e.set(s,{material:null,gltfMaterialIndex:t.material});return e};class xp{constructor(e){this.parser=e,this.name="KHR_materials_variants"}afterRoot(e){const t=this.parser,s=t.json;if(s.extensions===void 0||s.extensions[this.name]===void 0)return null;const n=s.extensions[this.name].variants||[],r=yp(n.map(a=>a.name));for(const a of e.scenes)a.traverse(A=>{const c=A;if(!c.material)return;const l=t.associations.get(c);if(l==null||l.meshes==null||l.primitives==null)return;const g=s.meshes[l.meshes].primitives[l.primitives].extensions;!g||!g[this.name]||(c.userData.variantMaterials=wp(g[this.name]))});return e.userData.variants=r,Promise.resolve()}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Lu,oc;Ze.DEFAULT_ANISOTROPY=4;const vp=(o,e,t=()=>{})=>{const s=i=>{const n=i.loaded/i.total;t(Math.max(0,Math.min(1,isFinite(n)?n:1)))};return new Promise((i,n)=>{e.load(o,i,s,n)})},Qp=o=>new Promise((e,t)=>{const s=document.createElement("script");document.body.appendChild(s),s.onload=e,s.onerror=t,s.async=!0,s.src=o}),at=new Map,Ao=new Map;let ac;const Ac=new Sf;let cc;const co=new et;let lo,ho;const Jt=Symbol("loader"),St=Symbol("evictionPolicy"),lc=Symbol("GLTFInstance");class re extends Tr{constructor(e){super(),this[oc]=new Tf().register(t=>new xp(t)),this[lc]=e,this[Jt].setDRACOLoader(Ac),this[Jt].setKTX2Loader(co)}static setDRACODecoderLocation(e){ac=e,Ac.setDecoderPath(e)}static getDRACODecoderLocation(){return ac}static setKTX2TranscoderLocation(e){cc=e,co.setTranscoderPath(e)}static getKTX2TranscoderLocation(){return cc}static setMeshoptDecoderLocation(e){lo!==e&&(lo=e,ho=Qp(e).then(()=>MeshoptDecoder.ready).then(()=>MeshoptDecoder))}static getMeshoptDecoderLocation(){return lo}static initializeKTX2Loader(e){co.detectSupport(e)}static get cache(){return at}static clearCache(){at.forEach((e,t)=>{this.delete(t)}),this[St].reset()}static has(e){return at.has(e)}static async delete(e){if(!this.has(e))return;const t=at.get(e);Ao.delete(e),at.delete(e),(await t).dispose()}static hasFinishedLoading(e){return!!Ao.get(e)}get[(Lu=St,oc=Jt,St)](){return this.constructor[St]}async preload(e,t,s=()=>{}){if(this[Jt].setWithCredentials(re.withCredentials),this.dispatchEvent({type:"preload",element:t,src:e}),!at.has(e)){ho!=null&&this[Jt].setMeshoptDecoder(await ho);const i=vp(e,this[Jt],a=>{s(a*.8)}),n=this[lc],r=i.then(a=>n.prepare(a)).then(a=>(s(.9),new n(a))).catch(a=>(console.error(a),new n));at.set(e,r)}await at.get(e),Ao.set(e,!0),s&&s(1)}async load(e,t,s=()=>{}){await this.preload(e,t,s);const n=await(await at.get(e)).clone();return this[St].retain(e),n.dispose=()=>{this[St].release(e)},n}}re[Lu]=new Bp(re);class Sp extends Xi{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new ce(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof Element&&t.element.parentNode!==null&&t.element.parentNode.removeChild(t.element)})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const As=new R,hc=new le,uc=new le,dc=new R,gc=new R;class bp{constructor(e={}){const t=this;let s,i,n,r;const a={objects:new WeakMap},A=e.element!==void 0?e.element:document.createElement("div");A.style.overflow="hidden",this.domElement=A,this.getSize=function(){return{width:s,height:i}},this.render=function(d,g){d.matrixWorldAutoUpdate===!0&&d.updateMatrixWorld(),g.parent===null&&g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),hc.copy(g.matrixWorldInverse),uc.multiplyMatrices(g.projectionMatrix,hc),c(d,d,g),u(d)},this.setSize=function(d,g){s=d,i=g,n=s/2,r=i/2,A.style.width=d+"px",A.style.height=g+"px"};function c(d,g,p){if(d.isCSS2DObject){As.setFromMatrixPosition(d.matrixWorld),As.applyMatrix4(uc);const f=d.visible===!0&&As.z>=-1&&As.z<=1&&d.layers.test(p.layers)===!0;if(d.element.style.display=f===!0?"":"none",f===!0){d.onBeforeRender(t,g,p);const E=d.element;E.style.transform="translate("+-100*d.center.x+"%,"+-100*d.center.y+"%)translate("+(As.x*n+n)+"px,"+(-As.y*r+r)+"px)",E.parentNode!==A&&A.appendChild(E),d.onAfterRender(t,g,p)}const m={distanceToCameraSquared:l(p,d)};a.objects.set(d,m)}for(let f=0,m=d.children.length;f<m;f++)c(d.children[f],g,p)}function l(d,g){return dc.setFromMatrixPosition(d.matrixWorld),gc.setFromMatrixPosition(g.matrixWorld),dc.distanceToSquared(gc)}function h(d){const g=[];return d.traverse(function(p){p.isCSS2DObject&&g.push(p)}),g}function u(d){const g=h(d).sort(function(f,m){if(f.renderOrder!==m.renderOrder)return m.renderOrder-f.renderOrder;const E=a.objects.get(f).distanceToCameraSquared,w=a.objects.get(m).distanceToCameraSquared;return E-w}),p=g.length;for(let f=0,m=g.length;f<m;f++)g[f].element.style.zIndex=p-f}}}function on(o,e,t){let s=t;const i=new R;return o.updateWorldMatrix(!0,!0),o.traverseVisible(n=>{const{geometry:r}=n;if(r!==void 0){const{position:a}=r.attributes;if(a!==void 0)for(let A=0,c=a.count;A<c;A++)n.isMesh?n.getVertexPosition(A,i):i.fromBufferAttribute(a,A),n.isSkinnedMesh||i.applyMatrix4(n.matrixWorld),s=e(s,i)}}),s}let ni,uo,cs,an;function Wn(o,e=1/0,t=null){uo||(uo=new Ws(2,2,1,1)),cs||(cs=new $s({uniforms:{blitTexture:new yg(o)},vertexShader:`
			varying vec2 vUv;
			void main(){
				vUv = uv;
				gl_Position = vec4(position.xy * 1.0,0.,.999999);
			}`,fragmentShader:`
			uniform sampler2D blitTexture; 
			varying vec2 vUv;

			void main(){ 
				gl_FragColor = vec4(vUv.xy, 0, 1);
				
				#ifdef IS_SRGB
				gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );
				#else
				gl_FragColor = texture2D( blitTexture, vUv);
				#endif
			}`})),cs.uniforms.blitTexture.value=o,cs.defines.IS_SRGB=o.colorSpace==be,cs.needsUpdate=!0,an||(an=new ge(uo,cs),an.frustrumCulled=!1);const s=new Vi,i=new Ut;i.add(an),t===null&&(t=ni=new rA({antialias:!1}));const n=Math.min(o.image.width,e),r=Math.min(o.image.height,e);t.setSize(n,r),t.clear(),t.render(i,s);const a=document.createElement("canvas"),A=a.getContext("2d");a.width=n,a.height=r,A.drawImage(t.domElement,0,0,n,r);const c=new Wh(a);return c.minFilter=o.minFilter,c.magFilter=o.magFilter,c.wrapS=o.wrapS,c.wrapT=o.wrapT,c.name=o.name,ni&&(ni.forceContextLoss(),ni.dispose(),ni=null),c}const fc={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class AA{constructor(){this.pluginCallbacks=[],this.register(function(e){return new Up(e)}),this.register(function(e){return new Pp(e)}),this.register(function(e){return new Hp(e)}),this.register(function(e){return new $p(e)}),this.register(function(e){return new Vp(e)}),this.register(function(e){return new qp(e)}),this.register(function(e){return new Gp(e)}),this.register(function(e){return new Op(e)}),this.register(function(e){return new zp(e)}),this.register(function(e){return new Kp(e)}),this.register(function(e){return new Yp(e)}),this.register(function(e){return new Jp(e)}),this.register(function(e){return new jp(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,i){const n=new kp,r=[];for(let a=0,A=this.pluginCallbacks.length;a<A;a++)r.push(this.pluginCallbacks[a](n));n.setPlugins(r),n.write(e,t,i).catch(s)}parseAsync(e,t){const s=this;return new Promise(function(i,n){s.parse(e,i,n,t)})}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},go="KHR_mesh_quantization",Le={};Le[js]=O.NEAREST;Le[xr]=O.NEAREST_MIPMAP_NEAREST;Le[Qr]=O.NEAREST_MIPMAP_LINEAR;Le[de]=O.LINEAR;Le[vr]=O.LINEAR_MIPMAP_NEAREST;Le[Js]=O.LINEAR_MIPMAP_LINEAR;Le[Pe]=O.CLAMP_TO_EDGE;Le[Nt]=O.REPEAT;Le[Sr]=O.MIRRORED_REPEAT;const pc={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Tp=new Ke,mc=12,Mp=1179937895,Rp=2,Ic=8,_p=1313821514,Dp=5130562;function Mi(o,e){return o.length===e.length&&o.every(function(t,s){return t===e[s]})}function Lp(o){return new TextEncoder().encode(o).buffer}function Fp(o){return Mi(o.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Np(o,e,t){const s={min:new Array(o.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(o.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+t;i++)for(let n=0;n<o.itemSize;n++){let r;o.itemSize>4?r=o.array[i*o.itemSize+n]:(n===0?r=o.getX(i):n===1?r=o.getY(i):n===2?r=o.getZ(i):n===3&&(r=o.getW(i)),o.normalized===!0&&(r=cr.normalize(r,o.array))),s.min[n]=Math.min(s.min[n],r),s.max[n]=Math.max(s.max[n],r)}return s}function Fu(o){return Math.ceil(o/4)*4}function fo(o,e=0){const t=Fu(o.byteLength);if(t!==o.byteLength){const s=new Uint8Array(t);if(s.set(new Uint8Array(o)),e!==0)for(let i=o.byteLength;i<t;i++)s[i]=e;return s.buffer}return o}function Ec(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Cc(o,e){if(o.toBlob!==void 0)return new Promise(s=>o.toBlob(s,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),o.convertToBlob({type:e,quality:t})}class kp{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,s={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},s),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,n=i.buffers,r=i.json;s=i.options;const a=i.extensionsUsed,A=i.extensionsRequired,c=new Blob(n,{type:"application/octet-stream"}),l=Object.keys(a),h=Object.keys(A);if(l.length>0&&(r.extensionsUsed=l),h.length>0&&(r.extensionsRequired=h),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=c.size),s.binary===!0){const u=new FileReader;u.readAsArrayBuffer(c),u.onloadend=function(){const d=fo(u.result),g=new DataView(new ArrayBuffer(Ic));g.setUint32(0,d.byteLength,!0),g.setUint32(4,Dp,!0);const p=fo(Lp(JSON.stringify(r)),32),f=new DataView(new ArrayBuffer(Ic));f.setUint32(0,p.byteLength,!0),f.setUint32(4,_p,!0);const m=new ArrayBuffer(mc),E=new DataView(m);E.setUint32(0,Mp,!0),E.setUint32(4,Rp,!0);const w=mc+f.byteLength+p.byteLength+g.byteLength+d.byteLength;E.setUint32(8,w,!0);const I=new Blob([m,f,p,g,d],{type:"application/octet-stream"}),C=new FileReader;C.readAsArrayBuffer(I),C.onloadend=function(){t(C.result)}}}else if(r.buffers&&r.buffers.length>0){const u=new FileReader;u.readAsDataURL(c),u.onloadend=function(){const d=u.result;r.buffers[0].uri=d,t(r)}}else t(r)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const s=this.options,i=this.extensionsUsed;try{const n=JSON.parse(JSON.stringify(e.userData));if(s.includeCustomExtensions&&n.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const r in n.gltfExtensions)t.extensions[r]=n.gltfExtensions[r],i[r]=!0;delete n.gltfExtensions}Object.keys(n).length>0&&(t.extras=n)}catch(n){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+n.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(e,i)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const s=new R;for(let i=0,n=e.count;i<n;i++)if(Math.abs(s.fromBufferAttribute(e,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const s=e.clone(),i=new R;for(let n=0,r=s.count;n<r;n++)i.fromBufferAttribute(s,n),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),s.setXYZ(n,i.x,i.y,i.z);return t.attributesNormalized.set(e,s),s}applyTextureTransform(e,t){let s=!1;const i={};(t.offset.x!==0||t.offset.y!==0)&&(i.offset=t.offset.toArray(),s=!0),t.rotation!==0&&(i.rotation=t.rotation,s=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(i.scale=t.repeat.toArray(),s=!0),s&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function s(d){return d.colorSpace===be?function(p){return p<.04045?p*.0773993808:Math.pow(p*.9478672986+.0521327014,2.4)}:function(p){return p}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof ki&&(e=Wn(e)),t instanceof ki&&(t=Wn(t));const i=e?e.image:null,n=t?t.image:null,r=Math.max(i?i.width:0,n?n.width:0),a=Math.max(i?i.height:0,n?n.height:0),A=Ec();A.width=r,A.height=a;const c=A.getContext("2d");c.fillStyle="#00ffff",c.fillRect(0,0,r,a);const l=c.getImageData(0,0,r,a);if(i){c.drawImage(i,0,0,r,a);const d=s(e),g=c.getImageData(0,0,r,a).data;for(let p=2;p<g.length;p+=4)l.data[p]=d(g[p]/256)*256}if(n){c.drawImage(n,0,0,r,a);const d=s(t),g=c.getImageData(0,0,r,a).data;for(let p=1;p<g.length;p+=4)l.data[p]=d(g[p]/256)*256}c.putImageData(l,0,0);const u=(e||t).clone();return u.source=new wg(A),u.colorSpace=lr,u.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),u}processBuffer(e){const t=this.json,s=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),s.push(e),0}processBufferView(e,t,s,i,n){const r=this.json;r.bufferViews||(r.bufferViews=[]);let a;switch(t){case O.BYTE:case O.UNSIGNED_BYTE:a=1;break;case O.SHORT:case O.UNSIGNED_SHORT:a=2;break;default:a=4}const A=Fu(i*e.itemSize*a),c=new DataView(new ArrayBuffer(A));let l=0;for(let d=s;d<s+i;d++)for(let g=0;g<e.itemSize;g++){let p;e.itemSize>4?p=e.array[d*e.itemSize+g]:(g===0?p=e.getX(d):g===1?p=e.getY(d):g===2?p=e.getZ(d):g===3&&(p=e.getW(d)),e.normalized===!0&&(p=cr.normalize(p,e.array))),t===O.FLOAT?c.setFloat32(l,p,!0):t===O.INT?c.setInt32(l,p,!0):t===O.UNSIGNED_INT?c.setUint32(l,p,!0):t===O.SHORT?c.setInt16(l,p,!0):t===O.UNSIGNED_SHORT?c.setUint16(l,p,!0):t===O.BYTE?c.setInt8(l,p):t===O.UNSIGNED_BYTE&&c.setUint8(l,p),l+=a}const h={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:A};return n!==void 0&&(h.target=n),n===O.ARRAY_BUFFER&&(h.byteStride=e.itemSize*a),this.byteOffset+=A,r.bufferViews.push(h),{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,s=t.json;return s.bufferViews||(s.bufferViews=[]),new Promise(function(i){const n=new FileReader;n.readAsArrayBuffer(e),n.onloadend=function(){const r=fo(n.result),a={buffer:t.processBuffer(r),byteOffset:t.byteOffset,byteLength:r.byteLength};t.byteOffset+=r.byteLength,i(s.bufferViews.push(a)-1)}})}processAccessor(e,t,s,i){const n=this.json,r={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=O.FLOAT;else if(e.array.constructor===Int32Array)a=O.INT;else if(e.array.constructor===Uint32Array)a=O.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=O.SHORT;else if(e.array.constructor===Uint16Array)a=O.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=O.BYTE;else if(e.array.constructor===Uint8Array)a=O.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(s===void 0&&(s=0),(i===void 0||i===1/0)&&(i=e.count),i===0)return null;const A=Np(e,s,i);let c;t!==void 0&&(c=e===t.index?O.ELEMENT_ARRAY_BUFFER:O.ARRAY_BUFFER);const l=this.processBufferView(e,a,s,i,c),h={bufferView:l.id,byteOffset:l.byteOffset,componentType:a,count:i,max:A.max,min:A.min,type:r[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),n.accessors||(n.accessors=[]),n.accessors.push(h)-1}processImage(e,t,s,i="image/png"){if(e!==null){const n=this,r=n.cache,a=n.json,A=n.options,c=n.pending;r.images.has(e)||r.images.set(e,{});const l=r.images.get(e),h=i+":flipY/"+s.toString();if(l[h]!==void 0)return l[h];a.images||(a.images=[]);const u={mimeType:i},d=Ec();d.width=Math.min(e.width,A.maxTextureSize),d.height=Math.min(e.height,A.maxTextureSize);const g=d.getContext("2d");if(s===!0&&(g.translate(0,d.height),g.scale(1,-1)),e.data!==void 0){t!==_e&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>A.maxTextureSize||e.height>A.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const f=new Uint8ClampedArray(e.height*e.width*4);for(let m=0;m<f.length;m+=4)f[m+0]=e.data[m+0],f[m+1]=e.data[m+1],f[m+2]=e.data[m+2],f[m+3]=e.data[m+3];g.putImageData(new ImageData(f,e.width,e.height),0,0)}else g.drawImage(e,0,0,d.width,d.height);A.binary===!0?c.push(Cc(d,i).then(f=>n.processBufferViewImage(f)).then(f=>{u.bufferView=f})):d.toDataURL!==void 0?u.uri=d.toDataURL(i):c.push(Cc(d,i).then(f=>new FileReader().readAsDataURL(f)).then(f=>{u.uri=f}));const p=a.images.push(u)-1;return l[h]=p,p}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const s={magFilter:Le[e.magFilter],minFilter:Le[e.minFilter],wrapS:Le[e.wrapS],wrapT:Le[e.wrapT]};return t.samplers.push(s)-1}processTexture(e){const s=this.options,i=this.cache,n=this.json;if(i.textures.has(e))return i.textures.get(e);n.textures||(n.textures=[]),e instanceof ki&&(e=Wn(e,s.maxTextureSize));let r=e.userData.mimeType;r==="image/webp"&&(r="image/png");const a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(a.name=e.name),this._invokeAll(function(c){c.writeTexture&&c.writeTexture(e,a)});const A=n.textures.push(a)-1;return i.textures.set(e,A),A}processMaterial(e){const t=this.cache,s=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;s.materials||(s.materials=[]);const i={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const n=e.color.toArray().concat([e.opacity]);if(Mi(n,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=n),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),A={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(A,a),i.pbrMetallicRoughness.metallicRoughnessTexture=A}if(e.map){const a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const c={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(c,e.emissiveMap),i.emissiveTexture=c}}if(e.normalMap){const a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),i.occlusionTexture=a}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===kt&&(i.doubleSided=!0),e.name!==""&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,i)});const r=s.materials.push(i)-1;return t.materials.set(e,r),r}processMesh(e){const t=this.cache,s=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let I=0,C=e.material.length;I<C;I++)i.push(e.material[I].uuid);else i.push(e.material.uuid);const n=i.join(":");if(t.meshes.has(n))return t.meshes.get(n);const r=e.geometry;let a;e.isLineSegments?a=O.LINES:e.isLineLoop?a=O.LINE_LOOP:e.isLine?a=O.LINE_STRIP:e.isPoints?a=O.POINTS:a=e.material.wireframe?O.LINES:O.TRIANGLES;const A={},c={},l=[],h=[],u={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=r.getAttribute("normal");d!==void 0&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),r.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let g=null;for(let I in r.attributes){if(I.slice(0,5)==="morph")continue;const C=r.attributes[I];if(I=u[I]||I.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(I)||(I="_"+I),t.attributes.has(this.getUID(C))){c[I]=t.attributes.get(this.getUID(C));continue}g=null;const B=C.array;I==="JOINTS_0"&&!(B instanceof Uint16Array)&&!(B instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),g=new Se(new Uint16Array(B),C.itemSize,C.normalized));const y=this.processAccessor(g||C,r);y!==null&&(I.startsWith("_")||this.detectMeshQuantization(I,C),c[I]=y,t.attributes.set(this.getUID(C),y))}if(d!==void 0&&r.setAttribute("normal",d),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const I=[],C=[],x={};if(e.morphTargetDictionary!==void 0)for(const B in e.morphTargetDictionary)x[e.morphTargetDictionary[B]]=B;for(let B=0;B<e.morphTargetInfluences.length;++B){const y={};let v=!1;for(const Q in r.morphAttributes){if(Q!=="position"&&Q!=="normal"){v||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),v=!0);continue}const b=r.morphAttributes[Q][B],S=Q.toUpperCase(),M=r.attributes[Q];if(t.attributes.has(this.getUID(b,!0))){y[S]=t.attributes.get(this.getUID(b,!0));continue}const T=b.clone();if(!r.morphTargetsRelative)for(let _=0,L=b.count;_<L;_++)for(let N=0;N<b.itemSize;N++)N===0&&T.setX(_,b.getX(_)-M.getX(_)),N===1&&T.setY(_,b.getY(_)-M.getY(_)),N===2&&T.setZ(_,b.getZ(_)-M.getZ(_)),N===3&&T.setW(_,b.getW(_)-M.getW(_));y[S]=this.processAccessor(T,r),t.attributes.set(this.getUID(M,!0),y[S])}h.push(y),I.push(e.morphTargetInfluences[B]),e.morphTargetDictionary!==void 0&&C.push(x[B])}A.weights=I,C.length>0&&(A.extras={},A.extras.targetNames=C)}const p=Array.isArray(e.material);if(p&&r.groups.length===0)return null;let f=!1;if(p&&r.index===null){const I=[];for(let C=0,x=r.attributes.position.count;C<x;C++)I[C]=C;r.setIndex(I),f=!0}const m=p?e.material:[e.material],E=p?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let I=0,C=E.length;I<C;I++){const x={mode:a,attributes:c};if(this.serializeUserData(r,x),h.length>0&&(x.targets=h),r.index!==null){let y=this.getUID(r.index);(E[I].start!==void 0||E[I].count!==void 0)&&(y+=":"+E[I].start+":"+E[I].count),t.attributes.has(y)?x.indices=t.attributes.get(y):(x.indices=this.processAccessor(r.index,r,E[I].start,E[I].count),t.attributes.set(y,x.indices)),x.indices===null&&delete x.indices}const B=this.processMaterial(m[E[I].materialIndex]);B!==null&&(x.material=B),l.push(x)}f===!0&&r.setIndex(null),A.primitives=l,s.meshes||(s.meshes=[]),this._invokeAll(function(I){I.writeMesh&&I.writeMesh(e,A)});const w=s.meshes.push(A)-1;return t.meshes.set(n,w),w}detectMeshQuantization(e,t){if(this.extensionsUsed[go])return;let s;switch(t.array.constructor){case Int8Array:s="byte";break;case Uint8Array:s="unsigned byte";break;case Int16Array:s="short";break;case Uint16Array:s="unsigned short";break;default:return}t.normalized&&(s+=" normalized");const i=e.split("_",1)[0];fc[i]&&fc[i].includes(s)&&(this.extensionsUsed[go]=!0,this.extensionsRequired[go]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const s=e.isOrthographicCamera,i={type:s?"orthographic":"perspective"};return s?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:cr.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const s=this.json,i=this.nodeMap;s.animations||(s.animations=[]),e=AA.Utils.mergeMorphTargetTracks(e.clone(),t);const n=e.tracks,r=[],a=[];for(let A=0;A<n.length;++A){const c=n[A],l=$i.parseTrackName(c.name);let h=$i.findNode(t,l.nodeName);const u=pc[l.propertyName];if(l.objectName==="bones"&&(h.isSkinnedMesh===!0?h=h.skeleton.getBoneByName(l.objectIndex):h=void 0),!h||!u)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',c.name),null;const d=1;let g=c.values.length/c.times.length;u===pc.morphTargetInfluences&&(g/=h.morphTargetInfluences.length);let p;c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(p="CUBICSPLINE",g/=3):c.getInterpolation()===Jh?p="STEP":p="LINEAR",a.push({input:this.processAccessor(new Se(c.times,d)),output:this.processAccessor(new Se(c.values,g)),interpolation:p}),r.push({sampler:a.length-1,target:{node:i.get(h),path:u}})}return s.animations.push({name:e.name||"clip_"+s.animations.length,samplers:a,channels:r}),s.animations.length-1}processSkin(e){const t=this.json,s=this.nodeMap,i=t.nodes[s.get(e)],n=e.skeleton;if(n===void 0)return null;const r=e.skeleton.bones[0];if(r===void 0)return null;const a=[],A=new Float32Array(n.bones.length*16),c=new le;for(let h=0;h<n.bones.length;++h)a.push(s.get(n.bones[h])),c.copy(n.boneInverses[h]),c.multiply(e.bindMatrix).toArray(A,h*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Se(A,16)),joints:a,skeleton:s.get(r)}),i.skin=t.skins.length-1}processNode(e){const t=this.json,s=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const n={};if(s.trs){const a=e.quaternion.toArray(),A=e.position.toArray(),c=e.scale.toArray();Mi(a,[0,0,0,1])||(n.rotation=a),Mi(A,[0,0,0])||(n.translation=A),Mi(c,[1,1,1])||(n.scale=c)}else e.matrixAutoUpdate&&e.updateMatrix(),Fp(e.matrix)===!1&&(n.matrix=e.matrix.elements);if(e.name!==""&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(n.mesh=a)}else e.isCamera&&(n.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let A=0,c=e.children.length;A<c;A++){const l=e.children[A];if(l.visible||s.onlyVisible===!1){const h=this.processNode(l);h!==null&&a.push(h)}}a.length>0&&(n.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,n)});const r=t.nodes.push(n)-1;return i.set(e,r),r}processScene(e){const t=this.json,s=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};e.name!==""&&(i.name=e.name),t.scenes.push(i);const n=[];for(let r=0,a=e.children.length;r<a;r++){const A=e.children[r];if(A.visible||s.onlyVisible===!1){const c=this.processNode(A);c!==null&&n.push(c)}}n.length>0&&(i.nodes=n),this.serializeUserData(e,i)}processObjects(e){const t=new Ut;t.name="AuxScene";for(let s=0;s<e.length;s++)t.children.push(e[s]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(i){i.beforeParse&&i.beforeParse(e)});const s=[];for(let i=0;i<e.length;i++)e[i]instanceof Ut?this.processScene(e[i]):s.push(e[i]);s.length>0&&this.processObjects(s);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);for(let i=0;i<t.animations.length;++i)this.processAnimation(t.animations[i],e[0]);this._invokeAll(function(i){i.afterParse&&i.afterParse(e)})}_invokeAll(e){for(let t=0,s=this.plugins.length;t<s;t++)e(this.plugins[t])}}class Up{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const s=this.writer,i=s.json,n=s.extensionsUsed,r={};e.name&&(r.name=e.name),r.color=e.color.toArray(),r.intensity=e.intensity,e.isDirectionalLight?r.type="directional":e.isPointLight?(r.type="point",e.distance>0&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",e.distance>0&&(r.range=e.distance),r.spot={},r.spot.innerConeAngle=(1-e.penumbra)*e.angle,r.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),n[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},n[this.name]=!0);const a=i.extensions[this.name].lights;a.push(r),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class Pp{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class Gp{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.clearcoatFactor=e.clearcoat,e.clearcoatMap){const r={index:s.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};s.applyTextureTransform(r,e.clearcoatMap),n.clearcoatTexture=r}if(n.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const r={index:s.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};s.applyTextureTransform(r,e.clearcoatRoughnessMap),n.clearcoatRoughnessTexture=r}if(e.clearcoatNormalMap){const r={index:s.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};s.applyTextureTransform(r,e.clearcoatNormalMap),n.clearcoatNormalTexture=r}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Op{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.iridescenceFactor=e.iridescence,e.iridescenceMap){const r={index:s.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};s.applyTextureTransform(r,e.iridescenceMap),n.iridescenceTexture=r}if(n.iridescenceIor=e.iridescenceIOR,n.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],n.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const r={index:s.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};s.applyTextureTransform(r,e.iridescenceThicknessMap),n.iridescenceThicknessTexture=r}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Hp{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.transmissionFactor=e.transmission,e.transmissionMap){const r={index:s.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};s.applyTextureTransform(r,e.transmissionMap),n.transmissionTexture=r}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class $p{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const s=this.writer,i=s.extensionsUsed,n={};if(n.thicknessFactor=e.thickness,e.thicknessMap){const r={index:s.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};s.applyTextureTransform(r,e.thicknessMap),n.thicknessTexture=r}n.attenuationDistance=e.attenuationDistance,n.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Vp{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const i=this.writer.extensionsUsed,n={};n.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class qp{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(Tp)&&!e.specularIntensityMap&&!e.specularColorMap)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.specularIntensityMap){const r={index:s.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};s.applyTextureTransform(r,e.specularIntensityMap),n.specularTexture=r}if(e.specularColorMap){const r={index:s.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};s.applyTextureTransform(r,e.specularColorMap),n.specularColorTexture=r}n.specularFactor=e.specularIntensity,n.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class zp{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.sheenRoughnessMap){const r={index:s.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};s.applyTextureTransform(r,e.sheenRoughnessMap),n.sheenRoughnessTexture=r}if(e.sheenColorMap){const r={index:s.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};s.applyTextureTransform(r,e.sheenColorMap),n.sheenColorTexture=r}n.sheenRoughnessFactor=e.sheenRoughness,n.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Kp{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.anisotropyMap){const r={index:s.processTexture(e.anisotropyMap)};s.applyTextureTransform(r,e.anisotropyMap),n.anisotropyTexture=r}n.anisotropyStrength=e.anisotropy,n.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Yp{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const i=this.writer.extensionsUsed,n={};n.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class Jp{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const s=this.writer,i=s.extensionsUsed,n={};if(e.bumpMap){const r={index:s.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};s.applyTextureTransform(r,e.bumpMap),n.bumpTexture=r}n.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class jp{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const s=this.writer,i=e,n=new Float32Array(i.count*3),r=new Float32Array(i.count*4),a=new Float32Array(i.count*3),A=new le,c=new R,l=new wr,h=new R;for(let d=0;d<i.count;d++)i.getMatrixAt(d,A),A.decompose(c,l,h),c.toArray(n,d*3),l.toArray(r,d*4),h.toArray(a,d*3);const u={TRANSLATION:s.processAccessor(new Se(n,3)),ROTATION:s.processAccessor(new Se(r,4)),SCALE:s.processAccessor(new Se(a,3))};i.instanceColor&&(u._COLOR_0=s.processAccessor(i.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:u},s.extensionsUsed[this.name]=!0,s.extensionsRequired[this.name]=!0}}AA.Utils={insertKeyframe:function(o,e){const s=o.getValueSize(),i=new o.TimeBufferType(o.times.length+1),n=new o.ValueBufferType(o.values.length+s),r=o.createInterpolant(new o.ValueBufferType(s));let a;if(o.times.length===0){i[0]=e;for(let A=0;A<s;A++)n[A]=0;a=0}else if(e<o.times[0]){if(Math.abs(o.times[0]-e)<.001)return 0;i[0]=e,i.set(o.times,1),n.set(r.evaluate(e),0),n.set(o.values,s),a=0}else if(e>o.times[o.times.length-1]){if(Math.abs(o.times[o.times.length-1]-e)<.001)return o.times.length-1;i[i.length-1]=e,i.set(o.times,0),n.set(o.values,0),n.set(r.evaluate(e),o.values.length),a=i.length-1}else for(let A=0;A<o.times.length;A++){if(Math.abs(o.times[A]-e)<.001)return A;if(o.times[A]<e&&o.times[A+1]>e){i.set(o.times.slice(0,A+1),0),i[A+1]=e,i.set(o.times.slice(A+1),A+2),n.set(o.values.slice(0,(A+1)*s),0),n.set(r.evaluate(e),(A+1)*s),n.set(o.values.slice((A+1)*s),(A+2)*s),a=A+1;break}}return o.times=i,o.values=n,a},mergeMorphTargetTracks:function(o,e){const t=[],s={},i=o.tracks;for(let n=0;n<i.length;++n){let r=i[n];const a=$i.parseTrackName(r.name),A=$i.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),r=r.clone(),r.setInterpolation(nA)}const c=A.morphTargetInfluences.length,l=A.morphTargetDictionary[a.propertyIndex];if(l===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let h;if(s[A.uuid]===void 0){h=r.clone();const d=new h.ValueBufferType(c*h.times.length);for(let g=0;g<h.times.length;g++)d[g*c+l]=h.values[g];h.name=(a.nodeName||"")+".morphTargetInfluences",h.values=d,s[A.uuid]=h,t.push(h);continue}const u=r.createInterpolant(new r.ValueBufferType(1));h=s[A.uuid];for(let d=0;d<h.times.length;d++)h.values[d*c+l]=u.evaluate(h.times[d]);for(let d=0;d<r.times.length;d++){const g=this.insertKeyframe(h,r.times[d]);h.values[g*c+l]=r.values[d]}}return o.tracks=t,o}};/* @license
 * Copyright 2021 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Bc=o=>o.material!==void 0&&o.userData&&o.userData.variantMaterials&&!!Array.from(o.userData.variantMaterials.values()).filter(e=>Xn(e.material)),Xn=o=>o&&o.isMaterial&&!Array.isArray(o);class Wp{constructor(e){this.writer=e,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(e){const t=new Set;for(const s of e)s.traverse(i=>{if(!Bc(i))return;const n=i.userData.variantMaterials,r=i.userData.variantData;for(const[a,A]of r){const c=n.get(A.index);c&&Xn(c.material)&&t.add(a)}});t.forEach(s=>this.variantNames.push(s))}writeMesh(e,t){if(!Bc(e))return;const s=e.userData,i=s.variantMaterials,n=s.variantData,r=new Map,a=new Map,A=Array.from(n.values()).sort((h,u)=>h.index-u.index);for(const[h,u]of A.entries())a.set(u.index,h);for(const h of n.values()){const u=i.get(h.index);if(!u||!Xn(u.material))continue;const d=this.writer.processMaterial(u.material);r.has(d)||r.set(d,{material:d,variants:[]}),r.get(d).variants.push(a.get(h.index))}const c=Array.from(r.values()).map(h=>h.variants.sort((u,d)=>u-d)&&h).sort((h,u)=>h.material-u.material);if(c.length===0)return;const l=Xn(s.originalMaterial)?this.writer.processMaterial(s.originalMaterial):-1;for(const h of t.primitives)l>=0&&(h.material=l),h.extensions=h.extensions||{},h.extensions[this.name]={mappings:c}}afterParse(){if(this.variantNames.length===0)return;const e=this.writer.json;e.extensions=e.extensions||{};const t=this.variantNames.map(s=>({name:s}));e.extensions[this.name]={variants:t},this.writer.extensionsUsed[this.name]=!0}}class Xp{constructor(e,t,s,i,n){this.xrLight=e,this.renderer=t,this.lightProbe=s,this.xrWebGLBinding=null,this.estimationStartCallback=n,this.frameCallback=this.onXRFrame.bind(this);const r=t.xr.getSession();if(i&&"XRWebGLBinding"in window){const a=new Xh(16);e.environment=a.texture;const A=t.getContext();switch(r.preferredReflectionFormat){case"srgba8":A.getExtension("EXT_sRGB");break;case"rgba16f":A.getExtension("OES_texture_half_float");break}this.xrWebGLBinding=new XRWebGLBinding(r,A),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}r.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const i=t.getLightEstimate(this.lightProbe);if(i){this.xrLight.lightProbe.sh.fromArray(i.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const n=Math.max(1,Math.max(i.primaryLightIntensity.x,Math.max(i.primaryLightIntensity.y,i.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(i.primaryLightIntensity.x/n,i.primaryLightIntensity.y/n,i.primaryLightIntensity.z/n),this.xrLight.directionalLight.intensity=n,this.xrLight.directionalLight.position.copy(i.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class Zp extends Kn{constructor(e,t=!0){super(),this.lightProbe=new xg,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new Kh,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let s=null,i=!1;e.xr.addEventListener("sessionstart",()=>{const n=e.xr.getSession();"requestLightProbe"in n&&n.requestLightProbe({reflectionFormat:n.preferredReflectionFormat}).then(r=>{s=new Xp(this,e,r,t,()=>{i=!0,this.dispatchEvent({type:"estimationstart"})})})}),e.xr.addEventListener("sessionend",()=>{s&&(s.dispose(),s=null),i&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{s&&(s.dispose(),s=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Nu=1e4,em=.001,ku=50;class Re{constructor(e=ku){this.velocity=0,this.naturalFrequency=0,this.setDecayTime(e)}setDecayTime(e){this.naturalFrequency=1/Math.max(em,e)}update(e,t,s,i){const n=2e-4*this.naturalFrequency;if(e==null||i===0||e===t&&this.velocity===0)return t;if(s<0)return e;const r=e-t,a=this.velocity+this.naturalFrequency*r,A=r+s*a,c=Math.exp(-this.naturalFrequency*s),l=(a-this.naturalFrequency*A)*c,h=-this.naturalFrequency*(l+a*c);return Math.abs(l)<n*Math.abs(i)&&h*r>=0?(this.velocity=0,t):(this.velocity=l,t+A*c)}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ns=.2,yc=.03,tm=.75,Uu=12,sm=Math.PI/(2*Uu),wc=new ce,An=(o,e,t)=>{let s=e>0?t>0?0:-Math.PI/2:t>0?Math.PI/2:Math.PI;for(let i=0;i<=Uu;++i)o.push(e+(Ns-yc)*Math.cos(s),t+(Ns-yc)*Math.sin(s),0,e+Ns*Math.cos(s),t+Ns*Math.sin(s),0),s+=sm};class xc extends ge{constructor(e,t){const s=new Hi,i=[],n=[],{size:r,boundingBox:a}=e,A=r.x/2,c=(t==="back"?r.y:r.z)/2;An(n,A,c),An(n,-A,c),An(n,-A,-c),An(n,A,-c);const l=n.length/3;for(let d=0;d<l-2;d+=2)i.push(d,d+1,d+3,d,d+3,d+2);const h=l-2;i.push(h,h+1,1,h,1,0),s.setAttribute("position",new vg(n,3)),s.setIndex(i),super(s),this.side=t;const u=this.material;switch(u.side=kt,u.transparent=!0,u.opacity=0,this.goalOpacity=0,this.opacityDamper=new Re,this.hitPlane=new ge(new Ws(2*(A+Ns),2*(c+Ns))),this.hitPlane.visible=!1,this.hitPlane.material.side=kt,this.add(this.hitPlane),a.getCenter(this.position),t){case"bottom":this.rotateX(-Math.PI/2),this.shadowHeight=a.min.y,this.position.y=this.shadowHeight;break;case"back":this.shadowHeight=a.min.z,this.position.z=this.shadowHeight}e.target.add(this),this.offsetHeight=0}getHit(e,t,s){wc.set(t,-s),this.hitPlane.visible=!0;const i=e.positionAndNormalFromPoint(wc,this.hitPlane);return this.hitPlane.visible=!1,i==null?null:i.position}getExpandedHit(e,t,s){this.hitPlane.scale.set(1e3,1e3,1e3),this.hitPlane.updateMatrixWorld();const i=this.getHit(e,t,s);return this.hitPlane.scale.set(1,1,1),i}set offsetHeight(e){e-=.001,this.side==="back"?this.position.z=this.shadowHeight+e:this.position.y=this.shadowHeight+e}get offsetHeight(){return this.side==="back"?this.position.z-this.shadowHeight:this.position.y-this.shadowHeight}set show(e){this.goalOpacity=e?tm:0}updateOpacity(e){const t=this.material;t.opacity=this.opacityDamper.update(t.opacity,this.goalOpacity,e,1),this.visible=t.opacity>0}dispose(){var e;const{geometry:t,material:s}=this.hitPlane;t.dispose(),s.dispose(),this.geometry.dispose(),this.material.dispose(),(e=this.parent)===null||e===void 0||e.remove(this)}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ie=(o,e)=>({type:"number",number:o,unit:e}),ft=(()=>{const o={};return t=>{const s=t;if(s in o)return o[s];const i=[];let n=0;for(;t;){if(++n>1e3){t="";break}const r=Pu(t),a=r.nodes[0];if(a==null||a.terms.length===0)break;i.push(a),t=r.remainingInput}return o[s]=i}})(),Pu=(()=>{const o=/^(\-\-|[a-z\u0240-\uffff])/i,e=/^([\*\+\/]|[\-]\s)/i,t=/^[\),]/,s="(",i="#";return n=>{const r=[];for(;n.length&&(n=n.trim(),!t.test(n));)if(n[0]===s){const{nodes:a,remainingInput:A}=vc(n);n=A,r.push({type:"function",name:{type:"ident",value:"calc"},arguments:a})}else if(o.test(n)){const a=im(n),A=a.nodes[0];if(n=a.remainingInput,n[0]===s){const{nodes:c,remainingInput:l}=vc(n);r.push({type:"function",name:A,arguments:c}),n=l}else r.push(A)}else if(e.test(n))r.push({type:"operator",value:n[0]}),n=n.slice(1);else{const{nodes:a,remainingInput:A}=n[0]===i?rm(n):nm(n);if(a.length===0)break;r.push(a[0]),n=A}return{nodes:[{type:"expression",terms:r}],remainingInput:n}}})(),im=(()=>{const o=/[^a-z0-9_\-\u0240-\uffff]/i;return e=>{const t=e.match(o),s=t==null?e:e.substr(0,t.index),i=t==null?"":e.substr(t.index);return{nodes:[{type:"ident",value:s}],remainingInput:i}}})(),nm=(()=>{const o=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,e=/^[a-z%]+/i,t=/^(m|mm|cm|rad|deg|[%])$/;return s=>{const i=s.match(o),n=i==null?"0":i[0];s=n==null?s:s.slice(n.length);const r=s.match(e);let a=r!=null&&r[0]!==""?r[0]:null;const A=r==null?s:s.slice(a.length);return a!=null&&!t.test(a)&&(a=null),{nodes:[{type:"number",number:parseFloat(n)||0,unit:a}],remainingInput:A}}})(),rm=(()=>{const o=/^[a-f0-9]*/i;return e=>{e=e.slice(1).trim();const t=e.match(o);return{nodes:t==null?[]:[{type:"hex",value:t[0]}],remainingInput:t==null?e:e.slice(t[0].length)}}})(),vc=o=>{const e=[];for(o=o.slice(1).trim();o.length;){const t=Pu(o);if(e.push(t.nodes[0]),o=t.remainingInput.trim(),o[0]===",")o=o.slice(1).trim();else if(o[0]===")"){o=o.slice(1);break}}return{nodes:e,remainingInput:o}},Qc=Symbol("visitedTypes");class om{constructor(e){this[Qc]=e}walk(e,t){const s=e.slice();for(;s.length;){const i=s.shift();switch(this[Qc].indexOf(i.type)>-1&&t(i),i.type){case"expression":s.unshift(...i.terms);break;case"function":s.unshift(i.name,...i.arguments);break}}}}const Pt=Object.freeze({type:"number",number:0,unit:null});/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Dr=(o,e=0)=>{let{number:t,unit:s}=o;if(!isFinite(t))t=e,s="rad";else if(o.unit==="rad"||o.unit==null)return o;return{type:"number",number:(s==="deg"&&t!=null?t:0)*Math.PI/180,unit:"rad"}},Sc=(o,e=0)=>{let{number:t,unit:s}=o;if(!isFinite(t))t=e,s="m";else if(o.unit==="m")return o;let i;switch(s){default:i=1;break;case"cm":i=1/100;break;case"mm":i=1/1e3;break}return{type:"number",number:i*t,unit:"m"}},tt=(()=>{const o=t=>t,e={rad:o,deg:Dr,m:o,mm:Sc,cm:Sc};return(t,s=Pt)=>{isFinite(t.number)||(t.number=s.number,t.unit=s.unit);const{unit:i}=t;if(i==null)return t;const n=e[i];return n==null?s:n(t)}})();/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Gu,bc,Tc;const Xs=Symbol("evaluate"),Zn=Symbol("lastValue");class X{constructor(){this[Gu]=null}static evaluatableFor(e,t=Pt){if(e instanceof X)return e;if(e.type==="number")return e.unit==="%"?new am(e,t):e;switch(e.name.value){case"calc":return new lm(e,t);case"env":return new Am(e)}return Pt}static evaluate(e){return e instanceof X?e.evaluate():e}static isConstant(e){return e instanceof X?e.isConstant:!0}static applyIntrinsics(e,t){const{basis:s,keywords:i}=t,{auto:n}=i;return s.map((r,a)=>{const A=n[a]==null?r:n[a];let c=e[a]?e[a]:A;if(c.type==="ident"){const l=c.value;l in i&&(c=i[l][a])}return(c==null||c.type==="ident")&&(c=A),c.unit==="%"?Ie(c.number/100*r.number,r.unit):(c=tt(c,r),c.unit!==r.unit?r:c)})}get isConstant(){return!1}evaluate(){return(!this.isConstant||this[Zn]==null)&&(this[Zn]=this[Xs]()),this[Zn]}}Gu=Zn;const Mc=Symbol("percentage"),po=Symbol("basis");class am extends X{constructor(e,t){super(),this[Mc]=e,this[po]=t}get isConstant(){return!0}[Xs](){return Ie(this[Mc].number/100*this[po].number,this[po].unit)}}const cn=Symbol("identNode");class Am extends X{constructor(e){super(),this[bc]=null;const t=e.arguments.length?e.arguments[0].terms[0]:null;t!=null&&t.type==="ident"&&(this[cn]=t)}get isConstant(){return!1}[(bc=cn,Xs)](){if(this[cn]!=null)switch(this[cn].value){case"window-scroll-y":const e=window.pageYOffset,t=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight);return{type:"number",number:e/(t-window.innerHeight)||0,unit:null}}return Pt}}const cm=/[\*\/]/,ls=Symbol("evaluator");class lm extends X{constructor(e,t=Pt){if(super(),this[Tc]=null,e.arguments.length!==1)return;const s=e.arguments[0].terms.slice(),i=[];for(;s.length;){const n=s.shift();if(i.length>0){const r=i[i.length-1];if(r.type==="operator"&&cm.test(r.value)){const a=i.pop(),A=i.pop();if(A==null)return;i.push(new _c(a,X.evaluatableFor(A,t),X.evaluatableFor(n,t)));continue}}i.push(n.type==="operator"?n:X.evaluatableFor(n,t))}for(;i.length>2;){const[n,r,a]=i.splice(0,3);if(r.type!=="operator")return;i.unshift(new _c(r,X.evaluatableFor(n,t),X.evaluatableFor(a,t)))}i.length===1&&(this[ls]=i[0])}get isConstant(){return this[ls]==null||X.isConstant(this[ls])}[(Tc=ls,Xs)](){return this[ls]!=null?X.evaluate(this[ls]):Pt}}const Rc=Symbol("operator"),mo=Symbol("left"),Io=Symbol("right");class _c extends X{constructor(e,t,s){super(),this[Rc]=e,this[mo]=t,this[Io]=s}get isConstant(){return X.isConstant(this[mo])&&X.isConstant(this[Io])}[Xs](){const e=tt(X.evaluate(this[mo])),t=tt(X.evaluate(this[Io])),{number:s,unit:i}=e,{number:n,unit:r}=t;if(r!=null&&i!=null&&r!=i)return Pt;const a=i||r;let A;switch(this[Rc].value){case"+":A=s+n;break;case"-":A=s-n;break;case"/":A=s/n;break;case"*":A=s*n;break;default:return Pt}return{type:"number",number:A,unit:a}}}const Eo=Symbol("evaluatables"),Dc=Symbol("intrinsics");class Ou extends X{constructor(e,t){super(),this[Dc]=t;const s=e[0],i=s!=null?s.terms:[];this[Eo]=t.basis.map((n,r)=>{const a=i[r];return a==null?{type:"ident",value:"auto"}:a.type==="ident"?a:X.evaluatableFor(a,n)})}get isConstant(){for(const e of this[Eo])if(!X.isConstant(e))return!1;return!0}[Xs](){const e=this[Eo].map(t=>X.evaluate(t));return X.applyIntrinsics(e,this[Dc]).map(t=>t.number)}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Hu,$u,Vu,qu;const hs=Symbol("instances"),Lc=Symbol("activateListener"),Fc=Symbol("deactivateListener"),Co=Symbol("notifyInstances"),Nc=Symbol("notify"),kc=Symbol("callback");class je{constructor(e){this[kc]=e}static[Co](){for(const e of je[hs])e[Nc]()}static[(Hu=hs,Lc)](){window.addEventListener("scroll",this[Co],{passive:!0})}static[Fc](){window.removeEventListener("scroll",this[Co])}observe(){je[hs].size===0&&je[Lc](),je[hs].add(this)}disconnect(){je[hs].delete(this),je[hs].size===0&&je[Fc]()}[Nc](){this[kc]()}}je[Hu]=new Set;const Uc=Symbol("computeStyleCallback"),zu=Symbol("astWalker"),Ri=Symbol("dependencies"),Ku=Symbol("onScroll");class hm{constructor(e){this[$u]={},this[Vu]=new om(["function"]),this[qu]=()=>{this[Uc]({relatedState:"window-scroll"})},this[Uc]=e}observeEffectsFor(e){const t={},s=this[Ri];this[zu].walk(e,i=>{const{name:n}=i,a=i.arguments[0].terms[0];if(!(n.value!=="env"||a==null||a.type!=="ident"))switch(a.value){case"window-scroll-y":if(t["window-scroll"]==null){const A="window-scroll"in s?s["window-scroll"]:new je(this[Ku]);A.observe(),delete s["window-scroll"],t["window-scroll"]=A}break}});for(const i in s)s[i].disconnect();this[Ri]=t}dispose(){for(const e in this[Ri])this[Ri][e].disconnect()}}$u=Ri,Vu=zu,qu=Ku;/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const vt=o=>{const e=o.observeEffects||!1,t=o.intrinsics instanceof Function?o.intrinsics:()=>o.intrinsics;return(s,i)=>{const n=s.updated,r=s.connectedCallback,a=s.disconnectedCallback,A=Symbol(`${i}StyleEffector`),c=Symbol(`${i}StyleEvaluator`),l=Symbol(`${i}UpdateEvaluator`),h=Symbol(`${i}EvaluateAndSync`);Object.defineProperties(s,{[A]:{value:null,writable:!0},[c]:{value:null,writable:!0},[l]:{value:function(){const u=ft(this[i]);this[c]=new Ou(u,t(this)),this[A]==null&&e&&(this[A]=new hm(()=>this[h]())),this[A]!=null&&this[A].observeEffectsFor(u)}},[h]:{value:function(){if(this[c]==null)return;const u=this[c].evaluate();this[o.updateHandler](u)}},updated:{value:function(u){u.has(i)&&(this[l](),this[h]()),n.call(this,u)}},connectedCallback:{value:function(){r.call(this),this.requestUpdate(i,this[i])}},disconnectedCallback:{value:function(){a.call(this),this[A]!=null&&(this[A].dispose(),this[A]=null)}}})}};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Yu=o=>o<.5?2*o*o:-1+(4-2*o)*o,um=(o,e,t=Yu)=>s=>o+(e-o)*t(s),dm=(o,e)=>{const t=i=>n=>i+=n,s=e.map(t(0));return i=>{i=We(i,0,1),i*=s[s.length-1];const n=s.findIndex(A=>A>=i),r=n<1?0:s[n-1],a=s[n];return o[n]((i-r)/(a-r))}},ks=o=>{const e=[],t=[];let s=o.initialValue;for(let i=0;i<o.keyframes.length;++i){const n=o.keyframes[i],{value:r,frames:a}=n,A=n.ease||Yu,c=um(s,r,A);e.push(c),t.push(a),s=r}return dm(e,t)};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var ne=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const gm=5e3,fm=ks({initialValue:0,keyframes:[{frames:5,value:-1},{frames:1,value:-1},{frames:8,value:1},{frames:1,value:1},{frames:5,value:0},{frames:18,value:0}]}),pm=ks({initialValue:0,keyframes:[{frames:1,value:1},{frames:5,value:1},{frames:1,value:0},{frames:6,value:0}]}),mm=30,Im=12,Ju="0deg 75deg 105%",Em="auto auto auto",Cm="auto",Bm=2.2,ym=["front","right","back","left"],wm=["upper-","","lower-"],xm=3e3,vm=". Use mouse, touch or arrow keys to move.",ln={AUTO:"auto",NONE:"none"},Bo={BASIC:"basic",WIGGLE:"wiggle"},Qm={PAN_Y:"pan-y",PAN_X:"pan-x",NONE:"none"},Pc=()=>({basis:[Dr(Ie(mm,"deg"))],keywords:{auto:[null]}}),Sm=()=>({basis:[Dr(Ie(Im,"deg"))],keywords:{auto:[null]}}),ju=(()=>{const o=ft(Ju)[0].terms,e=tt(o[0]),t=tt(o[1]);return s=>{const i=s[D].idealCameraDistance();return{basis:[e,t,Ie(i,"m")],keywords:{auto:[null,null,Ie(105,"%")]}}}})(),bm=o=>{const e=Bm*o[D].boundingSphere.radius;return{basis:[Ie(-1/0,"rad"),Ie(Math.PI/8,"rad"),Ie(e,"m")],keywords:{auto:[null,null,null]}}},Tm=o=>{const e=ju(o),s=new Ou([],e).evaluate()[2];return{basis:[Ie(1/0,"rad"),Ie(Math.PI-Math.PI/8,"rad"),Ie(s,"m")],keywords:{auto:[null,null,null]}}},Mm=o=>{const e=o[D].boundingBox.getCenter(new R);return{basis:[Ie(e.x,"m"),Ie(e.y,"m"),Ie(e.z,"m")],keywords:{auto:[null,null,null]}}},Wu=Math.PI/2,Rm=Math.PI/3,_m=Wu/2,Dm=2*Math.PI,K=Symbol("controls"),er=Symbol("panElement"),yo=Symbol("promptElement"),hn=Symbol("promptAnimatedContainer"),wo=Symbol("fingerAnimatedContainers"),un=Symbol("deferInteractionPrompt"),Gc=Symbol("updateAria"),Oc=Symbol("updateCameraForRadius"),us=Symbol("cancelPrompts"),xo=Symbol("onChange"),ri=Symbol("onPointerChange"),zt=Symbol("waitingToPromptUser"),dn=Symbol("userHasInteracted"),ds=Symbol("promptElementVisibleTime"),oi=Symbol("lastPromptOffset"),gn=Symbol("cancellationSource"),vo=Symbol("lastSpherical"),ai=Symbol("jumpCamera"),Qo=Symbol("initialized"),Ai=Symbol("maintainThetaPhi"),Hc=Symbol("syncCameraOrbit"),$c=Symbol("syncFieldOfView"),Vc=Symbol("syncCameraTarget"),qc=Symbol("syncMinCameraOrbit"),zc=Symbol("syncMaxCameraOrbit"),Kc=Symbol("syncMinFieldOfView"),Yc=Symbol("syncMaxFieldOfView"),Lm=o=>{var e,t,s,i,n,r,a,A,c,l,h,u,d,g,p,f,m;class E extends o{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=Ju,this.cameraTarget=Em,this.fieldOfView=Cm,this.minCameraOrbit="auto",this.maxCameraOrbit="auto",this.minFieldOfView="auto",this.maxFieldOfView="auto",this.interactionPromptThreshold=xm,this.interactionPrompt=ln.AUTO,this.interactionPromptStyle=Bo.WIGGLE,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.touchAction=Qm.NONE,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=ku,this[e]=this.shadowRoot.querySelector(".interaction-prompt"),this[t]=this.shadowRoot.querySelector("#prompt"),this[s]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[i]=this.shadowRoot.querySelector(".pan-target"),this[n]=0,this[r]=1/0,this[a]=!1,this[A]=!1,this[c]=Z.AUTOMATIC,this[l]=new Um(this[D].camera,this[st],this[D]),this[h]=new Yn,this[u]=!1,this[d]=!1,this[g]=!1,this[p]=()=>{const I=this[K].changeSource;this[gn]=I,I===Z.USER_INTERACTION&&(this[dn]=!0,this[un]())},this[f]=()=>{this[Gc](),this[me]();const I=this[K].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:I}}))},this[m]=I=>{this[rr].classList.toggle("pointer-tumbling",I.type==="pointer-change-start")}}get inputSensitivity(){return this[K].inputSensitivity}set inputSensitivity(I){this[K].inputSensitivity=I}getCameraOrbit(){const{theta:I,phi:C,radius:x}=this[vo];return{theta:I,phi:C,radius:x,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return Rt(this[q].isPresenting?this[q].arRenderer.target:this[D].getTarget())}getFieldOfView(){return this[K].getFieldOfView()}getMinimumFieldOfView(){return this[K].options.minimumFieldOfView}getMaximumFieldOfView(){return this[K].options.maximumFieldOfView}getIdealAspect(){return this[D].idealAspect}jumpCameraToGoal(){this[ai]=!0,this.requestUpdate(ai,!1)}resetInteractionPrompt(){this[oi]=0,this[ds]=1/0,this[dn]=!1,this[zt]=this.interactionPrompt===ln.AUTO&&this.cameraControls}zoom(I){const C=new WheelEvent("wheel",{deltaY:-30*I});this[st].dispatchEvent(C)}connectedCallback(){super.connectedCallback(),this[K].addEventListener("user-interaction",this[us]),this[K].addEventListener("pointer-change-start",this[ri]),this[K].addEventListener("pointer-change-end",this[ri])}disconnectedCallback(){super.disconnectedCallback(),this[K].removeEventListener("user-interaction",this[us]),this[K].removeEventListener("pointer-change-start",this[ri]),this[K].removeEventListener("pointer-change-end",this[ri])}updated(I){super.updated(I);const C=this[K],x=this[D];if(I.has("cameraControls")&&(this.cameraControls?(C.enableInteraction(),this.interactionPrompt===ln.AUTO&&(this[zt]=!0)):(C.disableInteraction(),this[un]()),this[st].setAttribute("aria-label",this[Ui])),I.has("disableZoom")&&(C.disableZoom=this.disableZoom),I.has("disablePan")&&(C.enablePan=!this.disablePan),I.has("disableTap")&&(C.enableTap=!this.disableTap),(I.has("interactionPrompt")||I.has("cameraControls")||I.has("src"))&&(this.interactionPrompt===ln.AUTO&&this.cameraControls&&!this[dn]?this[zt]=!0:this[un]()),I.has("interactionPromptStyle")&&(this[hn].style.opacity=this.interactionPromptStyle==Bo.BASIC?"1":"0"),I.has("touchAction")){const B=this.touchAction;C.applyOptions({touchAction:B}),C.updateTouchActionStyle()}I.has("orbitSensitivity")&&(C.orbitSensitivity=this.orbitSensitivity),I.has("zoomSensitivity")&&(C.zoomSensitivity=this.zoomSensitivity),I.has("panSensitivity")&&(C.panSensitivity=this.panSensitivity),I.has("interpolationDecay")&&(C.setDamperDecayTime(this.interpolationDecay),x.setTargetDamperDecayTime(this.interpolationDecay)),this[ai]===!0&&Promise.resolve().then(()=>{C.jumpToGoal(),x.jumpToGoal(),this[xo](),this[ai]=!1})}async updateFraming(){const I=this[D],C=I.adjustedFoV(I.framedFoVDeg);await I.updateFraming();const x=I.adjustedFoV(I.framedFoVDeg),B=this[K].getFieldOfView()/C;this[K].setFieldOfView(x*B),this[Ai]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(I,C,x){const B=this[st],y=this[wo];if(y[0].style.opacity==="1"){console.warn("interact() failed because an existing interaction is running.");return}const v=new Array;v.push({x:ks(C.x),y:ks(C.y)});const Q=[{x:v[0].x(0),y:v[0].y(0)}];x!=null&&(v.push({x:ks(x.x),y:ks(x.y)}),Q.push({x:v[1].x(0),y:v[1].y(0)}));let b=performance.now();const{width:S,height:M}=this[D],T=this.getBoundingClientRect(),_=P=>{for(const[$,V]of Q.entries()){const{style:Y}=y[$];Y.transform=`translateX(${S*V.x}px) translateY(${M*V.y}px)`,P==="pointerdown"?Y.opacity="1":P==="pointerup"&&(Y.opacity="0");const te={pointerId:$-5678,pointerType:"touch",target:B,clientX:S*V.x+T.x,clientY:M*V.y+T.y,altKey:!0};B.dispatchEvent(new PointerEvent(P,te))}},L=()=>{const P=this[gn];if(P!==Z.AUTOMATIC||!B.isConnected){for(const V of this[wo])V.style.opacity="0";_("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:P}})),document.removeEventListener("visibilitychange",N);return}const $=Math.min(1,(performance.now()-b)/I);for(const[V,Y]of Q.entries())Y.x=v[V].x($),Y.y=v[V].y($);_("pointermove"),$<1?requestAnimationFrame(L):(_("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:Z.AUTOMATIC}})),document.removeEventListener("visibilitychange",N))},N=()=>{let P=0;document.visibilityState==="hidden"?P=performance.now()-b:b=performance.now()-P};document.addEventListener("visibilitychange",N),_("pointerdown"),this[gn]=Z.AUTOMATIC,requestAnimationFrame(L)}[(e=yo,t=hn,s=wo,i=er,n=oi,r=ds,a=dn,A=zt,c=gn,l=K,h=vo,u=ai,d=Qo,g=Ai,$c)](I){const C=this[K],x=this[D];x.framedFoVDeg=I[0]*180/Math.PI,C.changeSource=Z.NONE,C.setFieldOfView(x.adjustedFoV(x.framedFoVDeg)),this[us]()}[Hc](I){const C=this[K];if(this[Ai]){const{theta:x,phi:B}=this.getCameraOrbit();I[0]=x,I[1]=B,this[Ai]=!1}C.changeSource=Z.NONE,C.setOrbit(I[0],I[1],I[2]),this[us]()}[qc](I){this[K].applyOptions({minimumAzimuthalAngle:I[0],minimumPolarAngle:I[1],minimumRadius:I[2]}),this.jumpCameraToGoal()}[zc](I){this[K].applyOptions({maximumAzimuthalAngle:I[0],maximumPolarAngle:I[1],maximumRadius:I[2]}),this[Oc](I[2]),this.jumpCameraToGoal()}[Kc](I){this[K].applyOptions({minimumFieldOfView:I[0]*180/Math.PI}),this.jumpCameraToGoal()}[Yc](I){const C=this[D].adjustedFoV(I[0]*180/Math.PI);this[K].applyOptions({maximumFieldOfView:C}),this.jumpCameraToGoal()}[Vc](I){const[C,x,B]=I;this[q].arRenderer.isPresenting||this[D].setTarget(C,x,B),this[K].changeSource=Z.NONE,this[q].arRenderer.updateTarget(),this[us]()}[nt](I,C){if(super[nt](I,C),this[q].isPresenting||!this[rs]())return;const x=this[K],B=this[D],y=performance.now();if(this[zt]&&this.loaded&&y>this[Li]+this.interactionPromptThreshold&&(this[zt]=!1,this[ds]=y,this[yo].classList.add("visible")),isFinite(this[ds])&&this.interactionPromptStyle===Bo.WIGGLE){const b=(y-this[ds])/gm%1,S=fm(b),M=pm(b);if(this[hn].style.opacity=`${M}`,S!==this[oi]){const T=S*B.width*.05,_=(S-this[oi])*Math.PI/16;this[hn].style.transform=`translateX(${T}px)`,x.changeSource=Z.AUTOMATIC,x.adjustOrbit(_,0,0),this[oi]=S}}const v=x.update(I,C),Q=B.updateTarget(C);(v||Q)&&this[xo]()}[un](){this[zt]=!1,this[yo].classList.remove("visible"),this[ds]=1/0}[Oc](I){const C=Math.max(this[D].farRadius(),I),x=0,B=Math.abs(2*C);this[K].updateNearFar(x,B)}[Gc](){const{theta:I,phi:C}=this[K].getCameraSpherical(this[vo]),x=(4+Math.floor((I%Dm+_m)/Wu))%4,B=Math.floor(C/Rm),y=ym[x],v=wm[B];this[Oa](`View from stage ${v}${y}`)}get[Ui](){return super[Ui].replace(/\.$/,"")+(this.cameraControls?vm:"")}async[Wi](I){const C=this[K],x=this[D],B=x.adjustedFoV(x.framedFoVDeg);super[Wi](I);const y=x.adjustedFoV(x.framedFoVDeg)/B,v=C.getFieldOfView()*(isFinite(y)?y:1);C.updateAspect(this[D].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[K].setFieldOfView(v),this.jumpCameraToGoal()}[Gt](){super[Gt](),this[Qo]?this[Ai]=!0:this[Qo]=!0,this.requestUpdate("maxFieldOfView",this.maxFieldOfView),this.requestUpdate("fieldOfView",this.fieldOfView),this.requestUpdate("minCameraOrbit",this.minCameraOrbit),this.requestUpdate("maxCameraOrbit",this.maxCameraOrbit),this.requestUpdate("cameraOrbit",this.cameraOrbit),this.requestUpdate("cameraTarget",this.cameraTarget),this.jumpCameraToGoal()}}return p=us,f=xo,m=ri,ne([U({type:Boolean,attribute:"camera-controls"})],E.prototype,"cameraControls",void 0),ne([vt({intrinsics:ju,observeEffects:!0,updateHandler:Hc}),U({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],E.prototype,"cameraOrbit",void 0),ne([vt({intrinsics:Mm,observeEffects:!0,updateHandler:Vc}),U({type:String,attribute:"camera-target",hasChanged:()=>!0})],E.prototype,"cameraTarget",void 0),ne([vt({intrinsics:Pc,observeEffects:!0,updateHandler:$c}),U({type:String,attribute:"field-of-view",hasChanged:()=>!0})],E.prototype,"fieldOfView",void 0),ne([vt({intrinsics:bm,updateHandler:qc}),U({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],E.prototype,"minCameraOrbit",void 0),ne([vt({intrinsics:Tm,updateHandler:zc}),U({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],E.prototype,"maxCameraOrbit",void 0),ne([vt({intrinsics:Sm,updateHandler:Kc}),U({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],E.prototype,"minFieldOfView",void 0),ne([vt({intrinsics:Pc,updateHandler:Yc}),U({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],E.prototype,"maxFieldOfView",void 0),ne([U({type:Number,attribute:"interaction-prompt-threshold"})],E.prototype,"interactionPromptThreshold",void 0),ne([U({type:String,attribute:"interaction-prompt"})],E.prototype,"interactionPrompt",void 0),ne([U({type:String,attribute:"interaction-prompt-style"})],E.prototype,"interactionPromptStyle",void 0),ne([U({type:Number,attribute:"orbit-sensitivity"})],E.prototype,"orbitSensitivity",void 0),ne([U({type:Number,attribute:"zoom-sensitivity"})],E.prototype,"zoomSensitivity",void 0),ne([U({type:Number,attribute:"pan-sensitivity"})],E.prototype,"panSensitivity",void 0),ne([U({type:String,attribute:"touch-action"})],E.prototype,"touchAction",void 0),ne([U({type:Boolean,attribute:"disable-zoom"})],E.prototype,"disableZoom",void 0),ne([U({type:Boolean,attribute:"disable-pan"})],E.prototype,"disablePan",void 0),ne([U({type:Boolean,attribute:"disable-tap"})],E.prototype,"disableTap",void 0),ne([U({type:Number,attribute:"interpolation-decay"})],E.prototype,"interpolationDecay",void 0),E};/* @license
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Fm=.018,Jc=2,Nm=300,km=new ce,jc=new R,Wc=Object.freeze({minimumRadius:0,maximumRadius:1/0,minimumPolarAngle:Math.PI/8,maximumPolarAngle:Math.PI-Math.PI/8,minimumAzimuthalAngle:-1/0,maximumAzimuthalAngle:1/0,minimumFieldOfView:10,maximumFieldOfView:45,touchAction:"none"}),fn=Math.PI/8,pn=.04,mn=10,Z={USER_INTERACTION:"user-interaction",NONE:"none",AUTOMATIC:"automatic"};class Um extends Tr{constructor(e,t,s){super(),this.camera=e,this.element=t,this.scene=s,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.inputSensitivity=1,this.changeSource=Z.NONE,this._interactionEnabled=!1,this._disableZoom=!1,this.isUserPointing=!1,this.enablePan=!0,this.enableTap=!0,this.panProjection=new oA,this.panPerPixel=0,this.spherical=new Yn,this.goalSpherical=new Yn,this.thetaDamper=new Re,this.phiDamper=new Re,this.radiusDamper=new Re,this.logFov=Math.log(Wc.maximumFieldOfView),this.goalLogFov=this.logFov,this.fovDamper=new Re,this.touchMode=null,this.pointers=[],this.startTime=0,this.startPointerPosition={clientX:0,clientY:0},this.lastSeparation=0,this.touchDecided=!1,this.onContext=i=>{if(this.enablePan)i.preventDefault();else for(const n of this.pointers)this.onPointerUp(new PointerEvent("pointercancel",Object.assign(Object.assign({},this.startPointerPosition),{pointerId:n.id})))},this.touchModeZoom=(i,n)=>{if(!this._disableZoom){const r=this.twoTouchDistance(this.pointers[0],this.pointers[1]),a=pn*this.zoomSensitivity*(this.lastSeparation-r)*50/this.scene.height;this.lastSeparation=r,this.userAdjustOrbit(0,0,a)}this.panPerPixel>0&&this.movePan(i,n)},this.disableScroll=i=>{i.preventDefault()},this.touchModeRotate=(i,n)=>{const{touchAction:r}=this._options;if(!this.touchDecided&&r!=="none"){this.touchDecided=!0;const a=Math.abs(i),A=Math.abs(n);if(this.changeSource===Z.USER_INTERACTION&&(r==="pan-y"&&A>a||r==="pan-x"&&a>A)){this.touchMode=null;return}else this.element.addEventListener("touchmove",this.disableScroll,{passive:!1})}this.handleSinglePointerMove(i,n)},this.onPointerDown=i=>{if(this.pointers.length>2)return;const{element:n}=this;this.pointers.length===0&&(n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),this.touchMode=null,this.touchDecided=!1,this.startPointerPosition.clientX=i.clientX,this.startPointerPosition.clientY=i.clientY,this.startTime=performance.now());try{n.setPointerCapture(i.pointerId)}catch{}this.pointers.push({clientX:i.clientX,clientY:i.clientY,id:i.pointerId}),this.isUserPointing=!1,i.pointerType==="touch"?(this.changeSource=i.altKey?Z.AUTOMATIC:Z.USER_INTERACTION,this.onTouchChange(i)):(this.changeSource=Z.USER_INTERACTION,this.onMouseDown(i)),this.changeSource===Z.USER_INTERACTION&&this.dispatchEvent({type:"user-interaction"})},this.onPointerMove=i=>{const n=this.pointers.find(c=>c.id===i.pointerId);if(n==null)return;if(i.pointerType==="mouse"&&i.buttons===0){this.onPointerUp(i);return}const r=this.pointers.length,a=(i.clientX-n.clientX)/r,A=(i.clientY-n.clientY)/r;a===0&&A===0||(n.clientX=i.clientX,n.clientY=i.clientY,i.pointerType==="touch"?(this.changeSource=i.altKey?Z.AUTOMATIC:Z.USER_INTERACTION,this.touchMode!==null&&this.touchMode(a,A)):(this.changeSource=Z.USER_INTERACTION,this.panPerPixel>0?this.movePan(a,A):this.handleSinglePointerMove(a,A)))},this.onPointerUp=i=>{const{element:n}=this,r=this.pointers.findIndex(a=>a.id===i.pointerId);r!==-1&&this.pointers.splice(r,1),this.panPerPixel>0&&!i.altKey&&this.resetRadius(),this.pointers.length===0?(n.removeEventListener("pointermove",this.onPointerMove),n.removeEventListener("pointerup",this.onPointerUp),n.removeEventListener("touchmove",this.disableScroll),this.enablePan&&this.enableTap&&this.recenter(i)):this.touchMode!==null&&this.onTouchChange(i),this.scene.element[er].style.opacity=0,n.style.cursor="grab",this.panPerPixel=0,this.isUserPointing&&this.dispatchEvent({type:"pointer-change-end"})},this.onWheel=i=>{this.changeSource=Z.USER_INTERACTION;const n=i.deltaY*(i.deltaMode==1?18:1)*pn*this.zoomSensitivity/30;this.userAdjustOrbit(0,0,n),i.preventDefault(),this.dispatchEvent({type:"user-interaction"})},this.onKeyDown=i=>{const{changeSource:n}=this;this.changeSource=Z.USER_INTERACTION,(i.shiftKey&&this.enablePan?this.panKeyCodeHandler(i):this.orbitZoomKeyCodeHandler(i))?(i.preventDefault(),this.dispatchEvent({type:"user-interaction"})):this.changeSource=n},this._options=Object.assign({},Wc),this.setOrbit(0,Math.PI/2,1),this.setFieldOfView(100),this.jumpToGoal()}get interactionEnabled(){return this._interactionEnabled}enableInteraction(){if(this._interactionEnabled===!1){const{element:e}=this;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointercancel",this.onPointerUp),this._disableZoom||e.addEventListener("wheel",this.onWheel),e.addEventListener("keydown",this.onKeyDown),e.addEventListener("touchmove",()=>{},{passive:!1}),e.addEventListener("contextmenu",this.onContext),this.element.style.cursor="grab",this._interactionEnabled=!0,this.updateTouchActionStyle()}}disableInteraction(){if(this._interactionEnabled===!0){const{element:e}=this;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),e.removeEventListener("pointercancel",this.onPointerUp),e.removeEventListener("wheel",this.onWheel),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("contextmenu",this.onContext),e.style.cursor="",this.touchMode=null,this._interactionEnabled=!1,this.updateTouchActionStyle()}}get options(){return this._options}set disableZoom(e){this._disableZoom!=e&&(this._disableZoom=e,e===!0?this.element.removeEventListener("wheel",this.onWheel):this.element.addEventListener("wheel",this.onWheel),this.updateTouchActionStyle())}getCameraSpherical(e=new Yn){return e.copy(this.spherical)}getFieldOfView(){return this.camera.fov}applyOptions(e){Object.assign(this._options,e),this.setOrbit(),this.setFieldOfView(Math.exp(this.goalLogFov))}updateNearFar(e,t){this.camera.far=t===0?2:t,this.camera.near=Math.max(e,this.camera.far/1e3),this.camera.updateProjectionMatrix()}updateAspect(e){this.camera.aspect=e,this.camera.updateProjectionMatrix()}setOrbit(e=this.goalSpherical.theta,t=this.goalSpherical.phi,s=this.goalSpherical.radius){const{minimumAzimuthalAngle:i,maximumAzimuthalAngle:n,minimumPolarAngle:r,maximumPolarAngle:a,minimumRadius:A,maximumRadius:c}=this._options,{theta:l,phi:h,radius:u}=this.goalSpherical,d=We(e,i,n);!isFinite(i)&&!isFinite(n)&&(this.spherical.theta=this.wrapAngle(this.spherical.theta-d)+d);const g=We(t,r,a),p=We(s,A,c);return d===l&&g===h&&p===u||!isFinite(d)||!isFinite(g)||!isFinite(p)?!1:(this.goalSpherical.theta=d,this.goalSpherical.phi=g,this.goalSpherical.radius=p,this.goalSpherical.makeSafe(),!0)}setRadius(e){this.goalSpherical.radius=e,this.setOrbit()}setFieldOfView(e){const{minimumFieldOfView:t,maximumFieldOfView:s}=this._options;e=We(e,t,s),this.goalLogFov=Math.log(e)}setDamperDecayTime(e){this.thetaDamper.setDecayTime(e),this.phiDamper.setDecayTime(e),this.radiusDamper.setDecayTime(e),this.fovDamper.setDecayTime(e)}adjustOrbit(e,t,s){const{theta:i,phi:n,radius:r}=this.goalSpherical,{minimumRadius:a,maximumRadius:A,minimumFieldOfView:c,maximumFieldOfView:l}=this._options,h=this.spherical.theta-i,u=Math.PI-.001,d=i-We(e,-u-h,u-h),g=n-t,p=s===0?0:((s>0?A:a)-r)/(Math.log(s>0?l:c)-this.goalLogFov),f=r+s*(isFinite(p)?p:(A-a)*2);if(this.setOrbit(d,g,f),s!==0){const m=this.goalLogFov+s;this.setFieldOfView(Math.exp(m))}}jumpToGoal(){this.update(0,Nu)}update(e,t){if(this.isStationary())return!1;const{maximumPolarAngle:s,maximumRadius:i}=this._options,n=this.spherical.theta-this.goalSpherical.theta;return Math.abs(n)>Math.PI&&!isFinite(this._options.minimumAzimuthalAngle)&&!isFinite(this._options.maximumAzimuthalAngle)&&(this.spherical.theta-=Math.sign(n)*2*Math.PI),this.spherical.theta=this.thetaDamper.update(this.spherical.theta,this.goalSpherical.theta,t,Math.PI),this.spherical.phi=this.phiDamper.update(this.spherical.phi,this.goalSpherical.phi,t,s),this.spherical.radius=this.radiusDamper.update(this.spherical.radius,this.goalSpherical.radius,t,i),this.logFov=this.fovDamper.update(this.logFov,this.goalLogFov,t,1),this.moveCamera(),!0}updateTouchActionStyle(){const{style:e}=this.element;if(this._interactionEnabled){const{touchAction:t}=this._options;this._disableZoom&&t!=="none"?e.touchAction="manipulation":e.touchAction=t}else e.touchAction=""}isStationary(){return this.goalSpherical.theta===this.spherical.theta&&this.goalSpherical.phi===this.spherical.phi&&this.goalSpherical.radius===this.spherical.radius&&this.goalLogFov===this.logFov}moveCamera(){this.spherical.makeSafe(),this.camera.position.setFromSpherical(this.spherical),this.camera.setRotationFromEuler(new Zh(this.spherical.phi-Math.PI/2,this.spherical.theta,0,"YXZ")),this.camera.fov!==Math.exp(this.logFov)&&(this.camera.fov=Math.exp(this.logFov),this.camera.updateProjectionMatrix())}userAdjustOrbit(e,t,s){this.adjustOrbit(e*this.orbitSensitivity*this.inputSensitivity,t*this.orbitSensitivity*this.inputSensitivity,s*this.inputSensitivity)}wrapAngle(e){const t=(e+Math.PI)/(2*Math.PI);return(t-Math.floor(t))*2*Math.PI-Math.PI}pixelLengthToSphericalAngle(e){return 2*Math.PI*e/this.scene.height}twoTouchDistance(e,t){const{clientX:s,clientY:i}=e,{clientX:n,clientY:r}=t,a=n-s,A=r-i;return Math.sqrt(a*a+A*A)}handleSinglePointerMove(e,t){const s=this.pixelLengthToSphericalAngle(e),i=this.pixelLengthToSphericalAngle(t);this.isUserPointing===!1&&(this.isUserPointing=!0,this.dispatchEvent({type:"pointer-change-start"})),this.userAdjustOrbit(s,i,0)}initializePan(){const{theta:e,phi:t}=this.spherical,s=e-this.scene.yaw;this.panPerPixel=Fm*this.panSensitivity/this.scene.height,this.panProjection.set(-Math.cos(s),-Math.cos(t)*Math.sin(s),0,0,Math.sin(t),0,Math.sin(s),-Math.cos(t)*Math.cos(s),0)}movePan(e,t){const{scene:s}=this,i=jc.set(e,t,0).multiplyScalar(this.inputSensitivity),n=this.spherical.radius*Math.exp(this.logFov)*this.panPerPixel;i.multiplyScalar(n);const r=s.getTarget();r.add(i.applyMatrix3(this.panProjection)),s.boundingSphere.clampPoint(r,r),s.setTarget(r.x,r.y,r.z)}recenter(e){if(performance.now()>this.startTime+Nm||Math.abs(e.clientX-this.startPointerPosition.clientX)>Jc||Math.abs(e.clientY-this.startPointerPosition.clientY)>Jc)return;const{scene:t}=this,s=t.positionAndNormalFromPoint(t.getNDC(e.clientX,e.clientY));if(s==null){const{cameraTarget:i}=t.element;t.element.cameraTarget="",t.element.cameraTarget=i,this.userAdjustOrbit(0,0,1)}else t.target.worldToLocal(s.position),t.setTarget(s.position.x,s.position.y,s.position.z)}resetRadius(){const{scene:e}=this,t=e.positionAndNormalFromPoint(km.set(0,0));if(t==null)return;e.target.worldToLocal(t.position);const s=e.getTarget(),{theta:i,phi:n}=this.spherical,r=i-e.yaw,a=jc.set(Math.sin(n)*Math.sin(r),Math.cos(n),Math.sin(n)*Math.cos(r)),A=a.dot(t.position.sub(s));s.add(a.multiplyScalar(A)),e.setTarget(s.x,s.y,s.z),this.setOrbit(void 0,void 0,this.goalSpherical.radius-A)}onTouchChange(e){if(this.pointers.length===1)this.touchMode=this.touchModeRotate;else{if(this._disableZoom){this.touchMode=null,this.element.removeEventListener("touchmove",this.disableScroll);return}this.touchMode=this.touchDecided&&this.touchMode===null?null:this.touchModeZoom,this.touchDecided=!0,this.element.addEventListener("touchmove",this.disableScroll,{passive:!1}),this.lastSeparation=this.twoTouchDistance(this.pointers[0],this.pointers[1]),this.enablePan&&this.touchMode!=null&&(this.initializePan(),e.altKey||(this.scene.element[er].style.opacity=1))}}onMouseDown(e){this.panPerPixel=0,this.enablePan&&(e.button===2||e.ctrlKey||e.metaKey||e.shiftKey)&&(this.initializePan(),this.scene.element[er].style.opacity=1),this.element.style.cursor="grabbing"}orbitZoomKeyCodeHandler(e){let t=!0;switch(e.key){case"PageUp":this.userAdjustOrbit(0,0,pn*this.zoomSensitivity);break;case"PageDown":this.userAdjustOrbit(0,0,-1*pn*this.zoomSensitivity);break;case"ArrowUp":this.userAdjustOrbit(0,-fn,0);break;case"ArrowDown":this.userAdjustOrbit(0,fn,0);break;case"ArrowLeft":this.userAdjustOrbit(-fn,0,0);break;case"ArrowRight":this.userAdjustOrbit(fn,0,0);break;default:t=!1;break}return t}panKeyCodeHandler(e){this.initializePan();let t=!0;switch(e.key){case"ArrowUp":this.movePan(0,-1*mn);break;case"ArrowDown":this.movePan(0,mn);break;case"ArrowLeft":this.movePan(-1*mn,0);break;case"ArrowRight":this.movePan(mn,0);break;default:t=!1;break}return t}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Pm=30,Gm=.8,Xc=1.5,Om=20,Xu=1.3,Hm=1/Xu,$m=.25,Vm=10,Mt={NOT_PRESENTING:"not-presenting",SESSION_STARTED:"session-started",OBJECT_PLACED:"object-placed",FAILED:"failed"},Fa={TRACKING:"tracking",NOT_TRACKING:"not-tracking"},In=new R,qm=new le,zm=new R,Km=new Vi(45,1,.1,100);class Ym extends Tr{constructor(e){super(),this.renderer=e,this.currentSession=null,this.placeOnWall=!1,this.placementBox=null,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.initialHitSource=null,this.transientHitTestSource=null,this.inputSource=null,this._presentedScene=null,this.resolveCleanup=null,this.exitWebXRButtonContainer=null,this.overlay=null,this.xrLight=null,this.tracking=!0,this.frames=0,this.initialized=!1,this.oldTarget=new R,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.lastDragPosition=new R,this.firstRatio=0,this.lastAngle=0,this.goalPosition=new R,this.goalYaw=0,this.goalScale=1,this.xDamper=new Re,this.yDamper=new Re,this.zDamper=new Re,this.yawDamper=new Re,this.scaleDamper=new Re,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onUpdateScene=()=>{this.placementBox!=null&&this.isPresenting&&(this.placementBox.dispose(),this.placementBox=new xc(this.presentedScene,this.placeOnWall?"back":"bottom"))},this.onSelectStart=t=>{const s=this.transientHitTestSource;if(s==null)return;const i=this.frame.getHitTestResultsForTransientInput(s),n=this.presentedScene,r=this.placementBox;if(i.length===1){this.inputSource=t.inputSource;const{axes:a}=this.inputSource.gamepad,A=r.getHit(this.presentedScene,a[0],a[1]);r.show=!0,A!=null?(this.isTranslating=!0,this.lastDragPosition.copy(A)):this.placeOnWall===!1&&(this.isRotating=!0,this.lastAngle=a[0]*Xc)}else if(i.length===2){r.show=!0,this.isTwoFingering=!0;const{separation:a}=this.fingerPolar(i);this.firstRatio=a/n.scale.x}},this.onSelectEnd=()=>{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.inputSource=null,this.goalPosition.y+=this.placementBox.offsetHeight*this.presentedScene.scale.x,this.placementBox.show=!1},this.threeRenderer=e.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){KA();const e=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:["hit-test"],optionalFeatures:["dom-overlay","light-estimation"],domOverlay:this.overlay?{root:this.overlay}:void 0});return this.threeRenderer.xr.setReferenceSpaceType("local"),await this.threeRenderer.xr.setSession(e),this.threeRenderer.xr.cameraAutoUpdate=!1,e}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return KA(),await navigator.xr.isSessionSupported("immersive-ar")}catch(e){return console.warn("Request to present in WebXR denied:"),console.warn(e),console.warn("Falling back to next ar-mode"),!1}}async present(e,t=!1){this.isPresenting&&console.warn("Cannot present while a model is already presenting");let s=new Promise((c,l)=>{requestAnimationFrame(()=>c())});e.setHotspotsVisibility(!1),e.queueRender(),await s,this._presentedScene=e,this.overlay=e.element.shadowRoot.querySelector("div.default"),t===!0&&(this.xrLight=new Zp(this.threeRenderer),this.xrLight.addEventListener("estimationstart",()=>{if(!this.isPresenting||this.xrLight==null)return;const c=this.presentedScene;c.add(this.xrLight),c.environment=this.xrLight.environment}));const i=await this.resolveARSession();i.addEventListener("end",()=>{this.postSessionCleanup()},{once:!0});const n=e.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");n.classList.add("enabled"),n.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=n;const r=await i.requestReferenceSpace("viewer");this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=e.yaw,this.goalYaw=e.yaw,this.goalScale=1,e.setBackground(null),this.oldShadowIntensity=e.shadowIntensity,e.setShadowIntensity(.01),this.oldTarget.copy(e.getTarget()),e.element.addEventListener("load",this.onUpdateScene);const a=Om*Math.PI/180,A=this.placeOnWall===!0?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(a),z:-Math.cos(a)});i.requestHitTestSource({space:r,offsetRay:A}).then(c=>{this.initialHitSource=c}),this.currentSession=i,this.placementBox=new xc(e,this.placeOnWall?"back":"bottom"),this.placementComplete=!1,this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:Mt.SESSION_STARTED})}async stopPresenting(){if(!this.isPresenting)return;const e=new Promise(t=>{this.resolveCleanup=t});try{await this.currentSession.end(),await e}catch(t){console.warn("Error while trying to end WebXR AR session"),console.warn(t),this.postSessionCleanup()}}get isPresenting(){return this.presentedScene!=null}get target(){return this.oldTarget}updateTarget(){const e=this.presentedScene;if(e!=null){const t=e.getTarget();this.oldTarget.copy(t),this.placeOnWall?t.z=e.boundingBox.min.z:t.y=e.boundingBox.min.y,e.setTarget(t.x,t.y,t.z)}}postSessionCleanup(){const e=this.currentSession;e!=null&&(e.removeEventListener("selectstart",this.onSelectStart),e.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const t=this.presentedScene;if(this._presentedScene=null,t!=null){const{element:r}=t;this.xrLight!=null&&(t.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),t.position.set(0,0,0),t.scale.set(1,1,1),t.setShadowOffset(0);const a=this.turntableRotation;a!=null&&(t.yaw=a);const A=this.oldShadowIntensity;A!=null&&t.setShadowIntensity(A),t.setEnvironmentAndSkybox(r[bi],r[Ti]);const c=this.oldTarget;t.setTarget(c.x,c.y,c.z),t.xrCamera=null,t.element.removeEventListener("load",this.onUpdateScene),t.orientHotspots(0),r.requestUpdate("cameraTarget"),r.requestUpdate("maxCameraOrbit"),r[Wi](r.getBoundingClientRect()),requestAnimationFrame(()=>{t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:Z.NONE}}))})}this.renderer.height=0;const s=this.exitWebXRButtonContainer;s!=null&&(s.classList.remove("enabled"),s.removeEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=null);const i=this.transientHitTestSource;i!=null&&(i.cancel(),this.transientHitTestSource=null);const n=this.initialHitSource;n!=null&&(n.cancel(),this.initialHitSource=null),this.placementBox!=null&&(this.placementBox.dispose(),this.placementBox=null),this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.inputSource=null,this.overlay=null,this.resolveCleanup!=null&&this.resolveCleanup(),this.dispatchEvent({type:"status",status:Mt.NOT_PRESENTING})}updateView(e){const t=this.presentedScene,s=this.threeRenderer.xr;s.updateCamera(Km),t.xrCamera=s.getCamera();const{elements:i}=t.getCamera().matrixWorld;if(t.orientHotspots(Math.atan2(i[1],i[5])),this.initialized||(this.placeInitially(),this.initialized=!0),e.requestViewportScale&&e.recommendedViewportScale){const r=e.recommendedViewportScale;e.requestViewportScale(Math.max(r,$m))}const n=s.getBaseLayer();if(n!=null){const r=n instanceof XRWebGLLayer?n.getViewport(e):s.getBinding().getViewSubImage(n,e).viewport;this.threeRenderer.setViewport(r.x,r.y,r.width,r.height)}}placeInitially(){const e=this.presentedScene,{position:t,element:s}=e,i=e.getCamera(),{width:n,height:r}=this.overlay.getBoundingClientRect();e.setSize(n,r),i.projectionMatrixInverse.copy(i.projectionMatrix).invert();const{theta:a,radius:A}=s.getCameraOrbit(),c=i.getWorldDirection(In);e.yaw=Math.atan2(-c.x,-c.z)-a,this.goalYaw=e.yaw,t.copy(i.position).add(c.multiplyScalar(A)),this.updateTarget();const l=e.getTarget();t.add(l).sub(this.oldTarget),this.goalPosition.copy(t),e.setHotspotsVisibility(!0);const{session:h}=this.frame;h.addEventListener("selectstart",this.onSelectStart),h.addEventListener("selectend",this.onSelectEnd),h.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then(u=>{this.transientHitTestSource=u})}getTouchLocation(){const{axes:e}=this.inputSource.gamepad;let t=this.placementBox.getExpandedHit(this.presentedScene,e[0],e[1]);return t!=null&&(In.copy(t).sub(this.presentedScene.getCamera().position),In.length()>Vm)?null:t}getHitPoint(e){const t=this.threeRenderer.xr.getReferenceSpace(),s=e.getPose(t);if(s==null)return null;const i=qm.fromArray(s.transform.matrix);return this.placeOnWall===!0&&(this.goalYaw=Math.atan2(i.elements[4],i.elements[6])),i.elements[5]>.75!==this.placeOnWall?zm.setFromMatrixPosition(i):null}moveToFloor(e){const t=this.initialHitSource;if(t==null)return;const s=e.getHitTestResults(t);if(s.length==0)return;const i=s[0],n=this.getHitPoint(i);n!=null&&(this.placementBox.show=!0,this.isTranslating||(this.placeOnWall?this.goalPosition.copy(n):this.goalPosition.y=n.y),t.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:Mt.OBJECT_PLACED}))}fingerPolar(e){const t=e[0].inputSource.gamepad.axes,s=e[1].inputSource.gamepad.axes,i=s[0]-t[0],n=s[1]-t[1],r=Math.atan2(n,i);let a=this.lastAngle-r;return a>Math.PI?a-=2*Math.PI:a<-Math.PI&&(a+=2*Math.PI),this.lastAngle=r,{separation:Math.sqrt(i*i+n*n),deltaYaw:a}}processInput(e){const t=this.transientHitTestSource;if(t==null||!this.isTranslating&&!this.isTwoFingering&&!this.isRotating)return;const s=e.getHitTestResultsForTransientInput(t),i=this.presentedScene,n=i.scale.x;if(this.isTwoFingering){if(s.length<2)this.isTwoFingering=!1;else{const{separation:r,deltaYaw:a}=this.fingerPolar(s);if(this.placeOnWall===!1&&(this.goalYaw+=a),i.canScale){const A=r/this.firstRatio;this.goalScale=A<Xu&&A>Hm?1:A}}return}else if(s.length===2){this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!0;const{separation:r}=this.fingerPolar(s);this.firstRatio=r/n;return}if(this.isRotating){const r=this.inputSource.gamepad.axes[0]*Xc;this.goalYaw+=r-this.lastAngle,this.lastAngle=r}else this.isTranslating&&s.forEach(r=>{if(r.inputSource!==this.inputSource)return;let a=null;if(r.results.length>0&&(a=this.getHitPoint(r.results[0])),a==null&&(a=this.getTouchLocation()),a!=null){if(this.goalPosition.sub(this.lastDragPosition),this.placeOnWall===!1){const A=a.y-this.lastDragPosition.y;if(A<0){this.placementBox.offsetHeight=A/n,this.presentedScene.setShadowOffset(A);const c=In.copy(i.getCamera().position),l=-A/(c.y-a.y);c.multiplyScalar(l),a.multiplyScalar(1-l).add(c)}}this.goalPosition.add(a),this.lastDragPosition.copy(a)}})}moveScene(e){const t=this.presentedScene,{position:s,yaw:i}=t,n=t.boundingSphere.radius,r=this.goalPosition,a=t.scale.x,A=this.placementBox;let c=Z.NONE;if(!r.equals(s)||this.goalScale!==a){c=Z.USER_INTERACTION;let{x:l,y:h,z:u}=s;l=this.xDamper.update(l,r.x,e,n),h=this.yDamper.update(h,r.y,e,n),u=this.zDamper.update(u,r.z,e,n),s.set(l,h,u);const d=this.scaleDamper.update(a,this.goalScale,e,1);if(t.scale.set(d,d,d),!this.isTranslating){const g=r.y-h;this.placementComplete&&this.placeOnWall===!1?(A.offsetHeight=g/d,t.setShadowOffset(g)):g===0&&(this.placementComplete=!0,A.show=!1,t.setShadowIntensity(Gm))}}A.updateOpacity(e),t.updateTarget(e),t.yaw=this.yawDamper.update(i,this.goalYaw,e,Math.PI),t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:c}}))}onWebXRFrame(e,t){this.frame=t,++this.frames;const s=this.threeRenderer.xr.getReferenceSpace(),i=t.getViewerPose(s);i==null&&this.tracking===!0&&this.frames>Pm&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:Fa.NOT_TRACKING}));const n=this.presentedScene;if(i==null||n==null||!n.element.loaded){this.threeRenderer.clear();return}this.tracking===!1&&(this.tracking=!0,this.dispatchEvent({type:"tracking",status:Fa.TRACKING}));let r=!0;for(const a of i.views){if(this.updateView(a),r){this.moveToFloor(t),this.processInput(t);const A=e-this.lastTick;this.moveScene(A),this.renderer.preRender(n,e,A),this.lastTick=e,n.renderShadow(this.threeRenderer)}this.threeRenderer.render(n,n.getCamera()),r=!1}}}function Jm(o){const e=new Map,t=new Map,s=o.clone();return Zu(o,s,function(i,n){e.set(n,i),t.set(i,n)}),s.traverse(function(i){if(!i.isSkinnedMesh)return;const n=i,r=e.get(i),a=r.skeleton.bones;n.skeleton=r.skeleton.clone(),n.bindMatrix.copy(r.bindMatrix),n.skeleton.bones=a.map(function(A){return t.get(A)}),n.bind(n.skeleton,n.bindMatrix)}),s}function Zu(o,e,t){t(o,e);for(let s=0;s<o.children.length;s++)Zu(o.children[s],e.children[s],t)}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Zc=Symbol("prepared"),fr=Symbol("prepare"),Je=Symbol("preparedGLTF"),pr=Symbol("clone");class jm{constructor(e){this[Je]=e}static prepare(e){if(e.scene==null)throw new Error("Model does not have a scene");if(e[Zc])return e;const t=this[fr](e);return t[Zc]=!0,t}static[fr](e){const{scene:t}=e,s=[t];return Object.assign(Object.assign({},e),{scene:t,scenes:s})}get parser(){return this[Je].parser}get animations(){return this[Je].animations}get scene(){return this[Je].scene}get scenes(){return this[Je].scenes}get cameras(){return this[Je].cameras}get asset(){return this[Je].asset}get userData(){return this[Je].userData}clone(){const e=this.constructor,t=this[pr]();return new e(t)}dispose(){this.scenes.forEach(e=>{e.traverse(t=>{const s=t;if(!s.material)return;(Array.isArray(s.material)?s.material:[s.material]).forEach(n=>{for(const r in n){const a=n[r];if(a instanceof Ze){const A=a.source.data;A.close!=null&&A.close(),a.dispose()}}n.dispose()}),s.geometry.dispose()})})}[pr](){const e=this[Je],t=Jm(this.scene);Wm(t,this.scene);const s=[t],i=e.userData?Object.assign({},e.userData):{};return Object.assign(Object.assign({},e),{scene:t,scenes:s,userData:i})}}const Wm=(o,e)=>{ed(o,e,(t,s)=>{s.userData.variantMaterials!==void 0&&(t.userData.variantMaterials=new Map(s.userData.variantMaterials)),s.userData.variantData!==void 0&&(t.userData.variantData=s.userData.variantData),s.userData.originalMaterial!==void 0&&(t.userData.originalMaterial=s.userData.originalMaterial)})},ed=(o,e,t)=>{t(o,e);for(let s=0;s<o.children.length;s++)ed(o.children[s],e.children[s],t)},el=Symbol("threeGLTF"),tl=Symbol("gltf"),sl=Symbol("gltfElementMap"),il=Symbol("threeObjectMap"),nl=Symbol("parallelTraverseThreeScene"),rl=Symbol("correlateOriginalThreeGLTF"),ol=Symbol("correlateCloneThreeGLTF");class ji{constructor(e,t,s,i){this[el]=e,this[tl]=t,this[sl]=i,this[il]=s}static from(e,t){return t!=null?this[ol](e,t):this[rl](e)}static[rl](e){const t=e.parser.json,s=e.parser.associations,i=new Map,n={name:"Default"},r={type:"materials",index:-1};for(const a of s.keys())a instanceof zn&&s.get(a)==null&&(r.index<0&&(t.materials==null&&(t.materials=[]),r.index=t.materials.length,t.materials.push(n)),a.name=n.name,s.set(a,{materials:r.index}));for(const[a,A]of s){A&&(a.userData=a.userData||{},a.userData.associations=A);for(const c in A)if(c!=null&&c!=="primitives"){const l=c,u=(t[l]||[])[A[l]];if(u==null)continue;let d=i.get(u);d==null&&(d=new Set,i.set(u,d)),d.add(a)}}return new ji(e,t,s,i)}static[ol](e,t){const s=t.threeGLTF,i=t.gltf,n=JSON.parse(JSON.stringify(i)),r=new Map,a=new Map;for(let A=0;A<s.scenes.length;A++)this[nl](s.scenes[A],e.scenes[A],(c,l)=>{const h=t.threeObjectMap.get(c);if(h!=null){for(const u in h)if(u!=null&&u!=="primitives"){const d=u,g=h[d],p=n[d][g],f=r.get(l)||{};f[d]=g,r.set(l,f);const m=a.get(p)||new Set;m.add(l),a.set(p,m)}}});return new ji(e,n,r,a)}static[nl](e,t,s){const i=(n,r)=>{if(s(n,r),n.isObject3D){const a=n,A=r;if(a.material)if(Array.isArray(a.material))for(let c=0;c<a.material.length;++c)s(a.material[c],A.material[c]);else s(a.material,A.material);for(let c=0;c<n.children.length;++c)i(n.children[c],r.children[c])}};i(e,t)}get threeGLTF(){return this[el]}get gltf(){return this[tl]}get gltfElementMap(){return this[sl]}get threeObjectMap(){return this[il]}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const ci=Symbol("correlatedSceneGraph");class Xm extends jm{static[fr](e){const t=super[fr](e);t[ci]==null&&(t[ci]=ji.from(t));const{scene:s}=t,i=new br(void 0,1/0);return s.traverse(n=>{n.renderOrder=1e3,n.frustumCulled=!1,n.name||(n.name=n.uuid);const r=n;if(r.material){const{geometry:a}=r;r.castShadow=!0,r.isSkinnedMesh&&(a.boundingSphere=i,a.boundingBox=null);const A=r.material;if(A.isMeshBasicMaterial===!0&&(A.toneMapped=!1),A.shadowSide=qi,A.aoMap){const{gltf:c,threeObjectMap:l}=t[ci],h=l.get(A);if(c.materials!=null&&h!=null&&h.materials!=null){const u=c.materials[h.materials];u.occlusionTexture&&u.occlusionTexture.texCoord===0&&a.attributes.uv!=null&&a.setAttribute("uv2",a.attributes.uv)}}}}),t}get correlatedSceneGraph(){return this[Je][ci]}[pr](){const e=super[pr](),t=new Map;return e.scene.traverse(s=>{const i=s;if(i.material){const r=i.material;if(r!=null){if(t.has(r.uuid)){i.material=t.get(r.uuid);return}i.material=r.clone(),t.set(r.uuid,i.material)}}const n=s;n.target!==void 0&&n.add(n.target)}),e[ci]=ji.from(e,this.correlatedSceneGraph),e}}const td=(o,e,t)=>{let s;switch(o){case ve:s=new Uint8ClampedArray(e*t*4);break;case De:s=new Uint16Array(e*t*4);break;case Tg:s=new Uint32Array(e*t*4);break;case bg:s=new Int8Array(e*t*4);break;case Sg:s=new Int16Array(e*t*4);break;case Qg:s=new Int32Array(e*t*4);break;case it:s=new Float32Array(e*t*4);break;default:throw new Error("Unsupported data type")}return s};let En;const Zm=(o,e,t,s)=>{if(En!==void 0)return En;const i=new zi(1,1,s);e.setRenderTarget(i);const n=new ge(new Ws,new Xe({color:16777215}));e.render(n,t),e.setRenderTarget(null);const r=td(o,i.width,i.height);return e.readRenderTargetPixels(i,0,0,i.width,i.height,r),i.dispose(),n.geometry.dispose(),n.material.dispose(),En=r[0]!==0,En};class cA{constructor(e){var t,s,i,n,r,a,A,c,l,h,u,d,g,p,f,m;this._rendererIsDisposable=!1,this._supportsReadPixels=!0,this.render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(w){throw this._renderer.setRenderTarget(null),w}this._renderer.setRenderTarget(null)},this._width=e.width,this._height=e.height,this._type=e.type,this._colorSpace=e.colorSpace;const E={format:_e,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:((t=e.renderTargetOptions)===null||t===void 0?void 0:t.anisotropy)!==void 0?(s=e.renderTargetOptions)===null||s===void 0?void 0:s.anisotropy:1,generateMipmaps:((i=e.renderTargetOptions)===null||i===void 0?void 0:i.generateMipmaps)!==void 0?(n=e.renderTargetOptions)===null||n===void 0?void 0:n.generateMipmaps:!1,magFilter:((r=e.renderTargetOptions)===null||r===void 0?void 0:r.magFilter)!==void 0?(a=e.renderTargetOptions)===null||a===void 0?void 0:a.magFilter:de,minFilter:((A=e.renderTargetOptions)===null||A===void 0?void 0:A.minFilter)!==void 0?(c=e.renderTargetOptions)===null||c===void 0?void 0:c.minFilter:de,samples:((l=e.renderTargetOptions)===null||l===void 0?void 0:l.samples)!==void 0?(h=e.renderTargetOptions)===null||h===void 0?void 0:h.samples:void 0,wrapS:((u=e.renderTargetOptions)===null||u===void 0?void 0:u.wrapS)!==void 0?(d=e.renderTargetOptions)===null||d===void 0?void 0:d.wrapS:Pe,wrapT:((g=e.renderTargetOptions)===null||g===void 0?void 0:g.wrapT)!==void 0?(p=e.renderTargetOptions)===null||p===void 0?void 0:p.wrapT:Pe};if(this._material=e.material,e.renderer?this._renderer=e.renderer:(this._renderer=cA.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new Ut,this._camera=new yr,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!Zm(this._type,this._renderer,this._camera,E)){let w;switch(this._type){case De:w=this._renderer.extensions.has("EXT_color_buffer_float")?it:void 0;break}w!==void 0?(console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${it}`),this._type=w):(this._supportsReadPixels=!1,console.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new ge(new Ws,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new zi(this.width,this.height,E),this._renderTarget.texture.mapping=((f=e.renderTargetOptions)===null||f===void 0?void 0:f.mapping)!==void 0?(m=e.renderTargetOptions)===null||m===void 0?void 0:m.mapping:hr}static instantiateRenderer(){const e=new rA;return e.setSize(128,128),e}toArray(){if(!this._supportsReadPixels)throw new Error("Can't read pixels in this browser");const e=td(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){const t=new jh(this.toArray(),this.width,this.height,_e,this._type,(e==null?void 0:e.mapping)||hr,(e==null?void 0:e.wrapS)||Pe,(e==null?void 0:e.wrapT)||Pe,(e==null?void 0:e.magFilter)||de,(e==null?void 0:e.minFilter)||de,(e==null?void 0:e.anisotropy)||1,ie);return t.generateMipmaps=(e==null?void 0:e.generateMipmaps)!==void 0?e==null?void 0:e.generateMipmaps:!1,t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof $s&&Object.values(this.material.uniforms).forEach(t=>{t.value instanceof Ze&&t.value.dispose()}),Object.values(this.material).forEach(t=>{t instanceof Ze&&t.dispose()}),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}const eI=`
varying vec2 vUv;

void main() {
  vUv = uv;
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,tI=`
// min half float value
#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )
// max half float value
#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )

uniform sampler2D sdr;
uniform sampler2D gainMap;
uniform vec3 gamma;
uniform vec3 offsetHdr;
uniform vec3 offsetSdr;
uniform vec3 gainMapMin;
uniform vec3 gainMapMax;
uniform float weightFactor;

varying vec2 vUv;

void main() {
  vec3 rgb = texture2D( sdr, vUv ).rgb;
  vec3 recovery = texture2D( gainMap, vUv ).rgb;
  vec3 logRecovery = pow( recovery, gamma );
  vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;
  vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;
  vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));
  gl_FragColor = vec4( clampedHdrColor , 1.0 );
}
`;class sI extends $s{constructor({gamma:e,offsetHdr:t,offsetSdr:s,gainMapMin:i,gainMapMax:n,maxDisplayBoost:r,hdrCapacityMin:a,hdrCapacityMax:A,sdr:c,gainMap:l}){super({name:"GainMapDecoderMaterial",vertexShader:eI,fragmentShader:tI,uniforms:{sdr:{value:c},gainMap:{value:l},gamma:{value:new R(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:new R().fromArray(t)},offsetSdr:{value:new R().fromArray(s)},gainMapMin:{value:new R().fromArray(i)},gainMapMax:{value:new R().fromArray(n)},weightFactor:{value:(Math.log2(r)-a)/(A-a)}},blending:eu,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=r,this._hdrCapacityMin=a,this._hdrCapacityMax=A,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){const e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){const t=this.uniforms.gamma.value;t.x=1/e[0],t.y=1/e[1],t.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){const e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}}class sd extends Error{}class id extends Error{}const li=(o,e,t)=>{var s;let i;const n=(s=o.attributes.getNamedItem(e))===null||s===void 0?void 0:s.nodeValue;if(n)i=n;else{const r=o.getElementsByTagName(e)[0];if(r){const a=r.getElementsByTagName("rdf:li");if(a.length===3)i=Array.from(a).map(A=>A.innerHTML);else throw new Error(`Gainmap metadata contains an array of items for ${e} but its length is not 3`)}else{if(t)return t;throw new Error(`Can't find ${e} in gainmap metadata`)}}return i},iI=o=>{var e,t;let s;typeof TextDecoder<"u"?s=new TextDecoder().decode(o):s=o.toString();let i=s.indexOf("<x:xmpmeta");const n=new DOMParser;for(;i!==-1;){const r=s.indexOf("x:xmpmeta>",i);s.slice(i,r+10);const a=s.slice(i,r+10);try{const c=n.parseFromString(a,"text/xml").getElementsByTagName("rdf:Description")[0],l=li(c,"hdrgm:GainMapMin","0"),h=li(c,"hdrgm:GainMapMax"),u=li(c,"hdrgm:Gamma","1"),d=li(c,"hdrgm:OffsetSDR","0.015625"),g=li(c,"hdrgm:OffsetHDR","0.015625");let p=(e=c.attributes.getNamedItem("hdrgm:HDRCapacityMin"))===null||e===void 0?void 0:e.nodeValue;p||(p="0");const f=(t=c.attributes.getNamedItem("hdrgm:HDRCapacityMax"))===null||t===void 0?void 0:t.nodeValue;if(!f)throw new Error("Incomplete gainmap metadata");return{gainMapMin:Array.isArray(l)?l.map(m=>parseFloat(m)):[parseFloat(l),parseFloat(l),parseFloat(l)],gainMapMax:Array.isArray(h)?h.map(m=>parseFloat(m)):[parseFloat(h),parseFloat(h),parseFloat(h)],gamma:Array.isArray(u)?u.map(m=>parseFloat(m)):[parseFloat(u),parseFloat(u),parseFloat(u)],offsetSdr:Array.isArray(d)?d.map(m=>parseFloat(m)):[parseFloat(d),parseFloat(d),parseFloat(d)],offsetHdr:Array.isArray(g)?g.map(m=>parseFloat(m)):[parseFloat(g),parseFloat(g),parseFloat(g)],hdrCapacityMin:parseFloat(p),hdrCapacityMax:parseFloat(f)}}catch{}i=s.indexOf("<x:xmpmeta",r)}};class nI{constructor(e){this.options={debug:e&&e.debug!==void 0?e.debug:!1,extractFII:e&&e.extractFII!==void 0?e.extractFII:!0,extractNonFII:e&&e.extractNonFII!==void 0?e.extractNonFII:!0}}extract(e){return new Promise((t,s)=>{const i=this.options.debug,n=new DataView(e.buffer);if(n.getUint16(0)!==65496){s(new Error("Not a valid jpeg"));return}const r=n.byteLength;let a=2,A=0,c;for(;a<r;){if(++A>250){s(new Error(`Found no marker after ${A} loops 😵`));return}if(n.getUint8(a)!==255){s(new Error(`Not a valid marker at offset 0x${a.toString(16)}, found: 0x${n.getUint8(a).toString(16)}`));return}if(c=n.getUint8(a+1),i&&console.log(`Marker: ${c.toString(16)}`),c===226){i&&console.log("Found APP2 marker (0xffe2)");const l=a+4;if(n.getUint32(l)===1297106432){const h=l+4;let u;if(n.getUint16(h)===18761)u=!1;else if(n.getUint16(h)===19789)u=!0;else{s(new Error("No valid endianness marker found in TIFF header"));return}if(n.getUint16(h+2,!u)!==42){s(new Error("Not valid TIFF data! (no 0x002A marker)"));return}const d=n.getUint32(h+4,!u);if(d<8){s(new Error("Not valid TIFF data! (First offset less than 8)"));return}const g=h+d,p=n.getUint16(g,!u),f=g+2;let m=0;for(let C=f;C<f+12*p;C+=12)n.getUint16(C,!u)===45057&&(m=n.getUint32(C+8,!u));const w=g+2+p*12+4,I=[];for(let C=w;C<w+m*16;C+=16){const x={MPType:n.getUint32(C,!u),size:n.getUint32(C+4,!u),dataOffset:n.getUint32(C+8,!u),dependantImages:n.getUint32(C+12,!u),start:-1,end:-1,isFII:!1};x.dataOffset?(x.start=h+x.dataOffset,x.isFII=!1):(x.start=0,x.isFII=!0),x.end=x.start+x.size,I.push(x)}if(this.options.extractNonFII&&I.length){const C=new Blob([n]),x=[];for(const B of I){if(B.isFII&&!this.options.extractFII)continue;const y=C.slice(B.start,B.end+1,"image/jpeg");x.push(y)}t(x)}}}a+=2+n.getUint16(a+2)}})}}const rI=async o=>{const e=iI(o);if(!e)throw new id("Gain map XMP metadata not found");const s=await new nI({extractFII:!0,extractNonFII:!0}).extract(o);if(s.length!==2)throw new sd("Gain map recovery image not found");return{sdr:new Uint8Array(await s[0].arrayBuffer()),gainMap:new Uint8Array(await s[1].arrayBuffer()),metadata:e}},al=o=>new Promise((e,t)=>{const s=document.createElement("img");s.onload=()=>{e(s)},s.onerror=i=>{t(i)},s.src=URL.createObjectURL(o)});class oI extends Br{constructor(e,t){super(t),this._renderer=e,this._internalLoadingManager=new Mg}setRenderTargetOptions(e){return this._renderTargetOptions=e,this}prepareQuadRenderer(){const e=new sI({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new Ze,sdr:new Ze});return new cA({width:16,height:16,type:De,colorSpace:ie,material:e,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async render(e,t,s,i){const n=i?new Blob([i],{type:"image/jpeg"}):void 0,r=new Blob([s],{type:"image/jpeg"});let a,A,c=!1;if(typeof createImageBitmap>"u"){const u=await Promise.all([n?al(n):Promise.resolve(void 0),al(r)]);A=u[0],a=u[1],c=!0}else{const u=await Promise.all([n?createImageBitmap(n,{imageOrientation:"flipY"}):Promise.resolve(void 0),createImageBitmap(r,{imageOrientation:"flipY"})]);A=u[0],a=u[1]}const l=new Ze(A||new ImageData(2,2),hr,Pe,Pe,de,RA,_e,ve,1,ie);l.flipY=c,l.needsUpdate=!0;const h=new Ze(a,hr,Pe,Pe,de,RA,_e,ve,1,be);h.flipY=c,h.needsUpdate=!0,e.width=a.width,e.height=a.height,e.material.gainMap=l,e.material.sdr=h,e.material.gainMapMin=t.gainMapMin,e.material.gainMapMax=t.gainMapMax,e.material.offsetHdr=t.offsetHdr,e.material.offsetSdr=t.offsetSdr,e.material.gamma=t.gamma,e.material.hdrCapacityMin=t.hdrCapacityMin,e.material.hdrCapacityMax=t.hdrCapacityMax,e.material.maxDisplayBoost=Math.pow(2,t.hdrCapacityMax),e.material.needsUpdate=!0,e.render()}}class aI extends oI{load(e,t,s,i){const n=this.prepareQuadRenderer(),r=new Lt(this._internalLoadingManager);return r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),this.manager.itemStart(e),r.load(e,async a=>{if(typeof a=="string")throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const A=new Uint8Array(a);let c,l,h;try{const u=await rI(A);c=u.sdr,l=u.gainMap,h=u.metadata}catch(u){if(u instanceof id||u instanceof sd)console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),h={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},c=A;else throw u}try{await this.render(n,h,c,l)}catch(u){this.manager.itemError(e),typeof i=="function"&&i(u),n.disposeOnDemandRenderer();return}typeof t=="function"&&t(n),this.manager.itemEnd(e),n.disposeOnDemandRenderer()},s,a=>{this.manager.itemError(e),typeof i=="function"&&i(a)}),n}}class AI extends Rg{constructor(e){super(e),this.type=De}parse(e){const r=function(y,v){switch(y){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(v||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(v||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(v||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(v||""))}},l=`
`,h=function(y,v,Q){v=v||1024;let S=y.pos,M=-1,T=0,_="",L=String.fromCharCode.apply(null,new Uint16Array(y.subarray(S,S+128)));for(;0>(M=L.indexOf(l))&&T<v&&S<y.byteLength;)_+=L,T+=L.length,S+=128,L+=String.fromCharCode.apply(null,new Uint16Array(y.subarray(S,S+128)));return-1<M?(Q!==!1&&(y.pos+=T+M+1),_+L.slice(0,M)):!1},u=function(y){const v=/^#\?(\S+)/,Q=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,S=/^\s*FORMAT=(\S+)\s*$/,M=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,T={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let _,L;for((y.pos>=y.byteLength||!(_=h(y)))&&r(1,"no header found"),(L=_.match(v))||r(3,"bad initial token"),T.valid|=1,T.programtype=L[1],T.string+=_+`
`;_=h(y),_!==!1;){if(T.string+=_+`
`,_.charAt(0)==="#"){T.comments+=_+`
`;continue}if((L=_.match(Q))&&(T.gamma=parseFloat(L[1])),(L=_.match(b))&&(T.exposure=parseFloat(L[1])),(L=_.match(S))&&(T.valid|=2,T.format=L[1]),(L=_.match(M))&&(T.valid|=4,T.height=parseInt(L[1],10),T.width=parseInt(L[2],10)),T.valid&2&&T.valid&4)break}return T.valid&2||r(3,"missing format specifier"),T.valid&4||r(3,"missing image size specifier"),T},d=function(y,v,Q){const b=v;if(b<8||b>32767||y[0]!==2||y[1]!==2||y[2]&128)return new Uint8Array(y);b!==(y[2]<<8|y[3])&&r(3,"wrong scanline width");const S=new Uint8Array(4*v*Q);S.length||r(4,"unable to allocate buffer space");let M=0,T=0;const _=4*b,L=new Uint8Array(4),N=new Uint8Array(_);let P=Q;for(;P>0&&T<y.byteLength;){T+4>y.byteLength&&r(1),L[0]=y[T++],L[1]=y[T++],L[2]=y[T++],L[3]=y[T++],(L[0]!=2||L[1]!=2||(L[2]<<8|L[3])!=b)&&r(3,"bad rgbe scanline format");let $=0,V;for(;$<_&&T<y.byteLength;){V=y[T++];const te=V>128;if(te&&(V-=128),(V===0||$+V>_)&&r(3,"bad scanline data"),te){const he=y[T++];for(let Te=0;Te<V;Te++)N[$++]=he}else N.set(y.subarray(T,T+V),$),$+=V,T+=V}const Y=b;for(let te=0;te<Y;te++){let he=0;S[M]=N[te+he],he+=b,S[M+1]=N[te+he],he+=b,S[M+2]=N[te+he],he+=b,S[M+3]=N[te+he],M+=4}P--}return S},g=function(y,v,Q,b){const S=y[v+3],M=Math.pow(2,S-128)/255;Q[b+0]=y[v+0]*M,Q[b+1]=y[v+1]*M,Q[b+2]=y[v+2]*M,Q[b+3]=1},p=function(y,v,Q,b){const S=y[v+3],M=Math.pow(2,S-128)/255;Q[b+0]=sn.toHalfFloat(Math.min(y[v+0]*M,65504)),Q[b+1]=sn.toHalfFloat(Math.min(y[v+1]*M,65504)),Q[b+2]=sn.toHalfFloat(Math.min(y[v+2]*M,65504)),Q[b+3]=sn.toHalfFloat(1)},f=new Uint8Array(e);f.pos=0;const m=u(f),E=m.width,w=m.height,I=d(f.subarray(f.pos),E,w);let C,x,B;switch(this.type){case it:B=I.length/4;const y=new Float32Array(B*4);for(let Q=0;Q<B;Q++)g(I,Q*4,y,Q*4);C=y,x=it;break;case De:B=I.length/4;const v=new Uint16Array(B*4);for(let Q=0;Q<B;Q++)p(I,Q*4,v,Q*4);C=v,x=De;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:E,height:w,data:C,header:m.string,gamma:m.gamma,exposure:m.exposure,type:x}}setDataType(e){return this.type=e,this}load(e,t,s,i){function n(r,a){switch(r.type){case it:case De:r.colorSpace=ie,r.minFilter=de,r.magFilter=de,r.generateMipmaps=!1,r.flipY=!0;break}t&&t(r,a)}return super.load(e,n,s,i)}}/* @license
 * Copyright 2021 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const cI={topLight:{intensity:500,position:[.418,16.199,.3]},room:{position:[-.757,13.219,.717],scale:[31.713,28.305,28.591]},boxes:[{position:[-10.906,2.009,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,.857,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:50,position:[-16.116,14.37,8.208],scale:[.1,2.428,2.739]},{intensity:50,position:[-16.109,18.021,-8.207],scale:[.1,2.425,2.751]},{intensity:17,position:[14.904,12.198,-1.832],scale:[.15,4.265,6.331]},{intensity:43,position:[-.462,8.89,14.52],scale:[4.38,5.441,.088]},{intensity:20,position:[3.235,11.486,-12.541],scale:[2.5,2,.1]},{intensity:100,position:[0,20,0],scale:[1,.1,1]}]},lI={topLight:{intensity:400,position:[.5,14,.5]},room:{position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-10.906,-1,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,-.16,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:80,position:[-14,10,8],scale:[.1,2.5,2.5]},{intensity:80,position:[-14,14,-4],scale:[.1,2.5,2.5]},{intensity:23,position:[14,12,0],scale:[.1,5,5]},{intensity:16,position:[0,9,14],scale:[5,5,.1]},{intensity:80,position:[7,8,-14],scale:[2.5,2.5,.1]},{intensity:80,position:[-7,16,-14],scale:[2.5,2.5,.1]},{intensity:1,position:[0,20,0],scale:[.1,.1,.1]}]};class Al extends Ut{constructor(e){super(),this.position.y=-3.5;const t=new tu;t.deleteAttribute("uv");const s=new Ar({metalness:0,side:Mr}),i=new Ar({metalness:0}),n=e=="legacy"?cI:lI,r=new zh(16777215,n.topLight.intensity,28,2);r.position.set(...n.topLight.position),this.add(r);const a=new ge(t,s);a.position.set(...n.room.position),a.scale.set(...n.room.scale),this.add(a);for(const A of n.boxes){const c=new ge(t,i);c.position.set(...A.position),c.rotation.set(0,A.rotation,0),c.scale.set(...A.scale),this.add(c)}for(const A of n.lights){const c=new ge(t,this.createAreaLightMaterial(A.intensity));c.position.set(...A.position),c.scale.set(...A.scale),this.add(c)}}createAreaLightMaterial(e){const t=new Xe;return t.color.setScalar(e),t}}const hI=.04,gs=20,uI=/\.hdr(\.js)?$/;class cl{constructor(e){this.threeRenderer=e,this.lottieLoaderUrl="",this.withCredentials=!1,this._ldrLoader=null,this._imageLoader=null,this._hdrLoader=null,this._lottieLoader=null,this.generatedEnvironmentMap=null,this.generatedEnvironmentMapAlt=null,this.skyboxCache=new Map,this.blurMaterial=null,this.blurScene=null}get ldrLoader(){return this._ldrLoader==null&&(this._ldrLoader=new Yh),this._ldrLoader.setWithCredentials(this.withCredentials),this._ldrLoader}get imageLoader(){return this._imageLoader==null&&(this._imageLoader=new aI(this.threeRenderer)),this._imageLoader.setWithCredentials(this.withCredentials),this._imageLoader}get hdrLoader(){return this._hdrLoader==null&&(this._hdrLoader=new AI,this._hdrLoader.setDataType(De)),this._hdrLoader.setWithCredentials(this.withCredentials),this._hdrLoader}async getLottieLoader(){if(this._lottieLoader==null){const{LottieLoader:e}=await Dd(()=>import(this.lottieLoaderUrl),__vite__mapDeps([]),import.meta.url);this._lottieLoader=new e}return this._lottieLoader.setWithCredentials(this.withCredentials),this._lottieLoader}async loadImage(e){const t=await new Promise((s,i)=>this.ldrLoader.load(e,s,()=>{},i));return t.name=e,t.flipY=!1,t}async loadLottie(e,t){const s=await this.getLottieLoader();s.setQuality(t);const i=await new Promise((n,r)=>s.load(e,n,()=>{},r));return i.name=e,i}async loadEquirect(e,t=()=>{}){try{const s=uI.test(e),i=s?this.hdrLoader:this.imageLoader,n=await new Promise((r,a)=>i.load(e,A=>{const{renderTarget:c}=A;if(c!=null){const{texture:l}=c;A.dispose(!1),r(l)}else r(A)},A=>{t(A.loaded/A.total*.9)},a));return t(1),n.name=e,n.mapping=_g,s||(n.colorSpace=be),n}finally{t&&t(1)}}async generateEnvironmentMapAndSkybox(e=null,t=null,s=()=>{}){const i=t!=="legacy";(t==="legacy"||t==="neutral")&&(t=null),t=fu(t);let n=Promise.resolve(null),r;e&&(n=this.loadEquirectFromUrl(e,s)),t?r=this.loadEquirectFromUrl(t,s):e?r=this.loadEquirectFromUrl(e,s):r=i?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[a,A]=await Promise.all([r,n]);if(a==null)throw new Error("Failed to load environment map.");return{environmentMap:a,skybox:A}}async loadEquirectFromUrl(e,t){if(!this.skyboxCache.has(e)){const s=this.loadEquirect(e,t);this.skyboxCache.set(e,s)}return this.skyboxCache.get(e)}async GenerateEnvironmentMap(e,t){await ff();const s=this.threeRenderer,i=new Xh(256,{generateMipmaps:!1,type:De,format:_e,colorSpace:ie,depthBuffer:!0}),n=new _A(.1,100,i),r=n.renderTarget.texture;r.name=t;const a=s.outputColorSpace,A=s.toneMapping;return s.toneMapping=Dg,s.outputColorSpace=ie,n.update(s,e),this.blurCubemap(i,hI),s.toneMapping=A,s.outputColorSpace=a,r}async loadGeneratedEnvironmentMap(){return this.generatedEnvironmentMap==null&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new Al("legacy"),"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return this.generatedEnvironmentMapAlt==null&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new Al("neutral"),"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(e,t){if(this.blurMaterial==null){this.blurMaterial=this.getBlurShader(gs);const i=new tu,n=new ge(i,this.blurMaterial);this.blurScene=new Ut,this.blurScene.add(n)}const s=e.clone();this.halfblur(e,s,t,"latitudinal"),this.halfblur(s,e,t,"longitudinal")}halfblur(e,t,s,i){const r=e.width,a=isFinite(s)?Math.PI/(2*r):2*Math.PI/(2*gs-1),A=s/a,c=isFinite(s)?1+Math.floor(3*A):gs;c>gs&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${c} samples when the maximum is set to ${gs}`);const l=[];let h=0;for(let g=0;g<gs;++g){const p=g/A,f=Math.exp(-p*p/2);l.push(f),g==0?h+=f:g<c&&(h+=2*f)}for(let g=0;g<l.length;g++)l[g]=l[g]/h;const u=this.blurMaterial.uniforms;u.envMap.value=e.texture,u.samples.value=c,u.weights.value=l,u.latitudinal.value=i==="latitudinal",u.dTheta.value=a,new _A(.1,100,t).update(this.threeRenderer,this.blurScene)}getBlurShader(e){const t=new Float32Array(e),s=new R(0,1,0);return new $s({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},poleAxis:{value:s}},vertexShader:`
      
      varying vec3 vOutputDirection;
  
      void main() {
  
        vOutputDirection = vec3( position );
        gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  
      }
    `,fragmentShader:`
        varying vec3 vOutputDirection;
  
        uniform samplerCube envMap;
        uniform int samples;
        uniform float weights[ n ];
        uniform bool latitudinal;
        uniform float dTheta;
        uniform vec3 poleAxis;
  
        vec3 getSample( float theta, vec3 axis ) {
  
          float cosTheta = cos( theta );
          // Rodrigues' axis-angle rotation
          vec3 sampleDirection = vOutputDirection * cosTheta
            + cross( axis, vOutputDirection ) * sin( theta )
            + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  
          return vec3( textureCube( envMap, sampleDirection ) );
  
        }
  
        void main() {
  
          vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  
          if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  
            axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  
          }
  
          axis = normalize( axis );
  
          gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
          gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  
          for ( int i = 1; i < n; i++ ) {
  
            if ( i >= samples ) {
  
              break;
  
            }
  
            float theta = dTheta * float( i );
            gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
            gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  
          }
        }
      `,blending:eu,depthTest:!1,depthWrite:!1,side:Mr})}async dispose(){for(const[,e]of this.skyboxCache)(await e).dispose();this.generatedEnvironmentMap!=null&&((await this.generatedEnvironmentMap).dispose(),this.generatedEnvironmentMap=null),this.generatedEnvironmentMapAlt!=null&&((await this.generatedEnvironmentMapAlt).dispose(),this.generatedEnvironmentMapAlt=null),this.blurMaterial!=null&&this.blurMaterial.dispose()}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const dI=.2,So=40,bo=60,ll=5,fs=[1,.79,.62,.5,.4,.31,.25],gI=3,nd="high-performance",fI=1.3;class Ge extends Tr{constructor(e){super(),this.loader=new re(Xm),this.width=0,this.height=0,this.dpr=1,this.scenes=new Set,this.multipleScenesVisible=!1,this.lastTick=performance.now(),this.renderedLastFrame=!1,this.scaleStep=0,this.lastStep=gI,this.avgFrameDuration=(bo+So)/2,this.onWebGLContextLost=t=>{this.dispatchEvent({type:"contextlost",sourceEvent:t})},this.onWebGLContextRestored=()=>{var t;(t=this.textureUtils)===null||t===void 0||t.dispose(),this.textureUtils=new cl(this.threeRenderer);for(const s of this.scenes)s.element[gr]()},this.dpr=Ra(),this.canvas3D=document.createElement("canvas"),this.canvas3D.id="webgl-canvas",this.canvas3D.classList.add("show"),DA.tonemapping_pars_fragment=DA.tonemapping_pars_fragment.replace("vec3 CustomToneMapping( vec3 color ) { return color; }",`
      float startCompression = 0.8 - 0.04;
      float desaturation = 0.15;
      vec3 CustomToneMapping( vec3 color ) {
        color *= toneMappingExposure;

        float x = min(color.r, min(color.g, color.b));
        float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
        color -= offset;

        float peak = max(color.r, max(color.g, color.b));
        if (peak < startCompression) return color;

        float d = 1. - startCompression;
        float newPeak = 1. - d * d / (peak + d - startCompression);
        color *= newPeak / peak;

        float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
        return mix(color, vec3(1, 1, 1), g);
      }`);try{this.threeRenderer=new rA({canvas:this.canvas3D,alpha:!0,antialias:!0,powerPreference:e.powerPreference,preserveDrawingBuffer:!0}),this.threeRenderer.autoClear=!0,this.threeRenderer.setPixelRatio(1),this.threeRenderer.debug={checkShaderErrors:!!e.debug,onShaderError:null},this.threeRenderer.toneMapping=iA}catch(t){console.warn(t)}this.arRenderer=new Ym(this),this.textureUtils=this.canRender?new cl(this.threeRenderer):null,re.initializeKTX2Loader(this.threeRenderer),this.canvas3D.addEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.addEventListener("webglcontextrestored",this.onWebGLContextRestored),this.updateRendererSize()}static get singleton(){return this._singleton}static resetSingleton(){const e=this._singleton.dispose();for(const t of e)t.disconnectedCallback();this._singleton=new Ge({powerPreference:(self.ModelViewerElement||{}).powerPreference||nd,debug:pu()});for(const t of e)t.connectedCallback()}get canRender(){return this.threeRenderer!=null}get scaleFactor(){return fs[this.scaleStep]}set minScale(e){let t=1;for(;t<fs.length&&!(fs[t]<e);)++t;this.lastStep=t-1}registerScene(e){this.scenes.add(e),e.forceRescale();const t=new ce;this.threeRenderer.getSize(t),e.canvas.width=t.x,e.canvas.height=t.y,this.canRender&&this.scenes.size>0&&this.threeRenderer.setAnimationLoop((s,i)=>this.render(s,i))}unregisterScene(e){this.scenes.delete(e),this.canvas3D.parentElement===e.canvas.parentElement&&e.canvas.parentElement.removeChild(this.canvas3D),this.canRender&&this.scenes.size===0&&this.threeRenderer.setAnimationLoop(null)}displayCanvas(e){return this.multipleScenesVisible?e.element[Ha]:this.canvas3D}countVisibleScenes(){const{canvas3D:e}=this;let t=0,s=null;for(const n of this.scenes){const{element:r}=n;r.modelIsVisible&&n.externalRenderer==null&&++t,e.parentElement===n.canvas.parentElement&&(s=n)}const i=t>1;if(s!=null){const n=i&&!this.multipleScenesVisible,r=!s.element.modelIsVisible;if(n||r){const{width:a,height:A}=this.sceneSize(s);this.copyPixels(s,a,A),e.parentElement.removeChild(e)}}this.multipleScenesVisible=i}updateRendererSize(){var e;const t=Ra();if(t!==this.dpr)for(const n of this.scenes){const{element:r}=n;r[Fs](r.getBoundingClientRect())}let s=0,i=0;for(const n of this.scenes)s=Math.max(s,n.width),i=Math.max(i,n.height);if(!(s===this.width&&i===this.height&&t===this.dpr)){this.width=s,this.height=i,this.dpr=t,s=Math.ceil(s*t),i=Math.ceil(i*t),this.canRender&&this.threeRenderer.setSize(s,i,!1);for(const n of this.scenes){const{canvas:r}=n;r.width=s,r.height=i,n.forceRescale(),(e=n.effectRenderer)===null||e===void 0||e.setSize(s,i)}}}updateRendererScale(e){const t=this.scaleStep;this.avgFrameDuration+=We(dI*(e-this.avgFrameDuration),-ll,ll),this.avgFrameDuration>bo?++this.scaleStep:this.avgFrameDuration<So&&this.scaleStep>0&&--this.scaleStep,this.scaleStep=Math.min(this.scaleStep,this.lastStep),t!==this.scaleStep&&(this.avgFrameDuration=(bo+So)/2)}shouldRender(e){if(e.shouldRender())e.scaleStep!=this.scaleStep&&(e.scaleStep=this.scaleStep,this.rescaleCanvas(e));else if(e.scaleStep!=0)e.scaleStep=0,this.rescaleCanvas(e);else return!1;return!0}rescaleCanvas(e){const t=fs[e.scaleStep],s=Math.ceil(this.width/t),i=Math.ceil(this.height/t),{style:n}=e.canvas;n.width=`${s}px`,n.height=`${i}px`,this.canvas3D.style.width=`${s}px`,this.canvas3D.style.height=`${i}px`;const r=this.dpr*t,a=t<1?"GPU throttling":this.dpr!==window.devicePixelRatio?"No meta viewport tag":"";e.element.dispatchEvent(new CustomEvent("render-scale",{detail:{reportedDpr:window.devicePixelRatio,renderedDpr:r,minimumDpr:this.dpr*fs[this.lastStep],pixelWidth:Math.ceil(e.width*r),pixelHeight:Math.ceil(e.height*r),reason:a}}))}sceneSize(e){const{dpr:t}=this,s=fs[e.scaleStep],i=Math.min(Math.ceil(e.width*s*t),this.canvas3D.width),n=Math.min(Math.ceil(e.height*s*t),this.canvas3D.height);return{width:i,height:n}}copyPixels(e,t,s){const i=e.context;if(i==null){console.log("could not acquire 2d context");return}i.clearRect(0,0,t,s),i.drawImage(this.canvas3D,0,0,t,s,0,0,t,s),e.canvas.classList.add("show")}orderedScenes(){const e=[];for(const t of[!1,!0])for(const s of this.scenes)s.element.modelIsVisible===t&&e.push(s);return e}get isPresenting(){return this.arRenderer.isPresenting}preRender(e,t,s){const{element:i,exposure:n,toneMapping:r}=e;i[nt](t,s);const a=typeof n=="number"&&!Number.isNaN(n),A=i.environmentImage,c=i.skyboxImage,l=r===Vh&&(A==="neutral"||A==="legacy"||!A&&!c);this.threeRenderer.toneMappingExposure=(a?n:1)*(l?fI:1)}render(e,t){if(t!=null){this.arRenderer.onWebXRFrame(e,t);return}const s=e-this.lastTick;if(this.lastTick=e,!this.canRender||this.isPresenting)return;this.countVisibleScenes(),this.updateRendererSize(),this.renderedLastFrame&&(this.updateRendererScale(s),this.renderedLastFrame=!1);const{canvas3D:i}=this;for(const n of this.orderedScenes()){const{element:r}=n;if(!r.loaded||!r.modelIsVisible&&n.renderCount>0||(this.preRender(n,e,s),!this.shouldRender(n)))continue;if(n.externalRenderer!=null){const c=n.getCamera();c.updateMatrix();const{matrix:l,projectionMatrix:h}=c,u=l.elements.slice(),d=n.getTarget();u[12]+=d.x,u[13]+=d.y,u[14]+=d.z,n.externalRenderer.render({viewMatrix:u,projectionMatrix:h.elements});continue}if(!r.modelIsVisible&&!this.multipleScenesVisible)for(const c of this.scenes)c.element.modelIsVisible&&c.queueRender();const{width:a,height:A}=this.sceneSize(n);n.renderShadow(this.threeRenderer),this.threeRenderer.setRenderTarget(null),this.threeRenderer.setViewport(0,Math.ceil(this.height*this.dpr)-A,a,A),n.effectRenderer!=null?n.effectRenderer.render(s):(this.threeRenderer.autoClear=!0,this.threeRenderer.toneMapping=n.toneMapping,this.threeRenderer.render(n,n.camera)),this.multipleScenesVisible||!n.element.modelIsVisible&&n.renderCount===0?this.copyPixels(n,a,A):i.parentElement!==n.canvas.parentElement&&(n.canvas.parentElement.appendChild(i),n.canvas.classList.remove("show")),n.hasRendered(),++n.renderCount,this.renderedLastFrame=!0}}dispose(){this.textureUtils!=null&&this.textureUtils.dispose(),this.threeRenderer!=null&&this.threeRenderer.dispose(),this.textureUtils=null,this.threeRenderer=null;const e=[];for(const t of this.scenes)e.push(t.element);return this.canvas3D.removeEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.removeEventListener("webglcontextrestored",this.onWebGLContextRestored),e}}Ge._singleton=new Ge({powerPreference:(self.ModelViewerElement||{}).powerPreference||nd,debug:pu()});/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const G=Symbol("correlatedObjects"),z=Symbol("onUpdate");class en{constructor(e,t=null){this[z]=e,this[G]=t}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const hl=new Xe,pI=new Ws(2,2);let mI=0;const Ce=Symbol("threeTexture"),ul=Symbol("threeTextures");let II=class extends en{get[Ce](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get[ul](){return this[G]}constructor(e,t){super(e,new Set(t?[t]:[])),this[Ce].image.src||(this[Ce].image.src=t.name?t.name:"adhoc_image"+mI++),this[Ce].image.name||(this[Ce].image.name=t&&t.image&&t.image.src?t.image.src.split("/").pop():"adhoc_image")}get name(){return this[Ce].image.name||""}get uri(){return this[Ce].image.src}get bufferView(){return this[Ce].image.bufferView}get element(){const e=this[Ce];if(e&&(e.isCanvasTexture||e.isVideoTexture))return e.image}get animation(){const e=this[Ce];if(e&&e.isCanvasTexture&&e.animation)return e.animation}get type(){return this.uri!=null?"external":"embedded"}set name(e){for(const t of this[ul])t.image.name=e}update(){const e=this[Ce];e&&e.isCanvasTexture&&!e.animation&&(this[Ce].needsUpdate=!0,this[z]())}async createThumbnail(e,t){const s=new Ut;hl.map=this[Ce];const i=new ge(pI,hl);s.add(i);const n=new yr(-1,1,1,-1,0,1),{threeRenderer:r}=Ge.singleton,a=new zi(e,t);r.setRenderTarget(a),r.render(s,n),r.setRenderTarget(null);const A=new Uint8Array(e*t*4);r.readRenderTargetPixels(a,0,0,e,t,A),_t.width=e,_t.height=t;const c=_t.getContext("2d"),l=c.createImageData(e,t);return l.data.set(A),c.putImageData(l,0,0),new Promise(async(h,u)=>{_t.toBlob(d=>{if(!d)return u("Failed to capture thumbnail.");h(URL.createObjectURL(d))},"image/png")})}};var ae;(function(o){o[o.Nearest=9728]="Nearest",o[o.Linear=9729]="Linear",o[o.NearestMipmapNearest=9984]="NearestMipmapNearest",o[o.LinearMipmapNearest=9985]="LinearMipmapNearest",o[o.NearestMipmapLinear=9986]="NearestMipmapLinear",o[o.LinearMipmapLinear=9987]="LinearMipmapLinear"})(ae||(ae={}));var Ft;(function(o){o[o.ClampToEdge=33071]="ClampToEdge",o[o.MirroredRepeat=33648]="MirroredRepeat",o[o.Repeat=10497]="Repeat"})(Ft||(Ft={}));/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const dl=new Map([[Ft.Repeat,Nt],[Ft.ClampToEdge,Pe],[Ft.MirroredRepeat,Sr]]),Na=new Map([[Nt,Ft.Repeat],[Pe,Ft.ClampToEdge],[Sr,Ft.MirroredRepeat]]),EI=new Map([[ae.Nearest,js],[ae.Linear,de],[ae.NearestMipmapNearest,xr],[ae.LinearMipmapNearest,vr],[ae.NearestMipmapLinear,Qr],[ae.LinearMipmapLinear,Js]]),rd=new Map([[js,ae.Nearest],[de,ae.Linear],[xr,ae.NearestMipmapNearest],[vr,ae.LinearMipmapNearest],[Qr,ae.NearestMipmapLinear],[Js,ae.LinearMipmapLinear]]),CI=new Map([[ae.Nearest,js],[ae.Linear,de]]),od=new Map([[js,ae.Nearest],[de,ae.Linear]]),BI=o=>rd.has(o),yI=o=>od.has(o),wI=o=>Na.has(o),xI=(o,e)=>{switch(o){case"minFilter":return BI(e);case"magFilter":return yI(e);case"wrapS":case"wrapT":return wI(e);case"rotation":case"repeat":case"offset":return!0;default:throw new Error(`Cannot configure property "${o}" on Sampler`)}},At=Symbol("threeTexture"),gl=Symbol("threeTextures"),yt=Symbol("setProperty");class vI extends en{get[At](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get[gl](){return this[G]}constructor(e,t){super(e,new Set(t?[t]:[]))}get name(){return this[At].name||""}get minFilter(){return rd.get(this[At].minFilter)}get magFilter(){return od.get(this[At].magFilter)}get wrapS(){return Na.get(this[At].wrapS)}get wrapT(){return Na.get(this[At].wrapT)}get rotation(){return this[At].rotation}get scale(){return $a(this[At].repeat)}get offset(){return $a(this[At].offset)}setMinFilter(e){this[yt]("minFilter",EI.get(e))}setMagFilter(e){this[yt]("magFilter",CI.get(e))}setWrapS(e){this[yt]("wrapS",dl.get(e))}setWrapT(e){this[yt]("wrapT",dl.get(e))}setRotation(e){e==null&&(e=0),this[yt]("rotation",e)}setScale(e){e==null&&(e={u:1,v:1}),this[yt]("repeat",new ce(e.u,e.v))}setOffset(e){e==null&&(e={u:0,v:0}),this[yt]("offset",new ce(e.u,e.v))}[yt](e,t){if(xI(e,t))for(const s of this[gl])s[e]=t,s.needsUpdate=!0;this[z]()}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const fl=Symbol("image"),pl=Symbol("sampler"),ml=Symbol("threeTexture");class ad extends en{constructor(e,t){super(e,new Set(t?[t]:[])),this[pl]=new vI(e,t),this[fl]=new II(e,t)}get[ml](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get name(){return this[ml].name||""}set name(e){for(const t of this[G])t.name=e}get sampler(){return this[pl]}get source(){return this[fl]}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Ad,cd,ld;const jt=Symbol("texture"),Wt=Symbol("transform"),To=Symbol("materials"),Il=Symbol("usage"),ps=Symbol("onUpdate"),_i=Symbol("activeVideo");var k;(function(o){o[o.Base=0]="Base",o[o.MetallicRoughness=1]="MetallicRoughness",o[o.Normal=2]="Normal",o[o.Occlusion=3]="Occlusion",o[o.Emissive=4]="Emissive",o[o.Clearcoat=5]="Clearcoat",o[o.ClearcoatRoughness=6]="ClearcoatRoughness",o[o.ClearcoatNormal=7]="ClearcoatNormal",o[o.SheenColor=8]="SheenColor",o[o.SheenRoughness=9]="SheenRoughness",o[o.Transmission=10]="Transmission",o[o.Thickness=11]="Thickness",o[o.Specular=12]="Specular",o[o.SpecularColor=13]="SpecularColor",o[o.Iridescence=14]="Iridescence",o[o.IridescenceThickness=15]="IridescenceThickness",o[o.Anisotropy=16]="Anisotropy"})(k||(k={}));class Us{constructor(e,t,s,i){this[Ad]=null,this[cd]={rotation:0,scale:new ce(1,1),offset:new ce(0,0)},this[ld]=!1,s&&(this[Wt].rotation=s.rotation,this[Wt].scale.copy(s.repeat),this[Wt].offset.copy(s.offset),this[jt]=new ad(e,s)),this[ps]=e,this[To]=i,this[Il]=t}get texture(){return this[jt]}setTexture(e){var t,s;const i=e!=null?e.source[Ce]:null,n=(t=this[jt])===null||t===void 0?void 0:t.source[Ce];if(n!=null&&n.isVideoTexture?this[_i]=!1:!((s=this[jt])===null||s===void 0)&&s.source.animation&&this[jt].source.animation.removeEventListener("enterFrame",this[ps]),this[jt]=e,i!=null&&i.isVideoTexture){const a=i.image;if(this[_i]=!0,a.requestVideoFrameCallback!=null){const A=()=>{this[_i]&&(this[ps](),a.requestVideoFrameCallback(A))};a.requestVideoFrameCallback(A)}else{const A=()=>{this[_i]&&(this[ps](),requestAnimationFrame(A))};requestAnimationFrame(A)}}else(e==null?void 0:e.source.animation)!=null&&e.source.animation.addEventListener("enterFrame",this[ps]);let r=be;if(this[To])for(const a of this[To]){switch(this[Il]){case k.Base:a.map=i;break;case k.MetallicRoughness:r=ie,a.metalnessMap=i,a.roughnessMap=i;break;case k.Normal:r=ie,a.normalMap=i;break;case k.Occlusion:r=ie,a.aoMap=i;break;case k.Emissive:a.emissiveMap=i;break;case k.Clearcoat:a.clearcoatMap=i;break;case k.ClearcoatRoughness:a.clearcoatRoughnessMap=i;break;case k.ClearcoatNormal:a.clearcoatNormalMap=i;break;case k.SheenColor:a.sheenColorMap=i;break;case k.SheenRoughness:a.sheenRoughnessMap=i;break;case k.Transmission:a.transmissionMap=i;break;case k.Thickness:a.thicknessMap=i;break;case k.Specular:a.specularIntensityMap=i;break;case k.SpecularColor:a.specularColorMap=i;break;case k.Iridescence:a.iridescenceMap=i;break;case k.IridescenceThickness:a.iridescenceThicknessMap=i;break;case k.Anisotropy:a.anisotropyMap=i;break}a.needsUpdate=!0}i&&(i.colorSpace=r,i.rotation=this[Wt].rotation,i.repeat=this[Wt].scale,i.offset=this[Wt].offset),this[ps]()}}Ad=jt,cd=Wt,ld=_i;/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const hi=Symbol("threeMaterial"),Cn=Symbol("threeMaterials"),El=Symbol("baseColorTexture"),Cl=Symbol("metallicRoughnessTexture");class QI extends en{constructor(e,t){super(e,t);const{map:s,metalnessMap:i}=t.values().next().value;this[El]=new Us(e,k.Base,s,t),this[Cl]=new Us(e,k.MetallicRoughness,i,t)}get[Cn](){return this[G]}get[hi](){var e;return(e=this[G])===null||e===void 0?void 0:e.values().next().value}get baseColorFactor(){const e=[0,0,0,this[hi].opacity];return this[hi].color.toArray(e),e}get metallicFactor(){return this[hi].metalness}get roughnessFactor(){return this[hi].roughness}get baseColorTexture(){return this[El]}get metallicRoughnessTexture(){return this[Cl]}setBaseColorFactor(e){const t=new Ke;e instanceof Array?t.fromArray(e):t.set(e);for(const s of this[Cn])s.color.set(t),e instanceof Array?s.opacity=e[3]:(e=[0,0,0,s.opacity],t.toArray(e));this[z]()}setMetallicFactor(e){for(const t of this[Cn])t.metalness=e;this[z]()}setRoughnessFactor(e){for(const t of this[Cn])t.roughness=e;this[z]()}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Bl,yl;const wl=Symbol("pbrMetallicRoughness"),xl=Symbol("normalTexture"),vl=Symbol("occlusionTexture"),Ql=Symbol("emissiveTexture"),J=Symbol("backingThreeMaterial"),Sl=Symbol("applyAlphaCutoff"),Mo=Symbol("getAlphaMode"),ms=Symbol("lazyLoadGLTFInfo"),Ro=Symbol("initialize"),ka=Symbol("getLoadedMaterial"),F=Symbol("ensureMaterialIsLoaded"),bl=Symbol("gltfIndex"),Di=Symbol("setActive"),tr=Symbol("variantIndices"),_o=Symbol("isActive"),sr=Symbol("variantSet"),Tl=Symbol("modelVariants"),Do=Symbol("name"),xe=Symbol("pbrTextures");class Lo extends en{constructor(e,t,s,i,n,r,a=void 0){super(e,n),this[Bl]=new Set,this[yl]=new Map,this[bl]=t,this[_o]=s,this[Tl]=i,this[Do]=r,a==null?this[Ro]():this[ms]=a}get[(Bl=sr,yl=xe,J)](){return this[G].values().next().value}[Ro](){const e=this[z],t=this[G];this[wl]=new QI(e,t);const{normalMap:s,aoMap:i,emissiveMap:n}=t.values().next().value;this[xl]=new Us(e,k.Normal,s,t),this[vl]=new Us(e,k.Occlusion,i,t),this[Ql]=new Us(e,k.Emissive,n,t);const r=a=>{this[xe].set(a,new Us(e,a,null,t))};r(k.Clearcoat),r(k.ClearcoatRoughness),r(k.ClearcoatNormal),r(k.SheenColor),r(k.SheenRoughness),r(k.Transmission),r(k.Thickness),r(k.Specular),r(k.SpecularColor),r(k.Iridescence),r(k.IridescenceThickness),r(k.Anisotropy)}async[ka](){if(this[ms]!=null){const{set:e,material:t}=await this[ms].doLazyLoad();return this[G]=e,this[Ro](),this[ms]=void 0,this.ensureLoaded=async()=>{},t}return this[G].values().next().value}colorFromRgb(e){const t=new Ke;return e instanceof Array?t.fromArray(e):t.set(e),t}[F](){if(this[ms]!=null)throw new Error(`Material "${this.name}" has not been loaded, call 'await
    myMaterial.ensureLoaded()' before using an unloaded material.`)}async ensureLoaded(){await this[ka]()}get isLoaded(){return this[ms]==null}get isActive(){return this[_o]}[Di](e){this[_o]=e}get name(){return this[Do]||""}set name(e){if(this[Do]=e,this[G]!=null)for(const t of this[G])t.name=e}get pbrMetallicRoughness(){return this[F](),this[wl]}get normalTexture(){return this[F](),this[xl]}get occlusionTexture(){return this[F](),this[vl]}get emissiveTexture(){return this[F](),this[Ql]}get emissiveFactor(){return this[F](),this[J].emissive.toArray()}get index(){return this[bl]}[tr](){return this[sr]}hasVariant(e){const t=this[Tl].get(e);return t!=null&&this[sr].has(t.index)}setEmissiveFactor(e){this[F]();const t=this.colorFromRgb(e);for(const s of this[G])s.emissive.set(t);this[z]()}[Mo](){return this[J].transparent?"BLEND":this[J].alphaTest>0?"MASK":"OPAQUE"}[Sl](){this[F]();for(const e of this[G])this[Mo]()==="MASK"?e.alphaTest==null&&(e.alphaTest=.5):e.alphaTest=void 0,e.needsUpdate=!0}setAlphaCutoff(e){this[F]();for(const t of this[G])t.alphaTest=e,t.needsUpdate=!0;this[Sl](),this[z]()}getAlphaCutoff(){return this[F](),this[J].alphaTest}setDoubleSided(e){this[F]();for(const t of this[G])t.side=e?kt:qi,t.needsUpdate=!0;this[z]()}getDoubleSided(){return this[F](),this[J].side==kt}setAlphaMode(e){this[F]();const t=(s,i)=>{s.transparent=i,s.depthWrite=!i};for(const s of this[G])t(s,e==="BLEND"),e==="MASK"?s.alphaTest=.5:s.alphaTest=void 0,s.needsUpdate=!0;this[z]()}getAlphaMode(){return this[F](),this[Mo]()}get emissiveStrength(){return this[F](),this[J].emissiveIntensity}setEmissiveStrength(e){this[F]();for(const t of this[G])t.emissiveIntensity=e;this[z]()}get clearcoatFactor(){return this[F](),this[J].clearcoat}get clearcoatRoughnessFactor(){return this[F](),this[J].clearcoatRoughness}get clearcoatTexture(){return this[F](),this[xe].get(k.Clearcoat)}get clearcoatRoughnessTexture(){return this[F](),this[xe].get(k.ClearcoatRoughness)}get clearcoatNormalTexture(){return this[F](),this[xe].get(k.ClearcoatNormal)}get clearcoatNormalScale(){return this[F](),this[J].clearcoatNormalScale.x}setClearcoatFactor(e){this[F]();for(const t of this[G])t.clearcoat=e;this[z]()}setClearcoatRoughnessFactor(e){this[F]();for(const t of this[G])t.clearcoatRoughness=e;this[z]()}setClearcoatNormalScale(e){this[F]();for(const t of this[G])t.clearcoatNormalScale=new ce(e,e);this[z]()}get ior(){return this[F](),this[J].ior}setIor(e){this[F]();for(const t of this[G])t.ior=e;this[z]()}get sheenColorFactor(){return this[F](),this[J].sheenColor.toArray()}get sheenColorTexture(){return this[F](),this[xe].get(k.SheenColor)}get sheenRoughnessFactor(){return this[F](),this[J].sheenRoughness}get sheenRoughnessTexture(){return this[F](),this[xe].get(k.SheenRoughness)}setSheenColorFactor(e){this[F]();const t=this.colorFromRgb(e);for(const s of this[G])s.sheenColor.set(t),s.sheen=1;this[z]()}setSheenRoughnessFactor(e){this[F]();for(const t of this[G])t.sheenRoughness=e,t.sheen=1;this[z]()}get transmissionFactor(){return this[F](),this[J].transmission}get transmissionTexture(){return this[F](),this[xe].get(k.Transmission)}setTransmissionFactor(e){this[F]();for(const t of this[G])t.transmission=e;this[z]()}get thicknessFactor(){return this[F](),this[J].thickness}get thicknessTexture(){return this[F](),this[xe].get(k.Thickness)}get attenuationDistance(){return this[F](),this[J].attenuationDistance}get attenuationColor(){return this[F](),this[J].attenuationColor.toArray()}setThicknessFactor(e){this[F]();for(const t of this[G])t.thickness=e;this[z]()}setAttenuationDistance(e){this[F]();for(const t of this[G])t.attenuationDistance=e;this[z]()}setAttenuationColor(e){this[F]();const t=this.colorFromRgb(e);for(const s of this[G])s.attenuationColor.set(t);this[z]()}get specularFactor(){return this[F](),this[J].specularIntensity}get specularTexture(){return this[F](),this[xe].get(k.Specular)}get specularColorFactor(){return this[F](),this[J].specularColor.toArray()}get specularColorTexture(){return this[F](),this[xe].get(k.SheenColor)}setSpecularFactor(e){this[F]();for(const t of this[G])t.specularIntensity=e;this[z]()}setSpecularColorFactor(e){this[F]();const t=this.colorFromRgb(e);for(const s of this[G])s.specularColor.set(t);this[z]()}get iridescenceFactor(){return this[F](),this[J].iridescence}get iridescenceTexture(){return this[F](),this[xe].get(k.Iridescence)}get iridescenceIor(){return this[F](),this[J].iridescenceIOR}get iridescenceThicknessMinimum(){return this[F](),this[J].iridescenceThicknessRange[0]}get iridescenceThicknessMaximum(){return this[F](),this[J].iridescenceThicknessRange[1]}get iridescenceThicknessTexture(){return this[F](),this[xe].get(k.IridescenceThickness)}setIridescenceFactor(e){this[F]();for(const t of this[G])t.iridescence=e;this[z]()}setIridescenceIor(e){this[F]();for(const t of this[G])t.iridescenceIOR=e;this[z]()}setIridescenceThicknessMinimum(e){this[F]();for(const t of this[G])t.iridescenceThicknessRange[0]=e;this[z]()}setIridescenceThicknessMaximum(e){this[F]();for(const t of this[G])t.iridescenceThicknessRange[1]=e;this[z]()}get anisotropyStrength(){return this[F](),this[J].anisotropy}get anisotropyRotation(){return this[F](),this[J].anisotropyRotation}get anisotropyTexture(){return this[F](),this[xe].get(k.Anisotropy)}setAnisotropyStrength(e){this[F]();for(const t of this[G])t.anisotropy=e;this[z]()}setAnisotropyRotation(e){this[F]();for(const t of this[G])t.anisotropyRotation=e;this[z]()}}let hd=class{constructor(e){this.name="",this.children=new Array,this.name=e}};class Fo extends hd{constructor(e,t,s,i){super(e.name),this.materials=new Map,this.variantToMaterialMap=new Map,this.initialMaterialIdx=0,this.activeMaterialIdx=0,this.mesh=e;const{gltf:n,threeGLTF:r,threeObjectMap:a}=i;this.parser=r.parser,this.modelVariants=s,this.mesh.userData.variantData=s;const A=a.get(e.material);A.materials!=null?this.initialMaterialIdx=this.activeMaterialIdx=A.materials:console.error(`Primitive (${e.name}) missing initial material reference.`);const c=e.userData.associations||{};if(c.meshes==null){console.error("Mesh is missing primitive index association");return}const u=((n.meshes||[])[c.meshes].primitives||[])[c.primitives];if(u==null){console.error("Mesh primitive definition is missing.");return}if(u.material!=null)this.materials.set(u.material,t[u.material]);else{const d=t.findIndex(g=>g.name==="Default");d>=0?this.materials.set(d,t[d]):console.warn("gltfPrimitive has no material!")}if(u.extensions&&u.extensions.KHR_materials_variants){const d=u.extensions.KHR_materials_variants,p=r.parser.json.extensions.KHR_materials_variants.variants;for(const f of d.mappings){const m=t[f.material];this.materials.set(f.material,m);for(const E of f.variants){const{name:w}=p[E];this.variantToMaterialMap.set(E,m),m[tr]().add(E),s.has(w)||s.set(w,{name:w,index:E})}}}}async setActiveMaterial(e){const t=this.materials.get(e);if(t!=null&&e!==this.activeMaterialIdx){this.mesh.material=await t[ka]();const{normalScale:s}=this.mesh.material;s!=null&&s.y*s.x<0!=(this.mesh.geometry.attributes.tangent==null)&&this.parser.assignFinalMaterial(this.mesh),this.activeMaterialIdx=e}return this.mesh.material}getActiveMaterial(){return this.materials.get(this.activeMaterialIdx)}getMaterial(e){return this.materials.get(e)}async enableVariant(e){if(e==null)return this.setActiveMaterial(this.initialMaterialIdx);if(this.variantToMaterialMap!=null&&this.modelVariants.has(e)){const t=this.modelVariants.get(e);return this.enableVariantHelper(t.index)}return null}async enableVariantHelper(e){if(this.variantToMaterialMap!=null&&e!=null){const t=this.variantToMaterialMap.get(e);if(t!=null)return this.setActiveMaterial(t.index)}return null}async instantiateVariants(){if(this.variantToMaterialMap!=null)for(const e of this.variantToMaterialMap.keys()){const t=this.mesh.userData.variantMaterials.get(e);if(t.material!=null)continue;const s=await this.enableVariantHelper(e);s!=null&&(t.material=s)}}get variantInfo(){return this.variantToMaterialMap}addVariant(e,t){if(!this.ensureVariantIsUnused(t))return!1;this.modelVariants.has(t)||this.modelVariants.set(t,{name:t,index:this.modelVariants.size});const i=this.modelVariants.get(t).index;return e[tr]().add(i),this.variantToMaterialMap.set(i,e),this.materials.set(e.index,e),this.updateVariantUserData(i,e),!0}deleteVariant(e){if(this.variantInfo.has(e)){this.variantInfo.delete(e);const t=this.mesh.userData.variantMaterials;t!=null&&t.delete(e)}}updateVariantUserData(e,t){t[tr]().add(e),this.mesh.userData.variantData=this.modelVariants,this.mesh.userData.variantMaterials=this.mesh.userData.variantMaterials||new Map,this.mesh.userData.variantMaterials.set(e,{material:t[G].values().next().value,gltfMaterialIndex:t.index})}ensureVariantIsUnused(e){const t=this.modelVariants.get(e);return t!=null&&this.variantInfo.has(t.index)?(console.warn(`Primitive cannot add variant '${e}' for this material, it already exists.`),!1):!0}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Ml,Rl,_l,Dl,Ll,Fl;const Kt=Symbol("materials"),Bn=Symbol("hierarchy"),Nl=Symbol("roots"),ct=Symbol("primitives"),ud=Symbol("prepareVariantsForExport"),dd=Symbol("switchVariant"),gd=Symbol("materialFromPoint"),Ua=Symbol("nodeFromPoint"),fd=Symbol("nodeFromIndex"),fe=Symbol("variantData"),Pa=Symbol("availableVariants"),No=Symbol("modelOnUpdate"),kl=Symbol("cloneMaterial");class SI{constructor(e,t,s,i){this.gltf=e,this.gltfElementMap=t,this.mapKey=s,this.doLazyLoad=i}}class bI{constructor(e,t=()=>{}){this[Ml]=new Array,this[Rl]=new Array,this[_l]=new Array,this[Dl]=new Array,this[Ll]=()=>{},this[Fl]=new Map,this[No]=t;const{gltf:s,threeGLTF:i,gltfElementMap:n}=e;for(const[A,c]of s.materials.entries()){const l=n.get(c);if(l!=null)this[Kt].push(new Lo(t,A,!0,this[fe],l,c.name));else{const u=(s.materials||[])[A],d=A,g=async()=>{const p=await i.parser.getDependency("material",d),f=new Set;return n.set(u,f),f.add(p),{set:f,material:p}};this[Kt].push(new Lo(t,A,!1,this[fe],l,c.name,new SI(s,n,u,g)))}}const r=new Map,a=new Array;for(const A of i.scene.children)a.push(A);for(;a.length>0;){const A=a.pop();let c=null;A instanceof ge?(c=new Fo(A,this.materials,this[fe],e),this[ct].push(c)):c=new hd(A.name);const l=r.get(A);l!=null?l.children.push(c):this[Nl].push(c),this[Bn].push(c);for(const h of A.children)a.push(h),r.set(A,c)}}get materials(){return this[Kt]}[(Ml=Kt,Rl=Bn,_l=Nl,Dl=ct,Ll=No,Fl=fe,Pa)](){const e=Array.from(this[fe].values());return e.sort((t,s)=>t.index-s.index),e.map(t=>t.name)}getMaterialByName(e){const t=this[Kt].filter(s=>s.name===e);return t.length>0?t[0]:null}[fd](e,t){const s=this[Bn].find(i=>{if(i instanceof Fo){const{meshes:n,primitives:r}=i.mesh.userData.associations;if(n==e&&r==t)return!0}return!1});return s??null}[Ua](e){return this[Bn].find(t=>t instanceof Fo&&t.mesh===e.object)}[gd](e){return this[Ua](e).getActiveMaterial()}async[dd](e){for(const t of this[ct])await t.enableVariant(e);for(const t of this.materials)t[Di](!1);for(const t of this[ct])this.materials[t.getActiveMaterial().index][Di](!0)}async[ud](){const e=new Array;for(const t of this[ct])e.push(t.instantiateVariants());await Promise.all(e)}[kl](e,t){const s=this.materials[e];s.isLoaded||console.error(`Cloning an unloaded material,
           call 'material.ensureLoaded() before cloning the material.`);const i=s[G],n=new Set;for(const[a,A]of i.entries()){const c=A.clone();c.name=t+(i.size>1?"_inst"+a:""),n.add(c)}const r=new Lo(this[No],this[Kt].length,!1,this[fe],n,t);return this[Kt].push(r),r}createMaterialInstanceForVariant(e,t,s,i=!0){let n=null;for(const r of this[ct]){const a=this[fe].get(s);a!=null&&r.variantInfo.has(a.index)||r.getMaterial(e)!=null&&(this.hasVariant(s)||this.createVariant(s),n==null&&(n=this[kl](e,t)),r.addVariant(n,s))}if(i&&n!=null){n[Di](!0),this.materials[e][Di](!1);for(const r of this[ct])r.enableVariant(s)}return n}createVariant(e){this[fe].has(e)?console.warn(`Variant '${e}'' already exists`):this[fe].set(e,{name:e,index:this[fe].size})}hasVariant(e){return this[fe].has(e)}setMaterialToVariant(e,t){if(this[Pa]().find(s=>s===t)==null){console.warn(`Can't add material to '${t}', the variant does not exist.'`);return}if(e<0||e>=this.materials.length){console.error("setMaterialToVariant(): materialIndex is out of bounds.");return}for(const s of this[ct]){const i=s.getMaterial(e);i!=null&&s.addVariant(i,t)}}updateVariantName(e,t){const s=this[fe].get(e);s!=null&&(s.name=t,this[fe].set(t,s),this[fe].delete(e))}deleteVariant(e){const t=this[fe].get(e);if(t!=null){for(const s of this.materials)s.hasVariant(e)&&s[sr].delete(t.index);for(const s of this[ct])s.deleteVariant(t.index);this[fe].delete(e)}}}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var ko=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const ir=Symbol("currentGLTF"),nr=Symbol("originalGltfJson"),Xt=Symbol("model"),Uo=Symbol("getOnUpdateMethod"),ui=Symbol("buildTexture"),TI=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this[e]=void 0,this[t]=null,this[s]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[Xt]}get availableVariants(){return this.model?this.model[Pa]():[]}get originalGltfJson(){return this[nr]}[(e=Xt,t=ir,s=nr,Uo)](){return()=>{this[me]()}}[ui](r){return r.colorSpace=be,r.wrapS=Nt,r.wrapT=Nt,new ad(this[Uo](),r)}async createTexture(r,a="image/png"){const{textureUtils:A}=this[q],c=await A.loadImage(r);return c.userData.mimeType=a,this[ui](c)}async createLottieTexture(r,a=1){const{textureUtils:A}=this[q],c=await A.loadLottie(r,a);return this[ui](c)}createVideoTexture(r){const a=document.createElement("video");a.crossOrigin=this.withCredentials?"use-credentials":"anonymous",a.src=r,a.muted=!0,a.playsInline=!0,a.loop=!0,a.play();const A=new Lg(a);return this[ui](A)}createCanvasTexture(){const r=document.createElement("canvas"),a=new Wh(r);return this[ui](a)}async updated(r){if(super.updated(r),r.has("variantName")){const a=this[ns].beginActivity("variant-update");a(.1);const A=this[Xt],{variantName:c}=this;A!=null&&(await A[dd](c),this[me](),this.dispatchEvent(new CustomEvent("variant-applied"))),a(1)}if(r.has("orientation")||r.has("scale")){if(!this.loaded)return;const a=this[D];a.applyTransform(),a.updateBoundingBox(),a.updateShadow(),this[q].arRenderer.onUpdateScene(),this[me]()}}[Gt](){super[Gt]();const{currentGLTF:r}=this[D];if(r!=null){const{correlatedSceneGraph:a}=r;a!=null&&r!==this[ir]&&(this[Xt]=new bI(a,this[Uo]()),this[nr]=JSON.parse(JSON.stringify(a.gltf))),"variants"in r.userData&&this.requestUpdate("variantName")}this[ir]=r}async exportScene(r){const a=this[D];return new Promise(async(A,c)=>{const l={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(l,r),l.animations=a.animations,l.truncateDrawRange=!0;const h=a.shadow;let u=!1;h!=null&&(u=h.visible,h.visible=!1),await this[Xt][ud](),new AA().register(g=>new Wp(g)).parse(a.model,g=>A(new Blob([l.binary?g:JSON.stringify(g)],{type:l.binary?"application/octet-stream":"application/json"})),()=>c("glTF export failed"),l),h!=null&&(h.visible=u)})}materialFromPoint(r,a){const A=this[Xt];if(A==null)return null;const c=this[D],l=c.getNDC(r,a),h=c.hitFromPoint(l);return h==null||h.face==null?null:A[gd](h)}}return ko([U({type:String,attribute:"variant-name"})],i.prototype,"variantName",void 0),ko([U({type:String,attribute:"orientation"})],i.prototype,"orientation",void 0),ko([U({type:String,attribute:"scale"})],i.prototype,"scale",void 0),i};/* @license
 * Copyright 2023 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class MI extends ge{constructor(){super(void 0,new Xe({depthWrite:!1})),this.height=0,this.radius=0,this.resolution=0,this.userData.noHit=!0}get map(){return this.material.map}set map(e){this.material.map=e}isUsable(){return this.height>0&&this.radius>0&&this.geometry!=null&&this.map!=null}updateGeometry(e=this.height,t=this.radius,s=128){(e!=this.height||t!=this.radius||s!=this.resolution)&&(this.height=e,this.radius=t,this.resolution=s,e>0&&t>0&&(this.geometry.dispose(),this.geometry=RI(e,t,s)))}}function RI(o,e,t){const s=new Fg(e,2*t,t);s.scale(1,1,-1);const i=s.getAttribute("position"),n=new R;for(let r=0;r<i.count;++r)if(n.fromBufferAttribute(i,r),n.y<0){const a=-o*3/2,A=n.y<a?-o/n.y:1-n.y*n.y/(3*a*a);n.multiplyScalar(A),n.toArray(i.array,3*r)}return i.needsUpdate=!0,s}/* @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const yn=new R,Po=new R,Go=new R,wn=new oA,Ul=new ts,Pl=new wr;class Ps extends Sp{constructor(e){super(document.createElement("div")),this.normal=new R(0,1,0),this.initialized=!1,this.referenceCount=1,this.pivot=document.createElement("div"),this.slot=document.createElement("slot"),this.element.classList.add("annotation-wrapper"),this.slot.name=e.name,this.element.appendChild(this.pivot),this.pivot.appendChild(this.slot),this.updatePosition(e.position),this.updateNormal(e.normal),this.surface=e.surface}get facingCamera(){return!this.element.classList.contains("hide")}show(){(!this.facingCamera||!this.initialized)&&this.updateVisibility(!0)}hide(){(this.facingCamera||!this.initialized)&&this.updateVisibility(!1)}increment(){this.referenceCount++}decrement(){return this.referenceCount>0&&--this.referenceCount,this.referenceCount===0}updatePosition(e){if(e==null)return;const t=ft(e)[0].terms;for(let s=0;s<3;++s)this.position.setComponent(s,tt(t[s]).number);this.updateMatrixWorld()}updateNormal(e){if(e==null)return;const t=ft(e)[0].terms;for(let s=0;s<3;++s)this.normal.setComponent(s,t[s].number)}updateSurface(e){if(!e&&this.initialized)return;const{mesh:t,tri:s,bary:i}=this;if(t==null||s==null||i==null)return;t.getVertexPosition(s.x,yn),t.getVertexPosition(s.y,Po),t.getVertexPosition(s.z,Go),yn.toArray(wn.elements,0),Po.toArray(wn.elements,3),Go.toArray(wn.elements,6),this.position.copy(i).applyMatrix3(wn);const n=this.parent;n.worldToLocal(t.localToWorld(this.position)),Ul.set(yn,Po,Go),Ul.getNormal(this.normal).transformDirection(t.matrixWorld);const r=n.parent;Pl.setFromAxisAngle(yn.set(0,1,0),-r.yaw),this.normal.applyQuaternion(Pl)}orient(e){this.pivot.style.transform=`rotate(${e}rad)`}updateVisibility(e){this.element.classList.toggle("hide",!e),this.slot.assignedNodes().forEach(t=>{if(t.nodeType!==Node.ELEMENT_NODE)return;const s=t,i=s.dataset.visibilityAttribute;if(i!=null){const n=`data-${i}`;s.toggleAttribute(n,e)}s.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:e}}))}),this.initialized=!0}}const _I={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform sampler2D tDiffuse;
		uniform float h;

		varying vec2 vUv;

		void main() {

			vec4 sum = vec4( 0.0 );

			sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;
			sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
			sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;

			gl_FragColor = sum;

		}`},DI={name:"VerticalBlurShader",uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform sampler2D tDiffuse;
		uniform float v;

		varying vec2 vUv;

		void main() {

			vec4 sum = vec4( 0.0 );

			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;
			sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;

			gl_FragColor = sum;

		}`};/* @license
 * Copyright 2022 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Gl=9,LI=6,Oo=2,FI=.3;class NI extends Xi{constructor(e,t,s){super(),this.camera=new yr,this.renderTarget=null,this.renderTargetBlur=null,this.depthMaterial=new Ng,this.horizontalBlurMaterial=new $s(_I),this.verticalBlurMaterial=new $s(DI),this.intensity=0,this.softness=1,this.boundingBox=new Ae,this.size=new R,this.maxDimension=0,this.isAnimated=!1,this.needsUpdate=!1;const{camera:i}=this;i.rotation.x=Math.PI/2,i.left=-.5,i.right=.5,i.bottom=-.5,i.top=.5,this.add(i);const n=new Ws,r=new Xe({opacity:1,transparent:!0,side:Mr});this.floor=new ge(n,r),this.floor.userData.noHit=!0,i.add(this.floor),this.blurPlane=new ge(n),this.blurPlane.visible=!1,i.add(this.blurPlane),e.target.add(this),this.depthMaterial.onBeforeCompile=function(a){a.fragmentShader=a.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * opacity );")},this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial.depthTest=!1,this.setScene(e,t,s)}setScene(e,t,s){const{boundingBox:i,size:n,rotation:r,position:a}=this;if(this.isAnimated=e.animationNames.length>0,this.boundingBox.copy(e.boundingBox),this.size.copy(e.size),this.maxDimension=Math.max(n.x,n.y,n.z)*(this.isAnimated?Oo:1),this.boundingBox.getCenter(a),s==="back"){const{min:A,max:c}=i;[A.y,A.z]=[A.z,A.y],[c.y,c.z]=[c.z,c.y],[n.y,n.z]=[n.z,n.y],r.x=Math.PI/2,r.y=Math.PI}else r.x=0,r.y=0;if(this.isAnimated){const A=i.min.y,c=i.max.y;n.y=this.maxDimension,i.expandByVector(n.subScalar(this.maxDimension).multiplyScalar(-.5)),i.min.y=A,i.max.y=c,n.set(this.maxDimension,c-A,this.maxDimension)}s==="bottom"?a.y=i.min.y:a.z=i.min.y,this.setSoftness(t)}setSoftness(e){this.softness=e;const{size:t,camera:s}=this,i=this.isAnimated?Oo:1,n=i*Math.pow(2,Gl-e*(Gl-LI));this.setMapSize(n);const r=t.y/2,a=t.y*i;s.near=0,s.far=CA(a,r,e),this.depthMaterial.opacity=1/e,s.updateProjectionMatrix(),this.setIntensity(this.intensity),this.setOffset(0)}setMapSize(e){const{size:t}=this;this.isAnimated&&(e*=Oo);const s=Math.floor(t.x>t.z?e:e*t.x/t.z),i=Math.floor(t.x>t.z?e*t.z/t.x:e),n=10,r=n+s,a=n+i;if(this.renderTarget!=null&&(this.renderTarget.width!==r||this.renderTarget.height!==a)&&(this.renderTarget.dispose(),this.renderTarget=null,this.renderTargetBlur.dispose(),this.renderTargetBlur=null),this.renderTarget==null){const A={format:_e};this.renderTarget=new zi(r,a,A),this.renderTargetBlur=new zi(r,a,A),this.floor.material.map=this.renderTarget.texture}this.camera.scale.set(t.x*(1+n/s),t.z*(1+n/i),1),this.needsUpdate=!0}setIntensity(e){this.intensity=e,e>0?(this.visible=!0,this.floor.visible=!0,this.floor.material.opacity=e*CA(FI,1,this.softness*this.softness)):(this.visible=!1,this.floor.visible=!1)}getIntensity(){return this.intensity}setOffset(e){this.floor.position.z=-e+this.gap()}gap(){return .001*this.maxDimension}render(e,t){t.overrideMaterial=this.depthMaterial;const s=e.getClearAlpha();e.setClearAlpha(0),this.floor.visible=!1;const i=e.xr.enabled;e.xr.enabled=!1;const n=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.render(t,this.camera),t.overrideMaterial=null,this.floor.visible=!0,this.blurShadow(e),e.xr.enabled=i,e.setRenderTarget(n),e.setClearAlpha(s)}blurShadow(e){const{camera:t,horizontalBlurMaterial:s,verticalBlurMaterial:i,renderTarget:n,renderTargetBlur:r,blurPlane:a}=this;a.visible=!0,a.material=s,s.uniforms.h.value=1/this.renderTarget.width,s.uniforms.tDiffuse.value=this.renderTarget.texture,e.setRenderTarget(r),e.render(a,t),a.material=i,i.uniforms.v.value=1/this.renderTarget.height,i.uniforms.tDiffuse.value=this.renderTargetBlur.texture,e.setRenderTarget(n),e.render(a,t),a.visible=!1}dispose(){this.renderTarget!=null&&this.renderTarget.dispose(),this.renderTargetBlur!=null&&this.renderTargetBlur.dispose(),this.depthMaterial.dispose(),this.horizontalBlurMaterial.dispose(),this.verticalBlurMaterial.dispose(),this.floor.material.dispose(),this.floor.geometry.dispose(),this.blurPlane.geometry.dispose(),this.removeFromParent()}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Ol=10,Ho=100,$o=new R,Hl=new R,$l=new R,Vo=new kg,kI=new R,di=new ce;class UI extends Ut{constructor({canvas:e,element:t,width:s,height:i}){super(),this.annotationRenderer=new bp,this.effectRenderer=null,this.schemaElement=document.createElement("script"),this.width=1,this.height=1,this.aspect=1,this.scaleStep=0,this.renderCount=0,this.externalRenderer=null,this.camera=new Vi(45,1,.1,100),this.xrCamera=null,this.url=null,this.target=new Xi,this.animationNames=[],this.boundingBox=new Ae,this.boundingSphere=new br,this.size=new R,this.idealAspect=0,this.framedFoVDeg=0,this.shadow=null,this.shadowIntensity=0,this.shadowSoftness=1,this.bakedShadows=new Set,this.exposure=1,this.toneMapping=iA,this.canScale=!0,this.isDirty=!1,this.goalTarget=new R,this.targetDamperX=new Re,this.targetDamperY=new Re,this.targetDamperZ=new Re,this._currentGLTF=null,this._model=null,this.cancelPendingSourceChange=null,this.animationsByName=new Map,this.currentAnimationAction=null,this.groundedSkybox=new MI,this.name="ModelScene",this.element=t,this.canvas=e,this.camera=new Vi(45,1,.1,100),this.camera.name="MainCamera",this.add(this.target),this.setSize(s,i),this.target.name="Target",this.mixer=new Ug(this.target);const{domElement:n}=this.annotationRenderer,{style:r}=n;r.display="none",r.pointerEvents="none",r.position="absolute",r.top="0",this.element.shadowRoot.querySelector(".default").appendChild(n),this.schemaElement.setAttribute("type","application/ld+json")}get context(){return this.canvas.getContext("2d")}getCamera(){return this.xrCamera!=null?this.xrCamera:this.camera}queueRender(){this.isDirty=!0}shouldRender(){return this.isDirty}hasRendered(){this.isDirty=!1}forceRescale(){this.scaleStep=-1,this.queueRender()}async setObject(e){this.reset(),this._model=e,this.target.add(e),await this.setupScene()}async setSource(e,t=()=>{}){if(!e||e===this.url){t(1);return}if(this.reset(),this.url=e,this.externalRenderer!=null){const a=await this.externalRenderer.load(t);this.boundingSphere.radius=a.framedRadius,this.idealAspect=a.fieldOfViewAspect;return}this.cancelPendingSourceChange!=null&&(this.cancelPendingSourceChange(),this.cancelPendingSourceChange=null);let s;try{s=await new Promise(async(a,A)=>{this.cancelPendingSourceChange=()=>A();try{const c=await this.element[q].loader.load(e,this.element,t);a(c)}catch(c){A(c)}})}catch(a){if(a==null)return;throw a}this.cancelPendingSourceChange=null,this.reset(),this.url=e,this._currentGLTF=s,s!=null&&(this._model=s.scene,this.target.add(s.scene));const{animations:i}=s,n=new Map,r=[];for(const a of i)n.set(a.name,a),r.push(a.name);this.animations=i,this.animationsByName=n,this.animationNames=r,await this.setupScene()}async setupScene(){this.applyTransform(),this.updateBoundingBox(),await this.updateFraming(),this.updateShadow(),this.setShadowIntensity(this.shadowIntensity),this.setGroundedSkybox()}reset(){this.url=null,this.renderCount=0,this.queueRender(),this.shadow!=null&&this.shadow.setIntensity(0),this.bakedShadows.clear();const{_model:e}=this;e!=null&&(e.removeFromParent(),this._model=null);const t=this._currentGLTF;t!=null&&(t.dispose(),this._currentGLTF=null),this.currentAnimationAction!=null&&(this.currentAnimationAction.stop(),this.currentAnimationAction=null),this.mixer.stopAllAction(),this.mixer.uncacheRoot(this)}dispose(){this.reset(),this.shadow!=null&&(this.shadow.dispose(),this.shadow=null),this.element[ir]=null,this.element[nr]=null,this.element[Xt]=null}get currentGLTF(){return this._currentGLTF}setSize(e,t){if(!(this.width===e&&this.height===t)){if(this.width=Math.max(e,1),this.height=Math.max(t,1),this.annotationRenderer.setSize(e,t),this.aspect=this.width/this.height,this.externalRenderer!=null){const s=Ra();this.externalRenderer.resize(e*s,t*s)}this.queueRender()}}markBakedShadow(e){e.userData.noHit=!0,this.bakedShadows.add(e)}unmarkBakedShadow(e){e.userData.noHit=!1,e.visible=!0,this.bakedShadows.delete(e),this.boundingBox.expandByObject(e)}findBakedShadows(e){const t=new Ae;e.traverse(s=>{const i=s;if(!i.material||!i.material.transparent)return;t.setFromObject(i);const r=t.getSize(kI),a=Math.min(r.x,r.y,r.z);Math.max(r.x,r.y,r.z)<Ho*a||this.markBakedShadow(i)})}checkBakedShadows(){const{min:e,max:t}=this.boundingBox,s=new Ae;this.boundingBox.getSize(this.size);for(const i of this.bakedShadows)s.setFromObject(i),!(s.min.y<e.y+this.size.y/Ho&&s.min.x<=e.x&&s.max.x>=t.x&&s.min.z<=e.z&&s.max.z>=t.z)&&(s.min.z<e.z+this.size.z/Ho&&s.min.x<=e.x&&s.max.x>=t.x&&s.min.y<=e.y&&s.max.y>=t.y||this.unmarkBakedShadow(i))}applyTransform(){const{model:e}=this;if(e==null)return;const t=ft(this.element.orientation)[0].terms,s=tt(t[0]).number,i=tt(t[1]).number,n=tt(t[2]).number;e.quaternion.setFromEuler(new Zh(i,n,s,"YXZ"));const r=ft(this.element.scale)[0].terms;e.scale.set(r[0].number,r[1].number,r[2].number)}updateBoundingBox(){const{model:e}=this;if(e==null)return;this.target.remove(e),this.findBakedShadows(e);const t=(s,i)=>s.expandByPoint(i);this.setBakedShadowVisibility(!1),this.boundingBox=on(e,t,new Ae),this.boundingBox.isEmpty()&&(this.setBakedShadowVisibility(!0),this.bakedShadows.forEach(s=>this.unmarkBakedShadow(s)),this.boundingBox=on(e,t,new Ae)),this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size),this.target.add(e)}async updateFraming(){const{model:e}=this;if(e==null)return;this.target.remove(e),this.setBakedShadowVisibility(!1);const{center:t}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,t.copy(this.getTarget());const s=(n,r)=>Math.max(n,t.distanceToSquared(r));this.boundingSphere.radius=Math.sqrt(on(e,s,0));const i=(n,r)=>{r.sub(t);const a=Math.sqrt(r.x*r.x+r.z*r.z);return Math.max(n,a/(this.idealCameraDistance()-Math.abs(r.y)))};this.idealAspect=on(e,i,0)/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility(),this.target.add(e)}setBakedShadowVisibility(e=this.shadowIntensity<=0){for(const t of this.bakedShadows)t.visible=e}idealCameraDistance(){const e=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(e)}adjustedFoV(e){const t=Math.tan(e/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(t)*180/Math.PI}getNDC(e,t){if(this.xrCamera!=null)di.set(e/window.screen.width,t/window.screen.height);else{const s=this.element.getBoundingClientRect();di.set((e-s.x)/this.width,(t-s.y)/this.height)}return di.multiplyScalar(2).subScalar(1),di.y*=-1,di}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(e,t){this.element[q].arRenderer.presentedScene!==this&&(this.environment=e,this.setBackground(t),this.queueRender())}setBackground(e){this.groundedSkybox.map=e,this.groundedSkybox.isUsable()?(this.target.add(this.groundedSkybox),this.background=null):(this.target.remove(this.groundedSkybox),this.background=e)}farRadius(){return this.boundingSphere.radius*(this.groundedSkybox.parent!=null?Ol:1)}setGroundedSkybox(){const e=ft(this.element.skyboxHeight)[0].terms[0],t=tt(e).number,s=Ol*this.boundingSphere.radius;this.groundedSkybox.updateGeometry(t,s),this.groundedSkybox.position.y=t-(this.shadow?2*this.shadow.gap():0),this.setBackground(this.groundedSkybox.map)}setTarget(e,t,s){this.goalTarget.set(-e,-t,-s)}setTargetDamperDecayTime(e){this.targetDamperX.setDecayTime(e),this.targetDamperY.setDecayTime(e),this.targetDamperZ.setDecayTime(e)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget(Nu)}updateTarget(e){const t=this.goalTarget,s=this.target.position;if(t.equals(s))return!1;{const i=this.boundingSphere.radius/10;let{x:n,y:r,z:a}=s;return n=this.targetDamperX.update(n,t.x,e,i),r=this.targetDamperY.update(r,t.y,e,i),a=this.targetDamperZ.update(a,t.z,e,i),this.target.position.set(n,r,a),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(e,t){const{x:s,z:i}=this.position;this.yaw=Math.atan2(e-s,t-i)}get model(){return this._model}set yaw(e){this.rotation.y=e,this.queueRender()}get yaw(){return this.rotation.y}set animationTime(e){this.mixer.setTime(e),this.queueShadowRender()}get animationTime(){if(this.currentAnimationAction!=null){const e=Math.max(this.currentAnimationAction._loopCount,0);return this.currentAnimationAction.loop===su&&(e&1)===1?this.duration-this.currentAnimationAction.time:this.currentAnimationAction.time}return 0}set animationTimeScale(e){this.mixer.timeScale=e}get animationTimeScale(){return this.mixer.timeScale}get duration(){return this.currentAnimationAction!=null&&this.currentAnimationAction.getClip()?this.currentAnimationAction.getClip().duration:0}get hasActiveAnimation(){return this.currentAnimationAction!=null}playAnimation(e=null,t=0,s=iu,i=1/0){if(this._currentGLTF==null)return;const{animations:n}=this;if(n==null||n.length===0)return;let r=null;if(e!=null&&(r=this.animationsByName.get(e),r==null)){const a=parseInt(e);!isNaN(a)&&a>=0&&a<n.length&&(r=n[a])}r==null&&(r=n[0]);try{const{currentAnimationAction:a}=this,A=this.mixer.clipAction(r,this);this.currentAnimationAction=A,this.element.paused?this.mixer.stopAllAction():(A.paused=!1,a!=null&&A!==a?A.crossFadeFrom(a,t,!1):this.animationTimeScale>0&&this.animationTime==this.duration&&(this.animationTime=0)),A.setLoop(s,i),A.enabled=!0,A.clampWhenFinished=!0,A.play()}catch(a){console.error(a)}}stopAnimation(){this.currentAnimationAction=null,this.mixer.stopAllAction()}updateAnimation(e){this.mixer.update(e),this.queueShadowRender()}subscribeMixerEvent(e,t){this.mixer.addEventListener(e,t)}updateShadow(){const e=this.shadow;if(e!=null){const t=this.element.arPlacement==="wall"?"back":"bottom";e.setScene(this,this.shadowSoftness,t),e.needsUpdate=!0}}renderShadow(e){const t=this.shadow;t!=null&&t.needsUpdate==!0&&(t.render(e,this),t.needsUpdate=!1)}queueShadowRender(){this.shadow!=null&&(this.shadow.needsUpdate=!0)}setShadowIntensity(e){if(this.shadowIntensity=e,this._currentGLTF!=null&&(this.setBakedShadowVisibility(),!(e<=0&&this.shadow==null))){if(this.shadow==null){const t=this.element.arPlacement==="wall"?"back":"bottom";this.shadow=new NI(this,this.shadowSoftness,t)}this.shadow.setIntensity(e)}}setShadowSoftness(e){this.shadowSoftness=e;const t=this.shadow;t!=null&&t.setSoftness(e)}setShadowOffset(e){const t=this.shadow;t!=null&&t.setOffset(e)}hitFromPoint(e,t=this){return Vo.setFromCamera(e,this.getCamera()),Vo.intersectObject(t,!0).find(i=>i.object.visible&&!i.object.userData.noHit)}positionAndNormalFromPoint(e,t=this){var s;const i=this.hitFromPoint(e,t);if(i==null)return null;const n=i.point,r=i.face!=null?i.face.normal.clone().applyNormalMatrix(new oA().getNormalMatrix(i.object.matrixWorld)):Vo.ray.direction.clone().multiplyScalar(-1),a=(s=i.uv)!==null&&s!==void 0?s:null;return{position:n,normal:r,uv:a}}surfaceFromPoint(e,t=this){const s=this.element.model;if(s==null)return null;const i=this.hitFromPoint(e,t);if(i==null||i.face==null)return null;const n=s[Ua](i),{meshes:r,primitives:a}=n.mesh.userData.associations,A=new R,c=new R,l=new R,{a:h,b:u,c:d}=i.face,g=i.object;g.getVertexPosition(h,A),g.getVertexPosition(u,c),g.getVertexPosition(d,l);const p=new ts(A,c,l),f=new R;return p.getBarycoord(g.worldToLocal(i.point),f),`${r} ${a} ${h} ${u} ${d} ${f.x.toFixed(3)} ${f.y.toFixed(3)} ${f.z.toFixed(3)}`}addHotspot(e){this.target.add(e),this.annotationRenderer.domElement.appendChild(e.element)}removeHotspot(e){this.target.remove(e)}forHotspots(e){const{children:t}=this.target;for(let s=0,i=t.length;s<i;s++){const n=t[s];n instanceof Ps&&e(n)}}initializeSurface(e){if(e.surface!=null&&e.mesh==null){const t=ft(e.surface)[0].terms;if(t.length!=8){console.warn(e.surface+" does not have exactly 8 numbers.");return}const s=this.element.model[fd](t[0].number,t[1].number),i=new R(t[2].number,t[3].number,t[4].number);if(s==null){console.warn(e.surface+" does not match a node/primitive in this glTF! Skipping this hotspot.");return}const n=s.mesh.geometry.attributes.position.count;if(i.x>=n||i.y>=n||i.z>=n){console.warn(e.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");return}const r=new R(t[5].number,t[6].number,t[7].number);e.mesh=s.mesh,e.tri=i,e.bary=r}}updateSurfaceHotspots(){const e=!this.element.paused;this.forHotspots(t=>{this.initializeSurface(t),t.updateSurface(e)})}updateHotspotsVisibility(e){this.forHotspots(t=>{$o.copy(e),Hl.setFromMatrixPosition(t.matrixWorld),$o.sub(Hl),$l.copy(t.normal).transformDirection(this.target.matrixWorld),$o.dot($l)<0?t.hide():t.show()})}orientHotspots(e){this.forHotspots(t=>{t.orient(e)})}setHotspotsVisibility(e){this.forHotspots(t=>{t.visible=e})}updateSchema(e){var t;const{schemaElement:s,element:i}=this,{alt:n,poster:r,iosSrc:a}=i;if(e!=null){const A=[{"@type":"MediaObject",contentUrl:e,encodingFormat:((t=e.split(".").pop())===null||t===void 0?void 0:t.toLowerCase())==="gltf"?"model/gltf+json":"model/gltf-binary"}];a&&A.push({"@type":"MediaObject",contentUrl:a,encodingFormat:"model/vnd.usdz+zip"});const c={"@context":"http://schema.org/","@type":"3DModel",image:r??void 0,name:n??void 0,encoding:A};s.textContent=JSON.stringify(c),document.head.appendChild(s)}else s.parentElement!=null&&s.parentElement.removeChild(s)}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class PI extends EventTarget{constructor(){super(...arguments),this.ongoingActivities=new Set,this.totalProgress=0}get ongoingActivityCount(){return this.ongoingActivities.size}beginActivity(e){const t={progress:0,completed:!1};return this.ongoingActivities.add(t),this.ongoingActivityCount===1&&this.announceTotalProgress(t,0,e),s=>{let i;return i=Math.max(We(s,0,1),t.progress),i!==t.progress&&this.announceTotalProgress(t,i,e),t.progress}}announceTotalProgress(e,t,s){let i=0,n=0;t==1&&(e.completed=!0);for(const A of this.ongoingActivities){const{progress:c}=A;i+=1-c,A.completed&&n++}const r=e.progress;e.progress=t,this.totalProgress+=(t-r)*(1-this.totalProgress)/i;const a=n===this.ongoingActivityCount?1:this.totalProgress;this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:a,reason:s}})),n===this.ongoingActivityCount&&(this.totalProgress=0,this.ongoingActivities.clear())}}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Lr=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n},Vl,ql,zl,Kl,Yl,Jl,jl,Wl,Xl,Zl,eh,th,sh;const GI=10,OI=50,HI=0,$I=300,VI=150,_t=document.createElement("canvas"),qo=Symbol("fallbackResizeHandler"),ih=Symbol("defaultAriaLabel"),xn=Symbol("resizeObserver"),Is=Symbol("clearModelTimeout"),zo=Symbol("onContextLost"),Es=Symbol("loaded"),Ko=Symbol("status"),Yo=Symbol("onFocus"),Jo=Symbol("onBlur"),Fs=Symbol("updateSize"),vn=Symbol("intersectionObserver"),Zt=Symbol("isElementInViewport"),mr=Symbol("announceModelVisibility"),Ui=Symbol("ariaLabel"),Ga=Symbol("altDefaulted"),gi=Symbol("statusElement"),Oa=Symbol("updateStatus"),Li=Symbol("loadedTime"),Hs=Symbol("updateSource"),nh=Symbol("markLoaded"),rr=Symbol("container"),st=Symbol("input"),Ha=Symbol("canvas"),D=Symbol("scene"),me=Symbol("needsRender"),nt=Symbol("tick"),Gt=Symbol("onModelLoad"),Wi=Symbol("onResize"),q=Symbol("renderer"),ns=Symbol("progressTracker"),rh=Symbol("getLoaded"),rs=Symbol("getModelIsVisible"),Ks=Symbol("shouldAttemptPreload"),Rt=o=>({x:o.x,y:o.y,z:o.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),$a=o=>({u:o.x,v:o.y,toString(){return`${this.u} ${this.v}`}});class tn extends es{constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[Vl]=!1,this[ql]=!1,this[zl]=0,this[Kl]="",this[Yl]=null,this[Jl]=YA(()=>{const i=this.getBoundingClientRect();this[Fs](i)},OI),this[jl]=YA(i=>{const n=this.modelIsVisible;n!==i&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:n}}))},HI),this[Wl]=null,this[Xl]=null,this[Zl]=new PI,this[eh]=()=>{this[gi].textContent=this[Ko]},this[th]=()=>{this[gi].textContent=""},this[sh]=i=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:i.sourceEvent}}))},this.attachShadow({mode:"open"});const e=this.shadowRoot;Qf(e),this[rr]=e.querySelector(".container"),this[st]=e.querySelector(".userInput"),this[Ha]=e.querySelector("canvas"),this[gi]=e.querySelector("#status"),this[ih]=this[st].getAttribute("aria-label");let t,s;if(this.isConnected){const i=this.getBoundingClientRect();t=i.width,s=i.height}else t=$I,s=VI;this[D]=new UI({canvas:this[Ha],element:this,width:t,height:s}),Promise.resolve().then(()=>{this[Fs](this.getBoundingClientRect())}),Yr&&(this[xn]=new ResizeObserver(i=>{if(!this[q].isPresenting)for(let n of i)n.target===this&&this[Fs](n.contentRect)})),Jr?this[vn]=new IntersectionObserver(i=>{for(let n of i)if(n.target===this){const r=this.modelIsVisible;this[Zt]=n.isIntersecting,this[mr](r),this[Zt]&&!this.loaded&&this[Hs]()}},{root:null,rootMargin:"0px",threshold:1e-5}):this[Zt]=!0}static get is(){return"model-viewer"}static set modelCacheSize(e){re[St].evictionThreshold=e}static get modelCacheSize(){return re[St].evictionThreshold}static set minimumRenderScale(e){e>1&&console.warn("<model-viewer> minimumRenderScale has been clamped to a maximum value of 1."),e<=0&&console.warn("<model-viewer> minimumRenderScale has been clamped to a minimum value of 0.25."),Ge.singleton.minScale=e}static get minimumRenderScale(){return Ge.singleton.minScale}get loaded(){return this[rh]()}get[(Vl=Zt,ql=Es,zl=Li,Kl=Ko,Yl=Is,Jl=qo,jl=mr,Wl=xn,Xl=vn,Zl=ns,q)](){return Ge.singleton}get modelIsVisible(){return this[rs]()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),Yr?this[xn].observe(this):self.addEventListener("resize",this[qo]),Jr&&this[vn].observe(this),this.addEventListener("focus",this[Yo]),this.addEventListener("blur",this[Jo]);const e=this[q];e.addEventListener("contextlost",this[zo]),e.registerScene(this[D]),this[Is]!=null&&(self.clearTimeout(this[Is]),this[Is]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),Yr?this[xn].unobserve(this):self.removeEventListener("resize",this[qo]),Jr&&this[vn].unobserve(this),this.removeEventListener("focus",this[Yo]),this.removeEventListener("blur",this[Jo]);const e=this[q];e.removeEventListener("contextlost",this[zo]),e.unregisterScene(this[D]),this[Is]=self.setTimeout(()=>{this[D].dispose(),this[Is]=null},GI)}updated(e){super.updated(e),e.has("src")&&(this.src==null?(this[Es]=!1,this[Li]=0,this[D].reset()):this.src!==this[D].url&&(this[Es]=!1,this[Li]=0,this[Hs]())),e.has("alt")&&this[st].setAttribute("aria-label",this[Ui]),e.has("withCredentials")&&(re.withCredentials=this.withCredentials,this[q].textureUtils.withCredentials=this.withCredentials),e.has("generateSchema")&&(this.generateSchema?this[D].updateSchema(this.src):this[D].updateSchema(null))}toDataURL(e,t){return this[q].displayCanvas(this[D]).toDataURL(e,t)}async toBlob(e){const t=e?e.mimeType:void 0,s=e?e.qualityArgument:void 0,i=e?e.idealAspect:void 0,{width:n,height:r,idealAspect:a,aspect:A}=this[D],{dpr:c,scaleFactor:l}=this[q];let h=n*l*c,u=r*l*c,d=0,g=0;if(i===!0)if(a>A){const p=u;u=Math.round(h/a),g=(p-u)/2}else{const p=h;h=Math.round(u*a),d=(p-h)/2}_t.width=h,_t.height=u;try{return new Promise(async(p,f)=>{_t.getContext("2d").drawImage(this[q].displayCanvas(this[D]),d,g,h,u,0,0,h,u),_t.toBlob(m=>{if(!m)return f(new Error("Unable to retrieve canvas blob"));p(m)},t,s)})}finally{this[Fs]({width:n,height:r})}}registerEffectComposer(e){e.setRenderer(this[q].threeRenderer),e.setMainCamera(this[D].getCamera()),e.setMainScene(this[D]),this[D].effectRenderer=e}unregisterEffectComposer(){this[D].effectRenderer=null}registerRenderer(e){this[D].externalRenderer=e}unregisterRenderer(){this[D].externalRenderer=null}get[Ui](){return this[Ga]}get[Ga](){return this.alt==null||this.alt==="null"?this[ih]:this.alt}[rh](){return this[Es]}[rs](){return this.loaded&&this[Zt]}[Ks](){return!!this.src&&this[Zt]}[Fs]({width:e,height:t}){e===0||t===0||(this[rr].style.width=`${e}px`,this[rr].style.height=`${t}px`,this[Wi]({width:e,height:t}))}[nt](e,t){var s;(s=this[D].effectRenderer)===null||s===void 0||s.beforeRender(e,t)}[nh](){this[Es]||(this[Es]=!0,this[Li]=performance.now())}[me](){this[D].queueRender()}[Gt](){}[Oa](e){this[Ko]=e;const t=this.getRootNode();t!=null&&t.activeElement===this&&this[gi].textContent!=e&&(this[gi].textContent=e)}[(eh=Yo,th=Jo,Wi)](e){this[D].setSize(e.width,e.height)}async[(sh=zo,Hs)](){const e=this[D];if(this.loaded||!this[Ks]()||this.src===e.url)return;this.generateSchema&&e.updateSchema(this.src),this[Oa]("Loading"),e.stopAnimation();const t=this[ns].beginActivity("model-load"),s=this.src;try{const i=e.setSource(s,r=>t(We(r,0,1)*.95)),n=this[gr]();await Promise.all([i,n]),this[nh](),this[Gt](),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("before-render"))}),await new Promise(r=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("load",{detail:{url:s}})),r()})})})}catch(i){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:i}}))}finally{t(1)}}}Lr([U({type:String})],tn.prototype,"alt",void 0);Lr([U({type:String})],tn.prototype,"src",void 0);Lr([U({type:Boolean,attribute:"with-credentials"})],tn.prototype,"withCredentials",void 0);Lr([U({type:Boolean,attribute:"generate-schema"})],tn.prototype,"generateSchema",void 0);/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var jo=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const oh=1e3,Qn=Symbol("changeAnimation"),lt=Symbol("paused"),qI={repetitions:1/0,pingpong:!1},zI=o=>{var e;class t extends o{constructor(...i){super(i),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[e]=!0,this[D].subscribeMixerEvent("loop",n=>{const r=n.action._loopCount;this.dispatchEvent(new CustomEvent("loop",{detail:{count:r}}))}),this[D].subscribeMixerEvent("finished",()=>{this[lt]=!0,this.dispatchEvent(new CustomEvent("finished"))})}get availableAnimations(){return this.loaded?this[D].animationNames:[]}get duration(){return this[D].duration}get paused(){return this[lt]}get currentTime(){return this[D].animationTime}set currentTime(i){this[D].animationTime=i,this[me]()}get timeScale(){return this[D].animationTimeScale}set timeScale(i){this[D].animationTimeScale=i}pause(){this[lt]||(this[lt]=!0,this.dispatchEvent(new CustomEvent("pause")))}play(i){this.availableAnimations.length>0&&(this[lt]=!1,this[Qn](i),this.dispatchEvent(new CustomEvent("play")))}[(e=lt,Gt)](){super[Gt](),this[lt]=!0,this.animationName!=null&&this[Qn](),this.autoplay&&this.play()}[nt](i,n){super[nt](i,n),!(this[lt]||!this[rs]()&&!this[q].isPresenting)&&(this[D].updateAnimation(n/oh),this[me]())}updated(i){super.updated(i),i.has("autoplay")&&this.autoplay&&this.play(),i.has("animationName")&&this[Qn]()}[Qn](i=qI){var n;const r=(n=i.repetitions)!==null&&n!==void 0?n:1/0,a=i.pingpong?su:r===1?Pg:iu;this[D].playAnimation(this.animationName,this.animationCrossfadeDuration/oh,a,r),this[lt]&&(this[D].updateAnimation(0),this[me]())}}return jo([U({type:Boolean})],t.prototype,"autoplay",void 0),jo([U({type:String,attribute:"animation-name"})],t.prototype,"animationName",void 0),jo([U({type:Number,attribute:"animation-crossfade-duration"})],t.prototype,"animationCrossfadeDuration",void 0),t};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Yt=Symbol("hotspotMap"),Wo=Symbol("mutationCallback"),fi=Symbol("observer"),Xo=Symbol("addHotspot"),ah=Symbol("removeHotspot"),Zo=new le,KI=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this[e]=new Map,this[t]=r=>{r.forEach(a=>{(!(a instanceof MutationRecord)||a.type==="childList")&&(a.addedNodes.forEach(A=>{this[Xo](A)}),a.removedNodes.forEach(A=>{this[ah](A)}),this[me]())})},this[s]=new MutationObserver(this[Wo])}connectedCallback(){super.connectedCallback();for(let a=0;a<this.children.length;++a)this[Xo](this.children[a]);const{ShadyDOM:r}=self;r==null?this[fi].observe(this,{childList:!0}):this[fi]=r.observeChildren(this,this[Wo])}disconnectedCallback(){super.disconnectedCallback();const{ShadyDOM:r}=self;r==null?this[fi].disconnect():r.unobserveChildren(this[fi])}[(e=Yt,t=Wo,s=fi,nt)](r,a){super[nt](r,a);const A=this[D],{annotationRenderer:c}=A,l=A.getCamera();A.shouldRender()&&(A.updateSurfaceHotspots(),A.updateHotspotsVisibility(l.position),c.domElement.style.display="",c.render(A,l))}updateHotspot(r){const a=this[Yt].get(r.name);a!=null&&(a.updatePosition(r.position),a.updateNormal(r.normal),a.surface=r.surface,this[me]())}queryHotspot(r){const a=this[Yt].get(r);if(a==null)return null;const A=Rt(a.position),c=Rt(a.normal),l=a.facingCamera,h=this[D],u=h.getCamera(),d=new R;d.setFromMatrixPosition(a.matrixWorld),d.project(u);const g=h.width/2,p=h.height/2;d.x=d.x*g+g,d.y=-(d.y*p)+p;const f=Rt(new R(d.x,d.y,d.z));return!Number.isFinite(f.x)||!Number.isFinite(f.y)?null:{position:A,normal:c,canvasPosition:f,facingCamera:l}}positionAndNormalFromPoint(r,a){const A=this[D],c=A.getNDC(r,a),l=A.positionAndNormalFromPoint(c);if(l==null)return null;Zo.copy(A.target.matrixWorld).invert();const h=Rt(l.position.applyMatrix4(Zo)),u=Rt(l.normal.transformDirection(Zo));let d=null;return l.uv!=null&&(d=$a(l.uv)),{position:h,normal:u,uv:d}}surfaceFromPoint(r,a){const A=this[D],c=A.getNDC(r,a);return A.surfaceFromPoint(c)}[Xo](r){if(!(r instanceof HTMLElement&&r.slot.indexOf("hotspot")===0))return;let a=this[Yt].get(r.slot);a!=null?a.increment():(a=new Ps({name:r.slot,position:r.dataset.position,normal:r.dataset.normal,surface:r.dataset.surface}),this[Yt].set(r.slot,a),this[D].addHotspot(a)),this[D].queueRender()}[ah](r){if(!(r instanceof HTMLElement))return;const a=this[Yt].get(r.slot);a&&(a.decrement()&&(this[D].removeHotspot(a),this[Yt].delete(r.slot)),this[D].queueRender())}}return i};/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.6.9
*/var Ah=function(o){return URL.createObjectURL(new Blob([o],{type:"text/javascript"}))};try{URL.revokeObjectURL(Ah(""))}catch{Ah=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var ye=Uint8Array,Be=Uint16Array,Ys=Uint32Array,lA=new ye([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,0,0,0]),hA=new ye([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,0,0]),ch=new ye([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pd=function(o,e){for(var t=new Be(31),s=0;s<31;++s)t[s]=e+=1<<o[s-1];for(var i=new Ys(t[30]),s=1;s<30;++s)for(var n=t[s];n<t[s+1];++n)i[n]=n-t[s]<<5|s;return[t,i]},md=pd(lA,2),YI=md[0],Va=md[1];YI[28]=258,Va[258]=28;var JI=pd(hA,0),lh=JI[1],qa=new Be(32768);for(var j=0;j<32768;++j){var wt=(j&43690)>>>1|(j&21845)<<1;wt=(wt&52428)>>>2|(wt&13107)<<2,wt=(wt&61680)>>>4|(wt&3855)<<4,qa[j]=((wt&65280)>>>8|(wt&255)<<8)>>>1}var Pi=function(o,e,t){for(var s=o.length,i=0,n=new Be(e);i<s;++i)++n[o[i]-1];var r=new Be(e);for(i=0;i<e;++i)r[i]=r[i-1]+n[i-1]<<1;var a;if(t){a=new Be(1<<e);var A=15-e;for(i=0;i<s;++i)if(o[i])for(var c=i<<4|o[i],l=e-o[i],h=r[o[i]-1]++<<l,u=h|(1<<l)-1;h<=u;++h)a[qa[h]>>>A]=c}else for(a=new Be(s),i=0;i<s;++i)o[i]&&(a[i]=qa[r[o[i]-1]++]>>>15-o[i]);return a},os=new ye(288);for(var j=0;j<144;++j)os[j]=8;for(var j=144;j<256;++j)os[j]=9;for(var j=256;j<280;++j)os[j]=7;for(var j=280;j<288;++j)os[j]=8;var Ir=new ye(32);for(var j=0;j<32;++j)Ir[j]=5;var jI=Pi(os,9,0),WI=Pi(Ir,5,0),Id=function(o){return(o/8|0)+(o&7&&1)},Ed=function(o,e,t){(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length);var s=new(o instanceof Be?Be:o instanceof Ys?Ys:ye)(t-e);return s.set(o.subarray(e,t)),s},ht=function(o,e,t){t<<=e&7;var s=e/8|0;o[s]|=t,o[s+1]|=t>>>8},pi=function(o,e,t){t<<=e&7;var s=e/8|0;o[s]|=t,o[s+1]|=t>>>8,o[s+2]|=t>>>16},ea=function(o,e){for(var t=[],s=0;s<o.length;++s)o[s]&&t.push({s,f:o[s]});var i=t.length,n=t.slice();if(!i)return[uA,0];if(i==1){var r=new ye(t[0].s+1);return r[t[0].s]=1,[r,1]}t.sort(function(C,x){return C.f-x.f}),t.push({s:-1,f:25001});var a=t[0],A=t[1],c=0,l=1,h=2;for(t[0]={s:-1,f:a.f+A.f,l:a,r:A};l!=i-1;)a=t[t[c].f<t[h].f?c++:h++],A=t[c!=l&&t[c].f<t[h].f?c++:h++],t[l++]={s:-1,f:a.f+A.f,l:a,r:A};for(var u=n[0].s,s=1;s<i;++s)n[s].s>u&&(u=n[s].s);var d=new Be(u+1),g=za(t[l-1],d,0);if(g>e){var s=0,p=0,f=g-e,m=1<<f;for(n.sort(function(x,B){return d[B.s]-d[x.s]||x.f-B.f});s<i;++s){var E=n[s].s;if(d[E]>e)p+=m-(1<<g-d[E]),d[E]=e;else break}for(p>>>=f;p>0;){var w=n[s].s;d[w]<e?p-=1<<e-d[w]++-1:++s}for(;s>=0&&p;--s){var I=n[s].s;d[I]==e&&(--d[I],++p)}g=e}return[new ye(d),g]},za=function(o,e,t){return o.s==-1?Math.max(za(o.l,e,t+1),za(o.r,e,t+1)):e[o.s]=t},hh=function(o){for(var e=o.length;e&&!o[--e];);for(var t=new Be(++e),s=0,i=o[0],n=1,r=function(A){t[s++]=A},a=1;a<=e;++a)if(o[a]==i&&a!=e)++n;else{if(!i&&n>2){for(;n>138;n-=138)r(32754);n>2&&(r(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(r(i),--n;n>6;n-=6)r(8304);n>2&&(r(n-3<<5|8208),n=0)}for(;n--;)r(i);n=1,i=o[a]}return[t.subarray(0,s),e]},mi=function(o,e){for(var t=0,s=0;s<e.length;++s)t+=o[s]*e[s];return t},or=function(o,e,t){var s=t.length,i=Id(e+2);o[i]=s&255,o[i+1]=s>>>8,o[i+2]=o[i]^255,o[i+3]=o[i+1]^255;for(var n=0;n<s;++n)o[i+n+4]=t[n];return(i+4+s)*8},uh=function(o,e,t,s,i,n,r,a,A,c,l){ht(e,l++,t),++i[256];for(var h=ea(i,15),u=h[0],d=h[1],g=ea(n,15),p=g[0],f=g[1],m=hh(u),E=m[0],w=m[1],I=hh(p),C=I[0],x=I[1],B=new Be(19),y=0;y<E.length;++y)B[E[y]&31]++;for(var y=0;y<C.length;++y)B[C[y]&31]++;for(var v=ea(B,7),Q=v[0],b=v[1],S=19;S>4&&!Q[ch[S-1]];--S);var M=c+5<<3,T=mi(i,os)+mi(n,Ir)+r,_=mi(i,u)+mi(n,p)+r+14+3*S+mi(B,Q)+(2*B[16]+3*B[17]+7*B[18]);if(M<=T&&M<=_)return or(e,l,o.subarray(A,A+c));var L,N,P,$;if(ht(e,l,1+(_<T)),l+=2,_<T){L=Pi(u,d,0),N=u,P=Pi(p,f,0),$=p;var V=Pi(Q,b,0);ht(e,l,w-257),ht(e,l+5,x-1),ht(e,l+10,S-4),l+=14;for(var y=0;y<S;++y)ht(e,l+3*y,Q[ch[y]]);l+=3*S;for(var Y=[E,C],te=0;te<2;++te)for(var he=Y[te],y=0;y<he.length;++y){var Te=he[y]&31;ht(e,l,V[Te]),l+=Q[Te],Te>15&&(ht(e,l,he[y]>>>5&127),l+=he[y]>>>12)}}else L=jI,N=os,P=WI,$=Ir;for(var y=0;y<a;++y)if(s[y]>255){var Te=s[y]>>>18&31;pi(e,l,L[Te+257]),l+=N[Te+257],Te>7&&(ht(e,l,s[y]>>>23&31),l+=lA[Te]);var Me=s[y]&31;pi(e,l,P[Me]),l+=$[Me],Me>3&&(pi(e,l,s[y]>>>5&8191),l+=hA[Me])}else pi(e,l,L[s[y]]),l+=N[s[y]];return pi(e,l,L[256]),l+N[256]},XI=new Ys([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),uA=new ye(0),ZI=function(o,e,t,s,i,n){var r=o.length,a=new ye(s+r+5*(1+Math.ceil(r/7e3))+i),A=a.subarray(s,a.length-i),c=0;if(!e||r<8)for(var l=0;l<=r;l+=65535){var h=l+65535;h<r?c=or(A,c,o.subarray(l,h)):(A[l]=n,c=or(A,c,o.subarray(l,r)))}else{for(var u=XI[e-1],d=u>>>13,g=u&8191,p=(1<<t)-1,f=new Be(32768),m=new Be(p+1),E=Math.ceil(t/3),w=2*E,I=function(Ur){return(o[Ur]^o[Ur+1]<<E^o[Ur+2]<<w)&p},C=new Ys(25e3),x=new Be(288),B=new Be(32),y=0,v=0,l=0,Q=0,b=0,S=0;l<r;++l){var M=I(l),T=l&32767,_=m[M];if(f[T]=_,m[M]=T,b<=l){var L=r-l;if((y>7e3||Q>24576)&&L>423){c=uh(o,A,0,C,x,B,v,Q,S,l-S,c),Q=y=v=0,S=l;for(var N=0;N<286;++N)x[N]=0;for(var N=0;N<30;++N)B[N]=0}var P=2,$=0,V=g,Y=T-_&32767;if(L>2&&M==I(l-Y))for(var te=Math.min(d,L)-1,he=Math.min(32767,l),Te=Math.min(258,L);Y<=he&&--V&&T!=_;){if(o[l+P]==o[l+P-Y]){for(var Me=0;Me<Te&&o[l+Me]==o[l+Me-Y];++Me);if(Me>P){if(P=Me,$=Y,Me>te)break;for(var Rd=Math.min(Y,Me-2),pA=0,N=0;N<Rd;++N){var kr=l-Y+N+32768&32767,_d=f[kr],mA=kr-_d+32768&32767;mA>pA&&(pA=mA,_=kr)}}}T=_,_=f[T],Y+=T-_+32768&32767}if($){C[Q++]=268435456|Va[P]<<18|lh[$];var IA=Va[P]&31,EA=lh[$]&31;v+=lA[IA]+hA[EA],++x[257+IA],++B[EA],b=l+P,++y}else C[Q++]=o[l],++x[o[l]]}}c=uh(o,A,n,C,x,B,v,Q,S,l-S,c),!n&&c&7&&(c=or(A,c+1,uA))}return Ed(a,0,s+Id(c)+i)},eE=function(){for(var o=new Ys(256),e=0;e<256;++e){for(var t=e,s=9;--s;)t=(t&1&&3988292384)^t>>>1;o[e]=t}return o}(),tE=function(){var o=-1;return{p:function(e){for(var t=o,s=0;s<e.length;++s)t=eE[t&255^e[s]]^t>>>8;o=t},d:function(){return~o}}},sE=function(o,e,t,s,i){return ZI(o,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(o.length)))*1.5):12+e.mem,t,s,!i)},Cd=function(o,e){var t={};for(var s in o)t[s]=o[s];for(var s in e)t[s]=e[s];return t},ue=function(o,e,t){for(;t;++e)o[e]=t,t>>>=8};function iE(o,e){return sE(o,e||{},0,0)}var Bd=function(o,e,t,s){for(var i in o){var n=o[i],r=e+i;n instanceof ye?t[r]=[n,s]:Array.isArray(n)?t[r]=[n[0],Cd(s,n[1])]:Bd(n,r+"/",t,s)}},dh=typeof TextEncoder<"u"&&new TextEncoder,nE=typeof TextDecoder<"u"&&new TextDecoder,rE=0;try{nE.decode(uA,{stream:!0}),rE=1}catch{}function Er(o,e){if(e){for(var t=new ye(o.length),s=0;s<o.length;++s)t[s]=o.charCodeAt(s);return t}if(dh)return dh.encode(o);for(var i=o.length,n=new ye(o.length+(o.length>>1)),r=0,a=function(l){n[r++]=l},s=0;s<i;++s){if(r+5>n.length){var A=new ye(r+8+(i-s<<1));A.set(n),n=A}var c=o.charCodeAt(s);c<128||e?a(c):c<2048?(a(192|c>>6),a(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|o.charCodeAt(++s)&1023,a(240|c>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|c&63)):(a(224|c>>12),a(128|c>>6&63),a(128|c&63))}return Ed(n,0,r)}var Ka=function(o){var e=0;if(o)for(var t in o){var s=o[t].length;if(s>65535)throw"extra field too long";e+=s+4}return e},gh=function(o,e,t,s,i,n,r,a){var A=s.length,c=t.extra,l=a&&a.length,h=Ka(c);ue(o,e,r!=null?33639248:67324752),e+=4,r!=null&&(o[e++]=20,o[e++]=t.os),o[e]=20,e+=2,o[e++]=t.flag<<1|(n==null&&8),o[e++]=i&&8,o[e++]=t.compression&255,o[e++]=t.compression>>8;var u=new Date(t.mtime==null?Date.now():t.mtime),d=u.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(ue(o,e,d<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>>1),e+=4,n!=null&&(ue(o,e,t.crc),ue(o,e+4,n),ue(o,e+8,t.size)),ue(o,e+12,A),ue(o,e+14,h),e+=16,r!=null&&(ue(o,e,l),ue(o,e+6,t.attrs),ue(o,e+10,r),e+=14),o.set(s,e),e+=A,h)for(var g in c){var p=c[g],f=p.length;ue(o,e,+g),ue(o,e+2,f),o.set(p,e+4),e+=4+f}return l&&(o.set(a,e),e+=l),e},oE=function(o,e,t,s,i){ue(o,e,101010256),ue(o,e+8,t),ue(o,e+10,t),ue(o,e+12,s),ue(o,e+16,i)};function aE(o,e){e||(e={});var t={},s=[];Bd(o,"",t,e);var i=0,n=0;for(var r in t){var a=t[r],A=a[0],c=a[1],l=c.level==0?0:8,h=Er(r),u=h.length,d=c.comment,g=d&&Er(d),p=g&&g.length,f=Ka(c.extra);if(u>65535)throw"filename too long";var m=l?iE(A,c):A,E=m.length,w=tE();w.p(A),s.push(Cd(c,{size:A.length,crc:w.d(),c:m,f:h,m:g,u:u!=r.length||g&&d.length!=p,o:i,compression:l})),i+=30+u+f+E,n+=76+2*(u+f)+(p||0)+E}for(var I=new ye(n+22),C=i,x=n-i,B=0;B<s.length;++B){var h=s[B];gh(I,h.o,h,h.f,h.u,h.c.length);var y=30+h.f.length+Ka(h.extra);I.set(h.c,h.o+y),gh(I,i,h,h.f,h.u,h.c.length,h.o,h.m),i+=16+y+(h.m?h.m.length:0)}return oE(I,i,s.length,x,C),I}class AE{async parse(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1},t);const s={},i="model.usda";s[i]=null;let n=yd();n+=lE(t);const r={},a={};e.traverseVisible(c=>{if(c.isMesh){const l=c.geometry,h=c.material;if(h.isMeshStandardMaterial){const u="geometries/Geometry_"+l.id+".usda";if(!(u in s)){const d=gE(l);s[u]=uE(d)}h.uuid in r||(r[h.uuid]=h),n+=dE(c,l,h)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",c)}else c.isCamera&&(n+=wE(c))}),n+=hE(),n+=CE(r,a,t.quickLookCompatible),s[i]=Er(n),n=null;for(const c in a){let l=a[c];l.isCompressedTexture===!0&&(l=Wn(l));const h=cE(l.image,l.flipY),u=await new Promise(d=>h.toBlob(d,"image/png",1));s[`textures/Texture_${c}.png`]=new Uint8Array(await u.arrayBuffer())}let A=0;for(const c in s){const l=s[c],h=34+c.length;A+=h;const u=A&63;if(u!==4){const d=64-u,g=new Uint8Array(d);s[c]=[l,{extra:{12345:g}}]}A=l.length}return aE(s,{level:0})}}function cE(o,e){if(typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&o instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&o instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&o instanceof ImageBitmap){const t=1024/Math.max(o.width,o.height),s=document.createElement("canvas");s.width=o.width*Math.min(1,t),s.height=o.height*Math.min(1,t);const i=s.getContext("2d");return e===!0&&(i.translate(0,s.height),i.scale(1,-1)),i.drawImage(o,0,0,s.width,s.height),s}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const pe=7;function yd(){return`#usda 1.0
(
	customLayerData = {
		string creator = "Three.js USDZExporter"
	}
	defaultPrim = "Root"
	metersPerUnit = 1
	upAxis = "Y"
)

`}function lE(o){return`def Xform "Root"
{
	def Scope "Scenes" (
		kind = "sceneLibrary"
	)
	{
		def Xform "Scene" (
			customData = {
				bool preliminary_collidesWithEnvironment = 0
				string sceneName = "Scene"
			}
			sceneName = "Scene"
		)
		{
		token preliminary:anchoring:type = "${o.ar.anchoring.type}"
		token preliminary:planeAnchoring:alignment = "${o.ar.planeAnchoring.alignment}"

`}function hE(){return`
		}
	}
}

`}function uE(o){let e=yd();return e+=o,Er(e)}function dE(o,e,t){const s="Object_"+o.id,i=wd(o.matrixWorld);return o.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",o),`def Xform "${s}" (
	prepend references = @./geometries/Geometry_${e.id}.usda@</Geometry>
	prepend apiSchemas = ["MaterialBindingAPI"]
)
{
	matrix4d xformOp:transform = ${i}
	uniform token[] xformOpOrder = ["xformOp:transform"]

	rel material:binding = </Materials/Material_${t.id}>
}

`}function wd(o){const e=o.elements;return`( ${Sn(e,0)}, ${Sn(e,4)}, ${Sn(e,8)}, ${Sn(e,12)} )`}function Sn(o,e){return`(${o[e+0]}, ${o[e+1]}, ${o[e+2]}, ${o[e+3]})`}function gE(o){return`
def "Geometry"
{
${fE(o)}
}
`}function fE(o){const e="Geometry",t=o.attributes,s=t.position.count;return`
	def Mesh "${e}"
	{
		int[] faceVertexCounts = [${pE(o)}]
		int[] faceVertexIndices = [${mE(o)}]
		normal3f[] normals = [${fh(t.normal,s)}] (
			interpolation = "vertex"
		)
		point3f[] points = [${fh(t.position,s)}]
${EE(t)}
		uniform token subdivisionScheme = "none"
	}
`}function pE(o){const e=o.index!==null?o.index.count:o.attributes.position.count;return Array(e/3).fill(3).join(", ")}function mE(o){const e=o.index,t=[];if(e!==null)for(let s=0;s<e.count;s++)t.push(e.getX(s));else{const s=o.attributes.position.count;for(let i=0;i<s;i++)t.push(i)}return t.join(", ")}function fh(o,e){if(o===void 0)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const t=[];for(let s=0;s<o.count;s++){const i=o.getX(s),n=o.getY(s),r=o.getZ(s);t.push(`(${i.toPrecision(pe)}, ${n.toPrecision(pe)}, ${r.toPrecision(pe)})`)}return t.join(", ")}function IE(o){const e=[];for(let t=0;t<o.count;t++){const s=o.getX(t),i=o.getY(t);e.push(`(${s.toPrecision(pe)}, ${1-i.toPrecision(pe)})`)}return e.join(", ")}function EE(o){let e="";for(let t=0;t<4;t++){const s=t>0?t:"",i=o["uv"+s];i!==void 0&&(e+=`
		texCoord2f[] primvars:st${s} = [${IE(i)}] (
			interpolation = "vertex"
		)`)}return e}function CE(o,e,t=!1){const s=[];for(const i in o){const n=o[i];s.push(BE(n,e,t))}return`def "Materials"
{
${s.join("")}
}

`}function BE(o,e,t=!1){const s="			",i=[],n=[];function r(a,A,c){const l=a.source.id+"_"+a.flipY;e[l]=a;const h=a.channel>0?"st"+a.channel:"st",u={1e3:"repeat",1001:"clamp",1002:"mirror"},d=a.repeat.clone(),g=a.offset.clone(),p=a.rotation,f=Math.sin(p),m=Math.cos(p);return g.y=1-g.y-d.y,t?(g.x=g.x/d.x,g.y=g.y/d.y,g.x+=f/d.x,g.y+=m-1):(g.x+=f*d.x,g.y+=(1-m)*d.y),`
		def Shader "PrimvarReader_${A}"
		{
			uniform token info:id = "UsdPrimvarReader_float2"
			float2 inputs:fallback = (0.0, 0.0)
			token inputs:varname = "${h}"
			float2 outputs:result
		}

		def Shader "Transform2d_${A}"
		{
			uniform token info:id = "UsdTransform2d"
			token inputs:in.connect = </Materials/Material_${o.id}/PrimvarReader_${A}.outputs:result>
			float inputs:rotation = ${(p*(180/Math.PI)).toFixed(pe)}
			float2 inputs:scale = ${mh(d)}
			float2 inputs:translation = ${mh(g)}
			float2 outputs:result
		}

		def Shader "Texture_${a.id}_${A}"
		{
			uniform token info:id = "UsdUVTexture"
			asset inputs:file = @textures/Texture_${l}.png@
			float2 inputs:st.connect = </Materials/Material_${o.id}/Transform2d_${A}.outputs:result>
			${c!==void 0?"float4 inputs:scale = "+yE(c):""}
			token inputs:sourceColorSpace = "${a.colorSpace===lr?"raw":"sRGB"}"
			token inputs:wrapS = "${u[a.wrapS]}"
			token inputs:wrapT = "${u[a.wrapT]}"
			float outputs:r
			float outputs:g
			float outputs:b
			float3 outputs:rgb
			${o.transparent||o.alphaTest>0?"float outputs:a":""}
		}`}return o.side===kt&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",o),o.map!==null?(i.push(`${s}color3f inputs:diffuseColor.connect = </Materials/Material_${o.id}/Texture_${o.map.id}_diffuse.outputs:rgb>`),o.transparent?i.push(`${s}float inputs:opacity.connect = </Materials/Material_${o.id}/Texture_${o.map.id}_diffuse.outputs:a>`):o.alphaTest>0&&(i.push(`${s}float inputs:opacity.connect = </Materials/Material_${o.id}/Texture_${o.map.id}_diffuse.outputs:a>`),i.push(`${s}float inputs:opacityThreshold = ${o.alphaTest}`)),n.push(r(o.map,"diffuse",o.color))):i.push(`${s}color3f inputs:diffuseColor = ${ph(o.color)}`),o.emissiveMap!==null?(i.push(`${s}color3f inputs:emissiveColor.connect = </Materials/Material_${o.id}/Texture_${o.emissiveMap.id}_emissive.outputs:rgb>`),n.push(r(o.emissiveMap,"emissive"))):o.emissive.getHex()>0&&i.push(`${s}color3f inputs:emissiveColor = ${ph(o.emissive)}`),o.normalMap!==null&&(i.push(`${s}normal3f inputs:normal.connect = </Materials/Material_${o.id}/Texture_${o.normalMap.id}_normal.outputs:rgb>`),n.push(r(o.normalMap,"normal"))),o.aoMap!==null&&(i.push(`${s}float inputs:occlusion.connect = </Materials/Material_${o.id}/Texture_${o.aoMap.id}_occlusion.outputs:r>`),n.push(r(o.aoMap,"occlusion"))),o.roughnessMap!==null&&o.roughness===1?(i.push(`${s}float inputs:roughness.connect = </Materials/Material_${o.id}/Texture_${o.roughnessMap.id}_roughness.outputs:g>`),n.push(r(o.roughnessMap,"roughness"))):i.push(`${s}float inputs:roughness = ${o.roughness}`),o.metalnessMap!==null&&o.metalness===1?(i.push(`${s}float inputs:metallic.connect = </Materials/Material_${o.id}/Texture_${o.metalnessMap.id}_metallic.outputs:b>`),n.push(r(o.metalnessMap,"metallic"))):i.push(`${s}float inputs:metallic = ${o.metalness}`),o.alphaMap!==null?(i.push(`${s}float inputs:opacity.connect = </Materials/Material_${o.id}/Texture_${o.alphaMap.id}_opacity.outputs:r>`),i.push(`${s}float inputs:opacityThreshold = 0.0001`),n.push(r(o.alphaMap,"opacity"))):i.push(`${s}float inputs:opacity = ${o.opacity}`),o.isMeshPhysicalMaterial&&(i.push(`${s}float inputs:clearcoat = ${o.clearcoat}`),i.push(`${s}float inputs:clearcoatRoughness = ${o.clearcoatRoughness}`),i.push(`${s}float inputs:ior = ${o.ior}`)),`
	def Material "Material_${o.id}"
	{
		def Shader "PreviewSurface"
		{
			uniform token info:id = "UsdPreviewSurface"
${i.join(`
`)}
			int inputs:useSpecularWorkflow = 0
			token outputs:surface
		}

		token outputs:surface.connect = </Materials/Material_${o.id}/PreviewSurface.outputs:surface>

${n.join(`
`)}

	}
`}function ph(o){return`(${o.r}, ${o.g}, ${o.b})`}function yE(o){return`(${o.r}, ${o.g}, ${o.b}, 1.0)`}function mh(o){return`(${o.x}, ${o.y})`}function wE(o){const e=o.name?o.name:"Camera_"+o.id,t=wd(o.matrixWorld);return o.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",o),o.isOrthographicCamera?`def Camera "${e}"
		{
			matrix4d xformOp:transform = ${t}
			uniform token[] xformOpOrder = ["xformOp:transform"]

			float2 clippingRange = (${o.near.toPrecision(pe)}, ${o.far.toPrecision(pe)})
			float horizontalAperture = ${((Math.abs(o.left)+Math.abs(o.right))*10).toPrecision(pe)}
			float verticalAperture = ${((Math.abs(o.top)+Math.abs(o.bottom))*10).toPrecision(pe)}
			token projection = "orthographic"
		}
	
	`:`def Camera "${e}"
		{
			matrix4d xformOp:transform = ${t}
			uniform token[] xformOpOrder = ["xformOp:transform"]

			float2 clippingRange = (${o.near.toPrecision(pe)}, ${o.far.toPrecision(pe)})
			float focalLength = ${o.getFocalLength().toPrecision(pe)}
			float focusDistance = ${o.focus.toPrecision(pe)}
			float horizontalAperture = ${o.getFilmWidth().toPrecision(pe)}
			token projection = "perspective"
			float verticalAperture = ${o.getFilmHeight().toPrecision(pe)}
		}
	
	`}/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const xE=o=>e=>{try{const t=ft(e),s=(t.length?t[0].terms:[]).filter(i=>i&&i.type==="ident").map(i=>i.value).filter(i=>o.indexOf(i)>-1);return new Set(s)}catch{}return new Set};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var Cs=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};let Ih=!1,Eh=!1;const Ch="#model-viewer-no-ar-fallback",vE=xE(["quick-look","scene-viewer","webxr","none"]),QE="webxr scene-viewer quick-look",ke={QUICK_LOOK:"quick-look",SCENE_VIEWER:"scene-viewer",WEBXR:"webxr",NONE:"none"},ut=Symbol("arButtonContainer"),Bh=Symbol("enterARWithWebXR"),yh=Symbol("openSceneViewer"),wh=Symbol("openIOSARQuickLook"),SE=Symbol("canActivateAR"),bn=Symbol("arMode"),ta=Symbol("arModes"),Bs=Symbol("arAnchor"),Tn=Symbol("preload"),Mn=Symbol("onARButtonContainerClick"),sa=Symbol("onARStatus"),ia=Symbol("onARTracking"),na=Symbol("onARTap"),Ii=Symbol("selectARMode"),ra=Symbol("triggerLoad"),bE=o=>{var e,t,s,i,n,r,a,A,c,l;class h extends o{constructor(){super(...arguments),this.ar=!1,this.arScale="auto",this.arPlacement="floor",this.arModes=QE,this.iosSrc=null,this.xrEnvironment=!1,this[e]=!1,this[t]=this.shadowRoot.querySelector(".ar-button"),this[s]=document.createElement("a"),this[i]=new Set,this[n]=ke.NONE,this[r]=!1,this[a]=d=>{d.preventDefault(),this.activateAR()},this[A]=({status:d})=>{(d===Mt.NOT_PRESENTING||this[q].arRenderer.presentedScene===this[D])&&(this.setAttribute("ar-status",d),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:d}})),d===Mt.NOT_PRESENTING?this.removeAttribute("ar-tracking"):d===Mt.SESSION_STARTED&&this.setAttribute("ar-tracking",Fa.TRACKING))},this[c]=({status:d})=>{this.setAttribute("ar-tracking",d),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:d}}))},this[l]=d=>{d.data=="_apple_ar_quicklook_button_tapped"&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[bn]!==ke.NONE}connectedCallback(){super.connectedCallback(),this[q].arRenderer.addEventListener("status",this[sa]),this.setAttribute("ar-status",Mt.NOT_PRESENTING),this[q].arRenderer.addEventListener("tracking",this[ia]),this[Bs].addEventListener("message",this[na])}disconnectedCallback(){super.disconnectedCallback(),this[q].arRenderer.removeEventListener("status",this[sa]),this[q].arRenderer.removeEventListener("tracking",this[ia]),this[Bs].removeEventListener("message",this[na])}update(d){super.update(d),d.has("arScale")&&(this[D].canScale=this.arScale!=="fixed"),d.has("arPlacement")&&(this[D].updateShadow(),this[me]()),d.has("arModes")&&(this[ta]=vE(this.arModes)),(d.has("ar")||d.has("arModes")||d.has("src")||d.has("iosSrc"))&&this[Ii]()}async activateAR(){switch(this[bn]){case ke.QUICK_LOOK:await this[wh]();break;case ke.WEBXR:await this[Bh]();break;case ke.SCENE_VIEWER:this[yh]();break;default:console.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities");break}}async[(e=SE,t=ut,s=Bs,i=ta,n=bn,r=Tn,a=Mn,A=sa,c=ia,l=na,Ii)](){let d=ke.NONE;if(this.ar){if(this.src!=null)for(const g of this[ta]){if(g==="webxr"&&gu&&!Ih&&await this[q].arRenderer.supportsPresentation()){d=ke.WEBXR;break}if(g==="scene-viewer"&&lf&&!Eh){d=ke.SCENE_VIEWER;break}if(g==="quick-look"&&zA){d=ke.QUICK_LOOK;break}}d===ke.NONE&&this.iosSrc!=null&&zA&&(d=ke.QUICK_LOOK)}if(d!==ke.NONE)this[ut].classList.add("enabled"),this[ut].addEventListener("click",this[Mn]);else if(this[ut].classList.contains("enabled")){this[ut].removeEventListener("click",this[Mn]),this[ut].classList.remove("enabled");const g=Mt.FAILED;this.setAttribute("ar-status",g),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:g}}))}this[bn]=d}async[Bh](){console.log("Attempting to present in AR with WebXR..."),await this[ra]();try{this[ut].removeEventListener("click",this[Mn]);const{arRenderer:d}=this[q];d.placeOnWall=this.arPlacement==="wall",await d.present(this[D],this.xrEnvironment)}catch(d){console.warn("Error while trying to present in AR with WebXR"),console.error(d),await this[q].arRenderer.stopPresenting(),Ih=!0,console.warn("Falling back to next ar-mode"),await this[Ii](),this.activateAR()}finally{this[Ii]()}}async[ra](){this.loaded||(this[Tn]=!0,this[Hs](),await pf(this,"load"),this[Tn]=!1)}[Ks](){return super[Ks]()||this[Tn]}[yh](){const d=self.location.toString(),g=new URL(d),p=new URL(this.src,d);p.hash&&(p.hash="");const f=new URLSearchParams(p.search);if(g.hash=Ch,f.set("mode","ar_preferred"),f.has("disable_occlusion")||f.set("disable_occlusion","true"),this.arScale==="fixed"&&f.set("resizable","false"),this.arPlacement==="wall"&&f.set("enable_vertical_placement","true"),f.has("sound")){const w=new URL(f.get("sound"),d);f.set("sound",w.toString())}if(f.has("link")){const w=new URL(f.get("link"),d);f.set("link",w.toString())}const m=`intent://arvr.google.com/scene-viewer/1.0?${f.toString()+"&file="+encodeURIComponent(p.toString())}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(g.toString())};end;`,E=()=>{self.location.hash===Ch&&(Eh=!0,self.history.back(),console.warn("Error while trying to present in AR with Scene Viewer"),console.warn("Falling back to next ar-mode"),this[Ii]())};self.addEventListener("hashchange",E,{once:!0}),this[Bs].setAttribute("href",m),console.log("Attempting to present in AR with Scene Viewer..."),this[Bs].click()}async[wh](){const d=!this.iosSrc;this[ut].classList.remove("enabled");const g=d?await this.prepareUSDZ():this.iosSrc,p=new URL(g,self.location.toString());if(d){const E=self.location.toString(),w=new URL(E),I=new URL(this.src,w);I.hash&&(p.hash=I.hash)}this.arScale==="fixed"&&(p.hash&&(p.hash+="&"),p.hash+="allowsContentScaling=0");const f=this[Bs];f.setAttribute("rel","ar");const m=document.createElement("img");f.appendChild(m),f.setAttribute("href",p.toString()),d&&f.setAttribute("download","model.usdz"),f.style.display="none",f.isConnected||this.shadowRoot.appendChild(f),console.log("Attempting to present in AR with Quick Look..."),f.click(),f.removeChild(m),d&&URL.revokeObjectURL(g),this[ut].classList.add("enabled")}async prepareUSDZ(){const d=this[ns].beginActivity("usdz-conversion");await this[ra]();const{model:g,shadow:p}=this[D];if(g==null)return"";let f=!1;p!=null&&(f=p.visible,p.visible=!1),d(.2);const E=await new AE().parse(g),w=new Blob([E],{type:"model/vnd.usdz+zip"}),I=URL.createObjectURL(w);return d(1),p!=null&&(p.visible=f),I}}return Cs([U({type:Boolean,attribute:"ar"})],h.prototype,"ar",void 0),Cs([U({type:String,attribute:"ar-scale"})],h.prototype,"arScale",void 0),Cs([U({type:String,attribute:"ar-placement"})],h.prototype,"arPlacement",void 0),Cs([U({type:String,attribute:"ar-modes"})],h.prototype,"arModes",void 0),Cs([U({type:String,attribute:"ios-src"})],h.prototype,"iosSrc",void 0),Cs([U({type:Boolean,attribute:"xr-environment"})],h.prototype,"xrEnvironment",void 0),h};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var oa=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const TE=100,ME="https://www.gstatic.com/draco/versioned/decoders/1.5.6/",RE="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/",_E="https://cdn.jsdelivr.net/npm/three@0.149.0/examples/jsm/loaders/LottieLoader.js",aa={AUTO:"auto",MANUAL:"manual"},xh={AUTO:"auto",LAZY:"lazy",EAGER:"eager"},ys=Symbol("defaultProgressBarElement"),Aa=Symbol("posterContainerElement"),ws=Symbol("defaultPosterElement"),Ei=Symbol("shouldDismissPoster"),ca=Symbol("hidePoster"),Rn=Symbol("modelIsRevealed"),la=Symbol("updateProgressBar"),DE=Symbol("ariaLabelCallToAction"),ha=Symbol("onProgress"),LE=o=>{var e,t,s,i,n,r,a,A;class c extends o{constructor(...h){super(...h),this.poster=null,this.reveal=aa.AUTO,this.loading=xh.AUTO,this[e]=!1,this[t]=!1,this[s]=this.shadowRoot.querySelector(".slot.poster"),this[i]=this.shadowRoot.querySelector("#default-poster"),this[n]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[r]=this[ws].getAttribute("aria-label"),this[a]=df(f=>{const m=this[ys].parentNode;requestAnimationFrame(()=>{this[ys].style.transform=`scaleX(${f})`,f===0&&(m.removeChild(this[ys]),m.appendChild(this[ys])),this[ys].classList.toggle("hide",f===1)})},TE),this[A]=f=>{const m=f.detail.totalProgress;m===1&&(this[la].flush(),this.loaded&&(this[Ei]||this.reveal===aa.AUTO)&&this[ca]()),this[la](m),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:m}}))};const u=self.ModelViewerElement||{},d=u.dracoDecoderLocation||ME;re.setDRACODecoderLocation(d);const g=u.ktx2TranscoderLocation||RE;re.setKTX2TranscoderLocation(g),u.meshoptDecoderLocation&&re.setMeshoptDecoderLocation(u.meshoptDecoderLocation);const p=u.lottieLoaderLocation||_E;Ge.singleton.textureUtils.lottieLoaderUrl=p}static set dracoDecoderLocation(h){re.setDRACODecoderLocation(h)}static get dracoDecoderLocation(){return re.getDRACODecoderLocation()}static set ktx2TranscoderLocation(h){re.setKTX2TranscoderLocation(h)}static get ktx2TranscoderLocation(){return re.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(h){re.setMeshoptDecoderLocation(h)}static get meshoptDecoderLocation(){return re.getMeshoptDecoderLocation()}static set lottieLoaderLocation(h){Ge.singleton.textureUtils.lottieLoaderUrl=h}static get lottieLoaderLocation(){return Ge.singleton.textureUtils.lottieLoaderUrl}static mapURLs(h){Ge.singleton.loader[Jt].manager.setURLModifier(h)}dismissPoster(){this.loaded?this[ca]():(this[Ei]=!0,this[Hs]())}showPoster(){const h=this[Aa];if(h.classList.contains("show"))return;h.classList.add("show"),this[st].classList.remove("show");const u=this[ws];u.removeAttribute("tabindex"),u.removeAttribute("aria-hidden");const d=this.modelIsVisible;this[Rn]=!1,this[mr](d)}getDimensions(){return Rt(this[D].size)}getBoundingBoxCenter(){return Rt(this[D].boundingBox.getCenter(new R))}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[ns].addEventListener("progress",this[ha])}disconnectedCallback(){super.disconnectedCallback(),this[ns].removeEventListener("progress",this[ha])}async updated(h){super.updated(h),h.has("poster")&&this.poster!=null&&(this[ws].style.backgroundImage=`url(${this.poster})`),h.has("alt")&&this[ws].setAttribute("aria-label",this[Ga]),(h.has("reveal")||h.has("loading"))&&this[Hs]()}[(e=Rn,t=Ei,s=Aa,i=ws,n=ys,r=DE,a=la,A=ha,Ks)](){return!!this.src&&(this[Ei]||this.loading===xh.EAGER||this.reveal===aa.AUTO&&this[Zt])}[ca](){this[Ei]=!1;const h=this[Aa];if(!h.classList.contains("show"))return;h.classList.remove("show"),this[st].classList.add("show");const u=this.modelIsVisible;this[Rn]=!0,this[mr](u);const d=this.getRootNode();d&&d.activeElement===this&&this[st].focus();const g=this[ws];g.setAttribute("aria-hidden","true"),g.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[rs](){return super[rs]()&&this[Rn]}}return oa([U({type:String})],c.prototype,"poster",void 0),oa([U({type:String})],c.prototype,"reveal",void 0),oa([U({type:String})],c.prototype,"loading",void 0),c};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var ua=function(o,e,t,s){var i=arguments.length,n=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,e,t,s);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(n=(i<3?r(n):i>3?r(e,t,n):r(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n};const FE=Math.PI/32,NE=3e3,kE={basis:[Dr(Ie(FE,"rad"))],keywords:{auto:[null]}},xs=Symbol("autoRotateStartTime"),da=Symbol("radiansPerSecond"),vh=Symbol("syncRotationRate"),ga=Symbol("onCameraChange"),UE=o=>{var e,t,s;class i extends o{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=NE,this.rotationPerSecond="auto",this[e]=performance.now(),this[t]=0,this[s]=r=>{this.autoRotate&&r.detail.source==="user-interaction"&&(this[xs]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[ga]),this[xs]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[ga]),this[xs]=performance.now()}updated(r){super.updated(r),r.has("autoRotate")&&(this[xs]=performance.now())}[(e=xs,t=da,vh)](r){this[da]=r[0]}[nt](r,a){if(super[nt](r,a),!this.autoRotate||!this[rs]()||this[q].isPresenting)return;const A=Math.min(a,r-this[xs]-this.autoRotateDelay);A>0&&(this[D].yaw=this.turntableRotation+this[da]*A*.001)}get turntableRotation(){return this[D].yaw}resetTurntableRotation(r=0){this[D].yaw=r}}return s=ga,ua([U({type:Boolean,attribute:"auto-rotate"})],i.prototype,"autoRotate",void 0),ua([U({type:Number,attribute:"auto-rotate-delay"})],i.prototype,"autoRotateDelay",void 0),ua([vt({intrinsics:kE,updateHandler:vh}),U({type:String,attribute:"rotation-per-second"})],i.prototype,"rotationPerSecond",void 0),i};/* @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const xd=KI(TI(UE(Bf(Lm(bE(LE(zI(tn))))))));customElements.define("model-viewer",xd);const vd=0,PE=1,GE=2,Qh=2,fa=1.25,Sh=1,Gi=6*4+4+4,Fr=65535,OE=Math.pow(2,-24),pa=Symbol("SKIP_GENERATION");function HE(o){return o.index?o.index.count:o.attributes.position.count}function Zs(o){return HE(o)/3}function $E(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function VE(o,e){if(!o.index){const t=o.attributes.position.count,s=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=$E(t,s);o.setIndex(new Se(i,1));for(let n=0;n<t;n++)i[n]=n}}function Qd(o){const e=Zs(o),t=o.drawRange,s=t.start/3,i=(t.start+t.count)/3,n=Math.max(0,s),r=Math.min(e,i)-n;return[{offset:Math.floor(n),count:Math.floor(r)}]}function Sd(o){if(!o.groups||!o.groups.length)return Qd(o);const e=[],t=new Set,s=o.drawRange,i=s.start/3,n=(s.start+s.count)/3;for(const a of o.groups){const A=a.start/3,c=(a.start+a.count)/3;t.add(Math.max(i,A)),t.add(Math.min(n,c))}const r=Array.from(t.values()).sort((a,A)=>a-A);for(let a=0;a<r.length-1;a++){const A=r[a],c=r[a+1];e.push({offset:Math.floor(A),count:Math.floor(c-A)})}return e}function qE(o){if(o.groups.length===0)return!1;const e=Zs(o),t=Sd(o).sort((n,r)=>n.offset-r.offset),s=t[t.length-1];s.count=Math.min(e-s.offset,s.count);let i=0;return t.forEach(({count:n})=>i+=n),e!==i}function ma(o,e,t,s,i){let n=1/0,r=1/0,a=1/0,A=-1/0,c=-1/0,l=-1/0,h=1/0,u=1/0,d=1/0,g=-1/0,p=-1/0,f=-1/0;for(let m=e*6,E=(e+t)*6;m<E;m+=6){const w=o[m+0],I=o[m+1],C=w-I,x=w+I;C<n&&(n=C),x>A&&(A=x),w<h&&(h=w),w>g&&(g=w);const B=o[m+2],y=o[m+3],v=B-y,Q=B+y;v<r&&(r=v),Q>c&&(c=Q),B<u&&(u=B),B>p&&(p=B);const b=o[m+4],S=o[m+5],M=b-S,T=b+S;M<a&&(a=M),T>l&&(l=T),b<d&&(d=b),b>f&&(f=b)}s[0]=n,s[1]=r,s[2]=a,s[3]=A,s[4]=c,s[5]=l,i[0]=h,i[1]=u,i[2]=d,i[3]=g,i[4]=p,i[5]=f}function zE(o,e=null,t=null,s=null){const i=o.attributes.position,n=o.index?o.index.array:null,r=Zs(o),a=i.normalized;let A;e===null?(A=new Float32Array(r*6*4),t=0,s=r):(A=e,t=t||0,s=s||r);const c=i.array,l=i.offset||0;let h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);const u=["getX","getY","getZ"];for(let d=t;d<t+s;d++){const g=d*3,p=d*6;let f=g+0,m=g+1,E=g+2;n&&(f=n[f],m=n[m],E=n[E]),a||(f=f*h+l,m=m*h+l,E=E*h+l);for(let w=0;w<3;w++){let I,C,x;a?(I=i[u[w]](f),C=i[u[w]](m),x=i[u[w]](E)):(I=c[f+w],C=c[m+w],x=c[E+w]);let B=I;C<B&&(B=C),x<B&&(B=x);let y=I;C>y&&(y=C),x>y&&(y=x);const v=(y-B)/2,Q=w*2;A[p+Q+0]=B+v,A[p+Q+1]=v+(Math.abs(B)+v)*OE}}return A}function ee(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function bh(o){let e=-1,t=-1/0;for(let s=0;s<3;s++){const i=o[s+3]-o[s];i>t&&(t=i,e=s)}return e}function Th(o,e){e.set(o)}function Mh(o,e,t){let s,i;for(let n=0;n<3;n++){const r=n+3;s=o[n],i=e[n],t[n]=s<i?s:i,s=o[r],i=e[r],t[r]=s>i?s:i}}function _n(o,e,t){for(let s=0;s<3;s++){const i=e[o+2*s],n=e[o+2*s+1],r=i-n,a=i+n;r<t[s]&&(t[s]=r),a>t[s+3]&&(t[s+3]=a)}}function Ci(o){const e=o[3]-o[0],t=o[4]-o[1],s=o[5]-o[2];return 2*(e*t+t*s+s*e)}const gt=32,KE=(o,e)=>o.candidate-e.candidate,xt=new Array(gt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Dn=new Float32Array(6);function YE(o,e,t,s,i,n){let r=-1,a=0;if(n===vd)r=bh(e),r!==-1&&(a=(e[r]+e[r+3])/2);else if(n===PE)r=bh(o),r!==-1&&(a=JE(t,s,i,r));else if(n===GE){const A=Ci(o);let c=fa*i;const l=s*6,h=(s+i)*6;for(let u=0;u<3;u++){const d=e[u],f=(e[u+3]-d)/gt;if(i<gt/4){const m=[...xt];m.length=i;let E=0;for(let I=l;I<h;I+=6,E++){const C=m[E];C.candidate=t[I+2*u],C.count=0;const{bounds:x,leftCacheBounds:B,rightCacheBounds:y}=C;for(let v=0;v<3;v++)y[v]=1/0,y[v+3]=-1/0,B[v]=1/0,B[v+3]=-1/0,x[v]=1/0,x[v+3]=-1/0;_n(I,t,x)}m.sort(KE);let w=i;for(let I=0;I<w;I++){const C=m[I];for(;I+1<w&&m[I+1].candidate===C.candidate;)m.splice(I+1,1),w--}for(let I=l;I<h;I+=6){const C=t[I+2*u];for(let x=0;x<w;x++){const B=m[x];C>=B.candidate?_n(I,t,B.rightCacheBounds):(_n(I,t,B.leftCacheBounds),B.count++)}}for(let I=0;I<w;I++){const C=m[I],x=C.count,B=i-C.count,y=C.leftCacheBounds,v=C.rightCacheBounds;let Q=0;x!==0&&(Q=Ci(y)/A);let b=0;B!==0&&(b=Ci(v)/A);const S=Sh+fa*(Q*x+b*B);S<c&&(r=u,c=S,a=C.candidate)}}else{for(let w=0;w<gt;w++){const I=xt[w];I.count=0,I.candidate=d+f+w*f;const C=I.bounds;for(let x=0;x<3;x++)C[x]=1/0,C[x+3]=-1/0}for(let w=l;w<h;w+=6){let x=~~((t[w+2*u]-d)/f);x>=gt&&(x=gt-1);const B=xt[x];B.count++,_n(w,t,B.bounds)}const m=xt[gt-1];Th(m.bounds,m.rightCacheBounds);for(let w=gt-2;w>=0;w--){const I=xt[w],C=xt[w+1];Mh(I.bounds,C.rightCacheBounds,I.rightCacheBounds)}let E=0;for(let w=0;w<gt-1;w++){const I=xt[w],C=I.count,x=I.bounds,y=xt[w+1].rightCacheBounds;C!==0&&(E===0?Th(x,Dn):Mh(x,Dn,Dn)),E+=C;let v=0,Q=0;E!==0&&(v=Ci(Dn)/A);const b=i-E;b!==0&&(Q=Ci(y)/A);const S=Sh+fa*(v*E+Q*b);S<c&&(r=u,c=S,a=I.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:r,pos:a}}function JE(o,e,t,s){let i=0;for(let n=e,r=e+t;n<r;n++)i+=o[n*6+s*2];return i/t}class Ia{constructor(){this.boundingData=new Float32Array(6)}}function jE(o,e,t,s,i,n){let r=s,a=s+i-1;const A=n.pos,c=n.axis*2;for(;;){for(;r<=a&&t[r*6+c]<A;)r++;for(;r<=a&&t[a*6+c]>=A;)a--;if(r<a){for(let l=0;l<3;l++){let h=e[r*3+l];e[r*3+l]=e[a*3+l],e[a*3+l]=h}for(let l=0;l<6;l++){let h=t[r*6+l];t[r*6+l]=t[a*6+l],t[a*6+l]=h}r++,a--}else return r}}function WE(o,e,t,s,i,n){let r=s,a=s+i-1;const A=n.pos,c=n.axis*2;for(;;){for(;r<=a&&t[r*6+c]<A;)r++;for(;r<=a&&t[a*6+c]>=A;)a--;if(r<a){let l=o[r];o[r]=o[a],o[a]=l;for(let h=0;h<6;h++){let u=t[r*6+h];t[r*6+h]=t[a*6+h],t[a*6+h]=u}r++,a--}else return r}}function Qe(o,e){return e[o+15]===65535}function Fe(o,e){return e[o+6]}function Oe(o,e){return e[o+14]}function He(o){return o+8}function $e(o,e){return e[o+6]}function bd(o,e){return e[o+7]}let Td,Fi,ar,Md;const XE=Math.pow(2,32);function Ya(o){return"count"in o?1:1+Ya(o.left)+Ya(o.right)}function ZE(o,e,t){return Td=new Float32Array(t),Fi=new Uint32Array(t),ar=new Uint16Array(t),Md=new Uint8Array(t),Ja(o,e)}function Ja(o,e){const t=o/4,s=o/2,i="count"in e,n=e.boundingData;for(let r=0;r<6;r++)Td[t+r]=n[r];if(i)if(e.buffer){const r=e.buffer;Md.set(new Uint8Array(r),o);for(let a=o,A=o+r.byteLength;a<A;a+=Gi){const c=a/2;Qe(c,ar)||(Fi[a/4+6]+=t)}return o+r.byteLength}else{const r=e.offset,a=e.count;return Fi[t+6]=r,ar[s+14]=a,ar[s+15]=Fr,o+Gi}else{const r=e.left,a=e.right,A=e.splitAxis;let c;if(c=Ja(o+Gi,r),c/4>XE)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Fi[t+6]=c/4,c=Ja(c,a),Fi[t+7]=A,c}}function eC(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,s=t>2**16,i=s?4:2,n=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),r=s?new Uint32Array(n):new Uint16Array(n);for(let a=0,A=r.length;a<A;a++)r[a]=a;return r}function tC(o,e,t,s,i){const{maxDepth:n,verbose:r,maxLeafTris:a,strategy:A,onProgress:c,indirect:l}=i,h=o._indirectBuffer,u=o.geometry,d=u.index?u.index.array:null,g=l?WE:jE,p=Zs(u),f=new Float32Array(6);let m=!1;const E=new Ia;return ma(e,t,s,E.boundingData,f),I(E,t,s,f),E;function w(C){c&&c(C/p)}function I(C,x,B,y=null,v=0){if(!m&&v>=n&&(m=!0,r&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(u))),B<=a||v>=n)return w(x+B),C.offset=x,C.count=B,C;const Q=YE(C.boundingData,y,e,x,B,A);if(Q.axis===-1)return w(x+B),C.offset=x,C.count=B,C;const b=g(h,d,e,x,B,Q);if(b===x||b===x+B)w(x+B),C.offset=x,C.count=B;else{C.splitAxis=Q.axis;const S=new Ia,M=x,T=b-x;C.left=S,ma(e,M,T,S.boundingData,f),I(S,M,T,f,v+1);const _=new Ia,L=b,N=B-T;C.right=_,ma(e,L,N,_.boundingData,f),I(_,L,N,f,v+1)}return C}}function sC(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=eC(t,e.useSharedArrayBuffer),qE(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),o._indirectBuffer||VE(t,e);const s=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=zE(t),n=e.indirect?Qd(t):Sd(t);o._roots=n.map(r=>{const a=tC(o,i,r.offset,r.count,e),A=Ya(a),c=new s(Gi*A);return ZE(0,a,c),c})}class mt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let s=1/0,i=-1/0;for(let n=0,r=e.length;n<r;n++){const A=e[n][t];s=A<s?A:s,i=A>i?A:i}this.min=s,this.max=i}setFromPoints(e,t){let s=1/0,i=-1/0;for(let n=0,r=t.length;n<r;n++){const a=t[n],A=e.dot(a);s=A<s?A:s,i=A>i?A:i}this.min=s,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}mt.prototype.setFromBox=function(){const o=new R;return function(t,s){const i=s.min,n=s.max;let r=1/0,a=-1/0;for(let A=0;A<=1;A++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){o.x=i.x*A+n.x*(1-A),o.y=i.y*c+n.y*(1-c),o.z=i.z*l+n.z*(1-l);const h=t.dot(o);r=Math.min(h,r),a=Math.max(h,a)}this.min=r,this.max=a}}();const iC=function(){const o=new R,e=new R,t=new R;return function(i,n,r){const a=i.start,A=o,c=n.start,l=e;t.subVectors(a,c),o.subVectors(i.end,i.start),e.subVectors(n.end,n.start);const h=t.dot(l),u=l.dot(A),d=l.dot(l),g=t.dot(A),f=A.dot(A)*d-u*u;let m,E;f!==0?m=(h*u-g*d)/f:m=0,E=(h+m*u)/d,r.x=m,r.y=E}}(),dA=function(){const o=new ce,e=new R,t=new R;return function(i,n,r,a){iC(i,n,o);let A=o.x,c=o.y;if(A>=0&&A<=1&&c>=0&&c<=1){i.at(A,r),n.at(c,a);return}else if(A>=0&&A<=1){c<0?n.at(0,a):n.at(1,a),i.closestPointToPoint(a,!0,r);return}else if(c>=0&&c<=1){A<0?i.at(0,r):i.at(1,r),n.closestPointToPoint(r,!0,a);return}else{let l;A<0?l=i.start:l=i.end;let h;c<0?h=n.start:h=n.end;const u=e,d=t;if(i.closestPointToPoint(h,!0,e),n.closestPointToPoint(l,!0,t),u.distanceToSquared(h)<=d.distanceToSquared(l)){r.copy(u),a.copy(h);return}else{r.copy(l),a.copy(d);return}}}}(),nC=function(){const o=new R,e=new R,t=new nu,s=new pt;return function(n,r){const{radius:a,center:A}=n,{a:c,b:l,c:h}=r;if(s.start=c,s.end=l,s.closestPointToPoint(A,!0,o).distanceTo(A)<=a||(s.start=c,s.end=h,s.closestPointToPoint(A,!0,o).distanceTo(A)<=a)||(s.start=l,s.end=h,s.closestPointToPoint(A,!0,o).distanceTo(A)<=a))return!0;const p=r.getPlane(t);if(Math.abs(p.distanceToPoint(A))<=a){const m=p.projectPoint(A,e);if(r.containsPoint(m))return!0}return!1}}(),rC=1e-15;function Ea(o){return Math.abs(o)<rC}class Ye extends ts{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new R),this.satBounds=new Array(4).fill().map(()=>new mt),this.points=[this.a,this.b,this.c],this.sphere=new br,this.plane=new nu,this.needsUpdate=!0}intersectsSphere(e){return nC(e,this)}update(){const e=this.a,t=this.b,s=this.c,i=this.points,n=this.satAxes,r=this.satBounds,a=n[0],A=r[0];this.getNormal(a),A.setFromPoints(a,i);const c=n[1],l=r[1];c.subVectors(e,t),l.setFromPoints(c,i);const h=n[2],u=r[2];h.subVectors(t,s),u.setFromPoints(h,i);const d=n[3],g=r[3];d.subVectors(s,e),g.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Ye.prototype.closestPointToSegment=function(){const o=new R,e=new R,t=new pt;return function(i,n=null,r=null){const{start:a,end:A}=i,c=this.points;let l,h=1/0;for(let u=0;u<3;u++){const d=(u+1)%3;t.start.copy(c[u]),t.end.copy(c[d]),dA(t,i,o,e),l=o.distanceToSquared(e),l<h&&(h=l,n&&n.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),l=a.distanceToSquared(o),l<h&&(h=l,n&&n.copy(o),r&&r.copy(a)),this.closestPointToPoint(A,o),l=A.distanceToSquared(o),l<h&&(h=l,n&&n.copy(o),r&&r.copy(A)),Math.sqrt(h)}}();Ye.prototype.intersectsTriangle=function(){const o=new Ye,e=new Array(3),t=new Array(3),s=new mt,i=new mt,n=new R,r=new R,a=new R,A=new R,c=new R,l=new pt,h=new pt,u=new pt,d=new R;function g(p,f,m){const E=p.points;let w=0,I=-1;for(let C=0;C<3;C++){const{start:x,end:B}=l;x.copy(E[C]),B.copy(E[(C+1)%3]),l.delta(r);const y=Ea(f.distanceToPoint(x));if(Ea(f.normal.dot(r))&&y){m.copy(l),w=2;break}const v=f.intersectLine(l,d);if(!v&&y&&d.copy(x),(v||y)&&!Ea(d.distanceTo(B))){if(w<=1)(w===1?m.start:m.end).copy(d),y&&(I=w);else if(w>=2){(I===1?m.start:m.end).copy(d),w=2;break}if(w++,w===2&&I===-1)break}}return w}return function(f,m=null,E=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(o.copy(f),o.update(),f=o);const w=this.plane,I=f.plane;if(Math.abs(w.normal.dot(I.normal))>1-1e-10){const C=this.satBounds,x=this.satAxes;t[0]=f.a,t[1]=f.b,t[2]=f.c;for(let v=0;v<4;v++){const Q=C[v],b=x[v];if(s.setFromPoints(b,t),Q.isSeparated(s))return!1}const B=f.satBounds,y=f.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let v=0;v<4;v++){const Q=B[v],b=y[v];if(s.setFromPoints(b,e),Q.isSeparated(s))return!1}for(let v=0;v<4;v++){const Q=x[v];for(let b=0;b<4;b++){const S=y[b];if(n.crossVectors(Q,S),s.setFromPoints(n,e),i.setFromPoints(n,t),s.isSeparated(i))return!1}}return m&&(E||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{const C=g(this,I,h);if(C===1&&f.containsPoint(h.end))return m&&(m.start.copy(h.end),m.end.copy(h.end)),!0;if(C!==2)return!1;const x=g(f,w,u);if(x===1&&this.containsPoint(u.end))return m&&(m.start.copy(u.end),m.end.copy(u.end)),!0;if(x!==2)return!1;if(h.delta(a),u.delta(A),a.dot(A)<0){let M=u.start;u.start=u.end,u.end=M}const B=h.start.dot(a),y=h.end.dot(a),v=u.start.dot(a),Q=u.end.dot(a),b=y<v,S=B<Q;return B!==Q&&v!==y&&b===S?!1:(m&&(c.subVectors(h.start,u.start),c.dot(a)>0?m.start.copy(h.start):m.start.copy(u.start),c.subVectors(h.end,u.end),c.dot(a)<0?m.end.copy(h.end):m.end.copy(u.end)),!0)}}}();Ye.prototype.distanceToPoint=function(){const o=new R;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();Ye.prototype.distanceToTriangle=function(){const o=new R,e=new R,t=["a","b","c"],s=new pt,i=new pt;return function(r,a=null,A=null){const c=a||A?s:null;if(this.intersectsTriangle(r,c))return(a||A)&&(a&&c.getCenter(a),A&&c.getCenter(A)),0;let l=1/0;for(let h=0;h<3;h++){let u;const d=t[h],g=r[d];this.closestPointToPoint(g,o),u=g.distanceToSquared(o),u<l&&(l=u,a&&a.copy(o),A&&A.copy(g));const p=this[d];r.closestPointToPoint(p,o),u=p.distanceToSquared(o),u<l&&(l=u,a&&a.copy(p),A&&A.copy(o))}for(let h=0;h<3;h++){const u=t[h],d=t[(h+1)%3];s.set(this[u],this[d]);for(let g=0;g<3;g++){const p=t[g],f=t[(g+1)%3];i.set(r[p],r[f]),dA(s,i,o,e);const m=o.distanceToSquared(e);m<l&&(l=m,a&&a.copy(o),A&&A.copy(e))}}return Math.sqrt(l)}}();class we{constructor(e,t,s){this.isOrientedBox=!0,this.min=new R,this.max=new R,this.matrix=new le,this.invMatrix=new le,this.points=new Array(8).fill().map(()=>new R),this.satAxes=new Array(3).fill().map(()=>new R),this.satBounds=new Array(3).fill().map(()=>new mt),this.alignedSatBounds=new Array(3).fill().map(()=>new mt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),s&&this.matrix.copy(s)}set(e,t,s){this.min.copy(e),this.max.copy(t),this.matrix.copy(s),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}we.prototype.update=function(){return function(){const e=this.matrix,t=this.min,s=this.max,i=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){const u=1*c|2*l|4*h,d=i[u];d.x=c?s.x:t.x,d.y=l?s.y:t.y,d.z=h?s.z:t.z,d.applyMatrix4(e)}const n=this.satBounds,r=this.satAxes,a=i[0];for(let c=0;c<3;c++){const l=r[c],h=n[c],u=1<<c,d=i[u];l.subVectors(a,d),h.setFromPoints(l,i)}const A=this.alignedSatBounds;A[0].setFromPointsField(i,"x"),A[1].setFromPointsField(i,"y"),A[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();we.prototype.intersectsBox=function(){const o=new mt;return function(t){this.needsUpdate&&this.update();const s=t.min,i=t.max,n=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(o.min=s.x,o.max=i.x,a[0].isSeparated(o)||(o.min=s.y,o.max=i.y,a[1].isSeparated(o))||(o.min=s.z,o.max=i.z,a[2].isSeparated(o)))return!1;for(let A=0;A<3;A++){const c=r[A],l=n[A];if(o.setFromBox(c,t),l.isSeparated(o))return!1}return!0}}();we.prototype.intersectsTriangle=function(){const o=new Ye,e=new Array(3),t=new mt,s=new mt,i=new R;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(o.copy(r),o.update(),r=o);const a=this.satBounds,A=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let u=0;u<3;u++){const d=a[u],g=A[u];if(t.setFromPoints(g,e),d.isSeparated(t))return!1}const c=r.satBounds,l=r.satAxes,h=this.points;for(let u=0;u<3;u++){const d=c[u],g=l[u];if(t.setFromPoints(g,h),d.isSeparated(t))return!1}for(let u=0;u<3;u++){const d=A[u];for(let g=0;g<4;g++){const p=l[g];if(i.crossVectors(d,p),t.setFromPoints(i,e),s.setFromPoints(i,h),t.isSeparated(s))return!1}}return!0}}();we.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();we.prototype.distanceToPoint=function(){const o=new R;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();we.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new pt),t=new Array(12).fill().map(()=>new pt),s=new R,i=new R;return function(r,a=0,A=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(A||c)&&(r.getCenter(i),this.closestPointToPoint(i,s),r.closestPointToPoint(s,i),A&&A.copy(s),c&&c.copy(i)),0;const l=a*a,h=r.min,u=r.max,d=this.points;let g=1/0;for(let f=0;f<8;f++){const m=d[f];i.copy(m).clamp(h,u);const E=m.distanceToSquared(i);if(E<g&&(g=E,A&&A.copy(m),c&&c.copy(i),E<l))return Math.sqrt(E)}let p=0;for(let f=0;f<3;f++)for(let m=0;m<=1;m++)for(let E=0;E<=1;E++){const w=(f+1)%3,I=(f+2)%3,C=m<<w|E<<I,x=1<<f|m<<w|E<<I,B=d[C],y=d[x];e[p].set(B,y);const Q=o[f],b=o[w],S=o[I],M=t[p],T=M.start,_=M.end;T[Q]=h[Q],T[b]=m?h[b]:u[b],T[S]=E?h[S]:u[b],_[Q]=u[Q],_[b]=m?h[b]:u[b],_[S]=E?h[S]:u[b],p++}for(let f=0;f<=1;f++)for(let m=0;m<=1;m++)for(let E=0;E<=1;E++){i.x=f?u.x:h.x,i.y=m?u.y:h.y,i.z=E?u.z:h.z,this.closestPointToPoint(i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,A&&A.copy(s),c&&c.copy(i),w<l))return Math.sqrt(w)}for(let f=0;f<12;f++){const m=e[f];for(let E=0;E<12;E++){const w=t[E];dA(m,w,s,i);const I=s.distanceToSquared(i);if(I<g&&(g=I,A&&A.copy(s),c&&c.copy(i),I<l))return Math.sqrt(I)}}return Math.sqrt(g)}}();class gA{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class oC extends gA{constructor(){super(()=>new Ye)}}const Ve=new oC;class aC{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=s=>{t&&e.push(t),t=s,this.float32Array=new Float32Array(s),this.uint16Array=new Uint16Array(s),this.uint32Array=new Uint32Array(s)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const W=new aC;let Dt,Gs;const vs=[],Ln=new gA(()=>new Ae);function AC(o,e,t,s,i,n){Dt=Ln.getPrimitive(),Gs=Ln.getPrimitive(),vs.push(Dt,Gs),W.setBuffer(o._roots[e]);const r=ja(0,o.geometry,t,s,i,n);W.clearBuffer(),Ln.releasePrimitive(Dt),Ln.releasePrimitive(Gs),vs.pop(),vs.pop();const a=vs.length;return a>0&&(Gs=vs[a-1],Dt=vs[a-2]),r}function ja(o,e,t,s,i=null,n=0,r=0){const{float32Array:a,uint16Array:A,uint32Array:c}=W;let l=o*2;if(Qe(l,A)){const u=Fe(o,c),d=Oe(l,A);return ee(o,a,Dt),s(u,d,!1,r,n+o,Dt)}else{let Q=function(S){const{uint16Array:M,uint32Array:T}=W;let _=S*2;for(;!Qe(_,M);)S=He(S),_=S*2;return Fe(S,T)},b=function(S){const{uint16Array:M,uint32Array:T}=W;let _=S*2;for(;!Qe(_,M);)S=$e(S,T),_=S*2;return Fe(S,T)+Oe(_,M)};const u=He(o),d=$e(o,c);let g=u,p=d,f,m,E,w;if(i&&(E=Dt,w=Gs,ee(g,a,E),ee(p,a,w),f=i(E),m=i(w),m<f)){g=d,p=u;const S=f;f=m,m=S,E=w}E||(E=Dt,ee(g,a,E));const I=Qe(g*2,A),C=t(E,I,f,r+1,n+g);let x;if(C===Qh){const S=Q(g),T=b(g)-S;x=s(S,T,!0,r+1,n+g,E)}else x=C&&ja(g,e,t,s,i,n,r+1);if(x)return!0;w=Gs,ee(p,a,w);const B=Qe(p*2,A),y=t(w,B,m,r+1,n+p);let v;if(y===Qh){const S=Q(p),T=b(p)-S;v=s(S,T,!0,r+1,n+p,w)}else v=y&&ja(p,e,t,s,i,n,r+1);return!!v}}const Bi=new R,Ca=new R;function cC(o,e,t={},s=0,i=1/0){const n=s*s,r=i*i;let a=1/0,A=null;if(o.shapecast({boundsTraverseOrder:l=>(Bi.copy(e).clamp(l.min,l.max),Bi.distanceToSquared(e)),intersectsBounds:(l,h,u)=>u<a&&u<r,intersectsTriangle:(l,h)=>{l.closestPointToPoint(e,Bi);const u=e.distanceToSquared(Bi);return u<a&&(Ca.copy(Bi),a=u,A=h),u<n}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(Ca):t.point=Ca.clone(),t.distance=c,t.faceIndex=A,t}const Qs=new R,Ss=new R,bs=new R,Fn=new ce,Nn=new ce,kn=new ce,Rh=new R,_h=new R,Dh=new R,Un=new R;function lC(o,e,t,s,i,n){let r;return n===Mr?r=o.intersectTriangle(s,t,e,!0,i):r=o.intersectTriangle(e,t,s,n!==kt,i),r===null?null:{distance:o.origin.distanceTo(i),point:i.clone()}}function hC(o,e,t,s,i,n,r,a,A){Qs.fromBufferAttribute(e,n),Ss.fromBufferAttribute(e,r),bs.fromBufferAttribute(e,a);const c=lC(o,Qs,Ss,bs,Un,A);if(c){s&&(Fn.fromBufferAttribute(s,n),Nn.fromBufferAttribute(s,r),kn.fromBufferAttribute(s,a),c.uv=ts.getInterpolation(Un,Qs,Ss,bs,Fn,Nn,kn,new ce)),i&&(Fn.fromBufferAttribute(i,n),Nn.fromBufferAttribute(i,r),kn.fromBufferAttribute(i,a),c.uv1=ts.getInterpolation(Un,Qs,Ss,bs,Fn,Nn,kn,new ce)),t&&(Rh.fromBufferAttribute(t,n),_h.fromBufferAttribute(t,r),Dh.fromBufferAttribute(t,a),c.normal=ts.getInterpolation(Un,Qs,Ss,bs,Rh,_h,Dh,new R),c.normal.dot(o.direction)>0&&c.normal.multiplyScalar(-1));const l={a:n,b:r,c:a,normal:new R,materialIndex:0};ts.getNormal(Qs,Ss,bs,l.normal),c.face=l,c.faceIndex=n}return c}function Nr(o,e,t,s,i){const n=s*3;let r=n+0,a=n+1,A=n+2;const c=o.index;o.index&&(r=c.getX(r),a=c.getX(a),A=c.getX(A));const{position:l,normal:h,uv:u,uv1:d}=o.attributes,g=hC(t,l,h,u,d,r,a,A,e);return g?(g.faceIndex=s,i&&i.push(g),g):null}function se(o,e,t,s){const i=o.a,n=o.b,r=o.c;let a=e,A=e+1,c=e+2;t&&(a=t.getX(a),A=t.getX(A),c=t.getX(c)),i.x=s.getX(a),i.y=s.getY(a),i.z=s.getZ(a),n.x=s.getX(A),n.y=s.getY(A),n.z=s.getZ(A),r.x=s.getX(c),r.y=s.getY(c),r.z=s.getZ(c)}function uC(o,e,t,s,i,n){const{geometry:r,_indirectBuffer:a}=o;for(let A=s,c=s+i;A<c;A++)Nr(r,e,t,A,n)}function dC(o,e,t,s,i){const{geometry:n,_indirectBuffer:r}=o;let a=1/0,A=null;for(let c=s,l=s+i;c<l;c++){let h;h=Nr(n,e,t,c),h&&h.distance<a&&(A=h,a=h.distance)}return A}function gC(o,e,t,s,i,n,r){const{geometry:a}=t,{index:A}=a,c=a.attributes.position;for(let l=o,h=e+o;l<h;l++){let u;if(u=l,se(r,u*3,A,c),r.needsUpdate=!0,s(r,u,i,n))return!0}return!1}function fC(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,s=t.index?t.index.array:null,i=t.attributes.position;let n,r,a,A,c=0;const l=o._roots;for(let u=0,d=l.length;u<d;u++)n=l[u],r=new Uint32Array(n),a=new Uint16Array(n),A=new Float32Array(n),h(0,c),c+=n.byteLength;function h(u,d,g=!1){const p=u*2;if(a[p+15]===Fr){const m=r[u+6],E=a[p+14];let w=1/0,I=1/0,C=1/0,x=-1/0,B=-1/0,y=-1/0;for(let v=3*m,Q=3*(m+E);v<Q;v++){let b=s[v];const S=i.getX(b),M=i.getY(b),T=i.getZ(b);S<w&&(w=S),S>x&&(x=S),M<I&&(I=M),M>B&&(B=M),T<C&&(C=T),T>y&&(y=T)}return A[u+0]!==w||A[u+1]!==I||A[u+2]!==C||A[u+3]!==x||A[u+4]!==B||A[u+5]!==y?(A[u+0]=w,A[u+1]=I,A[u+2]=C,A[u+3]=x,A[u+4]=B,A[u+5]=y,!0):!1}else{const m=u+8,E=r[u+6],w=m+d,I=E+d;let C=g,x=!1,B=!1;e?C||(x=e.has(w),B=e.has(I),C=!x&&!B):(x=!0,B=!0);const y=C||x,v=C||B;let Q=!1;y&&(Q=h(m,d,C));let b=!1;v&&(b=h(E,d,C));const S=Q||b;if(S)for(let M=0;M<3;M++){const T=m+M,_=E+M,L=A[T],N=A[T+3],P=A[_],$=A[_+3];A[u+M]=L<P?L:P,A[u+M+3]=N>$?N:$}return S}}}const Lh=new Ae;function Ot(o,e,t,s){return ee(o,e,Lh),t.intersectBox(Lh,s)}function pC(o,e,t,s,i,n){const{geometry:r,_indirectBuffer:a}=o;for(let A=s,c=s+i;A<c;A++){let l=a?a[A]:A;Nr(r,e,t,l,n)}}function mC(o,e,t,s,i){const{geometry:n,_indirectBuffer:r}=o;let a=1/0,A=null;for(let c=s,l=s+i;c<l;c++){let h;h=Nr(n,e,t,r?r[c]:c),h&&h.distance<a&&(A=h,a=h.distance)}return A}function IC(o,e,t,s,i,n,r){const{geometry:a}=t,{index:A}=a,c=a.attributes.position;for(let l=o,h=e+o;l<h;l++){let u;if(u=t.resolveTriangleIndex(l),se(r,u*3,A,c),r.needsUpdate=!0,s(r,u,i,n))return!0}return!1}const Fh=new R;function EC(o,e,t,s,i){W.setBuffer(o._roots[e]),Wa(0,o,t,s,i),W.clearBuffer()}function Wa(o,e,t,s,i){const{float32Array:n,uint16Array:r,uint32Array:a}=W,A=o*2;if(Qe(A,r)){const l=Fe(o,a),h=Oe(A,r);uC(e,t,s,l,h,i)}else{const l=He(o);Ot(l,n,s,Fh)&&Wa(l,e,t,s,i);const h=$e(o,a);Ot(h,n,s,Fh)&&Wa(h,e,t,s,i)}}const Nh=new R,CC=["x","y","z"];function BC(o,e,t,s){W.setBuffer(o._roots[e]);const i=Xa(0,o,t,s);return W.clearBuffer(),i}function Xa(o,e,t,s){const{float32Array:i,uint16Array:n,uint32Array:r}=W;let a=o*2;if(Qe(a,n)){const c=Fe(o,r),l=Oe(a,n);return dC(e,t,s,c,l)}else{const c=bd(o,r),l=CC[c],u=s.direction[l]>=0;let d,g;u?(d=He(o),g=$e(o,r)):(d=$e(o,r),g=He(o));const f=Ot(d,i,s,Nh)?Xa(d,e,t,s):null;if(f){const w=f.point[l];if(u?w<=i[g+c]:w>=i[g+c+3])return f}const E=Ot(g,i,s,Nh)?Xa(g,e,t,s):null;return f&&E?f.distance<=E.distance?f:E:f||E||null}}const Pn=new Ae,Ts=new Ye,Ms=new Ye,yi=new le,kh=new we,Gn=new we;function yC(o,e,t,s){W.setBuffer(o._roots[e]);const i=Za(0,o,t,s);return W.clearBuffer(),i}function Za(o,e,t,s,i=null){const{float32Array:n,uint16Array:r,uint32Array:a}=W;let A=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),kh.set(t.boundingBox.min,t.boundingBox.max,s),i=kh),Qe(A,r)){const l=e.geometry,h=l.index,u=l.attributes.position,d=t.index,g=t.attributes.position,p=Fe(o,a),f=Oe(A,r);if(yi.copy(s).invert(),t.boundsTree)return ee(o,n,Gn),Gn.matrix.copy(yi),Gn.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:E=>Gn.intersectsBox(E),intersectsTriangle:E=>{E.a.applyMatrix4(s),E.b.applyMatrix4(s),E.c.applyMatrix4(s),E.needsUpdate=!0;for(let w=p*3,I=(f+p)*3;w<I;w+=3)if(se(Ms,w,h,u),Ms.needsUpdate=!0,E.intersectsTriangle(Ms))return!0;return!1}});for(let m=p*3,E=(f+p)*3;m<E;m+=3){se(Ts,m,h,u),Ts.a.applyMatrix4(yi),Ts.b.applyMatrix4(yi),Ts.c.applyMatrix4(yi),Ts.needsUpdate=!0;for(let w=0,I=d.count;w<I;w+=3)if(se(Ms,w,d,g),Ms.needsUpdate=!0,Ts.intersectsTriangle(Ms))return!0}}else{const l=o+8,h=a[o+6];return ee(l,n,Pn),!!(i.intersectsBox(Pn)&&Za(l,e,t,s,i)||(ee(h,n,Pn),i.intersectsBox(Pn)&&Za(h,e,t,s,i)))}}const On=new le,Ba=new we,wi=new we,wC=new R,xC=new R,vC=new R,QC=new R;function SC(o,e,t,s={},i={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),Ba.set(e.boundingBox.min,e.boundingBox.max,t),Ba.needsUpdate=!0;const a=o.geometry,A=a.attributes.position,c=a.index,l=e.attributes.position,h=e.index,u=Ve.getPrimitive(),d=Ve.getPrimitive();let g=wC,p=xC,f=null,m=null;i&&(f=vC,m=QC);let E=1/0,w=null,I=null;return On.copy(t).invert(),wi.matrix.copy(On),o.shapecast({boundsTraverseOrder:C=>Ba.distanceToBox(C),intersectsBounds:(C,x,B)=>B<E&&B<r?(x&&(wi.min.copy(C.min),wi.max.copy(C.max),wi.needsUpdate=!0),!0):!1,intersectsRange:(C,x)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:y=>wi.distanceToBox(y),intersectsBounds:(y,v,Q)=>Q<E&&Q<r,intersectsRange:(y,v)=>{for(let Q=y,b=y+v;Q<b;Q++){se(d,3*Q,h,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=C,M=C+x;S<M;S++){se(u,3*S,c,A),u.needsUpdate=!0;const T=u.distanceToTriangle(d,g,f);if(T<E&&(p.copy(g),m&&m.copy(f),E=T,w=S,I=Q),T<n)return!0}}}});{const B=Zs(e);for(let y=0,v=B;y<v;y++){se(d,3*y,h,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let Q=C,b=C+x;Q<b;Q++){se(u,3*Q,c,A),u.needsUpdate=!0;const S=u.distanceToTriangle(d,g,f);if(S<E&&(p.copy(g),m&&m.copy(f),E=S,w=Q,I=y),S<n)return!0}}}}}),Ve.releasePrimitive(u),Ve.releasePrimitive(d),E===1/0?null:(s.point?s.point.copy(p):s.point=p.clone(),s.distance=E,s.faceIndex=w,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(On),p.applyMatrix4(On),i.distance=p.sub(i.point).length(),i.faceIndex=I),s)}function bC(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,s=t.index?t.index.array:null,i=t.attributes.position;let n,r,a,A,c=0;const l=o._roots;for(let u=0,d=l.length;u<d;u++)n=l[u],r=new Uint32Array(n),a=new Uint16Array(n),A=new Float32Array(n),h(0,c),c+=n.byteLength;function h(u,d,g=!1){const p=u*2;if(a[p+15]===Fr){const m=r[u+6],E=a[p+14];let w=1/0,I=1/0,C=1/0,x=-1/0,B=-1/0,y=-1/0;for(let v=m,Q=m+E;v<Q;v++){const b=3*o.resolveTriangleIndex(v);for(let S=0;S<3;S++){let M=b+S;M=s?s[M]:M;const T=i.getX(M),_=i.getY(M),L=i.getZ(M);T<w&&(w=T),T>x&&(x=T),_<I&&(I=_),_>B&&(B=_),L<C&&(C=L),L>y&&(y=L)}}return A[u+0]!==w||A[u+1]!==I||A[u+2]!==C||A[u+3]!==x||A[u+4]!==B||A[u+5]!==y?(A[u+0]=w,A[u+1]=I,A[u+2]=C,A[u+3]=x,A[u+4]=B,A[u+5]=y,!0):!1}else{const m=u+8,E=r[u+6],w=m+d,I=E+d;let C=g,x=!1,B=!1;e?C||(x=e.has(w),B=e.has(I),C=!x&&!B):(x=!0,B=!0);const y=C||x,v=C||B;let Q=!1;y&&(Q=h(m,d,C));let b=!1;v&&(b=h(E,d,C));const S=Q||b;if(S)for(let M=0;M<3;M++){const T=m+M,_=E+M,L=A[T],N=A[T+3],P=A[_],$=A[_+3];A[u+M]=L<P?L:P,A[u+M+3]=N>$?N:$}return S}}}const Uh=new R;function TC(o,e,t,s,i){W.setBuffer(o._roots[e]),eA(0,o,t,s,i),W.clearBuffer()}function eA(o,e,t,s,i){const{float32Array:n,uint16Array:r,uint32Array:a}=W,A=o*2;if(Qe(A,r)){const l=Fe(o,a),h=Oe(A,r);pC(e,t,s,l,h,i)}else{const l=He(o);Ot(l,n,s,Uh)&&eA(l,e,t,s,i);const h=$e(o,a);Ot(h,n,s,Uh)&&eA(h,e,t,s,i)}}const Ph=new R,MC=["x","y","z"];function RC(o,e,t,s){W.setBuffer(o._roots[e]);const i=tA(0,o,t,s);return W.clearBuffer(),i}function tA(o,e,t,s){const{float32Array:i,uint16Array:n,uint32Array:r}=W;let a=o*2;if(Qe(a,n)){const c=Fe(o,r),l=Oe(a,n);return mC(e,t,s,c,l)}else{const c=bd(o,r),l=MC[c],u=s.direction[l]>=0;let d,g;u?(d=He(o),g=$e(o,r)):(d=$e(o,r),g=He(o));const f=Ot(d,i,s,Ph)?tA(d,e,t,s):null;if(f){const w=f.point[l];if(u?w<=i[g+c]:w>=i[g+c+3])return f}const E=Ot(g,i,s,Ph)?tA(g,e,t,s):null;return f&&E?f.distance<=E.distance?f:E:f||E||null}}const Hn=new Ae,Rs=new Ye,_s=new Ye,xi=new le,Gh=new we,$n=new we;function _C(o,e,t,s){W.setBuffer(o._roots[e]);const i=sA(0,o,t,s);return W.clearBuffer(),i}function sA(o,e,t,s,i=null){const{float32Array:n,uint16Array:r,uint32Array:a}=W;let A=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Gh.set(t.boundingBox.min,t.boundingBox.max,s),i=Gh),Qe(A,r)){const l=e.geometry,h=l.index,u=l.attributes.position,d=t.index,g=t.attributes.position,p=Fe(o,a),f=Oe(A,r);if(xi.copy(s).invert(),t.boundsTree)return ee(o,n,$n),$n.matrix.copy(xi),$n.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:E=>$n.intersectsBox(E),intersectsTriangle:E=>{E.a.applyMatrix4(s),E.b.applyMatrix4(s),E.c.applyMatrix4(s),E.needsUpdate=!0;for(let w=p,I=f+p;w<I;w++)if(se(_s,3*e.resolveTriangleIndex(w),h,u),_s.needsUpdate=!0,E.intersectsTriangle(_s))return!0;return!1}});for(let m=p,E=f+p;m<E;m++){const w=e.resolveTriangleIndex(m);se(Rs,3*w,h,u),Rs.a.applyMatrix4(xi),Rs.b.applyMatrix4(xi),Rs.c.applyMatrix4(xi),Rs.needsUpdate=!0;for(let I=0,C=d.count;I<C;I+=3)if(se(_s,I,d,g),_s.needsUpdate=!0,Rs.intersectsTriangle(_s))return!0}}else{const l=o+8,h=a[o+6];return ee(l,n,Hn),!!(i.intersectsBox(Hn)&&sA(l,e,t,s,i)||(ee(h,n,Hn),i.intersectsBox(Hn)&&sA(h,e,t,s,i)))}}const Vn=new le,ya=new we,vi=new we,DC=new R,LC=new R,FC=new R,NC=new R;function kC(o,e,t,s={},i={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ya.set(e.boundingBox.min,e.boundingBox.max,t),ya.needsUpdate=!0;const a=o.geometry,A=a.attributes.position,c=a.index,l=e.attributes.position,h=e.index,u=Ve.getPrimitive(),d=Ve.getPrimitive();let g=DC,p=LC,f=null,m=null;i&&(f=FC,m=NC);let E=1/0,w=null,I=null;return Vn.copy(t).invert(),vi.matrix.copy(Vn),o.shapecast({boundsTraverseOrder:C=>ya.distanceToBox(C),intersectsBounds:(C,x,B)=>B<E&&B<r?(x&&(vi.min.copy(C.min),vi.max.copy(C.max),vi.needsUpdate=!0),!0):!1,intersectsRange:(C,x)=>{if(e.boundsTree){const B=e.boundsTree;return B.shapecast({boundsTraverseOrder:y=>vi.distanceToBox(y),intersectsBounds:(y,v,Q)=>Q<E&&Q<r,intersectsRange:(y,v)=>{for(let Q=y,b=y+v;Q<b;Q++){const S=B.resolveTriangleIndex(Q);se(d,3*S,h,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=C,T=C+x;M<T;M++){const _=o.resolveTriangleIndex(M);se(u,3*_,c,A),u.needsUpdate=!0;const L=u.distanceToTriangle(d,g,f);if(L<E&&(p.copy(g),m&&m.copy(f),E=L,w=M,I=Q),L<n)return!0}}}})}else{const B=Zs(e);for(let y=0,v=B;y<v;y++){se(d,3*y,h,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let Q=C,b=C+x;Q<b;Q++){const S=o.resolveTriangleIndex(Q);se(u,3*S,c,A),u.needsUpdate=!0;const M=u.distanceToTriangle(d,g,f);if(M<E&&(p.copy(g),m&&m.copy(f),E=M,w=Q,I=y),M<n)return!0}}}}}),Ve.releasePrimitive(u),Ve.releasePrimitive(d),E===1/0?null:(s.point?s.point.copy(p):s.point=p.clone(),s.distance=E,s.faceIndex=w,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Vn),p.applyMatrix4(Vn),i.distance=p.sub(i.point).length(),i.faceIndex=I),s)}function UC(){return typeof SharedArrayBuffer<"u"}const Oi=new W.constructor,Cr=new W.constructor,bt=new gA(()=>new Ae),Ds=new Ae,Ls=new Ae,wa=new Ae,xa=new Ae;let va=!1;function PC(o,e,t,s){if(va)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");va=!0;const i=o._roots,n=e._roots;let r,a=0,A=0;const c=new le().copy(t).invert();for(let l=0,h=i.length;l<h;l++){Oi.setBuffer(i[l]),A=0;const u=bt.getPrimitive();ee(0,Oi.float32Array,u),u.applyMatrix4(c);for(let d=0,g=n.length;d<g&&(Cr.setBuffer(n[l]),r=ze(0,0,t,c,s,a,A,0,0,u),Cr.clearBuffer(),A+=n[d].length,!r);d++);if(bt.releasePrimitive(u),Oi.clearBuffer(),a+=i[l].length,r)break}return va=!1,r}function ze(o,e,t,s,i,n=0,r=0,a=0,A=0,c=null,l=!1){let h,u;l?(h=Cr,u=Oi):(h=Oi,u=Cr);const d=h.float32Array,g=h.uint32Array,p=h.uint16Array,f=u.float32Array,m=u.uint32Array,E=u.uint16Array,w=o*2,I=e*2,C=Qe(w,p),x=Qe(I,E);let B=!1;if(x&&C)l?B=i(Fe(e,m),Oe(e*2,E),Fe(o,g),Oe(o*2,p),A,r+e,a,n+o):B=i(Fe(o,g),Oe(o*2,p),Fe(e,m),Oe(e*2,E),a,n+o,A,r+e);else if(x){const y=bt.getPrimitive();ee(e,f,y),y.applyMatrix4(t);const v=He(o),Q=$e(o,g);ee(v,d,Ds),ee(Q,d,Ls);const b=y.intersectsBox(Ds),S=y.intersectsBox(Ls);B=b&&ze(e,v,s,t,i,r,n,A,a+1,y,!l)||S&&ze(e,Q,s,t,i,r,n,A,a+1,y,!l),bt.releasePrimitive(y)}else{const y=He(e),v=$e(e,m);ee(y,f,wa),ee(v,f,xa);const Q=c.intersectsBox(wa),b=c.intersectsBox(xa);if(Q&&b)B=ze(o,y,t,s,i,n,r,a,A+1,c,l)||ze(o,v,t,s,i,n,r,a,A+1,c,l);else if(Q)if(C)B=ze(o,y,t,s,i,n,r,a,A+1,c,l);else{const S=bt.getPrimitive();S.copy(wa).applyMatrix4(t);const M=He(o),T=$e(o,g);ee(M,d,Ds),ee(T,d,Ls);const _=S.intersectsBox(Ds),L=S.intersectsBox(Ls);B=_&&ze(y,M,s,t,i,r,n,A,a+1,S,!l)||L&&ze(y,T,s,t,i,r,n,A,a+1,S,!l),bt.releasePrimitive(S)}else if(b)if(C)B=ze(o,v,t,s,i,n,r,a,A+1,c,l);else{const S=bt.getPrimitive();S.copy(xa).applyMatrix4(t);const M=He(o),T=$e(o,g);ee(M,d,Ds),ee(T,d,Ls);const _=S.intersectsBox(Ds),L=S.intersectsBox(Ls);B=_&&ze(v,M,s,t,i,r,n,A,a+1,S,!l)||L&&ze(v,T,s,t,i,r,n,A,a+1,S,!l),bt.releasePrimitive(S)}}return B}const qn=new we,Oh=new Ae,GC={strategy:vd,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class fA{static serialize(e,t={}){t={cloneBuffers:!0,...t};const s=e.geometry,i=e._roots,n=e._indirectBuffer,r=s.getIndex();let a;return t.cloneBuffers?a={roots:i.map(A=>A.slice()),index:r.array.slice(),indirectBuffer:n?n.slice():null}:a={roots:i,index:r.array,indirectBuffer:n},a}static deserialize(e,t,s={}){s={setIndex:!0,indirect:!!e.indirectBuffer,...s};const{index:i,roots:n,indirectBuffer:r}=e,a=new fA(t,{...s,[pa]:!0});if(a._roots=n,a._indirectBuffer=r||null,s.setIndex){const A=t.getIndex();if(A===null){const c=new Se(e.index,1,!1);t.setIndex(c)}else A.array!==i&&(A.array.set(i),A.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...GC,[pa]:!1},t),t.useSharedArrayBuffer&&!UC())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[pa]||(sC(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ae)));const{_indirectBuffer:s}=this;this.resolveTriangleIndex=t.indirect?i=>s[i]:i=>i}refit(e=null){return(this.indirect?bC:fC)(this,e)}traverse(e,t=0){const s=this._roots[t],i=new Uint32Array(s),n=new Uint16Array(s);r(0);function r(a,A=0){const c=a*2,l=n[c+15]===Fr;if(l){const h=i[a+6],u=n[c+14];e(A,l,new Float32Array(s,a*4,6),h,u)}else{const h=a+Gi/4,u=i[a+6],d=i[a+7];e(A,l,new Float32Array(s,a*4,6),d)||(r(h,A+1),r(u,A+1))}}}raycast(e,t=qi){const s=this._roots,i=this.geometry,n=[],r=t.isMaterial,a=Array.isArray(t),A=i.groups,c=r?t.side:t,l=this.indirect?TC:EC;for(let h=0,u=s.length;h<u;h++){const d=a?t[A[h].materialIndex].side:c,g=n.length;if(l(this,h,d,e,n),a){const p=A[h].materialIndex;for(let f=g,m=n.length;f<m;f++)n[f].face.materialIndex=p}}return n}raycastFirst(e,t=qi){const s=this._roots,i=this.geometry,n=t.isMaterial,r=Array.isArray(t);let a=null;const A=i.groups,c=n?t.side:t,l=this.indirect?RC:BC;for(let h=0,u=s.length;h<u;h++){const d=r?t[A[h].materialIndex].side:c,g=l(this,h,d,e);g!=null&&(a==null||g.distance<a.distance)&&(a=g,r&&(g.face.materialIndex=A[h].materialIndex))}return a}intersectsGeometry(e,t){let s=!1;const i=this._roots,n=this.indirect?_C:yC;for(let r=0,a=i.length;r<a&&(s=n(this,r,e,t),!s);r++);return s}shapecast(e){const t=Ve.getPrimitive(),s=this.indirect?IC:gC;let{boundsTraverseOrder:i,intersectsBounds:n,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const h=r;r=(u,d,g,p,f)=>h(u,d,g,p,f)?!0:s(u,d,this,a,g,p,t)}else r||(a?r=(h,u,d,g)=>s(h,u,this,a,d,g,t):r=(h,u,d)=>d);let A=!1,c=0;const l=this._roots;for(let h=0,u=l.length;h<u;h++){const d=l[h];if(A=AC(this,h,n,r,i,c),A)break;c+=d.byteLength}return Ve.releasePrimitive(t),A}bvhcast(e,t,s){let{intersectsRanges:i,intersectsTriangles:n}=s;const r=Ve.getPrimitive(),a=this.geometry.index,A=this.geometry.attributes.position,c=this.indirect?g=>{const p=this.resolveTriangleIndex(g);se(r,p*3,a,A)}:g=>{se(r,g*3,a,A)},l=Ve.getPrimitive(),h=e.geometry.index,u=e.geometry.attributes.position,d=e.indirect?g=>{const p=e.resolveTriangleIndex(g);se(l,p*3,h,u)}:g=>{se(l,g*3,h,u)};if(n){const g=(p,f,m,E,w,I,C,x)=>{for(let B=m,y=m+E;B<y;B++){d(B),l.a.applyMatrix4(t),l.b.applyMatrix4(t),l.c.applyMatrix4(t),l.needsUpdate=!0;for(let v=p,Q=p+f;v<Q;v++)if(c(v),r.needsUpdate=!0,n(r,l,v,B,w,I,C,x))return!0}return!1};if(i){const p=i;i=function(f,m,E,w,I,C,x,B){return p(f,m,E,w,I,C,x,B)?!0:g(f,m,E,w,I,C,x,B)}}else i=g}return PC(this,e,t,i)}intersectsBox(e,t){return qn.set(e.min,e.max,t),qn.needsUpdate=!0,this.shapecast({intersectsBounds:s=>qn.intersectsBox(s),intersectsTriangle:s=>qn.intersectsTriangle(s)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,s={},i={},n=0,r=1/0){return(this.indirect?kC:SC)(this,e,t,s,i,n,r)}closestPointToPoint(e,t={},s=0,i=1/0){return cC(this,e,t,s,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(s=>{ee(0,new Float32Array(s),Oh),e.union(Oh)}),e}}function Hh(o,e,t){return o===null||(o.point.applyMatrix4(e.matrixWorld),o.distance=o.point.distanceTo(t.ray.origin),o.object=e,o.distance<t.near||o.distance>t.far)?null:o}const Qa=new Gg,$h=new le,OC=ge.prototype.raycast;function HC(o,e){if(this.geometry.boundsTree){if(this.material===void 0)return;$h.copy(this.matrixWorld).invert(),Qa.copy(o.ray).applyMatrix4($h);const t=this.geometry.boundsTree;if(o.firstHitOnly===!0){const s=Hh(t.raycastFirst(Qa,this.material),this,o);s&&e.push(s)}else{const s=t.raycast(Qa,this.material);for(let i=0,n=s.length;i<n;i++){const r=Hh(s[i],this,o);r&&e.push(r)}}}else OC.call(this,o,e)}function $C(o){return this.boundsTree=new fA(this,o),this.boundsTree}function VC(){this.boundsTree=null}const qC=["src","disable-tap","exposure","shadow-intensity","autoplay","ar","ar-modes","skybox-image","environment-image"],zC={class:"annotation initial-load-banner"},KC={class:"overlay-svg-wrapper"},YC=["x1","y1","x2","y2"],JC={key:0},jC=["x","y","width","height"],WC=["x","y"],XC=Ld({__name:"ModelViewerWrapper",props:{src:{}},emits:["load"],setup(o,{expose:e,emit:t}){xd.modelCacheSize=0,Hi.prototype.computeBoundsTree=$C,Hi.prototype.disposeBoundsTree=VC,ge.prototype.raycast=HC;const s=t,i=o,n=Ht(null),r=Ht(null),a=Ht(null);Fd(()=>{n.value&&(n.value.addEventListener("load",async()=>{if(!n.value)return;let B=n.value.querySelector(".initial-load-banner");B&&B.remove(),r.value=n.value[D],a.value=n.value[q],s("load")}),n.value.addEventListener("camera-change",m),n.value.addEventListener("progress",B=>h(B.detail.totalProgress)))});const A=Ht(null),c=Ht(null);let l=null;const h=B=>{!A.value||!c.value||(A.value.style.display="block",A.value.style.opacity="1",c.value.style.width=`${B*100}%`,l&&clearTimeout(l),l=setTimeout(()=>{A.value&&(A.value.style.opacity="0",setTimeout(()=>{A.value&&(A.value.style.display="none")},300))},1e3))};let u=1,d=Ht({});function g(B){return B.x+" "+B.y+" "+B.z}function p(B,y,v,Q={"stroke-width":"2",stroke:"red"}){var T;if(!r.value||!((T=n.value)!=null&&T.shadowRoot))return null;let b=u++,S="line"+b+"_start",M="line"+b+"_end";return r.value.addHotspot(new Ps({name:S,position:g(B)})),r.value.addHotspot(new Ps({name:M,position:g(y)})),d.value[b]={startHotspot:n.value.shadowRoot.querySelector('slot[name="'+S+'"]').parentElement,endHotspot:n.value.shadowRoot.querySelector('slot[name="'+M+'"]').parentElement,start2D:[-1e3,-1e3],end2D:[-1e3,-1e3],centerText:v,centerTextSize:[0,0],lineAttrs:Q},r.value.queueRender(),requestIdleCallback(()=>w(b),{timeout:100}),b}function f(B){var y,v;return!r.value||!(B in d.value)?!1:(r.value.removeHotspot(new Ps({name:"line"+B+"_start"})),(y=d.value[B].startHotspot.parentElement)==null||y.remove(),r.value.removeHotspot(new Ps({name:"line"+B+"_end"})),(v=d.value[B].endHotspot.parentElement)==null||v.remove(),delete d.value[B],r.value.queueRender(),!0)}function m(){for(let B in d.value)w(B)}let E=Ht(null);function w(B){if(!(B in d.value)||!n.value)return;let{x:y,y:v}=n.value.getBoundingClientRect(),{x:Q,y:b}=d.value[B].startHotspot.getBoundingClientRect();d.value[B].start2D=[Q-y,b-v];let{x:S,y:M}=d.value[B].endHotspot.getBoundingClientRect();if(d.value[B].end2D=[S-y,M-v],E.value&&d.value[B].centerText&&d.value[B].centerTextSize[0]===0){let T=E.value.getElementsByClassName("line"+B+"_text")[0];if(T){let _=T.getBBox();d.value[B].centerTextSize=[_.width,_.height]}}}function I(B){n.value?B(n.value):BA(()=>n.value,y=>{y&&B(y)})}function C(B){return Object.entries(B)}e({elem:n,onElemReady:I,scene:r,renderer:a,addLine3D:p,removeLine3D:f,onProgress:h});let{disableTap:x}=Nd("disableTap");return BA(x,B=>{var y,v;B?(y=n.value)==null||y.setAttribute("disable-tap",""):(v=n.value)==null||v.removeAttribute("disable-tap")}),(B,y)=>(rt(),Et(Pr,null,[as("model-viewer",{ref_key:"elem",ref:n,style:{width:"100%",height:"100%"},src:i.src,alt:"The 3D model(s)","camera-controls":"","camera-orbit":"30deg 75deg auto","max-camera-orbit":"Infinity 180deg auto","min-camera-orbit":"-Infinity 0deg 5%","disable-tap":Ne(x),exposure:Ne(Ct).exposure,"shadow-intensity":Ne(Ct).shadowIntensity,"interaction-prompt":"none",autoplay:Ne(Ct).autoplay,ar:Ne(Ct).arModes.length>0,"ar-modes":Ne(Ct).arModes,"skybox-image":Ne(Ct).background,"environment-image":Ne(Ct).background},[kd(B.$slots,"default",{},void 0,!0),as("div",zC,[yA(" Trying to load models from... "),(rt(!0),Et(Pr,null,wA(Ne(Ct).preload,v=>(rt(),Ud(Ne(Hg),{key:v},{default:xA(()=>[Pd(Ne(Og),null,{default:xA(()=>[yA(vA(v),1)]),_:2},1024)]),_:2},1024))),128))]),as("div",{class:"progress-bar",slot:"progress-bar",ref_key:"progressBar",ref:A},[as("div",{class:"update-bar",ref_key:"updateBar",ref:c},null,512)],512)],8,qC),as("div",KC,[(rt(),Et("svg",{ref_key:"svg",ref:E,class:"overlay-svg",width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg"},[(rt(!0),Et(Pr,null,wA(C(Ne(d)),([v,Q])=>(rt(),Et("g",{key:v},[as("line",Gd({x1:Q.start2D[0],y1:Q.start2D[1],x2:Q.end2D[0],y2:Q.end2D[1]},Q.lineAttrs),null,16,YC),Q.centerText!==void 0?(rt(),Et("g",JC,[Q.centerText?(rt(),Et("rect",{key:0,x:(Q.start2D[0]+Q.end2D[0])/2-Q.centerTextSize[0]/2-4,y:(Q.start2D[1]+Q.end2D[1])/2-Q.centerTextSize[1]/2-2,width:Q.centerTextSize[0]+8,height:Q.centerTextSize[1]+4,fill:"gray","fill-opacity":"0.75",rx:"4",ry:"4",stroke:"black"},null,8,jC)):Gr("",!0),Q.centerText?(rt(),Et("text",{key:1,x:(Q.start2D[0]+Q.end2D[0])/2,y:(Q.start2D[1]+Q.end2D[1])/2,"text-anchor":"middle","dominant-baseline":"middle","font-size":"16",fill:"black",class:Od("line"+v+"_text")},vA(Q.centerText),11,WC)):Gr("",!0)])):Gr("",!0)]))),128))],512))])],64))}}),I0=Hd(XC,[["__scopeId","data-v-a73ee4b5"]]);export{I0 as default};
