@tora-editor/tora 0.1.0 → 0.2.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 +108 -58
- package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
- package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
- package/assets/kenney-food-starter/License.txt +28 -0
- package/assets/kenney-food-starter/burger.glb +0 -0
- package/assets/kenney-food-starter/frying-pan.glb +0 -0
- package/assets/kenney-food-starter/plan.json +61 -0
- package/assets/kenney-food-starter/plate.glb +0 -0
- package/assets/kenney-food-starter/pot.glb +0 -0
- package/assets/kenney-harvest/audio/victory.wav +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
- package/bin/tora.mjs +77 -9
- package/crates/packer/trusted/native-3d-meta.json +3 -2
- package/crates/packer/trusted/native-3d.js +181 -181
- package/crates/packer/trusted/native-meta.json +2 -2
- 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 -2
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/TORA_AGENT_SETUP.md +24 -13
- package/docs/TORA_CREATION_API.md +29 -12
- package/docs/reference/CORE_AUTHORING.md +2 -1
- package/docs/reference/PLAYABLE_STARTERS.md +20 -0
- package/docs/reference/packs/3d.md +9 -3
- package/network-rules/mintegral-appgrowth-single-html.json +10 -10
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +264 -8
- package/scripts/lean/editor/review-editor.css +10 -0
- package/scripts/lean/editor/review-editor.js +117 -1
- package/scripts/lean/native/agent-tools.mjs +7 -7
- package/scripts/lean/native/api.mjs +16 -5
- package/scripts/lean/native/asset-catalog.mjs +7 -6
- package/scripts/lean/native/asset-lineage.mjs +54 -0
- package/scripts/lean/native/asset-prep.mjs +173 -40
- package/scripts/lean/native/assets.mjs +107 -11
- package/scripts/lean/native/author-expansion-proofs.mjs +2 -99
- package/scripts/lean/native/author-fps.mjs +545 -0
- package/scripts/lean/native/author-primitive-proofs.mjs +5 -4
- package/scripts/lean/native/build-cache.mjs +2 -2
- package/scripts/lean/native/cc0-inputs.mjs +24 -0
- package/scripts/lean/native/cc0-staging.mjs +28 -8
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +7 -8
- package/scripts/lean/native/check-salvage.mjs +8 -5
- package/scripts/lean/native/compiler.mjs +9 -3
- package/scripts/lean/native/contracts.mjs +11 -8
- package/scripts/lean/native/creative-qa.mjs +305 -122
- package/scripts/lean/native/demos.mjs +47 -3
- package/scripts/lean/native/document.mjs +36 -10
- package/scripts/lean/native/export-budget.mjs +75 -0
- package/scripts/lean/native/glb-loader.mjs +468 -0
- package/scripts/lean/native/intake-creator-tools.mjs +83 -30
- package/scripts/lean/native/local-bundle.mjs +5 -3
- package/scripts/lean/native/mcp-server.mjs +33 -46
- package/scripts/lean/native/media-validate.mjs +124 -0
- package/scripts/lean/native/native-bin.mjs +3 -3
- package/scripts/lean/native/outcome-playthrough.mjs +97 -0
- package/scripts/lean/native/prepare-fps-assets.mjs +330 -0
- package/scripts/lean/native/project-bundle.mjs +3 -3
- package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
- package/scripts/lean/native/review-agent-tools.mjs +2 -2
- package/scripts/lean/native/review.mjs +3 -0
- package/scripts/lean/native/runtime.mjs +242 -56
- package/scripts/lean/native/schema.mjs +7 -5
- package/scripts/lean/native/service.mjs +159 -32
- package/scripts/lean/native/stage-3d.mjs +343 -40
- package/scripts/lean/native/starters.mjs +436 -0
- package/scripts/lean/native/verify.mjs +1 -1
- package/scripts/lean/native/win-cues.mjs +96 -0
- package/skills/tora-playables/SKILL.md +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var ToraNative=(()=>{var af=Object.defineProperty;var mg=Object.getOwnPropertyDescriptor;var vg=Object.getOwnPropertyNames;var gg=Object.prototype.hasOwnProperty;var yg=(n,e)=>{for(var t in e)af(n,t,{get:e[t],enumerable:!0})},xg=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of vg(e))!gg.call(n,r)&&r!==t&&af(n,r,{get:()=>e[r],enumerable:!(i=mg(e,r))||i.enumerable});return n};var _g=n=>xg(af({},"__esModule",{value:!0}),n);var ew={};yg(ew,{computeSafeArea:()=>np,createNetworkBridge:()=>wv,layoutStandardText:()=>Tv,mountNative:()=>jb});var Pp=function(n,e){if(!n)throw Error(e)},ga=function(){return[1,0,0,1,0,0]};function sf(n){return Pp(Array.isArray(n)&&n.length===6&&n.every(Number.isFinite),"E_SCENE_MATRIX"),n}function qs(n,e){return sf(n),sf(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 wr(n){sf(n);var e=n[0]*n[3]-n[1]*n[2];return Pp(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 lf=function(){return lf=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},lf.apply(this,arguments)},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},Ts=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))},of=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 Lp(n){var e=n.rows,t=n.columns,i=n.seed,r=n.slots,a=n.paint,s=n.onEvent,o=r.map(function(fe){return fe.group}),u=Ts([],ya(new Set(o)),!1),l=Ts([],ya(o),!1),d=i,f="idle",h=0,v,y,T=[],g=[],m=0,L=0,F=0,_,p,S=function(fe,pe){return fe*t+pe},B=function(fe){return Math.floor(fe/t)},b=function(fe){return fe%t},I=function(){return d=Math.imul(d,1664525)+1013904223>>>0,d/4294967296};function z(fe){for(var pe=new Set,Fe=0;Fe<e;Fe++)for(var ae=0;ae<t;ae++){var de=S(Fe,ae),_e=fe[de];if(ae+2<t&&_e===fe[de+1]&&_e===fe[de+2])for(var Ge=0;Ge<3;Ge++)pe.add(de+Ge);if(Fe+2<e&&_e===fe[de+t]&&_e===fe[de+t*2])for(var Ge=0;Ge<3;Ge++)pe.add(de+t*Ge)}return Ts([],ya(pe),!1)}function U(fe,pe){var Fe;if(l[fe]===l[pe])return!1;var ae=Ts([],ya(l),!1);return Fe=ya([ae[pe],ae[fe]],2),ae[fe]=Fe[0],ae[pe]=Fe[1],z(ae).some(function(de){return de===fe||de===pe})}function Y(){for(var fe=[],pe=0;pe<l.length;pe++)b(pe)+1<t&&U(pe,pe+1)&&fe.push({from:r[pe].id,to:r[pe+1].id}),B(pe)+1<e&&U(pe,pe+t)&&fe.push({from:r[pe].id,to:r[pe+t].id});return fe}function E(){for(var fe=0;fe<64;fe++){l=[];for(var pe=function(ae){var de=u.filter(function(_e){return!(b(ae)>=2&&l[ae-1]===_e&&l[ae-2]===_e)&&!(B(ae)>=2&&l[ae-t]===_e&&l[ae-t*2]===_e)});l.push(de[Math.floor(I()*de.length)])},Fe=0;Fe<r.length;Fe++)pe(Fe);if(Y().length)return}l=r.map(function(ae,de){return u[(B(de)*2+b(de))%3]}),l[0]=u[0],l[1]=u[1],l[2]=u[0],l[t+1]=u[0]}function M(){for(var fe=0;fe<r.length;fe++)a(fe,l[fe],{})}function O(){d=i,l=Ts([],ya(o),!1),f="idle",h=0,v=void 0,y=void 0,T=[],g=[],m=0,L=0,F=0,_=void 0,p=void 0,(z(l).length||!Y().length)&&E(),M()}function H(fe,pe){if(f!=="idle")return!1;var Fe=r.findIndex(function(de){return de.id===fe}),ae=r.findIndex(function(de){return de.id===pe});return Fe<0||ae<0||Math.abs(B(Fe)-B(ae))+Math.abs(b(Fe)-b(ae))!==1?!1:(v=void 0,_=void 0,M(),y=[Fe,ae],f="swap",h=0,!0)}function ee(fe){if(f==="idle"){if(v===fe){v=void 0;return}if(!(v&&H(v,fe)))return v=fe,v}}function j(){T=z(l),F+=T.length,p={group:l[T[0]],from:r[T[0]].id,count:T.length},s("matchClear"),f="clear",h=0}function K(){var fe=new Set(T),pe=Ts([],ya(l),!1);g=[];for(var Fe=0;Fe<t;Fe++){for(var ae=[],de=e-1;de>=0;de--)fe.has(S(de,Fe))||ae.push(S(de,Fe));for(var _e=0,de=e-1;de>=0;de--){var Ge=S(de,Fe),$e=ae[e-1-de];$e!==void 0?(pe[Ge]=l[$e],g.push({cell:Ge,from:$e,offsetRows:0})):(pe[Ge]=u[Math.floor(I()*u.length)],g.push({cell:Ge,from:Ge,offsetRows:-(de+1+_e++)}))}}l=pe,f="fall",h=0}function re(){if(z(l).length&&m<3){m++,j();return}(z(l).length||!Y().length)&&E(),M(),f="idle",h=0,y=void 0,T=[],g=[],L++,s("validMatch")}function J(fe){var pe,Fe,ae,de,_e,Ge,$e;if(f==="idle"){if(_){_.elapsed+=fe;var ut=1+.065*Math.sin(Math.min(1,_.elapsed/.8)*Math.PI*4),zt=function(ze){a(r.findIndex(function(Ye){return Ye.id===ze}),l[r.findIndex(function(Ye){return Ye.id===ze})],{scale:ut})};try{for(var ct=of(_.ids),Tt=ct.next();!Tt.done;Tt=ct.next()){var Zt=Tt.value;zt(Zt)}}catch(ze){pe={error:ze}}finally{try{Tt&&!Tt.done&&(Fe=ct.return)&&Fe.call(ct)}finally{if(pe)throw pe.error}}_.elapsed>=.8&&(_=void 0,M())}return}if(h+=fe,f==="swap"||f==="reverse"){var wt=Math.min(1,h/.14),bt=wt*wt*(3-2*wt),_t=ya(y,2),ln=_t[0],rt=_t[1];if(a(ln,l[ln],{from:rt,progress:f==="swap"?bt:1-bt}),a(rt,l[rt],{from:ln,progress:f==="swap"?bt:1-bt}),wt<1)return;if(f==="reverse"){M(),f="idle",y=void 0,s("invalidMatch");return}if(!U(ln,rt)){f="reverse",h=0;return}ae=ya([l[rt],l[ln]],2),l[ln]=ae[0],l[rt]=ae[1],M(),j();return}if(f==="clear"){var an=Math.min(1,h/.18),ut=an<.22?1+an*.45:Math.max(.05,1.1*(1-an)/.78);try{for(var se=of(T),mn=se.next();!mn.done;mn=se.next()){var nn=mn.value;a(nn,l[nn],{scale:ut,opacity:1-an})}}catch(Ye){de={error:Ye}}finally{try{mn&&!mn.done&&(_e=se.return)&&_e.call(se)}finally{if(de)throw de.error}}an===1&&K();return}var W=Math.min(1,h/.25),w=1-Math.pow(1-W,3);try{for(var ue=of(g),ye=ue.next();!ye.done;ye=ue.next()){var we=ye.value;a(we.cell,l[we.cell],{from:we.from,offsetRows:we.offsetRows,progress:1-w})}}catch(ze){Ge={error:ze}}finally{try{ye&&!ye.done&&($e=ue.return)&&$e.call(ue)}finally{if(Ge)throw Ge.error}}W===1&&re()}function ne(){if(f==="idle"){v=void 0;var fe=Y()[0];fe&&(_={ids:[fe.from,fe.to],elapsed:0})}}function Te(){var fe;return{phase:f,busy:f!=="idle",selected:v??null,moves:L,cleared:F,groups:Ts([],ya(l),!1),legalMoves:f==="idle"?Y():[],hint:(fe=_?.ids)!==null&&fe!==void 0?fe:[],lastMatch:p?lf({},p):null}}return{reset:O,select:ee,swap:H,tick:J,showHint:ne,snapshot:Te,cancelSelection:function(){v=void 0,_&&(_=void 0,M())}}}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)},Dp=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},Mg=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))},Np=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 Up(){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 Mg([],Dp((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 wc(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 T,g,m;return y.id!==i&&(((g=(T=y.acceptTags)===null||T===void 0?void 0:T.length)!==null&&g!==void 0?g:0)===0||((m=y.acceptTags)===null||m===void 0?void 0:m.includes(a)))});u.sort(function(y,T){return Number(T.itemTarget)-Number(y.itemTarget)||T.paintOrder-y.paintOrder||y.distance-T.distance||y.id.localeCompare(T.id)});try{for(var l=Np(u),d=l.next();!d.done;d=l.next()){var f=d.value,h=o.items(f.id).filter(function(y){return y!==i}),v=f.capacity>0&&h.length>=f.capacity;return f.snapMode==="reject"?{kind:"reject",zone:f,occupantId:h[0]}:v?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 Fp(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 Op(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 Bp(){var n=new Map;return{to:function(e,t,i,r,a){r===void 0&&(r=.18),n.set(e,{from:bc({},t),to:bc({},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=Np(n),o=s.next();!o.done;o=s.next()){var u=Dp(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(v){i={error:v}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}}}}function cf(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,v=n.y+f*u;if(l<=i)return{nx:0,ny:0,magnitude:0,angle:0,knobX:h,knobY:v};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:v}}var uf=function(){return uf=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},uf.apply(this,arguments)},kp=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 zp(n){var e,t,i=2166136261;try{for(var r=kp(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 Sg(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 Vp(n,e,t,i,r){var a,s;i===void 0&&(i=0);var o=null,u=1/0;try{for(var l=kp(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(v){a={error:v}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}return o}function Gp(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 Hp(n){var e=Sg(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?uf({},a):void 0}}}function Wp(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,v=s.canvasFactory,y=s.source,T=n,g=T.gridSize,m=new Uint8Array(g*g),L=0,F=!1,_=-1,p=!1,S=Math.max(1,o),B=Math.max(1,u),b=Math.min(1,512/Math.max(S,B)),I=(t=v?.())!==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(S*b)),I.height=Math.max(1,Math.round(B*b)));var z=(r=I?.getContext)===null||r===void 0?void 0:r.call(I,"2d"),U=(a=T.maskColor)!==null&&a!==void 0?a:"#dceeff",Y=function(){return!!(y&&y.complete&&y.naturalWidth>0)},E=function(){z&&(z.globalCompositeOperation="source-over",z.clearRect(0,0,I.width,I.height),T.mode==="erase"&&(Y()?(z.drawImage(y,0,0,I.width,I.height),p=!0):(z.fillStyle=U,z.fillRect(0,0,I.width,I.height),p=!1)))};E();var M=function(){if(!F){var H=Math.round(L/m.length*100),ee=Math.min(100,H);ee!==_&&(_=ee,d(ee)),ee>=T.targetPercent&&(F=!0,h(ee))}},O=function(H,ee){for(var j=Math.max(0,Math.min(g-1,Math.floor(H/S*g))),K=Math.max(0,Math.min(g-1,Math.floor(ee/B*g))),re=Math.max(0,Math.ceil(T.brushRadiusPx/S*g)),J=Math.max(0,Math.ceil(T.brushRadiusPx/B*g)),ne=Math.max(0,K-J);ne<=Math.min(g-1,K+J);ne++)for(var Te=Math.max(0,j-re);Te<=Math.min(g-1,j+re);Te++)if(!(Math.hypot((Te+.5)/g*S-H,(ne+.5)/g*B-ee)>T.brushRadiusPx)){var fe=ne*g+Te;m[fe]||(m[fe]=1,L++)}z&&(z.save(),z.scale(b,b),z.globalCompositeOperation=T.mode==="erase"?"destination-out":"source-over",z.fillStyle=U,z.beginPath(),z.arc(H,ee,T.brushRadiusPx,0,Math.PI*2),z.fill(),T.mode==="reveal"&&y&&(z.globalCompositeOperation="source-in",z.drawImage(y,0,0,S,B)),z.restore()),M()};return{canvas:I,stampSegment:function(H,ee){for(var j=Math.hypot(ee.x-H.x,ee.y-H.y),K=Math.max(1,Math.ceil(j/Math.max(1,T.brushRadiusPx*.45))),re=0;re<=K;re++)O(H.x+(ee.x-H.x)*re/K,H.y+(ee.y-H.y)*re/K)},reset:function(){m.fill(0),L=0,F=!1,_=-1,E(),M()},get progress(){return Math.round(L/m.length*100)},render:function(H){T.mode==="erase"&&L===0&&!p&&Y()&&E(),I?H.drawImage(I,0,0,I.width,I.height,0,0,o,u):T.mode==="erase"&&this.progress<100&&(H.save(),H.globalAlpha=1-this.progress/100,H.fillStyle=U,H.fillRect(0,0,o,u),H.restore())}}}var Es=function(){return Es=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},Es.apply(this,arguments)},bg=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 df(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 Xp(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 Yp(n,e,t){if(t.length>=3&&(Xp(n,t)||Xp(e,t)))return!0;for(var i=0;i<t.length;i++)if(df(n,e,t[i],t[(i+1)%t.length]))return!0;return!1}function qp(n){var e=n,t=[],i=null,r=0,a=function(s){return Es(Es({},s),{points:s.points.map(function(o){return Es({},o)})})};return{begin:function(s){var o={id:++r,points:[Es({},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(Es({},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=bg(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 Zp(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 jo=function(){return jo=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},jo.apply(this,arguments)},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},ts=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.")},wg=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))},Ba=function(n,e){return Math.hypot(n,e)},Jp=function(n,e,t){return Math.max(e,Math.min(t,n))},As=function(n){return Math.max(1,Math.min(n.width,n.height)/2)};function $p(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=em(o,2),l=u[0],d=u[1];return{x:n.x+l*i-d*r,y:n.y+l*r+d*i}})}function Tg(n,e){var t,i,r,a,s,o,u,l,d,f,h=$p(n),v=$p(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],T=1/0,g=1,m=0;try{for(var L=ts(y),F=L.next();!F.done;F=L.next()){var _=F.value,p=Math.cos(_),S=Math.sin(_),B=1/0,b=-1/0,I=1/0,z=-1/0;try{for(var U=(r=void 0,ts(h)),Y=U.next();!Y.done;Y=U.next()){var E=Y.value,M=E.x*p+E.y*S;M<B&&(B=M),M>b&&(b=M)}}catch(j){r={error:j}}finally{try{Y&&!Y.done&&(a=U.return)&&a.call(U)}finally{if(r)throw r.error}}try{for(var O=(s=void 0,ts(v)),H=O.next();!H.done;H=O.next()){var E=H.value,M=E.x*p+E.y*S;M<I&&(I=M),M>z&&(z=M)}}catch(j){s={error:j}}finally{try{H&&!H.done&&(o=O.return)&&o.call(O)}finally{if(s)throw s.error}}var ee=Math.min(b,z)-Math.max(B,I);if(ee<=0)return null;ee<T&&(T=ee,g=p,m=S)}}catch(j){t={error:j}}finally{try{F&&!F.done&&(i=L.return)&&i.call(L)}finally{if(t)throw t.error}}return(n.x-e.x)*g+(n.y-e.y)*m<0&&(g=-g,m=-m),{nx:g,ny:m,penetration:T}}function Kp(n,e){var t,i,r,a=As(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,v=e.width/2,y=e.height/2,T=Jp(f,-v,v),g=Jp(h,-y,y),m=f-T,L=h-g,F=Ba(m,L),_;if(F>=a)return null;if(F<1e-4){var p=[{d:v-Math.abs(f),x:f>=0?1:-1,y:0},{d:y-Math.abs(h),x:0,y:h>=0?1:-1}].sort(function(b,I){return b.d-I.d});m=p[0].x,L=p[0].y,_=a+p[0].d}else m/=F,L/=F,_=a-F;var S=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:m*S-L*B,ny:m*B+L*S,penetration:_}}function Qp(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 jp(n,e,t){var i,r,a,s,o,u;if(!(n.captured||e.captured||Qp(n,e)||Qp(e,n))){var l=n.x-e.x,d=n.y-e.y,f;if(n.shape==="circle"&&e.shape==="circle"){var h=Ba(l,d),v=As(n)+As(e)-h;if(v<=0)return;f=v,h>1e-4?(l/=h,d/=h):(l=1,d=0)}else if(n.shape==="circle"&&e.shape==="box"){var y=Kp(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="circle"){var y=Kp(e,n);if(!y)return;l=-y.nx,d=-y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="box"){var y=Tg(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else return;var T=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,m=T+g;if(m){n.x+=l*f*T/m,n.y+=d*f*T/m,e.mode==="dynamic"&&(e.x-=l*f*g/m,e.y-=d*f*g/m);var L=n.vx-((a=e.vx)!==null&&a!==void 0?a:0),F=n.vy-((s=e.vy)!==null&&s!==void 0?s:0),_=L*l+F*d;if(!(_>=0)){var p=Math.max((o=n.restitution)!==null&&o!==void 0?o:0,(u=e.restitution)!==null&&u!==void 0?u:0),S=-(1+p)*_/m;n.vx+=l*S*T,n.vy+=d*S*T,e.mode==="dynamic"&&(e.vx-=l*S*g,e.vy-=d*S*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 Eg(n,e,t,i){var r,a;if(!(n.mode!=="dynamic"||n.captured))try{for(var s=ts(e),o=s.next();!o.done;o=s.next()){var u=o.value,l=u.x-n.x,d=u.y-n.y,f=Ba(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&&Ba(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(v){r={error:v}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}}function Ag(n,e){var t,i,r,a,s,o,u=function(h){if(h.broken)return"continue";var v=e.find(function(B){return B.id===h.bodyId}),y=e.find(function(B){return B.id===h.anchorId});if(!v||v.mode!=="dynamic")return"continue";var T=(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,m=v.x-T,L=v.y-g,F=Ba(m,L);if(F<=h.lengthPx||F<1e-4)return"continue";var _=m/F,p=L/F;v.x=T+_*h.lengthPx,v.y=g+p*h.lengthPx;var S=v.vx*_+v.vy*p;S>0&&(v.vx-=_*S,v.vy-=p*S)};try{for(var l=ts(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 ff(n){for(var e,t,i,r,a,s,o,u,l,d,f,h=n.bodies,v=n.zones,y=v===void 0?[]:v,T=n.joints,g=T===void 0?[]:T,m=n.bounds,L=n.dt,F=n.onEvent,_=F===void 0?function(){}:F,p=h.filter(function(ae){return ae.mode==="dynamic"&&!ae.captured}),S=p.reduce(function(ae,de){return Math.max(ae,Ba(de.vx,de.vy))},0),B=p.reduce(function(ae,de){return Math.min(ae,As(de))},24),b=Math.min(16,Math.max(1,Math.ceil(S*L/(B*.45)))),I=L/b,z=0;z<b;z++){try{for(var U=(e=void 0,ts(p)),Y=U.next();!Y.done;Y=U.next()){var E=Y.value;E.vy+=((o=E.gravity)!==null&&o!==void 0?o:0)*I;var M=Ba(E.vx,E.vy);if(M>E.maxSpeed){var O=E.maxSpeed/M;E.vx*=O,E.vy*=O,M=E.maxSpeed}E.x+=E.vx*I,E.y+=E.vy*I;var H=Math.max(0,M-((u=E.friction)!==null&&u!==void 0?u:0)*I),ee=Math.exp(-((l=E.linearDamping)!==null&&l!==void 0?l:0)*I);if(M>1e-4){var j=H/M*ee;E.vx*=j,E.vy*=j}E.spinToRotation&&(E.angle=((d=E.angle)!==null&&d!==void 0?d:0)+Ba(E.vx,E.vy)*I/As(E)*(E.vx<0?-1:1))}}catch(ae){e={error:ae}}finally{try{Y&&!Y.done&&(t=U.return)&&t.call(U)}finally{if(e)throw e.error}}for(var K=0;K<p.length;K++){var E=p[K];try{for(var re=(i=void 0,ts(h)),J=re.next();!J.done;J=re.next()){var ne=J.value;ne.id!==E.id&&ne.mode!=="dynamic"&&jp(E,ne,_)}}catch(de){i={error:de}}finally{try{J&&!J.done&&(r=re.return)&&r.call(re)}finally{if(i)throw i.error}}for(var ne=K+1;ne<p.length;ne++)jp(p[ne],E,_);var Te=E.shape==="box"?E.width/2:As(E),fe=E.shape==="box"?E.height/2:As(E);E.wallBounce?(E.x-Te<m.left&&(E.x=m.left+Te,E.vx<0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vx)}),E.vx=-E.vx*E.restitution)),E.x+Te>m.right&&(E.x=m.right-Te,E.vx>0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vx)}),E.vx=-E.vx*E.restitution)),E.y-fe<m.top&&(E.y=m.top+fe,E.vy<0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vy)}),E.vy=-E.vy*E.restitution)),E.y+fe>m.bottom&&(E.y=m.bottom-fe,E.vy>0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vy)}),E.vy=-E.vy*E.restitution))):!E.exited&&(E.x+Te<m.left||E.x-Te>m.right||E.y+fe<m.top||E.y-fe>m.bottom)&&(E.exited=!0,_("boundaryExit",E,null,{})),Eg(E,y,I,_)}Ag(g,h)}try{for(var pe=ts(p),Fe=pe.next();!Fe.done;Fe=pe.next()){var E=Fe.value,M=Ba(E.vx,E.vy);M<E.restSpeed&&!E.captured?(E.restElapsed=((f=E.restElapsed)!==null&&f!==void 0?f:0)+L,E.restElapsed>=E.restDelaySeconds&&!E.atRest&&(E.atRest=!0,E.vx=0,E.vy=0,_("bodyRest",E,null,{}))):M>=E.restSpeed&&(E.restElapsed=0,E.atRest=!1)}}catch(ae){a={error:ae}}finally{try{Fe&&!Fe.done&&(s=pe.return)&&s.call(pe)}finally{if(a)throw a.error}}}function tm(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(F){return jo({},F)},f=d(e),h=t.filter(function(F){return F.id!==e.id}).map(d),v=wg([f],em(h),!1),y=[],T=0,g=!1,m=function(F,_,p,S){F==="bodyBounce"&&S.sourceId===e.id&&T++,F==="zoneCapture"&&S.sourceId===e.id&&(g=!0)},L=0;L<90&&y.length<o&&!g&&T<=l;L++)ff({bodies:v,zones:r,bounds:a,dt:1/60,onEvent:function(F,_,p,S){return m(F,_,p,jo(jo({},S),{sourceId:_.id}))}}),L%Math.max(1,Math.floor(90/o))===0&&y.push({x:f.x,y:f.y});return y}var Zs=function(){return Zs=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},Zs.apply(this,arguments)},el=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.")},im=.008333333333333333;function Js(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 nm(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,v=-l*d+u*f,y=Math.max(-e.hx,Math.min(e.hx,h)),T=Math.max(-e.hz,Math.min(e.hz,v)),g=h-y,m=v-T,L=Math.hypot(g,m),F=Js(n,n.x,n.z);if(!(L>=o||F!==null&&n.y>F+.55)){L<1e-8?e.hx-Math.abs(h)<e.hz-Math.abs(v)?(g=h<0?-1:1,m=0,L=0):(g=0,m=v<0?-1:1,L=0):(g/=L,m/=L);var _=u*g-l*m,p=l*g+u*m;n.x+=_*(o-L+1e-5),n.z+=p*(o-L+1e-5);var S=(r=e.vx)!==null&&r!==void 0?r:0,B=(a=e.vz)!==null&&a!==void 0?a:0,b=(n.vx-S)*_+(n.vz-B)*p;if(b<0){var I=1+((s=n.restitution)!==null&&s!==void 0?s:.72);n.vx-=I*b*_,n.vz-=I*b*p,Math.abs(b)>.3&&t>0&&i&&i("bodyBounce",n,e.sourceId?e:void 0)}}}function rm(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 hf(n,e){n.x=n.lastSafe.x,n.y=n.lastSafe.y,n.z=n.lastSafe.z,rm(n,e)}function pf(n){var e,t,i,r,a,s,o,u,l,d,f,h,v,y,T,g,m,L,F=n.bodies,_=n.walls,p=n.zones,S=n.dt,B=n.onEvent;if(!(!Number.isFinite(S)||S<=0))for(var b=Math.max(1,Math.round(S/im)),I=S/b,z=0;z<b;z++)try{for(var U=(e=void 0,el(F)),Y=U.next();!Y.done;Y=U.next()){var E=Y.value;if(!(E.mode!=="dynamic"||E.captured)&&!E.atRest){var M=(l=E.boundsX)!==null&&l!==void 0?l:3,O=(d=E.boundsZ)!==null&&d!==void 0?d:7;if(E.y<-3||Math.abs(E.x)>M+2||Math.abs(E.z)>O+2){hf(E,B);continue}E.movingTime=((f=E.movingTime)!==null&&f!==void 0?f:0)+I;var H=E.radius,ee=Math.hypot(E.vx,E.vy,E.vz),j=Math.max(1,Math.min(16,Math.ceil(ee*I/(H*.45)))),K=I/j;(!E._perimeter||E._pbx!==M||E._pbz!==O)&&(E._pbx=M,E._pbz=O,E._perimeter=[{x:-(M+.1),z:0,hx:.1,hz:O+.1,angle:0,vx:0,vz:0},{x:M+.1,z:0,hx:.1,hz:O+.1,angle:0,vx:0,vz:0},{x:0,z:-(O+.1),hx:M+.1,hz:.1,angle:0,vx:0,vz:0},{x:0,z:O+.1,hx:M+.1,hz:.1,angle:0,vx:0,vz:0}]);for(var re=E._perimeter,J=!1,ne=0;ne<j;ne++){var Te=Js(E,E.x,E.z),fe=Te!==null&&E.y<=Te+H+.012&&E.vy<=.1,pe=Te;if(fe){E.y=Te+H,E.vy=0;var Fe=Math.hypot(E.vx,E.vz),ae=Math.max(0,Fe-((h=E.friction)!==null&&h!==void 0?h:1.05)*K);if(Fe>0&&(E.vx*=ae/Fe,E.vz*=ae/Fe),E.ramp&&E.z<1&&E.z>-1){var de=((v=E.rampHeight)!==null&&v!==void 0?v:1.1)*.5;E.vz+=9.81*de/(1+de*de)*K}}else E.vy-=9.81*K,E.airborne||(E.airborne=!0,B&&B("bodyJump",E));E.x+=E.vx*K,E.z+=E.vz*K,E.y+=E.vy*K;var _e=Js(E,E.x,E.z);if(_e!==null){if(fe&&pe!==null){var de=((y=E.rampHeight)!==null&&y!==void 0?y:1.1)*.5;E.ramp&&E.z<=-1&&E.z-E.vz*K>-1.5&&E.vz<-.8?(E.vy=-E.vz*de,E.airborne=!0,B&&B("bodyJump",E)):E.y=_e+H}E.y<_e+H&&(E.y=_e+H,E.vy=0,E.airborne=!1)}if(E.y<2){try{for(var Ge=(i=void 0,el(_)),$e=Ge.next();!$e.done;$e=Ge.next()){var ut=$e.value;nm(E,ut,K,B)}}catch(rt){i={error:rt}}finally{try{$e&&!$e.done&&(r=Ge.return)&&r.call(Ge)}finally{if(i)throw i.error}}try{for(var zt=(a=void 0,el(re)),ct=zt.next();!ct.done;ct=zt.next()){var ut=ct.value;nm(E,ut,K,B)}}catch(rt){a={error:rt}}finally{try{ct&&!ct.done&&(s=zt.return)&&s.call(zt)}finally{if(a)throw a.error}}}E.spin=((T=E.spin)!==null&&T!==void 0?T:0)+Math.hypot(E.vx,E.vz)*K/H;var Tt=Math.hypot(E.vx,E.vz);try{for(var Zt=(o=void 0,el(p)),wt=Zt.next();!wt.done;wt=Zt.next()){var bt=wt.value,_t=Math.hypot(E.x-bt.x,E.z-bt.z);if(_t<bt.radius&&Math.abs(E.y-(bt.y+H))<bt.heightTolerance&&Tt<bt.maxCaptureSpeed){E.captured=!0,E.captureElapsed=0,E.captureTarget={x:bt.x,y:bt.y,z:bt.z},E.vx=0,E.vy=0,E.vz=0,E.atRest=!0,B&&B("zoneCapture",E,bt),J=!0;break}}}catch(rt){o={error:rt}}finally{try{wt&&!wt.done&&(u=Zt.return)&&u.call(Zt)}finally{if(o)throw o.error}}if(J)break;if(E.y<-3||Math.abs(E.x)>M+2||Math.abs(E.z)>O+2){hf(E,B),J=!0;break}}if(!J){var ln=Math.hypot(E.vx,E.vy,E.vz);ln<((g=E.restSpeed)!==null&&g!==void 0?g:.07)?(E.restElapsed=((m=E.restElapsed)!==null&&m!==void 0?m:0)+I,E.restElapsed>((L=E.restDelaySeconds)!==null&&L!==void 0?L:.25)&&rm(E,B)):E.restElapsed=0,E.movingTime>18&&hf(E,B)}}}}catch(rt){e={error:rt}}finally{try{Y&&!Y.done&&(t=U.return)&&t.call(U)}finally{if(e)throw e.error}}}function am(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=Zs(Zs({},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 Zs(Zs({},L),{vx:0,vz:0})}),v=[f],y={bodies:v,walls:h,zones:r,dt:im},T=[],g=Math.max(18,u*6),m=0;m<g&&(pf(y),m%6===0&&T.push({x:f.x,y:f.y,z:f.z}),!(f.atRest||f.captured));m++);return T}function mf(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),v=0;v<2;v++){try{for(var y=(s=void 0,el(i)),T=y.next();!T.done;T=y.next()){var g=T.value,m=Math.cos((u=g.angle)!==null&&u!==void 0?u:0),L=Math.sin((l=g.angle)!==null&&l!==void 0?l:0),F=d-g.x,_=f-g.z,p=m*F+L*_,S=-L*F+m*_,B=Math.max(-g.hx,Math.min(g.hx,p)),b=Math.max(-g.hz,Math.min(g.hz,S)),I=p-B,z=S-b,U=Math.hypot(I,z);if(!(U>=h)){U<1e-8?g.hx-Math.abs(p)<g.hz-Math.abs(S)?(I=p<0?-1:1,z=0):(I=0,z=S<0?-1:1):(I/=U,z/=U);var Y=m*I-L*z,E=L*I+m*z;d+=Y*(h-U+1e-4),f+=E*(h-U+1e-4)}}}catch(H){s={error:H}}finally{try{T&&!T.done&&(o=y.return)&&o.call(y)}finally{if(s)throw s.error}}var M=Math.max(0,(r??12)-h),O=Math.max(0,(a??12)-h);d=Math.max(-M,Math.min(M,d)),f=Math.max(-O,Math.min(O,f))}return{x:d,z:f}}var Bm=0,jf=1,km=2;var kl=1,Du=2,Eo=3,ms=0,pr=1,Ir=2,Aa=0,Ao=1,eh=2,th=3,nh=4,zm=5;var Fs=100,Vm=101,Gm=102,Hm=103,Wm=104,Xm=200,Ym=201,qm=202,Zm=203,ih=204,rh=205,Jm=206,$m=207,Km=208,Qm=209,jm=210,e0=211,t0=212,n0=213,i0=214,Jc=0,$c=1,Kc=2,ho=3,Qc=4,jc=5,eu=6,tu=7,Nu=0,r0=1,a0=2,aa=0,ah=1,sh=2,oh=3,lh=4,ch=5,uh=6,dh=7;var fh=300,vs=301,Os=302,Uu=303,Fu=304,zl=306,nu=1e3,_a=1001,iu=1002,Bi=1003,s0=1004;var Vl=1005;var Hi=1006,Ou=1007;var gs=1008;var Cr=1009,hh=1010,ph=1011,Io=1012,Bu=1013,sa=1014,Yr=1015,oa=1016,ku=1017,zu=1018,Co=1020,mh=35902,vh=35899,gh=1021,yh=1022,qr=1023,Ma=1026,ys=1027,Vu=1028,Gu=1029,xs=1030,Hu=1031;var Wu=1033,Gl=33776,Hl=33777,Wl=33778,Xl=33779,Xu=35840,Yu=35841,qu=35842,Zu=35843,Ju=36196,$u=37492,Ku=37496,Qu=37488,ju=37489,Yl=37490,ed=37491,td=37808,nd=37809,id=37810,rd=37811,ad=37812,sd=37813,od=37814,ld=37815,cd=37816,ud=37817,dd=37818,fd=37819,hd=37820,pd=37821,md=36492,vd=36494,gd=36495,yd=36283,xd=36284,ql=36285,_d=36286;var dl=2300,ru=2301,qc=2302,Gf=2303,Hf=2400,Wf=2401,Xf=2402;var o0=3200;var Md=0,l0=1,Ya="",hr="srgb",fl="srgb-linear",hl="linear",Jn="srgb";var Zc=7680;var c0=519,u0=512,d0=513,f0=514,Sd=515,h0=516,p0=517,bd=518,m0=519,v0=35044;var xh="300 es",ra=2e3,po=2001;function Ig(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Cg(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function pl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function g0(){let n=pl("canvas");return n.style.display="block",n}var sm={},mo=null;function _h(...n){let e="THREE."+n.shift();mo?mo("log",e,...n):console.log(e,...n)}function y0(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 rn(...n){n=y0(n);let e="THREE."+n.shift();if(mo)mo("warn",e,...n);else{let t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function sn(...n){n=y0(n);let e="THREE."+n.shift();if(mo)mo("error",e,...n);else{let t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Ls(...n){let e=n.join(" ");e in sm||(sm[e]=!0,rn(...n))}function x0(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 _0={[Jc]:$c,[Kc]:eu,[Qc]:tu,[ho]:jc,[$c]:Jc,[eu]:Kc,[tu]:Qc,[jc]:ho},Sa=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}}},Qi=["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 vf=Math.PI/180,au=180/Math.PI;function Ro(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Qi[n&255]+Qi[n>>8&255]+Qi[n>>16&255]+Qi[n>>24&255]+"-"+Qi[e&255]+Qi[e>>8&255]+"-"+Qi[e>>16&15|64]+Qi[e>>24&255]+"-"+Qi[t&63|128]+Qi[t>>8&255]+"-"+Qi[t>>16&255]+Qi[t>>24&255]+Qi[i&255]+Qi[i>>8&255]+Qi[i>>16&255]+Qi[i>>24&255]).toLowerCase()}function Tn(n,e,t){return Math.max(e,Math.min(t,n))}function Rg(n,e){return(n%e+e)%e}function gf(n,e,t){return(1-t)*n+t*e}function tl(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 Tr(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 Eh=class Eh{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=Tn(this.x,e.x,t.x),this.y=Tn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Tn(this.x,e,t),this.y=Tn(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Tn(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(Tn(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}};Eh.prototype.isVector2=!0;var kt=Eh,ba=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],v=a[s+1],y=a[s+2],T=a[s+3];if(f!==T||u!==h||l!==v||d!==y){let g=u*h+l*v+d*y+f*T;g<0&&(h=-h,v=-v,y=-y,T=-T,g=-g);let m=1-o;if(g<.9995){let L=Math.acos(g),F=Math.sin(L);m=Math.sin(m*L)/F,o=Math.sin(o*L)/F,u=u*m+h*o,l=l*m+v*o,d=d*m+y*o,f=f*m+T*o}else{u=u*m+h*o,l=l*m+v*o,d=d*m+y*o,f=f*m+T*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],v=a[s+2],y=a[s+3];return e[t]=o*y+d*f+u*v-l*h,e[t+1]=u*y+d*h+l*f-o*v,e[t+2]=l*y+d*v+o*h-u*f,e[t+3]=d*y-o*f-u*h-l*v,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),v=u(r/2),y=u(a/2);switch(s){case"XYZ":this._x=h*d*f+l*v*y,this._y=l*v*f-h*d*y,this._z=l*d*y+h*v*f,this._w=l*d*f-h*v*y;break;case"YXZ":this._x=h*d*f+l*v*y,this._y=l*v*f-h*d*y,this._z=l*d*y-h*v*f,this._w=l*d*f+h*v*y;break;case"ZXY":this._x=h*d*f-l*v*y,this._y=l*v*f+h*d*y,this._z=l*d*y+h*v*f,this._w=l*d*f-h*v*y;break;case"ZYX":this._x=h*d*f-l*v*y,this._y=l*v*f+h*d*y,this._z=l*d*y-h*v*f,this._w=l*d*f+h*v*y;break;case"YZX":this._x=h*d*f+l*v*y,this._y=l*v*f+h*d*y,this._z=l*d*y-h*v*f,this._w=l*d*f-h*v*y;break;case"XZY":this._x=h*d*f-l*v*y,this._y=l*v*f-h*d*y,this._z=l*d*y+h*v*f,this._w=l*d*f+h*v*y;break;default:rn("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 v=.5/Math.sqrt(h+1);this._w=.25/v,this._x=(d-u)*v,this._y=(a-l)*v,this._z=(s-r)*v}else if(i>o&&i>f){let v=2*Math.sqrt(1+i-o-f);this._w=(d-u)/v,this._x=.25*v,this._y=(r+s)/v,this._z=(a+l)/v}else if(o>f){let v=2*Math.sqrt(1+o-i-f);this._w=(a-l)/v,this._x=(r+s)/v,this._y=.25*v,this._z=(u+d)/v}else{let v=2*Math.sqrt(1+f-i-o);this._w=(s-r)/v,this._x=(a+l)/v,this._y=(u+d)/v,this._z=.25*v}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(Tn(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}},Ah=class Ah{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(om.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(om.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=Tn(this.x,e.x,t.x),this.y=Tn(this.y,e.y,t.y),this.z=Tn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Tn(this.x,e,t),this.y=Tn(this.y,e,t),this.z=Tn(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Tn(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 yf.copy(this).projectOnVector(e),this.sub(yf)}reflect(e){return this.sub(yf.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(Tn(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}};Ah.prototype.isVector3=!0;var ge=Ah,yf=new ge,om=new ba,Ih=class Ih{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],v=i[5],y=i[8],T=r[0],g=r[3],m=r[6],L=r[1],F=r[4],_=r[7],p=r[2],S=r[5],B=r[8];return a[0]=s*T+o*L+u*p,a[3]=s*g+o*F+u*S,a[6]=s*m+o*_+u*B,a[1]=l*T+d*L+f*p,a[4]=l*g+d*F+f*S,a[7]=l*m+d*_+f*B,a[2]=h*T+v*L+y*p,a[5]=h*g+v*F+y*S,a[8]=h*m+v*_+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,v=l*a-s*u,y=t*f+i*h+r*v;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let T=1/y;return e[0]=f*T,e[1]=(r*l-d*i)*T,e[2]=(o*i-r*s)*T,e[3]=h*T,e[4]=(d*t-r*u)*T,e[5]=(r*a-o*t)*T,e[6]=v*T,e[7]=(i*u-l*t)*T,e[8]=(s*t-i*a)*T,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 Ls("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(xf.makeScale(e,t)),this}rotate(e){return Ls("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(xf.makeRotation(-e)),this}translate(e,t){return Ls("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(xf.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)}};Ih.prototype.isMatrix3=!0;var un=Ih,xf=new un,lm=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),cm=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pg(){let n={enabled:!0,workingColorSpace:fl,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Jn&&(r.r=Wa(r.r),r.g=Wa(r.g),r.b=Wa(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===Jn&&(r.r=uo(r.r),r.g=uo(r.g),r.b=uo(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===Ya?hl: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 Ls("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return Ls("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({[fl]:{primaries:e,whitePoint:i,transfer:hl,toXYZ:lm,fromXYZ:cm,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:hr},outputColorSpaceConfig:{drawingBufferColorSpace:hr}},[hr]:{primaries:e,whitePoint:i,transfer:Jn,toXYZ:lm,fromXYZ:cm,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:hr}}}),n}var Ln=Pg();function Wa(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function uo(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var $s,su=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{$s===void 0&&($s=pl("canvas")),$s.width=e.width,$s.height=e.height;let r=$s.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=$s}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=pl("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]=Wa(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(Wa(t[i]/255)*255):t[i]=Wa(t[i]);return{data:t,width:e.width,height:e.height}}else return rn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Lg=0,vo=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Lg++}),this.uuid=Ro(),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(_f(r[s].image)):a.push(_f(r[s]))}else a=_f(r);i.url=a}return t||(e.images[this.uuid]=i),i}};function _f(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?su.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(rn("Texture: Unable to serialize Texture."),{})}var Dg=0,Mf=new ge,tr=class n extends Sa{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=_a,r=_a,a=Hi,s=gs,o=qr,u=Cr,l=n.DEFAULT_ANISOTROPY,d=Ya){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Dg++}),this.uuid=Ro(),this.name="",this.source=new vo(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 kt(0,0),this.repeat=new kt(1,1),this.center=new kt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,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(Mf).x}get height(){return this.source.getSize(Mf).y}get depth(){return this.source.getSize(Mf).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){rn(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){rn(`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!==fh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nu:e.x=e.x-Math.floor(e.x);break;case _a:e.x=e.x<0?0:1;break;case iu: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 nu:e.y=e.y-Math.floor(e.y);break;case _a:e.y=e.y<0?0:1;break;case iu: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=fh;tr.DEFAULT_ANISOTROPY=1;var Ch=class Ch{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],v=u[5],y=u[9],T=u[2],g=u[6],m=u[10];if(Math.abs(d-h)<.01&&Math.abs(f-T)<.01&&Math.abs(y-g)<.01){if(Math.abs(d+h)<.1&&Math.abs(f+T)<.1&&Math.abs(y+g)<.1&&Math.abs(l+v+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let F=(l+1)/2,_=(v+1)/2,p=(m+1)/2,S=(d+h)/4,B=(f+T)/4,b=(y+g)/4;return F>_&&F>p?F<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(F),r=S/i,a=B/i):_>p?_<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(_),i=S/r,a=b/r):p<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(p),i=B/a,r=b/a),this.set(i,r,a,t),this}let L=Math.sqrt((g-y)*(g-y)+(f-T)*(f-T)+(h-d)*(h-d));return Math.abs(L)<.001&&(L=1),this.x=(g-y)/L,this.y=(f-T)/L,this.z=(h-d)/L,this.w=Math.acos((l+v+m-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=Tn(this.x,e.x,t.x),this.y=Tn(this.y,e.y,t.y),this.z=Tn(this.z,e.z,t.z),this.w=Tn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Tn(this.x,e,t),this.y=Tn(this.y,e,t),this.z=Tn(this.z,e,t),this.w=Tn(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Tn(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}};Ch.prototype.isVector4=!0;var fi=Ch,ou=class extends Sa{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Hi,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 fi(0,0,e,t),this.scissorTest=!1,this.viewport=new fi(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:Hi,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 vo(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"})}},Ar=class extends ou{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},ml=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=Bi,this.minFilter=Bi,this.wrapR=_a,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 lu=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=Bi,this.minFilter=Bi,this.wrapR=_a,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var Lu=class Lu{constructor(e,t,i,r,a,s,o,u,l,d,f,h,v,y,T,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,v,y,T,g)}set(e,t,i,r,a,s,o,u,l,d,f,h,v,y,T,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=a,m[5]=s,m[9]=o,m[13]=u,m[2]=l,m[6]=d,m[10]=f,m[14]=h,m[3]=v,m[7]=y,m[11]=T,m[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 Lu().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/Ks.setFromMatrixColumn(e,0).length(),a=1/Ks.setFromMatrixColumn(e,1).length(),s=1/Ks.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,v=s*f,y=o*d,T=o*f;t[0]=u*d,t[4]=-u*f,t[8]=l,t[1]=v+y*l,t[5]=h-T*l,t[9]=-o*u,t[2]=T-h*l,t[6]=y+v*l,t[10]=s*u}else if(e.order==="YXZ"){let h=u*d,v=u*f,y=l*d,T=l*f;t[0]=h+T*o,t[4]=y*o-v,t[8]=s*l,t[1]=s*f,t[5]=s*d,t[9]=-o,t[2]=v*o-y,t[6]=T+h*o,t[10]=s*u}else if(e.order==="ZXY"){let h=u*d,v=u*f,y=l*d,T=l*f;t[0]=h-T*o,t[4]=-s*f,t[8]=y+v*o,t[1]=v+y*o,t[5]=s*d,t[9]=T-h*o,t[2]=-s*l,t[6]=o,t[10]=s*u}else if(e.order==="ZYX"){let h=s*d,v=s*f,y=o*d,T=o*f;t[0]=u*d,t[4]=y*l-v,t[8]=h*l+T,t[1]=u*f,t[5]=T*l+h,t[9]=v*l-y,t[2]=-l,t[6]=o*u,t[10]=s*u}else if(e.order==="YZX"){let h=s*u,v=s*l,y=o*u,T=o*l;t[0]=u*d,t[4]=T-h*f,t[8]=y*f+v,t[1]=f,t[5]=s*d,t[9]=-o*d,t[2]=-l*d,t[6]=v*f+y,t[10]=h-T*f}else if(e.order==="XZY"){let h=s*u,v=s*l,y=o*u,T=o*l;t[0]=u*d,t[4]=-f,t[8]=l*d,t[1]=h*f+T,t[5]=s*d,t[9]=v*f-y,t[2]=y*f-v,t[6]=o*d,t[10]=T*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(Ng,e,Ug)}lookAt(e,t,i){let r=this.elements;return Dr.subVectors(e,t),Dr.lengthSq()===0&&(Dr.z=1),Dr.normalize(),ns.crossVectors(i,Dr),ns.lengthSq()===0&&(Math.abs(i.z)===1?Dr.x+=1e-4:Dr.z+=1e-4,Dr.normalize(),ns.crossVectors(i,Dr)),ns.normalize(),Tc.crossVectors(Dr,ns),r[0]=ns.x,r[4]=Tc.x,r[8]=Dr.x,r[1]=ns.y,r[5]=Tc.y,r[9]=Dr.y,r[2]=ns.z,r[6]=Tc.z,r[10]=Dr.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],v=i[13],y=i[2],T=i[6],g=i[10],m=i[14],L=i[3],F=i[7],_=i[11],p=i[15],S=r[0],B=r[4],b=r[8],I=r[12],z=r[1],U=r[5],Y=r[9],E=r[13],M=r[2],O=r[6],H=r[10],ee=r[14],j=r[3],K=r[7],re=r[11],J=r[15];return a[0]=s*S+o*z+u*M+l*j,a[4]=s*B+o*U+u*O+l*K,a[8]=s*b+o*Y+u*H+l*re,a[12]=s*I+o*E+u*ee+l*J,a[1]=d*S+f*z+h*M+v*j,a[5]=d*B+f*U+h*O+v*K,a[9]=d*b+f*Y+h*H+v*re,a[13]=d*I+f*E+h*ee+v*J,a[2]=y*S+T*z+g*M+m*j,a[6]=y*B+T*U+g*O+m*K,a[10]=y*b+T*Y+g*H+m*re,a[14]=y*I+T*E+g*ee+m*J,a[3]=L*S+F*z+_*M+p*j,a[7]=L*B+F*U+_*O+p*K,a[11]=L*b+F*Y+_*H+p*re,a[15]=L*I+F*E+_*ee+p*J,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],v=e[14],y=e[3],T=e[7],g=e[11],m=e[15],L=u*v-l*h,F=o*v-l*f,_=o*h-u*f,p=s*v-l*d,S=s*h-u*d,B=s*f-o*d;return t*(T*L-g*F+m*_)-i*(y*L-g*p+m*S)+r*(y*F-T*p+m*B)-a*(y*_-T*S+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],v=e[11],y=e[12],T=e[13],g=e[14],m=e[15],L=t*o-i*s,F=t*u-r*s,_=t*l-a*s,p=i*u-r*o,S=i*l-a*o,B=r*l-a*u,b=d*T-f*y,I=d*g-h*y,z=d*m-v*y,U=f*g-h*T,Y=f*m-v*T,E=h*m-v*g,M=L*E-F*Y+_*U+p*z-S*I+B*b;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let O=1/M;return e[0]=(o*E-u*Y+l*U)*O,e[1]=(r*Y-i*E-a*U)*O,e[2]=(T*B-g*S+m*p)*O,e[3]=(h*S-f*B-v*p)*O,e[4]=(u*z-s*E-l*I)*O,e[5]=(t*E-r*z+a*I)*O,e[6]=(g*_-y*B-m*F)*O,e[7]=(d*B-h*_+v*F)*O,e[8]=(s*Y-o*z+l*b)*O,e[9]=(i*z-t*Y-a*b)*O,e[10]=(y*S-T*_+m*L)*O,e[11]=(f*_-d*S-v*L)*O,e[12]=(o*I-s*U-u*b)*O,e[13]=(t*U-i*I+r*b)*O,e[14]=(T*F-y*p-g*L)*O,e[15]=(d*p-f*F+h*L)*O,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,v=a*d,y=a*f,T=s*d,g=s*f,m=o*f,L=u*l,F=u*d,_=u*f,p=i.x,S=i.y,B=i.z;return r[0]=(1-(T+m))*p,r[1]=(v+_)*p,r[2]=(y-F)*p,r[3]=0,r[4]=(v-_)*S,r[5]=(1-(h+m))*S,r[6]=(g+L)*S,r[7]=0,r[8]=(y+F)*B,r[9]=(g-L)*B,r[10]=(1-(h+T))*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=Ks.set(r[0],r[1],r[2]).length(),o=Ks.set(r[4],r[5],r[6]).length(),u=Ks.set(r[8],r[9],r[10]).length();a<0&&(s=-s),ta.copy(this);let l=1/s,d=1/o,f=1/u;return ta.elements[0]*=l,ta.elements[1]*=l,ta.elements[2]*=l,ta.elements[4]*=d,ta.elements[5]*=d,ta.elements[6]*=d,ta.elements[8]*=f,ta.elements[9]*=f,ta.elements[10]*=f,t.setFromRotationMatrix(ta),i.x=s,i.y=o,i.z=u,this}makePerspective(e,t,i,r,a,s,o=ra,u=!1){let l=this.elements,d=2*a/(t-e),f=2*a/(i-r),h=(t+e)/(t-e),v=(i+r)/(i-r),y,T;if(u)y=a/(s-a),T=s*a/(s-a);else if(o===ra)y=-(s+a)/(s-a),T=-2*s*a/(s-a);else if(o===po)y=-s/(s-a),T=-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]=v,l[13]=0,l[2]=0,l[6]=0,l[10]=y,l[14]=T,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,a,s,o=ra,u=!1){let l=this.elements,d=2/(t-e),f=2/(i-r),h=-(t+e)/(t-e),v=-(i+r)/(i-r),y,T;if(u)y=1/(s-a),T=s/(s-a);else if(o===ra)y=-2/(s-a),T=-(s+a)/(s-a);else if(o===po)y=-1/(s-a),T=-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]=v,l[2]=0,l[6]=0,l[10]=y,l[14]=T,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}};Lu.prototype.isMatrix4=!0;var $n=Lu,Ks=new ge,ta=new $n,Ng=new ge(0,0,0),Ug=new ge(1,1,1),ns=new ge,Tc=new ge,Dr=new ge,um=new $n,dm=new ba,Xa=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],v=r[10];switch(t){case"XYZ":this._y=Math.asin(Tn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,v),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Tn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,v),this._z=Math.atan2(u,l)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Tn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,v),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(u,a));break;case"ZYX":this._y=Math.asin(-Tn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,v),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Tn(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,v));break;case"XZY":this._z=Math.asin(-Tn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,v),this._y=0);break;default:rn("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return um.makeRotationFromQuaternion(e),this.setFromRotationMatrix(um,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return dm.setFromEuler(this),this.setFromQuaternion(dm,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}};Xa.DEFAULT_ORDER="XYZ";var go=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}},Fg=0,fm=new ge,Qs=new ba,ka=new $n,Ec=new ge,nl=new ge,Og=new ge,Bg=new ba,hm=new ge(1,0,0),pm=new ge(0,1,0),mm=new ge(0,0,1),vm={type:"added"},kg={type:"removed"},js={type:"childadded",child:null},Sf={type:"childremoved",child:null},nr=class n extends Sa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fg++}),this.uuid=Ro(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new ge,t=new Xa,i=new ba,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 $n},normalMatrix:{value:new un}}),this.matrix=new $n,this.matrixWorld=new $n,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new go,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 Qs.setFromAxisAngle(e,t),this.quaternion.multiply(Qs),this}rotateOnWorldAxis(e,t){return Qs.setFromAxisAngle(e,t),this.quaternion.premultiply(Qs),this}rotateX(e){return this.rotateOnAxis(hm,e)}rotateY(e){return this.rotateOnAxis(pm,e)}rotateZ(e){return this.rotateOnAxis(mm,e)}translateOnAxis(e,t){return fm.copy(e).applyQuaternion(this.quaternion),this.position.add(fm.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(hm,e)}translateY(e){return this.translateOnAxis(pm,e)}translateZ(e){return this.translateOnAxis(mm,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ka.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Ec.copy(e):Ec.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),nl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ka.lookAt(nl,Ec,this.up):ka.lookAt(Ec,nl,this.up),this.quaternion.setFromRotationMatrix(ka),r&&(ka.extractRotation(r.matrixWorld),Qs.setFromRotationMatrix(ka),this.quaternion.premultiply(Qs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(sn("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(vm),js.child=e,this.dispatchEvent(js),js.child=null):sn("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(kg),Sf.child=e,this.dispatchEvent(Sf),Sf.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),ka.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ka.multiply(e.parent.matrixWorld)),e.applyMatrix4(ka),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(vm),js.child=e,this.dispatchEvent(js),js.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(nl,e,Og),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,Bg,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),v=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),v.length>0&&(i.animations=v),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"})}};nr.DEFAULT_UP=new ge(0,1,0);nr.DEFAULT_MATRIX_AUTO_UPDATE=!0;nr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Er=class extends nr{constructor(){super(),this.isGroup=!0,this.type="Group"}},zg={type:"move"},yo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Er,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 Er,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 Er,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 T of e.hand.values()){let g=t.getJointPose(T,i),m=this._getHandJoint(l,T);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}let d=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],h=d.position.distanceTo(f.position),v=.02,y=.005;l.inputState.pinching&&h>v+y?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=v-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(zg)))}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 Er;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},M0={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},is={h:0,s:0,l:0},Ac={h:0,s:0,l:0};function bf(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 vn=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=hr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ln.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=Ln.workingColorSpace){return this.r=e,this.g=t,this.b=i,Ln.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Ln.workingColorSpace){if(e=Rg(e,1),t=Tn(t,0,1),i=Tn(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=bf(s,a,e+1/3),this.g=bf(s,a,e),this.b=bf(s,a,e-1/3)}return Ln.colorSpaceToWorking(this,r),this}setStyle(e,t=hr){function i(a){a!==void 0&&parseFloat(a)<1&&rn("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:rn("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);rn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=hr){let i=M0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):rn("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=Wa(e.r),this.g=Wa(e.g),this.b=Wa(e.b),this}copyLinearToSRGB(e){return this.r=uo(e.r),this.g=uo(e.g),this.b=uo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=hr){return Ln.workingToColorSpace(ji.copy(this),e),Math.round(Tn(ji.r*255,0,255))*65536+Math.round(Tn(ji.g*255,0,255))*256+Math.round(Tn(ji.b*255,0,255))}getHexString(e=hr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ln.workingColorSpace){Ln.workingToColorSpace(ji.copy(this),t);let i=ji.r,r=ji.g,a=ji.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=Ln.workingColorSpace){return Ln.workingToColorSpace(ji.copy(this),t),e.r=ji.r,e.g=ji.g,e.b=ji.b,e}getStyle(e=hr){Ln.workingToColorSpace(ji.copy(this),e);let t=ji.r,i=ji.g,r=ji.b;return e!==hr?`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(is),this.setHSL(is.h+e,is.s+t,is.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(is),e.getHSL(Ac);let i=gf(is.h,Ac.h,t),r=gf(is.s,Ac.s,t),a=gf(is.l,Ac.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}},ji=new vn;vn.NAMES=M0;var vl=class extends nr{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 Xa,this.environmentIntensity=1,this.environmentRotation=new Xa,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}},na=new ge,za=new ge,wf=new ge,Va=new ge,eo=new ge,to=new ge,gm=new ge,Tf=new ge,Ef=new ge,Af=new ge,If=new fi,Cf=new fi,Rf=new fi,os=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),na.subVectors(e,t),r.cross(na);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){na.subVectors(r,t),za.subVectors(i,t),wf.subVectors(e,t);let s=na.dot(na),o=na.dot(za),u=na.dot(wf),l=za.dot(za),d=za.dot(wf),f=s*l-o*o;if(f===0)return a.set(0,0,0),null;let h=1/f,v=(l*u-o*d)*h,y=(s*d-o*u)*h;return a.set(1-v-y,y,v)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Va)===null?!1:Va.x>=0&&Va.y>=0&&Va.x+Va.y<=1}static getInterpolation(e,t,i,r,a,s,o,u){return this.getBarycoord(e,t,i,r,Va)===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,Va.x),u.addScaledVector(s,Va.y),u.addScaledVector(o,Va.z),u)}static getInterpolatedAttribute(e,t,i,r,a,s){return If.setScalar(0),Cf.setScalar(0),Rf.setScalar(0),If.fromBufferAttribute(e,t),Cf.fromBufferAttribute(e,i),Rf.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(If,a.x),s.addScaledVector(Cf,a.y),s.addScaledVector(Rf,a.z),s}static isFrontFacing(e,t,i,r){return na.subVectors(i,t),za.subVectors(e,t),na.cross(za).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 na.subVectors(this.c,this.b),za.subVectors(this.a,this.b),na.cross(za).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;eo.subVectors(r,i),to.subVectors(a,i),Tf.subVectors(e,i);let u=eo.dot(Tf),l=to.dot(Tf);if(u<=0&&l<=0)return t.copy(i);Ef.subVectors(e,r);let d=eo.dot(Ef),f=to.dot(Ef);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(eo,s);Af.subVectors(e,a);let v=eo.dot(Af),y=to.dot(Af);if(y>=0&&v<=y)return t.copy(a);let T=v*l-u*y;if(T<=0&&l>=0&&y<=0)return o=l/(l-y),t.copy(i).addScaledVector(to,o);let g=d*y-v*f;if(g<=0&&f-d>=0&&v-y>=0)return gm.subVectors(a,r),o=(f-d)/(f-d+(v-y)),t.copy(r).addScaledVector(gm,o);let m=1/(g+T+h);return s=T*m,o=h*m,t.copy(i).addScaledVector(eo,s).addScaledVector(to,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},wa=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(ia.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(ia.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=ia.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,ia):ia.fromBufferAttribute(a,s),ia.applyMatrix4(e.matrixWorld),this.expandByPoint(ia);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ic.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ic.copy(i.boundingBox)),Ic.applyMatrix4(e.matrixWorld),this.union(Ic)}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,ia),ia.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(il),Cc.subVectors(this.max,il),no.subVectors(e.a,il),io.subVectors(e.b,il),ro.subVectors(e.c,il),rs.subVectors(io,no),as.subVectors(ro,io),Is.subVectors(no,ro);let t=[0,-rs.z,rs.y,0,-as.z,as.y,0,-Is.z,Is.y,rs.z,0,-rs.x,as.z,0,-as.x,Is.z,0,-Is.x,-rs.y,rs.x,0,-as.y,as.x,0,-Is.y,Is.x,0];return!Pf(t,no,io,ro,Cc)||(t=[1,0,0,0,1,0,0,0,1],!Pf(t,no,io,ro,Cc))?!1:(Rc.crossVectors(rs,as),t=[Rc.x,Rc.y,Rc.z],Pf(t,no,io,ro,Cc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ia).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ia).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:(Ga[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ga[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ga[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ga[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ga[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ga[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ga[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ga[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ga),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}},Ga=[new ge,new ge,new ge,new ge,new ge,new ge,new ge,new ge],ia=new ge,Ic=new wa,no=new ge,io=new ge,ro=new ge,rs=new ge,as=new ge,Is=new ge,il=new ge,Cc=new ge,Rc=new ge,Cs=new ge;function Pf(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){Cs.fromArray(n,a);let o=r.x*Math.abs(Cs.x)+r.y*Math.abs(Cs.y)+r.z*Math.abs(Cs.z),u=e.dot(Cs),l=t.dot(Cs),d=i.dot(Cs);if(Math.max(-Math.max(u,l,d),Math.min(u,l,d))>o)return!1}return!0}var Ci=new ge,Pc=new kt,Vg=0,Fr=class extends Sa{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:Vg++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=v0,this.updateRanges=[],this.gpuType=Yr,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++)Pc.fromBufferAttribute(this,t),Pc.applyMatrix3(e),this.setXY(t,Pc.x,Pc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyMatrix3(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyMatrix4(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyNormalMatrix(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.transformDirection(e),this.setXYZ(t,Ci.x,Ci.y,Ci.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=tl(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Tr(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tl(t,this.array)),t}setX(e,t){return this.normalized&&(t=Tr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tl(t,this.array)),t}setY(e,t){return this.normalized&&(t=Tr(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=tl(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Tr(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=tl(t,this.array)),t}setW(e,t){return this.normalized&&(t=Tr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Tr(t,this.array),i=Tr(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=Tr(t,this.array),i=Tr(i,this.array),r=Tr(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=Tr(t,this.array),i=Tr(i,this.array),r=Tr(r,this.array),a=Tr(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 gl=class extends Fr{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var yl=class extends Fr{constructor(e,t,i){super(new Uint32Array(e),t,i)}};var Xn=class extends Fr{constructor(e,t,i){super(new Float32Array(e),t,i)}},Gg=new wa,rl=new ge,Lf=new ge,ls=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):Gg.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;rl.subVectors(e,this.center);let t=rl.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(rl,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):(Lf.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rl.copy(e.center).add(Lf)),this.expandByPoint(rl.copy(e.center).sub(Lf))),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}},Hg=0,Xr=new $n,Df=new nr,ao=new ge,Nr=new wa,al=new wa,Oi=new ge,Wi=class n extends Sa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Hg++}),this.uuid=Ro(),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(Ig(e)?yl:gl)(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 un().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 Xr.makeRotationFromQuaternion(e),this.applyMatrix4(Xr),this}rotateX(e){return Xr.makeRotationX(e),this.applyMatrix4(Xr),this}rotateY(e){return Xr.makeRotationY(e),this.applyMatrix4(Xr),this}rotateZ(e){return Xr.makeRotationZ(e),this.applyMatrix4(Xr),this}translate(e,t,i){return Xr.makeTranslation(e,t,i),this.applyMatrix4(Xr),this}scale(e,t,i){return Xr.makeScale(e,t,i),this.applyMatrix4(Xr),this}lookAt(e){return Df.lookAt(e),Df.updateMatrix(),this.applyMatrix4(Df.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ao).negate(),this.translate(ao.x,ao.y,ao.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 Xn(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&&rn("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 wa);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("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];Nr.setFromBufferAttribute(a),this.morphTargetsRelative?(Oi.addVectors(this.boundingBox.min,Nr.min),this.boundingBox.expandByPoint(Oi),Oi.addVectors(this.boundingBox.max,Nr.max),this.boundingBox.expandByPoint(Oi)):(this.boundingBox.expandByPoint(Nr.min),this.boundingBox.expandByPoint(Nr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&sn('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 ls);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("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(Nr.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){let o=t[a];al.setFromBufferAttribute(o),this.morphTargetsRelative?(Oi.addVectors(Nr.min,al.min),Nr.expandByPoint(Oi),Oi.addVectors(Nr.max,al.max),Nr.expandByPoint(Oi)):(Nr.expandByPoint(al.min),Nr.expandByPoint(al.max))}Nr.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)Oi.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(Oi));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++)Oi.fromBufferAttribute(o,l),u&&(ao.fromBufferAttribute(e,l),Oi.add(ao)),r=Math.max(r,i.distanceToSquared(Oi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&sn('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){sn("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 Fr(new Float32Array(4*i.count),4),this.setAttribute("tangent",s));let o=[],u=[];for(let b=0;b<i.count;b++)o[b]=new ge,u[b]=new ge;let l=new ge,d=new ge,f=new ge,h=new kt,v=new kt,y=new kt,T=new ge,g=new ge;function m(b,I,z){l.fromBufferAttribute(i,b),d.fromBufferAttribute(i,I),f.fromBufferAttribute(i,z),h.fromBufferAttribute(a,b),v.fromBufferAttribute(a,I),y.fromBufferAttribute(a,z),d.sub(l),f.sub(l),v.sub(h),y.sub(h);let U=1/(v.x*y.y-y.x*v.y);isFinite(U)&&(T.copy(d).multiplyScalar(y.y).addScaledVector(f,-v.y).multiplyScalar(U),g.copy(f).multiplyScalar(v.x).addScaledVector(d,-y.x).multiplyScalar(U),o[b].add(T),o[I].add(T),o[z].add(T),u[b].add(g),u[I].add(g),u[z].add(g))}let L=this.groups;L.length===0&&(L=[{start:0,count:e.count}]);for(let b=0,I=L.length;b<I;++b){let z=L[b],U=z.start,Y=z.count;for(let E=U,M=U+Y;E<M;E+=3)m(e.getX(E+0),e.getX(E+1),e.getX(E+2))}let F=new ge,_=new ge,p=new ge,S=new ge;function B(b){p.fromBufferAttribute(r,b),S.copy(p);let I=o[b];F.copy(I),F.sub(p.multiplyScalar(p.dot(I))).normalize(),_.crossVectors(S,I);let U=_.dot(u[b])<0?-1:1;s.setXYZW(b,F.x,F.y,F.z,U)}for(let b=0,I=L.length;b<I;++b){let z=L[b],U=z.start,Y=z.count;for(let E=U,M=U+Y;E<M;E+=3)B(e.getX(E+0)),B(e.getX(E+1)),B(e.getX(E+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 Fr(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,v=i.count;h<v;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,v=e.count;h<v;h+=3){let y=e.getX(h+0),T=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,y),a.fromBufferAttribute(t,T),s.fromBufferAttribute(t,g),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,y),u.fromBufferAttribute(i,T),l.fromBufferAttribute(i,g),o.add(d),u.add(d),l.add(d),i.setXYZ(y,o.x,o.y,o.z),i.setXYZ(T,u.x,u.y,u.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,v=t.count;h<v;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++)Oi.fromBufferAttribute(e,t),Oi.normalize(),e.setXYZ(t,Oi.x,Oi.y,Oi.z)}toNonIndexed(){function e(o,u){let l=o.array,d=o.itemSize,f=o.normalized,h=new l.constructor(u.length*d),v=0,y=0;for(let T=0,g=u.length;T<g;T++){o.isInterleavedBufferAttribute?v=u[T]*o.data.stride+o.offset:v=u[T]*d;for(let m=0;m<d;m++)h[y++]=l[v++]}return new Fr(h,d,f)}if(this.index===null)return rn("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],v=e(h,i);u.push(v)}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 v=l[f];d.push(v.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,v=f.length;h<v;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 Nf=new ge,Wg=new ge,Xg=new un,Ur=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=Nf.subVectors(i,t).cross(Wg.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(Nf),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||Xg.getNormalMatrix(e),r=this.coplanarPoint(Nf).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}},Yg=0,cs=class extends Sa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yg++}),this.uuid=Ro(),this.name="",this.type="Material",this.blending=Ao,this.side=ms,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ih,this.blendDst=rh,this.blendEquation=Fs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new vn(0,0,0),this.blendAlpha=0,this.depthFunc=ho,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=c0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Zc,this.stencilZFail=Zc,this.stencilZPass=Zc,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){rn(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){rn(`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 vn().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 Ur().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 kt().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 kt().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 Ha=new ge,Uf=new ge,Lc=new ge,Dc=new ge,xl=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,Ha)),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=Ha.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ha.copy(this.origin).addScaledVector(this.direction,t),Ha.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Uf.copy(e).add(t).multiplyScalar(.5),Lc.copy(t).sub(e).normalize(),Dc.copy(this.origin).sub(Uf);let a=e.distanceTo(t)*.5,s=-this.direction.dot(Lc),o=Dc.dot(this.direction),u=-Dc.dot(Lc),l=Dc.lengthSq(),d=Math.abs(1-s*s),f,h,v,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 T=1/d;f*=T,h*=T,v=f*(f+s*h+2*o)+h*(s*f+h+2*u)+l}else h=a,f=Math.max(0,-(s*h+o)),v=-f*f+h*(h+2*u)+l;else h=-a,f=Math.max(0,-(s*h+o)),v=-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),v=-f*f+h*(h+2*u)+l):h<=y?(f=0,h=Math.min(Math.max(-a,-u),a),v=h*(h+2*u)+l):(f=Math.max(0,-(s*a+o)),h=f>0?a:Math.min(Math.max(-a,-u),a),v=-f*f+h*(h+2*u)+l);else h=s>0?-a:a,f=Math.max(0,-(s*h+o)),v=-f*f+h*(h+2*u)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(Uf).addScaledVector(Lc,h),v}intersectSphere(e,t){if(e.radius<0)return null;Ha.subVectors(e.center,this.origin);let i=Ha.dot(this.direction),r=Ha.dot(Ha)-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,Ha)!==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,v=e.z-s.z,y=t.x-s.x,T=t.y-s.y,g=t.z-s.z,m=i.x-s.x,L=i.y-s.y,F=i.z-s.z,_=Math.abs(u),p=Math.abs(l),S=Math.abs(d),B,b,I,z,U,Y,E,M,O,H,ee,j;if(_>=p&&_>=S?(I=u,Y=f,O=y,j=m,u>=0?(B=l,b=d,z=h,U=v,E=T,M=g,H=L,ee=F):(B=d,b=l,z=v,U=h,E=g,M=T,H=F,ee=L)):p>=S?(I=l,Y=h,O=T,j=L,l>=0?(B=d,b=u,z=v,U=f,E=g,M=y,H=F,ee=m):(B=u,b=d,z=f,U=v,E=y,M=g,H=m,ee=F)):(I=d,Y=v,O=g,j=F,d>=0?(B=u,b=l,z=f,U=h,E=y,M=T,H=m,ee=L):(B=l,b=u,z=h,U=f,E=T,M=y,H=L,ee=m)),I===0)return null;let K=B/I,re=b/I,J=1/I,ne=z-K*Y,Te=U-re*Y,fe=E-K*O,pe=M-re*O,Fe=H-K*j,ae=ee-re*j,de=Fe*pe-ae*fe,_e=ne*ae-Te*Fe,Ge=fe*Te-pe*ne;if(r){if(de<0||_e<0||Ge<0)return null}else if((de<0||_e<0||Ge<0)&&(de>0||_e>0||Ge>0))return null;let $e=de+_e+Ge;if($e===0)return null;let ut=J*(de*Y+_e*O+Ge*j);return($e>0?ut<0:ut>0)?null:this.at(ut/$e,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)}},Ta=class extends cs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vn(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 Xa,this.combine=Nu,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}},ym=new $n,Rs=new xl,Nc=new ls,xm=new ge,Uc=new ge,Fc=new ge,Oc=new ge,Ff=new ge,Bc=new ge,_m=new ge,kc=new ge,jn=class extends nr{constructor(e=new Wi,t=new Ta){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){Bc.set(0,0,0);for(let u=0,l=a.length;u<l;u++){let d=o[u],f=a[u];d!==0&&(Ff.fromBufferAttribute(f,e),s?Bc.addScaledVector(Ff,d):Bc.addScaledVector(Ff.sub(t),d))}t.add(Bc)}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(),Nc.copy(i.boundingSphere),Nc.applyMatrix4(a),Rs.copy(e.ray).recast(e.near),!(Nc.containsPoint(Rs.origin)===!1&&(Rs.intersectSphere(Nc,xm)===null||Rs.origin.distanceToSquared(xm)>(e.far-e.near)**2))&&(ym.copy(a).invert(),Rs.copy(e.ray).applyMatrix4(ym),!(i.boundingBox!==null&&Rs.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Rs)))}_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,v=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,T=h.length;y<T;y++){let g=h[y],m=s[g.materialIndex],L=Math.max(g.start,v.start),F=Math.min(o.count,Math.min(g.start+g.count,v.start+v.count));for(let _=L,p=F;_<p;_+=3){let S=o.getX(_),B=o.getX(_+1),b=o.getX(_+2);r=zc(this,m,e,i,l,d,f,S,B,b),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,v.start),T=Math.min(o.count,v.start+v.count);for(let g=y,m=T;g<m;g+=3){let L=o.getX(g),F=o.getX(g+1),_=o.getX(g+2);r=zc(this,s,e,i,l,d,f,L,F,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(s))for(let y=0,T=h.length;y<T;y++){let g=h[y],m=s[g.materialIndex],L=Math.max(g.start,v.start),F=Math.min(u.count,Math.min(g.start+g.count,v.start+v.count));for(let _=L,p=F;_<p;_+=3){let S=_,B=_+1,b=_+2;r=zc(this,m,e,i,l,d,f,S,B,b),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,v.start),T=Math.min(u.count,v.start+v.count);for(let g=y,m=T;g<m;g+=3){let L=g,F=g+1,_=g+2;r=zc(this,s,e,i,l,d,f,L,F,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};function qg(n,e,t,i,r,a,s,o){let u;if(e.side===pr?u=i.intersectTriangle(s,a,r,!0,o):u=i.intersectTriangle(r,a,s,e.side===ms,o),u===null)return null;kc.copy(o),kc.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(kc);return l<t.near||l>t.far?null:{distance:l,point:kc.clone(),object:n}}function zc(n,e,t,i,r,a,s,o,u,l){n.getVertexPosition(o,Uc),n.getVertexPosition(u,Fc),n.getVertexPosition(l,Oc);let d=qg(n,e,t,i,Uc,Fc,Oc,_m);if(d){let f=new ge;os.getBarycoord(_m,Uc,Fc,Oc,f),r&&(d.uv=os.getInterpolatedAttribute(r,o,u,l,f,new kt)),a&&(d.uv1=os.getInterpolatedAttribute(a,o,u,l,f,new kt)),s&&(d.normal=os.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};os.getNormal(Uc,Fc,Oc,h.normal),d.face=h,d.barycoord=f}return d}var _l=class extends tr{constructor(e=null,t=1,i=1,r,a,s,o,u,l=Bi,d=Bi,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}};var Ml=class extends Fr{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}},so=new $n,Mm=new $n,Vc=[],Sm=new wa,Zg=new $n,sl=new jn,ol=new ls,Ea=class extends jn{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ml(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,Zg)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new wa),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,so),Sm.copy(e.boundingBox).applyMatrix4(so),this.boundingBox.union(Sm)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ls),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,so),ol.copy(e.boundingSphere).applyMatrix4(so),this.boundingSphere.union(ol)}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(sl.geometry=this.geometry,sl.material=this.material,sl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ol.copy(this.boundingSphere),ol.applyMatrix4(i),e.ray.intersectsSphere(ol)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,so),Mm.multiplyMatrices(i,so),sl.matrixWorld=Mm,sl.raycast(e,Vc);for(let s=0,o=Vc.length;s<o;s++){let u=Vc[s];u.instanceId=a,u.object=this,t.push(u)}Vc.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Ml(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 _l(new Float32Array(r*this.count),r,this.count,Vu,Yr));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)}},Ps=new ls,Jg=new kt(.5,.5),Gc=new ge,xo=class{constructor(e=new Ur,t=new Ur,i=new Ur,r=new Ur,a=new Ur,s=new Ur){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=ra,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],v=a[7],y=a[8],T=a[9],g=a[10],m=a[11],L=a[12],F=a[13],_=a[14],p=a[15];if(r[0].setComponents(l-s,v-d,m-y,p-L).normalize(),r[1].setComponents(l+s,v+d,m+y,p+L).normalize(),r[2].setComponents(l+o,v+f,m+T,p+F).normalize(),r[3].setComponents(l-o,v-f,m-T,p-F).normalize(),i)r[4].setComponents(u,h,g,_).normalize(),r[5].setComponents(l-u,v-h,m-g,p-_).normalize();else if(r[4].setComponents(l-u,v-h,m-g,p-_).normalize(),t===ra)r[5].setComponents(l+u,v+h,m+g,p+_).normalize();else if(t===po)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(),Ps.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ps.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ps)}intersectsSprite(e){Ps.center.set(0,0,0);let t=Jg.distanceTo(e.center);return Ps.radius=.7071067811865476+t,Ps.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ps)}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(Gc.x=r.normal.x>0?e.max.x:e.min.x,Gc.y=r.normal.y>0?e.max.y:e.min.y,Gc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Gc)<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 Sl=class extends tr{constructor(e=[],t=vs,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 us=class extends tr{constructor(e,t,i=sa,r,a,s,o=Bi,u=Bi,l,d=Ma,f=1){if(d!==Ma&&d!==ys)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 vo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},cu=class extends us{constructor(e,t=sa,i=vs,r,a,s=Bi,o=Bi,u,l=Ma){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}},bl=class extends tr{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Or=class n extends Wi{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,v=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 Xn(l,3)),this.setAttribute("normal",new Xn(d,3)),this.setAttribute("uv",new Xn(f,2));function y(T,g,m,L,F,_,p,S,B,b,I){let z=_/B,U=p/b,Y=_/2,E=p/2,M=S/2,O=B+1,H=b+1,ee=0,j=0,K=new ge;for(let re=0;re<H;re++){let J=re*U-E;for(let ne=0;ne<O;ne++){let Te=ne*z-Y;K[T]=Te*L,K[g]=J*F,K[m]=M,l.push(K.x,K.y,K.z),K[T]=0,K[g]=0,K[m]=S>0?1:-1,d.push(K.x,K.y,K.z),f.push(ne/B),f.push(1-re/b),ee+=1}}for(let re=0;re<b;re++)for(let J=0;J<B;J++){let ne=h+J+O*re,Te=h+J+O*(re+1),fe=h+(J+1)+O*(re+1),pe=h+(J+1)+O*re;u.push(ne,Te,pe),u.push(Te,fe,pe),j+=6}o.addGroup(v,j,I),v+=j,h+=ee}}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 _o=class n extends Wi{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 kt;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 v=i+f/t*r;l.x=e*Math.cos(v),l.y=e*Math.sin(v),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 Xn(s,3)),this.setAttribute("normal",new Xn(o,3)),this.setAttribute("uv",new Xn(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)}},Ds=class n extends Wi{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=[],v=[],y=0,T=[],g=i/2,m=0;L(),s===!1&&(e>0&&F(!0),t>0&&F(!1)),this.setIndex(d),this.setAttribute("position",new Xn(f,3)),this.setAttribute("normal",new Xn(h,3)),this.setAttribute("uv",new Xn(v,2));function L(){let _=new ge,p=new ge,S=0,B=(t-e)/i;for(let b=0;b<=a;b++){let I=[],z=b/a,U=z*(t-e)+e;for(let Y=0;Y<=r;Y++){let E=Y/r,M=E*u+o,O=Math.sin(M),H=Math.cos(M);p.x=U*O,p.y=-z*i+g,p.z=U*H,f.push(p.x,p.y,p.z),_.set(O,B,H).normalize(),h.push(_.x,_.y,_.z),v.push(E,1-z),I.push(y++)}T.push(I)}for(let b=0;b<r;b++)for(let I=0;I<a;I++){let z=T[I][b],U=T[I+1][b],Y=T[I+1][b+1],E=T[I][b+1];(e>0||I!==0)&&(d.push(z,U,E),S+=3),(t>0||I!==a-1)&&(d.push(U,Y,E),S+=3)}l.addGroup(m,S,0),m+=S}function F(_){let p=y,S=new kt,B=new ge,b=0,I=_===!0?e:t,z=_===!0?1:-1;for(let Y=1;Y<=r;Y++)f.push(0,g*z,0),h.push(0,z,0),v.push(.5,.5),y++;let U=y;for(let Y=0;Y<=r;Y++){let M=Y/r*u+o,O=Math.cos(M),H=Math.sin(M);B.x=I*H,B.y=g*z,B.z=I*O,f.push(B.x,B.y,B.z),h.push(0,z,0),S.x=O*.5+.5,S.y=H*.5*z+.5,v.push(S.x,S.y),y++}for(let Y=0;Y<r;Y++){let E=p+Y,M=U+Y;_===!0?d.push(M,M+1,E):d.push(M+1,M,E),b+=3}l.addGroup(m,b,_===!0?1:2),m+=b}}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 Br=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){rn("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,v=(s-d)/h;return(r+v)/(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 kt: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 $n;for(let v=0;v<=e;v++){let y=v/e;r[v]=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 v=1;v<=e;v++){if(a[v]=a[v-1].clone(),s[v]=s[v-1].clone(),o.crossVectors(r[v-1],r[v]),o.length()>Number.EPSILON){o.normalize();let y=Math.acos(Tn(r[v-1].dot(r[v]),-1,1));a[v].applyMatrix4(u.makeRotationAxis(o,y))}s[v].crossVectors(r[v],a[v])}if(t===!0){let v=Math.acos(Tn(a[0].dot(a[e]),-1,1));v/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(v=-v);for(let y=1;y<=e;y++)a[y].applyMatrix4(u.makeRotationAxis(r[y],v*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}},Mo=class extends Br{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 kt){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,v=l-this.aY;u=h*d-v*f+this.aX,l=h*f+v*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}},uu=class extends Mo{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function Mh(){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,v=(o-s)/d-(u-s)/(d+f)+(u-o)/f;h*=d,v*=d,r(s,o,h,v)},calc:function(a){let s=a*a,o=s*a;return n+e*a+t*s+i*o}}}var bm=new ge,wm=new ge,Of=new Mh,Bf=new Mh,kf=new Mh,du=class extends Br{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]:(wm.subVectors(r[0],r[1]).add(r[0]),l=wm);let f=r[o%a],h=r[(o+1)%a];if(this.closed||o+2<a?d=r[(o+2)%a]:(bm.subVectors(r[a-1],r[a-2]).add(r[a-1]),d=bm),this.curveType==="centripetal"||this.curveType==="chordal"){let v=this.curveType==="chordal"?.5:.25,y=Math.pow(l.distanceToSquared(f),v),T=Math.pow(f.distanceToSquared(h),v),g=Math.pow(h.distanceToSquared(d),v);T<1e-4&&(T=1),y<1e-4&&(y=T),g<1e-4&&(g=T),Of.initNonuniformCatmullRom(l.x,f.x,h.x,d.x,y,T,g),Bf.initNonuniformCatmullRom(l.y,f.y,h.y,d.y,y,T,g),kf.initNonuniformCatmullRom(l.z,f.z,h.z,d.z,y,T,g)}else this.curveType==="catmullrom"&&(Of.initCatmullRom(l.x,f.x,h.x,d.x,this.tension),Bf.initCatmullRom(l.y,f.y,h.y,d.y,this.tension),kf.initCatmullRom(l.z,f.z,h.z,d.z,this.tension));return i.set(Of.calc(u),Bf.calc(u),kf.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 Tm(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 $g(n,e){let t=1-n;return t*t*e}function Kg(n,e){return 2*(1-n)*n*e}function Qg(n,e){return n*n*e}function cl(n,e,t,i){return $g(n,e)+Kg(n,t)+Qg(n,i)}function jg(n,e){let t=1-n;return t*t*t*e}function ey(n,e){let t=1-n;return 3*t*t*n*e}function ty(n,e){return 3*(1-n)*n*n*e}function ny(n,e){return n*n*n*e}function ul(n,e,t,i,r){return jg(n,e)+ey(n,t)+ty(n,i)+ny(n,r)}var wl=class extends Br{constructor(e=new kt,t=new kt,i=new kt,r=new kt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new kt){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(ul(e,r.x,a.x,s.x,o.x),ul(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}},fu=class extends Br{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(ul(e,r.x,a.x,s.x,o.x),ul(e,r.y,a.y,s.y,o.y),ul(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}},Tl=class extends Br{constructor(e=new kt,t=new kt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new kt){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 kt){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}},hu=class extends Br{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}},El=class extends Br{constructor(e=new kt,t=new kt,i=new kt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new kt){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(cl(e,r.x,a.x,s.x),cl(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}},pu=class extends Br{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(cl(e,r.x,a.x,s.x),cl(e,r.y,a.y,s.y),cl(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}},Al=class extends Br{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new kt){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(Tm(o,u.x,l.x,d.x,f.x),Tm(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 kt().fromArray(r))}return this}},Em=Object.freeze({__proto__:null,ArcCurve:uu,CatmullRomCurve3:du,CubicBezierCurve:wl,CubicBezierCurve3:fu,EllipseCurve:Mo,LineCurve:Tl,LineCurve3:hu,QuadraticBezierCurve:El,QuadraticBezierCurve3:pu,SplineCurve:Al}),mu=class extends Br{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 Em[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 Em[r.type]().fromJSON(r))}return this}},Ns=class extends mu{constructor(e){super(),this.type="Path",this.currentPoint=new kt,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 Tl(this.currentPoint.clone(),new kt(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new El(this.currentPoint.clone(),new kt(e,t),new kt(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let o=new wl(this.currentPoint.clone(),new kt(e,t),new kt(i,r),new kt(a,s));return this.curves.push(o),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Al(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 Mo(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}},So=class extends Ns{constructor(e){super(e),this.uuid=Ro(),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 Ns().fromJSON(r))}return this}};function iy(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,a=S0(n,0,r,t,!0),s=[];if(!a||a.next===a.prev)return s;let o,u,l;if(i&&(a=ly(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 v=n[h],y=n[h+1];v<o&&(o=v),y<u&&(u=y),v>d&&(d=v),y>f&&(f=y)}l=Math.max(d-o,f-u),l=l!==0?32767/l:0}return Il(a,s,t,o,u,l,0),s}function S0(n,e,t,i,r){let a;if(r===xy(n,e,t,i)>0)for(let s=e;s<t;s+=i)a=Am(s/i|0,n[s],n[s+1],a);else for(let s=t-i;s>=e;s-=i)a=Am(s/i|0,n[s],n[s+1],a);return a&&bo(a,a.next)&&(Rl(a),a=a.next),a}function Us(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(bo(t,t.next)||mi(t.prev,t,t.next)===0)){if(Rl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Il(n,e,t,i,r,a,s){if(!n)return;!s&&a&&hy(n,i,r,a);let o=n;for(;n.prev!==n.next;){let u=n.prev,l=n.next;if(a?ay(n,i,r,a):ry(n)){e.push(u.i,n.i,l.i),Rl(n),n=l.next,o=l.next;continue}if(n=l,n===o){s?s===1?(n=sy(Us(n),e),Il(n,e,t,i,r,a,2)):s===2&&oy(n,e,t,i,r,a):Il(Us(n),e,t,i,r,a,1);break}}}function ry(n){let e=n.prev,t=n,i=n.next;if(mi(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),v=Math.max(o,u,l),y=i.next;for(;y!==e;){if(y.x>=d&&y.x<=h&&y.y>=f&&y.y<=v&&ll(r,o,a,u,s,l,y.x,y.y)&&mi(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function ay(n,e,t,i){let r=n.prev,a=n,s=n.next;if(mi(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,v=Math.min(o,u,l),y=Math.min(d,f,h),T=Math.max(o,u,l),g=Math.max(d,f,h),m=Yf(v,y,e,t,i),L=Yf(T,g,e,t,i),F=n.prevZ,_=n.nextZ;for(;F&&F.z>=m&&_&&_.z<=L;){if(F.x>=v&&F.x<=T&&F.y>=y&&F.y<=g&&F!==r&&F!==s&&ll(o,d,u,f,l,h,F.x,F.y)&&mi(F.prev,F,F.next)>=0||(F=F.prevZ,_.x>=v&&_.x<=T&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&ll(o,d,u,f,l,h,_.x,_.y)&&mi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;F&&F.z>=m;){if(F.x>=v&&F.x<=T&&F.y>=y&&F.y<=g&&F!==r&&F!==s&&ll(o,d,u,f,l,h,F.x,F.y)&&mi(F.prev,F,F.next)>=0)return!1;F=F.prevZ}for(;_&&_.z<=L;){if(_.x>=v&&_.x<=T&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&ll(o,d,u,f,l,h,_.x,_.y)&&mi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function sy(n,e){let t=n;do{let i=t.prev,r=t.next.next;!bo(i,r)&&w0(i,t,t.next,r)&&Cl(i,r)&&Cl(r,i)&&(e.push(i.i,t.i,r.i),Rl(t),Rl(t.next),t=n=r),t=t.next}while(t!==n);return Us(t)}function oy(n,e,t,i,r,a){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&vy(s,o)){let u=T0(s,o);s=Us(s,s.next),u=Us(u,u.next),Il(s,e,t,i,r,a,0),Il(u,e,t,i,r,a,0);return}o=o.next}s=s.next}while(s!==n)}function ly(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=S0(n,o,u,i,!1);l===l.next&&(l.steiner=!0),r.push(my(l))}r.sort(cy);for(let a=0;a<r.length;a++)t=uy(r[a],t);return t}function cy(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 uy(n,e){let t=dy(n,e);if(!t)return e;let i=T0(t,n);return Us(i,i.next),Us(t,t.next)}function dy(n,e){let t=e,i=n.x,r=n.y,a=-1/0,s;if(bo(n,t))return t;do{if(bo(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&&b0(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);Cl(t,n)&&(f<d||f===d&&(t.x>s.x||t.x===s.x&&fy(s,t)))&&(s=t,d=f)}t=t.next}while(t!==o);return s}function fy(n,e){return mi(n.prev,n,e.prev)<0&&mi(e.next,n,n.next)<0}function hy(n,e,t,i){let r=n;do r.z===0&&(r.z=Yf(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,py(r)}function py(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 Yf(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 my(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 b0(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 ll(n,e,t,i,r,a,s,o){return!(n===s&&e===o)&&b0(n,e,t,i,r,a,s,o)}function vy(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!gy(n,e)&&(Cl(n,e)&&Cl(e,n)&&yy(n,e)&&(mi(n.prev,n,e.prev)||mi(n,e.prev,e))||bo(n,e)&&mi(n.prev,n,n.next)>0&&mi(e.prev,e,e.next)>0)}function mi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function bo(n,e){return n.x===e.x&&n.y===e.y}function w0(n,e,t,i){let r=Wc(mi(n,e,t)),a=Wc(mi(n,e,i)),s=Wc(mi(t,i,n)),o=Wc(mi(t,i,e));return!!(r!==a&&s!==o||r===0&&Hc(n,t,e)||a===0&&Hc(n,i,e)||s===0&&Hc(t,n,i)||o===0&&Hc(t,e,i))}function Hc(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 Wc(n){return n>0?1:n<0?-1:0}function gy(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&&w0(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Cl(n,e){return mi(n.prev,n,n.next)<0?mi(n,e,n.next)>=0&&mi(n,n.prev,e)>=0:mi(n,e,n.prev)<0||mi(n,n.next,e)<0}function yy(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 T0(n,e){let t=qf(n.i,n.x,n.y),i=qf(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 Am(n,e,t,i){let r=qf(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 Rl(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 qf(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xy(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 Zf=class{static triangulate(e,t,i=2){return iy(e,t,i)}},fo=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=[];Im(e),Cm(i,e);let s=e.length;t.forEach(Im);for(let u=0;u<t.length;u++)r.push(s),s+=t[u].length,Cm(i,t[u]);let o=Zf.triangulate(i,r);for(let u=0;u<o.length;u+=3)a.push(o.slice(u,u+3));return a}};function Im(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Cm(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var Pl=class n extends Wi{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,v=[],y=[],T=[],g=[];for(let m=0;m<d;m++){let L=m*h-s;for(let F=0;F<l;F++){let _=F*f-a;y.push(_,-L,0),T.push(0,0,1),g.push(F/o),g.push(1-m/u)}}for(let m=0;m<u;m++)for(let L=0;L<o;L++){let F=L+l*m,_=L+l*(m+1),p=L+1+l*(m+1),S=L+1+l*m;v.push(F,_,S),v.push(_,p,S)}this.setIndex(v),this.setAttribute("position",new Xn(y,3)),this.setAttribute("normal",new Xn(T,3)),this.setAttribute("uv",new Xn(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)}},wo=class n extends Wi{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,v=new ge,y=new kt;for(let T=0;T<=r;T++){for(let g=0;g<=i;g++){let m=a+g/i*s;v.x=f*Math.cos(m),v.y=f*Math.sin(m),u.push(v.x,v.y,v.z),l.push(0,0,1),y.x=(v.x/t+1)/2,y.y=(v.y/t+1)/2,d.push(y.x,y.y)}f+=h}for(let T=0;T<r;T++){let g=T*(i+1);for(let m=0;m<i;m++){let L=m+g,F=L,_=L+i+1,p=L+i+2,S=L+1;o.push(F,_,S),o.push(_,p,S)}}this.setIndex(o),this.setAttribute("position",new Xn(u,3)),this.setAttribute("normal",new Xn(l,3)),this.setAttribute("uv",new Xn(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)}},Ll=class n extends Wi{constructor(e=new So([new kt(0,.5),new kt(-.5,-.5),new kt(.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 Xn(r,3)),this.setAttribute("normal",new Xn(a,3)),this.setAttribute("uv",new Xn(s,2));function l(d){let f=r.length/3,h=d.extractPoints(t),v=h.shape,y=h.holes;fo.isClockWise(v)===!1&&(v=v.reverse());for(let g=0,m=y.length;g<m;g++){let L=y[g];fo.isClockWise(L)===!0&&(y[g]=L.reverse())}let T=fo.triangulateShape(v,y);for(let g=0,m=y.length;g<m;g++){let L=y[g];v=v.concat(L)}for(let g=0,m=v.length;g<m;g++){let L=v[g];r.push(L.x,L.y,0),a.push(0,0,1),s.push(L.x,L.y)}for(let g=0,m=T.length;g<m;g++){let L=T[g],F=L[0]+f,_=L[1]+f,p=L[2]+f;i.push(F,_,p),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 _y(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 _y(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 ds=class n extends Wi{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,v=[],y=[],T=[],g=[];for(let m=0;m<=i;m++){let L=[],F=m/i,_=s+F*o,p=e*Math.cos(_),S=Math.sqrt(e*e-p*p),B=0;m===0&&s===0?B=.5/t:m===i&&u===Math.PI&&(B=-.5/t);for(let b=0;b<=t;b++){let I=b/t,z=r+I*a;f.x=-S*Math.cos(z),f.y=p,f.z=S*Math.sin(z),y.push(f.x,f.y,f.z),h.copy(f).normalize(),T.push(h.x,h.y,h.z),g.push(I+B,1-F),L.push(l++)}d.push(L)}for(let m=0;m<i;m++)for(let L=0;L<t;L++){let F=d[m][L+1],_=d[m][L],p=d[m+1][L],S=d[m+1][L+1];(m!==0||s>0)&&v.push(F,_,S),(m!==i-1||u<Math.PI)&&v.push(_,p,S)}this.setIndex(v),this.setAttribute("position",new Xn(y,3)),this.setAttribute("normal",new Xn(T,3)),this.setAttribute("uv",new Xn(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 Bs(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];if(Rm(r))r.isRenderTargetTexture?(rn("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(Rm(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 ir(n){let e={};for(let t=0;t<n.length;t++){let i=Bs(n[t]);for(let r in i)e[r]=i[r]}return e}function Rm(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function My(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Sh(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ln.workingColorSpace}var E0={clone:Bs,merge:ir},Sy=`void main() {
|
|
1
|
+
var ToraNative=(()=>{var Zf=Object.defineProperty;var cy=Object.getOwnPropertyDescriptor;var uy=Object.getOwnPropertyNames;var dy=Object.prototype.hasOwnProperty;var fy=(n,e)=>{for(var t in e)Zf(n,t,{get:e[t],enumerable:!0})},hy=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of uy(e))!dy.call(n,r)&&r!==t&&Zf(n,r,{get:()=>e[r],enumerable:!(i=cy(e,r))||i.enumerable});return n};var py=n=>hy(Zf({},"__esModule",{value:!0}),n);var n1={};fy(n1,{computeSafeArea:()=>Zp,createNetworkBridge:()=>Tg,layoutStandardText:()=>Eg,mountNative:()=>t1});var gm=function(n,e){if(!n)throw Error(e)},za=function(){return[1,0,0,1,0,0]};function Jf(n){return gm(Array.isArray(n)&&n.length===6&&n.every(Number.isFinite),"E_SCENE_MATRIX"),n}function Io(n,e){return Jf(n),Jf(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 kr(n){Jf(n);var e=n[0]*n[3]-n[1]*n[2];return gm(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 Kf=function(){return Kf=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},Kf.apply(this,arguments)},Va=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},Js=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))},$f=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 ym(n){var e=n.rows,t=n.columns,i=n.seed,r=n.slots,a=n.paint,s=n.onEvent,o=r.map(function(se){return se.group}),u=Js([],Va(new Set(o)),!1),l=Js([],Va(o),!1),d=i,f="idle",h=0,p,y,M=[],v=[],m=0,N=0,P=0,_,g,b=function(se,Se){return se*t+Se},z=function(se){return Math.floor(se/t)},T=function(se){return se%t},D=function(){return d=Math.imul(d,1664525)+1013904223>>>0,d/4294967296};function G(se){for(var Se=new Set,Pe=0;Pe<e;Pe++)for(var le=0;le<t;le++){var ae=b(Pe,le),fe=se[ae];if(le+2<t&&fe===se[ae+1]&&fe===se[ae+2])for(var Ne=0;Ne<3;Ne++)Se.add(ae+Ne);if(Pe+2<e&&fe===se[ae+t]&&fe===se[ae+t*2])for(var Ne=0;Ne<3;Ne++)Se.add(ae+t*Ne)}return Js([],Va(Se),!1)}function F(se,Se){var Pe;if(l[se]===l[Se])return!1;var le=Js([],Va(l),!1);return Pe=Va([le[Se],le[se]],2),le[se]=Pe[0],le[Se]=Pe[1],G(le).some(function(ae){return ae===se||ae===Se})}function $(){for(var se=[],Se=0;Se<l.length;Se++)T(Se)+1<t&&F(Se,Se+1)&&se.push({from:r[Se].id,to:r[Se+1].id}),z(Se)+1<e&&F(Se,Se+t)&&se.push({from:r[Se].id,to:r[Se+t].id});return se}function A(){for(var se=0;se<64;se++){l=[];for(var Se=function(le){var ae=u.filter(function(fe){return!(T(le)>=2&&l[le-1]===fe&&l[le-2]===fe)&&!(z(le)>=2&&l[le-t]===fe&&l[le-t*2]===fe)});l.push(ae[Math.floor(D()*ae.length)])},Pe=0;Pe<r.length;Pe++)Se(Pe);if($().length)return}l=r.map(function(le,ae){return u[(z(ae)*2+T(ae))%3]}),l[0]=u[0],l[1]=u[1],l[2]=u[0],l[t+1]=u[0]}function S(){for(var se=0;se<r.length;se++)a(se,l[se],{})}function H(){d=i,l=Js([],Va(o),!1),f="idle",h=0,p=void 0,y=void 0,M=[],v=[],m=0,N=0,P=0,_=void 0,g=void 0,(G(l).length||!$().length)&&A(),S()}function Y(se,Se){if(f!=="idle")return!1;var Pe=r.findIndex(function(ae){return ae.id===se}),le=r.findIndex(function(ae){return ae.id===Se});return Pe<0||le<0||Math.abs(z(Pe)-z(le))+Math.abs(T(Pe)-T(le))!==1?!1:(p=void 0,_=void 0,S(),y=[Pe,le],f="swap",h=0,!0)}function oe(se){if(f==="idle"){if(p===se){p=void 0;return}if(!(p&&Y(p,se)))return p=se,p}}function O(){M=G(l),P+=M.length,g={group:l[M[0]],from:r[M[0]].id,count:M.length},s("matchClear"),f="clear",h=0}function k(){var se=new Set(M),Se=Js([],Va(l),!1);v=[];for(var Pe=0;Pe<t;Pe++){for(var le=[],ae=e-1;ae>=0;ae--)se.has(b(ae,Pe))||le.push(b(ae,Pe));for(var fe=0,ae=e-1;ae>=0;ae--){var Ne=b(ae,Pe),Re=le[e-1-ae];Re!==void 0?(Se[Ne]=l[Re],v.push({cell:Ne,from:Re,offsetRows:0})):(Se[Ne]=u[Math.floor(D()*u.length)],v.push({cell:Ne,from:Ne,offsetRows:-(ae+1+fe++)}))}}l=Se,f="fall",h=0}function ne(){if(G(l).length&&m<3){m++,O();return}(G(l).length||!$().length)&&A(),S(),f="idle",h=0,y=void 0,M=[],v=[],N++,s("validMatch")}function X(se){var Se,Pe,le,ae,fe,Ne,Re;if(f==="idle"){if(_){_.elapsed+=se;var We=1+.065*Math.sin(Math.min(1,_.elapsed/.8)*Math.PI*4),Qe=function(Xe){a(r.findIndex(function(Je){return Je.id===Xe}),l[r.findIndex(function(Je){return Je.id===Xe})],{scale:We})};try{for(var ke=$f(_.ids),qe=ke.next();!qe.done;qe=ke.next()){var ft=qe.value;Qe(ft)}}catch(Xe){Se={error:Xe}}finally{try{qe&&!qe.done&&(Pe=ke.return)&&Pe.call(ke)}finally{if(Se)throw Se.error}}_.elapsed>=.8&&(_=void 0,S())}return}if(h+=se,f==="swap"||f==="reverse"){var tt=Math.min(1,h/.14),st=tt*tt*(3-2*tt),Ke=Va(y,2),en=Ke[0],nt=Ke[1];if(a(en,l[en],{from:nt,progress:f==="swap"?st:1-st}),a(nt,l[nt],{from:en,progress:f==="swap"?st:1-st}),tt<1)return;if(f==="reverse"){S(),f="idle",y=void 0,s("invalidMatch");return}if(!F(en,nt)){f="reverse",h=0;return}le=Va([l[nt],l[en]],2),l[en]=le[0],l[nt]=le[1],S(),O();return}if(f==="clear"){var on=Math.min(1,h/.18),We=on<.22?1+on*.45:Math.max(.05,1.1*(1-on)/.78);try{for(var ue=$f(M),hn=ue.next();!hn.done;hn=ue.next()){var gn=hn.value;a(gn,l[gn],{scale:We,opacity:1-on})}}catch(Je){ae={error:Je}}finally{try{hn&&!hn.done&&(fe=ue.return)&&fe.call(ue)}finally{if(ae)throw ae.error}}on===1&&k();return}var J=Math.min(1,h/.25),w=1-Math.pow(1-J,3);try{for(var ie=$f(v),ye=ie.next();!ye.done;ye=ie.next()){var Ae=ye.value;a(Ae.cell,l[Ae.cell],{from:Ae.from,offsetRows:Ae.offsetRows,progress:1-w})}}catch(Xe){Ne={error:Xe}}finally{try{ye&&!ye.done&&(Re=ie.return)&&Re.call(ie)}finally{if(Ne)throw Ne.error}}J===1&&ne()}function K(){if(f==="idle"){p=void 0;var se=$()[0];se&&(_={ids:[se.from,se.to],elapsed:0})}}function ge(){var se;return{phase:f,busy:f!=="idle",selected:p??null,moves:N,cleared:P,groups:Js([],Va(l),!1),legalMoves:f==="idle"?$():[],hint:(se=_?.ids)!==null&&se!==void 0?se:[],lastMatch:g?Kf({},g):null}}return{reset:H,select:oe,swap:Y,tick:X,showHint:K,snapshot:ge,cancelSelection:function(){p=void 0,_&&(_=void 0,S())}}}var hu=function(){return hu=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},hu.apply(this,arguments)},xm=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},my=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))},_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 Mm(){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 my([],xm((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 pu(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,v,m;return y.id!==i&&(((v=(M=y.acceptTags)===null||M===void 0?void 0:M.length)!==null&&v!==void 0?v:0)===0||((m=y.acceptTags)===null||m===void 0?void 0:m.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=_m(u),d=l.next();!d.done;d=l.next()){var f=d.value,h=o.items(f.id).filter(function(y){return y!==i}),p=f.capacity>0&&h.length>=f.capacity;return f.snapMode==="reject"?{kind:"reject",zone:f,occupantId:h[0]}:p?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 Sm(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 bm(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 wm(){var n=new Map;return{to:function(e,t,i,r,a){r===void 0&&(r=.18),n.set(e,{from:hu({},t),to:hu({},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=_m(n),o=s.next();!o.done;o=s.next()){var u=xm(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(p){i={error:p}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}}}}function Qf(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,p=n.y+f*u;if(l<=i)return{nx:0,ny:0,magnitude:0,angle:0,knobX:h,knobY:p};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:p}}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)},Tm=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 mu(n){var e,t,i=2166136261;try{for(var r=Tm(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 vu(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 Em(n,e,t,i,r){var a,s;i===void 0&&(i=0);var o=null,u=1/0;try{for(var l=Tm(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(p){a={error:p}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}return o}function Am(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 Im(n){var e=vu(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 Cm(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,p=s.canvasFactory,y=s.source,M=n,v=M.gridSize,m=new Uint8Array(v*v),N=0,P=!1,_=-1,g=!1,b=Math.max(1,o),z=Math.max(1,u),T=Math.min(1,512/Math.max(b,z)),D=(t=p?.())!==null&&t!==void 0?t:!((i=globalThis.document)===null||i===void 0)&&i.createElement?globalThis.document.createElement("canvas"):void 0;D&&(D.width=Math.max(1,Math.round(b*T)),D.height=Math.max(1,Math.round(z*T)));var G=(r=D?.getContext)===null||r===void 0?void 0:r.call(D,"2d"),F=(a=M.maskColor)!==null&&a!==void 0?a:"#dceeff",$=function(){return!!(y&&y.complete&&y.naturalWidth>0)},A=function(){G&&(G.globalCompositeOperation="source-over",G.clearRect(0,0,D.width,D.height),M.mode==="erase"&&($()?(G.drawImage(y,0,0,D.width,D.height),g=!0):(G.fillStyle=F,G.fillRect(0,0,D.width,D.height),g=!1)))};A();var S=function(){if(!P){var Y=Math.round(N/m.length*100),oe=Math.min(100,Y);oe!==_&&(_=oe,d(oe)),oe>=M.targetPercent&&(P=!0,h(oe))}},H=function(Y,oe){for(var O=Math.max(0,Math.min(v-1,Math.floor(Y/b*v))),k=Math.max(0,Math.min(v-1,Math.floor(oe/z*v))),ne=Math.max(0,Math.ceil(M.brushRadiusPx/b*v)),X=Math.max(0,Math.ceil(M.brushRadiusPx/z*v)),K=Math.max(0,k-X);K<=Math.min(v-1,k+X);K++)for(var ge=Math.max(0,O-ne);ge<=Math.min(v-1,O+ne);ge++)if(!(Math.hypot((ge+.5)/v*b-Y,(K+.5)/v*z-oe)>M.brushRadiusPx)){var se=K*v+ge;m[se]||(m[se]=1,N++)}G&&(G.save(),G.scale(T,T),G.globalCompositeOperation=M.mode==="erase"?"destination-out":"source-over",G.fillStyle=F,G.beginPath(),G.arc(Y,oe,M.brushRadiusPx,0,Math.PI*2),G.fill(),M.mode==="reveal"&&y&&(G.globalCompositeOperation="source-in",G.drawImage(y,0,0,b,z)),G.restore()),S()};return{canvas:D,stampSegment:function(Y,oe){for(var O=Math.hypot(oe.x-Y.x,oe.y-Y.y),k=Math.max(1,Math.ceil(O/Math.max(1,M.brushRadiusPx*.45))),ne=0;ne<=k;ne++)H(Y.x+(oe.x-Y.x)*ne/k,Y.y+(oe.y-Y.y)*ne/k)},reset:function(){m.fill(0),N=0,P=!1,_=-1,A(),S()},get progress(){return Math.round(N/m.length*100)},render:function(Y){M.mode==="erase"&&N===0&&!g&&$()&&A(),D?Y.drawImage(D,0,0,D.width,D.height,0,0,o,u):M.mode==="erase"&&this.progress<100&&(Y.save(),Y.globalAlpha=1-this.progress/100,Y.fillStyle=F,Y.fillRect(0,0,o,u),Y.restore())}}}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)},vy=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 eh(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 Rm(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 Pm(n,e,t){if(t.length>=3&&(Rm(n,t)||Rm(e,t)))return!0;for(var i=0;i<t.length;i++)if(eh(n,e,t[i],t[(i+1)%t.length]))return!0;return!1}function Lm(n){var e=n,t=[],i=null,r=0,a=function(s){return $s($s({},s),{points:s.points.map(function(o){return $s({},o)})})};return{begin:function(s){var o={id:++r,points:[$s({},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($s({},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=vy(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 Dm(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 kl=function(){return kl=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},kl.apply(this,arguments)},km=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},_s=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.")},gy=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))},os=function(n,e){return Math.hypot(n,e)},Nm=function(n,e,t){return Math.max(e,Math.min(t,n))},Ks=function(n){return Math.max(1,Math.min(n.width,n.height)/2)};function Um(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=km(o,2),l=u[0],d=u[1];return{x:n.x+l*i-d*r,y:n.y+l*r+d*i}})}function yy(n,e){var t,i,r,a,s,o,u,l,d,f,h=Um(n),p=Um(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,v=1,m=0;try{for(var N=_s(y),P=N.next();!P.done;P=N.next()){var _=P.value,g=Math.cos(_),b=Math.sin(_),z=1/0,T=-1/0,D=1/0,G=-1/0;try{for(var F=(r=void 0,_s(h)),$=F.next();!$.done;$=F.next()){var A=$.value,S=A.x*g+A.y*b;S<z&&(z=S),S>T&&(T=S)}}catch(O){r={error:O}}finally{try{$&&!$.done&&(a=F.return)&&a.call(F)}finally{if(r)throw r.error}}try{for(var H=(s=void 0,_s(p)),Y=H.next();!Y.done;Y=H.next()){var A=Y.value,S=A.x*g+A.y*b;S<D&&(D=S),S>G&&(G=S)}}catch(O){s={error:O}}finally{try{Y&&!Y.done&&(o=H.return)&&o.call(H)}finally{if(s)throw s.error}}var oe=Math.min(T,G)-Math.max(z,D);if(oe<=0)return null;oe<M&&(M=oe,v=g,m=b)}}catch(O){t={error:O}}finally{try{P&&!P.done&&(i=N.return)&&i.call(N)}finally{if(t)throw t.error}}return(n.x-e.x)*v+(n.y-e.y)*m<0&&(v=-v,m=-m),{nx:v,ny:m,penetration:M}}function Fm(n,e){var t,i,r,a=Ks(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,p=e.width/2,y=e.height/2,M=Nm(f,-p,p),v=Nm(h,-y,y),m=f-M,N=h-v,P=os(m,N),_;if(P>=a)return null;if(P<1e-4){var g=[{d:p-Math.abs(f),x:f>=0?1:-1,y:0},{d:y-Math.abs(h),x:0,y:h>=0?1:-1}].sort(function(T,D){return T.d-D.d});m=g[0].x,N=g[0].y,_=a+g[0].d}else m/=P,N/=P,_=a-P;var b=Math.cos((i=e.angle)!==null&&i!==void 0?i:0),z=Math.sin((r=e.angle)!==null&&r!==void 0?r:0);return{nx:m*b-N*z,ny:m*z+N*b,penetration:_}}function Om(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 Bm(n,e,t){var i,r,a,s,o,u;if(!(n.captured||e.captured||Om(n,e)||Om(e,n))){var l=n.x-e.x,d=n.y-e.y,f;if(n.shape==="circle"&&e.shape==="circle"){var h=os(l,d),p=Ks(n)+Ks(e)-h;if(p<=0)return;f=p,h>1e-4?(l/=h,d/=h):(l=1,d=0)}else if(n.shape==="circle"&&e.shape==="box"){var y=Fm(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="circle"){var y=Fm(e,n);if(!y)return;l=-y.nx,d=-y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="box"){var y=yy(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,v=e.mode==="dynamic"?1/((r=e.mass)!==null&&r!==void 0?r:1):0,m=M+v;if(m){n.x+=l*f*M/m,n.y+=d*f*M/m,e.mode==="dynamic"&&(e.x-=l*f*v/m,e.y-=d*f*v/m);var N=n.vx-((a=e.vx)!==null&&a!==void 0?a:0),P=n.vy-((s=e.vy)!==null&&s!==void 0?s:0),_=N*l+P*d;if(!(_>=0)){var g=Math.max((o=n.restitution)!==null&&o!==void 0?o:0,(u=e.restitution)!==null&&u!==void 0?u:0),b=-(1+g)*_/m;n.vx+=l*b*M,n.vy+=d*b*M,e.mode==="dynamic"&&(e.vx-=l*b*v,e.vy-=d*b*v),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 xy(n,e,t,i){var r,a;if(!(n.mode!=="dynamic"||n.captured))try{for(var s=_s(e),o=s.next();!o.done;o=s.next()){var u=o.value,l=u.x-n.x,d=u.y-n.y,f=os(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&&os(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(p){r={error:p}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}}function _y(n,e){var t,i,r,a,s,o,u=function(h){if(h.broken)return"continue";var p=e.find(function(z){return z.id===h.bodyId}),y=e.find(function(z){return z.id===h.anchorId});if(!p||p.mode!=="dynamic")return"continue";var M=(a=(r=y?.x)!==null&&r!==void 0?r:h.x)!==null&&a!==void 0?a:0,v=(o=(s=y?.y)!==null&&s!==void 0?s:h.y)!==null&&o!==void 0?o:0,m=p.x-M,N=p.y-v,P=os(m,N);if(P<=h.lengthPx||P<1e-4)return"continue";var _=m/P,g=N/P;p.x=M+_*h.lengthPx,p.y=v+g*h.lengthPx;var b=p.vx*_+p.vy*g;b>0&&(p.vx-=_*b,p.vy-=g*b)};try{for(var l=_s(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 th(n){for(var e,t,i,r,a,s,o,u,l,d,f,h=n.bodies,p=n.zones,y=p===void 0?[]:p,M=n.joints,v=M===void 0?[]:M,m=n.bounds,N=n.dt,P=n.onEvent,_=P===void 0?function(){}:P,g=h.filter(function(le){return le.mode==="dynamic"&&!le.captured}),b=g.reduce(function(le,ae){return Math.max(le,os(ae.vx,ae.vy))},0),z=g.reduce(function(le,ae){return Math.min(le,Ks(ae))},24),T=Math.min(16,Math.max(1,Math.ceil(b*N/(z*.45)))),D=N/T,G=0;G<T;G++){try{for(var F=(e=void 0,_s(g)),$=F.next();!$.done;$=F.next()){var A=$.value;A.vy+=((o=A.gravity)!==null&&o!==void 0?o:0)*D;var S=os(A.vx,A.vy);if(S>A.maxSpeed){var H=A.maxSpeed/S;A.vx*=H,A.vy*=H,S=A.maxSpeed}A.x+=A.vx*D,A.y+=A.vy*D;var Y=Math.max(0,S-((u=A.friction)!==null&&u!==void 0?u:0)*D),oe=Math.exp(-((l=A.linearDamping)!==null&&l!==void 0?l:0)*D);if(S>1e-4){var O=Y/S*oe;A.vx*=O,A.vy*=O}A.spinToRotation&&(A.angle=((d=A.angle)!==null&&d!==void 0?d:0)+os(A.vx,A.vy)*D/Ks(A)*(A.vx<0?-1:1))}}catch(le){e={error:le}}finally{try{$&&!$.done&&(t=F.return)&&t.call(F)}finally{if(e)throw e.error}}for(var k=0;k<g.length;k++){var A=g[k];try{for(var ne=(i=void 0,_s(h)),X=ne.next();!X.done;X=ne.next()){var K=X.value;K.id!==A.id&&K.mode!=="dynamic"&&Bm(A,K,_)}}catch(ae){i={error:ae}}finally{try{X&&!X.done&&(r=ne.return)&&r.call(ne)}finally{if(i)throw i.error}}for(var K=k+1;K<g.length;K++)Bm(g[K],A,_);var ge=A.shape==="box"?A.width/2:Ks(A),se=A.shape==="box"?A.height/2:Ks(A);A.wallBounce?(A.x-ge<m.left&&(A.x=m.left+ge,A.vx<0&&(_("bodyBounce",A,null,{speed:Math.abs(A.vx)}),A.vx=-A.vx*A.restitution)),A.x+ge>m.right&&(A.x=m.right-ge,A.vx>0&&(_("bodyBounce",A,null,{speed:Math.abs(A.vx)}),A.vx=-A.vx*A.restitution)),A.y-se<m.top&&(A.y=m.top+se,A.vy<0&&(_("bodyBounce",A,null,{speed:Math.abs(A.vy)}),A.vy=-A.vy*A.restitution)),A.y+se>m.bottom&&(A.y=m.bottom-se,A.vy>0&&(_("bodyBounce",A,null,{speed:Math.abs(A.vy)}),A.vy=-A.vy*A.restitution))):!A.exited&&(A.x+ge<m.left||A.x-ge>m.right||A.y+se<m.top||A.y-se>m.bottom)&&(A.exited=!0,_("boundaryExit",A,null,{})),xy(A,y,D,_)}_y(v,h)}try{for(var Se=_s(g),Pe=Se.next();!Pe.done;Pe=Se.next()){var A=Pe.value,S=os(A.vx,A.vy);S<A.restSpeed&&!A.captured?(A.restElapsed=((f=A.restElapsed)!==null&&f!==void 0?f:0)+N,A.restElapsed>=A.restDelaySeconds&&!A.atRest&&(A.atRest=!0,A.vx=0,A.vy=0,_("bodyRest",A,null,{}))):S>=A.restSpeed&&(A.restElapsed=0,A.atRest=!1)}}catch(le){a={error:le}}finally{try{Pe&&!Pe.done&&(s=Se.return)&&s.call(Se)}finally{if(a)throw a.error}}}function zm(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 kl({},P)},f=d(e),h=t.filter(function(P){return P.id!==e.id}).map(d),p=gy([f],km(h),!1),y=[],M=0,v=!1,m=function(P,_,g,b){P==="bodyBounce"&&b.sourceId===e.id&&M++,P==="zoneCapture"&&b.sourceId===e.id&&(v=!0)},N=0;N<90&&y.length<o&&!v&&M<=l;N++)th({bodies:p,zones:r,bounds:a,dt:1/60,onEvent:function(P,_,g,b){return m(P,_,g,kl(kl({},b),{sourceId:_.id}))}}),N%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)},zl=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.")},Gm=.008333333333333333;function Qs(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 Vm(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,p=-l*d+u*f,y=Math.max(-e.hx,Math.min(e.hx,h)),M=Math.max(-e.hz,Math.min(e.hz,p)),v=h-y,m=p-M,N=Math.hypot(v,m),P=Qs(n,n.x,n.z);if(!(N>=o||P!==null&&n.y>P+.55)){N<1e-8?e.hx-Math.abs(h)<e.hz-Math.abs(p)?(v=h<0?-1:1,m=0,N=0):(v=0,m=p<0?-1:1,N=0):(v/=N,m/=N);var _=u*v-l*m,g=l*v+u*m;n.x+=_*(o-N+1e-5),n.z+=g*(o-N+1e-5);var b=(r=e.vx)!==null&&r!==void 0?r:0,z=(a=e.vz)!==null&&a!==void 0?a:0,T=(n.vx-b)*_+(n.vz-z)*g;if(T<0){var D=1+((s=n.restitution)!==null&&s!==void 0?s:.72);n.vx-=D*T*_,n.vz-=D*T*g,Math.abs(T)>.3&&t>0&&i&&i("bodyBounce",n,e.sourceId?e:void 0)}}}function Hm(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 nh(n,e){n.x=n.lastSafe.x,n.y=n.lastSafe.y,n.z=n.lastSafe.z,Hm(n,e)}function ih(n){var e,t,i,r,a,s,o,u,l,d,f,h,p,y,M,v,m,N,P=n.bodies,_=n.walls,g=n.zones,b=n.dt,z=n.onEvent;if(!(!Number.isFinite(b)||b<=0))for(var T=Math.max(1,Math.round(b/Gm)),D=b/T,G=0;G<T;G++)try{for(var F=(e=void 0,zl(P)),$=F.next();!$.done;$=F.next()){var A=$.value;if(!(A.mode!=="dynamic"||A.captured)&&!A.atRest){var S=(l=A.boundsX)!==null&&l!==void 0?l:3,H=(d=A.boundsZ)!==null&&d!==void 0?d:7;if(A.y<-3||Math.abs(A.x)>S+2||Math.abs(A.z)>H+2){nh(A,z);continue}A.movingTime=((f=A.movingTime)!==null&&f!==void 0?f:0)+D;var Y=A.radius,oe=Math.hypot(A.vx,A.vy,A.vz),O=Math.max(1,Math.min(16,Math.ceil(oe*D/(Y*.45)))),k=D/O;(!A._perimeter||A._pbx!==S||A._pbz!==H)&&(A._pbx=S,A._pbz=H,A._perimeter=[{x:-(S+.1),z:0,hx:.1,hz:H+.1,angle:0,vx:0,vz:0},{x:S+.1,z:0,hx:.1,hz:H+.1,angle:0,vx:0,vz:0},{x:0,z:-(H+.1),hx:S+.1,hz:.1,angle:0,vx:0,vz:0},{x:0,z:H+.1,hx:S+.1,hz:.1,angle:0,vx:0,vz:0}]);for(var ne=A._perimeter,X=!1,K=0;K<O;K++){var ge=Qs(A,A.x,A.z),se=ge!==null&&A.y<=ge+Y+.012&&A.vy<=.1,Se=ge;if(se){A.y=ge+Y,A.vy=0;var Pe=Math.hypot(A.vx,A.vz),le=Math.max(0,Pe-((h=A.friction)!==null&&h!==void 0?h:1.05)*k);if(Pe>0&&(A.vx*=le/Pe,A.vz*=le/Pe),A.ramp&&A.z<1&&A.z>-1){var ae=((p=A.rampHeight)!==null&&p!==void 0?p:1.1)*.5;A.vz+=9.81*ae/(1+ae*ae)*k}}else A.vy-=9.81*k,A.airborne||(A.airborne=!0,z&&z("bodyJump",A));A.x+=A.vx*k,A.z+=A.vz*k,A.y+=A.vy*k;var fe=Qs(A,A.x,A.z);if(fe!==null){if(se&&Se!==null){var ae=((y=A.rampHeight)!==null&&y!==void 0?y:1.1)*.5;A.ramp&&A.z<=-1&&A.z-A.vz*k>-1.5&&A.vz<-.8?(A.vy=-A.vz*ae,A.airborne=!0,z&&z("bodyJump",A)):A.y=fe+Y}A.y<fe+Y&&(A.y=fe+Y,A.vy=0,A.airborne=!1)}if(A.y<2){try{for(var Ne=(i=void 0,zl(_)),Re=Ne.next();!Re.done;Re=Ne.next()){var We=Re.value;Vm(A,We,k,z)}}catch(nt){i={error:nt}}finally{try{Re&&!Re.done&&(r=Ne.return)&&r.call(Ne)}finally{if(i)throw i.error}}try{for(var Qe=(a=void 0,zl(ne)),ke=Qe.next();!ke.done;ke=Qe.next()){var We=ke.value;Vm(A,We,k,z)}}catch(nt){a={error:nt}}finally{try{ke&&!ke.done&&(s=Qe.return)&&s.call(Qe)}finally{if(a)throw a.error}}}A.spin=((M=A.spin)!==null&&M!==void 0?M:0)+Math.hypot(A.vx,A.vz)*k/Y;var qe=Math.hypot(A.vx,A.vz);try{for(var ft=(o=void 0,zl(g)),tt=ft.next();!tt.done;tt=ft.next()){var st=tt.value,Ke=Math.hypot(A.x-st.x,A.z-st.z);if(Ke<st.radius&&Math.abs(A.y-(st.y+Y))<st.heightTolerance&&qe<st.maxCaptureSpeed){A.captured=!0,A.captureElapsed=0,A.captureTarget={x:st.x,y:st.y,z:st.z},A.vx=0,A.vy=0,A.vz=0,A.atRest=!0,z&&z("zoneCapture",A,st),X=!0;break}}}catch(nt){o={error:nt}}finally{try{tt&&!tt.done&&(u=ft.return)&&u.call(ft)}finally{if(o)throw o.error}}if(X)break;if(A.y<-3||Math.abs(A.x)>S+2||Math.abs(A.z)>H+2){nh(A,z),X=!0;break}}if(!X){var en=Math.hypot(A.vx,A.vy,A.vz);en<((v=A.restSpeed)!==null&&v!==void 0?v:.07)?(A.restElapsed=((m=A.restElapsed)!==null&&m!==void 0?m:0)+D,A.restElapsed>((N=A.restDelaySeconds)!==null&&N!==void 0?N:.25)&&Hm(A,z)):A.restElapsed=0,A.movingTime>18&&nh(A,z)}}}}catch(nt){e={error:nt}}finally{try{$&&!$.done&&(t=F.return)&&t.call(F)}finally{if(e)throw e.error}}}function Wm(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(N){return Co(Co({},N),{vx:0,vz:0})}),p=[f],y={bodies:p,walls:h,zones:r,dt:Gm},M=[],v=Math.max(18,u*6),m=0;m<v&&(ih(y),m%6===0&&M.push({x:f.x,y:f.y,z:f.z}),!(f.atRest||f.captured));m++);return M}function rh(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),p=0;p<2;p++){try{for(var y=(s=void 0,zl(i)),M=y.next();!M.done;M=y.next()){var v=M.value,m=Math.cos((u=v.angle)!==null&&u!==void 0?u:0),N=Math.sin((l=v.angle)!==null&&l!==void 0?l:0),P=d-v.x,_=f-v.z,g=m*P+N*_,b=-N*P+m*_,z=Math.max(-v.hx,Math.min(v.hx,g)),T=Math.max(-v.hz,Math.min(v.hz,b)),D=g-z,G=b-T,F=Math.hypot(D,G);if(!(F>=h)){F<1e-8?v.hx-Math.abs(g)<v.hz-Math.abs(b)?(D=g<0?-1:1,G=0):(D=0,G=b<0?-1:1):(D/=F,G/=F);var $=m*D-N*G,A=N*D+m*G;d+=$*(h-F+1e-4),f+=A*(h-F+1e-4)}}}catch(Y){s={error:Y}}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),H=Math.max(0,(a??12)-h);d=Math.max(-S,Math.min(S,d)),f=Math.max(-H,Math.min(H,f))}return{x:d,z:f}}var Iv=0,Xh=1,Cv=2;var Tc=1,wd=2,ul=3,Ya=0,Fr=1,Ir=2,qa=0,dl=1,Yh=2,qh=3,Zh=4,Rv=5;var oo=100,Pv=101,Lv=102,Dv=103,Nv=104,Uv=200,Fv=201,Ov=202,Bv=203,Jh=204,$h=205,kv=206,zv=207,Vv=208,Gv=209,Hv=210,Wv=211,Xv=212,Yv=213,qv=214,Gu=0,Hu=1,Wu=2,Yo=3,Xu=4,Yu=5,qu=6,Zu=7,Td=0,Zv=1,Jv=2,Wr=0,Kh=1,Qh=2,jh=3,Ec=4,ep=5,tp=6,Ac=7,Dh="attached",$v="detached",np=300,Ds=301,lo=302,fl=303,Ed=304,Ic=306,As=1e3,va=1001,qo=1002,tr=1003,Ad=1004;var co=1005;var cr=1006,hl=1007;var Za=1008;var Xr=1009,ip=1010,rp=1011,pl=1012,Id=1013,Pa=1014,ra=1015,La=1016,Cd=1017,Rd=1018,ml=1020,ap=35902,sp=35899,op=1021,lp=1022,aa=1023,Ha=1026,Ns=1027,Pd=1028,Ld=1029,Us=1030,Dd=1031;var Nd=1033,Cc=33776,Rc=33777,Pc=33778,Lc=33779,Ud=35840,Fd=35841,Od=35842,Bd=35843,kd=36196,zd=37492,Vd=37496,Gd=37488,Hd=37489,Dc=37490,Wd=37491,Xd=37808,Yd=37809,qd=37810,Zd=37811,Jd=37812,$d=37813,Kd=37814,Qd=37815,jd=37816,ef=37817,tf=37818,nf=37819,rf=37820,af=37821,sf=36492,of=36494,lf=36495,cf=36283,uf=36284,Nc=36285,df=36286;var Ql=2300,Ju=2301,zu=2302,Nh=2303,Uh=2400,Fh=2401,Oh=2402;var Kv=3200;var Uc=0,Qv=1,Or="",xr="srgb",jl="srgb-linear",ec="linear",_i="srgb";var Vu=7680;var jv=519,e0=512,t0=513,n0=514,ff=515,i0=516,r0=517,hf=518,a0=519,s0=35044;var cp="300 es",Ca=2e3,Zo=2001;function My(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Sy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function tc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function o0(){let n=tc("canvas");return n.style.display="block",n}var Xm={},Jo=null;function up(...n){let e="THREE."+n.shift();Jo?Jo("log",e,...n):console.log(e,...n)}function l0(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 xn(...n){n=l0(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=l0(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 io(...n){let e=n.join(" ");e in Xm||(Xm[e]=!0,xn(...n))}function c0(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 u0={[Gu]:Hu,[Wu]:qu,[Xu]:Zu,[Yo]:Yu,[Hu]:Gu,[qu]:Wu,[Zu]:Xu,[Yu]:Yo},Wa=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}}},wr=["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 ah=Math.PI/180,$u=180/Math.PI;function uo(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(wr[n&255]+wr[n>>8&255]+wr[n>>16&255]+wr[n>>24&255]+"-"+wr[e&255]+wr[e>>8&255]+"-"+wr[e>>16&15|64]+wr[e>>24&255]+"-"+wr[t&63|128]+wr[t>>8&255]+"-"+wr[t>>16&255]+wr[t>>24&255]+wr[i&255]+wr[i>>8&255]+wr[i>>16&255]+wr[i>>24&255]).toLowerCase()}function Qn(n,e,t){return Math.max(e,Math.min(t,n))}function by(n,e){return(n%e+e)%e}function sh(n,e,t){return(1-t)*n+t*e}function Vl(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 zr(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 vp=class vp{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=Qn(this.x,e.x,t.x),this.y=Qn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Qn(this.x,e,t),this.y=Qn(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Qn(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(Qn(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}};vp.prototype.isVector2=!0;var Kt=vp,Vr=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],p=a[s+1],y=a[s+2],M=a[s+3];if(f!==M||u!==h||l!==p||d!==y){let v=u*h+l*p+d*y+f*M;v<0&&(h=-h,p=-p,y=-y,M=-M,v=-v);let m=1-o;if(v<.9995){let N=Math.acos(v),P=Math.sin(N);m=Math.sin(m*N)/P,o=Math.sin(o*N)/P,u=u*m+h*o,l=l*m+p*o,d=d*m+y*o,f=f*m+M*o}else{u=u*m+h*o,l=l*m+p*o,d=d*m+y*o,f=f*m+M*o;let N=1/Math.sqrt(u*u+l*l+d*d+f*f);u*=N,l*=N,d*=N,f*=N}}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],p=a[s+2],y=a[s+3];return e[t]=o*y+d*f+u*p-l*h,e[t+1]=u*y+d*h+l*f-o*p,e[t+2]=l*y+d*p+o*h-u*f,e[t+3]=d*y-o*f-u*h-l*p,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),p=u(r/2),y=u(a/2);switch(s){case"XYZ":this._x=h*d*f+l*p*y,this._y=l*p*f-h*d*y,this._z=l*d*y+h*p*f,this._w=l*d*f-h*p*y;break;case"YXZ":this._x=h*d*f+l*p*y,this._y=l*p*f-h*d*y,this._z=l*d*y-h*p*f,this._w=l*d*f+h*p*y;break;case"ZXY":this._x=h*d*f-l*p*y,this._y=l*p*f+h*d*y,this._z=l*d*y+h*p*f,this._w=l*d*f-h*p*y;break;case"ZYX":this._x=h*d*f-l*p*y,this._y=l*p*f+h*d*y,this._z=l*d*y-h*p*f,this._w=l*d*f+h*p*y;break;case"YZX":this._x=h*d*f+l*p*y,this._y=l*p*f+h*d*y,this._z=l*d*y-h*p*f,this._w=l*d*f-h*p*y;break;case"XZY":this._x=h*d*f-l*p*y,this._y=l*p*f-h*d*y,this._z=l*d*y+h*p*f,this._w=l*d*f+h*p*y;break;default:xn("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 p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(d-u)*p,this._y=(a-l)*p,this._z=(s-r)*p}else if(i>o&&i>f){let p=2*Math.sqrt(1+i-o-f);this._w=(d-u)/p,this._x=.25*p,this._y=(r+s)/p,this._z=(a+l)/p}else if(o>f){let p=2*Math.sqrt(1+o-i-f);this._w=(a-l)/p,this._x=(r+s)/p,this._y=.25*p,this._z=(u+d)/p}else{let p=2*Math.sqrt(1+f-i-o);this._w=(s-r)/p,this._x=(a+l)/p,this._y=(u+d)/p,this._z=.25*p}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(Qn(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}},gp=class gp{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(Ym.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ym.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=Qn(this.x,e.x,t.x),this.y=Qn(this.y,e.y,t.y),this.z=Qn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Qn(this.x,e,t),this.y=Qn(this.y,e,t),this.z=Qn(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Qn(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 oh.copy(this).projectOnVector(e),this.sub(oh)}reflect(e){return this.sub(oh.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(Qn(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}};gp.prototype.isVector3=!0;var _e=gp,oh=new _e,Ym=new Vr,yp=class yp{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],p=i[5],y=i[8],M=r[0],v=r[3],m=r[6],N=r[1],P=r[4],_=r[7],g=r[2],b=r[5],z=r[8];return a[0]=s*M+o*N+u*g,a[3]=s*v+o*P+u*b,a[6]=s*m+o*_+u*z,a[1]=l*M+d*N+f*g,a[4]=l*v+d*P+f*b,a[7]=l*m+d*_+f*z,a[2]=h*M+p*N+y*g,a[5]=h*v+p*P+y*b,a[8]=h*m+p*_+y*z,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,p=l*a-s*u,y=t*f+i*h+r*p;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]=p*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 io("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(lh.makeScale(e,t)),this}rotate(e){return io("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(lh.makeRotation(-e)),this}translate(e,t){return io("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(lh.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)}};yp.prototype.isMatrix3=!0;var Ln=yp,lh=new Ln,qm=new Ln().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Zm=new Ln().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function wy(){let n={enabled:!0,workingColorSpace:jl,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===_i&&(r.r=hs(r.r),r.g=hs(r.g),r.b=hs(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===_i&&(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===Or?ec: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 io("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return io("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({[jl]:{primaries:e,whitePoint:i,transfer:ec,toXYZ:qm,fromXYZ:Zm,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:xr},outputColorSpaceConfig:{drawingBufferColorSpace:xr}},[xr]:{primaries:e,whitePoint:i,transfer:_i,toXYZ:qm,fromXYZ:Zm,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:xr}}}),n}var ni=wy();function hs(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,Ku=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=tc("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=tc("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]=hs(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(hs(t[i]/255)*255):t[i]=hs(t[i]);return{data:t,width:e.width,height:e.height}}else return xn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Ty=0,$o=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Ty++}),this.uuid=uo(),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(ch(r[s].image)):a.push(ch(r[s]))}else a=ch(r);i.url=a}return t||(e.images[this.uuid]=i),i}};function ch(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Ku.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(xn("Texture: Unable to serialize Texture."),{})}var Ey=0,uh=new _e,_r=class n extends Wa{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=va,r=va,a=cr,s=Za,o=aa,u=Xr,l=n.DEFAULT_ANISOTROPY,d=Or){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ey++}),this.uuid=uo(),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 Kt(0,0),this.repeat=new Kt(1,1),this.center=new Kt(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(uh).x}get height(){return this.source.getSize(uh).y}get depth(){return this.source.getSize(uh).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){xn(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){xn(`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!==np)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case As:e.x=e.x-Math.floor(e.x);break;case va: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 As:e.y=e.y-Math.floor(e.y);break;case va: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++}};_r.DEFAULT_IMAGE=null;_r.DEFAULT_MAPPING=np;_r.DEFAULT_ANISOTROPY=1;var xp=class xp{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],p=u[5],y=u[9],M=u[2],v=u[6],m=u[10];if(Math.abs(d-h)<.01&&Math.abs(f-M)<.01&&Math.abs(y-v)<.01){if(Math.abs(d+h)<.1&&Math.abs(f+M)<.1&&Math.abs(y+v)<.1&&Math.abs(l+p+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let P=(l+1)/2,_=(p+1)/2,g=(m+1)/2,b=(d+h)/4,z=(f+M)/4,T=(y+v)/4;return P>_&&P>g?P<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(P),r=b/i,a=z/i):_>g?_<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(_),i=b/r,a=T/r):g<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(g),i=z/a,r=T/a),this.set(i,r,a,t),this}let N=Math.sqrt((v-y)*(v-y)+(f-M)*(f-M)+(h-d)*(h-d));return Math.abs(N)<.001&&(N=1),this.x=(v-y)/N,this.y=(f-M)/N,this.z=(h-d)/N,this.w=Math.acos((l+p+m-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=Qn(this.x,e.x,t.x),this.y=Qn(this.y,e.y,t.y),this.z=Qn(this.z,e.z,t.z),this.w=Qn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Qn(this.x,e,t),this.y=Qn(this.y,e,t),this.z=Qn(this.z,e,t),this.w=Qn(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Qn(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}};xp.prototype.isVector4=!0;var Ti=xp,Qu=class extends Wa{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:cr,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 Ti(0,0,e,t),this.scissorTest=!1,this.viewport=new Ti(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:i.depth},a=new _r(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:cr,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"})}},Gr=class extends Qu{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},nc=class extends _r{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=tr,this.minFilter=tr,this.wrapR=va,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 ju=class extends _r{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=tr,this.minFilter=tr,this.wrapR=va,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var bd=class bd{constructor(e,t,i,r,a,s,o,u,l,d,f,h,p,y,M,v){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,p,y,M,v)}set(e,t,i,r,a,s,o,u,l,d,f,h,p,y,M,v){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=a,m[5]=s,m[9]=o,m[13]=u,m[2]=l,m[6]=d,m[10]=f,m[14]=h,m[3]=p,m[7]=y,m[11]=M,m[15]=v,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 bd().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,p=s*f,y=o*d,M=o*f;t[0]=u*d,t[4]=-u*f,t[8]=l,t[1]=p+y*l,t[5]=h-M*l,t[9]=-o*u,t[2]=M-h*l,t[6]=y+p*l,t[10]=s*u}else if(e.order==="YXZ"){let h=u*d,p=u*f,y=l*d,M=l*f;t[0]=h+M*o,t[4]=y*o-p,t[8]=s*l,t[1]=s*f,t[5]=s*d,t[9]=-o,t[2]=p*o-y,t[6]=M+h*o,t[10]=s*u}else if(e.order==="ZXY"){let h=u*d,p=u*f,y=l*d,M=l*f;t[0]=h-M*o,t[4]=-s*f,t[8]=y+p*o,t[1]=p+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,p=s*f,y=o*d,M=o*f;t[0]=u*d,t[4]=y*l-p,t[8]=h*l+M,t[1]=u*f,t[5]=M*l+h,t[9]=p*l-y,t[2]=-l,t[6]=o*u,t[10]=s*u}else if(e.order==="YZX"){let h=s*u,p=s*l,y=o*u,M=o*l;t[0]=u*d,t[4]=M-h*f,t[8]=y*f+p,t[1]=f,t[5]=s*d,t[9]=-o*d,t[2]=-l*d,t[6]=p*f+y,t[10]=h-M*f}else if(e.order==="XZY"){let h=s*u,p=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]=p*f-y,t[2]=y*f-p,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(Ay,e,Iy)}lookAt(e,t,i){let r=this.elements;return Kr.subVectors(e,t),Kr.lengthSq()===0&&(Kr.z=1),Kr.normalize(),Ms.crossVectors(i,Kr),Ms.lengthSq()===0&&(Math.abs(i.z)===1?Kr.x+=1e-4:Kr.z+=1e-4,Kr.normalize(),Ms.crossVectors(i,Kr)),Ms.normalize(),gu.crossVectors(Kr,Ms),r[0]=Ms.x,r[4]=gu.x,r[8]=Kr.x,r[1]=Ms.y,r[5]=gu.y,r[9]=Kr.y,r[2]=Ms.z,r[6]=gu.z,r[10]=Kr.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],p=i[13],y=i[2],M=i[6],v=i[10],m=i[14],N=i[3],P=i[7],_=i[11],g=i[15],b=r[0],z=r[4],T=r[8],D=r[12],G=r[1],F=r[5],$=r[9],A=r[13],S=r[2],H=r[6],Y=r[10],oe=r[14],O=r[3],k=r[7],ne=r[11],X=r[15];return a[0]=s*b+o*G+u*S+l*O,a[4]=s*z+o*F+u*H+l*k,a[8]=s*T+o*$+u*Y+l*ne,a[12]=s*D+o*A+u*oe+l*X,a[1]=d*b+f*G+h*S+p*O,a[5]=d*z+f*F+h*H+p*k,a[9]=d*T+f*$+h*Y+p*ne,a[13]=d*D+f*A+h*oe+p*X,a[2]=y*b+M*G+v*S+m*O,a[6]=y*z+M*F+v*H+m*k,a[10]=y*T+M*$+v*Y+m*ne,a[14]=y*D+M*A+v*oe+m*X,a[3]=N*b+P*G+_*S+g*O,a[7]=N*z+P*F+_*H+g*k,a[11]=N*T+P*$+_*Y+g*ne,a[15]=N*D+P*A+_*oe+g*X,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],p=e[14],y=e[3],M=e[7],v=e[11],m=e[15],N=u*p-l*h,P=o*p-l*f,_=o*h-u*f,g=s*p-l*d,b=s*h-u*d,z=s*f-o*d;return t*(M*N-v*P+m*_)-i*(y*N-v*g+m*b)+r*(y*P-M*g+m*z)-a*(y*_-M*b+v*z)}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],p=e[11],y=e[12],M=e[13],v=e[14],m=e[15],N=t*o-i*s,P=t*u-r*s,_=t*l-a*s,g=i*u-r*o,b=i*l-a*o,z=r*l-a*u,T=d*M-f*y,D=d*v-h*y,G=d*m-p*y,F=f*v-h*M,$=f*m-p*M,A=h*m-p*v,S=N*A-P*$+_*F+g*G-b*D+z*T;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let H=1/S;return e[0]=(o*A-u*$+l*F)*H,e[1]=(r*$-i*A-a*F)*H,e[2]=(M*z-v*b+m*g)*H,e[3]=(h*b-f*z-p*g)*H,e[4]=(u*G-s*A-l*D)*H,e[5]=(t*A-r*G+a*D)*H,e[6]=(v*_-y*z-m*P)*H,e[7]=(d*z-h*_+p*P)*H,e[8]=(s*$-o*G+l*T)*H,e[9]=(i*G-t*$-a*T)*H,e[10]=(y*b-M*_+m*N)*H,e[11]=(f*_-d*b-p*N)*H,e[12]=(o*D-s*F-u*T)*H,e[13]=(t*F-i*D+r*T)*H,e[14]=(M*P-y*g-v*N)*H,e[15]=(d*g-f*P+h*N)*H,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,p=a*d,y=a*f,M=s*d,v=s*f,m=o*f,N=u*l,P=u*d,_=u*f,g=i.x,b=i.y,z=i.z;return r[0]=(1-(M+m))*g,r[1]=(p+_)*g,r[2]=(y-P)*g,r[3]=0,r[4]=(p-_)*b,r[5]=(1-(h+m))*b,r[6]=(v+N)*b,r[7]=0,r[8]=(y+P)*z,r[9]=(v-N)*z,r[10]=(1-(h+M))*z,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),Ea.copy(this);let l=1/s,d=1/o,f=1/u;return Ea.elements[0]*=l,Ea.elements[1]*=l,Ea.elements[2]*=l,Ea.elements[4]*=d,Ea.elements[5]*=d,Ea.elements[6]*=d,Ea.elements[8]*=f,Ea.elements[9]*=f,Ea.elements[10]*=f,t.setFromRotationMatrix(Ea),i.x=s,i.y=o,i.z=u,this}makePerspective(e,t,i,r,a,s,o=Ca,u=!1){let l=this.elements,d=2*a/(t-e),f=2*a/(i-r),h=(t+e)/(t-e),p=(i+r)/(i-r),y,M;if(u)y=a/(s-a),M=s*a/(s-a);else if(o===Ca)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]=p,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=Ca,u=!1){let l=this.elements,d=2/(t-e),f=2/(i-r),h=-(t+e)/(t-e),p=-(i+r)/(i-r),y,M;if(u)y=1/(s-a),M=s/(s-a);else if(o===Ca)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]=p,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}};bd.prototype.isMatrix4=!0;var Dn=bd,Po=new _e,Ea=new Dn,Ay=new _e(0,0,0),Iy=new _e(1,1,1),Ms=new _e,gu=new _e,Kr=new _e,Jm=new Dn,$m=new Vr,ga=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],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Qn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Qn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(u,l)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Qn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(u,a));break;case"ZYX":this._y=Math.asin(-Qn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Qn(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,p));break;case"XZY":this._z=Math.asin(-Qn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:xn("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Jm.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Jm,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return $m.setFromEuler(this),this.setFromQuaternion($m,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}};ga.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}},Cy=0,Km=new _e,Lo=new Vr,ls=new Dn,yu=new _e,Gl=new _e,Ry=new _e,Py=new Vr,Qm=new _e(1,0,0),jm=new _e(0,1,0),ev=new _e(0,0,1),tv={type:"added"},Ly={type:"removed"},Do={type:"childadded",child:null},dh={type:"childremoved",child:null},ur=class n extends Wa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Cy++}),this.uuid=uo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new _e,t=new ga,i=new Vr,r=new _e(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 Dn},normalMatrix:{value:new Ln}}),this.matrix=new Dn,this.matrixWorld=new Dn,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(jm,e)}rotateZ(e){return this.rotateOnAxis(ev,e)}translateOnAxis(e,t){return Km.copy(e).applyQuaternion(this.quaternion),this.position.add(Km.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Qm,e)}translateY(e){return this.translateOnAxis(jm,e)}translateZ(e){return this.translateOnAxis(ev,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ls.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?yu.copy(e):yu.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Gl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ls.lookAt(Gl,yu,this.up):ls.lookAt(yu,Gl,this.up),this.quaternion.setFromRotationMatrix(ls),r&&(ls.extractRotation(r.matrixWorld),Lo.setFromRotationMatrix(ls),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(tv),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(Ly),dh.child=e,this.dispatchEvent(dh),dh.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),ls.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ls.multiply(e.parent.matrixWorld)),e.applyMatrix4(ls),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(tv),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(Gl,e,Ry),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gl,Py,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),p=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),p.length>0&&(i.animations=p),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"})}};ur.DEFAULT_UP=new _e(0,1,0);ur.DEFAULT_MATRIX_AUTO_UPDATE=!0;ur.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var lr=class extends ur{constructor(){super(),this.isGroup=!0,this.type="Group"}},Dy={type:"move"},Qo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new lr,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 lr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new _e,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new _e),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new lr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new _e,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new _e,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 v=t.getJointPose(M,i),m=this._getHandJoint(l,M);v!==null&&(m.matrix.fromArray(v.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=v.radius),m.visible=v!==null}let d=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],h=d.position.distanceTo(f.position),p=.02,y=.005;l.inputState.pinching&&h>p+y?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=p-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(Dy)))}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 lr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},d0={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},Ss={h:0,s:0,l:0},xu={h:0,s:0,l:0};function fh(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 Cn=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=xr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ni.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=ni.workingColorSpace){return this.r=e,this.g=t,this.b=i,ni.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=ni.workingColorSpace){if(e=by(e,1),t=Qn(t,0,1),i=Qn(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=fh(s,a,e+1/3),this.g=fh(s,a,e),this.b=fh(s,a,e-1/3)}return ni.colorSpaceToWorking(this,r),this}setStyle(e,t=xr){function i(a){a!==void 0&&parseFloat(a)<1&&xn("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:xn("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);xn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=xr){let i=d0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):xn("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=hs(e.r),this.g=hs(e.g),this.b=hs(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=xr){return ni.workingToColorSpace(Tr.copy(this),e),Math.round(Qn(Tr.r*255,0,255))*65536+Math.round(Qn(Tr.g*255,0,255))*256+Math.round(Qn(Tr.b*255,0,255))}getHexString(e=xr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ni.workingColorSpace){ni.workingToColorSpace(Tr.copy(this),t);let i=Tr.r,r=Tr.g,a=Tr.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=ni.workingColorSpace){return ni.workingToColorSpace(Tr.copy(this),t),e.r=Tr.r,e.g=Tr.g,e.b=Tr.b,e}getStyle(e=xr){ni.workingToColorSpace(Tr.copy(this),e);let t=Tr.r,i=Tr.g,r=Tr.b;return e!==xr?`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(Ss),this.setHSL(Ss.h+e,Ss.s+t,Ss.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(Ss),e.getHSL(xu);let i=sh(Ss.h,xu.h,t),r=sh(Ss.s,xu.s,t),a=sh(Ss.l,xu.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}},Tr=new Cn;Cn.NAMES=d0;var ic=class extends ur{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 ga,this.environmentIntensity=1,this.environmentRotation=new ga,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}},Aa=new _e,cs=new _e,hh=new _e,us=new _e,No=new _e,Uo=new _e,nv=new _e,ph=new _e,mh=new _e,vh=new _e,gh=new Ti,yh=new Ti,xh=new Ti,Es=class n{constructor(e=new _e,t=new _e,i=new _e){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Aa.subVectors(e,t),r.cross(Aa);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){Aa.subVectors(r,t),cs.subVectors(i,t),hh.subVectors(e,t);let s=Aa.dot(Aa),o=Aa.dot(cs),u=Aa.dot(hh),l=cs.dot(cs),d=cs.dot(hh),f=s*l-o*o;if(f===0)return a.set(0,0,0),null;let h=1/f,p=(l*u-o*d)*h,y=(s*d-o*u)*h;return a.set(1-p-y,y,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,us)===null?!1:us.x>=0&&us.y>=0&&us.x+us.y<=1}static getInterpolation(e,t,i,r,a,s,o,u){return this.getBarycoord(e,t,i,r,us)===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,us.x),u.addScaledVector(s,us.y),u.addScaledVector(o,us.z),u)}static getInterpolatedAttribute(e,t,i,r,a,s){return gh.setScalar(0),yh.setScalar(0),xh.setScalar(0),gh.fromBufferAttribute(e,t),yh.fromBufferAttribute(e,i),xh.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(gh,a.x),s.addScaledVector(yh,a.y),s.addScaledVector(xh,a.z),s}static isFrontFacing(e,t,i,r){return Aa.subVectors(i,t),cs.subVectors(e,t),Aa.cross(cs).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 Aa.subVectors(this.c,this.b),cs.subVectors(this.a,this.b),Aa.cross(cs).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),ph.subVectors(e,i);let u=No.dot(ph),l=Uo.dot(ph);if(u<=0&&l<=0)return t.copy(i);mh.subVectors(e,r);let d=No.dot(mh),f=Uo.dot(mh);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);vh.subVectors(e,a);let p=No.dot(vh),y=Uo.dot(vh);if(y>=0&&p<=y)return t.copy(a);let M=p*l-u*y;if(M<=0&&l>=0&&y<=0)return o=l/(l-y),t.copy(i).addScaledVector(Uo,o);let v=d*y-p*f;if(v<=0&&f-d>=0&&p-y>=0)return nv.subVectors(a,r),o=(f-d)/(f-d+(p-y)),t.copy(r).addScaledVector(nv,o);let m=1/(v+M+h);return s=M*m,o=h*m,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)}},ea=class{constructor(e=new _e(1/0,1/0,1/0),t=new _e(-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(Ia.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Ia.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=Ia.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,Ia):Ia.fromBufferAttribute(a,s),Ia.applyMatrix4(e.matrixWorld),this.expandByPoint(Ia);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),_u.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),_u.copy(i.boundingBox)),_u.applyMatrix4(e.matrixWorld),this.union(_u)}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,Ia),Ia.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(Hl),Mu.subVectors(this.max,Hl),Fo.subVectors(e.a,Hl),Oo.subVectors(e.b,Hl),Bo.subVectors(e.c,Hl),bs.subVectors(Oo,Fo),ws.subVectors(Bo,Oo),js.subVectors(Fo,Bo);let t=[0,-bs.z,bs.y,0,-ws.z,ws.y,0,-js.z,js.y,bs.z,0,-bs.x,ws.z,0,-ws.x,js.z,0,-js.x,-bs.y,bs.x,0,-ws.y,ws.x,0,-js.y,js.x,0];return!_h(t,Fo,Oo,Bo,Mu)||(t=[1,0,0,0,1,0,0,0,1],!_h(t,Fo,Oo,Bo,Mu))?!1:(Su.crossVectors(bs,ws),t=[Su.x,Su.y,Su.z],_h(t,Fo,Oo,Bo,Mu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ia).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ia).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:(ds[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ds[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ds[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ds[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ds[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ds[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ds[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ds[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ds),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}},ds=[new _e,new _e,new _e,new _e,new _e,new _e,new _e,new _e],Ia=new _e,_u=new ea,Fo=new _e,Oo=new _e,Bo=new _e,bs=new _e,ws=new _e,js=new _e,Hl=new _e,Mu=new _e,Su=new _e,eo=new _e;function _h(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){eo.fromArray(n,a);let o=r.x*Math.abs(eo.x)+r.y*Math.abs(eo.y)+r.z*Math.abs(eo.z),u=e.dot(eo),l=t.dot(eo),d=i.dot(eo);if(Math.max(-Math.max(u,l,d),Math.min(u,l,d))>o)return!1}return!0}var er=new _e,bu=new Kt,Ny=0,Ar=class extends Wa{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:Ny++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=s0,this.updateRanges=[],this.gpuType=ra,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++)bu.fromBufferAttribute(this,t),bu.applyMatrix3(e),this.setXY(t,bu.x,bu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)er.fromBufferAttribute(this,t),er.applyMatrix3(e),this.setXYZ(t,er.x,er.y,er.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)er.fromBufferAttribute(this,t),er.applyMatrix4(e),this.setXYZ(t,er.x,er.y,er.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)er.fromBufferAttribute(this,t),er.applyNormalMatrix(e),this.setXYZ(t,er.x,er.y,er.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)er.fromBufferAttribute(this,t),er.transformDirection(e),this.setXYZ(t,er.x,er.y,er.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=Vl(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=zr(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Vl(t,this.array)),t}setX(e,t){return this.normalized&&(t=zr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Vl(t,this.array)),t}setY(e,t){return this.normalized&&(t=zr(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=Vl(t,this.array)),t}setZ(e,t){return this.normalized&&(t=zr(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=Vl(t,this.array)),t}setW(e,t){return this.normalized&&(t=zr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=zr(t,this.array),i=zr(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=zr(t,this.array),i=zr(i,this.array),r=zr(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=zr(t,this.array),i=zr(i,this.array),r=zr(r,this.array),a=zr(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 rc=class extends Ar{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var ac=class extends Ar{constructor(e,t,i){super(new Uint32Array(e),t,i)}};var mi=class extends Ar{constructor(e,t,i){super(new Float32Array(e),t,i)}},Uy=new ea,Wl=new _e,Mh=new _e,Xa=class{constructor(e=new _e,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):Uy.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;Wl.subVectors(e,this.center);let t=Wl.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Wl,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):(Mh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Wl.copy(e.center).add(Mh)),this.expandByPoint(Wl.copy(e.center).sub(Mh))),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}},Fy=0,ma=new Dn,Sh=new ur,ko=new _e,Qr=new ea,Xl=new ea,yr=new _e,dr=class n extends Wa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Fy++}),this.uuid=uo(),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(My(e)?ac:rc)(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 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 Sh.lookAt(e),Sh.updateMatrix(),this.applyMatrix4(Sh.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 mi(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&&xn("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 ea);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 _e(-1/0,-1/0,-1/0),new _e(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];Qr.setFromBufferAttribute(a),this.morphTargetsRelative?(yr.addVectors(this.boundingBox.min,Qr.min),this.boundingBox.expandByPoint(yr),yr.addVectors(this.boundingBox.max,Qr.max),this.boundingBox.expandByPoint(yr)):(this.boundingBox.expandByPoint(Qr.min),this.boundingBox.expandByPoint(Qr.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 Xa);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 _e,1/0);return}if(e){let i=this.boundingSphere.center;if(Qr.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){let o=t[a];Xl.setFromBufferAttribute(o),this.morphTargetsRelative?(yr.addVectors(Qr.min,Xl.min),Qr.expandByPoint(yr),yr.addVectors(Qr.max,Xl.max),Qr.expandByPoint(yr)):(Qr.expandByPoint(Xl.min),Qr.expandByPoint(Xl.max))}Qr.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)yr.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(yr));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++)yr.fromBufferAttribute(o,l),u&&(ko.fromBufferAttribute(e,l),yr.add(ko)),r=Math.max(r,i.distanceToSquared(yr))}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 Ar(new Float32Array(4*i.count),4),this.setAttribute("tangent",s));let o=[],u=[];for(let T=0;T<i.count;T++)o[T]=new _e,u[T]=new _e;let l=new _e,d=new _e,f=new _e,h=new Kt,p=new Kt,y=new Kt,M=new _e,v=new _e;function m(T,D,G){l.fromBufferAttribute(i,T),d.fromBufferAttribute(i,D),f.fromBufferAttribute(i,G),h.fromBufferAttribute(a,T),p.fromBufferAttribute(a,D),y.fromBufferAttribute(a,G),d.sub(l),f.sub(l),p.sub(h),y.sub(h);let F=1/(p.x*y.y-y.x*p.y);isFinite(F)&&(M.copy(d).multiplyScalar(y.y).addScaledVector(f,-p.y).multiplyScalar(F),v.copy(f).multiplyScalar(p.x).addScaledVector(d,-y.x).multiplyScalar(F),o[T].add(M),o[D].add(M),o[G].add(M),u[T].add(v),u[D].add(v),u[G].add(v))}let N=this.groups;N.length===0&&(N=[{start:0,count:e.count}]);for(let T=0,D=N.length;T<D;++T){let G=N[T],F=G.start,$=G.count;for(let A=F,S=F+$;A<S;A+=3)m(e.getX(A+0),e.getX(A+1),e.getX(A+2))}let P=new _e,_=new _e,g=new _e,b=new _e;function z(T){g.fromBufferAttribute(r,T),b.copy(g);let D=o[T];P.copy(D),P.sub(g.multiplyScalar(g.dot(D))).normalize(),_.crossVectors(b,D);let F=_.dot(u[T])<0?-1:1;s.setXYZW(T,P.x,P.y,P.z,F)}for(let T=0,D=N.length;T<D;++T){let G=N[T],F=G.start,$=G.count;for(let A=F,S=F+$;A<S;A+=3)z(e.getX(A+0)),z(e.getX(A+1)),z(e.getX(A+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 Ar(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,p=i.count;h<p;h++)i.setXYZ(h,0,0,0);let r=new _e,a=new _e,s=new _e,o=new _e,u=new _e,l=new _e,d=new _e,f=new _e;if(e)for(let h=0,p=e.count;h<p;h+=3){let y=e.getX(h+0),M=e.getX(h+1),v=e.getX(h+2);r.fromBufferAttribute(t,y),a.fromBufferAttribute(t,M),s.fromBufferAttribute(t,v),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,y),u.fromBufferAttribute(i,M),l.fromBufferAttribute(i,v),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(v,l.x,l.y,l.z)}else for(let h=0,p=t.count;h<p;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++)yr.fromBufferAttribute(e,t),yr.normalize(),e.setXYZ(t,yr.x,yr.y,yr.z)}toNonIndexed(){function e(o,u){let l=o.array,d=o.itemSize,f=o.normalized,h=new l.constructor(u.length*d),p=0,y=0;for(let M=0,v=u.length;M<v;M++){o.isInterleavedBufferAttribute?p=u[M]*o.data.stride+o.offset:p=u[M]*d;for(let m=0;m<d;m++)h[y++]=l[p++]}return new Ar(h,d,f)}if(this.index===null)return xn("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],p=e(h,i);u.push(p)}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 p=l[f];d.push(p.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,p=f.length;h<p;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 bh=new _e,Oy=new _e,By=new Ln,jr=class{constructor(e=new _e(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=bh.subVectors(i,t).cross(Oy.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(bh),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||By.getNormalMatrix(e),r=this.coplanarPoint(bh).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}},ky=0,ps=class extends Wa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ky++}),this.uuid=uo(),this.name="",this.type="Material",this.blending=dl,this.side=Ya,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Jh,this.blendDst=$h,this.blendEquation=oo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Cn(0,0,0),this.blendAlpha=0,this.depthFunc=Yo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=jv,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Vu,this.stencilZFail=Vu,this.stencilZPass=Vu,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){xn(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){xn(`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 Cn().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 jr().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 Kt().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 Kt().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 fs=new _e,wh=new _e,wu=new _e,Tu=new _e,jo=class{constructor(e=new _e,t=new _e(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,fs)),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=fs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(fs.copy(this.origin).addScaledVector(this.direction,t),fs.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){wh.copy(e).add(t).multiplyScalar(.5),wu.copy(t).sub(e).normalize(),Tu.copy(this.origin).sub(wh);let a=e.distanceTo(t)*.5,s=-this.direction.dot(wu),o=Tu.dot(this.direction),u=-Tu.dot(wu),l=Tu.lengthSq(),d=Math.abs(1-s*s),f,h,p,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,p=f*(f+s*h+2*o)+h*(s*f+h+2*u)+l}else h=a,f=Math.max(0,-(s*h+o)),p=-f*f+h*(h+2*u)+l;else h=-a,f=Math.max(0,-(s*h+o)),p=-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),p=-f*f+h*(h+2*u)+l):h<=y?(f=0,h=Math.min(Math.max(-a,-u),a),p=h*(h+2*u)+l):(f=Math.max(0,-(s*a+o)),h=f>0?a:Math.min(Math.max(-a,-u),a),p=-f*f+h*(h+2*u)+l);else h=s>0?-a:a,f=Math.max(0,-(s*h+o)),p=-f*f+h*(h+2*u)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(wh).addScaledVector(wu,h),p}intersectSphere(e,t){if(e.radius<0)return null;fs.subVectors(e.center,this.origin);let i=fs.dot(this.direction),r=fs.dot(fs)-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,fs)!==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,p=e.z-s.z,y=t.x-s.x,M=t.y-s.y,v=t.z-s.z,m=i.x-s.x,N=i.y-s.y,P=i.z-s.z,_=Math.abs(u),g=Math.abs(l),b=Math.abs(d),z,T,D,G,F,$,A,S,H,Y,oe,O;if(_>=g&&_>=b?(D=u,$=f,H=y,O=m,u>=0?(z=l,T=d,G=h,F=p,A=M,S=v,Y=N,oe=P):(z=d,T=l,G=p,F=h,A=v,S=M,Y=P,oe=N)):g>=b?(D=l,$=h,H=M,O=N,l>=0?(z=d,T=u,G=p,F=f,A=v,S=y,Y=P,oe=m):(z=u,T=d,G=f,F=p,A=y,S=v,Y=m,oe=P)):(D=d,$=p,H=v,O=P,d>=0?(z=u,T=l,G=f,F=h,A=y,S=M,Y=m,oe=N):(z=l,T=u,G=h,F=f,A=M,S=y,Y=N,oe=m)),D===0)return null;let k=z/D,ne=T/D,X=1/D,K=G-k*$,ge=F-ne*$,se=A-k*H,Se=S-ne*H,Pe=Y-k*O,le=oe-ne*O,ae=Pe*Se-le*se,fe=K*le-ge*Pe,Ne=se*ge-Se*K;if(r){if(ae<0||fe<0||Ne<0)return null}else if((ae<0||fe<0||Ne<0)&&(ae>0||fe>0||Ne>0))return null;let Re=ae+fe+Ne;if(Re===0)return null;let We=X*(ae*$+fe*H+Ne*O);return(Re>0?We<0:We>0)?null:this.at(We/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)}},Hr=class extends ps{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Cn(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 ga,this.combine=Td,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}},iv=new Dn,to=new jo,Eu=new Xa,rv=new _e,Au=new _e,Iu=new _e,Cu=new _e,Th=new _e,Ru=new _e,av=new _e,Pu=new _e,li=class extends ur{constructor(e=new dr,t=new Hr){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){Ru.set(0,0,0);for(let u=0,l=a.length;u<l;u++){let d=o[u],f=a[u];d!==0&&(Th.fromBufferAttribute(f,e),s?Ru.addScaledVector(Th,d):Ru.addScaledVector(Th.sub(t),d))}t.add(Ru)}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(),Eu.copy(i.boundingSphere),Eu.applyMatrix4(a),to.copy(e.ray).recast(e.near),!(Eu.containsPoint(to.origin)===!1&&(to.intersectSphere(Eu,rv)===null||to.origin.distanceToSquared(rv)>(e.far-e.near)**2))&&(iv.copy(a).invert(),to.copy(e.ray).applyMatrix4(iv),!(i.boundingBox!==null&&to.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,to)))}_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,p=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,M=h.length;y<M;y++){let v=h[y],m=s[v.materialIndex],N=Math.max(v.start,p.start),P=Math.min(o.count,Math.min(v.start+v.count,p.start+p.count));for(let _=N,g=P;_<g;_+=3){let b=o.getX(_),z=o.getX(_+1),T=o.getX(_+2);r=Lu(this,m,e,i,l,d,f,b,z,T),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=v.materialIndex,t.push(r))}}else{let y=Math.max(0,p.start),M=Math.min(o.count,p.start+p.count);for(let v=y,m=M;v<m;v+=3){let N=o.getX(v),P=o.getX(v+1),_=o.getX(v+2);r=Lu(this,s,e,i,l,d,f,N,P,_),r&&(r.faceIndex=Math.floor(v/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(s))for(let y=0,M=h.length;y<M;y++){let v=h[y],m=s[v.materialIndex],N=Math.max(v.start,p.start),P=Math.min(u.count,Math.min(v.start+v.count,p.start+p.count));for(let _=N,g=P;_<g;_+=3){let b=_,z=_+1,T=_+2;r=Lu(this,m,e,i,l,d,f,b,z,T),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=v.materialIndex,t.push(r))}}else{let y=Math.max(0,p.start),M=Math.min(u.count,p.start+p.count);for(let v=y,m=M;v<m;v+=3){let N=v,P=v+1,_=v+2;r=Lu(this,s,e,i,l,d,f,N,P,_),r&&(r.faceIndex=Math.floor(v/3),t.push(r))}}}};function zy(n,e,t,i,r,a,s,o){let u;if(e.side===Fr?u=i.intersectTriangle(s,a,r,!0,o):u=i.intersectTriangle(r,a,s,e.side===Ya,o),u===null)return null;Pu.copy(o),Pu.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Pu);return l<t.near||l>t.far?null:{distance:l,point:Pu.clone(),object:n}}function Lu(n,e,t,i,r,a,s,o,u,l){n.getVertexPosition(o,Au),n.getVertexPosition(u,Iu),n.getVertexPosition(l,Cu);let d=zy(n,e,t,i,Au,Iu,Cu,av);if(d){let f=new _e;Es.getBarycoord(av,Au,Iu,Cu,f),r&&(d.uv=Es.getInterpolatedAttribute(r,o,u,l,f,new Kt)),a&&(d.uv1=Es.getInterpolatedAttribute(a,o,u,l,f,new Kt)),s&&(d.normal=Es.getInterpolatedAttribute(s,o,u,l,f,new _e),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));let h={a:o,b:u,c:l,normal:new _e,materialIndex:0};Es.getNormal(Au,Iu,Cu,h.normal),d.face=h,d.barycoord=f}return d}var Yl=new Ti,sv=new Ti,ov=new Ti,Vy=new Ti,lv=new Dn,Du=new _e,Eh=new Xa,cv=new Dn,Ah=new jo,sc=class extends li{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Dh,this.bindMatrix=new Dn,this.bindMatrixInverse=new Dn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ea),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Du),this.boundingBox.expandByPoint(Du)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Xa),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Du),this.boundingSphere.expandByPoint(Du)}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(),Eh.copy(this.boundingSphere),Eh.applyMatrix4(r),e.ray.intersectsSphere(Eh)!==!1&&(cv.copy(r).invert(),Ah.copy(e.ray).applyMatrix4(cv),!(this.boundingBox!==null&&Ah.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Ah)))}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 Ti,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===Dh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===$v?this.bindMatrixInverse.copy(this.bindMatrix).invert():xn("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;sv.fromBufferAttribute(r.attributes.skinIndex,e),ov.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(Yl.copy(t),t.set(0,0,0,0)):(Yl.set(...t,1),t.set(0,0,0)),Yl.applyMatrix4(this.bindMatrix);for(let a=0;a<4;a++){let s=ov.getComponent(a);if(s!==0){let o=sv.getComponent(a);lv.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Vy.copy(Yl).applyMatrix4(lv),s)}}return t.isVector4&&(t.w=Yl.w),t.applyMatrix4(this.bindMatrixInverse)}},el=class extends ur{constructor(){super(),this.isBone=!0,this.type="Bone"}},Is=class extends _r{constructor(e=null,t=1,i=1,r,a,s,o,u,l=tr,d=tr,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}},uv=new Dn,Gy=new Dn,tl=class n{constructor(e=[],t=[]){this.uuid=uo(),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){xn("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 Dn)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Dn;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:Gy;uv.multiplyMatrices(o,t[a]),uv.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 Is(t,e,e,aa,ra);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&&(xn("Skeleton: No bone found with UUID:",a),s=new el),this.bones.push(s),this.boneInverses.push(new Dn().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}},oc=class extends Ar{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 Dn,dv=new Dn,Nu=[],fv=new ea,Hy=new Dn,ql=new li,Zl=new Xa,Ra=class extends li{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new oc(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,Hy)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ea),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,zo),fv.copy(e.boundingBox).applyMatrix4(zo),this.boundingBox.union(fv)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Xa),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,zo),Zl.copy(e.boundingSphere).applyMatrix4(zo),this.boundingSphere.union(Zl)}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(ql.geometry=this.geometry,ql.material=this.material,ql.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Zl.copy(this.boundingSphere),Zl.applyMatrix4(i),e.ray.intersectsSphere(Zl)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,zo),dv.multiplyMatrices(i,zo),ql.matrixWorld=dv,ql.raycast(e,Nu);for(let s=0,o=Nu.length;s<o;s++){let u=Nu[s];u.instanceId=a,u.object=this,t.push(u)}Nu.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new oc(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 Is(new Float32Array(r*this.count),r,this.count,Pd,ra));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)}},no=new Xa,Wy=new Kt(.5,.5),Uu=new _e,nl=class{constructor(e=new jr,t=new jr,i=new jr,r=new jr,a=new jr,s=new jr){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=Ca,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],p=a[7],y=a[8],M=a[9],v=a[10],m=a[11],N=a[12],P=a[13],_=a[14],g=a[15];if(r[0].setComponents(l-s,p-d,m-y,g-N).normalize(),r[1].setComponents(l+s,p+d,m+y,g+N).normalize(),r[2].setComponents(l+o,p+f,m+M,g+P).normalize(),r[3].setComponents(l-o,p-f,m-M,g-P).normalize(),i)r[4].setComponents(u,h,v,_).normalize(),r[5].setComponents(l-u,p-h,m-v,g-_).normalize();else if(r[4].setComponents(l-u,p-h,m-v,g-_).normalize(),t===Ca)r[5].setComponents(l+u,p+h,m+v,g+_).normalize();else if(t===Zo)r[5].setComponents(u,h,v,_).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(),no.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),no.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(no)}intersectsSprite(e){no.center.set(0,0,0);let t=Wy.distanceTo(e.center);return no.radius=.7071067811865476+t,no.applyMatrix4(e.matrixWorld),this.intersectsSphere(no)}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(Uu.x=r.normal.x>0?e.max.x:e.min.x,Uu.y=r.normal.y>0?e.max.y:e.min.y,Uu.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Uu)<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 lc=class extends _r{constructor(e=[],t=Ds,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 Cs=class extends _r{constructor(e,t,i=Pa,r,a,s,o=tr,u=tr,l,d=Ha,f=1){if(d!==Ha&&d!==Ns)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}},ed=class extends Cs{constructor(e,t=Pa,i=Ds,r,a,s=tr,o=tr,u,l=Ha){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}},cc=class extends _r{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Ur=class n extends dr{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,p=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 mi(l,3)),this.setAttribute("normal",new mi(d,3)),this.setAttribute("uv",new mi(f,2));function y(M,v,m,N,P,_,g,b,z,T,D){let G=_/z,F=g/T,$=_/2,A=g/2,S=b/2,H=z+1,Y=T+1,oe=0,O=0,k=new _e;for(let ne=0;ne<Y;ne++){let X=ne*F-A;for(let K=0;K<H;K++){let ge=K*G-$;k[M]=ge*N,k[v]=X*P,k[m]=S,l.push(k.x,k.y,k.z),k[M]=0,k[v]=0,k[m]=b>0?1:-1,d.push(k.x,k.y,k.z),f.push(K/z),f.push(1-ne/T),oe+=1}}for(let ne=0;ne<T;ne++)for(let X=0;X<z;X++){let K=h+X+H*ne,ge=h+X+H*(ne+1),se=h+(X+1)+H*(ne+1),Se=h+(X+1)+H*ne;u.push(K,ge,Se),u.push(ge,se,Se),O+=6}o.addGroup(p,O,D),p+=O,h+=oe}}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 dr{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 _e,d=new Kt;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 p=i+f/t*r;l.x=e*Math.cos(p),l.y=e*Math.sin(p),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 mi(s,3)),this.setAttribute("normal",new mi(o,3)),this.setAttribute("uv",new mi(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)}},ro=class n extends dr{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=[],p=[],y=0,M=[],v=i/2,m=0;N(),s===!1&&(e>0&&P(!0),t>0&&P(!1)),this.setIndex(d),this.setAttribute("position",new mi(f,3)),this.setAttribute("normal",new mi(h,3)),this.setAttribute("uv",new mi(p,2));function N(){let _=new _e,g=new _e,b=0,z=(t-e)/i;for(let T=0;T<=a;T++){let D=[],G=T/a,F=G*(t-e)+e;for(let $=0;$<=r;$++){let A=$/r,S=A*u+o,H=Math.sin(S),Y=Math.cos(S);g.x=F*H,g.y=-G*i+v,g.z=F*Y,f.push(g.x,g.y,g.z),_.set(H,z,Y).normalize(),h.push(_.x,_.y,_.z),p.push(A,1-G),D.push(y++)}M.push(D)}for(let T=0;T<r;T++)for(let D=0;D<a;D++){let G=M[D][T],F=M[D+1][T],$=M[D+1][T+1],A=M[D][T+1];(e>0||D!==0)&&(d.push(G,F,A),b+=3),(t>0||D!==a-1)&&(d.push(F,$,A),b+=3)}l.addGroup(m,b,0),m+=b}function P(_){let g=y,b=new Kt,z=new _e,T=0,D=_===!0?e:t,G=_===!0?1:-1;for(let $=1;$<=r;$++)f.push(0,v*G,0),h.push(0,G,0),p.push(.5,.5),y++;let F=y;for(let $=0;$<=r;$++){let S=$/r*u+o,H=Math.cos(S),Y=Math.sin(S);z.x=D*Y,z.y=v*G,z.z=D*H,f.push(z.x,z.y,z.z),h.push(0,G,0),b.x=H*.5+.5,b.y=Y*.5*G+.5,p.push(b.x,b.y),y++}for(let $=0;$<r;$++){let A=g+$,S=F+$;_===!0?d.push(S,S+1,A):d.push(S+1,S,A),T+=3}l.addGroup(m,T,_===!0?1:2),m+=T}}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 ta=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){xn("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,p=(s-d)/h;return(r+p)/(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 Kt:new _e);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 _e,r=[],a=[],s=[],o=new _e,u=new Dn;for(let p=0;p<=e;p++){let y=p/e;r[p]=this.getTangentAt(y,new _e)}a[0]=new _e,s[0]=new _e;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 p=1;p<=e;p++){if(a[p]=a[p-1].clone(),s[p]=s[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();let y=Math.acos(Qn(r[p-1].dot(r[p]),-1,1));a[p].applyMatrix4(u.makeRotationAxis(o,y))}s[p].crossVectors(r[p],a[p])}if(t===!0){let p=Math.acos(Qn(a[0].dot(a[e]),-1,1));p/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(p=-p);for(let y=1;y<=e;y++)a[y].applyMatrix4(u.makeRotationAxis(r[y],p*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 ta{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 Kt){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,p=l-this.aY;u=h*d-p*f+this.aX,l=h*f+p*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}},td=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 dp(){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,p=(o-s)/d-(u-s)/(d+f)+(u-o)/f;h*=d,p*=d,r(s,o,h,p)},calc:function(a){let s=a*a,o=s*a;return n+e*a+t*s+i*o}}}var hv=new _e,pv=new _e,Ih=new dp,Ch=new dp,Rh=new dp,nd=class extends ta{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 _e){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]:(pv.subVectors(r[0],r[1]).add(r[0]),l=pv);let f=r[o%a],h=r[(o+1)%a];if(this.closed||o+2<a?d=r[(o+2)%a]:(hv.subVectors(r[a-1],r[a-2]).add(r[a-1]),d=hv),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,y=Math.pow(l.distanceToSquared(f),p),M=Math.pow(f.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p);M<1e-4&&(M=1),y<1e-4&&(y=M),v<1e-4&&(v=M),Ih.initNonuniformCatmullRom(l.x,f.x,h.x,d.x,y,M,v),Ch.initNonuniformCatmullRom(l.y,f.y,h.y,d.y,y,M,v),Rh.initNonuniformCatmullRom(l.z,f.z,h.z,d.z,y,M,v)}else this.curveType==="catmullrom"&&(Ih.initCatmullRom(l.x,f.x,h.x,d.x,this.tension),Ch.initCatmullRom(l.y,f.y,h.y,d.y,this.tension),Rh.initCatmullRom(l.z,f.z,h.z,d.z,this.tension));return i.set(Ih.calc(u),Ch.calc(u),Rh.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 _e().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function mv(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 Xy(n,e){let t=1-n;return t*t*e}function Yy(n,e){return 2*(1-n)*n*e}function qy(n,e){return n*n*e}function $l(n,e,t,i){return Xy(n,e)+Yy(n,t)+qy(n,i)}function Zy(n,e){let t=1-n;return t*t*t*e}function Jy(n,e){let t=1-n;return 3*t*t*n*e}function $y(n,e){return 3*(1-n)*n*n*e}function Ky(n,e){return n*n*n*e}function Kl(n,e,t,i,r){return Zy(n,e)+Jy(n,t)+$y(n,i)+Ky(n,r)}var uc=class extends ta{constructor(e=new Kt,t=new Kt,i=new Kt,r=new Kt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Kt){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(Kl(e,r.x,a.x,s.x,o.x),Kl(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}},id=class extends ta{constructor(e=new _e,t=new _e,i=new _e,r=new _e){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new _e){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(Kl(e,r.x,a.x,s.x,o.x),Kl(e,r.y,a.y,s.y,o.y),Kl(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}},dc=class extends ta{constructor(e=new Kt,t=new Kt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Kt){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 Kt){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}},rd=class extends ta{constructor(e=new _e,t=new _e){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new _e){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 _e){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}},fc=class extends ta{constructor(e=new Kt,t=new Kt,i=new Kt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Kt){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set($l(e,r.x,a.x,s.x),$l(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}},ad=class extends ta{constructor(e=new _e,t=new _e,i=new _e){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new _e){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set($l(e,r.x,a.x,s.x),$l(e,r.y,a.y,s.y),$l(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}},hc=class extends ta{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Kt){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(mv(o,u.x,l.x,d.x,f.x),mv(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 Kt().fromArray(r))}return this}},vv=Object.freeze({__proto__:null,ArcCurve:td,CatmullRomCurve3:nd,CubicBezierCurve:uc,CubicBezierCurve3:id,EllipseCurve:rl,LineCurve:dc,LineCurve3:rd,QuadraticBezierCurve:fc,QuadraticBezierCurve3:ad,SplineCurve:hc}),sd=class extends ta{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 vv[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 vv[r.type]().fromJSON(r))}return this}},ao=class extends sd{constructor(e){super(),this.type="Path",this.currentPoint=new Kt,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 dc(this.currentPoint.clone(),new Kt(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new fc(this.currentPoint.clone(),new Kt(e,t),new Kt(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let o=new uc(this.currentPoint.clone(),new Kt(e,t),new Kt(i,r),new Kt(a,s));return this.curves.push(o),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new hc(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 ao{constructor(e){super(e),this.uuid=uo(),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 ao().fromJSON(r))}return this}};function Qy(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,a=f0(n,0,r,t,!0),s=[];if(!a||a.next===a.prev)return s;let o,u,l;if(i&&(a=ix(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 p=n[h],y=n[h+1];p<o&&(o=p),y<u&&(u=y),p>d&&(d=p),y>f&&(f=y)}l=Math.max(d-o,f-u),l=l!==0?32767/l:0}return pc(a,s,t,o,u,l,0),s}function f0(n,e,t,i,r){let a;if(r===px(n,e,t,i)>0)for(let s=e;s<t;s+=i)a=gv(s/i|0,n[s],n[s+1],a);else for(let s=t-i;s>=e;s-=i)a=gv(s/i|0,n[s],n[s+1],a);return a&&sl(a,a.next)&&(vc(a),a=a.next),a}function so(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(vc(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function pc(n,e,t,i,r,a,s){if(!n)return;!s&&a&&lx(n,i,r,a);let o=n;for(;n.prev!==n.next;){let u=n.prev,l=n.next;if(a?ex(n,i,r,a):jy(n)){e.push(u.i,n.i,l.i),vc(n),n=l.next,o=l.next;continue}if(n=l,n===o){s?s===1?(n=tx(so(n),e),pc(n,e,t,i,r,a,2)):s===2&&nx(n,e,t,i,r,a):pc(so(n),e,t,i,r,a,1);break}}}function jy(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),p=Math.max(o,u,l),y=i.next;for(;y!==e;){if(y.x>=d&&y.x<=h&&y.y>=f&&y.y<=p&&Jl(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 ex(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,p=Math.min(o,u,l),y=Math.min(d,f,h),M=Math.max(o,u,l),v=Math.max(d,f,h),m=Bh(p,y,e,t,i),N=Bh(M,v,e,t,i),P=n.prevZ,_=n.nextZ;for(;P&&P.z>=m&&_&&_.z<=N;){if(P.x>=p&&P.x<=M&&P.y>=y&&P.y<=v&&P!==r&&P!==s&&Jl(o,d,u,f,l,h,P.x,P.y)&&zi(P.prev,P,P.next)>=0||(P=P.prevZ,_.x>=p&&_.x<=M&&_.y>=y&&_.y<=v&&_!==r&&_!==s&&Jl(o,d,u,f,l,h,_.x,_.y)&&zi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;P&&P.z>=m;){if(P.x>=p&&P.x<=M&&P.y>=y&&P.y<=v&&P!==r&&P!==s&&Jl(o,d,u,f,l,h,P.x,P.y)&&zi(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;_&&_.z<=N;){if(_.x>=p&&_.x<=M&&_.y>=y&&_.y<=v&&_!==r&&_!==s&&Jl(o,d,u,f,l,h,_.x,_.y)&&zi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function tx(n,e){let t=n;do{let i=t.prev,r=t.next.next;!sl(i,r)&&p0(i,t,t.next,r)&&mc(i,r)&&mc(r,i)&&(e.push(i.i,t.i,r.i),vc(t),vc(t.next),t=n=r),t=t.next}while(t!==n);return so(t)}function nx(n,e,t,i,r,a){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&dx(s,o)){let u=m0(s,o);s=so(s,s.next),u=so(u,u.next),pc(s,e,t,i,r,a,0),pc(u,e,t,i,r,a,0);return}o=o.next}s=s.next}while(s!==n)}function ix(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=f0(n,o,u,i,!1);l===l.next&&(l.steiner=!0),r.push(ux(l))}r.sort(rx);for(let a=0;a<r.length;a++)t=ax(r[a],t);return t}function rx(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 ax(n,e){let t=sx(n,e);if(!t)return e;let i=m0(t,n);return so(i,i.next),so(t,t.next)}function sx(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&&h0(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);mc(t,n)&&(f<d||f===d&&(t.x>s.x||t.x===s.x&&ox(s,t)))&&(s=t,d=f)}t=t.next}while(t!==o);return s}function ox(n,e){return zi(n.prev,n,e.prev)<0&&zi(e.next,n,n.next)<0}function lx(n,e,t,i){let r=n;do r.z===0&&(r.z=Bh(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,cx(r)}function cx(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 Bh(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 ux(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 h0(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 Jl(n,e,t,i,r,a,s,o){return!(n===s&&e===o)&&h0(n,e,t,i,r,a,s,o)}function dx(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!fx(n,e)&&(mc(n,e)&&mc(e,n)&&hx(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 p0(n,e,t,i){let r=Ou(zi(n,e,t)),a=Ou(zi(n,e,i)),s=Ou(zi(t,i,n)),o=Ou(zi(t,i,e));return!!(r!==a&&s!==o||r===0&&Fu(n,t,e)||a===0&&Fu(n,i,e)||s===0&&Fu(t,n,i)||o===0&&Fu(t,e,i))}function Fu(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 Ou(n){return n>0?1:n<0?-1:0}function fx(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&&p0(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function mc(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 hx(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 m0(n,e){let t=kh(n.i,n.x,n.y),i=kh(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 gv(n,e,t,i){let r=kh(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 vc(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 kh(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function px(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 zh=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=[];yv(e),xv(i,e);let s=e.length;t.forEach(yv);for(let u=0;u<t.length;u++)r.push(s),s+=t[u].length,xv(i,t[u]);let o=zh.triangulate(i,r);for(let u=0;u<o.length;u+=3)a.push(o.slice(u,u+3));return a}};function yv(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function xv(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var gc=class n extends dr{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,p=[],y=[],M=[],v=[];for(let m=0;m<d;m++){let N=m*h-s;for(let P=0;P<l;P++){let _=P*f-a;y.push(_,-N,0),M.push(0,0,1),v.push(P/o),v.push(1-m/u)}}for(let m=0;m<u;m++)for(let N=0;N<o;N++){let P=N+l*m,_=N+l*(m+1),g=N+1+l*(m+1),b=N+1+l*m;p.push(P,_,b),p.push(_,g,b)}this.setIndex(p),this.setAttribute("position",new mi(y,3)),this.setAttribute("normal",new mi(M,3)),this.setAttribute("uv",new mi(v,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 dr{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,p=new _e,y=new Kt;for(let M=0;M<=r;M++){for(let v=0;v<=i;v++){let m=a+v/i*s;p.x=f*Math.cos(m),p.y=f*Math.sin(m),u.push(p.x,p.y,p.z),l.push(0,0,1),y.x=(p.x/t+1)/2,y.y=(p.y/t+1)/2,d.push(y.x,y.y)}f+=h}for(let M=0;M<r;M++){let v=M*(i+1);for(let m=0;m<i;m++){let N=m+v,P=N,_=N+i+1,g=N+i+2,b=N+1;o.push(P,_,b),o.push(_,g,b)}}this.setIndex(o),this.setAttribute("position",new mi(u,3)),this.setAttribute("normal",new mi(l,3)),this.setAttribute("uv",new mi(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)}},yc=class n extends dr{constructor(e=new al([new Kt(0,.5),new Kt(-.5,-.5),new Kt(.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 mi(r,3)),this.setAttribute("normal",new mi(a,3)),this.setAttribute("uv",new mi(s,2));function l(d){let f=r.length/3,h=d.extractPoints(t),p=h.shape,y=h.holes;Xo.isClockWise(p)===!1&&(p=p.reverse());for(let v=0,m=y.length;v<m;v++){let N=y[v];Xo.isClockWise(N)===!0&&(y[v]=N.reverse())}let M=Xo.triangulateShape(p,y);for(let v=0,m=y.length;v<m;v++){let N=y[v];p=p.concat(N)}for(let v=0,m=p.length;v<m;v++){let N=p[v];r.push(N.x,N.y,0),a.push(0,0,1),s.push(N.x,N.y)}for(let v=0,m=M.length;v<m;v++){let N=M[v],P=N[0]+f,_=N[1]+f,g=N[2]+f;i.push(P,_,g),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 mx(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 mx(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 ms=class n extends dr{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 _e,h=new _e,p=[],y=[],M=[],v=[];for(let m=0;m<=i;m++){let N=[],P=m/i,_=s+P*o,g=e*Math.cos(_),b=Math.sqrt(e*e-g*g),z=0;m===0&&s===0?z=.5/t:m===i&&u===Math.PI&&(z=-.5/t);for(let T=0;T<=t;T++){let D=T/t,G=r+D*a;f.x=-b*Math.cos(G),f.y=g,f.z=b*Math.sin(G),y.push(f.x,f.y,f.z),h.copy(f).normalize(),M.push(h.x,h.y,h.z),v.push(D+z,1-P),N.push(l++)}d.push(N)}for(let m=0;m<i;m++)for(let N=0;N<t;N++){let P=d[m][N+1],_=d[m][N],g=d[m+1][N],b=d[m+1][N+1];(m!==0||s>0)&&p.push(P,_,b),(m!==i-1||u<Math.PI)&&p.push(_,g,b)}this.setIndex(p),this.setAttribute("position",new mi(y,3)),this.setAttribute("normal",new mi(M,3)),this.setAttribute("uv",new mi(v,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 fo(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];if(_v(r))r.isRenderTargetTexture?(xn("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(_v(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 Cr(n){let e={};for(let t=0;t<n.length;t++){let i=fo(n[t]);for(let r in i)e[r]=i[r]}return e}function _v(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function vx(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function fp(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ni.workingColorSpace}var v0={clone:fo,merge:Cr},gx=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
-
}`,
|
|
3
|
+
}`,yx=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`,kr=class extends cs{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Sy,this.fragmentShader=by,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=Bs(e.uniforms),this.uniformsGroups=My(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 vn().setHex(r.value);break;case"v2":this.uniforms[i].value=new kt().fromArray(r.value);break;case"v3":this.uniforms[i].value=new ge().fromArray(r.value);break;case"v4":this.uniforms[i].value=new fi().fromArray(r.value);break;case"m3":this.uniforms[i].value=new un().fromArray(r.value);break;case"m4":this.uniforms[i].value=new $n().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}},vu=class extends kr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var Xi=class extends cs{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new vn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Md,this.normalScale=new kt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xa,this.combine=Nu,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}},gu=class extends cs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=o0,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}},yu=class extends cs{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 oo(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function zf(n){return n!==void 0&&n.inTangents!==void 0&&n.outTangents!==void 0}var fs=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_(){}},xu=class extends fs{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:Hf,endingEnd:Hf}}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 Wf:a=e,o=2*t-i;break;case Xf: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 Wf:s=e,u=2*i-t;break;case Xf: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,v=this._weightNext,y=(i-t)/(r-t),T=y*y,g=T*y,m=-h*g+2*h*T-h*y,L=(1+h)*g+(-1.5-2*h)*T+(-.5+h)*y+1,F=(-1-v)*g+(1.5+v)*T+.5*y,_=v*g-v*T;for(let p=0;p!==o;++p)a[p]=m*s[d+p]+L*s[l+p]+F*s[u+p]+_*s[f+p];return a}},_u=class extends fs{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}},Mu=class extends fs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Su=class extends fs{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),T=1-y;for(let g=0;g!==o;++g)a[g]=s[l+g]*T+s[u+g]*y;return a}let h=o*2,v=e-1;for(let y=0;y!==o;++y){let T=s[l+y],g=s[u+y],m=v*h+y*2,L=f[m],F=f[m+1],_=e*h+y*2,p=d[_],S=d[_+1],B=Ty(i,t,L,p,r);a[y]=A0(B,T,F,S,g)}return a}};function A0(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 wy(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 Ty(n,e,t,i,r){let a=(n-e)/(r-e);for(let s=0;s<8;s++){let o=A0(a,e,t,i,r)-n;if(Math.abs(o)<1e-10)break;let u=wy(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 zr=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=oo(t,this.TimeBufferType),this.values=oo(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:oo(e.times,Array),values:oo(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r),zf(e.settings)&&(i.settings={inTangents:oo(e.settings.inTangents,Array),outTangents:oo(e.settings.outTangents,Array)})}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Mu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new _u(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new xu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Su(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 dl:t=this.InterpolantFactoryMethodDiscrete;break;case ru:t=this.InterpolantFactoryMethodLinear;break;case qc:t=this.InterpolantFactoryMethodSmooth;break;case Gf: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 rn("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return dl;case this.InterpolantFactoryMethodLinear:return ru;case this.InterpolantFactoryMethodSmooth:return qc;case this.InterpolantFactoryMethodBezier:return Gf}}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;zf(this.settings)&&(Pm(this.settings.inTangents,e),Pm(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&&(sn("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(sn("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)){sn("KeyframeTrack: Time is not a valid number.",this,o,u),e=!1;break}if(s!==null&&s>u){sn("KeyframeTrack: Out of order keys.",this,o,u,s),e=!1;break}s=u}if(r!==void 0&&Cg(r))for(let o=0,u=r.length;o!==u;++o){let l=r[o];if(isNaN(l)){sn("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()===qc,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,v=f+i;for(let y=0;y!==i;++y){let T=t[f+y];if(T!==t[h+y]||T!==t[v+y]){u=!0;break}}}if(u){if(o!==s){e[s]=e[o];let f=o*i,h=s*i;for(let v=0;v!==i;++v)t[h+v]=t[f+v]}++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,zf(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function Pm(n,e){for(let t=0,i=n.length;t!==i;t+=2)n[t]*=e}zr.prototype.ValueTypeName="";zr.prototype.TimeBufferType=Float32Array;zr.prototype.ValueBufferType=Float32Array;zr.prototype.DefaultInterpolation=ru;var hs=class extends zr{constructor(e,t,i){super(e,t,i)}};hs.prototype.ValueTypeName="bool";hs.prototype.ValueBufferType=Array;hs.prototype.DefaultInterpolation=dl;hs.prototype.InterpolantFactoryMethodLinear=void 0;hs.prototype.InterpolantFactoryMethodSmooth=void 0;var bu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}};bu.prototype.ValueTypeName="color";var wu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}};wu.prototype.ValueTypeName="number";var Tu=class extends fs{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)ba.slerpFlat(a,0,s,l-o,s,l,u);return a}},Dl=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new Tu(this.times,this.values,this.getValueSize(),e)}};Dl.prototype.ValueTypeName="quaternion";Dl.prototype.InterpolantFactoryMethodSmooth=void 0;var ps=class extends zr{constructor(e,t,i){super(e,t,i)}};ps.prototype.ValueTypeName="string";ps.prototype.ValueBufferType=Array;ps.prototype.DefaultInterpolation=dl;ps.prototype.InterpolantFactoryMethodLinear=void 0;ps.prototype.InterpolantFactoryMethodSmooth=void 0;var Eu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}};Eu.prototype.ValueTypeName="vector";var Au=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 v=l[f],y=l[f+1];if(v.global&&(v.lastIndex=0),v.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}},I0=new Au,Iu=class{constructor(e){this.manager=e!==void 0?e:I0,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}};Iu.DEFAULT_MATERIAL_NAME="__DEFAULT";var Nl=class extends nr{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new vn(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}},Ul=class extends Nl{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(nr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new vn(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}},Vf=new $n,Lm=new ge,Dm=new ge,Cu=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 kt(512,512),this.mapType=Cr,this.map=null,this.mapPass=null,this.matrix=new $n,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new xo,this._frameExtents=new kt(1,1),this._viewportCount=1,this._viewports=[new fi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Lm.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lm),Dm.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Dm),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,i,r){Vf.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i.setFromProjectionMatrix(Vf,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===po||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(Vf)}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}},Xc=new ge,Yc=new ba,xa=new ge,Fl=class extends nr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $n,this.projectionMatrix=new $n,this.projectionMatrixInverse=new $n,this.coordinateSystem=ra,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(Xc,Yc,xa),xa.x===1&&xa.y===1&&xa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Xc,Yc,xa.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Xc,Yc,xa),xa.x===1&&xa.y===1&&xa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Xc,Yc,xa.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},ss=new ge,Nm=new kt,Um=new kt,er=class extends Fl{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=au*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(vf*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return au*2*Math.atan(Math.tan(vf*.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,Nm,Um),t.subVectors(Um,Nm)}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(vf*.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 To=class extends Fl{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}},Jf=class extends Cu{constructor(){super(new To(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Ol=class extends Nl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(nr.DEFAULT_UP),this.updateMatrix(),this.target=new nr,this.shadow=new Jf}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 lo=-90,co=1,Ru=class extends nr{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new er(lo,co,e,t);r.layers=this.layers,this.add(r);let a=new er(lo,co,e,t);a.layers=this.layers,this.add(a);let s=new er(lo,co,e,t);s.layers=this.layers,this.add(s);let o=new er(lo,co,e,t);o.layers=this.layers,this.add(o);let u=new er(lo,co,e,t);u.layers=this.layers,this.add(u);let l=new er(lo,co,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===ra)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===po)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(),v=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;let T=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=T,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(f,h,v),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}},Pu=class extends er{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var bh="\\[\\]\\.:\\/",Ey=new RegExp("["+bh+"]","g"),wh="[^"+bh+"]",Ay="[^"+bh.replace("\\.","")+"]",Iy=/((?:WC+[\/:])*)/.source.replace("WC",wh),Cy=/(WCOD+)?/.source.replace("WCOD",Ay),Ry=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wh),Py=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wh),Ly=new RegExp("^"+Iy+Cy+Ry+Py+"$"),Dy=["material","materials","bones","map"],$f=class{constructor(e,t,i){let r=i||li.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()}},li=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(Ey,"")}static parseTrackName(e){let t=Ly.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);Dy.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){rn("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){sn("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){sn("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){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){sn("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){sn("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){sn("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;sn("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){sn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){sn("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}};li.Composite=$f;li.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};li.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};li.prototype.GetterByBindingType=[li.prototype._getValue_direct,li.prototype._getValue_array,li.prototype._getValue_arrayElement,li.prototype._getValue_toArray];li.prototype.SetterByBindingTypeAndVersioning=[[li.prototype._setValue_direct,li.prototype._setValue_direct_setNeedsUpdate,li.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[li.prototype._setValue_array,li.prototype._setValue_array_setNeedsUpdate,li.prototype._setValue_array_setMatrixWorldNeedsUpdate],[li.prototype._setValue_arrayElement,li.prototype._setValue_arrayElement_setNeedsUpdate,li.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[li.prototype._setValue_fromArray,li.prototype._setValue_fromArray_setNeedsUpdate,li.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var uw=new Float32Array(1);var Fm=new $n,Bl=class{constructor(e,t,i=0,r=1/0){this.ray=new xl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new go,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):sn("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Fm.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Fm),this}intersectObject(e,t=!0,i=[]){return Kf(e,this,i,t),i.sort(Om),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)Kf(e[r],this,i,t);return i.sort(Om),i}};function Om(n,e){return n.distance-e.distance}function Kf(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++)Kf(a[s],e,t,!0)}}var Rh=class Rh{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}};Rh.prototype.isMatrix2=!0;var Qf=Rh;function Th(n,e,t,i){let r=Ny(i);switch(t){case gh:return n*e;case Vu:return n*e/r.components*r.byteLength;case Gu:return n*e/r.components*r.byteLength;case xs:return n*e*2/r.components*r.byteLength;case Hu:return n*e*2/r.components*r.byteLength;case yh:return n*e*3/r.components*r.byteLength;case qr:return n*e*4/r.components*r.byteLength;case Wu:return n*e*4/r.components*r.byteLength;case Gl:case Hl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Yu:case Zu:return Math.max(n,16)*Math.max(e,8)/4;case Xu:case qu:return Math.max(n,8)*Math.max(e,8)/2;case Ju:case $u:case Qu:case ju:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ku:case Yl:case ed:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case td:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case nd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case id:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case rd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case ad:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case sd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case od:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ld:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case cd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case ud:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case dd:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case fd:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case hd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case pd:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case md:case vd:case gd:return Math.ceil(n/4)*Math.ceil(e/4)*16;case yd:case xd:return Math.ceil(n/4)*Math.ceil(e/4)*8;case ql:case _d:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Ny(n){switch(n){case Cr:case hh:return{byteLength:1,components:1};case Io:case ph:case oa:return{byteLength:2,components:1};case ku:case zu:return{byteLength:2,components:4};case sa:case Bu:case Yr:return{byteLength:4,components:1};case mh:case vh: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__?rn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");function $0(){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 Fy(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 v;if(l instanceof Float32Array)v=n.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)v=n.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?v=n.HALF_FLOAT:v=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)v=n.SHORT;else if(l instanceof Uint32Array)v=n.UNSIGNED_INT;else if(l instanceof Int32Array)v=n.INT;else if(l instanceof Int8Array)v=n.BYTE;else if(l instanceof Uint8Array)v=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)v=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:v,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((v,y)=>v.start-y.start);let h=0;for(let v=1;v<f.length;v++){let y=f[h],T=f[v];T.start<=y.start+y.count+1?y.count=Math.max(y.count,T.start+T.count-y.start):(++h,f[h]=T)}f.length=h+1;for(let v=0,y=f.length;v<y;v++){let T=f[v];n.bufferSubData(l,T.start*d.BYTES_PER_ELEMENT,d,T.start,T.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 Oy=`#ifdef USE_ALPHAHASH
|
|
5
|
+
}`,na=class extends ps{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=gx,this.fragmentShader=yx,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=fo(e.uniforms),this.uniformsGroups=vx(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 Cn().setHex(r.value);break;case"v2":this.uniforms[i].value=new Kt().fromArray(r.value);break;case"v3":this.uniforms[i].value=new _e().fromArray(r.value);break;case"v4":this.uniforms[i].value=new Ti().fromArray(r.value);break;case"m3":this.uniforms[i].value=new Ln().fromArray(r.value);break;case"m4":this.uniforms[i].value=new Dn().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}},od=class extends na{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},ll=class extends ps{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Cn(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 Cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Uc,this.normalScale=new Kt(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 ga,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 fr=class extends ps{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Uc,this.normalScale=new Kt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ga,this.combine=Td,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}},ld=class extends ps{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Kv,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}},cd=class extends ps{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 Ph(n){return n!==void 0&&n.inTangents!==void 0&&n.outTangents!==void 0}var Rs=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_(){}},ud=class extends Rs{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:Uh,endingEnd:Uh}}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 Fh:a=e,o=2*t-i;break;case Oh: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 Fh:s=e,u=2*i-t;break;case Oh: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,p=this._weightNext,y=(i-t)/(r-t),M=y*y,v=M*y,m=-h*v+2*h*M-h*y,N=(1+h)*v+(-1.5-2*h)*M+(-.5+h)*y+1,P=(-1-p)*v+(1.5+p)*M+.5*y,_=p*v-p*M;for(let g=0;g!==o;++g)a[g]=m*s[d+g]+N*s[l+g]+P*s[u+g]+_*s[f+g];return a}},dd=class extends Rs{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}},fd=class extends Rs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},hd=class extends Rs{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 v=0;v!==o;++v)a[v]=s[l+v]*M+s[u+v]*y;return a}let h=o*2,p=e-1;for(let y=0;y!==o;++y){let M=s[l+y],v=s[u+y],m=p*h+y*2,N=f[m],P=f[m+1],_=e*h+y*2,g=d[_],b=d[_+1],z=_x(i,t,N,g,r);a[y]=g0(z,M,P,b,v)}return a}};function g0(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 xx(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 _x(n,e,t,i,r){let a=(n-e)/(r-e);for(let s=0;s<8;s++){let o=g0(a,e,t,i,r)-n;if(Math.abs(o)<1e-10)break;let u=xx(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 ia=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),Ph(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 fd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new dd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ud(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new hd(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 Ql:t=this.InterpolantFactoryMethodDiscrete;break;case Ju:t=this.InterpolantFactoryMethodLinear;break;case zu:t=this.InterpolantFactoryMethodSmooth;break;case Nh: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 xn("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ql;case this.InterpolantFactoryMethodLinear:return Ju;case this.InterpolantFactoryMethodSmooth:return zu;case this.InterpolantFactoryMethodBezier:return Nh}}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;Ph(this.settings)&&(Mv(this.settings.inTangents,e),Mv(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&&Sy(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()===zu,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,p=f+i;for(let y=0;y!==i;++y){let M=t[f+y];if(M!==t[h+y]||M!==t[p+y]){u=!0;break}}}if(u){if(o!==s){e[s]=e[o];let f=o*i,h=s*i;for(let p=0;p!==i;++p)t[h+p]=t[f+p]}++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,Ph(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function Mv(n,e){for(let t=0,i=n.length;t!==i;t+=2)n[t]*=e}ia.prototype.ValueTypeName="";ia.prototype.TimeBufferType=Float32Array;ia.prototype.ValueBufferType=Float32Array;ia.prototype.DefaultInterpolation=Ju;var Ps=class extends ia{constructor(e,t,i){super(e,t,i)}};Ps.prototype.ValueTypeName="bool";Ps.prototype.ValueBufferType=Array;Ps.prototype.DefaultInterpolation=Ql;Ps.prototype.InterpolantFactoryMethodLinear=void 0;Ps.prototype.InterpolantFactoryMethodSmooth=void 0;var pd=class extends ia{constructor(e,t,i,r){super(e,t,i,r)}};pd.prototype.ValueTypeName="color";var md=class extends ia{constructor(e,t,i,r){super(e,t,i,r)}};md.prototype.ValueTypeName="number";var vd=class extends Rs{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)Vr.slerpFlat(a,0,s,l-o,s,l,u);return a}},xc=class extends ia{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new vd(this.times,this.values,this.getValueSize(),e)}};xc.prototype.ValueTypeName="quaternion";xc.prototype.InterpolantFactoryMethodSmooth=void 0;var Ls=class extends ia{constructor(e,t,i){super(e,t,i)}};Ls.prototype.ValueTypeName="string";Ls.prototype.ValueBufferType=Array;Ls.prototype.DefaultInterpolation=Ql;Ls.prototype.InterpolantFactoryMethodLinear=void 0;Ls.prototype.InterpolantFactoryMethodSmooth=void 0;var gd=class extends ia{constructor(e,t,i,r){super(e,t,i,r)}};gd.prototype.ValueTypeName="vector";var yd=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 p=l[f],y=l[f+1];if(p.global&&(p.lastIndex=0),p.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}},y0=new yd,xd=class{constructor(e){this.manager=e!==void 0?e:y0,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}};xd.DEFAULT_MATERIAL_NAME="__DEFAULT";var _c=class extends ur{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Cn(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}},Mc=class extends _c{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ur.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Cn(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}},Lh=new Dn,Sv=new _e,bv=new _e,_d=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 Kt(512,512),this.mapType=Xr,this.map=null,this.mapPass=null,this.matrix=new Dn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nl,this._frameExtents=new Kt(1,1),this._viewportCount=1,this._viewports=[new Ti(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Sv.setFromMatrixPosition(e.matrixWorld),t.position.copy(Sv),bv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(bv),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,i,r){Lh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i.setFromProjectionMatrix(Lh,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(Lh)}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}},Bu=new _e,ku=new Vr,Ga=new _e,Sc=class extends ur{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Dn,this.projectionMatrix=new Dn,this.projectionMatrixInverse=new Dn,this.coordinateSystem=Ca,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(Bu,ku,Ga),Ga.x===1&&Ga.y===1&&Ga.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Bu,ku,Ga.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Bu,ku,Ga),Ga.x===1&&Ga.y===1&&Ga.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Bu,ku,Ga.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Ts=new _e,wv=new Kt,Tv=new Kt,Er=class extends Sc{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=$u*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ah*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $u*2*Math.atan(Math.tan(ah*.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){Ts.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ts.x,Ts.y).multiplyScalar(-e/Ts.z),Ts.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ts.x,Ts.y).multiplyScalar(-e/Ts.z)}getViewSize(e,t){return this.getViewBounds(e,wv,Tv),t.subVectors(Tv,wv)}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(ah*.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 Sc{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}},Vh=class extends _d{constructor(){super(new cl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},bc=class extends _c{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ur.DEFAULT_UP),this.updateMatrix(),this.target=new ur,this.shadow=new Vh}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,Md=class extends ur{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Er(Go,Ho,e,t);r.layers=this.layers,this.add(r);let a=new Er(Go,Ho,e,t);a.layers=this.layers,this.add(a);let s=new Er(Go,Ho,e,t);s.layers=this.layers,this.add(s);let o=new Er(Go,Ho,e,t);o.layers=this.layers,this.add(o);let u=new Er(Go,Ho,e,t);u.layers=this.layers,this.add(u);let l=new Er(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===Ca)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(),p=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;let M=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let v=!1;e.isWebGLRenderer===!0?v=e.state.buffers.depth.getReversed():v=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,1,r),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,2,r),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(i,4,r),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=M,e.setRenderTarget(i,5,r),v&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(f,h,p),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}},Sd=class extends Er{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var hp="\\[\\]\\.:\\/",Mx=new RegExp("["+hp+"]","g"),pp="[^"+hp+"]",Sx="[^"+hp.replace("\\.","")+"]",bx=/((?:WC+[\/:])*)/.source.replace("WC",pp),wx=/(WCOD+)?/.source.replace("WCOD",Sx),Tx=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",pp),Ex=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",pp),Ax=new RegExp("^"+bx+wx+Tx+Ex+"$"),Ix=["material","materials","bones","map"],Gh=class{constructor(e,t,i){let r=i||Di.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()}},Di=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(Mx,"")}static parseTrackName(e){let t=Ax.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);Ix.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){xn("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}};Di.Composite=Gh;Di.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Di.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Di.prototype.GetterByBindingType=[Di.prototype._getValue_direct,Di.prototype._getValue_array,Di.prototype._getValue_arrayElement,Di.prototype._getValue_toArray];Di.prototype.SetterByBindingTypeAndVersioning=[[Di.prototype._setValue_direct,Di.prototype._setValue_direct_setNeedsUpdate,Di.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Di.prototype._setValue_array,Di.prototype._setValue_array_setNeedsUpdate,Di.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Di.prototype._setValue_arrayElement,Di.prototype._setValue_arrayElement_setNeedsUpdate,Di.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Di.prototype._setValue_fromArray,Di.prototype._setValue_fromArray_setNeedsUpdate,Di.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var f1=new Float32Array(1);var Ev=new Dn,wc=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 Ev.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ev),this}intersectObject(e,t=!0,i=[]){return Hh(e,this,i,t),i.sort(Av),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)Hh(e[r],this,i,t);return i.sort(Av),i}};function Av(n,e){return n.distance-e.distance}function Hh(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++)Hh(a[s],e,t,!0)}}var _p=class _p{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}};_p.prototype.isMatrix2=!0;var Wh=_p;function mp(n,e,t,i){let r=Cx(i);switch(t){case op:return n*e;case Pd:return n*e/r.components*r.byteLength;case Ld:return n*e/r.components*r.byteLength;case Us:return n*e*2/r.components*r.byteLength;case Dd:return n*e*2/r.components*r.byteLength;case lp:return n*e*3/r.components*r.byteLength;case aa:return n*e*4/r.components*r.byteLength;case Nd:return n*e*4/r.components*r.byteLength;case Cc:case Rc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Pc:case Lc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fd:case Bd:return Math.max(n,16)*Math.max(e,8)/4;case Ud:case Od:return Math.max(n,8)*Math.max(e,8)/2;case kd:case zd:case Gd:case Hd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Vd:case Dc:case Wd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Xd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Yd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case qd:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Zd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jd:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case $d:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Kd: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 jd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case ef:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case tf:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case nf:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rf:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case af:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case sf:case of:case lf:return Math.ceil(n/4)*Math.ceil(e/4)*16;case cf:case uf:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Nc:case df:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Cx(n){switch(n){case Xr:case ip:return{byteLength:1,components:1};case pl:case rp:case La:return{byteLength:2,components:1};case Cd:case Rd:return{byteLength:2,components:4};case Pa:case Id:case ra:return{byteLength:4,components:1};case ap:case sp: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__?xn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");function z0(){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 Px(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 p;if(l instanceof Float32Array)p=n.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=n.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=n.SHORT;else if(l instanceof Uint32Array)p=n.UNSIGNED_INT;else if(l instanceof Int32Array)p=n.INT;else if(l instanceof Int8Array)p=n.BYTE;else if(l instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:p,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((p,y)=>p.start-y.start);let h=0;for(let p=1;p<f.length;p++){let y=f[h],M=f[p];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 p=0,y=f.length;p<y;p++){let M=f[p];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 Lx=`#ifdef USE_ALPHAHASH
|
|
6
6
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
7
|
-
#endif`,
|
|
7
|
+
#endif`,Dx=`#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 af=Object.defineProperty;var mg=Object.getOwnPropertyDe
|
|
|
39
39
|
: cases.z;
|
|
40
40
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
41
41
|
}
|
|
42
|
-
#endif`,
|
|
42
|
+
#endif`,Nx=`#ifdef USE_ALPHAMAP
|
|
43
43
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
44
|
-
#endif`,
|
|
44
|
+
#endif`,Ux=`#ifdef USE_ALPHAMAP
|
|
45
45
|
uniform sampler2D alphaMap;
|
|
46
|
-
#endif`,
|
|
46
|
+
#endif`,Fx=`#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`,Ox=`#ifdef USE_ALPHATEST
|
|
54
54
|
uniform float alphaTest;
|
|
55
|
-
#endif`,
|
|
55
|
+
#endif`,Bx=`#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 af=Object.defineProperty;var mg=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`,kx=`#ifdef USE_AOMAP
|
|
69
69
|
uniform sampler2D aoMap;
|
|
70
70
|
uniform float aoMapIntensity;
|
|
71
|
-
#endif`,
|
|
71
|
+
#endif`,zx=`#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 af=Object.defineProperty;var mg=Object.getOwnPropertyDe
|
|
|
102
102
|
int y = j / size;
|
|
103
103
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
104
104
|
}
|
|
105
|
-
#endif`,
|
|
105
|
+
#endif`,Vx=`#ifdef USE_BATCHING
|
|
106
106
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
107
|
-
#endif`,
|
|
107
|
+
#endif`,Gx=`vec3 transformed = vec3( position );
|
|
108
108
|
#ifdef USE_ALPHAHASH
|
|
109
109
|
vPosition = vec3( position );
|
|
110
|
-
#endif`,
|
|
110
|
+
#endif`,Hx=`vec3 objectNormal = vec3( normal );
|
|
111
111
|
#ifdef USE_TANGENT
|
|
112
112
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
113
|
-
#endif`,
|
|
113
|
+
#endif`,Wx=`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`,Xx=`#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`,Yx=`#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`,qx=`#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`,Zx=`#if NUM_CLIPPING_PLANES > 0
|
|
258
258
|
varying vec3 vClipPosition;
|
|
259
259
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
260
|
-
#endif`,
|
|
260
|
+
#endif`,Jx=`#if NUM_CLIPPING_PLANES > 0
|
|
261
261
|
varying vec3 vClipPosition;
|
|
262
|
-
#endif
|
|
262
|
+
#endif`,$x=`#if NUM_CLIPPING_PLANES > 0
|
|
263
263
|
vClipPosition = - mvPosition.xyz;
|
|
264
|
-
#endif`,
|
|
264
|
+
#endif`,Kx=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
265
265
|
diffuseColor *= vColor;
|
|
266
|
-
#endif`,
|
|
266
|
+
#endif`,Qx=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
267
267
|
varying vec4 vColor;
|
|
268
|
-
#endif`,
|
|
268
|
+
#endif`,jx=`#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`,e_=`#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`,t_=`#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`,n_=`#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`,i_=`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`,r_=`#ifdef USE_DISPLACEMENTMAP
|
|
474
474
|
uniform sampler2D displacementMap;
|
|
475
475
|
uniform float displacementScale;
|
|
476
476
|
uniform float displacementBias;
|
|
477
|
-
#endif`,
|
|
477
|
+
#endif`,a_=`#ifdef USE_DISPLACEMENTMAP
|
|
478
478
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
479
|
-
#endif`,
|
|
479
|
+
#endif`,s_=`#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`,o_=`#ifdef USE_EMISSIVEMAP
|
|
486
486
|
uniform sampler2D emissiveMap;
|
|
487
|
-
#endif`,
|
|
487
|
+
#endif`,l_="gl_FragColor = linearToOutputTexel( gl_FragColor );",c_=`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
|
+
}`,u_=`#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`,d_=`#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`,f_=`#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`,h_=`#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`,p_=`#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`,m_=`#ifdef USE_FOG
|
|
570
570
|
vFogDepth = - mvPosition.z;
|
|
571
|
-
#endif`,
|
|
571
|
+
#endif`,v_=`#ifdef USE_FOG
|
|
572
572
|
varying float vFogDepth;
|
|
573
|
-
#endif`,
|
|
573
|
+
#endif`,g_=`#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`,y_=`#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`,x_=`#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
|
+
}`,__=`#ifdef USE_LIGHTMAP
|
|
602
602
|
uniform sampler2D lightMap;
|
|
603
603
|
uniform float lightMapIntensity;
|
|
604
|
-
#endif`,
|
|
604
|
+
#endif`,M_=`LambertMaterial material;
|
|
605
605
|
material.diffuseColor = diffuseColor.rgb;
|
|
606
|
-
material.specularStrength = specularStrength;`,
|
|
606
|
+
material.specularStrength = specularStrength;`,S_=`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`,b_=`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>`,w_=`#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`,T_=`ToonMaterial material;
|
|
807
|
+
material.diffuseColor = diffuseColor.rgb;`,E_=`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`,A_=`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;`,I_=`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`,C_=`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`,R_=`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
|
+
}`,P_=`
|
|
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`,L_=`#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`,D_=`#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`,N_=`#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`,U_=`#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`,F_=`#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`,O_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1538
1538
|
varying float vFragDepth;
|
|
1539
1539
|
varying float vIsPerspective;
|
|
1540
|
-
#endif`,
|
|
1540
|
+
#endif`,B_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1541
1541
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1542
1542
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1543
|
-
#endif`,
|
|
1543
|
+
#endif`,k_=`#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`,z_=`#ifdef USE_MAP
|
|
1550
1550
|
uniform sampler2D map;
|
|
1551
|
-
#endif`,
|
|
1551
|
+
#endif`,V_=`#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`,G_=`#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`,H_=`float metalnessFactor = metalness;
|
|
1576
1576
|
#ifdef USE_METALNESSMAP
|
|
1577
1577
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1578
1578
|
metalnessFactor *= texelMetalness.b;
|
|
1579
|
-
#endif`,
|
|
1579
|
+
#endif`,W_=`#ifdef USE_METALNESSMAP
|
|
1580
1580
|
uniform sampler2D metalnessMap;
|
|
1581
|
-
#endif
|
|
1581
|
+
#endif`,X_=`#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`,Y_=`#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`,q_=`#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`,Z_=`#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`,J_=`#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`,$_=`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;`,K_=`#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;`,n_=`#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`,Q_=`#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`,j_=`#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`,eM=`#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;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1697
1697
|
vBitangent = - vBitangent;
|
|
1698
1698
|
#endif
|
|
1699
1699
|
#endif
|
|
1700
|
-
#endif`,
|
|
1700
|
+
#endif`,tM=`#ifdef USE_NORMALMAP
|
|
1701
1701
|
uniform sampler2D normalMap;
|
|
1702
1702
|
uniform vec2 normalScale;
|
|
1703
1703
|
#endif
|
|
@@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,n_=`#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`,nM=`#ifdef USE_CLEARCOAT
|
|
1723
1723
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1724
|
-
#endif`,
|
|
1724
|
+
#endif`,iM=`#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`,rM=`#ifdef USE_CLEARCOATMAP
|
|
1729
1729
|
uniform sampler2D clearcoatMap;
|
|
1730
1730
|
#endif
|
|
1731
1731
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1734
1734
|
#endif
|
|
1735
1735
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1736
1736
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1737
|
-
#endif`,
|
|
1737
|
+
#endif`,aM=`#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`,sM=`#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 );`,oM=`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
|
+
}`,lM=`#ifdef PREMULTIPLIED_ALPHA
|
|
1828
1828
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1829
|
-
#endif`,
|
|
1829
|
+
#endif`,cM=`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;`,uM=`#ifdef DITHERING
|
|
1838
1838
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1839
|
-
#endif`,
|
|
1839
|
+
#endif`,dM=`#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`,fM=`float roughnessFactor = roughness;
|
|
1847
1847
|
#ifdef USE_ROUGHNESSMAP
|
|
1848
1848
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1849
1849
|
roughnessFactor *= texelRoughness.g;
|
|
1850
|
-
#endif`,
|
|
1850
|
+
#endif`,hM=`#ifdef USE_ROUGHNESSMAP
|
|
1851
1851
|
uniform sampler2D roughnessMap;
|
|
1852
|
-
#endif`,
|
|
1852
|
+
#endif`,pM=`#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;`,m_=`#ifdef DITHERING
|
|
|
2100
2100
|
}
|
|
2101
2101
|
#endif
|
|
2102
2102
|
#endif
|
|
2103
|
-
#endif`,
|
|
2103
|
+
#endif`,mM=`#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;`,m_=`#ifdef DITHERING
|
|
|
2145
2145
|
};
|
|
2146
2146
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2147
2147
|
#endif
|
|
2148
|
-
#endif`,
|
|
2148
|
+
#endif`,vM=`#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;`,m_=`#ifdef DITHERING
|
|
|
2185
2185
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2186
2186
|
}
|
|
2187
2187
|
#pragma unroll_loop_end
|
|
2188
|
-
#endif`,
|
|
2188
|
+
#endif`,gM=`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;`,m_=`#ifdef DITHERING
|
|
|
2226
2226
|
#endif
|
|
2227
2227
|
#endif
|
|
2228
2228
|
return shadow;
|
|
2229
|
-
}`,
|
|
2229
|
+
}`,yM=`#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`,xM=`#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;`,m_=`#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`,_M=`#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;`,m_=`#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`,MM=`#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;`,m_=`#ifdef DITHERING
|
|
|
2265
2265
|
#ifdef USE_TANGENT
|
|
2266
2266
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2267
2267
|
#endif
|
|
2268
|
-
#endif`,
|
|
2268
|
+
#endif`,SM=`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`,bM=`#ifdef USE_SPECULARMAP
|
|
2275
2275
|
uniform sampler2D specularMap;
|
|
2276
|
-
#endif`,
|
|
2276
|
+
#endif`,wM=`#if defined( TONE_MAPPING )
|
|
2277
2277
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2278
|
-
#endif`,
|
|
2278
|
+
#endif`,TM=`#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; }`,EM=`#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; }`,P_=`#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`,AM=`#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; }`,P_=`#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`,IM=`#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; }`,P_=`#ifdef USE_TRANSMISS
|
|
|
2589
2589
|
#ifdef USE_THICKNESSMAP
|
|
2590
2590
|
uniform mat3 thicknessMapTransform;
|
|
2591
2591
|
varying vec2 vThicknessMapUv;
|
|
2592
|
-
#endif`,
|
|
2592
|
+
#endif`,CM=`#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; }`,P_=`#ifdef USE_TRANSMISS
|
|
|
2683
2683
|
#ifdef USE_THICKNESSMAP
|
|
2684
2684
|
uniform mat3 thicknessMapTransform;
|
|
2685
2685
|
varying vec2 vThicknessMapUv;
|
|
2686
|
-
#endif`,
|
|
2686
|
+
#endif`,RM=`#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; }`,P_=`#ifdef USE_TRANSMISS
|
|
|
2754
2754
|
#endif
|
|
2755
2755
|
#ifdef USE_THICKNESSMAP
|
|
2756
2756
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2757
|
-
#endif`,
|
|
2757
|
+
#endif`,PM=`#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; }`,P_=`#ifdef USE_TRANSMISS
|
|
|
2763
2763
|
worldPosition = instanceMatrix * worldPosition;
|
|
2764
2764
|
#endif
|
|
2765
2765
|
worldPosition = modelMatrix * worldPosition;
|
|
2766
|
-
#endif`,
|
|
2766
|
+
#endif`,LM=`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
|
+
}`,DM=`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
|
+
}`,NM=`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
|
+
}`,UM=`#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
|
+
}`,FM=`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
|
+
}`,OM=`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
|
+
}`,BM=`#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
|
+
}`,kM=`#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
|
+
}`,zM=`#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
|
+
}`,VM=`#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
|
+
}`,GM=`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
|
+
}`,HM=`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
|
+
}`,WM=`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
|
+
}`,XM=`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
|
+
}`,YM=`#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
|
+
}`,qM=`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
|
+
}`,ZM=`#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
|
+
}`,JM=`#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
|
+
}`,$M=`#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
|
+
}`,KM=`#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
|
+
}`,QM=`#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
|
+
}`,jM=`#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
|
+
}`,eS=`#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
|
+
}`,tS=`#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
|
+
}`,nS=`#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
|
+
}`,iS=`#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
|
+
}`,rS=`#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
|
+
}`,aS=`#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
|
+
}`,sS=`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
|
+
}`,oS=`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
|
+
}`,lS=`#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
|
+
}`,cS=`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
|
+
}`,uS=`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
|
+
}`,dS=`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:Oy,alphahash_pars_fragment:By,alphamap_fragment:ky,alphamap_pars_fragment:zy,alphatest_fragment:Vy,alphatest_pars_fragment:Gy,aomap_fragment:Hy,aomap_pars_fragment:Wy,batching_pars_vertex:Xy,batching_vertex:Yy,begin_vertex:qy,beginnormal_vertex:Zy,bsdfs:Jy,iridescence_fragment:$y,bumpmap_pars_fragment:Ky,clipping_planes_fragment:Qy,clipping_planes_pars_fragment:jy,clipping_planes_pars_vertex:ex,clipping_planes_vertex:tx,color_fragment:nx,color_pars_fragment:ix,color_pars_vertex:rx,color_vertex:ax,common:sx,cube_uv_reflection_fragment:ox,defaultnormal_vertex:lx,displacementmap_pars_vertex:cx,displacementmap_vertex:ux,emissivemap_fragment:dx,emissivemap_pars_fragment:fx,colorspace_fragment:hx,colorspace_pars_fragment:px,envmap_fragment:mx,envmap_common_pars_fragment:vx,envmap_pars_fragment:gx,envmap_pars_vertex:yx,envmap_physical_pars_fragment:Cx,envmap_vertex:xx,fog_vertex:_x,fog_pars_vertex:Mx,fog_fragment:Sx,fog_pars_fragment:bx,gradientmap_pars_fragment:wx,lightmap_pars_fragment:Tx,lights_lambert_fragment:Ex,lights_lambert_pars_fragment:Ax,lights_pars_begin:Ix,lights_toon_fragment:Rx,lights_toon_pars_fragment:Px,lights_phong_fragment:Lx,lights_phong_pars_fragment:Dx,lights_physical_fragment:Nx,lights_physical_pars_fragment:Ux,lights_fragment_begin:Fx,lights_fragment_maps:Ox,lights_fragment_end:Bx,lightprobes_pars_fragment:kx,logdepthbuf_fragment:zx,logdepthbuf_pars_fragment:Vx,logdepthbuf_pars_vertex:Gx,logdepthbuf_vertex:Hx,map_fragment:Wx,map_pars_fragment:Xx,map_particle_fragment:Yx,map_particle_pars_fragment:qx,metalnessmap_fragment:Zx,metalnessmap_pars_fragment:Jx,morphinstance_vertex:$x,morphcolor_vertex:Kx,morphnormal_vertex:Qx,morphtarget_pars_vertex:jx,morphtarget_vertex:e_,normal_fragment_begin:t_,normal_fragment_maps:n_,normal_pars_fragment:i_,normal_pars_vertex:r_,normal_vertex:a_,normalmap_pars_fragment:s_,clearcoat_normal_fragment_begin:o_,clearcoat_normal_fragment_maps:l_,clearcoat_pars_fragment:c_,iridescence_pars_fragment:u_,opaque_fragment:d_,packing:f_,premultiplied_alpha_fragment:h_,project_vertex:p_,dithering_fragment:m_,dithering_pars_fragment:v_,roughnessmap_fragment:g_,roughnessmap_pars_fragment:y_,shadowmap_pars_fragment:x_,shadowmap_pars_vertex:__,shadowmap_vertex:M_,shadowmask_pars_fragment:S_,skinbase_vertex:b_,skinning_pars_vertex:w_,skinning_vertex:T_,skinnormal_vertex:E_,specularmap_fragment:A_,specularmap_pars_fragment:I_,tonemapping_fragment:C_,tonemapping_pars_fragment:R_,transmission_fragment:P_,transmission_pars_fragment:L_,uv_pars_fragment:D_,uv_pars_vertex:N_,uv_vertex:U_,worldpos_vertex:F_,background_vert:O_,background_frag:B_,backgroundCube_vert:k_,backgroundCube_frag:z_,cube_vert:V_,cube_frag:G_,depth_vert:H_,depth_frag:W_,distance_vert:X_,distance_frag:Y_,equirect_vert:q_,equirect_frag:Z_,linedashed_vert:J_,linedashed_frag:$_,meshbasic_vert:K_,meshbasic_frag:Q_,meshlambert_vert:j_,meshlambert_frag:eM,meshmatcap_vert:tM,meshmatcap_frag:nM,meshnormal_vert:iM,meshnormal_frag:rM,meshphong_vert:aM,meshphong_frag:sM,meshphysical_vert:oM,meshphysical_frag:lM,meshtoon_vert:cM,meshtoon_frag:uM,points_vert:dM,points_frag:fM,shadow_vert:hM,shadow_frag:pM,sprite_vert:mM,sprite_frag:vM},At={common:{diffuse:{value:new vn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new un}},envmap:{envMap:{value:null},envMapRotation:{value:new un},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new un},normalScale:{value:new kt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vn(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 vn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0},uvTransform:{value:new un}},sprite:{diffuse:{value:new vn(16777215)},opacity:{value:1},center:{value:new kt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}}},Ca={basic:{uniforms:ir([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.fog]),vertexShader:gn.meshbasic_vert,fragmentShader:gn.meshbasic_frag},lambert:{uniforms:ir([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.fog,At.lights,{emissive:{value:new vn(0)},envMapIntensity:{value:1}}]),vertexShader:gn.meshlambert_vert,fragmentShader:gn.meshlambert_frag},phong:{uniforms:ir([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.fog,At.lights,{emissive:{value:new vn(0)},specular:{value:new vn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:gn.meshphong_vert,fragmentShader:gn.meshphong_frag},standard:{uniforms:ir([At.common,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.roughnessmap,At.metalnessmap,At.fog,At.lights,{emissive:{value:new vn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag},toon:{uniforms:ir([At.common,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.gradientmap,At.fog,At.lights,{emissive:{value:new vn(0)}}]),vertexShader:gn.meshtoon_vert,fragmentShader:gn.meshtoon_frag},matcap:{uniforms:ir([At.common,At.bumpmap,At.normalmap,At.displacementmap,At.fog,{matcap:{value:null}}]),vertexShader:gn.meshmatcap_vert,fragmentShader:gn.meshmatcap_frag},points:{uniforms:ir([At.points,At.fog]),vertexShader:gn.points_vert,fragmentShader:gn.points_frag},dashed:{uniforms:ir([At.common,At.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gn.linedashed_vert,fragmentShader:gn.linedashed_frag},depth:{uniforms:ir([At.common,At.displacementmap]),vertexShader:gn.depth_vert,fragmentShader:gn.depth_frag},normal:{uniforms:ir([At.common,At.bumpmap,At.normalmap,At.displacementmap,{opacity:{value:1}}]),vertexShader:gn.meshnormal_vert,fragmentShader:gn.meshnormal_frag},sprite:{uniforms:ir([At.sprite,At.fog]),vertexShader:gn.sprite_vert,fragmentShader:gn.sprite_frag},background:{uniforms:{uvTransform:{value:new un},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 un}},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:ir([At.common,At.displacementmap,{referencePosition:{value:new ge},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gn.distance_vert,fragmentShader:gn.distance_frag},shadow:{uniforms:ir([At.lights,At.fog,{color:{value:new vn(0)},opacity:{value:1}}]),vertexShader:gn.shadow_vert,fragmentShader:gn.shadow_frag}};Ca.physical={uniforms:ir([Ca.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new un},clearcoatNormalScale:{value:new kt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new un},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new un},sheen:{value:0},sheenColor:{value:new vn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new un},transmissionSamplerSize:{value:new kt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new un},attenuationDistance:{value:0},attenuationColor:{value:new vn(0)},specularColor:{value:new vn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new un},anisotropyVector:{value:new kt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new un}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag};var wd={r:0,b:0,g:0},gM=new $n,K0=new un;K0.set(-1,0,0,0,1,0,0,0,1);function yM(n,e,t,i,r,a){let s=new vn(0),o=r===!0?0:1,u,l,d=null,f=0,h=null;function v(L){let F=L.isScene===!0?L.background:null;if(F&&F.isTexture){let _=L.backgroundBlurriness>0;F=e.get(F,_)}return F}function y(L){let F=!1,_=v(L);_===null?g(s,o):_&&_.isColor&&(g(_,1),F=!0);let p=n.xr.getEnvironmentBlendMode();p==="additive"?t.buffers.color.setClear(0,0,0,1,a):p==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,a),(n.autoClear||F)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function T(L,F){let _=v(F);_&&(_.isCubeTexture||_.mapping===zl)?(l===void 0&&(l=new jn(new Or(1,1,1),new kr({name:"BackgroundCubeMaterial",uniforms:Bs(Ca.backgroundCube.uniforms),vertexShader:Ca.backgroundCube.vertexShader,fragmentShader:Ca.backgroundCube.fragmentShader,side:pr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(p,S,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=F.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=F.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(gM.makeRotationFromEuler(F.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(K0),l.material.toneMapped=Ln.getTransfer(_.colorSpace)!==Jn,(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 jn(new Pl(2,2),new kr({name:"BackgroundMaterial",uniforms:Bs(Ca.background.uniforms),vertexShader:Ca.background.vertexShader,fragmentShader:Ca.background.fragmentShader,side:ms,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=F.backgroundIntensity,u.material.toneMapped=Ln.getTransfer(_.colorSpace)!==Jn,_.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,F){L.getRGB(wd,Sh(n)),t.buffers.color.setClear(wd.r,wd.g,wd.b,F,a)}function m(){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,F=1){s.set(L),o=F,g(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(L){o=L,g(s,o)},render:y,addToRenderList:T,dispose:m}}function xM(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),a=r,s=!1;function o(U,Y,E,M,O){let H=!1,ee=f(U,M,E,Y);a!==ee&&(a=ee,l(a.object)),H=v(U,M,E,O),H&&y(U,M,E,O),O!==null&&e.update(O,n.ELEMENT_ARRAY_BUFFER),(H||s)&&(s=!1,_(U,Y,E,M),O!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function u(){return n.createVertexArray()}function l(U){return n.bindVertexArray(U)}function d(U){return n.deleteVertexArray(U)}function f(U,Y,E,M){let O=M.wireframe===!0,H=i[Y.id];H===void 0&&(H={},i[Y.id]=H);let ee=U.isInstancedMesh===!0?U.id:0,j=H[ee];j===void 0&&(j={},H[ee]=j);let K=j[E.id];K===void 0&&(K={},j[E.id]=K);let re=K[O];return re===void 0&&(re=h(u()),K[O]=re),re}function h(U){let Y=[],E=[],M=[];for(let O=0;O<t;O++)Y[O]=0,E[O]=0,M[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:Y,enabledAttributes:E,attributeDivisors:M,object:U,attributes:{},index:null}}function v(U,Y,E,M){let O=a.attributes,H=Y.attributes,ee=0,j=E.getAttributes();for(let K in j)if(j[K].location>=0){let J=O[K],ne=H[K];if(ne===void 0&&(K==="instanceMatrix"&&U.instanceMatrix&&(ne=U.instanceMatrix),K==="instanceColor"&&U.instanceColor&&(ne=U.instanceColor)),J===void 0||J.attribute!==ne||ne&&J.data!==ne.data)return!0;ee++}return a.attributesNum!==ee||a.index!==M}function y(U,Y,E,M){let O={},H=Y.attributes,ee=0,j=E.getAttributes();for(let K in j)if(j[K].location>=0){let J=H[K];J===void 0&&(K==="instanceMatrix"&&U.instanceMatrix&&(J=U.instanceMatrix),K==="instanceColor"&&U.instanceColor&&(J=U.instanceColor));let ne={};ne.attribute=J,J&&J.data&&(ne.data=J.data),O[K]=ne,ee++}a.attributes=O,a.attributesNum=ee,a.index=M}function T(){let U=a.newAttributes;for(let Y=0,E=U.length;Y<E;Y++)U[Y]=0}function g(U){m(U,0)}function m(U,Y){let E=a.newAttributes,M=a.enabledAttributes,O=a.attributeDivisors;E[U]=1,M[U]===0&&(n.enableVertexAttribArray(U),M[U]=1),O[U]!==Y&&(n.vertexAttribDivisor(U,Y),O[U]=Y)}function L(){let U=a.newAttributes,Y=a.enabledAttributes;for(let E=0,M=Y.length;E<M;E++)Y[E]!==U[E]&&(n.disableVertexAttribArray(E),Y[E]=0)}function F(U,Y,E,M,O,H,ee){ee===!0?n.vertexAttribIPointer(U,Y,E,O,H):n.vertexAttribPointer(U,Y,E,M,O,H)}function _(U,Y,E,M){T();let O=M.attributes,H=E.getAttributes(),ee=Y.defaultAttributeValues;for(let j in H){let K=H[j];if(K.location>=0){let re=O[j];if(re===void 0&&(j==="instanceMatrix"&&U.instanceMatrix&&(re=U.instanceMatrix),j==="instanceColor"&&U.instanceColor&&(re=U.instanceColor)),re!==void 0){let J=re.normalized,ne=re.itemSize,Te=e.get(re);if(Te===void 0)continue;let fe=Te.buffer,pe=Te.type,Fe=Te.bytesPerElement,ae=pe===n.INT||pe===n.UNSIGNED_INT||re.gpuType===Bu;if(re.isInterleavedBufferAttribute){let de=re.data,_e=de.stride,Ge=re.offset;if(de.isInstancedInterleavedBuffer){for(let $e=0;$e<K.locationSize;$e++)m(K.location+$e,de.meshPerAttribute);U.isInstancedMesh!==!0&&M._maxInstanceCount===void 0&&(M._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let $e=0;$e<K.locationSize;$e++)g(K.location+$e);n.bindBuffer(n.ARRAY_BUFFER,fe);for(let $e=0;$e<K.locationSize;$e++)F(K.location+$e,ne/K.locationSize,pe,J,_e*Fe,(Ge+ne/K.locationSize*$e)*Fe,ae)}else{if(re.isInstancedBufferAttribute){for(let de=0;de<K.locationSize;de++)m(K.location+de,re.meshPerAttribute);U.isInstancedMesh!==!0&&M._maxInstanceCount===void 0&&(M._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let de=0;de<K.locationSize;de++)g(K.location+de);n.bindBuffer(n.ARRAY_BUFFER,fe);for(let de=0;de<K.locationSize;de++)F(K.location+de,ne/K.locationSize,pe,J,ne*Fe,ne/K.locationSize*de*Fe,ae)}}else if(ee!==void 0){let J=ee[j];if(J!==void 0)switch(J.length){case 2:n.vertexAttrib2fv(K.location,J);break;case 3:n.vertexAttrib3fv(K.location,J);break;case 4:n.vertexAttrib4fv(K.location,J);break;default:n.vertexAttrib1fv(K.location,J)}}}}L()}function p(){I();for(let U in i){let Y=i[U];for(let E in Y){let M=Y[E];for(let O in M){let H=M[O];for(let ee in H)d(H[ee].object),delete H[ee];delete M[O]}}delete i[U]}}function S(U){if(i[U.id]===void 0)return;let Y=i[U.id];for(let E in Y){let M=Y[E];for(let O in M){let H=M[O];for(let ee in H)d(H[ee].object),delete H[ee];delete M[O]}}delete i[U.id]}function B(U){for(let Y in i){let E=i[Y];for(let M in E){let O=E[M];if(O[U.id]===void 0)continue;let H=O[U.id];for(let ee in H)d(H[ee].object),delete H[ee];delete O[U.id]}}}function b(U){for(let Y in i){let E=i[Y],M=U.isInstancedMesh===!0?U.id:0,O=E[M];if(O!==void 0){for(let H in O){let ee=O[H];for(let j in ee)d(ee[j].object),delete ee[j];delete O[H]}delete E[M],Object.keys(E).length===0&&delete i[Y]}}}function I(){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:I,resetDefaultState:z,dispose:p,releaseStatesOfGeometry:S,releaseStatesOfObject:b,releaseStatesOfProgram:B,initAttributes:T,enableAttribute:g,disableUnusedAttributes:L}}function _M(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 v=0;v<d;v++)h+=l[v];t.update(h,i,1)}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o}function MM(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!==qr&&i.convert(B)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(B){let b=B===oa&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(B!==Cr&&B!==Yr&&!b&&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&&(rn("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&&rn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let v=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=n.getParameter(n.MAX_TEXTURE_SIZE),g=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),m=n.getParameter(n.MAX_VERTEX_ATTRIBS),L=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),F=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),p=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:u,textureFormatReadable:s,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:v,maxVertexTextures:y,maxTextureSize:T,maxCubemapSize:g,maxAttributes:m,maxVertexUniforms:L,maxVaryings:F,maxFragmentUniforms:_,maxSamples:p,samples:S}}function SM(n){let e=this,t=null,i=0,r=!1,a=!1,s=new Ur,o=new un,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let v=f.length!==0||h||i!==0||r;return r=h,i=f.length,v},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,v){let y=f.clippingPlanes,T=f.clipIntersection,g=f.clipShadows,m=n.get(f);if(!r||y===null||y.length===0||a&&!g)a?d(null):l();else{let L=a?0:i,F=L*4,_=m.clippingState||null;u.value=_,_=d(y,h,F,v);for(let p=0;p!==F;++p)_[p]=t[p];m.clippingState=_,this.numIntersection=T?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,v,y){let T=f!==null?f.length:0,g=null;if(T!==0){if(g=u.value,y!==!0||g===null){let m=v+T*4,L=h.matrixWorldInverse;o.getNormalMatrix(L),(g===null||g.length<m)&&(g=new Float32Array(m));for(let F=0,_=v;F!==T;++F,_+=4)s.copy(f[F]).applyMatrix4(L,o),s.normal.toArray(g,_),g[_+3]=s.constant}u.value=g,u.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,g}}var Lo=4,bM=6,wM=20,TM=256,Zl=new To,C0=new vn,Ph=null,Lh=0,Dh=0,Nh=!1,EM=new ge,ks=new ge,Ed=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=EM}=a;Ph=this._renderer.getRenderTarget(),Lh=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Nh=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=L0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=P0(),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(Ph,Lh,Dh),this._renderer.xr.enabled=Nh,e.scissorTest=!1,Po(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===vs||e.mapping===Os?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ph=this._renderer.getRenderTarget(),Lh=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Nh=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:Hi,minFilter:Hi,generateMipmaps:!1,type:oa,format:qr,colorSpace:fl,depthBuffer:!1},r=R0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=R0(e,t,i);let{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=AM(a)),this._blurMaterial=CM(a,e,t),this._ggxMaterial=IM(a,e,t)}return r}_compileMaterial(e){let t=new jn(new Wi,e);this._renderer.compile(t,Zl)}_sceneToCubeUV(e,t,i,r,a){let u=new er(90,1,t,i),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,h=f.autoClear,v=f.toneMapping;f.getClearColor(C0),f.toneMapping=aa,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new jn(new Or,new Ta({name:"PMREM.Background",side:pr,depthWrite:!1,depthTest:!1})));let T=this._backgroundBox,g=T.material,m=!1,L=e.background;L?L.isColor&&(g.color.copy(L),e.background=null,m=!0):(g.color.copy(C0),m=!0);for(let F=0;F<6;F++){let _=F%3;_===0?(u.up.set(0,l[F],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x+d[F],a.y,a.z)):_===1?(u.up.set(0,0,l[F]),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y+d[F],a.z)):(u.up.set(0,l[F],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y,a.z+d[F]));let p=this._cubeSize;Po(r,_*p,F>2?p:0,p,p),f.setRenderTarget(r),m&&f.render(T,u),f.render(e,u)}f.toneMapping=v,f.autoClear=h,e.background=L}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===vs||e.mapping===Os;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=L0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=P0());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;Po(t,0,0,3*u,2*u),i.setRenderTarget(t),i.render(s,Zl)}_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,v=f*h,{_lodMax:y}=this,T=this._sizeLods[i],g=3*T*(i>y-Lo?i-y+Lo:0),m=4*(this._cubeSize-T);u.envMap.value=e.texture,u.roughness.value=v,u.mipInt.value=y-t,Po(a,g,m,3*T,2*T),r.setRenderTarget(a),r.render(o,Zl),u.envMap.value=a.texture,u.roughness.value=0,u.mipInt.value=y-i,Po(e,g,m,3*T,2*T),r.setRenderTarget(e),r.render(o,Zl)}_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-Lo?r-this._lodMax+Lo:0),h=4*(this._cubeSize-d);Po(t,f,h,3*d,2*d),s.setRenderTarget(t),s.render(u,Zl)}};function AM(n){let e=[],t=[],i=n,r=n-Lo+1+bM;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,v=3,y=new Float32Array(v*h*f),T=new Float32Array(v*h*f);for(let m=0;m<f;m++){let L=m%3*2/3-1,F=m>2?0:-1,_=[L,F,0,L+2/3,F,0,L+2/3,F+1,0,L,F,0,L+2/3,F+1,0,L,F+1,0];y.set(_,v*h*m);for(let p=0;p<h;p++){let S=d[p*2]*2-1,B=d[p*2+1]*2-1;m===0?ks.set(1,B,S):m===1?ks.set(-S,1,-B):m===2?ks.set(-S,B,1):m===3?ks.set(-1,B,-S):m===4?ks.set(-S,-1,B):ks.set(S,B,-1),ks.toArray(T,(m*h+p)*v)}}let g=new Wi;g.setAttribute("position",new Fr(y,v)),g.setAttribute("outputDirection",new Fr(T,v)),t.push(new jn(g,null)),i>Lo&&i--}return{lodMeshes:t,sizeLods:e}}function R0(n,e,t){let i=new Ar(n,e,t);return i.texture.mapping=zl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Po(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function IM(n,e,t){return new kr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:TM,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:Cd(),fragmentShader:`
|
|
3823
|
+
}`,Hn={alphahash_fragment:Lx,alphahash_pars_fragment:Dx,alphamap_fragment:Nx,alphamap_pars_fragment:Ux,alphatest_fragment:Fx,alphatest_pars_fragment:Ox,aomap_fragment:Bx,aomap_pars_fragment:kx,batching_pars_vertex:zx,batching_vertex:Vx,begin_vertex:Gx,beginnormal_vertex:Hx,bsdfs:Wx,iridescence_fragment:Xx,bumpmap_pars_fragment:Yx,clipping_planes_fragment:qx,clipping_planes_pars_fragment:Zx,clipping_planes_pars_vertex:Jx,clipping_planes_vertex:$x,color_fragment:Kx,color_pars_fragment:Qx,color_pars_vertex:jx,color_vertex:e_,common:t_,cube_uv_reflection_fragment:n_,defaultnormal_vertex:i_,displacementmap_pars_vertex:r_,displacementmap_vertex:a_,emissivemap_fragment:s_,emissivemap_pars_fragment:o_,colorspace_fragment:l_,colorspace_pars_fragment:c_,envmap_fragment:u_,envmap_common_pars_fragment:d_,envmap_pars_fragment:f_,envmap_pars_vertex:h_,envmap_physical_pars_fragment:w_,envmap_vertex:p_,fog_vertex:m_,fog_pars_vertex:v_,fog_fragment:g_,fog_pars_fragment:y_,gradientmap_pars_fragment:x_,lightmap_pars_fragment:__,lights_lambert_fragment:M_,lights_lambert_pars_fragment:S_,lights_pars_begin:b_,lights_toon_fragment:T_,lights_toon_pars_fragment:E_,lights_phong_fragment:A_,lights_phong_pars_fragment:I_,lights_physical_fragment:C_,lights_physical_pars_fragment:R_,lights_fragment_begin:P_,lights_fragment_maps:L_,lights_fragment_end:D_,lightprobes_pars_fragment:N_,logdepthbuf_fragment:U_,logdepthbuf_pars_fragment:F_,logdepthbuf_pars_vertex:O_,logdepthbuf_vertex:B_,map_fragment:k_,map_pars_fragment:z_,map_particle_fragment:V_,map_particle_pars_fragment:G_,metalnessmap_fragment:H_,metalnessmap_pars_fragment:W_,morphinstance_vertex:X_,morphcolor_vertex:Y_,morphnormal_vertex:q_,morphtarget_pars_vertex:Z_,morphtarget_vertex:J_,normal_fragment_begin:$_,normal_fragment_maps:K_,normal_pars_fragment:Q_,normal_pars_vertex:j_,normal_vertex:eM,normalmap_pars_fragment:tM,clearcoat_normal_fragment_begin:nM,clearcoat_normal_fragment_maps:iM,clearcoat_pars_fragment:rM,iridescence_pars_fragment:aM,opaque_fragment:sM,packing:oM,premultiplied_alpha_fragment:lM,project_vertex:cM,dithering_fragment:uM,dithering_pars_fragment:dM,roughnessmap_fragment:fM,roughnessmap_pars_fragment:hM,shadowmap_pars_fragment:pM,shadowmap_pars_vertex:mM,shadowmap_vertex:vM,shadowmask_pars_fragment:gM,skinbase_vertex:yM,skinning_pars_vertex:xM,skinning_vertex:_M,skinnormal_vertex:MM,specularmap_fragment:SM,specularmap_pars_fragment:bM,tonemapping_fragment:wM,tonemapping_pars_fragment:TM,transmission_fragment:EM,transmission_pars_fragment:AM,uv_pars_fragment:IM,uv_pars_vertex:CM,uv_vertex:RM,worldpos_vertex:PM,background_vert:LM,background_frag:DM,backgroundCube_vert:NM,backgroundCube_frag:UM,cube_vert:FM,cube_frag:OM,depth_vert:BM,depth_frag:kM,distance_vert:zM,distance_frag:VM,equirect_vert:GM,equirect_frag:HM,linedashed_vert:WM,linedashed_frag:XM,meshbasic_vert:YM,meshbasic_frag:qM,meshlambert_vert:ZM,meshlambert_frag:JM,meshmatcap_vert:$M,meshmatcap_frag:KM,meshnormal_vert:QM,meshnormal_frag:jM,meshphong_vert:eS,meshphong_frag:tS,meshphysical_vert:nS,meshphysical_frag:iS,meshtoon_vert:rS,meshtoon_frag:aS,points_vert:sS,points_frag:oS,shadow_vert:lS,shadow_frag:cS,sprite_vert:uS,sprite_frag:dS},Vt={common:{diffuse:{value:new Cn(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 Kt(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 Cn(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 _e},probesMax:{value:new _e},probesResolution:{value:new _e}},points:{diffuse:{value:new Cn(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 Cn(16777215)},opacity:{value:1},center:{value:new Kt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}}},$a={basic:{uniforms:Cr([Vt.common,Vt.specularmap,Vt.envmap,Vt.aomap,Vt.lightmap,Vt.fog]),vertexShader:Hn.meshbasic_vert,fragmentShader:Hn.meshbasic_frag},lambert:{uniforms:Cr([Vt.common,Vt.specularmap,Vt.envmap,Vt.aomap,Vt.lightmap,Vt.emissivemap,Vt.bumpmap,Vt.normalmap,Vt.displacementmap,Vt.fog,Vt.lights,{emissive:{value:new Cn(0)},envMapIntensity:{value:1}}]),vertexShader:Hn.meshlambert_vert,fragmentShader:Hn.meshlambert_frag},phong:{uniforms:Cr([Vt.common,Vt.specularmap,Vt.envmap,Vt.aomap,Vt.lightmap,Vt.emissivemap,Vt.bumpmap,Vt.normalmap,Vt.displacementmap,Vt.fog,Vt.lights,{emissive:{value:new Cn(0)},specular:{value:new Cn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Hn.meshphong_vert,fragmentShader:Hn.meshphong_frag},standard:{uniforms:Cr([Vt.common,Vt.envmap,Vt.aomap,Vt.lightmap,Vt.emissivemap,Vt.bumpmap,Vt.normalmap,Vt.displacementmap,Vt.roughnessmap,Vt.metalnessmap,Vt.fog,Vt.lights,{emissive:{value:new Cn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Hn.meshphysical_vert,fragmentShader:Hn.meshphysical_frag},toon:{uniforms:Cr([Vt.common,Vt.aomap,Vt.lightmap,Vt.emissivemap,Vt.bumpmap,Vt.normalmap,Vt.displacementmap,Vt.gradientmap,Vt.fog,Vt.lights,{emissive:{value:new Cn(0)}}]),vertexShader:Hn.meshtoon_vert,fragmentShader:Hn.meshtoon_frag},matcap:{uniforms:Cr([Vt.common,Vt.bumpmap,Vt.normalmap,Vt.displacementmap,Vt.fog,{matcap:{value:null}}]),vertexShader:Hn.meshmatcap_vert,fragmentShader:Hn.meshmatcap_frag},points:{uniforms:Cr([Vt.points,Vt.fog]),vertexShader:Hn.points_vert,fragmentShader:Hn.points_frag},dashed:{uniforms:Cr([Vt.common,Vt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Hn.linedashed_vert,fragmentShader:Hn.linedashed_frag},depth:{uniforms:Cr([Vt.common,Vt.displacementmap]),vertexShader:Hn.depth_vert,fragmentShader:Hn.depth_frag},normal:{uniforms:Cr([Vt.common,Vt.bumpmap,Vt.normalmap,Vt.displacementmap,{opacity:{value:1}}]),vertexShader:Hn.meshnormal_vert,fragmentShader:Hn.meshnormal_frag},sprite:{uniforms:Cr([Vt.sprite,Vt.fog]),vertexShader:Hn.sprite_vert,fragmentShader:Hn.sprite_frag},background:{uniforms:{uvTransform:{value:new Ln},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Hn.background_vert,fragmentShader:Hn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ln}},vertexShader:Hn.backgroundCube_vert,fragmentShader:Hn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Hn.cube_vert,fragmentShader:Hn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Hn.equirect_vert,fragmentShader:Hn.equirect_frag},distance:{uniforms:Cr([Vt.common,Vt.displacementmap,{referencePosition:{value:new _e},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Hn.distance_vert,fragmentShader:Hn.distance_frag},shadow:{uniforms:Cr([Vt.lights,Vt.fog,{color:{value:new Cn(0)},opacity:{value:1}}]),vertexShader:Hn.shadow_vert,fragmentShader:Hn.shadow_frag}};$a.physical={uniforms:Cr([$a.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ln},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ln},clearcoatNormalScale:{value:new Kt(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 Cn(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 Kt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ln},attenuationDistance:{value:0},attenuationColor:{value:new Cn(0)},specularColor:{value:new Cn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ln},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ln},anisotropyVector:{value:new Kt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ln}}]),vertexShader:Hn.meshphysical_vert,fragmentShader:Hn.meshphysical_frag};var pf={r:0,b:0,g:0},fS=new Dn,V0=new Ln;V0.set(-1,0,0,0,1,0,0,0,1);function hS(n,e,t,i,r,a){let s=new Cn(0),o=r===!0?0:1,u,l,d=null,f=0,h=null;function p(N){let P=N.isScene===!0?N.background:null;if(P&&P.isTexture){let _=N.backgroundBlurriness>0;P=e.get(P,_)}return P}function y(N){let P=!1,_=p(N);_===null?v(s,o):_&&_.isColor&&(v(_,1),P=!0);let g=n.xr.getEnvironmentBlendMode();g==="additive"?t.buffers.color.setClear(0,0,0,1,a):g==="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(N,P){let _=p(P);_&&(_.isCubeTexture||_.mapping===Ic)?(l===void 0&&(l=new li(new Ur(1,1,1),new na({name:"BackgroundCubeMaterial",uniforms:fo($a.backgroundCube.uniforms),vertexShader:$a.backgroundCube.vertexShader,fragmentShader:$a.backgroundCube.fragmentShader,side:Fr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(g,b,z){this.matrixWorld.copyPosition(z.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(fS.makeRotationFromEuler(P.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(V0),l.material.toneMapped=ni.getTransfer(_.colorSpace)!==_i,(d!==_||f!==_.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,d=_,f=_.version,h=n.toneMapping),l.layers.enableAll(),N.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(u===void 0&&(u=new li(new gc(2,2),new na({name:"BackgroundMaterial",uniforms:fo($a.background.uniforms),vertexShader:$a.background.vertexShader,fragmentShader:$a.background.fragmentShader,side:Ya,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=ni.getTransfer(_.colorSpace)!==_i,_.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(),N.unshift(u,u.geometry,u.material,0,0,null))}function v(N,P){N.getRGB(pf,fp(n)),t.buffers.color.setClear(pf.r,pf.g,pf.b,P,a)}function m(){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(N,P=1){s.set(N),o=P,v(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(N){o=N,v(s,o)},render:y,addToRenderList:M,dispose:m}}function pS(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),a=r,s=!1;function o(F,$,A,S,H){let Y=!1,oe=f(F,S,A,$);a!==oe&&(a=oe,l(a.object)),Y=p(F,S,A,H),Y&&y(F,S,A,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(Y||s)&&(s=!1,_(F,$,A,S),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function u(){return n.createVertexArray()}function l(F){return n.bindVertexArray(F)}function d(F){return n.deleteVertexArray(F)}function f(F,$,A,S){let H=S.wireframe===!0,Y=i[$.id];Y===void 0&&(Y={},i[$.id]=Y);let oe=F.isInstancedMesh===!0?F.id:0,O=Y[oe];O===void 0&&(O={},Y[oe]=O);let k=O[A.id];k===void 0&&(k={},O[A.id]=k);let ne=k[H];return ne===void 0&&(ne=h(u()),k[H]=ne),ne}function h(F){let $=[],A=[],S=[];for(let H=0;H<t;H++)$[H]=0,A[H]=0,S[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:A,attributeDivisors:S,object:F,attributes:{},index:null}}function p(F,$,A,S){let H=a.attributes,Y=$.attributes,oe=0,O=A.getAttributes();for(let k in O)if(O[k].location>=0){let X=H[k],K=Y[k];if(K===void 0&&(k==="instanceMatrix"&&F.instanceMatrix&&(K=F.instanceMatrix),k==="instanceColor"&&F.instanceColor&&(K=F.instanceColor)),X===void 0||X.attribute!==K||K&&X.data!==K.data)return!0;oe++}return a.attributesNum!==oe||a.index!==S}function y(F,$,A,S){let H={},Y=$.attributes,oe=0,O=A.getAttributes();for(let k in O)if(O[k].location>=0){let X=Y[k];X===void 0&&(k==="instanceMatrix"&&F.instanceMatrix&&(X=F.instanceMatrix),k==="instanceColor"&&F.instanceColor&&(X=F.instanceColor));let K={};K.attribute=X,X&&X.data&&(K.data=X.data),H[k]=K,oe++}a.attributes=H,a.attributesNum=oe,a.index=S}function M(){let F=a.newAttributes;for(let $=0,A=F.length;$<A;$++)F[$]=0}function v(F){m(F,0)}function m(F,$){let A=a.newAttributes,S=a.enabledAttributes,H=a.attributeDivisors;A[F]=1,S[F]===0&&(n.enableVertexAttribArray(F),S[F]=1),H[F]!==$&&(n.vertexAttribDivisor(F,$),H[F]=$)}function N(){let F=a.newAttributes,$=a.enabledAttributes;for(let A=0,S=$.length;A<S;A++)$[A]!==F[A]&&(n.disableVertexAttribArray(A),$[A]=0)}function P(F,$,A,S,H,Y,oe){oe===!0?n.vertexAttribIPointer(F,$,A,H,Y):n.vertexAttribPointer(F,$,A,S,H,Y)}function _(F,$,A,S){M();let H=S.attributes,Y=A.getAttributes(),oe=$.defaultAttributeValues;for(let O in Y){let k=Y[O];if(k.location>=0){let ne=H[O];if(ne===void 0&&(O==="instanceMatrix"&&F.instanceMatrix&&(ne=F.instanceMatrix),O==="instanceColor"&&F.instanceColor&&(ne=F.instanceColor)),ne!==void 0){let X=ne.normalized,K=ne.itemSize,ge=e.get(ne);if(ge===void 0)continue;let se=ge.buffer,Se=ge.type,Pe=ge.bytesPerElement,le=Se===n.INT||Se===n.UNSIGNED_INT||ne.gpuType===Id;if(ne.isInterleavedBufferAttribute){let ae=ne.data,fe=ae.stride,Ne=ne.offset;if(ae.isInstancedInterleavedBuffer){for(let Re=0;Re<k.locationSize;Re++)m(k.location+Re,ae.meshPerAttribute);F.isInstancedMesh!==!0&&S._maxInstanceCount===void 0&&(S._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let Re=0;Re<k.locationSize;Re++)v(k.location+Re);n.bindBuffer(n.ARRAY_BUFFER,se);for(let Re=0;Re<k.locationSize;Re++)P(k.location+Re,K/k.locationSize,Se,X,fe*Pe,(Ne+K/k.locationSize*Re)*Pe,le)}else{if(ne.isInstancedBufferAttribute){for(let ae=0;ae<k.locationSize;ae++)m(k.location+ae,ne.meshPerAttribute);F.isInstancedMesh!==!0&&S._maxInstanceCount===void 0&&(S._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let ae=0;ae<k.locationSize;ae++)v(k.location+ae);n.bindBuffer(n.ARRAY_BUFFER,se);for(let ae=0;ae<k.locationSize;ae++)P(k.location+ae,K/k.locationSize,Se,X,K*Pe,K/k.locationSize*ae*Pe,le)}}else if(oe!==void 0){let X=oe[O];if(X!==void 0)switch(X.length){case 2:n.vertexAttrib2fv(k.location,X);break;case 3:n.vertexAttrib3fv(k.location,X);break;case 4:n.vertexAttrib4fv(k.location,X);break;default:n.vertexAttrib1fv(k.location,X)}}}}N()}function g(){D();for(let F in i){let $=i[F];for(let A in $){let S=$[A];for(let H in S){let Y=S[H];for(let oe in Y)d(Y[oe].object),delete Y[oe];delete S[H]}}delete i[F]}}function b(F){if(i[F.id]===void 0)return;let $=i[F.id];for(let A in $){let S=$[A];for(let H in S){let Y=S[H];for(let oe in Y)d(Y[oe].object),delete Y[oe];delete S[H]}}delete i[F.id]}function z(F){for(let $ in i){let A=i[$];for(let S in A){let H=A[S];if(H[F.id]===void 0)continue;let Y=H[F.id];for(let oe in Y)d(Y[oe].object),delete Y[oe];delete H[F.id]}}}function T(F){for(let $ in i){let A=i[$],S=F.isInstancedMesh===!0?F.id:0,H=A[S];if(H!==void 0){for(let Y in H){let oe=H[Y];for(let O in oe)d(oe[O].object),delete oe[O];delete H[Y]}delete A[S],Object.keys(A).length===0&&delete i[$]}}}function D(){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:D,resetDefaultState:G,dispose:g,releaseStatesOfGeometry:b,releaseStatesOfObject:T,releaseStatesOfProgram:z,initAttributes:M,enableAttribute:v,disableUnusedAttributes:N}}function mS(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 p=0;p<d;p++)h+=l[p];t.update(h,i,1)}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o}function vS(n,e,t,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let z=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(z.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(z){return!(z!==aa&&i.convert(z)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(z){let T=z===La&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(z!==Xr&&z!==ra&&!T&&i.convert(z)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE))}function u(z){if(z==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";z="mediump"}return z==="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&&(xn("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&&xn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),M=n.getParameter(n.MAX_TEXTURE_SIZE),v=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),m=n.getParameter(n.MAX_VERTEX_ATTRIBS),N=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),P=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),g=n.getParameter(n.MAX_SAMPLES),b=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:u,textureFormatReadable:s,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:y,maxTextureSize:M,maxCubemapSize:v,maxAttributes:m,maxVertexUniforms:N,maxVaryings:P,maxFragmentUniforms:_,maxSamples:g,samples:b}}function gS(n){let e=this,t=null,i=0,r=!1,a=!1,s=new jr,o=new Ln,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let p=f.length!==0||h||i!==0||r;return r=h,i=f.length,p},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,p){let y=f.clippingPlanes,M=f.clipIntersection,v=f.clipShadows,m=n.get(f);if(!r||y===null||y.length===0||a&&!v)a?d(null):l();else{let N=a?0:i,P=N*4,_=m.clippingState||null;u.value=_,_=d(y,h,P,p);for(let g=0;g!==P;++g)_[g]=t[g];m.clippingState=_,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=N}};function l(){u.value!==t&&(u.value=t,u.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(f,h,p,y){let M=f!==null?f.length:0,v=null;if(M!==0){if(v=u.value,y!==!0||v===null){let m=p+M*4,N=h.matrixWorldInverse;o.getNormalMatrix(N),(v===null||v.length<m)&&(v=new Float32Array(m));for(let P=0,_=p;P!==M;++P,_+=4)s.copy(f[P]).applyMatrix4(N,o),s.normal.toArray(v,_),v[_+3]=s.constant}u.value=v,u.needsUpdate=!0}return e.numPlanes=M,e.numIntersection=0,v}}var gl=4,yS=6,xS=20,_S=256,Fc=new cl,x0=new Cn,Mp=null,Sp=0,bp=0,wp=!1,MS=new _e,ho=new _e,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=MS}=a;Mp=this._renderer.getRenderTarget(),Sp=this._renderer.getActiveCubeFace(),bp=this._renderer.getActiveMipmapLevel(),wp=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=S0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=M0(),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(Mp,Sp,bp),this._renderer.xr.enabled=wp,e.scissorTest=!1,vl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ds||e.mapping===lo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Mp=this._renderer.getRenderTarget(),Sp=this._renderer.getActiveCubeFace(),bp=this._renderer.getActiveMipmapLevel(),wp=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:cr,minFilter:cr,generateMipmaps:!1,type:La,format:aa,colorSpace:jl,depthBuffer:!1},r=_0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=_0(e,t,i);let{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=SS(a)),this._blurMaterial=wS(a,e,t),this._ggxMaterial=bS(a,e,t)}return r}_compileMaterial(e){let t=new li(new dr,e);this._renderer.compile(t,Fc)}_sceneToCubeUV(e,t,i,r,a){let u=new Er(90,1,t,i),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,h=f.autoClear,p=f.toneMapping;f.getClearColor(x0),f.toneMapping=Wr,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new li(new Ur,new Hr({name:"PMREM.Background",side:Fr,depthWrite:!1,depthTest:!1})));let M=this._backgroundBox,v=M.material,m=!1,N=e.background;N?N.isColor&&(v.color.copy(N),e.background=null,m=!0):(v.color.copy(x0),m=!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 g=this._cubeSize;vl(r,_*g,P>2?g:0,g,g),f.setRenderTarget(r),m&&f.render(M,u),f.render(e,u)}f.toneMapping=p,f.autoClear=h,e.background=N}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===Ds||e.mapping===lo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=S0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=M0());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,Fc)}_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,p=f*h,{_lodMax:y}=this,M=this._sizeLods[i],v=3*M*(i>y-gl?i-y+gl:0),m=4*(this._cubeSize-M);u.envMap.value=e.texture,u.roughness.value=p,u.mipInt.value=y-t,vl(a,v,m,3*M,2*M),r.setRenderTarget(a),r.render(o,Fc),u.envMap.value=a.texture,u.roughness.value=0,u.mipInt.value=y-i,vl(e,v,m,3*M,2*M),r.setRenderTarget(e),r.render(o,Fc)}_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,Fc)}};function SS(n){let e=[],t=[],i=n,r=n-gl+1+yS;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,p=3,y=new Float32Array(p*h*f),M=new Float32Array(p*h*f);for(let m=0;m<f;m++){let N=m%3*2/3-1,P=m>2?0:-1,_=[N,P,0,N+2/3,P,0,N+2/3,P+1,0,N,P,0,N+2/3,P+1,0,N,P+1,0];y.set(_,p*h*m);for(let g=0;g<h;g++){let b=d[g*2]*2-1,z=d[g*2+1]*2-1;m===0?ho.set(1,z,b):m===1?ho.set(-b,1,-z):m===2?ho.set(-b,z,1):m===3?ho.set(-1,z,-b):m===4?ho.set(-b,-1,z):ho.set(b,z,-1),ho.toArray(M,(m*h+g)*p)}}let v=new dr;v.setAttribute("position",new Ar(y,p)),v.setAttribute("outputDirection",new Ar(M,p)),t.push(new li(v,null)),i>gl&&i--}return{lodMeshes:t,sizeLods:e}}function _0(n,e,t){let i=new Gr(n,e,t);return i.texture.mapping=Ic,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 bS(n,e,t){return new na({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:_S,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:yf(),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:qa,depthTest:!1,depthWrite:!1})}function wS(n,e,t){return new na({name:"SphericalGaussianBlur",defines:{SAMPLES:xS,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:yf(),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:qa,depthTest:!1,depthWrite:!1})}function M0(){return new na({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yf(),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:qa,depthTest:!1,depthWrite:!1})}function S0(){return new na({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yf(),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:qa,depthTest:!1,depthWrite:!1})}function yf(){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 vf=class extends Gr{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 lc(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 Ur(5,5,5),a=new na({name:"CubemapFromEquirect",uniforms:fo(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Fr,blending:qa});a.uniforms.tEquirect.value=t;let s=new li(r,a),o=t.minFilter;return t.minFilter===Za&&(t.minFilter=cr),new Md(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 TS(n){let e=new WeakMap,t=new WeakMap,i=null;function r(h,p=!1){return h==null?null:p?s(h):a(h)}function a(h){if(h&&h.isTexture){let p=h.mapping;if(p===fl||p===Ed)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 vf(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 p=h.mapping,y=p===fl||p===Ed,M=p===Ds||p===lo;if(y||M){let v=t.get(h),m=v!==void 0?v.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m)return i===null&&(i=new xl(n)),v=y?i.fromEquirectangular(h,v):i.fromCubemap(h,v),v.texture.pmremVersion=h.pmremVersion,t.set(h,v),v.texture;if(v!==void 0)return v.texture;{let N=h.image;return y&&N&&N.height>0||M&&N&&u(N)?(i===null&&(i=new xl(n)),v=y?i.fromEquirectangular(h):i.fromCubemap(h),v.texture.pmremVersion=h.pmremVersion,t.set(h,v),h.addEventListener("dispose",d),v.texture):null}}}return h}function o(h,p){return p===fl?h.mapping=Ds:p===Ed&&(h.mapping=lo),h}function u(h){let p=0,y=6;for(let M=0;M<y;M++)h[M]!==void 0&&p++;return p===y}function l(h){let p=h.target;p.removeEventListener("dispose",l);let y=e.get(p);y!==void 0&&(e.delete(p),y.dispose())}function d(h){let p=h.target;p.removeEventListener("dispose",d);let y=t.get(p);y!==void 0&&(t.delete(p),y.dispose())}function f(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:f}}function ES(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&&io("WebGLRenderer: "+i+" extension not supported."),r}}}function AS(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 p=a.get(h);p&&(e.remove(p),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 p in h)e.update(h[p],n.ARRAY_BUFFER)}function l(f){let h=[],p=f.index,y=f.attributes.position,M=0;if(y===void 0)return;if(p!==null){let N=p.array;M=p.version;for(let P=0,_=N.length;P<_;P+=3){let g=N[P+0],b=N[P+1],z=N[P+2];h.push(g,b,b,z,z,g)}}else{let N=y.array;M=y.version;for(let P=0,_=N.length/3-1;P<_;P+=3){let g=P+0,b=P+1,z=P+2;h.push(g,b,b,z,z,g)}}let v=new(y.count>=65535?ac:rc)(h,1);v.version=M;let m=a.get(f);m&&e.remove(m),a.set(f,v)}function d(f){let h=a.get(f);if(h){let p=f.index;p!==null&&h.version<p.version&&l(f)}else l(f);return a.get(f)}return{get:o,update:u,getWireframeAttribute:d}}function IS(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,p){p!==0&&(n.drawElementsInstanced(i,h,a,f*s,p),t.update(h,i,p))}function d(f,h,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,a,f,0,p);let M=0;for(let v=0;v<p;v++)M+=h[v];t.update(M,i,1)}this.setMode=r,this.setIndex=o,this.render=u,this.renderInstances=l,this.renderMultiDraw=d}function CS(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:Tn("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 RS(n,e,t){let i=new WeakMap,r=new Ti;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 D=function(){z.dispose(),i.delete(o),o.removeEventListener("dispose",D)};h!==void 0&&h.texture.dispose();let p=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,M=o.morphAttributes.color!==void 0,v=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],N=o.morphAttributes.color||[],P=0;p===!0&&(P=1),y===!0&&(P=2),M===!0&&(P=3);let _=o.attributes.position.count*P,g=1;_>e.maxTextureSize&&(g=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);let b=new Float32Array(_*g*4*f),z=new nc(b,_,g,f);z.type=ra,z.needsUpdate=!0;let T=P*4;for(let G=0;G<f;G++){let F=v[G],$=m[G],A=N[G],S=_*g*4*G;for(let H=0;H<F.count;H++){let Y=H*T;p===!0&&(r.fromBufferAttribute(F,H),b[S+Y+0]=r.x,b[S+Y+1]=r.y,b[S+Y+2]=r.z,b[S+Y+3]=0),y===!0&&(r.fromBufferAttribute($,H),b[S+Y+4]=r.x,b[S+Y+5]=r.y,b[S+Y+6]=r.z,b[S+Y+7]=0),M===!0&&(r.fromBufferAttribute(A,H),b[S+Y+8]=r.x,b[S+Y+9]=r.y,b[S+Y+10]=r.z,b[S+Y+11]=A.itemSize===4?r.w:1)}}h={count:f,texture:z,size:new Kt(_,g)},i.set(o,h),o.addEventListener("dispose",D)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)u.getUniforms().setValue(n,"morphTexture",s.morphTexture,t);else{let p=0;for(let M=0;M<l.length;M++)p+=l[M];let y=o.morphTargetsRelative?1:1-p;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 PS(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 p=l.skeleton;a.get(p)!==d&&(p.update(),a.set(p,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 LS={[Kh]:"LINEAR_TONE_MAPPING",[Qh]:"REINHARD_TONE_MAPPING",[jh]:"CINEON_TONE_MAPPING",[Ec]:"ACES_FILMIC_TONE_MAPPING",[tp]:"AGX_TONE_MAPPING",[Ac]:"NEUTRAL_TONE_MAPPING",[ep]:"CUSTOM_TONE_MAPPING"};function DS(n,e,t,i,r,a){let s=new Gr(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 dr;l.setAttribute("position",new mi([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new mi([0,2,0,0,2,0],2));let d=new od({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 li(l,d),h=new cl(-1,1,1,-1,0,1),p=null,y=null,M=!1,v,m=null,N=[],P=!1;this.setSize=function(_,g){s.setSize(_,g),o!==null&&o.setSize(_,g),u!==null&&u.setSize(_,g);for(let b=0;b<N.length;b++){let z=N[b];z.setSize&&z.setSize(_,g)}},this.setEffects=function(_){N=_,P=N.length>0&&N[0].isRenderPass===!0;let g=s.width,b=s.height;N.length>0&&o===null&&(o=new Gr(g,b,{type:La,depthBuffer:!1,stencilBuffer:!1}),u=new Gr(g,b,{type:La,depthBuffer:!1,stencilBuffer:!1}));for(let z=0;z<N.length;z++){let T=N[z];T.setSize&&T.setSize(g,b)}},this.begin=function(_,g){if(M||_.toneMapping===Wr&&N.length===0)return!1;if(m=g,g!==null){let b=g.width,z=g.height;(s.width!==b||s.height!==z)&&this.setSize(b,z)}return P===!1&&_.setRenderTarget(s),v=_.toneMapping,_.toneMapping=Wr,!0},this.hasRenderPass=function(){return P},this.end=function(_,g){_.toneMapping=v,M=!0;let b=s,z=o;for(let T=0;T<N.length;T++){let D=N[T];D.enabled!==!1&&(D.render(_,z,b,g),D.needsSwap!==!1&&(b=z,z=z===o?u:o))}if(p!==_.outputColorSpace||y!==_.toneMapping){p=_.outputColorSpace,y=_.toneMapping,d.defines={},ni.getTransfer(p)===_i&&(d.defines.SRGB_TRANSFER="");let T=LS[y];T&&(d.defines[T]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=b.texture,_.setRenderTarget(m),_.render(f,h),m=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 G0=new _r,Ap=new Cs(1,1),H0=new nc,W0=new ju,X0=new lc,b0=[],w0=[],T0=new Float32Array(16),E0=new Float32Array(9),A0=new Float32Array(4);function _l(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,a=b0[r];if(a===void 0&&(a=new Float32Array(r),b0[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 hr(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 pr(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function xf(n,e){let t=w0[e];t===void 0&&(t=new Int32Array(e),w0[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function NS(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function US(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(hr(t,e))return;n.uniform2fv(this.addr,e),pr(t,e)}}function FS(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(hr(t,e))return;n.uniform3fv(this.addr,e),pr(t,e)}}function OS(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(hr(t,e))return;n.uniform4fv(this.addr,e),pr(t,e)}}function BS(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(hr(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),pr(t,e)}else{if(hr(t,i))return;A0.set(i),n.uniformMatrix2fv(this.addr,!1,A0),pr(t,i)}}function kS(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(hr(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),pr(t,e)}else{if(hr(t,i))return;E0.set(i),n.uniformMatrix3fv(this.addr,!1,E0),pr(t,i)}}function zS(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(hr(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),pr(t,e)}else{if(hr(t,i))return;T0.set(i),n.uniformMatrix4fv(this.addr,!1,T0),pr(t,i)}}function VS(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function GS(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(hr(t,e))return;n.uniform2iv(this.addr,e),pr(t,e)}}function HS(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(hr(t,e))return;n.uniform3iv(this.addr,e),pr(t,e)}}function WS(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(hr(t,e))return;n.uniform4iv(this.addr,e),pr(t,e)}}function XS(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function YS(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(hr(t,e))return;n.uniform2uiv(this.addr,e),pr(t,e)}}function qS(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(hr(t,e))return;n.uniform3uiv(this.addr,e),pr(t,e)}}function ZS(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(hr(t,e))return;n.uniform4uiv(this.addr,e),pr(t,e)}}function JS(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?(Ap.compareFunction=t.isReversedDepthBuffer()?hf:ff,a=Ap):a=G0,t.setTexture2D(e||a,r)}function $S(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||W0,r)}function KS(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||X0,r)}function QS(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||H0,r)}function jS(n){switch(n){case 5126:return NS;case 35664:return US;case 35665:return FS;case 35666:return OS;case 35674:return BS;case 35675:return kS;case 35676:return zS;case 5124:case 35670:return VS;case 35667:case 35671:return GS;case 35668:case 35672:return HS;case 35669:case 35673:return WS;case 5125:return XS;case 36294:return YS;case 36295:return qS;case 36296:return ZS;case 35678:case 36198:case 36298:case 36306:case 35682:return JS;case 35679:case 36299:case 36307:return $S;case 35680:case 36300:case 36308:case 36293:return KS;case 36289:case 36303:case 36311:case 36292:return QS}}function eb(n,e){n.uniform1fv(this.addr,e)}function tb(n,e){let t=_l(e,this.size,2);n.uniform2fv(this.addr,t)}function nb(n,e){let t=_l(e,this.size,3);n.uniform3fv(this.addr,t)}function ib(n,e){let t=_l(e,this.size,4);n.uniform4fv(this.addr,t)}function rb(n,e){let t=_l(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function ab(n,e){let t=_l(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function sb(n,e){let t=_l(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function ob(n,e){n.uniform1iv(this.addr,e)}function lb(n,e){n.uniform2iv(this.addr,e)}function cb(n,e){n.uniform3iv(this.addr,e)}function ub(n,e){n.uniform4iv(this.addr,e)}function db(n,e){n.uniform1uiv(this.addr,e)}function fb(n,e){n.uniform2uiv(this.addr,e)}function hb(n,e){n.uniform3uiv(this.addr,e)}function pb(n,e){n.uniform4uiv(this.addr,e)}function mb(n,e,t){let i=this.cache,r=e.length,a=xf(t,r);hr(i,a)||(n.uniform1iv(this.addr,a),pr(i,a));let s;this.type===n.SAMPLER_2D_SHADOW?s=Ap:s=G0;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||s,a[o])}function vb(n,e,t){let i=this.cache,r=e.length,a=xf(t,r);hr(i,a)||(n.uniform1iv(this.addr,a),pr(i,a));for(let s=0;s!==r;++s)t.setTexture3D(e[s]||W0,a[s])}function gb(n,e,t){let i=this.cache,r=e.length,a=xf(t,r);hr(i,a)||(n.uniform1iv(this.addr,a),pr(i,a));for(let s=0;s!==r;++s)t.setTextureCube(e[s]||X0,a[s])}function yb(n,e,t){let i=this.cache,r=e.length,a=xf(t,r);hr(i,a)||(n.uniform1iv(this.addr,a),pr(i,a));for(let s=0;s!==r;++s)t.setTexture2DArray(e[s]||H0,a[s])}function xb(n){switch(n){case 5126:return eb;case 35664:return tb;case 35665:return nb;case 35666:return ib;case 35674:return rb;case 35675:return ab;case 35676:return sb;case 5124:case 35670:return ob;case 35667:case 35671:return lb;case 35668:case 35672:return cb;case 35669:case 35673:return ub;case 5125:return db;case 36294:return fb;case 36295:return hb;case 36296:return pb;case 35678:case 36198:case 36298:case 36306:case 35682:return mb;case 35679:case 36299:case 36307:return vb;case 35680:case 36300:case 36308:case 36293:return gb;case 36289:case 36303:case 36311:case 36292:return yb}}var Ip=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=jS(t.type)}},Cp=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=xb(t.type)}},Rp=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)}}},Tp=/(\w+)(\])?(\[|\.)?/g;function I0(n,e){n.seq.push(e),n.map[e.id]=e}function _b(n,e,t){let i=n.name,r=i.length;for(Tp.lastIndex=0;;){let a=Tp.exec(i),s=Tp.lastIndex,o=a[1],u=a[2]==="]",l=a[3];if(u&&(o=o|0),l===void 0||l==="["&&s+2===r){I0(t,l===void 0?new Ip(o,n,e):new Cp(o,n,e));break}else{let f=t.map[o];f===void 0&&(f=new Rp(o),I0(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);_b(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 C0(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}var Mb=37297,Sb=0;function bb(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 R0=new Ln;function wb(n){ni._getMatrix(R0,ni.workingColorSpace,n);let e=`mat3( ${R0.elements.map(t=>t.toFixed(4))} )`;switch(ni.getTransfer(n)){case ec:return[e,"LinearTransferOETF"];case _i:return[e,"sRGBTransferOETF"];default:return xn("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function P0(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
|
+
`+bb(n.getShaderSource(e),o)}else return a}function Tb(n,e){let t=wb(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
4125
|
+
`)}var Eb={[Kh]:"Linear",[Qh]:"Reinhard",[jh]:"Cineon",[Ec]:"ACESFilmic",[tp]:"AgX",[Ac]:"Neutral",[ep]:"Custom"};function Ab(n,e){let t=Eb[e];return t===void 0?(xn("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var mf=new _e;function Ib(){ni.getLuminanceCoefficients(mf);let n=mf.x.toFixed(4),e=mf.y.toFixed(4),t=mf.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4126
|
+
`)}function Cb(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Bc).join(`
|
|
4127
|
+
`)}function Rb(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
4128
|
+
`)}function Pb(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 Bc(n){return n!==""}function L0(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 D0(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Lb=/^[ \t]*#include +<([\w\d./]+)>/gm;function Pp(n){return n.replace(Lb,Nb)}var Db=new Map;function Nb(n,e){let t=Hn[e];if(t===void 0){let i=Db.get(e);if(i!==void 0)t=Hn[i],xn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Pp(t)}var Ub=/#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 N0(n){return n.replace(Ub,Fb)}function Fb(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 U0(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?(
|
|
4150
|
-
`),
|
|
4151
|
-
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(
|
|
4148
|
+
#define LOW_PRECISION`),e}var Ob={[Tc]:"SHADOWMAP_TYPE_PCF",[ul]:"SHADOWMAP_TYPE_VSM"};function Bb(n){return Ob[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var kb={[Ds]:"ENVMAP_TYPE_CUBE",[lo]:"ENVMAP_TYPE_CUBE",[Ic]:"ENVMAP_TYPE_CUBE_UV"};function zb(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":kb[n.envMapMode]||"ENVMAP_TYPE_CUBE"}var Vb={[lo]:"ENVMAP_MODE_REFRACTION"};function Gb(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":Vb[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}var Hb={[Td]:"ENVMAP_BLENDING_MULTIPLY",[Zv]:"ENVMAP_BLENDING_MIX",[Jv]:"ENVMAP_BLENDING_ADD"};function Wb(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":Hb[n.combine]||"ENVMAP_BLENDING_NONE"}function Xb(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 Yb(n,e,t,i){let r=n.getContext(),a=t.defines,s=t.vertexShader,o=t.fragmentShader,u=Bb(t),l=zb(t),d=Gb(t),f=Wb(t),h=Xb(t),p=Cb(t),y=Rb(a),M=r.createProgram(),v,m,N=t.glslVersion?"#version "+t.glslVersion+`
|
|
4149
|
+
`:"";t.isRawShaderMaterial?(v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Bc).join(`
|
|
4150
|
+
`),v.length>0&&(v+=`
|
|
4151
|
+
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(Bc).join(`
|
|
4152
4152
|
`),m.length>0&&(m+=`
|
|
4153
|
-
`)):(
|
|
4154
|
-
`].filter(
|
|
4155
|
-
`),m=[
|
|
4156
|
-
`].filter(
|
|
4157
|
-
`)),s=
|
|
4158
|
-
`,
|
|
4153
|
+
`)):(v=[U0(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(Bc).join(`
|
|
4155
|
+
`),m=[U0(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!==Wr?"#define TONE_MAPPING":"",t.toneMapping!==Wr?Hn.tonemapping_pars_fragment:"",t.toneMapping!==Wr?Ab("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Hn.colorspace_pars_fragment,Tb("linearToOutputTexel",t.outputColorSpace),Ib(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4156
|
+
`].filter(Bc).join(`
|
|
4157
|
+
`)),s=Pp(s),s=L0(s,t),s=D0(s,t),o=Pp(o),o=L0(o,t),o=D0(o,t),s=N0(s),o=N0(o),t.isRawShaderMaterial!==!0&&(N=`#version 300 es
|
|
4158
|
+
`,v=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4159
4159
|
`)+`
|
|
4160
|
-
`+
|
|
4160
|
+
`+v,m=["#define varying in",t.glslVersion===cp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===cp?"":"#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
|
-
`+m);let
|
|
4162
|
+
`+m);let P=N+v+s,_=N+m+o,g=C0(r,r.VERTEX_SHADER,P),b=C0(r,r.FRAGMENT_SHADER,_);r.attachShader(M,g),r.attachShader(M,b),t.index0AttributeName!==void 0?r.bindAttribLocation(M,0,t.index0AttributeName):t.hasPositionAttribute===!0&&r.bindAttribLocation(M,0,"position"),r.linkProgram(M);function z(F){if(n.debug.checkShaderErrors){let $=r.getProgramInfoLog(M)||"",A=r.getShaderInfoLog(g)||"",S=r.getShaderInfoLog(b)||"",H=$.trim(),Y=A.trim(),oe=S.trim(),O=!0,k=!0;if(r.getProgramParameter(M,r.LINK_STATUS)===!1)if(O=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,M,g,b);else{let ne=P0(r,g,"vertex"),X=P0(r,b,"fragment");Tn("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(M,r.VALIDATE_STATUS)+`
|
|
4163
4163
|
|
|
4164
|
-
Material Name: `+
|
|
4165
|
-
Material Type: `+
|
|
4164
|
+
Material Name: `+F.name+`
|
|
4165
|
+
Material Type: `+F.type+`
|
|
4166
4166
|
|
|
4167
|
-
Program Info Log: `+
|
|
4168
|
-
`+
|
|
4169
|
-
`+J)}else O!==""?rn("WebGLProgram: Program Info Log:",O):(H===""||ee==="")&&(K=!1);K&&(U.diagnostics={runnable:j,programLog:O,vertexShader:{log:H,prefix:g},fragmentShader:{log:ee,prefix:m}})}r.deleteShader(p),r.deleteShader(S),b=new Do(r,T),I=FS(r,T)}let b;this.getUniforms=function(){return b===void 0&&B(this),b};let I;this.getAttributes=function(){return I===void 0&&B(this),I};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=r.getProgramParameter(T,ES)),z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(T),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=AS++,this.cacheKey=e,this.usedTimes=1,this.program=T,this.vertexShader=p,this.fragmentShader=S,this}var QS=0,Gh=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 Hh(e),t.set(e,i)),i}},Hh=class{constructor(e){this.id=QS++,this.code=e,this.usedTimes=0}};function jS(n){return n===xs||n===Yl||n===ql}function eb(n,e,t,i,r,a){let s=new go,o=new Gh,u=new Set,l=[],d=new Map,f=i.logarithmicDepthBuffer,h=i.precision,v={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(b){return u.add(b),b===0?"uv":`uv${b}`}function T(b,I,z,U,Y,E){let M=U.fog,O=Y.geometry,H=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?U.environment:null,ee=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap,j=e.get(b.envMap||H,ee),K=j&&j.mapping===zl?j.image.height:null,re=v[b.type];b.precision!==null&&(h=i.getMaxPrecision(b.precision),h!==b.precision&&rn("WebGLProgram.getParameters:",b.precision,"not supported, using",h,"instead."));let J=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ne=J!==void 0?J.length:0,Te=0;O.morphAttributes.position!==void 0&&(Te=1),O.morphAttributes.normal!==void 0&&(Te=2),O.morphAttributes.color!==void 0&&(Te=3);let fe,pe,Fe,ae;if(re){let cn=Ca[re];fe=cn.vertexShader,pe=cn.fragmentShader}else{fe=b.vertexShader,pe=b.fragmentShader;let cn=o.getVertexShaderStage(b),dn=o.getFragmentShaderStage(b);o.update(b,cn,dn),Fe=cn.id,ae=dn.id}let de=n.getRenderTarget(),_e=n.state.buffers.depth.getReversed(),Ge=Y.isInstancedMesh===!0,$e=Y.isBatchedMesh===!0,ut=!!b.map,zt=!!b.matcap,ct=!!j,Tt=!!b.aoMap,Zt=!!b.lightMap,wt=!!b.bumpMap&&b.wireframe===!1,bt=!!b.normalMap,_t=!!b.displacementMap,ln=!!b.emissiveMap,rt=!!b.metalnessMap,an=!!b.roughnessMap,se=b.anisotropy>0,mn=b.clearcoat>0,nn=b.dispersion>0,W=b.retroreflectivity>0,w=b.iridescence>0,ue=b.sheen>0,ye=b.transmission>0,we=se&&!!b.anisotropyMap,ze=mn&&!!b.clearcoatMap,Ye=mn&&!!b.clearcoatNormalMap,Re=mn&&!!b.clearcoatRoughnessMap,Ae=w&&!!b.iridescenceMap,Ne=w&&!!b.iridescenceThicknessMap,je=ue&&!!b.sheenColorMap,Ve=ue&&!!b.sheenRoughnessMap,qe=!!b.specularMap,ot=!!b.specularColorMap,pt=!!b.specularIntensityMap,He=ye&&!!b.transmissionMap,ie=ye&&!!b.thicknessMap,Oe=!!b.gradientMap,Pe=!!b.alphaMap,nt=b.alphaTest>0,dt=!!b.alphaHash,Be=!!b.extensions,Rt=aa;b.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(Rt=n.toneMapping);let vt={shaderID:re,shaderType:b.type,shaderName:b.name,vertexShader:fe,fragmentShader:pe,defines:b.defines,customVertexShaderID:Fe,customFragmentShaderID:ae,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:h,batching:$e,batchingColor:$e&&Y._colorsTexture!==null,instancing:Ge,instancingColor:Ge&&Y.instanceColor!==null,instancingMorph:Ge&&Y.morphTexture!==null,outputColorSpace:de===null?n.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:Ln.workingColorSpace,alphaToCoverage:!!b.alphaToCoverage,map:ut,matcap:zt,envMap:ct,envMapMode:ct&&j.mapping,envMapCubeUVHeight:K,aoMap:Tt,lightMap:Zt,bumpMap:wt,normalMap:bt,displacementMap:_t,emissiveMap:ln,normalMapObjectSpace:bt&&b.normalMapType===l0,normalMapTangentSpace:bt&&b.normalMapType===Md,packedNormalMap:bt&&b.normalMapType===Md&&jS(b.normalMap.format),metalnessMap:rt,roughnessMap:an,anisotropy:se,anisotropyMap:we,clearcoat:mn,clearcoatMap:ze,clearcoatNormalMap:Ye,clearcoatRoughnessMap:Re,dispersion:nn,retroreflection:W,iridescence:w,iridescenceMap:Ae,iridescenceThicknessMap:Ne,sheen:ue,sheenColorMap:je,sheenRoughnessMap:Ve,specularMap:qe,specularColorMap:ot,specularIntensityMap:pt,transmission:ye,transmissionMap:He,thicknessMap:ie,gradientMap:Oe,opaque:b.transparent===!1&&b.blending===Ao&&b.alphaToCoverage===!1,alphaMap:Pe,alphaTest:nt,alphaHash:dt,combine:b.combine,mapUv:ut&&y(b.map.channel),aoMapUv:Tt&&y(b.aoMap.channel),lightMapUv:Zt&&y(b.lightMap.channel),bumpMapUv:wt&&y(b.bumpMap.channel),normalMapUv:bt&&y(b.normalMap.channel),displacementMapUv:_t&&y(b.displacementMap.channel),emissiveMapUv:ln&&y(b.emissiveMap.channel),metalnessMapUv:rt&&y(b.metalnessMap.channel),roughnessMapUv:an&&y(b.roughnessMap.channel),anisotropyMapUv:we&&y(b.anisotropyMap.channel),clearcoatMapUv:ze&&y(b.clearcoatMap.channel),clearcoatNormalMapUv:Ye&&y(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Re&&y(b.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&y(b.iridescenceMap.channel),iridescenceThicknessMapUv:Ne&&y(b.iridescenceThicknessMap.channel),sheenColorMapUv:je&&y(b.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&y(b.sheenRoughnessMap.channel),specularMapUv:qe&&y(b.specularMap.channel),specularColorMapUv:ot&&y(b.specularColorMap.channel),specularIntensityMapUv:pt&&y(b.specularIntensityMap.channel),transmissionMapUv:He&&y(b.transmissionMap.channel),thicknessMapUv:ie&&y(b.thicknessMap.channel),alphaMapUv:Pe&&y(b.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(bt||se),vertexNormals:!!O.attributes.normal,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!O.attributes.uv&&(ut||Pe),fog:!!M,useFog:b.fog===!0,fogExp2:!!M&&M.isFogExp2,flatShading:b.wireframe===!1&&(b.flatShading===!0||O.attributes.normal===void 0&&bt===!1&&(b.isMeshLambertMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isMeshPhysicalMaterial)),sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:_e,skinning:Y.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ne,morphTextureStride:Te,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:E.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&z.length>0,shadowMapType:n.shadowMap.type,toneMapping:Rt,decodeVideoTexture:ut&&b.map.isVideoTexture===!0&&Ln.getTransfer(b.map.colorSpace)===Jn,decodeVideoTextureEmissive:ln&&b.emissiveMap.isVideoTexture===!0&&Ln.getTransfer(b.emissiveMap.colorSpace)===Jn,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Ir,flipSided:b.side===pr,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Be&&b.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Be&&b.extensions.multiDraw===!0||$e)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return vt.vertexUv1s=u.has(1),vt.vertexUv2s=u.has(2),vt.vertexUv3s=u.has(3),u.clear(),vt}function g(b){let I=[];if(b.shaderID?I.push(b.shaderID):(I.push(b.customVertexShaderID),I.push(b.customFragmentShaderID)),b.defines!==void 0)for(let z in b.defines)I.push(z),I.push(b.defines[z]);return b.isRawShaderMaterial===!1&&(m(I,b),L(I,b),I.push(n.outputColorSpace)),I.push(b.customProgramCacheKey),I.join()}function m(b,I){b.push(I.precision),b.push(I.outputColorSpace),b.push(I.envMapMode),b.push(I.envMapCubeUVHeight),b.push(I.mapUv),b.push(I.alphaMapUv),b.push(I.lightMapUv),b.push(I.aoMapUv),b.push(I.bumpMapUv),b.push(I.normalMapUv),b.push(I.displacementMapUv),b.push(I.emissiveMapUv),b.push(I.metalnessMapUv),b.push(I.roughnessMapUv),b.push(I.anisotropyMapUv),b.push(I.clearcoatMapUv),b.push(I.clearcoatNormalMapUv),b.push(I.clearcoatRoughnessMapUv),b.push(I.iridescenceMapUv),b.push(I.iridescenceThicknessMapUv),b.push(I.sheenColorMapUv),b.push(I.sheenRoughnessMapUv),b.push(I.specularMapUv),b.push(I.specularColorMapUv),b.push(I.specularIntensityMapUv),b.push(I.transmissionMapUv),b.push(I.thicknessMapUv),b.push(I.combine),b.push(I.fogExp2),b.push(I.sizeAttenuation),b.push(I.morphTargetsCount),b.push(I.morphAttributeCount),b.push(I.numSunLights),b.push(I.numDirLights),b.push(I.numPointLights),b.push(I.numSpotLights),b.push(I.numSpotLightMaps),b.push(I.numHemiLights),b.push(I.numRectAreaLights),b.push(I.numSunLightShadows),b.push(I.numDirLightShadows),b.push(I.numPointLightShadows),b.push(I.numSpotLightShadows),b.push(I.numSpotLightShadowsWithMaps),b.push(I.numLightProbes),b.push(I.shadowMapType),b.push(I.toneMapping),b.push(I.numClippingPlanes),b.push(I.numClipIntersection),b.push(I.depthPacking)}function L(b,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),b.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),b.push(s.mask)}function F(b){let I=v[b.type],z;if(I){let U=Ca[I];z=E0.clone(U.uniforms)}else z=b.uniforms;return z}function _(b,I){let z=d.get(I);return z!==void 0?++z.usedTimes:(z=new KS(n,I,b,r),l.push(z),d.set(I,z)),z}function p(b){if(--b.usedTimes===0){let I=l.indexOf(b);l[I]=l[l.length-1],l.pop(),d.delete(b.cacheKey),b.destroy()}}function S(b){o.remove(b)}function B(){o.dispose()}return{getParameters:T,getProgramCacheKey:g,getUniforms:F,acquireProgram:_,releaseProgram:p,releaseShaderCache:S,programs:l,dispose:B}}function tb(){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 nb(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 Y0(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 q0(){let n=[],e=0,t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(h){let v=0;return h.isInstancedMesh&&(v+=2),h.isSkinnedMesh&&(v+=1),v}function o(h,v,y,T,g,m){let L=n[e];return L===void 0?(L={id:h.id,object:h,geometry:v,material:y,materialVariant:s(h),groupOrder:T,renderOrder:h.renderOrder,z:g,group:m},n[e]=L):(L.id=h.id,L.object=h,L.geometry=v,L.material=y,L.materialVariant=s(h),L.groupOrder=T,L.renderOrder=h.renderOrder,L.z=g,L.group=m),e++,L}function u(h,v,y,T,g,m,L){L.reversedDepth===!0&&(g=-g);let F=o(h,v,y,T,g,m);y.transmission>0?i.push(F):y.transparent===!0?r.push(F):t.push(F)}function l(h,v,y,T,g,m){let L=o(h,v,y,T,g,m);y.transmission>0?i.unshift(L):y.transparent===!0?r.unshift(L):t.unshift(L)}function d(h,v){t.length>1&&t.sort(h||nb),i.length>1&&i.sort(v||Y0),r.length>1&&r.sort(v||Y0)}function f(){for(let h=e,v=n.length;h<v;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 ib(){let n=new WeakMap;function e(i,r){let a=n.get(i),s;return a===void 0?(s=new q0,n.set(i,[s])):r>=a.length?(s=new q0,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function rb(){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 vn};break;case"SpotLight":t={position:new ge,direction:new ge,color:new vn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ge,color:new vn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ge,skyColor:new vn,groundColor:new vn};break;case"RectAreaLight":t={color:new vn,position:new ge,halfWidth:new ge,halfHeight:new ge};break}return n[e.id]=t,t}}}function ab(){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 kt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var sb=0;function ob(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function lb(n){let e=new rb,t=ab(),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 $n,s=new $n;function o(l){let d=0,f=0,h=0;for(let Y=0;Y<9;Y++)i.probe[Y].set(0,0,0);let v=0,y=0,T=0,g=0,m=0,L=0,F=0,_=0,p=0,S=0,B=0,b=0,I=0,z=0;l.sort(ob);for(let Y=0,E=l.length;Y<E;Y++){let M=l[Y],O=M.color,H=M.intensity,ee=M.distance,j=null;if(M.shadow&&M.shadow.map&&(M.shadow.map.texture.format===xs?j=M.shadow.map.texture:j=M.shadow.map.depthTexture||M.shadow.map.texture),M.isAmbientLight)d+=O.r*H,f+=O.g*H,h+=O.b*H;else if(M.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(M.sh.coefficients[K],H);z++}else if(M.isSunLight){let K=e.get(M);if(K.color.copy(M.color).multiplyScalar(M.intensity),M.castShadow){let re=M.shadow,J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize.copy(re.mapSize).multiply(re.getFrameExtents()),i.sunShadow[y]=J,i.sunShadowMap[y]=j;let ne=re.getViewportCount();for(let Te=0;Te<ne;Te++)i.sunShadowMatrix[T+Te]=re.getMatrix(Te),i.sunShadowCascade[T+Te]=re._cascadeData[Te];T+=ne,y++}i.sun[v]=K,v++}else if(M.isDirectionalLight){let K=e.get(M);if(K.color.copy(M.color).multiplyScalar(M.intensity),M.castShadow){let re=M.shadow,J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize=re.mapSize,i.directionalShadow[g]=J,i.directionalShadowMap[g]=j,i.directionalShadowMatrix[g]=M.shadow.matrix,p++}i.directional[g]=K,g++}else if(M.isSpotLight){let K=e.get(M);K.position.setFromMatrixPosition(M.matrixWorld),K.color.copy(O).multiplyScalar(H),K.distance=ee,K.coneCos=Math.cos(M.angle),K.penumbraCos=Math.cos(M.angle*(1-M.penumbra)),K.decay=M.decay,i.spot[L]=K;let re=M.shadow;if(M.map&&(i.spotLightMap[b]=M.map,b++,re.updateMatrices(M),M.castShadow&&I++),i.spotLightMatrix[L]=re.matrix,M.castShadow){let J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize=re.mapSize,i.spotShadow[L]=J,i.spotShadowMap[L]=j,B++}L++}else if(M.isRectAreaLight){let K=e.get(M);K.color.copy(O).multiplyScalar(H),K.halfWidth.set(M.width*.5,0,0),K.halfHeight.set(0,M.height*.5,0),i.rectArea[F]=K,F++}else if(M.isPointLight){let K=e.get(M);if(K.color.copy(M.color).multiplyScalar(M.intensity),K.distance=M.distance,K.decay=M.decay,M.castShadow){let re=M.shadow,J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize=re.mapSize,J.shadowCameraNear=re.camera.near,J.shadowCameraFar=re.camera.far,i.pointShadow[m]=J,i.pointShadowMap[m]=j,i.pointShadowMatrix[m]=M.shadow.matrix,S++}i.point[m]=K,m++}else if(M.isHemisphereLight){let K=e.get(M);K.skyColor.copy(M.color).multiplyScalar(H),K.groundColor.copy(M.groundColor).multiplyScalar(H),i.hemi[_]=K,_++}}F>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=At.LTC_FLOAT_1,i.rectAreaLTC2=At.LTC_FLOAT_2):(i.rectAreaLTC1=At.LTC_HALF_1,i.rectAreaLTC2=At.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=h;let U=i.hash;(U.sunLength!==v||U.directionalLength!==g||U.pointLength!==m||U.spotLength!==L||U.rectAreaLength!==F||U.hemiLength!==_||U.numSunShadows!==y||U.numDirectionalShadows!==p||U.numPointShadows!==S||U.numSpotShadows!==B||U.numSpotMaps!==b||U.numLightProbes!==z)&&(i.sun.length=v,i.directional.length=g,i.spot.length=L,i.rectArea.length=F,i.point.length=m,i.hemi.length=_,i.sunShadow.length=y,i.sunShadowMap.length=y,i.sunShadowMatrix.length=T,i.sunShadowCascade.length=T,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.directionalShadowMatrix.length=p,i.pointShadow.length=S,i.pointShadowMap.length=S,i.pointShadowMatrix.length=S,i.spotShadow.length=B,i.spotShadowMap.length=B,i.spotLightMatrix.length=B+b-I,i.spotLightMap.length=b,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=z,U.sunLength=v,U.directionalLength=g,U.pointLength=m,U.spotLength=L,U.rectAreaLength=F,U.hemiLength=_,U.numSunShadows=y,U.numDirectionalShadows=p,U.numPointShadows=S,U.numSpotShadows=B,U.numSpotMaps=b,U.numLightProbes=z,i.version=sb++)}function u(l,d){let f=0,h=0,v=0,y=0,T=0,g=0,m=d.matrixWorldInverse;for(let L=0,F=l.length;L<F;L++){let _=l[L];if(_.isSunLight){let p=i.sun[f];p.direction.setFromMatrixPosition(_.matrixWorld),p.direction.transformDirection(m),f++}else if(_.isDirectionalLight){let p=i.directional[h];p.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),p.direction.sub(r),p.direction.transformDirection(m),h++}else if(_.isSpotLight){let p=i.spot[y];p.position.setFromMatrixPosition(_.matrixWorld),p.position.applyMatrix4(m),p.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),p.direction.sub(r),p.direction.transformDirection(m),y++}else if(_.isRectAreaLight){let p=i.rectArea[T];p.position.setFromMatrixPosition(_.matrixWorld),p.position.applyMatrix4(m),s.identity(),a.copy(_.matrixWorld),a.premultiply(m),s.extractRotation(a),p.halfWidth.set(_.width*.5,0,0),p.halfHeight.set(0,_.height*.5,0),p.halfWidth.applyMatrix4(s),p.halfHeight.applyMatrix4(s),T++}else if(_.isPointLight){let p=i.point[v];p.position.setFromMatrixPosition(_.matrixWorld),p.position.applyMatrix4(m),v++}else if(_.isHemisphereLight){let p=i.hemi[g];p.direction.setFromMatrixPosition(_.matrixWorld),p.direction.transformDirection(m),g++}}}return{setup:o,setupView:u,state:i}}function Z0(n){let e=new lb(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 cb(n){let e=new WeakMap;function t(r,a=0){let s=e.get(r),o;return s===void 0?(o=new Z0(n),e.set(r,[o])):a>=s.length?(o=new Z0(n),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:t,dispose:i}}var ub=`void main() {
|
|
4167
|
+
Program Info Log: `+H+`
|
|
4168
|
+
`+ne+`
|
|
4169
|
+
`+X)}else H!==""?xn("WebGLProgram: Program Info Log:",H):(Y===""||oe==="")&&(k=!1);k&&(F.diagnostics={runnable:O,programLog:H,vertexShader:{log:Y,prefix:v},fragmentShader:{log:oe,prefix:m}})}r.deleteShader(g),r.deleteShader(b),T=new yl(r,M),D=Pb(r,M)}let T;this.getUniforms=function(){return T===void 0&&z(this),T};let D;this.getAttributes=function(){return D===void 0&&z(this),D};let G=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return G===!1&&(G=r.getProgramParameter(M,Mb)),G},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(M),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Sb++,this.cacheKey=e,this.usedTimes=1,this.program=M,this.vertexShader=g,this.fragmentShader=b,this}var qb=0,Lp=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 Dp(e),t.set(e,i)),i}},Dp=class{constructor(e){this.id=qb++,this.code=e,this.usedTimes=0}};function Zb(n){return n===Us||n===Dc||n===Nc}function Jb(n,e,t,i,r,a){let s=new Ko,o=new Lp,u=new Set,l=[],d=new Map,f=i.logarithmicDepthBuffer,h=i.precision,p={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(T){return u.add(T),T===0?"uv":`uv${T}`}function M(T,D,G,F,$,A){let S=F.fog,H=$.geometry,Y=T.isMeshStandardMaterial||T.isMeshLambertMaterial||T.isMeshPhongMaterial?F.environment:null,oe=T.isMeshStandardMaterial||T.isMeshLambertMaterial&&!T.envMap||T.isMeshPhongMaterial&&!T.envMap,O=e.get(T.envMap||Y,oe),k=O&&O.mapping===Ic?O.image.height:null,ne=p[T.type];T.precision!==null&&(h=i.getMaxPrecision(T.precision),h!==T.precision&&xn("WebGLProgram.getParameters:",T.precision,"not supported, using",h,"instead."));let X=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,K=X!==void 0?X.length:0,ge=0;H.morphAttributes.position!==void 0&&(ge=1),H.morphAttributes.normal!==void 0&&(ge=2),H.morphAttributes.color!==void 0&&(ge=3);let se,Se,Pe,le;if(ne){let xt=$a[ne];se=xt.vertexShader,Se=xt.fragmentShader}else{se=T.vertexShader,Se=T.fragmentShader;let xt=o.getVertexShaderStage(T),kt=o.getFragmentShaderStage(T);o.update(T,xt,kt),Pe=xt.id,le=kt.id}let ae=n.getRenderTarget(),fe=n.state.buffers.depth.getReversed(),Ne=$.isInstancedMesh===!0,Re=$.isBatchedMesh===!0,We=!!T.map,Qe=!!T.matcap,ke=!!O,qe=!!T.aoMap,ft=!!T.lightMap,tt=!!T.bumpMap&&T.wireframe===!1,st=!!T.normalMap,Ke=!!T.displacementMap,en=!!T.emissiveMap,nt=!!T.metalnessMap,on=!!T.roughnessMap,ue=T.anisotropy>0,hn=T.clearcoat>0,gn=T.dispersion>0,J=T.retroreflectivity>0,w=T.iridescence>0,ie=T.sheen>0,ye=T.transmission>0,Ae=ue&&!!T.anisotropyMap,Xe=hn&&!!T.clearcoatMap,Je=hn&&!!T.clearcoatNormalMap,Te=hn&&!!T.clearcoatRoughnessMap,Ie=w&&!!T.iridescenceMap,ot=w&&!!T.iridescenceThicknessMap,yt=ie&&!!T.sheenColorMap,ht=ie&&!!T.sheenRoughnessMap,rt=!!T.specularMap,Lt=!!T.specularColorMap,Bt=!!T.specularIntensityMap,qt=ye&&!!T.transmissionMap,te=ye&&!!T.thicknessMap,at=!!T.gradientMap,Ce=!!T.alphaMap,pt=T.alphaTest>0,lt=!!T.alphaHash,He=!!T.extensions,Zt=Wr;T.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(Zt=n.toneMapping);let It={shaderID:ne,shaderType:T.type,shaderName:T.name,vertexShader:se,fragmentShader:Se,defines:T.defines,customVertexShaderID:Pe,customFragmentShaderID:le,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:h,batching:Re,batchingColor:Re&&$._colorsTexture!==null,instancing:Ne,instancingColor:Ne&&$.instanceColor!==null,instancingMorph:Ne&&$.morphTexture!==null,outputColorSpace:ae===null?n.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:ni.workingColorSpace,alphaToCoverage:!!T.alphaToCoverage,map:We,matcap:Qe,envMap:ke,envMapMode:ke&&O.mapping,envMapCubeUVHeight:k,aoMap:qe,lightMap:ft,bumpMap:tt,normalMap:st,displacementMap:Ke,emissiveMap:en,normalMapObjectSpace:st&&T.normalMapType===Qv,normalMapTangentSpace:st&&T.normalMapType===Uc,packedNormalMap:st&&T.normalMapType===Uc&&Zb(T.normalMap.format),metalnessMap:nt,roughnessMap:on,anisotropy:ue,anisotropyMap:Ae,clearcoat:hn,clearcoatMap:Xe,clearcoatNormalMap:Je,clearcoatRoughnessMap:Te,dispersion:gn,retroreflection:J,iridescence:w,iridescenceMap:Ie,iridescenceThicknessMap:ot,sheen:ie,sheenColorMap:yt,sheenRoughnessMap:ht,specularMap:rt,specularColorMap:Lt,specularIntensityMap:Bt,transmission:ye,transmissionMap:qt,thicknessMap:te,gradientMap:at,opaque:T.transparent===!1&&T.blending===dl&&T.alphaToCoverage===!1,alphaMap:Ce,alphaTest:pt,alphaHash:lt,combine:T.combine,mapUv:We&&y(T.map.channel),aoMapUv:qe&&y(T.aoMap.channel),lightMapUv:ft&&y(T.lightMap.channel),bumpMapUv:tt&&y(T.bumpMap.channel),normalMapUv:st&&y(T.normalMap.channel),displacementMapUv:Ke&&y(T.displacementMap.channel),emissiveMapUv:en&&y(T.emissiveMap.channel),metalnessMapUv:nt&&y(T.metalnessMap.channel),roughnessMapUv:on&&y(T.roughnessMap.channel),anisotropyMapUv:Ae&&y(T.anisotropyMap.channel),clearcoatMapUv:Xe&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:Je&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Ie&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:ot&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:yt&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:ht&&y(T.sheenRoughnessMap.channel),specularMapUv:rt&&y(T.specularMap.channel),specularColorMapUv:Lt&&y(T.specularColorMap.channel),specularIntensityMapUv:Bt&&y(T.specularIntensityMap.channel),transmissionMapUv:qt&&y(T.transmissionMap.channel),thicknessMapUv:te&&y(T.thicknessMap.channel),alphaMapUv:Ce&&y(T.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(st||ue),vertexNormals:!!H.attributes.normal,vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!H.attributes.uv&&(We||Ce),fog:!!S,useFog:T.fog===!0,fogExp2:!!S&&S.isFogExp2,flatShading:T.wireframe===!1&&(T.flatShading===!0||H.attributes.normal===void 0&&st===!1&&(T.isMeshLambertMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isMeshPhysicalMaterial)),sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:fe,skinning:$.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:K,morphTextureStride:ge,numSunLights:D.sun.length,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numSunLightShadows:D.sunShadowMap.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numLightProbeGrids:A.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:T.dithering,shadowMapEnabled:n.shadowMap.enabled&&G.length>0,shadowMapType:n.shadowMap.type,toneMapping:Zt,decodeVideoTexture:We&&T.map.isVideoTexture===!0&&ni.getTransfer(T.map.colorSpace)===_i,decodeVideoTextureEmissive:en&&T.emissiveMap.isVideoTexture===!0&&ni.getTransfer(T.emissiveMap.colorSpace)===_i,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Ir,flipSided:T.side===Fr,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:He&&T.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(He&&T.extensions.multiDraw===!0||Re)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return It.vertexUv1s=u.has(1),It.vertexUv2s=u.has(2),It.vertexUv3s=u.has(3),u.clear(),It}function v(T){let D=[];if(T.shaderID?D.push(T.shaderID):(D.push(T.customVertexShaderID),D.push(T.customFragmentShaderID)),T.defines!==void 0)for(let G in T.defines)D.push(G),D.push(T.defines[G]);return T.isRawShaderMaterial===!1&&(m(D,T),N(D,T),D.push(n.outputColorSpace)),D.push(T.customProgramCacheKey),D.join()}function m(T,D){T.push(D.precision),T.push(D.outputColorSpace),T.push(D.envMapMode),T.push(D.envMapCubeUVHeight),T.push(D.mapUv),T.push(D.alphaMapUv),T.push(D.lightMapUv),T.push(D.aoMapUv),T.push(D.bumpMapUv),T.push(D.normalMapUv),T.push(D.displacementMapUv),T.push(D.emissiveMapUv),T.push(D.metalnessMapUv),T.push(D.roughnessMapUv),T.push(D.anisotropyMapUv),T.push(D.clearcoatMapUv),T.push(D.clearcoatNormalMapUv),T.push(D.clearcoatRoughnessMapUv),T.push(D.iridescenceMapUv),T.push(D.iridescenceThicknessMapUv),T.push(D.sheenColorMapUv),T.push(D.sheenRoughnessMapUv),T.push(D.specularMapUv),T.push(D.specularColorMapUv),T.push(D.specularIntensityMapUv),T.push(D.transmissionMapUv),T.push(D.thicknessMapUv),T.push(D.combine),T.push(D.fogExp2),T.push(D.sizeAttenuation),T.push(D.morphTargetsCount),T.push(D.morphAttributeCount),T.push(D.numSunLights),T.push(D.numDirLights),T.push(D.numPointLights),T.push(D.numSpotLights),T.push(D.numSpotLightMaps),T.push(D.numHemiLights),T.push(D.numRectAreaLights),T.push(D.numSunLightShadows),T.push(D.numDirLightShadows),T.push(D.numPointLightShadows),T.push(D.numSpotLightShadows),T.push(D.numSpotLightShadowsWithMaps),T.push(D.numLightProbes),T.push(D.shadowMapType),T.push(D.toneMapping),T.push(D.numClippingPlanes),T.push(D.numClipIntersection),T.push(D.depthPacking)}function N(T,D){s.disableAll(),D.instancing&&s.enable(0),D.instancingColor&&s.enable(1),D.instancingMorph&&s.enable(2),D.matcap&&s.enable(3),D.envMap&&s.enable(4),D.normalMapObjectSpace&&s.enable(5),D.normalMapTangentSpace&&s.enable(6),D.clearcoat&&s.enable(7),D.iridescence&&s.enable(8),D.alphaTest&&s.enable(9),D.vertexColors&&s.enable(10),D.vertexAlphas&&s.enable(11),D.vertexUv1s&&s.enable(12),D.vertexUv2s&&s.enable(13),D.vertexUv3s&&s.enable(14),D.vertexTangents&&s.enable(15),D.anisotropy&&s.enable(16),D.alphaHash&&s.enable(17),D.batching&&s.enable(18),D.dispersion&&s.enable(19),D.retroreflection&&s.enable(24),D.batchingColor&&s.enable(20),D.gradientMap&&s.enable(21),D.packedNormalMap&&s.enable(22),D.vertexNormals&&s.enable(23),T.push(s.mask),s.disableAll(),D.fog&&s.enable(0),D.useFog&&s.enable(1),D.flatShading&&s.enable(2),D.logarithmicDepthBuffer&&s.enable(3),D.reversedDepthBuffer&&s.enable(4),D.skinning&&s.enable(5),D.morphTargets&&s.enable(6),D.morphNormals&&s.enable(7),D.morphColors&&s.enable(8),D.premultipliedAlpha&&s.enable(9),D.shadowMapEnabled&&s.enable(10),D.doubleSided&&s.enable(11),D.flipSided&&s.enable(12),D.useDepthPacking&&s.enable(13),D.dithering&&s.enable(14),D.transmission&&s.enable(15),D.sheen&&s.enable(16),D.opaque&&s.enable(17),D.pointsUvs&&s.enable(18),D.decodeVideoTexture&&s.enable(19),D.decodeVideoTextureEmissive&&s.enable(20),D.alphaToCoverage&&s.enable(21),D.numLightProbeGrids>0&&s.enable(22),D.hasPositionAttribute&&s.enable(23),T.push(s.mask)}function P(T){let D=p[T.type],G;if(D){let F=$a[D];G=v0.clone(F.uniforms)}else G=T.uniforms;return G}function _(T,D){let G=d.get(D);return G!==void 0?++G.usedTimes:(G=new Yb(n,D,T,r),l.push(G),d.set(D,G)),G}function g(T){if(--T.usedTimes===0){let D=l.indexOf(T);l[D]=l[l.length-1],l.pop(),d.delete(T.cacheKey),T.destroy()}}function b(T){o.remove(T)}function z(){o.dispose()}return{getParameters:M,getProgramCacheKey:v,getUniforms:P,acquireProgram:_,releaseProgram:g,releaseShaderCache:b,programs:l,dispose:z}}function $b(){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 Kb(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 F0(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 O0(){let n=[],e=0,t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(h){let p=0;return h.isInstancedMesh&&(p+=2),h.isSkinnedMesh&&(p+=1),p}function o(h,p,y,M,v,m){let N=n[e];return N===void 0?(N={id:h.id,object:h,geometry:p,material:y,materialVariant:s(h),groupOrder:M,renderOrder:h.renderOrder,z:v,group:m},n[e]=N):(N.id=h.id,N.object=h,N.geometry=p,N.material=y,N.materialVariant=s(h),N.groupOrder=M,N.renderOrder=h.renderOrder,N.z=v,N.group=m),e++,N}function u(h,p,y,M,v,m,N){N.reversedDepth===!0&&(v=-v);let P=o(h,p,y,M,v,m);y.transmission>0?i.push(P):y.transparent===!0?r.push(P):t.push(P)}function l(h,p,y,M,v,m){let N=o(h,p,y,M,v,m);y.transmission>0?i.unshift(N):y.transparent===!0?r.unshift(N):t.unshift(N)}function d(h,p){t.length>1&&t.sort(h||Kb),i.length>1&&i.sort(p||F0),r.length>1&&r.sort(p||F0)}function f(){for(let h=e,p=n.length;h<p;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 O0,n.set(i,[s])):r>=a.length?(s=new O0,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose: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={direction:new _e,color:new Cn};break;case"SpotLight":t={position:new _e,direction:new _e,color:new Cn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new _e,color:new Cn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new _e,skyColor:new Cn,groundColor:new Cn};break;case"RectAreaLight":t={color:new Cn,position:new _e,halfWidth:new _e,halfHeight:new _e};break}return n[e.id]=t,t}}}function ew(){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 Kt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var tw=0;function nw(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function iw(n){let e=new jb,t=ew(),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 _e);let r=new _e,a=new Dn,s=new Dn;function o(l){let d=0,f=0,h=0;for(let $=0;$<9;$++)i.probe[$].set(0,0,0);let p=0,y=0,M=0,v=0,m=0,N=0,P=0,_=0,g=0,b=0,z=0,T=0,D=0,G=0;l.sort(nw);for(let $=0,A=l.length;$<A;$++){let S=l[$],H=S.color,Y=S.intensity,oe=S.distance,O=null;if(S.shadow&&S.shadow.map&&(S.shadow.map.texture.format===Us?O=S.shadow.map.texture:O=S.shadow.map.depthTexture||S.shadow.map.texture),S.isAmbientLight)d+=H.r*Y,f+=H.g*Y,h+=H.b*Y;else if(S.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(S.sh.coefficients[k],Y);G++}else if(S.isSunLight){let k=e.get(S);if(k.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let ne=S.shadow,X=t.get(S);X.shadowIntensity=ne.intensity,X.shadowBias=ne.bias,X.shadowNormalBias=ne.normalBias,X.shadowRadius=ne.radius,X.shadowMapSize.copy(ne.mapSize).multiply(ne.getFrameExtents()),i.sunShadow[y]=X,i.sunShadowMap[y]=O;let K=ne.getViewportCount();for(let ge=0;ge<K;ge++)i.sunShadowMatrix[M+ge]=ne.getMatrix(ge),i.sunShadowCascade[M+ge]=ne._cascadeData[ge];M+=K,y++}i.sun[p]=k,p++}else if(S.isDirectionalLight){let k=e.get(S);if(k.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let ne=S.shadow,X=t.get(S);X.shadowIntensity=ne.intensity,X.shadowBias=ne.bias,X.shadowNormalBias=ne.normalBias,X.shadowRadius=ne.radius,X.shadowMapSize=ne.mapSize,i.directionalShadow[v]=X,i.directionalShadowMap[v]=O,i.directionalShadowMatrix[v]=S.shadow.matrix,g++}i.directional[v]=k,v++}else if(S.isSpotLight){let k=e.get(S);k.position.setFromMatrixPosition(S.matrixWorld),k.color.copy(H).multiplyScalar(Y),k.distance=oe,k.coneCos=Math.cos(S.angle),k.penumbraCos=Math.cos(S.angle*(1-S.penumbra)),k.decay=S.decay,i.spot[N]=k;let ne=S.shadow;if(S.map&&(i.spotLightMap[T]=S.map,T++,ne.updateMatrices(S),S.castShadow&&D++),i.spotLightMatrix[N]=ne.matrix,S.castShadow){let X=t.get(S);X.shadowIntensity=ne.intensity,X.shadowBias=ne.bias,X.shadowNormalBias=ne.normalBias,X.shadowRadius=ne.radius,X.shadowMapSize=ne.mapSize,i.spotShadow[N]=X,i.spotShadowMap[N]=O,z++}N++}else if(S.isRectAreaLight){let k=e.get(S);k.color.copy(H).multiplyScalar(Y),k.halfWidth.set(S.width*.5,0,0),k.halfHeight.set(0,S.height*.5,0),i.rectArea[P]=k,P++}else if(S.isPointLight){let k=e.get(S);if(k.color.copy(S.color).multiplyScalar(S.intensity),k.distance=S.distance,k.decay=S.decay,S.castShadow){let ne=S.shadow,X=t.get(S);X.shadowIntensity=ne.intensity,X.shadowBias=ne.bias,X.shadowNormalBias=ne.normalBias,X.shadowRadius=ne.radius,X.shadowMapSize=ne.mapSize,X.shadowCameraNear=ne.camera.near,X.shadowCameraFar=ne.camera.far,i.pointShadow[m]=X,i.pointShadowMap[m]=O,i.pointShadowMatrix[m]=S.shadow.matrix,b++}i.point[m]=k,m++}else if(S.isHemisphereLight){let k=e.get(S);k.skyColor.copy(S.color).multiplyScalar(Y),k.groundColor.copy(S.groundColor).multiplyScalar(Y),i.hemi[_]=k,_++}}P>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Vt.LTC_FLOAT_1,i.rectAreaLTC2=Vt.LTC_FLOAT_2):(i.rectAreaLTC1=Vt.LTC_HALF_1,i.rectAreaLTC2=Vt.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=h;let F=i.hash;(F.sunLength!==p||F.directionalLength!==v||F.pointLength!==m||F.spotLength!==N||F.rectAreaLength!==P||F.hemiLength!==_||F.numSunShadows!==y||F.numDirectionalShadows!==g||F.numPointShadows!==b||F.numSpotShadows!==z||F.numSpotMaps!==T||F.numLightProbes!==G)&&(i.sun.length=p,i.directional.length=v,i.spot.length=N,i.rectArea.length=P,i.point.length=m,i.hemi.length=_,i.sunShadow.length=y,i.sunShadowMap.length=y,i.sunShadowMatrix.length=M,i.sunShadowCascade.length=M,i.directionalShadow.length=g,i.directionalShadowMap.length=g,i.directionalShadowMatrix.length=g,i.pointShadow.length=b,i.pointShadowMap.length=b,i.pointShadowMatrix.length=b,i.spotShadow.length=z,i.spotShadowMap.length=z,i.spotLightMatrix.length=z+T-D,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=G,F.sunLength=p,F.directionalLength=v,F.pointLength=m,F.spotLength=N,F.rectAreaLength=P,F.hemiLength=_,F.numSunShadows=y,F.numDirectionalShadows=g,F.numPointShadows=b,F.numSpotShadows=z,F.numSpotMaps=T,F.numLightProbes=G,i.version=tw++)}function u(l,d){let f=0,h=0,p=0,y=0,M=0,v=0,m=d.matrixWorldInverse;for(let N=0,P=l.length;N<P;N++){let _=l[N];if(_.isSunLight){let g=i.sun[f];g.direction.setFromMatrixPosition(_.matrixWorld),g.direction.transformDirection(m),f++}else if(_.isDirectionalLight){let g=i.directional[h];g.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),g.direction.sub(r),g.direction.transformDirection(m),h++}else if(_.isSpotLight){let g=i.spot[y];g.position.setFromMatrixPosition(_.matrixWorld),g.position.applyMatrix4(m),g.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),g.direction.sub(r),g.direction.transformDirection(m),y++}else if(_.isRectAreaLight){let g=i.rectArea[M];g.position.setFromMatrixPosition(_.matrixWorld),g.position.applyMatrix4(m),s.identity(),a.copy(_.matrixWorld),a.premultiply(m),s.extractRotation(a),g.halfWidth.set(_.width*.5,0,0),g.halfHeight.set(0,_.height*.5,0),g.halfWidth.applyMatrix4(s),g.halfHeight.applyMatrix4(s),M++}else if(_.isPointLight){let g=i.point[p];g.position.setFromMatrixPosition(_.matrixWorld),g.position.applyMatrix4(m),p++}else if(_.isHemisphereLight){let g=i.hemi[v];g.direction.setFromMatrixPosition(_.matrixWorld),g.direction.transformDirection(m),v++}}}return{setup:o,setupView:u,state:i}}function B0(n){let e=new iw(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 rw(n){let e=new WeakMap;function t(r,a=0){let s=e.get(r),o;return s===void 0?(o=new B0(n),e.set(r,[o])):a>=s.length?(o=new B0(n),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:t,dispose:i}}var aw=`void main() {
|
|
4170
4170
|
gl_Position = vec4( position, 1.0 );
|
|
4171
|
-
}`,
|
|
4171
|
+
}`,sw=`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
|
-
}`,fb=[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)],hb=[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)],J0=new $n,Jl=new ge,Fh=new ge;function pb(n,e,t){let i=new xo,r=new kt,a=new kt,s=new fi,o=new gu,u=new yu,l={},d=t.maxTextureSize,f={[ms]:pr,[pr]:ms,[Ir]:Ir},h=new kr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new kt},radius:{value:4}},vertexShader:ub,fragmentShader:db}),v=h.clone();v.defines.HORIZONTAL_PASS=1;let y=new Wi;y.setAttribute("position",new Fr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let T=new jn(y,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kl;let m=this.type;this.render=function(S,B,b){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;this.type===Du&&(rn("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=kl);let I=n.getRenderTarget(),z=n.getActiveCubeFace(),U=n.getActiveMipmapLevel(),Y=n.state;Y.setBlending(Aa),Y.buffers.depth.getReversed()===!0?Y.buffers.color.setClear(0,0,0,0):Y.buffers.color.setClear(1,1,1,1),Y.buffers.depth.setTest(!0),Y.setScissorTest(!1);let E=m!==this.type;E&&B.traverse(function(M){M.material&&(Array.isArray(M.material)?M.material.forEach(O=>O.needsUpdate=!0):M.material.needsUpdate=!0)});for(let M=0,O=S.length;M<O;M++){let H=S[M],ee=H.shadow;if(ee===void 0){rn("WebGLShadowMap:",H,"has no shadow.");continue}if(ee.autoUpdate===!1&&ee.needsUpdate===!1)continue;r.copy(ee.mapSize);let j=ee.getFrameExtents();r.multiply(j),a.copy(ee.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/j.x),r.x=a.x*j.x,ee.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/j.y),r.y=a.y*j.y,ee.mapSize.y=a.y));let K=n.state.buffers.depth.getReversed();if(ee.camera._reversedDepth=K,ee.map===null||E===!0){if(ee.map!==null&&(ee.map.depthTexture!==null&&(ee.map.depthTexture.dispose(),ee.map.depthTexture=null),ee.map.dispose()),this.type===Eo){if(H.isPointLight){rn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}ee.map=new Ar(r.x,r.y,{format:xs,type:oa,minFilter:Hi,magFilter:Hi,generateMipmaps:!1}),ee.map.texture.name=H.name+".shadowMap",ee.map.depthTexture=new us(r.x,r.y,Yr),ee.map.depthTexture.name=H.name+".shadowMapDepth",ee.map.depthTexture.format=Ma,ee.map.depthTexture.compareFunction=null,ee.map.depthTexture.minFilter=Bi,ee.map.depthTexture.magFilter=Bi}else H.isPointLight?(ee.map=new Ad(r.x),ee.map.depthTexture=new cu(r.x,sa)):(ee.map=new Ar(r.x,r.y),ee.map.depthTexture=new us(r.x,r.y,sa)),ee.map.depthTexture.name=H.name+".shadowMap",ee.map.depthTexture.format=Ma,this.type===kl?(ee.map.depthTexture.compareFunction=K?bd:Sd,ee.map.depthTexture.minFilter=Hi,ee.map.depthTexture.magFilter=Hi):(ee.map.depthTexture.compareFunction=null,ee.map.depthTexture.minFilter=Bi,ee.map.depthTexture.magFilter=Bi);ee.camera.updateProjectionMatrix()}ee.map.isWebGLCubeRenderTarget!==!0&&(ee.map.width!==r.x||ee.map.height!==r.y)&&ee.map.setSize(r.x,r.y);let re=ee.map.isWebGLCubeRenderTarget?6:ee.getViewportCount();H.isPointLight!==!0&&ee.updateMatrices(H,b);for(let J=0;J<re;J++){let ne=ee.getCamera(J);if(H.isPointLight){let Te=ee.camera,fe=ee.matrix,pe=H.distance||Te.far;pe!==Te.far&&(Te.far=pe,Te.updateProjectionMatrix()),Jl.setFromMatrixPosition(H.matrixWorld),Te.position.copy(Jl),Fh.copy(Te.position),Fh.add(fb[J]),Te.up.copy(hb[J]),Te.lookAt(Fh),Te.updateMatrixWorld(),fe.makeTranslation(-Jl.x,-Jl.y,-Jl.z),J0.multiplyMatrices(Te.projectionMatrix,Te.matrixWorldInverse),ee._frustum.setFromProjectionMatrix(J0,Te.coordinateSystem,Te.reversedDepth)}if(ee.map.isWebGLCubeRenderTarget)n.setRenderTarget(ee.map,J),n.clear();else{J===0&&(n.setRenderTarget(ee.map),n.clear());let Te=ee.getViewport(J);s.set(a.x*Te.x,a.y*Te.y,a.x*Te.z,a.y*Te.w),Y.viewport(s)}i=ee.getFrustum(J),_(B,b,ne,H,this.type)}ee.isPointLightShadow!==!0&&this.type===Eo&&L(ee,b),ee.needsUpdate=!1}m=this.type,g.needsUpdate=!1,n.setRenderTarget(I,z,U)};function L(S,B){let b=e.update(T);h.defines.VSM_SAMPLES!==S.blurSamples&&(h.defines.VSM_SAMPLES=S.blurSamples,v.defines.VSM_SAMPLES=S.blurSamples,h.needsUpdate=!0,v.needsUpdate=!0),S.mapPass===null?S.mapPass=new Ar(r.x,r.y,{format:xs,type:oa}):(S.mapPass.width!==S.map.width||S.mapPass.height!==S.map.height)&&S.mapPass.setSize(S.map.width,S.map.height),h.uniforms.shadow_pass.value=S.map.depthTexture,h.uniforms.resolution.value.set(S.map.width,S.map.height),h.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(B,null,b,h,T,null),v.uniforms.shadow_pass.value=S.mapPass.texture,v.uniforms.resolution.value.set(S.map.width,S.map.height),v.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(B,null,b,v,T,null)}function F(S,B,b,I){let z=null,U=b.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(U!==void 0)z=U;else if(z=b.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 Y=z.uuid,E=B.uuid,M=l[Y];M===void 0&&(M={},l[Y]=M);let O=M[E];O===void 0&&(O=z.clone(),M[E]=O,B.addEventListener("dispose",p)),z=O}if(z.visible=B.visible,z.wireframe=B.wireframe,I===Eo?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,b.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let Y=n.properties.get(z);Y.light=b}return z}function _(S,B,b,I,z){if(S.visible===!1)return;if(S.layers.test(B.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&z===Eo)&&(!S.frustumCulled||S.intersectsFrustum(i))){S.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,S.matrixWorld);let E=e.update(S),M=S.material;if(Array.isArray(M)){let O=E.groups;for(let H=0,ee=O.length;H<ee;H++){let j=O[H],K=M[j.materialIndex];if(K&&K.visible){let re=F(S,K,I,z);S.onBeforeShadow(n,S,B,b,E,re,j),n.renderBufferDirect(b,null,E,re,S,j),S.onAfterShadow(n,S,B,b,E,re,j)}}}else if(M.visible){let O=F(S,M,I,z);S.onBeforeShadow(n,S,B,b,E,O,null),n.renderBufferDirect(b,null,E,O,S,null),S.onAfterShadow(n,S,B,b,E,O,null)}}let Y=S.children;for(let E=0,M=Y.length;E<M;E++)_(Y[E],B,b,I,z)}function p(S){S.target.removeEventListener("dispose",p);for(let b in l){let I=l[b],z=S.target.uuid;z in I&&(I[z].dispose(),delete I[z])}}}function mb(n,e){function t(){let ie=!1,Oe=new fi,Pe=null,nt=new fi(0,0,0,0);return{setMask:function(dt){Pe!==dt&&!ie&&(n.colorMask(dt,dt,dt,dt),Pe=dt)},setLocked:function(dt){ie=dt},setClear:function(dt,Be,Rt,vt,cn){cn===!0&&(dt*=vt,Be*=vt,Rt*=vt),Oe.set(dt,Be,Rt,vt),nt.equals(Oe)===!1&&(n.clearColor(dt,Be,Rt,vt),nt.copy(Oe))},reset:function(){ie=!1,Pe=null,nt.set(-1,0,0,0)}}}function i(){let ie=!1,Oe=!1,Pe=null,nt=null,dt=null;return{setReversed:function(Be){if(Oe!==Be){let Rt=e.get("EXT_clip_control");Be?Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.ZERO_TO_ONE_EXT):Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.NEGATIVE_ONE_TO_ONE_EXT),Oe=Be;let vt=dt;dt=null,this.setClear(vt)}},getReversed:function(){return Oe},setTest:function(Be){Be?de(n.DEPTH_TEST):_e(n.DEPTH_TEST)},setMask:function(Be){Pe!==Be&&!ie&&(n.depthMask(Be),Pe=Be)},setFunc:function(Be){if(Oe&&(Be=_0[Be]),nt!==Be){switch(Be){case Jc:n.depthFunc(n.NEVER);break;case $c:n.depthFunc(n.ALWAYS);break;case Kc:n.depthFunc(n.LESS);break;case ho:n.depthFunc(n.LEQUAL);break;case Qc:n.depthFunc(n.EQUAL);break;case jc:n.depthFunc(n.GEQUAL);break;case eu:n.depthFunc(n.GREATER);break;case tu:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}nt=Be}},setLocked:function(Be){ie=Be},setClear:function(Be){dt!==Be&&(dt=Be,Oe&&(Be=1-Be),n.clearDepth(Be))},reset:function(){ie=!1,Pe=null,nt=null,dt=null,Oe=!1}}}function r(){let ie=!1,Oe=null,Pe=null,nt=null,dt=null,Be=null,Rt=null,vt=null,cn=null;return{setTest:function(dn){ie||(dn?de(n.STENCIL_TEST):_e(n.STENCIL_TEST))},setMask:function(dn){Oe!==dn&&!ie&&(n.stencilMask(dn),Oe=dn)},setFunc:function(dn,Fn,Dn){(Pe!==dn||nt!==Fn||dt!==Dn)&&(n.stencilFunc(dn,Fn,Dn),Pe=dn,nt=Fn,dt=Dn)},setOp:function(dn,Fn,Dn){(Be!==dn||Rt!==Fn||vt!==Dn)&&(n.stencilOp(dn,Fn,Dn),Be=dn,Rt=Fn,vt=Dn)},setLocked:function(dn){ie=dn},setClear:function(dn){cn!==dn&&(n.clearStencil(dn),cn=dn)},reset:function(){ie=!1,Oe=null,Pe=null,nt=null,dt=null,Be=null,Rt=null,vt=null,cn=null}}}let a=new t,s=new i,o=new r,u=new WeakMap,l=new WeakMap,d={},f={},h={},v=new WeakMap,y=[],T=null,g=!1,m=null,L=null,F=null,_=null,p=null,S=null,B=null,b=new vn(0,0,0),I=0,z=!1,U=null,Y=null,E=null,M=null,O=null,H=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),ee=!1,j=0,K=n.getParameter(n.VERSION);K.indexOf("WebGL")!==-1?(j=parseFloat(/^WebGL (\d)/.exec(K)[1]),ee=j>=1):K.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),ee=j>=2);let re=null,J={},ne=n.getParameter(n.SCISSOR_BOX),Te=n.getParameter(n.VIEWPORT),fe=new fi().fromArray(ne),pe=new fi().fromArray(Te);function Fe(ie,Oe,Pe,nt){let dt=new Uint8Array(4),Be=n.createTexture();n.bindTexture(ie,Be),n.texParameteri(ie,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(ie,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Rt=0;Rt<Pe;Rt++)ie===n.TEXTURE_3D||ie===n.TEXTURE_2D_ARRAY?n.texImage3D(Oe,0,n.RGBA,1,1,nt,0,n.RGBA,n.UNSIGNED_BYTE,dt):n.texImage2D(Oe+Rt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,dt);return Be}let ae={};ae[n.TEXTURE_2D]=Fe(n.TEXTURE_2D,n.TEXTURE_2D,1),ae[n.TEXTURE_CUBE_MAP]=Fe(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[n.TEXTURE_2D_ARRAY]=Fe(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ae[n.TEXTURE_3D]=Fe(n.TEXTURE_3D,n.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),de(n.DEPTH_TEST),s.setFunc(ho),wt(!1),bt(jf),de(n.CULL_FACE),Tt(Aa);function de(ie){d[ie]!==!0&&(n.enable(ie),d[ie]=!0)}function _e(ie){d[ie]!==!1&&(n.disable(ie),d[ie]=!1)}function Ge(ie,Oe){return h[ie]!==Oe?(n.bindFramebuffer(ie,Oe),h[ie]=Oe,ie===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=Oe),ie===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=Oe),!0):!1}function $e(ie,Oe){let Pe=y,nt=!1;if(ie){Pe=v.get(Oe),Pe===void 0&&(Pe=[],v.set(Oe,Pe));let dt=ie.textures;if(Pe.length!==dt.length||Pe[0]!==n.COLOR_ATTACHMENT0){for(let Be=0,Rt=dt.length;Be<Rt;Be++)Pe[Be]=n.COLOR_ATTACHMENT0+Be;Pe.length=dt.length,nt=!0}}else Pe[0]!==n.BACK&&(Pe[0]=n.BACK,nt=!0);nt&&n.drawBuffers(Pe)}function ut(ie){return T!==ie?(n.useProgram(ie),T=ie,!0):!1}let zt={[Fs]:n.FUNC_ADD,[Vm]:n.FUNC_SUBTRACT,[Gm]:n.FUNC_REVERSE_SUBTRACT};zt[Hm]=n.MIN,zt[Wm]=n.MAX;let ct={[Xm]:n.ZERO,[Ym]:n.ONE,[qm]:n.SRC_COLOR,[ih]:n.SRC_ALPHA,[jm]:n.SRC_ALPHA_SATURATE,[Km]:n.DST_COLOR,[Jm]:n.DST_ALPHA,[Zm]:n.ONE_MINUS_SRC_COLOR,[rh]:n.ONE_MINUS_SRC_ALPHA,[Qm]:n.ONE_MINUS_DST_COLOR,[$m]:n.ONE_MINUS_DST_ALPHA,[e0]:n.CONSTANT_COLOR,[t0]:n.ONE_MINUS_CONSTANT_COLOR,[n0]:n.CONSTANT_ALPHA,[i0]:n.ONE_MINUS_CONSTANT_ALPHA};function Tt(ie,Oe,Pe,nt,dt,Be,Rt,vt,cn,dn){if(ie===Aa){g===!0&&(_e(n.BLEND),g=!1);return}if(g===!1&&(de(n.BLEND),g=!0),ie!==zm){if(ie!==m||dn!==z){if((L!==Fs||p!==Fs)&&(n.blendEquation(n.FUNC_ADD),L=Fs,p=Fs),dn)switch(ie){case Ao:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case eh:n.blendFunc(n.ONE,n.ONE);break;case th:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case nh:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:sn("WebGLState: Invalid blending: ",ie);break}else switch(ie){case Ao:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case eh:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case th:sn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case nh:sn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:sn("WebGLState: Invalid blending: ",ie);break}F=null,_=null,S=null,B=null,b.set(0,0,0),I=0,m=ie,z=dn}return}dt=dt||Oe,Be=Be||Pe,Rt=Rt||nt,(Oe!==L||dt!==p)&&(n.blendEquationSeparate(zt[Oe],zt[dt]),L=Oe,p=dt),(Pe!==F||nt!==_||Be!==S||Rt!==B)&&(n.blendFuncSeparate(ct[Pe],ct[nt],ct[Be],ct[Rt]),F=Pe,_=nt,S=Be,B=Rt),(vt.equals(b)===!1||cn!==I)&&(n.blendColor(vt.r,vt.g,vt.b,cn),b.copy(vt),I=cn),m=ie,z=!1}function Zt(ie,Oe){ie.side===Ir?_e(n.CULL_FACE):de(n.CULL_FACE);let Pe=ie.side===pr;Oe&&(Pe=!Pe),wt(Pe),ie.blending===Ao&&ie.transparent===!1?Tt(Aa):Tt(ie.blending,ie.blendEquation,ie.blendSrc,ie.blendDst,ie.blendEquationAlpha,ie.blendSrcAlpha,ie.blendDstAlpha,ie.blendColor,ie.blendAlpha,ie.premultipliedAlpha),s.setFunc(ie.depthFunc),s.setTest(ie.depthTest),s.setMask(ie.depthWrite),a.setMask(ie.colorWrite);let nt=ie.stencilWrite;o.setTest(nt),nt&&(o.setMask(ie.stencilWriteMask),o.setFunc(ie.stencilFunc,ie.stencilRef,ie.stencilFuncMask),o.setOp(ie.stencilFail,ie.stencilZFail,ie.stencilZPass)),ln(ie.polygonOffset,ie.polygonOffsetFactor,ie.polygonOffsetUnits),ie.alphaToCoverage===!0?de(n.SAMPLE_ALPHA_TO_COVERAGE):_e(n.SAMPLE_ALPHA_TO_COVERAGE)}function wt(ie){U!==ie&&(ie?n.frontFace(n.CW):n.frontFace(n.CCW),U=ie)}function bt(ie){ie!==Bm?(de(n.CULL_FACE),ie!==Y&&(ie===jf?n.cullFace(n.BACK):ie===km?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):_e(n.CULL_FACE),Y=ie}function _t(ie){ie!==E&&(ee&&n.lineWidth(ie),E=ie)}function ln(ie,Oe,Pe){ie?(de(n.POLYGON_OFFSET_FILL),(M!==Oe||O!==Pe)&&(M=Oe,O=Pe,s.getReversed()&&(Oe=-Oe),n.polygonOffset(Oe,Pe))):_e(n.POLYGON_OFFSET_FILL)}function rt(ie){ie?de(n.SCISSOR_TEST):_e(n.SCISSOR_TEST)}function an(ie){ie===void 0&&(ie=n.TEXTURE0+H-1),re!==ie&&(n.activeTexture(ie),re=ie)}function se(ie,Oe,Pe){Pe===void 0&&(re===null?Pe=n.TEXTURE0+H-1:Pe=re);let nt=J[Pe];nt===void 0&&(nt={type:void 0,texture:void 0},J[Pe]=nt),(nt.type!==ie||nt.texture!==Oe)&&(re!==Pe&&(n.activeTexture(Pe),re=Pe),n.bindTexture(ie,Oe||ae[ie]),nt.type=ie,nt.texture=Oe)}function mn(){let ie=J[re];ie!==void 0&&ie.type!==void 0&&(n.bindTexture(ie.type,null),ie.type=void 0,ie.texture=void 0)}function nn(){try{n.compressedTexImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function W(){try{n.compressedTexImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function w(){try{n.texSubImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function ue(){try{n.texSubImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function ye(){try{n.compressedTexSubImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function we(){try{n.compressedTexSubImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function ze(){try{n.texStorage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Ye(){try{n.texStorage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Re(){try{n.texImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Ae(){try{n.texImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Ne(ie){return f[ie]!==void 0?f[ie]:n.getParameter(ie)}function je(ie,Oe){f[ie]!==Oe&&(n.pixelStorei(ie,Oe),f[ie]=Oe)}function Ve(ie){fe.equals(ie)===!1&&(n.scissor(ie.x,ie.y,ie.z,ie.w),fe.copy(ie))}function qe(ie){pe.equals(ie)===!1&&(n.viewport(ie.x,ie.y,ie.z,ie.w),pe.copy(ie))}function ot(ie,Oe){let Pe=l.get(Oe);Pe===void 0&&(Pe=new WeakMap,l.set(Oe,Pe));let nt=Pe.get(ie);nt===void 0&&(nt=n.getUniformBlockIndex(Oe,ie.name),Pe.set(ie,nt))}function pt(ie,Oe){let nt=l.get(Oe).get(ie);u.get(Oe)!==nt&&(n.uniformBlockBinding(Oe,nt,ie.__bindingPointIndex),u.set(Oe,nt))}function He(){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={},re=null,J={},h={},v=new WeakMap,y=[],T=null,g=!1,m=null,L=null,F=null,_=null,p=null,S=null,B=null,b=new vn(0,0,0),I=0,z=!1,U=null,Y=null,E=null,M=null,O=null,fe.set(0,0,n.canvas.width,n.canvas.height),pe.set(0,0,n.canvas.width,n.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:de,disable:_e,bindFramebuffer:Ge,drawBuffers:$e,useProgram:ut,setBlending:Tt,setMaterial:Zt,setFlipSided:wt,setCullFace:bt,setLineWidth:_t,setPolygonOffset:ln,setScissorTest:rt,activeTexture:an,bindTexture:se,unbindTexture:mn,compressedTexImage2D:nn,compressedTexImage3D:W,texImage2D:Re,texImage3D:Ae,pixelStorei:je,getParameter:Ne,updateUBOMapping:ot,uniformBlockBinding:pt,texStorage2D:ze,texStorage3D:Ye,texSubImage2D:w,texSubImage3D:ue,compressedTexSubImage2D:ye,compressedTexSubImage3D:we,scissor:Ve,viewport:qe,reset:He}}function vb(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 kt,d=new WeakMap,f=new Set,h,v=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function T(W,w){return y?new OffscreenCanvas(W,w):pl("canvas")}function g(W,w,ue){let ye=1,we=nn(W);if((we.width>ue||we.height>ue)&&(ye=ue/Math.max(we.width,we.height)),ye<1)if(typeof HTMLImageElement<"u"&&W instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&W instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&W instanceof ImageBitmap||typeof VideoFrame<"u"&&W instanceof VideoFrame){let ze=Math.floor(ye*we.width),Ye=Math.floor(ye*we.height);h===void 0&&(h=T(ze,Ye));let Re=w?T(ze,Ye):h;return Re.width=ze,Re.height=Ye,Re.getContext("2d").drawImage(W,0,0,ze,Ye),rn("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ze+"x"+Ye+")."),Re}else return"data"in W&&rn("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),W;return W}function m(W){return W.generateMipmaps}function L(W){n.generateMipmap(W)}function F(W){return W.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:W.isWebGL3DRenderTarget?n.TEXTURE_3D:W.isWebGLArrayRenderTarget||W.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function _(W,w,ue,ye,we,ze=!1){if(W!==null){if(n[W]!==void 0)return n[W];rn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+W+"'")}let Ye;ye&&(Ye=e.get("EXT_texture_norm16"),Ye||rn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Re=w;if(w===n.RED&&(ue===n.FLOAT&&(Re=n.R32F),ue===n.HALF_FLOAT&&(Re=n.R16F),ue===n.UNSIGNED_BYTE&&(Re=n.R8),ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.R16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.R16_SNORM_EXT)),w===n.RED_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.R8UI),ue===n.UNSIGNED_SHORT&&(Re=n.R16UI),ue===n.UNSIGNED_INT&&(Re=n.R32UI),ue===n.BYTE&&(Re=n.R8I),ue===n.SHORT&&(Re=n.R16I),ue===n.INT&&(Re=n.R32I)),w===n.RG&&(ue===n.FLOAT&&(Re=n.RG32F),ue===n.HALF_FLOAT&&(Re=n.RG16F),ue===n.UNSIGNED_BYTE&&(Re=n.RG8),ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.RG16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.RG16_SNORM_EXT)),w===n.RG_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.RG8UI),ue===n.UNSIGNED_SHORT&&(Re=n.RG16UI),ue===n.UNSIGNED_INT&&(Re=n.RG32UI),ue===n.BYTE&&(Re=n.RG8I),ue===n.SHORT&&(Re=n.RG16I),ue===n.INT&&(Re=n.RG32I)),w===n.RGB_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.RGB8UI),ue===n.UNSIGNED_SHORT&&(Re=n.RGB16UI),ue===n.UNSIGNED_INT&&(Re=n.RGB32UI),ue===n.BYTE&&(Re=n.RGB8I),ue===n.SHORT&&(Re=n.RGB16I),ue===n.INT&&(Re=n.RGB32I)),w===n.RGBA_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.RGBA8UI),ue===n.UNSIGNED_SHORT&&(Re=n.RGBA16UI),ue===n.UNSIGNED_INT&&(Re=n.RGBA32UI),ue===n.BYTE&&(Re=n.RGBA8I),ue===n.SHORT&&(Re=n.RGBA16I),ue===n.INT&&(Re=n.RGBA32I)),w===n.RGB&&(ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.RGB16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.RGB16_SNORM_EXT),ue===n.UNSIGNED_INT_5_9_9_9_REV&&(Re=n.RGB9_E5),ue===n.UNSIGNED_INT_10F_11F_11F_REV&&(Re=n.R11F_G11F_B10F)),w===n.RGBA){let Ae=ze?hl:Ln.getTransfer(we);ue===n.FLOAT&&(Re=n.RGBA32F),ue===n.HALF_FLOAT&&(Re=n.RGBA16F),ue===n.UNSIGNED_BYTE&&(Re=Ae===Jn?n.SRGB8_ALPHA8:n.RGBA8),ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.RGBA16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.RGBA16_SNORM_EXT),ue===n.UNSIGNED_SHORT_4_4_4_4&&(Re=n.RGBA4),ue===n.UNSIGNED_SHORT_5_5_5_1&&(Re=n.RGB5_A1)}return(Re===n.R16F||Re===n.R32F||Re===n.RG16F||Re===n.RG32F||Re===n.RGBA16F||Re===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Re}function p(W,w){let ue;return W?w===null||w===sa||w===Co?ue=n.DEPTH24_STENCIL8:w===Yr?ue=n.DEPTH32F_STENCIL8:w===Io&&(ue=n.DEPTH24_STENCIL8,rn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===sa||w===Co?ue=n.DEPTH_COMPONENT24:w===Yr?ue=n.DEPTH_COMPONENT32F:w===Io&&(ue=n.DEPTH_COMPONENT16),ue}function S(W,w){return m(W)===!0||W.isFramebufferTexture&&W.minFilter!==Bi&&W.minFilter!==Hi?Math.log2(Math.max(w.width,w.height))+1:W.mipmaps!==void 0&&W.mipmaps.length>0?W.mipmaps.length:W.isCompressedTexture&&Array.isArray(W.image)?w.mipmaps.length:1}function B(W){let w=W.target;w.removeEventListener("dispose",B),I(w),w.isVideoTexture&&d.delete(w),w.isHTMLTexture&&f.delete(w)}function b(W){let w=W.target;w.removeEventListener("dispose",b),U(w)}function I(W){let w=i.get(W);if(w.__webglInit===void 0)return;let ue=W.source,ye=v.get(ue);if(ye){let we=ye[w.__cacheKey];we.usedTimes--,we.usedTimes===0&&z(W),Object.keys(ye).length===0&&v.delete(ue)}i.remove(W)}function z(W){let w=i.get(W);n.deleteTexture(w.__webglTexture);let ue=W.source,ye=v.get(ue);delete ye[w.__cacheKey],s.memory.textures--}function U(W){let w=i.get(W);if(W.depthTexture&&(W.depthTexture.dispose(),i.remove(W.depthTexture)),W.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(w.__webglFramebuffer[ye]))for(let we=0;we<w.__webglFramebuffer[ye].length;we++)n.deleteFramebuffer(w.__webglFramebuffer[ye][we]);else n.deleteFramebuffer(w.__webglFramebuffer[ye]);w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer[ye])}else{if(Array.isArray(w.__webglFramebuffer))for(let ye=0;ye<w.__webglFramebuffer.length;ye++)n.deleteFramebuffer(w.__webglFramebuffer[ye]);else n.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&n.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let ye=0;ye<w.__webglColorRenderbuffer.length;ye++)w.__webglColorRenderbuffer[ye]&&n.deleteRenderbuffer(w.__webglColorRenderbuffer[ye]);w.__webglDepthRenderbuffer&&n.deleteRenderbuffer(w.__webglDepthRenderbuffer)}let ue=W.textures;for(let ye=0,we=ue.length;ye<we;ye++){let ze=i.get(ue[ye]);ze.__webglTexture&&(n.deleteTexture(ze.__webglTexture),s.memory.textures--),i.remove(ue[ye])}i.remove(W)}let Y=0;function E(){Y=0}function M(){return Y}function O(W){Y=W}function H(){let W=Y;return W>=r.maxTextures&&rn("WebGLTextures: Trying to use "+(W+1)+" texture units while this GPU supports only "+r.maxTextures),Y+=1,W}function ee(W){let w=[];return w.push(W.wrapS),w.push(W.wrapT),w.push(W.wrapR||0),w.push(W.magFilter),w.push(W.minFilter),w.push(W.anisotropy),w.push(W.internalFormat),w.push(W.format),w.push(W.type),w.push(W.generateMipmaps),w.push(W.premultiplyAlpha),w.push(W.flipY),w.push(W.unpackAlignment),w.push(W.colorSpace),w.join()}function j(W,w){let ue=i.get(W);if(W.isVideoTexture&&se(W),W.isRenderTargetTexture===!1&&W.isExternalTexture!==!0&&W.version>0&&ue.__version!==W.version){let ye=W.image;if(ye===null)rn("WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)rn("WebGLRenderer: Texture marked for update but image is incomplete");else{_e(ue,W,w);return}}else W.isExternalTexture&&(ue.__webglTexture=W.sourceTexture?W.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ue.__webglTexture,n.TEXTURE0+w)}function K(W,w){let ue=i.get(W);if(W.isRenderTargetTexture===!1&&W.version>0&&ue.__version!==W.version){_e(ue,W,w);return}else W.isExternalTexture&&(ue.__webglTexture=W.sourceTexture?W.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ue.__webglTexture,n.TEXTURE0+w)}function re(W,w){let ue=i.get(W);if(W.isRenderTargetTexture===!1&&W.version>0&&ue.__version!==W.version){_e(ue,W,w);return}t.bindTexture(n.TEXTURE_3D,ue.__webglTexture,n.TEXTURE0+w)}function J(W,w){let ue=i.get(W);if(W.isCubeDepthTexture!==!0&&W.version>0&&ue.__version!==W.version){Ge(ue,W,w);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ue.__webglTexture,n.TEXTURE0+w)}let ne={[nu]:n.REPEAT,[_a]:n.CLAMP_TO_EDGE,[iu]:n.MIRRORED_REPEAT},Te={[Bi]:n.NEAREST,[s0]:n.NEAREST_MIPMAP_NEAREST,[Vl]:n.NEAREST_MIPMAP_LINEAR,[Hi]:n.LINEAR,[Ou]:n.LINEAR_MIPMAP_NEAREST,[gs]:n.LINEAR_MIPMAP_LINEAR},fe={[u0]:n.NEVER,[m0]:n.ALWAYS,[d0]:n.LESS,[Sd]:n.LEQUAL,[f0]:n.EQUAL,[bd]:n.GEQUAL,[h0]:n.GREATER,[p0]:n.NOTEQUAL};function pe(W,w){if(w.type===Yr&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===Hi||w.magFilter===Ou||w.magFilter===Vl||w.magFilter===gs||w.minFilter===Hi||w.minFilter===Ou||w.minFilter===Vl||w.minFilter===gs)&&rn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(W,n.TEXTURE_WRAP_S,ne[w.wrapS]),n.texParameteri(W,n.TEXTURE_WRAP_T,ne[w.wrapT]),(W===n.TEXTURE_3D||W===n.TEXTURE_2D_ARRAY)&&n.texParameteri(W,n.TEXTURE_WRAP_R,ne[w.wrapR]),n.texParameteri(W,n.TEXTURE_MAG_FILTER,Te[w.magFilter]),n.texParameteri(W,n.TEXTURE_MIN_FILTER,Te[w.minFilter]),w.compareFunction&&(n.texParameteri(W,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(W,n.TEXTURE_COMPARE_FUNC,fe[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===Bi||w.minFilter!==Vl&&w.minFilter!==gs||w.type===Yr&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||i.get(w).__currentAnisotropy){let ue=e.get("EXT_texture_filter_anisotropic");n.texParameterf(W,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,r.getMaxAnisotropy())),i.get(w).__currentAnisotropy=w.anisotropy}}}function Fe(W,w){let ue=!1;W.__webglInit===void 0&&(W.__webglInit=!0,w.addEventListener("dispose",B));let ye=w.source,we=v.get(ye);we===void 0&&(we={},v.set(ye,we));let ze=ee(w);if(ze!==W.__cacheKey){we[ze]===void 0&&(we[ze]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ue=!0),we[ze].usedTimes++;let Ye=we[W.__cacheKey];Ye!==void 0&&(we[W.__cacheKey].usedTimes--,Ye.usedTimes===0&&z(w)),W.__cacheKey=ze,W.__webglTexture=we[ze].texture}return ue}function ae(W,w,ue){return Math.floor(Math.floor(W/ue)/w)}function de(W,w,ue,ye){let ze=W.updateRanges;if(ze.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,w.width,w.height,ue,ye,w.data);else{ze.sort((je,Ve)=>je.start-Ve.start);let Ye=0;for(let je=1;je<ze.length;je++){let Ve=ze[Ye],qe=ze[je],ot=Ve.start+Ve.count,pt=ae(qe.start,w.width,4),He=ae(Ve.start,w.width,4);qe.start<=ot+1&&pt===He&&ae(qe.start+qe.count-1,w.width,4)===pt?Ve.count=Math.max(Ve.count,qe.start+qe.count-Ve.start):(++Ye,ze[Ye]=qe)}ze.length=Ye+1;let Re=t.getParameter(n.UNPACK_ROW_LENGTH),Ae=t.getParameter(n.UNPACK_SKIP_PIXELS),Ne=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,w.width);for(let je=0,Ve=ze.length;je<Ve;je++){let qe=ze[je],ot=Math.floor(qe.start/4),pt=Math.ceil(qe.count/4),He=ot%w.width,ie=Math.floor(ot/w.width),Oe=pt,Pe=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,He),t.pixelStorei(n.UNPACK_SKIP_ROWS,ie),t.texSubImage2D(n.TEXTURE_2D,0,He,ie,Oe,Pe,ue,ye,w.data)}W.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,Re),t.pixelStorei(n.UNPACK_SKIP_PIXELS,Ae),t.pixelStorei(n.UNPACK_SKIP_ROWS,Ne)}}function _e(W,w,ue){let ye=n.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(ye=n.TEXTURE_2D_ARRAY),w.isData3DTexture&&(ye=n.TEXTURE_3D);let we=Fe(W,w),ze=w.source;t.bindTexture(ye,W.__webglTexture,n.TEXTURE0+ue);let Ye=i.get(ze);if(ze.version!==Ye.__version||we===!0){if(t.activeTexture(n.TEXTURE0+ue),(typeof ImageBitmap<"u"&&w.image instanceof ImageBitmap)===!1){let Pe=Ln.getPrimaries(Ln.workingColorSpace),nt=w.colorSpace===Ya?null:Ln.getPrimaries(w.colorSpace),dt=w.colorSpace===Ya||Pe===nt?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,dt)}t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment);let Ae=g(w.image,!1,r.maxTextureSize);Ae=mn(w,Ae);let Ne=a.convert(w.format,w.colorSpace),je=a.convert(w.type),Ve=_(w.internalFormat,Ne,je,w.normalized,w.colorSpace,w.isVideoTexture);pe(ye,w);let qe,ot=w.mipmaps,pt=w.isVideoTexture!==!0,He=Ye.__version===void 0||we===!0,ie=ze.dataReady,Oe=S(w,Ae);if(w.isDepthTexture)Ve=p(w.format===ys,w.type),He&&(pt?t.texStorage2D(n.TEXTURE_2D,1,Ve,Ae.width,Ae.height):t.texImage2D(n.TEXTURE_2D,0,Ve,Ae.width,Ae.height,0,Ne,je,null));else if(w.isDataTexture)if(ot.length>0){pt&&He&&t.texStorage2D(n.TEXTURE_2D,Oe,Ve,ot[0].width,ot[0].height);for(let Pe=0,nt=ot.length;Pe<nt;Pe++)qe=ot[Pe],pt?ie&&t.texSubImage2D(n.TEXTURE_2D,Pe,0,0,qe.width,qe.height,Ne,je,qe.data):t.texImage2D(n.TEXTURE_2D,Pe,Ve,qe.width,qe.height,0,Ne,je,qe.data);w.generateMipmaps=!1}else pt?(He&&t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Ae.width,Ae.height),ie&&de(w,Ae,Ne,je)):t.texImage2D(n.TEXTURE_2D,0,Ve,Ae.width,Ae.height,0,Ne,je,Ae.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){pt&&He&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ve,ot[0].width,ot[0].height,Ae.depth);for(let Pe=0,nt=ot.length;Pe<nt;Pe++)if(qe=ot[Pe],w.format!==qr)if(Ne!==null)if(pt){if(ie)if(w.layerUpdates.size>0){let dt=Th(qe.width,qe.height,w.format,w.type);for(let Be of w.layerUpdates){let Rt=qe.data.subarray(Be*dt/qe.data.BYTES_PER_ELEMENT,(Be+1)*dt/qe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Pe,0,0,Be,qe.width,qe.height,1,Ne,Rt)}}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Pe,0,0,0,qe.width,qe.height,Ae.depth,Ne,qe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Pe,Ve,qe.width,qe.height,Ae.depth,0,qe.data,0,0);else rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else pt?ie&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Pe,0,0,0,qe.width,qe.height,Ae.depth,Ne,je,qe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Pe,Ve,qe.width,qe.height,Ae.depth,0,Ne,je,qe.data);w.layerUpdates.size>0&&w.clearLayerUpdates()}else{pt&&He&&t.texStorage2D(n.TEXTURE_2D,Oe,Ve,ot[0].width,ot[0].height);for(let Pe=0,nt=ot.length;Pe<nt;Pe++)qe=ot[Pe],w.format!==qr?Ne!==null?pt?ie&&t.compressedTexSubImage2D(n.TEXTURE_2D,Pe,0,0,qe.width,qe.height,Ne,qe.data):t.compressedTexImage2D(n.TEXTURE_2D,Pe,Ve,qe.width,qe.height,0,qe.data):rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pt?ie&&t.texSubImage2D(n.TEXTURE_2D,Pe,0,0,qe.width,qe.height,Ne,je,qe.data):t.texImage2D(n.TEXTURE_2D,Pe,Ve,qe.width,qe.height,0,Ne,je,qe.data)}else if(w.isDataArrayTexture)if(pt){if(He&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ve,Ae.width,Ae.height,Ae.depth),ie)if(w.layerUpdates.size>0){let Pe=Th(Ae.width,Ae.height,w.format,w.type);for(let nt of w.layerUpdates){let dt=Ae.data.subarray(nt*Pe/Ae.data.BYTES_PER_ELEMENT,(nt+1)*Pe/Ae.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,nt,Ae.width,Ae.height,1,Ne,je,dt)}w.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ae.width,Ae.height,Ae.depth,Ne,je,Ae.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ve,Ae.width,Ae.height,Ae.depth,0,Ne,je,Ae.data);else if(w.isData3DTexture)pt?(He&&t.texStorage3D(n.TEXTURE_3D,Oe,Ve,Ae.width,Ae.height,Ae.depth),ie&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ae.width,Ae.height,Ae.depth,Ne,je,Ae.data)):t.texImage3D(n.TEXTURE_3D,0,Ve,Ae.width,Ae.height,Ae.depth,0,Ne,je,Ae.data);else if(w.isFramebufferTexture){if(He)if(pt)t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Ae.width,Ae.height);else{let Pe=Ae.width,nt=Ae.height;for(let dt=0;dt<Oe;dt++)t.texImage2D(n.TEXTURE_2D,dt,Ve,Pe,nt,0,Ne,je,null),Pe>>=1,nt>>=1}}else if(w.isHTMLTexture){if("texElementImage2D"in n){let Pe=n.canvas;if(Pe.hasAttribute("layoutsubtree")||Pe.setAttribute("layoutsubtree","true"),Ae.parentNode!==Pe){Pe.appendChild(Ae),f.add(w),Pe.onpaint=nt=>{let dt=nt.changedElements;for(let Be of f)dt.includes(Be.image)&&(Be.needsUpdate=!0)},Pe.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Ae);else{let dt=n.RGBA,Be=n.RGBA,Rt=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,dt,Be,Rt,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(ot.length>0){if(pt&&He){let Pe=nn(ot[0]);t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Pe.width,Pe.height)}for(let Pe=0,nt=ot.length;Pe<nt;Pe++)qe=ot[Pe],pt?ie&&t.texSubImage2D(n.TEXTURE_2D,Pe,0,0,Ne,je,qe):t.texImage2D(n.TEXTURE_2D,Pe,Ve,Ne,je,qe);w.generateMipmaps=!1}else if(pt){if(He){let Pe=nn(Ae);t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Pe.width,Pe.height)}ie&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ne,je,Ae)}else t.texImage2D(n.TEXTURE_2D,0,Ve,Ne,je,Ae);m(w)&&L(ye),Ye.__version=ze.version,w.onUpdate&&w.onUpdate(w)}W.__version=w.version}function Ge(W,w,ue){if(w.image.length!==6)return;let ye=Fe(W,w),we=w.source;t.bindTexture(n.TEXTURE_CUBE_MAP,W.__webglTexture,n.TEXTURE0+ue);let ze=i.get(we);if(we.version!==ze.__version||ye===!0){t.activeTexture(n.TEXTURE0+ue);let Ye=Ln.getPrimaries(Ln.workingColorSpace),Re=w.colorSpace===Ya?null:Ln.getPrimaries(w.colorSpace),Ae=w.colorSpace===Ya||Ye===Re?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae);let Ne=w.isCompressedTexture||w.image[0].isCompressedTexture,je=w.image[0]&&w.image[0].isDataTexture,Ve=[];for(let Be=0;Be<6;Be++)!Ne&&!je?Ve[Be]=g(w.image[Be],!0,r.maxCubemapSize):Ve[Be]=je?w.image[Be].image:w.image[Be],Ve[Be]=mn(w,Ve[Be]);let qe=Ve[0],ot=a.convert(w.format,w.colorSpace),pt=a.convert(w.type),He=_(w.internalFormat,ot,pt,w.normalized,w.colorSpace),ie=w.isVideoTexture!==!0,Oe=ze.__version===void 0||ye===!0,Pe=we.dataReady,nt=S(w,qe);pe(n.TEXTURE_CUBE_MAP,w);let dt;if(Ne){ie&&Oe&&t.texStorage2D(n.TEXTURE_CUBE_MAP,nt,He,qe.width,qe.height);for(let Be=0;Be<6;Be++){dt=Ve[Be].mipmaps;for(let Rt=0;Rt<dt.length;Rt++){let vt=dt[Rt];w.format!==qr?ot!==null?ie?Pe&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,0,0,vt.width,vt.height,ot,vt.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,He,vt.width,vt.height,0,vt.data):rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,0,0,vt.width,vt.height,ot,pt,vt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,He,vt.width,vt.height,0,ot,pt,vt.data)}}}else{if(dt=w.mipmaps,ie&&Oe){dt.length>0&&nt++;let Be=nn(Ve[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,nt,He,Be.width,Be.height)}for(let Be=0;Be<6;Be++)if(je){ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,0,0,Ve[Be].width,Ve[Be].height,ot,pt,Ve[Be].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,He,Ve[Be].width,Ve[Be].height,0,ot,pt,Ve[Be].data);for(let Rt=0;Rt<dt.length;Rt++){let cn=dt[Rt].image[Be].image;ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,0,0,cn.width,cn.height,ot,pt,cn.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,He,cn.width,cn.height,0,ot,pt,cn.data)}}else{ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,0,0,ot,pt,Ve[Be]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,He,ot,pt,Ve[Be]);for(let Rt=0;Rt<dt.length;Rt++){let vt=dt[Rt];ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,0,0,ot,pt,vt.image[Be]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,He,ot,pt,vt.image[Be])}}}m(w)&&L(n.TEXTURE_CUBE_MAP),ze.__version=we.version,w.onUpdate&&w.onUpdate(w)}W.__version=w.version}function $e(W,w,ue,ye,we,ze){let Ye=a.convert(ue.format,ue.colorSpace),Re=a.convert(ue.type),Ae=_(ue.internalFormat,Ye,Re,ue.normalized,ue.colorSpace),Ne=i.get(w),je=i.get(ue);if(je.__renderTarget=w,!Ne.__hasExternalTextures){let Ve=Math.max(1,w.width>>ze),qe=Math.max(1,w.height>>ze);we===n.TEXTURE_3D||we===n.TEXTURE_2D_ARRAY?t.texImage3D(we,ze,Ae,Ve,qe,w.depth,0,Ye,Re,null):t.texImage2D(we,ze,Ae,Ve,qe,0,Ye,Re,null)}t.bindFramebuffer(n.FRAMEBUFFER,W),an(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ye,we,je.__webglTexture,0,rt(w)):(we===n.TEXTURE_2D||we>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ye,we,je.__webglTexture,ze),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ut(W,w,ue){if(n.bindRenderbuffer(n.RENDERBUFFER,W),w.depthBuffer){let ye=w.depthTexture,we=ye&&ye.isDepthTexture?ye.type:null,ze=p(w.stencilBuffer,we),Ye=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;an(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,rt(w),ze,w.width,w.height):ue?n.renderbufferStorageMultisample(n.RENDERBUFFER,rt(w),ze,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,ze,w.width,w.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ye,n.RENDERBUFFER,W)}else{let ye=w.textures;for(let we=0;we<ye.length;we++){let ze=ye[we],Ye=a.convert(ze.format,ze.colorSpace),Re=a.convert(ze.type),Ae=_(ze.internalFormat,Ye,Re,ze.normalized,ze.colorSpace);an(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,rt(w),Ae,w.width,w.height):ue?n.renderbufferStorageMultisample(n.RENDERBUFFER,rt(w),Ae,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,Ae,w.width,w.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function zt(W,w,ue){let ye=w.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,W),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let we=i.get(w.depthTexture);if(we.__renderTarget=w,(!we.__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),ye){if(we.__webglInit===void 0&&(we.__webglInit=!0,w.depthTexture.addEventListener("dispose",B)),we.__webglTexture===void 0){we.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,we.__webglTexture),pe(n.TEXTURE_CUBE_MAP,w.depthTexture);let Ne=a.convert(w.depthTexture.format),je=a.convert(w.depthTexture.type),Ve;w.depthTexture.format===Ma?Ve=n.DEPTH_COMPONENT24:w.depthTexture.format===ys&&(Ve=n.DEPTH24_STENCIL8);for(let qe=0;qe<6;qe++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+qe,0,Ve,w.width,w.height,0,Ne,je,null)}}else j(w.depthTexture,0);let ze=we.__webglTexture,Ye=rt(w),Re=ye?n.TEXTURE_CUBE_MAP_POSITIVE_X+ue:n.TEXTURE_2D,Ae=w.depthTexture.format===ys?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(w.depthTexture.format===Ma)an(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ae,Re,ze,0,Ye):n.framebufferTexture2D(n.FRAMEBUFFER,Ae,Re,ze,0);else if(w.depthTexture.format===ys)an(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ae,Re,ze,0,Ye):n.framebufferTexture2D(n.FRAMEBUFFER,Ae,Re,ze,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ct(W){let w=i.get(W),ue=W.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==W.depthTexture){let ye=W.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),ye){let we=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,ye.removeEventListener("dispose",we)};ye.addEventListener("dispose",we),w.__depthDisposeCallback=we}w.__boundDepthTexture=ye}if(W.depthTexture&&!w.__autoAllocateDepthBuffer)if(ue)for(let ye=0;ye<6;ye++)zt(w.__webglFramebuffer[ye],W,ye);else{let ye=W.texture.mipmaps;ye&&ye.length>0?zt(w.__webglFramebuffer[0],W,0):zt(w.__webglFramebuffer,W,0)}else if(ue){w.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)if(t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[ye]),w.__webglDepthbuffer[ye]===void 0)w.__webglDepthbuffer[ye]=n.createRenderbuffer(),ut(w.__webglDepthbuffer[ye],W,!1);else{let we=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ze=w.__webglDepthbuffer[ye];n.bindRenderbuffer(n.RENDERBUFFER,ze),n.framebufferRenderbuffer(n.FRAMEBUFFER,we,n.RENDERBUFFER,ze)}}else{let ye=W.texture.mipmaps;if(ye&&ye.length>0?t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=n.createRenderbuffer(),ut(w.__webglDepthbuffer,W,!1);else{let we=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ze=w.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,ze),n.framebufferRenderbuffer(n.FRAMEBUFFER,we,n.RENDERBUFFER,ze)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Tt(W,w,ue){let ye=i.get(W);w!==void 0&&$e(ye.__webglFramebuffer,W,W.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ue!==void 0&&ct(W)}function Zt(W){let w=W.texture,ue=i.get(W),ye=i.get(w);W.addEventListener("dispose",b);let we=W.textures,ze=W.isWebGLCubeRenderTarget===!0,Ye=we.length>1;if(Ye||(ye.__webglTexture===void 0&&(ye.__webglTexture=n.createTexture()),ye.__version=w.version,s.memory.textures++),ze){ue.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)if(w.mipmaps&&w.mipmaps.length>0){ue.__webglFramebuffer[Re]=[];for(let Ae=0;Ae<w.mipmaps.length;Ae++)ue.__webglFramebuffer[Re][Ae]=n.createFramebuffer()}else ue.__webglFramebuffer[Re]=n.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){ue.__webglFramebuffer=[];for(let Re=0;Re<w.mipmaps.length;Re++)ue.__webglFramebuffer[Re]=n.createFramebuffer()}else ue.__webglFramebuffer=n.createFramebuffer();if(Ye)for(let Re=0,Ae=we.length;Re<Ae;Re++){let Ne=i.get(we[Re]);Ne.__webglTexture===void 0&&(Ne.__webglTexture=n.createTexture(),s.memory.textures++)}if(W.samples>0&&an(W)===!1){ue.__webglMultisampledFramebuffer=n.createFramebuffer(),ue.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ue.__webglMultisampledFramebuffer);for(let Re=0;Re<we.length;Re++){let Ae=we[Re];ue.__webglColorRenderbuffer[Re]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ue.__webglColorRenderbuffer[Re]);let Ne=a.convert(Ae.format,Ae.colorSpace),je=a.convert(Ae.type),Ve=_(Ae.internalFormat,Ne,je,Ae.normalized,Ae.colorSpace,W.isXRRenderTarget===!0),qe=rt(W);n.renderbufferStorageMultisample(n.RENDERBUFFER,qe,Ve,W.width,W.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,ue.__webglColorRenderbuffer[Re])}n.bindRenderbuffer(n.RENDERBUFFER,null),W.depthBuffer&&(ue.__webglDepthRenderbuffer=n.createRenderbuffer(),ut(ue.__webglDepthRenderbuffer,W,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(ze){t.bindTexture(n.TEXTURE_CUBE_MAP,ye.__webglTexture),pe(n.TEXTURE_CUBE_MAP,w);for(let Re=0;Re<6;Re++)if(w.mipmaps&&w.mipmaps.length>0)for(let Ae=0;Ae<w.mipmaps.length;Ae++)$e(ue.__webglFramebuffer[Re][Ae],W,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,Ae);else $e(ue.__webglFramebuffer[Re],W,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0);m(w)&&L(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ye){for(let Re=0,Ae=we.length;Re<Ae;Re++){let Ne=we[Re],je=i.get(Ne),Ve=n.TEXTURE_2D;(W.isWebGL3DRenderTarget||W.isWebGLArrayRenderTarget)&&(Ve=W.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ve,je.__webglTexture),pe(Ve,Ne),$e(ue.__webglFramebuffer,W,Ne,n.COLOR_ATTACHMENT0+Re,Ve,0),m(Ne)&&L(Ve)}t.unbindTexture()}else{let Re=n.TEXTURE_2D;if((W.isWebGL3DRenderTarget||W.isWebGLArrayRenderTarget)&&(Re=W.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Re,ye.__webglTexture),pe(Re,w),w.mipmaps&&w.mipmaps.length>0)for(let Ae=0;Ae<w.mipmaps.length;Ae++)$e(ue.__webglFramebuffer[Ae],W,w,n.COLOR_ATTACHMENT0,Re,Ae);else $e(ue.__webglFramebuffer,W,w,n.COLOR_ATTACHMENT0,Re,0);m(w)&&L(Re),t.unbindTexture()}W.depthBuffer&&ct(W)}function wt(W){let w=W.textures;for(let ue=0,ye=w.length;ue<ye;ue++){let we=w[ue];if(m(we)){let ze=F(W),Ye=i.get(we).__webglTexture;t.bindTexture(ze,Ye),L(ze),t.unbindTexture()}}}let bt=[],_t=[];function ln(W){if(W.samples>0){if(an(W)===!1){let w=W.textures,ue=W.width,ye=W.height,we=n.COLOR_BUFFER_BIT,ze=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ye=i.get(W),Re=w.length>1;if(Re)for(let Ne=0;Ne<w.length;Ne++)t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ye.__webglMultisampledFramebuffer);let Ae=W.texture.mipmaps;Ae&&Ae.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ye.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ye.__webglFramebuffer);for(let Ne=0;Ne<w.length;Ne++){if(W.resolveDepthBuffer&&(W.depthBuffer&&(we|=n.DEPTH_BUFFER_BIT),W.stencilBuffer&&W.resolveStencilBuffer&&(we|=n.STENCIL_BUFFER_BIT)),Re){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ye.__webglColorRenderbuffer[Ne]);let je=i.get(w[Ne]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,je,0)}n.blitFramebuffer(0,0,ue,ye,0,0,ue,ye,we,n.NEAREST),u===!0&&(bt.length=0,_t.length=0,bt.push(n.COLOR_ATTACHMENT0+Ne),W.depthBuffer&&W.storeMultisampledDepthBuffer===!1&&(bt.push(ze),_t.push(ze),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,_t)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,bt))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Re)for(let Ne=0;Ne<w.length;Ne++){t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.RENDERBUFFER,Ye.__webglColorRenderbuffer[Ne]);let je=i.get(w[Ne]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.TEXTURE_2D,je,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ye.__webglMultisampledFramebuffer)}else if(W.depthBuffer&&W.storeMultisampledDepthBuffer===!1&&u){let w=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[w])}}}function rt(W){return Math.min(r.maxSamples,W.samples)}function an(W){let w=i.get(W);return W.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function se(W){let w=s.render.frame;d.get(W)!==w&&(d.set(W,w),W.update())}function mn(W,w){let ue=W.colorSpace,ye=W.format,we=W.type;return W.isCompressedTexture===!0||W.isVideoTexture===!0||ue!==fl&&ue!==Ya&&(Ln.getTransfer(ue)===Jn?(ye!==qr||we!==Cr)&&rn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):sn("WebGLTextures: Unsupported texture color space:",ue)),w}function nn(W){return typeof HTMLImageElement<"u"&&W instanceof HTMLImageElement?(l.width=W.naturalWidth||W.width,l.height=W.naturalHeight||W.height):typeof VideoFrame<"u"&&W instanceof VideoFrame?(l.width=W.displayWidth,l.height=W.displayHeight):(l.width=W.width,l.height=W.height),l}this.allocateTextureUnit=H,this.resetTextureUnits=E,this.getTextureUnits=M,this.setTextureUnits=O,this.setTexture2D=j,this.setTexture2DArray=K,this.setTexture3D=re,this.setTextureCube=J,this.rebindTextures=Tt,this.setupRenderTarget=Zt,this.updateRenderTargetMipmap=wt,this.updateMultisampleRenderTarget=ln,this.setupDepthRenderbuffer=ct,this.setupFrameBufferTexture=$e,this.useMultisampledRTT=an,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function gb(n,e){function t(i,r=Ya){let a,s=Ln.getTransfer(r);if(i===Cr)return n.UNSIGNED_BYTE;if(i===ku)return n.UNSIGNED_SHORT_4_4_4_4;if(i===zu)return n.UNSIGNED_SHORT_5_5_5_1;if(i===mh)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===vh)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===hh)return n.BYTE;if(i===ph)return n.SHORT;if(i===Io)return n.UNSIGNED_SHORT;if(i===Bu)return n.INT;if(i===sa)return n.UNSIGNED_INT;if(i===Yr)return n.FLOAT;if(i===oa)return n.HALF_FLOAT;if(i===gh)return n.ALPHA;if(i===yh)return n.RGB;if(i===qr)return n.RGBA;if(i===Ma)return n.DEPTH_COMPONENT;if(i===ys)return n.DEPTH_STENCIL;if(i===Vu)return n.RED;if(i===Gu)return n.RED_INTEGER;if(i===xs)return n.RG;if(i===Hu)return n.RG_INTEGER;if(i===Wu)return n.RGBA_INTEGER;if(i===Gl||i===Hl||i===Wl||i===Xl)if(s===Jn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Gl)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Hl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Wl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Xl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Gl)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Hl)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Wl)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Xl)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Xu||i===Yu||i===qu||i===Zu)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===Xu)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Yu)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===qu)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Zu)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Ju||i===$u||i===Ku||i===Qu||i===ju||i===Yl||i===ed)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===Ju||i===$u)return s===Jn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Ku)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(i===Qu)return a.COMPRESSED_R11_EAC;if(i===ju)return a.COMPRESSED_SIGNED_R11_EAC;if(i===Yl)return a.COMPRESSED_RG11_EAC;if(i===ed)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===td||i===nd||i===id||i===rd||i===ad||i===sd||i===od||i===ld||i===cd||i===ud||i===dd||i===fd||i===hd||i===pd)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===td)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===nd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===id)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===rd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ad)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===sd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===od)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ld)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===cd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ud)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===dd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===fd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===hd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===pd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===md||i===vd||i===gd)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===md)return s===Jn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===vd)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===gd)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===yd||i===xd||i===ql||i===_d)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===yd)return a.COMPRESSED_RED_RGTC1_EXT;if(i===xd)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ql)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===_d)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Co?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}var yb=`
|
|
4196
|
+
}`,ow=[new _e(1,0,0),new _e(-1,0,0),new _e(0,1,0),new _e(0,-1,0),new _e(0,0,1),new _e(0,0,-1)],lw=[new _e(0,-1,0),new _e(0,-1,0),new _e(0,0,1),new _e(0,0,-1),new _e(0,-1,0),new _e(0,-1,0)],k0=new Dn,Oc=new _e,Ep=new _e;function cw(n,e,t){let i=new nl,r=new Kt,a=new Kt,s=new Ti,o=new ld,u=new cd,l={},d=t.maxTextureSize,f={[Ya]:Fr,[Fr]:Ya,[Ir]:Ir},h=new na({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Kt},radius:{value:4}},vertexShader:aw,fragmentShader:sw}),p=h.clone();p.defines.HORIZONTAL_PASS=1;let y=new dr;y.setAttribute("position",new Ar(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let M=new li(y,h),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Tc;let m=this.type;this.render=function(b,z,T){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||b.length===0)return;this.type===wd&&(xn("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Tc);let D=n.getRenderTarget(),G=n.getActiveCubeFace(),F=n.getActiveMipmapLevel(),$=n.state;$.setBlending(qa),$.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 A=m!==this.type;A&&z.traverse(function(S){S.material&&(Array.isArray(S.material)?S.material.forEach(H=>H.needsUpdate=!0):S.material.needsUpdate=!0)});for(let S=0,H=b.length;S<H;S++){let Y=b[S],oe=Y.shadow;if(oe===void 0){xn("WebGLShadowMap:",Y,"has no shadow.");continue}if(oe.autoUpdate===!1&&oe.needsUpdate===!1)continue;r.copy(oe.mapSize);let O=oe.getFrameExtents();r.multiply(O),a.copy(oe.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/O.x),r.x=a.x*O.x,oe.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/O.y),r.y=a.y*O.y,oe.mapSize.y=a.y));let k=n.state.buffers.depth.getReversed();if(oe.camera._reversedDepth=k,oe.map===null||A===!0){if(oe.map!==null&&(oe.map.depthTexture!==null&&(oe.map.depthTexture.dispose(),oe.map.depthTexture=null),oe.map.dispose()),this.type===ul){if(Y.isPointLight){xn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}oe.map=new Gr(r.x,r.y,{format:Us,type:La,minFilter:cr,magFilter:cr,generateMipmaps:!1}),oe.map.texture.name=Y.name+".shadowMap",oe.map.depthTexture=new Cs(r.x,r.y,ra),oe.map.depthTexture.name=Y.name+".shadowMapDepth",oe.map.depthTexture.format=Ha,oe.map.depthTexture.compareFunction=null,oe.map.depthTexture.minFilter=tr,oe.map.depthTexture.magFilter=tr}else Y.isPointLight?(oe.map=new vf(r.x),oe.map.depthTexture=new ed(r.x,Pa)):(oe.map=new Gr(r.x,r.y),oe.map.depthTexture=new Cs(r.x,r.y,Pa)),oe.map.depthTexture.name=Y.name+".shadowMap",oe.map.depthTexture.format=Ha,this.type===Tc?(oe.map.depthTexture.compareFunction=k?hf:ff,oe.map.depthTexture.minFilter=cr,oe.map.depthTexture.magFilter=cr):(oe.map.depthTexture.compareFunction=null,oe.map.depthTexture.minFilter=tr,oe.map.depthTexture.magFilter=tr);oe.camera.updateProjectionMatrix()}oe.map.isWebGLCubeRenderTarget!==!0&&(oe.map.width!==r.x||oe.map.height!==r.y)&&oe.map.setSize(r.x,r.y);let ne=oe.map.isWebGLCubeRenderTarget?6:oe.getViewportCount();Y.isPointLight!==!0&&oe.updateMatrices(Y,T);for(let X=0;X<ne;X++){let K=oe.getCamera(X);if(Y.isPointLight){let ge=oe.camera,se=oe.matrix,Se=Y.distance||ge.far;Se!==ge.far&&(ge.far=Se,ge.updateProjectionMatrix()),Oc.setFromMatrixPosition(Y.matrixWorld),ge.position.copy(Oc),Ep.copy(ge.position),Ep.add(ow[X]),ge.up.copy(lw[X]),ge.lookAt(Ep),ge.updateMatrixWorld(),se.makeTranslation(-Oc.x,-Oc.y,-Oc.z),k0.multiplyMatrices(ge.projectionMatrix,ge.matrixWorldInverse),oe._frustum.setFromProjectionMatrix(k0,ge.coordinateSystem,ge.reversedDepth)}if(oe.map.isWebGLCubeRenderTarget)n.setRenderTarget(oe.map,X),n.clear();else{X===0&&(n.setRenderTarget(oe.map),n.clear());let ge=oe.getViewport(X);s.set(a.x*ge.x,a.y*ge.y,a.x*ge.z,a.y*ge.w),$.viewport(s)}i=oe.getFrustum(X),_(z,T,K,Y,this.type)}oe.isPointLightShadow!==!0&&this.type===ul&&N(oe,T),oe.needsUpdate=!1}m=this.type,v.needsUpdate=!1,n.setRenderTarget(D,G,F)};function N(b,z){let T=e.update(M);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null?b.mapPass=new Gr(r.x,r.y,{format:Us,type:La}):(b.mapPass.width!==b.map.width||b.mapPass.height!==b.map.height)&&b.mapPass.setSize(b.map.width,b.map.height),h.uniforms.shadow_pass.value=b.map.depthTexture,h.uniforms.resolution.value.set(b.map.width,b.map.height),h.uniforms.radius.value=b.radius,n.setRenderTarget(b.mapPass),n.clear(),n.renderBufferDirect(z,null,T,h,M,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value.set(b.map.width,b.map.height),p.uniforms.radius.value=b.radius,n.setRenderTarget(b.map),n.clear(),n.renderBufferDirect(z,null,T,p,M,null)}function P(b,z,T,D){let G=null,F=T.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(F!==void 0)G=F;else if(G=T.isPointLight===!0?u:o,n.localClippingEnabled&&z.clipShadows===!0&&Array.isArray(z.clippingPlanes)&&z.clippingPlanes.length!==0||z.displacementMap&&z.displacementScale!==0||z.alphaMap&&z.alphaTest>0||z.map&&z.alphaTest>0||z.alphaToCoverage===!0){let $=G.uuid,A=z.uuid,S=l[$];S===void 0&&(S={},l[$]=S);let H=S[A];H===void 0&&(H=G.clone(),S[A]=H,z.addEventListener("dispose",g)),G=H}if(G.visible=z.visible,G.wireframe=z.wireframe,D===ul?G.side=z.shadowSide!==null?z.shadowSide:z.side:G.side=z.shadowSide!==null?z.shadowSide:f[z.side],G.alphaMap=z.alphaMap,G.alphaTest=z.alphaToCoverage===!0?.5:z.alphaTest,G.map=z.map,G.clipShadows=z.clipShadows,G.clippingPlanes=z.clippingPlanes,G.clipIntersection=z.clipIntersection,G.displacementMap=z.displacementMap,G.displacementScale=z.displacementScale,G.displacementBias=z.displacementBias,G.wireframeLinewidth=z.wireframeLinewidth,G.linewidth=z.linewidth,T.isPointLight===!0&&G.isMeshDistanceMaterial===!0){let $=n.properties.get(G);$.light=T}return G}function _(b,z,T,D,G){if(b.visible===!1)return;if(b.layers.test(z.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&G===ul)&&(!b.frustumCulled||b.intersectsFrustum(i))){b.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,b.matrixWorld);let A=e.update(b),S=b.material;if(Array.isArray(S)){let H=A.groups;for(let Y=0,oe=H.length;Y<oe;Y++){let O=H[Y],k=S[O.materialIndex];if(k&&k.visible){let ne=P(b,k,D,G);b.onBeforeShadow(n,b,z,T,A,ne,O),n.renderBufferDirect(T,null,A,ne,b,O),b.onAfterShadow(n,b,z,T,A,ne,O)}}}else if(S.visible){let H=P(b,S,D,G);b.onBeforeShadow(n,b,z,T,A,H,null),n.renderBufferDirect(T,null,A,H,b,null),b.onAfterShadow(n,b,z,T,A,H,null)}}let $=b.children;for(let A=0,S=$.length;A<S;A++)_($[A],z,T,D,G)}function g(b){b.target.removeEventListener("dispose",g);for(let T in l){let D=l[T],G=b.target.uuid;G in D&&(D[G].dispose(),delete D[G])}}}function uw(n,e){function t(){let te=!1,at=new Ti,Ce=null,pt=new Ti(0,0,0,0);return{setMask:function(lt){Ce!==lt&&!te&&(n.colorMask(lt,lt,lt,lt),Ce=lt)},setLocked:function(lt){te=lt},setClear:function(lt,He,Zt,It,xt){xt===!0&&(lt*=It,He*=It,Zt*=It),at.set(lt,He,Zt,It),pt.equals(at)===!1&&(n.clearColor(lt,He,Zt,It),pt.copy(at))},reset:function(){te=!1,Ce=null,pt.set(-1,0,0,0)}}}function i(){let te=!1,at=!1,Ce=null,pt=null,lt=null;return{setReversed:function(He){if(at!==He){let Zt=e.get("EXT_clip_control");He?Zt.clipControlEXT(Zt.LOWER_LEFT_EXT,Zt.ZERO_TO_ONE_EXT):Zt.clipControlEXT(Zt.LOWER_LEFT_EXT,Zt.NEGATIVE_ONE_TO_ONE_EXT),at=He;let It=lt;lt=null,this.setClear(It)}},getReversed:function(){return at},setTest:function(He){He?ae(n.DEPTH_TEST):fe(n.DEPTH_TEST)},setMask:function(He){Ce!==He&&!te&&(n.depthMask(He),Ce=He)},setFunc:function(He){if(at&&(He=u0[He]),pt!==He){switch(He){case Gu:n.depthFunc(n.NEVER);break;case Hu:n.depthFunc(n.ALWAYS);break;case Wu:n.depthFunc(n.LESS);break;case Yo:n.depthFunc(n.LEQUAL);break;case Xu:n.depthFunc(n.EQUAL);break;case Yu:n.depthFunc(n.GEQUAL);break;case qu:n.depthFunc(n.GREATER);break;case Zu:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}pt=He}},setLocked:function(He){te=He},setClear:function(He){lt!==He&&(lt=He,at&&(He=1-He),n.clearDepth(He))},reset:function(){te=!1,Ce=null,pt=null,lt=null,at=!1}}}function r(){let te=!1,at=null,Ce=null,pt=null,lt=null,He=null,Zt=null,It=null,xt=null;return{setTest:function(kt){te||(kt?ae(n.STENCIL_TEST):fe(n.STENCIL_TEST))},setMask:function(kt){at!==kt&&!te&&(n.stencilMask(kt),at=kt)},setFunc:function(kt,ct,zt){(Ce!==kt||pt!==ct||lt!==zt)&&(n.stencilFunc(kt,ct,zt),Ce=kt,pt=ct,lt=zt)},setOp:function(kt,ct,zt){(He!==kt||Zt!==ct||It!==zt)&&(n.stencilOp(kt,ct,zt),He=kt,Zt=ct,It=zt)},setLocked:function(kt){te=kt},setClear:function(kt){xt!==kt&&(n.clearStencil(kt),xt=kt)},reset:function(){te=!1,at=null,Ce=null,pt=null,lt=null,He=null,Zt=null,It=null,xt=null}}}let a=new t,s=new i,o=new r,u=new WeakMap,l=new WeakMap,d={},f={},h={},p=new WeakMap,y=[],M=null,v=!1,m=null,N=null,P=null,_=null,g=null,b=null,z=null,T=new Cn(0,0,0),D=0,G=!1,F=null,$=null,A=null,S=null,H=null,Y=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),oe=!1,O=0,k=n.getParameter(n.VERSION);k.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(k)[1]),oe=O>=1):k.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),oe=O>=2);let ne=null,X={},K=n.getParameter(n.SCISSOR_BOX),ge=n.getParameter(n.VIEWPORT),se=new Ti().fromArray(K),Se=new Ti().fromArray(ge);function Pe(te,at,Ce,pt){let lt=new Uint8Array(4),He=n.createTexture();n.bindTexture(te,He),n.texParameteri(te,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(te,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Zt=0;Zt<Ce;Zt++)te===n.TEXTURE_3D||te===n.TEXTURE_2D_ARRAY?n.texImage3D(at,0,n.RGBA,1,1,pt,0,n.RGBA,n.UNSIGNED_BYTE,lt):n.texImage2D(at+Zt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,lt);return He}let le={};le[n.TEXTURE_2D]=Pe(n.TEXTURE_2D,n.TEXTURE_2D,1),le[n.TEXTURE_CUBE_MAP]=Pe(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[n.TEXTURE_2D_ARRAY]=Pe(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),le[n.TEXTURE_3D]=Pe(n.TEXTURE_3D,n.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ae(n.DEPTH_TEST),s.setFunc(Yo),tt(!1),st(Xh),ae(n.CULL_FACE),qe(qa);function ae(te){d[te]!==!0&&(n.enable(te),d[te]=!0)}function fe(te){d[te]!==!1&&(n.disable(te),d[te]=!1)}function Ne(te,at){return h[te]!==at?(n.bindFramebuffer(te,at),h[te]=at,te===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=at),te===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=at),!0):!1}function Re(te,at){let Ce=y,pt=!1;if(te){Ce=p.get(at),Ce===void 0&&(Ce=[],p.set(at,Ce));let lt=te.textures;if(Ce.length!==lt.length||Ce[0]!==n.COLOR_ATTACHMENT0){for(let He=0,Zt=lt.length;He<Zt;He++)Ce[He]=n.COLOR_ATTACHMENT0+He;Ce.length=lt.length,pt=!0}}else Ce[0]!==n.BACK&&(Ce[0]=n.BACK,pt=!0);pt&&n.drawBuffers(Ce)}function We(te){return M!==te?(n.useProgram(te),M=te,!0):!1}let Qe={[oo]:n.FUNC_ADD,[Pv]:n.FUNC_SUBTRACT,[Lv]:n.FUNC_REVERSE_SUBTRACT};Qe[Dv]=n.MIN,Qe[Nv]=n.MAX;let ke={[Uv]:n.ZERO,[Fv]:n.ONE,[Ov]:n.SRC_COLOR,[Jh]:n.SRC_ALPHA,[Hv]:n.SRC_ALPHA_SATURATE,[Vv]:n.DST_COLOR,[kv]:n.DST_ALPHA,[Bv]:n.ONE_MINUS_SRC_COLOR,[$h]:n.ONE_MINUS_SRC_ALPHA,[Gv]:n.ONE_MINUS_DST_COLOR,[zv]:n.ONE_MINUS_DST_ALPHA,[Wv]:n.CONSTANT_COLOR,[Xv]:n.ONE_MINUS_CONSTANT_COLOR,[Yv]:n.CONSTANT_ALPHA,[qv]:n.ONE_MINUS_CONSTANT_ALPHA};function qe(te,at,Ce,pt,lt,He,Zt,It,xt,kt){if(te===qa){v===!0&&(fe(n.BLEND),v=!1);return}if(v===!1&&(ae(n.BLEND),v=!0),te!==Rv){if(te!==m||kt!==G){if((N!==oo||g!==oo)&&(n.blendEquation(n.FUNC_ADD),N=oo,g=oo),kt)switch(te){case dl:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Yh:n.blendFunc(n.ONE,n.ONE);break;case qh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Zh:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:Tn("WebGLState: Invalid blending: ",te);break}else switch(te){case dl:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Yh:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case qh:Tn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Zh:Tn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Tn("WebGLState: Invalid blending: ",te);break}P=null,_=null,b=null,z=null,T.set(0,0,0),D=0,m=te,G=kt}return}lt=lt||at,He=He||Ce,Zt=Zt||pt,(at!==N||lt!==g)&&(n.blendEquationSeparate(Qe[at],Qe[lt]),N=at,g=lt),(Ce!==P||pt!==_||He!==b||Zt!==z)&&(n.blendFuncSeparate(ke[Ce],ke[pt],ke[He],ke[Zt]),P=Ce,_=pt,b=He,z=Zt),(It.equals(T)===!1||xt!==D)&&(n.blendColor(It.r,It.g,It.b,xt),T.copy(It),D=xt),m=te,G=!1}function ft(te,at){te.side===Ir?fe(n.CULL_FACE):ae(n.CULL_FACE);let Ce=te.side===Fr;at&&(Ce=!Ce),tt(Ce),te.blending===dl&&te.transparent===!1?qe(qa):qe(te.blending,te.blendEquation,te.blendSrc,te.blendDst,te.blendEquationAlpha,te.blendSrcAlpha,te.blendDstAlpha,te.blendColor,te.blendAlpha,te.premultipliedAlpha),s.setFunc(te.depthFunc),s.setTest(te.depthTest),s.setMask(te.depthWrite),a.setMask(te.colorWrite);let pt=te.stencilWrite;o.setTest(pt),pt&&(o.setMask(te.stencilWriteMask),o.setFunc(te.stencilFunc,te.stencilRef,te.stencilFuncMask),o.setOp(te.stencilFail,te.stencilZFail,te.stencilZPass)),en(te.polygonOffset,te.polygonOffsetFactor,te.polygonOffsetUnits),te.alphaToCoverage===!0?ae(n.SAMPLE_ALPHA_TO_COVERAGE):fe(n.SAMPLE_ALPHA_TO_COVERAGE)}function tt(te){F!==te&&(te?n.frontFace(n.CW):n.frontFace(n.CCW),F=te)}function st(te){te!==Iv?(ae(n.CULL_FACE),te!==$&&(te===Xh?n.cullFace(n.BACK):te===Cv?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):fe(n.CULL_FACE),$=te}function Ke(te){te!==A&&(oe&&n.lineWidth(te),A=te)}function en(te,at,Ce){te?(ae(n.POLYGON_OFFSET_FILL),(S!==at||H!==Ce)&&(S=at,H=Ce,s.getReversed()&&(at=-at),n.polygonOffset(at,Ce))):fe(n.POLYGON_OFFSET_FILL)}function nt(te){te?ae(n.SCISSOR_TEST):fe(n.SCISSOR_TEST)}function on(te){te===void 0&&(te=n.TEXTURE0+Y-1),ne!==te&&(n.activeTexture(te),ne=te)}function ue(te,at,Ce){Ce===void 0&&(ne===null?Ce=n.TEXTURE0+Y-1:Ce=ne);let pt=X[Ce];pt===void 0&&(pt={type:void 0,texture:void 0},X[Ce]=pt),(pt.type!==te||pt.texture!==at)&&(ne!==Ce&&(n.activeTexture(Ce),ne=Ce),n.bindTexture(te,at||le[te]),pt.type=te,pt.texture=at)}function hn(){let te=X[ne];te!==void 0&&te.type!==void 0&&(n.bindTexture(te.type,null),te.type=void 0,te.texture=void 0)}function gn(){try{n.compressedTexImage2D(...arguments)}catch(te){Tn("WebGLState:",te)}}function J(){try{n.compressedTexImage3D(...arguments)}catch(te){Tn("WebGLState:",te)}}function w(){try{n.texSubImage2D(...arguments)}catch(te){Tn("WebGLState:",te)}}function ie(){try{n.texSubImage3D(...arguments)}catch(te){Tn("WebGLState:",te)}}function ye(){try{n.compressedTexSubImage2D(...arguments)}catch(te){Tn("WebGLState:",te)}}function Ae(){try{n.compressedTexSubImage3D(...arguments)}catch(te){Tn("WebGLState:",te)}}function Xe(){try{n.texStorage2D(...arguments)}catch(te){Tn("WebGLState:",te)}}function Je(){try{n.texStorage3D(...arguments)}catch(te){Tn("WebGLState:",te)}}function Te(){try{n.texImage2D(...arguments)}catch(te){Tn("WebGLState:",te)}}function Ie(){try{n.texImage3D(...arguments)}catch(te){Tn("WebGLState:",te)}}function ot(te){return f[te]!==void 0?f[te]:n.getParameter(te)}function yt(te,at){f[te]!==at&&(n.pixelStorei(te,at),f[te]=at)}function ht(te){se.equals(te)===!1&&(n.scissor(te.x,te.y,te.z,te.w),se.copy(te))}function rt(te){Se.equals(te)===!1&&(n.viewport(te.x,te.y,te.z,te.w),Se.copy(te))}function Lt(te,at){let Ce=l.get(at);Ce===void 0&&(Ce=new WeakMap,l.set(at,Ce));let pt=Ce.get(te);pt===void 0&&(pt=n.getUniformBlockIndex(at,te.name),Ce.set(te,pt))}function Bt(te,at){let pt=l.get(at).get(te);u.get(at)!==pt&&(n.uniformBlockBinding(at,pt,te.__bindingPointIndex),u.set(at,pt))}function qt(){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={},ne=null,X={},h={},p=new WeakMap,y=[],M=null,v=!1,m=null,N=null,P=null,_=null,g=null,b=null,z=null,T=new Cn(0,0,0),D=0,G=!1,F=null,$=null,A=null,S=null,H=null,se.set(0,0,n.canvas.width,n.canvas.height),Se.set(0,0,n.canvas.width,n.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:ae,disable:fe,bindFramebuffer:Ne,drawBuffers:Re,useProgram:We,setBlending:qe,setMaterial:ft,setFlipSided:tt,setCullFace:st,setLineWidth:Ke,setPolygonOffset:en,setScissorTest:nt,activeTexture:on,bindTexture:ue,unbindTexture:hn,compressedTexImage2D:gn,compressedTexImage3D:J,texImage2D:Te,texImage3D:Ie,pixelStorei:yt,getParameter:ot,updateUBOMapping:Lt,uniformBlockBinding:Bt,texStorage2D:Xe,texStorage3D:Je,texSubImage2D:w,texSubImage3D:ie,compressedTexSubImage2D:ye,compressedTexSubImage3D:Ae,scissor:ht,viewport:rt,reset:qt}}function dw(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 Kt,d=new WeakMap,f=new Set,h,p=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(J,w){return y?new OffscreenCanvas(J,w):tc("canvas")}function v(J,w,ie){let ye=1,Ae=gn(J);if((Ae.width>ie||Ae.height>ie)&&(ye=ie/Math.max(Ae.width,Ae.height)),ye<1)if(typeof HTMLImageElement<"u"&&J instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&J instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&J instanceof ImageBitmap||typeof VideoFrame<"u"&&J instanceof VideoFrame){let Xe=Math.floor(ye*Ae.width),Je=Math.floor(ye*Ae.height);h===void 0&&(h=M(Xe,Je));let Te=w?M(Xe,Je):h;return Te.width=Xe,Te.height=Je,Te.getContext("2d").drawImage(J,0,0,Xe,Je),xn("WebGLRenderer: Texture has been resized from ("+Ae.width+"x"+Ae.height+") to ("+Xe+"x"+Je+")."),Te}else return"data"in J&&xn("WebGLRenderer: Image in DataTexture is too big ("+Ae.width+"x"+Ae.height+")."),J;return J}function m(J){return J.generateMipmaps}function N(J){n.generateMipmap(J)}function P(J){return J.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:J.isWebGL3DRenderTarget?n.TEXTURE_3D:J.isWebGLArrayRenderTarget||J.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function _(J,w,ie,ye,Ae,Xe=!1){if(J!==null){if(n[J]!==void 0)return n[J];xn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+J+"'")}let Je;ye&&(Je=e.get("EXT_texture_norm16"),Je||xn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Te=w;if(w===n.RED&&(ie===n.FLOAT&&(Te=n.R32F),ie===n.HALF_FLOAT&&(Te=n.R16F),ie===n.UNSIGNED_BYTE&&(Te=n.R8),ie===n.UNSIGNED_SHORT&&Je&&(Te=Je.R16_EXT),ie===n.SHORT&&Je&&(Te=Je.R16_SNORM_EXT)),w===n.RED_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Te=n.R8UI),ie===n.UNSIGNED_SHORT&&(Te=n.R16UI),ie===n.UNSIGNED_INT&&(Te=n.R32UI),ie===n.BYTE&&(Te=n.R8I),ie===n.SHORT&&(Te=n.R16I),ie===n.INT&&(Te=n.R32I)),w===n.RG&&(ie===n.FLOAT&&(Te=n.RG32F),ie===n.HALF_FLOAT&&(Te=n.RG16F),ie===n.UNSIGNED_BYTE&&(Te=n.RG8),ie===n.UNSIGNED_SHORT&&Je&&(Te=Je.RG16_EXT),ie===n.SHORT&&Je&&(Te=Je.RG16_SNORM_EXT)),w===n.RG_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Te=n.RG8UI),ie===n.UNSIGNED_SHORT&&(Te=n.RG16UI),ie===n.UNSIGNED_INT&&(Te=n.RG32UI),ie===n.BYTE&&(Te=n.RG8I),ie===n.SHORT&&(Te=n.RG16I),ie===n.INT&&(Te=n.RG32I)),w===n.RGB_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Te=n.RGB8UI),ie===n.UNSIGNED_SHORT&&(Te=n.RGB16UI),ie===n.UNSIGNED_INT&&(Te=n.RGB32UI),ie===n.BYTE&&(Te=n.RGB8I),ie===n.SHORT&&(Te=n.RGB16I),ie===n.INT&&(Te=n.RGB32I)),w===n.RGBA_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Te=n.RGBA8UI),ie===n.UNSIGNED_SHORT&&(Te=n.RGBA16UI),ie===n.UNSIGNED_INT&&(Te=n.RGBA32UI),ie===n.BYTE&&(Te=n.RGBA8I),ie===n.SHORT&&(Te=n.RGBA16I),ie===n.INT&&(Te=n.RGBA32I)),w===n.RGB&&(ie===n.UNSIGNED_SHORT&&Je&&(Te=Je.RGB16_EXT),ie===n.SHORT&&Je&&(Te=Je.RGB16_SNORM_EXT),ie===n.UNSIGNED_INT_5_9_9_9_REV&&(Te=n.RGB9_E5),ie===n.UNSIGNED_INT_10F_11F_11F_REV&&(Te=n.R11F_G11F_B10F)),w===n.RGBA){let Ie=Xe?ec:ni.getTransfer(Ae);ie===n.FLOAT&&(Te=n.RGBA32F),ie===n.HALF_FLOAT&&(Te=n.RGBA16F),ie===n.UNSIGNED_BYTE&&(Te=Ie===_i?n.SRGB8_ALPHA8:n.RGBA8),ie===n.UNSIGNED_SHORT&&Je&&(Te=Je.RGBA16_EXT),ie===n.SHORT&&Je&&(Te=Je.RGBA16_SNORM_EXT),ie===n.UNSIGNED_SHORT_4_4_4_4&&(Te=n.RGBA4),ie===n.UNSIGNED_SHORT_5_5_5_1&&(Te=n.RGB5_A1)}return(Te===n.R16F||Te===n.R32F||Te===n.RG16F||Te===n.RG32F||Te===n.RGBA16F||Te===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Te}function g(J,w){let ie;return J?w===null||w===Pa||w===ml?ie=n.DEPTH24_STENCIL8:w===ra?ie=n.DEPTH32F_STENCIL8:w===pl&&(ie=n.DEPTH24_STENCIL8,xn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===Pa||w===ml?ie=n.DEPTH_COMPONENT24:w===ra?ie=n.DEPTH_COMPONENT32F:w===pl&&(ie=n.DEPTH_COMPONENT16),ie}function b(J,w){return m(J)===!0||J.isFramebufferTexture&&J.minFilter!==tr&&J.minFilter!==cr?Math.log2(Math.max(w.width,w.height))+1:J.mipmaps!==void 0&&J.mipmaps.length>0?J.mipmaps.length:J.isCompressedTexture&&Array.isArray(J.image)?w.mipmaps.length:1}function z(J){let w=J.target;w.removeEventListener("dispose",z),D(w),w.isVideoTexture&&d.delete(w),w.isHTMLTexture&&f.delete(w)}function T(J){let w=J.target;w.removeEventListener("dispose",T),F(w)}function D(J){let w=i.get(J);if(w.__webglInit===void 0)return;let ie=J.source,ye=p.get(ie);if(ye){let Ae=ye[w.__cacheKey];Ae.usedTimes--,Ae.usedTimes===0&&G(J),Object.keys(ye).length===0&&p.delete(ie)}i.remove(J)}function G(J){let w=i.get(J);n.deleteTexture(w.__webglTexture);let ie=J.source,ye=p.get(ie);delete ye[w.__cacheKey],s.memory.textures--}function F(J){let w=i.get(J);if(J.depthTexture&&(J.depthTexture.dispose(),i.remove(J.depthTexture)),J.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(w.__webglFramebuffer[ye]))for(let Ae=0;Ae<w.__webglFramebuffer[ye].length;Ae++)n.deleteFramebuffer(w.__webglFramebuffer[ye][Ae]);else n.deleteFramebuffer(w.__webglFramebuffer[ye]);w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer[ye])}else{if(Array.isArray(w.__webglFramebuffer))for(let ye=0;ye<w.__webglFramebuffer.length;ye++)n.deleteFramebuffer(w.__webglFramebuffer[ye]);else n.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&n.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let ye=0;ye<w.__webglColorRenderbuffer.length;ye++)w.__webglColorRenderbuffer[ye]&&n.deleteRenderbuffer(w.__webglColorRenderbuffer[ye]);w.__webglDepthRenderbuffer&&n.deleteRenderbuffer(w.__webglDepthRenderbuffer)}let ie=J.textures;for(let ye=0,Ae=ie.length;ye<Ae;ye++){let Xe=i.get(ie[ye]);Xe.__webglTexture&&(n.deleteTexture(Xe.__webglTexture),s.memory.textures--),i.remove(ie[ye])}i.remove(J)}let $=0;function A(){$=0}function S(){return $}function H(J){$=J}function Y(){let J=$;return J>=r.maxTextures&&xn("WebGLTextures: Trying to use "+(J+1)+" texture units while this GPU supports only "+r.maxTextures),$+=1,J}function oe(J){let w=[];return w.push(J.wrapS),w.push(J.wrapT),w.push(J.wrapR||0),w.push(J.magFilter),w.push(J.minFilter),w.push(J.anisotropy),w.push(J.internalFormat),w.push(J.format),w.push(J.type),w.push(J.generateMipmaps),w.push(J.premultiplyAlpha),w.push(J.flipY),w.push(J.unpackAlignment),w.push(J.colorSpace),w.join()}function O(J,w){let ie=i.get(J);if(J.isVideoTexture&&ue(J),J.isRenderTargetTexture===!1&&J.isExternalTexture!==!0&&J.version>0&&ie.__version!==J.version){let ye=J.image;if(ye===null)xn("WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)xn("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(ie,J,w);return}}else J.isExternalTexture&&(ie.__webglTexture=J.sourceTexture?J.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ie.__webglTexture,n.TEXTURE0+w)}function k(J,w){let ie=i.get(J);if(J.isRenderTargetTexture===!1&&J.version>0&&ie.__version!==J.version){fe(ie,J,w);return}else J.isExternalTexture&&(ie.__webglTexture=J.sourceTexture?J.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ie.__webglTexture,n.TEXTURE0+w)}function ne(J,w){let ie=i.get(J);if(J.isRenderTargetTexture===!1&&J.version>0&&ie.__version!==J.version){fe(ie,J,w);return}t.bindTexture(n.TEXTURE_3D,ie.__webglTexture,n.TEXTURE0+w)}function X(J,w){let ie=i.get(J);if(J.isCubeDepthTexture!==!0&&J.version>0&&ie.__version!==J.version){Ne(ie,J,w);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ie.__webglTexture,n.TEXTURE0+w)}let K={[As]:n.REPEAT,[va]:n.CLAMP_TO_EDGE,[qo]:n.MIRRORED_REPEAT},ge={[tr]:n.NEAREST,[Ad]:n.NEAREST_MIPMAP_NEAREST,[co]:n.NEAREST_MIPMAP_LINEAR,[cr]:n.LINEAR,[hl]:n.LINEAR_MIPMAP_NEAREST,[Za]:n.LINEAR_MIPMAP_LINEAR},se={[e0]:n.NEVER,[a0]:n.ALWAYS,[t0]:n.LESS,[ff]:n.LEQUAL,[n0]:n.EQUAL,[hf]:n.GEQUAL,[i0]:n.GREATER,[r0]:n.NOTEQUAL};function Se(J,w){if(w.type===ra&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===cr||w.magFilter===hl||w.magFilter===co||w.magFilter===Za||w.minFilter===cr||w.minFilter===hl||w.minFilter===co||w.minFilter===Za)&&xn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(J,n.TEXTURE_WRAP_S,K[w.wrapS]),n.texParameteri(J,n.TEXTURE_WRAP_T,K[w.wrapT]),(J===n.TEXTURE_3D||J===n.TEXTURE_2D_ARRAY)&&n.texParameteri(J,n.TEXTURE_WRAP_R,K[w.wrapR]),n.texParameteri(J,n.TEXTURE_MAG_FILTER,ge[w.magFilter]),n.texParameteri(J,n.TEXTURE_MIN_FILTER,ge[w.minFilter]),w.compareFunction&&(n.texParameteri(J,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(J,n.TEXTURE_COMPARE_FUNC,se[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===tr||w.minFilter!==co&&w.minFilter!==Za||w.type===ra&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||i.get(w).__currentAnisotropy){let ie=e.get("EXT_texture_filter_anisotropic");n.texParameterf(J,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,r.getMaxAnisotropy())),i.get(w).__currentAnisotropy=w.anisotropy}}}function Pe(J,w){let ie=!1;J.__webglInit===void 0&&(J.__webglInit=!0,w.addEventListener("dispose",z));let ye=w.source,Ae=p.get(ye);Ae===void 0&&(Ae={},p.set(ye,Ae));let Xe=oe(w);if(Xe!==J.__cacheKey){Ae[Xe]===void 0&&(Ae[Xe]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ie=!0),Ae[Xe].usedTimes++;let Je=Ae[J.__cacheKey];Je!==void 0&&(Ae[J.__cacheKey].usedTimes--,Je.usedTimes===0&&G(w)),J.__cacheKey=Xe,J.__webglTexture=Ae[Xe].texture}return ie}function le(J,w,ie){return Math.floor(Math.floor(J/ie)/w)}function ae(J,w,ie,ye){let Xe=J.updateRanges;if(Xe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,w.width,w.height,ie,ye,w.data);else{Xe.sort((yt,ht)=>yt.start-ht.start);let Je=0;for(let yt=1;yt<Xe.length;yt++){let ht=Xe[Je],rt=Xe[yt],Lt=ht.start+ht.count,Bt=le(rt.start,w.width,4),qt=le(ht.start,w.width,4);rt.start<=Lt+1&&Bt===qt&&le(rt.start+rt.count-1,w.width,4)===Bt?ht.count=Math.max(ht.count,rt.start+rt.count-ht.start):(++Je,Xe[Je]=rt)}Xe.length=Je+1;let Te=t.getParameter(n.UNPACK_ROW_LENGTH),Ie=t.getParameter(n.UNPACK_SKIP_PIXELS),ot=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,w.width);for(let yt=0,ht=Xe.length;yt<ht;yt++){let rt=Xe[yt],Lt=Math.floor(rt.start/4),Bt=Math.ceil(rt.count/4),qt=Lt%w.width,te=Math.floor(Lt/w.width),at=Bt,Ce=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,qt),t.pixelStorei(n.UNPACK_SKIP_ROWS,te),t.texSubImage2D(n.TEXTURE_2D,0,qt,te,at,Ce,ie,ye,w.data)}J.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,Te),t.pixelStorei(n.UNPACK_SKIP_PIXELS,Ie),t.pixelStorei(n.UNPACK_SKIP_ROWS,ot)}}function fe(J,w,ie){let ye=n.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(ye=n.TEXTURE_2D_ARRAY),w.isData3DTexture&&(ye=n.TEXTURE_3D);let Ae=Pe(J,w),Xe=w.source;t.bindTexture(ye,J.__webglTexture,n.TEXTURE0+ie);let Je=i.get(Xe);if(Xe.version!==Je.__version||Ae===!0){if(t.activeTexture(n.TEXTURE0+ie),(typeof ImageBitmap<"u"&&w.image instanceof ImageBitmap)===!1){let Ce=ni.getPrimaries(ni.workingColorSpace),pt=w.colorSpace===Or?null:ni.getPrimaries(w.colorSpace),lt=w.colorSpace===Or||Ce===pt?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,lt)}t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment);let Ie=v(w.image,!1,r.maxTextureSize);Ie=hn(w,Ie);let ot=a.convert(w.format,w.colorSpace),yt=a.convert(w.type),ht=_(w.internalFormat,ot,yt,w.normalized,w.colorSpace,w.isVideoTexture);Se(ye,w);let rt,Lt=w.mipmaps,Bt=w.isVideoTexture!==!0,qt=Je.__version===void 0||Ae===!0,te=Xe.dataReady,at=b(w,Ie);if(w.isDepthTexture)ht=g(w.format===Ns,w.type),qt&&(Bt?t.texStorage2D(n.TEXTURE_2D,1,ht,Ie.width,Ie.height):t.texImage2D(n.TEXTURE_2D,0,ht,Ie.width,Ie.height,0,ot,yt,null));else if(w.isDataTexture)if(Lt.length>0){Bt&&qt&&t.texStorage2D(n.TEXTURE_2D,at,ht,Lt[0].width,Lt[0].height);for(let Ce=0,pt=Lt.length;Ce<pt;Ce++)rt=Lt[Ce],Bt?te&&t.texSubImage2D(n.TEXTURE_2D,Ce,0,0,rt.width,rt.height,ot,yt,rt.data):t.texImage2D(n.TEXTURE_2D,Ce,ht,rt.width,rt.height,0,ot,yt,rt.data);w.generateMipmaps=!1}else Bt?(qt&&t.texStorage2D(n.TEXTURE_2D,at,ht,Ie.width,Ie.height),te&&ae(w,Ie,ot,yt)):t.texImage2D(n.TEXTURE_2D,0,ht,Ie.width,Ie.height,0,ot,yt,Ie.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){Bt&&qt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,at,ht,Lt[0].width,Lt[0].height,Ie.depth);for(let Ce=0,pt=Lt.length;Ce<pt;Ce++)if(rt=Lt[Ce],w.format!==aa)if(ot!==null)if(Bt){if(te)if(w.layerUpdates.size>0){let lt=mp(rt.width,rt.height,w.format,w.type);for(let He of w.layerUpdates){let Zt=rt.data.subarray(He*lt/rt.data.BYTES_PER_ELEMENT,(He+1)*lt/rt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ce,0,0,He,rt.width,rt.height,1,ot,Zt)}}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ce,0,0,0,rt.width,rt.height,Ie.depth,ot,rt.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Ce,ht,rt.width,rt.height,Ie.depth,0,rt.data,0,0);else xn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Bt?te&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Ce,0,0,0,rt.width,rt.height,Ie.depth,ot,yt,rt.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Ce,ht,rt.width,rt.height,Ie.depth,0,ot,yt,rt.data);w.layerUpdates.size>0&&w.clearLayerUpdates()}else{Bt&&qt&&t.texStorage2D(n.TEXTURE_2D,at,ht,Lt[0].width,Lt[0].height);for(let Ce=0,pt=Lt.length;Ce<pt;Ce++)rt=Lt[Ce],w.format!==aa?ot!==null?Bt?te&&t.compressedTexSubImage2D(n.TEXTURE_2D,Ce,0,0,rt.width,rt.height,ot,rt.data):t.compressedTexImage2D(n.TEXTURE_2D,Ce,ht,rt.width,rt.height,0,rt.data):xn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Bt?te&&t.texSubImage2D(n.TEXTURE_2D,Ce,0,0,rt.width,rt.height,ot,yt,rt.data):t.texImage2D(n.TEXTURE_2D,Ce,ht,rt.width,rt.height,0,ot,yt,rt.data)}else if(w.isDataArrayTexture)if(Bt){if(qt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,at,ht,Ie.width,Ie.height,Ie.depth),te)if(w.layerUpdates.size>0){let Ce=mp(Ie.width,Ie.height,w.format,w.type);for(let pt of w.layerUpdates){let lt=Ie.data.subarray(pt*Ce/Ie.data.BYTES_PER_ELEMENT,(pt+1)*Ce/Ie.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,pt,Ie.width,Ie.height,1,ot,yt,lt)}w.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ie.width,Ie.height,Ie.depth,ot,yt,Ie.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ht,Ie.width,Ie.height,Ie.depth,0,ot,yt,Ie.data);else if(w.isData3DTexture)Bt?(qt&&t.texStorage3D(n.TEXTURE_3D,at,ht,Ie.width,Ie.height,Ie.depth),te&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ie.width,Ie.height,Ie.depth,ot,yt,Ie.data)):t.texImage3D(n.TEXTURE_3D,0,ht,Ie.width,Ie.height,Ie.depth,0,ot,yt,Ie.data);else if(w.isFramebufferTexture){if(qt)if(Bt)t.texStorage2D(n.TEXTURE_2D,at,ht,Ie.width,Ie.height);else{let Ce=Ie.width,pt=Ie.height;for(let lt=0;lt<at;lt++)t.texImage2D(n.TEXTURE_2D,lt,ht,Ce,pt,0,ot,yt,null),Ce>>=1,pt>>=1}}else if(w.isHTMLTexture){if("texElementImage2D"in n){let Ce=n.canvas;if(Ce.hasAttribute("layoutsubtree")||Ce.setAttribute("layoutsubtree","true"),Ie.parentNode!==Ce){Ce.appendChild(Ie),f.add(w),Ce.onpaint=pt=>{let lt=pt.changedElements;for(let He of f)lt.includes(He.image)&&(He.needsUpdate=!0)},Ce.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Ie);else{let lt=n.RGBA,He=n.RGBA,Zt=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,lt,He,Zt,Ie)}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(Lt.length>0){if(Bt&&qt){let Ce=gn(Lt[0]);t.texStorage2D(n.TEXTURE_2D,at,ht,Ce.width,Ce.height)}for(let Ce=0,pt=Lt.length;Ce<pt;Ce++)rt=Lt[Ce],Bt?te&&t.texSubImage2D(n.TEXTURE_2D,Ce,0,0,ot,yt,rt):t.texImage2D(n.TEXTURE_2D,Ce,ht,ot,yt,rt);w.generateMipmaps=!1}else if(Bt){if(qt){let Ce=gn(Ie);t.texStorage2D(n.TEXTURE_2D,at,ht,Ce.width,Ce.height)}te&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ot,yt,Ie)}else t.texImage2D(n.TEXTURE_2D,0,ht,ot,yt,Ie);m(w)&&N(ye),Je.__version=Xe.version,w.onUpdate&&w.onUpdate(w)}J.__version=w.version}function Ne(J,w,ie){if(w.image.length!==6)return;let ye=Pe(J,w),Ae=w.source;t.bindTexture(n.TEXTURE_CUBE_MAP,J.__webglTexture,n.TEXTURE0+ie);let Xe=i.get(Ae);if(Ae.version!==Xe.__version||ye===!0){t.activeTexture(n.TEXTURE0+ie);let Je=ni.getPrimaries(ni.workingColorSpace),Te=w.colorSpace===Or?null:ni.getPrimaries(w.colorSpace),Ie=w.colorSpace===Or||Je===Te?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ie);let ot=w.isCompressedTexture||w.image[0].isCompressedTexture,yt=w.image[0]&&w.image[0].isDataTexture,ht=[];for(let He=0;He<6;He++)!ot&&!yt?ht[He]=v(w.image[He],!0,r.maxCubemapSize):ht[He]=yt?w.image[He].image:w.image[He],ht[He]=hn(w,ht[He]);let rt=ht[0],Lt=a.convert(w.format,w.colorSpace),Bt=a.convert(w.type),qt=_(w.internalFormat,Lt,Bt,w.normalized,w.colorSpace),te=w.isVideoTexture!==!0,at=Xe.__version===void 0||ye===!0,Ce=Ae.dataReady,pt=b(w,rt);Se(n.TEXTURE_CUBE_MAP,w);let lt;if(ot){te&&at&&t.texStorage2D(n.TEXTURE_CUBE_MAP,pt,qt,rt.width,rt.height);for(let He=0;He<6;He++){lt=ht[He].mipmaps;for(let Zt=0;Zt<lt.length;Zt++){let It=lt[Zt];w.format!==aa?Lt!==null?te?Ce&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt,0,0,It.width,It.height,Lt,It.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt,qt,It.width,It.height,0,It.data):xn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):te?Ce&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt,0,0,It.width,It.height,Lt,Bt,It.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt,qt,It.width,It.height,0,Lt,Bt,It.data)}}}else{if(lt=w.mipmaps,te&&at){lt.length>0&&pt++;let He=gn(ht[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,pt,qt,He.width,He.height)}for(let He=0;He<6;He++)if(yt){te?Ce&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,0,0,ht[He].width,ht[He].height,Lt,Bt,ht[He].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,qt,ht[He].width,ht[He].height,0,Lt,Bt,ht[He].data);for(let Zt=0;Zt<lt.length;Zt++){let xt=lt[Zt].image[He].image;te?Ce&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt+1,0,0,xt.width,xt.height,Lt,Bt,xt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt+1,qt,xt.width,xt.height,0,Lt,Bt,xt.data)}}else{te?Ce&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,0,0,Lt,Bt,ht[He]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,qt,Lt,Bt,ht[He]);for(let Zt=0;Zt<lt.length;Zt++){let It=lt[Zt];te?Ce&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt+1,0,0,Lt,Bt,It.image[He]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Zt+1,qt,Lt,Bt,It.image[He])}}}m(w)&&N(n.TEXTURE_CUBE_MAP),Xe.__version=Ae.version,w.onUpdate&&w.onUpdate(w)}J.__version=w.version}function Re(J,w,ie,ye,Ae,Xe){let Je=a.convert(ie.format,ie.colorSpace),Te=a.convert(ie.type),Ie=_(ie.internalFormat,Je,Te,ie.normalized,ie.colorSpace),ot=i.get(w),yt=i.get(ie);if(yt.__renderTarget=w,!ot.__hasExternalTextures){let ht=Math.max(1,w.width>>Xe),rt=Math.max(1,w.height>>Xe);Ae===n.TEXTURE_3D||Ae===n.TEXTURE_2D_ARRAY?t.texImage3D(Ae,Xe,Ie,ht,rt,w.depth,0,Je,Te,null):t.texImage2D(Ae,Xe,Ie,ht,rt,0,Je,Te,null)}t.bindFramebuffer(n.FRAMEBUFFER,J),on(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ye,Ae,yt.__webglTexture,0,nt(w)):(Ae===n.TEXTURE_2D||Ae>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Ae<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ye,Ae,yt.__webglTexture,Xe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function We(J,w,ie){if(n.bindRenderbuffer(n.RENDERBUFFER,J),w.depthBuffer){let ye=w.depthTexture,Ae=ye&&ye.isDepthTexture?ye.type:null,Xe=g(w.stencilBuffer,Ae),Je=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;on(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,nt(w),Xe,w.width,w.height):ie?n.renderbufferStorageMultisample(n.RENDERBUFFER,nt(w),Xe,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,Xe,w.width,w.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Je,n.RENDERBUFFER,J)}else{let ye=w.textures;for(let Ae=0;Ae<ye.length;Ae++){let Xe=ye[Ae],Je=a.convert(Xe.format,Xe.colorSpace),Te=a.convert(Xe.type),Ie=_(Xe.internalFormat,Je,Te,Xe.normalized,Xe.colorSpace);on(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,nt(w),Ie,w.width,w.height):ie?n.renderbufferStorageMultisample(n.RENDERBUFFER,nt(w),Ie,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,Ie,w.width,w.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Qe(J,w,ie){let ye=w.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,J),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let Ae=i.get(w.depthTexture);if(Ae.__renderTarget=w,(!Ae.__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),ye){if(Ae.__webglInit===void 0&&(Ae.__webglInit=!0,w.depthTexture.addEventListener("dispose",z)),Ae.__webglTexture===void 0){Ae.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,Ae.__webglTexture),Se(n.TEXTURE_CUBE_MAP,w.depthTexture);let ot=a.convert(w.depthTexture.format),yt=a.convert(w.depthTexture.type),ht;w.depthTexture.format===Ha?ht=n.DEPTH_COMPONENT24:w.depthTexture.format===Ns&&(ht=n.DEPTH24_STENCIL8);for(let rt=0;rt<6;rt++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+rt,0,ht,w.width,w.height,0,ot,yt,null)}}else O(w.depthTexture,0);let Xe=Ae.__webglTexture,Je=nt(w),Te=ye?n.TEXTURE_CUBE_MAP_POSITIVE_X+ie:n.TEXTURE_2D,Ie=w.depthTexture.format===Ns?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(w.depthTexture.format===Ha)on(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ie,Te,Xe,0,Je):n.framebufferTexture2D(n.FRAMEBUFFER,Ie,Te,Xe,0);else if(w.depthTexture.format===Ns)on(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ie,Te,Xe,0,Je):n.framebufferTexture2D(n.FRAMEBUFFER,Ie,Te,Xe,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ke(J){let w=i.get(J),ie=J.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==J.depthTexture){let ye=J.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),ye){let Ae=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,ye.removeEventListener("dispose",Ae)};ye.addEventListener("dispose",Ae),w.__depthDisposeCallback=Ae}w.__boundDepthTexture=ye}if(J.depthTexture&&!w.__autoAllocateDepthBuffer)if(ie)for(let ye=0;ye<6;ye++)Qe(w.__webglFramebuffer[ye],J,ye);else{let ye=J.texture.mipmaps;ye&&ye.length>0?Qe(w.__webglFramebuffer[0],J,0):Qe(w.__webglFramebuffer,J,0)}else if(ie){w.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)if(t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[ye]),w.__webglDepthbuffer[ye]===void 0)w.__webglDepthbuffer[ye]=n.createRenderbuffer(),We(w.__webglDepthbuffer[ye],J,!1);else{let Ae=J.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Xe=w.__webglDepthbuffer[ye];n.bindRenderbuffer(n.RENDERBUFFER,Xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ae,n.RENDERBUFFER,Xe)}}else{let ye=J.texture.mipmaps;if(ye&&ye.length>0?t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=n.createRenderbuffer(),We(w.__webglDepthbuffer,J,!1);else{let Ae=J.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Xe=w.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,Xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ae,n.RENDERBUFFER,Xe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function qe(J,w,ie){let ye=i.get(J);w!==void 0&&Re(ye.__webglFramebuffer,J,J.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ie!==void 0&&ke(J)}function ft(J){let w=J.texture,ie=i.get(J),ye=i.get(w);J.addEventListener("dispose",T);let Ae=J.textures,Xe=J.isWebGLCubeRenderTarget===!0,Je=Ae.length>1;if(Je||(ye.__webglTexture===void 0&&(ye.__webglTexture=n.createTexture()),ye.__version=w.version,s.memory.textures++),Xe){ie.__webglFramebuffer=[];for(let Te=0;Te<6;Te++)if(w.mipmaps&&w.mipmaps.length>0){ie.__webglFramebuffer[Te]=[];for(let Ie=0;Ie<w.mipmaps.length;Ie++)ie.__webglFramebuffer[Te][Ie]=n.createFramebuffer()}else ie.__webglFramebuffer[Te]=n.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){ie.__webglFramebuffer=[];for(let Te=0;Te<w.mipmaps.length;Te++)ie.__webglFramebuffer[Te]=n.createFramebuffer()}else ie.__webglFramebuffer=n.createFramebuffer();if(Je)for(let Te=0,Ie=Ae.length;Te<Ie;Te++){let ot=i.get(Ae[Te]);ot.__webglTexture===void 0&&(ot.__webglTexture=n.createTexture(),s.memory.textures++)}if(J.samples>0&&on(J)===!1){ie.__webglMultisampledFramebuffer=n.createFramebuffer(),ie.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ie.__webglMultisampledFramebuffer);for(let Te=0;Te<Ae.length;Te++){let Ie=Ae[Te];ie.__webglColorRenderbuffer[Te]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ie.__webglColorRenderbuffer[Te]);let ot=a.convert(Ie.format,Ie.colorSpace),yt=a.convert(Ie.type),ht=_(Ie.internalFormat,ot,yt,Ie.normalized,Ie.colorSpace,J.isXRRenderTarget===!0),rt=nt(J);n.renderbufferStorageMultisample(n.RENDERBUFFER,rt,ht,J.width,J.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Te,n.RENDERBUFFER,ie.__webglColorRenderbuffer[Te])}n.bindRenderbuffer(n.RENDERBUFFER,null),J.depthBuffer&&(ie.__webglDepthRenderbuffer=n.createRenderbuffer(),We(ie.__webglDepthRenderbuffer,J,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(Xe){t.bindTexture(n.TEXTURE_CUBE_MAP,ye.__webglTexture),Se(n.TEXTURE_CUBE_MAP,w);for(let Te=0;Te<6;Te++)if(w.mipmaps&&w.mipmaps.length>0)for(let Ie=0;Ie<w.mipmaps.length;Ie++)Re(ie.__webglFramebuffer[Te][Ie],J,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Te,Ie);else Re(ie.__webglFramebuffer[Te],J,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0);m(w)&&N(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Je){for(let Te=0,Ie=Ae.length;Te<Ie;Te++){let ot=Ae[Te],yt=i.get(ot),ht=n.TEXTURE_2D;(J.isWebGL3DRenderTarget||J.isWebGLArrayRenderTarget)&&(ht=J.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ht,yt.__webglTexture),Se(ht,ot),Re(ie.__webglFramebuffer,J,ot,n.COLOR_ATTACHMENT0+Te,ht,0),m(ot)&&N(ht)}t.unbindTexture()}else{let Te=n.TEXTURE_2D;if((J.isWebGL3DRenderTarget||J.isWebGLArrayRenderTarget)&&(Te=J.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Te,ye.__webglTexture),Se(Te,w),w.mipmaps&&w.mipmaps.length>0)for(let Ie=0;Ie<w.mipmaps.length;Ie++)Re(ie.__webglFramebuffer[Ie],J,w,n.COLOR_ATTACHMENT0,Te,Ie);else Re(ie.__webglFramebuffer,J,w,n.COLOR_ATTACHMENT0,Te,0);m(w)&&N(Te),t.unbindTexture()}J.depthBuffer&&ke(J)}function tt(J){let w=J.textures;for(let ie=0,ye=w.length;ie<ye;ie++){let Ae=w[ie];if(m(Ae)){let Xe=P(J),Je=i.get(Ae).__webglTexture;t.bindTexture(Xe,Je),N(Xe),t.unbindTexture()}}}let st=[],Ke=[];function en(J){if(J.samples>0){if(on(J)===!1){let w=J.textures,ie=J.width,ye=J.height,Ae=n.COLOR_BUFFER_BIT,Xe=J.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Je=i.get(J),Te=w.length>1;if(Te)for(let ot=0;ot<w.length;ot++)t.bindFramebuffer(n.FRAMEBUFFER,Je.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ot,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Je.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ot,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Je.__webglMultisampledFramebuffer);let Ie=J.texture.mipmaps;Ie&&Ie.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Je.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Je.__webglFramebuffer);for(let ot=0;ot<w.length;ot++){if(J.resolveDepthBuffer&&(J.depthBuffer&&(Ae|=n.DEPTH_BUFFER_BIT),J.stencilBuffer&&J.resolveStencilBuffer&&(Ae|=n.STENCIL_BUFFER_BIT)),Te){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Je.__webglColorRenderbuffer[ot]);let yt=i.get(w[ot]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,yt,0)}n.blitFramebuffer(0,0,ie,ye,0,0,ie,ye,Ae,n.NEAREST),u===!0&&(st.length=0,Ke.length=0,st.push(n.COLOR_ATTACHMENT0+ot),J.depthBuffer&&J.storeMultisampledDepthBuffer===!1&&(st.push(Xe),Ke.push(Xe),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ke)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,st))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Te)for(let ot=0;ot<w.length;ot++){t.bindFramebuffer(n.FRAMEBUFFER,Je.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ot,n.RENDERBUFFER,Je.__webglColorRenderbuffer[ot]);let yt=i.get(w[ot]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Je.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+ot,n.TEXTURE_2D,yt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Je.__webglMultisampledFramebuffer)}else if(J.depthBuffer&&J.storeMultisampledDepthBuffer===!1&&u){let w=J.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[w])}}}function nt(J){return Math.min(r.maxSamples,J.samples)}function on(J){let w=i.get(J);return J.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function ue(J){let w=s.render.frame;d.get(J)!==w&&(d.set(J,w),J.update())}function hn(J,w){let ie=J.colorSpace,ye=J.format,Ae=J.type;return J.isCompressedTexture===!0||J.isVideoTexture===!0||ie!==jl&&ie!==Or&&(ni.getTransfer(ie)===_i?(ye!==aa||Ae!==Xr)&&xn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Tn("WebGLTextures: Unsupported texture color space:",ie)),w}function gn(J){return typeof HTMLImageElement<"u"&&J instanceof HTMLImageElement?(l.width=J.naturalWidth||J.width,l.height=J.naturalHeight||J.height):typeof VideoFrame<"u"&&J instanceof VideoFrame?(l.width=J.displayWidth,l.height=J.displayHeight):(l.width=J.width,l.height=J.height),l}this.allocateTextureUnit=Y,this.resetTextureUnits=A,this.getTextureUnits=S,this.setTextureUnits=H,this.setTexture2D=O,this.setTexture2DArray=k,this.setTexture3D=ne,this.setTextureCube=X,this.rebindTextures=qe,this.setupRenderTarget=ft,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=en,this.setupDepthRenderbuffer=ke,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=on,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function fw(n,e){function t(i,r=Or){let a,s=ni.getTransfer(r);if(i===Xr)return n.UNSIGNED_BYTE;if(i===Cd)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Rd)return n.UNSIGNED_SHORT_5_5_5_1;if(i===ap)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===sp)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===ip)return n.BYTE;if(i===rp)return n.SHORT;if(i===pl)return n.UNSIGNED_SHORT;if(i===Id)return n.INT;if(i===Pa)return n.UNSIGNED_INT;if(i===ra)return n.FLOAT;if(i===La)return n.HALF_FLOAT;if(i===op)return n.ALPHA;if(i===lp)return n.RGB;if(i===aa)return n.RGBA;if(i===Ha)return n.DEPTH_COMPONENT;if(i===Ns)return n.DEPTH_STENCIL;if(i===Pd)return n.RED;if(i===Ld)return n.RED_INTEGER;if(i===Us)return n.RG;if(i===Dd)return n.RG_INTEGER;if(i===Nd)return n.RGBA_INTEGER;if(i===Cc||i===Rc||i===Pc||i===Lc)if(s===_i)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Cc)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Rc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Pc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Lc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Cc)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Rc)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Pc)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Lc)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ud||i===Fd||i===Od||i===Bd)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===Ud)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fd)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Od)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Bd)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===kd||i===zd||i===Vd||i===Gd||i===Hd||i===Dc||i===Wd)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===kd||i===zd)return s===_i?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Vd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(i===Gd)return a.COMPRESSED_R11_EAC;if(i===Hd)return a.COMPRESSED_SIGNED_R11_EAC;if(i===Dc)return a.COMPRESSED_RG11_EAC;if(i===Wd)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Xd||i===Yd||i===qd||i===Zd||i===Jd||i===$d||i===Kd||i===Qd||i===jd||i===ef||i===tf||i===nf||i===rf||i===af)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===Xd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Yd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===qd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Zd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$d)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Kd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Qd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===jd)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ef)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===tf)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===nf)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rf)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===af)return s===_i?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===sf||i===of||i===lf)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===sf)return s===_i?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===of)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===lf)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===cf||i===uf||i===Nc||i===df)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===cf)return a.COMPRESSED_RED_RGTC1_EXT;if(i===uf)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Nc)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===df)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 hw=`
|
|
4197
4197
|
void main() {
|
|
4198
4198
|
|
|
4199
4199
|
gl_Position = vec4( position, 1.0 );
|
|
4200
4200
|
|
|
4201
|
-
}`,
|
|
4201
|
+
}`,pw=`
|
|
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
|
-
}`,Wh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let i=new bl(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 kr({vertexShader:yb,fragmentShader:xb,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new jn(new Pl(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Xh=class extends Sa{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,v=null,y=null,T=typeof XRWebGLBinding<"u",g=new Wh,m={},L=t.getContextAttributes(),F=null,_=null,p=[],S=[],B=new kt,b=null,I=null,z=new er;z.viewport=new fi;let U=new er;U.viewport=new fi;let Y=[z,U],E=new Pu,M=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ae){let de=p[ae];return de===void 0&&(de=new yo,p[ae]=de),de.getTargetRaySpace()},this.getControllerGrip=function(ae){let de=p[ae];return de===void 0&&(de=new yo,p[ae]=de),de.getGripSpace()},this.getHand=function(ae){let de=p[ae];return de===void 0&&(de=new yo,p[ae]=de),de.getHandSpace()};function H(ae){let de=S.indexOf(ae.inputSource);if(de===-1)return;let _e=p[de];_e!==void 0&&(_e.update(ae.inputSource,ae.frame,l||s),_e.dispatchEvent({type:ae.type,data:ae.inputSource}))}function ee(){r.removeEventListener("select",H),r.removeEventListener("selectstart",H),r.removeEventListener("selectend",H),r.removeEventListener("squeeze",H),r.removeEventListener("squeezestart",H),r.removeEventListener("squeezeend",H),r.removeEventListener("end",ee),r.removeEventListener("inputsourceschange",j);for(let ae=0;ae<p.length;ae++){let de=S[ae];de!==null&&(S[ae]=null,p[ae].disconnect(de))}M=null,O=null,g.reset();for(let ae in m)delete m[ae];if(e.setRenderTarget(F),v=null,h=null,f=null,r=null,_=null,Fe.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(B.width,B.height,!1),I!==null){let ae=I.camera;ae.fov=I.fov,ae.zoom=I.zoom,ae.updateProjectionMatrix(),I=null}i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ae){a=ae,i.isPresenting===!0&&rn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ae){o=ae,i.isPresenting===!0&&rn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(ae){l=ae},this.getBaseLayer=function(){return h!==null?h:v},this.getBinding=function(){return f===null&&T&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(ae){if(r=ae,r!==null){if(F=e.getRenderTarget(),r.addEventListener("select",H),r.addEventListener("selectstart",H),r.addEventListener("selectend",H),r.addEventListener("squeeze",H),r.addEventListener("squeezestart",H),r.addEventListener("squeezeend",H),r.addEventListener("end",ee),r.addEventListener("inputsourceschange",j),L.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(B),T&&"createProjectionLayer"in XRWebGLBinding.prototype){let _e=null,Ge=null,$e=null;L.depth&&($e=L.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,_e=L.stencil?ys:Ma,Ge=L.stencil?Co:sa);let ut={colorFormat:t.RGBA8,depthFormat:$e,scaleFactor:a};f=this.getBinding(),h=f.createProjectionLayer(ut),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),_=new Ar(h.textureWidth,h.textureHeight,{format:qr,type:Cr,depthTexture:new us(h.textureWidth,h.textureHeight,Ge,void 0,void 0,void 0,void 0,void 0,void 0,_e),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 _e={antialias:L.antialias,alpha:!0,depth:L.depth,stencil:L.stencil,framebufferScaleFactor:a};v=new XRWebGLLayer(r,t,_e),r.updateRenderState({baseLayer:v}),e.setPixelRatio(1),e.setSize(v.framebufferWidth,v.framebufferHeight,!1),_=new Ar(v.framebufferWidth,v.framebufferHeight,{format:qr,type:Cr,colorSpace:e.outputColorSpace,stencilBuffer:L.stencil,resolveDepthBuffer:v.ignoreDepthValues===!1,resolveStencilBuffer:v.ignoreDepthValues===!1,storeMultisampledDepthBuffer:v.ignoreDepthValues===!1,storeMultisampledStencilBuffer:v.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(u),l=null,s=await r.requestReferenceSpace(o),Fe.setContext(r),Fe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function j(ae){for(let de=0;de<ae.removed.length;de++){let _e=ae.removed[de],Ge=S.indexOf(_e);Ge>=0&&(S[Ge]=null,p[Ge].disconnect(_e))}for(let de=0;de<ae.added.length;de++){let _e=ae.added[de],Ge=S.indexOf(_e);if(Ge===-1){for(let ut=0;ut<p.length;ut++)if(ut>=S.length){S.push(_e),Ge=ut;break}else if(S[ut]===null){S[ut]=_e,Ge=ut;break}if(Ge===-1)break}let $e=p[Ge];$e&&$e.connect(_e)}}let K=new ge,re=new ge;function J(ae,de,_e){K.setFromMatrixPosition(de.matrixWorld),re.setFromMatrixPosition(_e.matrixWorld);let Ge=K.distanceTo(re),$e=de.projectionMatrix.elements,ut=_e.projectionMatrix.elements,zt=$e[14]/($e[10]-1),ct=$e[14]/($e[10]+1),Tt=($e[9]+1)/$e[5],Zt=($e[9]-1)/$e[5],wt=($e[8]-1)/$e[0],bt=(ut[8]+1)/ut[0],_t=zt*wt,ln=zt*bt,rt=Ge/(-wt+bt),an=rt*-wt;if(de.matrixWorld.decompose(ae.position,ae.quaternion,ae.scale),ae.translateX(an),ae.translateZ(rt),ae.matrixWorld.compose(ae.position,ae.quaternion,ae.scale),ae.matrixWorldInverse.copy(ae.matrixWorld).invert(),$e[10]===-1)ae.projectionMatrix.copy(de.projectionMatrix),ae.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{let se=zt+rt,mn=ct+rt,nn=_t-an,W=ln+(Ge-an),w=Tt*ct/mn*se,ue=Zt*ct/mn*se;ae.projectionMatrix.makePerspective(nn,W,w,ue,se,mn),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert()}}function ne(ae,de){de===null?ae.matrixWorld.copy(ae.matrix):ae.matrixWorld.multiplyMatrices(de.matrixWorld,ae.matrix),ae.matrixWorldInverse.copy(ae.matrixWorld).invert()}this.updateCamera=function(ae){if(r===null)return;let de=ae.near,_e=ae.far;g.texture!==null&&(g.depthNear>0&&(de=g.depthNear),g.depthFar>0&&(_e=g.depthFar)),E.near=U.near=z.near=de,E.far=U.far=z.far=_e,(M!==E.near||O!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),M=E.near,O=E.far),E.layers.mask=ae.layers.mask|6,z.layers.mask=E.layers.mask&-5,U.layers.mask=E.layers.mask&-3;let Ge=ae.parent,$e=E.cameras;ne(E,Ge);for(let ut=0;ut<$e.length;ut++)ne($e[ut],Ge);$e.length===2?J(E,z,U):E.projectionMatrix.copy(z.projectionMatrix),I===null&&ae.isPerspectiveCamera&&(I={camera:ae,fov:ae.fov,zoom:ae.zoom}),Te(ae,E,Ge)};function Te(ae,de,_e){_e===null?ae.matrix.copy(de.matrixWorld):(ae.matrix.copy(_e.matrixWorld),ae.matrix.invert(),ae.matrix.multiply(de.matrixWorld)),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.updateMatrixWorld(!0),ae.projectionMatrix.copy(de.projectionMatrix),ae.projectionMatrixInverse.copy(de.projectionMatrixInverse),ae.isPerspectiveCamera&&(ae.fov=au*2*Math.atan(1/ae.projectionMatrix.elements[5]),ae.zoom=1)}this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&v===null))return u},this.setFoveation=function(ae){u=ae,h!==null&&(h.fixedFoveation=ae),v!==null&&v.fixedFoveation!==void 0&&(v.fixedFoveation=ae)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(E)},this.getCameraTexture=function(ae){return m[ae]};let fe=null;function pe(ae,de){if(d=de.getViewerPose(l||s),y=de,d!==null){let _e=d.views;v!==null&&(e.setRenderTargetFramebuffer(_,v.framebuffer),e.setRenderTarget(_));let Ge=!1;_e.length!==E.cameras.length&&(E.cameras.length=0,Ge=!0);for(let ct=0;ct<_e.length;ct++){let Tt=_e[ct],Zt=null;if(v!==null)Zt=v.getViewport(Tt);else{let bt=f.getViewSubImage(h,Tt);Zt=bt.viewport,ct===0&&(e.setRenderTargetTextures(_,bt.colorTexture,bt.depthStencilTexture),e.setRenderTarget(_))}let wt=Y[ct];wt===void 0&&(wt=new er,wt.layers.enable(ct),wt.viewport=new fi,Y[ct]=wt),wt.matrix.fromArray(Tt.transform.matrix),wt.matrix.decompose(wt.position,wt.quaternion,wt.scale),wt.projectionMatrix.fromArray(Tt.projectionMatrix),wt.projectionMatrixInverse.copy(wt.projectionMatrix).invert(),wt.viewport.set(Zt.x,Zt.y,Zt.width,Zt.height),ct===0&&(E.matrix.copy(wt.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),Ge===!0&&E.cameras.push(wt)}let $e=r.enabledFeatures;if($e&&$e.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&T){f=i.getBinding();let ct=f.getDepthInformation(_e[0]);ct&&ct.isValid&&ct.texture&&g.init(ct,r.renderState)}if($e&&$e.includes("camera-access")&&T){e.state.unbindTexture(),f=i.getBinding();for(let ct=0;ct<_e.length;ct++){let Tt=_e[ct].camera;if(Tt){let Zt=m[Tt];Zt||(Zt=new bl,m[Tt]=Zt);let wt=f.getCameraImage(Tt);Zt.sourceTexture=wt}}}}for(let _e=0;_e<p.length;_e++){let Ge=S[_e],$e=p[_e];Ge!==null&&$e!==void 0&&$e.update(Ge,de,l||s)}fe&&fe(ae,de),de.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:de}),y=null}let Fe=new $0;Fe.setAnimationLoop(pe),this.setAnimationLoop=function(ae){fe=ae},this.dispose=function(){}}},_b=new $n,nv=new un;nv.set(-1,0,0,0,1,0,0,0,1);function Mb(n,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function i(g,m){m.color.getRGB(g.fogColor.value,Sh(n)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,L,F,_){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?a(g,m):m.isMeshLambertMaterial?(a(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(a(g,m),f(g,m)):m.isMeshPhongMaterial?(a(g,m),d(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(a(g,m),h(g,m),m.isMeshPhysicalMaterial&&v(g,m,_)):m.isMeshMatcapMaterial?(a(g,m),y(g,m)):m.isMeshDepthMaterial?a(g,m):m.isMeshDistanceMaterial?(a(g,m),T(g,m)):m.isMeshNormalMaterial?a(g,m):m.isLineBasicMaterial?(s(g,m),m.isLineDashedMaterial&&o(g,m)):m.isPointsMaterial?u(g,m,L,F):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function a(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===pr&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===pr&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let L=e.get(m),F=L.envMap,_=L.envMapRotation;F&&(g.envMap.value=F,g.envMapRotation.value.setFromMatrix4(_b.makeRotationFromEuler(_)).transpose(),F.isCubeTexture&&F.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(nv),g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function s(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function u(g,m,L,F){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*L,g.scale.value=F*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function d(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function f(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function h(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function v(g,m,L){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===pr&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.retroreflectivity>0&&(g.retroreflectivity.value=m.retroreflectivity),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=L.texture,g.transmissionSamplerSize.value.set(L.width,L.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function y(g,m){m.matcap&&(g.matcap.value=m.matcap)}function T(g,m){let L=e.get(m).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 Sb(n,e,t,i){let r={},a={},s=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function u(_,p){let S=p.program;i.uniformBlockBinding(_,S)}function l(_,p){let S=r[_.id];S===void 0&&(g(_),S=d(_),r[_.id]=S,_.addEventListener("dispose",L));let B=p.program;i.updateUBOMapping(_,B);let b=e.render.frame;a[_.id]!==b&&(h(_),a[_.id]=b)}function d(_){let p=f();_.__bindingPointIndex=p;let S=n.createBuffer(),B=_.__size,b=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,B,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,p,S),S}function f(){for(let _=0;_<o;_++)if(s.indexOf(_)===-1)return s.push(_),_;return sn("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(_){let p=r[_.id],S=_.uniforms,B=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,p);for(let b=0,I=S.length;b<I;b++){let z=S[b];if(Array.isArray(z))for(let U=0,Y=z.length;U<Y;U++)v(z[U],b,U,B);else v(z,b,0,B)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function v(_,p,S,B){if(T(_,p,S,B)===!0){let b=_.__offset,I=_.value;if(Array.isArray(I)){let z=0;for(let U=0;U<I.length;U++){let Y=I[U],E=m(Y);y(Y,_.__data,z),typeof Y!="number"&&typeof Y!="boolean"&&!Y.isMatrix3&&!ArrayBuffer.isView(Y)&&(z+=E.storage/Float32Array.BYTES_PER_ELEMENT)}}else y(I,_.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,b,_.__data)}}function y(_,p,S){typeof _=="number"||typeof _=="boolean"?p[0]=_:_.isMatrix3?(p[0]=_.elements[0],p[1]=_.elements[1],p[2]=_.elements[2],p[3]=0,p[4]=_.elements[3],p[5]=_.elements[4],p[6]=_.elements[5],p[7]=0,p[8]=_.elements[6],p[9]=_.elements[7],p[10]=_.elements[8],p[11]=0):ArrayBuffer.isView(_)?p.set(new _.constructor(_.buffer,_.byteOffset,p.length)):_.toArray(p,S)}function T(_,p,S,B){let b=_.value,I=p+"_"+S;if(B[I]===void 0)return typeof b=="number"||typeof b=="boolean"?B[I]=b:ArrayBuffer.isView(b)?B[I]=b.slice():B[I]=b.clone(),!0;{let z=B[I];if(typeof b=="number"||typeof b=="boolean"){if(z!==b)return B[I]=b,!0}else{if(ArrayBuffer.isView(b))return!0;if(z.equals(b)===!1)return z.copy(b),!0}}return!1}function g(_){let p=_.uniforms,S=0,B=16;for(let I=0,z=p.length;I<z;I++){let U=Array.isArray(p[I])?p[I]:[p[I]];for(let Y=0,E=U.length;Y<E;Y++){let M=U[Y],O=Array.isArray(M.value)?M.value:[M.value];for(let H=0,ee=O.length;H<ee;H++){let j=O[H],K=m(j),re=S%B,J=re%K.boundary,ne=re+J;S+=J,ne!==0&&B-ne<K.storage&&(S+=B-ne),M.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=S,S+=K.storage}}}let b=S%B;return b>0&&(S+=B-b),_.__size=S,_.__cache={},this}function m(_){let p={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(p.boundary=4,p.storage=4):_.isVector2?(p.boundary=8,p.storage=8):_.isVector3||_.isColor?(p.boundary=16,p.storage=12):_.isVector4?(p.boundary=16,p.storage=16):_.isMatrix3?(p.boundary=48,p.storage=48):_.isMatrix4?(p.boundary=64,p.storage=64):_.isTexture?rn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(p.boundary=16,p.storage=_.byteLength):rn("WebGLRenderer: Unsupported uniform value type.",_),p}function L(_){let p=_.target;p.removeEventListener("dispose",L);let S=s.indexOf(p.__bindingPointIndex);s.splice(S,1),n.deleteBuffer(r[p.id]),delete r[p.id],delete a[p.id]}function F(){for(let _ in r)n.deleteBuffer(r[_]);s=[],r={},a={}}return{bind:u,update:l,dispose:F}}var bb=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]),Ia=null;function wb(){return Ia===null&&(Ia=new _l(bb,16,16,xs,oa),Ia.name="DFG_LUT",Ia.minFilter=Hi,Ia.magFilter=Hi,Ia.wrapS=_a,Ia.wrapT=_a,Ia.generateMipmaps=!1,Ia.needsUpdate=!0),Ia}var Id=class{constructor(e={}){let{canvas:t=g0(),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:v=Cr}=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 T=v,g=new Set([Wu,Hu,Gu]),m=new Set([Cr,sa,Io,Co,ku,zu]),L=new Uint32Array(4),F=new Int32Array(4),_=new ge,p=null,S=null,B=[],b=[],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=aa,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let z=this,U=!1,Y=null,E=null,M=null,O=null;this._outputColorSpace=hr;let H=0,ee=0,j=null,K=-1,re=null,J=new fi,ne=new fi,Te=null,fe=new vn(0),pe=0,Fe=t.width,ae=t.height,de=1,_e=null,Ge=null,$e=new fi(0,0,Fe,ae),ut=new fi(0,0,Fe,ae),zt=!1,ct=new xo,Tt=!1,Zt=!1,wt=new $n,bt=new ge,_t=new fi,ln={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},rt=!1;function an(){return j===null?de:1}let se=i;function mn(D,le){return t.getContext(D,le)}let nn,W,w,ue,ye,we,ze,Ye,Re,Ae,Ne,je,Ve,qe,ot,pt,He,ie,Oe,Pe,nt,dt,Be;try{let D={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",cn,!1),t.addEventListener("webglcontextrestored",dn,!1),t.addEventListener("webglcontextcreationerror",Fn,!1),se===null){let le="webgl2";if(se=mn(le,D),se===null)throw mn(le)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Rt()}catch(D){throw t.removeEventListener("webglcontextlost",cn,!1),t.removeEventListener("webglcontextrestored",dn,!1),t.removeEventListener("webglcontextcreationerror",Fn,!1),sn("WebGLRenderer: "+D.message),D}function Rt(){nn=new PM(se),nn.init(),nt=new gb(se,nn),W=new MM(se,nn,e,nt),w=new mb(se,nn),W.reversedDepthBuffer&&h&&w.buffers.depth.setReversed(!0),E=se.createFramebuffer(),M=se.createFramebuffer(),O=se.createFramebuffer(),ue=new NM(se),ye=new tb,we=new vb(se,nn,w,ye,W,nt,ue),ze=new RM(z),Ye=new Fy(se),dt=new xM(se,Ye),Re=new LM(se,Ye,ue,dt),Ae=new FM(se,Re,Ye,dt,ue),ie=new UM(se,W,we),ot=new SM(ye),Ne=new eb(z,ze,nn,W,dt,ot),je=new Mb(z,ye),Ve=new ib,qe=new cb(nn),He=new yM(z,ze,w,Ae,y,u),pt=new pb(z,Ae,W),Be=new Sb(se,ue,W,w),Oe=new _M(se,nn,ue),Pe=new DM(se,nn,ue),ue.programs=Ne.programs,z.capabilities=W,z.extensions=nn,z.properties=ye,z.renderLists=Ve,z.shadowMap=pt,z.state=w,z.info=ue}T!==Cr&&(I=new BM(T,t.width,t.height,o,r,a));let vt=new Xh(z,se);this.xr=vt,this.getContext=function(){return se},this.getContextAttributes=function(){return se.getContextAttributes()},this.forceContextLoss=function(){let D=nn.get("WEBGL_lose_context");D&&D.loseContext()},this.forceContextRestore=function(){let D=nn.get("WEBGL_lose_context");D&&D.restoreContext()},this.getPixelRatio=function(){return de},this.setPixelRatio=function(D){D!==void 0&&(de=D,this.setSize(Fe,ae,!1))},this.getSize=function(D){return D.set(Fe,ae)},this.setSize=function(D,le,he=!0){if(vt.isPresenting){rn("WebGLRenderer: Can't change size while VR device is presenting.");return}Fe=D,ae=le,t.width=Math.floor(D*de),t.height=Math.floor(le*de),he===!0&&(t.style.width=D+"px",t.style.height=le+"px"),I!==null&&I.setSize(t.width,t.height),this.setViewport(0,0,D,le)},this.getDrawingBufferSize=function(D){return D.set(Fe*de,ae*de).floor()},this.setDrawingBufferSize=function(D,le,he){Fe=D,ae=le,de=he,t.width=Math.floor(D*he),t.height=Math.floor(le*he),this.setViewport(0,0,D,le)},this.setEffects=function(D){if(T===Cr){sn("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(D){for(let le=0;le<D.length;le++)if(D[le].isOutputPass===!0){rn("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}I.setEffects(D||[])},this.getCurrentViewport=function(D){return D.copy(J)},this.getViewport=function(D){return D.copy($e)},this.setViewport=function(D,le,he,Me){D.isVector4?$e.set(D.x,D.y,D.z,D.w):$e.set(D,le,he,Me),w.viewport(J.copy($e).multiplyScalar(de).round())},this.getScissor=function(D){return D.copy(ut)},this.setScissor=function(D,le,he,Me){D.isVector4?ut.set(D.x,D.y,D.z,D.w):ut.set(D,le,he,Me),w.scissor(ne.copy(ut).multiplyScalar(de).round())},this.getScissorTest=function(){return zt},this.setScissorTest=function(D){w.setScissorTest(zt=D)},this.setOpaqueSort=function(D){_e=D},this.setTransparentSort=function(D){Ge=D},this.getClearColor=function(D){return D.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor(...arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha(...arguments)},this.clear=function(D=!0,le=!0,he=!0){let Me=0;if(D){let Se=!1;if(j!==null){let ke=j.texture.format;Se=g.has(ke)}if(Se){let ke=j.texture.type,et=m.has(ke),Je=He.getClearColor(),ft=He.getClearAlpha(),Dt=Je.r,tn=Je.g,$t=Je.b;et?(L[0]=Dt,L[1]=tn,L[2]=$t,L[3]=ft,se.clearBufferuiv(se.COLOR,0,L)):(F[0]=Dt,F[1]=tn,F[2]=$t,F[3]=ft,se.clearBufferiv(se.COLOR,0,F))}else Me|=se.COLOR_BUFFER_BIT}le&&(Me|=se.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),he&&(Me|=se.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Me!==0&&se.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(D){D.setRenderer(this),Y=D},this.dispose=function(){t.removeEventListener("webglcontextlost",cn,!1),t.removeEventListener("webglcontextrestored",dn,!1),t.removeEventListener("webglcontextcreationerror",Fn,!1),He.dispose(),Ve.dispose(),qe.dispose(),ye.dispose(),ze.dispose(),Ae.dispose(),dt.dispose(),Be.dispose(),Ne.dispose(),vt.dispose(),vt.removeEventListener("sessionstart",en),vt.removeEventListener("sessionend",xt),ni.stop()};function cn(D){D.preventDefault(),_h("WebGLRenderer: Context Lost."),U=!0}function dn(){_h("WebGLRenderer: Context Restored."),U=!1;let D=ue.autoReset,le=pt.enabled,he=pt.autoUpdate,Me=pt.needsUpdate,Se=pt.type;Rt(),ue.autoReset=D,pt.enabled=le,pt.autoUpdate=he,pt.needsUpdate=Me,pt.type=Se}function Fn(D){sn("WebGLRenderer: A WebGL context could not be created. Reason: ",D.statusMessage)}function Dn(D){let le=D.target;le.removeEventListener("dispose",Dn),vi(le)}function vi(D){rr(D),ye.remove(D)}function rr(D){let le=ye.get(D).programs;le!==void 0&&(le.forEach(function(he){Ne.releaseProgram(he)}),D.isShaderMaterial&&Ne.releaseShaderCache(D))}this.renderBufferDirect=function(D,le,he,Me,Se,ke){le===null&&(le=ln);let et=Se.isMesh&&Se.matrixWorld.determinantAffine()<0,Je=Ei(D,le,he,Me,Se);w.setMaterial(Me,et);let ft=he.index,Dt=1;if(Me.wireframe===!0){if(ft=Re.getWireframeAttribute(he),ft===void 0)return;Dt=2}let tn=he.drawRange,$t=he.attributes.position,Et=tn.start*Dt,hn=(tn.start+tn.count)*Dt;ke!==null&&(Et=Math.max(Et,ke.start*Dt),hn=Math.min(hn,(ke.start+ke.count)*Dt)),ft!==null?(Et=Math.max(Et,0),hn=Math.min(hn,ft.count)):$t!=null&&(Et=Math.max(Et,0),hn=Math.min(hn,$t.count));let Vn=hn-Et;if(Vn<0||Vn===1/0)return;dt.setup(Se,Me,Je,he,ft);let It,Qt=Oe;if(ft!==null&&(It=Ye.get(ft),Qt=Pe,Qt.setIndex(It)),Se.isMesh)Me.wireframe===!0?(w.setLineWidth(Me.wireframeLinewidth*an()),Qt.setMode(se.LINES)):Qt.setMode(se.TRIANGLES);else if(Se.isLine){let jt=Me.linewidth;jt===void 0&&(jt=1),w.setLineWidth(jt*an()),Se.isLineSegments?Qt.setMode(se.LINES):Se.isLineLoop?Qt.setMode(se.LINE_LOOP):Qt.setMode(se.LINE_STRIP)}else Se.isPoints?Qt.setMode(se.POINTS):Se.isSprite&&Qt.setMode(se.TRIANGLES);if(Se.isBatchedMesh)if(nn.get("WEBGL_multi_draw"))Qt.renderMultiDraw(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount);else{let jt=Se._multiDrawStarts,Le=Se._multiDrawCounts,An=Se._multiDrawCount,pn=ft?Ye.get(ft).bytesPerElement:1,yi=ye.get(Me).currentProgram.getUniforms();for(let or=0;or<An;or++)yi.setValue(se,"_gl_DrawID",or),Qt.render(jt[or]/pn,Le[or])}else if(Se.isInstancedMesh)Qt.renderInstances(Et,Vn,Se.count);else if(he.isInstancedBufferGeometry){let jt=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,Le=Math.min(he.instanceCount,jt);Qt.renderInstances(Et,Vn,Le)}else Qt.render(Et,Vn)};function yn(D,le,he,Me){Y!==null&&D.isNodeMaterial&&Y.setObject(Me,D),Tt===!0&&ot.setState(D,he,!1),D.transparent===!0&&D.side===Ir&&D.forceSinglePass===!1?(D.side=pr,D.needsUpdate=!0,Bn(D,le,Me),D.side=ms,D.needsUpdate=!0,Bn(D,le,Me),D.side=Ir):Bn(D,le,Me)}this.compile=function(D,le,he=null){he===null&&(he=D),Y!==null&&Y.renderStart(D,le,he),S=qe.get(he),S.init(le),b.push(S),he.traverseVisible(function(Se){Se.isLight&&Se.layers.test(le.layers)&&(S.pushLight(Se),Se.castShadow&&S.pushShadow(Se))}),D!==he&&D.traverseVisible(function(Se){Se.isLight&&Se.layers.test(le.layers)&&(S.pushLight(Se),Se.castShadow&&S.pushShadow(Se))}),S.setupLights(),Y!==null&&Y.updateLights(S.state.lightsArray),Zt=this.localClippingEnabled,Tt=ot.init(this.clippingPlanes,Zt),Tt===!0&&ot.setGlobalState(this.clippingPlanes,le),Y!==null&&pt.render(S.state.shadowsArray,he,le);let Me=new Set;return D.traverse(function(Se){if(!(Se.isMesh||Se.isPoints||Se.isLine||Se.isSprite))return;let ke=Se.material;if(ke)if(Array.isArray(ke))for(let et=0;et<ke.length;et++){let Je=ke[et];yn(Je,he,le,Se),Me.add(Je)}else yn(ke,he,le,Se),Me.add(ke)}),S=b.pop(),Y!==null&&Y.renderEnd(),Me},this.compileAsync=function(D,le,he=null){let Me=this.compile(D,le,he);return new Promise(Se=>{function ke(){if(Me.forEach(function(et){let ft=ye.get(et).currentProgram;(ft===void 0||ft.isReady())&&Me.delete(et)}),Me.size===0){Se(D);return}setTimeout(ke,10)}nn.get("KHR_parallel_shader_compile")!==null?ke():setTimeout(ke,10)})};let En=null;function Yi(D){En&&En(D)}function en(){ni.stop()}function xt(){ni.start()}let ni=new $0;ni.setAnimationLoop(Yi),typeof self<"u"&&ni.setContext(self),this.setAnimationLoop=function(D){En=D,vt.setAnimationLoop(D),D===null?ni.stop():ni.start()},vt.addEventListener("sessionstart",en),vt.addEventListener("sessionend",xt),this.render=function(D,le){if(le!==void 0&&le.isCamera!==!0){sn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;Y!==null&&Y.renderStart(D,le);let he=vt.enabled===!0&&vt.isPresenting===!0,Me=I!==null&&(j===null||he)&&I.begin(z,j);if(D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),le.parent===null&&le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),vt.enabled===!0&&vt.isPresenting===!0&&(I===null||I.isCompositing()===!1)&&(vt.cameraAutoUpdate===!0&&vt.updateCamera(le),le=vt.getCamera()),D.isScene===!0&&D.onBeforeRender(z,D,le,j),S=qe.get(D,b.length),S.init(le),S.state.textureUnits=we.getTextureUnits(),b.push(S),wt.multiplyMatrices(le.projectionMatrix,le.matrixWorldInverse),ct.setFromProjectionMatrix(wt,ra,le.reversedDepth),Zt=this.localClippingEnabled,Tt=ot.init(this.clippingPlanes,Zt),p=Ve.get(D,B.length),p.init(),B.push(p),vt.enabled===!0&&vt.isPresenting===!0){let et=z.xr.getDepthSensingMesh();et!==null&&fn(et,le,-1/0,z.sortObjects)}fn(D,le,0,z.sortObjects),p.finish(),Y!==null&&Y.updateLights(S.state.lightsArray),z.sortObjects===!0&&p.sort(_e,Ge),rt=vt.enabled===!1||vt.isPresenting===!1||vt.hasDepthSensing()===!1,rt&&He.addToRenderList(p,D),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Tt===!0&&ot.beginShadows();let Se=S.state.shadowsArray;if(pt.render(Se,D,le),Tt===!0&&ot.endShadows(),(Me&&I.hasRenderPass())===!1){let et=p.opaque,Je=p.transmissive;if(S.setupLights(),le.isArrayCamera){let ft=le.cameras;if(Je.length>0)for(let Dt=0,tn=ft.length;Dt<tn;Dt++){let $t=ft[Dt];qi(et,Je,D,$t)}rt&&He.render(D);for(let Dt=0,tn=ft.length;Dt<tn;Dt++){let $t=ft[Dt];bi(p,D,$t,$t.viewport)}}else Je.length>0&&qi(et,Je,D,le),rt&&He.render(D),bi(p,D,le)}j!==null&&ee===0&&(we.updateMultisampleRenderTarget(j),we.updateRenderTargetMipmap(j)),Me&&I.end(z),D.isScene===!0&&D.onAfterRender(z,D,le),dt.resetDefaultState(),K=-1,re=null,b.pop(),b.length>0?(S=b[b.length-1],we.setTextureUnits(S.state.textureUnits),Tt===!0&&ot.setGlobalState(z.clippingPlanes,S.state.camera)):S=null,B.pop(),B.length>0?p=B[B.length-1]:p=null,Y!==null&&Y.renderEnd()};function fn(D,le,he,Me){if(D.visible===!1)return;if(D.layers.test(le.layers)){if(D.isGroup)he=D.renderOrder;else if(D.isLOD)D.autoUpdate===!0&&D.update(le);else if(D.isLightProbeGrid)S.pushLightProbeGrid(D);else if(D.isLight)S.pushLight(D),D.castShadow&&S.pushShadow(D);else if(D.isSprite){if(!D.frustumCulled||D.intersectsFrustum(ct)){Me&&_t.setFromMatrixPosition(D.matrixWorld).applyMatrix4(wt);let et=Ae.update(D),Je=D.material;Je.visible&&p.push(D,et,Je,he,_t.z,null,le)}}else if((D.isMesh||D.isLine||D.isPoints)&&(!D.frustumCulled||D.intersectsFrustum(ct))){let et=Ae.update(D),Je=D.material;if(Me&&(D.boundingSphere!==void 0?(D.boundingSphere===null&&D.computeBoundingSphere(),_t.copy(D.boundingSphere.center)):(et.boundingSphere===null&&et.computeBoundingSphere(),_t.copy(et.boundingSphere.center)),_t.applyMatrix4(D.matrixWorld).applyMatrix4(wt)),Array.isArray(Je)){let ft=et.groups;for(let Dt=0,tn=ft.length;Dt<tn;Dt++){let $t=ft[Dt],Et=Je[$t.materialIndex];Et&&Et.visible&&p.push(D,et,Et,he,_t.z,$t,le)}}else Je.visible&&p.push(D,et,Je,he,_t.z,null,le)}}let ke=D.children;for(let et=0,Je=ke.length;et<Je;et++)fn(ke[et],le,he,Me)}function bi(D,le,he,Me){let{opaque:Se,transmissive:ke,transparent:et}=D;S.setupLightsView(he),Tt===!0&&ot.setGlobalState(z.clippingPlanes,he),Me&&w.viewport(J.copy(Me)),Se.length>0&&wi(Se,le,he),ke.length>0&&wi(ke,le,he),et.length>0&&wi(et,le,he),w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function qi(D,le,he,Me){if((he.isScene===!0?he.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Me.id]===void 0){let Et=nn.has("EXT_color_buffer_half_float")||nn.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Me.id]=new Ar(1,1,{generateMipmaps:!0,type:Et?oa:Cr,minFilter:gs,samples:Math.max(4,W.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ln.workingColorSpace})}let ke=S.state.transmissionRenderTarget[Me.id],et=Me.viewport||J;ke.setSize(et.z*z.transmissionResolutionScale,et.w*z.transmissionResolutionScale);let Je=z.getRenderTarget(),ft=z.getActiveCubeFace(),Dt=z.getActiveMipmapLevel();z.setRenderTarget(ke),z.getClearColor(fe),pe=z.getClearAlpha(),pe<1&&z.setClearColor(16777215,.5),z.clear(),rt&&He.render(he);let tn=z.toneMapping;z.toneMapping=aa;let $t=Me.viewport;if(Me.viewport!==void 0&&(Me.viewport=void 0),S.setupLightsView(Me),Tt===!0&&ot.setGlobalState(z.clippingPlanes,Me),wi(D,he,Me),we.updateMultisampleRenderTarget(ke),we.updateRenderTargetMipmap(ke),nn.has("WEBGL_multisampled_render_to_texture")===!1){let Et=!1;for(let hn=0,Vn=le.length;hn<Vn;hn++){let It=le[hn],{object:Qt,geometry:jt,material:Le,group:An}=It;if(Le.side===Ir&&Qt.layers.test(Me.layers)){let pn=Le.side;Le.side=pr,Le.needsUpdate=!0,gi(Qt,he,Me,jt,Le,An),Le.side=pn,Le.needsUpdate=!0,Et=!0}}Et===!0&&(we.updateMultisampleRenderTarget(ke),we.updateRenderTargetMipmap(ke))}z.setRenderTarget(Je,ft,Dt),z.setClearColor(fe,pe),$t!==void 0&&(Me.viewport=$t),z.toneMapping=tn}function wi(D,le,he){let Me=le.isScene===!0?le.overrideMaterial:null;for(let Se=0,ke=D.length;Se<ke;Se++){let et=D[Se],{object:Je,geometry:ft,group:Dt}=et,tn=et.material;tn.allowOverride===!0&&Me!==null&&(tn=Me),Je.layers.test(he.layers)&&gi(Je,le,he,ft,tn,Dt)}}function gi(D,le,he,Me,Se,ke){Y!==null&&Se.isNodeMaterial&&Y.setObject(D,Se),D.onBeforeRender(z,le,he,Me,Se,ke),D.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,D.matrixWorld),D.normalMatrix.getNormalMatrix(D.modelViewMatrix),Se.onBeforeRender(z,le,he,Me,D,ke),Se.transparent===!0&&Se.side===Ir&&Se.forceSinglePass===!1?(Se.side=pr,Se.needsUpdate=!0,z.renderBufferDirect(he,le,Me,Se,D,ke),Se.side=ms,Se.needsUpdate=!0,z.renderBufferDirect(he,le,Me,Se,D,ke),Se.side=Ir):z.renderBufferDirect(he,le,Me,Se,D,ke),D.onAfterRender(z,le,he,Me,Se,ke)}function Bn(D,le,he){le.isScene!==!0&&(le=ln);let Me=ye.get(D),Se=S.state.lights,ke=S.state.shadowsArray,et=Se.state.version,Je=Ne.getParameters(D,Se.state,ke,le,he,S.state.lightProbeGridArray),ft=Ne.getProgramCacheKey(Je),Dt=Me.programs;Me.environment=D.isMeshStandardMaterial||D.isMeshLambertMaterial||D.isMeshPhongMaterial?le.environment:null,Me.fog=le.fog;let tn=D.isMeshStandardMaterial||D.isMeshLambertMaterial&&!D.envMap||D.isMeshPhongMaterial&&!D.envMap;Me.envMap=ze.get(D.envMap||Me.environment,tn),Me.envMapRotation=Me.environment!==null&&D.envMap===null?le.environmentRotation:D.envMapRotation,Dt===void 0&&(D.addEventListener("dispose",Dn),Dt=new Map,Me.programs=Dt);let $t=Dt.get(ft);if($t!==void 0){if(Me.currentProgram===$t&&Me.lightsStateVersion===et)return la(D,Je),$t}else Je.uniforms=Ne.getUniforms(D),Y!==null&&D.isNodeMaterial&&Y.build(D,he,Je),D.onBeforeCompile(Je,z),$t=Ne.acquireProgram(Je,ft),Dt.set(ft,$t),Me.uniforms=Je.uniforms;let Et=Me.uniforms;return(!D.isShaderMaterial&&!D.isRawShaderMaterial||D.clipping===!0)&&(Et.clippingPlanes=ot.uniform),la(D,Je),Me.needsLights=sr(D),Me.lightsStateVersion=et,Me.needsLights&&(Et.ambientLightColor.value=Se.state.ambient,Et.lightProbe.value=Se.state.probe,Et.sunLights.value=Se.state.sun,Et.sunLightShadows.value=Se.state.sunShadow,Et.directionalLights.value=Se.state.directional,Et.directionalLightShadows.value=Se.state.directionalShadow,Et.spotLights.value=Se.state.spot,Et.spotLightShadows.value=Se.state.spotShadow,Et.rectAreaLights.value=Se.state.rectArea,Et.ltc_1.value=Se.state.rectAreaLTC1,Et.ltc_2.value=Se.state.rectAreaLTC2,Et.pointLights.value=Se.state.point,Et.pointLightShadows.value=Se.state.pointShadow,Et.hemisphereLights.value=Se.state.hemi,Et.sunShadowMatrix.value=Se.state.sunShadowMatrix,Et.sunShadowCascade.value=Se.state.sunShadowCascade,Et.directionalShadowMatrix.value=Se.state.directionalShadowMatrix,Et.spotLightMatrix.value=Se.state.spotLightMatrix,Et.spotLightMap.value=Se.state.spotLightMap,Et.pointShadowMatrix.value=Se.state.pointShadowMatrix),Me.lightProbeGrid=S.state.lightProbeGridArray.length>0,Me.currentProgram=$t,Me.uniformsList=null,$t}function ar(D){if(D.uniformsList===null){let le=D.currentProgram.getUniforms();D.uniformsList=Do.seqWithValue(le.seq,D.uniforms)}return D.uniformsList}function la(D,le){let he=ye.get(D);he.outputColorSpace=le.outputColorSpace,he.batching=le.batching,he.batchingColor=le.batchingColor,he.instancing=le.instancing,he.instancingColor=le.instancingColor,he.instancingMorph=le.instancingMorph,he.skinning=le.skinning,he.morphTargets=le.morphTargets,he.morphNormals=le.morphNormals,he.morphColors=le.morphColors,he.morphTargetsCount=le.morphTargetsCount,he.numClippingPlanes=le.numClippingPlanes,he.numIntersection=le.numClipIntersection,he.vertexAlphas=le.vertexAlphas,he.vertexTangents=le.vertexTangents,he.toneMapping=le.toneMapping}function Za(D,le){if(D.length===0)return null;if(D.length===1)return D[0].texture!==null?D[0]:null;_.setFromMatrixPosition(le.matrixWorld);for(let he=0,Me=D.length;he<Me;he++){let Se=D[he];if(Se.texture!==null&&Se.boundingBox.containsPoint(_))return Se}return null}function Ei(D,le,he,Me,Se){le.isScene!==!0&&(le=ln),we.resetTextureUnits();let ke=le.fog,et=Me.isMeshStandardMaterial||Me.isMeshLambertMaterial||Me.isMeshPhongMaterial?le.environment:null,Je=j===null?z.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Ln.workingColorSpace,ft=Me.isMeshStandardMaterial||Me.isMeshLambertMaterial&&!Me.envMap||Me.isMeshPhongMaterial&&!Me.envMap,Dt=ze.get(Me.envMap||et,ft),tn=Me.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,$t=!!he.attributes.tangent&&(!!Me.normalMap||Me.anisotropy>0),Et=!!he.morphAttributes.position,hn=!!he.morphAttributes.normal,Vn=!!he.morphAttributes.color,It=aa;Me.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(It=z.toneMapping);let Qt=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,jt=Qt!==void 0?Qt.length:0,Le=ye.get(Me),An=S.state.lights;if(Tt===!0&&(Zt===!0||D!==re)){let kn=D===re&&Me.id===K;ot.setState(Me,D,kn)}let pn=!1;Me.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==An.state.version||Le.outputColorSpace!==Je||Se.isBatchedMesh&&Le.batching===!1||!Se.isBatchedMesh&&Le.batching===!0||Se.isBatchedMesh&&Le.batchingColor===!0&&Se._colorsTexture===null||Se.isBatchedMesh&&Le.batchingColor===!1&&Se._colorsTexture!==null||Se.isInstancedMesh&&Le.instancing===!1||!Se.isInstancedMesh&&Le.instancing===!0||Se.isSkinnedMesh&&Le.skinning===!1||!Se.isSkinnedMesh&&Le.skinning===!0||Se.isInstancedMesh&&Le.instancingColor===!0&&Se.instanceColor===null||Se.isInstancedMesh&&Le.instancingColor===!1&&Se.instanceColor!==null||Se.isInstancedMesh&&Le.instancingMorph===!0&&Se.morphTexture===null||Se.isInstancedMesh&&Le.instancingMorph===!1&&Se.morphTexture!==null||Le.envMap!==Dt||Me.fog===!0&&Le.fog!==ke||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ot.numPlanes||Le.numIntersection!==ot.numIntersection)||Le.vertexAlphas!==tn||Le.vertexTangents!==$t||Le.morphTargets!==Et||Le.morphNormals!==hn||Le.morphColors!==Vn||Le.toneMapping!==It||Le.morphTargetsCount!==jt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(pn=!0):(pn=!0,Le.__version=Me.version);let yi=Le.currentProgram;pn===!0&&(yi=Bn(Me,le,Se),Y&&Me.isNodeMaterial&&Y.onUpdateProgram(Me,yi,Le));let or=!1,Li=!1,vr=!1,Mn=yi.getUniforms(),Yn=Le.uniforms;if(w.useProgram(yi.program)&&(or=!0,Li=!0,vr=!0),Me.id!==K&&(K=Me.id,Li=!0),Le.needsLights){let kn=Za(S.state.lightProbeGridArray,Se);Le.lightProbeGrid!==kn&&(Le.lightProbeGrid=kn,Li=!0)}if(or||re!==D){w.buffers.depth.getReversed()&&D.reversedDepth!==!0&&(D._reversedDepth=!0,D.updateProjectionMatrix()),Mn.setValue(se,"projectionMatrix",D.projectionMatrix),Mn.setValue(se,"viewMatrix",D.matrixWorldInverse);let ki=Mn.map.cameraPosition;ki!==void 0&&ki.setValue(se,bt.setFromMatrixPosition(D.matrixWorld)),W.logarithmicDepthBuffer&&Mn.setValue(se,"logDepthBufFC",2/(Math.log(D.far+1)/Math.LN2)),(Me.isMeshPhongMaterial||Me.isMeshToonMaterial||Me.isMeshLambertMaterial||Me.isMeshBasicMaterial||Me.isMeshStandardMaterial||Me.isShaderMaterial)&&Mn.setValue(se,"isOrthographic",D.isOrthographicCamera===!0),re!==D&&(re=D,Li=!0,vr=!0)}if(Le.needsLights&&(An.state.sunShadowMap.length>0&&Mn.setValue(se,"sunShadowMap",An.state.sunShadowMap,we),An.state.directionalShadowMap.length>0&&Mn.setValue(se,"directionalShadowMap",An.state.directionalShadowMap,we),An.state.spotShadowMap.length>0&&Mn.setValue(se,"spotShadowMap",An.state.spotShadowMap,we),An.state.pointShadowMap.length>0&&Mn.setValue(se,"pointShadowMap",An.state.pointShadowMap,we)),Se.isSkinnedMesh){Mn.setOptional(se,Se,"bindMatrix"),Mn.setOptional(se,Se,"bindMatrixInverse");let kn=Se.skeleton;kn&&(kn.boneTexture===null&&kn.computeBoneTexture(),Mn.setValue(se,"boneTexture",kn.boneTexture,we))}Se.isBatchedMesh&&(Mn.setOptional(se,Se,"batchingTexture"),Mn.setValue(se,"batchingTexture",Se._matricesTexture,we),Mn.setOptional(se,Se,"batchingIdTexture"),Mn.setValue(se,"batchingIdTexture",Se._indirectTexture,we),Mn.setOptional(se,Se,"batchingColorTexture"),Se._colorsTexture!==null&&Mn.setValue(se,"batchingColorTexture",Se._colorsTexture,we));let Zi=he.morphAttributes;if((Zi.position!==void 0||Zi.normal!==void 0||Zi.color!==void 0)&&ie.update(Se,he,yi),(Li||Le.receiveShadow!==Se.receiveShadow)&&(Le.receiveShadow=Se.receiveShadow,Mn.setValue(se,"receiveShadow",Se.receiveShadow)),(Me.isMeshStandardMaterial||Me.isMeshLambertMaterial||Me.isMeshPhongMaterial)&&Me.envMap===null&&le.environment!==null&&(Yn.envMapIntensity.value=le.environmentIntensity),Yn.dfgLUT!==void 0&&(Yn.dfgLUT.value=wb()),Li){if(Mn.setValue(se,"toneMappingExposure",z.toneMappingExposure),Le.needsLights&&mr(Yn,vr),ke&&Me.fog===!0&&je.refreshFogUniforms(Yn,ke),je.refreshMaterialUniforms(Yn,Me,de,ae,S.state.transmissionRenderTarget[D.id]),Le.needsLights&&Le.lightProbeGrid){let kn=Le.lightProbeGrid;Yn.probesSH.value=kn.texture,Yn.probesMin.value.copy(kn.boundingBox.min),Yn.probesMax.value.copy(kn.boundingBox.max),Yn.probesResolution.value.copy(kn.resolution)}Do.upload(se,ar(Le),Yn,we)}if(Me.isShaderMaterial&&Me.uniformsNeedUpdate===!0&&(Do.upload(se,ar(Le),Yn,we),Me.uniformsNeedUpdate=!1),Me.isSpriteMaterial&&Mn.setValue(se,"center",Se.center),Mn.setValue(se,"modelViewMatrix",Se.modelViewMatrix),Mn.setValue(se,"normalMatrix",Se.normalMatrix),Mn.setValue(se,"modelMatrix",Se.matrixWorld),Me.uniformsGroups!==void 0){let kn=Me.uniformsGroups;for(let ki=0,ca=kn.length;ki<ca;ki++){let lr=kn[ki];Be.update(lr,yi),Be.bind(lr,yi)}}return yi}function mr(D,le){D.ambientLightColor.needsUpdate=le,D.lightProbe.needsUpdate=le,D.sunLights.needsUpdate=le,D.sunLightShadows.needsUpdate=le,D.directionalLights.needsUpdate=le,D.directionalLightShadows.needsUpdate=le,D.pointLights.needsUpdate=le,D.pointLightShadows.needsUpdate=le,D.spotLights.needsUpdate=le,D.spotLightShadows.needsUpdate=le,D.rectAreaLights.needsUpdate=le,D.hemisphereLights.needsUpdate=le}function sr(D){return D.isMeshLambertMaterial||D.isMeshToonMaterial||D.isMeshPhongMaterial||D.isMeshStandardMaterial||D.isShadowMaterial||D.isShaderMaterial&&D.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return ee},this.getRenderTarget=function(){return j},this.setRenderTargetTextures=function(D,le,he){let Me=ye.get(D);Me.__autoAllocateDepthBuffer=D.resolveDepthBuffer===!1,Me.__autoAllocateDepthBuffer===!1&&(Me.__useRenderToTexture=!1),ye.get(D.texture).__webglTexture=le,ye.get(D.depthTexture).__webglTexture=Me.__autoAllocateDepthBuffer?void 0:he,Me.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(D,le){let he=ye.get(D);he.__webglFramebuffer=le,he.__useDefaultFramebuffer=le===void 0},this.setRenderTarget=function(D,le=0,he=0){j=D,H=le,ee=he;let Me=null,Se=!1,ke=!1;if(D){let Je=ye.get(D);if(Je.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(se.FRAMEBUFFER,Je.__webglFramebuffer),J.copy(D.viewport),ne.copy(D.scissor),Te=D.scissorTest,w.viewport(J),w.scissor(ne),w.setScissorTest(Te),K=-1;return}else if(Je.__webglFramebuffer===void 0)we.setupRenderTarget(D);else if(Je.__hasExternalTextures)we.rebindTextures(D,ye.get(D.texture).__webglTexture,ye.get(D.depthTexture).__webglTexture);else if(D.depthBuffer){let tn=D.depthTexture;if(Je.__boundDepthTexture!==tn){if(tn!==null&&ye.has(tn)&&(D.width!==tn.image.width||D.height!==tn.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");we.setupDepthRenderbuffer(D)}}let ft=D.texture;(ft.isData3DTexture||ft.isDataArrayTexture||ft.isCompressedArrayTexture)&&(ke=!0);let Dt=ye.get(D).__webglFramebuffer;D.isWebGLCubeRenderTarget?(Array.isArray(Dt[le])?Me=Dt[le][he]:Me=Dt[le],Se=!0):D.samples>0&&we.useMultisampledRTT(D)===!1?Me=ye.get(D).__webglMultisampledFramebuffer:Array.isArray(Dt)?Me=Dt[he]:Me=Dt,J.copy(D.viewport),ne.copy(D.scissor),Te=D.scissorTest}else J.copy($e).multiplyScalar(de).floor(),ne.copy(ut).multiplyScalar(de).floor(),Te=zt;if(he!==0&&(Me=E),w.bindFramebuffer(se.FRAMEBUFFER,Me)&&w.drawBuffers(D,Me),w.viewport(J),w.scissor(ne),w.setScissorTest(Te),Se){let Je=ye.get(D.texture);se.framebufferTexture2D(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_CUBE_MAP_POSITIVE_X+le,Je.__webglTexture,he)}else if(ke){let Je=le;for(let ft=0;ft<D.textures.length;ft++){let Dt=ye.get(D.textures[ft]);se.framebufferTextureLayer(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0+ft,Dt.__webglTexture,he,Je)}}else if(D!==null&&he!==0){let Je=ye.get(D.texture);se.framebufferTexture2D(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_2D,Je.__webglTexture,he)}K=-1};function Vr(D){let le=ye.get(D);return(le.__readFormat!==D.format||le.__readType!==D.type)&&(le.__readFormat=D.format,le.__readType=D.type,le.__formatReadable=W.textureFormatReadable(D.format),le.__typeReadable=W.textureTypeReadable(D.type)),le}this.readRenderTargetPixels=function(D,le,he,Me,Se,ke,et,Je=0){if(!(D&&D.isWebGLRenderTarget)){sn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ft=ye.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&et!==void 0&&(ft=ft[et]),ft){w.bindFramebuffer(se.FRAMEBUFFER,ft);try{let Dt=D.textures[Je],tn=Dt.format,$t=Dt.type;D.textures.length>1&&se.readBuffer(se.COLOR_ATTACHMENT0+Je);let Et=Vr(Dt);if(Et.__formatReadable===!1){sn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Et.__typeReadable===!1){sn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=D.width-Me&&he>=0&&he<=D.height-Se&&se.readPixels(le,he,Me,Se,nt.convert(tn),nt.convert($t),ke)}finally{let Dt=j!==null?ye.get(j).__webglFramebuffer:null;w.bindFramebuffer(se.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(D,le,he,Me,Se,ke,et,Je=0){if(!(D&&D.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ft=ye.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&et!==void 0&&(ft=ft[et]),ft)if(le>=0&&le<=D.width-Me&&he>=0&&he<=D.height-Se){w.bindFramebuffer(se.FRAMEBUFFER,ft);let Dt=D.textures[Je],tn=Dt.format,$t=Dt.type;D.textures.length>1&&se.readBuffer(se.COLOR_ATTACHMENT0+Je);let Et=Vr(Dt);if(Et.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Et.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let hn=se.createBuffer();se.bindBuffer(se.PIXEL_PACK_BUFFER,hn),se.bufferData(se.PIXEL_PACK_BUFFER,ke.byteLength,se.STREAM_READ),se.readPixels(le,he,Me,Se,nt.convert(tn),nt.convert($t),0),se.bindBuffer(se.PIXEL_PACK_BUFFER,null);let Vn=j!==null?ye.get(j).__webglFramebuffer:null;w.bindFramebuffer(se.FRAMEBUFFER,Vn);let It=se.fenceSync(se.SYNC_GPU_COMMANDS_COMPLETE,0);return se.flush(),await x0(se,It,4),se.bindBuffer(se.PIXEL_PACK_BUFFER,hn),se.getBufferSubData(se.PIXEL_PACK_BUFFER,0,ke),se.bindBuffer(se.PIXEL_PACK_BUFFER,null),se.deleteBuffer(hn),se.deleteSync(It),ke}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(D,le=null,he=0){let Me=Math.pow(2,-he),Se=Math.floor(D.image.width*Me),ke=Math.floor(D.image.height*Me),et=le!==null?le.x:0,Je=le!==null?le.y:0;we.setTexture2D(D,0),se.copyTexSubImage2D(se.TEXTURE_2D,he,0,0,et,Je,Se,ke),w.unbindTexture()},this.copyTextureToTexture=function(D,le,he=null,Me=null,Se=0,ke=0){let et,Je,ft,Dt,tn,$t,Et,hn,Vn,It=D.isCompressedTexture?D.mipmaps[ke]:D.image;if(he!==null)et=he.max.x-he.min.x,Je=he.max.y-he.min.y,ft=he.isBox3?he.max.z-he.min.z:1,Dt=he.min.x,tn=he.min.y,$t=he.isBox3?he.min.z:0;else{let Yn=Math.pow(2,-Se);et=Math.floor(It.width*Yn),Je=Math.floor(It.height*Yn),D.isDataArrayTexture?ft=It.depth:D.isData3DTexture?ft=Math.floor(It.depth*Yn):ft=1,Dt=0,tn=0,$t=0}Me!==null?(Et=Me.x,hn=Me.y,Vn=Me.z):(Et=0,hn=0,Vn=0);let Qt=nt.convert(le.format),jt=nt.convert(le.type),Le;le.isData3DTexture?(we.setTexture3D(le,0),Le=se.TEXTURE_3D):le.isDataArrayTexture||le.isCompressedArrayTexture?(we.setTexture2DArray(le,0),Le=se.TEXTURE_2D_ARRAY):(we.setTexture2D(le,0),Le=se.TEXTURE_2D),w.activeTexture(se.TEXTURE0),w.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,le.flipY),w.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,le.premultiplyAlpha),w.pixelStorei(se.UNPACK_ALIGNMENT,le.unpackAlignment);let An=w.getParameter(se.UNPACK_ROW_LENGTH),pn=w.getParameter(se.UNPACK_IMAGE_HEIGHT),yi=w.getParameter(se.UNPACK_SKIP_PIXELS),or=w.getParameter(se.UNPACK_SKIP_ROWS),Li=w.getParameter(se.UNPACK_SKIP_IMAGES);w.pixelStorei(se.UNPACK_ROW_LENGTH,It.width),w.pixelStorei(se.UNPACK_IMAGE_HEIGHT,It.height),w.pixelStorei(se.UNPACK_SKIP_PIXELS,Dt),w.pixelStorei(se.UNPACK_SKIP_ROWS,tn),w.pixelStorei(se.UNPACK_SKIP_IMAGES,$t);let vr=D.isDataArrayTexture||D.isData3DTexture,Mn=le.isDataArrayTexture||le.isData3DTexture;if(D.isDepthTexture){let Yn=ye.get(D),Zi=ye.get(le),kn=ye.get(Yn.__renderTarget),ki=ye.get(Zi.__renderTarget);w.bindFramebuffer(se.READ_FRAMEBUFFER,kn.__webglFramebuffer),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,ki.__webglFramebuffer);for(let ca=0;ca<ft;ca++)vr&&(se.framebufferTextureLayer(se.READ_FRAMEBUFFER,se.COLOR_ATTACHMENT0,ye.get(D).__webglTexture,Se,$t+ca),se.framebufferTextureLayer(se.DRAW_FRAMEBUFFER,se.COLOR_ATTACHMENT0,ye.get(le).__webglTexture,ke,Vn+ca)),se.blitFramebuffer(Dt,tn,et,Je,Et,hn,et,Je,se.DEPTH_BUFFER_BIT,se.NEAREST);w.bindFramebuffer(se.READ_FRAMEBUFFER,null),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,null)}else if(Se!==0||D.isRenderTargetTexture||ye.has(D)){let Yn=ye.get(D),Zi=ye.get(le);w.bindFramebuffer(se.READ_FRAMEBUFFER,M),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,O);for(let kn=0;kn<ft;kn++)vr?se.framebufferTextureLayer(se.READ_FRAMEBUFFER,se.COLOR_ATTACHMENT0,Yn.__webglTexture,Se,$t+kn):se.framebufferTexture2D(se.READ_FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_2D,Yn.__webglTexture,Se),Mn?se.framebufferTextureLayer(se.DRAW_FRAMEBUFFER,se.COLOR_ATTACHMENT0,Zi.__webglTexture,ke,Vn+kn):se.framebufferTexture2D(se.DRAW_FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_2D,Zi.__webglTexture,ke),Se!==0?se.blitFramebuffer(Dt,tn,et,Je,Et,hn,et,Je,se.COLOR_BUFFER_BIT,se.NEAREST):Mn?se.copyTexSubImage3D(Le,ke,Et,hn,Vn+kn,Dt,tn,et,Je):se.copyTexSubImage2D(Le,ke,Et,hn,Dt,tn,et,Je);w.bindFramebuffer(se.READ_FRAMEBUFFER,null),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,null)}else Mn?D.isDataTexture||D.isData3DTexture?se.texSubImage3D(Le,ke,Et,hn,Vn,et,Je,ft,Qt,jt,It.data):le.isCompressedArrayTexture?se.compressedTexSubImage3D(Le,ke,Et,hn,Vn,et,Je,ft,Qt,It.data):se.texSubImage3D(Le,ke,Et,hn,Vn,et,Je,ft,Qt,jt,It):D.isDataTexture?se.texSubImage2D(se.TEXTURE_2D,ke,Et,hn,et,Je,Qt,jt,It.data):D.isCompressedTexture?se.compressedTexSubImage2D(se.TEXTURE_2D,ke,Et,hn,It.width,It.height,Qt,It.data):se.texSubImage2D(se.TEXTURE_2D,ke,Et,hn,et,Je,Qt,jt,It);w.pixelStorei(se.UNPACK_ROW_LENGTH,An),w.pixelStorei(se.UNPACK_IMAGE_HEIGHT,pn),w.pixelStorei(se.UNPACK_SKIP_PIXELS,yi),w.pixelStorei(se.UNPACK_SKIP_ROWS,or),w.pixelStorei(se.UNPACK_SKIP_IMAGES,Li),ke===0&&le.generateMipmaps&&se.generateMipmap(Le),w.unbindTexture()},this.initRenderTarget=function(D){ye.get(D).__webglFramebuffer===void 0&&we.setupRenderTarget(D)},this.initTexture=function(D){D.isCubeTexture?we.setTextureCube(D,0):D.isData3DTexture?we.setTexture3D(D,0):D.isDataArrayTexture||D.isCompressedArrayTexture?we.setTexture2DArray(D,0):we.setTexture2D(D,0),w.unbindTexture()},this.resetState=function(){H=0,ee=0,j=null,w.reset(),dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ra}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ln._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ln._getUnpackColorSpace()}};var Pd=function(){return Pd=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},Pd.apply(this,arguments)},ti=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.")},Kl=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},iv=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 Tb(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 Wi;return h.setAttribute("position",new Xn(o,3)),h.setAttribute("normal",new Xn(u,3)),h.setAttribute("uv",new Xn(l,2)),h.setIndex(Array.from(f)),h}function rv(n,e,t){return!n||t>=1?0:t<=-1?1.1:(1-t)*.55}function Eb(n,e,t){var i,r,a,s,o,u,l,d,f,h,v,y,T,g,m,L,F,_=new Er,p=!!n.fairwayRamp,S=(T=n.cupX)!==null&&T!==void 0?T:0,B=(g=n.cupZ)!==null&&g!==void 0?g:-4.8,b=(m=n.cupRadius)!==null&&m!==void 0?m:.23,I=new Or(1,1,1),z=new Map,U=function(Ae,Ne,je,Ve,qe,ot,pt){var He=z.get(pt);He||(He=new Xi({color:pt}),z.set(pt,He));var ie=new jn(I,He);ie.position.set(Ae,Ne,je),ie.scale.set(Ve,qe,ot),_.add(ie)};try{for(var Y=ti([-3.2,3.2]),E=Y.next();!E.done;E=Y.next()){var M=E.value;U(M,-.65,0,.2,1.1,14.6,"#a1b8b1"),U(M-Math.sign(M)*.1,-.18,0,.2,.25,14.4,"#e9cea5")}}catch(Ae){i={error:Ae}}finally{try{E&&!E.done&&(r=Y.return)&&r.call(Y)}finally{if(i)throw i.error}}try{for(var O=ti([-7.2,7.2]),H=O.next();!H.done;H=O.next()){var ee=H.value;U(0,-.65,ee,6.4,1.1,.2,"#a1b8b1"),U(0,-.18,ee-Math.sign(ee)*.1,6.2,.25,.2,"#e9cea5")}}catch(Ae){a={error:Ae}}finally{try{H&&!H.done&&(s=O.return)&&s.call(O)}finally{if(a)throw a.error}}var j=.5,K=.5;if(t){var re=t.getAttribute("uv"),J=t.getAttribute("normal");if(re&&J){for(var ne=0;ne<J.count&&J.getY(ne)<.9;)ne++;ne<re.count&&(j=re.getX(ne),K=re.getY(ne))}}var Te=!!(e&&(!((L=e.image)===null||L===void 0)&&L.complete)&&((F=e.image)===null||F===void 0?void 0:F.naturalWidth)>0),fe=Te?new Xi({map:e}):new Xi({color:"#6ec458"}),pe=Te?new Xi({map:e,color:"#779263"}):new Xi({color:"#5a9949"});e&&!Te&&(fe.userData.pendingTex={tex:e,color:"#ffffff"},pe.userData.pendingTex={tex:e,color:"#779263"});var Fe=p?[[-7,-1],[-1,1],[1,7]]:[[-7,7]];try{for(var ae=ti(Fe),de=ae.next();!de.done;de=ae.next()){var _e=Kl(de.value,2),Ge=_e[0],$e=_e[1],ut=new So;if(ut.moveTo(-3,Ge),ut.lineTo(3,Ge),ut.lineTo(3,$e),ut.lineTo(-3,$e),ut.closePath(),B>Ge&&B<$e){var zt=new Ns;zt.absarc(S,B,b,0,Math.PI*2,!0),ut.holes.push(zt)}for(var ct=new Ll(ut,32),Tt=ct.getAttribute("position"),Zt=!1,wt=!1,bt=0;bt<Tt.count;bt++){var _t=Tt.getX(bt),ln=Tt.getY(bt),rt=rv(p,_t,ln);rt===0&&(Zt=!0),rt>0&&(wt=!0),Tt.setXYZ(bt,_t,rt,ln)}var an=ct.getIndex();if(an)for(var bt=0;bt<an.count;bt+=3){var se=an.getX(bt+1);an.setX(bt+1,an.getX(bt+2)),an.setX(bt+2,se)}ct.computeVertexNormals();for(var mn=ct.getAttribute("uv"),bt=0;bt<mn.count;bt++)mn.setXY(bt,j,K);var nn=new jn(ct,p&&Zt&&wt?pe:fe);nn.name="continuous-fairway",_.add(nn)}}catch(Ae){o={error:Ae}}finally{try{de&&!de.done&&(u=ae.return)&&u.call(ae)}finally{if(o)throw o.error}}var W="#d69260",w="#f1bd87";try{for(var ue=ti([-3.1,3.1]),ye=ue.next();!ye.done;ye=ue.next()){var M=ye.value;U(M,.12,0,.2,.3,14.2,W),U(M,.29,0,.22,.04,14.2,w)}}catch(Ae){l={error:Ae}}finally{try{ye&&!ye.done&&(d=ue.return)&&d.call(ue)}finally{if(l)throw l.error}}try{for(var we=ti([-7.1,7.1]),ze=we.next();!ze.done;ze=we.next()){var ee=ze.value;U(0,rv(p,0,ee>0?6:-6)+.12,ee,6.4,.3,.2,W)}}catch(Ae){f={error:Ae}}finally{try{ze&&!ze.done&&(h=we.return)&&h.call(we)}finally{if(f)throw f.error}}if(p)try{for(var Ye=ti([-3.1,3.1]),Re=Ye.next();!Re.done;Re=Ye.next()){var M=Re.value;U(M,.7,-4.5,.2,1.1,5.2,W)}}catch(Ae){v={error:Ae}}finally{try{Re&&!Re.done&&(y=Ye.return)&&y.call(Ye)}finally{if(v)throw v.error}}return _}function Ab(n){var e,t=new Er,i=(e=n.cupRadius)!==null&&e!==void 0?e:.23,r=new jn(new Ds(i,i*.89,.48,24,1,!0),new Xi({color:"#244640",side:Ir}));r.position.y=-.24,t.add(r);var a=new jn(new _o(i*.91,24),new Ta({color:"#082c2b"}));a.rotation.x=-Math.PI/2,a.position.y=-.475,t.add(a);var s=new jn(new Ds(i,i*.978,.09,24,1,!0),new Xi({color:"#eee9cf",side:Ir}));s.position.y=-.045,t.add(s);var o=new jn(new wo(i,i+.06,24),new Xi({color:"#fff7d1"}));return o.rotation.x=-Math.PI/2,o.position.y=.004,t.add(o),t}function Ib(){for(var n,e,t=new Er,i=new Or(.18,1,.18),r=new Xi({color:"#b27b59"}),a=new Or(1.5,.2,1.6),s=new Xi({color:"#82b88b"}),o=new ds(.62,7,5),u=new ds(.49,7,5),l=new Xi({color:"#77b86b"}),d=new Xi({color:"#3e9d79"}),f=new Ea(i,r,14),h=new Ea(a,s,14),v=5,y=9,T=new Ea(o,l,v),g=new Ea(u,l,v),m=new Ea(o,d,y),L=new Ea(u,d,y),F=new $n,_=0,p=0,S=0;S<14;S++){var B=S%2?-1:1,b=B*(3.8+S%3*.35),I=-6.5+Math.floor(S/2)*2;F.makeTranslation(b,-.02,I),f.setMatrixAt(S,F),F.makeTranslation(b,-.48,I),h.setMatrixAt(S,F),S%3===0?(F.makeTranslation(b,.5,I),T.setMatrixAt(_,F),F.makeTranslation(b,1,I),g.setMatrixAt(_,F),_++):(F.makeTranslation(b,.5,I),m.setMatrixAt(p,F),F.makeTranslation(b,1,I),L.setMatrixAt(p,F),p++)}try{for(var z=ti([f,h,T,g,m,L]),U=z.next();!U.done;U=z.next()){var Y=U.value;Y.instanceMatrix.needsUpdate=!0,t.add(Y)}}catch(E){n={error:E}}finally{try{U&&!U.done&&(e=z.return)&&e.call(z)}finally{if(n)throw n.error}}return t}function Cb(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 av(n,e,t){var i=new Map,r=new Map,a=new Map,s,o,u,l,d;function f(){var _,p;if(o!==void 0)return o;try{return s=document.createElement("canvas"),(_=s.addEventListener)===null||_===void 0||_.call(s,"webglcontextrestored",function(){var S,B;d=void 0;try{for(var b=ti(a.values()),I=b.next();!I.done;I=b.next()){var z=I.value;z.compiled=!1,z.textureDirty=!0,z.lastRenderedTime=-1,z.lastFlagStep=-1}}catch(U){S={error:U}}finally{try{I&&!I.done&&(B=b.return)&&B.call(b)}finally{if(S)throw S.error}}t?.()}),u=document.createElement("canvas"),l=(p=u.getContext)===null||p===void 0?void 0:p.call(u,"2d"),o=new Id({canvas:s,antialias:!0,alpha:!1,preserveDrawingBuffer:!1,powerPreference:"default"}),o.shadowMap.type=Du,o}catch{return o=null,null}}function h(_){if(_){if(i.has(_))return i.get(_);var p=e.get(_);if(!(!p||p.mime!=="model/tora-mesh"||!p.data)){var S=Tb(p.data);return i.set(_,S),S}}}function v(_){if(_){if(r.has(_))return r.get(_);var p=e.get(_);if(!(!p||!p.mime.startsWith("image/")||!p.data)){var S=new Image,B=new tr(S);B.colorSpace=hr;var b=function(I){var z,U;B.needsUpdate=!0;try{for(var Y=ti(a.values()),E=Y.next();!E.done;E=Y.next()){var M=E.value;M.scene.traverse(function(O){var H,ee,j,K=O.isMesh&&O.material?Array.isArray(O.material)?O.material:[O.material]:[];try{for(var re=(H=void 0,ti(K)),J=re.next();!J.done;J=re.next()){var ne=J.value;!((j=ne.userData)===null||j===void 0)&&j.pendingTex&&ne.userData.pendingTex.tex===B&&(ne.map=B,ne.color.set(ne.userData.pendingTex.color||"#ffffff"),delete ne.userData.pendingTex,ne.needsUpdate=!0)}}catch(Te){H={error:Te}}finally{try{J&&!J.done&&(ee=re.return)&&ee.call(re)}finally{if(H)throw H.error}}}),M.textureDirty=!0}}catch(O){z={error:O}}finally{try{E&&!E.done&&(U=Y.return)&&U.call(Y)}finally{if(z)throw z.error}}I&&t?.()};return r.set(_,B),S.onload=function(){return b(!0)},S.src="data:"+p.mime+";base64,"+p.data,S.complete&&S.naturalWidth&&b(!1),B}}}function y(_){var p,S,B,b,I,z,U,Y,E,M,O,H,ee,j,K,re,J,ne,Te,fe,pe=_.parameters,Fe=new vl;Fe.background=new vn(pe.skyColor||"#b8e2ed");var ae=new er((B=pe.cameraFov)!==null&&B!==void 0?B:39,1,.1,160);ae.position.set((b=pe.cameraX)!==null&&b!==void 0?b:10,(I=pe.cameraY)!==null&&I!==void 0?I:18,(z=pe.cameraZ)!==null&&z!==void 0?z:21),ae.lookAt((U=pe.lookAtX)!==null&&U!==void 0?U:0,(Y=pe.lookAtY)!==null&&Y!==void 0?Y:.15,(E=pe.lookAtZ)!==null&&E!==void 0?E:0),Fe.add(ae),Fe.add(new Ul(pe.hemiSkyColor||"#fff9dd",pe.hemiGroundColor||"#527b75",(M=pe.hemiIntensity)!==null&&M!==void 0?M:1.8));var de=new Ol(pe.sunColor||"#fff0cf",(O=pe.sunIntensity)!==null&&O!==void 0?O:2.1);de.position.set((H=pe.sunX)!==null&&H!==void 0?H:-9,(ee=pe.sunY)!==null&&ee!==void 0?ee:18,(j=pe.sunZ)!==null&&j!==void 0?j:8),Fe.add(de);var _e=v((re=(K=_.assetSlots)===null||K===void 0?void 0:K[0])===null||re===void 0?void 0:re.assetId),Ge=new Map,$e=new Map,ut=[],zt=[];function ct(Ne,je,Ve,qe){Ne.traverse(function(ot){ot.userData.toraRootId=je,ot.userData.toraSourceId=Ve,qe&&(ot.userData.cameraAttached=!0)})}function Tt(Ne,je,Ve,qe,ot){var pt,He,ie,Oe,Pe,nt,dt,Be,Rt,vt,cn,dn,Fn,Dn,vi,rr,yn,En,Yi,en=Ne.parameters,xt,ni=function(){var qi,wi,gi={},Bn=!!(_e&&(!((qi=_e.image)===null||qi===void 0)&&qi.complete)&&((wi=_e.image)===null||wi===void 0?void 0:wi.naturalWidth)>0);en.useTexture&&_e&&Bn?gi.map=_e:gi.color=en.useTexture?en.waveFlag?"#e85d56":"#d89b6a":en.color||"#ffffff",en.doubleSide&&(gi.side=Ir),en.opacity<1&&(gi.transparent=!0,gi.opacity=en.opacity,gi.depthWrite=!1);var ar=en.unlit?new Ta(gi):new Xi(gi);return en.useTexture&&_e&&!Bn&&(ar.userData.pendingTex={tex:_e,color:"#ffffff"}),ar};if(en.primitive==="group")xt=new Er;else if(en.primitive==="fairway")xt=Eb(en,_e,h((He=(pt=Ne.assetSlots)===null||pt===void 0?void 0:pt[0])===null||He===void 0?void 0:He.assetId));else if(en.primitive==="cup")xt=Ab(en);else if(en.primitive==="garden")xt=Ib();else if(en.primitive==="mesh"){var fn=h((Oe=(ie=Ne.assetSlots)===null||ie===void 0?void 0:ie[0])===null||Oe===void 0?void 0:Oe.assetId),bi=en.waveFlag&&fn?fn.clone():fn??new Or(1,1,1);xt=new jn(bi,ni()),en.waveFlag&&fn&&ut.push({geo:bi,rest:new Float32Array(bi.getAttribute("position").array)})}else en.primitive==="sphere"?xt=new jn(new ds((Pe=en.radiusTop)!==null&&Pe!==void 0?Pe:.5,16,12),ni()):en.primitive==="cylinder"?xt=new jn(new Ds((nt=en.radiusTop)!==null&&nt!==void 0?nt:.23,(dt=en.radiusBottom)!==null&&dt!==void 0?dt:.21,1,32,1,!!en.openEnded),ni()):en.primitive==="ring"?xt=new jn(new wo((Be=en.innerRadius)!==null&&Be!==void 0?Be:0,(Rt=en.radiusTop)!==null&&Rt!==void 0?Rt:.15,24),ni()):en.primitive==="circle"?xt=new jn(new _o((vt=en.radiusTop)!==null&&vt!==void 0?vt:.21,32),ni()):xt=new jn(new Or(1,1,1),ni());return xt.position.set((cn=en.x)!==null&&cn!==void 0?cn:0,(dn=en.y)!==null&&dn!==void 0?dn:0,(Fn=en.z)!==null&&Fn!==void 0?Fn:0),xt.rotation.set((Dn=en.rx)!==null&&Dn!==void 0?Dn:0,(vi=en.ry)!==null&&vi!==void 0?vi:0,(rr=en.rz)!==null&&rr!==void 0?rr:0),xt.scale.set((yn=en.sx)!==null&&yn!==void 0?yn:1,(En=en.sy)!==null&&En!==void 0?En:1,(Yi=en.sz)!==null&&Yi!==void 0?Yi:1),xt.visible=en.visible!==!1,ct(xt,Ve,qe,ot),je.add(xt),xt}var Zt=[],wt=new Map,bt=function(Ne,je,Ve){var qe,ot;try{for(var pt=ti(n.components),He=pt.next();!He.done;He=pt.next()){var ie=He.value;if(ie.parentId===Ne&&ie.contract==="native.mesh3d.v1"&&!ie.prototype){var Oe=je??ie,Pe=Ve||!!ie.parameters.attachToCamera;wt.set(ie.id,{rootId:Oe.id,sourceId:Oe.id,cameraAttached:Pe}),Zt.push(ie),bt(ie.id,Oe,Pe)}}}catch(nt){qe={error:nt}}finally{try{He&&!He.done&&(ot=pt.return)&&ot.call(pt)}finally{if(qe)throw qe.error}}};bt(_.id,null,!1);var _t=function(Ne){var je=Ne.parameters,Ve=wt.get(Ne.id),qe=je.attachToCamera&&Ne.parentId===_.id?ae:Ne.parentId===_.id?Fe:(J=Ge.get(Ne.parentId))!==null&&J!==void 0?J:Fe,ot=Tt(Ne,qe,Ve.rootId,Ve.sourceId,Ve.cameraAttached);if(Ge.set(Ne.id,ot),je.confetti){var pt=new Er;pt.userData.isConfetti=!0;var He=new Or(.08,.025,.12),ie=["#ffda69","#fff6c9","#ef8774","#7cc6bf"].map(function(Pe){return new Ta({color:Pe})}),Oe=Array.from({length:28},function(Pe,nt){var dt=new jn(He,ie[nt%4]);return dt.visible=!1,pt.add(dt),dt});Fe.add(pt),zt.push({id:Ne.id,origin:{x:(ne=je.x)!==null&&ne!==void 0?ne:0,y:(Te=je.y)!==null&&Te!==void 0?Te:0,z:(fe=je.z)!==null&&fe!==void 0?fe:0},pieces:Oe})}};try{for(var ln=ti(Zt),rt=ln.next();!rt.done;rt=ln.next()){var an=rt.value;_t(an)}}catch(Ne){p={error:Ne}}finally{try{rt&&!rt.done&&(S=ln.return)&&S.call(ln)}finally{if(p)throw p.error}}var se=new Er;Fe.add(se);var mn=new ds(1,8,5),nn=new Ta({color:"#fff1a2",transparent:!0,opacity:.85}),W=Array.from({length:24},function(){var Ne=new jn(mn,nn);return Ne.visible=!1,se.add(Ne),Ne}),w=new Bl,ue=new kt,ye=new ge,we=new Ur(new ge(0,1,0),0),ze=new ge,Ye="",Re=Array.from(Ge,function(Ne){var je=Kl(Ne,2),Ve=je[0],qe=je[1];return{id:Ve,obj:qe,comp:n.components.find(function(ot){return ot.id===Ve})}}).filter(function(Ne){return Ne.comp}),Ae={id:_.id,scene:Fe,camera:ae,nodes:Ge,dynamicNodes:$e,nodeEntries:Re,createMeshObject:Tt,wavingFlags:ut,confettiSystems:zt,guideGroup:se,guidePool:W,compiled:!1,lastRenderMs:0,textureDirty:!0,skyColor:pe.skyColor||"#b8e2ed",lastWaveAt:-1,lastRenderedTime:-1,lastRenderedW:0,lastRenderedH:0,lastPoseSig:"",guideDirty:!0,focusZ:0,lastTime:-1,lastWidth:0,lastHeight:0,setGuide:function(Ne){var je=Ne?Math.min(Ne.length,W.length):0,Ve=je?Ne.slice(0,je).map(function(ie){return"".concat(ie.x.toFixed(2),",").concat(ie.y.toFixed(2),",").concat(ie.z.toFixed(2))}).join("|"):"";if(Ve!==Ye){Ye=Ve,Ae.guideDirty=!0;for(var qe=0;qe<W.length;qe++){var ot=W[qe];if(qe<je){var pt=Ne[qe],He=.055*(1-qe/je*.5);ot.visible=!0,ot.scale.setScalar(He),ot.position.set(pt.x,pt.y+.03,pt.z)}else ot.visible=!1}}},project:function(Ne,je,Ve){return ye.set(Ne.x,Ne.y,Ne.z).project(ae),{x:(ye.x+1)*je/2,y:(1-ye.y)*Ve/2}},unproject:function(Ne,je,Ve,qe,ot){return ue.set(Ne/Ve*2-1,1-je/qe*2),w.setFromCamera(ue,ae),we.constant=-ot,w.ray.intersectPlane(we,ze)?{x:ze.x,y:ze.y,z:ze.z}:null},raycast:function(Ne,je,Ve,qe){var ot,pt,He,ie,Oe,Pe;Ve===void 0&&(Ve=80);var nt=qe===void 0?{}:qe,dt=nt.isTarget,Be=dt===void 0?function(){return!0}:dt,Rt=nt.isOccluder,vt=Rt===void 0?function(){return!1}:Rt;Fe.updateMatrixWorld(!0),ae.updateMatrixWorld(!0),ue.set(Ne,je),w.near=.05,w.far=Ve,w.setFromCamera(ue,ae);var cn=w.intersectObjects(Fe.children,!0),dn=new Set;try{for(var Fn=ti(cn),Dn=Fn.next();!Dn.done;Dn=Fn.next()){for(var vi=Dn.value,rr=!1,yn=vi.object;yn;yn=yn.parent)if(!yn.visible||yn===se||!((He=yn.userData)===null||He===void 0)&&He.cameraAttached||!((ie=yn.userData)===null||ie===void 0)&&ie.isConfetti){rr=!0;break}if(!rr){var En=(Oe=vi.object.userData)===null||Oe===void 0?void 0:Oe.toraRootId,Yi=(Pe=vi.object.userData)===null||Pe===void 0?void 0:Pe.toraSourceId;if(!(!En||dn.has(En))){if(dn.add(En),Be(En,Yi))return{id:En,sourceId:Yi,distance:vi.distance,point:{x:vi.point.x,y:vi.point.y,z:vi.point.z}};if(vt(En,Yi))return null}}}}catch(en){ot={error:en}}finally{try{Dn&&!Dn.done&&(pt=Fn.return)&&pt.call(Fn)}finally{if(ot)throw ot.error}}return null}};return a.set(_.id,Ae),Ae}function T(_){var p;return(p=a.get(_.id))!==null&&p!==void 0?p:y(_)}function g(_,p){var S,B,b,I,z,U,Y,E,M,O,H,ee,j,K,re,J,ne,Te,fe,pe,Fe,ae,de,_e,Ge,$e,ut,zt,ct,Tt,Zt,wt,bt,_t,ln,rt,an,se,mn,nn,W,w,ue,ye,we,ze,Ye,Re,Ae,Ne,je,Ve,qe,ot,pt,He,ie,Oe,Pe,nt=p.time,dt=nt===void 0?0:nt,Be=p.ambientTime,Rt=p.propsOf,vt=p.bodies3d,cn=p.fpsPose,dn=p.instances3d,Fn=dn===void 0?[]:dn,Dn=p.aimLocked,vi=Dn===void 0?!1:Dn,rr=p.groundFn,yn=p.worldWidth,En=yn===void 0?390:yn,Yi=p.worldHeight,en=Yi===void 0?700:Yi,xt=T(_),ni=Be??dt,fn=Rt(_),bi=fn.skyColor||"#b8e2ed";xt.skyColor!==bi&&(xt.skyColor=bi,xt.scene.background=new vn(bi));var qi=new Set(Fn.map(function(Sn){return Sn.id}));try{for(var wi=ti(xt.dynamicNodes),gi=wi.next();!gi.done;gi=wi.next()){var Bn=Kl(gi.value,2),ar=Bn[0],la=Bn[1];qi.has(ar)||((H=la.parent)===null||H===void 0||H.remove(la),xt.dynamicNodes.delete(ar))}}catch(Sn){S={error:Sn}}finally{try{gi&&!gi.done&&(B=wi.return)&&B.call(wi)}finally{if(S)throw S.error}}var Za=function(Sn){if(xt.dynamicNodes.has(Sn.id))return"continue";var Di=Sn.parentId===_.id?xt.scene:(j=(ee=xt.dynamicNodes.get(Sn.parentId))!==null&&ee!==void 0?ee:xt.nodes.get(Sn.parentId))!==null&&j!==void 0?j:xt.scene,yr=(K=Sn.instanceId)!==null&&K!==void 0?K:Sn.id,Pa=(re=Fn.find(function($r){return $r.id===yr}))!==null&&re!==void 0?re:Sn,Jt=(J=Pa.prototypeId)!==null&&J!==void 0?J:Pa.id,pi=xt.createMeshObject(Sn,Di,yr,Jt,!!Sn.parameters.attachToCamera);xt.dynamicNodes.set(Sn.id,pi)};try{for(var Ei=ti(Fn),mr=Ei.next();!mr.done;mr=Ei.next()){var sr=mr.value;Za(sr)}}catch(Sn){b={error:Sn}}finally{try{mr&&!mr.done&&(I=Ei.return)&&I.call(Ei)}finally{if(b)throw b.error}}var Vr=iv(iv([],Kl(xt.nodeEntries),!1),Kl(Fn.map(function(Sn){return{id:Sn.id,obj:xt.dynamicNodes.get(Sn.id),comp:Sn}}).filter(function(Sn){return Sn.obj})),!1),D="";try{for(var le=ti(Vr),he=le.next();!he.done;he=le.next()){var Me=he.value,Se=Me.id,ke=Me.obj,sr=Me.comp,et=Rt(sr);ke.visible=et.visible!==!1,!et.useTexture&&ke.isMesh&&(!((ne=ke.material)===null||ne===void 0)&&ne.color)&&et.color&&ke.material.color.set(et.color);var Je=vt?.get(Se);if(Je&&Je.mode==="dynamic"){var ft=Je.captured?Math.min(1,((Te=Je.captureElapsed)!==null&&Te!==void 0?Te:0)/.55):0,Dt=Je.captured&&Je.captureTarget?Je.x+(Je.captureTarget.x-Je.x)*ft:Je.x,tn=Je.y-ft*.45,$t=Je.captured&&Je.captureTarget?Je.z+(Je.captureTarget.z-Je.z)*ft:Je.z;ke.position.set(Dt,tn,$t);var Et=1-ft*.65;ke.scale.set(((fe=et.sx)!==null&&fe!==void 0?fe:1)*Et,((pe=et.sy)!==null&&pe!==void 0?pe:1)*Et,((Fe=et.sz)!==null&&Fe!==void 0?Fe:1)*Et),ke.rotation.set(-((ae=Je.spin)!==null&&ae!==void 0?ae:0),(de=et.ry)!==null&&de!==void 0?de:0,((_e=Je.spin)!==null&&_e!==void 0?_e:0)*.22)}else if(Je&&Je.mode==="kinematic")ke.position.set(Je.x,($e=(Ge=Je.y)!==null&&Ge!==void 0?Ge:et.y)!==null&&$e!==void 0?$e:0,Je.z),ke.rotation.set((ut=et.rx)!==null&&ut!==void 0?ut:0,-((ct=(zt=Je.angle)!==null&&zt!==void 0?zt:et.ry)!==null&&ct!==void 0?ct:0),(Tt=et.rz)!==null&&Tt!==void 0?Tt:0);else if(et.dropShadowOf&&vt?.has(et.dropShadowOf)){var hn=vt.get(et.dropShadowOf),Vn=rr?(Zt=rr(hn,hn.x,hn.z))!==null&&Zt!==void 0?Zt:-1:0;ke.position.set(hn.x,Vn+.008,hn.z);var It=Math.max(0,hn.y-Vn-hn.radius);ke.material&&(ke.material.opacity=.22/(1+It*2));var Et=1+It*.4;ke.scale.set(Et,Et,Et),ke.visible=!hn.captured&&et.visible!==!1}else ke.position.set((wt=et.x)!==null&&wt!==void 0?wt:0,(bt=et.y)!==null&&bt!==void 0?bt:0,(_t=et.z)!==null&&_t!==void 0?_t:0),ke.rotation.set((ln=et.rx)!==null&&ln!==void 0?ln:0,(rt=et.ry)!==null&&rt!==void 0?rt:0,(an=et.rz)!==null&&an!==void 0?an:0),ke.scale.set((se=et.sx)!==null&&se!==void 0?se:1,(mn=et.sy)!==null&&mn!==void 0?mn:1,(nn=et.sz)!==null&&nn!==void 0?nn:1);(cn||xt.dynamicNodes.size>0)&&(D+="".concat(Se,":").concat(ke.visible?1:0,",").concat(ke.position.x.toFixed(3),",").concat(ke.position.y.toFixed(3),",").concat(ke.position.z.toFixed(3),",").concat(ke.rotation.y.toFixed(3),",").concat((W=et.color)!==null&&W!==void 0?W:"","|"))}}catch(Sn){z={error:Sn}}finally{try{he&&!he.done&&(U=le.return)&&U.call(le)}finally{if(z)throw z.error}}var Qt;if(vt)try{for(var jt=ti(vt.values()),Le=jt.next();!Le.done;Le=jt.next()){var Je=Le.value;if(Je.stageId===_.id&&Je.captured){Qt=Je;break}}}catch(Sn){Y={error:Sn}}finally{try{Le&&!Le.done&&(E=jt.return)&&E.call(jt)}finally{if(Y)throw Y.error}}var An=function(Sn){var Di=!!Qt,yr=Qt&&(w=Qt.captureElapsed)!==null&&w!==void 0?w:0;Sn.pieces.forEach(function(Pa,Jt){var pi,$r,Ms,Oo,Bo,Ja;if(Pa.visible=Di,!!Di){var ko=Jt*2.399,kd=($r=(pi=Qt.captureTarget)===null||pi===void 0?void 0:pi.x)!==null&&$r!==void 0?$r:Sn.origin.x,rc=(Oo=(Ms=Qt.captureTarget)===null||Ms===void 0?void 0:Ms.y)!==null&&Oo!==void 0?Oo:Sn.origin.y,ci=(Ja=(Bo=Qt.captureTarget)===null||Bo===void 0?void 0:Bo.z)!==null&&Ja!==void 0?Ja:Sn.origin.z;Pa.position.set(kd+Math.cos(ko)*yr*(.5+Jt%4*.17),rc+.3+Math.sin(Math.min(1,yr/2)*Math.PI)*(1+Jt%5*.15),ci+Math.sin(ko)*yr*(.5+Jt%4*.17)),Pa.rotation.set(yr*3+Jt,yr*2+Jt,Math.sin(yr+Jt))}})};try{for(var pn=ti(xt.confettiSystems),yi=pn.next();!yi.done;yi=pn.next()){var or=yi.value;An(or)}}catch(Sn){M={error:Sn}}finally{try{yi&&!yi.done&&(O=pn.return)&&O.call(pn)}finally{if(M)throw M.error}}var Li=en>=En,vr=xt.lastTime<0||ni<xt.lastTime?0:Math.min(.05,ni-xt.lastTime);xt.camera.aspect=En/Math.max(1,en);var Mn=!1;if(cn)xt.lastTime=ni,xt.camera.rotation.order="YXZ",xt.camera.position.set(cn.x,cn.y+((ue=cn.bob)!==null&&ue!==void 0?ue:0),cn.z),xt.camera.rotation.set(cn.pitch,cn.yaw,0),xt.camera.fov=Li?(ye=fn.cameraFov)!==null&&ye!==void 0?ye:68:(we=fn.landscapeCameraFov)!==null&&we!==void 0?we:54,D+="cam:".concat(xt.camera.position.x.toFixed(3),",").concat(xt.camera.position.y.toFixed(3),",").concat(xt.camera.position.z.toFixed(3),",").concat(cn.yaw.toFixed(4),",").concat(cn.pitch.toFixed(4),",").concat(xt.camera.fov.toFixed(2));else{var Yn=fn.followTargetId?vt?.get(fn.followTargetId):void 0,Zi=Yn?Yn.z*((ze=fn.followZFactor)!==null&&ze!==void 0?ze:.12):(Ye=fn.lookAtZ)!==null&&Ye!==void 0?Ye:0;xt.lastTime<0||ni<xt.lastTime?xt.focusZ=Zi:vi||(xt.focusZ+=(Zi-xt.focusZ)*(1-Math.exp(-6*vr))),xt.lastTime=ni;var kn=Math.max(0,1-ni/1.5);if(Mn=!fn.followTargetId&&((Re=fn.introLift)!==null&&Re!==void 0?Re:2)===0,!vi){var ki=Mn?Math.sin(ni*.42)*1.15:0,ca=Mn?(Math.cos(ni*.42)-1)*.55:0,lr=(Li?(Ae=fn.cameraX)!==null&&Ae!==void 0?Ae:10:(Ne=fn.landscapeCameraX)!==null&&Ne!==void 0?Ne:13)+ki,gr=Li?((je=fn.cameraY)!==null&&je!==void 0?je:18)+kn*((Ve=fn.introLift)!==null&&Ve!==void 0?Ve:2):(qe=fn.landscapeCameraY)!==null&&qe!==void 0?qe:15,Ai=(Li?(ot=fn.cameraZ)!==null&&ot!==void 0?ot:21:(pt=fn.landscapeCameraZ)!==null&&pt!==void 0?pt:18)+ca,Vt=vr===0?gr:xt.camera.position.y+(gr-xt.camera.position.y)*(1-Math.exp(-6*vr));xt.camera.position.set(lr,Vt,Ai+xt.focusZ),xt.camera.fov=Li?(He=fn.cameraFov)!==null&&He!==void 0?He:39:(ie=fn.landscapeCameraFov)!==null&&ie!==void 0?ie:22.6199,xt.camera.lookAt((Oe=fn.lookAtX)!==null&&Oe!==void 0?Oe:0,(Pe=fn.lookAtY)!==null&&Pe!==void 0?Pe:.15,xt.focusZ)}}return xt.camera.updateProjectionMatrix(),xt.camera.updateMatrixWorld(!0),{entry:xt,waveTime:ni,victorySway:Mn,poseParts:D}}function m(_,p,S,B,b,I,z){var U,Y,E,M,O,H,ee,j,K,re,J,ne,Te,fe=g(_,Pd(Pd({},z),{worldWidth:(K=z.worldWidth)!==null&&K!==void 0?K:b,worldHeight:(re=z.worldHeight)!==null&&re!==void 0?re:I})),pe=fe.entry,Fe=fe.waveTime,ae=fe.victorySway,de=fe.poseParts,_e=z.bodies3d;if(S<2||B<2)return p.fillStyle=pe.skyColor,p.fillRect(0,0,b,I),pe;var Ge=f();if(!Ge||!((Te=(ne=(J=Ge.getContext)===null||J===void 0?void 0:J.call(Ge))===null||ne===void 0?void 0:ne.isContextLost)===null||Te===void 0)&&Te.call(ne))return p.fillStyle=pe.skyColor,p.fillRect(0,0,b,I),pe;var $e=Math.max(S,B,1),ut=520,zt=$e>ut?ut/$e:1,ct=Math.max(2,Math.round(S*zt)),Tt=Math.max(2,Math.round(B*zt)),Zt=s.width!==ct||s.height!==Tt;if(Zt&&(Ge.setPixelRatio(1),Ge.setSize(ct,Tt,!1),u.width=ct,u.height=Tt,d=void 0),!pe.compiled){pe.compiled=!0;var wt=[];pe.guidePool[0]&&!pe.guidePool[0].visible&&(pe.guidePool[0].visible=!0,pe.guidePool[0].position.set(0,-99,0),wt.push(pe.guidePool[0]));try{for(var bt=ti(pe.confettiSystems),_t=bt.next();!_t.done;_t=bt.next()){var ln=_t.value;ln.pieces[0]&&!ln.pieces[0].visible&&(ln.pieces[0].visible=!0,ln.pieces[0].position.set(0,-99,0),wt.push(ln.pieces[0]))}}catch(Ve){U={error:Ve}}finally{try{_t&&!_t.done&&(Y=bt.return)&&Y.call(bt)}finally{if(U)throw U.error}}Ge.compile(pe.scene,pe.camera);try{for(var rt=ti(wt),an=rt.next();!an.done;an=rt.next()){var se=an.value;se.visible=!1}}catch(Ve){E={error:Ve}}finally{try{an&&!an.done&&(M=rt.return)&&M.call(rt)}finally{if(E)throw E.error}}}var mn=!1;if(_e)try{for(var nn=ti(_e.values()),W=nn.next();!W.done;W=nn.next()){var w=W.value;if(w.stageId===_.id&&(w.mode==="kinematic"||w.mode==="dynamic"&&(!w.atRest||w.captured))){mn=!0;break}}}catch(Ve){O={error:Ve}}finally{try{W&&!W.done&&(H=nn.return)&&H.call(nn)}finally{if(O)throw O.error}}var ue=Math.floor(Fe*20),ye=pe.wavingFlags.length>0&&pe.lastFlagStep!==ue,we=ae&&Math.abs(Fe-pe.lastRenderedTime)>=.032,ze=mn&&pe.lastRenderedTime!==Fe,Ye=de!==pe.lastPoseSig,Re=Zt||d!==_.id||pe.guideDirty||pe.textureDirty||pe.lastRenderedTime<0||pe.lastRenderedW!==ct||pe.lastRenderedH!==Tt||ye||we||ze||Ye;if(Re){if(pe.wavingFlags.length>0&&pe.lastFlagStep!==ue){try{for(var Ae=ti(pe.wavingFlags),Ne=Ae.next();!Ne.done;Ne=Ae.next()){var je=Ne.value;Cb(je.geo,je.rest,ue/20)}}catch(Ve){ee={error:Ve}}finally{try{Ne&&!Ne.done&&(j=Ae.return)&&j.call(Ae)}finally{if(ee)throw ee.error}}pe.lastFlagStep=ue}Ge.setClearColor(pe.skyColor,1),Ge.render(pe.scene,pe.camera),s.width>0&&s.height>0&&(l.drawImage(s,0,0,ct,Tt),d=_.id),pe.lastRenderedTime=Fe,pe.lastRenderedW=ct,pe.lastRenderedH=Tt,pe.lastPoseSig=de,pe.guideDirty=!1,pe.textureDirty=!1}return pe.lastWidth=b,pe.lastHeight=I,u.width>0&&u.height>0&&p.drawImage(u,0,0,b,I),pe}function L(){var _,p,S,B,b;try{for(var I=ti(a.values()),z=I.next();!z.done;z=I.next()){var U=z.value;try{for(var Y=(S=void 0,ti(U.dynamicNodes.values())),E=Y.next();!E.done;E=Y.next()){var M=E.value;(b=M.parent)===null||b===void 0||b.remove(M)}}catch(O){S={error:O}}finally{try{E&&!E.done&&(B=Y.return)&&B.call(Y)}finally{if(S)throw S.error}}U.dynamicNodes.clear(),U.focusZ=0,U.lastTime=-1,U.lastRenderedTime=-1,U.lastFlagStep=-1,U.lastPoseSig="",U.guideDirty=!0,U.setGuide([])}}catch(O){_={error:O}}finally{try{z&&!z.done&&(p=I.return)&&p.call(I)}finally{if(_)throw _.error}}}function F(){var _,p,S,B,b,I,z;try{for(var U=ti(a.values()),Y=U.next();!Y.done;Y=U.next()){var E=Y.value;E.scene.traverse(function(re){var J,ne;if(re.isMesh&&(re.geometry&&!Array.from(i.values()).includes(re.geometry)&&re.geometry.dispose(),re.material))try{for(var Te=(J=void 0,ti(Array.isArray(re.material)?re.material:[re.material])),fe=Te.next();!fe.done;fe=Te.next()){var pe=fe.value;pe.dispose()}}catch(Fe){J={error:Fe}}finally{try{fe&&!fe.done&&(ne=Te.return)&&ne.call(Te)}finally{if(J)throw J.error}}})}}catch(re){_={error:re}}finally{try{Y&&!Y.done&&(p=U.return)&&p.call(U)}finally{if(_)throw _.error}}try{for(var M=ti(i.values()),O=M.next();!O.done;O=M.next()){var H=O.value;H.dispose()}}catch(re){S={error:re}}finally{try{O&&!O.done&&(B=M.return)&&B.call(M)}finally{if(S)throw S.error}}try{for(var ee=ti(r.values()),j=ee.next();!j.done;j=ee.next()){var K=j.value;K.dispose()}}catch(re){b={error:re}}finally{try{j&&!j.done&&(I=ee.return)&&I.call(ee)}finally{if(b)throw b.error}}a.clear(),i.clear(),r.clear(),(z=o?.forceContextLoss)===null||z===void 0||z.call(o),o?.dispose(),o=void 0,s=void 0,u=void 0,l=void 0,d=void 0}return{getStage:T,syncStage:g,renderStage:m,reset:L,dispose:F}}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)},Zr=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},Jr=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))},Ql=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.")},sv=function(n,e,t){return Math.max(e,Math.min(t,n))},_s=function(n,e){return Math.hypot(e.x-n.x,e.y-n.y)};function ov(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(M){return[M.id,qa({},M)]})),l=new Map(i.map(function(M){return[M.id,qa({speedScale:1,enabled:!0,bidirectional:!1,cost:0},M)]})),d=new Map(a.map(function(M){return[M.id,qa({},M)]})),f=new Map,h=f,v=0,y=0,T=function(M){return u.get(M)},g=function(M){return Jr([],Zr(d.values()),!1).find(function(O){return O.parameters.nodeId===M})},m=function(M){var O=M.parameters;if(O.mode==="open")return!0;if(O.mode==="closed")return!1;var H=O.openSeconds+O.closedSeconds,ee=(v+O.phaseOffsetSeconds)%H;return ee<O.openSeconds},L=function(M){return Jr([],Zr(l.values()),!1).filter(function(O){return O.enabled&&(O.from===M||O.bidirectional&&O.to===M)}).sort(function(O,H){return O.id<H.id?-1:O.id>H.id?1:0})},F=function(M,O){return Jr([],Zr(l.values()),!1).find(function(H){return H.enabled&&(H.from===M&&H.to===O||H.bidirectional&&H.from===O&&H.to===M)})};function _(M,O){var H,ee,j,K;if(M===O)return[M];for(var re=new Map([[M,0]]),J=new Map,ne=new Set([M]);ne.size;){var Te=Jr([],Zr(ne),!1).sort(function(ct,Tt){return re.get(ct)-re.get(Tt)||(ct<Tt?-1:ct>Tt?1:0)})[0];if(ne.delete(Te),Te===O)break;try{for(var fe=(H=void 0,Ql(L(Te))),pe=fe.next();!pe.done;pe=fe.next()){var Fe=pe.value,ae=Fe.from===Te?Fe.to:Fe.from,de=g(ae),_e=T(ae),Ge=de?de.parameters.holdSeconds*90+(m(de)?0:de.parameters.closedSeconds*90):0,$e=re.get(Te)+_s(T(Te),_e)/Fe.speedScale+Fe.cost+((j=_e.cost)!==null&&j!==void 0?j:0)+Ge;$e>=((K=re.get(ae))!==null&&K!==void 0?K:1/0)||(re.set(ae,$e),J.set(ae,Te),ne.add(ae))}}catch(ct){H={error:ct}}finally{try{pe&&!pe.done&&(ee=fe.return)&&ee.call(fe)}finally{if(H)throw H.error}}}if(!re.has(O))return[];for(var ut=[O],zt=O;zt!==M;)zt=J.get(zt),ut.unshift(zt);return ut}function p(M){var O,H=M.route.length>=2&&M.segment<M.route.length-1;if(!H){var ee=(O=M.route[Math.min(M.segment,M.route.length-1)])!==null&&O!==void 0?O:M.startNode,j=_(ee,M.target);M.route=j.length?j:[ee],M.segment=0,M.distance=0,M.arrived=!1,M.active=M.route.length>=2;return}var K=M.route[M.segment],re=M.route[M.segment+1],J=_s(T(K),T(re));if(M.arrived||M.distance>=J-1e-4){var j=_(re,M.target);M.route=j.length?j:[re],M.segment=0,M.distance=0,M.arrived=!1,M.active=M.route.length>=2;return}var ne=_(re,M.target);M.route=ne.length?Jr([K],Zr(ne),!1):[K,re],M.segment=0}function S(M){var O,H=_(M.startNode,M.targetNode),ee=T(M.startNode),j=H.length>=2?T(H[1]):ee,K=H.length>=2?Math.atan2(j.y-ee.y,j.x-ee.x):0,re=Math.floor((K%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,J=qa(qa({},M),{loop:(O=M.loop)!==null&&O!==void 0?O:"none",originNode:M.startNode,destinationNode:M.targetNode,target:M.targetNode,networkId:e,route:H.length?H:[M.startNode],segment:0,distance:0,x:ee.x,y:ee.y,heading:K,frame:[0,1,2,3][re],flipX:Math.cos(K)<0,hold:0,arrived:!1,active:M.active&&H.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return f.set(J.id,J),J}function B(M){if(b("pathArrive",M,M.target),M.loop==="none"){M.active=!1;return}var O=M.target,H=M.loop==="ping-pong"?O===M.destinationNode?M.originNode:M.destinationNode:O===M.originNode?M.destinationNode:M.originNode;M.startNode=O,M.target=H,M.route=_(O,H),M.segment=0,M.distance=0,M.arrived=!1,M.route.length<2&&(M.active=!1)}function b(M,O,H){o(M,{componentId:O.id,nodeId:H})}function I(M,O){var H,ee,j=M.route[M.segment+1],K=g(j);if(K&&!m(K)){M.blockedTicks++,M.blockedTicks>=30&&!M.blockedEmitted&&(M.blockedEmitted=!0,b("pathBlocked",M,j));return}if(!M.arrived){if(M.arrived=!0,M.segment+1===M.route.length-1){j===M.target?B(M):(M.active=!1,M.blockedEmitted||(M.blockedEmitted=!0,b("pathBlocked",M,j)));return}M.hold=Math.max((H=T(j).holdSeconds)!==null&&H!==void 0?H:0,(ee=K?.parameters.holdSeconds)!==null&&ee!==void 0?ee:0)}if(M.hold>0){M.hold=Math.max(0,M.hold-O),M.blockedTicks++,M.blockedTicks>=30&&!M.blockedEmitted&&(M.blockedEmitted=!0,b("pathBlocked",M,j));return}M.segment++,M.distance=0,M.arrived=!1,M.blockedTicks=0,M.blockedEmitted=!1}function z(M,O){var H,ee;if(M.spacing<=0)return O;var j=M.route[M.segment],K=M.route[M.segment+1],re=_s(T(j),T(K)),J=re-M.distance,ne=O;try{for(var Te=Ql(h.values()),fe=Te.next();!fe.done;fe=Te.next()){var pe=fe.value;if(!(pe.id===M.id||!pe.active||pe.route.length<2||pe.segment>=pe.route.length-1)){var Fe=pe.route[pe.segment],ae=pe.route[pe.segment+1],de=1/0;if(Fe===j&&ae===K&&(pe.distance>M.distance||pe.distance===M.distance&&pe.id<M.id))de=pe.distance-M.distance;else if(Fe===K)de=J+pe.distance;else if(ae===K&&Fe!==j){var _e=_s(T(Fe),T(ae))-pe.distance;_e<M.spacing&&(_e<J||_e===J&&pe.id<M.id)&&(de=J)}de<1/0&&(ne=Math.min(ne,Math.max(0,de-M.spacing)))}}}catch(Ge){H={error:Ge}}finally{try{fe&&!fe.done&&(ee=Te.return)&&ee.call(Te)}finally{if(H)throw H.error}}return ne}function U(M){var O=T(M.route[M.segment]),H=T(M.route[M.segment+1]),ee=_s(O,H),j=sv(M.distance/Math.max(1e-4,ee),0,1),K=O.x+(H.x-O.x)*j,re=O.y+(H.y-O.y)*j,J=Math.atan2(H.y-O.y,H.x-O.x),ne=Math.min(M.cornerRadius,ee/3),Te=M.route[M.segment+2];if(ne>0&&Te){var fe=T(Te),pe=_s(H,fe),Fe=Math.min(ne,pe/3);if(M.distance>ee-ne){var ae={x:H.x-(H.x-O.x)/ee*ne,y:H.y-(H.y-O.y)/ee*ne},de={x:H.x+(fe.x-H.x)/pe*Fe,y:H.y+(fe.y-H.y)/pe*Fe},_e=sv((M.distance-(ee-ne))/(ne*2),0,.5),Ge=1-_e;K=Ge*Ge*ae.x+2*Ge*_e*H.x+_e*_e*de.x,re=Ge*Ge*ae.y+2*Ge*_e*H.y+_e*_e*de.y;var $e=2*Ge*(H.x-ae.x)+2*_e*(de.x-H.x),ut=2*Ge*(H.y-ae.y)+2*_e*(de.y-H.y);Math.abs($e)+Math.abs(ut)>.001&&(J=Math.atan2(ut,$e))}}return{x:K,y:re,heading:J}}function Y(M){var O,H,ee,j;v+=M,y++;var K=Jr([],Zr(f.values()),!1).sort(function(wt,bt){return wt.id<bt.id?-1:wt.id>bt.id?1:0}),re=K.length?y%K.length:0,J=Jr(Jr([],Zr(K.slice(re)),!1),Zr(K.slice(0,re)),!1);try{for(var ne=Ql(J),Te=ne.next();!Te.done;Te=ne.next()){var fe=Te.value;if(!(!fe.active||fe.route.length<2||fe.segment>=fe.route.length-1)){var pe=fe.route[fe.segment],Fe=fe.route[fe.segment+1],ae=_s(T(pe),T(Fe));if(!(fe.distance>=ae-1e-4&&(I(fe,M),!fe.active||fe.route.length<2||fe.segment>=fe.route.length-1))){var de=fe.route[fe.segment],_e=fe.route[fe.segment+1],Ge=_s(T(de),T(_e)),$e=Ge-fe.distance,ut=(j=(ee=F(de,_e))===null||ee===void 0?void 0:ee.speedScale)!==null&&j!==void 0?j:1,zt=Math.min($e,fe.speed*ut*Math.max(0,fe.speedMultiplier)*M),ct=z(fe,zt);ct<=1e-4?(fe.blockedTicks++,fe.blockedTicks>=30&&!fe.blockedEmitted&&(fe.blockedEmitted=!0,b("pathBlocked",fe,_e))):(fe.distance+=ct,fe.blockedTicks=0,fe.blockedEmitted=!1);var Tt=U(fe);fe.x=Tt.x,fe.y=Tt.y,fe.heading=Tt.heading;var Zt=Math.floor((fe.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;fe.frame=[0,1,2,3][Zt],fe.flipX=Math.cos(fe.heading)<0}}}}catch(wt){O={error:wt}}finally{try{Te&&!Te.done&&(H=ne.return)&&H.call(ne)}finally{if(O)throw O.error}}}function E(){return{id:e,nodeCount:u.size,edgeCount:l.size,activeAgents:Jr([],Zr(f.values()),!1).filter(function(M){return M.active}).length,queuedAgents:Jr([],Zr(f.values()),!1).filter(function(M){return M.active&&M.blockedTicks>0}).length,agents:Jr([],Zr(f.values()),!1).map(function(M){var O;return{id:M.id,x:M.x,y:M.y,heading:M.heading,frame:(O=M.frame)!==null&&O!==void 0?O:0,flipX:!!M.flipX,active:M.active,targetNode:M.target,route:Jr([],Zr(M.route),!1),segment:M.segment,distance:M.distance,blocked:M.blockedTicks>0}})}}return{addAgent:S,removeAgent:function(M){return f.delete(M)},getAgent:function(M){return f.get(M)},setTarget:function(M,O){var H=f.get(M);return!H||!T(O)?!1:(H.target=O,H.destinationNode=O,H.active=!0,p(H),!0)},setEdge:function(M,O,H){var ee,j,K=l.get(M);if(!K)return!1;K.enabled=O,H!==void 0&&(K.cost=H);try{for(var re=Ql(f.values()),J=re.next();!J.done;J=re.next()){var ne=J.value;p(ne)}}catch(Te){ee={error:Te}}finally{try{J&&!J.done&&(j=re.return)&&j.call(re)}finally{if(ee)throw ee.error}}return!0},setGate:function(M,O,H){var ee,j,K=d.get(M);if(!K)return!1;K.parameters=qa(qa({},K.parameters),{mode:O,holdSeconds:H});try{for(var re=Ql(f.values()),J=re.next();!J.done;J=re.next()){var ne=J.value;p(ne)}}catch(Te){ee={error:Te}}finally{try{J&&!J.done&&(j=re.return)&&j.call(re)}finally{if(ee)throw ee.error}}return!0},tick:Y,snapshot:E}}var jl=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.")},Ld=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},Dd=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))},Nd={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"]},ec=function(n){var e,t,i,r,a=0;try{for(var s=jl(n),o=s.next();!o.done;o=s.next()){var u=o.value;a+=((r=(i=Nd[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)},Rb=function(n,e){var t,i,r=[],a="";try{for(var s=jl(n),o=s.next();!o.done;o=s.next()){var u=o.value;a&&ec(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 Pb(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=jl(String(n).toUpperCase().split(`
|
|
4221
|
-
`)),f=d.next();!f.done;f=d.next()){var h=f.value,
|
|
4222
|
-
`):
|
|
4223
|
-
`&&!Nd[y]}))),!1),l,d=s;d>=o;d--){var f=Lb(n,e,d,r),h=f.renderedWidth>r,v=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:v,unsupportedChars:u},e.autoFit===!1||!h&&!v)break}return l}function cv(n,e,t){var i,r=Yh(e,t),a=r.lines,s=r.scale,o=lv(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,v){var y,T,g,m=ec(h)*s,L=t.align==="left"?o.x:t.align==="right"?t.width-m-o.x:o.x+(u-m)/2,F=L;try{for(var _=jl(h),p=_.next();!p.done;p=_.next()){var S=p.value,B=(g=Nd[S])!==null&&g!==void 0?g:Nd["?"];B.forEach(function(b,I){for(var z=0;z<b.length;z++)b[z]==="1"&&n.fillRect(Math.round(F+z*s),Math.round(f+v*d+I*s),s,s)}),F+=(B[0].length+1)*s}}catch(b){y={error:b}}finally{try{p&&!p.done&&(T=_.return)&&T.call(_)}finally{if(y)throw y.error}}}),r}var Ra=function(){return Ra=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},Ra.apply(this,arguments)},Zh=Math.PI*2,hi=function(n,e){return((Math.imul(n+1,2654435769)^Math.imul(e,2246822507))>>>0)/4294967296};function Jh(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+hi(l,1)*.6)/n.count-.5)*s,v=n.speed*(.42+.65*hi(l,2));return Ra(Ra({},e),{clipId:t,shape:"pixel-confetti",age:-.12*hi(l,3),vx:Math.cos(h)*v,vy:Math.sin(h)*v,gravity:(d=n.gravity)!==null&&d!==void 0?d:250,life:((f=n.lifetime)!==null&&f!==void 0?f:.7)*(.6+.4*hi(l,4)),color:a[l%a.length],size:3+Math.floor(3*hi(l,5)),angle:Zh*hi(l,6),spin:(hi(l,7)-.5)*12})})}function uv(n){var e=Math.min(12,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Jh(n).map(function(r,a){return Ra(Ra({},r),{screen:!0,x:(a%e+.15+.7*hi(a,8))/e,y:(Math.floor(a/e)+.15+.7*hi(a,9))/t,vx:i*(hi(a,10)-.5)*.7,vy:i*(.3+.5*hi(a,11)),size:r.size+1})})}var Fd=function(n,e){return(n%e+e)%e};function dv(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,v=e.color;if(!(o<0)){var y=a*o,T=s*o+l*o*o/2,g=Math.round(t?t.x+Fd(i*t.width+y,t.width):i+y),m=Math.round(t?t.y+Fd(r*t.height+T,t.height):r+T),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,m+1,d*2+1,d+1);else if(L===2)n.fillRect(g+1,m-d+1,d+1,d*2+1);else for(var F=-1;F<=1;F++)n.fillRect(g+F*d+1,m+F*d*(L===1?1:-1)+1,d+1,d+1);if(n.fillStyle=v,L===0)n.fillRect(g-d,m,d*2,d);else if(L===2)n.fillRect(g,m-d,d,d*2);else for(var F=-1;F<=1;F++)n.fillRect(g+F*d,m+F*d*(L===1?1:-1),d,d)}}function $h(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+hi(l,11)*.6)/n.count-.5)*s,v=n.speed*(.45+.65*hi(l,12));return Ra(Ra({},e),{clipId:t,shape:"confetti",age:-.15*hi(l,13),vx:Math.cos(h)*v,vy:Math.sin(h)*v,gravity:(d=n.gravity)!==null&&d!==void 0?d:140,life:((f=n.lifetime)!==null&&f!==void 0?f:2.6)*(.75+.35*hi(l,14)),color:a[l%a.length],size:5+Math.floor(5*hi(l,15)),kind:l%5===0?"star":"ribbon",angle:Zh*hi(l,16),spin:(hi(l,17)-.5)*5.5,flutter:1.6+2.2*hi(l,18),phase:Zh*hi(l,19)})})}function fv(n){var e=Math.min(14,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return $h(n,{x:0,y:0}).map(function(r,a){var s;return Ra(Ra({},r),{screen:!0,x:(a%e+.12+.76*hi(a,20))/e,y:(Math.floor(a/e)+.08+.84*hi(a,21))/t,vx:i*(hi(a,22)-.5)*.65,vy:i*(.38+.55*hi(a,23)),gravity:Math.min((s=n.gravity)!==null&&s!==void 0?s:90,90)})})}function hv(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,v=e.flutter,y=e.phase,T=e.color,g=e.kind;if(!(o<0)){var m=Math.sin(o*v+y)*14,L=a*o+m,F=s*o+l*o*o/2,_=t?t.x+Fd(i*t.width+L,t.width):i+L,p=t?t.y+Fd(r*t.height+F,t.height):r+F,S=Math.min(1,o*2.8,(u-o)*2.2);if(!(S<=0)){n.save(),n.globalAlpha*=S,n.translate(_,p),n.rotate(f+h*o);var B=Math.cos(o*v*1.4+y);if(n.scale(1,Math.max(.22,Math.abs(B))),n.fillStyle=T,g==="star"){var b=d*.85;n.beginPath();for(var I=0;I<8;I++){var z=I%2===0?b:b*.38,U=I*Math.PI/4;I===0?n.moveTo(Math.cos(U)*z,Math.sin(U)*z):n.lineTo(Math.cos(U)*z,Math.sin(U)*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 pv(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 v=Math.floor(((a+14*o)*h-6*o)/o)*o,y=u+3*o,T=0;y<l;y+=o,T++){var g=v-Math.floor(T/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 m=Math.max(0,Math.sin(r*4.2)),L=Math.max(0,Math.sin(r*4.2+2.2)),F=function(_,p,S){if(!(S<.25)){n.save(),n.globalAlpha*=S*.95,n.fillStyle="#fffef4";var B=S>.65?o*2:o;n.fillRect(Math.round(_-B),Math.round(p-o/2),B*2+o,o),n.fillRect(Math.round(_-o/2),Math.round(p-B),o,B*2+o),n.restore()}};F(5*o,u+4*o,m),F(a-6*o,u+5*o,L)}}}function Ud(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 qh(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 mv(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,v=r>=0?.5-.5*Math.cos(r*2.4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd23f99",n.shadowBlur=10+v*12,Ud(n,0,h,u,l-h,d),n.fillStyle=t,n.fill(),n.restore()),n.save(),Ud(n,0,h+2,u,Math.max(4,l-h-2),d),n.fillStyle="#0e2830",n.fill(),n.restore(),n.save(),Ud(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 T=(r%2.4-.15)/.95;if(T>0&&T<1){var g=T*T*(3-2*T),m=Math.sin(T*Math.PI),L=-u*.36+u*1.72*g;n.save(),n.globalAlpha*=m,n.translate(L,h),n.transform(1,0,-.36,1,0,0);var F=(o=n.createLinearGradient)===null||o===void 0?void 0:o.call(n,-48,0,48,0);F?.addColorStop?(F.addColorStop(0,"#ffffff00"),F.addColorStop(.32,"#ffffff48"),F.addColorStop(.5,"#fffef8cc"),F.addColorStop(.68,"#ffffff48"),F.addColorStop(1,"#ffffff00"),n.fillStyle=F,n.fillRect(-48,0,96,l)):(n.fillStyle="#fffef8a8",n.fillRect(-14,0,28,l)),n.restore()}}if(n.restore(),e.strokeWidth&&(n.save(),Ud(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)),p=_*_,S=Math.max(0,Math.sin(r*2.4+2.1)),B=S*S,b=Math.max(0,Math.sin(r*2.4+4.2)),I=b*b;qh(n,u*.12,h+9,4+p*6,p*.92),qh(n,u*.88,h+10,3.8+B*5.5,B*.9),qh(n,u*.76,Math.max(h+14,l-f-8),3+I*4.2,I*.8)}}}function Od(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 tc=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.")},nc=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},Kh=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 vv(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(j){return Number.isFinite(j)&&j>=1&&j<=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,v=!1,y=!1,T=!1,g=!1,m,L,F,_,p,S,B=function(){return v||y};function b(){var j,K,re;clearTimeout(p),clearTimeout(S);try{for(var J=tc(l.splice(0)),ne=J.next();!ne.done;ne=J.next()){var Te=nc(ne.value,2),fe=Te[0],pe=Te[1];try{(re=d.mraid)===null||re===void 0||re.removeEventListener(fe,pe)}catch{}}}catch(Fe){j={error:Fe}}finally{try{ne&&!ne.done&&(K=J.return)&&K.call(J)}finally{if(j)throw j.error}}}function I(j){_?.(j instanceof Error?j:Error(String(j))),F=void 0,_=void 0}function z(j){var K,re;if(!B()){var J=f;if(v=!0,f=!1,h=!1,b(),I(j),J)try{for(var ne=tc(Kh([],nc(u),!1)),Te=ne.next();!Te.done;Te=ne.next()){var fe=Te.value;fe()}}catch(pe){K={error:pe}}finally{try{Te&&!Te.done&&(re=ne.return)&&re.call(ne)}finally{if(K)throw K.error}}o.clear(),u.clear()}}function U(j,K){return l.push([j,K]),d.mraid.addEventListener(j,K),Y(j,K)}function Y(j,K){if(B()){try{d.mraid.removeEventListener(j,K)}catch{}return!1}return!0}function E(j){var K,re;if(!B()){if(typeof j!="boolean"){z(Error("Invalid Unity viewability event"));return}if(!f){m=j;return}if(h!==j){h=j;try{for(var J=tc(Kh([],nc(o),!1)),ne=J.next();!ne.done;ne=J.next()){var Te=ne.value;if(B())break;Te(h)}}catch(fe){K={error:fe}}finally{try{ne&&!ne.done&&(re=J.return)&&re.call(J)}finally{if(K)throw K.error}}}}}var M=function(j){j==="hidden"&&z(Error("Unity host closed"))},O=function(){var j;f&&!B()&&((j=n.onResize)===null||j===void 0||j.call(n))};function H(){var j,K,re,J;if(!(!T||f||g||B())){g=!0;try{var ne=d.mraid.getState();if(B()||ne==="loading")return;if(ne==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(ne))throw Error("Invalid Unity host state");var Te=d.mraid.getVersion();if(B())return;if(Te!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var fe=tc([["viewableChange",E],["stateChange",M],["sizeChange",O]]),pe=fe.next();!pe.done;pe=fe.next()){var Fe=nc(pe.value,2),ae=Fe[0],de=Fe[1];if(!U(ae,de))return}}catch(zt){j={error:zt}}finally{try{pe&&!pe.done&&(K=fe.return)&&K.call(fe)}finally{if(j)throw j.error}}var _e=d.mraid.isViewable();if(B())return;if(typeof _e!="boolean")throw Error("Invalid Unity initial viewability");h=m??_e,f=!0,clearTimeout(p),clearTimeout(S),F?.(),F=void 0,_=void 0;try{for(var Ge=tc(Kh([],nc(o),!1)),$e=Ge.next();!$e.done;$e=Ge.next()){var ut=$e.value;if(B())break;ut(h)}}catch(zt){re={error:zt}}finally{try{$e&&!$e.done&&(J=Ge.return)&&J.call(Ge)}finally{if(re)throw re.error}}}catch(zt){z(zt)}finally{g=!1}}}function ee(){if(!B())try{var j=s();if(B())return;if(!j){S=setTimeout(ee,a);return}if(d.mraid=j,l.push(["ready",H]),d.mraid.addEventListener("ready",H),!Y("ready",H))return;T=!0,H()}catch(K){z(K)}}return{init:function(){return L||(L=new Promise(function(j,K){F=j,_=K}),B()?(I(Error("Unity bridge destroyed")),L):(p=setTimeout(function(){return z(Error("Unity MRAID readiness timed out"))},r),ee(),L))},isReady:function(){return f&&!B()},isVisible:function(){return f&&h&&!B()},isClosed:B,onVisibilityChanged:function(j){return B()||o.add(j),function(){return o.delete(j)}},onClosed:function(j){return B()||u.add(j),function(){return u.delete(j)}},openStore:function(j){if(!f||!h||B()||!Od(j))throw Error("Unity store request not permitted");d.mraid.open(j)},destroy:function(){y||(y=!0,f=!1,h=!1,b(),I(Error("Unity bridge destroyed")),o.clear(),u.clear())}}}var Uo=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.")},Fo=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},Qh=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 gv(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,v,y=new Set,T=new Set,g=[];function m(){var U,Y;clearTimeout(h),clearTimeout(v);try{for(var E=Uo(g.splice(0)),M=E.next();!M.done;M=E.next()){var O=Fo(M.value,2),H=O[0],ee=O[1];try{i?.removeEventListener(H,ee)}catch{}}}catch(j){U={error:j}}finally{try{M&&!M.done&&(Y=E.return)&&Y.call(E)}finally{if(U)throw U.error}}}function L(U,Y){if(g.push([U,Y]),i.addEventListener(U,Y),s||o){try{i.removeEventListener(U,Y)}catch{}return!1}return!0}function F(U){var Y=U instanceof Error?U:Error(String(U));f?.(Y),d=void 0,f=void 0}function _(U,Y){var E,M;if(!(s||o)&&(s=!0,r=!1,a=!1,m(),F(U),Y))try{for(var O=Uo(Qh([],Fo(T),!1)),H=O.next();!H.done;H=O.next()){var ee=H.value;ee()}}catch(j){E={error:j}}finally{try{H&&!H.done&&(M=O.return)&&M.call(O)}finally{if(E)throw E.error}}}function p(){var U,Y,E,M;if(!(!u||r||s||o))try{var O=i.getState();if(s||o||O==="loading")return;if(O==="hidden"){_(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(O))throw Error("Invalid MRAID state");try{for(var H=Uo([["viewableChange",B],["stateChange",b],["sizeChange",I]]),ee=H.next();!ee.done;ee=H.next()){var j=Fo(ee.value,2),K=j[0],re=j[1];if(!L(K,re))return}}catch(fe){U={error:fe}}finally{try{ee&&!ee.done&&(Y=H.return)&&Y.call(H)}finally{if(U)throw U.error}}var J=i.isViewable();if(s||o)return;if(typeof J!="boolean")throw Error("Invalid MRAID viewability");a=J,r=!0,clearTimeout(h),clearTimeout(v),d?.(),d=void 0,f=void 0;try{for(var ne=Uo(Qh([],Fo(y),!1)),Te=ne.next();!Te.done;Te=ne.next()){var re=Te.value;re(a)}}catch(fe){E={error:fe}}finally{try{Te&&!Te.done&&(M=ne.return)&&M.call(ne)}finally{if(E)throw E.error}}}catch(fe){_(fe,r)}}var S=function(){return p()},B=function(U){var Y,E;if(!(!r||s||o)){if(typeof U!="boolean"){_(Error("Invalid MRAID visibility event"),!0);return}a=U;try{for(var M=Uo(Qh([],Fo(y),!1)),O=M.next();!O.done;O=M.next()){var H=O.value;H(a)}}catch(ee){Y={error:ee}}finally{try{O&&!O.done&&(E=M.return)&&E.call(M)}finally{if(Y)throw Y.error}}}},b=function(U){U==="hidden"&&_(Error("MRAID closed"),!0)},I=function(){var U;r&&!s&&!o&&((U=n.onResize)===null||U===void 0||U.call(n))};function z(){var U,Y,E;if(!(s||o))try{if(i=t(),s||o)return;if(!i){v=setTimeout(z,(E=n.pollMs)!==null&&E!==void 0?E:50);return}if(![i.getState,i.isViewable,i.addEventListener,i.removeEventListener,i.open].every(function(K){return typeof K=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var M=Uo([["ready",S]]),O=M.next();!O.done;O=M.next()){var H=Fo(O.value,2),ee=H[0],j=H[1];if(!L(ee,j))return}}catch(K){U={error:K}}finally{try{O&&!O.done&&(Y=M.return)&&Y.call(M)}finally{if(U)throw U.error}}u=!0,p()}catch(K){_(K,!1)}}return{init:function(){var U;return l||(l=new Promise(function(Y,E){d=Y,f=E}),s||o?(F(Error("MRAID bridge destroyed")),l):(h=setTimeout(function(){return _(Error("MRAID readiness timed out"),!1)},(U=n.timeoutMs)!==null&&U!==void 0?U:5e3),z(),l))},isReady:function(){return r&&!s&&!o},isVisible:function(){return a&&r&&!s&&!o},isClosed:function(){return s||o},onVisibilityChanged:function(U){return!s&&!o&&y.add(U),function(){return y.delete(U)}},onClosed:function(U){return!s&&!o&&T.add(U),function(){return T.delete(U)}},openStore:function(U){if(!r||!a||s||o||!Od(U))throw Error("MRAID store request not permitted");i.open(U)},destroy:function(){o||(o=!0,r=!1,a=!1,m(),F(Error("MRAID bridge destroyed")),y.clear(),T.clear())}}}var zs=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.")},Vs=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},ic=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 yv(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,v,y,T=function(){return u||l};function g(){var I,z;clearTimeout(v),clearTimeout(y);try{for(var U=zs(r.splice(0)),Y=U.next();!Y.done;Y=U.next()){var E=Vs(Y.value,2),M=E[0],O=E[1];try{a?.removeEventListener(M,O)}catch{}}}catch(H){I={error:H}}finally{try{Y&&!Y.done&&(z=U.return)&&z.call(U)}finally{if(I)throw I.error}}}function m(I){var z,U;if(!T()){u=!0,s=!1,o=!1,g(),h?.(I instanceof Error?I:Error(String(I))),f=void 0,h=void 0;try{for(var Y=zs(ic([],Vs(t),!1)),E=Y.next();!E.done;E=Y.next()){var M=E.value;M()}}catch(O){z={error:O}}finally{try{E&&!E.done&&(U=Y.return)&&U.call(Y)}finally{if(z)throw z.error}}}}var L=function(I){if(!(typeof I!="number"||!Number.isFinite(I)||I<0))return Math.min(1,I>1?I/100:I)},F=function(I){if(typeof I=="boolean")return I;if(I&&typeof I=="object"&&typeof I.isViewable=="boolean")return I.isViewable},_=function(){var I,z,U,Y,E,M;if(!(s||T()||!a||((E=a.isReady)===null||E===void 0?void 0:E.call(a))===!1))try{o=a.isViewable();var O=(M=a.getAudioVolume)===null||M===void 0?void 0:M.call(a),H=O===void 0?void 0:L(O);if(typeof o!="boolean"||O!==void 0&&H===void 0)throw Error("Invalid DAPI initial state");if(s=!0,clearTimeout(v),clearTimeout(y),f?.(),f=void 0,h=void 0,H!==void 0)try{for(var ee=zs(ic([],Vs(i),!1)),j=ee.next();!j.done;j=ee.next()){var K=j.value;K(H)}}catch(ne){I={error:ne}}finally{try{j&&!j.done&&(z=ee.return)&&z.call(ee)}finally{if(I)throw I.error}}try{for(var re=zs(ic([],Vs(e),!1)),J=re.next();!J.done;J=re.next()){var K=J.value;K(o)}}catch(ne){U={error:ne}}finally{try{J&&!J.done&&(Y=re.return)&&Y.call(re)}finally{if(U)throw U.error}}}catch(ne){m(ne)}},p=function(I){var z,U;if(!T()){var Y=F(I);if(Y===void 0){m(Error("Invalid DAPI visibility"));return}o=Y;try{for(var E=zs(ic([],Vs(e),!1)),M=E.next();!M.done;M=E.next()){var O=M.value;O(Y)}}catch(H){z={error:H}}finally{try{M&&!M.done&&(U=E.return)&&U.call(E)}finally{if(z)throw z.error}}}},S=function(I){var z,U;if(!T()){var Y=L(I);if(Y===void 0){m(Error("Invalid DAPI volume"));return}try{for(var E=zs(ic([],Vs(i),!1)),M=E.next();!M.done;M=E.next()){var O=M.value;O(Y)}}catch(H){z={error:H}}finally{try{M&&!M.done&&(U=E.return)&&U.call(E)}finally{if(z)throw z.error}}}},B=function(){var I;s&&!T()&&((I=n.onResize)===null||I===void 0||I.call(n))};function b(){var I,z,U;if(!T()){if(a=window.dapi,!a){y=setTimeout(b,(U=n.pollMs)!==null&&U!==void 0?U:25);return}try{try{for(var Y=zs([["ready",_],["viewableChange",p],["audioVolumeChange",S],["adResized",B]]),E=Y.next();!E.done;E=Y.next()){var M=Vs(E.value,2),O=M[0],H=M[1];r.push([O,H]),a.addEventListener(O,H)}}catch(ee){I={error:ee}}finally{try{E&&!E.done&&(z=Y.return)&&z.call(Y)}finally{if(I)throw I.error}}_()}catch(ee){m(ee)}}}return{init:function(){var I;return d||(d=new Promise(function(z,U){f=z,h=U}),T()?(h?.(Error("DAPI bridge closed")),d):(v=setTimeout(function(){return m(Error("DAPI readiness timed out"))},(I=n.timeoutMs)!==null&&I!==void 0?I:5e3),b(),d))},isReady:function(){return s&&!T()},isVisible:function(){return s&&o&&!T()},isClosed:T,onVisibilityChanged:function(I){return T()||e.add(I),function(){return e.delete(I)}},onClosed:function(I){return T()||t.add(I),function(){return t.delete(I)}},onVolumeChanged:function(I){return T()||i.add(I),function(){return i.delete(I)}},openStore:function(){if(!s||!o||T()||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 Db=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())})},Nb=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}}},Ub=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},Fb=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))},Ob=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 xv(){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=Ob(Fb([],Ub(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 Db(this,void 0,void 0,function(){return Nb(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 Bb=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())})},kb=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}}},zb=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},Vb=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))},Gb=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 _v(){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=Gb(Vb([],zb(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 Bb(this,void 0,void 0,function(){return kb(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 Hb=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())})},Wb=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}}},jh=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},ep=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))},tp=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 Mv(){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 v=!s||!a;if(a=!0,s=!0,v)try{for(var y=tp(ep([],jh(e),!1)),T=y.next();!T.done;T=y.next()){var g=T.value;g(!0)}}catch(m){f={error:m}}finally{try{T&&!T.done&&(h=y.return)&&h.call(y)}finally{if(f)throw f.error}}}},d=function(){var f,h,v,y;if(!(o||u)){a=!1,s=!1,o=!0;try{for(var T=tp(ep([],jh(e),!1)),g=T.next();!g.done;g=T.next()){var m=g.value;m(!1)}}catch(_){f={error:_}}finally{try{g&&!g.done&&(h=T.return)&&h.call(T)}finally{if(f)throw f.error}}try{for(var L=tp(ep([],jh(t),!1)),F=L.next();!F.done;F=L.next()){var m=F.value;m()}}catch(_){v={error:_}}finally{try{F&&!F.done&&(y=L.return)&&y.call(L)}finally{if(v)throw v.error}}}};return n.gameStart=l,n.gameClose=d,{init:function(){return Hb(this,void 0,void 0,function(){return Wb(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 Xb=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())})},Yb=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}}},qb=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},Zb=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))},Jb=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 Sv(){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=Jb(Zb([],qb(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 Xb(this,void 0,void 0,function(){return Yb(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 gt=function(){return gt=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},gt.apply(this,arguments)},$b=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())})},Kb=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}}},De=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},Ke=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))},Ue=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 wv(n){if(n!=="standalone"){if(n==="unity-ads-ua-playable")return vv();if(n==="applovin-growth-playable")return gv();if(n==="ironsource-levelplay-playable")return yv();if(n==="meta-audience-playable")return xv();if(n==="google-ads-app-playable")return _v();if(n==="mintegral-appgrowth-zip")return Mv();if(n==="tiktok-ads-playable")return Sv();throw Error("E_NATIVE_TARGET")}}function np(n){var e=[{id:"sdk-top-left",left:0,top:0,right:Math.min(48,n.width),bottom:Math.min(48,n.height)},{id:"sdk-top-right",left:Math.max(0,n.width-56),top:0,right:n.width,bottom:Math.min(56,n.height)},{id:"sdk-bottom-left",left:0,top:Math.max(0,n.height-28),right:Math.min(48,n.width),bottom:n.height}];return{left:Math.min(48,n.width),top:Math.min(56,n.height),right:Math.max(0,n.width-56),bottom:Math.max(0,n.height-28),zones:e}}function Bd(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:Ke([],De(e),!1).length*(a?Number(a[1]):16)*.6}function bv(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 v=Ue(String(e).split(`
|
|
4224
|
-
`)),y=v.next();!y.done;y=v.next()){var T=y.value;if(t.wrap===!1){h.push(T);continue}var g=T.trim()?T.trim().split(/\s+/):[""],m=void 0;try{for(var L=(s=void 0,Ue(g)),F=L.next();!F.done;F=L.next()){var _=F.value,p=m?m+" "+_:_;if(Bd(n,p)<=f){m=p;continue}if(m&&h.push(m),Bd(n,_)<=f){m=_;continue}var S="";try{for(var B=(u=void 0,Ue(_)),b=B.next();!b.done;b=B.next()){var I=b.value;S&&Bd(n,S+I)>f?(h.push(S),S=I):S+=I}}catch(z){u={error:z}}finally{try{b&&!b.done&&(l=B.return)&&l.call(B)}finally{if(u)throw u.error}}m=S}}catch(z){s={error:z}}finally{try{F&&!F.done&&(o=L.return)&&o.call(L)}finally{if(s)throw s.error}}h.push(m)}}catch(z){r={error:z}}finally{try{y&&!y.done&&(a=v.return)&&a.call(v)}finally{if(r)throw r.error}}return h}function Tv(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=bv(n,e,t,l),f,h=function(){var v;n.font=t.fontWeight+" "+l+"px "+t.fontFamily;var y=Math.max.apply(Math,Ke([0],De(d.map(function(L){return Bd(n,L)})),!1)),T=l*((v=t.lineHeight)!==null&&v!==void 0?v:1.2),g=d.length>16;g&&(d=d.slice(0,16));var m=d.length*T;return{lines:d,fontSize:l,scale:l/t.fontSize,renderedWidth:y,renderedHeight:m,availableWidth:s,availableHeight:o,padding:a,lineHeight:T,overflowsWidth:y>s+.01,overflowsHeight:g||m>o+.01,unsupportedChars:[]}};if(f=h(),t.autoFit!==!1)for(;(f.overflowsWidth||f.overflowsHeight)&&l>u;)l=Math.max(u,l-1),d=bv(n,e,t,l),f=h();return f}function Qb(n,e,t){var i=Tv(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 jb(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,v=h===void 0?n.base.startScene:h,y=l.onSelect,T=y===void 0?function(){}:y,g=l.network,m=g===void 0?"standalone":g,L=l.review,F=L===void 0?!1:L,_=wv(m),p=e.getContext("2d"),S=new Map(n.components.map(function(c){return[c.id,c]})),B=new Map(n.assets.map(function(c){return[c.id,c]})),b=new Map,I=new Map(n.events.map(function(c){return[c.id,c]})),z=new Map(n.gameplay.filter(function(c){return c.kind==="responsive-layout"}).map(function(c){return[c.componentId,c.parameters]})),U=(a=globalThis.matchMedia)===null||a===void 0?void 0:a.call(globalThis,"(prefers-reduced-motion: reduce)"),Y,E=new Map,M=E;function O(){var c=z.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 H(){Y!==O().landscape&&(gr(),ei())}try{for(var ee=Ue(n.assets),j=ee.next();!j.done;j=ee.next()){var K=j.value;if(K.mime.startsWith("image/")){var re=new Image;re.src="data:"+K.mime+";base64,"+K.data,b.set(K.id,re)}}}catch(c){i={error:c}}finally{try{j&&!j.done&&(r=ee.return)&&r.call(ee)}finally{if(i)throw i.error}}var J=v,ne={},Te=[],fe=[],pe=[],Fe=[],ae=new Set,de=new Map,_e=0,Ge=0,$e=0,ut=0,zt=0,ct=!1,Tt=0,Zt=0,wt=!1,bt=[],_t,ln,rt,an,se,mn,nn,W,w,ue=[],ye,we=[],ze=[],Ye,Re=0,Ae=!1,Ne=0,je=m==="standalone",Ve=m==="standalone",qe=m==="standalone",ot=!1,pt=!1,He=new Map,ie=new Map,Oe=new Map,Pe=new Map,nt=new Set,dt=new Map,Be=new Set,Rt=new Map,vt=new Map,cn=new Map,dn=new Map,Fn=new Map,Dn=new Map,vi=0,rr=0,yn,En,Yi=1,en,xt=new Map,ni=new Map,fn=new Map,bi=new Map,qi=new Map,wi=new Map,gi=new Map,Bn=Up(),ar=Bp(),la=new Map,Za=new Map,Ei=Hp(zp(n.projectId)),mr=new Map,sr=new Map,Vr=new Map,D=new Set,le=new Map,he,Me=1,Se=1,ke,et,Je={x:0,y:0},ft,Dt=[],tn=[],$t=new Map,Et=new Map,hn=new Map,Vn=new Map,It,Qt,jt;n.components.some(function(c){return c.contract==="native.stage3d.v1"})&&(jt=av(n,B,function(){pt||Promise.resolve().then(function(){pt||ei()})}));var Le=function(c){var x;return(x=Oe.get(c))!==null&&x!==void 0?x:S.get(c)},An=function(c,x){return n.gameplay.find(function(R){return R.kind===c&&R.componentId===x})},pn=function(){var c,x;vi++,Be.clear(),Rt.clear(),cn.clear(),dn.clear();try{for(var R=Ue(nt),A=R.next();!A.done;A=R.next()){var C=A.value;try{C.stop()}catch{}}}catch(N){c={error:N}}finally{try{A&&!A.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}nt.clear(),vt.clear()},yi=function(c){var x,R;if(!he||c!==void 0&&he.pointerId!==c)return!1;var A=he.pointerId;he.behavior.parameters.powerVariableId&&(ne[he.behavior.parameters.powerVariableId]=0),he=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,A)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,A))}catch{}return!0},or=function(c){var x,R,A;if(!It||c!==void 0&&It.pointerId!==c)return!1;var C=It.pointerId;It.behavior.parameters.powerVariableId&&(ne[It.behavior.parameters.powerVariableId]=0),(x=jt?.getStage(S.get(It.stageId)))===null||x===void 0||x.setGuide([]),It=void 0;try{!((R=e.hasPointerCapture)===null||R===void 0)&&R.call(e,C)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,C))}catch{}return!0},Li=function(c){var x,R;if(!Qt||c!==void 0&&Qt.pointerId!==c)return!1;var A=Qt.pointerId;Qt=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,A)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,A))}catch{}return!0},vr=function(c){var x=c.behavior.parameters;x.axisXVariableId&&(ne[x.axisXVariableId]=c.nx),x.axisYVariableId&&(ne[x.axisYVariableId]=c.ny),x.magnitudeVariableId&&(ne[x.magnitudeVariableId]=c.magnitude),x.angleVariableId&&c.magnitude>0&&(ne[x.angleVariableId]=c.angle)},Mn=function(c,x){var R,A,C,N;x===void 0&&(x=!1);try{for(var P=Ue(le.values()),X=P.next();!X.done;X=P.next()){var k=X.value;if(!(k.pointerId===null||c!==void 0&&k.pointerId!==c)){var Z=k.pointerId;k.pointerId=null,k.nx=0,k.ny=0,k.magnitude=0,k.knobX=k.origin.x,k.knobY=k.origin.y,vr(k);try{!((C=e.hasPointerCapture)===null||C===void 0)&&C.call(e,Z)&&((N=e.releasePointerCapture)===null||N===void 0||N.call(e,Z))}catch{}x&&Jt(pi("joystickEnd",k.c))}}}catch(V){R={error:V}}finally{try{X&&!X.done&&(A=P.return)&&A.call(P)}finally{if(R)throw R.error}}},Yn=function(c,x){var R,A;if(x===void 0&&(x=!0),!rt||c!==void 0&&rt.pointerId!==c)return!1;var C=rt,N=C.pointerId;if(rt=void 0,et=void 0,x){var P=Le(C.targetId);P&&C.b.parameters.snapBack&&(ua(P,C.origin.x,C.origin.y),C.originZone&&Bn.place(P.id,C.originZone))}try{!((R=e.hasPointerCapture)===null||R===void 0)&&R.call(e,N)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,N))}catch{}return!0},Zi=function(c){var x,R;ye?.pointerId===c.pointerId&&(ye=void 0);try{for(var A=Ue(Fn.values()),C=A.next();!C.done;C=A.next()){var N=C.value;N.pointerId===c.pointerId&&N.held&&(N.held=!1,N.releasedAt=_e)}}catch(X){x={error:X}}finally{try{C&&!C.done&&(R=A.return)&&R.call(A)}finally{if(x)throw x.error}}var P=Yn(c.pointerId);return mn===c.pointerId?(se=void 0,mn=void 0,!0):P},kn=function(c){var x,R,A,C,N,P,X,k;if(c){rt&&((X=Oe.get(rt.targetId))===null||X===void 0?void 0:X.instanceId)===c&&Yn(void 0,!1),he&&((k=Oe.get(he.targetId))===null||k===void 0?void 0:k.instanceId)===c&&yi();var Z=[];Bn.release(c),ar.cancel(c),mr.delete(c),Vr.delete(c),Ei.remove(c),Te=Te.filter(function(be){return be.id!==c});try{for(var V=Ue(Oe),$=V.next();!$.done;$=V.next()){var q=De($.value,2),Q=q[0],te=q[1];if(te.instanceId===c){Z.push(Q),Bn.release(Q),ar.cancel(Q),Oe.delete(Q),He.delete(Q),Pe.delete(Q),fn.delete(Q),qi.delete(Q),wi.delete(Q);try{for(var G=(A=void 0,Ue(bi.values())),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;me.removeAgent(Q)}}catch(be){A={error:be}}finally{try{ce&&!ce.done&&(C=G.return)&&C.call(G)}finally{if(A)throw A.error}}try{for(var ve=(N=void 0,Ue(ie.keys())),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;oe.endsWith(":"+Q)&&ie.delete(oe)}}catch(be){N={error:be}}finally{try{xe&&!xe.done&&(P=ve.return)&&P.call(ve)}finally{if(N)throw N.error}}}}}catch(be){x={error:be}}finally{try{$&&!$.done&&(R=V.return)&&R.call(V)}finally{if(x)throw x.error}}pe=pe.filter(function(be){return!Z.includes(be.targetId)})}},ki=function(c){for(;c;){if(c.prototype)return c.id;c=Le(c.parentId)}},ca=function(){var c,x,R;return{viewport:O(),components:Object.fromEntries(Ke([],De(He),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,gt(gt({},P),{parameters:gt({},P.parameters)})]})),mode:f?"edit":"play",scene:J,variables:gt({},ne),time:_e,instances:Te.map(function(A){return gt({id:A.id,prototypeId:A.prototypeId,x:A.transform[4],y:A.transform[5]},Ei.snapshot(A.id))}),particles:fe.length,animations:pe.length,contacts:ae.size,spriteFrames:Object.fromEntries(Ke([],De(Pe),!1).map(function(A){var C,N=De(A,2),P=N[0],X=N[1];return[P,(C=X.frame)!==null&&C!==void 0?C:0]})),input:{dragging:!!rt,pointerId:(x=(c=rt?.pointerId)!==null&&c!==void 0?c:ke?.pointerId)!==null&&x!==void 0?x:null,pressed:se??null,holding:!!ke?.holds.length,occupancy:Bn.snapshot(),joysticks:Object.fromEntries(Ke([],De(le),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,{active:P.pointerId!==null,x:P.nx,y:P.ny,magnitude:P.magnitude,angle:P.angle}]}))},feedback:{presses:Fn.size,floatingTexts:we.length,flashes:ze.length,shaking:!!Ye,tutorialHands:Ne},match:{boards:Object.fromEntries(Ke([],De(xt),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,P.snapshot()]})),selected:yn??null,cells:Ke([],De(Dn),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return gt({id:N},P)})},physics:Cv(),physics3d:Nv(),paths:Object.fromEntries(Ke([],De(bi),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,P.snapshot()]})),canvas:{masks:Object.fromEntries(Ke([],De(mr),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,{progress:P.progress}]})),strokes:Object.fromEntries(Ke([],De(sr),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,P.strokes.length]})),walls:Dt.length,joints:tn.filter(function(A){return!A.broken}).length},audio:{state:(R=_t?.state)!==null&&R!==void 0?R:"locked",voices:nt.size,blocked:rr},network:{target:m,ready:Ve,visible:qe,started:je,closed:ot,hostVolume:Yi},diagnostics:Ke([],De(bt),!1)}},lr=function(){return!f&&!ct&&!document.hidden&&Ve&&qe&&je&&!ot},gr=function(){var c,x,R,A;ye=void 0,yi(),or(),Li(),Mn(),Yn(),ke=void 0,et=void 0,ft=void 0;try{for(var C=Ue(sr.values()),N=C.next();!N.done;N=C.next()){var P=N.value;P.cancel()}}catch(V){c={error:V}}finally{try{N&&!N.done&&(x=C.return)&&x.call(C)}finally{if(c)throw c.error}}ar.clear(),En=void 0;try{for(var X=Ue(xt.values()),k=X.next();!k.done;k=X.next()){var Z=k.value;Z.cancelSelection()}}catch(V){R={error:V}}finally{try{k&&!k.done&&(A=X.return)&&A.call(X)}finally{if(R)throw R.error}}xt.size&&(yn=void 0),se=void 0,mn=void 0,Fn.clear()},Ai=function(c){wt=!0,bt.push(c),bt=bt.slice(-16),Fe=[]},Vt=function(c){var x,R,A;return gt(gt(gt({},c.parameters),c.prototypeId?(x=He.get(c.prototypeId))===null||x===void 0?void 0:x.parameters:{}),(A=He.get((R=c.runtimeId)!==null&&R!==void 0?R:c.id))===null||A===void 0?void 0:A.parameters)};function Sn(c,x){var R,A=Fn.get(c.id);if(!A||U?.matches)return x;var C=Ke([],De(x),!1),N=A.held?0:_e-((R=A.releasedAt)!==null&&R!==void 0?R:_e),P=A.held?0:Math.min(1,N/A.behavior.springBackSeconds),X=A.held?A.behavior.scaleDown:A.behavior.scaleDown+(1-A.behavior.scaleDown)*(1-Math.pow(1-P,3)),k=Vt(c);C[4]+=(1-X)*(C[0]*k.width+C[2]*k.height)/2,C[5]+=(1-X)*(C[1]*k.width+C[3]*k.height)/2;for(var Z=0;Z<4;Z++)C[Z]*=X;return C}function Di(c){var x,R,A,C,N,P,X,k=c.transform,Z=(A=(R=He.get((x=c.runtimeId)!==null&&x!==void 0?x:c.id))===null||R===void 0?void 0:R.transform)!==null&&A!==void 0?A:k,V=z.get((C=c.prototypeId)!==null&&C!==void 0?C:c.id);if(!V)return Sn(c,Z);var $=O(),q=Ke([],De(Z),!1);$.landscape&&(q[4]+=V.x-k[4],q[5]+=V.y-k[5],q[0]*=V.scaleX,q[1]*=V.scaleX,q[2]*=V.scaleY,q[3]*=V.scaleY);var Q=(N=V.anchor)!==null&&N!==void 0?N:"none";if(Q==="none"&&!V.respectSafeArea)return Sn(c,q);var te=V.respectSafeArea?np($):{left:0,top:0,right:$.width,bottom:$.height},G=Vt(c),ce=(P=V.marginX)!==null&&P!==void 0?P:0,me=(X=V.marginY)!==null&&X!==void 0?X:0,ve=Math.abs(q[0])*G.width+Math.abs(q[2])*G.height,xe=Math.abs(q[1])*G.width+Math.abs(q[3])*G.height;return Q!=="none"?(q[4]=Q.endsWith("left")?te.left+ce:Q.endsWith("right")?te.right-ve-ce:(te.left+te.right-ve)/2,q[5]=Q.startsWith("top")?te.top+me:Q.startsWith("bottom")?te.bottom-xe-me:(te.top+te.bottom-xe)/2):(q[4]=Math.max(te.left+ce,Math.min(te.right-ve-ce,q[4])),q[5]=Math.max(te.top+me,Math.min(te.bottom-xe-me,q[5]))),Sn(c,q)}var yr=function(c){return(Oe.has(c)?Ke([],De(Oe.values()),!1):Ke(Ke([],De(n.components),!1),De(Te),!1)).filter(function(x){return x.parentId===c&&!x.prototype}).sort(function(x,R){return x.order-R.order||(x.id<R.id?-1:x.id>R.id?1:0)})},Pa=function(){return n.components.filter(function(c){return c.sceneId===J&&!c.parentId&&!c.prototype}).sort(function(c,x){return c.order-x.order||(c.id<x.id?-1:c.id>x.id?1:0)})},Jt=function(c){var x,R;if(c.kind==="sceneEnter"&&((x=n.scenes.find(function(A){return A.id===c.sceneId}))===null||x===void 0?void 0:x.role)==="end-card"&&en!==c.sceneId&&(en=c.sceneId,(R=_?.notifyGameEnd)===null||R===void 0||R.call(_)),Fe.length>=256){Ai("Event queue budget exhausted");return}Fe.push(c)},pi=function(c,x,R,A){var C,N,P,X;return A===void 0&&(A={}),gt(gt({kind:c,componentId:(C=x.prototypeId)!==null&&C!==void 0?C:x.id,selfInstanceId:(N=x.instanceId)!==null&&N!==void 0?N:x.id,instanceId:x.instanceId},R?{otherId:(P=R.prototypeId)!==null&&P!==void 0?P:R.id,otherInstanceId:(X=R.instanceId)!==null&&X!==void 0?X:R.id}:{}),A)};function $r(c){for(var x,R=c;R;R=Le(R.parentId)){var A=Ei.states.get((x=R.instanceId)!==null&&x!==void 0?x:R.id);if(A)return A}}function Ms(c){var x,R,A=An("instance-state",(x=c.prototypeId)!==null&&x!==void 0?x:c.id);return A?Ei.initialize((R=c.instanceId)!==null&&R!==void 0?R:c.id,A.parameters):void 0}function Oo(){var c,x,R,A;try{for(var C=Ue(n.gameplay.filter(function(V){return V.kind==="instance-state"})),N=C.next();!N.done;N=C.next()){var P=N.value;try{for(var X=(R=void 0,Ue(ci(S.get(P.componentId)))),k=X.next();!k.done;k=X.next()){var Z=k.value;Ms(Z)}}catch(V){R={error:V}}finally{try{k&&!k.done&&(A=X.return)&&A.call(X)}finally{if(R)throw R.error}}}}catch(V){c={error:V}}finally{try{N&&!N.done&&(x=C.return)&&x.call(C)}finally{if(c)throw c.error}}}function Bo(c,x,R,A){var C=$r(c);if(C){var N=C.hp;if(x==="tag")C.tag=R==="set"?String(A):C.tag;else{var P=Number(A);if(C[x]=R==="add"?C[x]+P:R==="sub"?C[x]-P:P,!Number.isFinite(C[x])){Ai("Instance state range exceeded");return}x==="hp"&&(C.hp=Math.max(0,Math.min(C.maxHp,C.hp)))}N>0&&C.hp<=0&&Jt(pi("instanceDepleted",c))}}function Ja(c,x){var R,A,C;if(!c)return!0;if(c.all)return c.all.every(function(Z){return Ja(Z,x)});if(c.any)return c.any.some(function(Z){return Ja(Z,x)});var N=c.instanceTarget==="other"?x?.otherInstanceId:(R=x?.selfInstanceId)!==null&&R!==void 0?R:x?.instanceId,P=c.instanceField?(A=Le(N))!==null&&A!==void 0?A:Ke([],De(Oe.values()),!1).find(function(Z){return Z.instanceId===N}):void 0,X=c.instanceField?(C=$r(P))===null||C===void 0?void 0:C[c.instanceField]:ne[c.variableId],k=c.compareVariableId?ne[c.compareVariableId]:c.value;return{eq:function(){return X===k},ne:function(){return X!==k},lt:function(){return X<k},lte:function(){return X<=k},gt:function(){return X>k},gte:function(){return X>=k}}[c.op]()}function ko(c){var x,R,A;yn=void 0,En=void 0,c||Dn.clear();try{for(var C=Ue(n.gameplay),N=C.next();!N.done;N=C.next()){var P=N.value;if(P.kind==="match-tile"){var X=S.get(P.componentId);if(c&&X.id!==c&&!Rr(X,c))continue;He.delete(X.id),Dn.set(X.id,{row:P.parameters.row,column:P.parameters.column,group:P.parameters.group,sceneId:X.sceneId,boardId:(A=X.parentId)!==null&&A!==void 0?A:X.sceneId})}}}catch(k){x={error:k}}finally{try{N&&!N.done&&(R=C.return)&&R.call(C)}finally{if(x)throw x.error}}}function kd(){var c,x,R=function(P){var X,k;if(xt.has(P.componentId))return"continue";var Z=P.componentId,V=P.parameters,$=n.gameplay.filter(function(oe){return oe.kind==="match-tile"&&S.get(oe.componentId).parentId===Z}).sort(function(oe,be){return oe.parameters.row-be.parameters.row||oe.parameters.column-be.parameters.column}).map(function(oe){return gt({id:oe.componentId},oe.parameters)}),q=new Map;try{for(var Q=(X=void 0,Ue($)),te=Q.next();!te.done;te=Q.next()){var G=te.value;if(!q.has(G.group)){var ce=S.get(G.id);q.set(G.group,{fill:ce.parameters.fill,children:yr(G.id).filter(function(oe){return["native.image.v1","native.text.v1"].includes(oe.contract)})})}}}catch(oe){X={error:oe}}finally{try{te&&!te.done&&(k=Q.return)&&k.call(Q)}finally{if(X)throw X.error}}ni.set(Z,q);var me=S.get($[V.columns].id).transform[5]-S.get($[0].id).transform[5],ve=function(oe,be,Ee){var Ie,Ze=Ee.from,lt=Ze===void 0?oe:Ze,Xe=Ee.progress,ht=Xe===void 0?0:Xe,yt=Ee.offsetRows,Gt=yt===void 0?0:yt,Ut=Ee.scale,at=Ut===void 0?1:Ut,Wt=Ee.opacity,Mt=Wt===void 0?1:Wt,mt=$[oe],Qe=S.get(mt.id),st=S.get($[lt].id),We=q.get(be),tt=Ke([],De(Qe.transform),!1);tt[4]+=(st.transform[4]-Qe.transform[4])*ht,tt[5]+=(st.transform[5]-Qe.transform[5]+Gt*me)*ht,tt[4]+=(1-at)*(tt[0]*Qe.parameters.width+tt[2]*Qe.parameters.height)/2,tt[5]+=(1-at)*(tt[1]*Qe.parameters.width+tt[3]*Qe.parameters.height)/2;for(var St=0;St<4;St++)tt[St]*=at;He.set(mt.id,gt(gt({},He.get(mt.id)),{transform:tt,parameters:gt(gt({},(Ie=He.get(mt.id))===null||Ie===void 0?void 0:Ie.parameters),{fill:We.fill,opacity:Mt})})),Dn.get(mt.id).group=be;var Ct=yr(mt.id).filter(function(Pt){return["native.image.v1","native.text.v1"].includes(Pt.contract)});Ct.forEach(function(Pt,Nt){var Yt,Bt,it=We.children[Nt];if(!(!it||it.contract!==Pt.contract)){var Ft=(Yt=He.get(Pt.id))!==null&&Yt!==void 0?Yt:{transform:Ke([],De(Pt.transform),!1),parameters:{}};Pt.contract==="native.image.v1"?Ft.assetId=(Bt=it.assetSlots[0])===null||Bt===void 0?void 0:Bt.assetId:Ft.parameters.text=it.parameters.text,He.set(Pt.id,Ft)}})},xe=Lp(gt(gt({},V),{slots:$,paint:ve,onEvent:function(oe){yn=void 0,Jt({kind:oe,componentId:Z})}}));xt.set(Z,xe)};try{for(var A=Ue(n.gameplay.filter(function(P){return P.kind==="match-board"})),C=A.next();!C.done;C=A.next()){var N=C.value;R(N)}}catch(P){c={error:P}}finally{try{C&&!C.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}}function rc(c){var x,R;kd();try{for(var A=Ue(xt),C=A.next();!C.done;C=A.next()){var N=De(C.value,2),P=N[0],X=N[1];(!c||c===P||Rr(S.get(P),c))&&X.reset()}}catch(k){x={error:k}}finally{try{C&&!C.done&&(R=A.return)&&R.call(A)}finally{if(x)throw x.error}}}function ci(c){return ki(c)?Ke([],De(Oe.values()),!1).filter(function(x){return x.prototypeId===c.id}):[c]}function xi(c){var x=Vt(c);return In(zn(c),x.width/2,x.height/2)}function Ss(c,x,R){var A;R===void 0&&(R="self");var C=S.get(c),N=R==="other"?x.otherInstanceId:(A=x.selfInstanceId)!==null&&A!==void 0?A:x.instanceId,P=!!(C&&ki(C));if(N!==void 0){if(c){var X=Ke([],De(Oe.values()),!1).find(function(k){return k.prototypeId===c&&(k.instanceId===N||k.id===N)});if(X)return X}if(R==="other"||!c)return Le(N);if(P&&typeof N=="string"&&N.startsWith("instance."))return}return C?P?ci(C)[0]:Le(c):void 0}function ua(c,x,R){var A,C=Vt(c),N=(A=He.get(c.id))!==null&&A!==void 0?A:{transform:Ke([],De(c.transform),!1),parameters:{}},P=Ke([],De(N.transform),!1),X=c.parentId?zn(Le(c.parentId)):ga(),k=In(wr(X),x,R);P[4]=k.x-(P[0]*C.width+P[2]*C.height)/2,P[5]=k.y-(P[1]*C.width+P[3]*C.height)/2,He.set(c.id,gt(gt({},N),{transform:P})),c.prototypeId&&(c.transform=Ke([],De(P),!1))}function Gs(c,x,R){var A,C,N,P;R===void 0&&(R=!1);var X=(A=He.get(c.id))!==null&&A!==void 0?A:{transform:Ke([],De(c.transform),!1),parameters:{}},k=(P=(N=S.get((C=c.prototypeId)!==null&&C!==void 0?C:c.id))===null||N===void 0?void 0:N.transform)!==null&&P!==void 0?P:c.transform,Z=Math.hypot(k[0],k[1])*(R?-1:1),V=Math.hypot(k[2],k[3]),$=x+(R?0:Math.atan2(k[1],k[0])),q=Math.cos($),Q=Math.sin($),te=Ke([],De(X.transform),!1);te[0]=q*Z,te[1]=Q*Z,te[2]=-Q*V,te[3]=q*V,He.set(c.id,gt(gt({},X),{transform:te}))}function $a(c,x){var R=fn.get(c.id);if(R)return R;var A=zn(c),C=Vt(c),N=In(A,C.width/2,C.height/2);return R=gt({id:c.id,sourceId:x.componentId,instanceId:c.instanceId,x:N.x,y:N.y,vx:0,vy:0,width:Math.hypot(A[0],A[1])*C.width,height:Math.hypot(A[2],A[3])*C.height,angle:Math.atan2(A[1],A[0]),restElapsed:0,atRest:!0},x.parameters),fn.set(c.id,R),R}function zo(c,x){var R,A=mr.get(c.id);if(A)return A;var C=Vt(c),N=x.parameters;return A=Wp(N,{width:C.width,height:C.height,source:c.contract==="native.image.v1"?b.get((R=c.assetSlots[0])===null||R===void 0?void 0:R.assetId):void 0,onProgress:function(P){N.progressVariableId&&(ne[N.progressVariableId]=P),Jt(pi("maskProgress",c))},onComplete:function(){return Jt(pi("maskComplete",c))}}),mr.set(c.id,A),A}function Ev(c){var x=sr.get(c.componentId);return x||(x=qp(c.parameters),sr.set(c.componentId,x)),x}function ip(){var c,x,R,A,C,N,P,X,k,Z,V,$,q=new Set,Q=[];try{for(var te=Ue(n.gameplay.filter(function(tt){return tt.kind==="physics-body"})),G=te.next();!G.done;G=te.next()){var ce=G.value,me=S.get(ce.componentId);if(me.sceneId===J)try{for(var ve=(R=void 0,Ue(ci(me))),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;if(ii(oe)){if(Q.length>=64){Ai("Physics body budget exhausted");break}var be=$a(oe,ce),Ee=zn(oe),Ie=Vt(oe),Ze=In(Ee,Ie.width/2,Ie.height/2);if(q.add(oe.id),be.width=Math.hypot(Ee[0],Ee[1])*Ie.width,be.height=Math.hypot(Ee[2],Ee[3])*Ie.height,be.mode!=="dynamic"){var lt=qi.get(oe.id),Xe=oe.parentId?zn(Le(oe.parentId)):ga(),ht=(V=lt?.vx)!==null&&V!==void 0?V:0,yt=($=lt?.vy)!==null&&$!==void 0?$:0;be.x=Ze.x,be.y=Ze.y,be.angle=Math.atan2(Ee[1],Ee[0]),be.vx=Xe[0]*ht+Xe[2]*yt,be.vy=Xe[1]*ht+Xe[3]*yt}else be.atRest&&(be.x=Ze.x,be.y=Ze.y);Q.push(be)}}}catch(tt){R={error:tt}}finally{try{xe&&!xe.done&&(A=ve.return)&&A.call(ve)}finally{if(R)throw R.error}}}}catch(tt){c={error:tt}}finally{try{G&&!G.done&&(x=te.return)&&x.call(te)}finally{if(c)throw c.error}}try{for(var Gt=Ue(fn.keys()),Ut=Gt.next();!Ut.done;Ut=Gt.next()){var at=Ut.value;!q.has(at)&&!Oe.has(at)&&fn.delete(at)}}catch(tt){C={error:tt}}finally{try{Ut&&!Ut.done&&(N=Gt.return)&&N.call(Gt)}finally{if(C)throw C.error}}var Wt=[];try{for(var Mt=Ue(n.gameplay.filter(function(tt){return tt.kind==="capture-zone"})),mt=Mt.next();!mt.done;mt=Mt.next()){var ce=mt.value,me=S.get(ce.componentId);if(me.sceneId===J)try{for(var Qe=(k=void 0,Ue(ci(me))),st=Qe.next();!st.done;st=Qe.next()){var oe=st.value;if(ii(oe)){var Ee=zn(oe),Ie=Vt(oe),Ze=In(Ee,Ie.width/2,Ie.height/2),We=Math.max(.1,Math.min(Math.hypot(Ee[0],Ee[1]),Math.hypot(Ee[2],Ee[3])));Wt.push(gt(gt({id:oe.id,sourceId:me.id,instanceId:oe.instanceId,x:Ze.x,y:Ze.y},ce.parameters),{radius:ce.parameters.radius*We}))}}}catch(Ct){k={error:Ct}}finally{try{st&&!st.done&&(Z=Qe.return)&&Z.call(Qe)}finally{if(k)throw k.error}}}}catch(tt){P={error:tt}}finally{try{mt&&!mt.done&&(X=Mt.return)&&X.call(Mt)}finally{if(P)throw P.error}}return{bodies:Ke(Ke([],De(Q),!1),De(Dt),!1),zones:Wt}}function Av(c){var x,R,A,C,N,P,X,k=ip(),Z=k.bodies,V=k.zones,$=O();tn=[];try{for(var q=Ue(n.gameplay.filter(function(Xe){return Xe.kind==="physics-joint"})),Q=q.next();!Q.done;Q=q.next()){var te=Q.value,G=S.get(te.componentId);if(G.sceneId===J){var ce=Le(te.parameters.anchorComponentId),me=An("physics-body",G.id);if(!(!ce||!me))try{for(var ve=(A=void 0,Ue(ci(G))),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;$a(oe,me);var be=xi(ce),Ee=te.id+":"+oe.id;tn.push(gt(gt({},te.parameters),{id:te.id,key:Ee,componentId:G.id,bodyId:oe.id,anchorId:ce.id,x:be.x,y:be.y,broken:D.has(Ee)}))}}catch(Xe){A={error:Xe}}finally{try{xe&&!xe.done&&(C=ve.return)&&C.call(ve)}finally{if(A)throw A.error}}}}}catch(Xe){x={error:Xe}}finally{try{Q&&!Q.done&&(R=q.return)&&R.call(q)}finally{if(x)throw x.error}}ff({bodies:Z,zones:V,joints:tn,bounds:{left:0,top:0,right:$.width,bottom:$.height},dt:c,onEvent:function(Xe,ht,yt){var Gt,Ut,at,Wt;if(!(Xe==="bodyBounce"&&yt&&ht.sourceId===yt.sourceId&&ht.id>yt.id)){var Mt=(Gt=ht.instanceId)!==null&&Gt!==void 0?Gt:ht.id,mt=yt?(Ut=yt.instanceId)!==null&&Ut!==void 0?Ut:yt.id:void 0,Qe=gt(gt({kind:Xe,componentId:ht.sourceId,selfInstanceId:Mt},mt?{otherInstanceId:mt}:{}),{instanceId:(at=ht.instanceId)!==null&&at!==void 0?at:yt?.instanceId});if(yt&&(Qe.otherId=yt.sourceId),Jt(Qe),Xe==="zoneCapture"){var st=Le(ht.id),We=S.get(yt.sourceId);if(yt.hideCaptured&&st){var tt=(Wt=He.get(st.id))!==null&&Wt!==void 0?Wt:{transform:Ke([],De(st.transform),!1),parameters:{}};tt.parameters.visible=!1,He.set(st.id,tt)}yt.stopBody&&We&&st&&ua(st,yt.x,yt.y)}}}});try{for(var Ie=Ue(Z),Ze=Ie.next();!Ze.done;Ze=Ie.next()){var lt=Ze.value,oe=Le(lt.id);!oe||lt.mode!=="dynamic"||(lt.spinToRotation&&Gs(oe,(X=lt.angle)!==null&&X!==void 0?X:0),ua(oe,lt.x,lt.y))}}catch(Xe){N={error:Xe}}finally{try{Ze&&!Ze.done&&(P=Ie.return)&&P.call(Ie)}finally{if(N)throw N.error}}}function Iv(){var c,x,R,A,C;try{for(var N=Ue(n.gameplay.filter(function(xe){return xe.kind==="oscillate"})),P=N.next();!P.done;P=N.next()){var X=P.value,k=S.get(X.componentId);if(k.sceneId===J)try{for(var Z=(R=void 0,Ue(ci(k))),V=Z.next();!V.done;V=Z.next()){var $=V.value,q=qi.get($.id);q||(q={base:Ke([],De(Di($)),!1),vx:0,vy:0},qi.set($.id,q));var Q=X.parameters,te=(_e/Q.periodSeconds+Q.phase)*Math.PI*2,G=Math.sin(te)*Q.amplitude,ce=Math.cos(te)*Q.amplitude*Math.PI*2/Q.periodSeconds,me=(C=He.get($.id))!==null&&C!==void 0?C:{parameters:{}},ve=Ke([],De(q.base),!1);Q.axis==="x"?(ve[4]+=G,q.vx=ce,q.vy=0):(ve[5]+=G,q.vy=ce,q.vx=0),He.set($.id,gt(gt({},me),{transform:ve})),qi.set($.id,q)}}catch(xe){R={error:xe}}finally{try{V&&!V.done&&(A=Z.return)&&A.call(Z)}finally{if(R)throw R.error}}}}catch(xe){c={error:xe}}finally{try{P&&!P.done&&(x=N.return)&&x.call(N)}finally{if(c)throw c.error}}}function rp(){var c,x;bi.clear();var R=function(P){var X=n.gameplay.filter(function(Z){return Z.kind==="path-gate"&&Z.parameters.networkBehaviorId===P.id}),k=ov({id:P.id,nodes:P.parameters.nodes,edges:P.parameters.edges,gates:X,onEvent:function(Z,V){var $,q=Le(V.componentId),Q=($=q?.prototypeId)!==null&&$!==void 0?$:V.componentId;Jt(gt({kind:Z,componentId:Q,instanceId:q?.instanceId},V.nodeId?{nodeId:V.nodeId}:{}))}});bi.set(P.id,k)};try{for(var A=Ue(n.gameplay.filter(function(P){return P.kind==="path-network"})),C=A.next();!C.done;C=A.next()){var N=C.value;R(N)}}catch(P){c={error:P}}finally{try{C&&!C.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}}function ac(c,x){var R,A,C,N,P,X,k,Z,V,$,q,Q,te;x===void 0&&(x=!0);var G=0;try{for(var ce=Ue(n.gameplay.filter(function(tt){return tt.kind==="path-agent"})),me=ce.next();!me.done;me=ce.next()){var ve=me.value,xe=S.get(ve.componentId),oe=bi.get(ve.parameters.networkBehaviorId);if(!(xe.sceneId!==J||!oe))try{for(var be=(C=void 0,Ue(ci(xe))),Ee=be.next();!Ee.done;Ee=be.next()){var Ie=Ee.value;if(++G>64){Ai("Path agent budget exhausted");break}var Ze=oe.getAgent(Ie.id);Ze||(Ze=oe.addAgent(gt(gt({},ve.parameters),{id:Ie.id,startNode:(q=Ie.pathStartNode)!==null&&q!==void 0?q:ve.parameters.startNode,targetNode:(Q=Ie.pathTargetNode)!==null&&Q!==void 0?Q:ve.parameters.targetNode}))),Ze.speedMultiplier=Math.max(0,Number(ve.parameters.speedMultiplierVariableId?ne[ve.parameters.speedMultiplierVariableId]:1))}}catch(tt){C={error:tt}}finally{try{Ee&&!Ee.done&&(N=be.return)&&N.call(be)}finally{if(C)throw C.error}}}}catch(tt){R={error:tt}}finally{try{me&&!me.done&&(A=ce.return)&&A.call(ce)}finally{if(R)throw R.error}}if(x){var lt=function(tt,St){var Ct=n.gameplay.find(function(Pt){return Pt.id===tt});S.get(Ct.componentId).sceneId===J&&St.tick(c)};try{for(var Xe=Ue(bi),ht=Xe.next();!ht.done;ht=Xe.next()){var yt=De(ht.value,2),Gt=yt[0],Ut=yt[1];lt(Gt,Ut)}}catch(tt){P={error:tt}}finally{try{ht&&!ht.done&&(X=Xe.return)&&X.call(Xe)}finally{if(P)throw P.error}}}try{for(var at=Ue(n.gameplay.filter(function(tt){return tt.kind==="path-agent"})),Wt=at.next();!Wt.done;Wt=at.next()){var ve=Wt.value,xe=S.get(ve.componentId),Mt=bi.get(ve.parameters.networkBehaviorId);if(!(xe.sceneId!==J||!Mt))try{for(var mt=(V=void 0,Ue(ci(xe))),Qe=mt.next();!Qe.done;Qe=mt.next()){var Ie=Qe.value,Ze=Mt.getAgent(Ie.id);if(Ze){if(Ze.orientToPath==="rotate")Gs(Ie,Ze.heading);else if(Ze.orientToPath==="flip-x")Gs(Ie,0,Ze.flipX);else if(Ze.orientToPath==="iso-4"){var st=(te=He.get(Ie.id))!==null&&te!==void 0?te:{transform:Ke([],De(Ie.transform),!1),parameters:{}};st.pathFrame=Ze.frame,He.set(Ie.id,st)}var We=Ie.parentId?In(zn(Le(Ie.parentId)),Ze.x,Ze.y):Ze;ua(Ie,We.x,We.y)}}}catch(Ct){V={error:Ct}}finally{try{Qe&&!Qe.done&&($=mt.return)&&$.call(mt)}finally{if(V)throw V.error}}}}catch(tt){k={error:tt}}finally{try{Wt&&!Wt.done&&(Z=at.return)&&Z.call(at)}finally{if(k)throw k.error}}}function zd(c){var x,R,A,C,N,P,X,k,Z,V,$=new Set;try{for(var q=Ue(n.gameplay.filter(function(Ft){return Ft.kind==="value-meter"})),Q=q.next();!Q.done;Q=q.next()){var te=Q.value,G=S.get(te.componentId);if(G.sceneId===J)try{for(var ce=(A=void 0,Ue(ci(G))),me=ce.next();!me.done;me=ce.next()){var ve=me.value,xe=te.parameters,oe=xe.instanceField?$r(ve):void 0,be=xe.instanceField==="hp"&&oe?oe.hp/oe.maxHp*(xe.max-xe.min)+xe.min:xe.instanceField==="value"&&oe?oe.value:Number(ne[xe.variableId]),Ee=wi.get(ve.id);Ee||(Ee={base:Ke([],De(Di(ve)),!1),value:Number.isFinite(be)?Math.max(xe.min,Math.min(xe.max,be)):xe.min},wi.set(ve.id,Ee)),$.add(ve.id);var Ie=Math.max(xe.min,Math.min(xe.max,be)),Ze=xe.smoothingSeconds?1-Math.exp(-c/xe.smoothingSeconds):1;Ee.value+=((Number.isFinite(Ie)?Ie:xe.min)-Ee.value)*Ze;var lt=Math.max(0,Math.min(1,(Ee.value-xe.min)/(xe.max-xe.min))),Xe=Ke([],De(Ee.base),!1),ht=(Z=He.get(ve.id))!==null&&Z!==void 0?Z:{parameters:{}},yt=xe.axis==="x"?Vt(ve).width:Vt(ve).height;if(xe.axis==="x"?(Xe[0]*=lt,Xe[1]*=lt):(Xe[2]*=lt,Xe[3]*=lt),xe.direction==="negative"){var Gt=yt*(1-lt);xe.axis==="x"?(Xe[4]+=Ee.base[0]*Gt,Xe[5]+=Ee.base[1]*Gt):(Xe[4]+=Ee.base[2]*Gt,Xe[5]+=Ee.base[3]*Gt)}He.set(ve.id,gt(gt({},ht),{transform:Xe}))}}catch(Ft){A={error:Ft}}finally{try{me&&!me.done&&(C=ce.return)&&C.call(ce)}finally{if(A)throw A.error}}}}catch(Ft){x={error:Ft}}finally{try{Q&&!Q.done&&(R=q.return)&&R.call(q)}finally{if(x)throw x.error}}try{for(var Ut=Ue(wi.keys()),at=Ut.next();!at.done;at=Ut.next()){var Wt=at.value;$.has(Wt)||wi.delete(Wt)}}catch(Ft){N={error:Ft}}finally{try{at&&!at.done&&(P=Ut.return)&&P.call(Ut)}finally{if(N)throw N.error}}try{for(var Mt=Ue(n.gameplay.filter(function(Ft){return Ft.kind==="camera-follow"})),mt=Mt.next();!mt.done;mt=Mt.next()){var te=mt.value,Qe=S.get(te.componentId),Ie=Le(te.parameters.targetId);if(!(Qe.sceneId!==J||!Ie)){var st=gi.get(Qe.id);st||(st={base:Ke([],De(Qe.transform),!1),x:te.parameters.minX,y:te.parameters.minY},gi.set(Qe.id,st));var We=function(Rn,Hn){for(var si=[],ai=Rn;ai&&ai.id!==Hn.id;ai=Le(ai.parentId))si.unshift(ai);return si.reduce(function(qn,Kr){return qs(qn,Di(Kr))},ga())},Xe=Rr(Ie,Qe.id)?We(Ie,Qe):zn(Ie),xe=Vt(Ie),tt=In(Xe,xe.width/2,xe.height/2),St=O(),Ct=te.parameters,Pt=Math.max(Ct.minX,Ct.maxX-St.width/Ct.zoom),Nt=Math.max(Ct.minY,Ct.maxY-St.height/Ct.zoom),Yt=Math.max(Ct.minX,Math.min(Pt,tt.x-St.width/(2*Ct.zoom))),Bt=Math.max(Ct.minY,Math.min(Nt,tt.y-St.height/(2*Ct.zoom))),Ze=1-Math.exp(-Ct.smoothing*c);st.x+=(Yt-st.x)*Ze,st.y+=(Bt-st.y)*Ze;var ht=(V=He.get(Qe.id))!==null&&V!==void 0?V:{parameters:{}},it=Ke([],De(st.base),!1);it[0]*=Ct.zoom,it[1]*=Ct.zoom,it[2]*=Ct.zoom,it[3]*=Ct.zoom,it[4]-=st.x*Ct.zoom,it[5]-=st.y*Ct.zoom,He.set(Qe.id,gt(gt({},ht),{transform:it}))}}}catch(Ft){X={error:Ft}}finally{try{mt&&!mt.done&&(k=Mt.return)&&k.call(Mt)}finally{if(X)throw X.error}}}function Cv(){return{bodies:Ke([],De(fn.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:he?{componentId:he.sourceId,pointerId:he.pointerId,power:he.power}:null}}function sc(c){for(var x=c;x;){if(x.contract==="native.stage3d.v1")return x;x=x.parentId?Le(x.parentId):void 0}}function oc(c,x){var R,A,C,N,P,X,k=$t.get(c.id);if(k)return k;var Z=Vt(c),V=sc(c);return k=gt({id:c.id,sourceId:x.componentId,stageId:V?.id,x:(R=Z.x)!==null&&R!==void 0?R:0,y:(A=Z.y)!==null&&A!==void 0?A:0,z:(C=Z.z)!==null&&C!==void 0?C:0,vx:0,vy:0,vz:0,spin:0,atRest:!0,captured:!1,captureElapsed:0,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:(N=Z.x)!==null&&N!==void 0?N:0,y:(P=Z.y)!==null&&P!==void 0?P:0,z:(X=Z.z)!==null&&X!==void 0?X:0}},x.parameters),$t.set(c.id,k),k}function lc(){var c,x,R,A,C,N,P,X=[],k=[],Z=[];if(!jt)return{bodies:X,walls:k,zones:Z};try{for(var V=Ue(n.gameplay.filter(function(ve){return ve.kind==="physics-3d"})),$=V.next();!$.done;$=V.next()){var q=$.value,Q=S.get(q.componentId);if(!(!Q||Q.sceneId!==J||!ii(Q))){var te=oc(Q,q);te.mode==="dynamic"?X.push(te):k.push(te)}}}catch(ve){c={error:ve}}finally{try{$&&!$.done&&(x=V.return)&&x.call(V)}finally{if(c)throw c.error}}try{for(var G=Ue(n.gameplay.filter(function(ve){return ve.kind==="capture-zone-3d"})),ce=G.next();!ce.done;ce=G.next()){var q=ce.value,Q=S.get(q.componentId);if(!(!Q||Q.sceneId!==J||!ii(Q))){var me=Vt(Q);Z.push(gt({id:Q.id,sourceId:Q.id,x:(C=me.x)!==null&&C!==void 0?C:0,y:(N=me.y)!==null&&N!==void 0?N:0,z:(P=me.z)!==null&&P!==void 0?P:0},q.parameters))}}}catch(ve){R={error:ve}}finally{try{ce&&!ce.done&&(A=G.return)&&A.call(G)}finally{if(R)throw R.error}}return{bodies:X,walls:k,zones:Z}}function Rv(c){var x,R,A,C,N,P,X,k,Z,V;if(jt){try{for(var $=Ue(n.gameplay.filter(function(Wt){return Wt.kind==="oscillate-3d"})),q=$.next();!q.done;q=$.next()){var Q=q.value,te=S.get(Q.componentId);if(!(!te||te.sceneId!==J)){var G=Et.get(te.id);if(!G){var ce=Vt(te);G={x:(N=ce.x)!==null&&N!==void 0?N:0,y:(P=ce.y)!==null&&P!==void 0?P:0,z:(X=ce.z)!==null&&X!==void 0?X:0},Et.set(te.id,G)}var me=Q.parameters,ve=_e*me.angularSpeed+me.phase,xe=Math.sin(ve)*me.amplitude,oe=Math.cos(ve)*me.amplitude*me.angularSpeed,be=(k=$t.get(te.id))!==null&&k!==void 0?k:An("physics-3d",te.id)?oc(te,An("physics-3d",te.id)):void 0,Ee=G.x+(me.axis==="x"?xe:0),Ie=G.y+(me.axis==="y"?xe:0),Ze=G.z+(me.axis==="z"?xe:0);if(be)be.x=Ee,be.y=Ie,be.z=Ze,be.vx=me.axis==="x"?oe:0,be.vy=me.axis==="y"?oe:0,be.vz=me.axis==="z"?oe:0;else{var lt=(Z=He.get(te.id))!==null&&Z!==void 0?Z:{transform:Ke([],De(te.transform),!1),parameters:{}};lt.parameters.x=Ee,lt.parameters.y=Ie,lt.parameters.z=Ze,He.set(te.id,lt)}}}}catch(Wt){x={error:Wt}}finally{try{q&&!q.done&&(R=$.return)&&R.call($)}finally{if(x)throw x.error}}var Xe=lc(),ht=Xe.bodies,yt=Xe.walls,Gt=Xe.zones;pf({bodies:ht,walls:yt,zones:Gt,dt:c,onEvent:function(Wt,Mt,mt){var Qe={kind:Wt,componentId:Mt.sourceId};mt&&(Qe.otherId=mt.sourceId),Jt(Qe)}});try{for(var Ut=Ue(ht),at=Ut.next();!at.done;at=Ut.next()){var be=at.value;be.captured&&(be.captureElapsed=((V=be.captureElapsed)!==null&&V!==void 0?V:0)+c)}}catch(Wt){A={error:Wt}}finally{try{at&&!at.done&&(C=Ut.return)&&C.call(Ut)}finally{if(A)throw A.error}}Pv(c,yt)}}function cc(c){var x=Vn.get(c.componentId);if(!x){var R=c.parameters;x={behavior:c,x:R.x,y:R.y,z:R.z,yaw:R.yaw,pitch:R.pitch,bobPhase:0,bob:0},Vn.set(c.componentId,x)}return x}function ap(){var c,x;try{for(var R=Ue(n.gameplay.filter(function(N){var P;return N.kind==="fps-controller-3d"&&((P=S.get(N.componentId))===null||P===void 0?void 0:P.sceneId)===J})),A=R.next();!A.done;A=R.next()){var C=A.value;cc(C)}}catch(N){c={error:N}}finally{try{A&&!A.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}}function sp(c){var x,R,A,C=[];try{for(var N=Ue(Oe.values()),P=N.next();!P.done;P=N.next()){var X=P.value;X.contract==="native.mesh3d.v1"&&((A=sc(X))===null||A===void 0?void 0:A.id)===c&&C.push(X)}}catch(k){x={error:k}}finally{try{P&&!P.done&&(R=N.return)&&R.call(N)}finally{if(x)throw x.error}}return C}function op(c,x,R){var A,C,N=cc(c),P=c.parameters,X=P.lookSensitivity,k=P.invertAimY?-1:1,Z=N.yaw-x*X;P.minYaw!==void 0&&P.maxYaw!==void 0&&(Z=Math.max(P.minYaw,Math.min(P.maxYaw,Z))),N.yaw=Z,N.pitch=Math.max((A=P.minPitch)!==null&&A!==void 0?A:-.75,Math.min((C=P.maxPitch)!==null&&C!==void 0?C:.75,N.pitch-R*X*k))}function Pv(c,x){var R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be=function(Mt){var mt=S.get(Mt.componentId);if(!mt||mt.sceneId!==J)return"continue";var Qe=cc(Mt),st=Mt.parameters,We=st.aimJoystickBehaviorId?le.get(st.aimJoystickBehaviorId):void 0;if(We&&st.aimMode==="rate"&&We.magnitude>1e-4&&c>0){var tt=(k=st.aimTurnSpeed)!==null&&k!==void 0?k:1.8,St=st.invertAimY?-1:1,Ct=Qe.yaw-We.nx*tt*c;st.minYaw!==void 0&&st.maxYaw!==void 0&&(Ct=Math.max(st.minYaw,Math.min(st.maxYaw,Ct))),Qe.yaw=Ct,Qe.pitch=Math.max((Z=st.minPitch)!==null&&Z!==void 0?Z:-.75,Math.min((V=st.maxPitch)!==null&&V!==void 0?V:.75,Qe.pitch-We.ny*tt*St*c))}var Pt=st.joystickBehaviorId?le.get(st.joystickBehaviorId):void 0,Nt=Pt?Pt.nx:Number(st.moveXVariableId?ne[st.moveXVariableId]:0),Yt=Pt?Pt.ny:Number(st.moveYVariableId?ne[st.moveYVariableId]:0),Bt=Math.min(1,Math.hypot(Nt,Yt));if(Bt>1e-4&&st.moveSpeed>0&&c>0){var it=-Yt,Ft=Nt,Cn=-Math.sin(Qe.yaw),bn=-Math.cos(Qe.yaw),_i=Math.cos(Qe.yaw),ri=-Math.sin(Qe.yaw),wn=st.moveSpeed*c,Rn=x.filter(function(si){return si.stageId===mt.id}),Hn=mf(Qe.x+(Cn*it+_i*Ft)*wn,Qe.z+(bn*it+ri*Ft)*wn,($=st.playerRadius)!==null&&$!==void 0?$:.45,Rn,(q=st.boundsX)!==null&&q!==void 0?q:12,(Q=st.boundsZ)!==null&&Q!==void 0?Q:12);Qe.x=Hn.x,Qe.z=Hn.z,Qe.bobPhase+=c*10*Bt,Qe.bob=U?.matches?0:Math.sin(Qe.bobPhase)*((te=st.bobAmplitude)!==null&&te!==void 0?te:.04)*Bt}else Qe.bob*=Math.max(0,1-12*c)};try{for(var Ee=Ue(n.gameplay.filter(function(Mt){return Mt.kind==="fps-controller-3d"})),Ie=Ee.next();!Ie.done;Ie=Ee.next()){var Ze=Ie.value;be(Ze)}}catch(Mt){R={error:Mt}}finally{try{Ie&&!Ie.done&&(A=Ee.return)&&A.call(Ee)}finally{if(R)throw R.error}}try{for(var lt=Ue(n.gameplay.filter(function(Mt){return Mt.kind==="steer-3d"})),Xe=lt.next();!Xe.done;Xe=lt.next()){var Ze=Xe.value,ht=S.get(Ze.componentId);if(!(!ht||ht.sceneId!==J)){var yt=Ze.parameters,Gt=function(mt){if(!ii(mt))return"continue";var Qe=sc(mt),st=Qe?Vn.get(Qe.id):void 0;if(!st)return"continue";var We=Vt(mt),tt=(G=We.x)!==null&&G!==void 0?G:0,St=(ce=We.z)!==null&&ce!==void 0?ce:0,Ct=st.x-tt,Pt=st.z-St,Nt=Math.hypot(Ct,Pt),Yt=(me=yt.stopDistance)!==null&&me!==void 0?me:2.5,Bt=tt,it=St;if(yt.mode==="chase-camera"&&Nt>Yt&&Nt>1e-4){var Ft=Math.min(Nt-Yt,yt.speed*c);Bt+=Ct/Nt*Ft,it+=Pt/Nt*Ft}else if(yt.mode==="strafe-camera"&&Nt>1e-4){var Cn=-Pt/Nt,bn=Ct/Nt;Bt+=Cn*yt.speed*c,it+=bn*yt.speed*c}else yt.mode==="patrol"&&(Bt+=Math.cos(_e*1.5)*yt.speed*c);var _i=x.filter(function(Rn){return Rn.stageId===Qe.id&&Rn.id!==mt.id}),ri=mf(Bt,it,.45,_i,(ve=yt.boundsX)!==null&&ve!==void 0?ve:12,(xe=yt.boundsZ)!==null&&xe!==void 0?xe:12),wn=(oe=He.get(mt.id))!==null&&oe!==void 0?oe:{transform:Ke([],De(mt.transform),!1),parameters:{}};wn.parameters.x=ri.x,wn.parameters.z=ri.z,yt.faceCamera!==!1&&(wn.parameters.ry=Math.atan2(st.x-ri.x,st.z-ri.z)),He.set(mt.id,wn)};try{for(var Ut=(P=void 0,Ue(ci(ht))),at=Ut.next();!at.done;at=Ut.next()){var Wt=at.value;Gt(Wt)}}catch(mt){P={error:mt}}finally{try{at&&!at.done&&(X=Ut.return)&&X.call(Ut)}finally{if(P)throw P.error}}}}}catch(Mt){C={error:Mt}}finally{try{Xe&&!Xe.done&&(N=lt.return)&&N.call(lt)}finally{if(C)throw C.error}}}function Lv(c,x,R,A){if(Te.length>=128){Ai("Instance budget exhausted");return}var C=S.get(c),N=function(Z){return 1+n.components.filter(function(V){return V.parentId===Z}).reduce(function(V,$){return V+N($.id)},0)};if(Oe.size+N(C.id)>4096){Ai("Runtime node budget exhausted");return}var P="instance."+ ++$e;function X(Z,V){var $,q,Q=Z.id===C.id?P:P+":"+Z.id,te=gt(gt({},Z),{id:Q,runtimeId:Q,instanceId:P,prototypeId:Z.id,prototype:!1,parentId:V,transform:Ke([],De(Z.transform),!1),parameters:gt({},Z.parameters),spawnTime:_e});Oe.set(Q,te);try{for(var G=Ue(n.components.filter(function(ve){return ve.parentId===Z.id})),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;X(me,Q)}}catch(ve){$={error:ve}}finally{try{ce&&!ce.done&&(q=G.return)&&q.call(G)}finally{if($)throw $.error}}return te}var k=X(C,C.parentId);return k.parameters.x=x,k.parameters.y=R,k.parameters.z=A,Te.push(k),Ms(k),k}function Dv(c){var x,R;if(jt){var A=S.get(c.stageId);if(!(!A||A.sceneId!==J)){var C=Vt(A),N=zn(A),P=Math.hypot(N[0],N[1]),X=Math.hypot(N[2],N[3]),k=jt.syncStage(A,{time:_e,ambientTime:Ge,propsOf:Vt,bodies3d:$t,fpsPose:Vn.get(A.id),instances3d:sp(A.id),aimLocked:!!It,groundFn:Js,worldWidth:C.width*P,worldHeight:C.height*X}).entry,Z=0,V=0;if(c.mode==="pointer"){var $=In(wr(N),Je.x,Je.y);Z=$.x/Math.max(1,C.width)*2-1,V=1-$.y/Math.max(1,C.height)*2}var q=new Set(n.gameplay.filter(function(me){return me.kind==="physics-3d"&&me.parameters.mode!=="dynamic"}).map(function(me){return me.componentId})),Q=(x=c.targetTeam)!==null&&x!==void 0?x:"any",te=function(me){var ve,xe,oe=Le(me);return!oe||!ii(oe)?!1:Q!=="any"?((ve=$r(oe))===null||ve===void 0?void 0:ve.team)===Q:!!$r(oe)||!q.has((xe=oe.prototypeId)!==null&&xe!==void 0?xe:oe.id)},G=k.raycast(Z,V,(R=c.maxDistance)!==null&&R!==void 0?R:80,{isTarget:te,isOccluder:function(me){return q.has(me)}});if(G){var ce=Le(G.id);ce&&Jt(pi("raycastHit3d",ce,A))}else Jt({kind:"raycastMiss3d",componentId:A.id})}}}function Vd(c){var x,R,A;if(!jt)return null;var C=Le(c);if(!C||C.contract!=="native.mesh3d.v1")return null;var N=sc(C);if(!N)return null;var P=jt.getStage(N);if(!P||!P.lastWidth||!P.lastHeight)return null;var X=$t.get(C.id),k=Vt(C),Z=P.project({x:X?X.x:(x=k.x)!==null&&x!==void 0?x:0,y:X?X.y:(R=k.y)!==null&&R!==void 0?R:0,z:X?X.z:(A=k.z)!==null&&A!==void 0?A:0},P.lastWidth,P.lastHeight);return In(zn(N),Z.x,Z.y)}function lp(){if(!It||!jt)return{vx:0,vz:0,power:0,pull:0};var c=S.get(It.stageId),x=jt.getStage(c),R=$t.get(It.targetId),A=It.behavior.parameters;if(!x||!R||!x.lastWidth||!x.lastHeight)return{vx:0,vz:0,power:0,pull:0};var C=wr(zn(c)),N=In(C,It.start.x,It.start.y),P=In(C,It.current.x,It.current.y),X=Math.hypot(It.current.x-It.start.x,It.current.y-It.start.y),k=x.unproject(N.x,N.y,x.lastWidth,x.lastHeight,R.y),Z=x.unproject(P.x,P.y,x.lastWidth,x.lastHeight,R.y);if(!k||!Z)return{vx:0,vz:0,power:0,pull:X};var V=(k.x-Z.x)*A.dragScale,$=(k.z-Z.z)*A.dragScale,q=Math.hypot(V,$);return q>A.maxSpeed&&(V*=A.maxSpeed/q,$*=A.maxSpeed/q),{vx:V,vz:$,power:Math.min(1,Math.hypot(V,$)/Math.max(.001,A.maxSpeed)),pull:X}}function cp(c){if(!(!It||!jt)){It.current=c;var x=lp(),R=It.behavior.parameters;It.power=x.power,R.powerVariableId&&(ne[R.powerVariableId]=x.power);var A=S.get(It.stageId),C=jt.getStage(A),N=$t.get(It.targetId);if(C&&N&&R.showTrajectory&&x.pull>=R.minPullPx){var P=lc(),X=P.walls,k=P.zones;C.setGuide(am({body:N,walls:X,zones:k,vx:x.vx,vz:x.vz,dots:R.trajectoryDots}))}else C?.setGuide([])}}function Nv(){return{bodies:Ke([],De($t.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:It?{componentId:It.sourceId,pointerId:It.pointerId,power:It.power}:null,projected:Object.fromEntries(hn),fps:Object.fromEntries(Ke([],De(Vn),!1).map(function(c){var x=De(c,2),R=x[0],A=x[1];return[R,{x:A.x,y:A.y,z:A.z,yaw:A.yaw,pitch:A.pitch}]}))}}function uc(){en=void 0,gr(),le.clear(),Bn.clear(),la.clear(),Za.clear(),Ei.reset(),mr.clear(),sr.clear(),Dt=[],tn=[],Vr.clear(),D.clear(),E.clear(),we=[],ze=[],Ye=void 0,Re=0,Ae=!1,Ne=0,ne=Object.fromEntries(n.variables.map(function(c){return[c.id,c.initial]})),pn(),rr=0,Oe.clear(),Pe.clear(),fn.clear(),qi.clear(),$t.clear(),Et.clear(),hn.clear(),Vn.clear(),jt?.reset(),wi.clear(),gi.clear(),he=void 0,Te=[],fe=[],pe=[],He.clear(),ko(),ie.clear(),ae.clear(),de.clear(),Fe=[],_e=0,Ge=0,$e=0,wt=!1,ut=0,J=n.base.startScene,se=void 0,mn=void 0,an=void 0,W=void 0,f||(Oo(),rc(),rp(),lc(),ap(),ac(0,!1),Xd(),zd(0),Jt({kind:"sceneEnter",sceneId:J}))}function Gd(){var c,x;if(!(!_t||_t.state!=="running"||!Rt.size)){var R=Ke([],De(Rt.values()),!1);Rt.clear();try{for(var A=Ue(R),C=A.next();!C.done;C=A.next()){var N=C.value;dp(N)}}catch(P){c={error:P}}finally{try{C&&!C.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}}}function Hs(c){if(c===void 0&&(c=!1),!_t)return Promise.resolve(void 0);if(_t.state==="running")return Promise.resolve().then(Gd),Promise.resolve(_t);if(!ln||c){var x=_t,R=Promise.resolve().then(function(){return x.resume()}).then(function(){if(x.state==="running")return Gd(),x}).catch(function(){}).finally(function(){ln===R&&(ln=void 0)});ln=R}return ln}function Hd(){var c,x,R=Ke([],De(vt.values()),!1),A=R.some(function(V){return V.bus==="voice"}),C=R.some(function(V){return V.bus==="stinger"}),N=C?.2:A?.25:1;try{for(var P=Ue(R),X=P.next();!X.done;X=P.next()){var k=X.value,Z=k.volume*Yi*(k.bus==="music"?N:1);k.gain.gain.setTargetAtTime?k.gain.gain.setTargetAtTime(Z,_t.currentTime,.04):k.gain.gain.value=Z}}catch(V){c={error:V}}finally{try{X&&!X.done&&(x=P.return)&&x.call(P)}finally{if(c)throw c.error}}}function up(c,x,R){var A,C=(A=R.parameters.bus)!==null&&A!==void 0?A:"sfx";c.connect(x),x.connect(_t.destination),nt.add(c),vt.set(c,{gain:x,bus:C,volume:R.parameters.volume}),c.onended=function(){nt.delete(c),vt.delete(c),R.parameters.loop&&Be.delete(R.id),Hd()},Hd()}function dp(c){return $b(this,void 0,void 0,function(){var x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut;return Kb(this,function(at){switch(at.label){case 0:return nt.size>=32?[2]:_t?(x=_t,R=vi,A=(Ze=c.parameters.cooldownMs)!==null&&Ze!==void 0?Ze:45,C=x.currentTime,A>0&&C-((lt=cn.get(c.id))!==null&<!==void 0?lt:-1/0)<A/1e3?[2]:c.parameters.loop&&Be.has(c.id)?[2]:(N=S.get(c.componentId),P=B.get((Xe=N?.assetSlots[0])===null||Xe===void 0?void 0:Xe.assetId),X=P?.mime==="audio/wav"||P?.mime==="audio/mpeg",!X&&c.parameters.allowSynthFallback===!1?(rr++,[2]):(cn.set(c.id,C),k=x.state!=="running",k?[4,Hs()]:[3,2]))):(c.parameters.loop&&Rt.set(c.id,c),[2]);case 1:k=!at.sent(),at.label=2;case 2:if(k)return c.parameters.loop&&Rt.set(c.id,c),[2];if(_t!==x||x.state!=="running"||R!==vi||nt.size>=32)return[2];if(Z=(ht=dn.get(c.id))!==null&&ht!==void 0?ht:0,V=[0,-.5,.5,-1,1],$=((yt=c.parameters.pitchJitter)!==null&&yt!==void 0?yt:0)*V[Z%V.length],q=Number((Gt=ne[c.parameters.pitchVariableId])!==null&&Gt!==void 0?Gt:0),Q=Math.max(-12,Math.min(12,$+q*((Ut=c.parameters.pitchStep)!==null&&Ut!==void 0?Ut:0))),te=Math.pow(2,Q/12),dn.set(c.id,Z+1),!X)return[3,8];c.parameters.loop&&Be.add(c.id),at.label=3;case 3:if(at.trys.push([3,6,,7]),G=dt.get(P.hash),G)return[3,5];for(ce=atob(P.data),me=new Uint8Array(ce.length),ve=0;ve<ce.length;ve++)me[ve]=ce.charCodeAt(ve);return[4,new Promise(function(Wt,Mt){var mt=x.decodeAudioData(me.buffer,Wt,Mt);mt&&typeof mt.then=="function"&&mt.then(Wt,Mt)})];case 4:G=at.sent(),dt.set(P.hash,G),at.label=5;case 5:return _t!==x||x.state!=="running"||R!==vi||nt.size>=32?(c.parameters.loop&&R===vi&&Be.delete(c.id),[2]):(xe=x.createBufferSource(),oe=x.createGain(),xe.buffer=G,xe.loop=c.parameters.loop,xe.playbackRate&&(xe.playbackRate.value=te),oe.gain.value=c.parameters.volume,up(xe,oe,c),xe.start(),[3,7]);case 6:return be=at.sent(),Be.delete(c.id),Ai("Audio decode failed"),[3,7];case 7:return[2];case 8:return Ee=x.createOscillator(),Ie=x.createGain(),Ee.frequency.value=c.parameters.frequency*te,Ee.type="sine",Ie.gain.setValueAtTime(c.parameters.volume,x.currentTime),Ie.gain.exponentialRampToValueAtTime(.001,x.currentTime+c.parameters.seconds),up(Ee,Ie,c),Ee.start(),Ee.stop(x.currentTime+c.parameters.seconds),[2]}})})}function Uv(c,x){for(var R=Ke([],De(Dn.values()),!1).filter(function(V){return V.boardId===c}),A=function(V,$){var q;return(q=R.find(function(Q){return Q.row===V&&Q.column===$}))===null||q===void 0?void 0:q.group},C=function(V){for(var $=function(te){var G=A(V,te);if(G&&G===A(V,te+1)&&G===A(V,te+2)&&x.some(function(ce){return ce.row===V&&ce.column>=te&&ce.column<=te+2}))return{value:!0}},q=0;q<14;q++){var Q=$(q);if(typeof Q=="object")return Q}},N=0;N<16;N++){var P=C(N);if(typeof P=="object")return P.value}for(var X=function(V){for(var $=function(te){var G=A(te,V);if(G&&G===A(te+1,V)&&G===A(te+2,V)&&x.some(function(ce){return ce.column===V&&ce.row>=te&&ce.row<=te+2}))return{value:!0}},q=0;q<14;q++){var Q=$(q);if(typeof Q=="object")return Q}},k=0;k<16;k++){var Z=X(k);if(typeof Z=="object")return Z.value}return!1}function Fv(c){var x,R,A,C=Dn.get(c.id);if(!(!C||C.sceneId!==J||!Vt(c).enabled||!ii(c))){var N=xt.get(c.parentId);if(N){yn=N.select(c.id);return}if(yn===c.id){yn=void 0;return}var P=Dn.get(yn);if(!P||P.sceneId!==J||P.boardId!==C.boardId){yn=c.id;return}var X=S.get(yn);if(Math.abs(P.row-C.row)+Math.abs(P.column-C.column)!==1){yn=c.id;return}if(P.group===C.group){yn=void 0,Jt({kind:"invalidMatch",componentId:(x=c.parentId)!==null&&x!==void 0?x:c.id});return}var k=P.row,Z=P.column,V=C.row,$=C.column,q=Ke([],De(Di(X)),!1),Q=Ke([],De(Di(c)),!1);if(P.row=V,P.column=$,C.row=k,C.column=Z,Uv(C.boardId,[P,C])){var te=function(G,ce){var me,ve=(me=He.get(G.id))!==null&&me!==void 0?me:{transform:Ke([],De(Di(G)),!1),parameters:{}};ve.transform=Ke([],De(ve.transform),!1),ve.transform[4]=ce[4],ve.transform[5]=ce[5],He.set(G.id,ve)};te(X,Q),te(c,q),yn=void 0,Jt({kind:"validMatch",componentId:(R=c.parentId)!==null&&R!==void 0?R:c.id})}else P.row=k,P.column=Z,C.row=V,C.column=$,yn=void 0,Jt({kind:"invalidMatch",componentId:(A=c.parentId)!==null&&A!==void 0?A:c.id})}}function Wd(c){var x,R,A,C,N=[],P=zi(c,zn(c)),X=xi(c),k=An("drag",(A=c.prototypeId)!==null&&A!==void 0?A:c.id),Z=function(Q){var te,G,ce=S.get(Q.componentId),me=Q.parameters;if(ce.sceneId!==J)return"continue";var ve=function(Ee){if(Ee.id===c.id||Rr(Ee,c.id)||!ii(Ee))return"continue";var Ie=zi(Ee,zn(Ee)),Ze=xi(Ee),lt=Math.hypot(Ze.x-X.x,Ze.y-X.y),Xe=me.radiusPx>0?lt<=me.radiusPx:P.left<Ie.right&&P.right>Ie.left&&P.top<Ie.bottom&&P.bottom>Ie.top;if(!Xe)return"continue";N.push(gt({id:Ee.id,c:Ee,sourceId:ce.id,paintOrder:ue.findIndex(function(ht){return ht.c.id===Ee.id}),distance:lt,itemTarget:n.gameplay.some(function(ht){return ht.kind==="drag"&&ht.componentId===ce.id})},me))};try{for(var xe=(te=void 0,Ue(ci(ce))),oe=xe.next();!oe.done;oe=xe.next()){var be=oe.value;ve(be)}}catch(Ee){te={error:Ee}}finally{try{oe&&!oe.done&&(G=xe.return)&&G.call(xe)}finally{if(te)throw te.error}}};try{for(var V=Ue(n.gameplay.filter(function(Q){return Q.kind==="drop-zone"})),$=V.next();!$.done;$=V.next()){var q=$.value;Z(q)}}catch(Q){x={error:Q}}finally{try{$&&!$.done&&(R=V.return)&&R.call(V)}finally{if(x)throw x.error}}return{zones:N,tag:(C=k?.parameters.tag)!==null&&C!==void 0?C:""}}function Xd(c){var x,R,A=c?[c]:n.gameplay.filter(function($){return $.kind==="drag"}).flatMap(function($){return ci(S.get($.componentId))});try{for(var C=Ue(A),N=C.next();!N.done;N=C.next()){var P=N.value;if(!(!P||!ii(P)||Bn.zoneOf(P.id))){var X=Wd(P),k=X.zones,Z=X.tag,V=wc({itemId:P.id,tag:Z,zones:k.filter(function($){return!$.itemTarget}),occupancy:Bn});V?.kind==="accept"&&Bn.place(P.id,V.zone.id)}}}catch($){x={error:$}}finally{try{N&&!N.done&&(R=C.return)&&R.call(C)}finally{if(x)throw x.error}}}function bs(c,x,R){R===void 0&&(R=.18),c&&ar.to(c.id,xi(c),x,R)}function Yd(c,x,R,A){var C,N,P=A??R?.c;Jt(gt(gt({},pi(c,x,P,gt({},R?{otherId:R.sourceId}:{}))),{instanceId:(C=x.instanceId)!==null&&C!==void 0?C:(N=R?.c)===null||N===void 0?void 0:N.instanceId}))}function Ov(c){var x,R,A,C,N,P,X;if(!rt||rt.pointerId!==c.pointerId)return!1;var k=rt,Z=Le(k.targetId),V=k.b.parameters;rt=void 0,et=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,c.pointerId))}catch{}if(!Z)return!0;var $=Wd(Z),q=$.zones,Q=$.tag,te=wc({itemId:Z.id,tag:Q,zones:q,occupancy:Bn}),G=k.origin,ce=k.originZone;if(!te)return Yd("dragReject",Z,void 0,void 0),V.snapBack&&(ce&&Bn.place(Z.id,ce),bs(Z,G,(A=V.snapBackSeconds)!==null&&A!==void 0?A:.18)),!0;var me=te.zone,ve=te.occupantId?Le(te.occupantId):void 0;return te.kind==="reject"?(Yd("dragReject",Z,me,ve),V.snapBack&&(ce&&Bn.place(Z.id,ce),bs(Z,G,(C=V.snapBackSeconds)!==null&&C!==void 0?C:.18)),!0):(te.kind==="accept"?(Bn.place(Z.id,me.id),me.snapMode==="center"&&bs(Z,xi(me.c),(N=V.snapBackSeconds)!==null&&N!==void 0?N:.18)):te.kind==="swap"&&ve&&(Bn.place(Z.id,me.id),ce?Bn.place(ve.id,ce):Bn.release(ve.id),bs(Z,xi(me.c),(P=V.snapBackSeconds)!==null&&P!==void 0?P:.18),bs(ve,G,(X=V.snapBackSeconds)!==null&&X!==void 0?X:.18)),Yd("dragDrop",Z,me,te.kind==="accept"?me.c:ve),!0)}function Bv(c){var x,R,A,C,N;ar.tick(c,function(te,G){var ce=Le(te);ce&&ua(ce,G.x,G.y)});try{for(var P=Ue(Ke([],De(Bn.itemZone.keys()),!1)),X=P.next();!X.done;X=P.next()){var k=X.value,Z=Le(k);(!Z||!ii(Z))&&Bn.release(k)}}catch(te){x={error:te}}finally{try{X&&!X.done&&(R=P.return)&&R.call(P)}finally{if(x)throw x.error}}if(ke)try{for(var V=Ue(ke.holds),$=V.next();!$.done;$=V.next()){var q=$.value,Q=q.charge.tick(c);Q!==ne[q.behavior.parameters.variableId]&&(ne[q.behavior.parameters.variableId]=Q,Jt({kind:"variableChange",variableId:q.behavior.parameters.variableId,instanceId:q.c.instanceId,selfInstanceId:(N=q.c.instanceId)!==null&&N!==void 0?N:q.c.id}))}}catch(te){A={error:te}}finally{try{$&&!$.done&&(C=V.return)&&C.call(V)}finally{if(A)throw A.error}}}function fp(c,x){var R,A,C,N,P=x.targetMode;if(P==="pointer")return gt({},Je);if(P==="component"){var X=Le(x.targetComponentId);return X?xi(X):void 0}if(P==="nearest-team"){var k=xi(c),Z=[],V=x.team,$=(C=x.maxRangePx)!==null&&C!==void 0?C:0;try{for(var q=Ue(Ei.states),Q=q.next();!Q.done;Q=q.next()){var te=De(Q.value,2),G=te[0],ce=te[1],X=Le(G);X&&ii(X)&&Z.push(gt(gt({id:G},xi(X)),{team:ce.team}))}}catch(me){R={error:me}}finally{try{Q&&!Q.done&&(A=q.return)&&A.call(q)}finally{if(R)throw R.error}}return Vp(k,Z,V,$,(N=c.instanceId)!==null&&N!==void 0?N:c.id)}}function kv(c){var x,R,A,C,N;try{for(var P=Ue(n.gameplay.filter(function(be){return be.kind==="steer"})),X=P.next();!X.done;X=P.next()){var k=X.value,Z=S.get(k.componentId),V=k.parameters;if(Z.sceneId===J)try{for(var $=(A=void 0,Ue(ci(Z))),q=$.next();!q.done;q=$.next()){var Q=q.value;if(ii(Q)){var te=fp(Q,V);if(te){var G=xi(Q),ce=te.x-G.x,me=te.y-G.y;if(!(V.maxRangePx>0&&Math.hypot(ce,me)>V.maxRangePx)){var ve=Math.atan2(me,ce);V.mode==="flee"?ve+=Math.PI:V.mode==="orbit"&&(ve+=Math.PI/2);var xe=(N=Ei.headings.get(Q.id))!==null&&N!==void 0?N:ve,oe=Gp(xe,ve,V.turnRateDegPerSec*Math.PI/180*c);Ei.headings.set(Q.id,oe),ua(Q,G.x+Math.cos(oe)*V.speed*c,G.y+Math.sin(oe)*V.speed*c),V.orientToVelocity!==!1&&Gs(Q,oe)}}}}}catch(be){A={error:be}}finally{try{q&&!q.done&&(C=$.return)&&C.call($)}finally{if(A)throw A.error}}}}catch(be){x={error:be}}finally{try{X&&!X.done&&(R=P.return)&&R.call(P)}finally{if(x)throw x.error}}}function qd(c,x,R,A){var C;if(Te.length>=128){Ai("Instance budget exhausted");return}var N=S.get(c),P=function(V){return 1+n.components.filter(function($){return $.parentId===V}).reduce(function($,q){return $+P(q.id)},0)};if(Oe.size+P(N.id)>4096){Ai("Runtime node budget exhausted");return}var X="instance."+ ++$e;function k(V,$){var q,Q,te=V.id===N.id?X:X+":"+V.id,G=gt(gt({},V),{id:te,runtimeId:te,instanceId:X,prototypeId:V.id,prototype:!1,parentId:$,transform:Ke([],De(V.transform),!1),spawnTime:_e});Oe.set(te,G);try{for(var ce=Ue(n.components.filter(function(xe){return xe.parentId===V.id})),me=ce.next();!me.done;me=ce.next()){var ve=me.value;k(ve,te)}}catch(xe){q={error:xe}}finally{try{me&&!me.done&&(Q=ce.return)&&Q.call(ce)}finally{if(q)throw q.error}}return G}var Z=k(N,void 0);return Z.transform[4]=x,Z.transform[5]=R,A&&(Z.pathStartNode=A.startNode,Z.pathTargetNode=A.targetNode,Z.parentId=(C=n.gameplay.find(function(V){return V.id===A.networkBehaviorId}))===null||C===void 0?void 0:C.componentId),Te.push(Z),Ms(Z),Xd(Z),A&&ac(0,!1),Z}function zv(c,x,R){var A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut,at,Wt,Mt,mt;if(++Zt>1024){Ai("Action budget exhausted");return}if(c.kind==="add"||c.kind==="set"){var Qe=ne[c.variableId],st=c.kind==="add"?Qe+c.value:c.value;if(typeof st=="number"&&(!Number.isFinite(st)||Math.abs(st)>1e12)){Ai("Variable range exceeded");return}ne[c.variableId]=st,Qe!==st&&Jt({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="setComponent"||c.kind==="setAsset"){var We=Le(c.componentId);if(!We)return;var tt=($=He.get(We.id))!==null&&$!==void 0?$:{transform:Ke([],De(We.transform),!1),parameters:{}};c.kind==="setComponent"?tt.parameters[c.key]=c.valueVariableId?ne[c.valueVariableId]:c.value:tt.assetId=c.assetId,He.set(We.id,tt),c.kind==="setComponent"&&c.key==="visible"&&c.value===!1&&(Bn.release(We.id),ar.cancel(We.id))}else if(c.kind==="resetMatch")ko(c.componentId),rc(c.componentId);else if(c.kind==="clearStrokes")(q=sr.get(c.componentId))===null||q===void 0||q.clear(),Dt=Dt.filter(function(On){return On.owner!==c.componentId});else if(c.kind==="resetMask"){var We=Le(c.componentId),St=An("erase-mask",c.componentId);We&&St&&zo(We,St).reset()}else if(c.kind==="raycast3d")Dv(c);else if(c.kind==="spawnAt3d")for(var Ct=Math.max(1,Math.min(16,Math.floor((Q=c.count)!==null&&Q!==void 0?Q:1))),Pt=0;Pt<Ct;Pt++){var Nt=c.jitterX?(Ei.rng.next()*2-1)*c.jitterX:0,Yt=c.jitterZ?(Ei.rng.next()*2-1)*c.jitterZ:0;Lv(c.prototypeId,c.x+Nt,c.y,c.z+Yt)}else if(c.kind==="copyMatchAsset"){var Bt=(te=xt.get(c.boardId))===null||te===void 0?void 0:te.snapshot().lastMatch,it=S.get(c.componentId),Ft=Bt&&((ce=(G=ni.get(c.boardId))===null||G===void 0?void 0:G.get(Bt.group))===null||ce===void 0?void 0:ce.children.find(function(On){return On.contract==="native.image.v1"}));if(Bt&&Ft){var Cn=S.get(Bt.from),bn=In(zn(Cn),Cn.parameters.width/2,Cn.parameters.height/2),_i=it.parentId?zn(S.get(it.parentId)):ga(),ri=In(wr(_i),bn.x,bn.y),wn=(me=He.get(it.id))!==null&&me!==void 0?me:{transform:Ke([],De(it.transform),!1),parameters:{}};wn.transform=Ke([],De(wn.transform),!1),wn.transform[4]=ri.x-it.parameters.width/2,wn.transform[5]=ri.y-it.parameters.height/2,wn.assetId=(ve=Ft.assetSlots[0])===null||ve===void 0?void 0:ve.assetId,He.set(it.id,wn)}}else if(c.kind==="hintMatch")yn=void 0,(xe=xt.get(c.componentId))===null||xe===void 0||xe.showHint();else if(c.kind==="spawn")qd(c.prototypeId,c.x,c.y);else if(c.kind==="spawnAt"){var Rn=(c.at==="self"||c.at==="midpoint")&&(x.selfInstanceId!==void 0||x.instanceId!==void 0)?Le((oe=x.selfInstanceId)!==null&&oe!==void 0?oe:x.instanceId):Ss(c.targetComponentId,x,"self"),Hn=(c.at==="other"||c.at==="midpoint")&&x.otherInstanceId!==void 0?Le(x.otherInstanceId):void 0,it=c.at==="other"?Hn:Rn;if(c.at==="pointer"||(c.at==="midpoint"?Rn&&Hn:it))for(var si=Rn?xi(Rn):void 0,ai=Hn?xi(Hn):void 0,bn=c.at==="pointer"?Je:c.at==="midpoint"?{x:(si.x+ai.x)/2,y:(si.y+ai.y)/2}:xi(it),qn=S.get(c.prototypeId),Ct=Math.max(0,Math.min(16,Math.floor(c.countVariableId?Number(ne[c.countVariableId]):(be=c.count)!==null&&be!==void 0?be:1))),Pt=0;Pt<Ct;Pt++){var Kr=c.jitterX?(Ei.rng.next()*2-1)*c.jitterX:0,Gr=c.jitterY?(Ei.rng.next()*2-1)*c.jitterY:0;qd(c.prototypeId,bn.x+c.offsetX+Kr-qn.parameters.width/2,bn.y+c.offsetY+Gr-qn.parameters.height/2)}}else if(c.kind==="random"){var Qe=ne[c.variableId],st=Ei.rng.between(c.min,c.max,c.integer===!0);ne[c.variableId]=st,Qe!==st&&Jt({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="modifyInstanceState"){var We=c.target==="component"?Le(c.componentId):Ss(c.componentId,x,c.target);We&&Bo(We,c.field,c.op,c.variableId?ne[c.variableId]:c.value)}else if(c.kind==="launchToward"){var Cn=S.get(c.componentId),Ii=ci(Cn),Pn=(Ee=x.selfInstanceId)!==null&&Ee!==void 0?Ee:x.instanceId,We=Cn.prototype?(Ie=Ii.find(function(on){return on.instanceId===Pn||on.id===Pn}))!==null&&Ie!==void 0?Ie:Ii[Ii.length-1]:(Ze=Ss(c.componentId,x,"self"))!==null&&Ze!==void 0?Ze:Le(c.componentId),St=An("physics-body",c.componentId),Ht=We&&$a(We,St);if(!Ht)return;var Lt=void 0;if(c.targetMode==="angle-variable")Lt=Number(ne[c.angleVariableId])*Math.PI/180;else{var it=fp(We,c);if(!it)return;var bn=xi(We);Lt=Math.atan2(it.y-bn.y,it.x-bn.x)}var oi=Number(c.speedVariableId?ne[c.speedVariableId]:c.speed);if(!Number.isFinite(oi)){Ai("Launch speed invalid");return}Ht.vx=Math.cos(Lt)*oi,Ht.vy=Math.sin(Lt)*oi,Ht.atRest=!1,Ht.restElapsed=0,Ht.captured=!1,Ht.exited=!1,c.orientToVelocity!==!1&&Gs(We,Lt),Jt(pi("launch",We))}else if(c.kind==="moveToComponent"){var $i=S.get(c.targetComponentId),We=Ss(c.componentId,x,(lt=c.target)!==null&<!==void 0?lt:"self"),it=$i&&ki($i)?(Xe=Ss(c.targetComponentId,x,c.target==="other"?"self":"other"))!==null&&Xe!==void 0?Xe:ci($i)[0]:Le(c.targetComponentId);We&&it&&bs(We,xi(it),c.seconds)}else if(c.kind==="returnToOrigin"){var We=Ss(c.componentId,x,"self"),_r=We&&la.get(We.id);We&&_r&&bs(We,_r,c.seconds)}else if(c.kind==="spawnOnPath")qd(c.prototypeId,0,0,{startNode:c.startNode,targetNode:c.targetNode,networkBehaviorId:c.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(c.kind)){var Hr=S.get(c.componentId),Nn=x.instanceId?Ke([],De(Oe.values()),!1).filter(function(xn){return xn.instanceId===x.instanceId&&xn.prototypeId===Hr.id}):ci(Hr),St=An("physics-body",Hr.id);try{for(var cr=Ue(Nn),Pr=cr.next();!Pr.done;Pr=cr.next()){var We=Pr.value,Ht=$a(We,St);c.kind==="setVelocity"?(Ht.vx=c.vxVariableId?ne[c.vxVariableId]:c.vx,Ht.vy=c.vyVariableId?ne[c.vyVariableId]:c.vy):c.kind==="applyImpulse"?(Ht.vx+=c.vxVariableId?ne[c.vxVariableId]:c.ix,Ht.vy+=c.vyVariableId?ne[c.vyVariableId]:c.iy):(Ht.vx=0,Ht.vy=0,Ht.atRest=!0),Ht.captured=!1,Ht.exited=!1,Ht.restElapsed=0,c.kind!=="stopBody"&&(Ht.atRest=!1)}}catch(xn){A={error:xn}}finally{try{Pr&&!Pr.done&&(C=cr.return)&&C.call(cr)}finally{if(A)throw A.error}}}else if(c.kind==="setPosition"){var Qa=S.get(c.componentId),Nn=x.instanceId?Ke([],De(Oe.values()),!1).filter(function(Kt){return Kt.instanceId===x.instanceId&&Kt.prototypeId===Qa.id}):ci(Qa),St=An("physics-body",Qa.id);try{for(var Lr=Ue(Nn),ur=Lr.next();!ur.done;ur=Lr.next()){var We=ur.value,Ht=$a(We,St);Ht.x=c.xVariableId?ne[c.xVariableId]:c.x,Ht.y=c.yVariableId?ne[c.yVariableId]:c.y,Ht.vx=0,Ht.vy=0,Ht.captured=!1,Ht.exited=!1,Ht.atRest=!0,ua(We,Ht.x,Ht.y)}}catch(Kt){N={error:Kt}}finally{try{ur&&!ur.done&&(P=Lr.return)&&P.call(Lr)}finally{if(N)throw N.error}}}else if(c.kind==="setPathEdge")(ht=bi.get(c.behaviorId))===null||ht===void 0||ht.setEdge(c.edgeId,c.enabled,c.cost);else if(c.kind==="setPathGate")(Gt=bi.get((yt=n.gameplay.find(function(On){return On.id===c.behaviorId}))===null||yt===void 0?void 0:yt.parameters.networkBehaviorId))===null||Gt===void 0||Gt.setGate(c.behaviorId,c.mode,c.holdSeconds);else if(c.kind==="setPathTarget"){var da=S.get(c.componentId),St=An("path-agent",da.id),dr=bi.get(St.parameters.networkBehaviorId);try{for(var fa=Ue(x.instanceId?Ke([],De(Oe.values()),!1).filter(function(xn){return xn.instanceId===x.instanceId&&xn.prototypeId===da.id}):ci(da)),Vi=fa.next();!Vi.done;Vi=fa.next()){var We=Vi.value;We.pathTargetNode=c.targetNode,dr?.setTarget(We.id,c.targetNode)}}catch(xn){X={error:xn}}finally{try{Vi&&!Vi.done&&(k=fa.return)&&k.call(fa)}finally{if(X)throw X.error}}}else if(c.kind==="compute"){var Mi=Number(ne[c.variableId]),ui=c.operandVariableId!==void 0?Number(ne[c.operandVariableId]):c.value;if(["div","mod"].includes(c.op)&&ui===0){Ai("Division by zero");return}var st={add:function(){return Mi+ui},sub:function(){return Mi-ui},mul:function(){return Mi*ui},div:function(){return ui===0?Mi:Mi/ui},mod:function(){return ui===0?Mi:Mi%ui},min:function(){return Math.min(Mi,ui)},max:function(){return Math.max(Mi,ui)},set:function(){return ui},floor:function(){return Math.floor(Mi)},ceil:function(){return Math.ceil(Mi)},abs:function(){return Math.abs(Mi)},clamp:function(){return Math.max(c.min,Math.min(c.max,Mi))}}[c.op]();if(c.round&&(st=Math.round(st)),!Number.isFinite(st)||Math.abs(st)>1e12){Ai("Variable range exceeded");return}var Qe=ne[c.variableId];ne[c.variableId]=st,Qe!==st&&Jt({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="despawn"){var Rn=(Ut=x.selfInstanceId)!==null&&Ut!==void 0?Ut:x.instanceId;c.target==="other"?kn(x.otherInstanceId):c.target==="both"?(kn(Rn),kn(x.otherInstanceId)):kn(Rn)}else if(c.kind==="changeScene")W=c.sceneId;else if(c.kind==="restart")(at=_?.notifyGameRetry)===null||at===void 0||at.call(_),W="__restart";else if(c.kind==="cameraShake")U?.matches||(Ye={intensity:c.intensity,seconds:c.seconds,elapsed:0});else if(c.kind==="screenFlash")ze.push({color:c.color,opacity:c.opacity,seconds:c.seconds,elapsed:0}),ze.length>8&&ze.shift();else if(c.kind==="floatingText"){var Da=S.get(c.componentId),Cn=x.instanceId?(Wt=Ke([],De(Oe.values()),!1).find(function(Kt){return Kt.instanceId===x.instanceId&&Kt.prototypeId===c.componentId}))!==null&&Wt!==void 0?Wt:Da:(Mt=Le(c.componentId))!==null&&Mt!==void 0?Mt:Da,it=Cn?.sceneId===J?Cn:Da;if(it){var bn=void 0;if(it.contract==="native.mesh3d.v1"&&(bn=Vd(it.id)),!bn){var Si=Vt(it);bn=In(zn(it),Si.width/2,Si.height/2)}we.push({x:bn.x,y:bn.y,text:c.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(on,Wr){var Ni;return String((Ni=ne[Wr])!==null&&Ni!==void 0?Ni:"")}),color:c.color,fontSize:c.fontSize,risePx:c.risePx,seconds:c.seconds,elapsed:0}),we.length>32&&we.shift()}}else if(c.kind==="store")x.kind==="click"&&x.pointerId!==void 0&&!ye&&(ye={pointerId:x.pointerId,targetId:x.targetId,condition:R},(mt=e.setPointerCapture)===null||mt===void 0||mt.call(e,x.pointerId));else if(c.behaviorId){var Kn=n.gameplay.find(function(On){return On.id===c.behaviorId});if(c.kind==="playAudio")dp(Kn);else if(c.kind==="animate"){var Un=S.get(Kn.componentId),Nn=ki(Un)?Ke([],De(Oe.values()),!1).filter(function(xn){return xn.prototypeId===Un.id&&(!x.instanceId||xn.instanceId===x.instanceId)}):[Un],ha=function(xn){var Kt=Kn.id+":"+xn.id;pe=pe.filter(function(Wr){return Wr.id!==Kt});var on=gt({},Kn.parameters);on.fromCurrent&&(on.from=on.property==="opacity"?Vt(xn).opacity:Di(xn)[on.property==="x"?4:5]),pe.push(gt(gt({},Kn),{parameters:on,id:Kt,behaviorId:Kn.id,targetId:xn.id,elapsed:0,baseTransform:Ke([],De(xn.transform),!1)}))};try{for(var fr=Ue(Nn),Mr=fr.next();!Mr.done;Mr=fr.next()){var it=Mr.value;ha(it)}}catch(xn){Z={error:xn}}finally{try{Mr&&!Mr.done&&(V=fr.return)&&V.call(fr)}finally{if(Z)throw Z.error}}}else c.kind==="stopAnimation"?pe=pe.filter(function(On){return On.behaviorId!==Kn.id}):c.kind==="emit"&&Vv(Kn,x)}}function Vv(c,x){var R,A,C,N,P,X,k=c.parameters,Z=k.shape==="pixel-confetti",V=k.shape==="confetti",$=Z||V;if(!($&&U?.matches)){if(fe.length+k.count>256){Ai("Particle budget exhausted");return}if(Z&&k.coverage==="screen"){fe.push.apply(fe,Ke([],De(uv(k)),!1));return}if(V&&k.coverage==="screen"){fe.push.apply(fe,Ke([],De(fv(k)),!1));return}for(var q=S.get(c.componentId),Q=x.instanceId&&(R=Ke([],De(Oe.values()),!1).find(function(Ee){return Ee.instanceId===x.instanceId&&Ee.prototypeId===q.id}))!==null&&R!==void 0?R:q,te=Di(Q),G,ce=Le(Q.parentId);ce;ce=Le(ce.parentId)){if($&&ce.contract==="native.group.v1"&&Vt(ce).clip){G=ce.id;break}te=qs(Di(ce),te)}var me=Vt(Q),ve=k.origin==="anchor"?In(te,0,0):$||k.origin==="center"?In(te,me.width/2,me.height/2):{x:te[4]+Q.parameters.width/2,y:te[5]+Q.parameters.height/2};if(Z){fe.push.apply(fe,Ke([],De(Jh(k,ve,G)),!1));return}if(V){fe.push.apply(fe,Ke([],De($h(k,ve,G)),!1));return}for(var xe=0;xe<k.count;xe++){var oe=((A=k.spread)!==null&&A!==void 0?A:360)===360?xe*2.399963:-Math.PI/2+((xe+.5)/k.count-.5)*((C=k.spread)!==null&&C!==void 0?C:360)*Math.PI/180,be=k.speed*(.5+xe%7/14);fe.push(gt(gt({},ve),{vx:Math.cos(oe)*be,vy:Math.sin(oe)*be,life:(N=k.lifetime)!==null&&N!==void 0?N:.7,gravity:(P=k.gravity)!==null&&P!==void 0?P:250,color:k.color,shape:(X=k.shape)!==null&&X!==void 0?X:"circle"}))}}}function xr(){for(var c=function(){var x,R,A,C,N,P,X=Fe.shift();Tt++;var k=function(oe){return oe===void 0||!!Le(oe)||Ke([],De(Oe.values()),!1).some(function(be){return be.instanceId===oe})};if(!k(X.selfInstanceId)||!k(X.otherInstanceId)||["contactBegin","boundaryExit"].includes(X.kind)&&X.instanceId&&!Oe.has(X.instanceId))return"continue";try{for(var Z=(x=void 0,Ue(n.eventBindings)),V=Z.next();!V.done;V=Z.next()){var $=V.value;if(Object.entries(I.get($.eventId)).every(function(oe){var be=De(oe,2),Ee=be[0],Ie=be[1];return Ee==="id"||X[Ee]===Ie})&&Ja($.condition,X)){try{for(var q=(A=void 0,Ue($.actions)),Q=q.next();!Q.done;Q=q.next()){var te=Q.value;if(Zt>=1024||wt)break;zv(te,X,$.condition)}}catch(oe){A={error:oe}}finally{try{Q&&!Q.done&&(C=q.return)&&C.call(q)}finally{if(A)throw A.error}}if(W)break}}}catch(oe){x={error:oe}}finally{try{V&&!V.done&&(R=Z.return)&&R.call(Z)}finally{if(x)throw x.error}}if(W){var G=W;if(W=void 0,G==="__restart")uc();else if(G!==J){var ce=J;pn(),J=G,le.clear(),Bn.clear(),la.clear(),Za.clear(),mr.clear(),sr.clear(),Dt=[],tn=[],Vr.clear(),D.clear(),yn=void 0,Te=[],fe=[],we=[],ze=[],Ye=void 0,Ae=!1,Ne=0,Oe.clear(),fn.clear(),qi.clear(),$t.clear(),Et.clear(),hn.clear(),Vn.clear(),jt?.reset(),wi.clear(),gi.clear(),he=void 0,rp(),Fe=Fe.filter(function(oe){return oe.kind==="variableChange"}),He.clear(),En=void 0;try{for(var me=(N=void 0,Ue(xt.values())),ve=me.next();!ve.done;ve=me.next()){var xe=ve.value;xe.reset()}}catch(oe){N={error:oe}}finally{try{ve&&!ve.done&&(P=me.return)&&P.call(me)}finally{if(N)throw N.error}}ae.clear(),de.clear(),ie.clear(),pe=[],gr(),E.clear(),se=void 0,mn=void 0,lc(),ap(),ac(0,!1),Xd(),zd(0),Jt({kind:"sceneExit",sceneId:ce}),Jt({kind:"sceneEnter",sceneId:J})}}};Fe.length&&!wt&&Tt<256&&Zt<1024;)c();Fe.length&&Ai("Event/action budget exhausted")}function zn(c){return qs(c.parentId?zn(Le(c.parentId)):ga(),Di(c))}var In=function(c,x,R){return{x:c[0]*x+c[2]*R+c[4],y:c[1]*x+c[3]*R+c[5]}};function zi(c,x){var R=Vt(c),A=[[0,0],[R.width,0],[R.width,R.height],[0,R.height]].map(function(C){var N=De(C,2),P=N[0],X=N[1];return In(x,P,X)});return{left:Math.min.apply(Math,Ke([],De(A.map(function(C){return C.x})),!1)),right:Math.max.apply(Math,Ke([],De(A.map(function(C){return C.x})),!1)),top:Math.min.apply(Math,Ke([],De(A.map(function(C){return C.y})),!1)),bottom:Math.max.apply(Math,Ke([],De(A.map(function(C){return C.y})),!1))}}function ii(c){return Vt(c).visible&&Vt(c).opacity>0&&(!c.parentId||ii(Le(c.parentId)))}function hp(c,x){for(var R=Vt(c),A=zn(c),C=Math.min(R.width,R.height)/2,N=x==="circle"?Array.from({length:32},function(k,Z){return In(A,R.width/2+Math.cos(Z*Math.PI/16)*C,R.height/2+Math.sin(Z*Math.PI/16)*C)}):[[0,0],[R.width,0],[R.width,R.height],[0,R.height]].map(function(k){var Z=De(k,2),V=Z[0],$=Z[1];return In(A,V,$)}),P=c.parentId?Le(c.parentId):void 0,X=function(){var k=Vt(P);if(P.contract==="native.group.v1"&&k.clip){for(var Z=zn(P),V=[[0,0],[k.width,0],[k.width,k.height],[0,k.height]].map(function(G){var ce=De(G,2),me=ce[0],ve=ce[1];return In(Z,me,ve)}),$=0,q=0;q<4;q++)$+=V[q].x*V[(q+1)%4].y-V[(q+1)%4].x*V[q].y;for(var Q=$>=0?1:-1,te=function(G){var ce,me,ve=V[G],xe=V[(G+1)%4],oe=function(Gt){return Q*((xe.x-ve.x)*(Gt.y-ve.y)-(xe.y-ve.y)*(Gt.x-ve.x))},be=N;N=[];var Ee=be[be.length-1],Ie=oe(Ee);try{for(var Ze=(ce=void 0,Ue(be)),lt=Ze.next();!lt.done;lt=Ze.next()){var Xe=lt.value,ht=oe(Xe);if(ht>=0!=Ie>=0){var yt=Ie/(Ie-ht);N.push({x:Ee.x+(Xe.x-Ee.x)*yt,y:Ee.y+(Xe.y-Ee.y)*yt})}ht>=0&&N.push(Xe),Ee=Xe,Ie=ht}}catch(Gt){ce={error:Gt}}finally{try{lt&&!lt.done&&(me=Ze.return)&&me.call(Ze)}finally{if(ce)throw ce.error}}},q=0;q<4&&N.length;q++)te(q)}P=P.parentId?Le(P.parentId):void 0};P;)X();return N}function Gv(c,x){var R,A,C,N,P,X;if(c.length<3||x.length<3)return!1;try{for(var k=Ue([c,x]),Z=k.next();!Z.done;Z=k.next())for(var V=Z.value,$=0;$<V.length;$++){var q=V[$],Q=V[($+1)%V.length],te=q.y-Q.y,G=Q.x-q.x,ce=1/0,me=-1/0,ve=1/0,xe=-1/0;try{for(var oe=(C=void 0,Ue(c)),be=oe.next();!be.done;be=oe.next()){var Ee=be.value,Ie=Ee.x*te+Ee.y*G;ce=Math.min(ce,Ie),me=Math.max(me,Ie)}}catch(Xe){C={error:Xe}}finally{try{be&&!be.done&&(N=oe.return)&&N.call(oe)}finally{if(C)throw C.error}}try{for(var Ze=(P=void 0,Ue(x)),lt=Ze.next();!lt.done;lt=Ze.next()){var Ee=lt.value,Ie=Ee.x*te+Ee.y*G;ve=Math.min(ve,Ie),xe=Math.max(xe,Ie)}}catch(Xe){P={error:Xe}}finally{try{lt&&!lt.done&&(X=Ze.return)&&X.call(Ze)}finally{if(P)throw P.error}}if(me<ve||xe<ce)return!1}}catch(Xe){R={error:Xe}}finally{try{Z&&!Z.done&&(A=k.return)&&A.call(k)}finally{if(R)throw R.error}}return!0}function Hv(c){var x,R,A,C,N=O();try{for(var P=Ue(le.values()),X=P.next();!X.done;X=P.next()){var k=X.value,Z=k.behavior.parameters;if(!(!Z.moveComponentId||k.magnitude<=0)){var V=Le(Z.moveComponentId);if(!(!V||!ii(V))){var $=(A=Z.moveSpeed)!==null&&A!==void 0?A:220,q=An("physics-body",(C=V.prototypeId)!==null&&C!==void 0?C:V.id);if(q&&q.parameters.mode==="dynamic"){var Q=$a(V,q);Q.vx=k.nx*$,Q.vy=k.ny*$,Q.atRest=!1,Q.restElapsed=0}else{var te=xi(V),G=Vt(V),ce=te.x+k.nx*$*c,me=te.y+k.ny*$*c;mp(V)||(ce=Math.max(G.width/2,Math.min(N.width-G.width/2,ce)),me=Math.max(G.height/2,Math.min(N.height-G.height/2,me))),ua(V,ce,me)}Z.orientToMove&&Gs(V,Math.atan2(k.ny,k.nx))}}}}catch(ve){x={error:ve}}finally{try{X&&!X.done&&(R=P.return)&&R.call(P)}finally{if(x)throw x.error}}}function pp(c){var x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut,at,Wt,Mt=O();_e+=c,ig(c),Bv(c),Hv(c),kv(c),Iv();try{for(var mt=Ue(Fn),Qe=mt.next();!Qe.done;Qe=mt.next()){var st=De(Qe.value,2),We=st[0],tt=st[1];!tt.held&&_e-((Ie=tt.releasedAt)!==null&&Ie!==void 0?Ie:_e)>=tt.behavior.springBackSeconds&&Fn.delete(We)}}catch(Xt){x={error:Xt}}finally{try{Qe&&!Qe.done&&(R=mt.return)&&R.call(mt)}finally{if(x)throw x.error}}Ye&&(Ye.elapsed+=c,Ye.elapsed>=Ye.seconds&&(Ye=void 0));try{for(var St=Ue(ze),Ct=St.next();!Ct.done;Ct=St.next()){var Pt=Ct.value;Pt.elapsed+=c}}catch(Xt){A={error:Xt}}finally{try{Ct&&!Ct.done&&(C=St.return)&&C.call(St)}finally{if(A)throw A.error}}ze=ze.filter(function(Xt){return Xt.elapsed<Xt.seconds});try{for(var Nt=Ue(we),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Bt=Yt.value;Bt.elapsed+=c}}catch(Xt){N={error:Xt}}finally{try{Yt&&!Yt.done&&(P=Nt.return)&&P.call(Nt)}finally{if(N)throw N.error}}we=we.filter(function(Xt){return Xt.elapsed<Xt.seconds});try{for(var it=Ue(xt),Ft=it.next();!Ft.done;Ft=it.next()){var Cn=De(Ft.value,2),We=Cn[0],bn=Cn[1];S.get(We).sceneId===J&&ii(S.get(We))&&bn.tick(c)}}catch(Xt){X={error:Xt}}finally{try{Ft&&!Ft.done&&(k=it.return)&&k.call(it)}finally{if(X)throw X.error}}var _i=function(Xt){var Wn,Ui,Zn=S.get(Xt.componentId);if(Zn.sceneId!==J)return"continue";var br=ki(Zn)?Ke([],De(Oe.values()),!1).filter(function(Xo){return Xo.prototypeId===Zn.id}):[Zn];try{for(var Gn=(Wn=void 0,Ue(br)),Fi=Gn.next();!Fi.done;Fi=Gn.next()){var Gi=Fi.value,Na=Xt.id+":"+Gi.id;if(Xt.kind==="motion"){var Ki=(Ze=He.get(Gi.id))!==null&&Ze!==void 0?Ze:{transform:Ke([],De(Gi.transform),!1),parameters:{}},pa=(lt=Ki.velocity)!==null&<!==void 0?lt:{x:Xt.parameters.vx,y:Xt.parameters.vy};pa.y+=Xt.parameters.gravity*c,Ki.transform[4]+=pa.x*c,Ki.transform[5]+=pa.y*c,Ki.velocity=pa,He.set(Gi.id,Ki),Gi.prototypeId&&(Gi.transform=Ki.transform);var Xs=zn(Gi);(Xs[5]>Mt.height||Xs[4]<-300||Xs[4]>Mt.width+300)&&(Ki.exited||(Ki.exited=!0,Jt({kind:"boundaryExit",componentId:Zn.id,instanceId:Gi.instanceId})))}else if(Xt.kind==="timer"){var es=((Xe=ie.get(Na))!==null&&Xe!==void 0?Xe:0)+c;ie.set(Na,es),es>=Xt.parameters.seconds&&es-c<Xt.parameters.seconds&&(Jt({kind:"timer",behaviorId:Xt.id,componentId:Zn.id}),Xt.parameters.repeat&&ie.set(Na,es-Xt.parameters.seconds))}}}catch(Xo){Wn={error:Xo}}finally{try{Fi&&!Fi.done&&(Ui=Gn.return)&&Ui.call(Gn)}finally{if(Wn)throw Wn.error}}};try{for(var ri=Ue(n.gameplay),wn=ri.next();!wn.done;wn=ri.next()){var Rn=wn.value;_i(Rn)}}catch(Xt){Z={error:Xt}}finally{try{wn&&!wn.done&&(V=ri.return)&&V.call(ri)}finally{if(Z)throw Z.error}}Av(c),Rv(c),ac(c),zd(c);var Hn=[],si=function(Xt){var Wn,Ui,Zn=S.get(Xt.componentId);if(Zn.sceneId!==J)return"continue";try{for(var br=(Wn=void 0,Ue(ki(Zn)?Ke([],De(Oe.values()),!1).filter(function(Gi){return Gi.prototypeId===Zn.id}):[Zn])),Gn=br.next();!Gn.done;Gn=br.next()){var Fi=Gn.value;if(ii(Fi)){if(Hn.length>=256){Ai("Collider budget exhausted");break}Hn.push({b:Xt,c:Fi,box:zi(Fi,zn(Fi)),polygon:hp(Fi,Xt.parameters.shape)})}}}catch(Gi){Wn={error:Gi}}finally{try{Gn&&!Gn.done&&(Ui=br.return)&&Ui.call(br)}finally{if(Wn)throw Wn.error}}};try{for(var ai=Ue(n.gameplay.filter(function(Xt){return Xt.kind==="collider"})),qn=ai.next();!qn.done;qn=ai.next()){var Rn=qn.value;si(Rn)}}catch(Xt){$={error:Xt}}finally{try{qn&&!qn.done&&(q=ai.return)&&q.call(ai)}finally{if($)throw $.error}}var Kr=new Set,Gr=new Map,Ii=function(Xt,Wn,Ui){var Zn,br,Gn;((Zn=Wn.c.prototypeId)!==null&&Zn!==void 0?Zn:Wn.c.id)===((br=Ui.c.prototypeId)!==null&&br!==void 0?br:Ui.c.id)&&Wn.c.id>Ui.c.id||Jt(gt(gt({},pi(Xt,Wn.c,Ui.c)),{instanceId:(Gn=Wn.c.instanceId)!==null&&Gn!==void 0?Gn:Ui.c.instanceId}))},Pn=0;e:for(var Ht=0;Ht<Hn.length;Ht++)for(var Rn=Ht+1;Rn<Hn.length;Rn++){var Lt=Hn[Ht],oi=Hn[Rn];if(!(Lt.c.instanceId&&Lt.c.instanceId===oi.c.instanceId)){var $i=Lt.box,_r=oi.box,Hr=$i.left<_r.right&&$i.right>_r.left&&$i.top<_r.bottom&&$i.bottom>_r.top;if(Hr){if(++Pn>4096){Ai("Collision budget exhausted");break e}Hr=Gv(Lt.polygon,oi.polygon)}if(Hr){var Nn=[Lt.c.id,oi.c.id].sort().join("|");if(Kr.add(Nn),Gr.set(Nn,[Lt,oi]),!ae.has(Nn))try{for(var cr=(Q=void 0,Ue([[Lt,oi],[oi,Lt]])),Pr=cr.next();!Pr.done;Pr=cr.next()){var Qa=De(Pr.value,2),Lr=Qa[0],ur=Qa[1];Ii("contactBegin",Lr,ur)}}catch(Wn){Q={error:Wn}}finally{try{Pr&&!Pr.done&&(te=cr.return)&&te.call(cr)}finally{if(Q)throw Q.error}}}}}try{for(var da=Ue(de),dr=da.next();!dr.done;dr=da.next()){var fa=De(dr.value,2),Nn=fa[0],Vi=De(fa[1],2),Lt=Vi[0],oi=Vi[1];if(!Kr.has(Nn))try{for(var Mi=(me=void 0,Ue([[Lt,oi],[oi,Lt]])),ui=Mi.next();!ui.done;ui=Mi.next()){var Da=De(ui.value,2),Lr=Da[0],ur=Da[1];Ii("contactEnd",Lr,ur)}}catch(Zn){me={error:Zn}}finally{try{ui&&!ui.done&&(ve=Mi.return)&&ve.call(Mi)}finally{if(me)throw me.error}}}}catch(Xt){G={error:Xt}}finally{try{dr&&!dr.done&&(ce=da.return)&&ce.call(da)}finally{if(G)throw G.error}}ae=Kr,de=Gr;try{for(var Si=Ue(pe),Kn=Si.next();!Kn.done;Kn=Si.next()){var Ht=Kn.value;Ht.elapsed+=c;var Un=Ht.parameters,ha=(ht=Un.delay)!==null&&ht!==void 0?ht:0,fr=Ht.elapsed-ha;if(!(fr<0)){var Mr=fr/Un.seconds,On=Un.loop?Mr%1:Math.min(1,Mr),xn=(yt=Un.easing)!==null&&yt!==void 0?yt:"ease-out",Kt=On;Un.loop&&xn==="ease-in-out"?Kt=.5-.5*Math.cos(On*Math.PI*2):xn==="ease-out"?Kt=1-Math.pow(1-On,3):xn==="ease-in"?Kt=Math.pow(On,3):xn==="ease-in-out"?Kt=On<.5?4*Math.pow(On,3):1-Math.pow(-2*On+2,3)/2:xn==="back-out"&&(Kt=1+2.70158*Math.pow(On-1,3)+1.70158*Math.pow(On-1,2));var on=Un.from+(Un.to-Un.from)*Kt,Wr=Le((Gt=Ht.targetId)!==null&&Gt!==void 0?Gt:Ht.componentId);if(Wr){var Ni=(Ut=He.get(Wr.id))!==null&&Ut!==void 0?Ut:{transform:Ke([],De(Wr.transform),!1),parameters:{}},Sr=(at=Ht.baseTransform)!==null&&at!==void 0?at:Wr.transform;if(Un.property==="opacity")Ni.parameters.opacity=Math.max(0,Math.min(1,on));else if(["scale","scaleX","scaleY","rotation"].includes(Un.property)){(Wt=Ni.animationAxes)!==null&&Wt!==void 0||(Ni.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),Ni.animationAxes[Un.property]=on;var Qr=Ni.animationAxes,pc=Qr.rotation*Math.PI/180,ws=Math.cos(pc),ja=Math.sin(pc),Ws=Qr.scale*Qr.scaleX,Wo=Qr.scale*Qr.scaleY;Ni.transform[0]=(Sr[0]*ws+Sr[2]*ja)*Ws,Ni.transform[1]=(Sr[1]*ws+Sr[3]*ja)*Ws,Ni.transform[2]=(-Sr[0]*ja+Sr[2]*ws)*Wo,Ni.transform[3]=(-Sr[1]*ja+Sr[3]*ws)*Wo}else Ni.transform[Un.property==="x"?4:5]=on;He.set(Wr.id,Ni),Un.loop&&fr>=Un.seconds&&(Ht.elapsed=ha+fr%Un.seconds)}}}}catch(Xt){xe={error:Xt}}finally{try{Kn&&!Kn.done&&(oe=Si.return)&&oe.call(Si)}finally{if(xe)throw xe.error}}pe=pe.filter(function(Xt){var Wn,Ui;return Le((Wn=Xt.targetId)!==null&&Wn!==void 0?Wn:Xt.componentId)&&(Xt.elapsed<Xt.parameters.seconds+((Ui=Xt.parameters.delay)!==null&&Ui!==void 0?Ui:0)||Xt.parameters.loop)});try{for(var jr=Ue(fe),ea=jr.next();!ea.done;ea=jr.next()){var Un=ea.value;if(Un.shape==="pixel-confetti"||Un.shape==="confetti"){Un.age+=c;continue}Un.life-=c,Un.x+=Un.vx*c,Un.y+=Un.vy*c,Un.vy+=Un.gravity*c}}catch(Xt){be={error:Xt}}finally{try{ea&&!ea.done&&(Ee=jr.return)&&Ee.call(jr)}finally{if(be)throw be.error}}fe=fe.filter(function(Xt){var Wn;return Xt.life>((Wn=Xt.age)!==null&&Wn!==void 0?Wn:0)}),xr()}function dc(c,x){var R,A,C;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 N=function(q,Q){({M:function(){return p.moveTo.apply(p,Ke([],De(Q),!1))},L:function(){return p.lineTo.apply(p,Ke([],De(Q),!1))},C:function(){return p.bezierCurveTo.apply(p,Ke([],De(Q),!1))},Q:function(){return p.quadraticCurveTo.apply(p,Ke([],De(Q),!1))},Z:function(){return p.closePath()}})[q]()};try{for(var P=Ue(x.commands),X=P.next();!X.done;X=P.next()){var k=De(X.value),Z=k[0],V=k.slice(1);N(Z,V)}}catch(q){R={error:q}}finally{try{X&&!X.done&&(A=P.return)&&A.call(P)}finally{if(R)throw R.error}}}else{var $=Math.min((C=x.radius)!==null&&C!==void 0?C:0,x.width/2,x.height/2);typeof p.roundRect=="function"?p.roundRect(0,0,x.width,x.height,$):(p.moveTo($,0),p.arcTo(x.width,0,x.width,x.height,$),p.arcTo(x.width,x.height,0,x.height,$),p.arcTo(0,x.height,0,0,$),p.arcTo(0,0,x.width,0,$),p.closePath())}}function Wv(c,x,R){var A,C,N,P=(A=He.get(c.id))===null||A===void 0?void 0:A.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,_e-((C=c.spawnTime)!==null&&C!==void 0?C:0))*x.frameRate)%x.frameCount;var X=(N=c.runtimeId)!==null&&N!==void 0?N:c.id,k=Pe.get(X);if(!k)return Pe.set(X,{x:R[4],y:R[5],phase:0,lastMove:-1/0,frame:0}),0;var Z=Math.hypot(R[4]-k.x,R[5]-k.y)>.3;if(Z){var V=_e-k.lastMove;k.phase=Number.isFinite(V)&&V<.25?k.phase+Math.min(V,.12)*x.frameRate:0,k.lastMove=_e}return k.x=R[4],k.y=R[5],_e-k.lastMove>.11&&(k.phase=0),k.frame=Math.floor(k.phase)%x.frameCount,k.frame}function Vo(c,x,R,A){var C,N,P,X,k,Z,V,$,q,Q,te;if(x===void 0&&(x=ga()),R===void 0&&(R=[]),c.contract!=="native.mesh3d.v1"){var G=Vt(c),ce=An("erase-mask",(k=c.prototypeId)!==null&&k!==void 0?k:c.id);if(!(!G.visible||G.opacity<=0)){var me=qs(x,Di(c));p.save(),p.transform.apply(p,Ke([],De(Di(c)),!1)),p.globalAlpha*=G.opacity;var ve=Fn.get(c.id);ve?.behavior.liftShadow&&(p.shadowColor="#00000055",p.shadowBlur=8,p.shadowOffsetY=4);var xe=R;c.contract==="native.group.v1"&&G.clip&&(p.beginPath(),p.rect(0,0,G.width,G.height),p.clip(),xe=Ke(Ke([],De(R),!1),[{matrix:me,width:G.width,height:G.height}],!1));var oe=!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 be=c.contract==="native.button.v1",Ee=se===c.id,Ie=be?G.enabled?Ee?G.pressedFill:an===c.id?G.hoverFill:G.fill:G.disabledFill:G.fill;if(be&&(G.presentation==="pixel-cta"||G.presentation==="shiny-cta")){var Ze=(Z=M.get(c.id))!==null&&Z!==void 0?Z:Ge;E.set(c.id,Ze);var lt=!f&&!U?.matches?Ge-Ze:-1;G.presentation==="shiny-cta"?mv(p,G,Ie,Ee,lt):pv(p,G,Ie,Ee,lt)}else G.pixelFrame&&(p.save(),p.translate(3,4),dc(c,G),p.fillStyle="#3c293366",p.fill(),p.restore()),dc(c,G),ce?(p.save(),p.clip(),zo(c,ce).render(p),p.restore(),oe=!0,dc(c,G)):(p.fillStyle=Ie,p.fill()),G.pixelFrame&&!(G.radius>0)&&(p.fillStyle="#ffffff22",p.fillRect(2,2,Math.max(0,G.width-4),2),p.fillRect(2,2,2,Math.max(0,G.height-4))),G.strokeWidth&&(p.strokeStyle=G.stroke,p.lineWidth=G.strokeWidth,p.stroke());yn===c.id&&(dc(c,G),p.strokeStyle="#ffffff",p.lineWidth=5,p.stroke())}var Xe;if(c.contract==="native.text.v1"){var ht=G.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(wn,Rn){var Hn;return String((Hn=ne[Rn])!==null&&Hn!==void 0?Hn:"")});G.pixelPanel&&(p.fillStyle="#3c293366",p.fillRect(3,4,G.width,G.height),p.fillStyle=G.panelFill,p.fillRect(0,0,G.width,G.height),p.strokeStyle=(V=G.panelStroke)!==null&&V!==void 0?V:G.color,p.lineWidth=2,p.strokeRect(1,1,G.width-2,G.height-2),p.fillStyle="#ffffff22",p.fillRect(3,3,Math.max(0,G.width-6),2));var yt=G.fontFamily==="pixel"?Yh(ht,G):void 0;yt&&!yt.unsupportedChars.length?Xe=cv(p,ht,G):Xe=Qb(p,ht,yt?gt(gt({},G),{fontFamily:"sans-serif",fontWeight:"700"}):G)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(c.contract)&&!ce){var Gt=b.get((q=($=He.get(c.id))===null||$===void 0?void 0:$.assetId)!==null&&q!==void 0?q:(Q=c.assetSlots[0])===null||Q===void 0?void 0:Q.assetId);if(Gt?.complete&&Gt.naturalWidth){p.save(),p.beginPath(),p.rect(0,0,G.width,G.height),p.clip();var Ut=c.contract!=="native.image.v1",at=Ut?Math.min(G.frameColumns,G.frameCount):1,Wt=Ut?Math.ceil(G.frameCount/at):1,Mt=Gt.width/at,mt=Gt.height/Wt,Qe=Ut?Wv(c,G,me):0,st=Qe%at*Mt,We=Math.floor(Qe/at)*mt,tt=G.fit==="cover"?Math.max(G.width/Mt,G.height/mt):Math.min(G.width/Mt,G.height/mt),St=G.fit==="stretch"?G.width:Mt*tt,Ct=G.fit==="stretch"?G.height:mt*tt;p.imageSmoothingEnabled=(te=G.smoothing)!==null&&te!==void 0?te:!0,p.drawImage(Gt,st,We,Mt,mt,(G.width-St)/2,(G.height-Ct)/2,St,Ct),p.restore()}}if(ce&&!oe&&zo(c,ce).render(p),c.contract==="native.stage3d.v1"&&jt){var st=Math.hypot(me[0],me[1]),We=Math.hypot(me[2],me[3]),Pt=jt.renderStage(c,p,G.width*st*Me*Se,G.height*We*Me*Se,G.width,G.height,{time:_e,ambientTime:Ge,propsOf:Vt,bodies3d:$t,fpsPose:Vn.get(c.id),instances3d:sp(c.id),aimLocked:!!It,groundFn:Js,worldWidth:G.width*st,worldHeight:G.height*We});try{for(var Nt=Ue($t),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Bt=De(Yt.value,2),it=Bt[0],Ft=Bt[1];if(Ft.stageId===c.id&&Ft.mode==="dynamic"){var Cn=Pt.project({x:Ft.x,y:Ft.y,z:Ft.z},G.width,G.height);hn.set(it,In(me,Cn.x,Cn.y))}}}catch(Hn){C={error:Hn}}finally{try{Yt&&!Yt.done&&(N=Nt.return)&&N.call(Nt)}finally{if(C)throw C.error}}}ue.push({c,m:me,clips:xe,instance:A??c.prototypeId,textMetrics:Xe});try{for(var bn=Ue(yr(c.id)),_i=bn.next();!_i.done;_i=bn.next()){var ri=_i.value;Vo(ri,me,xe,A??c.prototypeId)}}catch(wn){P={error:wn}}finally{try{_i&&!_i.done&&(X=bn.return)&&X.call(bn)}finally{if(P)throw P.error}}G.clip&&c.contract==="native.group.v1"&&Zd(c.id),p.restore()}}}function Zd(c,x){var R,A;if(!U?.matches)try{for(var C=Ue(fe),N=C.next();!N.done;N=C.next()){var P=N.value;P.shape!=="pixel-confetti"&&P.shape!=="confetti"||P.clipId!==c||!!P.screen!=!!x||(p.save(),P.shape==="confetti"?hv(p,P,x):dv(p,P,x),p.restore())}}catch(X){R={error:X}}finally{try{N&&!N.done&&(A=C.return)&&A.call(C)}finally{if(R)throw R.error}}}function Xv(c,x,R,A){p.save(),p.translate(c,x),p.globalAlpha=.92,p.lineWidth=2,p.lineJoin="round",R==="tap"&&(p.strokeStyle="#fff0bd",p.globalAlpha=.7*(1-A),p.beginPath(),p.arc(0,0,12+A*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 Yv(){var c,x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve;if(Ne=0,!f)try{for(var xe=Ue(n.gameplay.filter(function(Nn){return Nn.kind==="tutorial-hand"})),oe=xe.next();!oe.done;oe=xe.next()){var be=oe.value,Ee=S.get(be.componentId),Ie=Le(be.parameters.targetId);if(!(!Ee||Ee.sceneId!==J||!Ie||Ie.sceneId!==J||!ii(Ie))&&!(be.parameters.hideOnFirstInput&&Ae)){var Ze=je?_e:Ge;if(!(Ze-Re<be.parameters.idleDelaySeconds)){Ne++;var lt=be.parameters.destinationId?Le(be.parameters.destinationId):void 0,Xe=Vt(Ie),ht=void 0;Ie.contract==="native.mesh3d.v1"&&(ht=Vd(Ie.id)),ht||(ht=In(zn(Ie),Xe.width/2,Xe.height/2));var yt=Ze%1.2/1.2,Gt=U?.matches?0:yt*yt*(3-2*yt),Ut=ht.x,at=ht.y;if(be.parameters.mode!=="tap"){var Wt=lt?In(zn(lt),Vt(lt).width/2,Vt(lt).height/2):{x:ht.x-36,y:ht.y+48};Ut=ht.x+(Wt.x-ht.x)*Gt,at=ht.y+(Wt.y-ht.y)*Gt}Xv(Ut+8,at+22,be.parameters.mode,Gt)}}}}catch(Nn){c={error:Nn}}finally{try{oe&&!oe.done&&(x=xe.return)&&x.call(xe)}finally{if(c)throw c.error}}try{for(var Mt=Ue(sr),mt=Mt.next();!mt.done;mt=Mt.next()){var Qe=De(mt.value,2),st=Qe[0],We=Qe[1],tt=An("draw-stroke",st).parameters;try{for(var St=(C=void 0,Ue(We.strokes)),Ct=St.next();!Ct.done;Ct=St.next()){var Pt=Ct.value;if(!(Pt.points.length<2)){p.save(),p.globalAlpha=tt.mode==="slice-blade"?Math.max(0,1-Pt.age/.18):1,p.strokeStyle=tt.color,p.lineWidth=tt.strokeWidth,p.lineCap="round",p.lineJoin="round",p.beginPath(),p.moveTo(Pt.points[0].x,Pt.points[0].y);try{for(var Nt=(P=void 0,Ue(Pt.points.slice(1))),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Bt=Yt.value;p.lineTo(Bt.x,Bt.y)}}catch(Nn){P={error:Nn}}finally{try{Yt&&!Yt.done&&(X=Nt.return)&&X.call(Nt)}finally{if(P)throw P.error}}p.stroke(),p.restore()}}}catch(Nn){C={error:Nn}}finally{try{Ct&&!Ct.done&&(N=St.return)&&N.call(St)}finally{if(C)throw C.error}}}}catch(Nn){R={error:Nn}}finally{try{mt&&!mt.done&&(A=Mt.return)&&A.call(Mt)}finally{if(R)throw R.error}}try{for(var it=Ue(tn),Ft=it.next();!Ft.done;Ft=it.next()){var Cn=Ft.value;if(!(Cn.broken||!Cn.drawRope)){var bn=fn.get(Cn.bodyId),_i=Le(Cn.anchorId);if(!(!bn||!_i)){var ri=xi(_i);p.save(),p.strokeStyle=Cn.ropeColor,p.lineWidth=Cn.ropeWidth,p.beginPath(),p.moveTo(ri.x,ri.y),p.lineTo(bn.x,bn.y),p.stroke(),p.restore()}}}}catch(Nn){k={error:Nn}}finally{try{Ft&&!Ft.done&&(Z=it.return)&&Z.call(it)}finally{if(k)throw k.error}}try{for(var wn=Ue(n.gameplay.filter(function(Nn){var cr;return Nn.kind==="virtual-joystick"&&((cr=S.get(Nn.componentId))===null||cr===void 0?void 0:cr.sceneId)===J})),Rn=wn.next();!Rn.done;Rn=wn.next()){var be=Rn.value,Hn=Le(be.componentId),Xe=be.parameters;if(!(!Hn||!ii(Hn)||Xe.drawControl===!1)){var si=le.get(be.id),ai=si&&si.pointerId!==null?si.origin:xi(Hn),qn=si&&si.pointerId!==null?si.knobX:ai.x,Kr=si&&si.pointerId!==null?si.knobY:ai.y,Gr=(ce=Xe.radiusPx)!==null&&ce!==void 0?ce:56;p.save(),p.fillStyle=(me=Xe.baseColor)!==null&&me!==void 0?me:"#ffffff44",p.strokeStyle="#ffffffaa",p.lineWidth=2.5,p.beginPath(),p.arc(ai.x,ai.y,Gr,0,Math.PI*2),p.fill(),p.stroke(),p.fillStyle=(ve=Xe.knobColor)!==null&&ve!==void 0?ve:"#fff0bdee",p.strokeStyle="#193b46aa",p.lineWidth=2,p.beginPath(),p.arc(qn,Kr,Gr*.42,0,Math.PI*2),p.fill(),p.stroke(),p.restore()}}}catch(Nn){V={error:Nn}}finally{try{Rn&&!Rn.done&&($=wn.return)&&$.call(wn)}finally{if(V)throw V.error}}try{for(var Ii=Ue(we),Pn=Ii.next();!Pn.done;Pn=Ii.next()){var Ht=Pn.value,Lt=Math.min(1,Ht.elapsed/Ht.seconds);p.save(),p.globalAlpha=1-Lt,p.fillStyle=Ht.color,p.strokeStyle="#193b46",p.lineWidth=3,p.font="900 "+Ht.fontSize+"px sans-serif",p.textAlign="center",p.textBaseline="middle";var at=Ht.y-(U?.matches?0:Ht.risePx*Lt);p.strokeText(Ht.text,Ht.x,at),p.fillText(Ht.text,Ht.x,at),p.restore()}}catch(Nn){q={error:Nn}}finally{try{Pn&&!Pn.done&&(Q=Ii.return)&&Q.call(Ii)}finally{if(q)throw q.error}}try{for(var oi=Ue(ze),$i=oi.next();!$i.done;$i=oi.next()){var _r=$i.value,Lt=Math.min(1,_r.elapsed/_r.seconds),Hr=O();p.save(),p.globalAlpha=_r.opacity*(1-Lt),p.fillStyle=_r.color,p.fillRect(0,0,Hr.width,Hr.height),p.restore()}}catch(Nn){te={error:Nn}}finally{try{$i&&!$i.done&&(G=oi.return)&&G.call(oi)}finally{if(te)throw te.error}}}function qv(){if(he){var c=fn.get(he.targetId),x=he.behavior.parameters;if(c){var R=he.current.x-he.start.x,A=he.current.y-he.start.y,C=Math.hypot(R,A),N=Math.min(x.maxPullPx,C),P=C>.001?N/C: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&&C>=x.minPullPx){var k=Jd(),Z=ip(),V=Z.bodies,$=Z.zones,q=O(),Q=tm({body:gt(gt({},c),{vx:k.vx,vy:k.vy,atRest:!1}),bodies:V,zones:$,bounds:{left:0,top:0,right:q.width,bottom:q.height},dots:x.trajectoryDots,bounces:x.trajectoryBounces});Q.forEach(function(ce,me){var ve=.96-.52*(me/Math.max(1,Q.length)),xe=Math.max(2.2,4.5-me*.22);p.globalAlpha=ve,p.fillStyle="#173a2f88",p.beginPath(),p.arc(ce.x,ce.y,xe+1.3,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(ce.x,ce.y,xe,0,Math.PI*2),p.fill()})}if(C>=4){var te=c.x+R*P,G=c.y+A*P;p.globalAlpha=.9,p.strokeStyle="#173a2f66",p.lineWidth=5,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(te,G),p.stroke(),p.strokeStyle=x.trajectoryColor,p.lineWidth=2.6,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(te,G),p.stroke(),p.fillStyle="#173a2f88",p.beginPath(),p.arc(te,G,5.2,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(te,G,3.6,0,Math.PI*2),p.fill()}p.restore()}}}function Zv(c){var x,R,A,C;try{for(var N=Ue(Pa()),P=N.next();!P.done;P=N.next()){var X=P.value,k=X.contract==="native.group.v1"?yr(X.id):[X];try{for(var Z=(A=void 0,Ue(k)),V=Z.next();!V.done;V=Z.next()){var $=V.value;if($.contract==="native.stage3d.v1"&&ii($)&&Vt($).skyColor)return Vt($).skyColor;if(!($.contract!=="native.rectangle.v1"||!ii($))){var q=Vt($);if(!(q.opacity<.95||!q.fill||q.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test($.id)||q.width>=c.width*.9&&q.height>=c.height*.9))return q.fill}}}catch(Q){A={error:Q}}finally{try{V&&!V.done&&(C=Z.return)&&C.call(Z)}finally{if(A)throw A.error}}}}catch(Q){x={error:Q}}finally{try{P&&!P.done&&(R=N.return)&&R.call(N)}finally{if(x)throw x.error}}return"#102a34"}function Jv(){var c;if(et&&ii(et.c)){var x=et.c,R=Vt(x);p.save(),p.transform.apply(p,Ke([],De(zn(x)),!1)),p.strokeStyle=(c=et.highlightColor)!==null&&c!==void 0?c:"#ffffff",p.lineWidth=4,p.globalAlpha=.85,p.strokeRect(-4,-4,R.width+8,R.height+8),p.restore()}if(rt?.b.parameters.bringToFront){var x=Le(rt.targetId);x&&Vo(x,x.parentId?zn(Le(x.parentId)):ga(),[],x.prototypeId)}}function ei(){var c,x,R,A,C,N;M=E,E=new Map;var P=O();Y!==void 0&&Y!==P.landscape&&gr(),Y=P.landscape;var X=Math.min(devicePixelRatio||1,2),k=e.clientWidth,Z=e.clientHeight;(e.width!==Math.round(k*X)||e.height!==Math.round(Z*X))&&(e.width=Math.round(k*X),e.height=Math.round(Z*X)),p.setTransform(X,0,0,X,0,0),p.fillStyle=Zv(P),p.fillRect(0,0,k,Z);var V=Math.min(k/P.width,Z/P.height),$=(k-P.width*V)/2,q=(Z-P.height*V)/2;if(Me=V||1,Se=X,p.translate($,q),p.scale(V,V),Ye){var Q=Math.min(1,Ye.elapsed/Ye.seconds),te=Ye.intensity*(1-Q);p.translate(Math.sin(Ye.elapsed*95)*te,Math.cos(Ye.elapsed*113)*te)}p.save(),p.beginPath(),p.rect(0,0,P.width,P.height),p.clip(),ue=[];try{for(var G=Ue(Pa()),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;Vo(me)}}catch(at){c={error:at}}finally{try{ce&&!ce.done&&(x=G.return)&&x.call(G)}finally{if(c)throw c.error}}try{for(var ve=Ue(Te),xe=ve.next();!xe.done;xe=ve.next()){var me=xe.value;me.parentId||Vo(me,ga(),[],me.prototypeId)}}catch(at){R={error:at}}finally{try{xe&&!xe.done&&(A=ve.return)&&A.call(ve)}finally{if(R)throw R.error}}if(Jv(),qv(),f&&w){for(var oe=S.get(w);oe?.parentId;)oe=S.get(oe.parentId);oe?.prototype&&Vo(oe)}Zd(),p.save();try{for(var be=Ue(fe),Ee=be.next();!Ee.done;Ee=be.next()){var Ie=Ee.value;if(!(Ie.shape==="pixel-confetti"||Ie.shape==="confetti")){var Ze=Math.min(1,Ie.life*2),lt=1.5+2.5*Ze;if(p.globalAlpha=Ze,p.globalCompositeOperation=Ie.shape==="square"?"source-over":"lighter",p.fillStyle=Ie.color,Ie.shape==="square"){var Xe=Math.max(2,Math.round(lt*1.6));p.fillRect(Math.round(Ie.x-Xe/2),Math.round(Ie.y-Xe/2),Xe,Xe);continue}p.globalCompositeOperation="lighter",p.shadowColor=Ie.color,p.shadowBlur=fe.length<=16?6:0,p.strokeStyle=Ie.color,p.lineWidth=1.5+Ze,p.beginPath(),p.moveTo(Ie.x-Ie.vx*.025,Ie.y-Ie.vy*.025),p.lineTo(Ie.x,Ie.y),p.stroke(),p.beginPath(),p.arc(Ie.x,Ie.y,lt,0,Math.PI*2),p.fill()}}}catch(at){C={error:at}}finally{try{Ee&&!Ee.done&&(N=be.return)&&N.call(be)}finally{if(C)throw C.error}}if(p.restore(),Yv(),f&&w){var ht=ue.filter(function(at){return at.c.contract!=="native.group.v1"&&(at.c.id===w||Rr(at.c,w))});if(ht.length){var yt=ht.map(function(at){return zi(at.c,at.m)}),Gt=Math.min.apply(Math,Ke([],De(yt.map(function(at){return at.left})),!1)),Ut=Math.min.apply(Math,Ke([],De(yt.map(function(at){return at.top})),!1));p.strokeStyle="#55e6ef",p.lineWidth=2/V,p.strokeRect(Gt,Ut,Math.max.apply(Math,Ke([],De(yt.map(function(at){return at.right})),!1))-Gt,Math.max.apply(Math,Ke([],De(yt.map(function(at){return at.bottom})),!1))-Ut)}}p.restore(),V>0&&Zd(void 0,{x:-$/V,y:-q/V,width:k/V,height:Z/V})}function $v(c){var x,R,A,C,N=Array.isArray(c)?Ke([],De(new Set(c)),!1):void 0;ei();var P=O(),X=new Set,k=[];try{for(var Z=Ue(ue),V=Z.next();!V.done;V=Z.next()){var $=V.value,q=(A=$.c.prototypeId)!==null&&A!==void 0?A:$.c.id;if(!($.c.contract==="native.group.v1"||N&&!N.includes(q))){X.add(q);var Q=zi($.c,$.m),te=((C=Vt($.c).strokeWidth)!==null&&C!==void 0?C:0)/2;Q.left-=te,Q.right+=te,Q.top-=te,Q.bottom+=te;var G={left:Math.max(0,-Q.left),right:Math.max(0,Q.right-P.width),top:Math.max(0,-Q.top),bottom:Math.max(0,Q.bottom-P.height)};Object.values(G).some(function(me){return me>.01})&&k.push({id:q,contract:$.c.contract,bounds:Q,overflow:G})}}}catch(me){x={error:me}}finally{try{V&&!V.done&&(R=Z.return)&&R.call(Z)}finally{if(x)throw x.error}}var ce=N?N.filter(function(me){return!X.has(me)}):[];return{ok:k.length===0&&ce.length===0,viewport:gt(gt({},P),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight}),issues:k,missing:ce}}function Kv(c){var x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut,at,Wt,Mt,mt=c===void 0?{}:c,Qe=mt.ids,st=mt.interactiveIds,We=mt.network,tt=We===void 0?"standalone":We,St=mt.minTouchPx,Ct=St===void 0?44:St,Pt=Array.isArray(Qe)?Ke([],De(new Set(Qe)),!1):void 0;ei();var Nt=O(),Yt=Math.min(e.clientWidth/Nt.width,e.clientHeight/Nt.height),Bt=np(Nt,tt),it=[],Ft=new Set,Cn=function(Ce){var Ot;return!Pt||Pt.includes((Ot=Ce.c.prototypeId)!==null&&Ot!==void 0?Ot:Ce.c.id)},bn=ue.filter(Cn),_i=new Set(n.events.filter(function(Ce){return Ce.kind==="click"}).map(function(Ce){return Ce.componentId}));try{for(var ri=Ue(n.gameplay),wn=ri.next();!wn.done;wn=ri.next()){var Rn=wn.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(Rn.kind)&&_i.add(Rn.componentId)}}catch(Ce){x={error:Ce}}finally{try{wn&&!wn.done&&(R=ri.return)&&R.call(ri)}finally{if(x)throw x.error}}var Hn=new Set(st??_i),si=new Set(n.gameplay.filter(function(Ce){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(Ce.kind)&&(Ce.parameters.dragMode==="anywhere"||Ce.kind==="draw-stroke"||Ce.kind==="virtual-joystick"&&Ce.parameters.mode==="floating")}).map(function(Ce){return Ce.componentId})),ai=function(Ce){var Ot;return Hn.has((Ot=Ce.c.prototypeId)!==null&&Ot!==void 0?Ot:Ce.c.id)},qn=function(Ce,Ot,qt,_n,Ti,di){return it.push(gt(gt({kind:Ce,severity:Ot,id:qt},di?{otherId:di}:{}),{detail:_n,metrics:Ti}))},Kr=function(Ce){var Ot=[[0,0],[Ce.width,0],[Ce.width,Ce.height],[0,Ce.height]].map(function(qt){var _n=De(qt,2),Ti=_n[0],di=_n[1];return In(Ce.matrix,Ti,di)});return{left:Math.min.apply(Math,Ke([],De(Ot.map(function(qt){return qt.x})),!1)),right:Math.max.apply(Math,Ke([],De(Ot.map(function(qt){return qt.x})),!1)),top:Math.min.apply(Math,Ke([],De(Ot.map(function(qt){return qt.y})),!1)),bottom:Math.max.apply(Math,Ke([],De(Ot.map(function(qt){return qt.y})),!1))}};try{for(var Gr=Ue(bn),Ii=Gr.next();!Ii.done;Ii=Gr.next()){var Pn=Ii.value,Ht=(Ie=Pn.c.prototypeId)!==null&&Ie!==void 0?Ie:Pn.c.id;Ft.add(Ht);var Lt=zi(Pn.c,Pn.m),oi=((Ze=Vt(Pn.c).strokeWidth)!==null&&Ze!==void 0?Ze:0)/2;Lt.left-=oi,Lt.right+=oi,Lt.top-=oi,Lt.bottom+=oi;var $i=Pn.c.contract==="native.group.v1"&&!Vt(Pn.c).clip,_r=Pn.c.contract==="native.image.v1"&&Pn.clips.length===0&&Vt(Pn.c).fit==="cover"&&Lt.left<=0&&Lt.top<=0&&Lt.right>=Nt.width&&Lt.bottom>=Nt.height||Pn.c.contract==="native.stage3d.v1"&&Lt.left<=0&&Lt.top<=0&&Lt.right>=Nt.width&&Lt.bottom>=Nt.height,Hr=Pn.c.contract==="native.rectangle.v1"&&oi===0&&Lt.left<=0&&Lt.top<=0&&Lt.right>=Nt.width&&Lt.bottom>=Nt.height||_r;if(!$i){var Nn={left:Math.max(0,-Lt.left),right:Math.max(0,Lt.right-Nt.width),top:Math.max(0,-Lt.top),bottom:Math.max(0,Lt.bottom-Nt.height)};if(!Hr&&!mp(Pn.c)&&Object.values(Nn).some(function(Ce){return Ce>.01})&&qn("stage-overflow","blocker",Ht,"Component extends beyond the active stage.",{bounds:Lt,overflow:Nn}),Pn.c.contract==="native.image.v1"&&Pn.clips.length===0){var cr=Lt.right-Lt.left,Pr=Lt.bottom-Lt.top,Qa=/(?:^|\.)(backdrop|background|bg)$/.test(Ht)||Vt(Pn.c).fit==="cover"&&!Pn.c.parentId&&Lt.left<=1&&Lt.top<=1&&(cr>=Nt.width*.4||Pr>=Nt.height*.4);Qa&&(Lt.left>.5||Lt.top>.5||Lt.right<Nt.width-.5||Lt.bottom<Nt.height-.5)&&qn("backdrop-incomplete","blocker",Ht,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:Lt,stage:{width:Nt.width,height:Nt.height}})}try{for(var Lr=(N=void 0,Ue(Pn.clips)),ur=Lr.next();!ur.done;ur=Lr.next()){var da=ur.value,dr=Kr(da),fa={left:Math.max(0,dr.left-Lt.left),right:Math.max(0,Lt.right-dr.right),top:Math.max(0,dr.top-Lt.top),bottom:Math.max(0,Lt.bottom-dr.bottom)};Object.values(fa).some(function(Ce){return Ce>.01})&&qn("parent-clip-crop","blocker",Ht,"Component is cropped by an ancestor clipping group.",{bounds:Lt,clip:dr,crop:fa})}}catch(Ce){N={error:Ce}}finally{try{ur&&!ur.done&&(P=Lr.return)&&P.call(Lr)}finally{if(N)throw N.error}}}if(Pn.textMetrics){var Vi=Pn.textMetrics;(Vi.overflowsWidth||Vi.overflowsHeight)&&qn("text-overflow","blocker",Ht,"Text does not fit its component after wrapping and auto-fit.",Vi);var Mi=(lt=Vi.fontSize)!==null&<!==void 0?lt:Vi.scale*8;Mi<12&&qn("text-illegible",Mi<8?"blocker":"warning",Ht,"Rendered text is below the recommended legible size.",gt({renderedFontSize:Mi},Vi));var ui=Vt(Pn.c);if(ui.pixelPanel&&ui.align!=="center"){var Da=Math.max(0,ui.width-2*(ui.padding===void 0?8:ui.padding));Da-((Xe=Vi.renderedWidth)!==null&&Xe!==void 0?Xe:0)>12&&qn("panel-off-center","blocker",Ht,"Text inside a framed pixel panel is not horizontally centered.",{align:ui.align,innerWidth:Da,renderedWidth:(ht=Vi.renderedWidth)!==null&&ht!==void 0?ht:0})}}if(ai(Pn)&&!si.has(Ht)&&(Pn.c.contract!=="native.group.v1"||Lt.right>Lt.left&&Lt.bottom>Lt.top)){var Si=(Lt.right-Lt.left)*Yt,Kn=(Lt.bottom-Lt.top)*Yt;(Si<Ct-.01||Kn<Ct-.01)&&qn("touch-target-small","blocker",Ht,"Interactive target is smaller than the required physical touch size.",{width:Si,height:Kn,minTouchPx:Ct,scale:Yt})}if(ai(Pn)&&!si.has(Ht)||Pn.c.contract==="native.text.v1")try{for(var Un=(X=void 0,Ue(Bt.zones)),ha=Un.next();!ha.done;ha=Un.next()){var fr=ha.value,Si=Math.min(Lt.right,fr.right)-Math.max(Lt.left,fr.left),Kn=Math.min(Lt.bottom,fr.bottom)-Math.max(Lt.top,fr.top);Si>.01&&Kn>.01&&qn("sdk-safe-area-collision","blocker",Ht,"Component intersects a reserved ad-SDK overlay zone.",{bounds:Lt,zone:fr,intersection:{width:Si,height:Kn},network:tt})}}catch(Ce){X={error:Ce}}finally{try{ha&&!ha.done&&(k=Un.return)&&k.call(Un)}finally{if(X)throw X.error}}}}catch(Ce){A={error:Ce}}finally{try{Ii&&!Ii.done&&(C=Gr.return)&&C.call(Gr)}finally{if(A)throw A.error}}for(var Mr=bn.filter(function(Ce){return ai(Ce)&&Ce.c.contract!=="native.group.v1"}),On=0;On<Mr.length;On++)for(var xn=On+1;xn<Mr.length;xn++){var Kt=Mr[On],on=Mr[xn],Wr=(yt=Kt.c.prototypeId)!==null&&yt!==void 0?yt:Kt.c.id,Ni=(Gt=on.c.prototypeId)!==null&&Gt!==void 0?Gt:on.c.id;if(!(Wr===Ni||Rr(Kt.c,on.c.id)||Rr(on.c,Kt.c.id))){var Sr=zi(Kt.c,Kt.m),Qr=zi(on.c,on.m),Si=Math.min(Sr.right,Qr.right)-Math.max(Sr.left,Qr.left),Kn=Math.min(Sr.bottom,Qr.bottom)-Math.max(Sr.top,Qr.top);Si>1&&Kn>1&&qn("interactive-overlap","blocker",Wr,"Interactive targets overlap.",{intersection:{width:Si,height:Kn},first:Sr,second:Qr},Ni)}}var pc=function(Ce){if(!Ce||Ce==="transparent")return!1;var Ot=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(Ce);if(Ot)return Ot[1].length===4?Ot[1][3].toLowerCase()==="f":Ot[1].slice(6).toLowerCase()==="ff";var qt=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(Ce);return qt?Number(qt[1])>=.95:!0},ws=[];bn.forEach(function(Ce,Ot){var qt,_n;Ce.c.contract==="native.rectangle.v1"&&!ai(Ce)&&((qt=Vt(Ce.c).opacity)!==null&&qt!==void 0?qt:1)>=.95&&pc(Vt(Ce.c).fill)&&ws.push({rowIndex:Ot,row:Ce,order:(_n=Ce.c.order)!==null&&_n!==void 0?_n:0,bounds:zi(Ce.c,Ce.m)})});var ja=bn.filter(function(Ce,Ot){var qt,_n=zi(Ce.c,Ce.m),Ti=(qt=Ce.c.order)!==null&&qt!==void 0?qt:0;return!ws.some(function(di){return di.rowIndex>Ot&&di.order>Ti&&di.row.c.id!==Ce.c.id&&!Rr(di.row.c,Ce.c.id)&&!Rr(Ce.c,di.row.c.id)&&di.bounds.left<=_n.left+1&&di.bounds.right>=_n.right-1&&di.bounds.top<=_n.top+1&&di.bounds.bottom>=_n.bottom-1})}),Ws=ja.map(function(Ce,Ot){return{row:Ce,rowIndex:Ot}}).filter(function(Ce){var Ot,qt=Ce.row;if(qt.c.contract!=="native.rectangle.v1")return!1;var _n=zi(qt.c,qt.m),Ti=_n.right-_n.left,di=_n.bottom-_n.top,Ua=((Ot=Vt(qt.c).strokeWidth)!==null&&Ot!==void 0?Ot:0)===0&&_n.left<=0&&_n.right>=Nt.width;return!Ua&&Ti>=180&&di>=140&&!ai(qt)}).map(function(Ce){var Ot,qt=Ce.row,_n=Ce.rowIndex;return{id:(Ot=qt.c.prototypeId)!==null&&Ot!==void 0?Ot:qt.c.id,row:qt,rowIndex:_n,bounds:zi(qt.c,qt.m)}}),Wo=function(Ce,Ot,qt,_n){var Ti,di;_n===void 0&&(_n=!1);var Ua=(Ti=Ce.c.prototypeId)!==null&&Ti!==void 0?Ti:Ce.c.id,Qo=(qt.left+qt.right)/2,Fa=(qt.top+qt.bottom)/2,rf=(di=Ce.c.order)!==null&&di!==void 0?di:0;return Ws.filter(function(Qn){var Oa;return Qn.id!==Ua&&(!_n||Qn.rowIndex<Ot||((Oa=Qn.row.c.order)!==null&&Oa!==void 0?Oa:0)===rf)&&qt.right-qt.left<=Qn.bounds.right-Qn.bounds.left+4&&qt.bottom-qt.top<=Qn.bounds.bottom-Qn.bounds.top+4&&Qo>=Qn.bounds.left&&Qo<=Qn.bounds.right&&Fa>=Qn.bounds.top&&Fa<=Qn.bounds.bottom}).sort(function(Qn,Oa){return(Qn.bounds.right-Qn.bounds.left)*(Qn.bounds.bottom-Qn.bounds.top)-(Oa.bounds.right-Oa.bounds.left)*(Oa.bounds.bottom-Oa.bounds.top)||Oa.rowIndex-Qn.rowIndex})[0]},jr=new Map,ea=new Map;if(Ws.length){ja.forEach(function(Ce,Ot){var qt,_n=(qt=Ce.c.prototypeId)!==null&&qt!==void 0?qt:Ce.c.id,Ti=zi(Ce.c,Ce.m),di=(Ti.left+Ti.right)/2,Ua=(Ti.top+Ti.bottom)/2,Qo=Ce.c.contract==="native.button.v1"&&!Dn.has(Ce.c.id),Fa=Ce.c.parentId?Le(Ce.c.parentId):void 0,rf=Ce.c.contract==="native.text.v1"&&Vt(Ce.c).align==="center"&&Fa?.contract!=="native.button.v1";if(Qo||rf){var Qn=Wo(Ce,Ot,Ti,!1);Qn&&(jr.has(Qn.id)||jr.set(Qn.id,{panel:Qn,items:[]}),jr.get(Qn.id).items.push({id:_n,bounds:Ti,cx:di,cy:Ua,isBtn:Qo}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(Ce.c.contract)&&Fa?.contract!=="native.button.v1"){var Qn=Wo(Ce,Ot,Ti,!0);Qn&&(ea.has(Qn.id)||ea.set(Qn.id,{panel:Qn,content:[]}),ea.get(Qn.id).content.push({row:Ce,id:_n,bounds:Ti}))}});try{for(var Xt=Ue(jr.values()),Wn=Xt.next();!Wn.done;Wn=Xt.next()){var Ui=Wn.value,Zn=Ui.panel,br=Ui.items;if(br.some(function(Ce){return Ce.isBtn})){var Gn=Zn.bounds,Fi=(Gn.left+Gn.right)/2;try{for(var Gi=($=void 0,Ue(br)),Na=Gi.next();!Na.done;Na=Gi.next()){var Ki=Na.value,pa={left:Ki.bounds.left-Gn.left,right:Gn.right-Ki.bounds.right,top:Ki.bounds.top-Gn.top,bottom:Gn.bottom-Ki.bounds.bottom},Xs=Math.min(pa.left,pa.right,pa.top,pa.bottom);(Xs<10||Xs*Yt<8)&&qn("panel-edge-cramped","blocker",Ki.id,"Element sits too close to its enclosing panel edge.",{panelId:Zn.id,margins:pa,scale:Yt,minStagePx:10,minCssPx:8},Zn.id)}}catch(Ce){$={error:Ce}}finally{try{Na&&!Na.done&&(q=Gi.return)&&q.call(Gi)}finally{if($)throw $.error}}var es=[],Xo=function(Ce){var Ot=es.find(function(qt){return Math.abs(qt.cy-Ce.cy)<=16&&qt.isBtn===Ce.isBtn});Ot?Ot.items.push(Ce):es.push({cy:Ce.cy,isBtn:Ce.isBtn,items:[Ce]})};try{for(var mc=(Q=void 0,Ue(br)),Yo=mc.next();!Yo.done;Yo=mc.next()){var Ki=Yo.value;Xo(Ki)}}catch(Ce){Q={error:Ce}}finally{try{Yo&&!Yo.done&&(te=mc.return)&&te.call(mc)}finally{if(Q)throw Q.error}}try{for(var vc=(G=void 0,Ue(es)),qo=vc.next();!qo.done;qo=vc.next()){var tf=qo.value,lg=Math.min.apply(Math,Ke([],De(tf.items.map(function(Ce){return Ce.bounds.left})),!1)),cg=Math.max.apply(Math,Ke([],De(tf.items.map(function(Ce){return Ce.bounds.right})),!1)),wp=(lg+cg)/2,Tp=wp-Fi;Math.abs(Tp)>3&&qn("panel-off-center","blocker",tf.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:Zn.id,offsetX:Tp,groupCenterX:wp,panelCenterX:Fi,scale:Yt},Zn.id)}}catch(Ce){G={error:Ce}}finally{try{qo&&!qo.done&&(ce=vc.return)&&ce.call(vc)}finally{if(G)throw G.error}}}}}catch(Ce){Z={error:Ce}}finally{try{Wn&&!Wn.done&&(V=Xt.return)&&V.call(Xt)}finally{if(Z)throw Z.error}}try{for(var gc=Ue(ea.values()),Zo=gc.next();!Zo.done;Zo=gc.next())for(var Ep=Zo.value,Zn=Ep.panel,yc=Ep.content,ug=jr.has(Zn.id),On=0;On<yc.length;On++)for(var xn=On+1;xn<yc.length;xn++){var Kt=yc[On],on=yc[xn];if(!(Kt.id===on.id||Rr(Kt.row.c,on.row.c.id)||Rr(on.row.c,Kt.row.c.id))){var dg=Kt.row.c.contract==="native.image.v1"&&on.row.c.contract==="native.image.v1";if(!(dg&&(!ug||Kt.row.c.parentId&&Kt.row.c.parentId===on.row.c.parentId))){var Si=Math.min(Kt.bounds.right,on.bounds.right)-Math.max(Kt.bounds.left,on.bounds.left),Kn=Math.min(Kt.bounds.bottom,on.bounds.bottom)-Math.max(Kt.bounds.top,on.bounds.top);Si>2&&Kn>2&&qn("panel-content-overlap","blocker",Kt.id,"Panel elements overlap each other.",{panelId:Zn.id,intersection:{width:Si,height:Kn},first:Kt.bounds,second:on.bounds},on.id)}}}}catch(Ce){me={error:Ce}}finally{try{Zo&&!Zo.done&&(ve=gc.return)&&ve.call(gc)}finally{if(me)throw me.error}}}var Ys=ja.filter(function(Ce){if(Ce.c.contract!=="native.text.v1")return!1;var Ot=Ce.c.parentId?Le(Ce.c.parentId):void 0;return Ot?.contract!=="native.button.v1"}).map(function(Ce){var Ot,qt,_n=String((Ot=Vt(Ce.c).text)!==null&&Ot!==void 0?Ot:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Ti,di){var Ua;return String((Ua=ne[di])!==null&&Ua!==void 0?Ua:"")}).trim();return{row:Ce,id:(qt=Ce.c.prototypeId)!==null&&qt!==void 0?qt:Ce.c.id,bounds:zi(Ce.c,Ce.m),raw:_n,norm:_n.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(Ce){return Ce.raw.length>0}),fg=Ws.filter(function(Ce){var Ot,qt;return((Ot=jr.get(Ce.id))===null||Ot===void 0?void 0:Ot.items.some(function(_n){return _n.isBtn}))||((qt=ea.get(Ce.id))===null||qt===void 0?void 0:qt.content.some(function(_n){return _n.row.c.contract==="native.button.v1"}))});try{for(var xc=Ue(fg),Jo=xc.next();!Jo.done;Jo=xc.next()){var Zn=Jo.value,Gn=Zn.bounds,Fi=(Gn.left+Gn.right)/2,hg=Gn.right-Gn.left;try{for(var _c=(be=void 0,Ue(Ys)),$o=_c.next();!$o.done;$o=_c.next()){var ma=$o.value;if(Vt(ma.row.c).align==="center"&&!(ma.bounds.bottom>Gn.top+6||Gn.top-ma.bounds.bottom>48)){var Ap=ma.bounds.right-ma.bounds.left,Ko=(ma.bounds.left+ma.bounds.right)/2,pg=Math.min(ma.bounds.right,Gn.right)-Math.max(ma.bounds.left,Gn.left);(Ko>=Gn.left&&Ko<=Gn.right||pg>=Ap*.6)&&Ap<=hg+60&&Math.abs(Ko-Fi)>4&&qn("header-off-center","blocker",ma.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:Zn.id,offsetX:Ko-Fi,textCenterX:Ko,panelCenterX:Fi,scale:Yt},Zn.id)}}}catch(_n){be={error:_n}}finally{try{$o&&!$o.done&&(Ee=_c.return)&&Ee.call(_c)}finally{if(be)throw be.error}}}}catch(Ce){xe={error:Ce}}finally{try{Jo&&!Jo.done&&(oe=xc.return)&&oe.call(xc)}finally{if(xe)throw xe.error}}for(var On=0;On<Ys.length;On++)for(var xn=On+1;xn<Ys.length;xn++){var Kt=Ys[On],on=Ys[xn];if(!(Kt.id===on.id||Rr(Kt.row.c,on.row.c.id)||Rr(on.row.c,Kt.row.c.id))){var Si=Math.min(Kt.bounds.right,on.bounds.right)-Math.max(Kt.bounds.left,on.bounds.left),Kn=Math.min(Kt.bounds.bottom,on.bounds.bottom)-Math.max(Kt.bounds.top,on.bounds.top);if(Si>2&&Kn>2&&qn("panel-content-overlap","blocker",Kt.id,"Visible text elements overlap.",{intersection:{width:Si,height:Kn},first:Kt.bounds,second:on.bounds},on.id),Kt.norm&&on.norm){var Ip=De(Kt.norm.length<=on.norm.length?[Kt.norm,on.norm]:[on.norm,Kt.norm],2),Mc=Ip[0],Cp=Ip[1];(Mc===Cp&&Mc.length>=6||Mc.length>=12&&Cp.includes(Mc))&&qn("duplicate-visible-copy","blocker",Kt.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:Kt.raw,second:on.raw},on.id)}}}var va=Ys.filter(function(Ce){return!/^[\d\s/.,:%+\-x]+$/i.test(Ce.raw)}),Sc=va.reduce(function(Ce,Ot){return Ce+(Ot.norm?Ot.norm.split(" ").filter(Boolean).length:0)},0),nf=va.reduce(function(Ce,Ot){return Ce+Ot.raw.replace(/\s+/g," ").length},0);Sc>20||nf>130||va.length>5?qn("text-clutter-heavy","blocker",(at=(Ut=va[0])===null||Ut===void 0?void 0:Ut.id)!==null&&at!==void 0?at:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:va.length,wordCount:Sc,charCount:nf,texts:va.map(function(Ce){return Ce.raw})}):(Sc>12||va.length>4)&&qn("text-clutter-heavy","warning",(Mt=(Wt=va[0])===null||Wt===void 0?void 0:Wt.id)!==null&&Mt!==void 0?Mt:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:va.length,wordCount:Sc,charCount:nf,texts:va.map(function(Ce){return Ce.raw})});var Rp=Pt?Pt.filter(function(Ce){if(Ft.has(Ce))return!1;var Ot=Le(Ce);return Ot?.contract==="native.mesh3d.v1"?!1:!Ot||ii(Ot)}):[];return{ok:!it.some(function(Ce){return Ce.severity==="blocker"})&&Rp.length===0,viewport:gt(gt({},Nt),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight,scale:Yt}),defects:it,missing:Rp,interactive:Mr.map(function(Ce){var Ot;return{id:(Ot=Ce.c.prototypeId)!==null&&Ot!==void 0?Ot:Ce.c.id,bounds:zi(Ce.c,Ce.m)}}),safeArea:Bt}}function Rr(c,x){for(;c.parentId;){if(c.parentId===x)return!0;c=Le(c.parentId)}return!1}function mp(c){for(var x=function(C){if(n.gameplay.some(function(N){var P;return N.kind==="camera-follow"&&N.componentId===((P=C.prototypeId)!==null&&P!==void 0?P:C.id)}))return{value:!0}},R=c;R;R=R.parentId?Le(R.parentId):void 0){var A=x(R);if(typeof A=="object")return A.value}return!1}function fc(c){var x=O(),R=e.getBoundingClientRect(),A=Math.min(R.width/x.width,R.height/x.height);return{x:(c.clientX-R.left-(R.width-x.width*A)/2)/A,y:(c.clientY-R.top-(R.height-x.height*A)/2)/A}}function Qv(c,x){var R,A,C,N;try{try{for(var P=Ue(c.clips),X=P.next();!X.done;X=P.next()){var k=X.value,Z=In(wr(k.matrix),x.x,x.y);if(Z.x<0||Z.y<0||Z.x>k.width||Z.y>k.height)return!1}}catch(oe){R={error:oe}}finally{try{X&&!X.done&&(A=P.return)&&A.call(P)}finally{if(R)throw R.error}}var V=In(wr(c.m),x.x,x.y),$=Vt(c.c);if(c.c.contract==="native.path.v1"){var q=new Path2D,Q=function(oe,be){({M:function(){return q.moveTo.apply(q,Ke([],De(be),!1))},L:function(){return q.lineTo.apply(q,Ke([],De(be),!1))},C:function(){return q.bezierCurveTo.apply(q,Ke([],De(be),!1))},Q:function(){return q.quadraticCurveTo.apply(q,Ke([],De(be),!1))},Z:function(){return q.closePath()}})[oe]()};try{for(var te=Ue($.commands),G=te.next();!G.done;G=te.next()){var ce=De(G.value),me=ce[0],ve=ce.slice(1);Q(me,ve)}}catch(oe){C={error:oe}}finally{try{G&&!G.done&&(N=te.return)&&N.call(te)}finally{if(C)throw C.error}}p.save(),p.setTransform(1,0,0,1,0,0),p.lineWidth=$.strokeWidth;var xe=p.isPointInPath(q,V.x,V.y)||$.strokeWidth>0&&p.isPointInStroke(q,V.x,V.y);return p.restore(),xe}return c.c.contract==="native.ellipse.v1"?Math.pow((V.x-$.width/2)/($.width/2),2)+Math.pow((V.y-$.height/2)/($.height/2),2)<=1:V.x>=0&&V.y>=0&&V.x<=$.width&&V.y<=$.height}catch{return!1}}function Go(c){return Ke([],De(ue),!1).reverse().find(function(x){return x.c.contract!=="native.group.v1"&&x.c.sceneId===J&&Le(x.c.id)&&ii(x.c)&&Qv(x,c)})}function Ho(c){for(var x=[];c;)x.push(c),c=Le(c.parentId);return x}function Jd(){if(!he)return{vx:0,vy:0,power:0,pull:0};var c=he.behavior.parameters,x=he.current.x-he.start.x,R=he.current.y-he.start.y,A=Math.hypot(x,R),C=Math.max(0,Math.min(1,(A-c.minPullPx)/Math.max(1,c.maxPullPx-c.minPullPx))),N=c.minSpeed+(c.maxSpeed-c.minSpeed)*C,P=c.invert?-1:1;return{vx:A?x/A*N*P:0,vy:A?R/A*N*P:0,power:C,pull:A}}function vp(c){if(he){he.current=c;var x=Jd();he.power=x.power,he.behavior.parameters.powerVariableId&&(ne[he.behavior.parameters.powerVariableId]=x.power)}}function $d(c){var x,R;c===void 0&&(c=!1);try{var A=(x=globalThis.AudioContext)!==null&&x!==void 0?x:globalThis.webkitAudioContext;A&&!_t&&(_t=new A,(R=_t.addEventListener)===null||R===void 0||R.call(_t,"statechange",function(){_t?.state==="running"&&Gd()})),Hs(c)}catch{}}function jv(c,x,R){var A,C,N,P,X,k,Z=function(be){var Ee=R.find(function(lt){var Xe;return((Xe=lt.prototypeId)!==null&&Xe!==void 0?Xe:lt.id)===be.componentId});if(!Ee)return"continue";var Ie=In(wr(zn(Ee)),x.x,x.y),Ze=zo(Ee,be);return Ze.stampSegment(Ie,Ie),ft={kind:"mask",pointerId:c.pointerId,c:Ee,behavior:be,last:Ie},(X=e.setPointerCapture)===null||X===void 0||X.call(e,c.pointerId),{value:!0}};try{for(var V=Ue(n.gameplay.filter(function(be){var Ee;return be.kind==="erase-mask"&&((Ee=S.get(be.componentId))===null||Ee===void 0?void 0:Ee.sceneId)===J})),$=V.next();!$.done;$=V.next()){var q=$.value,Q=Z(q);if(typeof Q=="object")return Q.value}}catch(be){A={error:be}}finally{try{$&&!$.done&&(C=V.return)&&C.call(V)}finally{if(A)throw A.error}}if(R.some(function(be){return be.contract==="native.button.v1"||n.events.some(function(Ee){var Ie;return Ee.kind==="click"&&Ee.componentId===((Ie=be.prototypeId)!==null&&Ie!==void 0?Ie:be.id)})}))return!1;try{for(var te=Ue(n.gameplay.filter(function(be){var Ee;return be.kind==="draw-stroke"&&((Ee=S.get(be.componentId))===null||Ee===void 0?void 0:Ee.sceneId)===J})),G=te.next();!G.done;G=te.next()){var q=G.value,ce=S.get(q.componentId),me=wr(zn(ce)),ve=In(me,x.x,x.y),xe=Vt(ce);if(!(ve.x<0||ve.y<0||ve.x>xe.width||ve.y>xe.height)){var oe=Ev(q);return oe.begin(x),ft={kind:"stroke",pointerId:c.pointerId,c:ce,behavior:q,store:oe,last:x},Jt({kind:"strokeStart",componentId:ce.id}),(k=e.setPointerCapture)===null||k===void 0||k.call(e,c.pointerId),!0}}}catch(be){N={error:be}}finally{try{G&&!G.done&&(P=te.return)&&P.call(te)}finally{if(N)throw N.error}}return!1}function eg(c,x,R){var A,C,N,P,X,k,Z,V=R.store.active;if(V){try{for(var $=Ue(n.gameplay.filter(function(Ze){var lt;return Ze.kind==="collider"&&((lt=S.get(Ze.componentId))===null||lt===void 0?void 0:lt.sceneId)===J})),q=$.next();!q.done;q=$.next()){var Q=q.value,te=S.get(Q.componentId);try{for(var G=(N=void 0,Ue(ci(te))),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;!ii(me)||V.hitIds.has(me.id)||Yp(c,x,hp(me,Q.parameters.shape))&&(V.hitIds.add(me.id),Jt(pi("sliceHit",me)))}}catch(Ze){N={error:Ze}}finally{try{ce&&!ce.done&&(P=G.return)&&P.call(G)}finally{if(N)throw N.error}}}}catch(Ze){A={error:Ze}}finally{try{q&&!q.done&&(C=$.return)&&C.call($)}finally{if(A)throw A.error}}try{for(var ve=Ue(tn),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;if(!(oe.broken||!oe.breakable||V.hitIds.has(oe.key))){var be=fn.get(oe.bodyId),Ee=Le(oe.anchorId);if(!(!be||!Ee)){var Ie=xi(Ee);df(c,x,{x:Ie.x,y:Ie.y},{x:be.x,y:be.y})&&(V.hitIds.add(oe.key),oe.broken=!0,D.add(oe.key),Jt({kind:"jointBreak",behaviorId:oe.id,componentId:oe.componentId,selfInstanceId:oe.bodyId,instanceId:(Z=Le(oe.bodyId))===null||Z===void 0?void 0:Z.instanceId}))}}}}catch(Ze){X={error:Ze}}finally{try{xe&&!xe.done&&(k=ve.return)&&k.call(ve)}finally{if(X)throw X.error}}}}function tg(c,x){var R,A=x.last,C=x.behavior.parameters;if(C.inkVariableId){var N=C.inkVariableId,P=Math.hypot(c.x-A.x,c.y-A.y);if(((R=ne[N])!==null&&R!==void 0?R:0)<P)return;ne[N]-=P}x.store.add(c)&&(C.mode==="slice-blade"&&eg(A,c,x),x.last=c)}function ng(c){var x,R;if(!(!ft||ft.pointerId!==c.pointerId)){var A=ft;ft=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,c.pointerId))}catch{}if(A.kind==="stroke"){var C=A.store.end(),N=A.behavior.parameters;if(C){if(N.mode==="physics-wall"){var P=new Set(A.store.strokes.map(function(k){return k.id}));Dt=Dt.filter(function(k){return k.owner!==A.c.id||P.has(k.strokeId)}),Dt.push.apply(Dt,Ke([],De(Zp(C,N.strokeWidth).map(function(k){return gt(gt({},k),{owner:A.c.id})})),!1))}else if(N.mode==="path-trace"){var X=Le(N.followComponentId);X&&C.points.length>1&&Vr.set(X.id,{points:C.points,index:1,speed:N.followSpeed})}}Jt({kind:"strokeEnd",componentId:A.c.id})}}}function ig(c){var x,R,A,C;try{for(var N=Ue(sr.values()),P=N.next();!P.done;P=N.next()){var X=P.value;X.tick(c)}}catch(oe){x={error:oe}}finally{try{P&&!P.done&&(R=N.return)&&R.call(N)}finally{if(x)throw x.error}}try{for(var k=Ue(Vr),Z=k.next();!Z.done;Z=k.next()){var V=De(Z.value,2),$=V[0],q=V[1],Q=Le($);if(!Q){Vr.delete($);continue}var te=q.points[q.index];if(!te){Vr.delete($),Jt(pi("pathArrive",Q));continue}var G=xi(Q),ce=te.x-G.x,me=te.y-G.y,ve=Math.hypot(ce,me),xe=q.speed*c;ve<=xe?(ua(Q,te.x,te.y),q.index++):ve>.001&&ua(Q,G.x+ce/ve*xe,G.y+me/ve*xe)}}catch(oe){A={error:oe}}finally{try{Z&&!Z.done&&(C=k.return)&&C.call(k)}finally{if(A)throw A.error}}}function rg(c,x,R){var A,C,N=[],P=[],X=function($){var q=S.get($.componentId),Q=$.parameters.dragMode==="anywhere"?ci(q).find(function(ce){return ii(ce)}):R.find(function(ce){var me;return((me=ce.prototypeId)!==null&&me!==void 0?me:ce.id)===q.id});if(!Q)return"continue";if($.kind==="swipe-input")P.push({behavior:$,c:Q});else{var te=$.parameters,G=Math.max(te.min,Math.min(te.max,Number(ne[te.variableId])));ne[te.variableId]=G,N.push({behavior:$,c:Q,charge:Op(te,G)}),Jt(pi("holdStart",Q))}};try{for(var k=Ue(n.gameplay.filter(function($){var q;return["swipe-input","hold-charge"].includes($.kind)&&((q=S.get($.componentId))===null||q===void 0?void 0:q.sceneId)===J})),Z=k.next();!Z.done;Z=k.next()){var V=Z.value;X(V)}}catch($){A={error:$}}finally{try{Z&&!Z.done&&(C=k.return)&&C.call(k)}finally{if(A)throw A.error}}(N.length||P.length)&&(ke={pointerId:c.pointerId,start:x,current:x,holds:N,swipes:P})}function ag(c,x){var R,A,C,N,P,X,k,Z;if(!(!ke||ke.pointerId!==c.pointerId)){var V=ke,$=new Set;ke=void 0;try{for(var q=Ue(Ke(Ke([],De(V.holds),!1),De(V.swipes),!1)),Q=q.next();!Q.done;Q=q.next()){var te=Q.value,G=te.behavior,ce=te.c;$.has(G.componentId)||($.add(G.componentId),Jt(pi("pointerUp",ce,void 0,{targetId:ce.id,pointerId:c.pointerId})))}}catch(Xe){R={error:Xe}}finally{try{Q&&!Q.done&&(A=q.return)&&A.call(q)}finally{if(R)throw R.error}}try{for(var me=Ue(V.holds),ve=me.next();!ve.done;ve=me.next()){var xe=ve.value,oe=xe.behavior.parameters;if(Jt(pi("holdRelease",xe.c)),oe.resetOnRelease!==!1){var be=ne[oe.variableId];ne[oe.variableId]=oe.min,be!==oe.min&&Jt({kind:"variableChange",variableId:oe.variableId,selfInstanceId:(k=xe.c.instanceId)!==null&&k!==void 0?k:xe.c.id,instanceId:xe.c.instanceId})}}}catch(Xe){C={error:Xe}}finally{try{ve&&!ve.done&&(N=me.return)&&N.call(me)}finally{if(C)throw C.error}}try{for(var Ee=Ue(V.swipes),Ie=Ee.next();!Ie.done;Ie=Ee.next()){var Ze=Ie.value,lt=Fp(V.start,x,Ze.behavior.parameters.minDistancePx,(Z=Za.get(Ze.behavior.id))!==null&&Z!==void 0?Z:-1/0,_e*1e3,Ze.behavior.parameters.cooldownMs);lt&&(Za.set(Ze.behavior.id,_e*1e3),Jt(pi("swipe",Ze.c,void 0,{direction:lt})))}}catch(Xe){P={error:Xe}}finally{try{Ie&&!Ie.done&&(X=Ee.return)&&X.call(Ee)}finally{if(P)throw P.error}}return $}}function sg(c,x,R){var A,C,N;if(R.some(function(G){return G.contract==="native.button.v1"&&Vt(G).enabled}))return!1;try{for(var P=Ue(n.gameplay.filter(function(G){var ce;return G.kind==="virtual-joystick"&&((ce=S.get(G.componentId))===null||ce===void 0?void 0:ce.sceneId)===J})),X=P.next();!X.done;X=P.next()){var k=X.value,Z=S.get(k.componentId);if(ii(Z)){var V=le.get(k.id);if(!(V&&V.pointerId!==null)){var $=In(wr(zn(Z)),x.x,x.y),q=Vt(Z);if(!($.x<0||$.y<0||$.x>q.width||$.y>q.height)){var Q=k.parameters.mode==="floating"?gt({},x):xi(Z),te=cf(Q,x,k.parameters.radiusPx,k.parameters.deadZone);return V=gt({behavior:k,c:Z,pointerId:c.pointerId,origin:Q,current:x},te),le.set(k.id,V),vr(V),Jt(pi("joystickStart",Z)),(N=e.setPointerCapture)===null||N===void 0||N.call(e,c.pointerId),!0}}}}}catch(G){A={error:G}}finally{try{X&&!X.done&&(C=P.return)&&C.call(P)}finally{if(A)throw A.error}}return!1}var gp=function(c){var x,R,A,C,N,P,X,k,Z,V,$,q,Q;H();var te=fc(c),G=Go(te);if(Je=te,!(!G&&f)){if(f){G&&(w=G.c.id,T((N=G.c.prototypeId)!==null&&N!==void 0?N:G.c.id));return}var ce=n.gameplay.some(function(Bt){return Bt.kind==="virtual-joystick"||Bt.kind==="fps-controller-3d"});if(!(!c.isTrusted||c.button!==void 0&&c.button!==0||!ce&&c.isPrimary===!1||ct||ot||!ce&&(rt&&rt.pointerId!==c.pointerId||ke&&ke.pointerId!==c.pointerId||he&&he.pointerId!==c.pointerId||It&&It.pointerId!==c.pointerId)||_&&(!Ve||!qe))){var me=!je;Re=_e,Ae=!0,je=!0,$d(!0),me&&!wt&&(Tt=Zt=0,xr());var ve=G?Ho(G.c):[];if(sg(c,te,ve)){Tt=Zt=0,wt=!1,xr(),ei();return}if(jv(c,te,ve)){xr(),ei();return}rg(c,te,ve);var xe=jt&&!ve.some(function(Bt){return Bt.contract==="native.button.v1"})?n.gameplay.find(function(Bt){var it;return Bt.kind==="aim-launch-3d"&&((it=S.get(Bt.componentId))===null||it===void 0?void 0:it.sceneId)===J}):void 0;if(xe){var oe=S.get(xe.componentId),be=An("physics-3d",oe.id),Ee=be?oc(oe,be):void 0,Ie=Vd(oe.id),Ze=xe.parameters.dragMode==="anywhere"||Ie&&Math.hypot(te.x-Ie.x,te.y-Ie.y)<=xe.parameters.hitRadiusPx;if(Ee&&Ee.atRest&&!Ee.captured&&Ze){It={behavior:xe,targetId:oe.id,sourceId:oe.id,stageId:xe.parameters.stageId,pointerId:c.pointerId,start:te,current:te,power:0},cp(te),(P=e.setPointerCapture)===null||P===void 0||P.call(e,c.pointerId);return}}var lt=ve.some(function(Bt){return Bt.contract==="native.button.v1"&&Vt(Bt).enabled||n.events.some(function(it){var Ft;return it.kind==="click"&&it.componentId===((Ft=Bt.prototypeId)!==null&&Ft!==void 0?Ft:Bt.id)})});if(jt&&!Qt&&!lt){var Xe=n.gameplay.find(function(Bt){var it;return Bt.kind==="fps-controller-3d"&&Bt.parameters.lookMode!=="none"&&((it=S.get(Bt.componentId))===null||it===void 0?void 0:it.sceneId)===J});if(Xe){var ht=S.get(Xe.componentId),yt=In(wr(zn(ht)),te.x,te.y),Gt=Vt(ht);if(yt.x>=0&&yt.y>=0&&yt.x<=Gt.width&&yt.y<=Gt.height){cc(Xe),Qt={pointerId:c.pointerId,stageId:ht.id,behavior:Xe,last:te},(X=e.setPointerCapture)===null||X===void 0||X.call(e,c.pointerId);return}}}var Ut=n.gameplay.find(function(Bt){return Bt.kind==="aim-launch"&&S.get(Bt.componentId).sceneId===J&&(Bt.parameters.dragMode==="anywhere"&&!ve.some(function(it){return it.contract==="native.button.v1"})||ve.some(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===Bt.componentId}))});if(Ut){var at=S.get(Ut.componentId),Wt=(k=ve.find(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===at.id}))!==null&&k!==void 0?k:ci(at).find(function(it){return ii(it)}),Ee=Wt&&$a(Wt,An("physics-body",at.id));if(Ee&&(!Ut.parameters.onlyWhenAtRest||Ee.atRest)){he={behavior:Ut,targetId:Wt.id,sourceId:at.id,pointerId:c.pointerId,start:te,current:te,power:0},vp(te),(Z=e.setPointerCapture)===null||Z===void 0||Z.call(e,c.pointerId),ei();return}}try{for(var Mt=Ue(ve),mt=Mt.next();!mt.done;mt=Mt.next()){var Qe=mt.value,st=An("press-feedback",(V=Qe.prototypeId)!==null&&V!==void 0?V:Qe.id);st&&(Qe.contract!=="native.button.v1"||Vt(Qe).enabled)&&Fn.set(Qe.id,{behavior:st.parameters,pointerId:c.pointerId,held:!0})}}catch(Bt){x={error:Bt}}finally{try{mt&&!mt.done&&(R=Mt.return)&&R.call(Mt)}finally{if(x)throw x.error}}var We=ve.find(function(Bt){var it;return((it=Dn.get(Bt.id))===null||it===void 0?void 0:it.sceneId)===J});if(We){var tt=xt.get(We.parentId);if(tt?.snapshot().busy)return;Fv(We),tt&&!tt.snapshot().busy&&(En={pointerId:c.pointerId,boardId:We.parentId,tileId:We.id,start:te},($=e.setPointerCapture)===null||$===void 0||$.call(e,c.pointerId))}se=(q=ve.find(function(Bt){return Bt.contract==="native.button.v1"&&Vt(Bt).enabled}))===null||q===void 0?void 0:q.id,mn=se?c.pointerId:void 0;var St=n.gameplay.find(function(Bt){return Bt.kind==="drag"&&ve.some(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===Bt.componentId})});if(St){var Qe=ve.find(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===St.componentId}),Ct=xi(Qe),Pt=Bn.zoneOf(Qe.id);la.set(Qe.id,Ct),Bn.release(Qe.id),rt={b:St,targetId:Qe.id,start:te,current:te,origin:Ct,originZone:Pt,m:Ke([],De(Di(Qe)),!1),pointerId:c.pointerId},Jt(pi("dragStart",Qe)),e.setPointerCapture(c.pointerId)}Tt=Zt=0,wt=!1;try{for(var Nt=Ue(ve),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Qe=Yt.value;(Qe.contract!=="native.button.v1"||Vt(Qe).enabled)&&Jt({kind:"click",componentId:(Q=Qe.prototypeId)!==null&&Q!==void 0?Q:Qe.id,instanceId:Qe.instanceId,targetId:Qe.id,pointerId:c.pointerId})}}catch(Bt){A={error:Bt}}finally{try{Yt&&!Yt.done&&(C=Nt.return)&&C.call(Nt)}finally{if(A)throw A.error}}xr(),ei()}}};function yp(c,x){if(!En||En.pointerId!==c.pointerId)return!1;if(!c.isTrusted||!lr())return!0;var R=En,A=xt.get(R.boardId);if(A.snapshot().busy)return En=void 0,!0;var C=wr(zn(S.get(R.boardId))),N=In(C,R.start.x,R.start.y),P=In(C,x.x,x.y),X=P.x-N.x,k=P.y-N.y,Z=S.get(R.tileId);if(Math.max(Math.abs(X),Math.abs(k))<Math.min(Z.parameters.width,Z.parameters.height)*.35)return!0;var V=Dn.get(Z.id),$=Math.abs(X)>Math.abs(k),q=V.row+($?0:Math.sign(k)),Q=V.column+($?Math.sign(X):0),te=Ke([],De(Dn),!1).find(function(G){var ce=De(G,2),me=ce[1];return me.boardId===R.boardId&&me.row===q&&me.column===Q});return te&&A.swap(Z.id,te[0])&&(yn=void 0,ei()),En=void 0,!0}var xp=function(c){var x,R,A,C;if(!ct){H();var N=O(),P=fc(c);Je=P,ke?.pointerId===c.pointerId&&(ke.current=P);var X=function(Mt){var mt,Qe;if(Mt.pointerId===c.pointerId){var st=P.x-Mt.current.x,We=P.y-Mt.current.y;if(c.isTrusted&&lr())try{for(var tt=(mt=void 0,Ue(n.gameplay.filter(function(Pt){var Nt,Yt;return Pt.kind==="fps-controller-3d"&&Pt.parameters.aimJoystickBehaviorId===Mt.behavior.id&&((Nt=Pt.parameters.aimMode)!==null&&Nt!==void 0?Nt:"delta")==="delta"&&((Yt=S.get(Pt.componentId))===null||Yt===void 0?void 0:Yt.sceneId)===J}))),St=tt.next();!St.done;St=tt.next()){var Ct=St.value;op(Ct,st,We)}}catch(Pt){mt={error:Pt}}finally{try{St&&!St.done&&(Qe=tt.return)&&Qe.call(tt)}finally{if(mt)throw mt.error}}return Object.assign(Mt,{current:P},cf(Mt.origin,P,Mt.behavior.parameters.radiusPx,Mt.behavior.parameters.deadZone)),vr(Mt),ei(),{value:void 0}}};try{for(var k=Ue(le.values()),Z=k.next();!Z.done;Z=k.next()){var V=Z.value,$=X(V);if(typeof $=="object")return $.value}}catch(Mt){x={error:Mt}}finally{try{Z&&!Z.done&&(R=k.return)&&R.call(k)}finally{if(x)throw x.error}}if(ft?.pointerId===c.pointerId){if(ft.kind==="mask"){var q=ft,Q=In(wr(zn(q.c)),P.x,P.y);zo(q.c,q.behavior).stampSegment(q.last,Q),q.last=Q}else tg(P,ft);xr(),ei();return}if(Qt?.pointerId===c.pointerId){c.isTrusted&&lr()&&(op(Qt.behavior,P.x-Qt.last.x,P.y-Qt.last.y),Qt.last=P,ei());return}if(It?.pointerId===c.pointerId){c.isTrusted&&lr()&&cp(P);return}if(he?.pointerId===c.pointerId){c.isTrusted&&lr()&&vp(P),ei();return}var te=Go(P);if(an=te?(A=Ho(te.c).find(function(Mt){return Mt.contract==="native.button.v1"}))===null||A===void 0?void 0:A.id:void 0,!yp(c,P)&&!(!rt||rt.pointerId!==c.pointerId)){var G=Le(rt.targetId);if(!G){Yn();return}var ce=G.parentId?zn(Le(G.parentId)):ga(),me=wr(ce),ve=In(me,rt.start.x,rt.start.y),xe=In(me,P.x,P.y),oe=Ke([],De(rt.m),!1),be=rt.b.parameters.axis;if(be!=="y"){var Ee=rt.m[4]+xe.x-ve.x;Number.isFinite(rt.b.parameters.minX)&&(Ee=Math.max(rt.b.parameters.minX,Ee)),Number.isFinite(rt.b.parameters.maxX)&&(Ee=Math.min(rt.b.parameters.maxX,Ee)),oe[4]=Ee}if(be!=="x"){var Ie=rt.m[5]+xe.y-ve.y;Number.isFinite(rt.b.parameters.minY)&&(Ie=Math.max(rt.b.parameters.minY,Ie)),Number.isFinite(rt.b.parameters.maxY)&&(Ie=Math.min(rt.b.parameters.maxY,Ie)),oe[5]=Ie}if(!G.parentId)be!=="y"&&(oe[4]=Math.max(0,Math.min(N.width-G.parameters.width,oe[4])));else{var Ze=zi(G,qs(ce,oe)),lt=0;Ze.left<0||Ze.right-Ze.left>N.width?lt=-Ze.left:Ze.right>N.width&&(lt=N.width-Ze.right);var Xe=be==="y"?0:ce[0],ht=be==="x"?0:ce[2];Math.abs(Xe)>=Math.abs(ht)&&Math.abs(Xe)>1e-8?oe[4]+=lt/Xe:Math.abs(ht)>1e-8&&(oe[5]+=lt/ht)}var yt=(C=He.get(G.id))!==null&&C!==void 0?C:{parameters:{}};He.set(G.id,gt(gt({},yt),{transform:oe})),rt.current=P;var Gt=Wd(G),Ut=Gt.zones,at=Gt.tag,Wt=wc({itemId:G.id,tag:at,zones:Ut,occupancy:Bn});et=Wt&&Wt.kind!=="reject"?Wt.zone:void 0}}},_p=function(c){var x,R,A,C,N;H();var P=fc(c),X=ye;Je=P,Mn(c.pointerId,!0),Li(c.pointerId),ng(c);var k=(A=ag(c,P))!==null&&A!==void 0?A:new Set;if(Ov(c),c.isTrusted&&lr()){var Z=Go(P);try{for(var V=Ue(Z?Ho(Z.c):[]),$=V.next();!$.done;$=V.next()){var q=$.value;!k.has((C=q.prototypeId)!==null&&C!==void 0?C:q.id)&&(q.contract!=="native.button.v1"||Vt(q).enabled)&&Jt(pi("pointerUp",q,void 0,{targetId:q.id,pointerId:c.pointerId}))}}catch(ve){x={error:ve}}finally{try{$&&!$.done&&(R=V.return)&&R.call(V)}finally{if(x)throw x.error}}}if(xr(),ei(),It?.pointerId===c.pointerId){var Q=It,te=lp(),G=$t.get(Q.targetId);(N=jt?.getStage(S.get(Q.stageId)))===null||N===void 0||N.setGuide([]),It=void 0,Q.behavior.parameters.powerVariableId&&(ne[Q.behavior.parameters.powerVariableId]=0);var ce=Math.hypot(te.vx,te.vz);c.isTrusted&&$d(!0),G&&c.isTrusted&&lr()&&te.pull>=Q.behavior.parameters.minPullPx&&ce>=Q.behavior.parameters.minSpeed&&(G.vx=te.vx,G.vy=0,G.vz=te.vz,G.atRest=!1,G.restElapsed=0,G.movingTime=0,G.captured=!1,G.lastSafe={x:G.x,y:G.y,z:G.z},Jt({kind:"launch",componentId:Q.sourceId})),Zi(c),xr();return}if(he?.pointerId===c.pointerId){var Q=he,te=Jd(),G=fn.get(Q.targetId);he=void 0,Q.behavior.parameters.powerVariableId&&(ne[Q.behavior.parameters.powerVariableId]=0),G&&c.isTrusted&&lr()&&te.pull>=Q.behavior.parameters.minPullPx&&(G.vx=te.vx,G.vy=te.vy,G.atRest=!1,G.restElapsed=0,G.captured=!1,G.exited=!1,Jt({kind:"launch",componentId:Q.sourceId,instanceId:G.instanceId})),Zi(c),xr(),ei();return}if(yp(c,P),En?.pointerId===c.pointerId&&(En=void 0),Zi(c),!(F||X?.pointerId!==c.pointerId||!c.isTrusted||!lr()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!Ja(X.condition))){var me=Go(P);!me||!Ho(me.c).some(function(ve){return ve.id===X.targetId&&(ve.contract!=="native.button.v1"||Vt(ve).enabled)})||(_?_.openStore(n.base.storeUrl):window.open(n.base.storeUrl,"_blank","noopener"))}},hc=function(c){var x,R;if(It?.pointerId===c.pointerId&&or(c.pointerId),Qt?.pointerId===c.pointerId&&Li(c.pointerId),Mn(c.pointerId,!0),he?.pointerId===c.pointerId&&(he.behavior.parameters.powerVariableId&&(ne[he.behavior.parameters.powerVariableId]=0),he=void 0),En?.pointerId===c.pointerId&&(En=void 0),ft?.pointerId===c.pointerId&&(ft.kind==="stroke"&&ft.store.cancel(),ft=void 0),ke?.pointerId===c.pointerId){try{for(var A=Ue(ke.holds),C=A.next();!C.done;C=A.next()){var N=C.value;N.behavior.parameters.resetOnRelease!==!1&&(ne[N.behavior.parameters.variableId]=N.behavior.parameters.min)}}catch(P){x={error:P}}finally{try{C&&!C.done&&(R=A.return)&&R.call(A)}finally{if(x)throw x.error}}ke=void 0}Zi(c)},Mp=function(c){c?.isTrusted&&!f&&!ct&&!ot&&$d(!0)},Kd=function(){pt||ei()},Ka=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver(Kd):void 0;try{(s=Ka?.observe)===null||s===void 0||s.call(Ka,e)}catch{}var Sp=function(){ut=0,zt=0,document.hidden&&gr(),_t&&(document.hidden?_t.suspend().catch(function(){}):!ct&&je&&Hs())};document.addEventListener("visibilitychange",Sp),(o=globalThis.addEventListener)===null||o===void 0||o.call(globalThis,"resize",Kd),e.addEventListener("pointerdown",gp),e.addEventListener("pointermove",xp),e.addEventListener("pointerup",_p),e.addEventListener("pointercancel",hc),e.addEventListener("lostpointercapture",hc),e.addEventListener("click",Mp);var Qd=_?.onVisibilityChanged(function(c){qe=c,ut=0,zt=0,c||gr(),_t&&(c?!ct&&je&&Hs():_t.suspend().catch(function(){}))}),jd=_?.onClosed(function(){ot=!0,ut=0,zt=0,gr(),pn()}),ef=(u=_?.onVolumeChanged)===null||u===void 0?void 0:u.call(_,function(c){typeof c=="number"&&Number.isFinite(c)&&c>=0&&(Yi=Math.min(1,c>1?c/100:c),Hd())}),Ji,La;function bp(c){var x=!f&&!ct&&!document.hidden&&Ve&&qe&&!ot;if(x&&zt&&(Ge+=Math.min((c-zt)/1e3,5/60)),lr()){Tt=Zt=0,wt=!1,zt&&(ut+=Math.min((c-zt)/1e3,5/60));for(var R=0;R<5&&ut>=1/60;R++)La?.(),pp(1/60),ut-=1/60;xr(),Ji?.()&&(ct=!0,Ji=void 0,La=void 0)}else ut=0;zt=c,ei(),nn=requestAnimationFrame(bp)}uc(),f&&(J=v),ei(),nn=requestAnimationFrame(bp),_&&_.init().then(function(){pt||(Ve=!0,qe=_.isVisible(),ut=0,zt=0)}).catch(function(){pt||(ot=!0,gr(),pn())});var og=F?{freezeReview:function(){ct=!0,Ji=void 0,La=void 0,ut=0,zt=0,yi(),Yn(),En=void 0,_t?.suspend().catch(function(){}),ei()},seekReview:function(c,x){var R,A,C,N,P=x===void 0?{}:x,X=P.motion,k=X===void 0?!1:X,Z=P.trustedEvent;ct=!0,Ji=void 0,La=void 0,uc();var V=xt.get("harvest.board"),$=k&&Z instanceof globalThis.Event&&Z.isTrusted,q=function(){var We=_t;_t=void 0;try{Tt=Zt=0,wt=!1,pp(1/60),xr()}finally{_t=We}},Q=function(){var We;if($)try{var tt=(We=globalThis.AudioContext)!==null&&We!==void 0?We:globalThis.webkitAudioContext;tt&&(_t??(_t=new tt)),Hs()}catch{}ut=0,zt=0,ct=!1,ei()};if(S.has("salvage.ship")&&Object.hasOwn(ne,"salvage.phase")){if(!["opening","first-catch","end-card","timeout"].includes(c))throw Error("Review moment unavailable");var te=S.get("salvage.ship"),G=function(We){var tt,St=Te.filter(function(Nt){return Nt.prototypeId.startsWith("salvage.core")}).sort(function(Nt,Yt){return Yt.transform[5]-Nt.transform[5]})[0],Ct=He.get(te.id),Pt=Ke([],De((tt=Ct?.transform)!==null&&tt!==void 0?tt:te.transform),!1);Pt[4]=We&&St?Math.max(20,Math.min(306,St.transform[4]-8)):20,He.set(te.id,gt(gt({},Ct),{transform:Pt,parameters:gt(gt({},Ct?.parameters),{visible:We})}))},ce,me,ve=function(){return ne["salvage.phase"]!=="cta"?!1:(ce??(ce=_e),_e-ce>=.65)};if(c==="opening"){if(k){Ji=function(){return _e>=4},Q();return}ei();return}if(c==="timeout"){var xe=(R=n.gameplay.find(function(We){return We.id==="salvage.deadline"}))===null||R===void 0?void 0:R.parameters.seconds;if(!Number.isFinite(xe))throw Error("Timeout replay unavailable");if(G(!1),k){for(;_e<xe-.25&&ne["salvage.phase"]!=="cta";)G(!1),q();if(ne["salvage.phase"]==="cta")throw Error("Timeout replay unavailable");La=function(){ne["salvage.phase"]!=="cta"&&G(!1)},Ji=function(){return ve()||_e>=xe+1},Q();return}for(var oe=0;ne["salvage.phase"]!=="cta"&&oe<3600;oe++)G(!1),q();if(ne["salvage.phase"]!=="cta")throw Error("Timeout card unavailable");ei();return}var be=c==="first-catch"?1:3;if(k){for(var oe=0;ne["salvage.catches"]<be-1&&oe<3600;oe++)G(!0),q();if(ne["salvage.catches"]!==be-1)throw Error("Review replay unavailable");La=function(){ne["salvage.catches"]<be&&G(!0)},Ji=function(){return be===1&&ne["salvage.catches"]>=1?(me??(me=_e),_e-me>=1):be===3&&ve()||_e>=20},Q();return}for(var oe=0;ne["salvage.catches"]<be&&oe<3600;oe++)G(!0),q();if(ne["salvage.catches"]!==be)throw Error("Review catch unavailable");if(be===1)for(var oe=0;oe<84;oe++)q();else{for(var oe=0;ne["salvage.phase"]!=="cta"&&oe<300;oe++)q();if(ne["salvage.phase"]!=="cta")throw Error("End card unavailable")}ei();return}if(!V){if(!["opening","first-input","end-card","timeout"].includes(c))throw Error("Review moment unavailable");if(c==="opening"){k?(Ji=function(){return _e>=4},Q()):ei();return}var Ee=n.gameplay.find(function(We){return We.kind==="aim-launch"&&S.get(We.componentId).sceneId===J}),Ie=n.gameplay.find(function(We){return We.kind==="aim-launch-3d"&&S.get(We.componentId).sceneId===J}),Ze=n.events.find(function(We){var tt;return We.kind==="click"&&((tt=S.get(We.componentId))===null||tt===void 0?void 0:tt.sceneId)===J&&n.eventBindings.some(function(St){return St.eventId===We.id})}),lt=function(){var We,tt;if(Ie){var St=S.get(Ie.componentId),Ct=An("physics-3d",St.id),Pt=oc(St,Ct),Nt=n.gameplay.find(function(ai){return ai.kind==="capture-zone-3d"&&S.get(ai.componentId).sceneId===J}),Yt=0,Bt=-Ie.parameters.maxSpeed*.45;if(Nt){var it=S.get(Nt.componentId),Ft=Vt(it),Cn=((We=Ft.x)!==null&&We!==void 0?We:0)-Pt.x,bn=((tt=Ft.z)!==null&&tt!==void 0?tt:0)-Pt.z,_i=Math.hypot(Cn,bn)||1;Yt=Cn/_i*Ie.parameters.maxSpeed*.55,Bt=bn/_i*Ie.parameters.maxSpeed*.55}Pt.vx=Yt,Pt.vy=0,Pt.vz=Bt,Pt.atRest=!1,Pt.restElapsed=0,Pt.movingTime=0,Pt.lastSafe={x:Pt.x,y:Pt.y,z:Pt.z},Jt({kind:"launch",componentId:St.id}),xr();return}if(Ee){var St=S.get(Ee.componentId),ri=ci(St)[0],Pt=$a(ri,An("physics-body",St.id)),Nt=n.gameplay.find(function(Ii){return Ii.kind==="capture-zone"&&S.get(Ii.componentId).sceneId===J}),Yt=Ee.parameters.maxSpeed*.45,wn=0;if(Nt){var it=S.get(Nt.componentId),Rn=In(zn(it),Vt(it).width/2,Vt(it).height/2),Cn=Rn.x-Pt.x,Hn=Rn.y-Pt.y,si=Math.hypot(Cn,Hn)||1;Yt=Cn/si*Ee.parameters.maxSpeed*.45,wn=Hn/si*Ee.parameters.maxSpeed*.45}Pt.vx=Yt,Pt.vy=wn,Pt.atRest=!1,Pt.restElapsed=0,Jt({kind:"launch",componentId:St.id,instanceId:ri.instanceId})}else if(Ze)Jt({kind:"click",componentId:Ze.componentId,targetId:Ze.componentId});else throw Error("Review primary input unavailable");xr()};if(c==="first-input"){if(lt(),k)Ji=function(){return _e>=2},Q();else{for(var oe=0;oe<60;oe++)q();ei()}return}c==="end-card"&<();var Xe=c==="timeout"?Math.min(60,Math.max(1,(C=(A=n.gameplay.find(function(We){return We.kind==="timer"}))===null||A===void 0?void 0:A.parameters.seconds)!==null&&C!==void 0?C:10)):60,ht=function(){var We;return((We=n.scenes.find(function(tt){return tt.id===J}))===null||We===void 0?void 0:We.role)==="end-card"},yt=function(){var We,tt;return c==="timeout"?(We=n.scenes.find(function(St){return St.role==="end-card"&&/fail|loss|timeout/i.test(St.id)}))!==null&&We!==void 0?We:n.scenes.find(function(St){return St.role==="end-card"}):(tt=n.scenes.find(function(St){return St.role==="end-card"&&!/fail|loss|timeout/i.test(St.id)}))!==null&&tt!==void 0?tt:n.scenes.find(function(St){return St.role==="end-card"})};if(k){Ji=function(){return ht()&&_e>=1||_e>=Xe+1},Q();return}for(var oe=0;oe<Xe*60&&!ht();oe++)q();if(!ht()||c==="timeout"&&!/fail|loss|timeout/i.test(J)||c==="end-card"&&/fail|loss|timeout/i.test(J)){var Gt=yt();if(!Gt)throw Error("End card unavailable");J=Gt.id,he=void 0,gr(),Jt({kind:"sceneEnter",sceneId:J}),xr()}for(var oe=0;oe<45;oe++)q();ei();return}var Ut,at=function(){return ne["harvest.phase"]!=="cta"?!1:(Ut??(Ut=_e),_e-Ut>=.65)};if(c==="opening"&&k&&(Ji=function(){return _e>=7},ut=0,zt=0,ct=!1),c==="timeout"){if(!V)throw Error("Review moment unavailable");if(k){var Wt=(N=n.gameplay.find(function(We){return We.id==="harvest.deadline"}))===null||N===void 0?void 0:N.parameters.seconds;if(!Number.isFinite(Wt))throw Error("Timeout replay unavailable");for(;_e<Wt-.25&&ne["harvest.phase"]!=="cta";)q();if(ne["harvest.phase"]==="cta")throw Error("Timeout replay unavailable");Ji=function(){return at()||_e>=Wt+1},Q();return}for(var oe=0;ne["harvest.phase"]!=="cta"&&oe<3600;oe++)q();if(ne["harvest.phase"]!=="cta")throw Error("Timeout card unavailable")}else if(c!=="opening"){if(!V||!["first-harvest","end-card"].includes(c))throw Error("Review moment unavailable");for(var Mt=c==="first-harvest"?1:3,mt=function(We){var tt=V.snapshot().legalMoves[0];if(!tt||!V.swap(tt.from,tt.to))throw Error("Review move unavailable");if(k&&We===Mt-1){var St=_e+(Mt===1?3:8);return Ji=function(){return _e>=St||Mt===3&&at()},Q(),{value:void 0}}for(var Ct=0;V.snapshot().busy&&Ct<240;Ct++)q();if(V.snapshot().busy)throw Error("Review replay did not settle")},Qe=0;Qe<Mt;Qe++){var st=mt(Qe);if(typeof st=="object")return st.value}if(Mt===1)for(var oe=0;oe<84;oe++)q();else{for(var oe=0;ne["harvest.phase"]!=="cta"&&oe<300;oe++)q();if(ne["harvest.phase"]!=="cta")throw Error("End card unavailable")}}ei()},pickReview:function(c,x){var R=Go(fc({clientX:c,clientY:x}));return R?Ho(R.c).map(function(A){var C;return(C=A.prototypeId)!==null&&C!==void 0?C:A.id}):[]},reviewBounds:function(c){var x=O(),R=e.clientWidth,A=e.clientHeight,C=Math.min(R/x.width,A/x.height);return ue.filter(function(N){return c.includes(N.c.id)}).map(function(N){var P=zi(N.c,N.m);return{left:(R-x.width*C)/2+P.left*C,top:(A-x.height*C)/2+P.top*C,width:(P.right-P.left)*C,height:(P.bottom-P.top)*C}})}}:void 0;return gt(gt({},og),{state:ca,auditViewport:$v,auditSceneLayout:Kv,restart:function(){var c;Ji=void 0,La=void 0,(c=_?.notifyGameRetry)===null||c===void 0||c.call(_),uc(),ei()},select:function(c){w=c},inspectScene:function(c){f&&n.scenes.some(function(x){return x.id===c})&&(J=c,w=void 0)},pause:function(c){ct=c,ut=0,zt=0,c&&gr(),_t&&(c?_t.suspend().catch(function(){}):je&&Hs())},destroy:function(){var c,x;pt=!0,cancelAnimationFrame(nn),gr(),pn(),jt?.dispose(),Qd?.(),jd?.(),ef?.(),_?.destroy(),(c=Ka?.disconnect)===null||c===void 0||c.call(Ka),document.removeEventListener("visibilitychange",Sp),(x=globalThis.removeEventListener)===null||x===void 0||x.call(globalThis,"resize",Kd),e.removeEventListener("pointerdown",gp),e.removeEventListener("pointermove",xp),e.removeEventListener("pointerup",_p),e.removeEventListener("pointercancel",hc),e.removeEventListener("lostpointercapture",hc),e.removeEventListener("click",Mp),_t?.close().catch(function(){})}})}return _g(ew);})();
|
|
4220
|
+
}`,Np=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let i=new cc(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 na({vertexShader:hw,fragmentShader:pw,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new li(new gc(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Up=class extends Wa{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,p=null,y=null,M=typeof XRWebGLBinding<"u",v=new Np,m={},N=t.getContextAttributes(),P=null,_=null,g=[],b=[],z=new Kt,T=null,D=null,G=new Er;G.viewport=new Ti;let F=new Er;F.viewport=new Ti;let $=[G,F],A=new Sd,S=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(le){let ae=g[le];return ae===void 0&&(ae=new Qo,g[le]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(le){let ae=g[le];return ae===void 0&&(ae=new Qo,g[le]=ae),ae.getGripSpace()},this.getHand=function(le){let ae=g[le];return ae===void 0&&(ae=new Qo,g[le]=ae),ae.getHandSpace()};function Y(le){let ae=b.indexOf(le.inputSource);if(ae===-1)return;let fe=g[ae];fe!==void 0&&(fe.update(le.inputSource,le.frame,l||s),fe.dispatchEvent({type:le.type,data:le.inputSource}))}function oe(){r.removeEventListener("select",Y),r.removeEventListener("selectstart",Y),r.removeEventListener("selectend",Y),r.removeEventListener("squeeze",Y),r.removeEventListener("squeezestart",Y),r.removeEventListener("squeezeend",Y),r.removeEventListener("end",oe),r.removeEventListener("inputsourceschange",O);for(let le=0;le<g.length;le++){let ae=b[le];ae!==null&&(b[le]=null,g[le].disconnect(ae))}S=null,H=null,v.reset();for(let le in m)delete m[le];if(e.setRenderTarget(P),p=null,h=null,f=null,r=null,_=null,Pe.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(z.width,z.height,!1),D!==null){let le=D.camera;le.fov=D.fov,le.zoom=D.zoom,le.updateProjectionMatrix(),D=null}i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(le){a=le,i.isPresenting===!0&&xn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(le){o=le,i.isPresenting===!0&&xn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(le){l=le},this.getBaseLayer=function(){return h!==null?h:p},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(le){if(r=le,r!==null){if(P=e.getRenderTarget(),r.addEventListener("select",Y),r.addEventListener("selectstart",Y),r.addEventListener("selectend",Y),r.addEventListener("squeeze",Y),r.addEventListener("squeezestart",Y),r.addEventListener("squeezeend",Y),r.addEventListener("end",oe),r.addEventListener("inputsourceschange",O),N.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(z),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let fe=null,Ne=null,Re=null;N.depth&&(Re=N.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,fe=N.stencil?Ns:Ha,Ne=N.stencil?ml:Pa);let We={colorFormat:t.RGBA8,depthFormat:Re,scaleFactor:a};f=this.getBinding(),h=f.createProjectionLayer(We),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),_=new Gr(h.textureWidth,h.textureHeight,{format:aa,type:Xr,depthTexture:new Cs(h.textureWidth,h.textureHeight,Ne,void 0,void 0,void 0,void 0,void 0,void 0,fe),stencilBuffer:N.stencil,colorSpace:e.outputColorSpace,samples:N.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let fe={antialias:N.antialias,alpha:!0,depth:N.depth,stencil:N.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(r,t,fe),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),_=new Gr(p.framebufferWidth,p.framebufferHeight,{format:aa,type:Xr,colorSpace:e.outputColorSpace,stencilBuffer:N.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1,storeMultisampledDepthBuffer:p.ignoreDepthValues===!1,storeMultisampledStencilBuffer:p.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 v.getDepthTexture()};function O(le){for(let ae=0;ae<le.removed.length;ae++){let fe=le.removed[ae],Ne=b.indexOf(fe);Ne>=0&&(b[Ne]=null,g[Ne].disconnect(fe))}for(let ae=0;ae<le.added.length;ae++){let fe=le.added[ae],Ne=b.indexOf(fe);if(Ne===-1){for(let We=0;We<g.length;We++)if(We>=b.length){b.push(fe),Ne=We;break}else if(b[We]===null){b[We]=fe,Ne=We;break}if(Ne===-1)break}let Re=g[Ne];Re&&Re.connect(fe)}}let k=new _e,ne=new _e;function X(le,ae,fe){k.setFromMatrixPosition(ae.matrixWorld),ne.setFromMatrixPosition(fe.matrixWorld);let Ne=k.distanceTo(ne),Re=ae.projectionMatrix.elements,We=fe.projectionMatrix.elements,Qe=Re[14]/(Re[10]-1),ke=Re[14]/(Re[10]+1),qe=(Re[9]+1)/Re[5],ft=(Re[9]-1)/Re[5],tt=(Re[8]-1)/Re[0],st=(We[8]+1)/We[0],Ke=Qe*tt,en=Qe*st,nt=Ne/(-tt+st),on=nt*-tt;if(ae.matrixWorld.decompose(le.position,le.quaternion,le.scale),le.translateX(on),le.translateZ(nt),le.matrixWorld.compose(le.position,le.quaternion,le.scale),le.matrixWorldInverse.copy(le.matrixWorld).invert(),Re[10]===-1)le.projectionMatrix.copy(ae.projectionMatrix),le.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{let ue=Qe+nt,hn=ke+nt,gn=Ke-on,J=en+(Ne-on),w=qe*ke/hn*ue,ie=ft*ke/hn*ue;le.projectionMatrix.makePerspective(gn,J,w,ie,ue,hn),le.projectionMatrixInverse.copy(le.projectionMatrix).invert()}}function K(le,ae){ae===null?le.matrixWorld.copy(le.matrix):le.matrixWorld.multiplyMatrices(ae.matrixWorld,le.matrix),le.matrixWorldInverse.copy(le.matrixWorld).invert()}this.updateCamera=function(le){if(r===null)return;let ae=le.near,fe=le.far;v.texture!==null&&(v.depthNear>0&&(ae=v.depthNear),v.depthFar>0&&(fe=v.depthFar)),A.near=F.near=G.near=ae,A.far=F.far=G.far=fe,(S!==A.near||H!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),S=A.near,H=A.far),A.layers.mask=le.layers.mask|6,G.layers.mask=A.layers.mask&-5,F.layers.mask=A.layers.mask&-3;let Ne=le.parent,Re=A.cameras;K(A,Ne);for(let We=0;We<Re.length;We++)K(Re[We],Ne);Re.length===2?X(A,G,F):A.projectionMatrix.copy(G.projectionMatrix),D===null&&le.isPerspectiveCamera&&(D={camera:le,fov:le.fov,zoom:le.zoom}),ge(le,A,Ne)};function ge(le,ae,fe){fe===null?le.matrix.copy(ae.matrixWorld):(le.matrix.copy(fe.matrixWorld),le.matrix.invert(),le.matrix.multiply(ae.matrixWorld)),le.matrix.decompose(le.position,le.quaternion,le.scale),le.updateMatrixWorld(!0),le.projectionMatrix.copy(ae.projectionMatrix),le.projectionMatrixInverse.copy(ae.projectionMatrixInverse),le.isPerspectiveCamera&&(le.fov=$u*2*Math.atan(1/le.projectionMatrix.elements[5]),le.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(h===null&&p===null))return u},this.setFoveation=function(le){u=le,h!==null&&(h.fixedFoveation=le),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=le)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(A)},this.getCameraTexture=function(le){return m[le]};let se=null;function Se(le,ae){if(d=ae.getViewerPose(l||s),y=ae,d!==null){let fe=d.views;p!==null&&(e.setRenderTargetFramebuffer(_,p.framebuffer),e.setRenderTarget(_));let Ne=!1;fe.length!==A.cameras.length&&(A.cameras.length=0,Ne=!0);for(let ke=0;ke<fe.length;ke++){let qe=fe[ke],ft=null;if(p!==null)ft=p.getViewport(qe);else{let st=f.getViewSubImage(h,qe);ft=st.viewport,ke===0&&(e.setRenderTargetTextures(_,st.colorTexture,st.depthStencilTexture),e.setRenderTarget(_))}let tt=$[ke];tt===void 0&&(tt=new Er,tt.layers.enable(ke),tt.viewport=new Ti,$[ke]=tt),tt.matrix.fromArray(qe.transform.matrix),tt.matrix.decompose(tt.position,tt.quaternion,tt.scale),tt.projectionMatrix.fromArray(qe.projectionMatrix),tt.projectionMatrixInverse.copy(tt.projectionMatrix).invert(),tt.viewport.set(ft.x,ft.y,ft.width,ft.height),ke===0&&(A.matrix.copy(tt.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),Ne===!0&&A.cameras.push(tt)}let Re=r.enabledFeatures;if(Re&&Re.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&M){f=i.getBinding();let ke=f.getDepthInformation(fe[0]);ke&&ke.isValid&&ke.texture&&v.init(ke,r.renderState)}if(Re&&Re.includes("camera-access")&&M){e.state.unbindTexture(),f=i.getBinding();for(let ke=0;ke<fe.length;ke++){let qe=fe[ke].camera;if(qe){let ft=m[qe];ft||(ft=new cc,m[qe]=ft);let tt=f.getCameraImage(qe);ft.sourceTexture=tt}}}}for(let fe=0;fe<g.length;fe++){let Ne=b[fe],Re=g[fe];Ne!==null&&Re!==void 0&&Re.update(Ne,ae,l||s)}se&&se(le,ae),ae.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ae}),y=null}let Pe=new z0;Pe.setAnimationLoop(Se),this.setAnimationLoop=function(le){se=le},this.dispose=function(){}}},mw=new Dn,Y0=new Ln;Y0.set(-1,0,0,0,1,0,0,0,1);function vw(n,e){function t(v,m){v.matrixAutoUpdate===!0&&v.updateMatrix(),m.value.copy(v.matrix)}function i(v,m){m.color.getRGB(v.fogColor.value,fp(n)),m.isFog?(v.fogNear.value=m.near,v.fogFar.value=m.far):m.isFogExp2&&(v.fogDensity.value=m.density)}function r(v,m,N,P,_){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?a(v,m):m.isMeshLambertMaterial?(a(v,m),m.envMap&&(v.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(a(v,m),f(v,m)):m.isMeshPhongMaterial?(a(v,m),d(v,m),m.envMap&&(v.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(a(v,m),h(v,m),m.isMeshPhysicalMaterial&&p(v,m,_)):m.isMeshMatcapMaterial?(a(v,m),y(v,m)):m.isMeshDepthMaterial?a(v,m):m.isMeshDistanceMaterial?(a(v,m),M(v,m)):m.isMeshNormalMaterial?a(v,m):m.isLineBasicMaterial?(s(v,m),m.isLineDashedMaterial&&o(v,m)):m.isPointsMaterial?u(v,m,N,P):m.isSpriteMaterial?l(v,m):m.isShadowMaterial?(v.color.value.copy(m.color),v.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function a(v,m){v.opacity.value=m.opacity,m.color&&v.diffuse.value.copy(m.color),m.emissive&&v.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(v.map.value=m.map,t(m.map,v.mapTransform)),m.alphaMap&&(v.alphaMap.value=m.alphaMap,t(m.alphaMap,v.alphaMapTransform)),m.bumpMap&&(v.bumpMap.value=m.bumpMap,t(m.bumpMap,v.bumpMapTransform),v.bumpScale.value=m.bumpScale,m.side===Fr&&(v.bumpScale.value*=-1)),m.normalMap&&(v.normalMap.value=m.normalMap,t(m.normalMap,v.normalMapTransform),v.normalScale.value.copy(m.normalScale),m.side===Fr&&v.normalScale.value.negate()),m.displacementMap&&(v.displacementMap.value=m.displacementMap,t(m.displacementMap,v.displacementMapTransform),v.displacementScale.value=m.displacementScale,v.displacementBias.value=m.displacementBias),m.emissiveMap&&(v.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,v.emissiveMapTransform)),m.specularMap&&(v.specularMap.value=m.specularMap,t(m.specularMap,v.specularMapTransform)),m.alphaTest>0&&(v.alphaTest.value=m.alphaTest);let N=e.get(m),P=N.envMap,_=N.envMapRotation;P&&(v.envMap.value=P,v.envMapRotation.value.setFromMatrix4(mw.makeRotationFromEuler(_)).transpose(),P.isCubeTexture&&P.isRenderTargetTexture===!1&&v.envMapRotation.value.premultiply(Y0),v.reflectivity.value=m.reflectivity,v.ior.value=m.ior,v.refractionRatio.value=m.refractionRatio),m.lightMap&&(v.lightMap.value=m.lightMap,v.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,v.lightMapTransform)),m.aoMap&&(v.aoMap.value=m.aoMap,v.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,v.aoMapTransform))}function s(v,m){v.diffuse.value.copy(m.color),v.opacity.value=m.opacity,m.map&&(v.map.value=m.map,t(m.map,v.mapTransform))}function o(v,m){v.dashSize.value=m.dashSize,v.totalSize.value=m.dashSize+m.gapSize,v.scale.value=m.scale}function u(v,m,N,P){v.diffuse.value.copy(m.color),v.opacity.value=m.opacity,v.size.value=m.size*N,v.scale.value=P*.5,m.map&&(v.map.value=m.map,t(m.map,v.uvTransform)),m.alphaMap&&(v.alphaMap.value=m.alphaMap,t(m.alphaMap,v.alphaMapTransform)),m.alphaTest>0&&(v.alphaTest.value=m.alphaTest)}function l(v,m){v.diffuse.value.copy(m.color),v.opacity.value=m.opacity,v.rotation.value=m.rotation,m.map&&(v.map.value=m.map,t(m.map,v.mapTransform)),m.alphaMap&&(v.alphaMap.value=m.alphaMap,t(m.alphaMap,v.alphaMapTransform)),m.alphaTest>0&&(v.alphaTest.value=m.alphaTest)}function d(v,m){v.specular.value.copy(m.specular),v.shininess.value=Math.max(m.shininess,1e-4)}function f(v,m){m.gradientMap&&(v.gradientMap.value=m.gradientMap)}function h(v,m){v.metalness.value=m.metalness,m.metalnessMap&&(v.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,v.metalnessMapTransform)),v.roughness.value=m.roughness,m.roughnessMap&&(v.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,v.roughnessMapTransform)),m.envMap&&(v.envMapIntensity.value=m.envMapIntensity)}function p(v,m,N){v.ior.value=m.ior,m.sheen>0&&(v.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),v.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(v.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,v.sheenColorMapTransform)),m.sheenRoughnessMap&&(v.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,v.sheenRoughnessMapTransform))),m.clearcoat>0&&(v.clearcoat.value=m.clearcoat,v.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(v.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,v.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(v.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Fr&&v.clearcoatNormalScale.value.negate())),m.dispersion>0&&(v.dispersion.value=m.dispersion),m.retroreflectivity>0&&(v.retroreflectivity.value=m.retroreflectivity),m.iridescence>0&&(v.iridescence.value=m.iridescence,v.iridescenceIOR.value=m.iridescenceIOR,v.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(v.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,v.iridescenceMapTransform)),m.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),m.transmission>0&&(v.transmission.value=m.transmission,v.transmissionSamplerMap.value=N.texture,v.transmissionSamplerSize.value.set(N.width,N.height),m.transmissionMap&&(v.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,v.transmissionMapTransform)),v.thickness.value=m.thickness,m.thicknessMap&&(v.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=m.attenuationDistance,v.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(v.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(v.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=m.specularIntensity,v.specularColor.value.copy(m.specularColor),m.specularColorMap&&(v.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,v.specularColorMapTransform)),m.specularIntensityMap&&(v.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,v.specularIntensityMapTransform))}function y(v,m){m.matcap&&(v.matcap.value=m.matcap)}function M(v,m){let N=e.get(m).light;v.referencePosition.value.setFromMatrixPosition(N.matrixWorld),v.nearDistance.value=N.shadow.camera.near,v.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function gw(n,e,t,i){let r={},a={},s=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function u(_,g){let b=g.program;i.uniformBlockBinding(_,b)}function l(_,g){let b=r[_.id];b===void 0&&(v(_),b=d(_),r[_.id]=b,_.addEventListener("dispose",N));let z=g.program;i.updateUBOMapping(_,z);let T=e.render.frame;a[_.id]!==T&&(h(_),a[_.id]=T)}function d(_){let g=f();_.__bindingPointIndex=g;let b=n.createBuffer(),z=_.__size,T=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,z,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,g,b),b}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 g=r[_.id],b=_.uniforms,z=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,g);for(let T=0,D=b.length;T<D;T++){let G=b[T];if(Array.isArray(G))for(let F=0,$=G.length;F<$;F++)p(G[F],T,F,z);else p(G,T,0,z)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(_,g,b,z){if(M(_,g,b,z)===!0){let T=_.__offset,D=_.value;if(Array.isArray(D)){let G=0;for(let F=0;F<D.length;F++){let $=D[F],A=m($);y($,_.__data,G),typeof $!="number"&&typeof $!="boolean"&&!$.isMatrix3&&!ArrayBuffer.isView($)&&(G+=A.storage/Float32Array.BYTES_PER_ELEMENT)}}else y(D,_.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,T,_.__data)}}function y(_,g,b){typeof _=="number"||typeof _=="boolean"?g[0]=_:_.isMatrix3?(g[0]=_.elements[0],g[1]=_.elements[1],g[2]=_.elements[2],g[3]=0,g[4]=_.elements[3],g[5]=_.elements[4],g[6]=_.elements[5],g[7]=0,g[8]=_.elements[6],g[9]=_.elements[7],g[10]=_.elements[8],g[11]=0):ArrayBuffer.isView(_)?g.set(new _.constructor(_.buffer,_.byteOffset,g.length)):_.toArray(g,b)}function M(_,g,b,z){let T=_.value,D=g+"_"+b;if(z[D]===void 0)return typeof T=="number"||typeof T=="boolean"?z[D]=T:ArrayBuffer.isView(T)?z[D]=T.slice():z[D]=T.clone(),!0;{let G=z[D];if(typeof T=="number"||typeof T=="boolean"){if(G!==T)return z[D]=T,!0}else{if(ArrayBuffer.isView(T))return!0;if(G.equals(T)===!1)return G.copy(T),!0}}return!1}function v(_){let g=_.uniforms,b=0,z=16;for(let D=0,G=g.length;D<G;D++){let F=Array.isArray(g[D])?g[D]:[g[D]];for(let $=0,A=F.length;$<A;$++){let S=F[$],H=Array.isArray(S.value)?S.value:[S.value];for(let Y=0,oe=H.length;Y<oe;Y++){let O=H[Y],k=m(O),ne=b%z,X=ne%k.boundary,K=ne+X;b+=X,K!==0&&z-K<k.storage&&(b+=z-K),S.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),S.__offset=b,b+=k.storage}}}let T=b%z;return T>0&&(b+=z-T),_.__size=b,_.__cache={},this}function m(_){let g={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(g.boundary=4,g.storage=4):_.isVector2?(g.boundary=8,g.storage=8):_.isVector3||_.isColor?(g.boundary=16,g.storage=12):_.isVector4?(g.boundary=16,g.storage=16):_.isMatrix3?(g.boundary=48,g.storage=48):_.isMatrix4?(g.boundary=64,g.storage=64):_.isTexture?xn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(g.boundary=16,g.storage=_.byteLength):xn("WebGLRenderer: Unsupported uniform value type.",_),g}function N(_){let g=_.target;g.removeEventListener("dispose",N);let b=s.indexOf(g.__bindingPointIndex);s.splice(b,1),n.deleteBuffer(r[g.id]),delete r[g.id],delete a[g.id]}function P(){for(let _ in r)n.deleteBuffer(r[_]);s=[],r={},a={}}return{bind:u,update:l,dispose:P}}var yw=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 xw(){return Ja===null&&(Ja=new Is(yw,16,16,Us,La),Ja.name="DFG_LUT",Ja.minFilter=cr,Ja.magFilter=cr,Ja.wrapS=va,Ja.wrapT=va,Ja.generateMipmaps=!1,Ja.needsUpdate=!0),Ja}var gf=class{constructor(e={}){let{canvas:t=o0(),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:p=Xr}=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=p,v=new Set([Nd,Dd,Ld]),m=new Set([Xr,Pa,pl,ml,Cd,Rd]),N=new Uint32Array(4),P=new Int32Array(4),_=new _e,g=null,b=null,z=[],T=[],D=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=Wr,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let G=this,F=!1,$=null,A=null,S=null,H=null;this._outputColorSpace=xr;let Y=0,oe=0,O=null,k=-1,ne=null,X=new Ti,K=new Ti,ge=null,se=new Cn(0),Se=0,Pe=t.width,le=t.height,ae=1,fe=null,Ne=null,Re=new Ti(0,0,Pe,le),We=new Ti(0,0,Pe,le),Qe=!1,ke=new nl,qe=!1,ft=!1,tt=new Dn,st=new _e,Ke=new Ti,en={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},nt=!1;function on(){return O===null?ae:1}let ue=i;function hn(R,ce){return t.getContext(R,ce)}let gn,J,w,ie,ye,Ae,Xe,Je,Te,Ie,ot,yt,ht,rt,Lt,Bt,qt,te,at,Ce,pt,lt,He;try{let R={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",xt,!1),t.addEventListener("webglcontextrestored",kt,!1),t.addEventListener("webglcontextcreationerror",ct,!1),ue===null){let ce="webgl2";if(ue=hn(ce,R),ue===null)throw hn(ce)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Zt()}catch(R){throw t.removeEventListener("webglcontextlost",xt,!1),t.removeEventListener("webglcontextrestored",kt,!1),t.removeEventListener("webglcontextcreationerror",ct,!1),Tn("WebGLRenderer: "+R.message),R}function Zt(){gn=new ES(ue),gn.init(),pt=new fw(ue,gn),J=new vS(ue,gn,e,pt),w=new uw(ue,gn),J.reversedDepthBuffer&&h&&w.buffers.depth.setReversed(!0),A=ue.createFramebuffer(),S=ue.createFramebuffer(),H=ue.createFramebuffer(),ie=new CS(ue),ye=new $b,Ae=new dw(ue,gn,w,ye,J,pt,ie),Xe=new TS(G),Je=new Px(ue),lt=new pS(ue,Je),Te=new AS(ue,Je,ie,lt),Ie=new PS(ue,Te,Je,lt,ie),te=new RS(ue,J,Ae),Lt=new gS(ye),ot=new Jb(G,Xe,gn,J,lt,Lt),yt=new vw(G,ye),ht=new Qb,rt=new rw(gn),qt=new hS(G,Xe,w,Ie,y,u),Bt=new cw(G,Ie,J),He=new gw(ue,ie,J,w),at=new mS(ue,gn,ie),Ce=new IS(ue,gn,ie),ie.programs=ot.programs,G.capabilities=J,G.extensions=gn,G.properties=ye,G.renderLists=ht,G.shadowMap=Bt,G.state=w,G.info=ie}M!==Xr&&(D=new DS(M,t.width,t.height,o,r,a));let It=new Up(G,ue);this.xr=It,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){let R=gn.get("WEBGL_lose_context");R&&R.loseContext()},this.forceContextRestore=function(){let R=gn.get("WEBGL_lose_context");R&&R.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(R){R!==void 0&&(ae=R,this.setSize(Pe,le,!1))},this.getSize=function(R){return R.set(Pe,le)},this.setSize=function(R,ce,we=!0){if(It.isPresenting){xn("WebGLRenderer: Can't change size while VR device is presenting.");return}Pe=R,le=ce,t.width=Math.floor(R*ae),t.height=Math.floor(ce*ae),we===!0&&(t.style.width=R+"px",t.style.height=ce+"px"),D!==null&&D.setSize(t.width,t.height),this.setViewport(0,0,R,ce)},this.getDrawingBufferSize=function(R){return R.set(Pe*ae,le*ae).floor()},this.setDrawingBufferSize=function(R,ce,we){Pe=R,le=ce,ae=we,t.width=Math.floor(R*we),t.height=Math.floor(ce*we),this.setViewport(0,0,R,ce)},this.setEffects=function(R){if(M===Xr){Tn("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(R){for(let ce=0;ce<R.length;ce++)if(R[ce].isOutputPass===!0){xn("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}D.setEffects(R||[])},this.getCurrentViewport=function(R){return R.copy(X)},this.getViewport=function(R){return R.copy(Re)},this.setViewport=function(R,ce,we,ve){R.isVector4?Re.set(R.x,R.y,R.z,R.w):Re.set(R,ce,we,ve),w.viewport(X.copy(Re).multiplyScalar(ae).round())},this.getScissor=function(R){return R.copy(We)},this.setScissor=function(R,ce,we,ve){R.isVector4?We.set(R.x,R.y,R.z,R.w):We.set(R,ce,we,ve),w.scissor(K.copy(We).multiplyScalar(ae).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(R){w.setScissorTest(Qe=R)},this.setOpaqueSort=function(R){fe=R},this.setTransparentSort=function(R){Ne=R},this.getClearColor=function(R){return R.copy(qt.getClearColor())},this.setClearColor=function(){qt.setClearColor(...arguments)},this.getClearAlpha=function(){return qt.getClearAlpha()},this.setClearAlpha=function(){qt.setClearAlpha(...arguments)},this.clear=function(R=!0,ce=!0,we=!0){let ve=0;if(R){let de=!1;if(O!==null){let mt=O.texture.format;de=v.has(mt)}if(de){let mt=O.texture.type,Ct=m.has(mt),Ye=qt.getClearColor(),Rt=qt.getClearAlpha(),Dt=Ye.r,_t=Ye.g,Gt=Ye.b;Ct?(N[0]=Dt,N[1]=_t,N[2]=Gt,N[3]=Rt,ue.clearBufferuiv(ue.COLOR,0,N)):(P[0]=Dt,P[1]=_t,P[2]=Gt,P[3]=Rt,ue.clearBufferiv(ue.COLOR,0,P))}else ve|=ue.COLOR_BUFFER_BIT}ce&&(ve|=ue.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),we&&(ve|=ue.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ve!==0&&ue.clear(ve)},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(R){R.setRenderer(this),$=R},this.dispose=function(){t.removeEventListener("webglcontextlost",xt,!1),t.removeEventListener("webglcontextrestored",kt,!1),t.removeEventListener("webglcontextcreationerror",ct,!1),qt.dispose(),ht.dispose(),rt.dispose(),ye.dispose(),Xe.dispose(),Ie.dispose(),lt.dispose(),He.dispose(),ot.dispose(),It.dispose(),It.removeEventListener("sessionstart",nn),It.removeEventListener("sessionend",yn),un.stop()};function xt(R){R.preventDefault(),up("WebGLRenderer: Context Lost."),F=!0}function kt(){up("WebGLRenderer: Context Restored."),F=!1;let R=ie.autoReset,ce=Bt.enabled,we=Bt.autoUpdate,ve=Bt.needsUpdate,de=Bt.type;Zt(),ie.autoReset=R,Bt.enabled=ce,Bt.autoUpdate=we,Bt.needsUpdate=ve,Bt.type=de}function ct(R){Tn("WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function zt(R){let ce=R.target;ce.removeEventListener("dispose",zt),$t(ce)}function $t(R){ln(R),ye.remove(R)}function ln(R){let ce=ye.get(R).programs;ce!==void 0&&(ce.forEach(function(we){ot.releaseProgram(we)}),R.isShaderMaterial&&ot.releaseShaderCache(R))}this.renderBufferDirect=function(R,ce,we,ve,de,mt){ce===null&&(ce=en);let Ct=de.isMesh&&de.matrixWorld.determinantAffine()<0,Ye=Wn(R,ce,we,ve,de);w.setMaterial(ve,Ct);let Rt=we.index,Dt=1;if(ve.wireframe===!0){if(Rt=Te.getWireframeAttribute(we),Rt===void 0)return;Dt=2}let _t=we.drawRange,Gt=we.attributes.position,De=_t.start*Dt,Ht=(_t.start+_t.count)*Dt;mt!==null&&(De=Math.max(De,mt.start*Dt),Ht=Math.min(Ht,(mt.start+mt.count)*Dt)),Rt!==null?(De=Math.max(De,0),Ht=Math.min(Ht,Rt.count)):Gt!=null&&(De=Math.max(De,0),Ht=Math.min(Ht,Gt.count));let an=Ht-De;if(an<0||an===1/0)return;lt.setup(de,ve,Ye,we,Rt);let Pn,An=at;if(Rt!==null&&(Pn=Je.get(Rt),An=Ce,An.setIndex(Pn)),de.isMesh)ve.wireframe===!0?(w.setLineWidth(ve.wireframeLinewidth*on()),An.setMode(ue.LINES)):An.setMode(ue.TRIANGLES);else if(de.isLine){let Xn=ve.linewidth;Xn===void 0&&(Xn=1),w.setLineWidth(Xn*on()),de.isLineSegments?An.setMode(ue.LINES):de.isLineLoop?An.setMode(ue.LINE_LOOP):An.setMode(ue.LINE_STRIP)}else de.isPoints?An.setMode(ue.POINTS):de.isSprite&&An.setMode(ue.TRIANGLES);if(de.isBatchedMesh)if(gn.get("WEBGL_multi_draw"))An.renderMultiDraw(de._multiDrawStarts,de._multiDrawCounts,de._multiDrawCount);else{let Xn=de._multiDrawStarts,Ge=de._multiDrawCounts,Yn=de._multiDrawCount,Et=Rt?Je.get(Rt).bytesPerElement:1,vt=ye.get(ve).currentProgram.getUniforms();for(let si=0;si<Yn;si++)vt.setValue(ue,"_gl_DrawID",si),An.render(Xn[si]/Et,Ge[si])}else if(de.isInstancedMesh)An.renderInstances(De,an,de.count);else if(we.isInstancedBufferGeometry){let Xn=we._maxInstanceCount!==void 0?we._maxInstanceCount:1/0,Ge=Math.min(we.instanceCount,Xn);An.renderInstances(De,an,Ge)}else An.render(De,an)};function pn(R,ce,we,ve){$!==null&&R.isNodeMaterial&&$.setObject(ve,R),qe===!0&&Lt.setState(R,we,!1),R.transparent===!0&&R.side===Ir&&R.forceSinglePass===!1?(R.side=Fr,R.needsUpdate=!0,Fn(R,ce,ve),R.side=Ya,R.needsUpdate=!0,Fn(R,ce,ve),R.side=Ir):Fn(R,ce,ve)}this.compile=function(R,ce,we=null){we===null&&(we=R),$!==null&&$.renderStart(R,ce,we),b=rt.get(we),b.init(ce),T.push(b),we.traverseVisible(function(de){de.isLight&&de.layers.test(ce.layers)&&(b.pushLight(de),de.castShadow&&b.pushShadow(de))}),R!==we&&R.traverseVisible(function(de){de.isLight&&de.layers.test(ce.layers)&&(b.pushLight(de),de.castShadow&&b.pushShadow(de))}),b.setupLights(),$!==null&&$.updateLights(b.state.lightsArray),ft=this.localClippingEnabled,qe=Lt.init(this.clippingPlanes,ft),qe===!0&&Lt.setGlobalState(this.clippingPlanes,ce),$!==null&&Bt.render(b.state.shadowsArray,we,ce);let ve=new Set;return R.traverse(function(de){if(!(de.isMesh||de.isPoints||de.isLine||de.isSprite))return;let mt=de.material;if(mt)if(Array.isArray(mt))for(let Ct=0;Ct<mt.length;Ct++){let Ye=mt[Ct];pn(Ye,we,ce,de),ve.add(Ye)}else pn(mt,we,ce,de),ve.add(mt)}),b=T.pop(),$!==null&&$.renderEnd(),ve},this.compileAsync=function(R,ce,we=null){let ve=this.compile(R,ce,we);return new Promise(de=>{function mt(){if(ve.forEach(function(Ct){let Rt=ye.get(Ct).currentProgram;(Rt===void 0||Rt.isReady())&&ve.delete(Ct)}),ve.size===0){de(R);return}setTimeout(mt,10)}gn.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let tn=null;function Qt(R){tn&&tn(R)}function nn(){un.stop()}function yn(){un.start()}let un=new z0;un.setAnimationLoop(Qt),typeof self<"u"&&un.setContext(self),this.setAnimationLoop=function(R){tn=R,It.setAnimationLoop(R),R===null?un.stop():un.start()},It.addEventListener("sessionstart",nn),It.addEventListener("sessionend",yn),this.render=function(R,ce){if(ce!==void 0&&ce.isCamera!==!0){Tn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(F===!0)return;$!==null&&$.renderStart(R,ce);let we=It.enabled===!0&&It.isPresenting===!0,ve=D!==null&&(O===null||we)&&D.begin(G,O);if(R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),ce.parent===null&&ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),It.enabled===!0&&It.isPresenting===!0&&(D===null||D.isCompositing()===!1)&&(It.cameraAutoUpdate===!0&&It.updateCamera(ce),ce=It.getCamera()),R.isScene===!0&&R.onBeforeRender(G,R,ce,O),b=rt.get(R,T.length),b.init(ce),b.state.textureUnits=Ae.getTextureUnits(),T.push(b),tt.multiplyMatrices(ce.projectionMatrix,ce.matrixWorldInverse),ke.setFromProjectionMatrix(tt,Ca,ce.reversedDepth),ft=this.localClippingEnabled,qe=Lt.init(this.clippingPlanes,ft),g=ht.get(R,z.length),g.init(),z.push(g),It.enabled===!0&&It.isPresenting===!0){let Ct=G.xr.getDepthSensingMesh();Ct!==null&&En(Ct,ce,-1/0,G.sortObjects)}En(R,ce,0,G.sortObjects),g.finish(),$!==null&&$.updateLights(b.state.lightsArray),G.sortObjects===!0&&g.sort(fe,Ne),nt=It.enabled===!1||It.isPresenting===!1||It.hasDepthSensing()===!1,nt&&qt.addToRenderList(g,R),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),qe===!0&&Lt.beginShadows();let de=b.state.shadowsArray;if(Bt.render(de,R,ce),qe===!0&&Lt.endShadows(),(ve&&D.hasRenderPass())===!1){let Ct=g.opaque,Ye=g.transmissive;if(b.setupLights(),ce.isArrayCamera){let Rt=ce.cameras;if(Ye.length>0)for(let Dt=0,_t=Rt.length;Dt<_t;Dt++){let Gt=Rt[Dt];kn(Ct,Ye,R,Gt)}nt&&qt.render(R);for(let Dt=0,_t=Rt.length;Dt<_t;Dt++){let Gt=Rt[Dt];ii(g,R,Gt,Gt.viewport)}}else Ye.length>0&&kn(Ct,Ye,R,ce),nt&&qt.render(R),ii(g,R,ce)}O!==null&&oe===0&&(Ae.updateMultisampleRenderTarget(O),Ae.updateRenderTargetMipmap(O)),ve&&D.end(G),R.isScene===!0&&R.onAfterRender(G,R,ce),lt.resetDefaultState(),k=-1,ne=null,T.pop(),T.length>0?(b=T[T.length-1],Ae.setTextureUnits(b.state.textureUnits),qe===!0&&Lt.setGlobalState(G.clippingPlanes,b.state.camera)):b=null,z.pop(),z.length>0?g=z[z.length-1]:g=null,$!==null&&$.renderEnd()};function En(R,ce,we,ve){if(R.visible===!1)return;if(R.layers.test(ce.layers)){if(R.isGroup)we=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update(ce);else if(R.isLightProbeGrid)b.pushLightProbeGrid(R);else if(R.isLight)b.pushLight(R),R.castShadow&&b.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||R.intersectsFrustum(ke)){ve&&Ke.setFromMatrixPosition(R.matrixWorld).applyMatrix4(tt);let Ct=Ie.update(R),Ye=R.material;Ye.visible&&g.push(R,Ct,Ye,we,Ke.z,null,ce)}}else if((R.isMesh||R.isLine||R.isPoints)&&(!R.frustumCulled||R.intersectsFrustum(ke))){let Ct=Ie.update(R),Ye=R.material;if(ve&&(R.boundingSphere!==void 0?(R.boundingSphere===null&&R.computeBoundingSphere(),Ke.copy(R.boundingSphere.center)):(Ct.boundingSphere===null&&Ct.computeBoundingSphere(),Ke.copy(Ct.boundingSphere.center)),Ke.applyMatrix4(R.matrixWorld).applyMatrix4(tt)),Array.isArray(Ye)){let Rt=Ct.groups;for(let Dt=0,_t=Rt.length;Dt<_t;Dt++){let Gt=Rt[Dt],De=Ye[Gt.materialIndex];De&&De.visible&&g.push(R,Ct,De,we,Ke.z,Gt,ce)}}else Ye.visible&&g.push(R,Ct,Ye,we,Ke.z,null,ce)}}let mt=R.children;for(let Ct=0,Ye=mt.length;Ct<Ye;Ct++)En(mt[Ct],ce,we,ve)}function ii(R,ce,we,ve){let{opaque:de,transmissive:mt,transparent:Ct}=R;b.setupLightsView(we),qe===!0&&Lt.setGlobalState(G.clippingPlanes,we),ve&&w.viewport(X.copy(ve)),de.length>0&&zn(de,ce,we),mt.length>0&&zn(mt,ce,we),Ct.length>0&&zn(Ct,ce,we),w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function kn(R,ce,we,ve){if((we.isScene===!0?we.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[ve.id]===void 0){let De=gn.has("EXT_color_buffer_half_float")||gn.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[ve.id]=new Gr(1,1,{generateMipmaps:!0,type:De?La:Xr,minFilter:Za,samples:Math.max(4,J.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ni.workingColorSpace})}let mt=b.state.transmissionRenderTarget[ve.id],Ct=ve.viewport||X;mt.setSize(Ct.z*G.transmissionResolutionScale,Ct.w*G.transmissionResolutionScale);let Ye=G.getRenderTarget(),Rt=G.getActiveCubeFace(),Dt=G.getActiveMipmapLevel();G.setRenderTarget(mt),G.getClearColor(se),Se=G.getClearAlpha(),Se<1&&G.setClearColor(16777215,.5),G.clear(),nt&&qt.render(we);let _t=G.toneMapping;G.toneMapping=Wr;let Gt=ve.viewport;if(ve.viewport!==void 0&&(ve.viewport=void 0),b.setupLightsView(ve),qe===!0&&Lt.setGlobalState(G.clippingPlanes,ve),zn(R,we,ve),Ae.updateMultisampleRenderTarget(mt),Ae.updateRenderTargetMipmap(mt),gn.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let Ht=0,an=ce.length;Ht<an;Ht++){let Pn=ce[Ht],{object:An,geometry:Xn,material:Ge,group:Yn}=Pn;if(Ge.side===Ir&&An.layers.test(ve.layers)){let Et=Ge.side;Ge.side=Fr,Ge.needsUpdate=!0,Un(An,we,ve,Xn,Ge,Yn),Ge.side=Et,Ge.needsUpdate=!0,De=!0}}De===!0&&(Ae.updateMultisampleRenderTarget(mt),Ae.updateRenderTargetMipmap(mt))}G.setRenderTarget(Ye,Rt,Dt),G.setClearColor(se,Se),Gt!==void 0&&(ve.viewport=Gt),G.toneMapping=_t}function zn(R,ce,we){let ve=ce.isScene===!0?ce.overrideMaterial:null;for(let de=0,mt=R.length;de<mt;de++){let Ct=R[de],{object:Ye,geometry:Rt,group:Dt}=Ct,_t=Ct.material;_t.allowOverride===!0&&ve!==null&&(_t=ve),Ye.layers.test(we.layers)&&Un(Ye,ce,we,Rt,_t,Dt)}}function Un(R,ce,we,ve,de,mt){$!==null&&de.isNodeMaterial&&$.setObject(R,de),R.onBeforeRender(G,ce,we,ve,de,mt),R.modelViewMatrix.multiplyMatrices(we.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),de.onBeforeRender(G,ce,we,ve,R,mt),de.transparent===!0&&de.side===Ir&&de.forceSinglePass===!1?(de.side=Fr,de.needsUpdate=!0,G.renderBufferDirect(we,ce,ve,de,R,mt),de.side=Ya,de.needsUpdate=!0,G.renderBufferDirect(we,ce,ve,de,R,mt),de.side=Ir):G.renderBufferDirect(we,ce,ve,de,R,mt),R.onAfterRender(G,ce,we,ve,de,mt)}function Fn(R,ce,we){ce.isScene!==!0&&(ce=en);let ve=ye.get(R),de=b.state.lights,mt=b.state.shadowsArray,Ct=de.state.version,Ye=ot.getParameters(R,de.state,mt,ce,we,b.state.lightProbeGridArray),Rt=ot.getProgramCacheKey(Ye),Dt=ve.programs;ve.environment=R.isMeshStandardMaterial||R.isMeshLambertMaterial||R.isMeshPhongMaterial?ce.environment:null,ve.fog=ce.fog;let _t=R.isMeshStandardMaterial||R.isMeshLambertMaterial&&!R.envMap||R.isMeshPhongMaterial&&!R.envMap;ve.envMap=Xe.get(R.envMap||ve.environment,_t),ve.envMapRotation=ve.environment!==null&&R.envMap===null?ce.environmentRotation:R.envMapRotation,Dt===void 0&&(R.addEventListener("dispose",zt),Dt=new Map,ve.programs=Dt);let Gt=Dt.get(Rt);if(Gt!==void 0){if(ve.currentProgram===Gt&&ve.lightsStateVersion===Ct)return rn(R,Ye),Gt}else Ye.uniforms=ot.getUniforms(R),$!==null&&R.isNodeMaterial&&$.build(R,we,Ye),R.onBeforeCompile(Ye,G),Gt=ot.acquireProgram(Ye,Rt),Dt.set(Rt,Gt),ve.uniforms=Ye.uniforms;let De=ve.uniforms;return(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)&&(De.clippingPlanes=Lt.uniform),rn(R,Ye),ve.needsLights=Rn(R),ve.lightsStateVersion=Ct,ve.needsLights&&(De.ambientLightColor.value=de.state.ambient,De.lightProbe.value=de.state.probe,De.sunLights.value=de.state.sun,De.sunLightShadows.value=de.state.sunShadow,De.directionalLights.value=de.state.directional,De.directionalLightShadows.value=de.state.directionalShadow,De.spotLights.value=de.state.spot,De.spotLightShadows.value=de.state.spotShadow,De.rectAreaLights.value=de.state.rectArea,De.ltc_1.value=de.state.rectAreaLTC1,De.ltc_2.value=de.state.rectAreaLTC2,De.pointLights.value=de.state.point,De.pointLightShadows.value=de.state.pointShadow,De.hemisphereLights.value=de.state.hemi,De.sunShadowMatrix.value=de.state.sunShadowMatrix,De.sunShadowCascade.value=de.state.sunShadowCascade,De.directionalShadowMatrix.value=de.state.directionalShadowMatrix,De.spotLightMatrix.value=de.state.spotLightMatrix,De.spotLightMap.value=de.state.spotLightMap,De.pointShadowMatrix.value=de.state.pointShadowMatrix),ve.lightProbeGrid=b.state.lightProbeGridArray.length>0,ve.currentProgram=Gt,ve.uniformsList=null,Gt}function Jn(R){if(R.uniformsList===null){let ce=R.currentProgram.getUniforms();R.uniformsList=yl.seqWithValue(ce.seq,R.uniforms)}return R.uniformsList}function rn(R,ce){let we=ye.get(R);we.outputColorSpace=ce.outputColorSpace,we.batching=ce.batching,we.batchingColor=ce.batchingColor,we.instancing=ce.instancing,we.instancingColor=ce.instancingColor,we.instancingMorph=ce.instancingMorph,we.skinning=ce.skinning,we.morphTargets=ce.morphTargets,we.morphNormals=ce.morphNormals,we.morphColors=ce.morphColors,we.morphTargetsCount=ce.morphTargetsCount,we.numClippingPlanes=ce.numClippingPlanes,we.numIntersection=ce.numClipIntersection,we.vertexAlphas=ce.vertexAlphas,we.vertexTangents=ce.vertexTangents,we.toneMapping=ce.toneMapping}function ri(R,ce){if(R.length===0)return null;if(R.length===1)return R[0].texture!==null?R[0]:null;_.setFromMatrixPosition(ce.matrixWorld);for(let we=0,ve=R.length;we<ve;we++){let de=R[we];if(de.texture!==null&&de.boundingBox.containsPoint(_))return de}return null}function Wn(R,ce,we,ve,de){ce.isScene!==!0&&(ce=en),Ae.resetTextureUnits();let mt=ce.fog,Ct=ve.isMeshStandardMaterial||ve.isMeshLambertMaterial||ve.isMeshPhongMaterial?ce.environment:null,Ye=O===null?G.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:ni.workingColorSpace,Rt=ve.isMeshStandardMaterial||ve.isMeshLambertMaterial&&!ve.envMap||ve.isMeshPhongMaterial&&!ve.envMap,Dt=Xe.get(ve.envMap||Ct,Rt),_t=ve.vertexColors===!0&&!!we.attributes.color&&we.attributes.color.itemSize===4,Gt=!!we.attributes.tangent&&(!!ve.normalMap||ve.anisotropy>0),De=!!we.morphAttributes.position,Ht=!!we.morphAttributes.normal,an=!!we.morphAttributes.color,Pn=Wr;ve.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(Pn=G.toneMapping);let An=we.morphAttributes.position||we.morphAttributes.normal||we.morphAttributes.color,Xn=An!==void 0?An.length:0,Ge=ye.get(ve),Yn=b.state.lights;if(qe===!0&&(ft===!0||R!==ne)){let jn=R===ne&&ve.id===k;Lt.setState(ve,R,jn)}let Et=!1;ve.version===Ge.__version?(Ge.needsLights&&Ge.lightsStateVersion!==Yn.state.version||Ge.outputColorSpace!==Ye||de.isBatchedMesh&&Ge.batching===!1||!de.isBatchedMesh&&Ge.batching===!0||de.isBatchedMesh&&Ge.batchingColor===!0&&de._colorsTexture===null||de.isBatchedMesh&&Ge.batchingColor===!1&&de._colorsTexture!==null||de.isInstancedMesh&&Ge.instancing===!1||!de.isInstancedMesh&&Ge.instancing===!0||de.isSkinnedMesh&&Ge.skinning===!1||!de.isSkinnedMesh&&Ge.skinning===!0||de.isInstancedMesh&&Ge.instancingColor===!0&&de.instanceColor===null||de.isInstancedMesh&&Ge.instancingColor===!1&&de.instanceColor!==null||de.isInstancedMesh&&Ge.instancingMorph===!0&&de.morphTexture===null||de.isInstancedMesh&&Ge.instancingMorph===!1&&de.morphTexture!==null||Ge.envMap!==Dt||ve.fog===!0&&Ge.fog!==mt||Ge.numClippingPlanes!==void 0&&(Ge.numClippingPlanes!==Lt.numPlanes||Ge.numIntersection!==Lt.numIntersection)||Ge.vertexAlphas!==_t||Ge.vertexTangents!==Gt||Ge.morphTargets!==De||Ge.morphNormals!==Ht||Ge.morphColors!==an||Ge.toneMapping!==Pn||Ge.morphTargetsCount!==Xn||!!Ge.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Et=!0):(Et=!0,Ge.__version=ve.version);let vt=Ge.currentProgram;Et===!0&&(vt=Fn(ve,ce,de),$&&ve.isNodeMaterial&&$.onUpdateProgram(ve,vt,Ge));let si=!1,Ni=!1,nr=!1,Vn=vt.getUniforms(),$n=Ge.uniforms;if(w.useProgram(vt.program)&&(si=!0,Ni=!0,nr=!0),ve.id!==k&&(k=ve.id,Ni=!0),Ge.needsLights){let jn=ri(b.state.lightProbeGridArray,de);Ge.lightProbeGrid!==jn&&(Ge.lightProbeGrid=jn,Ni=!0)}if(si||ne!==R){w.buffers.depth.getReversed()&&R.reversedDepth!==!0&&(R._reversedDepth=!0,R.updateProjectionMatrix()),Vn.setValue(ue,"projectionMatrix",R.projectionMatrix),Vn.setValue(ue,"viewMatrix",R.matrixWorldInverse);let Ki=Vn.map.cameraPosition;Ki!==void 0&&Ki.setValue(ue,st.setFromMatrixPosition(R.matrixWorld)),J.logarithmicDepthBuffer&&Vn.setValue(ue,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),(ve.isMeshPhongMaterial||ve.isMeshToonMaterial||ve.isMeshLambertMaterial||ve.isMeshBasicMaterial||ve.isMeshStandardMaterial||ve.isShaderMaterial)&&Vn.setValue(ue,"isOrthographic",R.isOrthographicCamera===!0),ne!==R&&(ne=R,Ni=!0,nr=!0)}if(Ge.needsLights&&(Yn.state.sunShadowMap.length>0&&Vn.setValue(ue,"sunShadowMap",Yn.state.sunShadowMap,Ae),Yn.state.directionalShadowMap.length>0&&Vn.setValue(ue,"directionalShadowMap",Yn.state.directionalShadowMap,Ae),Yn.state.spotShadowMap.length>0&&Vn.setValue(ue,"spotShadowMap",Yn.state.spotShadowMap,Ae),Yn.state.pointShadowMap.length>0&&Vn.setValue(ue,"pointShadowMap",Yn.state.pointShadowMap,Ae)),de.isSkinnedMesh){Vn.setOptional(ue,de,"bindMatrix"),Vn.setOptional(ue,de,"bindMatrixInverse");let jn=de.skeleton;jn&&(jn.boneTexture===null&&jn.computeBoneTexture(),Vn.setValue(ue,"boneTexture",jn.boneTexture,Ae))}de.isBatchedMesh&&(Vn.setOptional(ue,de,"batchingTexture"),Vn.setValue(ue,"batchingTexture",de._matricesTexture,Ae),Vn.setOptional(ue,de,"batchingIdTexture"),Vn.setValue(ue,"batchingIdTexture",de._indirectTexture,Ae),Vn.setOptional(ue,de,"batchingColorTexture"),de._colorsTexture!==null&&Vn.setValue(ue,"batchingColorTexture",de._colorsTexture,Ae));let Wi=we.morphAttributes;if((Wi.position!==void 0||Wi.normal!==void 0||Wi.color!==void 0)&&te.update(de,we,vt),(Ni||Ge.receiveShadow!==de.receiveShadow)&&(Ge.receiveShadow=de.receiveShadow,Vn.setValue(ue,"receiveShadow",de.receiveShadow)),(ve.isMeshStandardMaterial||ve.isMeshLambertMaterial||ve.isMeshPhongMaterial)&&ve.envMap===null&&ce.environment!==null&&($n.envMapIntensity.value=ce.environmentIntensity),$n.dfgLUT!==void 0&&($n.dfgLUT.value=xw()),Ni){if(Vn.setValue(ue,"toneMappingExposure",G.toneMappingExposure),Ge.needsLights&&Ei($n,nr),mt&&ve.fog===!0&&yt.refreshFogUniforms($n,mt),yt.refreshMaterialUniforms($n,ve,ae,le,b.state.transmissionRenderTarget[R.id]),Ge.needsLights&&Ge.lightProbeGrid){let jn=Ge.lightProbeGrid;$n.probesSH.value=jn.texture,$n.probesMin.value.copy(jn.boundingBox.min),$n.probesMax.value.copy(jn.boundingBox.max),$n.probesResolution.value.copy(jn.resolution)}yl.upload(ue,Jn(Ge),$n,Ae)}if(ve.isShaderMaterial&&ve.uniformsNeedUpdate===!0&&(yl.upload(ue,Jn(Ge),$n,Ae),ve.uniformsNeedUpdate=!1),ve.isSpriteMaterial&&Vn.setValue(ue,"center",de.center),Vn.setValue(ue,"modelViewMatrix",de.modelViewMatrix),Vn.setValue(ue,"normalMatrix",de.normalMatrix),Vn.setValue(ue,"modelMatrix",de.matrixWorld),ve.uniformsGroups!==void 0){let jn=ve.uniformsGroups;for(let Ki=0,Mi=jn.length;Ki<Mi;Ki++){let ir=jn[Ki];He.update(ir,vt),He.bind(ir,vt)}}return vt}function Ei(R,ce){R.ambientLightColor.needsUpdate=ce,R.lightProbe.needsUpdate=ce,R.sunLights.needsUpdate=ce,R.sunLightShadows.needsUpdate=ce,R.directionalLights.needsUpdate=ce,R.directionalLightShadows.needsUpdate=ce,R.pointLights.needsUpdate=ce,R.pointLightShadows.needsUpdate=ce,R.spotLights.needsUpdate=ce,R.spotLightShadows.needsUpdate=ce,R.rectAreaLights.needsUpdate=ce,R.hemisphereLights.needsUpdate=ce}function Rn(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return Y},this.getActiveMipmapLevel=function(){return oe},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(R,ce,we){let ve=ye.get(R);ve.__autoAllocateDepthBuffer=R.resolveDepthBuffer===!1,ve.__autoAllocateDepthBuffer===!1&&(ve.__useRenderToTexture=!1),ye.get(R.texture).__webglTexture=ce,ye.get(R.depthTexture).__webglTexture=ve.__autoAllocateDepthBuffer?void 0:we,ve.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(R,ce){let we=ye.get(R);we.__webglFramebuffer=ce,we.__useDefaultFramebuffer=ce===void 0},this.setRenderTarget=function(R,ce=0,we=0){O=R,Y=ce,oe=we;let ve=null,de=!1,mt=!1;if(R){let Ye=ye.get(R);if(Ye.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(ue.FRAMEBUFFER,Ye.__webglFramebuffer),X.copy(R.viewport),K.copy(R.scissor),ge=R.scissorTest,w.viewport(X),w.scissor(K),w.setScissorTest(ge),k=-1;return}else if(Ye.__webglFramebuffer===void 0)Ae.setupRenderTarget(R);else if(Ye.__hasExternalTextures)Ae.rebindTextures(R,ye.get(R.texture).__webglTexture,ye.get(R.depthTexture).__webglTexture);else if(R.depthBuffer){let _t=R.depthTexture;if(Ye.__boundDepthTexture!==_t){if(_t!==null&&ye.has(_t)&&(R.width!==_t.image.width||R.height!==_t.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Ae.setupDepthRenderbuffer(R)}}let Rt=R.texture;(Rt.isData3DTexture||Rt.isDataArrayTexture||Rt.isCompressedArrayTexture)&&(mt=!0);let Dt=ye.get(R).__webglFramebuffer;R.isWebGLCubeRenderTarget?(Array.isArray(Dt[ce])?ve=Dt[ce][we]:ve=Dt[ce],de=!0):R.samples>0&&Ae.useMultisampledRTT(R)===!1?ve=ye.get(R).__webglMultisampledFramebuffer:Array.isArray(Dt)?ve=Dt[we]:ve=Dt,X.copy(R.viewport),K.copy(R.scissor),ge=R.scissorTest}else X.copy(Re).multiplyScalar(ae).floor(),K.copy(We).multiplyScalar(ae).floor(),ge=Qe;if(we!==0&&(ve=A),w.bindFramebuffer(ue.FRAMEBUFFER,ve)&&w.drawBuffers(R,ve),w.viewport(X),w.scissor(K),w.setScissorTest(ge),de){let Ye=ye.get(R.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ye.__webglTexture,we)}else if(mt){let Ye=ce;for(let Rt=0;Rt<R.textures.length;Rt++){let Dt=ye.get(R.textures[Rt]);ue.framebufferTextureLayer(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0+Rt,Dt.__webglTexture,we,Ye)}}else if(R!==null&&we!==0){let Ye=ye.get(R.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_2D,Ye.__webglTexture,we)}k=-1};function ci(R){let ce=ye.get(R);return(ce.__readFormat!==R.format||ce.__readType!==R.type)&&(ce.__readFormat=R.format,ce.__readType=R.type,ce.__formatReadable=J.textureFormatReadable(R.format),ce.__typeReadable=J.textureTypeReadable(R.type)),ce}this.readRenderTargetPixels=function(R,ce,we,ve,de,mt,Ct,Ye=0){if(!(R&&R.isWebGLRenderTarget)){Tn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Rt=ye.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Ct!==void 0&&(Rt=Rt[Ct]),Rt){w.bindFramebuffer(ue.FRAMEBUFFER,Rt);try{let Dt=R.textures[Ye],_t=Dt.format,Gt=Dt.type;R.textures.length>1&&ue.readBuffer(ue.COLOR_ATTACHMENT0+Ye);let De=ci(Dt);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}ce>=0&&ce<=R.width-ve&&we>=0&&we<=R.height-de&&ue.readPixels(ce,we,ve,de,pt.convert(_t),pt.convert(Gt),mt)}finally{let Dt=O!==null?ye.get(O).__webglFramebuffer:null;w.bindFramebuffer(ue.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(R,ce,we,ve,de,mt,Ct,Ye=0){if(!(R&&R.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Rt=ye.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Ct!==void 0&&(Rt=Rt[Ct]),Rt)if(ce>=0&&ce<=R.width-ve&&we>=0&&we<=R.height-de){w.bindFramebuffer(ue.FRAMEBUFFER,Rt);let Dt=R.textures[Ye],_t=Dt.format,Gt=Dt.type;R.textures.length>1&&ue.readBuffer(ue.COLOR_ATTACHMENT0+Ye);let De=ci(Dt);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 Ht=ue.createBuffer();ue.bindBuffer(ue.PIXEL_PACK_BUFFER,Ht),ue.bufferData(ue.PIXEL_PACK_BUFFER,mt.byteLength,ue.STREAM_READ),ue.readPixels(ce,we,ve,de,pt.convert(_t),pt.convert(Gt),0),ue.bindBuffer(ue.PIXEL_PACK_BUFFER,null);let an=O!==null?ye.get(O).__webglFramebuffer:null;w.bindFramebuffer(ue.FRAMEBUFFER,an);let Pn=ue.fenceSync(ue.SYNC_GPU_COMMANDS_COMPLETE,0);return ue.flush(),await c0(ue,Pn,4),ue.bindBuffer(ue.PIXEL_PACK_BUFFER,Ht),ue.getBufferSubData(ue.PIXEL_PACK_BUFFER,0,mt),ue.bindBuffer(ue.PIXEL_PACK_BUFFER,null),ue.deleteBuffer(Ht),ue.deleteSync(Pn),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(R,ce=null,we=0){let ve=Math.pow(2,-we),de=Math.floor(R.image.width*ve),mt=Math.floor(R.image.height*ve),Ct=ce!==null?ce.x:0,Ye=ce!==null?ce.y:0;Ae.setTexture2D(R,0),ue.copyTexSubImage2D(ue.TEXTURE_2D,we,0,0,Ct,Ye,de,mt),w.unbindTexture()},this.copyTextureToTexture=function(R,ce,we=null,ve=null,de=0,mt=0){let Ct,Ye,Rt,Dt,_t,Gt,De,Ht,an,Pn=R.isCompressedTexture?R.mipmaps[mt]:R.image;if(we!==null)Ct=we.max.x-we.min.x,Ye=we.max.y-we.min.y,Rt=we.isBox3?we.max.z-we.min.z:1,Dt=we.min.x,_t=we.min.y,Gt=we.isBox3?we.min.z:0;else{let $n=Math.pow(2,-de);Ct=Math.floor(Pn.width*$n),Ye=Math.floor(Pn.height*$n),R.isDataArrayTexture?Rt=Pn.depth:R.isData3DTexture?Rt=Math.floor(Pn.depth*$n):Rt=1,Dt=0,_t=0,Gt=0}ve!==null?(De=ve.x,Ht=ve.y,an=ve.z):(De=0,Ht=0,an=0);let An=pt.convert(ce.format),Xn=pt.convert(ce.type),Ge;ce.isData3DTexture?(Ae.setTexture3D(ce,0),Ge=ue.TEXTURE_3D):ce.isDataArrayTexture||ce.isCompressedArrayTexture?(Ae.setTexture2DArray(ce,0),Ge=ue.TEXTURE_2D_ARRAY):(Ae.setTexture2D(ce,0),Ge=ue.TEXTURE_2D),w.activeTexture(ue.TEXTURE0),w.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,ce.flipY),w.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ce.premultiplyAlpha),w.pixelStorei(ue.UNPACK_ALIGNMENT,ce.unpackAlignment);let Yn=w.getParameter(ue.UNPACK_ROW_LENGTH),Et=w.getParameter(ue.UNPACK_IMAGE_HEIGHT),vt=w.getParameter(ue.UNPACK_SKIP_PIXELS),si=w.getParameter(ue.UNPACK_SKIP_ROWS),Ni=w.getParameter(ue.UNPACK_SKIP_IMAGES);w.pixelStorei(ue.UNPACK_ROW_LENGTH,Pn.width),w.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,Pn.height),w.pixelStorei(ue.UNPACK_SKIP_PIXELS,Dt),w.pixelStorei(ue.UNPACK_SKIP_ROWS,_t),w.pixelStorei(ue.UNPACK_SKIP_IMAGES,Gt);let nr=R.isDataArrayTexture||R.isData3DTexture,Vn=ce.isDataArrayTexture||ce.isData3DTexture;if(R.isDepthTexture){let $n=ye.get(R),Wi=ye.get(ce),jn=ye.get($n.__renderTarget),Ki=ye.get(Wi.__renderTarget);w.bindFramebuffer(ue.READ_FRAMEBUFFER,jn.__webglFramebuffer),w.bindFramebuffer(ue.DRAW_FRAMEBUFFER,Ki.__webglFramebuffer);for(let Mi=0;Mi<Rt;Mi++)nr&&(ue.framebufferTextureLayer(ue.READ_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ye.get(R).__webglTexture,de,Gt+Mi),ue.framebufferTextureLayer(ue.DRAW_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ye.get(ce).__webglTexture,mt,an+Mi)),ue.blitFramebuffer(Dt,_t,Ct,Ye,De,Ht,Ct,Ye,ue.DEPTH_BUFFER_BIT,ue.NEAREST);w.bindFramebuffer(ue.READ_FRAMEBUFFER,null),w.bindFramebuffer(ue.DRAW_FRAMEBUFFER,null)}else if(de!==0||R.isRenderTargetTexture||ye.has(R)){let $n=ye.get(R),Wi=ye.get(ce);w.bindFramebuffer(ue.READ_FRAMEBUFFER,S),w.bindFramebuffer(ue.DRAW_FRAMEBUFFER,H);for(let jn=0;jn<Rt;jn++)nr?ue.framebufferTextureLayer(ue.READ_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,$n.__webglTexture,de,Gt+jn):ue.framebufferTexture2D(ue.READ_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_2D,$n.__webglTexture,de),Vn?ue.framebufferTextureLayer(ue.DRAW_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,Wi.__webglTexture,mt,an+jn):ue.framebufferTexture2D(ue.DRAW_FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_2D,Wi.__webglTexture,mt),de!==0?ue.blitFramebuffer(Dt,_t,Ct,Ye,De,Ht,Ct,Ye,ue.COLOR_BUFFER_BIT,ue.NEAREST):Vn?ue.copyTexSubImage3D(Ge,mt,De,Ht,an+jn,Dt,_t,Ct,Ye):ue.copyTexSubImage2D(Ge,mt,De,Ht,Dt,_t,Ct,Ye);w.bindFramebuffer(ue.READ_FRAMEBUFFER,null),w.bindFramebuffer(ue.DRAW_FRAMEBUFFER,null)}else Vn?R.isDataTexture||R.isData3DTexture?ue.texSubImage3D(Ge,mt,De,Ht,an,Ct,Ye,Rt,An,Xn,Pn.data):ce.isCompressedArrayTexture?ue.compressedTexSubImage3D(Ge,mt,De,Ht,an,Ct,Ye,Rt,An,Pn.data):ue.texSubImage3D(Ge,mt,De,Ht,an,Ct,Ye,Rt,An,Xn,Pn):R.isDataTexture?ue.texSubImage2D(ue.TEXTURE_2D,mt,De,Ht,Ct,Ye,An,Xn,Pn.data):R.isCompressedTexture?ue.compressedTexSubImage2D(ue.TEXTURE_2D,mt,De,Ht,Pn.width,Pn.height,An,Pn.data):ue.texSubImage2D(ue.TEXTURE_2D,mt,De,Ht,Ct,Ye,An,Xn,Pn);w.pixelStorei(ue.UNPACK_ROW_LENGTH,Yn),w.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,Et),w.pixelStorei(ue.UNPACK_SKIP_PIXELS,vt),w.pixelStorei(ue.UNPACK_SKIP_ROWS,si),w.pixelStorei(ue.UNPACK_SKIP_IMAGES,Ni),mt===0&&ce.generateMipmaps&&ue.generateMipmap(Ge),w.unbindTexture()},this.initRenderTarget=function(R){ye.get(R).__webglFramebuffer===void 0&&Ae.setupRenderTarget(R)},this.initTexture=function(R){R.isCubeTexture?Ae.setTextureCube(R,0):R.isData3DTexture?Ae.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?Ae.setTexture2DArray(R,0):Ae.setTexture2D(R,0),w.unbindTexture()},this.resetState=function(){Y=0,oe=0,O=null,w.reset(),lt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ca}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=ni._getDrawingBufferColorSpace(e),t.unpackColorSpace=ni._getUnpackColorSpace()}};var kc=function(){return kc=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},kc.apply(this,arguments)},_f=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},_w=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))},mr=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.")},Mw={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5126:Float32Array},Sw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT4:16},q0={POSITION:"position",NORMAL:"normal",COLOR_0:"color",TEXCOORD_0:"uv",JOINTS_0:"skinIndex",WEIGHTS_0:"skinWeight"},Z0={33071:va,33648:qo,10497:As},J0={9728:tr,9729:cr,9984:Ad,9985:hl,9986:co,9987:Za};function Rr(n){if(!n)throw Error("E_MODEL_CORRUPT")}function bw(n,e,t){var i,r,a,s=Mw[t.componentType],o=Sw[t.type];Rr(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,p=t.count;Rr(Number.isSafeInteger(p)&&p>0&&f>=0&&h>=0&&d>=l&&d%u===0&&h%u===0&&f+(p-1)*d+l<=e.byteLength&&h+(p-1)*d+l<=n.length);var y=new s(n.buffer,n.byteOffset+h,((p-1)*d+l)/u);if(d===l)return new Ar(y,o,!!t.normalized);for(var M=new s(p*o),v=0;v<p;v++){var m=v*d/u;M.set(y.subarray(m,m+o),v*o)}return new Ar(M,o,!!t.normalized)}function ww(n,e,t){for(var i="",r=0;r<n.length;r+=8192)i+=String.fromCharCode.apply(String,_w([],_f(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 eg(n,e){var t,i,r,a,s,o,u,l,d,f,h,p,y,M,v,m,N,P,_,g,b,z,T,D,G,F,$,A,S;Rr(n.byteLength>=28&&n.byteLength<=7e5);var H=new DataView(n.buffer,n.byteOffset,n.byteLength),Y=function(ct){return H.getUint32(ct,!0)};Rr(Y(0)===1179937895&&Y(4)===2&&Y(8)===n.byteLength&&Y(16)===1313821514);var oe=20+Y(12);Rr(oe%4===0&&oe+8<=n.byteLength&&Y(oe+4)===5130562&&Y(oe)===n.byteLength-oe-8);var O=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n.subarray(20,oe)));Rr(((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&&((m=(v=O.skins)===null||v===void 0?void 0:v.length)!==null&&m!==void 0?m:0)<=4&&((P=(N=O.animations)===null||N===void 0?void 0:N.length)!==null&&P!==void 0?P:0)<=16);var k=n.subarray(oe+8),ne=new Map,X=new Map,K=new Map,ge=new Map,se=new Set,Se=new Set;function Pe(ct){if(!K.has(ct)){var zt=O.accessors[ct];K.set(ct,bw(k,O.bufferViews[zt.bufferView],zt))}return K.get(ct)}function le(ct,zt){var $t,ln,pn,tn,Qt,nn,yn,un,En,ii,kn,zn;if(!ct)return null;var Un=(ln=($t=ct.extensions)===null||$t===void 0?void 0:$t.KHR_texture_transform)!==null&&ln!==void 0?ln:{};Rr(((tn=(pn=Un.texCoord)!==null&&pn!==void 0?pn:ct.texCoord)!==null&&tn!==void 0?tn:0)===0);var Fn=JSON.stringify([ct.index,zt,Un]);if(ne.has(Fn))return ne.get(Fn);var Jn=O.textures[ct.index],rn=O.images[Jn.source],ri=(nn=(Qt=O.samplers)===null||Qt===void 0?void 0:Qt[Jn.sampler])!==null&&nn!==void 0?nn:{},Wn=new _r;if(Wn.colorSpace=zt,Wn.flipY=!1,Wn.wrapS=Z0[(yn=ri.wrapS)!==null&&yn!==void 0?yn:10497],Wn.wrapT=Z0[(un=ri.wrapT)!==null&&un!==void 0?un:10497],Wn.magFilter=J0[(En=ri.magFilter)!==null&&En!==void 0?En:9729],Wn.minFilter=J0[(ii=ri.minFilter)!==null&&ii!==void 0?ii:9987],Un.offset&&Wn.offset.fromArray(Un.offset),Un.scale&&Wn.repeat.fromArray(Un.scale),Wn.rotation=(kn=Un.rotation)!==null&&kn!==void 0?kn:0,ne.set(Fn,Wn),!X.has(Jn.source)){var Ei=O.bufferViews[rn.bufferView],Rn=(zn=Ei?.byteOffset)!==null&&zn!==void 0?zn:0;Rr(Ei&&!rn.uri&&["image/png","image/jpeg"].includes(rn.mimeType)&&Rn+Ei.byteLength<=k.length);var ci={textures:[],ready:!1,failed:!1};X.set(Jn.source,ci),ci.image=ww(k.subarray(Rn,Rn+Ei.byteLength),rn.mimeType,function(ce){var we,ve;if(ci.ready=!0,ci.failed=!ce,ce)try{for(var de=mr(ci.textures),mt=de.next();!mt.done;mt=de.next()){var Ct=mt.value;Ct.needsUpdate=!0}}catch(Ye){we={error:Ye}}finally{try{mt&&!mt.done&&(ve=de.return)&&ve.call(de)}finally{if(we)throw we.error}}e?.()})}var R=X.get(Jn.source);return Wn.image=R.image,R.textures.push(Wn),R.ready&&!R.failed&&(Wn.needsUpdate=!0),Wn}var ae=new Map;function fe(ct,zt){var $t,ln,pn,tn,Qt,nn,yn,un,En,ii,kn,zn,Un,Fn,Jn,rn,ri,Wn,Ei=String(ct)+"/"+zt;if(ae.has(Ei))return ae.get(Ei);var Rn=(ln=($t=O.materials)===null||$t===void 0?void 0:$t[ct])!==null&&ln!==void 0?ln:{},ci=(pn=Rn.pbrMetallicRoughness)!==null&&pn!==void 0?pn:{},R=(tn=ci.baseColorFactor)!==null&&tn!==void 0?tn:[1,1,1,1],ce=(Qt=Rn.alphaMode)!==null&&Qt!==void 0?Qt:"OPAQUE",we={name:(nn=Rn.name)!==null&&nn!==void 0?nn:"",color:new Cn().fromArray(R),vertexColors:zt,map:le(ci.baseColorTexture,xr),side:Rn.doubleSided?Ir:Ya,opacity:ce==="OPAQUE"?1:R[3],transparent:ce==="BLEND",depthWrite:ce!=="BLEND",alphaTest:ce==="MASK"?(yn=Rn.alphaCutoff)!==null&&yn!==void 0?yn:.5:0},ve;if(!((un=Rn.extensions)===null||un===void 0)&&un.KHR_materials_unlit)ve=new Hr(we);else{var de=le(ci.metallicRoughnessTexture,Or);ve=new ll(kc(kc({},we),{roughness:(En=ci.roughnessFactor)!==null&&En!==void 0?En:1,metalness:(ii=ci.metallicFactor)!==null&&ii!==void 0?ii:1,roughnessMap:de,metalnessMap:de,normalMap:le(Rn.normalTexture,Or),normalScale:new Kt().setScalar((zn=(kn=Rn.normalTexture)===null||kn===void 0?void 0:kn.scale)!==null&&zn!==void 0?zn:1),aoMap:le(Rn.occlusionTexture,Or),aoMapIntensity:(Fn=(Un=Rn.occlusionTexture)===null||Un===void 0?void 0:Un.strength)!==null&&Fn!==void 0?Fn:1,emissive:new Cn().fromArray((Jn=Rn.emissiveFactor)!==null&&Jn!==void 0?Jn:[0,0,0]),emissiveMap:le(Rn.emissiveTexture,xr),emissiveIntensity:(Wn=(ri=(rn=Rn.extensions)===null||rn===void 0?void 0:rn.KHR_materials_emissive_strength)===null||ri===void 0?void 0:ri.emissiveStrength)!==null&&Wn!==void 0?Wn:1})),ve.normalScale.y*=-1}return Se.add(ve),ae.set(Ei,ve),ve}var Ne=O.meshes.map(function(ct){return ct.primitives.map(function(zt){var $t,ln,pn;Rr(((pn=zt.mode)!==null&&pn!==void 0?pn:4)===4&&zt.attributes.POSITION!==void 0&&!zt.targets);var tn=new dr;try{for(var Qt=mr(Object.entries(zt.attributes)),nn=Qt.next();!nn.done;nn=Qt.next()){var yn=_f(nn.value,2),un=yn[0],En=yn[1];Rr(Object.hasOwn(q0,un)),tn.setAttribute(q0[un],Pe(En))}}catch(ii){$t={error:ii}}finally{try{nn&&!nn.done&&(ln=Qt.return)&&ln.call(Qt)}finally{if($t)throw $t.error}}return zt.indices!==void 0&&tn.setIndex(Pe(zt.indices)),tn.attributes.normal||tn.computeVertexNormals(),se.add(tn),{geo:tn,mat:fe(zt.material,!!tn.attributes.color)}})}),Re=new Set;try{for(var We=mr((_=O.skins)!==null&&_!==void 0?_:[]),Qe=We.next();!Qe.done;Qe=We.next()){var ke=Qe.value;try{for(var qe=(r=void 0,mr((g=ke.joints)!==null&&g!==void 0?g:[])),ft=qe.next();!ft.done;ft=qe.next()){var tt=ft.value;Re.add(tt)}}catch(ct){r={error:ct}}finally{try{ft&&!ft.done&&(a=qe.return)&&a.call(qe)}finally{if(r)throw r.error}}}}catch(ct){t={error:ct}}finally{try{Qe&&!Qe.done&&(i=We.return)&&i.call(We)}finally{if(t)throw t.error}}var st=new lr,Ke=new Set,en=new Map,nt=[];function on(ct,zt){var $t,ln,pn,tn,Qt,nn;Rr(!Ke.has(ct)&&Ke.size<128),Ke.add(ct);var yn=O.nodes[ct],un=Re.has(ct)?new el:new lr;if(un.name=(Qt=yn.name)!==null&&Qt!==void 0?Qt:"",un.userData.gltfNodeIndex=ct,en.set(ct,un),un.name&&!ge.has(un.name)&&ge.set(un.name,un),yn.matrix?un.matrix.fromArray(yn.matrix).decompose(un.position,un.quaternion,un.scale):(yn.translation&&un.position.fromArray(yn.translation),yn.rotation&&un.quaternion.fromArray(yn.rotation),yn.scale&&un.scale.fromArray(yn.scale)),zt.add(un),yn.mesh!==void 0)try{for(var En=mr(Ne[yn.mesh]),ii=En.next();!ii.done;ii=En.next()){var kn=ii.value,zn=kn.geo,Un=kn.mat;if(yn.skin!==void 0){var Fn=new sc(zn,Un);Fn.userData.gltfSkinIndex=yn.skin,un.add(Fn),nt.push(Fn)}else un.add(new li(zn,Un))}}catch(Wn){$t={error:Wn}}finally{try{ii&&!ii.done&&(ln=En.return)&&ln.call(En)}finally{if($t)throw $t.error}}try{for(var Jn=mr((nn=yn.children)!==null&&nn!==void 0?nn:[]),rn=Jn.next();!rn.done;rn=Jn.next()){var ri=rn.value;on(ri,un)}}catch(Wn){pn={error:Wn}}finally{try{rn&&!rn.done&&(tn=Jn.return)&&tn.call(Jn)}finally{if(pn)throw pn.error}}}try{for(var ue=mr((z=O.scenes[(b=O.scene)!==null&&b!==void 0?b:0].nodes)!==null&&z!==void 0?z:[]),hn=ue.next();!hn.done;hn=ue.next()){var gn=hn.value;on(gn,st)}}catch(ct){s={error:ct}}finally{try{hn&&!hn.done&&(o=ue.return)&&o.call(ue)}finally{if(s)throw s.error}}st.updateMatrixWorld(!0);var J=((T=O.skins)!==null&&T!==void 0?T:[]).map(function(ct){var zt,$t=(zt=ct.joints)!==null&&zt!==void 0?zt:[];Rr($t.length>0&&$t.length<=64);var ln;if(ct.inverseBindMatrices!==void 0){var pn=Pe(ct.inverseBindMatrices).array;ln=Array.from({length:$t.length},function(tn,Qt){return new Dn().fromArray(pn,Qt*16)})}else ln=$t.map(function(){return new Dn});return{joints:$t,inverseBindMatrices:ln}});try{for(var w=mr(nt),ie=w.next();!ie.done;ie=w.next()){var ye=ie.value,Ae=J[ye.userData.gltfSkinIndex];Rr(Ae);var Xe=Ae.joints.map(function(ct){return en.get(ct)});Rr(Xe.every(Boolean)),ye.bind(new tl(Xe,Ae.inverseBindMatrices.map(function(ct){return ct.clone()})),new Dn)}}catch(ct){u={error:ct}}finally{try{ie&&!ie.done&&(l=w.return)&&l.call(w)}finally{if(u)throw u.error}}var Je=[],Te=new Map;try{for(var Ie=mr(((D=O.animations)!==null&&D!==void 0?D:[]).entries()),ot=Ie.next();!ot.done;ot=Ie.next()){var yt=_f(ot.value,2),ht=yt[0],rt=yt[1],Lt=rt.name||"clip_"+ht,Bt=[],qt=0;try{for(var te=(h=void 0,mr((G=rt.channels)!==null&&G!==void 0?G:[])),at=te.next();!at.done;at=te.next()){var Ce=at.value,pt=(F=Ce.target)===null||F===void 0?void 0:F.node,lt=($=Ce.target)===null||$===void 0?void 0:$.path;if(!(pt===void 0||!["translation","rotation","scale"].includes(lt))){var He=(A=rt.samplers)===null||A===void 0?void 0:A[Ce.sampler];Rr(He);var Zt=(S=He.interpolation)!==null&&S!==void 0?S:"LINEAR";Rr(Zt==="LINEAR"||Zt==="STEP");var It=Pe(He.input).array,xt=Pe(He.output).array;It.length&&(qt=Math.max(qt,It[It.length-1])),Bt.push({nodeIndex:pt,path:lt,interp:Zt,times:It,values:xt})}}}catch(ct){h={error:ct}}finally{try{at&&!at.done&&(p=te.return)&&p.call(te)}finally{if(h)throw h.error}}var kt={name:Lt,duration:qt,tracks:Bt};Je.push(kt),Te.has(Lt)||Te.set(Lt,kt)}}catch(ct){d={error:ct}}finally{try{ot&&!ot.done&&(f=Ie.return)&&f.call(Ie)}finally{if(d)throw d.error}}return{root:st,nodesByName:ge,skins:J,animations:Je,animationsByName:Te,geometries:se,materials:Se,textures:ne,imageStatus:function(){var ct,zt,$t=0,ln=0;try{for(var pn=mr(X.values()),tn=pn.next();!tn.done;tn=pn.next()){var Qt=tn.value;Qt.ready||$t++,Qt.failed&&ln++}}catch(nn){ct={error:nn}}finally{try{tn&&!tn.done&&(zt=pn.return)&&zt.call(pn)}finally{if(ct)throw ct.error}}return{texturesPending:$t,textureErrors:ln}}}}function Tw(n,e,t){var i,r,a,s,o,u,l,d,f,h,p,y,M=(o=e.materialMode)!==null&&o!==void 0?o:"asset",v=!e.overrideMaterialName||n.name===e.overrideMaterialName,m=v&&Object.keys(t).length>0;if(M==="asset"&&!m&&((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 N={lambert:fr,unlit:Hr,standard:ll}[M],P;if(!N||n.constructor===N)P=n.clone();else{P=new N;try{for(var _=mr(["name","map","alphaTest","transparent","opacity","side","depthWrite","vertexColors","roughness","metalness","roughnessMap","metalnessMap","normalMap","aoMap","aoMapIntensity","emissiveMap","emissiveIntensity"]),g=_.next();!g.done;g=_.next()){var b=g.value;b in P&&b in n&&(P[b]=n[b])}}catch(D){i={error:D}}finally{try{g&&!g.done&&(r=_.return)&&r.call(_)}finally{if(i)throw i.error}}try{for(var z=mr(["color","emissive","normalScale"]),T=z.next();!T.done;T=z.next()){var b=T.value;P[b]&&n[b]&&P[b].copy(n[b])}}catch(D){a={error:D}}finally{try{T&&!T.done&&(s=z.return)&&s.call(z)}finally{if(a)throw a.error}}}return e.tintColor&&P.color.multiply(new Cn(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*((p=e.roughnessScale)!==null&&p!==void 0?p:1)),P.metalness=Math.min(1,P.metalness*((y=e.metalnessScale)!==null&&y!==void 0?y:1))),m&&(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 tg(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 lr,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(b){var z,T;if(((z=b.userData)===null||z===void 0?void 0:z.gltfNodeIndex)!==void 0&&f.set(b.userData.gltfNodeIndex,b),!!b.isMesh){var D=b.material;l.has(D)||l.set(D,Tw(D,e,t)),b.material=l.get(D),b.castShadow=!!e.castShadow,b.receiveShadow=!!e.receiveShadow,b.isSkinnedMesh&&((T=b.userData)===null||T===void 0?void 0:T.gltfSkinIndex)!==void 0&&h.push(b)}}),h.length){u.updateMatrixWorld(!0);try{for(var p=mr(h),y=p.next();!y.done;y=p.next()){var M=y.value,v=(a=n.skins)===null||a===void 0?void 0:a[M.userData.gltfSkinIndex];if(v){var m=v.joints.map(function(b){return f.get(b)}).filter(Boolean);m.length===v.joints.length&&M.bind(new tl(m,v.inverseBindMatrices.map(function(b){return b.clone()})),new Dn)}}}catch(b){i={error:b}}finally{try{y&&!y.done&&(r=p.return)&&r.call(p)}finally{if(i)throw i.error}}}u.userData.clonedByIndex=f,u.userData.template=n;var N=new ea().setFromObject(u,!0);if(!N.isEmpty()){var P=N.getSize(new _e),_=new _e,g=Math.max(P.x,P.y,P.z);(e.pivotMode==="center"||e.pivotMode==="bottom-center")&&(N.getCenter(_),e.pivotMode==="bottom-center"&&(_.y=N.min.y)),e.normalizeSize>0&&g>0&&u.scale.setScalar(e.normalizeSize/g),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 Fp=new _e,$0=new _e,Op=new Vr,K0=new Vr;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 p=f+h>>1;r[p]<=e?f=p:h=p}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(Op.set(a[y],a[y+1],a[y+2],a[y+3]),u===l||d===0){i.copy(Op);return}K0.set(a[M],a[M+1],a[M+2],a[M+3]),i.copy(Op).slerp(K0,d)}else{if(Fp.set(a[y],a[y+1],a[y+2]),u===l||d===0){t.copy(Fp);return}$0.set(a[M],a[M+1],a[M+2]),t.copy(Fp).lerp($0,d)}}}function j0(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 ng(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=mr(u.animations),h=f.next();!h.done;h=f.next()){var p=h.value;try{for(var y=(i=void 0,mr(p.tracks)),M=y.next();!M.done;M=y.next()){var v=M.value,m=l.get(v.nodeIndex);m&&!d.has(v.nodeIndex)&&d.set(v.nodeIndex,{pos:m.position.clone(),quat:m.quaternion.clone(),scl:m.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 N=function(){var G,F;try{for(var $=mr(d),A=$.next();!A.done;A=$.next()){var S=_f(A.value,2),H=S[0],Y=S[1],oe=l.get(H);oe&&(oe.position.copy(Y.pos),oe.quaternion.copy(Y.quat),oe.scale.copy(Y.scl))}}catch(O){G={error:O}}finally{try{A&&!A.done&&(F=$.return)&&F.call($)}finally{if(G)throw G.error}}},P=null,_=null,g=0,b=0,z=new _e,T=new Vr,D=function(){var G,F,$,A;N();var S=_&&b>0?Math.min(1,g/b):1;if(_&&S<1){var H=j0(_.time,_.clip.duration,_.loop);try{for(var Y=mr(_.clip.tracks),oe=Y.next();!oe.done;oe=Y.next()){var O=oe.value,k=l.get(O.nodeIndex);k&&(Q0(O,H,z,T),O.path==="translation"?k.position.copy(z):O.path==="rotation"?k.quaternion.copy(T):O.path==="scale"&&k.scale.copy(z))}}catch(ge){G={error:ge}}finally{try{oe&&!oe.done&&(F=Y.return)&&F.call(Y)}finally{if(G)throw G.error}}}if(P){var ne=j0(P.time,P.clip.duration,P.loop);try{for(var X=mr(P.clip.tracks),K=X.next();!K.done;K=X.next()){var O=K.value,k=l.get(O.nodeIndex);k&&(Q0(O,ne,z,T),O.path==="translation"?S<1?k.position.lerp(z,S):k.position.copy(z):O.path==="rotation"?S<1?k.quaternion.slerp(T,S):k.quaternion.copy(T):O.path==="scale"&&(S<1?k.scale.lerp(z,S):k.scale.copy(z)))}}catch(ge){$={error:ge}}finally{try{K&&!K.done&&(A=X.return)&&A.call(X)}finally{if($)throw $.error}}}};return{play:function(G,F){var $=F===void 0?{}:F,A=$.loop,S=A===void 0?"repeat":A,H=$.speed,Y=H===void 0?1:H,oe=$.fadeSeconds,O=oe===void 0?.15:oe,k=$.restart,ne=k===void 0?!1:k,X=$.startTime,K=X===void 0?0:X,ge=G?u.animationsByName.get(G):u.animations[0];return ge?P?.clip===ge&&!ne&&P.playing?(P.loop=S,P.speed=Y,!0):(_=P&&O>0?kc({},P):null,b=_?O:0,g=0,P={clip:ge,loop:S,speed:Y,time:K,playing:!0,ended:!1},D(),!0):!1},step:function(G,F){if(!P||!P.playing)return!1;var $=Math.max(0,G);_&&b>0&&(_.time+=$*_.speed,g+=$,g>=b&&(_=null,b=0)),P.time+=$*P.speed;var A=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,A=P.clip.name)),D(),A&&F?.(A),!0},reset:function(){P=null,_=null,g=0,b=0,N()},snapshot:function(){var G,F,$;return{clip:(F=(G=P?.clip)===null||G===void 0?void 0:G.name)!==null&&F!==void 0?F:null,time:P?Number(P.time.toFixed(4)):0,playing:!!P?.playing,loop:($=P?.loop)!==null&&$!==void 0?$:"repeat",clips:u.animations.map(function(A){return A.name})}}}}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)},_n=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.")},Ka=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},ig=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 ag(n,e,t,i){for(var r,a,s,o,u,l,d,f=new _e,h=new _e,p=new ga,y=n;y?.contract==="native.mesh3d.v1";y=e(y.parentId)){var M=t(y),v=i.get(y.id),m=v?.mode==="dynamic",N=m&&v.captured,P=N?Math.min(1,((r=v.captureElapsed)!==null&&r!==void 0?r:0)/.55):0,_=v?.captureTarget,g=1-P*.65;h.set(M.sx*g,M.sy*g,M.sz*g),p.set(m?-((a=v.spin)!==null&&a!==void 0?a:0):M.rx,v?.mode==="kinematic"?-((s=v.angle)!==null&&s!==void 0?s:M.ry):M.ry,m?((o=v.spin)!==null&&o!==void 0?o:0)*.22:M.rz),f.multiply(h).applyEuler(p),h.set(((u=v?.x)!==null&&u!==void 0?u:M.x)+(N&&_?(_.x-v.x)*P:0),((l=v?.y)!==null&&l!==void 0?l:M.y)-P*.45,((d=v?.z)!==null&&d!==void 0?d:M.z)+(N&&_?(_.z-v.z)*P:0)),f.add(h)}return{x:f.x,y:f.y,z:f.z}}function Ew(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 dr;return h.setAttribute("position",new mi(o,3)),h.setAttribute("normal",new mi(u,3)),h.setAttribute("uv",new mi(l,2)),h.setIndex(Array.from(f)),h}function rg(n,e,t){return!n||t>=1?0:t<=-1?1.1:(1-t)*.55}function Aw(n,e,t){var i,r,a,s,o,u,l,d,f,h,p,y,M,v,m,N,P,_=new lr,g=!!n.fairwayRamp,b=(M=n.cupX)!==null&&M!==void 0?M:0,z=(v=n.cupZ)!==null&&v!==void 0?v:-4.8,T=(m=n.cupRadius)!==null&&m!==void 0?m:.23,D=new Ur(1,1,1),G=new Map,F=function(Ie,ot,yt,ht,rt,Lt,Bt){var qt=G.get(Bt);qt||(qt=new fr({color:Bt}),G.set(Bt,qt));var te=new li(D,qt);te.position.set(Ie,ot,yt),te.scale.set(ht,rt,Lt),_.add(te)};try{for(var $=_n([-3.2,3.2]),A=$.next();!A.done;A=$.next()){var S=A.value;F(S,-.65,0,.2,1.1,14.6,"#a1b8b1"),F(S-Math.sign(S)*.1,-.18,0,.2,.25,14.4,"#e9cea5")}}catch(Ie){i={error:Ie}}finally{try{A&&!A.done&&(r=$.return)&&r.call($)}finally{if(i)throw i.error}}try{for(var H=_n([-7.2,7.2]),Y=H.next();!Y.done;Y=H.next()){var oe=Y.value;F(0,-.65,oe,6.4,1.1,.2,"#a1b8b1"),F(0,-.18,oe-Math.sign(oe)*.1,6.2,.25,.2,"#e9cea5")}}catch(Ie){a={error:Ie}}finally{try{Y&&!Y.done&&(s=H.return)&&s.call(H)}finally{if(a)throw a.error}}var O=.5,k=.5;if(t){var ne=t.getAttribute("uv"),X=t.getAttribute("normal");if(ne&&X){for(var K=0;K<X.count&&X.getY(K)<.9;)K++;K<ne.count&&(O=ne.getX(K),k=ne.getY(K))}}var ge=!!(e&&(!((N=e.image)===null||N===void 0)&&N.complete)&&((P=e.image)===null||P===void 0?void 0:P.naturalWidth)>0),se=ge?new fr({map:e}):new fr({color:"#6ec458"}),Se=ge?new fr({map:e,color:"#779263"}):new fr({color:"#5a9949"});e&&!ge&&(se.userData.pendingTex={tex:e,color:"#ffffff"},Se.userData.pendingTex={tex:e,color:"#779263"});var Pe=g?[[-7,-1],[-1,1],[1,7]]:[[-7,7]];try{for(var le=_n(Pe),ae=le.next();!ae.done;ae=le.next()){var fe=Ka(ae.value,2),Ne=fe[0],Re=fe[1],We=new al;if(We.moveTo(-3,Ne),We.lineTo(3,Ne),We.lineTo(3,Re),We.lineTo(-3,Re),We.closePath(),z>Ne&&z<Re){var Qe=new ao;Qe.absarc(b,z,T,0,Math.PI*2,!0),We.holes.push(Qe)}for(var ke=new yc(We,32),qe=ke.getAttribute("position"),ft=!1,tt=!1,st=0;st<qe.count;st++){var Ke=qe.getX(st),en=qe.getY(st),nt=rg(g,Ke,en);nt===0&&(ft=!0),nt>0&&(tt=!0),qe.setXYZ(st,Ke,nt,en)}var on=ke.getIndex();if(on)for(var st=0;st<on.count;st+=3){var ue=on.getX(st+1);on.setX(st+1,on.getX(st+2)),on.setX(st+2,ue)}ke.computeVertexNormals();for(var hn=ke.getAttribute("uv"),st=0;st<hn.count;st++)hn.setXY(st,O,k);var gn=new li(ke,g&&ft&&tt?Se:se);gn.name="continuous-fairway",_.add(gn)}}catch(Ie){o={error:Ie}}finally{try{ae&&!ae.done&&(u=le.return)&&u.call(le)}finally{if(o)throw o.error}}var J="#d69260",w="#f1bd87";try{for(var ie=_n([-3.1,3.1]),ye=ie.next();!ye.done;ye=ie.next()){var S=ye.value;F(S,.12,0,.2,.3,14.2,J),F(S,.29,0,.22,.04,14.2,w)}}catch(Ie){l={error:Ie}}finally{try{ye&&!ye.done&&(d=ie.return)&&d.call(ie)}finally{if(l)throw l.error}}try{for(var Ae=_n([-7.1,7.1]),Xe=Ae.next();!Xe.done;Xe=Ae.next()){var oe=Xe.value;F(0,rg(g,0,oe>0?6:-6)+.12,oe,6.4,.3,.2,J)}}catch(Ie){f={error:Ie}}finally{try{Xe&&!Xe.done&&(h=Ae.return)&&h.call(Ae)}finally{if(f)throw f.error}}if(g)try{for(var Je=_n([-3.1,3.1]),Te=Je.next();!Te.done;Te=Je.next()){var S=Te.value;F(S,.7,-4.5,.2,1.1,5.2,J)}}catch(Ie){p={error:Ie}}finally{try{Te&&!Te.done&&(y=Je.return)&&y.call(Je)}finally{if(p)throw p.error}}return _}function Iw(n){var e,t=new lr,i=(e=n.cupRadius)!==null&&e!==void 0?e:.23,r=new li(new ro(i,i*.89,.48,24,1,!0),new fr({color:"#244640",side:Ir}));r.position.y=-.24,t.add(r);var a=new li(new il(i*.91,24),new Hr({color:"#082c2b"}));a.rotation.x=-Math.PI/2,a.position.y=-.475,t.add(a);var s=new li(new ro(i,i*.978,.09,24,1,!0),new fr({color:"#eee9cf",side:Ir}));s.position.y=-.045,t.add(s);var o=new li(new ol(i,i+.06,24),new fr({color:"#fff7d1"}));return o.rotation.x=-Math.PI/2,o.position.y=.004,t.add(o),t}function Cw(){for(var n,e,t=new lr,i=new Ur(.18,1,.18),r=new fr({color:"#b27b59"}),a=new Ur(1.5,.2,1.6),s=new fr({color:"#82b88b"}),o=new ms(.62,7,5),u=new ms(.49,7,5),l=new fr({color:"#77b86b"}),d=new fr({color:"#3e9d79"}),f=new Ra(i,r,14),h=new Ra(a,s,14),p=5,y=9,M=new Ra(o,l,p),v=new Ra(u,l,p),m=new Ra(o,d,y),N=new Ra(u,d,y),P=new Dn,_=0,g=0,b=0;b<14;b++){var z=b%2?-1:1,T=z*(3.8+b%3*.35),D=-6.5+Math.floor(b/2)*2;P.makeTranslation(T,-.02,D),f.setMatrixAt(b,P),P.makeTranslation(T,-.48,D),h.setMatrixAt(b,P),b%3===0?(P.makeTranslation(T,.5,D),M.setMatrixAt(_,P),P.makeTranslation(T,1,D),v.setMatrixAt(_,P),_++):(P.makeTranslation(T,.5,D),m.setMatrixAt(g,P),P.makeTranslation(T,1,D),N.setMatrixAt(g,P),g++)}try{for(var G=_n([f,h,M,v,m,N]),F=G.next();!F.done;F=G.next()){var $=F.value;$.instanceMatrix.needsUpdate=!0,t.add($)}}catch(A){n={error:A}}finally{try{F&&!F.done&&(e=G.return)&&e.call(G)}finally{if(n)throw n.error}}return t}function Rw(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 Pw(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 Is(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 sg(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,k;try{for(var ne=_n(p.values()),X=ne.next();!X.done;X=ne.next()){var K=X.value;K.textureDirty=!0}}catch(ge){O={error:ge}}finally{try{X&&!X.done&&(k=ne.return)&&k.call(ne)}finally{if(O)throw O.error}}t?.()}function f(O){var k,ne,X,K,ge,se,Se;if(!s.has((ge=O.hash)!==null&&ge!==void 0?ge:O.id)){var Pe=Uint8Array.from(atob(O.data),function(ke){return ke.charCodeAt(0)}),le=eg(Pe,d);try{for(var ae=_n(le.geometries),fe=ae.next();!fe.done;fe=ae.next()){var Ne=fe.value;o.add(Ne)}}catch(ke){k={error:ke}}finally{try{fe&&!fe.done&&(ne=ae.return)&&ne.call(ae)}finally{if(k)throw k.error}}try{for(var Re=_n(le.materials),We=Re.next();!We.done;We=Re.next()){var Qe=We.value;u.add(Qe)}}catch(ke){X={error:ke}}finally{try{We&&!We.done&&(K=Re.return)&&K.call(Re)}finally{if(X)throw X.error}}s.set((se=O.hash)!==null&&se!==void 0?se:O.id,le)}return s.get((Se=O.hash)!==null&&Se!==void 0?Se:O.id)}function h(O){var k,ne,X,K,ge=new Set,se=new Set;O.traverse(function(Re){var We,Qe;if(Re.geometry&&!o.has(Re.geometry)&&ge.add(Re.geometry),Re.material)try{for(var ke=_n(Array.isArray(Re.material)?Re.material:[Re.material]),qe=ke.next();!qe.done;qe=ke.next()){var ft=qe.value;u.has(ft)||se.add(ft)}}catch(tt){We={error:tt}}finally{try{qe&&!qe.done&&(Qe=ke.return)&&Qe.call(ke)}finally{if(We)throw We.error}}});try{for(var Se=_n(ge),Pe=Se.next();!Pe.done;Pe=Se.next()){var le=Pe.value;le.dispose()}}catch(Re){k={error:Re}}finally{try{Pe&&!Pe.done&&(ne=Se.return)&&ne.call(Se)}finally{if(k)throw k.error}}try{for(var ae=_n(se),fe=ae.next();!fe.done;fe=ae.next()){var Ne=fe.value;Ne.dispose()}}catch(Re){X={error:Re}}finally{try{fe&&!fe.done&&(K=ae.return)&&K.call(ae)}finally{if(X)throw X.error}}}var p=new Map,y,M,v,m,N;function P(){var O,k;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 ne,X;N=void 0;try{for(var K=_n(p.values()),ge=K.next();!ge.done;ge=K.next()){var se=ge.value;se.compiled=!1,se.textureDirty=!0,se.lastRenderedTime=-1,se.lastFlagStep=-1}}catch(Se){ne={error:Se}}finally{try{ge&&!ge.done&&(X=K.return)&&X.call(K)}finally{if(ne)throw ne.error}}t?.()}),v=document.createElement("canvas"),m=(k=v.getContext)===null||k===void 0?void 0:k.call(v,"2d"),M=new gf({canvas:y,antialias:!0,alpha:!1,preserveDrawingBuffer:!1,powerPreference:"default"}),M.shadowMap.type=wd,M}catch{return M=null,null}}function _(O){if(O){if(r.has(O))return r.get(O);var k=e.get(O);if(!(!k||k.mime!=="model/tora-mesh"||!k.data)){var ne=Ew(k.data);return r.set(O,ne),o.add(ne),ne}}}function g(O,k){if(O){var ne=(k??"stage")+":"+O;if(a.has(ne))return a.get(ne);var X=e.get(O);if(!(!X||!X.mime.startsWith("image/")||!X.data)){var K=new Image,ge=new _r(K);ge.colorSpace=k==="normalMap"?Or:xr,k&&(ge.flipY=!1,ge.wrapS=ge.wrapT=As);var se=function(Se){var Pe,le;ge.needsUpdate=!0;try{for(var ae=_n(p.values()),fe=ae.next();!fe.done;fe=ae.next()){var Ne=fe.value;Ne.scene.traverse(function(Re){var We,Qe,ke,qe=Re.isMesh&&Re.material?Array.isArray(Re.material)?Re.material:[Re.material]:[];try{for(var ft=(We=void 0,_n(qe)),tt=ft.next();!tt.done;tt=ft.next()){var st=tt.value;!((ke=st.userData)===null||ke===void 0)&&ke.pendingTex&&st.userData.pendingTex.tex===ge&&(st.map=ge,st.color.set(st.userData.pendingTex.color||"#ffffff"),delete st.userData.pendingTex,st.needsUpdate=!0)}}catch(Ke){We={error:Ke}}finally{try{tt&&!tt.done&&(Qe=ft.return)&&Qe.call(ft)}finally{if(We)throw We.error}}}),Ne.textureDirty=!0}}catch(Re){Pe={error:Re}}finally{try{fe&&!fe.done&&(le=ae.return)&&le.call(ae)}finally{if(Pe)throw Pe.error}}Se&&t?.()};return a.set(ne,ge),K.onload=function(){return se(!0)},K.src="data:"+X.mime+";base64,"+X.data,K.complete&&K.naturalWidth&&se(!1),ge}}}function b(O){var k,ne,X,K,ge,se,Se,Pe,le,ae,fe,Ne,Re,We,Qe,ke,qe,ft,tt,st,Ke=O.parameters,en=new ic;en.background=new Cn(Ke.skyColor||"#b8e2ed");var nt=new Er((X=Ke.cameraFov)!==null&&X!==void 0?X:39,1,.1,160);nt.position.set((K=Ke.cameraX)!==null&&K!==void 0?K:10,(ge=Ke.cameraY)!==null&&ge!==void 0?ge:18,(se=Ke.cameraZ)!==null&&se!==void 0?se:21),nt.lookAt((Se=Ke.lookAtX)!==null&&Se!==void 0?Se:0,(Pe=Ke.lookAtY)!==null&&Pe!==void 0?Pe:.15,(le=Ke.lookAtZ)!==null&&le!==void 0?le:0),en.add(nt),en.add(new Mc(Ke.hemiSkyColor||"#fff9dd",Ke.hemiGroundColor||"#527b75",(ae=Ke.hemiIntensity)!==null&&ae!==void 0?ae:1.8));var on=new bc(Ke.sunColor||"#fff0cf",(fe=Ke.sunIntensity)!==null&&fe!==void 0?fe:2.1);on.position.set((Ne=Ke.sunX)!==null&&Ne!==void 0?Ne:-9,(Re=Ke.sunY)!==null&&Re!==void 0?Re:18,(We=Ke.sunZ)!==null&&We!==void 0?We:8),en.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 ue=g((ke=(Qe=O.assetSlots)===null||Qe===void 0?void 0:Qe[0])===null||ke===void 0?void 0:ke.assetId),hn=new Map,gn=new Map,J=[],w=[],ie=new Map;function ye(xt,kt,ct,zt){xt.traverse(function($t){$t.userData.toraRootId=kt,$t.userData.toraSourceId=ct,zt&&($t.userData.cameraAttached=!0)})}function Ae(xt,kt,ct,zt,$t){var ln,pn,tn,Qt,nn,yn,un,En,ii,kn,zn,Un,Fn,Jn,rn,ri,Wn,Ei,Rn,ci,R=xt.parameters,ce,we=function(){var _t,Gt,De={},Ht=!!(ue&&(!((_t=ue.image)===null||_t===void 0)&&_t.complete)&&((Gt=ue.image)===null||Gt===void 0?void 0:Gt.naturalWidth)>0);R.useTexture&&ue&&Ht?De.map=ue:De.color=R.useTexture?R.waveFlag?"#e85d56":"#d89b6a":R.color||"#ffffff",R.doubleSide&&(De.side=Ir),R.opacity<1&&(De.transparent=!0,De.opacity=R.opacity,De.depthWrite=!1);var an=R.unlit?new Hr(De):new fr(De);return R.useTexture&&ue&&!Ht&&(an.userData.pendingTex={tex:ue,color:"#ffffff"}),an};if(R.primitive==="model"||R.primitive==="mesh"&&!R.waveFlag){ce=new lr;var ve,de,mt,Ct=((ln=n.gameplay)!==null&&ln!==void 0?ln:[]).find(function(_t){var Gt;return _t.kind==="animate-3d"&&_t.componentId===((Gt=xt.prototypeId)!==null&&Gt!==void 0?Gt:xt.id)}),Ye={sourceId:zt,animator:null,modelBounds:null,startDefaultAnimation:function(){var _t,Gt,De;if(!(!Ye.animator||!Ct)){var Ht=Ct.parameters;Ht.autoplay!==!1&&Ye.animator.play(Ht.clipName||"",{loop:(_t=Ht.loop)!==null&&_t!==void 0?_t:"repeat",speed:(Gt=Ht.speed)!==null&&Gt!==void 0?Gt:1,fadeSeconds:0,restart:!0,startTime:(De=Ht.startTime)!==null&&De!==void 0?De:0})}},update:function(_t){var Gt,De,Ht,an,Pn,An,Xn,Ge=(Ht=i.get(xt.id))===null||Ht===void 0?void 0:Ht.slots,Yn=(an=i.get(xt.prototypeId))===null||an===void 0?void 0:an.slots,Et=function(Mi){var ir,sa,Da,rr;return(sa=(ir=Ge?.[Mi])!==null&&ir!==void 0?ir:Yn?.[Mi])!==null&&sa!==void 0?sa:(rr=(Da=xt.assetSlots)===null||Da===void 0?void 0:Da.find(function(ar){return ar.slotId===Mi}))===null||rr===void 0?void 0:rr.assetId},vt=["source","texture","normalMap","emissiveMap"].map(Et),si=["subNode","materialMode","overrideMaterialName","opacity","tintColor","roughnessScale","metalnessScale","castShadow","receiveShadow","normalizeSize","pivotMode","color","useTexture"];if(de&&vt.every(function(Mi,ir){return Mi===de[ir]})&&si.every(function(Mi){return _t[Mi]===mt[Mi]}))return!1;var Ni=e.get(vt[0]);if(ve&&(ce.remove(ve),h(ve)),Ye.animator=null,Ye.modelBounds=null,Ni?.mime==="model/gltf-binary"){var nr={};try{for(var Vn=_n(["texture","normalMap","emissiveMap"].entries()),$n=Vn.next();!$n.done;$n=Vn.next()){var Wi=Ka($n.value,2),jn=Wi[0],Ki=Wi[1];vt[jn+1]&&(nr[Ki]=g(vt[jn+1],Ki))}}catch(Mi){Gt={error:Mi}}finally{try{$n&&!$n.done&&(De=Vn.return)&&De.call(Vn)}finally{if(Gt)throw Gt.error}}ve=tg(f(Ni),_t,nr),Ye.modelBounds=(An=(Pn=ve.userData)===null||Pn===void 0?void 0:Pn.modelBounds)!==null&&An!==void 0?An:null,Ye.animator=ng(ve),Ye.startDefaultAnimation()}else ve=new li((Xn=_(vt[0]))!==null&&Xn!==void 0?Xn:new Ur(1,1,1),we()),ve.castShadow=!!_t.castShadow,ve.receiveShadow=!!_t.receiveShadow,vt[1]?ve.material.map=g(vt[1]):_t.color&&!_t.useTexture&&ve.material.color.set(_t.color);return ce.add(ve),ye(ve,ct,zt,$t),de=vt,mt=zc({},_t),!0}};Ye.update(R),ie.set(xt.id,Ye)}else if(R.primitive==="group")ce=new lr;else if(R.primitive==="fairway")ce=Aw(R,ue,_((tn=(pn=xt.assetSlots)===null||pn===void 0?void 0:pn[0])===null||tn===void 0?void 0:tn.assetId));else if(R.primitive==="cup")ce=Iw(R);else if(R.primitive==="garden")ce=Cw();else if(R.primitive==="mesh"){var Rt=_((nn=(Qt=xt.assetSlots)===null||Qt===void 0?void 0:Qt[0])===null||nn===void 0?void 0:nn.assetId),Dt=R.waveFlag&&Rt?Rt.clone():Rt??new Ur(1,1,1);ce=new li(Dt,we()),R.waveFlag&&Rt&&J.push({geo:Dt,rest:new Float32Array(Dt.getAttribute("position").array)})}else R.primitive==="sphere"?ce=new li(new ms((yn=R.radiusTop)!==null&&yn!==void 0?yn:.5,16,12),we()):R.primitive==="cylinder"?ce=new li(new ro((un=R.radiusTop)!==null&&un!==void 0?un:.23,(En=R.radiusBottom)!==null&&En!==void 0?En:.21,1,32,1,!!R.openEnded),we()):R.primitive==="ring"?ce=new li(new ol((ii=R.innerRadius)!==null&&ii!==void 0?ii:0,(kn=R.radiusTop)!==null&&kn!==void 0?kn:.15,24),we()):R.primitive==="circle"?ce=new li(new il((zn=R.radiusTop)!==null&&zn!==void 0?zn:.21,32),we()):ce=new li(new Ur(1,1,1),we());return ce.position.set((Un=R.x)!==null&&Un!==void 0?Un:0,(Fn=R.y)!==null&&Fn!==void 0?Fn:0,(Jn=R.z)!==null&&Jn!==void 0?Jn:0),ce.rotation.set((rn=R.rx)!==null&&rn!==void 0?rn:0,(ri=R.ry)!==null&&ri!==void 0?ri:0,(Wn=R.rz)!==null&&Wn!==void 0?Wn:0),ce.scale.set((Ei=R.sx)!==null&&Ei!==void 0?Ei:1,(Rn=R.sy)!==null&&Rn!==void 0?Rn:1,(ci=R.sz)!==null&&ci!==void 0?ci:1),ce.visible=R.visible!==!1,ye(ce,ct,zt,$t),kt.add(ce),ce}var Xe=[],Je=new Map,Te=function(xt,kt,ct){var zt,$t;try{for(var ln=_n(n.components),pn=ln.next();!pn.done;pn=ln.next()){var tn=pn.value;if(tn.parentId===xt&&tn.contract==="native.mesh3d.v1"&&!tn.prototype){var Qt=kt??tn,nn=ct||!!tn.parameters.attachToCamera;Je.set(tn.id,{rootId:Qt.id,sourceId:Qt.id,cameraAttached:nn}),Xe.push(tn),Te(tn.id,Qt,nn)}}}catch(yn){zt={error:yn}}finally{try{pn&&!pn.done&&($t=ln.return)&&$t.call(ln)}finally{if(zt)throw zt.error}}};Te(O.id,null,!1);var Ie=function(xt){var kt=xt.parameters,ct=Je.get(xt.id),zt=kt.attachToCamera&&xt.parentId===O.id?nt:xt.parentId===O.id?en:(qe=hn.get(xt.parentId))!==null&&qe!==void 0?qe:en,$t=Ae(xt,zt,ct.rootId,ct.sourceId,ct.cameraAttached);if(hn.set(xt.id,$t),kt.confetti){var ln=new lr;ln.userData.isConfetti=!0;var pn=new Ur(.08,.025,.12),tn=["#ffda69","#fff6c9","#ef8774","#7cc6bf"].map(function(nn){return new Hr({color:nn})}),Qt=Array.from({length:28},function(nn,yn){var un=new li(pn,tn[yn%4]);return un.visible=!1,ln.add(un),un});en.add(ln),w.push({id:xt.id,origin:{x:(ft=kt.x)!==null&&ft!==void 0?ft:0,y:(tt=kt.y)!==null&&tt!==void 0?tt:0,z:(st=kt.z)!==null&&st!==void 0?st:0},pieces:Qt})}};try{for(var ot=_n(Xe),yt=ot.next();!yt.done;yt=ot.next()){var ht=yt.value;Ie(ht)}}catch(xt){k={error:xt}}finally{try{yt&&!yt.done&&(ne=ot.return)&&ne.call(ot)}finally{if(k)throw k.error}}var rt=new lr;en.add(rt);var Lt=new ms(1,8,5),Bt=new Hr({color:"#fff1a2",transparent:!0,opacity:.85}),qt=Array.from({length:24},function(){var xt=new li(Lt,Bt);return xt.visible=!1,rt.add(xt),xt}),te=new wc,at=new Kt,Ce=new _e,pt=new jr(new _e(0,1,0),0),lt=new _e,He="",Zt=Array.from(hn,function(xt){var kt=Ka(xt,2),ct=kt[0],zt=kt[1];return{id:ct,obj:zt,comp:n.components.find(function($t){return $t.id===ct})}}).filter(function(xt){return xt.comp}),It={id:O.id,scene:en,camera:nt,nodes:hn,dynamicNodes:gn,nodeEntries:Zt,createMeshObject:Ae,modelBindings:ie,sun:on,wavingFlags:J,confettiSystems:w,guideGroup:rt,guidePool:qt,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(xt){var kt=xt?Math.min(xt.length,qt.length):0,ct=kt?xt.slice(0,kt).map(function(tn){return"".concat(tn.x.toFixed(2),",").concat(tn.y.toFixed(2),",").concat(tn.z.toFixed(2))}).join("|"):"";if(ct!==He){He=ct,It.guideDirty=!0;for(var zt=0;zt<qt.length;zt++){var $t=qt[zt];if(zt<kt){var ln=xt[zt],pn=.055*(1-zt/kt*.5);$t.visible=!0,$t.scale.setScalar(pn),$t.position.set(ln.x,ln.y+.03,ln.z)}else $t.visible=!1}}},project:function(xt,kt,ct){return Ce.set(xt.x,xt.y,xt.z).project(nt),{x:(Ce.x+1)*kt/2,y:(1-Ce.y)*ct/2}},unproject:function(xt,kt,ct,zt,$t){return at.set(xt/ct*2-1,1-kt/zt*2),te.setFromCamera(at,nt),pt.constant=-$t,te.ray.intersectPlane(pt,lt)?{x:lt.x,y:lt.y,z:lt.z}:null},raycast:function(xt,kt,ct,zt){var $t,ln,pn,tn,Qt,nn,yn,un,En,ii,kn,zn,Un,Fn,Jn,rn;ct===void 0&&(ct=80);var ri=zt===void 0?{}:zt,Wn=ri.isTarget,Ei=Wn===void 0?function(){return!0}:Wn,Rn=ri.isOccluder,ci=Rn===void 0?function(){return!1}:Rn;en.updateMatrixWorld(!0),nt.updateMatrixWorld(!0),at.set(xt,kt),te.near=.05,te.far=ct,te.setFromCamera(at,nt);var R=[];try{for(var ce=_n(It.nodes.values()),we=ce.next();!we.done;we=ce.next()){var ve=we.value;if(!(!ve.visible||!((yn=ve.userData)===null||yn===void 0)&&yn.cameraAttached)){var de=(un=ve.userData)===null||un===void 0?void 0:un.toraRootId,mt=(En=ve.userData)===null||En===void 0?void 0:En.toraSourceId;de&&(Ei(de,mt)||ci(de,mt))&&R.push(ve)}}}catch(Xn){$t={error:Xn}}finally{try{we&&!we.done&&(ln=ce.return)&&ln.call(ce)}finally{if($t)throw $t.error}}try{for(var Ct=_n(It.dynamicNodes.values()),Ye=Ct.next();!Ye.done;Ye=Ct.next()){var ve=Ye.value;if(!(!ve.visible||!((ii=ve.userData)===null||ii===void 0)&&ii.cameraAttached)){var de=(kn=ve.userData)===null||kn===void 0?void 0:kn.toraRootId,mt=(zn=ve.userData)===null||zn===void 0?void 0:zn.toraSourceId;de&&(Ei(de,mt)||ci(de,mt))&&R.push(ve)}}}catch(Xn){pn={error:Xn}}finally{try{Ye&&!Ye.done&&(tn=Ct.return)&&tn.call(Ct)}finally{if(pn)throw pn.error}}var Rt=te.intersectObjects(R.length?R:en.children,!0),Dt=new Set;try{for(var _t=_n(Rt),Gt=_t.next();!Gt.done;Gt=_t.next()){for(var De=Gt.value,Ht=!1,an=De.object;an;an=an.parent)if(!an.visible||an===rt||!((Un=an.userData)===null||Un===void 0)&&Un.cameraAttached||!((Fn=an.userData)===null||Fn===void 0)&&Fn.isConfetti){Ht=!0;break}if(!Ht){var Pn=(Jn=De.object.userData)===null||Jn===void 0?void 0:Jn.toraRootId,An=(rn=De.object.userData)===null||rn===void 0?void 0:rn.toraSourceId;if(!(!Pn||Dt.has(Pn))){if(Dt.add(Pn),Ei(Pn,An))return{id:Pn,sourceId:An,distance:De.distance,point:{x:De.point.x,y:De.point.y,z:De.point.z}};if(ci(Pn,An))return null}}}}catch(Xn){Qt={error:Xn}}finally{try{Gt&&!Gt.done&&(nn=_t.return)&&nn.call(_t)}finally{if(Qt)throw Qt.error}}return null}};return p.set(O.id,It),It}function z(O){var k;return(k=p.get(O.id))!==null&&k!==void 0?k:b(O)}function T(O,k){var ne,X,K,ge,se,Se;if(!k.length&&!O.contactBatches)return!1;O.contactBatches||(O.contactBatches=[new ms(1,6,4),new Ur(1,.2,1.6)].map(function(Ke){var en=new Ra(Ke,new Hr({toneMapped:!1}),256);return en.userData.isConfetti=!0,en.frustumCulled=!1,en.count=0,O.scene.add(en),en}),O.contactPose=new ur,O.contactColor=new Cn);var Pe=O.contactBatches.some(function(Ke){return Ke.count>0});try{for(var le=_n(O.contactBatches),ae=le.next();!ae.done;ae=le.next()){var fe=ae.value;fe.count=0}}catch(Ke){ne={error:Ke}}finally{try{ae&&!ae.done&&(X=le.return)&&X.call(le)}finally{if(ne)throw ne.error}}var Ne=O.contactBatches,Re=O.contactPose,We=O.contactColor;try{for(var Qe=_n(k),ke=Qe.next();!ke.done;ke=Qe.next()){var qe=ke.value,fe=Ne[Number(qe.confetti)],ft=qe.age;Re.position.set(qe.x+qe.vx*ft,qe.y+qe.vy*ft-qe.gravity*ft*ft/2,qe.z+qe.vz*ft),Re.rotation.set(qe.spinX*ft,qe.spinZ*ft/2,qe.spinZ*ft),Re.scale.setScalar(qe.size*Math.min(1,(qe.life-ft)*7)),Re.updateMatrix(),fe.setMatrixAt(fe.count,Re.matrix),fe.setColorAt(fe.count,We.set(qe.color)),fe.count++}}catch(Ke){K={error:Ke}}finally{try{ke&&!ke.done&&(ge=Qe.return)&&ge.call(Qe)}finally{if(K)throw K.error}}try{for(var tt=_n(Ne),st=tt.next();!st.done;st=tt.next()){var fe=st.value;fe.instanceMatrix.needsUpdate=!0,fe.instanceColor&&(fe.instanceColor.needsUpdate=!0)}}catch(Ke){se={error:Ke}}finally{try{st&&!st.done&&(Se=tt.return)&&Se.call(tt)}finally{if(se)throw se.error}}return Pe||k.length>0}function D(O,k){var ne,X,K,ge,se,Se,Pe,le,ae,fe,Ne,Re,We,Qe,ke,qe,ft,tt,st,Ke,en,nt,on,ue,hn,gn,J,w,ie,ye,Ae,Xe,Je,Te,Ie,ot,yt,ht,rt,Lt,Bt,qt,te,at,Ce,pt,lt,He,Zt,It,xt,kt,ct,zt,$t,ln,pn,tn,Qt,nn,yn,un,En,ii,kn,zn,Un,Fn,Jn,rn,ri,Wn=k.time,Ei=Wn===void 0?0:Wn,Rn=k.ambientTime,ci=k.propsOf,R=k.bodies3d,ce=k.fpsPose,we=k.instances3d,ve=we===void 0?[]:we,de=k.aimLocked,mt=de===void 0?!1:de,Ct=k.groundFn,Ye=k.worldWidth,Rt=Ye===void 0?390:Ye,Dt=k.worldHeight,_t=Dt===void 0?700:Dt,Gt=k.designHeight,De=z(O),Ht=Rn??Ei,an=ci(O),Pn=an.skyColor||"#b8e2ed";De.skyColor!==Pn&&(De.skyColor=Pn,De.scene.background=new Cn(Pn));var An=new Set(ve.map(function(Bn){return Bn.id}));try{for(var Xn=_n(De.dynamicNodes),Ge=Xn.next();!Ge.done;Ge=Xn.next()){var Yn=Ka(Ge.value,2),Et=Yn[0],vt=Yn[1];An.has(Et)||((Ne=vt.parent)===null||Ne===void 0||Ne.remove(vt),h(vt),De.modelBindings.delete(Et),De.dynamicNodes.delete(Et))}}catch(Bn){ne={error:Bn}}finally{try{Ge&&!Ge.done&&(X=Xn.return)&&X.call(Xn)}finally{if(ne)throw ne.error}}var si=function(Bn){if(De.dynamicNodes.has(Bn.id))return"continue";var zs=Bn.parentId===O.id?De.scene:(We=(Re=De.dynamicNodes.get(Bn.parentId))!==null&&Re!==void 0?Re:De.nodes.get(Bn.parentId))!==null&&We!==void 0?We:De.scene,Yr=(Qe=Bn.instanceId)!==null&&Qe!==void 0?Qe:Bn.id,ja=(ke=ve.find(function(es){return es.id===Yr}))!==null&&ke!==void 0?ke:Bn,Ma=(qe=ja.prototypeId)!==null&&qe!==void 0?qe:ja.id,Vs=De.createMeshObject(Bn,zs,Yr,Ma,!!Bn.parameters.attachToCamera);De.dynamicNodes.set(Bn.id,Vs)};try{for(var Ni=_n(ve),nr=Ni.next();!nr.done;nr=Ni.next()){var Vn=nr.value;si(Vn)}}catch(Bn){K={error:Bn}}finally{try{nr&&!nr.done&&(ge=Ni.return)&&ge.call(Ni)}finally{if(K)throw K.error}}var $n=_t>=Rt,Wi=De.lastTime<0||Ht<De.lastTime?0:Math.min(.05,Ht-De.lastTime),jn=Math.max(1,_t/Math.max(1,Gt??_t)),Ki=function(Bn){return jn>1.001?Math.min(135,2*Math.atan(Math.tan(Bn*Math.PI/360)*jn)*(180/Math.PI)):Bn},Mi=Rt/Math.max(1,_t),ir=Ki(ce?$n?(ft=an.cameraFov)!==null&&ft!==void 0?ft:68:(tt=an.landscapeCameraFov)!==null&&tt!==void 0?tt:54:$n?(st=an.cameraFov)!==null&&st!==void 0?st:39:(Ke=an.landscapeCameraFov)!==null&&Ke!==void 0?Ke:22.6199);De.recoil>0&&(De.recoil=Wi>0?De.recoil*Math.exp(-10*Wi):De.recoil,De.recoil<.002&&(De.recoil=0));var sa=ig(ig([],Ka(De.nodeEntries),!1),Ka(ve.map(function(Bn){return{id:Bn.id,obj:De.dynamicNodes.get(Bn.id),comp:Bn}}).filter(function(Bn){return Bn.obj})),!1),Da="";try{for(var rr=_n(sa),ar=rr.next();!ar.done;ar=rr.next()){var Vi=ar.value,Yt=Vi.id,vi=Vi.obj,Vn=Vi.comp,On=ci(Vn);vi.visible=On.visible!==!1,!((en=De.modelBindings.get(Yt))===null||en===void 0)&&en.update(On)&&(De.textureDirty=!0,De.compiled=!1),!On.useTexture&&vi.isMesh&&(!((nt=vi.material)===null||nt===void 0)&&nt.color)&&On.color&&vi.material.color.set(On.color);var Nn=R?.get(Yt);if(Nn&&Nn.mode==="dynamic"){var _a=Nn.captured?Math.min(1,((on=Nn.captureElapsed)!==null&&on!==void 0?on:0)/.55):0,qc=Nn.captured&&Nn.captureTarget?Nn.x+(Nn.captureTarget.x-Nn.x)*_a:Nn.x,bn=Nn.y-_a*.45,sr=Nn.captured&&Nn.captureTarget?Nn.z+(Nn.captureTarget.z-Nn.z)*_a:Nn.z;vi.position.set(qc,bn,sr);var Xi=1-_a*.65;vi.scale.set(((ue=On.sx)!==null&&ue!==void 0?ue:1)*Xi,((hn=On.sy)!==null&&hn!==void 0?hn:1)*Xi,((gn=On.sz)!==null&&gn!==void 0?gn:1)*Xi),vi.rotation.set(-((J=Nn.spin)!==null&&J!==void 0?J:0),(w=On.ry)!==null&&w!==void 0?w:0,((ie=Nn.spin)!==null&&ie!==void 0?ie:0)*.22)}else if(Nn&&Nn.mode==="kinematic")vi.position.set(Nn.x,(Ae=(ye=Nn.y)!==null&&ye!==void 0?ye:On.y)!==null&&Ae!==void 0?Ae:0,Nn.z),vi.rotation.set((Xe=On.rx)!==null&&Xe!==void 0?Xe:0,-((Te=(Je=Nn.angle)!==null&&Je!==void 0?Je:On.ry)!==null&&Te!==void 0?Te:0),(Ie=On.rz)!==null&&Ie!==void 0?Ie:0);else if(On.dropShadowOf&&R?.has(On.dropShadowOf)){var oa=R.get(On.dropShadowOf),Zc=Ct?(ot=Ct(oa,oa.x,oa.z))!==null&&ot!==void 0?ot:-1:0;vi.position.set(oa.x,Zc+.008,oa.z);var Jc=Math.max(0,oa.y-Zc-oa.radius);vi.material&&(vi.material.opacity=.22/(1+Jc*2));var Xi=1+Jc*.4;vi.scale.set(Xi,Xi,Xi),vi.visible=!oa.captured&&On.visible!==!1}else if(On.attachToCamera){var vo=Math.tan(((yt=an.cameraFov)!==null&&yt!==void 0?yt:68)*Math.PI/360),$c=Math.tan(ir*Math.PI/360),Kc=$c/Math.max(.05,vo),Xi=Math.min(1,Kc),bl=Math.min(1.15,Kc)*(Mi>1.3?1.12:1),Pi=bl*Math.min(3.55,Mi/(390/700)),Ai=(ht=De.recoil)!==null&&ht!==void 0?ht:0;vi.position.set(((rt=On.x)!==null&&rt!==void 0?rt:0)*Pi,((Lt=On.y)!==null&&Lt!==void 0?Lt:0)*bl+Ai*.085*Xi,((Bt=On.z)!==null&&Bt!==void 0?Bt:0)+Ai*.3*Xi),vi.rotation.set(((qt=On.rx)!==null&&qt!==void 0?qt:0)+Ai*.34,((te=On.ry)!==null&&te!==void 0?te:0)+(Mi>1.1?.1:0),((at=On.rz)!==null&&at!==void 0?at:0)-Ai*.09),vi.scale.set(((Ce=On.sx)!==null&&Ce!==void 0?Ce:1)*Xi,((pt=On.sy)!==null&&pt!==void 0?pt:1)*Xi,((lt=On.sz)!==null&<!==void 0?lt:1)*Xi)}else vi.position.set((He=On.x)!==null&&He!==void 0?He:0,(Zt=On.y)!==null&&Zt!==void 0?Zt:0,(It=On.z)!==null&&It!==void 0?It:0),vi.rotation.set((xt=On.rx)!==null&&xt!==void 0?xt:0,(kt=On.ry)!==null&&kt!==void 0?kt:0,(ct=On.rz)!==null&&ct!==void 0?ct:0),vi.scale.set((zt=On.sx)!==null&&zt!==void 0?zt:1,($t=On.sy)!==null&&$t!==void 0?$t:1,(ln=On.sz)!==null&&ln!==void 0?ln:1);(ce||De.dynamicNodes.size>0)&&(Da+="".concat(Yt,":").concat(+vi.visible,",").concat(vi.position.x*100|0,",").concat(vi.position.y*100|0,",").concat(vi.position.z*100|0,",").concat(vi.rotation.x*100|0,",").concat(vi.rotation.y*100|0,"|"))}}catch(Bn){se={error:Bn}}finally{try{ar&&!ar.done&&(Se=rr.return)&&Se.call(rr)}finally{if(se)throw se.error}}var Pr;if(R)try{for(var Lr=_n(R.values()),la=Lr.next();!la.done;la=Lr.next()){var Nn=la.value;if(Nn.stageId===O.id&&Nn.captured){Pr=Nn;break}}}catch(Bn){Pe={error:Bn}}finally{try{la&&!la.done&&(le=Lr.return)&&le.call(Lr)}finally{if(Pe)throw Pe.error}}var Na=function(Bn){var zs=!!Pr,Yr=Pr&&(pn=Pr.captureElapsed)!==null&&pn!==void 0?pn:0;Bn.pieces.forEach(function(ja,Ma){var Vs,es,El,_o,Al,Gs;if(ja.visible=zs,!!zs){var Il=Ma*2.399,eu=(es=(Vs=Pr.captureTarget)===null||Vs===void 0?void 0:Vs.x)!==null&&es!==void 0?es:Bn.origin.x,Rf=(_o=(El=Pr.captureTarget)===null||El===void 0?void 0:El.y)!==null&&_o!==void 0?_o:Bn.origin.y,Mo=(Gs=(Al=Pr.captureTarget)===null||Al===void 0?void 0:Al.z)!==null&&Gs!==void 0?Gs:Bn.origin.z;ja.position.set(eu+Math.cos(Il)*Yr*(.5+Ma%4*.17),Rf+.3+Math.sin(Math.min(1,Yr/2)*Math.PI)*(1+Ma%5*.15),Mo+Math.sin(Il)*Yr*(.5+Ma%4*.17)),ja.rotation.set(Yr*3+Ma,Yr*2+Ma,Math.sin(Yr+Ma))}})};try{for(var Ua=_n(De.confettiSystems),Os=Ua.next();!Os.done;Os=Ua.next()){var Qc=Os.value;Na(Qc)}}catch(Bn){ae={error:Bn}}finally{try{Os&&!Os.done&&(fe=Ua.return)&&fe.call(Ua)}finally{if(ae)throw ae.error}}De.camera.aspect=Mi;var go=!1;if(ce)De.lastTime=Ht,De.camera.rotation.order="YXZ",De.camera.position.set(ce.x,ce.y+((tn=ce.bob)!==null&&tn!==void 0?tn:0),ce.z),De.camera.rotation.set(ce.pitch,ce.yaw,0),De.camera.fov=ir,Da+="c:".concat(De.camera.position.x*100|0,",").concat(De.camera.position.y*100|0,",").concat(De.camera.position.z*100|0,",").concat(ce.yaw*1e3|0,",").concat(ce.pitch*1e3|0,",").concat(ir*100|0,",").concat(Mi*1e3|0,",").concat(((Qt=De.recoil)!==null&&Qt!==void 0?Qt:0)*1e3|0);else{var jc=an.followTargetId?R?.get(an.followTargetId):void 0,wl=jc?jc.z*((nn=an.followZFactor)!==null&&nn!==void 0?nn:.12):(yn=an.lookAtZ)!==null&&yn!==void 0?yn:0;De.lastTime<0||Ht<De.lastTime?De.focusZ=wl:mt||(De.focusZ+=(wl-De.focusZ)*(1-Math.exp(-6*Wi))),De.lastTime=Ht;var yo=Math.max(0,1-Ht/1.5);if(go=!an.followTargetId&&((un=an.introLift)!==null&&un!==void 0?un:2)===0,!mt){var Tl=go?Math.sin(Ht*.42)*1.15:0,If=go?(Math.cos(Ht*.42)-1)*.55:0,Bs=($n?(En=an.cameraX)!==null&&En!==void 0?En:10:(ii=an.landscapeCameraX)!==null&&ii!==void 0?ii:13)+Tl,ks=$n?((kn=an.cameraY)!==null&&kn!==void 0?kn:18)+yo*((zn=an.introLift)!==null&&zn!==void 0?zn:2):(Un=an.landscapeCameraY)!==null&&Un!==void 0?Un:15,xo=($n?(Fn=an.cameraZ)!==null&&Fn!==void 0?Fn:21:(Jn=an.landscapeCameraZ)!==null&&Jn!==void 0?Jn:18)+If,Cf=Wi===0?ks:De.camera.position.y+(ks-De.camera.position.y)*(1-Math.exp(-6*Wi));De.camera.position.set(Bs,Cf,xo+De.focusZ),De.camera.fov=ir,De.camera.lookAt((rn=an.lookAtX)!==null&&rn!==void 0?rn:0,(ri=an.lookAtY)!==null&&ri!==void 0?ri:.15,De.focusZ)}Da+="a:".concat(Mi*1e3|0,",").concat(ir*100|0)}return De.camera.updateProjectionMatrix(),De.camera.updateMatrixWorld(!0),{entry:De,waveTime:Ht,victorySway:go,poseParts:Da}}function G(O,k,ne,X,K,ge,se){var Se,Pe,le,ae,fe,Ne,Re,We,Qe,ke,qe,ft,tt,st,Ke,en,nt,on,ue,hn,gn,J,w=D(O,zc(zc({},se),{worldWidth:(Qe=se.worldWidth)!==null&&Qe!==void 0?Qe:K,worldHeight:(ke=se.worldHeight)!==null&&ke!==void 0?ke:ge})),ie=w.entry,ye=w.waveTime,Ae=w.victorySway,Xe=w.poseParts,Je=se.bodies3d,Te=(qe=se.drawX)!==null&&qe!==void 0?qe:0,Ie=(ft=se.drawY)!==null&&ft!==void 0?ft:0,ot=T(ie,(tt=se.contactParticles)!==null&&tt!==void 0?tt:[]);Object.assign(ie,{lastX:Te,lastY:Ie,lastWidth:K,lastHeight:ge,lastDesignH:(st=se.designHeight)!==null&&st!==void 0?st:ge,isFullBleed:!!se.fullBleed});var yt=ne>=2&&X>=2?P():null;if(!yt||!((nt=(en=(Ke=yt.getContext)===null||Ke===void 0?void 0:Ke.call(yt))===null||en===void 0?void 0:en.isContextLost)===null||nt===void 0)&&nt.call(en))return k.fillStyle=ie.skyColor,k.fillRect(Te,Ie,K,ge),ie;var ht=Math.max(ne,X,1),rt=se.propsOf(O),Lt=(on={none:Wr,neutral:Ac,aces:Ec}[rt.toneMapping])!==null&&on!==void 0?on:Wr;yt.toneMapping=Lt;var Bt=!!rt.shadowsEnabled,qt=Number((ue=rt.shadowMapSize)!==null&&ue!==void 0?ue:512);yt.shadowMap.enabled=Bt,ie.sun.castShadow=Bt,ie.sun.shadow.mapSize.x!==qt&&(ie.sun.shadow.mapSize.set(qt,qt),(hn=ie.sun.shadow.map)===null||hn===void 0||hn.dispose(),ie.sun.shadow.map=null);var te=(gn=rt.envIntensity)!==null&&gn!==void 0?gn:.8;(ie.textureDirty||!ie.compiled)&&(ie.usesPbr=!1,ie.scene.traverse(function(rn){var ri;!((ri=rn.material)===null||ri===void 0)&&ri.isMeshStandardMaterial&&(ie.usesPbr=!0)})),ie.usesPbr&&te>0&&(l??(l=Pw(yt))),ie.scene.environment=ie.usesPbr&&te>0?l?.texture:null,ie.scene.environmentIntensity=te;var at=[Lt,Bt,qt,te].join("/");ie.lightingKey!==at&&(ie.textureDirty=!0,ie.lightingKey=at);var Ce=(J=rt.renderMaxDim)!==null&&J!==void 0?J:520,pt=ht>Ce?Ce/ht:1,lt=Math.max(2,Math.round(ne*pt)),He=Math.max(2,Math.round(X*pt)),Zt=y.width!==lt||y.height!==He;if(Zt&&(yt.setPixelRatio(1),yt.setSize(lt,He,!1),v.width=lt,v.height=He,N=void 0),!ie.compiled){ie.compiled=!0;var It=[];ie.guidePool[0]&&!ie.guidePool[0].visible&&(ie.guidePool[0].visible=!0,ie.guidePool[0].position.set(0,-99,0),It.push(ie.guidePool[0]));try{for(var xt=_n(ie.confettiSystems),kt=xt.next();!kt.done;kt=xt.next()){var ct=kt.value;ct.pieces[0]&&!ct.pieces[0].visible&&(ct.pieces[0].visible=!0,ct.pieces[0].position.set(0,-99,0),It.push(ct.pieces[0]))}}catch(rn){Se={error:rn}}finally{try{kt&&!kt.done&&(Pe=xt.return)&&Pe.call(xt)}finally{if(Se)throw Se.error}}yt.compile(ie.scene,ie.camera);try{for(var zt=_n(It),$t=zt.next();!$t.done;$t=zt.next()){var ln=$t.value;ln.visible=!1}}catch(rn){le={error:rn}}finally{try{$t&&!$t.done&&(ae=zt.return)&&ae.call(zt)}finally{if(le)throw le.error}}}var pn=!1;if(Je)try{for(var tn=_n(Je.values()),Qt=tn.next();!Qt.done;Qt=tn.next()){var nn=Qt.value;if(nn.stageId===O.id&&(nn.mode==="kinematic"||nn.mode==="dynamic"&&(!nn.atRest||nn.captured))){pn=!0;break}}}catch(rn){fe={error:rn}}finally{try{Qt&&!Qt.done&&(Ne=tn.return)&&Ne.call(tn)}finally{if(fe)throw fe.error}}var yn=Math.floor(ye*20),un=ie.wavingFlags.length>0&&ie.lastFlagStep!==yn,En=Ae&&Math.abs(ye-ie.lastRenderedTime)>=.032,ii=pn&&ie.lastRenderedTime!==ye,kn=Xe!==ie.lastPoseSig,zn=Zt||N!==O.id||ie.guideDirty||ie.textureDirty||ie.animDirty||ie.lastRenderedTime<0||ie.lastRenderedW!==lt||ie.lastRenderedH!==He||un||En||ii||kn||ot;if(zn){if(ie.wavingFlags.length>0&&ie.lastFlagStep!==yn){try{for(var Un=_n(ie.wavingFlags),Fn=Un.next();!Fn.done;Fn=Un.next()){var Jn=Fn.value;Rw(Jn.geo,Jn.rest,yn/20)}}catch(rn){Re={error:rn}}finally{try{Fn&&!Fn.done&&(We=Un.return)&&We.call(Un)}finally{if(Re)throw Re.error}}ie.lastFlagStep=yn}yt.setClearColor(ie.skyColor,1),yt.render(ie.scene,ie.camera),y.width>0&&y.height>0&&(m.drawImage(y,0,0,lt,He),N=O.id),ie.lastRenderedTime=ye,ie.lastRenderedW=lt,ie.lastRenderedH=He,ie.lastPoseSig=Xe,ie.guideDirty=!1,ie.textureDirty=!1,ie.animDirty=!1}return v.width>0&&v.height>0&&k.drawImage(v,Te,Ie,K,ge),ie}function F(){var O,k,ne,X,K,ge,se,Se;try{for(var Pe=_n(p.values()),le=Pe.next();!le.done;le=Pe.next()){var ae=le.value;try{for(var fe=(ne=void 0,_n(ae.dynamicNodes)),Ne=fe.next();!Ne.done;Ne=fe.next()){var Re=Ka(Ne.value,2),We=Re[0],Qe=Re[1];(se=Qe.parent)===null||se===void 0||se.remove(Qe),h(Qe),ae.modelBindings.delete(We)}}catch(tt){ne={error:tt}}finally{try{Ne&&!Ne.done&&(X=fe.return)&&X.call(fe)}finally{if(ne)throw ne.error}}ae.dynamicNodes.clear();try{for(var ke=(K=void 0,_n(ae.modelBindings.values())),qe=ke.next();!qe.done;qe=ke.next()){var ft=qe.value;(Se=ft.animator)===null||Se===void 0||Se.reset(),ft.startDefaultAnimation()}}catch(tt){K={error:tt}}finally{try{qe&&!qe.done&&(ge=ke.return)&&ge.call(ke)}finally{if(K)throw K.error}}ae.animDirty=!0,ae.focusZ=0,ae.lastTime=-1,ae.lastRenderedTime=-1,ae.lastFlagStep=-1,ae.lastPoseSig="",ae.guideDirty=!0,ae.setGuide([])}}catch(tt){O={error:tt}}finally{try{le&&!le.done&&(k=Pe.return)&&k.call(Pe)}finally{if(O)throw O.error}}}function $(){var O,k,ne,X,K,ge,se,Se,Pe,le,ae,fe,Ne,Re,We,Qe;try{for(var ke=_n(p.values()),qe=ke.next();!qe.done;qe=ke.next()){var ft=qe.value;try{for(var tt=(ne=void 0,_n((We=ft.contactBatches)!==null&&We!==void 0?We:[])),st=tt.next();!st.done;st=tt.next()){var Ke=st.value;Ke.dispose()}}catch(Ie){ne={error:Ie}}finally{try{st&&!st.done&&(X=tt.return)&&X.call(tt)}finally{if(ne)throw ne.error}}h(ft.scene),ft.sun.shadow.dispose()}}catch(Ie){O={error:Ie}}finally{try{qe&&!qe.done&&(k=ke.return)&&k.call(ke)}finally{if(O)throw O.error}}try{for(var en=_n(o),nt=en.next();!nt.done;nt=en.next()){var on=nt.value;on.dispose()}}catch(Ie){K={error:Ie}}finally{try{nt&&!nt.done&&(ge=en.return)&&ge.call(en)}finally{if(K)throw K.error}}try{for(var ue=_n(u),hn=ue.next();!hn.done;hn=ue.next()){var gn=hn.value;gn.dispose()}}catch(Ie){se={error:Ie}}finally{try{hn&&!hn.done&&(Se=ue.return)&&Se.call(ue)}finally{if(se)throw se.error}}try{for(var J=_n(a.values()),w=J.next();!w.done;w=J.next()){var ie=w.value;ie.dispose()}}catch(Ie){Pe={error:Ie}}finally{try{w&&!w.done&&(le=J.return)&&le.call(J)}finally{if(Pe)throw Pe.error}}try{for(var ye=_n(s.values()),Ae=ye.next();!Ae.done;Ae=ye.next()){var Xe=Ae.value;try{for(var Je=(Ne=void 0,_n(Xe.textures.values())),Te=Je.next();!Te.done;Te=Je.next()){var ie=Te.value;ie.dispose()}}catch(Ie){Ne={error:Ie}}finally{try{Te&&!Te.done&&(Re=Je.return)&&Re.call(Je)}finally{if(Ne)throw Ne.error}}}}catch(Ie){ae={error:Ie}}finally{try{Ae&&!Ae.done&&(fe=ye.return)&&fe.call(ye)}finally{if(ae)throw ae.error}}u.clear(),o.clear(),s.clear(),l?.dispose(),l=void 0,p.clear(),r.clear(),a.clear(),(Qe=M?.forceContextLoss)===null||Qe===void 0||Qe.call(M),M?.dispose(),M=void 0,y=void 0,v=void 0,m=void 0,N=void 0}function A(O,k){var ne,X,K,ge;try{for(var se=_n(p.values()),Se=se.next();!Se.done;Se=se.next()){var Pe=Se.value,le=function(Qe,ke){if(!ke.animator)return"continue";ke.animator.step(O,function(qe){var ft;return k?.(Qe,(ft=ke.sourceId)!==null&&ft!==void 0?ft:Qe,qe)})&&(Pe.animDirty=!0)};try{for(var ae=(K=void 0,_n(Pe.modelBindings)),fe=ae.next();!fe.done;fe=ae.next()){var Ne=Ka(fe.value,2),Re=Ne[0],We=Ne[1];le(Re,We)}}catch(Qe){K={error:Qe}}finally{try{fe&&!fe.done&&(ge=ae.return)&&ge.call(ae)}finally{if(K)throw K.error}}}}catch(Qe){ne={error:Qe}}finally{try{Se&&!Se.done&&(X=se.return)&&X.call(se)}finally{if(ne)throw ne.error}}}function S(O,k){var ne,X,K,ge,se;k===void 0&&(k={});var Se=!1;try{for(var Pe=_n(p.values()),le=Pe.next();!le.done;le=Pe.next()){var ae=le.value;try{for(var fe=(K=void 0,_n(ae.modelBindings)),Ne=fe.next();!Ne.done;Ne=fe.next()){var Re=Ka(Ne.value,2),We=Re[0],Qe=Re[1];We!==O&&Qe.sourceId!==O||!((se=Qe.animator)===null||se===void 0)&&se.play(k.clipName||"",k)&&(ae.animDirty=!0,Se=!0)}}catch(ke){K={error:ke}}finally{try{Ne&&!Ne.done&&(ge=fe.return)&&ge.call(fe)}finally{if(K)throw K.error}}}}catch(ke){ne={error:ke}}finally{try{le&&!le.done&&(X=Pe.return)&&X.call(Pe)}finally{if(ne)throw ne.error}}return Se}function H(O){var k,ne;try{for(var X=_n(p.values()),K=X.next();!K.done;K=X.next()){var ge=K.value,se=ge.modelBindings.get(O);if(se?.modelBounds)return se.modelBounds}}catch(Se){k={error:Se}}finally{try{K&&!K.done&&(ne=X.return)&&ne.call(X)}finally{if(k)throw k.error}}return null}function Y(){var O,k,ne,X,K,ge,se={texturesPending:0,textureErrors:0,animations:{}};try{for(var Se=_n(s.values()),Pe=Se.next();!Pe.done;Pe=Se.next()){var le=Pe.value,ae=le.imageStatus();se.texturesPending+=ae.texturesPending,se.textureErrors+=ae.textureErrors}}catch(tt){O={error:tt}}finally{try{Pe&&!Pe.done&&(k=Se.return)&&k.call(Se)}finally{if(O)throw O.error}}try{for(var fe=_n(p.values()),Ne=fe.next();!Ne.done;Ne=fe.next()){var Re=Ne.value;try{for(var We=(K=void 0,_n(Re.modelBindings)),Qe=We.next();!Qe.done;Qe=We.next()){var ke=Ka(Qe.value,2),qe=ke[0],ft=ke[1];ft.animator&&(se.animations[qe]=ft.animator.snapshot())}}catch(tt){K={error:tt}}finally{try{Qe&&!Qe.done&&(ge=We.return)&&ge.call(We)}finally{if(K)throw K.error}}}}catch(tt){ne={error:tt}}finally{try{Ne&&!Ne.done&&(X=fe.return)&&X.call(fe)}finally{if(ne)throw ne.error}}return se}function oe(O){var k=p.get(O);k&&(k.recoil=1)}return{getStage:z,syncStage:D,renderStage:G,reset:F,dispose:$,stepAnimations:A,playModelAnimation:S,modelBoundsFor:H,modelStatus:Y,triggerRecoil:oe}}var vs=function(){return vs=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},vs.apply(this,arguments)},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},xa=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))},Vc=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.")},og=function(n,e,t){return Math.max(e,Math.min(t,n))},Fs=function(n,e){return Math.hypot(e.x-n.x,e.y-n.y)};function lg(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,vs({},S)]})),l=new Map(i.map(function(S){return[S.id,vs({speedScale:1,enabled:!0,bidirectional:!1,cost:0},S)]})),d=new Map(a.map(function(S){return[S.id,vs({},S)]})),f=new Map,h=f,p=0,y=0,M=function(S){return u.get(S)},v=function(S){return xa([],ya(d.values()),!1).find(function(H){return H.parameters.nodeId===S})},m=function(S){var H=S.parameters;if(H.mode==="open")return!0;if(H.mode==="closed")return!1;var Y=H.openSeconds+H.closedSeconds,oe=(p+H.phaseOffsetSeconds)%Y;return oe<H.openSeconds},N=function(S){return xa([],ya(l.values()),!1).filter(function(H){return H.enabled&&(H.from===S||H.bidirectional&&H.to===S)}).sort(function(H,Y){return H.id<Y.id?-1:H.id>Y.id?1:0})},P=function(S,H){return xa([],ya(l.values()),!1).find(function(Y){return Y.enabled&&(Y.from===S&&Y.to===H||Y.bidirectional&&Y.from===H&&Y.to===S)})};function _(S,H){var Y,oe,O,k;if(S===H)return[S];for(var ne=new Map([[S,0]]),X=new Map,K=new Set([S]);K.size;){var ge=xa([],ya(K),!1).sort(function(ke,qe){return ne.get(ke)-ne.get(qe)||(ke<qe?-1:ke>qe?1:0)})[0];if(K.delete(ge),ge===H)break;try{for(var se=(Y=void 0,Vc(N(ge))),Se=se.next();!Se.done;Se=se.next()){var Pe=Se.value,le=Pe.from===ge?Pe.to:Pe.from,ae=v(le),fe=M(le),Ne=ae?ae.parameters.holdSeconds*90+(m(ae)?0:ae.parameters.closedSeconds*90):0,Re=ne.get(ge)+Fs(M(ge),fe)/Pe.speedScale+Pe.cost+((O=fe.cost)!==null&&O!==void 0?O:0)+Ne;Re>=((k=ne.get(le))!==null&&k!==void 0?k:1/0)||(ne.set(le,Re),X.set(le,ge),K.add(le))}}catch(ke){Y={error:ke}}finally{try{Se&&!Se.done&&(oe=se.return)&&oe.call(se)}finally{if(Y)throw Y.error}}}if(!ne.has(H))return[];for(var We=[H],Qe=H;Qe!==S;)Qe=X.get(Qe),We.unshift(Qe);return We}function g(S){var H,Y=S.route.length>=2&&S.segment<S.route.length-1;if(!Y){var oe=(H=S.route[Math.min(S.segment,S.route.length-1)])!==null&&H!==void 0?H:S.startNode,O=_(oe,S.target);S.route=O.length?O:[oe],S.segment=0,S.distance=0,S.arrived=!1,S.active=S.route.length>=2;return}var k=S.route[S.segment],ne=S.route[S.segment+1],X=Fs(M(k),M(ne));if(S.arrived||S.distance>=X-1e-4){var O=_(ne,S.target);S.route=O.length?O:[ne],S.segment=0,S.distance=0,S.arrived=!1,S.active=S.route.length>=2;return}var K=_(ne,S.target);S.route=K.length?xa([k],ya(K),!1):[k,ne],S.segment=0}function b(S){var H,Y=_(S.startNode,S.targetNode),oe=M(S.startNode),O=Y.length>=2?M(Y[1]):oe,k=Y.length>=2?Math.atan2(O.y-oe.y,O.x-oe.x):0,ne=Math.floor((k%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,X=vs(vs({},S),{loop:(H=S.loop)!==null&&H!==void 0?H:"none",originNode:S.startNode,destinationNode:S.targetNode,target:S.targetNode,networkId:e,route:Y.length?Y:[S.startNode],segment:0,distance:0,x:oe.x,y:oe.y,heading:k,frame:[0,1,2,3][ne],flipX:Math.cos(k)<0,hold:0,arrived:!1,active:S.active&&Y.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return f.set(X.id,X),X}function z(S){if(T("pathArrive",S,S.target),S.loop==="none"){S.active=!1;return}var H=S.target,Y=S.loop==="ping-pong"?H===S.destinationNode?S.originNode:S.destinationNode:H===S.originNode?S.destinationNode:S.originNode;S.startNode=H,S.target=Y,S.route=_(H,Y),S.segment=0,S.distance=0,S.arrived=!1,S.route.length<2&&(S.active=!1)}function T(S,H,Y){o(S,{componentId:H.id,nodeId:Y})}function D(S,H){var Y,oe,O=S.route[S.segment+1],k=v(O);if(k&&!m(k)){S.blockedTicks++,S.blockedTicks>=30&&!S.blockedEmitted&&(S.blockedEmitted=!0,T("pathBlocked",S,O));return}if(!S.arrived){if(S.arrived=!0,S.segment+1===S.route.length-1){O===S.target?z(S):(S.active=!1,S.blockedEmitted||(S.blockedEmitted=!0,T("pathBlocked",S,O)));return}S.hold=Math.max((Y=M(O).holdSeconds)!==null&&Y!==void 0?Y:0,(oe=k?.parameters.holdSeconds)!==null&&oe!==void 0?oe:0)}if(S.hold>0){S.hold=Math.max(0,S.hold-H),S.blockedTicks++,S.blockedTicks>=30&&!S.blockedEmitted&&(S.blockedEmitted=!0,T("pathBlocked",S,O));return}S.segment++,S.distance=0,S.arrived=!1,S.blockedTicks=0,S.blockedEmitted=!1}function G(S,H){var Y,oe;if(S.spacing<=0)return H;var O=S.route[S.segment],k=S.route[S.segment+1],ne=Fs(M(O),M(k)),X=ne-S.distance,K=H;try{for(var ge=Vc(h.values()),se=ge.next();!se.done;se=ge.next()){var Se=se.value;if(!(Se.id===S.id||!Se.active||Se.route.length<2||Se.segment>=Se.route.length-1)){var Pe=Se.route[Se.segment],le=Se.route[Se.segment+1],ae=1/0;if(Pe===O&&le===k&&(Se.distance>S.distance||Se.distance===S.distance&&Se.id<S.id))ae=Se.distance-S.distance;else if(Pe===k)ae=X+Se.distance;else if(le===k&&Pe!==O){var fe=Fs(M(Pe),M(le))-Se.distance;fe<S.spacing&&(fe<X||fe===X&&Se.id<S.id)&&(ae=X)}ae<1/0&&(K=Math.min(K,Math.max(0,ae-S.spacing)))}}}catch(Ne){Y={error:Ne}}finally{try{se&&!se.done&&(oe=ge.return)&&oe.call(ge)}finally{if(Y)throw Y.error}}return K}function F(S){var H=M(S.route[S.segment]),Y=M(S.route[S.segment+1]),oe=Fs(H,Y),O=og(S.distance/Math.max(1e-4,oe),0,1),k=H.x+(Y.x-H.x)*O,ne=H.y+(Y.y-H.y)*O,X=Math.atan2(Y.y-H.y,Y.x-H.x),K=Math.min(S.cornerRadius,oe/3),ge=S.route[S.segment+2];if(K>0&&ge){var se=M(ge),Se=Fs(Y,se),Pe=Math.min(K,Se/3);if(S.distance>oe-K){var le={x:Y.x-(Y.x-H.x)/oe*K,y:Y.y-(Y.y-H.y)/oe*K},ae={x:Y.x+(se.x-Y.x)/Se*Pe,y:Y.y+(se.y-Y.y)/Se*Pe},fe=og((S.distance-(oe-K))/(K*2),0,.5),Ne=1-fe;k=Ne*Ne*le.x+2*Ne*fe*Y.x+fe*fe*ae.x,ne=Ne*Ne*le.y+2*Ne*fe*Y.y+fe*fe*ae.y;var Re=2*Ne*(Y.x-le.x)+2*fe*(ae.x-Y.x),We=2*Ne*(Y.y-le.y)+2*fe*(ae.y-Y.y);Math.abs(Re)+Math.abs(We)>.001&&(X=Math.atan2(We,Re))}}return{x:k,y:ne,heading:X}}function $(S){var H,Y,oe,O;p+=S,y++;var k=xa([],ya(f.values()),!1).sort(function(tt,st){return tt.id<st.id?-1:tt.id>st.id?1:0}),ne=k.length?y%k.length:0,X=xa(xa([],ya(k.slice(ne)),!1),ya(k.slice(0,ne)),!1);try{for(var K=Vc(X),ge=K.next();!ge.done;ge=K.next()){var se=ge.value;if(!(!se.active||se.route.length<2||se.segment>=se.route.length-1)){var Se=se.route[se.segment],Pe=se.route[se.segment+1],le=Fs(M(Se),M(Pe));if(!(se.distance>=le-1e-4&&(D(se,S),!se.active||se.route.length<2||se.segment>=se.route.length-1))){var ae=se.route[se.segment],fe=se.route[se.segment+1],Ne=Fs(M(ae),M(fe)),Re=Ne-se.distance,We=(O=(oe=P(ae,fe))===null||oe===void 0?void 0:oe.speedScale)!==null&&O!==void 0?O:1,Qe=Math.min(Re,se.speed*We*Math.max(0,se.speedMultiplier)*S),ke=G(se,Qe);ke<=1e-4?(se.blockedTicks++,se.blockedTicks>=30&&!se.blockedEmitted&&(se.blockedEmitted=!0,T("pathBlocked",se,fe))):(se.distance+=ke,se.blockedTicks=0,se.blockedEmitted=!1);var qe=F(se);se.x=qe.x,se.y=qe.y,se.heading=qe.heading;var ft=Math.floor((se.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;se.frame=[0,1,2,3][ft],se.flipX=Math.cos(se.heading)<0}}}}catch(tt){H={error:tt}}finally{try{ge&&!ge.done&&(Y=K.return)&&Y.call(K)}finally{if(H)throw H.error}}}function A(){return{id:e,nodeCount:u.size,edgeCount:l.size,activeAgents:xa([],ya(f.values()),!1).filter(function(S){return S.active}).length,queuedAgents:xa([],ya(f.values()),!1).filter(function(S){return S.active&&S.blockedTicks>0}).length,agents:xa([],ya(f.values()),!1).map(function(S){var H;return{id:S.id,x:S.x,y:S.y,heading:S.heading,frame:(H=S.frame)!==null&&H!==void 0?H:0,flipX:!!S.flipX,active:S.active,targetNode:S.target,route:xa([],ya(S.route),!1),segment:S.segment,distance:S.distance,blocked:S.blockedTicks>0}})}}return{addAgent:b,removeAgent:function(S){return f.delete(S)},getAgent:function(S){return f.get(S)},setTarget:function(S,H){var Y=f.get(S);return!Y||!M(H)?!1:(Y.target=H,Y.destinationNode=H,Y.active=!0,g(Y),!0)},setEdge:function(S,H,Y){var oe,O,k=l.get(S);if(!k)return!1;k.enabled=H,Y!==void 0&&(k.cost=Y);try{for(var ne=Vc(f.values()),X=ne.next();!X.done;X=ne.next()){var K=X.value;g(K)}}catch(ge){oe={error:ge}}finally{try{X&&!X.done&&(O=ne.return)&&O.call(ne)}finally{if(oe)throw oe.error}}return!0},setGate:function(S,H,Y){var oe,O,k=d.get(S);if(!k)return!1;k.parameters=vs(vs({},k.parameters),{mode:H,holdSeconds:Y});try{for(var ne=Vc(f.values()),X=ne.next();!X.done;X=ne.next()){var K=X.value;g(K)}}catch(ge){oe={error:ge}}finally{try{X&&!X.done&&(O=ne.return)&&O.call(ne)}finally{if(oe)throw oe.error}}return!0},tick:$,snapshot:A}}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.")},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},Sf=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))},bf={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"]},Hc=function(n){var e,t,i,r,a=0;try{for(var s=Gc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a+=((r=(i=bf[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)},Lw=function(n,e){var t,i,r=[],a="";try{for(var s=Gc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a&&Hc(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 Dw(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=Gc(String(n).toUpperCase().split(`
|
|
4221
|
+
`)),f=d.next();!f.done;f=d.next()){var h=f.value,p=h.split(/\s+/).filter(Boolean);if(!p.length){l.push("");continue}var y="";try{for(var M=(a=void 0,Gc(p)),v=M.next();!v.done;v=M.next()){var m=v.value;if(Hc(m)>u){y&&l.push(y);var N=Lw(m,u);l.push.apply(l,Sf([],Mf(N.slice(0,-1)),!1)),y=(o=N.at(-1))!==null&&o!==void 0?o:""}else{var P=y?y+" "+m:m;Hc(P)<=u?y=P:(y&&l.push(y),y=m)}}}catch(_){a={error:_}}finally{try{v&&!v.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 cg=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}},Nw=function(n,e,t,i){var r,a=e.wrap===!1?String(n).toUpperCase().split(`
|
|
4222
|
+
`):Dw(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,Sf([0],Mf(s.map(function(u){return Hc(u)*t})),!1)),renderedHeight:(s.length-1)*o+7*t}};function Bp(n,e){for(var t,i=cg(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=Sf([],Mf(new Set(Sf([],Mf(String(n).toUpperCase()),!1).filter(function(y){return y!==`
|
|
4223
|
+
`&&!bf[y]}))),!1),l,d=s;d>=o;d--){var f=Nw(n,e,d,r),h=f.renderedWidth>r,p=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:p,unsupportedChars:u},e.autoFit===!1||!h&&!p)break}return l}function ug(n,e,t){var i,r=Bp(e,t),a=r.lines,s=r.scale,o=cg(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,p){var y,M,v,m=Hc(h)*s,N=t.align==="left"?o.x:t.align==="right"?t.width-m-o.x:o.x+(u-m)/2,P=N;try{for(var _=Gc(h),g=_.next();!g.done;g=_.next()){var b=g.value,z=(v=bf[b])!==null&&v!==void 0?v:bf["?"];z.forEach(function(T,D){for(var G=0;G<T.length;G++)T[G]==="1"&&n.fillRect(Math.round(P+G*s),Math.round(f+p*d+D*s),s,s)}),P+=(z[0].length+1)*s}}catch(T){y={error:T}}finally{try{g&&!g.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)},zp=Math.PI*2,Fi=function(n,e){return((Math.imul(n+1,2654435769)^Math.imul(e,2246822507))>>>0)/4294967296};function Vp(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+Fi(l,1)*.6)/n.count-.5)*s,p=n.speed*(.42+.65*Fi(l,2));return Qa(Qa({},e),{clipId:t,shape:"pixel-confetti",age:-.12*Fi(l,3),vx:Math.cos(h)*p,vy:Math.sin(h)*p,gravity:(d=n.gravity)!==null&&d!==void 0?d:250,life:((f=n.lifetime)!==null&&f!==void 0?f:.7)*(.6+.4*Fi(l,4)),color:a[l%a.length],size:3+Math.floor(3*Fi(l,5)),angle:zp*Fi(l,6),spin:(Fi(l,7)-.5)*12})})}function dg(n){var e=Math.min(12,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Vp(n).map(function(r,a){return Qa(Qa({},r),{screen:!0,x:(a%e+.15+.7*Fi(a,8))/e,y:(Math.floor(a/e)+.15+.7*Fi(a,9))/t,vx:i*(Fi(a,10)-.5)*.7,vy:i*(.3+.5*Fi(a,11)),size:r.size+1})})}var Tf=function(n,e){return(n%e+e)%e};function fg(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,p=e.color;if(!(o<0)){var y=a*o,M=s*o+l*o*o/2,v=Math.round(t?t.x+Tf(i*t.width+y,t.width):i+y),m=Math.round(t?t.y+Tf(r*t.height+M,t.height):r+M),N=Math.round((f+h*o)/(Math.PI/4))&3;if(n.globalAlpha*=Math.min(1,(u-o)*4),n.fillStyle="#3c293388",N===0)n.fillRect(v-d+1,m+1,d*2+1,d+1);else if(N===2)n.fillRect(v+1,m-d+1,d+1,d*2+1);else for(var P=-1;P<=1;P++)n.fillRect(v+P*d+1,m+P*d*(N===1?1:-1)+1,d+1,d+1);if(n.fillStyle=p,N===0)n.fillRect(v-d,m,d*2,d);else if(N===2)n.fillRect(v,m-d,d,d*2);else for(var P=-1;P<=1;P++)n.fillRect(v+P*d,m+P*d*(N===1?1:-1),d,d)}}function Gp(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+Fi(l,11)*.6)/n.count-.5)*s,p=n.speed*(.45+.65*Fi(l,12));return Qa(Qa({},e),{clipId:t,shape:"confetti",age:-.15*Fi(l,13),vx:Math.cos(h)*p,vy:Math.sin(h)*p,gravity:(d=n.gravity)!==null&&d!==void 0?d:140,life:((f=n.lifetime)!==null&&f!==void 0?f:2.6)*(.75+.35*Fi(l,14)),color:a[l%a.length],size:5+Math.floor(5*Fi(l,15)),kind:l%5===0?"star":"ribbon",angle:zp*Fi(l,16),spin:(Fi(l,17)-.5)*5.5,flutter:1.6+2.2*Fi(l,18),phase:zp*Fi(l,19)})})}function hg(n){var e=Math.min(14,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Gp(n,{x:0,y:0}).map(function(r,a){var s;return Qa(Qa({},r),{screen:!0,x:(a%e+.12+.76*Fi(a,20))/e,y:(Math.floor(a/e)+.08+.84*Fi(a,21))/t,vx:i*(Fi(a,22)-.5)*.65,vy:i*(.38+.55*Fi(a,23)),gravity:Math.min((s=n.gravity)!==null&&s!==void 0?s:90,90)})})}function pg(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,p=e.flutter,y=e.phase,M=e.color,v=e.kind;if(!(o<0)){var m=Math.sin(o*p+y)*14,N=a*o+m,P=s*o+l*o*o/2,_=t?t.x+Tf(i*t.width+N,t.width):i+N,g=t?t.y+Tf(r*t.height+P,t.height):r+P,b=Math.min(1,o*2.8,(u-o)*2.2);if(!(b<=0)){n.save(),n.globalAlpha*=b,n.translate(_,g),n.rotate(f+h*o);var z=Math.cos(o*p*1.4+y);if(n.scale(1,Math.max(.22,Math.abs(z))),n.fillStyle=M,v==="star"){var T=d*.85;n.beginPath();for(var D=0;D<8;D++){var G=D%2===0?T:T*.38,F=D*Math.PI/4;D===0?n.moveTo(Math.cos(F)*G,Math.sin(F)*G):n.lineTo(Math.cos(F)*G,Math.sin(F)*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 mg(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 p=Math.floor(((a+14*o)*h-6*o)/o)*o,y=u+3*o,M=0;y<l;y+=o,M++){var v=p-Math.floor(M/2)*o;n.fillStyle="#fff4be44",n.fillRect(v-2*o,y,9*o,o),n.fillStyle="#fffef0aa",n.fillRect(v,y,4*o,o)}n.restore()}if(e.enabled&&!i&&r>=0){var m=Math.max(0,Math.sin(r*4.2)),N=Math.max(0,Math.sin(r*4.2+2.2)),P=function(_,g,b){if(!(b<.25)){n.save(),n.globalAlpha*=b*.95,n.fillStyle="#fffef4";var z=b>.65?o*2:o;n.fillRect(Math.round(_-z),Math.round(g-o/2),z*2+o,o),n.fillRect(Math.round(_-o/2),Math.round(g-z),o,z*2+o),n.restore()}};P(5*o,u+4*o,m),P(a-6*o,u+5*o,N)}}}function wf(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 kp(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 vg(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,p=r>=0?.5-.5*Math.cos(r*2.4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd23f99",n.shadowBlur=10+p*12,wf(n,0,h,u,l-h,d),n.fillStyle=t,n.fill(),n.restore()),n.save(),wf(n,0,h+2,u,Math.max(4,l-h-2),d),n.fillStyle="#0e2830",n.fill(),n.restore(),n.save(),wf(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 v=M*M*(3-2*M),m=Math.sin(M*Math.PI),N=-u*.36+u*1.72*v;n.save(),n.globalAlpha*=m,n.translate(N,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(),wf(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)),g=_*_,b=Math.max(0,Math.sin(r*2.4+2.1)),z=b*b,T=Math.max(0,Math.sin(r*2.4+4.2)),D=T*T;kp(n,u*.12,h+9,4+g*6,g*.92),kp(n,u*.88,h+10,3.8+z*5.5,z*.9),kp(n,u*.76,Math.max(h+14,l-f-8),3+D*4.2,D*.8)}}}function Ef(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 Wc=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.")},Xc=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},Hp=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 gg(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,p=!1,y=!1,M=!1,v=!1,m,N,P,_,g,b,z=function(){return p||y};function T(){var O,k,ne;clearTimeout(g),clearTimeout(b);try{for(var X=Wc(l.splice(0)),K=X.next();!K.done;K=X.next()){var ge=Xc(K.value,2),se=ge[0],Se=ge[1];try{(ne=d.mraid)===null||ne===void 0||ne.removeEventListener(se,Se)}catch{}}}catch(Pe){O={error:Pe}}finally{try{K&&!K.done&&(k=X.return)&&k.call(X)}finally{if(O)throw O.error}}}function D(O){_?.(O instanceof Error?O:Error(String(O))),P=void 0,_=void 0}function G(O){var k,ne;if(!z()){var X=f;if(p=!0,f=!1,h=!1,T(),D(O),X)try{for(var K=Wc(Hp([],Xc(u),!1)),ge=K.next();!ge.done;ge=K.next()){var se=ge.value;se()}}catch(Se){k={error:Se}}finally{try{ge&&!ge.done&&(ne=K.return)&&ne.call(K)}finally{if(k)throw k.error}}o.clear(),u.clear()}}function F(O,k){return l.push([O,k]),d.mraid.addEventListener(O,k),$(O,k)}function $(O,k){if(z()){try{d.mraid.removeEventListener(O,k)}catch{}return!1}return!0}function A(O){var k,ne;if(!z()){if(typeof O!="boolean"){G(Error("Invalid Unity viewability event"));return}if(!f){m=O;return}if(h!==O){h=O;try{for(var X=Wc(Hp([],Xc(o),!1)),K=X.next();!K.done;K=X.next()){var ge=K.value;if(z())break;ge(h)}}catch(se){k={error:se}}finally{try{K&&!K.done&&(ne=X.return)&&ne.call(X)}finally{if(k)throw k.error}}}}}var S=function(O){O==="hidden"&&G(Error("Unity host closed"))},H=function(){var O;f&&!z()&&((O=n.onResize)===null||O===void 0||O.call(n))};function Y(){var O,k,ne,X;if(!(!M||f||v||z())){v=!0;try{var K=d.mraid.getState();if(z()||K==="loading")return;if(K==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(K))throw Error("Invalid Unity host state");var ge=d.mraid.getVersion();if(z())return;if(ge!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var se=Wc([["viewableChange",A],["stateChange",S],["sizeChange",H]]),Se=se.next();!Se.done;Se=se.next()){var Pe=Xc(Se.value,2),le=Pe[0],ae=Pe[1];if(!F(le,ae))return}}catch(Qe){O={error:Qe}}finally{try{Se&&!Se.done&&(k=se.return)&&k.call(se)}finally{if(O)throw O.error}}var fe=d.mraid.isViewable();if(z())return;if(typeof fe!="boolean")throw Error("Invalid Unity initial viewability");h=m??fe,f=!0,clearTimeout(g),clearTimeout(b),P?.(),P=void 0,_=void 0;try{for(var Ne=Wc(Hp([],Xc(o),!1)),Re=Ne.next();!Re.done;Re=Ne.next()){var We=Re.value;if(z())break;We(h)}}catch(Qe){ne={error:Qe}}finally{try{Re&&!Re.done&&(X=Ne.return)&&X.call(Ne)}finally{if(ne)throw ne.error}}}catch(Qe){G(Qe)}finally{v=!1}}}function oe(){if(!z())try{var O=s();if(z())return;if(!O){b=setTimeout(oe,a);return}if(d.mraid=O,l.push(["ready",Y]),d.mraid.addEventListener("ready",Y),!$("ready",Y))return;M=!0,Y()}catch(k){G(k)}}return{init:function(){return N||(N=new Promise(function(O,k){P=O,_=k}),z()?(D(Error("Unity bridge destroyed")),N):(g=setTimeout(function(){return G(Error("Unity MRAID readiness timed out"))},r),oe(),N))},isReady:function(){return f&&!z()},isVisible:function(){return f&&h&&!z()},isClosed:z,onVisibilityChanged:function(O){return z()||o.add(O),function(){return o.delete(O)}},onClosed:function(O){return z()||u.add(O),function(){return u.delete(O)}},openStore:function(O){if(!f||!h||z()||!Ef(O))throw Error("Unity store request not permitted");d.mraid.open(O)},destroy:function(){y||(y=!0,f=!1,h=!1,T(),D(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},Wp=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 yg(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,p,y=new Set,M=new Set,v=[];function m(){var F,$;clearTimeout(h),clearTimeout(p);try{for(var A=Ml(v.splice(0)),S=A.next();!S.done;S=A.next()){var H=Sl(S.value,2),Y=H[0],oe=H[1];try{i?.removeEventListener(Y,oe)}catch{}}}catch(O){F={error:O}}finally{try{S&&!S.done&&($=A.return)&&$.call(A)}finally{if(F)throw F.error}}}function N(F,$){if(v.push([F,$]),i.addEventListener(F,$),s||o){try{i.removeEventListener(F,$)}catch{}return!1}return!0}function P(F){var $=F instanceof Error?F:Error(String(F));f?.($),d=void 0,f=void 0}function _(F,$){var A,S;if(!(s||o)&&(s=!0,r=!1,a=!1,m(),P(F),$))try{for(var H=Ml(Wp([],Sl(M),!1)),Y=H.next();!Y.done;Y=H.next()){var oe=Y.value;oe()}}catch(O){A={error:O}}finally{try{Y&&!Y.done&&(S=H.return)&&S.call(H)}finally{if(A)throw A.error}}}function g(){var F,$,A,S;if(!(!u||r||s||o))try{var H=i.getState();if(s||o||H==="loading")return;if(H==="hidden"){_(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(H))throw Error("Invalid MRAID state");try{for(var Y=Ml([["viewableChange",z],["stateChange",T],["sizeChange",D]]),oe=Y.next();!oe.done;oe=Y.next()){var O=Sl(oe.value,2),k=O[0],ne=O[1];if(!N(k,ne))return}}catch(se){F={error:se}}finally{try{oe&&!oe.done&&($=Y.return)&&$.call(Y)}finally{if(F)throw F.error}}var X=i.isViewable();if(s||o)return;if(typeof X!="boolean")throw Error("Invalid MRAID viewability");a=X,r=!0,clearTimeout(h),clearTimeout(p),d?.(),d=void 0,f=void 0;try{for(var K=Ml(Wp([],Sl(y),!1)),ge=K.next();!ge.done;ge=K.next()){var ne=ge.value;ne(a)}}catch(se){A={error:se}}finally{try{ge&&!ge.done&&(S=K.return)&&S.call(K)}finally{if(A)throw A.error}}}catch(se){_(se,r)}}var b=function(){return g()},z=function(F){var $,A;if(!(!r||s||o)){if(typeof F!="boolean"){_(Error("Invalid MRAID visibility event"),!0);return}a=F;try{for(var S=Ml(Wp([],Sl(y),!1)),H=S.next();!H.done;H=S.next()){var Y=H.value;Y(a)}}catch(oe){$={error:oe}}finally{try{H&&!H.done&&(A=S.return)&&A.call(S)}finally{if($)throw $.error}}}},T=function(F){F==="hidden"&&_(Error("MRAID closed"),!0)},D=function(){var F;r&&!s&&!o&&((F=n.onResize)===null||F===void 0||F.call(n))};function G(){var F,$,A;if(!(s||o))try{if(i=t(),s||o)return;if(!i){p=setTimeout(G,(A=n.pollMs)!==null&&A!==void 0?A:50);return}if(![i.getState,i.isViewable,i.addEventListener,i.removeEventListener,i.open].every(function(k){return typeof k=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var S=Ml([["ready",b]]),H=S.next();!H.done;H=S.next()){var Y=Sl(H.value,2),oe=Y[0],O=Y[1];if(!N(oe,O))return}}catch(k){F={error:k}}finally{try{H&&!H.done&&($=S.return)&&$.call(S)}finally{if(F)throw F.error}}u=!0,g()}catch(k){_(k,!1)}}return{init:function(){var F;return l||(l=new Promise(function($,A){d=$,f=A}),s||o?(P(Error("MRAID bridge destroyed")),l):(h=setTimeout(function(){return _(Error("MRAID readiness timed out"),!1)},(F=n.timeoutMs)!==null&&F!==void 0?F:5e3),G(),l))},isReady:function(){return r&&!s&&!o},isVisible:function(){return a&&r&&!s&&!o},isClosed:function(){return s||o},onVisibilityChanged:function(F){return!s&&!o&&y.add(F),function(){return y.delete(F)}},onClosed:function(F){return!s&&!o&&M.add(F),function(){return M.delete(F)}},openStore:function(F){if(!r||!a||s||o||!Ef(F))throw Error("MRAID store request not permitted");i.open(F)},destroy:function(){o||(o=!0,r=!1,a=!1,m(),P(Error("MRAID bridge destroyed")),y.clear(),M.clear())}}}var po=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.")},mo=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},Yc=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){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,p,y,M=function(){return u||l};function v(){var D,G;clearTimeout(p),clearTimeout(y);try{for(var F=po(r.splice(0)),$=F.next();!$.done;$=F.next()){var A=mo($.value,2),S=A[0],H=A[1];try{a?.removeEventListener(S,H)}catch{}}}catch(Y){D={error:Y}}finally{try{$&&!$.done&&(G=F.return)&&G.call(F)}finally{if(D)throw D.error}}}function m(D){var G,F;if(!M()){u=!0,s=!1,o=!1,v(),h?.(D instanceof Error?D:Error(String(D))),f=void 0,h=void 0;try{for(var $=po(Yc([],mo(t),!1)),A=$.next();!A.done;A=$.next()){var S=A.value;S()}}catch(H){G={error:H}}finally{try{A&&!A.done&&(F=$.return)&&F.call($)}finally{if(G)throw G.error}}}}var N=function(D){if(!(typeof D!="number"||!Number.isFinite(D)||D<0))return Math.min(1,D>1?D/100:D)},P=function(D){if(typeof D=="boolean")return D;if(D&&typeof D=="object"&&typeof D.isViewable=="boolean")return D.isViewable},_=function(){var D,G,F,$,A,S;if(!(s||M()||!a||((A=a.isReady)===null||A===void 0?void 0:A.call(a))===!1))try{o=a.isViewable();var H=(S=a.getAudioVolume)===null||S===void 0?void 0:S.call(a),Y=H===void 0?void 0:N(H);if(typeof o!="boolean"||H!==void 0&&Y===void 0)throw Error("Invalid DAPI initial state");if(s=!0,clearTimeout(p),clearTimeout(y),f?.(),f=void 0,h=void 0,Y!==void 0)try{for(var oe=po(Yc([],mo(i),!1)),O=oe.next();!O.done;O=oe.next()){var k=O.value;k(Y)}}catch(K){D={error:K}}finally{try{O&&!O.done&&(G=oe.return)&&G.call(oe)}finally{if(D)throw D.error}}try{for(var ne=po(Yc([],mo(e),!1)),X=ne.next();!X.done;X=ne.next()){var k=X.value;k(o)}}catch(K){F={error:K}}finally{try{X&&!X.done&&($=ne.return)&&$.call(ne)}finally{if(F)throw F.error}}}catch(K){m(K)}},g=function(D){var G,F;if(!M()){var $=P(D);if($===void 0){m(Error("Invalid DAPI visibility"));return}o=$;try{for(var A=po(Yc([],mo(e),!1)),S=A.next();!S.done;S=A.next()){var H=S.value;H($)}}catch(Y){G={error:Y}}finally{try{S&&!S.done&&(F=A.return)&&F.call(A)}finally{if(G)throw G.error}}}},b=function(D){var G,F;if(!M()){var $=N(D);if($===void 0){m(Error("Invalid DAPI volume"));return}try{for(var A=po(Yc([],mo(i),!1)),S=A.next();!S.done;S=A.next()){var H=S.value;H($)}}catch(Y){G={error:Y}}finally{try{S&&!S.done&&(F=A.return)&&F.call(A)}finally{if(G)throw G.error}}}},z=function(){var D;s&&!M()&&((D=n.onResize)===null||D===void 0||D.call(n))};function T(){var D,G,F;if(!M()){if(a=window.dapi,!a){y=setTimeout(T,(F=n.pollMs)!==null&&F!==void 0?F:25);return}try{try{for(var $=po([["ready",_],["viewableChange",g],["audioVolumeChange",b],["adResized",z]]),A=$.next();!A.done;A=$.next()){var S=mo(A.value,2),H=S[0],Y=S[1];r.push([H,Y]),a.addEventListener(H,Y)}}catch(oe){D={error:oe}}finally{try{A&&!A.done&&(G=$.return)&&G.call($)}finally{if(D)throw D.error}}_()}catch(oe){m(oe)}}}return{init:function(){var D;return d||(d=new Promise(function(G,F){f=G,h=F}),M()?(h?.(Error("DAPI bridge closed")),d):(p=setTimeout(function(){return m(Error("DAPI readiness timed out"))},(D=n.timeoutMs)!==null&&D!==void 0?D:5e3),T(),d))},isReady:function(){return s&&!M()},isVisible:function(){return s&&o&&!M()},isClosed:M,onVisibilityChanged:function(D){return M()||e.add(D),function(){return e.delete(D)}},onClosed:function(D){return M()||t.add(D),function(){return t.delete(D)}},onVolumeChanged:function(D){return M()||i.add(D),function(){return i.delete(D)}},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,v(),h?.(Error("DAPI bridge destroyed")),e.clear(),t.clear(),i.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 _g(){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("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 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}}},Gw=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},Hw=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))},Ww=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=Ww(Hw([],Gw(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 zw(this,void 0,void 0,function(){return Vw(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 Xw=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())})},Yw=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}}},Xp=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},Yp=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))},qp=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 Sg(){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 p=!s||!a;if(a=!0,s=!0,p)try{for(var y=qp(Yp([],Xp(e),!1)),M=y.next();!M.done;M=y.next()){var v=M.value;v(!0)}}catch(m){f={error:m}}finally{try{M&&!M.done&&(h=y.return)&&h.call(y)}finally{if(f)throw f.error}}}},d=function(){var f,h,p,y;if(!(o||u)){a=!1,s=!1,o=!0;try{for(var M=qp(Yp([],Xp(e),!1)),v=M.next();!v.done;v=M.next()){var m=v.value;m(!1)}}catch(_){f={error:_}}finally{try{v&&!v.done&&(h=M.return)&&h.call(M)}finally{if(f)throw f.error}}try{for(var N=qp(Yp([],Xp(t),!1)),P=N.next();!P.done;P=N.next()){var m=P.value;m()}}catch(_){p={error:_}}finally{try{P&&!P.done&&(y=N.return)&&y.call(N)}finally{if(p)throw p.error}}}};return n.gameStart=l,n.gameClose=d,{init:function(){return Xw(this,void 0,void 0,function(){return Yw(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 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}}},Jw=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},$w=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 bg(){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($w([],Jw(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 qw(this,void 0,void 0,function(){return Zw(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 bt=function(){return bt=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},bt.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())})},jw=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}}},Oe=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},et=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 Tg(n){if(n!=="standalone"){if(n==="unity-ads-ua-playable")return gg();if(n==="applovin-growth-playable")return yg();if(n==="ironsource-levelplay-playable")return xg();if(n==="meta-audience-playable")return _g();if(n==="google-ads-app-playable")return Mg();if(n==="mintegral-appgrowth-zip")return Sg();if(n==="tiktok-ads-playable")return bg();throw Error("E_NATIVE_TARGET")}}function Zp(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 Af(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:et([],Oe(e),!1).length*(a?Number(a[1]):16)*.6}function wg(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 p=Be(String(e).split(`
|
|
4224
|
+
`)),y=p.next();!y.done;y=p.next()){var M=y.value;if(t.wrap===!1){h.push(M);continue}var v=M.trim()?M.trim().split(/\s+/):[""],m=void 0;try{for(var N=(s=void 0,Be(v)),P=N.next();!P.done;P=N.next()){var _=P.value,g=m?m+" "+_:_;if(Af(n,g)<=f){m=g;continue}if(m&&h.push(m),Af(n,_)<=f){m=_;continue}var b="";try{for(var z=(u=void 0,Be(_)),T=z.next();!T.done;T=z.next()){var D=T.value;b&&Af(n,b+D)>f?(h.push(b),b=D):b+=D}}catch(G){u={error:G}}finally{try{T&&!T.done&&(l=z.return)&&l.call(z)}finally{if(u)throw u.error}}m=b}}catch(G){s={error:G}}finally{try{P&&!P.done&&(o=N.return)&&o.call(N)}finally{if(s)throw s.error}}h.push(m)}}catch(G){r={error:G}}finally{try{y&&!y.done&&(a=p.return)&&a.call(p)}finally{if(r)throw r.error}}return h}function Eg(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=wg(n,e,t,l),f,h=function(){var p;n.font=t.fontWeight+" "+l+"px "+t.fontFamily;var y=Math.max.apply(Math,et([0],Oe(d.map(function(N){return Af(n,N)})),!1)),M=l*((p=t.lineHeight)!==null&&p!==void 0?p:1.2),v=d.length>16;v&&(d=d.slice(0,16));var m=d.length*M;return{lines:d,fontSize:l,scale:l/t.fontSize,renderedWidth:y,renderedHeight:m,availableWidth:s,availableHeight:o,padding:a,lineHeight:M,overflowsWidth:y>s+.01,overflowsHeight:v||m>o+.01,unsupportedChars:[]}};if(f=h(),t.autoFit!==!1)for(;(f.overflowsWidth||f.overflowsHeight)&&l>u;)l=Math.max(u,l-1),d=wg(n,e,t,l),f=h();return f}function e1(n,e,t){var i=Eg(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 t1(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,p=h===void 0?n.base.startScene:h,y=l.onSelect,M=y===void 0?function(){}:y,v=l.network,m=v===void 0?"standalone":v,N=l.review,P=N===void 0?!1:N,_=Tg(m),g=e.getContext("2d"),b=new Map(n.components.map(function(c){return[c.id,c]})),z=new Map(n.assets.map(function(c){return[c.id,c]})),T=new Map,D=new Map(n.events.map(function(c){return[c.id,c]})),G=new Map(n.gameplay.filter(function(c){return c.kind==="responsive-layout"}).map(function(c){return[c.componentId,c.parameters]})),F=(a=globalThis.matchMedia)===null||a===void 0?void 0:a.call(globalThis,"(prefers-reduced-motion: reduce)"),$,A=new Map,S=A;function H(){var c=G.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 Y(){$!==H().landscape&&(ar(),Si())}try{for(var oe=Be(n.assets),O=oe.next();!O.done;O=oe.next()){var k=O.value;if(k.mime.startsWith("image/")){var ne=new Image;ne.src="data:"+k.mime+";base64,"+k.data,T.set(k.id,ne)}}}catch(c){i={error:c}}finally{try{O&&!O.done&&(r=oe.return)&&r.call(oe)}finally{if(i)throw i.error}}var X=p,K={},ge=[],se=[],Se=[],Pe=[],le=new Set,ae=new Map,fe=0,Ne=0,Re=0,We=0,Qe=0,ke=!1,qe=0,ft=0,tt=!1,st=[],Ke,en,nt,on,ue,hn,gn,J,w,ie,ye=[],Ae,Xe=[],Je=[],Te,Ie=0,ot=!1,yt=0,ht=m==="standalone",rt=m==="standalone",Lt=m==="standalone",Bt=!1,qt=!1,te=new Map,at=new Map,Ce=new Map,pt=new Map,lt=new Set,He=new Map,Zt=new Map,It=new Set,xt=new Map,kt=new Map,ct=new Map,zt=new Map,$t=new Map,ln=new Map,pn=0,tn=0,Qt,nn,yn=1,un,En=new Map,ii=new Map,kn=new Map,zn=new Map,Un=new Map,Fn=new Map,Jn=new Map,rn=Mm(),ri=wm(),Wn=new Map,Ei=new Map,Rn=Im(mu(n.projectId)),ci=new Map,R=new Map,ce=new Map,we=new Set,ve=new Map,de,mt=1,Ct=1,Ye,Rt,Dt={x:0,y:0},_t,Gt=[],De=[],Ht=new Map,an=new Map,Pn=new Map,An=new Map,Xn=new Set,Ge,Yn,Et;n.components.some(function(c){return c.contract==="native.stage3d.v1"})&&(Et=sg(n,z,function(){qt||Promise.resolve().then(function(){qt||Si()})},te));var vt=function(c){var x;return(x=Ce.get(c))!==null&&x!==void 0?x:b.get(c)},si=function(c,x){return n.gameplay.find(function(I){return I.kind===c&&I.componentId===x})},Ni=function(){var c,x;pn++,It.clear(),xt.clear(),ct.clear(),zt.clear();try{for(var I=Be(lt),E=I.next();!E.done;E=I.next()){var C=E.value;try{C.stop()}catch{}}}catch(U){c={error:U}}finally{try{E&&!E.done&&(x=I.return)&&x.call(I)}finally{if(c)throw c.error}}lt.clear(),kt.clear()},nr=function(c){var x,I;if(!de||c!==void 0&&de.pointerId!==c)return!1;var E=de.pointerId;de.behavior.parameters.powerVariableId&&(K[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},Vn=function(c){var x,I,E;if(!Ge||c!==void 0&&Ge.pointerId!==c)return!1;var C=Ge.pointerId;Ge.behavior.parameters.powerVariableId&&(K[Ge.behavior.parameters.powerVariableId]=0),(x=Et?.getStage(b.get(Ge.stageId)))===null||x===void 0||x.setGuide([]),Ge=void 0;try{!((I=e.hasPointerCapture)===null||I===void 0)&&I.call(e,C)&&((E=e.releasePointerCapture)===null||E===void 0||E.call(e,C))}catch{}return!0},$n=function(c){var x,I;if(!Yn||c!==void 0&&Yn.pointerId!==c)return!1;var E=Yn.pointerId;Yn=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},Wi=function(c){var x=c.behavior.parameters;x.axisXVariableId&&(K[x.axisXVariableId]=c.nx),x.axisYVariableId&&(K[x.axisYVariableId]=c.ny),x.magnitudeVariableId&&(K[x.magnitudeVariableId]=c.magnitude),x.angleVariableId&&c.magnitude>0&&(K[x.angleVariableId]=c.angle)},jn=function(c,x){var I,E,C,U;x===void 0&&(x=!1);try{for(var L=Be(ve.values()),W=L.next();!W.done;W=L.next()){var V=W.value;if(!(V.pointerId===null||c!==void 0&&V.pointerId!==c)){var Q=V.pointerId;V.pointerId=null,V.nx=0,V.ny=0,V.magnitude=0,V.knobX=V.origin.x,V.knobY=V.origin.y,Wi(V);try{!((C=e.hasPointerCapture)===null||C===void 0)&&C.call(e,Q)&&((U=e.releasePointerCapture)===null||U===void 0||U.call(e,Q))}catch{}x&&bn(sr("joystickEnd",V.c))}}}catch(B){I={error:B}}finally{try{W&&!W.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),!nt||c!==void 0&&nt.pointerId!==c)return!1;var C=nt,U=C.pointerId;if(nt=void 0,Rt=void 0,x){var L=vt(C.targetId);L&&C.b.parameters.snapBack&&(Lr(L,C.origin.x,C.origin.y),C.originZone&&rn.place(L.id,C.originZone))}try{!((I=e.hasPointerCapture)===null||I===void 0)&&I.call(e,U)&&((E=e.releasePointerCapture)===null||E===void 0||E.call(e,U))}catch{}return!0},Mi=function(c){var x,I;Ae?.pointerId===c.pointerId&&(Ae=void 0);try{for(var E=Be($t.values()),C=E.next();!C.done;C=E.next()){var U=C.value;U.pointerId===c.pointerId&&U.held&&(U.held=!1,U.releasedAt=fe)}}catch(W){x={error:W}}finally{try{C&&!C.done&&(I=E.return)&&I.call(E)}finally{if(x)throw x.error}}var L=Ki(c.pointerId);return hn===c.pointerId?(ue=void 0,hn=void 0,!0):L},ir=function(c){var x,I,E,C,U,L,W,V;if(c){nt&&((W=Ce.get(nt.targetId))===null||W===void 0?void 0:W.instanceId)===c&&Ki(void 0,!1),de&&((V=Ce.get(de.targetId))===null||V===void 0?void 0:V.instanceId)===c&&nr();var Q=[];rn.release(c),ri.cancel(c),ci.delete(c),ce.delete(c),Rn.remove(c),ge=ge.filter(function(Me){return Me.id!==c});try{for(var B=Be(Ce),Z=B.next();!Z.done;Z=B.next()){var q=Oe(Z.value,2),ee=q[0],j=q[1];if(j.instanceId===c){Q.push(ee),rn.release(ee),ri.cancel(ee),Ce.delete(ee),te.delete(ee),pt.delete(ee),kn.delete(ee),Un.delete(ee),Fn.delete(ee);try{for(var re=(E=void 0,Be(zn.values())),pe=re.next();!pe.done;pe=re.next()){var be=pe.value;be.removeAgent(ee)}}catch(Me){E={error:Me}}finally{try{pe&&!pe.done&&(C=re.return)&&C.call(re)}finally{if(E)throw E.error}}try{for(var xe=(U=void 0,Be(at.keys())),Ee=xe.next();!Ee.done;Ee=xe.next()){var he=Ee.value;he.endsWith(":"+ee)&&at.delete(he)}}catch(Me){U={error:Me}}finally{try{Ee&&!Ee.done&&(L=xe.return)&&L.call(xe)}finally{if(U)throw U.error}}}}}catch(Me){x={error:Me}}finally{try{Z&&!Z.done&&(I=B.return)&&I.call(B)}finally{if(x)throw x.error}}Se=Se.filter(function(Me){return!Q.includes(Me.targetId)})}},sa=function(c){for(;c;){if(c.prototype)return c.id;c=vt(c.parentId)}},Da=function(){var c,x,I;return{viewport:H(),components:Object.fromEntries(et([],Oe(te),!1).map(function(E){var C=Oe(E,2),U=C[0],L=C[1];return[U,bt(bt({},L),{parameters:bt({},L.parameters)})]})),mode:f?"edit":"play",scene:X,variables:bt({},K),time:fe,instances:ge.map(function(E){return bt({id:E.id,prototypeId:E.prototypeId,x:E.transform[4],y:E.transform[5]},Rn.snapshot(E.id))}),particles:se.length,animations:Se.length,contacts:le.size,spriteFrames:Object.fromEntries(et([],Oe(pt),!1).map(function(E){var C,U=Oe(E,2),L=U[0],W=U[1];return[L,(C=W.frame)!==null&&C!==void 0?C:0]})),input:{dragging:!!nt,pointerId:(x=(c=nt?.pointerId)!==null&&c!==void 0?c:Ye?.pointerId)!==null&&x!==void 0?x:null,pressed:ue??null,holding:!!Ye?.holds.length,occupancy:rn.snapshot(),joysticks:Object.fromEntries(et([],Oe(ve),!1).map(function(E){var C=Oe(E,2),U=C[0],L=C[1];return[U,{active:L.pointerId!==null,x:L.nx,y:L.ny,magnitude:L.magnitude,angle:L.angle}]}))},feedback:{presses:$t.size,floatingTexts:Xe.length,flashes:Je.length,shaking:!!Te,tutorialHands:yt},match:{boards:Object.fromEntries(et([],Oe(En),!1).map(function(E){var C=Oe(E,2),U=C[0],L=C[1];return[U,L.snapshot()]})),selected:Qt??null,cells:et([],Oe(ln),!1).map(function(E){var C=Oe(E,2),U=C[0],L=C[1];return bt({id:U},L)})},physics:If(),physics3d:Rf(),model3d:Et?.modelStatus(),paths:Object.fromEntries(et([],Oe(zn),!1).map(function(E){var C=Oe(E,2),U=C[0],L=C[1];return[U,L.snapshot()]})),canvas:{masks:Object.fromEntries(et([],Oe(ci),!1).map(function(E){var C=Oe(E,2),U=C[0],L=C[1];return[U,{progress:L.progress}]})),strokes:Object.fromEntries(et([],Oe(R),!1).map(function(E){var C=Oe(E,2),U=C[0],L=C[1];return[U,L.strokes.length]})),walls:Gt.length,joints:De.filter(function(E){return!E.broken}).length},audio:{state:(I=Ke?.state)!==null&&I!==void 0?I:"locked",voices:lt.size,blocked:tn},network:{target:m,ready:rt,visible:Lt,started:ht,closed:Bt,hostVolume:yn},diagnostics:et([],Oe(st),!1)}},rr=function(){return!f&&!ke&&!document.hidden&&rt&&Lt&&ht&&!Bt},ar=function(){var c,x,I,E;Ae=void 0,nr(),Vn(),$n(),jn(),Ki(),Ye=void 0,Rt=void 0,_t=void 0;try{for(var C=Be(R.values()),U=C.next();!U.done;U=C.next()){var L=U.value;L.cancel()}}catch(B){c={error:B}}finally{try{U&&!U.done&&(x=C.return)&&x.call(C)}finally{if(c)throw c.error}}ri.clear(),nn=void 0;try{for(var W=Be(En.values()),V=W.next();!V.done;V=W.next()){var Q=V.value;Q.cancelSelection()}}catch(B){I={error:B}}finally{try{V&&!V.done&&(E=W.return)&&E.call(W)}finally{if(I)throw I.error}}En.size&&(Qt=void 0),ue=void 0,hn=void 0,$t.clear()},Vi=function(c){tt=!0,st.push(c),st=st.slice(-16),Pe=[]},Yt=function(c){var x,I,E;return bt(bt(bt({},c.parameters),c.prototypeId?(x=te.get(c.prototypeId))===null||x===void 0?void 0:x.parameters:{}),(E=te.get((I=c.runtimeId)!==null&&I!==void 0?I:c.id))===null||E===void 0?void 0:E.parameters)};function vi(c,x){var I,E=$t.get(c.id);if(!E||F?.matches)return x;var C=et([],Oe(x),!1),U=E.held?0:fe-((I=E.releasedAt)!==null&&I!==void 0?I:fe),L=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-L,3)),V=Yt(c);C[4]+=(1-W)*(C[0]*V.width+C[2]*V.height)/2,C[5]+=(1-W)*(C[1]*V.width+C[3]*V.height)/2;for(var Q=0;Q<4;Q++)C[Q]*=W;return C}function On(c){return Et&&Xn.size>0&&di?{left:di.x,top:di.y,right:di.x+di.w,bottom:di.y+di.h,width:di.w,height:di.h}:{left:0,top:0,right:c.width,bottom:c.height,width:c.width,height:c.height}}function Nn(c){var x,I,E,C,U,L,W,V=c.transform,Q=(E=(I=te.get((x=c.runtimeId)!==null&&x!==void 0?x:c.id))===null||I===void 0?void 0:I.transform)!==null&&E!==void 0?E:V,B=G.get((C=c.prototypeId)!==null&&C!==void 0?C:c.id);if(!B)return vi(c,Q);var Z=H(),q=et([],Oe(Q),!1);Z.landscape&&(q[4]+=B.x-V[4],q[5]+=B.y-V[5],q[0]*=B.scaleX,q[1]*=B.scaleX,q[2]*=B.scaleY,q[3]*=B.scaleY);var ee=(U=B.anchor)!==null&&U!==void 0?U:"none";if(ee==="none"&&!B.respectSafeArea)return vi(c,q);var j=On(Z),re=B.respectSafeArea?Zp(j):j,pe=Yt(c),be=(L=B.marginX)!==null&&L!==void 0?L:0,xe=(W=B.marginY)!==null&&W!==void 0?W:0,Ee=Math.abs(q[0])*pe.width+Math.abs(q[2])*pe.height,he=Math.abs(q[1])*pe.width+Math.abs(q[3])*pe.height;return ee!=="none"?(q[4]=ee.endsWith("left")?re.left+be:ee.endsWith("right")?re.right-Ee-be:(re.left+re.right-Ee)/2,q[5]=ee.startsWith("top")?re.top+xe:ee.startsWith("bottom")?re.bottom-he-xe:(re.top+re.bottom-he)/2):(q[4]=Math.max(re.left+be,Math.min(re.right-Ee-be,q[4])),q[5]=Math.max(re.top+xe,Math.min(re.bottom-he-xe,q[5]))),vi(c,q)}var _a=function(c){return(Ce.has(c)?et([],Oe(Ce.values()),!1):et(et([],Oe(n.components),!1),Oe(ge),!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)})},qc=function(){return n.components.filter(function(c){return c.sceneId===X&&!c.parentId&&!c.prototype}).sort(function(c,x){return c.order-x.order||(c.id<x.id?-1:c.id>x.id?1:0)})},bn=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"&&un!==c.sceneId&&(un=c.sceneId,(I=_?.notifyGameEnd)===null||I===void 0||I.call(_)),Pe.length>=256){Vi("Event queue budget exhausted");return}Pe.push(c)},sr=function(c,x,I,E){var C,U,L,W;return E===void 0&&(E={}),bt(bt({kind:c,componentId:(C=x.prototypeId)!==null&&C!==void 0?C:x.id,selfInstanceId:(U=x.instanceId)!==null&&U!==void 0?U:x.id,instanceId:x.instanceId},I?{otherId:(L=I.prototypeId)!==null&&L!==void 0?L:I.id,otherInstanceId:(W=I.instanceId)!==null&&W!==void 0?W:I.id}:{}),E)};function Xi(c){for(var x,I=c;I;I=vt(I.parentId)){var E=Rn.states.get((x=I.instanceId)!==null&&x!==void 0?x:I.id);if(E)return E}}function oa(c){var x,I,E=si("instance-state",(x=c.prototypeId)!==null&&x!==void 0?x:c.id);return E?Rn.initialize((I=c.instanceId)!==null&&I!==void 0?I:c.id,E.parameters):void 0}function Zc(){var c,x,I,E;try{for(var C=Be(n.gameplay.filter(function(B){return B.kind==="instance-state"})),U=C.next();!U.done;U=C.next()){var L=U.value;try{for(var W=(I=void 0,Be(Pi(b.get(L.componentId)))),V=W.next();!V.done;V=W.next()){var Q=V.value;oa(Q)}}catch(B){I={error:B}}finally{try{V&&!V.done&&(E=W.return)&&E.call(W)}finally{if(I)throw I.error}}}}catch(B){c={error:B}}finally{try{U&&!U.done&&(x=C.return)&&x.call(C)}finally{if(c)throw c.error}}}function Jc(c,x,I,E){var C=Xi(c);if(C){var U=C.hp;if(x==="tag")C.tag=I==="set"?String(E):C.tag;else{var L=Number(E);if(C[x]=I==="add"?C[x]+L:I==="sub"?C[x]-L:L,!Number.isFinite(C[x])){Vi("Instance state range exceeded");return}x==="hp"&&(C.hp=Math.max(0,Math.min(C.maxHp,C.hp)))}U>0&&C.hp<=0&&bn(sr("instanceDepleted",c))}}function vo(c,x){var I,E,C;if(!c)return!0;if(c.all)return c.all.every(function(Q){return vo(Q,x)});if(c.any)return c.any.some(function(Q){return vo(Q,x)});var U=c.instanceTarget==="other"?x?.otherInstanceId:(I=x?.selfInstanceId)!==null&&I!==void 0?I:x?.instanceId,L=c.instanceField?(E=vt(U))!==null&&E!==void 0?E:et([],Oe(Ce.values()),!1).find(function(Q){return Q.instanceId===U}):void 0,W=c.instanceField?(C=Xi(L))===null||C===void 0?void 0:C[c.instanceField]:K[c.variableId],V=c.compareVariableId?K[c.compareVariableId]:c.value;return{eq:function(){return W===V},ne:function(){return W!==V},lt:function(){return W<V},lte:function(){return W<=V},gt:function(){return W>V},gte:function(){return W>=V}}[c.op]()}function $c(c){var x,I,E;Qt=void 0,nn=void 0,c||ln.clear();try{for(var C=Be(n.gameplay),U=C.next();!U.done;U=C.next()){var L=U.value;if(L.kind==="match-tile"){var W=b.get(L.componentId);if(c&&W.id!==c&&!qr(W,c))continue;te.delete(W.id),ln.set(W.id,{row:L.parameters.row,column:L.parameters.column,group:L.parameters.group,sceneId:W.sceneId,boardId:(E=W.parentId)!==null&&E!==void 0?E:W.sceneId})}}}catch(V){x={error:V}}finally{try{U&&!U.done&&(I=C.return)&&I.call(C)}finally{if(x)throw x.error}}}function Kc(){var c,x,I=function(L){var W,V;if(En.has(L.componentId))return"continue";var Q=L.componentId,B=L.parameters,Z=n.gameplay.filter(function(he){return he.kind==="match-tile"&&b.get(he.componentId).parentId===Q}).sort(function(he,Me){return he.parameters.row-Me.parameters.row||he.parameters.column-Me.parameters.column}).map(function(he){return bt({id:he.componentId},he.parameters)}),q=new Map;try{for(var ee=(W=void 0,Be(Z)),j=ee.next();!j.done;j=ee.next()){var re=j.value;if(!q.has(re.group)){var pe=b.get(re.id);q.set(re.group,{fill:pe.parameters.fill,children:_a(re.id).filter(function(he){return["native.image.v1","native.text.v1"].includes(he.contract)})})}}}catch(he){W={error:he}}finally{try{j&&!j.done&&(V=ee.return)&&V.call(ee)}finally{if(W)throw W.error}}ii.set(Q,q);var be=b.get(Z[B.columns].id).transform[5]-b.get(Z[0].id).transform[5],xe=function(he,Me,me){var Ue,Fe=me.from,it=Fe===void 0?he:Fe,Ve=me.progress,Ze=Ve===void 0?0:Ve,At=me.offsetRows,Nt=At===void 0?0:At,Jt=me.scale,Wt=Jt===void 0?1:Jt,Ut=me.opacity,Mt=Ut===void 0?1:Ut,wt=Z[he],Tt=b.get(wt.id),St=b.get(Z[it].id),ze=q.get(Me),je=et([],Oe(Tt.transform),!1);je[4]+=(St.transform[4]-Tt.transform[4])*Ze,je[5]+=(St.transform[5]-Tt.transform[5]+Nt*be)*Ze,je[4]+=(1-Wt)*(je[0]*Tt.parameters.width+je[2]*Tt.parameters.height)/2,je[5]+=(1-Wt)*(je[1]*Tt.parameters.width+je[3]*Tt.parameters.height)/2;for(var gt=0;gt<4;gt++)je[gt]*=Wt;te.set(wt.id,bt(bt({},te.get(wt.id)),{transform:je,parameters:bt(bt({},(Ue=te.get(wt.id))===null||Ue===void 0?void 0:Ue.parameters),{fill:ze.fill,opacity:Mt})})),ln.get(wt.id).group=Me;var $e=_a(wt.id).filter(function(Pt){return["native.image.v1","native.text.v1"].includes(Pt.contract)});$e.forEach(function(Pt,Ft){var mn,Xt,vn=ze.children[Ft];if(!(!vn||vn.contract!==Pt.contract)){var ut=(mn=te.get(Pt.id))!==null&&mn!==void 0?mn:{transform:et([],Oe(Pt.transform),!1),parameters:{}};Pt.contract==="native.image.v1"?ut.assetId=(Xt=vn.assetSlots[0])===null||Xt===void 0?void 0:Xt.assetId:ut.parameters.text=vn.parameters.text,te.set(Pt.id,ut)}})},Ee=ym(bt(bt({},B),{slots:Z,paint:xe,onEvent:function(he){Qt=void 0,bn({kind:he,componentId:Q})}}));En.set(Q,Ee)};try{for(var E=Be(n.gameplay.filter(function(L){return L.kind==="match-board"})),C=E.next();!C.done;C=E.next()){var U=C.value;I(U)}}catch(L){c={error:L}}finally{try{C&&!C.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}function bl(c){var x,I;Kc();try{for(var E=Be(En),C=E.next();!C.done;C=E.next()){var U=Oe(C.value,2),L=U[0],W=U[1];(!c||c===L||qr(b.get(L),c))&&W.reset()}}catch(V){x={error:V}}finally{try{C&&!C.done&&(I=E.return)&&I.call(E)}finally{if(x)throw x.error}}}function Pi(c){return sa(c)?et([],Oe(Ce.values()),!1).filter(function(x){return x.prototypeId===c.id}):[c]}function Ai(c){var x=Yt(c);return ei(ai(c),x.width/2,x.height/2)}function Pr(c,x,I){var E;I===void 0&&(I="self");var C=b.get(c),U=I==="other"?x.otherInstanceId:(E=x.selfInstanceId)!==null&&E!==void 0?E:x.instanceId,L=!!(C&&sa(C));if(U!==void 0){if(c){var W=et([],Oe(Ce.values()),!1).find(function(V){return V.prototypeId===c&&(V.instanceId===U||V.id===U)});if(W)return W}if(I==="other"||!c)return vt(U);if(L&&typeof U=="string"&&U.startsWith("instance."))return}return C?L?Pi(C)[0]:vt(c):void 0}function Lr(c,x,I){var E,C=Yt(c),U=(E=te.get(c.id))!==null&&E!==void 0?E:{transform:et([],Oe(c.transform),!1),parameters:{}},L=et([],Oe(U.transform),!1),W=c.parentId?ai(vt(c.parentId)):za(),V=ei(kr(W),x,I);L[4]=V.x-(L[0]*C.width+L[2]*C.height)/2,L[5]=V.y-(L[1]*C.width+L[3]*C.height)/2,te.set(c.id,bt(bt({},U),{transform:L})),c.prototypeId&&(c.transform=et([],Oe(L),!1))}function la(c,x,I){var E,C,U,L;I===void 0&&(I=!1);var W=(E=te.get(c.id))!==null&&E!==void 0?E:{transform:et([],Oe(c.transform),!1),parameters:{}},V=(L=(U=b.get((C=c.prototypeId)!==null&&C!==void 0?C:c.id))===null||U===void 0?void 0:U.transform)!==null&&L!==void 0?L:c.transform,Q=Math.hypot(V[0],V[1])*(I?-1:1),B=Math.hypot(V[2],V[3]),Z=x+(I?0:Math.atan2(V[1],V[0])),q=Math.cos(Z),ee=Math.sin(Z),j=et([],Oe(W.transform),!1);j[0]=q*Q,j[1]=ee*Q,j[2]=-ee*B,j[3]=q*B,te.set(c.id,bt(bt({},W),{transform:j}))}function Na(c,x){var I=kn.get(c.id);if(I)return I;var E=ai(c),C=Yt(c),U=ei(E,C.width/2,C.height/2);return I=bt({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])*C.width,height:Math.hypot(E[2],E[3])*C.height,angle:Math.atan2(E[1],E[0]),restElapsed:0,atRest:!0},x.parameters),kn.set(c.id,I),I}function Ua(c,x){var I,E=ci.get(c.id);if(E)return E;var C=Yt(c),U=x.parameters;return E=Cm(U,{width:C.width,height:C.height,source:c.contract==="native.image.v1"?T.get((I=c.assetSlots[0])===null||I===void 0?void 0:I.assetId):void 0,onProgress:function(L){U.progressVariableId&&(K[U.progressVariableId]=L),bn(sr("maskProgress",c))},onComplete:function(){return bn(sr("maskComplete",c))}}),ci.set(c.id,E),E}function Os(c){var x=R.get(c.componentId);return x||(x=Lm(c.parameters),R.set(c.componentId,x)),x}function Qc(){var c,x,I,E,C,U,L,W,V,Q,B,Z,q=new Set,ee=[];try{for(var j=Be(n.gameplay.filter(function(je){return je.kind==="physics-body"})),re=j.next();!re.done;re=j.next()){var pe=re.value,be=b.get(pe.componentId);if(be.sceneId===X)try{for(var xe=(I=void 0,Be(Pi(be))),Ee=xe.next();!Ee.done;Ee=xe.next()){var he=Ee.value;if(gi(he)){if(ee.length>=64){Vi("Physics body budget exhausted");break}var Me=Na(he,pe),me=ai(he),Ue=Yt(he),Fe=ei(me,Ue.width/2,Ue.height/2);if(q.add(he.id),Me.width=Math.hypot(me[0],me[1])*Ue.width,Me.height=Math.hypot(me[2],me[3])*Ue.height,Me.mode!=="dynamic"){var it=Un.get(he.id),Ve=he.parentId?ai(vt(he.parentId)):za(),Ze=(B=it?.vx)!==null&&B!==void 0?B:0,At=(Z=it?.vy)!==null&&Z!==void 0?Z:0;Me.x=Fe.x,Me.y=Fe.y,Me.angle=Math.atan2(me[1],me[0]),Me.vx=Ve[0]*Ze+Ve[2]*At,Me.vy=Ve[1]*Ze+Ve[3]*At}else Me.atRest&&(Me.x=Fe.x,Me.y=Fe.y);ee.push(Me)}}}catch(je){I={error:je}}finally{try{Ee&&!Ee.done&&(E=xe.return)&&E.call(xe)}finally{if(I)throw I.error}}}}catch(je){c={error:je}}finally{try{re&&!re.done&&(x=j.return)&&x.call(j)}finally{if(c)throw c.error}}try{for(var Nt=Be(kn.keys()),Jt=Nt.next();!Jt.done;Jt=Nt.next()){var Wt=Jt.value;!q.has(Wt)&&!Ce.has(Wt)&&kn.delete(Wt)}}catch(je){C={error:je}}finally{try{Jt&&!Jt.done&&(U=Nt.return)&&U.call(Nt)}finally{if(C)throw C.error}}var Ut=[];try{for(var Mt=Be(n.gameplay.filter(function(je){return je.kind==="capture-zone"})),wt=Mt.next();!wt.done;wt=Mt.next()){var pe=wt.value,be=b.get(pe.componentId);if(be.sceneId===X)try{for(var Tt=(V=void 0,Be(Pi(be))),St=Tt.next();!St.done;St=Tt.next()){var he=St.value;if(gi(he)){var me=ai(he),Ue=Yt(he),Fe=ei(me,Ue.width/2,Ue.height/2),ze=Math.max(.1,Math.min(Math.hypot(me[0],me[1]),Math.hypot(me[2],me[3])));Ut.push(bt(bt({id:he.id,sourceId:be.id,instanceId:he.instanceId,x:Fe.x,y:Fe.y},pe.parameters),{radius:pe.parameters.radius*ze}))}}}catch($e){V={error:$e}}finally{try{St&&!St.done&&(Q=Tt.return)&&Q.call(Tt)}finally{if(V)throw V.error}}}}catch(je){L={error:je}}finally{try{wt&&!wt.done&&(W=Mt.return)&&W.call(Mt)}finally{if(L)throw L.error}}return{bodies:et(et([],Oe(ee),!1),Oe(Gt),!1),zones:Ut}}function go(c){var x,I,E,C,U,L,W,V=Qc(),Q=V.bodies,B=V.zones,Z=H();De=[];try{for(var q=Be(n.gameplay.filter(function(Ve){return Ve.kind==="physics-joint"})),ee=q.next();!ee.done;ee=q.next()){var j=ee.value,re=b.get(j.componentId);if(re.sceneId===X){var pe=vt(j.parameters.anchorComponentId),be=si("physics-body",re.id);if(!(!pe||!be))try{for(var xe=(E=void 0,Be(Pi(re))),Ee=xe.next();!Ee.done;Ee=xe.next()){var he=Ee.value;Na(he,be);var Me=Ai(pe),me=j.id+":"+he.id;De.push(bt(bt({},j.parameters),{id:j.id,key:me,componentId:re.id,bodyId:he.id,anchorId:pe.id,x:Me.x,y:Me.y,broken:we.has(me)}))}}catch(Ve){E={error:Ve}}finally{try{Ee&&!Ee.done&&(C=xe.return)&&C.call(xe)}finally{if(E)throw E.error}}}}}catch(Ve){x={error:Ve}}finally{try{ee&&!ee.done&&(I=q.return)&&I.call(q)}finally{if(x)throw x.error}}th({bodies:Q,zones:B,joints:De,bounds:{left:0,top:0,right:Z.width,bottom:Z.height},dt:c,onEvent:function(Ve,Ze,At){var Nt,Jt,Wt,Ut;if(!(Ve==="bodyBounce"&&At&&Ze.sourceId===At.sourceId&&Ze.id>At.id)){var Mt=(Nt=Ze.instanceId)!==null&&Nt!==void 0?Nt:Ze.id,wt=At?(Jt=At.instanceId)!==null&&Jt!==void 0?Jt:At.id:void 0,Tt=bt(bt({kind:Ve,componentId:Ze.sourceId,selfInstanceId:Mt},wt?{otherInstanceId:wt}:{}),{instanceId:(Wt=Ze.instanceId)!==null&&Wt!==void 0?Wt:At?.instanceId});if(At&&(Tt.otherId=At.sourceId),bn(Tt),Ve==="zoneCapture"){var St=vt(Ze.id),ze=b.get(At.sourceId);if(At.hideCaptured&&St){var je=(Ut=te.get(St.id))!==null&&Ut!==void 0?Ut:{transform:et([],Oe(St.transform),!1),parameters:{}};je.parameters.visible=!1,te.set(St.id,je)}At.stopBody&&ze&&St&&Lr(St,At.x,At.y)}}}});try{for(var Ue=Be(Q),Fe=Ue.next();!Fe.done;Fe=Ue.next()){var it=Fe.value,he=vt(it.id);!he||it.mode!=="dynamic"||(it.spinToRotation&&la(he,(W=it.angle)!==null&&W!==void 0?W:0),Lr(he,it.x,it.y))}}catch(Ve){U={error:Ve}}finally{try{Fe&&!Fe.done&&(L=Ue.return)&&L.call(Ue)}finally{if(U)throw U.error}}}function jc(){var c,x,I,E,C;try{for(var U=Be(n.gameplay.filter(function(Ee){return Ee.kind==="oscillate"})),L=U.next();!L.done;L=U.next()){var W=L.value,V=b.get(W.componentId);if(V.sceneId===X)try{for(var Q=(I=void 0,Be(Pi(V))),B=Q.next();!B.done;B=Q.next()){var Z=B.value,q=Un.get(Z.id);q||(q={base:et([],Oe(Nn(Z)),!1),vx:0,vy:0},Un.set(Z.id,q));var ee=W.parameters,j=(fe/ee.periodSeconds+ee.phase)*Math.PI*2,re=Math.sin(j)*ee.amplitude,pe=Math.cos(j)*ee.amplitude*Math.PI*2/ee.periodSeconds,be=(C=te.get(Z.id))!==null&&C!==void 0?C:{parameters:{}},xe=et([],Oe(q.base),!1);ee.axis==="x"?(xe[4]+=re,q.vx=pe,q.vy=0):(xe[5]+=re,q.vy=pe,q.vx=0),te.set(Z.id,bt(bt({},be),{transform:xe})),Un.set(Z.id,q)}}catch(Ee){I={error:Ee}}finally{try{B&&!B.done&&(E=Q.return)&&E.call(Q)}finally{if(I)throw I.error}}}}catch(Ee){c={error:Ee}}finally{try{L&&!L.done&&(x=U.return)&&x.call(U)}finally{if(c)throw c.error}}}function wl(){var c,x;zn.clear();var I=function(L){var W=n.gameplay.filter(function(Q){return Q.kind==="path-gate"&&Q.parameters.networkBehaviorId===L.id}),V=lg({id:L.id,nodes:L.parameters.nodes,edges:L.parameters.edges,gates:W,onEvent:function(Q,B){var Z,q=vt(B.componentId),ee=(Z=q?.prototypeId)!==null&&Z!==void 0?Z:B.componentId;bn(bt({kind:Q,componentId:ee,instanceId:q?.instanceId},B.nodeId?{nodeId:B.nodeId}:{}))}});zn.set(L.id,V)};try{for(var E=Be(n.gameplay.filter(function(L){return L.kind==="path-network"})),C=E.next();!C.done;C=E.next()){var U=C.value;I(U)}}catch(L){c={error:L}}finally{try{C&&!C.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}function yo(c,x){var I,E,C,U,L,W,V,Q,B,Z,q,ee,j;x===void 0&&(x=!0);var re=0;try{for(var pe=Be(n.gameplay.filter(function(je){return je.kind==="path-agent"})),be=pe.next();!be.done;be=pe.next()){var xe=be.value,Ee=b.get(xe.componentId),he=zn.get(xe.parameters.networkBehaviorId);if(!(Ee.sceneId!==X||!he))try{for(var Me=(C=void 0,Be(Pi(Ee))),me=Me.next();!me.done;me=Me.next()){var Ue=me.value;if(++re>64){Vi("Path agent budget exhausted");break}var Fe=he.getAgent(Ue.id);Fe||(Fe=he.addAgent(bt(bt({},xe.parameters),{id:Ue.id,startNode:(q=Ue.pathStartNode)!==null&&q!==void 0?q:xe.parameters.startNode,targetNode:(ee=Ue.pathTargetNode)!==null&&ee!==void 0?ee:xe.parameters.targetNode}))),Fe.speedMultiplier=Math.max(0,Number(xe.parameters.speedMultiplierVariableId?K[xe.parameters.speedMultiplierVariableId]:1))}}catch(je){C={error:je}}finally{try{me&&!me.done&&(U=Me.return)&&U.call(Me)}finally{if(C)throw C.error}}}}catch(je){I={error:je}}finally{try{be&&!be.done&&(E=pe.return)&&E.call(pe)}finally{if(I)throw I.error}}if(x){var it=function(je,gt){var $e=n.gameplay.find(function(Pt){return Pt.id===je});b.get($e.componentId).sceneId===X&>.tick(c)};try{for(var Ve=Be(zn),Ze=Ve.next();!Ze.done;Ze=Ve.next()){var At=Oe(Ze.value,2),Nt=At[0],Jt=At[1];it(Nt,Jt)}}catch(je){L={error:je}}finally{try{Ze&&!Ze.done&&(W=Ve.return)&&W.call(Ve)}finally{if(L)throw L.error}}}try{for(var Wt=Be(n.gameplay.filter(function(je){return je.kind==="path-agent"})),Ut=Wt.next();!Ut.done;Ut=Wt.next()){var xe=Ut.value,Ee=b.get(xe.componentId),Mt=zn.get(xe.parameters.networkBehaviorId);if(!(Ee.sceneId!==X||!Mt))try{for(var wt=(B=void 0,Be(Pi(Ee))),Tt=wt.next();!Tt.done;Tt=wt.next()){var Ue=Tt.value,Fe=Mt.getAgent(Ue.id);if(Fe){if(Fe.orientToPath==="rotate")la(Ue,Fe.heading);else if(Fe.orientToPath==="flip-x")la(Ue,0,Fe.flipX);else if(Fe.orientToPath==="iso-4"){var St=(j=te.get(Ue.id))!==null&&j!==void 0?j:{transform:et([],Oe(Ue.transform),!1),parameters:{}};St.pathFrame=Fe.frame,te.set(Ue.id,St)}var ze=Ue.parentId?ei(ai(vt(Ue.parentId)),Fe.x,Fe.y):Fe;Lr(Ue,ze.x,ze.y)}}}catch($e){B={error:$e}}finally{try{Tt&&!Tt.done&&(Z=wt.return)&&Z.call(wt)}finally{if(B)throw B.error}}}}catch(je){V={error:je}}finally{try{Ut&&!Ut.done&&(Q=Wt.return)&&Q.call(Wt)}finally{if(V)throw V.error}}}function Tl(c){var x,I,E,C,U,L,W,V,Q,B,Z=new Set;try{for(var q=Be(n.gameplay.filter(function(ut){return ut.kind==="value-meter"})),ee=q.next();!ee.done;ee=q.next()){var j=ee.value,re=b.get(j.componentId);if(re.sceneId===X)try{for(var pe=(E=void 0,Be(Pi(re))),be=pe.next();!be.done;be=pe.next()){var xe=be.value,Ee=j.parameters,he=Ee.instanceField?Xi(xe):void 0,Me=Ee.instanceField==="hp"&&he?he.hp/he.maxHp*(Ee.max-Ee.min)+Ee.min:Ee.instanceField==="value"&&he?he.value:Number(K[Ee.variableId]),me=Fn.get(xe.id);me||(me={base:et([],Oe(Nn(xe)),!1),value:Number.isFinite(Me)?Math.max(Ee.min,Math.min(Ee.max,Me)):Ee.min},Fn.set(xe.id,me)),Z.add(xe.id);var Ue=Math.max(Ee.min,Math.min(Ee.max,Me)),Fe=Ee.smoothingSeconds?1-Math.exp(-c/Ee.smoothingSeconds):1;me.value+=((Number.isFinite(Ue)?Ue:Ee.min)-me.value)*Fe;var it=Math.max(0,Math.min(1,(me.value-Ee.min)/(Ee.max-Ee.min))),Ve=et([],Oe(me.base),!1),Ze=(Q=te.get(xe.id))!==null&&Q!==void 0?Q:{parameters:{}},At=Ee.axis==="x"?Yt(xe).width:Yt(xe).height;if(Ee.axis==="x"?(Ve[0]*=it,Ve[1]*=it):(Ve[2]*=it,Ve[3]*=it),Ee.direction==="negative"){var Nt=At*(1-it);Ee.axis==="x"?(Ve[4]+=me.base[0]*Nt,Ve[5]+=me.base[1]*Nt):(Ve[4]+=me.base[2]*Nt,Ve[5]+=me.base[3]*Nt)}te.set(xe.id,bt(bt({},Ze),{transform:Ve}))}}catch(ut){E={error:ut}}finally{try{be&&!be.done&&(C=pe.return)&&C.call(pe)}finally{if(E)throw E.error}}}}catch(ut){x={error:ut}}finally{try{ee&&!ee.done&&(I=q.return)&&I.call(q)}finally{if(x)throw x.error}}try{for(var Jt=Be(Fn.keys()),Wt=Jt.next();!Wt.done;Wt=Jt.next()){var Ut=Wt.value;Z.has(Ut)||Fn.delete(Ut)}}catch(ut){U={error:ut}}finally{try{Wt&&!Wt.done&&(L=Jt.return)&&L.call(Jt)}finally{if(U)throw U.error}}try{for(var Mt=Be(n.gameplay.filter(function(ut){return ut.kind==="camera-follow"})),wt=Mt.next();!wt.done;wt=Mt.next()){var j=wt.value,Tt=b.get(j.componentId),Ue=vt(j.parameters.targetId);if(!(Tt.sceneId!==X||!Ue)){var St=Jn.get(Tt.id);St||(St={base:et([],Oe(Tt.transform),!1),x:j.parameters.minX,y:j.parameters.minY},Jn.set(Tt.id,St));var ze=function(Gn,hi){for(var oi=[],Kn=Gn;Kn&&Kn.id!==hi.id;Kn=vt(Kn.parentId))oi.unshift(Kn);return oi.reduce(function(Li,pi){return Io(Li,Nn(pi))},za())},Ve=qr(Ue,Tt.id)?ze(Ue,Tt):ai(Ue),Ee=Yt(Ue),je=ei(Ve,Ee.width/2,Ee.height/2),gt=H(),$e=j.parameters,Pt=Math.max($e.minX,$e.maxX-gt.width/$e.zoom),Ft=Math.max($e.minY,$e.maxY-gt.height/$e.zoom),mn=Math.max($e.minX,Math.min(Pt,je.x-gt.width/(2*$e.zoom))),Xt=Math.max($e.minY,Math.min(Ft,je.y-gt.height/(2*$e.zoom))),Fe=1-Math.exp(-$e.smoothing*c);St.x+=(mn-St.x)*Fe,St.y+=(Xt-St.y)*Fe;var Ze=(B=te.get(Tt.id))!==null&&B!==void 0?B:{parameters:{}},vn=et([],Oe(St.base),!1);vn[0]*=$e.zoom,vn[1]*=$e.zoom,vn[2]*=$e.zoom,vn[3]*=$e.zoom,vn[4]-=St.x*$e.zoom,vn[5]-=St.y*$e.zoom,te.set(Tt.id,bt(bt({},Ze),{transform:vn}))}}}catch(ut){W={error:ut}}finally{try{wt&&!wt.done&&(V=Mt.return)&&V.call(Mt)}finally{if(W)throw W.error}}}function If(){return{bodies:et([],Oe(kn.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 Bs(c){for(var x=c;x;){if(x.contract==="native.stage3d.v1")return x;x=x.parentId?vt(x.parentId):void 0}}function ks(c,x){var I,E,C,U,L,W,V,Q,B=Ht.get(c.id);if(B)return B;var Z=Yt(c),q=Bs(c),ee={};if(x.parameters.fitColliderFromModel&&q&&Et){Et.getStage(q);var j=Et.modelBoundsFor(c.id);if(j){var re=Math.max(.02,j.width*Math.abs((I=Z.sx)!==null&&I!==void 0?I:1)*.5),pe=Math.max(.02,j.depth*Math.abs((E=Z.sz)!==null&&E!==void 0?E:1)*.5);ee.hx=re,ee.hz=pe,ee.radius=Math.max(.02,Math.max(re,pe))}}return B=bt(bt({id:c.id,sourceId:x.componentId,stageId:q?.id,x:(C=Z.x)!==null&&C!==void 0?C:0,y:(U=Z.y)!==null&&U!==void 0?U:0,z:(L=Z.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:(W=Z.x)!==null&&W!==void 0?W:0,y:(V=Z.y)!==null&&V!==void 0?V:0,z:(Q=Z.z)!==null&&Q!==void 0?Q:0}},x.parameters),ee),Ht.set(c.id,B),B}function xo(){var c,x,I,E,C,U,L,W=[],V=[],Q=[];if(!Et)return{bodies:W,walls:V,zones:Q};try{for(var B=Be(n.gameplay.filter(function(xe){return xe.kind==="physics-3d"})),Z=B.next();!Z.done;Z=B.next()){var q=Z.value,ee=b.get(q.componentId);if(!(!ee||ee.sceneId!==X||!gi(ee))){var j=ks(ee,q);j.mode==="dynamic"?W.push(j):V.push(j)}}}catch(xe){c={error:xe}}finally{try{Z&&!Z.done&&(x=B.return)&&x.call(B)}finally{if(c)throw c.error}}try{for(var re=Be(n.gameplay.filter(function(xe){return xe.kind==="capture-zone-3d"})),pe=re.next();!pe.done;pe=re.next()){var q=pe.value,ee=b.get(q.componentId);if(!(!ee||ee.sceneId!==X||!gi(ee))){var be=Yt(ee);Q.push(bt({id:ee.id,sourceId:ee.id,x:(C=be.x)!==null&&C!==void 0?C:0,y:(U=be.y)!==null&&U!==void 0?U:0,z:(L=be.z)!==null&&L!==void 0?L:0},q.parameters))}}}catch(xe){I={error:xe}}finally{try{pe&&!pe.done&&(E=re.return)&&E.call(re)}finally{if(I)throw I.error}}return{bodies:W,walls:V,zones:Q}}function Cf(c){var x,I,E,C,U,L,W,V,Q,B;if(Et){try{for(var Z=Be(n.gameplay.filter(function(Ut){return Ut.kind==="oscillate-3d"})),q=Z.next();!q.done;q=Z.next()){var ee=q.value,j=b.get(ee.componentId);if(!(!j||j.sceneId!==X)){var re=an.get(j.id);if(!re){var pe=Yt(j);re={x:(U=pe.x)!==null&&U!==void 0?U:0,y:(L=pe.y)!==null&&L!==void 0?L:0,z:(W=pe.z)!==null&&W!==void 0?W:0},an.set(j.id,re)}var be=ee.parameters,xe=fe*be.angularSpeed+be.phase,Ee=Math.sin(xe)*be.amplitude,he=Math.cos(xe)*be.amplitude*be.angularSpeed,Me=(V=Ht.get(j.id))!==null&&V!==void 0?V:si("physics-3d",j.id)?ks(j,si("physics-3d",j.id)):void 0,me=re.x+(be.axis==="x"?Ee:0),Ue=re.y+(be.axis==="y"?Ee:0),Fe=re.z+(be.axis==="z"?Ee:0);if(Me)Me.x=me,Me.y=Ue,Me.z=Fe,Me.vx=be.axis==="x"?he:0,Me.vy=be.axis==="y"?he:0,Me.vz=be.axis==="z"?he:0;else{var it=(Q=te.get(j.id))!==null&&Q!==void 0?Q:{transform:et([],Oe(j.transform),!1),parameters:{}};it.parameters.x=me,it.parameters.y=Ue,it.parameters.z=Fe,te.set(j.id,it)}}}}catch(Ut){x={error:Ut}}finally{try{q&&!q.done&&(I=Z.return)&&I.call(Z)}finally{if(x)throw x.error}}var Ve=xo(),Ze=Ve.bodies,At=Ve.walls,Nt=Ve.zones;ih({bodies:Ze,walls:At,zones:Nt,dt:c,onEvent:function(Ut,Mt,wt){var Tt={kind:Ut,componentId:Mt.sourceId};wt&&(Tt.otherId=wt.sourceId),bn(Tt)}});try{for(var Jt=Be(Ze),Wt=Jt.next();!Wt.done;Wt=Jt.next()){var Me=Wt.value;Me.captured&&(Me.captureElapsed=((B=Me.captureElapsed)!==null&&B!==void 0?B:0)+c)}}catch(Ut){E={error:Ut}}finally{try{Wt&&!Wt.done&&(C=Jt.return)&&C.call(Jt)}finally{if(E)throw E.error}}Ma(c,At),Et.stepAnimations(c,function(Ut,Mt,wt){bn(bt(bt({kind:"modelAnimationEnd",componentId:Mt},Ut!==Mt?{selfInstanceId:Ut,instanceId:Ut}:{}),{clipName:wt}))})}}function Bn(c){var x=An.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},An.set(c.componentId,x)}return x}function zs(){var c,x;try{for(var I=Be(n.gameplay.filter(function(U){var L;return U.kind==="fps-controller-3d"&&((L=b.get(U.componentId))===null||L===void 0?void 0:L.sceneId)===X})),E=I.next();!E.done;E=I.next()){var C=E.value;Bn(C)}}catch(U){c={error:U}}finally{try{E&&!E.done&&(x=I.return)&&x.call(I)}finally{if(c)throw c.error}}}function Yr(c){var x,I,E,C=[];try{for(var U=Be(Ce.values()),L=U.next();!L.done;L=U.next()){var W=L.value;W.contract==="native.mesh3d.v1"&&((E=Bs(W))===null||E===void 0?void 0:E.id)===c&&C.push(W)}}catch(V){x={error:V}}finally{try{L&&!L.done&&(I=U.return)&&I.call(U)}finally{if(x)throw x.error}}return C}function ja(c,x,I){var E,C,U=Bn(c),L=c.parameters,W=L.lookSensitivity,V=L.invertAimY?-1:1,Q=U.yaw-x*W;L.minYaw!==void 0&&L.maxYaw!==void 0&&(Q=Math.max(L.minYaw,Math.min(L.maxYaw,Q))),U.yaw=Q,U.pitch=Math.max((E=L.minPitch)!==null&&E!==void 0?E:-.75,Math.min((C=L.maxPitch)!==null&&C!==void 0?C:.75,U.pitch-I*W*V))}function Ma(c,x){var I,E,C,U,L,W,V,Q,B,Z,q,ee,j,re,pe,be,xe,Ee,he,Me,me=function(wt){var Tt=b.get(wt.componentId);if(!Tt||Tt.sceneId!==X)return"continue";var St=Bn(wt),ze=wt.parameters,je=ze.aimJoystickBehaviorId?ve.get(ze.aimJoystickBehaviorId):void 0;if(je&&ze.aimMode==="rate"&&je.magnitude>1e-4&&c>0){var gt=(V=ze.aimTurnSpeed)!==null&&V!==void 0?V:1.8,$e=ze.invertAimY?-1:1,Pt=St.yaw-je.nx*gt*c;ze.minYaw!==void 0&&ze.maxYaw!==void 0&&(Pt=Math.max(ze.minYaw,Math.min(ze.maxYaw,Pt))),St.yaw=Pt,St.pitch=Math.max((Q=ze.minPitch)!==null&&Q!==void 0?Q:-.75,Math.min((B=ze.maxPitch)!==null&&B!==void 0?B:.75,St.pitch-je.ny*gt*$e*c))}var Ft=ze.joystickBehaviorId?ve.get(ze.joystickBehaviorId):void 0,mn=Ft?Ft.nx:Number(ze.moveXVariableId?K[ze.moveXVariableId]:0),Xt=Ft?Ft.ny:Number(ze.moveYVariableId?K[ze.moveYVariableId]:0),vn=Math.min(1,Math.hypot(mn,Xt));if(vn>1e-4&&ze.moveSpeed>0&&c>0){var ut=-Xt,dt=mn,In=-Math.sin(St.yaw),Ii=-Math.cos(St.yaw),fi=Math.cos(St.yaw),ui=-Math.sin(St.yaw),Gn=ze.moveSpeed*c,hi=x.filter(function(Kn){return Kn.stageId===Tt.id}),oi=rh(St.x+(In*ut+fi*dt)*Gn,St.z+(Ii*ut+ui*dt)*Gn,(Z=ze.playerRadius)!==null&&Z!==void 0?Z:.45,hi,(q=ze.boundsX)!==null&&q!==void 0?q:12,(ee=ze.boundsZ)!==null&&ee!==void 0?ee:12);St.x=oi.x,St.z=oi.z,St.bobPhase+=c*10*vn,St.bob=F?.matches?0:Math.sin(St.bobPhase)*((j=ze.bobAmplitude)!==null&&j!==void 0?j:.04)*vn}else St.bob*=Math.max(0,1-12*c)};try{for(var Ue=Be(n.gameplay.filter(function(wt){return wt.kind==="fps-controller-3d"})),Fe=Ue.next();!Fe.done;Fe=Ue.next()){var it=Fe.value;me(it)}}catch(wt){I={error:wt}}finally{try{Fe&&!Fe.done&&(E=Ue.return)&&E.call(Ue)}finally{if(I)throw I.error}}try{for(var Ve=Be(n.gameplay.filter(function(wt){return wt.kind==="steer-3d"})),Ze=Ve.next();!Ze.done;Ze=Ve.next()){var it=Ze.value,At=b.get(it.componentId);if(!(!At||At.sceneId!==X)){var Nt=it.parameters,Jt=function(Tt){if(!gi(Tt))return"continue";var St=Bs(Tt),ze=St?An.get(St.id):void 0;if(!ze)return"continue";var je=Yt(Tt),gt=(re=je.x)!==null&&re!==void 0?re:0,$e=(pe=je.y)!==null&&pe!==void 0?pe:0,Pt=(be=je.z)!==null&&be!==void 0?be:0,Ft=ze.x-gt,mn=ze.z-Pt,Xt=Math.hypot(Ft,mn),vn=(xe=Nt.stopDistance)!==null&&xe!==void 0?xe:2.5,ut=gt,dt=$e,In=Pt,Ii=Nt.mode==="chase-camera"&&vn<=.5;if(Nt.mode==="chase-camera"&&Xt>vn&&Xt>1e-4){var fi=Math.min(Xt-vn,Nt.speed*c);ut+=Ft/Xt*fi,In+=mn/Xt*fi,Ii&&(dt+=(ze.y-.14-$e)*(fi/Xt))}else if(Nt.mode==="strafe-camera"&&Xt>1e-4){var ui=-mn/Xt,Gn=Ft/Xt;ut+=ui*Nt.speed*c,In+=Gn*Nt.speed*c}else Nt.mode==="patrol"&&(ut+=Math.cos(fe*1.5)*Nt.speed*c);var hi=Ii?[]:x.filter(function(Li){return Li.stageId===St.id&&Li.id!==Tt.id}),oi=Ii?{x:ut,z:In}:rh(ut,In,.45,hi,(Ee=Nt.boundsX)!==null&&Ee!==void 0?Ee:12,(he=Nt.boundsZ)!==null&&he!==void 0?he:12),Kn=(Me=te.get(Tt.id))!==null&&Me!==void 0?Me:{transform:et([],Oe(Tt.transform),!1),parameters:{}};Kn.parameters.x=oi.x,Ii&&(Kn.parameters.y=dt),Kn.parameters.z=oi.z,Nt.faceCamera!==!1&&(Kn.parameters.ry=Math.atan2(ze.x-oi.x,ze.z-oi.z)),te.set(Tt.id,Kn)};try{for(var Wt=(L=void 0,Be(Pi(At))),Ut=Wt.next();!Ut.done;Ut=Wt.next()){var Mt=Ut.value;Jt(Mt)}}catch(Tt){L={error:Tt}}finally{try{Ut&&!Ut.done&&(W=Wt.return)&&W.call(Wt)}finally{if(L)throw L.error}}}}}catch(wt){C={error:wt}}finally{try{Ze&&!Ze.done&&(U=Ve.return)&&U.call(Ve)}finally{if(C)throw C.error}}}function Vs(c){for(var x,I,E,C,U,L,W=[],V=c;V&&V.contract==="native.mesh3d.v1";V=vt(V.parentId))W.push(V);for(var Q=0,B=0,Z=0,q=0,ee=W.length-1;ee>=0;ee--){var j=W[ee],re=Ht.get(j.id),pe=Yt(j),be=re?re.x:(x=pe.x)!==null&&x!==void 0?x:0,xe=re?(E=(I=re.y)!==null&&I!==void 0?I:pe.y)!==null&&E!==void 0?E:0:(C=pe.y)!==null&&C!==void 0?C:0,Ee=re?re.z:(U=pe.z)!==null&&U!==void 0?U:0,he=Math.cos(q),Me=Math.sin(q);Q+=be*he+Ee*Me,B+=xe,Z+=-be*Me+Ee*he,q+=(L=pe.ry)!==null&&L!==void 0?L:0}return{x:Q,y:B,z:Z,ry:q}}var es=0;function El(c){var x,I,E,C,U,L,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 V=[];if(c.fromComponentId!==void 0){var Q=b.get(c.fromComponentId);Q&&Q.sceneId===X&&(V=Pi(Q).filter(function(Ve){var Ze,At;return gi(Ve)&&((At=(Ze=Xi(Ve))===null||Ze===void 0?void 0:Ze.hp)!==null&&At!==void 0?At:1)>0}))}else{var B=new Set;try{for(var Z=Be(et(et([],Oe(n.components),!1),Oe(ge),!1)),q=Z.next();!q.done;q=Z.next()){var ee=q.value;if(!(ee.contract!=="native.mesh3d.v1"||ee.sceneId!==X||ee.prototype||B.has(ee.id)||!gi(ee))){var j=Xi(ee);j&&j.hp>0&&(c.fromTeam==="any"||j.team===c.fromTeam)&&(B.add(ee.id),V.push(ee))}}}catch(Ve){x={error:Ve}}finally{try{q&&!q.done&&(I=Z.return)&&I.call(Z)}finally{if(x)throw x.error}}}if(!V.length)return;for(var re=(C=c.offsetX)!==null&&C!==void 0?C:0,pe=(U=c.offsetY)!==null&&U!==void 0?U:0,be=(L=c.offsetZ)!==null&&L!==void 0?L:0,xe=0;xe<W;xe++){var Ee=V[es++%V.length],he=Vs(Ee),Me=Math.cos(he.ry),me=Math.sin(he.ry),Ue=c.jitterX?(Rn.rng.next()*2-1)*c.jitterX:0,Fe=c.jitterZ?(Rn.rng.next()*2-1)*c.jitterZ:0;_o(c.prototypeId,he.x+re*Me+be*me+Ue,he.y+pe,he.z-re*me+be*Me+Fe)}return}for(var it=0;it<W;it++){var Ue=c.jitterX?(Rn.rng.next()*2-1)*c.jitterX:0,Fe=c.jitterZ?(Rn.rng.next()*2-1)*c.jitterZ:0;_o(c.prototypeId,c.x+Ue,c.y,c.z+Fe)}}function _o(c,x,I,E){if(ge.length>=128){Vi("Instance budget exhausted");return}var C=b.get(c),U=function(Q){return 1+n.components.filter(function(B){return B.parentId===Q}).reduce(function(B,Z){return B+U(Z.id)},0)};if(Ce.size+U(C.id)>4096){Vi("Runtime node budget exhausted");return}var L="instance."+ ++Re;function W(Q,B){var Z,q,ee=Q.id===C.id?L:L+":"+Q.id,j=bt(bt({},Q),{id:ee,runtimeId:ee,instanceId:L,prototypeId:Q.id,prototype:!1,parentId:B,transform:et([],Oe(Q.transform),!1),parameters:bt({},Q.parameters),spawnTime:fe});Ce.set(ee,j);try{for(var re=Be(n.components.filter(function(xe){return xe.parentId===Q.id})),pe=re.next();!pe.done;pe=re.next()){var be=pe.value;W(be,ee)}}catch(xe){Z={error:xe}}finally{try{pe&&!pe.done&&(q=re.return)&&q.call(re)}finally{if(Z)throw Z.error}}return j}var V=W(C,C.parentId);return V.parameters.x=x,V.parameters.y=I,V.parameters.z=E,ge.push(V),oa(V),V}function Al(c){var x,I,E;if(Et){var C=b.get(c.stageId);if(!(!C||C.sceneId!==X)){(x=Et.triggerRecoil)===null||x===void 0||x.call(Et,C.id);var U=Yt(C),L=ai(C),W=Math.hypot(L[0],L[1]),V=Math.hypot(L[2],L[3]),Q=Et.getStage(C),B=!!(Q?.isFullBleed&&Q.lastWidth>0&&Q.lastHeight>0),Z=Et.syncStage(C,{time:fe,ambientTime:Ne,propsOf:Yt,bodies3d:Ht,fpsPose:An.get(C.id),instances3d:Yr(C.id),aimLocked:!!Ge,groundFn:Qs,worldWidth:B?Q.lastWidth:U.width*W,worldHeight:B?Q.lastHeight:U.height*V,designHeight:B?Q.lastDesignH:U.height*V}).entry,q=0,ee=0;if(c.mode==="pointer")if(B)q=(Dt.x-Q.lastX)/Math.max(1,Q.lastWidth)*2-1,ee=1-(Dt.y-Q.lastY)/Math.max(1,Q.lastHeight)*2;else{var j=ei(kr(L),Dt.x,Dt.y);q=j.x/Math.max(1,U.width)*2-1,ee=1-j.y/Math.max(1,U.height)*2}var re=new Set(n.gameplay.filter(function(he){return he.kind==="physics-3d"&&he.parameters.mode!=="dynamic"}).map(function(he){return he.componentId})),pe=(I=c.targetTeam)!==null&&I!==void 0?I:"any",be=function(he){var Me,me,Ue=vt(he);return!Ue||!gi(Ue)?!1:pe!=="any"?((Me=Xi(Ue))===null||Me===void 0?void 0:Me.team)===pe:!!Xi(Ue)||!re.has((me=Ue.prototypeId)!==null&&me!==void 0?me:Ue.id)},xe=Z.raycast(q,ee,(E=c.maxDistance)!==null&&E!==void 0?E:80,{isTarget:be,isOccluder:function(he){return re.has(he)}});if(xe){var Ee=vt(xe.id);Ee&&bn(sr("raycastHit3d",Ee,C))}else bn({kind:"raycastMiss3d",componentId:C.id})}}}function Gs(c){var x,I,E;if(!Et)return null;var C=vt(c);if(!C||C.contract!=="native.mesh3d.v1")return null;var U=Bs(C);if(!U)return null;var L=Et.getStage(U);if(!L||!L.lastWidth||!L.lastHeight)return null;var W=Ht.get(C.id),V=Yt(C),Q=L.project({x:W?W.x:(x=V.x)!==null&&x!==void 0?x:0,y:W?W.y:(I=V.y)!==null&&I!==void 0?I:0,z:W?W.z:(E=V.z)!==null&&E!==void 0?E:0},L.lastWidth,L.lastHeight);return L.isFullBleed?{x:L.lastX+Q.x,y:L.lastY+Q.y}:ei(ai(U),Q.x,Q.y)}function Il(){if(!Ge||!Et)return{vx:0,vz:0,power:0,pull:0};var c=b.get(Ge.stageId),x=Et.getStage(c),I=Ht.get(Ge.targetId),E=Ge.behavior.parameters;if(!x||!I||!x.lastWidth||!x.lastHeight)return{vx:0,vz:0,power:0,pull:0};var C,U;if(x.isFullBleed)C={x:Ge.start.x-x.lastX,y:Ge.start.y-x.lastY},U={x:Ge.current.x-x.lastX,y:Ge.current.y-x.lastY};else{var L=kr(ai(c));C=ei(L,Ge.start.x,Ge.start.y),U=ei(L,Ge.current.x,Ge.current.y)}var W=Math.hypot(Ge.current.x-Ge.start.x,Ge.current.y-Ge.start.y),V=x.unproject(C.x,C.y,x.lastWidth,x.lastHeight,I.y),Q=x.unproject(U.x,U.y,x.lastWidth,x.lastHeight,I.y);if(!V||!Q)return{vx:0,vz:0,power:0,pull:W};var B=(V.x-Q.x)*E.dragScale,Z=(V.z-Q.z)*E.dragScale,q=Math.hypot(B,Z);return q>E.maxSpeed&&(B*=E.maxSpeed/q,Z*=E.maxSpeed/q),{vx:B,vz:Z,power:Math.min(1,Math.hypot(B,Z)/Math.max(.001,E.maxSpeed)),pull:W}}function eu(c){if(!(!Ge||!Et)){Ge.current=c;var x=Il(),I=Ge.behavior.parameters;Ge.power=x.power,I.powerVariableId&&(K[I.powerVariableId]=x.power);var E=b.get(Ge.stageId),C=Et.getStage(E),U=Ht.get(Ge.targetId);if(C&&U&&I.showTrajectory&&x.pull>=I.minPullPx){var L=xo(),W=L.walls,V=L.zones;C.setGuide(Wm({body:U,walls:W,zones:V,vx:x.vx,vz:x.vz,dots:I.trajectoryDots}))}else C?.setGuide([])}}function Rf(){return{bodies:et([],Oe(Ht.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:Ge?{componentId:Ge.sourceId,pointerId:Ge.pointerId,power:Ge.power}:null,projected:Object.fromEntries(Pn),fps:Object.fromEntries(et([],Oe(An),!1).map(function(c){var x=Oe(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 Mo(){w=void 0,un=void 0,ar(),ve.clear(),rn.clear(),Wn.clear(),Ei.clear(),Rn.reset(),ci.clear(),R.clear(),Gt=[],De=[],ce.clear(),we.clear(),A.clear(),Xe=[],Je=[],Te=void 0,Ie=0,ot=!1,yt=0,K=Object.fromEntries(n.variables.map(function(c){return[c.id,c.initial]})),Ni(),tn=0,Ce.clear(),pt.clear(),kn.clear(),Un.clear(),Ht.clear(),an.clear(),Pn.clear(),An.clear(),es=0,Et?.reset(),Fn.clear(),Jn.clear(),de=void 0,ge=[],se=[],Se=[],te.clear(),$c(),at.clear(),le.clear(),ae.clear(),Pe=[],fe=0,Ne=0,Re=0,tt=!1,We=0,X=n.base.startScene,ue=void 0,hn=void 0,on=void 0,J=void 0,f||(Zc(),bl(),wl(),xo(),zs(),yo(0,!1),Nf(),Tl(0),bn({kind:"sceneEnter",sceneId:X}))}function Pf(){var c,x;if(!(!Ke||Ke.state!=="running"||!xt.size)){var I=et([],Oe(xt.values()),!1);xt.clear();try{for(var E=Be(I),C=E.next();!C.done;C=E.next()){var U=C.value;$p(U)}}catch(L){c={error:L}}finally{try{C&&!C.done&&(x=E.return)&&x.call(E)}finally{if(c)throw c.error}}}}function So(c){if(c===void 0&&(c=!1),!Ke)return Promise.resolve(void 0);if(Ke.state==="running")return Promise.resolve().then(Pf),Promise.resolve(Ke);if(!en||c){var x=Ke,I=Promise.resolve().then(function(){return x.resume()}).then(function(){if(x.state==="running")return Pf(),x}).catch(function(){}).finally(function(){en===I&&(en=void 0)});en=I}return en}function Lf(){var c,x,I=et([],Oe(kt.values()),!1),E=I.some(function(B){return B.bus==="voice"}),C=I.some(function(B){return B.bus==="stinger"}),U=C?.2:E?.25:1;try{for(var L=Be(I),W=L.next();!W.done;W=L.next()){var V=W.value,Q=V.volume*yn*(V.bus==="music"?U:1);V.gain.gain.setTargetAtTime?V.gain.gain.setTargetAtTime(Q,Ke.currentTime,.04):V.gain.gain.value=Q}}catch(B){c={error:B}}finally{try{W&&!W.done&&(x=L.return)&&x.call(L)}finally{if(c)throw c.error}}}function Ag(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 C=x.numberOfChannels,U=.002,L=E,W=0,V=0;V<C;V++){for(var Q=x.getChannelData(V),B=0;B<L;B++)if(Math.abs(Q[B])>U){L=B;break}for(var B=E-1;B>W;B--)if(Math.abs(Q[B])>U){W=B;break}}if(L>=W)return x;var Z=W-L+1;if(Z<Math.round(I*.15))return x;var q=Math.min(Math.round(I*.06),Math.floor(Z*.1)),ee=Z-q;if(q<8||ee<Math.round(I*.1))return x;for(var j=c.createBuffer(C,ee,I),V=0;V<C;V++){for(var re=x.getChannelData(V),pe=j.getChannelData(V),B=0;B<q;B++){var be=B/q;pe[B]=re[L+B]*Math.sin(be*Math.PI*.5)+re[L+ee+B]*Math.cos(be*Math.PI*.5)}for(var B=q;B<ee;B++)pe[B]=re[L+B]}return j}function Jp(c,x,I){var E,C=(E=I.parameters.bus)!==null&&E!==void 0?E:"sfx";c.connect(x),x.connect(Ke.destination),lt.add(c),kt.set(c,{gain:x,bus:C,volume:I.parameters.volume}),c.onended=function(){lt.delete(c),kt.delete(c),I.parameters.loop&&It.delete(I.id),Lf()},Lf()}function $p(c){return Qw(this,void 0,void 0,function(){var x,I,E,C,U,L,W,V,Q,B,Z,q,ee,j,re,pe,be,xe,Ee,he,Me,me,Ue,Fe,it,Ve,Ze,At,Nt,Jt,Wt,Ut;return jw(this,function(Mt){switch(Mt.label){case 0:return lt.size>=32?[2]:(x=!!c.parameters.loop,Ke?(I=Ke,E=pn,C=(Ve=c.parameters.cooldownMs)!==null&&Ve!==void 0?Ve:45,U=I.currentTime,C>0&&U-((Ze=ct.get(c.id))!==null&&Ze!==void 0?Ze:-1/0)<C/1e3?[2]:x&&It.has(c.id)?[2]:(L=b.get(c.componentId),W=z.get((At=L?.assetSlots[0])===null||At===void 0?void 0:At.assetId),V=W?.mime==="audio/wav"||W?.mime==="audio/mpeg",!V&&c.parameters.allowSynthFallback===!1?(tn++,[2]):(ct.set(c.id,U),Q=I.state!=="running",Q?[4,So()]:[3,2]))):(x&&xt.set(c.id,c),[2]));case 1:Q=!Mt.sent(),Mt.label=2;case 2:if(Q)return x&&xt.set(c.id,c),[2];if(Ke!==I||I.state!=="running"||E!==pn||lt.size>=32)return[2];if(B=(Nt=zt.get(c.id))!==null&&Nt!==void 0?Nt:0,Z=[0,-.5,.5,-1,1],q=((Jt=c.parameters.pitchJitter)!==null&&Jt!==void 0?Jt:0)*Z[B%Z.length],ee=Number((Wt=K[c.parameters.pitchVariableId])!==null&&Wt!==void 0?Wt:0),j=Math.max(-12,Math.min(12,q+ee*((Ut=c.parameters.pitchStep)!==null&&Ut!==void 0?Ut:0))),re=Math.pow(2,j/12),zt.set(c.id,B+1),!V)return[3,8];x&&It.add(c.id),Mt.label=3;case 3:if(Mt.trys.push([3,6,,7]),pe=He.get(W.hash),pe)return[3,5];for(be=atob(W.data),xe=new Uint8Array(be.length),Ee=0;Ee<be.length;Ee++)xe[Ee]=be.charCodeAt(Ee);return[4,new Promise(function(wt,Tt){var St=I.decodeAudioData(xe.buffer,wt,Tt);St&&typeof St.then=="function"&&St.then(wt,Tt)})];case 4:pe=Mt.sent(),He.set(W.hash,pe),Mt.label=5;case 5:return Ke!==I||I.state!=="running"||E!==pn||lt.size>=32?(x&&E===pn&&It.delete(c.id),[2]):(he=pe,x&&(he=Zt.get(W.hash),he||(he=Ag(I,pe),Zt.set(W.hash,he))),Me=I.createBufferSource(),me=I.createGain(),Me.buffer=he,Me.loop=x,Me.playbackRate&&(Me.playbackRate.value=re),x&&me.gain.setValueAtTime&&me.gain.linearRampToValueAtTime?(me.gain.setValueAtTime(1e-4,I.currentTime),me.gain.linearRampToValueAtTime(c.parameters.volume,I.currentTime+.025)):me.gain.value=c.parameters.volume,Jp(Me,me,c),Me.start(),[3,7]);case 6:return Ue=Mt.sent(),It.delete(c.id),Vi("Audio decode failed"),[3,7];case 7:return[2];case 8:return Fe=I.createOscillator(),it=I.createGain(),Fe.frequency.value=c.parameters.frequency*re,Fe.type="sine",it.gain.setValueAtTime(c.parameters.volume,I.currentTime),it.gain.exponentialRampToValueAtTime(.001,I.currentTime+c.parameters.seconds),Jp(Fe,it,c),Fe.start(),Fe.stop(I.currentTime+c.parameters.seconds),[2]}})})}function Ig(c,x){for(var I=et([],Oe(ln.values()),!1).filter(function(B){return B.boardId===c}),E=function(B,Z){var q;return(q=I.find(function(ee){return ee.row===B&&ee.column===Z}))===null||q===void 0?void 0:q.group},C=function(B){for(var Z=function(j){var re=E(B,j);if(re&&re===E(B,j+1)&&re===E(B,j+2)&&x.some(function(pe){return pe.row===B&&pe.column>=j&&pe.column<=j+2}))return{value:!0}},q=0;q<14;q++){var ee=Z(q);if(typeof ee=="object")return ee}},U=0;U<16;U++){var L=C(U);if(typeof L=="object")return L.value}for(var W=function(B){for(var Z=function(j){var re=E(j,B);if(re&&re===E(j+1,B)&&re===E(j+2,B)&&x.some(function(pe){return pe.column===B&&pe.row>=j&&pe.row<=j+2}))return{value:!0}},q=0;q<14;q++){var ee=Z(q);if(typeof ee=="object")return ee}},V=0;V<16;V++){var Q=W(V);if(typeof Q=="object")return Q.value}return!1}function Cg(c){var x,I,E,C=ln.get(c.id);if(!(!C||C.sceneId!==X||!Yt(c).enabled||!gi(c))){var U=En.get(c.parentId);if(U){Qt=U.select(c.id);return}if(Qt===c.id){Qt=void 0;return}var L=ln.get(Qt);if(!L||L.sceneId!==X||L.boardId!==C.boardId){Qt=c.id;return}var W=b.get(Qt);if(Math.abs(L.row-C.row)+Math.abs(L.column-C.column)!==1){Qt=c.id;return}if(L.group===C.group){Qt=void 0,bn({kind:"invalidMatch",componentId:(x=c.parentId)!==null&&x!==void 0?x:c.id});return}var V=L.row,Q=L.column,B=C.row,Z=C.column,q=et([],Oe(Nn(W)),!1),ee=et([],Oe(Nn(c)),!1);if(L.row=B,L.column=Z,C.row=V,C.column=Q,Ig(C.boardId,[L,C])){var j=function(re,pe){var be,xe=(be=te.get(re.id))!==null&&be!==void 0?be:{transform:et([],Oe(Nn(re)),!1),parameters:{}};xe.transform=et([],Oe(xe.transform),!1),xe.transform[4]=pe[4],xe.transform[5]=pe[5],te.set(re.id,xe)};j(W,ee),j(c,q),Qt=void 0,bn({kind:"validMatch",componentId:(I=c.parentId)!==null&&I!==void 0?I:c.id})}else L.row=V,L.column=Q,C.row=B,C.column=Z,Qt=void 0,bn({kind:"invalidMatch",componentId:(E=c.parentId)!==null&&E!==void 0?E:c.id})}}function Df(c){var x,I,E,C,U=[],L=Mr(c,ai(c)),W=Ai(c),V=si("drag",(E=c.prototypeId)!==null&&E!==void 0?E:c.id),Q=function(ee){var j,re,pe=b.get(ee.componentId),be=ee.parameters;if(pe.sceneId!==X)return"continue";var xe=function(me){if(me.id===c.id||qr(me,c.id)||!gi(me))return"continue";var Ue=Mr(me,ai(me)),Fe=Ai(me),it=Math.hypot(Fe.x-W.x,Fe.y-W.y),Ve=be.radiusPx>0?it<=be.radiusPx:L.left<Ue.right&&L.right>Ue.left&&L.top<Ue.bottom&&L.bottom>Ue.top;if(!Ve)return"continue";U.push(bt({id:me.id,c:me,sourceId:pe.id,paintOrder:ye.findIndex(function(Ze){return Ze.c.id===me.id}),distance:it,itemTarget:n.gameplay.some(function(Ze){return Ze.kind==="drag"&&Ze.componentId===pe.id})},be))};try{for(var Ee=(j=void 0,Be(Pi(pe))),he=Ee.next();!he.done;he=Ee.next()){var Me=he.value;xe(Me)}}catch(me){j={error:me}}finally{try{he&&!he.done&&(re=Ee.return)&&re.call(Ee)}finally{if(j)throw j.error}}};try{for(var B=Be(n.gameplay.filter(function(ee){return ee.kind==="drop-zone"})),Z=B.next();!Z.done;Z=B.next()){var q=Z.value;Q(q)}}catch(ee){x={error:ee}}finally{try{Z&&!Z.done&&(I=B.return)&&I.call(B)}finally{if(x)throw x.error}}return{zones:U,tag:(C=V?.parameters.tag)!==null&&C!==void 0?C:""}}function Nf(c){var x,I,E=c?[c]:n.gameplay.filter(function(Z){return Z.kind==="drag"}).flatMap(function(Z){return Pi(b.get(Z.componentId))});try{for(var C=Be(E),U=C.next();!U.done;U=C.next()){var L=U.value;if(!(!L||!gi(L)||rn.zoneOf(L.id))){var W=Df(L),V=W.zones,Q=W.tag,B=pu({itemId:L.id,tag:Q,zones:V.filter(function(Z){return!Z.itemTarget}),occupancy:rn});B?.kind==="accept"&&rn.place(L.id,B.zone.id)}}}catch(Z){x={error:Z}}finally{try{U&&!U.done&&(I=C.return)&&I.call(C)}finally{if(x)throw x.error}}}function Hs(c,x,I){I===void 0&&(I=.18),c&&ri.to(c.id,Ai(c),x,I)}function Uf(c,x,I,E){var C,U,L=E??I?.c;bn(bt(bt({},sr(c,x,L,bt({},I?{otherId:I.sourceId}:{}))),{instanceId:(C=x.instanceId)!==null&&C!==void 0?C:(U=I?.c)===null||U===void 0?void 0:U.instanceId}))}function Rg(c){var x,I,E,C,U,L,W;if(!nt||nt.pointerId!==c.pointerId)return!1;var V=nt,Q=vt(V.targetId),B=V.b.parameters;nt=void 0,Rt=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(!Q)return!0;var Z=Df(Q),q=Z.zones,ee=Z.tag,j=pu({itemId:Q.id,tag:ee,zones:q,occupancy:rn}),re=V.origin,pe=V.originZone;if(!j)return Uf("dragReject",Q,void 0,void 0),B.snapBack&&(pe&&rn.place(Q.id,pe),Hs(Q,re,(E=B.snapBackSeconds)!==null&&E!==void 0?E:.18)),!0;var be=j.zone,xe=j.occupantId?vt(j.occupantId):void 0;return j.kind==="reject"?(Uf("dragReject",Q,be,xe),B.snapBack&&(pe&&rn.place(Q.id,pe),Hs(Q,re,(C=B.snapBackSeconds)!==null&&C!==void 0?C:.18)),!0):(j.kind==="accept"?(rn.place(Q.id,be.id),be.snapMode==="center"&&Hs(Q,Ai(be.c),(U=B.snapBackSeconds)!==null&&U!==void 0?U:.18)):j.kind==="swap"&&xe&&(rn.place(Q.id,be.id),pe?rn.place(xe.id,pe):rn.release(xe.id),Hs(Q,Ai(be.c),(L=B.snapBackSeconds)!==null&&L!==void 0?L:.18),Hs(xe,re,(W=B.snapBackSeconds)!==null&&W!==void 0?W:.18)),Uf("dragDrop",Q,be,j.kind==="accept"?be.c:xe),!0)}function Pg(c){var x,I,E,C,U;ri.tick(c,function(j,re){var pe=vt(j);pe&&Lr(pe,re.x,re.y)});try{for(var L=Be(et([],Oe(rn.itemZone.keys()),!1)),W=L.next();!W.done;W=L.next()){var V=W.value,Q=vt(V);(!Q||!gi(Q))&&rn.release(V)}}catch(j){x={error:j}}finally{try{W&&!W.done&&(I=L.return)&&I.call(L)}finally{if(x)throw x.error}}if(Ye)try{for(var B=Be(Ye.holds),Z=B.next();!Z.done;Z=B.next()){var q=Z.value,ee=q.charge.tick(c);ee!==K[q.behavior.parameters.variableId]&&(K[q.behavior.parameters.variableId]=ee,bn({kind:"variableChange",variableId:q.behavior.parameters.variableId,instanceId:q.c.instanceId,selfInstanceId:(U=q.c.instanceId)!==null&&U!==void 0?U:q.c.id}))}}catch(j){E={error:j}}finally{try{Z&&!Z.done&&(C=B.return)&&C.call(B)}finally{if(E)throw E.error}}}function Kp(c,x){var I,E,C,U,L=x.targetMode;if(L==="pointer")return bt({},Dt);if(L==="component"){var W=vt(x.targetComponentId);return W?Ai(W):void 0}if(L==="nearest-team"){var V=Ai(c),Q=[],B=x.team,Z=(C=x.maxRangePx)!==null&&C!==void 0?C:0;try{for(var q=Be(Rn.states),ee=q.next();!ee.done;ee=q.next()){var j=Oe(ee.value,2),re=j[0],pe=j[1],W=vt(re);W&&gi(W)&&Q.push(bt(bt({id:re},Ai(W)),{team:pe.team}))}}catch(be){I={error:be}}finally{try{ee&&!ee.done&&(E=q.return)&&E.call(q)}finally{if(I)throw I.error}}return Em(V,Q,B,Z,(U=c.instanceId)!==null&&U!==void 0?U:c.id)}}function Lg(c){var x,I,E,C,U;try{for(var L=Be(n.gameplay.filter(function(Me){return Me.kind==="steer"})),W=L.next();!W.done;W=L.next()){var V=W.value,Q=b.get(V.componentId),B=V.parameters;if(Q.sceneId===X)try{for(var Z=(E=void 0,Be(Pi(Q))),q=Z.next();!q.done;q=Z.next()){var ee=q.value;if(gi(ee)){var j=Kp(ee,B);if(j){var re=Ai(ee),pe=j.x-re.x,be=j.y-re.y;if(!(B.maxRangePx>0&&Math.hypot(pe,be)>B.maxRangePx)){var xe=Math.atan2(be,pe);B.mode==="flee"?xe+=Math.PI:B.mode==="orbit"&&(xe+=Math.PI/2);var Ee=(U=Rn.headings.get(ee.id))!==null&&U!==void 0?U:xe,he=Am(Ee,xe,B.turnRateDegPerSec*Math.PI/180*c);Rn.headings.set(ee.id,he),Lr(ee,re.x+Math.cos(he)*B.speed*c,re.y+Math.sin(he)*B.speed*c),B.orientToVelocity!==!1&&la(ee,he)}}}}}catch(Me){E={error:Me}}finally{try{q&&!q.done&&(C=Z.return)&&C.call(Z)}finally{if(E)throw E.error}}}}catch(Me){x={error:Me}}finally{try{W&&!W.done&&(I=L.return)&&I.call(L)}finally{if(x)throw x.error}}}function Ff(c,x,I,E){var C;if(ge.length>=128){Vi("Instance budget exhausted");return}var U=b.get(c),L=function(B){return 1+n.components.filter(function(Z){return Z.parentId===B}).reduce(function(Z,q){return Z+L(q.id)},0)};if(Ce.size+L(U.id)>4096){Vi("Runtime node budget exhausted");return}var W="instance."+ ++Re;function V(B,Z){var q,ee,j=B.id===U.id?W:W+":"+B.id,re=bt(bt({},B),{id:j,runtimeId:j,instanceId:W,prototypeId:B.id,prototype:!1,parentId:Z,transform:et([],Oe(B.transform),!1),spawnTime:fe});Ce.set(j,re);try{for(var pe=Be(n.components.filter(function(Ee){return Ee.parentId===B.id})),be=pe.next();!be.done;be=pe.next()){var xe=be.value;V(xe,j)}}catch(Ee){q={error:Ee}}finally{try{be&&!be.done&&(ee=pe.return)&&ee.call(pe)}finally{if(q)throw q.error}}return re}var Q=V(U,void 0);return Q.transform[4]=x,Q.transform[5]=I,E&&(Q.pathStartNode=E.startNode,Q.pathTargetNode=E.targetNode,Q.parentId=(C=n.gameplay.find(function(B){return B.id===E.networkBehaviorId}))===null||C===void 0?void 0:C.componentId),ge.push(Q),oa(Q),Nf(Q),E&&yo(0,!1),Q}function Dg(c,x,I){var E,C,U,L,W,V,Q,B,Z,q,ee,j,re,pe,be,xe,Ee,he,Me,me,Ue,Fe,it,Ve,Ze,At,Nt,Jt,Wt,Ut,Mt,wt,Tt,St,ze;if(++ft>1024){Vi("Action budget exhausted");return}if(c.kind==="add"||c.kind==="set"){var je=K[c.variableId],gt=c.kind==="add"?je+c.value:c.value;if(typeof gt=="number"&&(!Number.isFinite(gt)||Math.abs(gt)>1e12)){Vi("Variable range exceeded");return}K[c.variableId]=gt,je!==gt&&bn({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="setAsset"&&((Z=vt(c.componentId))===null||Z===void 0?void 0:Z.contract)==="native.mesh3d.v1"){var $e=vt(c.componentId),Pt=(q=te.get($e.id))!==null&&q!==void 0?q:{transform:et([],Oe($e.transform),!1),parameters:{}};((ee=Pt.slots)!==null&&ee!==void 0?ee:Pt.slots={})[(j=c.slotId)!==null&&j!==void 0?j:"source"]=c.assetId,te.set($e.id,Pt)}else if(c.kind==="setComponent"||c.kind==="setAsset"){var $e=vt(c.componentId);if(!$e)return;var Pt=(re=te.get($e.id))!==null&&re!==void 0?re:{transform:et([],Oe($e.transform),!1),parameters:{}};c.kind==="setComponent"?Pt.parameters[c.key]=c.valueVariableId?K[c.valueVariableId]:c.value:Pt.assetId=c.assetId,te.set($e.id,Pt),c.kind==="setComponent"&&c.key==="visible"&&c.value===!1&&(rn.release($e.id),ri.cancel($e.id))}else if(c.kind==="resetMatch")$c(c.componentId),bl(c.componentId);else if(c.kind==="clearStrokes")(pe=R.get(c.componentId))===null||pe===void 0||pe.clear(),Gt=Gt.filter(function(yi){return yi.owner!==c.componentId});else if(c.kind==="resetMask"){var $e=vt(c.componentId),Ft=si("erase-mask",c.componentId);$e&&Ft&&Ua($e,Ft).reset()}else if(c.kind==="raycast3d")Al(c);else if(c.kind==="spawnAt3d")El(c);else if(c.kind==="playModelAnimation")Et?.playModelAnimation(c.componentId,c);else if(c.kind==="copyMatchAsset"){var mn=(be=En.get(c.boardId))===null||be===void 0?void 0:be.snapshot().lastMatch,Xt=b.get(c.componentId),vn=mn&&((Ee=(xe=ii.get(c.boardId))===null||xe===void 0?void 0:xe.get(mn.group))===null||Ee===void 0?void 0:Ee.children.find(function(yi){return yi.contract==="native.image.v1"}));if(mn&&vn){var ut=b.get(mn.from),dt=ei(ai(ut),ut.parameters.width/2,ut.parameters.height/2),In=Xt.parentId?ai(b.get(Xt.parentId)):za(),Ii=ei(kr(In),dt.x,dt.y),fi=(he=te.get(Xt.id))!==null&&he!==void 0?he:{transform:et([],Oe(Xt.transform),!1),parameters:{}};fi.transform=et([],Oe(fi.transform),!1),fi.transform[4]=Ii.x-Xt.parameters.width/2,fi.transform[5]=Ii.y-Xt.parameters.height/2,fi.assetId=(Me=vn.assetSlots[0])===null||Me===void 0?void 0:Me.assetId,te.set(Xt.id,fi)}}else if(c.kind==="hintMatch")Qt=void 0,(me=En.get(c.componentId))===null||me===void 0||me.showHint();else if(c.kind==="spawn")Ff(c.prototypeId,c.x,c.y);else if(c.kind==="spawnAt"){var ui=(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):Pr(c.targetComponentId,x,"self"),Gn=(c.at==="other"||c.at==="midpoint")&&x.otherInstanceId!==void 0?vt(x.otherInstanceId):void 0,Xt=c.at==="other"?Gn:ui;if(c.at==="pointer"||(c.at==="midpoint"?ui&&Gn:Xt))for(var hi=ui?Ai(ui):void 0,oi=Gn?Ai(Gn):void 0,dt=c.at==="pointer"?Dt:c.at==="midpoint"?{x:(hi.x+oi.x)/2,y:(hi.y+oi.y)/2}:Ai(Xt),Kn=b.get(c.prototypeId),Li=Math.max(0,Math.min(16,Math.floor(c.countVariableId?Number(K[c.countVariableId]):(Fe=c.count)!==null&&Fe!==void 0?Fe:1))),pi=0;pi<Li;pi++){var ca=c.jitterX?(Rn.rng.next()*2-1)*c.jitterX:0,Qi=c.jitterY?(Rn.rng.next()*2-1)*c.jitterY:0;Ff(c.prototypeId,dt.x+c.offsetX+ca-Kn.parameters.width/2,dt.y+c.offsetY+Qi-Kn.parameters.height/2)}}else if(c.kind==="random"){var je=K[c.variableId],gt=Rn.rng.between(c.min,c.max,c.integer===!0);K[c.variableId]=gt,je!==gt&&bn({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="modifyInstanceState"){var $e=c.target==="component"?vt(c.componentId):Pr(c.componentId,x,c.target);$e&&Jc($e,c.field,c.op,c.variableId?K[c.variableId]:c.value)}else if(c.kind==="launchToward"){var ut=b.get(c.componentId),Gi=Pi(ut),dn=(it=x.selfInstanceId)!==null&&it!==void 0?it:x.instanceId,$e=ut.prototype?(Ve=Gi.find(function(Sn){return Sn.instanceId===dn||Sn.id===dn}))!==null&&Ve!==void 0?Ve:Gi[Gi.length-1]:(Ze=Pr(c.componentId,x,"self"))!==null&&Ze!==void 0?Ze:vt(c.componentId),Ft=si("physics-body",c.componentId),sn=$e&&Na($e,Ft);if(!sn)return;var Ot=void 0;if(c.targetMode==="angle-variable")Ot=Number(K[c.angleVariableId])*Math.PI/180;else{var Xt=Kp($e,c);if(!Xt)return;var dt=Ai($e);Ot=Math.atan2(Xt.y-dt.y,Xt.x-dt.x)}var Ci=Number(c.speedVariableId?K[c.speedVariableId]:c.speed);if(!Number.isFinite(Ci)){Vi("Launch speed invalid");return}sn.vx=Math.cos(Ot)*Ci,sn.vy=Math.sin(Ot)*Ci,sn.atRest=!1,sn.restElapsed=0,sn.captured=!1,sn.exited=!1,c.orientToVelocity!==!1&&la($e,Ot),bn(sr("launch",$e))}else if(c.kind==="moveToComponent"){var Ri=b.get(c.targetComponentId),$e=Pr(c.componentId,x,(At=c.target)!==null&&At!==void 0?At:"self"),Xt=Ri&&sa(Ri)?(Nt=Pr(c.targetComponentId,x,c.target==="other"?"self":"other"))!==null&&Nt!==void 0?Nt:Pi(Ri)[0]:vt(c.targetComponentId);$e&&Xt&&Hs($e,Ai(Xt),c.seconds)}else if(c.kind==="returnToOrigin"){var $e=Pr(c.componentId,x,"self"),Zr=$e&&Wn.get($e.id);$e&&Zr&&Hs($e,Zr,c.seconds)}else if(c.kind==="spawnOnPath")Ff(c.prototypeId,0,0,{startNode:c.startNode,targetNode:c.targetNode,networkBehaviorId:c.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(c.kind)){var ti=b.get(c.componentId),Yi=x.instanceId?et([],Oe(Ce.values()),!1).filter(function(qn){return qn.instanceId===x.instanceId&&qn.prototypeId===ti.id}):Pi(ti),Ft=si("physics-body",ti.id);try{for(var ua=Be(Yi),Fa=ua.next();!Fa.done;Fa=ua.next()){var $e=Fa.value,sn=Na($e,Ft);c.kind==="setVelocity"?(sn.vx=c.vxVariableId?K[c.vxVariableId]:c.vx,sn.vy=c.vyVariableId?K[c.vyVariableId]:c.vy):c.kind==="applyImpulse"?(sn.vx+=c.vxVariableId?K[c.vxVariableId]:c.ix,sn.vy+=c.vyVariableId?K[c.vyVariableId]:c.iy):(sn.vx=0,sn.vy=0,sn.atRest=!0),sn.captured=!1,sn.exited=!1,sn.restElapsed=0,c.kind!=="stopBody"&&(sn.atRest=!1)}}catch(qn){E={error:qn}}finally{try{Fa&&!Fa.done&&(C=ua.return)&&C.call(ua)}finally{if(E)throw E.error}}}else if(c.kind==="setPosition"){var ns=b.get(c.componentId),Yi=x.instanceId?et([],Oe(Ce.values()),!1).filter(function(Mn){return Mn.instanceId===x.instanceId&&Mn.prototypeId===ns.id}):Pi(ns),Ft=si("physics-body",ns.id);try{for(var Jr=Be(Yi),br=Jr.next();!br.done;br=Jr.next()){var $e=br.value,sn=Na($e,Ft);sn.x=c.xVariableId?K[c.xVariableId]:c.x,sn.y=c.yVariableId?K[c.yVariableId]:c.y,sn.vx=0,sn.vy=0,sn.captured=!1,sn.exited=!1,sn.atRest=!0,Lr($e,sn.x,sn.y)}}catch(Mn){U={error:Mn}}finally{try{br&&!br.done&&(L=Jr.return)&&L.call(Jr)}finally{if(U)throw U.error}}}else if(c.kind==="setPathEdge")(Jt=zn.get(c.behaviorId))===null||Jt===void 0||Jt.setEdge(c.edgeId,c.enabled,c.cost);else if(c.kind==="setPathGate")(Ut=zn.get((Wt=n.gameplay.find(function(yi){return yi.id===c.behaviorId}))===null||Wt===void 0?void 0:Wt.parameters.networkBehaviorId))===null||Ut===void 0||Ut.setGate(c.behaviorId,c.mode,c.holdSeconds);else if(c.kind==="setPathTarget"){var Sa=b.get(c.componentId),Ft=si("path-agent",Sa.id),da=zn.get(Ft.parameters.networkBehaviorId);try{for(var Oa=Be(x.instanceId?et([],Oe(Ce.values()),!1).filter(function(qn){return qn.instanceId===x.instanceId&&qn.prototypeId===Sa.id}):Pi(Sa)),or=Oa.next();!or.done;or=Oa.next()){var $e=or.value;$e.pathTargetNode=c.targetNode,da?.setTarget($e.id,c.targetNode)}}catch(qn){W={error:qn}}finally{try{or&&!or.done&&(V=Oa.return)&&V.call(Oa)}finally{if(W)throw W.error}}}else if(c.kind==="compute"){var Oi=Number(K[c.variableId]),qi=c.operandVariableId!==void 0?Number(K[c.operandVariableId]):c.value;if(["div","mod"].includes(c.op)&&qi===0){Vi("Division by zero");return}var gt={add:function(){return Oi+qi},sub:function(){return Oi-qi},mul:function(){return Oi*qi},div:function(){return qi===0?Oi:Oi/qi},mod:function(){return qi===0?Oi:Oi%qi},min:function(){return Math.min(Oi,qi)},max:function(){return Math.max(Oi,qi)},set:function(){return qi},floor:function(){return Math.floor(Oi)},ceil:function(){return Math.ceil(Oi)},abs:function(){return Math.abs(Oi)},clamp:function(){return Math.max(c.min,Math.min(c.max,Oi))}}[c.op]();if(c.round&&(gt=Math.round(gt)),!Number.isFinite(gt)||Math.abs(gt)>1e12){Vi("Variable range exceeded");return}var je=K[c.variableId];K[c.variableId]=gt,je!==gt&&bn({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="despawn"){var ui=(Mt=x.selfInstanceId)!==null&&Mt!==void 0?Mt:x.instanceId;c.target==="other"?ir(x.otherInstanceId):c.target==="both"?(ir(ui),ir(x.otherInstanceId)):ir(ui)}else if(c.kind==="changeScene")c.delaySeconds>0?c.sceneId!==X&&(w??(w={sceneId:c.sceneId,at:fe+c.delaySeconds})):J=c.sceneId;else if(c.kind==="restart")(wt=_?.notifyGameRetry)===null||wt===void 0||wt.call(_),J="__restart";else if(c.kind==="cameraShake")F?.matches||(Te={intensity:c.intensity,seconds:c.seconds,elapsed:0});else if(c.kind==="screenFlash")Je.push({color:c.color,opacity:c.opacity,seconds:c.seconds,elapsed:0}),Je.length>8&&Je.shift();else if(c.kind==="floatingText"){var ba=b.get(c.componentId),ut=x.instanceId?(Tt=et([],Oe(Ce.values()),!1).find(function(Mn){return Mn.instanceId===x.instanceId&&Mn.prototypeId===c.componentId}))!==null&&Tt!==void 0?Tt:ba:(St=vt(c.componentId))!==null&&St!==void 0?St:ba,Xt=ut?.sceneId===X?ut:ba;if(Xt){var dt=void 0;if(Xt.contract==="native.mesh3d.v1"&&(dt=Gs(Xt.id)),!dt){var Bi=Yt(Xt);dt=ei(ai(Xt),Bi.width/2,Bi.height/2)}Xe.push({x:dt.x,y:dt.y,text:c.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Sn,vr){var Nr;return String((Nr=K[vr])!==null&&Nr!==void 0?Nr:"")}),color:c.color,fontSize:c.fontSize,risePx:c.risePx,seconds:c.seconds,elapsed:0}),Xe.length>32&&Xe.shift()}}else if(c.kind==="store")x.kind==="click"&&x.pointerId!==void 0&&!Ae&&(Ae={pointerId:x.pointerId,targetId:x.targetId,condition:I},(ze=e.setPointerCapture)===null||ze===void 0||ze.call(e,x.pointerId));else if(c.behaviorId){var wn=n.gameplay.find(function(yi){return yi.id===c.behaviorId});if(c.kind==="playAudio")$p(wn);else if(c.kind==="animate"){var wa=b.get(wn.componentId),Yi=sa(wa)?et([],Oe(Ce.values()),!1).filter(function(qn){return qn.prototypeId===wa.id&&(!x.instanceId||qn.instanceId===x.instanceId)}):[wa],fa=function(qn){var Mn=wn.id+":"+qn.id;Se=Se.filter(function(vr){return vr.id!==Mn});var Sn=bt({},wn.parameters);Sn.fromCurrent&&(Sn.from=Sn.property==="opacity"?Yt(qn).opacity:Nn(qn)[Sn.property==="x"?4:5]),Se.push(bt(bt({},wn),{parameters:Sn,id:Mn,behaviorId:wn.id,targetId:qn.id,elapsed:0,baseTransform:et([],Oe(qn.transform),!1)}))};try{for(var $r=Be(Yi),Zi=$r.next();!Zi.done;Zi=$r.next()){var Xt=Zi.value;fa(Xt)}}catch(qn){Q={error:qn}}finally{try{Zi&&!Zi.done&&(B=$r.return)&&B.call($r)}finally{if(Q)throw Q.error}}}else c.kind==="stopAnimation"?Se=Se.filter(function(yi){return yi.behaviorId!==wn.id}):c.kind==="emit"&&Ng(wn,x)}}function Ng(c,x){var I,E,C,U,L,W,V,Q,B,Z=c.parameters,q=Z.shape==="pixel-confetti",ee=Z.shape==="confetti",j=q||ee;if(!(j&&F?.matches)){if(se.length+Z.count>256){Vi("Particle budget exhausted");return}if(q&&Z.coverage==="screen"){se.push.apply(se,et([],Oe(dg(Z)),!1));return}if(ee&&Z.coverage==="screen"){se.push.apply(se,et([],Oe(hg(Z)),!1));return}var re=b.get(c.componentId),pe=x.instanceId&&(I=et([],Oe(Ce.values()),!1).find(function(Ut){return Ut.instanceId===x.instanceId&&Ut.prototypeId===re.id}))!==null&&I!==void 0?I:re;if(Z.origin==="contact-3d"){if(F?.matches)return;var be=Bs(pe);if(!be)return;for(var xe=ag(pe,vt,Yt,Ht),Ee=[Z.color,Z.color2,Z.color3].filter(Boolean),he=vu(mu(pe.id+":"+fe.toFixed(3))),Me=((E=Z.spread)!==null&&E!==void 0?E:360)*Math.PI/180,me=((C=Z.direction)!==null&&C!==void 0?C:-90)*Math.PI/180,Ue=0;Ue<Z.count;Ue++){var Fe=me+Me*(he.next()-.5),it=Z.speed/100*he.between(.42,1.1);se.push(bt(bt({},xe),{stageId:be.id,shape:"contact-3d",confetti:ee,age:0,vx:Math.cos(Fe)*it,vy:he.between(.55,.95)*it,vz:Math.sin(Fe)*it,life:((U=Z.lifetime)!==null&&U!==void 0?U:.5)*he.between(.7,1),gravity:((L=Z.gravity)!==null&&L!==void 0?L:300)/100,color:Ee[Ue%Ee.length],size:he.between(.024,.058),spinX:he.between(-13,13),spinZ:he.between(-17,17)}))}return}for(var Ve=Nn(pe),Ze,At=vt(pe.parentId);At;At=vt(At.parentId)){if(j&&At.contract==="native.group.v1"&&Yt(At).clip){Ze=At.id;break}Ve=Io(Nn(At),Ve)}var Nt=Yt(pe),Jt=Z.origin==="anchor"?ei(Ve,0,0):j||Z.origin==="center"?ei(Ve,Nt.width/2,Nt.height/2):{x:Ve[4]+pe.parameters.width/2,y:Ve[5]+pe.parameters.height/2};if(q){se.push.apply(se,et([],Oe(Vp(Z,Jt,Ze)),!1));return}if(ee){se.push.apply(se,et([],Oe(Gp(Z,Jt,Ze)),!1));return}for(var Wt=vu(mu(pe.id+":"+fe.toFixed(3))),Ue=0;Ue<Z.count;Ue++){var Fe=-Math.PI/2+((Ue+Wt.next())/Z.count-.5)*((W=Z.spread)!==null&&W!==void 0?W:360)*Math.PI/180,it=Z.speed*Wt.between(.5,.95);se.push(bt(bt({},Jt),{vx:Math.cos(Fe)*it,vy:Math.sin(Fe)*it,life:(V=Z.lifetime)!==null&&V!==void 0?V:.7,gravity:(Q=Z.gravity)!==null&&Q!==void 0?Q:250,color:Z.color,shape:(B=Z.shape)!==null&&B!==void 0?B:"circle"}))}}}function Qp(c){var x,I;if(c==="__restart"){Mo();return}if(c!==X){w=void 0;var E=X;Ni(),X=c,ve.clear(),rn.clear(),Wn.clear(),Ei.clear(),ci.clear(),R.clear(),Gt=[],De=[],ce.clear(),we.clear(),Qt=void 0,ge=[],se=[],Xe=[],Je=[],Te=void 0,ot=!1,yt=0,Ce.clear(),kn.clear(),Un.clear(),Ht.clear(),an.clear(),Pn.clear(),An.clear(),es=0,Et?.reset(),Fn.clear(),Jn.clear(),de=void 0,wl(),Pe=Pe.filter(function(W){return W.kind==="variableChange"}),te.clear(),nn=void 0;try{for(var C=Be(En.values()),U=C.next();!U.done;U=C.next()){var L=U.value;L.reset()}}catch(W){x={error:W}}finally{try{U&&!U.done&&(I=C.return)&&I.call(C)}finally{if(x)throw x.error}}le.clear(),ae.clear(),at.clear(),Se=[],ar(),A.clear(),ue=void 0,hn=void 0,xo(),zs(),yo(0,!1),Nf(),Tl(0),bn({kind:"sceneExit",sceneId:E}),bn({kind:"sceneEnter",sceneId:X})}}function Dr(){for(var c=function(){var x,I,E,C,U=Pe.shift();qe++;var L=function(j){return j===void 0||!!vt(j)||et([],Oe(Ce.values()),!1).some(function(re){return re.instanceId===j})};if(!L(U.selfInstanceId)||!L(U.otherInstanceId)||["contactBegin","boundaryExit"].includes(U.kind)&&U.instanceId&&!Ce.has(U.instanceId))return"continue";try{for(var W=(x=void 0,Be(n.eventBindings)),V=W.next();!V.done;V=W.next()){var Q=V.value;if(Object.entries(D.get(Q.eventId)).every(function(j){var re=Oe(j,2),pe=re[0],be=re[1];return pe==="id"||U[pe]===be})&&vo(Q.condition,U)){try{for(var B=(E=void 0,Be(Q.actions)),Z=B.next();!Z.done;Z=B.next()){var q=Z.value;if(ft>=1024||tt)break;Dg(q,U,Q.condition)}}catch(j){E={error:j}}finally{try{Z&&!Z.done&&(C=B.return)&&C.call(B)}finally{if(E)throw E.error}}if(J)break}}}catch(j){x={error:j}}finally{try{V&&!V.done&&(I=W.return)&&I.call(W)}finally{if(x)throw x.error}}if(J){var ee=J;J=void 0,Qp(ee)}};Pe.length&&!tt&&qe<256&&ft<1024;)c();Pe.length&&Vi("Event/action budget exhausted")}function ai(c){return Io(c.parentId?ai(vt(c.parentId)):za(),Nn(c))}var ei=function(c,x,I){return{x:c[0]*x+c[2]*I+c[4],y:c[1]*x+c[3]*I+c[5]}};function Mr(c,x){var I=Yt(c),E=[[0,0],[I.width,0],[I.width,I.height],[0,I.height]].map(function(C){var U=Oe(C,2),L=U[0],W=U[1];return ei(x,L,W)});return{left:Math.min.apply(Math,et([],Oe(E.map(function(C){return C.x})),!1)),right:Math.max.apply(Math,et([],Oe(E.map(function(C){return C.x})),!1)),top:Math.min.apply(Math,et([],Oe(E.map(function(C){return C.y})),!1)),bottom:Math.max.apply(Math,et([],Oe(E.map(function(C){return C.y})),!1))}}function gi(c){return Yt(c).visible&&Yt(c).opacity>0&&(!c.parentId||gi(vt(c.parentId)))}function jp(c,x){for(var I=Yt(c),E=ai(c),C=Math.min(I.width,I.height)/2,U=x==="circle"?Array.from({length:32},function(V,Q){return ei(E,I.width/2+Math.cos(Q*Math.PI/16)*C,I.height/2+Math.sin(Q*Math.PI/16)*C)}):[[0,0],[I.width,0],[I.width,I.height],[0,I.height]].map(function(V){var Q=Oe(V,2),B=Q[0],Z=Q[1];return ei(E,B,Z)}),L=c.parentId?vt(c.parentId):void 0,W=function(){var V=Yt(L);if(L.contract==="native.group.v1"&&V.clip){for(var Q=ai(L),B=[[0,0],[V.width,0],[V.width,V.height],[0,V.height]].map(function(re){var pe=Oe(re,2),be=pe[0],xe=pe[1];return ei(Q,be,xe)}),Z=0,q=0;q<4;q++)Z+=B[q].x*B[(q+1)%4].y-B[(q+1)%4].x*B[q].y;for(var ee=Z>=0?1:-1,j=function(re){var pe,be,xe=B[re],Ee=B[(re+1)%4],he=function(Nt){return ee*((Ee.x-xe.x)*(Nt.y-xe.y)-(Ee.y-xe.y)*(Nt.x-xe.x))},Me=U;U=[];var me=Me[Me.length-1],Ue=he(me);try{for(var Fe=(pe=void 0,Be(Me)),it=Fe.next();!it.done;it=Fe.next()){var Ve=it.value,Ze=he(Ve);if(Ze>=0!=Ue>=0){var At=Ue/(Ue-Ze);U.push({x:me.x+(Ve.x-me.x)*At,y:me.y+(Ve.y-me.y)*At})}Ze>=0&&U.push(Ve),me=Ve,Ue=Ze}}catch(Nt){pe={error:Nt}}finally{try{it&&!it.done&&(be=Fe.return)&&be.call(Fe)}finally{if(pe)throw pe.error}}},q=0;q<4&&U.length;q++)j(q)}L=L.parentId?vt(L.parentId):void 0};L;)W();return U}function Ug(c,x){var I,E,C,U,L,W;if(c.length<3||x.length<3)return!1;try{for(var V=Be([c,x]),Q=V.next();!Q.done;Q=V.next())for(var B=Q.value,Z=0;Z<B.length;Z++){var q=B[Z],ee=B[(Z+1)%B.length],j=q.y-ee.y,re=ee.x-q.x,pe=1/0,be=-1/0,xe=1/0,Ee=-1/0;try{for(var he=(C=void 0,Be(c)),Me=he.next();!Me.done;Me=he.next()){var me=Me.value,Ue=me.x*j+me.y*re;pe=Math.min(pe,Ue),be=Math.max(be,Ue)}}catch(Ve){C={error:Ve}}finally{try{Me&&!Me.done&&(U=he.return)&&U.call(he)}finally{if(C)throw C.error}}try{for(var Fe=(L=void 0,Be(x)),it=Fe.next();!it.done;it=Fe.next()){var me=it.value,Ue=me.x*j+me.y*re;xe=Math.min(xe,Ue),Ee=Math.max(Ee,Ue)}}catch(Ve){L={error:Ve}}finally{try{it&&!it.done&&(W=Fe.return)&&W.call(Fe)}finally{if(L)throw L.error}}if(be<xe||Ee<pe)return!1}}catch(Ve){I={error:Ve}}finally{try{Q&&!Q.done&&(E=V.return)&&E.call(V)}finally{if(I)throw I.error}}return!0}function Fg(c){var x,I,E,C,U=H();try{for(var L=Be(ve.values()),W=L.next();!W.done;W=L.next()){var V=W.value,Q=V.behavior.parameters;if(!(!Q.moveComponentId||V.magnitude<=0)){var B=vt(Q.moveComponentId);if(!(!B||!gi(B))){var Z=(E=Q.moveSpeed)!==null&&E!==void 0?E:220,q=si("physics-body",(C=B.prototypeId)!==null&&C!==void 0?C:B.id);if(q&&q.parameters.mode==="dynamic"){var ee=Na(B,q);ee.vx=V.nx*Z,ee.vy=V.ny*Z,ee.atRest=!1,ee.restElapsed=0}else{var j=Ai(B),re=Yt(B),pe=j.x+V.nx*Z*c,be=j.y+V.ny*Z*c;tm(B)||(pe=Math.max(re.width/2,Math.min(U.width-re.width/2,pe)),be=Math.max(re.height/2,Math.min(U.height-re.height/2,be))),Lr(B,pe,be)}Q.orientToMove&&la(B,Math.atan2(V.ny,V.nx))}}}}catch(xe){x={error:xe}}finally{try{W&&!W.done&&(I=L.return)&&I.call(L)}finally{if(x)throw x.error}}}function em(c){var x,I,E,C,U,L,W,V,Q,B,Z,q,ee,j,re,pe,be,xe,Ee,he,Me,me,Ue,Fe,it,Ve,Ze,At,Nt,Jt,Wt,Ut,Mt=H();fe+=c,w&&fe>=w.at&&Qp(w.sceneId),$g(c),Pg(c),Fg(c),Lg(c),jc();try{for(var wt=Be($t),Tt=wt.next();!Tt.done;Tt=wt.next()){var St=Oe(Tt.value,2),ze=St[0],je=St[1];!je.held&&fe-((Ue=je.releasedAt)!==null&&Ue!==void 0?Ue:fe)>=je.behavior.springBackSeconds&&$t.delete(ze)}}catch(cn){x={error:cn}}finally{try{Tt&&!Tt.done&&(I=wt.return)&&I.call(wt)}finally{if(x)throw x.error}}Te&&(Te.elapsed+=c,Te.elapsed>=Te.seconds&&(Te=void 0));try{for(var gt=Be(Je),$e=gt.next();!$e.done;$e=gt.next()){var Pt=$e.value;Pt.elapsed+=c}}catch(cn){E={error:cn}}finally{try{$e&&!$e.done&&(C=gt.return)&&C.call(gt)}finally{if(E)throw E.error}}Je=Je.filter(function(cn){return cn.elapsed<cn.seconds});try{for(var Ft=Be(Xe),mn=Ft.next();!mn.done;mn=Ft.next()){var Xt=mn.value;Xt.elapsed+=c}}catch(cn){U={error:cn}}finally{try{mn&&!mn.done&&(L=Ft.return)&&L.call(Ft)}finally{if(U)throw U.error}}Xe=Xe.filter(function(cn){return cn.elapsed<cn.seconds});try{for(var vn=Be(En),ut=vn.next();!ut.done;ut=vn.next()){var dt=Oe(ut.value,2),ze=dt[0],In=dt[1];b.get(ze).sceneId===X&&gi(b.get(ze))&&In.tick(c)}}catch(cn){W={error:cn}}finally{try{ut&&!ut.done&&(V=vn.return)&&V.call(vn)}finally{if(W)throw W.error}}var Ii=function(cn){var xi,Ji,ji=b.get(cn.componentId);if(ji.sceneId!==X)return"continue";var ki=sa(ji)?et([],Oe(Ce.values()),!1).filter(function(Zs){return Zs.prototypeId===ji.id}):[ji];try{for(var gr=(xi=void 0,Be(ki)),bi=gr.next();!bi.done;bi=gr.next()){var Hi=bi.value,xs=cn.id+":"+Hi.id;if(cn.kind==="motion"){var Br=(Fe=te.get(Hi.id))!==null&&Fe!==void 0?Fe:{transform:et([],Oe(Hi.transform),!1),parameters:{}},pa=(it=Br.velocity)!==null&&it!==void 0?it:{x:cn.parameters.vx,y:cn.parameters.vy};pa.y+=cn.parameters.gravity*c,Br.transform[4]+=pa.x*c,Br.transform[5]+=pa.y*c,Br.velocity=pa,te.set(Hi.id,Br),Hi.prototypeId&&(Hi.transform=Br.transform);var is=ai(Hi);(is[5]>Mt.height||is[4]<-300||is[4]>Mt.width+300)&&(Br.exited||(Br.exited=!0,bn({kind:"boundaryExit",componentId:ji.id,instanceId:Hi.instanceId})))}else if(cn.kind==="timer"){var qs=((Ve=at.get(xs))!==null&&Ve!==void 0?Ve:0)+c;at.set(xs,qs),qs>=cn.parameters.seconds&&qs-c<cn.parameters.seconds&&(bn(bt({kind:"timer",behaviorId:cn.id,componentId:ji.id},Hi.instanceId?{instanceId:Hi.instanceId,selfInstanceId:Hi.instanceId}:{})),cn.parameters.repeat&&at.set(xs,qs-cn.parameters.seconds))}}}catch(Zs){xi={error:Zs}}finally{try{bi&&!bi.done&&(Ji=gr.return)&&Ji.call(gr)}finally{if(xi)throw xi.error}}};try{for(var fi=Be(n.gameplay),ui=fi.next();!ui.done;ui=fi.next()){var Gn=ui.value;Ii(Gn)}}catch(cn){Q={error:cn}}finally{try{ui&&!ui.done&&(B=fi.return)&&B.call(fi)}finally{if(Q)throw Q.error}}go(c),Cf(c),yo(c),Tl(c);var hi=[],oi=function(cn){var xi,Ji,ji=b.get(cn.componentId);if(ji.sceneId!==X)return"continue";try{for(var ki=(xi=void 0,Be(sa(ji)?et([],Oe(Ce.values()),!1).filter(function(Hi){return Hi.prototypeId===ji.id}):[ji])),gr=ki.next();!gr.done;gr=ki.next()){var bi=gr.value;if(gi(bi)){if(hi.length>=256){Vi("Collider budget exhausted");break}hi.push({b:cn,c:bi,box:Mr(bi,ai(bi)),polygon:jp(bi,cn.parameters.shape)})}}}catch(Hi){xi={error:Hi}}finally{try{gr&&!gr.done&&(Ji=ki.return)&&Ji.call(ki)}finally{if(xi)throw xi.error}}};try{for(var Kn=Be(n.gameplay.filter(function(cn){return cn.kind==="collider"})),Li=Kn.next();!Li.done;Li=Kn.next()){var Gn=Li.value;oi(Gn)}}catch(cn){Z={error:cn}}finally{try{Li&&!Li.done&&(q=Kn.return)&&q.call(Kn)}finally{if(Z)throw Z.error}}var pi=new Set,ca=new Map,Qi=function(cn,xi,Ji){var ji,ki,gr;((ji=xi.c.prototypeId)!==null&&ji!==void 0?ji:xi.c.id)===((ki=Ji.c.prototypeId)!==null&&ki!==void 0?ki:Ji.c.id)&&xi.c.id>Ji.c.id||bn(bt(bt({},sr(cn,xi.c,Ji.c)),{instanceId:(gr=xi.c.instanceId)!==null&&gr!==void 0?gr:Ji.c.instanceId}))},Gi=0;e:for(var dn=0;dn<hi.length;dn++)for(var Gn=dn+1;Gn<hi.length;Gn++){var sn=hi[dn],Ot=hi[Gn];if(!(sn.c.instanceId&&sn.c.instanceId===Ot.c.instanceId)){var Ci=sn.box,Ri=Ot.box,Zr=Ci.left<Ri.right&&Ci.right>Ri.left&&Ci.top<Ri.bottom&&Ci.bottom>Ri.top;if(Zr){if(++Gi>4096){Vi("Collision budget exhausted");break e}Zr=Ug(sn.polygon,Ot.polygon)}if(Zr){var ti=[sn.c.id,Ot.c.id].sort().join("|");if(pi.add(ti),ca.set(ti,[sn,Ot]),!le.has(ti))try{for(var Yi=(ee=void 0,Be([[sn,Ot],[Ot,sn]])),ua=Yi.next();!ua.done;ua=Yi.next()){var Fa=Oe(ua.value,2),ns=Fa[0],Jr=Fa[1];Qi("contactBegin",ns,Jr)}}catch(xi){ee={error:xi}}finally{try{ua&&!ua.done&&(j=Yi.return)&&j.call(Yi)}finally{if(ee)throw ee.error}}}}}try{for(var br=Be(ae),Sa=br.next();!Sa.done;Sa=br.next()){var da=Oe(Sa.value,2),ti=da[0],Oa=Oe(da[1],2),sn=Oa[0],Ot=Oa[1];if(!pi.has(ti))try{for(var or=(be=void 0,Be([[sn,Ot],[Ot,sn]])),Oi=or.next();!Oi.done;Oi=or.next()){var qi=Oe(Oi.value,2),ns=qi[0],Jr=qi[1];Qi("contactEnd",ns,Jr)}}catch(ji){be={error:ji}}finally{try{Oi&&!Oi.done&&(xe=or.return)&&xe.call(or)}finally{if(be)throw be.error}}}}catch(cn){re={error:cn}}finally{try{Sa&&!Sa.done&&(pe=br.return)&&pe.call(br)}finally{if(re)throw re.error}}le=pi,ae=ca;try{for(var ba=Be(Se),Bi=ba.next();!Bi.done;Bi=ba.next()){var dn=Bi.value;dn.elapsed+=c;var wn=dn.parameters,wa=(Ze=wn.delay)!==null&&Ze!==void 0?Ze:0,fa=dn.elapsed-wa;if(!(fa<0)){var $r=fa/wn.seconds,Zi=wn.loop?$r%1:Math.min(1,$r),yi=(At=wn.easing)!==null&&At!==void 0?At:"ease-out",qn=Zi;wn.loop&&yi==="ease-in-out"?qn=.5-.5*Math.cos(Zi*Math.PI*2):yi==="ease-out"?qn=1-Math.pow(1-Zi,3):yi==="ease-in"?qn=Math.pow(Zi,3):yi==="ease-in-out"?qn=Zi<.5?4*Math.pow(Zi,3):1-Math.pow(-2*Zi+2,3)/2:yi==="back-out"&&(qn=1+2.70158*Math.pow(Zi-1,3)+1.70158*Math.pow(Zi-1,2));var Mn=wn.from+(wn.to-wn.from)*qn,Sn=vt((Nt=dn.targetId)!==null&&Nt!==void 0?Nt:dn.componentId);if(Sn){var vr=(Jt=te.get(Sn.id))!==null&&Jt!==void 0?Jt:{transform:et([],Oe(Sn.transform),!1),parameters:{}},Nr=(Wt=dn.baseTransform)!==null&&Wt!==void 0?Wt:Sn.transform;if(wn.property==="opacity")vr.parameters.opacity=Math.max(0,Math.min(1,Mn));else if(["scale","scaleX","scaleY","rotation"].includes(wn.property)){(Ut=vr.animationAxes)!==null&&Ut!==void 0||(vr.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),vr.animationAxes[wn.property]=Mn;var Ta=vr.animationAxes,ys=Ta.rotation*Math.PI/180,wo=Math.cos(ys),Xs=Math.sin(ys),To=Ta.scale*Ta.scaleX,Eo=Ta.scale*Ta.scaleY;vr.transform[0]=(Nr[0]*wo+Nr[2]*Xs)*To,vr.transform[1]=(Nr[1]*wo+Nr[3]*Xs)*To,vr.transform[2]=(-Nr[0]*Xs+Nr[2]*wo)*Eo,vr.transform[3]=(-Nr[1]*Xs+Nr[3]*wo)*Eo}else vr.transform[wn.property==="x"?4:5]=Mn;te.set(Sn.id,vr),wn.loop&&fa>=wn.seconds&&(dn.elapsed=wa+fa%wn.seconds)}}}}catch(cn){Ee={error:cn}}finally{try{Bi&&!Bi.done&&(he=ba.return)&&he.call(ba)}finally{if(Ee)throw Ee.error}}Se=Se.filter(function(cn){var xi,Ji;return vt((xi=cn.targetId)!==null&&xi!==void 0?xi:cn.componentId)&&(cn.elapsed<cn.parameters.seconds+((Ji=cn.parameters.delay)!==null&&Ji!==void 0?Ji:0)||cn.parameters.loop)});try{for(var Ys=Be(se),ha=Ys.next();!ha.done;ha=Ys.next()){var wn=ha.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(cn){Me={error:cn}}finally{try{ha&&!ha.done&&(me=Ys.return)&&me.call(Ys)}finally{if(Me)throw Me.error}}se=se.filter(function(cn){var xi;return cn.life>((xi=cn.age)!==null&&xi!==void 0?xi:0)}),Dr()}function tu(c,x){var I,E,C;if(g.beginPath(),c.contract==="native.ellipse.v1")g.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(q,ee){({M:function(){return g.moveTo.apply(g,et([],Oe(ee),!1))},L:function(){return g.lineTo.apply(g,et([],Oe(ee),!1))},C:function(){return g.bezierCurveTo.apply(g,et([],Oe(ee),!1))},Q:function(){return g.quadraticCurveTo.apply(g,et([],Oe(ee),!1))},Z:function(){return g.closePath()}})[q]()};try{for(var L=Be(x.commands),W=L.next();!W.done;W=L.next()){var V=Oe(W.value),Q=V[0],B=V.slice(1);U(Q,B)}}catch(q){I={error:q}}finally{try{W&&!W.done&&(E=L.return)&&E.call(L)}finally{if(I)throw I.error}}}else{var Z=Math.min((C=x.radius)!==null&&C!==void 0?C:0,x.width/2,x.height/2);typeof g.roundRect=="function"?g.roundRect(0,0,x.width,x.height,Z):(g.moveTo(Z,0),g.arcTo(x.width,0,x.width,x.height,Z),g.arcTo(x.width,x.height,0,x.height,Z),g.arcTo(0,x.height,0,0,Z),g.arcTo(0,0,x.width,0,Z),g.closePath())}}function Og(c,x,I){var E,C,U,L=(E=te.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,fe-((C=c.spawnTime)!==null&&C!==void 0?C:0))*x.frameRate)%x.frameCount;var W=(U=c.runtimeId)!==null&&U!==void 0?U:c.id,V=pt.get(W);if(!V)return pt.set(W,{x:I[4],y:I[5],phase:0,lastMove:-1/0,frame:0}),0;var Q=Math.hypot(I[4]-V.x,I[5]-V.y)>.3;if(Q){var B=fe-V.lastMove;V.phase=Number.isFinite(B)&&B<.25?V.phase+Math.min(B,.12)*x.frameRate:0,V.lastMove=fe}return V.x=I[4],V.y=I[5],fe-V.lastMove>.11&&(V.phase=0),V.frame=Math.floor(V.phase)%x.frameCount,V.frame}var Cl=!1,bo={width:390,height:700},di,Of=new Set;function nu(c){var x,I;c!==Cl&&(c?(g.save(),g.beginPath(),g.rect((x=bo.left)!==null&&x!==void 0?x:0,(I=bo.top)!==null&&I!==void 0?I:0,bo.width,bo.height),g.clip(),Cl=!0):(g.restore(),Cl=!1))}function Ws(c,x,I,E,C){var U,L,W,V,Q,B,Z,q,ee,j,re,pe,be,xe,Ee,he,Me;if(x===void 0&&(x=za()),I===void 0&&(I=[]),C===void 0&&(C=!1),c.contract!=="native.mesh3d.v1"){var me=Yt(c),Ue=si("erase-mask",(re=c.prototypeId)!==null&&re!==void 0?re:c.id);if(!(!me.visible||me.opacity<=0)){var Fe=Io(x,Nn(c));if(Of.has(c.id)){ye.push({c,m:Fe,clips:I,instance:E??c.prototypeId});try{for(var it=Be(_a(c.id)),Ve=it.next();!Ve.done;Ve=it.next()){var Ze=Ve.value;Ws(Ze,Fe,I,E??c.prototypeId,!0)}}catch(Ri){U={error:Ri}}finally{try{Ve&&!Ve.done&&(L=it.return)&&L.call(it)}finally{if(U)throw U.error}}return}if(c.contract==="native.stage3d.v1"&&Et&&di&&Xn.has(c.id)){nu(!1);var At=Et.renderStage(c,g,di.pw,di.ph,di.w,di.h,{time:fe,ambientTime:Ne,propsOf:Yt,bodies3d:Ht,fpsPose:An.get(c.id),instances3d:Yr(c.id),contactParticles:F?.matches?[]:se.filter(function(Ri){return Ri.stageId===c.id}),aimLocked:!!Ge,groundFn:Qs,worldWidth:di.w,worldHeight:di.h,designHeight:H().height,drawX:di.x,drawY:di.y,fullBleed:!0});try{for(var Nt=Be(Ht),Jt=Nt.next();!Jt.done;Jt=Nt.next()){var Wt=Oe(Jt.value,2),Ut=Wt[0],Mt=Wt[1];if(Mt.stageId===c.id&&Mt.mode==="dynamic"){var wt=At.project({x:Mt.x,y:Mt.y,z:Mt.z},di.w,di.h);Pn.set(Ut,{x:di.x+wt.x,y:di.y+wt.y})}}}catch(Ri){W={error:Ri}}finally{try{Jt&&!Jt.done&&(V=Nt.return)&&V.call(Nt)}finally{if(W)throw W.error}}ye.push({c,m:Fe,clips:I,instance:E??c.prototypeId});try{for(var Tt=Be(_a(c.id)),St=Tt.next();!St.done;St=Tt.next()){var Ze=St.value;Ws(Ze,Fe,I,E??c.prototypeId,!0)}}catch(Ri){Q={error:Ri}}finally{try{St&&!St.done&&(B=Tt.return)&&B.call(Tt)}finally{if(Q)throw Q.error}}return}Cl||nu(!0),g.save(),g.transform.apply(g,et([],Oe(C?Fe:Nn(c)),!1)),g.globalAlpha*=me.opacity;var ze=$t.get(c.id);ze?.behavior.liftShadow&&(g.shadowColor="#00000055",g.shadowBlur=8,g.shadowOffsetY=4);var je=I;c.contract==="native.group.v1"&&me.clip&&(g.beginPath(),g.rect(0,0,me.width,me.height),g.clip(),je=et(et([],Oe(I),!1),[{matrix:Fe,width:me.width,height:me.height}],!1));var gt=!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 $e=c.contract==="native.button.v1",Pt=ue===c.id,Ft=$e?me.enabled?Pt?me.pressedFill:on===c.id?me.hoverFill:me.fill:me.disabledFill:me.fill;if($e&&(me.presentation==="pixel-cta"||me.presentation==="shiny-cta")){var mn=(pe=S.get(c.id))!==null&&pe!==void 0?pe:Ne;A.set(c.id,mn);var Xt=!f&&!F?.matches?Ne-mn:-1;me.presentation==="shiny-cta"?vg(g,me,Ft,Pt,Xt):mg(g,me,Ft,Pt,Xt)}else me.pixelFrame&&(g.save(),g.translate(3,4),tu(c,me),g.fillStyle="#3c293366",g.fill(),g.restore()),tu(c,me),Ue?(g.save(),g.clip(),Ua(c,Ue).render(g),g.restore(),gt=!0,tu(c,me)):(g.fillStyle=Ft,g.fill()),me.pixelFrame&&!(me.radius>0)&&(g.fillStyle="#ffffff22",g.fillRect(2,2,Math.max(0,me.width-4),2),g.fillRect(2,2,2,Math.max(0,me.height-4))),me.strokeWidth&&(g.strokeStyle=me.stroke,g.lineWidth=me.strokeWidth,g.stroke());Qt===c.id&&(tu(c,me),g.strokeStyle="#ffffff",g.lineWidth=5,g.stroke())}var vn;if(c.contract==="native.text.v1"){var ut=me.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Ri,Zr){var ti;return String((ti=K[Zr])!==null&&ti!==void 0?ti:"")});me.pixelPanel&&(g.fillStyle="#3c293366",g.fillRect(3,4,me.width,me.height),g.fillStyle=me.panelFill,g.fillRect(0,0,me.width,me.height),g.strokeStyle=(be=me.panelStroke)!==null&&be!==void 0?be:me.color,g.lineWidth=2,g.strokeRect(1,1,me.width-2,me.height-2),g.fillStyle="#ffffff22",g.fillRect(3,3,Math.max(0,me.width-6),2));var dt=me.fontFamily==="pixel"?Bp(ut,me):void 0;dt&&!dt.unsupportedChars.length?vn=ug(g,ut,me):vn=e1(g,ut,dt?bt(bt({},me),{fontFamily:"sans-serif",fontWeight:"700"}):me)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(c.contract)&&!Ue){var In=T.get((Ee=(xe=te.get(c.id))===null||xe===void 0?void 0:xe.assetId)!==null&&Ee!==void 0?Ee:(he=c.assetSlots[0])===null||he===void 0?void 0:he.assetId);if(In?.complete&&In.naturalWidth){g.save(),g.beginPath(),g.rect(0,0,me.width,me.height),g.clip();var Ii=c.contract!=="native.image.v1",fi=Ii?Math.min(me.frameColumns,me.frameCount):1,ui=Ii?Math.ceil(me.frameCount/fi):1,Gn=In.width/fi,hi=In.height/ui,oi=Ii?Og(c,me,Fe):0,Kn=oi%fi*Gn,Li=Math.floor(oi/fi)*hi,pi=me.fit==="cover"?Math.max(me.width/Gn,me.height/hi):Math.min(me.width/Gn,me.height/hi),ca=me.fit==="stretch"?me.width:Gn*pi,Qi=me.fit==="stretch"?me.height:hi*pi;g.imageSmoothingEnabled=(Me=me.smoothing)!==null&&Me!==void 0?Me:!0,g.drawImage(In,Kn,Li,Gn,hi,(me.width-ca)/2,(me.height-Qi)/2,ca,Qi),g.restore()}}if(Ue&&!gt&&Ua(c,Ue).render(g),c.contract==="native.stage3d.v1"&&Et&&!Xn.has(c.id)){var Kn=Math.hypot(Fe[0],Fe[1]),Li=Math.hypot(Fe[2],Fe[3]),At=Et.renderStage(c,g,me.width*Kn*mt*Ct,me.height*Li*mt*Ct,me.width,me.height,{time:fe,ambientTime:Ne,propsOf:Yt,bodies3d:Ht,fpsPose:An.get(c.id),instances3d:Yr(c.id),contactParticles:F?.matches?[]:se.filter(function(Yi){return Yi.stageId===c.id}),aimLocked:!!Ge,groundFn:Qs,worldWidth:me.width*Kn,worldHeight:me.height*Li});try{for(var Gi=Be(Ht),dn=Gi.next();!dn.done;dn=Gi.next()){var sn=Oe(dn.value,2),Ut=sn[0],Mt=sn[1];if(Mt.stageId===c.id&&Mt.mode==="dynamic"){var wt=At.project({x:Mt.x,y:Mt.y,z:Mt.z},me.width,me.height);Pn.set(Ut,ei(Fe,wt.x,wt.y))}}}catch(Yi){Z={error:Yi}}finally{try{dn&&!dn.done&&(q=Gi.return)&&q.call(Gi)}finally{if(Z)throw Z.error}}}ye.push({c,m:Fe,clips:je,instance:E??c.prototypeId,textMetrics:vn});try{for(var Ot=Be(_a(c.id)),Ci=Ot.next();!Ci.done;Ci=Ot.next()){var Ze=Ci.value;Ws(Ze,Fe,je,E??c.prototypeId)}}catch(Ri){ee={error:Ri}}finally{try{Ci&&!Ci.done&&(j=Ot.return)&&j.call(Ot)}finally{if(ee)throw ee.error}}me.clip&&c.contract==="native.group.v1"&&Bf(c.id),g.restore()}}}function Bf(c,x){var I,E;if(!F?.matches)try{for(var C=Be(se),U=C.next();!U.done;U=C.next()){var L=U.value;L.shape!=="pixel-confetti"&&L.shape!=="confetti"||L.clipId!==c||!!L.screen!=!!x||(g.save(),L.shape==="confetti"?pg(g,L,x):fg(g,L,x),g.restore())}}catch(W){I={error:W}}finally{try{U&&!U.done&&(E=C.return)&&E.call(C)}finally{if(I)throw I.error}}}function Bg(c,x,I,E){g.save(),g.translate(c,x),g.globalAlpha=.92,g.lineWidth=2,g.lineJoin="round",I==="tap"&&(g.strokeStyle="#fff0bd",g.globalAlpha=.7*(1-E),g.beginPath(),g.arc(0,0,12+E*12,0,Math.PI*2),g.stroke(),g.globalAlpha=.92),g.fillStyle="#fff0bd",g.strokeStyle="#193b46",g.beginPath(),g.moveTo(-7,10),g.lineTo(-9,-1),g.quadraticCurveTo(-9,-5,-5,-5),g.lineTo(-3,-3),g.lineTo(-3,-17),g.quadraticCurveTo(-3,-22,1,-22),g.quadraticCurveTo(5,-22,5,-17),g.lineTo(5,-6),g.quadraticCurveTo(9,-9,11,-5),g.quadraticCurveTo(15,-7,16,-2),g.lineTo(14,9),g.quadraticCurveTo(12,18,3,18),g.lineTo(-1,18),g.quadraticCurveTo(-5,17,-7,10),g.closePath(),g.fill(),g.stroke(),g.restore()}function kg(){var c,x,I,E,C,U,L,W,V,Q,B,Z,q,ee,j,re,pe,be,xe;if(yt=0,!f)try{for(var Ee=Be(n.gameplay.filter(function(ti){return ti.kind==="tutorial-hand"})),he=Ee.next();!he.done;he=Ee.next()){var Me=he.value,me=b.get(Me.componentId),Ue=vt(Me.parameters.targetId);if(!(!me||me.sceneId!==X||!Ue||Ue.sceneId!==X||!gi(Ue))&&!(Me.parameters.hideOnFirstInput&&ot)){var Fe=ht?fe:Ne;if(!(Fe-Ie<Me.parameters.idleDelaySeconds)){yt++;var it=Me.parameters.destinationId?vt(Me.parameters.destinationId):void 0,Ve=Yt(Ue),Ze=void 0;Ue.contract==="native.mesh3d.v1"&&(Ze=Gs(Ue.id)),Ze||(Ze=ei(ai(Ue),Ve.width/2,Ve.height/2));var At=Fe%1.2/1.2,Nt=F?.matches?0:At*At*(3-2*At),Jt=Ze.x,Wt=Ze.y;if(Me.parameters.mode!=="tap"){var Ut=it?ei(ai(it),Yt(it).width/2,Yt(it).height/2):{x:Ze.x-36,y:Ze.y+48};Jt=Ze.x+(Ut.x-Ze.x)*Nt,Wt=Ze.y+(Ut.y-Ze.y)*Nt}Bg(Jt+8,Wt+22,Me.parameters.mode,Nt)}}}}catch(ti){c={error:ti}}finally{try{he&&!he.done&&(x=Ee.return)&&x.call(Ee)}finally{if(c)throw c.error}}try{for(var Mt=Be(R),wt=Mt.next();!wt.done;wt=Mt.next()){var Tt=Oe(wt.value,2),St=Tt[0],ze=Tt[1],je=si("draw-stroke",St).parameters;try{for(var gt=(C=void 0,Be(ze.strokes)),$e=gt.next();!$e.done;$e=gt.next()){var Pt=$e.value;if(!(Pt.points.length<2)){g.save(),g.globalAlpha=je.mode==="slice-blade"?Math.max(0,1-Pt.age/.18):1,g.strokeStyle=je.color,g.lineWidth=je.strokeWidth,g.lineCap="round",g.lineJoin="round",g.beginPath(),g.moveTo(Pt.points[0].x,Pt.points[0].y);try{for(var Ft=(L=void 0,Be(Pt.points.slice(1))),mn=Ft.next();!mn.done;mn=Ft.next()){var Xt=mn.value;g.lineTo(Xt.x,Xt.y)}}catch(ti){L={error:ti}}finally{try{mn&&!mn.done&&(W=Ft.return)&&W.call(Ft)}finally{if(L)throw L.error}}g.stroke(),g.restore()}}}catch(ti){C={error:ti}}finally{try{$e&&!$e.done&&(U=gt.return)&&U.call(gt)}finally{if(C)throw C.error}}}}catch(ti){I={error:ti}}finally{try{wt&&!wt.done&&(E=Mt.return)&&E.call(Mt)}finally{if(I)throw I.error}}try{for(var vn=Be(De),ut=vn.next();!ut.done;ut=vn.next()){var dt=ut.value;if(!(dt.broken||!dt.drawRope)){var In=kn.get(dt.bodyId),Ii=vt(dt.anchorId);if(!(!In||!Ii)){var fi=Ai(Ii);g.save(),g.strokeStyle=dt.ropeColor,g.lineWidth=dt.ropeWidth,g.beginPath(),g.moveTo(fi.x,fi.y),g.lineTo(In.x,In.y),g.stroke(),g.restore()}}}}catch(ti){V={error:ti}}finally{try{ut&&!ut.done&&(Q=vn.return)&&Q.call(vn)}finally{if(V)throw V.error}}try{for(var ui=Be(n.gameplay.filter(function(ti){var Yi;return ti.kind==="virtual-joystick"&&((Yi=b.get(ti.componentId))===null||Yi===void 0?void 0:Yi.sceneId)===X})),Gn=ui.next();!Gn.done;Gn=ui.next()){var Me=Gn.value,hi=vt(Me.componentId),Ve=Me.parameters;if(!(!hi||!gi(hi)||Ve.drawControl===!1)){var oi=ve.get(Me.id),Kn=oi&&oi.pointerId!==null?oi.origin:Ai(hi),Li=oi&&oi.pointerId!==null?oi.knobX:Kn.x,pi=oi&&oi.pointerId!==null?oi.knobY:Kn.y,ca=(pe=Ve.radiusPx)!==null&&pe!==void 0?pe:56;g.save(),g.fillStyle=(be=Ve.baseColor)!==null&&be!==void 0?be:"#ffffff44",g.strokeStyle="#ffffffaa",g.lineWidth=2.5,g.beginPath(),g.arc(Kn.x,Kn.y,ca,0,Math.PI*2),g.fill(),g.stroke(),g.fillStyle=(xe=Ve.knobColor)!==null&&xe!==void 0?xe:"#fff0bdee",g.strokeStyle="#193b46aa",g.lineWidth=2,g.beginPath(),g.arc(Li,pi,ca*.42,0,Math.PI*2),g.fill(),g.stroke(),g.restore()}}}catch(ti){B={error:ti}}finally{try{Gn&&!Gn.done&&(Z=ui.return)&&Z.call(ui)}finally{if(B)throw B.error}}try{for(var Qi=Be(Xe),Gi=Qi.next();!Gi.done;Gi=Qi.next()){var dn=Gi.value,sn=Math.min(1,dn.elapsed/dn.seconds);g.save(),g.globalAlpha=1-sn,g.fillStyle=dn.color,g.strokeStyle="#193b46",g.lineWidth=3,g.font="900 "+dn.fontSize+"px sans-serif",g.textAlign="center",g.textBaseline="middle";var Wt=dn.y-(F?.matches?0:dn.risePx*sn);g.strokeText(dn.text,dn.x,Wt),g.fillText(dn.text,dn.x,Wt),g.restore()}}catch(ti){q={error:ti}}finally{try{Gi&&!Gi.done&&(ee=Qi.return)&&ee.call(Qi)}finally{if(q)throw q.error}}try{for(var Ot=Be(Je),Ci=Ot.next();!Ci.done;Ci=Ot.next()){var Ri=Ci.value,sn=Math.min(1,Ri.elapsed/Ri.seconds),Zr=H();g.save(),g.globalAlpha=Ri.opacity*(1-sn),g.fillStyle=Ri.color,g.fillRect(0,0,Zr.width,Zr.height),g.restore()}}catch(ti){j={error:ti}}finally{try{Ci&&!Ci.done&&(re=Ot.return)&&re.call(Ot)}finally{if(j)throw j.error}}}function zg(){if(de){var c=kn.get(de.targetId),x=de.behavior.parameters;if(c){var I=de.current.x-de.start.x,E=de.current.y-de.start.y,C=Math.hypot(I,E),U=Math.min(x.maxPullPx,C),L=C>.001?U/C:0;g.save(),g.lineCap="round";var W=Math.max(12,Math.min(c.width,c.height)*.62);if(g.strokeStyle="#173a2f66",g.lineWidth=3.5,g.beginPath(),g.arc(c.x,c.y,W,0,Math.PI*2),g.stroke(),g.strokeStyle=x.trajectoryColor,g.lineWidth=2,g.beginPath(),g.arc(c.x,c.y,W,0,Math.PI*2),g.stroke(),x.showTrajectory&&C>=x.minPullPx){var V=kf(),Q=Qc(),B=Q.bodies,Z=Q.zones,q=H(),ee=zm({body:bt(bt({},c),{vx:V.vx,vy:V.vy,atRest:!1}),bodies:B,zones:Z,bounds:{left:0,top:0,right:q.width,bottom:q.height},dots:x.trajectoryDots,bounces:x.trajectoryBounces});ee.forEach(function(pe,be){var xe=.96-.52*(be/Math.max(1,ee.length)),Ee=Math.max(2.2,4.5-be*.22);g.globalAlpha=xe,g.fillStyle="#173a2f88",g.beginPath(),g.arc(pe.x,pe.y,Ee+1.3,0,Math.PI*2),g.fill(),g.fillStyle=x.trajectoryColor,g.beginPath(),g.arc(pe.x,pe.y,Ee,0,Math.PI*2),g.fill()})}if(C>=4){var j=c.x+I*L,re=c.y+E*L;g.globalAlpha=.9,g.strokeStyle="#173a2f66",g.lineWidth=5,g.beginPath(),g.moveTo(c.x,c.y),g.lineTo(j,re),g.stroke(),g.strokeStyle=x.trajectoryColor,g.lineWidth=2.6,g.beginPath(),g.moveTo(c.x,c.y),g.lineTo(j,re),g.stroke(),g.fillStyle="#173a2f88",g.beginPath(),g.arc(j,re,5.2,0,Math.PI*2),g.fill(),g.fillStyle=x.trajectoryColor,g.beginPath(),g.arc(j,re,3.6,0,Math.PI*2),g.fill()}g.restore()}}}function Vg(c){var x,I,E,C;try{for(var U=Be(qc()),L=U.next();!L.done;L=U.next()){var W=L.value,V=W.contract==="native.group.v1"?_a(W.id):[W];try{for(var Q=(E=void 0,Be(V)),B=Q.next();!B.done;B=Q.next()){var Z=B.value;if(Z.contract==="native.stage3d.v1"&&gi(Z)&&Yt(Z).skyColor)return Yt(Z).skyColor;if(!(Z.contract!=="native.rectangle.v1"||!gi(Z))){var q=Yt(Z);if(!(q.opacity<.95||!q.fill||q.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test(Z.id)||q.width>=c.width*.9&&q.height>=c.height*.9))return q.fill}}}catch(ee){E={error:ee}}finally{try{B&&!B.done&&(C=Q.return)&&C.call(Q)}finally{if(E)throw E.error}}}}catch(ee){x={error:ee}}finally{try{L&&!L.done&&(I=U.return)&&I.call(U)}finally{if(x)throw x.error}}return"#102a34"}function Gg(){var c;if(Rt&&gi(Rt.c)){var x=Rt.c,I=Yt(x);g.save(),g.transform.apply(g,et([],Oe(ai(x)),!1)),g.strokeStyle=(c=Rt.highlightColor)!==null&&c!==void 0?c:"#ffffff",g.lineWidth=4,g.globalAlpha=.85,g.strokeRect(-4,-4,I.width+8,I.height+8),g.restore()}if(nt?.b.parameters.bringToFront){var x=vt(nt.targetId);x&&Ws(x,x.parentId?ai(vt(x.parentId)):za(),[],x.prototypeId)}}function Si(){var c,x,I,E,C,U,L,W,V,Q;S=A,A=new Map;var B=H();$!==void 0&&$!==B.landscape&&ar(),$=B.landscape;var Z=Math.min(devicePixelRatio||1,2),q=e.clientWidth,ee=e.clientHeight;(e.width!==Math.round(q*Z)||e.height!==Math.round(ee*Z))&&(e.width=Math.round(q*Z),e.height=Math.round(ee*Z)),g.setTransform(Z,0,0,Z,0,0),g.fillStyle=Vg(B),g.fillRect(0,0,q,ee);var j=Math.min(q/B.width,ee/B.height),re=(q-B.width*j)/2,pe=(ee-B.height*j)/2;if(mt=j||1,Ct=Z,g.translate(re,pe),g.scale(j,j),Te){var be=Math.min(1,Te.elapsed/Te.seconds),xe=Te.intensity*(1-be);g.translate(Math.sin(Te.elapsed*95)*xe,Math.cos(Te.elapsed*113)*xe)}if(bo=B,Cl=!1,di=void 0,Of.clear(),Xn.clear(),Et&&j>0&&q>=2&&ee>=2){di={x:-re/j,y:-pe/j,w:q/j,h:ee/j,pw:q*Z,ph:ee*Z};try{for(var Ee=Be(n.components),he=Ee.next();!he.done;he=Ee.next()){var Me=he.value;if(!(Me.contract!=="native.stage3d.v1"||Me.sceneId!==X||Me.prototype||!gi(Me))){for(var me=!0,Ue=[],Fe=Me.parentId?vt(Me.parentId):void 0;Fe;Fe=Fe.parentId?vt(Fe.parentId):void 0){var it=Yt(Fe);if(Fe.contract!=="native.group.v1"||it.clip||it.opacity<1){me=!1;break}Ue.push(Fe.id)}if(me){var Ve=ai(Me),Ze=Yt(Me);if(!(Math.abs(Ve[1])>.001||Math.abs(Ve[2])>.001)){var At=Math.hypot(Ve[0],Ve[1]),Nt=Math.hypot(Ve[2],Ve[3]);if(!(Ve[4]>1||Ve[5]>1||Ve[4]+Ze.width*At<B.width-1||Ve[5]+Ze.height*Nt<B.height-1)){Xn.add(Me.id);try{for(var Jt=(I=void 0,Be(Ue)),Wt=Jt.next();!Wt.done;Wt=Jt.next()){var Ut=Wt.value;Of.add(Ut)}}catch(dt){I={error:dt}}finally{try{Wt&&!Wt.done&&(E=Jt.return)&&E.call(Jt)}finally{if(I)throw I.error}}}}}}}}catch(dt){c={error:dt}}finally{try{he&&!he.done&&(x=Ee.return)&&x.call(Ee)}finally{if(c)throw c.error}}}bo=On(B),ye=[];try{for(var Mt=Be(qc()),wt=Mt.next();!wt.done;wt=Mt.next()){var Me=wt.value;Ws(Me)}}catch(dt){C={error:dt}}finally{try{wt&&!wt.done&&(U=Mt.return)&&U.call(Mt)}finally{if(C)throw C.error}}nu(!0);try{for(var Tt=Be(ge),St=Tt.next();!St.done;St=Tt.next()){var Me=St.value;Me.parentId||Ws(Me,za(),[],Me.prototypeId)}}catch(dt){L={error:dt}}finally{try{St&&!St.done&&(W=Tt.return)&&W.call(Tt)}finally{if(L)throw L.error}}if(Gg(),zg(),f&&ie){for(var ze=b.get(ie);ze?.parentId;)ze=b.get(ze.parentId);ze?.prototype&&Ws(ze)}Bf(),g.save();try{for(var je=Be(se),gt=je.next();!gt.done;gt=je.next()){var Ze=gt.value;if(Ze.age===void 0){var $e=Math.min(1,Ze.life*2),Pt=1.5+2.5*$e;if(g.globalAlpha=$e,g.globalCompositeOperation=Ze.shape==="square"?"source-over":"lighter",g.fillStyle=Ze.color,Ze.shape==="square"){var Ft=Math.max(2,Math.round(Pt*1.6));g.fillRect(Math.round(Ze.x-Ft/2),Math.round(Ze.y-Ft/2),Ft,Ft);continue}g.globalCompositeOperation="lighter",g.shadowColor=Ze.color,g.shadowBlur=se.length<=16?6:0,g.strokeStyle=Ze.color,g.lineWidth=1.5+$e,g.beginPath(),g.moveTo(Ze.x-Ze.vx*.025,Ze.y-Ze.vy*.025),g.lineTo(Ze.x,Ze.y),g.stroke(),g.beginPath(),g.arc(Ze.x,Ze.y,Pt,0,Math.PI*2),g.fill()}}}catch(dt){V={error:dt}}finally{try{gt&&!gt.done&&(Q=je.return)&&Q.call(je)}finally{if(V)throw V.error}}if(g.restore(),kg(),f&&ie){var mn=ye.filter(function(dt){return dt.c.contract!=="native.group.v1"&&(dt.c.id===ie||qr(dt.c,ie))});if(mn.length){var Xt=mn.map(function(dt){return Mr(dt.c,dt.m)}),vn=Math.min.apply(Math,et([],Oe(Xt.map(function(dt){return dt.left})),!1)),ut=Math.min.apply(Math,et([],Oe(Xt.map(function(dt){return dt.top})),!1));g.strokeStyle="#55e6ef",g.lineWidth=2/j,g.strokeRect(vn,ut,Math.max.apply(Math,et([],Oe(Xt.map(function(dt){return dt.right})),!1))-vn,Math.max.apply(Math,et([],Oe(Xt.map(function(dt){return dt.bottom})),!1))-ut)}}nu(!1),j>0&&Bf(void 0,{x:-re/j,y:-pe/j,width:q/j,height:ee/j})}function Hg(c){var x,I,E,C,U=Array.isArray(c)?et([],Oe(new Set(c)),!1):void 0;Si();var L=H(),W=On(L),V=new Set,Q=[];try{for(var B=Be(ye),Z=B.next();!Z.done;Z=B.next()){var q=Z.value,ee=(E=q.c.prototypeId)!==null&&E!==void 0?E:q.c.id;if(!(q.c.contract==="native.group.v1"||U&&!U.includes(ee))){V.add(ee);var j=Mr(q.c,q.m),re=((C=Yt(q.c).strokeWidth)!==null&&C!==void 0?C:0)/2;j.left-=re,j.right+=re,j.top-=re,j.bottom+=re;var pe={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(pe).some(function(xe){return xe>.01})&&Q.push({id:ee,contract:q.c.contract,bounds:j,overflow:pe})}}}catch(xe){x={error:xe}}finally{try{Z&&!Z.done&&(I=B.return)&&I.call(B)}finally{if(x)throw x.error}}var be=U?U.filter(function(xe){return!V.has(xe)}):[];return{ok:Q.length===0&&be.length===0,viewport:bt(bt({},L),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight}),issues:Q,missing:be}}function Wg(c){var x,I,E,C,U,L,W,V,Q,B,Z,q,ee,j,re,pe,be,xe,Ee,he,Me,me,Ue,Fe,it,Ve,Ze,At,Nt,Jt,Wt,Ut,Mt,wt=c===void 0?{}:c,Tt=wt.ids,St=wt.interactiveIds,ze=wt.network,je=ze===void 0?"standalone":ze,gt=wt.minTouchPx,$e=gt===void 0?44:gt,Pt=Array.isArray(Tt)?et([],Oe(new Set(Tt)),!1):void 0;Si();var Ft=H(),mn=On(Ft),Xt=Math.min(e.clientWidth/Ft.width,e.clientHeight/Ft.height),vn=Zp(mn,je),ut=[],dt=new Set,In=function(Le){var jt;return!Pt||Pt.includes((jt=Le.c.prototypeId)!==null&&jt!==void 0?jt:Le.c.id)},Ii=ye.filter(In),fi=new Set(n.events.filter(function(Le){return Le.kind==="click"}).map(function(Le){return Le.componentId}));try{for(var ui=Be(n.gameplay),Gn=ui.next();!Gn.done;Gn=ui.next()){var hi=Gn.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(hi.kind)&&fi.add(hi.componentId)}}catch(Le){x={error:Le}}finally{try{Gn&&!Gn.done&&(I=ui.return)&&I.call(ui)}finally{if(x)throw x.error}}var oi=new Set(St??fi),Kn=new Set(et(et([],Oe(n.gameplay.filter(function(Le){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(Le.kind)&&(Le.parameters.dragMode==="anywhere"||Le.kind==="draw-stroke"||Le.kind==="virtual-joystick"&&Le.parameters.mode==="floating")}).map(function(Le){return Le.componentId})),!1),Oe(n.components.filter(function(Le){return Le.contract==="native.stage3d.v1"}).map(function(Le){return Le.id})),!1)),Li=function(Le){var jt;return oi.has((jt=Le.c.prototypeId)!==null&&jt!==void 0?jt:Le.c.id)},pi=function(Le,jt,fn,Zn,$i,Ui){return ut.push(bt(bt({kind:Le,severity:jt,id:fn},Ui?{otherId:Ui}:{}),{detail:Zn,metrics:$i}))},ca=function(Le){var jt=[[0,0],[Le.width,0],[Le.width,Le.height],[0,Le.height]].map(function(fn){var Zn=Oe(fn,2),$i=Zn[0],Ui=Zn[1];return ei(Le.matrix,$i,Ui)});return{left:Math.min.apply(Math,et([],Oe(jt.map(function(fn){return fn.x})),!1)),right:Math.max.apply(Math,et([],Oe(jt.map(function(fn){return fn.x})),!1)),top:Math.min.apply(Math,et([],Oe(jt.map(function(fn){return fn.y})),!1)),bottom:Math.max.apply(Math,et([],Oe(jt.map(function(fn){return fn.y})),!1))}};try{for(var Qi=Be(Ii),Gi=Qi.next();!Gi.done;Gi=Qi.next()){var dn=Gi.value,sn=(Ue=dn.c.prototypeId)!==null&&Ue!==void 0?Ue:dn.c.id;dt.add(sn);var Ot=Mr(dn.c,dn.m),Ci=((Fe=Yt(dn.c).strokeWidth)!==null&&Fe!==void 0?Fe:0)/2;Ot.left-=Ci,Ot.right+=Ci,Ot.top-=Ci,Ot.bottom+=Ci;var Ri=dn.c.contract==="native.group.v1"&&!Yt(dn.c).clip,Zr=dn.c.contract==="native.image.v1"&&dn.clips.length===0&&Yt(dn.c).fit==="cover"&&Ot.left<=0&&Ot.top<=0&&Ot.right>=Ft.width&&Ot.bottom>=Ft.height||dn.c.contract==="native.stage3d.v1"&&Ot.left<=0&&Ot.top<=0&&Ot.right>=Ft.width&&Ot.bottom>=Ft.height,ti=dn.c.contract==="native.rectangle.v1"&&Ci===0&&Ot.left<=0&&Ot.top<=0&&Ot.right>=Ft.width&&Ot.bottom>=Ft.height||Zr;if(!Ri){var Yi={left:Math.max(0,mn.left-Ot.left),right:Math.max(0,Ot.right-mn.right),top:Math.max(0,mn.top-Ot.top),bottom:Math.max(0,Ot.bottom-mn.bottom)};if(!ti&&!tm(dn.c)&&Object.values(Yi).some(function(Le){return Le>.01})&&pi("stage-overflow","blocker",sn,"Component extends beyond the active stage.",{bounds:Ot,overflow:Yi}),dn.c.contract==="native.image.v1"&&dn.clips.length===0){var ua=Ot.right-Ot.left,Fa=Ot.bottom-Ot.top,ns=/(?:^|\.)(backdrop|background|bg)$/.test(sn)||Yt(dn.c).fit==="cover"&&!dn.c.parentId&&Ot.left<=1&&Ot.top<=1&&(ua>=Ft.width*.4||Fa>=Ft.height*.4);ns&&(Ot.left>.5||Ot.top>.5||Ot.right<Ft.width-.5||Ot.bottom<Ft.height-.5)&&pi("backdrop-incomplete","blocker",sn,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:Ot,stage:{width:Ft.width,height:Ft.height}})}try{for(var Jr=(U=void 0,Be(dn.clips)),br=Jr.next();!br.done;br=Jr.next()){var Sa=br.value,da=ca(Sa),Oa={left:Math.max(0,da.left-Ot.left),right:Math.max(0,Ot.right-da.right),top:Math.max(0,da.top-Ot.top),bottom:Math.max(0,Ot.bottom-da.bottom)};Object.values(Oa).some(function(Le){return Le>.01})&&pi("parent-clip-crop","blocker",sn,"Component is cropped by an ancestor clipping group.",{bounds:Ot,clip:da,crop:Oa})}}catch(Le){U={error:Le}}finally{try{br&&!br.done&&(L=Jr.return)&&L.call(Jr)}finally{if(U)throw U.error}}}if(dn.textMetrics){var or=dn.textMetrics;(or.overflowsWidth||or.overflowsHeight)&&pi("text-overflow","blocker",sn,"Text does not fit its component after wrapping and auto-fit.",or);var Oi=(it=or.fontSize)!==null&&it!==void 0?it:or.scale*8;Oi<12&&pi("text-illegible",Oi<8?"blocker":"warning",sn,"Rendered text is below the recommended legible size.",bt({renderedFontSize:Oi},or));var qi=Yt(dn.c);if(qi.pixelPanel&&qi.align!=="center"){var ba=Math.max(0,qi.width-2*(qi.padding===void 0?8:qi.padding));ba-((Ve=or.renderedWidth)!==null&&Ve!==void 0?Ve:0)>12&&pi("panel-off-center","blocker",sn,"Text inside a framed pixel panel is not horizontally centered.",{align:qi.align,innerWidth:ba,renderedWidth:(Ze=or.renderedWidth)!==null&&Ze!==void 0?Ze:0})}}if(Li(dn)&&!Kn.has(sn)&&(dn.c.contract!=="native.group.v1"||Ot.right>Ot.left&&Ot.bottom>Ot.top)){var Bi=(Ot.right-Ot.left)*Xt,wn=(Ot.bottom-Ot.top)*Xt;(Bi<$e-.01||wn<$e-.01)&&pi("touch-target-small","blocker",sn,"Interactive target is smaller than the required physical touch size.",{width:Bi,height:wn,minTouchPx:$e,scale:Xt})}if(Li(dn)&&!Kn.has(sn)||dn.c.contract==="native.text.v1")try{for(var wa=(W=void 0,Be(vn.zones)),fa=wa.next();!fa.done;fa=wa.next()){var $r=fa.value,Bi=Math.min(Ot.right,$r.right)-Math.max(Ot.left,$r.left),wn=Math.min(Ot.bottom,$r.bottom)-Math.max(Ot.top,$r.top);Bi>.01&&wn>.01&&pi("sdk-safe-area-collision","blocker",sn,"Component intersects a reserved ad-SDK overlay zone.",{bounds:Ot,zone:$r,intersection:{width:Bi,height:wn},network:je})}}catch(Le){W={error:Le}}finally{try{fa&&!fa.done&&(V=wa.return)&&V.call(wa)}finally{if(W)throw W.error}}}}catch(Le){E={error:Le}}finally{try{Gi&&!Gi.done&&(C=Qi.return)&&C.call(Qi)}finally{if(E)throw E.error}}for(var Zi=Ii.filter(function(Le){return Li(Le)&&Le.c.contract!=="native.group.v1"&&Le.c.contract!=="native.stage3d.v1"}),yi=0;yi<Zi.length;yi++)for(var qn=yi+1;qn<Zi.length;qn++){var Mn=Zi[yi],Sn=Zi[qn],vr=(At=Mn.c.prototypeId)!==null&&At!==void 0?At:Mn.c.id,Nr=(Nt=Sn.c.prototypeId)!==null&&Nt!==void 0?Nt:Sn.c.id;if(!(vr===Nr||qr(Mn.c,Sn.c.id)||qr(Sn.c,Mn.c.id))){var Ta=Mr(Mn.c,Mn.m),ys=Mr(Sn.c,Sn.m),Bi=Math.min(Ta.right,ys.right)-Math.max(Ta.left,ys.left),wn=Math.min(Ta.bottom,ys.bottom)-Math.max(Ta.top,ys.top);Bi>1&&wn>1&&pi("interactive-overlap","blocker",vr,"Interactive targets overlap.",{intersection:{width:Bi,height:wn},first:Ta,second:ys},Nr)}}var wo=function(Le){if(!Le||Le==="transparent")return!1;var jt=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(Le);if(jt)return jt[1].length===4?jt[1][3].toLowerCase()==="f":jt[1].slice(6).toLowerCase()==="ff";var fn=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(Le);return fn?Number(fn[1])>=.95:!0},Xs=[];Ii.forEach(function(Le,jt){var fn,Zn;Le.c.contract==="native.rectangle.v1"&&!Li(Le)&&((fn=Yt(Le.c).opacity)!==null&&fn!==void 0?fn:1)>=.95&&wo(Yt(Le.c).fill)&&Xs.push({rowIndex:jt,row:Le,order:(Zn=Le.c.order)!==null&&Zn!==void 0?Zn:0,bounds:Mr(Le.c,Le.m)})});var To=Ii.filter(function(Le,jt){var fn,Zn=Mr(Le.c,Le.m),$i=(fn=Le.c.order)!==null&&fn!==void 0?fn:0;return!Xs.some(function(Ui){return Ui.rowIndex>jt&&Ui.order>$i&&Ui.row.c.id!==Le.c.id&&!qr(Ui.row.c,Le.c.id)&&!qr(Le.c,Ui.row.c.id)&&Ui.bounds.left<=Zn.left+1&&Ui.bounds.right>=Zn.right-1&&Ui.bounds.top<=Zn.top+1&&Ui.bounds.bottom>=Zn.bottom-1})}),Eo=To.map(function(Le,jt){return{row:Le,rowIndex:jt}}).filter(function(Le){var jt,fn=Le.row;if(fn.c.contract!=="native.rectangle.v1")return!1;var Zn=Mr(fn.c,fn.m),$i=Zn.right-Zn.left,Ui=Zn.bottom-Zn.top,rs=((jt=Yt(fn.c).strokeWidth)!==null&&jt!==void 0?jt:0)===0&&Zn.left<=0&&Zn.right>=Ft.width;return!rs&&$i>=180&&Ui>=140&&!Li(fn)}).map(function(Le){var jt,fn=Le.row,Zn=Le.rowIndex;return{id:(jt=fn.c.prototypeId)!==null&&jt!==void 0?jt:fn.c.id,row:fn,rowIndex:Zn,bounds:Mr(fn.c,fn.m)}}),Ys=function(Le,jt,fn,Zn){var $i,Ui;Zn===void 0&&(Zn=!1);var rs=($i=Le.c.prototypeId)!==null&&$i!==void 0?$i:Le.c.id,Bl=(fn.left+fn.right)/2,as=(fn.top+fn.bottom)/2,qf=(Ui=Le.c.order)!==null&&Ui!==void 0?Ui:0;return Eo.filter(function(wi){var ss;return wi.id!==rs&&(!Zn||wi.rowIndex<jt||((ss=wi.row.c.order)!==null&&ss!==void 0?ss:0)===qf)&&fn.right-fn.left<=wi.bounds.right-wi.bounds.left+4&&fn.bottom-fn.top<=wi.bounds.bottom-wi.bounds.top+4&&Bl>=wi.bounds.left&&Bl<=wi.bounds.right&&as>=wi.bounds.top&&as<=wi.bounds.bottom}).sort(function(wi,ss){return(wi.bounds.right-wi.bounds.left)*(wi.bounds.bottom-wi.bounds.top)-(ss.bounds.right-ss.bounds.left)*(ss.bounds.bottom-ss.bounds.top)||ss.rowIndex-wi.rowIndex})[0]},ha=new Map,cn=new Map;if(Eo.length){To.forEach(function(Le,jt){var fn,Zn=(fn=Le.c.prototypeId)!==null&&fn!==void 0?fn:Le.c.id,$i=Mr(Le.c,Le.m),Ui=($i.left+$i.right)/2,rs=($i.top+$i.bottom)/2,Bl=Le.c.contract==="native.button.v1"&&!ln.has(Le.c.id),as=Le.c.parentId?vt(Le.c.parentId):void 0,qf=Le.c.contract==="native.text.v1"&&Yt(Le.c).align==="center"&&as?.contract!=="native.button.v1";if(Bl||qf){var wi=Ys(Le,jt,$i,!1);wi&&(ha.has(wi.id)||ha.set(wi.id,{panel:wi,items:[]}),ha.get(wi.id).items.push({id:Zn,bounds:$i,cx:Ui,cy:rs,isBtn:Bl}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(Le.c.contract)&&as?.contract!=="native.button.v1"){var wi=Ys(Le,jt,$i,!0);wi&&(cn.has(wi.id)||cn.set(wi.id,{panel:wi,content:[]}),cn.get(wi.id).content.push({row:Le,id:Zn,bounds:$i}))}});try{for(var xi=Be(ha.values()),Ji=xi.next();!Ji.done;Ji=xi.next()){var ji=Ji.value,ki=ji.panel,gr=ji.items;if(gr.some(function(Le){return Le.isBtn})){var bi=ki.bounds,Hi=(bi.left+bi.right)/2;try{for(var xs=(Z=void 0,Be(gr)),Br=xs.next();!Br.done;Br=xs.next()){var pa=Br.value,is={left:pa.bounds.left-bi.left,right:bi.right-pa.bounds.right,top:pa.bounds.top-bi.top,bottom:bi.bottom-pa.bounds.bottom},qs=Math.min(is.left,is.right,is.top,is.bottom);(qs<10||qs*Xt<8)&&pi("panel-edge-cramped","blocker",pa.id,"Element sits too close to its enclosing panel edge.",{panelId:ki.id,margins:is,scale:Xt,minStagePx:10,minCssPx:8},ki.id)}}catch(Le){Z={error:Le}}finally{try{Br&&!Br.done&&(q=xs.return)&&q.call(xs)}finally{if(Z)throw Z.error}}var Zs=[],ty=function(Le){var jt=Zs.find(function(fn){return Math.abs(fn.cy-Le.cy)<=16&&fn.isBtn===Le.isBtn});jt?jt.items.push(Le):Zs.push({cy:Le.cy,isBtn:Le.isBtn,items:[Le]})};try{for(var au=(ee=void 0,Be(gr)),Ll=au.next();!Ll.done;Ll=au.next()){var pa=Ll.value;ty(pa)}}catch(Le){ee={error:Le}}finally{try{Ll&&!Ll.done&&(j=au.return)&&j.call(au)}finally{if(ee)throw ee.error}}try{for(var su=(re=void 0,Be(Zs)),Dl=su.next();!Dl.done;Dl=su.next()){var Xf=Dl.value,ny=Math.min.apply(Math,et([],Oe(Xf.items.map(function(Le){return Le.bounds.left})),!1)),iy=Math.max.apply(Math,et([],Oe(Xf.items.map(function(Le){return Le.bounds.right})),!1)),um=(ny+iy)/2,dm=um-Hi;Math.abs(dm)>3&&pi("panel-off-center","blocker",Xf.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:ki.id,offsetX:dm,groupCenterX:um,panelCenterX:Hi,scale:Xt},ki.id)}}catch(Le){re={error:Le}}finally{try{Dl&&!Dl.done&&(pe=su.return)&&pe.call(su)}finally{if(re)throw re.error}}}}}catch(Le){Q={error:Le}}finally{try{Ji&&!Ji.done&&(B=xi.return)&&B.call(xi)}finally{if(Q)throw Q.error}}try{for(var ou=Be(cn.values()),Nl=ou.next();!Nl.done;Nl=ou.next())for(var fm=Nl.value,ki=fm.panel,lu=fm.content,ry=ha.has(ki.id),yi=0;yi<lu.length;yi++)for(var qn=yi+1;qn<lu.length;qn++){var Mn=lu[yi],Sn=lu[qn];if(!(Mn.id===Sn.id||qr(Mn.row.c,Sn.row.c.id)||qr(Sn.row.c,Mn.row.c.id))){var ay=Mn.row.c.contract==="native.image.v1"&&Sn.row.c.contract==="native.image.v1";if(!(ay&&(!ry||Mn.row.c.parentId&&Mn.row.c.parentId===Sn.row.c.parentId))){var Bi=Math.min(Mn.bounds.right,Sn.bounds.right)-Math.max(Mn.bounds.left,Sn.bounds.left),wn=Math.min(Mn.bounds.bottom,Sn.bounds.bottom)-Math.max(Mn.bounds.top,Sn.bounds.top);Bi>2&&wn>2&&pi("panel-content-overlap","blocker",Mn.id,"Panel elements overlap each other.",{panelId:ki.id,intersection:{width:Bi,height:wn},first:Mn.bounds,second:Sn.bounds},Sn.id)}}}}catch(Le){be={error:Le}}finally{try{Nl&&!Nl.done&&(xe=ou.return)&&xe.call(ou)}finally{if(be)throw be.error}}}var Ao=To.filter(function(Le){if(Le.c.contract!=="native.text.v1")return!1;var jt=Le.c.parentId?vt(Le.c.parentId):void 0;return jt?.contract!=="native.button.v1"}).map(function(Le){var jt,fn,Zn=String((jt=Yt(Le.c).text)!==null&&jt!==void 0?jt:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function($i,Ui){var rs;return String((rs=K[Ui])!==null&&rs!==void 0?rs:"")}).trim();return{row:Le,id:(fn=Le.c.prototypeId)!==null&&fn!==void 0?fn:Le.c.id,bounds:Mr(Le.c,Le.m),raw:Zn,norm:Zn.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(Le){return Le.raw.length>0}),sy=Eo.filter(function(Le){var jt,fn;return((jt=ha.get(Le.id))===null||jt===void 0?void 0:jt.items.some(function(Zn){return Zn.isBtn}))||((fn=cn.get(Le.id))===null||fn===void 0?void 0:fn.content.some(function(Zn){return Zn.row.c.contract==="native.button.v1"}))});try{for(var cu=Be(sy),Ul=cu.next();!Ul.done;Ul=cu.next()){var ki=Ul.value,bi=ki.bounds,Hi=(bi.left+bi.right)/2,oy=bi.right-bi.left;try{for(var uu=(Me=void 0,Be(Ao)),Fl=uu.next();!Fl.done;Fl=uu.next()){var Ba=Fl.value;if(Yt(Ba.row.c).align==="center"&&!(Ba.bounds.bottom>bi.top+6||bi.top-Ba.bounds.bottom>48)){var hm=Ba.bounds.right-Ba.bounds.left,Ol=(Ba.bounds.left+Ba.bounds.right)/2,ly=Math.min(Ba.bounds.right,bi.right)-Math.max(Ba.bounds.left,bi.left);(Ol>=bi.left&&Ol<=bi.right||ly>=hm*.6)&&hm<=oy+60&&Math.abs(Ol-Hi)>4&&pi("header-off-center","blocker",Ba.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:ki.id,offsetX:Ol-Hi,textCenterX:Ol,panelCenterX:Hi,scale:Xt},ki.id)}}}catch(Zn){Me={error:Zn}}finally{try{Fl&&!Fl.done&&(me=uu.return)&&me.call(uu)}finally{if(Me)throw Me.error}}}}catch(Le){Ee={error:Le}}finally{try{Ul&&!Ul.done&&(he=cu.return)&&he.call(cu)}finally{if(Ee)throw Ee.error}}for(var yi=0;yi<Ao.length;yi++)for(var qn=yi+1;qn<Ao.length;qn++){var Mn=Ao[yi],Sn=Ao[qn];if(!(Mn.id===Sn.id||qr(Mn.row.c,Sn.row.c.id)||qr(Sn.row.c,Mn.row.c.id))){var Bi=Math.min(Mn.bounds.right,Sn.bounds.right)-Math.max(Mn.bounds.left,Sn.bounds.left),wn=Math.min(Mn.bounds.bottom,Sn.bounds.bottom)-Math.max(Mn.bounds.top,Sn.bounds.top);if(Bi>2&&wn>2&&pi("panel-content-overlap","blocker",Mn.id,"Visible text elements overlap.",{intersection:{width:Bi,height:wn},first:Mn.bounds,second:Sn.bounds},Sn.id),Mn.norm&&Sn.norm){var pm=Oe(Mn.norm.length<=Sn.norm.length?[Mn.norm,Sn.norm]:[Sn.norm,Mn.norm],2),du=pm[0],mm=pm[1];(du===mm&&du.length>=6||du.length>=12&&mm.includes(du))&&pi("duplicate-visible-copy","blocker",Mn.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:Mn.raw,second:Sn.raw},Sn.id)}}}var ka=Ao.filter(function(Le){return!/^[\d\s/.,:%+\-x]+$/i.test(Le.raw)}),fu=ka.reduce(function(Le,jt){return Le+(jt.norm?jt.norm.split(" ").filter(Boolean).length:0)},0),Yf=ka.reduce(function(Le,jt){return Le+jt.raw.replace(/\s+/g," ").length},0);fu>20||Yf>130||ka.length>5?pi("text-clutter-heavy","blocker",(Wt=(Jt=ka[0])===null||Jt===void 0?void 0:Jt.id)!==null&&Wt!==void 0?Wt:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:ka.length,wordCount:fu,charCount:Yf,texts:ka.map(function(Le){return Le.raw})}):(fu>12||ka.length>4)&&pi("text-clutter-heavy","warning",(Mt=(Ut=ka[0])===null||Ut===void 0?void 0:Ut.id)!==null&&Mt!==void 0?Mt:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:ka.length,wordCount:fu,charCount:Yf,texts:ka.map(function(Le){return Le.raw})});var vm=Pt?Pt.filter(function(Le){if(dt.has(Le))return!1;var jt=vt(Le);return jt?.contract==="native.mesh3d.v1"?!1:!jt||gi(jt)}):[];return{ok:!ut.some(function(Le){return Le.severity==="blocker"})&&vm.length===0,viewport:bt(bt({},Ft),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight,scale:Xt}),defects:ut,missing:vm,interactive:Zi.map(function(Le){var jt;return{id:(jt=Le.c.prototypeId)!==null&&jt!==void 0?jt:Le.c.id,bounds:Mr(Le.c,Le.m)}}),safeArea:vn}}function qr(c,x){for(;c.parentId;){if(c.parentId===x)return!0;c=vt(c.parentId)}return!1}function tm(c){for(var x=function(C){if(n.gameplay.some(function(U){var L;return U.kind==="camera-follow"&&U.componentId===((L=C.prototypeId)!==null&&L!==void 0?L:C.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 iu(c){var x=H(),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 Xg(c,x){var I,E,C,U;try{if(c.c.contract==="native.stage3d.v1"&&Xn.has(c.c.id)&&di)return x.x>=di.x&&x.y>=di.y&&x.x<=di.x+di.w&&x.y<=di.y+di.h;try{for(var L=Be(c.clips),W=L.next();!W.done;W=L.next()){var V=W.value,Q=ei(kr(V.matrix),x.x,x.y);if(Q.x<0||Q.y<0||Q.x>V.width||Q.y>V.height)return!1}}catch(he){I={error:he}}finally{try{W&&!W.done&&(E=L.return)&&E.call(L)}finally{if(I)throw I.error}}var B=ei(kr(c.m),x.x,x.y),Z=Yt(c.c);if(c.c.contract==="native.path.v1"){var q=new Path2D,ee=function(he,Me){({M:function(){return q.moveTo.apply(q,et([],Oe(Me),!1))},L:function(){return q.lineTo.apply(q,et([],Oe(Me),!1))},C:function(){return q.bezierCurveTo.apply(q,et([],Oe(Me),!1))},Q:function(){return q.quadraticCurveTo.apply(q,et([],Oe(Me),!1))},Z:function(){return q.closePath()}})[he]()};try{for(var j=Be(Z.commands),re=j.next();!re.done;re=j.next()){var pe=Oe(re.value),be=pe[0],xe=pe.slice(1);ee(be,xe)}}catch(he){C={error:he}}finally{try{re&&!re.done&&(U=j.return)&&U.call(j)}finally{if(C)throw C.error}}g.save(),g.setTransform(1,0,0,1,0,0),g.lineWidth=Z.strokeWidth;var Ee=g.isPointInPath(q,B.x,B.y)||Z.strokeWidth>0&&g.isPointInStroke(q,B.x,B.y);return g.restore(),Ee}return c.c.contract==="native.ellipse.v1"?Math.pow((B.x-Z.width/2)/(Z.width/2),2)+Math.pow((B.y-Z.height/2)/(Z.height/2),2)<=1:B.x>=0&&B.y>=0&&B.x<=Z.width&&B.y<=Z.height}catch{return!1}}function Rl(c){return et([],Oe(ye),!1).reverse().find(function(x){return x.c.contract!=="native.group.v1"&&x.c.sceneId===X&&vt(x.c.id)&&gi(x.c)&&Xg(x,c)})}function Pl(c){for(var x=[];c;)x.push(c),c=vt(c.parentId);return x}function kf(){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),C=Math.max(0,Math.min(1,(E-c.minPullPx)/Math.max(1,c.maxPullPx-c.minPullPx))),U=c.minSpeed+(c.maxSpeed-c.minSpeed)*C,L=c.invert?-1:1;return{vx:E?x/E*U*L:0,vy:E?I/E*U*L:0,power:C,pull:E}}function nm(c){if(de){de.current=c;var x=kf();de.power=x.power,de.behavior.parameters.powerVariableId&&(K[de.behavior.parameters.powerVariableId]=x.power)}}function zf(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"&&Pf()})),So(c)}catch{}}function Yg(c,x,I){var E,C,U,L,W,V,Q=function(Me){var me=I.find(function(it){var Ve;return((Ve=it.prototypeId)!==null&&Ve!==void 0?Ve:it.id)===Me.componentId});if(!me)return"continue";var Ue=ei(kr(ai(me)),x.x,x.y),Fe=Ua(me,Me);return Fe.stampSegment(Ue,Ue),_t={kind:"mask",pointerId:c.pointerId,c:me,behavior:Me,last:Ue},(W=e.setPointerCapture)===null||W===void 0||W.call(e,c.pointerId),{value:!0}};try{for(var B=Be(n.gameplay.filter(function(Me){var me;return Me.kind==="erase-mask"&&((me=b.get(Me.componentId))===null||me===void 0?void 0:me.sceneId)===X})),Z=B.next();!Z.done;Z=B.next()){var q=Z.value,ee=Q(q);if(typeof ee=="object")return ee.value}}catch(Me){E={error:Me}}finally{try{Z&&!Z.done&&(C=B.return)&&C.call(B)}finally{if(E)throw E.error}}if(I.some(function(Me){return Me.contract==="native.button.v1"||n.events.some(function(me){var Ue;return me.kind==="click"&&me.componentId===((Ue=Me.prototypeId)!==null&&Ue!==void 0?Ue:Me.id)})}))return!1;try{for(var j=Be(n.gameplay.filter(function(Me){var me;return Me.kind==="draw-stroke"&&((me=b.get(Me.componentId))===null||me===void 0?void 0:me.sceneId)===X})),re=j.next();!re.done;re=j.next()){var q=re.value,pe=b.get(q.componentId),be=kr(ai(pe)),xe=ei(be,x.x,x.y),Ee=Yt(pe);if(!(xe.x<0||xe.y<0||xe.x>Ee.width||xe.y>Ee.height)){var he=Os(q);return he.begin(x),_t={kind:"stroke",pointerId:c.pointerId,c:pe,behavior:q,store:he,last:x},bn({kind:"strokeStart",componentId:pe.id}),(V=e.setPointerCapture)===null||V===void 0||V.call(e,c.pointerId),!0}}}catch(Me){U={error:Me}}finally{try{re&&!re.done&&(L=j.return)&&L.call(j)}finally{if(U)throw U.error}}return!1}function qg(c,x,I){var E,C,U,L,W,V,Q,B=I.store.active;if(B){try{for(var Z=Be(n.gameplay.filter(function(Fe){var it;return Fe.kind==="collider"&&((it=b.get(Fe.componentId))===null||it===void 0?void 0:it.sceneId)===X})),q=Z.next();!q.done;q=Z.next()){var ee=q.value,j=b.get(ee.componentId);try{for(var re=(U=void 0,Be(Pi(j))),pe=re.next();!pe.done;pe=re.next()){var be=pe.value;!gi(be)||B.hitIds.has(be.id)||Pm(c,x,jp(be,ee.parameters.shape))&&(B.hitIds.add(be.id),bn(sr("sliceHit",be)))}}catch(Fe){U={error:Fe}}finally{try{pe&&!pe.done&&(L=re.return)&&L.call(re)}finally{if(U)throw U.error}}}}catch(Fe){E={error:Fe}}finally{try{q&&!q.done&&(C=Z.return)&&C.call(Z)}finally{if(E)throw E.error}}try{for(var xe=Be(De),Ee=xe.next();!Ee.done;Ee=xe.next()){var he=Ee.value;if(!(he.broken||!he.breakable||B.hitIds.has(he.key))){var Me=kn.get(he.bodyId),me=vt(he.anchorId);if(!(!Me||!me)){var Ue=Ai(me);eh(c,x,{x:Ue.x,y:Ue.y},{x:Me.x,y:Me.y})&&(B.hitIds.add(he.key),he.broken=!0,we.add(he.key),bn({kind:"jointBreak",behaviorId:he.id,componentId:he.componentId,selfInstanceId:he.bodyId,instanceId:(Q=vt(he.bodyId))===null||Q===void 0?void 0:Q.instanceId}))}}}}catch(Fe){W={error:Fe}}finally{try{Ee&&!Ee.done&&(V=xe.return)&&V.call(xe)}finally{if(W)throw W.error}}}}function Zg(c,x){var I,E=x.last,C=x.behavior.parameters;if(C.inkVariableId){var U=C.inkVariableId,L=Math.hypot(c.x-E.x,c.y-E.y);if(((I=K[U])!==null&&I!==void 0?I:0)<L)return;K[U]-=L}x.store.add(c)&&(C.mode==="slice-blade"&&qg(E,c,x),x.last=c)}function Jg(c){var x,I;if(!(!_t||_t.pointerId!==c.pointerId)){var E=_t;_t=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 C=E.store.end(),U=E.behavior.parameters;if(C){if(U.mode==="physics-wall"){var L=new Set(E.store.strokes.map(function(V){return V.id}));Gt=Gt.filter(function(V){return V.owner!==E.c.id||L.has(V.strokeId)}),Gt.push.apply(Gt,et([],Oe(Dm(C,U.strokeWidth).map(function(V){return bt(bt({},V),{owner:E.c.id})})),!1))}else if(U.mode==="path-trace"){var W=vt(U.followComponentId);W&&C.points.length>1&&ce.set(W.id,{points:C.points,index:1,speed:U.followSpeed})}}bn({kind:"strokeEnd",componentId:E.c.id})}}}function $g(c){var x,I,E,C;try{for(var U=Be(R.values()),L=U.next();!L.done;L=U.next()){var W=L.value;W.tick(c)}}catch(he){x={error:he}}finally{try{L&&!L.done&&(I=U.return)&&I.call(U)}finally{if(x)throw x.error}}try{for(var V=Be(ce),Q=V.next();!Q.done;Q=V.next()){var B=Oe(Q.value,2),Z=B[0],q=B[1],ee=vt(Z);if(!ee){ce.delete(Z);continue}var j=q.points[q.index];if(!j){ce.delete(Z),bn(sr("pathArrive",ee));continue}var re=Ai(ee),pe=j.x-re.x,be=j.y-re.y,xe=Math.hypot(pe,be),Ee=q.speed*c;xe<=Ee?(Lr(ee,j.x,j.y),q.index++):xe>.001&&Lr(ee,re.x+pe/xe*Ee,re.y+be/xe*Ee)}}catch(he){E={error:he}}finally{try{Q&&!Q.done&&(C=V.return)&&C.call(V)}finally{if(E)throw E.error}}}function Kg(c,x,I){var E,C,U=[],L=[],W=function(Z){var q=b.get(Z.componentId),ee=Z.parameters.dragMode==="anywhere"?Pi(q).find(function(pe){return gi(pe)}):I.find(function(pe){var be;return((be=pe.prototypeId)!==null&&be!==void 0?be:pe.id)===q.id});if(!ee)return"continue";if(Z.kind==="swipe-input")L.push({behavior:Z,c:ee});else{var j=Z.parameters,re=Math.max(j.min,Math.min(j.max,Number(K[j.variableId])));K[j.variableId]=re,U.push({behavior:Z,c:ee,charge:bm(j,re)}),bn(sr("holdStart",ee))}};try{for(var V=Be(n.gameplay.filter(function(Z){var q;return["swipe-input","hold-charge"].includes(Z.kind)&&((q=b.get(Z.componentId))===null||q===void 0?void 0:q.sceneId)===X})),Q=V.next();!Q.done;Q=V.next()){var B=Q.value;W(B)}}catch(Z){E={error:Z}}finally{try{Q&&!Q.done&&(C=V.return)&&C.call(V)}finally{if(E)throw E.error}}(U.length||L.length)&&(Ye={pointerId:c.pointerId,start:x,current:x,holds:U,swipes:L})}function Qg(c,x){var I,E,C,U,L,W,V,Q;if(!(!Ye||Ye.pointerId!==c.pointerId)){var B=Ye,Z=new Set;Ye=void 0;try{for(var q=Be(et(et([],Oe(B.holds),!1),Oe(B.swipes),!1)),ee=q.next();!ee.done;ee=q.next()){var j=ee.value,re=j.behavior,pe=j.c;Z.has(re.componentId)||(Z.add(re.componentId),bn(sr("pointerUp",pe,void 0,{targetId:pe.id,pointerId:c.pointerId})))}}catch(Ve){I={error:Ve}}finally{try{ee&&!ee.done&&(E=q.return)&&E.call(q)}finally{if(I)throw I.error}}try{for(var be=Be(B.holds),xe=be.next();!xe.done;xe=be.next()){var Ee=xe.value,he=Ee.behavior.parameters;if(bn(sr("holdRelease",Ee.c)),he.resetOnRelease!==!1){var Me=K[he.variableId];K[he.variableId]=he.min,Me!==he.min&&bn({kind:"variableChange",variableId:he.variableId,selfInstanceId:(V=Ee.c.instanceId)!==null&&V!==void 0?V:Ee.c.id,instanceId:Ee.c.instanceId})}}}catch(Ve){C={error:Ve}}finally{try{xe&&!xe.done&&(U=be.return)&&U.call(be)}finally{if(C)throw C.error}}try{for(var me=Be(B.swipes),Ue=me.next();!Ue.done;Ue=me.next()){var Fe=Ue.value,it=Sm(B.start,x,Fe.behavior.parameters.minDistancePx,(Q=Ei.get(Fe.behavior.id))!==null&&Q!==void 0?Q:-1/0,fe*1e3,Fe.behavior.parameters.cooldownMs);it&&(Ei.set(Fe.behavior.id,fe*1e3),bn(sr("swipe",Fe.c,void 0,{direction:it})))}}catch(Ve){L={error:Ve}}finally{try{Ue&&!Ue.done&&(W=me.return)&&W.call(me)}finally{if(L)throw L.error}}return Z}}function jg(c,x,I){var E,C,U;if(I.some(function(re){return re.contract==="native.button.v1"&&Yt(re).enabled}))return!1;try{for(var L=Be(n.gameplay.filter(function(re){var pe;return re.kind==="virtual-joystick"&&((pe=b.get(re.componentId))===null||pe===void 0?void 0:pe.sceneId)===X})),W=L.next();!W.done;W=L.next()){var V=W.value,Q=b.get(V.componentId);if(gi(Q)){var B=ve.get(V.id);if(!(B&&B.pointerId!==null)){var Z=ei(kr(ai(Q)),x.x,x.y),q=Yt(Q);if(!(Z.x<0||Z.y<0||Z.x>q.width||Z.y>q.height)){var ee=V.parameters.mode==="floating"?bt({},x):Ai(Q),j=Qf(ee,x,V.parameters.radiusPx,V.parameters.deadZone);return B=bt({behavior:V,c:Q,pointerId:c.pointerId,origin:ee,current:x},j),ve.set(V.id,B),Wi(B),bn(sr("joystickStart",Q)),(U=e.setPointerCapture)===null||U===void 0||U.call(e,c.pointerId),!0}}}}}catch(re){E={error:re}}finally{try{W&&!W.done&&(C=L.return)&&C.call(L)}finally{if(E)throw E.error}}return!1}var im=function(c){var x,I,E,C,U,L,W,V,Q,B,Z,q,ee;Y();var j=iu(c),re=Rl(j);if(Dt=j,!(!re&&f)){if(f){re&&(ie=re.c.id,M((U=re.c.prototypeId)!==null&&U!==void 0?U:re.c.id));return}var pe=n.gameplay.some(function(ut){return ut.kind==="virtual-joystick"||ut.kind==="fps-controller-3d"});if(!(!c.isTrusted||c.button!==void 0&&c.button!==0||!pe&&c.isPrimary===!1||ke||Bt||!pe&&(nt&&nt.pointerId!==c.pointerId||Ye&&Ye.pointerId!==c.pointerId||de&&de.pointerId!==c.pointerId||Ge&&Ge.pointerId!==c.pointerId)||_&&(!rt||!Lt))){var be=!ht;Ie=fe,ot=!0,ht=!0,zf(!0),be&&!tt&&(qe=ft=0,Dr());var xe=re?Pl(re.c):[];if(jg(c,j,xe)){qe=ft=0,tt=!1,Dr(),Si();return}if(Yg(c,j,xe)){Dr(),Si();return}Kg(c,j,xe);var Ee=Et&&!xe.some(function(ut){return ut.contract==="native.button.v1"})?n.gameplay.find(function(ut){var dt;return ut.kind==="aim-launch-3d"&&((dt=b.get(ut.componentId))===null||dt===void 0?void 0:dt.sceneId)===X}):void 0;if(Ee){var he=b.get(Ee.componentId),Me=si("physics-3d",he.id),me=Me?ks(he,Me):void 0,Ue=Gs(he.id),Fe=Ee.parameters.dragMode==="anywhere"||Ue&&Math.hypot(j.x-Ue.x,j.y-Ue.y)<=Ee.parameters.hitRadiusPx;if(me&&me.atRest&&!me.captured&&Fe){Ge={behavior:Ee,targetId:he.id,sourceId:he.id,stageId:Ee.parameters.stageId,pointerId:c.pointerId,start:j,current:j,power:0},eu(j),(L=e.setPointerCapture)===null||L===void 0||L.call(e,c.pointerId);return}}var it=xe.some(function(ut){return ut.contract==="native.button.v1"&&Yt(ut).enabled}),Ve=it||xe.some(function(ut){return n.events.some(function(dt){var In;return dt.kind==="click"&&dt.componentId===((In=ut.prototypeId)!==null&&In!==void 0?In:ut.id)})});if(Et&&!it){var Ze=n.gameplay.find(function(ut){var dt;return ut.kind==="fps-controller-3d"&&((dt=b.get(ut.componentId))===null||dt===void 0?void 0:dt.sceneId)===X});if(Ze){var At=b.get(Ze.componentId),Nt=ei(kr(ai(At)),j.x,j.y),Jt=Yt(At);if(Xn.has(At.id)||Nt.x>=0&&Nt.y>=0&&Nt.x<=Jt.width&&Nt.y<=Jt.height){var Wt=n.events.some(function(ut){return ut.kind==="click"&&ut.componentId===At.id});if(!Yn&&Ze.parameters.lookMode!=="none"&&(Bn(Ze),Yn={pointerId:c.pointerId,stageId:At.id,behavior:Ze,last:j},(W=e.setPointerCapture)===null||W===void 0||W.call(e,c.pointerId)),Wt){qe=ft=0,tt=!1,bn({kind:"click",componentId:At.id,targetId:At.id,pointerId:c.pointerId}),Dr(),Si();return}if(!Ve)return}}}var Ut=n.gameplay.find(function(ut){return ut.kind==="aim-launch"&&b.get(ut.componentId).sceneId===X&&(ut.parameters.dragMode==="anywhere"&&!xe.some(function(dt){return dt.contract==="native.button.v1"})||xe.some(function(dt){var In;return((In=dt.prototypeId)!==null&&In!==void 0?In:dt.id)===ut.componentId}))});if(Ut){var Mt=b.get(Ut.componentId),wt=(V=xe.find(function(dt){var In;return((In=dt.prototypeId)!==null&&In!==void 0?In:dt.id)===Mt.id}))!==null&&V!==void 0?V:Pi(Mt).find(function(dt){return gi(dt)}),me=wt&&Na(wt,si("physics-body",Mt.id));if(me&&(!Ut.parameters.onlyWhenAtRest||me.atRest)){de={behavior:Ut,targetId:wt.id,sourceId:Mt.id,pointerId:c.pointerId,start:j,current:j,power:0},nm(j),(Q=e.setPointerCapture)===null||Q===void 0||Q.call(e,c.pointerId),Si();return}}try{for(var Tt=Be(xe),St=Tt.next();!St.done;St=Tt.next()){var ze=St.value,je=si("press-feedback",(B=ze.prototypeId)!==null&&B!==void 0?B:ze.id);je&&(ze.contract!=="native.button.v1"||Yt(ze).enabled)&&$t.set(ze.id,{behavior:je.parameters,pointerId:c.pointerId,held:!0})}}catch(ut){x={error:ut}}finally{try{St&&!St.done&&(I=Tt.return)&&I.call(Tt)}finally{if(x)throw x.error}}var gt=xe.find(function(ut){var dt;return((dt=ln.get(ut.id))===null||dt===void 0?void 0:dt.sceneId)===X});if(gt){var $e=En.get(gt.parentId);if($e?.snapshot().busy)return;Cg(gt),$e&&!$e.snapshot().busy&&(nn={pointerId:c.pointerId,boardId:gt.parentId,tileId:gt.id,start:j},(Z=e.setPointerCapture)===null||Z===void 0||Z.call(e,c.pointerId))}ue=(q=xe.find(function(ut){return ut.contract==="native.button.v1"&&Yt(ut).enabled}))===null||q===void 0?void 0:q.id,hn=ue?c.pointerId:void 0;var Pt=n.gameplay.find(function(ut){return ut.kind==="drag"&&xe.some(function(dt){var In;return((In=dt.prototypeId)!==null&&In!==void 0?In:dt.id)===ut.componentId})});if(Pt){var ze=xe.find(function(dt){var In;return((In=dt.prototypeId)!==null&&In!==void 0?In:dt.id)===Pt.componentId}),Ft=Ai(ze),mn=rn.zoneOf(ze.id);Wn.set(ze.id,Ft),rn.release(ze.id),nt={b:Pt,targetId:ze.id,start:j,current:j,origin:Ft,originZone:mn,m:et([],Oe(Nn(ze)),!1),pointerId:c.pointerId},bn(sr("dragStart",ze)),e.setPointerCapture(c.pointerId)}qe=ft=0,tt=!1;try{for(var Xt=Be(xe),vn=Xt.next();!vn.done;vn=Xt.next()){var ze=vn.value;(ze.contract!=="native.button.v1"||Yt(ze).enabled)&&bn({kind:"click",componentId:(ee=ze.prototypeId)!==null&&ee!==void 0?ee:ze.id,instanceId:ze.instanceId,targetId:ze.id,pointerId:c.pointerId})}}catch(ut){E={error:ut}}finally{try{vn&&!vn.done&&(C=Xt.return)&&C.call(Xt)}finally{if(E)throw E.error}}Dr(),Si()}}};function rm(c,x){if(!nn||nn.pointerId!==c.pointerId)return!1;if(!c.isTrusted||!rr())return!0;var I=nn,E=En.get(I.boardId);if(E.snapshot().busy)return nn=void 0,!0;var C=kr(ai(b.get(I.boardId))),U=ei(C,I.start.x,I.start.y),L=ei(C,x.x,x.y),W=L.x-U.x,V=L.y-U.y,Q=b.get(I.tileId);if(Math.max(Math.abs(W),Math.abs(V))<Math.min(Q.parameters.width,Q.parameters.height)*.35)return!0;var B=ln.get(Q.id),Z=Math.abs(W)>Math.abs(V),q=B.row+(Z?0:Math.sign(V)),ee=B.column+(Z?Math.sign(W):0),j=et([],Oe(ln),!1).find(function(re){var pe=Oe(re,2),be=pe[1];return be.boardId===I.boardId&&be.row===q&&be.column===ee});return j&&E.swap(Q.id,j[0])&&(Qt=void 0,Si()),nn=void 0,!0}var am=function(c){var x,I,E,C;if(!ke){Y();var U=H(),L=iu(c);Dt=L,Ye?.pointerId===c.pointerId&&(Ye.current=L);var W=function(Mt){var wt,Tt;if(Mt.pointerId===c.pointerId){var St=L.x-Mt.current.x,ze=L.y-Mt.current.y;if(c.isTrusted&&rr())try{for(var je=(wt=void 0,Be(n.gameplay.filter(function(Pt){var Ft,mn;return Pt.kind==="fps-controller-3d"&&Pt.parameters.aimJoystickBehaviorId===Mt.behavior.id&&((Ft=Pt.parameters.aimMode)!==null&&Ft!==void 0?Ft:"delta")==="delta"&&((mn=b.get(Pt.componentId))===null||mn===void 0?void 0:mn.sceneId)===X}))),gt=je.next();!gt.done;gt=je.next()){var $e=gt.value;ja($e,St,ze)}}catch(Pt){wt={error:Pt}}finally{try{gt&&!gt.done&&(Tt=je.return)&&Tt.call(je)}finally{if(wt)throw wt.error}}return Object.assign(Mt,{current:L},Qf(Mt.origin,L,Mt.behavior.parameters.radiusPx,Mt.behavior.parameters.deadZone)),Wi(Mt),Si(),{value:void 0}}};try{for(var V=Be(ve.values()),Q=V.next();!Q.done;Q=V.next()){var B=Q.value,Z=W(B);if(typeof Z=="object")return Z.value}}catch(Mt){x={error:Mt}}finally{try{Q&&!Q.done&&(I=V.return)&&I.call(V)}finally{if(x)throw x.error}}if(_t?.pointerId===c.pointerId){if(_t.kind==="mask"){var q=_t,ee=ei(kr(ai(q.c)),L.x,L.y);Ua(q.c,q.behavior).stampSegment(q.last,ee),q.last=ee}else Zg(L,_t);Dr(),Si();return}if(Yn?.pointerId===c.pointerId){c.isTrusted&&rr()&&(ja(Yn.behavior,L.x-Yn.last.x,L.y-Yn.last.y),Yn.last=L,Si());return}if(Ge?.pointerId===c.pointerId){c.isTrusted&&rr()&&eu(L);return}if(de?.pointerId===c.pointerId){c.isTrusted&&rr()&&nm(L),Si();return}var j=Rl(L);if(on=j?(E=Pl(j.c).find(function(Mt){return Mt.contract==="native.button.v1"}))===null||E===void 0?void 0:E.id:void 0,!rm(c,L)&&!(!nt||nt.pointerId!==c.pointerId)){var re=vt(nt.targetId);if(!re){Ki();return}var pe=re.parentId?ai(vt(re.parentId)):za(),be=kr(pe),xe=ei(be,nt.start.x,nt.start.y),Ee=ei(be,L.x,L.y),he=et([],Oe(nt.m),!1),Me=nt.b.parameters.axis;if(Me!=="y"){var me=nt.m[4]+Ee.x-xe.x;Number.isFinite(nt.b.parameters.minX)&&(me=Math.max(nt.b.parameters.minX,me)),Number.isFinite(nt.b.parameters.maxX)&&(me=Math.min(nt.b.parameters.maxX,me)),he[4]=me}if(Me!=="x"){var Ue=nt.m[5]+Ee.y-xe.y;Number.isFinite(nt.b.parameters.minY)&&(Ue=Math.max(nt.b.parameters.minY,Ue)),Number.isFinite(nt.b.parameters.maxY)&&(Ue=Math.min(nt.b.parameters.maxY,Ue)),he[5]=Ue}if(!re.parentId)Me!=="y"&&(he[4]=Math.max(0,Math.min(U.width-re.parameters.width,he[4])));else{var Fe=Mr(re,Io(pe,he)),it=0;Fe.left<0||Fe.right-Fe.left>U.width?it=-Fe.left:Fe.right>U.width&&(it=U.width-Fe.right);var Ve=Me==="y"?0:pe[0],Ze=Me==="x"?0:pe[2];Math.abs(Ve)>=Math.abs(Ze)&&Math.abs(Ve)>1e-8?he[4]+=it/Ve:Math.abs(Ze)>1e-8&&(he[5]+=it/Ze)}var At=(C=te.get(re.id))!==null&&C!==void 0?C:{parameters:{}};te.set(re.id,bt(bt({},At),{transform:he})),nt.current=L;var Nt=Df(re),Jt=Nt.zones,Wt=Nt.tag,Ut=pu({itemId:re.id,tag:Wt,zones:Jt,occupancy:rn});Rt=Ut&&Ut.kind!=="reject"?Ut.zone:void 0}}},sm=function(c){var x,I,E,C,U;Y();var L=iu(c),W=Ae;Dt=L,jn(c.pointerId,!0),$n(c.pointerId),Jg(c);var V=(E=Qg(c,L))!==null&&E!==void 0?E:new Set;if(Rg(c),c.isTrusted&&rr()){var Q=Rl(L);try{for(var B=Be(Q?Pl(Q.c):[]),Z=B.next();!Z.done;Z=B.next()){var q=Z.value;!V.has((C=q.prototypeId)!==null&&C!==void 0?C:q.id)&&(q.contract!=="native.button.v1"||Yt(q).enabled)&&bn(sr("pointerUp",q,void 0,{targetId:q.id,pointerId:c.pointerId}))}}catch(xe){x={error:xe}}finally{try{Z&&!Z.done&&(I=B.return)&&I.call(B)}finally{if(x)throw x.error}}}if(Dr(),Si(),Ge?.pointerId===c.pointerId){var ee=Ge,j=Il(),re=Ht.get(ee.targetId);(U=Et?.getStage(b.get(ee.stageId)))===null||U===void 0||U.setGuide([]),Ge=void 0,ee.behavior.parameters.powerVariableId&&(K[ee.behavior.parameters.powerVariableId]=0);var pe=Math.hypot(j.vx,j.vz);c.isTrusted&&zf(!0),re&&c.isTrusted&&rr()&&j.pull>=ee.behavior.parameters.minPullPx&&pe>=ee.behavior.parameters.minSpeed&&(re.vx=j.vx,re.vy=0,re.vz=j.vz,re.atRest=!1,re.restElapsed=0,re.movingTime=0,re.captured=!1,re.lastSafe={x:re.x,y:re.y,z:re.z},bn({kind:"launch",componentId:ee.sourceId})),Mi(c),Dr();return}if(de?.pointerId===c.pointerId){var ee=de,j=kf(),re=kn.get(ee.targetId);de=void 0,ee.behavior.parameters.powerVariableId&&(K[ee.behavior.parameters.powerVariableId]=0),re&&c.isTrusted&&rr()&&j.pull>=ee.behavior.parameters.minPullPx&&(re.vx=j.vx,re.vy=j.vy,re.atRest=!1,re.restElapsed=0,re.captured=!1,re.exited=!1,bn({kind:"launch",componentId:ee.sourceId,instanceId:re.instanceId})),Mi(c),Dr(),Si();return}if(rm(c,L),nn?.pointerId===c.pointerId&&(nn=void 0),Mi(c),!(P||W?.pointerId!==c.pointerId||!c.isTrusted||!rr()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!vo(W.condition))){var be=Rl(L);!be||!Pl(be.c).some(function(xe){return xe.id===W.targetId&&(xe.contract!=="native.button.v1"||Yt(xe).enabled)})||(_?_.openStore(n.base.storeUrl):window.open(n.base.storeUrl,"_blank","noopener"))}},ru=function(c){var x,I;if(Ge?.pointerId===c.pointerId&&Vn(c.pointerId),Yn?.pointerId===c.pointerId&&$n(c.pointerId),jn(c.pointerId,!0),de?.pointerId===c.pointerId&&(de.behavior.parameters.powerVariableId&&(K[de.behavior.parameters.powerVariableId]=0),de=void 0),nn?.pointerId===c.pointerId&&(nn=void 0),_t?.pointerId===c.pointerId&&(_t.kind==="stroke"&&_t.store.cancel(),_t=void 0),Ye?.pointerId===c.pointerId){try{for(var E=Be(Ye.holds),C=E.next();!C.done;C=E.next()){var U=C.value;U.behavior.parameters.resetOnRelease!==!1&&(K[U.behavior.parameters.variableId]=U.behavior.parameters.min)}}catch(L){x={error:L}}finally{try{C&&!C.done&&(I=E.return)&&I.call(E)}finally{if(x)throw x.error}}Ye=void 0}Mi(c)},om=function(c){c?.isTrusted&&!f&&!ke&&!Bt&&zf(!0)},Vf=function(){qt||Si()},gs=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver(Vf):void 0;try{(s=gs?.observe)===null||s===void 0||s.call(gs,e)}catch{}var lm=function(){We=0,Qe=0,document.hidden&&ar(),Ke&&(document.hidden?Ke.suspend().catch(function(){}):!ke&&ht&&So())};document.addEventListener("visibilitychange",lm),(o=globalThis.addEventListener)===null||o===void 0||o.call(globalThis,"resize",Vf),e.addEventListener("pointerdown",im),e.addEventListener("pointermove",am),e.addEventListener("pointerup",sm),e.addEventListener("pointercancel",ru),e.addEventListener("lostpointercapture",ru),e.addEventListener("click",om);var Gf=_?.onVisibilityChanged(function(c){Lt=c,We=0,Qe=0,c||ar(),Ke&&(c?!ke&&ht&&So():Ke.suspend().catch(function(){}))}),Hf=_?.onClosed(function(){Bt=!0,We=0,Qe=0,ar(),Ni()}),Wf=(u=_?.onVolumeChanged)===null||u===void 0?void 0:u.call(_,function(c){typeof c=="number"&&Number.isFinite(c)&&c>=0&&(yn=Math.min(1,c>1?c/100:c),Lf())}),Sr,ts;function cm(c){var x=!f&&!ke&&!document.hidden&&rt&&Lt&&!Bt;if(x&&Qe&&(Ne+=Math.min((c-Qe)/1e3,5/60)),rr()){qe=ft=0,tt=!1,Qe&&(We+=Math.min((c-Qe)/1e3,5/60));for(var I=0;I<5&&We>=1/60;I++)ts?.(),em(1/60),We-=1/60;Dr(),Sr?.()&&(ke=!0,Sr=void 0,ts=void 0)}else We=0;Qe=c,Si(),gn=requestAnimationFrame(cm)}Mo(),f&&(X=p),Si(),gn=requestAnimationFrame(cm),_&&_.init().then(function(){qt||(rt=!0,Lt=_.isVisible(),We=0,Qe=0)}).catch(function(){qt||(Bt=!0,ar(),Ni())});var ey=P?{freezeReview:function(){ke=!0,Sr=void 0,ts=void 0,We=0,Qe=0,nr(),Ki(),nn=void 0,Ke?.suspend().catch(function(){}),Si()},seekReview:function(c,x){var I,E,C,U,L=x===void 0?{}:x,W=L.motion,V=W===void 0?!1:W,Q=L.trustedEvent;ke=!0,Sr=void 0,ts=void 0,Mo();var B=En.get("harvest.board"),Z=V&&Q instanceof globalThis.Event&&Q.isTrusted,q=function(){var ze=Ke;Ke=void 0;try{qe=ft=0,tt=!1,em(1/60),Dr()}finally{Ke=ze}},ee=function(){var ze;if(Z)try{var je=(ze=globalThis.AudioContext)!==null&&ze!==void 0?ze:globalThis.webkitAudioContext;je&&(Ke??(Ke=new je)),So()}catch{}We=0,Qe=0,ke=!1,Si()};if(b.has("salvage.ship")&&Object.hasOwn(K,"salvage.phase")){if(!["opening","first-catch","end-card","timeout"].includes(c))throw Error("Review moment unavailable");var j=b.get("salvage.ship"),re=function(ze){var je,gt=ge.filter(function(Ft){return Ft.prototypeId.startsWith("salvage.core")}).sort(function(Ft,mn){return mn.transform[5]-Ft.transform[5]})[0],$e=te.get(j.id),Pt=et([],Oe((je=$e?.transform)!==null&&je!==void 0?je:j.transform),!1);Pt[4]=ze&>?Math.max(20,Math.min(306,gt.transform[4]-8)):20,te.set(j.id,bt(bt({},$e),{transform:Pt,parameters:bt(bt({},$e?.parameters),{visible:ze})}))},pe,be,xe=function(){return K["salvage.phase"]!=="cta"?!1:(pe??(pe=fe),fe-pe>=.65)};if(c==="opening"){if(V){Sr=function(){return fe>=4},ee();return}Si();return}if(c==="timeout"){var Ee=(I=n.gameplay.find(function(ze){return ze.id==="salvage.deadline"}))===null||I===void 0?void 0:I.parameters.seconds;if(!Number.isFinite(Ee))throw Error("Timeout replay unavailable");if(re(!1),V){for(;fe<Ee-.25&&K["salvage.phase"]!=="cta";)re(!1),q();if(K["salvage.phase"]==="cta")throw Error("Timeout replay unavailable");ts=function(){K["salvage.phase"]!=="cta"&&re(!1)},Sr=function(){return xe()||fe>=Ee+1},ee();return}for(var he=0;K["salvage.phase"]!=="cta"&&he<3600;he++)re(!1),q();if(K["salvage.phase"]!=="cta")throw Error("Timeout card unavailable");Si();return}var Me=c==="first-catch"?1:3;if(V){for(var he=0;K["salvage.catches"]<Me-1&&he<3600;he++)re(!0),q();if(K["salvage.catches"]!==Me-1)throw Error("Review replay unavailable");ts=function(){K["salvage.catches"]<Me&&re(!0)},Sr=function(){return Me===1&&K["salvage.catches"]>=1?(be??(be=fe),fe-be>=1):Me===3&&xe()||fe>=20},ee();return}for(var he=0;K["salvage.catches"]<Me&&he<3600;he++)re(!0),q();if(K["salvage.catches"]!==Me)throw Error("Review catch unavailable");if(Me===1)for(var he=0;he<84;he++)q();else{for(var he=0;K["salvage.phase"]!=="cta"&&he<300;he++)q();if(K["salvage.phase"]!=="cta")throw Error("End card unavailable")}Si();return}if(!B){if(!["opening","first-input","end-card","timeout"].includes(c))throw Error("Review moment unavailable");if(c==="opening"){V?(Sr=function(){return fe>=4},ee()):Si();return}var me=n.gameplay.find(function(ze){return ze.kind==="aim-launch"&&b.get(ze.componentId).sceneId===X}),Ue=n.gameplay.find(function(ze){return ze.kind==="aim-launch-3d"&&b.get(ze.componentId).sceneId===X}),Fe=n.events.find(function(ze){var je;return ze.kind==="click"&&((je=b.get(ze.componentId))===null||je===void 0?void 0:je.sceneId)===X&&n.eventBindings.some(function(gt){return gt.eventId===ze.id})}),it=function(){var ze,je;if(Ue){var gt=b.get(Ue.componentId),$e=si("physics-3d",gt.id),Pt=ks(gt,$e),Ft=n.gameplay.find(function(Kn){return Kn.kind==="capture-zone-3d"&&b.get(Kn.componentId).sceneId===X}),mn=0,Xt=-Ue.parameters.maxSpeed*.45;if(Ft){var vn=b.get(Ft.componentId),ut=Yt(vn),dt=((ze=ut.x)!==null&&ze!==void 0?ze:0)-Pt.x,In=((je=ut.z)!==null&&je!==void 0?je:0)-Pt.z,Ii=Math.hypot(dt,In)||1;mn=dt/Ii*Ue.parameters.maxSpeed*.55,Xt=In/Ii*Ue.parameters.maxSpeed*.55}Pt.vx=mn,Pt.vy=0,Pt.vz=Xt,Pt.atRest=!1,Pt.restElapsed=0,Pt.movingTime=0,Pt.lastSafe={x:Pt.x,y:Pt.y,z:Pt.z},bn({kind:"launch",componentId:gt.id}),Dr();return}if(me){var gt=b.get(me.componentId),fi=Pi(gt)[0],Pt=Na(fi,si("physics-body",gt.id)),Ft=n.gameplay.find(function(Qi){return Qi.kind==="capture-zone"&&b.get(Qi.componentId).sceneId===X}),mn=me.parameters.maxSpeed*.45,ui=0;if(Ft){var vn=b.get(Ft.componentId),Gn=ei(ai(vn),Yt(vn).width/2,Yt(vn).height/2),dt=Gn.x-Pt.x,hi=Gn.y-Pt.y,oi=Math.hypot(dt,hi)||1;mn=dt/oi*me.parameters.maxSpeed*.45,ui=hi/oi*me.parameters.maxSpeed*.45}Pt.vx=mn,Pt.vy=ui,Pt.atRest=!1,Pt.restElapsed=0,bn({kind:"launch",componentId:gt.id,instanceId:fi.instanceId})}else if(Fe)bn({kind:"click",componentId:Fe.componentId,targetId:Fe.componentId});else throw Error("Review primary input unavailable");Dr()};if(c==="first-input"){if(it(),V)Sr=function(){return fe>=2},ee();else{for(var he=0;he<60;he++)q();Si()}return}c==="end-card"&&it();var Ve=c==="timeout"?Math.min(60,Math.max(1,(C=(E=n.gameplay.find(function(ze){return ze.kind==="timer"}))===null||E===void 0?void 0:E.parameters.seconds)!==null&&C!==void 0?C:10)):60,Ze=function(){var ze;return((ze=n.scenes.find(function(je){return je.id===X}))===null||ze===void 0?void 0:ze.role)==="end-card"},At=function(){var ze,je;return c==="timeout"?(ze=n.scenes.find(function(gt){return gt.role==="end-card"&&/fail|loss|timeout/i.test(gt.id)}))!==null&&ze!==void 0?ze:n.scenes.find(function(gt){return gt.role==="end-card"}):(je=n.scenes.find(function(gt){return gt.role==="end-card"&&!/fail|loss|timeout/i.test(gt.id)}))!==null&&je!==void 0?je:n.scenes.find(function(gt){return gt.role==="end-card"})};if(V){Sr=function(){return Ze()&&fe>=1||fe>=Ve+1},ee();return}for(var he=0;he<Ve*60&&!Ze();he++)q();if(!Ze()||c==="timeout"&&!/fail|loss|timeout/i.test(X)||c==="end-card"&&/fail|loss|timeout/i.test(X)){var Nt=At();if(!Nt)throw Error("End card unavailable");X=Nt.id,de=void 0,ar(),bn({kind:"sceneEnter",sceneId:X}),Dr()}for(var he=0;he<45;he++)q();Si();return}var Jt,Wt=function(){return K["harvest.phase"]!=="cta"?!1:(Jt??(Jt=fe),fe-Jt>=.65)};if(c==="opening"&&V&&(Sr=function(){return fe>=7},We=0,Qe=0,ke=!1),c==="timeout"){if(!B)throw Error("Review moment unavailable");if(V){var Ut=(U=n.gameplay.find(function(ze){return ze.id==="harvest.deadline"}))===null||U===void 0?void 0:U.parameters.seconds;if(!Number.isFinite(Ut))throw Error("Timeout replay unavailable");for(;fe<Ut-.25&&K["harvest.phase"]!=="cta";)q();if(K["harvest.phase"]==="cta")throw Error("Timeout replay unavailable");Sr=function(){return Wt()||fe>=Ut+1},ee();return}for(var he=0;K["harvest.phase"]!=="cta"&&he<3600;he++)q();if(K["harvest.phase"]!=="cta")throw Error("Timeout card unavailable")}else if(c!=="opening"){if(!B||!["first-harvest","end-card"].includes(c))throw Error("Review moment unavailable");for(var Mt=c==="first-harvest"?1:3,wt=function(ze){var je=B.snapshot().legalMoves[0];if(!je||!B.swap(je.from,je.to))throw Error("Review move unavailable");if(V&&ze===Mt-1){var gt=fe+(Mt===1?3:8);return Sr=function(){return fe>=gt||Mt===3&&Wt()},ee(),{value:void 0}}for(var $e=0;B.snapshot().busy&&$e<240;$e++)q();if(B.snapshot().busy)throw Error("Review replay did not settle")},Tt=0;Tt<Mt;Tt++){var St=wt(Tt);if(typeof St=="object")return St.value}if(Mt===1)for(var he=0;he<84;he++)q();else{for(var he=0;K["harvest.phase"]!=="cta"&&he<300;he++)q();if(K["harvest.phase"]!=="cta")throw Error("End card unavailable")}}Si()},pickReview:function(c,x){var I=Rl(iu({clientX:c,clientY:x}));return I?Pl(I.c).map(function(E){var C;return(C=E.prototypeId)!==null&&C!==void 0?C:E.id}):[]},reviewBounds:function(c){var x=H(),I=e.clientWidth,E=e.clientHeight,C=Math.min(I/x.width,E/x.height);return ye.filter(function(U){return c.includes(U.c.id)}).map(function(U){var L=Mr(U.c,U.m);return{left:(I-x.width*C)/2+L.left*C,top:(E-x.height*C)/2+L.top*C,width:(L.right-L.left)*C,height:(L.bottom-L.top)*C}})}}:void 0;return bt(bt({},ey),{state:Da,auditViewport:Hg,auditSceneLayout:Wg,restart:function(){var c;Sr=void 0,ts=void 0,(c=_?.notifyGameRetry)===null||c===void 0||c.call(_),Mo(),Si()},select:function(c){ie=c},inspectScene:function(c){f&&n.scenes.some(function(x){return x.id===c})&&(X=c,ie=void 0)},pause:function(c){ke=c,We=0,Qe=0,c&&ar(),Ke&&(c?Ke.suspend().catch(function(){}):ht&&So())},destroy:function(){var c,x;qt=!0,cancelAnimationFrame(gn),ar(),Ni(),Et?.dispose(),Gf?.(),Hf?.(),Wf?.(),_?.destroy(),(c=gs?.disconnect)===null||c===void 0||c.call(gs),document.removeEventListener("visibilitychange",lm),(x=globalThis.removeEventListener)===null||x===void 0||x.call(globalThis,"resize",Vf),e.removeEventListener("pointerdown",im),e.removeEventListener("pointermove",am),e.removeEventListener("pointerup",sm),e.removeEventListener("pointercancel",ru),e.removeEventListener("lostpointercapture",ru),e.removeEventListener("click",om),Ke?.close().catch(function(){})}})}return py(n1);})();
|