@tora-editor/tora 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/bin/tora.mjs +255 -29
- package/crates/packer/trusted/native-3d-meta.json +3 -3
- package/crates/packer/trusted/native-3d.js +180 -180
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +3 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -106
- package/docs/TORA_CREATION_API.md +63 -365
- package/docs/reference/CORE_AUTHORING.md +8 -2
- package/docs/reference/PLAYABLE_STARTERS.md +1 -1
- package/docs/reference/packs/3d.md +2 -0
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +108 -1
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +246 -68
- package/scripts/lean/editor/review-editor.js +1731 -1099
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +35 -58
- package/scripts/lean/native/api.mjs +148 -134
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +36 -5
- package/scripts/lean/native/contracts.mjs +8 -6
- package/scripts/lean/native/creative-qa.mjs +66 -12
- package/scripts/lean/native/demos.mjs +11 -20
- package/scripts/lean/native/document.mjs +14 -2
- package/scripts/lean/native/local-bundle.mjs +4 -2
- package/scripts/lean/native/mcp-server.mjs +16 -35
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/project-bundle.mjs +3 -2
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/review.mjs +203 -572
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +1 -1
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +242 -70
- package/scripts/lean/native/starters.mjs +135 -8
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +1 -1
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -143
- package/scripts/lean/native/author-fps.mjs +0 -545
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -875
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -190
- package/scripts/lean/native/check-salvage.mjs +0 -200
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/glb-loader.mjs +0 -468
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -218
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-fps-assets.mjs +0 -330
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1809
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -1121
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var ToraNative=(()=>{var Wf=Object.defineProperty;var ry=Object.getOwnPropertyDescriptor;var ay=Object.getOwnPropertyNames;var sy=Object.prototype.hasOwnProperty;var oy=(n,e)=>{for(var t in e)Wf(n,t,{get:e[t],enumerable:!0})},ly=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ay(e))!sy.call(n,r)&&r!==t&&Wf(n,r,{get:()=>e[r],enumerable:!(i=ry(e,r))||i.enumerable});return n};var cy=n=>ly(Wf({},"__esModule",{value:!0}),n);var Kw={};oy(Kw,{computeSafeArea:()=>Wp,createNetworkBridge:()=>_g,layoutStandardText:()=>Mg,mountNative:()=>$w});var fm=function(n,e){if(!n)throw Error(e)},Ua=function(){return[1,0,0,1,0,0]};function Xf(n){return fm(Array.isArray(n)&&n.length===6&&n.every(Number.isFinite),"E_SCENE_MATRIX"),n}function Io(n,e){return Xf(n),Xf(e),[n[0]*e[0]+n[2]*e[1],n[1]*e[0]+n[3]*e[1],n[0]*e[2]+n[2]*e[3],n[1]*e[2]+n[3]*e[3],n[0]*e[4]+n[2]*e[5]+n[4],n[1]*e[4]+n[3]*e[5]+n[5]]}function Or(n){Xf(n);var e=n[0]*n[3]-n[1]*n[2];return fm(Math.abs(e)>1e-12,"E_SCENE_SINGULAR_TRANSFORM"),[n[3]/e,-n[1]/e,-n[2]/e,n[0]/e,(n[2]*n[5]-n[3]*n[4])/e,(n[1]*n[4]-n[0]*n[5])/e]}var qf=function(){return qf=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},qf.apply(this,arguments)},Fa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Ks=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Yf=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function hm(n){var e=n.rows,t=n.columns,i=n.seed,r=n.slots,a=n.paint,s=n.onEvent,o=r.map(function(le){return le.group}),u=Ks([],Fa(new Set(o)),!1),l=Ks([],Fa(o),!1),d=i,f="idle",h=0,m,y,M=[],g=[],v=0,P=0,p=0,_,N,D=function(le,be){return le*t+be},B=function(le){return Math.floor(le/t)},w=function(le){return le%t},A=function(){return d=Math.imul(d,1664525)+1013904223>>>0,d/4294967296};function z(le){for(var be=new Set,Pe=0;Pe<e;Pe++)for(var Q=0;Q<t;Q++){var ie=D(Pe,Q),Me=le[ie];if(Q+2<t&&Me===le[ie+1]&&Me===le[ie+2])for(var Le=0;Le<3;Le++)be.add(ie+Le);if(Pe+2<e&&Me===le[ie+t]&&Me===le[ie+t*2])for(var Le=0;Le<3;Le++)be.add(ie+t*Le)}return Ks([],Fa(be),!1)}function V(le,be){var Pe;if(l[le]===l[be])return!1;var Q=Ks([],Fa(l),!1);return Pe=Fa([Q[be],Q[le]],2),Q[le]=Pe[0],Q[be]=Pe[1],z(Q).some(function(ie){return ie===le||ie===be})}function $(){for(var le=[],be=0;be<l.length;be++)w(be)+1<t&&V(be,be+1)&&le.push({from:r[be].id,to:r[be+1].id}),B(be)+1<e&&V(be,be+t)&&le.push({from:r[be].id,to:r[be+t].id});return le}function T(){for(var le=0;le<64;le++){l=[];for(var be=function(Q){var ie=u.filter(function(Me){return!(w(Q)>=2&&l[Q-1]===Me&&l[Q-2]===Me)&&!(B(Q)>=2&&l[Q-t]===Me&&l[Q-t*2]===Me)});l.push(ie[Math.floor(A()*ie.length)])},Pe=0;Pe<r.length;Pe++)be(Pe);if($().length)return}l=r.map(function(Q,ie){return u[(B(ie)*2+w(ie))%3]}),l[0]=u[0],l[1]=u[1],l[2]=u[0],l[t+1]=u[0]}function S(){for(var le=0;le<r.length;le++)a(le,l[le],{})}function Y(){d=i,l=Ks([],Fa(o),!1),f="idle",h=0,m=void 0,y=void 0,M=[],g=[],v=0,P=0,p=0,_=void 0,N=void 0,(z(l).length||!$().length)&&T(),S()}function W(le,be){if(f!=="idle")return!1;var Pe=r.findIndex(function(ie){return ie.id===le}),Q=r.findIndex(function(ie){return ie.id===be});return Pe<0||Q<0||Math.abs(B(Pe)-B(Q))+Math.abs(w(Pe)-w(Q))!==1?!1:(m=void 0,_=void 0,S(),y=[Pe,Q],f="swap",h=0,!0)}function se(le){if(f==="idle"){if(m===le){m=void 0;return}if(!(m&&W(m,le)))return m=le,m}}function O(){M=z(l),p+=M.length,N={group:l[M[0]],from:r[M[0]].id,count:M.length},s("matchClear"),f="clear",h=0}function U(){var le=new Set(M),be=Ks([],Fa(l),!1);g=[];for(var Pe=0;Pe<t;Pe++){for(var Q=[],ie=e-1;ie>=0;ie--)le.has(D(ie,Pe))||Q.push(D(ie,Pe));for(var Me=0,ie=e-1;ie>=0;ie--){var Le=D(ie,Pe),Ee=Q[e-1-ie];Ee!==void 0?(be[Le]=l[Ee],g.push({cell:Le,from:Ee,offsetRows:0})):(be[Le]=u[Math.floor(A()*u.length)],g.push({cell:Le,from:Le,offsetRows:-(ie+1+Me++)}))}}l=be,f="fall",h=0}function H(){if(z(l).length&&v<3){v++,O();return}(z(l).length||!$().length)&&T(),S(),f="idle",h=0,y=void 0,M=[],g=[],P++,s("validMatch")}function ne(le){var be,Pe,Q,ie,Me,Le,Ee;if(f==="idle"){if(_){_.elapsed+=le;var Xe=1+.065*Math.sin(Math.min(1,_.elapsed/.8)*Math.PI*4),tt=function(Ve){a(r.findIndex(function($e){return $e.id===Ve}),l[r.findIndex(function($e){return $e.id===Ve})],{scale:Xe})};try{for(var Ge=Yf(_.ids),Ye=Ge.next();!Ye.done;Ye=Ge.next()){var dt=Ye.value;tt(dt)}}catch(Ve){be={error:Ve}}finally{try{Ye&&!Ye.done&&(Pe=Ge.return)&&Pe.call(Ge)}finally{if(be)throw be.error}}_.elapsed>=.8&&(_=void 0,S())}return}if(h+=le,f==="swap"||f==="reverse"){var ke=Math.min(1,h/.14),at=ke*ke*(3-2*ke),Ke=Fa(y,2),jt=Ke[0],Pt=Ke[1];if(a(jt,l[jt],{from:Pt,progress:f==="swap"?at:1-at}),a(Pt,l[Pt],{from:jt,progress:f==="swap"?at:1-at}),ke<1)return;if(f==="reverse"){S(),f="idle",y=void 0,s("invalidMatch");return}if(!V(jt,Pt)){f="reverse",h=0;return}Q=Fa([l[Pt],l[jt]],2),l[jt]=Q[0],l[Pt]=Q[1],S(),O();return}if(f==="clear"){var tn=Math.min(1,h/.18),Xe=tn<.22?1+tn*.45:Math.max(.05,1.1*(1-tn)/.78);try{for(var ue=Yf(M),ln=ue.next();!ln.done;ln=ue.next()){var on=ln.value;a(on,l[on],{scale:Xe,opacity:1-tn})}}catch($e){ie={error:$e}}finally{try{ln&&!ln.done&&(Me=ue.return)&&Me.call(ue)}finally{if(ie)throw ie.error}}tn===1&&U();return}var Z=Math.min(1,h/.25),b=1-Math.pow(1-Z,3);try{for(var ee=Yf(g),ve=ee.next();!ve.done;ve=ee.next()){var Te=ve.value;a(Te.cell,l[Te.cell],{from:Te.from,offsetRows:Te.offsetRows,progress:1-b})}}catch(Ve){Le={error:Ve}}finally{try{ve&&!ve.done&&(Ee=ee.return)&&Ee.call(ee)}finally{if(Le)throw Le.error}}Z===1&&H()}function ce(){if(f==="idle"){m=void 0;var le=$()[0];le&&(_={ids:[le.from,le.to],elapsed:0})}}function pe(){var le;return{phase:f,busy:f!=="idle",selected:m??null,moves:P,cleared:p,groups:Ks([],Fa(l),!1),legalMoves:f==="idle"?$():[],hint:(le=_?.ids)!==null&&le!==void 0?le:[],lastMatch:N?qf({},N):null}}return{reset:Y,select:se,swap:W,tick:ne,showHint:ce,snapshot:pe,cancelSelection:function(){m=void 0,_&&(_=void 0,S())}}}var lu=function(){return lu=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},lu.apply(this,arguments)},pm=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},uy=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},mm=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function vm(){var n=new Map,e=new Map,t=function(r){var a,s,o=e.get(r);o!==void 0&&((a=n.get(o))===null||a===void 0||a.delete(r),((s=n.get(o))===null||s===void 0?void 0:s.size)===0&&n.delete(o)),e.delete(r)},i=function(r,a){t(r),a!=null&&(n.has(a)||n.set(a,new Set),n.get(a).add(r),e.set(r,a))};return{occupants:n,itemZone:e,release:t,place:i,clear:function(){n.clear(),e.clear()},items:function(r){var a;return uy([],pm((a=n.get(r))!==null&&a!==void 0?a:[]),!1).sort()},zoneOf:function(r){return e.get(r)},snapshot:function(){return{itemZone:Object.fromEntries(e)}}}}function cu(n){var e,t,i=n.itemId,r=n.tag,a=r===void 0?"":r,s=n.zones,o=n.occupancy,u=s.filter(function(y){var M,g,v;return y.id!==i&&(((g=(M=y.acceptTags)===null||M===void 0?void 0:M.length)!==null&&g!==void 0?g:0)===0||((v=y.acceptTags)===null||v===void 0?void 0:v.includes(a)))});u.sort(function(y,M){return Number(M.itemTarget)-Number(y.itemTarget)||M.paintOrder-y.paintOrder||y.distance-M.distance||y.id.localeCompare(M.id)});try{for(var l=mm(u),d=l.next();!d.done;d=l.next()){var f=d.value,h=o.items(f.id).filter(function(y){return y!==i}),m=f.capacity>0&&h.length>=f.capacity;return f.snapMode==="reject"?{kind:"reject",zone:f,occupantId:h[0]}:m?f.onOccupied==="emit"?{kind:"emit",zone:f,occupantId:h[0]}:f.onOccupied==="swap"&&h.length?{kind:"swap",zone:f,occupantId:h[0]}:{kind:"reject",zone:f,occupantId:h[0]}:{kind:"accept",zone:f}}}catch(y){e={error:y}}finally{try{d&&!d.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}return null}function gm(n,e,t,i,r,a){if(t===void 0&&(t=28),i===void 0&&(i=-1/0),r===void 0&&(r=0),a===void 0&&(a=80),r-i<a)return null;var s=e.x-n.x,o=e.y-n.y;return Math.max(Math.abs(s),Math.abs(o))<t?null:Math.abs(s)>Math.abs(o)?s<0?"left":"right":o<0?"up":"down"}function ym(n,e){var t=e,i=1;return{tick:function(r){return n.pingPong?(t+=i*n.ratePerSecond*r,t>=n.max?(t=n.max,i=-1):t<=n.min&&(t=n.min,i=1)):t=Math.max(n.min,Math.min(n.max,t+n.ratePerSecond*r)),t}}}function xm(){var n=new Map;return{to:function(e,t,i,r,a){r===void 0&&(r=.18),n.set(e,{from:lu({},t),to:lu({},i),seconds:Math.max(.02,r),elapsed:0,onDone:a})},cancel:function(e){n.delete(e)},clear:function(){n.clear()},tick:function(e,t){var i,r,a;try{for(var s=mm(n),o=s.next();!o.done;o=s.next()){var u=pm(o.value,2),l=u[0],d=u[1];d.elapsed+=e;var f=Math.min(1,d.elapsed/d.seconds),h=1-Math.pow(1-f,3);t(l,{x:d.from.x+(d.to.x-d.from.x)*h,y:d.from.y+(d.to.y-d.from.y)*h}),f===1&&(n.delete(l),(a=d.onDone)===null||a===void 0||a.call(d))}}catch(m){i={error:m}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}}}}function Zf(n,e,t,i){t===void 0&&(t=56),i===void 0&&(i=.12);var r=Math.max(1,t),a=e.x-n.x,s=e.y-n.y,o=Math.hypot(a,s),u=Math.min(o,r),l=u/r,d=o>1e-6?a/o:0,f=o>1e-6?s/o:0,h=n.x+d*u,m=n.y+f*u;if(l<=i)return{nx:0,ny:0,magnitude:0,angle:0,knobX:h,knobY:m};var y=(l-i)/Math.max(1e-6,1-i);return{nx:d*y,ny:f*y,magnitude:y,angle:Math.atan2(f,d)*180/Math.PI,knobX:h,knobY:m}}var Jf=function(){return Jf=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Jf.apply(this,arguments)},_m=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function uu(n){var e,t,i=2166136261;try{for(var r=_m(String(n)),a=r.next();!a.done;a=r.next()){var s=a.value;i^=s.codePointAt(0),i=Math.imul(i,16777619)}}catch(o){e={error:o}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i>>>0||1}function du(n){var e=n>>>0||1,t=e;return{next:function(){return t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296},between:function(i,r,a){if(a===void 0&&(a=!1),a){var s=Math.ceil(i),o=Math.floor(r);return o<s?s:Math.min(o,s+Math.floor((o-s+1)*this.next()))}return i+(r-i)*this.next()},reset:function(){t=e}}}function Mm(n,e,t,i,r){var a,s;i===void 0&&(i=0);var o=null,u=1/0;try{for(var l=_m(e),d=l.next();!d.done;d=l.next()){var f=d.value;if(!(f.id===r||f.team!==t)){var h=Math.hypot(f.x-n.x,f.y-n.y);i>0&&h>i||(h<u||h===u&&f.id<o?.id)&&(o=f,u=h)}}}catch(m){a={error:m}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}return o}function Sm(n,e,t){var i=((e-n+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return n+Math.max(-t,Math.min(t,i))}function bm(n){var e=du(n),t=new Map,i=new Map;return{rng:e,states:t,headings:i,reset:function(){e.reset(),t.clear(),i.clear()},initialize:function(r,a){var s;return t.has(r)||t.set(r,{hp:a.hp,maxHp:a.maxHp,value:a.value,tag:(s=a.tag)!==null&&s!==void 0?s:"",team:a.team}),t.get(r)},remove:function(r){t.delete(r),i.delete(r)},snapshot:function(r){var a=t.get(r);return a?Jf({},a):void 0}}}function wm(n,e){var t,i,r,a,s=e===void 0?{}:e,o=s.width,u=s.height,l=s.onProgress,d=l===void 0?function(){}:l,f=s.onComplete,h=f===void 0?function(){}:f,m=s.canvasFactory,y=s.source,M=n,g=M.gridSize,v=new Uint8Array(g*g),P=0,p=!1,_=-1,N=!1,D=Math.max(1,o),B=Math.max(1,u),w=Math.min(1,512/Math.max(D,B)),A=(t=m?.())!==null&&t!==void 0?t:!((i=globalThis.document)===null||i===void 0)&&i.createElement?globalThis.document.createElement("canvas"):void 0;A&&(A.width=Math.max(1,Math.round(D*w)),A.height=Math.max(1,Math.round(B*w)));var z=(r=A?.getContext)===null||r===void 0?void 0:r.call(A,"2d"),V=(a=M.maskColor)!==null&&a!==void 0?a:"#dceeff",$=function(){return!!(y&&y.complete&&y.naturalWidth>0)},T=function(){z&&(z.globalCompositeOperation="source-over",z.clearRect(0,0,A.width,A.height),M.mode==="erase"&&($()?(z.drawImage(y,0,0,A.width,A.height),N=!0):(z.fillStyle=V,z.fillRect(0,0,A.width,A.height),N=!1)))};T();var S=function(){if(!p){var W=Math.round(P/v.length*100),se=Math.min(100,W);se!==_&&(_=se,d(se)),se>=M.targetPercent&&(p=!0,h(se))}},Y=function(W,se){for(var O=Math.max(0,Math.min(g-1,Math.floor(W/D*g))),U=Math.max(0,Math.min(g-1,Math.floor(se/B*g))),H=Math.max(0,Math.ceil(M.brushRadiusPx/D*g)),ne=Math.max(0,Math.ceil(M.brushRadiusPx/B*g)),ce=Math.max(0,U-ne);ce<=Math.min(g-1,U+ne);ce++)for(var pe=Math.max(0,O-H);pe<=Math.min(g-1,O+H);pe++)if(!(Math.hypot((pe+.5)/g*D-W,(ce+.5)/g*B-se)>M.brushRadiusPx)){var le=ce*g+pe;v[le]||(v[le]=1,P++)}z&&(z.save(),z.scale(w,w),z.globalCompositeOperation=M.mode==="erase"?"destination-out":"source-over",z.fillStyle=V,z.beginPath(),z.arc(W,se,M.brushRadiusPx,0,Math.PI*2),z.fill(),M.mode==="reveal"&&y&&(z.globalCompositeOperation="source-in",z.drawImage(y,0,0,D,B)),z.restore()),S()};return{canvas:A,stampSegment:function(W,se){for(var O=Math.hypot(se.x-W.x,se.y-W.y),U=Math.max(1,Math.ceil(O/Math.max(1,M.brushRadiusPx*.45))),H=0;H<=U;H++)Y(W.x+(se.x-W.x)*H/U,W.y+(se.y-W.y)*H/U)},reset:function(){v.fill(0),P=0,p=!1,_=-1,T(),S()},get progress(){return Math.round(P/v.length*100)},render:function(W){M.mode==="erase"&&P===0&&!N&&$()&&T(),A?W.drawImage(A,0,0,A.width,A.height,0,0,o,u):M.mode==="erase"&&this.progress<100&&(W.save(),W.globalAlpha=1-this.progress/100,W.fillStyle=V,W.fillRect(0,0,o,u),W.restore())}}}var Qs=function(){return Qs=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Qs.apply(this,arguments)},dy=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function $f(n,e,t,i){var r=function(d,f,h){return(f.x-d.x)*(h.y-d.y)-(f.y-d.y)*(h.x-d.x)},a=r(n,e,t),s=r(n,e,i),o=r(t,i,n),u=r(t,i,e),l=1e-8;return Math.abs(a)<l&&Math.abs(s)<l&&Math.abs(o)<l&&Math.abs(u)<l?Math.max(Math.min(n.x,e.x),Math.min(t.x,i.x))<=Math.min(Math.max(n.x,e.x),Math.max(t.x,i.x))+l&&Math.max(Math.min(n.y,e.y),Math.min(t.y,i.y))<=Math.min(Math.max(n.y,e.y),Math.max(t.y,i.y))+l:a>0!=s>0&&o>0!=u>0}function Tm(n,e){for(var t=!1,i=0,r=e.length-1;i<e.length;r=i++){var a=e[i],s=e[r];a.y>n.y!=s.y>n.y&&n.x<(s.x-a.x)*(n.y-a.y)/(s.y-a.y)+a.x&&(t=!t)}return t}function Em(n,e,t){if(t.length>=3&&(Tm(n,t)||Tm(e,t)))return!0;for(var i=0;i<t.length;i++)if($f(n,e,t[i],t[(i+1)%t.length]))return!0;return!1}function Am(n){var e=n,t=[],i=null,r=0,a=function(s){return Qs(Qs({},s),{points:s.points.map(function(o){return Qs({},o)})})};return{begin:function(s){var o={id:++r,points:[Qs({},s)],age:0,hitIds:new Set};return i=o,t.push(o),t.length>e.maxStrokes&&t.shift(),o},add:function(s){if(!i||i.points.length>=e.maxPoints)return!1;var o=i.points[i.points.length-1];return Math.hypot(s.x-o.x,s.y-o.y)<e.minSegmentPx?!1:(i.points.push(Qs({},s)),!0)},end:function(){var s=i;return i=null,s?a(s):void 0},cancel:function(){i&&(t=t.filter(function(s){return s!==i})),i=null},clear:function(){i=null,t=[]},tick:function(s){var o,u;try{for(var l=dy(t),d=l.next();!d.done;d=l.next()){var f=d.value;f.age+=s}}catch(h){o={error:h}}finally{try{d&&!d.done&&(u=l.return)&&u.call(l)}finally{if(o)throw o.error}}t=t.filter(function(h){return h===i||h.age<.18||e.mode!=="slice-blade"})},get active(){return i},get strokes(){return t}}}function Im(n,e){for(var t=[],i=1;i<n.points.length;i++){var r=n.points[i-1],a=n.points[i],s=Math.hypot(a.x-r.x,a.y-r.y);s<.001||t.push({id:"stroke-".concat(n.id,"-").concat(i),strokeId:n.id,mode:"static",shape:"box",x:(r.x+a.x)/2,y:(r.y+a.y)/2,width:s,height:Math.max(2,e),angle:Math.atan2(a.y-r.y,a.x-r.x),restitution:.8})}return t}var Ol=function(){return Ol=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Ol.apply(this,arguments)},Nm=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},gs=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},fy=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},ts=function(n,e){return Math.hypot(n,e)},Cm=function(n,e,t){return Math.max(e,Math.min(t,n))},js=function(n){return Math.max(1,Math.min(n.width,n.height)/2)};function Rm(n){var e,t,i=Math.cos((e=n.angle)!==null&&e!==void 0?e:0),r=Math.sin((t=n.angle)!==null&&t!==void 0?t:0),a=n.width/2,s=n.height/2;return[[-a,-s],[a,-s],[a,s],[-a,s]].map(function(o){var u=Nm(o,2),l=u[0],d=u[1];return{x:n.x+l*i-d*r,y:n.y+l*r+d*i}})}function hy(n,e){var t,i,r,a,s,o,u,l,d,f,h=Rm(n),m=Rm(e),y=[(u=n.angle)!==null&&u!==void 0?u:0,((l=n.angle)!==null&&l!==void 0?l:0)+Math.PI/2,(d=e.angle)!==null&&d!==void 0?d:0,((f=e.angle)!==null&&f!==void 0?f:0)+Math.PI/2],M=1/0,g=1,v=0;try{for(var P=gs(y),p=P.next();!p.done;p=P.next()){var _=p.value,N=Math.cos(_),D=Math.sin(_),B=1/0,w=-1/0,A=1/0,z=-1/0;try{for(var V=(r=void 0,gs(h)),$=V.next();!$.done;$=V.next()){var T=$.value,S=T.x*N+T.y*D;S<B&&(B=S),S>w&&(w=S)}}catch(O){r={error:O}}finally{try{$&&!$.done&&(a=V.return)&&a.call(V)}finally{if(r)throw r.error}}try{for(var Y=(s=void 0,gs(m)),W=Y.next();!W.done;W=Y.next()){var T=W.value,S=T.x*N+T.y*D;S<A&&(A=S),S>z&&(z=S)}}catch(O){s={error:O}}finally{try{W&&!W.done&&(o=Y.return)&&o.call(Y)}finally{if(s)throw s.error}}var se=Math.min(w,z)-Math.max(B,A);if(se<=0)return null;se<M&&(M=se,g=N,v=D)}}catch(O){t={error:O}}finally{try{p&&!p.done&&(i=P.return)&&i.call(P)}finally{if(t)throw t.error}}return(n.x-e.x)*g+(n.y-e.y)*v<0&&(g=-g,v=-v),{nx:g,ny:v,penetration:M}}function Pm(n,e){var t,i,r,a=js(n),s=-((t=e.angle)!==null&&t!==void 0?t:0),o=Math.cos(s),u=Math.sin(s),l=n.x-e.x,d=n.y-e.y,f=l*o-d*u,h=l*u+d*o,m=e.width/2,y=e.height/2,M=Cm(f,-m,m),g=Cm(h,-y,y),v=f-M,P=h-g,p=ts(v,P),_;if(p>=a)return null;if(p<1e-4){var N=[{d:m-Math.abs(f),x:f>=0?1:-1,y:0},{d:y-Math.abs(h),x:0,y:h>=0?1:-1}].sort(function(w,A){return w.d-A.d});v=N[0].x,P=N[0].y,_=a+N[0].d}else v/=p,P/=p,_=a-p;var D=Math.cos((i=e.angle)!==null&&i!==void 0?i:0),B=Math.sin((r=e.angle)!==null&&r!==void 0?r:0);return{nx:v*D-P*B,ny:v*B+P*D,penetration:_}}function Lm(n,e){var t;return!!(n.ignoreGroup&&n.ignoreGroup!=="none"&&(n.ignoreGroup==="all"||n.ignoreGroup===((t=e.collisionGroup)!==null&&t!==void 0?t:"all")))}function Dm(n,e,t){var i,r,a,s,o,u;if(!(n.captured||e.captured||Lm(n,e)||Lm(e,n))){var l=n.x-e.x,d=n.y-e.y,f;if(n.shape==="circle"&&e.shape==="circle"){var h=ts(l,d),m=js(n)+js(e)-h;if(m<=0)return;f=m,h>1e-4?(l/=h,d/=h):(l=1,d=0)}else if(n.shape==="circle"&&e.shape==="box"){var y=Pm(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="circle"){var y=Pm(e,n);if(!y)return;l=-y.nx,d=-y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="box"){var y=hy(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else return;var M=n.mode==="dynamic"?1/((i=n.mass)!==null&&i!==void 0?i:1):0,g=e.mode==="dynamic"?1/((r=e.mass)!==null&&r!==void 0?r:1):0,v=M+g;if(v){n.x+=l*f*M/v,n.y+=d*f*M/v,e.mode==="dynamic"&&(e.x-=l*f*g/v,e.y-=d*f*g/v);var P=n.vx-((a=e.vx)!==null&&a!==void 0?a:0),p=n.vy-((s=e.vy)!==null&&s!==void 0?s:0),_=P*l+p*d;if(!(_>=0)){var N=Math.max((o=n.restitution)!==null&&o!==void 0?o:0,(u=e.restitution)!==null&&u!==void 0?u:0),D=-(1+N)*_/v;n.vx+=l*D*M,n.vy+=d*D*M,e.mode==="dynamic"&&(e.vx-=l*D*g,e.vy-=d*D*g),n.atRest=!1,n.restElapsed=0,e.mode==="dynamic"&&(e.atRest=!1,e.restElapsed=0),Math.abs(_)>4&&(t("bodyBounce",n,e,{speed:Math.abs(_)}),e.mode==="dynamic"&&t("bodyBounce",e,n,{speed:Math.abs(_)}))}}}}function py(n,e,t,i){var r,a;if(!(n.mode!=="dynamic"||n.captured))try{for(var s=gs(e),o=s.next();!o.done;o=s.next()){var u=o.value,l=u.x-n.x,d=u.y-n.y,f=ts(l,d);if(!(f>=u.radius*2.5)){if(f>u.radius&&f>.001&&u.pullStrength>0){var h=u.pullStrength*(1-f/(u.radius*2.5));n.vx+=l/f*h*t,n.vy+=d/f*h*t}if(f<u.radius&&ts(n.vx,n.vy)<=u.maxCaptureSpeed){n.captured=!0,n.atRest=!0,n.vx=u.stopBody?0:n.vx,n.vy=u.stopBody?0:n.vy,u.stopBody&&(n.x=u.x,n.y=u.y),i("zoneCapture",n,u,{});return}}}}catch(m){r={error:m}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}}function my(n,e){var t,i,r,a,s,o,u=function(h){if(h.broken)return"continue";var m=e.find(function(B){return B.id===h.bodyId}),y=e.find(function(B){return B.id===h.anchorId});if(!m||m.mode!=="dynamic")return"continue";var M=(a=(r=y?.x)!==null&&r!==void 0?r:h.x)!==null&&a!==void 0?a:0,g=(o=(s=y?.y)!==null&&s!==void 0?s:h.y)!==null&&o!==void 0?o:0,v=m.x-M,P=m.y-g,p=ts(v,P);if(p<=h.lengthPx||p<1e-4)return"continue";var _=v/p,N=P/p;m.x=M+_*h.lengthPx,m.y=g+N*h.lengthPx;var D=m.vx*_+m.vy*N;D>0&&(m.vx-=_*D,m.vy-=N*D)};try{for(var l=gs(n),d=l.next();!d.done;d=l.next()){var f=d.value;u(f)}}catch(h){t={error:h}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(t)throw t.error}}}function Kf(n){for(var e,t,i,r,a,s,o,u,l,d,f,h=n.bodies,m=n.zones,y=m===void 0?[]:m,M=n.joints,g=M===void 0?[]:M,v=n.bounds,P=n.dt,p=n.onEvent,_=p===void 0?function(){}:p,N=h.filter(function(Q){return Q.mode==="dynamic"&&!Q.captured}),D=N.reduce(function(Q,ie){return Math.max(Q,ts(ie.vx,ie.vy))},0),B=N.reduce(function(Q,ie){return Math.min(Q,js(ie))},24),w=Math.min(16,Math.max(1,Math.ceil(D*P/(B*.45)))),A=P/w,z=0;z<w;z++){try{for(var V=(e=void 0,gs(N)),$=V.next();!$.done;$=V.next()){var T=$.value;T.vy+=((o=T.gravity)!==null&&o!==void 0?o:0)*A;var S=ts(T.vx,T.vy);if(S>T.maxSpeed){var Y=T.maxSpeed/S;T.vx*=Y,T.vy*=Y,S=T.maxSpeed}T.x+=T.vx*A,T.y+=T.vy*A;var W=Math.max(0,S-((u=T.friction)!==null&&u!==void 0?u:0)*A),se=Math.exp(-((l=T.linearDamping)!==null&&l!==void 0?l:0)*A);if(S>1e-4){var O=W/S*se;T.vx*=O,T.vy*=O}T.spinToRotation&&(T.angle=((d=T.angle)!==null&&d!==void 0?d:0)+ts(T.vx,T.vy)*A/js(T)*(T.vx<0?-1:1))}}catch(Q){e={error:Q}}finally{try{$&&!$.done&&(t=V.return)&&t.call(V)}finally{if(e)throw e.error}}for(var U=0;U<N.length;U++){var T=N[U];try{for(var H=(i=void 0,gs(h)),ne=H.next();!ne.done;ne=H.next()){var ce=ne.value;ce.id!==T.id&&ce.mode!=="dynamic"&&Dm(T,ce,_)}}catch(ie){i={error:ie}}finally{try{ne&&!ne.done&&(r=H.return)&&r.call(H)}finally{if(i)throw i.error}}for(var ce=U+1;ce<N.length;ce++)Dm(N[ce],T,_);var pe=T.shape==="box"?T.width/2:js(T),le=T.shape==="box"?T.height/2:js(T);T.wallBounce?(T.x-pe<v.left&&(T.x=v.left+pe,T.vx<0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vx)}),T.vx=-T.vx*T.restitution)),T.x+pe>v.right&&(T.x=v.right-pe,T.vx>0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vx)}),T.vx=-T.vx*T.restitution)),T.y-le<v.top&&(T.y=v.top+le,T.vy<0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vy)}),T.vy=-T.vy*T.restitution)),T.y+le>v.bottom&&(T.y=v.bottom-le,T.vy>0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vy)}),T.vy=-T.vy*T.restitution))):!T.exited&&(T.x+pe<v.left||T.x-pe>v.right||T.y+le<v.top||T.y-le>v.bottom)&&(T.exited=!0,_("boundaryExit",T,null,{})),py(T,y,A,_)}my(g,h)}try{for(var be=gs(N),Pe=be.next();!Pe.done;Pe=be.next()){var T=Pe.value,S=ts(T.vx,T.vy);S<T.restSpeed&&!T.captured?(T.restElapsed=((f=T.restElapsed)!==null&&f!==void 0?f:0)+P,T.restElapsed>=T.restDelaySeconds&&!T.atRest&&(T.atRest=!0,T.vx=0,T.vy=0,_("bodyRest",T,null,{}))):S>=T.restSpeed&&(T.restElapsed=0,T.atRest=!1)}}catch(Q){a={error:Q}}finally{try{Pe&&!Pe.done&&(s=be.return)&&s.call(be)}finally{if(a)throw a.error}}}function Um(n){for(var e=n.body,t=n.bodies,i=n.zones,r=i===void 0?[]:i,a=n.bounds,s=n.dots,o=s===void 0?8:s,u=n.bounces,l=u===void 0?1:u,d=function(p){return Ol({},p)},f=d(e),h=t.filter(function(p){return p.id!==e.id}).map(d),m=fy([f],Nm(h),!1),y=[],M=0,g=!1,v=function(p,_,N,D){p==="bodyBounce"&&D.sourceId===e.id&&M++,p==="zoneCapture"&&D.sourceId===e.id&&(g=!0)},P=0;P<90&&y.length<o&&!g&&M<=l;P++)Kf({bodies:m,zones:r,bounds:a,dt:1/60,onEvent:function(p,_,N,D){return v(p,_,N,Ol(Ol({},D),{sourceId:_.id}))}}),P%Math.max(1,Math.floor(90/o))===0&&y.push({x:f.x,y:f.y});return y}var Co=function(){return Co=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Co.apply(this,arguments)},Bl=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Om=.008333333333333333;function eo(n,e,t){var i,r,a,s=(i=n.boundsX)!==null&&i!==void 0?i:3,o=(r=n.boundsZ)!==null&&r!==void 0?r:7;if(Math.abs(e)>s||Math.abs(t)>o)return null;if(!n.ramp)return 0;var u=(a=n.rampHeight)!==null&&a!==void 0?a:1.1;return t>=1?0:t<=-1?u:(1-t)*(u*.5)}function Fm(n,e,t,i){var r,a,s,o=n.radius,u=Math.cos(e.angle),l=Math.sin(e.angle),d=n.x-e.x,f=n.z-e.z,h=u*d+l*f,m=-l*d+u*f,y=Math.max(-e.hx,Math.min(e.hx,h)),M=Math.max(-e.hz,Math.min(e.hz,m)),g=h-y,v=m-M,P=Math.hypot(g,v),p=eo(n,n.x,n.z);if(!(P>=o||p!==null&&n.y>p+.55)){P<1e-8?e.hx-Math.abs(h)<e.hz-Math.abs(m)?(g=h<0?-1:1,v=0,P=0):(g=0,v=m<0?-1:1,P=0):(g/=P,v/=P);var _=u*g-l*v,N=l*g+u*v;n.x+=_*(o-P+1e-5),n.z+=N*(o-P+1e-5);var D=(r=e.vx)!==null&&r!==void 0?r:0,B=(a=e.vz)!==null&&a!==void 0?a:0,w=(n.vx-D)*_+(n.vz-B)*N;if(w<0){var A=1+((s=n.restitution)!==null&&s!==void 0?s:.72);n.vx-=A*w*_,n.vz-=A*w*N,Math.abs(w)>.3&&t>0&&i&&i("bodyBounce",n,e.sourceId?e:void 0)}}}function Bm(n,e){n.vx=0,n.vy=0,n.vz=0,n.airborne=!1,n.atRest=!0,n.restElapsed=0,n.movingTime=0,e&&e("bodyRest",n)}function Qf(n,e){n.x=n.lastSafe.x,n.y=n.lastSafe.y,n.z=n.lastSafe.z,Bm(n,e)}function jf(n){var e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g,v,P,p=n.bodies,_=n.walls,N=n.zones,D=n.dt,B=n.onEvent;if(!(!Number.isFinite(D)||D<=0))for(var w=Math.max(1,Math.round(D/Om)),A=D/w,z=0;z<w;z++)try{for(var V=(e=void 0,Bl(p)),$=V.next();!$.done;$=V.next()){var T=$.value;if(!(T.mode!=="dynamic"||T.captured)&&!T.atRest){var S=(l=T.boundsX)!==null&&l!==void 0?l:3,Y=(d=T.boundsZ)!==null&&d!==void 0?d:7;if(T.y<-3||Math.abs(T.x)>S+2||Math.abs(T.z)>Y+2){Qf(T,B);continue}T.movingTime=((f=T.movingTime)!==null&&f!==void 0?f:0)+A;var W=T.radius,se=Math.hypot(T.vx,T.vy,T.vz),O=Math.max(1,Math.min(16,Math.ceil(se*A/(W*.45)))),U=A/O;(!T._perimeter||T._pbx!==S||T._pbz!==Y)&&(T._pbx=S,T._pbz=Y,T._perimeter=[{x:-(S+.1),z:0,hx:.1,hz:Y+.1,angle:0,vx:0,vz:0},{x:S+.1,z:0,hx:.1,hz:Y+.1,angle:0,vx:0,vz:0},{x:0,z:-(Y+.1),hx:S+.1,hz:.1,angle:0,vx:0,vz:0},{x:0,z:Y+.1,hx:S+.1,hz:.1,angle:0,vx:0,vz:0}]);for(var H=T._perimeter,ne=!1,ce=0;ce<O;ce++){var pe=eo(T,T.x,T.z),le=pe!==null&&T.y<=pe+W+.012&&T.vy<=.1,be=pe;if(le){T.y=pe+W,T.vy=0;var Pe=Math.hypot(T.vx,T.vz),Q=Math.max(0,Pe-((h=T.friction)!==null&&h!==void 0?h:1.05)*U);if(Pe>0&&(T.vx*=Q/Pe,T.vz*=Q/Pe),T.ramp&&T.z<1&&T.z>-1){var ie=((m=T.rampHeight)!==null&&m!==void 0?m:1.1)*.5;T.vz+=9.81*ie/(1+ie*ie)*U}}else T.vy-=9.81*U,T.airborne||(T.airborne=!0,B&&B("bodyJump",T));T.x+=T.vx*U,T.z+=T.vz*U,T.y+=T.vy*U;var Me=eo(T,T.x,T.z);if(Me!==null){if(le&&be!==null){var ie=((y=T.rampHeight)!==null&&y!==void 0?y:1.1)*.5;T.ramp&&T.z<=-1&&T.z-T.vz*U>-1.5&&T.vz<-.8?(T.vy=-T.vz*ie,T.airborne=!0,B&&B("bodyJump",T)):T.y=Me+W}T.y<Me+W&&(T.y=Me+W,T.vy=0,T.airborne=!1)}if(T.y<2){try{for(var Le=(i=void 0,Bl(_)),Ee=Le.next();!Ee.done;Ee=Le.next()){var Xe=Ee.value;Fm(T,Xe,U,B)}}catch(Pt){i={error:Pt}}finally{try{Ee&&!Ee.done&&(r=Le.return)&&r.call(Le)}finally{if(i)throw i.error}}try{for(var tt=(a=void 0,Bl(H)),Ge=tt.next();!Ge.done;Ge=tt.next()){var Xe=Ge.value;Fm(T,Xe,U,B)}}catch(Pt){a={error:Pt}}finally{try{Ge&&!Ge.done&&(s=tt.return)&&s.call(tt)}finally{if(a)throw a.error}}}T.spin=((M=T.spin)!==null&&M!==void 0?M:0)+Math.hypot(T.vx,T.vz)*U/W;var Ye=Math.hypot(T.vx,T.vz);try{for(var dt=(o=void 0,Bl(N)),ke=dt.next();!ke.done;ke=dt.next()){var at=ke.value,Ke=Math.hypot(T.x-at.x,T.z-at.z);if(Ke<at.radius&&Math.abs(T.y-(at.y+W))<at.heightTolerance&&Ye<at.maxCaptureSpeed){T.captured=!0,T.captureElapsed=0,T.captureTarget={x:at.x,y:at.y,z:at.z},T.vx=0,T.vy=0,T.vz=0,T.atRest=!0,B&&B("zoneCapture",T,at),ne=!0;break}}}catch(Pt){o={error:Pt}}finally{try{ke&&!ke.done&&(u=dt.return)&&u.call(dt)}finally{if(o)throw o.error}}if(ne)break;if(T.y<-3||Math.abs(T.x)>S+2||Math.abs(T.z)>Y+2){Qf(T,B),ne=!0;break}}if(!ne){var jt=Math.hypot(T.vx,T.vy,T.vz);jt<((g=T.restSpeed)!==null&&g!==void 0?g:.07)?(T.restElapsed=((v=T.restElapsed)!==null&&v!==void 0?v:0)+A,T.restElapsed>((P=T.restDelaySeconds)!==null&&P!==void 0?P:.25)&&Bm(T,B)):T.restElapsed=0,T.movingTime>18&&Qf(T,B)}}}}catch(Pt){e={error:Pt}}finally{try{$&&!$.done&&(t=V.return)&&t.call(V)}finally{if(e)throw e.error}}}function km(n){var e,t=n.body,i=n.walls,r=n.zones,a=n.vx,s=n.vz,o=n.dots,u=o===void 0?15:o,l=Math.hypot(a,s);if(!Number.isFinite(l)||l<.35)return[];for(var d=Math.min(1,((e=t.maxSpeed)!==null&&e!==void 0?e:9)/l),f=Co(Co({},t),{vx:a*d,vy:0,vz:s*d,atRest:!1,captured:!1,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:t.x,y:t.y,z:t.z}}),h=i.map(function(P){return Co(Co({},P),{vx:0,vz:0})}),m=[f],y={bodies:m,walls:h,zones:r,dt:Om},M=[],g=Math.max(18,u*6),v=0;v<g&&(jf(y),v%6===0&&M.push({x:f.x,y:f.y,z:f.z}),!(f.atRest||f.captured));v++);return M}function eh(n,e,t,i,r,a){var s,o,u,l;i===void 0&&(i=[]),r===void 0&&(r=12),a===void 0&&(a=12);for(var d=n,f=e,h=Math.max(.05,t??.45),m=0;m<2;m++){try{for(var y=(s=void 0,Bl(i)),M=y.next();!M.done;M=y.next()){var g=M.value,v=Math.cos((u=g.angle)!==null&&u!==void 0?u:0),P=Math.sin((l=g.angle)!==null&&l!==void 0?l:0),p=d-g.x,_=f-g.z,N=v*p+P*_,D=-P*p+v*_,B=Math.max(-g.hx,Math.min(g.hx,N)),w=Math.max(-g.hz,Math.min(g.hz,D)),A=N-B,z=D-w,V=Math.hypot(A,z);if(!(V>=h)){V<1e-8?g.hx-Math.abs(N)<g.hz-Math.abs(D)?(A=N<0?-1:1,z=0):(A=0,z=D<0?-1:1):(A/=V,z/=V);var $=v*A-P*z,T=P*A+v*z;d+=$*(h-V+1e-4),f+=T*(h-V+1e-4)}}}catch(W){s={error:W}}finally{try{M&&!M.done&&(o=y.return)&&o.call(y)}finally{if(s)throw s.error}}var S=Math.max(0,(r??12)-h),Y=Math.max(0,(a??12)-h);d=Math.max(-S,Math.min(S,d)),f=Math.max(-Y,Math.min(Y,f))}return{x:d,z:f}}var bv=0,Vh=1,wv=2;var bc=1,xd=2,ul=3,Va=0,Dr=1,Er=2,Ga=0,dl=1,Gh=2,Hh=3,Wh=4,Tv=5;var co=100,Ev=101,Av=102,Iv=103,Cv=104,Rv=200,Pv=201,Lv=202,Dv=203,Xh=204,Yh=205,Nv=206,Uv=207,Fv=208,Ov=209,Bv=210,kv=211,zv=212,Vv=213,Gv=214,Ou=0,Bu=1,ku=2,Yo=3,zu=4,Vu=5,Gu=6,Hu=7,_d=0,Hv=1,Wv=2,Gr=0,qh=1,Zh=2,Jh=3,wc=4,$h=5,Kh=6,Tc=7,Ch="attached",Xv="detached",Qh=300,Rs=301,uo=302,fl=303,Md=304,Ec=306,ws=1e3,fa=1001,qo=1002,Ki=1003,Sd=1004;var fo=1005;var rr=1006,hl=1007;var Ha=1008;var Hr=1009,jh=1010,ep=1011,pl=1012,bd=1013,Ia=1014,na=1015,Ca=1016,wd=1017,Td=1018,ml=1020,tp=35902,np=35899,ip=1021,rp=1022,ia=1023,Ba=1026,Ps=1027,Ed=1028,Ad=1029,Ls=1030,Id=1031;var Cd=1033,Ac=33776,Ic=33777,Cc=33778,Rc=33779,Rd=35840,Pd=35841,Ld=35842,Dd=35843,Nd=36196,Ud=37492,Fd=37496,Od=37488,Bd=37489,Pc=37490,kd=37491,zd=37808,Vd=37809,Gd=37810,Hd=37811,Wd=37812,Xd=37813,Yd=37814,qd=37815,Zd=37816,Jd=37817,$d=37818,Kd=37819,Qd=37820,jd=37821,ef=36492,tf=36494,nf=36495,rf=36283,af=36284,Lc=36285,sf=36286;var $l=2300,Wu=2301,Uu=2302,Rh=2303,Ph=2400,Lh=2401,Dh=2402;var Yv=3200;var Dc=0,qv=1,Nr="",pr="srgb",Kl="srgb-linear",Ql="linear",gi="srgb";var Fu=7680;var Zv=519,Jv=512,$v=513,Kv=514,of=515,Qv=516,jv=517,lf=518,e0=519,t0=35044;var ap="300 es",Ea=2e3,Zo=2001;function vy(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function gy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function jl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function n0(){let n=jl("canvas");return n.style.display="block",n}var zm={},Jo=null;function sp(...n){let e="THREE."+n.shift();Jo?Jo("log",e,...n):console.log(e,...n)}function i0(n){let e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function mn(...n){n=i0(n);let e="THREE."+n.shift();if(Jo)Jo("warn",e,...n);else{let t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function Tn(...n){n=i0(n);let e="THREE."+n.shift();if(Jo)Jo("error",e,...n);else{let t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function ao(...n){let e=n.join(" ");e in zm||(zm[e]=!0,mn(...n))}function r0(n,e,t){return new Promise(function(i,r){function a(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:i()}}setTimeout(a,t)})}var a0={[Ou]:Bu,[ku]:Gu,[zu]:Hu,[Yo]:Vu,[Bu]:Ou,[Gu]:ku,[Hu]:zu,[Vu]:Yo},ka=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){let i=this._listeners;if(i===void 0)return;let r=i[e];if(r!==void 0){let a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let i=t[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}},Sr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var th=Math.PI/180,Xu=180/Math.PI;function ho(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Sr[n&255]+Sr[n>>8&255]+Sr[n>>16&255]+Sr[n>>24&255]+"-"+Sr[e&255]+Sr[e>>8&255]+"-"+Sr[e>>16&15|64]+Sr[e>>24&255]+"-"+Sr[t&63|128]+Sr[t>>8&255]+"-"+Sr[t>>16&255]+Sr[t>>24&255]+Sr[i&255]+Sr[i>>8&255]+Sr[i>>16&255]+Sr[i>>24&255]).toLowerCase()}function Kn(n,e,t){return Math.max(e,Math.min(t,n))}function yy(n,e){return(n%e+e)%e}function nh(n,e,t){return(1-t)*n+t*e}function kl(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:case Uint8ClampedArray:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Br(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var fp=class fp{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Kn(this.x,e.x,t.x),this.y=Kn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Kn(this.x,e,t),this.y=Kn(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Kn(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Kn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};fp.prototype.isVector2=!0;var qt=fp,kr=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,s,o){let u=i[r+0],l=i[r+1],d=i[r+2],f=i[r+3],h=a[s+0],m=a[s+1],y=a[s+2],M=a[s+3];if(f!==M||u!==h||l!==m||d!==y){let g=u*h+l*m+d*y+f*M;g<0&&(h=-h,m=-m,y=-y,M=-M,g=-g);let v=1-o;if(g<.9995){let P=Math.acos(g),p=Math.sin(P);v=Math.sin(v*P)/p,o=Math.sin(o*P)/p,u=u*v+h*o,l=l*v+m*o,d=d*v+y*o,f=f*v+M*o}else{u=u*v+h*o,l=l*v+m*o,d=d*v+y*o,f=f*v+M*o;let P=1/Math.sqrt(u*u+l*l+d*d+f*f);u*=P,l*=P,d*=P,f*=P}}e[t]=u,e[t+1]=l,e[t+2]=d,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,r,a,s){let o=i[r],u=i[r+1],l=i[r+2],d=i[r+3],f=a[s],h=a[s+1],m=a[s+2],y=a[s+3];return e[t]=o*y+d*f+u*m-l*h,e[t+1]=u*y+d*h+l*f-o*m,e[t+2]=l*y+d*m+o*h-u*f,e[t+3]=d*y-o*f-u*h-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,u=Math.sin,l=o(i/2),d=o(r/2),f=o(a/2),h=u(i/2),m=u(r/2),y=u(a/2);switch(s){case"XYZ":this._x=h*d*f+l*m*y,this._y=l*m*f-h*d*y,this._z=l*d*y+h*m*f,this._w=l*d*f-h*m*y;break;case"YXZ":this._x=h*d*f+l*m*y,this._y=l*m*f-h*d*y,this._z=l*d*y-h*m*f,this._w=l*d*f+h*m*y;break;case"ZXY":this._x=h*d*f-l*m*y,this._y=l*m*f+h*d*y,this._z=l*d*y+h*m*f,this._w=l*d*f-h*m*y;break;case"ZYX":this._x=h*d*f-l*m*y,this._y=l*m*f+h*d*y,this._z=l*d*y-h*m*f,this._w=l*d*f+h*m*y;break;case"YZX":this._x=h*d*f+l*m*y,this._y=l*m*f+h*d*y,this._z=l*d*y-h*m*f,this._w=l*d*f-h*m*y;break;case"XZY":this._x=h*d*f-l*m*y,this._y=l*m*f-h*d*y,this._z=l*d*y+h*m*f,this._w=l*d*f+h*m*y;break;default:mn("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],a=t[8],s=t[1],o=t[5],u=t[9],l=t[2],d=t[6],f=t[10],h=i+o+f;if(h>0){let m=.5/Math.sqrt(h+1);this._w=.25/m,this._x=(d-u)*m,this._y=(a-l)*m,this._z=(s-r)*m}else if(i>o&&i>f){let m=2*Math.sqrt(1+i-o-f);this._w=(d-u)/m,this._x=.25*m,this._y=(r+s)/m,this._z=(a+l)/m}else if(o>f){let m=2*Math.sqrt(1+o-i-f);this._w=(a-l)/m,this._x=(r+s)/m,this._y=.25*m,this._z=(u+d)/m}else{let m=2*Math.sqrt(1+f-i-o);this._w=(s-r)/m,this._x=(a+l)/m,this._y=(u+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Kn(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=t._x,u=t._y,l=t._z,d=t._w;return this._x=i*d+s*o+r*l-a*u,this._y=r*d+s*u+a*o-i*l,this._z=a*d+s*l+i*u-r*o,this._w=s*d-i*o-r*u-a*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,a=-a,s=-s,o=-o);let u=1-t;if(o<.9995){let l=Math.acos(o),d=Math.sin(l);u=Math.sin(u*l)/d,t=Math.sin(t*l)/d,this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this._onChangeCallback()}else this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),a=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),a*Math.sin(t),a*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},hp=class hp{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Vm.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Vm.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,u=e.w,l=2*(s*r-o*i),d=2*(o*t-a*r),f=2*(a*i-s*t);return this.x=t+u*l+s*f-o*d,this.y=i+u*d+o*l-a*f,this.z=r+u*f+a*d-s*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Kn(this.x,e.x,t.x),this.y=Kn(this.y,e.y,t.y),this.z=Kn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Kn(this.x,e,t),this.y=Kn(this.y,e,t),this.z=Kn(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Kn(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,a=e.z,s=t.x,o=t.y,u=t.z;return this.x=r*u-a*o,this.y=a*s-i*u,this.z=i*o-r*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return ih.copy(this).projectOnVector(e),this.sub(ih)}reflect(e){return this.sub(ih.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Kn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};hp.prototype.isVector3=!0;var ge=hp,ih=new ge,Vm=new kr,pp=class pp{constructor(e,t,i,r,a,s,o,u,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l)}set(e,t,i,r,a,s,o,u,l){let d=this.elements;return d[0]=e,d[1]=r,d[2]=o,d[3]=t,d[4]=a,d[5]=u,d[6]=i,d[7]=s,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[3],u=i[6],l=i[1],d=i[4],f=i[7],h=i[2],m=i[5],y=i[8],M=r[0],g=r[3],v=r[6],P=r[1],p=r[4],_=r[7],N=r[2],D=r[5],B=r[8];return a[0]=s*M+o*P+u*N,a[3]=s*g+o*p+u*D,a[6]=s*v+o*_+u*B,a[1]=l*M+d*P+f*N,a[4]=l*g+d*p+f*D,a[7]=l*v+d*_+f*B,a[2]=h*M+m*P+y*N,a[5]=h*g+m*p+y*D,a[8]=h*v+m*_+y*B,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8];return t*s*d-t*o*l-i*a*d+i*o*u+r*a*l-r*s*u}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=d*s-o*l,h=o*u-d*a,m=l*a-s*u,y=t*f+i*h+r*m;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let M=1/y;return e[0]=f*M,e[1]=(r*l-d*i)*M,e[2]=(o*i-r*s)*M,e[3]=h*M,e[4]=(d*t-r*u)*M,e[5]=(r*a-o*t)*M,e[6]=m*M,e[7]=(i*u-l*t)*M,e[8]=(s*t-i*a)*M,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,a,s,o){let u=Math.cos(a),l=Math.sin(a);return this.set(i*u,i*l,-i*(u*s+l*o)+s+e,-r*l,r*u,-r*(-l*s+u*o)+o+t,0,0,1),this}scale(e,t){return ao("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(rh.makeScale(e,t)),this}rotate(e){return ao("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(rh.makeRotation(-e)),this}translate(e,t){return ao("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(rh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};pp.prototype.isMatrix3=!0;var Ln=pp,rh=new Ln,Gm=new Ln().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Hm=new Ln().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xy(){let n={enabled:!0,workingColorSpace:Kl,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===gi&&(r.r=os(r.r),r.g=os(r.g),r.b=os(r.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(r.applyMatrix3(this.spaces[a].toXYZ),r.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===gi&&(r.r=Wo(r.r),r.g=Wo(r.g),r.b=Wo(r.b))),r},workingToColorSpace:function(r,a){return this.convert(r,this.workingColorSpace,a)},colorSpaceToWorking:function(r,a){return this.convert(r,a,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Nr?Ql:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,a=this.workingColorSpace){return r.fromArray(this.spaces[a].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,a,s){return r.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,a){return ao("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return ao("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Kl]:{primaries:e,whitePoint:i,transfer:Ql,toXYZ:Gm,fromXYZ:Hm,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pr},outputColorSpaceConfig:{drawingBufferColorSpace:pr}},[pr]:{primaries:e,whitePoint:i,transfer:gi,toXYZ:Gm,fromXYZ:Hm,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pr}}}),n}var jn=xy();function os(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Wo(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Ro,Yu=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Ro===void 0&&(Ro=jl("canvas")),Ro.width=e.width,Ro.height=e.height;let r=Ro.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Ro}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=jl("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=os(a[s]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(os(t[i]/255)*255):t[i]=os(t[i]);return{data:t,width:e.width,height:e.height}}else return mn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},_y=0,$o=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:_y++}),this.uuid=ho(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,o=r.length;s<o;s++)r[s].isDataTexture?a.push(ah(r[s].image)):a.push(ah(r[s]))}else a=ah(r);i.url=a}return t||(e.images[this.uuid]=i),i}};function ah(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Yu.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(mn("Texture: Unable to serialize Texture."),{})}var My=0,sh=new ge,mr=class n extends ka{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=fa,r=fa,a=rr,s=Ha,o=ia,u=Hr,l=n.DEFAULT_ANISOTROPY,d=Nr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:My++}),this.uuid=ho(),this.name="",this.source=new $o(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=u,this.offset=new qt(0,0),this.repeat=new qt(1,1),this.center=new qt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ln,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(sh).x}get height(){return this.source.getSize(sh).y}get depth(){return this.source.getSize(sh).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let i=e[t];if(i===void 0){mn(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){mn(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Qh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ws:e.x=e.x-Math.floor(e.x);break;case fa:e.x=e.x<0?0:1;break;case qo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ws:e.y=e.y-Math.floor(e.y);break;case fa:e.y=e.y<0?0:1;break;case qo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};mr.DEFAULT_IMAGE=null;mr.DEFAULT_MAPPING=Qh;mr.DEFAULT_ANISOTROPY=1;var mp=class mp{constructor(e=0,t=0,i=0,r=1){this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,a,u=e.elements,l=u[0],d=u[4],f=u[8],h=u[1],m=u[5],y=u[9],M=u[2],g=u[6],v=u[10];if(Math.abs(d-h)<.01&&Math.abs(f-M)<.01&&Math.abs(y-g)<.01){if(Math.abs(d+h)<.1&&Math.abs(f+M)<.1&&Math.abs(y+g)<.1&&Math.abs(l+m+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let p=(l+1)/2,_=(m+1)/2,N=(v+1)/2,D=(d+h)/4,B=(f+M)/4,w=(y+g)/4;return p>_&&p>N?p<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(p),r=D/i,a=B/i):_>N?_<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(_),i=D/r,a=w/r):N<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(N),i=B/a,r=w/a),this.set(i,r,a,t),this}let P=Math.sqrt((g-y)*(g-y)+(f-M)*(f-M)+(h-d)*(h-d));return Math.abs(P)<.001&&(P=1),this.x=(g-y)/P,this.y=(f-M)/P,this.z=(h-d)/P,this.w=Math.acos((l+m+v-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Kn(this.x,e.x,t.x),this.y=Kn(this.y,e.y,t.y),this.z=Kn(this.z,e.z,t.z),this.w=Kn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Kn(this.x,e,t),this.y=Kn(this.y,e,t),this.z=Kn(this.z,e,t),this.w=Kn(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Kn(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};mp.prototype.isVector4=!0;var Si=mp,qu=class extends ka{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rr,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Si(0,0,e,t),this.scissorTest=!1,this.viewport=new Si(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:i.depth},a=new mr(r),s=i.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveColorBuffer=i.resolveColorBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.storeMultisampledColorBuffer=i.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=i.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=i.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:rr,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,a=this.textures.length;r<a;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new $o(r)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},zr=class extends qu{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},ec=class extends mr{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ki,this.minFilter=Ki,this.wrapR=fa,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Zu=class extends mr{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ki,this.minFilter=Ki,this.wrapR=fa,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var yd=class yd{constructor(e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g)}set(e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g){let v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=a,v[5]=s,v[9]=o,v[13]=u,v[2]=l,v[6]=d,v[10]=f,v[14]=h,v[3]=m,v[7]=y,v[11]=M,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new yd().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,i=e.elements,r=1/Po.setFromMatrixColumn(e,0).length(),a=1/Po.setFromMatrixColumn(e,1).length(),s=1/Po.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),u=Math.cos(r),l=Math.sin(r),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){let h=s*d,m=s*f,y=o*d,M=o*f;t[0]=u*d,t[4]=-u*f,t[8]=l,t[1]=m+y*l,t[5]=h-M*l,t[9]=-o*u,t[2]=M-h*l,t[6]=y+m*l,t[10]=s*u}else if(e.order==="YXZ"){let h=u*d,m=u*f,y=l*d,M=l*f;t[0]=h+M*o,t[4]=y*o-m,t[8]=s*l,t[1]=s*f,t[5]=s*d,t[9]=-o,t[2]=m*o-y,t[6]=M+h*o,t[10]=s*u}else if(e.order==="ZXY"){let h=u*d,m=u*f,y=l*d,M=l*f;t[0]=h-M*o,t[4]=-s*f,t[8]=y+m*o,t[1]=m+y*o,t[5]=s*d,t[9]=M-h*o,t[2]=-s*l,t[6]=o,t[10]=s*u}else if(e.order==="ZYX"){let h=s*d,m=s*f,y=o*d,M=o*f;t[0]=u*d,t[4]=y*l-m,t[8]=h*l+M,t[1]=u*f,t[5]=M*l+h,t[9]=m*l-y,t[2]=-l,t[6]=o*u,t[10]=s*u}else if(e.order==="YZX"){let h=s*u,m=s*l,y=o*u,M=o*l;t[0]=u*d,t[4]=M-h*f,t[8]=y*f+m,t[1]=f,t[5]=s*d,t[9]=-o*d,t[2]=-l*d,t[6]=m*f+y,t[10]=h-M*f}else if(e.order==="XZY"){let h=s*u,m=s*l,y=o*u,M=o*l;t[0]=u*d,t[4]=-f,t[8]=l*d,t[1]=h*f+M,t[5]=s*d,t[9]=m*f-y,t[2]=y*f-m,t[6]=o*d,t[10]=M*f+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Sy,e,by)}lookAt(e,t,i){let r=this.elements;return Jr.subVectors(e,t),Jr.lengthSq()===0&&(Jr.z=1),Jr.normalize(),ys.crossVectors(i,Jr),ys.lengthSq()===0&&(Math.abs(i.z)===1?Jr.x+=1e-4:Jr.z+=1e-4,Jr.normalize(),ys.crossVectors(i,Jr)),ys.normalize(),fu.crossVectors(Jr,ys),r[0]=ys.x,r[4]=fu.x,r[8]=Jr.x,r[1]=ys.y,r[5]=fu.y,r[9]=Jr.y,r[2]=ys.z,r[6]=fu.z,r[10]=Jr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[4],u=i[8],l=i[12],d=i[1],f=i[5],h=i[9],m=i[13],y=i[2],M=i[6],g=i[10],v=i[14],P=i[3],p=i[7],_=i[11],N=i[15],D=r[0],B=r[4],w=r[8],A=r[12],z=r[1],V=r[5],$=r[9],T=r[13],S=r[2],Y=r[6],W=r[10],se=r[14],O=r[3],U=r[7],H=r[11],ne=r[15];return a[0]=s*D+o*z+u*S+l*O,a[4]=s*B+o*V+u*Y+l*U,a[8]=s*w+o*$+u*W+l*H,a[12]=s*A+o*T+u*se+l*ne,a[1]=d*D+f*z+h*S+m*O,a[5]=d*B+f*V+h*Y+m*U,a[9]=d*w+f*$+h*W+m*H,a[13]=d*A+f*T+h*se+m*ne,a[2]=y*D+M*z+g*S+v*O,a[6]=y*B+M*V+g*Y+v*U,a[10]=y*w+M*$+g*W+v*H,a[14]=y*A+M*T+g*se+v*ne,a[3]=P*D+p*z+_*S+N*O,a[7]=P*B+p*V+_*Y+N*U,a[11]=P*w+p*$+_*W+N*H,a[15]=P*A+p*T+_*se+N*ne,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],u=e[9],l=e[13],d=e[2],f=e[6],h=e[10],m=e[14],y=e[3],M=e[7],g=e[11],v=e[15],P=u*m-l*h,p=o*m-l*f,_=o*h-u*f,N=s*m-l*d,D=s*h-u*d,B=s*f-o*d;return t*(M*P-g*p+v*_)-i*(y*P-g*N+v*D)+r*(y*p-M*N+v*B)-a*(y*_-M*D+g*B)}determinantAffine(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[1],s=e[5],o=e[9],u=e[2],l=e[6],d=e[10];return t*(s*d-o*l)-i*(a*d-o*u)+r*(a*l-s*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=e[9],h=e[10],m=e[11],y=e[12],M=e[13],g=e[14],v=e[15],P=t*o-i*s,p=t*u-r*s,_=t*l-a*s,N=i*u-r*o,D=i*l-a*o,B=r*l-a*u,w=d*M-f*y,A=d*g-h*y,z=d*v-m*y,V=f*g-h*M,$=f*v-m*M,T=h*v-m*g,S=P*T-p*$+_*V+N*z-D*A+B*w;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Y=1/S;return e[0]=(o*T-u*$+l*V)*Y,e[1]=(r*$-i*T-a*V)*Y,e[2]=(M*B-g*D+v*N)*Y,e[3]=(h*D-f*B-m*N)*Y,e[4]=(u*z-s*T-l*A)*Y,e[5]=(t*T-r*z+a*A)*Y,e[6]=(g*_-y*B-v*p)*Y,e[7]=(d*B-h*_+m*p)*Y,e[8]=(s*$-o*z+l*w)*Y,e[9]=(i*z-t*$-a*w)*Y,e[10]=(y*D-M*_+v*P)*Y,e[11]=(f*_-d*D-m*P)*Y,e[12]=(o*A-s*V-u*w)*Y,e[13]=(t*V-i*A+r*w)*Y,e[14]=(M*p-y*N-g*P)*Y,e[15]=(d*N-f*p+h*P)*Y,this}scale(e){let t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),a=1-i,s=e.x,o=e.y,u=e.z,l=a*s,d=a*o;return this.set(l*s+i,l*o-r*u,l*u+r*o,0,l*o+r*u,d*o+i,d*u-r*s,0,l*u-r*o,d*u+r*s,a*u*u+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,a=t._x,s=t._y,o=t._z,u=t._w,l=a+a,d=s+s,f=o+o,h=a*l,m=a*d,y=a*f,M=s*d,g=s*f,v=o*f,P=u*l,p=u*d,_=u*f,N=i.x,D=i.y,B=i.z;return r[0]=(1-(M+v))*N,r[1]=(m+_)*N,r[2]=(y-p)*N,r[3]=0,r[4]=(m-_)*D,r[5]=(1-(h+v))*D,r[6]=(g+P)*D,r[7]=0,r[8]=(y+p)*B,r[9]=(g-P)*B,r[10]=(1-(h+M))*B,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let a=this.determinantAffine();if(a===0)return i.set(1,1,1),t.identity(),this;let s=Po.set(r[0],r[1],r[2]).length(),o=Po.set(r[4],r[5],r[6]).length(),u=Po.set(r[8],r[9],r[10]).length();a<0&&(s=-s),ba.copy(this);let l=1/s,d=1/o,f=1/u;return ba.elements[0]*=l,ba.elements[1]*=l,ba.elements[2]*=l,ba.elements[4]*=d,ba.elements[5]*=d,ba.elements[6]*=d,ba.elements[8]*=f,ba.elements[9]*=f,ba.elements[10]*=f,t.setFromRotationMatrix(ba),i.x=s,i.y=o,i.z=u,this}makePerspective(e,t,i,r,a,s,o=Ea,u=!1){let l=this.elements,d=2*a/(t-e),f=2*a/(i-r),h=(t+e)/(t-e),m=(i+r)/(i-r),y,M;if(u)y=a/(s-a),M=s*a/(s-a);else if(o===Ea)y=-(s+a)/(s-a),M=-2*s*a/(s-a);else if(o===Zo)y=-s/(s-a),M=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=f,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=y,l[14]=M,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,a,s,o=Ea,u=!1){let l=this.elements,d=2/(t-e),f=2/(i-r),h=-(t+e)/(t-e),m=-(i+r)/(i-r),y,M;if(u)y=1/(s-a),M=s/(s-a);else if(o===Ea)y=-2/(s-a),M=-(s+a)/(s-a);else if(o===Zo)y=-1/(s-a),M=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=f,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=y,l[14]=M,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};yd.prototype.isMatrix4=!0;var Un=yd,Po=new ge,ba=new Un,Sy=new ge(0,0,0),by=new ge(1,1,1),ys=new ge,fu=new ge,Jr=new ge,Wm=new Un,Xm=new kr,ha=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,a=r[0],s=r[4],o=r[8],u=r[1],l=r[5],d=r[9],f=r[2],h=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(Kn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Kn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(u,l)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Kn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(u,a));break;case"ZYX":this._y=Math.asin(-Kn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,m),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Kn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-d,l),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Kn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:mn("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Wm.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Wm,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Xm.setFromEuler(this),this.setFromQuaternion(Xm,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ha.DEFAULT_ORDER="XYZ";var Ko=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},wy=0,Ym=new ge,Lo=new kr,ns=new Un,hu=new ge,zl=new ge,Ty=new ge,Ey=new kr,qm=new ge(1,0,0),Zm=new ge(0,1,0),Jm=new ge(0,0,1),$m={type:"added"},Ay={type:"removed"},Do={type:"childadded",child:null},oh={type:"childremoved",child:null},ar=class n extends ka{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:wy++}),this.uuid=ho(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new ge,t=new ha,i=new kr,r=new ge(1,1,1);function a(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Un},normalMatrix:{value:new Ln}}),this.matrix=new Un,this.matrixWorld=new Un,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ko,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Lo.setFromAxisAngle(e,t),this.quaternion.multiply(Lo),this}rotateOnWorldAxis(e,t){return Lo.setFromAxisAngle(e,t),this.quaternion.premultiply(Lo),this}rotateX(e){return this.rotateOnAxis(qm,e)}rotateY(e){return this.rotateOnAxis(Zm,e)}rotateZ(e){return this.rotateOnAxis(Jm,e)}translateOnAxis(e,t){return Ym.copy(e).applyQuaternion(this.quaternion),this.position.add(Ym.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(qm,e)}translateY(e){return this.translateOnAxis(Zm,e)}translateZ(e){return this.translateOnAxis(Jm,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ns.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?hu.copy(e):hu.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),zl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ns.lookAt(zl,hu,this.up):ns.lookAt(hu,zl,this.up),this.quaternion.setFromRotationMatrix(ns),r&&(ns.extractRotation(r.matrixWorld),Lo.setFromRotationMatrix(ns),this.quaternion.premultiply(Lo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Tn("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent($m),Do.child=e,this.dispatchEvent(Do),Do.child=null):Tn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ay),oh.child=e,this.dispatchEvent(oh),oh.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ns.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ns.multiply(e.parent.matrixWorld)),e.applyMatrix4(ns),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent($m),Do.child=e,this.dispatchEvent(Do),Do.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zl,e,Ty),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zl,Ey,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,i=e.y,r=e.z,a=this.matrix.elements;a[12]+=t-a[0]*t-a[4]*i-a[8]*r,a[13]+=i-a[1]*t-a[5]*i-a[9]*r,a[14]+=r-a[2]*t-a[6]*i-a[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),t===!0){let a=this.children;for(let s=0,o=a.length;s<o;s++)a[s].updateWorldMatrix(!1,!0,i)}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function a(o,u){return o[u.uuid]===void 0&&(o[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let u=o.shapes;if(Array.isArray(u))for(let l=0,d=u.length;l<d;l++){let f=u[l];a(e.shapes,f)}else a(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let u=0,l=this.material.length;u<l;u++)o.push(a(e.materials,this.material[u]));r.material=o}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){let u=this.animations[o];r.animations.push(a(e.animations,u))}}if(t){let o=s(e.geometries),u=s(e.materials),l=s(e.textures),d=s(e.images),f=s(e.shapes),h=s(e.skeletons),m=s(e.animations),y=s(e.nodes);o.length>0&&(i.geometries=o),u.length>0&&(i.materials=u),l.length>0&&(i.textures=l),d.length>0&&(i.images=d),f.length>0&&(i.shapes=f),h.length>0&&(i.skeletons=h),m.length>0&&(i.animations=m),y.length>0&&(i.nodes=y)}return i.object=r,i;function s(o){let u=[];for(let l in o){let d=o[l];delete d.metadata,u.push(d)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};ar.DEFAULT_UP=new ge(0,1,0);ar.DEFAULT_MATRIX_AUTO_UPDATE=!0;ar.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var ir=class extends ar{constructor(){super(),this.isGroup=!0,this.type="Group"}},Iy={type:"move"},Qo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ir,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ir,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ge,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ge),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ir,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ge,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ge,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,s=null,o=this._targetRay,u=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){s=!0;for(let M of e.hand.values()){let g=t.getJointPose(M,i),v=this._getHandJoint(l,M);g!==null&&(v.matrix.fromArray(g.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=g.radius),v.visible=g!==null}let d=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],h=d.position.distanceTo(f.position),m=.02,y=.005;l.inputState.pinching&&h>m+y?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=m-y&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(u.matrix.fromArray(a.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,a.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(a.linearVelocity)):u.hasLinearVelocity=!1,a.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(a.angularVelocity)):u.hasAngularVelocity=!1,u.eventsEnabled&&u.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Iy)))}return o!==null&&(o.visible=r!==null),u!==null&&(u.visible=a!==null),l!==null&&(l.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new ir;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},s0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},xs={h:0,s:0,l:0},pu={h:0,s:0,l:0};function lh(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}var Rn=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jn.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=jn.workingColorSpace){return this.r=e,this.g=t,this.b=i,jn.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=jn.workingColorSpace){if(e=yy(e,1),t=Kn(t,0,1),i=Kn(i,0,1),t===0)this.r=this.g=this.b=i;else{let a=i<=.5?i*(1+t):i+t-i*t,s=2*i-a;this.r=lh(s,a,e+1/3),this.g=lh(s,a,e),this.b=lh(s,a,e-1/3)}return jn.colorSpaceToWorking(this,r),this}setStyle(e,t=pr){function i(a){a!==void 0&&parseFloat(a)<1&&mn("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a,s=r[1],o=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:mn("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(a,16),t);mn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pr){let i=s0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):mn("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=os(e.r),this.g=os(e.g),this.b=os(e.b),this}copyLinearToSRGB(e){return this.r=Wo(e.r),this.g=Wo(e.g),this.b=Wo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pr){return jn.workingToColorSpace(br.copy(this),e),Math.round(Kn(br.r*255,0,255))*65536+Math.round(Kn(br.g*255,0,255))*256+Math.round(Kn(br.b*255,0,255))}getHexString(e=pr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=jn.workingColorSpace){jn.workingToColorSpace(br.copy(this),t);let i=br.r,r=br.g,a=br.b,s=Math.max(i,r,a),o=Math.min(i,r,a),u,l,d=(o+s)/2;if(o===s)u=0,l=0;else{let f=s-o;switch(l=d<=.5?f/(s+o):f/(2-s-o),s){case i:u=(r-a)/f+(r<a?6:0);break;case r:u=(a-i)/f+2;break;case a:u=(i-r)/f+4;break}u/=6}return e.h=u,e.s=l,e.l=d,e}getRGB(e,t=jn.workingColorSpace){return jn.workingToColorSpace(br.copy(this),t),e.r=br.r,e.g=br.g,e.b=br.b,e}getStyle(e=pr){jn.workingToColorSpace(br.copy(this),e);let t=br.r,i=br.g,r=br.b;return e!==pr?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(xs),this.setHSL(xs.h+e,xs.s+t,xs.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(xs),e.getHSL(pu);let i=nh(xs.h,pu.h,t),r=nh(xs.s,pu.s,t),a=nh(xs.l,pu.l,t);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*t+a[3]*i+a[6]*r,this.g=a[1]*t+a[4]*i+a[7]*r,this.b=a[2]*t+a[5]*i+a[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},br=new Rn;Rn.NAMES=s0;var tc=class extends ar{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ha,this.environmentIntensity=1,this.environmentRotation=new ha,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},wa=new ge,is=new ge,ch=new ge,rs=new ge,No=new ge,Uo=new ge,Km=new ge,uh=new ge,dh=new ge,fh=new ge,hh=new Si,ph=new Si,mh=new Si,bs=class n{constructor(e=new ge,t=new ge,i=new ge){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),wa.subVectors(e,t),r.cross(wa);let a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){wa.subVectors(r,t),is.subVectors(i,t),ch.subVectors(e,t);let s=wa.dot(wa),o=wa.dot(is),u=wa.dot(ch),l=is.dot(is),d=is.dot(ch),f=s*l-o*o;if(f===0)return a.set(0,0,0),null;let h=1/f,m=(l*u-o*d)*h,y=(s*d-o*u)*h;return a.set(1-m-y,y,m)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,rs)===null?!1:rs.x>=0&&rs.y>=0&&rs.x+rs.y<=1}static getInterpolation(e,t,i,r,a,s,o,u){return this.getBarycoord(e,t,i,r,rs)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(a,rs.x),u.addScaledVector(s,rs.y),u.addScaledVector(o,rs.z),u)}static getInterpolatedAttribute(e,t,i,r,a,s){return hh.setScalar(0),ph.setScalar(0),mh.setScalar(0),hh.fromBufferAttribute(e,t),ph.fromBufferAttribute(e,i),mh.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(hh,a.x),s.addScaledVector(ph,a.y),s.addScaledVector(mh,a.z),s}static isFrontFacing(e,t,i,r){return wa.subVectors(i,t),is.subVectors(e,t),wa.cross(is).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return wa.subVectors(this.c,this.b),is.subVectors(this.a,this.b),wa.cross(is).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,a){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,a=this.c,s,o;No.subVectors(r,i),Uo.subVectors(a,i),uh.subVectors(e,i);let u=No.dot(uh),l=Uo.dot(uh);if(u<=0&&l<=0)return t.copy(i);dh.subVectors(e,r);let d=No.dot(dh),f=Uo.dot(dh);if(d>=0&&f<=d)return t.copy(r);let h=u*f-d*l;if(h<=0&&u>=0&&d<=0)return s=u/(u-d),t.copy(i).addScaledVector(No,s);fh.subVectors(e,a);let m=No.dot(fh),y=Uo.dot(fh);if(y>=0&&m<=y)return t.copy(a);let M=m*l-u*y;if(M<=0&&l>=0&&y<=0)return o=l/(l-y),t.copy(i).addScaledVector(Uo,o);let g=d*y-m*f;if(g<=0&&f-d>=0&&m-y>=0)return Km.subVectors(a,r),o=(f-d)/(f-d+(m-y)),t.copy(r).addScaledVector(Km,o);let v=1/(g+M+h);return s=M*v,o=h*v,t.copy(i).addScaledVector(No,s).addScaledVector(Uo,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Qr=class{constructor(e=new ge(1/0,1/0,1/0),t=new ge(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Ta.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Ta.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Ta.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let a=i.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,Ta):Ta.fromBufferAttribute(a,s),Ta.applyMatrix4(e.matrixWorld),this.expandByPoint(Ta);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),mu.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),mu.copy(i.boundingBox)),mu.applyMatrix4(e.matrixWorld),this.union(mu)}let r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ta),Ta.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Vl),vu.subVectors(this.max,Vl),Fo.subVectors(e.a,Vl),Oo.subVectors(e.b,Vl),Bo.subVectors(e.c,Vl),_s.subVectors(Oo,Fo),Ms.subVectors(Bo,Oo),to.subVectors(Fo,Bo);let t=[0,-_s.z,_s.y,0,-Ms.z,Ms.y,0,-to.z,to.y,_s.z,0,-_s.x,Ms.z,0,-Ms.x,to.z,0,-to.x,-_s.y,_s.x,0,-Ms.y,Ms.x,0,-to.y,to.x,0];return!vh(t,Fo,Oo,Bo,vu)||(t=[1,0,0,0,1,0,0,0,1],!vh(t,Fo,Oo,Bo,vu))?!1:(gu.crossVectors(_s,Ms),t=[gu.x,gu.y,gu.z],vh(t,Fo,Oo,Bo,vu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ta).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ta).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(as[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),as[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),as[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),as[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),as[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),as[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),as[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),as[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(as),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},as=[new ge,new ge,new ge,new ge,new ge,new ge,new ge,new ge],Ta=new ge,mu=new Qr,Fo=new ge,Oo=new ge,Bo=new ge,_s=new ge,Ms=new ge,to=new ge,Vl=new ge,vu=new ge,gu=new ge,no=new ge;function vh(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){no.fromArray(n,a);let o=r.x*Math.abs(no.x)+r.y*Math.abs(no.y)+r.z*Math.abs(no.z),u=e.dot(no),l=t.dot(no),d=i.dot(no);if(Math.max(-Math.max(u,l,d),Math.min(u,l,d))>o)return!1}return!0}var $i=new ge,yu=new qt,Cy=0,Tr=class extends ka{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Cy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=t0,this.updateRanges=[],this.gpuType=na,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)yu.fromBufferAttribute(this,t),yu.applyMatrix3(e),this.setXY(t,yu.x,yu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyMatrix3(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyMatrix4(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyNormalMatrix(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.transformDirection(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=kl(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Br(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=kl(t,this.array)),t}setX(e,t){return this.normalized&&(t=Br(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=kl(t,this.array)),t}setY(e,t){return this.normalized&&(t=Br(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=kl(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Br(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=kl(t,this.array)),t}setW(e,t){return this.normalized&&(t=Br(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Br(t,this.array),i=Br(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Br(t,this.array),i=Br(i,this.array),r=Br(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e*=this.itemSize,this.normalized&&(t=Br(t,this.array),i=Br(i,this.array),r=Br(r,this.array),a=Br(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}};var nc=class extends Tr{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var ic=class extends Tr{constructor(e,t,i){super(new Uint32Array(e),t,i)}};var fi=class extends Tr{constructor(e,t,i){super(new Float32Array(e),t,i)}},Ry=new Qr,Gl=new ge,gh=new ge,za=class{constructor(e=new ge,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):Ry.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Gl.subVectors(e,this.center);let t=Gl.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Gl,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(gh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gl.copy(e.center).add(gh)),this.expandByPoint(Gl.copy(e.center).sub(gh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Py=0,da=new Un,yh=new ar,ko=new ge,$r=new Qr,Hl=new Qr,hr=new ge,sr=class n extends ka{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Py++}),this.uuid=ho(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(vy(e)?ic:nc)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let a=new Ln().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return da.makeRotationFromQuaternion(e),this.applyMatrix4(da),this}rotateX(e){return da.makeRotationX(e),this.applyMatrix4(da),this}rotateY(e){return da.makeRotationY(e),this.applyMatrix4(da),this}rotateZ(e){return da.makeRotationZ(e),this.applyMatrix4(da),this}translate(e,t,i){return da.makeTranslation(e,t,i),this.applyMatrix4(da),this}scale(e,t,i){return da.makeScale(e,t,i),this.applyMatrix4(da),this}lookAt(e){return yh.lookAt(e),yh.updateMatrix(),this.applyMatrix4(yh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ko).negate(),this.translate(ko.x,ko.y,ko.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let i=[];for(let r=0,a=e.length;r<a;r++){let s=e[r];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new fi(i,3))}else{let i=Math.min(e.length,t.count);for(let r=0;r<i;r++){let a=e[r];t.setXYZ(r,a.x,a.y,a.z||0)}e.length>t.count&&mn("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Qr);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ge(-1/0,-1/0,-1/0),new ge(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let a=t[i];$r.setFromBufferAttribute(a),this.morphTargetsRelative?(hr.addVectors(this.boundingBox.min,$r.min),this.boundingBox.expandByPoint(hr),hr.addVectors(this.boundingBox.max,$r.max),this.boundingBox.expandByPoint(hr)):(this.boundingBox.expandByPoint($r.min),this.boundingBox.expandByPoint($r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Tn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new za);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ge,1/0);return}if(e){let i=this.boundingSphere.center;if($r.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){let o=t[a];Hl.setFromBufferAttribute(o),this.morphTargetsRelative?(hr.addVectors($r.min,Hl.min),$r.expandByPoint(hr),hr.addVectors($r.max,Hl.max),$r.expandByPoint(hr)):($r.expandByPoint(Hl.min),$r.expandByPoint(Hl.max))}$r.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)hr.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(hr));if(t)for(let a=0,s=t.length;a<s;a++){let o=t[a],u=this.morphTargetsRelative;for(let l=0,d=o.count;l<d;l++)hr.fromBufferAttribute(o,l),u&&(ko.fromBufferAttribute(e,l),hr.add(ko)),r=Math.max(r,i.distanceToSquared(hr))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Tn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Tn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,a=t.uv,s=this.getAttribute("tangent");(s===void 0||s.count!==i.count)&&(s=new Tr(new Float32Array(4*i.count),4),this.setAttribute("tangent",s));let o=[],u=[];for(let w=0;w<i.count;w++)o[w]=new ge,u[w]=new ge;let l=new ge,d=new ge,f=new ge,h=new qt,m=new qt,y=new qt,M=new ge,g=new ge;function v(w,A,z){l.fromBufferAttribute(i,w),d.fromBufferAttribute(i,A),f.fromBufferAttribute(i,z),h.fromBufferAttribute(a,w),m.fromBufferAttribute(a,A),y.fromBufferAttribute(a,z),d.sub(l),f.sub(l),m.sub(h),y.sub(h);let V=1/(m.x*y.y-y.x*m.y);isFinite(V)&&(M.copy(d).multiplyScalar(y.y).addScaledVector(f,-m.y).multiplyScalar(V),g.copy(f).multiplyScalar(m.x).addScaledVector(d,-y.x).multiplyScalar(V),o[w].add(M),o[A].add(M),o[z].add(M),u[w].add(g),u[A].add(g),u[z].add(g))}let P=this.groups;P.length===0&&(P=[{start:0,count:e.count}]);for(let w=0,A=P.length;w<A;++w){let z=P[w],V=z.start,$=z.count;for(let T=V,S=V+$;T<S;T+=3)v(e.getX(T+0),e.getX(T+1),e.getX(T+2))}let p=new ge,_=new ge,N=new ge,D=new ge;function B(w){N.fromBufferAttribute(r,w),D.copy(N);let A=o[w];p.copy(A),p.sub(N.multiplyScalar(N.dot(A))).normalize(),_.crossVectors(D,A);let V=_.dot(u[w])<0?-1:1;s.setXYZW(w,p.x,p.y,p.z,V)}for(let w=0,A=P.length;w<A;++w){let z=P[w],V=z.start,$=z.count;for(let T=V,S=V+$;T<S;T+=3)B(e.getX(T+0)),B(e.getX(T+1)),B(e.getX(T+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new Tr(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,m=i.count;h<m;h++)i.setXYZ(h,0,0,0);let r=new ge,a=new ge,s=new ge,o=new ge,u=new ge,l=new ge,d=new ge,f=new ge;if(e)for(let h=0,m=e.count;h<m;h+=3){let y=e.getX(h+0),M=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,y),a.fromBufferAttribute(t,M),s.fromBufferAttribute(t,g),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,y),u.fromBufferAttribute(i,M),l.fromBufferAttribute(i,g),o.add(d),u.add(d),l.add(d),i.setXYZ(y,o.x,o.y,o.z),i.setXYZ(M,u.x,u.y,u.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,m=t.count;h<m;h+=3)r.fromBufferAttribute(t,h+0),a.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),i.setXYZ(h+0,d.x,d.y,d.z),i.setXYZ(h+1,d.x,d.y,d.z),i.setXYZ(h+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)hr.fromBufferAttribute(e,t),hr.normalize(),e.setXYZ(t,hr.x,hr.y,hr.z)}toNonIndexed(){function e(o,u){let l=o.array,d=o.itemSize,f=o.normalized,h=new l.constructor(u.length*d),m=0,y=0;for(let M=0,g=u.length;M<g;M++){o.isInterleavedBufferAttribute?m=u[M]*o.data.stride+o.offset:m=u[M]*d;for(let v=0;v<d;v++)h[y++]=l[m++]}return new Tr(h,d,f)}if(this.index===null)return mn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let o in r){let u=r[o],l=e(u,i);t.setAttribute(o,l)}let a=this.morphAttributes;for(let o in a){let u=[],l=a[o];for(let d=0,f=l.length;d<f;d++){let h=l[d],m=e(h,i);u.push(m)}t.morphAttributes[o]=u}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,u=s.length;o<u;o++){let l=s[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let u=this.parameters;for(let l in u)u[l]!==void 0&&(e[l]=u[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let u in i){let l=i[u];e.data.attributes[u]=l.toJSON(e.data)}let r={},a=!1;for(let u in this.morphAttributes){let l=this.morphAttributes[u],d=[];for(let f=0,h=l.length;f<h;f++){let m=l[f];d.push(m.toJSON(e.data))}d.length>0&&(r[u]=d,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone());let r=e.attributes;for(let l in r){let d=r[l];this.setAttribute(l,d.clone(t))}let a=e.morphAttributes;for(let l in a){let d=[],f=a[l];for(let h=0,m=f.length;h<m;h++)d.push(f[h].clone(t));this.morphAttributes[l]=d}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let l=0,d=s.length;l<d;l++){let f=s[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};var xh=new ge,Ly=new ge,Dy=new Ln,Kr=class{constructor(e=new ge(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=xh.subVectors(i,t).cross(Ly.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){let r=e.delta(xh),a=this.normal.dot(r);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/a;return i===!0&&(s<0||s>1)?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||Dy.getNormalMatrix(e),r=this.coplanarPoint(xh).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Ny=0,ls=class extends ka{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ny++}),this.uuid=ho(),this.name="",this.type="Material",this.blending=dl,this.side=Va,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Xh,this.blendDst=Yh,this.blendEquation=co,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Rn(0,0,0),this.blendAlpha=0,this.depthFunc=Yo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Zv,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Fu,this.stencilZFail=Fu,this.stencilZPass=Fu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){mn(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){mn(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector2&&i&&i.isVector2||r&&r.isEuler&&i&&i.isEuler||r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,i.blending=this.blending,i.side=this.side,i.shadowSide=this.shadowSide,i.vertexColors=this.vertexColors,i.opacity=this.opacity,i.transparent=this.transparent,i.blendSrc=this.blendSrc,i.blendDst=this.blendDst,i.blendEquation=this.blendEquation,i.blendSrcAlpha=this.blendSrcAlpha,i.blendDstAlpha=this.blendDstAlpha,i.blendEquationAlpha=this.blendEquationAlpha,i.blendColor=this.blendColor.getHex(),i.blendAlpha=this.blendAlpha,i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.clipIntersection=this.clipIntersection,i.clipShadows=this.clipShadows,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,i.stencilWrite=this.stencilWrite,i.polygonOffset=this.polygonOffset,i.polygonOffsetFactor=this.polygonOffsetFactor,i.polygonOffsetUnits=this.polygonOffsetUnits,i.dithering=this.dithering,i.alphaTest=this.alphaTest,i.alphaHash=this.alphaHash,i.alphaToCoverage=this.alphaToCoverage,i.premultipliedAlpha=this.premultipliedAlpha,i.forceSinglePass=this.forceSinglePass,i.allowOverride=this.allowOverride,i.visible=this.visible,i.toneMapped=this.toneMapped,i.name=this.name,this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(i.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(i.clippingPlanes=this.clippingPlanes.map(a=>a.toJSON())),this.rotation!==void 0&&(i.rotation=this.rotation),this.depthPacking!==void 0&&(i.depthPacking=this.depthPacking),this.linewidth!==void 0&&(i.linewidth=this.linewidth),this.linecap!==void 0&&(i.linecap=this.linecap),this.linejoin!==void 0&&(i.linejoin=this.linejoin),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.wireframe!==void 0&&(i.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(i.flatShading=this.flatShading),this.fog!==void 0&&(i.fog=this.fog),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){let s=[];for(let o in a){let u=a[o];delete u.metadata,s.push(u)}return s}if(t){let a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Rn().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(i=>new Kr().fromJSON(i))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new qt().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new qt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=t[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var ss=new ge,_h=new ge,xu=new ge,_u=new ge,jo=class{constructor(e=new ge,t=new ge(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ss)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ss.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ss.copy(this.origin).addScaledVector(this.direction,t),ss.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){_h.copy(e).add(t).multiplyScalar(.5),xu.copy(t).sub(e).normalize(),_u.copy(this.origin).sub(_h);let a=e.distanceTo(t)*.5,s=-this.direction.dot(xu),o=_u.dot(this.direction),u=-_u.dot(xu),l=_u.lengthSq(),d=Math.abs(1-s*s),f,h,m,y;if(d>0)if(f=s*u-o,h=s*o-u,y=a*d,f>=0)if(h>=-y)if(h<=y){let M=1/d;f*=M,h*=M,m=f*(f+s*h+2*o)+h*(s*f+h+2*u)+l}else h=a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;else h=-a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;else h<=-y?(f=Math.max(0,-(-s*a+o)),h=f>0?-a:Math.min(Math.max(-a,-u),a),m=-f*f+h*(h+2*u)+l):h<=y?(f=0,h=Math.min(Math.max(-a,-u),a),m=h*(h+2*u)+l):(f=Math.max(0,-(s*a+o)),h=f>0?a:Math.min(Math.max(-a,-u),a),m=-f*f+h*(h+2*u)+l);else h=s>0?-a:a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(_h).addScaledVector(xu,h),m}intersectSphere(e,t){if(e.radius<0)return null;ss.subVectors(e.center,this.origin);let i=ss.dot(this.direction),r=ss.dot(ss)-i*i,a=e.radius*e.radius;if(r>a)return null;let s=Math.sqrt(a-r),o=i-s,u=i+s;return u<0?null:o<0?this.at(u,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,a,s,o,u,l=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),d>=0?(a=(e.min.y-h.y)*d,s=(e.max.y-h.y)*d):(a=(e.max.y-h.y)*d,s=(e.min.y-h.y)*d),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-h.z)*f,u=(e.max.z-h.z)*f):(o=(e.max.z-h.z)*f,u=(e.min.z-h.z)*f),i>u||o>r)||((o>i||i!==i)&&(i=o),(u<r||r!==r)&&(r=u),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,ss)!==null}intersectTriangle(e,t,i,r,a){let s=this.origin,o=this.direction,u=o.x,l=o.y,d=o.z,f=e.x-s.x,h=e.y-s.y,m=e.z-s.z,y=t.x-s.x,M=t.y-s.y,g=t.z-s.z,v=i.x-s.x,P=i.y-s.y,p=i.z-s.z,_=Math.abs(u),N=Math.abs(l),D=Math.abs(d),B,w,A,z,V,$,T,S,Y,W,se,O;if(_>=N&&_>=D?(A=u,$=f,Y=y,O=v,u>=0?(B=l,w=d,z=h,V=m,T=M,S=g,W=P,se=p):(B=d,w=l,z=m,V=h,T=g,S=M,W=p,se=P)):N>=D?(A=l,$=h,Y=M,O=P,l>=0?(B=d,w=u,z=m,V=f,T=g,S=y,W=p,se=v):(B=u,w=d,z=f,V=m,T=y,S=g,W=v,se=p)):(A=d,$=m,Y=g,O=p,d>=0?(B=u,w=l,z=f,V=h,T=y,S=M,W=v,se=P):(B=l,w=u,z=h,V=f,T=M,S=y,W=P,se=v)),A===0)return null;let U=B/A,H=w/A,ne=1/A,ce=z-U*$,pe=V-H*$,le=T-U*Y,be=S-H*Y,Pe=W-U*O,Q=se-H*O,ie=Pe*be-Q*le,Me=ce*Q-pe*Pe,Le=le*pe-be*ce;if(r){if(ie<0||Me<0||Le<0)return null}else if((ie<0||Me<0||Le<0)&&(ie>0||Me>0||Le>0))return null;let Ee=ie+Me+Le;if(Ee===0)return null;let Xe=ne*(ie*$+Me*Y+Le*O);return(Ee>0?Xe<0:Xe>0)?null:this.at(Xe/Ee,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Vr=class extends ls{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Rn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ha,this.combine=_d,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Qm=new Un,io=new jo,Mu=new za,jm=new ge,Su=new ge,bu=new ge,wu=new ge,Mh=new ge,Tu=new ge,ev=new ge,Eu=new ge,ai=class extends ar{constructor(e=new sr,t=new Vr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){let o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(a&&o){Tu.set(0,0,0);for(let u=0,l=a.length;u<l;u++){let d=o[u],f=a[u];d!==0&&(Mh.fromBufferAttribute(f,e),s?Tu.addScaledVector(Mh,d):Tu.addScaledVector(Mh.sub(t),d))}t.add(Tu)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Mu.copy(i.boundingSphere),Mu.applyMatrix4(a),io.copy(e.ray).recast(e.near),!(Mu.containsPoint(io.origin)===!1&&(io.intersectSphere(Mu,jm)===null||io.origin.distanceToSquared(jm)>(e.far-e.near)**2))&&(Qm.copy(a).invert(),io.copy(e.ray).applyMatrix4(Qm),!(i.boundingBox!==null&&io.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,io)))}_computeIntersections(e,t,i){let r,a=this.geometry,s=this.material,o=a.index,u=a.attributes.position,l=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,h=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,M=h.length;y<M;y++){let g=h[y],v=s[g.materialIndex],P=Math.max(g.start,m.start),p=Math.min(o.count,Math.min(g.start+g.count,m.start+m.count));for(let _=P,N=p;_<N;_+=3){let D=o.getX(_),B=o.getX(_+1),w=o.getX(_+2);r=Au(this,v,e,i,l,d,f,D,B,w),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,m.start),M=Math.min(o.count,m.start+m.count);for(let g=y,v=M;g<v;g+=3){let P=o.getX(g),p=o.getX(g+1),_=o.getX(g+2);r=Au(this,s,e,i,l,d,f,P,p,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(s))for(let y=0,M=h.length;y<M;y++){let g=h[y],v=s[g.materialIndex],P=Math.max(g.start,m.start),p=Math.min(u.count,Math.min(g.start+g.count,m.start+m.count));for(let _=P,N=p;_<N;_+=3){let D=_,B=_+1,w=_+2;r=Au(this,v,e,i,l,d,f,D,B,w),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,m.start),M=Math.min(u.count,m.start+m.count);for(let g=y,v=M;g<v;g+=3){let P=g,p=g+1,_=g+2;r=Au(this,s,e,i,l,d,f,P,p,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};function Uy(n,e,t,i,r,a,s,o){let u;if(e.side===Dr?u=i.intersectTriangle(s,a,r,!0,o):u=i.intersectTriangle(r,a,s,e.side===Va,o),u===null)return null;Eu.copy(o),Eu.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Eu);return l<t.near||l>t.far?null:{distance:l,point:Eu.clone(),object:n}}function Au(n,e,t,i,r,a,s,o,u,l){n.getVertexPosition(o,Su),n.getVertexPosition(u,bu),n.getVertexPosition(l,wu);let d=Uy(n,e,t,i,Su,bu,wu,ev);if(d){let f=new ge;bs.getBarycoord(ev,Su,bu,wu,f),r&&(d.uv=bs.getInterpolatedAttribute(r,o,u,l,f,new qt)),a&&(d.uv1=bs.getInterpolatedAttribute(a,o,u,l,f,new qt)),s&&(d.normal=bs.getInterpolatedAttribute(s,o,u,l,f,new ge),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));let h={a:o,b:u,c:l,normal:new ge,materialIndex:0};bs.getNormal(Su,bu,wu,h.normal),d.face=h,d.barycoord=f}return d}var Wl=new Si,tv=new Si,nv=new Si,Fy=new Si,iv=new Un,Iu=new ge,Sh=new za,rv=new Un,bh=new jo,rc=class extends ai{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ch,this.bindMatrix=new Un,this.bindMatrixInverse=new Un,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Qr),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Iu),this.boundingBox.expandByPoint(Iu)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new za),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Iu),this.boundingSphere.expandByPoint(Iu)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Sh.copy(this.boundingSphere),Sh.applyMatrix4(r),e.ray.intersectsSphere(Sh)!==!1&&(rv.copy(r).invert(),bh.copy(e.ray).applyMatrix4(rv),!(this.boundingBox!==null&&bh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,bh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Si,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Ch?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Xv?this.bindMatrixInverse.copy(this.bindMatrix).invert():mn("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;tv.fromBufferAttribute(r.attributes.skinIndex,e),nv.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(Wl.copy(t),t.set(0,0,0,0)):(Wl.set(...t,1),t.set(0,0,0)),Wl.applyMatrix4(this.bindMatrix);for(let a=0;a<4;a++){let s=nv.getComponent(a);if(s!==0){let o=tv.getComponent(a);iv.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Fy.copy(Wl).applyMatrix4(iv),s)}}return t.isVector4&&(t.w=Wl.w),t.applyMatrix4(this.bindMatrixInverse)}},el=class extends ar{constructor(){super(),this.isBone=!0,this.type="Bone"}},Ts=class extends mr{constructor(e=null,t=1,i=1,r,a,s,o,u,l=Ki,d=Ki,f,h){super(null,s,o,u,l,d,r,a,f,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},av=new Un,Oy=new Un,tl=class n{constructor(e=[],t=[]){this.uuid=ho(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){mn("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Un)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Un;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){let o=e[a]?e[a].matrixWorld:Oy;av.multiplyMatrices(o,t[a]),av.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Ts(t,e,e,ia,na);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let a=e.bones[i],s=t[a];s===void 0&&(mn("Skeleton: No bone found with UUID:",a),s=new el),this.bones.push(s),this.boneInverses.push(new Un().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){let s=t[r];e.bones.push(s.uuid);let o=i[r];e.boneInverses.push(o.toArray())}return e}},ac=class extends Tr{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},zo=new Un,sv=new Un,Cu=[],ov=new Qr,By=new Un,Xl=new ai,Yl=new za,Aa=class extends ai{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ac(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,By)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Qr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,zo),ov.copy(e.boundingBox).applyMatrix4(zo),this.boundingBox.union(ov)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new za),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,zo),Yl.copy(e.boundingSphere).applyMatrix4(zo),this.boundingSphere.union(Yl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,a=i.length+1,s=e*a+1;for(let o=0;o<i.length;o++)i[o]=r[s+o]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Xl.geometry=this.geometry,Xl.material=this.material,Xl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Yl.copy(this.boundingSphere),Yl.applyMatrix4(i),e.ray.intersectsSphere(Yl)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,zo),sv.multiplyMatrices(i,zo),Xl.matrixWorld=sv,Xl.raycast(e,Cu);for(let s=0,o=Cu.length;s<o;s++){let u=Cu[s];u.instanceId=a,u.object=this,t.push(u)}Cu.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new ac(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Ts(new Float32Array(r*this.count),r,this.count,Ed,na));let a=this.morphTexture.source.data.data,s=0;for(let l=0;l<i.length;l++)s+=i[l];let o=this.geometry.morphTargetsRelative?1:1-s,u=r*e;return a[u]=o,a.set(i,u+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},ro=new za,ky=new qt(.5,.5),Ru=new ge,nl=class{constructor(e=new Kr,t=new Kr,i=new Kr,r=new Kr,a=new Kr,s=new Kr){this.planes=[e,t,i,r,a,s]}set(e,t,i,r,a,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Ea,i=!1){let r=this.planes,a=e.elements,s=a[0],o=a[1],u=a[2],l=a[3],d=a[4],f=a[5],h=a[6],m=a[7],y=a[8],M=a[9],g=a[10],v=a[11],P=a[12],p=a[13],_=a[14],N=a[15];if(r[0].setComponents(l-s,m-d,v-y,N-P).normalize(),r[1].setComponents(l+s,m+d,v+y,N+P).normalize(),r[2].setComponents(l+o,m+f,v+M,N+p).normalize(),r[3].setComponents(l-o,m-f,v-M,N-p).normalize(),i)r[4].setComponents(u,h,g,_).normalize(),r[5].setComponents(l-u,m-h,v-g,N-_).normalize();else if(r[4].setComponents(l-u,m-h,v-g,N-_).normalize(),t===Ea)r[5].setComponents(l+u,m+h,v+g,N+_).normalize();else if(t===Zo)r[5].setComponents(u,h,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ro.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ro.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ro)}intersectsSprite(e){ro.center.set(0,0,0);let t=ky.distanceTo(e.center);return ro.radius=.7071067811865476+t,ro.applyMatrix4(e.matrixWorld),this.intersectsSphere(ro)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(Ru.x=r.normal.x>0?e.max.x:e.min.x,Ru.y=r.normal.y>0?e.max.y:e.min.y,Ru.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ru)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var sc=class extends mr{constructor(e=[],t=Rs,i,r,a,s,o,u,l,d){super(e,t,i,r,a,s,o,u,l,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var Es=class extends mr{constructor(e,t,i=Ia,r,a,s,o=Ki,u=Ki,l,d=Ba,f=1){if(d!==Ba&&d!==Ps)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:f};super(h,r,a,s,o,u,d,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new $o(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Ju=class extends Es{constructor(e,t=Ia,i=Rs,r,a,s=Ki,o=Ki,u,l=Ba){let d={width:e,height:e,depth:1},f=[d,d,d,d,d,d];super(e,e,t,i,r,a,s,o,u,l),this.image=f,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},oc=class extends mr{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Lr=class n extends sr{constructor(e=1,t=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};let o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);let u=[],l=[],d=[],f=[],h=0,m=0;y("z","y","x",-1,-1,i,t,e,s,a,0),y("z","y","x",1,-1,i,t,-e,s,a,1),y("x","z","y",1,1,e,i,t,r,s,2),y("x","z","y",1,-1,e,i,-t,r,s,3),y("x","y","z",1,-1,e,t,i,r,a,4),y("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(u),this.setAttribute("position",new fi(l,3)),this.setAttribute("normal",new fi(d,3)),this.setAttribute("uv",new fi(f,2));function y(M,g,v,P,p,_,N,D,B,w,A){let z=_/B,V=N/w,$=_/2,T=N/2,S=D/2,Y=B+1,W=w+1,se=0,O=0,U=new ge;for(let H=0;H<W;H++){let ne=H*V-T;for(let ce=0;ce<Y;ce++){let pe=ce*z-$;U[M]=pe*P,U[g]=ne*p,U[v]=S,l.push(U.x,U.y,U.z),U[M]=0,U[g]=0,U[v]=D>0?1:-1,d.push(U.x,U.y,U.z),f.push(ce/B),f.push(1-H/w),se+=1}}for(let H=0;H<w;H++)for(let ne=0;ne<B;ne++){let ce=h+ne+Y*H,pe=h+ne+Y*(H+1),le=h+(ne+1)+Y*(H+1),be=h+(ne+1)+Y*H;u.push(ce,pe,be),u.push(pe,le,be),O+=6}o.addGroup(m,O,A),m+=O,h+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var il=class n extends sr{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let a=[],s=[],o=[],u=[],l=new ge,d=new qt;s.push(0,0,0),o.push(0,0,1),u.push(.5,.5);for(let f=0,h=3;f<=t;f++,h+=3){let m=i+f/t*r;l.x=e*Math.cos(m),l.y=e*Math.sin(m),s.push(l.x,l.y,l.z),o.push(0,0,1),d.x=(s[h]/e+1)/2,d.y=(s[h+1]/e+1)/2,u.push(d.x,d.y)}for(let f=1;f<=t;f++)a.push(f,f+1,0);this.setIndex(a),this.setAttribute("position",new fi(s,3)),this.setAttribute("normal",new fi(o,3)),this.setAttribute("uv",new fi(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},so=class n extends sr{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,o=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:o,thetaLength:u};let l=this;r=Math.floor(r),a=Math.floor(a);let d=[],f=[],h=[],m=[],y=0,M=[],g=i/2,v=0;P(),s===!1&&(e>0&&p(!0),t>0&&p(!1)),this.setIndex(d),this.setAttribute("position",new fi(f,3)),this.setAttribute("normal",new fi(h,3)),this.setAttribute("uv",new fi(m,2));function P(){let _=new ge,N=new ge,D=0,B=(t-e)/i;for(let w=0;w<=a;w++){let A=[],z=w/a,V=z*(t-e)+e;for(let $=0;$<=r;$++){let T=$/r,S=T*u+o,Y=Math.sin(S),W=Math.cos(S);N.x=V*Y,N.y=-z*i+g,N.z=V*W,f.push(N.x,N.y,N.z),_.set(Y,B,W).normalize(),h.push(_.x,_.y,_.z),m.push(T,1-z),A.push(y++)}M.push(A)}for(let w=0;w<r;w++)for(let A=0;A<a;A++){let z=M[A][w],V=M[A+1][w],$=M[A+1][w+1],T=M[A][w+1];(e>0||A!==0)&&(d.push(z,V,T),D+=3),(t>0||A!==a-1)&&(d.push(V,$,T),D+=3)}l.addGroup(v,D,0),v+=D}function p(_){let N=y,D=new qt,B=new ge,w=0,A=_===!0?e:t,z=_===!0?1:-1;for(let $=1;$<=r;$++)f.push(0,g*z,0),h.push(0,z,0),m.push(.5,.5),y++;let V=y;for(let $=0;$<=r;$++){let S=$/r*u+o,Y=Math.cos(S),W=Math.sin(S);B.x=A*W,B.y=g*z,B.z=A*Y,f.push(B.x,B.y,B.z),h.push(0,z,0),D.x=Y*.5+.5,D.y=W*.5*z+.5,m.push(D.x,D.y),y++}for(let $=0;$<r;$++){let T=N+$,S=V+$;_===!0?d.push(S,S+1,T):d.push(S+1,S,T),w+=3}l.addGroup(v,w,_===!0?1:2),v+=w}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};var jr=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){mn("Curve: .getPoint() not implemented.")}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let o=0,u=a-1,l;for(;o<=u;)if(r=Math.floor(o+(u-o)/2),l=i[r]-s,l<0)o=r+1;else if(l>0)u=r-1;else{u=r;break}if(r=u,i[r]===s)return r/(a-1);let d=i[r],h=i[r+1]-d,m=(s-d)/h;return(r+m)/(a-1)}getTangent(e,t){let r=e-1e-4,a=e+1e-4;r<0&&(r=0),a>1&&(a=1);let s=this.getPoint(r),o=this.getPoint(a),u=t||(s.isVector2?new qt:new ge);return u.copy(o).sub(s).normalize(),u}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){let i=new ge,r=[],a=[],s=[],o=new ge,u=new Un;for(let m=0;m<=e;m++){let y=m/e;r[m]=this.getTangentAt(y,new ge)}a[0]=new ge,s[0]=new ge;let l=Number.MAX_VALUE,d=Math.abs(r[0].x),f=Math.abs(r[0].y),h=Math.abs(r[0].z);d<=l&&(l=d,i.set(1,0,0)),f<=l&&(l=f,i.set(0,1,0)),h<=l&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],o),s[0].crossVectors(r[0],a[0]);for(let m=1;m<=e;m++){if(a[m]=a[m-1].clone(),s[m]=s[m-1].clone(),o.crossVectors(r[m-1],r[m]),o.length()>Number.EPSILON){o.normalize();let y=Math.acos(Kn(r[m-1].dot(r[m]),-1,1));a[m].applyMatrix4(u.makeRotationAxis(o,y))}s[m].crossVectors(r[m],a[m])}if(t===!0){let m=Math.acos(Kn(a[0].dot(a[e]),-1,1));m/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(m=-m);for(let y=1;y<=e;y++)a[y].applyMatrix4(u.makeRotationAxis(r[y],m*y)),s[y].crossVectors(r[y],a[y])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},rl=class extends jr{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,o=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=o,this.aRotation=u}getPoint(e,t=new qt){let i=t,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let o=this.aStartAngle+e*a,u=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let d=Math.cos(this.aRotation),f=Math.sin(this.aRotation),h=u-this.aX,m=l-this.aY;u=h*d-m*f+this.aX,l=h*f+m*d+this.aY}return i.set(u,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},$u=class extends rl{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function op(){let n=0,e=0,t=0,i=0;function r(a,s,o,u){n=a,e=o,t=-3*a+3*s-2*o-u,i=2*a-2*s+o+u}return{initCatmullRom:function(a,s,o,u,l){r(s,o,l*(o-a),l*(u-s))},initNonuniformCatmullRom:function(a,s,o,u,l,d,f){let h=(s-a)/l-(o-a)/(l+d)+(o-s)/d,m=(o-s)/d-(u-s)/(d+f)+(u-o)/f;h*=d,m*=d,r(s,o,h,m)},calc:function(a){let s=a*a,o=s*a;return n+e*a+t*s+i*o}}}var lv=new ge,cv=new ge,wh=new op,Th=new op,Eh=new op,Ku=class extends jr{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new ge){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,o=Math.floor(s),u=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:u===0&&o===a-1&&(o=a-2,u=1);let l,d;this.closed||o>0?l=r[(o-1)%a]:(cv.subVectors(r[0],r[1]).add(r[0]),l=cv);let f=r[o%a],h=r[(o+1)%a];if(this.closed||o+2<a?d=r[(o+2)%a]:(lv.subVectors(r[a-1],r[a-2]).add(r[a-1]),d=lv),this.curveType==="centripetal"||this.curveType==="chordal"){let m=this.curveType==="chordal"?.5:.25,y=Math.pow(l.distanceToSquared(f),m),M=Math.pow(f.distanceToSquared(h),m),g=Math.pow(h.distanceToSquared(d),m);M<1e-4&&(M=1),y<1e-4&&(y=M),g<1e-4&&(g=M),wh.initNonuniformCatmullRom(l.x,f.x,h.x,d.x,y,M,g),Th.initNonuniformCatmullRom(l.y,f.y,h.y,d.y,y,M,g),Eh.initNonuniformCatmullRom(l.z,f.z,h.z,d.z,y,M,g)}else this.curveType==="catmullrom"&&(wh.initCatmullRom(l.x,f.x,h.x,d.x,this.tension),Th.initCatmullRom(l.y,f.y,h.y,d.y,this.tension),Eh.initCatmullRom(l.z,f.z,h.z,d.z,this.tension));return i.set(wh.calc(u),Th.calc(u),Eh.calc(u)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ge().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function uv(n,e,t,i,r){let a=(i-e)*.5,s=(r-t)*.5,o=n*n,u=n*o;return(2*t-2*i+a+s)*u+(-3*t+3*i-2*a-s)*o+a*n+t}function zy(n,e){let t=1-n;return t*t*e}function Vy(n,e){return 2*(1-n)*n*e}function Gy(n,e){return n*n*e}function Zl(n,e,t,i){return zy(n,e)+Vy(n,t)+Gy(n,i)}function Hy(n,e){let t=1-n;return t*t*t*e}function Wy(n,e){let t=1-n;return 3*t*t*n*e}function Xy(n,e){return 3*(1-n)*n*n*e}function Yy(n,e){return n*n*n*e}function Jl(n,e,t,i,r){return Hy(n,e)+Wy(n,t)+Xy(n,i)+Yy(n,r)}var lc=class extends jr{constructor(e=new qt,t=new qt,i=new qt,r=new qt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new qt){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(Jl(e,r.x,a.x,s.x,o.x),Jl(e,r.y,a.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Qu=class extends jr{constructor(e=new ge,t=new ge,i=new ge,r=new ge){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ge){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(Jl(e,r.x,a.x,s.x,o.x),Jl(e,r.y,a.y,s.y,o.y),Jl(e,r.z,a.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},cc=class extends jr{constructor(e=new qt,t=new qt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new qt){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new qt){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ju=class extends jr{constructor(e=new ge,t=new ge){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new ge){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ge){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},uc=class extends jr{constructor(e=new qt,t=new qt,i=new qt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new qt){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(Zl(e,r.x,a.x,s.x),Zl(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ed=class extends jr{constructor(e=new ge,t=new ge,i=new ge){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ge){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(Zl(e,r.x,a.x,s.x),Zl(e,r.y,a.y,s.y),Zl(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},dc=class extends jr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new qt){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),o=a-s,u=r[s===0?s:s-1],l=r[s],d=r[s>r.length-2?r.length-1:s+1],f=r[s>r.length-3?r.length-1:s+2];return i.set(uv(o,u.x,l.x,d.x,f.x),uv(o,u.y,l.y,d.y,f.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new qt().fromArray(r))}return this}},dv=Object.freeze({__proto__:null,ArcCurve:$u,CatmullRomCurve3:Ku,CubicBezierCurve:lc,CubicBezierCurve3:Qu,EllipseCurve:rl,LineCurve:cc,LineCurve3:ju,QuadraticBezierCurve:uc,QuadraticBezierCurve3:ed,SplineCurve:dc}),td=class extends jr{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new dv[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,o=this.curves[a],u=o.getLength(),l=u===0?0:1-s/u;return o.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],o=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,u=s.getPoints(o);for(let l=0;l<u.length;l++){let d=u[l];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new dv[r.type]().fromJSON(r))}return this}},oo=class extends td{constructor(e){super(),this.type="Path",this.currentPoint=new qt,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new cc(this.currentPoint.clone(),new qt(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new uc(this.currentPoint.clone(),new qt(e,t),new qt(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let o=new lc(this.currentPoint.clone(),new qt(e,t),new qt(i,r),new qt(a,s));return this.curves.push(o),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new dc(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let o=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+o,t+u,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,o,u){let l=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+l,t+d,i,r,a,s,o,u),this}absellipse(e,t,i,r,a,s,o,u){let l=new rl(e,t,i,r,a,s,o,u);if(this.curves.length>0){let f=l.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(l);let d=l.getPoint(1);return this.currentPoint.copy(d),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},al=class extends oo{constructor(e){super(e),this.uuid=ho(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new oo().fromJSON(r))}return this}};function qy(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,a=o0(n,0,r,t,!0),s=[];if(!a||a.next===a.prev)return s;let o,u,l;if(i&&(a=Qy(n,e,a,t)),n.length>80*t){o=n[0],u=n[1];let d=o,f=u;for(let h=t;h<r;h+=t){let m=n[h],y=n[h+1];m<o&&(o=m),y<u&&(u=y),m>d&&(d=m),y>f&&(f=y)}l=Math.max(d-o,f-u),l=l!==0?32767/l:0}return fc(a,s,t,o,u,l,0),s}function o0(n,e,t,i,r){let a;if(r===cx(n,e,t,i)>0)for(let s=e;s<t;s+=i)a=fv(s/i|0,n[s],n[s+1],a);else for(let s=t-i;s>=e;s-=i)a=fv(s/i|0,n[s],n[s+1],a);return a&&sl(a,a.next)&&(pc(a),a=a.next),a}function lo(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(sl(t,t.next)||Bi(t.prev,t,t.next)===0)){if(pc(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function fc(n,e,t,i,r,a,s){if(!n)return;!s&&a&&ix(n,i,r,a);let o=n;for(;n.prev!==n.next;){let u=n.prev,l=n.next;if(a?Jy(n,i,r,a):Zy(n)){e.push(u.i,n.i,l.i),pc(n),n=l.next,o=l.next;continue}if(n=l,n===o){s?s===1?(n=$y(lo(n),e),fc(n,e,t,i,r,a,2)):s===2&&Ky(n,e,t,i,r,a):fc(lo(n),e,t,i,r,a,1);break}}}function Zy(n){let e=n.prev,t=n,i=n.next;if(Bi(e,t,i)>=0)return!1;let r=e.x,a=t.x,s=i.x,o=e.y,u=t.y,l=i.y,d=Math.min(r,a,s),f=Math.min(o,u,l),h=Math.max(r,a,s),m=Math.max(o,u,l),y=i.next;for(;y!==e;){if(y.x>=d&&y.x<=h&&y.y>=f&&y.y<=m&&ql(r,o,a,u,s,l,y.x,y.y)&&Bi(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function Jy(n,e,t,i){let r=n.prev,a=n,s=n.next;if(Bi(r,a,s)>=0)return!1;let o=r.x,u=a.x,l=s.x,d=r.y,f=a.y,h=s.y,m=Math.min(o,u,l),y=Math.min(d,f,h),M=Math.max(o,u,l),g=Math.max(d,f,h),v=Nh(m,y,e,t,i),P=Nh(M,g,e,t,i),p=n.prevZ,_=n.nextZ;for(;p&&p.z>=v&&_&&_.z<=P;){if(p.x>=m&&p.x<=M&&p.y>=y&&p.y<=g&&p!==r&&p!==s&&ql(o,d,u,f,l,h,p.x,p.y)&&Bi(p.prev,p,p.next)>=0||(p=p.prevZ,_.x>=m&&_.x<=M&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&ql(o,d,u,f,l,h,_.x,_.y)&&Bi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;p&&p.z>=v;){if(p.x>=m&&p.x<=M&&p.y>=y&&p.y<=g&&p!==r&&p!==s&&ql(o,d,u,f,l,h,p.x,p.y)&&Bi(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;_&&_.z<=P;){if(_.x>=m&&_.x<=M&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&ql(o,d,u,f,l,h,_.x,_.y)&&Bi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function $y(n,e){let t=n;do{let i=t.prev,r=t.next.next;!sl(i,r)&&c0(i,t,t.next,r)&&hc(i,r)&&hc(r,i)&&(e.push(i.i,t.i,r.i),pc(t),pc(t.next),t=n=r),t=t.next}while(t!==n);return lo(t)}function Ky(n,e,t,i,r,a){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&sx(s,o)){let u=u0(s,o);s=lo(s,s.next),u=lo(u,u.next),fc(s,e,t,i,r,a,0),fc(u,e,t,i,r,a,0);return}o=o.next}s=s.next}while(s!==n)}function Qy(n,e,t,i){let r=[];for(let a=0,s=e.length;a<s;a++){let o=e[a]*i,u=a<s-1?e[a+1]*i:n.length,l=o0(n,o,u,i,!1);l===l.next&&(l.steiner=!0),r.push(ax(l))}r.sort(jy);for(let a=0;a<r.length;a++)t=ex(r[a],t);return t}function jy(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){let i=(n.next.y-n.y)/(n.next.x-n.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=i-r}return t}function ex(n,e){let t=tx(n,e);if(!t)return e;let i=u0(t,n);return lo(i,i.next),lo(t,t.next)}function tx(n,e){let t=e,i=n.x,r=n.y,a=-1/0,s;if(sl(n,t))return t;do{if(sl(n,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){let f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=i&&f>a&&(a=f,s=t.x<t.next.x?t:t.next,f===i))return s}t=t.next}while(t!==e);if(!s)return null;let o=s,u=s.x,l=s.y,d=1/0;t=s;do{if(i>=t.x&&t.x>=u&&i!==t.x&&l0(r<l?i:a,r,u,l,r<l?a:i,r,t.x,t.y)){let f=Math.abs(r-t.y)/(i-t.x);hc(t,n)&&(f<d||f===d&&(t.x>s.x||t.x===s.x&&nx(s,t)))&&(s=t,d=f)}t=t.next}while(t!==o);return s}function nx(n,e){return Bi(n.prev,n,e.prev)<0&&Bi(e.next,n,n.next)<0}function ix(n,e,t,i){let r=n;do r.z===0&&(r.z=Nh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,rx(r)}function rx(n){let e,t=1;do{let i=n,r;n=null;let a=null;for(e=0;i;){e++;let s=i,o=0;for(let l=0;l<t&&(o++,s=s.nextZ,!!s);l++);let u=t;for(;o>0||u>0&&s;)o!==0&&(u===0||!s||i.z<=s.z)?(r=i,i=i.nextZ,o--):(r=s,s=s.nextZ,u--),a?a.nextZ=r:n=r,r.prevZ=a,a=r;i=s}a.nextZ=null,t*=2}while(e>1);return n}function Nh(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function ax(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function l0(n,e,t,i,r,a,s,o){return(r-s)*(e-o)>=(n-s)*(a-o)&&(n-s)*(i-o)>=(t-s)*(e-o)&&(t-s)*(a-o)>=(r-s)*(i-o)}function ql(n,e,t,i,r,a,s,o){return!(n===s&&e===o)&&l0(n,e,t,i,r,a,s,o)}function sx(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!ox(n,e)&&(hc(n,e)&&hc(e,n)&&lx(n,e)&&(Bi(n.prev,n,e.prev)||Bi(n,e.prev,e))||sl(n,e)&&Bi(n.prev,n,n.next)>0&&Bi(e.prev,e,e.next)>0)}function Bi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function sl(n,e){return n.x===e.x&&n.y===e.y}function c0(n,e,t,i){let r=Lu(Bi(n,e,t)),a=Lu(Bi(n,e,i)),s=Lu(Bi(t,i,n)),o=Lu(Bi(t,i,e));return!!(r!==a&&s!==o||r===0&&Pu(n,t,e)||a===0&&Pu(n,i,e)||s===0&&Pu(t,n,i)||o===0&&Pu(t,e,i))}function Pu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Lu(n){return n>0?1:n<0?-1:0}function ox(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&c0(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function hc(n,e){return Bi(n.prev,n,n.next)<0?Bi(n,e,n.next)>=0&&Bi(n,n.prev,e)>=0:Bi(n,e,n.prev)<0||Bi(n,n.next,e)<0}function lx(n,e){let t=n,i=!1,r=(n.x+e.x)/2,a=(n.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&r<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function u0(n,e){let t=Uh(n.i,n.x,n.y),i=Uh(e.i,e.x,e.y),r=n.next,a=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,a.next=i,i.prev=a,i}function fv(n,e,t,i){let r=Uh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function pc(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Uh(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function cx(n,e,t,i){let r=0;for(let a=e,s=t-i;a<t;a+=i)r+=(n[s]-n[a])*(n[a+1]+n[s+1]),s=a;return r}var Fh=class{static triangulate(e,t,i=2){return qy(e,t,i)}},Xo=class n{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];hv(e),pv(i,e);let s=e.length;t.forEach(hv);for(let u=0;u<t.length;u++)r.push(s),s+=t[u].length,pv(i,t[u]);let o=Fh.triangulate(i,r);for(let u=0;u<o.length;u+=3)a.push(o.slice(u,u+3));return a}};function hv(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function pv(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var mc=class n extends sr{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let a=e/2,s=t/2,o=Math.floor(i),u=Math.floor(r),l=o+1,d=u+1,f=e/o,h=t/u,m=[],y=[],M=[],g=[];for(let v=0;v<d;v++){let P=v*h-s;for(let p=0;p<l;p++){let _=p*f-a;y.push(_,-P,0),M.push(0,0,1),g.push(p/o),g.push(1-v/u)}}for(let v=0;v<u;v++)for(let P=0;P<o;P++){let p=P+l*v,_=P+l*(v+1),N=P+1+l*(v+1),D=P+1+l*v;m.push(p,_,D),m.push(_,N,D)}this.setIndex(m),this.setAttribute("position",new fi(y,3)),this.setAttribute("normal",new fi(M,3)),this.setAttribute("uv",new fi(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},ol=class n extends sr{constructor(e=.5,t=1,i=32,r=1,a=0,s=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:a,thetaLength:s},i=Math.max(3,i),r=Math.max(1,r);let o=[],u=[],l=[],d=[],f=e,h=(t-e)/r,m=new ge,y=new qt;for(let M=0;M<=r;M++){for(let g=0;g<=i;g++){let v=a+g/i*s;m.x=f*Math.cos(v),m.y=f*Math.sin(v),u.push(m.x,m.y,m.z),l.push(0,0,1),y.x=(m.x/t+1)/2,y.y=(m.y/t+1)/2,d.push(y.x,y.y)}f+=h}for(let M=0;M<r;M++){let g=M*(i+1);for(let v=0;v<i;v++){let P=v+g,p=P,_=P+i+1,N=P+i+2,D=P+1;o.push(p,_,D),o.push(_,N,D)}}this.setIndex(o),this.setAttribute("position",new fi(u,3)),this.setAttribute("normal",new fi(l,3)),this.setAttribute("uv",new fi(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},vc=class n extends sr{constructor(e=new al([new qt(0,.5),new qt(-.5,-.5),new qt(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],a=[],s=[],o=0,u=0;if(Array.isArray(e)===!1)l(e);else for(let d=0;d<e.length;d++)l(e[d]),this.addGroup(o,u,d),o+=u,u=0;this.setIndex(i),this.setAttribute("position",new fi(r,3)),this.setAttribute("normal",new fi(a,3)),this.setAttribute("uv",new fi(s,2));function l(d){let f=r.length/3,h=d.extractPoints(t),m=h.shape,y=h.holes;Xo.isClockWise(m)===!1&&(m=m.reverse());for(let g=0,v=y.length;g<v;g++){let P=y[g];Xo.isClockWise(P)===!0&&(y[g]=P.reverse())}let M=Xo.triangulateShape(m,y);for(let g=0,v=y.length;g<v;g++){let P=y[g];m=m.concat(P)}for(let g=0,v=m.length;g<v;g++){let P=m[g];r.push(P.x,P.y,0),a.push(0,0,1),s.push(P.x,P.y)}for(let g=0,v=M.length;g<v;g++){let P=M[g],p=P[0]+f,_=P[1]+f,N=P[2]+f;i.push(p,_,N),u+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return ux(t,e)}static fromJSON(e,t){let i=[];for(let r=0,a=e.shapes.length;r<a;r++){let s=t[e.shapes[r]];i.push(s)}return new n(i,e.curveSegments)}};function ux(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}var cs=class n extends sr{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let u=Math.min(s+o,Math.PI),l=0,d=[],f=new ge,h=new ge,m=[],y=[],M=[],g=[];for(let v=0;v<=i;v++){let P=[],p=v/i,_=s+p*o,N=e*Math.cos(_),D=Math.sqrt(e*e-N*N),B=0;v===0&&s===0?B=.5/t:v===i&&u===Math.PI&&(B=-.5/t);for(let w=0;w<=t;w++){let A=w/t,z=r+A*a;f.x=-D*Math.cos(z),f.y=N,f.z=D*Math.sin(z),y.push(f.x,f.y,f.z),h.copy(f).normalize(),M.push(h.x,h.y,h.z),g.push(A+B,1-p),P.push(l++)}d.push(P)}for(let v=0;v<i;v++)for(let P=0;P<t;P++){let p=d[v][P+1],_=d[v][P],N=d[v+1][P],D=d[v+1][P+1];(v!==0||s>0)&&m.push(p,_,D),(v!==i-1||u<Math.PI)&&m.push(_,N,D)}this.setIndex(m),this.setAttribute("position",new fi(y,3)),this.setAttribute("normal",new fi(M,3)),this.setAttribute("uv",new fi(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};function po(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];if(mv(r))r.isRenderTargetTexture?(mn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone();else if(Array.isArray(r))if(mv(r[0])){let a=[];for(let s=0,o=r.length;s<o;s++)a[s]=r[s].clone();e[t][i]=a}else e[t][i]=r.slice();else e[t][i]=r}}return e}function Ar(n){let e={};for(let t=0;t<n.length;t++){let i=po(n[t]);for(let r in i)e[r]=i[r]}return e}function mv(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function dx(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function lp(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:jn.workingColorSpace}var d0={clone:po,merge:Ar},fx=`void main() {
|
|
1
|
+
var ToraNative=(()=>{var ih=Object.defineProperty;var Ey=Object.getOwnPropertyDescriptor;var Iy=Object.getOwnPropertyNames;var Cy=Object.prototype.hasOwnProperty;var Ry=(n,e)=>{for(var t in e)ih(n,t,{get:e[t],enumerable:!0})},Py=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Iy(e))!Cy.call(n,r)&&r!==t&&ih(n,r,{get:()=>e[r],enumerable:!(i=Ey(e,r))||i.enumerable});return n};var Ly=n=>Py(ih({},"__esModule",{value:!0}),n);var _1={};Ry(_1,{computeSafeArea:()=>im,createNetworkBridge:()=>kg,layoutStandardText:()=>zg,mountNative:()=>x1});var Pm=function(n,e){if(!n)throw Error(e)},Ca=function(){return[1,0,0,1,0,0]};function rh(n){return Pm(Array.isArray(n)&&n.length===6&&n.every(Number.isFinite),"E_SCENE_MATRIX"),n}function Io(n,e){return rh(n),rh(e),[n[0]*e[0]+n[2]*e[1],n[1]*e[0]+n[3]*e[1],n[0]*e[2]+n[2]*e[3],n[1]*e[2]+n[3]*e[3],n[0]*e[4]+n[2]*e[5]+n[4],n[1]*e[4]+n[3]*e[5]+n[5]]}function Dr(n){rh(n);var e=n[0]*n[3]-n[1]*n[2];return Pm(Math.abs(e)>1e-12,"E_SCENE_SINGULAR_TRANSFORM"),[n[3]/e,-n[1]/e,-n[2]/e,n[0]/e,(n[2]*n[5]-n[3]*n[4])/e,(n[1]*n[4]-n[0]*n[5])/e]}var sh=function(){return sh=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},sh.apply(this,arguments)},Xa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},to=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},ah=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Lm(n){var e=n.rows,t=n.columns,i=n.seed,r=n.slots,a=n.paint,s=n.onEvent,o=r.map(function(le){return le.group}),u=to([],Xa(new Set(o)),!1),l=to([],Xa(o),!1),d=i,f="idle",h=0,m,y,M=[],g=[],v=0,L=0,p=0,_,N,D=function(le,Te){return le*t+Te},V=function(le){return Math.floor(le/t)},w=function(le){return le%t},I=function(){return d=Math.imul(d,1664525)+1013904223>>>0,d/4294967296};function G(le){for(var Te=new Set,De=0;De<e;De++)for(var oe=0;oe<t;oe++){var ee=D(De,oe),be=le[ee];if(oe+2<t&&be===le[ee+1]&&be===le[ee+2])for(var Be=0;Be<3;Be++)Te.add(ee+Be);if(De+2<e&&be===le[ee+t]&&be===le[ee+t*2])for(var Be=0;Be<3;Be++)Te.add(ee+t*Be)}return to([],Xa(Te),!1)}function H(le,Te){var De;if(l[le]===l[Te])return!1;var oe=to([],Xa(l),!1);return De=Xa([oe[Te],oe[le]],2),oe[le]=De[0],oe[Te]=De[1],G(oe).some(function(ee){return ee===le||ee===Te})}function Q(){for(var le=[],Te=0;Te<l.length;Te++)w(Te)+1<t&&H(Te,Te+1)&&le.push({from:r[Te].id,to:r[Te+1].id}),V(Te)+1<e&&H(Te,Te+t)&&le.push({from:r[Te].id,to:r[Te+t].id});return le}function T(){for(var le=0;le<64;le++){l=[];for(var Te=function(oe){var ee=u.filter(function(be){return!(w(oe)>=2&&l[oe-1]===be&&l[oe-2]===be)&&!(V(oe)>=2&&l[oe-t]===be&&l[oe-t*2]===be)});l.push(ee[Math.floor(I()*ee.length)])},De=0;De<r.length;De++)Te(De);if(Q().length)return}l=r.map(function(oe,ee){return u[(V(ee)*2+w(ee))%3]}),l[0]=u[0],l[1]=u[1],l[2]=u[0],l[t+1]=u[0]}function S(){for(var le=0;le<r.length;le++)a(le,l[le],{})}function Z(){d=i,l=to([],Xa(o),!1),f="idle",h=0,m=void 0,y=void 0,M=[],g=[],v=0,L=0,p=0,_=void 0,N=void 0,(G(l).length||!Q().length)&&T(),S()}function q(le,Te){if(f!=="idle")return!1;var De=r.findIndex(function(ee){return ee.id===le}),oe=r.findIndex(function(ee){return ee.id===Te});return De<0||oe<0||Math.abs(V(De)-V(oe))+Math.abs(w(De)-w(oe))!==1?!1:(m=void 0,_=void 0,S(),y=[De,oe],f="swap",h=0,!0)}function se(le){if(f==="idle"){if(m===le){m=void 0;return}if(!(m&&q(m,le)))return m=le,m}}function F(){M=G(l),p+=M.length,N={group:l[M[0]],from:r[M[0]].id,count:M.length},s("matchClear"),f="clear",h=0}function z(){var le=new Set(M),Te=to([],Xa(l),!1);g=[];for(var De=0;De<t;De++){for(var oe=[],ee=e-1;ee>=0;ee--)le.has(D(ee,De))||oe.push(D(ee,De));for(var be=0,ee=e-1;ee>=0;ee--){var Be=D(ee,De),Re=oe[e-1-ee];Re!==void 0?(Te[Be]=l[Re],g.push({cell:Be,from:Re,offsetRows:0})):(Te[Be]=u[Math.floor(I()*u.length)],g.push({cell:Be,from:Be,offsetRows:-(ee+1+be++)}))}}l=Te,f="fall",h=0}function Y(){if(G(l).length&&v<3){v++,F();return}(G(l).length||!Q().length)&&T(),S(),f="idle",h=0,y=void 0,M=[],g=[],L++,s("validMatch")}function $(le){var Te,De,oe,ee,be,Be,Re;if(f==="idle"){if(_){_.elapsed+=le;var Ye=1+.065*Math.sin(Math.min(1,_.elapsed/.8)*Math.PI*4),nt=function(Xe){a(r.findIndex(function(qe){return qe.id===Xe}),l[r.findIndex(function(qe){return qe.id===Xe})],{scale:Ye})};try{for(var Ge=ah(_.ids),$e=Ge.next();!$e.done;$e=Ge.next()){var mt=$e.value;nt(mt)}}catch(Xe){Te={error:Xe}}finally{try{$e&&!$e.done&&(De=Ge.return)&&De.call(Ge)}finally{if(Te)throw Te.error}}_.elapsed>=.8&&(_=void 0,S())}return}if(h+=le,f==="swap"||f==="reverse"){var at=Math.min(1,h/.14),Ve=at*at*(3-2*at),Yt=Xa(y,2),st=Yt[0],Dt=Yt[1];if(a(st,l[st],{from:Dt,progress:f==="swap"?Ve:1-Ve}),a(Dt,l[Dt],{from:st,progress:f==="swap"?Ve:1-Ve}),at<1)return;if(f==="reverse"){S(),f="idle",y=void 0,s("invalidMatch");return}if(!H(st,Dt)){f="reverse",h=0;return}oe=Xa([l[Dt],l[st]],2),l[st]=oe[0],l[Dt]=oe[1],S(),F();return}if(f==="clear"){var on=Math.min(1,h/.18),Ye=on<.22?1+on*.45:Math.max(.05,1.1*(1-on)/.78);try{for(var de=ah(M),wn=de.next();!wn.done;wn=de.next()){var Mn=wn.value;a(Mn,l[Mn],{scale:Ye,opacity:1-on})}}catch(qe){ee={error:qe}}finally{try{wn&&!wn.done&&(be=de.return)&&be.call(de)}finally{if(ee)throw ee.error}}on===1&&z();return}var K=Math.min(1,h/.25),b=1-Math.pow(1-K,3);try{for(var ne=ah(g),Se=ne.next();!Se.done;Se=ne.next()){var Ie=Se.value;a(Ie.cell,l[Ie.cell],{from:Ie.from,offsetRows:Ie.offsetRows,progress:1-b})}}catch(Xe){Be={error:Xe}}finally{try{Se&&!Se.done&&(Re=ne.return)&&Re.call(ne)}finally{if(Be)throw Be.error}}K===1&&Y()}function he(){if(f==="idle"){m=void 0;var le=Q()[0];le&&(_={ids:[le.from,le.to],elapsed:0})}}function pe(){var le;return{phase:f,busy:f!=="idle",selected:m??null,moves:L,cleared:p,groups:to([],Xa(l),!1),legalMoves:f==="idle"?Q():[],hint:(le=_?.ids)!==null&&le!==void 0?le:[],lastMatch:N?sh({},N):null}}return{reset:Z,select:se,swap:q,tick:$,showHint:he,snapshot:pe,cancelSelection:function(){m=void 0,_&&(_=void 0,S())}}}var mu=function(){return mu=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},mu.apply(this,arguments)},Dm=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Dy=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Nm=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Um(){var n=new Map,e=new Map,t=function(r){var a,s,o=e.get(r);o!==void 0&&((a=n.get(o))===null||a===void 0||a.delete(r),((s=n.get(o))===null||s===void 0?void 0:s.size)===0&&n.delete(o)),e.delete(r)},i=function(r,a){t(r),a!=null&&(n.has(a)||n.set(a,new Set),n.get(a).add(r),e.set(r,a))};return{occupants:n,itemZone:e,release:t,place:i,clear:function(){n.clear(),e.clear()},items:function(r){var a;return Dy([],Dm((a=n.get(r))!==null&&a!==void 0?a:[]),!1).sort()},zoneOf:function(r){return e.get(r)},snapshot:function(){return{itemZone:Object.fromEntries(e)}}}}function vu(n){var e,t,i=n.itemId,r=n.tag,a=r===void 0?"":r,s=n.zones,o=n.occupancy,u=s.filter(function(y){var M,g,v;return y.id!==i&&(((g=(M=y.acceptTags)===null||M===void 0?void 0:M.length)!==null&&g!==void 0?g:0)===0||((v=y.acceptTags)===null||v===void 0?void 0:v.includes(a)))});u.sort(function(y,M){return Number(M.itemTarget)-Number(y.itemTarget)||M.paintOrder-y.paintOrder||y.distance-M.distance||y.id.localeCompare(M.id)});try{for(var l=Nm(u),d=l.next();!d.done;d=l.next()){var f=d.value,h=o.items(f.id).filter(function(y){return y!==i}),m=f.capacity>0&&h.length>=f.capacity;return f.snapMode==="reject"?{kind:"reject",zone:f,occupantId:h[0]}:m?f.onOccupied==="emit"?{kind:"emit",zone:f,occupantId:h[0]}:f.onOccupied==="swap"&&h.length?{kind:"swap",zone:f,occupantId:h[0]}:{kind:"reject",zone:f,occupantId:h[0]}:{kind:"accept",zone:f}}}catch(y){e={error:y}}finally{try{d&&!d.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}return null}function Fm(n,e,t,i,r,a){if(t===void 0&&(t=28),i===void 0&&(i=-1/0),r===void 0&&(r=0),a===void 0&&(a=80),r-i<a)return null;var s=e.x-n.x,o=e.y-n.y;return Math.max(Math.abs(s),Math.abs(o))<t?null:Math.abs(s)>Math.abs(o)?s<0?"left":"right":o<0?"up":"down"}function Om(n,e){var t=e,i=1;return{tick:function(r){return n.pingPong?(t+=i*n.ratePerSecond*r,t>=n.max?(t=n.max,i=-1):t<=n.min&&(t=n.min,i=1)):t=Math.max(n.min,Math.min(n.max,t+n.ratePerSecond*r)),t}}}function Bm(){var n=new Map;return{to:function(e,t,i,r,a){r===void 0&&(r=.18),n.set(e,{from:mu({},t),to:mu({},i),seconds:Math.max(.02,r),elapsed:0,onDone:a})},cancel:function(e){n.delete(e)},clear:function(){n.clear()},tick:function(e,t){var i,r,a;try{for(var s=Nm(n),o=s.next();!o.done;o=s.next()){var u=Dm(o.value,2),l=u[0],d=u[1];d.elapsed+=e;var f=Math.min(1,d.elapsed/d.seconds),h=1-Math.pow(1-f,3);t(l,{x:d.from.x+(d.to.x-d.from.x)*h,y:d.from.y+(d.to.y-d.from.y)*h}),f===1&&(n.delete(l),(a=d.onDone)===null||a===void 0||a.call(d))}}catch(m){i={error:m}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}}}}function oh(n,e,t,i){t===void 0&&(t=56),i===void 0&&(i=.12);var r=Math.max(1,t),a=e.x-n.x,s=e.y-n.y,o=Math.hypot(a,s),u=Math.min(o,r),l=u/r,d=o>1e-6?a/o:0,f=o>1e-6?s/o:0,h=n.x+d*u,m=n.y+f*u;if(l<=i)return{nx:0,ny:0,magnitude:0,angle:0,knobX:h,knobY:m};var y=(l-i)/Math.max(1e-6,1-i);return{nx:d*y,ny:f*y,magnitude:y,angle:Math.atan2(f,d)*180/Math.PI,knobX:h,knobY:m}}var lh=function(){return lh=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},lh.apply(this,arguments)},km=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function gu(n){var e,t,i=2166136261;try{for(var r=km(String(n)),a=r.next();!a.done;a=r.next()){var s=a.value;i^=s.codePointAt(0),i=Math.imul(i,16777619)}}catch(o){e={error:o}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i>>>0||1}function yu(n){var e=n>>>0||1,t=e;return{next:function(){return t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296},between:function(i,r,a){if(a===void 0&&(a=!1),a){var s=Math.ceil(i),o=Math.floor(r);return o<s?s:Math.min(o,s+Math.floor((o-s+1)*this.next()))}return i+(r-i)*this.next()},reset:function(){t=e}}}function zm(n,e,t,i,r){var a,s;i===void 0&&(i=0);var o=null,u=1/0;try{for(var l=km(e),d=l.next();!d.done;d=l.next()){var f=d.value;if(!(f.id===r||f.team!==t)){var h=Math.hypot(f.x-n.x,f.y-n.y);i>0&&h>i||(h<u||h===u&&f.id<o?.id)&&(o=f,u=h)}}}catch(m){a={error:m}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}return o}function Vm(n,e,t){var i=((e-n+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return n+Math.max(-t,Math.min(t,i))}function Gm(n){var e=yu(n),t=new Map,i=new Map;return{rng:e,states:t,headings:i,reset:function(){e.reset(),t.clear(),i.clear()},initialize:function(r,a){var s;return t.has(r)||t.set(r,{hp:a.hp,maxHp:a.maxHp,value:a.value,tag:(s=a.tag)!==null&&s!==void 0?s:"",team:a.team}),t.get(r)},remove:function(r){t.delete(r),i.delete(r)},snapshot:function(r){var a=t.get(r);return a?lh({},a):void 0}}}function Hm(n,e){var t,i,r,a,s=e===void 0?{}:e,o=s.width,u=s.height,l=s.onProgress,d=l===void 0?function(){}:l,f=s.onComplete,h=f===void 0?function(){}:f,m=s.canvasFactory,y=s.source,M=n,g=M.gridSize,v=new Uint8Array(g*g),L=0,p=!1,_=-1,N=!1,D=Math.max(1,o),V=Math.max(1,u),w=Math.min(1,512/Math.max(D,V)),I=(t=m?.())!==null&&t!==void 0?t:!((i=globalThis.document)===null||i===void 0)&&i.createElement?globalThis.document.createElement("canvas"):void 0;I&&(I.width=Math.max(1,Math.round(D*w)),I.height=Math.max(1,Math.round(V*w)));var G=(r=I?.getContext)===null||r===void 0?void 0:r.call(I,"2d"),H=(a=M.maskColor)!==null&&a!==void 0?a:"#dceeff",Q=function(){return!!(y&&y.complete&&y.naturalWidth>0)},T=function(){G&&(G.globalCompositeOperation="source-over",G.clearRect(0,0,I.width,I.height),M.mode==="erase"&&(Q()?(G.drawImage(y,0,0,I.width,I.height),N=!0):(G.fillStyle=H,G.fillRect(0,0,I.width,I.height),N=!1)))};T();var S=function(){if(!p){var q=Math.round(L/v.length*100),se=Math.min(100,q);se!==_&&(_=se,d(se)),se>=M.targetPercent&&(p=!0,h(se))}},Z=function(q,se){for(var F=Math.max(0,Math.min(g-1,Math.floor(q/D*g))),z=Math.max(0,Math.min(g-1,Math.floor(se/V*g))),Y=Math.max(0,Math.ceil(M.brushRadiusPx/D*g)),$=Math.max(0,Math.ceil(M.brushRadiusPx/V*g)),he=Math.max(0,z-$);he<=Math.min(g-1,z+$);he++)for(var pe=Math.max(0,F-Y);pe<=Math.min(g-1,F+Y);pe++)if(!(Math.hypot((pe+.5)/g*D-q,(he+.5)/g*V-se)>M.brushRadiusPx)){var le=he*g+pe;v[le]||(v[le]=1,L++)}G&&(G.save(),G.scale(w,w),G.globalCompositeOperation=M.mode==="erase"?"destination-out":"source-over",G.fillStyle=H,G.beginPath(),G.arc(q,se,M.brushRadiusPx,0,Math.PI*2),G.fill(),M.mode==="reveal"&&y&&(G.globalCompositeOperation="source-in",G.drawImage(y,0,0,D,V)),G.restore()),S()};return{canvas:I,stampSegment:function(q,se){for(var F=Math.hypot(se.x-q.x,se.y-q.y),z=Math.max(1,Math.ceil(F/Math.max(1,M.brushRadiusPx*.45))),Y=0;Y<=z;Y++)Z(q.x+(se.x-q.x)*Y/z,q.y+(se.y-q.y)*Y/z)},reset:function(){v.fill(0),L=0,p=!1,_=-1,T(),S()},get progress(){return Math.round(L/v.length*100)},render:function(q){M.mode==="erase"&&L===0&&!N&&Q()&&T(),I?q.drawImage(I,0,0,I.width,I.height,0,0,o,u):M.mode==="erase"&&this.progress<100&&(q.save(),q.globalAlpha=1-this.progress/100,q.fillStyle=H,q.fillRect(0,0,o,u),q.restore())}}}var no=function(){return no=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},no.apply(this,arguments)},Ny=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function ch(n,e,t,i){var r=function(d,f,h){return(f.x-d.x)*(h.y-d.y)-(f.y-d.y)*(h.x-d.x)},a=r(n,e,t),s=r(n,e,i),o=r(t,i,n),u=r(t,i,e),l=1e-8;return Math.abs(a)<l&&Math.abs(s)<l&&Math.abs(o)<l&&Math.abs(u)<l?Math.max(Math.min(n.x,e.x),Math.min(t.x,i.x))<=Math.min(Math.max(n.x,e.x),Math.max(t.x,i.x))+l&&Math.max(Math.min(n.y,e.y),Math.min(t.y,i.y))<=Math.min(Math.max(n.y,e.y),Math.max(t.y,i.y))+l:a>0!=s>0&&o>0!=u>0}function Wm(n,e){for(var t=!1,i=0,r=e.length-1;i<e.length;r=i++){var a=e[i],s=e[r];a.y>n.y!=s.y>n.y&&n.x<(s.x-a.x)*(n.y-a.y)/(s.y-a.y)+a.x&&(t=!t)}return t}function Xm(n,e,t){if(t.length>=3&&(Wm(n,t)||Wm(e,t)))return!0;for(var i=0;i<t.length;i++)if(ch(n,e,t[i],t[(i+1)%t.length]))return!0;return!1}function Ym(n){var e=n,t=[],i=null,r=0,a=function(s){return no(no({},s),{points:s.points.map(function(o){return no({},o)})})};return{begin:function(s){var o={id:++r,points:[no({},s)],age:0,hitIds:new Set};return i=o,t.push(o),t.length>e.maxStrokes&&t.shift(),o},add:function(s){if(!i||i.points.length>=e.maxPoints)return!1;var o=i.points[i.points.length-1];return Math.hypot(s.x-o.x,s.y-o.y)<e.minSegmentPx?!1:(i.points.push(no({},s)),!0)},end:function(){var s=i;return i=null,s?a(s):void 0},cancel:function(){i&&(t=t.filter(function(s){return s!==i})),i=null},clear:function(){i=null,t=[]},tick:function(s){var o,u;try{for(var l=Ny(t),d=l.next();!d.done;d=l.next()){var f=d.value;f.age+=s}}catch(h){o={error:h}}finally{try{d&&!d.done&&(u=l.return)&&u.call(l)}finally{if(o)throw o.error}}t=t.filter(function(h){return h===i||h.age<.18||e.mode!=="slice-blade"})},get active(){return i},get strokes(){return t}}}function qm(n,e){for(var t=[],i=1;i<n.points.length;i++){var r=n.points[i-1],a=n.points[i],s=Math.hypot(a.x-r.x,a.y-r.y);s<.001||t.push({id:"stroke-".concat(n.id,"-").concat(i),strokeId:n.id,mode:"static",shape:"box",x:(r.x+a.x)/2,y:(r.y+a.y)/2,width:s,height:Math.max(2,e),angle:Math.atan2(a.y-r.y,a.x-r.x),restitution:.8})}return t}var zl=function(){return zl=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},zl.apply(this,arguments)},jm=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Is=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Uy=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},ds=function(n,e){return Math.hypot(n,e)},Zm=function(n,e,t){return Math.max(e,Math.min(t,n))},io=function(n){return Math.max(1,Math.min(n.width,n.height)/2)};function Jm(n){var e,t,i=Math.cos((e=n.angle)!==null&&e!==void 0?e:0),r=Math.sin((t=n.angle)!==null&&t!==void 0?t:0),a=n.width/2,s=n.height/2;return[[-a,-s],[a,-s],[a,s],[-a,s]].map(function(o){var u=jm(o,2),l=u[0],d=u[1];return{x:n.x+l*i-d*r,y:n.y+l*r+d*i}})}function Fy(n,e){var t,i,r,a,s,o,u,l,d,f,h=Jm(n),m=Jm(e),y=[(u=n.angle)!==null&&u!==void 0?u:0,((l=n.angle)!==null&&l!==void 0?l:0)+Math.PI/2,(d=e.angle)!==null&&d!==void 0?d:0,((f=e.angle)!==null&&f!==void 0?f:0)+Math.PI/2],M=1/0,g=1,v=0;try{for(var L=Is(y),p=L.next();!p.done;p=L.next()){var _=p.value,N=Math.cos(_),D=Math.sin(_),V=1/0,w=-1/0,I=1/0,G=-1/0;try{for(var H=(r=void 0,Is(h)),Q=H.next();!Q.done;Q=H.next()){var T=Q.value,S=T.x*N+T.y*D;S<V&&(V=S),S>w&&(w=S)}}catch(F){r={error:F}}finally{try{Q&&!Q.done&&(a=H.return)&&a.call(H)}finally{if(r)throw r.error}}try{for(var Z=(s=void 0,Is(m)),q=Z.next();!q.done;q=Z.next()){var T=q.value,S=T.x*N+T.y*D;S<I&&(I=S),S>G&&(G=S)}}catch(F){s={error:F}}finally{try{q&&!q.done&&(o=Z.return)&&o.call(Z)}finally{if(s)throw s.error}}var se=Math.min(w,G)-Math.max(V,I);if(se<=0)return null;se<M&&(M=se,g=N,v=D)}}catch(F){t={error:F}}finally{try{p&&!p.done&&(i=L.return)&&i.call(L)}finally{if(t)throw t.error}}return(n.x-e.x)*g+(n.y-e.y)*v<0&&(g=-g,v=-v),{nx:g,ny:v,penetration:M}}function $m(n,e){var t,i,r,a=io(n),s=-((t=e.angle)!==null&&t!==void 0?t:0),o=Math.cos(s),u=Math.sin(s),l=n.x-e.x,d=n.y-e.y,f=l*o-d*u,h=l*u+d*o,m=e.width/2,y=e.height/2,M=Zm(f,-m,m),g=Zm(h,-y,y),v=f-M,L=h-g,p=ds(v,L),_;if(p>=a)return null;if(p<1e-4){var N=[{d:m-Math.abs(f),x:f>=0?1:-1,y:0},{d:y-Math.abs(h),x:0,y:h>=0?1:-1}].sort(function(w,I){return w.d-I.d});v=N[0].x,L=N[0].y,_=a+N[0].d}else v/=p,L/=p,_=a-p;var D=Math.cos((i=e.angle)!==null&&i!==void 0?i:0),V=Math.sin((r=e.angle)!==null&&r!==void 0?r:0);return{nx:v*D-L*V,ny:v*V+L*D,penetration:_}}function Km(n,e){var t;return!!(n.ignoreGroup&&n.ignoreGroup!=="none"&&(n.ignoreGroup==="all"||n.ignoreGroup===((t=e.collisionGroup)!==null&&t!==void 0?t:"all")))}function Qm(n,e,t){var i,r,a,s,o,u;if(!(n.captured||e.captured||Km(n,e)||Km(e,n))){var l=n.x-e.x,d=n.y-e.y,f;if(n.shape==="circle"&&e.shape==="circle"){var h=ds(l,d),m=io(n)+io(e)-h;if(m<=0)return;f=m,h>1e-4?(l/=h,d/=h):(l=1,d=0)}else if(n.shape==="circle"&&e.shape==="box"){var y=$m(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="circle"){var y=$m(e,n);if(!y)return;l=-y.nx,d=-y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="box"){var y=Fy(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else return;var M=n.mode==="dynamic"?1/((i=n.mass)!==null&&i!==void 0?i:1):0,g=e.mode==="dynamic"?1/((r=e.mass)!==null&&r!==void 0?r:1):0,v=M+g;if(v){n.x+=l*f*M/v,n.y+=d*f*M/v,e.mode==="dynamic"&&(e.x-=l*f*g/v,e.y-=d*f*g/v);var L=n.vx-((a=e.vx)!==null&&a!==void 0?a:0),p=n.vy-((s=e.vy)!==null&&s!==void 0?s:0),_=L*l+p*d;if(!(_>=0)){var N=Math.max((o=n.restitution)!==null&&o!==void 0?o:0,(u=e.restitution)!==null&&u!==void 0?u:0),D=-(1+N)*_/v;n.vx+=l*D*M,n.vy+=d*D*M,e.mode==="dynamic"&&(e.vx-=l*D*g,e.vy-=d*D*g),n.atRest=!1,n.restElapsed=0,e.mode==="dynamic"&&(e.atRest=!1,e.restElapsed=0),Math.abs(_)>4&&(t("bodyBounce",n,e,{speed:Math.abs(_)}),e.mode==="dynamic"&&t("bodyBounce",e,n,{speed:Math.abs(_)}))}}}}function Oy(n,e,t,i){var r,a;if(!(n.mode!=="dynamic"||n.captured))try{for(var s=Is(e),o=s.next();!o.done;o=s.next()){var u=o.value,l=u.x-n.x,d=u.y-n.y,f=ds(l,d);if(!(f>=u.radius*2.5)){if(f>u.radius&&f>.001&&u.pullStrength>0){var h=u.pullStrength*(1-f/(u.radius*2.5));n.vx+=l/f*h*t,n.vy+=d/f*h*t}if(f<u.radius&&ds(n.vx,n.vy)<=u.maxCaptureSpeed){n.captured=!0,n.atRest=!0,n.vx=u.stopBody?0:n.vx,n.vy=u.stopBody?0:n.vy,u.stopBody&&(n.x=u.x,n.y=u.y),i("zoneCapture",n,u,{});return}}}}catch(m){r={error:m}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}}function By(n,e){var t,i,r,a,s,o,u=function(h){if(h.broken)return"continue";var m=e.find(function(V){return V.id===h.bodyId}),y=e.find(function(V){return V.id===h.anchorId});if(!m||m.mode!=="dynamic")return"continue";var M=(a=(r=y?.x)!==null&&r!==void 0?r:h.x)!==null&&a!==void 0?a:0,g=(o=(s=y?.y)!==null&&s!==void 0?s:h.y)!==null&&o!==void 0?o:0,v=m.x-M,L=m.y-g,p=ds(v,L);if(p<=h.lengthPx||p<1e-4)return"continue";var _=v/p,N=L/p;m.x=M+_*h.lengthPx,m.y=g+N*h.lengthPx;var D=m.vx*_+m.vy*N;D>0&&(m.vx-=_*D,m.vy-=N*D)};try{for(var l=Is(n),d=l.next();!d.done;d=l.next()){var f=d.value;u(f)}}catch(h){t={error:h}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(t)throw t.error}}}function uh(n){for(var e,t,i,r,a,s,o,u,l,d,f,h=n.bodies,m=n.zones,y=m===void 0?[]:m,M=n.joints,g=M===void 0?[]:M,v=n.bounds,L=n.dt,p=n.onEvent,_=p===void 0?function(){}:p,N=h.filter(function(oe){return oe.mode==="dynamic"&&!oe.captured}),D=N.reduce(function(oe,ee){return Math.max(oe,ds(ee.vx,ee.vy))},0),V=N.reduce(function(oe,ee){return Math.min(oe,io(ee))},24),w=Math.min(16,Math.max(1,Math.ceil(D*L/(V*.45)))),I=L/w,G=0;G<w;G++){try{for(var H=(e=void 0,Is(N)),Q=H.next();!Q.done;Q=H.next()){var T=Q.value;T.vy+=((o=T.gravity)!==null&&o!==void 0?o:0)*I;var S=ds(T.vx,T.vy);if(S>T.maxSpeed){var Z=T.maxSpeed/S;T.vx*=Z,T.vy*=Z,S=T.maxSpeed}T.x+=T.vx*I,T.y+=T.vy*I;var q=Math.max(0,S-((u=T.friction)!==null&&u!==void 0?u:0)*I),se=Math.exp(-((l=T.linearDamping)!==null&&l!==void 0?l:0)*I);if(S>1e-4){var F=q/S*se;T.vx*=F,T.vy*=F}T.spinToRotation&&(T.angle=((d=T.angle)!==null&&d!==void 0?d:0)+ds(T.vx,T.vy)*I/io(T)*(T.vx<0?-1:1))}}catch(oe){e={error:oe}}finally{try{Q&&!Q.done&&(t=H.return)&&t.call(H)}finally{if(e)throw e.error}}for(var z=0;z<N.length;z++){var T=N[z];try{for(var Y=(i=void 0,Is(h)),$=Y.next();!$.done;$=Y.next()){var he=$.value;he.id!==T.id&&he.mode!=="dynamic"&&Qm(T,he,_)}}catch(ee){i={error:ee}}finally{try{$&&!$.done&&(r=Y.return)&&r.call(Y)}finally{if(i)throw i.error}}for(var he=z+1;he<N.length;he++)Qm(N[he],T,_);var pe=T.shape==="box"?T.width/2:io(T),le=T.shape==="box"?T.height/2:io(T);T.wallBounce?(T.x-pe<v.left&&(T.x=v.left+pe,T.vx<0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vx)}),T.vx=-T.vx*T.restitution)),T.x+pe>v.right&&(T.x=v.right-pe,T.vx>0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vx)}),T.vx=-T.vx*T.restitution)),T.y-le<v.top&&(T.y=v.top+le,T.vy<0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vy)}),T.vy=-T.vy*T.restitution)),T.y+le>v.bottom&&(T.y=v.bottom-le,T.vy>0&&(_("bodyBounce",T,null,{speed:Math.abs(T.vy)}),T.vy=-T.vy*T.restitution))):!T.exited&&(T.x+pe<v.left||T.x-pe>v.right||T.y+le<v.top||T.y-le>v.bottom)&&(T.exited=!0,_("boundaryExit",T,null,{})),Oy(T,y,I,_)}By(g,h)}try{for(var Te=Is(N),De=Te.next();!De.done;De=Te.next()){var T=De.value,S=ds(T.vx,T.vy);S<T.restSpeed&&!T.captured?(T.restElapsed=((f=T.restElapsed)!==null&&f!==void 0?f:0)+L,T.restElapsed>=T.restDelaySeconds&&!T.atRest&&(T.atRest=!0,T.vx=0,T.vy=0,_("bodyRest",T,null,{}))):S>=T.restSpeed&&(T.restElapsed=0,T.atRest=!1)}}catch(oe){a={error:oe}}finally{try{De&&!De.done&&(s=Te.return)&&s.call(Te)}finally{if(a)throw a.error}}}function ev(n){for(var e=n.body,t=n.bodies,i=n.zones,r=i===void 0?[]:i,a=n.bounds,s=n.dots,o=s===void 0?8:s,u=n.bounces,l=u===void 0?1:u,d=function(p){return zl({},p)},f=d(e),h=t.filter(function(p){return p.id!==e.id}).map(d),m=Uy([f],jm(h),!1),y=[],M=0,g=!1,v=function(p,_,N,D){p==="bodyBounce"&&D.sourceId===e.id&&M++,p==="zoneCapture"&&D.sourceId===e.id&&(g=!0)},L=0;L<90&&y.length<o&&!g&&M<=l;L++)uh({bodies:m,zones:r,bounds:a,dt:1/60,onEvent:function(p,_,N,D){return v(p,_,N,zl(zl({},D),{sourceId:_.id}))}}),L%Math.max(1,Math.floor(90/o))===0&&y.push({x:f.x,y:f.y});return y}var Co=function(){return Co=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Co.apply(this,arguments)},Vl=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nv=.008333333333333333;function Cs(n,e,t){var i,r,a,s=(i=n.boundsX)!==null&&i!==void 0?i:3,o=(r=n.boundsZ)!==null&&r!==void 0?r:7;if(Math.abs(e)>s||Math.abs(t)>o)return null;if(!n.ramp)return 0;var u=(a=n.rampHeight)!==null&&a!==void 0?a:1.1;return t>=1?0:t<=-1?u:(1-t)*(u*.5)}function tv(n,e,t,i){var r,a,s,o=n.radius,u=Math.cos(e.angle),l=Math.sin(e.angle),d=n.x-e.x,f=n.z-e.z,h=u*d+l*f,m=-l*d+u*f,y=Math.max(-e.hx,Math.min(e.hx,h)),M=Math.max(-e.hz,Math.min(e.hz,m)),g=h-y,v=m-M,L=Math.hypot(g,v),p=Cs(n,n.x,n.z);if(!(L>=o||p!==null&&n.y>p+.55)){L<1e-8?e.hx-Math.abs(h)<e.hz-Math.abs(m)?(g=h<0?-1:1,v=0,L=0):(g=0,v=m<0?-1:1,L=0):(g/=L,v/=L);var _=u*g-l*v,N=l*g+u*v;n.x+=_*(o-L+1e-5),n.z+=N*(o-L+1e-5);var D=(r=e.vx)!==null&&r!==void 0?r:0,V=(a=e.vz)!==null&&a!==void 0?a:0,w=(n.vx-D)*_+(n.vz-V)*N;if(w<0){var I=1+((s=n.restitution)!==null&&s!==void 0?s:.72);n.vx-=I*w*_,n.vz-=I*w*N,Math.abs(w)>.3&&t>0&&i&&i("bodyBounce",n,e.sourceId?e:void 0)}}}function iv(n,e){n.vx=0,n.vy=0,n.vz=0,n.airborne=!1,n.atRest=!0,n.restElapsed=0,n.movingTime=0,e&&e("bodyRest",n)}function dh(n,e){n.x=n.lastSafe.x,n.y=n.lastSafe.y,n.z=n.lastSafe.z,iv(n,e)}function fh(n){var e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g,v,L,p=n.bodies,_=n.walls,N=n.zones,D=n.dt,V=n.onEvent;if(!(!Number.isFinite(D)||D<=0))for(var w=Math.max(1,Math.round(D/nv)),I=D/w,G=0;G<w;G++)try{for(var H=(e=void 0,Vl(p)),Q=H.next();!Q.done;Q=H.next()){var T=Q.value;if(!(T.mode!=="dynamic"||T.captured)&&!T.atRest){var S=(l=T.boundsX)!==null&&l!==void 0?l:3,Z=(d=T.boundsZ)!==null&&d!==void 0?d:7;if(T.y<-3||Math.abs(T.x)>S+2||Math.abs(T.z)>Z+2){dh(T,V);continue}T.movingTime=((f=T.movingTime)!==null&&f!==void 0?f:0)+I;var q=T.radius,se=Math.hypot(T.vx,T.vy,T.vz),F=Math.max(1,Math.min(16,Math.ceil(se*I/(q*.45)))),z=I/F;(!T._perimeter||T._pbx!==S||T._pbz!==Z)&&(T._pbx=S,T._pbz=Z,T._perimeter=[{x:-(S+.1),z:0,hx:.1,hz:Z+.1,angle:0,vx:0,vz:0},{x:S+.1,z:0,hx:.1,hz:Z+.1,angle:0,vx:0,vz:0},{x:0,z:-(Z+.1),hx:S+.1,hz:.1,angle:0,vx:0,vz:0},{x:0,z:Z+.1,hx:S+.1,hz:.1,angle:0,vx:0,vz:0}]);for(var Y=T._perimeter,$=!1,he=0;he<F;he++){var pe=Cs(T,T.x,T.z),le=pe!==null&&T.y<=pe+q+.012&&T.vy<=.1,Te=pe;if(le){T.y=pe+q,T.vy=0;var De=Math.hypot(T.vx,T.vz),oe=Math.max(0,De-((h=T.friction)!==null&&h!==void 0?h:1.05)*z);if(De>0&&(T.vx*=oe/De,T.vz*=oe/De),T.ramp&&T.z<1&&T.z>-1){var ee=((m=T.rampHeight)!==null&&m!==void 0?m:1.1)*.5;T.vz+=9.81*ee/(1+ee*ee)*z}}else T.vy-=9.81*z,T.airborne||(T.airborne=!0,V&&V("bodyJump",T));T.x+=T.vx*z,T.z+=T.vz*z,T.y+=T.vy*z;var be=Cs(T,T.x,T.z);if(be!==null){if(le&&Te!==null){var ee=((y=T.rampHeight)!==null&&y!==void 0?y:1.1)*.5;T.ramp&&T.z<=-1&&T.z-T.vz*z>-1.5&&T.vz<-.8?(T.vy=-T.vz*ee,T.airborne=!0,V&&V("bodyJump",T)):T.y=be+q}T.y<be+q&&(T.y=be+q,T.vy=0,T.airborne=!1)}if(T.y<2){try{for(var Be=(i=void 0,Vl(_)),Re=Be.next();!Re.done;Re=Be.next()){var Ye=Re.value;tv(T,Ye,z,V)}}catch(Dt){i={error:Dt}}finally{try{Re&&!Re.done&&(r=Be.return)&&r.call(Be)}finally{if(i)throw i.error}}try{for(var nt=(a=void 0,Vl(Y)),Ge=nt.next();!Ge.done;Ge=nt.next()){var Ye=Ge.value;tv(T,Ye,z,V)}}catch(Dt){a={error:Dt}}finally{try{Ge&&!Ge.done&&(s=nt.return)&&s.call(nt)}finally{if(a)throw a.error}}}T.spin=((M=T.spin)!==null&&M!==void 0?M:0)+Math.hypot(T.vx,T.vz)*z/q;var $e=Math.hypot(T.vx,T.vz);try{for(var mt=(o=void 0,Vl(N)),at=mt.next();!at.done;at=mt.next()){var Ve=at.value,Yt=Math.hypot(T.x-Ve.x,T.z-Ve.z);if(Yt<Ve.radius&&Math.abs(T.y-(Ve.y+q))<Ve.heightTolerance&&$e<Ve.maxCaptureSpeed){T.captured=!0,T.captureElapsed=0,T.captureTarget={x:Ve.x,y:Ve.y,z:Ve.z},T.vx=0,T.vy=0,T.vz=0,T.atRest=!0,V&&V("zoneCapture",T,Ve),$=!0;break}}}catch(Dt){o={error:Dt}}finally{try{at&&!at.done&&(u=mt.return)&&u.call(mt)}finally{if(o)throw o.error}}if($)break;if(T.y<-3||Math.abs(T.x)>S+2||Math.abs(T.z)>Z+2){dh(T,V),$=!0;break}}if(!$){var st=Math.hypot(T.vx,T.vy,T.vz);st<((g=T.restSpeed)!==null&&g!==void 0?g:.07)?(T.restElapsed=((v=T.restElapsed)!==null&&v!==void 0?v:0)+I,T.restElapsed>((L=T.restDelaySeconds)!==null&&L!==void 0?L:.25)&&iv(T,V)):T.restElapsed=0,T.movingTime>18&&dh(T,V)}}}}catch(Dt){e={error:Dt}}finally{try{Q&&!Q.done&&(t=H.return)&&t.call(H)}finally{if(e)throw e.error}}}function rv(n){var e,t=n.body,i=n.walls,r=n.zones,a=n.vx,s=n.vz,o=n.dots,u=o===void 0?15:o,l=Math.hypot(a,s);if(!Number.isFinite(l)||l<.35)return[];for(var d=Math.min(1,((e=t.maxSpeed)!==null&&e!==void 0?e:9)/l),f=Co(Co({},t),{vx:a*d,vy:0,vz:s*d,atRest:!1,captured:!1,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:t.x,y:t.y,z:t.z}}),h=i.map(function(L){return Co(Co({},L),{vx:0,vz:0})}),m=[f],y={bodies:m,walls:h,zones:r,dt:nv},M=[],g=Math.max(18,u*6),v=0;v<g&&(fh(y),v%6===0&&M.push({x:f.x,y:f.y,z:f.z}),!(f.atRest||f.captured));v++);return M}function hh(n,e,t,i,r,a){var s,o,u,l;i===void 0&&(i=[]),r===void 0&&(r=12),a===void 0&&(a=12);for(var d=n,f=e,h=Math.max(.05,t??.45),m=0;m<2;m++){try{for(var y=(s=void 0,Vl(i)),M=y.next();!M.done;M=y.next()){var g=M.value,v=Math.cos((u=g.angle)!==null&&u!==void 0?u:0),L=Math.sin((l=g.angle)!==null&&l!==void 0?l:0),p=d-g.x,_=f-g.z,N=v*p+L*_,D=-L*p+v*_,V=Math.max(-g.hx,Math.min(g.hx,N)),w=Math.max(-g.hz,Math.min(g.hz,D)),I=N-V,G=D-w,H=Math.hypot(I,G);if(!(H>=h)){H<1e-8?g.hx-Math.abs(N)<g.hz-Math.abs(D)?(I=N<0?-1:1,G=0):(I=0,G=D<0?-1:1):(I/=H,G/=H);var Q=v*I-L*G,T=L*I+v*G;d+=Q*(h-H+1e-4),f+=T*(h-H+1e-4)}}}catch(q){s={error:q}}finally{try{M&&!M.done&&(o=y.return)&&o.call(y)}finally{if(s)throw s.error}}var S=Math.max(0,(r??12)-h),Z=Math.max(0,(a??12)-h);d=Math.max(-S,Math.min(S,d)),f=Math.max(-Z,Math.min(Z,f))}return{x:d,z:f}}var Gv=0,ep=1,Hv=2;var Ac=1,Ad=2,ul=3,$a=0,Kr=1,Br=2,Ka=0,dl=1,tp=2,np=3,ip=4,Wv=5;var ho=100,Xv=101,Yv=102,qv=103,Zv=104,Jv=200,$v=201,Kv=202,Qv=203,rp=204,ap=205,jv=206,e0=207,t0=208,n0=209,i0=210,r0=211,a0=212,s0=213,o0=214,Wu=0,Xu=1,Yu=2,Yo=3,qu=4,Zu=5,Ju=6,$u=7,Ed=0,l0=1,c0=2,oa=0,sp=1,op=2,lp=3,Ec=4,cp=5,up=6,Ic=7,Gh="attached",u0="detached",dp=300,Gs=301,po=302,fl=303,Id=304,Cc=306,Fs=1e3,Sa=1001,qo=1002,ir=1003,Cd=1004;var mo=1005;var lr=1006,hl=1007;var Qa=1008;var la=1009,fp=1010,hp=1011,pl=1012,Rd=1013,Ua=1014,va=1015,Fa=1016,Pd=1017,Ld=1018,ml=1020,pp=35902,mp=35899,vp=1021,gp=1022,ga=1023,qa=1026,Hs=1027,Dd=1028,Nd=1029,Ws=1030,Ud=1031;var Fd=1033,Rc=33776,Pc=33777,Lc=33778,Dc=33779,Od=35840,Bd=35841,kd=35842,zd=35843,Vd=36196,Gd=37492,Hd=37496,Wd=37488,Xd=37489,Nc=37490,Yd=37491,qd=37808,Zd=37809,Jd=37810,$d=37811,Kd=37812,Qd=37813,jd=37814,ef=37815,tf=37816,nf=37817,rf=37818,af=37819,sf=37820,of=37821,lf=36492,cf=36494,uf=36495,df=36283,ff=36284,Uc=36285,hf=36286;var jl=2300,Ku=2301,Gu=2302,Hh=2303,Wh=2400,Xh=2401,Yh=2402;var d0=3200;var Fc=0,f0=1,Qr="",wr="srgb",ec="srgb-linear",tc="linear",Li="srgb";var Hu=7680;var h0=519,p0=512,m0=513,v0=514,pf=515,g0=516,y0=517,mf=518,x0=519,_0=35044;var yp="300 es",Da=2e3,Zo=2001;function ky(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function zy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function nc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function M0(){let n=nc("canvas");return n.style.display="block",n}var av={},Jo=null;function xp(...n){let e="THREE."+n.shift();Jo?Jo("log",e,...n):console.log(e,...n)}function S0(n){let e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function En(...n){n=S0(n);let e="THREE."+n.shift();if(Jo)Jo("warn",e,...n);else{let t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function Un(...n){n=S0(n);let e="THREE."+n.shift();if(Jo)Jo("error",e,...n);else{let t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function lo(...n){let e=n.join(" ");e in av||(av[e]=!0,En(...n))}function b0(n,e,t){return new Promise(function(i,r){function a(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:i()}}setTimeout(a,t)})}var w0={[Wu]:Xu,[Yu]:Ju,[qu]:$u,[Yo]:Zu,[Xu]:Wu,[Ju]:Yu,[$u]:qu,[Zu]:Yo},Za=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){let i=this._listeners;if(i===void 0)return;let r=i[e];if(r!==void 0){let a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let i=t[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}},Nr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var ph=Math.PI/180,Qu=180/Math.PI;function vo(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Nr[n&255]+Nr[n>>8&255]+Nr[n>>16&255]+Nr[n>>24&255]+"-"+Nr[e&255]+Nr[e>>8&255]+"-"+Nr[e>>16&15|64]+Nr[e>>24&255]+"-"+Nr[t&63|128]+Nr[t>>8&255]+"-"+Nr[t>>16&255]+Nr[t>>24&255]+Nr[i&255]+Nr[i>>8&255]+Nr[i>>16&255]+Nr[i>>24&255]).toLowerCase()}function fi(n,e,t){return Math.max(e,Math.min(t,n))}function Vy(n,e){return(n%e+e)%e}function mh(n,e,t){return(1-t)*n+t*e}function Gl(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:case Uint8ClampedArray:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ia(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var Tp=class Tp{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=fi(this.x,e.x,t.x),this.y=fi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=fi(this.x,e,t),this.y=fi(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(fi(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(fi(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Tp.prototype.isVector2=!0;var tn=Tp,ra=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,s,o){let u=i[r+0],l=i[r+1],d=i[r+2],f=i[r+3],h=a[s+0],m=a[s+1],y=a[s+2],M=a[s+3];if(f!==M||u!==h||l!==m||d!==y){let g=u*h+l*m+d*y+f*M;g<0&&(h=-h,m=-m,y=-y,M=-M,g=-g);let v=1-o;if(g<.9995){let L=Math.acos(g),p=Math.sin(L);v=Math.sin(v*L)/p,o=Math.sin(o*L)/p,u=u*v+h*o,l=l*v+m*o,d=d*v+y*o,f=f*v+M*o}else{u=u*v+h*o,l=l*v+m*o,d=d*v+y*o,f=f*v+M*o;let L=1/Math.sqrt(u*u+l*l+d*d+f*f);u*=L,l*=L,d*=L,f*=L}}e[t]=u,e[t+1]=l,e[t+2]=d,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,r,a,s){let o=i[r],u=i[r+1],l=i[r+2],d=i[r+3],f=a[s],h=a[s+1],m=a[s+2],y=a[s+3];return e[t]=o*y+d*f+u*m-l*h,e[t+1]=u*y+d*h+l*f-o*m,e[t+2]=l*y+d*m+o*h-u*f,e[t+3]=d*y-o*f-u*h-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,u=Math.sin,l=o(i/2),d=o(r/2),f=o(a/2),h=u(i/2),m=u(r/2),y=u(a/2);switch(s){case"XYZ":this._x=h*d*f+l*m*y,this._y=l*m*f-h*d*y,this._z=l*d*y+h*m*f,this._w=l*d*f-h*m*y;break;case"YXZ":this._x=h*d*f+l*m*y,this._y=l*m*f-h*d*y,this._z=l*d*y-h*m*f,this._w=l*d*f+h*m*y;break;case"ZXY":this._x=h*d*f-l*m*y,this._y=l*m*f+h*d*y,this._z=l*d*y+h*m*f,this._w=l*d*f-h*m*y;break;case"ZYX":this._x=h*d*f-l*m*y,this._y=l*m*f+h*d*y,this._z=l*d*y-h*m*f,this._w=l*d*f+h*m*y;break;case"YZX":this._x=h*d*f+l*m*y,this._y=l*m*f+h*d*y,this._z=l*d*y-h*m*f,this._w=l*d*f-h*m*y;break;case"XZY":this._x=h*d*f-l*m*y,this._y=l*m*f-h*d*y,this._z=l*d*y+h*m*f,this._w=l*d*f+h*m*y;break;default:En("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],a=t[8],s=t[1],o=t[5],u=t[9],l=t[2],d=t[6],f=t[10],h=i+o+f;if(h>0){let m=.5/Math.sqrt(h+1);this._w=.25/m,this._x=(d-u)*m,this._y=(a-l)*m,this._z=(s-r)*m}else if(i>o&&i>f){let m=2*Math.sqrt(1+i-o-f);this._w=(d-u)/m,this._x=.25*m,this._y=(r+s)/m,this._z=(a+l)/m}else if(o>f){let m=2*Math.sqrt(1+o-i-f);this._w=(a-l)/m,this._x=(r+s)/m,this._y=.25*m,this._z=(u+d)/m}else{let m=2*Math.sqrt(1+f-i-o);this._w=(s-r)/m,this._x=(a+l)/m,this._y=(u+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(fi(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=t._x,u=t._y,l=t._z,d=t._w;return this._x=i*d+s*o+r*l-a*u,this._y=r*d+s*u+a*o-i*l,this._z=a*d+s*l+i*u-r*o,this._w=s*d-i*o-r*u-a*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,a=-a,s=-s,o=-o);let u=1-t;if(o<.9995){let l=Math.acos(o),d=Math.sin(l);u=Math.sin(u*l)/d,t=Math.sin(t*l)/d,this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this._onChangeCallback()}else this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),a=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),a*Math.sin(t),a*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Ap=class Ap{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(sv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(sv.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,u=e.w,l=2*(s*r-o*i),d=2*(o*t-a*r),f=2*(a*i-s*t);return this.x=t+u*l+s*f-o*d,this.y=i+u*d+o*l-a*f,this.z=r+u*f+a*d-s*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=fi(this.x,e.x,t.x),this.y=fi(this.y,e.y,t.y),this.z=fi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=fi(this.x,e,t),this.y=fi(this.y,e,t),this.z=fi(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(fi(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,a=e.z,s=t.x,o=t.y,u=t.z;return this.x=r*u-a*o,this.y=a*s-i*u,this.z=i*o-r*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return vh.copy(this).projectOnVector(e),this.sub(vh)}reflect(e){return this.sub(vh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(fi(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Ap.prototype.isVector3=!0;var xe=Ap,vh=new xe,sv=new ra,Ep=class Ep{constructor(e,t,i,r,a,s,o,u,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l)}set(e,t,i,r,a,s,o,u,l){let d=this.elements;return d[0]=e,d[1]=r,d[2]=o,d[3]=t,d[4]=a,d[5]=u,d[6]=i,d[7]=s,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[3],u=i[6],l=i[1],d=i[4],f=i[7],h=i[2],m=i[5],y=i[8],M=r[0],g=r[3],v=r[6],L=r[1],p=r[4],_=r[7],N=r[2],D=r[5],V=r[8];return a[0]=s*M+o*L+u*N,a[3]=s*g+o*p+u*D,a[6]=s*v+o*_+u*V,a[1]=l*M+d*L+f*N,a[4]=l*g+d*p+f*D,a[7]=l*v+d*_+f*V,a[2]=h*M+m*L+y*N,a[5]=h*g+m*p+y*D,a[8]=h*v+m*_+y*V,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8];return t*s*d-t*o*l-i*a*d+i*o*u+r*a*l-r*s*u}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=d*s-o*l,h=o*u-d*a,m=l*a-s*u,y=t*f+i*h+r*m;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let M=1/y;return e[0]=f*M,e[1]=(r*l-d*i)*M,e[2]=(o*i-r*s)*M,e[3]=h*M,e[4]=(d*t-r*u)*M,e[5]=(r*a-o*t)*M,e[6]=m*M,e[7]=(i*u-l*t)*M,e[8]=(s*t-i*a)*M,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,a,s,o){let u=Math.cos(a),l=Math.sin(a);return this.set(i*u,i*l,-i*(u*s+l*o)+s+e,-r*l,r*u,-r*(-l*s+u*o)+o+t,0,0,1),this}scale(e,t){return lo("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(gh.makeScale(e,t)),this}rotate(e){return lo("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(gh.makeRotation(-e)),this}translate(e,t){return lo("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(gh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Ep.prototype.isMatrix3=!0;var qn=Ep,gh=new qn,ov=new qn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),lv=new qn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Gy(){let n={enabled:!0,workingColorSpace:ec,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Li&&(r.r=gs(r.r),r.g=gs(r.g),r.b=gs(r.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(r.applyMatrix3(this.spaces[a].toXYZ),r.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Li&&(r.r=Wo(r.r),r.g=Wo(r.g),r.b=Wo(r.b))),r},workingToColorSpace:function(r,a){return this.convert(r,this.workingColorSpace,a)},colorSpaceToWorking:function(r,a){return this.convert(r,a,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Qr?tc:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,a=this.workingColorSpace){return r.fromArray(this.spaces[a].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,a,s){return r.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,a){return lo("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return lo("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[ec]:{primaries:e,whitePoint:i,transfer:tc,toXYZ:ov,fromXYZ:lv,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:wr},outputColorSpaceConfig:{drawingBufferColorSpace:wr}},[wr]:{primaries:e,whitePoint:i,transfer:Li,toXYZ:ov,fromXYZ:lv,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:wr}}}),n}var mi=Gy();function gs(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Wo(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Ro,ju=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Ro===void 0&&(Ro=nc("canvas")),Ro.width=e.width,Ro.height=e.height;let r=Ro.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Ro}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=nc("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=gs(a[s]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(gs(t[i]/255)*255):t[i]=gs(t[i]);return{data:t,width:e.width,height:e.height}}else return En("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Hy=0,$o=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Hy++}),this.uuid=vo(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,o=r.length;s<o;s++)r[s].isDataTexture?a.push(yh(r[s].image)):a.push(yh(r[s]))}else a=yh(r);i.url=a}return t||(e.images[this.uuid]=i),i}};function yh(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?ju.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(En("Texture: Unable to serialize Texture."),{})}var Wy=0,xh=new xe,Tr=class n extends Za{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=Sa,r=Sa,a=lr,s=Qa,o=ga,u=la,l=n.DEFAULT_ANISOTROPY,d=Qr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Wy++}),this.uuid=vo(),this.name="",this.source=new $o(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=u,this.offset=new tn(0,0),this.repeat=new tn(1,1),this.center=new tn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(xh).x}get height(){return this.source.getSize(xh).y}get depth(){return this.source.getSize(xh).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let i=e[t];if(i===void 0){En(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){En(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==dp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Fs:e.x=e.x-Math.floor(e.x);break;case Sa:e.x=e.x<0?0:1;break;case qo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Fs:e.y=e.y-Math.floor(e.y);break;case Sa:e.y=e.y<0?0:1;break;case qo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Tr.DEFAULT_IMAGE=null;Tr.DEFAULT_MAPPING=dp;Tr.DEFAULT_ANISOTROPY=1;var Ip=class Ip{constructor(e=0,t=0,i=0,r=1){this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,a,u=e.elements,l=u[0],d=u[4],f=u[8],h=u[1],m=u[5],y=u[9],M=u[2],g=u[6],v=u[10];if(Math.abs(d-h)<.01&&Math.abs(f-M)<.01&&Math.abs(y-g)<.01){if(Math.abs(d+h)<.1&&Math.abs(f+M)<.1&&Math.abs(y+g)<.1&&Math.abs(l+m+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let p=(l+1)/2,_=(m+1)/2,N=(v+1)/2,D=(d+h)/4,V=(f+M)/4,w=(y+g)/4;return p>_&&p>N?p<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(p),r=D/i,a=V/i):_>N?_<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(_),i=D/r,a=w/r):N<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(N),i=V/a,r=w/a),this.set(i,r,a,t),this}let L=Math.sqrt((g-y)*(g-y)+(f-M)*(f-M)+(h-d)*(h-d));return Math.abs(L)<.001&&(L=1),this.x=(g-y)/L,this.y=(f-M)/L,this.z=(h-d)/L,this.w=Math.acos((l+m+v-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=fi(this.x,e.x,t.x),this.y=fi(this.y,e.y,t.y),this.z=fi(this.z,e.z,t.z),this.w=fi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=fi(this.x,e,t),this.y=fi(this.y,e,t),this.z=fi(this.z,e,t),this.w=fi(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(fi(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Ip.prototype.isVector4=!0;var Ni=Ip,ed=class extends Za{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:lr,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Ni(0,0,e,t),this.scissorTest=!1,this.viewport=new Ni(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:i.depth},a=new Tr(r),s=i.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveColorBuffer=i.resolveColorBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.storeMultisampledColorBuffer=i.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=i.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=i.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:lr,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,a=this.textures.length;r<a;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new $o(r)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},aa=class extends ed{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},ic=class extends Tr{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=ir,this.minFilter=ir,this.wrapR=Sa,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var td=class extends Tr{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=ir,this.minFilter=ir,this.wrapR=Sa,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var Td=class Td{constructor(e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g)}set(e,t,i,r,a,s,o,u,l,d,f,h,m,y,M,g){let v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=a,v[5]=s,v[9]=o,v[13]=u,v[2]=l,v[6]=d,v[10]=f,v[14]=h,v[3]=m,v[7]=y,v[11]=M,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Td().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,i=e.elements,r=1/Po.setFromMatrixColumn(e,0).length(),a=1/Po.setFromMatrixColumn(e,1).length(),s=1/Po.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),u=Math.cos(r),l=Math.sin(r),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){let h=s*d,m=s*f,y=o*d,M=o*f;t[0]=u*d,t[4]=-u*f,t[8]=l,t[1]=m+y*l,t[5]=h-M*l,t[9]=-o*u,t[2]=M-h*l,t[6]=y+m*l,t[10]=s*u}else if(e.order==="YXZ"){let h=u*d,m=u*f,y=l*d,M=l*f;t[0]=h+M*o,t[4]=y*o-m,t[8]=s*l,t[1]=s*f,t[5]=s*d,t[9]=-o,t[2]=m*o-y,t[6]=M+h*o,t[10]=s*u}else if(e.order==="ZXY"){let h=u*d,m=u*f,y=l*d,M=l*f;t[0]=h-M*o,t[4]=-s*f,t[8]=y+m*o,t[1]=m+y*o,t[5]=s*d,t[9]=M-h*o,t[2]=-s*l,t[6]=o,t[10]=s*u}else if(e.order==="ZYX"){let h=s*d,m=s*f,y=o*d,M=o*f;t[0]=u*d,t[4]=y*l-m,t[8]=h*l+M,t[1]=u*f,t[5]=M*l+h,t[9]=m*l-y,t[2]=-l,t[6]=o*u,t[10]=s*u}else if(e.order==="YZX"){let h=s*u,m=s*l,y=o*u,M=o*l;t[0]=u*d,t[4]=M-h*f,t[8]=y*f+m,t[1]=f,t[5]=s*d,t[9]=-o*d,t[2]=-l*d,t[6]=m*f+y,t[10]=h-M*f}else if(e.order==="XZY"){let h=s*u,m=s*l,y=o*u,M=o*l;t[0]=u*d,t[4]=-f,t[8]=l*d,t[1]=h*f+M,t[5]=s*d,t[9]=m*f-y,t[2]=y*f-m,t[6]=o*d,t[10]=M*f+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Xy,e,Yy)}lookAt(e,t,i){let r=this.elements;return ua.subVectors(e,t),ua.lengthSq()===0&&(ua.z=1),ua.normalize(),Rs.crossVectors(i,ua),Rs.lengthSq()===0&&(Math.abs(i.z)===1?ua.x+=1e-4:ua.z+=1e-4,ua.normalize(),Rs.crossVectors(i,ua)),Rs.normalize(),xu.crossVectors(ua,Rs),r[0]=Rs.x,r[4]=xu.x,r[8]=ua.x,r[1]=Rs.y,r[5]=xu.y,r[9]=ua.y,r[2]=Rs.z,r[6]=xu.z,r[10]=ua.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[4],u=i[8],l=i[12],d=i[1],f=i[5],h=i[9],m=i[13],y=i[2],M=i[6],g=i[10],v=i[14],L=i[3],p=i[7],_=i[11],N=i[15],D=r[0],V=r[4],w=r[8],I=r[12],G=r[1],H=r[5],Q=r[9],T=r[13],S=r[2],Z=r[6],q=r[10],se=r[14],F=r[3],z=r[7],Y=r[11],$=r[15];return a[0]=s*D+o*G+u*S+l*F,a[4]=s*V+o*H+u*Z+l*z,a[8]=s*w+o*Q+u*q+l*Y,a[12]=s*I+o*T+u*se+l*$,a[1]=d*D+f*G+h*S+m*F,a[5]=d*V+f*H+h*Z+m*z,a[9]=d*w+f*Q+h*q+m*Y,a[13]=d*I+f*T+h*se+m*$,a[2]=y*D+M*G+g*S+v*F,a[6]=y*V+M*H+g*Z+v*z,a[10]=y*w+M*Q+g*q+v*Y,a[14]=y*I+M*T+g*se+v*$,a[3]=L*D+p*G+_*S+N*F,a[7]=L*V+p*H+_*Z+N*z,a[11]=L*w+p*Q+_*q+N*Y,a[15]=L*I+p*T+_*se+N*$,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],u=e[9],l=e[13],d=e[2],f=e[6],h=e[10],m=e[14],y=e[3],M=e[7],g=e[11],v=e[15],L=u*m-l*h,p=o*m-l*f,_=o*h-u*f,N=s*m-l*d,D=s*h-u*d,V=s*f-o*d;return t*(M*L-g*p+v*_)-i*(y*L-g*N+v*D)+r*(y*p-M*N+v*V)-a*(y*_-M*D+g*V)}determinantAffine(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[1],s=e[5],o=e[9],u=e[2],l=e[6],d=e[10];return t*(s*d-o*l)-i*(a*d-o*u)+r*(a*l-s*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=e[9],h=e[10],m=e[11],y=e[12],M=e[13],g=e[14],v=e[15],L=t*o-i*s,p=t*u-r*s,_=t*l-a*s,N=i*u-r*o,D=i*l-a*o,V=r*l-a*u,w=d*M-f*y,I=d*g-h*y,G=d*v-m*y,H=f*g-h*M,Q=f*v-m*M,T=h*v-m*g,S=L*T-p*Q+_*H+N*G-D*I+V*w;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Z=1/S;return e[0]=(o*T-u*Q+l*H)*Z,e[1]=(r*Q-i*T-a*H)*Z,e[2]=(M*V-g*D+v*N)*Z,e[3]=(h*D-f*V-m*N)*Z,e[4]=(u*G-s*T-l*I)*Z,e[5]=(t*T-r*G+a*I)*Z,e[6]=(g*_-y*V-v*p)*Z,e[7]=(d*V-h*_+m*p)*Z,e[8]=(s*Q-o*G+l*w)*Z,e[9]=(i*G-t*Q-a*w)*Z,e[10]=(y*D-M*_+v*L)*Z,e[11]=(f*_-d*D-m*L)*Z,e[12]=(o*I-s*H-u*w)*Z,e[13]=(t*H-i*I+r*w)*Z,e[14]=(M*p-y*N-g*L)*Z,e[15]=(d*N-f*p+h*L)*Z,this}scale(e){let t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),a=1-i,s=e.x,o=e.y,u=e.z,l=a*s,d=a*o;return this.set(l*s+i,l*o-r*u,l*u+r*o,0,l*o+r*u,d*o+i,d*u-r*s,0,l*u-r*o,d*u+r*s,a*u*u+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,a=t._x,s=t._y,o=t._z,u=t._w,l=a+a,d=s+s,f=o+o,h=a*l,m=a*d,y=a*f,M=s*d,g=s*f,v=o*f,L=u*l,p=u*d,_=u*f,N=i.x,D=i.y,V=i.z;return r[0]=(1-(M+v))*N,r[1]=(m+_)*N,r[2]=(y-p)*N,r[3]=0,r[4]=(m-_)*D,r[5]=(1-(h+v))*D,r[6]=(g+L)*D,r[7]=0,r[8]=(y+p)*V,r[9]=(g-L)*V,r[10]=(1-(h+M))*V,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let a=this.determinantAffine();if(a===0)return i.set(1,1,1),t.identity(),this;let s=Po.set(r[0],r[1],r[2]).length(),o=Po.set(r[4],r[5],r[6]).length(),u=Po.set(r[8],r[9],r[10]).length();a<0&&(s=-s),Ra.copy(this);let l=1/s,d=1/o,f=1/u;return Ra.elements[0]*=l,Ra.elements[1]*=l,Ra.elements[2]*=l,Ra.elements[4]*=d,Ra.elements[5]*=d,Ra.elements[6]*=d,Ra.elements[8]*=f,Ra.elements[9]*=f,Ra.elements[10]*=f,t.setFromRotationMatrix(Ra),i.x=s,i.y=o,i.z=u,this}makePerspective(e,t,i,r,a,s,o=Da,u=!1){let l=this.elements,d=2*a/(t-e),f=2*a/(i-r),h=(t+e)/(t-e),m=(i+r)/(i-r),y,M;if(u)y=a/(s-a),M=s*a/(s-a);else if(o===Da)y=-(s+a)/(s-a),M=-2*s*a/(s-a);else if(o===Zo)y=-s/(s-a),M=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=f,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=y,l[14]=M,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,a,s,o=Da,u=!1){let l=this.elements,d=2/(t-e),f=2/(i-r),h=-(t+e)/(t-e),m=-(i+r)/(i-r),y,M;if(u)y=1/(s-a),M=s/(s-a);else if(o===Da)y=-2/(s-a),M=-(s+a)/(s-a);else if(o===Zo)y=-1/(s-a),M=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=f,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=y,l[14]=M,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};Td.prototype.isMatrix4=!0;var Kn=Td,Po=new xe,Ra=new Kn,Xy=new xe(0,0,0),Yy=new xe(1,1,1),Rs=new xe,xu=new xe,ua=new xe,cv=new Kn,uv=new ra,ba=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,a=r[0],s=r[4],o=r[8],u=r[1],l=r[5],d=r[9],f=r[2],h=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(fi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-fi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(u,l)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(fi(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(u,a));break;case"ZYX":this._y=Math.asin(-fi(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,m),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(fi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-d,l),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-fi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:En("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return cv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return uv.setFromEuler(this),this.setFromQuaternion(uv,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ba.DEFAULT_ORDER="XYZ";var Ko=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},qy=0,dv=new xe,Lo=new ra,fs=new Kn,_u=new xe,Hl=new xe,Zy=new xe,Jy=new ra,fv=new xe(1,0,0),hv=new xe(0,1,0),pv=new xe(0,0,1),mv={type:"added"},$y={type:"removed"},Do={type:"childadded",child:null},_h={type:"childremoved",child:null},cr=class n extends Za{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qy++}),this.uuid=vo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new xe,t=new ba,i=new ra,r=new xe(1,1,1);function a(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Kn},normalMatrix:{value:new qn}}),this.matrix=new Kn,this.matrixWorld=new Kn,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ko,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Lo.setFromAxisAngle(e,t),this.quaternion.multiply(Lo),this}rotateOnWorldAxis(e,t){return Lo.setFromAxisAngle(e,t),this.quaternion.premultiply(Lo),this}rotateX(e){return this.rotateOnAxis(fv,e)}rotateY(e){return this.rotateOnAxis(hv,e)}rotateZ(e){return this.rotateOnAxis(pv,e)}translateOnAxis(e,t){return dv.copy(e).applyQuaternion(this.quaternion),this.position.add(dv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(fv,e)}translateY(e){return this.translateOnAxis(hv,e)}translateZ(e){return this.translateOnAxis(pv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(fs.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?_u.copy(e):_u.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Hl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?fs.lookAt(Hl,_u,this.up):fs.lookAt(_u,Hl,this.up),this.quaternion.setFromRotationMatrix(fs),r&&(fs.extractRotation(r.matrixWorld),Lo.setFromRotationMatrix(fs),this.quaternion.premultiply(Lo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Un("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(mv),Do.child=e,this.dispatchEvent(Do),Do.child=null):Un("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent($y),_h.child=e,this.dispatchEvent(_h),_h.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),fs.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),fs.multiply(e.parent.matrixWorld)),e.applyMatrix4(fs),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(mv),Do.child=e,this.dispatchEvent(Do),Do.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hl,e,Zy),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hl,Jy,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,i=e.y,r=e.z,a=this.matrix.elements;a[12]+=t-a[0]*t-a[4]*i-a[8]*r,a[13]+=i-a[1]*t-a[5]*i-a[9]*r,a[14]+=r-a[2]*t-a[6]*i-a[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),t===!0){let a=this.children;for(let s=0,o=a.length;s<o;s++)a[s].updateWorldMatrix(!1,!0,i)}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function a(o,u){return o[u.uuid]===void 0&&(o[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let u=o.shapes;if(Array.isArray(u))for(let l=0,d=u.length;l<d;l++){let f=u[l];a(e.shapes,f)}else a(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let u=0,l=this.material.length;u<l;u++)o.push(a(e.materials,this.material[u]));r.material=o}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){let u=this.animations[o];r.animations.push(a(e.animations,u))}}if(t){let o=s(e.geometries),u=s(e.materials),l=s(e.textures),d=s(e.images),f=s(e.shapes),h=s(e.skeletons),m=s(e.animations),y=s(e.nodes);o.length>0&&(i.geometries=o),u.length>0&&(i.materials=u),l.length>0&&(i.textures=l),d.length>0&&(i.images=d),f.length>0&&(i.shapes=f),h.length>0&&(i.skeletons=h),m.length>0&&(i.animations=m),y.length>0&&(i.nodes=y)}return i.object=r,i;function s(o){let u=[];for(let l in o){let d=o[l];delete d.metadata,u.push(d)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};cr.DEFAULT_UP=new xe(0,1,0);cr.DEFAULT_MATRIX_AUTO_UPDATE=!0;cr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var or=class extends cr{constructor(){super(),this.isGroup=!0,this.type="Group"}},Ky={type:"move"},Qo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new or,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new or,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new xe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new xe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new or,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new xe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new xe,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,s=null,o=this._targetRay,u=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){s=!0;for(let M of e.hand.values()){let g=t.getJointPose(M,i),v=this._getHandJoint(l,M);g!==null&&(v.matrix.fromArray(g.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=g.radius),v.visible=g!==null}let d=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],h=d.position.distanceTo(f.position),m=.02,y=.005;l.inputState.pinching&&h>m+y?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=m-y&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(u.matrix.fromArray(a.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,a.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(a.linearVelocity)):u.hasLinearVelocity=!1,a.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(a.angularVelocity)):u.hasAngularVelocity=!1,u.eventsEnabled&&u.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ky)))}return o!==null&&(o.visible=r!==null),u!==null&&(u.visible=a!==null),l!==null&&(l.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new or;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},T0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ps={h:0,s:0,l:0},Mu={h:0,s:0,l:0};function Mh(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}var zn=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=wr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mi.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=mi.workingColorSpace){return this.r=e,this.g=t,this.b=i,mi.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=mi.workingColorSpace){if(e=Vy(e,1),t=fi(t,0,1),i=fi(i,0,1),t===0)this.r=this.g=this.b=i;else{let a=i<=.5?i*(1+t):i+t-i*t,s=2*i-a;this.r=Mh(s,a,e+1/3),this.g=Mh(s,a,e),this.b=Mh(s,a,e-1/3)}return mi.colorSpaceToWorking(this,r),this}setStyle(e,t=wr){function i(a){a!==void 0&&parseFloat(a)<1&&En("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a,s=r[1],o=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:En("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(a,16),t);En("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=wr){let i=T0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):En("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=gs(e.r),this.g=gs(e.g),this.b=gs(e.b),this}copyLinearToSRGB(e){return this.r=Wo(e.r),this.g=Wo(e.g),this.b=Wo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wr){return mi.workingToColorSpace(Ur.copy(this),e),Math.round(fi(Ur.r*255,0,255))*65536+Math.round(fi(Ur.g*255,0,255))*256+Math.round(fi(Ur.b*255,0,255))}getHexString(e=wr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mi.workingColorSpace){mi.workingToColorSpace(Ur.copy(this),t);let i=Ur.r,r=Ur.g,a=Ur.b,s=Math.max(i,r,a),o=Math.min(i,r,a),u,l,d=(o+s)/2;if(o===s)u=0,l=0;else{let f=s-o;switch(l=d<=.5?f/(s+o):f/(2-s-o),s){case i:u=(r-a)/f+(r<a?6:0);break;case r:u=(a-i)/f+2;break;case a:u=(i-r)/f+4;break}u/=6}return e.h=u,e.s=l,e.l=d,e}getRGB(e,t=mi.workingColorSpace){return mi.workingToColorSpace(Ur.copy(this),t),e.r=Ur.r,e.g=Ur.g,e.b=Ur.b,e}getStyle(e=wr){mi.workingToColorSpace(Ur.copy(this),e);let t=Ur.r,i=Ur.g,r=Ur.b;return e!==wr?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Ps),this.setHSL(Ps.h+e,Ps.s+t,Ps.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Ps),e.getHSL(Mu);let i=mh(Ps.h,Mu.h,t),r=mh(Ps.s,Mu.s,t),a=mh(Ps.l,Mu.l,t);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*t+a[3]*i+a[6]*r,this.g=a[1]*t+a[4]*i+a[7]*r,this.b=a[2]*t+a[5]*i+a[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Ur=new zn;zn.NAMES=T0;var rc=class extends cr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ba,this.environmentIntensity=1,this.environmentRotation=new ba,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Pa=new xe,hs=new xe,Sh=new xe,ps=new xe,No=new xe,Uo=new xe,vv=new xe,bh=new xe,wh=new xe,Th=new xe,Ah=new Ni,Eh=new Ni,Ih=new Ni,Us=class n{constructor(e=new xe,t=new xe,i=new xe){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Pa.subVectors(e,t),r.cross(Pa);let a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){Pa.subVectors(r,t),hs.subVectors(i,t),Sh.subVectors(e,t);let s=Pa.dot(Pa),o=Pa.dot(hs),u=Pa.dot(Sh),l=hs.dot(hs),d=hs.dot(Sh),f=s*l-o*o;if(f===0)return a.set(0,0,0),null;let h=1/f,m=(l*u-o*d)*h,y=(s*d-o*u)*h;return a.set(1-m-y,y,m)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,ps)===null?!1:ps.x>=0&&ps.y>=0&&ps.x+ps.y<=1}static getInterpolation(e,t,i,r,a,s,o,u){return this.getBarycoord(e,t,i,r,ps)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(a,ps.x),u.addScaledVector(s,ps.y),u.addScaledVector(o,ps.z),u)}static getInterpolatedAttribute(e,t,i,r,a,s){return Ah.setScalar(0),Eh.setScalar(0),Ih.setScalar(0),Ah.fromBufferAttribute(e,t),Eh.fromBufferAttribute(e,i),Ih.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(Ah,a.x),s.addScaledVector(Eh,a.y),s.addScaledVector(Ih,a.z),s}static isFrontFacing(e,t,i,r){return Pa.subVectors(i,t),hs.subVectors(e,t),Pa.cross(hs).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Pa.subVectors(this.c,this.b),hs.subVectors(this.a,this.b),Pa.cross(hs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,a){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,a=this.c,s,o;No.subVectors(r,i),Uo.subVectors(a,i),bh.subVectors(e,i);let u=No.dot(bh),l=Uo.dot(bh);if(u<=0&&l<=0)return t.copy(i);wh.subVectors(e,r);let d=No.dot(wh),f=Uo.dot(wh);if(d>=0&&f<=d)return t.copy(r);let h=u*f-d*l;if(h<=0&&u>=0&&d<=0)return s=u/(u-d),t.copy(i).addScaledVector(No,s);Th.subVectors(e,a);let m=No.dot(Th),y=Uo.dot(Th);if(y>=0&&m<=y)return t.copy(a);let M=m*l-u*y;if(M<=0&&l>=0&&y<=0)return o=l/(l-y),t.copy(i).addScaledVector(Uo,o);let g=d*y-m*f;if(g<=0&&f-d>=0&&m-y>=0)return vv.subVectors(a,r),o=(f-d)/(f-d+(m-y)),t.copy(r).addScaledVector(vv,o);let v=1/(g+M+h);return s=M*v,o=h*v,t.copy(i).addScaledVector(No,s).addScaledVector(Uo,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Jr=class{constructor(e=new xe(1/0,1/0,1/0),t=new xe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(La.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(La.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=La.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let a=i.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,La):La.fromBufferAttribute(a,s),La.applyMatrix4(e.matrixWorld),this.expandByPoint(La);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Su.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Su.copy(i.boundingBox)),Su.applyMatrix4(e.matrixWorld),this.union(Su)}let r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,La),La.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wl),bu.subVectors(this.max,Wl),Fo.subVectors(e.a,Wl),Oo.subVectors(e.b,Wl),Bo.subVectors(e.c,Wl),Ls.subVectors(Oo,Fo),Ds.subVectors(Bo,Oo),ro.subVectors(Fo,Bo);let t=[0,-Ls.z,Ls.y,0,-Ds.z,Ds.y,0,-ro.z,ro.y,Ls.z,0,-Ls.x,Ds.z,0,-Ds.x,ro.z,0,-ro.x,-Ls.y,Ls.x,0,-Ds.y,Ds.x,0,-ro.y,ro.x,0];return!Ch(t,Fo,Oo,Bo,bu)||(t=[1,0,0,0,1,0,0,0,1],!Ch(t,Fo,Oo,Bo,bu))?!1:(wu.crossVectors(Ls,Ds),t=[wu.x,wu.y,wu.z],Ch(t,Fo,Oo,Bo,bu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,La).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(La).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ms[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ms[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ms[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ms[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ms[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ms[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ms[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ms[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ms),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},ms=[new xe,new xe,new xe,new xe,new xe,new xe,new xe,new xe],La=new xe,Su=new Jr,Fo=new xe,Oo=new xe,Bo=new xe,Ls=new xe,Ds=new xe,ro=new xe,Wl=new xe,bu=new xe,wu=new xe,ao=new xe;function Ch(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){ao.fromArray(n,a);let o=r.x*Math.abs(ao.x)+r.y*Math.abs(ao.y)+r.z*Math.abs(ao.z),u=e.dot(ao),l=t.dot(ao),d=i.dot(ao);if(Math.max(-Math.max(u,l,d),Math.min(u,l,d))>o)return!1}return!0}var nr=new xe,Tu=new tn,Qy=0,Or=class extends Za{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Qy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=_0,this.updateRanges=[],this.gpuType=va,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Tu.fromBufferAttribute(this,t),Tu.applyMatrix3(e),this.setXY(t,Tu.x,Tu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)nr.fromBufferAttribute(this,t),nr.applyMatrix3(e),this.setXYZ(t,nr.x,nr.y,nr.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)nr.fromBufferAttribute(this,t),nr.applyMatrix4(e),this.setXYZ(t,nr.x,nr.y,nr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)nr.fromBufferAttribute(this,t),nr.applyNormalMatrix(e),this.setXYZ(t,nr.x,nr.y,nr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)nr.fromBufferAttribute(this,t),nr.transformDirection(e),this.setXYZ(t,nr.x,nr.y,nr.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Gl(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ia(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Gl(t,this.array)),t}setX(e,t){return this.normalized&&(t=ia(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Gl(t,this.array)),t}setY(e,t){return this.normalized&&(t=ia(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Gl(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ia(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Gl(t,this.array)),t}setW(e,t){return this.normalized&&(t=ia(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ia(t,this.array),i=ia(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ia(t,this.array),i=ia(i,this.array),r=ia(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e*=this.itemSize,this.normalized&&(t=ia(t,this.array),i=ia(i,this.array),r=ia(r,this.array),a=ia(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}};var ac=class extends Or{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var sc=class extends Or{constructor(e,t,i){super(new Uint32Array(e),t,i)}};var Ci=class extends Or{constructor(e,t,i){super(new Float32Array(e),t,i)}},jy=new Jr,Xl=new xe,Rh=new xe,Ja=class{constructor(e=new xe,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):jy.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Xl.subVectors(e,this.center);let t=Xl.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Xl,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Rh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Xl.copy(e.center).add(Rh)),this.expandByPoint(Xl.copy(e.center).sub(Rh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},ex=0,Ma=new Kn,Ph=new cr,ko=new xe,da=new Jr,Yl=new Jr,br=new xe,ur=class n extends Za{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ex++}),this.uuid=vo(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ky(e)?sc:ac)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let a=new qn().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Ma.makeRotationFromQuaternion(e),this.applyMatrix4(Ma),this}rotateX(e){return Ma.makeRotationX(e),this.applyMatrix4(Ma),this}rotateY(e){return Ma.makeRotationY(e),this.applyMatrix4(Ma),this}rotateZ(e){return Ma.makeRotationZ(e),this.applyMatrix4(Ma),this}translate(e,t,i){return Ma.makeTranslation(e,t,i),this.applyMatrix4(Ma),this}scale(e,t,i){return Ma.makeScale(e,t,i),this.applyMatrix4(Ma),this}lookAt(e){return Ph.lookAt(e),Ph.updateMatrix(),this.applyMatrix4(Ph.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ko).negate(),this.translate(ko.x,ko.y,ko.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let i=[];for(let r=0,a=e.length;r<a;r++){let s=e[r];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Ci(i,3))}else{let i=Math.min(e.length,t.count);for(let r=0;r<i;r++){let a=e[r];t.setXYZ(r,a.x,a.y,a.z||0)}e.length>t.count&&En("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Jr);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Un("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new xe(-1/0,-1/0,-1/0),new xe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let a=t[i];da.setFromBufferAttribute(a),this.morphTargetsRelative?(br.addVectors(this.boundingBox.min,da.min),this.boundingBox.expandByPoint(br),br.addVectors(this.boundingBox.max,da.max),this.boundingBox.expandByPoint(br)):(this.boundingBox.expandByPoint(da.min),this.boundingBox.expandByPoint(da.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Un('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ja);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Un("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new xe,1/0);return}if(e){let i=this.boundingSphere.center;if(da.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){let o=t[a];Yl.setFromBufferAttribute(o),this.morphTargetsRelative?(br.addVectors(da.min,Yl.min),da.expandByPoint(br),br.addVectors(da.max,Yl.max),da.expandByPoint(br)):(da.expandByPoint(Yl.min),da.expandByPoint(Yl.max))}da.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)br.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(br));if(t)for(let a=0,s=t.length;a<s;a++){let o=t[a],u=this.morphTargetsRelative;for(let l=0,d=o.count;l<d;l++)br.fromBufferAttribute(o,l),u&&(ko.fromBufferAttribute(e,l),br.add(ko)),r=Math.max(r,i.distanceToSquared(br))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Un('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Un("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,a=t.uv,s=this.getAttribute("tangent");(s===void 0||s.count!==i.count)&&(s=new Or(new Float32Array(4*i.count),4),this.setAttribute("tangent",s));let o=[],u=[];for(let w=0;w<i.count;w++)o[w]=new xe,u[w]=new xe;let l=new xe,d=new xe,f=new xe,h=new tn,m=new tn,y=new tn,M=new xe,g=new xe;function v(w,I,G){l.fromBufferAttribute(i,w),d.fromBufferAttribute(i,I),f.fromBufferAttribute(i,G),h.fromBufferAttribute(a,w),m.fromBufferAttribute(a,I),y.fromBufferAttribute(a,G),d.sub(l),f.sub(l),m.sub(h),y.sub(h);let H=1/(m.x*y.y-y.x*m.y);isFinite(H)&&(M.copy(d).multiplyScalar(y.y).addScaledVector(f,-m.y).multiplyScalar(H),g.copy(f).multiplyScalar(m.x).addScaledVector(d,-y.x).multiplyScalar(H),o[w].add(M),o[I].add(M),o[G].add(M),u[w].add(g),u[I].add(g),u[G].add(g))}let L=this.groups;L.length===0&&(L=[{start:0,count:e.count}]);for(let w=0,I=L.length;w<I;++w){let G=L[w],H=G.start,Q=G.count;for(let T=H,S=H+Q;T<S;T+=3)v(e.getX(T+0),e.getX(T+1),e.getX(T+2))}let p=new xe,_=new xe,N=new xe,D=new xe;function V(w){N.fromBufferAttribute(r,w),D.copy(N);let I=o[w];p.copy(I),p.sub(N.multiplyScalar(N.dot(I))).normalize(),_.crossVectors(D,I);let H=_.dot(u[w])<0?-1:1;s.setXYZW(w,p.x,p.y,p.z,H)}for(let w=0,I=L.length;w<I;++w){let G=L[w],H=G.start,Q=G.count;for(let T=H,S=H+Q;T<S;T+=3)V(e.getX(T+0)),V(e.getX(T+1)),V(e.getX(T+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new Or(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,m=i.count;h<m;h++)i.setXYZ(h,0,0,0);let r=new xe,a=new xe,s=new xe,o=new xe,u=new xe,l=new xe,d=new xe,f=new xe;if(e)for(let h=0,m=e.count;h<m;h+=3){let y=e.getX(h+0),M=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,y),a.fromBufferAttribute(t,M),s.fromBufferAttribute(t,g),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,y),u.fromBufferAttribute(i,M),l.fromBufferAttribute(i,g),o.add(d),u.add(d),l.add(d),i.setXYZ(y,o.x,o.y,o.z),i.setXYZ(M,u.x,u.y,u.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,m=t.count;h<m;h+=3)r.fromBufferAttribute(t,h+0),a.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),i.setXYZ(h+0,d.x,d.y,d.z),i.setXYZ(h+1,d.x,d.y,d.z),i.setXYZ(h+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)br.fromBufferAttribute(e,t),br.normalize(),e.setXYZ(t,br.x,br.y,br.z)}toNonIndexed(){function e(o,u){let l=o.array,d=o.itemSize,f=o.normalized,h=new l.constructor(u.length*d),m=0,y=0;for(let M=0,g=u.length;M<g;M++){o.isInterleavedBufferAttribute?m=u[M]*o.data.stride+o.offset:m=u[M]*d;for(let v=0;v<d;v++)h[y++]=l[m++]}return new Or(h,d,f)}if(this.index===null)return En("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let o in r){let u=r[o],l=e(u,i);t.setAttribute(o,l)}let a=this.morphAttributes;for(let o in a){let u=[],l=a[o];for(let d=0,f=l.length;d<f;d++){let h=l[d],m=e(h,i);u.push(m)}t.morphAttributes[o]=u}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,u=s.length;o<u;o++){let l=s[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let u=this.parameters;for(let l in u)u[l]!==void 0&&(e[l]=u[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let u in i){let l=i[u];e.data.attributes[u]=l.toJSON(e.data)}let r={},a=!1;for(let u in this.morphAttributes){let l=this.morphAttributes[u],d=[];for(let f=0,h=l.length;f<h;f++){let m=l[f];d.push(m.toJSON(e.data))}d.length>0&&(r[u]=d,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone());let r=e.attributes;for(let l in r){let d=r[l];this.setAttribute(l,d.clone(t))}let a=e.morphAttributes;for(let l in a){let d=[],f=a[l];for(let h=0,m=f.length;h<m;h++)d.push(f[h].clone(t));this.morphAttributes[l]=d}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let l=0,d=s.length;l<d;l++){let f=s[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};var Lh=new xe,tx=new xe,nx=new qn,fa=class{constructor(e=new xe(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Lh.subVectors(i,t).cross(tx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){let r=e.delta(Lh),a=this.normal.dot(r);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/a;return i===!0&&(s<0||s>1)?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||nx.getNormalMatrix(e),r=this.coplanarPoint(Lh).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},ix=0,ys=class extends Za{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ix++}),this.uuid=vo(),this.name="",this.type="Material",this.blending=dl,this.side=$a,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=rp,this.blendDst=ap,this.blendEquation=ho,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new zn(0,0,0),this.blendAlpha=0,this.depthFunc=Yo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=h0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Hu,this.stencilZFail=Hu,this.stencilZPass=Hu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){En(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){En(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector2&&i&&i.isVector2||r&&r.isEuler&&i&&i.isEuler||r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,i.blending=this.blending,i.side=this.side,i.shadowSide=this.shadowSide,i.vertexColors=this.vertexColors,i.opacity=this.opacity,i.transparent=this.transparent,i.blendSrc=this.blendSrc,i.blendDst=this.blendDst,i.blendEquation=this.blendEquation,i.blendSrcAlpha=this.blendSrcAlpha,i.blendDstAlpha=this.blendDstAlpha,i.blendEquationAlpha=this.blendEquationAlpha,i.blendColor=this.blendColor.getHex(),i.blendAlpha=this.blendAlpha,i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.clipIntersection=this.clipIntersection,i.clipShadows=this.clipShadows,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,i.stencilWrite=this.stencilWrite,i.polygonOffset=this.polygonOffset,i.polygonOffsetFactor=this.polygonOffsetFactor,i.polygonOffsetUnits=this.polygonOffsetUnits,i.dithering=this.dithering,i.alphaTest=this.alphaTest,i.alphaHash=this.alphaHash,i.alphaToCoverage=this.alphaToCoverage,i.premultipliedAlpha=this.premultipliedAlpha,i.forceSinglePass=this.forceSinglePass,i.allowOverride=this.allowOverride,i.visible=this.visible,i.toneMapped=this.toneMapped,i.name=this.name,this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(i.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(i.clippingPlanes=this.clippingPlanes.map(a=>a.toJSON())),this.rotation!==void 0&&(i.rotation=this.rotation),this.depthPacking!==void 0&&(i.depthPacking=this.depthPacking),this.linewidth!==void 0&&(i.linewidth=this.linewidth),this.linecap!==void 0&&(i.linecap=this.linecap),this.linejoin!==void 0&&(i.linejoin=this.linejoin),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.wireframe!==void 0&&(i.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(i.flatShading=this.flatShading),this.fog!==void 0&&(i.fog=this.fog),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){let s=[];for(let o in a){let u=a[o];delete u.metadata,s.push(u)}return s}if(t){let a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new zn().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(i=>new fa().fromJSON(i))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new tn().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new tn().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=t[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var vs=new xe,Dh=new xe,Au=new xe,Eu=new xe,jo=class{constructor(e=new xe,t=new xe(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,vs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=vs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(vs.copy(this.origin).addScaledVector(this.direction,t),vs.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Dh.copy(e).add(t).multiplyScalar(.5),Au.copy(t).sub(e).normalize(),Eu.copy(this.origin).sub(Dh);let a=e.distanceTo(t)*.5,s=-this.direction.dot(Au),o=Eu.dot(this.direction),u=-Eu.dot(Au),l=Eu.lengthSq(),d=Math.abs(1-s*s),f,h,m,y;if(d>0)if(f=s*u-o,h=s*o-u,y=a*d,f>=0)if(h>=-y)if(h<=y){let M=1/d;f*=M,h*=M,m=f*(f+s*h+2*o)+h*(s*f+h+2*u)+l}else h=a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;else h=-a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;else h<=-y?(f=Math.max(0,-(-s*a+o)),h=f>0?-a:Math.min(Math.max(-a,-u),a),m=-f*f+h*(h+2*u)+l):h<=y?(f=0,h=Math.min(Math.max(-a,-u),a),m=h*(h+2*u)+l):(f=Math.max(0,-(s*a+o)),h=f>0?a:Math.min(Math.max(-a,-u),a),m=-f*f+h*(h+2*u)+l);else h=s>0?-a:a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(Dh).addScaledVector(Au,h),m}intersectSphere(e,t){if(e.radius<0)return null;vs.subVectors(e.center,this.origin);let i=vs.dot(this.direction),r=vs.dot(vs)-i*i,a=e.radius*e.radius;if(r>a)return null;let s=Math.sqrt(a-r),o=i-s,u=i+s;return u<0?null:o<0?this.at(u,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,a,s,o,u,l=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),d>=0?(a=(e.min.y-h.y)*d,s=(e.max.y-h.y)*d):(a=(e.max.y-h.y)*d,s=(e.min.y-h.y)*d),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-h.z)*f,u=(e.max.z-h.z)*f):(o=(e.max.z-h.z)*f,u=(e.min.z-h.z)*f),i>u||o>r)||((o>i||i!==i)&&(i=o),(u<r||r!==r)&&(r=u),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,vs)!==null}intersectTriangle(e,t,i,r,a){let s=this.origin,o=this.direction,u=o.x,l=o.y,d=o.z,f=e.x-s.x,h=e.y-s.y,m=e.z-s.z,y=t.x-s.x,M=t.y-s.y,g=t.z-s.z,v=i.x-s.x,L=i.y-s.y,p=i.z-s.z,_=Math.abs(u),N=Math.abs(l),D=Math.abs(d),V,w,I,G,H,Q,T,S,Z,q,se,F;if(_>=N&&_>=D?(I=u,Q=f,Z=y,F=v,u>=0?(V=l,w=d,G=h,H=m,T=M,S=g,q=L,se=p):(V=d,w=l,G=m,H=h,T=g,S=M,q=p,se=L)):N>=D?(I=l,Q=h,Z=M,F=L,l>=0?(V=d,w=u,G=m,H=f,T=g,S=y,q=p,se=v):(V=u,w=d,G=f,H=m,T=y,S=g,q=v,se=p)):(I=d,Q=m,Z=g,F=p,d>=0?(V=u,w=l,G=f,H=h,T=y,S=M,q=v,se=L):(V=l,w=u,G=h,H=f,T=M,S=y,q=L,se=v)),I===0)return null;let z=V/I,Y=w/I,$=1/I,he=G-z*Q,pe=H-Y*Q,le=T-z*Z,Te=S-Y*Z,De=q-z*F,oe=se-Y*F,ee=De*Te-oe*le,be=he*oe-pe*De,Be=le*pe-Te*he;if(r){if(ee<0||be<0||Be<0)return null}else if((ee<0||be<0||Be<0)&&(ee>0||be>0||Be>0))return null;let Re=ee+be+Be;if(Re===0)return null;let Ye=$*(ee*Q+be*Z+Be*F);return(Re>0?Ye<0:Ye>0)?null:this.at(Ye/Re,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},sa=class extends ys{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new zn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ba,this.combine=Ed,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},gv=new Kn,so=new jo,Iu=new Ja,yv=new xe,Cu=new xe,Ru=new xe,Pu=new xe,Nh=new xe,Lu=new xe,xv=new xe,Du=new xe,_i=class extends cr{constructor(e=new ur,t=new sa){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){let o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(a&&o){Lu.set(0,0,0);for(let u=0,l=a.length;u<l;u++){let d=o[u],f=a[u];d!==0&&(Nh.fromBufferAttribute(f,e),s?Lu.addScaledVector(Nh,d):Lu.addScaledVector(Nh.sub(t),d))}t.add(Lu)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Iu.copy(i.boundingSphere),Iu.applyMatrix4(a),so.copy(e.ray).recast(e.near),!(Iu.containsPoint(so.origin)===!1&&(so.intersectSphere(Iu,yv)===null||so.origin.distanceToSquared(yv)>(e.far-e.near)**2))&&(gv.copy(a).invert(),so.copy(e.ray).applyMatrix4(gv),!(i.boundingBox!==null&&so.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,so)))}_computeIntersections(e,t,i){let r,a=this.geometry,s=this.material,o=a.index,u=a.attributes.position,l=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,h=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,M=h.length;y<M;y++){let g=h[y],v=s[g.materialIndex],L=Math.max(g.start,m.start),p=Math.min(o.count,Math.min(g.start+g.count,m.start+m.count));for(let _=L,N=p;_<N;_+=3){let D=o.getX(_),V=o.getX(_+1),w=o.getX(_+2);r=Nu(this,v,e,i,l,d,f,D,V,w),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,m.start),M=Math.min(o.count,m.start+m.count);for(let g=y,v=M;g<v;g+=3){let L=o.getX(g),p=o.getX(g+1),_=o.getX(g+2);r=Nu(this,s,e,i,l,d,f,L,p,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(s))for(let y=0,M=h.length;y<M;y++){let g=h[y],v=s[g.materialIndex],L=Math.max(g.start,m.start),p=Math.min(u.count,Math.min(g.start+g.count,m.start+m.count));for(let _=L,N=p;_<N;_+=3){let D=_,V=_+1,w=_+2;r=Nu(this,v,e,i,l,d,f,D,V,w),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,m.start),M=Math.min(u.count,m.start+m.count);for(let g=y,v=M;g<v;g+=3){let L=g,p=g+1,_=g+2;r=Nu(this,s,e,i,l,d,f,L,p,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};function rx(n,e,t,i,r,a,s,o){let u;if(e.side===Kr?u=i.intersectTriangle(s,a,r,!0,o):u=i.intersectTriangle(r,a,s,e.side===$a,o),u===null)return null;Du.copy(o),Du.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Du);return l<t.near||l>t.far?null:{distance:l,point:Du.clone(),object:n}}function Nu(n,e,t,i,r,a,s,o,u,l){n.getVertexPosition(o,Cu),n.getVertexPosition(u,Ru),n.getVertexPosition(l,Pu);let d=rx(n,e,t,i,Cu,Ru,Pu,xv);if(d){let f=new xe;Us.getBarycoord(xv,Cu,Ru,Pu,f),r&&(d.uv=Us.getInterpolatedAttribute(r,o,u,l,f,new tn)),a&&(d.uv1=Us.getInterpolatedAttribute(a,o,u,l,f,new tn)),s&&(d.normal=Us.getInterpolatedAttribute(s,o,u,l,f,new xe),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));let h={a:o,b:u,c:l,normal:new xe,materialIndex:0};Us.getNormal(Cu,Ru,Pu,h.normal),d.face=h,d.barycoord=f}return d}var ql=new Ni,_v=new Ni,Mv=new Ni,ax=new Ni,Sv=new Kn,Uu=new xe,Uh=new Ja,bv=new Kn,Fh=new jo,oc=class extends _i{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Gh,this.bindMatrix=new Kn,this.bindMatrixInverse=new Kn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Jr),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Uu),this.boundingBox.expandByPoint(Uu)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ja),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Uu),this.boundingSphere.expandByPoint(Uu)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Uh.copy(this.boundingSphere),Uh.applyMatrix4(r),e.ray.intersectsSphere(Uh)!==!1&&(bv.copy(r).invert(),Fh.copy(e.ray).applyMatrix4(bv),!(this.boundingBox!==null&&Fh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Fh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Ni,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Gh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===u0?this.bindMatrixInverse.copy(this.bindMatrix).invert():En("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;_v.fromBufferAttribute(r.attributes.skinIndex,e),Mv.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(ql.copy(t),t.set(0,0,0,0)):(ql.set(...t,1),t.set(0,0,0)),ql.applyMatrix4(this.bindMatrix);for(let a=0;a<4;a++){let s=Mv.getComponent(a);if(s!==0){let o=_v.getComponent(a);Sv.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(ax.copy(ql).applyMatrix4(Sv),s)}}return t.isVector4&&(t.w=ql.w),t.applyMatrix4(this.bindMatrixInverse)}},el=class extends cr{constructor(){super(),this.isBone=!0,this.type="Bone"}},Os=class extends Tr{constructor(e=null,t=1,i=1,r,a,s,o,u,l=ir,d=ir,f,h){super(null,s,o,u,l,d,r,a,f,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},wv=new Kn,sx=new Kn,tl=class n{constructor(e=[],t=[]){this.uuid=vo(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){En("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Kn)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Kn;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){let o=e[a]?e[a].matrixWorld:sx;wv.multiplyMatrices(o,t[a]),wv.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Os(t,e,e,ga,va);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let a=e.bones[i],s=t[a];s===void 0&&(En("Skeleton: No bone found with UUID:",a),s=new el),this.bones.push(s),this.boneInverses.push(new Kn().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){let s=t[r];e.bones.push(s.uuid);let o=i[r];e.boneInverses.push(o.toArray())}return e}},lc=class extends Or{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},zo=new Kn,Tv=new Kn,Fu=[],Av=new Jr,ox=new Kn,Zl=new _i,Jl=new Ja,Na=class extends _i{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new lc(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,ox)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Jr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,zo),Av.copy(e.boundingBox).applyMatrix4(zo),this.boundingBox.union(Av)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ja),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,zo),Jl.copy(e.boundingSphere).applyMatrix4(zo),this.boundingSphere.union(Jl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,a=i.length+1,s=e*a+1;for(let o=0;o<i.length;o++)i[o]=r[s+o]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Zl.geometry=this.geometry,Zl.material=this.material,Zl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Jl.copy(this.boundingSphere),Jl.applyMatrix4(i),e.ray.intersectsSphere(Jl)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,zo),Tv.multiplyMatrices(i,zo),Zl.matrixWorld=Tv,Zl.raycast(e,Fu);for(let s=0,o=Fu.length;s<o;s++){let u=Fu[s];u.instanceId=a,u.object=this,t.push(u)}Fu.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new lc(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Os(new Float32Array(r*this.count),r,this.count,Dd,va));let a=this.morphTexture.source.data.data,s=0;for(let l=0;l<i.length;l++)s+=i[l];let o=this.geometry.morphTargetsRelative?1:1-s,u=r*e;return a[u]=o,a.set(i,u+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},oo=new Ja,lx=new tn(.5,.5),Ou=new xe,nl=class{constructor(e=new fa,t=new fa,i=new fa,r=new fa,a=new fa,s=new fa){this.planes=[e,t,i,r,a,s]}set(e,t,i,r,a,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Da,i=!1){let r=this.planes,a=e.elements,s=a[0],o=a[1],u=a[2],l=a[3],d=a[4],f=a[5],h=a[6],m=a[7],y=a[8],M=a[9],g=a[10],v=a[11],L=a[12],p=a[13],_=a[14],N=a[15];if(r[0].setComponents(l-s,m-d,v-y,N-L).normalize(),r[1].setComponents(l+s,m+d,v+y,N+L).normalize(),r[2].setComponents(l+o,m+f,v+M,N+p).normalize(),r[3].setComponents(l-o,m-f,v-M,N-p).normalize(),i)r[4].setComponents(u,h,g,_).normalize(),r[5].setComponents(l-u,m-h,v-g,N-_).normalize();else if(r[4].setComponents(l-u,m-h,v-g,N-_).normalize(),t===Da)r[5].setComponents(l+u,m+h,v+g,N+_).normalize();else if(t===Zo)r[5].setComponents(u,h,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),oo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),oo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(oo)}intersectsSprite(e){oo.center.set(0,0,0);let t=lx.distanceTo(e.center);return oo.radius=.7071067811865476+t,oo.applyMatrix4(e.matrixWorld),this.intersectsSphere(oo)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(Ou.x=r.normal.x>0?e.max.x:e.min.x,Ou.y=r.normal.y>0?e.max.y:e.min.y,Ou.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ou)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var cc=class extends Tr{constructor(e=[],t=Gs,i,r,a,s,o,u,l,d){super(e,t,i,r,a,s,o,u,l,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var Bs=class extends Tr{constructor(e,t,i=Ua,r,a,s,o=ir,u=ir,l,d=qa,f=1){if(d!==qa&&d!==Hs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:f};super(h,r,a,s,o,u,d,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new $o(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},nd=class extends Bs{constructor(e,t=Ua,i=Gs,r,a,s=ir,o=ir,u,l=qa){let d={width:e,height:e,depth:1},f=[d,d,d,d,d,d];super(e,e,t,i,r,a,s,o,u,l),this.image=f,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},uc=class extends Tr{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},$r=class n extends ur{constructor(e=1,t=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};let o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);let u=[],l=[],d=[],f=[],h=0,m=0;y("z","y","x",-1,-1,i,t,e,s,a,0),y("z","y","x",1,-1,i,t,-e,s,a,1),y("x","z","y",1,1,e,i,t,r,s,2),y("x","z","y",1,-1,e,i,-t,r,s,3),y("x","y","z",1,-1,e,t,i,r,a,4),y("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(u),this.setAttribute("position",new Ci(l,3)),this.setAttribute("normal",new Ci(d,3)),this.setAttribute("uv",new Ci(f,2));function y(M,g,v,L,p,_,N,D,V,w,I){let G=_/V,H=N/w,Q=_/2,T=N/2,S=D/2,Z=V+1,q=w+1,se=0,F=0,z=new xe;for(let Y=0;Y<q;Y++){let $=Y*H-T;for(let he=0;he<Z;he++){let pe=he*G-Q;z[M]=pe*L,z[g]=$*p,z[v]=S,l.push(z.x,z.y,z.z),z[M]=0,z[g]=0,z[v]=D>0?1:-1,d.push(z.x,z.y,z.z),f.push(he/V),f.push(1-Y/w),se+=1}}for(let Y=0;Y<w;Y++)for(let $=0;$<V;$++){let he=h+$+Z*Y,pe=h+$+Z*(Y+1),le=h+($+1)+Z*(Y+1),Te=h+($+1)+Z*Y;u.push(he,pe,Te),u.push(pe,le,Te),F+=6}o.addGroup(m,F,I),m+=F,h+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var il=class n extends ur{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let a=[],s=[],o=[],u=[],l=new xe,d=new tn;s.push(0,0,0),o.push(0,0,1),u.push(.5,.5);for(let f=0,h=3;f<=t;f++,h+=3){let m=i+f/t*r;l.x=e*Math.cos(m),l.y=e*Math.sin(m),s.push(l.x,l.y,l.z),o.push(0,0,1),d.x=(s[h]/e+1)/2,d.y=(s[h+1]/e+1)/2,u.push(d.x,d.y)}for(let f=1;f<=t;f++)a.push(f,f+1,0);this.setIndex(a),this.setAttribute("position",new Ci(s,3)),this.setAttribute("normal",new Ci(o,3)),this.setAttribute("uv",new Ci(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},co=class n extends ur{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,o=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:o,thetaLength:u};let l=this;r=Math.floor(r),a=Math.floor(a);let d=[],f=[],h=[],m=[],y=0,M=[],g=i/2,v=0;L(),s===!1&&(e>0&&p(!0),t>0&&p(!1)),this.setIndex(d),this.setAttribute("position",new Ci(f,3)),this.setAttribute("normal",new Ci(h,3)),this.setAttribute("uv",new Ci(m,2));function L(){let _=new xe,N=new xe,D=0,V=(t-e)/i;for(let w=0;w<=a;w++){let I=[],G=w/a,H=G*(t-e)+e;for(let Q=0;Q<=r;Q++){let T=Q/r,S=T*u+o,Z=Math.sin(S),q=Math.cos(S);N.x=H*Z,N.y=-G*i+g,N.z=H*q,f.push(N.x,N.y,N.z),_.set(Z,V,q).normalize(),h.push(_.x,_.y,_.z),m.push(T,1-G),I.push(y++)}M.push(I)}for(let w=0;w<r;w++)for(let I=0;I<a;I++){let G=M[I][w],H=M[I+1][w],Q=M[I+1][w+1],T=M[I][w+1];(e>0||I!==0)&&(d.push(G,H,T),D+=3),(t>0||I!==a-1)&&(d.push(H,Q,T),D+=3)}l.addGroup(v,D,0),v+=D}function p(_){let N=y,D=new tn,V=new xe,w=0,I=_===!0?e:t,G=_===!0?1:-1;for(let Q=1;Q<=r;Q++)f.push(0,g*G,0),h.push(0,G,0),m.push(.5,.5),y++;let H=y;for(let Q=0;Q<=r;Q++){let S=Q/r*u+o,Z=Math.cos(S),q=Math.sin(S);V.x=I*q,V.y=g*G,V.z=I*Z,f.push(V.x,V.y,V.z),h.push(0,G,0),D.x=Z*.5+.5,D.y=q*.5*G+.5,m.push(D.x,D.y),y++}for(let Q=0;Q<r;Q++){let T=N+Q,S=H+Q;_===!0?d.push(S,S+1,T):d.push(S+1,S,T),w+=3}l.addGroup(v,w,_===!0?1:2),v+=w}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};var ha=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){En("Curve: .getPoint() not implemented.")}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let o=0,u=a-1,l;for(;o<=u;)if(r=Math.floor(o+(u-o)/2),l=i[r]-s,l<0)o=r+1;else if(l>0)u=r-1;else{u=r;break}if(r=u,i[r]===s)return r/(a-1);let d=i[r],h=i[r+1]-d,m=(s-d)/h;return(r+m)/(a-1)}getTangent(e,t){let r=e-1e-4,a=e+1e-4;r<0&&(r=0),a>1&&(a=1);let s=this.getPoint(r),o=this.getPoint(a),u=t||(s.isVector2?new tn:new xe);return u.copy(o).sub(s).normalize(),u}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){let i=new xe,r=[],a=[],s=[],o=new xe,u=new Kn;for(let m=0;m<=e;m++){let y=m/e;r[m]=this.getTangentAt(y,new xe)}a[0]=new xe,s[0]=new xe;let l=Number.MAX_VALUE,d=Math.abs(r[0].x),f=Math.abs(r[0].y),h=Math.abs(r[0].z);d<=l&&(l=d,i.set(1,0,0)),f<=l&&(l=f,i.set(0,1,0)),h<=l&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],o),s[0].crossVectors(r[0],a[0]);for(let m=1;m<=e;m++){if(a[m]=a[m-1].clone(),s[m]=s[m-1].clone(),o.crossVectors(r[m-1],r[m]),o.length()>Number.EPSILON){o.normalize();let y=Math.acos(fi(r[m-1].dot(r[m]),-1,1));a[m].applyMatrix4(u.makeRotationAxis(o,y))}s[m].crossVectors(r[m],a[m])}if(t===!0){let m=Math.acos(fi(a[0].dot(a[e]),-1,1));m/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(m=-m);for(let y=1;y<=e;y++)a[y].applyMatrix4(u.makeRotationAxis(r[y],m*y)),s[y].crossVectors(r[y],a[y])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},rl=class extends ha{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,o=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=o,this.aRotation=u}getPoint(e,t=new tn){let i=t,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let o=this.aStartAngle+e*a,u=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let d=Math.cos(this.aRotation),f=Math.sin(this.aRotation),h=u-this.aX,m=l-this.aY;u=h*d-m*f+this.aX,l=h*f+m*d+this.aY}return i.set(u,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},id=class extends rl{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function _p(){let n=0,e=0,t=0,i=0;function r(a,s,o,u){n=a,e=o,t=-3*a+3*s-2*o-u,i=2*a-2*s+o+u}return{initCatmullRom:function(a,s,o,u,l){r(s,o,l*(o-a),l*(u-s))},initNonuniformCatmullRom:function(a,s,o,u,l,d,f){let h=(s-a)/l-(o-a)/(l+d)+(o-s)/d,m=(o-s)/d-(u-s)/(d+f)+(u-o)/f;h*=d,m*=d,r(s,o,h,m)},calc:function(a){let s=a*a,o=s*a;return n+e*a+t*s+i*o}}}var Ev=new xe,Iv=new xe,Oh=new _p,Bh=new _p,kh=new _p,rd=class extends ha{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new xe){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,o=Math.floor(s),u=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:u===0&&o===a-1&&(o=a-2,u=1);let l,d;this.closed||o>0?l=r[(o-1)%a]:(Iv.subVectors(r[0],r[1]).add(r[0]),l=Iv);let f=r[o%a],h=r[(o+1)%a];if(this.closed||o+2<a?d=r[(o+2)%a]:(Ev.subVectors(r[a-1],r[a-2]).add(r[a-1]),d=Ev),this.curveType==="centripetal"||this.curveType==="chordal"){let m=this.curveType==="chordal"?.5:.25,y=Math.pow(l.distanceToSquared(f),m),M=Math.pow(f.distanceToSquared(h),m),g=Math.pow(h.distanceToSquared(d),m);M<1e-4&&(M=1),y<1e-4&&(y=M),g<1e-4&&(g=M),Oh.initNonuniformCatmullRom(l.x,f.x,h.x,d.x,y,M,g),Bh.initNonuniformCatmullRom(l.y,f.y,h.y,d.y,y,M,g),kh.initNonuniformCatmullRom(l.z,f.z,h.z,d.z,y,M,g)}else this.curveType==="catmullrom"&&(Oh.initCatmullRom(l.x,f.x,h.x,d.x,this.tension),Bh.initCatmullRom(l.y,f.y,h.y,d.y,this.tension),kh.initCatmullRom(l.z,f.z,h.z,d.z,this.tension));return i.set(Oh.calc(u),Bh.calc(u),kh.calc(u)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new xe().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Cv(n,e,t,i,r){let a=(i-e)*.5,s=(r-t)*.5,o=n*n,u=n*o;return(2*t-2*i+a+s)*u+(-3*t+3*i-2*a-s)*o+a*n+t}function cx(n,e){let t=1-n;return t*t*e}function ux(n,e){return 2*(1-n)*n*e}function dx(n,e){return n*n*e}function Kl(n,e,t,i){return cx(n,e)+ux(n,t)+dx(n,i)}function fx(n,e){let t=1-n;return t*t*t*e}function hx(n,e){let t=1-n;return 3*t*t*n*e}function px(n,e){return 3*(1-n)*n*n*e}function mx(n,e){return n*n*n*e}function Ql(n,e,t,i,r){return fx(n,e)+hx(n,t)+px(n,i)+mx(n,r)}var dc=class extends ha{constructor(e=new tn,t=new tn,i=new tn,r=new tn){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new tn){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(Ql(e,r.x,a.x,s.x,o.x),Ql(e,r.y,a.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ad=class extends ha{constructor(e=new xe,t=new xe,i=new xe,r=new xe){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new xe){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(Ql(e,r.x,a.x,s.x,o.x),Ql(e,r.y,a.y,s.y,o.y),Ql(e,r.z,a.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},fc=class extends ha{constructor(e=new tn,t=new tn){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new tn){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new tn){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},sd=class extends ha{constructor(e=new xe,t=new xe){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new xe){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new xe){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},hc=class extends ha{constructor(e=new tn,t=new tn,i=new tn){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new tn){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(Kl(e,r.x,a.x,s.x),Kl(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},od=class extends ha{constructor(e=new xe,t=new xe,i=new xe){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new xe){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(Kl(e,r.x,a.x,s.x),Kl(e,r.y,a.y,s.y),Kl(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},pc=class extends ha{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new tn){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),o=a-s,u=r[s===0?s:s-1],l=r[s],d=r[s>r.length-2?r.length-1:s+1],f=r[s>r.length-3?r.length-1:s+2];return i.set(Cv(o,u.x,l.x,d.x,f.x),Cv(o,u.y,l.y,d.y,f.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new tn().fromArray(r))}return this}},Rv=Object.freeze({__proto__:null,ArcCurve:id,CatmullRomCurve3:rd,CubicBezierCurve:dc,CubicBezierCurve3:ad,EllipseCurve:rl,LineCurve:fc,LineCurve3:sd,QuadraticBezierCurve:hc,QuadraticBezierCurve3:od,SplineCurve:pc}),ld=class extends ha{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Rv[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,o=this.curves[a],u=o.getLength(),l=u===0?0:1-s/u;return o.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],o=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,u=s.getPoints(o);for(let l=0;l<u.length;l++){let d=u[l];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Rv[r.type]().fromJSON(r))}return this}},uo=class extends ld{constructor(e){super(),this.type="Path",this.currentPoint=new tn,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new fc(this.currentPoint.clone(),new tn(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new hc(this.currentPoint.clone(),new tn(e,t),new tn(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let o=new dc(this.currentPoint.clone(),new tn(e,t),new tn(i,r),new tn(a,s));return this.curves.push(o),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new pc(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let o=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+o,t+u,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,o,u){let l=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+l,t+d,i,r,a,s,o,u),this}absellipse(e,t,i,r,a,s,o,u){let l=new rl(e,t,i,r,a,s,o,u);if(this.curves.length>0){let f=l.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(l);let d=l.getPoint(1);return this.currentPoint.copy(d),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},al=class extends uo{constructor(e){super(e),this.uuid=vo(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new uo().fromJSON(r))}return this}};function vx(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,a=A0(n,0,r,t,!0),s=[];if(!a||a.next===a.prev)return s;let o,u,l;if(i&&(a=Mx(n,e,a,t)),n.length>80*t){o=n[0],u=n[1];let d=o,f=u;for(let h=t;h<r;h+=t){let m=n[h],y=n[h+1];m<o&&(o=m),y<u&&(u=y),m>d&&(d=m),y>f&&(f=y)}l=Math.max(d-o,f-u),l=l!==0?32767/l:0}return mc(a,s,t,o,u,l,0),s}function A0(n,e,t,i,r){let a;if(r===Lx(n,e,t,i)>0)for(let s=e;s<t;s+=i)a=Pv(s/i|0,n[s],n[s+1],a);else for(let s=t-i;s>=e;s-=i)a=Pv(s/i|0,n[s],n[s+1],a);return a&&sl(a,a.next)&&(gc(a),a=a.next),a}function fo(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(sl(t,t.next)||Zi(t.prev,t,t.next)===0)){if(gc(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function mc(n,e,t,i,r,a,s){if(!n)return;!s&&a&&Ax(n,i,r,a);let o=n;for(;n.prev!==n.next;){let u=n.prev,l=n.next;if(a?yx(n,i,r,a):gx(n)){e.push(u.i,n.i,l.i),gc(n),n=l.next,o=l.next;continue}if(n=l,n===o){s?s===1?(n=xx(fo(n),e),mc(n,e,t,i,r,a,2)):s===2&&_x(n,e,t,i,r,a):mc(fo(n),e,t,i,r,a,1);break}}}function gx(n){let e=n.prev,t=n,i=n.next;if(Zi(e,t,i)>=0)return!1;let r=e.x,a=t.x,s=i.x,o=e.y,u=t.y,l=i.y,d=Math.min(r,a,s),f=Math.min(o,u,l),h=Math.max(r,a,s),m=Math.max(o,u,l),y=i.next;for(;y!==e;){if(y.x>=d&&y.x<=h&&y.y>=f&&y.y<=m&&$l(r,o,a,u,s,l,y.x,y.y)&&Zi(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function yx(n,e,t,i){let r=n.prev,a=n,s=n.next;if(Zi(r,a,s)>=0)return!1;let o=r.x,u=a.x,l=s.x,d=r.y,f=a.y,h=s.y,m=Math.min(o,u,l),y=Math.min(d,f,h),M=Math.max(o,u,l),g=Math.max(d,f,h),v=qh(m,y,e,t,i),L=qh(M,g,e,t,i),p=n.prevZ,_=n.nextZ;for(;p&&p.z>=v&&_&&_.z<=L;){if(p.x>=m&&p.x<=M&&p.y>=y&&p.y<=g&&p!==r&&p!==s&&$l(o,d,u,f,l,h,p.x,p.y)&&Zi(p.prev,p,p.next)>=0||(p=p.prevZ,_.x>=m&&_.x<=M&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&$l(o,d,u,f,l,h,_.x,_.y)&&Zi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;p&&p.z>=v;){if(p.x>=m&&p.x<=M&&p.y>=y&&p.y<=g&&p!==r&&p!==s&&$l(o,d,u,f,l,h,p.x,p.y)&&Zi(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;_&&_.z<=L;){if(_.x>=m&&_.x<=M&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&$l(o,d,u,f,l,h,_.x,_.y)&&Zi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function xx(n,e){let t=n;do{let i=t.prev,r=t.next.next;!sl(i,r)&&I0(i,t,t.next,r)&&vc(i,r)&&vc(r,i)&&(e.push(i.i,t.i,r.i),gc(t),gc(t.next),t=n=r),t=t.next}while(t!==n);return fo(t)}function _x(n,e,t,i,r,a){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&Cx(s,o)){let u=C0(s,o);s=fo(s,s.next),u=fo(u,u.next),mc(s,e,t,i,r,a,0),mc(u,e,t,i,r,a,0);return}o=o.next}s=s.next}while(s!==n)}function Mx(n,e,t,i){let r=[];for(let a=0,s=e.length;a<s;a++){let o=e[a]*i,u=a<s-1?e[a+1]*i:n.length,l=A0(n,o,u,i,!1);l===l.next&&(l.steiner=!0),r.push(Ix(l))}r.sort(Sx);for(let a=0;a<r.length;a++)t=bx(r[a],t);return t}function Sx(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){let i=(n.next.y-n.y)/(n.next.x-n.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=i-r}return t}function bx(n,e){let t=wx(n,e);if(!t)return e;let i=C0(t,n);return fo(i,i.next),fo(t,t.next)}function wx(n,e){let t=e,i=n.x,r=n.y,a=-1/0,s;if(sl(n,t))return t;do{if(sl(n,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){let f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=i&&f>a&&(a=f,s=t.x<t.next.x?t:t.next,f===i))return s}t=t.next}while(t!==e);if(!s)return null;let o=s,u=s.x,l=s.y,d=1/0;t=s;do{if(i>=t.x&&t.x>=u&&i!==t.x&&E0(r<l?i:a,r,u,l,r<l?a:i,r,t.x,t.y)){let f=Math.abs(r-t.y)/(i-t.x);vc(t,n)&&(f<d||f===d&&(t.x>s.x||t.x===s.x&&Tx(s,t)))&&(s=t,d=f)}t=t.next}while(t!==o);return s}function Tx(n,e){return Zi(n.prev,n,e.prev)<0&&Zi(e.next,n,n.next)<0}function Ax(n,e,t,i){let r=n;do r.z===0&&(r.z=qh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,Ex(r)}function Ex(n){let e,t=1;do{let i=n,r;n=null;let a=null;for(e=0;i;){e++;let s=i,o=0;for(let l=0;l<t&&(o++,s=s.nextZ,!!s);l++);let u=t;for(;o>0||u>0&&s;)o!==0&&(u===0||!s||i.z<=s.z)?(r=i,i=i.nextZ,o--):(r=s,s=s.nextZ,u--),a?a.nextZ=r:n=r,r.prevZ=a,a=r;i=s}a.nextZ=null,t*=2}while(e>1);return n}function qh(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Ix(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function E0(n,e,t,i,r,a,s,o){return(r-s)*(e-o)>=(n-s)*(a-o)&&(n-s)*(i-o)>=(t-s)*(e-o)&&(t-s)*(a-o)>=(r-s)*(i-o)}function $l(n,e,t,i,r,a,s,o){return!(n===s&&e===o)&&E0(n,e,t,i,r,a,s,o)}function Cx(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Rx(n,e)&&(vc(n,e)&&vc(e,n)&&Px(n,e)&&(Zi(n.prev,n,e.prev)||Zi(n,e.prev,e))||sl(n,e)&&Zi(n.prev,n,n.next)>0&&Zi(e.prev,e,e.next)>0)}function Zi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function sl(n,e){return n.x===e.x&&n.y===e.y}function I0(n,e,t,i){let r=ku(Zi(n,e,t)),a=ku(Zi(n,e,i)),s=ku(Zi(t,i,n)),o=ku(Zi(t,i,e));return!!(r!==a&&s!==o||r===0&&Bu(n,t,e)||a===0&&Bu(n,i,e)||s===0&&Bu(t,n,i)||o===0&&Bu(t,e,i))}function Bu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ku(n){return n>0?1:n<0?-1:0}function Rx(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&I0(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function vc(n,e){return Zi(n.prev,n,n.next)<0?Zi(n,e,n.next)>=0&&Zi(n,n.prev,e)>=0:Zi(n,e,n.prev)<0||Zi(n,n.next,e)<0}function Px(n,e){let t=n,i=!1,r=(n.x+e.x)/2,a=(n.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&r<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function C0(n,e){let t=Zh(n.i,n.x,n.y),i=Zh(e.i,e.x,e.y),r=n.next,a=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,a.next=i,i.prev=a,i}function Pv(n,e,t,i){let r=Zh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function gc(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Zh(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Lx(n,e,t,i){let r=0;for(let a=e,s=t-i;a<t;a+=i)r+=(n[s]-n[a])*(n[a+1]+n[s+1]),s=a;return r}var Jh=class{static triangulate(e,t,i=2){return vx(e,t,i)}},Xo=class n{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];Lv(e),Dv(i,e);let s=e.length;t.forEach(Lv);for(let u=0;u<t.length;u++)r.push(s),s+=t[u].length,Dv(i,t[u]);let o=Jh.triangulate(i,r);for(let u=0;u<o.length;u+=3)a.push(o.slice(u,u+3));return a}};function Lv(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Dv(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var yc=class n extends ur{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let a=e/2,s=t/2,o=Math.floor(i),u=Math.floor(r),l=o+1,d=u+1,f=e/o,h=t/u,m=[],y=[],M=[],g=[];for(let v=0;v<d;v++){let L=v*h-s;for(let p=0;p<l;p++){let _=p*f-a;y.push(_,-L,0),M.push(0,0,1),g.push(p/o),g.push(1-v/u)}}for(let v=0;v<u;v++)for(let L=0;L<o;L++){let p=L+l*v,_=L+l*(v+1),N=L+1+l*(v+1),D=L+1+l*v;m.push(p,_,D),m.push(_,N,D)}this.setIndex(m),this.setAttribute("position",new Ci(y,3)),this.setAttribute("normal",new Ci(M,3)),this.setAttribute("uv",new Ci(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},ol=class n extends ur{constructor(e=.5,t=1,i=32,r=1,a=0,s=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:a,thetaLength:s},i=Math.max(3,i),r=Math.max(1,r);let o=[],u=[],l=[],d=[],f=e,h=(t-e)/r,m=new xe,y=new tn;for(let M=0;M<=r;M++){for(let g=0;g<=i;g++){let v=a+g/i*s;m.x=f*Math.cos(v),m.y=f*Math.sin(v),u.push(m.x,m.y,m.z),l.push(0,0,1),y.x=(m.x/t+1)/2,y.y=(m.y/t+1)/2,d.push(y.x,y.y)}f+=h}for(let M=0;M<r;M++){let g=M*(i+1);for(let v=0;v<i;v++){let L=v+g,p=L,_=L+i+1,N=L+i+2,D=L+1;o.push(p,_,D),o.push(_,N,D)}}this.setIndex(o),this.setAttribute("position",new Ci(u,3)),this.setAttribute("normal",new Ci(l,3)),this.setAttribute("uv",new Ci(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},xc=class n extends ur{constructor(e=new al([new tn(0,.5),new tn(-.5,-.5),new tn(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],a=[],s=[],o=0,u=0;if(Array.isArray(e)===!1)l(e);else for(let d=0;d<e.length;d++)l(e[d]),this.addGroup(o,u,d),o+=u,u=0;this.setIndex(i),this.setAttribute("position",new Ci(r,3)),this.setAttribute("normal",new Ci(a,3)),this.setAttribute("uv",new Ci(s,2));function l(d){let f=r.length/3,h=d.extractPoints(t),m=h.shape,y=h.holes;Xo.isClockWise(m)===!1&&(m=m.reverse());for(let g=0,v=y.length;g<v;g++){let L=y[g];Xo.isClockWise(L)===!0&&(y[g]=L.reverse())}let M=Xo.triangulateShape(m,y);for(let g=0,v=y.length;g<v;g++){let L=y[g];m=m.concat(L)}for(let g=0,v=m.length;g<v;g++){let L=m[g];r.push(L.x,L.y,0),a.push(0,0,1),s.push(L.x,L.y)}for(let g=0,v=M.length;g<v;g++){let L=M[g],p=L[0]+f,_=L[1]+f,N=L[2]+f;i.push(p,_,N),u+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return Dx(t,e)}static fromJSON(e,t){let i=[];for(let r=0,a=e.shapes.length;r<a;r++){let s=t[e.shapes[r]];i.push(s)}return new n(i,e.curveSegments)}};function Dx(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}var xs=class n extends ur{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let u=Math.min(s+o,Math.PI),l=0,d=[],f=new xe,h=new xe,m=[],y=[],M=[],g=[];for(let v=0;v<=i;v++){let L=[],p=v/i,_=s+p*o,N=e*Math.cos(_),D=Math.sqrt(e*e-N*N),V=0;v===0&&s===0?V=.5/t:v===i&&u===Math.PI&&(V=-.5/t);for(let w=0;w<=t;w++){let I=w/t,G=r+I*a;f.x=-D*Math.cos(G),f.y=N,f.z=D*Math.sin(G),y.push(f.x,f.y,f.z),h.copy(f).normalize(),M.push(h.x,h.y,h.z),g.push(I+V,1-p),L.push(l++)}d.push(L)}for(let v=0;v<i;v++)for(let L=0;L<t;L++){let p=d[v][L+1],_=d[v][L],N=d[v+1][L],D=d[v+1][L+1];(v!==0||s>0)&&m.push(p,_,D),(v!==i-1||u<Math.PI)&&m.push(_,N,D)}this.setIndex(m),this.setAttribute("position",new Ci(y,3)),this.setAttribute("normal",new Ci(M,3)),this.setAttribute("uv",new Ci(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};function go(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];if(Nv(r))r.isRenderTargetTexture?(En("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone();else if(Array.isArray(r))if(Nv(r[0])){let a=[];for(let s=0,o=r.length;s<o;s++)a[s]=r[s].clone();e[t][i]=a}else e[t][i]=r.slice();else e[t][i]=r}}return e}function kr(n){let e={};for(let t=0;t<n.length;t++){let i=go(n[t]);for(let r in i)e[r]=i[r]}return e}function Nv(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function Nx(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Mp(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:mi.workingColorSpace}var R0={clone:go,merge:kr},Ux=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
-
}`,
|
|
3
|
+
}`,Fx=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`,ea=class extends ls{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=fx,this.fragmentShader=hx,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=po(e.uniforms),this.uniformsGroups=dx(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let i in e.uniforms){let r=e.uniforms[i];switch(this.uniforms[i]={},r.type){case"t":this.uniforms[i].value=t[r.value]||null;break;case"c":this.uniforms[i].value=new Rn().setHex(r.value);break;case"v2":this.uniforms[i].value=new qt().fromArray(r.value);break;case"v3":this.uniforms[i].value=new ge().fromArray(r.value);break;case"v4":this.uniforms[i].value=new Si().fromArray(r.value);break;case"m3":this.uniforms[i].value=new Ln().fromArray(r.value);break;case"m4":this.uniforms[i].value=new Un().fromArray(r.value);break;default:this.uniforms[i].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},nd=class extends ea{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},ll=class extends ls{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Rn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ha,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};var or=class extends ls{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Rn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ha,this.combine=_d,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},id=class extends ls{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Yv,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},rd=class extends ls{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Vo(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Ah(n){return n!==void 0&&n.inTangents!==void 0&&n.outTangents!==void 0}var As=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;n:{i:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<a)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break n}if(!(e>=a)){let o=t[1];e<o&&(i=2,a=o);for(let u=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===u)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break n}break e}for(;i<s;){let o=i+s>>>1;e<t[o]?s=o:i=o+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},ad=class extends As{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ph,endingEnd:Ph}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,o=r[a],u=r[s];if(o===void 0)switch(this.getSettings_().endingStart){case Lh:a=e,o=2*t-i;break;case Dh:a=r.length-2,o=t+r[a]-r[a+1];break;default:a=e,o=i}if(u===void 0)switch(this.getSettings_().endingEnd){case Lh:s=e,u=2*i-t;break;case Dh:s=1,u=i+r[1]-r[0];break;default:s=e-1,u=t}let l=(i-t)*.5,d=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(u-i),this._offsetPrev=a*d,this._offsetNext=s*d}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this._offsetPrev,f=this._offsetNext,h=this._weightPrev,m=this._weightNext,y=(i-t)/(r-t),M=y*y,g=M*y,v=-h*g+2*h*M-h*y,P=(1+h)*g+(-1.5-2*h)*M+(-.5+h)*y+1,p=(-1-m)*g+(1.5+m)*M+.5*y,_=m*g-m*M;for(let N=0;N!==o;++N)a[N]=v*s[d+N]+P*s[l+N]+p*s[u+N]+_*s[f+N];return a}},sd=class extends As{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=(i-t)/(r-t),f=1-d;for(let h=0;h!==o;++h)a[h]=s[l+h]*f+s[u+h]*d;return a}},od=class extends As{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},ld=class extends As{interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this.inTangents,f=this.outTangents;if(!d||!f){let y=(i-t)/(r-t),M=1-y;for(let g=0;g!==o;++g)a[g]=s[l+g]*M+s[u+g]*y;return a}let h=o*2,m=e-1;for(let y=0;y!==o;++y){let M=s[l+y],g=s[u+y],v=m*h+y*2,P=f[v],p=f[v+1],_=e*h+y*2,N=d[_],D=d[_+1],B=mx(i,t,P,N,r);a[y]=f0(B,M,p,D,g)}return a}};function f0(n,e,t,i,r){let a=1-n;return a*a*a*e+3*a*a*n*t+3*a*n*n*i+n*n*n*r}function px(n,e,t,i,r){let a=1-n;return 3*a*a*(t-e)+6*a*n*(i-t)+3*n*n*(r-i)}function mx(n,e,t,i,r){let a=(n-e)/(r-e);for(let s=0;s<8;s++){let o=f0(a,e,t,i,r)-n;if(Math.abs(o)<1e-10)break;let u=px(a,e,t,i,r);if(Math.abs(u)<1e-10)break;a=Math.max(0,Math.min(1,a-o/u))}return a}var ta=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Vo(t,this.TimeBufferType),this.values=Vo(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Vo(e.times,Array),values:Vo(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r),Ah(e.settings)&&(i.settings={inTangents:Vo(e.settings.inTangents,Array),outTangents:Vo(e.settings.outTangents,Array)})}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new od(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new sd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ad(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new ld(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case $l:t=this.InterpolantFactoryMethodDiscrete;break;case Wu:t=this.InterpolantFactoryMethodLinear;break;case Uu:t=this.InterpolantFactoryMethodSmooth;break;case Rh:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return mn("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return $l;case this.InterpolantFactoryMethodLinear:return Wu;case this.InterpolantFactoryMethodSmooth:return Uu;case this.InterpolantFactoryMethodBezier:return Rh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e;Ah(this.settings)&&(vv(this.settings.inTangents,e),vv(this.settings.outTangents,e))}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let o=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Tn("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(Tn("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let o=0;o!==a;o++){let u=i[o];if(typeof u=="number"&&isNaN(u)){Tn("KeyframeTrack: Time is not a valid number.",this,o,u),e=!1;break}if(s!==null&&s>u){Tn("KeyframeTrack: Out of order keys.",this,o,u,s),e=!1;break}s=u}if(r!==void 0&&gy(r))for(let o=0,u=r.length;o!==u;++o){let l=r[o];if(isNaN(l)){Tn("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Uu,a=e.length-1,s=1;for(let o=1;o<a;++o){let u=!1,l=e[o],d=e[o+1];if(l!==d&&(o!==1||l!==e[0]))if(r)u=!0;else{let f=o*i,h=f-i,m=f+i;for(let y=0;y!==i;++y){let M=t[f+y];if(M!==t[h+y]||M!==t[m+y]){u=!0;break}}}if(u){if(o!==s){e[s]=e[o];let f=o*i,h=s*i;for(let m=0;m!==i;++m)t[h+m]=t[f+m]}++s}}if(a>0){e[s]=e[a];for(let o=a*i,u=s*i,l=0;l!==i;++l)t[u+l]=t[o+l];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,Ah(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function vv(n,e){for(let t=0,i=n.length;t!==i;t+=2)n[t]*=e}ta.prototype.ValueTypeName="";ta.prototype.TimeBufferType=Float32Array;ta.prototype.ValueBufferType=Float32Array;ta.prototype.DefaultInterpolation=Wu;var Is=class extends ta{constructor(e,t,i){super(e,t,i)}};Is.prototype.ValueTypeName="bool";Is.prototype.ValueBufferType=Array;Is.prototype.DefaultInterpolation=$l;Is.prototype.InterpolantFactoryMethodLinear=void 0;Is.prototype.InterpolantFactoryMethodSmooth=void 0;var cd=class extends ta{constructor(e,t,i,r){super(e,t,i,r)}};cd.prototype.ValueTypeName="color";var ud=class extends ta{constructor(e,t,i,r){super(e,t,i,r)}};ud.prototype.ValueTypeName="number";var dd=class extends As{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=(i-t)/(r-t),l=e*o;for(let d=l+o;l!==d;l+=4)kr.slerpFlat(a,0,s,l-o,s,l,u);return a}},gc=class extends ta{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new dd(this.times,this.values,this.getValueSize(),e)}};gc.prototype.ValueTypeName="quaternion";gc.prototype.InterpolantFactoryMethodSmooth=void 0;var Cs=class extends ta{constructor(e,t,i){super(e,t,i)}};Cs.prototype.ValueTypeName="string";Cs.prototype.ValueBufferType=Array;Cs.prototype.DefaultInterpolation=$l;Cs.prototype.InterpolantFactoryMethodLinear=void 0;Cs.prototype.InterpolantFactoryMethodSmooth=void 0;var fd=class extends ta{constructor(e,t,i,r){super(e,t,i,r)}};fd.prototype.ValueTypeName="vector";var hd=class{constructor(e,t,i){let r=this,a=!1,s=0,o=0,u,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(d){o++,a===!1&&r.onStart!==void 0&&r.onStart(d,s,o),a=!0},this.itemEnd=function(d){s++,r.onProgress!==void 0&&r.onProgress(d,s,o),s===o&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return d=d.normalize("NFC"),u?u(d):d},this.setURLModifier=function(d){return u=d,this},this.addHandler=function(d,f){return l.push(d,f),this},this.removeHandler=function(d){let f=l.indexOf(d);return f!==-1&&l.splice(f,2),this},this.getHandler=function(d){for(let f=0,h=l.length;f<h;f+=2){let m=l[f],y=l[f+1];if(m.global&&(m.lastIndex=0),m.test(d))return y}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},h0=new hd,pd=class{constructor(e){this.manager=e!==void 0?e:h0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};pd.DEFAULT_MATERIAL_NAME="__DEFAULT";var yc=class extends ar{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Rn(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},xc=class extends yc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ar.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Rn(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Ih=new Un,gv=new ge,yv=new ge,md=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new qt(512,512),this.mapType=Hr,this.map=null,this.mapPass=null,this.matrix=new Un,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nl,this._frameExtents=new qt(1,1),this._viewportCount=1,this._viewports=[new Si(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;gv.setFromMatrixPosition(e.matrixWorld),t.position.copy(gv),yv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(yv),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,i,r){Ih.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i.setFromProjectionMatrix(Ih,e.coordinateSystem,e.reversedDepth);let a=this._frameExtents,s=r?r.z/a.x:1,o=r?r.w/a.y:1,u=r?r.x/a.x:0,l=r?r.y/a.y:0;e.coordinateSystem===Zo||e.reversedDepth?t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(Ih)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Du=new ge,Nu=new kr,Oa=new ge,_c=class extends ar{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Un,this.projectionMatrix=new Un,this.projectionMatrixInverse=new Un,this.coordinateSystem=Ea,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Du,Nu,Oa),Oa.x===1&&Oa.y===1&&Oa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Du,Nu,Oa.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Du,Nu,Oa),Oa.x===1&&Oa.y===1&&Oa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Du,Nu,Oa.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Ss=new ge,xv=new qt,_v=new qt,wr=class extends _c{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Xu*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(th*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Xu*2*Math.atan(Math.tan(th*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Ss.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ss.x,Ss.y).multiplyScalar(-e/Ss.z),Ss.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ss.x,Ss.y).multiplyScalar(-e/Ss.z)}getViewSize(e,t){return this.getViewBounds(e,xv,_v),t.subVectors(_v,xv)}setViewOffset(e,t,i,r,a,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(th*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r,s=this.view;if(this.view!==null&&this.view.enabled){let u=s.fullWidth,l=s.fullHeight;a+=s.offsetX*r/u,t-=s.offsetY*i/l,r*=s.width/u,i*=s.height/l}let o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};var cl=class extends _c{constructor(e=-1,t=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,a=i-e,s=i+e,o=r+t,u=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=l*this.view.offsetX,s=a+l*this.view.width,o-=d*this.view.offsetY,u=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,u,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Oh=class extends md{constructor(){super(new cl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Mc=class extends yc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ar.DEFAULT_UP),this.updateMatrix(),this.target=new ar,this.shadow=new Oh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var Go=-90,Ho=1,vd=class extends ar{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new wr(Go,Ho,e,t);r.layers=this.layers,this.add(r);let a=new wr(Go,Ho,e,t);a.layers=this.layers,this.add(a);let s=new wr(Go,Ho,e,t);s.layers=this.layers,this.add(s);let o=new wr(Go,Ho,e,t);o.layers=this.layers,this.add(o);let u=new wr(Go,Ho,e,t);u.layers=this.layers,this.add(u);let l=new wr(Go,Ho,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,a,s,o,u]=t;for(let l of t)this.remove(l);if(e===Ea)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===Zo)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[a,s,o,u,l,d]=this.children,f=e.getRenderTarget(),h=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;let M=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(i,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=M,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(f,h,m),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}},gd=class extends wr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var cp="\\[\\]\\.:\\/",vx=new RegExp("["+cp+"]","g"),up="[^"+cp+"]",gx="[^"+cp.replace("\\.","")+"]",yx=/((?:WC+[\/:])*)/.source.replace("WC",up),xx=/(WCOD+)?/.source.replace("WCOD",gx),_x=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",up),Mx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",up),Sx=new RegExp("^"+yx+xx+_x+Mx+"$"),bx=["material","materials","bones","map"],Bh=class{constructor(e,t,i){let r=i||Pi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Pi=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(vx,"")}static parseTrackName(e){let t=Sx.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);bx.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let o=a[s];if(o.name===t||o.uuid===t)return o;let u=i(o.children);if(u)return u}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){mn("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){Tn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Tn("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Tn("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===l){l=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Tn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Tn("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Tn("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){Tn("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;Tn("PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Tn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Tn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}u=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(u=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Pi.Composite=Bh;Pi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Pi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Pi.prototype.GetterByBindingType=[Pi.prototype._getValue_direct,Pi.prototype._getValue_array,Pi.prototype._getValue_arrayElement,Pi.prototype._getValue_toArray];Pi.prototype.SetterByBindingTypeAndVersioning=[[Pi.prototype._setValue_direct,Pi.prototype._setValue_direct_setNeedsUpdate,Pi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Pi.prototype._setValue_array,Pi.prototype._setValue_array_setNeedsUpdate,Pi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Pi.prototype._setValue_arrayElement,Pi.prototype._setValue_arrayElement_setNeedsUpdate,Pi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Pi.prototype._setValue_fromArray,Pi.prototype._setValue_fromArray_setNeedsUpdate,Pi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var o1=new Float32Array(1);var Mv=new Un,Sc=class{constructor(e,t,i=0,r=1/0){this.ray=new jo(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Ko,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Tn("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Mv.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Mv),this}intersectObject(e,t=!0,i=[]){return kh(e,this,i,t),i.sort(Sv),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)kh(e[r],this,i,t);return i.sort(Sv),i}};function Sv(n,e){return n.distance-e.distance}function kh(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){let a=n.children;for(let s=0,o=a.length;s<o;s++)kh(a[s],e,t,!0)}}var vp=class vp{constructor(e,t,i,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){let a=this.elements;return a[0]=e,a[2]=t,a[1]=i,a[3]=r,this}};vp.prototype.isMatrix2=!0;var zh=vp;function dp(n,e,t,i){let r=wx(i);switch(t){case ip:return n*e;case Ed:return n*e/r.components*r.byteLength;case Ad:return n*e/r.components*r.byteLength;case Ls:return n*e*2/r.components*r.byteLength;case Id:return n*e*2/r.components*r.byteLength;case rp:return n*e*3/r.components*r.byteLength;case ia:return n*e*4/r.components*r.byteLength;case Cd:return n*e*4/r.components*r.byteLength;case Ac:case Ic:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Cc:case Rc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Pd:case Dd:return Math.max(n,16)*Math.max(e,8)/4;case Rd:case Ld:return Math.max(n,8)*Math.max(e,8)/2;case Nd:case Ud:case Od:case Bd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Fd:case Pc:case kd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case zd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Vd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Gd:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Hd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Wd:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Xd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Yd:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case qd:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Zd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Jd:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case $d:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Kd:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Qd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case jd:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case ef:case tf:case nf:return Math.ceil(n/4)*Math.ceil(e/4)*16;case rf:case af:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Lc:case sf:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function wx(n){switch(n){case Hr:case jh:return{byteLength:1,components:1};case pl:case ep:case Ca:return{byteLength:2,components:1};case wd:case Td:return{byteLength:2,components:4};case Ia:case bd:case na:return{byteLength:4,components:1};case tp:case np:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));typeof window<"u"&&(window.__THREE__?mn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");function U0(){let n=null,e=!1,t=null,i=null;function r(a,s){i=n.requestAnimationFrame(r),t(a,s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){n=a}}}function Ex(n){let e=new WeakMap;function t(o,u){let l=o.array,d=o.usage,f=l.byteLength,h=n.createBuffer();n.bindBuffer(u,h),n.bufferData(u,l,d),o.onUploadCallback();let m;if(l instanceof Float32Array)m=n.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=n.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?m=n.HALF_FLOAT:m=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=n.SHORT;else if(l instanceof Uint32Array)m=n.UNSIGNED_INT;else if(l instanceof Int32Array)m=n.INT;else if(l instanceof Int8Array)m=n.BYTE;else if(l instanceof Uint8Array)m=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function i(o,u,l){let d=u.array,f=u.updateRanges;if(n.bindBuffer(l,o),f.length===0)n.bufferSubData(l,0,d);else{f.sort((m,y)=>m.start-y.start);let h=0;for(let m=1;m<f.length;m++){let y=f[h],M=f[m];M.start<=y.start+y.count+1?y.count=Math.max(y.count,M.start+M.count-y.start):(++h,f[h]=M)}f.length=h+1;for(let m=0,y=f.length;m<y;m++){let M=f[m];n.bufferSubData(l,M.start*d.BYTES_PER_ELEMENT,d,M.start,M.count)}u.clearUpdateRanges()}u.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);let u=e.get(o);u&&(n.deleteBuffer(u.buffer),e.delete(o))}function s(o,u){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=e.get(o);if(l===void 0)e.set(o,t(o,u));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,o,u),l.version=o.version}}return{get:r,remove:a,update:s}}var Ax=`#ifdef USE_ALPHAHASH
|
|
5
|
+
}`,pa=class extends ys{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ux,this.fragmentShader=Fx,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=go(e.uniforms),this.uniformsGroups=Nx(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let i in e.uniforms){let r=e.uniforms[i];switch(this.uniforms[i]={},r.type){case"t":this.uniforms[i].value=t[r.value]||null;break;case"c":this.uniforms[i].value=new zn().setHex(r.value);break;case"v2":this.uniforms[i].value=new tn().fromArray(r.value);break;case"v3":this.uniforms[i].value=new xe().fromArray(r.value);break;case"v4":this.uniforms[i].value=new Ni().fromArray(r.value);break;case"m3":this.uniforms[i].value=new qn().fromArray(r.value);break;case"m4":this.uniforms[i].value=new Kn().fromArray(r.value);break;default:this.uniforms[i].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},cd=class extends pa{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},ll=class extends ys{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new zn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new zn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fc,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ba,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};var dr=class extends ys{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new zn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new zn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fc,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ba,this.combine=Ed,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},ud=class extends ys{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=d0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},dd=class extends ys{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Vo(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function zh(n){return n!==void 0&&n.inTangents!==void 0&&n.outTangents!==void 0}var ks=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;n:{i:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<a)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break n}if(!(e>=a)){let o=t[1];e<o&&(i=2,a=o);for(let u=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===u)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break n}break e}for(;i<s;){let o=i+s>>>1;e<t[o]?s=o:i=o+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},fd=class extends ks{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Wh,endingEnd:Wh}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,o=r[a],u=r[s];if(o===void 0)switch(this.getSettings_().endingStart){case Xh:a=e,o=2*t-i;break;case Yh:a=r.length-2,o=t+r[a]-r[a+1];break;default:a=e,o=i}if(u===void 0)switch(this.getSettings_().endingEnd){case Xh:s=e,u=2*i-t;break;case Yh:s=1,u=i+r[1]-r[0];break;default:s=e-1,u=t}let l=(i-t)*.5,d=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(u-i),this._offsetPrev=a*d,this._offsetNext=s*d}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this._offsetPrev,f=this._offsetNext,h=this._weightPrev,m=this._weightNext,y=(i-t)/(r-t),M=y*y,g=M*y,v=-h*g+2*h*M-h*y,L=(1+h)*g+(-1.5-2*h)*M+(-.5+h)*y+1,p=(-1-m)*g+(1.5+m)*M+.5*y,_=m*g-m*M;for(let N=0;N!==o;++N)a[N]=v*s[d+N]+L*s[l+N]+p*s[u+N]+_*s[f+N];return a}},hd=class extends ks{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=(i-t)/(r-t),f=1-d;for(let h=0;h!==o;++h)a[h]=s[l+h]*f+s[u+h]*d;return a}},pd=class extends ks{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},md=class extends ks{interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this.inTangents,f=this.outTangents;if(!d||!f){let y=(i-t)/(r-t),M=1-y;for(let g=0;g!==o;++g)a[g]=s[l+g]*M+s[u+g]*y;return a}let h=o*2,m=e-1;for(let y=0;y!==o;++y){let M=s[l+y],g=s[u+y],v=m*h+y*2,L=f[v],p=f[v+1],_=e*h+y*2,N=d[_],D=d[_+1],V=Bx(i,t,L,N,r);a[y]=P0(V,M,p,D,g)}return a}};function P0(n,e,t,i,r){let a=1-n;return a*a*a*e+3*a*a*n*t+3*a*n*n*i+n*n*n*r}function Ox(n,e,t,i,r){let a=1-n;return 3*a*a*(t-e)+6*a*n*(i-t)+3*n*n*(r-i)}function Bx(n,e,t,i,r){let a=(n-e)/(r-e);for(let s=0;s<8;s++){let o=P0(a,e,t,i,r)-n;if(Math.abs(o)<1e-10)break;let u=Ox(a,e,t,i,r);if(Math.abs(u)<1e-10)break;a=Math.max(0,Math.min(1,a-o/u))}return a}var ma=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Vo(t,this.TimeBufferType),this.values=Vo(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Vo(e.times,Array),values:Vo(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r),zh(e.settings)&&(i.settings={inTangents:Vo(e.settings.inTangents,Array),outTangents:Vo(e.settings.outTangents,Array)})}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new pd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new hd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new fd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new md(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case jl:t=this.InterpolantFactoryMethodDiscrete;break;case Ku:t=this.InterpolantFactoryMethodLinear;break;case Gu:t=this.InterpolantFactoryMethodSmooth;break;case Hh:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return En("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return jl;case this.InterpolantFactoryMethodLinear:return Ku;case this.InterpolantFactoryMethodSmooth:return Gu;case this.InterpolantFactoryMethodBezier:return Hh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e;zh(this.settings)&&(Uv(this.settings.inTangents,e),Uv(this.settings.outTangents,e))}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let o=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Un("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(Un("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let o=0;o!==a;o++){let u=i[o];if(typeof u=="number"&&isNaN(u)){Un("KeyframeTrack: Time is not a valid number.",this,o,u),e=!1;break}if(s!==null&&s>u){Un("KeyframeTrack: Out of order keys.",this,o,u,s),e=!1;break}s=u}if(r!==void 0&&zy(r))for(let o=0,u=r.length;o!==u;++o){let l=r[o];if(isNaN(l)){Un("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Gu,a=e.length-1,s=1;for(let o=1;o<a;++o){let u=!1,l=e[o],d=e[o+1];if(l!==d&&(o!==1||l!==e[0]))if(r)u=!0;else{let f=o*i,h=f-i,m=f+i;for(let y=0;y!==i;++y){let M=t[f+y];if(M!==t[h+y]||M!==t[m+y]){u=!0;break}}}if(u){if(o!==s){e[s]=e[o];let f=o*i,h=s*i;for(let m=0;m!==i;++m)t[h+m]=t[f+m]}++s}}if(a>0){e[s]=e[a];for(let o=a*i,u=s*i,l=0;l!==i;++l)t[u+l]=t[o+l];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,zh(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function Uv(n,e){for(let t=0,i=n.length;t!==i;t+=2)n[t]*=e}ma.prototype.ValueTypeName="";ma.prototype.TimeBufferType=Float32Array;ma.prototype.ValueBufferType=Float32Array;ma.prototype.DefaultInterpolation=Ku;var zs=class extends ma{constructor(e,t,i){super(e,t,i)}};zs.prototype.ValueTypeName="bool";zs.prototype.ValueBufferType=Array;zs.prototype.DefaultInterpolation=jl;zs.prototype.InterpolantFactoryMethodLinear=void 0;zs.prototype.InterpolantFactoryMethodSmooth=void 0;var vd=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}};vd.prototype.ValueTypeName="color";var gd=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}};gd.prototype.ValueTypeName="number";var yd=class extends ks{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=(i-t)/(r-t),l=e*o;for(let d=l+o;l!==d;l+=4)ra.slerpFlat(a,0,s,l-o,s,l,u);return a}},_c=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new yd(this.times,this.values,this.getValueSize(),e)}};_c.prototype.ValueTypeName="quaternion";_c.prototype.InterpolantFactoryMethodSmooth=void 0;var Vs=class extends ma{constructor(e,t,i){super(e,t,i)}};Vs.prototype.ValueTypeName="string";Vs.prototype.ValueBufferType=Array;Vs.prototype.DefaultInterpolation=jl;Vs.prototype.InterpolantFactoryMethodLinear=void 0;Vs.prototype.InterpolantFactoryMethodSmooth=void 0;var xd=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}};xd.prototype.ValueTypeName="vector";var _d=class{constructor(e,t,i){let r=this,a=!1,s=0,o=0,u,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(d){o++,a===!1&&r.onStart!==void 0&&r.onStart(d,s,o),a=!0},this.itemEnd=function(d){s++,r.onProgress!==void 0&&r.onProgress(d,s,o),s===o&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return d=d.normalize("NFC"),u?u(d):d},this.setURLModifier=function(d){return u=d,this},this.addHandler=function(d,f){return l.push(d,f),this},this.removeHandler=function(d){let f=l.indexOf(d);return f!==-1&&l.splice(f,2),this},this.getHandler=function(d){for(let f=0,h=l.length;f<h;f+=2){let m=l[f],y=l[f+1];if(m.global&&(m.lastIndex=0),m.test(d))return y}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},L0=new _d,Md=class{constructor(e){this.manager=e!==void 0?e:L0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};Md.DEFAULT_MATERIAL_NAME="__DEFAULT";var Mc=class extends cr{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new zn(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},Sc=class extends Mc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(cr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new zn(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Vh=new Kn,Fv=new xe,Ov=new xe,Sd=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new tn(512,512),this.mapType=la,this.map=null,this.mapPass=null,this.matrix=new Kn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nl,this._frameExtents=new tn(1,1),this._viewportCount=1,this._viewports=[new Ni(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Fv.setFromMatrixPosition(e.matrixWorld),t.position.copy(Fv),Ov.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ov),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,i,r){Vh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i.setFromProjectionMatrix(Vh,e.coordinateSystem,e.reversedDepth);let a=this._frameExtents,s=r?r.z/a.x:1,o=r?r.w/a.y:1,u=r?r.x/a.x:0,l=r?r.y/a.y:0;e.coordinateSystem===Zo||e.reversedDepth?t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(Vh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},zu=new xe,Vu=new ra,Ya=new xe,bc=class extends cr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Kn,this.projectionMatrix=new Kn,this.projectionMatrixInverse=new Kn,this.coordinateSystem=Da,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(zu,Vu,Ya),Ya.x===1&&Ya.y===1&&Ya.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zu,Vu,Ya.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(zu,Vu,Ya),Ya.x===1&&Ya.y===1&&Ya.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zu,Vu,Ya.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Ns=new xe,Bv=new tn,kv=new tn,Fr=class extends bc{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Qu*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ph*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Qu*2*Math.atan(Math.tan(ph*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Ns.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ns.x,Ns.y).multiplyScalar(-e/Ns.z),Ns.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ns.x,Ns.y).multiplyScalar(-e/Ns.z)}getViewSize(e,t){return this.getViewBounds(e,Bv,kv),t.subVectors(kv,Bv)}setViewOffset(e,t,i,r,a,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ph*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r,s=this.view;if(this.view!==null&&this.view.enabled){let u=s.fullWidth,l=s.fullHeight;a+=s.offsetX*r/u,t-=s.offsetY*i/l,r*=s.width/u,i*=s.height/l}let o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};var cl=class extends bc{constructor(e=-1,t=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,a=i-e,s=i+e,o=r+t,u=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=l*this.view.offsetX,s=a+l*this.view.width,o-=d*this.view.offsetY,u=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,u,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},$h=class extends Sd{constructor(){super(new cl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},wc=class extends Mc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(cr.DEFAULT_UP),this.updateMatrix(),this.target=new cr,this.shadow=new $h}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var Go=-90,Ho=1,bd=class extends cr{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Fr(Go,Ho,e,t);r.layers=this.layers,this.add(r);let a=new Fr(Go,Ho,e,t);a.layers=this.layers,this.add(a);let s=new Fr(Go,Ho,e,t);s.layers=this.layers,this.add(s);let o=new Fr(Go,Ho,e,t);o.layers=this.layers,this.add(o);let u=new Fr(Go,Ho,e,t);u.layers=this.layers,this.add(u);let l=new Fr(Go,Ho,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,a,s,o,u]=t;for(let l of t)this.remove(l);if(e===Da)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===Zo)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[a,s,o,u,l,d]=this.children,f=e.getRenderTarget(),h=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;let M=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(i,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=M,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(f,h,m),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}},wd=class extends Fr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var Sp="\\[\\]\\.:\\/",kx=new RegExp("["+Sp+"]","g"),bp="[^"+Sp+"]",zx="[^"+Sp.replace("\\.","")+"]",Vx=/((?:WC+[\/:])*)/.source.replace("WC",bp),Gx=/(WCOD+)?/.source.replace("WCOD",zx),Hx=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",bp),Wx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",bp),Xx=new RegExp("^"+Vx+Gx+Hx+Wx+"$"),Yx=["material","materials","bones","map"],Kh=class{constructor(e,t,i){let r=i||Vi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Vi=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(kx,"")}static parseTrackName(e){let t=Xx.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);Yx.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let o=a[s];if(o.name===t||o.uuid===t)return o;let u=i(o.children);if(u)return u}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){En("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){Un("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Un("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Un("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===l){l=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Un("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Un("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Un("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){Un("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;Un("PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Un("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Un("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}u=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(u=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Vi.Composite=Kh;Vi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Vi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Vi.prototype.GetterByBindingType=[Vi.prototype._getValue_direct,Vi.prototype._getValue_array,Vi.prototype._getValue_arrayElement,Vi.prototype._getValue_toArray];Vi.prototype.SetterByBindingTypeAndVersioning=[[Vi.prototype._setValue_direct,Vi.prototype._setValue_direct_setNeedsUpdate,Vi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Vi.prototype._setValue_array,Vi.prototype._setValue_array_setNeedsUpdate,Vi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Vi.prototype._setValue_arrayElement,Vi.prototype._setValue_arrayElement_setNeedsUpdate,Vi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Vi.prototype._setValue_fromArray,Vi.prototype._setValue_fromArray_setNeedsUpdate,Vi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var R1=new Float32Array(1);var zv=new Kn,Tc=class{constructor(e,t,i=0,r=1/0){this.ray=new jo(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Ko,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Un("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return zv.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(zv),this}intersectObject(e,t=!0,i=[]){return Qh(e,this,i,t),i.sort(Vv),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)Qh(e[r],this,i,t);return i.sort(Vv),i}};function Vv(n,e){return n.distance-e.distance}function Qh(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){let a=n.children;for(let s=0,o=a.length;s<o;s++)Qh(a[s],e,t,!0)}}var Cp=class Cp{constructor(e,t,i,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){let a=this.elements;return a[0]=e,a[2]=t,a[1]=i,a[3]=r,this}};Cp.prototype.isMatrix2=!0;var jh=Cp;function wp(n,e,t,i){let r=qx(i);switch(t){case vp:return n*e;case Dd:return n*e/r.components*r.byteLength;case Nd:return n*e/r.components*r.byteLength;case Ws:return n*e*2/r.components*r.byteLength;case Ud:return n*e*2/r.components*r.byteLength;case gp:return n*e*3/r.components*r.byteLength;case ga:return n*e*4/r.components*r.byteLength;case Fd:return n*e*4/r.components*r.byteLength;case Rc:case Pc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Lc:case Dc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Bd:case zd:return Math.max(n,16)*Math.max(e,8)/4;case Od:case kd:return Math.max(n,8)*Math.max(e,8)/2;case Vd:case Gd:case Wd:case Xd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Hd:case Nc:case Yd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case qd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Zd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Jd:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $d:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Kd:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Qd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case jd:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ef:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tf:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nf:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case rf:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case af:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case sf:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case of:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case lf:case cf:case uf:return Math.ceil(n/4)*Math.ceil(e/4)*16;case df:case ff:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Uc:case hf:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function qx(n){switch(n){case la:case fp:return{byteLength:1,components:1};case pl:case hp:case Fa:return{byteLength:2,components:1};case Pd:case Ld:return{byteLength:2,components:4};case Ua:case Rd:case va:return{byteLength:4,components:1};case pp:case mp:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));typeof window<"u"&&(window.__THREE__?En("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");function eg(){let n=null,e=!1,t=null,i=null;function r(a,s){i=n.requestAnimationFrame(r),t(a,s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){n=a}}}function Jx(n){let e=new WeakMap;function t(o,u){let l=o.array,d=o.usage,f=l.byteLength,h=n.createBuffer();n.bindBuffer(u,h),n.bufferData(u,l,d),o.onUploadCallback();let m;if(l instanceof Float32Array)m=n.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=n.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?m=n.HALF_FLOAT:m=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=n.SHORT;else if(l instanceof Uint32Array)m=n.UNSIGNED_INT;else if(l instanceof Int32Array)m=n.INT;else if(l instanceof Int8Array)m=n.BYTE;else if(l instanceof Uint8Array)m=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function i(o,u,l){let d=u.array,f=u.updateRanges;if(n.bindBuffer(l,o),f.length===0)n.bufferSubData(l,0,d);else{f.sort((m,y)=>m.start-y.start);let h=0;for(let m=1;m<f.length;m++){let y=f[h],M=f[m];M.start<=y.start+y.count+1?y.count=Math.max(y.count,M.start+M.count-y.start):(++h,f[h]=M)}f.length=h+1;for(let m=0,y=f.length;m<y;m++){let M=f[m];n.bufferSubData(l,M.start*d.BYTES_PER_ELEMENT,d,M.start,M.count)}u.clearUpdateRanges()}u.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);let u=e.get(o);u&&(n.deleteBuffer(u.buffer),e.delete(o))}function s(o,u){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=e.get(o);if(l===void 0)e.set(o,t(o,u));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,o,u),l.version=o.version}}return{get:r,remove:a,update:s}}var $x=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
|
-
#endif`,
|
|
7
|
+
#endif`,Kx=`#ifdef USE_ALPHAHASH
|
|
8
8
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
9
9
|
float hash2D( vec2 value ) {
|
|
10
10
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -39,20 +39,20 @@ var ToraNative=(()=>{var Wf=Object.defineProperty;var ry=Object.getOwnPropertyDe
|
|
|
39
39
|
: cases.z;
|
|
40
40
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
41
41
|
}
|
|
42
|
-
#endif`,
|
|
42
|
+
#endif`,Qx=`#ifdef USE_ALPHAMAP
|
|
43
43
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
44
|
-
#endif`,
|
|
44
|
+
#endif`,jx=`#ifdef USE_ALPHAMAP
|
|
45
45
|
uniform sampler2D alphaMap;
|
|
46
|
-
#endif`,
|
|
46
|
+
#endif`,e_=`#ifdef USE_ALPHATEST
|
|
47
47
|
#ifdef ALPHA_TO_COVERAGE
|
|
48
48
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
49
49
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
50
50
|
#else
|
|
51
51
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
52
52
|
#endif
|
|
53
|
-
#endif`,
|
|
53
|
+
#endif`,t_=`#ifdef USE_ALPHATEST
|
|
54
54
|
uniform float alphaTest;
|
|
55
|
-
#endif`,
|
|
55
|
+
#endif`,n_=`#ifdef USE_AOMAP
|
|
56
56
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
57
57
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
58
58
|
#if defined( USE_CLEARCOAT )
|
|
@@ -65,10 +65,10 @@ var ToraNative=(()=>{var Wf=Object.defineProperty;var ry=Object.getOwnPropertyDe
|
|
|
65
65
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
66
66
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
67
67
|
#endif
|
|
68
|
-
#endif`,
|
|
68
|
+
#endif`,i_=`#ifdef USE_AOMAP
|
|
69
69
|
uniform sampler2D aoMap;
|
|
70
70
|
uniform float aoMapIntensity;
|
|
71
|
-
#endif`,
|
|
71
|
+
#endif`,r_=`#ifdef USE_BATCHING
|
|
72
72
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
73
73
|
#define gl_DrawID _gl_DrawID
|
|
74
74
|
uniform int _gl_DrawID;
|
|
@@ -102,15 +102,15 @@ var ToraNative=(()=>{var Wf=Object.defineProperty;var ry=Object.getOwnPropertyDe
|
|
|
102
102
|
int y = j / size;
|
|
103
103
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
104
104
|
}
|
|
105
|
-
#endif`,
|
|
105
|
+
#endif`,a_=`#ifdef USE_BATCHING
|
|
106
106
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
107
|
-
#endif`,
|
|
107
|
+
#endif`,s_=`vec3 transformed = vec3( position );
|
|
108
108
|
#ifdef USE_ALPHAHASH
|
|
109
109
|
vPosition = vec3( position );
|
|
110
|
-
#endif`,
|
|
110
|
+
#endif`,o_=`vec3 objectNormal = vec3( normal );
|
|
111
111
|
#ifdef USE_TANGENT
|
|
112
112
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
113
|
-
#endif`,
|
|
113
|
+
#endif`,l_=`float G_BlinnPhong_Implicit( ) {
|
|
114
114
|
return 0.25;
|
|
115
115
|
}
|
|
116
116
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -124,7 +124,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
124
124
|
float G = G_BlinnPhong_Implicit( );
|
|
125
125
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
126
126
|
return F * ( G * D );
|
|
127
|
-
} // validated`,
|
|
127
|
+
} // validated`,c_=`#ifdef USE_IRIDESCENCE
|
|
128
128
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
129
129
|
3.2404542, -0.9692660, 0.0556434,
|
|
130
130
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -187,7 +187,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
187
187
|
}
|
|
188
188
|
return max( I, vec3( 0.0 ) );
|
|
189
189
|
}
|
|
190
|
-
#endif`,
|
|
190
|
+
#endif`,u_=`#ifdef USE_BUMPMAP
|
|
191
191
|
uniform sampler2D bumpMap;
|
|
192
192
|
uniform float bumpScale;
|
|
193
193
|
vec2 dHdxy_fwd() {
|
|
@@ -208,7 +208,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
208
208
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
209
209
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
210
210
|
}
|
|
211
|
-
#endif`,
|
|
211
|
+
#endif`,d_=`#if NUM_CLIPPING_PLANES > 0
|
|
212
212
|
vec4 plane;
|
|
213
213
|
#ifdef ALPHA_TO_COVERAGE
|
|
214
214
|
float distanceToPlane, distanceGradient;
|
|
@@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
254
254
|
if ( clipped ) discard;
|
|
255
255
|
#endif
|
|
256
256
|
#endif
|
|
257
|
-
#endif`,
|
|
257
|
+
#endif`,f_=`#if NUM_CLIPPING_PLANES > 0
|
|
258
258
|
varying vec3 vClipPosition;
|
|
259
259
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
260
|
-
#endif`,
|
|
260
|
+
#endif`,h_=`#if NUM_CLIPPING_PLANES > 0
|
|
261
261
|
varying vec3 vClipPosition;
|
|
262
|
-
#endif`,
|
|
262
|
+
#endif`,p_=`#if NUM_CLIPPING_PLANES > 0
|
|
263
263
|
vClipPosition = - mvPosition.xyz;
|
|
264
|
-
#endif`,
|
|
264
|
+
#endif`,m_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
265
265
|
diffuseColor *= vColor;
|
|
266
|
-
#endif`,
|
|
266
|
+
#endif`,v_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
267
267
|
varying vec4 vColor;
|
|
268
|
-
#endif`,
|
|
268
|
+
#endif`,g_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
269
269
|
varying vec4 vColor;
|
|
270
|
-
#endif`,
|
|
270
|
+
#endif`,y_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
271
271
|
vColor = vec4( 1.0 );
|
|
272
272
|
#endif
|
|
273
273
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
280
280
|
#endif
|
|
281
281
|
#ifdef USE_BATCHING_COLOR
|
|
282
282
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
283
|
-
#endif
|
|
283
|
+
#endif`,x_=`#define PI 3.141592653589793
|
|
284
284
|
#define PI2 6.283185307179586
|
|
285
285
|
#define PI_HALF 1.5707963267948966
|
|
286
286
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -351,7 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
351
351
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
352
352
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
353
353
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
354
|
-
} // validated`,
|
|
354
|
+
} // validated`,__=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
355
355
|
#define cubeUV_minMipLevel 4.0
|
|
356
356
|
#define cubeUV_minTileSize 16.0
|
|
357
357
|
float getFace( vec3 direction ) {
|
|
@@ -444,7 +444,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
444
444
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
#endif`,
|
|
447
|
+
#endif`,M_=`vec3 transformedNormal = objectNormal;
|
|
448
448
|
#ifdef USE_TANGENT
|
|
449
449
|
vec3 transformedTangent = objectTangent;
|
|
450
450
|
#endif
|
|
@@ -470,21 +470,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
470
470
|
#endif
|
|
471
471
|
#ifdef USE_TANGENT
|
|
472
472
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
473
|
-
#endif`,
|
|
473
|
+
#endif`,S_=`#ifdef USE_DISPLACEMENTMAP
|
|
474
474
|
uniform sampler2D displacementMap;
|
|
475
475
|
uniform float displacementScale;
|
|
476
476
|
uniform float displacementBias;
|
|
477
|
-
#endif`,
|
|
477
|
+
#endif`,b_=`#ifdef USE_DISPLACEMENTMAP
|
|
478
478
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
479
|
-
#endif`,
|
|
479
|
+
#endif`,w_=`#ifdef USE_EMISSIVEMAP
|
|
480
480
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
481
481
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
482
482
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
483
483
|
#endif
|
|
484
484
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
485
|
-
#endif`,
|
|
485
|
+
#endif`,T_=`#ifdef USE_EMISSIVEMAP
|
|
486
486
|
uniform sampler2D emissiveMap;
|
|
487
|
-
#endif`,
|
|
487
|
+
#endif`,A_="gl_FragColor = linearToOutputTexel( gl_FragColor );",E_=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
488
488
|
return value;
|
|
489
489
|
}
|
|
490
490
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -492,7 +492,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
492
492
|
}
|
|
493
493
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
494
494
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
495
|
-
}`,
|
|
495
|
+
}`,I_=`#ifdef USE_ENVMAP
|
|
496
496
|
#ifdef ENV_WORLDPOS
|
|
497
497
|
vec3 cameraToFrag;
|
|
498
498
|
if ( isOrthographic ) {
|
|
@@ -519,7 +519,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
519
519
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
520
520
|
#endif
|
|
521
521
|
#endif
|
|
522
|
-
#endif`,
|
|
522
|
+
#endif`,C_=`#ifdef USE_ENVMAP
|
|
523
523
|
uniform float envMapIntensity;
|
|
524
524
|
uniform mat3 envMapRotation;
|
|
525
525
|
#ifdef ENVMAP_TYPE_CUBE
|
|
@@ -527,7 +527,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
527
527
|
#else
|
|
528
528
|
uniform sampler2D envMap;
|
|
529
529
|
#endif
|
|
530
|
-
#endif`,
|
|
530
|
+
#endif`,R_=`#ifdef USE_ENVMAP
|
|
531
531
|
uniform float reflectivity;
|
|
532
532
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
533
533
|
#define ENV_WORLDPOS
|
|
@@ -538,7 +538,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
538
538
|
#else
|
|
539
539
|
varying vec3 vReflect;
|
|
540
540
|
#endif
|
|
541
|
-
#endif`,
|
|
541
|
+
#endif`,P_=`#ifdef USE_ENVMAP
|
|
542
542
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
543
543
|
#define ENV_WORLDPOS
|
|
544
544
|
#endif
|
|
@@ -549,7 +549,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
549
549
|
varying vec3 vReflect;
|
|
550
550
|
uniform float refractionRatio;
|
|
551
551
|
#endif
|
|
552
|
-
#endif`,
|
|
552
|
+
#endif`,L_=`#ifdef USE_ENVMAP
|
|
553
553
|
#ifdef ENV_WORLDPOS
|
|
554
554
|
vWorldPosition = worldPosition.xyz;
|
|
555
555
|
#else
|
|
@@ -566,18 +566,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
566
566
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
567
567
|
#endif
|
|
568
568
|
#endif
|
|
569
|
-
#endif`,
|
|
569
|
+
#endif`,D_=`#ifdef USE_FOG
|
|
570
570
|
vFogDepth = - mvPosition.z;
|
|
571
|
-
#endif`,
|
|
571
|
+
#endif`,N_=`#ifdef USE_FOG
|
|
572
572
|
varying float vFogDepth;
|
|
573
|
-
#endif`,
|
|
573
|
+
#endif`,U_=`#ifdef USE_FOG
|
|
574
574
|
#ifdef FOG_EXP2
|
|
575
575
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
576
576
|
#else
|
|
577
577
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
578
578
|
#endif
|
|
579
579
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
580
|
-
#endif`,
|
|
580
|
+
#endif`,F_=`#ifdef USE_FOG
|
|
581
581
|
uniform vec3 fogColor;
|
|
582
582
|
varying float vFogDepth;
|
|
583
583
|
#ifdef FOG_EXP2
|
|
@@ -586,7 +586,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
586
586
|
uniform float fogNear;
|
|
587
587
|
uniform float fogFar;
|
|
588
588
|
#endif
|
|
589
|
-
#endif`,
|
|
589
|
+
#endif`,O_=`#ifdef USE_GRADIENTMAP
|
|
590
590
|
uniform sampler2D gradientMap;
|
|
591
591
|
#endif
|
|
592
592
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -598,12 +598,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
598
598
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
599
599
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
600
600
|
#endif
|
|
601
|
-
}`,
|
|
601
|
+
}`,B_=`#ifdef USE_LIGHTMAP
|
|
602
602
|
uniform sampler2D lightMap;
|
|
603
603
|
uniform float lightMapIntensity;
|
|
604
|
-
#endif`,
|
|
604
|
+
#endif`,k_=`LambertMaterial material;
|
|
605
605
|
material.diffuseColor = diffuseColor.rgb;
|
|
606
|
-
material.specularStrength = specularStrength;`,
|
|
606
|
+
material.specularStrength = specularStrength;`,z_=`varying vec3 vViewPosition;
|
|
607
607
|
struct LambertMaterial {
|
|
608
608
|
vec3 diffuseColor;
|
|
609
609
|
float specularStrength;
|
|
@@ -617,7 +617,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
617
617
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
618
618
|
}
|
|
619
619
|
#define RE_Direct RE_Direct_Lambert
|
|
620
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
620
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,V_=`uniform bool receiveShadow;
|
|
621
621
|
uniform vec3 ambientLightColor;
|
|
622
622
|
#if defined( USE_LIGHT_PROBES )
|
|
623
623
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -746,7 +746,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
746
746
|
return irradiance;
|
|
747
747
|
}
|
|
748
748
|
#endif
|
|
749
|
-
#include <lightprobes_pars_fragment>`,
|
|
749
|
+
#include <lightprobes_pars_fragment>`,G_=`#ifdef USE_ENVMAP
|
|
750
750
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
751
751
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
752
752
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -803,8 +803,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
803
803
|
}
|
|
804
804
|
#endif
|
|
805
805
|
#endif
|
|
806
|
-
#endif`,
|
|
807
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
806
|
+
#endif`,H_=`ToonMaterial material;
|
|
807
|
+
material.diffuseColor = diffuseColor.rgb;`,W_=`varying vec3 vViewPosition;
|
|
808
808
|
struct ToonMaterial {
|
|
809
809
|
vec3 diffuseColor;
|
|
810
810
|
};
|
|
@@ -816,11 +816,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
816
816
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
817
817
|
}
|
|
818
818
|
#define RE_Direct RE_Direct_Toon
|
|
819
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
819
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,X_=`BlinnPhongMaterial material;
|
|
820
820
|
material.diffuseColor = diffuseColor.rgb;
|
|
821
821
|
material.specularColor = specular;
|
|
822
822
|
material.specularShininess = shininess;
|
|
823
|
-
material.specularStrength = specularStrength;`,
|
|
823
|
+
material.specularStrength = specularStrength;`,Y_=`varying vec3 vViewPosition;
|
|
824
824
|
struct BlinnPhongMaterial {
|
|
825
825
|
vec3 diffuseColor;
|
|
826
826
|
vec3 specularColor;
|
|
@@ -837,7 +837,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
837
837
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
838
838
|
}
|
|
839
839
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
840
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
840
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,q_=`PhysicalMaterial material;
|
|
841
841
|
material.diffuseColor = diffuseColor.rgb;
|
|
842
842
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
843
843
|
material.metalness = metalnessFactor;
|
|
@@ -930,7 +930,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
930
930
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
931
931
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
932
932
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
933
|
-
#endif`,
|
|
933
|
+
#endif`,Z_=`uniform sampler2D dfgLUT;
|
|
934
934
|
struct PhysicalMaterial {
|
|
935
935
|
vec3 diffuseColor;
|
|
936
936
|
vec3 diffuseContribution;
|
|
@@ -1297,7 +1297,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1297
1297
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1298
1298
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1299
1299
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1300
|
-
}`,
|
|
1300
|
+
}`,J_=`
|
|
1301
1301
|
vec3 geometryPosition = - vViewPosition;
|
|
1302
1302
|
vec3 geometryNormal = normal;
|
|
1303
1303
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1445,7 +1445,7 @@ IncidentLight directLight;
|
|
|
1445
1445
|
#if defined( RE_IndirectSpecular )
|
|
1446
1446
|
vec3 radiance = vec3( 0.0 );
|
|
1447
1447
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1448
|
-
#endif
|
|
1448
|
+
#endif`,$_=`#if defined( RE_IndirectDiffuse )
|
|
1449
1449
|
#ifdef USE_LIGHTMAP
|
|
1450
1450
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1451
1451
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1475,7 +1475,7 @@ IncidentLight directLight;
|
|
|
1475
1475
|
#ifdef USE_CLEARCOAT
|
|
1476
1476
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1477
1477
|
#endif
|
|
1478
|
-
#endif`,
|
|
1478
|
+
#endif`,K_=`#if defined( RE_IndirectDiffuse )
|
|
1479
1479
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1480
1480
|
irradiance += iblIrradiance;
|
|
1481
1481
|
#endif
|
|
@@ -1483,7 +1483,7 @@ IncidentLight directLight;
|
|
|
1483
1483
|
#endif
|
|
1484
1484
|
#if defined( RE_IndirectSpecular )
|
|
1485
1485
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1486
|
-
#endif`,
|
|
1486
|
+
#endif`,Q_=`#ifdef USE_LIGHT_PROBES_GRID
|
|
1487
1487
|
uniform highp sampler3D probesSH;
|
|
1488
1488
|
uniform vec3 probesMin;
|
|
1489
1489
|
uniform vec3 probesMax;
|
|
@@ -1528,27 +1528,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1528
1528
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1529
1529
|
return max( result, vec3( 0.0 ) );
|
|
1530
1530
|
}
|
|
1531
|
-
#endif`,
|
|
1531
|
+
#endif`,j_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1532
1532
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1533
|
-
#endif`,
|
|
1533
|
+
#endif`,eM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1534
1534
|
uniform float logDepthBufFC;
|
|
1535
1535
|
varying float vFragDepth;
|
|
1536
1536
|
varying float vIsPerspective;
|
|
1537
|
-
#endif`,
|
|
1537
|
+
#endif`,tM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1538
1538
|
varying float vFragDepth;
|
|
1539
1539
|
varying float vIsPerspective;
|
|
1540
|
-
#endif`,
|
|
1540
|
+
#endif`,nM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1541
1541
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1542
1542
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1543
|
-
#endif`,
|
|
1543
|
+
#endif`,iM=`#ifdef USE_MAP
|
|
1544
1544
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1545
1545
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1546
1546
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1547
1547
|
#endif
|
|
1548
1548
|
diffuseColor *= sampledDiffuseColor;
|
|
1549
|
-
#endif`,
|
|
1549
|
+
#endif`,rM=`#ifdef USE_MAP
|
|
1550
1550
|
uniform sampler2D map;
|
|
1551
|
-
#endif`,
|
|
1551
|
+
#endif`,aM=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1552
1552
|
#if defined( USE_POINTS_UV )
|
|
1553
1553
|
vec2 uv = vUv;
|
|
1554
1554
|
#else
|
|
@@ -1560,7 +1560,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1560
1560
|
#endif
|
|
1561
1561
|
#ifdef USE_ALPHAMAP
|
|
1562
1562
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1563
|
-
#endif`,
|
|
1563
|
+
#endif`,sM=`#if defined( USE_POINTS_UV )
|
|
1564
1564
|
varying vec2 vUv;
|
|
1565
1565
|
#else
|
|
1566
1566
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1572,19 +1572,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1572
1572
|
#endif
|
|
1573
1573
|
#ifdef USE_ALPHAMAP
|
|
1574
1574
|
uniform sampler2D alphaMap;
|
|
1575
|
-
#endif`,
|
|
1575
|
+
#endif`,oM=`float metalnessFactor = metalness;
|
|
1576
1576
|
#ifdef USE_METALNESSMAP
|
|
1577
1577
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1578
1578
|
metalnessFactor *= texelMetalness.b;
|
|
1579
|
-
#endif`,
|
|
1579
|
+
#endif`,lM=`#ifdef USE_METALNESSMAP
|
|
1580
1580
|
uniform sampler2D metalnessMap;
|
|
1581
|
-
#endif`,
|
|
1581
|
+
#endif`,cM=`#ifdef USE_INSTANCING_MORPH
|
|
1582
1582
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1583
1583
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1584
1584
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1585
1585
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1586
1586
|
}
|
|
1587
|
-
#endif`,
|
|
1587
|
+
#endif`,uM=`#if defined( USE_MORPHCOLORS )
|
|
1588
1588
|
vColor *= morphTargetBaseInfluence;
|
|
1589
1589
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1590
1590
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -1593,12 +1593,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1593
1593
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1594
1594
|
#endif
|
|
1595
1595
|
}
|
|
1596
|
-
#endif`,
|
|
1596
|
+
#endif`,dM=`#ifdef USE_MORPHNORMALS
|
|
1597
1597
|
objectNormal *= morphTargetBaseInfluence;
|
|
1598
1598
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1599
1599
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1600
1600
|
}
|
|
1601
|
-
#endif`,
|
|
1601
|
+
#endif`,fM=`#ifdef USE_MORPHTARGETS
|
|
1602
1602
|
#ifndef USE_INSTANCING_MORPH
|
|
1603
1603
|
uniform float morphTargetBaseInfluence;
|
|
1604
1604
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1612,12 +1612,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1612
1612
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1613
1613
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1614
1614
|
}
|
|
1615
|
-
#endif`,
|
|
1615
|
+
#endif`,hM=`#ifdef USE_MORPHTARGETS
|
|
1616
1616
|
transformed *= morphTargetBaseInfluence;
|
|
1617
1617
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1618
1618
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1619
1619
|
}
|
|
1620
|
-
#endif`,
|
|
1620
|
+
#endif`,pM=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1621
1621
|
#ifdef FLAT_SHADED
|
|
1622
1622
|
vec3 fdx = dFdx( vViewPosition );
|
|
1623
1623
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1658,7 +1658,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1658
1658
|
tbn2[1] *= faceDirection;
|
|
1659
1659
|
#endif
|
|
1660
1660
|
#endif
|
|
1661
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
1661
|
+
vec3 nonPerturbedNormal = normal;`,mM=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1662
1662
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1663
1663
|
#ifdef FLIP_SIDED
|
|
1664
1664
|
normal = - normal;
|
|
@@ -1676,19 +1676,19 @@ vec3 nonPerturbedNormal = normal;`,Y_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1676
1676
|
normal = normalize( tbn * mapN );
|
|
1677
1677
|
#elif defined( USE_BUMPMAP )
|
|
1678
1678
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1679
|
-
#endif`,
|
|
1679
|
+
#endif`,vM=`#ifndef FLAT_SHADED
|
|
1680
1680
|
varying vec3 vNormal;
|
|
1681
1681
|
#ifdef USE_TANGENT
|
|
1682
1682
|
varying vec3 vTangent;
|
|
1683
1683
|
varying vec3 vBitangent;
|
|
1684
1684
|
#endif
|
|
1685
|
-
#endif`,
|
|
1685
|
+
#endif`,gM=`#ifndef FLAT_SHADED
|
|
1686
1686
|
varying vec3 vNormal;
|
|
1687
1687
|
#ifdef USE_TANGENT
|
|
1688
1688
|
varying vec3 vTangent;
|
|
1689
1689
|
varying vec3 vBitangent;
|
|
1690
1690
|
#endif
|
|
1691
|
-
#endif`,
|
|
1691
|
+
#endif`,yM=`#ifndef FLAT_SHADED
|
|
1692
1692
|
vNormal = normalize( transformedNormal );
|
|
1693
1693
|
#ifdef USE_TANGENT
|
|
1694
1694
|
vTangent = normalize( transformedTangent );
|
|
@@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,Y_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1697
1697
|
vBitangent = - vBitangent;
|
|
1698
1698
|
#endif
|
|
1699
1699
|
#endif
|
|
1700
|
-
#endif
|
|
1700
|
+
#endif`,xM=`#ifdef USE_NORMALMAP
|
|
1701
1701
|
uniform sampler2D normalMap;
|
|
1702
1702
|
uniform vec2 normalScale;
|
|
1703
1703
|
#endif
|
|
@@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,Y_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1719
1719
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1720
1720
|
return mat3( T * scale, B * scale, N );
|
|
1721
1721
|
}
|
|
1722
|
-
#endif`,
|
|
1722
|
+
#endif`,_M=`#ifdef USE_CLEARCOAT
|
|
1723
1723
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1724
|
-
#endif`,
|
|
1724
|
+
#endif`,MM=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1725
1725
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1726
1726
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1727
1727
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1728
|
-
#endif`,
|
|
1728
|
+
#endif`,SM=`#ifdef USE_CLEARCOATMAP
|
|
1729
1729
|
uniform sampler2D clearcoatMap;
|
|
1730
1730
|
#endif
|
|
1731
1731
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,Y_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1734
1734
|
#endif
|
|
1735
1735
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1736
1736
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1737
|
-
#endif`,
|
|
1737
|
+
#endif`,bM=`#ifdef USE_IRIDESCENCEMAP
|
|
1738
1738
|
uniform sampler2D iridescenceMap;
|
|
1739
1739
|
#endif
|
|
1740
1740
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1741
1741
|
uniform sampler2D iridescenceThicknessMap;
|
|
1742
|
-
#endif`,
|
|
1742
|
+
#endif`,wM=`#ifdef OPAQUE
|
|
1743
1743
|
diffuseColor.a = 1.0;
|
|
1744
1744
|
#endif
|
|
1745
1745
|
#ifdef USE_TRANSMISSION
|
|
1746
1746
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1747
1747
|
#endif
|
|
1748
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1748
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,TM=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1749
1749
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1750
1750
|
}
|
|
1751
1751
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -1824,9 +1824,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1824
1824
|
#else
|
|
1825
1825
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1826
1826
|
#endif
|
|
1827
|
-
}`,
|
|
1827
|
+
}`,AM=`#ifdef PREMULTIPLIED_ALPHA
|
|
1828
1828
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1829
|
-
#endif`,
|
|
1829
|
+
#endif`,EM=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1830
1830
|
#ifdef USE_BATCHING
|
|
1831
1831
|
mvPosition = batchingMatrix * mvPosition;
|
|
1832
1832
|
#endif
|
|
@@ -1834,22 +1834,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1834
1834
|
mvPosition = instanceMatrix * mvPosition;
|
|
1835
1835
|
#endif
|
|
1836
1836
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1837
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
1837
|
+
gl_Position = projectionMatrix * mvPosition;`,IM=`#ifdef DITHERING
|
|
1838
1838
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1839
|
-
#endif`,
|
|
1839
|
+
#endif`,CM=`#ifdef DITHERING
|
|
1840
1840
|
vec3 dithering( vec3 color ) {
|
|
1841
1841
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1842
1842
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1843
1843
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1844
1844
|
return color + dither_shift_RGB;
|
|
1845
1845
|
}
|
|
1846
|
-
#endif`,
|
|
1846
|
+
#endif`,RM=`float roughnessFactor = roughness;
|
|
1847
1847
|
#ifdef USE_ROUGHNESSMAP
|
|
1848
1848
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1849
1849
|
roughnessFactor *= texelRoughness.g;
|
|
1850
|
-
#endif`,
|
|
1850
|
+
#endif`,PM=`#ifdef USE_ROUGHNESSMAP
|
|
1851
1851
|
uniform sampler2D roughnessMap;
|
|
1852
|
-
#endif`,
|
|
1852
|
+
#endif`,LM=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1853
1853
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1854
1854
|
#endif
|
|
1855
1855
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2100,7 +2100,7 @@ gl_Position = projectionMatrix * mvPosition;`,aM=`#ifdef DITHERING
|
|
|
2100
2100
|
}
|
|
2101
2101
|
#endif
|
|
2102
2102
|
#endif
|
|
2103
|
-
#endif`,
|
|
2103
|
+
#endif`,DM=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2104
2104
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2105
2105
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2106
2106
|
#endif
|
|
@@ -2145,7 +2145,7 @@ gl_Position = projectionMatrix * mvPosition;`,aM=`#ifdef DITHERING
|
|
|
2145
2145
|
};
|
|
2146
2146
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2147
2147
|
#endif
|
|
2148
|
-
#endif`,
|
|
2148
|
+
#endif`,NM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2149
2149
|
#ifdef HAS_NORMAL
|
|
2150
2150
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2151
2151
|
#else
|
|
@@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,aM=`#ifdef DITHERING
|
|
|
2185
2185
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2186
2186
|
}
|
|
2187
2187
|
#pragma unroll_loop_end
|
|
2188
|
-
#endif`,
|
|
2188
|
+
#endif`,UM=`float getShadowMask() {
|
|
2189
2189
|
float shadow = 1.0;
|
|
2190
2190
|
#ifdef USE_SHADOWMAP
|
|
2191
2191
|
#if NUM_SUN_LIGHT_SHADOWS > 0
|
|
@@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,aM=`#ifdef DITHERING
|
|
|
2226
2226
|
#endif
|
|
2227
2227
|
#endif
|
|
2228
2228
|
return shadow;
|
|
2229
|
-
}`,
|
|
2229
|
+
}`,FM=`#ifdef USE_SKINNING
|
|
2230
2230
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2231
2231
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2232
2232
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2233
2233
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2234
|
-
#endif`,
|
|
2234
|
+
#endif`,OM=`#ifdef USE_SKINNING
|
|
2235
2235
|
uniform mat4 bindMatrix;
|
|
2236
2236
|
uniform mat4 bindMatrixInverse;
|
|
2237
2237
|
uniform highp sampler2D boneTexture;
|
|
@@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,aM=`#ifdef DITHERING
|
|
|
2246
2246
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2247
2247
|
return mat4( v1, v2, v3, v4 );
|
|
2248
2248
|
}
|
|
2249
|
-
#endif`,
|
|
2249
|
+
#endif`,BM=`#ifdef USE_SKINNING
|
|
2250
2250
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2251
2251
|
vec4 skinned = vec4( 0.0 );
|
|
2252
2252
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2254,7 +2254,7 @@ gl_Position = projectionMatrix * mvPosition;`,aM=`#ifdef DITHERING
|
|
|
2254
2254
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2255
2255
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2256
2256
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2257
|
-
#endif`,
|
|
2257
|
+
#endif`,kM=`#ifdef USE_SKINNING
|
|
2258
2258
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2259
2259
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2260
2260
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,aM=`#ifdef DITHERING
|
|
|
2265
2265
|
#ifdef USE_TANGENT
|
|
2266
2266
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2267
2267
|
#endif
|
|
2268
|
-
#endif`,
|
|
2268
|
+
#endif`,zM=`float specularStrength;
|
|
2269
2269
|
#ifdef USE_SPECULARMAP
|
|
2270
2270
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2271
2271
|
specularStrength = texelSpecular.r;
|
|
2272
2272
|
#else
|
|
2273
2273
|
specularStrength = 1.0;
|
|
2274
|
-
#endif`,
|
|
2274
|
+
#endif`,VM=`#ifdef USE_SPECULARMAP
|
|
2275
2275
|
uniform sampler2D specularMap;
|
|
2276
|
-
#endif`,
|
|
2276
|
+
#endif`,GM=`#if defined( TONE_MAPPING )
|
|
2277
2277
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2278
|
-
#endif`,
|
|
2278
|
+
#endif`,HM=`#ifndef saturate
|
|
2279
2279
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2280
2280
|
#endif
|
|
2281
2281
|
uniform float toneMappingExposure;
|
|
@@ -2372,7 +2372,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2372
2372
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2373
2373
|
return mix( color, vec3( newPeak ), g );
|
|
2374
2374
|
}
|
|
2375
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2375
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,WM=`#ifdef USE_TRANSMISSION
|
|
2376
2376
|
material.transmission = transmission;
|
|
2377
2377
|
material.transmissionAlpha = 1.0;
|
|
2378
2378
|
material.thickness = thickness;
|
|
@@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,MM=`#ifdef USE_TRANSMISS
|
|
|
2393
2393
|
material.attenuationColor, material.attenuationDistance );
|
|
2394
2394
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2395
2395
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2396
|
-
#endif`,
|
|
2396
|
+
#endif`,XM=`#ifdef USE_TRANSMISSION
|
|
2397
2397
|
uniform float transmission;
|
|
2398
2398
|
uniform float thickness;
|
|
2399
2399
|
uniform float attenuationDistance;
|
|
@@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,MM=`#ifdef USE_TRANSMISS
|
|
|
2519
2519
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2520
2520
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2521
2521
|
}
|
|
2522
|
-
#endif`,
|
|
2522
|
+
#endif`,YM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2523
2523
|
varying vec2 vUv;
|
|
2524
2524
|
#endif
|
|
2525
2525
|
#ifdef USE_MAP
|
|
@@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,MM=`#ifdef USE_TRANSMISS
|
|
|
2589
2589
|
#ifdef USE_THICKNESSMAP
|
|
2590
2590
|
uniform mat3 thicknessMapTransform;
|
|
2591
2591
|
varying vec2 vThicknessMapUv;
|
|
2592
|
-
#endif`,
|
|
2592
|
+
#endif`,qM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2593
2593
|
varying vec2 vUv;
|
|
2594
2594
|
#endif
|
|
2595
2595
|
#ifdef USE_MAP
|
|
@@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,MM=`#ifdef USE_TRANSMISS
|
|
|
2683
2683
|
#ifdef USE_THICKNESSMAP
|
|
2684
2684
|
uniform mat3 thicknessMapTransform;
|
|
2685
2685
|
varying vec2 vThicknessMapUv;
|
|
2686
|
-
#endif`,
|
|
2686
|
+
#endif`,ZM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2687
2687
|
vUv = vec3( uv, 1 ).xy;
|
|
2688
2688
|
#endif
|
|
2689
2689
|
#ifdef USE_MAP
|
|
@@ -2754,7 +2754,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,MM=`#ifdef USE_TRANSMISS
|
|
|
2754
2754
|
#endif
|
|
2755
2755
|
#ifdef USE_THICKNESSMAP
|
|
2756
2756
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2757
|
-
#endif`,
|
|
2757
|
+
#endif`,JM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2758
2758
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2759
2759
|
#ifdef USE_BATCHING
|
|
2760
2760
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2763,12 +2763,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,MM=`#ifdef USE_TRANSMISS
|
|
|
2763
2763
|
worldPosition = instanceMatrix * worldPosition;
|
|
2764
2764
|
#endif
|
|
2765
2765
|
worldPosition = modelMatrix * worldPosition;
|
|
2766
|
-
#endif
|
|
2766
|
+
#endif`,$M=`varying vec2 vUv;
|
|
2767
2767
|
uniform mat3 uvTransform;
|
|
2768
2768
|
void main() {
|
|
2769
2769
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2770
2770
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2771
|
-
}`,
|
|
2771
|
+
}`,KM=`uniform sampler2D t2D;
|
|
2772
2772
|
uniform float backgroundIntensity;
|
|
2773
2773
|
varying vec2 vUv;
|
|
2774
2774
|
void main() {
|
|
@@ -2780,14 +2780,14 @@ void main() {
|
|
|
2780
2780
|
gl_FragColor = texColor;
|
|
2781
2781
|
#include <tonemapping_fragment>
|
|
2782
2782
|
#include <colorspace_fragment>
|
|
2783
|
-
}`,
|
|
2783
|
+
}`,QM=`varying vec3 vWorldDirection;
|
|
2784
2784
|
#include <common>
|
|
2785
2785
|
void main() {
|
|
2786
2786
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2787
2787
|
#include <begin_vertex>
|
|
2788
2788
|
#include <project_vertex>
|
|
2789
2789
|
gl_Position.z = gl_Position.w;
|
|
2790
|
-
}`,
|
|
2790
|
+
}`,jM=`#ifdef ENVMAP_TYPE_CUBE
|
|
2791
2791
|
uniform samplerCube envMap;
|
|
2792
2792
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2793
2793
|
uniform sampler2D envMap;
|
|
@@ -2809,14 +2809,14 @@ void main() {
|
|
|
2809
2809
|
gl_FragColor = texColor;
|
|
2810
2810
|
#include <tonemapping_fragment>
|
|
2811
2811
|
#include <colorspace_fragment>
|
|
2812
|
-
}`,
|
|
2812
|
+
}`,eS=`varying vec3 vWorldDirection;
|
|
2813
2813
|
#include <common>
|
|
2814
2814
|
void main() {
|
|
2815
2815
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2816
2816
|
#include <begin_vertex>
|
|
2817
2817
|
#include <project_vertex>
|
|
2818
2818
|
gl_Position.z = gl_Position.w;
|
|
2819
|
-
}`,
|
|
2819
|
+
}`,tS=`uniform samplerCube tCube;
|
|
2820
2820
|
uniform float tFlip;
|
|
2821
2821
|
uniform float opacity;
|
|
2822
2822
|
varying vec3 vWorldDirection;
|
|
@@ -2826,7 +2826,7 @@ void main() {
|
|
|
2826
2826
|
gl_FragColor.a *= opacity;
|
|
2827
2827
|
#include <tonemapping_fragment>
|
|
2828
2828
|
#include <colorspace_fragment>
|
|
2829
|
-
}`,
|
|
2829
|
+
}`,nS=`#include <common>
|
|
2830
2830
|
#include <batching_pars_vertex>
|
|
2831
2831
|
#include <uv_pars_vertex>
|
|
2832
2832
|
#include <displacementmap_pars_vertex>
|
|
@@ -2853,7 +2853,7 @@ void main() {
|
|
|
2853
2853
|
#include <logdepthbuf_vertex>
|
|
2854
2854
|
#include <clipping_planes_vertex>
|
|
2855
2855
|
vHighPrecisionZW = gl_Position.zw;
|
|
2856
|
-
}`,
|
|
2856
|
+
}`,iS=`#if DEPTH_PACKING == 3200
|
|
2857
2857
|
uniform float opacity;
|
|
2858
2858
|
#endif
|
|
2859
2859
|
#include <common>
|
|
@@ -2891,7 +2891,7 @@ void main() {
|
|
|
2891
2891
|
#elif DEPTH_PACKING == 3203
|
|
2892
2892
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2893
2893
|
#endif
|
|
2894
|
-
}`,
|
|
2894
|
+
}`,rS=`#define DISTANCE
|
|
2895
2895
|
varying vec3 vWorldPosition;
|
|
2896
2896
|
#include <common>
|
|
2897
2897
|
#include <batching_pars_vertex>
|
|
@@ -2918,7 +2918,7 @@ void main() {
|
|
|
2918
2918
|
#include <worldpos_vertex>
|
|
2919
2919
|
#include <clipping_planes_vertex>
|
|
2920
2920
|
vWorldPosition = worldPosition.xyz;
|
|
2921
|
-
}`,
|
|
2921
|
+
}`,aS=`#define DISTANCE
|
|
2922
2922
|
uniform vec3 referencePosition;
|
|
2923
2923
|
uniform float nearDistance;
|
|
2924
2924
|
uniform float farDistance;
|
|
@@ -2941,13 +2941,13 @@ void main() {
|
|
|
2941
2941
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2942
2942
|
dist = saturate( dist );
|
|
2943
2943
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
2944
|
-
}`,
|
|
2944
|
+
}`,sS=`varying vec3 vWorldDirection;
|
|
2945
2945
|
#include <common>
|
|
2946
2946
|
void main() {
|
|
2947
2947
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2948
2948
|
#include <begin_vertex>
|
|
2949
2949
|
#include <project_vertex>
|
|
2950
|
-
}`,
|
|
2950
|
+
}`,oS=`uniform sampler2D tEquirect;
|
|
2951
2951
|
varying vec3 vWorldDirection;
|
|
2952
2952
|
#include <common>
|
|
2953
2953
|
void main() {
|
|
@@ -2956,7 +2956,7 @@ void main() {
|
|
|
2956
2956
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2957
2957
|
#include <tonemapping_fragment>
|
|
2958
2958
|
#include <colorspace_fragment>
|
|
2959
|
-
}`,
|
|
2959
|
+
}`,lS=`uniform float scale;
|
|
2960
2960
|
attribute float lineDistance;
|
|
2961
2961
|
varying float vLineDistance;
|
|
2962
2962
|
#include <common>
|
|
@@ -2978,7 +2978,7 @@ void main() {
|
|
|
2978
2978
|
#include <logdepthbuf_vertex>
|
|
2979
2979
|
#include <clipping_planes_vertex>
|
|
2980
2980
|
#include <fog_vertex>
|
|
2981
|
-
}`,
|
|
2981
|
+
}`,cS=`uniform vec3 diffuse;
|
|
2982
2982
|
uniform float opacity;
|
|
2983
2983
|
uniform float dashSize;
|
|
2984
2984
|
uniform float totalSize;
|
|
@@ -3006,7 +3006,7 @@ void main() {
|
|
|
3006
3006
|
#include <colorspace_fragment>
|
|
3007
3007
|
#include <fog_fragment>
|
|
3008
3008
|
#include <premultiplied_alpha_fragment>
|
|
3009
|
-
}`,
|
|
3009
|
+
}`,uS=`#include <common>
|
|
3010
3010
|
#include <batching_pars_vertex>
|
|
3011
3011
|
#include <uv_pars_vertex>
|
|
3012
3012
|
#include <envmap_pars_vertex>
|
|
@@ -3038,7 +3038,7 @@ void main() {
|
|
|
3038
3038
|
#include <worldpos_vertex>
|
|
3039
3039
|
#include <envmap_vertex>
|
|
3040
3040
|
#include <fog_vertex>
|
|
3041
|
-
}`,
|
|
3041
|
+
}`,dS=`uniform vec3 diffuse;
|
|
3042
3042
|
uniform float opacity;
|
|
3043
3043
|
#ifndef FLAT_SHADED
|
|
3044
3044
|
varying vec3 vNormal;
|
|
@@ -3086,7 +3086,7 @@ void main() {
|
|
|
3086
3086
|
#include <fog_fragment>
|
|
3087
3087
|
#include <premultiplied_alpha_fragment>
|
|
3088
3088
|
#include <dithering_fragment>
|
|
3089
|
-
}`,
|
|
3089
|
+
}`,fS=`#define LAMBERT
|
|
3090
3090
|
varying vec3 vViewPosition;
|
|
3091
3091
|
#include <common>
|
|
3092
3092
|
#include <batching_pars_vertex>
|
|
@@ -3125,7 +3125,7 @@ void main() {
|
|
|
3125
3125
|
#include <envmap_vertex>
|
|
3126
3126
|
#include <shadowmap_vertex>
|
|
3127
3127
|
#include <fog_vertex>
|
|
3128
|
-
}`,
|
|
3128
|
+
}`,hS=`#define LAMBERT
|
|
3129
3129
|
uniform vec3 diffuse;
|
|
3130
3130
|
uniform vec3 emissive;
|
|
3131
3131
|
uniform float opacity;
|
|
@@ -3183,7 +3183,7 @@ void main() {
|
|
|
3183
3183
|
#include <fog_fragment>
|
|
3184
3184
|
#include <premultiplied_alpha_fragment>
|
|
3185
3185
|
#include <dithering_fragment>
|
|
3186
|
-
}`,
|
|
3186
|
+
}`,pS=`#define MATCAP
|
|
3187
3187
|
varying vec3 vViewPosition;
|
|
3188
3188
|
#include <common>
|
|
3189
3189
|
#include <batching_pars_vertex>
|
|
@@ -3217,7 +3217,7 @@ void main() {
|
|
|
3217
3217
|
#include <clipping_planes_vertex>
|
|
3218
3218
|
#include <fog_vertex>
|
|
3219
3219
|
vViewPosition = - mvPosition.xyz;
|
|
3220
|
-
}`,
|
|
3220
|
+
}`,mS=`#define MATCAP
|
|
3221
3221
|
uniform vec3 diffuse;
|
|
3222
3222
|
uniform float opacity;
|
|
3223
3223
|
uniform sampler2D matcap;
|
|
@@ -3263,7 +3263,7 @@ void main() {
|
|
|
3263
3263
|
#include <fog_fragment>
|
|
3264
3264
|
#include <premultiplied_alpha_fragment>
|
|
3265
3265
|
#include <dithering_fragment>
|
|
3266
|
-
}`,
|
|
3266
|
+
}`,vS=`#define NORMAL
|
|
3267
3267
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3268
3268
|
varying vec3 vViewPosition;
|
|
3269
3269
|
#endif
|
|
@@ -3296,7 +3296,7 @@ void main() {
|
|
|
3296
3296
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3297
3297
|
vViewPosition = - mvPosition.xyz;
|
|
3298
3298
|
#endif
|
|
3299
|
-
}`,
|
|
3299
|
+
}`,gS=`#define NORMAL
|
|
3300
3300
|
uniform float opacity;
|
|
3301
3301
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3302
3302
|
varying vec3 vViewPosition;
|
|
@@ -3317,7 +3317,7 @@ void main() {
|
|
|
3317
3317
|
#ifdef OPAQUE
|
|
3318
3318
|
gl_FragColor.a = 1.0;
|
|
3319
3319
|
#endif
|
|
3320
|
-
}`,
|
|
3320
|
+
}`,yS=`#define PHONG
|
|
3321
3321
|
varying vec3 vViewPosition;
|
|
3322
3322
|
#include <common>
|
|
3323
3323
|
#include <batching_pars_vertex>
|
|
@@ -3356,7 +3356,7 @@ void main() {
|
|
|
3356
3356
|
#include <envmap_vertex>
|
|
3357
3357
|
#include <shadowmap_vertex>
|
|
3358
3358
|
#include <fog_vertex>
|
|
3359
|
-
}
|
|
3359
|
+
}`,xS=`#define PHONG
|
|
3360
3360
|
uniform vec3 diffuse;
|
|
3361
3361
|
uniform vec3 emissive;
|
|
3362
3362
|
uniform vec3 specular;
|
|
@@ -3416,7 +3416,7 @@ void main() {
|
|
|
3416
3416
|
#include <fog_fragment>
|
|
3417
3417
|
#include <premultiplied_alpha_fragment>
|
|
3418
3418
|
#include <dithering_fragment>
|
|
3419
|
-
}`,
|
|
3419
|
+
}`,_S=`#define STANDARD
|
|
3420
3420
|
varying vec3 vViewPosition;
|
|
3421
3421
|
#ifdef USE_TRANSMISSION
|
|
3422
3422
|
varying vec3 vWorldPosition;
|
|
@@ -3459,7 +3459,7 @@ void main() {
|
|
|
3459
3459
|
#ifdef USE_TRANSMISSION
|
|
3460
3460
|
vWorldPosition = worldPosition.xyz;
|
|
3461
3461
|
#endif
|
|
3462
|
-
}`,
|
|
3462
|
+
}`,MS=`#define STANDARD
|
|
3463
3463
|
#ifdef PHYSICAL
|
|
3464
3464
|
#define IOR
|
|
3465
3465
|
#define USE_SPECULAR
|
|
@@ -3587,7 +3587,7 @@ void main() {
|
|
|
3587
3587
|
#include <fog_fragment>
|
|
3588
3588
|
#include <premultiplied_alpha_fragment>
|
|
3589
3589
|
#include <dithering_fragment>
|
|
3590
|
-
}`,
|
|
3590
|
+
}`,SS=`#define TOON
|
|
3591
3591
|
varying vec3 vViewPosition;
|
|
3592
3592
|
#include <common>
|
|
3593
3593
|
#include <batching_pars_vertex>
|
|
@@ -3624,7 +3624,7 @@ void main() {
|
|
|
3624
3624
|
#include <worldpos_vertex>
|
|
3625
3625
|
#include <shadowmap_vertex>
|
|
3626
3626
|
#include <fog_vertex>
|
|
3627
|
-
}`,
|
|
3627
|
+
}`,bS=`#define TOON
|
|
3628
3628
|
uniform vec3 diffuse;
|
|
3629
3629
|
uniform vec3 emissive;
|
|
3630
3630
|
uniform float opacity;
|
|
@@ -3676,7 +3676,7 @@ void main() {
|
|
|
3676
3676
|
#include <fog_fragment>
|
|
3677
3677
|
#include <premultiplied_alpha_fragment>
|
|
3678
3678
|
#include <dithering_fragment>
|
|
3679
|
-
}`,
|
|
3679
|
+
}`,wS=`uniform float size;
|
|
3680
3680
|
uniform float scale;
|
|
3681
3681
|
#include <common>
|
|
3682
3682
|
#include <color_pars_vertex>
|
|
@@ -3707,7 +3707,7 @@ void main() {
|
|
|
3707
3707
|
#include <clipping_planes_vertex>
|
|
3708
3708
|
#include <worldpos_vertex>
|
|
3709
3709
|
#include <fog_vertex>
|
|
3710
|
-
}`,
|
|
3710
|
+
}`,TS=`uniform vec3 diffuse;
|
|
3711
3711
|
uniform float opacity;
|
|
3712
3712
|
#include <common>
|
|
3713
3713
|
#include <color_pars_fragment>
|
|
@@ -3732,7 +3732,7 @@ void main() {
|
|
|
3732
3732
|
#include <colorspace_fragment>
|
|
3733
3733
|
#include <fog_fragment>
|
|
3734
3734
|
#include <premultiplied_alpha_fragment>
|
|
3735
|
-
}`,
|
|
3735
|
+
}`,AS=`#include <common>
|
|
3736
3736
|
#include <batching_pars_vertex>
|
|
3737
3737
|
#include <fog_pars_vertex>
|
|
3738
3738
|
#include <morphtarget_pars_vertex>
|
|
@@ -3755,7 +3755,7 @@ void main() {
|
|
|
3755
3755
|
#include <worldpos_vertex>
|
|
3756
3756
|
#include <shadowmap_vertex>
|
|
3757
3757
|
#include <fog_vertex>
|
|
3758
|
-
}`,
|
|
3758
|
+
}`,ES=`uniform vec3 color;
|
|
3759
3759
|
uniform float opacity;
|
|
3760
3760
|
#include <common>
|
|
3761
3761
|
#include <fog_pars_fragment>
|
|
@@ -3771,7 +3771,7 @@ void main() {
|
|
|
3771
3771
|
#include <colorspace_fragment>
|
|
3772
3772
|
#include <fog_fragment>
|
|
3773
3773
|
#include <premultiplied_alpha_fragment>
|
|
3774
|
-
}`,
|
|
3774
|
+
}`,IS=`uniform float rotation;
|
|
3775
3775
|
uniform vec2 center;
|
|
3776
3776
|
#include <common>
|
|
3777
3777
|
#include <uv_pars_vertex>
|
|
@@ -3795,7 +3795,7 @@ void main() {
|
|
|
3795
3795
|
#include <logdepthbuf_vertex>
|
|
3796
3796
|
#include <clipping_planes_vertex>
|
|
3797
3797
|
#include <fog_vertex>
|
|
3798
|
-
}`,
|
|
3798
|
+
}`,CS=`uniform vec3 diffuse;
|
|
3799
3799
|
uniform float opacity;
|
|
3800
3800
|
#include <common>
|
|
3801
3801
|
#include <uv_pars_fragment>
|
|
@@ -3820,7 +3820,7 @@ void main() {
|
|
|
3820
3820
|
#include <tonemapping_fragment>
|
|
3821
3821
|
#include <colorspace_fragment>
|
|
3822
3822
|
#include <fog_fragment>
|
|
3823
|
-
}`,Gn={alphahash_fragment:Ax,alphahash_pars_fragment:Ix,alphamap_fragment:Cx,alphamap_pars_fragment:Rx,alphatest_fragment:Px,alphatest_pars_fragment:Lx,aomap_fragment:Dx,aomap_pars_fragment:Nx,batching_pars_vertex:Ux,batching_vertex:Fx,begin_vertex:Ox,beginnormal_vertex:Bx,bsdfs:kx,iridescence_fragment:zx,bumpmap_pars_fragment:Vx,clipping_planes_fragment:Gx,clipping_planes_pars_fragment:Hx,clipping_planes_pars_vertex:Wx,clipping_planes_vertex:Xx,color_fragment:Yx,color_pars_fragment:qx,color_pars_vertex:Zx,color_vertex:Jx,common:$x,cube_uv_reflection_fragment:Kx,defaultnormal_vertex:Qx,displacementmap_pars_vertex:jx,displacementmap_vertex:e_,emissivemap_fragment:t_,emissivemap_pars_fragment:n_,colorspace_fragment:i_,colorspace_pars_fragment:r_,envmap_fragment:a_,envmap_common_pars_fragment:s_,envmap_pars_fragment:o_,envmap_pars_vertex:l_,envmap_physical_pars_fragment:x_,envmap_vertex:c_,fog_vertex:u_,fog_pars_vertex:d_,fog_fragment:f_,fog_pars_fragment:h_,gradientmap_pars_fragment:p_,lightmap_pars_fragment:m_,lights_lambert_fragment:v_,lights_lambert_pars_fragment:g_,lights_pars_begin:y_,lights_toon_fragment:__,lights_toon_pars_fragment:M_,lights_phong_fragment:S_,lights_phong_pars_fragment:b_,lights_physical_fragment:w_,lights_physical_pars_fragment:T_,lights_fragment_begin:E_,lights_fragment_maps:A_,lights_fragment_end:I_,lightprobes_pars_fragment:C_,logdepthbuf_fragment:R_,logdepthbuf_pars_fragment:P_,logdepthbuf_pars_vertex:L_,logdepthbuf_vertex:D_,map_fragment:N_,map_pars_fragment:U_,map_particle_fragment:F_,map_particle_pars_fragment:O_,metalnessmap_fragment:B_,metalnessmap_pars_fragment:k_,morphinstance_vertex:z_,morphcolor_vertex:V_,morphnormal_vertex:G_,morphtarget_pars_vertex:H_,morphtarget_vertex:W_,normal_fragment_begin:X_,normal_fragment_maps:Y_,normal_pars_fragment:q_,normal_pars_vertex:Z_,normal_vertex:J_,normalmap_pars_fragment:$_,clearcoat_normal_fragment_begin:K_,clearcoat_normal_fragment_maps:Q_,clearcoat_pars_fragment:j_,iridescence_pars_fragment:eM,opaque_fragment:tM,packing:nM,premultiplied_alpha_fragment:iM,project_vertex:rM,dithering_fragment:aM,dithering_pars_fragment:sM,roughnessmap_fragment:oM,roughnessmap_pars_fragment:lM,shadowmap_pars_fragment:cM,shadowmap_pars_vertex:uM,shadowmap_vertex:dM,shadowmask_pars_fragment:fM,skinbase_vertex:hM,skinning_pars_vertex:pM,skinning_vertex:mM,skinnormal_vertex:vM,specularmap_fragment:gM,specularmap_pars_fragment:yM,tonemapping_fragment:xM,tonemapping_pars_fragment:_M,transmission_fragment:MM,transmission_pars_fragment:SM,uv_pars_fragment:bM,uv_pars_vertex:wM,uv_vertex:TM,worldpos_vertex:EM,background_vert:AM,background_frag:IM,backgroundCube_vert:CM,backgroundCube_frag:RM,cube_vert:PM,cube_frag:LM,depth_vert:DM,depth_frag:NM,distance_vert:UM,distance_frag:FM,equirect_vert:OM,equirect_frag:BM,linedashed_vert:kM,linedashed_frag:zM,meshbasic_vert:VM,meshbasic_frag:GM,meshlambert_vert:HM,meshlambert_frag:WM,meshmatcap_vert:XM,meshmatcap_frag:YM,meshnormal_vert:qM,meshnormal_frag:ZM,meshphong_vert:JM,meshphong_frag:$M,meshphysical_vert:KM,meshphysical_frag:QM,meshtoon_vert:jM,meshtoon_frag:eS,points_vert:tS,points_frag:nS,shadow_vert:iS,shadow_frag:rS,sprite_vert:aS,sprite_frag:sS},zt={common:{diffuse:{value:new Rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ln}},envmap:{envMap:{value:null},envMapRotation:{value:new Ln},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ln}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ln}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ln},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ln},normalScale:{value:new qt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ln},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ln}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ln}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ln}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Rn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new ge},probesMax:{value:new ge},probesResolution:{value:new ge}},points:{diffuse:{value:new Rn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0},uvTransform:{value:new Ln}},sprite:{diffuse:{value:new Rn(16777215)},opacity:{value:1},center:{value:new qt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}}},Xa={basic:{uniforms:Ar([zt.common,zt.specularmap,zt.envmap,zt.aomap,zt.lightmap,zt.fog]),vertexShader:Gn.meshbasic_vert,fragmentShader:Gn.meshbasic_frag},lambert:{uniforms:Ar([zt.common,zt.specularmap,zt.envmap,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.fog,zt.lights,{emissive:{value:new Rn(0)},envMapIntensity:{value:1}}]),vertexShader:Gn.meshlambert_vert,fragmentShader:Gn.meshlambert_frag},phong:{uniforms:Ar([zt.common,zt.specularmap,zt.envmap,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.fog,zt.lights,{emissive:{value:new Rn(0)},specular:{value:new Rn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Gn.meshphong_vert,fragmentShader:Gn.meshphong_frag},standard:{uniforms:Ar([zt.common,zt.envmap,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.roughnessmap,zt.metalnessmap,zt.fog,zt.lights,{emissive:{value:new Rn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Gn.meshphysical_vert,fragmentShader:Gn.meshphysical_frag},toon:{uniforms:Ar([zt.common,zt.aomap,zt.lightmap,zt.emissivemap,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.gradientmap,zt.fog,zt.lights,{emissive:{value:new Rn(0)}}]),vertexShader:Gn.meshtoon_vert,fragmentShader:Gn.meshtoon_frag},matcap:{uniforms:Ar([zt.common,zt.bumpmap,zt.normalmap,zt.displacementmap,zt.fog,{matcap:{value:null}}]),vertexShader:Gn.meshmatcap_vert,fragmentShader:Gn.meshmatcap_frag},points:{uniforms:Ar([zt.points,zt.fog]),vertexShader:Gn.points_vert,fragmentShader:Gn.points_frag},dashed:{uniforms:Ar([zt.common,zt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Gn.linedashed_vert,fragmentShader:Gn.linedashed_frag},depth:{uniforms:Ar([zt.common,zt.displacementmap]),vertexShader:Gn.depth_vert,fragmentShader:Gn.depth_frag},normal:{uniforms:Ar([zt.common,zt.bumpmap,zt.normalmap,zt.displacementmap,{opacity:{value:1}}]),vertexShader:Gn.meshnormal_vert,fragmentShader:Gn.meshnormal_frag},sprite:{uniforms:Ar([zt.sprite,zt.fog]),vertexShader:Gn.sprite_vert,fragmentShader:Gn.sprite_frag},background:{uniforms:{uvTransform:{value:new Ln},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Gn.background_vert,fragmentShader:Gn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ln}},vertexShader:Gn.backgroundCube_vert,fragmentShader:Gn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Gn.cube_vert,fragmentShader:Gn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Gn.equirect_vert,fragmentShader:Gn.equirect_frag},distance:{uniforms:Ar([zt.common,zt.displacementmap,{referencePosition:{value:new ge},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Gn.distance_vert,fragmentShader:Gn.distance_frag},shadow:{uniforms:Ar([zt.lights,zt.fog,{color:{value:new Rn(0)},opacity:{value:1}}]),vertexShader:Gn.shadow_vert,fragmentShader:Gn.shadow_frag}};Xa.physical={uniforms:Ar([Xa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ln},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ln},clearcoatNormalScale:{value:new qt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ln},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ln},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ln},sheen:{value:0},sheenColor:{value:new Rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ln},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ln},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ln},transmissionSamplerSize:{value:new qt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ln},attenuationDistance:{value:0},attenuationColor:{value:new Rn(0)},specularColor:{value:new Rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ln},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ln},anisotropyVector:{value:new qt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ln}}]),vertexShader:Gn.meshphysical_vert,fragmentShader:Gn.meshphysical_frag};var cf={r:0,b:0,g:0},oS=new Un,F0=new Ln;F0.set(-1,0,0,0,1,0,0,0,1);function lS(n,e,t,i,r,a){let s=new Rn(0),o=r===!0?0:1,u,l,d=null,f=0,h=null;function m(P){let p=P.isScene===!0?P.background:null;if(p&&p.isTexture){let _=P.backgroundBlurriness>0;p=e.get(p,_)}return p}function y(P){let p=!1,_=m(P);_===null?g(s,o):_&&_.isColor&&(g(_,1),p=!0);let N=n.xr.getEnvironmentBlendMode();N==="additive"?t.buffers.color.setClear(0,0,0,1,a):N==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,a),(n.autoClear||p)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function M(P,p){let _=m(p);_&&(_.isCubeTexture||_.mapping===Ec)?(l===void 0&&(l=new ai(new Lr(1,1,1),new ea({name:"BackgroundCubeMaterial",uniforms:po(Xa.backgroundCube.uniforms),vertexShader:Xa.backgroundCube.vertexShader,fragmentShader:Xa.backgroundCube.fragmentShader,side:Dr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(N,D,B){this.matrixWorld.copyPosition(B.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(oS.makeRotationFromEuler(p.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(F0),l.material.toneMapped=jn.getTransfer(_.colorSpace)!==gi,(d!==_||f!==_.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,d=_,f=_.version,h=n.toneMapping),l.layers.enableAll(),P.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(u===void 0&&(u=new ai(new mc(2,2),new ea({name:"BackgroundMaterial",uniforms:po(Xa.background.uniforms),vertexShader:Xa.background.vertexShader,fragmentShader:Xa.background.fragmentShader,side:Va,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=_,u.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,u.material.toneMapped=jn.getTransfer(_.colorSpace)!==gi,_.matrixAutoUpdate===!0&&_.updateMatrix(),u.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||f!==_.version||h!==n.toneMapping)&&(u.material.needsUpdate=!0,d=_,f=_.version,h=n.toneMapping),u.layers.enableAll(),P.unshift(u,u.geometry,u.material,0,0,null))}function g(P,p){P.getRGB(cf,lp(n)),t.buffers.color.setClear(cf.r,cf.g,cf.b,p,a)}function v(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return s},setClearColor:function(P,p=1){s.set(P),o=p,g(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(P){o=P,g(s,o)},render:y,addToRenderList:M,dispose:v}}function cS(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),a=r,s=!1;function o(V,$,T,S,Y){let W=!1,se=f(V,S,T,$);a!==se&&(a=se,l(a.object)),W=m(V,S,T,Y),W&&y(V,S,T,Y),Y!==null&&e.update(Y,n.ELEMENT_ARRAY_BUFFER),(W||s)&&(s=!1,_(V,$,T,S),Y!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function u(){return n.createVertexArray()}function l(V){return n.bindVertexArray(V)}function d(V){return n.deleteVertexArray(V)}function f(V,$,T,S){let Y=S.wireframe===!0,W=i[$.id];W===void 0&&(W={},i[$.id]=W);let se=V.isInstancedMesh===!0?V.id:0,O=W[se];O===void 0&&(O={},W[se]=O);let U=O[T.id];U===void 0&&(U={},O[T.id]=U);let H=U[Y];return H===void 0&&(H=h(u()),U[Y]=H),H}function h(V){let $=[],T=[],S=[];for(let Y=0;Y<t;Y++)$[Y]=0,T[Y]=0,S[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:T,attributeDivisors:S,object:V,attributes:{},index:null}}function m(V,$,T,S){let Y=a.attributes,W=$.attributes,se=0,O=T.getAttributes();for(let U in O)if(O[U].location>=0){let ne=Y[U],ce=W[U];if(ce===void 0&&(U==="instanceMatrix"&&V.instanceMatrix&&(ce=V.instanceMatrix),U==="instanceColor"&&V.instanceColor&&(ce=V.instanceColor)),ne===void 0||ne.attribute!==ce||ce&&ne.data!==ce.data)return!0;se++}return a.attributesNum!==se||a.index!==S}function y(V,$,T,S){let Y={},W=$.attributes,se=0,O=T.getAttributes();for(let U in O)if(O[U].location>=0){let ne=W[U];ne===void 0&&(U==="instanceMatrix"&&V.instanceMatrix&&(ne=V.instanceMatrix),U==="instanceColor"&&V.instanceColor&&(ne=V.instanceColor));let ce={};ce.attribute=ne,ne&&ne.data&&(ce.data=ne.data),Y[U]=ce,se++}a.attributes=Y,a.attributesNum=se,a.index=S}function M(){let V=a.newAttributes;for(let $=0,T=V.length;$<T;$++)V[$]=0}function g(V){v(V,0)}function v(V,$){let T=a.newAttributes,S=a.enabledAttributes,Y=a.attributeDivisors;T[V]=1,S[V]===0&&(n.enableVertexAttribArray(V),S[V]=1),Y[V]!==$&&(n.vertexAttribDivisor(V,$),Y[V]=$)}function P(){let V=a.newAttributes,$=a.enabledAttributes;for(let T=0,S=$.length;T<S;T++)$[T]!==V[T]&&(n.disableVertexAttribArray(T),$[T]=0)}function p(V,$,T,S,Y,W,se){se===!0?n.vertexAttribIPointer(V,$,T,Y,W):n.vertexAttribPointer(V,$,T,S,Y,W)}function _(V,$,T,S){M();let Y=S.attributes,W=T.getAttributes(),se=$.defaultAttributeValues;for(let O in W){let U=W[O];if(U.location>=0){let H=Y[O];if(H===void 0&&(O==="instanceMatrix"&&V.instanceMatrix&&(H=V.instanceMatrix),O==="instanceColor"&&V.instanceColor&&(H=V.instanceColor)),H!==void 0){let ne=H.normalized,ce=H.itemSize,pe=e.get(H);if(pe===void 0)continue;let le=pe.buffer,be=pe.type,Pe=pe.bytesPerElement,Q=be===n.INT||be===n.UNSIGNED_INT||H.gpuType===bd;if(H.isInterleavedBufferAttribute){let ie=H.data,Me=ie.stride,Le=H.offset;if(ie.isInstancedInterleavedBuffer){for(let Ee=0;Ee<U.locationSize;Ee++)v(U.location+Ee,ie.meshPerAttribute);V.isInstancedMesh!==!0&&S._maxInstanceCount===void 0&&(S._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let Ee=0;Ee<U.locationSize;Ee++)g(U.location+Ee);n.bindBuffer(n.ARRAY_BUFFER,le);for(let Ee=0;Ee<U.locationSize;Ee++)p(U.location+Ee,ce/U.locationSize,be,ne,Me*Pe,(Le+ce/U.locationSize*Ee)*Pe,Q)}else{if(H.isInstancedBufferAttribute){for(let ie=0;ie<U.locationSize;ie++)v(U.location+ie,H.meshPerAttribute);V.isInstancedMesh!==!0&&S._maxInstanceCount===void 0&&(S._maxInstanceCount=H.meshPerAttribute*H.count)}else for(let ie=0;ie<U.locationSize;ie++)g(U.location+ie);n.bindBuffer(n.ARRAY_BUFFER,le);for(let ie=0;ie<U.locationSize;ie++)p(U.location+ie,ce/U.locationSize,be,ne,ce*Pe,ce/U.locationSize*ie*Pe,Q)}}else if(se!==void 0){let ne=se[O];if(ne!==void 0)switch(ne.length){case 2:n.vertexAttrib2fv(U.location,ne);break;case 3:n.vertexAttrib3fv(U.location,ne);break;case 4:n.vertexAttrib4fv(U.location,ne);break;default:n.vertexAttrib1fv(U.location,ne)}}}}P()}function N(){A();for(let V in i){let $=i[V];for(let T in $){let S=$[T];for(let Y in S){let W=S[Y];for(let se in W)d(W[se].object),delete W[se];delete S[Y]}}delete i[V]}}function D(V){if(i[V.id]===void 0)return;let $=i[V.id];for(let T in $){let S=$[T];for(let Y in S){let W=S[Y];for(let se in W)d(W[se].object),delete W[se];delete S[Y]}}delete i[V.id]}function B(V){for(let $ in i){let T=i[$];for(let S in T){let Y=T[S];if(Y[V.id]===void 0)continue;let W=Y[V.id];for(let se in W)d(W[se].object),delete W[se];delete Y[V.id]}}}function w(V){for(let $ in i){let T=i[$],S=V.isInstancedMesh===!0?V.id:0,Y=T[S];if(Y!==void 0){for(let W in Y){let se=Y[W];for(let O in se)d(se[O].object),delete se[O];delete Y[W]}delete T[S],Object.keys(T).length===0&&delete i[$]}}}function A(){z(),s=!0,a!==r&&(a=r,l(a.object))}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:A,resetDefaultState:z,dispose:N,releaseStatesOfGeometry:D,releaseStatesOfObject:w,releaseStatesOfProgram:B,initAttributes:M,enableAttribute:g,disableUnusedAttributes:P}}function uS(n,e,t){let i;function r(u){i=u}function a(u,l){n.drawArrays(i,u,l),t.update(l,i,1)}function s(u,l,d){d!==0&&(n.drawArraysInstanced(i,u,l,d),t.update(l,i,d))}function o(u,l,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,u,0,l,0,d);let h=0;for(let m=0;m<d;m++)h+=l[m];t.update(h,i,1)}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o}function dS(n,e,t,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let B=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(B.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(B){return!(B!==ia&&i.convert(B)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(B){let w=B===Ca&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(B!==Hr&&B!==na&&!w&&i.convert(B)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE))}function u(B){if(B==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";B="mediump"}return B==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",d=u(l);d!==l&&(mn("WebGLRenderer:",l,"not supported, using",d,"instead."),l=d);let f=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&mn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),M=n.getParameter(n.MAX_TEXTURE_SIZE),g=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),v=n.getParameter(n.MAX_VERTEX_ATTRIBS),P=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),p=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),N=n.getParameter(n.MAX_SAMPLES),D=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:u,textureFormatReadable:s,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:m,maxVertexTextures:y,maxTextureSize:M,maxCubemapSize:g,maxAttributes:v,maxVertexUniforms:P,maxVaryings:p,maxFragmentUniforms:_,maxSamples:N,samples:D}}function fS(n){let e=this,t=null,i=0,r=!1,a=!1,s=new Kr,o=new Ln,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let m=f.length!==0||h||i!==0||r;return r=h,i=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,h){t=d(f,h,0)},this.setState=function(f,h,m){let y=f.clippingPlanes,M=f.clipIntersection,g=f.clipShadows,v=n.get(f);if(!r||y===null||y.length===0||a&&!g)a?d(null):l();else{let P=a?0:i,p=P*4,_=v.clippingState||null;u.value=_,_=d(y,h,p,m);for(let N=0;N!==p;++N)_[N]=t[N];v.clippingState=_,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=P}};function l(){u.value!==t&&(u.value=t,u.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(f,h,m,y){let M=f!==null?f.length:0,g=null;if(M!==0){if(g=u.value,y!==!0||g===null){let v=m+M*4,P=h.matrixWorldInverse;o.getNormalMatrix(P),(g===null||g.length<v)&&(g=new Float32Array(v));for(let p=0,_=m;p!==M;++p,_+=4)s.copy(f[p]).applyMatrix4(P,o),s.normal.toArray(g,_),g[_+3]=s.constant}u.value=g,u.needsUpdate=!0}return e.numPlanes=M,e.numIntersection=0,g}}var gl=4,hS=6,pS=20,mS=256,Nc=new cl,p0=new Rn,gp=null,yp=0,xp=0,_p=!1,vS=new ge,mo=new ge,xl=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,a={}){let{size:s=256,position:o=vS}=a;gp=this._renderer.getRenderTarget(),yp=this._renderer.getActiveCubeFace(),xp=this._renderer.getActiveMipmapLevel(),_p=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let u=this._allocateTargets();return u.depthBuffer=!0,this._sceneToCubeUV(e,i,r,u,o),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=g0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=v0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(gp,yp,xp),this._renderer.xr.enabled=_p,e.scissorTest=!1,vl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Rs||e.mapping===uo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),gp=this._renderer.getRenderTarget(),yp=this._renderer.getActiveCubeFace(),xp=this._renderer.getActiveMipmapLevel(),_p=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:rr,minFilter:rr,generateMipmaps:!1,type:Ca,format:ia,colorSpace:Kl,depthBuffer:!1},r=m0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=m0(e,t,i);let{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=gS(a)),this._blurMaterial=xS(a,e,t),this._ggxMaterial=yS(a,e,t)}return r}_compileMaterial(e){let t=new ai(new sr,e);this._renderer.compile(t,Nc)}_sceneToCubeUV(e,t,i,r,a){let u=new wr(90,1,t,i),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,h=f.autoClear,m=f.toneMapping;f.getClearColor(p0),f.toneMapping=Gr,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new ai(new Lr,new Vr({name:"PMREM.Background",side:Dr,depthWrite:!1,depthTest:!1})));let M=this._backgroundBox,g=M.material,v=!1,P=e.background;P?P.isColor&&(g.color.copy(P),e.background=null,v=!0):(g.color.copy(p0),v=!0);for(let p=0;p<6;p++){let _=p%3;_===0?(u.up.set(0,l[p],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x+d[p],a.y,a.z)):_===1?(u.up.set(0,0,l[p]),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y+d[p],a.z)):(u.up.set(0,l[p],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y,a.z+d[p]));let N=this._cubeSize;vl(r,_*N,p>2?N:0,N,N),f.setRenderTarget(r),v&&f.render(M,u),f.render(e,u)}f.toneMapping=m,f.autoClear=h,e.background=P}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===Rs||e.mapping===uo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=g0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=v0());let a=r?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;let o=a.uniforms;o.envMap.value=e;let u=this._cubeSize;vl(t,0,0,3*u,2*u),i.setRenderTarget(t),i.render(s,Nc)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let a=1;a<r;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=i}_applyGGXFilter(e,t,i){let r=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;let u=s.uniforms,l=i/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),f=Math.sqrt(l*l-d*d),h=l*1.25,m=f*h,{_lodMax:y}=this,M=this._sizeLods[i],g=3*M*(i>y-gl?i-y+gl:0),v=4*(this._cubeSize-M);u.envMap.value=e.texture,u.roughness.value=m,u.mipInt.value=y-t,vl(a,g,v,3*M,2*M),r.setRenderTarget(a),r.render(o,Nc),u.envMap.value=a.texture,u.roughness.value=0,u.mipInt.value=y-i,vl(e,g,v,3*M,2*M),r.setRenderTarget(e),r.render(o,Nc)}_blur(e,t,i,r){let a=this._pingPongRenderTarget,s=Math.min(r,Math.PI)/Math.SQRT2;this._blurPass(e,a,t,i,s),this._blurPass(a,e,i,i,s)}_blurPass(e,t,i,r,a){let s=this._renderer,o=this._blurMaterial,u=this._lodMeshes[r];u.material=o;let l=o.uniforms;l.envMap.value=e.texture,l.sigma.value=a,l.mipInt.value=this._lodMax-i;let d=this._sizeLods[r],f=3*d*(r>this._lodMax-gl?r-this._lodMax+gl:0),h=4*(this._cubeSize-d);vl(t,f,h,3*d,2*d),s.setRenderTarget(t),s.render(u,Nc)}};function gS(n){let e=[],t=[],i=n,r=n-gl+1+hS;for(let a=0;a<r;a++){let s=Math.pow(2,i);e.push(s);let o=1/(s-2),u=-o,l=1+o,d=[u,u,l,u,l,l,u,u,l,l,u,l],f=6,h=6,m=3,y=new Float32Array(m*h*f),M=new Float32Array(m*h*f);for(let v=0;v<f;v++){let P=v%3*2/3-1,p=v>2?0:-1,_=[P,p,0,P+2/3,p,0,P+2/3,p+1,0,P,p,0,P+2/3,p+1,0,P,p+1,0];y.set(_,m*h*v);for(let N=0;N<h;N++){let D=d[N*2]*2-1,B=d[N*2+1]*2-1;v===0?mo.set(1,B,D):v===1?mo.set(-D,1,-B):v===2?mo.set(-D,B,1):v===3?mo.set(-1,B,-D):v===4?mo.set(-D,-1,B):mo.set(D,B,-1),mo.toArray(M,(v*h+N)*m)}}let g=new sr;g.setAttribute("position",new Tr(y,m)),g.setAttribute("outputDirection",new Tr(M,m)),t.push(new ai(g,null)),i>gl&&i--}return{lodMeshes:t,sizeLods:e}}function m0(n,e,t){let i=new zr(n,e,t);return i.texture.mapping=Ec,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function vl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function yS(n,e,t){return new ea({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:mS,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:hf(),fragmentShader:`
|
|
3823
|
+
}`,ai={alphahash_fragment:$x,alphahash_pars_fragment:Kx,alphamap_fragment:Qx,alphamap_pars_fragment:jx,alphatest_fragment:e_,alphatest_pars_fragment:t_,aomap_fragment:n_,aomap_pars_fragment:i_,batching_pars_vertex:r_,batching_vertex:a_,begin_vertex:s_,beginnormal_vertex:o_,bsdfs:l_,iridescence_fragment:c_,bumpmap_pars_fragment:u_,clipping_planes_fragment:d_,clipping_planes_pars_fragment:f_,clipping_planes_pars_vertex:h_,clipping_planes_vertex:p_,color_fragment:m_,color_pars_fragment:v_,color_pars_vertex:g_,color_vertex:y_,common:x_,cube_uv_reflection_fragment:__,defaultnormal_vertex:M_,displacementmap_pars_vertex:S_,displacementmap_vertex:b_,emissivemap_fragment:w_,emissivemap_pars_fragment:T_,colorspace_fragment:A_,colorspace_pars_fragment:E_,envmap_fragment:I_,envmap_common_pars_fragment:C_,envmap_pars_fragment:R_,envmap_pars_vertex:P_,envmap_physical_pars_fragment:G_,envmap_vertex:L_,fog_vertex:D_,fog_pars_vertex:N_,fog_fragment:U_,fog_pars_fragment:F_,gradientmap_pars_fragment:O_,lightmap_pars_fragment:B_,lights_lambert_fragment:k_,lights_lambert_pars_fragment:z_,lights_pars_begin:V_,lights_toon_fragment:H_,lights_toon_pars_fragment:W_,lights_phong_fragment:X_,lights_phong_pars_fragment:Y_,lights_physical_fragment:q_,lights_physical_pars_fragment:Z_,lights_fragment_begin:J_,lights_fragment_maps:$_,lights_fragment_end:K_,lightprobes_pars_fragment:Q_,logdepthbuf_fragment:j_,logdepthbuf_pars_fragment:eM,logdepthbuf_pars_vertex:tM,logdepthbuf_vertex:nM,map_fragment:iM,map_pars_fragment:rM,map_particle_fragment:aM,map_particle_pars_fragment:sM,metalnessmap_fragment:oM,metalnessmap_pars_fragment:lM,morphinstance_vertex:cM,morphcolor_vertex:uM,morphnormal_vertex:dM,morphtarget_pars_vertex:fM,morphtarget_vertex:hM,normal_fragment_begin:pM,normal_fragment_maps:mM,normal_pars_fragment:vM,normal_pars_vertex:gM,normal_vertex:yM,normalmap_pars_fragment:xM,clearcoat_normal_fragment_begin:_M,clearcoat_normal_fragment_maps:MM,clearcoat_pars_fragment:SM,iridescence_pars_fragment:bM,opaque_fragment:wM,packing:TM,premultiplied_alpha_fragment:AM,project_vertex:EM,dithering_fragment:IM,dithering_pars_fragment:CM,roughnessmap_fragment:RM,roughnessmap_pars_fragment:PM,shadowmap_pars_fragment:LM,shadowmap_pars_vertex:DM,shadowmap_vertex:NM,shadowmask_pars_fragment:UM,skinbase_vertex:FM,skinning_pars_vertex:OM,skinning_vertex:BM,skinnormal_vertex:kM,specularmap_fragment:zM,specularmap_pars_fragment:VM,tonemapping_fragment:GM,tonemapping_pars_fragment:HM,transmission_fragment:WM,transmission_pars_fragment:XM,uv_pars_fragment:YM,uv_pars_vertex:qM,uv_vertex:ZM,worldpos_vertex:JM,background_vert:$M,background_frag:KM,backgroundCube_vert:QM,backgroundCube_frag:jM,cube_vert:eS,cube_frag:tS,depth_vert:nS,depth_frag:iS,distance_vert:rS,distance_frag:aS,equirect_vert:sS,equirect_frag:oS,linedashed_vert:lS,linedashed_frag:cS,meshbasic_vert:uS,meshbasic_frag:dS,meshlambert_vert:fS,meshlambert_frag:hS,meshmatcap_vert:pS,meshmatcap_frag:mS,meshnormal_vert:vS,meshnormal_frag:gS,meshphong_vert:yS,meshphong_frag:xS,meshphysical_vert:_S,meshphysical_frag:MS,meshtoon_vert:SS,meshtoon_frag:bS,points_vert:wS,points_frag:TS,shadow_vert:AS,shadow_frag:ES,sprite_vert:IS,sprite_frag:CS},$t={common:{diffuse:{value:new zn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qn},alphaMap:{value:null},alphaMapTransform:{value:new qn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qn}},envmap:{envMap:{value:null},envMapRotation:{value:new qn},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qn},normalScale:{value:new tn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new xe},probesMax:{value:new xe},probesResolution:{value:new xe}},points:{diffuse:{value:new zn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qn},alphaTest:{value:0},uvTransform:{value:new qn}},sprite:{diffuse:{value:new zn(16777215)},opacity:{value:1},center:{value:new tn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qn},alphaMap:{value:null},alphaMapTransform:{value:new qn},alphaTest:{value:0}}},es={basic:{uniforms:kr([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.fog]),vertexShader:ai.meshbasic_vert,fragmentShader:ai.meshbasic_frag},lambert:{uniforms:kr([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,$t.lights,{emissive:{value:new zn(0)},envMapIntensity:{value:1}}]),vertexShader:ai.meshlambert_vert,fragmentShader:ai.meshlambert_frag},phong:{uniforms:kr([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,$t.lights,{emissive:{value:new zn(0)},specular:{value:new zn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ai.meshphong_vert,fragmentShader:ai.meshphong_frag},standard:{uniforms:kr([$t.common,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.roughnessmap,$t.metalnessmap,$t.fog,$t.lights,{emissive:{value:new zn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ai.meshphysical_vert,fragmentShader:ai.meshphysical_frag},toon:{uniforms:kr([$t.common,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.gradientmap,$t.fog,$t.lights,{emissive:{value:new zn(0)}}]),vertexShader:ai.meshtoon_vert,fragmentShader:ai.meshtoon_frag},matcap:{uniforms:kr([$t.common,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,{matcap:{value:null}}]),vertexShader:ai.meshmatcap_vert,fragmentShader:ai.meshmatcap_frag},points:{uniforms:kr([$t.points,$t.fog]),vertexShader:ai.points_vert,fragmentShader:ai.points_frag},dashed:{uniforms:kr([$t.common,$t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ai.linedashed_vert,fragmentShader:ai.linedashed_frag},depth:{uniforms:kr([$t.common,$t.displacementmap]),vertexShader:ai.depth_vert,fragmentShader:ai.depth_frag},normal:{uniforms:kr([$t.common,$t.bumpmap,$t.normalmap,$t.displacementmap,{opacity:{value:1}}]),vertexShader:ai.meshnormal_vert,fragmentShader:ai.meshnormal_frag},sprite:{uniforms:kr([$t.sprite,$t.fog]),vertexShader:ai.sprite_vert,fragmentShader:ai.sprite_frag},background:{uniforms:{uvTransform:{value:new qn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ai.background_vert,fragmentShader:ai.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qn}},vertexShader:ai.backgroundCube_vert,fragmentShader:ai.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ai.cube_vert,fragmentShader:ai.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ai.equirect_vert,fragmentShader:ai.equirect_frag},distance:{uniforms:kr([$t.common,$t.displacementmap,{referencePosition:{value:new xe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ai.distance_vert,fragmentShader:ai.distance_frag},shadow:{uniforms:kr([$t.lights,$t.fog,{color:{value:new zn(0)},opacity:{value:1}}]),vertexShader:ai.shadow_vert,fragmentShader:ai.shadow_frag}};es.physical={uniforms:kr([es.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qn},clearcoatNormalScale:{value:new tn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qn},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qn},sheen:{value:0},sheenColor:{value:new zn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qn},transmissionSamplerSize:{value:new tn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qn},attenuationDistance:{value:0},attenuationColor:{value:new zn(0)},specularColor:{value:new zn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qn},anisotropyVector:{value:new tn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qn}}]),vertexShader:ai.meshphysical_vert,fragmentShader:ai.meshphysical_frag};var vf={r:0,b:0,g:0},RS=new Kn,tg=new qn;tg.set(-1,0,0,0,1,0,0,0,1);function PS(n,e,t,i,r,a){let s=new zn(0),o=r===!0?0:1,u,l,d=null,f=0,h=null;function m(L){let p=L.isScene===!0?L.background:null;if(p&&p.isTexture){let _=L.backgroundBlurriness>0;p=e.get(p,_)}return p}function y(L){let p=!1,_=m(L);_===null?g(s,o):_&&_.isColor&&(g(_,1),p=!0);let N=n.xr.getEnvironmentBlendMode();N==="additive"?t.buffers.color.setClear(0,0,0,1,a):N==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,a),(n.autoClear||p)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function M(L,p){let _=m(p);_&&(_.isCubeTexture||_.mapping===Cc)?(l===void 0&&(l=new _i(new $r(1,1,1),new pa({name:"BackgroundCubeMaterial",uniforms:go(es.backgroundCube.uniforms),vertexShader:es.backgroundCube.vertexShader,fragmentShader:es.backgroundCube.fragmentShader,side:Kr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(N,D,V){this.matrixWorld.copyPosition(V.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(RS.makeRotationFromEuler(p.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(tg),l.material.toneMapped=mi.getTransfer(_.colorSpace)!==Li,(d!==_||f!==_.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,d=_,f=_.version,h=n.toneMapping),l.layers.enableAll(),L.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(u===void 0&&(u=new _i(new yc(2,2),new pa({name:"BackgroundMaterial",uniforms:go(es.background.uniforms),vertexShader:es.background.vertexShader,fragmentShader:es.background.fragmentShader,side:$a,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=_,u.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,u.material.toneMapped=mi.getTransfer(_.colorSpace)!==Li,_.matrixAutoUpdate===!0&&_.updateMatrix(),u.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||f!==_.version||h!==n.toneMapping)&&(u.material.needsUpdate=!0,d=_,f=_.version,h=n.toneMapping),u.layers.enableAll(),L.unshift(u,u.geometry,u.material,0,0,null))}function g(L,p){L.getRGB(vf,Mp(n)),t.buffers.color.setClear(vf.r,vf.g,vf.b,p,a)}function v(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return s},setClearColor:function(L,p=1){s.set(L),o=p,g(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(L){o=L,g(s,o)},render:y,addToRenderList:M,dispose:v}}function LS(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),a=r,s=!1;function o(H,Q,T,S,Z){let q=!1,se=f(H,S,T,Q);a!==se&&(a=se,l(a.object)),q=m(H,S,T,Z),q&&y(H,S,T,Z),Z!==null&&e.update(Z,n.ELEMENT_ARRAY_BUFFER),(q||s)&&(s=!1,_(H,Q,T,S),Z!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Z).buffer))}function u(){return n.createVertexArray()}function l(H){return n.bindVertexArray(H)}function d(H){return n.deleteVertexArray(H)}function f(H,Q,T,S){let Z=S.wireframe===!0,q=i[Q.id];q===void 0&&(q={},i[Q.id]=q);let se=H.isInstancedMesh===!0?H.id:0,F=q[se];F===void 0&&(F={},q[se]=F);let z=F[T.id];z===void 0&&(z={},F[T.id]=z);let Y=z[Z];return Y===void 0&&(Y=h(u()),z[Z]=Y),Y}function h(H){let Q=[],T=[],S=[];for(let Z=0;Z<t;Z++)Q[Z]=0,T[Z]=0,S[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:Q,enabledAttributes:T,attributeDivisors:S,object:H,attributes:{},index:null}}function m(H,Q,T,S){let Z=a.attributes,q=Q.attributes,se=0,F=T.getAttributes();for(let z in F)if(F[z].location>=0){let $=Z[z],he=q[z];if(he===void 0&&(z==="instanceMatrix"&&H.instanceMatrix&&(he=H.instanceMatrix),z==="instanceColor"&&H.instanceColor&&(he=H.instanceColor)),$===void 0||$.attribute!==he||he&&$.data!==he.data)return!0;se++}return a.attributesNum!==se||a.index!==S}function y(H,Q,T,S){let Z={},q=Q.attributes,se=0,F=T.getAttributes();for(let z in F)if(F[z].location>=0){let $=q[z];$===void 0&&(z==="instanceMatrix"&&H.instanceMatrix&&($=H.instanceMatrix),z==="instanceColor"&&H.instanceColor&&($=H.instanceColor));let he={};he.attribute=$,$&&$.data&&(he.data=$.data),Z[z]=he,se++}a.attributes=Z,a.attributesNum=se,a.index=S}function M(){let H=a.newAttributes;for(let Q=0,T=H.length;Q<T;Q++)H[Q]=0}function g(H){v(H,0)}function v(H,Q){let T=a.newAttributes,S=a.enabledAttributes,Z=a.attributeDivisors;T[H]=1,S[H]===0&&(n.enableVertexAttribArray(H),S[H]=1),Z[H]!==Q&&(n.vertexAttribDivisor(H,Q),Z[H]=Q)}function L(){let H=a.newAttributes,Q=a.enabledAttributes;for(let T=0,S=Q.length;T<S;T++)Q[T]!==H[T]&&(n.disableVertexAttribArray(T),Q[T]=0)}function p(H,Q,T,S,Z,q,se){se===!0?n.vertexAttribIPointer(H,Q,T,Z,q):n.vertexAttribPointer(H,Q,T,S,Z,q)}function _(H,Q,T,S){M();let Z=S.attributes,q=T.getAttributes(),se=Q.defaultAttributeValues;for(let F in q){let z=q[F];if(z.location>=0){let Y=Z[F];if(Y===void 0&&(F==="instanceMatrix"&&H.instanceMatrix&&(Y=H.instanceMatrix),F==="instanceColor"&&H.instanceColor&&(Y=H.instanceColor)),Y!==void 0){let $=Y.normalized,he=Y.itemSize,pe=e.get(Y);if(pe===void 0)continue;let le=pe.buffer,Te=pe.type,De=pe.bytesPerElement,oe=Te===n.INT||Te===n.UNSIGNED_INT||Y.gpuType===Rd;if(Y.isInterleavedBufferAttribute){let ee=Y.data,be=ee.stride,Be=Y.offset;if(ee.isInstancedInterleavedBuffer){for(let Re=0;Re<z.locationSize;Re++)v(z.location+Re,ee.meshPerAttribute);H.isInstancedMesh!==!0&&S._maxInstanceCount===void 0&&(S._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let Re=0;Re<z.locationSize;Re++)g(z.location+Re);n.bindBuffer(n.ARRAY_BUFFER,le);for(let Re=0;Re<z.locationSize;Re++)p(z.location+Re,he/z.locationSize,Te,$,be*De,(Be+he/z.locationSize*Re)*De,oe)}else{if(Y.isInstancedBufferAttribute){for(let ee=0;ee<z.locationSize;ee++)v(z.location+ee,Y.meshPerAttribute);H.isInstancedMesh!==!0&&S._maxInstanceCount===void 0&&(S._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let ee=0;ee<z.locationSize;ee++)g(z.location+ee);n.bindBuffer(n.ARRAY_BUFFER,le);for(let ee=0;ee<z.locationSize;ee++)p(z.location+ee,he/z.locationSize,Te,$,he*De,he/z.locationSize*ee*De,oe)}}else if(se!==void 0){let $=se[F];if($!==void 0)switch($.length){case 2:n.vertexAttrib2fv(z.location,$);break;case 3:n.vertexAttrib3fv(z.location,$);break;case 4:n.vertexAttrib4fv(z.location,$);break;default:n.vertexAttrib1fv(z.location,$)}}}}L()}function N(){I();for(let H in i){let Q=i[H];for(let T in Q){let S=Q[T];for(let Z in S){let q=S[Z];for(let se in q)d(q[se].object),delete q[se];delete S[Z]}}delete i[H]}}function D(H){if(i[H.id]===void 0)return;let Q=i[H.id];for(let T in Q){let S=Q[T];for(let Z in S){let q=S[Z];for(let se in q)d(q[se].object),delete q[se];delete S[Z]}}delete i[H.id]}function V(H){for(let Q in i){let T=i[Q];for(let S in T){let Z=T[S];if(Z[H.id]===void 0)continue;let q=Z[H.id];for(let se in q)d(q[se].object),delete q[se];delete Z[H.id]}}}function w(H){for(let Q in i){let T=i[Q],S=H.isInstancedMesh===!0?H.id:0,Z=T[S];if(Z!==void 0){for(let q in Z){let se=Z[q];for(let F in se)d(se[F].object),delete se[F];delete Z[q]}delete T[S],Object.keys(T).length===0&&delete i[Q]}}}function I(){G(),s=!0,a!==r&&(a=r,l(a.object))}function G(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:I,resetDefaultState:G,dispose:N,releaseStatesOfGeometry:D,releaseStatesOfObject:w,releaseStatesOfProgram:V,initAttributes:M,enableAttribute:g,disableUnusedAttributes:L}}function DS(n,e,t){let i;function r(u){i=u}function a(u,l){n.drawArrays(i,u,l),t.update(l,i,1)}function s(u,l,d){d!==0&&(n.drawArraysInstanced(i,u,l,d),t.update(l,i,d))}function o(u,l,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,u,0,l,0,d);let h=0;for(let m=0;m<d;m++)h+=l[m];t.update(h,i,1)}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o}function NS(n,e,t,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let V=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(V.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(V){return!(V!==ga&&i.convert(V)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(V){let w=V===Fa&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(V!==la&&V!==va&&!w&&i.convert(V)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE))}function u(V){if(V==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";V="mediump"}return V==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",d=u(l);d!==l&&(En("WebGLRenderer:",l,"not supported, using",d,"instead."),l=d);let f=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&En("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),M=n.getParameter(n.MAX_TEXTURE_SIZE),g=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),v=n.getParameter(n.MAX_VERTEX_ATTRIBS),L=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),p=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),N=n.getParameter(n.MAX_SAMPLES),D=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:u,textureFormatReadable:s,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:m,maxVertexTextures:y,maxTextureSize:M,maxCubemapSize:g,maxAttributes:v,maxVertexUniforms:L,maxVaryings:p,maxFragmentUniforms:_,maxSamples:N,samples:D}}function US(n){let e=this,t=null,i=0,r=!1,a=!1,s=new fa,o=new qn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let m=f.length!==0||h||i!==0||r;return r=h,i=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,h){t=d(f,h,0)},this.setState=function(f,h,m){let y=f.clippingPlanes,M=f.clipIntersection,g=f.clipShadows,v=n.get(f);if(!r||y===null||y.length===0||a&&!g)a?d(null):l();else{let L=a?0:i,p=L*4,_=v.clippingState||null;u.value=_,_=d(y,h,p,m);for(let N=0;N!==p;++N)_[N]=t[N];v.clippingState=_,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=L}};function l(){u.value!==t&&(u.value=t,u.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(f,h,m,y){let M=f!==null?f.length:0,g=null;if(M!==0){if(g=u.value,y!==!0||g===null){let v=m+M*4,L=h.matrixWorldInverse;o.getNormalMatrix(L),(g===null||g.length<v)&&(g=new Float32Array(v));for(let p=0,_=m;p!==M;++p,_+=4)s.copy(f[p]).applyMatrix4(L,o),s.normal.toArray(g,_),g[_+3]=s.constant}u.value=g,u.needsUpdate=!0}return e.numPlanes=M,e.numIntersection=0,g}}var gl=4,FS=6,OS=20,BS=256,Oc=new cl,D0=new zn,Rp=null,Pp=0,Lp=0,Dp=!1,kS=new xe,yo=new xe,xl=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,a={}){let{size:s=256,position:o=kS}=a;Rp=this._renderer.getRenderTarget(),Pp=this._renderer.getActiveCubeFace(),Lp=this._renderer.getActiveMipmapLevel(),Dp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let u=this._allocateTargets();return u.depthBuffer=!0,this._sceneToCubeUV(e,i,r,u,o),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=F0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=U0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Rp,Pp,Lp),this._renderer.xr.enabled=Dp,e.scissorTest=!1,vl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Gs||e.mapping===po?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Rp=this._renderer.getRenderTarget(),Pp=this._renderer.getActiveCubeFace(),Lp=this._renderer.getActiveMipmapLevel(),Dp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:lr,minFilter:lr,generateMipmaps:!1,type:Fa,format:ga,colorSpace:ec,depthBuffer:!1},r=N0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=N0(e,t,i);let{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=zS(a)),this._blurMaterial=GS(a,e,t),this._ggxMaterial=VS(a,e,t)}return r}_compileMaterial(e){let t=new _i(new ur,e);this._renderer.compile(t,Oc)}_sceneToCubeUV(e,t,i,r,a){let u=new Fr(90,1,t,i),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,h=f.autoClear,m=f.toneMapping;f.getClearColor(D0),f.toneMapping=oa,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new _i(new $r,new sa({name:"PMREM.Background",side:Kr,depthWrite:!1,depthTest:!1})));let M=this._backgroundBox,g=M.material,v=!1,L=e.background;L?L.isColor&&(g.color.copy(L),e.background=null,v=!0):(g.color.copy(D0),v=!0);for(let p=0;p<6;p++){let _=p%3;_===0?(u.up.set(0,l[p],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x+d[p],a.y,a.z)):_===1?(u.up.set(0,0,l[p]),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y+d[p],a.z)):(u.up.set(0,l[p],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y,a.z+d[p]));let N=this._cubeSize;vl(r,_*N,p>2?N:0,N,N),f.setRenderTarget(r),v&&f.render(M,u),f.render(e,u)}f.toneMapping=m,f.autoClear=h,e.background=L}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===Gs||e.mapping===po;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=F0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=U0());let a=r?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;let o=a.uniforms;o.envMap.value=e;let u=this._cubeSize;vl(t,0,0,3*u,2*u),i.setRenderTarget(t),i.render(s,Oc)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let a=1;a<r;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=i}_applyGGXFilter(e,t,i){let r=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;let u=s.uniforms,l=i/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),f=Math.sqrt(l*l-d*d),h=l*1.25,m=f*h,{_lodMax:y}=this,M=this._sizeLods[i],g=3*M*(i>y-gl?i-y+gl:0),v=4*(this._cubeSize-M);u.envMap.value=e.texture,u.roughness.value=m,u.mipInt.value=y-t,vl(a,g,v,3*M,2*M),r.setRenderTarget(a),r.render(o,Oc),u.envMap.value=a.texture,u.roughness.value=0,u.mipInt.value=y-i,vl(e,g,v,3*M,2*M),r.setRenderTarget(e),r.render(o,Oc)}_blur(e,t,i,r){let a=this._pingPongRenderTarget,s=Math.min(r,Math.PI)/Math.SQRT2;this._blurPass(e,a,t,i,s),this._blurPass(a,e,i,i,s)}_blurPass(e,t,i,r,a){let s=this._renderer,o=this._blurMaterial,u=this._lodMeshes[r];u.material=o;let l=o.uniforms;l.envMap.value=e.texture,l.sigma.value=a,l.mipInt.value=this._lodMax-i;let d=this._sizeLods[r],f=3*d*(r>this._lodMax-gl?r-this._lodMax+gl:0),h=4*(this._cubeSize-d);vl(t,f,h,3*d,2*d),s.setRenderTarget(t),s.render(u,Oc)}};function zS(n){let e=[],t=[],i=n,r=n-gl+1+FS;for(let a=0;a<r;a++){let s=Math.pow(2,i);e.push(s);let o=1/(s-2),u=-o,l=1+o,d=[u,u,l,u,l,l,u,u,l,l,u,l],f=6,h=6,m=3,y=new Float32Array(m*h*f),M=new Float32Array(m*h*f);for(let v=0;v<f;v++){let L=v%3*2/3-1,p=v>2?0:-1,_=[L,p,0,L+2/3,p,0,L+2/3,p+1,0,L,p,0,L+2/3,p+1,0,L,p+1,0];y.set(_,m*h*v);for(let N=0;N<h;N++){let D=d[N*2]*2-1,V=d[N*2+1]*2-1;v===0?yo.set(1,V,D):v===1?yo.set(-D,1,-V):v===2?yo.set(-D,V,1):v===3?yo.set(-1,V,-D):v===4?yo.set(-D,-1,V):yo.set(D,V,-1),yo.toArray(M,(v*h+N)*m)}}let g=new ur;g.setAttribute("position",new Or(y,m)),g.setAttribute("outputDirection",new Or(M,m)),t.push(new _i(g,null)),i>gl&&i--}return{lodMeshes:t,sizeLods:e}}function N0(n,e,t){let i=new aa(n,e,t);return i.texture.mapping=Cc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function vl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function VS(n,e,t){return new pa({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:BS,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:_f(),fragmentShader:`
|
|
3824
3824
|
|
|
3825
3825
|
precision highp float;
|
|
3826
3826
|
precision highp int;
|
|
@@ -3924,7 +3924,7 @@ void main() {
|
|
|
3924
3924
|
|
|
3925
3925
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
3926
3926
|
}
|
|
3927
|
-
`,blending:
|
|
3927
|
+
`,blending:Ka,depthTest:!1,depthWrite:!1})}function GS(n,e,t){return new pa({name:"SphericalGaussianBlur",defines:{SAMPLES:OS,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:_f(),fragmentShader:`
|
|
3928
3928
|
|
|
3929
3929
|
precision highp float;
|
|
3930
3930
|
precision highp int;
|
|
@@ -3984,7 +3984,7 @@ void main() {
|
|
|
3984
3984
|
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
|
|
3985
3985
|
|
|
3986
3986
|
}
|
|
3987
|
-
`,blending:
|
|
3987
|
+
`,blending:Ka,depthTest:!1,depthWrite:!1})}function U0(){return new pa({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_f(),fragmentShader:`
|
|
3988
3988
|
|
|
3989
3989
|
precision mediump float;
|
|
3990
3990
|
precision mediump int;
|
|
@@ -4003,7 +4003,7 @@ void main() {
|
|
|
4003
4003
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
4004
4004
|
|
|
4005
4005
|
}
|
|
4006
|
-
`,blending:
|
|
4006
|
+
`,blending:Ka,depthTest:!1,depthWrite:!1})}function F0(){return new pa({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_f(),fragmentShader:`
|
|
4007
4007
|
|
|
4008
4008
|
precision mediump float;
|
|
4009
4009
|
precision mediump int;
|
|
@@ -4019,7 +4019,7 @@ void main() {
|
|
|
4019
4019
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
4020
4020
|
|
|
4021
4021
|
}
|
|
4022
|
-
`,blending:
|
|
4022
|
+
`,blending:Ka,depthTest:!1,depthWrite:!1})}function _f(){return`
|
|
4023
4023
|
|
|
4024
4024
|
precision mediump float;
|
|
4025
4025
|
precision mediump int;
|
|
@@ -4034,7 +4034,7 @@ void main() {
|
|
|
4034
4034
|
gl_Position = vec4( position, 1.0 );
|
|
4035
4035
|
|
|
4036
4036
|
}
|
|
4037
|
-
`}var
|
|
4037
|
+
`}var yf=class extends aa{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new cc(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
4038
4038
|
|
|
4039
4039
|
varying vec3 vWorldDirection;
|
|
4040
4040
|
|
|
@@ -4069,7 +4069,7 @@ void main() {
|
|
|
4069
4069
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4070
4070
|
|
|
4071
4071
|
}
|
|
4072
|
-
`},r=new
|
|
4072
|
+
`},r=new $r(5,5,5),a=new pa({name:"CubemapFromEquirect",uniforms:go(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Kr,blending:Ka});a.uniforms.tEquirect.value=t;let s=new _i(r,a),o=t.minFilter;return t.minFilter===Qa&&(t.minFilter=lr),new bd(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){let a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,r);e.setRenderTarget(a)}};function HS(n){let e=new WeakMap,t=new WeakMap,i=null;function r(h,m=!1){return h==null?null:m?s(h):a(h)}function a(h){if(h&&h.isTexture){let m=h.mapping;if(m===fl||m===Id)if(e.has(h)){let y=e.get(h).texture;return o(y,h.mapping)}else{let y=h.image;if(y&&y.height>0){let M=new yf(y.height);return M.fromEquirectangularTexture(n,h),e.set(h,M),h.addEventListener("dispose",l),o(M.texture,h.mapping)}else return null}}return h}function s(h){if(h&&h.isTexture){let m=h.mapping,y=m===fl||m===Id,M=m===Gs||m===po;if(y||M){let g=t.get(h),v=g!==void 0?g.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==v)return i===null&&(i=new xl(n)),g=y?i.fromEquirectangular(h,g):i.fromCubemap(h,g),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),g.texture;if(g!==void 0)return g.texture;{let L=h.image;return y&&L&&L.height>0||M&&L&&u(L)?(i===null&&(i=new xl(n)),g=y?i.fromEquirectangular(h):i.fromCubemap(h),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),h.addEventListener("dispose",d),g.texture):null}}}return h}function o(h,m){return m===fl?h.mapping=Gs:m===Id&&(h.mapping=po),h}function u(h){let m=0,y=6;for(let M=0;M<y;M++)h[M]!==void 0&&m++;return m===y}function l(h){let m=h.target;m.removeEventListener("dispose",l);let y=e.get(m);y!==void 0&&(e.delete(m),y.dispose())}function d(h){let m=h.target;m.removeEventListener("dispose",d);let y=t.get(m);y!==void 0&&(t.delete(m),y.dispose())}function f(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:f}}function WS(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r=n.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&lo("WebGLRenderer: "+i+" extension not supported."),r}}}function XS(n,e,t,i){let r={},a=new WeakMap;function s(f){let h=f.target;h.index!==null&&e.remove(h.index);for(let y in h.attributes)e.remove(h.attributes[y]);h.removeEventListener("dispose",s),delete r[h.id];let m=a.get(h);m&&(e.remove(m),a.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(f,h){return r[h.id]===!0||(h.addEventListener("dispose",s),r[h.id]=!0,t.memory.geometries++),h}function u(f){let h=f.attributes;for(let m in h)e.update(h[m],n.ARRAY_BUFFER)}function l(f){let h=[],m=f.index,y=f.attributes.position,M=0;if(y===void 0)return;if(m!==null){let L=m.array;M=m.version;for(let p=0,_=L.length;p<_;p+=3){let N=L[p+0],D=L[p+1],V=L[p+2];h.push(N,D,D,V,V,N)}}else{let L=y.array;M=y.version;for(let p=0,_=L.length/3-1;p<_;p+=3){let N=p+0,D=p+1,V=p+2;h.push(N,D,D,V,V,N)}}let g=new(y.count>=65535?sc:ac)(h,1);g.version=M;let v=a.get(f);v&&e.remove(v),a.set(f,g)}function d(f){let h=a.get(f);if(h){let m=f.index;m!==null&&h.version<m.version&&l(f)}else l(f);return a.get(f)}return{get:o,update:u,getWireframeAttribute:d}}function YS(n,e,t){let i;function r(f){i=f}let a,s;function o(f){a=f.type,s=f.bytesPerElement}function u(f,h){n.drawElements(i,h,a,f*s),t.update(h,i,1)}function l(f,h,m){m!==0&&(n.drawElementsInstanced(i,h,a,f*s,m),t.update(h,i,m))}function d(f,h,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,a,f,0,m);let M=0;for(let g=0;g<m;g++)M+=h[g];t.update(M,i,1)}this.setMode=r,this.setIndex=o,this.render=u,this.renderInstances=l,this.renderMultiDraw=d}function qS(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(a,s,o){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=o*(a/3);break;case n.LINES:t.lines+=o*(a/2);break;case n.LINE_STRIP:t.lines+=o*(a-1);break;case n.LINE_LOOP:t.lines+=o*a;break;case n.POINTS:t.points+=o*a;break;default:Un("WebGLInfo: Unknown draw mode:",s);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function ZS(n,e,t){let i=new WeakMap,r=new Ni;function a(s,o,u){let l=s.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0,h=i.get(o);if(h===void 0||h.count!==f){let I=function(){V.dispose(),i.delete(o),o.removeEventListener("dispose",I)};h!==void 0&&h.texture.dispose();let m=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,M=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],v=o.morphAttributes.normal||[],L=o.morphAttributes.color||[],p=0;m===!0&&(p=1),y===!0&&(p=2),M===!0&&(p=3);let _=o.attributes.position.count*p,N=1;_>e.maxTextureSize&&(N=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);let D=new Float32Array(_*N*4*f),V=new ic(D,_,N,f);V.type=va,V.needsUpdate=!0;let w=p*4;for(let G=0;G<f;G++){let H=g[G],Q=v[G],T=L[G],S=_*N*4*G;for(let Z=0;Z<H.count;Z++){let q=Z*w;m===!0&&(r.fromBufferAttribute(H,Z),D[S+q+0]=r.x,D[S+q+1]=r.y,D[S+q+2]=r.z,D[S+q+3]=0),y===!0&&(r.fromBufferAttribute(Q,Z),D[S+q+4]=r.x,D[S+q+5]=r.y,D[S+q+6]=r.z,D[S+q+7]=0),M===!0&&(r.fromBufferAttribute(T,Z),D[S+q+8]=r.x,D[S+q+9]=r.y,D[S+q+10]=r.z,D[S+q+11]=T.itemSize===4?r.w:1)}}h={count:f,texture:V,size:new tn(_,N)},i.set(o,h),o.addEventListener("dispose",I)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)u.getUniforms().setValue(n,"morphTexture",s.morphTexture,t);else{let m=0;for(let M=0;M<l.length;M++)m+=l[M];let y=o.morphTargetsRelative?1:1-m;u.getUniforms().setValue(n,"morphTargetBaseInfluence",y),u.getUniforms().setValue(n,"morphTargetInfluences",l)}u.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),u.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:a}}function JS(n,e,t,i,r){let a=new WeakMap;function s(l){let d=r.render.frame,f=l.geometry,h=e.get(l,f);if(a.get(h)!==d&&(e.update(h),a.set(h,d)),l.isInstancedMesh&&(l.hasEventListener("dispose",u)===!1&&l.addEventListener("dispose",u),a.get(l)!==d&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),a.set(l,d))),l.isSkinnedMesh){let m=l.skeleton;a.get(m)!==d&&(m.update(),a.set(m,d))}return h}function o(){a=new WeakMap}function u(l){let d=l.target;d.removeEventListener("dispose",u),i.releaseStatesOfObject(d),t.remove(d.instanceMatrix),d.instanceColor!==null&&t.remove(d.instanceColor)}return{update:s,dispose:o}}var $S={[sp]:"LINEAR_TONE_MAPPING",[op]:"REINHARD_TONE_MAPPING",[lp]:"CINEON_TONE_MAPPING",[Ec]:"ACES_FILMIC_TONE_MAPPING",[up]:"AGX_TONE_MAPPING",[Ic]:"NEUTRAL_TONE_MAPPING",[cp]:"CUSTOM_TONE_MAPPING"};function KS(n,e,t,i,r,a){let s=new aa(e,t,{type:n,depthBuffer:r,stencilBuffer:a,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,u=null,l=new ur;l.setAttribute("position",new Ci([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Ci([0,2,0,0,2,0],2));let d=new cd({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4073
4073
|
precision highp float;
|
|
4074
4074
|
|
|
4075
4075
|
uniform mat4 modelViewMatrix;
|
|
@@ -4115,17 +4115,17 @@ void main() {
|
|
|
4115
4115
|
#ifdef SRGB_TRANSFER
|
|
4116
4116
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4117
4117
|
#endif
|
|
4118
|
-
}`,depthTest:!1,depthWrite:!1}),f=new
|
|
4118
|
+
}`,depthTest:!1,depthWrite:!1}),f=new _i(l,d),h=new cl(-1,1,1,-1,0,1),m=null,y=null,M=!1,g,v=null,L=[],p=!1;this.setSize=function(_,N){s.setSize(_,N),o!==null&&o.setSize(_,N),u!==null&&u.setSize(_,N);for(let D=0;D<L.length;D++){let V=L[D];V.setSize&&V.setSize(_,N)}},this.setEffects=function(_){L=_,p=L.length>0&&L[0].isRenderPass===!0;let N=s.width,D=s.height;L.length>0&&o===null&&(o=new aa(N,D,{type:Fa,depthBuffer:!1,stencilBuffer:!1}),u=new aa(N,D,{type:Fa,depthBuffer:!1,stencilBuffer:!1}));for(let V=0;V<L.length;V++){let w=L[V];w.setSize&&w.setSize(N,D)}},this.begin=function(_,N){if(M||_.toneMapping===oa&&L.length===0)return!1;if(v=N,N!==null){let D=N.width,V=N.height;(s.width!==D||s.height!==V)&&this.setSize(D,V)}return p===!1&&_.setRenderTarget(s),g=_.toneMapping,_.toneMapping=oa,!0},this.hasRenderPass=function(){return p},this.end=function(_,N){_.toneMapping=g,M=!0;let D=s,V=o;for(let w=0;w<L.length;w++){let I=L[w];I.enabled!==!1&&(I.render(_,V,D,N),I.needsSwap!==!1&&(D=V,V=V===o?u:o))}if(m!==_.outputColorSpace||y!==_.toneMapping){m=_.outputColorSpace,y=_.toneMapping,d.defines={},mi.getTransfer(m)===Li&&(d.defines.SRGB_TRANSFER="");let w=$S[y];w&&(d.defines[w]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=D.texture,_.setRenderTarget(v),_.render(f,h),v=null,M=!1},this.isCompositing=function(){return M},this.dispose=function(){s.dispose(),o!==null&&o.dispose(),u!==null&&u.dispose(),l.dispose(),d.dispose()}}var ng=new Tr,Fp=new Bs(1,1),ig=new ic,rg=new td,ag=new cc,O0=[],B0=[],k0=new Float32Array(16),z0=new Float32Array(9),V0=new Float32Array(4);function _l(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,a=O0[r];if(a===void 0&&(a=new Float32Array(r),O0[r]=a),e!==0){i.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=t,n[s].toArray(a,o)}return a}function fr(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function hr(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Mf(n,e){let t=B0[e];t===void 0&&(t=new Int32Array(e),B0[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function QS(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function jS(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(fr(t,e))return;n.uniform2fv(this.addr,e),hr(t,e)}}function eb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(fr(t,e))return;n.uniform3fv(this.addr,e),hr(t,e)}}function tb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(fr(t,e))return;n.uniform4fv(this.addr,e),hr(t,e)}}function nb(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(fr(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),hr(t,e)}else{if(fr(t,i))return;V0.set(i),n.uniformMatrix2fv(this.addr,!1,V0),hr(t,i)}}function ib(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(fr(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),hr(t,e)}else{if(fr(t,i))return;z0.set(i),n.uniformMatrix3fv(this.addr,!1,z0),hr(t,i)}}function rb(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(fr(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),hr(t,e)}else{if(fr(t,i))return;k0.set(i),n.uniformMatrix4fv(this.addr,!1,k0),hr(t,i)}}function ab(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function sb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(fr(t,e))return;n.uniform2iv(this.addr,e),hr(t,e)}}function ob(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(fr(t,e))return;n.uniform3iv(this.addr,e),hr(t,e)}}function lb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(fr(t,e))return;n.uniform4iv(this.addr,e),hr(t,e)}}function cb(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function ub(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(fr(t,e))return;n.uniform2uiv(this.addr,e),hr(t,e)}}function db(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(fr(t,e))return;n.uniform3uiv(this.addr,e),hr(t,e)}}function fb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(fr(t,e))return;n.uniform4uiv(this.addr,e),hr(t,e)}}function hb(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let a;this.type===n.SAMPLER_2D_SHADOW?(Fp.compareFunction=t.isReversedDepthBuffer()?mf:pf,a=Fp):a=ng,t.setTexture2D(e||a,r)}function pb(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||rg,r)}function mb(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||ag,r)}function vb(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||ig,r)}function gb(n){switch(n){case 5126:return QS;case 35664:return jS;case 35665:return eb;case 35666:return tb;case 35674:return nb;case 35675:return ib;case 35676:return rb;case 5124:case 35670:return ab;case 35667:case 35671:return sb;case 35668:case 35672:return ob;case 35669:case 35673:return lb;case 5125:return cb;case 36294:return ub;case 36295:return db;case 36296:return fb;case 35678:case 36198:case 36298:case 36306:case 35682:return hb;case 35679:case 36299:case 36307:return pb;case 35680:case 36300:case 36308:case 36293:return mb;case 36289:case 36303:case 36311:case 36292:return vb}}function yb(n,e){n.uniform1fv(this.addr,e)}function xb(n,e){let t=_l(e,this.size,2);n.uniform2fv(this.addr,t)}function _b(n,e){let t=_l(e,this.size,3);n.uniform3fv(this.addr,t)}function Mb(n,e){let t=_l(e,this.size,4);n.uniform4fv(this.addr,t)}function Sb(n,e){let t=_l(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function bb(n,e){let t=_l(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function wb(n,e){let t=_l(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function Tb(n,e){n.uniform1iv(this.addr,e)}function Ab(n,e){n.uniform2iv(this.addr,e)}function Eb(n,e){n.uniform3iv(this.addr,e)}function Ib(n,e){n.uniform4iv(this.addr,e)}function Cb(n,e){n.uniform1uiv(this.addr,e)}function Rb(n,e){n.uniform2uiv(this.addr,e)}function Pb(n,e){n.uniform3uiv(this.addr,e)}function Lb(n,e){n.uniform4uiv(this.addr,e)}function Db(n,e,t){let i=this.cache,r=e.length,a=Mf(t,r);fr(i,a)||(n.uniform1iv(this.addr,a),hr(i,a));let s;this.type===n.SAMPLER_2D_SHADOW?s=Fp:s=ng;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||s,a[o])}function Nb(n,e,t){let i=this.cache,r=e.length,a=Mf(t,r);fr(i,a)||(n.uniform1iv(this.addr,a),hr(i,a));for(let s=0;s!==r;++s)t.setTexture3D(e[s]||rg,a[s])}function Ub(n,e,t){let i=this.cache,r=e.length,a=Mf(t,r);fr(i,a)||(n.uniform1iv(this.addr,a),hr(i,a));for(let s=0;s!==r;++s)t.setTextureCube(e[s]||ag,a[s])}function Fb(n,e,t){let i=this.cache,r=e.length,a=Mf(t,r);fr(i,a)||(n.uniform1iv(this.addr,a),hr(i,a));for(let s=0;s!==r;++s)t.setTexture2DArray(e[s]||ig,a[s])}function Ob(n){switch(n){case 5126:return yb;case 35664:return xb;case 35665:return _b;case 35666:return Mb;case 35674:return Sb;case 35675:return bb;case 35676:return wb;case 5124:case 35670:return Tb;case 35667:case 35671:return Ab;case 35668:case 35672:return Eb;case 35669:case 35673:return Ib;case 5125:return Cb;case 36294:return Rb;case 36295:return Pb;case 36296:return Lb;case 35678:case 36198:case 36298:case 36306:case 35682:return Db;case 35679:case 36299:case 36307:return Nb;case 35680:case 36300:case 36308:case 36293:return Ub;case 36289:case 36303:case 36311:case 36292:return Fb}}var Op=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=gb(t.type)}},Bp=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Ob(t.type)}},kp=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let a=0,s=r.length;a!==s;++a){let o=r[a];o.setValue(e,t[o.id],i)}}},Np=/(\w+)(\])?(\[|\.)?/g;function G0(n,e){n.seq.push(e),n.map[e.id]=e}function Bb(n,e,t){let i=n.name,r=i.length;for(Np.lastIndex=0;;){let a=Np.exec(i),s=Np.lastIndex,o=a[1],u=a[2]==="]",l=a[3];if(u&&(o=o|0),l===void 0||l==="["&&s+2===r){G0(t,l===void 0?new Op(o,n,e):new Bp(o,n,e));break}else{let f=t.map[o];f===void 0&&(f=new kp(o),G0(t,f)),t=f}}}var yl=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<i;++s){let o=e.getActiveUniform(t,s),u=e.getUniformLocation(t,o.name);Bb(o,u,this)}let r=[],a=[];for(let s of this.seq)s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(s):a.push(s);r.length>0&&(this.seq=r.concat(a))}setValue(e,t,i,r){let a=this.map[t];a!==void 0&&a.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let a=0,s=t.length;a!==s;++a){let o=t[a],u=i[o.id];u.needsUpdate!==!1&&o.setValue(e,u.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,a=e.length;r!==a;++r){let s=e[r];s.id in t&&i.push(s)}return i}};function H0(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}var kb=37297,zb=0;function Vb(n,e){let t=n.split(`
|
|
4119
4119
|
`),i=[],r=Math.max(e-6,0),a=Math.min(e+6,t.length);for(let s=r;s<a;s++){let o=s+1;i.push(`${o===e?">":" "} ${o}: ${t[s]}`)}return i.join(`
|
|
4120
|
-
`)}var
|
|
4120
|
+
`)}var W0=new qn;function Gb(n){mi._getMatrix(W0,mi.workingColorSpace,n);let e=`mat3( ${W0.elements.map(t=>t.toFixed(4))} )`;switch(mi.getTransfer(n)){case tc:return[e,"LinearTransferOETF"];case Li:return[e,"sRGBTransferOETF"];default:return En("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function X0(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),a=(n.getShaderInfoLog(e)||"").trim();if(i&&a==="")return"";let s=/ERROR: 0:(\d+)/.exec(a);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
|
|
4121
4121
|
|
|
4122
4122
|
`+a+`
|
|
4123
4123
|
|
|
4124
|
-
`+
|
|
4125
|
-
`)}var
|
|
4126
|
-
`)}function
|
|
4127
|
-
`)}function
|
|
4128
|
-
`)}function
|
|
4124
|
+
`+Vb(n.getShaderSource(e),o)}else return a}function Hb(n,e){let t=Gb(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
4125
|
+
`)}var Wb={[sp]:"Linear",[op]:"Reinhard",[lp]:"Cineon",[Ec]:"ACESFilmic",[up]:"AgX",[Ic]:"Neutral",[cp]:"Custom"};function Xb(n,e){let t=Wb[e];return t===void 0?(En("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var gf=new xe;function Yb(){mi.getLuminanceCoefficients(gf);let n=gf.x.toFixed(4),e=gf.y.toFixed(4),t=gf.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4126
|
+
`)}function qb(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(kc).join(`
|
|
4127
|
+
`)}function Zb(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
4128
|
+
`)}function Jb(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let a=n.getActiveAttrib(e,r),s=a.name,o=1;a.type===n.FLOAT_MAT2&&(o=2),a.type===n.FLOAT_MAT3&&(o=3),a.type===n.FLOAT_MAT4&&(o=4),t[s]={type:a.type,location:n.getAttribLocation(e,s),locationSize:o}}return t}function kc(n){return n!==""}function Y0(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function q0(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var $b=/^[ \t]*#include +<([\w\d./]+)>/gm;function zp(n){return n.replace($b,Qb)}var Kb=new Map;function Qb(n,e){let t=ai[e];if(t===void 0){let i=Kb.get(e);if(i!==void 0)t=ai[i],En('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return zp(t)}var jb=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Z0(n){return n.replace(jb,ew)}function ew(n,e,t,i){let r="";for(let a=parseInt(e);a<parseInt(t);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function J0(n){let e=`precision ${n.precision} float;
|
|
4129
4129
|
precision ${n.precision} int;
|
|
4130
4130
|
precision ${n.precision} sampler2D;
|
|
4131
4131
|
precision ${n.precision} samplerCube;
|
|
@@ -4145,30 +4145,30 @@ void main() {
|
|
|
4145
4145
|
`;return n.precision==="highp"?e+=`
|
|
4146
4146
|
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
|
|
4147
4147
|
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
|
|
4148
|
-
#define LOW_PRECISION`),e}var
|
|
4149
|
-
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(
|
|
4148
|
+
#define LOW_PRECISION`),e}var tw={[Ac]:"SHADOWMAP_TYPE_PCF",[ul]:"SHADOWMAP_TYPE_VSM"};function nw(n){return tw[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var iw={[Gs]:"ENVMAP_TYPE_CUBE",[po]:"ENVMAP_TYPE_CUBE",[Cc]:"ENVMAP_TYPE_CUBE_UV"};function rw(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":iw[n.envMapMode]||"ENVMAP_TYPE_CUBE"}var aw={[po]:"ENVMAP_MODE_REFRACTION"};function sw(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":aw[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}var ow={[Ed]:"ENVMAP_BLENDING_MULTIPLY",[l0]:"ENVMAP_BLENDING_MIX",[c0]:"ENVMAP_BLENDING_ADD"};function lw(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":ow[n.combine]||"ENVMAP_BLENDING_NONE"}function cw(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function uw(n,e,t,i){let r=n.getContext(),a=t.defines,s=t.vertexShader,o=t.fragmentShader,u=nw(t),l=rw(t),d=sw(t),f=lw(t),h=cw(t),m=qb(t),y=Zb(a),M=r.createProgram(),g,v,L=t.glslVersion?"#version "+t.glslVersion+`
|
|
4149
|
+
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(kc).join(`
|
|
4150
4150
|
`),g.length>0&&(g+=`
|
|
4151
|
-
`),v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(
|
|
4151
|
+
`),v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(kc).join(`
|
|
4152
4152
|
`),v.length>0&&(v+=`
|
|
4153
|
-
`)):(g=[
|
|
4154
|
-
`].filter(
|
|
4155
|
-
`),v=[
|
|
4156
|
-
`].filter(
|
|
4157
|
-
`)),s=
|
|
4153
|
+
`)):(g=[J0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
4154
|
+
`].filter(kc).join(`
|
|
4155
|
+
`),v=[J0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+d:"",t.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==oa?"#define TONE_MAPPING":"",t.toneMapping!==oa?ai.tonemapping_pars_fragment:"",t.toneMapping!==oa?Xb("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ai.colorspace_pars_fragment,Hb("linearToOutputTexel",t.outputColorSpace),Yb(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4156
|
+
`].filter(kc).join(`
|
|
4157
|
+
`)),s=zp(s),s=Y0(s,t),s=q0(s,t),o=zp(o),o=Y0(o,t),o=q0(o,t),s=Z0(s),o=Z0(o),t.isRawShaderMaterial!==!0&&(L=`#version 300 es
|
|
4158
4158
|
`,g=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4159
4159
|
`)+`
|
|
4160
|
-
`+g,v=["#define varying in",t.glslVersion===
|
|
4160
|
+
`+g,v=["#define varying in",t.glslVersion===yp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===yp?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
4161
4161
|
`)+`
|
|
4162
|
-
`+v);let p=
|
|
4162
|
+
`+v);let p=L+g+s,_=L+v+o,N=H0(r,r.VERTEX_SHADER,p),D=H0(r,r.FRAGMENT_SHADER,_);r.attachShader(M,N),r.attachShader(M,D),t.index0AttributeName!==void 0?r.bindAttribLocation(M,0,t.index0AttributeName):t.hasPositionAttribute===!0&&r.bindAttribLocation(M,0,"position"),r.linkProgram(M);function V(H){if(n.debug.checkShaderErrors){let Q=r.getProgramInfoLog(M)||"",T=r.getShaderInfoLog(N)||"",S=r.getShaderInfoLog(D)||"",Z=Q.trim(),q=T.trim(),se=S.trim(),F=!0,z=!0;if(r.getProgramParameter(M,r.LINK_STATUS)===!1)if(F=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,M,N,D);else{let Y=X0(r,N,"vertex"),$=X0(r,D,"fragment");Un("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(M,r.VALIDATE_STATUS)+`
|
|
4163
4163
|
|
|
4164
|
-
Material Name: `+
|
|
4165
|
-
Material Type: `+
|
|
4164
|
+
Material Name: `+H.name+`
|
|
4165
|
+
Material Type: `+H.type+`
|
|
4166
4166
|
|
|
4167
|
-
Program Info Log: `+
|
|
4168
|
-
`+
|
|
4169
|
-
`+ne)}else Y!==""?mn("WebGLProgram: Program Info Log:",Y):(W===""||se==="")&&(U=!1);U&&(V.diagnostics={runnable:O,programLog:Y,vertexShader:{log:W,prefix:g},fragmentShader:{log:se,prefix:v}})}r.deleteShader(N),r.deleteShader(D),w=new yl(r,M),A=Eb(r,M)}let w;this.getUniforms=function(){return w===void 0&&B(this),w};let A;this.getAttributes=function(){return A===void 0&&B(this),A};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=r.getProgramParameter(M,vb)),z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(M),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=gb++,this.cacheKey=e,this.usedTimes=1,this.program=M,this.vertexShader=N,this.fragmentShader=D,this}var Gb=0,Ip=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(i)===!1&&(r.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new Cp(e),t.set(e,i)),i}},Cp=class{constructor(e){this.id=Gb++,this.code=e,this.usedTimes=0}};function Hb(n){return n===Ls||n===Pc||n===Lc}function Wb(n,e,t,i,r,a){let s=new Ko,o=new Ip,u=new Set,l=[],d=new Map,f=i.logarithmicDepthBuffer,h=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(w){return u.add(w),w===0?"uv":`uv${w}`}function M(w,A,z,V,$,T){let S=V.fog,Y=$.geometry,W=w.isMeshStandardMaterial||w.isMeshLambertMaterial||w.isMeshPhongMaterial?V.environment:null,se=w.isMeshStandardMaterial||w.isMeshLambertMaterial&&!w.envMap||w.isMeshPhongMaterial&&!w.envMap,O=e.get(w.envMap||W,se),U=O&&O.mapping===Ec?O.image.height:null,H=m[w.type];w.precision!==null&&(h=i.getMaxPrecision(w.precision),h!==w.precision&&mn("WebGLProgram.getParameters:",w.precision,"not supported, using",h,"instead."));let ne=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,ce=ne!==void 0?ne.length:0,pe=0;Y.morphAttributes.position!==void 0&&(pe=1),Y.morphAttributes.normal!==void 0&&(pe=2),Y.morphAttributes.color!==void 0&&(pe=3);let le,be,Pe,Q;if(H){let _t=Xa[H];le=_t.vertexShader,be=_t.fragmentShader}else{le=w.vertexShader,be=w.fragmentShader;let _t=o.getVertexShaderStage(w),Bt=o.getFragmentShaderStage(w);o.update(w,_t,Bt),Pe=_t.id,Q=Bt.id}let ie=n.getRenderTarget(),Me=n.state.buffers.depth.getReversed(),Le=$.isInstancedMesh===!0,Ee=$.isBatchedMesh===!0,Xe=!!w.map,tt=!!w.matcap,Ge=!!O,Ye=!!w.aoMap,dt=!!w.lightMap,ke=!!w.bumpMap&&w.wireframe===!1,at=!!w.normalMap,Ke=!!w.displacementMap,jt=!!w.emissiveMap,Pt=!!w.metalnessMap,tn=!!w.roughnessMap,ue=w.anisotropy>0,ln=w.clearcoat>0,on=w.dispersion>0,Z=w.retroreflectivity>0,b=w.iridescence>0,ee=w.sheen>0,ve=w.transmission>0,Te=ue&&!!w.anisotropyMap,Ve=ln&&!!w.clearcoatMap,$e=ln&&!!w.clearcoatNormalMap,Ce=ln&&!!w.clearcoatRoughnessMap,Ae=b&&!!w.iridescenceMap,nt=b&&!!w.iridescenceThicknessMap,gt=ee&&!!w.sheenColorMap,ct=ee&&!!w.sheenRoughnessMap,je=!!w.specularMap,Dt=!!w.specularColorMap,qe=!!w.specularIntensityMap,Gt=ve&&!!w.transmissionMap,oe=ve&&!!w.thicknessMap,st=!!w.gradientMap,Ne=!!w.alphaMap,ft=w.alphaTest>0,ht=!!w.alphaHash,ze=!!w.extensions,Ot=Gr;w.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(Ot=n.toneMapping);let Tt={shaderID:H,shaderType:w.type,shaderName:w.name,vertexShader:le,fragmentShader:be,defines:w.defines,customVertexShaderID:Pe,customFragmentShaderID:Q,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:h,batching:Ee,batchingColor:Ee&&$._colorsTexture!==null,instancing:Le,instancingColor:Le&&$.instanceColor!==null,instancingMorph:Le&&$.morphTexture!==null,outputColorSpace:ie===null?n.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:jn.workingColorSpace,alphaToCoverage:!!w.alphaToCoverage,map:Xe,matcap:tt,envMap:Ge,envMapMode:Ge&&O.mapping,envMapCubeUVHeight:U,aoMap:Ye,lightMap:dt,bumpMap:ke,normalMap:at,displacementMap:Ke,emissiveMap:jt,normalMapObjectSpace:at&&w.normalMapType===qv,normalMapTangentSpace:at&&w.normalMapType===Dc,packedNormalMap:at&&w.normalMapType===Dc&&Hb(w.normalMap.format),metalnessMap:Pt,roughnessMap:tn,anisotropy:ue,anisotropyMap:Te,clearcoat:ln,clearcoatMap:Ve,clearcoatNormalMap:$e,clearcoatRoughnessMap:Ce,dispersion:on,retroreflection:Z,iridescence:b,iridescenceMap:Ae,iridescenceThicknessMap:nt,sheen:ee,sheenColorMap:gt,sheenRoughnessMap:ct,specularMap:je,specularColorMap:Dt,specularIntensityMap:qe,transmission:ve,transmissionMap:Gt,thicknessMap:oe,gradientMap:st,opaque:w.transparent===!1&&w.blending===dl&&w.alphaToCoverage===!1,alphaMap:Ne,alphaTest:ft,alphaHash:ht,combine:w.combine,mapUv:Xe&&y(w.map.channel),aoMapUv:Ye&&y(w.aoMap.channel),lightMapUv:dt&&y(w.lightMap.channel),bumpMapUv:ke&&y(w.bumpMap.channel),normalMapUv:at&&y(w.normalMap.channel),displacementMapUv:Ke&&y(w.displacementMap.channel),emissiveMapUv:jt&&y(w.emissiveMap.channel),metalnessMapUv:Pt&&y(w.metalnessMap.channel),roughnessMapUv:tn&&y(w.roughnessMap.channel),anisotropyMapUv:Te&&y(w.anisotropyMap.channel),clearcoatMapUv:Ve&&y(w.clearcoatMap.channel),clearcoatNormalMapUv:$e&&y(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ce&&y(w.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&y(w.iridescenceMap.channel),iridescenceThicknessMapUv:nt&&y(w.iridescenceThicknessMap.channel),sheenColorMapUv:gt&&y(w.sheenColorMap.channel),sheenRoughnessMapUv:ct&&y(w.sheenRoughnessMap.channel),specularMapUv:je&&y(w.specularMap.channel),specularColorMapUv:Dt&&y(w.specularColorMap.channel),specularIntensityMapUv:qe&&y(w.specularIntensityMap.channel),transmissionMapUv:Gt&&y(w.transmissionMap.channel),thicknessMapUv:oe&&y(w.thicknessMap.channel),alphaMapUv:Ne&&y(w.alphaMap.channel),vertexTangents:!!Y.attributes.tangent&&(at||ue),vertexNormals:!!Y.attributes.normal,vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!Y.attributes.uv&&(Xe||Ne),fog:!!S,useFog:w.fog===!0,fogExp2:!!S&&S.isFogExp2,flatShading:w.wireframe===!1&&(w.flatShading===!0||Y.attributes.normal===void 0&&at===!1&&(w.isMeshLambertMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isMeshPhysicalMaterial)),sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Me,skinning:$.isSkinnedMesh===!0,hasPositionAttribute:Y.attributes.position!==void 0,morphTargets:Y.morphAttributes.position!==void 0,morphNormals:Y.morphAttributes.normal!==void 0,morphColors:Y.morphAttributes.color!==void 0,morphTargetsCount:ce,morphTextureStride:pe,numSunLights:A.sun.length,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numSunLightShadows:A.sunShadowMap.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:T.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:w.dithering,shadowMapEnabled:n.shadowMap.enabled&&z.length>0,shadowMapType:n.shadowMap.type,toneMapping:Ot,decodeVideoTexture:Xe&&w.map.isVideoTexture===!0&&jn.getTransfer(w.map.colorSpace)===gi,decodeVideoTextureEmissive:jt&&w.emissiveMap.isVideoTexture===!0&&jn.getTransfer(w.emissiveMap.colorSpace)===gi,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===Er,flipSided:w.side===Dr,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:ze&&w.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ze&&w.extensions.multiDraw===!0||Ee)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return Tt.vertexUv1s=u.has(1),Tt.vertexUv2s=u.has(2),Tt.vertexUv3s=u.has(3),u.clear(),Tt}function g(w){let A=[];if(w.shaderID?A.push(w.shaderID):(A.push(w.customVertexShaderID),A.push(w.customFragmentShaderID)),w.defines!==void 0)for(let z in w.defines)A.push(z),A.push(w.defines[z]);return w.isRawShaderMaterial===!1&&(v(A,w),P(A,w),A.push(n.outputColorSpace)),A.push(w.customProgramCacheKey),A.join()}function v(w,A){w.push(A.precision),w.push(A.outputColorSpace),w.push(A.envMapMode),w.push(A.envMapCubeUVHeight),w.push(A.mapUv),w.push(A.alphaMapUv),w.push(A.lightMapUv),w.push(A.aoMapUv),w.push(A.bumpMapUv),w.push(A.normalMapUv),w.push(A.displacementMapUv),w.push(A.emissiveMapUv),w.push(A.metalnessMapUv),w.push(A.roughnessMapUv),w.push(A.anisotropyMapUv),w.push(A.clearcoatMapUv),w.push(A.clearcoatNormalMapUv),w.push(A.clearcoatRoughnessMapUv),w.push(A.iridescenceMapUv),w.push(A.iridescenceThicknessMapUv),w.push(A.sheenColorMapUv),w.push(A.sheenRoughnessMapUv),w.push(A.specularMapUv),w.push(A.specularColorMapUv),w.push(A.specularIntensityMapUv),w.push(A.transmissionMapUv),w.push(A.thicknessMapUv),w.push(A.combine),w.push(A.fogExp2),w.push(A.sizeAttenuation),w.push(A.morphTargetsCount),w.push(A.morphAttributeCount),w.push(A.numSunLights),w.push(A.numDirLights),w.push(A.numPointLights),w.push(A.numSpotLights),w.push(A.numSpotLightMaps),w.push(A.numHemiLights),w.push(A.numRectAreaLights),w.push(A.numSunLightShadows),w.push(A.numDirLightShadows),w.push(A.numPointLightShadows),w.push(A.numSpotLightShadows),w.push(A.numSpotLightShadowsWithMaps),w.push(A.numLightProbes),w.push(A.shadowMapType),w.push(A.toneMapping),w.push(A.numClippingPlanes),w.push(A.numClipIntersection),w.push(A.depthPacking)}function P(w,A){s.disableAll(),A.instancing&&s.enable(0),A.instancingColor&&s.enable(1),A.instancingMorph&&s.enable(2),A.matcap&&s.enable(3),A.envMap&&s.enable(4),A.normalMapObjectSpace&&s.enable(5),A.normalMapTangentSpace&&s.enable(6),A.clearcoat&&s.enable(7),A.iridescence&&s.enable(8),A.alphaTest&&s.enable(9),A.vertexColors&&s.enable(10),A.vertexAlphas&&s.enable(11),A.vertexUv1s&&s.enable(12),A.vertexUv2s&&s.enable(13),A.vertexUv3s&&s.enable(14),A.vertexTangents&&s.enable(15),A.anisotropy&&s.enable(16),A.alphaHash&&s.enable(17),A.batching&&s.enable(18),A.dispersion&&s.enable(19),A.retroreflection&&s.enable(24),A.batchingColor&&s.enable(20),A.gradientMap&&s.enable(21),A.packedNormalMap&&s.enable(22),A.vertexNormals&&s.enable(23),w.push(s.mask),s.disableAll(),A.fog&&s.enable(0),A.useFog&&s.enable(1),A.flatShading&&s.enable(2),A.logarithmicDepthBuffer&&s.enable(3),A.reversedDepthBuffer&&s.enable(4),A.skinning&&s.enable(5),A.morphTargets&&s.enable(6),A.morphNormals&&s.enable(7),A.morphColors&&s.enable(8),A.premultipliedAlpha&&s.enable(9),A.shadowMapEnabled&&s.enable(10),A.doubleSided&&s.enable(11),A.flipSided&&s.enable(12),A.useDepthPacking&&s.enable(13),A.dithering&&s.enable(14),A.transmission&&s.enable(15),A.sheen&&s.enable(16),A.opaque&&s.enable(17),A.pointsUvs&&s.enable(18),A.decodeVideoTexture&&s.enable(19),A.decodeVideoTextureEmissive&&s.enable(20),A.alphaToCoverage&&s.enable(21),A.numLightProbeGrids>0&&s.enable(22),A.hasPositionAttribute&&s.enable(23),w.push(s.mask)}function p(w){let A=m[w.type],z;if(A){let V=Xa[A];z=d0.clone(V.uniforms)}else z=w.uniforms;return z}function _(w,A){let z=d.get(A);return z!==void 0?++z.usedTimes:(z=new Vb(n,A,w,r),l.push(z),d.set(A,z)),z}function N(w){if(--w.usedTimes===0){let A=l.indexOf(w);l[A]=l[l.length-1],l.pop(),d.delete(w.cacheKey),w.destroy()}}function D(w){o.remove(w)}function B(){o.dispose()}return{getParameters:M,getProgramCacheKey:g,getUniforms:p,acquireProgram:_,releaseProgram:N,releaseShaderCache:D,programs:l,dispose:B}}function Xb(){let n=new WeakMap;function e(s){return n.has(s)}function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function i(s){n.delete(s)}function r(s,o,u){n.get(s)[o]=u}function a(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:a}}function Yb(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function P0(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function L0(){let n=[],e=0,t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(h){let m=0;return h.isInstancedMesh&&(m+=2),h.isSkinnedMesh&&(m+=1),m}function o(h,m,y,M,g,v){let P=n[e];return P===void 0?(P={id:h.id,object:h,geometry:m,material:y,materialVariant:s(h),groupOrder:M,renderOrder:h.renderOrder,z:g,group:v},n[e]=P):(P.id=h.id,P.object=h,P.geometry=m,P.material=y,P.materialVariant=s(h),P.groupOrder=M,P.renderOrder=h.renderOrder,P.z=g,P.group=v),e++,P}function u(h,m,y,M,g,v,P){P.reversedDepth===!0&&(g=-g);let p=o(h,m,y,M,g,v);y.transmission>0?i.push(p):y.transparent===!0?r.push(p):t.push(p)}function l(h,m,y,M,g,v){let P=o(h,m,y,M,g,v);y.transmission>0?i.unshift(P):y.transparent===!0?r.unshift(P):t.unshift(P)}function d(h,m){t.length>1&&t.sort(h||Yb),i.length>1&&i.sort(m||P0),r.length>1&&r.sort(m||P0)}function f(){for(let h=e,m=n.length;h<m;h++){let y=n[h];if(y.id===null)break;y.id=null,y.object=null,y.geometry=null,y.material=null,y.group=null}}return{opaque:t,transmissive:i,transparent:r,init:a,push:u,unshift:l,finish:f,sort:d}}function qb(){let n=new WeakMap;function e(i,r){let a=n.get(i),s;return a===void 0?(s=new L0,n.set(i,[s])):r>=a.length?(s=new L0,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function Zb(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new ge,color:new Rn};break;case"SpotLight":t={position:new ge,direction:new ge,color:new Rn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ge,color:new Rn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ge,skyColor:new Rn,groundColor:new Rn};break;case"RectAreaLight":t={color:new Rn,position:new ge,halfWidth:new ge,halfHeight:new ge};break}return n[e.id]=t,t}}}function Jb(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var $b=0;function Kb(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Qb(n){let e=new Zb,t=Jb(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new ge);let r=new ge,a=new Un,s=new Un;function o(l){let d=0,f=0,h=0;for(let $=0;$<9;$++)i.probe[$].set(0,0,0);let m=0,y=0,M=0,g=0,v=0,P=0,p=0,_=0,N=0,D=0,B=0,w=0,A=0,z=0;l.sort(Kb);for(let $=0,T=l.length;$<T;$++){let S=l[$],Y=S.color,W=S.intensity,se=S.distance,O=null;if(S.shadow&&S.shadow.map&&(S.shadow.map.texture.format===Ls?O=S.shadow.map.texture:O=S.shadow.map.depthTexture||S.shadow.map.texture),S.isAmbientLight)d+=Y.r*W,f+=Y.g*W,h+=Y.b*W;else if(S.isLightProbe){for(let U=0;U<9;U++)i.probe[U].addScaledVector(S.sh.coefficients[U],W);z++}else if(S.isSunLight){let U=e.get(S);if(U.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let H=S.shadow,ne=t.get(S);ne.shadowIntensity=H.intensity,ne.shadowBias=H.bias,ne.shadowNormalBias=H.normalBias,ne.shadowRadius=H.radius,ne.shadowMapSize.copy(H.mapSize).multiply(H.getFrameExtents()),i.sunShadow[y]=ne,i.sunShadowMap[y]=O;let ce=H.getViewportCount();for(let pe=0;pe<ce;pe++)i.sunShadowMatrix[M+pe]=H.getMatrix(pe),i.sunShadowCascade[M+pe]=H._cascadeData[pe];M+=ce,y++}i.sun[m]=U,m++}else if(S.isDirectionalLight){let U=e.get(S);if(U.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let H=S.shadow,ne=t.get(S);ne.shadowIntensity=H.intensity,ne.shadowBias=H.bias,ne.shadowNormalBias=H.normalBias,ne.shadowRadius=H.radius,ne.shadowMapSize=H.mapSize,i.directionalShadow[g]=ne,i.directionalShadowMap[g]=O,i.directionalShadowMatrix[g]=S.shadow.matrix,N++}i.directional[g]=U,g++}else if(S.isSpotLight){let U=e.get(S);U.position.setFromMatrixPosition(S.matrixWorld),U.color.copy(Y).multiplyScalar(W),U.distance=se,U.coneCos=Math.cos(S.angle),U.penumbraCos=Math.cos(S.angle*(1-S.penumbra)),U.decay=S.decay,i.spot[P]=U;let H=S.shadow;if(S.map&&(i.spotLightMap[w]=S.map,w++,H.updateMatrices(S),S.castShadow&&A++),i.spotLightMatrix[P]=H.matrix,S.castShadow){let ne=t.get(S);ne.shadowIntensity=H.intensity,ne.shadowBias=H.bias,ne.shadowNormalBias=H.normalBias,ne.shadowRadius=H.radius,ne.shadowMapSize=H.mapSize,i.spotShadow[P]=ne,i.spotShadowMap[P]=O,B++}P++}else if(S.isRectAreaLight){let U=e.get(S);U.color.copy(Y).multiplyScalar(W),U.halfWidth.set(S.width*.5,0,0),U.halfHeight.set(0,S.height*.5,0),i.rectArea[p]=U,p++}else if(S.isPointLight){let U=e.get(S);if(U.color.copy(S.color).multiplyScalar(S.intensity),U.distance=S.distance,U.decay=S.decay,S.castShadow){let H=S.shadow,ne=t.get(S);ne.shadowIntensity=H.intensity,ne.shadowBias=H.bias,ne.shadowNormalBias=H.normalBias,ne.shadowRadius=H.radius,ne.shadowMapSize=H.mapSize,ne.shadowCameraNear=H.camera.near,ne.shadowCameraFar=H.camera.far,i.pointShadow[v]=ne,i.pointShadowMap[v]=O,i.pointShadowMatrix[v]=S.shadow.matrix,D++}i.point[v]=U,v++}else if(S.isHemisphereLight){let U=e.get(S);U.skyColor.copy(S.color).multiplyScalar(W),U.groundColor.copy(S.groundColor).multiplyScalar(W),i.hemi[_]=U,_++}}p>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=zt.LTC_FLOAT_1,i.rectAreaLTC2=zt.LTC_FLOAT_2):(i.rectAreaLTC1=zt.LTC_HALF_1,i.rectAreaLTC2=zt.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=h;let V=i.hash;(V.sunLength!==m||V.directionalLength!==g||V.pointLength!==v||V.spotLength!==P||V.rectAreaLength!==p||V.hemiLength!==_||V.numSunShadows!==y||V.numDirectionalShadows!==N||V.numPointShadows!==D||V.numSpotShadows!==B||V.numSpotMaps!==w||V.numLightProbes!==z)&&(i.sun.length=m,i.directional.length=g,i.spot.length=P,i.rectArea.length=p,i.point.length=v,i.hemi.length=_,i.sunShadow.length=y,i.sunShadowMap.length=y,i.sunShadowMatrix.length=M,i.sunShadowCascade.length=M,i.directionalShadow.length=N,i.directionalShadowMap.length=N,i.directionalShadowMatrix.length=N,i.pointShadow.length=D,i.pointShadowMap.length=D,i.pointShadowMatrix.length=D,i.spotShadow.length=B,i.spotShadowMap.length=B,i.spotLightMatrix.length=B+w-A,i.spotLightMap.length=w,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=z,V.sunLength=m,V.directionalLength=g,V.pointLength=v,V.spotLength=P,V.rectAreaLength=p,V.hemiLength=_,V.numSunShadows=y,V.numDirectionalShadows=N,V.numPointShadows=D,V.numSpotShadows=B,V.numSpotMaps=w,V.numLightProbes=z,i.version=$b++)}function u(l,d){let f=0,h=0,m=0,y=0,M=0,g=0,v=d.matrixWorldInverse;for(let P=0,p=l.length;P<p;P++){let _=l[P];if(_.isSunLight){let N=i.sun[f];N.direction.setFromMatrixPosition(_.matrixWorld),N.direction.transformDirection(v),f++}else if(_.isDirectionalLight){let N=i.directional[h];N.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),N.direction.sub(r),N.direction.transformDirection(v),h++}else if(_.isSpotLight){let N=i.spot[y];N.position.setFromMatrixPosition(_.matrixWorld),N.position.applyMatrix4(v),N.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),N.direction.sub(r),N.direction.transformDirection(v),y++}else if(_.isRectAreaLight){let N=i.rectArea[M];N.position.setFromMatrixPosition(_.matrixWorld),N.position.applyMatrix4(v),s.identity(),a.copy(_.matrixWorld),a.premultiply(v),s.extractRotation(a),N.halfWidth.set(_.width*.5,0,0),N.halfHeight.set(0,_.height*.5,0),N.halfWidth.applyMatrix4(s),N.halfHeight.applyMatrix4(s),M++}else if(_.isPointLight){let N=i.point[m];N.position.setFromMatrixPosition(_.matrixWorld),N.position.applyMatrix4(v),m++}else if(_.isHemisphereLight){let N=i.hemi[g];N.direction.setFromMatrixPosition(_.matrixWorld),N.direction.transformDirection(v),g++}}}return{setup:o,setupView:u,state:i}}function D0(n){let e=new Qb(n),t=[],i=[],r=[];function a(h){f.camera=h,t.length=0,i.length=0,r.length=0}function s(h){t.push(h)}function o(h){i.push(h)}function u(h){r.push(h)}function l(){e.setup(t)}function d(h){e.setupView(t,h)}let f={lightsArray:t,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:f,setupLights:l,setupLightsView:d,pushLight:s,pushShadow:o,pushLightProbeGrid:u}}function jb(n){let e=new WeakMap;function t(r,a=0){let s=e.get(r),o;return s===void 0?(o=new D0(n),e.set(r,[o])):a>=s.length?(o=new D0(n),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:t,dispose:i}}var ew=`void main() {
|
|
4167
|
+
Program Info Log: `+Z+`
|
|
4168
|
+
`+Y+`
|
|
4169
|
+
`+$)}else Z!==""?En("WebGLProgram: Program Info Log:",Z):(q===""||se==="")&&(z=!1);z&&(H.diagnostics={runnable:F,programLog:Z,vertexShader:{log:q,prefix:g},fragmentShader:{log:se,prefix:v}})}r.deleteShader(N),r.deleteShader(D),w=new yl(r,M),I=Jb(r,M)}let w;this.getUniforms=function(){return w===void 0&&V(this),w};let I;this.getAttributes=function(){return I===void 0&&V(this),I};let G=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return G===!1&&(G=r.getProgramParameter(M,kb)),G},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(M),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=zb++,this.cacheKey=e,this.usedTimes=1,this.program=M,this.vertexShader=N,this.fragmentShader=D,this}var dw=0,Vp=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(i)===!1&&(r.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new Gp(e),t.set(e,i)),i}},Gp=class{constructor(e){this.id=dw++,this.code=e,this.usedTimes=0}};function fw(n){return n===Ws||n===Nc||n===Uc}function hw(n,e,t,i,r,a){let s=new Ko,o=new Vp,u=new Set,l=[],d=new Map,f=i.logarithmicDepthBuffer,h=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(w){return u.add(w),w===0?"uv":`uv${w}`}function M(w,I,G,H,Q,T){let S=H.fog,Z=Q.geometry,q=w.isMeshStandardMaterial||w.isMeshLambertMaterial||w.isMeshPhongMaterial?H.environment:null,se=w.isMeshStandardMaterial||w.isMeshLambertMaterial&&!w.envMap||w.isMeshPhongMaterial&&!w.envMap,F=e.get(w.envMap||q,se),z=F&&F.mapping===Cc?F.image.height:null,Y=m[w.type];w.precision!==null&&(h=i.getMaxPrecision(w.precision),h!==w.precision&&En("WebGLProgram.getParameters:",w.precision,"not supported, using",h,"instead."));let $=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,he=$!==void 0?$.length:0,pe=0;Z.morphAttributes.position!==void 0&&(pe=1),Z.morphAttributes.normal!==void 0&&(pe=2),Z.morphAttributes.color!==void 0&&(pe=3);let le,Te,De,oe;if(Y){let pt=es[Y];le=pt.vertexShader,Te=pt.fragmentShader}else{le=w.vertexShader,Te=w.fragmentShader;let pt=o.getVertexShaderStage(w),Lt=o.getFragmentShaderStage(w);o.update(w,pt,Lt),De=pt.id,oe=Lt.id}let ee=n.getRenderTarget(),be=n.state.buffers.depth.getReversed(),Be=Q.isInstancedMesh===!0,Re=Q.isBatchedMesh===!0,Ye=!!w.map,nt=!!w.matcap,Ge=!!F,$e=!!w.aoMap,mt=!!w.lightMap,at=!!w.bumpMap&&w.wireframe===!1,Ve=!!w.normalMap,Yt=!!w.displacementMap,st=!!w.emissiveMap,Dt=!!w.metalnessMap,on=!!w.roughnessMap,de=w.anisotropy>0,wn=w.clearcoat>0,Mn=w.dispersion>0,K=w.retroreflectivity>0,b=w.iridescence>0,ne=w.sheen>0,Se=w.transmission>0,Ie=de&&!!w.anisotropyMap,Xe=wn&&!!w.clearcoatMap,qe=wn&&!!w.clearcoatNormalMap,Le=wn&&!!w.clearcoatRoughnessMap,Pe=b&&!!w.iridescenceMap,lt=b&&!!w.iridescenceThicknessMap,Mt=ne&&!!w.sheenColorMap,yt=ne&&!!w.sheenRoughnessMap,it=!!w.specularMap,Gt=!!w.specularColorMap,Zt=!!w.specularIntensityMap,Ke=Se&&!!w.transmissionMap,fe=Se&&!!w.thicknessMap,We=!!w.gradientMap,ze=!!w.alphaMap,ht=w.alphaTest>0,St=!!w.alphaHash,He=!!w.extensions,qt=oa;w.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(qt=n.toneMapping);let Tt={shaderID:Y,shaderType:w.type,shaderName:w.name,vertexShader:le,fragmentShader:Te,defines:w.defines,customVertexShaderID:De,customFragmentShaderID:oe,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:h,batching:Re,batchingColor:Re&&Q._colorsTexture!==null,instancing:Be,instancingColor:Be&&Q.instanceColor!==null,instancingMorph:Be&&Q.morphTexture!==null,outputColorSpace:ee===null?n.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:mi.workingColorSpace,alphaToCoverage:!!w.alphaToCoverage,map:Ye,matcap:nt,envMap:Ge,envMapMode:Ge&&F.mapping,envMapCubeUVHeight:z,aoMap:$e,lightMap:mt,bumpMap:at,normalMap:Ve,displacementMap:Yt,emissiveMap:st,normalMapObjectSpace:Ve&&w.normalMapType===f0,normalMapTangentSpace:Ve&&w.normalMapType===Fc,packedNormalMap:Ve&&w.normalMapType===Fc&&fw(w.normalMap.format),metalnessMap:Dt,roughnessMap:on,anisotropy:de,anisotropyMap:Ie,clearcoat:wn,clearcoatMap:Xe,clearcoatNormalMap:qe,clearcoatRoughnessMap:Le,dispersion:Mn,retroreflection:K,iridescence:b,iridescenceMap:Pe,iridescenceThicknessMap:lt,sheen:ne,sheenColorMap:Mt,sheenRoughnessMap:yt,specularMap:it,specularColorMap:Gt,specularIntensityMap:Zt,transmission:Se,transmissionMap:Ke,thicknessMap:fe,gradientMap:We,opaque:w.transparent===!1&&w.blending===dl&&w.alphaToCoverage===!1,alphaMap:ze,alphaTest:ht,alphaHash:St,combine:w.combine,mapUv:Ye&&y(w.map.channel),aoMapUv:$e&&y(w.aoMap.channel),lightMapUv:mt&&y(w.lightMap.channel),bumpMapUv:at&&y(w.bumpMap.channel),normalMapUv:Ve&&y(w.normalMap.channel),displacementMapUv:Yt&&y(w.displacementMap.channel),emissiveMapUv:st&&y(w.emissiveMap.channel),metalnessMapUv:Dt&&y(w.metalnessMap.channel),roughnessMapUv:on&&y(w.roughnessMap.channel),anisotropyMapUv:Ie&&y(w.anisotropyMap.channel),clearcoatMapUv:Xe&&y(w.clearcoatMap.channel),clearcoatNormalMapUv:qe&&y(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Le&&y(w.clearcoatRoughnessMap.channel),iridescenceMapUv:Pe&&y(w.iridescenceMap.channel),iridescenceThicknessMapUv:lt&&y(w.iridescenceThicknessMap.channel),sheenColorMapUv:Mt&&y(w.sheenColorMap.channel),sheenRoughnessMapUv:yt&&y(w.sheenRoughnessMap.channel),specularMapUv:it&&y(w.specularMap.channel),specularColorMapUv:Gt&&y(w.specularColorMap.channel),specularIntensityMapUv:Zt&&y(w.specularIntensityMap.channel),transmissionMapUv:Ke&&y(w.transmissionMap.channel),thicknessMapUv:fe&&y(w.thicknessMap.channel),alphaMapUv:ze&&y(w.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(Ve||de),vertexNormals:!!Z.attributes.normal,vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:Q.isPoints===!0&&!!Z.attributes.uv&&(Ye||ze),fog:!!S,useFog:w.fog===!0,fogExp2:!!S&&S.isFogExp2,flatShading:w.wireframe===!1&&(w.flatShading===!0||Z.attributes.normal===void 0&&Ve===!1&&(w.isMeshLambertMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isMeshPhysicalMaterial)),sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:be,skinning:Q.isSkinnedMesh===!0,hasPositionAttribute:Z.attributes.position!==void 0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:he,morphTextureStride:pe,numSunLights:I.sun.length,numDirLights:I.directional.length,numPointLights:I.point.length,numSpotLights:I.spot.length,numSpotLightMaps:I.spotLightMap.length,numRectAreaLights:I.rectArea.length,numHemiLights:I.hemi.length,numSunLightShadows:I.sunShadowMap.length,numDirLightShadows:I.directionalShadowMap.length,numPointLightShadows:I.pointShadowMap.length,numSpotLightShadows:I.spotShadowMap.length,numSpotLightShadowsWithMaps:I.numSpotLightShadowsWithMaps,numLightProbes:I.numLightProbes,numLightProbeGrids:T.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:w.dithering,shadowMapEnabled:n.shadowMap.enabled&&G.length>0,shadowMapType:n.shadowMap.type,toneMapping:qt,decodeVideoTexture:Ye&&w.map.isVideoTexture===!0&&mi.getTransfer(w.map.colorSpace)===Li,decodeVideoTextureEmissive:st&&w.emissiveMap.isVideoTexture===!0&&mi.getTransfer(w.emissiveMap.colorSpace)===Li,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===Br,flipSided:w.side===Kr,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:He&&w.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(He&&w.extensions.multiDraw===!0||Re)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return Tt.vertexUv1s=u.has(1),Tt.vertexUv2s=u.has(2),Tt.vertexUv3s=u.has(3),u.clear(),Tt}function g(w){let I=[];if(w.shaderID?I.push(w.shaderID):(I.push(w.customVertexShaderID),I.push(w.customFragmentShaderID)),w.defines!==void 0)for(let G in w.defines)I.push(G),I.push(w.defines[G]);return w.isRawShaderMaterial===!1&&(v(I,w),L(I,w),I.push(n.outputColorSpace)),I.push(w.customProgramCacheKey),I.join()}function v(w,I){w.push(I.precision),w.push(I.outputColorSpace),w.push(I.envMapMode),w.push(I.envMapCubeUVHeight),w.push(I.mapUv),w.push(I.alphaMapUv),w.push(I.lightMapUv),w.push(I.aoMapUv),w.push(I.bumpMapUv),w.push(I.normalMapUv),w.push(I.displacementMapUv),w.push(I.emissiveMapUv),w.push(I.metalnessMapUv),w.push(I.roughnessMapUv),w.push(I.anisotropyMapUv),w.push(I.clearcoatMapUv),w.push(I.clearcoatNormalMapUv),w.push(I.clearcoatRoughnessMapUv),w.push(I.iridescenceMapUv),w.push(I.iridescenceThicknessMapUv),w.push(I.sheenColorMapUv),w.push(I.sheenRoughnessMapUv),w.push(I.specularMapUv),w.push(I.specularColorMapUv),w.push(I.specularIntensityMapUv),w.push(I.transmissionMapUv),w.push(I.thicknessMapUv),w.push(I.combine),w.push(I.fogExp2),w.push(I.sizeAttenuation),w.push(I.morphTargetsCount),w.push(I.morphAttributeCount),w.push(I.numSunLights),w.push(I.numDirLights),w.push(I.numPointLights),w.push(I.numSpotLights),w.push(I.numSpotLightMaps),w.push(I.numHemiLights),w.push(I.numRectAreaLights),w.push(I.numSunLightShadows),w.push(I.numDirLightShadows),w.push(I.numPointLightShadows),w.push(I.numSpotLightShadows),w.push(I.numSpotLightShadowsWithMaps),w.push(I.numLightProbes),w.push(I.shadowMapType),w.push(I.toneMapping),w.push(I.numClippingPlanes),w.push(I.numClipIntersection),w.push(I.depthPacking)}function L(w,I){s.disableAll(),I.instancing&&s.enable(0),I.instancingColor&&s.enable(1),I.instancingMorph&&s.enable(2),I.matcap&&s.enable(3),I.envMap&&s.enable(4),I.normalMapObjectSpace&&s.enable(5),I.normalMapTangentSpace&&s.enable(6),I.clearcoat&&s.enable(7),I.iridescence&&s.enable(8),I.alphaTest&&s.enable(9),I.vertexColors&&s.enable(10),I.vertexAlphas&&s.enable(11),I.vertexUv1s&&s.enable(12),I.vertexUv2s&&s.enable(13),I.vertexUv3s&&s.enable(14),I.vertexTangents&&s.enable(15),I.anisotropy&&s.enable(16),I.alphaHash&&s.enable(17),I.batching&&s.enable(18),I.dispersion&&s.enable(19),I.retroreflection&&s.enable(24),I.batchingColor&&s.enable(20),I.gradientMap&&s.enable(21),I.packedNormalMap&&s.enable(22),I.vertexNormals&&s.enable(23),w.push(s.mask),s.disableAll(),I.fog&&s.enable(0),I.useFog&&s.enable(1),I.flatShading&&s.enable(2),I.logarithmicDepthBuffer&&s.enable(3),I.reversedDepthBuffer&&s.enable(4),I.skinning&&s.enable(5),I.morphTargets&&s.enable(6),I.morphNormals&&s.enable(7),I.morphColors&&s.enable(8),I.premultipliedAlpha&&s.enable(9),I.shadowMapEnabled&&s.enable(10),I.doubleSided&&s.enable(11),I.flipSided&&s.enable(12),I.useDepthPacking&&s.enable(13),I.dithering&&s.enable(14),I.transmission&&s.enable(15),I.sheen&&s.enable(16),I.opaque&&s.enable(17),I.pointsUvs&&s.enable(18),I.decodeVideoTexture&&s.enable(19),I.decodeVideoTextureEmissive&&s.enable(20),I.alphaToCoverage&&s.enable(21),I.numLightProbeGrids>0&&s.enable(22),I.hasPositionAttribute&&s.enable(23),w.push(s.mask)}function p(w){let I=m[w.type],G;if(I){let H=es[I];G=R0.clone(H.uniforms)}else G=w.uniforms;return G}function _(w,I){let G=d.get(I);return G!==void 0?++G.usedTimes:(G=new uw(n,I,w,r),l.push(G),d.set(I,G)),G}function N(w){if(--w.usedTimes===0){let I=l.indexOf(w);l[I]=l[l.length-1],l.pop(),d.delete(w.cacheKey),w.destroy()}}function D(w){o.remove(w)}function V(){o.dispose()}return{getParameters:M,getProgramCacheKey:g,getUniforms:p,acquireProgram:_,releaseProgram:N,releaseShaderCache:D,programs:l,dispose:V}}function pw(){let n=new WeakMap;function e(s){return n.has(s)}function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function i(s){n.delete(s)}function r(s,o,u){n.get(s)[o]=u}function a(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:a}}function mw(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function $0(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function K0(){let n=[],e=0,t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(h){let m=0;return h.isInstancedMesh&&(m+=2),h.isSkinnedMesh&&(m+=1),m}function o(h,m,y,M,g,v){let L=n[e];return L===void 0?(L={id:h.id,object:h,geometry:m,material:y,materialVariant:s(h),groupOrder:M,renderOrder:h.renderOrder,z:g,group:v},n[e]=L):(L.id=h.id,L.object=h,L.geometry=m,L.material=y,L.materialVariant=s(h),L.groupOrder=M,L.renderOrder=h.renderOrder,L.z=g,L.group=v),e++,L}function u(h,m,y,M,g,v,L){L.reversedDepth===!0&&(g=-g);let p=o(h,m,y,M,g,v);y.transmission>0?i.push(p):y.transparent===!0?r.push(p):t.push(p)}function l(h,m,y,M,g,v){let L=o(h,m,y,M,g,v);y.transmission>0?i.unshift(L):y.transparent===!0?r.unshift(L):t.unshift(L)}function d(h,m){t.length>1&&t.sort(h||mw),i.length>1&&i.sort(m||$0),r.length>1&&r.sort(m||$0)}function f(){for(let h=e,m=n.length;h<m;h++){let y=n[h];if(y.id===null)break;y.id=null,y.object=null,y.geometry=null,y.material=null,y.group=null}}return{opaque:t,transmissive:i,transparent:r,init:a,push:u,unshift:l,finish:f,sort:d}}function vw(){let n=new WeakMap;function e(i,r){let a=n.get(i),s;return a===void 0?(s=new K0,n.set(i,[s])):r>=a.length?(s=new K0,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function gw(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new xe,color:new zn};break;case"SpotLight":t={position:new xe,direction:new xe,color:new zn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new xe,color:new zn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new xe,skyColor:new zn,groundColor:new zn};break;case"RectAreaLight":t={color:new zn,position:new xe,halfWidth:new xe,halfHeight:new xe};break}return n[e.id]=t,t}}}function yw(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var xw=0;function _w(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Mw(n){let e=new gw,t=yw(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new xe);let r=new xe,a=new Kn,s=new Kn;function o(l){let d=0,f=0,h=0;for(let Q=0;Q<9;Q++)i.probe[Q].set(0,0,0);let m=0,y=0,M=0,g=0,v=0,L=0,p=0,_=0,N=0,D=0,V=0,w=0,I=0,G=0;l.sort(_w);for(let Q=0,T=l.length;Q<T;Q++){let S=l[Q],Z=S.color,q=S.intensity,se=S.distance,F=null;if(S.shadow&&S.shadow.map&&(S.shadow.map.texture.format===Ws?F=S.shadow.map.texture:F=S.shadow.map.depthTexture||S.shadow.map.texture),S.isAmbientLight)d+=Z.r*q,f+=Z.g*q,h+=Z.b*q;else if(S.isLightProbe){for(let z=0;z<9;z++)i.probe[z].addScaledVector(S.sh.coefficients[z],q);G++}else if(S.isSunLight){let z=e.get(S);if(z.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let Y=S.shadow,$=t.get(S);$.shadowIntensity=Y.intensity,$.shadowBias=Y.bias,$.shadowNormalBias=Y.normalBias,$.shadowRadius=Y.radius,$.shadowMapSize.copy(Y.mapSize).multiply(Y.getFrameExtents()),i.sunShadow[y]=$,i.sunShadowMap[y]=F;let he=Y.getViewportCount();for(let pe=0;pe<he;pe++)i.sunShadowMatrix[M+pe]=Y.getMatrix(pe),i.sunShadowCascade[M+pe]=Y._cascadeData[pe];M+=he,y++}i.sun[m]=z,m++}else if(S.isDirectionalLight){let z=e.get(S);if(z.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let Y=S.shadow,$=t.get(S);$.shadowIntensity=Y.intensity,$.shadowBias=Y.bias,$.shadowNormalBias=Y.normalBias,$.shadowRadius=Y.radius,$.shadowMapSize=Y.mapSize,i.directionalShadow[g]=$,i.directionalShadowMap[g]=F,i.directionalShadowMatrix[g]=S.shadow.matrix,N++}i.directional[g]=z,g++}else if(S.isSpotLight){let z=e.get(S);z.position.setFromMatrixPosition(S.matrixWorld),z.color.copy(Z).multiplyScalar(q),z.distance=se,z.coneCos=Math.cos(S.angle),z.penumbraCos=Math.cos(S.angle*(1-S.penumbra)),z.decay=S.decay,i.spot[L]=z;let Y=S.shadow;if(S.map&&(i.spotLightMap[w]=S.map,w++,Y.updateMatrices(S),S.castShadow&&I++),i.spotLightMatrix[L]=Y.matrix,S.castShadow){let $=t.get(S);$.shadowIntensity=Y.intensity,$.shadowBias=Y.bias,$.shadowNormalBias=Y.normalBias,$.shadowRadius=Y.radius,$.shadowMapSize=Y.mapSize,i.spotShadow[L]=$,i.spotShadowMap[L]=F,V++}L++}else if(S.isRectAreaLight){let z=e.get(S);z.color.copy(Z).multiplyScalar(q),z.halfWidth.set(S.width*.5,0,0),z.halfHeight.set(0,S.height*.5,0),i.rectArea[p]=z,p++}else if(S.isPointLight){let z=e.get(S);if(z.color.copy(S.color).multiplyScalar(S.intensity),z.distance=S.distance,z.decay=S.decay,S.castShadow){let Y=S.shadow,$=t.get(S);$.shadowIntensity=Y.intensity,$.shadowBias=Y.bias,$.shadowNormalBias=Y.normalBias,$.shadowRadius=Y.radius,$.shadowMapSize=Y.mapSize,$.shadowCameraNear=Y.camera.near,$.shadowCameraFar=Y.camera.far,i.pointShadow[v]=$,i.pointShadowMap[v]=F,i.pointShadowMatrix[v]=S.shadow.matrix,D++}i.point[v]=z,v++}else if(S.isHemisphereLight){let z=e.get(S);z.skyColor.copy(S.color).multiplyScalar(q),z.groundColor.copy(S.groundColor).multiplyScalar(q),i.hemi[_]=z,_++}}p>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=$t.LTC_FLOAT_1,i.rectAreaLTC2=$t.LTC_FLOAT_2):(i.rectAreaLTC1=$t.LTC_HALF_1,i.rectAreaLTC2=$t.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=h;let H=i.hash;(H.sunLength!==m||H.directionalLength!==g||H.pointLength!==v||H.spotLength!==L||H.rectAreaLength!==p||H.hemiLength!==_||H.numSunShadows!==y||H.numDirectionalShadows!==N||H.numPointShadows!==D||H.numSpotShadows!==V||H.numSpotMaps!==w||H.numLightProbes!==G)&&(i.sun.length=m,i.directional.length=g,i.spot.length=L,i.rectArea.length=p,i.point.length=v,i.hemi.length=_,i.sunShadow.length=y,i.sunShadowMap.length=y,i.sunShadowMatrix.length=M,i.sunShadowCascade.length=M,i.directionalShadow.length=N,i.directionalShadowMap.length=N,i.directionalShadowMatrix.length=N,i.pointShadow.length=D,i.pointShadowMap.length=D,i.pointShadowMatrix.length=D,i.spotShadow.length=V,i.spotShadowMap.length=V,i.spotLightMatrix.length=V+w-I,i.spotLightMap.length=w,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=G,H.sunLength=m,H.directionalLength=g,H.pointLength=v,H.spotLength=L,H.rectAreaLength=p,H.hemiLength=_,H.numSunShadows=y,H.numDirectionalShadows=N,H.numPointShadows=D,H.numSpotShadows=V,H.numSpotMaps=w,H.numLightProbes=G,i.version=xw++)}function u(l,d){let f=0,h=0,m=0,y=0,M=0,g=0,v=d.matrixWorldInverse;for(let L=0,p=l.length;L<p;L++){let _=l[L];if(_.isSunLight){let N=i.sun[f];N.direction.setFromMatrixPosition(_.matrixWorld),N.direction.transformDirection(v),f++}else if(_.isDirectionalLight){let N=i.directional[h];N.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),N.direction.sub(r),N.direction.transformDirection(v),h++}else if(_.isSpotLight){let N=i.spot[y];N.position.setFromMatrixPosition(_.matrixWorld),N.position.applyMatrix4(v),N.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),N.direction.sub(r),N.direction.transformDirection(v),y++}else if(_.isRectAreaLight){let N=i.rectArea[M];N.position.setFromMatrixPosition(_.matrixWorld),N.position.applyMatrix4(v),s.identity(),a.copy(_.matrixWorld),a.premultiply(v),s.extractRotation(a),N.halfWidth.set(_.width*.5,0,0),N.halfHeight.set(0,_.height*.5,0),N.halfWidth.applyMatrix4(s),N.halfHeight.applyMatrix4(s),M++}else if(_.isPointLight){let N=i.point[m];N.position.setFromMatrixPosition(_.matrixWorld),N.position.applyMatrix4(v),m++}else if(_.isHemisphereLight){let N=i.hemi[g];N.direction.setFromMatrixPosition(_.matrixWorld),N.direction.transformDirection(v),g++}}}return{setup:o,setupView:u,state:i}}function Q0(n){let e=new Mw(n),t=[],i=[],r=[];function a(h){f.camera=h,t.length=0,i.length=0,r.length=0}function s(h){t.push(h)}function o(h){i.push(h)}function u(h){r.push(h)}function l(){e.setup(t)}function d(h){e.setupView(t,h)}let f={lightsArray:t,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:f,setupLights:l,setupLightsView:d,pushLight:s,pushShadow:o,pushLightProbeGrid:u}}function Sw(n){let e=new WeakMap;function t(r,a=0){let s=e.get(r),o;return s===void 0?(o=new Q0(n),e.set(r,[o])):a>=s.length?(o=new Q0(n),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:t,dispose:i}}var bw=`void main() {
|
|
4170
4170
|
gl_Position = vec4( position, 1.0 );
|
|
4171
|
-
}`,
|
|
4171
|
+
}`,ww=`uniform sampler2D shadow_pass;
|
|
4172
4172
|
uniform vec2 resolution;
|
|
4173
4173
|
uniform float radius;
|
|
4174
4174
|
void main() {
|
|
@@ -4193,12 +4193,12 @@ void main() {
|
|
|
4193
4193
|
squared_mean = squared_mean / samples;
|
|
4194
4194
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4195
4195
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4196
|
-
}`,nw=[new ge(1,0,0),new ge(-1,0,0),new ge(0,1,0),new ge(0,-1,0),new ge(0,0,1),new ge(0,0,-1)],iw=[new ge(0,-1,0),new ge(0,-1,0),new ge(0,0,1),new ge(0,0,-1),new ge(0,-1,0),new ge(0,-1,0)],N0=new Un,Uc=new ge,Sp=new ge;function rw(n,e,t){let i=new nl,r=new qt,a=new qt,s=new Si,o=new id,u=new rd,l={},d=t.maxTextureSize,f={[Va]:Dr,[Dr]:Va,[Er]:Er},h=new ea({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qt},radius:{value:4}},vertexShader:ew,fragmentShader:tw}),m=h.clone();m.defines.HORIZONTAL_PASS=1;let y=new sr;y.setAttribute("position",new Tr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let M=new ai(y,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bc;let v=this.type;this.render=function(D,B,w){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||D.length===0)return;this.type===xd&&(mn("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=bc);let A=n.getRenderTarget(),z=n.getActiveCubeFace(),V=n.getActiveMipmapLevel(),$=n.state;$.setBlending(Ga),$.buffers.depth.getReversed()===!0?$.buffers.color.setClear(0,0,0,0):$.buffers.color.setClear(1,1,1,1),$.buffers.depth.setTest(!0),$.setScissorTest(!1);let T=v!==this.type;T&&B.traverse(function(S){S.material&&(Array.isArray(S.material)?S.material.forEach(Y=>Y.needsUpdate=!0):S.material.needsUpdate=!0)});for(let S=0,Y=D.length;S<Y;S++){let W=D[S],se=W.shadow;if(se===void 0){mn("WebGLShadowMap:",W,"has no shadow.");continue}if(se.autoUpdate===!1&&se.needsUpdate===!1)continue;r.copy(se.mapSize);let O=se.getFrameExtents();r.multiply(O),a.copy(se.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/O.x),r.x=a.x*O.x,se.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/O.y),r.y=a.y*O.y,se.mapSize.y=a.y));let U=n.state.buffers.depth.getReversed();if(se.camera._reversedDepth=U,se.map===null||T===!0){if(se.map!==null&&(se.map.depthTexture!==null&&(se.map.depthTexture.dispose(),se.map.depthTexture=null),se.map.dispose()),this.type===ul){if(W.isPointLight){mn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}se.map=new zr(r.x,r.y,{format:Ls,type:Ca,minFilter:rr,magFilter:rr,generateMipmaps:!1}),se.map.texture.name=W.name+".shadowMap",se.map.depthTexture=new Es(r.x,r.y,na),se.map.depthTexture.name=W.name+".shadowMapDepth",se.map.depthTexture.format=Ba,se.map.depthTexture.compareFunction=null,se.map.depthTexture.minFilter=Ki,se.map.depthTexture.magFilter=Ki}else W.isPointLight?(se.map=new df(r.x),se.map.depthTexture=new Ju(r.x,Ia)):(se.map=new zr(r.x,r.y),se.map.depthTexture=new Es(r.x,r.y,Ia)),se.map.depthTexture.name=W.name+".shadowMap",se.map.depthTexture.format=Ba,this.type===bc?(se.map.depthTexture.compareFunction=U?lf:of,se.map.depthTexture.minFilter=rr,se.map.depthTexture.magFilter=rr):(se.map.depthTexture.compareFunction=null,se.map.depthTexture.minFilter=Ki,se.map.depthTexture.magFilter=Ki);se.camera.updateProjectionMatrix()}se.map.isWebGLCubeRenderTarget!==!0&&(se.map.width!==r.x||se.map.height!==r.y)&&se.map.setSize(r.x,r.y);let H=se.map.isWebGLCubeRenderTarget?6:se.getViewportCount();W.isPointLight!==!0&&se.updateMatrices(W,w);for(let ne=0;ne<H;ne++){let ce=se.getCamera(ne);if(W.isPointLight){let pe=se.camera,le=se.matrix,be=W.distance||pe.far;be!==pe.far&&(pe.far=be,pe.updateProjectionMatrix()),Uc.setFromMatrixPosition(W.matrixWorld),pe.position.copy(Uc),Sp.copy(pe.position),Sp.add(nw[ne]),pe.up.copy(iw[ne]),pe.lookAt(Sp),pe.updateMatrixWorld(),le.makeTranslation(-Uc.x,-Uc.y,-Uc.z),N0.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),se._frustum.setFromProjectionMatrix(N0,pe.coordinateSystem,pe.reversedDepth)}if(se.map.isWebGLCubeRenderTarget)n.setRenderTarget(se.map,ne),n.clear();else{ne===0&&(n.setRenderTarget(se.map),n.clear());let pe=se.getViewport(ne);s.set(a.x*pe.x,a.y*pe.y,a.x*pe.z,a.y*pe.w),$.viewport(s)}i=se.getFrustum(ne),_(B,w,ce,W,this.type)}se.isPointLightShadow!==!0&&this.type===ul&&P(se,w),se.needsUpdate=!1}v=this.type,g.needsUpdate=!1,n.setRenderTarget(A,z,V)};function P(D,B){let w=e.update(M);h.defines.VSM_SAMPLES!==D.blurSamples&&(h.defines.VSM_SAMPLES=D.blurSamples,m.defines.VSM_SAMPLES=D.blurSamples,h.needsUpdate=!0,m.needsUpdate=!0),D.mapPass===null?D.mapPass=new zr(r.x,r.y,{format:Ls,type:Ca}):(D.mapPass.width!==D.map.width||D.mapPass.height!==D.map.height)&&D.mapPass.setSize(D.map.width,D.map.height),h.uniforms.shadow_pass.value=D.map.depthTexture,h.uniforms.resolution.value.set(D.map.width,D.map.height),h.uniforms.radius.value=D.radius,n.setRenderTarget(D.mapPass),n.clear(),n.renderBufferDirect(B,null,w,h,M,null),m.uniforms.shadow_pass.value=D.mapPass.texture,m.uniforms.resolution.value.set(D.map.width,D.map.height),m.uniforms.radius.value=D.radius,n.setRenderTarget(D.map),n.clear(),n.renderBufferDirect(B,null,w,m,M,null)}function p(D,B,w,A){let z=null,V=w.isPointLight===!0?D.customDistanceMaterial:D.customDepthMaterial;if(V!==void 0)z=V;else if(z=w.isPointLight===!0?u:o,n.localClippingEnabled&&B.clipShadows===!0&&Array.isArray(B.clippingPlanes)&&B.clippingPlanes.length!==0||B.displacementMap&&B.displacementScale!==0||B.alphaMap&&B.alphaTest>0||B.map&&B.alphaTest>0||B.alphaToCoverage===!0){let $=z.uuid,T=B.uuid,S=l[$];S===void 0&&(S={},l[$]=S);let Y=S[T];Y===void 0&&(Y=z.clone(),S[T]=Y,B.addEventListener("dispose",N)),z=Y}if(z.visible=B.visible,z.wireframe=B.wireframe,A===ul?z.side=B.shadowSide!==null?B.shadowSide:B.side:z.side=B.shadowSide!==null?B.shadowSide:f[B.side],z.alphaMap=B.alphaMap,z.alphaTest=B.alphaToCoverage===!0?.5:B.alphaTest,z.map=B.map,z.clipShadows=B.clipShadows,z.clippingPlanes=B.clippingPlanes,z.clipIntersection=B.clipIntersection,z.displacementMap=B.displacementMap,z.displacementScale=B.displacementScale,z.displacementBias=B.displacementBias,z.wireframeLinewidth=B.wireframeLinewidth,z.linewidth=B.linewidth,w.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let $=n.properties.get(z);$.light=w}return z}function _(D,B,w,A,z){if(D.visible===!1)return;if(D.layers.test(B.layers)&&(D.isMesh||D.isLine||D.isPoints)&&(D.castShadow||D.receiveShadow&&z===ul)&&(!D.frustumCulled||D.intersectsFrustum(i))){D.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,D.matrixWorld);let T=e.update(D),S=D.material;if(Array.isArray(S)){let Y=T.groups;for(let W=0,se=Y.length;W<se;W++){let O=Y[W],U=S[O.materialIndex];if(U&&U.visible){let H=p(D,U,A,z);D.onBeforeShadow(n,D,B,w,T,H,O),n.renderBufferDirect(w,null,T,H,D,O),D.onAfterShadow(n,D,B,w,T,H,O)}}}else if(S.visible){let Y=p(D,S,A,z);D.onBeforeShadow(n,D,B,w,T,Y,null),n.renderBufferDirect(w,null,T,Y,D,null),D.onAfterShadow(n,D,B,w,T,Y,null)}}let $=D.children;for(let T=0,S=$.length;T<S;T++)_($[T],B,w,A,z)}function N(D){D.target.removeEventListener("dispose",N);for(let w in l){let A=l[w],z=D.target.uuid;z in A&&(A[z].dispose(),delete A[z])}}}function aw(n,e){function t(){let oe=!1,st=new Si,Ne=null,ft=new Si(0,0,0,0);return{setMask:function(ht){Ne!==ht&&!oe&&(n.colorMask(ht,ht,ht,ht),Ne=ht)},setLocked:function(ht){oe=ht},setClear:function(ht,ze,Ot,Tt,_t){_t===!0&&(ht*=Tt,ze*=Tt,Ot*=Tt),st.set(ht,ze,Ot,Tt),ft.equals(st)===!1&&(n.clearColor(ht,ze,Ot,Tt),ft.copy(st))},reset:function(){oe=!1,Ne=null,ft.set(-1,0,0,0)}}}function i(){let oe=!1,st=!1,Ne=null,ft=null,ht=null;return{setReversed:function(ze){if(st!==ze){let Ot=e.get("EXT_clip_control");ze?Ot.clipControlEXT(Ot.LOWER_LEFT_EXT,Ot.ZERO_TO_ONE_EXT):Ot.clipControlEXT(Ot.LOWER_LEFT_EXT,Ot.NEGATIVE_ONE_TO_ONE_EXT),st=ze;let Tt=ht;ht=null,this.setClear(Tt)}},getReversed:function(){return st},setTest:function(ze){ze?ie(n.DEPTH_TEST):Me(n.DEPTH_TEST)},setMask:function(ze){Ne!==ze&&!oe&&(n.depthMask(ze),Ne=ze)},setFunc:function(ze){if(st&&(ze=a0[ze]),ft!==ze){switch(ze){case Ou:n.depthFunc(n.NEVER);break;case Bu:n.depthFunc(n.ALWAYS);break;case ku:n.depthFunc(n.LESS);break;case Yo:n.depthFunc(n.LEQUAL);break;case zu:n.depthFunc(n.EQUAL);break;case Vu:n.depthFunc(n.GEQUAL);break;case Gu:n.depthFunc(n.GREATER);break;case Hu:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ft=ze}},setLocked:function(ze){oe=ze},setClear:function(ze){ht!==ze&&(ht=ze,st&&(ze=1-ze),n.clearDepth(ze))},reset:function(){oe=!1,Ne=null,ft=null,ht=null,st=!1}}}function r(){let oe=!1,st=null,Ne=null,ft=null,ht=null,ze=null,Ot=null,Tt=null,_t=null;return{setTest:function(Bt){oe||(Bt?ie(n.STENCIL_TEST):Me(n.STENCIL_TEST))},setMask:function(Bt){st!==Bt&&!oe&&(n.stencilMask(Bt),st=Bt)},setFunc:function(Bt,rt,Ct){(Ne!==Bt||ft!==rt||ht!==Ct)&&(n.stencilFunc(Bt,rt,Ct),Ne=Bt,ft=rt,ht=Ct)},setOp:function(Bt,rt,Ct){(ze!==Bt||Ot!==rt||Tt!==Ct)&&(n.stencilOp(Bt,rt,Ct),ze=Bt,Ot=rt,Tt=Ct)},setLocked:function(Bt){oe=Bt},setClear:function(Bt){_t!==Bt&&(n.clearStencil(Bt),_t=Bt)},reset:function(){oe=!1,st=null,Ne=null,ft=null,ht=null,ze=null,Ot=null,Tt=null,_t=null}}}let a=new t,s=new i,o=new r,u=new WeakMap,l=new WeakMap,d={},f={},h={},m=new WeakMap,y=[],M=null,g=!1,v=null,P=null,p=null,_=null,N=null,D=null,B=null,w=new Rn(0,0,0),A=0,z=!1,V=null,$=null,T=null,S=null,Y=null,W=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),se=!1,O=0,U=n.getParameter(n.VERSION);U.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(U)[1]),se=O>=1):U.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),se=O>=2);let H=null,ne={},ce=n.getParameter(n.SCISSOR_BOX),pe=n.getParameter(n.VIEWPORT),le=new Si().fromArray(ce),be=new Si().fromArray(pe);function Pe(oe,st,Ne,ft){let ht=new Uint8Array(4),ze=n.createTexture();n.bindTexture(oe,ze),n.texParameteri(oe,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(oe,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ot=0;Ot<Ne;Ot++)oe===n.TEXTURE_3D||oe===n.TEXTURE_2D_ARRAY?n.texImage3D(st,0,n.RGBA,1,1,ft,0,n.RGBA,n.UNSIGNED_BYTE,ht):n.texImage2D(st+Ot,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ht);return ze}let Q={};Q[n.TEXTURE_2D]=Pe(n.TEXTURE_2D,n.TEXTURE_2D,1),Q[n.TEXTURE_CUBE_MAP]=Pe(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),Q[n.TEXTURE_2D_ARRAY]=Pe(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),Q[n.TEXTURE_3D]=Pe(n.TEXTURE_3D,n.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ie(n.DEPTH_TEST),s.setFunc(Yo),ke(!1),at(Vh),ie(n.CULL_FACE),Ye(Ga);function ie(oe){d[oe]!==!0&&(n.enable(oe),d[oe]=!0)}function Me(oe){d[oe]!==!1&&(n.disable(oe),d[oe]=!1)}function Le(oe,st){return h[oe]!==st?(n.bindFramebuffer(oe,st),h[oe]=st,oe===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=st),oe===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=st),!0):!1}function Ee(oe,st){let Ne=y,ft=!1;if(oe){Ne=m.get(st),Ne===void 0&&(Ne=[],m.set(st,Ne));let ht=oe.textures;if(Ne.length!==ht.length||Ne[0]!==n.COLOR_ATTACHMENT0){for(let ze=0,Ot=ht.length;ze<Ot;ze++)Ne[ze]=n.COLOR_ATTACHMENT0+ze;Ne.length=ht.length,ft=!0}}else Ne[0]!==n.BACK&&(Ne[0]=n.BACK,ft=!0);ft&&n.drawBuffers(Ne)}function Xe(oe){return M!==oe?(n.useProgram(oe),M=oe,!0):!1}let tt={[co]:n.FUNC_ADD,[Ev]:n.FUNC_SUBTRACT,[Av]:n.FUNC_REVERSE_SUBTRACT};tt[Iv]=n.MIN,tt[Cv]=n.MAX;let Ge={[Rv]:n.ZERO,[Pv]:n.ONE,[Lv]:n.SRC_COLOR,[Xh]:n.SRC_ALPHA,[Bv]:n.SRC_ALPHA_SATURATE,[Fv]:n.DST_COLOR,[Nv]:n.DST_ALPHA,[Dv]:n.ONE_MINUS_SRC_COLOR,[Yh]:n.ONE_MINUS_SRC_ALPHA,[Ov]:n.ONE_MINUS_DST_COLOR,[Uv]:n.ONE_MINUS_DST_ALPHA,[kv]:n.CONSTANT_COLOR,[zv]:n.ONE_MINUS_CONSTANT_COLOR,[Vv]:n.CONSTANT_ALPHA,[Gv]:n.ONE_MINUS_CONSTANT_ALPHA};function Ye(oe,st,Ne,ft,ht,ze,Ot,Tt,_t,Bt){if(oe===Ga){g===!0&&(Me(n.BLEND),g=!1);return}if(g===!1&&(ie(n.BLEND),g=!0),oe!==Tv){if(oe!==v||Bt!==z){if((P!==co||N!==co)&&(n.blendEquation(n.FUNC_ADD),P=co,N=co),Bt)switch(oe){case dl:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Gh:n.blendFunc(n.ONE,n.ONE);break;case Hh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Wh:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:Tn("WebGLState: Invalid blending: ",oe);break}else switch(oe){case dl:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Gh:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Hh:Tn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Wh:Tn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Tn("WebGLState: Invalid blending: ",oe);break}p=null,_=null,D=null,B=null,w.set(0,0,0),A=0,v=oe,z=Bt}return}ht=ht||st,ze=ze||Ne,Ot=Ot||ft,(st!==P||ht!==N)&&(n.blendEquationSeparate(tt[st],tt[ht]),P=st,N=ht),(Ne!==p||ft!==_||ze!==D||Ot!==B)&&(n.blendFuncSeparate(Ge[Ne],Ge[ft],Ge[ze],Ge[Ot]),p=Ne,_=ft,D=ze,B=Ot),(Tt.equals(w)===!1||_t!==A)&&(n.blendColor(Tt.r,Tt.g,Tt.b,_t),w.copy(Tt),A=_t),v=oe,z=!1}function dt(oe,st){oe.side===Er?Me(n.CULL_FACE):ie(n.CULL_FACE);let Ne=oe.side===Dr;st&&(Ne=!Ne),ke(Ne),oe.blending===dl&&oe.transparent===!1?Ye(Ga):Ye(oe.blending,oe.blendEquation,oe.blendSrc,oe.blendDst,oe.blendEquationAlpha,oe.blendSrcAlpha,oe.blendDstAlpha,oe.blendColor,oe.blendAlpha,oe.premultipliedAlpha),s.setFunc(oe.depthFunc),s.setTest(oe.depthTest),s.setMask(oe.depthWrite),a.setMask(oe.colorWrite);let ft=oe.stencilWrite;o.setTest(ft),ft&&(o.setMask(oe.stencilWriteMask),o.setFunc(oe.stencilFunc,oe.stencilRef,oe.stencilFuncMask),o.setOp(oe.stencilFail,oe.stencilZFail,oe.stencilZPass)),jt(oe.polygonOffset,oe.polygonOffsetFactor,oe.polygonOffsetUnits),oe.alphaToCoverage===!0?ie(n.SAMPLE_ALPHA_TO_COVERAGE):Me(n.SAMPLE_ALPHA_TO_COVERAGE)}function ke(oe){V!==oe&&(oe?n.frontFace(n.CW):n.frontFace(n.CCW),V=oe)}function at(oe){oe!==bv?(ie(n.CULL_FACE),oe!==$&&(oe===Vh?n.cullFace(n.BACK):oe===wv?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Me(n.CULL_FACE),$=oe}function Ke(oe){oe!==T&&(se&&n.lineWidth(oe),T=oe)}function jt(oe,st,Ne){oe?(ie(n.POLYGON_OFFSET_FILL),(S!==st||Y!==Ne)&&(S=st,Y=Ne,s.getReversed()&&(st=-st),n.polygonOffset(st,Ne))):Me(n.POLYGON_OFFSET_FILL)}function Pt(oe){oe?ie(n.SCISSOR_TEST):Me(n.SCISSOR_TEST)}function tn(oe){oe===void 0&&(oe=n.TEXTURE0+W-1),H!==oe&&(n.activeTexture(oe),H=oe)}function ue(oe,st,Ne){Ne===void 0&&(H===null?Ne=n.TEXTURE0+W-1:Ne=H);let ft=ne[Ne];ft===void 0&&(ft={type:void 0,texture:void 0},ne[Ne]=ft),(ft.type!==oe||ft.texture!==st)&&(H!==Ne&&(n.activeTexture(Ne),H=Ne),n.bindTexture(oe,st||Q[oe]),ft.type=oe,ft.texture=st)}function ln(){let oe=ne[H];oe!==void 0&&oe.type!==void 0&&(n.bindTexture(oe.type,null),oe.type=void 0,oe.texture=void 0)}function on(){try{n.compressedTexImage2D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function Z(){try{n.compressedTexImage3D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function b(){try{n.texSubImage2D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function ee(){try{n.texSubImage3D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function ve(){try{n.compressedTexSubImage2D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function Te(){try{n.compressedTexSubImage3D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function Ve(){try{n.texStorage2D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function $e(){try{n.texStorage3D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function Ce(){try{n.texImage2D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function Ae(){try{n.texImage3D(...arguments)}catch(oe){Tn("WebGLState:",oe)}}function nt(oe){return f[oe]!==void 0?f[oe]:n.getParameter(oe)}function gt(oe,st){f[oe]!==st&&(n.pixelStorei(oe,st),f[oe]=st)}function ct(oe){le.equals(oe)===!1&&(n.scissor(oe.x,oe.y,oe.z,oe.w),le.copy(oe))}function je(oe){be.equals(oe)===!1&&(n.viewport(oe.x,oe.y,oe.z,oe.w),be.copy(oe))}function Dt(oe,st){let Ne=l.get(st);Ne===void 0&&(Ne=new WeakMap,l.set(st,Ne));let ft=Ne.get(oe);ft===void 0&&(ft=n.getUniformBlockIndex(st,oe.name),Ne.set(oe,ft))}function qe(oe,st){let ft=l.get(st).get(oe);u.get(st)!==ft&&(n.uniformBlockBinding(st,ft,oe.__bindingPointIndex),u.set(st,ft))}function Gt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),s.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.pixelStorei(n.PACK_ROW_LENGTH,0),n.pixelStorei(n.PACK_SKIP_PIXELS,0),n.pixelStorei(n.PACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_ROW_LENGTH,0),n.pixelStorei(n.UNPACK_IMAGE_HEIGHT,0),n.pixelStorei(n.UNPACK_SKIP_PIXELS,0),n.pixelStorei(n.UNPACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_SKIP_IMAGES,0),d={},f={},H=null,ne={},h={},m=new WeakMap,y=[],M=null,g=!1,v=null,P=null,p=null,_=null,N=null,D=null,B=null,w=new Rn(0,0,0),A=0,z=!1,V=null,$=null,T=null,S=null,Y=null,le.set(0,0,n.canvas.width,n.canvas.height),be.set(0,0,n.canvas.width,n.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:ie,disable:Me,bindFramebuffer:Le,drawBuffers:Ee,useProgram:Xe,setBlending:Ye,setMaterial:dt,setFlipSided:ke,setCullFace:at,setLineWidth:Ke,setPolygonOffset:jt,setScissorTest:Pt,activeTexture:tn,bindTexture:ue,unbindTexture:ln,compressedTexImage2D:on,compressedTexImage3D:Z,texImage2D:Ce,texImage3D:Ae,pixelStorei:gt,getParameter:nt,updateUBOMapping:Dt,uniformBlockBinding:qe,texStorage2D:Ve,texStorage3D:$e,texSubImage2D:b,texSubImage3D:ee,compressedTexSubImage2D:ve,compressedTexSubImage3D:Te,scissor:ct,viewport:je,reset:Gt}}function sw(n,e,t,i,r,a,s){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new qt,d=new WeakMap,f=new Set,h,m=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(Z,b){return y?new OffscreenCanvas(Z,b):jl("canvas")}function g(Z,b,ee){let ve=1,Te=on(Z);if((Te.width>ee||Te.height>ee)&&(ve=ee/Math.max(Te.width,Te.height)),ve<1)if(typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Z instanceof ImageBitmap||typeof VideoFrame<"u"&&Z instanceof VideoFrame){let Ve=Math.floor(ve*Te.width),$e=Math.floor(ve*Te.height);h===void 0&&(h=M(Ve,$e));let Ce=b?M(Ve,$e):h;return Ce.width=Ve,Ce.height=$e,Ce.getContext("2d").drawImage(Z,0,0,Ve,$e),mn("WebGLRenderer: Texture has been resized from ("+Te.width+"x"+Te.height+") to ("+Ve+"x"+$e+")."),Ce}else return"data"in Z&&mn("WebGLRenderer: Image in DataTexture is too big ("+Te.width+"x"+Te.height+")."),Z;return Z}function v(Z){return Z.generateMipmaps}function P(Z){n.generateMipmap(Z)}function p(Z){return Z.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:Z.isWebGL3DRenderTarget?n.TEXTURE_3D:Z.isWebGLArrayRenderTarget||Z.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function _(Z,b,ee,ve,Te,Ve=!1){if(Z!==null){if(n[Z]!==void 0)return n[Z];mn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Z+"'")}let $e;ve&&($e=e.get("EXT_texture_norm16"),$e||mn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Ce=b;if(b===n.RED&&(ee===n.FLOAT&&(Ce=n.R32F),ee===n.HALF_FLOAT&&(Ce=n.R16F),ee===n.UNSIGNED_BYTE&&(Ce=n.R8),ee===n.UNSIGNED_SHORT&&$e&&(Ce=$e.R16_EXT),ee===n.SHORT&&$e&&(Ce=$e.R16_SNORM_EXT)),b===n.RED_INTEGER&&(ee===n.UNSIGNED_BYTE&&(Ce=n.R8UI),ee===n.UNSIGNED_SHORT&&(Ce=n.R16UI),ee===n.UNSIGNED_INT&&(Ce=n.R32UI),ee===n.BYTE&&(Ce=n.R8I),ee===n.SHORT&&(Ce=n.R16I),ee===n.INT&&(Ce=n.R32I)),b===n.RG&&(ee===n.FLOAT&&(Ce=n.RG32F),ee===n.HALF_FLOAT&&(Ce=n.RG16F),ee===n.UNSIGNED_BYTE&&(Ce=n.RG8),ee===n.UNSIGNED_SHORT&&$e&&(Ce=$e.RG16_EXT),ee===n.SHORT&&$e&&(Ce=$e.RG16_SNORM_EXT)),b===n.RG_INTEGER&&(ee===n.UNSIGNED_BYTE&&(Ce=n.RG8UI),ee===n.UNSIGNED_SHORT&&(Ce=n.RG16UI),ee===n.UNSIGNED_INT&&(Ce=n.RG32UI),ee===n.BYTE&&(Ce=n.RG8I),ee===n.SHORT&&(Ce=n.RG16I),ee===n.INT&&(Ce=n.RG32I)),b===n.RGB_INTEGER&&(ee===n.UNSIGNED_BYTE&&(Ce=n.RGB8UI),ee===n.UNSIGNED_SHORT&&(Ce=n.RGB16UI),ee===n.UNSIGNED_INT&&(Ce=n.RGB32UI),ee===n.BYTE&&(Ce=n.RGB8I),ee===n.SHORT&&(Ce=n.RGB16I),ee===n.INT&&(Ce=n.RGB32I)),b===n.RGBA_INTEGER&&(ee===n.UNSIGNED_BYTE&&(Ce=n.RGBA8UI),ee===n.UNSIGNED_SHORT&&(Ce=n.RGBA16UI),ee===n.UNSIGNED_INT&&(Ce=n.RGBA32UI),ee===n.BYTE&&(Ce=n.RGBA8I),ee===n.SHORT&&(Ce=n.RGBA16I),ee===n.INT&&(Ce=n.RGBA32I)),b===n.RGB&&(ee===n.UNSIGNED_SHORT&&$e&&(Ce=$e.RGB16_EXT),ee===n.SHORT&&$e&&(Ce=$e.RGB16_SNORM_EXT),ee===n.UNSIGNED_INT_5_9_9_9_REV&&(Ce=n.RGB9_E5),ee===n.UNSIGNED_INT_10F_11F_11F_REV&&(Ce=n.R11F_G11F_B10F)),b===n.RGBA){let Ae=Ve?Ql:jn.getTransfer(Te);ee===n.FLOAT&&(Ce=n.RGBA32F),ee===n.HALF_FLOAT&&(Ce=n.RGBA16F),ee===n.UNSIGNED_BYTE&&(Ce=Ae===gi?n.SRGB8_ALPHA8:n.RGBA8),ee===n.UNSIGNED_SHORT&&$e&&(Ce=$e.RGBA16_EXT),ee===n.SHORT&&$e&&(Ce=$e.RGBA16_SNORM_EXT),ee===n.UNSIGNED_SHORT_4_4_4_4&&(Ce=n.RGBA4),ee===n.UNSIGNED_SHORT_5_5_5_1&&(Ce=n.RGB5_A1)}return(Ce===n.R16F||Ce===n.R32F||Ce===n.RG16F||Ce===n.RG32F||Ce===n.RGBA16F||Ce===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Ce}function N(Z,b){let ee;return Z?b===null||b===Ia||b===ml?ee=n.DEPTH24_STENCIL8:b===na?ee=n.DEPTH32F_STENCIL8:b===pl&&(ee=n.DEPTH24_STENCIL8,mn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===Ia||b===ml?ee=n.DEPTH_COMPONENT24:b===na?ee=n.DEPTH_COMPONENT32F:b===pl&&(ee=n.DEPTH_COMPONENT16),ee}function D(Z,b){return v(Z)===!0||Z.isFramebufferTexture&&Z.minFilter!==Ki&&Z.minFilter!==rr?Math.log2(Math.max(b.width,b.height))+1:Z.mipmaps!==void 0&&Z.mipmaps.length>0?Z.mipmaps.length:Z.isCompressedTexture&&Array.isArray(Z.image)?b.mipmaps.length:1}function B(Z){let b=Z.target;b.removeEventListener("dispose",B),A(b),b.isVideoTexture&&d.delete(b),b.isHTMLTexture&&f.delete(b)}function w(Z){let b=Z.target;b.removeEventListener("dispose",w),V(b)}function A(Z){let b=i.get(Z);if(b.__webglInit===void 0)return;let ee=Z.source,ve=m.get(ee);if(ve){let Te=ve[b.__cacheKey];Te.usedTimes--,Te.usedTimes===0&&z(Z),Object.keys(ve).length===0&&m.delete(ee)}i.remove(Z)}function z(Z){let b=i.get(Z);n.deleteTexture(b.__webglTexture);let ee=Z.source,ve=m.get(ee);delete ve[b.__cacheKey],s.memory.textures--}function V(Z){let b=i.get(Z);if(Z.depthTexture&&(Z.depthTexture.dispose(),i.remove(Z.depthTexture)),Z.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++){if(Array.isArray(b.__webglFramebuffer[ve]))for(let Te=0;Te<b.__webglFramebuffer[ve].length;Te++)n.deleteFramebuffer(b.__webglFramebuffer[ve][Te]);else n.deleteFramebuffer(b.__webglFramebuffer[ve]);b.__webglDepthbuffer&&n.deleteRenderbuffer(b.__webglDepthbuffer[ve])}else{if(Array.isArray(b.__webglFramebuffer))for(let ve=0;ve<b.__webglFramebuffer.length;ve++)n.deleteFramebuffer(b.__webglFramebuffer[ve]);else n.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&n.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&n.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let ve=0;ve<b.__webglColorRenderbuffer.length;ve++)b.__webglColorRenderbuffer[ve]&&n.deleteRenderbuffer(b.__webglColorRenderbuffer[ve]);b.__webglDepthRenderbuffer&&n.deleteRenderbuffer(b.__webglDepthRenderbuffer)}let ee=Z.textures;for(let ve=0,Te=ee.length;ve<Te;ve++){let Ve=i.get(ee[ve]);Ve.__webglTexture&&(n.deleteTexture(Ve.__webglTexture),s.memory.textures--),i.remove(ee[ve])}i.remove(Z)}let $=0;function T(){$=0}function S(){return $}function Y(Z){$=Z}function W(){let Z=$;return Z>=r.maxTextures&&mn("WebGLTextures: Trying to use "+(Z+1)+" texture units while this GPU supports only "+r.maxTextures),$+=1,Z}function se(Z){let b=[];return b.push(Z.wrapS),b.push(Z.wrapT),b.push(Z.wrapR||0),b.push(Z.magFilter),b.push(Z.minFilter),b.push(Z.anisotropy),b.push(Z.internalFormat),b.push(Z.format),b.push(Z.type),b.push(Z.generateMipmaps),b.push(Z.premultiplyAlpha),b.push(Z.flipY),b.push(Z.unpackAlignment),b.push(Z.colorSpace),b.join()}function O(Z,b){let ee=i.get(Z);if(Z.isVideoTexture&&ue(Z),Z.isRenderTargetTexture===!1&&Z.isExternalTexture!==!0&&Z.version>0&&ee.__version!==Z.version){let ve=Z.image;if(ve===null)mn("WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)mn("WebGLRenderer: Texture marked for update but image is incomplete");else{Me(ee,Z,b);return}}else Z.isExternalTexture&&(ee.__webglTexture=Z.sourceTexture?Z.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ee.__webglTexture,n.TEXTURE0+b)}function U(Z,b){let ee=i.get(Z);if(Z.isRenderTargetTexture===!1&&Z.version>0&&ee.__version!==Z.version){Me(ee,Z,b);return}else Z.isExternalTexture&&(ee.__webglTexture=Z.sourceTexture?Z.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ee.__webglTexture,n.TEXTURE0+b)}function H(Z,b){let ee=i.get(Z);if(Z.isRenderTargetTexture===!1&&Z.version>0&&ee.__version!==Z.version){Me(ee,Z,b);return}t.bindTexture(n.TEXTURE_3D,ee.__webglTexture,n.TEXTURE0+b)}function ne(Z,b){let ee=i.get(Z);if(Z.isCubeDepthTexture!==!0&&Z.version>0&&ee.__version!==Z.version){Le(ee,Z,b);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture,n.TEXTURE0+b)}let ce={[ws]:n.REPEAT,[fa]:n.CLAMP_TO_EDGE,[qo]:n.MIRRORED_REPEAT},pe={[Ki]:n.NEAREST,[Sd]:n.NEAREST_MIPMAP_NEAREST,[fo]:n.NEAREST_MIPMAP_LINEAR,[rr]:n.LINEAR,[hl]:n.LINEAR_MIPMAP_NEAREST,[Ha]:n.LINEAR_MIPMAP_LINEAR},le={[Jv]:n.NEVER,[e0]:n.ALWAYS,[$v]:n.LESS,[of]:n.LEQUAL,[Kv]:n.EQUAL,[lf]:n.GEQUAL,[Qv]:n.GREATER,[jv]:n.NOTEQUAL};function be(Z,b){if(b.type===na&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===rr||b.magFilter===hl||b.magFilter===fo||b.magFilter===Ha||b.minFilter===rr||b.minFilter===hl||b.minFilter===fo||b.minFilter===Ha)&&mn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(Z,n.TEXTURE_WRAP_S,ce[b.wrapS]),n.texParameteri(Z,n.TEXTURE_WRAP_T,ce[b.wrapT]),(Z===n.TEXTURE_3D||Z===n.TEXTURE_2D_ARRAY)&&n.texParameteri(Z,n.TEXTURE_WRAP_R,ce[b.wrapR]),n.texParameteri(Z,n.TEXTURE_MAG_FILTER,pe[b.magFilter]),n.texParameteri(Z,n.TEXTURE_MIN_FILTER,pe[b.minFilter]),b.compareFunction&&(n.texParameteri(Z,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(Z,n.TEXTURE_COMPARE_FUNC,le[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Ki||b.minFilter!==fo&&b.minFilter!==Ha||b.type===na&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||i.get(b).__currentAnisotropy){let ee=e.get("EXT_texture_filter_anisotropic");n.texParameterf(Z,ee.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,r.getMaxAnisotropy())),i.get(b).__currentAnisotropy=b.anisotropy}}}function Pe(Z,b){let ee=!1;Z.__webglInit===void 0&&(Z.__webglInit=!0,b.addEventListener("dispose",B));let ve=b.source,Te=m.get(ve);Te===void 0&&(Te={},m.set(ve,Te));let Ve=se(b);if(Ve!==Z.__cacheKey){Te[Ve]===void 0&&(Te[Ve]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ee=!0),Te[Ve].usedTimes++;let $e=Te[Z.__cacheKey];$e!==void 0&&(Te[Z.__cacheKey].usedTimes--,$e.usedTimes===0&&z(b)),Z.__cacheKey=Ve,Z.__webglTexture=Te[Ve].texture}return ee}function Q(Z,b,ee){return Math.floor(Math.floor(Z/ee)/b)}function ie(Z,b,ee,ve){let Ve=Z.updateRanges;if(Ve.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,b.width,b.height,ee,ve,b.data);else{Ve.sort((gt,ct)=>gt.start-ct.start);let $e=0;for(let gt=1;gt<Ve.length;gt++){let ct=Ve[$e],je=Ve[gt],Dt=ct.start+ct.count,qe=Q(je.start,b.width,4),Gt=Q(ct.start,b.width,4);je.start<=Dt+1&&qe===Gt&&Q(je.start+je.count-1,b.width,4)===qe?ct.count=Math.max(ct.count,je.start+je.count-ct.start):(++$e,Ve[$e]=je)}Ve.length=$e+1;let Ce=t.getParameter(n.UNPACK_ROW_LENGTH),Ae=t.getParameter(n.UNPACK_SKIP_PIXELS),nt=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,b.width);for(let gt=0,ct=Ve.length;gt<ct;gt++){let je=Ve[gt],Dt=Math.floor(je.start/4),qe=Math.ceil(je.count/4),Gt=Dt%b.width,oe=Math.floor(Dt/b.width),st=qe,Ne=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,Gt),t.pixelStorei(n.UNPACK_SKIP_ROWS,oe),t.texSubImage2D(n.TEXTURE_2D,0,Gt,oe,st,Ne,ee,ve,b.data)}Z.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,Ce),t.pixelStorei(n.UNPACK_SKIP_PIXELS,Ae),t.pixelStorei(n.UNPACK_SKIP_ROWS,nt)}}function Me(Z,b,ee){let ve=n.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(ve=n.TEXTURE_2D_ARRAY),b.isData3DTexture&&(ve=n.TEXTURE_3D);let Te=Pe(Z,b),Ve=b.source;t.bindTexture(ve,Z.__webglTexture,n.TEXTURE0+ee);let $e=i.get(Ve);if(Ve.version!==$e.__version||Te===!0){if(t.activeTexture(n.TEXTURE0+ee),(typeof ImageBitmap<"u"&&b.image instanceof ImageBitmap)===!1){let Ne=jn.getPrimaries(jn.workingColorSpace),ft=b.colorSpace===Nr?null:jn.getPrimaries(b.colorSpace),ht=b.colorSpace===Nr||Ne===ft?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ht)}t.pixelStorei(n.UNPACK_ALIGNMENT,b.unpackAlignment);let Ae=g(b.image,!1,r.maxTextureSize);Ae=ln(b,Ae);let nt=a.convert(b.format,b.colorSpace),gt=a.convert(b.type),ct=_(b.internalFormat,nt,gt,b.normalized,b.colorSpace,b.isVideoTexture);be(ve,b);let je,Dt=b.mipmaps,qe=b.isVideoTexture!==!0,Gt=$e.__version===void 0||Te===!0,oe=Ve.dataReady,st=D(b,Ae);if(b.isDepthTexture)ct=N(b.format===Ps,b.type),Gt&&(qe?t.texStorage2D(n.TEXTURE_2D,1,ct,Ae.width,Ae.height):t.texImage2D(n.TEXTURE_2D,0,ct,Ae.width,Ae.height,0,nt,gt,null));else if(b.isDataTexture)if(Dt.length>0){qe&&Gt&&t.texStorage2D(n.TEXTURE_2D,st,ct,Dt[0].width,Dt[0].height);for(let Ne=0,ft=Dt.length;Ne<ft;Ne++)je=Dt[Ne],qe?oe&&t.texSubImage2D(n.TEXTURE_2D,Ne,0,0,je.width,je.height,nt,gt,je.data):t.texImage2D(n.TEXTURE_2D,Ne,ct,je.width,je.height,0,nt,gt,je.data);b.generateMipmaps=!1}else qe?(Gt&&t.texStorage2D(n.TEXTURE_2D,st,ct,Ae.width,Ae.height),oe&&ie(b,Ae,nt,gt)):t.texImage2D(n.TEXTURE_2D,0,ct,Ae.width,Ae.height,0,nt,gt,Ae.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){qe&&Gt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,st,ct,Dt[0].width,Dt[0].height,Ae.depth);for(let Ne=0,ft=Dt.length;Ne<ft;Ne++)if(je=Dt[Ne],b.format!==ia)if(nt!==null)if(qe){if(oe)if(b.layerUpdates.size>0){let ht=dp(je.width,je.height,b.format,b.type);for(let ze of b.layerUpdates){let Ot=je.data.subarray(ze*ht/je.data.BYTES_PER_ELEMENT,(ze+1)*ht/je.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ne,0,0,ze,je.width,je.height,1,nt,Ot)}}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ne,0,0,0,je.width,je.height,Ae.depth,nt,je.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Ne,ct,je.width,je.height,Ae.depth,0,je.data,0,0);else mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else qe?oe&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Ne,0,0,0,je.width,je.height,Ae.depth,nt,gt,je.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Ne,ct,je.width,je.height,Ae.depth,0,nt,gt,je.data);b.layerUpdates.size>0&&b.clearLayerUpdates()}else{qe&&Gt&&t.texStorage2D(n.TEXTURE_2D,st,ct,Dt[0].width,Dt[0].height);for(let Ne=0,ft=Dt.length;Ne<ft;Ne++)je=Dt[Ne],b.format!==ia?nt!==null?qe?oe&&t.compressedTexSubImage2D(n.TEXTURE_2D,Ne,0,0,je.width,je.height,nt,je.data):t.compressedTexImage2D(n.TEXTURE_2D,Ne,ct,je.width,je.height,0,je.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qe?oe&&t.texSubImage2D(n.TEXTURE_2D,Ne,0,0,je.width,je.height,nt,gt,je.data):t.texImage2D(n.TEXTURE_2D,Ne,ct,je.width,je.height,0,nt,gt,je.data)}else if(b.isDataArrayTexture)if(qe){if(Gt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,st,ct,Ae.width,Ae.height,Ae.depth),oe)if(b.layerUpdates.size>0){let Ne=dp(Ae.width,Ae.height,b.format,b.type);for(let ft of b.layerUpdates){let ht=Ae.data.subarray(ft*Ne/Ae.data.BYTES_PER_ELEMENT,(ft+1)*Ne/Ae.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ft,Ae.width,Ae.height,1,nt,gt,ht)}b.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ae.width,Ae.height,Ae.depth,nt,gt,Ae.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ct,Ae.width,Ae.height,Ae.depth,0,nt,gt,Ae.data);else if(b.isData3DTexture)qe?(Gt&&t.texStorage3D(n.TEXTURE_3D,st,ct,Ae.width,Ae.height,Ae.depth),oe&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ae.width,Ae.height,Ae.depth,nt,gt,Ae.data)):t.texImage3D(n.TEXTURE_3D,0,ct,Ae.width,Ae.height,Ae.depth,0,nt,gt,Ae.data);else if(b.isFramebufferTexture){if(Gt)if(qe)t.texStorage2D(n.TEXTURE_2D,st,ct,Ae.width,Ae.height);else{let Ne=Ae.width,ft=Ae.height;for(let ht=0;ht<st;ht++)t.texImage2D(n.TEXTURE_2D,ht,ct,Ne,ft,0,nt,gt,null),Ne>>=1,ft>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in n){let Ne=n.canvas;if(Ne.hasAttribute("layoutsubtree")||Ne.setAttribute("layoutsubtree","true"),Ae.parentNode!==Ne){Ne.appendChild(Ae),f.add(b),Ne.onpaint=ft=>{let ht=ft.changedElements;for(let ze of f)ht.includes(ze.image)&&(ze.needsUpdate=!0)},Ne.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Ae);else{let ht=n.RGBA,ze=n.RGBA,Ot=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,ht,ze,Ot,Ae)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(Dt.length>0){if(qe&&Gt){let Ne=on(Dt[0]);t.texStorage2D(n.TEXTURE_2D,st,ct,Ne.width,Ne.height)}for(let Ne=0,ft=Dt.length;Ne<ft;Ne++)je=Dt[Ne],qe?oe&&t.texSubImage2D(n.TEXTURE_2D,Ne,0,0,nt,gt,je):t.texImage2D(n.TEXTURE_2D,Ne,ct,nt,gt,je);b.generateMipmaps=!1}else if(qe){if(Gt){let Ne=on(Ae);t.texStorage2D(n.TEXTURE_2D,st,ct,Ne.width,Ne.height)}oe&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,nt,gt,Ae)}else t.texImage2D(n.TEXTURE_2D,0,ct,nt,gt,Ae);v(b)&&P(ve),$e.__version=Ve.version,b.onUpdate&&b.onUpdate(b)}Z.__version=b.version}function Le(Z,b,ee){if(b.image.length!==6)return;let ve=Pe(Z,b),Te=b.source;t.bindTexture(n.TEXTURE_CUBE_MAP,Z.__webglTexture,n.TEXTURE0+ee);let Ve=i.get(Te);if(Te.version!==Ve.__version||ve===!0){t.activeTexture(n.TEXTURE0+ee);let $e=jn.getPrimaries(jn.workingColorSpace),Ce=b.colorSpace===Nr?null:jn.getPrimaries(b.colorSpace),Ae=b.colorSpace===Nr||$e===Ce?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,b.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae);let nt=b.isCompressedTexture||b.image[0].isCompressedTexture,gt=b.image[0]&&b.image[0].isDataTexture,ct=[];for(let ze=0;ze<6;ze++)!nt&&!gt?ct[ze]=g(b.image[ze],!0,r.maxCubemapSize):ct[ze]=gt?b.image[ze].image:b.image[ze],ct[ze]=ln(b,ct[ze]);let je=ct[0],Dt=a.convert(b.format,b.colorSpace),qe=a.convert(b.type),Gt=_(b.internalFormat,Dt,qe,b.normalized,b.colorSpace),oe=b.isVideoTexture!==!0,st=Ve.__version===void 0||ve===!0,Ne=Te.dataReady,ft=D(b,je);be(n.TEXTURE_CUBE_MAP,b);let ht;if(nt){oe&&st&&t.texStorage2D(n.TEXTURE_CUBE_MAP,ft,Gt,je.width,je.height);for(let ze=0;ze<6;ze++){ht=ct[ze].mipmaps;for(let Ot=0;Ot<ht.length;Ot++){let Tt=ht[Ot];b.format!==ia?Dt!==null?oe?Ne&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot,0,0,Tt.width,Tt.height,Dt,Tt.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot,Gt,Tt.width,Tt.height,0,Tt.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):oe?Ne&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot,0,0,Tt.width,Tt.height,Dt,qe,Tt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot,Gt,Tt.width,Tt.height,0,Dt,qe,Tt.data)}}}else{if(ht=b.mipmaps,oe&&st){ht.length>0&&ft++;let ze=on(ct[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ft,Gt,ze.width,ze.height)}for(let ze=0;ze<6;ze++)if(gt){oe?Ne&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0,0,0,ct[ze].width,ct[ze].height,Dt,qe,ct[ze].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0,Gt,ct[ze].width,ct[ze].height,0,Dt,qe,ct[ze].data);for(let Ot=0;Ot<ht.length;Ot++){let _t=ht[Ot].image[ze].image;oe?Ne&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot+1,0,0,_t.width,_t.height,Dt,qe,_t.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot+1,Gt,_t.width,_t.height,0,Dt,qe,_t.data)}}else{oe?Ne&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0,0,0,Dt,qe,ct[ze]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0,Gt,Dt,qe,ct[ze]);for(let Ot=0;Ot<ht.length;Ot++){let Tt=ht[Ot];oe?Ne&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot+1,0,0,Dt,qe,Tt.image[ze]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ot+1,Gt,Dt,qe,Tt.image[ze])}}}v(b)&&P(n.TEXTURE_CUBE_MAP),Ve.__version=Te.version,b.onUpdate&&b.onUpdate(b)}Z.__version=b.version}function Ee(Z,b,ee,ve,Te,Ve){let $e=a.convert(ee.format,ee.colorSpace),Ce=a.convert(ee.type),Ae=_(ee.internalFormat,$e,Ce,ee.normalized,ee.colorSpace),nt=i.get(b),gt=i.get(ee);if(gt.__renderTarget=b,!nt.__hasExternalTextures){let ct=Math.max(1,b.width>>Ve),je=Math.max(1,b.height>>Ve);Te===n.TEXTURE_3D||Te===n.TEXTURE_2D_ARRAY?t.texImage3D(Te,Ve,Ae,ct,je,b.depth,0,$e,Ce,null):t.texImage2D(Te,Ve,Ae,ct,je,0,$e,Ce,null)}t.bindFramebuffer(n.FRAMEBUFFER,Z),tn(b)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ve,Te,gt.__webglTexture,0,Pt(b)):(Te===n.TEXTURE_2D||Te>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Te<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ve,Te,gt.__webglTexture,Ve),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Xe(Z,b,ee){if(n.bindRenderbuffer(n.RENDERBUFFER,Z),b.depthBuffer){let ve=b.depthTexture,Te=ve&&ve.isDepthTexture?ve.type:null,Ve=N(b.stencilBuffer,Te),$e=b.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;tn(b)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Pt(b),Ve,b.width,b.height):ee?n.renderbufferStorageMultisample(n.RENDERBUFFER,Pt(b),Ve,b.width,b.height):n.renderbufferStorage(n.RENDERBUFFER,Ve,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,$e,n.RENDERBUFFER,Z)}else{let ve=b.textures;for(let Te=0;Te<ve.length;Te++){let Ve=ve[Te],$e=a.convert(Ve.format,Ve.colorSpace),Ce=a.convert(Ve.type),Ae=_(Ve.internalFormat,$e,Ce,Ve.normalized,Ve.colorSpace);tn(b)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Pt(b),Ae,b.width,b.height):ee?n.renderbufferStorageMultisample(n.RENDERBUFFER,Pt(b),Ae,b.width,b.height):n.renderbufferStorage(n.RENDERBUFFER,Ae,b.width,b.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function tt(Z,b,ee){let ve=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,Z),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let Te=i.get(b.depthTexture);if(Te.__renderTarget=b,(!Te.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),ve){if(Te.__webglInit===void 0&&(Te.__webglInit=!0,b.depthTexture.addEventListener("dispose",B)),Te.__webglTexture===void 0){Te.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,Te.__webglTexture),be(n.TEXTURE_CUBE_MAP,b.depthTexture);let nt=a.convert(b.depthTexture.format),gt=a.convert(b.depthTexture.type),ct;b.depthTexture.format===Ba?ct=n.DEPTH_COMPONENT24:b.depthTexture.format===Ps&&(ct=n.DEPTH24_STENCIL8);for(let je=0;je<6;je++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,ct,b.width,b.height,0,nt,gt,null)}}else O(b.depthTexture,0);let Ve=Te.__webglTexture,$e=Pt(b),Ce=ve?n.TEXTURE_CUBE_MAP_POSITIVE_X+ee:n.TEXTURE_2D,Ae=b.depthTexture.format===Ps?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(b.depthTexture.format===Ba)tn(b)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ae,Ce,Ve,0,$e):n.framebufferTexture2D(n.FRAMEBUFFER,Ae,Ce,Ve,0);else if(b.depthTexture.format===Ps)tn(b)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ae,Ce,Ve,0,$e):n.framebufferTexture2D(n.FRAMEBUFFER,Ae,Ce,Ve,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ge(Z){let b=i.get(Z),ee=Z.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==Z.depthTexture){let ve=Z.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),ve){let Te=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,ve.removeEventListener("dispose",Te)};ve.addEventListener("dispose",Te),b.__depthDisposeCallback=Te}b.__boundDepthTexture=ve}if(Z.depthTexture&&!b.__autoAllocateDepthBuffer)if(ee)for(let ve=0;ve<6;ve++)tt(b.__webglFramebuffer[ve],Z,ve);else{let ve=Z.texture.mipmaps;ve&&ve.length>0?tt(b.__webglFramebuffer[0],Z,0):tt(b.__webglFramebuffer,Z,0)}else if(ee){b.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)if(t.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer[ve]),b.__webglDepthbuffer[ve]===void 0)b.__webglDepthbuffer[ve]=n.createRenderbuffer(),Xe(b.__webglDepthbuffer[ve],Z,!1);else{let Te=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ve=b.__webglDepthbuffer[ve];n.bindRenderbuffer(n.RENDERBUFFER,Ve),n.framebufferRenderbuffer(n.FRAMEBUFFER,Te,n.RENDERBUFFER,Ve)}}else{let ve=Z.texture.mipmaps;if(ve&&ve.length>0?t.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=n.createRenderbuffer(),Xe(b.__webglDepthbuffer,Z,!1);else{let Te=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ve=b.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,Ve),n.framebufferRenderbuffer(n.FRAMEBUFFER,Te,n.RENDERBUFFER,Ve)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ye(Z,b,ee){let ve=i.get(Z);b!==void 0&&Ee(ve.__webglFramebuffer,Z,Z.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ee!==void 0&&Ge(Z)}function dt(Z){let b=Z.texture,ee=i.get(Z),ve=i.get(b);Z.addEventListener("dispose",w);let Te=Z.textures,Ve=Z.isWebGLCubeRenderTarget===!0,$e=Te.length>1;if($e||(ve.__webglTexture===void 0&&(ve.__webglTexture=n.createTexture()),ve.__version=b.version,s.memory.textures++),Ve){ee.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)if(b.mipmaps&&b.mipmaps.length>0){ee.__webglFramebuffer[Ce]=[];for(let Ae=0;Ae<b.mipmaps.length;Ae++)ee.__webglFramebuffer[Ce][Ae]=n.createFramebuffer()}else ee.__webglFramebuffer[Ce]=n.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){ee.__webglFramebuffer=[];for(let Ce=0;Ce<b.mipmaps.length;Ce++)ee.__webglFramebuffer[Ce]=n.createFramebuffer()}else ee.__webglFramebuffer=n.createFramebuffer();if($e)for(let Ce=0,Ae=Te.length;Ce<Ae;Ce++){let nt=i.get(Te[Ce]);nt.__webglTexture===void 0&&(nt.__webglTexture=n.createTexture(),s.memory.textures++)}if(Z.samples>0&&tn(Z)===!1){ee.__webglMultisampledFramebuffer=n.createFramebuffer(),ee.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let Ce=0;Ce<Te.length;Ce++){let Ae=Te[Ce];ee.__webglColorRenderbuffer[Ce]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ee.__webglColorRenderbuffer[Ce]);let nt=a.convert(Ae.format,Ae.colorSpace),gt=a.convert(Ae.type),ct=_(Ae.internalFormat,nt,gt,Ae.normalized,Ae.colorSpace,Z.isXRRenderTarget===!0),je=Pt(Z);n.renderbufferStorageMultisample(n.RENDERBUFFER,je,ct,Z.width,Z.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ce,n.RENDERBUFFER,ee.__webglColorRenderbuffer[Ce])}n.bindRenderbuffer(n.RENDERBUFFER,null),Z.depthBuffer&&(ee.__webglDepthRenderbuffer=n.createRenderbuffer(),Xe(ee.__webglDepthRenderbuffer,Z,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(Ve){t.bindTexture(n.TEXTURE_CUBE_MAP,ve.__webglTexture),be(n.TEXTURE_CUBE_MAP,b);for(let Ce=0;Ce<6;Ce++)if(b.mipmaps&&b.mipmaps.length>0)for(let Ae=0;Ae<b.mipmaps.length;Ae++)Ee(ee.__webglFramebuffer[Ce][Ae],Z,b,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Ae);else Ee(ee.__webglFramebuffer[Ce],Z,b,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0);v(b)&&P(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if($e){for(let Ce=0,Ae=Te.length;Ce<Ae;Ce++){let nt=Te[Ce],gt=i.get(nt),ct=n.TEXTURE_2D;(Z.isWebGL3DRenderTarget||Z.isWebGLArrayRenderTarget)&&(ct=Z.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ct,gt.__webglTexture),be(ct,nt),Ee(ee.__webglFramebuffer,Z,nt,n.COLOR_ATTACHMENT0+Ce,ct,0),v(nt)&&P(ct)}t.unbindTexture()}else{let Ce=n.TEXTURE_2D;if((Z.isWebGL3DRenderTarget||Z.isWebGLArrayRenderTarget)&&(Ce=Z.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ce,ve.__webglTexture),be(Ce,b),b.mipmaps&&b.mipmaps.length>0)for(let Ae=0;Ae<b.mipmaps.length;Ae++)Ee(ee.__webglFramebuffer[Ae],Z,b,n.COLOR_ATTACHMENT0,Ce,Ae);else Ee(ee.__webglFramebuffer,Z,b,n.COLOR_ATTACHMENT0,Ce,0);v(b)&&P(Ce),t.unbindTexture()}Z.depthBuffer&&Ge(Z)}function ke(Z){let b=Z.textures;for(let ee=0,ve=b.length;ee<ve;ee++){let Te=b[ee];if(v(Te)){let Ve=p(Z),$e=i.get(Te).__webglTexture;t.bindTexture(Ve,$e),P(Ve),t.unbindTexture()}}}let at=[],Ke=[];function jt(Z){if(Z.samples>0){if(tn(Z)===!1){let b=Z.textures,ee=Z.width,ve=Z.height,Te=n.COLOR_BUFFER_BIT,Ve=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,$e=i.get(Z),Ce=b.length>1;if(Ce)for(let nt=0;nt<b.length;nt++)t.bindFramebuffer(n.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,$e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,$e.__webglMultisampledFramebuffer);let Ae=Z.texture.mipmaps;Ae&&Ae.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,$e.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,$e.__webglFramebuffer);for(let nt=0;nt<b.length;nt++){if(Z.resolveDepthBuffer&&(Z.depthBuffer&&(Te|=n.DEPTH_BUFFER_BIT),Z.stencilBuffer&&Z.resolveStencilBuffer&&(Te|=n.STENCIL_BUFFER_BIT)),Ce){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,$e.__webglColorRenderbuffer[nt]);let gt=i.get(b[nt]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,gt,0)}n.blitFramebuffer(0,0,ee,ve,0,0,ee,ve,Te,n.NEAREST),u===!0&&(at.length=0,Ke.length=0,at.push(n.COLOR_ATTACHMENT0+nt),Z.depthBuffer&&Z.storeMultisampledDepthBuffer===!1&&(at.push(Ve),Ke.push(Ve),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ke)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,at))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ce)for(let nt=0;nt<b.length;nt++){t.bindFramebuffer(n.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.RENDERBUFFER,$e.__webglColorRenderbuffer[nt]);let gt=i.get(b[nt]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,$e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.TEXTURE_2D,gt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,$e.__webglMultisampledFramebuffer)}else if(Z.depthBuffer&&Z.storeMultisampledDepthBuffer===!1&&u){let b=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[b])}}}function Pt(Z){return Math.min(r.maxSamples,Z.samples)}function tn(Z){let b=i.get(Z);return Z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function ue(Z){let b=s.render.frame;d.get(Z)!==b&&(d.set(Z,b),Z.update())}function ln(Z,b){let ee=Z.colorSpace,ve=Z.format,Te=Z.type;return Z.isCompressedTexture===!0||Z.isVideoTexture===!0||ee!==Kl&&ee!==Nr&&(jn.getTransfer(ee)===gi?(ve!==ia||Te!==Hr)&&mn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Tn("WebGLTextures: Unsupported texture color space:",ee)),b}function on(Z){return typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement?(l.width=Z.naturalWidth||Z.width,l.height=Z.naturalHeight||Z.height):typeof VideoFrame<"u"&&Z instanceof VideoFrame?(l.width=Z.displayWidth,l.height=Z.displayHeight):(l.width=Z.width,l.height=Z.height),l}this.allocateTextureUnit=W,this.resetTextureUnits=T,this.getTextureUnits=S,this.setTextureUnits=Y,this.setTexture2D=O,this.setTexture2DArray=U,this.setTexture3D=H,this.setTextureCube=ne,this.rebindTextures=Ye,this.setupRenderTarget=dt,this.updateRenderTargetMipmap=ke,this.updateMultisampleRenderTarget=jt,this.setupDepthRenderbuffer=Ge,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=tn,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function ow(n,e){function t(i,r=Nr){let a,s=jn.getTransfer(r);if(i===Hr)return n.UNSIGNED_BYTE;if(i===wd)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Td)return n.UNSIGNED_SHORT_5_5_5_1;if(i===tp)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===np)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===jh)return n.BYTE;if(i===ep)return n.SHORT;if(i===pl)return n.UNSIGNED_SHORT;if(i===bd)return n.INT;if(i===Ia)return n.UNSIGNED_INT;if(i===na)return n.FLOAT;if(i===Ca)return n.HALF_FLOAT;if(i===ip)return n.ALPHA;if(i===rp)return n.RGB;if(i===ia)return n.RGBA;if(i===Ba)return n.DEPTH_COMPONENT;if(i===Ps)return n.DEPTH_STENCIL;if(i===Ed)return n.RED;if(i===Ad)return n.RED_INTEGER;if(i===Ls)return n.RG;if(i===Id)return n.RG_INTEGER;if(i===Cd)return n.RGBA_INTEGER;if(i===Ac||i===Ic||i===Cc||i===Rc)if(s===gi)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Ac)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Ic)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Cc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Rc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Ac)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ic)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Cc)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Rc)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Rd||i===Pd||i===Ld||i===Dd)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===Rd)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Pd)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ld)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Dd)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Nd||i===Ud||i===Fd||i===Od||i===Bd||i===Pc||i===kd)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===Nd||i===Ud)return s===gi?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Fd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(i===Od)return a.COMPRESSED_R11_EAC;if(i===Bd)return a.COMPRESSED_SIGNED_R11_EAC;if(i===Pc)return a.COMPRESSED_RG11_EAC;if(i===kd)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===zd||i===Vd||i===Gd||i===Hd||i===Wd||i===Xd||i===Yd||i===qd||i===Zd||i===Jd||i===$d||i===Kd||i===Qd||i===jd)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===zd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Vd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Gd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Hd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Wd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Xd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Yd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===qd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Zd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Jd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===$d)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Kd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Qd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===jd)return s===gi?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ef||i===tf||i===nf)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===ef)return s===gi?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===tf)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===nf)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===rf||i===af||i===Lc||i===sf)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===rf)return a.COMPRESSED_RED_RGTC1_EXT;if(i===af)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Lc)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===sf)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===ml?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}var lw=`
|
|
4196
|
+
}`,Tw=[new xe(1,0,0),new xe(-1,0,0),new xe(0,1,0),new xe(0,-1,0),new xe(0,0,1),new xe(0,0,-1)],Aw=[new xe(0,-1,0),new xe(0,-1,0),new xe(0,0,1),new xe(0,0,-1),new xe(0,-1,0),new xe(0,-1,0)],j0=new Kn,Bc=new xe,Up=new xe;function Ew(n,e,t){let i=new nl,r=new tn,a=new tn,s=new Ni,o=new ud,u=new dd,l={},d=t.maxTextureSize,f={[$a]:Kr,[Kr]:$a,[Br]:Br},h=new pa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new tn},radius:{value:4}},vertexShader:bw,fragmentShader:ww}),m=h.clone();m.defines.HORIZONTAL_PASS=1;let y=new ur;y.setAttribute("position",new Or(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let M=new _i(y,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ac;let v=this.type;this.render=function(D,V,w){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||D.length===0)return;this.type===Ad&&(En("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ac);let I=n.getRenderTarget(),G=n.getActiveCubeFace(),H=n.getActiveMipmapLevel(),Q=n.state;Q.setBlending(Ka),Q.buffers.depth.getReversed()===!0?Q.buffers.color.setClear(0,0,0,0):Q.buffers.color.setClear(1,1,1,1),Q.buffers.depth.setTest(!0),Q.setScissorTest(!1);let T=v!==this.type;T&&V.traverse(function(S){S.material&&(Array.isArray(S.material)?S.material.forEach(Z=>Z.needsUpdate=!0):S.material.needsUpdate=!0)});for(let S=0,Z=D.length;S<Z;S++){let q=D[S],se=q.shadow;if(se===void 0){En("WebGLShadowMap:",q,"has no shadow.");continue}if(se.autoUpdate===!1&&se.needsUpdate===!1)continue;r.copy(se.mapSize);let F=se.getFrameExtents();r.multiply(F),a.copy(se.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/F.x),r.x=a.x*F.x,se.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/F.y),r.y=a.y*F.y,se.mapSize.y=a.y));let z=n.state.buffers.depth.getReversed();if(se.camera._reversedDepth=z,se.map===null||T===!0){if(se.map!==null&&(se.map.depthTexture!==null&&(se.map.depthTexture.dispose(),se.map.depthTexture=null),se.map.dispose()),this.type===ul){if(q.isPointLight){En("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}se.map=new aa(r.x,r.y,{format:Ws,type:Fa,minFilter:lr,magFilter:lr,generateMipmaps:!1}),se.map.texture.name=q.name+".shadowMap",se.map.depthTexture=new Bs(r.x,r.y,va),se.map.depthTexture.name=q.name+".shadowMapDepth",se.map.depthTexture.format=qa,se.map.depthTexture.compareFunction=null,se.map.depthTexture.minFilter=ir,se.map.depthTexture.magFilter=ir}else q.isPointLight?(se.map=new yf(r.x),se.map.depthTexture=new nd(r.x,Ua)):(se.map=new aa(r.x,r.y),se.map.depthTexture=new Bs(r.x,r.y,Ua)),se.map.depthTexture.name=q.name+".shadowMap",se.map.depthTexture.format=qa,this.type===Ac?(se.map.depthTexture.compareFunction=z?mf:pf,se.map.depthTexture.minFilter=lr,se.map.depthTexture.magFilter=lr):(se.map.depthTexture.compareFunction=null,se.map.depthTexture.minFilter=ir,se.map.depthTexture.magFilter=ir);se.camera.updateProjectionMatrix()}se.map.isWebGLCubeRenderTarget!==!0&&(se.map.width!==r.x||se.map.height!==r.y)&&se.map.setSize(r.x,r.y);let Y=se.map.isWebGLCubeRenderTarget?6:se.getViewportCount();q.isPointLight!==!0&&se.updateMatrices(q,w);for(let $=0;$<Y;$++){let he=se.getCamera($);if(q.isPointLight){let pe=se.camera,le=se.matrix,Te=q.distance||pe.far;Te!==pe.far&&(pe.far=Te,pe.updateProjectionMatrix()),Bc.setFromMatrixPosition(q.matrixWorld),pe.position.copy(Bc),Up.copy(pe.position),Up.add(Tw[$]),pe.up.copy(Aw[$]),pe.lookAt(Up),pe.updateMatrixWorld(),le.makeTranslation(-Bc.x,-Bc.y,-Bc.z),j0.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),se._frustum.setFromProjectionMatrix(j0,pe.coordinateSystem,pe.reversedDepth)}if(se.map.isWebGLCubeRenderTarget)n.setRenderTarget(se.map,$),n.clear();else{$===0&&(n.setRenderTarget(se.map),n.clear());let pe=se.getViewport($);s.set(a.x*pe.x,a.y*pe.y,a.x*pe.z,a.y*pe.w),Q.viewport(s)}i=se.getFrustum($),_(V,w,he,q,this.type)}se.isPointLightShadow!==!0&&this.type===ul&&L(se,w),se.needsUpdate=!1}v=this.type,g.needsUpdate=!1,n.setRenderTarget(I,G,H)};function L(D,V){let w=e.update(M);h.defines.VSM_SAMPLES!==D.blurSamples&&(h.defines.VSM_SAMPLES=D.blurSamples,m.defines.VSM_SAMPLES=D.blurSamples,h.needsUpdate=!0,m.needsUpdate=!0),D.mapPass===null?D.mapPass=new aa(r.x,r.y,{format:Ws,type:Fa}):(D.mapPass.width!==D.map.width||D.mapPass.height!==D.map.height)&&D.mapPass.setSize(D.map.width,D.map.height),h.uniforms.shadow_pass.value=D.map.depthTexture,h.uniforms.resolution.value.set(D.map.width,D.map.height),h.uniforms.radius.value=D.radius,n.setRenderTarget(D.mapPass),n.clear(),n.renderBufferDirect(V,null,w,h,M,null),m.uniforms.shadow_pass.value=D.mapPass.texture,m.uniforms.resolution.value.set(D.map.width,D.map.height),m.uniforms.radius.value=D.radius,n.setRenderTarget(D.map),n.clear(),n.renderBufferDirect(V,null,w,m,M,null)}function p(D,V,w,I){let G=null,H=w.isPointLight===!0?D.customDistanceMaterial:D.customDepthMaterial;if(H!==void 0)G=H;else if(G=w.isPointLight===!0?u:o,n.localClippingEnabled&&V.clipShadows===!0&&Array.isArray(V.clippingPlanes)&&V.clippingPlanes.length!==0||V.displacementMap&&V.displacementScale!==0||V.alphaMap&&V.alphaTest>0||V.map&&V.alphaTest>0||V.alphaToCoverage===!0){let Q=G.uuid,T=V.uuid,S=l[Q];S===void 0&&(S={},l[Q]=S);let Z=S[T];Z===void 0&&(Z=G.clone(),S[T]=Z,V.addEventListener("dispose",N)),G=Z}if(G.visible=V.visible,G.wireframe=V.wireframe,I===ul?G.side=V.shadowSide!==null?V.shadowSide:V.side:G.side=V.shadowSide!==null?V.shadowSide:f[V.side],G.alphaMap=V.alphaMap,G.alphaTest=V.alphaToCoverage===!0?.5:V.alphaTest,G.map=V.map,G.clipShadows=V.clipShadows,G.clippingPlanes=V.clippingPlanes,G.clipIntersection=V.clipIntersection,G.displacementMap=V.displacementMap,G.displacementScale=V.displacementScale,G.displacementBias=V.displacementBias,G.wireframeLinewidth=V.wireframeLinewidth,G.linewidth=V.linewidth,w.isPointLight===!0&&G.isMeshDistanceMaterial===!0){let Q=n.properties.get(G);Q.light=w}return G}function _(D,V,w,I,G){if(D.visible===!1)return;if(D.layers.test(V.layers)&&(D.isMesh||D.isLine||D.isPoints)&&(D.castShadow||D.receiveShadow&&G===ul)&&(!D.frustumCulled||D.intersectsFrustum(i))){D.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,D.matrixWorld);let T=e.update(D),S=D.material;if(Array.isArray(S)){let Z=T.groups;for(let q=0,se=Z.length;q<se;q++){let F=Z[q],z=S[F.materialIndex];if(z&&z.visible){let Y=p(D,z,I,G);D.onBeforeShadow(n,D,V,w,T,Y,F),n.renderBufferDirect(w,null,T,Y,D,F),D.onAfterShadow(n,D,V,w,T,Y,F)}}}else if(S.visible){let Z=p(D,S,I,G);D.onBeforeShadow(n,D,V,w,T,Z,null),n.renderBufferDirect(w,null,T,Z,D,null),D.onAfterShadow(n,D,V,w,T,Z,null)}}let Q=D.children;for(let T=0,S=Q.length;T<S;T++)_(Q[T],V,w,I,G)}function N(D){D.target.removeEventListener("dispose",N);for(let w in l){let I=l[w],G=D.target.uuid;G in I&&(I[G].dispose(),delete I[G])}}}function Iw(n,e){function t(){let fe=!1,We=new Ni,ze=null,ht=new Ni(0,0,0,0);return{setMask:function(St){ze!==St&&!fe&&(n.colorMask(St,St,St,St),ze=St)},setLocked:function(St){fe=St},setClear:function(St,He,qt,Tt,pt){pt===!0&&(St*=Tt,He*=Tt,qt*=Tt),We.set(St,He,qt,Tt),ht.equals(We)===!1&&(n.clearColor(St,He,qt,Tt),ht.copy(We))},reset:function(){fe=!1,ze=null,ht.set(-1,0,0,0)}}}function i(){let fe=!1,We=!1,ze=null,ht=null,St=null;return{setReversed:function(He){if(We!==He){let qt=e.get("EXT_clip_control");He?qt.clipControlEXT(qt.LOWER_LEFT_EXT,qt.ZERO_TO_ONE_EXT):qt.clipControlEXT(qt.LOWER_LEFT_EXT,qt.NEGATIVE_ONE_TO_ONE_EXT),We=He;let Tt=St;St=null,this.setClear(Tt)}},getReversed:function(){return We},setTest:function(He){He?ee(n.DEPTH_TEST):be(n.DEPTH_TEST)},setMask:function(He){ze!==He&&!fe&&(n.depthMask(He),ze=He)},setFunc:function(He){if(We&&(He=w0[He]),ht!==He){switch(He){case Wu:n.depthFunc(n.NEVER);break;case Xu:n.depthFunc(n.ALWAYS);break;case Yu:n.depthFunc(n.LESS);break;case Yo:n.depthFunc(n.LEQUAL);break;case qu:n.depthFunc(n.EQUAL);break;case Zu:n.depthFunc(n.GEQUAL);break;case Ju:n.depthFunc(n.GREATER);break;case $u:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ht=He}},setLocked:function(He){fe=He},setClear:function(He){St!==He&&(St=He,We&&(He=1-He),n.clearDepth(He))},reset:function(){fe=!1,ze=null,ht=null,St=null,We=!1}}}function r(){let fe=!1,We=null,ze=null,ht=null,St=null,He=null,qt=null,Tt=null,pt=null;return{setTest:function(Lt){fe||(Lt?ee(n.STENCIL_TEST):be(n.STENCIL_TEST))},setMask:function(Lt){We!==Lt&&!fe&&(n.stencilMask(Lt),We=Lt)},setFunc:function(Lt,et,Pt){(ze!==Lt||ht!==et||St!==Pt)&&(n.stencilFunc(Lt,et,Pt),ze=Lt,ht=et,St=Pt)},setOp:function(Lt,et,Pt){(He!==Lt||qt!==et||Tt!==Pt)&&(n.stencilOp(Lt,et,Pt),He=Lt,qt=et,Tt=Pt)},setLocked:function(Lt){fe=Lt},setClear:function(Lt){pt!==Lt&&(n.clearStencil(Lt),pt=Lt)},reset:function(){fe=!1,We=null,ze=null,ht=null,St=null,He=null,qt=null,Tt=null,pt=null}}}let a=new t,s=new i,o=new r,u=new WeakMap,l=new WeakMap,d={},f={},h={},m=new WeakMap,y=[],M=null,g=!1,v=null,L=null,p=null,_=null,N=null,D=null,V=null,w=new zn(0,0,0),I=0,G=!1,H=null,Q=null,T=null,S=null,Z=null,q=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),se=!1,F=0,z=n.getParameter(n.VERSION);z.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(z)[1]),se=F>=1):z.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),se=F>=2);let Y=null,$={},he=n.getParameter(n.SCISSOR_BOX),pe=n.getParameter(n.VIEWPORT),le=new Ni().fromArray(he),Te=new Ni().fromArray(pe);function De(fe,We,ze,ht){let St=new Uint8Array(4),He=n.createTexture();n.bindTexture(fe,He),n.texParameteri(fe,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(fe,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let qt=0;qt<ze;qt++)fe===n.TEXTURE_3D||fe===n.TEXTURE_2D_ARRAY?n.texImage3D(We,0,n.RGBA,1,1,ht,0,n.RGBA,n.UNSIGNED_BYTE,St):n.texImage2D(We+qt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,St);return He}let oe={};oe[n.TEXTURE_2D]=De(n.TEXTURE_2D,n.TEXTURE_2D,1),oe[n.TEXTURE_CUBE_MAP]=De(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),oe[n.TEXTURE_2D_ARRAY]=De(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),oe[n.TEXTURE_3D]=De(n.TEXTURE_3D,n.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ee(n.DEPTH_TEST),s.setFunc(Yo),at(!1),Ve(ep),ee(n.CULL_FACE),$e(Ka);function ee(fe){d[fe]!==!0&&(n.enable(fe),d[fe]=!0)}function be(fe){d[fe]!==!1&&(n.disable(fe),d[fe]=!1)}function Be(fe,We){return h[fe]!==We?(n.bindFramebuffer(fe,We),h[fe]=We,fe===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=We),fe===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=We),!0):!1}function Re(fe,We){let ze=y,ht=!1;if(fe){ze=m.get(We),ze===void 0&&(ze=[],m.set(We,ze));let St=fe.textures;if(ze.length!==St.length||ze[0]!==n.COLOR_ATTACHMENT0){for(let He=0,qt=St.length;He<qt;He++)ze[He]=n.COLOR_ATTACHMENT0+He;ze.length=St.length,ht=!0}}else ze[0]!==n.BACK&&(ze[0]=n.BACK,ht=!0);ht&&n.drawBuffers(ze)}function Ye(fe){return M!==fe?(n.useProgram(fe),M=fe,!0):!1}let nt={[ho]:n.FUNC_ADD,[Xv]:n.FUNC_SUBTRACT,[Yv]:n.FUNC_REVERSE_SUBTRACT};nt[qv]=n.MIN,nt[Zv]=n.MAX;let Ge={[Jv]:n.ZERO,[$v]:n.ONE,[Kv]:n.SRC_COLOR,[rp]:n.SRC_ALPHA,[i0]:n.SRC_ALPHA_SATURATE,[t0]:n.DST_COLOR,[jv]:n.DST_ALPHA,[Qv]:n.ONE_MINUS_SRC_COLOR,[ap]:n.ONE_MINUS_SRC_ALPHA,[n0]:n.ONE_MINUS_DST_COLOR,[e0]:n.ONE_MINUS_DST_ALPHA,[r0]:n.CONSTANT_COLOR,[a0]:n.ONE_MINUS_CONSTANT_COLOR,[s0]:n.CONSTANT_ALPHA,[o0]:n.ONE_MINUS_CONSTANT_ALPHA};function $e(fe,We,ze,ht,St,He,qt,Tt,pt,Lt){if(fe===Ka){g===!0&&(be(n.BLEND),g=!1);return}if(g===!1&&(ee(n.BLEND),g=!0),fe!==Wv){if(fe!==v||Lt!==G){if((L!==ho||N!==ho)&&(n.blendEquation(n.FUNC_ADD),L=ho,N=ho),Lt)switch(fe){case dl:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case tp:n.blendFunc(n.ONE,n.ONE);break;case np:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case ip:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:Un("WebGLState: Invalid blending: ",fe);break}else switch(fe){case dl:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case tp:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case np:Un("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ip:Un("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Un("WebGLState: Invalid blending: ",fe);break}p=null,_=null,D=null,V=null,w.set(0,0,0),I=0,v=fe,G=Lt}return}St=St||We,He=He||ze,qt=qt||ht,(We!==L||St!==N)&&(n.blendEquationSeparate(nt[We],nt[St]),L=We,N=St),(ze!==p||ht!==_||He!==D||qt!==V)&&(n.blendFuncSeparate(Ge[ze],Ge[ht],Ge[He],Ge[qt]),p=ze,_=ht,D=He,V=qt),(Tt.equals(w)===!1||pt!==I)&&(n.blendColor(Tt.r,Tt.g,Tt.b,pt),w.copy(Tt),I=pt),v=fe,G=!1}function mt(fe,We){fe.side===Br?be(n.CULL_FACE):ee(n.CULL_FACE);let ze=fe.side===Kr;We&&(ze=!ze),at(ze),fe.blending===dl&&fe.transparent===!1?$e(Ka):$e(fe.blending,fe.blendEquation,fe.blendSrc,fe.blendDst,fe.blendEquationAlpha,fe.blendSrcAlpha,fe.blendDstAlpha,fe.blendColor,fe.blendAlpha,fe.premultipliedAlpha),s.setFunc(fe.depthFunc),s.setTest(fe.depthTest),s.setMask(fe.depthWrite),a.setMask(fe.colorWrite);let ht=fe.stencilWrite;o.setTest(ht),ht&&(o.setMask(fe.stencilWriteMask),o.setFunc(fe.stencilFunc,fe.stencilRef,fe.stencilFuncMask),o.setOp(fe.stencilFail,fe.stencilZFail,fe.stencilZPass)),st(fe.polygonOffset,fe.polygonOffsetFactor,fe.polygonOffsetUnits),fe.alphaToCoverage===!0?ee(n.SAMPLE_ALPHA_TO_COVERAGE):be(n.SAMPLE_ALPHA_TO_COVERAGE)}function at(fe){H!==fe&&(fe?n.frontFace(n.CW):n.frontFace(n.CCW),H=fe)}function Ve(fe){fe!==Gv?(ee(n.CULL_FACE),fe!==Q&&(fe===ep?n.cullFace(n.BACK):fe===Hv?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):be(n.CULL_FACE),Q=fe}function Yt(fe){fe!==T&&(se&&n.lineWidth(fe),T=fe)}function st(fe,We,ze){fe?(ee(n.POLYGON_OFFSET_FILL),(S!==We||Z!==ze)&&(S=We,Z=ze,s.getReversed()&&(We=-We),n.polygonOffset(We,ze))):be(n.POLYGON_OFFSET_FILL)}function Dt(fe){fe?ee(n.SCISSOR_TEST):be(n.SCISSOR_TEST)}function on(fe){fe===void 0&&(fe=n.TEXTURE0+q-1),Y!==fe&&(n.activeTexture(fe),Y=fe)}function de(fe,We,ze){ze===void 0&&(Y===null?ze=n.TEXTURE0+q-1:ze=Y);let ht=$[ze];ht===void 0&&(ht={type:void 0,texture:void 0},$[ze]=ht),(ht.type!==fe||ht.texture!==We)&&(Y!==ze&&(n.activeTexture(ze),Y=ze),n.bindTexture(fe,We||oe[fe]),ht.type=fe,ht.texture=We)}function wn(){let fe=$[Y];fe!==void 0&&fe.type!==void 0&&(n.bindTexture(fe.type,null),fe.type=void 0,fe.texture=void 0)}function Mn(){try{n.compressedTexImage2D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function K(){try{n.compressedTexImage3D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function b(){try{n.texSubImage2D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function ne(){try{n.texSubImage3D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function Se(){try{n.compressedTexSubImage2D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function Ie(){try{n.compressedTexSubImage3D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function Xe(){try{n.texStorage2D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function qe(){try{n.texStorage3D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function Le(){try{n.texImage2D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function Pe(){try{n.texImage3D(...arguments)}catch(fe){Un("WebGLState:",fe)}}function lt(fe){return f[fe]!==void 0?f[fe]:n.getParameter(fe)}function Mt(fe,We){f[fe]!==We&&(n.pixelStorei(fe,We),f[fe]=We)}function yt(fe){le.equals(fe)===!1&&(n.scissor(fe.x,fe.y,fe.z,fe.w),le.copy(fe))}function it(fe){Te.equals(fe)===!1&&(n.viewport(fe.x,fe.y,fe.z,fe.w),Te.copy(fe))}function Gt(fe,We){let ze=l.get(We);ze===void 0&&(ze=new WeakMap,l.set(We,ze));let ht=ze.get(fe);ht===void 0&&(ht=n.getUniformBlockIndex(We,fe.name),ze.set(fe,ht))}function Zt(fe,We){let ht=l.get(We).get(fe);u.get(We)!==ht&&(n.uniformBlockBinding(We,ht,fe.__bindingPointIndex),u.set(We,ht))}function Ke(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),s.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.pixelStorei(n.PACK_ROW_LENGTH,0),n.pixelStorei(n.PACK_SKIP_PIXELS,0),n.pixelStorei(n.PACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_ROW_LENGTH,0),n.pixelStorei(n.UNPACK_IMAGE_HEIGHT,0),n.pixelStorei(n.UNPACK_SKIP_PIXELS,0),n.pixelStorei(n.UNPACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_SKIP_IMAGES,0),d={},f={},Y=null,$={},h={},m=new WeakMap,y=[],M=null,g=!1,v=null,L=null,p=null,_=null,N=null,D=null,V=null,w=new zn(0,0,0),I=0,G=!1,H=null,Q=null,T=null,S=null,Z=null,le.set(0,0,n.canvas.width,n.canvas.height),Te.set(0,0,n.canvas.width,n.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:ee,disable:be,bindFramebuffer:Be,drawBuffers:Re,useProgram:Ye,setBlending:$e,setMaterial:mt,setFlipSided:at,setCullFace:Ve,setLineWidth:Yt,setPolygonOffset:st,setScissorTest:Dt,activeTexture:on,bindTexture:de,unbindTexture:wn,compressedTexImage2D:Mn,compressedTexImage3D:K,texImage2D:Le,texImage3D:Pe,pixelStorei:Mt,getParameter:lt,updateUBOMapping:Gt,uniformBlockBinding:Zt,texStorage2D:Xe,texStorage3D:qe,texSubImage2D:b,texSubImage3D:ne,compressedTexSubImage2D:Se,compressedTexSubImage3D:Ie,scissor:yt,viewport:it,reset:Ke}}function Cw(n,e,t,i,r,a,s){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new tn,d=new WeakMap,f=new Set,h,m=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(K,b){return y?new OffscreenCanvas(K,b):nc("canvas")}function g(K,b,ne){let Se=1,Ie=Mn(K);if((Ie.width>ne||Ie.height>ne)&&(Se=ne/Math.max(Ie.width,Ie.height)),Se<1)if(typeof HTMLImageElement<"u"&&K instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&K instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&K instanceof ImageBitmap||typeof VideoFrame<"u"&&K instanceof VideoFrame){let Xe=Math.floor(Se*Ie.width),qe=Math.floor(Se*Ie.height);h===void 0&&(h=M(Xe,qe));let Le=b?M(Xe,qe):h;return Le.width=Xe,Le.height=qe,Le.getContext("2d").drawImage(K,0,0,Xe,qe),En("WebGLRenderer: Texture has been resized from ("+Ie.width+"x"+Ie.height+") to ("+Xe+"x"+qe+")."),Le}else return"data"in K&&En("WebGLRenderer: Image in DataTexture is too big ("+Ie.width+"x"+Ie.height+")."),K;return K}function v(K){return K.generateMipmaps}function L(K){n.generateMipmap(K)}function p(K){return K.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:K.isWebGL3DRenderTarget?n.TEXTURE_3D:K.isWebGLArrayRenderTarget||K.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function _(K,b,ne,Se,Ie,Xe=!1){if(K!==null){if(n[K]!==void 0)return n[K];En("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+K+"'")}let qe;Se&&(qe=e.get("EXT_texture_norm16"),qe||En("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Le=b;if(b===n.RED&&(ne===n.FLOAT&&(Le=n.R32F),ne===n.HALF_FLOAT&&(Le=n.R16F),ne===n.UNSIGNED_BYTE&&(Le=n.R8),ne===n.UNSIGNED_SHORT&&qe&&(Le=qe.R16_EXT),ne===n.SHORT&&qe&&(Le=qe.R16_SNORM_EXT)),b===n.RED_INTEGER&&(ne===n.UNSIGNED_BYTE&&(Le=n.R8UI),ne===n.UNSIGNED_SHORT&&(Le=n.R16UI),ne===n.UNSIGNED_INT&&(Le=n.R32UI),ne===n.BYTE&&(Le=n.R8I),ne===n.SHORT&&(Le=n.R16I),ne===n.INT&&(Le=n.R32I)),b===n.RG&&(ne===n.FLOAT&&(Le=n.RG32F),ne===n.HALF_FLOAT&&(Le=n.RG16F),ne===n.UNSIGNED_BYTE&&(Le=n.RG8),ne===n.UNSIGNED_SHORT&&qe&&(Le=qe.RG16_EXT),ne===n.SHORT&&qe&&(Le=qe.RG16_SNORM_EXT)),b===n.RG_INTEGER&&(ne===n.UNSIGNED_BYTE&&(Le=n.RG8UI),ne===n.UNSIGNED_SHORT&&(Le=n.RG16UI),ne===n.UNSIGNED_INT&&(Le=n.RG32UI),ne===n.BYTE&&(Le=n.RG8I),ne===n.SHORT&&(Le=n.RG16I),ne===n.INT&&(Le=n.RG32I)),b===n.RGB_INTEGER&&(ne===n.UNSIGNED_BYTE&&(Le=n.RGB8UI),ne===n.UNSIGNED_SHORT&&(Le=n.RGB16UI),ne===n.UNSIGNED_INT&&(Le=n.RGB32UI),ne===n.BYTE&&(Le=n.RGB8I),ne===n.SHORT&&(Le=n.RGB16I),ne===n.INT&&(Le=n.RGB32I)),b===n.RGBA_INTEGER&&(ne===n.UNSIGNED_BYTE&&(Le=n.RGBA8UI),ne===n.UNSIGNED_SHORT&&(Le=n.RGBA16UI),ne===n.UNSIGNED_INT&&(Le=n.RGBA32UI),ne===n.BYTE&&(Le=n.RGBA8I),ne===n.SHORT&&(Le=n.RGBA16I),ne===n.INT&&(Le=n.RGBA32I)),b===n.RGB&&(ne===n.UNSIGNED_SHORT&&qe&&(Le=qe.RGB16_EXT),ne===n.SHORT&&qe&&(Le=qe.RGB16_SNORM_EXT),ne===n.UNSIGNED_INT_5_9_9_9_REV&&(Le=n.RGB9_E5),ne===n.UNSIGNED_INT_10F_11F_11F_REV&&(Le=n.R11F_G11F_B10F)),b===n.RGBA){let Pe=Xe?tc:mi.getTransfer(Ie);ne===n.FLOAT&&(Le=n.RGBA32F),ne===n.HALF_FLOAT&&(Le=n.RGBA16F),ne===n.UNSIGNED_BYTE&&(Le=Pe===Li?n.SRGB8_ALPHA8:n.RGBA8),ne===n.UNSIGNED_SHORT&&qe&&(Le=qe.RGBA16_EXT),ne===n.SHORT&&qe&&(Le=qe.RGBA16_SNORM_EXT),ne===n.UNSIGNED_SHORT_4_4_4_4&&(Le=n.RGBA4),ne===n.UNSIGNED_SHORT_5_5_5_1&&(Le=n.RGB5_A1)}return(Le===n.R16F||Le===n.R32F||Le===n.RG16F||Le===n.RG32F||Le===n.RGBA16F||Le===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Le}function N(K,b){let ne;return K?b===null||b===Ua||b===ml?ne=n.DEPTH24_STENCIL8:b===va?ne=n.DEPTH32F_STENCIL8:b===pl&&(ne=n.DEPTH24_STENCIL8,En("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===Ua||b===ml?ne=n.DEPTH_COMPONENT24:b===va?ne=n.DEPTH_COMPONENT32F:b===pl&&(ne=n.DEPTH_COMPONENT16),ne}function D(K,b){return v(K)===!0||K.isFramebufferTexture&&K.minFilter!==ir&&K.minFilter!==lr?Math.log2(Math.max(b.width,b.height))+1:K.mipmaps!==void 0&&K.mipmaps.length>0?K.mipmaps.length:K.isCompressedTexture&&Array.isArray(K.image)?b.mipmaps.length:1}function V(K){let b=K.target;b.removeEventListener("dispose",V),I(b),b.isVideoTexture&&d.delete(b),b.isHTMLTexture&&f.delete(b)}function w(K){let b=K.target;b.removeEventListener("dispose",w),H(b)}function I(K){let b=i.get(K);if(b.__webglInit===void 0)return;let ne=K.source,Se=m.get(ne);if(Se){let Ie=Se[b.__cacheKey];Ie.usedTimes--,Ie.usedTimes===0&&G(K),Object.keys(Se).length===0&&m.delete(ne)}i.remove(K)}function G(K){let b=i.get(K);n.deleteTexture(b.__webglTexture);let ne=K.source,Se=m.get(ne);delete Se[b.__cacheKey],s.memory.textures--}function H(K){let b=i.get(K);if(K.depthTexture&&(K.depthTexture.dispose(),i.remove(K.depthTexture)),K.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(b.__webglFramebuffer[Se]))for(let Ie=0;Ie<b.__webglFramebuffer[Se].length;Ie++)n.deleteFramebuffer(b.__webglFramebuffer[Se][Ie]);else n.deleteFramebuffer(b.__webglFramebuffer[Se]);b.__webglDepthbuffer&&n.deleteRenderbuffer(b.__webglDepthbuffer[Se])}else{if(Array.isArray(b.__webglFramebuffer))for(let Se=0;Se<b.__webglFramebuffer.length;Se++)n.deleteFramebuffer(b.__webglFramebuffer[Se]);else n.deleteFramebuffer(b.__webglFramebuffer);if(b.__webglDepthbuffer&&n.deleteRenderbuffer(b.__webglDepthbuffer),b.__webglMultisampledFramebuffer&&n.deleteFramebuffer(b.__webglMultisampledFramebuffer),b.__webglColorRenderbuffer)for(let Se=0;Se<b.__webglColorRenderbuffer.length;Se++)b.__webglColorRenderbuffer[Se]&&n.deleteRenderbuffer(b.__webglColorRenderbuffer[Se]);b.__webglDepthRenderbuffer&&n.deleteRenderbuffer(b.__webglDepthRenderbuffer)}let ne=K.textures;for(let Se=0,Ie=ne.length;Se<Ie;Se++){let Xe=i.get(ne[Se]);Xe.__webglTexture&&(n.deleteTexture(Xe.__webglTexture),s.memory.textures--),i.remove(ne[Se])}i.remove(K)}let Q=0;function T(){Q=0}function S(){return Q}function Z(K){Q=K}function q(){let K=Q;return K>=r.maxTextures&&En("WebGLTextures: Trying to use "+(K+1)+" texture units while this GPU supports only "+r.maxTextures),Q+=1,K}function se(K){let b=[];return b.push(K.wrapS),b.push(K.wrapT),b.push(K.wrapR||0),b.push(K.magFilter),b.push(K.minFilter),b.push(K.anisotropy),b.push(K.internalFormat),b.push(K.format),b.push(K.type),b.push(K.generateMipmaps),b.push(K.premultiplyAlpha),b.push(K.flipY),b.push(K.unpackAlignment),b.push(K.colorSpace),b.join()}function F(K,b){let ne=i.get(K);if(K.isVideoTexture&&de(K),K.isRenderTargetTexture===!1&&K.isExternalTexture!==!0&&K.version>0&&ne.__version!==K.version){let Se=K.image;if(Se===null)En("WebGLRenderer: Texture marked for update but no image data found.");else if(Se.complete===!1)En("WebGLRenderer: Texture marked for update but image is incomplete");else{be(ne,K,b);return}}else K.isExternalTexture&&(ne.__webglTexture=K.sourceTexture?K.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ne.__webglTexture,n.TEXTURE0+b)}function z(K,b){let ne=i.get(K);if(K.isRenderTargetTexture===!1&&K.version>0&&ne.__version!==K.version){be(ne,K,b);return}else K.isExternalTexture&&(ne.__webglTexture=K.sourceTexture?K.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ne.__webglTexture,n.TEXTURE0+b)}function Y(K,b){let ne=i.get(K);if(K.isRenderTargetTexture===!1&&K.version>0&&ne.__version!==K.version){be(ne,K,b);return}t.bindTexture(n.TEXTURE_3D,ne.__webglTexture,n.TEXTURE0+b)}function $(K,b){let ne=i.get(K);if(K.isCubeDepthTexture!==!0&&K.version>0&&ne.__version!==K.version){Be(ne,K,b);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ne.__webglTexture,n.TEXTURE0+b)}let he={[Fs]:n.REPEAT,[Sa]:n.CLAMP_TO_EDGE,[qo]:n.MIRRORED_REPEAT},pe={[ir]:n.NEAREST,[Cd]:n.NEAREST_MIPMAP_NEAREST,[mo]:n.NEAREST_MIPMAP_LINEAR,[lr]:n.LINEAR,[hl]:n.LINEAR_MIPMAP_NEAREST,[Qa]:n.LINEAR_MIPMAP_LINEAR},le={[p0]:n.NEVER,[x0]:n.ALWAYS,[m0]:n.LESS,[pf]:n.LEQUAL,[v0]:n.EQUAL,[mf]:n.GEQUAL,[g0]:n.GREATER,[y0]:n.NOTEQUAL};function Te(K,b){if(b.type===va&&e.has("OES_texture_float_linear")===!1&&(b.magFilter===lr||b.magFilter===hl||b.magFilter===mo||b.magFilter===Qa||b.minFilter===lr||b.minFilter===hl||b.minFilter===mo||b.minFilter===Qa)&&En("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(K,n.TEXTURE_WRAP_S,he[b.wrapS]),n.texParameteri(K,n.TEXTURE_WRAP_T,he[b.wrapT]),(K===n.TEXTURE_3D||K===n.TEXTURE_2D_ARRAY)&&n.texParameteri(K,n.TEXTURE_WRAP_R,he[b.wrapR]),n.texParameteri(K,n.TEXTURE_MAG_FILTER,pe[b.magFilter]),n.texParameteri(K,n.TEXTURE_MIN_FILTER,pe[b.minFilter]),b.compareFunction&&(n.texParameteri(K,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(K,n.TEXTURE_COMPARE_FUNC,le[b.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===ir||b.minFilter!==mo&&b.minFilter!==Qa||b.type===va&&e.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||i.get(b).__currentAnisotropy){let ne=e.get("EXT_texture_filter_anisotropic");n.texParameterf(K,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,r.getMaxAnisotropy())),i.get(b).__currentAnisotropy=b.anisotropy}}}function De(K,b){let ne=!1;K.__webglInit===void 0&&(K.__webglInit=!0,b.addEventListener("dispose",V));let Se=b.source,Ie=m.get(Se);Ie===void 0&&(Ie={},m.set(Se,Ie));let Xe=se(b);if(Xe!==K.__cacheKey){Ie[Xe]===void 0&&(Ie[Xe]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),Ie[Xe].usedTimes++;let qe=Ie[K.__cacheKey];qe!==void 0&&(Ie[K.__cacheKey].usedTimes--,qe.usedTimes===0&&G(b)),K.__cacheKey=Xe,K.__webglTexture=Ie[Xe].texture}return ne}function oe(K,b,ne){return Math.floor(Math.floor(K/ne)/b)}function ee(K,b,ne,Se){let Xe=K.updateRanges;if(Xe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,b.width,b.height,ne,Se,b.data);else{Xe.sort((Mt,yt)=>Mt.start-yt.start);let qe=0;for(let Mt=1;Mt<Xe.length;Mt++){let yt=Xe[qe],it=Xe[Mt],Gt=yt.start+yt.count,Zt=oe(it.start,b.width,4),Ke=oe(yt.start,b.width,4);it.start<=Gt+1&&Zt===Ke&&oe(it.start+it.count-1,b.width,4)===Zt?yt.count=Math.max(yt.count,it.start+it.count-yt.start):(++qe,Xe[qe]=it)}Xe.length=qe+1;let Le=t.getParameter(n.UNPACK_ROW_LENGTH),Pe=t.getParameter(n.UNPACK_SKIP_PIXELS),lt=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,b.width);for(let Mt=0,yt=Xe.length;Mt<yt;Mt++){let it=Xe[Mt],Gt=Math.floor(it.start/4),Zt=Math.ceil(it.count/4),Ke=Gt%b.width,fe=Math.floor(Gt/b.width),We=Zt,ze=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(n.UNPACK_SKIP_ROWS,fe),t.texSubImage2D(n.TEXTURE_2D,0,Ke,fe,We,ze,ne,Se,b.data)}K.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,Le),t.pixelStorei(n.UNPACK_SKIP_PIXELS,Pe),t.pixelStorei(n.UNPACK_SKIP_ROWS,lt)}}function be(K,b,ne){let Se=n.TEXTURE_2D;(b.isDataArrayTexture||b.isCompressedArrayTexture)&&(Se=n.TEXTURE_2D_ARRAY),b.isData3DTexture&&(Se=n.TEXTURE_3D);let Ie=De(K,b),Xe=b.source;t.bindTexture(Se,K.__webglTexture,n.TEXTURE0+ne);let qe=i.get(Xe);if(Xe.version!==qe.__version||Ie===!0){if(t.activeTexture(n.TEXTURE0+ne),(typeof ImageBitmap<"u"&&b.image instanceof ImageBitmap)===!1){let ze=mi.getPrimaries(mi.workingColorSpace),ht=b.colorSpace===Qr?null:mi.getPrimaries(b.colorSpace),St=b.colorSpace===Qr||ze===ht?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,St)}t.pixelStorei(n.UNPACK_ALIGNMENT,b.unpackAlignment);let Pe=g(b.image,!1,r.maxTextureSize);Pe=wn(b,Pe);let lt=a.convert(b.format,b.colorSpace),Mt=a.convert(b.type),yt=_(b.internalFormat,lt,Mt,b.normalized,b.colorSpace,b.isVideoTexture);Te(Se,b);let it,Gt=b.mipmaps,Zt=b.isVideoTexture!==!0,Ke=qe.__version===void 0||Ie===!0,fe=Xe.dataReady,We=D(b,Pe);if(b.isDepthTexture)yt=N(b.format===Hs,b.type),Ke&&(Zt?t.texStorage2D(n.TEXTURE_2D,1,yt,Pe.width,Pe.height):t.texImage2D(n.TEXTURE_2D,0,yt,Pe.width,Pe.height,0,lt,Mt,null));else if(b.isDataTexture)if(Gt.length>0){Zt&&Ke&&t.texStorage2D(n.TEXTURE_2D,We,yt,Gt[0].width,Gt[0].height);for(let ze=0,ht=Gt.length;ze<ht;ze++)it=Gt[ze],Zt?fe&&t.texSubImage2D(n.TEXTURE_2D,ze,0,0,it.width,it.height,lt,Mt,it.data):t.texImage2D(n.TEXTURE_2D,ze,yt,it.width,it.height,0,lt,Mt,it.data);b.generateMipmaps=!1}else Zt?(Ke&&t.texStorage2D(n.TEXTURE_2D,We,yt,Pe.width,Pe.height),fe&&ee(b,Pe,lt,Mt)):t.texImage2D(n.TEXTURE_2D,0,yt,Pe.width,Pe.height,0,lt,Mt,Pe.data);else if(b.isCompressedTexture)if(b.isCompressedArrayTexture){Zt&&Ke&&t.texStorage3D(n.TEXTURE_2D_ARRAY,We,yt,Gt[0].width,Gt[0].height,Pe.depth);for(let ze=0,ht=Gt.length;ze<ht;ze++)if(it=Gt[ze],b.format!==ga)if(lt!==null)if(Zt){if(fe)if(b.layerUpdates.size>0){let St=wp(it.width,it.height,b.format,b.type);for(let He of b.layerUpdates){let qt=it.data.subarray(He*St/it.data.BYTES_PER_ELEMENT,(He+1)*St/it.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ze,0,0,He,it.width,it.height,1,lt,qt)}}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ze,0,0,0,it.width,it.height,Pe.depth,lt,it.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ze,yt,it.width,it.height,Pe.depth,0,it.data,0,0);else En("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Zt?fe&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ze,0,0,0,it.width,it.height,Pe.depth,lt,Mt,it.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ze,yt,it.width,it.height,Pe.depth,0,lt,Mt,it.data);b.layerUpdates.size>0&&b.clearLayerUpdates()}else{Zt&&Ke&&t.texStorage2D(n.TEXTURE_2D,We,yt,Gt[0].width,Gt[0].height);for(let ze=0,ht=Gt.length;ze<ht;ze++)it=Gt[ze],b.format!==ga?lt!==null?Zt?fe&&t.compressedTexSubImage2D(n.TEXTURE_2D,ze,0,0,it.width,it.height,lt,it.data):t.compressedTexImage2D(n.TEXTURE_2D,ze,yt,it.width,it.height,0,it.data):En("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?fe&&t.texSubImage2D(n.TEXTURE_2D,ze,0,0,it.width,it.height,lt,Mt,it.data):t.texImage2D(n.TEXTURE_2D,ze,yt,it.width,it.height,0,lt,Mt,it.data)}else if(b.isDataArrayTexture)if(Zt){if(Ke&&t.texStorage3D(n.TEXTURE_2D_ARRAY,We,yt,Pe.width,Pe.height,Pe.depth),fe)if(b.layerUpdates.size>0){let ze=wp(Pe.width,Pe.height,b.format,b.type);for(let ht of b.layerUpdates){let St=Pe.data.subarray(ht*ze/Pe.data.BYTES_PER_ELEMENT,(ht+1)*ze/Pe.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ht,Pe.width,Pe.height,1,lt,Mt,St)}b.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Pe.width,Pe.height,Pe.depth,lt,Mt,Pe.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,yt,Pe.width,Pe.height,Pe.depth,0,lt,Mt,Pe.data);else if(b.isData3DTexture)Zt?(Ke&&t.texStorage3D(n.TEXTURE_3D,We,yt,Pe.width,Pe.height,Pe.depth),fe&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Pe.width,Pe.height,Pe.depth,lt,Mt,Pe.data)):t.texImage3D(n.TEXTURE_3D,0,yt,Pe.width,Pe.height,Pe.depth,0,lt,Mt,Pe.data);else if(b.isFramebufferTexture){if(Ke)if(Zt)t.texStorage2D(n.TEXTURE_2D,We,yt,Pe.width,Pe.height);else{let ze=Pe.width,ht=Pe.height;for(let St=0;St<We;St++)t.texImage2D(n.TEXTURE_2D,St,yt,ze,ht,0,lt,Mt,null),ze>>=1,ht>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in n){let ze=n.canvas;if(ze.hasAttribute("layoutsubtree")||ze.setAttribute("layoutsubtree","true"),Pe.parentNode!==ze){ze.appendChild(Pe),f.add(b),ze.onpaint=ht=>{let St=ht.changedElements;for(let He of f)St.includes(He.image)&&(He.needsUpdate=!0)},ze.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Pe);else{let St=n.RGBA,He=n.RGBA,qt=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,St,He,qt,Pe)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(Gt.length>0){if(Zt&&Ke){let ze=Mn(Gt[0]);t.texStorage2D(n.TEXTURE_2D,We,yt,ze.width,ze.height)}for(let ze=0,ht=Gt.length;ze<ht;ze++)it=Gt[ze],Zt?fe&&t.texSubImage2D(n.TEXTURE_2D,ze,0,0,lt,Mt,it):t.texImage2D(n.TEXTURE_2D,ze,yt,lt,Mt,it);b.generateMipmaps=!1}else if(Zt){if(Ke){let ze=Mn(Pe);t.texStorage2D(n.TEXTURE_2D,We,yt,ze.width,ze.height)}fe&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,lt,Mt,Pe)}else t.texImage2D(n.TEXTURE_2D,0,yt,lt,Mt,Pe);v(b)&&L(Se),qe.__version=Xe.version,b.onUpdate&&b.onUpdate(b)}K.__version=b.version}function Be(K,b,ne){if(b.image.length!==6)return;let Se=De(K,b),Ie=b.source;t.bindTexture(n.TEXTURE_CUBE_MAP,K.__webglTexture,n.TEXTURE0+ne);let Xe=i.get(Ie);if(Ie.version!==Xe.__version||Se===!0){t.activeTexture(n.TEXTURE0+ne);let qe=mi.getPrimaries(mi.workingColorSpace),Le=b.colorSpace===Qr?null:mi.getPrimaries(b.colorSpace),Pe=b.colorSpace===Qr||qe===Le?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,b.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,b.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);let lt=b.isCompressedTexture||b.image[0].isCompressedTexture,Mt=b.image[0]&&b.image[0].isDataTexture,yt=[];for(let He=0;He<6;He++)!lt&&!Mt?yt[He]=g(b.image[He],!0,r.maxCubemapSize):yt[He]=Mt?b.image[He].image:b.image[He],yt[He]=wn(b,yt[He]);let it=yt[0],Gt=a.convert(b.format,b.colorSpace),Zt=a.convert(b.type),Ke=_(b.internalFormat,Gt,Zt,b.normalized,b.colorSpace),fe=b.isVideoTexture!==!0,We=Xe.__version===void 0||Se===!0,ze=Ie.dataReady,ht=D(b,it);Te(n.TEXTURE_CUBE_MAP,b);let St;if(lt){fe&&We&&t.texStorage2D(n.TEXTURE_CUBE_MAP,ht,Ke,it.width,it.height);for(let He=0;He<6;He++){St=yt[He].mipmaps;for(let qt=0;qt<St.length;qt++){let Tt=St[qt];b.format!==ga?Gt!==null?fe?ze&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt,0,0,Tt.width,Tt.height,Gt,Tt.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt,Ke,Tt.width,Tt.height,0,Tt.data):En("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):fe?ze&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt,0,0,Tt.width,Tt.height,Gt,Zt,Tt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt,Ke,Tt.width,Tt.height,0,Gt,Zt,Tt.data)}}}else{if(St=b.mipmaps,fe&&We){St.length>0&&ht++;let He=Mn(yt[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ht,Ke,He.width,He.height)}for(let He=0;He<6;He++)if(Mt){fe?ze&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,0,0,yt[He].width,yt[He].height,Gt,Zt,yt[He].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,Ke,yt[He].width,yt[He].height,0,Gt,Zt,yt[He].data);for(let qt=0;qt<St.length;qt++){let pt=St[qt].image[He].image;fe?ze&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt+1,0,0,pt.width,pt.height,Gt,Zt,pt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt+1,Ke,pt.width,pt.height,0,Gt,Zt,pt.data)}}else{fe?ze&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,0,0,Gt,Zt,yt[He]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,Ke,Gt,Zt,yt[He]);for(let qt=0;qt<St.length;qt++){let Tt=St[qt];fe?ze&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt+1,0,0,Gt,Zt,Tt.image[He]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,qt+1,Ke,Gt,Zt,Tt.image[He])}}}v(b)&&L(n.TEXTURE_CUBE_MAP),Xe.__version=Ie.version,b.onUpdate&&b.onUpdate(b)}K.__version=b.version}function Re(K,b,ne,Se,Ie,Xe){let qe=a.convert(ne.format,ne.colorSpace),Le=a.convert(ne.type),Pe=_(ne.internalFormat,qe,Le,ne.normalized,ne.colorSpace),lt=i.get(b),Mt=i.get(ne);if(Mt.__renderTarget=b,!lt.__hasExternalTextures){let yt=Math.max(1,b.width>>Xe),it=Math.max(1,b.height>>Xe);Ie===n.TEXTURE_3D||Ie===n.TEXTURE_2D_ARRAY?t.texImage3D(Ie,Xe,Pe,yt,it,b.depth,0,qe,Le,null):t.texImage2D(Ie,Xe,Pe,yt,it,0,qe,Le,null)}t.bindFramebuffer(n.FRAMEBUFFER,K),on(b)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Se,Ie,Mt.__webglTexture,0,Dt(b)):(Ie===n.TEXTURE_2D||Ie>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Ie<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Se,Ie,Mt.__webglTexture,Xe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ye(K,b,ne){if(n.bindRenderbuffer(n.RENDERBUFFER,K),b.depthBuffer){let Se=b.depthTexture,Ie=Se&&Se.isDepthTexture?Se.type:null,Xe=N(b.stencilBuffer,Ie),qe=b.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;on(b)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Dt(b),Xe,b.width,b.height):ne?n.renderbufferStorageMultisample(n.RENDERBUFFER,Dt(b),Xe,b.width,b.height):n.renderbufferStorage(n.RENDERBUFFER,Xe,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,qe,n.RENDERBUFFER,K)}else{let Se=b.textures;for(let Ie=0;Ie<Se.length;Ie++){let Xe=Se[Ie],qe=a.convert(Xe.format,Xe.colorSpace),Le=a.convert(Xe.type),Pe=_(Xe.internalFormat,qe,Le,Xe.normalized,Xe.colorSpace);on(b)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Dt(b),Pe,b.width,b.height):ne?n.renderbufferStorageMultisample(n.RENDERBUFFER,Dt(b),Pe,b.width,b.height):n.renderbufferStorage(n.RENDERBUFFER,Pe,b.width,b.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function nt(K,b,ne){let Se=b.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,K),!(b.depthTexture&&b.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let Ie=i.get(b.depthTexture);if(Ie.__renderTarget=b,(!Ie.__webglTexture||b.depthTexture.image.width!==b.width||b.depthTexture.image.height!==b.height)&&(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0),Se){if(Ie.__webglInit===void 0&&(Ie.__webglInit=!0,b.depthTexture.addEventListener("dispose",V)),Ie.__webglTexture===void 0){Ie.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,Ie.__webglTexture),Te(n.TEXTURE_CUBE_MAP,b.depthTexture);let lt=a.convert(b.depthTexture.format),Mt=a.convert(b.depthTexture.type),yt;b.depthTexture.format===qa?yt=n.DEPTH_COMPONENT24:b.depthTexture.format===Hs&&(yt=n.DEPTH24_STENCIL8);for(let it=0;it<6;it++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+it,0,yt,b.width,b.height,0,lt,Mt,null)}}else F(b.depthTexture,0);let Xe=Ie.__webglTexture,qe=Dt(b),Le=Se?n.TEXTURE_CUBE_MAP_POSITIVE_X+ne:n.TEXTURE_2D,Pe=b.depthTexture.format===Hs?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(b.depthTexture.format===qa)on(b)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Pe,Le,Xe,0,qe):n.framebufferTexture2D(n.FRAMEBUFFER,Pe,Le,Xe,0);else if(b.depthTexture.format===Hs)on(b)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Pe,Le,Xe,0,qe):n.framebufferTexture2D(n.FRAMEBUFFER,Pe,Le,Xe,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ge(K){let b=i.get(K),ne=K.isWebGLCubeRenderTarget===!0;if(b.__boundDepthTexture!==K.depthTexture){let Se=K.depthTexture;if(b.__depthDisposeCallback&&b.__depthDisposeCallback(),Se){let Ie=()=>{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,Se.removeEventListener("dispose",Ie)};Se.addEventListener("dispose",Ie),b.__depthDisposeCallback=Ie}b.__boundDepthTexture=Se}if(K.depthTexture&&!b.__autoAllocateDepthBuffer)if(ne)for(let Se=0;Se<6;Se++)nt(b.__webglFramebuffer[Se],K,Se);else{let Se=K.texture.mipmaps;Se&&Se.length>0?nt(b.__webglFramebuffer[0],K,0):nt(b.__webglFramebuffer,K,0)}else if(ne){b.__webglDepthbuffer=[];for(let Se=0;Se<6;Se++)if(t.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer[Se]),b.__webglDepthbuffer[Se]===void 0)b.__webglDepthbuffer[Se]=n.createRenderbuffer(),Ye(b.__webglDepthbuffer[Se],K,!1);else{let Ie=K.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Xe=b.__webglDepthbuffer[Se];n.bindRenderbuffer(n.RENDERBUFFER,Xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ie,n.RENDERBUFFER,Xe)}}else{let Se=K.texture.mipmaps;if(Se&&Se.length>0?t.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=n.createRenderbuffer(),Ye(b.__webglDepthbuffer,K,!1);else{let Ie=K.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Xe=b.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,Xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ie,n.RENDERBUFFER,Xe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function $e(K,b,ne){let Se=i.get(K);b!==void 0&&Re(Se.__webglFramebuffer,K,K.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ne!==void 0&&Ge(K)}function mt(K){let b=K.texture,ne=i.get(K),Se=i.get(b);K.addEventListener("dispose",w);let Ie=K.textures,Xe=K.isWebGLCubeRenderTarget===!0,qe=Ie.length>1;if(qe||(Se.__webglTexture===void 0&&(Se.__webglTexture=n.createTexture()),Se.__version=b.version,s.memory.textures++),Xe){ne.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(b.mipmaps&&b.mipmaps.length>0){ne.__webglFramebuffer[Le]=[];for(let Pe=0;Pe<b.mipmaps.length;Pe++)ne.__webglFramebuffer[Le][Pe]=n.createFramebuffer()}else ne.__webglFramebuffer[Le]=n.createFramebuffer()}else{if(b.mipmaps&&b.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Le=0;Le<b.mipmaps.length;Le++)ne.__webglFramebuffer[Le]=n.createFramebuffer()}else ne.__webglFramebuffer=n.createFramebuffer();if(qe)for(let Le=0,Pe=Ie.length;Le<Pe;Le++){let lt=i.get(Ie[Le]);lt.__webglTexture===void 0&&(lt.__webglTexture=n.createTexture(),s.memory.textures++)}if(K.samples>0&&on(K)===!1){ne.__webglMultisampledFramebuffer=n.createFramebuffer(),ne.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Le=0;Le<Ie.length;Le++){let Pe=Ie[Le];ne.__webglColorRenderbuffer[Le]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ne.__webglColorRenderbuffer[Le]);let lt=a.convert(Pe.format,Pe.colorSpace),Mt=a.convert(Pe.type),yt=_(Pe.internalFormat,lt,Mt,Pe.normalized,Pe.colorSpace,K.isXRRenderTarget===!0),it=Dt(K);n.renderbufferStorageMultisample(n.RENDERBUFFER,it,yt,K.width,K.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Le,n.RENDERBUFFER,ne.__webglColorRenderbuffer[Le])}n.bindRenderbuffer(n.RENDERBUFFER,null),K.depthBuffer&&(ne.__webglDepthRenderbuffer=n.createRenderbuffer(),Ye(ne.__webglDepthRenderbuffer,K,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(Xe){t.bindTexture(n.TEXTURE_CUBE_MAP,Se.__webglTexture),Te(n.TEXTURE_CUBE_MAP,b);for(let Le=0;Le<6;Le++)if(b.mipmaps&&b.mipmaps.length>0)for(let Pe=0;Pe<b.mipmaps.length;Pe++)Re(ne.__webglFramebuffer[Le][Pe],K,b,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,Pe);else Re(ne.__webglFramebuffer[Le],K,b,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);v(b)&&L(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(qe){for(let Le=0,Pe=Ie.length;Le<Pe;Le++){let lt=Ie[Le],Mt=i.get(lt),yt=n.TEXTURE_2D;(K.isWebGL3DRenderTarget||K.isWebGLArrayRenderTarget)&&(yt=K.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(yt,Mt.__webglTexture),Te(yt,lt),Re(ne.__webglFramebuffer,K,lt,n.COLOR_ATTACHMENT0+Le,yt,0),v(lt)&&L(yt)}t.unbindTexture()}else{let Le=n.TEXTURE_2D;if((K.isWebGL3DRenderTarget||K.isWebGLArrayRenderTarget)&&(Le=K.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Le,Se.__webglTexture),Te(Le,b),b.mipmaps&&b.mipmaps.length>0)for(let Pe=0;Pe<b.mipmaps.length;Pe++)Re(ne.__webglFramebuffer[Pe],K,b,n.COLOR_ATTACHMENT0,Le,Pe);else Re(ne.__webglFramebuffer,K,b,n.COLOR_ATTACHMENT0,Le,0);v(b)&&L(Le),t.unbindTexture()}K.depthBuffer&&Ge(K)}function at(K){let b=K.textures;for(let ne=0,Se=b.length;ne<Se;ne++){let Ie=b[ne];if(v(Ie)){let Xe=p(K),qe=i.get(Ie).__webglTexture;t.bindTexture(Xe,qe),L(Xe),t.unbindTexture()}}}let Ve=[],Yt=[];function st(K){if(K.samples>0){if(on(K)===!1){let b=K.textures,ne=K.width,Se=K.height,Ie=n.COLOR_BUFFER_BIT,Xe=K.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,qe=i.get(K),Le=b.length>1;if(Le)for(let lt=0;lt<b.length;lt++)t.bindFramebuffer(n.FRAMEBUFFER,qe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+lt,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,qe.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+lt,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,qe.__webglMultisampledFramebuffer);let Pe=K.texture.mipmaps;Pe&&Pe.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,qe.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,qe.__webglFramebuffer);for(let lt=0;lt<b.length;lt++){if(K.resolveDepthBuffer&&(K.depthBuffer&&(Ie|=n.DEPTH_BUFFER_BIT),K.stencilBuffer&&K.resolveStencilBuffer&&(Ie|=n.STENCIL_BUFFER_BIT)),Le){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,qe.__webglColorRenderbuffer[lt]);let Mt=i.get(b[lt]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Mt,0)}n.blitFramebuffer(0,0,ne,Se,0,0,ne,Se,Ie,n.NEAREST),u===!0&&(Ve.length=0,Yt.length=0,Ve.push(n.COLOR_ATTACHMENT0+lt),K.depthBuffer&&K.storeMultisampledDepthBuffer===!1&&(Ve.push(Xe),Yt.push(Xe),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Yt)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Ve))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Le)for(let lt=0;lt<b.length;lt++){t.bindFramebuffer(n.FRAMEBUFFER,qe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+lt,n.RENDERBUFFER,qe.__webglColorRenderbuffer[lt]);let Mt=i.get(b[lt]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,qe.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+lt,n.TEXTURE_2D,Mt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,qe.__webglMultisampledFramebuffer)}else if(K.depthBuffer&&K.storeMultisampledDepthBuffer===!1&&u){let b=K.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[b])}}}function Dt(K){return Math.min(r.maxSamples,K.samples)}function on(K){let b=i.get(K);return K.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function de(K){let b=s.render.frame;d.get(K)!==b&&(d.set(K,b),K.update())}function wn(K,b){let ne=K.colorSpace,Se=K.format,Ie=K.type;return K.isCompressedTexture===!0||K.isVideoTexture===!0||ne!==ec&&ne!==Qr&&(mi.getTransfer(ne)===Li?(Se!==ga||Ie!==la)&&En("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Un("WebGLTextures: Unsupported texture color space:",ne)),b}function Mn(K){return typeof HTMLImageElement<"u"&&K instanceof HTMLImageElement?(l.width=K.naturalWidth||K.width,l.height=K.naturalHeight||K.height):typeof VideoFrame<"u"&&K instanceof VideoFrame?(l.width=K.displayWidth,l.height=K.displayHeight):(l.width=K.width,l.height=K.height),l}this.allocateTextureUnit=q,this.resetTextureUnits=T,this.getTextureUnits=S,this.setTextureUnits=Z,this.setTexture2D=F,this.setTexture2DArray=z,this.setTexture3D=Y,this.setTextureCube=$,this.rebindTextures=$e,this.setupRenderTarget=mt,this.updateRenderTargetMipmap=at,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=Ge,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=on,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Rw(n,e){function t(i,r=Qr){let a,s=mi.getTransfer(r);if(i===la)return n.UNSIGNED_BYTE;if(i===Pd)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Ld)return n.UNSIGNED_SHORT_5_5_5_1;if(i===pp)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===mp)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===fp)return n.BYTE;if(i===hp)return n.SHORT;if(i===pl)return n.UNSIGNED_SHORT;if(i===Rd)return n.INT;if(i===Ua)return n.UNSIGNED_INT;if(i===va)return n.FLOAT;if(i===Fa)return n.HALF_FLOAT;if(i===vp)return n.ALPHA;if(i===gp)return n.RGB;if(i===ga)return n.RGBA;if(i===qa)return n.DEPTH_COMPONENT;if(i===Hs)return n.DEPTH_STENCIL;if(i===Dd)return n.RED;if(i===Nd)return n.RED_INTEGER;if(i===Ws)return n.RG;if(i===Ud)return n.RG_INTEGER;if(i===Fd)return n.RGBA_INTEGER;if(i===Rc||i===Pc||i===Lc||i===Dc)if(s===Li)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Rc)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Pc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Lc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Dc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Rc)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Pc)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Lc)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Dc)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Od||i===Bd||i===kd||i===zd)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===Od)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Bd)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===kd)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===zd)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Vd||i===Gd||i===Hd||i===Wd||i===Xd||i===Nc||i===Yd)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===Vd||i===Gd)return s===Li?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Hd)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wd)return a.COMPRESSED_R11_EAC;if(i===Xd)return a.COMPRESSED_SIGNED_R11_EAC;if(i===Nc)return a.COMPRESSED_RG11_EAC;if(i===Yd)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===qd||i===Zd||i===Jd||i===$d||i===Kd||i===Qd||i===jd||i===ef||i===tf||i===nf||i===rf||i===af||i===sf||i===of)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===qd)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Zd)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Jd)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$d)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Kd)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Qd)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===jd)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ef)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tf)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nf)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===rf)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===af)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===sf)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===of)return s===Li?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===lf||i===cf||i===uf)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===lf)return s===Li?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===cf)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===uf)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===df||i===ff||i===Uc||i===hf)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===df)return a.COMPRESSED_RED_RGTC1_EXT;if(i===ff)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Uc)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===hf)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===ml?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}var Pw=`
|
|
4197
4197
|
void main() {
|
|
4198
4198
|
|
|
4199
4199
|
gl_Position = vec4( position, 1.0 );
|
|
4200
4200
|
|
|
4201
|
-
}`,
|
|
4201
|
+
}`,Lw=`
|
|
4202
4202
|
uniform sampler2DArray depthColor;
|
|
4203
4203
|
uniform float depthWidth;
|
|
4204
4204
|
uniform float depthHeight;
|
|
@@ -4217,8 +4217,8 @@ void main() {
|
|
|
4217
4217
|
|
|
4218
4218
|
}
|
|
4219
4219
|
|
|
4220
|
-
}`,Rp=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let i=new oc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,i=new ea({vertexShader:lw,fragmentShader:cw,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ai(new mc(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Pp=class extends ka{constructor(e,t){super();let i=this,r=null,a=1,s=null,o="local-floor",u=1,l=null,d=null,f=null,h=null,m=null,y=null,M=typeof XRWebGLBinding<"u",g=new Rp,v={},P=t.getContextAttributes(),p=null,_=null,N=[],D=[],B=new qt,w=null,A=null,z=new wr;z.viewport=new Si;let V=new wr;V.viewport=new Si;let $=[z,V],T=new gd,S=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let ie=N[Q];return ie===void 0&&(ie=new Qo,N[Q]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(Q){let ie=N[Q];return ie===void 0&&(ie=new Qo,N[Q]=ie),ie.getGripSpace()},this.getHand=function(Q){let ie=N[Q];return ie===void 0&&(ie=new Qo,N[Q]=ie),ie.getHandSpace()};function W(Q){let ie=D.indexOf(Q.inputSource);if(ie===-1)return;let Me=N[ie];Me!==void 0&&(Me.update(Q.inputSource,Q.frame,l||s),Me.dispatchEvent({type:Q.type,data:Q.inputSource}))}function se(){r.removeEventListener("select",W),r.removeEventListener("selectstart",W),r.removeEventListener("selectend",W),r.removeEventListener("squeeze",W),r.removeEventListener("squeezestart",W),r.removeEventListener("squeezeend",W),r.removeEventListener("end",se),r.removeEventListener("inputsourceschange",O);for(let Q=0;Q<N.length;Q++){let ie=D[Q];ie!==null&&(D[Q]=null,N[Q].disconnect(ie))}S=null,Y=null,g.reset();for(let Q in v)delete v[Q];if(e.setRenderTarget(p),m=null,h=null,f=null,r=null,_=null,Pe.stop(),i.isPresenting=!1,e.setPixelRatio(w),e.setSize(B.width,B.height,!1),A!==null){let Q=A.camera;Q.fov=A.fov,Q.zoom=A.zoom,Q.updateProjectionMatrix(),A=null}i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Q){a=Q,i.isPresenting===!0&&mn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Q){o=Q,i.isPresenting===!0&&mn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(Q){l=Q},this.getBaseLayer=function(){return h!==null?h:m},this.getBinding=function(){return f===null&&M&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(Q){if(r=Q,r!==null){if(p=e.getRenderTarget(),r.addEventListener("select",W),r.addEventListener("selectstart",W),r.addEventListener("selectend",W),r.addEventListener("squeeze",W),r.addEventListener("squeezestart",W),r.addEventListener("squeezeend",W),r.addEventListener("end",se),r.addEventListener("inputsourceschange",O),P.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(B),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let Me=null,Le=null,Ee=null;P.depth&&(Ee=P.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Me=P.stencil?Ps:Ba,Le=P.stencil?ml:Ia);let Xe={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:a};f=this.getBinding(),h=f.createProjectionLayer(Xe),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),_=new zr(h.textureWidth,h.textureHeight,{format:ia,type:Hr,depthTexture:new Es(h.textureWidth,h.textureHeight,Le,void 0,void 0,void 0,void 0,void 0,void 0,Me),stencilBuffer:P.stencil,colorSpace:e.outputColorSpace,samples:P.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let Me={antialias:P.antialias,alpha:!0,depth:P.depth,stencil:P.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(r,t,Me),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),_=new zr(m.framebufferWidth,m.framebufferHeight,{format:ia,type:Hr,colorSpace:e.outputColorSpace,stencilBuffer:P.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1,storeMultisampledDepthBuffer:m.ignoreDepthValues===!1,storeMultisampledStencilBuffer:m.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(u),l=null,s=await r.requestReferenceSpace(o),Pe.setContext(r),Pe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function O(Q){for(let ie=0;ie<Q.removed.length;ie++){let Me=Q.removed[ie],Le=D.indexOf(Me);Le>=0&&(D[Le]=null,N[Le].disconnect(Me))}for(let ie=0;ie<Q.added.length;ie++){let Me=Q.added[ie],Le=D.indexOf(Me);if(Le===-1){for(let Xe=0;Xe<N.length;Xe++)if(Xe>=D.length){D.push(Me),Le=Xe;break}else if(D[Xe]===null){D[Xe]=Me,Le=Xe;break}if(Le===-1)break}let Ee=N[Le];Ee&&Ee.connect(Me)}}let U=new ge,H=new ge;function ne(Q,ie,Me){U.setFromMatrixPosition(ie.matrixWorld),H.setFromMatrixPosition(Me.matrixWorld);let Le=U.distanceTo(H),Ee=ie.projectionMatrix.elements,Xe=Me.projectionMatrix.elements,tt=Ee[14]/(Ee[10]-1),Ge=Ee[14]/(Ee[10]+1),Ye=(Ee[9]+1)/Ee[5],dt=(Ee[9]-1)/Ee[5],ke=(Ee[8]-1)/Ee[0],at=(Xe[8]+1)/Xe[0],Ke=tt*ke,jt=tt*at,Pt=Le/(-ke+at),tn=Pt*-ke;if(ie.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(tn),Q.translateZ(Pt),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert(),Ee[10]===-1)Q.projectionMatrix.copy(ie.projectionMatrix),Q.projectionMatrixInverse.copy(ie.projectionMatrixInverse);else{let ue=tt+Pt,ln=Ge+Pt,on=Ke-tn,Z=jt+(Le-tn),b=Ye*Ge/ln*ue,ee=dt*Ge/ln*ue;Q.projectionMatrix.makePerspective(on,Z,b,ee,ue,ln),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}}function ce(Q,ie){ie===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(ie.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(r===null)return;let ie=Q.near,Me=Q.far;g.texture!==null&&(g.depthNear>0&&(ie=g.depthNear),g.depthFar>0&&(Me=g.depthFar)),T.near=V.near=z.near=ie,T.far=V.far=z.far=Me,(S!==T.near||Y!==T.far)&&(r.updateRenderState({depthNear:T.near,depthFar:T.far}),S=T.near,Y=T.far),T.layers.mask=Q.layers.mask|6,z.layers.mask=T.layers.mask&-5,V.layers.mask=T.layers.mask&-3;let Le=Q.parent,Ee=T.cameras;ce(T,Le);for(let Xe=0;Xe<Ee.length;Xe++)ce(Ee[Xe],Le);Ee.length===2?ne(T,z,V):T.projectionMatrix.copy(z.projectionMatrix),A===null&&Q.isPerspectiveCamera&&(A={camera:Q,fov:Q.fov,zoom:Q.zoom}),pe(Q,T,Le)};function pe(Q,ie,Me){Me===null?Q.matrix.copy(ie.matrixWorld):(Q.matrix.copy(Me.matrixWorld),Q.matrix.invert(),Q.matrix.multiply(ie.matrixWorld)),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale),Q.updateMatrixWorld(!0),Q.projectionMatrix.copy(ie.projectionMatrix),Q.projectionMatrixInverse.copy(ie.projectionMatrixInverse),Q.isPerspectiveCamera&&(Q.fov=Xu*2*Math.atan(1/Q.projectionMatrix.elements[5]),Q.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(h===null&&m===null))return u},this.setFoveation=function(Q){u=Q,h!==null&&(h.fixedFoveation=Q),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=Q)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(T)},this.getCameraTexture=function(Q){return v[Q]};let le=null;function be(Q,ie){if(d=ie.getViewerPose(l||s),y=ie,d!==null){let Me=d.views;m!==null&&(e.setRenderTargetFramebuffer(_,m.framebuffer),e.setRenderTarget(_));let Le=!1;Me.length!==T.cameras.length&&(T.cameras.length=0,Le=!0);for(let Ge=0;Ge<Me.length;Ge++){let Ye=Me[Ge],dt=null;if(m!==null)dt=m.getViewport(Ye);else{let at=f.getViewSubImage(h,Ye);dt=at.viewport,Ge===0&&(e.setRenderTargetTextures(_,at.colorTexture,at.depthStencilTexture),e.setRenderTarget(_))}let ke=$[Ge];ke===void 0&&(ke=new wr,ke.layers.enable(Ge),ke.viewport=new Si,$[Ge]=ke),ke.matrix.fromArray(Ye.transform.matrix),ke.matrix.decompose(ke.position,ke.quaternion,ke.scale),ke.projectionMatrix.fromArray(Ye.projectionMatrix),ke.projectionMatrixInverse.copy(ke.projectionMatrix).invert(),ke.viewport.set(dt.x,dt.y,dt.width,dt.height),Ge===0&&(T.matrix.copy(ke.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),Le===!0&&T.cameras.push(ke)}let Ee=r.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&M){f=i.getBinding();let Ge=f.getDepthInformation(Me[0]);Ge&&Ge.isValid&&Ge.texture&&g.init(Ge,r.renderState)}if(Ee&&Ee.includes("camera-access")&&M){e.state.unbindTexture(),f=i.getBinding();for(let Ge=0;Ge<Me.length;Ge++){let Ye=Me[Ge].camera;if(Ye){let dt=v[Ye];dt||(dt=new oc,v[Ye]=dt);let ke=f.getCameraImage(Ye);dt.sourceTexture=ke}}}}for(let Me=0;Me<N.length;Me++){let Le=D[Me],Ee=N[Me];Le!==null&&Ee!==void 0&&Ee.update(Le,ie,l||s)}le&&le(Q,ie),ie.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ie}),y=null}let Pe=new U0;Pe.setAnimationLoop(be),this.setAnimationLoop=function(Q){le=Q},this.dispose=function(){}}},uw=new Un,V0=new Ln;V0.set(-1,0,0,0,1,0,0,0,1);function dw(n,e){function t(g,v){g.matrixAutoUpdate===!0&&g.updateMatrix(),v.value.copy(g.matrix)}function i(g,v){v.color.getRGB(g.fogColor.value,lp(n)),v.isFog?(g.fogNear.value=v.near,g.fogFar.value=v.far):v.isFogExp2&&(g.fogDensity.value=v.density)}function r(g,v,P,p,_){v.isNodeMaterial?v.uniformsNeedUpdate=!1:v.isMeshBasicMaterial?a(g,v):v.isMeshLambertMaterial?(a(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshToonMaterial?(a(g,v),f(g,v)):v.isMeshPhongMaterial?(a(g,v),d(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshStandardMaterial?(a(g,v),h(g,v),v.isMeshPhysicalMaterial&&m(g,v,_)):v.isMeshMatcapMaterial?(a(g,v),y(g,v)):v.isMeshDepthMaterial?a(g,v):v.isMeshDistanceMaterial?(a(g,v),M(g,v)):v.isMeshNormalMaterial?a(g,v):v.isLineBasicMaterial?(s(g,v),v.isLineDashedMaterial&&o(g,v)):v.isPointsMaterial?u(g,v,P,p):v.isSpriteMaterial?l(g,v):v.isShadowMaterial?(g.color.value.copy(v.color),g.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(g,v){g.opacity.value=v.opacity,v.color&&g.diffuse.value.copy(v.color),v.emissive&&g.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(g.map.value=v.map,t(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.bumpMap&&(g.bumpMap.value=v.bumpMap,t(v.bumpMap,g.bumpMapTransform),g.bumpScale.value=v.bumpScale,v.side===Dr&&(g.bumpScale.value*=-1)),v.normalMap&&(g.normalMap.value=v.normalMap,t(v.normalMap,g.normalMapTransform),g.normalScale.value.copy(v.normalScale),v.side===Dr&&g.normalScale.value.negate()),v.displacementMap&&(g.displacementMap.value=v.displacementMap,t(v.displacementMap,g.displacementMapTransform),g.displacementScale.value=v.displacementScale,g.displacementBias.value=v.displacementBias),v.emissiveMap&&(g.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,g.emissiveMapTransform)),v.specularMap&&(g.specularMap.value=v.specularMap,t(v.specularMap,g.specularMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest);let P=e.get(v),p=P.envMap,_=P.envMapRotation;p&&(g.envMap.value=p,g.envMapRotation.value.setFromMatrix4(uw.makeRotationFromEuler(_)).transpose(),p.isCubeTexture&&p.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(V0),g.reflectivity.value=v.reflectivity,g.ior.value=v.ior,g.refractionRatio.value=v.refractionRatio),v.lightMap&&(g.lightMap.value=v.lightMap,g.lightMapIntensity.value=v.lightMapIntensity,t(v.lightMap,g.lightMapTransform)),v.aoMap&&(g.aoMap.value=v.aoMap,g.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,g.aoMapTransform))}function s(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,v.map&&(g.map.value=v.map,t(v.map,g.mapTransform))}function o(g,v){g.dashSize.value=v.dashSize,g.totalSize.value=v.dashSize+v.gapSize,g.scale.value=v.scale}function u(g,v,P,p){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.size.value=v.size*P,g.scale.value=p*.5,v.map&&(g.map.value=v.map,t(v.map,g.uvTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function l(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.rotation.value=v.rotation,v.map&&(g.map.value=v.map,t(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function d(g,v){g.specular.value.copy(v.specular),g.shininess.value=Math.max(v.shininess,1e-4)}function f(g,v){v.gradientMap&&(g.gradientMap.value=v.gradientMap)}function h(g,v){g.metalness.value=v.metalness,v.metalnessMap&&(g.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,g.metalnessMapTransform)),g.roughness.value=v.roughness,v.roughnessMap&&(g.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,g.roughnessMapTransform)),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)}function m(g,v,P){g.ior.value=v.ior,v.sheen>0&&(g.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),g.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(g.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,g.sheenColorMapTransform)),v.sheenRoughnessMap&&(g.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,g.sheenRoughnessMapTransform))),v.clearcoat>0&&(g.clearcoat.value=v.clearcoat,g.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(g.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,g.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(g.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Dr&&g.clearcoatNormalScale.value.negate())),v.dispersion>0&&(g.dispersion.value=v.dispersion),v.retroreflectivity>0&&(g.retroreflectivity.value=v.retroreflectivity),v.iridescence>0&&(g.iridescence.value=v.iridescence,g.iridescenceIOR.value=v.iridescenceIOR,g.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(g.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,g.iridescenceMapTransform)),v.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),v.transmission>0&&(g.transmission.value=v.transmission,g.transmissionSamplerMap.value=P.texture,g.transmissionSamplerSize.value.set(P.width,P.height),v.transmissionMap&&(g.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,g.transmissionMapTransform)),g.thickness.value=v.thickness,v.thicknessMap&&(g.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=v.attenuationDistance,g.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(g.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(g.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=v.specularIntensity,g.specularColor.value.copy(v.specularColor),v.specularColorMap&&(g.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,g.specularColorMapTransform)),v.specularIntensityMap&&(g.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,g.specularIntensityMapTransform))}function y(g,v){v.matcap&&(g.matcap.value=v.matcap)}function M(g,v){let P=e.get(v).light;g.referencePosition.value.setFromMatrixPosition(P.matrixWorld),g.nearDistance.value=P.shadow.camera.near,g.farDistance.value=P.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function fw(n,e,t,i){let r={},a={},s=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function u(_,N){let D=N.program;i.uniformBlockBinding(_,D)}function l(_,N){let D=r[_.id];D===void 0&&(g(_),D=d(_),r[_.id]=D,_.addEventListener("dispose",P));let B=N.program;i.updateUBOMapping(_,B);let w=e.render.frame;a[_.id]!==w&&(h(_),a[_.id]=w)}function d(_){let N=f();_.__bindingPointIndex=N;let D=n.createBuffer(),B=_.__size,w=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,D),n.bufferData(n.UNIFORM_BUFFER,B,w),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,N,D),D}function f(){for(let _=0;_<o;_++)if(s.indexOf(_)===-1)return s.push(_),_;return Tn("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(_){let N=r[_.id],D=_.uniforms,B=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,N);for(let w=0,A=D.length;w<A;w++){let z=D[w];if(Array.isArray(z))for(let V=0,$=z.length;V<$;V++)m(z[V],w,V,B);else m(z,w,0,B)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function m(_,N,D,B){if(M(_,N,D,B)===!0){let w=_.__offset,A=_.value;if(Array.isArray(A)){let z=0;for(let V=0;V<A.length;V++){let $=A[V],T=v($);y($,_.__data,z),typeof $!="number"&&typeof $!="boolean"&&!$.isMatrix3&&!ArrayBuffer.isView($)&&(z+=T.storage/Float32Array.BYTES_PER_ELEMENT)}}else y(A,_.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,w,_.__data)}}function y(_,N,D){typeof _=="number"||typeof _=="boolean"?N[0]=_:_.isMatrix3?(N[0]=_.elements[0],N[1]=_.elements[1],N[2]=_.elements[2],N[3]=0,N[4]=_.elements[3],N[5]=_.elements[4],N[6]=_.elements[5],N[7]=0,N[8]=_.elements[6],N[9]=_.elements[7],N[10]=_.elements[8],N[11]=0):ArrayBuffer.isView(_)?N.set(new _.constructor(_.buffer,_.byteOffset,N.length)):_.toArray(N,D)}function M(_,N,D,B){let w=_.value,A=N+"_"+D;if(B[A]===void 0)return typeof w=="number"||typeof w=="boolean"?B[A]=w:ArrayBuffer.isView(w)?B[A]=w.slice():B[A]=w.clone(),!0;{let z=B[A];if(typeof w=="number"||typeof w=="boolean"){if(z!==w)return B[A]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(z.equals(w)===!1)return z.copy(w),!0}}return!1}function g(_){let N=_.uniforms,D=0,B=16;for(let A=0,z=N.length;A<z;A++){let V=Array.isArray(N[A])?N[A]:[N[A]];for(let $=0,T=V.length;$<T;$++){let S=V[$],Y=Array.isArray(S.value)?S.value:[S.value];for(let W=0,se=Y.length;W<se;W++){let O=Y[W],U=v(O),H=D%B,ne=H%U.boundary,ce=H+ne;D+=ne,ce!==0&&B-ce<U.storage&&(D+=B-ce),S.__data=new Float32Array(U.storage/Float32Array.BYTES_PER_ELEMENT),S.__offset=D,D+=U.storage}}}let w=D%B;return w>0&&(D+=B-w),_.__size=D,_.__cache={},this}function v(_){let N={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(N.boundary=4,N.storage=4):_.isVector2?(N.boundary=8,N.storage=8):_.isVector3||_.isColor?(N.boundary=16,N.storage=12):_.isVector4?(N.boundary=16,N.storage=16):_.isMatrix3?(N.boundary=48,N.storage=48):_.isMatrix4?(N.boundary=64,N.storage=64):_.isTexture?mn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(N.boundary=16,N.storage=_.byteLength):mn("WebGLRenderer: Unsupported uniform value type.",_),N}function P(_){let N=_.target;N.removeEventListener("dispose",P);let D=s.indexOf(N.__bindingPointIndex);s.splice(D,1),n.deleteBuffer(r[N.id]),delete r[N.id],delete a[N.id]}function p(){for(let _ in r)n.deleteBuffer(r[_]);s=[],r={},a={}}return{bind:u,update:l,dispose:p}}var hw=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Wa=null;function pw(){return Wa===null&&(Wa=new Ts(hw,16,16,Ls,Ca),Wa.name="DFG_LUT",Wa.minFilter=rr,Wa.magFilter=rr,Wa.wrapS=fa,Wa.wrapT=fa,Wa.generateMipmaps=!1,Wa.needsUpdate=!0),Wa}var ff=class{constructor(e={}){let{canvas:t=n0(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:l=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:h=!1,outputBufferType:m=Hr}=e;this.isWebGLRenderer=!0;let y;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");y=i.getContextAttributes().alpha}else y=s;let M=m,g=new Set([Cd,Id,Ad]),v=new Set([Hr,Ia,pl,ml,wd,Td]),P=new Uint32Array(4),p=new Int32Array(4),_=new ge,N=null,D=null,B=[],w=[],A=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Gr,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let z=this,V=!1,$=null,T=null,S=null,Y=null;this._outputColorSpace=pr;let W=0,se=0,O=null,U=-1,H=null,ne=new Si,ce=new Si,pe=null,le=new Rn(0),be=0,Pe=t.width,Q=t.height,ie=1,Me=null,Le=null,Ee=new Si(0,0,Pe,Q),Xe=new Si(0,0,Pe,Q),tt=!1,Ge=new nl,Ye=!1,dt=!1,ke=new Un,at=new ge,Ke=new Si,jt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Pt=!1;function tn(){return O===null?ie:1}let ue=i;function ln(C,re){return t.getContext(C,re)}let on,Z,b,ee,ve,Te,Ve,$e,Ce,Ae,nt,gt,ct,je,Dt,qe,Gt,oe,st,Ne,ft,ht,ze;try{let C={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:u,preserveDrawingBuffer:l,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"186"}`),t.addEventListener("webglcontextlost",_t,!1),t.addEventListener("webglcontextrestored",Bt,!1),t.addEventListener("webglcontextcreationerror",rt,!1),ue===null){let re="webgl2";if(ue=ln(re,C),ue===null)throw ln(re)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Ot()}catch(C){throw t.removeEventListener("webglcontextlost",_t,!1),t.removeEventListener("webglcontextrestored",Bt,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Tn("WebGLRenderer: "+C.message),C}function Ot(){on=new MS(ue),on.init(),ft=new ow(ue,on),Z=new dS(ue,on,e,ft),b=new aw(ue,on),Z.reversedDepthBuffer&&h&&b.buffers.depth.setReversed(!0),T=ue.createFramebuffer(),S=ue.createFramebuffer(),Y=ue.createFramebuffer(),ee=new wS(ue),ve=new Xb,Te=new sw(ue,on,b,ve,Z,ft,ee),Ve=new _S(z),$e=new Ex(ue),ht=new cS(ue,$e),Ce=new SS(ue,$e,ee,ht),Ae=new ES(ue,Ce,$e,ht,ee),oe=new TS(ue,Z,Te),Dt=new fS(ve),nt=new Wb(z,Ve,on,Z,ht,Dt),gt=new dw(z,ve),ct=new qb,je=new jb(on),Gt=new lS(z,Ve,b,Ae,y,u),qe=new rw(z,Ae,Z),ze=new fw(ue,ee,Z,b),st=new uS(ue,on,ee),Ne=new bS(ue,on,ee),ee.programs=nt.programs,z.capabilities=Z,z.extensions=on,z.properties=ve,z.renderLists=ct,z.shadowMap=qe,z.state=b,z.info=ee}M!==Hr&&(A=new IS(M,t.width,t.height,o,r,a));let Tt=new Pp(z,ue);this.xr=Tt,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){let C=on.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){let C=on.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(C){C!==void 0&&(ie=C,this.setSize(Pe,Q,!1))},this.getSize=function(C){return C.set(Pe,Q)},this.setSize=function(C,re,de=!0){if(Tt.isPresenting){mn("WebGLRenderer: Can't change size while VR device is presenting.");return}Pe=C,Q=re,t.width=Math.floor(C*ie),t.height=Math.floor(re*ie),de===!0&&(t.style.width=C+"px",t.style.height=re+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,C,re)},this.getDrawingBufferSize=function(C){return C.set(Pe*ie,Q*ie).floor()},this.setDrawingBufferSize=function(C,re,de){Pe=C,Q=re,ie=de,t.width=Math.floor(C*de),t.height=Math.floor(re*de),this.setViewport(0,0,C,re)},this.setEffects=function(C){if(M===Hr){Tn("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let re=0;re<C.length;re++)if(C[re].isOutputPass===!0){mn("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(C||[])},this.getCurrentViewport=function(C){return C.copy(ne)},this.getViewport=function(C){return C.copy(Ee)},this.setViewport=function(C,re,de,me){C.isVector4?Ee.set(C.x,C.y,C.z,C.w):Ee.set(C,re,de,me),b.viewport(ne.copy(Ee).multiplyScalar(ie).round())},this.getScissor=function(C){return C.copy(Xe)},this.setScissor=function(C,re,de,me){C.isVector4?Xe.set(C.x,C.y,C.z,C.w):Xe.set(C,re,de,me),b.scissor(ce.copy(Xe).multiplyScalar(ie).round())},this.getScissorTest=function(){return tt},this.setScissorTest=function(C){b.setScissorTest(tt=C)},this.setOpaqueSort=function(C){Me=C},this.setTransparentSort=function(C){Le=C},this.getClearColor=function(C){return C.copy(Gt.getClearColor())},this.setClearColor=function(){Gt.setClearColor(...arguments)},this.getClearAlpha=function(){return Gt.getClearAlpha()},this.setClearAlpha=function(){Gt.setClearAlpha(...arguments)},this.clear=function(C=!0,re=!0,de=!0){let me=0;if(C){let _e=!1;if(O!==null){let Ze=O.texture.format;_e=g.has(Ze)}if(_e){let Ze=O.texture.type,yt=v.has(Ze),it=Gt.getClearColor(),ut=Gt.getClearAlpha(),Lt=it.r,Nt=it.g,Rt=it.b;yt?(P[0]=Lt,P[1]=Nt,P[2]=Rt,P[3]=ut,ue.clearBufferuiv(ue.COLOR,0,P)):(p[0]=Lt,p[1]=Nt,p[2]=Rt,p[3]=ut,ue.clearBufferiv(ue.COLOR,0,p))}else me|=ue.COLOR_BUFFER_BIT}re&&(me|=ue.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),de&&(me|=ue.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),me!==0&&ue.clear(me)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(C){C.setRenderer(this),$=C},this.dispose=function(){t.removeEventListener("webglcontextlost",_t,!1),t.removeEventListener("webglcontextrestored",Bt,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Gt.dispose(),ct.dispose(),je.dispose(),ve.dispose(),Ve.dispose(),Ae.dispose(),ht.dispose(),ze.dispose(),nt.dispose(),Tt.dispose(),Tt.removeEventListener("sessionstart",Sn),Tt.removeEventListener("sessionend",nn),cn.stop()};function _t(C){C.preventDefault(),sp("WebGLRenderer: Context Lost."),V=!0}function Bt(){sp("WebGLRenderer: Context Restored."),V=!1;let C=ee.autoReset,re=qe.enabled,de=qe.autoUpdate,me=qe.needsUpdate,_e=qe.type;Ot(),ee.autoReset=C,qe.enabled=re,qe.autoUpdate=de,qe.needsUpdate=me,qe.type=_e}function rt(C){Tn("WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function Ct(C){let re=C.target;re.removeEventListener("dispose",Ct),Jt(re)}function Jt(C){vn(C),ve.remove(C)}function vn(C){let re=ve.get(C).programs;re!==void 0&&(re.forEach(function(de){nt.releaseProgram(de)}),C.isShaderMaterial&&nt.releaseShaderCache(C))}this.renderBufferDirect=function(C,re,de,me,_e,Ze){re===null&&(re=jt);let yt=_e.isMesh&&_e.matrixWorld.determinantAffine()<0,it=xn(C,re,de,me,_e);b.setMaterial(me,yt);let ut=de.index,Lt=1;if(me.wireframe===!0){if(ut=Ce.getWireframeAttribute(de),ut===void 0)return;Lt=2}let Nt=de.drawRange,Rt=de.attributes.position,De=Nt.start*Lt,rn=(Nt.start+Nt.count)*Lt;Ze!==null&&(De=Math.max(De,Ze.start*Lt),rn=Math.min(rn,(Ze.start+Ze.count)*Lt)),ut!==null?(De=Math.max(De,0),rn=Math.min(rn,ut.count)):Rt!=null&&(De=Math.max(De,0),rn=Math.min(rn,Rt.count));let $t=rn-De;if($t<0||$t===1/0)return;ht.setup(_e,me,it,de,ut);let En,xt=st;if(ut!==null&&(En=$e.get(ut),xt=Ne,xt.setIndex(En)),_e.isMesh)me.wireframe===!0?(b.setLineWidth(me.wireframeLinewidth*tn()),xt.setMode(ue.LINES)):xt.setMode(ue.TRIANGLES);else if(_e.isLine){let An=me.linewidth;An===void 0&&(An=1),b.setLineWidth(An*tn()),_e.isLineSegments?xt.setMode(ue.LINES):_e.isLineLoop?xt.setMode(ue.LINE_LOOP):xt.setMode(ue.LINE_STRIP)}else _e.isPoints?xt.setMode(ue.POINTS):_e.isSprite&&xt.setMode(ue.TRIANGLES);if(_e.isBatchedMesh)if(on.get("WEBGL_multi_draw"))xt.renderMultiDraw(_e._multiDrawStarts,_e._multiDrawCounts,_e._multiDrawCount);else{let An=_e._multiDrawStarts,We=_e._multiDrawCounts,vt=_e._multiDrawCount,pn=ut?$e.get(ut).bytesPerElement:1,li=ve.get(me).currentProgram.getUniforms();for(let vr=0;vr<vt;vr++)li.setValue(ue,"_gl_DrawID",vr),xt.render(An[vr]/pn,We[vr])}else if(_e.isInstancedMesh)xt.renderInstances(De,$t,_e.count);else if(de.isInstancedBufferGeometry){let An=de._maxInstanceCount!==void 0?de._maxInstanceCount:1/0,We=Math.min(de.instanceCount,An);xt.renderInstances(De,$t,We)}else xt.render(De,$t)};function Wt(C,re,de,me){$!==null&&C.isNodeMaterial&&$.setObject(me,C),Ye===!0&&Dt.setState(C,de,!1),C.transparent===!0&&C.side===Er&&C.forceSinglePass===!1?(C.side=Dr,C.needsUpdate=!0,fn(C,re,me),C.side=Va,C.needsUpdate=!0,fn(C,re,me),C.side=Er):fn(C,re,me)}this.compile=function(C,re,de=null){de===null&&(de=C),$!==null&&$.renderStart(C,re,de),D=je.get(de),D.init(re),w.push(D),de.traverseVisible(function(_e){_e.isLight&&_e.layers.test(re.layers)&&(D.pushLight(_e),_e.castShadow&&D.pushShadow(_e))}),C!==de&&C.traverseVisible(function(_e){_e.isLight&&_e.layers.test(re.layers)&&(D.pushLight(_e),_e.castShadow&&D.pushShadow(_e))}),D.setupLights(),$!==null&&$.updateLights(D.state.lightsArray),dt=this.localClippingEnabled,Ye=Dt.init(this.clippingPlanes,dt),Ye===!0&&Dt.setGlobalState(this.clippingPlanes,re),$!==null&&qe.render(D.state.shadowsArray,de,re);let me=new Set;return C.traverse(function(_e){if(!(_e.isMesh||_e.isPoints||_e.isLine||_e.isSprite))return;let Ze=_e.material;if(Ze)if(Array.isArray(Ze))for(let yt=0;yt<Ze.length;yt++){let it=Ze[yt];Wt(it,de,re,_e),me.add(it)}else Wt(Ze,de,re,_e),me.add(Ze)}),D=w.pop(),$!==null&&$.renderEnd(),me},this.compileAsync=function(C,re,de=null){let me=this.compile(C,re,de);return new Promise(_e=>{function Ze(){if(me.forEach(function(yt){let ut=ve.get(yt).currentProgram;(ut===void 0||ut.isReady())&&me.delete(yt)}),me.size===0){_e(C);return}setTimeout(Ze,10)}on.get("KHR_parallel_shader_compile")!==null?Ze():setTimeout(Ze,10)})};let Ut=null;function yn(C){Ut&&Ut(C)}function Sn(){cn.stop()}function nn(){cn.start()}let cn=new U0;cn.setAnimationLoop(yn),typeof self<"u"&&cn.setContext(self),this.setAnimationLoop=function(C){Ut=C,Tt.setAnimationLoop(C),C===null?cn.stop():cn.start()},Tt.addEventListener("sessionstart",Sn),Tt.addEventListener("sessionend",nn),this.render=function(C,re){if(re!==void 0&&re.isCamera!==!0){Tn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(V===!0)return;$!==null&&$.renderStart(C,re);let de=Tt.enabled===!0&&Tt.isPresenting===!0,me=A!==null&&(O===null||de)&&A.begin(z,O);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),re.parent===null&&re.matrixWorldAutoUpdate===!0&&re.updateMatrixWorld(),Tt.enabled===!0&&Tt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Tt.cameraAutoUpdate===!0&&Tt.updateCamera(re),re=Tt.getCamera()),C.isScene===!0&&C.onBeforeRender(z,C,re,O),D=je.get(C,w.length),D.init(re),D.state.textureUnits=Te.getTextureUnits(),w.push(D),ke.multiplyMatrices(re.projectionMatrix,re.matrixWorldInverse),Ge.setFromProjectionMatrix(ke,Ea,re.reversedDepth),dt=this.localClippingEnabled,Ye=Dt.init(this.clippingPlanes,dt),N=ct.get(C,B.length),N.init(),B.push(N),Tt.enabled===!0&&Tt.isPresenting===!0){let yt=z.xr.getDepthSensingMesh();yt!==null&&Pn(yt,re,-1/0,z.sortObjects)}Pn(C,re,0,z.sortObjects),N.finish(),$!==null&&$.updateLights(D.state.lightsArray),z.sortObjects===!0&&N.sort(Me,Le),Pt=Tt.enabled===!1||Tt.isPresenting===!1||Tt.hasDepthSensing()===!1,Pt&&Gt.addToRenderList(N,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ye===!0&&Dt.beginShadows();let _e=D.state.shadowsArray;if(qe.render(_e,C,re),Ye===!0&&Dt.endShadows(),(me&&A.hasRenderPass())===!1){let yt=N.opaque,it=N.transmissive;if(D.setupLights(),re.isArrayCamera){let ut=re.cameras;if(it.length>0)for(let Lt=0,Nt=ut.length;Lt<Nt;Lt++){let Rt=ut[Lt];ei(yt,it,C,Rt)}Pt&&Gt.render(C);for(let Lt=0,Nt=ut.length;Lt<Nt;Lt++){let Rt=ut[Lt];Fn(N,C,Rt,Rt.viewport)}}else it.length>0&&ei(yt,it,C,re),Pt&&Gt.render(C),Fn(N,C,re)}O!==null&&se===0&&(Te.updateMultisampleRenderTarget(O),Te.updateRenderTargetMipmap(O)),me&&A.end(z),C.isScene===!0&&C.onAfterRender(z,C,re),ht.resetDefaultState(),U=-1,H=null,w.pop(),w.length>0?(D=w[w.length-1],Te.setTextureUnits(D.state.textureUnits),Ye===!0&&Dt.setGlobalState(z.clippingPlanes,D.state.camera)):D=null,B.pop(),B.length>0?N=B[B.length-1]:N=null,$!==null&&$.renderEnd()};function Pn(C,re,de,me){if(C.visible===!1)return;if(C.layers.test(re.layers)){if(C.isGroup)de=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(re);else if(C.isLightProbeGrid)D.pushLightProbeGrid(C);else if(C.isLight)D.pushLight(C),C.castShadow&&D.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||C.intersectsFrustum(Ge)){me&&Ke.setFromMatrixPosition(C.matrixWorld).applyMatrix4(ke);let yt=Ae.update(C),it=C.material;it.visible&&N.push(C,yt,it,de,Ke.z,null,re)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||C.intersectsFrustum(Ge))){let yt=Ae.update(C),it=C.material;if(me&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),Ke.copy(C.boundingSphere.center)):(yt.boundingSphere===null&&yt.computeBoundingSphere(),Ke.copy(yt.boundingSphere.center)),Ke.applyMatrix4(C.matrixWorld).applyMatrix4(ke)),Array.isArray(it)){let ut=yt.groups;for(let Lt=0,Nt=ut.length;Lt<Nt;Lt++){let Rt=ut[Lt],De=it[Rt.materialIndex];De&&De.visible&&N.push(C,yt,De,de,Ke.z,Rt,re)}}else it.visible&&N.push(C,yt,it,de,Ke.z,null,re)}}let Ze=C.children;for(let yt=0,it=Ze.length;yt<it;yt++)Pn(Ze[yt],re,de,me)}function Fn(C,re,de,me){let{opaque:_e,transmissive:Ze,transparent:yt}=C;D.setupLightsView(de),Ye===!0&&Dt.setGlobalState(z.clippingPlanes,de),me&&b.viewport(ne.copy(me)),_e.length>0&&qn(_e,re,de),Ze.length>0&&qn(Ze,re,de),yt.length>0&&qn(yt,re,de),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function ei(C,re,de,me){if((de.isScene===!0?de.overrideMaterial:null)!==null)return;if(D.state.transmissionRenderTarget[me.id]===void 0){let De=on.has("EXT_color_buffer_half_float")||on.has("EXT_color_buffer_float");D.state.transmissionRenderTarget[me.id]=new zr(1,1,{generateMipmaps:!0,type:De?Ca:Hr,minFilter:Ha,samples:Math.max(4,Z.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:jn.workingColorSpace})}let Ze=D.state.transmissionRenderTarget[me.id],yt=me.viewport||ne;Ze.setSize(yt.z*z.transmissionResolutionScale,yt.w*z.transmissionResolutionScale);let it=z.getRenderTarget(),ut=z.getActiveCubeFace(),Lt=z.getActiveMipmapLevel();z.setRenderTarget(Ze),z.getClearColor(le),be=z.getClearAlpha(),be<1&&z.setClearColor(16777215,.5),z.clear(),Pt&&Gt.render(de);let Nt=z.toneMapping;z.toneMapping=Gr;let Rt=me.viewport;if(me.viewport!==void 0&&(me.viewport=void 0),D.setupLightsView(me),Ye===!0&&Dt.setGlobalState(z.clippingPlanes,me),qn(C,de,me),Te.updateMultisampleRenderTarget(Ze),Te.updateRenderTargetMipmap(Ze),on.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let rn=0,$t=re.length;rn<$t;rn++){let En=re[rn],{object:xt,geometry:An,material:We,group:vt}=En;if(We.side===Er&&xt.layers.test(me.layers)){let pn=We.side;We.side=Dr,We.needsUpdate=!0,Hn(xt,de,me,An,We,vt),We.side=pn,We.needsUpdate=!0,De=!0}}De===!0&&(Te.updateMultisampleRenderTarget(Ze),Te.updateRenderTargetMipmap(Ze))}z.setRenderTarget(it,ut,Lt),z.setClearColor(le,be),Rt!==void 0&&(me.viewport=Rt),z.toneMapping=Nt}function qn(C,re,de){let me=re.isScene===!0?re.overrideMaterial:null;for(let _e=0,Ze=C.length;_e<Ze;_e++){let yt=C[_e],{object:it,geometry:ut,group:Lt}=yt,Nt=yt.material;Nt.allowOverride===!0&&me!==null&&(Nt=me),it.layers.test(de.layers)&&Hn(it,re,de,ut,Nt,Lt)}}function Hn(C,re,de,me,_e,Ze){$!==null&&_e.isNodeMaterial&&$.setObject(C,_e),C.onBeforeRender(z,re,de,me,_e,Ze),C.modelViewMatrix.multiplyMatrices(de.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),_e.onBeforeRender(z,re,de,me,C,Ze),_e.transparent===!0&&_e.side===Er&&_e.forceSinglePass===!1?(_e.side=Dr,_e.needsUpdate=!0,z.renderBufferDirect(de,re,me,_e,C,Ze),_e.side=Va,_e.needsUpdate=!0,z.renderBufferDirect(de,re,me,_e,C,Ze),_e.side=Er):z.renderBufferDirect(de,re,me,_e,C,Ze),C.onAfterRender(z,re,de,me,_e,Ze)}function fn(C,re,de){re.isScene!==!0&&(re=jt);let me=ve.get(C),_e=D.state.lights,Ze=D.state.shadowsArray,yt=_e.state.version,it=nt.getParameters(C,_e.state,Ze,re,de,D.state.lightProbeGridArray),ut=nt.getProgramCacheKey(it),Lt=me.programs;me.environment=C.isMeshStandardMaterial||C.isMeshLambertMaterial||C.isMeshPhongMaterial?re.environment:null,me.fog=re.fog;let Nt=C.isMeshStandardMaterial||C.isMeshLambertMaterial&&!C.envMap||C.isMeshPhongMaterial&&!C.envMap;me.envMap=Ve.get(C.envMap||me.environment,Nt),me.envMapRotation=me.environment!==null&&C.envMap===null?re.environmentRotation:C.envMapRotation,Lt===void 0&&(C.addEventListener("dispose",Ct),Lt=new Map,me.programs=Lt);let Rt=Lt.get(ut);if(Rt!==void 0){if(me.currentProgram===Rt&&me.lightsStateVersion===yt)return Dn(C,it),Rt}else it.uniforms=nt.getUniforms(C),$!==null&&C.isNodeMaterial&&$.build(C,de,it),C.onBeforeCompile(it,z),Rt=nt.acquireProgram(it,ut),Lt.set(ut,Rt),me.uniforms=it.uniforms;let De=me.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(De.clippingPlanes=Dt.uniform),Dn(C,it),me.needsLights=kn(C),me.lightsStateVersion=yt,me.needsLights&&(De.ambientLightColor.value=_e.state.ambient,De.lightProbe.value=_e.state.probe,De.sunLights.value=_e.state.sun,De.sunLightShadows.value=_e.state.sunShadow,De.directionalLights.value=_e.state.directional,De.directionalLightShadows.value=_e.state.directionalShadow,De.spotLights.value=_e.state.spot,De.spotLightShadows.value=_e.state.spotShadow,De.rectAreaLights.value=_e.state.rectArea,De.ltc_1.value=_e.state.rectAreaLTC1,De.ltc_2.value=_e.state.rectAreaLTC2,De.pointLights.value=_e.state.point,De.pointLightShadows.value=_e.state.pointShadow,De.hemisphereLights.value=_e.state.hemi,De.sunShadowMatrix.value=_e.state.sunShadowMatrix,De.sunShadowCascade.value=_e.state.sunShadowCascade,De.directionalShadowMatrix.value=_e.state.directionalShadowMatrix,De.spotLightMatrix.value=_e.state.spotLightMatrix,De.spotLightMap.value=_e.state.spotLightMap,De.pointShadowMatrix.value=_e.state.pointShadowMatrix),me.lightProbeGrid=D.state.lightProbeGridArray.length>0,me.currentProgram=Rt,me.uniformsList=null,Rt}function Wn(C){if(C.uniformsList===null){let re=C.currentProgram.getUniforms();C.uniformsList=yl.seqWithValue(re.seq,C.uniforms)}return C.uniformsList}function Dn(C,re){let de=ve.get(C);de.outputColorSpace=re.outputColorSpace,de.batching=re.batching,de.batchingColor=re.batchingColor,de.instancing=re.instancing,de.instancingColor=re.instancingColor,de.instancingMorph=re.instancingMorph,de.skinning=re.skinning,de.morphTargets=re.morphTargets,de.morphNormals=re.morphNormals,de.morphColors=re.morphColors,de.morphTargetsCount=re.morphTargetsCount,de.numClippingPlanes=re.numClippingPlanes,de.numIntersection=re.numClipIntersection,de.vertexAlphas=re.vertexAlphas,de.vertexTangents=re.vertexTangents,de.toneMapping=re.toneMapping}function si(C,re){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;_.setFromMatrixPosition(re.matrixWorld);for(let de=0,me=C.length;de<me;de++){let _e=C[de];if(_e.texture!==null&&_e.boundingBox.containsPoint(_))return _e}return null}function xn(C,re,de,me,_e){re.isScene!==!0&&(re=jt),Te.resetTextureUnits();let Ze=re.fog,yt=me.isMeshStandardMaterial||me.isMeshLambertMaterial||me.isMeshPhongMaterial?re.environment:null,it=O===null?z.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:jn.workingColorSpace,ut=me.isMeshStandardMaterial||me.isMeshLambertMaterial&&!me.envMap||me.isMeshPhongMaterial&&!me.envMap,Lt=Ve.get(me.envMap||yt,ut),Nt=me.vertexColors===!0&&!!de.attributes.color&&de.attributes.color.itemSize===4,Rt=!!de.attributes.tangent&&(!!me.normalMap||me.anisotropy>0),De=!!de.morphAttributes.position,rn=!!de.morphAttributes.normal,$t=!!de.morphAttributes.color,En=Gr;me.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(En=z.toneMapping);let xt=de.morphAttributes.position||de.morphAttributes.normal||de.morphAttributes.color,An=xt!==void 0?xt.length:0,We=ve.get(me),vt=D.state.lights;if(Ye===!0&&(dt===!0||C!==H)){let Jn=C===H&&me.id===U;Dt.setState(me,C,Jn)}let pn=!1;me.version===We.__version?(We.needsLights&&We.lightsStateVersion!==vt.state.version||We.outputColorSpace!==it||_e.isBatchedMesh&&We.batching===!1||!_e.isBatchedMesh&&We.batching===!0||_e.isBatchedMesh&&We.batchingColor===!0&&_e._colorsTexture===null||_e.isBatchedMesh&&We.batchingColor===!1&&_e._colorsTexture!==null||_e.isInstancedMesh&&We.instancing===!1||!_e.isInstancedMesh&&We.instancing===!0||_e.isSkinnedMesh&&We.skinning===!1||!_e.isSkinnedMesh&&We.skinning===!0||_e.isInstancedMesh&&We.instancingColor===!0&&_e.instanceColor===null||_e.isInstancedMesh&&We.instancingColor===!1&&_e.instanceColor!==null||_e.isInstancedMesh&&We.instancingMorph===!0&&_e.morphTexture===null||_e.isInstancedMesh&&We.instancingMorph===!1&&_e.morphTexture!==null||We.envMap!==Lt||me.fog===!0&&We.fog!==Ze||We.numClippingPlanes!==void 0&&(We.numClippingPlanes!==Dt.numPlanes||We.numIntersection!==Dt.numIntersection)||We.vertexAlphas!==Nt||We.vertexTangents!==Rt||We.morphTargets!==De||We.morphNormals!==rn||We.morphColors!==$t||We.toneMapping!==En||We.morphTargetsCount!==An||!!We.lightProbeGrid!=D.state.lightProbeGridArray.length>0)&&(pn=!0):(pn=!0,We.__version=me.version);let li=We.currentProgram;pn===!0&&(li=fn(me,re,_e),$&&me.isNodeMaterial&&$.onUpdateProgram(me,li,We));let vr=!1,Gi=!1,Qi=!1,Bn=li.getUniforms(),Zn=We.uniforms;if(b.useProgram(li.program)&&(vr=!0,Gi=!0,Qi=!0),me.id!==U&&(U=me.id,Gi=!0),We.needsLights){let Jn=si(D.state.lightProbeGridArray,_e);We.lightProbeGrid!==Jn&&(We.lightProbeGrid=Jn,Gi=!0)}if(vr||H!==C){b.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),Bn.setValue(ue,"projectionMatrix",C.projectionMatrix),Bn.setValue(ue,"viewMatrix",C.matrixWorldInverse);let ji=Bn.map.cameraPosition;ji!==void 0&&ji.setValue(ue,at.setFromMatrixPosition(C.matrixWorld)),Z.logarithmicDepthBuffer&&Bn.setValue(ue,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial)&&Bn.setValue(ue,"isOrthographic",C.isOrthographicCamera===!0),H!==C&&(H=C,Gi=!0,Qi=!0)}if(We.needsLights&&(vt.state.sunShadowMap.length>0&&Bn.setValue(ue,"sunShadowMap",vt.state.sunShadowMap,Te),vt.state.directionalShadowMap.length>0&&Bn.setValue(ue,"directionalShadowMap",vt.state.directionalShadowMap,Te),vt.state.spotShadowMap.length>0&&Bn.setValue(ue,"spotShadowMap",vt.state.spotShadowMap,Te),vt.state.pointShadowMap.length>0&&Bn.setValue(ue,"pointShadowMap",vt.state.pointShadowMap,Te)),_e.isSkinnedMesh){Bn.setOptional(ue,_e,"bindMatrix"),Bn.setOptional(ue,_e,"bindMatrixInverse");let Jn=_e.skeleton;Jn&&(Jn.boneTexture===null&&Jn.computeBoneTexture(),Bn.setValue(ue,"boneTexture",Jn.boneTexture,Te))}_e.isBatchedMesh&&(Bn.setOptional(ue,_e,"batchingTexture"),Bn.setValue(ue,"batchingTexture",_e._matricesTexture,Te),Bn.setOptional(ue,_e,"batchingIdTexture"),Bn.setValue(ue,"batchingIdTexture",_e._indirectTexture,Te),Bn.setOptional(ue,_e,"batchingColorTexture"),_e._colorsTexture!==null&&Bn.setValue(ue,"batchingColorTexture",_e._colorsTexture,Te));let ki=de.morphAttributes;if((ki.position!==void 0||ki.normal!==void 0||ki.color!==void 0)&&oe.update(_e,de,li),(Gi||We.receiveShadow!==_e.receiveShadow)&&(We.receiveShadow=_e.receiveShadow,Bn.setValue(ue,"receiveShadow",_e.receiveShadow)),(me.isMeshStandardMaterial||me.isMeshLambertMaterial||me.isMeshPhongMaterial)&&me.envMap===null&&re.environment!==null&&(Zn.envMapIntensity.value=re.environmentIntensity),Zn.dfgLUT!==void 0&&(Zn.dfgLUT.value=pw()),Gi){if(Bn.setValue(ue,"toneMappingExposure",z.toneMappingExposure),We.needsLights&&yi(Zn,Qi),Ze&&me.fog===!0&>.refreshFogUniforms(Zn,Ze),gt.refreshMaterialUniforms(Zn,me,ie,Q,D.state.transmissionRenderTarget[C.id]),We.needsLights&&We.lightProbeGrid){let Jn=We.lightProbeGrid;Zn.probesSH.value=Jn.texture,Zn.probesMin.value.copy(Jn.boundingBox.min),Zn.probesMax.value.copy(Jn.boundingBox.max),Zn.probesResolution.value.copy(Jn.resolution)}yl.upload(ue,Wn(We),Zn,Te)}if(me.isShaderMaterial&&me.uniformsNeedUpdate===!0&&(yl.upload(ue,Wn(We),Zn,Te),me.uniformsNeedUpdate=!1),me.isSpriteMaterial&&Bn.setValue(ue,"center",_e.center),Bn.setValue(ue,"modelViewMatrix",_e.modelViewMatrix),Bn.setValue(ue,"normalMatrix",_e.normalMatrix),Bn.setValue(ue,"modelMatrix",_e.matrixWorld),me.uniformsGroups!==void 0){let Jn=me.uniformsGroups;for(let ji=0,ci=Jn.length;ji<ci;ji++){let yr=Jn[ji];ze.update(yr,li),ze.bind(yr,li)}}return li}function yi(C,re){C.ambientLightColor.needsUpdate=re,C.lightProbe.needsUpdate=re,C.sunLights.needsUpdate=re,C.sunLightShadows.needsUpdate=re,C.directionalLights.needsUpdate=re,C.directionalLightShadows.needsUpdate=re,C.pointLights.needsUpdate=re,C.pointLightShadows.needsUpdate=re,C.spotLights.needsUpdate=re,C.spotLightShadows.needsUpdate=re,C.rectAreaLights.needsUpdate=re,C.hemisphereLights.needsUpdate=re}function kn(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return se},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(C,re,de){let me=ve.get(C);me.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,me.__autoAllocateDepthBuffer===!1&&(me.__useRenderToTexture=!1),ve.get(C.texture).__webglTexture=re,ve.get(C.depthTexture).__webglTexture=me.__autoAllocateDepthBuffer?void 0:de,me.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,re){let de=ve.get(C);de.__webglFramebuffer=re,de.__useDefaultFramebuffer=re===void 0},this.setRenderTarget=function(C,re=0,de=0){O=C,W=re,se=de;let me=null,_e=!1,Ze=!1;if(C){let it=ve.get(C);if(it.__useDefaultFramebuffer!==void 0){b.bindFramebuffer(ue.FRAMEBUFFER,it.__webglFramebuffer),ne.copy(C.viewport),ce.copy(C.scissor),pe=C.scissorTest,b.viewport(ne),b.scissor(ce),b.setScissorTest(pe),U=-1;return}else if(it.__webglFramebuffer===void 0)Te.setupRenderTarget(C);else if(it.__hasExternalTextures)Te.rebindTextures(C,ve.get(C.texture).__webglTexture,ve.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){let Nt=C.depthTexture;if(it.__boundDepthTexture!==Nt){if(Nt!==null&&ve.has(Nt)&&(C.width!==Nt.image.width||C.height!==Nt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Te.setupDepthRenderbuffer(C)}}let ut=C.texture;(ut.isData3DTexture||ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(Ze=!0);let Lt=ve.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(Lt[re])?me=Lt[re][de]:me=Lt[re],_e=!0):C.samples>0&&Te.useMultisampledRTT(C)===!1?me=ve.get(C).__webglMultisampledFramebuffer:Array.isArray(Lt)?me=Lt[de]:me=Lt,ne.copy(C.viewport),ce.copy(C.scissor),pe=C.scissorTest}else ne.copy(Ee).multiplyScalar(ie).floor(),ce.copy(Xe).multiplyScalar(ie).floor(),pe=tt;if(de!==0&&(me=T),b.bindFramebuffer(ue.FRAMEBUFFER,me)&&b.drawBuffers(C,me),b.viewport(ne),b.scissor(ce),b.setScissorTest(pe),_e){let it=ve.get(C.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+re,it.__webglTexture,de)}else if(Ze){let it=re;for(let ut=0;ut<C.textures.length;ut++){let Lt=ve.get(C.textures[ut]);ue.framebufferTextureLayer(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0+ut,Lt.__webglTexture,de,it)}}else if(C!==null&&de!==0){let it=ve.get(C.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_2D,it.__webglTexture,de)}U=-1};function ii(C){let re=ve.get(C);return(re.__readFormat!==C.format||re.__readType!==C.type)&&(re.__readFormat=C.format,re.__readType=C.type,re.__formatReadable=Z.textureFormatReadable(C.format),re.__typeReadable=Z.textureTypeReadable(C.type)),re}this.readRenderTargetPixels=function(C,re,de,me,_e,Ze,yt,it=0){if(!(C&&C.isWebGLRenderTarget)){Tn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ut=ve.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&yt!==void 0&&(ut=ut[yt]),ut){b.bindFramebuffer(ue.FRAMEBUFFER,ut);try{let Lt=C.textures[it],Nt=Lt.format,Rt=Lt.type;C.textures.length>1&&ue.readBuffer(ue.COLOR_ATTACHMENT0+it);let De=ii(Lt);if(De.__formatReadable===!1){Tn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(De.__typeReadable===!1){Tn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}re>=0&&re<=C.width-me&&de>=0&&de<=C.height-_e&&ue.readPixels(re,de,me,_e,ft.convert(Nt),ft.convert(Rt),Ze)}finally{let Lt=O!==null?ve.get(O).__webglFramebuffer:null;b.bindFramebuffer(ue.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(C,re,de,me,_e,Ze,yt,it=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ut=ve.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&yt!==void 0&&(ut=ut[yt]),ut)if(re>=0&&re<=C.width-me&&de>=0&&de<=C.height-_e){b.bindFramebuffer(ue.FRAMEBUFFER,ut);let Lt=C.textures[it],Nt=Lt.format,Rt=Lt.type;C.textures.length>1&&ue.readBuffer(ue.COLOR_ATTACHMENT0+it);let De=ii(Lt);if(De.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(De.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let rn=ue.createBuffer();ue.bindBuffer(ue.PIXEL_PACK_BUFFER,rn),ue.bufferData(ue.PIXEL_PACK_BUFFER,Ze.byteLength,ue.STREAM_READ),ue.readPixels(re,de,me,_e,ft.convert(Nt),ft.convert(Rt),0),ue.bindBuffer(ue.PIXEL_PACK_BUFFER,null);let $t=O!==null?ve.get(O).__webglFramebuffer:null;b.bindFramebuffer(ue.FRAMEBUFFER,$t);let En=ue.fenceSync(ue.SYNC_GPU_COMMANDS_COMPLETE,0);return ue.flush(),await r0(ue,En,4),ue.bindBuffer(ue.PIXEL_PACK_BUFFER,rn),ue.getBufferSubData(ue.PIXEL_PACK_BUFFER,0,Ze),ue.bindBuffer(ue.PIXEL_PACK_BUFFER,null),ue.deleteBuffer(rn),ue.deleteSync(En),Ze}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,re=null,de=0){let me=Math.pow(2,-de),_e=Math.floor(C.image.width*me),Ze=Math.floor(C.image.height*me),yt=re!==null?re.x:0,it=re!==null?re.y:0;Te.setTexture2D(C,0),ue.copyTexSubImage2D(ue.TEXTURE_2D,de,0,0,yt,it,_e,Ze),b.unbindTexture()},this.copyTextureToTexture=function(C,re,de=null,me=null,_e=0,Ze=0){let yt,it,ut,Lt,Nt,Rt,De,rn,$t,En=C.isCompressedTexture?C.mipmaps[Ze]:C.image;if(de!==null)yt=de.max.x-de.min.x,it=de.max.y-de.min.y,ut=de.isBox3?de.max.z-de.min.z:1,Lt=de.min.x,Nt=de.min.y,Rt=de.isBox3?de.min.z:0;else{let Zn=Math.pow(2,-_e);yt=Math.floor(En.width*Zn),it=Math.floor(En.height*Zn),C.isDataArrayTexture?ut=En.depth:C.isData3DTexture?ut=Math.floor(En.depth*Zn):ut=1,Lt=0,Nt=0,Rt=0}me!==null?(De=me.x,rn=me.y,$t=me.z):(De=0,rn=0,$t=0);let xt=ft.convert(re.format),An=ft.convert(re.type),We;re.isData3DTexture?(Te.setTexture3D(re,0),We=ue.TEXTURE_3D):re.isDataArrayTexture||re.isCompressedArrayTexture?(Te.setTexture2DArray(re,0),We=ue.TEXTURE_2D_ARRAY):(Te.setTexture2D(re,0),We=ue.TEXTURE_2D),b.activeTexture(ue.TEXTURE0),b.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,re.flipY),b.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,re.premultiplyAlpha),b.pixelStorei(ue.UNPACK_ALIGNMENT,re.unpackAlignment);let vt=b.getParameter(ue.UNPACK_ROW_LENGTH),pn=b.getParameter(ue.UNPACK_IMAGE_HEIGHT),li=b.getParameter(ue.UNPACK_SKIP_PIXELS),vr=b.getParameter(ue.UNPACK_SKIP_ROWS),Gi=b.getParameter(ue.UNPACK_SKIP_IMAGES);b.pixelStorei(ue.UNPACK_ROW_LENGTH,En.width),b.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,En.height),b.pixelStorei(ue.UNPACK_SKIP_PIXELS,Lt),b.pixelStorei(ue.UNPACK_SKIP_ROWS,Nt),b.pixelStorei(ue.UNPACK_SKIP_IMAGES,Rt);let Qi=C.isDataArrayTexture||C.isData3DTexture,Bn=re.isDataArrayTexture||re.isData3DTexture;if(C.isDepthTexture){let Zn=ve.get(C),ki=ve.get(re),Jn=ve.get(Zn.__renderTarget),ji=ve.get(ki.__renderTarget);b.bindFramebuffer(ue.READ_FRAMEBUFFER,Jn.__webglFramebuffer),b.bindFramebuffer(ue.DRAW_FRAMEBUFFER,ji.__webglFramebuffer);for(let ci=0;ci<ut;ci++)Qi&&(ue.framebufferTextureLayer(ue.READ_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ve.get(C).__webglTexture,_e,Rt+ci),ue.framebufferTextureLayer(ue.DRAW_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ve.get(re).__webglTexture,Ze,$t+ci)),ue.blitFramebuffer(Lt,Nt,yt,it,De,rn,yt,it,ue.DEPTH_BUFFER_BIT,ue.NEAREST);b.bindFramebuffer(ue.READ_FRAMEBUFFER,null),b.bindFramebuffer(ue.DRAW_FRAMEBUFFER,null)}else if(_e!==0||C.isRenderTargetTexture||ve.has(C)){let Zn=ve.get(C),ki=ve.get(re);b.bindFramebuffer(ue.READ_FRAMEBUFFER,S),b.bindFramebuffer(ue.DRAW_FRAMEBUFFER,Y);for(let Jn=0;Jn<ut;Jn++)Qi?ue.framebufferTextureLayer(ue.READ_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,Zn.__webglTexture,_e,Rt+Jn):ue.framebufferTexture2D(ue.READ_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_2D,Zn.__webglTexture,_e),Bn?ue.framebufferTextureLayer(ue.DRAW_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ki.__webglTexture,Ze,$t+Jn):ue.framebufferTexture2D(ue.DRAW_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_2D,ki.__webglTexture,Ze),_e!==0?ue.blitFramebuffer(Lt,Nt,yt,it,De,rn,yt,it,ue.COLOR_BUFFER_BIT,ue.NEAREST):Bn?ue.copyTexSubImage3D(We,Ze,De,rn,$t+Jn,Lt,Nt,yt,it):ue.copyTexSubImage2D(We,Ze,De,rn,Lt,Nt,yt,it);b.bindFramebuffer(ue.READ_FRAMEBUFFER,null),b.bindFramebuffer(ue.DRAW_FRAMEBUFFER,null)}else Bn?C.isDataTexture||C.isData3DTexture?ue.texSubImage3D(We,Ze,De,rn,$t,yt,it,ut,xt,An,En.data):re.isCompressedArrayTexture?ue.compressedTexSubImage3D(We,Ze,De,rn,$t,yt,it,ut,xt,En.data):ue.texSubImage3D(We,Ze,De,rn,$t,yt,it,ut,xt,An,En):C.isDataTexture?ue.texSubImage2D(ue.TEXTURE_2D,Ze,De,rn,yt,it,xt,An,En.data):C.isCompressedTexture?ue.compressedTexSubImage2D(ue.TEXTURE_2D,Ze,De,rn,En.width,En.height,xt,En.data):ue.texSubImage2D(ue.TEXTURE_2D,Ze,De,rn,yt,it,xt,An,En);b.pixelStorei(ue.UNPACK_ROW_LENGTH,vt),b.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,pn),b.pixelStorei(ue.UNPACK_SKIP_PIXELS,li),b.pixelStorei(ue.UNPACK_SKIP_ROWS,vr),b.pixelStorei(ue.UNPACK_SKIP_IMAGES,Gi),Ze===0&&re.generateMipmaps&&ue.generateMipmap(We),b.unbindTexture()},this.initRenderTarget=function(C){ve.get(C).__webglFramebuffer===void 0&&Te.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?Te.setTextureCube(C,0):C.isData3DTexture?Te.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?Te.setTexture2DArray(C,0):Te.setTexture2D(C,0),b.unbindTexture()},this.resetState=function(){W=0,se=0,O=null,b.reset(),ht.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ea}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=jn._getDrawingBufferColorSpace(e),t.unpackColorSpace=jn._getUnpackColorSpace()}};var Oc=function(){return Oc=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Oc.apply(this,arguments)},mf=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},mw=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},ur=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},vw={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5126:Float32Array},gw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT4:16},G0={POSITION:"position",NORMAL:"normal",COLOR_0:"color",TEXCOORD_0:"uv",JOINTS_0:"skinIndex",WEIGHTS_0:"skinWeight"},H0={33071:fa,33648:qo,10497:ws},W0={9728:Ki,9729:rr,9984:Sd,9985:hl,9986:fo,9987:Ha};function Ir(n){if(!n)throw Error("E_MODEL_CORRUPT")}function yw(n,e,t){var i,r,a,s=vw[t.componentType],o=gw[t.type];Ir(s&&o&&e&&!t.sparse);var u=s.BYTES_PER_ELEMENT,l=o*u,d=(i=e.byteStride)!==null&&i!==void 0?i:l,f=(r=t.byteOffset)!==null&&r!==void 0?r:0,h=((a=e.byteOffset)!==null&&a!==void 0?a:0)+f,m=t.count;Ir(Number.isSafeInteger(m)&&m>0&&f>=0&&h>=0&&d>=l&&d%u===0&&h%u===0&&f+(m-1)*d+l<=e.byteLength&&h+(m-1)*d+l<=n.length);var y=new s(n.buffer,n.byteOffset+h,((m-1)*d+l)/u);if(d===l)return new Tr(y,o,!!t.normalized);for(var M=new s(m*o),g=0;g<m;g++){var v=g*d/u;M.set(y.subarray(v,v+o),g*o)}return new Tr(M,o,!!t.normalized)}function xw(n,e,t){for(var i="",r=0;r<n.length;r+=8192)i+=String.fromCharCode.apply(String,mw([],mf(n.subarray(r,r+8192)),!1));var a=new Image;return a.onload=function(){return t(!0)},a.onerror=function(){return t(!1)},a.src="data:"+e+";base64,"+btoa(i),a}function J0(n,e){var t,i,r,a,s,o,u,l,d,f,h,m,y,M,g,v,P,p,_,N,D,B,w,A,z,V,$,T,S;Ir(n.byteLength>=28&&n.byteLength<=7e5);var Y=new DataView(n.buffer,n.byteOffset,n.byteLength),W=function(rt){return Y.getUint32(rt,!0)};Ir(W(0)===1179937895&&W(4)===2&&W(8)===n.byteLength&&W(16)===1313821514);var se=20+W(12);Ir(se%4===0&&se+8<=n.byteLength&&W(se+4)===5130562&&W(se)===n.byteLength-se-8);var O=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n.subarray(20,se)));Ir(((y=O.asset)===null||y===void 0?void 0:y.version)==="2.0"&&((M=O.buffers)===null||M===void 0?void 0:M.length)===1&&O.buffers[0].uri===void 0&&((v=(g=O.skins)===null||g===void 0?void 0:g.length)!==null&&v!==void 0?v:0)<=4&&((p=(P=O.animations)===null||P===void 0?void 0:P.length)!==null&&p!==void 0?p:0)<=16);var U=n.subarray(se+8),H=new Map,ne=new Map,ce=new Map,pe=new Map,le=new Set,be=new Set;function Pe(rt){if(!ce.has(rt)){var Ct=O.accessors[rt];ce.set(rt,yw(U,O.bufferViews[Ct.bufferView],Ct))}return ce.get(rt)}function Q(rt,Ct){var Jt,vn,Wt,Ut,yn,Sn,nn,cn,Pn,Fn,ei,qn;if(!rt)return null;var Hn=(vn=(Jt=rt.extensions)===null||Jt===void 0?void 0:Jt.KHR_texture_transform)!==null&&vn!==void 0?vn:{};Ir(((Ut=(Wt=Hn.texCoord)!==null&&Wt!==void 0?Wt:rt.texCoord)!==null&&Ut!==void 0?Ut:0)===0);var fn=JSON.stringify([rt.index,Ct,Hn]);if(H.has(fn))return H.get(fn);var Wn=O.textures[rt.index],Dn=O.images[Wn.source],si=(Sn=(yn=O.samplers)===null||yn===void 0?void 0:yn[Wn.sampler])!==null&&Sn!==void 0?Sn:{},xn=new mr;if(xn.colorSpace=Ct,xn.flipY=!1,xn.wrapS=H0[(nn=si.wrapS)!==null&&nn!==void 0?nn:10497],xn.wrapT=H0[(cn=si.wrapT)!==null&&cn!==void 0?cn:10497],xn.magFilter=W0[(Pn=si.magFilter)!==null&&Pn!==void 0?Pn:9729],xn.minFilter=W0[(Fn=si.minFilter)!==null&&Fn!==void 0?Fn:9987],Hn.offset&&xn.offset.fromArray(Hn.offset),Hn.scale&&xn.repeat.fromArray(Hn.scale),xn.rotation=(ei=Hn.rotation)!==null&&ei!==void 0?ei:0,H.set(fn,xn),!ne.has(Wn.source)){var yi=O.bufferViews[Dn.bufferView],kn=(qn=yi?.byteOffset)!==null&&qn!==void 0?qn:0;Ir(yi&&!Dn.uri&&["image/png","image/jpeg"].includes(Dn.mimeType)&&kn+yi.byteLength<=U.length);var ii={textures:[],ready:!1,failed:!1};ne.set(Wn.source,ii),ii.image=xw(U.subarray(kn,kn+yi.byteLength),Dn.mimeType,function(re){var de,me;if(ii.ready=!0,ii.failed=!re,re)try{for(var _e=ur(ii.textures),Ze=_e.next();!Ze.done;Ze=_e.next()){var yt=Ze.value;yt.needsUpdate=!0}}catch(it){de={error:it}}finally{try{Ze&&!Ze.done&&(me=_e.return)&&me.call(_e)}finally{if(de)throw de.error}}e?.()})}var C=ne.get(Wn.source);return xn.image=C.image,C.textures.push(xn),C.ready&&!C.failed&&(xn.needsUpdate=!0),xn}var ie=new Map;function Me(rt,Ct){var Jt,vn,Wt,Ut,yn,Sn,nn,cn,Pn,Fn,ei,qn,Hn,fn,Wn,Dn,si,xn,yi=String(rt)+"/"+Ct;if(ie.has(yi))return ie.get(yi);var kn=(vn=(Jt=O.materials)===null||Jt===void 0?void 0:Jt[rt])!==null&&vn!==void 0?vn:{},ii=(Wt=kn.pbrMetallicRoughness)!==null&&Wt!==void 0?Wt:{},C=(Ut=ii.baseColorFactor)!==null&&Ut!==void 0?Ut:[1,1,1,1],re=(yn=kn.alphaMode)!==null&&yn!==void 0?yn:"OPAQUE",de={name:(Sn=kn.name)!==null&&Sn!==void 0?Sn:"",color:new Rn().fromArray(C),vertexColors:Ct,map:Q(ii.baseColorTexture,pr),side:kn.doubleSided?Er:Va,opacity:re==="OPAQUE"?1:C[3],transparent:re==="BLEND",depthWrite:re!=="BLEND",alphaTest:re==="MASK"?(nn=kn.alphaCutoff)!==null&&nn!==void 0?nn:.5:0},me;if(!((cn=kn.extensions)===null||cn===void 0)&&cn.KHR_materials_unlit)me=new Vr(de);else{var _e=Q(ii.metallicRoughnessTexture,Nr);me=new ll(Oc(Oc({},de),{roughness:(Pn=ii.roughnessFactor)!==null&&Pn!==void 0?Pn:1,metalness:(Fn=ii.metallicFactor)!==null&&Fn!==void 0?Fn:1,roughnessMap:_e,metalnessMap:_e,normalMap:Q(kn.normalTexture,Nr),normalScale:new qt().setScalar((qn=(ei=kn.normalTexture)===null||ei===void 0?void 0:ei.scale)!==null&&qn!==void 0?qn:1),aoMap:Q(kn.occlusionTexture,Nr),aoMapIntensity:(fn=(Hn=kn.occlusionTexture)===null||Hn===void 0?void 0:Hn.strength)!==null&&fn!==void 0?fn:1,emissive:new Rn().fromArray((Wn=kn.emissiveFactor)!==null&&Wn!==void 0?Wn:[0,0,0]),emissiveMap:Q(kn.emissiveTexture,pr),emissiveIntensity:(xn=(si=(Dn=kn.extensions)===null||Dn===void 0?void 0:Dn.KHR_materials_emissive_strength)===null||si===void 0?void 0:si.emissiveStrength)!==null&&xn!==void 0?xn:1})),me.normalScale.y*=-1}return be.add(me),ie.set(yi,me),me}var Le=O.meshes.map(function(rt){return rt.primitives.map(function(Ct){var Jt,vn,Wt;Ir(((Wt=Ct.mode)!==null&&Wt!==void 0?Wt:4)===4&&Ct.attributes.POSITION!==void 0&&!Ct.targets);var Ut=new sr;try{for(var yn=ur(Object.entries(Ct.attributes)),Sn=yn.next();!Sn.done;Sn=yn.next()){var nn=mf(Sn.value,2),cn=nn[0],Pn=nn[1];Ir(Object.hasOwn(G0,cn)),Ut.setAttribute(G0[cn],Pe(Pn))}}catch(Fn){Jt={error:Fn}}finally{try{Sn&&!Sn.done&&(vn=yn.return)&&vn.call(yn)}finally{if(Jt)throw Jt.error}}return Ct.indices!==void 0&&Ut.setIndex(Pe(Ct.indices)),Ut.attributes.normal||Ut.computeVertexNormals(),le.add(Ut),{geo:Ut,mat:Me(Ct.material,!!Ut.attributes.color)}})}),Ee=new Set;try{for(var Xe=ur((_=O.skins)!==null&&_!==void 0?_:[]),tt=Xe.next();!tt.done;tt=Xe.next()){var Ge=tt.value;try{for(var Ye=(r=void 0,ur((N=Ge.joints)!==null&&N!==void 0?N:[])),dt=Ye.next();!dt.done;dt=Ye.next()){var ke=dt.value;Ee.add(ke)}}catch(rt){r={error:rt}}finally{try{dt&&!dt.done&&(a=Ye.return)&&a.call(Ye)}finally{if(r)throw r.error}}}}catch(rt){t={error:rt}}finally{try{tt&&!tt.done&&(i=Xe.return)&&i.call(Xe)}finally{if(t)throw t.error}}var at=new ir,Ke=new Set,jt=new Map,Pt=[];function tn(rt,Ct){var Jt,vn,Wt,Ut,yn,Sn;Ir(!Ke.has(rt)&&Ke.size<128),Ke.add(rt);var nn=O.nodes[rt],cn=Ee.has(rt)?new el:new ir;if(cn.name=(yn=nn.name)!==null&&yn!==void 0?yn:"",cn.userData.gltfNodeIndex=rt,jt.set(rt,cn),cn.name&&!pe.has(cn.name)&&pe.set(cn.name,cn),nn.matrix?cn.matrix.fromArray(nn.matrix).decompose(cn.position,cn.quaternion,cn.scale):(nn.translation&&cn.position.fromArray(nn.translation),nn.rotation&&cn.quaternion.fromArray(nn.rotation),nn.scale&&cn.scale.fromArray(nn.scale)),Ct.add(cn),nn.mesh!==void 0)try{for(var Pn=ur(Le[nn.mesh]),Fn=Pn.next();!Fn.done;Fn=Pn.next()){var ei=Fn.value,qn=ei.geo,Hn=ei.mat;if(nn.skin!==void 0){var fn=new rc(qn,Hn);fn.userData.gltfSkinIndex=nn.skin,cn.add(fn),Pt.push(fn)}else cn.add(new ai(qn,Hn))}}catch(xn){Jt={error:xn}}finally{try{Fn&&!Fn.done&&(vn=Pn.return)&&vn.call(Pn)}finally{if(Jt)throw Jt.error}}try{for(var Wn=ur((Sn=nn.children)!==null&&Sn!==void 0?Sn:[]),Dn=Wn.next();!Dn.done;Dn=Wn.next()){var si=Dn.value;tn(si,cn)}}catch(xn){Wt={error:xn}}finally{try{Dn&&!Dn.done&&(Ut=Wn.return)&&Ut.call(Wn)}finally{if(Wt)throw Wt.error}}}try{for(var ue=ur((B=O.scenes[(D=O.scene)!==null&&D!==void 0?D:0].nodes)!==null&&B!==void 0?B:[]),ln=ue.next();!ln.done;ln=ue.next()){var on=ln.value;tn(on,at)}}catch(rt){s={error:rt}}finally{try{ln&&!ln.done&&(o=ue.return)&&o.call(ue)}finally{if(s)throw s.error}}at.updateMatrixWorld(!0);var Z=((w=O.skins)!==null&&w!==void 0?w:[]).map(function(rt){var Ct,Jt=(Ct=rt.joints)!==null&&Ct!==void 0?Ct:[];Ir(Jt.length>0&&Jt.length<=64);var vn;if(rt.inverseBindMatrices!==void 0){var Wt=Pe(rt.inverseBindMatrices).array;vn=Array.from({length:Jt.length},function(Ut,yn){return new Un().fromArray(Wt,yn*16)})}else vn=Jt.map(function(){return new Un});return{joints:Jt,inverseBindMatrices:vn}});try{for(var b=ur(Pt),ee=b.next();!ee.done;ee=b.next()){var ve=ee.value,Te=Z[ve.userData.gltfSkinIndex];Ir(Te);var Ve=Te.joints.map(function(rt){return jt.get(rt)});Ir(Ve.every(Boolean)),ve.bind(new tl(Ve,Te.inverseBindMatrices.map(function(rt){return rt.clone()})),new Un)}}catch(rt){u={error:rt}}finally{try{ee&&!ee.done&&(l=b.return)&&l.call(b)}finally{if(u)throw u.error}}var $e=[],Ce=new Map;try{for(var Ae=ur(((A=O.animations)!==null&&A!==void 0?A:[]).entries()),nt=Ae.next();!nt.done;nt=Ae.next()){var gt=mf(nt.value,2),ct=gt[0],je=gt[1],Dt=je.name||"clip_"+ct,qe=[],Gt=0;try{for(var oe=(h=void 0,ur((z=je.channels)!==null&&z!==void 0?z:[])),st=oe.next();!st.done;st=oe.next()){var Ne=st.value,ft=(V=Ne.target)===null||V===void 0?void 0:V.node,ht=($=Ne.target)===null||$===void 0?void 0:$.path;if(!(ft===void 0||!["translation","rotation","scale"].includes(ht))){var ze=(T=je.samplers)===null||T===void 0?void 0:T[Ne.sampler];Ir(ze);var Ot=(S=ze.interpolation)!==null&&S!==void 0?S:"LINEAR";Ir(Ot==="LINEAR"||Ot==="STEP");var Tt=Pe(ze.input).array,_t=Pe(ze.output).array;Tt.length&&(Gt=Math.max(Gt,Tt[Tt.length-1])),qe.push({nodeIndex:ft,path:ht,interp:Ot,times:Tt,values:_t})}}}catch(rt){h={error:rt}}finally{try{st&&!st.done&&(m=oe.return)&&m.call(oe)}finally{if(h)throw h.error}}var Bt={name:Dt,duration:Gt,tracks:qe};$e.push(Bt),Ce.has(Dt)||Ce.set(Dt,Bt)}}catch(rt){d={error:rt}}finally{try{nt&&!nt.done&&(f=Ae.return)&&f.call(Ae)}finally{if(d)throw d.error}}return{root:at,nodesByName:pe,skins:Z,animations:$e,animationsByName:Ce,geometries:le,materials:be,textures:H,imageStatus:function(){var rt,Ct,Jt=0,vn=0;try{for(var Wt=ur(ne.values()),Ut=Wt.next();!Ut.done;Ut=Wt.next()){var yn=Ut.value;yn.ready||Jt++,yn.failed&&vn++}}catch(Sn){rt={error:Sn}}finally{try{Ut&&!Ut.done&&(Ct=Wt.return)&&Ct.call(Wt)}finally{if(rt)throw rt.error}}return{texturesPending:Jt,textureErrors:vn}}}}function _w(n,e,t){var i,r,a,s,o,u,l,d,f,h,m,y,M=(o=e.materialMode)!==null&&o!==void 0?o:"asset",g=!e.overrideMaterialName||n.name===e.overrideMaterialName,v=g&&Object.keys(t).length>0;if(M==="asset"&&!v&&((u=e.opacity)!==null&&u!==void 0?u:1)===1&&(!e.tintColor||e.tintColor==="#ffffff")&&((l=e.roughnessScale)!==null&&l!==void 0?l:1)===1&&((d=e.metalnessScale)!==null&&d!==void 0?d:1)===1)return n;var P={lambert:or,unlit:Vr,standard:ll}[M],p;if(!P||n.constructor===P)p=n.clone();else{p=new P;try{for(var _=ur(["name","map","alphaTest","transparent","opacity","side","depthWrite","vertexColors","roughness","metalness","roughnessMap","metalnessMap","normalMap","aoMap","aoMapIntensity","emissiveMap","emissiveIntensity"]),N=_.next();!N.done;N=_.next()){var D=N.value;D in p&&D in n&&(p[D]=n[D])}}catch(A){i={error:A}}finally{try{N&&!N.done&&(r=_.return)&&r.call(_)}finally{if(i)throw i.error}}try{for(var B=ur(["color","emissive","normalScale"]),w=B.next();!w.done;w=B.next()){var D=w.value;p[D]&&n[D]&&p[D].copy(n[D])}}catch(A){a={error:A}}finally{try{w&&!w.done&&(s=B.return)&&s.call(B)}finally{if(a)throw a.error}}}return e.tintColor&&p.color.multiply(new Rn(e.tintColor)),p.opacity*=(f=e.opacity)!==null&&f!==void 0?f:1,p.opacity<1&&((h=e.opacity)!==null&&h!==void 0?h:1)<1&&(p.transparent=!0,p.depthWrite=!1),p.isMeshStandardMaterial&&(p.roughness=Math.min(1,p.roughness*((m=e.roughnessScale)!==null&&m!==void 0?m:1)),p.metalness=Math.min(1,p.metalness*((y=e.metalnessScale)!==null&&y!==void 0?y:1))),v&&(t.texture&&(p.map=t.texture),t.normalMap&&"normalMap"in p&&(p.normalMap=t.normalMap),t.emissiveMap&&"emissiveMap"in p&&(p.emissiveMap=t.emissiveMap)),p}function $0(n,e,t){var i,r,a;e===void 0&&(e={}),t===void 0&&(t={});var s=e.subNode?n.nodesByName.get(e.subNode):n.root;if(!s)throw Error("E_MODEL_SUBNODE "+e.subNode);var o=s.clone(!0),u=new ir,l=new Map;if(e.subNode&&(o.position.set(0,0,0),s.parent)){var d=s.parent.matrixWorld.clone().setPosition(0,0,0);o.updateMatrix(),o.matrix.premultiply(d),o.matrixAutoUpdate=!1}u.add(o);var f=new Map,h=[];if(o.traverse(function(D){var B,w;if(((B=D.userData)===null||B===void 0?void 0:B.gltfNodeIndex)!==void 0&&f.set(D.userData.gltfNodeIndex,D),!!D.isMesh){var A=D.material;l.has(A)||l.set(A,_w(A,e,t)),D.material=l.get(A),D.castShadow=!!e.castShadow,D.receiveShadow=!!e.receiveShadow,D.isSkinnedMesh&&((w=D.userData)===null||w===void 0?void 0:w.gltfSkinIndex)!==void 0&&h.push(D)}}),h.length){u.updateMatrixWorld(!0);try{for(var m=ur(h),y=m.next();!y.done;y=m.next()){var M=y.value,g=(a=n.skins)===null||a===void 0?void 0:a[M.userData.gltfSkinIndex];if(g){var v=g.joints.map(function(D){return f.get(D)}).filter(Boolean);v.length===g.joints.length&&M.bind(new tl(v,g.inverseBindMatrices.map(function(D){return D.clone()})),new Un)}}}catch(D){i={error:D}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(i)throw i.error}}}u.userData.clonedByIndex=f,u.userData.template=n;var P=new Qr().setFromObject(u,!0);if(!P.isEmpty()){var p=P.getSize(new ge),_=new ge,N=Math.max(p.x,p.y,p.z);(e.pivotMode==="center"||e.pivotMode==="bottom-center")&&(P.getCenter(_),e.pivotMode==="bottom-center"&&(_.y=P.min.y)),e.normalizeSize>0&&N>0&&u.scale.setScalar(e.normalizeSize/N),u.position.copy(_).multiplyScalar(-u.scale.x),u.userData.modelBounds={width:p.x*u.scale.x,height:p.y*u.scale.y,depth:p.z*u.scale.z}}return u}var Lp=new ge,X0=new ge,Dp=new kr,Y0=new kr;function q0(n,e,t,i){var r=n.times,a=n.values,s=r.length,o=n.path==="rotation"?4:3;if(s!==0){var u=0,l=0,d=0;if(s>1&&e>r[0])if(e>=r[s-1])u=l=s-1;else{for(var f=0,h=s-1;f+1<h;){var m=f+h>>1;r[m]<=e?f=m:h=m}u=f,l=h,d=n.interp==="STEP"?0:(e-r[u])/Math.max(1e-8,r[l]-r[u])}var y=u*o,M=l*o;if(n.path==="rotation"){if(Dp.set(a[y],a[y+1],a[y+2],a[y+3]),u===l||d===0){i.copy(Dp);return}Y0.set(a[M],a[M+1],a[M+2],a[M+3]),i.copy(Dp).slerp(Y0,d)}else{if(Lp.set(a[y],a[y+1],a[y+2]),u===l||d===0){t.copy(Lp);return}X0.set(a[M],a[M+1],a[M+2]),t.copy(Lp).lerp(X0,d)}}}function Z0(n,e,t){if(e<=0)return 0;if(t==="once")return Math.min(e,Math.max(0,n));if(t==="pingpong"){var i=e*2,r=(n%i+i)%i;return r<=e?r:i-r}return(n%e+e)%e}function K0(n){var e,t,i,r,a,s,o,u=(a=n?.userData)===null||a===void 0?void 0:a.template,l=(s=n?.userData)===null||s===void 0?void 0:s.clonedByIndex;if(!(!((o=u?.animations)===null||o===void 0)&&o.length)||!l)return null;var d=new Map;try{for(var f=ur(u.animations),h=f.next();!h.done;h=f.next()){var m=h.value;try{for(var y=(i=void 0,ur(m.tracks)),M=y.next();!M.done;M=y.next()){var g=M.value,v=l.get(g.nodeIndex);v&&!d.has(g.nodeIndex)&&d.set(g.nodeIndex,{pos:v.position.clone(),quat:v.quaternion.clone(),scl:v.scale.clone()})}}catch(z){i={error:z}}finally{try{M&&!M.done&&(r=y.return)&&r.call(y)}finally{if(i)throw i.error}}}}catch(z){e={error:z}}finally{try{h&&!h.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}var P=function(){var z,V;try{for(var $=ur(d),T=$.next();!T.done;T=$.next()){var S=mf(T.value,2),Y=S[0],W=S[1],se=l.get(Y);se&&(se.position.copy(W.pos),se.quaternion.copy(W.quat),se.scale.copy(W.scl))}}catch(O){z={error:O}}finally{try{T&&!T.done&&(V=$.return)&&V.call($)}finally{if(z)throw z.error}}},p=null,_=null,N=0,D=0,B=new ge,w=new kr,A=function(){var z,V,$,T;P();var S=_&&D>0?Math.min(1,N/D):1;if(_&&S<1){var Y=Z0(_.time,_.clip.duration,_.loop);try{for(var W=ur(_.clip.tracks),se=W.next();!se.done;se=W.next()){var O=se.value,U=l.get(O.nodeIndex);U&&(q0(O,Y,B,w),O.path==="translation"?U.position.copy(B):O.path==="rotation"?U.quaternion.copy(w):O.path==="scale"&&U.scale.copy(B))}}catch(pe){z={error:pe}}finally{try{se&&!se.done&&(V=W.return)&&V.call(W)}finally{if(z)throw z.error}}}if(p){var H=Z0(p.time,p.clip.duration,p.loop);try{for(var ne=ur(p.clip.tracks),ce=ne.next();!ce.done;ce=ne.next()){var O=ce.value,U=l.get(O.nodeIndex);U&&(q0(O,H,B,w),O.path==="translation"?S<1?U.position.lerp(B,S):U.position.copy(B):O.path==="rotation"?S<1?U.quaternion.slerp(w,S):U.quaternion.copy(w):O.path==="scale"&&(S<1?U.scale.lerp(B,S):U.scale.copy(B)))}}catch(pe){$={error:pe}}finally{try{ce&&!ce.done&&(T=ne.return)&&T.call(ne)}finally{if($)throw $.error}}}};return{play:function(z,V){var $=V===void 0?{}:V,T=$.loop,S=T===void 0?"repeat":T,Y=$.speed,W=Y===void 0?1:Y,se=$.fadeSeconds,O=se===void 0?.15:se,U=$.restart,H=U===void 0?!1:U,ne=$.startTime,ce=ne===void 0?0:ne,pe=z?u.animationsByName.get(z):u.animations[0];return pe?p?.clip===pe&&!H&&p.playing?(p.loop=S,p.speed=W,!0):(_=p&&O>0?Oc({},p):null,D=_?O:0,N=0,p={clip:pe,loop:S,speed:W,time:ce,playing:!0,ended:!1},A(),!0):!1},step:function(z,V){if(!p||!p.playing)return!1;var $=Math.max(0,z);_&&D>0&&(_.time+=$*_.speed,N+=$,N>=D&&(_=null,D=0)),p.time+=$*p.speed;var T=null;return p.loop==="once"&&p.clip.duration>0&&p.time>=p.clip.duration&&(p.time=p.clip.duration,p.playing=!1,p.ended||(p.ended=!0,T=p.clip.name)),A(),T&&V?.(T),!0},reset:function(){p=null,_=null,N=0,D=0,P()},snapshot:function(){var z,V,$;return{clip:(V=(z=p?.clip)===null||z===void 0?void 0:z.name)!==null&&V!==void 0?V:null,time:p?Number(p.time.toFixed(4)):0,playing:!!p?.playing,loop:($=p?.loop)!==null&&$!==void 0?$:"repeat",clips:u.animations.map(function(T){return T.name})}}}}var Bc=function(){return Bc=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Bc.apply(this,arguments)},gn=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Ya=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Q0=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function eg(n,e,t,i){for(var r,a,s,o,u,l,d,f=new ge,h=new ge,m=new ha,y=n;y?.contract==="native.mesh3d.v1";y=e(y.parentId)){var M=t(y),g=i.get(y.id),v=g?.mode==="dynamic",P=v&&g.captured,p=P?Math.min(1,((r=g.captureElapsed)!==null&&r!==void 0?r:0)/.55):0,_=g?.captureTarget,N=1-p*.65;h.set(M.sx*N,M.sy*N,M.sz*N),m.set(v?-((a=g.spin)!==null&&a!==void 0?a:0):M.rx,g?.mode==="kinematic"?-((s=g.angle)!==null&&s!==void 0?s:M.ry):M.ry,v?((o=g.spin)!==null&&o!==void 0?o:0)*.22:M.rz),f.multiply(h).applyEuler(m),h.set(((u=g?.x)!==null&&u!==void 0?u:M.x)+(P&&_?(_.x-g.x)*p:0),((l=g?.y)!==null&&l!==void 0?l:M.y)-p*.45,((d=g?.z)!==null&&d!==void 0?d:M.z)+(P&&_?(_.z-g.z)*p:0)),f.add(h)}return{x:f.x,y:f.y,z:f.z}}function Mw(n){for(var e=atob(n),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);for(var r=new DataView(t.buffer,t.byteOffset,t.byteLength),a=r.getUint32(8,!0),s=r.getUint32(12,!0),o=new Float32Array(a*3),u=new Float32Array(a*3),l=new Float32Array(a*2),d=16,i=0;i<a;i++)o[i*3]=r.getFloat32(d,!0),o[i*3+1]=r.getFloat32(d+4,!0),o[i*3+2]=r.getFloat32(d+8,!0),u[i*3]=r.getFloat32(d+12,!0),u[i*3+1]=r.getFloat32(d+16,!0),u[i*3+2]=r.getFloat32(d+20,!0),l[i*2]=r.getFloat32(d+24,!0),l[i*2+1]=r.getFloat32(d+28,!0),d+=32;for(var f=new Uint16Array(s),i=0;i<s;i++)f[i]=r.getUint16(d+i*2,!0);var h=new sr;return h.setAttribute("position",new fi(o,3)),h.setAttribute("normal",new fi(u,3)),h.setAttribute("uv",new fi(l,2)),h.setIndex(Array.from(f)),h}function j0(n,e,t){return!n||t>=1?0:t<=-1?1.1:(1-t)*.55}function Sw(n,e,t){var i,r,a,s,o,u,l,d,f,h,m,y,M,g,v,P,p,_=new ir,N=!!n.fairwayRamp,D=(M=n.cupX)!==null&&M!==void 0?M:0,B=(g=n.cupZ)!==null&&g!==void 0?g:-4.8,w=(v=n.cupRadius)!==null&&v!==void 0?v:.23,A=new Lr(1,1,1),z=new Map,V=function(Ae,nt,gt,ct,je,Dt,qe){var Gt=z.get(qe);Gt||(Gt=new or({color:qe}),z.set(qe,Gt));var oe=new ai(A,Gt);oe.position.set(Ae,nt,gt),oe.scale.set(ct,je,Dt),_.add(oe)};try{for(var $=gn([-3.2,3.2]),T=$.next();!T.done;T=$.next()){var S=T.value;V(S,-.65,0,.2,1.1,14.6,"#a1b8b1"),V(S-Math.sign(S)*.1,-.18,0,.2,.25,14.4,"#e9cea5")}}catch(Ae){i={error:Ae}}finally{try{T&&!T.done&&(r=$.return)&&r.call($)}finally{if(i)throw i.error}}try{for(var Y=gn([-7.2,7.2]),W=Y.next();!W.done;W=Y.next()){var se=W.value;V(0,-.65,se,6.4,1.1,.2,"#a1b8b1"),V(0,-.18,se-Math.sign(se)*.1,6.2,.25,.2,"#e9cea5")}}catch(Ae){a={error:Ae}}finally{try{W&&!W.done&&(s=Y.return)&&s.call(Y)}finally{if(a)throw a.error}}var O=.5,U=.5;if(t){var H=t.getAttribute("uv"),ne=t.getAttribute("normal");if(H&&ne){for(var ce=0;ce<ne.count&&ne.getY(ce)<.9;)ce++;ce<H.count&&(O=H.getX(ce),U=H.getY(ce))}}var pe=!!(e&&(!((P=e.image)===null||P===void 0)&&P.complete)&&((p=e.image)===null||p===void 0?void 0:p.naturalWidth)>0),le=pe?new or({map:e}):new or({color:"#6ec458"}),be=pe?new or({map:e,color:"#779263"}):new or({color:"#5a9949"});e&&!pe&&(le.userData.pendingTex={tex:e,color:"#ffffff"},be.userData.pendingTex={tex:e,color:"#779263"});var Pe=N?[[-7,-1],[-1,1],[1,7]]:[[-7,7]];try{for(var Q=gn(Pe),ie=Q.next();!ie.done;ie=Q.next()){var Me=Ya(ie.value,2),Le=Me[0],Ee=Me[1],Xe=new al;if(Xe.moveTo(-3,Le),Xe.lineTo(3,Le),Xe.lineTo(3,Ee),Xe.lineTo(-3,Ee),Xe.closePath(),B>Le&&B<Ee){var tt=new oo;tt.absarc(D,B,w,0,Math.PI*2,!0),Xe.holes.push(tt)}for(var Ge=new vc(Xe,32),Ye=Ge.getAttribute("position"),dt=!1,ke=!1,at=0;at<Ye.count;at++){var Ke=Ye.getX(at),jt=Ye.getY(at),Pt=j0(N,Ke,jt);Pt===0&&(dt=!0),Pt>0&&(ke=!0),Ye.setXYZ(at,Ke,Pt,jt)}var tn=Ge.getIndex();if(tn)for(var at=0;at<tn.count;at+=3){var ue=tn.getX(at+1);tn.setX(at+1,tn.getX(at+2)),tn.setX(at+2,ue)}Ge.computeVertexNormals();for(var ln=Ge.getAttribute("uv"),at=0;at<ln.count;at++)ln.setXY(at,O,U);var on=new ai(Ge,N&&dt&&ke?be:le);on.name="continuous-fairway",_.add(on)}}catch(Ae){o={error:Ae}}finally{try{ie&&!ie.done&&(u=Q.return)&&u.call(Q)}finally{if(o)throw o.error}}var Z="#d69260",b="#f1bd87";try{for(var ee=gn([-3.1,3.1]),ve=ee.next();!ve.done;ve=ee.next()){var S=ve.value;V(S,.12,0,.2,.3,14.2,Z),V(S,.29,0,.22,.04,14.2,b)}}catch(Ae){l={error:Ae}}finally{try{ve&&!ve.done&&(d=ee.return)&&d.call(ee)}finally{if(l)throw l.error}}try{for(var Te=gn([-7.1,7.1]),Ve=Te.next();!Ve.done;Ve=Te.next()){var se=Ve.value;V(0,j0(N,0,se>0?6:-6)+.12,se,6.4,.3,.2,Z)}}catch(Ae){f={error:Ae}}finally{try{Ve&&!Ve.done&&(h=Te.return)&&h.call(Te)}finally{if(f)throw f.error}}if(N)try{for(var $e=gn([-3.1,3.1]),Ce=$e.next();!Ce.done;Ce=$e.next()){var S=Ce.value;V(S,.7,-4.5,.2,1.1,5.2,Z)}}catch(Ae){m={error:Ae}}finally{try{Ce&&!Ce.done&&(y=$e.return)&&y.call($e)}finally{if(m)throw m.error}}return _}function bw(n){var e,t=new ir,i=(e=n.cupRadius)!==null&&e!==void 0?e:.23,r=new ai(new so(i,i*.89,.48,24,1,!0),new or({color:"#244640",side:Er}));r.position.y=-.24,t.add(r);var a=new ai(new il(i*.91,24),new Vr({color:"#082c2b"}));a.rotation.x=-Math.PI/2,a.position.y=-.475,t.add(a);var s=new ai(new so(i,i*.978,.09,24,1,!0),new or({color:"#eee9cf",side:Er}));s.position.y=-.045,t.add(s);var o=new ai(new ol(i,i+.06,24),new or({color:"#fff7d1"}));return o.rotation.x=-Math.PI/2,o.position.y=.004,t.add(o),t}function ww(){for(var n,e,t=new ir,i=new Lr(.18,1,.18),r=new or({color:"#b27b59"}),a=new Lr(1.5,.2,1.6),s=new or({color:"#82b88b"}),o=new cs(.62,7,5),u=new cs(.49,7,5),l=new or({color:"#77b86b"}),d=new or({color:"#3e9d79"}),f=new Aa(i,r,14),h=new Aa(a,s,14),m=5,y=9,M=new Aa(o,l,m),g=new Aa(u,l,m),v=new Aa(o,d,y),P=new Aa(u,d,y),p=new Un,_=0,N=0,D=0;D<14;D++){var B=D%2?-1:1,w=B*(3.8+D%3*.35),A=-6.5+Math.floor(D/2)*2;p.makeTranslation(w,-.02,A),f.setMatrixAt(D,p),p.makeTranslation(w,-.48,A),h.setMatrixAt(D,p),D%3===0?(p.makeTranslation(w,.5,A),M.setMatrixAt(_,p),p.makeTranslation(w,1,A),g.setMatrixAt(_,p),_++):(p.makeTranslation(w,.5,A),v.setMatrixAt(N,p),p.makeTranslation(w,1,A),P.setMatrixAt(N,p),N++)}try{for(var z=gn([f,h,M,g,v,P]),V=z.next();!V.done;V=z.next()){var $=V.value;$.instanceMatrix.needsUpdate=!0,t.add($)}}catch(T){n={error:T}}finally{try{V&&!V.done&&(e=z.return)&&e.call(z)}finally{if(n)throw n.error}}return t}function Tw(n,e,t){for(var i=n.getAttribute("position"),r=0;r<i.count;r++){var a=e[r*3],s=e[r*3+1],o=e[r*3+2],u=s>.7?Math.max(0,Math.min(1,(-a-.035)/.32)):0;i.setXYZ(r,a,s+Math.sin(t*3.2+a*10)*.018*u,o+Math.sin(t*3.2+a*10+s*2)*.07*u)}i.needsUpdate=!0,n.computeVertexNormals()}function Ew(n){for(var e=64,t=32,i=new Uint8Array(e*t*4),r=0;r<t;r++)for(var a=r/(t-1),s=0;s<e;s++){var o=s/e,u=(r*e+s)*4,l=Math.exp(-(Math.pow(o-.35,2)/.012+Math.pow(a-.7,2)/.018)),d=Math.exp(-(Math.pow(o-.79,2)/.004+Math.pow(a-.58,2)/.055));i[u]=Math.min(255,21+a*90+l*180+d*125),i[u+1]=Math.min(255,22+a*105+l*158+d*145),i[u+2]=Math.min(255,24+a*127+l*128+d*180),i[u+3]=255}var f=new Ts(i,e,t);f.mapping=fl,f.needsUpdate=!0;var h=new xl(n);try{return h.fromEquirectangular(f)}finally{h.dispose(),f.dispose()}}function tg(n,e,t,i){i===void 0&&(i=new Map);var r=new Map,a=new Map,s=new Map,o=new Set,u=new Set,l;function d(){var O,U;try{for(var H=gn(m.values()),ne=H.next();!ne.done;ne=H.next()){var ce=ne.value;ce.textureDirty=!0}}catch(pe){O={error:pe}}finally{try{ne&&!ne.done&&(U=H.return)&&U.call(H)}finally{if(O)throw O.error}}t?.()}function f(O){var U,H,ne,ce,pe,le,be;if(!s.has((pe=O.hash)!==null&&pe!==void 0?pe:O.id)){var Pe=Uint8Array.from(atob(O.data),function(Ge){return Ge.charCodeAt(0)}),Q=J0(Pe,d);try{for(var ie=gn(Q.geometries),Me=ie.next();!Me.done;Me=ie.next()){var Le=Me.value;o.add(Le)}}catch(Ge){U={error:Ge}}finally{try{Me&&!Me.done&&(H=ie.return)&&H.call(ie)}finally{if(U)throw U.error}}try{for(var Ee=gn(Q.materials),Xe=Ee.next();!Xe.done;Xe=Ee.next()){var tt=Xe.value;u.add(tt)}}catch(Ge){ne={error:Ge}}finally{try{Xe&&!Xe.done&&(ce=Ee.return)&&ce.call(Ee)}finally{if(ne)throw ne.error}}s.set((le=O.hash)!==null&&le!==void 0?le:O.id,Q)}return s.get((be=O.hash)!==null&&be!==void 0?be:O.id)}function h(O){var U,H,ne,ce,pe=new Set,le=new Set;O.traverse(function(Ee){var Xe,tt;if(Ee.geometry&&!o.has(Ee.geometry)&&pe.add(Ee.geometry),Ee.material)try{for(var Ge=gn(Array.isArray(Ee.material)?Ee.material:[Ee.material]),Ye=Ge.next();!Ye.done;Ye=Ge.next()){var dt=Ye.value;u.has(dt)||le.add(dt)}}catch(ke){Xe={error:ke}}finally{try{Ye&&!Ye.done&&(tt=Ge.return)&&tt.call(Ge)}finally{if(Xe)throw Xe.error}}});try{for(var be=gn(pe),Pe=be.next();!Pe.done;Pe=be.next()){var Q=Pe.value;Q.dispose()}}catch(Ee){U={error:Ee}}finally{try{Pe&&!Pe.done&&(H=be.return)&&H.call(be)}finally{if(U)throw U.error}}try{for(var ie=gn(le),Me=ie.next();!Me.done;Me=ie.next()){var Le=Me.value;Le.dispose()}}catch(Ee){ne={error:Ee}}finally{try{Me&&!Me.done&&(ce=ie.return)&&ce.call(ie)}finally{if(ne)throw ne.error}}}var m=new Map,y,M,g,v,P;function p(){var O,U;if(M!==void 0)return M;try{return y=document.createElement("canvas"),(O=y.addEventListener)===null||O===void 0||O.call(y,"webglcontextrestored",function(){var H,ne;P=void 0;try{for(var ce=gn(m.values()),pe=ce.next();!pe.done;pe=ce.next()){var le=pe.value;le.compiled=!1,le.textureDirty=!0,le.lastRenderedTime=-1,le.lastFlagStep=-1}}catch(be){H={error:be}}finally{try{pe&&!pe.done&&(ne=ce.return)&&ne.call(ce)}finally{if(H)throw H.error}}t?.()}),g=document.createElement("canvas"),v=(U=g.getContext)===null||U===void 0?void 0:U.call(g,"2d"),M=new ff({canvas:y,antialias:!0,alpha:!1,preserveDrawingBuffer:!1,powerPreference:"default"}),M.shadowMap.type=xd,M}catch{return M=null,null}}function _(O){if(O){if(r.has(O))return r.get(O);var U=e.get(O);if(!(!U||U.mime!=="model/tora-mesh"||!U.data)){var H=Mw(U.data);return r.set(O,H),o.add(H),H}}}function N(O,U){if(O){var H=(U??"stage")+":"+O;if(a.has(H))return a.get(H);var ne=e.get(O);if(!(!ne||!ne.mime.startsWith("image/")||!ne.data)){var ce=new Image,pe=new mr(ce);pe.colorSpace=U==="normalMap"?Nr:pr,U&&(pe.flipY=!1,pe.wrapS=pe.wrapT=ws);var le=function(be){var Pe,Q;pe.needsUpdate=!0;try{for(var ie=gn(m.values()),Me=ie.next();!Me.done;Me=ie.next()){var Le=Me.value;Le.scene.traverse(function(Ee){var Xe,tt,Ge,Ye=Ee.isMesh&&Ee.material?Array.isArray(Ee.material)?Ee.material:[Ee.material]:[];try{for(var dt=(Xe=void 0,gn(Ye)),ke=dt.next();!ke.done;ke=dt.next()){var at=ke.value;!((Ge=at.userData)===null||Ge===void 0)&&Ge.pendingTex&&at.userData.pendingTex.tex===pe&&(at.map=pe,at.color.set(at.userData.pendingTex.color||"#ffffff"),delete at.userData.pendingTex,at.needsUpdate=!0)}}catch(Ke){Xe={error:Ke}}finally{try{ke&&!ke.done&&(tt=dt.return)&&tt.call(dt)}finally{if(Xe)throw Xe.error}}}),Le.textureDirty=!0}}catch(Ee){Pe={error:Ee}}finally{try{Me&&!Me.done&&(Q=ie.return)&&Q.call(ie)}finally{if(Pe)throw Pe.error}}be&&t?.()};return a.set(H,pe),ce.onload=function(){return le(!0)},ce.src="data:"+ne.mime+";base64,"+ne.data,ce.complete&&ce.naturalWidth&&le(!1),pe}}}function D(O){var U,H,ne,ce,pe,le,be,Pe,Q,ie,Me,Le,Ee,Xe,tt,Ge,Ye,dt,ke,at,Ke=O.parameters,jt=new tc;jt.background=new Rn(Ke.skyColor||"#b8e2ed");var Pt=new wr((ne=Ke.cameraFov)!==null&&ne!==void 0?ne:39,1,.1,160);Pt.position.set((ce=Ke.cameraX)!==null&&ce!==void 0?ce:10,(pe=Ke.cameraY)!==null&&pe!==void 0?pe:18,(le=Ke.cameraZ)!==null&&le!==void 0?le:21),Pt.lookAt((be=Ke.lookAtX)!==null&&be!==void 0?be:0,(Pe=Ke.lookAtY)!==null&&Pe!==void 0?Pe:.15,(Q=Ke.lookAtZ)!==null&&Q!==void 0?Q:0),jt.add(Pt),jt.add(new xc(Ke.hemiSkyColor||"#fff9dd",Ke.hemiGroundColor||"#527b75",(ie=Ke.hemiIntensity)!==null&&ie!==void 0?ie:1.8));var tn=new Mc(Ke.sunColor||"#fff0cf",(Me=Ke.sunIntensity)!==null&&Me!==void 0?Me:2.1);tn.position.set((Le=Ke.sunX)!==null&&Le!==void 0?Le:-9,(Ee=Ke.sunY)!==null&&Ee!==void 0?Ee:18,(Xe=Ke.sunZ)!==null&&Xe!==void 0?Xe:8),jt.add(tn),tn.shadow.camera.left=tn.shadow.camera.bottom=-16,tn.shadow.camera.right=tn.shadow.camera.top=16,tn.shadow.camera.far=100,tn.shadow.camera.updateProjectionMatrix();var ue=N((Ge=(tt=O.assetSlots)===null||tt===void 0?void 0:tt[0])===null||Ge===void 0?void 0:Ge.assetId),ln=new Map,on=new Map,Z=[],b=[],ee=new Map;function ve(_t,Bt,rt,Ct){_t.traverse(function(Jt){Jt.userData.toraRootId=Bt,Jt.userData.toraSourceId=rt,Ct&&(Jt.userData.cameraAttached=!0)})}function Te(_t,Bt,rt,Ct,Jt){var vn,Wt,Ut,yn,Sn,nn,cn,Pn,Fn,ei,qn,Hn,fn,Wn,Dn,si,xn,yi,kn,ii,C=_t.parameters,re,de=function(){var Nt,Rt,De={},rn=!!(ue&&(!((Nt=ue.image)===null||Nt===void 0)&&Nt.complete)&&((Rt=ue.image)===null||Rt===void 0?void 0:Rt.naturalWidth)>0);C.useTexture&&ue&&rn?De.map=ue:De.color=C.useTexture?C.waveFlag?"#e85d56":"#d89b6a":C.color||"#ffffff",C.doubleSide&&(De.side=Er),C.opacity<1&&(De.transparent=!0,De.opacity=C.opacity,De.depthWrite=!1);var $t=C.unlit?new Vr(De):new or(De);return C.useTexture&&ue&&!rn&&($t.userData.pendingTex={tex:ue,color:"#ffffff"}),$t};if(C.primitive==="model"||C.primitive==="mesh"&&!C.waveFlag){re=new ir;var me,_e,Ze,yt=((vn=n.gameplay)!==null&&vn!==void 0?vn:[]).find(function(Nt){var Rt;return Nt.kind==="animate-3d"&&Nt.componentId===((Rt=_t.prototypeId)!==null&&Rt!==void 0?Rt:_t.id)}),it={sourceId:Ct,animator:null,modelBounds:null,startDefaultAnimation:function(){var Nt,Rt,De;if(!(!it.animator||!yt)){var rn=yt.parameters;rn.autoplay!==!1&&it.animator.play(rn.clipName||"",{loop:(Nt=rn.loop)!==null&&Nt!==void 0?Nt:"repeat",speed:(Rt=rn.speed)!==null&&Rt!==void 0?Rt:1,fadeSeconds:0,restart:!0,startTime:(De=rn.startTime)!==null&&De!==void 0?De:0})}},update:function(Nt){var Rt,De,rn,$t,En,xt,An,We=(rn=i.get(_t.id))===null||rn===void 0?void 0:rn.slots,vt=($t=i.get(_t.prototypeId))===null||$t===void 0?void 0:$t.slots,pn=function(ci){var yr,xr,er,Ti;return(xr=(yr=We?.[ci])!==null&&yr!==void 0?yr:vt?.[ci])!==null&&xr!==void 0?xr:(Ti=(er=_t.assetSlots)===null||er===void 0?void 0:er.find(function(Vt){return Vt.slotId===ci}))===null||Ti===void 0?void 0:Ti.assetId},li=["source","texture","normalMap","emissiveMap"].map(pn),vr=["subNode","materialMode","overrideMaterialName","opacity","tintColor","roughnessScale","metalnessScale","castShadow","receiveShadow","normalizeSize","pivotMode","color","useTexture"];if(_e&&li.every(function(ci,yr){return ci===_e[yr]})&&vr.every(function(ci){return Nt[ci]===Ze[ci]}))return!1;var Gi=e.get(li[0]);if(me&&(re.remove(me),h(me)),it.animator=null,it.modelBounds=null,Gi?.mime==="model/gltf-binary"){var Qi={};try{for(var Bn=gn(["texture","normalMap","emissiveMap"].entries()),Zn=Bn.next();!Zn.done;Zn=Bn.next()){var ki=Ya(Zn.value,2),Jn=ki[0],ji=ki[1];li[Jn+1]&&(Qi[ji]=N(li[Jn+1],ji))}}catch(ci){Rt={error:ci}}finally{try{Zn&&!Zn.done&&(De=Bn.return)&&De.call(Bn)}finally{if(Rt)throw Rt.error}}me=$0(f(Gi),Nt,Qi),it.modelBounds=(xt=(En=me.userData)===null||En===void 0?void 0:En.modelBounds)!==null&&xt!==void 0?xt:null,it.animator=K0(me),it.startDefaultAnimation()}else me=new ai((An=_(li[0]))!==null&&An!==void 0?An:new Lr(1,1,1),de()),me.castShadow=!!Nt.castShadow,me.receiveShadow=!!Nt.receiveShadow,li[1]?me.material.map=N(li[1]):Nt.color&&!Nt.useTexture&&me.material.color.set(Nt.color);return re.add(me),ve(me,rt,Ct,Jt),_e=li,Ze=Bc({},Nt),!0}};it.update(C),ee.set(_t.id,it)}else if(C.primitive==="group")re=new ir;else if(C.primitive==="fairway")re=Sw(C,ue,_((Ut=(Wt=_t.assetSlots)===null||Wt===void 0?void 0:Wt[0])===null||Ut===void 0?void 0:Ut.assetId));else if(C.primitive==="cup")re=bw(C);else if(C.primitive==="garden")re=ww();else if(C.primitive==="mesh"){var ut=_((Sn=(yn=_t.assetSlots)===null||yn===void 0?void 0:yn[0])===null||Sn===void 0?void 0:Sn.assetId),Lt=C.waveFlag&&ut?ut.clone():ut??new Lr(1,1,1);re=new ai(Lt,de()),C.waveFlag&&ut&&Z.push({geo:Lt,rest:new Float32Array(Lt.getAttribute("position").array)})}else C.primitive==="sphere"?re=new ai(new cs((nn=C.radiusTop)!==null&&nn!==void 0?nn:.5,16,12),de()):C.primitive==="cylinder"?re=new ai(new so((cn=C.radiusTop)!==null&&cn!==void 0?cn:.23,(Pn=C.radiusBottom)!==null&&Pn!==void 0?Pn:.21,1,32,1,!!C.openEnded),de()):C.primitive==="ring"?re=new ai(new ol((Fn=C.innerRadius)!==null&&Fn!==void 0?Fn:0,(ei=C.radiusTop)!==null&&ei!==void 0?ei:.15,24),de()):C.primitive==="circle"?re=new ai(new il((qn=C.radiusTop)!==null&&qn!==void 0?qn:.21,32),de()):re=new ai(new Lr(1,1,1),de());return re.position.set((Hn=C.x)!==null&&Hn!==void 0?Hn:0,(fn=C.y)!==null&&fn!==void 0?fn:0,(Wn=C.z)!==null&&Wn!==void 0?Wn:0),re.rotation.set((Dn=C.rx)!==null&&Dn!==void 0?Dn:0,(si=C.ry)!==null&&si!==void 0?si:0,(xn=C.rz)!==null&&xn!==void 0?xn:0),re.scale.set((yi=C.sx)!==null&&yi!==void 0?yi:1,(kn=C.sy)!==null&&kn!==void 0?kn:1,(ii=C.sz)!==null&&ii!==void 0?ii:1),re.visible=C.visible!==!1,ve(re,rt,Ct,Jt),Bt.add(re),re}var Ve=[],$e=new Map,Ce=function(_t,Bt,rt){var Ct,Jt;try{for(var vn=gn(n.components),Wt=vn.next();!Wt.done;Wt=vn.next()){var Ut=Wt.value;if(Ut.parentId===_t&&Ut.contract==="native.mesh3d.v1"&&!Ut.prototype){var yn=Bt??Ut,Sn=rt||!!Ut.parameters.attachToCamera;$e.set(Ut.id,{rootId:yn.id,sourceId:yn.id,cameraAttached:Sn}),Ve.push(Ut),Ce(Ut.id,yn,Sn)}}}catch(nn){Ct={error:nn}}finally{try{Wt&&!Wt.done&&(Jt=vn.return)&&Jt.call(vn)}finally{if(Ct)throw Ct.error}}};Ce(O.id,null,!1);var Ae=function(_t){var Bt=_t.parameters,rt=$e.get(_t.id),Ct=Bt.attachToCamera&&_t.parentId===O.id?Pt:_t.parentId===O.id?jt:(Ye=ln.get(_t.parentId))!==null&&Ye!==void 0?Ye:jt,Jt=Te(_t,Ct,rt.rootId,rt.sourceId,rt.cameraAttached);if(ln.set(_t.id,Jt),Bt.confetti){var vn=new ir;vn.userData.isConfetti=!0;var Wt=new Lr(.08,.025,.12),Ut=["#ffda69","#fff6c9","#ef8774","#7cc6bf"].map(function(Sn){return new Vr({color:Sn})}),yn=Array.from({length:28},function(Sn,nn){var cn=new ai(Wt,Ut[nn%4]);return cn.visible=!1,vn.add(cn),cn});jt.add(vn),b.push({id:_t.id,origin:{x:(dt=Bt.x)!==null&&dt!==void 0?dt:0,y:(ke=Bt.y)!==null&&ke!==void 0?ke:0,z:(at=Bt.z)!==null&&at!==void 0?at:0},pieces:yn})}};try{for(var nt=gn(Ve),gt=nt.next();!gt.done;gt=nt.next()){var ct=gt.value;Ae(ct)}}catch(_t){U={error:_t}}finally{try{gt&&!gt.done&&(H=nt.return)&&H.call(nt)}finally{if(U)throw U.error}}var je=new ir;jt.add(je);var Dt=new cs(1,8,5),qe=new Vr({color:"#fff1a2",transparent:!0,opacity:.85}),Gt=Array.from({length:24},function(){var _t=new ai(Dt,qe);return _t.visible=!1,je.add(_t),_t}),oe=new Sc,st=new qt,Ne=new ge,ft=new Kr(new ge(0,1,0),0),ht=new ge,ze="",Ot=Array.from(ln,function(_t){var Bt=Ya(_t,2),rt=Bt[0],Ct=Bt[1];return{id:rt,obj:Ct,comp:n.components.find(function(Jt){return Jt.id===rt})}}).filter(function(_t){return _t.comp}),Tt={id:O.id,scene:jt,camera:Pt,nodes:ln,dynamicNodes:on,nodeEntries:Ot,createMeshObject:Te,modelBindings:ee,sun:tn,wavingFlags:Z,confettiSystems:b,guideGroup:je,guidePool:Gt,compiled:!1,lastRenderMs:0,textureDirty:!0,animDirty:!1,skyColor:Ke.skyColor||"#b8e2ed",lastWaveAt:-1,lastRenderedTime:-1,lastRenderedW:0,lastRenderedH:0,lastPoseSig:"",guideDirty:!0,focusZ:0,lastTime:-1,lastWidth:0,lastHeight:0,setGuide:function(_t){var Bt=_t?Math.min(_t.length,Gt.length):0,rt=Bt?_t.slice(0,Bt).map(function(Ut){return"".concat(Ut.x.toFixed(2),",").concat(Ut.y.toFixed(2),",").concat(Ut.z.toFixed(2))}).join("|"):"";if(rt!==ze){ze=rt,Tt.guideDirty=!0;for(var Ct=0;Ct<Gt.length;Ct++){var Jt=Gt[Ct];if(Ct<Bt){var vn=_t[Ct],Wt=.055*(1-Ct/Bt*.5);Jt.visible=!0,Jt.scale.setScalar(Wt),Jt.position.set(vn.x,vn.y+.03,vn.z)}else Jt.visible=!1}}},project:function(_t,Bt,rt){return Ne.set(_t.x,_t.y,_t.z).project(Pt),{x:(Ne.x+1)*Bt/2,y:(1-Ne.y)*rt/2}},unproject:function(_t,Bt,rt,Ct,Jt){return st.set(_t/rt*2-1,1-Bt/Ct*2),oe.setFromCamera(st,Pt),ft.constant=-Jt,oe.ray.intersectPlane(ft,ht)?{x:ht.x,y:ht.y,z:ht.z}:null},raycast:function(_t,Bt,rt,Ct){var Jt,vn,Wt,Ut,yn,Sn,nn,cn,Pn,Fn,ei,qn,Hn,fn,Wn,Dn;rt===void 0&&(rt=80);var si=Ct===void 0?{}:Ct,xn=si.isTarget,yi=xn===void 0?function(){return!0}:xn,kn=si.isOccluder,ii=kn===void 0?function(){return!1}:kn;jt.updateMatrixWorld(!0),Pt.updateMatrixWorld(!0),st.set(_t,Bt),oe.near=.05,oe.far=rt,oe.setFromCamera(st,Pt);var C=[];try{for(var re=gn(Tt.nodes.values()),de=re.next();!de.done;de=re.next()){var me=de.value;if(!(!me.visible||!((nn=me.userData)===null||nn===void 0)&&nn.cameraAttached)){var _e=(cn=me.userData)===null||cn===void 0?void 0:cn.toraRootId,Ze=(Pn=me.userData)===null||Pn===void 0?void 0:Pn.toraSourceId;_e&&(yi(_e,Ze)||ii(_e,Ze))&&C.push(me)}}}catch(An){Jt={error:An}}finally{try{de&&!de.done&&(vn=re.return)&&vn.call(re)}finally{if(Jt)throw Jt.error}}try{for(var yt=gn(Tt.dynamicNodes.values()),it=yt.next();!it.done;it=yt.next()){var me=it.value;if(!(!me.visible||!((Fn=me.userData)===null||Fn===void 0)&&Fn.cameraAttached)){var _e=(ei=me.userData)===null||ei===void 0?void 0:ei.toraRootId,Ze=(qn=me.userData)===null||qn===void 0?void 0:qn.toraSourceId;_e&&(yi(_e,Ze)||ii(_e,Ze))&&C.push(me)}}}catch(An){Wt={error:An}}finally{try{it&&!it.done&&(Ut=yt.return)&&Ut.call(yt)}finally{if(Wt)throw Wt.error}}var ut=oe.intersectObjects(C.length?C:jt.children,!0),Lt=new Set;try{for(var Nt=gn(ut),Rt=Nt.next();!Rt.done;Rt=Nt.next()){for(var De=Rt.value,rn=!1,$t=De.object;$t;$t=$t.parent)if(!$t.visible||$t===je||!((Hn=$t.userData)===null||Hn===void 0)&&Hn.cameraAttached||!((fn=$t.userData)===null||fn===void 0)&&fn.isConfetti){rn=!0;break}if(!rn){var En=(Wn=De.object.userData)===null||Wn===void 0?void 0:Wn.toraRootId,xt=(Dn=De.object.userData)===null||Dn===void 0?void 0:Dn.toraSourceId;if(!(!En||Lt.has(En))){if(Lt.add(En),yi(En,xt))return{id:En,sourceId:xt,distance:De.distance,point:{x:De.point.x,y:De.point.y,z:De.point.z}};if(ii(En,xt))return null}}}}catch(An){yn={error:An}}finally{try{Rt&&!Rt.done&&(Sn=Nt.return)&&Sn.call(Nt)}finally{if(yn)throw yn.error}}return null}};return m.set(O.id,Tt),Tt}function B(O){var U;return(U=m.get(O.id))!==null&&U!==void 0?U:D(O)}function w(O,U){var H,ne,ce,pe,le,be;if(!U.length&&!O.contactBatches)return!1;O.contactBatches||(O.contactBatches=[new cs(1,6,4),new Lr(1,.2,1.6)].map(function(Ke){var jt=new Aa(Ke,new Vr({toneMapped:!1}),256);return jt.userData.isConfetti=!0,jt.frustumCulled=!1,jt.count=0,O.scene.add(jt),jt}),O.contactPose=new ar,O.contactColor=new Rn);var Pe=O.contactBatches.some(function(Ke){return Ke.count>0});try{for(var Q=gn(O.contactBatches),ie=Q.next();!ie.done;ie=Q.next()){var Me=ie.value;Me.count=0}}catch(Ke){H={error:Ke}}finally{try{ie&&!ie.done&&(ne=Q.return)&&ne.call(Q)}finally{if(H)throw H.error}}var Le=O.contactBatches,Ee=O.contactPose,Xe=O.contactColor;try{for(var tt=gn(U),Ge=tt.next();!Ge.done;Ge=tt.next()){var Ye=Ge.value,Me=Le[Number(Ye.confetti)],dt=Ye.age;Ee.position.set(Ye.x+Ye.vx*dt,Ye.y+Ye.vy*dt-Ye.gravity*dt*dt/2,Ye.z+Ye.vz*dt),Ee.rotation.set(Ye.spinX*dt,Ye.spinZ*dt/2,Ye.spinZ*dt),Ee.scale.setScalar(Ye.size*Math.min(1,(Ye.life-dt)*7)),Ee.updateMatrix(),Me.setMatrixAt(Me.count,Ee.matrix),Me.setColorAt(Me.count,Xe.set(Ye.color)),Me.count++}}catch(Ke){ce={error:Ke}}finally{try{Ge&&!Ge.done&&(pe=tt.return)&&pe.call(tt)}finally{if(ce)throw ce.error}}try{for(var ke=gn(Le),at=ke.next();!at.done;at=ke.next()){var Me=at.value;Me.instanceMatrix.needsUpdate=!0,Me.instanceColor&&(Me.instanceColor.needsUpdate=!0)}}catch(Ke){le={error:Ke}}finally{try{at&&!at.done&&(be=ke.return)&&be.call(ke)}finally{if(le)throw le.error}}return Pe||U.length>0}function A(O,U){var H,ne,ce,pe,le,be,Pe,Q,ie,Me,Le,Ee,Xe,tt,Ge,Ye,dt,ke,at,Ke,jt,Pt,tn,ue,ln,on,Z,b,ee,ve,Te,Ve,$e,Ce,Ae,nt,gt,ct,je,Dt,qe,Gt,oe,st,Ne,ft,ht,ze,Ot,Tt,_t,Bt,rt,Ct,Jt,vn,Wt,Ut,yn,Sn,nn,cn,Pn,Fn,ei,qn,Hn,fn,Wn,Dn,si,xn=U.time,yi=xn===void 0?0:xn,kn=U.ambientTime,ii=U.propsOf,C=U.bodies3d,re=U.fpsPose,de=U.instances3d,me=de===void 0?[]:de,_e=U.aimLocked,Ze=_e===void 0?!1:_e,yt=U.groundFn,it=U.worldWidth,ut=it===void 0?390:it,Lt=U.worldHeight,Nt=Lt===void 0?700:Lt,Rt=U.designHeight,De=B(O),rn=kn??yi,$t=ii(O),En=$t.skyColor||"#b8e2ed";De.skyColor!==En&&(De.skyColor=En,De.scene.background=new Rn(En));var xt=new Set(me.map(function(Vn){return Vn.id}));try{for(var An=gn(De.dynamicNodes),We=An.next();!We.done;We=An.next()){var vt=Ya(We.value,2),pn=vt[0],li=vt[1];xt.has(pn)||((Le=li.parent)===null||Le===void 0||Le.remove(li),h(li),De.modelBindings.delete(pn),De.dynamicNodes.delete(pn))}}catch(Vn){H={error:Vn}}finally{try{We&&!We.done&&(ne=An.return)&&ne.call(An)}finally{if(H)throw H.error}}var vr=function(Vn){if(De.dynamicNodes.has(Vn.id))return"continue";var Vs=Vn.parentId===O.id?De.scene:(Xe=(Ee=De.dynamicNodes.get(Vn.parentId))!==null&&Ee!==void 0?Ee:De.nodes.get(Vn.parentId))!==null&&Xe!==void 0?Xe:De.scene,ga=(tt=Vn.instanceId)!==null&&tt!==void 0?tt:Vn.id,fs=(Ge=me.find(function(hs){return hs.id===ga}))!==null&&Ge!==void 0?Ge:Vn,Wr=(Ye=fs.prototypeId)!==null&&Ye!==void 0?Ye:fs.id,Gs=De.createMeshObject(Vn,Vs,ga,Wr,!!Vn.parameters.attachToCamera);De.dynamicNodes.set(Vn.id,Gs)};try{for(var Gi=gn(me),Qi=Gi.next();!Qi.done;Qi=Gi.next()){var Bn=Qi.value;vr(Bn)}}catch(Vn){ce={error:Vn}}finally{try{Qi&&!Qi.done&&(pe=Gi.return)&&pe.call(Gi)}finally{if(ce)throw ce.error}}var Zn=Nt>=ut,ki=De.lastTime<0||rn<De.lastTime?0:Math.min(.05,rn-De.lastTime),Jn=Math.max(1,Nt/Math.max(1,Rt??Nt)),ji=function(Vn){return Jn>1.001?Math.min(135,2*Math.atan(Math.tan(Vn*Math.PI/360)*Jn)*(180/Math.PI)):Vn},ci=ut/Math.max(1,Nt),yr=ji(re?Zn?(dt=$t.cameraFov)!==null&&dt!==void 0?dt:68:(ke=$t.landscapeCameraFov)!==null&&ke!==void 0?ke:54:Zn?(at=$t.cameraFov)!==null&&at!==void 0?at:39:(Ke=$t.landscapeCameraFov)!==null&&Ke!==void 0?Ke:22.6199);De.recoil>0&&(De.recoil=ki>0?De.recoil*Math.exp(-10*ki):De.recoil,De.recoil<.002&&(De.recoil=0));var xr=Q0(Q0([],Ya(De.nodeEntries),!1),Ya(me.map(function(Vn){return{id:Vn.id,obj:De.dynamicNodes.get(Vn.id),comp:Vn}}).filter(function(Vn){return Vn.obj})),!1),er="";try{for(var Ti=gn(xr),Vt=Ti.next();!Vt.done;Vt=Ti.next()){var Ns=Vt.value,ds=Ns.id,zn=Ns.obj,Bn=Ns.comp,On=ii(Bn);zn.visible=On.visible!==!1,!((jt=De.modelBindings.get(ds))===null||jt===void 0)&&jt.update(On)&&(De.textureDirty=!0,De.compiled=!1),!On.useTexture&&zn.isMesh&&(!((Pt=zn.material)===null||Pt===void 0)&&Pt.color)&&On.color&&zn.material.color.set(On.color);var oi=C?.get(ds);if(oi&&oi.mode==="dynamic"){var In=oi.captured?Math.min(1,((tn=oi.captureElapsed)!==null&&tn!==void 0?tn:0)/.55):0,tr=oi.captured&&oi.captureTarget?oi.x+(oi.captureTarget.x-oi.x)*In:oi.x,Za=oi.y-In*.45,bl=oi.captured&&oi.captureTarget?oi.z+(oi.captureTarget.z-oi.z)*In:oi.z;zn.position.set(tr,Za,bl);var Cr=1-In*.65;zn.scale.set(((ue=On.sx)!==null&&ue!==void 0?ue:1)*Cr,((ln=On.sy)!==null&&ln!==void 0?ln:1)*Cr,((on=On.sz)!==null&&on!==void 0?on:1)*Cr),zn.rotation.set(-((Z=oi.spin)!==null&&Z!==void 0?Z:0),(b=On.ry)!==null&&b!==void 0?b:0,((ee=oi.spin)!==null&&ee!==void 0?ee:0)*.22)}else if(oi&&oi.mode==="kinematic")zn.position.set(oi.x,(Te=(ve=oi.y)!==null&&ve!==void 0?ve:On.y)!==null&&Te!==void 0?Te:0,oi.z),zn.rotation.set((Ve=On.rx)!==null&&Ve!==void 0?Ve:0,-((Ce=($e=oi.angle)!==null&&$e!==void 0?$e:On.ry)!==null&&Ce!==void 0?Ce:0),(Ae=On.rz)!==null&&Ae!==void 0?Ae:0);else if(On.dropShadowOf&&C?.has(On.dropShadowOf)){var Ra=C.get(On.dropShadowOf),Us=yt?(nt=yt(Ra,Ra.x,Ra.z))!==null&&nt!==void 0?nt:-1:0;zn.position.set(Ra.x,Us+.008,Ra.z);var wl=Math.max(0,Ra.y-Us-Ra.radius);zn.material&&(zn.material.opacity=.22/(1+wl*2));var Cr=1+wl*.4;zn.scale.set(Cr,Cr,Cr),zn.visible=!Ra.captured&&On.visible!==!1}else if(On.attachToCamera){var bf=Math.tan(((gt=$t.cameraFov)!==null&>!==void 0?gt:68)*Math.PI/360),Xc=Math.tan(yr*Math.PI/360),Ii=Xc/Math.max(.05,bf),Cr=Math.min(1,Ii),Ci=Math.min(1.15,Ii)*(ci>1.3?1.12:1),Ja=Ci*Math.min(3.55,ci/(390/700)),Rr=(ct=De.recoil)!==null&&ct!==void 0?ct:0;zn.position.set(((je=On.x)!==null&&je!==void 0?je:0)*Ja,((Dt=On.y)!==null&&Dt!==void 0?Dt:0)*Ci+Rr*.085*Cr,((qe=On.z)!==null&&qe!==void 0?qe:0)+Rr*.3*Cr),zn.rotation.set(((Gt=On.rx)!==null&&Gt!==void 0?Gt:0)+Rr*.34,((oe=On.ry)!==null&&oe!==void 0?oe:0)+(ci>1.1?.1:0),((st=On.rz)!==null&&st!==void 0?st:0)-Rr*.09),zn.scale.set(((Ne=On.sx)!==null&&Ne!==void 0?Ne:1)*Cr,((ft=On.sy)!==null&&ft!==void 0?ft:1)*Cr,((ht=On.sz)!==null&&ht!==void 0?ht:1)*Cr)}else zn.position.set((ze=On.x)!==null&&ze!==void 0?ze:0,(Ot=On.y)!==null&&Ot!==void 0?Ot:0,(Tt=On.z)!==null&&Tt!==void 0?Tt:0),zn.rotation.set((_t=On.rx)!==null&&_t!==void 0?_t:0,(Bt=On.ry)!==null&&Bt!==void 0?Bt:0,(rt=On.rz)!==null&&rt!==void 0?rt:0),zn.scale.set((Ct=On.sx)!==null&&Ct!==void 0?Ct:1,(Jt=On.sy)!==null&&Jt!==void 0?Jt:1,(vn=On.sz)!==null&&vn!==void 0?vn:1);(re||De.dynamicNodes.size>0)&&(er+="".concat(ds,":").concat(+zn.visible,",").concat(zn.position.x*100|0,",").concat(zn.position.y*100|0,",").concat(zn.position.z*100|0,",").concat(zn.rotation.x*100|0,",").concat(zn.rotation.y*100|0,"|"))}}catch(Vn){le={error:Vn}}finally{try{Vt&&!Vt.done&&(be=Ti.return)&&be.call(Ti)}finally{if(le)throw le.error}}var Ur;if(C)try{for(var ra=gn(C.values()),va=ra.next();!va.done;va=ra.next()){var oi=va.value;if(oi.stageId===O.id&&oi.captured){Ur=oi;break}}}catch(Vn){Pe={error:Vn}}finally{try{va&&!va.done&&(Q=ra.return)&&Q.call(ra)}finally{if(Pe)throw Pe.error}}var wf=function(Vn){var Vs=!!Ur,ga=Ur&&(Wt=Ur.captureElapsed)!==null&&Wt!==void 0?Wt:0;Vn.pieces.forEach(function(fs,Wr){var Gs,hs,El,Hs,Mo,So;if(fs.visible=Vs,!!Vs){var Zc=Wr*2.399,Al=(hs=(Gs=Ur.captureTarget)===null||Gs===void 0?void 0:Gs.x)!==null&&hs!==void 0?hs:Vn.origin.x,Il=(Hs=(El=Ur.captureTarget)===null||El===void 0?void 0:El.y)!==null&&Hs!==void 0?Hs:Vn.origin.y,Ws=(So=(Mo=Ur.captureTarget)===null||Mo===void 0?void 0:Mo.z)!==null&&So!==void 0?So:Vn.origin.z;fs.position.set(Al+Math.cos(Zc)*ga*(.5+Wr%4*.17),Il+.3+Math.sin(Math.min(1,ga/2)*Math.PI)*(1+Wr%5*.15),Ws+Math.sin(Zc)*ga*(.5+Wr%4*.17)),fs.rotation.set(ga*3+Wr,ga*2+Wr,Math.sin(ga+Wr))}})};try{for(var Fs=gn(De.confettiSystems),Os=Fs.next();!Os.done;Os=Fs.next()){var Tf=Os.value;wf(Tf)}}catch(Vn){ie={error:Vn}}finally{try{Os&&!Os.done&&(Me=Fs.return)&&Me.call(Fs)}finally{if(ie)throw ie.error}}De.camera.aspect=ci;var Bs=!1;if(re)De.lastTime=rn,De.camera.rotation.order="YXZ",De.camera.position.set(re.x,re.y+((Ut=re.bob)!==null&&Ut!==void 0?Ut:0),re.z),De.camera.rotation.set(re.pitch,re.yaw,0),De.camera.fov=yr,er+="c:".concat(De.camera.position.x*100|0,",").concat(De.camera.position.y*100|0,",").concat(De.camera.position.z*100|0,",").concat(re.yaw*1e3|0,",").concat(re.pitch*1e3|0,",").concat(yr*100|0,",").concat(ci*1e3|0,",").concat(((yn=De.recoil)!==null&&yn!==void 0?yn:0)*1e3|0);else{var ks=$t.followTargetId?C?.get($t.followTargetId):void 0,yo=ks?ks.z*((Sn=$t.followZFactor)!==null&&Sn!==void 0?Sn:.12):(nn=$t.lookAtZ)!==null&&nn!==void 0?nn:0;De.lastTime<0||rn<De.lastTime?De.focusZ=yo:Ze||(De.focusZ+=(yo-De.focusZ)*(1-Math.exp(-6*ki))),De.lastTime=rn;var Ef=Math.max(0,1-rn/1.5);if(Bs=!$t.followTargetId&&((cn=$t.introLift)!==null&&cn!==void 0?cn:2)===0,!Ze){var zs=Bs?Math.sin(rn*.42)*1.15:0,Tl=Bs?(Math.cos(rn*.42)-1)*.55:0,xo=(Zn?(Pn=$t.cameraX)!==null&&Pn!==void 0?Pn:10:(Fn=$t.landscapeCameraX)!==null&&Fn!==void 0?Fn:13)+zs,Yc=Zn?((ei=$t.cameraY)!==null&&ei!==void 0?ei:18)+Ef*((qn=$t.introLift)!==null&&qn!==void 0?qn:2):(Hn=$t.landscapeCameraY)!==null&&Hn!==void 0?Hn:15,_o=(Zn?(fn=$t.cameraZ)!==null&&fn!==void 0?fn:21:(Wn=$t.landscapeCameraZ)!==null&&Wn!==void 0?Wn:18)+Tl,qc=ki===0?Yc:De.camera.position.y+(Yc-De.camera.position.y)*(1-Math.exp(-6*ki));De.camera.position.set(xo,qc,_o+De.focusZ),De.camera.fov=yr,De.camera.lookAt((Dn=$t.lookAtX)!==null&&Dn!==void 0?Dn:0,(si=$t.lookAtY)!==null&&si!==void 0?si:.15,De.focusZ)}er+="a:".concat(ci*1e3|0,",").concat(yr*100|0)}return De.camera.updateProjectionMatrix(),De.camera.updateMatrixWorld(!0),{entry:De,waveTime:rn,victorySway:Bs,poseParts:er}}function z(O,U,H,ne,ce,pe,le){var be,Pe,Q,ie,Me,Le,Ee,Xe,tt,Ge,Ye,dt,ke,at,Ke,jt,Pt,tn,ue,ln,on,Z,b=A(O,Bc(Bc({},le),{worldWidth:(tt=le.worldWidth)!==null&&tt!==void 0?tt:ce,worldHeight:(Ge=le.worldHeight)!==null&&Ge!==void 0?Ge:pe})),ee=b.entry,ve=b.waveTime,Te=b.victorySway,Ve=b.poseParts,$e=le.bodies3d,Ce=(Ye=le.drawX)!==null&&Ye!==void 0?Ye:0,Ae=(dt=le.drawY)!==null&&dt!==void 0?dt:0,nt=w(ee,(ke=le.contactParticles)!==null&&ke!==void 0?ke:[]);Object.assign(ee,{lastX:Ce,lastY:Ae,lastWidth:ce,lastHeight:pe,lastDesignH:(at=le.designHeight)!==null&&at!==void 0?at:pe,isFullBleed:!!le.fullBleed});var gt=H>=2&&ne>=2?p():null;if(!gt||!((Pt=(jt=(Ke=gt.getContext)===null||Ke===void 0?void 0:Ke.call(gt))===null||jt===void 0?void 0:jt.isContextLost)===null||Pt===void 0)&&Pt.call(jt))return U.fillStyle=ee.skyColor,U.fillRect(Ce,Ae,ce,pe),ee;var ct=Math.max(H,ne,1),je=le.propsOf(O),Dt=(tn={none:Gr,neutral:Tc,aces:wc}[je.toneMapping])!==null&&tn!==void 0?tn:Gr;gt.toneMapping=Dt;var qe=!!je.shadowsEnabled,Gt=Number((ue=je.shadowMapSize)!==null&&ue!==void 0?ue:512);gt.shadowMap.enabled=qe,ee.sun.castShadow=qe,ee.sun.shadow.mapSize.x!==Gt&&(ee.sun.shadow.mapSize.set(Gt,Gt),(ln=ee.sun.shadow.map)===null||ln===void 0||ln.dispose(),ee.sun.shadow.map=null);var oe=(on=je.envIntensity)!==null&&on!==void 0?on:.8;(ee.textureDirty||!ee.compiled)&&(ee.usesPbr=!1,ee.scene.traverse(function(Dn){var si;!((si=Dn.material)===null||si===void 0)&&si.isMeshStandardMaterial&&(ee.usesPbr=!0)})),ee.usesPbr&&oe>0&&(l??(l=Ew(gt))),ee.scene.environment=ee.usesPbr&&oe>0?l?.texture:null,ee.scene.environmentIntensity=oe;var st=[Dt,qe,Gt,oe].join("/");ee.lightingKey!==st&&(ee.textureDirty=!0,ee.lightingKey=st);var Ne=(Z=je.renderMaxDim)!==null&&Z!==void 0?Z:520,ft=ct>Ne?Ne/ct:1,ht=Math.max(2,Math.round(H*ft)),ze=Math.max(2,Math.round(ne*ft)),Ot=y.width!==ht||y.height!==ze;if(Ot&&(gt.setPixelRatio(1),gt.setSize(ht,ze,!1),g.width=ht,g.height=ze,P=void 0),!ee.compiled){ee.compiled=!0;var Tt=[];ee.guidePool[0]&&!ee.guidePool[0].visible&&(ee.guidePool[0].visible=!0,ee.guidePool[0].position.set(0,-99,0),Tt.push(ee.guidePool[0]));try{for(var _t=gn(ee.confettiSystems),Bt=_t.next();!Bt.done;Bt=_t.next()){var rt=Bt.value;rt.pieces[0]&&!rt.pieces[0].visible&&(rt.pieces[0].visible=!0,rt.pieces[0].position.set(0,-99,0),Tt.push(rt.pieces[0]))}}catch(Dn){be={error:Dn}}finally{try{Bt&&!Bt.done&&(Pe=_t.return)&&Pe.call(_t)}finally{if(be)throw be.error}}gt.compile(ee.scene,ee.camera);try{for(var Ct=gn(Tt),Jt=Ct.next();!Jt.done;Jt=Ct.next()){var vn=Jt.value;vn.visible=!1}}catch(Dn){Q={error:Dn}}finally{try{Jt&&!Jt.done&&(ie=Ct.return)&&ie.call(Ct)}finally{if(Q)throw Q.error}}}var Wt=!1;if($e)try{for(var Ut=gn($e.values()),yn=Ut.next();!yn.done;yn=Ut.next()){var Sn=yn.value;if(Sn.stageId===O.id&&(Sn.mode==="kinematic"||Sn.mode==="dynamic"&&(!Sn.atRest||Sn.captured))){Wt=!0;break}}}catch(Dn){Me={error:Dn}}finally{try{yn&&!yn.done&&(Le=Ut.return)&&Le.call(Ut)}finally{if(Me)throw Me.error}}var nn=Math.floor(ve*20),cn=ee.wavingFlags.length>0&&ee.lastFlagStep!==nn,Pn=Te&&Math.abs(ve-ee.lastRenderedTime)>=.032,Fn=Wt&&ee.lastRenderedTime!==ve,ei=Ve!==ee.lastPoseSig,qn=Ot||P!==O.id||ee.guideDirty||ee.textureDirty||ee.animDirty||ee.lastRenderedTime<0||ee.lastRenderedW!==ht||ee.lastRenderedH!==ze||cn||Pn||Fn||ei||nt;if(qn){if(ee.wavingFlags.length>0&&ee.lastFlagStep!==nn){try{for(var Hn=gn(ee.wavingFlags),fn=Hn.next();!fn.done;fn=Hn.next()){var Wn=fn.value;Tw(Wn.geo,Wn.rest,nn/20)}}catch(Dn){Ee={error:Dn}}finally{try{fn&&!fn.done&&(Xe=Hn.return)&&Xe.call(Hn)}finally{if(Ee)throw Ee.error}}ee.lastFlagStep=nn}gt.setClearColor(ee.skyColor,1),gt.render(ee.scene,ee.camera),y.width>0&&y.height>0&&(v.drawImage(y,0,0,ht,ze),P=O.id),ee.lastRenderedTime=ve,ee.lastRenderedW=ht,ee.lastRenderedH=ze,ee.lastPoseSig=Ve,ee.guideDirty=!1,ee.textureDirty=!1,ee.animDirty=!1}return g.width>0&&g.height>0&&U.drawImage(g,Ce,Ae,ce,pe),ee}function V(){var O,U,H,ne,ce,pe,le,be;try{for(var Pe=gn(m.values()),Q=Pe.next();!Q.done;Q=Pe.next()){var ie=Q.value;try{for(var Me=(H=void 0,gn(ie.dynamicNodes)),Le=Me.next();!Le.done;Le=Me.next()){var Ee=Ya(Le.value,2),Xe=Ee[0],tt=Ee[1];(le=tt.parent)===null||le===void 0||le.remove(tt),h(tt),ie.modelBindings.delete(Xe)}}catch(ke){H={error:ke}}finally{try{Le&&!Le.done&&(ne=Me.return)&&ne.call(Me)}finally{if(H)throw H.error}}ie.dynamicNodes.clear();try{for(var Ge=(ce=void 0,gn(ie.modelBindings.values())),Ye=Ge.next();!Ye.done;Ye=Ge.next()){var dt=Ye.value;(be=dt.animator)===null||be===void 0||be.reset(),dt.startDefaultAnimation()}}catch(ke){ce={error:ke}}finally{try{Ye&&!Ye.done&&(pe=Ge.return)&&pe.call(Ge)}finally{if(ce)throw ce.error}}ie.animDirty=!0,ie.focusZ=0,ie.lastTime=-1,ie.lastRenderedTime=-1,ie.lastFlagStep=-1,ie.lastPoseSig="",ie.guideDirty=!0,ie.setGuide([])}}catch(ke){O={error:ke}}finally{try{Q&&!Q.done&&(U=Pe.return)&&U.call(Pe)}finally{if(O)throw O.error}}}function $(){var O,U,H,ne,ce,pe,le,be,Pe,Q,ie,Me,Le,Ee,Xe,tt;try{for(var Ge=gn(m.values()),Ye=Ge.next();!Ye.done;Ye=Ge.next()){var dt=Ye.value;try{for(var ke=(H=void 0,gn((Xe=dt.contactBatches)!==null&&Xe!==void 0?Xe:[])),at=ke.next();!at.done;at=ke.next()){var Ke=at.value;Ke.dispose()}}catch(Ae){H={error:Ae}}finally{try{at&&!at.done&&(ne=ke.return)&&ne.call(ke)}finally{if(H)throw H.error}}h(dt.scene),dt.sun.shadow.dispose()}}catch(Ae){O={error:Ae}}finally{try{Ye&&!Ye.done&&(U=Ge.return)&&U.call(Ge)}finally{if(O)throw O.error}}try{for(var jt=gn(o),Pt=jt.next();!Pt.done;Pt=jt.next()){var tn=Pt.value;tn.dispose()}}catch(Ae){ce={error:Ae}}finally{try{Pt&&!Pt.done&&(pe=jt.return)&&pe.call(jt)}finally{if(ce)throw ce.error}}try{for(var ue=gn(u),ln=ue.next();!ln.done;ln=ue.next()){var on=ln.value;on.dispose()}}catch(Ae){le={error:Ae}}finally{try{ln&&!ln.done&&(be=ue.return)&&be.call(ue)}finally{if(le)throw le.error}}try{for(var Z=gn(a.values()),b=Z.next();!b.done;b=Z.next()){var ee=b.value;ee.dispose()}}catch(Ae){Pe={error:Ae}}finally{try{b&&!b.done&&(Q=Z.return)&&Q.call(Z)}finally{if(Pe)throw Pe.error}}try{for(var ve=gn(s.values()),Te=ve.next();!Te.done;Te=ve.next()){var Ve=Te.value;try{for(var $e=(Le=void 0,gn(Ve.textures.values())),Ce=$e.next();!Ce.done;Ce=$e.next()){var ee=Ce.value;ee.dispose()}}catch(Ae){Le={error:Ae}}finally{try{Ce&&!Ce.done&&(Ee=$e.return)&&Ee.call($e)}finally{if(Le)throw Le.error}}}}catch(Ae){ie={error:Ae}}finally{try{Te&&!Te.done&&(Me=ve.return)&&Me.call(ve)}finally{if(ie)throw ie.error}}u.clear(),o.clear(),s.clear(),l?.dispose(),l=void 0,m.clear(),r.clear(),a.clear(),(tt=M?.forceContextLoss)===null||tt===void 0||tt.call(M),M?.dispose(),M=void 0,y=void 0,g=void 0,v=void 0,P=void 0}function T(O,U){var H,ne,ce,pe;try{for(var le=gn(m.values()),be=le.next();!be.done;be=le.next()){var Pe=be.value,Q=function(tt,Ge){if(!Ge.animator)return"continue";Ge.animator.step(O,function(Ye){var dt;return U?.(tt,(dt=Ge.sourceId)!==null&&dt!==void 0?dt:tt,Ye)})&&(Pe.animDirty=!0)};try{for(var ie=(ce=void 0,gn(Pe.modelBindings)),Me=ie.next();!Me.done;Me=ie.next()){var Le=Ya(Me.value,2),Ee=Le[0],Xe=Le[1];Q(Ee,Xe)}}catch(tt){ce={error:tt}}finally{try{Me&&!Me.done&&(pe=ie.return)&&pe.call(ie)}finally{if(ce)throw ce.error}}}}catch(tt){H={error:tt}}finally{try{be&&!be.done&&(ne=le.return)&&ne.call(le)}finally{if(H)throw H.error}}}function S(O,U){var H,ne,ce,pe,le;U===void 0&&(U={});var be=!1;try{for(var Pe=gn(m.values()),Q=Pe.next();!Q.done;Q=Pe.next()){var ie=Q.value;try{for(var Me=(ce=void 0,gn(ie.modelBindings)),Le=Me.next();!Le.done;Le=Me.next()){var Ee=Ya(Le.value,2),Xe=Ee[0],tt=Ee[1];Xe!==O&&tt.sourceId!==O||!((le=tt.animator)===null||le===void 0)&&le.play(U.clipName||"",U)&&(ie.animDirty=!0,be=!0)}}catch(Ge){ce={error:Ge}}finally{try{Le&&!Le.done&&(pe=Me.return)&&pe.call(Me)}finally{if(ce)throw ce.error}}}}catch(Ge){H={error:Ge}}finally{try{Q&&!Q.done&&(ne=Pe.return)&&ne.call(Pe)}finally{if(H)throw H.error}}return be}function Y(O){var U,H;try{for(var ne=gn(m.values()),ce=ne.next();!ce.done;ce=ne.next()){var pe=ce.value,le=pe.modelBindings.get(O);if(le?.modelBounds)return le.modelBounds}}catch(be){U={error:be}}finally{try{ce&&!ce.done&&(H=ne.return)&&H.call(ne)}finally{if(U)throw U.error}}return null}function W(){var O,U,H,ne,ce,pe,le={texturesPending:0,textureErrors:0,animations:{}};try{for(var be=gn(s.values()),Pe=be.next();!Pe.done;Pe=be.next()){var Q=Pe.value,ie=Q.imageStatus();le.texturesPending+=ie.texturesPending,le.textureErrors+=ie.textureErrors}}catch(ke){O={error:ke}}finally{try{Pe&&!Pe.done&&(U=be.return)&&U.call(be)}finally{if(O)throw O.error}}try{for(var Me=gn(m.values()),Le=Me.next();!Le.done;Le=Me.next()){var Ee=Le.value;try{for(var Xe=(ce=void 0,gn(Ee.modelBindings)),tt=Xe.next();!tt.done;tt=Xe.next()){var Ge=Ya(tt.value,2),Ye=Ge[0],dt=Ge[1];dt.animator&&(le.animations[Ye]=dt.animator.snapshot())}}catch(ke){ce={error:ke}}finally{try{tt&&!tt.done&&(pe=Xe.return)&&pe.call(Xe)}finally{if(ce)throw ce.error}}}}catch(ke){H={error:ke}}finally{try{Le&&!Le.done&&(ne=Me.return)&&ne.call(Me)}finally{if(H)throw H.error}}return le}function se(O){var U=m.get(O);U&&(U.recoil=1)}return{getStage:B,syncStage:A,renderStage:z,reset:V,dispose:$,stepAnimations:T,playModelAnimation:S,modelBoundsFor:Y,modelStatus:W,triggerRecoil:se}}var us=function(){return us=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},us.apply(this,arguments)},pa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},ma=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},kc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ng=function(n,e,t){return Math.max(e,Math.min(t,n))},Ds=function(n,e){return Math.hypot(e.x-n.x,e.y-n.y)};function ig(n){var e=n.id,t=n.nodes,i=n.edges,r=n.gates,a=r===void 0?[]:r,s=n.onEvent,o=s===void 0?function(){}:s,u=new Map(t.map(function(S){return[S.id,us({},S)]})),l=new Map(i.map(function(S){return[S.id,us({speedScale:1,enabled:!0,bidirectional:!1,cost:0},S)]})),d=new Map(a.map(function(S){return[S.id,us({},S)]})),f=new Map,h=f,m=0,y=0,M=function(S){return u.get(S)},g=function(S){return ma([],pa(d.values()),!1).find(function(Y){return Y.parameters.nodeId===S})},v=function(S){var Y=S.parameters;if(Y.mode==="open")return!0;if(Y.mode==="closed")return!1;var W=Y.openSeconds+Y.closedSeconds,se=(m+Y.phaseOffsetSeconds)%W;return se<Y.openSeconds},P=function(S){return ma([],pa(l.values()),!1).filter(function(Y){return Y.enabled&&(Y.from===S||Y.bidirectional&&Y.to===S)}).sort(function(Y,W){return Y.id<W.id?-1:Y.id>W.id?1:0})},p=function(S,Y){return ma([],pa(l.values()),!1).find(function(W){return W.enabled&&(W.from===S&&W.to===Y||W.bidirectional&&W.from===Y&&W.to===S)})};function _(S,Y){var W,se,O,U;if(S===Y)return[S];for(var H=new Map([[S,0]]),ne=new Map,ce=new Set([S]);ce.size;){var pe=ma([],pa(ce),!1).sort(function(Ge,Ye){return H.get(Ge)-H.get(Ye)||(Ge<Ye?-1:Ge>Ye?1:0)})[0];if(ce.delete(pe),pe===Y)break;try{for(var le=(W=void 0,kc(P(pe))),be=le.next();!be.done;be=le.next()){var Pe=be.value,Q=Pe.from===pe?Pe.to:Pe.from,ie=g(Q),Me=M(Q),Le=ie?ie.parameters.holdSeconds*90+(v(ie)?0:ie.parameters.closedSeconds*90):0,Ee=H.get(pe)+Ds(M(pe),Me)/Pe.speedScale+Pe.cost+((O=Me.cost)!==null&&O!==void 0?O:0)+Le;Ee>=((U=H.get(Q))!==null&&U!==void 0?U:1/0)||(H.set(Q,Ee),ne.set(Q,pe),ce.add(Q))}}catch(Ge){W={error:Ge}}finally{try{be&&!be.done&&(se=le.return)&&se.call(le)}finally{if(W)throw W.error}}}if(!H.has(Y))return[];for(var Xe=[Y],tt=Y;tt!==S;)tt=ne.get(tt),Xe.unshift(tt);return Xe}function N(S){var Y,W=S.route.length>=2&&S.segment<S.route.length-1;if(!W){var se=(Y=S.route[Math.min(S.segment,S.route.length-1)])!==null&&Y!==void 0?Y:S.startNode,O=_(se,S.target);S.route=O.length?O:[se],S.segment=0,S.distance=0,S.arrived=!1,S.active=S.route.length>=2;return}var U=S.route[S.segment],H=S.route[S.segment+1],ne=Ds(M(U),M(H));if(S.arrived||S.distance>=ne-1e-4){var O=_(H,S.target);S.route=O.length?O:[H],S.segment=0,S.distance=0,S.arrived=!1,S.active=S.route.length>=2;return}var ce=_(H,S.target);S.route=ce.length?ma([U],pa(ce),!1):[U,H],S.segment=0}function D(S){var Y,W=_(S.startNode,S.targetNode),se=M(S.startNode),O=W.length>=2?M(W[1]):se,U=W.length>=2?Math.atan2(O.y-se.y,O.x-se.x):0,H=Math.floor((U%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,ne=us(us({},S),{loop:(Y=S.loop)!==null&&Y!==void 0?Y:"none",originNode:S.startNode,destinationNode:S.targetNode,target:S.targetNode,networkId:e,route:W.length?W:[S.startNode],segment:0,distance:0,x:se.x,y:se.y,heading:U,frame:[0,1,2,3][H],flipX:Math.cos(U)<0,hold:0,arrived:!1,active:S.active&&W.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return f.set(ne.id,ne),ne}function B(S){if(w("pathArrive",S,S.target),S.loop==="none"){S.active=!1;return}var Y=S.target,W=S.loop==="ping-pong"?Y===S.destinationNode?S.originNode:S.destinationNode:Y===S.originNode?S.destinationNode:S.originNode;S.startNode=Y,S.target=W,S.route=_(Y,W),S.segment=0,S.distance=0,S.arrived=!1,S.route.length<2&&(S.active=!1)}function w(S,Y,W){o(S,{componentId:Y.id,nodeId:W})}function A(S,Y){var W,se,O=S.route[S.segment+1],U=g(O);if(U&&!v(U)){S.blockedTicks++,S.blockedTicks>=30&&!S.blockedEmitted&&(S.blockedEmitted=!0,w("pathBlocked",S,O));return}if(!S.arrived){if(S.arrived=!0,S.segment+1===S.route.length-1){O===S.target?B(S):(S.active=!1,S.blockedEmitted||(S.blockedEmitted=!0,w("pathBlocked",S,O)));return}S.hold=Math.max((W=M(O).holdSeconds)!==null&&W!==void 0?W:0,(se=U?.parameters.holdSeconds)!==null&&se!==void 0?se:0)}if(S.hold>0){S.hold=Math.max(0,S.hold-Y),S.blockedTicks++,S.blockedTicks>=30&&!S.blockedEmitted&&(S.blockedEmitted=!0,w("pathBlocked",S,O));return}S.segment++,S.distance=0,S.arrived=!1,S.blockedTicks=0,S.blockedEmitted=!1}function z(S,Y){var W,se;if(S.spacing<=0)return Y;var O=S.route[S.segment],U=S.route[S.segment+1],H=Ds(M(O),M(U)),ne=H-S.distance,ce=Y;try{for(var pe=kc(h.values()),le=pe.next();!le.done;le=pe.next()){var be=le.value;if(!(be.id===S.id||!be.active||be.route.length<2||be.segment>=be.route.length-1)){var Pe=be.route[be.segment],Q=be.route[be.segment+1],ie=1/0;if(Pe===O&&Q===U&&(be.distance>S.distance||be.distance===S.distance&&be.id<S.id))ie=be.distance-S.distance;else if(Pe===U)ie=ne+be.distance;else if(Q===U&&Pe!==O){var Me=Ds(M(Pe),M(Q))-be.distance;Me<S.spacing&&(Me<ne||Me===ne&&be.id<S.id)&&(ie=ne)}ie<1/0&&(ce=Math.min(ce,Math.max(0,ie-S.spacing)))}}}catch(Le){W={error:Le}}finally{try{le&&!le.done&&(se=pe.return)&&se.call(pe)}finally{if(W)throw W.error}}return ce}function V(S){var Y=M(S.route[S.segment]),W=M(S.route[S.segment+1]),se=Ds(Y,W),O=ng(S.distance/Math.max(1e-4,se),0,1),U=Y.x+(W.x-Y.x)*O,H=Y.y+(W.y-Y.y)*O,ne=Math.atan2(W.y-Y.y,W.x-Y.x),ce=Math.min(S.cornerRadius,se/3),pe=S.route[S.segment+2];if(ce>0&&pe){var le=M(pe),be=Ds(W,le),Pe=Math.min(ce,be/3);if(S.distance>se-ce){var Q={x:W.x-(W.x-Y.x)/se*ce,y:W.y-(W.y-Y.y)/se*ce},ie={x:W.x+(le.x-W.x)/be*Pe,y:W.y+(le.y-W.y)/be*Pe},Me=ng((S.distance-(se-ce))/(ce*2),0,.5),Le=1-Me;U=Le*Le*Q.x+2*Le*Me*W.x+Me*Me*ie.x,H=Le*Le*Q.y+2*Le*Me*W.y+Me*Me*ie.y;var Ee=2*Le*(W.x-Q.x)+2*Me*(ie.x-W.x),Xe=2*Le*(W.y-Q.y)+2*Me*(ie.y-W.y);Math.abs(Ee)+Math.abs(Xe)>.001&&(ne=Math.atan2(Xe,Ee))}}return{x:U,y:H,heading:ne}}function $(S){var Y,W,se,O;m+=S,y++;var U=ma([],pa(f.values()),!1).sort(function(ke,at){return ke.id<at.id?-1:ke.id>at.id?1:0}),H=U.length?y%U.length:0,ne=ma(ma([],pa(U.slice(H)),!1),pa(U.slice(0,H)),!1);try{for(var ce=kc(ne),pe=ce.next();!pe.done;pe=ce.next()){var le=pe.value;if(!(!le.active||le.route.length<2||le.segment>=le.route.length-1)){var be=le.route[le.segment],Pe=le.route[le.segment+1],Q=Ds(M(be),M(Pe));if(!(le.distance>=Q-1e-4&&(A(le,S),!le.active||le.route.length<2||le.segment>=le.route.length-1))){var ie=le.route[le.segment],Me=le.route[le.segment+1],Le=Ds(M(ie),M(Me)),Ee=Le-le.distance,Xe=(O=(se=p(ie,Me))===null||se===void 0?void 0:se.speedScale)!==null&&O!==void 0?O:1,tt=Math.min(Ee,le.speed*Xe*Math.max(0,le.speedMultiplier)*S),Ge=z(le,tt);Ge<=1e-4?(le.blockedTicks++,le.blockedTicks>=30&&!le.blockedEmitted&&(le.blockedEmitted=!0,w("pathBlocked",le,Me))):(le.distance+=Ge,le.blockedTicks=0,le.blockedEmitted=!1);var Ye=V(le);le.x=Ye.x,le.y=Ye.y,le.heading=Ye.heading;var dt=Math.floor((le.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;le.frame=[0,1,2,3][dt],le.flipX=Math.cos(le.heading)<0}}}}catch(ke){Y={error:ke}}finally{try{pe&&!pe.done&&(W=ce.return)&&W.call(ce)}finally{if(Y)throw Y.error}}}function T(){return{id:e,nodeCount:u.size,edgeCount:l.size,activeAgents:ma([],pa(f.values()),!1).filter(function(S){return S.active}).length,queuedAgents:ma([],pa(f.values()),!1).filter(function(S){return S.active&&S.blockedTicks>0}).length,agents:ma([],pa(f.values()),!1).map(function(S){var Y;return{id:S.id,x:S.x,y:S.y,heading:S.heading,frame:(Y=S.frame)!==null&&Y!==void 0?Y:0,flipX:!!S.flipX,active:S.active,targetNode:S.target,route:ma([],pa(S.route),!1),segment:S.segment,distance:S.distance,blocked:S.blockedTicks>0}})}}return{addAgent:D,removeAgent:function(S){return f.delete(S)},getAgent:function(S){return f.get(S)},setTarget:function(S,Y){var W=f.get(S);return!W||!M(Y)?!1:(W.target=Y,W.destinationNode=Y,W.active=!0,N(W),!0)},setEdge:function(S,Y,W){var se,O,U=l.get(S);if(!U)return!1;U.enabled=Y,W!==void 0&&(U.cost=W);try{for(var H=kc(f.values()),ne=H.next();!ne.done;ne=H.next()){var ce=ne.value;N(ce)}}catch(pe){se={error:pe}}finally{try{ne&&!ne.done&&(O=H.return)&&O.call(H)}finally{if(se)throw se.error}}return!0},setGate:function(S,Y,W){var se,O,U=d.get(S);if(!U)return!1;U.parameters=us(us({},U.parameters),{mode:Y,holdSeconds:W});try{for(var H=kc(f.values()),ne=H.next();!ne.done;ne=H.next()){var ce=ne.value;N(ce)}}catch(pe){se={error:pe}}finally{try{ne&&!ne.done&&(O=H.return)&&O.call(H)}finally{if(se)throw se.error}}return!0},tick:$,snapshot:T}}var zc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},vf=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},gf=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},yf={A:["01110","10001","10001","11111","10001","10001","10001"],B:["11110","10001","10001","11110","10001","10001","11110"],C:["01111","10000","10000","10000","10000","10000","01111"],D:["11110","10001","10001","10001","10001","10001","11110"],E:["11111","10000","10000","11110","10000","10000","11111"],F:["11111","10000","10000","11110","10000","10000","10000"],G:["01111","10000","10000","10111","10001","10001","01111"],H:["10001","10001","10001","11111","10001","10001","10001"],I:["11111","00100","00100","00100","00100","00100","11111"],J:["00111","00010","00010","00010","10010","10010","01100"],K:["10001","10010","10100","11000","10100","10010","10001"],L:["10000","10000","10000","10000","10000","10000","11111"],M:["10001","11011","10101","10101","10001","10001","10001"],N:["10001","11001","10101","10011","10001","10001","10001"],O:["01110","10001","10001","10001","10001","10001","01110"],P:["11110","10001","10001","11110","10000","10000","10000"],Q:["01110","10001","10001","10001","10101","10010","01101"],R:["11110","10001","10001","11110","10100","10010","10001"],S:["01111","10000","10000","01110","00001","00001","11110"],T:["11111","00100","00100","00100","00100","00100","00100"],U:["10001","10001","10001","10001","10001","10001","01110"],V:["10001","10001","10001","10001","10001","01010","00100"],W:["10001","10001","10001","10101","10101","10101","01010"],X:["10001","10001","01010","00100","01010","10001","10001"],Y:["10001","10001","01010","00100","00100","00100","00100"],Z:["11111","00001","00010","00100","01000","10000","11111"],0:["01110","10001","10011","10101","11001","10001","01110"],1:["00100","01100","00100","00100","00100","00100","01110"],2:["01110","10001","00001","00010","00100","01000","11111"],3:["11110","00001","00001","01110","00001","00001","11110"],4:["00010","00110","01010","10010","11111","00010","00010"],5:["11111","10000","10000","11110","00001","00001","11110"],6:["01110","10000","10000","11110","10001","10001","01110"],7:["11111","00001","00010","00100","01000","01000","01000"],8:["01110","10001","10001","01110","10001","10001","01110"],9:["01110","10001","10001","01111","00001","00001","01110"],"!":["00100","00100","00100","00100","00100","00000","00100"],"?":["01110","10001","00001","00010","00100","00000","00100"],".":["00000","00000","00000","00000","00000","00110","00110"],",":["00000","00000","00000","00000","00110","00110","00100"],":":["00000","00110","00110","00000","00110","00110","00000"],"+":["00000","00100","00100","11111","00100","00100","00000"],"-":["00000","00000","00000","11111","00000","00000","00000"],"/":["00001","00010","00010","00100","01000","01000","10000"],"'":["00100","00100","00000","00000","00000","00000","00000"]," ":["000","000","000","000","000","000","000"]},Vc=function(n){var e,t,i,r,a=0;try{for(var s=zc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a+=((r=(i=yf[u])===null||i===void 0?void 0:i[0].length)!==null&&r!==void 0?r:5)+1}}catch(l){e={error:l}}finally{try{o&&!o.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return Math.max(0,a-1)},Aw=function(n,e){var t,i,r=[],a="";try{for(var s=zc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a&&Vc(a+u)>e&&(r.push(a),a=""),a+=u}}catch(l){t={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return a&&r.push(a),r};function Iw(n,e,t){var i,r,a,s,o;t===void 0&&(t=1);var u=Math.max(1,Math.floor(e/Math.max(1,t))),l=[];try{for(var d=zc(String(n).toUpperCase().split(`
|
|
4221
|
-
`)),f=d.next();!f.done;f=d.next()){var h=f.value,m=h.split(/\s+/).filter(Boolean);if(!m.length){l.push("");continue}var y="";try{for(var M=(a=void 0,
|
|
4222
|
-
`):
|
|
4223
|
-
`&&!yf[y]}))),!1),l,d=s;d>=o;d--){var f=Cw(n,e,d,r),h=f.renderedWidth>r,m=f.allLines.length>16||f.renderedHeight>a;if(l={lines:f.lines,scale:d,fontSize:d*8,renderedWidth:f.renderedWidth,renderedHeight:f.renderedHeight,overflowsWidth:h,overflowsHeight:m,unsupportedChars:u},e.autoFit===!1||!h&&!m)break}return l}function ag(n,e,t){var i,r=Np(e,t),a=r.lines,s=r.scale,o=rg(t),u=Math.max(0,t.width-2*o.x),l=Math.max(0,t.height-2*o.y),d=Math.round(r.fontSize*((i=t.lineHeight)!==null&&i!==void 0?i:1.2)),f=o.y+(l-r.renderedHeight)/2;return n.fillStyle=t.color,a.forEach(function(h,m){var y,M,g,v=Vc(h)*s,P=t.align==="left"?o.x:t.align==="right"?t.width-v-o.x:o.x+(u-v)/2,p=P;try{for(var _=zc(h),N=_.next();!N.done;N=_.next()){var D=N.value,B=(g=yf[D])!==null&&g!==void 0?g:yf["?"];B.forEach(function(w,A){for(var z=0;z<w.length;z++)w[z]==="1"&&n.fillRect(Math.round(p+z*s),Math.round(f+m*d+A*s),s,s)}),p+=(B[0].length+1)*s}}catch(w){y={error:w}}finally{try{N&&!N.done&&(M=_.return)&&M.call(_)}finally{if(y)throw y.error}}}),r}var qa=function(){return qa=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},qa.apply(this,arguments)},Fp=Math.PI*2,Di=function(n,e){return((Math.imul(n+1,2654435769)^Math.imul(e,2246822507))>>>0)/4294967296};function Op(n,e,t){var i,r,a=[n.color,n.color2,n.color3].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+Di(l,1)*.6)/n.count-.5)*s,m=n.speed*(.42+.65*Di(l,2));return qa(qa({},e),{clipId:t,shape:"pixel-confetti",age:-.12*Di(l,3),vx:Math.cos(h)*m,vy:Math.sin(h)*m,gravity:(d=n.gravity)!==null&&d!==void 0?d:250,life:((f=n.lifetime)!==null&&f!==void 0?f:.7)*(.6+.4*Di(l,4)),color:a[l%a.length],size:3+Math.floor(3*Di(l,5)),angle:Fp*Di(l,6),spin:(Di(l,7)-.5)*12})})}function sg(n){var e=Math.min(12,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Op(n).map(function(r,a){return qa(qa({},r),{screen:!0,x:(a%e+.15+.7*Di(a,8))/e,y:(Math.floor(a/e)+.15+.7*Di(a,9))/t,vx:i*(Di(a,10)-.5)*.7,vy:i*(.3+.5*Di(a,11)),size:r.size+1})})}var _f=function(n,e){return(n%e+e)%e};function og(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,m=e.color;if(!(o<0)){var y=a*o,M=s*o+l*o*o/2,g=Math.round(t?t.x+_f(i*t.width+y,t.width):i+y),v=Math.round(t?t.y+_f(r*t.height+M,t.height):r+M),P=Math.round((f+h*o)/(Math.PI/4))&3;if(n.globalAlpha*=Math.min(1,(u-o)*4),n.fillStyle="#3c293388",P===0)n.fillRect(g-d+1,v+1,d*2+1,d+1);else if(P===2)n.fillRect(g+1,v-d+1,d+1,d*2+1);else for(var p=-1;p<=1;p++)n.fillRect(g+p*d+1,v+p*d*(P===1?1:-1)+1,d+1,d+1);if(n.fillStyle=m,P===0)n.fillRect(g-d,v,d*2,d);else if(P===2)n.fillRect(g,v-d,d,d*2);else for(var p=-1;p<=1;p++)n.fillRect(g+p*d,v+p*d*(P===1?1:-1),d,d)}}function Bp(n,e,t){var i,r,a=[n.color,n.color2,n.color3,"#ff6b6b","#4ecdc4","#fff3b0"].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+Di(l,11)*.6)/n.count-.5)*s,m=n.speed*(.45+.65*Di(l,12));return qa(qa({},e),{clipId:t,shape:"confetti",age:-.15*Di(l,13),vx:Math.cos(h)*m,vy:Math.sin(h)*m,gravity:(d=n.gravity)!==null&&d!==void 0?d:140,life:((f=n.lifetime)!==null&&f!==void 0?f:2.6)*(.75+.35*Di(l,14)),color:a[l%a.length],size:5+Math.floor(5*Di(l,15)),kind:l%5===0?"star":"ribbon",angle:Fp*Di(l,16),spin:(Di(l,17)-.5)*5.5,flutter:1.6+2.2*Di(l,18),phase:Fp*Di(l,19)})})}function lg(n){var e=Math.min(14,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Bp(n,{x:0,y:0}).map(function(r,a){var s;return qa(qa({},r),{screen:!0,x:(a%e+.12+.76*Di(a,20))/e,y:(Math.floor(a/e)+.08+.84*Di(a,21))/t,vx:i*(Di(a,22)-.5)*.65,vy:i*(.38+.55*Di(a,23)),gravity:Math.min((s=n.gravity)!==null&&s!==void 0?s:90,90)})})}function cg(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,m=e.flutter,y=e.phase,M=e.color,g=e.kind;if(!(o<0)){var v=Math.sin(o*m+y)*14,P=a*o+v,p=s*o+l*o*o/2,_=t?t.x+_f(i*t.width+P,t.width):i+P,N=t?t.y+_f(r*t.height+p,t.height):r+p,D=Math.min(1,o*2.8,(u-o)*2.2);if(!(D<=0)){n.save(),n.globalAlpha*=D,n.translate(_,N),n.rotate(f+h*o);var B=Math.cos(o*m*1.4+y);if(n.scale(1,Math.max(.22,Math.abs(B))),n.fillStyle=M,g==="star"){var w=d*.85;n.beginPath();for(var A=0;A<8;A++){var z=A%2===0?w:w*.38,V=A*Math.PI/4;A===0?n.moveTo(Math.cos(V)*z,Math.sin(V)*z):n.lineTo(Math.cos(V)*z,Math.sin(V)*z)}n.closePath(),n.fill()}else n.fillRect(-d*.7,-d*.34,d*1.4,d*.68),n.fillStyle="#ffffff55",n.fillRect(-d*.7,-d*.34,d*1.4,d*.2);n.restore()}}}function ug(n,e,t,i,r){var a=e.width,s=e.height;if(!(a<=0||s<=0)){var o=Math.min(3,Math.floor(Math.min(a,s)/8));if(!o){n.fillStyle=t,n.fillRect(0,0,a,s);return}var u=i?o*2:0,l=s-(i?o:o*3),d=r>=0?.5+.5*Math.sin(r*4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd05a99",n.shadowBlur=8+d*9,n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.restore()),n.fillStyle=e.stroke,n.fillRect(o,0,a-2*o,s),n.fillRect(0,o,a,s-2*o),n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.fillStyle="#431d1380",n.fillRect(o,l,a-2*o,s-o-l),n.fillStyle=e.enabled?"#fff4be":"#ffffff55",n.fillRect(2*o,u+o,a-4*o,i?o:o*2),n.fillStyle="#ffffff55",n.fillRect(o,u+3*o,o,Math.max(0,l-u-3*o)),n.fillStyle="#521b2444",n.fillRect(a-2*o,u+3*o,o,Math.max(0,l-u-3*o));var f=r>=0?r%1.9:-1,h=(f-.1)/.55;if(e.enabled&&!i&&h>=0&&h<1){n.save(),n.beginPath(),n.rect(2*o,u+3*o,a-4*o,Math.max(0,l-u-3*o)),n.clip();for(var m=Math.floor(((a+14*o)*h-6*o)/o)*o,y=u+3*o,M=0;y<l;y+=o,M++){var g=m-Math.floor(M/2)*o;n.fillStyle="#fff4be44",n.fillRect(g-2*o,y,9*o,o),n.fillStyle="#fffef0aa",n.fillRect(g,y,4*o,o)}n.restore()}if(e.enabled&&!i&&r>=0){var v=Math.max(0,Math.sin(r*4.2)),P=Math.max(0,Math.sin(r*4.2+2.2)),p=function(_,N,D){if(!(D<.25)){n.save(),n.globalAlpha*=D*.95,n.fillStyle="#fffef4";var B=D>.65?o*2:o;n.fillRect(Math.round(_-B),Math.round(N-o/2),B*2+o,o),n.fillRect(Math.round(_-o/2),Math.round(N-B),o,B*2+o),n.restore()}};p(5*o,u+4*o,v),p(a-6*o,u+5*o,P)}}}function xf(n,e,t,i,r,a){var s=Math.max(0,Math.min(a,i/2,r/2));n.beginPath(),typeof n.roundRect=="function"?n.roundRect(e,t,i,r,s):(n.moveTo(e+s,t),n.arcTo(e+i,t,e+i,t+r,s),n.arcTo(e+i,t+r,e,t+r,s),n.arcTo(e,t+r,e,t,s),n.arcTo(e,t,e+i,t,s),n.closePath())}function Up(n,e,t,i,r){if(!(r<=.02||i<=.5)){n.save(),n.translate(e,t),n.globalAlpha*=r,n.fillStyle="#fffef0",n.beginPath();for(var a=0;a<8;a++){var s=a%2===0?i:i*.24,o=a*Math.PI/4;a===0?n.moveTo(Math.cos(o)*s,Math.sin(o)*s):n.lineTo(Math.cos(o)*s,Math.sin(o)*s)}n.closePath(),n.fill(),n.restore()}}function dg(n,e,t,i,r){var a,s,o,u=e.width,l=e.height;if(!(u<=0||l<=0)){var d=Math.min((a=e.radius)!==null&&a!==void 0?a:16,u/2,l/2),f=i?2:6,h=i?3:0,m=r>=0?.5-.5*Math.cos(r*2.4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd23f99",n.shadowBlur=10+m*12,xf(n,0,h,u,l-h,d),n.fillStyle=t,n.fill(),n.restore()),n.save(),xf(n,0,h+2,u,Math.max(4,l-h-2),d),n.fillStyle="#0e2830",n.fill(),n.restore(),n.save(),xf(n,0,h,u,Math.max(4,l-f),d),n.fillStyle=t,n.fill(),n.clip();var y=(s=n.createLinearGradient)===null||s===void 0?void 0:s.call(n,0,h,0,l-f);if(y?.addColorStop&&(y.addColorStop(0,"#ffffffa8"),y.addColorStop(.42,"#ffffff26"),y.addColorStop(.45,"#00000000"),y.addColorStop(1,"#00000024"),n.fillStyle=y,n.fillRect(0,h,u,l-f)),n.fillStyle="#fffef0bb",n.fillRect(d*.55,h+3,Math.max(0,u-d*1.1),3),e.enabled&&!i&&r>=0){var M=(r%2.4-.15)/.95;if(M>0&&M<1){var g=M*M*(3-2*M),v=Math.sin(M*Math.PI),P=-u*.36+u*1.72*g;n.save(),n.globalAlpha*=v,n.translate(P,h),n.transform(1,0,-.36,1,0,0);var p=(o=n.createLinearGradient)===null||o===void 0?void 0:o.call(n,-48,0,48,0);p?.addColorStop?(p.addColorStop(0,"#ffffff00"),p.addColorStop(.32,"#ffffff48"),p.addColorStop(.5,"#fffef8cc"),p.addColorStop(.68,"#ffffff48"),p.addColorStop(1,"#ffffff00"),n.fillStyle=p,n.fillRect(-48,0,96,l)):(n.fillStyle="#fffef8a8",n.fillRect(-14,0,28,l)),n.restore()}}if(n.restore(),e.strokeWidth&&(n.save(),xf(n,0,h,u,Math.max(4,l-f),d),n.strokeStyle=e.stroke,n.lineWidth=e.strokeWidth,n.stroke(),n.restore()),e.enabled&&!i&&r>=0){var _=Math.max(0,Math.sin(r*2.4)),N=_*_,D=Math.max(0,Math.sin(r*2.4+2.1)),B=D*D,w=Math.max(0,Math.sin(r*2.4+4.2)),A=w*w;Up(n,u*.12,h+9,4+N*6,N*.92),Up(n,u*.88,h+10,3.8+B*5.5,B*.9),Up(n,u*.76,Math.max(h+14,l-f-8),3+A*4.2,A*.8)}}}function Mf(n){if(/\s/.test(n)||n.length>512)return!1;var e=/^https:\/\/play\.google\.com\/store\/apps\/details\?id=[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*){1,9}$/,t=/^https:\/\/apps\.apple\.com\/([a-z]{2}\/)?app\/([a-zA-Z0-9-]+\/)?id[1-9][0-9]{5,19}$/;return e.test(n)&&!/id=example\.|[.=]placeholder(\.|$)|id=com\.example(\.|$)/.test(n)||t.test(n)}var Gc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Hc=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},kp=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function fg(n){var e,t,i;n===void 0&&(n={});var r=(e=n.timeoutMs)!==null&&e!==void 0?e:5e3,a=(t=n.pollMs)!==null&&t!==void 0?t:25;if(![r,a].every(function(O){return Number.isFinite(O)&&O>=1&&O<=6e4}))throw Error("Invalid Unity host deadline/poll interval");var s=(i=n.getHost)!==null&&i!==void 0?i:(function(){return window.mraid}),o=new Set,u=new Set,l=[],d={},f=!1,h=!1,m=!1,y=!1,M=!1,g=!1,v,P,p,_,N,D,B=function(){return m||y};function w(){var O,U,H;clearTimeout(N),clearTimeout(D);try{for(var ne=Gc(l.splice(0)),ce=ne.next();!ce.done;ce=ne.next()){var pe=Hc(ce.value,2),le=pe[0],be=pe[1];try{(H=d.mraid)===null||H===void 0||H.removeEventListener(le,be)}catch{}}}catch(Pe){O={error:Pe}}finally{try{ce&&!ce.done&&(U=ne.return)&&U.call(ne)}finally{if(O)throw O.error}}}function A(O){_?.(O instanceof Error?O:Error(String(O))),p=void 0,_=void 0}function z(O){var U,H;if(!B()){var ne=f;if(m=!0,f=!1,h=!1,w(),A(O),ne)try{for(var ce=Gc(kp([],Hc(u),!1)),pe=ce.next();!pe.done;pe=ce.next()){var le=pe.value;le()}}catch(be){U={error:be}}finally{try{pe&&!pe.done&&(H=ce.return)&&H.call(ce)}finally{if(U)throw U.error}}o.clear(),u.clear()}}function V(O,U){return l.push([O,U]),d.mraid.addEventListener(O,U),$(O,U)}function $(O,U){if(B()){try{d.mraid.removeEventListener(O,U)}catch{}return!1}return!0}function T(O){var U,H;if(!B()){if(typeof O!="boolean"){z(Error("Invalid Unity viewability event"));return}if(!f){v=O;return}if(h!==O){h=O;try{for(var ne=Gc(kp([],Hc(o),!1)),ce=ne.next();!ce.done;ce=ne.next()){var pe=ce.value;if(B())break;pe(h)}}catch(le){U={error:le}}finally{try{ce&&!ce.done&&(H=ne.return)&&H.call(ne)}finally{if(U)throw U.error}}}}}var S=function(O){O==="hidden"&&z(Error("Unity host closed"))},Y=function(){var O;f&&!B()&&((O=n.onResize)===null||O===void 0||O.call(n))};function W(){var O,U,H,ne;if(!(!M||f||g||B())){g=!0;try{var ce=d.mraid.getState();if(B()||ce==="loading")return;if(ce==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(ce))throw Error("Invalid Unity host state");var pe=d.mraid.getVersion();if(B())return;if(pe!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var le=Gc([["viewableChange",T],["stateChange",S],["sizeChange",Y]]),be=le.next();!be.done;be=le.next()){var Pe=Hc(be.value,2),Q=Pe[0],ie=Pe[1];if(!V(Q,ie))return}}catch(tt){O={error:tt}}finally{try{be&&!be.done&&(U=le.return)&&U.call(le)}finally{if(O)throw O.error}}var Me=d.mraid.isViewable();if(B())return;if(typeof Me!="boolean")throw Error("Invalid Unity initial viewability");h=v??Me,f=!0,clearTimeout(N),clearTimeout(D),p?.(),p=void 0,_=void 0;try{for(var Le=Gc(kp([],Hc(o),!1)),Ee=Le.next();!Ee.done;Ee=Le.next()){var Xe=Ee.value;if(B())break;Xe(h)}}catch(tt){H={error:tt}}finally{try{Ee&&!Ee.done&&(ne=Le.return)&&ne.call(Le)}finally{if(H)throw H.error}}}catch(tt){z(tt)}finally{g=!1}}}function se(){if(!B())try{var O=s();if(B())return;if(!O){D=setTimeout(se,a);return}if(d.mraid=O,l.push(["ready",W]),d.mraid.addEventListener("ready",W),!$("ready",W))return;M=!0,W()}catch(U){z(U)}}return{init:function(){return P||(P=new Promise(function(O,U){p=O,_=U}),B()?(A(Error("Unity bridge destroyed")),P):(N=setTimeout(function(){return z(Error("Unity MRAID readiness timed out"))},r),se(),P))},isReady:function(){return f&&!B()},isVisible:function(){return f&&h&&!B()},isClosed:B,onVisibilityChanged:function(O){return B()||o.add(O),function(){return o.delete(O)}},onClosed:function(O){return B()||u.add(O),function(){return u.delete(O)}},openStore:function(O){if(!f||!h||B()||!Mf(O))throw Error("Unity store request not permitted");d.mraid.open(O)},destroy:function(){y||(y=!0,f=!1,h=!1,w(),A(Error("Unity bridge destroyed")),o.clear(),u.clear())}}}var Ml=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Sl=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},zp=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function hg(n){var e;n===void 0&&(n={});var t=(e=n.getHost)!==null&&e!==void 0?e:(function(){return window.mraid}),i,r=!1,a=!1,s=!1,o=!1,u=!1,l,d,f,h,m,y=new Set,M=new Set,g=[];function v(){var V,$;clearTimeout(h),clearTimeout(m);try{for(var T=Ml(g.splice(0)),S=T.next();!S.done;S=T.next()){var Y=Sl(S.value,2),W=Y[0],se=Y[1];try{i?.removeEventListener(W,se)}catch{}}}catch(O){V={error:O}}finally{try{S&&!S.done&&($=T.return)&&$.call(T)}finally{if(V)throw V.error}}}function P(V,$){if(g.push([V,$]),i.addEventListener(V,$),s||o){try{i.removeEventListener(V,$)}catch{}return!1}return!0}function p(V){var $=V instanceof Error?V:Error(String(V));f?.($),d=void 0,f=void 0}function _(V,$){var T,S;if(!(s||o)&&(s=!0,r=!1,a=!1,v(),p(V),$))try{for(var Y=Ml(zp([],Sl(M),!1)),W=Y.next();!W.done;W=Y.next()){var se=W.value;se()}}catch(O){T={error:O}}finally{try{W&&!W.done&&(S=Y.return)&&S.call(Y)}finally{if(T)throw T.error}}}function N(){var V,$,T,S;if(!(!u||r||s||o))try{var Y=i.getState();if(s||o||Y==="loading")return;if(Y==="hidden"){_(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(Y))throw Error("Invalid MRAID state");try{for(var W=Ml([["viewableChange",B],["stateChange",w],["sizeChange",A]]),se=W.next();!se.done;se=W.next()){var O=Sl(se.value,2),U=O[0],H=O[1];if(!P(U,H))return}}catch(le){V={error:le}}finally{try{se&&!se.done&&($=W.return)&&$.call(W)}finally{if(V)throw V.error}}var ne=i.isViewable();if(s||o)return;if(typeof ne!="boolean")throw Error("Invalid MRAID viewability");a=ne,r=!0,clearTimeout(h),clearTimeout(m),d?.(),d=void 0,f=void 0;try{for(var ce=Ml(zp([],Sl(y),!1)),pe=ce.next();!pe.done;pe=ce.next()){var H=pe.value;H(a)}}catch(le){T={error:le}}finally{try{pe&&!pe.done&&(S=ce.return)&&S.call(ce)}finally{if(T)throw T.error}}}catch(le){_(le,r)}}var D=function(){return N()},B=function(V){var $,T;if(!(!r||s||o)){if(typeof V!="boolean"){_(Error("Invalid MRAID visibility event"),!0);return}a=V;try{for(var S=Ml(zp([],Sl(y),!1)),Y=S.next();!Y.done;Y=S.next()){var W=Y.value;W(a)}}catch(se){$={error:se}}finally{try{Y&&!Y.done&&(T=S.return)&&T.call(S)}finally{if($)throw $.error}}}},w=function(V){V==="hidden"&&_(Error("MRAID closed"),!0)},A=function(){var V;r&&!s&&!o&&((V=n.onResize)===null||V===void 0||V.call(n))};function z(){var V,$,T;if(!(s||o))try{if(i=t(),s||o)return;if(!i){m=setTimeout(z,(T=n.pollMs)!==null&&T!==void 0?T:50);return}if(![i.getState,i.isViewable,i.addEventListener,i.removeEventListener,i.open].every(function(U){return typeof U=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var S=Ml([["ready",D]]),Y=S.next();!Y.done;Y=S.next()){var W=Sl(Y.value,2),se=W[0],O=W[1];if(!P(se,O))return}}catch(U){V={error:U}}finally{try{Y&&!Y.done&&($=S.return)&&$.call(S)}finally{if(V)throw V.error}}u=!0,N()}catch(U){_(U,!1)}}return{init:function(){var V;return l||(l=new Promise(function($,T){d=$,f=T}),s||o?(p(Error("MRAID bridge destroyed")),l):(h=setTimeout(function(){return _(Error("MRAID readiness timed out"),!1)},(V=n.timeoutMs)!==null&&V!==void 0?V:5e3),z(),l))},isReady:function(){return r&&!s&&!o},isVisible:function(){return a&&r&&!s&&!o},isClosed:function(){return s||o},onVisibilityChanged:function(V){return!s&&!o&&y.add(V),function(){return y.delete(V)}},onClosed:function(V){return!s&&!o&&M.add(V),function(){return M.delete(V)}},openStore:function(V){if(!r||!a||s||o||!Mf(V))throw Error("MRAID store request not permitted");i.open(V)},destroy:function(){o||(o=!0,r=!1,a=!1,v(),p(Error("MRAID bridge destroyed")),y.clear(),M.clear())}}}var vo=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},go=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Wc=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function pg(n){n===void 0&&(n={});var e=new Set,t=new Set,i=new Set,r=[],a,s=!1,o=!1,u=!1,l=!1,d,f,h,m,y,M=function(){return u||l};function g(){var A,z;clearTimeout(m),clearTimeout(y);try{for(var V=vo(r.splice(0)),$=V.next();!$.done;$=V.next()){var T=go($.value,2),S=T[0],Y=T[1];try{a?.removeEventListener(S,Y)}catch{}}}catch(W){A={error:W}}finally{try{$&&!$.done&&(z=V.return)&&z.call(V)}finally{if(A)throw A.error}}}function v(A){var z,V;if(!M()){u=!0,s=!1,o=!1,g(),h?.(A instanceof Error?A:Error(String(A))),f=void 0,h=void 0;try{for(var $=vo(Wc([],go(t),!1)),T=$.next();!T.done;T=$.next()){var S=T.value;S()}}catch(Y){z={error:Y}}finally{try{T&&!T.done&&(V=$.return)&&V.call($)}finally{if(z)throw z.error}}}}var P=function(A){if(!(typeof A!="number"||!Number.isFinite(A)||A<0))return Math.min(1,A>1?A/100:A)},p=function(A){if(typeof A=="boolean")return A;if(A&&typeof A=="object"&&typeof A.isViewable=="boolean")return A.isViewable},_=function(){var A,z,V,$,T,S;if(!(s||M()||!a||((T=a.isReady)===null||T===void 0?void 0:T.call(a))===!1))try{o=a.isViewable();var Y=(S=a.getAudioVolume)===null||S===void 0?void 0:S.call(a),W=Y===void 0?void 0:P(Y);if(typeof o!="boolean"||Y!==void 0&&W===void 0)throw Error("Invalid DAPI initial state");if(s=!0,clearTimeout(m),clearTimeout(y),f?.(),f=void 0,h=void 0,W!==void 0)try{for(var se=vo(Wc([],go(i),!1)),O=se.next();!O.done;O=se.next()){var U=O.value;U(W)}}catch(ce){A={error:ce}}finally{try{O&&!O.done&&(z=se.return)&&z.call(se)}finally{if(A)throw A.error}}try{for(var H=vo(Wc([],go(e),!1)),ne=H.next();!ne.done;ne=H.next()){var U=ne.value;U(o)}}catch(ce){V={error:ce}}finally{try{ne&&!ne.done&&($=H.return)&&$.call(H)}finally{if(V)throw V.error}}}catch(ce){v(ce)}},N=function(A){var z,V;if(!M()){var $=p(A);if($===void 0){v(Error("Invalid DAPI visibility"));return}o=$;try{for(var T=vo(Wc([],go(e),!1)),S=T.next();!S.done;S=T.next()){var Y=S.value;Y($)}}catch(W){z={error:W}}finally{try{S&&!S.done&&(V=T.return)&&V.call(T)}finally{if(z)throw z.error}}}},D=function(A){var z,V;if(!M()){var $=P(A);if($===void 0){v(Error("Invalid DAPI volume"));return}try{for(var T=vo(Wc([],go(i),!1)),S=T.next();!S.done;S=T.next()){var Y=S.value;Y($)}}catch(W){z={error:W}}finally{try{S&&!S.done&&(V=T.return)&&V.call(T)}finally{if(z)throw z.error}}}},B=function(){var A;s&&!M()&&((A=n.onResize)===null||A===void 0||A.call(n))};function w(){var A,z,V;if(!M()){if(a=window.dapi,!a){y=setTimeout(w,(V=n.pollMs)!==null&&V!==void 0?V:25);return}try{try{for(var $=vo([["ready",_],["viewableChange",N],["audioVolumeChange",D],["adResized",B]]),T=$.next();!T.done;T=$.next()){var S=go(T.value,2),Y=S[0],W=S[1];r.push([Y,W]),a.addEventListener(Y,W)}}catch(se){A={error:se}}finally{try{T&&!T.done&&(z=$.return)&&z.call($)}finally{if(A)throw A.error}}_()}catch(se){v(se)}}}return{init:function(){var A;return d||(d=new Promise(function(z,V){f=z,h=V}),M()?(h?.(Error("DAPI bridge closed")),d):(m=setTimeout(function(){return v(Error("DAPI readiness timed out"))},(A=n.timeoutMs)!==null&&A!==void 0?A:5e3),w(),d))},isReady:function(){return s&&!M()},isVisible:function(){return s&&o&&!M()},isClosed:M,onVisibilityChanged:function(A){return M()||e.add(A),function(){return e.delete(A)}},onClosed:function(A){return M()||t.add(A),function(){return t.delete(A)}},onVolumeChanged:function(A){return M()||i.add(A),function(){return i.delete(A)}},openStore:function(){if(!s||!o||M()||typeof a?.openStoreUrl!="function")throw Error("DAPI store host unavailable");a.openStoreUrl()},destroy:function(){l||(l=!0,s=!1,o=!1,g(),h?.(Error("DAPI bridge destroyed")),e.clear(),t.clear(),i.clear())}}}var Rw=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Pw=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Lw=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Dw=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Nw=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function mg(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=Nw(Dw([],Lw(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return Rw(this,void 0,void 0,function(){return Pw(this,function(a){switch(a.label){case 0:if(i)throw Error("Meta bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Meta bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.FbPlayableAd;if(!e||!t||i||typeof a?.onCTAClick!="function")throw Error("Meta CTA host unavailable");a.onCTAClick()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var Uw=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Fw=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Ow=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Bw=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},kw=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function vg(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=kw(Bw([],Ow(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return Uw(this,void 0,void 0,function(){return Fw(this,function(a){switch(a.label){case 0:if(i)throw Error("Google Ads bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Google Ads bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.ExitApi;if(!e||!t||i||typeof a?.exit!="function")throw Error("Google ExitApi unavailable");a.exit()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var zw=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Vw=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Vp=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Gp=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Hp=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function gg(){var n=window,e=new Set,t=new Set,i=n.gameStart,r=n.gameClose,a=!1,s=!1,o=!1,u=!1,l=function(){var f,h;if(!(o||u)){var m=!s||!a;if(a=!0,s=!0,m)try{for(var y=Hp(Gp([],Vp(e),!1)),M=y.next();!M.done;M=y.next()){var g=M.value;g(!0)}}catch(v){f={error:v}}finally{try{M&&!M.done&&(h=y.return)&&h.call(y)}finally{if(f)throw f.error}}}},d=function(){var f,h,m,y;if(!(o||u)){a=!1,s=!1,o=!0;try{for(var M=Hp(Gp([],Vp(e),!1)),g=M.next();!g.done;g=M.next()){var v=g.value;v(!1)}}catch(_){f={error:_}}finally{try{g&&!g.done&&(h=M.return)&&h.call(M)}finally{if(f)throw f.error}}try{for(var P=Hp(Gp([],Vp(t),!1)),p=P.next();!p.done;p=P.next()){var v=p.value;v()}}catch(_){m={error:_}}finally{try{p&&!p.done&&(y=P.return)&&y.call(P)}finally{if(m)throw m.error}}}};return n.gameStart=l,n.gameClose=d,{init:function(){return zw(this,void 0,void 0,function(){return Vw(this,function(f){if(o||u)throw Error("Mintegral bridge closed");if(typeof n.gameReady!="function")throw Error("Mintegral gameReady host unavailable");return n.gameReady(),[2]})})},isReady:function(){return a&&!o&&!u},isVisible:function(){return a&&s&&!o&&!u},isClosed:function(){return o||u},onVisibilityChanged:function(f){return!o&&!u&&e.add(f),function(){return e.delete(f)}},onClosed:function(f){return!o&&!u&&t.add(f),function(){return t.delete(f)}},notifyGameEnd:function(){var f;!o&&!u&&((f=n.gameEnd)===null||f===void 0||f.call(n))},notifyGameRetry:function(){var f;!o&&!u&&((f=n.gameRetry)===null||f===void 0||f.call(n))},openStore:function(){if(!a||!s||o||u||typeof n.install!="function")throw Error("Mintegral install host unavailable");n.install()},destroy:function(){u||(u=!0,a=!1,s=!1,n.gameStart===l&&(i?n.gameStart=i:delete n.gameStart),n.gameClose===d&&(r?n.gameClose=r:delete n.gameClose),e.clear(),t.clear())}}}var Gw=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Hw=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Ww=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Xw=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Yw=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function yg(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=Yw(Xw([],Ww(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return Gw(this,void 0,void 0,function(){return Hw(this,function(a){switch(a.label){case 0:if(i)throw Error("TikTok bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("TikTok bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a,s,o=window,u=typeof o.openAppStore=="function"?o.openAppStore.bind(o):(s=(a=o.playableSDK)===null||a===void 0?void 0:a.openAppStore)===null||s===void 0?void 0:s.bind(o.playableSDK);if(!e||!t||i||!u)throw Error("TikTok store host unavailable");u()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var It=function(){return It=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},It.apply(this,arguments)},qw=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Zw=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Fe=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Qe=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Be=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function _g(n){if(n!=="standalone"){if(n==="unity-ads-ua-playable")return fg();if(n==="applovin-growth-playable")return hg();if(n==="ironsource-levelplay-playable")return pg();if(n==="meta-audience-playable")return mg();if(n==="google-ads-app-playable")return vg();if(n==="mintegral-appgrowth-zip")return gg();if(n==="tiktok-ads-playable")return yg();throw Error("E_NATIVE_TARGET")}}function Wp(n){var e,t,i,r,a=(e=n.left)!==null&&e!==void 0?e:0,s=(t=n.top)!==null&&t!==void 0?t:0,o=(i=n.right)!==null&&i!==void 0?i:a+n.width,u=(r=n.bottom)!==null&&r!==void 0?r:s+n.height,l=[{id:"sdk-top-left",left:a,top:s,right:Math.min(a+48,o),bottom:Math.min(s+48,u)},{id:"sdk-top-right",left:Math.max(a,o-56),top:s,right:o,bottom:Math.min(s+56,u)},{id:"sdk-bottom-left",left:a,top:Math.max(s,u-28),right:Math.min(a+48,o),bottom:u}];return{left:Math.min(a+48,o),top:Math.min(s+56,u),right:Math.max(a,o-56),bottom:Math.max(s,u-28),zones:l}}function Sf(n,e){var t,i,r=(i=(t=n.measureText)===null||t===void 0?void 0:t.call(n,e))===null||i===void 0?void 0:i.width,a=/(\d+(?:\.\d+)?)px/.exec(n.font||"");return Number.isFinite(r)?r:Qe([],Fe(e),!1).length*(a?Number(a[1]):16)*.6}function xg(n,e,t,i){var r,a,s,o,u,l,d;n.font=t.fontWeight+" "+i+"px "+t.fontFamily;var f=Math.max(0,t.width-2*((d=t.padding)!==null&&d!==void 0?d:4)),h=[];try{for(var m=Be(String(e).split(`
|
|
4224
|
-
`)),y=m.next();!y.done;y=m.next()){var M=y.value;if(t.wrap===!1){h.push(M);continue}var g=M.trim()?M.trim().split(/\s+/):[""],v=void 0;try{for(var P=(s=void 0,Be(g)),p=P.next();!p.done;p=P.next()){var _=p.value,N=v?v+" "+_:_;if(Sf(n,N)<=f){v=N;continue}if(v&&h.push(v),Sf(n,_)<=f){v=_;continue}var D="";try{for(var B=(u=void 0,Be(_)),w=B.next();!w.done;w=B.next()){var A=w.value;D&&Sf(n,D+A)>f?(h.push(D),D=A):D+=A}}catch(z){u={error:z}}finally{try{w&&!w.done&&(l=B.return)&&l.call(B)}finally{if(u)throw u.error}}v=D}}catch(z){s={error:z}}finally{try{p&&!p.done&&(o=P.return)&&o.call(P)}finally{if(s)throw s.error}}h.push(v)}}catch(z){r={error:z}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(r)throw r.error}}return h}function Mg(n,e,t){var i,r,a=(i=t.padding)!==null&&i!==void 0?i:4,s=Math.max(0,t.width-2*a),o=Math.max(0,t.height-2*a),u=Math.min(t.fontSize,(r=t.minFontSize)!==null&&r!==void 0?r:12),l=t.fontSize,d=xg(n,e,t,l),f,h=function(){var m;n.font=t.fontWeight+" "+l+"px "+t.fontFamily;var y=Math.max.apply(Math,Qe([0],Fe(d.map(function(P){return Sf(n,P)})),!1)),M=l*((m=t.lineHeight)!==null&&m!==void 0?m:1.2),g=d.length>16;g&&(d=d.slice(0,16));var v=d.length*M;return{lines:d,fontSize:l,scale:l/t.fontSize,renderedWidth:y,renderedHeight:v,availableWidth:s,availableHeight:o,padding:a,lineHeight:M,overflowsWidth:y>s+.01,overflowsHeight:g||v>o+.01,unsupportedChars:[]}};if(f=h(),t.autoFit!==!1)for(;(f.overflowsWidth||f.overflowsHeight)&&l>u;)l=Math.max(u,l-1),d=xg(n,e,t,l),f=h();return f}function Jw(n,e,t){var i=Mg(n,e,t),r=i.padding;n.fillStyle=t.color,n.font=t.fontWeight+" "+i.fontSize+"px "+t.fontFamily,n.textAlign=t.align,n.textBaseline="middle";var a=t.align==="left"?r:t.align==="right"?t.width-r:t.width/2,s=(t.height-i.renderedHeight)/2;return i.lines.forEach(function(o,u){return n.fillText(o,a,s+(u+.5)*i.lineHeight)}),i}function $w(n,e,t){var i,r,a,s,o,u,l=t===void 0?{}:t,d=l.edit,f=d===void 0?!1:d,h=l.sceneId,m=h===void 0?n.base.startScene:h,y=l.onSelect,M=y===void 0?function(){}:y,g=l.network,v=g===void 0?"standalone":g,P=_g(v),p=e.getContext("2d"),_=new Map(n.components.map(function(c){return[c.id,c]})),N=new Map(n.assets.map(function(c){return[c.id,c]})),D=new Map,B=new Map(n.events.map(function(c){return[c.id,c]})),w=new Map(n.gameplay.filter(function(c){return c.kind==="responsive-layout"}).map(function(c){return[c.componentId,c.parameters]})),A=(a=globalThis.matchMedia)===null||a===void 0?void 0:a.call(globalThis,"(prefers-reduced-motion: reduce)"),z,V=new Map,$=V;function T(){var c=w.size>0&&e.clientWidth>e.clientHeight;return{width:c?Math.max(n.base.width,n.base.height):n.base.width,height:c?Math.min(n.base.width,n.base.height):n.base.height,landscape:c}}function S(){z!==T().landscape&&(er(),Zi())}try{for(var Y=Be(n.assets),W=Y.next();!W.done;W=Y.next()){var se=W.value;if(se.mime.startsWith("image/")){var O=new Image;O.src="data:"+se.mime+";base64,"+se.data,D.set(se.id,O)}}}catch(c){i={error:c}}finally{try{W&&!W.done&&(r=Y.return)&&r.call(Y)}finally{if(i)throw i.error}}var U=m,H={},ne=[],ce=[],pe=[],le=[],be=new Set,Pe=new Map,Q=0,ie=0,Me=0,Le=0,Ee=0,Xe=!1,tt=0,Ge=0,Ye=!1,dt=[],ke,at,Ke,jt,Pt,tn,ue,ln,on,Z,b=[],ee,ve=[],Te=[],Ve,$e=0,Ce=!1,Ae=0,nt=v==="standalone",gt=v==="standalone",ct=v==="standalone",je=!1,Dt=!1,qe=new Map,Gt=new Map,oe=new Map,st=new Map,Ne=new Set,ft=new Map,ht=new Map,ze=new Set,Ot=new Map,Tt=new Map,_t=new Map,Bt=new Map,rt=new Map,Ct=new Map,Jt=0,vn=0,Wt,Ut,yn=1,Sn,nn=new Map,cn=new Map,Pn=new Map,Fn=new Map,ei=new Map,qn=new Map,Hn=new Map,fn=vm(),Wn=xm(),Dn=new Map,si=new Map,xn=bm(uu(n.projectId)),yi=new Map,kn=new Map,ii=new Map,C=new Set,re=new Map,de,me=1,_e=1,Ze,yt,it={x:0,y:0},ut,Lt=[],Nt=[],Rt=new Map,De=new Map,rn=new Map,$t=new Map,En=new Set,xt,An,We;n.components.some(function(c){return c.contract==="native.stage3d.v1"})&&(We=tg(n,N,function(){Dt||Promise.resolve().then(function(){Dt||Zi()})},qe));var vt=function(c){var x;return(x=oe.get(c))!==null&&x!==void 0?x:_.get(c)},pn=function(c,x){return n.gameplay.find(function(I){return I.kind===c&&I.componentId===x})},li=function(){var c,x;Jt++,ze.clear(),Ot.clear(),_t.clear(),Bt.clear();try{for(var I=Be(Ne),E=I.next();!E.done;E=I.next()){var R=E.value;try{R.stop()}catch{}}}catch(F){c={error:F}}finally{try{E&&!E.done&&(x=I.return)&&x.call(I)}finally{if(c)throw c.error}}Ne.clear(),Tt.clear()},vr=function(c){var x,I;if(!de||c!==void 0&&de.pointerId!==c)return!1;var E=de.pointerId;de.behavior.parameters.powerVariableId&&(H[de.behavior.parameters.powerVariableId]=0),de=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,E)&&((I=e.releasePointerCapture)===null||I===void 0||I.call(e,E))}catch{}return!0},Gi=function(c){var x,I,E;if(!xt||c!==void 0&&xt.pointerId!==c)return!1;var R=xt.pointerId;xt.behavior.parameters.powerVariableId&&(H[xt.behavior.parameters.powerVariableId]=0),(x=We?.getStage(_.get(xt.stageId)))===null||x===void 0||x.setGuide([]),xt=void 0;try{!((I=e.hasPointerCapture)===null||I===void 0)&&I.call(e,R)&&((E=e.releasePointerCapture)===null||E===void 0||E.call(e,R))}catch{}return!0},Qi=function(c){var x,I;if(!An||c!==void 0&&An.pointerId!==c)return!1;var E=An.pointerId;An=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,E)&&((I=e.releasePointerCapture)===null||I===void 0||I.call(e,E))}catch{}return!0},Bn=function(c){var x=c.behavior.parameters;x.axisXVariableId&&(H[x.axisXVariableId]=c.nx),x.axisYVariableId&&(H[x.axisYVariableId]=c.ny),x.magnitudeVariableId&&(H[x.magnitudeVariableId]=c.magnitude),x.angleVariableId&&c.magnitude>0&&(H[x.angleVariableId]=c.angle)},Zn=function(c,x){var I,E,R,F;x===void 0&&(x=!1);try{for(var L=Be(re.values()),X=L.next();!X.done;X=L.next()){var G=X.value;if(!(G.pointerId===null||c!==void 0&&G.pointerId!==c)){var K=G.pointerId;G.pointerId=null,G.nx=0,G.ny=0,G.magnitude=0,G.knobX=G.origin.x,G.knobY=G.origin.y,Bn(G);try{!((R=e.hasPointerCapture)===null||R===void 0)&&R.call(e,K)&&((F=e.releasePointerCapture)===null||F===void 0||F.call(e,K))}catch{}x&&In(tr("joystickEnd",G.c))}}}catch(k){I={error:k}}finally{try{X&&!X.done&&(E=L.return)&&E.call(L)}finally{if(I)throw I.error}}},ki=function(c,x){var I,E;if(x===void 0&&(x=!0),!Ke||c!==void 0&&Ke.pointerId!==c)return!1;var R=Ke,F=R.pointerId;if(Ke=void 0,yt=void 0,x){var L=vt(R.targetId);L&&R.b.parameters.snapBack&&(Rr(L,R.origin.x,R.origin.y),R.originZone&&fn.place(L.id,R.originZone))}try{!((I=e.hasPointerCapture)===null||I===void 0)&&I.call(e,F)&&((E=e.releasePointerCapture)===null||E===void 0||E.call(e,F))}catch{}return!0},Jn=function(c){var x,I;ee?.pointerId===c.pointerId&&(ee=void 0);try{for(var E=Be(rt.values()),R=E.next();!R.done;R=E.next()){var F=R.value;F.pointerId===c.pointerId&&F.held&&(F.held=!1,F.releasedAt=Q)}}catch(X){x={error:X}}finally{try{R&&!R.done&&(I=E.return)&&I.call(E)}finally{if(x)throw x.error}}var L=ki(c.pointerId);return tn===c.pointerId?(Pt=void 0,tn=void 0,!0):L},ji=function(c){var x,I,E,R,F,L,X,G;if(c){Ke&&((X=oe.get(Ke.targetId))===null||X===void 0?void 0:X.instanceId)===c&&ki(void 0,!1),de&&((G=oe.get(de.targetId))===null||G===void 0?void 0:G.instanceId)===c&&vr();var K=[];fn.release(c),Wn.cancel(c),yi.delete(c),ii.delete(c),xn.remove(c),ne=ne.filter(function(we){return we.id!==c});try{for(var k=Be(oe),q=k.next();!q.done;q=k.next()){var J=Fe(q.value,2),te=J[0],j=J[1];if(j.instanceId===c){K.push(te),fn.release(te),Wn.cancel(te),oe.delete(te),qe.delete(te),st.delete(te),Pn.delete(te),ei.delete(te),qn.delete(te);try{for(var ae=(E=void 0,Be(Fn.values())),fe=ae.next();!fe.done;fe=ae.next()){var Se=fe.value;Se.removeAgent(te)}}catch(we){E={error:we}}finally{try{fe&&!fe.done&&(R=ae.return)&&R.call(ae)}finally{if(E)throw E.error}}try{for(var xe=(F=void 0,Be(Gt.keys())),Ie=xe.next();!Ie.done;Ie=xe.next()){var ye=Ie.value;ye.endsWith(":"+te)&&Gt.delete(ye)}}catch(we){F={error:we}}finally{try{Ie&&!Ie.done&&(L=xe.return)&&L.call(xe)}finally{if(F)throw F.error}}}}}catch(we){x={error:we}}finally{try{q&&!q.done&&(I=k.return)&&I.call(k)}finally{if(x)throw x.error}}pe=pe.filter(function(we){return!K.includes(we.targetId)})}},ci=function(c){for(;c;){if(c.prototype)return c.id;c=vt(c.parentId)}},yr=function(){var c,x,I;return{viewport:T(),components:Object.fromEntries(Qe([],Fe(qe),!1).map(function(E){var R=Fe(E,2),F=R[0],L=R[1];return[F,It(It({},L),{parameters:It({},L.parameters)})]})),mode:f?"edit":"play",scene:U,variables:It({},H),time:Q,instances:ne.map(function(E){return It({id:E.id,prototypeId:E.prototypeId,x:E.transform[4],y:E.transform[5]},xn.snapshot(E.id))}),particles:ce.length,animations:pe.length,contacts:be.size,spriteFrames:Object.fromEntries(Qe([],Fe(st),!1).map(function(E){var R,F=Fe(E,2),L=F[0],X=F[1];return[L,(R=X.frame)!==null&&R!==void 0?R:0]})),input:{dragging:!!Ke,pointerId:(x=(c=Ke?.pointerId)!==null&&c!==void 0?c:Ze?.pointerId)!==null&&x!==void 0?x:null,pressed:Pt??null,holding:!!Ze?.holds.length,occupancy:fn.snapshot(),joysticks:Object.fromEntries(Qe([],Fe(re),!1).map(function(E){var R=Fe(E,2),F=R[0],L=R[1];return[F,{active:L.pointerId!==null,x:L.nx,y:L.ny,magnitude:L.magnitude,angle:L.angle}]}))},feedback:{presses:rt.size,floatingTexts:ve.length,flashes:Te.length,shaking:!!Ve,tutorialHands:Ae},match:{boards:Object.fromEntries(Qe([],Fe(nn),!1).map(function(E){var R=Fe(E,2),F=R[0],L=R[1];return[F,L.snapshot()]})),selected:Wt??null,cells:Qe([],Fe(Ct),!1).map(function(E){var R=Fe(E,2),F=R[0],L=R[1];return It({id:F},L)})},physics:Ef(),physics3d:Zc(),model3d:We?.modelStatus(),paths:Object.fromEntries(Qe([],Fe(Fn),!1).map(function(E){var R=Fe(E,2),F=R[0],L=R[1];return[F,L.snapshot()]})),canvas:{masks:Object.fromEntries(Qe([],Fe(yi),!1).map(function(E){var R=Fe(E,2),F=R[0],L=R[1];return[F,{progress:L.progress}]})),strokes:Object.fromEntries(Qe([],Fe(kn),!1).map(function(E){var R=Fe(E,2),F=R[0],L=R[1];return[F,L.strokes.length]})),walls:Lt.length,joints:Nt.filter(function(E){return!E.broken}).length},audio:{state:(I=ke?.state)!==null&&I!==void 0?I:"locked",voices:Ne.size,blocked:vn},network:{target:v,ready:gt,visible:ct,started:nt,closed:je,hostVolume:yn},diagnostics:Qe([],Fe(dt),!1)}},xr=function(){return!f&&!Xe&&!document.hidden&>&&ct&&nt&&!je},er=function(){var c,x,I,E;ee=void 0,vr(),Gi(),Qi(),Zn(),ki(),Ze=void 0,yt=void 0,ut=void 0;try{for(var R=Be(kn.values()),F=R.next();!F.done;F=R.next()){var L=F.value;L.cancel()}}catch(k){c={error:k}}finally{try{F&&!F.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}Wn.clear(),Ut=void 0;try{for(var X=Be(nn.values()),G=X.next();!G.done;G=X.next()){var K=G.value;K.cancelSelection()}}catch(k){I={error:k}}finally{try{G&&!G.done&&(E=X.return)&&E.call(X)}finally{if(I)throw I.error}}nn.size&&(Wt=void 0),Pt=void 0,tn=void 0,rt.clear()},Ti=function(c){Ye=!0,dt.push(c),dt=dt.slice(-16),le=[]},Vt=function(c){var x,I,E;return It(It(It({},c.parameters),c.prototypeId?(x=qe.get(c.prototypeId))===null||x===void 0?void 0:x.parameters:{}),(E=qe.get((I=c.runtimeId)!==null&&I!==void 0?I:c.id))===null||E===void 0?void 0:E.parameters)};function Ns(c,x){var I,E=rt.get(c.id);if(!E||A?.matches)return x;var R=Qe([],Fe(x),!1),F=E.held?0:Q-((I=E.releasedAt)!==null&&I!==void 0?I:Q),L=E.held?0:Math.min(1,F/E.behavior.springBackSeconds),X=E.held?E.behavior.scaleDown:E.behavior.scaleDown+(1-E.behavior.scaleDown)*(1-Math.pow(1-L,3)),G=Vt(c);R[4]+=(1-X)*(R[0]*G.width+R[2]*G.height)/2,R[5]+=(1-X)*(R[1]*G.width+R[3]*G.height)/2;for(var K=0;K<4;K++)R[K]*=X;return R}function ds(c){return We&&En.size>0&&ui?{left:ui.x,top:ui.y,right:ui.x+ui.w,bottom:ui.y+ui.h,width:ui.w,height:ui.h}:{left:0,top:0,right:c.width,bottom:c.height,width:c.width,height:c.height}}function zn(c){var x,I,E,R,F,L,X,G=c.transform,K=(E=(I=qe.get((x=c.runtimeId)!==null&&x!==void 0?x:c.id))===null||I===void 0?void 0:I.transform)!==null&&E!==void 0?E:G,k=w.get((R=c.prototypeId)!==null&&R!==void 0?R:c.id);if(!k)return Ns(c,K);var q=T(),J=Qe([],Fe(K),!1);q.landscape&&(J[4]+=k.x-G[4],J[5]+=k.y-G[5],J[0]*=k.scaleX,J[1]*=k.scaleX,J[2]*=k.scaleY,J[3]*=k.scaleY);var te=(F=k.anchor)!==null&&F!==void 0?F:"none";if(te==="none"&&!k.respectSafeArea)return Ns(c,J);var j=ds(q),ae=k.respectSafeArea?Wp(j):j,fe=Vt(c),Se=(L=k.marginX)!==null&&L!==void 0?L:0,xe=(X=k.marginY)!==null&&X!==void 0?X:0,Ie=Math.abs(J[0])*fe.width+Math.abs(J[2])*fe.height,ye=Math.abs(J[1])*fe.width+Math.abs(J[3])*fe.height;return te!=="none"?(J[4]=te.endsWith("left")?ae.left+Se:te.endsWith("right")?ae.right-Ie-Se:(ae.left+ae.right-Ie)/2,J[5]=te.startsWith("top")?ae.top+xe:te.startsWith("bottom")?ae.bottom-ye-xe:(ae.top+ae.bottom-ye)/2):(J[4]=Math.max(ae.left+Se,Math.min(ae.right-Ie-Se,J[4])),J[5]=Math.max(ae.top+xe,Math.min(ae.bottom-ye-xe,J[5]))),Ns(c,J)}var On=function(c){return(oe.has(c)?Qe([],Fe(oe.values()),!1):Qe(Qe([],Fe(n.components),!1),Fe(ne),!1)).filter(function(x){return x.parentId===c&&!x.prototype}).sort(function(x,I){return x.order-I.order||(x.id<I.id?-1:x.id>I.id?1:0)})},oi=function(){return n.components.filter(function(c){return c.sceneId===U&&!c.parentId&&!c.prototype}).sort(function(c,x){return c.order-x.order||(c.id<x.id?-1:c.id>x.id?1:0)})},In=function(c){var x,I;if(c.kind==="sceneEnter"&&((x=n.scenes.find(function(E){return E.id===c.sceneId}))===null||x===void 0?void 0:x.role)==="end-card"&&Sn!==c.sceneId&&(Sn=c.sceneId,(I=P?.notifyGameEnd)===null||I===void 0||I.call(P)),le.length>=256){Ti("Event queue budget exhausted");return}le.push(c)},tr=function(c,x,I,E){var R,F,L,X;return E===void 0&&(E={}),It(It({kind:c,componentId:(R=x.prototypeId)!==null&&R!==void 0?R:x.id,selfInstanceId:(F=x.instanceId)!==null&&F!==void 0?F:x.id,instanceId:x.instanceId},I?{otherId:(L=I.prototypeId)!==null&&L!==void 0?L:I.id,otherInstanceId:(X=I.instanceId)!==null&&X!==void 0?X:I.id}:{}),E)};function Za(c){for(var x,I=c;I;I=vt(I.parentId)){var E=xn.states.get((x=I.instanceId)!==null&&x!==void 0?x:I.id);if(E)return E}}function bl(c){var x,I,E=pn("instance-state",(x=c.prototypeId)!==null&&x!==void 0?x:c.id);return E?xn.initialize((I=c.instanceId)!==null&&I!==void 0?I:c.id,E.parameters):void 0}function Cr(){var c,x,I,E;try{for(var R=Be(n.gameplay.filter(function(k){return k.kind==="instance-state"})),F=R.next();!F.done;F=R.next()){var L=F.value;try{for(var X=(I=void 0,Be(Ii(_.get(L.componentId)))),G=X.next();!G.done;G=X.next()){var K=G.value;bl(K)}}catch(k){I={error:k}}finally{try{G&&!G.done&&(E=X.return)&&E.call(X)}finally{if(I)throw I.error}}}}catch(k){c={error:k}}finally{try{F&&!F.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}}function Ra(c,x,I,E){var R=Za(c);if(R){var F=R.hp;if(x==="tag")R.tag=I==="set"?String(E):R.tag;else{var L=Number(E);if(R[x]=I==="add"?R[x]+L:I==="sub"?R[x]-L:L,!Number.isFinite(R[x])){Ti("Instance state range exceeded");return}x==="hp"&&(R.hp=Math.max(0,Math.min(R.maxHp,R.hp)))}F>0&&R.hp<=0&&In(tr("instanceDepleted",c))}}function Us(c,x){var I,E,R;if(!c)return!0;if(c.all)return c.all.every(function(K){return Us(K,x)});if(c.any)return c.any.some(function(K){return Us(K,x)});var F=c.instanceTarget==="other"?x?.otherInstanceId:(I=x?.selfInstanceId)!==null&&I!==void 0?I:x?.instanceId,L=c.instanceField?(E=vt(F))!==null&&E!==void 0?E:Qe([],Fe(oe.values()),!1).find(function(K){return K.instanceId===F}):void 0,X=c.instanceField?(R=Za(L))===null||R===void 0?void 0:R[c.instanceField]:H[c.variableId],G=c.compareVariableId?H[c.compareVariableId]:c.value;return{eq:function(){return X===G},ne:function(){return X!==G},lt:function(){return X<G},lte:function(){return X<=G},gt:function(){return X>G},gte:function(){return X>=G}}[c.op]()}function wl(c){var x,I,E;Wt=void 0,Ut=void 0,c||Ct.clear();try{for(var R=Be(n.gameplay),F=R.next();!F.done;F=R.next()){var L=F.value;if(L.kind==="match-tile"){var X=_.get(L.componentId);if(c&&X.id!==c&&!Xr(X,c))continue;qe.delete(X.id),Ct.set(X.id,{row:L.parameters.row,column:L.parameters.column,group:L.parameters.group,sceneId:X.sceneId,boardId:(E=X.parentId)!==null&&E!==void 0?E:X.sceneId})}}}catch(G){x={error:G}}finally{try{F&&!F.done&&(I=R.return)&&I.call(R)}finally{if(x)throw x.error}}}function bf(){var c,x,I=function(L){var X,G;if(nn.has(L.componentId))return"continue";var K=L.componentId,k=L.parameters,q=n.gameplay.filter(function(ye){return ye.kind==="match-tile"&&_.get(ye.componentId).parentId===K}).sort(function(ye,we){return ye.parameters.row-we.parameters.row||ye.parameters.column-we.parameters.column}).map(function(ye){return It({id:ye.componentId},ye.parameters)}),J=new Map;try{for(var te=(X=void 0,Be(q)),j=te.next();!j.done;j=te.next()){var ae=j.value;if(!J.has(ae.group)){var fe=_.get(ae.id);J.set(ae.group,{fill:fe.parameters.fill,children:On(ae.id).filter(function(ye){return["native.image.v1","native.text.v1"].includes(ye.contract)})})}}}catch(ye){X={error:ye}}finally{try{j&&!j.done&&(G=te.return)&&G.call(te)}finally{if(X)throw X.error}}cn.set(K,J);var Se=_.get(q[k.columns].id).transform[5]-_.get(q[0].id).transform[5],xe=function(ye,we,he){var Ue,Oe=he.from,et=Oe===void 0?ye:Oe,He=he.progress,Je=He===void 0?0:He,wt=he.offsetRows,kt=wt===void 0?0:wt,en=he.scale,Xt=en===void 0?1:en,Ht=he.opacity,Et=Ht===void 0?1:Ht,Mt=q[ye],At=_.get(Mt.id),St=_.get(q[et].id),pt=J.get(we),bt=Qe([],Fe(At.transform),!1);bt[4]+=(St.transform[4]-At.transform[4])*Je,bt[5]+=(St.transform[5]-At.transform[5]+kt*Se)*Je,bt[4]+=(1-Xt)*(bt[0]*At.parameters.width+bt[2]*At.parameters.height)/2,bt[5]+=(1-Xt)*(bt[1]*At.parameters.width+bt[3]*At.parameters.height)/2;for(var Qt=0;Qt<4;Qt++)bt[Qt]*=Xt;qe.set(Mt.id,It(It({},qe.get(Mt.id)),{transform:bt,parameters:It(It({},(Ue=qe.get(Mt.id))===null||Ue===void 0?void 0:Ue.parameters),{fill:pt.fill,opacity:Et})})),Ct.get(Mt.id).group=we;var ot=On(Mt.id).filter(function(hn){return["native.image.v1","native.text.v1"].includes(hn.contract)});ot.forEach(function(hn,Kt){var Cn,Yt,bn=pt.children[Kt];if(!(!bn||bn.contract!==hn.contract)){var lt=(Cn=qe.get(hn.id))!==null&&Cn!==void 0?Cn:{transform:Qe([],Fe(hn.transform),!1),parameters:{}};hn.contract==="native.image.v1"?lt.assetId=(Yt=bn.assetSlots[0])===null||Yt===void 0?void 0:Yt.assetId:lt.parameters.text=bn.parameters.text,qe.set(hn.id,lt)}})},Ie=hm(It(It({},k),{slots:q,paint:xe,onEvent:function(ye){Wt=void 0,In({kind:ye,componentId:K})}}));nn.set(K,Ie)};try{for(var E=Be(n.gameplay.filter(function(L){return L.kind==="match-board"})),R=E.next();!R.done;R=E.next()){var F=R.value;I(F)}}catch(L){c={error:L}}finally{try{R&&!R.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}function Xc(c){var x,I;bf();try{for(var E=Be(nn),R=E.next();!R.done;R=E.next()){var F=Fe(R.value,2),L=F[0],X=F[1];(!c||c===L||Xr(_.get(L),c))&&X.reset()}}catch(G){x={error:G}}finally{try{R&&!R.done&&(I=E.return)&&I.call(E)}finally{if(x)throw x.error}}}function Ii(c){return ci(c)?Qe([],Fe(oe.values()),!1).filter(function(x){return x.prototypeId===c.id}):[c]}function Ci(c){var x=Vt(c);return ti(ri(c),x.width/2,x.height/2)}function Ja(c,x,I){var E;I===void 0&&(I="self");var R=_.get(c),F=I==="other"?x.otherInstanceId:(E=x.selfInstanceId)!==null&&E!==void 0?E:x.instanceId,L=!!(R&&ci(R));if(F!==void 0){if(c){var X=Qe([],Fe(oe.values()),!1).find(function(G){return G.prototypeId===c&&(G.instanceId===F||G.id===F)});if(X)return X}if(I==="other"||!c)return vt(F);if(L&&typeof F=="string"&&F.startsWith("instance."))return}return R?L?Ii(R)[0]:vt(c):void 0}function Rr(c,x,I){var E,R=Vt(c),F=(E=qe.get(c.id))!==null&&E!==void 0?E:{transform:Qe([],Fe(c.transform),!1),parameters:{}},L=Qe([],Fe(F.transform),!1),X=c.parentId?ri(vt(c.parentId)):Ua(),G=ti(Or(X),x,I);L[4]=G.x-(L[0]*R.width+L[2]*R.height)/2,L[5]=G.y-(L[1]*R.width+L[3]*R.height)/2,qe.set(c.id,It(It({},F),{transform:L})),c.prototypeId&&(c.transform=Qe([],Fe(L),!1))}function Ur(c,x,I){var E,R,F,L;I===void 0&&(I=!1);var X=(E=qe.get(c.id))!==null&&E!==void 0?E:{transform:Qe([],Fe(c.transform),!1),parameters:{}},G=(L=(F=_.get((R=c.prototypeId)!==null&&R!==void 0?R:c.id))===null||F===void 0?void 0:F.transform)!==null&&L!==void 0?L:c.transform,K=Math.hypot(G[0],G[1])*(I?-1:1),k=Math.hypot(G[2],G[3]),q=x+(I?0:Math.atan2(G[1],G[0])),J=Math.cos(q),te=Math.sin(q),j=Qe([],Fe(X.transform),!1);j[0]=J*K,j[1]=te*K,j[2]=-te*k,j[3]=J*k,qe.set(c.id,It(It({},X),{transform:j}))}function ra(c,x){var I=Pn.get(c.id);if(I)return I;var E=ri(c),R=Vt(c),F=ti(E,R.width/2,R.height/2);return I=It({id:c.id,sourceId:x.componentId,instanceId:c.instanceId,x:F.x,y:F.y,vx:0,vy:0,width:Math.hypot(E[0],E[1])*R.width,height:Math.hypot(E[2],E[3])*R.height,angle:Math.atan2(E[1],E[0]),restElapsed:0,atRest:!0},x.parameters),Pn.set(c.id,I),I}function va(c,x){var I,E=yi.get(c.id);if(E)return E;var R=Vt(c),F=x.parameters;return E=wm(F,{width:R.width,height:R.height,source:c.contract==="native.image.v1"?D.get((I=c.assetSlots[0])===null||I===void 0?void 0:I.assetId):void 0,onProgress:function(L){F.progressVariableId&&(H[F.progressVariableId]=L),In(tr("maskProgress",c))},onComplete:function(){return In(tr("maskComplete",c))}}),yi.set(c.id,E),E}function wf(c){var x=kn.get(c.componentId);return x||(x=Am(c.parameters),kn.set(c.componentId,x)),x}function Fs(){var c,x,I,E,R,F,L,X,G,K,k,q,J=new Set,te=[];try{for(var j=Be(n.gameplay.filter(function(bt){return bt.kind==="physics-body"})),ae=j.next();!ae.done;ae=j.next()){var fe=ae.value,Se=_.get(fe.componentId);if(Se.sceneId===U)try{for(var xe=(I=void 0,Be(Ii(Se))),Ie=xe.next();!Ie.done;Ie=xe.next()){var ye=Ie.value;if(hi(ye)){if(te.length>=64){Ti("Physics body budget exhausted");break}var we=ra(ye,fe),he=ri(ye),Ue=Vt(ye),Oe=ti(he,Ue.width/2,Ue.height/2);if(J.add(ye.id),we.width=Math.hypot(he[0],he[1])*Ue.width,we.height=Math.hypot(he[2],he[3])*Ue.height,we.mode!=="dynamic"){var et=ei.get(ye.id),He=ye.parentId?ri(vt(ye.parentId)):Ua(),Je=(k=et?.vx)!==null&&k!==void 0?k:0,wt=(q=et?.vy)!==null&&q!==void 0?q:0;we.x=Oe.x,we.y=Oe.y,we.angle=Math.atan2(he[1],he[0]),we.vx=He[0]*Je+He[2]*wt,we.vy=He[1]*Je+He[3]*wt}else we.atRest&&(we.x=Oe.x,we.y=Oe.y);te.push(we)}}}catch(bt){I={error:bt}}finally{try{Ie&&!Ie.done&&(E=xe.return)&&E.call(xe)}finally{if(I)throw I.error}}}}catch(bt){c={error:bt}}finally{try{ae&&!ae.done&&(x=j.return)&&x.call(j)}finally{if(c)throw c.error}}try{for(var kt=Be(Pn.keys()),en=kt.next();!en.done;en=kt.next()){var Xt=en.value;!J.has(Xt)&&!oe.has(Xt)&&Pn.delete(Xt)}}catch(bt){R={error:bt}}finally{try{en&&!en.done&&(F=kt.return)&&F.call(kt)}finally{if(R)throw R.error}}var Ht=[];try{for(var Et=Be(n.gameplay.filter(function(bt){return bt.kind==="capture-zone"})),Mt=Et.next();!Mt.done;Mt=Et.next()){var fe=Mt.value,Se=_.get(fe.componentId);if(Se.sceneId===U)try{for(var At=(G=void 0,Be(Ii(Se))),St=At.next();!St.done;St=At.next()){var ye=St.value;if(hi(ye)){var he=ri(ye),Ue=Vt(ye),Oe=ti(he,Ue.width/2,Ue.height/2),pt=Math.max(.1,Math.min(Math.hypot(he[0],he[1]),Math.hypot(he[2],he[3])));Ht.push(It(It({id:ye.id,sourceId:Se.id,instanceId:ye.instanceId,x:Oe.x,y:Oe.y},fe.parameters),{radius:fe.parameters.radius*pt}))}}}catch(ot){G={error:ot}}finally{try{St&&!St.done&&(K=At.return)&&K.call(At)}finally{if(G)throw G.error}}}}catch(bt){L={error:bt}}finally{try{Mt&&!Mt.done&&(X=Et.return)&&X.call(Et)}finally{if(L)throw L.error}}return{bodies:Qe(Qe([],Fe(te),!1),Fe(Lt),!1),zones:Ht}}function Os(c){var x,I,E,R,F,L,X,G=Fs(),K=G.bodies,k=G.zones,q=T();Nt=[];try{for(var J=Be(n.gameplay.filter(function(He){return He.kind==="physics-joint"})),te=J.next();!te.done;te=J.next()){var j=te.value,ae=_.get(j.componentId);if(ae.sceneId===U){var fe=vt(j.parameters.anchorComponentId),Se=pn("physics-body",ae.id);if(!(!fe||!Se))try{for(var xe=(E=void 0,Be(Ii(ae))),Ie=xe.next();!Ie.done;Ie=xe.next()){var ye=Ie.value;ra(ye,Se);var we=Ci(fe),he=j.id+":"+ye.id;Nt.push(It(It({},j.parameters),{id:j.id,key:he,componentId:ae.id,bodyId:ye.id,anchorId:fe.id,x:we.x,y:we.y,broken:C.has(he)}))}}catch(He){E={error:He}}finally{try{Ie&&!Ie.done&&(R=xe.return)&&R.call(xe)}finally{if(E)throw E.error}}}}}catch(He){x={error:He}}finally{try{te&&!te.done&&(I=J.return)&&I.call(J)}finally{if(x)throw x.error}}Kf({bodies:K,zones:k,joints:Nt,bounds:{left:0,top:0,right:q.width,bottom:q.height},dt:c,onEvent:function(He,Je,wt){var kt,en,Xt,Ht;if(!(He==="bodyBounce"&&wt&&Je.sourceId===wt.sourceId&&Je.id>wt.id)){var Et=(kt=Je.instanceId)!==null&&kt!==void 0?kt:Je.id,Mt=wt?(en=wt.instanceId)!==null&&en!==void 0?en:wt.id:void 0,At=It(It({kind:He,componentId:Je.sourceId,selfInstanceId:Et},Mt?{otherInstanceId:Mt}:{}),{instanceId:(Xt=Je.instanceId)!==null&&Xt!==void 0?Xt:wt?.instanceId});if(wt&&(At.otherId=wt.sourceId),In(At),He==="zoneCapture"){var St=vt(Je.id),pt=_.get(wt.sourceId);if(wt.hideCaptured&&St){var bt=(Ht=qe.get(St.id))!==null&&Ht!==void 0?Ht:{transform:Qe([],Fe(St.transform),!1),parameters:{}};bt.parameters.visible=!1,qe.set(St.id,bt)}wt.stopBody&&pt&&St&&Rr(St,wt.x,wt.y)}}}});try{for(var Ue=Be(K),Oe=Ue.next();!Oe.done;Oe=Ue.next()){var et=Oe.value,ye=vt(et.id);!ye||et.mode!=="dynamic"||(et.spinToRotation&&Ur(ye,(X=et.angle)!==null&&X!==void 0?X:0),Rr(ye,et.x,et.y))}}catch(He){F={error:He}}finally{try{Oe&&!Oe.done&&(L=Ue.return)&&L.call(Ue)}finally{if(F)throw F.error}}}function Tf(){var c,x,I,E,R;try{for(var F=Be(n.gameplay.filter(function(Ie){return Ie.kind==="oscillate"})),L=F.next();!L.done;L=F.next()){var X=L.value,G=_.get(X.componentId);if(G.sceneId===U)try{for(var K=(I=void 0,Be(Ii(G))),k=K.next();!k.done;k=K.next()){var q=k.value,J=ei.get(q.id);J||(J={base:Qe([],Fe(zn(q)),!1),vx:0,vy:0},ei.set(q.id,J));var te=X.parameters,j=(Q/te.periodSeconds+te.phase)*Math.PI*2,ae=Math.sin(j)*te.amplitude,fe=Math.cos(j)*te.amplitude*Math.PI*2/te.periodSeconds,Se=(R=qe.get(q.id))!==null&&R!==void 0?R:{parameters:{}},xe=Qe([],Fe(J.base),!1);te.axis==="x"?(xe[4]+=ae,J.vx=fe,J.vy=0):(xe[5]+=ae,J.vy=fe,J.vx=0),qe.set(q.id,It(It({},Se),{transform:xe})),ei.set(q.id,J)}}catch(Ie){I={error:Ie}}finally{try{k&&!k.done&&(E=K.return)&&E.call(K)}finally{if(I)throw I.error}}}}catch(Ie){c={error:Ie}}finally{try{L&&!L.done&&(x=F.return)&&x.call(F)}finally{if(c)throw c.error}}}function Bs(){var c,x;Fn.clear();var I=function(L){var X=n.gameplay.filter(function(K){return K.kind==="path-gate"&&K.parameters.networkBehaviorId===L.id}),G=ig({id:L.id,nodes:L.parameters.nodes,edges:L.parameters.edges,gates:X,onEvent:function(K,k){var q,J=vt(k.componentId),te=(q=J?.prototypeId)!==null&&q!==void 0?q:k.componentId;In(It({kind:K,componentId:te,instanceId:J?.instanceId},k.nodeId?{nodeId:k.nodeId}:{}))}});Fn.set(L.id,G)};try{for(var E=Be(n.gameplay.filter(function(L){return L.kind==="path-network"})),R=E.next();!R.done;R=E.next()){var F=R.value;I(F)}}catch(L){c={error:L}}finally{try{R&&!R.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}function ks(c,x){var I,E,R,F,L,X,G,K,k,q,J,te,j;x===void 0&&(x=!0);var ae=0;try{for(var fe=Be(n.gameplay.filter(function(bt){return bt.kind==="path-agent"})),Se=fe.next();!Se.done;Se=fe.next()){var xe=Se.value,Ie=_.get(xe.componentId),ye=Fn.get(xe.parameters.networkBehaviorId);if(!(Ie.sceneId!==U||!ye))try{for(var we=(R=void 0,Be(Ii(Ie))),he=we.next();!he.done;he=we.next()){var Ue=he.value;if(++ae>64){Ti("Path agent budget exhausted");break}var Oe=ye.getAgent(Ue.id);Oe||(Oe=ye.addAgent(It(It({},xe.parameters),{id:Ue.id,startNode:(J=Ue.pathStartNode)!==null&&J!==void 0?J:xe.parameters.startNode,targetNode:(te=Ue.pathTargetNode)!==null&&te!==void 0?te:xe.parameters.targetNode}))),Oe.speedMultiplier=Math.max(0,Number(xe.parameters.speedMultiplierVariableId?H[xe.parameters.speedMultiplierVariableId]:1))}}catch(bt){R={error:bt}}finally{try{he&&!he.done&&(F=we.return)&&F.call(we)}finally{if(R)throw R.error}}}}catch(bt){I={error:bt}}finally{try{Se&&!Se.done&&(E=fe.return)&&E.call(fe)}finally{if(I)throw I.error}}if(x){var et=function(bt,Qt){var ot=n.gameplay.find(function(hn){return hn.id===bt});_.get(ot.componentId).sceneId===U&&Qt.tick(c)};try{for(var He=Be(Fn),Je=He.next();!Je.done;Je=He.next()){var wt=Fe(Je.value,2),kt=wt[0],en=wt[1];et(kt,en)}}catch(bt){L={error:bt}}finally{try{Je&&!Je.done&&(X=He.return)&&X.call(He)}finally{if(L)throw L.error}}}try{for(var Xt=Be(n.gameplay.filter(function(bt){return bt.kind==="path-agent"})),Ht=Xt.next();!Ht.done;Ht=Xt.next()){var xe=Ht.value,Ie=_.get(xe.componentId),Et=Fn.get(xe.parameters.networkBehaviorId);if(!(Ie.sceneId!==U||!Et))try{for(var Mt=(k=void 0,Be(Ii(Ie))),At=Mt.next();!At.done;At=Mt.next()){var Ue=At.value,Oe=Et.getAgent(Ue.id);if(Oe){if(Oe.orientToPath==="rotate")Ur(Ue,Oe.heading);else if(Oe.orientToPath==="flip-x")Ur(Ue,0,Oe.flipX);else if(Oe.orientToPath==="iso-4"){var St=(j=qe.get(Ue.id))!==null&&j!==void 0?j:{transform:Qe([],Fe(Ue.transform),!1),parameters:{}};St.pathFrame=Oe.frame,qe.set(Ue.id,St)}var pt=Ue.parentId?ti(ri(vt(Ue.parentId)),Oe.x,Oe.y):Oe;Rr(Ue,pt.x,pt.y)}}}catch(ot){k={error:ot}}finally{try{At&&!At.done&&(q=Mt.return)&&q.call(Mt)}finally{if(k)throw k.error}}}}catch(bt){G={error:bt}}finally{try{Ht&&!Ht.done&&(K=Xt.return)&&K.call(Xt)}finally{if(G)throw G.error}}}function yo(c){var x,I,E,R,F,L,X,G,K,k,q=new Set;try{for(var J=Be(n.gameplay.filter(function(lt){return lt.kind==="value-meter"})),te=J.next();!te.done;te=J.next()){var j=te.value,ae=_.get(j.componentId);if(ae.sceneId===U)try{for(var fe=(E=void 0,Be(Ii(ae))),Se=fe.next();!Se.done;Se=fe.next()){var xe=Se.value,Ie=j.parameters,ye=Ie.instanceField?Za(xe):void 0,we=Ie.instanceField==="hp"&&ye?ye.hp/ye.maxHp*(Ie.max-Ie.min)+Ie.min:Ie.instanceField==="value"&&ye?ye.value:Number(H[Ie.variableId]),he=qn.get(xe.id);he||(he={base:Qe([],Fe(zn(xe)),!1),value:Number.isFinite(we)?Math.max(Ie.min,Math.min(Ie.max,we)):Ie.min},qn.set(xe.id,he)),q.add(xe.id);var Ue=Math.max(Ie.min,Math.min(Ie.max,we)),Oe=Ie.smoothingSeconds?1-Math.exp(-c/Ie.smoothingSeconds):1;he.value+=((Number.isFinite(Ue)?Ue:Ie.min)-he.value)*Oe;var et=Math.max(0,Math.min(1,(he.value-Ie.min)/(Ie.max-Ie.min))),He=Qe([],Fe(he.base),!1),Je=(K=qe.get(xe.id))!==null&&K!==void 0?K:{parameters:{}},wt=Ie.axis==="x"?Vt(xe).width:Vt(xe).height;if(Ie.axis==="x"?(He[0]*=et,He[1]*=et):(He[2]*=et,He[3]*=et),Ie.direction==="negative"){var kt=wt*(1-et);Ie.axis==="x"?(He[4]+=he.base[0]*kt,He[5]+=he.base[1]*kt):(He[4]+=he.base[2]*kt,He[5]+=he.base[3]*kt)}qe.set(xe.id,It(It({},Je),{transform:He}))}}catch(lt){E={error:lt}}finally{try{Se&&!Se.done&&(R=fe.return)&&R.call(fe)}finally{if(E)throw E.error}}}}catch(lt){x={error:lt}}finally{try{te&&!te.done&&(I=J.return)&&I.call(J)}finally{if(x)throw x.error}}try{for(var en=Be(qn.keys()),Xt=en.next();!Xt.done;Xt=en.next()){var Ht=Xt.value;q.has(Ht)||qn.delete(Ht)}}catch(lt){F={error:lt}}finally{try{Xt&&!Xt.done&&(L=en.return)&&L.call(en)}finally{if(F)throw F.error}}try{for(var Et=Be(n.gameplay.filter(function(lt){return lt.kind==="camera-follow"})),Mt=Et.next();!Mt.done;Mt=Et.next()){var j=Mt.value,At=_.get(j.componentId),Ue=vt(j.parameters.targetId);if(!(At.sceneId!==U||!Ue)){var St=Hn.get(At.id);St||(St={base:Qe([],Fe(At.transform),!1),x:j.parameters.minX,y:j.parameters.minY},Hn.set(At.id,St));var pt=function($n,wi){for(var pi=[],ni=$n;ni&&ni.id!==wi.id;ni=vt(ni.parentId))pi.unshift(ni);return pi.reduce(function(Ri,di){return Io(Ri,zn(di))},Ua())},He=Xr(Ue,At.id)?pt(Ue,At):ri(Ue),Ie=Vt(Ue),bt=ti(He,Ie.width/2,Ie.height/2),Qt=T(),ot=j.parameters,hn=Math.max(ot.minX,ot.maxX-Qt.width/ot.zoom),Kt=Math.max(ot.minY,ot.maxY-Qt.height/ot.zoom),Cn=Math.max(ot.minX,Math.min(hn,bt.x-Qt.width/(2*ot.zoom))),Yt=Math.max(ot.minY,Math.min(Kt,bt.y-Qt.height/(2*ot.zoom))),Oe=1-Math.exp(-ot.smoothing*c);St.x+=(Cn-St.x)*Oe,St.y+=(Yt-St.y)*Oe;var Je=(k=qe.get(At.id))!==null&&k!==void 0?k:{parameters:{}},bn=Qe([],Fe(St.base),!1);bn[0]*=ot.zoom,bn[1]*=ot.zoom,bn[2]*=ot.zoom,bn[3]*=ot.zoom,bn[4]-=St.x*ot.zoom,bn[5]-=St.y*ot.zoom,qe.set(At.id,It(It({},Je),{transform:bn}))}}}catch(lt){X={error:lt}}finally{try{Mt&&!Mt.done&&(G=Et.return)&&G.call(Et)}finally{if(X)throw X.error}}}function Ef(){return{bodies:Qe([],Fe(Pn.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,vx:c.vx,vy:c.vy,atRest:!!c.atRest,captured:!!c.captured}}),aiming:de?{componentId:de.sourceId,pointerId:de.pointerId,power:de.power}:null}}function zs(c){for(var x=c;x;){if(x.contract==="native.stage3d.v1")return x;x=x.parentId?vt(x.parentId):void 0}}function Tl(c,x){var I,E,R,F,L,X,G,K,k=Rt.get(c.id);if(k)return k;var q=Vt(c),J=zs(c),te={};if(x.parameters.fitColliderFromModel&&J&&We){We.getStage(J);var j=We.modelBoundsFor(c.id);if(j){var ae=Math.max(.02,j.width*Math.abs((I=q.sx)!==null&&I!==void 0?I:1)*.5),fe=Math.max(.02,j.depth*Math.abs((E=q.sz)!==null&&E!==void 0?E:1)*.5);te.hx=ae,te.hz=fe,te.radius=Math.max(.02,Math.max(ae,fe))}}return k=It(It({id:c.id,sourceId:x.componentId,stageId:J?.id,x:(R=q.x)!==null&&R!==void 0?R:0,y:(F=q.y)!==null&&F!==void 0?F:0,z:(L=q.z)!==null&&L!==void 0?L:0,vx:0,vy:0,vz:0,spin:0,atRest:!0,captured:!1,captureElapsed:0,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:(X=q.x)!==null&&X!==void 0?X:0,y:(G=q.y)!==null&&G!==void 0?G:0,z:(K=q.z)!==null&&K!==void 0?K:0}},x.parameters),te),Rt.set(c.id,k),k}function xo(){var c,x,I,E,R,F,L,X=[],G=[],K=[];if(!We)return{bodies:X,walls:G,zones:K};try{for(var k=Be(n.gameplay.filter(function(xe){return xe.kind==="physics-3d"})),q=k.next();!q.done;q=k.next()){var J=q.value,te=_.get(J.componentId);if(!(!te||te.sceneId!==U||!hi(te))){var j=Tl(te,J);j.mode==="dynamic"?X.push(j):G.push(j)}}}catch(xe){c={error:xe}}finally{try{q&&!q.done&&(x=k.return)&&x.call(k)}finally{if(c)throw c.error}}try{for(var ae=Be(n.gameplay.filter(function(xe){return xe.kind==="capture-zone-3d"})),fe=ae.next();!fe.done;fe=ae.next()){var J=fe.value,te=_.get(J.componentId);if(!(!te||te.sceneId!==U||!hi(te))){var Se=Vt(te);K.push(It({id:te.id,sourceId:te.id,x:(R=Se.x)!==null&&R!==void 0?R:0,y:(F=Se.y)!==null&&F!==void 0?F:0,z:(L=Se.z)!==null&&L!==void 0?L:0},J.parameters))}}}catch(xe){I={error:xe}}finally{try{fe&&!fe.done&&(E=ae.return)&&E.call(ae)}finally{if(I)throw I.error}}return{bodies:X,walls:G,zones:K}}function Yc(c){var x,I,E,R,F,L,X,G,K,k;if(We){try{for(var q=Be(n.gameplay.filter(function(Ht){return Ht.kind==="oscillate-3d"})),J=q.next();!J.done;J=q.next()){var te=J.value,j=_.get(te.componentId);if(!(!j||j.sceneId!==U)){var ae=De.get(j.id);if(!ae){var fe=Vt(j);ae={x:(F=fe.x)!==null&&F!==void 0?F:0,y:(L=fe.y)!==null&&L!==void 0?L:0,z:(X=fe.z)!==null&&X!==void 0?X:0},De.set(j.id,ae)}var Se=te.parameters,xe=Q*Se.angularSpeed+Se.phase,Ie=Math.sin(xe)*Se.amplitude,ye=Math.cos(xe)*Se.amplitude*Se.angularSpeed,we=(G=Rt.get(j.id))!==null&&G!==void 0?G:pn("physics-3d",j.id)?Tl(j,pn("physics-3d",j.id)):void 0,he=ae.x+(Se.axis==="x"?Ie:0),Ue=ae.y+(Se.axis==="y"?Ie:0),Oe=ae.z+(Se.axis==="z"?Ie:0);if(we)we.x=he,we.y=Ue,we.z=Oe,we.vx=Se.axis==="x"?ye:0,we.vy=Se.axis==="y"?ye:0,we.vz=Se.axis==="z"?ye:0;else{var et=(K=qe.get(j.id))!==null&&K!==void 0?K:{transform:Qe([],Fe(j.transform),!1),parameters:{}};et.parameters.x=he,et.parameters.y=Ue,et.parameters.z=Oe,qe.set(j.id,et)}}}}catch(Ht){x={error:Ht}}finally{try{J&&!J.done&&(I=q.return)&&I.call(q)}finally{if(x)throw x.error}}var He=xo(),Je=He.bodies,wt=He.walls,kt=He.zones;jf({bodies:Je,walls:wt,zones:kt,dt:c,onEvent:function(Ht,Et,Mt){var At={kind:Ht,componentId:Et.sourceId};Mt&&(At.otherId=Mt.sourceId),In(At)}});try{for(var en=Be(Je),Xt=en.next();!Xt.done;Xt=en.next()){var we=Xt.value;we.captured&&(we.captureElapsed=((k=we.captureElapsed)!==null&&k!==void 0?k:0)+c)}}catch(Ht){E={error:Ht}}finally{try{Xt&&!Xt.done&&(R=en.return)&&R.call(en)}finally{if(E)throw E.error}}ga(c,wt),We.stepAnimations(c,function(Ht,Et,Mt){In(It(It({kind:"modelAnimationEnd",componentId:Et},Ht!==Et?{selfInstanceId:Ht,instanceId:Ht}:{}),{clipName:Mt}))})}}function _o(c){var x=$t.get(c.componentId);if(!x){var I=c.parameters;x={behavior:c,x:I.x,y:I.y,z:I.z,yaw:I.yaw,pitch:I.pitch,bobPhase:0,bob:0},$t.set(c.componentId,x)}return x}function qc(){var c,x;try{for(var I=Be(n.gameplay.filter(function(F){var L;return F.kind==="fps-controller-3d"&&((L=_.get(F.componentId))===null||L===void 0?void 0:L.sceneId)===U})),E=I.next();!E.done;E=I.next()){var R=E.value;_o(R)}}catch(F){c={error:F}}finally{try{E&&!E.done&&(x=I.return)&&x.call(I)}finally{if(c)throw c.error}}}function Vn(c){var x,I,E,R=[];try{for(var F=Be(oe.values()),L=F.next();!L.done;L=F.next()){var X=L.value;X.contract==="native.mesh3d.v1"&&((E=zs(X))===null||E===void 0?void 0:E.id)===c&&R.push(X)}}catch(G){x={error:G}}finally{try{L&&!L.done&&(I=F.return)&&I.call(F)}finally{if(x)throw x.error}}return R}function Vs(c,x,I){var E,R,F=_o(c),L=c.parameters,X=L.lookSensitivity,G=L.invertAimY?-1:1,K=F.yaw-x*X;L.minYaw!==void 0&&L.maxYaw!==void 0&&(K=Math.max(L.minYaw,Math.min(L.maxYaw,K))),F.yaw=K,F.pitch=Math.max((E=L.minPitch)!==null&&E!==void 0?E:-.75,Math.min((R=L.maxPitch)!==null&&R!==void 0?R:.75,F.pitch-I*X*G))}function ga(c,x){var I,E,R,F,L,X,G,K,k,q,J,te,j,ae,fe,Se,xe,Ie,ye,we,he=function(Mt){var At=_.get(Mt.componentId);if(!At||At.sceneId!==U)return"continue";var St=_o(Mt),pt=Mt.parameters,bt=pt.aimJoystickBehaviorId?re.get(pt.aimJoystickBehaviorId):void 0;if(bt&&pt.aimMode==="rate"&&bt.magnitude>1e-4&&c>0){var Qt=(G=pt.aimTurnSpeed)!==null&&G!==void 0?G:1.8,ot=pt.invertAimY?-1:1,hn=St.yaw-bt.nx*Qt*c;pt.minYaw!==void 0&&pt.maxYaw!==void 0&&(hn=Math.max(pt.minYaw,Math.min(pt.maxYaw,hn))),St.yaw=hn,St.pitch=Math.max((K=pt.minPitch)!==null&&K!==void 0?K:-.75,Math.min((k=pt.maxPitch)!==null&&k!==void 0?k:.75,St.pitch-bt.ny*Qt*ot*c))}var Kt=pt.joystickBehaviorId?re.get(pt.joystickBehaviorId):void 0,Cn=Kt?Kt.nx:Number(pt.moveXVariableId?H[pt.moveXVariableId]:0),Yt=Kt?Kt.ny:Number(pt.moveYVariableId?H[pt.moveYVariableId]:0),bn=Math.min(1,Math.hypot(Cn,Yt));if(bn>1e-4&&pt.moveSpeed>0&&c>0){var lt=-Yt,mt=Cn,Nn=-Math.sin(St.yaw),Ni=-Math.cos(St.yaw),bi=Math.cos(St.yaw),xi=-Math.sin(St.yaw),$n=pt.moveSpeed*c,wi=x.filter(function(ni){return ni.stageId===At.id}),pi=eh(St.x+(Nn*lt+bi*mt)*$n,St.z+(Ni*lt+xi*mt)*$n,(q=pt.playerRadius)!==null&&q!==void 0?q:.45,wi,(J=pt.boundsX)!==null&&J!==void 0?J:12,(te=pt.boundsZ)!==null&&te!==void 0?te:12);St.x=pi.x,St.z=pi.z,St.bobPhase+=c*10*bn,St.bob=A?.matches?0:Math.sin(St.bobPhase)*((j=pt.bobAmplitude)!==null&&j!==void 0?j:.04)*bn}else St.bob*=Math.max(0,1-12*c)};try{for(var Ue=Be(n.gameplay.filter(function(Mt){return Mt.kind==="fps-controller-3d"})),Oe=Ue.next();!Oe.done;Oe=Ue.next()){var et=Oe.value;he(et)}}catch(Mt){I={error:Mt}}finally{try{Oe&&!Oe.done&&(E=Ue.return)&&E.call(Ue)}finally{if(I)throw I.error}}try{for(var He=Be(n.gameplay.filter(function(Mt){return Mt.kind==="steer-3d"})),Je=He.next();!Je.done;Je=He.next()){var et=Je.value,wt=_.get(et.componentId);if(!(!wt||wt.sceneId!==U)){var kt=et.parameters,en=function(At){if(!hi(At))return"continue";var St=zs(At),pt=St?$t.get(St.id):void 0;if(!pt)return"continue";var bt=Vt(At),Qt=(ae=bt.x)!==null&&ae!==void 0?ae:0,ot=(fe=bt.y)!==null&&fe!==void 0?fe:0,hn=(Se=bt.z)!==null&&Se!==void 0?Se:0,Kt=pt.x-Qt,Cn=pt.z-hn,Yt=Math.hypot(Kt,Cn),bn=(xe=kt.stopDistance)!==null&&xe!==void 0?xe:2.5,lt=Qt,mt=ot,Nn=hn,Ni=kt.mode==="chase-camera"&&bn<=.5;if(kt.mode==="chase-camera"&&Yt>bn&&Yt>1e-4){var bi=Math.min(Yt-bn,kt.speed*c);lt+=Kt/Yt*bi,Nn+=Cn/Yt*bi,Ni&&(mt+=(pt.y-.14-ot)*(bi/Yt))}else if(kt.mode==="strafe-camera"&&Yt>1e-4){var xi=-Cn/Yt,$n=Kt/Yt;lt+=xi*kt.speed*c,Nn+=$n*kt.speed*c}else kt.mode==="patrol"&&(lt+=Math.cos(Q*1.5)*kt.speed*c);var wi=Ni?[]:x.filter(function(Ri){return Ri.stageId===St.id&&Ri.id!==At.id}),pi=Ni?{x:lt,z:Nn}:eh(lt,Nn,.45,wi,(Ie=kt.boundsX)!==null&&Ie!==void 0?Ie:12,(ye=kt.boundsZ)!==null&&ye!==void 0?ye:12),ni=(we=qe.get(At.id))!==null&&we!==void 0?we:{transform:Qe([],Fe(At.transform),!1),parameters:{}};ni.parameters.x=pi.x,Ni&&(ni.parameters.y=mt),ni.parameters.z=pi.z,kt.faceCamera!==!1&&(ni.parameters.ry=Math.atan2(pt.x-pi.x,pt.z-pi.z)),qe.set(At.id,ni)};try{for(var Xt=(L=void 0,Be(Ii(wt))),Ht=Xt.next();!Ht.done;Ht=Xt.next()){var Et=Ht.value;en(Et)}}catch(At){L={error:At}}finally{try{Ht&&!Ht.done&&(X=Xt.return)&&X.call(Xt)}finally{if(L)throw L.error}}}}}catch(Mt){R={error:Mt}}finally{try{Je&&!Je.done&&(F=He.return)&&F.call(He)}finally{if(R)throw R.error}}}function fs(c){for(var x,I,E,R,F,L,X=[],G=c;G&&G.contract==="native.mesh3d.v1";G=vt(G.parentId))X.push(G);for(var K=0,k=0,q=0,J=0,te=X.length-1;te>=0;te--){var j=X[te],ae=Rt.get(j.id),fe=Vt(j),Se=ae?ae.x:(x=fe.x)!==null&&x!==void 0?x:0,xe=ae?(E=(I=ae.y)!==null&&I!==void 0?I:fe.y)!==null&&E!==void 0?E:0:(R=fe.y)!==null&&R!==void 0?R:0,Ie=ae?ae.z:(F=fe.z)!==null&&F!==void 0?F:0,ye=Math.cos(J),we=Math.sin(J);K+=Se*ye+Ie*we,k+=xe,q+=-Se*we+Ie*ye,J+=(L=fe.ry)!==null&&L!==void 0?L:0}return{x:K,y:k,z:q,ry:J}}var Wr=0;function Gs(c){var x,I,E,R,F,L,X=Math.max(1,Math.min(16,Math.floor((E=c.count)!==null&&E!==void 0?E:1)));if(c.fromComponentId!==void 0||c.fromTeam!==void 0){var G=[];if(c.fromComponentId!==void 0){var K=_.get(c.fromComponentId);K&&K.sceneId===U&&(G=Ii(K).filter(function(He){var Je,wt;return hi(He)&&((wt=(Je=Za(He))===null||Je===void 0?void 0:Je.hp)!==null&&wt!==void 0?wt:1)>0}))}else{var k=new Set;try{for(var q=Be(Qe(Qe([],Fe(n.components),!1),Fe(ne),!1)),J=q.next();!J.done;J=q.next()){var te=J.value;if(!(te.contract!=="native.mesh3d.v1"||te.sceneId!==U||te.prototype||k.has(te.id)||!hi(te))){var j=Za(te);j&&j.hp>0&&(c.fromTeam==="any"||j.team===c.fromTeam)&&(k.add(te.id),G.push(te))}}}catch(He){x={error:He}}finally{try{J&&!J.done&&(I=q.return)&&I.call(q)}finally{if(x)throw x.error}}}if(!G.length)return;for(var ae=(R=c.offsetX)!==null&&R!==void 0?R:0,fe=(F=c.offsetY)!==null&&F!==void 0?F:0,Se=(L=c.offsetZ)!==null&&L!==void 0?L:0,xe=0;xe<X;xe++){var Ie=G[Wr++%G.length],ye=fs(Ie),we=Math.cos(ye.ry),he=Math.sin(ye.ry),Ue=c.jitterX?(xn.rng.next()*2-1)*c.jitterX:0,Oe=c.jitterZ?(xn.rng.next()*2-1)*c.jitterZ:0;hs(c.prototypeId,ye.x+ae*we+Se*he+Ue,ye.y+fe,ye.z-ae*he+Se*we+Oe)}return}for(var et=0;et<X;et++){var Ue=c.jitterX?(xn.rng.next()*2-1)*c.jitterX:0,Oe=c.jitterZ?(xn.rng.next()*2-1)*c.jitterZ:0;hs(c.prototypeId,c.x+Ue,c.y,c.z+Oe)}}function hs(c,x,I,E){if(ne.length>=128){Ti("Instance budget exhausted");return}var R=_.get(c),F=function(K){return 1+n.components.filter(function(k){return k.parentId===K}).reduce(function(k,q){return k+F(q.id)},0)};if(oe.size+F(R.id)>4096){Ti("Runtime node budget exhausted");return}var L="instance."+ ++Me;function X(K,k){var q,J,te=K.id===R.id?L:L+":"+K.id,j=It(It({},K),{id:te,runtimeId:te,instanceId:L,prototypeId:K.id,prototype:!1,parentId:k,transform:Qe([],Fe(K.transform),!1),parameters:It({},K.parameters),spawnTime:Q});oe.set(te,j);try{for(var ae=Be(n.components.filter(function(xe){return xe.parentId===K.id})),fe=ae.next();!fe.done;fe=ae.next()){var Se=fe.value;X(Se,te)}}catch(xe){q={error:xe}}finally{try{fe&&!fe.done&&(J=ae.return)&&J.call(ae)}finally{if(q)throw q.error}}return j}var G=X(R,R.parentId);return G.parameters.x=x,G.parameters.y=I,G.parameters.z=E,ne.push(G),bl(G),G}function El(c){var x,I,E;if(We){var R=_.get(c.stageId);if(!(!R||R.sceneId!==U)){(x=We.triggerRecoil)===null||x===void 0||x.call(We,R.id);var F=Vt(R),L=ri(R),X=Math.hypot(L[0],L[1]),G=Math.hypot(L[2],L[3]),K=We.getStage(R),k=!!(K?.isFullBleed&&K.lastWidth>0&&K.lastHeight>0),q=We.syncStage(R,{time:Q,ambientTime:ie,propsOf:Vt,bodies3d:Rt,fpsPose:$t.get(R.id),instances3d:Vn(R.id),aimLocked:!!xt,groundFn:eo,worldWidth:k?K.lastWidth:F.width*X,worldHeight:k?K.lastHeight:F.height*G,designHeight:k?K.lastDesignH:F.height*G}).entry,J=0,te=0;if(c.mode==="pointer")if(k)J=(it.x-K.lastX)/Math.max(1,K.lastWidth)*2-1,te=1-(it.y-K.lastY)/Math.max(1,K.lastHeight)*2;else{var j=ti(Or(L),it.x,it.y);J=j.x/Math.max(1,F.width)*2-1,te=1-j.y/Math.max(1,F.height)*2}var ae=new Set(n.gameplay.filter(function(ye){return ye.kind==="physics-3d"&&ye.parameters.mode!=="dynamic"}).map(function(ye){return ye.componentId})),fe=(I=c.targetTeam)!==null&&I!==void 0?I:"any",Se=function(ye){var we,he,Ue=vt(ye);return!Ue||!hi(Ue)?!1:fe!=="any"?((we=Za(Ue))===null||we===void 0?void 0:we.team)===fe:!!Za(Ue)||!ae.has((he=Ue.prototypeId)!==null&&he!==void 0?he:Ue.id)},xe=q.raycast(J,te,(E=c.maxDistance)!==null&&E!==void 0?E:80,{isTarget:Se,isOccluder:function(ye){return ae.has(ye)}});if(xe){var Ie=vt(xe.id);Ie&&In(tr("raycastHit3d",Ie,R))}else In({kind:"raycastMiss3d",componentId:R.id})}}}function Hs(c){var x,I,E;if(!We)return null;var R=vt(c);if(!R||R.contract!=="native.mesh3d.v1")return null;var F=zs(R);if(!F)return null;var L=We.getStage(F);if(!L||!L.lastWidth||!L.lastHeight)return null;var X=Rt.get(R.id),G=Vt(R),K=L.project({x:X?X.x:(x=G.x)!==null&&x!==void 0?x:0,y:X?X.y:(I=G.y)!==null&&I!==void 0?I:0,z:X?X.z:(E=G.z)!==null&&E!==void 0?E:0},L.lastWidth,L.lastHeight);return L.isFullBleed?{x:L.lastX+K.x,y:L.lastY+K.y}:ti(ri(F),K.x,K.y)}function Mo(){if(!xt||!We)return{vx:0,vz:0,power:0,pull:0};var c=_.get(xt.stageId),x=We.getStage(c),I=Rt.get(xt.targetId),E=xt.behavior.parameters;if(!x||!I||!x.lastWidth||!x.lastHeight)return{vx:0,vz:0,power:0,pull:0};var R,F;if(x.isFullBleed)R={x:xt.start.x-x.lastX,y:xt.start.y-x.lastY},F={x:xt.current.x-x.lastX,y:xt.current.y-x.lastY};else{var L=Or(ri(c));R=ti(L,xt.start.x,xt.start.y),F=ti(L,xt.current.x,xt.current.y)}var X=Math.hypot(xt.current.x-xt.start.x,xt.current.y-xt.start.y),G=x.unproject(R.x,R.y,x.lastWidth,x.lastHeight,I.y),K=x.unproject(F.x,F.y,x.lastWidth,x.lastHeight,I.y);if(!G||!K)return{vx:0,vz:0,power:0,pull:X};var k=(G.x-K.x)*E.dragScale,q=(G.z-K.z)*E.dragScale,J=Math.hypot(k,q);return J>E.maxSpeed&&(k*=E.maxSpeed/J,q*=E.maxSpeed/J),{vx:k,vz:q,power:Math.min(1,Math.hypot(k,q)/Math.max(.001,E.maxSpeed)),pull:X}}function So(c){if(!(!xt||!We)){xt.current=c;var x=Mo(),I=xt.behavior.parameters;xt.power=x.power,I.powerVariableId&&(H[I.powerVariableId]=x.power);var E=_.get(xt.stageId),R=We.getStage(E),F=Rt.get(xt.targetId);if(R&&F&&I.showTrajectory&&x.pull>=I.minPullPx){var L=xo(),X=L.walls,G=L.zones;R.setGuide(km({body:F,walls:X,zones:G,vx:x.vx,vz:x.vz,dots:I.trajectoryDots}))}else R?.setGuide([])}}function Zc(){return{bodies:Qe([],Fe(Rt.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,z:c.z,vx:c.vx,vy:c.vy,vz:c.vz,atRest:!!c.atRest,captured:!!c.captured,airborne:!!c.airborne}}),aiming:xt?{componentId:xt.sourceId,pointerId:xt.pointerId,power:xt.power}:null,projected:Object.fromEntries(rn),fps:Object.fromEntries(Qe([],Fe($t),!1).map(function(c){var x=Fe(c,2),I=x[0],E=x[1];return[I,{x:E.x,y:E.y,z:E.z,yaw:E.yaw,pitch:E.pitch}]}))}}function Al(){on=void 0,Sn=void 0,er(),re.clear(),fn.clear(),Dn.clear(),si.clear(),xn.reset(),yi.clear(),kn.clear(),Lt=[],Nt=[],ii.clear(),C.clear(),V.clear(),ve=[],Te=[],Ve=void 0,$e=0,Ce=!1,Ae=0,H=Object.fromEntries(n.variables.map(function(c){return[c.id,c.initial]})),li(),vn=0,oe.clear(),st.clear(),Pn.clear(),ei.clear(),Rt.clear(),De.clear(),rn.clear(),$t.clear(),Wr=0,We?.reset(),qn.clear(),Hn.clear(),de=void 0,ne=[],ce=[],pe=[],qe.clear(),wl(),Gt.clear(),be.clear(),Pe.clear(),le=[],Q=0,ie=0,Me=0,Ye=!1,Le=0,U=n.base.startScene,Pt=void 0,tn=void 0,jt=void 0,ln=void 0,f||(Cr(),Xc(),Bs(),xo(),qc(),ks(0,!1),Cf(),yo(0),In({kind:"sceneEnter",sceneId:U}))}function Il(){var c,x;if(!(!ke||ke.state!=="running"||!Ot.size)){var I=Qe([],Fe(Ot.values()),!1);Ot.clear();try{for(var E=Be(I),R=E.next();!R.done;R=E.next()){var F=R.value;Yp(F)}}catch(L){c={error:L}}finally{try{R&&!R.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}}function Ws(c){if(c===void 0&&(c=!1),!ke)return Promise.resolve(void 0);if(ke.state==="running")return Promise.resolve().then(Il),Promise.resolve(ke);if(!at||c){var x=ke,I=Promise.resolve().then(function(){return x.resume()}).then(function(){if(x.state==="running")return Il(),x}).catch(function(){}).finally(function(){at===I&&(at=void 0)});at=I}return at}function Af(){var c,x,I=Qe([],Fe(Tt.values()),!1),E=I.some(function(k){return k.bus==="voice"}),R=I.some(function(k){return k.bus==="stinger"}),F=R?.2:E?.25:1;try{for(var L=Be(I),X=L.next();!X.done;X=L.next()){var G=X.value,K=G.volume*yn*(G.bus==="music"?F:1);G.gain.gain.setTargetAtTime?G.gain.gain.setTargetAtTime(K,ke.currentTime,.04):G.gain.gain.value=K}}catch(k){c={error:k}}finally{try{X&&!X.done&&(x=L.return)&&x.call(L)}finally{if(c)throw c.error}}}function Sg(c,x){if(!x||typeof c.createBuffer!="function"||typeof x.getChannelData!="function"||!x.numberOfChannels)return x;var I=x.sampleRate||44100,E=x.length;if(E<Math.round(I*.2))return x;for(var R=x.numberOfChannels,F=.002,L=E,X=0,G=0;G<R;G++){for(var K=x.getChannelData(G),k=0;k<L;k++)if(Math.abs(K[k])>F){L=k;break}for(var k=E-1;k>X;k--)if(Math.abs(K[k])>F){X=k;break}}if(L>=X)return x;var q=X-L+1;if(q<Math.round(I*.15))return x;var J=Math.min(Math.round(I*.06),Math.floor(q*.1)),te=q-J;if(J<8||te<Math.round(I*.1))return x;for(var j=c.createBuffer(R,te,I),G=0;G<R;G++){for(var ae=x.getChannelData(G),fe=j.getChannelData(G),k=0;k<J;k++){var Se=k/J;fe[k]=ae[L+k]*Math.sin(Se*Math.PI*.5)+ae[L+te+k]*Math.cos(Se*Math.PI*.5)}for(var k=J;k<te;k++)fe[k]=ae[L+k]}return j}function Xp(c,x,I){var E,R=(E=I.parameters.bus)!==null&&E!==void 0?E:"sfx";c.connect(x),x.connect(ke.destination),Ne.add(c),Tt.set(c,{gain:x,bus:R,volume:I.parameters.volume}),c.onended=function(){Ne.delete(c),Tt.delete(c),I.parameters.loop&&ze.delete(I.id),Af()},Af()}function Yp(c){return qw(this,void 0,void 0,function(){var x,I,E,R,F,L,X,G,K,k,q,J,te,j,ae,fe,Se,xe,Ie,ye,we,he,Ue,Oe,et,He,Je,wt,kt,en,Xt,Ht;return Zw(this,function(Et){switch(Et.label){case 0:return Ne.size>=32?[2]:(x=!!c.parameters.loop,ke?(I=ke,E=Jt,R=(He=c.parameters.cooldownMs)!==null&&He!==void 0?He:45,F=I.currentTime,R>0&&F-((Je=_t.get(c.id))!==null&&Je!==void 0?Je:-1/0)<R/1e3?[2]:x&&ze.has(c.id)?[2]:(L=_.get(c.componentId),X=N.get((wt=L?.assetSlots[0])===null||wt===void 0?void 0:wt.assetId),G=X?.mime==="audio/wav"||X?.mime==="audio/mpeg",!G&&c.parameters.allowSynthFallback===!1?(vn++,[2]):(_t.set(c.id,F),K=I.state!=="running",K?[4,Ws()]:[3,2]))):(x&&Ot.set(c.id,c),[2]));case 1:K=!Et.sent(),Et.label=2;case 2:if(K)return x&&Ot.set(c.id,c),[2];if(ke!==I||I.state!=="running"||E!==Jt||Ne.size>=32)return[2];if(k=(kt=Bt.get(c.id))!==null&&kt!==void 0?kt:0,q=[0,-.5,.5,-1,1],J=((en=c.parameters.pitchJitter)!==null&&en!==void 0?en:0)*q[k%q.length],te=Number((Xt=H[c.parameters.pitchVariableId])!==null&&Xt!==void 0?Xt:0),j=Math.max(-12,Math.min(12,J+te*((Ht=c.parameters.pitchStep)!==null&&Ht!==void 0?Ht:0))),ae=Math.pow(2,j/12),Bt.set(c.id,k+1),!G)return[3,8];x&&ze.add(c.id),Et.label=3;case 3:if(Et.trys.push([3,6,,7]),fe=ft.get(X.hash),fe)return[3,5];for(Se=atob(X.data),xe=new Uint8Array(Se.length),Ie=0;Ie<Se.length;Ie++)xe[Ie]=Se.charCodeAt(Ie);return[4,new Promise(function(Mt,At){var St=I.decodeAudioData(xe.buffer,Mt,At);St&&typeof St.then=="function"&&St.then(Mt,At)})];case 4:fe=Et.sent(),ft.set(X.hash,fe),Et.label=5;case 5:return ke!==I||I.state!=="running"||E!==Jt||Ne.size>=32?(x&&E===Jt&&ze.delete(c.id),[2]):(ye=fe,x&&(ye=ht.get(X.hash),ye||(ye=Sg(I,fe),ht.set(X.hash,ye))),we=I.createBufferSource(),he=I.createGain(),we.buffer=ye,we.loop=x,we.playbackRate&&(we.playbackRate.value=ae),x&&he.gain.setValueAtTime&&he.gain.linearRampToValueAtTime?(he.gain.setValueAtTime(1e-4,I.currentTime),he.gain.linearRampToValueAtTime(c.parameters.volume,I.currentTime+.025)):he.gain.value=c.parameters.volume,Xp(we,he,c),we.start(),[3,7]);case 6:return Ue=Et.sent(),ze.delete(c.id),Ti("Audio decode failed"),[3,7];case 7:return[2];case 8:return Oe=I.createOscillator(),et=I.createGain(),Oe.frequency.value=c.parameters.frequency*ae,Oe.type="sine",et.gain.setValueAtTime(c.parameters.volume,I.currentTime),et.gain.exponentialRampToValueAtTime(.001,I.currentTime+c.parameters.seconds),Xp(Oe,et,c),Oe.start(),Oe.stop(I.currentTime+c.parameters.seconds),[2]}})})}function bg(c,x){for(var I=Qe([],Fe(Ct.values()),!1).filter(function(k){return k.boardId===c}),E=function(k,q){var J;return(J=I.find(function(te){return te.row===k&&te.column===q}))===null||J===void 0?void 0:J.group},R=function(k){for(var q=function(j){var ae=E(k,j);if(ae&&ae===E(k,j+1)&&ae===E(k,j+2)&&x.some(function(fe){return fe.row===k&&fe.column>=j&&fe.column<=j+2}))return{value:!0}},J=0;J<14;J++){var te=q(J);if(typeof te=="object")return te}},F=0;F<16;F++){var L=R(F);if(typeof L=="object")return L.value}for(var X=function(k){for(var q=function(j){var ae=E(j,k);if(ae&&ae===E(j+1,k)&&ae===E(j+2,k)&&x.some(function(fe){return fe.column===k&&fe.row>=j&&fe.row<=j+2}))return{value:!0}},J=0;J<14;J++){var te=q(J);if(typeof te=="object")return te}},G=0;G<16;G++){var K=X(G);if(typeof K=="object")return K.value}return!1}function wg(c){var x,I,E,R=Ct.get(c.id);if(!(!R||R.sceneId!==U||!Vt(c).enabled||!hi(c))){var F=nn.get(c.parentId);if(F){Wt=F.select(c.id);return}if(Wt===c.id){Wt=void 0;return}var L=Ct.get(Wt);if(!L||L.sceneId!==U||L.boardId!==R.boardId){Wt=c.id;return}var X=_.get(Wt);if(Math.abs(L.row-R.row)+Math.abs(L.column-R.column)!==1){Wt=c.id;return}if(L.group===R.group){Wt=void 0,In({kind:"invalidMatch",componentId:(x=c.parentId)!==null&&x!==void 0?x:c.id});return}var G=L.row,K=L.column,k=R.row,q=R.column,J=Qe([],Fe(zn(X)),!1),te=Qe([],Fe(zn(c)),!1);if(L.row=k,L.column=q,R.row=G,R.column=K,bg(R.boardId,[L,R])){var j=function(ae,fe){var Se,xe=(Se=qe.get(ae.id))!==null&&Se!==void 0?Se:{transform:Qe([],Fe(zn(ae)),!1),parameters:{}};xe.transform=Qe([],Fe(xe.transform),!1),xe.transform[4]=fe[4],xe.transform[5]=fe[5],qe.set(ae.id,xe)};j(X,te),j(c,J),Wt=void 0,In({kind:"validMatch",componentId:(I=c.parentId)!==null&&I!==void 0?I:c.id})}else L.row=G,L.column=K,R.row=k,R.column=q,Wt=void 0,In({kind:"invalidMatch",componentId:(E=c.parentId)!==null&&E!==void 0?E:c.id})}}function If(c){var x,I,E,R,F=[],L=_r(c,ri(c)),X=Ci(c),G=pn("drag",(E=c.prototypeId)!==null&&E!==void 0?E:c.id),K=function(te){var j,ae,fe=_.get(te.componentId),Se=te.parameters;if(fe.sceneId!==U)return"continue";var xe=function(he){if(he.id===c.id||Xr(he,c.id)||!hi(he))return"continue";var Ue=_r(he,ri(he)),Oe=Ci(he),et=Math.hypot(Oe.x-X.x,Oe.y-X.y),He=Se.radiusPx>0?et<=Se.radiusPx:L.left<Ue.right&&L.right>Ue.left&&L.top<Ue.bottom&&L.bottom>Ue.top;if(!He)return"continue";F.push(It({id:he.id,c:he,sourceId:fe.id,paintOrder:b.findIndex(function(Je){return Je.c.id===he.id}),distance:et,itemTarget:n.gameplay.some(function(Je){return Je.kind==="drag"&&Je.componentId===fe.id})},Se))};try{for(var Ie=(j=void 0,Be(Ii(fe))),ye=Ie.next();!ye.done;ye=Ie.next()){var we=ye.value;xe(we)}}catch(he){j={error:he}}finally{try{ye&&!ye.done&&(ae=Ie.return)&&ae.call(Ie)}finally{if(j)throw j.error}}};try{for(var k=Be(n.gameplay.filter(function(te){return te.kind==="drop-zone"})),q=k.next();!q.done;q=k.next()){var J=q.value;K(J)}}catch(te){x={error:te}}finally{try{q&&!q.done&&(I=k.return)&&I.call(k)}finally{if(x)throw x.error}}return{zones:F,tag:(R=G?.parameters.tag)!==null&&R!==void 0?R:""}}function Cf(c){var x,I,E=c?[c]:n.gameplay.filter(function(q){return q.kind==="drag"}).flatMap(function(q){return Ii(_.get(q.componentId))});try{for(var R=Be(E),F=R.next();!F.done;F=R.next()){var L=F.value;if(!(!L||!hi(L)||fn.zoneOf(L.id))){var X=If(L),G=X.zones,K=X.tag,k=cu({itemId:L.id,tag:K,zones:G.filter(function(q){return!q.itemTarget}),occupancy:fn});k?.kind==="accept"&&fn.place(L.id,k.zone.id)}}}catch(q){x={error:q}}finally{try{F&&!F.done&&(I=R.return)&&I.call(R)}finally{if(x)throw x.error}}}function Xs(c,x,I){I===void 0&&(I=.18),c&&Wn.to(c.id,Ci(c),x,I)}function Rf(c,x,I,E){var R,F,L=E??I?.c;In(It(It({},tr(c,x,L,It({},I?{otherId:I.sourceId}:{}))),{instanceId:(R=x.instanceId)!==null&&R!==void 0?R:(F=I?.c)===null||F===void 0?void 0:F.instanceId}))}function Tg(c){var x,I,E,R,F,L,X;if(!Ke||Ke.pointerId!==c.pointerId)return!1;var G=Ke,K=vt(G.targetId),k=G.b.parameters;Ke=void 0,yt=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((I=e.releasePointerCapture)===null||I===void 0||I.call(e,c.pointerId))}catch{}if(!K)return!0;var q=If(K),J=q.zones,te=q.tag,j=cu({itemId:K.id,tag:te,zones:J,occupancy:fn}),ae=G.origin,fe=G.originZone;if(!j)return Rf("dragReject",K,void 0,void 0),k.snapBack&&(fe&&fn.place(K.id,fe),Xs(K,ae,(E=k.snapBackSeconds)!==null&&E!==void 0?E:.18)),!0;var Se=j.zone,xe=j.occupantId?vt(j.occupantId):void 0;return j.kind==="reject"?(Rf("dragReject",K,Se,xe),k.snapBack&&(fe&&fn.place(K.id,fe),Xs(K,ae,(R=k.snapBackSeconds)!==null&&R!==void 0?R:.18)),!0):(j.kind==="accept"?(fn.place(K.id,Se.id),Se.snapMode==="center"&&Xs(K,Ci(Se.c),(F=k.snapBackSeconds)!==null&&F!==void 0?F:.18)):j.kind==="swap"&&xe&&(fn.place(K.id,Se.id),fe?fn.place(xe.id,fe):fn.release(xe.id),Xs(K,Ci(Se.c),(L=k.snapBackSeconds)!==null&&L!==void 0?L:.18),Xs(xe,ae,(X=k.snapBackSeconds)!==null&&X!==void 0?X:.18)),Rf("dragDrop",K,Se,j.kind==="accept"?Se.c:xe),!0)}function Eg(c){var x,I,E,R,F;Wn.tick(c,function(j,ae){var fe=vt(j);fe&&Rr(fe,ae.x,ae.y)});try{for(var L=Be(Qe([],Fe(fn.itemZone.keys()),!1)),X=L.next();!X.done;X=L.next()){var G=X.value,K=vt(G);(!K||!hi(K))&&fn.release(G)}}catch(j){x={error:j}}finally{try{X&&!X.done&&(I=L.return)&&I.call(L)}finally{if(x)throw x.error}}if(Ze)try{for(var k=Be(Ze.holds),q=k.next();!q.done;q=k.next()){var J=q.value,te=J.charge.tick(c);te!==H[J.behavior.parameters.variableId]&&(H[J.behavior.parameters.variableId]=te,In({kind:"variableChange",variableId:J.behavior.parameters.variableId,instanceId:J.c.instanceId,selfInstanceId:(F=J.c.instanceId)!==null&&F!==void 0?F:J.c.id}))}}catch(j){E={error:j}}finally{try{q&&!q.done&&(R=k.return)&&R.call(k)}finally{if(E)throw E.error}}}function qp(c,x){var I,E,R,F,L=x.targetMode;if(L==="pointer")return It({},it);if(L==="component"){var X=vt(x.targetComponentId);return X?Ci(X):void 0}if(L==="nearest-team"){var G=Ci(c),K=[],k=x.team,q=(R=x.maxRangePx)!==null&&R!==void 0?R:0;try{for(var J=Be(xn.states),te=J.next();!te.done;te=J.next()){var j=Fe(te.value,2),ae=j[0],fe=j[1],X=vt(ae);X&&hi(X)&&K.push(It(It({id:ae},Ci(X)),{team:fe.team}))}}catch(Se){I={error:Se}}finally{try{te&&!te.done&&(E=J.return)&&E.call(J)}finally{if(I)throw I.error}}return Mm(G,K,k,q,(F=c.instanceId)!==null&&F!==void 0?F:c.id)}}function Ag(c){var x,I,E,R,F;try{for(var L=Be(n.gameplay.filter(function(we){return we.kind==="steer"})),X=L.next();!X.done;X=L.next()){var G=X.value,K=_.get(G.componentId),k=G.parameters;if(K.sceneId===U)try{for(var q=(E=void 0,Be(Ii(K))),J=q.next();!J.done;J=q.next()){var te=J.value;if(hi(te)){var j=qp(te,k);if(j){var ae=Ci(te),fe=j.x-ae.x,Se=j.y-ae.y;if(!(k.maxRangePx>0&&Math.hypot(fe,Se)>k.maxRangePx)){var xe=Math.atan2(Se,fe);k.mode==="flee"?xe+=Math.PI:k.mode==="orbit"&&(xe+=Math.PI/2);var Ie=(F=xn.headings.get(te.id))!==null&&F!==void 0?F:xe,ye=Sm(Ie,xe,k.turnRateDegPerSec*Math.PI/180*c);xn.headings.set(te.id,ye),Rr(te,ae.x+Math.cos(ye)*k.speed*c,ae.y+Math.sin(ye)*k.speed*c),k.orientToVelocity!==!1&&Ur(te,ye)}}}}}catch(we){E={error:we}}finally{try{J&&!J.done&&(R=q.return)&&R.call(q)}finally{if(E)throw E.error}}}}catch(we){x={error:we}}finally{try{X&&!X.done&&(I=L.return)&&I.call(L)}finally{if(x)throw x.error}}}function Pf(c,x,I,E){var R;if(ne.length>=128){Ti("Instance budget exhausted");return}var F=_.get(c),L=function(k){return 1+n.components.filter(function(q){return q.parentId===k}).reduce(function(q,J){return q+L(J.id)},0)};if(oe.size+L(F.id)>4096){Ti("Runtime node budget exhausted");return}var X="instance."+ ++Me;function G(k,q){var J,te,j=k.id===F.id?X:X+":"+k.id,ae=It(It({},k),{id:j,runtimeId:j,instanceId:X,prototypeId:k.id,prototype:!1,parentId:q,transform:Qe([],Fe(k.transform),!1),spawnTime:Q});oe.set(j,ae);try{for(var fe=Be(n.components.filter(function(Ie){return Ie.parentId===k.id})),Se=fe.next();!Se.done;Se=fe.next()){var xe=Se.value;G(xe,j)}}catch(Ie){J={error:Ie}}finally{try{Se&&!Se.done&&(te=fe.return)&&te.call(fe)}finally{if(J)throw J.error}}return ae}var K=G(F,void 0);return K.transform[4]=x,K.transform[5]=I,E&&(K.pathStartNode=E.startNode,K.pathTargetNode=E.targetNode,K.parentId=(R=n.gameplay.find(function(k){return k.id===E.networkBehaviorId}))===null||R===void 0?void 0:R.componentId),ne.push(K),bl(K),Cf(K),E&&ks(0,!1),K}function Ig(c,x,I){var E,R,F,L,X,G,K,k,q,J,te,j,ae,fe,Se,xe,Ie,ye,we,he,Ue,Oe,et,He,Je,wt,kt,en,Xt,Ht,Et,Mt,At,St,pt;if(++Ge>1024){Ti("Action budget exhausted");return}if(c.kind==="add"||c.kind==="set"){var bt=H[c.variableId],Qt=c.kind==="add"?bt+c.value:c.value;if(typeof Qt=="number"&&(!Number.isFinite(Qt)||Math.abs(Qt)>1e12)){Ti("Variable range exceeded");return}H[c.variableId]=Qt,bt!==Qt&&In({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="setAsset"&&((q=vt(c.componentId))===null||q===void 0?void 0:q.contract)==="native.mesh3d.v1"){var ot=vt(c.componentId),hn=(J=qe.get(ot.id))!==null&&J!==void 0?J:{transform:Qe([],Fe(ot.transform),!1),parameters:{}};((te=hn.slots)!==null&&te!==void 0?te:hn.slots={})[(j=c.slotId)!==null&&j!==void 0?j:"source"]=c.assetId,qe.set(ot.id,hn)}else if(c.kind==="setComponent"||c.kind==="setAsset"){var ot=vt(c.componentId);if(!ot)return;var hn=(ae=qe.get(ot.id))!==null&&ae!==void 0?ae:{transform:Qe([],Fe(ot.transform),!1),parameters:{}};c.kind==="setComponent"?hn.parameters[c.key]=c.valueVariableId?H[c.valueVariableId]:c.value:hn.assetId=c.assetId,qe.set(ot.id,hn),c.kind==="setComponent"&&c.key==="visible"&&c.value===!1&&(fn.release(ot.id),Wn.cancel(ot.id))}else if(c.kind==="resetMatch")wl(c.componentId),Xc(c.componentId);else if(c.kind==="clearStrokes")(fe=kn.get(c.componentId))===null||fe===void 0||fe.clear(),Lt=Lt.filter(function(mi){return mi.owner!==c.componentId});else if(c.kind==="resetMask"){var ot=vt(c.componentId),Kt=pn("erase-mask",c.componentId);ot&&Kt&&va(ot,Kt).reset()}else if(c.kind==="raycast3d")El(c);else if(c.kind==="spawnAt3d")Gs(c);else if(c.kind==="playModelAnimation")We?.playModelAnimation(c.componentId,c);else if(c.kind==="copyMatchAsset"){var Cn=(Se=nn.get(c.boardId))===null||Se===void 0?void 0:Se.snapshot().lastMatch,Yt=_.get(c.componentId),bn=Cn&&((Ie=(xe=cn.get(c.boardId))===null||xe===void 0?void 0:xe.get(Cn.group))===null||Ie===void 0?void 0:Ie.children.find(function(mi){return mi.contract==="native.image.v1"}));if(Cn&&bn){var lt=_.get(Cn.from),mt=ti(ri(lt),lt.parameters.width/2,lt.parameters.height/2),Nn=Yt.parentId?ri(_.get(Yt.parentId)):Ua(),Ni=ti(Or(Nn),mt.x,mt.y),bi=(ye=qe.get(Yt.id))!==null&&ye!==void 0?ye:{transform:Qe([],Fe(Yt.transform),!1),parameters:{}};bi.transform=Qe([],Fe(bi.transform),!1),bi.transform[4]=Ni.x-Yt.parameters.width/2,bi.transform[5]=Ni.y-Yt.parameters.height/2,bi.assetId=(we=bn.assetSlots[0])===null||we===void 0?void 0:we.assetId,qe.set(Yt.id,bi)}}else if(c.kind==="hintMatch")Wt=void 0,(he=nn.get(c.componentId))===null||he===void 0||he.showHint();else if(c.kind==="spawn")Pf(c.prototypeId,c.x,c.y);else if(c.kind==="spawnAt"){var xi=(c.at==="self"||c.at==="midpoint")&&(x.selfInstanceId!==void 0||x.instanceId!==void 0)?vt((Ue=x.selfInstanceId)!==null&&Ue!==void 0?Ue:x.instanceId):Ja(c.targetComponentId,x,"self"),$n=(c.at==="other"||c.at==="midpoint")&&x.otherInstanceId!==void 0?vt(x.otherInstanceId):void 0,Yt=c.at==="other"?$n:xi;if(c.at==="pointer"||(c.at==="midpoint"?xi&&$n:Yt))for(var wi=xi?Ci(xi):void 0,pi=$n?Ci($n):void 0,mt=c.at==="pointer"?it:c.at==="midpoint"?{x:(wi.x+pi.x)/2,y:(wi.y+pi.y)/2}:Ci(Yt),ni=_.get(c.prototypeId),Ri=Math.max(0,Math.min(16,Math.floor(c.countVariableId?Number(H[c.countVariableId]):(Oe=c.count)!==null&&Oe!==void 0?Oe:1))),di=0;di<Ri;di++){var aa=c.jitterX?(xn.rng.next()*2-1)*c.jitterX:0,gr=c.jitterY?(xn.rng.next()*2-1)*c.jitterY:0;Pf(c.prototypeId,mt.x+c.offsetX+aa-ni.parameters.width/2,mt.y+c.offsetY+gr-ni.parameters.height/2)}}else if(c.kind==="random"){var bt=H[c.variableId],Qt=xn.rng.between(c.min,c.max,c.integer===!0);H[c.variableId]=Qt,bt!==Qt&&In({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="modifyInstanceState"){var ot=c.target==="component"?vt(c.componentId):Ja(c.componentId,x,c.target);ot&&Ra(ot,c.field,c.op,c.variableId?H[c.variableId]:c.value)}else if(c.kind==="launchToward"){var lt=_.get(c.componentId),zi=Ii(lt),un=(et=x.selfInstanceId)!==null&&et!==void 0?et:x.instanceId,ot=lt.prototype?(He=zi.find(function(Mn){return Mn.instanceId===un||Mn.id===un}))!==null&&He!==void 0?He:zi[zi.length-1]:(Je=Ja(c.componentId,x,"self"))!==null&&Je!==void 0?Je:vt(c.componentId),Kt=pn("physics-body",c.componentId),an=ot&&ra(ot,Kt);if(!an)return;var Ft=void 0;if(c.targetMode==="angle-variable")Ft=Number(H[c.angleVariableId])*Math.PI/180;else{var Yt=qp(ot,c);if(!Yt)return;var mt=Ci(ot);Ft=Math.atan2(Yt.y-mt.y,Yt.x-mt.x)}var Ei=Number(c.speedVariableId?H[c.speedVariableId]:c.speed);if(!Number.isFinite(Ei)){Ti("Launch speed invalid");return}an.vx=Math.cos(Ft)*Ei,an.vy=Math.sin(Ft)*Ei,an.atRest=!1,an.restElapsed=0,an.captured=!1,an.exited=!1,c.orientToVelocity!==!1&&Ur(ot,Ft),In(tr("launch",ot))}else if(c.kind==="moveToComponent"){var Ai=_.get(c.targetComponentId),ot=Ja(c.componentId,x,(wt=c.target)!==null&&wt!==void 0?wt:"self"),Yt=Ai&&ci(Ai)?(kt=Ja(c.targetComponentId,x,c.target==="other"?"self":"other"))!==null&&kt!==void 0?kt:Ii(Ai)[0]:vt(c.targetComponentId);ot&&Yt&&Xs(ot,Ci(Yt),c.seconds)}else if(c.kind==="returnToOrigin"){var ot=Ja(c.componentId,x,"self"),Yr=ot&&Dn.get(ot.id);ot&&Yr&&Xs(ot,Yr,c.seconds)}else if(c.kind==="spawnOnPath")Pf(c.prototypeId,0,0,{startNode:c.startNode,targetNode:c.targetNode,networkBehaviorId:c.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(c.kind)){var Qn=_.get(c.componentId),Hi=x.instanceId?Qe([],Fe(oe.values()),!1).filter(function(Xn){return Xn.instanceId===x.instanceId&&Xn.prototypeId===Qn.id}):Ii(Qn),Kt=pn("physics-body",Qn.id);try{for(var sa=Be(Hi),Pa=sa.next();!Pa.done;Pa=sa.next()){var ot=Pa.value,an=ra(ot,Kt);c.kind==="setVelocity"?(an.vx=c.vxVariableId?H[c.vxVariableId]:c.vx,an.vy=c.vyVariableId?H[c.vyVariableId]:c.vy):c.kind==="applyImpulse"?(an.vx+=c.vxVariableId?H[c.vxVariableId]:c.ix,an.vy+=c.vyVariableId?H[c.vyVariableId]:c.iy):(an.vx=0,an.vy=0,an.atRest=!0),an.captured=!1,an.exited=!1,an.restElapsed=0,c.kind!=="stopBody"&&(an.atRest=!1)}}catch(Xn){E={error:Xn}}finally{try{Pa&&!Pa.done&&(R=sa.return)&&R.call(sa)}finally{if(E)throw E.error}}}else if(c.kind==="setPosition"){var $a=_.get(c.componentId),Hi=x.instanceId?Qe([],Fe(oe.values()),!1).filter(function(_n){return _n.instanceId===x.instanceId&&_n.prototypeId===$a.id}):Ii($a),Kt=pn("physics-body",$a.id);try{for(var qr=Be(Hi),Mr=qr.next();!Mr.done;Mr=qr.next()){var ot=Mr.value,an=ra(ot,Kt);an.x=c.xVariableId?H[c.xVariableId]:c.x,an.y=c.yVariableId?H[c.yVariableId]:c.y,an.vx=0,an.vy=0,an.captured=!1,an.exited=!1,an.atRest=!0,Rr(ot,an.x,an.y)}}catch(_n){F={error:_n}}finally{try{Mr&&!Mr.done&&(L=qr.return)&&L.call(qr)}finally{if(F)throw F.error}}}else if(c.kind==="setPathEdge")(en=Fn.get(c.behaviorId))===null||en===void 0||en.setEdge(c.edgeId,c.enabled,c.cost);else if(c.kind==="setPathGate")(Ht=Fn.get((Xt=n.gameplay.find(function(mi){return mi.id===c.behaviorId}))===null||Xt===void 0?void 0:Xt.parameters.networkBehaviorId))===null||Ht===void 0||Ht.setGate(c.behaviorId,c.mode,c.holdSeconds);else if(c.kind==="setPathTarget"){var xa=_.get(c.componentId),Kt=pn("path-agent",xa.id),oa=Fn.get(Kt.parameters.networkBehaviorId);try{for(var La=Be(x.instanceId?Qe([],Fe(oe.values()),!1).filter(function(Xn){return Xn.instanceId===x.instanceId&&Xn.prototypeId===xa.id}):Ii(xa)),nr=La.next();!nr.done;nr=La.next()){var ot=nr.value;ot.pathTargetNode=c.targetNode,oa?.setTarget(ot.id,c.targetNode)}}catch(Xn){X={error:Xn}}finally{try{nr&&!nr.done&&(G=La.return)&&G.call(La)}finally{if(X)throw X.error}}}else if(c.kind==="compute"){var Ui=Number(H[c.variableId]),Wi=c.operandVariableId!==void 0?Number(H[c.operandVariableId]):c.value;if(["div","mod"].includes(c.op)&&Wi===0){Ti("Division by zero");return}var Qt={add:function(){return Ui+Wi},sub:function(){return Ui-Wi},mul:function(){return Ui*Wi},div:function(){return Wi===0?Ui:Ui/Wi},mod:function(){return Wi===0?Ui:Ui%Wi},min:function(){return Math.min(Ui,Wi)},max:function(){return Math.max(Ui,Wi)},set:function(){return Wi},floor:function(){return Math.floor(Ui)},ceil:function(){return Math.ceil(Ui)},abs:function(){return Math.abs(Ui)},clamp:function(){return Math.max(c.min,Math.min(c.max,Ui))}}[c.op]();if(c.round&&(Qt=Math.round(Qt)),!Number.isFinite(Qt)||Math.abs(Qt)>1e12){Ti("Variable range exceeded");return}var bt=H[c.variableId];H[c.variableId]=Qt,bt!==Qt&&In({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="despawn"){var xi=(Et=x.selfInstanceId)!==null&&Et!==void 0?Et:x.instanceId;c.target==="other"?ji(x.otherInstanceId):c.target==="both"?(ji(xi),ji(x.otherInstanceId)):ji(xi)}else if(c.kind==="changeScene")c.delaySeconds>0?c.sceneId!==U&&(on??(on={sceneId:c.sceneId,at:Q+c.delaySeconds})):ln=c.sceneId;else if(c.kind==="restart")(Mt=P?.notifyGameRetry)===null||Mt===void 0||Mt.call(P),ln="__restart";else if(c.kind==="cameraShake")A?.matches||(Ve={intensity:c.intensity,seconds:c.seconds,elapsed:0});else if(c.kind==="screenFlash")Te.push({color:c.color,opacity:c.opacity,seconds:c.seconds,elapsed:0}),Te.length>8&&Te.shift();else if(c.kind==="floatingText"){var _a=_.get(c.componentId),lt=x.instanceId?(At=Qe([],Fe(oe.values()),!1).find(function(_n){return _n.instanceId===x.instanceId&&_n.prototypeId===c.componentId}))!==null&&At!==void 0?At:_a:(St=vt(c.componentId))!==null&&St!==void 0?St:_a,Yt=lt?.sceneId===U?lt:_a;if(Yt){var mt=void 0;if(Yt.contract==="native.mesh3d.v1"&&(mt=Hs(Yt.id)),!mt){var Fi=Vt(Yt);mt=ti(ri(Yt),Fi.width/2,Fi.height/2)}ve.push({x:mt.x,y:mt.y,text:c.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Mn,dr){var Pr;return String((Pr=H[dr])!==null&&Pr!==void 0?Pr:"")}),color:c.color,fontSize:c.fontSize,risePx:c.risePx,seconds:c.seconds,elapsed:0}),ve.length>32&&ve.shift()}}else if(c.kind==="store")x.kind==="click"&&x.pointerId!==void 0&&!ee&&(ee={pointerId:x.pointerId,targetId:x.targetId,condition:I},(pt=e.setPointerCapture)===null||pt===void 0||pt.call(e,x.pointerId));else if(c.behaviorId){var wn=n.gameplay.find(function(mi){return mi.id===c.behaviorId});if(c.kind==="playAudio")Yp(wn);else if(c.kind==="animate"){var Ma=_.get(wn.componentId),Hi=ci(Ma)?Qe([],Fe(oe.values()),!1).filter(function(Xn){return Xn.prototypeId===Ma.id&&(!x.instanceId||Xn.instanceId===x.instanceId)}):[Ma],la=function(Xn){var _n=wn.id+":"+Xn.id;pe=pe.filter(function(dr){return dr.id!==_n});var Mn=It({},wn.parameters);Mn.fromCurrent&&(Mn.from=Mn.property==="opacity"?Vt(Xn).opacity:zn(Xn)[Mn.property==="x"?4:5]),pe.push(It(It({},wn),{parameters:Mn,id:_n,behaviorId:wn.id,targetId:Xn.id,elapsed:0,baseTransform:Qe([],Fe(Xn.transform),!1)}))};try{for(var Zr=Be(Hi),Xi=Zr.next();!Xi.done;Xi=Zr.next()){var Yt=Xi.value;la(Yt)}}catch(Xn){K={error:Xn}}finally{try{Xi&&!Xi.done&&(k=Zr.return)&&k.call(Zr)}finally{if(K)throw K.error}}}else c.kind==="stopAnimation"?pe=pe.filter(function(mi){return mi.behaviorId!==wn.id}):c.kind==="emit"&&Cg(wn,x)}}function Cg(c,x){var I,E,R,F,L,X,G,K,k,q=c.parameters,J=q.shape==="pixel-confetti",te=q.shape==="confetti",j=J||te;if(!(j&&A?.matches)){if(ce.length+q.count>256){Ti("Particle budget exhausted");return}if(J&&q.coverage==="screen"){ce.push.apply(ce,Qe([],Fe(sg(q)),!1));return}if(te&&q.coverage==="screen"){ce.push.apply(ce,Qe([],Fe(lg(q)),!1));return}var ae=_.get(c.componentId),fe=x.instanceId&&(I=Qe([],Fe(oe.values()),!1).find(function(Ht){return Ht.instanceId===x.instanceId&&Ht.prototypeId===ae.id}))!==null&&I!==void 0?I:ae;if(q.origin==="contact-3d"){if(A?.matches)return;var Se=zs(fe);if(!Se)return;for(var xe=eg(fe,vt,Vt,Rt),Ie=[q.color,q.color2,q.color3].filter(Boolean),ye=du(uu(fe.id+":"+Q.toFixed(3))),we=((E=q.spread)!==null&&E!==void 0?E:360)*Math.PI/180,he=((R=q.direction)!==null&&R!==void 0?R:-90)*Math.PI/180,Ue=0;Ue<q.count;Ue++){var Oe=he+we*(ye.next()-.5),et=q.speed/100*ye.between(.42,1.1);ce.push(It(It({},xe),{stageId:Se.id,shape:"contact-3d",confetti:te,age:0,vx:Math.cos(Oe)*et,vy:ye.between(.55,.95)*et,vz:Math.sin(Oe)*et,life:((F=q.lifetime)!==null&&F!==void 0?F:.5)*ye.between(.7,1),gravity:((L=q.gravity)!==null&&L!==void 0?L:300)/100,color:Ie[Ue%Ie.length],size:ye.between(.024,.058),spinX:ye.between(-13,13),spinZ:ye.between(-17,17)}))}return}for(var He=zn(fe),Je,wt=vt(fe.parentId);wt;wt=vt(wt.parentId)){if(j&&wt.contract==="native.group.v1"&&Vt(wt).clip){Je=wt.id;break}He=Io(zn(wt),He)}var kt=Vt(fe),en=q.origin==="anchor"?ti(He,0,0):j||q.origin==="center"?ti(He,kt.width/2,kt.height/2):{x:He[4]+fe.parameters.width/2,y:He[5]+fe.parameters.height/2};if(J){ce.push.apply(ce,Qe([],Fe(Op(q,en,Je)),!1));return}if(te){ce.push.apply(ce,Qe([],Fe(Bp(q,en,Je)),!1));return}for(var Xt=du(uu(fe.id+":"+Q.toFixed(3))),Ue=0;Ue<q.count;Ue++){var Oe=-Math.PI/2+((Ue+Xt.next())/q.count-.5)*((X=q.spread)!==null&&X!==void 0?X:360)*Math.PI/180,et=q.speed*Xt.between(.5,.95);ce.push(It(It({},en),{vx:Math.cos(Oe)*et,vy:Math.sin(Oe)*et,life:(G=q.lifetime)!==null&&G!==void 0?G:.7,gravity:(K=q.gravity)!==null&&K!==void 0?K:250,color:q.color,shape:(k=q.shape)!==null&&k!==void 0?k:"circle"}))}}}function Zp(c){var x,I;if(c==="__restart"){Al();return}if(c!==U){on=void 0;var E=U;li(),U=c,re.clear(),fn.clear(),Dn.clear(),si.clear(),yi.clear(),kn.clear(),Lt=[],Nt=[],ii.clear(),C.clear(),Wt=void 0,ne=[],ce=[],ve=[],Te=[],Ve=void 0,Ce=!1,Ae=0,oe.clear(),Pn.clear(),ei.clear(),Rt.clear(),De.clear(),rn.clear(),$t.clear(),Wr=0,We?.reset(),qn.clear(),Hn.clear(),de=void 0,Bs(),le=le.filter(function(X){return X.kind==="variableChange"}),qe.clear(),Ut=void 0;try{for(var R=Be(nn.values()),F=R.next();!F.done;F=R.next()){var L=F.value;L.reset()}}catch(X){x={error:X}}finally{try{F&&!F.done&&(I=R.return)&&I.call(R)}finally{if(x)throw x.error}}be.clear(),Pe.clear(),Gt.clear(),pe=[],er(),V.clear(),Pt=void 0,tn=void 0,xo(),qc(),ks(0,!1),Cf(),yo(0),In({kind:"sceneExit",sceneId:E}),In({kind:"sceneEnter",sceneId:U})}}function ya(){for(var c=function(){var x,I,E,R,F=le.shift();tt++;var L=function(j){return j===void 0||!!vt(j)||Qe([],Fe(oe.values()),!1).some(function(ae){return ae.instanceId===j})};if(!L(F.selfInstanceId)||!L(F.otherInstanceId)||["contactBegin","boundaryExit"].includes(F.kind)&&F.instanceId&&!oe.has(F.instanceId))return"continue";try{for(var X=(x=void 0,Be(n.eventBindings)),G=X.next();!G.done;G=X.next()){var K=G.value;if(Object.entries(B.get(K.eventId)).every(function(j){var ae=Fe(j,2),fe=ae[0],Se=ae[1];return fe==="id"||F[fe]===Se})&&Us(K.condition,F)){try{for(var k=(E=void 0,Be(K.actions)),q=k.next();!q.done;q=k.next()){var J=q.value;if(Ge>=1024||Ye)break;Ig(J,F,K.condition)}}catch(j){E={error:j}}finally{try{q&&!q.done&&(R=k.return)&&R.call(k)}finally{if(E)throw E.error}}if(ln)break}}}catch(j){x={error:j}}finally{try{G&&!G.done&&(I=X.return)&&I.call(X)}finally{if(x)throw x.error}}if(ln){var te=ln;ln=void 0,Zp(te)}};le.length&&!Ye&&tt<256&&Ge<1024;)c();le.length&&Ti("Event/action budget exhausted")}function ri(c){return Io(c.parentId?ri(vt(c.parentId)):Ua(),zn(c))}var ti=function(c,x,I){return{x:c[0]*x+c[2]*I+c[4],y:c[1]*x+c[3]*I+c[5]}};function _r(c,x){var I=Vt(c),E=[[0,0],[I.width,0],[I.width,I.height],[0,I.height]].map(function(R){var F=Fe(R,2),L=F[0],X=F[1];return ti(x,L,X)});return{left:Math.min.apply(Math,Qe([],Fe(E.map(function(R){return R.x})),!1)),right:Math.max.apply(Math,Qe([],Fe(E.map(function(R){return R.x})),!1)),top:Math.min.apply(Math,Qe([],Fe(E.map(function(R){return R.y})),!1)),bottom:Math.max.apply(Math,Qe([],Fe(E.map(function(R){return R.y})),!1))}}function hi(c){return Vt(c).visible&&Vt(c).opacity>0&&(!c.parentId||hi(vt(c.parentId)))}function Jp(c,x){for(var I=Vt(c),E=ri(c),R=Math.min(I.width,I.height)/2,F=x==="circle"?Array.from({length:32},function(G,K){return ti(E,I.width/2+Math.cos(K*Math.PI/16)*R,I.height/2+Math.sin(K*Math.PI/16)*R)}):[[0,0],[I.width,0],[I.width,I.height],[0,I.height]].map(function(G){var K=Fe(G,2),k=K[0],q=K[1];return ti(E,k,q)}),L=c.parentId?vt(c.parentId):void 0,X=function(){var G=Vt(L);if(L.contract==="native.group.v1"&&G.clip){for(var K=ri(L),k=[[0,0],[G.width,0],[G.width,G.height],[0,G.height]].map(function(ae){var fe=Fe(ae,2),Se=fe[0],xe=fe[1];return ti(K,Se,xe)}),q=0,J=0;J<4;J++)q+=k[J].x*k[(J+1)%4].y-k[(J+1)%4].x*k[J].y;for(var te=q>=0?1:-1,j=function(ae){var fe,Se,xe=k[ae],Ie=k[(ae+1)%4],ye=function(kt){return te*((Ie.x-xe.x)*(kt.y-xe.y)-(Ie.y-xe.y)*(kt.x-xe.x))},we=F;F=[];var he=we[we.length-1],Ue=ye(he);try{for(var Oe=(fe=void 0,Be(we)),et=Oe.next();!et.done;et=Oe.next()){var He=et.value,Je=ye(He);if(Je>=0!=Ue>=0){var wt=Ue/(Ue-Je);F.push({x:he.x+(He.x-he.x)*wt,y:he.y+(He.y-he.y)*wt})}Je>=0&&F.push(He),he=He,Ue=Je}}catch(kt){fe={error:kt}}finally{try{et&&!et.done&&(Se=Oe.return)&&Se.call(Oe)}finally{if(fe)throw fe.error}}},J=0;J<4&&F.length;J++)j(J)}L=L.parentId?vt(L.parentId):void 0};L;)X();return F}function Rg(c,x){var I,E,R,F,L,X;if(c.length<3||x.length<3)return!1;try{for(var G=Be([c,x]),K=G.next();!K.done;K=G.next())for(var k=K.value,q=0;q<k.length;q++){var J=k[q],te=k[(q+1)%k.length],j=J.y-te.y,ae=te.x-J.x,fe=1/0,Se=-1/0,xe=1/0,Ie=-1/0;try{for(var ye=(R=void 0,Be(c)),we=ye.next();!we.done;we=ye.next()){var he=we.value,Ue=he.x*j+he.y*ae;fe=Math.min(fe,Ue),Se=Math.max(Se,Ue)}}catch(He){R={error:He}}finally{try{we&&!we.done&&(F=ye.return)&&F.call(ye)}finally{if(R)throw R.error}}try{for(var Oe=(L=void 0,Be(x)),et=Oe.next();!et.done;et=Oe.next()){var he=et.value,Ue=he.x*j+he.y*ae;xe=Math.min(xe,Ue),Ie=Math.max(Ie,Ue)}}catch(He){L={error:He}}finally{try{et&&!et.done&&(X=Oe.return)&&X.call(Oe)}finally{if(L)throw L.error}}if(Se<xe||Ie<fe)return!1}}catch(He){I={error:He}}finally{try{K&&!K.done&&(E=G.return)&&E.call(G)}finally{if(I)throw I.error}}return!0}function Pg(c){var x,I,E,R,F=T();try{for(var L=Be(re.values()),X=L.next();!X.done;X=L.next()){var G=X.value,K=G.behavior.parameters;if(!(!K.moveComponentId||G.magnitude<=0)){var k=vt(K.moveComponentId);if(!(!k||!hi(k))){var q=(E=K.moveSpeed)!==null&&E!==void 0?E:220,J=pn("physics-body",(R=k.prototypeId)!==null&&R!==void 0?R:k.id);if(J&&J.parameters.mode==="dynamic"){var te=ra(k,J);te.vx=G.nx*q,te.vy=G.ny*q,te.atRest=!1,te.restElapsed=0}else{var j=Ci(k),ae=Vt(k),fe=j.x+G.nx*q*c,Se=j.y+G.ny*q*c;$p(k)||(fe=Math.max(ae.width/2,Math.min(F.width-ae.width/2,fe)),Se=Math.max(ae.height/2,Math.min(F.height-ae.height/2,Se))),Rr(k,fe,Se)}K.orientToMove&&Ur(k,Math.atan2(G.ny,G.nx))}}}}catch(xe){x={error:xe}}finally{try{X&&!X.done&&(I=L.return)&&I.call(L)}finally{if(x)throw x.error}}}function Lg(c){var x,I,E,R,F,L,X,G,K,k,q,J,te,j,ae,fe,Se,xe,Ie,ye,we,he,Ue,Oe,et,He,Je,wt,kt,en,Xt,Ht,Et=T();Q+=c,on&&Q>=on.at&&Zp(on.sceneId),Yg(c),Eg(c),Pg(c),Ag(c),Tf();try{for(var Mt=Be(rt),At=Mt.next();!At.done;At=Mt.next()){var St=Fe(At.value,2),pt=St[0],bt=St[1];!bt.held&&Q-((Ue=bt.releasedAt)!==null&&Ue!==void 0?Ue:Q)>=bt.behavior.springBackSeconds&&rt.delete(pt)}}catch(sn){x={error:sn}}finally{try{At&&!At.done&&(I=Mt.return)&&I.call(Mt)}finally{if(x)throw x.error}}Ve&&(Ve.elapsed+=c,Ve.elapsed>=Ve.seconds&&(Ve=void 0));try{for(var Qt=Be(Te),ot=Qt.next();!ot.done;ot=Qt.next()){var hn=ot.value;hn.elapsed+=c}}catch(sn){E={error:sn}}finally{try{ot&&!ot.done&&(R=Qt.return)&&R.call(Qt)}finally{if(E)throw E.error}}Te=Te.filter(function(sn){return sn.elapsed<sn.seconds});try{for(var Kt=Be(ve),Cn=Kt.next();!Cn.done;Cn=Kt.next()){var Yt=Cn.value;Yt.elapsed+=c}}catch(sn){F={error:sn}}finally{try{Cn&&!Cn.done&&(L=Kt.return)&&L.call(Kt)}finally{if(F)throw F.error}}ve=ve.filter(function(sn){return sn.elapsed<sn.seconds});try{for(var bn=Be(nn),lt=bn.next();!lt.done;lt=bn.next()){var mt=Fe(lt.value,2),pt=mt[0],Nn=mt[1];_.get(pt).sceneId===U&&hi(_.get(pt))&&Nn.tick(c)}}catch(sn){X={error:sn}}finally{try{lt&&!lt.done&&(G=bn.return)&&G.call(bn)}finally{if(X)throw X.error}}var Ni=function(sn){var vi,Yi,Ji=_.get(sn.componentId);if(Ji.sceneId!==U)return"continue";var Oi=ci(Ji)?Qe([],Fe(oe.values()),!1).filter(function($s){return $s.prototypeId===Ji.id}):[Ji];try{for(var fr=(vi=void 0,Be(Oi)),_i=fr.next();!_i.done;_i=fr.next()){var Vi=_i.value,vs=sn.id+":"+Vi.id;if(sn.kind==="motion"){var Fr=(Oe=qe.get(Vi.id))!==null&&Oe!==void 0?Oe:{transform:Qe([],Fe(Vi.transform),!1),parameters:{}},ua=(et=Fr.velocity)!==null&&et!==void 0?et:{x:sn.parameters.vx,y:sn.parameters.vy};ua.y+=sn.parameters.gravity*c,Fr.transform[4]+=ua.x*c,Fr.transform[5]+=ua.y*c,Fr.velocity=ua,qe.set(Vi.id,Fr),Vi.prototypeId&&(Vi.transform=Fr.transform);var Ka=ri(Vi);(Ka[5]>Et.height||Ka[4]<-300||Ka[4]>Et.width+300)&&(Fr.exited||(Fr.exited=!0,In({kind:"boundaryExit",componentId:Ji.id,instanceId:Vi.instanceId})))}else if(sn.kind==="timer"){var Js=((He=Gt.get(vs))!==null&&He!==void 0?He:0)+c;Gt.set(vs,Js),Js>=sn.parameters.seconds&&Js-c<sn.parameters.seconds&&(In(It({kind:"timer",behaviorId:sn.id,componentId:Ji.id},Vi.instanceId?{instanceId:Vi.instanceId,selfInstanceId:Vi.instanceId}:{})),sn.parameters.repeat&&Gt.set(vs,Js-sn.parameters.seconds))}}}catch($s){vi={error:$s}}finally{try{_i&&!_i.done&&(Yi=fr.return)&&Yi.call(fr)}finally{if(vi)throw vi.error}}};try{for(var bi=Be(n.gameplay),xi=bi.next();!xi.done;xi=bi.next()){var $n=xi.value;Ni($n)}}catch(sn){K={error:sn}}finally{try{xi&&!xi.done&&(k=bi.return)&&k.call(bi)}finally{if(K)throw K.error}}Os(c),Yc(c),ks(c),yo(c);var wi=[],pi=function(sn){var vi,Yi,Ji=_.get(sn.componentId);if(Ji.sceneId!==U)return"continue";try{for(var Oi=(vi=void 0,Be(ci(Ji)?Qe([],Fe(oe.values()),!1).filter(function(Vi){return Vi.prototypeId===Ji.id}):[Ji])),fr=Oi.next();!fr.done;fr=Oi.next()){var _i=fr.value;if(hi(_i)){if(wi.length>=256){Ti("Collider budget exhausted");break}wi.push({b:sn,c:_i,box:_r(_i,ri(_i)),polygon:Jp(_i,sn.parameters.shape)})}}}catch(Vi){vi={error:Vi}}finally{try{fr&&!fr.done&&(Yi=Oi.return)&&Yi.call(Oi)}finally{if(vi)throw vi.error}}};try{for(var ni=Be(n.gameplay.filter(function(sn){return sn.kind==="collider"})),Ri=ni.next();!Ri.done;Ri=ni.next()){var $n=Ri.value;pi($n)}}catch(sn){q={error:sn}}finally{try{Ri&&!Ri.done&&(J=ni.return)&&J.call(ni)}finally{if(q)throw q.error}}var di=new Set,aa=new Map,gr=function(sn,vi,Yi){var Ji,Oi,fr;((Ji=vi.c.prototypeId)!==null&&Ji!==void 0?Ji:vi.c.id)===((Oi=Yi.c.prototypeId)!==null&&Oi!==void 0?Oi:Yi.c.id)&&vi.c.id>Yi.c.id||In(It(It({},tr(sn,vi.c,Yi.c)),{instanceId:(fr=vi.c.instanceId)!==null&&fr!==void 0?fr:Yi.c.instanceId}))},zi=0;e:for(var un=0;un<wi.length;un++)for(var $n=un+1;$n<wi.length;$n++){var an=wi[un],Ft=wi[$n];if(!(an.c.instanceId&&an.c.instanceId===Ft.c.instanceId)){var Ei=an.box,Ai=Ft.box,Yr=Ei.left<Ai.right&&Ei.right>Ai.left&&Ei.top<Ai.bottom&&Ei.bottom>Ai.top;if(Yr){if(++zi>4096){Ti("Collision budget exhausted");break e}Yr=Rg(an.polygon,Ft.polygon)}if(Yr){var Qn=[an.c.id,Ft.c.id].sort().join("|");if(di.add(Qn),aa.set(Qn,[an,Ft]),!be.has(Qn))try{for(var Hi=(te=void 0,Be([[an,Ft],[Ft,an]])),sa=Hi.next();!sa.done;sa=Hi.next()){var Pa=Fe(sa.value,2),$a=Pa[0],qr=Pa[1];gr("contactBegin",$a,qr)}}catch(vi){te={error:vi}}finally{try{sa&&!sa.done&&(j=Hi.return)&&j.call(Hi)}finally{if(te)throw te.error}}}}}try{for(var Mr=Be(Pe),xa=Mr.next();!xa.done;xa=Mr.next()){var oa=Fe(xa.value,2),Qn=oa[0],La=Fe(oa[1],2),an=La[0],Ft=La[1];if(!di.has(Qn))try{for(var nr=(Se=void 0,Be([[an,Ft],[Ft,an]])),Ui=nr.next();!Ui.done;Ui=nr.next()){var Wi=Fe(Ui.value,2),$a=Wi[0],qr=Wi[1];gr("contactEnd",$a,qr)}}catch(Ji){Se={error:Ji}}finally{try{Ui&&!Ui.done&&(xe=nr.return)&&xe.call(nr)}finally{if(Se)throw Se.error}}}}catch(sn){ae={error:sn}}finally{try{xa&&!xa.done&&(fe=Mr.return)&&fe.call(Mr)}finally{if(ae)throw ae.error}}be=di,Pe=aa;try{for(var _a=Be(pe),Fi=_a.next();!Fi.done;Fi=_a.next()){var un=Fi.value;un.elapsed+=c;var wn=un.parameters,Ma=(Je=wn.delay)!==null&&Je!==void 0?Je:0,la=un.elapsed-Ma;if(!(la<0)){var Zr=la/wn.seconds,Xi=wn.loop?Zr%1:Math.min(1,Zr),mi=(wt=wn.easing)!==null&&wt!==void 0?wt:"ease-out",Xn=Xi;wn.loop&&mi==="ease-in-out"?Xn=.5-.5*Math.cos(Xi*Math.PI*2):mi==="ease-out"?Xn=1-Math.pow(1-Xi,3):mi==="ease-in"?Xn=Math.pow(Xi,3):mi==="ease-in-out"?Xn=Xi<.5?4*Math.pow(Xi,3):1-Math.pow(-2*Xi+2,3)/2:mi==="back-out"&&(Xn=1+2.70158*Math.pow(Xi-1,3)+1.70158*Math.pow(Xi-1,2));var _n=wn.from+(wn.to-wn.from)*Xn,Mn=vt((kt=un.targetId)!==null&&kt!==void 0?kt:un.componentId);if(Mn){var dr=(en=qe.get(Mn.id))!==null&&en!==void 0?en:{transform:Qe([],Fe(Mn.transform),!1),parameters:{}},Pr=(Xt=un.baseTransform)!==null&&Xt!==void 0?Xt:Mn.transform;if(wn.property==="opacity")dr.parameters.opacity=Math.max(0,Math.min(1,_n));else if(["scale","scaleX","scaleY","rotation"].includes(wn.property)){(Ht=dr.animationAxes)!==null&&Ht!==void 0||(dr.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),dr.animationAxes[wn.property]=_n;var Sa=dr.animationAxes,ms=Sa.rotation*Math.PI/180,wo=Math.cos(ms),qs=Math.sin(ms),To=Sa.scale*Sa.scaleX,Eo=Sa.scale*Sa.scaleY;dr.transform[0]=(Pr[0]*wo+Pr[2]*qs)*To,dr.transform[1]=(Pr[1]*wo+Pr[3]*qs)*To,dr.transform[2]=(-Pr[0]*qs+Pr[2]*wo)*Eo,dr.transform[3]=(-Pr[1]*qs+Pr[3]*wo)*Eo}else dr.transform[wn.property==="x"?4:5]=_n;qe.set(Mn.id,dr),wn.loop&&la>=wn.seconds&&(un.elapsed=Ma+la%wn.seconds)}}}}catch(sn){Ie={error:sn}}finally{try{Fi&&!Fi.done&&(ye=_a.return)&&ye.call(_a)}finally{if(Ie)throw Ie.error}}pe=pe.filter(function(sn){var vi,Yi;return vt((vi=sn.targetId)!==null&&vi!==void 0?vi:sn.componentId)&&(sn.elapsed<sn.parameters.seconds+((Yi=sn.parameters.delay)!==null&&Yi!==void 0?Yi:0)||sn.parameters.loop)});try{for(var Zs=Be(ce),ca=Zs.next();!ca.done;ca=Zs.next()){var wn=ca.value;if(wn.age!==void 0){wn.age+=c;continue}wn.life-=c,wn.x+=wn.vx*c,wn.y+=wn.vy*c,wn.vy+=wn.gravity*c}}catch(sn){we={error:sn}}finally{try{ca&&!ca.done&&(he=Zs.return)&&he.call(Zs)}finally{if(we)throw we.error}}ce=ce.filter(function(sn){var vi;return sn.life>((vi=sn.age)!==null&&vi!==void 0?vi:0)}),ya()}function Jc(c,x){var I,E,R;if(p.beginPath(),c.contract==="native.ellipse.v1")p.ellipse(x.width/2,x.height/2,x.width/2,x.height/2,0,0,Math.PI*2);else if(c.contract==="native.path.v1"){var F=function(J,te){({M:function(){return p.moveTo.apply(p,Qe([],Fe(te),!1))},L:function(){return p.lineTo.apply(p,Qe([],Fe(te),!1))},C:function(){return p.bezierCurveTo.apply(p,Qe([],Fe(te),!1))},Q:function(){return p.quadraticCurveTo.apply(p,Qe([],Fe(te),!1))},Z:function(){return p.closePath()}})[J]()};try{for(var L=Be(x.commands),X=L.next();!X.done;X=L.next()){var G=Fe(X.value),K=G[0],k=G.slice(1);F(K,k)}}catch(J){I={error:J}}finally{try{X&&!X.done&&(E=L.return)&&E.call(L)}finally{if(I)throw I.error}}}else{var q=Math.min((R=x.radius)!==null&&R!==void 0?R:0,x.width/2,x.height/2);typeof p.roundRect=="function"?p.roundRect(0,0,x.width,x.height,q):(p.moveTo(q,0),p.arcTo(x.width,0,x.width,x.height,q),p.arcTo(x.width,x.height,0,x.height,q),p.arcTo(0,x.height,0,0,q),p.arcTo(0,0,x.width,0,q),p.closePath())}}function Dg(c,x,I){var E,R,F,L=(E=qe.get(c.id))===null||E===void 0?void 0:E.pathFrame;if(L!==void 0)return Math.min(x.frameCount-1,L);if(f||!x.frameRate)return 0;if(c.contract!=="native.walk-sprite.v1")return Math.floor(Math.max(0,Q-((R=c.spawnTime)!==null&&R!==void 0?R:0))*x.frameRate)%x.frameCount;var X=(F=c.runtimeId)!==null&&F!==void 0?F:c.id,G=st.get(X);if(!G)return st.set(X,{x:I[4],y:I[5],phase:0,lastMove:-1/0,frame:0}),0;var K=Math.hypot(I[4]-G.x,I[5]-G.y)>.3;if(K){var k=Q-G.lastMove;G.phase=Number.isFinite(k)&&k<.25?G.phase+Math.min(k,.12)*x.frameRate:0,G.lastMove=Q}return G.x=I[4],G.y=I[5],Q-G.lastMove>.11&&(G.phase=0),G.frame=Math.floor(G.phase)%x.frameCount,G.frame}var Cl=!1,bo={width:390,height:700},ui,Lf=new Set;function $c(c){var x,I;c!==Cl&&(c?(p.save(),p.beginPath(),p.rect((x=bo.left)!==null&&x!==void 0?x:0,(I=bo.top)!==null&&I!==void 0?I:0,bo.width,bo.height),p.clip(),Cl=!0):(p.restore(),Cl=!1))}function Ys(c,x,I,E,R){var F,L,X,G,K,k,q,J,te,j,ae,fe,Se,xe,Ie,ye,we;if(x===void 0&&(x=Ua()),I===void 0&&(I=[]),R===void 0&&(R=!1),c.contract!=="native.mesh3d.v1"){var he=Vt(c),Ue=pn("erase-mask",(ae=c.prototypeId)!==null&&ae!==void 0?ae:c.id);if(!(!he.visible||he.opacity<=0)){var Oe=Io(x,zn(c));if(Lf.has(c.id)){b.push({c,m:Oe,clips:I,instance:E??c.prototypeId});try{for(var et=Be(On(c.id)),He=et.next();!He.done;He=et.next()){var Je=He.value;Ys(Je,Oe,I,E??c.prototypeId,!0)}}catch(Ai){F={error:Ai}}finally{try{He&&!He.done&&(L=et.return)&&L.call(et)}finally{if(F)throw F.error}}return}if(c.contract==="native.stage3d.v1"&&We&&ui&&En.has(c.id)){$c(!1);var wt=We.renderStage(c,p,ui.pw,ui.ph,ui.w,ui.h,{time:Q,ambientTime:ie,propsOf:Vt,bodies3d:Rt,fpsPose:$t.get(c.id),instances3d:Vn(c.id),contactParticles:A?.matches?[]:ce.filter(function(Ai){return Ai.stageId===c.id}),aimLocked:!!xt,groundFn:eo,worldWidth:ui.w,worldHeight:ui.h,designHeight:T().height,drawX:ui.x,drawY:ui.y,fullBleed:!0});try{for(var kt=Be(Rt),en=kt.next();!en.done;en=kt.next()){var Xt=Fe(en.value,2),Ht=Xt[0],Et=Xt[1];if(Et.stageId===c.id&&Et.mode==="dynamic"){var Mt=wt.project({x:Et.x,y:Et.y,z:Et.z},ui.w,ui.h);rn.set(Ht,{x:ui.x+Mt.x,y:ui.y+Mt.y})}}}catch(Ai){X={error:Ai}}finally{try{en&&!en.done&&(G=kt.return)&&G.call(kt)}finally{if(X)throw X.error}}b.push({c,m:Oe,clips:I,instance:E??c.prototypeId});try{for(var At=Be(On(c.id)),St=At.next();!St.done;St=At.next()){var Je=St.value;Ys(Je,Oe,I,E??c.prototypeId,!0)}}catch(Ai){K={error:Ai}}finally{try{St&&!St.done&&(k=At.return)&&k.call(At)}finally{if(K)throw K.error}}return}Cl||$c(!0),p.save(),p.transform.apply(p,Qe([],Fe(R?Oe:zn(c)),!1)),p.globalAlpha*=he.opacity;var pt=rt.get(c.id);pt?.behavior.liftShadow&&(p.shadowColor="#00000055",p.shadowBlur=8,p.shadowOffsetY=4);var bt=I;c.contract==="native.group.v1"&&he.clip&&(p.beginPath(),p.rect(0,0,he.width,he.height),p.clip(),bt=Qe(Qe([],Fe(I),!1),[{matrix:Oe,width:he.width,height:he.height}],!1));var Qt=!1;if(!["native.group.v1","native.text.v1","native.image.v1","native.sprite.v1","native.walk-sprite.v1","native.stage3d.v1","native.mesh3d.v1"].includes(c.contract)){var ot=c.contract==="native.button.v1",hn=Pt===c.id,Kt=ot?he.enabled?hn?he.pressedFill:jt===c.id?he.hoverFill:he.fill:he.disabledFill:he.fill;if(ot&&(he.presentation==="pixel-cta"||he.presentation==="shiny-cta")){var Cn=(fe=$.get(c.id))!==null&&fe!==void 0?fe:ie;V.set(c.id,Cn);var Yt=!f&&!A?.matches?ie-Cn:-1;he.presentation==="shiny-cta"?dg(p,he,Kt,hn,Yt):ug(p,he,Kt,hn,Yt)}else he.pixelFrame&&(p.save(),p.translate(3,4),Jc(c,he),p.fillStyle="#3c293366",p.fill(),p.restore()),Jc(c,he),Ue?(p.save(),p.clip(),va(c,Ue).render(p),p.restore(),Qt=!0,Jc(c,he)):(p.fillStyle=Kt,p.fill()),he.pixelFrame&&!(he.radius>0)&&(p.fillStyle="#ffffff22",p.fillRect(2,2,Math.max(0,he.width-4),2),p.fillRect(2,2,2,Math.max(0,he.height-4))),he.strokeWidth&&(p.strokeStyle=he.stroke,p.lineWidth=he.strokeWidth,p.stroke());Wt===c.id&&(Jc(c,he),p.strokeStyle="#ffffff",p.lineWidth=5,p.stroke())}var bn;if(c.contract==="native.text.v1"){var lt=he.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Ai,Yr){var Qn;return String((Qn=H[Yr])!==null&&Qn!==void 0?Qn:"")});he.pixelPanel&&(p.fillStyle="#3c293366",p.fillRect(3,4,he.width,he.height),p.fillStyle=he.panelFill,p.fillRect(0,0,he.width,he.height),p.strokeStyle=(Se=he.panelStroke)!==null&&Se!==void 0?Se:he.color,p.lineWidth=2,p.strokeRect(1,1,he.width-2,he.height-2),p.fillStyle="#ffffff22",p.fillRect(3,3,Math.max(0,he.width-6),2));var mt=he.fontFamily==="pixel"?Np(lt,he):void 0;mt&&!mt.unsupportedChars.length?bn=ag(p,lt,he):bn=Jw(p,lt,mt?It(It({},he),{fontFamily:"sans-serif",fontWeight:"700"}):he)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(c.contract)&&!Ue){var Nn=D.get((Ie=(xe=qe.get(c.id))===null||xe===void 0?void 0:xe.assetId)!==null&&Ie!==void 0?Ie:(ye=c.assetSlots[0])===null||ye===void 0?void 0:ye.assetId);if(Nn?.complete&&Nn.naturalWidth){p.save(),p.beginPath(),p.rect(0,0,he.width,he.height),p.clip();var Ni=c.contract!=="native.image.v1",bi=Ni?Math.min(he.frameColumns,he.frameCount):1,xi=Ni?Math.ceil(he.frameCount/bi):1,$n=Nn.width/bi,wi=Nn.height/xi,pi=Ni?Dg(c,he,Oe):0,ni=pi%bi*$n,Ri=Math.floor(pi/bi)*wi,di=he.fit==="cover"?Math.max(he.width/$n,he.height/wi):Math.min(he.width/$n,he.height/wi),aa=he.fit==="stretch"?he.width:$n*di,gr=he.fit==="stretch"?he.height:wi*di;p.imageSmoothingEnabled=(we=he.smoothing)!==null&&we!==void 0?we:!0,p.drawImage(Nn,ni,Ri,$n,wi,(he.width-aa)/2,(he.height-gr)/2,aa,gr),p.restore()}}if(Ue&&!Qt&&va(c,Ue).render(p),c.contract==="native.stage3d.v1"&&We&&!En.has(c.id)){var ni=Math.hypot(Oe[0],Oe[1]),Ri=Math.hypot(Oe[2],Oe[3]),wt=We.renderStage(c,p,he.width*ni*me*_e,he.height*Ri*me*_e,he.width,he.height,{time:Q,ambientTime:ie,propsOf:Vt,bodies3d:Rt,fpsPose:$t.get(c.id),instances3d:Vn(c.id),contactParticles:A?.matches?[]:ce.filter(function(Hi){return Hi.stageId===c.id}),aimLocked:!!xt,groundFn:eo,worldWidth:he.width*ni,worldHeight:he.height*Ri});try{for(var zi=Be(Rt),un=zi.next();!un.done;un=zi.next()){var an=Fe(un.value,2),Ht=an[0],Et=an[1];if(Et.stageId===c.id&&Et.mode==="dynamic"){var Mt=wt.project({x:Et.x,y:Et.y,z:Et.z},he.width,he.height);rn.set(Ht,ti(Oe,Mt.x,Mt.y))}}}catch(Hi){q={error:Hi}}finally{try{un&&!un.done&&(J=zi.return)&&J.call(zi)}finally{if(q)throw q.error}}}b.push({c,m:Oe,clips:bt,instance:E??c.prototypeId,textMetrics:bn});try{for(var Ft=Be(On(c.id)),Ei=Ft.next();!Ei.done;Ei=Ft.next()){var Je=Ei.value;Ys(Je,Oe,bt,E??c.prototypeId)}}catch(Ai){te={error:Ai}}finally{try{Ei&&!Ei.done&&(j=Ft.return)&&j.call(Ft)}finally{if(te)throw te.error}}he.clip&&c.contract==="native.group.v1"&&Df(c.id),p.restore()}}}function Df(c,x){var I,E;if(!A?.matches)try{for(var R=Be(ce),F=R.next();!F.done;F=R.next()){var L=F.value;L.shape!=="pixel-confetti"&&L.shape!=="confetti"||L.clipId!==c||!!L.screen!=!!x||(p.save(),L.shape==="confetti"?cg(p,L,x):og(p,L,x),p.restore())}}catch(X){I={error:X}}finally{try{F&&!F.done&&(E=R.return)&&E.call(R)}finally{if(I)throw I.error}}}function Ng(c,x,I,E){p.save(),p.translate(c,x),p.globalAlpha=.92,p.lineWidth=2,p.lineJoin="round",I==="tap"&&(p.strokeStyle="#fff0bd",p.globalAlpha=.7*(1-E),p.beginPath(),p.arc(0,0,12+E*12,0,Math.PI*2),p.stroke(),p.globalAlpha=.92),p.fillStyle="#fff0bd",p.strokeStyle="#193b46",p.beginPath(),p.moveTo(-7,10),p.lineTo(-9,-1),p.quadraticCurveTo(-9,-5,-5,-5),p.lineTo(-3,-3),p.lineTo(-3,-17),p.quadraticCurveTo(-3,-22,1,-22),p.quadraticCurveTo(5,-22,5,-17),p.lineTo(5,-6),p.quadraticCurveTo(9,-9,11,-5),p.quadraticCurveTo(15,-7,16,-2),p.lineTo(14,9),p.quadraticCurveTo(12,18,3,18),p.lineTo(-1,18),p.quadraticCurveTo(-5,17,-7,10),p.closePath(),p.fill(),p.stroke(),p.restore()}function Ug(){var c,x,I,E,R,F,L,X,G,K,k,q,J,te,j,ae,fe,Se,xe;if(Ae=0,!f)try{for(var Ie=Be(n.gameplay.filter(function(Qn){return Qn.kind==="tutorial-hand"})),ye=Ie.next();!ye.done;ye=Ie.next()){var we=ye.value,he=_.get(we.componentId),Ue=vt(we.parameters.targetId);if(!(!he||he.sceneId!==U||!Ue||Ue.sceneId!==U||!hi(Ue))&&!(we.parameters.hideOnFirstInput&&Ce)){var Oe=nt?Q:ie;if(!(Oe-$e<we.parameters.idleDelaySeconds)){Ae++;var et=we.parameters.destinationId?vt(we.parameters.destinationId):void 0,He=Vt(Ue),Je=void 0;Ue.contract==="native.mesh3d.v1"&&(Je=Hs(Ue.id)),Je||(Je=ti(ri(Ue),He.width/2,He.height/2));var wt=Oe%1.2/1.2,kt=A?.matches?0:wt*wt*(3-2*wt),en=Je.x,Xt=Je.y;if(we.parameters.mode!=="tap"){var Ht=et?ti(ri(et),Vt(et).width/2,Vt(et).height/2):{x:Je.x-36,y:Je.y+48};en=Je.x+(Ht.x-Je.x)*kt,Xt=Je.y+(Ht.y-Je.y)*kt}Ng(en+8,Xt+22,we.parameters.mode,kt)}}}}catch(Qn){c={error:Qn}}finally{try{ye&&!ye.done&&(x=Ie.return)&&x.call(Ie)}finally{if(c)throw c.error}}try{for(var Et=Be(kn),Mt=Et.next();!Mt.done;Mt=Et.next()){var At=Fe(Mt.value,2),St=At[0],pt=At[1],bt=pn("draw-stroke",St).parameters;try{for(var Qt=(R=void 0,Be(pt.strokes)),ot=Qt.next();!ot.done;ot=Qt.next()){var hn=ot.value;if(!(hn.points.length<2)){p.save(),p.globalAlpha=bt.mode==="slice-blade"?Math.max(0,1-hn.age/.18):1,p.strokeStyle=bt.color,p.lineWidth=bt.strokeWidth,p.lineCap="round",p.lineJoin="round",p.beginPath(),p.moveTo(hn.points[0].x,hn.points[0].y);try{for(var Kt=(L=void 0,Be(hn.points.slice(1))),Cn=Kt.next();!Cn.done;Cn=Kt.next()){var Yt=Cn.value;p.lineTo(Yt.x,Yt.y)}}catch(Qn){L={error:Qn}}finally{try{Cn&&!Cn.done&&(X=Kt.return)&&X.call(Kt)}finally{if(L)throw L.error}}p.stroke(),p.restore()}}}catch(Qn){R={error:Qn}}finally{try{ot&&!ot.done&&(F=Qt.return)&&F.call(Qt)}finally{if(R)throw R.error}}}}catch(Qn){I={error:Qn}}finally{try{Mt&&!Mt.done&&(E=Et.return)&&E.call(Et)}finally{if(I)throw I.error}}try{for(var bn=Be(Nt),lt=bn.next();!lt.done;lt=bn.next()){var mt=lt.value;if(!(mt.broken||!mt.drawRope)){var Nn=Pn.get(mt.bodyId),Ni=vt(mt.anchorId);if(!(!Nn||!Ni)){var bi=Ci(Ni);p.save(),p.strokeStyle=mt.ropeColor,p.lineWidth=mt.ropeWidth,p.beginPath(),p.moveTo(bi.x,bi.y),p.lineTo(Nn.x,Nn.y),p.stroke(),p.restore()}}}}catch(Qn){G={error:Qn}}finally{try{lt&&!lt.done&&(K=bn.return)&&K.call(bn)}finally{if(G)throw G.error}}try{for(var xi=Be(n.gameplay.filter(function(Qn){var Hi;return Qn.kind==="virtual-joystick"&&((Hi=_.get(Qn.componentId))===null||Hi===void 0?void 0:Hi.sceneId)===U})),$n=xi.next();!$n.done;$n=xi.next()){var we=$n.value,wi=vt(we.componentId),He=we.parameters;if(!(!wi||!hi(wi)||He.drawControl===!1)){var pi=re.get(we.id),ni=pi&&pi.pointerId!==null?pi.origin:Ci(wi),Ri=pi&&pi.pointerId!==null?pi.knobX:ni.x,di=pi&&pi.pointerId!==null?pi.knobY:ni.y,aa=(fe=He.radiusPx)!==null&&fe!==void 0?fe:56;p.save(),p.fillStyle=(Se=He.baseColor)!==null&&Se!==void 0?Se:"#ffffff44",p.strokeStyle="#ffffffaa",p.lineWidth=2.5,p.beginPath(),p.arc(ni.x,ni.y,aa,0,Math.PI*2),p.fill(),p.stroke(),p.fillStyle=(xe=He.knobColor)!==null&&xe!==void 0?xe:"#fff0bdee",p.strokeStyle="#193b46aa",p.lineWidth=2,p.beginPath(),p.arc(Ri,di,aa*.42,0,Math.PI*2),p.fill(),p.stroke(),p.restore()}}}catch(Qn){k={error:Qn}}finally{try{$n&&!$n.done&&(q=xi.return)&&q.call(xi)}finally{if(k)throw k.error}}try{for(var gr=Be(ve),zi=gr.next();!zi.done;zi=gr.next()){var un=zi.value,an=Math.min(1,un.elapsed/un.seconds);p.save(),p.globalAlpha=1-an,p.fillStyle=un.color,p.strokeStyle="#193b46",p.lineWidth=3,p.font="900 "+un.fontSize+"px sans-serif",p.textAlign="center",p.textBaseline="middle";var Xt=un.y-(A?.matches?0:un.risePx*an);p.strokeText(un.text,un.x,Xt),p.fillText(un.text,un.x,Xt),p.restore()}}catch(Qn){J={error:Qn}}finally{try{zi&&!zi.done&&(te=gr.return)&&te.call(gr)}finally{if(J)throw J.error}}try{for(var Ft=Be(Te),Ei=Ft.next();!Ei.done;Ei=Ft.next()){var Ai=Ei.value,an=Math.min(1,Ai.elapsed/Ai.seconds),Yr=T();p.save(),p.globalAlpha=Ai.opacity*(1-an),p.fillStyle=Ai.color,p.fillRect(0,0,Yr.width,Yr.height),p.restore()}}catch(Qn){j={error:Qn}}finally{try{Ei&&!Ei.done&&(ae=Ft.return)&&ae.call(Ft)}finally{if(j)throw j.error}}}function Fg(){if(de){var c=Pn.get(de.targetId),x=de.behavior.parameters;if(c){var I=de.current.x-de.start.x,E=de.current.y-de.start.y,R=Math.hypot(I,E),F=Math.min(x.maxPullPx,R),L=R>.001?F/R:0;p.save(),p.lineCap="round";var X=Math.max(12,Math.min(c.width,c.height)*.62);if(p.strokeStyle="#173a2f66",p.lineWidth=3.5,p.beginPath(),p.arc(c.x,c.y,X,0,Math.PI*2),p.stroke(),p.strokeStyle=x.trajectoryColor,p.lineWidth=2,p.beginPath(),p.arc(c.x,c.y,X,0,Math.PI*2),p.stroke(),x.showTrajectory&&R>=x.minPullPx){var G=Uf(),K=Fs(),k=K.bodies,q=K.zones,J=T(),te=Um({body:It(It({},c),{vx:G.vx,vy:G.vy,atRest:!1}),bodies:k,zones:q,bounds:{left:0,top:0,right:J.width,bottom:J.height},dots:x.trajectoryDots,bounces:x.trajectoryBounces});te.forEach(function(fe,Se){var xe=.96-.52*(Se/Math.max(1,te.length)),Ie=Math.max(2.2,4.5-Se*.22);p.globalAlpha=xe,p.fillStyle="#173a2f88",p.beginPath(),p.arc(fe.x,fe.y,Ie+1.3,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(fe.x,fe.y,Ie,0,Math.PI*2),p.fill()})}if(R>=4){var j=c.x+I*L,ae=c.y+E*L;p.globalAlpha=.9,p.strokeStyle="#173a2f66",p.lineWidth=5,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(j,ae),p.stroke(),p.strokeStyle=x.trajectoryColor,p.lineWidth=2.6,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(j,ae),p.stroke(),p.fillStyle="#173a2f88",p.beginPath(),p.arc(j,ae,5.2,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(j,ae,3.6,0,Math.PI*2),p.fill()}p.restore()}}}function Og(c){var x,I,E,R;try{for(var F=Be(oi()),L=F.next();!L.done;L=F.next()){var X=L.value,G=X.contract==="native.group.v1"?On(X.id):[X];try{for(var K=(E=void 0,Be(G)),k=K.next();!k.done;k=K.next()){var q=k.value;if(q.contract==="native.stage3d.v1"&&hi(q)&&Vt(q).skyColor)return Vt(q).skyColor;if(!(q.contract!=="native.rectangle.v1"||!hi(q))){var J=Vt(q);if(!(J.opacity<.95||!J.fill||J.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test(q.id)||J.width>=c.width*.9&&J.height>=c.height*.9))return J.fill}}}catch(te){E={error:te}}finally{try{k&&!k.done&&(R=K.return)&&R.call(K)}finally{if(E)throw E.error}}}}catch(te){x={error:te}}finally{try{L&&!L.done&&(I=F.return)&&I.call(F)}finally{if(x)throw x.error}}return"#102a34"}function Bg(){var c;if(yt&&hi(yt.c)){var x=yt.c,I=Vt(x);p.save(),p.transform.apply(p,Qe([],Fe(ri(x)),!1)),p.strokeStyle=(c=yt.highlightColor)!==null&&c!==void 0?c:"#ffffff",p.lineWidth=4,p.globalAlpha=.85,p.strokeRect(-4,-4,I.width+8,I.height+8),p.restore()}if(Ke?.b.parameters.bringToFront){var x=vt(Ke.targetId);x&&Ys(x,x.parentId?ri(vt(x.parentId)):Ua(),[],x.prototypeId)}}function Zi(){var c,x,I,E,R,F,L,X,G,K;$=V,V=new Map;var k=T();z!==void 0&&z!==k.landscape&&er(),z=k.landscape;var q=Math.min(devicePixelRatio||1,2),J=e.clientWidth,te=e.clientHeight;(e.width!==Math.round(J*q)||e.height!==Math.round(te*q))&&(e.width=Math.round(J*q),e.height=Math.round(te*q)),p.setTransform(q,0,0,q,0,0),p.fillStyle=Og(k),p.fillRect(0,0,J,te);var j=Math.min(J/k.width,te/k.height),ae=(J-k.width*j)/2,fe=(te-k.height*j)/2;if(me=j||1,_e=q,p.translate(ae,fe),p.scale(j,j),Ve){var Se=Math.min(1,Ve.elapsed/Ve.seconds),xe=Ve.intensity*(1-Se);p.translate(Math.sin(Ve.elapsed*95)*xe,Math.cos(Ve.elapsed*113)*xe)}if(bo=k,Cl=!1,ui=void 0,Lf.clear(),En.clear(),We&&j>0&&J>=2&&te>=2){ui={x:-ae/j,y:-fe/j,w:J/j,h:te/j,pw:J*q,ph:te*q};try{for(var Ie=Be(n.components),ye=Ie.next();!ye.done;ye=Ie.next()){var we=ye.value;if(!(we.contract!=="native.stage3d.v1"||we.sceneId!==U||we.prototype||!hi(we))){for(var he=!0,Ue=[],Oe=we.parentId?vt(we.parentId):void 0;Oe;Oe=Oe.parentId?vt(Oe.parentId):void 0){var et=Vt(Oe);if(Oe.contract!=="native.group.v1"||et.clip||et.opacity<1){he=!1;break}Ue.push(Oe.id)}if(he){var He=ri(we),Je=Vt(we);if(!(Math.abs(He[1])>.001||Math.abs(He[2])>.001)){var wt=Math.hypot(He[0],He[1]),kt=Math.hypot(He[2],He[3]);if(!(He[4]>1||He[5]>1||He[4]+Je.width*wt<k.width-1||He[5]+Je.height*kt<k.height-1)){En.add(we.id);try{for(var en=(I=void 0,Be(Ue)),Xt=en.next();!Xt.done;Xt=en.next()){var Ht=Xt.value;Lf.add(Ht)}}catch(mt){I={error:mt}}finally{try{Xt&&!Xt.done&&(E=en.return)&&E.call(en)}finally{if(I)throw I.error}}}}}}}}catch(mt){c={error:mt}}finally{try{ye&&!ye.done&&(x=Ie.return)&&x.call(Ie)}finally{if(c)throw c.error}}}bo=ds(k),b=[];try{for(var Et=Be(oi()),Mt=Et.next();!Mt.done;Mt=Et.next()){var we=Mt.value;Ys(we)}}catch(mt){R={error:mt}}finally{try{Mt&&!Mt.done&&(F=Et.return)&&F.call(Et)}finally{if(R)throw R.error}}$c(!0);try{for(var At=Be(ne),St=At.next();!St.done;St=At.next()){var we=St.value;we.parentId||Ys(we,Ua(),[],we.prototypeId)}}catch(mt){L={error:mt}}finally{try{St&&!St.done&&(X=At.return)&&X.call(At)}finally{if(L)throw L.error}}if(Bg(),Fg(),f&&Z){for(var pt=_.get(Z);pt?.parentId;)pt=_.get(pt.parentId);pt?.prototype&&Ys(pt)}Df(),p.save();try{for(var bt=Be(ce),Qt=bt.next();!Qt.done;Qt=bt.next()){var Je=Qt.value;if(Je.age===void 0){var ot=Math.min(1,Je.life*2),hn=1.5+2.5*ot;if(p.globalAlpha=ot,p.globalCompositeOperation=Je.shape==="square"?"source-over":"lighter",p.fillStyle=Je.color,Je.shape==="square"){var Kt=Math.max(2,Math.round(hn*1.6));p.fillRect(Math.round(Je.x-Kt/2),Math.round(Je.y-Kt/2),Kt,Kt);continue}p.globalCompositeOperation="lighter",p.shadowColor=Je.color,p.shadowBlur=ce.length<=16?6:0,p.strokeStyle=Je.color,p.lineWidth=1.5+ot,p.beginPath(),p.moveTo(Je.x-Je.vx*.025,Je.y-Je.vy*.025),p.lineTo(Je.x,Je.y),p.stroke(),p.beginPath(),p.arc(Je.x,Je.y,hn,0,Math.PI*2),p.fill()}}}catch(mt){G={error:mt}}finally{try{Qt&&!Qt.done&&(K=bt.return)&&K.call(bt)}finally{if(G)throw G.error}}if(p.restore(),Ug(),f&&Z){var Cn=b.filter(function(mt){return mt.c.contract!=="native.group.v1"&&(mt.c.id===Z||Xr(mt.c,Z))});if(Cn.length){var Yt=Cn.map(function(mt){return _r(mt.c,mt.m)}),bn=Math.min.apply(Math,Qe([],Fe(Yt.map(function(mt){return mt.left})),!1)),lt=Math.min.apply(Math,Qe([],Fe(Yt.map(function(mt){return mt.top})),!1));p.strokeStyle="#55e6ef",p.lineWidth=2/j,p.strokeRect(bn,lt,Math.max.apply(Math,Qe([],Fe(Yt.map(function(mt){return mt.right})),!1))-bn,Math.max.apply(Math,Qe([],Fe(Yt.map(function(mt){return mt.bottom})),!1))-lt)}}$c(!1),j>0&&Df(void 0,{x:-ae/j,y:-fe/j,width:J/j,height:te/j})}function kg(c){var x,I,E,R,F=Array.isArray(c)?Qe([],Fe(new Set(c)),!1):void 0;Zi();var L=T(),X=ds(L),G=new Set,K=[];try{for(var k=Be(b),q=k.next();!q.done;q=k.next()){var J=q.value,te=(E=J.c.prototypeId)!==null&&E!==void 0?E:J.c.id;if(!(J.c.contract==="native.group.v1"||F&&!F.includes(te))){G.add(te);var j=_r(J.c,J.m),ae=((R=Vt(J.c).strokeWidth)!==null&&R!==void 0?R:0)/2;j.left-=ae,j.right+=ae,j.top-=ae,j.bottom+=ae;var fe={left:Math.max(0,X.left-j.left),right:Math.max(0,j.right-X.right),top:Math.max(0,X.top-j.top),bottom:Math.max(0,j.bottom-X.bottom)};Object.values(fe).some(function(xe){return xe>.01})&&K.push({id:te,contract:J.c.contract,bounds:j,overflow:fe})}}}catch(xe){x={error:xe}}finally{try{q&&!q.done&&(I=k.return)&&I.call(k)}finally{if(x)throw x.error}}var Se=F?F.filter(function(xe){return!G.has(xe)}):[];return{ok:K.length===0&&Se.length===0,viewport:It(It({},L),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight}),issues:K,missing:Se}}function zg(c){var x,I,E,R,F,L,X,G,K,k,q,J,te,j,ae,fe,Se,xe,Ie,ye,we,he,Ue,Oe,et,He,Je,wt,kt,en,Xt,Ht,Et,Mt=c===void 0?{}:c,At=Mt.ids,St=Mt.interactiveIds,pt=Mt.network,bt=pt===void 0?"standalone":pt,Qt=Mt.minTouchPx,ot=Qt===void 0?44:Qt,hn=Array.isArray(At)?Qe([],Fe(new Set(At)),!1):void 0;Zi();var Kt=T(),Cn=ds(Kt),Yt=Math.min(e.clientWidth/Kt.width,e.clientHeight/Kt.height),bn=Wp(Cn,bt),lt=[],mt=new Set,Nn=function(Re){var Zt;return!hn||hn.includes((Zt=Re.c.prototypeId)!==null&&Zt!==void 0?Zt:Re.c.id)},Ni=b.filter(Nn),bi=new Set(n.events.filter(function(Re){return Re.kind==="click"}).map(function(Re){return Re.componentId}));try{for(var xi=Be(n.gameplay),$n=xi.next();!$n.done;$n=xi.next()){var wi=$n.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(wi.kind)&&bi.add(wi.componentId)}}catch(Re){x={error:Re}}finally{try{$n&&!$n.done&&(I=xi.return)&&I.call(xi)}finally{if(x)throw x.error}}var pi=new Set(St??bi),ni=new Set(Qe(Qe([],Fe(n.gameplay.filter(function(Re){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(Re.kind)&&(Re.parameters.dragMode==="anywhere"||Re.kind==="draw-stroke"||Re.kind==="virtual-joystick"&&Re.parameters.mode==="floating")}).map(function(Re){return Re.componentId})),!1),Fe(n.components.filter(function(Re){return Re.contract==="native.stage3d.v1"}).map(function(Re){return Re.id})),!1)),Ri=function(Re){var Zt;return pi.has((Zt=Re.c.prototypeId)!==null&&Zt!==void 0?Zt:Re.c.id)},di=function(Re,Zt,dn,Yn,qi,Li){return lt.push(It(It({kind:Re,severity:Zt,id:dn},Li?{otherId:Li}:{}),{detail:Yn,metrics:qi}))},aa=function(Re){var Zt=[[0,0],[Re.width,0],[Re.width,Re.height],[0,Re.height]].map(function(dn){var Yn=Fe(dn,2),qi=Yn[0],Li=Yn[1];return ti(Re.matrix,qi,Li)});return{left:Math.min.apply(Math,Qe([],Fe(Zt.map(function(dn){return dn.x})),!1)),right:Math.max.apply(Math,Qe([],Fe(Zt.map(function(dn){return dn.x})),!1)),top:Math.min.apply(Math,Qe([],Fe(Zt.map(function(dn){return dn.y})),!1)),bottom:Math.max.apply(Math,Qe([],Fe(Zt.map(function(dn){return dn.y})),!1))}};try{for(var gr=Be(Ni),zi=gr.next();!zi.done;zi=gr.next()){var un=zi.value,an=(Ue=un.c.prototypeId)!==null&&Ue!==void 0?Ue:un.c.id;mt.add(an);var Ft=_r(un.c,un.m),Ei=((Oe=Vt(un.c).strokeWidth)!==null&&Oe!==void 0?Oe:0)/2;Ft.left-=Ei,Ft.right+=Ei,Ft.top-=Ei,Ft.bottom+=Ei;var Ai=un.c.contract==="native.group.v1"&&!Vt(un.c).clip,Yr=un.c.contract==="native.image.v1"&&un.clips.length===0&&Vt(un.c).fit==="cover"&&Ft.left<=0&&Ft.top<=0&&Ft.right>=Kt.width&&Ft.bottom>=Kt.height||un.c.contract==="native.stage3d.v1"&&Ft.left<=0&&Ft.top<=0&&Ft.right>=Kt.width&&Ft.bottom>=Kt.height,Qn=un.c.contract==="native.rectangle.v1"&&Ei===0&&Ft.left<=0&&Ft.top<=0&&Ft.right>=Kt.width&&Ft.bottom>=Kt.height||Yr;if(!Ai){var Hi={left:Math.max(0,Cn.left-Ft.left),right:Math.max(0,Ft.right-Cn.right),top:Math.max(0,Cn.top-Ft.top),bottom:Math.max(0,Ft.bottom-Cn.bottom)};if(!Qn&&!$p(un.c)&&Object.values(Hi).some(function(Re){return Re>.01})&&di("stage-overflow","blocker",an,"Component extends beyond the active stage.",{bounds:Ft,overflow:Hi}),un.c.contract==="native.image.v1"&&un.clips.length===0){var sa=Ft.right-Ft.left,Pa=Ft.bottom-Ft.top,$a=/(?:^|\.)(backdrop|background|bg)$/.test(an)||Vt(un.c).fit==="cover"&&!un.c.parentId&&Ft.left<=1&&Ft.top<=1&&(sa>=Kt.width*.4||Pa>=Kt.height*.4);$a&&(Ft.left>.5||Ft.top>.5||Ft.right<Kt.width-.5||Ft.bottom<Kt.height-.5)&&di("backdrop-incomplete","blocker",an,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:Ft,stage:{width:Kt.width,height:Kt.height}})}try{for(var qr=(F=void 0,Be(un.clips)),Mr=qr.next();!Mr.done;Mr=qr.next()){var xa=Mr.value,oa=aa(xa),La={left:Math.max(0,oa.left-Ft.left),right:Math.max(0,Ft.right-oa.right),top:Math.max(0,oa.top-Ft.top),bottom:Math.max(0,Ft.bottom-oa.bottom)};Object.values(La).some(function(Re){return Re>.01})&&di("parent-clip-crop","blocker",an,"Component is cropped by an ancestor clipping group.",{bounds:Ft,clip:oa,crop:La})}}catch(Re){F={error:Re}}finally{try{Mr&&!Mr.done&&(L=qr.return)&&L.call(qr)}finally{if(F)throw F.error}}}if(un.textMetrics){var nr=un.textMetrics;(nr.overflowsWidth||nr.overflowsHeight)&&di("text-overflow","blocker",an,"Text does not fit its component after wrapping and auto-fit.",nr);var Ui=(et=nr.fontSize)!==null&&et!==void 0?et:nr.scale*8;Ui<12&&di("text-illegible",Ui<8?"blocker":"warning",an,"Rendered text is below the recommended legible size.",It({renderedFontSize:Ui},nr));var Wi=Vt(un.c);if(Wi.pixelPanel&&Wi.align!=="center"){var _a=Math.max(0,Wi.width-2*(Wi.padding===void 0?8:Wi.padding));_a-((He=nr.renderedWidth)!==null&&He!==void 0?He:0)>12&&di("panel-off-center","blocker",an,"Text inside a framed pixel panel is not horizontally centered.",{align:Wi.align,innerWidth:_a,renderedWidth:(Je=nr.renderedWidth)!==null&&Je!==void 0?Je:0})}}if(Ri(un)&&!ni.has(an)&&(un.c.contract!=="native.group.v1"||Ft.right>Ft.left&&Ft.bottom>Ft.top)){var Fi=(Ft.right-Ft.left)*Yt,wn=(Ft.bottom-Ft.top)*Yt;(Fi<ot-.01||wn<ot-.01)&&di("touch-target-small","blocker",an,"Interactive target is smaller than the required physical touch size.",{width:Fi,height:wn,minTouchPx:ot,scale:Yt})}if(Ri(un)&&!ni.has(an)||un.c.contract==="native.text.v1")try{for(var Ma=(X=void 0,Be(bn.zones)),la=Ma.next();!la.done;la=Ma.next()){var Zr=la.value,Fi=Math.min(Ft.right,Zr.right)-Math.max(Ft.left,Zr.left),wn=Math.min(Ft.bottom,Zr.bottom)-Math.max(Ft.top,Zr.top);Fi>.01&&wn>.01&&di("sdk-safe-area-collision","blocker",an,"Component intersects a reserved ad-SDK overlay zone.",{bounds:Ft,zone:Zr,intersection:{width:Fi,height:wn},network:bt})}}catch(Re){X={error:Re}}finally{try{la&&!la.done&&(G=Ma.return)&&G.call(Ma)}finally{if(X)throw X.error}}}}catch(Re){E={error:Re}}finally{try{zi&&!zi.done&&(R=gr.return)&&R.call(gr)}finally{if(E)throw E.error}}for(var Xi=Ni.filter(function(Re){return Ri(Re)&&Re.c.contract!=="native.group.v1"&&Re.c.contract!=="native.stage3d.v1"}),mi=0;mi<Xi.length;mi++)for(var Xn=mi+1;Xn<Xi.length;Xn++){var _n=Xi[mi],Mn=Xi[Xn],dr=(wt=_n.c.prototypeId)!==null&&wt!==void 0?wt:_n.c.id,Pr=(kt=Mn.c.prototypeId)!==null&&kt!==void 0?kt:Mn.c.id;if(!(dr===Pr||Xr(_n.c,Mn.c.id)||Xr(Mn.c,_n.c.id))){var Sa=_r(_n.c,_n.m),ms=_r(Mn.c,Mn.m),Fi=Math.min(Sa.right,ms.right)-Math.max(Sa.left,ms.left),wn=Math.min(Sa.bottom,ms.bottom)-Math.max(Sa.top,ms.top);Fi>1&&wn>1&&di("interactive-overlap","blocker",dr,"Interactive targets overlap.",{intersection:{width:Fi,height:wn},first:Sa,second:ms},Pr)}}var wo=function(Re){if(!Re||Re==="transparent")return!1;var Zt=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(Re);if(Zt)return Zt[1].length===4?Zt[1][3].toLowerCase()==="f":Zt[1].slice(6).toLowerCase()==="ff";var dn=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(Re);return dn?Number(dn[1])>=.95:!0},qs=[];Ni.forEach(function(Re,Zt){var dn,Yn;Re.c.contract==="native.rectangle.v1"&&!Ri(Re)&&((dn=Vt(Re.c).opacity)!==null&&dn!==void 0?dn:1)>=.95&&wo(Vt(Re.c).fill)&&qs.push({rowIndex:Zt,row:Re,order:(Yn=Re.c.order)!==null&&Yn!==void 0?Yn:0,bounds:_r(Re.c,Re.m)})});var To=Ni.filter(function(Re,Zt){var dn,Yn=_r(Re.c,Re.m),qi=(dn=Re.c.order)!==null&&dn!==void 0?dn:0;return!qs.some(function(Li){return Li.rowIndex>Zt&&Li.order>qi&&Li.row.c.id!==Re.c.id&&!Xr(Li.row.c,Re.c.id)&&!Xr(Re.c,Li.row.c.id)&&Li.bounds.left<=Yn.left+1&&Li.bounds.right>=Yn.right-1&&Li.bounds.top<=Yn.top+1&&Li.bounds.bottom>=Yn.bottom-1})}),Eo=To.map(function(Re,Zt){return{row:Re,rowIndex:Zt}}).filter(function(Re){var Zt,dn=Re.row;if(dn.c.contract!=="native.rectangle.v1")return!1;var Yn=_r(dn.c,dn.m),qi=Yn.right-Yn.left,Li=Yn.bottom-Yn.top,Qa=((Zt=Vt(dn.c).strokeWidth)!==null&&Zt!==void 0?Zt:0)===0&&Yn.left<=0&&Yn.right>=Kt.width;return!Qa&&qi>=180&&Li>=140&&!Ri(dn)}).map(function(Re){var Zt,dn=Re.row,Yn=Re.rowIndex;return{id:(Zt=dn.c.prototypeId)!==null&&Zt!==void 0?Zt:dn.c.id,row:dn,rowIndex:Yn,bounds:_r(dn.c,dn.m)}}),Zs=function(Re,Zt,dn,Yn){var qi,Li;Yn===void 0&&(Yn=!1);var Qa=(qi=Re.c.prototypeId)!==null&&qi!==void 0?qi:Re.c.id,Fl=(dn.left+dn.right)/2,ja=(dn.top+dn.bottom)/2,Hf=(Li=Re.c.order)!==null&&Li!==void 0?Li:0;return Eo.filter(function(Mi){var es;return Mi.id!==Qa&&(!Yn||Mi.rowIndex<Zt||((es=Mi.row.c.order)!==null&&es!==void 0?es:0)===Hf)&&dn.right-dn.left<=Mi.bounds.right-Mi.bounds.left+4&&dn.bottom-dn.top<=Mi.bounds.bottom-Mi.bounds.top+4&&Fl>=Mi.bounds.left&&Fl<=Mi.bounds.right&&ja>=Mi.bounds.top&&ja<=Mi.bounds.bottom}).sort(function(Mi,es){return(Mi.bounds.right-Mi.bounds.left)*(Mi.bounds.bottom-Mi.bounds.top)-(es.bounds.right-es.bounds.left)*(es.bounds.bottom-es.bounds.top)||es.rowIndex-Mi.rowIndex})[0]},ca=new Map,sn=new Map;if(Eo.length){To.forEach(function(Re,Zt){var dn,Yn=(dn=Re.c.prototypeId)!==null&&dn!==void 0?dn:Re.c.id,qi=_r(Re.c,Re.m),Li=(qi.left+qi.right)/2,Qa=(qi.top+qi.bottom)/2,Fl=Re.c.contract==="native.button.v1"&&!Ct.has(Re.c.id),ja=Re.c.parentId?vt(Re.c.parentId):void 0,Hf=Re.c.contract==="native.text.v1"&&Vt(Re.c).align==="center"&&ja?.contract!=="native.button.v1";if(Fl||Hf){var Mi=Zs(Re,Zt,qi,!1);Mi&&(ca.has(Mi.id)||ca.set(Mi.id,{panel:Mi,items:[]}),ca.get(Mi.id).items.push({id:Yn,bounds:qi,cx:Li,cy:Qa,isBtn:Fl}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(Re.c.contract)&&ja?.contract!=="native.button.v1"){var Mi=Zs(Re,Zt,qi,!0);Mi&&(sn.has(Mi.id)||sn.set(Mi.id,{panel:Mi,content:[]}),sn.get(Mi.id).content.push({row:Re,id:Yn,bounds:qi}))}});try{for(var vi=Be(ca.values()),Yi=vi.next();!Yi.done;Yi=vi.next()){var Ji=Yi.value,Oi=Ji.panel,fr=Ji.items;if(fr.some(function(Re){return Re.isBtn})){var _i=Oi.bounds,Vi=(_i.left+_i.right)/2;try{for(var vs=(q=void 0,Be(fr)),Fr=vs.next();!Fr.done;Fr=vs.next()){var ua=Fr.value,Ka={left:ua.bounds.left-_i.left,right:_i.right-ua.bounds.right,top:ua.bounds.top-_i.top,bottom:_i.bottom-ua.bounds.bottom},Js=Math.min(Ka.left,Ka.right,Ka.top,Ka.bottom);(Js<10||Js*Yt<8)&&di("panel-edge-cramped","blocker",ua.id,"Element sits too close to its enclosing panel edge.",{panelId:Oi.id,margins:Ka,scale:Yt,minStagePx:10,minCssPx:8},Oi.id)}}catch(Re){q={error:Re}}finally{try{Fr&&!Fr.done&&(J=vs.return)&&J.call(vs)}finally{if(q)throw q.error}}var $s=[],$g=function(Re){var Zt=$s.find(function(dn){return Math.abs(dn.cy-Re.cy)<=16&&dn.isBtn===Re.isBtn});Zt?Zt.items.push(Re):$s.push({cy:Re.cy,isBtn:Re.isBtn,items:[Re]})};try{for(var eu=(te=void 0,Be(fr)),Rl=eu.next();!Rl.done;Rl=eu.next()){var ua=Rl.value;$g(ua)}}catch(Re){te={error:Re}}finally{try{Rl&&!Rl.done&&(j=eu.return)&&j.call(eu)}finally{if(te)throw te.error}}try{for(var tu=(ae=void 0,Be($s)),Pl=tu.next();!Pl.done;Pl=tu.next()){var Vf=Pl.value,Kg=Math.min.apply(Math,Qe([],Fe(Vf.items.map(function(Re){return Re.bounds.left})),!1)),Qg=Math.max.apply(Math,Qe([],Fe(Vf.items.map(function(Re){return Re.bounds.right})),!1)),am=(Kg+Qg)/2,sm=am-Vi;Math.abs(sm)>3&&di("panel-off-center","blocker",Vf.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:Oi.id,offsetX:sm,groupCenterX:am,panelCenterX:Vi,scale:Yt},Oi.id)}}catch(Re){ae={error:Re}}finally{try{Pl&&!Pl.done&&(fe=tu.return)&&fe.call(tu)}finally{if(ae)throw ae.error}}}}}catch(Re){K={error:Re}}finally{try{Yi&&!Yi.done&&(k=vi.return)&&k.call(vi)}finally{if(K)throw K.error}}try{for(var nu=Be(sn.values()),Ll=nu.next();!Ll.done;Ll=nu.next())for(var om=Ll.value,Oi=om.panel,iu=om.content,jg=ca.has(Oi.id),mi=0;mi<iu.length;mi++)for(var Xn=mi+1;Xn<iu.length;Xn++){var _n=iu[mi],Mn=iu[Xn];if(!(_n.id===Mn.id||Xr(_n.row.c,Mn.row.c.id)||Xr(Mn.row.c,_n.row.c.id))){var ey=_n.row.c.contract==="native.image.v1"&&Mn.row.c.contract==="native.image.v1";if(!(ey&&(!jg||_n.row.c.parentId&&_n.row.c.parentId===Mn.row.c.parentId))){var Fi=Math.min(_n.bounds.right,Mn.bounds.right)-Math.max(_n.bounds.left,Mn.bounds.left),wn=Math.min(_n.bounds.bottom,Mn.bounds.bottom)-Math.max(_n.bounds.top,Mn.bounds.top);Fi>2&&wn>2&&di("panel-content-overlap","blocker",_n.id,"Panel elements overlap each other.",{panelId:Oi.id,intersection:{width:Fi,height:wn},first:_n.bounds,second:Mn.bounds},Mn.id)}}}}catch(Re){Se={error:Re}}finally{try{Ll&&!Ll.done&&(xe=nu.return)&&xe.call(nu)}finally{if(Se)throw Se.error}}}var Ao=To.filter(function(Re){if(Re.c.contract!=="native.text.v1")return!1;var Zt=Re.c.parentId?vt(Re.c.parentId):void 0;return Zt?.contract!=="native.button.v1"}).map(function(Re){var Zt,dn,Yn=String((Zt=Vt(Re.c).text)!==null&&Zt!==void 0?Zt:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(qi,Li){var Qa;return String((Qa=H[Li])!==null&&Qa!==void 0?Qa:"")}).trim();return{row:Re,id:(dn=Re.c.prototypeId)!==null&&dn!==void 0?dn:Re.c.id,bounds:_r(Re.c,Re.m),raw:Yn,norm:Yn.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(Re){return Re.raw.length>0}),ty=Eo.filter(function(Re){var Zt,dn;return((Zt=ca.get(Re.id))===null||Zt===void 0?void 0:Zt.items.some(function(Yn){return Yn.isBtn}))||((dn=sn.get(Re.id))===null||dn===void 0?void 0:dn.content.some(function(Yn){return Yn.row.c.contract==="native.button.v1"}))});try{for(var ru=Be(ty),Dl=ru.next();!Dl.done;Dl=ru.next()){var Oi=Dl.value,_i=Oi.bounds,Vi=(_i.left+_i.right)/2,ny=_i.right-_i.left;try{for(var au=(we=void 0,Be(Ao)),Nl=au.next();!Nl.done;Nl=au.next()){var Da=Nl.value;if(Vt(Da.row.c).align==="center"&&!(Da.bounds.bottom>_i.top+6||_i.top-Da.bounds.bottom>48)){var lm=Da.bounds.right-Da.bounds.left,Ul=(Da.bounds.left+Da.bounds.right)/2,iy=Math.min(Da.bounds.right,_i.right)-Math.max(Da.bounds.left,_i.left);(Ul>=_i.left&&Ul<=_i.right||iy>=lm*.6)&&lm<=ny+60&&Math.abs(Ul-Vi)>4&&di("header-off-center","blocker",Da.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:Oi.id,offsetX:Ul-Vi,textCenterX:Ul,panelCenterX:Vi,scale:Yt},Oi.id)}}}catch(Yn){we={error:Yn}}finally{try{Nl&&!Nl.done&&(he=au.return)&&he.call(au)}finally{if(we)throw we.error}}}}catch(Re){Ie={error:Re}}finally{try{Dl&&!Dl.done&&(ye=ru.return)&&ye.call(ru)}finally{if(Ie)throw Ie.error}}for(var mi=0;mi<Ao.length;mi++)for(var Xn=mi+1;Xn<Ao.length;Xn++){var _n=Ao[mi],Mn=Ao[Xn];if(!(_n.id===Mn.id||Xr(_n.row.c,Mn.row.c.id)||Xr(Mn.row.c,_n.row.c.id))){var Fi=Math.min(_n.bounds.right,Mn.bounds.right)-Math.max(_n.bounds.left,Mn.bounds.left),wn=Math.min(_n.bounds.bottom,Mn.bounds.bottom)-Math.max(_n.bounds.top,Mn.bounds.top);if(Fi>2&&wn>2&&di("panel-content-overlap","blocker",_n.id,"Visible text elements overlap.",{intersection:{width:Fi,height:wn},first:_n.bounds,second:Mn.bounds},Mn.id),_n.norm&&Mn.norm){var cm=Fe(_n.norm.length<=Mn.norm.length?[_n.norm,Mn.norm]:[Mn.norm,_n.norm],2),su=cm[0],um=cm[1];(su===um&&su.length>=6||su.length>=12&&um.includes(su))&&di("duplicate-visible-copy","blocker",_n.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:_n.raw,second:Mn.raw},Mn.id)}}}var Na=Ao.filter(function(Re){return!/^[\d\s/.,:%+\-x]+$/i.test(Re.raw)}),ou=Na.reduce(function(Re,Zt){return Re+(Zt.norm?Zt.norm.split(" ").filter(Boolean).length:0)},0),Gf=Na.reduce(function(Re,Zt){return Re+Zt.raw.replace(/\s+/g," ").length},0);ou>20||Gf>130||Na.length>5?di("text-clutter-heavy","blocker",(Xt=(en=Na[0])===null||en===void 0?void 0:en.id)!==null&&Xt!==void 0?Xt:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:Na.length,wordCount:ou,charCount:Gf,texts:Na.map(function(Re){return Re.raw})}):(ou>12||Na.length>4)&&di("text-clutter-heavy","warning",(Et=(Ht=Na[0])===null||Ht===void 0?void 0:Ht.id)!==null&&Et!==void 0?Et:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:Na.length,wordCount:ou,charCount:Gf,texts:Na.map(function(Re){return Re.raw})});var dm=hn?hn.filter(function(Re){if(mt.has(Re))return!1;var Zt=vt(Re);return Zt?.contract==="native.mesh3d.v1"?!1:!Zt||hi(Zt)}):[];return{ok:!lt.some(function(Re){return Re.severity==="blocker"})&&dm.length===0,viewport:It(It({},Kt),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight,scale:Yt}),defects:lt,missing:dm,interactive:Xi.map(function(Re){var Zt;return{id:(Zt=Re.c.prototypeId)!==null&&Zt!==void 0?Zt:Re.c.id,bounds:_r(Re.c,Re.m)}}),safeArea:bn}}function Xr(c,x){for(;c.parentId;){if(c.parentId===x)return!0;c=vt(c.parentId)}return!1}function $p(c){for(var x=function(R){if(n.gameplay.some(function(F){var L;return F.kind==="camera-follow"&&F.componentId===((L=R.prototypeId)!==null&&L!==void 0?L:R.id)}))return{value:!0}},I=c;I;I=I.parentId?vt(I.parentId):void 0){var E=x(I);if(typeof E=="object")return E.value}return!1}function Nf(c){var x=T(),I=e.getBoundingClientRect(),E=Math.min(I.width/x.width,I.height/x.height);return{x:(c.clientX-I.left-(I.width-x.width*E)/2)/E,y:(c.clientY-I.top-(I.height-x.height*E)/2)/E}}function Vg(c,x){var I,E,R,F;try{if(c.c.contract==="native.stage3d.v1"&&En.has(c.c.id)&&ui)return x.x>=ui.x&&x.y>=ui.y&&x.x<=ui.x+ui.w&&x.y<=ui.y+ui.h;try{for(var L=Be(c.clips),X=L.next();!X.done;X=L.next()){var G=X.value,K=ti(Or(G.matrix),x.x,x.y);if(K.x<0||K.y<0||K.x>G.width||K.y>G.height)return!1}}catch(ye){I={error:ye}}finally{try{X&&!X.done&&(E=L.return)&&E.call(L)}finally{if(I)throw I.error}}var k=ti(Or(c.m),x.x,x.y),q=Vt(c.c);if(c.c.contract==="native.path.v1"){var J=new Path2D,te=function(ye,we){({M:function(){return J.moveTo.apply(J,Qe([],Fe(we),!1))},L:function(){return J.lineTo.apply(J,Qe([],Fe(we),!1))},C:function(){return J.bezierCurveTo.apply(J,Qe([],Fe(we),!1))},Q:function(){return J.quadraticCurveTo.apply(J,Qe([],Fe(we),!1))},Z:function(){return J.closePath()}})[ye]()};try{for(var j=Be(q.commands),ae=j.next();!ae.done;ae=j.next()){var fe=Fe(ae.value),Se=fe[0],xe=fe.slice(1);te(Se,xe)}}catch(ye){R={error:ye}}finally{try{ae&&!ae.done&&(F=j.return)&&F.call(j)}finally{if(R)throw R.error}}p.save(),p.setTransform(1,0,0,1,0,0),p.lineWidth=q.strokeWidth;var Ie=p.isPointInPath(J,k.x,k.y)||q.strokeWidth>0&&p.isPointInStroke(J,k.x,k.y);return p.restore(),Ie}return c.c.contract==="native.ellipse.v1"?Math.pow((k.x-q.width/2)/(q.width/2),2)+Math.pow((k.y-q.height/2)/(q.height/2),2)<=1:k.x>=0&&k.y>=0&&k.x<=q.width&&k.y<=q.height}catch{return!1}}function Kc(c){return Qe([],Fe(b),!1).reverse().find(function(x){return x.c.contract!=="native.group.v1"&&x.c.sceneId===U&&vt(x.c.id)&&hi(x.c)&&Vg(x,c)})}function Qc(c){for(var x=[];c;)x.push(c),c=vt(c.parentId);return x}function Uf(){if(!de)return{vx:0,vy:0,power:0,pull:0};var c=de.behavior.parameters,x=de.current.x-de.start.x,I=de.current.y-de.start.y,E=Math.hypot(x,I),R=Math.max(0,Math.min(1,(E-c.minPullPx)/Math.max(1,c.maxPullPx-c.minPullPx))),F=c.minSpeed+(c.maxSpeed-c.minSpeed)*R,L=c.invert?-1:1;return{vx:E?x/E*F*L:0,vy:E?I/E*F*L:0,power:R,pull:E}}function Kp(c){if(de){de.current=c;var x=Uf();de.power=x.power,de.behavior.parameters.powerVariableId&&(H[de.behavior.parameters.powerVariableId]=x.power)}}function Ff(c){var x,I;c===void 0&&(c=!1);try{var E=(x=globalThis.AudioContext)!==null&&x!==void 0?x:globalThis.webkitAudioContext;E&&!ke&&(ke=new E,(I=ke.addEventListener)===null||I===void 0||I.call(ke,"statechange",function(){ke?.state==="running"&&Il()})),Ws(c)}catch{}}function Gg(c,x,I){var E,R,F,L,X,G,K=function(we){var he=I.find(function(et){var He;return((He=et.prototypeId)!==null&&He!==void 0?He:et.id)===we.componentId});if(!he)return"continue";var Ue=ti(Or(ri(he)),x.x,x.y),Oe=va(he,we);return Oe.stampSegment(Ue,Ue),ut={kind:"mask",pointerId:c.pointerId,c:he,behavior:we,last:Ue},(X=e.setPointerCapture)===null||X===void 0||X.call(e,c.pointerId),{value:!0}};try{for(var k=Be(n.gameplay.filter(function(we){var he;return we.kind==="erase-mask"&&((he=_.get(we.componentId))===null||he===void 0?void 0:he.sceneId)===U})),q=k.next();!q.done;q=k.next()){var J=q.value,te=K(J);if(typeof te=="object")return te.value}}catch(we){E={error:we}}finally{try{q&&!q.done&&(R=k.return)&&R.call(k)}finally{if(E)throw E.error}}if(I.some(function(we){return we.contract==="native.button.v1"||n.events.some(function(he){var Ue;return he.kind==="click"&&he.componentId===((Ue=we.prototypeId)!==null&&Ue!==void 0?Ue:we.id)})}))return!1;try{for(var j=Be(n.gameplay.filter(function(we){var he;return we.kind==="draw-stroke"&&((he=_.get(we.componentId))===null||he===void 0?void 0:he.sceneId)===U})),ae=j.next();!ae.done;ae=j.next()){var J=ae.value,fe=_.get(J.componentId),Se=Or(ri(fe)),xe=ti(Se,x.x,x.y),Ie=Vt(fe);if(!(xe.x<0||xe.y<0||xe.x>Ie.width||xe.y>Ie.height)){var ye=wf(J);return ye.begin(x),ut={kind:"stroke",pointerId:c.pointerId,c:fe,behavior:J,store:ye,last:x},In({kind:"strokeStart",componentId:fe.id}),(G=e.setPointerCapture)===null||G===void 0||G.call(e,c.pointerId),!0}}}catch(we){F={error:we}}finally{try{ae&&!ae.done&&(L=j.return)&&L.call(j)}finally{if(F)throw F.error}}return!1}function Hg(c,x,I){var E,R,F,L,X,G,K,k=I.store.active;if(k){try{for(var q=Be(n.gameplay.filter(function(Oe){var et;return Oe.kind==="collider"&&((et=_.get(Oe.componentId))===null||et===void 0?void 0:et.sceneId)===U})),J=q.next();!J.done;J=q.next()){var te=J.value,j=_.get(te.componentId);try{for(var ae=(F=void 0,Be(Ii(j))),fe=ae.next();!fe.done;fe=ae.next()){var Se=fe.value;!hi(Se)||k.hitIds.has(Se.id)||Em(c,x,Jp(Se,te.parameters.shape))&&(k.hitIds.add(Se.id),In(tr("sliceHit",Se)))}}catch(Oe){F={error:Oe}}finally{try{fe&&!fe.done&&(L=ae.return)&&L.call(ae)}finally{if(F)throw F.error}}}}catch(Oe){E={error:Oe}}finally{try{J&&!J.done&&(R=q.return)&&R.call(q)}finally{if(E)throw E.error}}try{for(var xe=Be(Nt),Ie=xe.next();!Ie.done;Ie=xe.next()){var ye=Ie.value;if(!(ye.broken||!ye.breakable||k.hitIds.has(ye.key))){var we=Pn.get(ye.bodyId),he=vt(ye.anchorId);if(!(!we||!he)){var Ue=Ci(he);$f(c,x,{x:Ue.x,y:Ue.y},{x:we.x,y:we.y})&&(k.hitIds.add(ye.key),ye.broken=!0,C.add(ye.key),In({kind:"jointBreak",behaviorId:ye.id,componentId:ye.componentId,selfInstanceId:ye.bodyId,instanceId:(K=vt(ye.bodyId))===null||K===void 0?void 0:K.instanceId}))}}}}catch(Oe){X={error:Oe}}finally{try{Ie&&!Ie.done&&(G=xe.return)&&G.call(xe)}finally{if(X)throw X.error}}}}function Wg(c,x){var I,E=x.last,R=x.behavior.parameters;if(R.inkVariableId){var F=R.inkVariableId,L=Math.hypot(c.x-E.x,c.y-E.y);if(((I=H[F])!==null&&I!==void 0?I:0)<L)return;H[F]-=L}x.store.add(c)&&(R.mode==="slice-blade"&&Hg(E,c,x),x.last=c)}function Xg(c){var x,I;if(!(!ut||ut.pointerId!==c.pointerId)){var E=ut;ut=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((I=e.releasePointerCapture)===null||I===void 0||I.call(e,c.pointerId))}catch{}if(E.kind==="stroke"){var R=E.store.end(),F=E.behavior.parameters;if(R){if(F.mode==="physics-wall"){var L=new Set(E.store.strokes.map(function(G){return G.id}));Lt=Lt.filter(function(G){return G.owner!==E.c.id||L.has(G.strokeId)}),Lt.push.apply(Lt,Qe([],Fe(Im(R,F.strokeWidth).map(function(G){return It(It({},G),{owner:E.c.id})})),!1))}else if(F.mode==="path-trace"){var X=vt(F.followComponentId);X&&R.points.length>1&&ii.set(X.id,{points:R.points,index:1,speed:F.followSpeed})}}In({kind:"strokeEnd",componentId:E.c.id})}}}function Yg(c){var x,I,E,R;try{for(var F=Be(kn.values()),L=F.next();!L.done;L=F.next()){var X=L.value;X.tick(c)}}catch(ye){x={error:ye}}finally{try{L&&!L.done&&(I=F.return)&&I.call(F)}finally{if(x)throw x.error}}try{for(var G=Be(ii),K=G.next();!K.done;K=G.next()){var k=Fe(K.value,2),q=k[0],J=k[1],te=vt(q);if(!te){ii.delete(q);continue}var j=J.points[J.index];if(!j){ii.delete(q),In(tr("pathArrive",te));continue}var ae=Ci(te),fe=j.x-ae.x,Se=j.y-ae.y,xe=Math.hypot(fe,Se),Ie=J.speed*c;xe<=Ie?(Rr(te,j.x,j.y),J.index++):xe>.001&&Rr(te,ae.x+fe/xe*Ie,ae.y+Se/xe*Ie)}}catch(ye){E={error:ye}}finally{try{K&&!K.done&&(R=G.return)&&R.call(G)}finally{if(E)throw E.error}}}function qg(c,x,I){var E,R,F=[],L=[],X=function(q){var J=_.get(q.componentId),te=q.parameters.dragMode==="anywhere"?Ii(J).find(function(fe){return hi(fe)}):I.find(function(fe){var Se;return((Se=fe.prototypeId)!==null&&Se!==void 0?Se:fe.id)===J.id});if(!te)return"continue";if(q.kind==="swipe-input")L.push({behavior:q,c:te});else{var j=q.parameters,ae=Math.max(j.min,Math.min(j.max,Number(H[j.variableId])));H[j.variableId]=ae,F.push({behavior:q,c:te,charge:ym(j,ae)}),In(tr("holdStart",te))}};try{for(var G=Be(n.gameplay.filter(function(q){var J;return["swipe-input","hold-charge"].includes(q.kind)&&((J=_.get(q.componentId))===null||J===void 0?void 0:J.sceneId)===U})),K=G.next();!K.done;K=G.next()){var k=K.value;X(k)}}catch(q){E={error:q}}finally{try{K&&!K.done&&(R=G.return)&&R.call(G)}finally{if(E)throw E.error}}(F.length||L.length)&&(Ze={pointerId:c.pointerId,start:x,current:x,holds:F,swipes:L})}function Zg(c,x){var I,E,R,F,L,X,G,K;if(!(!Ze||Ze.pointerId!==c.pointerId)){var k=Ze,q=new Set;Ze=void 0;try{for(var J=Be(Qe(Qe([],Fe(k.holds),!1),Fe(k.swipes),!1)),te=J.next();!te.done;te=J.next()){var j=te.value,ae=j.behavior,fe=j.c;q.has(ae.componentId)||(q.add(ae.componentId),In(tr("pointerUp",fe,void 0,{targetId:fe.id,pointerId:c.pointerId})))}}catch(He){I={error:He}}finally{try{te&&!te.done&&(E=J.return)&&E.call(J)}finally{if(I)throw I.error}}try{for(var Se=Be(k.holds),xe=Se.next();!xe.done;xe=Se.next()){var Ie=xe.value,ye=Ie.behavior.parameters;if(In(tr("holdRelease",Ie.c)),ye.resetOnRelease!==!1){var we=H[ye.variableId];H[ye.variableId]=ye.min,we!==ye.min&&In({kind:"variableChange",variableId:ye.variableId,selfInstanceId:(G=Ie.c.instanceId)!==null&&G!==void 0?G:Ie.c.id,instanceId:Ie.c.instanceId})}}}catch(He){R={error:He}}finally{try{xe&&!xe.done&&(F=Se.return)&&F.call(Se)}finally{if(R)throw R.error}}try{for(var he=Be(k.swipes),Ue=he.next();!Ue.done;Ue=he.next()){var Oe=Ue.value,et=gm(k.start,x,Oe.behavior.parameters.minDistancePx,(K=si.get(Oe.behavior.id))!==null&&K!==void 0?K:-1/0,Q*1e3,Oe.behavior.parameters.cooldownMs);et&&(si.set(Oe.behavior.id,Q*1e3),In(tr("swipe",Oe.c,void 0,{direction:et})))}}catch(He){L={error:He}}finally{try{Ue&&!Ue.done&&(X=he.return)&&X.call(he)}finally{if(L)throw L.error}}return q}}function Jg(c,x,I){var E,R,F;if(I.some(function(ae){return ae.contract==="native.button.v1"&&Vt(ae).enabled}))return!1;try{for(var L=Be(n.gameplay.filter(function(ae){var fe;return ae.kind==="virtual-joystick"&&((fe=_.get(ae.componentId))===null||fe===void 0?void 0:fe.sceneId)===U})),X=L.next();!X.done;X=L.next()){var G=X.value,K=_.get(G.componentId);if(hi(K)){var k=re.get(G.id);if(!(k&&k.pointerId!==null)){var q=ti(Or(ri(K)),x.x,x.y),J=Vt(K);if(!(q.x<0||q.y<0||q.x>J.width||q.y>J.height)){var te=G.parameters.mode==="floating"?It({},x):Ci(K),j=Zf(te,x,G.parameters.radiusPx,G.parameters.deadZone);return k=It({behavior:G,c:K,pointerId:c.pointerId,origin:te,current:x},j),re.set(G.id,k),Bn(k),In(tr("joystickStart",K)),(F=e.setPointerCapture)===null||F===void 0||F.call(e,c.pointerId),!0}}}}}catch(ae){E={error:ae}}finally{try{X&&!X.done&&(R=L.return)&&R.call(L)}finally{if(E)throw E.error}}return!1}var Qp=function(c){var x,I,E,R,F,L,X,G,K,k,q,J,te;S();var j=Nf(c),ae=Kc(j);if(it=j,!(!ae&&f)){if(f){ae&&(Z=ae.c.id,M((F=ae.c.prototypeId)!==null&&F!==void 0?F:ae.c.id));return}var fe=n.gameplay.some(function(lt){return lt.kind==="virtual-joystick"||lt.kind==="fps-controller-3d"});if(!(!c.isTrusted||c.button!==void 0&&c.button!==0||!fe&&c.isPrimary===!1||Xe||je||!fe&&(Ke&&Ke.pointerId!==c.pointerId||Ze&&Ze.pointerId!==c.pointerId||de&&de.pointerId!==c.pointerId||xt&&xt.pointerId!==c.pointerId)||P&&(!gt||!ct))){var Se=!nt;$e=Q,Ce=!0,nt=!0,Ff(!0),Se&&!Ye&&(tt=Ge=0,ya());var xe=ae?Qc(ae.c):[];if(Jg(c,j,xe)){tt=Ge=0,Ye=!1,ya(),Zi();return}if(Gg(c,j,xe)){ya(),Zi();return}qg(c,j,xe);var Ie=We&&!xe.some(function(lt){return lt.contract==="native.button.v1"})?n.gameplay.find(function(lt){var mt;return lt.kind==="aim-launch-3d"&&((mt=_.get(lt.componentId))===null||mt===void 0?void 0:mt.sceneId)===U}):void 0;if(Ie){var ye=_.get(Ie.componentId),we=pn("physics-3d",ye.id),he=we?Tl(ye,we):void 0,Ue=Hs(ye.id),Oe=Ie.parameters.dragMode==="anywhere"||Ue&&Math.hypot(j.x-Ue.x,j.y-Ue.y)<=Ie.parameters.hitRadiusPx;if(he&&he.atRest&&!he.captured&&Oe){xt={behavior:Ie,targetId:ye.id,sourceId:ye.id,stageId:Ie.parameters.stageId,pointerId:c.pointerId,start:j,current:j,power:0},So(j),(L=e.setPointerCapture)===null||L===void 0||L.call(e,c.pointerId);return}}var et=xe.some(function(lt){return lt.contract==="native.button.v1"&&Vt(lt).enabled}),He=et||xe.some(function(lt){return n.events.some(function(mt){var Nn;return mt.kind==="click"&&mt.componentId===((Nn=lt.prototypeId)!==null&&Nn!==void 0?Nn:lt.id)})});if(We&&!et){var Je=n.gameplay.find(function(lt){var mt;return lt.kind==="fps-controller-3d"&&((mt=_.get(lt.componentId))===null||mt===void 0?void 0:mt.sceneId)===U});if(Je){var wt=_.get(Je.componentId),kt=ti(Or(ri(wt)),j.x,j.y),en=Vt(wt);if(En.has(wt.id)||kt.x>=0&&kt.y>=0&&kt.x<=en.width&&kt.y<=en.height){var Xt=n.events.some(function(lt){return lt.kind==="click"&<.componentId===wt.id});if(!An&&Je.parameters.lookMode!=="none"&&(_o(Je),An={pointerId:c.pointerId,stageId:wt.id,behavior:Je,last:j},(X=e.setPointerCapture)===null||X===void 0||X.call(e,c.pointerId)),Xt){tt=Ge=0,Ye=!1,In({kind:"click",componentId:wt.id,targetId:wt.id,pointerId:c.pointerId}),ya(),Zi();return}if(!He)return}}}var Ht=n.gameplay.find(function(lt){return lt.kind==="aim-launch"&&_.get(lt.componentId).sceneId===U&&(lt.parameters.dragMode==="anywhere"&&!xe.some(function(mt){return mt.contract==="native.button.v1"})||xe.some(function(mt){var Nn;return((Nn=mt.prototypeId)!==null&&Nn!==void 0?Nn:mt.id)===lt.componentId}))});if(Ht){var Et=_.get(Ht.componentId),Mt=(G=xe.find(function(mt){var Nn;return((Nn=mt.prototypeId)!==null&&Nn!==void 0?Nn:mt.id)===Et.id}))!==null&&G!==void 0?G:Ii(Et).find(function(mt){return hi(mt)}),he=Mt&&ra(Mt,pn("physics-body",Et.id));if(he&&(!Ht.parameters.onlyWhenAtRest||he.atRest)){de={behavior:Ht,targetId:Mt.id,sourceId:Et.id,pointerId:c.pointerId,start:j,current:j,power:0},Kp(j),(K=e.setPointerCapture)===null||K===void 0||K.call(e,c.pointerId),Zi();return}}try{for(var At=Be(xe),St=At.next();!St.done;St=At.next()){var pt=St.value,bt=pn("press-feedback",(k=pt.prototypeId)!==null&&k!==void 0?k:pt.id);bt&&(pt.contract!=="native.button.v1"||Vt(pt).enabled)&&rt.set(pt.id,{behavior:bt.parameters,pointerId:c.pointerId,held:!0})}}catch(lt){x={error:lt}}finally{try{St&&!St.done&&(I=At.return)&&I.call(At)}finally{if(x)throw x.error}}var Qt=xe.find(function(lt){var mt;return((mt=Ct.get(lt.id))===null||mt===void 0?void 0:mt.sceneId)===U});if(Qt){var ot=nn.get(Qt.parentId);if(ot?.snapshot().busy)return;wg(Qt),ot&&!ot.snapshot().busy&&(Ut={pointerId:c.pointerId,boardId:Qt.parentId,tileId:Qt.id,start:j},(q=e.setPointerCapture)===null||q===void 0||q.call(e,c.pointerId))}Pt=(J=xe.find(function(lt){return lt.contract==="native.button.v1"&&Vt(lt).enabled}))===null||J===void 0?void 0:J.id,tn=Pt?c.pointerId:void 0;var hn=n.gameplay.find(function(lt){return lt.kind==="drag"&&xe.some(function(mt){var Nn;return((Nn=mt.prototypeId)!==null&&Nn!==void 0?Nn:mt.id)===lt.componentId})});if(hn){var pt=xe.find(function(mt){var Nn;return((Nn=mt.prototypeId)!==null&&Nn!==void 0?Nn:mt.id)===hn.componentId}),Kt=Ci(pt),Cn=fn.zoneOf(pt.id);Dn.set(pt.id,Kt),fn.release(pt.id),Ke={b:hn,targetId:pt.id,start:j,current:j,origin:Kt,originZone:Cn,m:Qe([],Fe(zn(pt)),!1),pointerId:c.pointerId},In(tr("dragStart",pt)),e.setPointerCapture(c.pointerId)}tt=Ge=0,Ye=!1;try{for(var Yt=Be(xe),bn=Yt.next();!bn.done;bn=Yt.next()){var pt=bn.value;(pt.contract!=="native.button.v1"||Vt(pt).enabled)&&In({kind:"click",componentId:(te=pt.prototypeId)!==null&&te!==void 0?te:pt.id,instanceId:pt.instanceId,targetId:pt.id,pointerId:c.pointerId})}}catch(lt){E={error:lt}}finally{try{bn&&!bn.done&&(R=Yt.return)&&R.call(Yt)}finally{if(E)throw E.error}}ya(),Zi()}}};function jp(c,x){if(!Ut||Ut.pointerId!==c.pointerId)return!1;if(!c.isTrusted||!xr())return!0;var I=Ut,E=nn.get(I.boardId);if(E.snapshot().busy)return Ut=void 0,!0;var R=Or(ri(_.get(I.boardId))),F=ti(R,I.start.x,I.start.y),L=ti(R,x.x,x.y),X=L.x-F.x,G=L.y-F.y,K=_.get(I.tileId);if(Math.max(Math.abs(X),Math.abs(G))<Math.min(K.parameters.width,K.parameters.height)*.35)return!0;var k=Ct.get(K.id),q=Math.abs(X)>Math.abs(G),J=k.row+(q?0:Math.sign(G)),te=k.column+(q?Math.sign(X):0),j=Qe([],Fe(Ct),!1).find(function(ae){var fe=Fe(ae,2),Se=fe[1];return Se.boardId===I.boardId&&Se.row===J&&Se.column===te});return j&&E.swap(K.id,j[0])&&(Wt=void 0,Zi()),Ut=void 0,!0}var em=function(c){var x,I,E,R;if(!Xe){S();var F=T(),L=Nf(c);it=L,Ze?.pointerId===c.pointerId&&(Ze.current=L);var X=function(Et){var Mt,At;if(Et.pointerId===c.pointerId){var St=L.x-Et.current.x,pt=L.y-Et.current.y;if(c.isTrusted&&xr())try{for(var bt=(Mt=void 0,Be(n.gameplay.filter(function(hn){var Kt,Cn;return hn.kind==="fps-controller-3d"&&hn.parameters.aimJoystickBehaviorId===Et.behavior.id&&((Kt=hn.parameters.aimMode)!==null&&Kt!==void 0?Kt:"delta")==="delta"&&((Cn=_.get(hn.componentId))===null||Cn===void 0?void 0:Cn.sceneId)===U}))),Qt=bt.next();!Qt.done;Qt=bt.next()){var ot=Qt.value;Vs(ot,St,pt)}}catch(hn){Mt={error:hn}}finally{try{Qt&&!Qt.done&&(At=bt.return)&&At.call(bt)}finally{if(Mt)throw Mt.error}}return Object.assign(Et,{current:L},Zf(Et.origin,L,Et.behavior.parameters.radiusPx,Et.behavior.parameters.deadZone)),Bn(Et),Zi(),{value:void 0}}};try{for(var G=Be(re.values()),K=G.next();!K.done;K=G.next()){var k=K.value,q=X(k);if(typeof q=="object")return q.value}}catch(Et){x={error:Et}}finally{try{K&&!K.done&&(I=G.return)&&I.call(G)}finally{if(x)throw x.error}}if(ut?.pointerId===c.pointerId){if(ut.kind==="mask"){var J=ut,te=ti(Or(ri(J.c)),L.x,L.y);va(J.c,J.behavior).stampSegment(J.last,te),J.last=te}else Wg(L,ut);ya(),Zi();return}if(An?.pointerId===c.pointerId){c.isTrusted&&xr()&&(Vs(An.behavior,L.x-An.last.x,L.y-An.last.y),An.last=L,Zi());return}if(xt?.pointerId===c.pointerId){c.isTrusted&&xr()&&So(L);return}if(de?.pointerId===c.pointerId){c.isTrusted&&xr()&&Kp(L),Zi();return}var j=Kc(L);if(jt=j?(E=Qc(j.c).find(function(Et){return Et.contract==="native.button.v1"}))===null||E===void 0?void 0:E.id:void 0,!jp(c,L)&&!(!Ke||Ke.pointerId!==c.pointerId)){var ae=vt(Ke.targetId);if(!ae){ki();return}var fe=ae.parentId?ri(vt(ae.parentId)):Ua(),Se=Or(fe),xe=ti(Se,Ke.start.x,Ke.start.y),Ie=ti(Se,L.x,L.y),ye=Qe([],Fe(Ke.m),!1),we=Ke.b.parameters.axis;if(we!=="y"){var he=Ke.m[4]+Ie.x-xe.x;Number.isFinite(Ke.b.parameters.minX)&&(he=Math.max(Ke.b.parameters.minX,he)),Number.isFinite(Ke.b.parameters.maxX)&&(he=Math.min(Ke.b.parameters.maxX,he)),ye[4]=he}if(we!=="x"){var Ue=Ke.m[5]+Ie.y-xe.y;Number.isFinite(Ke.b.parameters.minY)&&(Ue=Math.max(Ke.b.parameters.minY,Ue)),Number.isFinite(Ke.b.parameters.maxY)&&(Ue=Math.min(Ke.b.parameters.maxY,Ue)),ye[5]=Ue}if(!ae.parentId)we!=="y"&&(ye[4]=Math.max(0,Math.min(F.width-ae.parameters.width,ye[4])));else{var Oe=_r(ae,Io(fe,ye)),et=0;Oe.left<0||Oe.right-Oe.left>F.width?et=-Oe.left:Oe.right>F.width&&(et=F.width-Oe.right);var He=we==="y"?0:fe[0],Je=we==="x"?0:fe[2];Math.abs(He)>=Math.abs(Je)&&Math.abs(He)>1e-8?ye[4]+=et/He:Math.abs(Je)>1e-8&&(ye[5]+=et/Je)}var wt=(R=qe.get(ae.id))!==null&&R!==void 0?R:{parameters:{}};qe.set(ae.id,It(It({},wt),{transform:ye})),Ke.current=L;var kt=If(ae),en=kt.zones,Xt=kt.tag,Ht=cu({itemId:ae.id,tag:Xt,zones:en,occupancy:fn});yt=Ht&&Ht.kind!=="reject"?Ht.zone:void 0}}},tm=function(c){var x,I,E,R,F;S();var L=Nf(c),X=ee;it=L,Zn(c.pointerId,!0),Qi(c.pointerId),Xg(c);var G=(E=Zg(c,L))!==null&&E!==void 0?E:new Set;if(Tg(c),c.isTrusted&&xr()){var K=Kc(L);try{for(var k=Be(K?Qc(K.c):[]),q=k.next();!q.done;q=k.next()){var J=q.value;!G.has((R=J.prototypeId)!==null&&R!==void 0?R:J.id)&&(J.contract!=="native.button.v1"||Vt(J).enabled)&&In(tr("pointerUp",J,void 0,{targetId:J.id,pointerId:c.pointerId}))}}catch(xe){x={error:xe}}finally{try{q&&!q.done&&(I=k.return)&&I.call(k)}finally{if(x)throw x.error}}}if(ya(),Zi(),xt?.pointerId===c.pointerId){var te=xt,j=Mo(),ae=Rt.get(te.targetId);(F=We?.getStage(_.get(te.stageId)))===null||F===void 0||F.setGuide([]),xt=void 0,te.behavior.parameters.powerVariableId&&(H[te.behavior.parameters.powerVariableId]=0);var fe=Math.hypot(j.vx,j.vz);c.isTrusted&&Ff(!0),ae&&c.isTrusted&&xr()&&j.pull>=te.behavior.parameters.minPullPx&&fe>=te.behavior.parameters.minSpeed&&(ae.vx=j.vx,ae.vy=0,ae.vz=j.vz,ae.atRest=!1,ae.restElapsed=0,ae.movingTime=0,ae.captured=!1,ae.lastSafe={x:ae.x,y:ae.y,z:ae.z},In({kind:"launch",componentId:te.sourceId})),Jn(c),ya();return}if(de?.pointerId===c.pointerId){var te=de,j=Uf(),ae=Pn.get(te.targetId);de=void 0,te.behavior.parameters.powerVariableId&&(H[te.behavior.parameters.powerVariableId]=0),ae&&c.isTrusted&&xr()&&j.pull>=te.behavior.parameters.minPullPx&&(ae.vx=j.vx,ae.vy=j.vy,ae.atRest=!1,ae.restElapsed=0,ae.captured=!1,ae.exited=!1,In({kind:"launch",componentId:te.sourceId,instanceId:ae.instanceId})),Jn(c),ya(),Zi();return}if(jp(c,L),Ut?.pointerId===c.pointerId&&(Ut=void 0),Jn(c),!(X?.pointerId!==c.pointerId||!c.isTrusted||!xr()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!Us(X.condition))){var Se=Kc(L);!Se||!Qc(Se.c).some(function(xe){return xe.id===X.targetId&&(xe.contract!=="native.button.v1"||Vt(xe).enabled)})||(P?P.openStore(n.base.storeUrl):window.open(n.base.storeUrl,"_blank","noopener"))}},jc=function(c){var x,I;if(xt?.pointerId===c.pointerId&&Gi(c.pointerId),An?.pointerId===c.pointerId&&Qi(c.pointerId),Zn(c.pointerId,!0),de?.pointerId===c.pointerId&&(de.behavior.parameters.powerVariableId&&(H[de.behavior.parameters.powerVariableId]=0),de=void 0),Ut?.pointerId===c.pointerId&&(Ut=void 0),ut?.pointerId===c.pointerId&&(ut.kind==="stroke"&&ut.store.cancel(),ut=void 0),Ze?.pointerId===c.pointerId){try{for(var E=Be(Ze.holds),R=E.next();!R.done;R=E.next()){var F=R.value;F.behavior.parameters.resetOnRelease!==!1&&(H[F.behavior.parameters.variableId]=F.behavior.parameters.min)}}catch(L){x={error:L}}finally{try{R&&!R.done&&(I=E.return)&&I.call(E)}finally{if(x)throw x.error}}Ze=void 0}Jn(c)},nm=function(c){c?.isTrusted&&!f&&!Xe&&!je&&Ff(!0)},Of=function(){Dt||Zi()},ps=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver(Of):void 0;try{(s=ps?.observe)===null||s===void 0||s.call(ps,e)}catch{}var im=function(){Le=0,Ee=0,document.hidden&&er(),ke&&(document.hidden?ke.suspend().catch(function(){}):!Xe&&nt&&Ws())};document.addEventListener("visibilitychange",im),(o=globalThis.addEventListener)===null||o===void 0||o.call(globalThis,"resize",Of),e.addEventListener("pointerdown",Qp),e.addEventListener("pointermove",em),e.addEventListener("pointerup",tm),e.addEventListener("pointercancel",jc),e.addEventListener("lostpointercapture",jc),e.addEventListener("click",nm);var Bf=P?.onVisibilityChanged(function(c){ct=c,Le=0,Ee=0,c||er(),ke&&(c?!Xe&&nt&&Ws():ke.suspend().catch(function(){}))}),kf=P?.onClosed(function(){je=!0,Le=0,Ee=0,er(),li()}),zf=(u=P?.onVolumeChanged)===null||u===void 0?void 0:u.call(P,function(c){typeof c=="number"&&Number.isFinite(c)&&c>=0&&(yn=Math.min(1,c>1?c/100:c),Af())});function rm(c){var x=!f&&!Xe&&!document.hidden&>&&ct&&!je;if(x&&Ee&&(ie+=Math.min((c-Ee)/1e3,5/60)),xr()){tt=Ge=0,Ye=!1,Ee&&(Le+=Math.min((c-Ee)/1e3,5/60));for(var I=0;I<5&&Le>=1/60;I++)Lg(1/60),Le-=1/60;ya()}else Le=0;Ee=c,Zi(),ue=requestAnimationFrame(rm)}return Al(),f&&(U=m),Zi(),ue=requestAnimationFrame(rm),P&&P.init().then(function(){Dt||(gt=!0,ct=P.isVisible(),Le=0,Ee=0)}).catch(function(){Dt||(je=!0,er(),li())}),{state:yr,auditViewport:kg,auditSceneLayout:zg,restart:function(){var c;(c=P?.notifyGameRetry)===null||c===void 0||c.call(P),Al(),Zi()},select:function(c){Z=c},inspectScene:function(c){f&&n.scenes.some(function(x){return x.id===c})&&(U=c,Z=void 0)},pause:function(c){Xe=c,Le=0,Ee=0,c&&er(),ke&&(c?ke.suspend().catch(function(){}):nt&&Ws())},destroy:function(){var c,x;Dt=!0,cancelAnimationFrame(ue),er(),li(),We?.dispose(),Bf?.(),kf?.(),zf?.(),P?.destroy(),(c=ps?.disconnect)===null||c===void 0||c.call(ps),document.removeEventListener("visibilitychange",im),(x=globalThis.removeEventListener)===null||x===void 0||x.call(globalThis,"resize",Of),e.removeEventListener("pointerdown",Qp),e.removeEventListener("pointermove",em),e.removeEventListener("pointerup",tm),e.removeEventListener("pointercancel",jc),e.removeEventListener("lostpointercapture",jc),e.removeEventListener("click",nm),ke?.close().catch(function(){})}}}return cy(Kw);})();
|
|
4220
|
+
}`,Hp=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let i=new uc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,i=new pa({vertexShader:Pw,fragmentShader:Lw,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new _i(new yc(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Wp=class extends Za{constructor(e,t){super();let i=this,r=null,a=1,s=null,o="local-floor",u=1,l=null,d=null,f=null,h=null,m=null,y=null,M=typeof XRWebGLBinding<"u",g=new Hp,v={},L=t.getContextAttributes(),p=null,_=null,N=[],D=[],V=new tn,w=null,I=null,G=new Fr;G.viewport=new Ni;let H=new Fr;H.viewport=new Ni;let Q=[G,H],T=new wd,S=null,Z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(oe){let ee=N[oe];return ee===void 0&&(ee=new Qo,N[oe]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(oe){let ee=N[oe];return ee===void 0&&(ee=new Qo,N[oe]=ee),ee.getGripSpace()},this.getHand=function(oe){let ee=N[oe];return ee===void 0&&(ee=new Qo,N[oe]=ee),ee.getHandSpace()};function q(oe){let ee=D.indexOf(oe.inputSource);if(ee===-1)return;let be=N[ee];be!==void 0&&(be.update(oe.inputSource,oe.frame,l||s),be.dispatchEvent({type:oe.type,data:oe.inputSource}))}function se(){r.removeEventListener("select",q),r.removeEventListener("selectstart",q),r.removeEventListener("selectend",q),r.removeEventListener("squeeze",q),r.removeEventListener("squeezestart",q),r.removeEventListener("squeezeend",q),r.removeEventListener("end",se),r.removeEventListener("inputsourceschange",F);for(let oe=0;oe<N.length;oe++){let ee=D[oe];ee!==null&&(D[oe]=null,N[oe].disconnect(ee))}S=null,Z=null,g.reset();for(let oe in v)delete v[oe];if(e.setRenderTarget(p),m=null,h=null,f=null,r=null,_=null,De.stop(),i.isPresenting=!1,e.setPixelRatio(w),e.setSize(V.width,V.height,!1),I!==null){let oe=I.camera;oe.fov=I.fov,oe.zoom=I.zoom,oe.updateProjectionMatrix(),I=null}i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(oe){a=oe,i.isPresenting===!0&&En("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(oe){o=oe,i.isPresenting===!0&&En("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(oe){l=oe},this.getBaseLayer=function(){return h!==null?h:m},this.getBinding=function(){return f===null&&M&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(oe){if(r=oe,r!==null){if(p=e.getRenderTarget(),r.addEventListener("select",q),r.addEventListener("selectstart",q),r.addEventListener("selectend",q),r.addEventListener("squeeze",q),r.addEventListener("squeezestart",q),r.addEventListener("squeezeend",q),r.addEventListener("end",se),r.addEventListener("inputsourceschange",F),L.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(V),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let be=null,Be=null,Re=null;L.depth&&(Re=L.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,be=L.stencil?Hs:qa,Be=L.stencil?ml:Ua);let Ye={colorFormat:t.RGBA8,depthFormat:Re,scaleFactor:a};f=this.getBinding(),h=f.createProjectionLayer(Ye),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),_=new aa(h.textureWidth,h.textureHeight,{format:ga,type:la,depthTexture:new Bs(h.textureWidth,h.textureHeight,Be,void 0,void 0,void 0,void 0,void 0,void 0,be),stencilBuffer:L.stencil,colorSpace:e.outputColorSpace,samples:L.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let be={antialias:L.antialias,alpha:!0,depth:L.depth,stencil:L.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(r,t,be),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),_=new aa(m.framebufferWidth,m.framebufferHeight,{format:ga,type:la,colorSpace:e.outputColorSpace,stencilBuffer:L.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1,storeMultisampledDepthBuffer:m.ignoreDepthValues===!1,storeMultisampledStencilBuffer:m.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(u),l=null,s=await r.requestReferenceSpace(o),De.setContext(r),De.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function F(oe){for(let ee=0;ee<oe.removed.length;ee++){let be=oe.removed[ee],Be=D.indexOf(be);Be>=0&&(D[Be]=null,N[Be].disconnect(be))}for(let ee=0;ee<oe.added.length;ee++){let be=oe.added[ee],Be=D.indexOf(be);if(Be===-1){for(let Ye=0;Ye<N.length;Ye++)if(Ye>=D.length){D.push(be),Be=Ye;break}else if(D[Ye]===null){D[Ye]=be,Be=Ye;break}if(Be===-1)break}let Re=N[Be];Re&&Re.connect(be)}}let z=new xe,Y=new xe;function $(oe,ee,be){z.setFromMatrixPosition(ee.matrixWorld),Y.setFromMatrixPosition(be.matrixWorld);let Be=z.distanceTo(Y),Re=ee.projectionMatrix.elements,Ye=be.projectionMatrix.elements,nt=Re[14]/(Re[10]-1),Ge=Re[14]/(Re[10]+1),$e=(Re[9]+1)/Re[5],mt=(Re[9]-1)/Re[5],at=(Re[8]-1)/Re[0],Ve=(Ye[8]+1)/Ye[0],Yt=nt*at,st=nt*Ve,Dt=Be/(-at+Ve),on=Dt*-at;if(ee.matrixWorld.decompose(oe.position,oe.quaternion,oe.scale),oe.translateX(on),oe.translateZ(Dt),oe.matrixWorld.compose(oe.position,oe.quaternion,oe.scale),oe.matrixWorldInverse.copy(oe.matrixWorld).invert(),Re[10]===-1)oe.projectionMatrix.copy(ee.projectionMatrix),oe.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{let de=nt+Dt,wn=Ge+Dt,Mn=Yt-on,K=st+(Be-on),b=$e*Ge/wn*de,ne=mt*Ge/wn*de;oe.projectionMatrix.makePerspective(Mn,K,b,ne,de,wn),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert()}}function he(oe,ee){ee===null?oe.matrixWorld.copy(oe.matrix):oe.matrixWorld.multiplyMatrices(ee.matrixWorld,oe.matrix),oe.matrixWorldInverse.copy(oe.matrixWorld).invert()}this.updateCamera=function(oe){if(r===null)return;let ee=oe.near,be=oe.far;g.texture!==null&&(g.depthNear>0&&(ee=g.depthNear),g.depthFar>0&&(be=g.depthFar)),T.near=H.near=G.near=ee,T.far=H.far=G.far=be,(S!==T.near||Z!==T.far)&&(r.updateRenderState({depthNear:T.near,depthFar:T.far}),S=T.near,Z=T.far),T.layers.mask=oe.layers.mask|6,G.layers.mask=T.layers.mask&-5,H.layers.mask=T.layers.mask&-3;let Be=oe.parent,Re=T.cameras;he(T,Be);for(let Ye=0;Ye<Re.length;Ye++)he(Re[Ye],Be);Re.length===2?$(T,G,H):T.projectionMatrix.copy(G.projectionMatrix),I===null&&oe.isPerspectiveCamera&&(I={camera:oe,fov:oe.fov,zoom:oe.zoom}),pe(oe,T,Be)};function pe(oe,ee,be){be===null?oe.matrix.copy(ee.matrixWorld):(oe.matrix.copy(be.matrixWorld),oe.matrix.invert(),oe.matrix.multiply(ee.matrixWorld)),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.updateMatrixWorld(!0),oe.projectionMatrix.copy(ee.projectionMatrix),oe.projectionMatrixInverse.copy(ee.projectionMatrixInverse),oe.isPerspectiveCamera&&(oe.fov=Qu*2*Math.atan(1/oe.projectionMatrix.elements[5]),oe.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(h===null&&m===null))return u},this.setFoveation=function(oe){u=oe,h!==null&&(h.fixedFoveation=oe),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=oe)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(T)},this.getCameraTexture=function(oe){return v[oe]};let le=null;function Te(oe,ee){if(d=ee.getViewerPose(l||s),y=ee,d!==null){let be=d.views;m!==null&&(e.setRenderTargetFramebuffer(_,m.framebuffer),e.setRenderTarget(_));let Be=!1;be.length!==T.cameras.length&&(T.cameras.length=0,Be=!0);for(let Ge=0;Ge<be.length;Ge++){let $e=be[Ge],mt=null;if(m!==null)mt=m.getViewport($e);else{let Ve=f.getViewSubImage(h,$e);mt=Ve.viewport,Ge===0&&(e.setRenderTargetTextures(_,Ve.colorTexture,Ve.depthStencilTexture),e.setRenderTarget(_))}let at=Q[Ge];at===void 0&&(at=new Fr,at.layers.enable(Ge),at.viewport=new Ni,Q[Ge]=at),at.matrix.fromArray($e.transform.matrix),at.matrix.decompose(at.position,at.quaternion,at.scale),at.projectionMatrix.fromArray($e.projectionMatrix),at.projectionMatrixInverse.copy(at.projectionMatrix).invert(),at.viewport.set(mt.x,mt.y,mt.width,mt.height),Ge===0&&(T.matrix.copy(at.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),Be===!0&&T.cameras.push(at)}let Re=r.enabledFeatures;if(Re&&Re.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&M){f=i.getBinding();let Ge=f.getDepthInformation(be[0]);Ge&&Ge.isValid&&Ge.texture&&g.init(Ge,r.renderState)}if(Re&&Re.includes("camera-access")&&M){e.state.unbindTexture(),f=i.getBinding();for(let Ge=0;Ge<be.length;Ge++){let $e=be[Ge].camera;if($e){let mt=v[$e];mt||(mt=new uc,v[$e]=mt);let at=f.getCameraImage($e);mt.sourceTexture=at}}}}for(let be=0;be<N.length;be++){let Be=D[be],Re=N[be];Be!==null&&Re!==void 0&&Re.update(Be,ee,l||s)}le&&le(oe,ee),ee.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ee}),y=null}let De=new eg;De.setAnimationLoop(Te),this.setAnimationLoop=function(oe){le=oe},this.dispose=function(){}}},Dw=new Kn,sg=new qn;sg.set(-1,0,0,0,1,0,0,0,1);function Nw(n,e){function t(g,v){g.matrixAutoUpdate===!0&&g.updateMatrix(),v.value.copy(g.matrix)}function i(g,v){v.color.getRGB(g.fogColor.value,Mp(n)),v.isFog?(g.fogNear.value=v.near,g.fogFar.value=v.far):v.isFogExp2&&(g.fogDensity.value=v.density)}function r(g,v,L,p,_){v.isNodeMaterial?v.uniformsNeedUpdate=!1:v.isMeshBasicMaterial?a(g,v):v.isMeshLambertMaterial?(a(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshToonMaterial?(a(g,v),f(g,v)):v.isMeshPhongMaterial?(a(g,v),d(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshStandardMaterial?(a(g,v),h(g,v),v.isMeshPhysicalMaterial&&m(g,v,_)):v.isMeshMatcapMaterial?(a(g,v),y(g,v)):v.isMeshDepthMaterial?a(g,v):v.isMeshDistanceMaterial?(a(g,v),M(g,v)):v.isMeshNormalMaterial?a(g,v):v.isLineBasicMaterial?(s(g,v),v.isLineDashedMaterial&&o(g,v)):v.isPointsMaterial?u(g,v,L,p):v.isSpriteMaterial?l(g,v):v.isShadowMaterial?(g.color.value.copy(v.color),g.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(g,v){g.opacity.value=v.opacity,v.color&&g.diffuse.value.copy(v.color),v.emissive&&g.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(g.map.value=v.map,t(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.bumpMap&&(g.bumpMap.value=v.bumpMap,t(v.bumpMap,g.bumpMapTransform),g.bumpScale.value=v.bumpScale,v.side===Kr&&(g.bumpScale.value*=-1)),v.normalMap&&(g.normalMap.value=v.normalMap,t(v.normalMap,g.normalMapTransform),g.normalScale.value.copy(v.normalScale),v.side===Kr&&g.normalScale.value.negate()),v.displacementMap&&(g.displacementMap.value=v.displacementMap,t(v.displacementMap,g.displacementMapTransform),g.displacementScale.value=v.displacementScale,g.displacementBias.value=v.displacementBias),v.emissiveMap&&(g.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,g.emissiveMapTransform)),v.specularMap&&(g.specularMap.value=v.specularMap,t(v.specularMap,g.specularMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest);let L=e.get(v),p=L.envMap,_=L.envMapRotation;p&&(g.envMap.value=p,g.envMapRotation.value.setFromMatrix4(Dw.makeRotationFromEuler(_)).transpose(),p.isCubeTexture&&p.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(sg),g.reflectivity.value=v.reflectivity,g.ior.value=v.ior,g.refractionRatio.value=v.refractionRatio),v.lightMap&&(g.lightMap.value=v.lightMap,g.lightMapIntensity.value=v.lightMapIntensity,t(v.lightMap,g.lightMapTransform)),v.aoMap&&(g.aoMap.value=v.aoMap,g.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,g.aoMapTransform))}function s(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,v.map&&(g.map.value=v.map,t(v.map,g.mapTransform))}function o(g,v){g.dashSize.value=v.dashSize,g.totalSize.value=v.dashSize+v.gapSize,g.scale.value=v.scale}function u(g,v,L,p){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.size.value=v.size*L,g.scale.value=p*.5,v.map&&(g.map.value=v.map,t(v.map,g.uvTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function l(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.rotation.value=v.rotation,v.map&&(g.map.value=v.map,t(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function d(g,v){g.specular.value.copy(v.specular),g.shininess.value=Math.max(v.shininess,1e-4)}function f(g,v){v.gradientMap&&(g.gradientMap.value=v.gradientMap)}function h(g,v){g.metalness.value=v.metalness,v.metalnessMap&&(g.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,g.metalnessMapTransform)),g.roughness.value=v.roughness,v.roughnessMap&&(g.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,g.roughnessMapTransform)),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)}function m(g,v,L){g.ior.value=v.ior,v.sheen>0&&(g.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),g.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(g.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,g.sheenColorMapTransform)),v.sheenRoughnessMap&&(g.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,g.sheenRoughnessMapTransform))),v.clearcoat>0&&(g.clearcoat.value=v.clearcoat,g.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(g.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,g.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(g.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Kr&&g.clearcoatNormalScale.value.negate())),v.dispersion>0&&(g.dispersion.value=v.dispersion),v.retroreflectivity>0&&(g.retroreflectivity.value=v.retroreflectivity),v.iridescence>0&&(g.iridescence.value=v.iridescence,g.iridescenceIOR.value=v.iridescenceIOR,g.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(g.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,g.iridescenceMapTransform)),v.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),v.transmission>0&&(g.transmission.value=v.transmission,g.transmissionSamplerMap.value=L.texture,g.transmissionSamplerSize.value.set(L.width,L.height),v.transmissionMap&&(g.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,g.transmissionMapTransform)),g.thickness.value=v.thickness,v.thicknessMap&&(g.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=v.attenuationDistance,g.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(g.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(g.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=v.specularIntensity,g.specularColor.value.copy(v.specularColor),v.specularColorMap&&(g.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,g.specularColorMapTransform)),v.specularIntensityMap&&(g.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,g.specularIntensityMapTransform))}function y(g,v){v.matcap&&(g.matcap.value=v.matcap)}function M(g,v){let L=e.get(v).light;g.referencePosition.value.setFromMatrixPosition(L.matrixWorld),g.nearDistance.value=L.shadow.camera.near,g.farDistance.value=L.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Uw(n,e,t,i){let r={},a={},s=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function u(_,N){let D=N.program;i.uniformBlockBinding(_,D)}function l(_,N){let D=r[_.id];D===void 0&&(g(_),D=d(_),r[_.id]=D,_.addEventListener("dispose",L));let V=N.program;i.updateUBOMapping(_,V);let w=e.render.frame;a[_.id]!==w&&(h(_),a[_.id]=w)}function d(_){let N=f();_.__bindingPointIndex=N;let D=n.createBuffer(),V=_.__size,w=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,D),n.bufferData(n.UNIFORM_BUFFER,V,w),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,N,D),D}function f(){for(let _=0;_<o;_++)if(s.indexOf(_)===-1)return s.push(_),_;return Un("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(_){let N=r[_.id],D=_.uniforms,V=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,N);for(let w=0,I=D.length;w<I;w++){let G=D[w];if(Array.isArray(G))for(let H=0,Q=G.length;H<Q;H++)m(G[H],w,H,V);else m(G,w,0,V)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function m(_,N,D,V){if(M(_,N,D,V)===!0){let w=_.__offset,I=_.value;if(Array.isArray(I)){let G=0;for(let H=0;H<I.length;H++){let Q=I[H],T=v(Q);y(Q,_.__data,G),typeof Q!="number"&&typeof Q!="boolean"&&!Q.isMatrix3&&!ArrayBuffer.isView(Q)&&(G+=T.storage/Float32Array.BYTES_PER_ELEMENT)}}else y(I,_.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,w,_.__data)}}function y(_,N,D){typeof _=="number"||typeof _=="boolean"?N[0]=_:_.isMatrix3?(N[0]=_.elements[0],N[1]=_.elements[1],N[2]=_.elements[2],N[3]=0,N[4]=_.elements[3],N[5]=_.elements[4],N[6]=_.elements[5],N[7]=0,N[8]=_.elements[6],N[9]=_.elements[7],N[10]=_.elements[8],N[11]=0):ArrayBuffer.isView(_)?N.set(new _.constructor(_.buffer,_.byteOffset,N.length)):_.toArray(N,D)}function M(_,N,D,V){let w=_.value,I=N+"_"+D;if(V[I]===void 0)return typeof w=="number"||typeof w=="boolean"?V[I]=w:ArrayBuffer.isView(w)?V[I]=w.slice():V[I]=w.clone(),!0;{let G=V[I];if(typeof w=="number"||typeof w=="boolean"){if(G!==w)return V[I]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(G.equals(w)===!1)return G.copy(w),!0}}return!1}function g(_){let N=_.uniforms,D=0,V=16;for(let I=0,G=N.length;I<G;I++){let H=Array.isArray(N[I])?N[I]:[N[I]];for(let Q=0,T=H.length;Q<T;Q++){let S=H[Q],Z=Array.isArray(S.value)?S.value:[S.value];for(let q=0,se=Z.length;q<se;q++){let F=Z[q],z=v(F),Y=D%V,$=Y%z.boundary,he=Y+$;D+=$,he!==0&&V-he<z.storage&&(D+=V-he),S.__data=new Float32Array(z.storage/Float32Array.BYTES_PER_ELEMENT),S.__offset=D,D+=z.storage}}}let w=D%V;return w>0&&(D+=V-w),_.__size=D,_.__cache={},this}function v(_){let N={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(N.boundary=4,N.storage=4):_.isVector2?(N.boundary=8,N.storage=8):_.isVector3||_.isColor?(N.boundary=16,N.storage=12):_.isVector4?(N.boundary=16,N.storage=16):_.isMatrix3?(N.boundary=48,N.storage=48):_.isMatrix4?(N.boundary=64,N.storage=64):_.isTexture?En("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(N.boundary=16,N.storage=_.byteLength):En("WebGLRenderer: Unsupported uniform value type.",_),N}function L(_){let N=_.target;N.removeEventListener("dispose",L);let D=s.indexOf(N.__bindingPointIndex);s.splice(D,1),n.deleteBuffer(r[N.id]),delete r[N.id],delete a[N.id]}function p(){for(let _ in r)n.deleteBuffer(r[_]);s=[],r={},a={}}return{bind:u,update:l,dispose:p}}var Fw=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),ja=null;function Ow(){return ja===null&&(ja=new Os(Fw,16,16,Ws,Fa),ja.name="DFG_LUT",ja.minFilter=lr,ja.magFilter=lr,ja.wrapS=Sa,ja.wrapT=Sa,ja.generateMipmaps=!1,ja.needsUpdate=!0),ja}var xf=class{constructor(e={}){let{canvas:t=M0(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:l=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:h=!1,outputBufferType:m=la}=e;this.isWebGLRenderer=!0;let y;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");y=i.getContextAttributes().alpha}else y=s;let M=m,g=new Set([Fd,Ud,Nd]),v=new Set([la,Ua,pl,ml,Pd,Ld]),L=new Uint32Array(4),p=new Int32Array(4),_=new xe,N=null,D=null,V=[],w=[],I=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=oa,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let G=this,H=!1,Q=null,T=null,S=null,Z=null;this._outputColorSpace=wr;let q=0,se=0,F=null,z=-1,Y=null,$=new Ni,he=new Ni,pe=null,le=new zn(0),Te=0,De=t.width,oe=t.height,ee=1,be=null,Be=null,Re=new Ni(0,0,De,oe),Ye=new Ni(0,0,De,oe),nt=!1,Ge=new nl,$e=!1,mt=!1,at=new Kn,Ve=new xe,Yt=new Ni,st={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Dt=!1;function on(){return F===null?ee:1}let de=i;function wn(C,re){return t.getContext(C,re)}let Mn,K,b,ne,Se,Ie,Xe,qe,Le,Pe,lt,Mt,yt,it,Gt,Zt,Ke,fe,We,ze,ht,St,He;try{let C={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:u,preserveDrawingBuffer:l,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"186"}`),t.addEventListener("webglcontextlost",pt,!1),t.addEventListener("webglcontextrestored",Lt,!1),t.addEventListener("webglcontextcreationerror",et,!1),de===null){let re="webgl2";if(de=wn(re,C),de===null)throw wn(re)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}qt()}catch(C){throw t.removeEventListener("webglcontextlost",pt,!1),t.removeEventListener("webglcontextrestored",Lt,!1),t.removeEventListener("webglcontextcreationerror",et,!1),Un("WebGLRenderer: "+C.message),C}function qt(){Mn=new WS(de),Mn.init(),ht=new Rw(de,Mn),K=new NS(de,Mn,e,ht),b=new Iw(de,Mn),K.reversedDepthBuffer&&h&&b.buffers.depth.setReversed(!0),T=de.createFramebuffer(),S=de.createFramebuffer(),Z=de.createFramebuffer(),ne=new qS(de),Se=new pw,Ie=new Cw(de,Mn,b,Se,K,ht,ne),Xe=new HS(G),qe=new Jx(de),St=new LS(de,qe),Le=new XS(de,qe,ne,St),Pe=new JS(de,Le,qe,St,ne),fe=new ZS(de,K,Ie),Gt=new US(Se),lt=new hw(G,Xe,Mn,K,St,Gt),Mt=new Nw(G,Se),yt=new vw,it=new Sw(Mn),Ke=new PS(G,Xe,b,Pe,y,u),Zt=new Ew(G,Pe,K),He=new Uw(de,ne,K,b),We=new DS(de,Mn,ne),ze=new YS(de,Mn,ne),ne.programs=lt.programs,G.capabilities=K,G.extensions=Mn,G.properties=Se,G.renderLists=yt,G.shadowMap=Zt,G.state=b,G.info=ne}M!==la&&(I=new KS(M,t.width,t.height,o,r,a));let Tt=new Wp(G,de);this.xr=Tt,this.getContext=function(){return de},this.getContextAttributes=function(){return de.getContextAttributes()},this.forceContextLoss=function(){let C=Mn.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){let C=Mn.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(C){C!==void 0&&(ee=C,this.setSize(De,oe,!1))},this.getSize=function(C){return C.set(De,oe)},this.setSize=function(C,re,Me=!0){if(Tt.isPresenting){En("WebGLRenderer: Can't change size while VR device is presenting.");return}De=C,oe=re,t.width=Math.floor(C*ee),t.height=Math.floor(re*ee),Me===!0&&(t.style.width=C+"px",t.style.height=re+"px"),I!==null&&I.setSize(t.width,t.height),this.setViewport(0,0,C,re)},this.getDrawingBufferSize=function(C){return C.set(De*ee,oe*ee).floor()},this.setDrawingBufferSize=function(C,re,Me){De=C,oe=re,ee=Me,t.width=Math.floor(C*Me),t.height=Math.floor(re*Me),this.setViewport(0,0,C,re)},this.setEffects=function(C){if(M===la){Un("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let re=0;re<C.length;re++)if(C[re].isOutputPass===!0){En("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}I.setEffects(C||[])},this.getCurrentViewport=function(C){return C.copy($)},this.getViewport=function(C){return C.copy(Re)},this.setViewport=function(C,re,Me,ie){C.isVector4?Re.set(C.x,C.y,C.z,C.w):Re.set(C,re,Me,ie),b.viewport($.copy(Re).multiplyScalar(ee).round())},this.getScissor=function(C){return C.copy(Ye)},this.setScissor=function(C,re,Me,ie){C.isVector4?Ye.set(C.x,C.y,C.z,C.w):Ye.set(C,re,Me,ie),b.scissor(he.copy(Ye).multiplyScalar(ee).round())},this.getScissorTest=function(){return nt},this.setScissorTest=function(C){b.setScissorTest(nt=C)},this.setOpaqueSort=function(C){be=C},this.setTransparentSort=function(C){Be=C},this.getClearColor=function(C){return C.copy(Ke.getClearColor())},this.setClearColor=function(){Ke.setClearColor(...arguments)},this.getClearAlpha=function(){return Ke.getClearAlpha()},this.setClearAlpha=function(){Ke.setClearAlpha(...arguments)},this.clear=function(C=!0,re=!0,Me=!0){let ie=0;if(C){let _e=!1;if(F!==null){let tt=F.texture.format;_e=g.has(tt)}if(_e){let tt=F.texture.type,Qe=v.has(tt),je=Ke.getClearColor(),bt=Ke.getClearAlpha(),ft=je.r,wt=je.g,kt=je.b;Qe?(L[0]=ft,L[1]=wt,L[2]=kt,L[3]=bt,de.clearBufferuiv(de.COLOR,0,L)):(p[0]=ft,p[1]=wt,p[2]=kt,p[3]=bt,de.clearBufferiv(de.COLOR,0,p))}else ie|=de.COLOR_BUFFER_BIT}re&&(ie|=de.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Me&&(ie|=de.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ie!==0&&de.clear(ie)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(C){C.setRenderer(this),Q=C},this.dispose=function(){t.removeEventListener("webglcontextlost",pt,!1),t.removeEventListener("webglcontextrestored",Lt,!1),t.removeEventListener("webglcontextcreationerror",et,!1),Ke.dispose(),yt.dispose(),it.dispose(),Se.dispose(),Xe.dispose(),Pe.dispose(),St.dispose(),He.dispose(),lt.dispose(),Tt.dispose(),Tt.removeEventListener("sessionstart",bn),Tt.removeEventListener("sessionend",gn),Wt.stop()};function pt(C){C.preventDefault(),xp("WebGLRenderer: Context Lost."),H=!0}function Lt(){xp("WebGLRenderer: Context Restored."),H=!1;let C=ne.autoReset,re=Zt.enabled,Me=Zt.autoUpdate,ie=Zt.needsUpdate,_e=Zt.type;qt(),ne.autoReset=C,Zt.enabled=re,Zt.autoUpdate=Me,Zt.needsUpdate=ie,Zt.type=_e}function et(C){Un("WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function Pt(C){let re=C.target;re.removeEventListener("dispose",Pt),Ht(re)}function Ht(C){cn(C),Se.remove(C)}function cn(C){let re=Se.get(C).programs;re!==void 0&&(re.forEach(function(Me){lt.releaseProgram(Me)}),C.isShaderMaterial&<.releaseShaderCache(C))}this.renderBufferDirect=function(C,re,Me,ie,_e,tt){re===null&&(re=st);let Qe=_e.isMesh&&_e.matrixWorld.determinantAffine()<0,je=Fn(C,re,Me,ie,_e);b.setMaterial(ie,Qe);let bt=Me.index,ft=1;if(ie.wireframe===!0){if(bt=Le.getWireframeAttribute(Me),bt===void 0)return;ft=2}let wt=Me.drawRange,kt=Me.attributes.position,Ee=wt.start*ft,nn=(wt.start+wt.count)*ft;tt!==null&&(Ee=Math.max(Ee,tt.start*ft),nn=Math.min(nn,(tt.start+tt.count)*ft)),bt!==null?(Ee=Math.max(Ee,0),nn=Math.min(nn,bt.count)):kt!=null&&(Ee=Math.max(Ee,0),nn=Math.min(nn,kt.count));let jt=nn-Ee;if(jt<0||jt===1/0)return;St.setup(_e,ie,je,Me,bt);let Sn,pn=We;if(bt!==null&&(Sn=qe.get(bt),pn=ze,pn.setIndex(Sn)),_e.isMesh)ie.wireframe===!0?(b.setLineWidth(ie.wireframeLinewidth*on()),pn.setMode(de.LINES)):pn.setMode(de.TRIANGLES);else if(_e.isLine){let xn=ie.linewidth;xn===void 0&&(xn=1),b.setLineWidth(xn*on()),_e.isLineSegments?pn.setMode(de.LINES):_e.isLineLoop?pn.setMode(de.LINE_LOOP):pn.setMode(de.LINE_STRIP)}else _e.isPoints?pn.setMode(de.POINTS):_e.isSprite&&pn.setMode(de.TRIANGLES);if(_e.isBatchedMesh)if(Mn.get("WEBGL_multi_draw"))pn.renderMultiDraw(_e._multiDrawStarts,_e._multiDrawCounts,_e._multiDrawCount);else{let xn=_e._multiDrawStarts,xt=_e._multiDrawCounts,Vt=_e._multiDrawCount,dn=bt?qe.get(bt).bytesPerElement:1,Nt=Se.get(ie).currentProgram.getUniforms();for(let hi=0;hi<Vt;hi++)Nt.setValue(de,"_gl_DrawID",hi),pn.render(xn[hi]/dn,xt[hi])}else if(_e.isInstancedMesh)pn.renderInstances(Ee,jt,_e.count);else if(Me.isInstancedBufferGeometry){let xn=Me._maxInstanceCount!==void 0?Me._maxInstanceCount:1/0,xt=Math.min(Me.instanceCount,xn);pn.renderInstances(Ee,jt,xt)}else pn.render(Ee,jt)};function an(C,re,Me,ie){Q!==null&&C.isNodeMaterial&&Q.setObject(ie,C),$e===!0&&Gt.setState(C,Me,!1),C.transparent===!0&&C.side===Br&&C.forceSinglePass===!1?(C.side=Kr,C.needsUpdate=!0,Wn(C,re,ie),C.side=$a,C.needsUpdate=!0,Wn(C,re,ie),C.side=Br):Wn(C,re,ie)}this.compile=function(C,re,Me=null){Me===null&&(Me=C),Q!==null&&Q.renderStart(C,re,Me),D=it.get(Me),D.init(re),w.push(D),Me.traverseVisible(function(_e){_e.isLight&&_e.layers.test(re.layers)&&(D.pushLight(_e),_e.castShadow&&D.pushShadow(_e))}),C!==Me&&C.traverseVisible(function(_e){_e.isLight&&_e.layers.test(re.layers)&&(D.pushLight(_e),_e.castShadow&&D.pushShadow(_e))}),D.setupLights(),Q!==null&&Q.updateLights(D.state.lightsArray),mt=this.localClippingEnabled,$e=Gt.init(this.clippingPlanes,mt),$e===!0&&Gt.setGlobalState(this.clippingPlanes,re),Q!==null&&Zt.render(D.state.shadowsArray,Me,re);let ie=new Set;return C.traverse(function(_e){if(!(_e.isMesh||_e.isPoints||_e.isLine||_e.isSprite))return;let tt=_e.material;if(tt)if(Array.isArray(tt))for(let Qe=0;Qe<tt.length;Qe++){let je=tt[Qe];an(je,Me,re,_e),ie.add(je)}else an(tt,Me,re,_e),ie.add(tt)}),D=w.pop(),Q!==null&&Q.renderEnd(),ie},this.compileAsync=function(C,re,Me=null){let ie=this.compile(C,re,Me);return new Promise(_e=>{function tt(){if(ie.forEach(function(Qe){let bt=Se.get(Qe).currentProgram;(bt===void 0||bt.isReady())&&ie.delete(Qe)}),ie.size===0){_e(C);return}setTimeout(tt,10)}Mn.get("KHR_parallel_shader_compile")!==null?tt():setTimeout(tt,10)})};let Ct=null;function Kt(C){Ct&&Ct(C)}function bn(){Wt.stop()}function gn(){Wt.start()}let Wt=new eg;Wt.setAnimationLoop(Kt),typeof self<"u"&&Wt.setContext(self),this.setAnimationLoop=function(C){Ct=C,Tt.setAnimationLoop(C),C===null?Wt.stop():Wt.start()},Tt.addEventListener("sessionstart",bn),Tt.addEventListener("sessionend",gn),this.render=function(C,re){if(re!==void 0&&re.isCamera!==!0){Un("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(H===!0)return;Q!==null&&Q.renderStart(C,re);let Me=Tt.enabled===!0&&Tt.isPresenting===!0,ie=I!==null&&(F===null||Me)&&I.begin(G,F);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),re.parent===null&&re.matrixWorldAutoUpdate===!0&&re.updateMatrixWorld(),Tt.enabled===!0&&Tt.isPresenting===!0&&(I===null||I.isCompositing()===!1)&&(Tt.cameraAutoUpdate===!0&&Tt.updateCamera(re),re=Tt.getCamera()),C.isScene===!0&&C.onBeforeRender(G,C,re,F),D=it.get(C,w.length),D.init(re),D.state.textureUnits=Ie.getTextureUnits(),w.push(D),at.multiplyMatrices(re.projectionMatrix,re.matrixWorldInverse),Ge.setFromProjectionMatrix(at,Da,re.reversedDepth),mt=this.localClippingEnabled,$e=Gt.init(this.clippingPlanes,mt),N=yt.get(C,V.length),N.init(),V.push(N),Tt.enabled===!0&&Tt.isPresenting===!0){let Qe=G.xr.getDepthSensingMesh();Qe!==null&&Qn(Qe,re,-1/0,G.sortObjects)}Qn(C,re,0,G.sortObjects),N.finish(),Q!==null&&Q.updateLights(D.state.lightsArray),G.sortObjects===!0&&N.sort(be,Be),Dt=Tt.enabled===!1||Tt.isPresenting===!1||Tt.hasDepthSensing()===!1,Dt&&Ke.addToRenderList(N,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),$e===!0&&Gt.beginShadows();let _e=D.state.shadowsArray;if(Zt.render(_e,C,re),$e===!0&&Gt.endShadows(),(ie&&I.hasRenderPass())===!1){let Qe=N.opaque,je=N.transmissive;if(D.setupLights(),re.isArrayCamera){let bt=re.cameras;if(je.length>0)for(let ft=0,wt=bt.length;ft<wt;ft++){let kt=bt[ft];Gn(Qe,je,C,kt)}Dt&&Ke.render(C);for(let ft=0,wt=bt.length;ft<wt;ft++){let kt=bt[ft];Tn(N,C,kt,kt.viewport)}}else je.length>0&&Gn(Qe,je,C,re),Dt&&Ke.render(C),Tn(N,C,re)}F!==null&&se===0&&(Ie.updateMultisampleRenderTarget(F),Ie.updateRenderTargetMipmap(F)),ie&&I.end(G),C.isScene===!0&&C.onAfterRender(G,C,re),St.resetDefaultState(),z=-1,Y=null,w.pop(),w.length>0?(D=w[w.length-1],Ie.setTextureUnits(D.state.textureUnits),$e===!0&&Gt.setGlobalState(G.clippingPlanes,D.state.camera)):D=null,V.pop(),V.length>0?N=V[V.length-1]:N=null,Q!==null&&Q.renderEnd()};function Qn(C,re,Me,ie){if(C.visible===!1)return;if(C.layers.test(re.layers)){if(C.isGroup)Me=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(re);else if(C.isLightProbeGrid)D.pushLightProbeGrid(C);else if(C.isLight)D.pushLight(C),C.castShadow&&D.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||C.intersectsFrustum(Ge)){ie&&Yt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(at);let Qe=Pe.update(C),je=C.material;je.visible&&N.push(C,Qe,je,Me,Yt.z,null,re)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||C.intersectsFrustum(Ge))){let Qe=Pe.update(C),je=C.material;if(ie&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),Yt.copy(C.boundingSphere.center)):(Qe.boundingSphere===null&&Qe.computeBoundingSphere(),Yt.copy(Qe.boundingSphere.center)),Yt.applyMatrix4(C.matrixWorld).applyMatrix4(at)),Array.isArray(je)){let bt=Qe.groups;for(let ft=0,wt=bt.length;ft<wt;ft++){let kt=bt[ft],Ee=je[kt.materialIndex];Ee&&Ee.visible&&N.push(C,Qe,Ee,Me,Yt.z,kt,re)}}else je.visible&&N.push(C,Qe,je,Me,Yt.z,null,re)}}let tt=C.children;for(let Qe=0,je=tt.length;Qe<je;Qe++)Qn(tt[Qe],re,Me,ie)}function Tn(C,re,Me,ie){let{opaque:_e,transmissive:tt,transparent:Qe}=C;D.setupLightsView(Me),$e===!0&&Gt.setGlobalState(G.clippingPlanes,Me),ie&&b.viewport($.copy(ie)),_e.length>0&&Hn(_e,re,Me),tt.length>0&&Hn(tt,re,Me),Qe.length>0&&Hn(Qe,re,Me),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function Gn(C,re,Me,ie){if((Me.isScene===!0?Me.overrideMaterial:null)!==null)return;if(D.state.transmissionRenderTarget[ie.id]===void 0){let Ee=Mn.has("EXT_color_buffer_half_float")||Mn.has("EXT_color_buffer_float");D.state.transmissionRenderTarget[ie.id]=new aa(1,1,{generateMipmaps:!0,type:Ee?Fa:la,minFilter:Qa,samples:Math.max(4,K.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:mi.workingColorSpace})}let tt=D.state.transmissionRenderTarget[ie.id],Qe=ie.viewport||$;tt.setSize(Qe.z*G.transmissionResolutionScale,Qe.w*G.transmissionResolutionScale);let je=G.getRenderTarget(),bt=G.getActiveCubeFace(),ft=G.getActiveMipmapLevel();G.setRenderTarget(tt),G.getClearColor(le),Te=G.getClearAlpha(),Te<1&&G.setClearColor(16777215,.5),G.clear(),Dt&&Ke.render(Me);let wt=G.toneMapping;G.toneMapping=oa;let kt=ie.viewport;if(ie.viewport!==void 0&&(ie.viewport=void 0),D.setupLightsView(ie),$e===!0&&Gt.setGlobalState(G.clippingPlanes,ie),Hn(C,Me,ie),Ie.updateMultisampleRenderTarget(tt),Ie.updateRenderTargetMipmap(tt),Mn.has("WEBGL_multisampled_render_to_texture")===!1){let Ee=!1;for(let nn=0,jt=re.length;nn<jt;nn++){let Sn=re[nn],{object:pn,geometry:xn,material:xt,group:Vt}=Sn;if(xt.side===Br&&pn.layers.test(ie.layers)){let dn=xt.side;xt.side=Kr,xt.needsUpdate=!0,Cn(pn,Me,ie,xn,xt,Vt),xt.side=dn,xt.needsUpdate=!0,Ee=!0}}Ee===!0&&(Ie.updateMultisampleRenderTarget(tt),Ie.updateRenderTargetMipmap(tt))}G.setRenderTarget(je,bt,ft),G.setClearColor(le,Te),kt!==void 0&&(ie.viewport=kt),G.toneMapping=wt}function Hn(C,re,Me){let ie=re.isScene===!0?re.overrideMaterial:null;for(let _e=0,tt=C.length;_e<tt;_e++){let Qe=C[_e],{object:je,geometry:bt,group:ft}=Qe,wt=Qe.material;wt.allowOverride===!0&&ie!==null&&(wt=ie),je.layers.test(Me.layers)&&Cn(je,re,Me,bt,wt,ft)}}function Cn(C,re,Me,ie,_e,tt){Q!==null&&_e.isNodeMaterial&&Q.setObject(C,_e),C.onBeforeRender(G,re,Me,ie,_e,tt),C.modelViewMatrix.multiplyMatrices(Me.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),_e.onBeforeRender(G,re,Me,ie,C,tt),_e.transparent===!0&&_e.side===Br&&_e.forceSinglePass===!1?(_e.side=Kr,_e.needsUpdate=!0,G.renderBufferDirect(Me,re,ie,_e,C,tt),_e.side=$a,_e.needsUpdate=!0,G.renderBufferDirect(Me,re,ie,_e,C,tt),_e.side=Br):G.renderBufferDirect(Me,re,ie,_e,C,tt),C.onAfterRender(G,re,Me,ie,_e,tt)}function Wn(C,re,Me){re.isScene!==!0&&(re=st);let ie=Se.get(C),_e=D.state.lights,tt=D.state.shadowsArray,Qe=_e.state.version,je=lt.getParameters(C,_e.state,tt,re,Me,D.state.lightProbeGridArray),bt=lt.getProgramCacheKey(je),ft=ie.programs;ie.environment=C.isMeshStandardMaterial||C.isMeshLambertMaterial||C.isMeshPhongMaterial?re.environment:null,ie.fog=re.fog;let wt=C.isMeshStandardMaterial||C.isMeshLambertMaterial&&!C.envMap||C.isMeshPhongMaterial&&!C.envMap;ie.envMap=Xe.get(C.envMap||ie.environment,wt),ie.envMapRotation=ie.environment!==null&&C.envMap===null?re.environmentRotation:C.envMapRotation,ft===void 0&&(C.addEventListener("dispose",Pt),ft=new Map,ie.programs=ft);let kt=ft.get(bt);if(kt!==void 0){if(ie.currentProgram===kt&&ie.lightsStateVersion===Qe)return un(C,je),kt}else je.uniforms=lt.getUniforms(C),Q!==null&&C.isNodeMaterial&&Q.build(C,Me,je),C.onBeforeCompile(je,G),kt=lt.acquireProgram(je,bt),ft.set(bt,kt),ie.uniforms=je.uniforms;let Ee=ie.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(Ee.clippingPlanes=Gt.uniform),un(C,je),ie.needsLights=jn(C),ie.lightsStateVersion=Qe,ie.needsLights&&(Ee.ambientLightColor.value=_e.state.ambient,Ee.lightProbe.value=_e.state.probe,Ee.sunLights.value=_e.state.sun,Ee.sunLightShadows.value=_e.state.sunShadow,Ee.directionalLights.value=_e.state.directional,Ee.directionalLightShadows.value=_e.state.directionalShadow,Ee.spotLights.value=_e.state.spot,Ee.spotLightShadows.value=_e.state.spotShadow,Ee.rectAreaLights.value=_e.state.rectArea,Ee.ltc_1.value=_e.state.rectAreaLTC1,Ee.ltc_2.value=_e.state.rectAreaLTC2,Ee.pointLights.value=_e.state.point,Ee.pointLightShadows.value=_e.state.pointShadow,Ee.hemisphereLights.value=_e.state.hemi,Ee.sunShadowMatrix.value=_e.state.sunShadowMatrix,Ee.sunShadowCascade.value=_e.state.sunShadowCascade,Ee.directionalShadowMatrix.value=_e.state.directionalShadowMatrix,Ee.spotLightMatrix.value=_e.state.spotLightMatrix,Ee.spotLightMap.value=_e.state.spotLightMap,Ee.pointShadowMatrix.value=_e.state.pointShadowMatrix),ie.lightProbeGrid=D.state.lightProbeGridArray.length>0,ie.currentProgram=kt,ie.uniformsList=null,kt}function hn(C){if(C.uniformsList===null){let re=C.currentProgram.getUniforms();C.uniformsList=yl.seqWithValue(re.seq,C.uniforms)}return C.uniformsList}function un(C,re){let Me=Se.get(C);Me.outputColorSpace=re.outputColorSpace,Me.batching=re.batching,Me.batchingColor=re.batchingColor,Me.instancing=re.instancing,Me.instancingColor=re.instancingColor,Me.instancingMorph=re.instancingMorph,Me.skinning=re.skinning,Me.morphTargets=re.morphTargets,Me.morphNormals=re.morphNormals,Me.morphColors=re.morphColors,Me.morphTargetsCount=re.morphTargetsCount,Me.numClippingPlanes=re.numClippingPlanes,Me.numIntersection=re.numClipIntersection,Me.vertexAlphas=re.vertexAlphas,Me.vertexTangents=re.vertexTangents,Me.toneMapping=re.toneMapping}function An(C,re){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;_.setFromMatrixPosition(re.matrixWorld);for(let Me=0,ie=C.length;Me<ie;Me++){let _e=C[Me];if(_e.texture!==null&&_e.boundingBox.containsPoint(_))return _e}return null}function Fn(C,re,Me,ie,_e){re.isScene!==!0&&(re=st),Ie.resetTextureUnits();let tt=re.fog,Qe=ie.isMeshStandardMaterial||ie.isMeshLambertMaterial||ie.isMeshPhongMaterial?re.environment:null,je=F===null?G.outputColorSpace:F.isXRRenderTarget===!0?F.texture.colorSpace:mi.workingColorSpace,bt=ie.isMeshStandardMaterial||ie.isMeshLambertMaterial&&!ie.envMap||ie.isMeshPhongMaterial&&!ie.envMap,ft=Xe.get(ie.envMap||Qe,bt),wt=ie.vertexColors===!0&&!!Me.attributes.color&&Me.attributes.color.itemSize===4,kt=!!Me.attributes.tangent&&(!!ie.normalMap||ie.anisotropy>0),Ee=!!Me.morphAttributes.position,nn=!!Me.morphAttributes.normal,jt=!!Me.morphAttributes.color,Sn=oa;ie.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(Sn=G.toneMapping);let pn=Me.morphAttributes.position||Me.morphAttributes.normal||Me.morphAttributes.color,xn=pn!==void 0?pn.length:0,xt=Se.get(ie),Vt=D.state.lights;if($e===!0&&(mt===!0||C!==Y)){let Pn=C===Y&&ie.id===z;Gt.setState(ie,C,Pn)}let dn=!1;ie.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==Vt.state.version||xt.outputColorSpace!==je||_e.isBatchedMesh&&xt.batching===!1||!_e.isBatchedMesh&&xt.batching===!0||_e.isBatchedMesh&&xt.batchingColor===!0&&_e._colorsTexture===null||_e.isBatchedMesh&&xt.batchingColor===!1&&_e._colorsTexture!==null||_e.isInstancedMesh&&xt.instancing===!1||!_e.isInstancedMesh&&xt.instancing===!0||_e.isSkinnedMesh&&xt.skinning===!1||!_e.isSkinnedMesh&&xt.skinning===!0||_e.isInstancedMesh&&xt.instancingColor===!0&&_e.instanceColor===null||_e.isInstancedMesh&&xt.instancingColor===!1&&_e.instanceColor!==null||_e.isInstancedMesh&&xt.instancingMorph===!0&&_e.morphTexture===null||_e.isInstancedMesh&&xt.instancingMorph===!1&&_e.morphTexture!==null||xt.envMap!==ft||ie.fog===!0&&xt.fog!==tt||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==Gt.numPlanes||xt.numIntersection!==Gt.numIntersection)||xt.vertexAlphas!==wt||xt.vertexTangents!==kt||xt.morphTargets!==Ee||xt.morphNormals!==nn||xt.morphColors!==jt||xt.toneMapping!==Sn||xt.morphTargetsCount!==xn||!!xt.lightProbeGrid!=D.state.lightProbeGridArray.length>0)&&(dn=!0):(dn=!0,xt.__version=ie.version);let Nt=xt.currentProgram;dn===!0&&(Nt=Wn(ie,re,_e),Q&&ie.isNodeMaterial&&Q.onUpdateProgram(ie,Nt,xt));let hi=!1,rt=!1,ii=!1,Rn=Nt.getUniforms(),Jn=xt.uniforms;if(b.useProgram(Nt.program)&&(hi=!0,rt=!0,ii=!0),ie.id!==z&&(z=ie.id,rt=!0),xt.needsLights){let Pn=An(D.state.lightProbeGridArray,_e);xt.lightProbeGrid!==Pn&&(xt.lightProbeGrid=Pn,rt=!0)}if(hi||Y!==C){b.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),Rn.setValue(de,"projectionMatrix",C.projectionMatrix),Rn.setValue(de,"viewMatrix",C.matrixWorldInverse);let bi=Rn.map.cameraPosition;bi!==void 0&&bi.setValue(de,Ve.setFromMatrixPosition(C.matrixWorld)),K.logarithmicDepthBuffer&&Rn.setValue(de,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(ie.isMeshPhongMaterial||ie.isMeshToonMaterial||ie.isMeshLambertMaterial||ie.isMeshBasicMaterial||ie.isMeshStandardMaterial||ie.isShaderMaterial)&&Rn.setValue(de,"isOrthographic",C.isOrthographicCamera===!0),Y!==C&&(Y=C,rt=!0,ii=!0)}if(xt.needsLights&&(Vt.state.sunShadowMap.length>0&&Rn.setValue(de,"sunShadowMap",Vt.state.sunShadowMap,Ie),Vt.state.directionalShadowMap.length>0&&Rn.setValue(de,"directionalShadowMap",Vt.state.directionalShadowMap,Ie),Vt.state.spotShadowMap.length>0&&Rn.setValue(de,"spotShadowMap",Vt.state.spotShadowMap,Ie),Vt.state.pointShadowMap.length>0&&Rn.setValue(de,"pointShadowMap",Vt.state.pointShadowMap,Ie)),_e.isSkinnedMesh){Rn.setOptional(de,_e,"bindMatrix"),Rn.setOptional(de,_e,"bindMatrixInverse");let Pn=_e.skeleton;Pn&&(Pn.boneTexture===null&&Pn.computeBoneTexture(),Rn.setValue(de,"boneTexture",Pn.boneTexture,Ie))}_e.isBatchedMesh&&(Rn.setOptional(de,_e,"batchingTexture"),Rn.setValue(de,"batchingTexture",_e._matricesTexture,Ie),Rn.setOptional(de,_e,"batchingIdTexture"),Rn.setValue(de,"batchingIdTexture",_e._indirectTexture,Ie),Rn.setOptional(de,_e,"batchingColorTexture"),_e._colorsTexture!==null&&Rn.setValue(de,"batchingColorTexture",_e._colorsTexture,Ie));let Si=Me.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&fe.update(_e,Me,Nt),(rt||xt.receiveShadow!==_e.receiveShadow)&&(xt.receiveShadow=_e.receiveShadow,Rn.setValue(de,"receiveShadow",_e.receiveShadow)),(ie.isMeshStandardMaterial||ie.isMeshLambertMaterial||ie.isMeshPhongMaterial)&&ie.envMap===null&&re.environment!==null&&(Jn.envMapIntensity.value=re.environmentIntensity),Jn.dfgLUT!==void 0&&(Jn.dfgLUT.value=Ow()),rt){if(Rn.setValue(de,"toneMappingExposure",G.toneMappingExposure),xt.needsLights&&Vn(Jn,ii),tt&&ie.fog===!0&&Mt.refreshFogUniforms(Jn,tt),Mt.refreshMaterialUniforms(Jn,ie,ee,oe,D.state.transmissionRenderTarget[C.id]),xt.needsLights&&xt.lightProbeGrid){let Pn=xt.lightProbeGrid;Jn.probesSH.value=Pn.texture,Jn.probesMin.value.copy(Pn.boundingBox.min),Jn.probesMax.value.copy(Pn.boundingBox.max),Jn.probesResolution.value.copy(Pn.resolution)}yl.upload(de,hn(xt),Jn,Ie)}if(ie.isShaderMaterial&&ie.uniformsNeedUpdate===!0&&(yl.upload(de,hn(xt),Jn,Ie),ie.uniformsNeedUpdate=!1),ie.isSpriteMaterial&&Rn.setValue(de,"center",_e.center),Rn.setValue(de,"modelViewMatrix",_e.modelViewMatrix),Rn.setValue(de,"normalMatrix",_e.normalMatrix),Rn.setValue(de,"modelMatrix",_e.matrixWorld),ie.uniformsGroups!==void 0){let Pn=ie.uniformsGroups;for(let bi=0,si=Pn.length;bi<si;bi++){let rr=Pn[bi];He.update(rr,Nt),He.bind(rr,Nt)}}return Nt}function Vn(C,re){C.ambientLightColor.needsUpdate=re,C.lightProbe.needsUpdate=re,C.sunLights.needsUpdate=re,C.sunLightShadows.needsUpdate=re,C.directionalLights.needsUpdate=re,C.directionalLightShadows.needsUpdate=re,C.pointLights.needsUpdate=re,C.pointLightShadows.needsUpdate=re,C.spotLights.needsUpdate=re,C.spotLightShadows.needsUpdate=re,C.rectAreaLights.needsUpdate=re,C.hemisphereLights.needsUpdate=re}function jn(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return se},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(C,re,Me){let ie=Se.get(C);ie.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,ie.__autoAllocateDepthBuffer===!1&&(ie.__useRenderToTexture=!1),Se.get(C.texture).__webglTexture=re,Se.get(C.depthTexture).__webglTexture=ie.__autoAllocateDepthBuffer?void 0:Me,ie.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,re){let Me=Se.get(C);Me.__webglFramebuffer=re,Me.__useDefaultFramebuffer=re===void 0},this.setRenderTarget=function(C,re=0,Me=0){F=C,q=re,se=Me;let ie=null,_e=!1,tt=!1;if(C){let je=Se.get(C);if(je.__useDefaultFramebuffer!==void 0){b.bindFramebuffer(de.FRAMEBUFFER,je.__webglFramebuffer),$.copy(C.viewport),he.copy(C.scissor),pe=C.scissorTest,b.viewport($),b.scissor(he),b.setScissorTest(pe),z=-1;return}else if(je.__webglFramebuffer===void 0)Ie.setupRenderTarget(C);else if(je.__hasExternalTextures)Ie.rebindTextures(C,Se.get(C.texture).__webglTexture,Se.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){let wt=C.depthTexture;if(je.__boundDepthTexture!==wt){if(wt!==null&&Se.has(wt)&&(C.width!==wt.image.width||C.height!==wt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Ie.setupDepthRenderbuffer(C)}}let bt=C.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(tt=!0);let ft=Se.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(ft[re])?ie=ft[re][Me]:ie=ft[re],_e=!0):C.samples>0&&Ie.useMultisampledRTT(C)===!1?ie=Se.get(C).__webglMultisampledFramebuffer:Array.isArray(ft)?ie=ft[Me]:ie=ft,$.copy(C.viewport),he.copy(C.scissor),pe=C.scissorTest}else $.copy(Re).multiplyScalar(ee).floor(),he.copy(Ye).multiplyScalar(ee).floor(),pe=nt;if(Me!==0&&(ie=T),b.bindFramebuffer(de.FRAMEBUFFER,ie)&&b.drawBuffers(C,ie),b.viewport($),b.scissor(he),b.setScissorTest(pe),_e){let je=Se.get(C.texture);de.framebufferTexture2D(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_CUBE_MAP_POSITIVE_X+re,je.__webglTexture,Me)}else if(tt){let je=re;for(let bt=0;bt<C.textures.length;bt++){let ft=Se.get(C.textures[bt]);de.framebufferTextureLayer(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0+bt,ft.__webglTexture,Me,je)}}else if(C!==null&&Me!==0){let je=Se.get(C.texture);de.framebufferTexture2D(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_2D,je.__webglTexture,Me)}z=-1};function Zn(C){let re=Se.get(C);return(re.__readFormat!==C.format||re.__readType!==C.type)&&(re.__readFormat=C.format,re.__readType=C.type,re.__formatReadable=K.textureFormatReadable(C.format),re.__typeReadable=K.textureTypeReadable(C.type)),re}this.readRenderTargetPixels=function(C,re,Me,ie,_e,tt,Qe,je=0){if(!(C&&C.isWebGLRenderTarget)){Un("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=Se.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Qe!==void 0&&(bt=bt[Qe]),bt){b.bindFramebuffer(de.FRAMEBUFFER,bt);try{let ft=C.textures[je],wt=ft.format,kt=ft.type;C.textures.length>1&&de.readBuffer(de.COLOR_ATTACHMENT0+je);let Ee=Zn(ft);if(Ee.__formatReadable===!1){Un("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ee.__typeReadable===!1){Un("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}re>=0&&re<=C.width-ie&&Me>=0&&Me<=C.height-_e&&de.readPixels(re,Me,ie,_e,ht.convert(wt),ht.convert(kt),tt)}finally{let ft=F!==null?Se.get(F).__webglFramebuffer:null;b.bindFramebuffer(de.FRAMEBUFFER,ft)}}},this.readRenderTargetPixelsAsync=async function(C,re,Me,ie,_e,tt,Qe,je=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=Se.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Qe!==void 0&&(bt=bt[Qe]),bt)if(re>=0&&re<=C.width-ie&&Me>=0&&Me<=C.height-_e){b.bindFramebuffer(de.FRAMEBUFFER,bt);let ft=C.textures[je],wt=ft.format,kt=ft.type;C.textures.length>1&&de.readBuffer(de.COLOR_ATTACHMENT0+je);let Ee=Zn(ft);if(Ee.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ee.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let nn=de.createBuffer();de.bindBuffer(de.PIXEL_PACK_BUFFER,nn),de.bufferData(de.PIXEL_PACK_BUFFER,tt.byteLength,de.STREAM_READ),de.readPixels(re,Me,ie,_e,ht.convert(wt),ht.convert(kt),0),de.bindBuffer(de.PIXEL_PACK_BUFFER,null);let jt=F!==null?Se.get(F).__webglFramebuffer:null;b.bindFramebuffer(de.FRAMEBUFFER,jt);let Sn=de.fenceSync(de.SYNC_GPU_COMMANDS_COMPLETE,0);return de.flush(),await b0(de,Sn,4),de.bindBuffer(de.PIXEL_PACK_BUFFER,nn),de.getBufferSubData(de.PIXEL_PACK_BUFFER,0,tt),de.bindBuffer(de.PIXEL_PACK_BUFFER,null),de.deleteBuffer(nn),de.deleteSync(Sn),tt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,re=null,Me=0){let ie=Math.pow(2,-Me),_e=Math.floor(C.image.width*ie),tt=Math.floor(C.image.height*ie),Qe=re!==null?re.x:0,je=re!==null?re.y:0;Ie.setTexture2D(C,0),de.copyTexSubImage2D(de.TEXTURE_2D,Me,0,0,Qe,je,_e,tt),b.unbindTexture()},this.copyTextureToTexture=function(C,re,Me=null,ie=null,_e=0,tt=0){let Qe,je,bt,ft,wt,kt,Ee,nn,jt,Sn=C.isCompressedTexture?C.mipmaps[tt]:C.image;if(Me!==null)Qe=Me.max.x-Me.min.x,je=Me.max.y-Me.min.y,bt=Me.isBox3?Me.max.z-Me.min.z:1,ft=Me.min.x,wt=Me.min.y,kt=Me.isBox3?Me.min.z:0;else{let Jn=Math.pow(2,-_e);Qe=Math.floor(Sn.width*Jn),je=Math.floor(Sn.height*Jn),C.isDataArrayTexture?bt=Sn.depth:C.isData3DTexture?bt=Math.floor(Sn.depth*Jn):bt=1,ft=0,wt=0,kt=0}ie!==null?(Ee=ie.x,nn=ie.y,jt=ie.z):(Ee=0,nn=0,jt=0);let pn=ht.convert(re.format),xn=ht.convert(re.type),xt;re.isData3DTexture?(Ie.setTexture3D(re,0),xt=de.TEXTURE_3D):re.isDataArrayTexture||re.isCompressedArrayTexture?(Ie.setTexture2DArray(re,0),xt=de.TEXTURE_2D_ARRAY):(Ie.setTexture2D(re,0),xt=de.TEXTURE_2D),b.activeTexture(de.TEXTURE0),b.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,re.flipY),b.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,re.premultiplyAlpha),b.pixelStorei(de.UNPACK_ALIGNMENT,re.unpackAlignment);let Vt=b.getParameter(de.UNPACK_ROW_LENGTH),dn=b.getParameter(de.UNPACK_IMAGE_HEIGHT),Nt=b.getParameter(de.UNPACK_SKIP_PIXELS),hi=b.getParameter(de.UNPACK_SKIP_ROWS),rt=b.getParameter(de.UNPACK_SKIP_IMAGES);b.pixelStorei(de.UNPACK_ROW_LENGTH,Sn.width),b.pixelStorei(de.UNPACK_IMAGE_HEIGHT,Sn.height),b.pixelStorei(de.UNPACK_SKIP_PIXELS,ft),b.pixelStorei(de.UNPACK_SKIP_ROWS,wt),b.pixelStorei(de.UNPACK_SKIP_IMAGES,kt);let ii=C.isDataArrayTexture||C.isData3DTexture,Rn=re.isDataArrayTexture||re.isData3DTexture;if(C.isDepthTexture){let Jn=Se.get(C),Si=Se.get(re),Pn=Se.get(Jn.__renderTarget),bi=Se.get(Si.__renderTarget);b.bindFramebuffer(de.READ_FRAMEBUFFER,Pn.__webglFramebuffer),b.bindFramebuffer(de.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let si=0;si<bt;si++)ii&&(de.framebufferTextureLayer(de.READ_FRAMEBUFFER,de.COLOR_ATTACHMENT0,Se.get(C).__webglTexture,_e,kt+si),de.framebufferTextureLayer(de.DRAW_FRAMEBUFFER,de.COLOR_ATTACHMENT0,Se.get(re).__webglTexture,tt,jt+si)),de.blitFramebuffer(ft,wt,Qe,je,Ee,nn,Qe,je,de.DEPTH_BUFFER_BIT,de.NEAREST);b.bindFramebuffer(de.READ_FRAMEBUFFER,null),b.bindFramebuffer(de.DRAW_FRAMEBUFFER,null)}else if(_e!==0||C.isRenderTargetTexture||Se.has(C)){let Jn=Se.get(C),Si=Se.get(re);b.bindFramebuffer(de.READ_FRAMEBUFFER,S),b.bindFramebuffer(de.DRAW_FRAMEBUFFER,Z);for(let Pn=0;Pn<bt;Pn++)ii?de.framebufferTextureLayer(de.READ_FRAMEBUFFER,de.COLOR_ATTACHMENT0,Jn.__webglTexture,_e,kt+Pn):de.framebufferTexture2D(de.READ_FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_2D,Jn.__webglTexture,_e),Rn?de.framebufferTextureLayer(de.DRAW_FRAMEBUFFER,de.COLOR_ATTACHMENT0,Si.__webglTexture,tt,jt+Pn):de.framebufferTexture2D(de.DRAW_FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_2D,Si.__webglTexture,tt),_e!==0?de.blitFramebuffer(ft,wt,Qe,je,Ee,nn,Qe,je,de.COLOR_BUFFER_BIT,de.NEAREST):Rn?de.copyTexSubImage3D(xt,tt,Ee,nn,jt+Pn,ft,wt,Qe,je):de.copyTexSubImage2D(xt,tt,Ee,nn,ft,wt,Qe,je);b.bindFramebuffer(de.READ_FRAMEBUFFER,null),b.bindFramebuffer(de.DRAW_FRAMEBUFFER,null)}else Rn?C.isDataTexture||C.isData3DTexture?de.texSubImage3D(xt,tt,Ee,nn,jt,Qe,je,bt,pn,xn,Sn.data):re.isCompressedArrayTexture?de.compressedTexSubImage3D(xt,tt,Ee,nn,jt,Qe,je,bt,pn,Sn.data):de.texSubImage3D(xt,tt,Ee,nn,jt,Qe,je,bt,pn,xn,Sn):C.isDataTexture?de.texSubImage2D(de.TEXTURE_2D,tt,Ee,nn,Qe,je,pn,xn,Sn.data):C.isCompressedTexture?de.compressedTexSubImage2D(de.TEXTURE_2D,tt,Ee,nn,Sn.width,Sn.height,pn,Sn.data):de.texSubImage2D(de.TEXTURE_2D,tt,Ee,nn,Qe,je,pn,xn,Sn);b.pixelStorei(de.UNPACK_ROW_LENGTH,Vt),b.pixelStorei(de.UNPACK_IMAGE_HEIGHT,dn),b.pixelStorei(de.UNPACK_SKIP_PIXELS,Nt),b.pixelStorei(de.UNPACK_SKIP_ROWS,hi),b.pixelStorei(de.UNPACK_SKIP_IMAGES,rt),tt===0&&re.generateMipmaps&&de.generateMipmap(xt),b.unbindTexture()},this.initRenderTarget=function(C){Se.get(C).__webglFramebuffer===void 0&&Ie.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?Ie.setTextureCube(C,0):C.isData3DTexture?Ie.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?Ie.setTexture2DArray(C,0):Ie.setTexture2D(C,0),b.unbindTexture()},this.resetState=function(){q=0,se=0,F=null,b.reset(),St.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Da}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=mi._getDrawingBufferColorSpace(e),t.unpackColorSpace=mi._getUnpackColorSpace()}};var zc=function(){return zc=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},zc.apply(this,arguments)},Sf=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Bw=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},pr=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},kw={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5126:Float32Array},zw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT4:16},og={POSITION:"position",NORMAL:"normal",COLOR_0:"color",TEXCOORD_0:"uv",JOINTS_0:"skinIndex",WEIGHTS_0:"skinWeight"},lg={33071:Sa,33648:qo,10497:Fs},cg={9728:ir,9729:lr,9984:Cd,9985:hl,9986:mo,9987:Qa};function zr(n){if(!n)throw Error("E_MODEL_CORRUPT")}function Vw(n,e,t){var i,r,a,s=kw[t.componentType],o=zw[t.type];zr(s&&o&&e&&!t.sparse);var u=s.BYTES_PER_ELEMENT,l=o*u,d=(i=e.byteStride)!==null&&i!==void 0?i:l,f=(r=t.byteOffset)!==null&&r!==void 0?r:0,h=((a=e.byteOffset)!==null&&a!==void 0?a:0)+f,m=t.count;zr(Number.isSafeInteger(m)&&m>0&&f>=0&&h>=0&&d>=l&&d%u===0&&h%u===0&&f+(m-1)*d+l<=e.byteLength&&h+(m-1)*d+l<=n.length);var y=new s(n.buffer,n.byteOffset+h,((m-1)*d+l)/u);if(d===l)return new Or(y,o,!!t.normalized);for(var M=new s(m*o),g=0;g<m;g++){var v=g*d/u;M.set(y.subarray(v,v+o),g*o)}return new Or(M,o,!!t.normalized)}function Gw(n,e,t){for(var i="",r=0;r<n.length;r+=8192)i+=String.fromCharCode.apply(String,Bw([],Sf(n.subarray(r,r+8192)),!1));var a=new Image;return a.onload=function(){return t(!0)},a.onerror=function(){return t(!1)},a.src="data:"+e+";base64,"+btoa(i),a}function pg(n,e){var t,i,r,a,s,o,u,l,d,f,h,m,y,M,g,v,L,p,_,N,D,V,w,I,G,H,Q,T,S;zr(n.byteLength>=28&&n.byteLength<=7e5);var Z=new DataView(n.buffer,n.byteOffset,n.byteLength),q=function(et){return Z.getUint32(et,!0)};zr(q(0)===1179937895&&q(4)===2&&q(8)===n.byteLength&&q(16)===1313821514);var se=20+q(12);zr(se%4===0&&se+8<=n.byteLength&&q(se+4)===5130562&&q(se)===n.byteLength-se-8);var F=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n.subarray(20,se)));zr(((y=F.asset)===null||y===void 0?void 0:y.version)==="2.0"&&((M=F.buffers)===null||M===void 0?void 0:M.length)===1&&F.buffers[0].uri===void 0&&((v=(g=F.skins)===null||g===void 0?void 0:g.length)!==null&&v!==void 0?v:0)<=4&&((p=(L=F.animations)===null||L===void 0?void 0:L.length)!==null&&p!==void 0?p:0)<=16);var z=n.subarray(se+8),Y=new Map,$=new Map,he=new Map,pe=new Map,le=new Set,Te=new Set;function De(et){if(!he.has(et)){var Pt=F.accessors[et];he.set(et,Vw(z,F.bufferViews[Pt.bufferView],Pt))}return he.get(et)}function oe(et,Pt){var Ht,cn,an,Ct,Kt,bn,gn,Wt,Qn,Tn,Gn,Hn;if(!et)return null;var Cn=(cn=(Ht=et.extensions)===null||Ht===void 0?void 0:Ht.KHR_texture_transform)!==null&&cn!==void 0?cn:{};zr(((Ct=(an=Cn.texCoord)!==null&&an!==void 0?an:et.texCoord)!==null&&Ct!==void 0?Ct:0)===0);var Wn=JSON.stringify([et.index,Pt,Cn]);if(Y.has(Wn))return Y.get(Wn);var hn=F.textures[et.index],un=F.images[hn.source],An=(bn=(Kt=F.samplers)===null||Kt===void 0?void 0:Kt[hn.sampler])!==null&&bn!==void 0?bn:{},Fn=new Tr;if(Fn.colorSpace=Pt,Fn.flipY=!1,Fn.wrapS=lg[(gn=An.wrapS)!==null&&gn!==void 0?gn:10497],Fn.wrapT=lg[(Wt=An.wrapT)!==null&&Wt!==void 0?Wt:10497],Fn.magFilter=cg[(Qn=An.magFilter)!==null&&Qn!==void 0?Qn:9729],Fn.minFilter=cg[(Tn=An.minFilter)!==null&&Tn!==void 0?Tn:9987],Cn.offset&&Fn.offset.fromArray(Cn.offset),Cn.scale&&Fn.repeat.fromArray(Cn.scale),Fn.rotation=(Gn=Cn.rotation)!==null&&Gn!==void 0?Gn:0,Y.set(Wn,Fn),!$.has(hn.source)){var Vn=F.bufferViews[un.bufferView],jn=(Hn=Vn?.byteOffset)!==null&&Hn!==void 0?Hn:0;zr(Vn&&!un.uri&&["image/png","image/jpeg"].includes(un.mimeType)&&jn+Vn.byteLength<=z.length);var Zn={textures:[],ready:!1,failed:!1};$.set(hn.source,Zn),Zn.image=Gw(z.subarray(jn,jn+Vn.byteLength),un.mimeType,function(re){var Me,ie;if(Zn.ready=!0,Zn.failed=!re,re)try{for(var _e=pr(Zn.textures),tt=_e.next();!tt.done;tt=_e.next()){var Qe=tt.value;Qe.needsUpdate=!0}}catch(je){Me={error:je}}finally{try{tt&&!tt.done&&(ie=_e.return)&&ie.call(_e)}finally{if(Me)throw Me.error}}e?.()})}var C=$.get(hn.source);return Fn.image=C.image,C.textures.push(Fn),C.ready&&!C.failed&&(Fn.needsUpdate=!0),Fn}var ee=new Map;function be(et,Pt){var Ht,cn,an,Ct,Kt,bn,gn,Wt,Qn,Tn,Gn,Hn,Cn,Wn,hn,un,An,Fn,Vn=String(et)+"/"+Pt;if(ee.has(Vn))return ee.get(Vn);var jn=(cn=(Ht=F.materials)===null||Ht===void 0?void 0:Ht[et])!==null&&cn!==void 0?cn:{},Zn=(an=jn.pbrMetallicRoughness)!==null&&an!==void 0?an:{},C=(Ct=Zn.baseColorFactor)!==null&&Ct!==void 0?Ct:[1,1,1,1],re=(Kt=jn.alphaMode)!==null&&Kt!==void 0?Kt:"OPAQUE",Me={name:(bn=jn.name)!==null&&bn!==void 0?bn:"",color:new zn().fromArray(C),vertexColors:Pt,map:oe(Zn.baseColorTexture,wr),side:jn.doubleSided?Br:$a,opacity:re==="OPAQUE"?1:C[3],transparent:re==="BLEND",depthWrite:re!=="BLEND",alphaTest:re==="MASK"?(gn=jn.alphaCutoff)!==null&&gn!==void 0?gn:.5:0},ie;if(!((Wt=jn.extensions)===null||Wt===void 0)&&Wt.KHR_materials_unlit)ie=new sa(Me);else{var _e=oe(Zn.metallicRoughnessTexture,Qr);ie=new ll(zc(zc({},Me),{roughness:(Qn=Zn.roughnessFactor)!==null&&Qn!==void 0?Qn:1,metalness:(Tn=Zn.metallicFactor)!==null&&Tn!==void 0?Tn:1,roughnessMap:_e,metalnessMap:_e,normalMap:oe(jn.normalTexture,Qr),normalScale:new tn().setScalar((Hn=(Gn=jn.normalTexture)===null||Gn===void 0?void 0:Gn.scale)!==null&&Hn!==void 0?Hn:1),aoMap:oe(jn.occlusionTexture,Qr),aoMapIntensity:(Wn=(Cn=jn.occlusionTexture)===null||Cn===void 0?void 0:Cn.strength)!==null&&Wn!==void 0?Wn:1,emissive:new zn().fromArray((hn=jn.emissiveFactor)!==null&&hn!==void 0?hn:[0,0,0]),emissiveMap:oe(jn.emissiveTexture,wr),emissiveIntensity:(Fn=(An=(un=jn.extensions)===null||un===void 0?void 0:un.KHR_materials_emissive_strength)===null||An===void 0?void 0:An.emissiveStrength)!==null&&Fn!==void 0?Fn:1})),ie.normalScale.y*=-1}return Te.add(ie),ee.set(Vn,ie),ie}var Be=F.meshes.map(function(et){return et.primitives.map(function(Pt){var Ht,cn,an;zr(((an=Pt.mode)!==null&&an!==void 0?an:4)===4&&Pt.attributes.POSITION!==void 0&&!Pt.targets);var Ct=new ur;try{for(var Kt=pr(Object.entries(Pt.attributes)),bn=Kt.next();!bn.done;bn=Kt.next()){var gn=Sf(bn.value,2),Wt=gn[0],Qn=gn[1];zr(Object.hasOwn(og,Wt)),Ct.setAttribute(og[Wt],De(Qn))}}catch(Tn){Ht={error:Tn}}finally{try{bn&&!bn.done&&(cn=Kt.return)&&cn.call(Kt)}finally{if(Ht)throw Ht.error}}return Pt.indices!==void 0&&Ct.setIndex(De(Pt.indices)),Ct.attributes.normal||Ct.computeVertexNormals(),le.add(Ct),{geo:Ct,mat:be(Pt.material,!!Ct.attributes.color)}})}),Re=new Set;try{for(var Ye=pr((_=F.skins)!==null&&_!==void 0?_:[]),nt=Ye.next();!nt.done;nt=Ye.next()){var Ge=nt.value;try{for(var $e=(r=void 0,pr((N=Ge.joints)!==null&&N!==void 0?N:[])),mt=$e.next();!mt.done;mt=$e.next()){var at=mt.value;Re.add(at)}}catch(et){r={error:et}}finally{try{mt&&!mt.done&&(a=$e.return)&&a.call($e)}finally{if(r)throw r.error}}}}catch(et){t={error:et}}finally{try{nt&&!nt.done&&(i=Ye.return)&&i.call(Ye)}finally{if(t)throw t.error}}var Ve=new or,Yt=new Set,st=new Map,Dt=[];function on(et,Pt){var Ht,cn,an,Ct,Kt,bn;zr(!Yt.has(et)&&Yt.size<128),Yt.add(et);var gn=F.nodes[et],Wt=Re.has(et)?new el:new or;if(Wt.name=(Kt=gn.name)!==null&&Kt!==void 0?Kt:"",Wt.userData.gltfNodeIndex=et,st.set(et,Wt),Wt.name&&!pe.has(Wt.name)&&pe.set(Wt.name,Wt),gn.matrix?Wt.matrix.fromArray(gn.matrix).decompose(Wt.position,Wt.quaternion,Wt.scale):(gn.translation&&Wt.position.fromArray(gn.translation),gn.rotation&&Wt.quaternion.fromArray(gn.rotation),gn.scale&&Wt.scale.fromArray(gn.scale)),Pt.add(Wt),gn.mesh!==void 0)try{for(var Qn=pr(Be[gn.mesh]),Tn=Qn.next();!Tn.done;Tn=Qn.next()){var Gn=Tn.value,Hn=Gn.geo,Cn=Gn.mat;if(gn.skin!==void 0){var Wn=new oc(Hn,Cn);Wn.userData.gltfSkinIndex=gn.skin,Wt.add(Wn),Dt.push(Wn)}else Wt.add(new _i(Hn,Cn))}}catch(Fn){Ht={error:Fn}}finally{try{Tn&&!Tn.done&&(cn=Qn.return)&&cn.call(Qn)}finally{if(Ht)throw Ht.error}}try{for(var hn=pr((bn=gn.children)!==null&&bn!==void 0?bn:[]),un=hn.next();!un.done;un=hn.next()){var An=un.value;on(An,Wt)}}catch(Fn){an={error:Fn}}finally{try{un&&!un.done&&(Ct=hn.return)&&Ct.call(hn)}finally{if(an)throw an.error}}}try{for(var de=pr((V=F.scenes[(D=F.scene)!==null&&D!==void 0?D:0].nodes)!==null&&V!==void 0?V:[]),wn=de.next();!wn.done;wn=de.next()){var Mn=wn.value;on(Mn,Ve)}}catch(et){s={error:et}}finally{try{wn&&!wn.done&&(o=de.return)&&o.call(de)}finally{if(s)throw s.error}}Ve.updateMatrixWorld(!0);var K=((w=F.skins)!==null&&w!==void 0?w:[]).map(function(et){var Pt,Ht=(Pt=et.joints)!==null&&Pt!==void 0?Pt:[];zr(Ht.length>0&&Ht.length<=64);var cn;if(et.inverseBindMatrices!==void 0){var an=De(et.inverseBindMatrices).array;cn=Array.from({length:Ht.length},function(Ct,Kt){return new Kn().fromArray(an,Kt*16)})}else cn=Ht.map(function(){return new Kn});return{joints:Ht,inverseBindMatrices:cn}});try{for(var b=pr(Dt),ne=b.next();!ne.done;ne=b.next()){var Se=ne.value,Ie=K[Se.userData.gltfSkinIndex];zr(Ie);var Xe=Ie.joints.map(function(et){return st.get(et)});zr(Xe.every(Boolean)),Se.bind(new tl(Xe,Ie.inverseBindMatrices.map(function(et){return et.clone()})),new Kn)}}catch(et){u={error:et}}finally{try{ne&&!ne.done&&(l=b.return)&&l.call(b)}finally{if(u)throw u.error}}var qe=[],Le=new Map;try{for(var Pe=pr(((I=F.animations)!==null&&I!==void 0?I:[]).entries()),lt=Pe.next();!lt.done;lt=Pe.next()){var Mt=Sf(lt.value,2),yt=Mt[0],it=Mt[1],Gt=it.name||"clip_"+yt,Zt=[],Ke=0;try{for(var fe=(h=void 0,pr((G=it.channels)!==null&&G!==void 0?G:[])),We=fe.next();!We.done;We=fe.next()){var ze=We.value,ht=(H=ze.target)===null||H===void 0?void 0:H.node,St=(Q=ze.target)===null||Q===void 0?void 0:Q.path;if(!(ht===void 0||!["translation","rotation","scale"].includes(St))){var He=(T=it.samplers)===null||T===void 0?void 0:T[ze.sampler];zr(He);var qt=(S=He.interpolation)!==null&&S!==void 0?S:"LINEAR";zr(qt==="LINEAR"||qt==="STEP");var Tt=De(He.input).array,pt=De(He.output).array;Tt.length&&(Ke=Math.max(Ke,Tt[Tt.length-1])),Zt.push({nodeIndex:ht,path:St,interp:qt,times:Tt,values:pt})}}}catch(et){h={error:et}}finally{try{We&&!We.done&&(m=fe.return)&&m.call(fe)}finally{if(h)throw h.error}}var Lt={name:Gt,duration:Ke,tracks:Zt};qe.push(Lt),Le.has(Gt)||Le.set(Gt,Lt)}}catch(et){d={error:et}}finally{try{lt&&!lt.done&&(f=Pe.return)&&f.call(Pe)}finally{if(d)throw d.error}}return{root:Ve,nodesByName:pe,skins:K,animations:qe,animationsByName:Le,geometries:le,materials:Te,textures:Y,imageStatus:function(){var et,Pt,Ht=0,cn=0;try{for(var an=pr($.values()),Ct=an.next();!Ct.done;Ct=an.next()){var Kt=Ct.value;Kt.ready||Ht++,Kt.failed&&cn++}}catch(bn){et={error:bn}}finally{try{Ct&&!Ct.done&&(Pt=an.return)&&Pt.call(an)}finally{if(et)throw et.error}}return{texturesPending:Ht,textureErrors:cn}}}}function Hw(n,e,t){var i,r,a,s,o,u,l,d,f,h,m,y,M=(o=e.materialMode)!==null&&o!==void 0?o:"asset",g=!e.overrideMaterialName||n.name===e.overrideMaterialName,v=g&&Object.keys(t).length>0;if(M==="asset"&&!v&&((u=e.opacity)!==null&&u!==void 0?u:1)===1&&(!e.tintColor||e.tintColor==="#ffffff")&&((l=e.roughnessScale)!==null&&l!==void 0?l:1)===1&&((d=e.metalnessScale)!==null&&d!==void 0?d:1)===1)return n;var L={lambert:dr,unlit:sa,standard:ll}[M],p;if(!L||n.constructor===L)p=n.clone();else{p=new L;try{for(var _=pr(["name","map","alphaTest","transparent","opacity","side","depthWrite","vertexColors","roughness","metalness","roughnessMap","metalnessMap","normalMap","aoMap","aoMapIntensity","emissiveMap","emissiveIntensity"]),N=_.next();!N.done;N=_.next()){var D=N.value;D in p&&D in n&&(p[D]=n[D])}}catch(I){i={error:I}}finally{try{N&&!N.done&&(r=_.return)&&r.call(_)}finally{if(i)throw i.error}}try{for(var V=pr(["color","emissive","normalScale"]),w=V.next();!w.done;w=V.next()){var D=w.value;p[D]&&n[D]&&p[D].copy(n[D])}}catch(I){a={error:I}}finally{try{w&&!w.done&&(s=V.return)&&s.call(V)}finally{if(a)throw a.error}}}return e.tintColor&&p.color.multiply(new zn(e.tintColor)),p.opacity*=(f=e.opacity)!==null&&f!==void 0?f:1,p.opacity<1&&((h=e.opacity)!==null&&h!==void 0?h:1)<1&&(p.transparent=!0,p.depthWrite=!1),p.isMeshStandardMaterial&&(p.roughness=Math.min(1,p.roughness*((m=e.roughnessScale)!==null&&m!==void 0?m:1)),p.metalness=Math.min(1,p.metalness*((y=e.metalnessScale)!==null&&y!==void 0?y:1))),v&&(t.texture&&(p.map=t.texture),t.normalMap&&"normalMap"in p&&(p.normalMap=t.normalMap),t.emissiveMap&&"emissiveMap"in p&&(p.emissiveMap=t.emissiveMap)),p}function mg(n,e,t){var i,r,a;e===void 0&&(e={}),t===void 0&&(t={});var s=e.subNode?n.nodesByName.get(e.subNode):n.root;if(!s)throw Error("E_MODEL_SUBNODE "+e.subNode);var o=s.clone(!0),u=new or,l=new Map;if(e.subNode&&(o.position.set(0,0,0),s.parent)){var d=s.parent.matrixWorld.clone().setPosition(0,0,0);o.updateMatrix(),o.matrix.premultiply(d),o.matrixAutoUpdate=!1}u.add(o);var f=new Map,h=[];if(o.traverse(function(D){var V,w;if(((V=D.userData)===null||V===void 0?void 0:V.gltfNodeIndex)!==void 0&&f.set(D.userData.gltfNodeIndex,D),!!D.isMesh){var I=D.material;l.has(I)||l.set(I,Hw(I,e,t)),D.material=l.get(I),D.castShadow=!!e.castShadow,D.receiveShadow=!!e.receiveShadow,D.isSkinnedMesh&&((w=D.userData)===null||w===void 0?void 0:w.gltfSkinIndex)!==void 0&&h.push(D)}}),h.length){u.updateMatrixWorld(!0);try{for(var m=pr(h),y=m.next();!y.done;y=m.next()){var M=y.value,g=(a=n.skins)===null||a===void 0?void 0:a[M.userData.gltfSkinIndex];if(g){var v=g.joints.map(function(D){return f.get(D)}).filter(Boolean);v.length===g.joints.length&&M.bind(new tl(v,g.inverseBindMatrices.map(function(D){return D.clone()})),new Kn)}}}catch(D){i={error:D}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(i)throw i.error}}}u.userData.clonedByIndex=f,u.userData.template=n;var L=new Jr().setFromObject(u,!0);if(!L.isEmpty()){var p=L.getSize(new xe),_=new xe,N=Math.max(p.x,p.y,p.z);(e.pivotMode==="center"||e.pivotMode==="bottom-center")&&(L.getCenter(_),e.pivotMode==="bottom-center"&&(_.y=L.min.y)),e.normalizeSize>0&&N>0&&u.scale.setScalar(e.normalizeSize/N),u.position.copy(_).multiplyScalar(-u.scale.x),u.userData.modelBounds={width:p.x*u.scale.x,height:p.y*u.scale.y,depth:p.z*u.scale.z}}return u}var Xp=new xe,ug=new xe,Yp=new ra,dg=new ra;function fg(n,e,t,i){var r=n.times,a=n.values,s=r.length,o=n.path==="rotation"?4:3;if(s!==0){var u=0,l=0,d=0;if(s>1&&e>r[0])if(e>=r[s-1])u=l=s-1;else{for(var f=0,h=s-1;f+1<h;){var m=f+h>>1;r[m]<=e?f=m:h=m}u=f,l=h,d=n.interp==="STEP"?0:(e-r[u])/Math.max(1e-8,r[l]-r[u])}var y=u*o,M=l*o;if(n.path==="rotation"){if(Yp.set(a[y],a[y+1],a[y+2],a[y+3]),u===l||d===0){i.copy(Yp);return}dg.set(a[M],a[M+1],a[M+2],a[M+3]),i.copy(Yp).slerp(dg,d)}else{if(Xp.set(a[y],a[y+1],a[y+2]),u===l||d===0){t.copy(Xp);return}ug.set(a[M],a[M+1],a[M+2]),t.copy(Xp).lerp(ug,d)}}}function hg(n,e,t){if(e<=0)return 0;if(t==="once")return Math.min(e,Math.max(0,n));if(t==="pingpong"){var i=e*2,r=(n%i+i)%i;return r<=e?r:i-r}return(n%e+e)%e}function vg(n){var e,t,i,r,a,s,o,u=(a=n?.userData)===null||a===void 0?void 0:a.template,l=(s=n?.userData)===null||s===void 0?void 0:s.clonedByIndex;if(!(!((o=u?.animations)===null||o===void 0)&&o.length)||!l)return null;var d=new Map;try{for(var f=pr(u.animations),h=f.next();!h.done;h=f.next()){var m=h.value;try{for(var y=(i=void 0,pr(m.tracks)),M=y.next();!M.done;M=y.next()){var g=M.value,v=l.get(g.nodeIndex);v&&!d.has(g.nodeIndex)&&d.set(g.nodeIndex,{pos:v.position.clone(),quat:v.quaternion.clone(),scl:v.scale.clone()})}}catch(G){i={error:G}}finally{try{M&&!M.done&&(r=y.return)&&r.call(y)}finally{if(i)throw i.error}}}}catch(G){e={error:G}}finally{try{h&&!h.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}var L=function(){var G,H;try{for(var Q=pr(d),T=Q.next();!T.done;T=Q.next()){var S=Sf(T.value,2),Z=S[0],q=S[1],se=l.get(Z);se&&(se.position.copy(q.pos),se.quaternion.copy(q.quat),se.scale.copy(q.scl))}}catch(F){G={error:F}}finally{try{T&&!T.done&&(H=Q.return)&&H.call(Q)}finally{if(G)throw G.error}}},p=null,_=null,N=0,D=0,V=new xe,w=new ra,I=function(){var G,H,Q,T;L();var S=_&&D>0?Math.min(1,N/D):1;if(_&&S<1){var Z=hg(_.time,_.clip.duration,_.loop);try{for(var q=pr(_.clip.tracks),se=q.next();!se.done;se=q.next()){var F=se.value,z=l.get(F.nodeIndex);z&&(fg(F,Z,V,w),F.path==="translation"?z.position.copy(V):F.path==="rotation"?z.quaternion.copy(w):F.path==="scale"&&z.scale.copy(V))}}catch(pe){G={error:pe}}finally{try{se&&!se.done&&(H=q.return)&&H.call(q)}finally{if(G)throw G.error}}}if(p){var Y=hg(p.time,p.clip.duration,p.loop);try{for(var $=pr(p.clip.tracks),he=$.next();!he.done;he=$.next()){var F=he.value,z=l.get(F.nodeIndex);z&&(fg(F,Y,V,w),F.path==="translation"?S<1?z.position.lerp(V,S):z.position.copy(V):F.path==="rotation"?S<1?z.quaternion.slerp(w,S):z.quaternion.copy(w):F.path==="scale"&&(S<1?z.scale.lerp(V,S):z.scale.copy(V)))}}catch(pe){Q={error:pe}}finally{try{he&&!he.done&&(T=$.return)&&T.call($)}finally{if(Q)throw Q.error}}}};return{play:function(G,H){var Q=H===void 0?{}:H,T=Q.loop,S=T===void 0?"repeat":T,Z=Q.speed,q=Z===void 0?1:Z,se=Q.fadeSeconds,F=se===void 0?.15:se,z=Q.restart,Y=z===void 0?!1:z,$=Q.startTime,he=$===void 0?0:$,pe=G?u.animationsByName.get(G):u.animations[0];return pe?p?.clip===pe&&!Y&&p.playing?(p.loop=S,p.speed=q,!0):(_=p&&F>0?zc({},p):null,D=_?F:0,N=0,p={clip:pe,loop:S,speed:q,time:he,playing:!0,ended:!1},I(),!0):!1},step:function(G,H){if(!p||!p.playing)return!1;var Q=Math.max(0,G);_&&D>0&&(_.time+=Q*_.speed,N+=Q,N>=D&&(_=null,D=0)),p.time+=Q*p.speed;var T=null;return p.loop==="once"&&p.clip.duration>0&&p.time>=p.clip.duration&&(p.time=p.clip.duration,p.playing=!1,p.ended||(p.ended=!0,T=p.clip.name)),I(),T&&H?.(T),!0},reset:function(){p=null,_=null,N=0,D=0,L()},snapshot:function(){var G,H,Q;return{clip:(H=(G=p?.clip)===null||G===void 0?void 0:G.name)!==null&&H!==void 0?H:null,time:p?Number(p.time.toFixed(4)):0,playing:!!p?.playing,loop:(Q=p?.loop)!==null&&Q!==void 0?Q:"repeat",clips:u.animations.map(function(T){return T.name})}}}}var Vc=function(){return Vc=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Vc.apply(this,arguments)},vn=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Oa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},gg=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function xg(n,e,t,i){for(var r,a,s,o,u,l,d,f=new xe,h=new xe,m=new ba,y=n;y?.contract==="native.mesh3d.v1";y=e(y.parentId)){var M=t(y),g=i.get(y.id),v=g?.mode==="dynamic",L=v&&g.captured,p=L?Math.min(1,((r=g.captureElapsed)!==null&&r!==void 0?r:0)/.55):0,_=g?.captureTarget,N=1-p*.65;h.set(M.sx*N,M.sy*N,M.sz*N),m.set(v?-((a=g.spin)!==null&&a!==void 0?a:0):M.rx,g?.mode==="kinematic"?-((s=g.angle)!==null&&s!==void 0?s:M.ry):M.ry,v?((o=g.spin)!==null&&o!==void 0?o:0)*.22:M.rz),f.multiply(h).applyEuler(m),h.set(((u=g?.x)!==null&&u!==void 0?u:M.x)+(L&&_?(_.x-g.x)*p:0),((l=g?.y)!==null&&l!==void 0?l:M.y)-p*.45,((d=g?.z)!==null&&d!==void 0?d:M.z)+(L&&_?(_.z-g.z)*p:0)),f.add(h)}return{x:f.x,y:f.y,z:f.z}}function Ww(n){for(var e=atob(n),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);for(var r=new DataView(t.buffer,t.byteOffset,t.byteLength),a=r.getUint32(8,!0),s=r.getUint32(12,!0),o=new Float32Array(a*3),u=new Float32Array(a*3),l=new Float32Array(a*2),d=16,i=0;i<a;i++)o[i*3]=r.getFloat32(d,!0),o[i*3+1]=r.getFloat32(d+4,!0),o[i*3+2]=r.getFloat32(d+8,!0),u[i*3]=r.getFloat32(d+12,!0),u[i*3+1]=r.getFloat32(d+16,!0),u[i*3+2]=r.getFloat32(d+20,!0),l[i*2]=r.getFloat32(d+24,!0),l[i*2+1]=r.getFloat32(d+28,!0),d+=32;for(var f=new Uint16Array(s),i=0;i<s;i++)f[i]=r.getUint16(d+i*2,!0);var h=new ur;return h.setAttribute("position",new Ci(o,3)),h.setAttribute("normal",new Ci(u,3)),h.setAttribute("uv",new Ci(l,2)),h.setIndex(Array.from(f)),h}function yg(n,e,t){return!n||t>=1?0:t<=-1?1.1:(1-t)*.55}function Xw(n,e,t){var i,r,a,s,o,u,l,d,f,h,m,y,M,g,v,L,p,_=new or,N=!!n.fairwayRamp,D=(M=n.cupX)!==null&&M!==void 0?M:0,V=(g=n.cupZ)!==null&&g!==void 0?g:-4.8,w=(v=n.cupRadius)!==null&&v!==void 0?v:.23,I=new $r(1,1,1),G=new Map,H=function(Pe,lt,Mt,yt,it,Gt,Zt){var Ke=G.get(Zt);Ke||(Ke=new dr({color:Zt}),G.set(Zt,Ke));var fe=new _i(I,Ke);fe.position.set(Pe,lt,Mt),fe.scale.set(yt,it,Gt),_.add(fe)};try{for(var Q=vn([-3.2,3.2]),T=Q.next();!T.done;T=Q.next()){var S=T.value;H(S,-.65,0,.2,1.1,14.6,"#a1b8b1"),H(S-Math.sign(S)*.1,-.18,0,.2,.25,14.4,"#e9cea5")}}catch(Pe){i={error:Pe}}finally{try{T&&!T.done&&(r=Q.return)&&r.call(Q)}finally{if(i)throw i.error}}try{for(var Z=vn([-7.2,7.2]),q=Z.next();!q.done;q=Z.next()){var se=q.value;H(0,-.65,se,6.4,1.1,.2,"#a1b8b1"),H(0,-.18,se-Math.sign(se)*.1,6.2,.25,.2,"#e9cea5")}}catch(Pe){a={error:Pe}}finally{try{q&&!q.done&&(s=Z.return)&&s.call(Z)}finally{if(a)throw a.error}}var F=.5,z=.5;if(t){var Y=t.getAttribute("uv"),$=t.getAttribute("normal");if(Y&&$){for(var he=0;he<$.count&&$.getY(he)<.9;)he++;he<Y.count&&(F=Y.getX(he),z=Y.getY(he))}}var pe=!!(e&&(!((L=e.image)===null||L===void 0)&&L.complete)&&((p=e.image)===null||p===void 0?void 0:p.naturalWidth)>0),le=pe?new dr({map:e}):new dr({color:"#6ec458"}),Te=pe?new dr({map:e,color:"#779263"}):new dr({color:"#5a9949"});e&&!pe&&(le.userData.pendingTex={tex:e,color:"#ffffff"},Te.userData.pendingTex={tex:e,color:"#779263"});var De=N?[[-7,-1],[-1,1],[1,7]]:[[-7,7]];try{for(var oe=vn(De),ee=oe.next();!ee.done;ee=oe.next()){var be=Oa(ee.value,2),Be=be[0],Re=be[1],Ye=new al;if(Ye.moveTo(-3,Be),Ye.lineTo(3,Be),Ye.lineTo(3,Re),Ye.lineTo(-3,Re),Ye.closePath(),V>Be&&V<Re){var nt=new uo;nt.absarc(D,V,w,0,Math.PI*2,!0),Ye.holes.push(nt)}for(var Ge=new xc(Ye,32),$e=Ge.getAttribute("position"),mt=!1,at=!1,Ve=0;Ve<$e.count;Ve++){var Yt=$e.getX(Ve),st=$e.getY(Ve),Dt=yg(N,Yt,st);Dt===0&&(mt=!0),Dt>0&&(at=!0),$e.setXYZ(Ve,Yt,Dt,st)}var on=Ge.getIndex();if(on)for(var Ve=0;Ve<on.count;Ve+=3){var de=on.getX(Ve+1);on.setX(Ve+1,on.getX(Ve+2)),on.setX(Ve+2,de)}Ge.computeVertexNormals();for(var wn=Ge.getAttribute("uv"),Ve=0;Ve<wn.count;Ve++)wn.setXY(Ve,F,z);var Mn=new _i(Ge,N&&mt&&at?Te:le);Mn.name="continuous-fairway",_.add(Mn)}}catch(Pe){o={error:Pe}}finally{try{ee&&!ee.done&&(u=oe.return)&&u.call(oe)}finally{if(o)throw o.error}}var K="#d69260",b="#f1bd87";try{for(var ne=vn([-3.1,3.1]),Se=ne.next();!Se.done;Se=ne.next()){var S=Se.value;H(S,.12,0,.2,.3,14.2,K),H(S,.29,0,.22,.04,14.2,b)}}catch(Pe){l={error:Pe}}finally{try{Se&&!Se.done&&(d=ne.return)&&d.call(ne)}finally{if(l)throw l.error}}try{for(var Ie=vn([-7.1,7.1]),Xe=Ie.next();!Xe.done;Xe=Ie.next()){var se=Xe.value;H(0,yg(N,0,se>0?6:-6)+.12,se,6.4,.3,.2,K)}}catch(Pe){f={error:Pe}}finally{try{Xe&&!Xe.done&&(h=Ie.return)&&h.call(Ie)}finally{if(f)throw f.error}}if(N)try{for(var qe=vn([-3.1,3.1]),Le=qe.next();!Le.done;Le=qe.next()){var S=Le.value;H(S,.7,-4.5,.2,1.1,5.2,K)}}catch(Pe){m={error:Pe}}finally{try{Le&&!Le.done&&(y=qe.return)&&y.call(qe)}finally{if(m)throw m.error}}return _}function Yw(n){var e,t=new or,i=(e=n.cupRadius)!==null&&e!==void 0?e:.23,r=new _i(new co(i,i*.89,.48,24,1,!0),new dr({color:"#244640",side:Br}));r.position.y=-.24,t.add(r);var a=new _i(new il(i*.91,24),new sa({color:"#082c2b"}));a.rotation.x=-Math.PI/2,a.position.y=-.475,t.add(a);var s=new _i(new co(i,i*.978,.09,24,1,!0),new dr({color:"#eee9cf",side:Br}));s.position.y=-.045,t.add(s);var o=new _i(new ol(i,i+.06,24),new dr({color:"#fff7d1"}));return o.rotation.x=-Math.PI/2,o.position.y=.004,t.add(o),t}function qw(){for(var n,e,t=new or,i=new $r(.18,1,.18),r=new dr({color:"#b27b59"}),a=new $r(1.5,.2,1.6),s=new dr({color:"#82b88b"}),o=new xs(.62,7,5),u=new xs(.49,7,5),l=new dr({color:"#77b86b"}),d=new dr({color:"#3e9d79"}),f=new Na(i,r,14),h=new Na(a,s,14),m=5,y=9,M=new Na(o,l,m),g=new Na(u,l,m),v=new Na(o,d,y),L=new Na(u,d,y),p=new Kn,_=0,N=0,D=0;D<14;D++){var V=D%2?-1:1,w=V*(3.8+D%3*.35),I=-6.5+Math.floor(D/2)*2;p.makeTranslation(w,-.02,I),f.setMatrixAt(D,p),p.makeTranslation(w,-.48,I),h.setMatrixAt(D,p),D%3===0?(p.makeTranslation(w,.5,I),M.setMatrixAt(_,p),p.makeTranslation(w,1,I),g.setMatrixAt(_,p),_++):(p.makeTranslation(w,.5,I),v.setMatrixAt(N,p),p.makeTranslation(w,1,I),L.setMatrixAt(N,p),N++)}try{for(var G=vn([f,h,M,g,v,L]),H=G.next();!H.done;H=G.next()){var Q=H.value;Q.instanceMatrix.needsUpdate=!0,t.add(Q)}}catch(T){n={error:T}}finally{try{H&&!H.done&&(e=G.return)&&e.call(G)}finally{if(n)throw n.error}}return t}function Zw(n,e,t){for(var i=n.getAttribute("position"),r=0;r<i.count;r++){var a=e[r*3],s=e[r*3+1],o=e[r*3+2],u=s>.7?Math.max(0,Math.min(1,(-a-.035)/.32)):0;i.setXYZ(r,a,s+Math.sin(t*3.2+a*10)*.018*u,o+Math.sin(t*3.2+a*10+s*2)*.07*u)}i.needsUpdate=!0,n.computeVertexNormals()}function Jw(n){for(var e=64,t=32,i=new Uint8Array(e*t*4),r=0;r<t;r++)for(var a=r/(t-1),s=0;s<e;s++){var o=s/e,u=(r*e+s)*4,l=Math.exp(-(Math.pow(o-.35,2)/.012+Math.pow(a-.7,2)/.018)),d=Math.exp(-(Math.pow(o-.79,2)/.004+Math.pow(a-.58,2)/.055));i[u]=Math.min(255,21+a*90+l*180+d*125),i[u+1]=Math.min(255,22+a*105+l*158+d*145),i[u+2]=Math.min(255,24+a*127+l*128+d*180),i[u+3]=255}var f=new Os(i,e,t);f.mapping=fl,f.needsUpdate=!0;var h=new xl(n);try{return h.fromEquirectangular(f)}finally{h.dispose(),f.dispose()}}function _g(n,e,t,i){i===void 0&&(i=new Map);var r=new Map,a=new Map,s=new Map,o=new Set,u=new Set,l;function d(){var F,z;try{for(var Y=vn(m.values()),$=Y.next();!$.done;$=Y.next()){var he=$.value;he.textureDirty=!0}}catch(pe){F={error:pe}}finally{try{$&&!$.done&&(z=Y.return)&&z.call(Y)}finally{if(F)throw F.error}}t?.()}function f(F){var z,Y,$,he,pe,le,Te;if(!s.has((pe=F.hash)!==null&&pe!==void 0?pe:F.id)){var De=Uint8Array.from(atob(F.data),function(Ge){return Ge.charCodeAt(0)}),oe=pg(De,d);try{for(var ee=vn(oe.geometries),be=ee.next();!be.done;be=ee.next()){var Be=be.value;o.add(Be)}}catch(Ge){z={error:Ge}}finally{try{be&&!be.done&&(Y=ee.return)&&Y.call(ee)}finally{if(z)throw z.error}}try{for(var Re=vn(oe.materials),Ye=Re.next();!Ye.done;Ye=Re.next()){var nt=Ye.value;u.add(nt)}}catch(Ge){$={error:Ge}}finally{try{Ye&&!Ye.done&&(he=Re.return)&&he.call(Re)}finally{if($)throw $.error}}s.set((le=F.hash)!==null&&le!==void 0?le:F.id,oe)}return s.get((Te=F.hash)!==null&&Te!==void 0?Te:F.id)}function h(F){var z,Y,$,he,pe=new Set,le=new Set;F.traverse(function(Re){var Ye,nt;if(Re.geometry&&!o.has(Re.geometry)&&pe.add(Re.geometry),Re.material)try{for(var Ge=vn(Array.isArray(Re.material)?Re.material:[Re.material]),$e=Ge.next();!$e.done;$e=Ge.next()){var mt=$e.value;u.has(mt)||le.add(mt)}}catch(at){Ye={error:at}}finally{try{$e&&!$e.done&&(nt=Ge.return)&&nt.call(Ge)}finally{if(Ye)throw Ye.error}}});try{for(var Te=vn(pe),De=Te.next();!De.done;De=Te.next()){var oe=De.value;oe.dispose()}}catch(Re){z={error:Re}}finally{try{De&&!De.done&&(Y=Te.return)&&Y.call(Te)}finally{if(z)throw z.error}}try{for(var ee=vn(le),be=ee.next();!be.done;be=ee.next()){var Be=be.value;Be.dispose()}}catch(Re){$={error:Re}}finally{try{be&&!be.done&&(he=ee.return)&&he.call(ee)}finally{if($)throw $.error}}}var m=new Map,y,M,g,v,L;function p(){var F,z;if(M!==void 0)return M;try{return y=document.createElement("canvas"),(F=y.addEventListener)===null||F===void 0||F.call(y,"webglcontextrestored",function(){var Y,$;L=void 0;try{for(var he=vn(m.values()),pe=he.next();!pe.done;pe=he.next()){var le=pe.value;le.compiled=!1,le.textureDirty=!0,le.lastRenderedTime=-1,le.lastFlagStep=-1}}catch(Te){Y={error:Te}}finally{try{pe&&!pe.done&&($=he.return)&&$.call(he)}finally{if(Y)throw Y.error}}t?.()}),g=document.createElement("canvas"),v=(z=g.getContext)===null||z===void 0?void 0:z.call(g,"2d"),M=new xf({canvas:y,antialias:!0,alpha:!1,preserveDrawingBuffer:!1,powerPreference:"default"}),M.shadowMap.type=Ad,M}catch{return M=null,null}}function _(F){if(F){if(r.has(F))return r.get(F);var z=e.get(F);if(!(!z||z.mime!=="model/tora-mesh"||!z.data)){var Y=Ww(z.data);return r.set(F,Y),o.add(Y),Y}}}function N(F,z){if(F){var Y=(z??"stage")+":"+F;if(a.has(Y))return a.get(Y);var $=e.get(F);if(!(!$||!$.mime.startsWith("image/")||!$.data)){var he=new Image,pe=new Tr(he);pe.colorSpace=z==="normalMap"?Qr:wr,z&&(pe.flipY=!1,pe.wrapS=pe.wrapT=Fs);var le=function(Te){var De,oe;pe.needsUpdate=!0;try{for(var ee=vn(m.values()),be=ee.next();!be.done;be=ee.next()){var Be=be.value;Be.scene.traverse(function(Re){var Ye,nt,Ge,$e=Re.isMesh&&Re.material?Array.isArray(Re.material)?Re.material:[Re.material]:[];try{for(var mt=(Ye=void 0,vn($e)),at=mt.next();!at.done;at=mt.next()){var Ve=at.value;!((Ge=Ve.userData)===null||Ge===void 0)&&Ge.pendingTex&&Ve.userData.pendingTex.tex===pe&&(Ve.map=pe,Ve.color.set(Ve.userData.pendingTex.color||"#ffffff"),delete Ve.userData.pendingTex,Ve.needsUpdate=!0)}}catch(Yt){Ye={error:Yt}}finally{try{at&&!at.done&&(nt=mt.return)&&nt.call(mt)}finally{if(Ye)throw Ye.error}}}),Be.textureDirty=!0}}catch(Re){De={error:Re}}finally{try{be&&!be.done&&(oe=ee.return)&&oe.call(ee)}finally{if(De)throw De.error}}Te&&t?.()};return a.set(Y,pe),he.onload=function(){return le(!0)},he.src="data:"+$.mime+";base64,"+$.data,he.complete&&he.naturalWidth&&le(!1),pe}}}function D(F){var z,Y,$,he,pe,le,Te,De,oe,ee,be,Be,Re,Ye,nt,Ge,$e,mt,at,Ve,Yt=F.parameters,st=new rc;st.background=new zn(Yt.skyColor||"#b8e2ed");var Dt=new Fr(($=Yt.cameraFov)!==null&&$!==void 0?$:39,1,.1,160);Dt.position.set((he=Yt.cameraX)!==null&&he!==void 0?he:10,(pe=Yt.cameraY)!==null&&pe!==void 0?pe:18,(le=Yt.cameraZ)!==null&&le!==void 0?le:21),Dt.lookAt((Te=Yt.lookAtX)!==null&&Te!==void 0?Te:0,(De=Yt.lookAtY)!==null&&De!==void 0?De:.15,(oe=Yt.lookAtZ)!==null&&oe!==void 0?oe:0),st.add(Dt),st.add(new Sc(Yt.hemiSkyColor||"#fff9dd",Yt.hemiGroundColor||"#527b75",(ee=Yt.hemiIntensity)!==null&&ee!==void 0?ee:1.8));var on=new wc(Yt.sunColor||"#fff0cf",(be=Yt.sunIntensity)!==null&&be!==void 0?be:2.1);on.position.set((Be=Yt.sunX)!==null&&Be!==void 0?Be:-9,(Re=Yt.sunY)!==null&&Re!==void 0?Re:18,(Ye=Yt.sunZ)!==null&&Ye!==void 0?Ye:8),st.add(on),on.shadow.camera.left=on.shadow.camera.bottom=-16,on.shadow.camera.right=on.shadow.camera.top=16,on.shadow.camera.far=100,on.shadow.camera.updateProjectionMatrix();var de=N((Ge=(nt=F.assetSlots)===null||nt===void 0?void 0:nt[0])===null||Ge===void 0?void 0:Ge.assetId),wn=new Map,Mn=new Map,K=[],b=[],ne=new Map;function Se(pt,Lt,et,Pt,Ht,cn){cn===void 0&&(cn=!1),pt.traverse(function(an){an.userData.toraRootId=Lt,an.userData.toraSourceId=et,Ht&&(an.userData.toraNodeId=Ht),Pt&&(an.userData.cameraAttached=!0),cn&&(an.userData.isDropShadow=!0)})}function Ie(pt,Lt,et,Pt,Ht){var cn,an,Ct,Kt,bn,gn,Wt,Qn,Tn,Gn,Hn,Cn,Wn,hn,un,An,Fn,Vn,jn,Zn,C=pt.parameters,re,Me=function(){var wt,kt,Ee={},nn=!!(de&&(!((wt=de.image)===null||wt===void 0)&&wt.complete)&&((kt=de.image)===null||kt===void 0?void 0:kt.naturalWidth)>0);C.useTexture&&de&&nn?Ee.map=de:Ee.color=C.useTexture?C.waveFlag?"#e85d56":"#d89b6a":C.color||"#ffffff",C.doubleSide&&(Ee.side=Br),C.opacity<1&&(Ee.transparent=!0,Ee.opacity=C.opacity,Ee.depthWrite=!1);var jt=C.unlit?new sa(Ee):new dr(Ee);return C.useTexture&&de&&!nn&&(jt.userData.pendingTex={tex:de,color:"#ffffff"}),jt};if(C.primitive==="model"||C.primitive==="mesh"&&!C.waveFlag){re=new or;var ie,_e,tt,Qe=((cn=n.gameplay)!==null&&cn!==void 0?cn:[]).find(function(wt){var kt;return wt.kind==="animate-3d"&&wt.componentId===((kt=pt.prototypeId)!==null&&kt!==void 0?kt:pt.id)}),je={sourceId:Pt,animator:null,modelBounds:null,startDefaultAnimation:function(){var wt,kt,Ee;if(!(!je.animator||!Qe)){var nn=Qe.parameters;nn.autoplay!==!1&&je.animator.play(nn.clipName||"",{loop:(wt=nn.loop)!==null&&wt!==void 0?wt:"repeat",speed:(kt=nn.speed)!==null&&kt!==void 0?kt:1,fadeSeconds:0,restart:!0,startTime:(Ee=nn.startTime)!==null&&Ee!==void 0?Ee:0})}},update:function(wt){var kt,Ee,nn,jt,Sn,pn,xn,xt=(nn=i.get(pt.id))===null||nn===void 0?void 0:nn.slots,Vt=(jt=i.get(pt.prototypeId))===null||jt===void 0?void 0:jt.slots,dn=function(si){var rr,Ba,ca,Vr;return(Ba=(rr=xt?.[si])!==null&&rr!==void 0?rr:Vt?.[si])!==null&&Ba!==void 0?Ba:(Vr=(ca=pt.assetSlots)===null||ca===void 0?void 0:ca.find(function(ns){return ns.slotId===si}))===null||Vr===void 0?void 0:Vr.assetId},Nt=["source","texture","normalMap","emissiveMap"].map(dn),hi=["subNode","materialMode","overrideMaterialName","opacity","tintColor","roughnessScale","metalnessScale","castShadow","receiveShadow","normalizeSize","pivotMode","color","useTexture"];if(_e&&Nt.every(function(si,rr){return si===_e[rr]})&&hi.every(function(si){return wt[si]===tt[si]}))return!1;var rt=e.get(Nt[0]);if(ie&&(re.remove(ie),h(ie)),je.animator=null,je.modelBounds=null,rt?.mime==="model/gltf-binary"){var ii={};try{for(var Rn=vn(["texture","normalMap","emissiveMap"].entries()),Jn=Rn.next();!Jn.done;Jn=Rn.next()){var Si=Oa(Jn.value,2),Pn=Si[0],bi=Si[1];Nt[Pn+1]&&(ii[bi]=N(Nt[Pn+1],bi))}}catch(si){kt={error:si}}finally{try{Jn&&!Jn.done&&(Ee=Rn.return)&&Ee.call(Rn)}finally{if(kt)throw kt.error}}ie=mg(f(rt),wt,ii),je.modelBounds=(pn=(Sn=ie.userData)===null||Sn===void 0?void 0:Sn.modelBounds)!==null&&pn!==void 0?pn:null,je.animator=vg(ie),je.startDefaultAnimation()}else ie=new _i((xn=_(Nt[0]))!==null&&xn!==void 0?xn:new $r(1,1,1),Me()),ie.castShadow=!!wt.castShadow,ie.receiveShadow=!!wt.receiveShadow,Nt[1]?ie.material.map=N(Nt[1]):wt.color&&!wt.useTexture&&ie.material.color.set(wt.color);return re.add(ie),Se(ie,et,Pt,Ht,pt.id,!!C.dropShadowOf),_e=Nt,tt=Vc({},wt),!0}};je.update(C),ne.set(pt.id,je)}else if(C.primitive==="group")re=new or;else if(C.primitive==="fairway")re=Xw(C,de,_((Ct=(an=pt.assetSlots)===null||an===void 0?void 0:an[0])===null||Ct===void 0?void 0:Ct.assetId));else if(C.primitive==="cup")re=Yw(C);else if(C.primitive==="garden")re=qw();else if(C.primitive==="mesh"){var bt=_((bn=(Kt=pt.assetSlots)===null||Kt===void 0?void 0:Kt[0])===null||bn===void 0?void 0:bn.assetId),ft=C.waveFlag&&bt?bt.clone():bt??new $r(1,1,1);re=new _i(ft,Me()),C.waveFlag&&bt&&K.push({geo:ft,rest:new Float32Array(ft.getAttribute("position").array)})}else C.primitive==="sphere"?re=new _i(new xs((gn=C.radiusTop)!==null&&gn!==void 0?gn:.5,16,12),Me()):C.primitive==="cylinder"?re=new _i(new co((Wt=C.radiusTop)!==null&&Wt!==void 0?Wt:.23,(Qn=C.radiusBottom)!==null&&Qn!==void 0?Qn:.21,1,32,1,!!C.openEnded),Me()):C.primitive==="ring"?re=new _i(new ol((Tn=C.innerRadius)!==null&&Tn!==void 0?Tn:0,(Gn=C.radiusTop)!==null&&Gn!==void 0?Gn:.15,24),Me()):C.primitive==="circle"?re=new _i(new il((Hn=C.radiusTop)!==null&&Hn!==void 0?Hn:.21,32),Me()):re=new _i(new $r(1,1,1),Me());return re.position.set((Cn=C.x)!==null&&Cn!==void 0?Cn:0,(Wn=C.y)!==null&&Wn!==void 0?Wn:0,(hn=C.z)!==null&&hn!==void 0?hn:0),re.rotation.set((un=C.rx)!==null&&un!==void 0?un:0,(An=C.ry)!==null&&An!==void 0?An:0,(Fn=C.rz)!==null&&Fn!==void 0?Fn:0),re.scale.set((Vn=C.sx)!==null&&Vn!==void 0?Vn:1,(jn=C.sy)!==null&&jn!==void 0?jn:1,(Zn=C.sz)!==null&&Zn!==void 0?Zn:1),re.visible=C.visible!==!1,Se(re,et,Pt,Ht,pt.id,!!C.dropShadowOf),Lt.add(re),re}var Xe=[],qe=new Map,Le=function(pt,Lt,et){var Pt,Ht;try{for(var cn=vn(n.components),an=cn.next();!an.done;an=cn.next()){var Ct=an.value;if(Ct.parentId===pt&&Ct.contract==="native.mesh3d.v1"&&!Ct.prototype){var Kt=Lt??Ct,bn=et||!!Ct.parameters.attachToCamera;qe.set(Ct.id,{rootId:Kt.id,sourceId:Kt.id,cameraAttached:bn}),Xe.push(Ct),Le(Ct.id,Kt,bn)}}}catch(gn){Pt={error:gn}}finally{try{an&&!an.done&&(Ht=cn.return)&&Ht.call(cn)}finally{if(Pt)throw Pt.error}}};Le(F.id,null,!1);var Pe=function(pt){var Lt=pt.parameters,et=qe.get(pt.id),Pt=Lt.attachToCamera&&pt.parentId===F.id?Dt:pt.parentId===F.id?st:($e=wn.get(pt.parentId))!==null&&$e!==void 0?$e:st,Ht=Ie(pt,Pt,et.rootId,et.sourceId,et.cameraAttached);if(wn.set(pt.id,Ht),Lt.confetti){var cn=new or;cn.userData.isConfetti=!0;var an=new $r(.08,.025,.12),Ct=["#ffda69","#fff6c9","#ef8774","#7cc6bf"].map(function(bn){return new sa({color:bn})}),Kt=Array.from({length:28},function(bn,gn){var Wt=new _i(an,Ct[gn%4]);return Wt.visible=!1,cn.add(Wt),Wt});st.add(cn),b.push({id:pt.id,origin:{x:(mt=Lt.x)!==null&&mt!==void 0?mt:0,y:(at=Lt.y)!==null&&at!==void 0?at:0,z:(Ve=Lt.z)!==null&&Ve!==void 0?Ve:0},pieces:Kt})}};try{for(var lt=vn(Xe),Mt=lt.next();!Mt.done;Mt=lt.next()){var yt=Mt.value;Pe(yt)}}catch(pt){z={error:pt}}finally{try{Mt&&!Mt.done&&(Y=lt.return)&&Y.call(lt)}finally{if(z)throw z.error}}var it=new or;st.add(it);var Gt=new xs(1,8,5),Zt=new sa({color:"#fff1a2",transparent:!0,opacity:.85}),Ke=Array.from({length:24},function(){var pt=new _i(Gt,Zt);return pt.visible=!1,it.add(pt),pt}),fe=new Tc,We=new tn,ze=new xe,ht=new fa(new xe(0,1,0),0),St=new xe,He="",qt=Array.from(wn,function(pt){var Lt=Oa(pt,2),et=Lt[0],Pt=Lt[1];return{id:et,obj:Pt,comp:n.components.find(function(Ht){return Ht.id===et})}}).filter(function(pt){return pt.comp}),Tt={id:F.id,scene:st,camera:Dt,nodes:wn,dynamicNodes:Mn,nodeEntries:qt,createMeshObject:Ie,modelBindings:ne,sun:on,wavingFlags:K,confettiSystems:b,guideGroup:it,guidePool:Ke,compiled:!1,lastRenderMs:0,textureDirty:!0,animDirty:!1,skyColor:Yt.skyColor||"#b8e2ed",lastWaveAt:-1,lastRenderedTime:-1,lastRenderedW:0,lastRenderedH:0,lastPoseSig:"",guideDirty:!0,focusZ:0,lastTime:-1,lastWidth:0,lastHeight:0,setGuide:function(pt){var Lt=pt?Math.min(pt.length,Ke.length):0,et=Lt?pt.slice(0,Lt).map(function(Ct){return"".concat(Ct.x.toFixed(2),",").concat(Ct.y.toFixed(2),",").concat(Ct.z.toFixed(2))}).join("|"):"";if(et!==He){He=et,Tt.guideDirty=!0;for(var Pt=0;Pt<Ke.length;Pt++){var Ht=Ke[Pt];if(Pt<Lt){var cn=pt[Pt],an=.055*(1-Pt/Lt*.5);Ht.visible=!0,Ht.scale.setScalar(an),Ht.position.set(cn.x,cn.y+.03,cn.z)}else Ht.visible=!1}}},project:function(pt,Lt,et){return ze.set(pt.x,pt.y,pt.z).project(Dt),{x:(ze.x+1)*Lt/2,y:(1-ze.y)*et/2}},projectNodeBounds:function(pt,Lt,et){var Pt,Ht,cn,an,Ct,Kt,bn,gn,Wt,Qn,Tn,Gn,Hn,Cn=(Hn=Tt.nodes.get(pt))!==null&&Hn!==void 0?Hn:Tt.dynamicNodes.get(pt);if(!Cn||Lt<=0||et<=0)return null;st.updateMatrixWorld(!0),Dt.updateMatrixWorld(!0);for(var Wn=!0,hn=Cn;hn;hn=hn.parent)if(!hn.visible){Wn=!1;break}var un=new Jr().setFromObject(Cn),An=new xe;un.isEmpty()?(Cn.getWorldPosition(An),un.set(An,An)):un.getCenter(An);var Fn=function(Pn){var bi=Pn.clone().applyMatrix4(Dt.matrixWorldInverse);if(bi.z>=-Dt.near)return{x:0,y:0,behind:!0};var si=Pn.clone().project(Dt);return{x:(si.x+1)*Lt/2,y:(1-si.y)*et/2,behind:!1}},Vn=[un.min.x,un.max.x],jn=[un.min.y,un.max.y],Zn=[un.min.z,un.max.z],C=1/0,re=-1/0,Me=1/0,ie=-1/0,_e=0;try{for(var tt=vn(Vn),Qe=tt.next();!Qe.done;Qe=tt.next()){var je=Qe.value;try{for(var bt=(cn=void 0,vn(jn)),ft=bt.next();!ft.done;ft=bt.next()){var wt=ft.value;try{for(var kt=(Ct=void 0,vn(Zn)),Ee=kt.next();!Ee.done;Ee=kt.next()){var nn=Ee.value,jt=new xe(je,wt,nn),Sn=jt.clone().applyMatrix4(Dt.matrixWorldInverse);if(Sn.z<-Dt.near){_e++,jt.project(Dt);var pn=(jt.x+1)*Lt/2,xn=(1-jt.y)*et/2;pn<C&&(C=pn),pn>re&&(re=pn),xn<Me&&(Me=xn),xn>ie&&(ie=xn)}}}catch(Pn){Ct={error:Pn}}finally{try{Ee&&!Ee.done&&(Kt=kt.return)&&Kt.call(kt)}finally{if(Ct)throw Ct.error}}}}catch(Pn){cn={error:Pn}}finally{try{ft&&!ft.done&&(an=bt.return)&&an.call(bt)}finally{if(cn)throw cn.error}}}}catch(Pn){Pt={error:Pn}}finally{try{Qe&&!Qe.done&&(Ht=tt.return)&&Ht.call(tt)}finally{if(Pt)throw Pt.error}}if(_e===0)return{id:pt,visible:Wn,behindCamera:!0,left:0,right:0,top:0,bottom:0,width:0,height:0,centerX:0,centerY:0,anchors:{center:{x:0,y:0},top:{x:0,y:0},bottom:{x:0,y:0}},worldCenter:{x:An.x,y:An.y,z:An.z}};if(_e<8)try{for(var xt=vn(Vn),Vt=xt.next();!Vt.done;Vt=xt.next()){var je=Vt.value;try{for(var dn=(Wt=void 0,vn(jn)),Nt=dn.next();!Nt.done;Nt=dn.next()){var wt=Nt.value;try{for(var hi=(Tn=void 0,vn(Zn)),rt=hi.next();!rt.done;rt=hi.next()){var nn=rt.value,Sn=new xe(je,wt,nn).applyMatrix4(Dt.matrixWorldInverse);if(Sn.z>=-Dt.near){Sn.z=-(Dt.near+.01),Sn.applyMatrix4(Dt.projectionMatrix);var pn=(Sn.x+1)*Lt/2,xn=(1-Sn.y)*et/2;pn<C&&(C=pn),pn>re&&(re=pn),xn<Me&&(Me=xn),xn>ie&&(ie=xn)}}}catch(si){Tn={error:si}}finally{try{rt&&!rt.done&&(Gn=hi.return)&&Gn.call(hi)}finally{if(Tn)throw Tn.error}}}}catch(bi){Wt={error:bi}}finally{try{Nt&&!Nt.done&&(Qn=dn.return)&&Qn.call(dn)}finally{if(Wt)throw Wt.error}}}}catch(Pn){bn={error:Pn}}finally{try{Vt&&!Vt.done&&(gn=xt.return)&&gn.call(xt)}finally{if(bn)throw bn.error}}var ii=Fn(An),Rn=Fn(new xe(An.x,un.max.y,An.z)),Jn=Fn(new xe(An.x,un.min.y,An.z)),Si={x:(C+re)/2,y:(Me+ie)/2};return{id:pt,visible:Wn,behindCamera:!1,left:C,right:re,top:Me,bottom:ie,width:Math.max(0,re-C),height:Math.max(0,ie-Me),centerX:Si.x,centerY:Si.y,anchors:{center:ii.behind?Si:{x:ii.x,y:ii.y},top:Rn.behind?{x:Si.x,y:Me}:{x:Rn.x,y:Rn.y},bottom:Jn.behind?{x:Si.x,y:ie}:{x:Jn.x,y:Jn.y}},worldCenter:{x:An.x,y:An.y,z:An.z}}},checkNodeOcclusion:function(pt,Lt,et,Pt){var Ht,cn,an,Ct,Kt,bn,gn,Wt,Qn,Tn,Gn,Hn,Cn=(gn=Tt.nodes.get(pt))!==null&&gn!==void 0?gn:Tt.dynamicNodes.get(pt);if(!Cn||!Lt||Lt.behindCamera||et<=0||Pt<=0)return{occluded:!1,occluderId:null,targetHitSamples:0,occludedSamples:0,occludedRatio:0};st.updateMatrixWorld(!0),Dt.updateMatrixWorld(!0);var Wn=function(hi){for(var rt=hi;rt;rt=rt.parent)if(rt===Cn)return!0;return!1},hn=function(hi){for(var rt,ii,Rn,Jn,Si,Pn,bi=hi;bi;bi=bi.parent)if(!bi.visible||bi===it||!((rt=bi.userData)===null||rt===void 0)&&rt.cameraAttached||!((ii=bi.userData)===null||ii===void 0)&&ii.isConfetti||!((Rn=bi.userData)===null||Rn===void 0)&&Rn.isDropShadow)return!1;var si=hi.material;return si&&!Array.isArray(si)&&si.transparent&&((Jn=si.opacity)!==null&&Jn!==void 0?Jn:1)<.25?!1:!!(!((Si=hi.userData)===null||Si===void 0)&&Si.toraNodeId||!((Pn=hi.userData)===null||Pn===void 0)&&Pn.toraRootId)},un=Lt.centerX,An=Lt.centerY,Fn=Math.max(1,Lt.width*.22),Vn=Math.max(1,Lt.height*.22),jn=[{x:un,y:An,center:!0},{x:un-Fn,y:An-Vn,center:!1},{x:un+Fn,y:An-Vn,center:!1},{x:un-Fn,y:An+Vn,center:!1},{x:un+Fn,y:An+Vn,center:!1}],Zn=0,C=0,re=!1,Me=new Map;try{for(var ie=vn(jn),_e=ie.next();!_e.done;_e=ie.next()){var tt=_e.value;if(!(tt.x<0||tt.x>et||tt.y<0||tt.y>Pt)){We.set(tt.x/et*2-1,1-tt.y/Pt*2),fe.near=.05,fe.far=200,fe.setFromCamera(We,Dt);var Qe=fe.intersectObject(Cn,!0).filter(function(hi){return hn(hi.object)});if(Qe.length){Zn++;var je=Qe[0].distance,bt=fe.intersectObjects(st.children,!0);try{for(var ft=(an=void 0,vn(bt)),wt=ft.next();!wt.done;wt=ft.next()){var kt=wt.value;if(hn(kt.object)){if(kt.distance>=je-.02||Wn(kt.object))break;var Ee=(Gn=(Qn=(Wt=kt.object.userData)===null||Wt===void 0?void 0:Wt.toraNodeId)!==null&&Qn!==void 0?Qn:(Tn=kt.object.userData)===null||Tn===void 0?void 0:Tn.toraRootId)!==null&&Gn!==void 0?Gn:null;Ee&&Ee!==pt&&(C++,tt.center&&(re=!0),Me.set(Ee,((Hn=Me.get(Ee))!==null&&Hn!==void 0?Hn:0)+1));break}}}catch(hi){an={error:hi}}finally{try{wt&&!wt.done&&(Ct=ft.return)&&Ct.call(ft)}finally{if(an)throw an.error}}}}}}catch(hi){Ht={error:hi}}finally{try{_e&&!_e.done&&(cn=ie.return)&&cn.call(ie)}finally{if(Ht)throw Ht.error}}var nn=Zn>0?C/Zn:0,jt=null,Sn=0;try{for(var pn=vn(Me),xn=pn.next();!xn.done;xn=pn.next()){var xt=Oa(xn.value,2),Vt=xt[0],dn=xt[1];dn>Sn&&(Sn=dn,jt=Vt)}}catch(hi){Kt={error:hi}}finally{try{xn&&!xn.done&&(bn=pn.return)&&bn.call(pn)}finally{if(Kt)throw Kt.error}}var Nt=Zn>0&&(nn>=.6||re&&nn>=.5);return{occluded:Nt,occluderId:Nt?jt:null,targetHitSamples:Zn,occludedSamples:C,occludedRatio:nn}},unproject:function(pt,Lt,et,Pt,Ht){return We.set(pt/et*2-1,1-Lt/Pt*2),fe.setFromCamera(We,Dt),ht.constant=-Ht,fe.ray.intersectPlane(ht,St)?{x:St.x,y:St.y,z:St.z}:null},raycast:function(pt,Lt,et,Pt){var Ht,cn,an,Ct,Kt,bn,gn,Wt,Qn,Tn,Gn,Hn,Cn,Wn,hn,un;et===void 0&&(et=80);var An=Pt===void 0?{}:Pt,Fn=An.isTarget,Vn=Fn===void 0?function(){return!0}:Fn,jn=An.isOccluder,Zn=jn===void 0?function(){return!1}:jn;st.updateMatrixWorld(!0),Dt.updateMatrixWorld(!0),We.set(pt,Lt),fe.near=.05,fe.far=et,fe.setFromCamera(We,Dt);var C=[];try{for(var re=vn(Tt.nodes.values()),Me=re.next();!Me.done;Me=re.next()){var ie=Me.value;if(!(!ie.visible||!((gn=ie.userData)===null||gn===void 0)&&gn.cameraAttached)){var _e=(Wt=ie.userData)===null||Wt===void 0?void 0:Wt.toraRootId,tt=(Qn=ie.userData)===null||Qn===void 0?void 0:Qn.toraSourceId;_e&&(Vn(_e,tt)||Zn(_e,tt))&&C.push(ie)}}}catch(xn){Ht={error:xn}}finally{try{Me&&!Me.done&&(cn=re.return)&&cn.call(re)}finally{if(Ht)throw Ht.error}}try{for(var Qe=vn(Tt.dynamicNodes.values()),je=Qe.next();!je.done;je=Qe.next()){var ie=je.value;if(!(!ie.visible||!((Tn=ie.userData)===null||Tn===void 0)&&Tn.cameraAttached)){var _e=(Gn=ie.userData)===null||Gn===void 0?void 0:Gn.toraRootId,tt=(Hn=ie.userData)===null||Hn===void 0?void 0:Hn.toraSourceId;_e&&(Vn(_e,tt)||Zn(_e,tt))&&C.push(ie)}}}catch(xn){an={error:xn}}finally{try{je&&!je.done&&(Ct=Qe.return)&&Ct.call(Qe)}finally{if(an)throw an.error}}var bt=fe.intersectObjects(C.length?C:st.children,!0),ft=new Set;try{for(var wt=vn(bt),kt=wt.next();!kt.done;kt=wt.next()){for(var Ee=kt.value,nn=!1,jt=Ee.object;jt;jt=jt.parent)if(!jt.visible||jt===it||!((Cn=jt.userData)===null||Cn===void 0)&&Cn.cameraAttached||!((Wn=jt.userData)===null||Wn===void 0)&&Wn.isConfetti){nn=!0;break}if(!nn){var Sn=(hn=Ee.object.userData)===null||hn===void 0?void 0:hn.toraRootId,pn=(un=Ee.object.userData)===null||un===void 0?void 0:un.toraSourceId;if(!(!Sn||ft.has(Sn))){if(ft.add(Sn),Vn(Sn,pn))return{id:Sn,sourceId:pn,distance:Ee.distance,point:{x:Ee.point.x,y:Ee.point.y,z:Ee.point.z}};if(Zn(Sn,pn))return null}}}}catch(xn){Kt={error:xn}}finally{try{kt&&!kt.done&&(bn=wt.return)&&bn.call(wt)}finally{if(Kt)throw Kt.error}}return null}};return m.set(F.id,Tt),Tt}function V(F){var z;return(z=m.get(F.id))!==null&&z!==void 0?z:D(F)}function w(F,z){var Y,$,he,pe,le,Te;if(!z.length&&!F.contactBatches)return!1;F.contactBatches||(F.contactBatches=[new xs(1,6,4),new $r(1,.2,1.6)].map(function(Yt){var st=new Na(Yt,new sa({toneMapped:!1}),256);return st.userData.isConfetti=!0,st.frustumCulled=!1,st.count=0,F.scene.add(st),st}),F.contactPose=new cr,F.contactColor=new zn);var De=F.contactBatches.some(function(Yt){return Yt.count>0});try{for(var oe=vn(F.contactBatches),ee=oe.next();!ee.done;ee=oe.next()){var be=ee.value;be.count=0}}catch(Yt){Y={error:Yt}}finally{try{ee&&!ee.done&&($=oe.return)&&$.call(oe)}finally{if(Y)throw Y.error}}var Be=F.contactBatches,Re=F.contactPose,Ye=F.contactColor;try{for(var nt=vn(z),Ge=nt.next();!Ge.done;Ge=nt.next()){var $e=Ge.value,be=Be[Number($e.confetti)],mt=$e.age;Re.position.set($e.x+$e.vx*mt,$e.y+$e.vy*mt-$e.gravity*mt*mt/2,$e.z+$e.vz*mt),Re.rotation.set($e.spinX*mt,$e.spinZ*mt/2,$e.spinZ*mt),Re.scale.setScalar($e.size*Math.min(1,($e.life-mt)*7)),Re.updateMatrix(),be.setMatrixAt(be.count,Re.matrix),be.setColorAt(be.count,Ye.set($e.color)),be.count++}}catch(Yt){he={error:Yt}}finally{try{Ge&&!Ge.done&&(pe=nt.return)&&pe.call(nt)}finally{if(he)throw he.error}}try{for(var at=vn(Be),Ve=at.next();!Ve.done;Ve=at.next()){var be=Ve.value;be.instanceMatrix.needsUpdate=!0,be.instanceColor&&(be.instanceColor.needsUpdate=!0)}}catch(Yt){le={error:Yt}}finally{try{Ve&&!Ve.done&&(Te=at.return)&&Te.call(at)}finally{if(le)throw le.error}}return De||z.length>0}function I(F,z){var Y,$,he,pe,le,Te,De,oe,ee,be,Be,Re,Ye,nt,Ge,$e,mt,at,Ve,Yt,st,Dt,on,de,wn,Mn,K,b,ne,Se,Ie,Xe,qe,Le,Pe,lt,Mt,yt,it,Gt,Zt,Ke,fe,We,ze,ht,St,He,qt,Tt,pt,Lt,et,Pt,Ht,cn,an,Ct,Kt,bn,gn,Wt,Qn,Tn,Gn,Hn,Cn,Wn,hn,un,An,Fn=z.time,Vn=Fn===void 0?0:Fn,jn=z.ambientTime,Zn=z.propsOf,C=z.bodies3d,re=z.fpsPose,Me=z.instances3d,ie=Me===void 0?[]:Me,_e=z.aimLocked,tt=_e===void 0?!1:_e,Qe=z.groundFn,je=z.worldWidth,bt=je===void 0?390:je,ft=z.worldHeight,wt=ft===void 0?700:ft,kt=z.designHeight,Ee=V(F),nn=jn??Vn,jt=Zn(F),Sn=jt.skyColor||"#b8e2ed";Ee.skyColor!==Sn&&(Ee.skyColor=Sn,Ee.scene.background=new zn(Sn));var pn=new Set(ie.map(function(ti){return ti.id}));try{for(var xn=vn(Ee.dynamicNodes),xt=xn.next();!xt.done;xt=xn.next()){var Vt=Oa(xt.value,2),dn=Vt[0],Nt=Vt[1];pn.has(dn)||((Be=Nt.parent)===null||Be===void 0||Be.remove(Nt),h(Nt),Ee.modelBindings.delete(dn),Ee.dynamicNodes.delete(dn))}}catch(ti){Y={error:ti}}finally{try{xt&&!xt.done&&($=xn.return)&&$.call(xn)}finally{if(Y)throw Y.error}}var hi=function(ti){if(Ee.dynamicNodes.has(ti.id))return"continue";var bo=ti.parentId===F.id?Ee.scene:(Ye=(Re=Ee.dynamicNodes.get(ti.parentId))!==null&&Re!==void 0?Re:Ee.nodes.get(ti.parentId))!==null&&Ye!==void 0?Ye:Ee.scene,ta=(nt=ti.instanceId)!==null&&nt!==void 0?nt:ti.id,os=(Ge=ie.find(function(Zs){return Zs.id===ta}))!==null&&Ge!==void 0?Ge:ti,na=($e=os.prototypeId)!==null&&$e!==void 0?$e:os.id,Ss=Ee.createMeshObject(ti,bo,ta,na,!!ti.parameters.attachToCamera);Ee.dynamicNodes.set(ti.id,Ss)};try{for(var rt=vn(ie),ii=rt.next();!ii.done;ii=rt.next()){var Rn=ii.value;hi(Rn)}}catch(ti){he={error:ti}}finally{try{ii&&!ii.done&&(pe=rt.return)&&pe.call(rt)}finally{if(he)throw he.error}}var Jn=wt>=bt,Si=Ee.lastTime<0||nn<Ee.lastTime?0:Math.min(.05,nn-Ee.lastTime),Pn=Math.max(1,wt/Math.max(1,kt??wt)),bi=function(ti){return Pn>1.001?Math.min(135,2*Math.atan(Math.tan(ti*Math.PI/360)*Pn)*(180/Math.PI)):ti},si=bt/Math.max(1,wt),rr=bi(re?Jn?(mt=jt.cameraFov)!==null&&mt!==void 0?mt:68:(at=jt.landscapeCameraFov)!==null&&at!==void 0?at:54:Jn?(Ve=jt.cameraFov)!==null&&Ve!==void 0?Ve:39:(Yt=jt.landscapeCameraFov)!==null&&Yt!==void 0?Yt:22.6199);Ee.recoil>0&&(Ee.recoil=Si>0?Ee.recoil*Math.exp(-10*Si):Ee.recoil,Ee.recoil<.002&&(Ee.recoil=0));var Ba=gg(gg([],Oa(Ee.nodeEntries),!1),Oa(ie.map(function(ti){return{id:ti.id,obj:Ee.dynamicNodes.get(ti.id),comp:ti}}).filter(function(ti){return ti.obj})),!1),ca="";try{for(var Vr=vn(Ba),ns=Vr.next();!ns.done;ns=Vr.next()){var jr=ns.value,ea=jr.id,Xn=jr.obj,Rn=jr.comp,ei=Zn(Rn);Xn.visible=ei.visible!==!1,!((st=Ee.modelBindings.get(ea))===null||st===void 0)&&st.update(ei)&&(Ee.textureDirty=!0,Ee.compiled=!1),!ei.useTexture&&Xn.isMesh&&(!((Dt=Xn.material)===null||Dt===void 0)&&Dt.color)&&ei.color&&Xn.material.color.set(ei.color);var vt=C?.get(ea);if(vt&&vt.mode==="dynamic"){var is=vt.captured?Math.min(1,((on=vt.captureElapsed)!==null&&on!==void 0?on:0)/.55):0,Ys=vt.captured&&vt.captureTarget?vt.x+(vt.captureTarget.x-vt.x)*is:vt.x,Gr=vt.y-is*.45,Ms=vt.captured&&vt.captureTarget?vt.z+(vt.captureTarget.z-vt.z)*is:vt.z;Xn.position.set(Ys,Gr,Ms);var Ir=1-is*.65;Xn.scale.set(((de=ei.sx)!==null&&de!==void 0?de:1)*Ir,((wn=ei.sy)!==null&&wn!==void 0?wn:1)*Ir,((Mn=ei.sz)!==null&&Mn!==void 0?Mn:1)*Ir),Xn.rotation.set(-((K=vt.spin)!==null&&K!==void 0?K:0),(b=ei.ry)!==null&&b!==void 0?b:0,((ne=vt.spin)!==null&&ne!==void 0?ne:0)*.22)}else if(vt&&vt.mode==="kinematic")Xn.position.set(vt.x,(Ie=(Se=vt.y)!==null&&Se!==void 0?Se:ei.y)!==null&&Ie!==void 0?Ie:0,vt.z),Xn.rotation.set((Xe=ei.rx)!==null&&Xe!==void 0?Xe:0,-((Le=(qe=vt.angle)!==null&&qe!==void 0?qe:ei.ry)!==null&&Le!==void 0?Le:0),(Pe=ei.rz)!==null&&Pe!==void 0?Pe:0);else if(ei.dropShadowOf&&C?.has(ei.dropShadowOf)){var In=C.get(ei.dropShadowOf),Qi=Qe?(lt=Qe(In,In.x,In.z))!==null&<!==void 0?lt:-1:0;Xn.position.set(In.x,Qi+.008,In.z);var ka=Math.max(0,In.y-Qi-In.radius);Xn.material&&(Xn.material.opacity=.22/(1+ka*2));var Ir=1+ka*.4;Xn.scale.set(Ir,Ir,Ir),Xn.visible=!In.captured&&ei.visible!==!1}else if(ei.attachToCamera){var bl=Math.tan(((Mt=jt.cameraFov)!==null&&Mt!==void 0?Mt:68)*Math.PI/360),Rf=Math.tan(rr*Math.PI/360),Zc=Rf/Math.max(.05,bl),Ir=Math.min(1,Zc),qs=Math.min(1.15,Zc)*(si>1.3?1.12:1),Jc=qs*Math.min(3.55,si/(390/700)),Mo=(yt=Ee.recoil)!==null&&yt!==void 0?yt:0;Xn.position.set(((it=ei.x)!==null&&it!==void 0?it:0)*Jc,((Gt=ei.y)!==null&&Gt!==void 0?Gt:0)*qs+Mo*.085*Ir,((Zt=ei.z)!==null&&Zt!==void 0?Zt:0)+Mo*.3*Ir),Xn.rotation.set(((Ke=ei.rx)!==null&&Ke!==void 0?Ke:0)+Mo*.34,((fe=ei.ry)!==null&&fe!==void 0?fe:0)+(si>1.1?.1:0),((We=ei.rz)!==null&&We!==void 0?We:0)-Mo*.09),Xn.scale.set(((ze=ei.sx)!==null&&ze!==void 0?ze:1)*Ir,((ht=ei.sy)!==null&&ht!==void 0?ht:1)*Ir,((St=ei.sz)!==null&&St!==void 0?St:1)*Ir)}else Xn.position.set((He=ei.x)!==null&&He!==void 0?He:0,(qt=ei.y)!==null&&qt!==void 0?qt:0,(Tt=ei.z)!==null&&Tt!==void 0?Tt:0),Xn.rotation.set((pt=ei.rx)!==null&&pt!==void 0?pt:0,(Lt=ei.ry)!==null&&Lt!==void 0?Lt:0,(et=ei.rz)!==null&&et!==void 0?et:0),Xn.scale.set((Pt=ei.sx)!==null&&Pt!==void 0?Pt:1,(Ht=ei.sy)!==null&&Ht!==void 0?Ht:1,(cn=ei.sz)!==null&&cn!==void 0?cn:1);(re||Ee.dynamicNodes.size>0)&&(ca+="".concat(ea,":").concat(+Xn.visible,",").concat(Xn.position.x*100|0,",").concat(Xn.position.y*100|0,",").concat(Xn.position.z*100|0,",").concat(Xn.rotation.x*100|0,",").concat(Xn.rotation.y*100|0,"|"))}}catch(ti){le={error:ti}}finally{try{ns&&!ns.done&&(Te=Vr.return)&&Te.call(Vr)}finally{if(le)throw le.error}}var za;if(C)try{for(var Bi=vn(C.values()),Ui=Bi.next();!Ui.done;Ui=Bi.next()){var vt=Ui.value;if(vt.stageId===F.id&&vt.captured){za=vt;break}}}catch(ti){De={error:ti}}finally{try{Ui&&!Ui.done&&(oe=Bi.return)&&oe.call(Bi)}finally{if(De)throw De.error}}var rs=function(ti){var bo=!!za,ta=za&&(an=za.captureElapsed)!==null&&an!==void 0?an:0;ti.pieces.forEach(function(os,na){var Ss,Zs,El,Js,Il,wo;if(os.visible=bo,!!bo){var eu=na*2.399,Lf=(Zs=(Ss=za.captureTarget)===null||Ss===void 0?void 0:Ss.x)!==null&&Zs!==void 0?Zs:ti.origin.x,Df=(Js=(El=za.captureTarget)===null||El===void 0?void 0:El.y)!==null&&Js!==void 0?Js:ti.origin.y,Nf=(wo=(Il=za.captureTarget)===null||Il===void 0?void 0:Il.z)!==null&&wo!==void 0?wo:ti.origin.z;os.position.set(Lf+Math.cos(eu)*ta*(.5+na%4*.17),Df+.3+Math.sin(Math.min(1,ta/2)*Math.PI)*(1+na%5*.15),Nf+Math.sin(eu)*ta*(.5+na%4*.17)),os.rotation.set(ta*3+na,ta*2+na,Math.sin(ta+na))}})};try{for(var Hr=vn(Ee.confettiSystems),ya=Hr.next();!ya.done;ya=Hr.next()){var as=ya.value;rs(as)}}catch(ti){ee={error:ti}}finally{try{ya&&!ya.done&&(be=Hr.return)&&be.call(Hr)}finally{if(ee)throw ee.error}}Ee.camera.aspect=si;var Va=!1;if(re)Ee.lastTime=nn,Ee.camera.rotation.order="YXZ",Ee.camera.position.set(re.x,re.y+((Ct=re.bob)!==null&&Ct!==void 0?Ct:0),re.z),Ee.camera.rotation.set(re.pitch,re.yaw,0),Ee.camera.fov=rr,ca+="c:".concat(Ee.camera.position.x*100|0,",").concat(Ee.camera.position.y*100|0,",").concat(Ee.camera.position.z*100|0,",").concat(re.yaw*1e3|0,",").concat(re.pitch*1e3|0,",").concat(rr*100|0,",").concat(si*1e3|0,",").concat(((Kt=Ee.recoil)!==null&&Kt!==void 0?Kt:0)*1e3|0);else{var $c=jt.followTargetId?C?.get(jt.followTargetId):void 0,wl=$c?$c.z*((bn=jt.followZFactor)!==null&&bn!==void 0?bn:.12):(gn=jt.lookAtZ)!==null&&gn!==void 0?gn:0,Kc=Ee.lastTime<0||nn<Ee.lastTime;Kc?Ee.focusZ=wl:!tt&&Si>0&&(Ee.focusZ+=(wl-Ee.focusZ)*(1-Math.exp(-6*Si))),Ee.lastTime=nn;var Pf=Math.max(0,1-nn/1.5);if(Va=!jt.followTargetId&&((Wt=jt.introLift)!==null&&Wt!==void 0?Wt:2)===0,!tt){var Qc=Va?Math.sin(nn*.42)*1.15:0,So=Va?(Math.cos(nn*.42)-1)*.55:0,Tl=(Jn?(Qn=jt.cameraX)!==null&&Qn!==void 0?Qn:10:(Tn=jt.landscapeCameraX)!==null&&Tn!==void 0?Tn:13)+Qc,jc=Jn?((Gn=jt.cameraY)!==null&&Gn!==void 0?Gn:18)+Pf*((Hn=jt.introLift)!==null&&Hn!==void 0?Hn:2):(Cn=jt.landscapeCameraY)!==null&&Cn!==void 0?Cn:15,ss=(Jn?(Wn=jt.cameraZ)!==null&&Wn!==void 0?Wn:21:(hn=jt.landscapeCameraZ)!==null&&hn!==void 0?hn:18)+So,Al=Kc?jc:Si===0?Ee.camera.position.y:Ee.camera.position.y+(jc-Ee.camera.position.y)*(1-Math.exp(-6*Si));Ee.camera.position.set(Tl,Al,ss+Ee.focusZ),Ee.camera.fov=rr,Ee.camera.lookAt((un=jt.lookAtX)!==null&&un!==void 0?un:0,(An=jt.lookAtY)!==null&&An!==void 0?An:.15,Ee.focusZ)}ca+="a:".concat(si*1e3|0,",").concat(rr*100|0)}return Ee.camera.updateProjectionMatrix(),Ee.camera.updateMatrixWorld(!0),Ee.scene.updateMatrixWorld(!0),{entry:Ee,waveTime:nn,victorySway:Va,poseParts:ca}}function G(F,z,Y,$,he,pe,le){var Te,De,oe,ee,be,Be,Re,Ye,nt,Ge,$e,mt,at,Ve,Yt,st,Dt,on,de,wn,Mn,K,b=I(F,Vc(Vc({},le),{worldWidth:(nt=le.worldWidth)!==null&&nt!==void 0?nt:he,worldHeight:(Ge=le.worldHeight)!==null&&Ge!==void 0?Ge:pe})),ne=b.entry,Se=b.waveTime,Ie=b.victorySway,Xe=b.poseParts,qe=le.bodies3d,Le=($e=le.drawX)!==null&&$e!==void 0?$e:0,Pe=(mt=le.drawY)!==null&&mt!==void 0?mt:0,lt=w(ne,(at=le.contactParticles)!==null&&at!==void 0?at:[]);Object.assign(ne,{lastX:Le,lastY:Pe,lastWidth:he,lastHeight:pe,lastDesignH:(Ve=le.designHeight)!==null&&Ve!==void 0?Ve:pe,isFullBleed:!!le.fullBleed});var Mt=Y>=2&&$>=2?p():null;if(!Mt||!((Dt=(st=(Yt=Mt.getContext)===null||Yt===void 0?void 0:Yt.call(Mt))===null||st===void 0?void 0:st.isContextLost)===null||Dt===void 0)&&Dt.call(st))return z.fillStyle=ne.skyColor,z.fillRect(Le,Pe,he,pe),ne;var yt=Math.max(Y,$,1),it=le.propsOf(F),Gt=(on={none:oa,neutral:Ic,aces:Ec}[it.toneMapping])!==null&&on!==void 0?on:oa;Mt.toneMapping=Gt;var Zt=!!it.shadowsEnabled,Ke=Number((de=it.shadowMapSize)!==null&&de!==void 0?de:512);Mt.shadowMap.enabled=Zt,ne.sun.castShadow=Zt,ne.sun.shadow.mapSize.x!==Ke&&(ne.sun.shadow.mapSize.set(Ke,Ke),(wn=ne.sun.shadow.map)===null||wn===void 0||wn.dispose(),ne.sun.shadow.map=null);var fe=(Mn=it.envIntensity)!==null&&Mn!==void 0?Mn:.8;(ne.textureDirty||!ne.compiled)&&(ne.usesPbr=!1,ne.scene.traverse(function(un){var An;!((An=un.material)===null||An===void 0)&&An.isMeshStandardMaterial&&(ne.usesPbr=!0)})),ne.usesPbr&&fe>0&&(l??(l=Jw(Mt))),ne.scene.environment=ne.usesPbr&&fe>0?l?.texture:null,ne.scene.environmentIntensity=fe;var We=[Gt,Zt,Ke,fe].join("/");ne.lightingKey!==We&&(ne.textureDirty=!0,ne.lightingKey=We);var ze=(K=it.renderMaxDim)!==null&&K!==void 0?K:520,ht=yt>ze?ze/yt:1,St=Math.max(2,Math.round(Y*ht)),He=Math.max(2,Math.round($*ht)),qt=y.width!==St||y.height!==He;if(qt&&(Mt.setPixelRatio(1),Mt.setSize(St,He,!1),g.width=St,g.height=He,L=void 0),!ne.compiled){ne.compiled=!0;var Tt=[];ne.guidePool[0]&&!ne.guidePool[0].visible&&(ne.guidePool[0].visible=!0,ne.guidePool[0].position.set(0,-99,0),Tt.push(ne.guidePool[0]));try{for(var pt=vn(ne.confettiSystems),Lt=pt.next();!Lt.done;Lt=pt.next()){var et=Lt.value;et.pieces[0]&&!et.pieces[0].visible&&(et.pieces[0].visible=!0,et.pieces[0].position.set(0,-99,0),Tt.push(et.pieces[0]))}}catch(un){Te={error:un}}finally{try{Lt&&!Lt.done&&(De=pt.return)&&De.call(pt)}finally{if(Te)throw Te.error}}Mt.compile(ne.scene,ne.camera);try{for(var Pt=vn(Tt),Ht=Pt.next();!Ht.done;Ht=Pt.next()){var cn=Ht.value;cn.visible=!1}}catch(un){oe={error:un}}finally{try{Ht&&!Ht.done&&(ee=Pt.return)&&ee.call(Pt)}finally{if(oe)throw oe.error}}}var an=!1;if(qe)try{for(var Ct=vn(qe.values()),Kt=Ct.next();!Kt.done;Kt=Ct.next()){var bn=Kt.value;if(bn.stageId===F.id&&(bn.mode==="kinematic"||bn.mode==="dynamic"&&(!bn.atRest||bn.captured))){an=!0;break}}}catch(un){be={error:un}}finally{try{Kt&&!Kt.done&&(Be=Ct.return)&&Be.call(Ct)}finally{if(be)throw be.error}}var gn=Math.floor(Se*20),Wt=ne.wavingFlags.length>0&&ne.lastFlagStep!==gn,Qn=Ie&&Math.abs(Se-ne.lastRenderedTime)>=.032,Tn=an&&ne.lastRenderedTime!==Se,Gn=Xe!==ne.lastPoseSig,Hn=qt||L!==F.id||ne.guideDirty||ne.textureDirty||ne.animDirty||ne.lastRenderedTime<0||ne.lastRenderedW!==St||ne.lastRenderedH!==He||Wt||Qn||Tn||Gn||lt;if(Hn){if(ne.wavingFlags.length>0&&ne.lastFlagStep!==gn){try{for(var Cn=vn(ne.wavingFlags),Wn=Cn.next();!Wn.done;Wn=Cn.next()){var hn=Wn.value;Zw(hn.geo,hn.rest,gn/20)}}catch(un){Re={error:un}}finally{try{Wn&&!Wn.done&&(Ye=Cn.return)&&Ye.call(Cn)}finally{if(Re)throw Re.error}}ne.lastFlagStep=gn}Mt.setClearColor(ne.skyColor,1),Mt.render(ne.scene,ne.camera),y.width>0&&y.height>0&&(v.drawImage(y,0,0,St,He),L=F.id),ne.lastRenderedTime=Se,ne.lastRenderedW=St,ne.lastRenderedH=He,ne.lastPoseSig=Xe,ne.guideDirty=!1,ne.textureDirty=!1,ne.animDirty=!1}return g.width>0&&g.height>0&&z.drawImage(g,Le,Pe,he,pe),ne}function H(){var F,z,Y,$,he,pe,le,Te;try{for(var De=vn(m.values()),oe=De.next();!oe.done;oe=De.next()){var ee=oe.value;try{for(var be=(Y=void 0,vn(ee.dynamicNodes)),Be=be.next();!Be.done;Be=be.next()){var Re=Oa(Be.value,2),Ye=Re[0],nt=Re[1];(le=nt.parent)===null||le===void 0||le.remove(nt),h(nt),ee.modelBindings.delete(Ye)}}catch(at){Y={error:at}}finally{try{Be&&!Be.done&&($=be.return)&&$.call(be)}finally{if(Y)throw Y.error}}ee.dynamicNodes.clear();try{for(var Ge=(he=void 0,vn(ee.modelBindings.values())),$e=Ge.next();!$e.done;$e=Ge.next()){var mt=$e.value;(Te=mt.animator)===null||Te===void 0||Te.reset(),mt.startDefaultAnimation()}}catch(at){he={error:at}}finally{try{$e&&!$e.done&&(pe=Ge.return)&&pe.call(Ge)}finally{if(he)throw he.error}}ee.animDirty=!0,ee.focusZ=0,ee.lastTime=-1,ee.lastRenderedTime=-1,ee.lastFlagStep=-1,ee.lastPoseSig="",ee.guideDirty=!0,ee.setGuide([])}}catch(at){F={error:at}}finally{try{oe&&!oe.done&&(z=De.return)&&z.call(De)}finally{if(F)throw F.error}}}function Q(){var F,z,Y,$,he,pe,le,Te,De,oe,ee,be,Be,Re,Ye,nt;try{for(var Ge=vn(m.values()),$e=Ge.next();!$e.done;$e=Ge.next()){var mt=$e.value;try{for(var at=(Y=void 0,vn((Ye=mt.contactBatches)!==null&&Ye!==void 0?Ye:[])),Ve=at.next();!Ve.done;Ve=at.next()){var Yt=Ve.value;Yt.dispose()}}catch(Pe){Y={error:Pe}}finally{try{Ve&&!Ve.done&&($=at.return)&&$.call(at)}finally{if(Y)throw Y.error}}h(mt.scene),mt.sun.shadow.dispose()}}catch(Pe){F={error:Pe}}finally{try{$e&&!$e.done&&(z=Ge.return)&&z.call(Ge)}finally{if(F)throw F.error}}try{for(var st=vn(o),Dt=st.next();!Dt.done;Dt=st.next()){var on=Dt.value;on.dispose()}}catch(Pe){he={error:Pe}}finally{try{Dt&&!Dt.done&&(pe=st.return)&&pe.call(st)}finally{if(he)throw he.error}}try{for(var de=vn(u),wn=de.next();!wn.done;wn=de.next()){var Mn=wn.value;Mn.dispose()}}catch(Pe){le={error:Pe}}finally{try{wn&&!wn.done&&(Te=de.return)&&Te.call(de)}finally{if(le)throw le.error}}try{for(var K=vn(a.values()),b=K.next();!b.done;b=K.next()){var ne=b.value;ne.dispose()}}catch(Pe){De={error:Pe}}finally{try{b&&!b.done&&(oe=K.return)&&oe.call(K)}finally{if(De)throw De.error}}try{for(var Se=vn(s.values()),Ie=Se.next();!Ie.done;Ie=Se.next()){var Xe=Ie.value;try{for(var qe=(Be=void 0,vn(Xe.textures.values())),Le=qe.next();!Le.done;Le=qe.next()){var ne=Le.value;ne.dispose()}}catch(Pe){Be={error:Pe}}finally{try{Le&&!Le.done&&(Re=qe.return)&&Re.call(qe)}finally{if(Be)throw Be.error}}}}catch(Pe){ee={error:Pe}}finally{try{Ie&&!Ie.done&&(be=Se.return)&&be.call(Se)}finally{if(ee)throw ee.error}}u.clear(),o.clear(),s.clear(),l?.dispose(),l=void 0,m.clear(),r.clear(),a.clear(),(nt=M?.forceContextLoss)===null||nt===void 0||nt.call(M),M?.dispose(),M=void 0,y=void 0,g=void 0,v=void 0,L=void 0}function T(F,z){var Y,$,he,pe;try{for(var le=vn(m.values()),Te=le.next();!Te.done;Te=le.next()){var De=Te.value,oe=function(nt,Ge){if(!Ge.animator)return"continue";Ge.animator.step(F,function($e){var mt;return z?.(nt,(mt=Ge.sourceId)!==null&&mt!==void 0?mt:nt,$e)})&&(De.animDirty=!0)};try{for(var ee=(he=void 0,vn(De.modelBindings)),be=ee.next();!be.done;be=ee.next()){var Be=Oa(be.value,2),Re=Be[0],Ye=Be[1];oe(Re,Ye)}}catch(nt){he={error:nt}}finally{try{be&&!be.done&&(pe=ee.return)&&pe.call(ee)}finally{if(he)throw he.error}}}}catch(nt){Y={error:nt}}finally{try{Te&&!Te.done&&($=le.return)&&$.call(le)}finally{if(Y)throw Y.error}}}function S(F,z){var Y,$,he,pe,le;z===void 0&&(z={});var Te=!1;try{for(var De=vn(m.values()),oe=De.next();!oe.done;oe=De.next()){var ee=oe.value;try{for(var be=(he=void 0,vn(ee.modelBindings)),Be=be.next();!Be.done;Be=be.next()){var Re=Oa(Be.value,2),Ye=Re[0],nt=Re[1];Ye!==F&&nt.sourceId!==F||!((le=nt.animator)===null||le===void 0)&&le.play(z.clipName||"",z)&&(ee.animDirty=!0,Te=!0)}}catch(Ge){he={error:Ge}}finally{try{Be&&!Be.done&&(pe=be.return)&&pe.call(be)}finally{if(he)throw he.error}}}}catch(Ge){Y={error:Ge}}finally{try{oe&&!oe.done&&($=De.return)&&$.call(De)}finally{if(Y)throw Y.error}}return Te}function Z(F){var z,Y;try{for(var $=vn(m.values()),he=$.next();!he.done;he=$.next()){var pe=he.value,le=pe.modelBindings.get(F);if(le?.modelBounds)return le.modelBounds}}catch(Te){z={error:Te}}finally{try{he&&!he.done&&(Y=$.return)&&Y.call($)}finally{if(z)throw z.error}}return null}function q(){var F,z,Y,$,he,pe,le={texturesPending:0,textureErrors:0,animations:{}};try{for(var Te=vn(s.values()),De=Te.next();!De.done;De=Te.next()){var oe=De.value,ee=oe.imageStatus();le.texturesPending+=ee.texturesPending,le.textureErrors+=ee.textureErrors}}catch(at){F={error:at}}finally{try{De&&!De.done&&(z=Te.return)&&z.call(Te)}finally{if(F)throw F.error}}try{for(var be=vn(m.values()),Be=be.next();!Be.done;Be=be.next()){var Re=Be.value;try{for(var Ye=(he=void 0,vn(Re.modelBindings)),nt=Ye.next();!nt.done;nt=Ye.next()){var Ge=Oa(nt.value,2),$e=Ge[0],mt=Ge[1];mt.animator&&(le.animations[$e]=mt.animator.snapshot())}}catch(at){he={error:at}}finally{try{nt&&!nt.done&&(pe=Ye.return)&&pe.call(Ye)}finally{if(he)throw he.error}}}}catch(at){Y={error:at}}finally{try{Be&&!Be.done&&($=be.return)&&$.call(be)}finally{if(Y)throw Y.error}}return le}function se(F){var z=m.get(F);z&&(z.recoil=1)}return{getStage:V,syncStage:I,renderStage:G,reset:H,dispose:Q,stepAnimations:T,playModelAnimation:S,modelBoundsFor:Z,modelStatus:q,triggerRecoil:se}}var _s=function(){return _s=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},_s.apply(this,arguments)},wa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Ta=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Gc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Mg=function(n,e,t){return Math.max(e,Math.min(t,n))},Xs=function(n,e){return Math.hypot(e.x-n.x,e.y-n.y)};function Sg(n){var e=n.id,t=n.nodes,i=n.edges,r=n.gates,a=r===void 0?[]:r,s=n.onEvent,o=s===void 0?function(){}:s,u=new Map(t.map(function(S){return[S.id,_s({},S)]})),l=new Map(i.map(function(S){return[S.id,_s({speedScale:1,enabled:!0,bidirectional:!1,cost:0},S)]})),d=new Map(a.map(function(S){return[S.id,_s({},S)]})),f=new Map,h=f,m=0,y=0,M=function(S){return u.get(S)},g=function(S){return Ta([],wa(d.values()),!1).find(function(Z){return Z.parameters.nodeId===S})},v=function(S){var Z=S.parameters;if(Z.mode==="open")return!0;if(Z.mode==="closed")return!1;var q=Z.openSeconds+Z.closedSeconds,se=(m+Z.phaseOffsetSeconds)%q;return se<Z.openSeconds},L=function(S){return Ta([],wa(l.values()),!1).filter(function(Z){return Z.enabled&&(Z.from===S||Z.bidirectional&&Z.to===S)}).sort(function(Z,q){return Z.id<q.id?-1:Z.id>q.id?1:0})},p=function(S,Z){return Ta([],wa(l.values()),!1).find(function(q){return q.enabled&&(q.from===S&&q.to===Z||q.bidirectional&&q.from===Z&&q.to===S)})};function _(S,Z){var q,se,F,z;if(S===Z)return[S];for(var Y=new Map([[S,0]]),$=new Map,he=new Set([S]);he.size;){var pe=Ta([],wa(he),!1).sort(function(Ge,$e){return Y.get(Ge)-Y.get($e)||(Ge<$e?-1:Ge>$e?1:0)})[0];if(he.delete(pe),pe===Z)break;try{for(var le=(q=void 0,Gc(L(pe))),Te=le.next();!Te.done;Te=le.next()){var De=Te.value,oe=De.from===pe?De.to:De.from,ee=g(oe),be=M(oe),Be=ee?ee.parameters.holdSeconds*90+(v(ee)?0:ee.parameters.closedSeconds*90):0,Re=Y.get(pe)+Xs(M(pe),be)/De.speedScale+De.cost+((F=be.cost)!==null&&F!==void 0?F:0)+Be;Re>=((z=Y.get(oe))!==null&&z!==void 0?z:1/0)||(Y.set(oe,Re),$.set(oe,pe),he.add(oe))}}catch(Ge){q={error:Ge}}finally{try{Te&&!Te.done&&(se=le.return)&&se.call(le)}finally{if(q)throw q.error}}}if(!Y.has(Z))return[];for(var Ye=[Z],nt=Z;nt!==S;)nt=$.get(nt),Ye.unshift(nt);return Ye}function N(S){var Z,q=S.route.length>=2&&S.segment<S.route.length-1;if(!q){var se=(Z=S.route[Math.min(S.segment,S.route.length-1)])!==null&&Z!==void 0?Z:S.startNode,F=_(se,S.target);S.route=F.length?F:[se],S.segment=0,S.distance=0,S.arrived=!1,S.active=S.route.length>=2;return}var z=S.route[S.segment],Y=S.route[S.segment+1],$=Xs(M(z),M(Y));if(S.arrived||S.distance>=$-1e-4){var F=_(Y,S.target);S.route=F.length?F:[Y],S.segment=0,S.distance=0,S.arrived=!1,S.active=S.route.length>=2;return}var he=_(Y,S.target);S.route=he.length?Ta([z],wa(he),!1):[z,Y],S.segment=0}function D(S){var Z,q=_(S.startNode,S.targetNode),se=M(S.startNode),F=q.length>=2?M(q[1]):se,z=q.length>=2?Math.atan2(F.y-se.y,F.x-se.x):0,Y=Math.floor((z%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,$=_s(_s({},S),{loop:(Z=S.loop)!==null&&Z!==void 0?Z:"none",originNode:S.startNode,destinationNode:S.targetNode,target:S.targetNode,networkId:e,route:q.length?q:[S.startNode],segment:0,distance:0,x:se.x,y:se.y,heading:z,frame:[0,1,2,3][Y],flipX:Math.cos(z)<0,hold:0,arrived:!1,active:S.active&&q.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return f.set($.id,$),$}function V(S){if(w("pathArrive",S,S.target),S.loop==="none"){S.active=!1;return}var Z=S.target,q=S.loop==="ping-pong"?Z===S.destinationNode?S.originNode:S.destinationNode:Z===S.originNode?S.destinationNode:S.originNode;S.startNode=Z,S.target=q,S.route=_(Z,q),S.segment=0,S.distance=0,S.arrived=!1,S.route.length<2&&(S.active=!1)}function w(S,Z,q){o(S,{componentId:Z.id,nodeId:q})}function I(S,Z){var q,se,F=S.route[S.segment+1],z=g(F);if(z&&!v(z)){S.blockedTicks++,S.blockedTicks>=30&&!S.blockedEmitted&&(S.blockedEmitted=!0,w("pathBlocked",S,F));return}if(!S.arrived){if(S.arrived=!0,S.segment+1===S.route.length-1){F===S.target?V(S):(S.active=!1,S.blockedEmitted||(S.blockedEmitted=!0,w("pathBlocked",S,F)));return}S.hold=Math.max((q=M(F).holdSeconds)!==null&&q!==void 0?q:0,(se=z?.parameters.holdSeconds)!==null&&se!==void 0?se:0)}if(S.hold>0){S.hold=Math.max(0,S.hold-Z),S.blockedTicks++,S.blockedTicks>=30&&!S.blockedEmitted&&(S.blockedEmitted=!0,w("pathBlocked",S,F));return}S.segment++,S.distance=0,S.arrived=!1,S.blockedTicks=0,S.blockedEmitted=!1}function G(S,Z){var q,se;if(S.spacing<=0)return Z;var F=S.route[S.segment],z=S.route[S.segment+1],Y=Xs(M(F),M(z)),$=Y-S.distance,he=Z;try{for(var pe=Gc(h.values()),le=pe.next();!le.done;le=pe.next()){var Te=le.value;if(!(Te.id===S.id||!Te.active||Te.route.length<2||Te.segment>=Te.route.length-1)){var De=Te.route[Te.segment],oe=Te.route[Te.segment+1],ee=1/0;if(De===F&&oe===z&&(Te.distance>S.distance||Te.distance===S.distance&&Te.id<S.id))ee=Te.distance-S.distance;else if(De===z)ee=$+Te.distance;else if(oe===z&&De!==F){var be=Xs(M(De),M(oe))-Te.distance;be<S.spacing&&(be<$||be===$&&Te.id<S.id)&&(ee=$)}ee<1/0&&(he=Math.min(he,Math.max(0,ee-S.spacing)))}}}catch(Be){q={error:Be}}finally{try{le&&!le.done&&(se=pe.return)&&se.call(pe)}finally{if(q)throw q.error}}return he}function H(S){var Z=M(S.route[S.segment]),q=M(S.route[S.segment+1]),se=Xs(Z,q),F=Mg(S.distance/Math.max(1e-4,se),0,1),z=Z.x+(q.x-Z.x)*F,Y=Z.y+(q.y-Z.y)*F,$=Math.atan2(q.y-Z.y,q.x-Z.x),he=Math.min(S.cornerRadius,se/3),pe=S.route[S.segment+2];if(he>0&&pe){var le=M(pe),Te=Xs(q,le),De=Math.min(he,Te/3);if(S.distance>se-he){var oe={x:q.x-(q.x-Z.x)/se*he,y:q.y-(q.y-Z.y)/se*he},ee={x:q.x+(le.x-q.x)/Te*De,y:q.y+(le.y-q.y)/Te*De},be=Mg((S.distance-(se-he))/(he*2),0,.5),Be=1-be;z=Be*Be*oe.x+2*Be*be*q.x+be*be*ee.x,Y=Be*Be*oe.y+2*Be*be*q.y+be*be*ee.y;var Re=2*Be*(q.x-oe.x)+2*be*(ee.x-q.x),Ye=2*Be*(q.y-oe.y)+2*be*(ee.y-q.y);Math.abs(Re)+Math.abs(Ye)>.001&&($=Math.atan2(Ye,Re))}}return{x:z,y:Y,heading:$}}function Q(S){var Z,q,se,F;m+=S,y++;var z=Ta([],wa(f.values()),!1).sort(function(at,Ve){return at.id<Ve.id?-1:at.id>Ve.id?1:0}),Y=z.length?y%z.length:0,$=Ta(Ta([],wa(z.slice(Y)),!1),wa(z.slice(0,Y)),!1);try{for(var he=Gc($),pe=he.next();!pe.done;pe=he.next()){var le=pe.value;if(!(!le.active||le.route.length<2||le.segment>=le.route.length-1)){var Te=le.route[le.segment],De=le.route[le.segment+1],oe=Xs(M(Te),M(De));if(!(le.distance>=oe-1e-4&&(I(le,S),!le.active||le.route.length<2||le.segment>=le.route.length-1))){var ee=le.route[le.segment],be=le.route[le.segment+1],Be=Xs(M(ee),M(be)),Re=Be-le.distance,Ye=(F=(se=p(ee,be))===null||se===void 0?void 0:se.speedScale)!==null&&F!==void 0?F:1,nt=Math.min(Re,le.speed*Ye*Math.max(0,le.speedMultiplier)*S),Ge=G(le,nt);Ge<=1e-4?(le.blockedTicks++,le.blockedTicks>=30&&!le.blockedEmitted&&(le.blockedEmitted=!0,w("pathBlocked",le,be))):(le.distance+=Ge,le.blockedTicks=0,le.blockedEmitted=!1);var $e=H(le);le.x=$e.x,le.y=$e.y,le.heading=$e.heading;var mt=Math.floor((le.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;le.frame=[0,1,2,3][mt],le.flipX=Math.cos(le.heading)<0}}}}catch(at){Z={error:at}}finally{try{pe&&!pe.done&&(q=he.return)&&q.call(he)}finally{if(Z)throw Z.error}}}function T(){return{id:e,nodeCount:u.size,edgeCount:l.size,activeAgents:Ta([],wa(f.values()),!1).filter(function(S){return S.active}).length,queuedAgents:Ta([],wa(f.values()),!1).filter(function(S){return S.active&&S.blockedTicks>0}).length,agents:Ta([],wa(f.values()),!1).map(function(S){var Z;return{id:S.id,x:S.x,y:S.y,heading:S.heading,frame:(Z=S.frame)!==null&&Z!==void 0?Z:0,flipX:!!S.flipX,active:S.active,targetNode:S.target,route:Ta([],wa(S.route),!1),segment:S.segment,distance:S.distance,blocked:S.blockedTicks>0}})}}return{addAgent:D,removeAgent:function(S){return f.delete(S)},getAgent:function(S){return f.get(S)},setTarget:function(S,Z){var q=f.get(S);return!q||!M(Z)?!1:(q.target=Z,q.destinationNode=Z,q.active=!0,N(q),!0)},setEdge:function(S,Z,q){var se,F,z=l.get(S);if(!z)return!1;z.enabled=Z,q!==void 0&&(z.cost=q);try{for(var Y=Gc(f.values()),$=Y.next();!$.done;$=Y.next()){var he=$.value;N(he)}}catch(pe){se={error:pe}}finally{try{$&&!$.done&&(F=Y.return)&&F.call(Y)}finally{if(se)throw se.error}}return!0},setGate:function(S,Z,q){var se,F,z=d.get(S);if(!z)return!1;z.parameters=_s(_s({},z.parameters),{mode:Z,holdSeconds:q});try{for(var Y=Gc(f.values()),$=Y.next();!$.done;$=Y.next()){var he=$.value;N(he)}}catch(pe){se={error:pe}}finally{try{$&&!$.done&&(F=Y.return)&&F.call(Y)}finally{if(se)throw se.error}}return!0},tick:Q,snapshot:T}}var Hc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},bf=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},wf=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Tf={A:["01110","10001","10001","11111","10001","10001","10001"],B:["11110","10001","10001","11110","10001","10001","11110"],C:["01111","10000","10000","10000","10000","10000","01111"],D:["11110","10001","10001","10001","10001","10001","11110"],E:["11111","10000","10000","11110","10000","10000","11111"],F:["11111","10000","10000","11110","10000","10000","10000"],G:["01111","10000","10000","10111","10001","10001","01111"],H:["10001","10001","10001","11111","10001","10001","10001"],I:["11111","00100","00100","00100","00100","00100","11111"],J:["00111","00010","00010","00010","10010","10010","01100"],K:["10001","10010","10100","11000","10100","10010","10001"],L:["10000","10000","10000","10000","10000","10000","11111"],M:["10001","11011","10101","10101","10001","10001","10001"],N:["10001","11001","10101","10011","10001","10001","10001"],O:["01110","10001","10001","10001","10001","10001","01110"],P:["11110","10001","10001","11110","10000","10000","10000"],Q:["01110","10001","10001","10001","10101","10010","01101"],R:["11110","10001","10001","11110","10100","10010","10001"],S:["01111","10000","10000","01110","00001","00001","11110"],T:["11111","00100","00100","00100","00100","00100","00100"],U:["10001","10001","10001","10001","10001","10001","01110"],V:["10001","10001","10001","10001","10001","01010","00100"],W:["10001","10001","10001","10101","10101","10101","01010"],X:["10001","10001","01010","00100","01010","10001","10001"],Y:["10001","10001","01010","00100","00100","00100","00100"],Z:["11111","00001","00010","00100","01000","10000","11111"],0:["01110","10001","10011","10101","11001","10001","01110"],1:["00100","01100","00100","00100","00100","00100","01110"],2:["01110","10001","00001","00010","00100","01000","11111"],3:["11110","00001","00001","01110","00001","00001","11110"],4:["00010","00110","01010","10010","11111","00010","00010"],5:["11111","10000","10000","11110","00001","00001","11110"],6:["01110","10000","10000","11110","10001","10001","01110"],7:["11111","00001","00010","00100","01000","01000","01000"],8:["01110","10001","10001","01110","10001","10001","01110"],9:["01110","10001","10001","01111","00001","00001","01110"],"!":["00100","00100","00100","00100","00100","00000","00100"],"?":["01110","10001","00001","00010","00100","00000","00100"],".":["00000","00000","00000","00000","00000","00110","00110"],",":["00000","00000","00000","00000","00110","00110","00100"],":":["00000","00110","00110","00000","00110","00110","00000"],"+":["00000","00100","00100","11111","00100","00100","00000"],"-":["00000","00000","00000","11111","00000","00000","00000"],"/":["00001","00010","00010","00100","01000","01000","10000"],"'":["00100","00100","00000","00000","00000","00000","00000"]," ":["000","000","000","000","000","000","000"]},Wc=function(n){var e,t,i,r,a=0;try{for(var s=Hc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a+=((r=(i=Tf[u])===null||i===void 0?void 0:i[0].length)!==null&&r!==void 0?r:5)+1}}catch(l){e={error:l}}finally{try{o&&!o.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return Math.max(0,a-1)},$w=function(n,e){var t,i,r=[],a="";try{for(var s=Hc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a&&Wc(a+u)>e&&(r.push(a),a=""),a+=u}}catch(l){t={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return a&&r.push(a),r};function Kw(n,e,t){var i,r,a,s,o;t===void 0&&(t=1);var u=Math.max(1,Math.floor(e/Math.max(1,t))),l=[];try{for(var d=Hc(String(n).toUpperCase().split(`
|
|
4221
|
+
`)),f=d.next();!f.done;f=d.next()){var h=f.value,m=h.split(/\s+/).filter(Boolean);if(!m.length){l.push("");continue}var y="";try{for(var M=(a=void 0,Hc(m)),g=M.next();!g.done;g=M.next()){var v=g.value;if(Wc(v)>u){y&&l.push(y);var L=$w(v,u);l.push.apply(l,wf([],bf(L.slice(0,-1)),!1)),y=(o=L.at(-1))!==null&&o!==void 0?o:""}else{var p=y?y+" "+v:v;Wc(p)<=u?y=p:(y&&l.push(y),y=v)}}}catch(_){a={error:_}}finally{try{g&&!g.done&&(s=M.return)&&s.call(M)}finally{if(a)throw a.error}}y&&l.push(y)}}catch(_){i={error:_}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(i)throw i.error}}return l}var bg=function(n){var e,t=Math.max(0,(e=n.padding)!==null&&e!==void 0?e:4),i=n.pixelPanel&&n.padding===void 0;return{x:i?8:t,y:i?4:t}},Qw=function(n,e,t,i){var r,a=e.wrap===!1?String(n).toUpperCase().split(`
|
|
4222
|
+
`):Kw(n,i,t),s=a.slice(0,16),o=Math.round(t*8*((r=e.lineHeight)!==null&&r!==void 0?r:1.2));return{allLines:a,lines:s,renderedWidth:Math.max.apply(Math,wf([0],bf(s.map(function(u){return Wc(u)*t})),!1)),renderedHeight:(s.length-1)*o+7*t}};function qp(n,e){for(var t,i=bg(e),r=Math.max(0,e.width-2*i.x),a=Math.max(0,e.height-2*i.y),s=Math.max(1,Math.floor(e.fontSize/8)),o=e.autoFit===!1?s:Math.min(s,Math.max(1,Math.ceil(((t=e.minFontSize)!==null&&t!==void 0?t:12)/8))),u=wf([],bf(new Set(wf([],bf(String(n).toUpperCase()),!1).filter(function(y){return y!==`
|
|
4223
|
+
`&&!Tf[y]}))),!1),l,d=s;d>=o;d--){var f=Qw(n,e,d,r),h=f.renderedWidth>r,m=f.allLines.length>16||f.renderedHeight>a;if(l={lines:f.lines,scale:d,fontSize:d*8,renderedWidth:f.renderedWidth,renderedHeight:f.renderedHeight,overflowsWidth:h,overflowsHeight:m,unsupportedChars:u},e.autoFit===!1||!h&&!m)break}return l}function wg(n,e,t){var i,r=qp(e,t),a=r.lines,s=r.scale,o=bg(t),u=Math.max(0,t.width-2*o.x),l=Math.max(0,t.height-2*o.y),d=Math.round(r.fontSize*((i=t.lineHeight)!==null&&i!==void 0?i:1.2)),f=o.y+(l-r.renderedHeight)/2;return n.fillStyle=t.color,a.forEach(function(h,m){var y,M,g,v=Wc(h)*s,L=t.align==="left"?o.x:t.align==="right"?t.width-v-o.x:o.x+(u-v)/2,p=L;try{for(var _=Hc(h),N=_.next();!N.done;N=_.next()){var D=N.value,V=(g=Tf[D])!==null&&g!==void 0?g:Tf["?"];V.forEach(function(w,I){for(var G=0;G<w.length;G++)w[G]==="1"&&n.fillRect(Math.round(p+G*s),Math.round(f+m*d+I*s),s,s)}),p+=(V[0].length+1)*s}}catch(w){y={error:w}}finally{try{N&&!N.done&&(M=_.return)&&M.call(_)}finally{if(y)throw y.error}}}),r}var ts=function(){return ts=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},ts.apply(this,arguments)},Jp=Math.PI*2,Xi=function(n,e){return((Math.imul(n+1,2654435769)^Math.imul(e,2246822507))>>>0)/4294967296};function $p(n,e,t){var i,r,a=[n.color,n.color2,n.color3].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+Xi(l,1)*.6)/n.count-.5)*s,m=n.speed*(.42+.65*Xi(l,2));return ts(ts({},e),{clipId:t,shape:"pixel-confetti",age:-.12*Xi(l,3),vx:Math.cos(h)*m,vy:Math.sin(h)*m,gravity:(d=n.gravity)!==null&&d!==void 0?d:250,life:((f=n.lifetime)!==null&&f!==void 0?f:.7)*(.6+.4*Xi(l,4)),color:a[l%a.length],size:3+Math.floor(3*Xi(l,5)),angle:Jp*Xi(l,6),spin:(Xi(l,7)-.5)*12})})}function Tg(n){var e=Math.min(12,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return $p(n).map(function(r,a){return ts(ts({},r),{screen:!0,x:(a%e+.15+.7*Xi(a,8))/e,y:(Math.floor(a/e)+.15+.7*Xi(a,9))/t,vx:i*(Xi(a,10)-.5)*.7,vy:i*(.3+.5*Xi(a,11)),size:r.size+1})})}var Ef=function(n,e){return(n%e+e)%e};function Ag(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,m=e.color;if(!(o<0)){var y=a*o,M=s*o+l*o*o/2,g=Math.round(t?t.x+Ef(i*t.width+y,t.width):i+y),v=Math.round(t?t.y+Ef(r*t.height+M,t.height):r+M),L=Math.round((f+h*o)/(Math.PI/4))&3;if(n.globalAlpha*=Math.min(1,(u-o)*4),n.fillStyle="#3c293388",L===0)n.fillRect(g-d+1,v+1,d*2+1,d+1);else if(L===2)n.fillRect(g+1,v-d+1,d+1,d*2+1);else for(var p=-1;p<=1;p++)n.fillRect(g+p*d+1,v+p*d*(L===1?1:-1)+1,d+1,d+1);if(n.fillStyle=m,L===0)n.fillRect(g-d,v,d*2,d);else if(L===2)n.fillRect(g,v-d,d,d*2);else for(var p=-1;p<=1;p++)n.fillRect(g+p*d,v+p*d*(L===1?1:-1),d,d)}}function Kp(n,e,t){var i,r,a=[n.color,n.color2,n.color3,"#ff6b6b","#4ecdc4","#fff3b0"].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+Xi(l,11)*.6)/n.count-.5)*s,m=n.speed*(.45+.65*Xi(l,12));return ts(ts({},e),{clipId:t,shape:"confetti",age:-.15*Xi(l,13),vx:Math.cos(h)*m,vy:Math.sin(h)*m,gravity:(d=n.gravity)!==null&&d!==void 0?d:140,life:((f=n.lifetime)!==null&&f!==void 0?f:2.6)*(.75+.35*Xi(l,14)),color:a[l%a.length],size:5+Math.floor(5*Xi(l,15)),kind:l%5===0?"star":"ribbon",angle:Jp*Xi(l,16),spin:(Xi(l,17)-.5)*5.5,flutter:1.6+2.2*Xi(l,18),phase:Jp*Xi(l,19)})})}function Eg(n){var e=Math.min(14,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Kp(n,{x:0,y:0}).map(function(r,a){var s;return ts(ts({},r),{screen:!0,x:(a%e+.12+.76*Xi(a,20))/e,y:(Math.floor(a/e)+.08+.84*Xi(a,21))/t,vx:i*(Xi(a,22)-.5)*.65,vy:i*(.38+.55*Xi(a,23)),gravity:Math.min((s=n.gravity)!==null&&s!==void 0?s:90,90)})})}function Ig(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,m=e.flutter,y=e.phase,M=e.color,g=e.kind;if(!(o<0)){var v=Math.sin(o*m+y)*14,L=a*o+v,p=s*o+l*o*o/2,_=t?t.x+Ef(i*t.width+L,t.width):i+L,N=t?t.y+Ef(r*t.height+p,t.height):r+p,D=Math.min(1,o*2.8,(u-o)*2.2);if(!(D<=0)){n.save(),n.globalAlpha*=D,n.translate(_,N),n.rotate(f+h*o);var V=Math.cos(o*m*1.4+y);if(n.scale(1,Math.max(.22,Math.abs(V))),n.fillStyle=M,g==="star"){var w=d*.85;n.beginPath();for(var I=0;I<8;I++){var G=I%2===0?w:w*.38,H=I*Math.PI/4;I===0?n.moveTo(Math.cos(H)*G,Math.sin(H)*G):n.lineTo(Math.cos(H)*G,Math.sin(H)*G)}n.closePath(),n.fill()}else n.fillRect(-d*.7,-d*.34,d*1.4,d*.68),n.fillStyle="#ffffff55",n.fillRect(-d*.7,-d*.34,d*1.4,d*.2);n.restore()}}}function Cg(n,e,t,i,r){var a=e.width,s=e.height;if(!(a<=0||s<=0)){var o=Math.min(3,Math.floor(Math.min(a,s)/8));if(!o){n.fillStyle=t,n.fillRect(0,0,a,s);return}var u=i?o*2:0,l=s-(i?o:o*3),d=r>=0?.5+.5*Math.sin(r*4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd05a99",n.shadowBlur=8+d*9,n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.restore()),n.fillStyle=e.stroke,n.fillRect(o,0,a-2*o,s),n.fillRect(0,o,a,s-2*o),n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.fillStyle="#431d1380",n.fillRect(o,l,a-2*o,s-o-l),n.fillStyle=e.enabled?"#fff4be":"#ffffff55",n.fillRect(2*o,u+o,a-4*o,i?o:o*2),n.fillStyle="#ffffff55",n.fillRect(o,u+3*o,o,Math.max(0,l-u-3*o)),n.fillStyle="#521b2444",n.fillRect(a-2*o,u+3*o,o,Math.max(0,l-u-3*o));var f=r>=0?r%1.9:-1,h=(f-.1)/.55;if(e.enabled&&!i&&h>=0&&h<1){n.save(),n.beginPath(),n.rect(2*o,u+3*o,a-4*o,Math.max(0,l-u-3*o)),n.clip();for(var m=Math.floor(((a+14*o)*h-6*o)/o)*o,y=u+3*o,M=0;y<l;y+=o,M++){var g=m-Math.floor(M/2)*o;n.fillStyle="#fff4be44",n.fillRect(g-2*o,y,9*o,o),n.fillStyle="#fffef0aa",n.fillRect(g,y,4*o,o)}n.restore()}if(e.enabled&&!i&&r>=0){var v=Math.max(0,Math.sin(r*4.2)),L=Math.max(0,Math.sin(r*4.2+2.2)),p=function(_,N,D){if(!(D<.25)){n.save(),n.globalAlpha*=D*.95,n.fillStyle="#fffef4";var V=D>.65?o*2:o;n.fillRect(Math.round(_-V),Math.round(N-o/2),V*2+o,o),n.fillRect(Math.round(_-o/2),Math.round(N-V),o,V*2+o),n.restore()}};p(5*o,u+4*o,v),p(a-6*o,u+5*o,L)}}}function Af(n,e,t,i,r,a){var s=Math.max(0,Math.min(a,i/2,r/2));n.beginPath(),typeof n.roundRect=="function"?n.roundRect(e,t,i,r,s):(n.moveTo(e+s,t),n.arcTo(e+i,t,e+i,t+r,s),n.arcTo(e+i,t+r,e,t+r,s),n.arcTo(e,t+r,e,t,s),n.arcTo(e,t,e+i,t,s),n.closePath())}function Zp(n,e,t,i,r){if(!(r<=.02||i<=.5)){n.save(),n.translate(e,t),n.globalAlpha*=r,n.fillStyle="#fffef0",n.beginPath();for(var a=0;a<8;a++){var s=a%2===0?i:i*.24,o=a*Math.PI/4;a===0?n.moveTo(Math.cos(o)*s,Math.sin(o)*s):n.lineTo(Math.cos(o)*s,Math.sin(o)*s)}n.closePath(),n.fill(),n.restore()}}function Rg(n,e,t,i,r){var a,s,o,u=e.width,l=e.height;if(!(u<=0||l<=0)){var d=Math.min((a=e.radius)!==null&&a!==void 0?a:16,u/2,l/2),f=i?2:6,h=i?3:0,m=r>=0?.5-.5*Math.cos(r*2.4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd23f99",n.shadowBlur=10+m*12,Af(n,0,h,u,l-h,d),n.fillStyle=t,n.fill(),n.restore()),n.save(),Af(n,0,h+2,u,Math.max(4,l-h-2),d),n.fillStyle="#0e2830",n.fill(),n.restore(),n.save(),Af(n,0,h,u,Math.max(4,l-f),d),n.fillStyle=t,n.fill(),n.clip();var y=(s=n.createLinearGradient)===null||s===void 0?void 0:s.call(n,0,h,0,l-f);if(y?.addColorStop&&(y.addColorStop(0,"#ffffffa8"),y.addColorStop(.42,"#ffffff26"),y.addColorStop(.45,"#00000000"),y.addColorStop(1,"#00000024"),n.fillStyle=y,n.fillRect(0,h,u,l-f)),n.fillStyle="#fffef0bb",n.fillRect(d*.55,h+3,Math.max(0,u-d*1.1),3),e.enabled&&!i&&r>=0){var M=(r%2.4-.15)/.95;if(M>0&&M<1){var g=M*M*(3-2*M),v=Math.sin(M*Math.PI),L=-u*.36+u*1.72*g;n.save(),n.globalAlpha*=v,n.translate(L,h),n.transform(1,0,-.36,1,0,0);var p=(o=n.createLinearGradient)===null||o===void 0?void 0:o.call(n,-48,0,48,0);p?.addColorStop?(p.addColorStop(0,"#ffffff00"),p.addColorStop(.32,"#ffffff48"),p.addColorStop(.5,"#fffef8cc"),p.addColorStop(.68,"#ffffff48"),p.addColorStop(1,"#ffffff00"),n.fillStyle=p,n.fillRect(-48,0,96,l)):(n.fillStyle="#fffef8a8",n.fillRect(-14,0,28,l)),n.restore()}}if(n.restore(),e.strokeWidth&&(n.save(),Af(n,0,h,u,Math.max(4,l-f),d),n.strokeStyle=e.stroke,n.lineWidth=e.strokeWidth,n.stroke(),n.restore()),e.enabled&&!i&&r>=0){var _=Math.max(0,Math.sin(r*2.4)),N=_*_,D=Math.max(0,Math.sin(r*2.4+2.1)),V=D*D,w=Math.max(0,Math.sin(r*2.4+4.2)),I=w*w;Zp(n,u*.12,h+9,4+N*6,N*.92),Zp(n,u*.88,h+10,3.8+V*5.5,V*.9),Zp(n,u*.76,Math.max(h+14,l-f-8),3+I*4.2,I*.8)}}}function If(n){if(/\s/.test(n)||n.length>512)return!1;var e=/^https:\/\/play\.google\.com\/store\/apps\/details\?id=[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*){1,9}$/,t=/^https:\/\/apps\.apple\.com\/([a-z]{2}\/)?app\/([a-zA-Z0-9-]+\/)?id[1-9][0-9]{5,19}$/;return e.test(n)&&!/id=example\.|[.=]placeholder(\.|$)|id=com\.example(\.|$)/.test(n)||t.test(n)}var Xc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Yc=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Qp=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function Pg(n){var e,t,i;n===void 0&&(n={});var r=(e=n.timeoutMs)!==null&&e!==void 0?e:5e3,a=(t=n.pollMs)!==null&&t!==void 0?t:25;if(![r,a].every(function(F){return Number.isFinite(F)&&F>=1&&F<=6e4}))throw Error("Invalid Unity host deadline/poll interval");var s=(i=n.getHost)!==null&&i!==void 0?i:(function(){return window.mraid}),o=new Set,u=new Set,l=[],d={},f=!1,h=!1,m=!1,y=!1,M=!1,g=!1,v,L,p,_,N,D,V=function(){return m||y};function w(){var F,z,Y;clearTimeout(N),clearTimeout(D);try{for(var $=Xc(l.splice(0)),he=$.next();!he.done;he=$.next()){var pe=Yc(he.value,2),le=pe[0],Te=pe[1];try{(Y=d.mraid)===null||Y===void 0||Y.removeEventListener(le,Te)}catch{}}}catch(De){F={error:De}}finally{try{he&&!he.done&&(z=$.return)&&z.call($)}finally{if(F)throw F.error}}}function I(F){_?.(F instanceof Error?F:Error(String(F))),p=void 0,_=void 0}function G(F){var z,Y;if(!V()){var $=f;if(m=!0,f=!1,h=!1,w(),I(F),$)try{for(var he=Xc(Qp([],Yc(u),!1)),pe=he.next();!pe.done;pe=he.next()){var le=pe.value;le()}}catch(Te){z={error:Te}}finally{try{pe&&!pe.done&&(Y=he.return)&&Y.call(he)}finally{if(z)throw z.error}}o.clear(),u.clear()}}function H(F,z){return l.push([F,z]),d.mraid.addEventListener(F,z),Q(F,z)}function Q(F,z){if(V()){try{d.mraid.removeEventListener(F,z)}catch{}return!1}return!0}function T(F){var z,Y;if(!V()){if(typeof F!="boolean"){G(Error("Invalid Unity viewability event"));return}if(!f){v=F;return}if(h!==F){h=F;try{for(var $=Xc(Qp([],Yc(o),!1)),he=$.next();!he.done;he=$.next()){var pe=he.value;if(V())break;pe(h)}}catch(le){z={error:le}}finally{try{he&&!he.done&&(Y=$.return)&&Y.call($)}finally{if(z)throw z.error}}}}}var S=function(F){F==="hidden"&&G(Error("Unity host closed"))},Z=function(){var F;f&&!V()&&((F=n.onResize)===null||F===void 0||F.call(n))};function q(){var F,z,Y,$;if(!(!M||f||g||V())){g=!0;try{var he=d.mraid.getState();if(V()||he==="loading")return;if(he==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(he))throw Error("Invalid Unity host state");var pe=d.mraid.getVersion();if(V())return;if(pe!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var le=Xc([["viewableChange",T],["stateChange",S],["sizeChange",Z]]),Te=le.next();!Te.done;Te=le.next()){var De=Yc(Te.value,2),oe=De[0],ee=De[1];if(!H(oe,ee))return}}catch(nt){F={error:nt}}finally{try{Te&&!Te.done&&(z=le.return)&&z.call(le)}finally{if(F)throw F.error}}var be=d.mraid.isViewable();if(V())return;if(typeof be!="boolean")throw Error("Invalid Unity initial viewability");h=v??be,f=!0,clearTimeout(N),clearTimeout(D),p?.(),p=void 0,_=void 0;try{for(var Be=Xc(Qp([],Yc(o),!1)),Re=Be.next();!Re.done;Re=Be.next()){var Ye=Re.value;if(V())break;Ye(h)}}catch(nt){Y={error:nt}}finally{try{Re&&!Re.done&&($=Be.return)&&$.call(Be)}finally{if(Y)throw Y.error}}}catch(nt){G(nt)}finally{g=!1}}}function se(){if(!V())try{var F=s();if(V())return;if(!F){D=setTimeout(se,a);return}if(d.mraid=F,l.push(["ready",q]),d.mraid.addEventListener("ready",q),!Q("ready",q))return;M=!0,q()}catch(z){G(z)}}return{init:function(){return L||(L=new Promise(function(F,z){p=F,_=z}),V()?(I(Error("Unity bridge destroyed")),L):(N=setTimeout(function(){return G(Error("Unity MRAID readiness timed out"))},r),se(),L))},isReady:function(){return f&&!V()},isVisible:function(){return f&&h&&!V()},isClosed:V,onVisibilityChanged:function(F){return V()||o.add(F),function(){return o.delete(F)}},onClosed:function(F){return V()||u.add(F),function(){return u.delete(F)}},openStore:function(F){if(!f||!h||V()||!If(F))throw Error("Unity store request not permitted");d.mraid.open(F)},destroy:function(){y||(y=!0,f=!1,h=!1,w(),I(Error("Unity bridge destroyed")),o.clear(),u.clear())}}}var Ml=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Sl=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},jp=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function Lg(n){var e;n===void 0&&(n={});var t=(e=n.getHost)!==null&&e!==void 0?e:(function(){return window.mraid}),i,r=!1,a=!1,s=!1,o=!1,u=!1,l,d,f,h,m,y=new Set,M=new Set,g=[];function v(){var H,Q;clearTimeout(h),clearTimeout(m);try{for(var T=Ml(g.splice(0)),S=T.next();!S.done;S=T.next()){var Z=Sl(S.value,2),q=Z[0],se=Z[1];try{i?.removeEventListener(q,se)}catch{}}}catch(F){H={error:F}}finally{try{S&&!S.done&&(Q=T.return)&&Q.call(T)}finally{if(H)throw H.error}}}function L(H,Q){if(g.push([H,Q]),i.addEventListener(H,Q),s||o){try{i.removeEventListener(H,Q)}catch{}return!1}return!0}function p(H){var Q=H instanceof Error?H:Error(String(H));f?.(Q),d=void 0,f=void 0}function _(H,Q){var T,S;if(!(s||o)&&(s=!0,r=!1,a=!1,v(),p(H),Q))try{for(var Z=Ml(jp([],Sl(M),!1)),q=Z.next();!q.done;q=Z.next()){var se=q.value;se()}}catch(F){T={error:F}}finally{try{q&&!q.done&&(S=Z.return)&&S.call(Z)}finally{if(T)throw T.error}}}function N(){var H,Q,T,S;if(!(!u||r||s||o))try{var Z=i.getState();if(s||o||Z==="loading")return;if(Z==="hidden"){_(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(Z))throw Error("Invalid MRAID state");try{for(var q=Ml([["viewableChange",V],["stateChange",w],["sizeChange",I]]),se=q.next();!se.done;se=q.next()){var F=Sl(se.value,2),z=F[0],Y=F[1];if(!L(z,Y))return}}catch(le){H={error:le}}finally{try{se&&!se.done&&(Q=q.return)&&Q.call(q)}finally{if(H)throw H.error}}var $=i.isViewable();if(s||o)return;if(typeof $!="boolean")throw Error("Invalid MRAID viewability");a=$,r=!0,clearTimeout(h),clearTimeout(m),d?.(),d=void 0,f=void 0;try{for(var he=Ml(jp([],Sl(y),!1)),pe=he.next();!pe.done;pe=he.next()){var Y=pe.value;Y(a)}}catch(le){T={error:le}}finally{try{pe&&!pe.done&&(S=he.return)&&S.call(he)}finally{if(T)throw T.error}}}catch(le){_(le,r)}}var D=function(){return N()},V=function(H){var Q,T;if(!(!r||s||o)){if(typeof H!="boolean"){_(Error("Invalid MRAID visibility event"),!0);return}a=H;try{for(var S=Ml(jp([],Sl(y),!1)),Z=S.next();!Z.done;Z=S.next()){var q=Z.value;q(a)}}catch(se){Q={error:se}}finally{try{Z&&!Z.done&&(T=S.return)&&T.call(S)}finally{if(Q)throw Q.error}}}},w=function(H){H==="hidden"&&_(Error("MRAID closed"),!0)},I=function(){var H;r&&!s&&!o&&((H=n.onResize)===null||H===void 0||H.call(n))};function G(){var H,Q,T;if(!(s||o))try{if(i=t(),s||o)return;if(!i){m=setTimeout(G,(T=n.pollMs)!==null&&T!==void 0?T:50);return}if(![i.getState,i.isViewable,i.addEventListener,i.removeEventListener,i.open].every(function(z){return typeof z=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var S=Ml([["ready",D]]),Z=S.next();!Z.done;Z=S.next()){var q=Sl(Z.value,2),se=q[0],F=q[1];if(!L(se,F))return}}catch(z){H={error:z}}finally{try{Z&&!Z.done&&(Q=S.return)&&Q.call(S)}finally{if(H)throw H.error}}u=!0,N()}catch(z){_(z,!1)}}return{init:function(){var H;return l||(l=new Promise(function(Q,T){d=Q,f=T}),s||o?(p(Error("MRAID bridge destroyed")),l):(h=setTimeout(function(){return _(Error("MRAID readiness timed out"),!1)},(H=n.timeoutMs)!==null&&H!==void 0?H:5e3),G(),l))},isReady:function(){return r&&!s&&!o},isVisible:function(){return a&&r&&!s&&!o},isClosed:function(){return s||o},onVisibilityChanged:function(H){return!s&&!o&&y.add(H),function(){return y.delete(H)}},onClosed:function(H){return!s&&!o&&M.add(H),function(){return M.delete(H)}},openStore:function(H){if(!r||!a||s||o||!If(H))throw Error("MRAID store request not permitted");i.open(H)},destroy:function(){o||(o=!0,r=!1,a=!1,v(),p(Error("MRAID bridge destroyed")),y.clear(),M.clear())}}}var xo=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},_o=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},qc=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function Dg(n){n===void 0&&(n={});var e=new Set,t=new Set,i=new Set,r=[],a,s=!1,o=!1,u=!1,l=!1,d,f,h,m,y,M=function(){return u||l};function g(){var I,G;clearTimeout(m),clearTimeout(y);try{for(var H=xo(r.splice(0)),Q=H.next();!Q.done;Q=H.next()){var T=_o(Q.value,2),S=T[0],Z=T[1];try{a?.removeEventListener(S,Z)}catch{}}}catch(q){I={error:q}}finally{try{Q&&!Q.done&&(G=H.return)&&G.call(H)}finally{if(I)throw I.error}}}function v(I){var G,H;if(!M()){u=!0,s=!1,o=!1,g(),h?.(I instanceof Error?I:Error(String(I))),f=void 0,h=void 0;try{for(var Q=xo(qc([],_o(t),!1)),T=Q.next();!T.done;T=Q.next()){var S=T.value;S()}}catch(Z){G={error:Z}}finally{try{T&&!T.done&&(H=Q.return)&&H.call(Q)}finally{if(G)throw G.error}}}}var L=function(I){if(!(typeof I!="number"||!Number.isFinite(I)||I<0))return Math.min(1,I>1?I/100:I)},p=function(I){if(typeof I=="boolean")return I;if(I&&typeof I=="object"&&typeof I.isViewable=="boolean")return I.isViewable},_=function(){var I,G,H,Q,T,S;if(!(s||M()||!a||((T=a.isReady)===null||T===void 0?void 0:T.call(a))===!1))try{o=a.isViewable();var Z=(S=a.getAudioVolume)===null||S===void 0?void 0:S.call(a),q=Z===void 0?void 0:L(Z);if(typeof o!="boolean"||Z!==void 0&&q===void 0)throw Error("Invalid DAPI initial state");if(s=!0,clearTimeout(m),clearTimeout(y),f?.(),f=void 0,h=void 0,q!==void 0)try{for(var se=xo(qc([],_o(i),!1)),F=se.next();!F.done;F=se.next()){var z=F.value;z(q)}}catch(he){I={error:he}}finally{try{F&&!F.done&&(G=se.return)&&G.call(se)}finally{if(I)throw I.error}}try{for(var Y=xo(qc([],_o(e),!1)),$=Y.next();!$.done;$=Y.next()){var z=$.value;z(o)}}catch(he){H={error:he}}finally{try{$&&!$.done&&(Q=Y.return)&&Q.call(Y)}finally{if(H)throw H.error}}}catch(he){v(he)}},N=function(I){var G,H;if(!M()){var Q=p(I);if(Q===void 0){v(Error("Invalid DAPI visibility"));return}o=Q;try{for(var T=xo(qc([],_o(e),!1)),S=T.next();!S.done;S=T.next()){var Z=S.value;Z(Q)}}catch(q){G={error:q}}finally{try{S&&!S.done&&(H=T.return)&&H.call(T)}finally{if(G)throw G.error}}}},D=function(I){var G,H;if(!M()){var Q=L(I);if(Q===void 0){v(Error("Invalid DAPI volume"));return}try{for(var T=xo(qc([],_o(i),!1)),S=T.next();!S.done;S=T.next()){var Z=S.value;Z(Q)}}catch(q){G={error:q}}finally{try{S&&!S.done&&(H=T.return)&&H.call(T)}finally{if(G)throw G.error}}}},V=function(){var I;s&&!M()&&((I=n.onResize)===null||I===void 0||I.call(n))};function w(){var I,G,H;if(!M()){if(a=window.dapi,!a){y=setTimeout(w,(H=n.pollMs)!==null&&H!==void 0?H:25);return}try{try{for(var Q=xo([["ready",_],["viewableChange",N],["audioVolumeChange",D],["adResized",V]]),T=Q.next();!T.done;T=Q.next()){var S=_o(T.value,2),Z=S[0],q=S[1];r.push([Z,q]),a.addEventListener(Z,q)}}catch(se){I={error:se}}finally{try{T&&!T.done&&(G=Q.return)&&G.call(Q)}finally{if(I)throw I.error}}_()}catch(se){v(se)}}}return{init:function(){var I;return d||(d=new Promise(function(G,H){f=G,h=H}),M()?(h?.(Error("DAPI bridge closed")),d):(m=setTimeout(function(){return v(Error("DAPI readiness timed out"))},(I=n.timeoutMs)!==null&&I!==void 0?I:5e3),w(),d))},isReady:function(){return s&&!M()},isVisible:function(){return s&&o&&!M()},isClosed:M,onVisibilityChanged:function(I){return M()||e.add(I),function(){return e.delete(I)}},onClosed:function(I){return M()||t.add(I),function(){return t.delete(I)}},onVolumeChanged:function(I){return M()||i.add(I),function(){return i.delete(I)}},openStore:function(){if(!s||!o||M()||typeof a?.openStoreUrl!="function")throw Error("DAPI store host unavailable");a.openStoreUrl()},destroy:function(){l||(l=!0,s=!1,o=!1,g(),h?.(Error("DAPI bridge destroyed")),e.clear(),t.clear(),i.clear())}}}var jw=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},e1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},t1=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},n1=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},i1=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Ng(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=i1(n1([],t1(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return jw(this,void 0,void 0,function(){return e1(this,function(a){switch(a.label){case 0:if(i)throw Error("Meta bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Meta bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.FbPlayableAd;if(!e||!t||i||typeof a?.onCTAClick!="function")throw Error("Meta CTA host unavailable");a.onCTAClick()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var r1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},a1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},s1=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},o1=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},l1=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Ug(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=l1(o1([],s1(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return r1(this,void 0,void 0,function(){return a1(this,function(a){switch(a.label){case 0:if(i)throw Error("Google Ads bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Google Ads bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.ExitApi;if(!e||!t||i||typeof a?.exit!="function")throw Error("Google ExitApi unavailable");a.exit()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var c1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},u1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},em=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},tm=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},nm=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Fg(){var n=window,e=new Set,t=new Set,i=n.gameStart,r=n.gameClose,a=!1,s=!1,o=!1,u=!1,l=function(){var f,h;if(!(o||u)){var m=!s||!a;if(a=!0,s=!0,m)try{for(var y=nm(tm([],em(e),!1)),M=y.next();!M.done;M=y.next()){var g=M.value;g(!0)}}catch(v){f={error:v}}finally{try{M&&!M.done&&(h=y.return)&&h.call(y)}finally{if(f)throw f.error}}}},d=function(){var f,h,m,y;if(!(o||u)){a=!1,s=!1,o=!0;try{for(var M=nm(tm([],em(e),!1)),g=M.next();!g.done;g=M.next()){var v=g.value;v(!1)}}catch(_){f={error:_}}finally{try{g&&!g.done&&(h=M.return)&&h.call(M)}finally{if(f)throw f.error}}try{for(var L=nm(tm([],em(t),!1)),p=L.next();!p.done;p=L.next()){var v=p.value;v()}}catch(_){m={error:_}}finally{try{p&&!p.done&&(y=L.return)&&y.call(L)}finally{if(m)throw m.error}}}};return n.gameStart=l,n.gameClose=d,{init:function(){return c1(this,void 0,void 0,function(){return u1(this,function(f){if(o||u)throw Error("Mintegral bridge closed");if(typeof n.gameReady!="function")throw Error("Mintegral gameReady host unavailable");return n.gameReady(),[2]})})},isReady:function(){return a&&!o&&!u},isVisible:function(){return a&&s&&!o&&!u},isClosed:function(){return o||u},onVisibilityChanged:function(f){return!o&&!u&&e.add(f),function(){return e.delete(f)}},onClosed:function(f){return!o&&!u&&t.add(f),function(){return t.delete(f)}},notifyGameEnd:function(){var f;!o&&!u&&((f=n.gameEnd)===null||f===void 0||f.call(n))},notifyGameRetry:function(){var f;!o&&!u&&((f=n.gameRetry)===null||f===void 0||f.call(n))},openStore:function(){if(!a||!s||o||u||typeof n.install!="function")throw Error("Mintegral install host unavailable");n.install()},destroy:function(){u||(u=!0,a=!1,s=!1,n.gameStart===l&&(i?n.gameStart=i:delete n.gameStart),n.gameClose===d&&(r?n.gameClose=r:delete n.gameClose),e.clear(),t.clear())}}}var d1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},f1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},h1=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},p1=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},m1=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Og(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=m1(p1([],h1(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return d1(this,void 0,void 0,function(){return f1(this,function(a){switch(a.label){case 0:if(i)throw Error("TikTok bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("TikTok bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a,s,o=window,u=typeof o.openAppStore=="function"?o.openAppStore.bind(o):(s=(a=o.playableSDK)===null||a===void 0?void 0:a.openAppStore)===null||s===void 0?void 0:s.bind(o.playableSDK);if(!e||!t||i||!u)throw Error("TikTok store host unavailable");u()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var It=function(){return It=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},It.apply(this,arguments)},v1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},g1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Ne=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Je=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},ke=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function kg(n){if(n!=="standalone"){if(n==="unity-ads-ua-playable")return Pg();if(n==="applovin-growth-playable")return Lg();if(n==="ironsource-levelplay-playable")return Dg();if(n==="meta-audience-playable")return Ng();if(n==="google-ads-app-playable")return Ug();if(n==="mintegral-appgrowth-zip")return Fg();if(n==="tiktok-ads-playable")return Og();throw Error("E_NATIVE_TARGET")}}function im(n){var e,t,i,r,a=(e=n.left)!==null&&e!==void 0?e:0,s=(t=n.top)!==null&&t!==void 0?t:0,o=(i=n.right)!==null&&i!==void 0?i:a+n.width,u=(r=n.bottom)!==null&&r!==void 0?r:s+n.height,l=[{id:"sdk-top-left",left:a,top:s,right:Math.min(a+48,o),bottom:Math.min(s+48,u)},{id:"sdk-top-right",left:Math.max(a,o-56),top:s,right:o,bottom:Math.min(s+56,u)},{id:"sdk-bottom-left",left:a,top:Math.max(s,u-28),right:Math.min(a+48,o),bottom:u}];return{left:Math.min(a+48,o),top:Math.min(s+56,u),right:Math.max(a,o-56),bottom:Math.max(s,u-28),zones:l}}function Cf(n,e){var t,i,r=(i=(t=n.measureText)===null||t===void 0?void 0:t.call(n,e))===null||i===void 0?void 0:i.width,a=/(\d+(?:\.\d+)?)px/.exec(n.font||"");return Number.isFinite(r)?r:Je([],Ne(e),!1).length*(a?Number(a[1]):16)*.6}function Bg(n,e,t,i){var r,a,s,o,u,l,d;n.font=t.fontWeight+" "+i+"px "+t.fontFamily;var f=Math.max(0,t.width-2*((d=t.padding)!==null&&d!==void 0?d:4)),h=[];try{for(var m=ke(String(e).split(`
|
|
4224
|
+
`)),y=m.next();!y.done;y=m.next()){var M=y.value;if(t.wrap===!1){h.push(M);continue}var g=M.trim()?M.trim().split(/\s+/):[""],v=void 0;try{for(var L=(s=void 0,ke(g)),p=L.next();!p.done;p=L.next()){var _=p.value,N=v?v+" "+_:_;if(Cf(n,N)<=f){v=N;continue}if(v&&h.push(v),Cf(n,_)<=f){v=_;continue}var D="";try{for(var V=(u=void 0,ke(_)),w=V.next();!w.done;w=V.next()){var I=w.value;D&&Cf(n,D+I)>f?(h.push(D),D=I):D+=I}}catch(G){u={error:G}}finally{try{w&&!w.done&&(l=V.return)&&l.call(V)}finally{if(u)throw u.error}}v=D}}catch(G){s={error:G}}finally{try{p&&!p.done&&(o=L.return)&&o.call(L)}finally{if(s)throw s.error}}h.push(v)}}catch(G){r={error:G}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(r)throw r.error}}return h}function zg(n,e,t){var i,r,a=(i=t.padding)!==null&&i!==void 0?i:4,s=Math.max(0,t.width-2*a),o=Math.max(0,t.height-2*a),u=Math.min(t.fontSize,(r=t.minFontSize)!==null&&r!==void 0?r:12),l=t.fontSize,d=Bg(n,e,t,l),f,h=function(){var m;n.font=t.fontWeight+" "+l+"px "+t.fontFamily;var y=Math.max.apply(Math,Je([0],Ne(d.map(function(L){return Cf(n,L)})),!1)),M=l*((m=t.lineHeight)!==null&&m!==void 0?m:1.2),g=d.length>16;g&&(d=d.slice(0,16));var v=d.length*M;return{lines:d,fontSize:l,scale:l/t.fontSize,renderedWidth:y,renderedHeight:v,availableWidth:s,availableHeight:o,padding:a,lineHeight:M,overflowsWidth:y>s+.01,overflowsHeight:g||v>o+.01,unsupportedChars:[]}};if(f=h(),t.autoFit!==!1)for(;(f.overflowsWidth||f.overflowsHeight)&&l>u;)l=Math.max(u,l-1),d=Bg(n,e,t,l),f=h();return f}function y1(n,e,t,i){i===void 0&&(i="en");var r=zg(n,e,t),a=r.padding,s=t.direction==="rtl"||t.direction!=="ltr"&&/^(ar|fa|he|iw|ps|sd|ug|ur|yi)(?:-|$)/.test(i),o=s&&t.direction!=="rtl"?t.align==="left"?"right":t.align==="right"?"left":t.align:t.align;n.fillStyle=t.color,n.font=t.fontWeight+" "+r.fontSize+"px "+t.fontFamily,n.direction=s?"rtl":"ltr",n.textAlign=o,n.textBaseline="middle";var u=o==="left"?a:o==="right"?t.width-a:t.width/2,l=(t.height-r.renderedHeight)/2;return r.lines.forEach(function(d,f){return n.fillText(d,u,l+(f+.5)*r.lineHeight)}),It(It({},r),{direction:s?"rtl":"ltr",resolvedAlign:o,clipped:r.overflowsHeight})}function x1(n,e,t){var i,r,a,s,o,u,l=t===void 0?{}:t,d=l.edit,f=d===void 0?!1:d,h=l.sceneId,m=h===void 0?n.base.startScene:h,y=l.onSelect,M=y===void 0?function(){}:y,g=l.network,v=g===void 0?"standalone":g,L=kg(v),p=e.getContext("2d"),_=new Map(n.components.map(function(c){return[c.id,c]})),N=new Map(n.assets.map(function(c){return[c.id,c]})),D=new Map,V=new Map(n.events.map(function(c){return[c.id,c]})),w=new Map(n.gameplay.filter(function(c){return c.kind==="responsive-layout"}).map(function(c){return[c.componentId,c.parameters]})),I=(a=globalThis.matchMedia)===null||a===void 0?void 0:a.call(globalThis,"(prefers-reduced-motion: reduce)"),G,H=new Map,Q=H;function T(){var c=w.size>0&&e.clientWidth>e.clientHeight;return{width:c?Math.max(n.base.width,n.base.height):n.base.width,height:c?Math.min(n.base.width,n.base.height):n.base.height,landscape:c}}function S(){G!==T().landscape&&(ea(),ji())}var Z=function(c){var x,A=N.get(c);return((x=A?.hash)!==null&&x!==void 0?x:c)+":"+c};try{for(var q=ke(n.assets),se=q.next();!se.done;se=q.next()){var F=se.value;if(F.mime.startsWith("image/")&&!D.has(Z(F.id))){var z=new Image;z.src="data:"+F.mime+";base64,"+F.data,D.set(Z(F.id),z)}}}catch(c){i={error:c}}finally{try{se&&!se.done&&(r=q.return)&&r.call(q)}finally{if(i)throw i.error}}var Y=m,$={},he=[],pe=[],le=[],Te=[],De=new Set,oe=new Map,ee=0,be=0,Be=0,Re=0,Ye=0,nt=!1,Ge=0,$e=0,mt=!1,at=[],Ve,Yt,st,Dt,on,de,wn,Mn,K,b,ne=[],Se,Ie=[],Xe=[],qe,Le=0,Pe=!1,lt=0,Mt=v==="standalone",yt=v==="standalone",it=v==="standalone",Gt=!1,Zt=!1,Ke=new Map,fe=new Map,We=new Map,ze=new Map,ht=new Set,St=new Map,He=new Map,qt=new Set,Tt=new Map,pt=new Map,Lt=new Map,et=new Map,Pt=new Map,Ht=new Map,cn=0,an=0,Ct,Kt,bn=1,gn,Wt=new Map,Qn=new Map,Tn=new Map,Gn=new Map,Hn=new Map,Cn=new Map,Wn=new Map,hn=Um(),un=Bm(),An=new Map,Fn=new Map,Vn=Gm(gu(n.projectId)),jn=new Map,Zn=new Map,C=new Map,re=new Set,Me=new Map,ie,_e=1,tt=1,Qe,je,bt={x:0,y:0},ft,wt=[],kt=[],Ee=new Map,nn=new Map,jt=new Map,Sn=new Map,pn=new Map,xn=new Map,xt=new Set,Vt,dn,Nt,hi=new Map(n.gameplay.filter(function(c){return c.kind==="ui-anchor-3d"}).map(function(c){return[c.componentId,c.parameters]}));n.components.some(function(c){return c.contract==="native.stage3d.v1"})&&(Nt=_g(n,N,function(){Zt||Promise.resolve().then(function(){Zt||ji()})},Ke));var rt=function(c){var x;return(x=We.get(c))!==null&&x!==void 0?x:_.get(c)},ii=function(c,x){return n.gameplay.find(function(A){return A.kind===c&&A.componentId===x})},Rn=function(){var c,x;cn++,qt.clear(),Tt.clear(),Lt.clear(),et.clear();try{for(var A=ke(ht),E=A.next();!E.done;E=A.next()){var R=E.value;try{R.stop()}catch{}}}catch(U){c={error:U}}finally{try{E&&!E.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}ht.clear(),pt.clear()},Jn=function(c){var x,A;if(!ie||c!==void 0&&ie.pointerId!==c)return!1;var E=ie.pointerId;ie.behavior.parameters.powerVariableId&&($[ie.behavior.parameters.powerVariableId]=0),ie=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,E)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,E))}catch{}return!0},Si=function(c){var x,A,E;if(!Vt||c!==void 0&&Vt.pointerId!==c)return!1;var R=Vt.pointerId;Vt.behavior.parameters.powerVariableId&&($[Vt.behavior.parameters.powerVariableId]=0),(x=Nt?.getStage(_.get(Vt.stageId)))===null||x===void 0||x.setGuide([]),Vt=void 0;try{!((A=e.hasPointerCapture)===null||A===void 0)&&A.call(e,R)&&((E=e.releasePointerCapture)===null||E===void 0||E.call(e,R))}catch{}return!0},Pn=function(c){var x,A;if(!dn||c!==void 0&&dn.pointerId!==c)return!1;var E=dn.pointerId;dn=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,E)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,E))}catch{}return!0},bi=function(c){var x=c.behavior.parameters;x.axisXVariableId&&($[x.axisXVariableId]=c.nx),x.axisYVariableId&&($[x.axisYVariableId]=c.ny),x.magnitudeVariableId&&($[x.magnitudeVariableId]=c.magnitude),x.angleVariableId&&c.magnitude>0&&($[x.angleVariableId]=c.angle)},si=function(c,x){var A,E,R,U;x===void 0&&(x=!1);try{for(var P=ke(Me.values()),W=P.next();!W.done;W=P.next()){var O=W.value;if(!(O.pointerId===null||c!==void 0&&O.pointerId!==c)){var J=O.pointerId;O.pointerId=null,O.nx=0,O.ny=0,O.magnitude=0,O.knobX=O.origin.x,O.knobY=O.origin.y,bi(O);try{!((R=e.hasPointerCapture)===null||R===void 0)&&R.call(e,J)&&((U=e.releasePointerCapture)===null||U===void 0||U.call(e,J))}catch{}x&&In(Qi("joystickEnd",O.c))}}}catch(B){A={error:B}}finally{try{W&&!W.done&&(E=P.return)&&E.call(P)}finally{if(A)throw A.error}}},rr=function(c,x){var A,E;if(x===void 0&&(x=!0),!st||c!==void 0&&st.pointerId!==c)return!1;var R=st,U=R.pointerId;if(st=void 0,je=void 0,x){var P=rt(R.targetId);P&&R.b.parameters.snapBack&&(Hr(P,R.origin.x,R.origin.y),R.originZone&&hn.place(P.id,R.originZone))}try{!((A=e.hasPointerCapture)===null||A===void 0)&&A.call(e,U)&&((E=e.releasePointerCapture)===null||E===void 0||E.call(e,U))}catch{}return!0},Ba=function(c){var x,A;Se?.pointerId===c.pointerId&&(Se=void 0);try{for(var E=ke(Pt.values()),R=E.next();!R.done;R=E.next()){var U=R.value;U.pointerId===c.pointerId&&U.held&&(U.held=!1,U.releasedAt=ee)}}catch(W){x={error:W}}finally{try{R&&!R.done&&(A=E.return)&&A.call(E)}finally{if(x)throw x.error}}var P=rr(c.pointerId);return de===c.pointerId?(on=void 0,de=void 0,!0):P},ca=function(c){var x,A,E,R,U,P,W,O;if(c){st&&((W=We.get(st.targetId))===null||W===void 0?void 0:W.instanceId)===c&&rr(void 0,!1),ie&&((O=We.get(ie.targetId))===null||O===void 0?void 0:O.instanceId)===c&&Jn();var J=[];hn.release(c),un.cancel(c),jn.delete(c),C.delete(c),Vn.remove(c),he=he.filter(function(ve){return ve.id!==c});try{for(var B=ke(We),k=B.next();!k.done;k=B.next()){var X=Ne(k.value,2),te=X[0],j=X[1];if(j.instanceId===c){J.push(te),hn.release(te),un.cancel(te),We.delete(te),Ke.delete(te),ze.delete(te),Tn.delete(te),Hn.delete(te),Cn.delete(te);try{for(var ae=(E=void 0,ke(Gn.values())),ce=ae.next();!ce.done;ce=ae.next()){var we=ce.value;we.removeAgent(te)}}catch(ve){E={error:ve}}finally{try{ce&&!ce.done&&(R=ae.return)&&R.call(ae)}finally{if(E)throw E.error}}try{for(var me=(U=void 0,ke(fe.keys())),Ae=me.next();!Ae.done;Ae=me.next()){var ye=Ae.value;ye.endsWith(":"+te)&&fe.delete(ye)}}catch(ve){U={error:ve}}finally{try{Ae&&!Ae.done&&(P=me.return)&&P.call(me)}finally{if(U)throw U.error}}}}}catch(ve){x={error:ve}}finally{try{k&&!k.done&&(A=B.return)&&A.call(B)}finally{if(x)throw x.error}}le=le.filter(function(ve){return!J.includes(ve.targetId)})}},Vr=function(c){for(;c;){if(c.prototype)return c.id;c=rt(c.parentId)}},ns=function(){var c,x,A;return{viewport:T(),components:Object.fromEntries(Je([],Ne(Ke),!1).map(function(E){var R=Ne(E,2),U=R[0],P=R[1];return[U,It(It({},P),{parameters:It({},P.parameters)})]})),mode:f?"edit":"play",scene:Y,variables:It({},$),time:ee,instances:he.map(function(E){return It({id:E.id,prototypeId:E.prototypeId,x:E.transform[4],y:E.transform[5]},Vn.snapshot(E.id))}),particles:pe.length,animations:le.length,contacts:De.size,spriteFrames:Object.fromEntries(Je([],Ne(ze),!1).map(function(E){var R,U=Ne(E,2),P=U[0],W=U[1];return[P,(R=W.frame)!==null&&R!==void 0?R:0]})),input:{dragging:!!st,pointerId:(x=(c=st?.pointerId)!==null&&c!==void 0?c:Qe?.pointerId)!==null&&x!==void 0?x:null,pressed:on??null,holding:!!Qe?.holds.length,occupancy:hn.snapshot(),joysticks:Object.fromEntries(Je([],Ne(Me),!1).map(function(E){var R=Ne(E,2),U=R[0],P=R[1];return[U,{active:P.pointerId!==null,x:P.nx,y:P.ny,magnitude:P.magnitude,angle:P.angle}]}))},feedback:{presses:Pt.size,floatingTexts:Ie.length,flashes:Xe.length,shaking:!!qe,tutorialHands:lt},match:{boards:Object.fromEntries(Je([],Ne(Wt),!1).map(function(E){var R=Ne(E,2),U=R[0],P=R[1];return[U,P.snapshot()]})),selected:Ct??null,cells:Je([],Ne(Ht),!1).map(function(E){var R=Ne(E,2),U=R[0],P=R[1];return It({id:U},P)})},physics:jc(),physics3d:Vg(),model3d:Nt?.modelStatus(),paths:Object.fromEntries(Je([],Ne(Gn),!1).map(function(E){var R=Ne(E,2),U=R[0],P=R[1];return[U,P.snapshot()]})),canvas:{masks:Object.fromEntries(Je([],Ne(jn),!1).map(function(E){var R=Ne(E,2),U=R[0],P=R[1];return[U,{progress:P.progress}]})),strokes:Object.fromEntries(Je([],Ne(Zn),!1).map(function(E){var R=Ne(E,2),U=R[0],P=R[1];return[U,P.strokes.length]})),walls:wt.length,joints:kt.filter(function(E){return!E.broken}).length},audio:{state:(A=Ve?.state)!==null&&A!==void 0?A:"locked",voices:ht.size,blocked:an},network:{target:v,ready:yt,visible:it,started:Mt,closed:Gt,hostVolume:bn},diagnostics:Je([],Ne(at),!1)}},jr=function(){return!f&&!nt&&!document.hidden&&yt&&it&&Mt&&!Gt},ea=function(){var c,x,A,E;Se=void 0,Jn(),Si(),Pn(),si(),rr(),Qe=void 0,je=void 0,ft=void 0;try{for(var R=ke(Zn.values()),U=R.next();!U.done;U=R.next()){var P=U.value;P.cancel()}}catch(B){c={error:B}}finally{try{U&&!U.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}un.clear(),Kt=void 0;try{for(var W=ke(Wt.values()),O=W.next();!O.done;O=W.next()){var J=O.value;J.cancelSelection()}}catch(B){A={error:B}}finally{try{O&&!O.done&&(E=W.return)&&E.call(W)}finally{if(A)throw A.error}}Wt.size&&(Ct=void 0),on=void 0,de=void 0,Pt.clear()},Xn=function(c){mt=!0,at.push(c),at=at.slice(-16),Te=[]},ei=function(c){var x,A,E;return It(It(It({},c.parameters),c.prototypeId?(x=Ke.get(c.prototypeId))===null||x===void 0?void 0:x.parameters:{}),(E=Ke.get((A=c.runtimeId)!==null&&A!==void 0?A:c.id))===null||E===void 0?void 0:E.parameters)};function vt(c){var x,A=ei(c),E=(x=c.runtimeId)!==null&&x!==void 0?x:c.id,R=pn.get(E);if(R)R.fittedWidth!==void 0&&c.contract!=="native.group.v1"&&(A.width=R.fittedWidth,A.height=R.fittedHeight),R.visible||(A.visible=!1);else if(c.contract==="native.text.v1"&&c.parentId){var U=pn.get(c.parentId),P=U&&rt(c.parentId);P?.contract==="native.button.v1"&&U.fittedWidth!==void 0&&c.transform[0]===1&&c.transform[1]===0&&c.transform[2]===0&&c.transform[3]===1&&c.transform[4]===0&&c.transform[5]===0&&c.parameters.width===P.parameters.width&&c.parameters.height===P.parameters.height&&(A.width=U.fittedWidth,A.height=U.fittedHeight)}return A}function is(c,x){var A,E=Pt.get(c.id);if(!E||I?.matches)return x;var R=Je([],Ne(x),!1),U=E.held?0:ee-((A=E.releasedAt)!==null&&A!==void 0?A:ee),P=E.held?0:Math.min(1,U/E.behavior.springBackSeconds),W=E.held?E.behavior.scaleDown:E.behavior.scaleDown+(1-E.behavior.scaleDown)*(1-Math.pow(1-P,3)),O=vt(c);R[4]+=(1-W)*(R[0]*O.width+R[2]*O.height)/2,R[5]+=(1-W)*(R[1]*O.width+R[3]*O.height)/2;for(var J=0;J<4;J++)R[J]*=W;return R}function Ys(c){return Nt&&xt.size>0&&pi?{left:pi.x,top:pi.y,right:pi.x+pi.w,bottom:pi.y+pi.h,width:pi.w,height:pi.h}:{left:0,top:0,right:c.width,bottom:c.height,width:c.width,height:c.height}}function Gr(c){var x,A,E,R,U,P,W,O,J=c.transform,B=(E=(A=Ke.get((x=c.runtimeId)!==null&&x!==void 0?x:c.id))===null||A===void 0?void 0:A.transform)!==null&&E!==void 0?E:J,k=pn.get((R=c.runtimeId)!==null&&R!==void 0?R:c.id);if(k&&k.anchorPoint){var X=Je([],Ne(B),!1),te=vt(c);c.contract==="native.group.v1"&&k.groupScaleX!==void 0&&(X[0]*=k.groupScaleX,X[1]*=k.groupScaleX,X[2]*=k.groupScaleY,X[3]*=k.groupScaleY);var j=c.parentId?ui(rt(c.parentId)):Ca(),ae=oi(Dr(j),k.cx,k.cy);return X[4]=ae.x-(X[0]*te.width+X[2]*te.height)/2,X[5]=ae.y-(X[1]*te.width+X[3]*te.height)/2,is(c,X)}var ce=w.get((U=c.prototypeId)!==null&&U!==void 0?U:c.id);if(!ce)return is(c,B);var we=T(),me=Je([],Ne(B),!1);we.landscape&&(me[4]+=ce.x-J[4],me[5]+=ce.y-J[5],me[0]*=ce.scaleX,me[1]*=ce.scaleX,me[2]*=ce.scaleY,me[3]*=ce.scaleY);var Ae=(P=ce.anchor)!==null&&P!==void 0?P:"none";if(Ae==="none"&&!ce.respectSafeArea)return is(c,me);var ye=Ys(we),ve=ce.respectSafeArea?im(ye):ye,Ce=vt(c),ue=(W=ce.marginX)!==null&&W!==void 0?W:0,Fe=(O=ce.marginY)!==null&&O!==void 0?O:0,Oe=Math.abs(me[0])*Ce.width+Math.abs(me[2])*Ce.height,Ue=Math.abs(me[1])*Ce.width+Math.abs(me[3])*Ce.height;return Ae!=="none"?(me[4]=Ae.endsWith("left")?ve.left+ue:Ae.endsWith("right")?ve.right-Oe-ue:(ve.left+ve.right-Oe)/2,me[5]=Ae.startsWith("top")?ve.top+Fe:Ae.startsWith("bottom")?ve.bottom-Ue-Fe:(ve.top+ve.bottom-Ue)/2):(me[4]=Math.max(ve.left+ue,Math.min(ve.right-Oe-ue,me[4])),me[5]=Math.max(ve.top+Fe,Math.min(ve.bottom-Ue-Fe,me[5]))),is(c,me)}var Ms=function(c){return(We.has(c)?Je([],Ne(We.values()),!1):Je(Je([],Ne(n.components),!1),Ne(he),!1)).filter(function(x){return x.parentId===c&&!x.prototype}).sort(function(x,A){return x.order-A.order||(x.id<A.id?-1:x.id>A.id?1:0)})},Ir=function(){return n.components.filter(function(c){return c.sceneId===Y&&!c.parentId&&!c.prototype}).sort(function(c,x){return c.order-x.order||(c.id<x.id?-1:c.id>x.id?1:0)})},In=function(c){var x,A;if(c.kind==="sceneEnter"&&((x=n.scenes.find(function(E){return E.id===c.sceneId}))===null||x===void 0?void 0:x.role)==="end-card"&&gn!==c.sceneId&&(gn=c.sceneId,(A=L?.notifyGameEnd)===null||A===void 0||A.call(L)),Te.length>=256){Xn("Event queue budget exhausted");return}Te.push(c)},Qi=function(c,x,A,E){var R,U,P,W;return E===void 0&&(E={}),It(It({kind:c,componentId:(R=x.prototypeId)!==null&&R!==void 0?R:x.id,selfInstanceId:(U=x.instanceId)!==null&&U!==void 0?U:x.id,instanceId:x.instanceId},A?{otherId:(P=A.prototypeId)!==null&&P!==void 0?P:A.id,otherInstanceId:(W=A.instanceId)!==null&&W!==void 0?W:A.id}:{}),E)};function ka(c){for(var x,A=c;A;A=rt(A.parentId)){var E=Vn.states.get((x=A.instanceId)!==null&&x!==void 0?x:A.id);if(E)return E}}function bl(c){var x,A,E=ii("instance-state",(x=c.prototypeId)!==null&&x!==void 0?x:c.id);return E?Vn.initialize((A=c.instanceId)!==null&&A!==void 0?A:c.id,E.parameters):void 0}function Rf(){var c,x,A,E;try{for(var R=ke(n.gameplay.filter(function(B){return B.kind==="instance-state"})),U=R.next();!U.done;U=R.next()){var P=U.value;try{for(var W=(A=void 0,ke(Bi(_.get(P.componentId)))),O=W.next();!O.done;O=W.next()){var J=O.value;bl(J)}}catch(B){A={error:B}}finally{try{O&&!O.done&&(E=W.return)&&E.call(W)}finally{if(A)throw A.error}}}}catch(B){c={error:B}}finally{try{U&&!U.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}}function Zc(c,x,A,E){var R=ka(c);if(R){var U=R.hp;if(x==="tag")R.tag=A==="set"?String(E):R.tag;else{var P=Number(E);if(R[x]=A==="add"?R[x]+P:A==="sub"?R[x]-P:P,!Number.isFinite(R[x])){Xn("Instance state range exceeded");return}x==="hp"&&(R.hp=Math.max(0,Math.min(R.maxHp,R.hp)))}U>0&&R.hp<=0&&In(Qi("instanceDepleted",c))}}function qs(c,x){var A,E,R;if(!c)return!0;if(c.all)return c.all.every(function(J){return qs(J,x)});if(c.any)return c.any.some(function(J){return qs(J,x)});var U=c.instanceTarget==="other"?x?.otherInstanceId:(A=x?.selfInstanceId)!==null&&A!==void 0?A:x?.instanceId,P=c.instanceField?(E=rt(U))!==null&&E!==void 0?E:Je([],Ne(We.values()),!1).find(function(J){return J.instanceId===U}):void 0,W=c.instanceField?(R=ka(P))===null||R===void 0?void 0:R[c.instanceField]:$[c.variableId],O=c.compareVariableId?$[c.compareVariableId]:c.value;return{eq:function(){return W===O},ne:function(){return W!==O},lt:function(){return W<O},lte:function(){return W<=O},gt:function(){return W>O},gte:function(){return W>=O}}[c.op]()}function Jc(c){var x,A,E;Ct=void 0,Kt=void 0,c||Ht.clear();try{for(var R=ke(n.gameplay),U=R.next();!U.done;U=R.next()){var P=U.value;if(P.kind==="match-tile"){var W=_.get(P.componentId);if(c&&W.id!==c&&!Wr(W,c))continue;Ke.delete(W.id),Ht.set(W.id,{row:P.parameters.row,column:P.parameters.column,group:P.parameters.group,sceneId:W.sceneId,boardId:(E=W.parentId)!==null&&E!==void 0?E:W.sceneId})}}}catch(O){x={error:O}}finally{try{U&&!U.done&&(A=R.return)&&A.call(R)}finally{if(x)throw x.error}}}function Mo(){var c,x,A=function(P){var W,O;if(Wt.has(P.componentId))return"continue";var J=P.componentId,B=P.parameters,k=n.gameplay.filter(function(ye){return ye.kind==="match-tile"&&_.get(ye.componentId).parentId===J}).sort(function(ye,ve){return ye.parameters.row-ve.parameters.row||ye.parameters.column-ve.parameters.column}).map(function(ye){return It({id:ye.componentId},ye.parameters)}),X=new Map;try{for(var te=(W=void 0,ke(k)),j=te.next();!j.done;j=te.next()){var ae=j.value;if(!X.has(ae.group)){var ce=_.get(ae.id);X.set(ae.group,{fill:ce.parameters.fill,children:Ms(ae.id).filter(function(ye){return["native.image.v1","native.text.v1"].includes(ye.contract)})})}}}catch(ye){W={error:ye}}finally{try{j&&!j.done&&(O=te.return)&&O.call(te)}finally{if(W)throw W.error}}Qn.set(J,X);var we=_.get(k[B.columns].id).transform[5]-_.get(k[0].id).transform[5],me=function(ye,ve,Ce){var ue,Fe=Ce.from,Oe=Fe===void 0?ye:Fe,Ue=Ce.progress,Ze=Ue===void 0?0:Ue,gt=Ce.offsetRows,Ft=gt===void 0?0:gt,Ot=Ce.scale,Ut=Ot===void 0?1:Ot,Xt=Ce.opacity,Bt=Xt===void 0?1:Xt,_t=k[ye],Rt=_.get(_t.id),At=_.get(k[Oe].id),ut=X.get(ve),Et=Je([],Ne(Rt.transform),!1);Et[4]+=(At.transform[4]-Rt.transform[4])*Ze,Et[5]+=(At.transform[5]-Rt.transform[5]+Ft*we)*Ze,Et[4]+=(1-Ut)*(Et[0]*Rt.parameters.width+Et[2]*Rt.parameters.height)/2,Et[5]+=(1-Ut)*(Et[1]*Rt.parameters.width+Et[3]*Rt.parameters.height)/2;for(var en=0;en<4;en++)Et[en]*=Ut;Ke.set(_t.id,It(It({},Ke.get(_t.id)),{transform:Et,parameters:It(It({},(ue=Ke.get(_t.id))===null||ue===void 0?void 0:ue.parameters),{fill:ut.fill,opacity:Bt})})),Ht.get(_t.id).group=ve;var ot=Ms(_t.id).filter(function(yn){return["native.image.v1","native.text.v1"].includes(yn.contract)});ot.forEach(function(yn,fn){var Dn,Jt,rn=ut.children[fn];if(!(!rn||rn.contract!==yn.contract)){var dt=(Dn=Ke.get(yn.id))!==null&&Dn!==void 0?Dn:{transform:Je([],Ne(yn.transform),!1),parameters:{}};yn.contract==="native.image.v1"?dt.assetId=(Jt=rn.assetSlots[0])===null||Jt===void 0?void 0:Jt.assetId:dt.parameters.text=rn.parameters.text,Ke.set(yn.id,dt)}})},Ae=Lm(It(It({},B),{slots:k,paint:me,onEvent:function(ye){Ct=void 0,In({kind:ye,componentId:J})}}));Wt.set(J,Ae)};try{for(var E=ke(n.gameplay.filter(function(P){return P.kind==="match-board"})),R=E.next();!R.done;R=E.next()){var U=R.value;A(U)}}catch(P){c={error:P}}finally{try{R&&!R.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}function za(c){var x,A;Mo();try{for(var E=ke(Wt),R=E.next();!R.done;R=E.next()){var U=Ne(R.value,2),P=U[0],W=U[1];(!c||c===P||Wr(_.get(P),c))&&W.reset()}}catch(O){x={error:O}}finally{try{R&&!R.done&&(A=E.return)&&A.call(E)}finally{if(x)throw x.error}}}function Bi(c){return Vr(c)?Je([],Ne(We.values()),!1).filter(function(x){return x.prototypeId===c.id}):[c]}function Ui(c){var x=vt(c);return oi(ui(c),x.width/2,x.height/2)}function rs(c,x,A){var E;A===void 0&&(A="self");var R=_.get(c),U=A==="other"?x.otherInstanceId:(E=x.selfInstanceId)!==null&&E!==void 0?E:x.instanceId,P=!!(R&&Vr(R));if(U!==void 0){if(c){var W=Je([],Ne(We.values()),!1).find(function(O){return O.prototypeId===c&&(O.instanceId===U||O.id===U)});if(W)return W}if(A==="other"||!c)return rt(U);if(P&&typeof U=="string"&&U.startsWith("instance."))return}return R?P?Bi(R)[0]:rt(c):void 0}function Hr(c,x,A){var E,R=vt(c),U=(E=Ke.get(c.id))!==null&&E!==void 0?E:{transform:Je([],Ne(c.transform),!1),parameters:{}},P=Je([],Ne(U.transform),!1),W=c.parentId?ui(rt(c.parentId)):Ca(),O=oi(Dr(W),x,A);P[4]=O.x-(P[0]*R.width+P[2]*R.height)/2,P[5]=O.y-(P[1]*R.width+P[3]*R.height)/2,Ke.set(c.id,It(It({},U),{transform:P})),c.prototypeId&&(c.transform=Je([],Ne(P),!1))}function ya(c,x,A){var E,R,U,P;A===void 0&&(A=!1);var W=(E=Ke.get(c.id))!==null&&E!==void 0?E:{transform:Je([],Ne(c.transform),!1),parameters:{}},O=(P=(U=_.get((R=c.prototypeId)!==null&&R!==void 0?R:c.id))===null||U===void 0?void 0:U.transform)!==null&&P!==void 0?P:c.transform,J=Math.hypot(O[0],O[1])*(A?-1:1),B=Math.hypot(O[2],O[3]),k=x+(A?0:Math.atan2(O[1],O[0])),X=Math.cos(k),te=Math.sin(k),j=Je([],Ne(W.transform),!1);j[0]=X*J,j[1]=te*J,j[2]=-te*B,j[3]=X*B,Ke.set(c.id,It(It({},W),{transform:j}))}function as(c,x){var A=Tn.get(c.id);if(A)return A;var E=ui(c),R=vt(c),U=oi(E,R.width/2,R.height/2);return A=It({id:c.id,sourceId:x.componentId,instanceId:c.instanceId,x:U.x,y:U.y,vx:0,vy:0,width:Math.hypot(E[0],E[1])*R.width,height:Math.hypot(E[2],E[3])*R.height,angle:Math.atan2(E[1],E[0]),restElapsed:0,atRest:!0},x.parameters),Tn.set(c.id,A),A}function Va(c,x){var A,E=jn.get(c.id);if(E)return E;var R=vt(c),U=x.parameters;return E=Hm(U,{width:R.width,height:R.height,source:c.contract==="native.image.v1"?D.get(Z((A=c.assetSlots[0])===null||A===void 0?void 0:A.assetId)):void 0,onProgress:function(P){U.progressVariableId&&($[U.progressVariableId]=P),In(Qi("maskProgress",c))},onComplete:function(){return In(Qi("maskComplete",c))}}),jn.set(c.id,E),E}function $c(c){var x=Zn.get(c.componentId);return x||(x=Ym(c.parameters),Zn.set(c.componentId,x)),x}function wl(){var c,x,A,E,R,U,P,W,O,J,B,k,X=new Set,te=[];try{for(var j=ke(n.gameplay.filter(function(Et){return Et.kind==="physics-body"})),ae=j.next();!ae.done;ae=j.next()){var ce=ae.value,we=_.get(ce.componentId);if(we.sceneId===Y)try{for(var me=(A=void 0,ke(Bi(we))),Ae=me.next();!Ae.done;Ae=me.next()){var ye=Ae.value;if(wi(ye)){if(te.length>=64){Xn("Physics body budget exhausted");break}var ve=as(ye,ce),Ce=ui(ye),ue=vt(ye),Fe=oi(Ce,ue.width/2,ue.height/2);if(X.add(ye.id),ve.width=Math.hypot(Ce[0],Ce[1])*ue.width,ve.height=Math.hypot(Ce[2],Ce[3])*ue.height,ve.mode!=="dynamic"){var Oe=Hn.get(ye.id),Ue=ye.parentId?ui(rt(ye.parentId)):Ca(),Ze=(B=Oe?.vx)!==null&&B!==void 0?B:0,gt=(k=Oe?.vy)!==null&&k!==void 0?k:0;ve.x=Fe.x,ve.y=Fe.y,ve.angle=Math.atan2(Ce[1],Ce[0]),ve.vx=Ue[0]*Ze+Ue[2]*gt,ve.vy=Ue[1]*Ze+Ue[3]*gt}else ve.atRest&&(ve.x=Fe.x,ve.y=Fe.y);te.push(ve)}}}catch(Et){A={error:Et}}finally{try{Ae&&!Ae.done&&(E=me.return)&&E.call(me)}finally{if(A)throw A.error}}}}catch(Et){c={error:Et}}finally{try{ae&&!ae.done&&(x=j.return)&&x.call(j)}finally{if(c)throw c.error}}try{for(var Ft=ke(Tn.keys()),Ot=Ft.next();!Ot.done;Ot=Ft.next()){var Ut=Ot.value;!X.has(Ut)&&!We.has(Ut)&&Tn.delete(Ut)}}catch(Et){R={error:Et}}finally{try{Ot&&!Ot.done&&(U=Ft.return)&&U.call(Ft)}finally{if(R)throw R.error}}var Xt=[];try{for(var Bt=ke(n.gameplay.filter(function(Et){return Et.kind==="capture-zone"})),_t=Bt.next();!_t.done;_t=Bt.next()){var ce=_t.value,we=_.get(ce.componentId);if(we.sceneId===Y)try{for(var Rt=(O=void 0,ke(Bi(we))),At=Rt.next();!At.done;At=Rt.next()){var ye=At.value;if(wi(ye)){var Ce=ui(ye),ue=vt(ye),Fe=oi(Ce,ue.width/2,ue.height/2),ut=Math.max(.1,Math.min(Math.hypot(Ce[0],Ce[1]),Math.hypot(Ce[2],Ce[3])));Xt.push(It(It({id:ye.id,sourceId:we.id,instanceId:ye.instanceId,x:Fe.x,y:Fe.y},ce.parameters),{radius:ce.parameters.radius*ut}))}}}catch(ot){O={error:ot}}finally{try{At&&!At.done&&(J=Rt.return)&&J.call(Rt)}finally{if(O)throw O.error}}}}catch(Et){P={error:Et}}finally{try{_t&&!_t.done&&(W=Bt.return)&&W.call(Bt)}finally{if(P)throw P.error}}return{bodies:Je(Je([],Ne(te),!1),Ne(wt),!1),zones:Xt}}function Kc(c){var x,A,E,R,U,P,W,O=wl(),J=O.bodies,B=O.zones,k=T();kt=[];try{for(var X=ke(n.gameplay.filter(function(Ue){return Ue.kind==="physics-joint"})),te=X.next();!te.done;te=X.next()){var j=te.value,ae=_.get(j.componentId);if(ae.sceneId===Y){var ce=rt(j.parameters.anchorComponentId),we=ii("physics-body",ae.id);if(!(!ce||!we))try{for(var me=(E=void 0,ke(Bi(ae))),Ae=me.next();!Ae.done;Ae=me.next()){var ye=Ae.value;as(ye,we);var ve=Ui(ce),Ce=j.id+":"+ye.id;kt.push(It(It({},j.parameters),{id:j.id,key:Ce,componentId:ae.id,bodyId:ye.id,anchorId:ce.id,x:ve.x,y:ve.y,broken:re.has(Ce)}))}}catch(Ue){E={error:Ue}}finally{try{Ae&&!Ae.done&&(R=me.return)&&R.call(me)}finally{if(E)throw E.error}}}}}catch(Ue){x={error:Ue}}finally{try{te&&!te.done&&(A=X.return)&&A.call(X)}finally{if(x)throw x.error}}uh({bodies:J,zones:B,joints:kt,bounds:{left:0,top:0,right:k.width,bottom:k.height},dt:c,onEvent:function(Ue,Ze,gt){var Ft,Ot,Ut,Xt;if(!(Ue==="bodyBounce"&>&&Ze.sourceId===gt.sourceId&&Ze.id>gt.id)){var Bt=(Ft=Ze.instanceId)!==null&&Ft!==void 0?Ft:Ze.id,_t=gt?(Ot=gt.instanceId)!==null&&Ot!==void 0?Ot:gt.id:void 0,Rt=It(It({kind:Ue,componentId:Ze.sourceId,selfInstanceId:Bt},_t?{otherInstanceId:_t}:{}),{instanceId:(Ut=Ze.instanceId)!==null&&Ut!==void 0?Ut:gt?.instanceId});if(gt&&(Rt.otherId=gt.sourceId),In(Rt),Ue==="zoneCapture"){var At=rt(Ze.id),ut=_.get(gt.sourceId);if(gt.hideCaptured&&At){var Et=(Xt=Ke.get(At.id))!==null&&Xt!==void 0?Xt:{transform:Je([],Ne(At.transform),!1),parameters:{}};Et.parameters.visible=!1,Ke.set(At.id,Et)}gt.stopBody&&ut&&At&&Hr(At,gt.x,gt.y)}}}});try{for(var ue=ke(J),Fe=ue.next();!Fe.done;Fe=ue.next()){var Oe=Fe.value,ye=rt(Oe.id);!ye||Oe.mode!=="dynamic"||(Oe.spinToRotation&&ya(ye,(W=Oe.angle)!==null&&W!==void 0?W:0),Hr(ye,Oe.x,Oe.y))}}catch(Ue){U={error:Ue}}finally{try{Fe&&!Fe.done&&(P=ue.return)&&P.call(ue)}finally{if(U)throw U.error}}}function Pf(){var c,x,A,E,R;try{for(var U=ke(n.gameplay.filter(function(Ae){return Ae.kind==="oscillate"})),P=U.next();!P.done;P=U.next()){var W=P.value,O=_.get(W.componentId);if(O.sceneId===Y)try{for(var J=(A=void 0,ke(Bi(O))),B=J.next();!B.done;B=J.next()){var k=B.value,X=Hn.get(k.id);X||(X={base:Je([],Ne(Gr(k)),!1),vx:0,vy:0},Hn.set(k.id,X));var te=W.parameters,j=(ee/te.periodSeconds+te.phase)*Math.PI*2,ae=Math.sin(j)*te.amplitude,ce=Math.cos(j)*te.amplitude*Math.PI*2/te.periodSeconds,we=(R=Ke.get(k.id))!==null&&R!==void 0?R:{parameters:{}},me=Je([],Ne(X.base),!1);te.axis==="x"?(me[4]+=ae,X.vx=ce,X.vy=0):(me[5]+=ae,X.vy=ce,X.vx=0),Ke.set(k.id,It(It({},we),{transform:me})),Hn.set(k.id,X)}}catch(Ae){A={error:Ae}}finally{try{B&&!B.done&&(E=J.return)&&E.call(J)}finally{if(A)throw A.error}}}}catch(Ae){c={error:Ae}}finally{try{P&&!P.done&&(x=U.return)&&x.call(U)}finally{if(c)throw c.error}}}function Qc(){var c,x;Gn.clear();var A=function(P){var W=n.gameplay.filter(function(J){return J.kind==="path-gate"&&J.parameters.networkBehaviorId===P.id}),O=Sg({id:P.id,nodes:P.parameters.nodes,edges:P.parameters.edges,gates:W,onEvent:function(J,B){var k,X=rt(B.componentId),te=(k=X?.prototypeId)!==null&&k!==void 0?k:B.componentId;In(It({kind:J,componentId:te,instanceId:X?.instanceId},B.nodeId?{nodeId:B.nodeId}:{}))}});Gn.set(P.id,O)};try{for(var E=ke(n.gameplay.filter(function(P){return P.kind==="path-network"})),R=E.next();!R.done;R=E.next()){var U=R.value;A(U)}}catch(P){c={error:P}}finally{try{R&&!R.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}function So(c,x){var A,E,R,U,P,W,O,J,B,k,X,te,j;x===void 0&&(x=!0);var ae=0;try{for(var ce=ke(n.gameplay.filter(function(Et){return Et.kind==="path-agent"})),we=ce.next();!we.done;we=ce.next()){var me=we.value,Ae=_.get(me.componentId),ye=Gn.get(me.parameters.networkBehaviorId);if(!(Ae.sceneId!==Y||!ye))try{for(var ve=(R=void 0,ke(Bi(Ae))),Ce=ve.next();!Ce.done;Ce=ve.next()){var ue=Ce.value;if(++ae>64){Xn("Path agent budget exhausted");break}var Fe=ye.getAgent(ue.id);Fe||(Fe=ye.addAgent(It(It({},me.parameters),{id:ue.id,startNode:(X=ue.pathStartNode)!==null&&X!==void 0?X:me.parameters.startNode,targetNode:(te=ue.pathTargetNode)!==null&&te!==void 0?te:me.parameters.targetNode}))),Fe.speedMultiplier=Math.max(0,Number(me.parameters.speedMultiplierVariableId?$[me.parameters.speedMultiplierVariableId]:1))}}catch(Et){R={error:Et}}finally{try{Ce&&!Ce.done&&(U=ve.return)&&U.call(ve)}finally{if(R)throw R.error}}}}catch(Et){A={error:Et}}finally{try{we&&!we.done&&(E=ce.return)&&E.call(ce)}finally{if(A)throw A.error}}if(x){var Oe=function(Et,en){var ot=n.gameplay.find(function(yn){return yn.id===Et});_.get(ot.componentId).sceneId===Y&&en.tick(c)};try{for(var Ue=ke(Gn),Ze=Ue.next();!Ze.done;Ze=Ue.next()){var gt=Ne(Ze.value,2),Ft=gt[0],Ot=gt[1];Oe(Ft,Ot)}}catch(Et){P={error:Et}}finally{try{Ze&&!Ze.done&&(W=Ue.return)&&W.call(Ue)}finally{if(P)throw P.error}}}try{for(var Ut=ke(n.gameplay.filter(function(Et){return Et.kind==="path-agent"})),Xt=Ut.next();!Xt.done;Xt=Ut.next()){var me=Xt.value,Ae=_.get(me.componentId),Bt=Gn.get(me.parameters.networkBehaviorId);if(!(Ae.sceneId!==Y||!Bt))try{for(var _t=(B=void 0,ke(Bi(Ae))),Rt=_t.next();!Rt.done;Rt=_t.next()){var ue=Rt.value,Fe=Bt.getAgent(ue.id);if(Fe){if(Fe.orientToPath==="rotate")ya(ue,Fe.heading);else if(Fe.orientToPath==="flip-x")ya(ue,0,Fe.flipX);else if(Fe.orientToPath==="iso-4"){var At=(j=Ke.get(ue.id))!==null&&j!==void 0?j:{transform:Je([],Ne(ue.transform),!1),parameters:{}};At.pathFrame=Fe.frame,Ke.set(ue.id,At)}var ut=ue.parentId?oi(ui(rt(ue.parentId)),Fe.x,Fe.y):Fe;Hr(ue,ut.x,ut.y)}}}catch(ot){B={error:ot}}finally{try{Rt&&!Rt.done&&(k=_t.return)&&k.call(_t)}finally{if(B)throw B.error}}}}catch(Et){O={error:Et}}finally{try{Xt&&!Xt.done&&(J=Ut.return)&&J.call(Ut)}finally{if(O)throw O.error}}}function Tl(c){var x,A,E,R,U,P,W,O,J,B,k=new Set;try{for(var X=ke(n.gameplay.filter(function(dt){return dt.kind==="value-meter"})),te=X.next();!te.done;te=X.next()){var j=te.value,ae=_.get(j.componentId);if(ae.sceneId===Y)try{for(var ce=(E=void 0,ke(Bi(ae))),we=ce.next();!we.done;we=ce.next()){var me=we.value,Ae=j.parameters,ye=Ae.instanceField?ka(me):void 0,ve=Ae.instanceField==="hp"&&ye?ye.hp/ye.maxHp*(Ae.max-Ae.min)+Ae.min:Ae.instanceField==="value"&&ye?ye.value:Number($[Ae.variableId]),Ce=Cn.get(me.id);Ce||(Ce={base:Je([],Ne(Gr(me)),!1),value:Number.isFinite(ve)?Math.max(Ae.min,Math.min(Ae.max,ve)):Ae.min},Cn.set(me.id,Ce)),k.add(me.id);var ue=Math.max(Ae.min,Math.min(Ae.max,ve)),Fe=Ae.smoothingSeconds?1-Math.exp(-c/Ae.smoothingSeconds):1;Ce.value+=((Number.isFinite(ue)?ue:Ae.min)-Ce.value)*Fe;var Oe=Math.max(0,Math.min(1,(Ce.value-Ae.min)/(Ae.max-Ae.min))),Ue=Je([],Ne(Ce.base),!1),Ze=(J=Ke.get(me.id))!==null&&J!==void 0?J:{parameters:{}},gt=Ae.axis==="x"?vt(me).width:vt(me).height;if(Ae.axis==="x"?(Ue[0]*=Oe,Ue[1]*=Oe):(Ue[2]*=Oe,Ue[3]*=Oe),Ae.direction==="negative"){var Ft=gt*(1-Oe);Ae.axis==="x"?(Ue[4]+=Ce.base[0]*Ft,Ue[5]+=Ce.base[1]*Ft):(Ue[4]+=Ce.base[2]*Ft,Ue[5]+=Ce.base[3]*Ft)}Ke.set(me.id,It(It({},Ze),{transform:Ue}))}}catch(dt){E={error:dt}}finally{try{we&&!we.done&&(R=ce.return)&&R.call(ce)}finally{if(E)throw E.error}}}}catch(dt){x={error:dt}}finally{try{te&&!te.done&&(A=X.return)&&A.call(X)}finally{if(x)throw x.error}}try{for(var Ot=ke(Cn.keys()),Ut=Ot.next();!Ut.done;Ut=Ot.next()){var Xt=Ut.value;k.has(Xt)||Cn.delete(Xt)}}catch(dt){U={error:dt}}finally{try{Ut&&!Ut.done&&(P=Ot.return)&&P.call(Ot)}finally{if(U)throw U.error}}try{for(var Bt=ke(n.gameplay.filter(function(dt){return dt.kind==="camera-follow"})),_t=Bt.next();!_t.done;_t=Bt.next()){var j=_t.value,Rt=_.get(j.componentId),ue=rt(j.parameters.targetId);if(!(Rt.sceneId!==Y||!ue)){var At=Wn.get(Rt.id);At||(At={base:Je([],Ne(Rt.transform),!1),x:j.parameters.minX,y:j.parameters.minY},Wn.set(Rt.id,At));var ut=function(ri,Mi){for(var li=[],Ln=ri;Ln&&Ln.id!==Mi.id;Ln=rt(Ln.parentId))li.unshift(Ln);return li.reduce(function(zi,vr){return Io(zi,Gr(vr))},Ca())},Ue=Wr(ue,Rt.id)?ut(ue,Rt):ui(ue),Ae=vt(ue),Et=oi(Ue,Ae.width/2,Ae.height/2),en=T(),ot=j.parameters,yn=Math.max(ot.minX,ot.maxX-en.width/ot.zoom),fn=Math.max(ot.minY,ot.maxY-en.height/ot.zoom),Dn=Math.max(ot.minX,Math.min(yn,Et.x-en.width/(2*ot.zoom))),Jt=Math.max(ot.minY,Math.min(fn,Et.y-en.height/(2*ot.zoom))),Fe=1-Math.exp(-ot.smoothing*c);At.x+=(Dn-At.x)*Fe,At.y+=(Jt-At.y)*Fe;var Ze=(B=Ke.get(Rt.id))!==null&&B!==void 0?B:{parameters:{}},rn=Je([],Ne(At.base),!1);rn[0]*=ot.zoom,rn[1]*=ot.zoom,rn[2]*=ot.zoom,rn[3]*=ot.zoom,rn[4]-=At.x*ot.zoom,rn[5]-=At.y*ot.zoom,Ke.set(Rt.id,It(It({},Ze),{transform:rn}))}}}catch(dt){W={error:dt}}finally{try{_t&&!_t.done&&(O=Bt.return)&&O.call(Bt)}finally{if(W)throw W.error}}}function jc(){return{bodies:Je([],Ne(Tn.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,vx:c.vx,vy:c.vy,atRest:!!c.atRest,captured:!!c.captured}}),aiming:ie?{componentId:ie.sourceId,pointerId:ie.pointerId,power:ie.power}:null}}function ss(c){for(var x=c;x;){if(x.contract==="native.stage3d.v1")return x;x=x.parentId?rt(x.parentId):void 0}}function Al(c,x){var A,E,R,U,P,W,O,J,B=Ee.get(c.id);if(B)return B;var k=vt(c),X=ss(c),te={};if(x.parameters.fitColliderFromModel&&X&&Nt){Nt.getStage(X);var j=Nt.modelBoundsFor(c.id);if(j){var ae=Math.max(.02,j.width*Math.abs((A=k.sx)!==null&&A!==void 0?A:1)*.5),ce=Math.max(.02,j.depth*Math.abs((E=k.sz)!==null&&E!==void 0?E:1)*.5);te.hx=ae,te.hz=ce,te.radius=Math.max(.02,Math.max(ae,ce))}}return B=It(It({id:c.id,sourceId:x.componentId,stageId:X?.id,x:(R=k.x)!==null&&R!==void 0?R:0,y:(U=k.y)!==null&&U!==void 0?U:0,z:(P=k.z)!==null&&P!==void 0?P:0,vx:0,vy:0,vz:0,spin:0,atRest:!0,captured:!1,captureElapsed:0,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:(W=k.x)!==null&&W!==void 0?W:0,y:(O=k.y)!==null&&O!==void 0?O:0,z:(J=k.z)!==null&&J!==void 0?J:0}},x.parameters),te),Ee.set(c.id,B),B}function ti(){var c,x,A,E,R,U,P,W=[],O=[],J=[];if(!Nt)return{bodies:W,walls:O,zones:J};try{for(var B=ke(n.gameplay.filter(function(me){return me.kind==="physics-3d"})),k=B.next();!k.done;k=B.next()){var X=k.value,te=_.get(X.componentId);if(!(!te||te.sceneId!==Y||!wi(te))){var j=Al(te,X);j.mode==="dynamic"?W.push(j):O.push(j)}}}catch(me){c={error:me}}finally{try{k&&!k.done&&(x=B.return)&&x.call(B)}finally{if(c)throw c.error}}try{for(var ae=ke(n.gameplay.filter(function(me){return me.kind==="capture-zone-3d"})),ce=ae.next();!ce.done;ce=ae.next()){var X=ce.value,te=_.get(X.componentId);if(!(!te||te.sceneId!==Y||!wi(te))){var we=vt(te);J.push(It({id:te.id,sourceId:te.id,x:(R=we.x)!==null&&R!==void 0?R:0,y:(U=we.y)!==null&&U!==void 0?U:0,z:(P=we.z)!==null&&P!==void 0?P:0},X.parameters))}}}catch(me){A={error:me}}finally{try{ce&&!ce.done&&(E=ae.return)&&E.call(ae)}finally{if(A)throw A.error}}return{bodies:W,walls:O,zones:J}}function bo(c){var x,A,E,R,U,P,W,O,J,B;if(Nt){try{for(var k=ke(n.gameplay.filter(function(Xt){return Xt.kind==="oscillate-3d"})),X=k.next();!X.done;X=k.next()){var te=X.value,j=_.get(te.componentId);if(!(!j||j.sceneId!==Y)){var ae=nn.get(j.id);if(!ae){var ce=vt(j);ae={x:(U=ce.x)!==null&&U!==void 0?U:0,y:(P=ce.y)!==null&&P!==void 0?P:0,z:(W=ce.z)!==null&&W!==void 0?W:0},nn.set(j.id,ae)}var we=te.parameters,me=ee*we.angularSpeed+we.phase,Ae=Math.sin(me)*we.amplitude,ye=Math.cos(me)*we.amplitude*we.angularSpeed,ve=(O=Ee.get(j.id))!==null&&O!==void 0?O:ii("physics-3d",j.id)?Al(j,ii("physics-3d",j.id)):void 0,Ce=ae.x+(we.axis==="x"?Ae:0),ue=ae.y+(we.axis==="y"?Ae:0),Fe=ae.z+(we.axis==="z"?Ae:0);if(ve)ve.x=Ce,ve.y=ue,ve.z=Fe,ve.vx=we.axis==="x"?ye:0,ve.vy=we.axis==="y"?ye:0,ve.vz=we.axis==="z"?ye:0;else{var Oe=(J=Ke.get(j.id))!==null&&J!==void 0?J:{transform:Je([],Ne(j.transform),!1),parameters:{}};Oe.parameters.x=Ce,Oe.parameters.y=ue,Oe.parameters.z=Fe,Ke.set(j.id,Oe)}}}}catch(Xt){x={error:Xt}}finally{try{X&&!X.done&&(A=k.return)&&A.call(k)}finally{if(x)throw x.error}}var Ue=ti(),Ze=Ue.bodies,gt=Ue.walls,Ft=Ue.zones;fh({bodies:Ze,walls:gt,zones:Ft,dt:c,onEvent:function(Xt,Bt,_t){var Rt={kind:Xt,componentId:Bt.sourceId};_t&&(Rt.otherId=_t.sourceId),In(Rt)}});try{for(var Ot=ke(Ze),Ut=Ot.next();!Ut.done;Ut=Ot.next()){var ve=Ut.value;ve.captured&&(ve.captureElapsed=((B=ve.captureElapsed)!==null&&B!==void 0?B:0)+c)}}catch(Xt){E={error:Xt}}finally{try{Ut&&!Ut.done&&(R=Ot.return)&&R.call(Ot)}finally{if(E)throw E.error}}Zs(c,gt),Nt.stepAnimations(c,function(Xt,Bt,_t){In(It(It({kind:"modelAnimationEnd",componentId:Bt},Xt!==Bt?{selfInstanceId:Xt,instanceId:Xt}:{}),{clipName:_t}))})}}function ta(c){var x=xn.get(c.componentId);if(!x){var A=c.parameters;x={behavior:c,x:A.x,y:A.y,z:A.z,yaw:A.yaw,pitch:A.pitch,bobPhase:0,bob:0},xn.set(c.componentId,x)}return x}function os(){var c,x;try{for(var A=ke(n.gameplay.filter(function(U){var P;return U.kind==="fps-controller-3d"&&((P=_.get(U.componentId))===null||P===void 0?void 0:P.sceneId)===Y})),E=A.next();!E.done;E=A.next()){var R=E.value;ta(R)}}catch(U){c={error:U}}finally{try{E&&!E.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}}function na(c){var x,A,E,R=[];try{for(var U=ke(We.values()),P=U.next();!P.done;P=U.next()){var W=P.value;W.contract==="native.mesh3d.v1"&&((E=ss(W))===null||E===void 0?void 0:E.id)===c&&R.push(W)}}catch(O){x={error:O}}finally{try{P&&!P.done&&(A=U.return)&&A.call(U)}finally{if(x)throw x.error}}return R}function Ss(c,x,A){var E,R,U=ta(c),P=c.parameters,W=P.lookSensitivity,O=P.invertAimY?-1:1,J=U.yaw-x*W;P.minYaw!==void 0&&P.maxYaw!==void 0&&(J=Math.max(P.minYaw,Math.min(P.maxYaw,J))),U.yaw=J,U.pitch=Math.max((E=P.minPitch)!==null&&E!==void 0?E:-.75,Math.min((R=P.maxPitch)!==null&&R!==void 0?R:.75,U.pitch-A*W*O))}function Zs(c,x){var A,E,R,U,P,W,O,J,B,k,X,te,j,ae,ce,we,me,Ae,ye,ve,Ce=function(_t){var Rt=_.get(_t.componentId);if(!Rt||Rt.sceneId!==Y)return"continue";var At=ta(_t),ut=_t.parameters,Et=ut.aimJoystickBehaviorId?Me.get(ut.aimJoystickBehaviorId):void 0;if(Et&&ut.aimMode==="rate"&&Et.magnitude>1e-4&&c>0){var en=(O=ut.aimTurnSpeed)!==null&&O!==void 0?O:1.8,ot=ut.invertAimY?-1:1,yn=At.yaw-Et.nx*en*c;ut.minYaw!==void 0&&ut.maxYaw!==void 0&&(yn=Math.max(ut.minYaw,Math.min(ut.maxYaw,yn))),At.yaw=yn,At.pitch=Math.max((J=ut.minPitch)!==null&&J!==void 0?J:-.75,Math.min((B=ut.maxPitch)!==null&&B!==void 0?B:.75,At.pitch-Et.ny*en*ot*c))}var fn=ut.joystickBehaviorId?Me.get(ut.joystickBehaviorId):void 0,Dn=fn?fn.nx:Number(ut.moveXVariableId?$[ut.moveXVariableId]:0),Jt=fn?fn.ny:Number(ut.moveYVariableId?$[ut.moveYVariableId]:0),rn=Math.min(1,Math.hypot(Dn,Jt));if(rn>1e-4&&ut.moveSpeed>0&&c>0){var dt=-Jt,ct=Dn,Bn=-Math.sin(At.yaw),ki=-Math.cos(At.yaw),Ti=Math.cos(At.yaw),ln=-Math.sin(At.yaw),ri=ut.moveSpeed*c,Mi=x.filter(function(Ln){return Ln.stageId===Rt.id}),li=hh(At.x+(Bn*dt+Ti*ct)*ri,At.z+(ki*dt+ln*ct)*ri,(k=ut.playerRadius)!==null&&k!==void 0?k:.45,Mi,(X=ut.boundsX)!==null&&X!==void 0?X:12,(te=ut.boundsZ)!==null&&te!==void 0?te:12);At.x=li.x,At.z=li.z,At.bobPhase+=c*10*rn,At.bob=I?.matches?0:Math.sin(At.bobPhase)*((j=ut.bobAmplitude)!==null&&j!==void 0?j:.04)*rn}else At.bob*=Math.max(0,1-12*c)};try{for(var ue=ke(n.gameplay.filter(function(_t){return _t.kind==="fps-controller-3d"})),Fe=ue.next();!Fe.done;Fe=ue.next()){var Oe=Fe.value;Ce(Oe)}}catch(_t){A={error:_t}}finally{try{Fe&&!Fe.done&&(E=ue.return)&&E.call(ue)}finally{if(A)throw A.error}}try{for(var Ue=ke(n.gameplay.filter(function(_t){return _t.kind==="steer-3d"})),Ze=Ue.next();!Ze.done;Ze=Ue.next()){var Oe=Ze.value,gt=_.get(Oe.componentId);if(!(!gt||gt.sceneId!==Y)){var Ft=Oe.parameters,Ot=function(Rt){if(!wi(Rt))return"continue";var At=ss(Rt),ut=At?xn.get(At.id):void 0;if(!ut)return"continue";var Et=vt(Rt),en=(ae=Et.x)!==null&&ae!==void 0?ae:0,ot=(ce=Et.y)!==null&&ce!==void 0?ce:0,yn=(we=Et.z)!==null&&we!==void 0?we:0,fn=ut.x-en,Dn=ut.z-yn,Jt=Math.hypot(fn,Dn),rn=(me=Ft.stopDistance)!==null&&me!==void 0?me:2.5,dt=en,ct=ot,Bn=yn,ki=Ft.mode==="chase-camera"&&rn<=.5;if(Ft.mode==="chase-camera"&&Jt>rn&&Jt>1e-4){var Ti=Math.min(Jt-rn,Ft.speed*c);dt+=fn/Jt*Ti,Bn+=Dn/Jt*Ti,ki&&(ct+=(ut.y-.14-ot)*(Ti/Jt))}else if(Ft.mode==="strafe-camera"&&Jt>1e-4){var ln=-Dn/Jt,ri=fn/Jt;dt+=ln*Ft.speed*c,Bn+=ri*Ft.speed*c}else Ft.mode==="patrol"&&(dt+=Math.cos(ee*1.5)*Ft.speed*c);var Mi=ki?[]:x.filter(function(zi){return zi.stageId===At.id&&zi.id!==Rt.id}),li=ki?{x:dt,z:Bn}:hh(dt,Bn,.45,Mi,(Ae=Ft.boundsX)!==null&&Ae!==void 0?Ae:12,(ye=Ft.boundsZ)!==null&&ye!==void 0?ye:12),Ln=(ve=Ke.get(Rt.id))!==null&&ve!==void 0?ve:{transform:Je([],Ne(Rt.transform),!1),parameters:{}};Ln.parameters.x=li.x,ki&&(Ln.parameters.y=ct),Ln.parameters.z=li.z,Ft.faceCamera!==!1&&(Ln.parameters.ry=Math.atan2(ut.x-li.x,ut.z-li.z)),Ke.set(Rt.id,Ln)};try{for(var Ut=(P=void 0,ke(Bi(gt))),Xt=Ut.next();!Xt.done;Xt=Ut.next()){var Bt=Xt.value;Ot(Bt)}}catch(Rt){P={error:Rt}}finally{try{Xt&&!Xt.done&&(W=Ut.return)&&W.call(Ut)}finally{if(P)throw P.error}}}}}catch(_t){R={error:_t}}finally{try{Ze&&!Ze.done&&(U=Ue.return)&&U.call(Ue)}finally{if(R)throw R.error}}}function El(c){for(var x,A,E,R,U,P,W=[],O=c;O&&O.contract==="native.mesh3d.v1";O=rt(O.parentId))W.push(O);for(var J=0,B=0,k=0,X=0,te=W.length-1;te>=0;te--){var j=W[te],ae=Ee.get(j.id),ce=vt(j),we=ae?ae.x:(x=ce.x)!==null&&x!==void 0?x:0,me=ae?(E=(A=ae.y)!==null&&A!==void 0?A:ce.y)!==null&&E!==void 0?E:0:(R=ce.y)!==null&&R!==void 0?R:0,Ae=ae?ae.z:(U=ce.z)!==null&&U!==void 0?U:0,ye=Math.cos(X),ve=Math.sin(X);J+=we*ye+Ae*ve,B+=me,k+=-we*ve+Ae*ye,X+=(P=ce.ry)!==null&&P!==void 0?P:0}return{x:J,y:B,z:k,ry:X}}var Js=0;function Il(c){var x,A,E,R,U,P,W=Math.max(1,Math.min(16,Math.floor((E=c.count)!==null&&E!==void 0?E:1)));if(c.fromComponentId!==void 0||c.fromTeam!==void 0){var O=[];if(c.fromComponentId!==void 0){var J=_.get(c.fromComponentId);J&&J.sceneId===Y&&(O=Bi(J).filter(function(Ue){var Ze,gt;return wi(Ue)&&((gt=(Ze=ka(Ue))===null||Ze===void 0?void 0:Ze.hp)!==null&>!==void 0?gt:1)>0}))}else{var B=new Set;try{for(var k=ke(Je(Je([],Ne(n.components),!1),Ne(he),!1)),X=k.next();!X.done;X=k.next()){var te=X.value;if(!(te.contract!=="native.mesh3d.v1"||te.sceneId!==Y||te.prototype||B.has(te.id)||!wi(te))){var j=ka(te);j&&j.hp>0&&(c.fromTeam==="any"||j.team===c.fromTeam)&&(B.add(te.id),O.push(te))}}}catch(Ue){x={error:Ue}}finally{try{X&&!X.done&&(A=k.return)&&A.call(k)}finally{if(x)throw x.error}}}if(!O.length)return;for(var ae=(R=c.offsetX)!==null&&R!==void 0?R:0,ce=(U=c.offsetY)!==null&&U!==void 0?U:0,we=(P=c.offsetZ)!==null&&P!==void 0?P:0,me=0;me<W;me++){var Ae=O[Js++%O.length],ye=El(Ae),ve=Math.cos(ye.ry),Ce=Math.sin(ye.ry),ue=c.jitterX?(Vn.rng.next()*2-1)*c.jitterX:0,Fe=c.jitterZ?(Vn.rng.next()*2-1)*c.jitterZ:0;wo(c.prototypeId,ye.x+ae*ve+we*Ce+ue,ye.y+ce,ye.z-ae*Ce+we*ve+Fe)}return}for(var Oe=0;Oe<W;Oe++){var ue=c.jitterX?(Vn.rng.next()*2-1)*c.jitterX:0,Fe=c.jitterZ?(Vn.rng.next()*2-1)*c.jitterZ:0;wo(c.prototypeId,c.x+ue,c.y,c.z+Fe)}}function wo(c,x,A,E){if(he.length>=128){Xn("Instance budget exhausted");return}var R=_.get(c),U=function(J){return 1+n.components.filter(function(B){return B.parentId===J}).reduce(function(B,k){return B+U(k.id)},0)};if(We.size+U(R.id)>4096){Xn("Runtime node budget exhausted");return}var P="instance."+ ++Be;function W(J,B){var k,X,te=J.id===R.id?P:P+":"+J.id,j=It(It({},J),{id:te,runtimeId:te,instanceId:P,prototypeId:J.id,prototype:!1,parentId:B,transform:Je([],Ne(J.transform),!1),parameters:It({},J.parameters),spawnTime:ee});We.set(te,j);try{for(var ae=ke(n.components.filter(function(me){return me.parentId===J.id})),ce=ae.next();!ce.done;ce=ae.next()){var we=ce.value;W(we,te)}}catch(me){k={error:me}}finally{try{ce&&!ce.done&&(X=ae.return)&&X.call(ae)}finally{if(k)throw k.error}}return j}var O=W(R,R.parentId);return O.parameters.x=x,O.parameters.y=A,O.parameters.z=E,he.push(O),bl(O),O}function eu(c){var x,A,E;if(Nt){var R=_.get(c.stageId);if(!(!R||R.sceneId!==Y)){(x=Nt.triggerRecoil)===null||x===void 0||x.call(Nt,R.id);var U=vt(R),P=ui(R),W=Math.hypot(P[0],P[1]),O=Math.hypot(P[2],P[3]),J=Nt.getStage(R),B=!!(J?.isFullBleed&&J.lastWidth>0&&J.lastHeight>0),k=Nt.syncStage(R,{time:ee,ambientTime:be,propsOf:vt,bodies3d:Ee,fpsPose:xn.get(R.id),instances3d:na(R.id),aimLocked:!!Vt,groundFn:Cs,worldWidth:B?J.lastWidth:U.width*W,worldHeight:B?J.lastHeight:U.height*O,designHeight:B?J.lastDesignH:U.height*O}).entry,X=0,te=0;if(c.mode==="pointer")if(B)X=(bt.x-J.lastX)/Math.max(1,J.lastWidth)*2-1,te=1-(bt.y-J.lastY)/Math.max(1,J.lastHeight)*2;else{var j=oi(Dr(P),bt.x,bt.y);X=j.x/Math.max(1,U.width)*2-1,te=1-j.y/Math.max(1,U.height)*2}var ae=new Set(n.gameplay.filter(function(ye){return ye.kind==="physics-3d"&&ye.parameters.mode!=="dynamic"}).map(function(ye){return ye.componentId})),ce=(A=c.targetTeam)!==null&&A!==void 0?A:"any",we=function(ye){var ve,Ce,ue=rt(ye);return!ue||!wi(ue)?!1:ce!=="any"?((ve=ka(ue))===null||ve===void 0?void 0:ve.team)===ce:!!ka(ue)||!ae.has((Ce=ue.prototypeId)!==null&&Ce!==void 0?Ce:ue.id)},me=k.raycast(X,te,(E=c.maxDistance)!==null&&E!==void 0?E:80,{isTarget:we,isOccluder:function(ye){return ae.has(ye)}});if(me){var Ae=rt(me.id);Ae&&In(Qi("raycastHit3d",Ae,R))}else In({kind:"raycastMiss3d",componentId:R.id})}}}function Lf(c,x){var A,E,R,U,P;if(!Nt||!c||c.contract!=="native.mesh3d.v1")return null;var W=(A=x?.stageComp)!==null&&A!==void 0?A:ss(c);if(!W)return null;var O=(E=x?.entry)!==null&&E!==void 0?E:Nt.getStage(W),J=x?x.fullBleed:!!O?.isFullBleed,B=x?J?x.worldWidth:x.stageWidth:(R=O?.lastWidth)!==null&&R!==void 0?R:0,k=x?J?x.worldHeight:x.stageHeight:(U=O?.lastHeight)!==null&&U!==void 0?U:0;if(!O||B<=0||k<=0)return null;var X=(P=O.projectNodeBounds)===null||P===void 0?void 0:P.call(O,c.id,B,k);if(!X)return null;var te=function(ve){var Ce,ue,Fe;if(J){var Oe=x?x.drawX:(Ce=O.lastX)!==null&&Ce!==void 0?Ce:0,Ue=x?x.drawY:(ue=O.lastY)!==null&&ue!==void 0?ue:0;return{x:Oe+ve.x,y:Ue+ve.y}}var Ze=(Fe=x?.m)!==null&&Fe!==void 0?Fe:ui(W);return oi(Ze,ve.x,ve.y)};if(X.behindCamera)return{id:c.id,stageId:W.id,visible:X.visible,behindCamera:!0,localBounds:X,stageLocalWidth:B,stageLocalHeight:k,stageEntry:O,bounds:{left:0,right:0,top:0,bottom:0,width:0,height:0,centerX:0,centerY:0},anchors:{center:{x:0,y:0},top:{x:0,y:0},bottom:{x:0,y:0}}};var j=[[X.left,X.top],[X.right,X.top],[X.right,X.bottom],[X.left,X.bottom]].map(function(ve){var Ce=Ne(ve,2),ue=Ce[0],Fe=Ce[1];return te({x:ue,y:Fe})}),ae=Math.min.apply(Math,Je([],Ne(j.map(function(ve){return ve.x})),!1)),ce=Math.max.apply(Math,Je([],Ne(j.map(function(ve){return ve.x})),!1)),we=Math.min.apply(Math,Je([],Ne(j.map(function(ve){return ve.y})),!1)),me=Math.max.apply(Math,Je([],Ne(j.map(function(ve){return ve.y})),!1)),Ae={left:ae,right:ce,top:we,bottom:me,width:Math.max(0,ce-ae),height:Math.max(0,me-we),centerX:(ae+ce)/2,centerY:(we+me)/2},ye={center:te(X.anchors.center),top:te(X.anchors.top),bottom:te(X.anchors.bottom)};return{id:c.id,stageId:W.id,visible:X.visible,behindCamera:!1,localBounds:X,stageLocalWidth:B,stageLocalHeight:k,stageEntry:O,bounds:Ae,anchors:ye}}function Df(c){var x,A,E,R,U,P,W,O,J,B,k,X,te,j,ae,ce,we,me,Ae;if(pn.clear(),Sn.clear(),!!Nt){var ye=[];try{for(var ve=ke(hi),Ce=ve.next();!Ce.done;Ce=ve.next()){var ue=Ne(Ce.value,2),Fe=ue[0],Oe=ue[1],Ue=_.get(Fe);Ue&&Ue.sceneId===Y&&ye.push({comp:Ue,cfg:Oe})}}catch(Oi){x={error:Oi}}finally{try{Ce&&!Ce.done&&(A=ve.return)&&A.call(ve)}finally{if(x)throw x.error}}if(ye.length){var Ze=new Map;try{for(var gt=ke(n.components),Ft=gt.next();!Ft.done;Ft=gt.next()){var Ot=Ft.value;if(!(Ot.contract!=="native.stage3d.v1"||Ot.sceneId!==Y||Ot.prototype||!wi(Ot))){var Ut=!!(xt.has(Ot.id)&&pi),Xt=ui(Ot),Bt=ei(Ot),_t=Math.hypot(Xt[0],Xt[1]),Rt=Math.hypot(Xt[2],Xt[3]),At=Ut?pi.w:Bt.width*_t,ut=Ut?pi.h:Bt.height*Rt,Et=Ut?pi.x:0,en=Ut?pi.y:0,ot=Ut?c.height:Bt.height*Rt,yn=Nt.syncStage(Ot,{time:ee,ambientTime:be,propsOf:ei,bodies3d:Ee,fpsPose:xn.get(Ot.id),instances3d:na(Ot.id),aimLocked:!!Vt,groundFn:Cs,worldWidth:At,worldHeight:ut,designHeight:ot}).entry;Object.assign(yn,{lastX:Et,lastY:en,lastWidth:Ut?At:Bt.width,lastHeight:Ut?ut:Bt.height,lastDesignH:ot,isFullBleed:Ut}),Ze.set(Ot.id,{stageComp:Ot,entry:yn,m:Xt,fullBleed:Ut,drawX:Et,drawY:en,worldWidth:At,worldHeight:ut,stageWidth:Bt.width,stageHeight:Bt.height})}}}catch(Oi){E={error:Oi}}finally{try{Ft&&!Ft.done&&(R=gt.return)&&R.call(gt)}finally{if(E)throw E.error}}var fn=Ys(c),Dn=function(Oi){for(var xr=Oi;xr;xr=xr.parentId?rt(xr.parentId):void 0){var kn=ei(xr);if(!kn.visible||kn.opacity<=0)return!1}return!0};try{for(var Jt=ke(ye),rn=Jt.next();!rn.done;rn=Jt.next()){var dt=rn.value,Ue=dt.comp,Oe=dt.cfg,ct=Dn(Ue),Bn=rt(Oe.targetId),Ot=Bn?ss(Bn):void 0,ki=Ot?Ze.get(Ot.id):void 0,Ti=!!(Bn&&ki&&Dn(Bn)),ln=Bn&&ki?Lf(Bn,ki):null,ri=!!(!ln||ln.behindCamera),Mi=1,li=!0;if(ln&&!ln.behindCamera){var Ln=ln.bounds,zi=Math.max(0,Math.min(Ln.right,fn.right)-Math.max(Ln.left,fn.left)),vr=Math.max(0,Math.min(Ln.bottom,fn.bottom)-Math.max(Ln.top,fn.top));if(Ln.width<.5&&Ln.height<.5){var gr=Ln.centerX>=fn.left&&Ln.centerX<=fn.right&&Ln.centerY>=fn.top&&Ln.centerY<=fn.bottom;Mi=gr?0:1,li=!gr}else{var Gi=Math.max(1,Ln.width*Ln.height);Mi=Math.max(0,Math.min(1,1-zi*vr/Gi)),li=zi<=0||vr<=0}}var $n=ei(Ue),ci=void 0,mn=void 0,vi=void 0,Nn=void 0;if(ln&&!ln.behindCamera&&Oe.fitToProjectedBounds){var yi=(W=Oe.paddingPx)!==null&&W!==void 0?W:10,sn=(O=Oe.minSizePx)!==null&&O!==void 0?O:48,Yn=(J=Oe.maxSizePx)!==null&&J!==void 0?J:260,Ai=ln.bounds.width+yi*2,yr=ln.bounds.height+yi*2;if(Oe.squareBounds){var Ar=Math.max(Ai,yr);Ai=Ar,yr=Ar}ci=Math.max(sn,Math.min(Yn,Ai)),mn=Math.max(sn,Math.min(Yn,yr)),Ue.contract==="native.group.v1"&&$n.width>0&&$n.height>0&&(vi=ci/$n.width,Nn=mn/$n.height)}var Cr=ci??$n.width,xa=mn??$n.height,ar=ln&&!ln.behindCamera?(k=ln.anchors[(B=Oe.anchor)!==null&&B!==void 0?B:"center"])!==null&&k!==void 0?k:{x:ln.bounds.centerX,y:ln.bounds.centerY}:null,Xr=ar?ar.x+((X=Oe.offsetX)!==null&&X!==void 0?X:0):0,Yr=ar?ar.y+((te=Oe.offsetY)!==null&&te!==void 0?te:0):0,Rr=(j=Oe.offscreen)!==null&&j!==void 0?j:"hide";if(ar&&Rr==="clamp"){var qr=Cr/2,Fi=xa/2;Xr=Math.max(fn.left+qr,Math.min(fn.right-qr,Xr)),Yr=Math.max(fn.top+Fi,Math.min(fn.bottom-Fi,Yr))}var Yi=ct;Oe.syncVisibility!==!1&&!Ti&&(Yi=!1),ri&&(Yi=!1),Rr==="hide"&&li&&(Yi=!1);var yn={componentId:Ue.id,targetId:Oe.targetId,stageId:(ae=Ot?.id)!==null&&ae!==void 0?ae:null,config:Oe,ownerHiddenByAuthor:!ct,targetVisible:Ti,visible:Yi,behindCamera:ri,offscreen:li,clippedFraction:Mi,targetBounds:ln&&!ln.behindCamera?ln.bounds:null,localBounds:(ce=ln?.localBounds)!==null&&ce!==void 0?ce:null,stageLocalWidth:(we=ln?.stageLocalWidth)!==null&&we!==void 0?we:0,stageLocalHeight:(me=ln?.stageLocalHeight)!==null&&me!==void 0?me:0,stageEntry:(Ae=ln?.stageEntry)!==null&&Ae!==void 0?Ae:null,anchorPoint:ar,cx:Xr,cy:Yr,fittedWidth:ci,fittedHeight:mn,groupScaleX:vi,groupScaleY:Nn,showHighlight:!!(Oe.showHighlight&&Yi&&ln&&!ln.behindCamera)};pn.set(Ue.id,yn),ln&&!ln.behindCamera&&Sn.set(Oe.targetId,It(It({},ln.bounds),{visible:Ti,behindCamera:!1,offscreen:li,clippedFraction:Number(Mi.toFixed(3))}))}}catch(Oi){U={error:Oi}}finally{try{rn&&!rn.done&&(P=Jt.return)&&P.call(Jt)}finally{if(U)throw U.error}}}}}function Nf(c){var x,A,E,R,U;if(!(!c?.showHighlight||!c.targetBounds)){var P=c.targetBounds,W=c.config,O=(x=W.paddingPx)!==null&&x!==void 0?x:10,J=(A=W.minSizePx)!==null&&A!==void 0?A:48,B=(E=W.maxSizePx)!==null&&E!==void 0?E:260,k=Math.max(J,Math.min(B,P.width+O*2)),X=Math.max(J,Math.min(B,P.height+O*2));if(W.squareBounds){var te=Math.max(k,X);k=te,X=te}var j=P.centerX,ae=P.centerY,ce=(R=W.highlightStyle)!==null&&R!==void 0?R:"pulse-ring",we=(U=W.highlightColor)!==null&&U!==void 0?U:"#fff0bd",me=ce==="pulse-ring"&&!I?.matches?Math.sin(be*4.2):0,Ae=ce==="pulse-ring"&&!I?.matches?be*.9%1:0;if(p.save(),ce==="box"){var ye=k/2,ve=X/2,Ce=j-ye,ue=ae-ve,Fe=j+ye,Oe=ae+ve,Ue=Math.max(8,Math.min(18,Math.min(k,X)*.28)),Ze=function(Ot,Ut){p.strokeStyle=Ot,p.lineWidth=Ut,p.lineCap="round",p.lineJoin="round",p.beginPath(),p.moveTo(Ce,ue+Ue),p.lineTo(Ce,ue),p.lineTo(Ce+Ue,ue),p.moveTo(Fe-Ue,ue),p.lineTo(Fe,ue),p.lineTo(Fe,ue+Ue),p.moveTo(Fe,Oe-Ue),p.lineTo(Fe,Oe),p.lineTo(Fe-Ue,Oe),p.moveTo(Ce+Ue,Oe),p.lineTo(Ce,Oe),p.lineTo(Ce,Oe-Ue),p.stroke()};Ze("#00000066",6),Ze(we,3)}else{var gt=Math.max(22,k/2*(1+me*.035)),Ft=Math.max(22,X/2*(1+me*.035));ce==="pulse-ring"&&!I?.matches&&(p.save(),p.globalAlpha*=.48*(1-Ae),p.strokeStyle=we,p.lineWidth=2.5,p.beginPath(),p.ellipse(j,ae,gt*(1+Ae*.18),Ft*(1+Ae*.18),0,0,Math.PI*2),p.stroke(),p.restore()),p.save(),p.globalAlpha*=.1,p.fillStyle=we,p.beginPath(),p.ellipse(j,ae,gt,Ft,0,0,Math.PI*2),p.fill(),p.restore(),p.strokeStyle="#00000066",p.lineWidth=5.5,p.beginPath(),p.ellipse(j,ae,gt,Ft,0,0,Math.PI*2),p.stroke(),p.strokeStyle=we,p.lineWidth=3,p.beginPath(),p.ellipse(j,ae,gt,Ft,0,0,Math.PI*2),p.stroke()}p.restore()}}function Uf(c){var x,A,E,R,U,P;if(!Nt)return null;var W=rt(c);if(!W||W.contract!=="native.mesh3d.v1")return null;var O=ss(W);if(!O)return null;var J=Nt.getStage(O);if(!J||!J.lastWidth||!J.lastHeight)return null;var B=(x=J.projectNodeBounds)===null||x===void 0?void 0:x.call(J,W.id,J.lastWidth,J.lastHeight);if(B&&!B.behindCamera){var k=(E=(A=B.anchors)===null||A===void 0?void 0:A.center)!==null&&E!==void 0?E:{x:B.centerX,y:B.centerY};return J.isFullBleed?{x:J.lastX+k.x,y:J.lastY+k.y}:oi(ui(O),k.x,k.y)}var X=Ee.get(W.id),te=vt(W),j=J.project({x:X?X.x:(R=te.x)!==null&&R!==void 0?R:0,y:X?X.y:(U=te.y)!==null&&U!==void 0?U:0,z:X?X.z:(P=te.z)!==null&&P!==void 0?P:0},J.lastWidth,J.lastHeight);return J.isFullBleed?{x:J.lastX+j.x,y:J.lastY+j.y}:oi(ui(O),j.x,j.y)}function rm(){if(!Vt||!Nt)return{vx:0,vz:0,power:0,pull:0};var c=_.get(Vt.stageId),x=Nt.getStage(c),A=Ee.get(Vt.targetId),E=Vt.behavior.parameters;if(!x||!A||!x.lastWidth||!x.lastHeight)return{vx:0,vz:0,power:0,pull:0};var R,U;if(x.isFullBleed)R={x:Vt.start.x-x.lastX,y:Vt.start.y-x.lastY},U={x:Vt.current.x-x.lastX,y:Vt.current.y-x.lastY};else{var P=Dr(ui(c));R=oi(P,Vt.start.x,Vt.start.y),U=oi(P,Vt.current.x,Vt.current.y)}var W=Math.hypot(Vt.current.x-Vt.start.x,Vt.current.y-Vt.start.y),O=x.unproject(R.x,R.y,x.lastWidth,x.lastHeight,A.y),J=x.unproject(U.x,U.y,x.lastWidth,x.lastHeight,A.y);if(!O||!J)return{vx:0,vz:0,power:0,pull:W};var B=(O.x-J.x)*E.dragScale,k=(O.z-J.z)*E.dragScale,X=Math.hypot(B,k);return X>E.maxSpeed&&(B*=E.maxSpeed/X,k*=E.maxSpeed/X),{vx:B,vz:k,power:Math.min(1,Math.hypot(B,k)/Math.max(.001,E.maxSpeed)),pull:W}}function am(c){if(!(!Vt||!Nt)){Vt.current=c;var x=rm(),A=Vt.behavior.parameters;Vt.power=x.power,A.powerVariableId&&($[A.powerVariableId]=x.power);var E=_.get(Vt.stageId),R=Nt.getStage(E),U=Ee.get(Vt.targetId);if(R&&U&&A.showTrajectory&&x.pull>=A.minPullPx){var P=ti(),W=P.walls,O=P.zones;R.setGuide(rv({body:U,walls:W,zones:O,vx:x.vx,vz:x.vz,dots:A.trajectoryDots}))}else R?.setGuide([])}}function Vg(){return{bodies:Je([],Ne(Ee.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,z:c.z,vx:c.vx,vy:c.vy,vz:c.vz,atRest:!!c.atRest,captured:!!c.captured,airborne:!!c.airborne}}),aiming:Vt?{componentId:Vt.sourceId,pointerId:Vt.pointerId,power:Vt.power}:null,projected:Object.fromEntries(jt),projectedBounds:Object.fromEntries(Sn),fps:Object.fromEntries(Je([],Ne(xn),!1).map(function(c){var x=Ne(c,2),A=x[0],E=x[1];return[A,{x:E.x,y:E.y,z:E.z,yaw:E.yaw,pitch:E.pitch}]}))}}function Ff(){K=void 0,gn=void 0,ea(),Me.clear(),hn.clear(),An.clear(),Fn.clear(),Vn.reset(),jn.clear(),Zn.clear(),wt=[],kt=[],C.clear(),re.clear(),H.clear(),Ie=[],Xe=[],qe=void 0,Le=0,Pe=!1,lt=0,$=Object.fromEntries(n.variables.map(function(c){return[c.id,c.initial]})),Rn(),an=0,We.clear(),ze.clear(),Tn.clear(),Hn.clear(),Ee.clear(),nn.clear(),jt.clear(),Sn.clear(),pn.clear(),xn.clear(),Js=0,Nt?.reset(),Cn.clear(),Wn.clear(),ie=void 0,he=[],pe=[],le=[],Ke.clear(),Jc(),fe.clear(),De.clear(),oe.clear(),Te=[],ee=0,be=0,Be=0,mt=!1,Re=0,Y=n.base.startScene,on=void 0,de=void 0,Dt=void 0,Mn=void 0,f||(Rf(),za(),Qc(),ti(),os(),So(0,!1),zf(),Tl(0),In({kind:"sceneEnter",sceneId:Y}))}function Of(){var c,x;if(!(!Ve||Ve.state!=="running"||!Tt.size)){var A=Je([],Ne(Tt.values()),!1);Tt.clear();try{for(var E=ke(A),R=E.next();!R.done;R=E.next()){var U=R.value;om(U)}}catch(P){c={error:P}}finally{try{R&&!R.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}}function Cl(c){if(c===void 0&&(c=!1),!Ve)return Promise.resolve(void 0);if(Ve.state==="running")return Promise.resolve().then(Of),Promise.resolve(Ve);if(!Yt||c){var x=Ve,A=Promise.resolve().then(function(){return x.resume()}).then(function(){if(x.state==="running")return Of(),x}).catch(function(){}).finally(function(){Yt===A&&(Yt=void 0)});Yt=A}return Yt}function Bf(){var c,x,A=Je([],Ne(pt.values()),!1),E=A.some(function(B){return B.bus==="voice"}),R=A.some(function(B){return B.bus==="stinger"}),U=R?.2:E?.25:1;try{for(var P=ke(A),W=P.next();!W.done;W=P.next()){var O=W.value,J=O.volume*bn*(O.bus==="music"?U:1);O.gain.gain.setTargetAtTime?O.gain.gain.setTargetAtTime(J,Ve.currentTime,.04):O.gain.gain.value=J}}catch(B){c={error:B}}finally{try{W&&!W.done&&(x=P.return)&&x.call(P)}finally{if(c)throw c.error}}}function Gg(c,x){if(!x||typeof c.createBuffer!="function"||typeof x.getChannelData!="function"||!x.numberOfChannels)return x;var A=x.sampleRate||44100,E=x.length;if(E<Math.round(A*.2))return x;for(var R=x.numberOfChannels,U=.002,P=E,W=0,O=0;O<R;O++){for(var J=x.getChannelData(O),B=0;B<P;B++)if(Math.abs(J[B])>U){P=B;break}for(var B=E-1;B>W;B--)if(Math.abs(J[B])>U){W=B;break}}if(P>=W)return x;var k=W-P+1;if(k<Math.round(A*.15))return x;var X=Math.min(Math.round(A*.06),Math.floor(k*.1)),te=k-X;if(X<8||te<Math.round(A*.1))return x;for(var j=c.createBuffer(R,te,A),O=0;O<R;O++){for(var ae=x.getChannelData(O),ce=j.getChannelData(O),B=0;B<X;B++){var we=B/X;ce[B]=ae[P+B]*Math.sin(we*Math.PI*.5)+ae[P+te+B]*Math.cos(we*Math.PI*.5)}for(var B=X;B<te;B++)ce[B]=ae[P+B]}return j}function sm(c,x,A){var E,R=(E=A.parameters.bus)!==null&&E!==void 0?E:"sfx";c.connect(x),x.connect(Ve.destination),ht.add(c),pt.set(c,{gain:x,bus:R,volume:A.parameters.volume}),c.onended=function(){ht.delete(c),pt.delete(c),A.parameters.loop&&qt.delete(A.id),Bf()},Bf()}function om(c){return v1(this,void 0,void 0,function(){var x,A,E,R,U,P,W,O,J,B,k,X,te,j,ae,ce,we,me,Ae,ye,ve,Ce,ue,Fe,Oe,Ue,Ze,gt,Ft,Ot,Ut,Xt;return g1(this,function(Bt){switch(Bt.label){case 0:return ht.size>=32?[2]:(x=!!c.parameters.loop,Ve?(A=Ve,E=cn,R=(Ue=c.parameters.cooldownMs)!==null&&Ue!==void 0?Ue:45,U=A.currentTime,R>0&&U-((Ze=Lt.get(c.id))!==null&&Ze!==void 0?Ze:-1/0)<R/1e3?[2]:x&&qt.has(c.id)?[2]:(P=_.get(c.componentId),W=N.get((gt=P?.assetSlots[0])===null||gt===void 0?void 0:gt.assetId),O=W?.mime==="audio/wav"||W?.mime==="audio/mpeg",!O&&c.parameters.allowSynthFallback===!1?(an++,[2]):(Lt.set(c.id,U),J=A.state!=="running",J?[4,Cl()]:[3,2]))):(x&&Tt.set(c.id,c),[2]));case 1:J=!Bt.sent(),Bt.label=2;case 2:if(J)return x&&Tt.set(c.id,c),[2];if(Ve!==A||A.state!=="running"||E!==cn||ht.size>=32)return[2];if(B=(Ft=et.get(c.id))!==null&&Ft!==void 0?Ft:0,k=[0,-.5,.5,-1,1],X=((Ot=c.parameters.pitchJitter)!==null&&Ot!==void 0?Ot:0)*k[B%k.length],te=Number((Ut=$[c.parameters.pitchVariableId])!==null&&Ut!==void 0?Ut:0),j=Math.max(-12,Math.min(12,X+te*((Xt=c.parameters.pitchStep)!==null&&Xt!==void 0?Xt:0))),ae=Math.pow(2,j/12),et.set(c.id,B+1),!O)return[3,8];x&&qt.add(c.id),Bt.label=3;case 3:if(Bt.trys.push([3,6,,7]),ce=St.get(W.hash),ce)return[3,5];for(we=atob(W.data),me=new Uint8Array(we.length),Ae=0;Ae<we.length;Ae++)me[Ae]=we.charCodeAt(Ae);return[4,new Promise(function(_t,Rt){var At=A.decodeAudioData(me.buffer,_t,Rt);At&&typeof At.then=="function"&&At.then(_t,Rt)})];case 4:ce=Bt.sent(),St.set(W.hash,ce),Bt.label=5;case 5:return Ve!==A||A.state!=="running"||E!==cn||ht.size>=32?(x&&E===cn&&qt.delete(c.id),[2]):(ye=ce,x&&(ye=He.get(W.hash),ye||(ye=Gg(A,ce),He.set(W.hash,ye))),ve=A.createBufferSource(),Ce=A.createGain(),ve.buffer=ye,ve.loop=x,ve.playbackRate&&(ve.playbackRate.value=ae),x&&Ce.gain.setValueAtTime&&Ce.gain.linearRampToValueAtTime?(Ce.gain.setValueAtTime(1e-4,A.currentTime),Ce.gain.linearRampToValueAtTime(c.parameters.volume,A.currentTime+.025)):Ce.gain.value=c.parameters.volume,sm(ve,Ce,c),ve.start(),[3,7]);case 6:return ue=Bt.sent(),qt.delete(c.id),Xn("Audio decode failed"),[3,7];case 7:return[2];case 8:return Fe=A.createOscillator(),Oe=A.createGain(),Fe.frequency.value=c.parameters.frequency*ae,Fe.type="sine",Oe.gain.setValueAtTime(c.parameters.volume,A.currentTime),Oe.gain.exponentialRampToValueAtTime(.001,A.currentTime+c.parameters.seconds),sm(Fe,Oe,c),Fe.start(),Fe.stop(A.currentTime+c.parameters.seconds),[2]}})})}function Hg(c,x){for(var A=Je([],Ne(Ht.values()),!1).filter(function(B){return B.boardId===c}),E=function(B,k){var X;return(X=A.find(function(te){return te.row===B&&te.column===k}))===null||X===void 0?void 0:X.group},R=function(B){for(var k=function(j){var ae=E(B,j);if(ae&&ae===E(B,j+1)&&ae===E(B,j+2)&&x.some(function(ce){return ce.row===B&&ce.column>=j&&ce.column<=j+2}))return{value:!0}},X=0;X<14;X++){var te=k(X);if(typeof te=="object")return te}},U=0;U<16;U++){var P=R(U);if(typeof P=="object")return P.value}for(var W=function(B){for(var k=function(j){var ae=E(j,B);if(ae&&ae===E(j+1,B)&&ae===E(j+2,B)&&x.some(function(ce){return ce.column===B&&ce.row>=j&&ce.row<=j+2}))return{value:!0}},X=0;X<14;X++){var te=k(X);if(typeof te=="object")return te}},O=0;O<16;O++){var J=W(O);if(typeof J=="object")return J.value}return!1}function Wg(c){var x,A,E,R=Ht.get(c.id);if(!(!R||R.sceneId!==Y||!vt(c).enabled||!wi(c))){var U=Wt.get(c.parentId);if(U){Ct=U.select(c.id);return}if(Ct===c.id){Ct=void 0;return}var P=Ht.get(Ct);if(!P||P.sceneId!==Y||P.boardId!==R.boardId){Ct=c.id;return}var W=_.get(Ct);if(Math.abs(P.row-R.row)+Math.abs(P.column-R.column)!==1){Ct=c.id;return}if(P.group===R.group){Ct=void 0,In({kind:"invalidMatch",componentId:(x=c.parentId)!==null&&x!==void 0?x:c.id});return}var O=P.row,J=P.column,B=R.row,k=R.column,X=Je([],Ne(Gr(W)),!1),te=Je([],Ne(Gr(c)),!1);if(P.row=B,P.column=k,R.row=O,R.column=J,Hg(R.boardId,[P,R])){var j=function(ae,ce){var we,me=(we=Ke.get(ae.id))!==null&&we!==void 0?we:{transform:Je([],Ne(Gr(ae)),!1),parameters:{}};me.transform=Je([],Ne(me.transform),!1),me.transform[4]=ce[4],me.transform[5]=ce[5],Ke.set(ae.id,me)};j(W,te),j(c,X),Ct=void 0,In({kind:"validMatch",componentId:(A=c.parentId)!==null&&A!==void 0?A:c.id})}else P.row=O,P.column=J,R.row=B,R.column=k,Ct=void 0,In({kind:"invalidMatch",componentId:(E=c.parentId)!==null&&E!==void 0?E:c.id})}}function kf(c){var x,A,E,R,U=[],P=mr(c,ui(c)),W=Ui(c),O=ii("drag",(E=c.prototypeId)!==null&&E!==void 0?E:c.id),J=function(te){var j,ae,ce=_.get(te.componentId),we=te.parameters;if(ce.sceneId!==Y)return"continue";var me=function(Ce){if(Ce.id===c.id||Wr(Ce,c.id)||!wi(Ce))return"continue";var ue=mr(Ce,ui(Ce)),Fe=Ui(Ce),Oe=Math.hypot(Fe.x-W.x,Fe.y-W.y),Ue=we.radiusPx>0?Oe<=we.radiusPx:P.left<ue.right&&P.right>ue.left&&P.top<ue.bottom&&P.bottom>ue.top;if(!Ue)return"continue";U.push(It({id:Ce.id,c:Ce,sourceId:ce.id,paintOrder:ne.findIndex(function(Ze){return Ze.c.id===Ce.id}),distance:Oe,itemTarget:n.gameplay.some(function(Ze){return Ze.kind==="drag"&&Ze.componentId===ce.id})},we))};try{for(var Ae=(j=void 0,ke(Bi(ce))),ye=Ae.next();!ye.done;ye=Ae.next()){var ve=ye.value;me(ve)}}catch(Ce){j={error:Ce}}finally{try{ye&&!ye.done&&(ae=Ae.return)&&ae.call(Ae)}finally{if(j)throw j.error}}};try{for(var B=ke(n.gameplay.filter(function(te){return te.kind==="drop-zone"})),k=B.next();!k.done;k=B.next()){var X=k.value;J(X)}}catch(te){x={error:te}}finally{try{k&&!k.done&&(A=B.return)&&A.call(B)}finally{if(x)throw x.error}}return{zones:U,tag:(R=O?.parameters.tag)!==null&&R!==void 0?R:""}}function zf(c){var x,A,E=c?[c]:n.gameplay.filter(function(k){return k.kind==="drag"}).flatMap(function(k){return Bi(_.get(k.componentId))});try{for(var R=ke(E),U=R.next();!U.done;U=R.next()){var P=U.value;if(!(!P||!wi(P)||hn.zoneOf(P.id))){var W=kf(P),O=W.zones,J=W.tag,B=vu({itemId:P.id,tag:J,zones:O.filter(function(k){return!k.itemTarget}),occupancy:hn});B?.kind==="accept"&&hn.place(P.id,B.zone.id)}}}catch(k){x={error:k}}finally{try{U&&!U.done&&(A=R.return)&&A.call(R)}finally{if(x)throw x.error}}}function $s(c,x,A){A===void 0&&(A=.18),c&&un.to(c.id,Ui(c),x,A)}function Vf(c,x,A,E){var R,U,P=E??A?.c;In(It(It({},Qi(c,x,P,It({},A?{otherId:A.sourceId}:{}))),{instanceId:(R=x.instanceId)!==null&&R!==void 0?R:(U=A?.c)===null||U===void 0?void 0:U.instanceId}))}function Xg(c){var x,A,E,R,U,P,W;if(!st||st.pointerId!==c.pointerId)return!1;var O=st,J=rt(O.targetId),B=O.b.parameters;st=void 0,je=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,c.pointerId))}catch{}if(!J)return!0;var k=kf(J),X=k.zones,te=k.tag,j=vu({itemId:J.id,tag:te,zones:X,occupancy:hn}),ae=O.origin,ce=O.originZone;if(!j)return Vf("dragReject",J,void 0,void 0),B.snapBack&&(ce&&hn.place(J.id,ce),$s(J,ae,(E=B.snapBackSeconds)!==null&&E!==void 0?E:.18)),!0;var we=j.zone,me=j.occupantId?rt(j.occupantId):void 0;return j.kind==="reject"?(Vf("dragReject",J,we,me),B.snapBack&&(ce&&hn.place(J.id,ce),$s(J,ae,(R=B.snapBackSeconds)!==null&&R!==void 0?R:.18)),!0):(j.kind==="accept"?(hn.place(J.id,we.id),we.snapMode==="center"&&$s(J,Ui(we.c),(U=B.snapBackSeconds)!==null&&U!==void 0?U:.18)):j.kind==="swap"&&me&&(hn.place(J.id,we.id),ce?hn.place(me.id,ce):hn.release(me.id),$s(J,Ui(we.c),(P=B.snapBackSeconds)!==null&&P!==void 0?P:.18),$s(me,ae,(W=B.snapBackSeconds)!==null&&W!==void 0?W:.18)),Vf("dragDrop",J,we,j.kind==="accept"?we.c:me),!0)}function Yg(c){var x,A,E,R,U;un.tick(c,function(j,ae){var ce=rt(j);ce&&Hr(ce,ae.x,ae.y)});try{for(var P=ke(Je([],Ne(hn.itemZone.keys()),!1)),W=P.next();!W.done;W=P.next()){var O=W.value,J=rt(O);(!J||!wi(J))&&hn.release(O)}}catch(j){x={error:j}}finally{try{W&&!W.done&&(A=P.return)&&A.call(P)}finally{if(x)throw x.error}}if(Qe)try{for(var B=ke(Qe.holds),k=B.next();!k.done;k=B.next()){var X=k.value,te=X.charge.tick(c);te!==$[X.behavior.parameters.variableId]&&($[X.behavior.parameters.variableId]=te,In({kind:"variableChange",variableId:X.behavior.parameters.variableId,instanceId:X.c.instanceId,selfInstanceId:(U=X.c.instanceId)!==null&&U!==void 0?U:X.c.id}))}}catch(j){E={error:j}}finally{try{k&&!k.done&&(R=B.return)&&R.call(B)}finally{if(E)throw E.error}}}function lm(c,x){var A,E,R,U,P=x.targetMode;if(P==="pointer")return It({},bt);if(P==="component"){var W=rt(x.targetComponentId);return W?Ui(W):void 0}if(P==="nearest-team"){var O=Ui(c),J=[],B=x.team,k=(R=x.maxRangePx)!==null&&R!==void 0?R:0;try{for(var X=ke(Vn.states),te=X.next();!te.done;te=X.next()){var j=Ne(te.value,2),ae=j[0],ce=j[1],W=rt(ae);W&&wi(W)&&J.push(It(It({id:ae},Ui(W)),{team:ce.team}))}}catch(we){A={error:we}}finally{try{te&&!te.done&&(E=X.return)&&E.call(X)}finally{if(A)throw A.error}}return zm(O,J,B,k,(U=c.instanceId)!==null&&U!==void 0?U:c.id)}}function qg(c){var x,A,E,R,U;try{for(var P=ke(n.gameplay.filter(function(ve){return ve.kind==="steer"})),W=P.next();!W.done;W=P.next()){var O=W.value,J=_.get(O.componentId),B=O.parameters;if(J.sceneId===Y)try{for(var k=(E=void 0,ke(Bi(J))),X=k.next();!X.done;X=k.next()){var te=X.value;if(wi(te)){var j=lm(te,B);if(j){var ae=Ui(te),ce=j.x-ae.x,we=j.y-ae.y;if(!(B.maxRangePx>0&&Math.hypot(ce,we)>B.maxRangePx)){var me=Math.atan2(we,ce);B.mode==="flee"?me+=Math.PI:B.mode==="orbit"&&(me+=Math.PI/2);var Ae=(U=Vn.headings.get(te.id))!==null&&U!==void 0?U:me,ye=Vm(Ae,me,B.turnRateDegPerSec*Math.PI/180*c);Vn.headings.set(te.id,ye),Hr(te,ae.x+Math.cos(ye)*B.speed*c,ae.y+Math.sin(ye)*B.speed*c),B.orientToVelocity!==!1&&ya(te,ye)}}}}}catch(ve){E={error:ve}}finally{try{X&&!X.done&&(R=k.return)&&R.call(k)}finally{if(E)throw E.error}}}}catch(ve){x={error:ve}}finally{try{W&&!W.done&&(A=P.return)&&A.call(P)}finally{if(x)throw x.error}}}function Gf(c,x,A,E){var R;if(he.length>=128){Xn("Instance budget exhausted");return}var U=_.get(c),P=function(B){return 1+n.components.filter(function(k){return k.parentId===B}).reduce(function(k,X){return k+P(X.id)},0)};if(We.size+P(U.id)>4096){Xn("Runtime node budget exhausted");return}var W="instance."+ ++Be;function O(B,k){var X,te,j=B.id===U.id?W:W+":"+B.id,ae=It(It({},B),{id:j,runtimeId:j,instanceId:W,prototypeId:B.id,prototype:!1,parentId:k,transform:Je([],Ne(B.transform),!1),spawnTime:ee});We.set(j,ae);try{for(var ce=ke(n.components.filter(function(Ae){return Ae.parentId===B.id})),we=ce.next();!we.done;we=ce.next()){var me=we.value;O(me,j)}}catch(Ae){X={error:Ae}}finally{try{we&&!we.done&&(te=ce.return)&&te.call(ce)}finally{if(X)throw X.error}}return ae}var J=O(U,void 0);return J.transform[4]=x,J.transform[5]=A,E&&(J.pathStartNode=E.startNode,J.pathTargetNode=E.targetNode,J.parentId=(R=n.gameplay.find(function(B){return B.id===E.networkBehaviorId}))===null||R===void 0?void 0:R.componentId),he.push(J),bl(J),zf(J),E&&So(0,!1),J}function Zg(c,x,A){var E,R,U,P,W,O,J,B,k,X,te,j,ae,ce,we,me,Ae,ye,ve,Ce,ue,Fe,Oe,Ue,Ze,gt,Ft,Ot,Ut,Xt,Bt,_t,Rt,At,ut;if(++$e>1024){Xn("Action budget exhausted");return}if(c.kind==="add"||c.kind==="set"){var Et=$[c.variableId],en=c.kind==="add"?Et+c.value:c.value;if(typeof en=="number"&&(!Number.isFinite(en)||Math.abs(en)>1e12)){Xn("Variable range exceeded");return}$[c.variableId]=en,Et!==en&&In({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="setAsset"&&((k=rt(c.componentId))===null||k===void 0?void 0:k.contract)==="native.mesh3d.v1"){var ot=rt(c.componentId),yn=(X=Ke.get(ot.id))!==null&&X!==void 0?X:{transform:Je([],Ne(ot.transform),!1),parameters:{}};((te=yn.slots)!==null&&te!==void 0?te:yn.slots={})[(j=c.slotId)!==null&&j!==void 0?j:"source"]=c.assetId,Ke.set(ot.id,yn)}else if(c.kind==="setComponent"||c.kind==="setAsset"){var ot=rt(c.componentId);if(!ot)return;var yn=(ae=Ke.get(ot.id))!==null&&ae!==void 0?ae:{transform:Je([],Ne(ot.transform),!1),parameters:{}};c.kind==="setComponent"?yn.parameters[c.key]=c.valueVariableId?$[c.valueVariableId]:c.value:yn.assetId=c.assetId,Ke.set(ot.id,yn),c.kind==="setComponent"&&c.key==="visible"&&c.value===!1&&(hn.release(ot.id),un.cancel(ot.id))}else if(c.kind==="resetMatch")Jc(c.componentId),za(c.componentId);else if(c.kind==="clearStrokes")(ce=Zn.get(c.componentId))===null||ce===void 0||ce.clear(),wt=wt.filter(function(er){return er.owner!==c.componentId});else if(c.kind==="resetMask"){var ot=rt(c.componentId),fn=ii("erase-mask",c.componentId);ot&&fn&&Va(ot,fn).reset()}else if(c.kind==="raycast3d")eu(c);else if(c.kind==="spawnAt3d")Il(c);else if(c.kind==="playModelAnimation")Nt?.playModelAnimation(c.componentId,c);else if(c.kind==="copyMatchAsset"){var Dn=(we=Wt.get(c.boardId))===null||we===void 0?void 0:we.snapshot().lastMatch,Jt=_.get(c.componentId),rn=Dn&&((Ae=(me=Qn.get(c.boardId))===null||me===void 0?void 0:me.get(Dn.group))===null||Ae===void 0?void 0:Ae.children.find(function(er){return er.contract==="native.image.v1"}));if(Dn&&rn){var dt=_.get(Dn.from),ct=oi(ui(dt),dt.parameters.width/2,dt.parameters.height/2),Bn=Jt.parentId?ui(_.get(Jt.parentId)):Ca(),ki=oi(Dr(Bn),ct.x,ct.y),Ti=(ye=Ke.get(Jt.id))!==null&&ye!==void 0?ye:{transform:Je([],Ne(Jt.transform),!1),parameters:{}};Ti.transform=Je([],Ne(Ti.transform),!1),Ti.transform[4]=ki.x-Jt.parameters.width/2,Ti.transform[5]=ki.y-Jt.parameters.height/2,Ti.assetId=(ve=rn.assetSlots[0])===null||ve===void 0?void 0:ve.assetId,Ke.set(Jt.id,Ti)}}else if(c.kind==="hintMatch")Ct=void 0,(Ce=Wt.get(c.componentId))===null||Ce===void 0||Ce.showHint();else if(c.kind==="spawn")Gf(c.prototypeId,c.x,c.y);else if(c.kind==="spawnAt"){var ln=(c.at==="self"||c.at==="midpoint")&&(x.selfInstanceId!==void 0||x.instanceId!==void 0)?rt((ue=x.selfInstanceId)!==null&&ue!==void 0?ue:x.instanceId):rs(c.targetComponentId,x,"self"),ri=(c.at==="other"||c.at==="midpoint")&&x.otherInstanceId!==void 0?rt(x.otherInstanceId):void 0,Jt=c.at==="other"?ri:ln;if(c.at==="pointer"||(c.at==="midpoint"?ln&&ri:Jt))for(var Mi=ln?Ui(ln):void 0,li=ri?Ui(ri):void 0,ct=c.at==="pointer"?bt:c.at==="midpoint"?{x:(Mi.x+li.x)/2,y:(Mi.y+li.y)/2}:Ui(Jt),Ln=_.get(c.prototypeId),zi=Math.max(0,Math.min(16,Math.floor(c.countVariableId?Number($[c.countVariableId]):(Fe=c.count)!==null&&Fe!==void 0?Fe:1))),vr=0;vr<zi;vr++){var gr=c.jitterX?(Vn.rng.next()*2-1)*c.jitterX:0,Gi=c.jitterY?(Vn.rng.next()*2-1)*c.jitterY:0;Gf(c.prototypeId,ct.x+c.offsetX+gr-Ln.parameters.width/2,ct.y+c.offsetY+Gi-Ln.parameters.height/2)}}else if(c.kind==="random"){var Et=$[c.variableId],en=Vn.rng.between(c.min,c.max,c.integer===!0);$[c.variableId]=en,Et!==en&&In({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="modifyInstanceState"){var ot=c.target==="component"?rt(c.componentId):rs(c.componentId,x,c.target);ot&&Zc(ot,c.field,c.op,c.variableId?$[c.variableId]:c.value)}else if(c.kind==="launchToward"){var dt=_.get(c.componentId),$n=Bi(dt),ci=(Oe=x.selfInstanceId)!==null&&Oe!==void 0?Oe:x.instanceId,ot=dt.prototype?(Ue=$n.find(function($i){return $i.instanceId===ci||$i.id===ci}))!==null&&Ue!==void 0?Ue:$n[$n.length-1]:(Ze=rs(c.componentId,x,"self"))!==null&&Ze!==void 0?Ze:rt(c.componentId),fn=ii("physics-body",c.componentId),mn=ot&&as(ot,fn);if(!mn)return;var vi=void 0;if(c.targetMode==="angle-variable")vi=Number($[c.angleVariableId])*Math.PI/180;else{var Jt=lm(ot,c);if(!Jt)return;var ct=Ui(ot);vi=Math.atan2(Jt.y-ct.y,Jt.x-ct.x)}var Nn=Number(c.speedVariableId?$[c.speedVariableId]:c.speed);if(!Number.isFinite(Nn)){Xn("Launch speed invalid");return}mn.vx=Math.cos(vi)*Nn,mn.vy=Math.sin(vi)*Nn,mn.atRest=!1,mn.restElapsed=0,mn.captured=!1,mn.exited=!1,c.orientToVelocity!==!1&&ya(ot,vi),In(Qi("launch",ot))}else if(c.kind==="moveToComponent"){var yi=_.get(c.targetComponentId),ot=rs(c.componentId,x,(gt=c.target)!==null&>!==void 0?gt:"self"),Jt=yi&&Vr(yi)?(Ft=rs(c.targetComponentId,x,c.target==="other"?"self":"other"))!==null&&Ft!==void 0?Ft:Bi(yi)[0]:rt(c.targetComponentId);ot&&Jt&&$s(ot,Ui(Jt),c.seconds)}else if(c.kind==="returnToOrigin"){var ot=rs(c.componentId,x,"self"),sn=ot&&An.get(ot.id);ot&&sn&&$s(ot,sn,c.seconds)}else if(c.kind==="spawnOnPath")Gf(c.prototypeId,0,0,{startNode:c.startNode,targetNode:c.targetNode,networkBehaviorId:c.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(c.kind)){var Yn=_.get(c.componentId),Ai=x.instanceId?Je([],Ne(We.values()),!1).filter(function(xi){return xi.instanceId===x.instanceId&&xi.prototypeId===Yn.id}):Bi(Yn),fn=ii("physics-body",Yn.id);try{for(var yr=ke(Ai),Ar=yr.next();!Ar.done;Ar=yr.next()){var ot=Ar.value,mn=as(ot,fn);c.kind==="setVelocity"?(mn.vx=c.vxVariableId?$[c.vxVariableId]:c.vx,mn.vy=c.vyVariableId?$[c.vyVariableId]:c.vy):c.kind==="applyImpulse"?(mn.vx+=c.vxVariableId?$[c.vxVariableId]:c.ix,mn.vy+=c.vyVariableId?$[c.vyVariableId]:c.iy):(mn.vx=0,mn.vy=0,mn.atRest=!0),mn.captured=!1,mn.exited=!1,mn.restElapsed=0,c.kind!=="stopBody"&&(mn.atRest=!1)}}catch(xi){E={error:xi}}finally{try{Ar&&!Ar.done&&(R=yr.return)&&R.call(yr)}finally{if(E)throw E.error}}}else if(c.kind==="setPosition"){var Cr=_.get(c.componentId),Ai=x.instanceId?Je([],Ne(We.values()),!1).filter(function(tr){return tr.instanceId===x.instanceId&&tr.prototypeId===Cr.id}):Bi(Cr),fn=ii("physics-body",Cr.id);try{for(var xa=ke(Ai),ar=xa.next();!ar.done;ar=xa.next()){var ot=ar.value,mn=as(ot,fn);mn.x=c.xVariableId?$[c.xVariableId]:c.x,mn.y=c.yVariableId?$[c.yVariableId]:c.y,mn.vx=0,mn.vy=0,mn.captured=!1,mn.exited=!1,mn.atRest=!0,Hr(ot,mn.x,mn.y)}}catch(tr){U={error:tr}}finally{try{ar&&!ar.done&&(P=xa.return)&&P.call(xa)}finally{if(U)throw U.error}}}else if(c.kind==="setPathEdge")(Ot=Gn.get(c.behaviorId))===null||Ot===void 0||Ot.setEdge(c.edgeId,c.enabled,c.cost);else if(c.kind==="setPathGate")(Xt=Gn.get((Ut=n.gameplay.find(function(er){return er.id===c.behaviorId}))===null||Ut===void 0?void 0:Ut.parameters.networkBehaviorId))===null||Xt===void 0||Xt.setGate(c.behaviorId,c.mode,c.holdSeconds);else if(c.kind==="setPathTarget"){var Xr=_.get(c.componentId),fn=ii("path-agent",Xr.id),Yr=Gn.get(fn.parameters.networkBehaviorId);try{for(var Rr=ke(x.instanceId?Je([],Ne(We.values()),!1).filter(function(xi){return xi.instanceId===x.instanceId&&xi.prototypeId===Xr.id}):Bi(Xr)),qr=Rr.next();!qr.done;qr=Rr.next()){var ot=qr.value;ot.pathTargetNode=c.targetNode,Yr?.setTarget(ot.id,c.targetNode)}}catch(xi){W={error:xi}}finally{try{qr&&!qr.done&&(O=Rr.return)&&O.call(Rr)}finally{if(W)throw W.error}}}else if(c.kind==="compute"){var Fi=Number($[c.variableId]),Yi=c.operandVariableId!==void 0?Number($[c.operandVariableId]):c.value;if(["div","mod"].includes(c.op)&&Yi===0){Xn("Division by zero");return}var en={add:function(){return Fi+Yi},sub:function(){return Fi-Yi},mul:function(){return Fi*Yi},div:function(){return Yi===0?Fi:Fi/Yi},mod:function(){return Yi===0?Fi:Fi%Yi},min:function(){return Math.min(Fi,Yi)},max:function(){return Math.max(Fi,Yi)},set:function(){return Yi},floor:function(){return Math.floor(Fi)},ceil:function(){return Math.ceil(Fi)},abs:function(){return Math.abs(Fi)},clamp:function(){return Math.max(c.min,Math.min(c.max,Fi))}}[c.op]();if(c.round&&(en=Math.round(en)),!Number.isFinite(en)||Math.abs(en)>1e12){Xn("Variable range exceeded");return}var Et=$[c.variableId];$[c.variableId]=en,Et!==en&&In({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="despawn"){var ln=(Bt=x.selfInstanceId)!==null&&Bt!==void 0?Bt:x.instanceId;c.target==="other"?ca(x.otherInstanceId):c.target==="both"?(ca(ln),ca(x.otherInstanceId)):ca(ln)}else if(c.kind==="changeScene")c.delaySeconds>0?c.sceneId!==Y&&(K??(K={sceneId:c.sceneId,at:ee+c.delaySeconds})):Mn=c.sceneId;else if(c.kind==="restart")(_t=L?.notifyGameRetry)===null||_t===void 0||_t.call(L),Mn="__restart";else if(c.kind==="cameraShake")I?.matches||(qe={intensity:c.intensity,seconds:c.seconds,elapsed:0});else if(c.kind==="screenFlash")Xe.push({color:c.color,opacity:c.opacity,seconds:c.seconds,elapsed:0}),Xe.length>8&&Xe.shift();else if(c.kind==="floatingText"){var Oi=_.get(c.componentId),dt=x.instanceId?(Rt=Je([],Ne(We.values()),!1).find(function(tr){return tr.instanceId===x.instanceId&&tr.prototypeId===c.componentId}))!==null&&Rt!==void 0?Rt:Oi:(At=rt(c.componentId))!==null&&At!==void 0?At:Oi,Jt=dt?.sceneId===Y?dt:Oi;if(Jt){var ct=void 0;if(Jt.contract==="native.mesh3d.v1"&&(ct=Uf(Jt.id)),!ct){var xr=vt(Jt);ct=oi(ui(Jt),xr.width/2,xr.height/2)}Ie.push({x:ct.x,y:ct.y,text:c.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function($i,Pi){var Hi;return String((Hi=$[Pi])!==null&&Hi!==void 0?Hi:"")}),color:c.color,fontSize:c.fontSize,risePx:c.risePx,seconds:c.seconds,elapsed:0}),Ie.length>32&&Ie.shift()}}else if(c.kind==="store")x.kind==="click"&&x.pointerId!==void 0&&!Se&&(Se={pointerId:x.pointerId,targetId:x.targetId,condition:A},(ut=e.setPointerCapture)===null||ut===void 0||ut.call(e,x.pointerId));else if(c.behaviorId){var kn=n.gameplay.find(function(er){return er.id===c.behaviorId});if(c.kind==="playAudio")om(kn);else if(c.kind==="animate"){var ws=_.get(kn.componentId),Ai=Vr(ws)?Je([],Ne(We.values()),!1).filter(function(xi){return xi.prototypeId===ws.id&&(!x.instanceId||xi.instanceId===x.instanceId)}):[ws],ls=function(xi){var tr=kn.id+":"+xi.id;le=le.filter(function(Pi){return Pi.id!==tr});var $i=It({},kn.parameters);$i.fromCurrent&&($i.from=$i.property==="opacity"?vt(xi).opacity:Gr(xi)[$i.property==="x"?4:5]),le.push(It(It({},kn),{parameters:$i,id:tr,behaviorId:kn.id,targetId:xi.id,elapsed:0,baseTransform:Je([],Ne(xi.transform),!1)}))};try{for(var Ji=ke(Ai),Ri=Ji.next();!Ri.done;Ri=Ji.next()){var Jt=Ri.value;ls(Jt)}}catch(xi){J={error:xi}}finally{try{Ri&&!Ri.done&&(B=Ji.return)&&B.call(Ji)}finally{if(J)throw J.error}}}else c.kind==="stopAnimation"?le=le.filter(function(er){return er.behaviorId!==kn.id}):c.kind==="emit"&&Jg(kn,x)}}function Jg(c,x){var A,E,R,U,P,W,O,J,B,k=c.parameters,X=k.shape==="pixel-confetti",te=k.shape==="confetti",j=X||te;if(!(j&&I?.matches)){if(pe.length+k.count>256){Xn("Particle budget exhausted");return}if(X&&k.coverage==="screen"){pe.push.apply(pe,Je([],Ne(Tg(k)),!1));return}if(te&&k.coverage==="screen"){pe.push.apply(pe,Je([],Ne(Eg(k)),!1));return}var ae=_.get(c.componentId),ce=x.instanceId&&(A=Je([],Ne(We.values()),!1).find(function(Xt){return Xt.instanceId===x.instanceId&&Xt.prototypeId===ae.id}))!==null&&A!==void 0?A:ae;if(k.origin==="contact-3d"){if(I?.matches)return;var we=ss(ce);if(!we)return;for(var me=xg(ce,rt,vt,Ee),Ae=[k.color,k.color2,k.color3].filter(Boolean),ye=yu(gu(ce.id+":"+ee.toFixed(3))),ve=((E=k.spread)!==null&&E!==void 0?E:360)*Math.PI/180,Ce=((R=k.direction)!==null&&R!==void 0?R:-90)*Math.PI/180,ue=0;ue<k.count;ue++){var Fe=Ce+ve*(ye.next()-.5),Oe=k.speed/100*ye.between(.42,1.1);pe.push(It(It({},me),{stageId:we.id,shape:"contact-3d",confetti:te,age:0,vx:Math.cos(Fe)*Oe,vy:ye.between(.55,.95)*Oe,vz:Math.sin(Fe)*Oe,life:((U=k.lifetime)!==null&&U!==void 0?U:.5)*ye.between(.7,1),gravity:((P=k.gravity)!==null&&P!==void 0?P:300)/100,color:Ae[ue%Ae.length],size:ye.between(.024,.058),spinX:ye.between(-13,13),spinZ:ye.between(-17,17)}))}return}for(var Ue=Gr(ce),Ze,gt=rt(ce.parentId);gt;gt=rt(gt.parentId)){if(j&>.contract==="native.group.v1"&&vt(gt).clip){Ze=gt.id;break}Ue=Io(Gr(gt),Ue)}var Ft=vt(ce),Ot=k.origin==="anchor"?oi(Ue,0,0):j||k.origin==="center"?oi(Ue,Ft.width/2,Ft.height/2):{x:Ue[4]+ce.parameters.width/2,y:Ue[5]+ce.parameters.height/2};if(X){pe.push.apply(pe,Je([],Ne($p(k,Ot,Ze)),!1));return}if(te){pe.push.apply(pe,Je([],Ne(Kp(k,Ot,Ze)),!1));return}for(var Ut=yu(gu(ce.id+":"+ee.toFixed(3))),ue=0;ue<k.count;ue++){var Fe=-Math.PI/2+((ue+Ut.next())/k.count-.5)*((W=k.spread)!==null&&W!==void 0?W:360)*Math.PI/180,Oe=k.speed*Ut.between(.5,.95);pe.push(It(It({},Ot),{vx:Math.cos(Fe)*Oe,vy:Math.sin(Fe)*Oe,life:(O=k.lifetime)!==null&&O!==void 0?O:.7,gravity:(J=k.gravity)!==null&&J!==void 0?J:250,color:k.color,shape:(B=k.shape)!==null&&B!==void 0?B:"circle"}))}}}function cm(c){var x,A;if(c==="__restart"){Ff();return}if(c!==Y){K=void 0;var E=Y;Rn(),Y=c,Me.clear(),hn.clear(),An.clear(),Fn.clear(),jn.clear(),Zn.clear(),wt=[],kt=[],C.clear(),re.clear(),Ct=void 0,he=[],pe=[],Ie=[],Xe=[],qe=void 0,Pe=!1,lt=0,We.clear(),Tn.clear(),Hn.clear(),Ee.clear(),nn.clear(),jt.clear(),Sn.clear(),pn.clear(),xn.clear(),Js=0,Nt?.reset(),Cn.clear(),Wn.clear(),ie=void 0,Qc(),Te=Te.filter(function(W){return W.kind==="variableChange"}),Ke.clear(),Kt=void 0;try{for(var R=ke(Wt.values()),U=R.next();!U.done;U=R.next()){var P=U.value;P.reset()}}catch(W){x={error:W}}finally{try{U&&!U.done&&(A=R.return)&&A.call(R)}finally{if(x)throw x.error}}De.clear(),oe.clear(),fe.clear(),le=[],ea(),H.clear(),on=void 0,de=void 0,ti(),os(),So(0,!1),zf(),Tl(0),In({kind:"sceneExit",sceneId:E}),In({kind:"sceneEnter",sceneId:Y})}}function Aa(){for(var c=function(){var x,A,E,R,U=Te.shift();Ge++;var P=function(j){return j===void 0||!!rt(j)||Je([],Ne(We.values()),!1).some(function(ae){return ae.instanceId===j})};if(!P(U.selfInstanceId)||!P(U.otherInstanceId)||["contactBegin","boundaryExit"].includes(U.kind)&&U.instanceId&&!We.has(U.instanceId))return"continue";try{for(var W=(x=void 0,ke(n.eventBindings)),O=W.next();!O.done;O=W.next()){var J=O.value;if(Object.entries(V.get(J.eventId)).every(function(j){var ae=Ne(j,2),ce=ae[0],we=ae[1];return ce==="id"||U[ce]===we})&&qs(J.condition,U)){try{for(var B=(E=void 0,ke(J.actions)),k=B.next();!k.done;k=B.next()){var X=k.value;if($e>=1024||mt)break;Zg(X,U,J.condition)}}catch(j){E={error:j}}finally{try{k&&!k.done&&(R=B.return)&&R.call(B)}finally{if(E)throw E.error}}if(Mn)break}}}catch(j){x={error:j}}finally{try{O&&!O.done&&(A=W.return)&&A.call(W)}finally{if(x)throw x.error}}if(Mn){var te=Mn;Mn=void 0,cm(te)}};Te.length&&!mt&&Ge<256&&$e<1024;)c();Te.length&&Xn("Event/action budget exhausted")}function ui(c){return Io(c.parentId?ui(rt(c.parentId)):Ca(),Gr(c))}var oi=function(c,x,A){return{x:c[0]*x+c[2]*A+c[4],y:c[1]*x+c[3]*A+c[5]}};function mr(c,x){var A=vt(c),E=[[0,0],[A.width,0],[A.width,A.height],[0,A.height]].map(function(R){var U=Ne(R,2),P=U[0],W=U[1];return oi(x,P,W)});return{left:Math.min.apply(Math,Je([],Ne(E.map(function(R){return R.x})),!1)),right:Math.max.apply(Math,Je([],Ne(E.map(function(R){return R.x})),!1)),top:Math.min.apply(Math,Je([],Ne(E.map(function(R){return R.y})),!1)),bottom:Math.max.apply(Math,Je([],Ne(E.map(function(R){return R.y})),!1))}}function wi(c){return vt(c).visible&&vt(c).opacity>0&&(!c.parentId||wi(rt(c.parentId)))}function um(c,x){for(var A=vt(c),E=ui(c),R=Math.min(A.width,A.height)/2,U=x==="circle"?Array.from({length:32},function(O,J){return oi(E,A.width/2+Math.cos(J*Math.PI/16)*R,A.height/2+Math.sin(J*Math.PI/16)*R)}):[[0,0],[A.width,0],[A.width,A.height],[0,A.height]].map(function(O){var J=Ne(O,2),B=J[0],k=J[1];return oi(E,B,k)}),P=c.parentId?rt(c.parentId):void 0,W=function(){var O=vt(P);if(P.contract==="native.group.v1"&&O.clip){for(var J=ui(P),B=[[0,0],[O.width,0],[O.width,O.height],[0,O.height]].map(function(ae){var ce=Ne(ae,2),we=ce[0],me=ce[1];return oi(J,we,me)}),k=0,X=0;X<4;X++)k+=B[X].x*B[(X+1)%4].y-B[(X+1)%4].x*B[X].y;for(var te=k>=0?1:-1,j=function(ae){var ce,we,me=B[ae],Ae=B[(ae+1)%4],ye=function(Ft){return te*((Ae.x-me.x)*(Ft.y-me.y)-(Ae.y-me.y)*(Ft.x-me.x))},ve=U;U=[];var Ce=ve[ve.length-1],ue=ye(Ce);try{for(var Fe=(ce=void 0,ke(ve)),Oe=Fe.next();!Oe.done;Oe=Fe.next()){var Ue=Oe.value,Ze=ye(Ue);if(Ze>=0!=ue>=0){var gt=ue/(ue-Ze);U.push({x:Ce.x+(Ue.x-Ce.x)*gt,y:Ce.y+(Ue.y-Ce.y)*gt})}Ze>=0&&U.push(Ue),Ce=Ue,ue=Ze}}catch(Ft){ce={error:Ft}}finally{try{Oe&&!Oe.done&&(we=Fe.return)&&we.call(Fe)}finally{if(ce)throw ce.error}}},X=0;X<4&&U.length;X++)j(X)}P=P.parentId?rt(P.parentId):void 0};P;)W();return U}function $g(c,x){var A,E,R,U,P,W;if(c.length<3||x.length<3)return!1;try{for(var O=ke([c,x]),J=O.next();!J.done;J=O.next())for(var B=J.value,k=0;k<B.length;k++){var X=B[k],te=B[(k+1)%B.length],j=X.y-te.y,ae=te.x-X.x,ce=1/0,we=-1/0,me=1/0,Ae=-1/0;try{for(var ye=(R=void 0,ke(c)),ve=ye.next();!ve.done;ve=ye.next()){var Ce=ve.value,ue=Ce.x*j+Ce.y*ae;ce=Math.min(ce,ue),we=Math.max(we,ue)}}catch(Ue){R={error:Ue}}finally{try{ve&&!ve.done&&(U=ye.return)&&U.call(ye)}finally{if(R)throw R.error}}try{for(var Fe=(P=void 0,ke(x)),Oe=Fe.next();!Oe.done;Oe=Fe.next()){var Ce=Oe.value,ue=Ce.x*j+Ce.y*ae;me=Math.min(me,ue),Ae=Math.max(Ae,ue)}}catch(Ue){P={error:Ue}}finally{try{Oe&&!Oe.done&&(W=Fe.return)&&W.call(Fe)}finally{if(P)throw P.error}}if(we<me||Ae<ce)return!1}}catch(Ue){A={error:Ue}}finally{try{J&&!J.done&&(E=O.return)&&E.call(O)}finally{if(A)throw A.error}}return!0}function Kg(c){var x,A,E,R,U=T();try{for(var P=ke(Me.values()),W=P.next();!W.done;W=P.next()){var O=W.value,J=O.behavior.parameters;if(!(!J.moveComponentId||O.magnitude<=0)){var B=rt(J.moveComponentId);if(!(!B||!wi(B))){var k=(E=J.moveSpeed)!==null&&E!==void 0?E:220,X=ii("physics-body",(R=B.prototypeId)!==null&&R!==void 0?R:B.id);if(X&&X.parameters.mode==="dynamic"){var te=as(B,X);te.vx=O.nx*k,te.vy=O.ny*k,te.atRest=!1,te.restElapsed=0}else{var j=Ui(B),ae=vt(B),ce=j.x+O.nx*k*c,we=j.y+O.ny*k*c;dm(B)||(ce=Math.max(ae.width/2,Math.min(U.width-ae.width/2,ce)),we=Math.max(ae.height/2,Math.min(U.height-ae.height/2,we))),Hr(B,ce,we)}J.orientToMove&&ya(B,Math.atan2(O.ny,O.nx))}}}}catch(me){x={error:me}}finally{try{W&&!W.done&&(A=P.return)&&A.call(P)}finally{if(x)throw x.error}}}function Qg(c){var x,A,E,R,U,P,W,O,J,B,k,X,te,j,ae,ce,we,me,Ae,ye,ve,Ce,ue,Fe,Oe,Ue,Ze,gt,Ft,Ot,Ut,Xt,Bt=T();ee+=c,K&&ee>=K.at&&cm(K.sceneId),fy(c),Yg(c),Kg(c),qg(c),Pf();try{for(var _t=ke(Pt),Rt=_t.next();!Rt.done;Rt=_t.next()){var At=Ne(Rt.value,2),ut=At[0],Et=At[1];!Et.held&&ee-((ue=Et.releasedAt)!==null&&ue!==void 0?ue:ee)>=Et.behavior.springBackSeconds&&Pt.delete(ut)}}catch(_n){x={error:_n}}finally{try{Rt&&!Rt.done&&(A=_t.return)&&A.call(_t)}finally{if(x)throw x.error}}qe&&(qe.elapsed+=c,qe.elapsed>=qe.seconds&&(qe=void 0));try{for(var en=ke(Xe),ot=en.next();!ot.done;ot=en.next()){var yn=ot.value;yn.elapsed+=c}}catch(_n){E={error:_n}}finally{try{ot&&!ot.done&&(R=en.return)&&R.call(en)}finally{if(E)throw E.error}}Xe=Xe.filter(function(_n){return _n.elapsed<_n.seconds});try{for(var fn=ke(Ie),Dn=fn.next();!Dn.done;Dn=fn.next()){var Jt=Dn.value;Jt.elapsed+=c}}catch(_n){U={error:_n}}finally{try{Dn&&!Dn.done&&(P=fn.return)&&P.call(fn)}finally{if(U)throw U.error}}Ie=Ie.filter(function(_n){return _n.elapsed<_n.seconds});try{for(var rn=ke(Wt),dt=rn.next();!dt.done;dt=rn.next()){var ct=Ne(dt.value,2),ut=ct[0],Bn=ct[1];_.get(ut).sceneId===Y&&wi(_.get(ut))&&Bn.tick(c)}}catch(_n){W={error:_n}}finally{try{dt&&!dt.done&&(O=rn.return)&&O.call(rn)}finally{if(W)throw W.error}}var ki=function(_n){var Di,_r,Wi=_.get(_n.componentId);if(Wi.sceneId!==Y)return"continue";var Pr=Vr(Wi)?Je([],Ne(We.values()),!1).filter(function(us){return us.prototypeId===Wi.id}):[Wi];try{for(var sr=(Di=void 0,ke(Pr)),Er=sr.next();!Er.done;Er=sr.next()){var Mr=Er.value,Lr=_n.id+":"+Mr.id;if(_n.kind==="motion"){var _a=(Fe=Ke.get(Mr.id))!==null&&Fe!==void 0?Fe:{transform:Je([],Ne(Mr.transform),!1),parameters:{}},Ki=(Oe=_a.velocity)!==null&&Oe!==void 0?Oe:{x:_n.parameters.vx,y:_n.parameters.vy};Ki.y+=_n.parameters.gravity*c,_a.transform[4]+=Ki.x*c,_a.transform[5]+=Ki.y*c,_a.velocity=Ki,Ke.set(Mr.id,_a),Mr.prototypeId&&(Mr.transform=_a.transform);var Ga=ui(Mr);(Ga[5]>Bt.height||Ga[4]<-300||Ga[4]>Bt.width+300)&&(_a.exited||(_a.exited=!0,In({kind:"boundaryExit",componentId:Wi.id,instanceId:Mr.instanceId})))}else if(_n.kind==="timer"){var cs=((Ue=fe.get(Lr))!==null&&Ue!==void 0?Ue:0)+c;fe.set(Lr,cs),cs>=_n.parameters.seconds&&cs-c<_n.parameters.seconds&&(In(It({kind:"timer",behaviorId:_n.id,componentId:Wi.id},Mr.instanceId?{instanceId:Mr.instanceId,selfInstanceId:Mr.instanceId}:{})),_n.parameters.repeat&&fe.set(Lr,cs-_n.parameters.seconds))}}}catch(us){Di={error:us}}finally{try{Er&&!Er.done&&(_r=sr.return)&&_r.call(sr)}finally{if(Di)throw Di.error}}};try{for(var Ti=ke(n.gameplay),ln=Ti.next();!ln.done;ln=Ti.next()){var ri=ln.value;ki(ri)}}catch(_n){J={error:_n}}finally{try{ln&&!ln.done&&(B=Ti.return)&&B.call(Ti)}finally{if(J)throw J.error}}Kc(c),bo(c),So(c),Tl(c);var Mi=[],li=function(_n){var Di,_r,Wi=_.get(_n.componentId);if(Wi.sceneId!==Y)return"continue";try{for(var Pr=(Di=void 0,ke(Vr(Wi)?Je([],Ne(We.values()),!1).filter(function(Mr){return Mr.prototypeId===Wi.id}):[Wi])),sr=Pr.next();!sr.done;sr=Pr.next()){var Er=sr.value;if(wi(Er)){if(Mi.length>=256){Xn("Collider budget exhausted");break}Mi.push({b:_n,c:Er,box:mr(Er,ui(Er)),polygon:um(Er,_n.parameters.shape)})}}}catch(Mr){Di={error:Mr}}finally{try{sr&&!sr.done&&(_r=Pr.return)&&_r.call(Pr)}finally{if(Di)throw Di.error}}};try{for(var Ln=ke(n.gameplay.filter(function(_n){return _n.kind==="collider"})),zi=Ln.next();!zi.done;zi=Ln.next()){var ri=zi.value;li(ri)}}catch(_n){k={error:_n}}finally{try{zi&&!zi.done&&(X=Ln.return)&&X.call(Ln)}finally{if(k)throw k.error}}var vr=new Set,gr=new Map,Gi=function(_n,Di,_r){var Wi,Pr,sr;((Wi=Di.c.prototypeId)!==null&&Wi!==void 0?Wi:Di.c.id)===((Pr=_r.c.prototypeId)!==null&&Pr!==void 0?Pr:_r.c.id)&&Di.c.id>_r.c.id||In(It(It({},Qi(_n,Di.c,_r.c)),{instanceId:(sr=Di.c.instanceId)!==null&&sr!==void 0?sr:_r.c.instanceId}))},$n=0;e:for(var ci=0;ci<Mi.length;ci++)for(var ri=ci+1;ri<Mi.length;ri++){var mn=Mi[ci],vi=Mi[ri];if(!(mn.c.instanceId&&mn.c.instanceId===vi.c.instanceId)){var Nn=mn.box,yi=vi.box,sn=Nn.left<yi.right&&Nn.right>yi.left&&Nn.top<yi.bottom&&Nn.bottom>yi.top;if(sn){if(++$n>4096){Xn("Collision budget exhausted");break e}sn=$g(mn.polygon,vi.polygon)}if(sn){var Yn=[mn.c.id,vi.c.id].sort().join("|");if(vr.add(Yn),gr.set(Yn,[mn,vi]),!De.has(Yn))try{for(var Ai=(te=void 0,ke([[mn,vi],[vi,mn]])),yr=Ai.next();!yr.done;yr=Ai.next()){var Ar=Ne(yr.value,2),Cr=Ar[0],xa=Ar[1];Gi("contactBegin",Cr,xa)}}catch(Di){te={error:Di}}finally{try{yr&&!yr.done&&(j=Ai.return)&&j.call(Ai)}finally{if(te)throw te.error}}}}}try{for(var ar=ke(oe),Xr=ar.next();!Xr.done;Xr=ar.next()){var Yr=Ne(Xr.value,2),Yn=Yr[0],Rr=Ne(Yr[1],2),mn=Rr[0],vi=Rr[1];if(!vr.has(Yn))try{for(var qr=(we=void 0,ke([[mn,vi],[vi,mn]])),Fi=qr.next();!Fi.done;Fi=qr.next()){var Yi=Ne(Fi.value,2),Cr=Yi[0],xa=Yi[1];Gi("contactEnd",Cr,xa)}}catch(Wi){we={error:Wi}}finally{try{Fi&&!Fi.done&&(me=qr.return)&&me.call(qr)}finally{if(we)throw we.error}}}}catch(_n){ae={error:_n}}finally{try{Xr&&!Xr.done&&(ce=ar.return)&&ce.call(ar)}finally{if(ae)throw ae.error}}De=vr,oe=gr;try{for(var Oi=ke(le),xr=Oi.next();!xr.done;xr=Oi.next()){var ci=xr.value;ci.elapsed+=c;var kn=ci.parameters,ws=(Ze=kn.delay)!==null&&Ze!==void 0?Ze:0,ls=ci.elapsed-ws;if(!(ls<0)){var Ji=ls/kn.seconds,Ri=kn.loop?Ji%1:Math.min(1,Ji),er=(gt=kn.easing)!==null&>!==void 0?gt:"ease-out",xi=Ri;kn.loop&&er==="ease-in-out"?xi=.5-.5*Math.cos(Ri*Math.PI*2):er==="ease-out"?xi=1-Math.pow(1-Ri,3):er==="ease-in"?xi=Math.pow(Ri,3):er==="ease-in-out"?xi=Ri<.5?4*Math.pow(Ri,3):1-Math.pow(-2*Ri+2,3)/2:er==="back-out"&&(xi=1+2.70158*Math.pow(Ri-1,3)+1.70158*Math.pow(Ri-1,2));var tr=kn.from+(kn.to-kn.from)*xi,$i=rt((Ft=ci.targetId)!==null&&Ft!==void 0?Ft:ci.componentId);if($i){var Pi=(Ot=Ke.get($i.id))!==null&&Ot!==void 0?Ot:{transform:Je([],Ne($i.transform),!1),parameters:{}},Hi=(Ut=ci.baseTransform)!==null&&Ut!==void 0?Ut:$i.transform;if(kn.property==="opacity")Pi.parameters.opacity=Math.max(0,Math.min(1,tr));else if(["scale","scaleX","scaleY","rotation"].includes(kn.property)){(Xt=Pi.animationAxes)!==null&&Xt!==void 0||(Pi.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),Pi.animationAxes[kn.property]=tr;var ni=Pi.animationAxes,di=ni.rotation*Math.PI/180,Qs=Math.cos(di),js=Math.sin(di),Ts=ni.scale*ni.scaleX,As=ni.scale*ni.scaleY;Pi.transform[0]=(Hi[0]*Qs+Hi[2]*js)*Ts,Pi.transform[1]=(Hi[1]*Qs+Hi[3]*js)*Ts,Pi.transform[2]=(-Hi[0]*js+Hi[2]*Qs)*As,Pi.transform[3]=(-Hi[1]*js+Hi[3]*Qs)*As}else Pi.transform[kn.property==="x"?4:5]=tr;Ke.set($i.id,Pi),kn.loop&&ls>=kn.seconds&&(ci.elapsed=ws+ls%kn.seconds)}}}}catch(_n){Ae={error:_n}}finally{try{xr&&!xr.done&&(ye=Oi.return)&&ye.call(Oi)}finally{if(Ae)throw Ae.error}}le=le.filter(function(_n){var Di,_r;return rt((Di=_n.targetId)!==null&&Di!==void 0?Di:_n.componentId)&&(_n.elapsed<_n.parameters.seconds+((_r=_n.parameters.delay)!==null&&_r!==void 0?_r:0)||_n.parameters.loop)});try{for(var Ao=ke(pe),Es=Ao.next();!Es.done;Es=Ao.next()){var kn=Es.value;if(kn.age!==void 0){kn.age+=c;continue}kn.life-=c,kn.x+=kn.vx*c,kn.y+=kn.vy*c,kn.vy+=kn.gravity*c}}catch(_n){ve={error:_n}}finally{try{Es&&!Es.done&&(Ce=Ao.return)&&Ce.call(Ao)}finally{if(ve)throw ve.error}}pe=pe.filter(function(_n){var Di;return _n.life>((Di=_n.age)!==null&&Di!==void 0?Di:0)}),Aa()}function tu(c,x){var A,E,R;if(p.beginPath(),c.contract==="native.ellipse.v1")p.ellipse(x.width/2,x.height/2,x.width/2,x.height/2,0,0,Math.PI*2);else if(c.contract==="native.path.v1"){var U=function(X,te){({M:function(){return p.moveTo.apply(p,Je([],Ne(te),!1))},L:function(){return p.lineTo.apply(p,Je([],Ne(te),!1))},C:function(){return p.bezierCurveTo.apply(p,Je([],Ne(te),!1))},Q:function(){return p.quadraticCurveTo.apply(p,Je([],Ne(te),!1))},Z:function(){return p.closePath()}})[X]()};try{for(var P=ke(x.commands),W=P.next();!W.done;W=P.next()){var O=Ne(W.value),J=O[0],B=O.slice(1);U(J,B)}}catch(X){A={error:X}}finally{try{W&&!W.done&&(E=P.return)&&E.call(P)}finally{if(A)throw A.error}}}else{var k=Math.min((R=x.radius)!==null&&R!==void 0?R:0,x.width/2,x.height/2);typeof p.roundRect=="function"?p.roundRect(0,0,x.width,x.height,k):(p.moveTo(k,0),p.arcTo(x.width,0,x.width,x.height,k),p.arcTo(x.width,x.height,0,x.height,k),p.arcTo(0,x.height,0,0,k),p.arcTo(0,0,x.width,0,k),p.closePath())}}function jg(c,x,A){var E,R,U,P=(E=Ke.get(c.id))===null||E===void 0?void 0:E.pathFrame;if(P!==void 0)return Math.min(x.frameCount-1,P);if(f||!x.frameRate)return 0;if(c.contract!=="native.walk-sprite.v1")return Math.floor(Math.max(0,ee-((R=c.spawnTime)!==null&&R!==void 0?R:0))*x.frameRate)%x.frameCount;var W=(U=c.runtimeId)!==null&&U!==void 0?U:c.id,O=ze.get(W);if(!O)return ze.set(W,{x:A[4],y:A[5],phase:0,lastMove:-1/0,frame:0}),0;var J=Math.hypot(A[4]-O.x,A[5]-O.y)>.3;if(J){var B=ee-O.lastMove;O.phase=Number.isFinite(B)&&B<.25?O.phase+Math.min(B,.12)*x.frameRate:0,O.lastMove=ee}return O.x=A[4],O.y=A[5],ee-O.lastMove>.11&&(O.phase=0),O.frame=Math.floor(O.phase)%x.frameCount,O.frame}var Rl=!1,To={width:390,height:700},pi,Hf=new Set;function nu(c){var x,A;c!==Rl&&(c?(p.save(),p.beginPath(),p.rect((x=To.left)!==null&&x!==void 0?x:0,(A=To.top)!==null&&A!==void 0?A:0,To.width,To.height),p.clip(),Rl=!0):(p.restore(),Rl=!1))}function Ks(c,x,A,E,R){var U,P,W,O,J,B,k,X,te,j,ae,ce,we,me,Ae,ye,ve,Ce;if(x===void 0&&(x=Ca()),A===void 0&&(A=[]),R===void 0&&(R=!1),c.contract!=="native.mesh3d.v1"){var ue=vt(c),Fe=ii("erase-mask",(ae=c.prototypeId)!==null&&ae!==void 0?ae:c.id);if(!(!ue.visible||ue.opacity<=0)){var Oe=Io(x,Gr(c));if(Hf.has(c.id)){ne.push({c,m:Oe,clips:A,instance:E??c.prototypeId});try{for(var Ue=ke(Ms(c.id)),Ze=Ue.next();!Ze.done;Ze=Ue.next()){var gt=Ze.value;Ks(gt,Oe,A,E??c.prototypeId,!0)}}catch(Ai){U={error:Ai}}finally{try{Ze&&!Ze.done&&(P=Ue.return)&&P.call(Ue)}finally{if(U)throw U.error}}return}if(c.contract==="native.stage3d.v1"&&Nt&&pi&&xt.has(c.id)){nu(!1);var Ft=Nt.renderStage(c,p,pi.pw,pi.ph,pi.w,pi.h,{time:ee,ambientTime:be,propsOf:vt,bodies3d:Ee,fpsPose:xn.get(c.id),instances3d:na(c.id),contactParticles:I?.matches?[]:pe.filter(function(Ai){return Ai.stageId===c.id}),aimLocked:!!Vt,groundFn:Cs,worldWidth:pi.w,worldHeight:pi.h,designHeight:T().height,drawX:pi.x,drawY:pi.y,fullBleed:!0});try{for(var Ot=ke(Ee),Ut=Ot.next();!Ut.done;Ut=Ot.next()){var Xt=Ne(Ut.value,2),Bt=Xt[0],_t=Xt[1];if(_t.stageId===c.id&&_t.mode==="dynamic"){var Rt=Ft.project({x:_t.x,y:_t.y,z:_t.z},pi.w,pi.h);jt.set(Bt,{x:pi.x+Rt.x,y:pi.y+Rt.y})}}}catch(Ai){W={error:Ai}}finally{try{Ut&&!Ut.done&&(O=Ot.return)&&O.call(Ot)}finally{if(W)throw W.error}}ne.push({c,m:Oe,clips:A,instance:E??c.prototypeId});try{for(var At=ke(Ms(c.id)),ut=At.next();!ut.done;ut=At.next()){var gt=ut.value;Ks(gt,Oe,A,E??c.prototypeId,!0)}}catch(Ai){J={error:Ai}}finally{try{ut&&!ut.done&&(B=At.return)&&B.call(At)}finally{if(J)throw J.error}}return}Rl||nu(!0);var Et=pn.get((ce=c.runtimeId)!==null&&ce!==void 0?ce:c.id);Et?.showHighlight&&(p.save(),!R&&c.parentId&&p.transform.apply(p,Je([],Ne(Dr(x)),!1)),Nf(Et),p.restore()),p.save(),p.transform.apply(p,Je([],Ne(R?Oe:Gr(c)),!1)),p.globalAlpha*=ue.opacity;var en=Pt.get(c.id);en?.behavior.liftShadow&&(p.shadowColor="#00000055",p.shadowBlur=8,p.shadowOffsetY=4);var ot=A;c.contract==="native.group.v1"&&ue.clip&&(p.beginPath(),p.rect(0,0,ue.width,ue.height),p.clip(),ot=Je(Je([],Ne(A),!1),[{matrix:Oe,width:ue.width,height:ue.height}],!1));var yn=!1;if(!["native.group.v1","native.text.v1","native.image.v1","native.sprite.v1","native.walk-sprite.v1","native.stage3d.v1","native.mesh3d.v1"].includes(c.contract)){var fn=c.contract==="native.button.v1",Dn=on===c.id,Jt=fn?ue.enabled?Dn?ue.pressedFill:Dt===c.id?ue.hoverFill:ue.fill:ue.disabledFill:ue.fill;if(fn&&(ue.presentation==="pixel-cta"||ue.presentation==="shiny-cta")){var rn=(we=Q.get(c.id))!==null&&we!==void 0?we:be;H.set(c.id,rn);var dt=!f&&!I?.matches?be-rn:-1;ue.presentation==="shiny-cta"?Rg(p,ue,Jt,Dn,dt):Cg(p,ue,Jt,Dn,dt)}else ue.pixelFrame&&(p.save(),p.translate(3,4),tu(c,ue),p.fillStyle="#3c293366",p.fill(),p.restore()),tu(c,ue),Fe?(p.save(),p.clip(),Va(c,Fe).render(p),p.restore(),yn=!0,tu(c,ue)):(p.fillStyle=Jt,p.fill()),ue.pixelFrame&&!(ue.radius>0)&&(p.fillStyle="#ffffff22",p.fillRect(2,2,Math.max(0,ue.width-4),2),p.fillRect(2,2,2,Math.max(0,ue.height-4))),ue.strokeWidth&&(p.strokeStyle=ue.stroke,p.lineWidth=ue.strokeWidth,p.stroke());Ct===c.id&&(tu(c,ue),p.strokeStyle="#ffffff",p.lineWidth=5,p.stroke())}var ct,Bn;if(c.contract==="native.text.v1"){var ki=Bn=ue.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Ai,yr){var Ar;return String((Ar=$[yr])!==null&&Ar!==void 0?Ar:"")});ue.pixelPanel&&(p.fillStyle="#3c293366",p.fillRect(3,4,ue.width,ue.height),p.fillStyle=ue.panelFill,p.fillRect(0,0,ue.width,ue.height),p.strokeStyle=(me=ue.panelStroke)!==null&&me!==void 0?me:ue.color,p.lineWidth=2,p.strokeRect(1,1,ue.width-2,ue.height-2),p.fillStyle="#ffffff22",p.fillRect(3,3,Math.max(0,ue.width-6),2));var Ti=ue.fontFamily==="pixel"?qp(ki,ue):void 0;Ti&&!Ti.unsupportedChars.length?ct=wg(p,ki,ue):ct=y1(p,ki,Ti?It(It({},ue),{fontFamily:"sans-serif",fontWeight:"700"}):ue,n.creativeBrief.language)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(c.contract)&&!Fe){var ln=D.get(Z((ye=(Ae=Ke.get(c.id))===null||Ae===void 0?void 0:Ae.assetId)!==null&&ye!==void 0?ye:(ve=c.assetSlots[0])===null||ve===void 0?void 0:ve.assetId));if(ln?.complete&&ln.naturalWidth){p.save(),p.beginPath(),p.rect(0,0,ue.width,ue.height),p.clip();var ri=c.contract!=="native.image.v1",Mi=ri?Math.min(ue.frameColumns,ue.frameCount):1,li=ri?Math.ceil(ue.frameCount/Mi):1,Ln=ln.width/Mi,zi=ln.height/li,vr=ri?jg(c,ue,Oe):0,gr=vr%Mi*Ln,Gi=Math.floor(vr/Mi)*zi,$n=ue.fit==="cover"?Math.max(ue.width/Ln,ue.height/zi):Math.min(ue.width/Ln,ue.height/zi),ci=ue.fit==="stretch"?ue.width:Ln*$n,mn=ue.fit==="stretch"?ue.height:zi*$n;p.imageSmoothingEnabled=(Ce=ue.smoothing)!==null&&Ce!==void 0?Ce:!0,p.drawImage(ln,gr,Gi,Ln,zi,(ue.width-ci)/2,(ue.height-mn)/2,ci,mn),p.restore()}}if(Fe&&!yn&&Va(c,Fe).render(p),c.contract==="native.stage3d.v1"&&Nt&&!xt.has(c.id)){var gr=Math.hypot(Oe[0],Oe[1]),Gi=Math.hypot(Oe[2],Oe[3]),Ft=Nt.renderStage(c,p,ue.width*gr*_e*tt,ue.height*Gi*_e*tt,ue.width,ue.height,{time:ee,ambientTime:be,propsOf:vt,bodies3d:Ee,fpsPose:xn.get(c.id),instances3d:na(c.id),contactParticles:I?.matches?[]:pe.filter(function(Cr){return Cr.stageId===c.id}),aimLocked:!!Vt,groundFn:Cs,worldWidth:ue.width*gr,worldHeight:ue.height*Gi});try{for(var vi=ke(Ee),Nn=vi.next();!Nn.done;Nn=vi.next()){var yi=Ne(Nn.value,2),Bt=yi[0],_t=yi[1];if(_t.stageId===c.id&&_t.mode==="dynamic"){var Rt=Ft.project({x:_t.x,y:_t.y,z:_t.z},ue.width,ue.height);jt.set(Bt,oi(Oe,Rt.x,Rt.y))}}}catch(Cr){k={error:Cr}}finally{try{Nn&&!Nn.done&&(X=vi.return)&&X.call(vi)}finally{if(k)throw k.error}}}ne.push({c,m:Oe,clips:ot,instance:E??c.prototypeId,textMetrics:ct,textContent:Bn});try{for(var sn=ke(Ms(c.id)),Yn=sn.next();!Yn.done;Yn=sn.next()){var gt=Yn.value;Ks(gt,Oe,ot,E??c.prototypeId)}}catch(Ai){te={error:Ai}}finally{try{Yn&&!Yn.done&&(j=sn.return)&&j.call(sn)}finally{if(te)throw te.error}}ue.clip&&c.contract==="native.group.v1"&&Wf(c.id),p.restore()}}}function Wf(c,x){var A,E;if(!I?.matches)try{for(var R=ke(pe),U=R.next();!U.done;U=R.next()){var P=U.value;P.shape!=="pixel-confetti"&&P.shape!=="confetti"||P.clipId!==c||!!P.screen!=!!x||(p.save(),P.shape==="confetti"?Ig(p,P,x):Ag(p,P,x),p.restore())}}catch(W){A={error:W}}finally{try{U&&!U.done&&(E=R.return)&&E.call(R)}finally{if(A)throw A.error}}}function ey(c,x,A,E){p.save(),p.translate(c,x),p.globalAlpha=.92,p.lineWidth=2,p.lineJoin="round",A==="tap"&&(p.strokeStyle="#fff0bd",p.globalAlpha=.7*(1-E),p.beginPath(),p.arc(0,0,12+E*12,0,Math.PI*2),p.stroke(),p.globalAlpha=.92),p.fillStyle="#fff0bd",p.strokeStyle="#193b46",p.beginPath(),p.moveTo(-7,10),p.lineTo(-9,-1),p.quadraticCurveTo(-9,-5,-5,-5),p.lineTo(-3,-3),p.lineTo(-3,-17),p.quadraticCurveTo(-3,-22,1,-22),p.quadraticCurveTo(5,-22,5,-17),p.lineTo(5,-6),p.quadraticCurveTo(9,-9,11,-5),p.quadraticCurveTo(15,-7,16,-2),p.lineTo(14,9),p.quadraticCurveTo(12,18,3,18),p.lineTo(-1,18),p.quadraticCurveTo(-5,17,-7,10),p.closePath(),p.fill(),p.stroke(),p.restore()}function ty(){var c,x,A,E,R,U,P,W,O,J,B,k,X,te,j,ae,ce,we,me;if(lt=0,!f)try{for(var Ae=ke(n.gameplay.filter(function(Yn){return Yn.kind==="tutorial-hand"})),ye=Ae.next();!ye.done;ye=Ae.next()){var ve=ye.value,Ce=_.get(ve.componentId),ue=rt(ve.parameters.targetId);if(!(!Ce||Ce.sceneId!==Y||!ue||ue.sceneId!==Y||!wi(ue))&&!(ve.parameters.hideOnFirstInput&&Pe)){var Fe=Mt?ee:be;if(!(Fe-Le<ve.parameters.idleDelaySeconds)){lt++;var Oe=ve.parameters.destinationId?rt(ve.parameters.destinationId):void 0,Ue=vt(ue),Ze=void 0;ue.contract==="native.mesh3d.v1"&&(Ze=Uf(ue.id)),Ze||(Ze=oi(ui(ue),Ue.width/2,Ue.height/2));var gt=Fe%1.2/1.2,Ft=I?.matches?0:gt*gt*(3-2*gt),Ot=Ze.x,Ut=Ze.y;if(ve.parameters.mode!=="tap"){var Xt=Oe?oi(ui(Oe),vt(Oe).width/2,vt(Oe).height/2):{x:Ze.x-36,y:Ze.y+48};Ot=Ze.x+(Xt.x-Ze.x)*Ft,Ut=Ze.y+(Xt.y-Ze.y)*Ft}ey(Ot+8,Ut+22,ve.parameters.mode,Ft)}}}}catch(Yn){c={error:Yn}}finally{try{ye&&!ye.done&&(x=Ae.return)&&x.call(Ae)}finally{if(c)throw c.error}}try{for(var Bt=ke(Zn),_t=Bt.next();!_t.done;_t=Bt.next()){var Rt=Ne(_t.value,2),At=Rt[0],ut=Rt[1],Et=ii("draw-stroke",At).parameters;try{for(var en=(R=void 0,ke(ut.strokes)),ot=en.next();!ot.done;ot=en.next()){var yn=ot.value;if(!(yn.points.length<2)){p.save(),p.globalAlpha=Et.mode==="slice-blade"?Math.max(0,1-yn.age/.18):1,p.strokeStyle=Et.color,p.lineWidth=Et.strokeWidth,p.lineCap="round",p.lineJoin="round",p.beginPath(),p.moveTo(yn.points[0].x,yn.points[0].y);try{for(var fn=(P=void 0,ke(yn.points.slice(1))),Dn=fn.next();!Dn.done;Dn=fn.next()){var Jt=Dn.value;p.lineTo(Jt.x,Jt.y)}}catch(Yn){P={error:Yn}}finally{try{Dn&&!Dn.done&&(W=fn.return)&&W.call(fn)}finally{if(P)throw P.error}}p.stroke(),p.restore()}}}catch(Yn){R={error:Yn}}finally{try{ot&&!ot.done&&(U=en.return)&&U.call(en)}finally{if(R)throw R.error}}}}catch(Yn){A={error:Yn}}finally{try{_t&&!_t.done&&(E=Bt.return)&&E.call(Bt)}finally{if(A)throw A.error}}try{for(var rn=ke(kt),dt=rn.next();!dt.done;dt=rn.next()){var ct=dt.value;if(!(ct.broken||!ct.drawRope)){var Bn=Tn.get(ct.bodyId),ki=rt(ct.anchorId);if(!(!Bn||!ki)){var Ti=Ui(ki);p.save(),p.strokeStyle=ct.ropeColor,p.lineWidth=ct.ropeWidth,p.beginPath(),p.moveTo(Ti.x,Ti.y),p.lineTo(Bn.x,Bn.y),p.stroke(),p.restore()}}}}catch(Yn){O={error:Yn}}finally{try{dt&&!dt.done&&(J=rn.return)&&J.call(rn)}finally{if(O)throw O.error}}try{for(var ln=ke(n.gameplay.filter(function(Yn){var Ai;return Yn.kind==="virtual-joystick"&&((Ai=_.get(Yn.componentId))===null||Ai===void 0?void 0:Ai.sceneId)===Y})),ri=ln.next();!ri.done;ri=ln.next()){var ve=ri.value,Mi=rt(ve.componentId),Ue=ve.parameters;if(!(!Mi||!wi(Mi)||Ue.drawControl===!1)){var li=Me.get(ve.id),Ln=li&&li.pointerId!==null?li.origin:Ui(Mi),zi=li&&li.pointerId!==null?li.knobX:Ln.x,vr=li&&li.pointerId!==null?li.knobY:Ln.y,gr=(ce=Ue.radiusPx)!==null&&ce!==void 0?ce:56;p.save(),p.fillStyle=(we=Ue.baseColor)!==null&&we!==void 0?we:"#ffffff44",p.strokeStyle="#ffffffaa",p.lineWidth=2.5,p.beginPath(),p.arc(Ln.x,Ln.y,gr,0,Math.PI*2),p.fill(),p.stroke(),p.fillStyle=(me=Ue.knobColor)!==null&&me!==void 0?me:"#fff0bdee",p.strokeStyle="#193b46aa",p.lineWidth=2,p.beginPath(),p.arc(zi,vr,gr*.42,0,Math.PI*2),p.fill(),p.stroke(),p.restore()}}}catch(Yn){B={error:Yn}}finally{try{ri&&!ri.done&&(k=ln.return)&&k.call(ln)}finally{if(B)throw B.error}}try{for(var Gi=ke(Ie),$n=Gi.next();!$n.done;$n=Gi.next()){var ci=$n.value,mn=Math.min(1,ci.elapsed/ci.seconds);p.save(),p.globalAlpha=1-mn,p.fillStyle=ci.color,p.strokeStyle="#193b46",p.lineWidth=3,p.font="900 "+ci.fontSize+"px sans-serif",p.textAlign="center",p.textBaseline="middle";var Ut=ci.y-(I?.matches?0:ci.risePx*mn);p.strokeText(ci.text,ci.x,Ut),p.fillText(ci.text,ci.x,Ut),p.restore()}}catch(Yn){X={error:Yn}}finally{try{$n&&!$n.done&&(te=Gi.return)&&te.call(Gi)}finally{if(X)throw X.error}}try{for(var vi=ke(Xe),Nn=vi.next();!Nn.done;Nn=vi.next()){var yi=Nn.value,mn=Math.min(1,yi.elapsed/yi.seconds),sn=T();p.save(),p.globalAlpha=yi.opacity*(1-mn),p.fillStyle=yi.color,p.fillRect(0,0,sn.width,sn.height),p.restore()}}catch(Yn){j={error:Yn}}finally{try{Nn&&!Nn.done&&(ae=vi.return)&&ae.call(vi)}finally{if(j)throw j.error}}}function ny(){if(ie){var c=Tn.get(ie.targetId),x=ie.behavior.parameters;if(c){var A=ie.current.x-ie.start.x,E=ie.current.y-ie.start.y,R=Math.hypot(A,E),U=Math.min(x.maxPullPx,R),P=R>.001?U/R:0;p.save(),p.lineCap="round";var W=Math.max(12,Math.min(c.width,c.height)*.62);if(p.strokeStyle="#173a2f66",p.lineWidth=3.5,p.beginPath(),p.arc(c.x,c.y,W,0,Math.PI*2),p.stroke(),p.strokeStyle=x.trajectoryColor,p.lineWidth=2,p.beginPath(),p.arc(c.x,c.y,W,0,Math.PI*2),p.stroke(),x.showTrajectory&&R>=x.minPullPx){var O=Yf(),J=wl(),B=J.bodies,k=J.zones,X=T(),te=ev({body:It(It({},c),{vx:O.vx,vy:O.vy,atRest:!1}),bodies:B,zones:k,bounds:{left:0,top:0,right:X.width,bottom:X.height},dots:x.trajectoryDots,bounces:x.trajectoryBounces});te.forEach(function(ce,we){var me=.96-.52*(we/Math.max(1,te.length)),Ae=Math.max(2.2,4.5-we*.22);p.globalAlpha=me,p.fillStyle="#173a2f88",p.beginPath(),p.arc(ce.x,ce.y,Ae+1.3,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(ce.x,ce.y,Ae,0,Math.PI*2),p.fill()})}if(R>=4){var j=c.x+A*P,ae=c.y+E*P;p.globalAlpha=.9,p.strokeStyle="#173a2f66",p.lineWidth=5,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(j,ae),p.stroke(),p.strokeStyle=x.trajectoryColor,p.lineWidth=2.6,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(j,ae),p.stroke(),p.fillStyle="#173a2f88",p.beginPath(),p.arc(j,ae,5.2,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(j,ae,3.6,0,Math.PI*2),p.fill()}p.restore()}}}function iy(c){var x,A,E,R;try{for(var U=ke(Ir()),P=U.next();!P.done;P=U.next()){var W=P.value,O=W.contract==="native.group.v1"?Ms(W.id):[W];try{for(var J=(E=void 0,ke(O)),B=J.next();!B.done;B=J.next()){var k=B.value;if(k.contract==="native.stage3d.v1"&&wi(k)&&vt(k).skyColor)return vt(k).skyColor;if(!(k.contract!=="native.rectangle.v1"||!wi(k))){var X=vt(k);if(!(X.opacity<.95||!X.fill||X.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test(k.id)||X.width>=c.width*.9&&X.height>=c.height*.9))return X.fill}}}catch(te){E={error:te}}finally{try{B&&!B.done&&(R=J.return)&&R.call(J)}finally{if(E)throw E.error}}}}catch(te){x={error:te}}finally{try{P&&!P.done&&(A=U.return)&&A.call(U)}finally{if(x)throw x.error}}return"#102a34"}function ry(){var c;if(je&&wi(je.c)){var x=je.c,A=vt(x);p.save(),p.transform.apply(p,Je([],Ne(ui(x)),!1)),p.strokeStyle=(c=je.highlightColor)!==null&&c!==void 0?c:"#ffffff",p.lineWidth=4,p.globalAlpha=.85,p.strokeRect(-4,-4,A.width+8,A.height+8),p.restore()}if(st?.b.parameters.bringToFront){var x=rt(st.targetId);x&&Ks(x,x.parentId?ui(rt(x.parentId)):Ca(),[],x.prototypeId)}}function ji(){var c,x,A,E,R,U,P,W,O,J;Q=H,H=new Map;var B=T();G!==void 0&&G!==B.landscape&&ea(),G=B.landscape;var k=Math.min(devicePixelRatio||1,2),X=e.clientWidth,te=e.clientHeight;(e.width!==Math.round(X*k)||e.height!==Math.round(te*k))&&(e.width=Math.round(X*k),e.height=Math.round(te*k)),p.setTransform(k,0,0,k,0,0),p.fillStyle=iy(B),p.fillRect(0,0,X,te);var j=Math.min(X/B.width,te/B.height),ae=(X-B.width*j)/2,ce=(te-B.height*j)/2;if(_e=j||1,tt=k,p.translate(ae,ce),p.scale(j,j),qe){var we=Math.min(1,qe.elapsed/qe.seconds),me=qe.intensity*(1-we);p.translate(Math.sin(qe.elapsed*95)*me,Math.cos(qe.elapsed*113)*me)}if(To=B,Rl=!1,pi=void 0,Hf.clear(),xt.clear(),Nt&&j>0&&X>=2&&te>=2){pi={x:-ae/j,y:-ce/j,w:X/j,h:te/j,pw:X*k,ph:te*k};try{for(var Ae=ke(n.components),ye=Ae.next();!ye.done;ye=Ae.next()){var ve=ye.value;if(!(ve.contract!=="native.stage3d.v1"||ve.sceneId!==Y||ve.prototype||!wi(ve))){for(var Ce=!0,ue=[],Fe=ve.parentId?rt(ve.parentId):void 0;Fe;Fe=Fe.parentId?rt(Fe.parentId):void 0){var Oe=vt(Fe);if(Fe.contract!=="native.group.v1"||Oe.clip||Oe.opacity<1){Ce=!1;break}ue.push(Fe.id)}if(Ce){var Ue=ui(ve),Ze=vt(ve);if(!(Math.abs(Ue[1])>.001||Math.abs(Ue[2])>.001)){var gt=Math.hypot(Ue[0],Ue[1]),Ft=Math.hypot(Ue[2],Ue[3]);if(!(Ue[4]>1||Ue[5]>1||Ue[4]+Ze.width*gt<B.width-1||Ue[5]+Ze.height*Ft<B.height-1)){xt.add(ve.id);try{for(var Ot=(A=void 0,ke(ue)),Ut=Ot.next();!Ut.done;Ut=Ot.next()){var Xt=Ut.value;Hf.add(Xt)}}catch(ct){A={error:ct}}finally{try{Ut&&!Ut.done&&(E=Ot.return)&&E.call(Ot)}finally{if(A)throw A.error}}}}}}}}catch(ct){c={error:ct}}finally{try{ye&&!ye.done&&(x=Ae.return)&&x.call(Ae)}finally{if(c)throw c.error}}}Df(B),To=Ys(B),ne=[];try{for(var Bt=ke(Ir()),_t=Bt.next();!_t.done;_t=Bt.next()){var ve=_t.value;Ks(ve)}}catch(ct){R={error:ct}}finally{try{_t&&!_t.done&&(U=Bt.return)&&U.call(Bt)}finally{if(R)throw R.error}}nu(!0);try{for(var Rt=ke(he),At=Rt.next();!At.done;At=Rt.next()){var ve=At.value;ve.parentId||Ks(ve,Ca(),[],ve.prototypeId)}}catch(ct){P={error:ct}}finally{try{At&&!At.done&&(W=Rt.return)&&W.call(Rt)}finally{if(P)throw P.error}}if(ry(),ny(),f&&b){for(var ut=_.get(b);ut?.parentId;)ut=_.get(ut.parentId);ut?.prototype&&Ks(ut)}Wf(),p.save();try{for(var Et=ke(pe),en=Et.next();!en.done;en=Et.next()){var Ze=en.value;if(Ze.age===void 0){var ot=Math.min(1,Ze.life*2),yn=1.5+2.5*ot;if(p.globalAlpha=ot,p.globalCompositeOperation=Ze.shape==="square"?"source-over":"lighter",p.fillStyle=Ze.color,Ze.shape==="square"){var fn=Math.max(2,Math.round(yn*1.6));p.fillRect(Math.round(Ze.x-fn/2),Math.round(Ze.y-fn/2),fn,fn);continue}p.globalCompositeOperation="lighter",p.shadowColor=Ze.color,p.shadowBlur=pe.length<=16?6:0,p.strokeStyle=Ze.color,p.lineWidth=1.5+ot,p.beginPath(),p.moveTo(Ze.x-Ze.vx*.025,Ze.y-Ze.vy*.025),p.lineTo(Ze.x,Ze.y),p.stroke(),p.beginPath(),p.arc(Ze.x,Ze.y,yn,0,Math.PI*2),p.fill()}}}catch(ct){O={error:ct}}finally{try{en&&!en.done&&(J=Et.return)&&J.call(Et)}finally{if(O)throw O.error}}if(p.restore(),ty(),f&&b){var Dn=ne.filter(function(ct){return ct.c.contract!=="native.group.v1"&&(ct.c.id===b||Wr(ct.c,b))});if(Dn.length){var Jt=Dn.map(function(ct){return mr(ct.c,ct.m)}),rn=Math.min.apply(Math,Je([],Ne(Jt.map(function(ct){return ct.left})),!1)),dt=Math.min.apply(Math,Je([],Ne(Jt.map(function(ct){return ct.top})),!1));p.strokeStyle="#55e6ef",p.lineWidth=2/j,p.strokeRect(rn,dt,Math.max.apply(Math,Je([],Ne(Jt.map(function(ct){return ct.right})),!1))-rn,Math.max.apply(Math,Je([],Ne(Jt.map(function(ct){return ct.bottom})),!1))-dt)}}nu(!1),j>0&&Wf(void 0,{x:-ae/j,y:-ce/j,width:X/j,height:te/j})}function ay(c){var x,A,E,R,U=Array.isArray(c)?Je([],Ne(new Set(c)),!1):void 0;ji();var P=T(),W=Ys(P),O=new Set,J=[];try{for(var B=ke(ne),k=B.next();!k.done;k=B.next()){var X=k.value,te=(E=X.c.prototypeId)!==null&&E!==void 0?E:X.c.id;if(!(X.c.contract==="native.group.v1"||U&&!U.includes(te))){O.add(te);var j=mr(X.c,X.m),ae=((R=vt(X.c).strokeWidth)!==null&&R!==void 0?R:0)/2;j.left-=ae,j.right+=ae,j.top-=ae,j.bottom+=ae;var ce={left:Math.max(0,W.left-j.left),right:Math.max(0,j.right-W.right),top:Math.max(0,W.top-j.top),bottom:Math.max(0,j.bottom-W.bottom)};Object.values(ce).some(function(me){return me>.01})&&J.push({id:te,contract:X.c.contract,bounds:j,overflow:ce})}}}catch(me){x={error:me}}finally{try{k&&!k.done&&(A=B.return)&&A.call(B)}finally{if(x)throw x.error}}var we=U?U.filter(function(me){return!O.has(me)}):[];return{ok:J.length===0&&we.length===0,viewport:It(It({},P),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight}),issues:J,missing:we}}function sy(c){var x,A,E,R,U,P,W,O,J,B,k,X,te,j,ae,ce,we,me,Ae,ye,ve,Ce,ue,Fe,Oe,Ue,Ze,gt,Ft,Ot,Ut,Xt,Bt,_t,Rt,At,ut=c===void 0?{}:c,Et=ut.ids,en=ut.interactiveIds,ot=ut.network,yn=ot===void 0?"standalone":ot,fn=ut.minTouchPx,Dn=fn===void 0?44:fn,Jt=Array.isArray(Et)?Je([],Ne(new Set(Et)),!1):void 0;ji();var rn=T(),dt=Ys(rn),ct=Math.min(e.clientWidth/rn.width,e.clientHeight/rn.height),Bn=im(dt,yn),ki=[],Ti=new Set,ln=function(ge){var zt;return!Jt||Jt.includes((zt=ge.c.prototypeId)!==null&&zt!==void 0?zt:ge.c.id)},ri=ne.filter(ln),Mi=new Set(n.events.filter(function(ge){return ge.kind==="click"}).map(function(ge){return ge.componentId}));try{for(var li=ke(n.gameplay),Ln=li.next();!Ln.done;Ln=li.next()){var zi=Ln.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(zi.kind)&&Mi.add(zi.componentId)}}catch(ge){x={error:ge}}finally{try{Ln&&!Ln.done&&(A=li.return)&&A.call(li)}finally{if(x)throw x.error}}var vr=new Set(en??Mi),gr=new Set(Je(Je([],Ne(n.gameplay.filter(function(ge){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(ge.kind)&&(ge.parameters.dragMode==="anywhere"||ge.kind==="draw-stroke"||ge.kind==="virtual-joystick"&&ge.parameters.mode==="floating")}).map(function(ge){return ge.componentId})),!1),Ne(n.components.filter(function(ge){return ge.contract==="native.stage3d.v1"}).map(function(ge){return ge.id})),!1)),Gi=function(ge){var zt;return vr.has((zt=ge.c.prototypeId)!==null&&zt!==void 0?zt:ge.c.id)},$n=function(ge,zt,Qt,On,gi,Ei){return ki.push(It(It({kind:ge,severity:zt,id:Qt},Ei?{otherId:Ei}:{}),{detail:On,metrics:gi}))},ci=function(ge){var zt=[[0,0],[ge.width,0],[ge.width,ge.height],[0,ge.height]].map(function(Qt){var On=Ne(Qt,2),gi=On[0],Ei=On[1];return oi(ge.matrix,gi,Ei)});return{left:Math.min.apply(Math,Je([],Ne(zt.map(function(Qt){return Qt.x})),!1)),right:Math.max.apply(Math,Je([],Ne(zt.map(function(Qt){return Qt.x})),!1)),top:Math.min.apply(Math,Je([],Ne(zt.map(function(Qt){return Qt.y})),!1)),bottom:Math.max.apply(Math,Je([],Ne(zt.map(function(Qt){return Qt.y})),!1))}};try{for(var mn=ke(ri),vi=mn.next();!vi.done;vi=mn.next()){var Nn=vi.value,yi=(Oe=Nn.c.prototypeId)!==null&&Oe!==void 0?Oe:Nn.c.id;Ti.add(yi);var sn=mr(Nn.c,Nn.m),Yn=((Ue=vt(Nn.c).strokeWidth)!==null&&Ue!==void 0?Ue:0)/2;sn.left-=Yn,sn.right+=Yn,sn.top-=Yn,sn.bottom+=Yn;var Ai=Nn.c.contract==="native.group.v1"&&!vt(Nn.c).clip,yr=Nn.c.contract==="native.image.v1"&&Nn.clips.length===0&&vt(Nn.c).fit==="cover"&&sn.left<=0&&sn.top<=0&&sn.right>=rn.width&&sn.bottom>=rn.height||Nn.c.contract==="native.stage3d.v1"&&sn.left<=0&&sn.top<=0&&sn.right>=rn.width&&sn.bottom>=rn.height,Ar=Nn.c.contract==="native.rectangle.v1"&&Yn===0&&sn.left<=0&&sn.top<=0&&sn.right>=rn.width&&sn.bottom>=rn.height||yr;if(!Ai){var Cr={left:Math.max(0,dt.left-sn.left),right:Math.max(0,sn.right-dt.right),top:Math.max(0,dt.top-sn.top),bottom:Math.max(0,sn.bottom-dt.bottom)};if(!Ar&&!dm(Nn.c)&&Object.values(Cr).some(function(ge){return ge>.01})&&$n("stage-overflow","blocker",yi,"Component extends beyond the active stage.",{bounds:sn,overflow:Cr}),Nn.c.contract==="native.image.v1"&&Nn.clips.length===0){var xa=sn.right-sn.left,ar=sn.bottom-sn.top,Xr=/(?:^|\.)(backdrop|background|bg)$/.test(yi)||vt(Nn.c).fit==="cover"&&!Nn.c.parentId&&sn.left<=1&&sn.top<=1&&(xa>=rn.width*.4||ar>=rn.height*.4);Xr&&(sn.left>.5||sn.top>.5||sn.right<rn.width-.5||sn.bottom<rn.height-.5)&&$n("backdrop-incomplete","blocker",yi,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:sn,stage:{width:rn.width,height:rn.height}})}try{for(var Yr=(U=void 0,ke(Nn.clips)),Rr=Yr.next();!Rr.done;Rr=Yr.next()){var qr=Rr.value,Fi=ci(qr),Yi={left:Math.max(0,Fi.left-sn.left),right:Math.max(0,sn.right-Fi.right),top:Math.max(0,Fi.top-sn.top),bottom:Math.max(0,sn.bottom-Fi.bottom)};Object.values(Yi).some(function(ge){return ge>.01})&&$n("parent-clip-crop","blocker",yi,"Component is cropped by an ancestor clipping group.",{bounds:sn,clip:Fi,crop:Yi})}}catch(ge){U={error:ge}}finally{try{Rr&&!Rr.done&&(P=Yr.return)&&P.call(Yr)}finally{if(U)throw U.error}}}if(Nn.textMetrics){var Oi=Nn.textMetrics;Oi.overflowsWidth&&$n("text-overflow","blocker",yi,"Text exceeds its component width after wrapping and auto-fit.",Oi),Oi.overflowsHeight&&$n("text-clipped","blocker",yi,"Text is vertically clipped by its component after wrapping and auto-fit.",Oi);var xr=(Ze=Oi.fontSize)!==null&&Ze!==void 0?Ze:Oi.scale*8;xr<12&&$n("text-illegible",xr<8?"blocker":"warning",yi,"Rendered text is below the recommended legible size.",It({renderedFontSize:xr},Oi));var kn=vt(Nn.c),ws=kn.direction==="rtl"||kn.direction!=="ltr"&&/^(ar|fa|he|iw|ps|sd|ug|ur|yi)(?:-|$)/.test(n.creativeBrief.language);if(ws&&Oi.resolvedAlign==="left"&&$n("rtl-alignment","blocker",yi,"Right-to-left copy must resolve to right or center alignment.",{direction:"rtl",align:kn.align,resolvedAlign:Oi.resolvedAlign}),kn.pixelPanel&&kn.align!=="center"){var ls=Math.max(0,kn.width-2*(kn.padding===void 0?8:kn.padding));ls-((gt=Oi.renderedWidth)!==null&>!==void 0?gt:0)>12&&$n("panel-off-center","blocker",yi,"Text inside a framed pixel panel is not horizontally centered.",{align:kn.align,innerWidth:ls,renderedWidth:(Ft=Oi.renderedWidth)!==null&&Ft!==void 0?Ft:0})}}if(Gi(Nn)&&!gr.has(yi)&&(Nn.c.contract!=="native.group.v1"||sn.right>sn.left&&sn.bottom>sn.top)){var Ji=(sn.right-sn.left)*ct,Ri=(sn.bottom-sn.top)*ct;(Ji<Dn-.01||Ri<Dn-.01)&&$n("touch-target-small","blocker",yi,"Interactive target is smaller than the required physical touch size.",{width:Ji,height:Ri,minTouchPx:Dn,scale:ct})}if(Gi(Nn)&&!gr.has(yi)||Nn.c.contract==="native.text.v1")try{for(var er=(W=void 0,ke(Bn.zones)),xi=er.next();!xi.done;xi=er.next()){var tr=xi.value,Ji=Math.min(sn.right,tr.right)-Math.max(sn.left,tr.left),Ri=Math.min(sn.bottom,tr.bottom)-Math.max(sn.top,tr.top);Ji>.01&&Ri>.01&&$n("sdk-safe-area-collision","blocker",yi,"Component intersects a reserved ad-SDK overlay zone.",{bounds:sn,zone:tr,intersection:{width:Ji,height:Ri},network:yn})}}catch(ge){W={error:ge}}finally{try{xi&&!xi.done&&(O=er.return)&&O.call(er)}finally{if(W)throw W.error}}}}catch(ge){E={error:ge}}finally{try{vi&&!vi.done&&(R=mn.return)&&R.call(mn)}finally{if(E)throw E.error}}for(var $i=ri.filter(function(ge){return Gi(ge)&&ge.c.contract!=="native.group.v1"&&ge.c.contract!=="native.stage3d.v1"}),Pi=0;Pi<$i.length;Pi++)for(var Hi=Pi+1;Hi<$i.length;Hi++){var ni=$i[Pi],di=$i[Hi],Qs=(Ot=ni.c.prototypeId)!==null&&Ot!==void 0?Ot:ni.c.id,js=(Ut=di.c.prototypeId)!==null&&Ut!==void 0?Ut:di.c.id;if(!(Qs===js||Wr(ni.c,di.c.id)||Wr(di.c,ni.c.id))){var Ts=mr(ni.c,ni.m),As=mr(di.c,di.m),Ji=Math.min(Ts.right,As.right)-Math.max(Ts.left,As.left),Ri=Math.min(Ts.bottom,As.bottom)-Math.max(Ts.top,As.top);Ji>1&&Ri>1&&$n("interactive-overlap","blocker",Qs,"Interactive targets overlap.",{intersection:{width:Ji,height:Ri},first:Ts,second:As},js)}}var Ao=function(ge){if(!ge||ge==="transparent")return!1;var zt=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(ge);if(zt)return zt[1].length===4?zt[1][3].toLowerCase()==="f":zt[1].slice(6).toLowerCase()==="ff";var Qt=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(ge);return Qt?Number(Qt[1])>=.95:!0},Es=[];ri.forEach(function(ge,zt){var Qt,On;ge.c.contract==="native.rectangle.v1"&&!Gi(ge)&&((Qt=vt(ge.c).opacity)!==null&&Qt!==void 0?Qt:1)>=.95&&Ao(vt(ge.c).fill)&&Es.push({rowIndex:zt,row:ge,order:(On=ge.c.order)!==null&&On!==void 0?On:0,bounds:mr(ge.c,ge.m)})});var _n=ri.filter(function(ge,zt){var Qt,On=mr(ge.c,ge.m),gi=(Qt=ge.c.order)!==null&&Qt!==void 0?Qt:0;return!Es.some(function(Ei){return Ei.rowIndex>zt&&Ei.order>gi&&Ei.row.c.id!==ge.c.id&&!Wr(Ei.row.c,ge.c.id)&&!Wr(ge.c,Ei.row.c.id)&&Ei.bounds.left<=On.left+1&&Ei.bounds.right>=On.right-1&&Ei.bounds.top<=On.top+1&&Ei.bounds.bottom>=On.bottom-1})}),Di=_n.map(function(ge,zt){return{row:ge,rowIndex:zt}}).filter(function(ge){var zt,Qt=ge.row;if(Qt.c.contract!=="native.rectangle.v1")return!1;var On=mr(Qt.c,Qt.m),gi=On.right-On.left,Ei=On.bottom-On.top,qi=((zt=vt(Qt.c).strokeWidth)!==null&&zt!==void 0?zt:0)===0&&On.left<=0&&On.right>=rn.width;return!qi&&gi>=180&&Ei>=140&&!Gi(Qt)}).map(function(ge){var zt,Qt=ge.row,On=ge.rowIndex;return{id:(zt=Qt.c.prototypeId)!==null&&zt!==void 0?zt:Qt.c.id,row:Qt,rowIndex:On,bounds:mr(Qt.c,Qt.m)}}),_r=function(ge,zt,Qt,On){var gi,Ei;On===void 0&&(On=!1);var qi=(gi=ge.c.prototypeId)!==null&&gi!==void 0?gi:ge.c.id,Zr=(Qt.left+Qt.right)/2,Ea=(Qt.top+Qt.bottom)/2,kl=(Ei=ge.c.order)!==null&&Ei!==void 0?Ei:0;return Di.filter(function(Ii){var Ia;return Ii.id!==qi&&(!On||Ii.rowIndex<zt||((Ia=Ii.row.c.order)!==null&&Ia!==void 0?Ia:0)===kl)&&Qt.right-Qt.left<=Ii.bounds.right-Ii.bounds.left+4&&Qt.bottom-Qt.top<=Ii.bounds.bottom-Ii.bounds.top+4&&Zr>=Ii.bounds.left&&Zr<=Ii.bounds.right&&Ea>=Ii.bounds.top&&Ea<=Ii.bounds.bottom}).sort(function(Ii,Ia){return(Ii.bounds.right-Ii.bounds.left)*(Ii.bounds.bottom-Ii.bounds.top)-(Ia.bounds.right-Ia.bounds.left)*(Ia.bounds.bottom-Ia.bounds.top)||Ia.rowIndex-Ii.rowIndex})[0]},Wi=new Map,Pr=new Map;if(Di.length){_n.forEach(function(ge,zt){var Qt,On=(Qt=ge.c.prototypeId)!==null&&Qt!==void 0?Qt:ge.c.id,gi=mr(ge.c,ge.m),Ei=(gi.left+gi.right)/2,qi=(gi.top+gi.bottom)/2,Zr=ge.c.contract==="native.button.v1"&&!Ht.has(ge.c.id),Ea=ge.c.parentId?rt(ge.c.parentId):void 0,kl=ge.c.contract==="native.text.v1"&&vt(ge.c).align==="center"&&Ea?.contract!=="native.button.v1";if(Zr||kl){var Ii=_r(ge,zt,gi,!1);Ii&&(Wi.has(Ii.id)||Wi.set(Ii.id,{panel:Ii,items:[]}),Wi.get(Ii.id).items.push({id:On,bounds:gi,cx:Ei,cy:qi,isBtn:Zr}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(ge.c.contract)&&Ea?.contract!=="native.button.v1"){var Ii=_r(ge,zt,gi,!0);Ii&&(Pr.has(Ii.id)||Pr.set(Ii.id,{panel:Ii,content:[]}),Pr.get(Ii.id).content.push({row:ge,id:On,bounds:gi}))}});try{for(var sr=ke(Wi.values()),Er=sr.next();!Er.done;Er=sr.next()){var Mr=Er.value,Lr=Mr.panel,_a=Mr.items;if(_a.some(function(ge){return ge.isBtn})){var Ki=Lr.bounds,Ga=(Ki.left+Ki.right)/2;try{for(var cs=(k=void 0,ke(_a)),us=cs.next();!us.done;us=cs.next()){var eo=us.value,Pl={left:eo.bounds.left-Ki.left,right:Ki.right-eo.bounds.right,top:eo.bounds.top-Ki.top,bottom:Ki.bottom-eo.bounds.bottom},_m=Math.min(Pl.left,Pl.right,Pl.top,Pl.bottom);(_m<10||_m*ct<8)&&$n("panel-edge-cramped","blocker",eo.id,"Element sits too close to its enclosing panel edge.",{panelId:Lr.id,margins:Pl,scale:ct,minStagePx:10,minCssPx:8},Lr.id)}}catch(ge){k={error:ge}}finally{try{us&&!us.done&&(X=cs.return)&&X.call(cs)}finally{if(k)throw k.error}}var Qf=[],vy=function(ge){var zt=Qf.find(function(Qt){return Math.abs(Qt.cy-ge.cy)<=16&&Qt.isBtn===ge.isBtn});zt?zt.items.push(ge):Qf.push({cy:ge.cy,isBtn:ge.isBtn,items:[ge]})};try{for(var su=(te=void 0,ke(_a)),Ll=su.next();!Ll.done;Ll=su.next()){var eo=Ll.value;vy(eo)}}catch(ge){te={error:ge}}finally{try{Ll&&!Ll.done&&(j=su.return)&&j.call(su)}finally{if(te)throw te.error}}try{for(var ou=(ae=void 0,ke(Qf)),Dl=ou.next();!Dl.done;Dl=ou.next()){var jf=Dl.value,gy=Math.min.apply(Math,Je([],Ne(jf.items.map(function(ge){return ge.bounds.left})),!1)),yy=Math.max.apply(Math,Je([],Ne(jf.items.map(function(ge){return ge.bounds.right})),!1)),Mm=(gy+yy)/2,Sm=Mm-Ga;Math.abs(Sm)>3&&$n("panel-off-center","blocker",jf.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:Lr.id,offsetX:Sm,groupCenterX:Mm,panelCenterX:Ga,scale:ct},Lr.id)}}catch(ge){ae={error:ge}}finally{try{Dl&&!Dl.done&&(ce=ou.return)&&ce.call(ou)}finally{if(ae)throw ae.error}}}}}catch(ge){J={error:ge}}finally{try{Er&&!Er.done&&(B=sr.return)&&B.call(sr)}finally{if(J)throw J.error}}try{for(var lu=ke(Pr.values()),Nl=lu.next();!Nl.done;Nl=lu.next())for(var bm=Nl.value,Lr=bm.panel,cu=bm.content,xy=Wi.has(Lr.id),Pi=0;Pi<cu.length;Pi++)for(var Hi=Pi+1;Hi<cu.length;Hi++){var ni=cu[Pi],di=cu[Hi];if(!(ni.id===di.id||Wr(ni.row.c,di.row.c.id)||Wr(di.row.c,ni.row.c.id))){var _y=ni.row.c.contract==="native.image.v1"&&di.row.c.contract==="native.image.v1";if(!(_y&&(!xy||ni.row.c.parentId&&ni.row.c.parentId===di.row.c.parentId))){var Ji=Math.min(ni.bounds.right,di.bounds.right)-Math.max(ni.bounds.left,di.bounds.left),Ri=Math.min(ni.bounds.bottom,di.bounds.bottom)-Math.max(ni.bounds.top,di.bounds.top);Ji>2&&Ri>2&&$n("panel-content-overlap","blocker",ni.id,"Panel elements overlap each other.",{panelId:Lr.id,intersection:{width:Ji,height:Ri},first:ni.bounds,second:di.bounds},di.id)}}}}catch(ge){we={error:ge}}finally{try{Nl&&!Nl.done&&(me=lu.return)&&me.call(lu)}finally{if(we)throw we.error}}}var Eo=_n.filter(function(ge){if(ge.c.contract!=="native.text.v1")return!1;var zt=ge.c.parentId?rt(ge.c.parentId):void 0;return zt?.contract!=="native.button.v1"}).map(function(ge){var zt,Qt,On=String((zt=vt(ge.c).text)!==null&&zt!==void 0?zt:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(gi,Ei){var qi;return String((qi=$[Ei])!==null&&qi!==void 0?qi:"")}).trim();return{row:ge,id:(Qt=ge.c.prototypeId)!==null&&Qt!==void 0?Qt:ge.c.id,bounds:mr(ge.c,ge.m),raw:On,norm:On.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(ge){return ge.raw.length>0}),My=Di.filter(function(ge){var zt,Qt;return((zt=Wi.get(ge.id))===null||zt===void 0?void 0:zt.items.some(function(On){return On.isBtn}))||((Qt=Pr.get(ge.id))===null||Qt===void 0?void 0:Qt.content.some(function(On){return On.row.c.contract==="native.button.v1"}))});try{for(var uu=ke(My),Ul=uu.next();!Ul.done;Ul=uu.next()){var Lr=Ul.value,Ki=Lr.bounds,Ga=(Ki.left+Ki.right)/2,Sy=Ki.right-Ki.left;try{for(var du=(ve=void 0,ke(Eo)),Fl=du.next();!Fl.done;Fl=du.next()){var Ha=Fl.value;if(vt(Ha.row.c).align==="center"&&!(Ha.bounds.bottom>Ki.top+6||Ki.top-Ha.bounds.bottom>48)){var wm=Ha.bounds.right-Ha.bounds.left,Ol=(Ha.bounds.left+Ha.bounds.right)/2,by=Math.min(Ha.bounds.right,Ki.right)-Math.max(Ha.bounds.left,Ki.left);(Ol>=Ki.left&&Ol<=Ki.right||by>=wm*.6)&&wm<=Sy+60&&Math.abs(Ol-Ga)>4&&$n("header-off-center","blocker",Ha.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:Lr.id,offsetX:Ol-Ga,textCenterX:Ol,panelCenterX:Ga,scale:ct},Lr.id)}}}catch(On){ve={error:On}}finally{try{Fl&&!Fl.done&&(Ce=du.return)&&Ce.call(du)}finally{if(ve)throw ve.error}}}}catch(ge){Ae={error:ge}}finally{try{Ul&&!Ul.done&&(ye=uu.return)&&ye.call(uu)}finally{if(Ae)throw Ae.error}}for(var Pi=0;Pi<Eo.length;Pi++)for(var Hi=Pi+1;Hi<Eo.length;Hi++){var ni=Eo[Pi],di=Eo[Hi];if(!(ni.id===di.id||Wr(ni.row.c,di.row.c.id)||Wr(di.row.c,ni.row.c.id))){var Ji=Math.min(ni.bounds.right,di.bounds.right)-Math.max(ni.bounds.left,di.bounds.left),Ri=Math.min(ni.bounds.bottom,di.bounds.bottom)-Math.max(ni.bounds.top,di.bounds.top);if(Ji>2&&Ri>2&&$n("panel-content-overlap","blocker",ni.id,"Visible text elements overlap.",{intersection:{width:Ji,height:Ri},first:ni.bounds,second:di.bounds},di.id),ni.norm&&di.norm){var Tm=Ne(ni.norm.length<=di.norm.length?[ni.norm,di.norm]:[di.norm,ni.norm],2),fu=Tm[0],Am=Tm[1];(fu===Am&&fu.length>=6||fu.length>=12&&Am.includes(fu))&&$n("duplicate-visible-copy","blocker",ni.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:ni.raw,second:di.raw},di.id)}}}var Wa=Eo.filter(function(ge){return!/^[\d\s/.,:%+\-x]+$/i.test(ge.raw)}),hu=Wa.reduce(function(ge,zt){return ge+(zt.norm?zt.norm.split(" ").filter(Boolean).length:0)},0),eh=Wa.reduce(function(ge,zt){return ge+zt.raw.replace(/\s+/g," ").length},0);hu>20||eh>130||Wa.length>5?$n("text-clutter-heavy","blocker",(Bt=(Xt=Wa[0])===null||Xt===void 0?void 0:Xt.id)!==null&&Bt!==void 0?Bt:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:Wa.length,wordCount:hu,charCount:eh,texts:Wa.map(function(ge){return ge.raw})}):(hu>12||Wa.length>4)&&$n("text-clutter-heavy","warning",(Rt=(_t=Wa[0])===null||_t===void 0?void 0:_t.id)!==null&&Rt!==void 0?Rt:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:Wa.length,wordCount:hu,charCount:eh,texts:Wa.map(function(ge){return ge.raw})});var th=[],wy=function(ge){if(Jt&&!Jt.includes(ge.componentId)||ge.ownerHiddenByAuthor||!ge.targetVisible)return"continue";var zt=ri.find(function(Sr){var nh;return((nh=Sr.c.prototypeId)!==null&&nh!==void 0?nh:Sr.c.id)===ge.componentId}),Qt=zt?mr(zt.c,zt.m):null;if(zt&&zt.c.contract==="native.group.v1"&&(!Qt||Qt.right<=Qt.left||Qt.bottom<=Qt.top)){var On=ri.filter(function(Sr){return Sr.c.contract!=="native.group.v1"&&Wr(Sr.c,zt.c.id)}).map(function(Sr){return mr(Sr.c,Sr.m)});On.length&&(Qt={left:Math.min.apply(Math,Je([],Ne(On.map(function(Sr){return Sr.left})),!1)),right:Math.max.apply(Math,Je([],Ne(On.map(function(Sr){return Sr.right})),!1)),top:Math.min.apply(Math,Je([],Ne(On.map(function(Sr){return Sr.top})),!1)),bottom:Math.max.apply(Math,Je([],Ne(On.map(function(Sr){return Sr.bottom})),!1))})}var gi={occluded:!1,occluderId:null,targetHitSamples:0,occludedSamples:0,occludedRatio:0};!ge.behindCamera&&!ge.offscreen&&ge.stageEntry&&ge.localBounds&&(gi=ge.stageEntry.checkNodeOcclusion(ge.targetId,ge.localBounds,ge.stageLocalWidth,ge.stageLocalHeight));var Ei={id:ge.componentId,targetId:ge.targetId,stageId:ge.stageId,visible:ge.visible,behindCamera:ge.behindCamera,offscreen:ge.offscreen,clippedFraction:Number(ge.clippedFraction.toFixed(3)),targetBounds:ge.targetBounds,overlayBounds:Qt,occluded:gi.occluded,occluderId:gi.occluderId};if(th.push(Ei),(ge.behindCamera||ge.offscreen||ge.clippedFraction>.25)&&$n("anchor-3d-target-offscreen","blocker",ge.componentId,"Anchored 3D target is behind the camera, off-screen, or significantly clipped in this viewport.",{targetId:ge.targetId,behindCamera:ge.behindCamera,offscreen:ge.offscreen,clippedFraction:Ei.clippedFraction,targetBounds:ge.targetBounds,viewportBounds:dt},ge.targetId),Qt&&ge.targetBounds&&!ge.behindCamera&&!ge.offscreen){var qi=ge.targetBounds,Zr=Qt,Ea=Math.min(Zr.right,qi.right)-Math.max(Zr.left,qi.left),kl=Math.min(Zr.bottom,qi.bottom)-Math.max(Zr.top,qi.top),Ii=Ea>0&&kl>0,Ia=Math.max(0,Math.max(Zr.left-qi.right,qi.left-Zr.right)),Ay=Math.max(0,Math.max(Zr.top-qi.bottom,qi.top-Zr.bottom)),Im=Math.hypot(Ia,Ay),Cm=$i.some(function(Sr){return Wr(Sr.c,ge.componentId)}),Rm=!!(zt&&Gi(zt)||Cm||ge.config.fitToProjectedBounds);(Rm&&!Ii||!Rm&&Im>72)&&$n("anchor-3d-misaligned","blocker",ge.componentId,"Anchored 2D overlay does not align with its projected 3D target bounds.",{targetId:ge.targetId,targetBounds:qi,overlayBounds:Zr,edgeGap:Number(Im.toFixed(1)),interactive:!!(zt&&Gi(zt)||Cm)},ge.targetId)}gi.occluded&&$n("anchor-3d-occluded","blocker",ge.componentId,"Anchored 3D target is occluded from the camera by another foreground 3D mesh.",{targetId:ge.targetId,occluderId:gi.occluderId,occludedRatio:Number(gi.occludedRatio.toFixed(2)),targetHitSamples:gi.targetHitSamples,occludedSamples:gi.occludedSamples},(At=gi.occluderId)!==null&&At!==void 0?At:ge.targetId)};try{for(var pu=ke(pn.values()),Bl=pu.next();!Bl.done;Bl=pu.next()){var Ty=Bl.value;wy(Ty)}}catch(ge){ue={error:ge}}finally{try{Bl&&!Bl.done&&(Fe=pu.return)&&Fe.call(pu)}finally{if(ue)throw ue.error}}var Em=Jt?Jt.filter(function(ge){if(Ti.has(ge))return!1;var zt=rt(ge);return zt?.contract==="native.mesh3d.v1"?!1:!zt||wi(zt)}):[];return It(It({ok:!ki.some(function(ge){return ge.severity==="blocker"})&&Em.length===0,viewport:It(It({},rn),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight,scale:ct}),defects:ki,missing:Em,interactive:$i.map(function(ge){var zt;return{id:(zt=ge.c.prototypeId)!==null&&zt!==void 0?zt:ge.c.id,bounds:mr(ge.c,ge.m)}}),texts:ri.filter(function(ge){return ge.c.contract==="native.text.v1"}).map(function(ge){var zt,Qt,On,gi,Ei,qi;return{id:(zt=ge.c.prototypeId)!==null&&zt!==void 0?zt:ge.c.id,text:(Qt=ge.textContent)!==null&&Qt!==void 0?Qt:"",direction:(gi=(On=ge.textMetrics)===null||On===void 0?void 0:On.direction)!==null&&gi!==void 0?gi:"ltr",align:(qi=(Ei=ge.textMetrics)===null||Ei===void 0?void 0:Ei.resolvedAlign)!==null&&qi!==void 0?qi:vt(ge.c).align}})},th.length?{anchors3d:th}:{}),{safeArea:Bn})}function Wr(c,x){for(;c.parentId;){if(c.parentId===x)return!0;c=rt(c.parentId)}return!1}function dm(c){for(var x=function(R){if(n.gameplay.some(function(U){var P;return U.kind==="camera-follow"&&U.componentId===((P=R.prototypeId)!==null&&P!==void 0?P:R.id)}))return{value:!0}},A=c;A;A=A.parentId?rt(A.parentId):void 0){var E=x(A);if(typeof E=="object")return E.value}return!1}function Xf(c){var x=T(),A=e.getBoundingClientRect(),E=Math.min(A.width/x.width,A.height/x.height);return{x:(c.clientX-A.left-(A.width-x.width*E)/2)/E,y:(c.clientY-A.top-(A.height-x.height*E)/2)/E}}function oy(c,x){var A,E,R,U;try{if(c.c.contract==="native.stage3d.v1"&&xt.has(c.c.id)&&pi)return x.x>=pi.x&&x.y>=pi.y&&x.x<=pi.x+pi.w&&x.y<=pi.y+pi.h;try{for(var P=ke(c.clips),W=P.next();!W.done;W=P.next()){var O=W.value,J=oi(Dr(O.matrix),x.x,x.y);if(J.x<0||J.y<0||J.x>O.width||J.y>O.height)return!1}}catch(ye){A={error:ye}}finally{try{W&&!W.done&&(E=P.return)&&E.call(P)}finally{if(A)throw A.error}}var B=oi(Dr(c.m),x.x,x.y),k=vt(c.c);if(c.c.contract==="native.path.v1"){var X=new Path2D,te=function(ye,ve){({M:function(){return X.moveTo.apply(X,Je([],Ne(ve),!1))},L:function(){return X.lineTo.apply(X,Je([],Ne(ve),!1))},C:function(){return X.bezierCurveTo.apply(X,Je([],Ne(ve),!1))},Q:function(){return X.quadraticCurveTo.apply(X,Je([],Ne(ve),!1))},Z:function(){return X.closePath()}})[ye]()};try{for(var j=ke(k.commands),ae=j.next();!ae.done;ae=j.next()){var ce=Ne(ae.value),we=ce[0],me=ce.slice(1);te(we,me)}}catch(ye){R={error:ye}}finally{try{ae&&!ae.done&&(U=j.return)&&U.call(j)}finally{if(R)throw R.error}}p.save(),p.setTransform(1,0,0,1,0,0),p.lineWidth=k.strokeWidth;var Ae=p.isPointInPath(X,B.x,B.y)||k.strokeWidth>0&&p.isPointInStroke(X,B.x,B.y);return p.restore(),Ae}return c.c.contract==="native.ellipse.v1"?Math.pow((B.x-k.width/2)/(k.width/2),2)+Math.pow((B.y-k.height/2)/(k.height/2),2)<=1:B.x>=0&&B.y>=0&&B.x<=k.width&&B.y<=k.height}catch{return!1}}function iu(c){return Je([],Ne(ne),!1).reverse().find(function(x){return x.c.contract!=="native.group.v1"&&x.c.sceneId===Y&&rt(x.c.id)&&wi(x.c)&&oy(x,c)})}function ru(c){for(var x=[];c;)x.push(c),c=rt(c.parentId);return x}function Yf(){if(!ie)return{vx:0,vy:0,power:0,pull:0};var c=ie.behavior.parameters,x=ie.current.x-ie.start.x,A=ie.current.y-ie.start.y,E=Math.hypot(x,A),R=Math.max(0,Math.min(1,(E-c.minPullPx)/Math.max(1,c.maxPullPx-c.minPullPx))),U=c.minSpeed+(c.maxSpeed-c.minSpeed)*R,P=c.invert?-1:1;return{vx:E?x/E*U*P:0,vy:E?A/E*U*P:0,power:R,pull:E}}function fm(c){if(ie){ie.current=c;var x=Yf();ie.power=x.power,ie.behavior.parameters.powerVariableId&&($[ie.behavior.parameters.powerVariableId]=x.power)}}function qf(c){var x,A;c===void 0&&(c=!1);try{var E=(x=globalThis.AudioContext)!==null&&x!==void 0?x:globalThis.webkitAudioContext;E&&!Ve&&(Ve=new E,(A=Ve.addEventListener)===null||A===void 0||A.call(Ve,"statechange",function(){Ve?.state==="running"&&Of()})),Cl(c)}catch{}}function ly(c,x,A){var E,R,U,P,W,O,J=function(ve){var Ce=A.find(function(Oe){var Ue;return((Ue=Oe.prototypeId)!==null&&Ue!==void 0?Ue:Oe.id)===ve.componentId});if(!Ce)return"continue";var ue=oi(Dr(ui(Ce)),x.x,x.y),Fe=Va(Ce,ve);return Fe.stampSegment(ue,ue),ft={kind:"mask",pointerId:c.pointerId,c:Ce,behavior:ve,last:ue},(W=e.setPointerCapture)===null||W===void 0||W.call(e,c.pointerId),{value:!0}};try{for(var B=ke(n.gameplay.filter(function(ve){var Ce;return ve.kind==="erase-mask"&&((Ce=_.get(ve.componentId))===null||Ce===void 0?void 0:Ce.sceneId)===Y})),k=B.next();!k.done;k=B.next()){var X=k.value,te=J(X);if(typeof te=="object")return te.value}}catch(ve){E={error:ve}}finally{try{k&&!k.done&&(R=B.return)&&R.call(B)}finally{if(E)throw E.error}}if(A.some(function(ve){return ve.contract==="native.button.v1"||n.events.some(function(Ce){var ue;return Ce.kind==="click"&&Ce.componentId===((ue=ve.prototypeId)!==null&&ue!==void 0?ue:ve.id)})}))return!1;try{for(var j=ke(n.gameplay.filter(function(ve){var Ce;return ve.kind==="draw-stroke"&&((Ce=_.get(ve.componentId))===null||Ce===void 0?void 0:Ce.sceneId)===Y})),ae=j.next();!ae.done;ae=j.next()){var X=ae.value,ce=_.get(X.componentId),we=Dr(ui(ce)),me=oi(we,x.x,x.y),Ae=vt(ce);if(!(me.x<0||me.y<0||me.x>Ae.width||me.y>Ae.height)){var ye=$c(X);return ye.begin(x),ft={kind:"stroke",pointerId:c.pointerId,c:ce,behavior:X,store:ye,last:x},In({kind:"strokeStart",componentId:ce.id}),(O=e.setPointerCapture)===null||O===void 0||O.call(e,c.pointerId),!0}}}catch(ve){U={error:ve}}finally{try{ae&&!ae.done&&(P=j.return)&&P.call(j)}finally{if(U)throw U.error}}return!1}function cy(c,x,A){var E,R,U,P,W,O,J,B=A.store.active;if(B){try{for(var k=ke(n.gameplay.filter(function(Fe){var Oe;return Fe.kind==="collider"&&((Oe=_.get(Fe.componentId))===null||Oe===void 0?void 0:Oe.sceneId)===Y})),X=k.next();!X.done;X=k.next()){var te=X.value,j=_.get(te.componentId);try{for(var ae=(U=void 0,ke(Bi(j))),ce=ae.next();!ce.done;ce=ae.next()){var we=ce.value;!wi(we)||B.hitIds.has(we.id)||Xm(c,x,um(we,te.parameters.shape))&&(B.hitIds.add(we.id),In(Qi("sliceHit",we)))}}catch(Fe){U={error:Fe}}finally{try{ce&&!ce.done&&(P=ae.return)&&P.call(ae)}finally{if(U)throw U.error}}}}catch(Fe){E={error:Fe}}finally{try{X&&!X.done&&(R=k.return)&&R.call(k)}finally{if(E)throw E.error}}try{for(var me=ke(kt),Ae=me.next();!Ae.done;Ae=me.next()){var ye=Ae.value;if(!(ye.broken||!ye.breakable||B.hitIds.has(ye.key))){var ve=Tn.get(ye.bodyId),Ce=rt(ye.anchorId);if(!(!ve||!Ce)){var ue=Ui(Ce);ch(c,x,{x:ue.x,y:ue.y},{x:ve.x,y:ve.y})&&(B.hitIds.add(ye.key),ye.broken=!0,re.add(ye.key),In({kind:"jointBreak",behaviorId:ye.id,componentId:ye.componentId,selfInstanceId:ye.bodyId,instanceId:(J=rt(ye.bodyId))===null||J===void 0?void 0:J.instanceId}))}}}}catch(Fe){W={error:Fe}}finally{try{Ae&&!Ae.done&&(O=me.return)&&O.call(me)}finally{if(W)throw W.error}}}}function uy(c,x){var A,E=x.last,R=x.behavior.parameters;if(R.inkVariableId){var U=R.inkVariableId,P=Math.hypot(c.x-E.x,c.y-E.y);if(((A=$[U])!==null&&A!==void 0?A:0)<P)return;$[U]-=P}x.store.add(c)&&(R.mode==="slice-blade"&&cy(E,c,x),x.last=c)}function dy(c){var x,A;if(!(!ft||ft.pointerId!==c.pointerId)){var E=ft;ft=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,c.pointerId))}catch{}if(E.kind==="stroke"){var R=E.store.end(),U=E.behavior.parameters;if(R){if(U.mode==="physics-wall"){var P=new Set(E.store.strokes.map(function(O){return O.id}));wt=wt.filter(function(O){return O.owner!==E.c.id||P.has(O.strokeId)}),wt.push.apply(wt,Je([],Ne(qm(R,U.strokeWidth).map(function(O){return It(It({},O),{owner:E.c.id})})),!1))}else if(U.mode==="path-trace"){var W=rt(U.followComponentId);W&&R.points.length>1&&C.set(W.id,{points:R.points,index:1,speed:U.followSpeed})}}In({kind:"strokeEnd",componentId:E.c.id})}}}function fy(c){var x,A,E,R;try{for(var U=ke(Zn.values()),P=U.next();!P.done;P=U.next()){var W=P.value;W.tick(c)}}catch(ye){x={error:ye}}finally{try{P&&!P.done&&(A=U.return)&&A.call(U)}finally{if(x)throw x.error}}try{for(var O=ke(C),J=O.next();!J.done;J=O.next()){var B=Ne(J.value,2),k=B[0],X=B[1],te=rt(k);if(!te){C.delete(k);continue}var j=X.points[X.index];if(!j){C.delete(k),In(Qi("pathArrive",te));continue}var ae=Ui(te),ce=j.x-ae.x,we=j.y-ae.y,me=Math.hypot(ce,we),Ae=X.speed*c;me<=Ae?(Hr(te,j.x,j.y),X.index++):me>.001&&Hr(te,ae.x+ce/me*Ae,ae.y+we/me*Ae)}}catch(ye){E={error:ye}}finally{try{J&&!J.done&&(R=O.return)&&R.call(O)}finally{if(E)throw E.error}}}function hy(c,x,A){var E,R,U=[],P=[],W=function(k){var X=_.get(k.componentId),te=k.parameters.dragMode==="anywhere"?Bi(X).find(function(ce){return wi(ce)}):A.find(function(ce){var we;return((we=ce.prototypeId)!==null&&we!==void 0?we:ce.id)===X.id});if(!te)return"continue";if(k.kind==="swipe-input")P.push({behavior:k,c:te});else{var j=k.parameters,ae=Math.max(j.min,Math.min(j.max,Number($[j.variableId])));$[j.variableId]=ae,U.push({behavior:k,c:te,charge:Om(j,ae)}),In(Qi("holdStart",te))}};try{for(var O=ke(n.gameplay.filter(function(k){var X;return["swipe-input","hold-charge"].includes(k.kind)&&((X=_.get(k.componentId))===null||X===void 0?void 0:X.sceneId)===Y})),J=O.next();!J.done;J=O.next()){var B=J.value;W(B)}}catch(k){E={error:k}}finally{try{J&&!J.done&&(R=O.return)&&R.call(O)}finally{if(E)throw E.error}}(U.length||P.length)&&(Qe={pointerId:c.pointerId,start:x,current:x,holds:U,swipes:P})}function py(c,x){var A,E,R,U,P,W,O,J;if(!(!Qe||Qe.pointerId!==c.pointerId)){var B=Qe,k=new Set;Qe=void 0;try{for(var X=ke(Je(Je([],Ne(B.holds),!1),Ne(B.swipes),!1)),te=X.next();!te.done;te=X.next()){var j=te.value,ae=j.behavior,ce=j.c;k.has(ae.componentId)||(k.add(ae.componentId),In(Qi("pointerUp",ce,void 0,{targetId:ce.id,pointerId:c.pointerId})))}}catch(Ue){A={error:Ue}}finally{try{te&&!te.done&&(E=X.return)&&E.call(X)}finally{if(A)throw A.error}}try{for(var we=ke(B.holds),me=we.next();!me.done;me=we.next()){var Ae=me.value,ye=Ae.behavior.parameters;if(In(Qi("holdRelease",Ae.c)),ye.resetOnRelease!==!1){var ve=$[ye.variableId];$[ye.variableId]=ye.min,ve!==ye.min&&In({kind:"variableChange",variableId:ye.variableId,selfInstanceId:(O=Ae.c.instanceId)!==null&&O!==void 0?O:Ae.c.id,instanceId:Ae.c.instanceId})}}}catch(Ue){R={error:Ue}}finally{try{me&&!me.done&&(U=we.return)&&U.call(we)}finally{if(R)throw R.error}}try{for(var Ce=ke(B.swipes),ue=Ce.next();!ue.done;ue=Ce.next()){var Fe=ue.value,Oe=Fm(B.start,x,Fe.behavior.parameters.minDistancePx,(J=Fn.get(Fe.behavior.id))!==null&&J!==void 0?J:-1/0,ee*1e3,Fe.behavior.parameters.cooldownMs);Oe&&(Fn.set(Fe.behavior.id,ee*1e3),In(Qi("swipe",Fe.c,void 0,{direction:Oe})))}}catch(Ue){P={error:Ue}}finally{try{ue&&!ue.done&&(W=Ce.return)&&W.call(Ce)}finally{if(P)throw P.error}}return k}}function my(c,x,A){var E,R,U;if(A.some(function(ae){return ae.contract==="native.button.v1"&&vt(ae).enabled}))return!1;try{for(var P=ke(n.gameplay.filter(function(ae){var ce;return ae.kind==="virtual-joystick"&&((ce=_.get(ae.componentId))===null||ce===void 0?void 0:ce.sceneId)===Y})),W=P.next();!W.done;W=P.next()){var O=W.value,J=_.get(O.componentId);if(wi(J)){var B=Me.get(O.id);if(!(B&&B.pointerId!==null)){var k=oi(Dr(ui(J)),x.x,x.y),X=vt(J);if(!(k.x<0||k.y<0||k.x>X.width||k.y>X.height)){var te=O.parameters.mode==="floating"?It({},x):Ui(J),j=oh(te,x,O.parameters.radiusPx,O.parameters.deadZone);return B=It({behavior:O,c:J,pointerId:c.pointerId,origin:te,current:x},j),Me.set(O.id,B),bi(B),In(Qi("joystickStart",J)),(U=e.setPointerCapture)===null||U===void 0||U.call(e,c.pointerId),!0}}}}}catch(ae){E={error:ae}}finally{try{W&&!W.done&&(R=P.return)&&R.call(P)}finally{if(E)throw E.error}}return!1}var hm=function(c){var x,A,E,R,U,P,W,O,J,B,k,X,te;S();var j=Xf(c),ae=iu(j);if(bt=j,!(!ae&&f)){if(f){ae&&(b=ae.c.id,M((U=ae.c.prototypeId)!==null&&U!==void 0?U:ae.c.id));return}var ce=n.gameplay.some(function(dt){return dt.kind==="virtual-joystick"||dt.kind==="fps-controller-3d"});if(!(!c.isTrusted||c.button!==void 0&&c.button!==0||!ce&&c.isPrimary===!1||nt||Gt||!ce&&(st&&st.pointerId!==c.pointerId||Qe&&Qe.pointerId!==c.pointerId||ie&&ie.pointerId!==c.pointerId||Vt&&Vt.pointerId!==c.pointerId)||L&&(!yt||!it))){var we=!Mt;Le=ee,Pe=!0,Mt=!0,qf(!0),we&&!mt&&(Ge=$e=0,Aa());var me=ae?ru(ae.c):[];if(my(c,j,me)){Ge=$e=0,mt=!1,Aa(),ji();return}if(ly(c,j,me)){Aa(),ji();return}hy(c,j,me);var Ae=Nt&&!me.some(function(dt){return dt.contract==="native.button.v1"})?n.gameplay.find(function(dt){var ct;return dt.kind==="aim-launch-3d"&&((ct=_.get(dt.componentId))===null||ct===void 0?void 0:ct.sceneId)===Y}):void 0;if(Ae){var ye=_.get(Ae.componentId),ve=ii("physics-3d",ye.id),Ce=ve?Al(ye,ve):void 0,ue=Uf(ye.id),Fe=Ae.parameters.dragMode==="anywhere"||ue&&Math.hypot(j.x-ue.x,j.y-ue.y)<=Ae.parameters.hitRadiusPx;if(Ce&&Ce.atRest&&!Ce.captured&&Fe){Vt={behavior:Ae,targetId:ye.id,sourceId:ye.id,stageId:Ae.parameters.stageId,pointerId:c.pointerId,start:j,current:j,power:0},am(j),(P=e.setPointerCapture)===null||P===void 0||P.call(e,c.pointerId);return}}var Oe=me.some(function(dt){return dt.contract==="native.button.v1"&&vt(dt).enabled}),Ue=Oe||me.some(function(dt){return n.events.some(function(ct){var Bn;return ct.kind==="click"&&ct.componentId===((Bn=dt.prototypeId)!==null&&Bn!==void 0?Bn:dt.id)})});if(Nt&&!Oe){var Ze=n.gameplay.find(function(dt){var ct;return dt.kind==="fps-controller-3d"&&((ct=_.get(dt.componentId))===null||ct===void 0?void 0:ct.sceneId)===Y});if(Ze){var gt=_.get(Ze.componentId),Ft=oi(Dr(ui(gt)),j.x,j.y),Ot=vt(gt);if(xt.has(gt.id)||Ft.x>=0&&Ft.y>=0&&Ft.x<=Ot.width&&Ft.y<=Ot.height){var Ut=n.events.some(function(dt){return dt.kind==="click"&&dt.componentId===gt.id});if(!dn&&Ze.parameters.lookMode!=="none"&&(ta(Ze),dn={pointerId:c.pointerId,stageId:gt.id,behavior:Ze,last:j},(W=e.setPointerCapture)===null||W===void 0||W.call(e,c.pointerId)),Ut){Ge=$e=0,mt=!1,In({kind:"click",componentId:gt.id,targetId:gt.id,pointerId:c.pointerId}),Aa(),ji();return}if(!Ue)return}}}var Xt=n.gameplay.find(function(dt){return dt.kind==="aim-launch"&&_.get(dt.componentId).sceneId===Y&&(dt.parameters.dragMode==="anywhere"&&!me.some(function(ct){return ct.contract==="native.button.v1"})||me.some(function(ct){var Bn;return((Bn=ct.prototypeId)!==null&&Bn!==void 0?Bn:ct.id)===dt.componentId}))});if(Xt){var Bt=_.get(Xt.componentId),_t=(O=me.find(function(ct){var Bn;return((Bn=ct.prototypeId)!==null&&Bn!==void 0?Bn:ct.id)===Bt.id}))!==null&&O!==void 0?O:Bi(Bt).find(function(ct){return wi(ct)}),Ce=_t&&as(_t,ii("physics-body",Bt.id));if(Ce&&(!Xt.parameters.onlyWhenAtRest||Ce.atRest)){ie={behavior:Xt,targetId:_t.id,sourceId:Bt.id,pointerId:c.pointerId,start:j,current:j,power:0},fm(j),(J=e.setPointerCapture)===null||J===void 0||J.call(e,c.pointerId),ji();return}}try{for(var Rt=ke(me),At=Rt.next();!At.done;At=Rt.next()){var ut=At.value,Et=ii("press-feedback",(B=ut.prototypeId)!==null&&B!==void 0?B:ut.id);Et&&(ut.contract!=="native.button.v1"||vt(ut).enabled)&&Pt.set(ut.id,{behavior:Et.parameters,pointerId:c.pointerId,held:!0})}}catch(dt){x={error:dt}}finally{try{At&&!At.done&&(A=Rt.return)&&A.call(Rt)}finally{if(x)throw x.error}}var en=me.find(function(dt){var ct;return((ct=Ht.get(dt.id))===null||ct===void 0?void 0:ct.sceneId)===Y});if(en){var ot=Wt.get(en.parentId);if(ot?.snapshot().busy)return;Wg(en),ot&&!ot.snapshot().busy&&(Kt={pointerId:c.pointerId,boardId:en.parentId,tileId:en.id,start:j},(k=e.setPointerCapture)===null||k===void 0||k.call(e,c.pointerId))}on=(X=me.find(function(dt){return dt.contract==="native.button.v1"&&vt(dt).enabled}))===null||X===void 0?void 0:X.id,de=on?c.pointerId:void 0;var yn=n.gameplay.find(function(dt){return dt.kind==="drag"&&me.some(function(ct){var Bn;return((Bn=ct.prototypeId)!==null&&Bn!==void 0?Bn:ct.id)===dt.componentId})});if(yn){var ut=me.find(function(ct){var Bn;return((Bn=ct.prototypeId)!==null&&Bn!==void 0?Bn:ct.id)===yn.componentId}),fn=Ui(ut),Dn=hn.zoneOf(ut.id);An.set(ut.id,fn),hn.release(ut.id),st={b:yn,targetId:ut.id,start:j,current:j,origin:fn,originZone:Dn,m:Je([],Ne(Gr(ut)),!1),pointerId:c.pointerId},In(Qi("dragStart",ut)),e.setPointerCapture(c.pointerId)}Ge=$e=0,mt=!1;try{for(var Jt=ke(me),rn=Jt.next();!rn.done;rn=Jt.next()){var ut=rn.value;(ut.contract!=="native.button.v1"||vt(ut).enabled)&&In({kind:"click",componentId:(te=ut.prototypeId)!==null&&te!==void 0?te:ut.id,instanceId:ut.instanceId,targetId:ut.id,pointerId:c.pointerId})}}catch(dt){E={error:dt}}finally{try{rn&&!rn.done&&(R=Jt.return)&&R.call(Jt)}finally{if(E)throw E.error}}Aa(),ji()}}};function pm(c,x){if(!Kt||Kt.pointerId!==c.pointerId)return!1;if(!c.isTrusted||!jr())return!0;var A=Kt,E=Wt.get(A.boardId);if(E.snapshot().busy)return Kt=void 0,!0;var R=Dr(ui(_.get(A.boardId))),U=oi(R,A.start.x,A.start.y),P=oi(R,x.x,x.y),W=P.x-U.x,O=P.y-U.y,J=_.get(A.tileId);if(Math.max(Math.abs(W),Math.abs(O))<Math.min(J.parameters.width,J.parameters.height)*.35)return!0;var B=Ht.get(J.id),k=Math.abs(W)>Math.abs(O),X=B.row+(k?0:Math.sign(O)),te=B.column+(k?Math.sign(W):0),j=Je([],Ne(Ht),!1).find(function(ae){var ce=Ne(ae,2),we=ce[1];return we.boardId===A.boardId&&we.row===X&&we.column===te});return j&&E.swap(J.id,j[0])&&(Ct=void 0,ji()),Kt=void 0,!0}var mm=function(c){var x,A,E,R;if(!nt){S();var U=T(),P=Xf(c);bt=P,Qe?.pointerId===c.pointerId&&(Qe.current=P);var W=function(Bt){var _t,Rt;if(Bt.pointerId===c.pointerId){var At=P.x-Bt.current.x,ut=P.y-Bt.current.y;if(c.isTrusted&&jr())try{for(var Et=(_t=void 0,ke(n.gameplay.filter(function(yn){var fn,Dn;return yn.kind==="fps-controller-3d"&&yn.parameters.aimJoystickBehaviorId===Bt.behavior.id&&((fn=yn.parameters.aimMode)!==null&&fn!==void 0?fn:"delta")==="delta"&&((Dn=_.get(yn.componentId))===null||Dn===void 0?void 0:Dn.sceneId)===Y}))),en=Et.next();!en.done;en=Et.next()){var ot=en.value;Ss(ot,At,ut)}}catch(yn){_t={error:yn}}finally{try{en&&!en.done&&(Rt=Et.return)&&Rt.call(Et)}finally{if(_t)throw _t.error}}return Object.assign(Bt,{current:P},oh(Bt.origin,P,Bt.behavior.parameters.radiusPx,Bt.behavior.parameters.deadZone)),bi(Bt),ji(),{value:void 0}}};try{for(var O=ke(Me.values()),J=O.next();!J.done;J=O.next()){var B=J.value,k=W(B);if(typeof k=="object")return k.value}}catch(Bt){x={error:Bt}}finally{try{J&&!J.done&&(A=O.return)&&A.call(O)}finally{if(x)throw x.error}}if(ft?.pointerId===c.pointerId){if(ft.kind==="mask"){var X=ft,te=oi(Dr(ui(X.c)),P.x,P.y);Va(X.c,X.behavior).stampSegment(X.last,te),X.last=te}else uy(P,ft);Aa(),ji();return}if(dn?.pointerId===c.pointerId){c.isTrusted&&jr()&&(Ss(dn.behavior,P.x-dn.last.x,P.y-dn.last.y),dn.last=P,ji());return}if(Vt?.pointerId===c.pointerId){c.isTrusted&&jr()&&am(P);return}if(ie?.pointerId===c.pointerId){c.isTrusted&&jr()&&fm(P),ji();return}var j=iu(P);if(Dt=j?(E=ru(j.c).find(function(Bt){return Bt.contract==="native.button.v1"}))===null||E===void 0?void 0:E.id:void 0,!pm(c,P)&&!(!st||st.pointerId!==c.pointerId)){var ae=rt(st.targetId);if(!ae){rr();return}var ce=ae.parentId?ui(rt(ae.parentId)):Ca(),we=Dr(ce),me=oi(we,st.start.x,st.start.y),Ae=oi(we,P.x,P.y),ye=Je([],Ne(st.m),!1),ve=st.b.parameters.axis;if(ve!=="y"){var Ce=st.m[4]+Ae.x-me.x;Number.isFinite(st.b.parameters.minX)&&(Ce=Math.max(st.b.parameters.minX,Ce)),Number.isFinite(st.b.parameters.maxX)&&(Ce=Math.min(st.b.parameters.maxX,Ce)),ye[4]=Ce}if(ve!=="x"){var ue=st.m[5]+Ae.y-me.y;Number.isFinite(st.b.parameters.minY)&&(ue=Math.max(st.b.parameters.minY,ue)),Number.isFinite(st.b.parameters.maxY)&&(ue=Math.min(st.b.parameters.maxY,ue)),ye[5]=ue}if(!ae.parentId)ve!=="y"&&(ye[4]=Math.max(0,Math.min(U.width-ae.parameters.width,ye[4])));else{var Fe=mr(ae,Io(ce,ye)),Oe=0;Fe.left<0||Fe.right-Fe.left>U.width?Oe=-Fe.left:Fe.right>U.width&&(Oe=U.width-Fe.right);var Ue=ve==="y"?0:ce[0],Ze=ve==="x"?0:ce[2];Math.abs(Ue)>=Math.abs(Ze)&&Math.abs(Ue)>1e-8?ye[4]+=Oe/Ue:Math.abs(Ze)>1e-8&&(ye[5]+=Oe/Ze)}var gt=(R=Ke.get(ae.id))!==null&&R!==void 0?R:{parameters:{}};Ke.set(ae.id,It(It({},gt),{transform:ye})),st.current=P;var Ft=kf(ae),Ot=Ft.zones,Ut=Ft.tag,Xt=vu({itemId:ae.id,tag:Ut,zones:Ot,occupancy:hn});je=Xt&&Xt.kind!=="reject"?Xt.zone:void 0}}},vm=function(c){var x,A,E,R,U;S();var P=Xf(c),W=Se;bt=P,si(c.pointerId,!0),Pn(c.pointerId),dy(c);var O=(E=py(c,P))!==null&&E!==void 0?E:new Set;if(Xg(c),c.isTrusted&&jr()){var J=iu(P);try{for(var B=ke(J?ru(J.c):[]),k=B.next();!k.done;k=B.next()){var X=k.value;!O.has((R=X.prototypeId)!==null&&R!==void 0?R:X.id)&&(X.contract!=="native.button.v1"||vt(X).enabled)&&In(Qi("pointerUp",X,void 0,{targetId:X.id,pointerId:c.pointerId}))}}catch(me){x={error:me}}finally{try{k&&!k.done&&(A=B.return)&&A.call(B)}finally{if(x)throw x.error}}}if(Aa(),ji(),Vt?.pointerId===c.pointerId){var te=Vt,j=rm(),ae=Ee.get(te.targetId);(U=Nt?.getStage(_.get(te.stageId)))===null||U===void 0||U.setGuide([]),Vt=void 0,te.behavior.parameters.powerVariableId&&($[te.behavior.parameters.powerVariableId]=0);var ce=Math.hypot(j.vx,j.vz);c.isTrusted&&qf(!0),ae&&c.isTrusted&&jr()&&j.pull>=te.behavior.parameters.minPullPx&&ce>=te.behavior.parameters.minSpeed&&(ae.vx=j.vx,ae.vy=0,ae.vz=j.vz,ae.atRest=!1,ae.restElapsed=0,ae.movingTime=0,ae.captured=!1,ae.lastSafe={x:ae.x,y:ae.y,z:ae.z},In({kind:"launch",componentId:te.sourceId})),Ba(c),Aa();return}if(ie?.pointerId===c.pointerId){var te=ie,j=Yf(),ae=Tn.get(te.targetId);ie=void 0,te.behavior.parameters.powerVariableId&&($[te.behavior.parameters.powerVariableId]=0),ae&&c.isTrusted&&jr()&&j.pull>=te.behavior.parameters.minPullPx&&(ae.vx=j.vx,ae.vy=j.vy,ae.atRest=!1,ae.restElapsed=0,ae.captured=!1,ae.exited=!1,In({kind:"launch",componentId:te.sourceId,instanceId:ae.instanceId})),Ba(c),Aa(),ji();return}if(pm(c,P),Kt?.pointerId===c.pointerId&&(Kt=void 0),Ba(c),!(W?.pointerId!==c.pointerId||!c.isTrusted||!jr()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!qs(W.condition))){var we=iu(P);!we||!ru(we.c).some(function(me){return me.id===W.targetId&&(me.contract!=="native.button.v1"||vt(me).enabled)})||(L?L.openStore(n.base.storeUrl):window.open(n.base.storeUrl,"_blank","noopener"))}},au=function(c){var x,A;if(Vt?.pointerId===c.pointerId&&Si(c.pointerId),dn?.pointerId===c.pointerId&&Pn(c.pointerId),si(c.pointerId,!0),ie?.pointerId===c.pointerId&&(ie.behavior.parameters.powerVariableId&&($[ie.behavior.parameters.powerVariableId]=0),ie=void 0),Kt?.pointerId===c.pointerId&&(Kt=void 0),ft?.pointerId===c.pointerId&&(ft.kind==="stroke"&&ft.store.cancel(),ft=void 0),Qe?.pointerId===c.pointerId){try{for(var E=ke(Qe.holds),R=E.next();!R.done;R=E.next()){var U=R.value;U.behavior.parameters.resetOnRelease!==!1&&($[U.behavior.parameters.variableId]=U.behavior.parameters.min)}}catch(P){x={error:P}}finally{try{R&&!R.done&&(A=E.return)&&A.call(E)}finally{if(x)throw x.error}}Qe=void 0}Ba(c)},gm=function(c){c?.isTrusted&&!f&&!nt&&!Gt&&qf(!0)},Zf=function(){Zt||ji()},bs=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver(Zf):void 0;try{(s=bs?.observe)===null||s===void 0||s.call(bs,e)}catch{}var ym=function(){Re=0,Ye=0,document.hidden&&ea(),Ve&&(document.hidden?Ve.suspend().catch(function(){}):!nt&&Mt&&Cl())};document.addEventListener("visibilitychange",ym),(o=globalThis.addEventListener)===null||o===void 0||o.call(globalThis,"resize",Zf),e.addEventListener("pointerdown",hm),e.addEventListener("pointermove",mm),e.addEventListener("pointerup",vm),e.addEventListener("pointercancel",au),e.addEventListener("lostpointercapture",au),e.addEventListener("click",gm);var Jf=L?.onVisibilityChanged(function(c){it=c,Re=0,Ye=0,c||ea(),Ve&&(c?!nt&&Mt&&Cl():Ve.suspend().catch(function(){}))}),$f=L?.onClosed(function(){Gt=!0,Re=0,Ye=0,ea(),Rn()}),Kf=(u=L?.onVolumeChanged)===null||u===void 0?void 0:u.call(L,function(c){typeof c=="number"&&Number.isFinite(c)&&c>=0&&(bn=Math.min(1,c>1?c/100:c),Bf())});function xm(c){var x=!f&&!nt&&!document.hidden&&yt&&it&&!Gt;if(x&&Ye&&(be+=Math.min((c-Ye)/1e3,5/60)),jr()){Ge=$e=0,mt=!1,Ye&&(Re+=Math.min((c-Ye)/1e3,5/60));for(var A=0;A<5&&Re>=1/60;A++)Qg(1/60),Re-=1/60;Aa()}else Re=0;Ye=c,ji(),wn=requestAnimationFrame(xm)}return Ff(),f&&(Y=m),ji(),wn=requestAnimationFrame(xm),L&&L.init().then(function(){Zt||(yt=!0,it=L.isVisible(),Re=0,Ye=0)}).catch(function(){Zt||(Gt=!0,ea(),Rn())}),{state:ns,auditViewport:ay,auditSceneLayout:sy,restart:function(){var c;(c=L?.notifyGameRetry)===null||c===void 0||c.call(L),Ff(),ji()},select:function(c){b=c},inspectScene:function(c){f&&n.scenes.some(function(x){return x.id===c})&&(Y=c,b=void 0)},pause:function(c){nt=c,Re=0,Ye=0,c&&ea(),Ve&&(c?Ve.suspend().catch(function(){}):Mt&&Cl())},destroy:function(){var c,x;Zt=!0,cancelAnimationFrame(wn),ea(),Rn(),Nt?.dispose(),Jf?.(),$f?.(),Kf?.(),L?.destroy(),(c=bs?.disconnect)===null||c===void 0||c.call(bs),document.removeEventListener("visibilitychange",ym),(x=globalThis.removeEventListener)===null||x===void 0||x.call(globalThis,"resize",Zf),e.removeEventListener("pointerdown",hm),e.removeEventListener("pointermove",mm),e.removeEventListener("pointerup",vm),e.removeEventListener("pointercancel",au),e.removeEventListener("lostpointercapture",au),e.removeEventListener("click",gm),Ve?.close().catch(function(){})}}}return Ly(_1);})();
|