shieldcortex 2.4.21 → 2.4.23

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.
Files changed (51) hide show
  1. package/dashboard/.next/standalone/dashboard/.next/BUILD_ID +1 -1
  2. package/dashboard/.next/standalone/dashboard/.next/build-manifest.json +2 -2
  3. package/dashboard/.next/standalone/dashboard/.next/prerender-manifest.json +3 -3
  4. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.html +2 -2
  5. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.rsc +1 -1
  6. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.html +1 -1
  13. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.rsc +10 -10
  14. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +10 -10
  15. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +3 -3
  16. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +6 -6
  17. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  18. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  19. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/dashboard/.next/standalone/dashboard/.next/server/app/index.html +1 -1
  21. package/dashboard/.next/standalone/dashboard/.next/server/app/index.rsc +5 -5
  22. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  23. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_full.segment.rsc +5 -5
  24. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_head.segment.rsc +1 -1
  25. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_index.segment.rsc +4 -4
  26. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  27. package/dashboard/.next/standalone/dashboard/.next/server/app/page/react-loadable-manifest.json +3 -3
  28. package/dashboard/.next/standalone/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
  29. package/dashboard/.next/standalone/dashboard/.next/server/chunks/ssr/dashboard_25b1b286._.js +1 -1
  30. package/dashboard/.next/standalone/dashboard/.next/server/pages/404.html +1 -1
  31. package/dashboard/.next/standalone/dashboard/.next/server/pages/500.html +2 -2
  32. package/dashboard/.next/standalone/dashboard/.next/server/server-reference-manifest.js +1 -1
  33. package/dashboard/.next/standalone/dashboard/.next/server/server-reference-manifest.json +1 -1
  34. package/dashboard/.next/standalone/dashboard/.next/static/chunks/0327af3bf4830eac.js +842 -0
  35. package/dashboard/.next/standalone/dashboard/.next/static/chunks/21c4fc7176fbe8ee.js +1 -0
  36. package/dashboard/.next/standalone/dashboard/.next/static/chunks/511275d9224bafb2.js +9 -0
  37. package/dashboard/.next/standalone/dashboard/.next/static/chunks/8e559e67e3d8782b.css +3 -0
  38. package/dashboard/.next/standalone/dashboard/.next/static/chunks/e007ff86847a4042.js +1 -0
  39. package/dist/api/visualization-server.d.ts.map +1 -1
  40. package/dist/api/visualization-server.js +100 -2
  41. package/dist/api/visualization-server.js.map +1 -1
  42. package/package.json +1 -1
  43. package/scripts/pre-compact-hook.mjs +56 -2
  44. package/dashboard/.next/standalone/dashboard/.next/static/chunks/407e39ab7e5d1d65.js +0 -842
  45. package/dashboard/.next/standalone/dashboard/.next/static/chunks/411ad30d41e2dba1.js +0 -1
  46. package/dashboard/.next/standalone/dashboard/.next/static/chunks/5b58941ef74d514c.js +0 -9
  47. package/dashboard/.next/standalone/dashboard/.next/static/chunks/8455c2995c6bc094.css +0 -3
  48. package/dashboard/.next/standalone/dashboard/.next/static/chunks/877441708af3b745.js +0 -1
  49. /package/dashboard/.next/standalone/dashboard/.next/static/{wS8cNlRVsGIHZycdxH6Pz → Ykr04kZxo_ae93TlaBU55}/_buildManifest.js +0 -0
  50. /package/dashboard/.next/standalone/dashboard/.next/static/{wS8cNlRVsGIHZycdxH6Pz → Ykr04kZxo_ae93TlaBU55}/_clientMiddlewareManifest.json +0 -0
  51. /package/dashboard/.next/standalone/dashboard/.next/static/{wS8cNlRVsGIHZycdxH6Pz → Ykr04kZxo_ae93TlaBU55}/_ssgManifest.js +0 -0
@@ -0,0 +1,842 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,5960,(e,t,n)=>{"use strict";var i=e.r(4),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=i.useState,s=i.useEffect,o=i.useLayoutEffect,l=i.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}var c="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),i=a({inst:{value:n,getSnapshot:t}}),r=i[0].inst,c=i[1];return o(function(){r.value=n,r.getSnapshot=t,u(r)&&c({inst:r})},[e,n,t]),s(function(){return u(r)&&c({inst:r}),e(function(){u(r)&&c({inst:r})})},[e]),l(n),n};n.useSyncExternalStore=void 0!==i.useSyncExternalStore?i.useSyncExternalStore:c},89782,(e,t,n)=>{"use strict";t.exports=e.r(5960)},75812,(e,t,n)=>{"use strict";var i=e.r(4),r=e.r(89782),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},s=r.useSyncExternalStore,o=i.useRef,l=i.useEffect,u=i.useMemo,c=i.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,i,r){var h=o(null);if(null===h.current){var d={hasValue:!1,value:null};h.current=d}else d=h.current;var p=s(e,(h=u(function(){function e(e){if(!l){if(l=!0,s=e,e=i(e),void 0!==r&&d.hasValue){var t=d.value;if(r(t,e))return o=t}return o=e}if(t=o,a(s,e))return t;var n=i(e);return void 0!==r&&r(t,n)?(s=e,t):(s=e,o=n)}var s,o,l=!1,u=void 0===n?null:n;return[function(){return e(t())},null===u?void 0:function(){return e(u())}]},[t,n,i,r]))[0],h[1]);return l(function(){d.hasValue=!0,d.value=p},[p]),c(p),p}},27688,(e,t,n)=>{"use strict";t.exports=e.r(75812)},54876,(e,t,n)=>{"use strict";function i(e,t){var n=e.length;for(e.push(t);0<n;){var i=n-1>>>1,r=e[i];if(0<s(r,t))e[i]=t,e[n]=r,n=i;else break}}function r(e){return 0===e.length?null:e[0]}function a(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;for(var i=0,r=e.length,a=r>>>1;i<a;){var o=2*(i+1)-1,l=e[o],u=o+1,c=e[u];if(0>s(l,n))u<r&&0>s(c,l)?(e[i]=c,e[u]=n,i=u):(e[i]=l,e[o]=n,i=o);else if(u<r&&0>s(c,n))e[i]=c,e[u]=n,i=u;else break}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(n.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var o,l=performance;n.unstable_now=function(){return l.now()}}else{var u=Date,c=u.now();n.unstable_now=function(){return u.now()-c}}var h=[],d=[],p=1,f=null,m=3,g=!1,v=!1,x=!1,y=!1,_="function"==typeof setTimeout?setTimeout:null,b="function"==typeof clearTimeout?clearTimeout:null,S="u">typeof setImmediate?setImmediate:null;function M(e){for(var t=r(d);null!==t;){if(null===t.callback)a(d);else if(t.startTime<=e)a(d),t.sortIndex=t.expirationTime,i(h,t);else break;t=r(d)}}function w(e){if(x=!1,M(e),!v)if(null!==r(h))v=!0,T||(T=!0,o());else{var t=r(d);null!==t&&N(w,t.startTime-e)}}var T=!1,E=-1,A=5,C=-1;function R(){return!!y||!(n.unstable_now()-C<A)}function P(){if(y=!1,T){var e=n.unstable_now();C=e;var t=!0;try{e:{v=!1,x&&(x=!1,b(E),E=-1),g=!0;var i=m;try{t:{for(M(e),f=r(h);null!==f&&!(f.expirationTime>e&&R());){var s=f.callback;if("function"==typeof s){f.callback=null,m=f.priorityLevel;var l=s(f.expirationTime<=e);if(e=n.unstable_now(),"function"==typeof l){f.callback=l,M(e),t=!0;break t}f===r(h)&&a(h),M(e)}else a(h);f=r(h)}if(null!==f)t=!0;else{var u=r(d);null!==u&&N(w,u.startTime-e),t=!1}}break e}finally{f=null,m=i,g=!1}}}finally{t?o():T=!1}}}if("function"==typeof S)o=function(){S(P)};else if("u">typeof MessageChannel){var I=new MessageChannel,L=I.port2;I.port1.onmessage=P,o=function(){L.postMessage(null)}}else o=function(){_(P,0)};function N(e,t){E=_(function(){e(n.unstable_now())},t)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(e){e.callback=null},n.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<e?Math.floor(1e3/e):5},n.unstable_getCurrentPriorityLevel=function(){return m},n.unstable_next=function(e){switch(m){case 1:case 2:case 3:var t=3;break;default:t=m}var n=m;m=t;try{return e()}finally{m=n}},n.unstable_requestPaint=function(){y=!0},n.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=m;m=e;try{return t()}finally{m=n}},n.unstable_scheduleCallback=function(e,t,a){var s=n.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?s+a:s,e){case 1:var l=-1;break;case 2:l=250;break;case 5:l=0x3fffffff;break;case 4:l=1e4;break;default:l=5e3}return l=a+l,e={id:p++,callback:t,priorityLevel:e,startTime:a,expirationTime:l,sortIndex:-1},a>s?(e.sortIndex=a,i(d,e),null===r(h)&&e===r(d)&&(x?(b(E),E=-1):x=!0,N(w,a-s))):(e.sortIndex=l,i(h,e),v||g||(v=!0,T||(T=!0,o()))),e},n.unstable_shouldYield=R,n.unstable_wrapCallback=function(e){var t=m;return function(){var n=m;m=t;try{return e.apply(this,arguments)}finally{m=n}}}},66241,(e,t,n)=>{"use strict";t.exports=e.r(54876)},28592,e=>{"use strict";let t,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g,v,x,y,_,b,S;var M,w,T,E,A,C,R=e.i(27493),P=e.i(4),I=e.i(42098),L=e.i(88069),N=e.i(87353);function D({stats:e,contradictionCount:t,quarantineCount:n,lastConsolidation:i,workerStatus:r,onClickContradictions:a,onClickQuarantine:s,onClickConsolidation:o}){let l=(e?.decayDistribution?.healthy??0)+(e?.decayDistribution?.fading??0)+(e?.decayDistribution?.critical??0),u=l>0?Math.round((e?.decayDistribution?.healthy??0)/l*100):100,c=u>70?"text-emerald-400":u>40?"text-amber-400":"text-red-400",h=e?.total??0,d=e?.totalLinks??e?.links??0;return(0,R.jsxs)("div",{className:"flex items-center h-10 px-4 bg-slate-900/80 backdrop-blur-sm border-b border-slate-800 text-sm",children:[(0,R.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,R.jsx)("span",{className:"text-slate-400",children:"Brain Health"}),(0,R.jsxs)("span",{className:`font-medium ${c}`,children:[u,"%"]})]}),(0,R.jsx)("div",{className:"w-px h-4 bg-slate-700 mx-3"}),(0,R.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,R.jsx)("span",{className:"text-slate-400",children:"Memories"}),(0,R.jsx)("span",{className:"text-slate-200 font-medium",children:h})]}),(0,R.jsx)("div",{className:"w-px h-4 bg-slate-700 mx-3"}),(0,R.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,R.jsx)("span",{className:"text-slate-400",children:"Links"}),(0,R.jsx)("span",{className:"text-slate-200 font-medium",children:d})]}),(0,R.jsx)("div",{className:"w-px h-4 bg-slate-700 mx-3"}),(0,R.jsxs)("button",{onClick:a,className:"flex items-center gap-1.5 hover:bg-slate-800/60 rounded px-1.5 py-0.5 transition-colors",children:[(0,R.jsx)("span",{className:"text-slate-400",children:"Contradictions"}),(0,R.jsx)("span",{className:`font-medium ${t>0?"text-amber-400 animate-pulse":"text-slate-200"}`,children:t})]}),(0,R.jsx)("div",{className:"w-px h-4 bg-slate-700 mx-3"}),(0,R.jsxs)("button",{onClick:s,className:"flex items-center gap-1.5 hover:bg-slate-800/60 rounded px-1.5 py-0.5 transition-colors",children:[(0,R.jsx)("span",{className:"text-slate-400",children:"Quarantine"}),(0,R.jsx)("span",{className:`font-medium ${n>0?"text-red-400 animate-pulse":"text-slate-200"}`,children:n})]}),(0,R.jsx)("div",{className:"w-px h-4 bg-slate-700 mx-3"}),(0,R.jsxs)("button",{onClick:o,className:"flex items-center gap-1.5 hover:bg-slate-800/60 rounded px-1.5 py-0.5 transition-colors",children:[(0,R.jsx)("span",{className:"text-slate-400",children:"Consolidated"}),(0,R.jsx)("span",{className:"text-slate-200 font-medium",children:function(e){if(!e)return"Never";let t=new Date(e),n=Math.floor((Date.now()-t.getTime())/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;let i=Math.floor(n/60);if(i<24)return`${i}h ago`;let r=Math.floor(i/24);return`${r}d ago`}(i)})]})]})}var U=e.i(97358);function O({percentage:e,size:t=80,strokeWidth:n=6}){let i=(t-n)/2,r=2*Math.PI*i,a=Math.max(0,Math.min(100,e)),s=a>70?"#10B981":a>=40?"#F59E0B":"#EF4444";return(0,R.jsxs)("div",{className:"relative inline-flex items-center justify-center",children:[(0,R.jsxs)("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"-rotate-90",children:[(0,R.jsx)("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",strokeWidth:n,className:"text-slate-700"}),(0,R.jsx)("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:s,strokeWidth:n,strokeLinecap:"round",strokeDasharray:r,strokeDashoffset:r-a/100*r,style:{transition:"stroke-dashoffset 0.6s ease, stroke 0.4s ease"}})]}),(0,R.jsxs)("span",{className:"absolute text-sm font-semibold",style:{color:s},children:[Math.round(a),"%"]})]})}function F({category:e,healthPct:t,count:n,color:i,isActive:r,onClick:a}){let s=Math.max(0,Math.min(100,t));return(0,R.jsxs)("button",{onClick:a,className:`w-full flex items-center gap-2 px-2 py-1.5 rounded text-left transition-colors ${r?"bg-slate-700/60 border border-slate-600":"bg-transparent border border-transparent hover:bg-slate-800/60"}`,children:[(0,R.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:i}}),(0,R.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,R.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,R.jsx)("span",{className:"text-[11px] text-slate-300 capitalize truncate",children:e}),(0,R.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0 ml-1",children:[s<50&&(0,R.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 flex-shrink-0",title:"Health below 50%"}),(0,R.jsx)("span",{className:"text-[10px] text-slate-500",children:n})]})]}),(0,R.jsx)("div",{className:"w-full h-1 rounded-full bg-slate-700 overflow-hidden",children:(0,R.jsx)("div",{className:"h-full rounded-full",style:{width:`${s}%`,backgroundColor:s>70?"#10B981":s>40?"#F59E0B":"#EF4444",transition:"width 0.4s ease, background-color 0.4s ease"}})})]})]})}function z({stats:e,memories:t,onCategoryClick:n,activeCategory:i,onConsolidate:r,isConsolidating:a,onScanContradictions:s,workerStatus:o}){let l=(0,P.useMemo)(()=>{let t=(e?.decayDistribution?.healthy??0)+(e?.decayDistribution?.fading??0)+(e?.decayDistribution?.critical??0);return t>0?Math.round((e?.decayDistribution?.healthy??0)/t*100):100},[e?.decayDistribution]),u=(0,P.useMemo)(()=>{let n=e?.byCategory??{};return Object.keys(n).map(e=>{let i=t.filter(t=>t.category===e),r=n[e]??0,a=100;i.length>0&&(a=Math.round(i.reduce((e,t)=>e+(t.decayedScore??t.salience??.5),0)/i.length*100));let s=U.CATEGORY_COLORS[e]??U.CATEGORY_COLORS.custom;return{category:e,healthPct:a,count:r,color:s}})},[e?.byCategory,t]),c=o?.running?"Active":o?.lastRun?"Idle":"Stopped",h=o?.running?"bg-emerald-400":o?.lastRun?"bg-amber-400":"bg-slate-500";return(0,R.jsxs)("div",{className:"w-56 shrink-0 h-full flex flex-col bg-slate-900/80 backdrop-blur-sm border-r border-slate-800",children:[(0,R.jsxs)("div",{className:"flex flex-col items-center py-4 px-3 border-b border-slate-800",children:[(0,R.jsx)(O,{percentage:l,size:80,strokeWidth:6}),(0,R.jsx)("span",{className:"text-[11px] text-slate-400 mt-2",children:"Brain Health"})]}),(0,R.jsxs)("div",{className:"flex-1 overflow-y-auto px-2 py-2 space-y-0.5",children:[(0,R.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider px-2 mb-1",children:"Categories"}),0===u.length&&(0,R.jsx)("div",{className:"text-[11px] text-slate-500 px-2 py-2",children:"No categories yet"}),u.map(({category:e,healthPct:t,count:r,color:a})=>(0,R.jsx)(F,{category:e,healthPct:t,count:r,color:a,isActive:i===e,onClick:()=>n(i===e?null:e)},e))]}),(0,R.jsxs)("div",{className:"px-3 py-3 border-t border-slate-800 space-y-2",children:[(0,R.jsx)("button",{onClick:r,disabled:a,className:`w-full px-2 py-1.5 text-[11px] rounded transition-colors ${a?"bg-slate-700 text-slate-500 cursor-not-allowed":"bg-blue-600/80 text-blue-100 hover:bg-blue-600"}`,children:a?"Consolidating...":"Consolidate Now"}),s&&(0,R.jsx)("button",{onClick:s,className:"w-full px-2 py-1.5 text-[11px] rounded bg-slate-700/60 text-slate-300 hover:bg-slate-700 transition-colors",children:"Scan Contradictions"}),(0,R.jsxs)("div",{className:"flex items-center gap-2 px-1 pt-1",children:[(0,R.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${h}`}),(0,R.jsxs)("span",{className:"text-[10px] text-slate-500",children:["Worker: ",c]})]})]})]})}function k(e){let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"Just now";if(t<60)return`${t}m ago`;let n=Math.floor(t/60);if(n<24)return`${n}h ago`;let i=Math.floor(n/24);return`${i}d ago`}let B={short_term:"STM",long_term:"LTM",episodic:"Episodic"},V={references:"bg-blue-500/20 text-blue-400 border-blue-500/30",extends:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",contradicts:"bg-red-500/20 text-red-400 border-red-500/30",related:"bg-slate-500/20 text-slate-400 border-slate-500/30"},H={references:"#3B82F6",extends:"#10B981",contradicts:"#EF4444",related:"#6B7280"};function j({memory:e,links:t,onClose:n,onBoost:i,onDemote:r,onPromote:a,onDelete:s,onQuarantine:o,onNavigateToMemory:l}){if(!e)return(0,R.jsxs)("div",{className:"w-80 shrink-0 h-full bg-slate-900/80 backdrop-blur-sm border-l border-slate-800 flex flex-col items-center justify-center",children:[(0,R.jsx)("div",{className:"text-slate-600 mb-3",children:(0,R.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,R.jsx)("path",{d:"M12 2a7 7 0 0 1 7 7c0 2.38-1.19 4.47-3 5.74V17a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1v-2.26C6.19 13.47 5 11.38 5 9a7 7 0 0 1 7-7z"}),(0,R.jsx)("path",{d:"M9 21h6"}),(0,R.jsx)("path",{d:"M10 21v1a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-1"})]})}),(0,R.jsx)("p",{className:"text-slate-500 text-sm",children:"Click a memory node to inspect it"})]});let u=e.salience??0,c=e.decayedScore??u,h=U.CATEGORY_COLORS[e.category]||U.CATEGORY_COLORS.custom,d=c>.7?"bg-emerald-400":c>=.4?"bg-amber-400":"bg-red-400",p=t.map(t=>{let n=t.source_id===e.id;return{link:t,targetId:n?t.target_id:t.source_id,targetTitle:n?t.target_title||`Memory #${t.target_id}`:t.source_title||`Memory #${t.source_id}`,targetCategory:n?t.target_category:t.source_category,relationship:t.relationship,strength:t.strength}});return(0,R.jsxs)("div",{className:"w-80 shrink-0 h-full bg-slate-900/80 backdrop-blur-sm border-l border-slate-800 flex flex-col",children:[(0,R.jsxs)("div",{className:"sticky top-0 z-10 bg-slate-900/95 backdrop-blur-sm border-b border-slate-800 p-4 flex-shrink-0",children:[(0,R.jsx)("button",{onClick:n,className:"absolute top-3 right-3 text-slate-500 hover:text-slate-300 transition-colors","aria-label":"Close inspector",children:(0,R.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,R.jsx)("path",{d:"M4 4l8 8M12 4l-8 8"})})}),(0,R.jsx)("h3",{className:"text-slate-200 font-medium text-sm pr-6 leading-tight mb-2",children:e.title}),(0,R.jsxs)("div",{className:"flex items-center gap-1.5 mb-2.5",children:[(0,R.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full border",style:{color:h,borderColor:`${h}40`,backgroundColor:`${h}15`},children:e.category}),(0,R.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full bg-slate-800 text-slate-400 border border-slate-700",children:B[e.type]||e.type})]}),(0,R.jsxs)("div",{className:"mb-1.5",children:[(0,R.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,R.jsx)("span",{className:"text-[10px] text-slate-500",children:"Salience"}),(0,R.jsx)("span",{className:"text-[10px] text-slate-400 font-mono",children:u.toFixed(2)})]}),(0,R.jsx)("div",{className:"h-1 bg-slate-800 rounded-full overflow-hidden",children:(0,R.jsx)("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${Math.min(100*u,100)}%`,backgroundColor:h}})})]}),(0,R.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,R.jsx)("div",{className:`w-2 h-2 rounded-full ${d}`}),(0,R.jsxs)("span",{className:"text-[10px] text-slate-500",children:["Health ",c.toFixed(2)]})]})]}),(0,R.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[(0,R.jsxs)("div",{className:"p-4 border-b border-slate-800",children:[(0,R.jsxs)("div",{className:"mb-3",children:[(0,R.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-1",children:"Content"}),(0,R.jsx)("div",{className:"max-h-48 overflow-y-auto rounded bg-slate-950/60 border border-slate-800 p-2",children:(0,R.jsx)("pre",{className:"text-xs text-slate-300 whitespace-pre-wrap break-words font-mono leading-relaxed",children:e.content})})]}),e.tags&&e.tags.length>0&&(0,R.jsxs)("div",{className:"mb-3",children:[(0,R.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-1",children:"Tags"}),(0,R.jsx)("div",{className:"flex flex-wrap gap-1",children:e.tags.map(e=>(0,R.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-slate-800 text-slate-400 border border-slate-700",children:e},e))})]}),(0,R.jsxs)("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5",children:[(0,R.jsxs)("div",{children:[(0,R.jsx)("div",{className:"text-[10px] text-slate-500",children:"Created"}),(0,R.jsx)("div",{className:"text-xs text-slate-300",children:k(e.createdAt)})]}),(0,R.jsxs)("div",{children:[(0,R.jsx)("div",{className:"text-[10px] text-slate-500",children:"Last Accessed"}),(0,R.jsx)("div",{className:"text-xs text-slate-300",children:k(e.lastAccessed)})]}),(0,R.jsxs)("div",{children:[(0,R.jsx)("div",{className:"text-[10px] text-slate-500",children:"Access Count"}),(0,R.jsx)("div",{className:"text-xs text-slate-300",children:e.accessCount})]}),(0,R.jsxs)("div",{children:[(0,R.jsx)("div",{className:"text-[10px] text-slate-500",children:"Project"}),(0,R.jsx)("div",{className:"text-xs text-slate-300 truncate",title:e.project||"Global",children:e.project||"Global"})]})]})]}),(0,R.jsxs)("div",{className:"p-4",children:[(0,R.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,R.jsx)("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Connections"}),(0,R.jsx)("span",{className:"text-[10px] text-slate-600 font-mono",children:p.length})]}),0===p.length?(0,R.jsx)("p",{className:"text-xs text-slate-600 py-2",children:"No connections yet"}):(0,R.jsx)("div",{className:"space-y-2",children:p.map(e=>{let t=V[e.relationship]||V.related,n=H[e.relationship]||H.related,i=e.targetCategory?U.CATEGORY_COLORS[e.targetCategory]||U.CATEGORY_COLORS.custom:"#6B7280";return(0,R.jsxs)("button",{onClick:()=>l(e.targetId),className:"w-full text-left rounded bg-slate-800/40 hover:bg-slate-800/70 border border-slate-800 hover:border-slate-700 p-2 transition-colors group",children:[(0,R.jsxs)("div",{className:"flex items-start gap-1.5 mb-1",children:[(0,R.jsx)("div",{className:"w-1.5 h-1.5 rounded-full mt-1 flex-shrink-0",style:{backgroundColor:i}}),(0,R.jsx)("span",{className:"text-xs text-slate-300 group-hover:text-slate-200 leading-tight line-clamp-2",children:e.targetTitle})]}),(0,R.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,R.jsx)("span",{className:`text-[9px] px-1 py-0.5 rounded border ${t}`,children:e.relationship}),(0,R.jsx)("div",{className:"flex-1 h-0.5 bg-slate-800 rounded-full overflow-hidden",children:(0,R.jsx)("div",{className:"h-full rounded-full",style:{width:`${Math.min(100*e.strength,100)}%`,backgroundColor:n}})}),(0,R.jsx)("span",{className:"text-[9px] text-slate-600 font-mono",children:e.strength.toFixed(1)})]})]},e.link.id)})})]})]}),(0,R.jsx)("div",{className:"sticky bottom-0 z-10 bg-slate-900/95 backdrop-blur-sm border-t border-slate-800 p-3 flex-shrink-0",children:(0,R.jsxs)("div",{className:"flex items-center gap-1",children:[(0,R.jsxs)("button",{onClick:()=>i(e.id),className:"flex-1 flex flex-col items-center gap-0.5 py-1.5 px-1 rounded text-slate-400 hover:text-emerald-400 hover:bg-slate-800/60 transition-colors",title:"Boost salience",children:[(0,R.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,R.jsx)("path",{d:"M8 12V4M4 8l4-4 4 4"})}),(0,R.jsx)("span",{className:"text-[9px]",children:"Boost"})]}),(0,R.jsxs)("button",{onClick:()=>r(e.id),className:"flex-1 flex flex-col items-center gap-0.5 py-1.5 px-1 rounded text-slate-400 hover:text-amber-400 hover:bg-slate-800/60 transition-colors",title:"Demote salience",children:[(0,R.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,R.jsx)("path",{d:"M8 4v8M4 8l4 4 4-4"})}),(0,R.jsx)("span",{className:"text-[9px]",children:"Demote"})]}),"short_term"===e.type&&(0,R.jsxs)("button",{onClick:()=>a(e.id),className:"flex-1 flex flex-col items-center gap-0.5 py-1.5 px-1 rounded text-slate-400 hover:text-blue-400 hover:bg-slate-800/60 transition-colors",title:"Promote to LTM",children:[(0,R.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,R.jsx)("path",{d:"M4 12l4-8 4 8"}),(0,R.jsx)("path",{d:"M5.5 9h5"})]}),(0,R.jsx)("span",{className:"text-[9px]",children:"Promote"})]}),(0,R.jsxs)("button",{onClick:()=>{window.confirm(`Delete memory "${e.title}"? This cannot be undone.`)&&s(e.id)},className:"flex-1 flex flex-col items-center gap-0.5 py-1.5 px-1 rounded text-slate-400 hover:text-red-400 hover:bg-slate-800/60 transition-colors",title:"Delete memory",children:[(0,R.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,R.jsx)("path",{d:"M2 4h12M5 4V3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1M6 7v5M10 7v5"}),(0,R.jsx)("path",{d:"M3 4l1 9a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1l1-9"})]}),(0,R.jsx)("span",{className:"text-[9px]",children:"Delete"})]}),(0,R.jsxs)("button",{onClick:()=>{window.confirm(`Quarantine memory "${e.title}"? It will be flagged for review.`)&&o(e.id)},className:"flex-1 flex flex-col items-center gap-0.5 py-1.5 px-1 rounded text-slate-400 hover:text-violet-400 hover:bg-slate-800/60 transition-colors",title:"Quarantine memory",children:[(0,R.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,R.jsx)("path",{d:"M8 1.5L1.5 5v6L8 14.5 14.5 11V5L8 1.5z"}),(0,R.jsx)("path",{d:"M8 5v4M8 11h.01"})]}),(0,R.jsx)("span",{className:"text-[9px]",children:"Quarantine"})]})]})})]})}let G=[{key:"all",label:"All",types:[]},{key:"creates",label:"Creates",types:["memory_created"]},{key:"updates",label:"Updates",types:["memory_updated","memory_accessed"]},{key:"deletes",label:"Deletes",types:["memory_deleted"]},{key:"consolidation",label:"Consolidation",types:["consolidation_complete"]},{key:"decay",label:"Decay",types:["decay_tick"]}],W={memory_created:"bg-emerald-400",memory_accessed:"bg-blue-400",memory_updated:"bg-amber-400",memory_deleted:"bg-red-400",consolidation_complete:"bg-purple-400",decay_tick:"bg-slate-400"},X={memory_created:"Created",memory_accessed:"Accessed",memory_updated:"Updated",memory_deleted:"Deleted",consolidation_complete:"Consolidated",decay_tick:"Decay Tick"};function q(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<5)return"Just now";if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Y(e){return e&&"object"==typeof e?"string"==typeof e.title&&e.title?e.title:"string"==typeof e.name&&e.name?e.name:"string"==typeof e.summary&&e.summary?e.summary:"string"==typeof e.message&&e.message?e.message:"number"==typeof e.id?`Memory #${e.id}`:"":""}function Z({events:e,onClickEvent:t,isCollapsed:n=!1,onToggleCollapse:i}){let[r,a]=(0,P.useState)(new Set(["all"])),s=(0,P.useCallback)(e=>{a(t=>{let n=new Set(t);if("all"===e)return new Set(["all"]);if(n.delete("all"),n.has(e)){if(n.delete(e),0===n.size)return new Set(["all"])}else n.add(e);return n})},[]),o=(0,P.useMemo)(()=>{if(r.has("all"))return e;let t=new Set;for(let e of r){let n=G.find(t=>t.key===e);if(n)for(let e of n.types)t.add(e)}return e.filter(e=>t.has(e.type))},[e,r]),l=e.length>0?e[0]:null;return(0,R.jsx)("div",{className:`bg-slate-900/80 backdrop-blur-sm border-t border-slate-800 transition-all duration-300 ease-in-out ${n?"h-8":"h-32"}`,children:n?(0,R.jsxs)("div",{className:"flex items-center h-8 px-3 gap-2",children:[(0,R.jsx)("button",{onClick:i,className:"flex items-center justify-center w-5 h-5 rounded hover:bg-slate-800 transition-colors text-slate-400 hover:text-slate-200 shrink-0","aria-label":"Expand activity feed",children:(0,R.jsx)("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,R.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})}),l?(0,R.jsxs)("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[(0,R.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${W[l.type]}`}),(0,R.jsx)("span",{className:"text-slate-500",children:q(l.timestamp)}),(0,R.jsx)("span",{className:"text-slate-300",children:X[l.type]}),(0,R.jsx)("span",{className:"text-slate-500 truncate",children:Y(l.data)})]}):(0,R.jsx)("span",{className:"text-xs text-slate-500",children:"No activity"})]}):(0,R.jsxs)("div",{className:"flex flex-col h-full",children:[(0,R.jsxs)("div",{className:"flex items-center h-7 px-3 gap-2 shrink-0 border-b border-slate-800/50",children:[(0,R.jsx)("button",{onClick:i,className:"flex items-center justify-center w-5 h-5 rounded hover:bg-slate-800 transition-colors text-slate-400 hover:text-slate-200 shrink-0","aria-label":"Collapse activity feed",children:(0,R.jsx)("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,R.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),(0,R.jsx)("div",{className:"flex items-center gap-1",children:G.map(e=>(0,R.jsx)("button",{onClick:()=>s(e.key),className:`px-1.5 py-0.5 text-[10px] rounded transition-colors ${r.has(e.key)?"bg-cyan-600 text-white":"bg-slate-800 text-slate-400 hover:bg-slate-700"}`,children:e.label},e.key))})]}),(0,R.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:0===o.length?(0,R.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,R.jsx)("span",{className:"text-xs text-slate-500",children:"No activity yet -- events will appear as the brain processes memories"})}):(0,R.jsx)("div",{className:"px-3 py-1",children:o.map((e,n)=>{let i=Y(e.data);return(0,R.jsxs)("button",{onClick:()=>t?.(e.data),className:"flex items-center gap-2 w-full text-left py-0.5 px-1 rounded hover:bg-slate-800/60 transition-colors group",children:[(0,R.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${W[e.type]}`}),(0,R.jsx)("span",{className:"text-[10px] text-slate-500 w-12 shrink-0 tabular-nums",children:q(e.timestamp)}),(0,R.jsx)("span",{className:"text-[10px] text-slate-300 w-16 shrink-0",children:X[e.type]}),i&&(0,R.jsx)("span",{className:"text-[10px] text-slate-500 truncate group-hover:text-slate-400 transition-colors",children:i})]},`${e.type}-${e.timestamp}-${n}`)})})})]})})}var J=e.i(22534),$=P;let K={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Q={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ee="attached",et="detached",en="srgb",ei="srgb-linear",er="linear",ea="srgb",es="300 es",eo={COMPUTE:"compute",RENDER:"render"},el={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},eu={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function ec(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}let eh={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ed(e,t){return new eh[e](t)}function ep(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ef(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function em(){let e=ef("canvas");return e.style.display="block",e}let eg={},ev=null;function ex(e){ev=e}function ey(){return ev}function e_(...e){let t="THREE."+e.shift();ev?ev("log",t,...e):console.log(t,...e)}function eb(...e){let t="THREE."+e.shift();ev?ev("warn",t,...e):console.warn(t,...e)}function eS(...e){let t="THREE."+e.shift();ev?ev("error",t,...e):console.error(t,...e)}function eM(...e){let t=e.join(" ");t in eg||(eg[t]=!0,eb(...e))}class ew{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return void 0!==n&&void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){let n=this._listeners;if(void 0===n)return;let i=n[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(void 0===t)return;let n=t[e.type];if(void 0!==n){e.target=this;let t=n.slice(0);for(let n=0,i=t.length;n<i;n++)t[n].call(this,e);e.target=null}}}let eT=["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"],eE=1234567,eA=Math.PI/180,eC=180/Math.PI;function eR(){let e=0xffffffff*Math.random()|0,t=0xffffffff*Math.random()|0,n=0xffffffff*Math.random()|0,i=0xffffffff*Math.random()|0;return(eT[255&e]+eT[e>>8&255]+eT[e>>16&255]+eT[e>>24&255]+"-"+eT[255&t]+eT[t>>8&255]+"-"+eT[t>>16&15|64]+eT[t>>24&255]+"-"+eT[63&n|128]+eT[n>>8&255]+"-"+eT[n>>16&255]+eT[n>>24&255]+eT[255&i]+eT[i>>8&255]+eT[i>>16&255]+eT[i>>24&255]).toLowerCase()}function eP(e,t,n){return Math.max(t,Math.min(n,e))}function eI(e,t){return(e%t+t)%t}function eL(e,t,n){return(1-n)*e+n*t}function eN(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/0xffffffff;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/0x7fffffff,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function eD(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(0xffffffff*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(0x7fffffff*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("Invalid component type.")}}let eU={DEG2RAD:eA,RAD2DEG:eC,generateUUID:eR,clamp:eP,euclideanModulo:eI,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:eL,damp:function(e,t,n,i){return eL(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(eI(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(eE=e);let t=eE+=0x6d2b79f5;return t=Math.imul(t^t>>>15,1|t),(((t^=t+Math.imul(t^t>>>7,61|t))^t>>>14)>>>0)/0x100000000},degToRad:function(e){return e*eA},radToDeg:function(e){return e*eC},isPowerOfTwo:function(e){return(e&e-1)==0&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){let a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),u=a((t+i)/2),c=s((t+i)/2),h=a((t-i)/2),d=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*c,l*h,l*d,o*u);break;case"YZY":e.set(l*d,o*c,l*h,o*u);break;case"ZXZ":e.set(l*h,l*d,o*c,o*u);break;case"XZX":e.set(o*c,l*f,l*p,o*u);break;case"YXY":e.set(l*p,o*c,l*f,o*u);break;case"ZYZ":e.set(l*f,l*p,o*c,o*u);break;default:eb("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:eD,denormalize:eN};class eO{constructor(e=0,t=0){eO.prototype.isVector2=!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 Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=eP(this.x,e.x,t.x),this.y=eP(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=eP(this.x,e,t),this.y=eP(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eP(n,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());return 0===t?Math.PI/2:Math.acos(eP(this.dot(e)/t,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class eF{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,s){let o=n[i+0],l=n[i+1],u=n[i+2],c=n[i+3],h=r[a+0],d=r[a+1],p=r[a+2],f=r[a+3];if(s<=0){e[t+0]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c;return}if(s>=1){e[t+0]=h,e[t+1]=d,e[t+2]=p,e[t+3]=f;return}if(c!==f||o!==h||l!==d||u!==p){let e=o*h+l*d+u*p+c*f;e<0&&(h=-h,d=-d,p=-p,f=-f,e=-e);let t=1-s;if(e<.9995){let n=Math.acos(e),i=Math.sin(n);o=o*(t=Math.sin(t*n)/i)+h*(s=Math.sin(s*n)/i),l=l*t+d*s,u=u*t+p*s,c=c*t+f*s}else{let e=1/Math.sqrt((o=o*t+h*s)*o+(l=l*t+d*s)*l+(u=u*t+p*s)*u+(c=c*t+f*s)*c);o*=e,l*=e,u*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,i,r,a){let s=n[i],o=n[i+1],l=n[i+2],u=n[i+3],c=r[a],h=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+u*c+o*d-l*h,e[t+1]=o*p+u*h+l*c-s*d,e[t+2]=l*p+u*d+s*h-o*c,e[t+3]=u*p-s*c-o*h-l*d,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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 n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),u=s(i/2),c=s(r/2),h=o(n/2),d=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"YXZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"ZXY":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"ZYX":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"YZX":this._x=h*u*c+l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c-h*d*p;break;case"XZY":this._x=h*u*c-l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c+h*d*p;break;default:eb("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],u=t[6],c=t[10],h=n+s+c;if(h>0){let e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(u-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>c){let e=2*Math.sqrt(1+n-s-c);this._w=(u-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-n-c);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+u)/e}else{let e=2*Math.sqrt(1+c-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+u)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(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=n,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(eP(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(0===n)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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 0===e?(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 n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,u=t._w;return this._x=n*u+a*s+i*l-r*o,this._y=i*u+a*o+r*s-n*l,this._z=r*u+a*l+n*o-i*s,this._w=a*u-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,i=e._y,r=e._z,a=e._w,s=this.dot(e);s<0&&(n=-n,i=-i,r=-r,a=-a,s=-s);let o=1-t;if(s<.9995){let e=Math.acos(s),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*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}}class ez{constructor(e=0,t=0,n=0){ez.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,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 Error("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 Error("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(eB.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(eB.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),u=2*(s*t-r*i),c=2*(r*n-a*t);return this.x=t+o*l+a*c-s*u,this.y=n+o*u+s*l-r*c,this.z=i+o*c+r*u-a*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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=eP(this.x,e.x,t.x),this.y=eP(this.y,e.y,t.y),this.z=eP(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=eP(this.x,e,t),this.y=eP(this.y,e,t),this.z=eP(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eP(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ek.copy(this).projectOnVector(e),this.sub(ek)}reflect(e){return this.sub(ek.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:Math.acos(eP(this.dot(e)/t,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let ek=new ez,eB=new eF;class eV{constructor(e,t,n,i,r,a,s,o,l){eV.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){let u=this.elements;return u[0]=e,u[1]=i,u[2]=s,u[3]=t,u[4]=r,u[5]=o,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],u=n[4],c=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],x=i[4],y=i[7],_=i[2],b=i[5],S=i[8];return r[0]=a*f+s*v+o*_,r[3]=a*m+s*x+o*b,r[6]=a*g+s*y+o*S,r[1]=l*f+u*v+c*_,r[4]=l*m+u*x+c*b,r[7]=l*g+u*y+c*S,r[2]=h*f+d*v+p*_,r[5]=h*m+d*x+p*b,r[8]=h*g+d*y+p*S,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],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8];return t*a*u-t*s*l-n*r*u+n*s*o+i*r*l-i*a*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=u*a-s*l,h=s*o-u*r,d=l*r-a*o,p=t*c+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(i*l-u*n)*f,e[2]=(s*n-i*a)*f,e[3]=h*f,e[4]=(u*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,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,n,i,r,a,s){let o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(eH.makeScale(e,t)),this}rotate(e){return this.premultiply(eH.makeRotation(-e)),this}translate(e,t){return this.premultiply(eH.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}let eH=new eV,ej=new eV().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),eG=new eV().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),eW=(f=[.64,.33,.3,.6,.15,.06],m=[.2126,.7152,.0722],g=[.3127,.329],(p={enabled:!0,workingColorSpace:ei,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n&&(this.spaces[t].transfer===ea&&(e.r=eX(e.r),e.g=eX(e.g),e.b=eX(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===ea&&(e.r=eq(e.r),e.g=eq(e.g),e.b=eq(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return""===e?er:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,t){return eM("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),p.workingToColorSpace(e,t)},toWorkingColorSpace:function(e,t){return eM("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),p.colorSpaceToWorking(e,t)}}).define({[ei]:{primaries:f,whitePoint:g,transfer:er,toXYZ:ej,fromXYZ:eG,luminanceCoefficients:m,workingColorSpaceConfig:{unpackColorSpace:en},outputColorSpaceConfig:{drawingBufferColorSpace:en}},[en]:{primaries:f,whitePoint:g,transfer:ea,toXYZ:ej,fromXYZ:eG,luminanceCoefficients:m,outputColorSpaceConfig:{drawingBufferColorSpace:en}}}),p);function eX(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function eq(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class eY{static getDataURL(e,n="image/png"){let i;if(/^data:/i.test(e.src)||"u"<typeof HTMLCanvasElement)return e.src;if(e instanceof HTMLCanvasElement)i=e;else{void 0===t&&(t=ef("canvas")),t.width=e.width,t.height=e.height;let n=t.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=t}return i.toDataURL(n)}static sRGBToLinear(e){if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap){let t=ef("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e<r.length;e++)r[e]=255*eX(r[e]/255);return n.putImageData(i,0,0),t}if(!e.data)return eb("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e;{let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*eX(t[e]/255)):t[e]=eX(t[e]);return{data:t,width:e.width,height:e.height}}}}let eZ=0;class eJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:eZ++}),this.uuid=eR(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return"u">typeof HTMLVideoElement&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):"u">typeof VideoFrame&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(e$(i[t].image)):e.push(e$(i[t]))}else e=e$(i);n.url=e}return t||(e.images[this.uuid]=n),n}}function e$(e){return"u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap?eY.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(eb("Texture: Unable to serialize Texture."),{})}let eK=0,eQ=new ez;class e0 extends ew{constructor(e=e0.DEFAULT_IMAGE,t=e0.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,s=1023,o=1009,l=e0.DEFAULT_ANISOTROPY,u=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:eK++}),this.uuid=eR(),this.name="",this.source=new eJ(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new eO(0,0),this.repeat=new eO(1,1),this.center=new eO(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new eV,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,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}get width(){return this.source.getSize(eQ).x}get height(){return this.source.getSize(eQ).y}get depth(){return this.source.getSize(eQ).z}get image(){return this.source.data}set image(e=null){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.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 n=e[t];if(void 0===n){eb(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){eb(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];let n={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,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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}e0.DEFAULT_IMAGE=null,e0.DEFAULT_MAPPING=300,e0.DEFAULT_ANISOTROPY=1;class e1{constructor(e=0,t=0,n=0,i=1){e1.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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 Error("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 Error("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=void 0!==e.w?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,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,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,n,i,r,a=e.elements,s=a[0],o=a[4],l=a[8],u=a[1],c=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(.01>Math.abs(o-u)&&.01>Math.abs(l-d)&&.01>Math.abs(h-p)){if(.1>Math.abs(o+u)&&.1>Math.abs(l+d)&&.1>Math.abs(h+p)&&.1>Math.abs(s+c+f-3))return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+u)/4,v=(l+d)/4,x=(h+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(i=g/(n=Math.sqrt(e)),r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(n=g/(i=Math.sqrt(a)),r=x/i):m<.01?(n=.707106781,i=.707106781,r=0):(n=v/(r=Math.sqrt(m)),i=x/r),this.set(n,i,r,t),this}let m=Math.sqrt((p-h)*(p-h)+(l-d)*(l-d)+(u-o)*(u-o));return .001>Math.abs(m)&&(m=1),this.x=(p-h)/m,this.y=(l-d)/m,this.z=(u-o)/m,this.w=Math.acos((s+c+f-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=eP(this.x,e.x,t.x),this.y=eP(this.y,e.y,t.y),this.z=eP(this.z,e.z,t.z),this.w=eP(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=eP(this.x,e,t),this.y=eP(this.y,e,t),this.z=eP(this.z,e,t),this.w=eP(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eP(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}}class e2 extends ew{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new e1(0,0,e,t),this.scissorTest=!1,this.viewport=new e1(0,0,e,t);const i=new e0({width:e,height:t,depth:n.depth});this.textures=[];const r=n.count;for(let e=0;e<r;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==e.mapping&&(t.mapping=e.mapping),void 0!==e.wrapS&&(t.wrapS=e.wrapS),void 0!==e.wrapT&&(t.wrapT=e.wrapT),void 0!==e.wrapR&&(t.wrapR=e.wrapR),void 0!==e.magFilter&&(t.magFilter=e.magFilter),void 0!==e.minFilter&&(t.minFilter=e.minFilter),void 0!==e.format&&(t.format=e.format),void 0!==e.type&&(t.type=e.type),void 0!==e.anisotropy&&(t.anisotropy=e.anisotropy),void 0!==e.colorSpace&&(t.colorSpace=e.colorSpace),void 0!==e.flipY&&(t.flipY=e.flipY),void 0!==e.generateMipmaps&&(t.generateMipmaps=e.generateMipmaps),void 0!==e.internalFormat&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,!0!==this.textures[i].isData3DTexture&&(this.textures[i].isArrayTexture=this.textures[i].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,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new eJ(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class e3 extends e2{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class e4 extends e0{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class e5 extends e3{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new e4(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class e6 extends e0{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class e8 extends e3{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new e6(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class e9{constructor(e=new ez(Infinity,Infinity,Infinity),t=new ez(-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,n=e.length;t<n;t+=3)this.expandByPoint(te.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(te.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=te.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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=Infinity,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 n=e.geometry;if(void 0!==n){let i=n.getAttribute("position");if(!0===t&&void 0!==i&&!0!==e.isInstancedMesh)for(let t=0,n=i.count;t<n;t++)!0===e.isMesh?e.getVertexPosition(t,te):te.fromBufferAttribute(i,t),te.applyMatrix4(e.matrixWorld),this.expandByPoint(te);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),tt.copy(e.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),tt.copy(n.boundingBox)),tt.applyMatrix4(e.matrixWorld),this.union(tt)}let i=e.children;for(let e=0,n=i.length;e<n;e++)this.expandByObject(i[e],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,te),te.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(tl),tu.subVectors(this.max,tl),tn.subVectors(e.a,tl),ti.subVectors(e.b,tl),tr.subVectors(e.c,tl),ta.subVectors(ti,tn),ts.subVectors(tr,ti),to.subVectors(tn,tr);let t=[0,-ta.z,ta.y,0,-ts.z,ts.y,0,-to.z,to.y,ta.z,0,-ta.x,ts.z,0,-ts.x,to.z,0,-to.x,-ta.y,ta.x,0,-ts.y,ts.x,0,-to.y,to.x,0];return!!td(t,tn,ti,tr,tu)&&!!td(t=[1,0,0,0,1,0,0,0,1],tn,ti,tr,tu)&&(tc.crossVectors(ta,ts),td(t=[tc.x,tc.y,tc.z],tn,ti,tr,tu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,te).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(te).length()),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()||(e7[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),e7[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),e7[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),e7[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),e7[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),e7[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),e7[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),e7[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(e7)),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}}let e7=[new ez,new ez,new ez,new ez,new ez,new ez,new ez,new ez],te=new ez,tt=new e9,tn=new ez,ti=new ez,tr=new ez,ta=new ez,ts=new ez,to=new ez,tl=new ez,tu=new ez,tc=new ez,th=new ez;function td(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){th.fromArray(e,a);let s=r.x*Math.abs(th.x)+r.y*Math.abs(th.y)+r.z*Math.abs(th.z),o=t.dot(th),l=n.dot(th),u=i.dot(th);if(Math.max(-Math.max(o,l,u),Math.min(o,l,u))>s)return!1}return!0}let tp=new e9,tf=new ez,tm=new ez;class tg{constructor(e=new ez,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 n=this.center;void 0!==t?n.copy(t):tp.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;t<r;t++)i=Math.max(i,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);return t.copy(e),n>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.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;tf.subVectors(e,this.center);let t=tf.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(tf,n/e),this.radius+=n}return this}union(e){return e.isEmpty()||(this.isEmpty()?this.copy(e):!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(tm.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(tf.copy(e.center).add(tm)),this.expandByPoint(tf.copy(e.center).sub(tm)))),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}}let tv=new ez,tx=new ez,ty=new ez,t_=new ez,tb=new ez,tS=new ez,tM=new ez;class tw{constructor(e=new ez,t=new ez(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,tv)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=tv.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(tv.copy(this.origin).addScaledVector(this.direction,t),tv.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){let r,a,s,o;tx.copy(e).add(t).multiplyScalar(.5),ty.copy(t).sub(e).normalize(),t_.copy(this.origin).sub(tx);let l=.5*e.distanceTo(t),u=-this.direction.dot(ty),c=t_.dot(this.direction),h=-t_.dot(ty),d=t_.lengthSq(),p=Math.abs(1-u*u);if(p>0)if(r=u*h-c,a=u*c-h,o=l*p,r>=0)if(a>=-o)if(a<=o){let e=1/p;r*=e,a*=e,s=r*(r+u*a+2*c)+a*(u*r+a+2*h)+d}else s=-(r=Math.max(0,-(u*(a=l)+c)))*r+a*(a+2*h)+d;else s=-(r=Math.max(0,-(u*(a=-l)+c)))*r+a*(a+2*h)+d;else a<=-o?(a=(r=Math.max(0,-(-u*l+c)))>0?-l:Math.min(Math.max(-l,-h),l),s=-r*r+a*(a+2*h)+d):a<=o?(r=0,s=(a=Math.min(Math.max(-l,-h),l))*(a+2*h)+d):(a=(r=Math.max(0,-(u*l+c)))>0?l:Math.min(Math.max(-l,-h),l),s=-r*r+a*(a+2*h)+d);else a=u>0?-l:l,s=-(r=Math.max(0,-(u*a+c)))*r+a*(a+2*h)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(tx).addScaledVector(ty,a),s}intersectSphere(e,t){tv.subVectors(e.center,this.origin);let n=tv.dot(this.direction),i=tv.dot(tv)-n*n,r=e.radius*e.radius;if(i>r)return null;let a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return!!(0===t||e.normal.dot(this.direction)*t<0)}intersectBox(e,t){let n,i,r,a,s,o,l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return(l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),c>=0?(s=(e.min.z-h.z)*c,o=(e.max.z-h.z)*c):(s=(e.max.z-h.z)*c,o=(e.min.z-h.z)*c),n>o||s>i||((s>n||n!=n)&&(n=s),(o<i||i!=i)&&(i=o),i<0)))?null:this.at(n>=0?n:i,t)}intersectsBox(e){return null!==this.intersectBox(e,tv)}intersectTriangle(e,t,n,i,r){let a;tb.subVectors(t,e),tS.subVectors(n,e),tM.crossVectors(tb,tS);let s=this.direction.dot(tM);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}t_.subVectors(this.origin,e);let o=a*this.direction.dot(tS.crossVectors(t_,tS));if(o<0)return null;let l=a*this.direction.dot(tb.cross(t_));if(l<0||o+l>s)return null;let u=-a*t_.dot(tM);return u<0?null:this.at(u/s,r)}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)}}class tT{constructor(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m){tT.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m)}set(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,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 tT().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return 0===this.determinant()?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1)):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2)),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(0===e.determinant())return this.identity();let t=this.elements,n=e.elements,i=1/tE.setFromMatrixColumn(e,0).length(),r=1/tE.setFromMatrixColumn(e,1).length(),a=1/tE.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),u=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){let e=a*u,n=a*c,i=s*u,r=s*c;t[0]=o*u,t[4]=-o*c,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*u,n=o*c,i=l*u,r=l*c;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*c,t[5]=a*u,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){let e=o*u,n=o*c,i=l*u,r=l*c;t[0]=e-r*s,t[4]=-a*c,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*u,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){let e=a*u,n=a*c,i=s*u,r=s*c;t[0]=o*u,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*c,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*u,t[4]=r-e*c,t[8]=i*c+n,t[1]=c,t[5]=a*u,t[9]=-s*u,t[2]=-l*u,t[6]=n*c+i,t[10]=e-r*c}else if("XZY"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*u,t[4]=-c,t[8]=l*u,t[1]=e*c+r,t[5]=a*u,t[9]=n*c-i,t[2]=i*c-n,t[6]=s*u,t[10]=r*c+e}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(tC,e,tR)}lookAt(e,t,n){let i=this.elements;return tL.subVectors(e,t),0===tL.lengthSq()&&(tL.z=1),tL.normalize(),tP.crossVectors(n,tL),0===tP.lengthSq()&&(1===Math.abs(n.z)?tL.x+=1e-4:tL.z+=1e-4,tL.normalize(),tP.crossVectors(n,tL)),tP.normalize(),tI.crossVectors(tL,tP),i[0]=tP.x,i[4]=tI.x,i[8]=tL.x,i[1]=tP.y,i[5]=tI.y,i[9]=tL.y,i[2]=tP.z,i[6]=tI.z,i[10]=tL.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],u=n[1],c=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],x=n[7],y=n[11],_=n[15],b=i[0],S=i[4],M=i[8],w=i[12],T=i[1],E=i[5],A=i[9],C=i[13],R=i[2],P=i[6],I=i[10],L=i[14],N=i[3],D=i[7],U=i[11],O=i[15];return r[0]=a*b+s*T+o*R+l*N,r[4]=a*S+s*E+o*P+l*D,r[8]=a*M+s*A+o*I+l*U,r[12]=a*w+s*C+o*L+l*O,r[1]=u*b+c*T+h*R+d*N,r[5]=u*S+c*E+h*P+d*D,r[9]=u*M+c*A+h*I+d*U,r[13]=u*w+c*C+h*L+d*O,r[2]=p*b+f*T+m*R+g*N,r[6]=p*S+f*E+m*P+g*D,r[10]=p*M+f*A+m*I+g*U,r[14]=p*w+f*C+m*L+g*O,r[3]=v*b+x*T+y*R+_*N,r[7]=v*S+x*E+y*P+_*D,r[11]=v*M+x*A+y*I+_*U,r[15]=v*w+x*C+y*L+_*O,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],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],u=e[2],c=e[6],h=e[10],d=e[14],p=e[3],f=e[7],m=e[11],g=e[15],v=o*d-l*h,x=s*d-l*c,y=s*h-o*c,_=a*d-l*u,b=a*h-o*u,S=a*c-s*u;return t*(f*v-m*x+g*y)-n*(p*v-m*_+g*b)+i*(p*x-f*_+g*S)-r*(p*y-f*b+m*S)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*h*l+f*o*d-s*m*d-c*o*g+s*h*g,x=p*h*l-u*m*l-p*o*d+a*m*d+u*o*g-a*h*g,y=u*f*l-p*c*l+p*s*d-a*f*d-u*s*g+a*c*g,_=p*c*o-u*f*o-p*s*h+a*f*h+u*s*m-a*c*m,b=t*v+n*x+i*y+r*_;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/b;return e[0]=v*S,e[1]=(f*h*r-c*m*r-f*i*d+n*m*d+c*i*g-n*h*g)*S,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*S,e[3]=(c*o*r-s*h*r-c*i*l+n*h*l+s*i*d-n*o*d)*S,e[4]=x*S,e[5]=(u*m*r-p*h*r+p*i*d-t*m*d-u*i*g+t*h*g)*S,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*S,e[7]=(a*h*r-u*o*r+u*i*l-t*h*l-a*i*d+t*o*d)*S,e[8]=y*S,e[9]=(p*c*r-u*f*r-p*n*d+t*f*d+u*n*g-t*c*g)*S,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*S,e[11]=(u*s*r-a*c*r-u*n*l+t*c*l+a*n*d-t*s*d)*S,e[12]=_*S,e[13]=(u*f*i-p*c*i+p*n*h-t*f*h-u*n*m+t*c*m)*S,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*S,e[15]=(a*c*i-u*s*i+u*n*o-t*c*o-a*n*h+t*s*h)*S,this}scale(e){let t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,u=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,u*s+n,u*o-i*a,0,l*o-i*s,u*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,u=a+a,c=s+s,h=r*l,d=r*u,p=r*c,f=a*u,m=a*c,g=s*c,v=o*l,x=o*u,y=o*c,_=n.x,b=n.y,S=n.z;return i[0]=(1-(f+g))*_,i[1]=(d+y)*_,i[2]=(p-x)*_,i[3]=0,i[4]=(d-y)*b,i[5]=(1-(h+g))*b,i[6]=(m+v)*b,i[7]=0,i[8]=(p+x)*S,i[9]=(m-v)*S,i[10]=(1-(h+f))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;if(e.x=i[12],e.y=i[13],e.z=i[14],0===this.determinant())return n.set(1,1,1),t.identity(),this;let r=tE.set(i[0],i[1],i[2]).length(),a=tE.set(i[4],i[5],i[6]).length(),s=tE.set(i[8],i[9],i[10]).length();0>this.determinant()&&(r=-r),tA.copy(this);let o=1/r,l=1/a,u=1/s;return tA.elements[0]*=o,tA.elements[1]*=o,tA.elements[2]*=o,tA.elements[4]*=l,tA.elements[5]*=l,tA.elements[6]*=l,tA.elements[8]*=u,tA.elements[9]*=u,tA.elements[10]*=u,t.setFromRotationMatrix(tA),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3,o=!1){let l,u,c=this.elements;if(o)l=r/(a-r),u=a*r/(a-r);else if(2e3===s)l=-(a+r)/(a-r),u=-2*a*r/(a-r);else if(2001===s)l=-a/(a-r),u=-a*r/(a-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);return c[0]=2*r/(t-e),c[4]=0,c[8]=(t+e)/(t-e),c[12]=0,c[1]=0,c[5]=2*r/(n-i),c[9]=(n+i)/(n-i),c[13]=0,c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3,o=!1){let l,u,c=this.elements;if(o)l=1/(a-r),u=a/(a-r);else if(2e3===s)l=-2/(a-r),u=-(a+r)/(a-r);else if(2001===s)l=-1/(a-r),u=-r/(a-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);return c[0]=2/(t-e),c[4]=0,c[8]=0,c[12]=-(t+e)/(t-e),c[1]=0,c[5]=2/(n-i),c[9]=0,c[13]=-(n+i)/(n-i),c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}let tE=new ez,tA=new tT,tC=new ez(0,0,0),tR=new ez(1,1,1),tP=new ez,tI=new ez,tL=new ez,tN=new tT,tD=new eF;class tU{constructor(e=0,t=0,n=0,i=tU.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}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,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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,n=!0){let i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],u=i[9],c=i[2],h=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(eP(s,-1,1)),.9999999>Math.abs(s)?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-eP(u,-1,1)),.9999999>Math.abs(u)?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(eP(h,-1,1)),.9999999>Math.abs(h)?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-eP(c,-1,1)),.9999999>Math.abs(c)?(this._x=Math.atan2(h,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(eP(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-eP(a,-1,1)),.9999999>Math.abs(a)?(this._x=Math.atan2(h,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-u,d),this._y=0);break;default:eb("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return tN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tN,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return tD.setFromEuler(this),this.setFromQuaternion(tD,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],void 0!==e[3]&&(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}}tU.DEFAULT_ORDER="XYZ";class tO{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!=0}isEnabled(e){return(this.mask&1<<e)!=0}}let tF=0,tz=new ez,tk=new eF,tB=new tT,tV=new ez,tH=new ez,tj=new ez,tG=new eF,tW=new ez(1,0,0),tX=new ez(0,1,0),tq=new ez(0,0,1),tY={type:"added"},tZ={type:"removed"},tJ={type:"childadded",child:null},t$={type:"childremoved",child:null};class tK extends ew{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:tF++}),this.uuid=eR(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tK.DEFAULT_UP.clone();const e=new ez,t=new tU,n=new eF,i=new ez(1,1,1);t._onChange(function(){n.setFromEuler(t,!1)}),n._onChange(function(){t.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new tT},normalMatrix:{value:new eV}}),this.matrix=new tT,this.matrixWorld=new tT,this.matrixAutoUpdate=tK.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=tK.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new tO,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.userData={}}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 tk.setFromAxisAngle(e,t),this.quaternion.multiply(tk),this}rotateOnWorldAxis(e,t){return tk.setFromAxisAngle(e,t),this.quaternion.premultiply(tk),this}rotateX(e){return this.rotateOnAxis(tW,e)}rotateY(e){return this.rotateOnAxis(tX,e)}rotateZ(e){return this.rotateOnAxis(tq,e)}translateOnAxis(e,t){return tz.copy(e).applyQuaternion(this.quaternion),this.position.add(tz.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(tW,e)}translateY(e){return this.translateOnAxis(tX,e)}translateZ(e){return this.translateOnAxis(tq,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(tB.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?tV.copy(e):tV.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),tH.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?tB.lookAt(tH,tV,this.up):tB.lookAt(tV,tH,this.up),this.quaternion.setFromRotationMatrix(tB),i&&(tB.extractRotation(i.matrixWorld),tk.setFromRotationMatrix(tB),this.quaternion.premultiply(tk.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?eS("Object3D.add: object can't be added as a child of itself.",e):e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(tY),tJ.child=e,this.dispatchEvent(tJ),tJ.child=null):eS("Object3D.add: object not an instance of THREE.Object3D.",e),this}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return -1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(tZ),t$.child=e,this.dispatchEvent(t$),t$.child=null),this}removeFromParent(){let e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),tB.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),tB.multiply(e.parent.matrixWorld)),e.applyMatrix4(tB),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(tY),tJ.child=e,this.dispatchEvent(tJ),tJ.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 n=0,i=this.children.length;n<i;n++){let i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(tH,e,tj),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(tH,tG,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(!0===e&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===t){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(e=>({...e})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let i=n[t];r(e.shapes,i)}else r(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){let t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(r(e.materials,this.material[n]));i.material=t}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];i.animations.push(r(e.animations,n))}}if(t){let t=a(e.geometries),i=a(e.materials),r=a(e.textures),s=a(e.images),o=a(e.shapes),l=a(e.skeletons),u=a(e.animations),c=a(e.nodes);t.length>0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),u.length>0&&(n.animations=u),c.length>0&&(n.nodes=c)}return n.object=i,n;function a(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}}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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}}tK.DEFAULT_UP=new ez(0,1,0),tK.DEFAULT_MATRIX_AUTO_UPDATE=!0,tK.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;let tQ=new ez,t0=new ez,t1=new ez,t2=new ez,t3=new ez,t4=new ez,t5=new ez,t6=new ez,t8=new ez,t9=new ez,t7=new e1,ne=new e1,nt=new e1;class nn{constructor(e=new ez,t=new ez,n=new ez){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),tQ.subVectors(e,t),i.cross(tQ);let r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){tQ.subVectors(i,t),t0.subVectors(n,t),t1.subVectors(e,t);let a=tQ.dot(tQ),s=tQ.dot(t0),o=tQ.dot(t1),l=t0.dot(t0),u=t0.dot(t1),c=a*l-s*s;if(0===c)return r.set(0,0,0),null;let h=1/c,d=(l*o-s*u)*h,p=(a*u-s*o)*h;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,t2)&&t2.x>=0&&t2.y>=0&&t2.x+t2.y<=1}static getInterpolation(e,t,n,i,r,a,s,o){return null===this.getBarycoord(e,t,n,i,t2)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,t2.x),o.addScaledVector(a,t2.y),o.addScaledVector(s,t2.z),o)}static getInterpolatedAttribute(e,t,n,i,r,a){return t7.setScalar(0),ne.setScalar(0),nt.setScalar(0),t7.fromBufferAttribute(e,t),ne.fromBufferAttribute(e,n),nt.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(t7,r.x),a.addScaledVector(ne,r.y),a.addScaledVector(nt,r.z),a}static isFrontFacing(e,t,n,i){return tQ.subVectors(n,t),t0.subVectors(e,t),0>tQ.cross(t0).dot(i)}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 tQ.subVectors(this.c,this.b),t0.subVectors(this.a,this.b),.5*tQ.cross(t0).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return nn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return nn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n,i,r=this.a,a=this.b,s=this.c;t3.subVectors(a,r),t4.subVectors(s,r),t6.subVectors(e,r);let o=t3.dot(t6),l=t4.dot(t6);if(o<=0&&l<=0)return t.copy(r);t8.subVectors(e,a);let u=t3.dot(t8),c=t4.dot(t8);if(u>=0&&c<=u)return t.copy(a);let h=o*c-u*l;if(h<=0&&o>=0&&u<=0)return n=o/(o-u),t.copy(r).addScaledVector(t3,n);t9.subVectors(e,s);let d=t3.dot(t9),p=t4.dot(t9);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(r).addScaledVector(t4,i);let m=u*p-d*c;if(m<=0&&c-u>=0&&d-p>=0)return t5.subVectors(s,a),i=(c-u)/(c-u+(d-p)),t.copy(a).addScaledVector(t5,i);let g=1/(m+f+h);return n=f*g,i=h*g,t.copy(r).addScaledVector(t3,n).addScaledVector(t4,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let ni={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32},nr={h:0,s:0,l:0},na={h:0,s:0,l:0};function ns(e,t,n){return(n<0&&(n+=1),n>1&&(n-=1),n<1/6)?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*6*(2/3-n):e}class no{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){return void 0===t&&void 0===n?e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e):this.setRGB(e,t,n),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=en){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,eW.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=eW.workingColorSpace){return this.r=e,this.g=t,this.b=n,eW.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=eW.workingColorSpace){if(e=eI(e,1),t=eP(t,0,1),n=eP(n,0,1),0===t)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=ns(r,i,e+1/3),this.g=ns(r,i,e),this.b=ns(r,i,e-1/3)}return eW.colorSpaceToWorking(this,i),this}setStyle(e,t=en){let n;function i(t){void 0!==t&&1>parseFloat(t)&&eb("Color: Alpha component of "+e+" will be ignored.")}if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=n[1],s=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:eb("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(i,16),t);eb("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=en){let n=ni[e.toLowerCase()];return void 0!==n?this.setHex(n,t):eb("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=eX(e.r),this.g=eX(e.g),this.b=eX(e.b),this}copyLinearToSRGB(e){return this.r=eq(e.r),this.g=eq(e.g),this.b=eq(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=en){return eW.workingToColorSpace(nl.copy(this),e),65536*Math.round(eP(255*nl.r,0,255))+256*Math.round(eP(255*nl.g,0,255))+Math.round(eP(255*nl.b,0,255))}getHexString(e=en){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=eW.workingColorSpace){let n,i;eW.workingToColorSpace(nl.copy(this),t);let r=nl.r,a=nl.g,s=nl.b,o=Math.max(r,a,s),l=Math.min(r,a,s),u=(l+o)/2;if(l===o)n=0,i=0;else{let e=o-l;switch(i=u<=.5?e/(o+l):e/(2-o-l),o){case r:n=(a-s)/e+6*(a<s);break;case a:n=(s-r)/e+2;break;case s:n=(r-a)/e+4}n/=6}return e.h=n,e.s=i,e.l=u,e}getRGB(e,t=eW.workingColorSpace){return eW.workingToColorSpace(nl.copy(this),t),e.r=nl.r,e.g=nl.g,e.b=nl.b,e}getStyle(e=en){eW.workingToColorSpace(nl.copy(this),e);let t=nl.r,n=nl.g,i=nl.b;return e!==en?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(e,t,n){return this.getHSL(nr),this.setHSL(nr.h+e,nr.s+t,nr.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(nr),e.getHSL(na);let n=eL(nr.h,na.h,t),i=eL(nr.s,na.s,t),r=eL(nr.l,na.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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}}let nl=new no;no.NAMES=ni;let nu=0;class nc extends ew{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:nu++}),this.uuid=eR(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new no(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,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(void 0!==e)for(let t in e){let n=e[t];if(void 0===n){eb(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){eb(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),100!==this.blendEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),7680!==this.stencilFail&&(n.stencilFail=this.stencilFail),7680!==this.stencilZFail&&(n.stencilZFail=this.stencilZFail),7680!==this.stencilZPass&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){let t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}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,n=null;if(null!==t){let e=t.length;n=Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,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){!0===e&&this.version++}}class nh extends nc{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new no(0xffffff),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 tU,this.combine=0,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}}let nd=function(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}let a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;(8388608&t)==0;)t<<=1,n-=8388608;t&=-8388609,n+=0x38800000,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=0x38000000+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=0x47800000,s[32]=0x80000000;for(let e=33;e<63;++e)s[e]=0x80000000+(e-32<<23);s[63]=0xc7800000;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}();function np(e){Math.abs(e)>65504&&eb("DataUtils.toHalfFloat(): Value out of range."),e=eP(e,-65504,65504),nd.floatView[0]=e;let t=nd.uint32View[0],n=t>>23&511;return nd.baseTable[n]+((8388607&t)>>nd.shiftTable[n])}function nf(e){let t=e>>10;return nd.uint32View[0]=nd.mantissaTable[nd.offsetTable[t]+(1023&e)]+nd.exponentTable[t],nd.floatView[0]}class nm{static toHalfFloat(e){return np(e)}static fromHalfFloat(e){return nf(e)}}let ng=new ez,nv=new eO,nx=0;class ny{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:nx++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)nv.fromBufferAttribute(this,t),nv.applyMatrix3(e),this.setXY(t,nv.x,nv.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)ng.fromBufferAttribute(this,t),ng.applyMatrix3(e),this.setXYZ(t,ng.x,ng.y,ng.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ng.fromBufferAttribute(this,t),ng.applyMatrix4(e),this.setXYZ(t,ng.x,ng.y,ng.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ng.fromBufferAttribute(this,t),ng.applyNormalMatrix(e),this.setXYZ(t,ng.x,ng.y,ng.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ng.fromBufferAttribute(this,t),ng.transformDirection(e),this.setXYZ(t,ng.x,ng.y,ng.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=eN(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=eD(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=eN(t,this.array)),t}setX(e,t){return this.normalized&&(t=eD(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=eN(t,this.array)),t}setY(e,t){return this.normalized&&(t=eD(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=eN(t,this.array)),t}setZ(e,t){return this.normalized&&(t=eD(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=eN(t,this.array)),t}setW(e,t){return this.normalized&&(t=eD(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array),i=eD(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array),i=eD(i,this.array),r=eD(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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""!==this.name&&(e.name=this.name),35044!==this.usage&&(e.usage=this.usage),e}}class n_ extends ny{constructor(e,t,n){super(new Int8Array(e),t,n)}}class nb extends ny{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class nS extends ny{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class nM extends ny{constructor(e,t,n){super(new Int16Array(e),t,n)}}class nw extends ny{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class nT extends ny{constructor(e,t,n){super(new Int32Array(e),t,n)}}class nE extends ny{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class nA extends ny{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=nf(this.array[e*this.itemSize]);return this.normalized&&(t=eN(t,this.array)),t}setX(e,t){return this.normalized&&(t=eD(t,this.array)),this.array[e*this.itemSize]=np(t),this}getY(e){let t=nf(this.array[e*this.itemSize+1]);return this.normalized&&(t=eN(t,this.array)),t}setY(e,t){return this.normalized&&(t=eD(t,this.array)),this.array[e*this.itemSize+1]=np(t),this}getZ(e){let t=nf(this.array[e*this.itemSize+2]);return this.normalized&&(t=eN(t,this.array)),t}setZ(e,t){return this.normalized&&(t=eD(t,this.array)),this.array[e*this.itemSize+2]=np(t),this}getW(e){let t=nf(this.array[e*this.itemSize+3]);return this.normalized&&(t=eN(t,this.array)),t}setW(e,t){return this.normalized&&(t=eD(t,this.array)),this.array[e*this.itemSize+3]=np(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array)),this.array[e+0]=np(t),this.array[e+1]=np(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array),i=eD(i,this.array)),this.array[e+0]=np(t),this.array[e+1]=np(n),this.array[e+2]=np(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array),i=eD(i,this.array),r=eD(r,this.array)),this.array[e+0]=np(t),this.array[e+1]=np(n),this.array[e+2]=np(i),this.array[e+3]=np(r),this}}class nC extends ny{constructor(e,t,n){super(new Float32Array(e),t,n)}}let nR=0,nP=new tT,nI=new tK,nL=new ez,nN=new e9,nD=new e9,nU=new ez;class nO extends ew{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:nR++}),this.uuid=eR(),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={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ec(e)?nE:nw)(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 void 0!==this.attributes[e]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(void 0!==n){let t=new eV().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return nP.makeRotationFromQuaternion(e),this.applyMatrix4(nP),this}rotateX(e){return nP.makeRotationX(e),this.applyMatrix4(nP),this}rotateY(e){return nP.makeRotationY(e),this.applyMatrix4(nP),this}rotateZ(e){return nP.makeRotationZ(e),this.applyMatrix4(nP),this}translate(e,t,n){return nP.makeTranslation(e,t,n),this.applyMatrix4(nP),this}scale(e,t,n){return nP.makeScale(e,t,n),this.applyMatrix4(nP),this}lookAt(e){return nI.lookAt(e),nI.updateMatrix(),this.applyMatrix4(nI.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(nL).negate(),this.translate(nL.x,nL.y,nL.z),this}setFromPoints(e){let t=this.getAttribute("position");if(void 0===t){let t=[];for(let n=0,i=e.length;n<i;n++){let i=e[n];t.push(i.x,i.y,i.z||0)}this.setAttribute("position",new nC(t,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let n=e[i];t.setXYZ(i,n.x,n.y,n.z||0)}e.length>t.count&&eb("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new e9);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){eS("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ez(-1/0,-1/0,-1/0),new ez(Infinity,Infinity,Infinity));return}if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];nN.setFromBufferAttribute(n),this.morphTargetsRelative?(nU.addVectors(this.boundingBox.min,nN.min),this.boundingBox.expandByPoint(nU),nU.addVectors(this.boundingBox.max,nN.max),this.boundingBox.expandByPoint(nU)):(this.boundingBox.expandByPoint(nN.min),this.boundingBox.expandByPoint(nN.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&eS('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new tg);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){eS("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ez,1/0);return}if(e){let n=this.boundingSphere.center;if(nN.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];nD.setFromBufferAttribute(n),this.morphTargetsRelative?(nU.addVectors(nN.min,nD.min),nN.expandByPoint(nU),nU.addVectors(nN.max,nD.max),nN.expandByPoint(nU)):(nN.expandByPoint(nD.min),nN.expandByPoint(nD.max))}nN.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)nU.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(nU));if(t)for(let r=0,a=t.length;r<a;r++){let a=t[r],s=this.morphTargetsRelative;for(let t=0,r=a.count;t<r;t++)nU.fromBufferAttribute(a,t),s&&(nL.fromBufferAttribute(e,t),nU.add(nL)),i=Math.max(i,n.distanceToSquared(nU))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&eS('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(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void eS("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");let n=t.position,i=t.normal,r=t.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new ny(new Float32Array(4*n.count),4));let a=this.getAttribute("tangent"),s=[],o=[];for(let e=0;e<n.count;e++)s[e]=new ez,o[e]=new ez;let l=new ez,u=new ez,c=new ez,h=new eO,d=new eO,p=new eO,f=new ez,m=new ez,g=this.groups;0===g.length&&(g=[{start:0,count:e.count}]);for(let t=0,i=g.length;t<i;++t){let i=g[t],a=i.start,v=i.count;for(let t=a,i=a+v;t<i;t+=3)!function(e,t,i){l.fromBufferAttribute(n,e),u.fromBufferAttribute(n,t),c.fromBufferAttribute(n,i),h.fromBufferAttribute(r,e),d.fromBufferAttribute(r,t),p.fromBufferAttribute(r,i),u.sub(l),c.sub(l),d.sub(h),p.sub(h);let a=1/(d.x*p.y-p.x*d.y);isFinite(a)&&(f.copy(u).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(a),m.copy(c).multiplyScalar(d.x).addScaledVector(u,-p.x).multiplyScalar(a),s[e].add(f),s[t].add(f),s[i].add(f),o[e].add(m),o[t].add(m),o[i].add(m))}(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new ez,x=new ez,y=new ez,_=new ez;function b(e){y.fromBufferAttribute(i,e),_.copy(y);let t=s[e];v.copy(t),v.sub(y.multiplyScalar(y.dot(t))).normalize(),x.crossVectors(_,t);let n=x.dot(o[e]);a.setXYZW(e,v.x,v.y,v.z,n<0?-1:1)}for(let t=0,n=g.length;t<n;++t){let n=g[t],i=n.start,r=n.count;for(let t=i,n=i+r;t<n;t+=3)b(e.getX(t+0)),b(e.getX(t+1)),b(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new ny(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let i=new ez,r=new ez,a=new ez,s=new ez,o=new ez,l=new ez,u=new ez,c=new ez;if(e)for(let h=0,d=e.count;h<d;h+=3){let d=e.getX(h+0),p=e.getX(h+1),f=e.getX(h+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),a.fromBufferAttribute(t,f),u.subVectors(a,r),c.subVectors(i,r),u.cross(c),s.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),s.add(u),o.add(u),l.add(u),n.setXYZ(d,s.x,s.y,s.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,s=t.count;e<s;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),u.subVectors(a,r),c.subVectors(i,r),u.cross(c),n.setXYZ(e+0,u.x,u.y,u.z),n.setXYZ(e+1,u.x,u.y,u.z),n.setXYZ(e+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)nU.fromBufferAttribute(e,t),nU.normalize(),e.setXYZ(t,nU.x,nU.y,nU.z)}toNonIndexed(){function e(e,t){let n=e.array,i=e.itemSize,r=e.normalized,a=new n.constructor(t.length*i),s=0,o=0;for(let r=0,l=t.length;r<l;r++){s=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*i;for(let e=0;e<i;e++)a[o++]=n[s++]}return new ny(a,i,r)}if(null===this.index)return eb("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new nO,n=this.index.array,i=this.attributes;for(let r in i){let a=e(i[r],n);t.setAttribute(r,a)}let r=this.morphAttributes;for(let i in r){let a=[],s=r[i];for(let t=0,i=s.length;t<i;t++){let i=e(s[t],n);a.push(i)}t.morphAttributes[i]=a}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let e=0,n=a.length;e<n;e++){let n=a[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){let t=this.parameters;for(let n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let i=n[t];e.data.attributes[t]=i.toJSON(e.data)}let i={},r=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t<i;t++){let i=n[t];a.push(i.toJSON(e.data))}a.length>0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let s=this.boundingSphere;return null!==s&&(e.data.boundingSphere=s.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 n=e.index;null!==n&&this.setIndex(n.clone());let i=e.attributes;for(let e in i){let n=i[e];this.setAttribute(e,n.clone(t))}let r=e.morphAttributes;for(let e in r){let n=[],i=r[e];for(let e=0,r=i.length;e<r;e++)n.push(i[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let s=e.boundingBox;null!==s&&(this.boundingBox=s.clone());let o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let nF=new tT,nz=new tw,nk=new tg,nB=new ez,nV=new ez,nH=new ez,nj=new ez,nG=new ez,nW=new ez,nX=new ez,nq=new ez;class nY extends tK{constructor(e=new nO,t=new nh){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),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let s=this.morphTargetInfluences;if(r&&s){nW.set(0,0,0);for(let n=0,i=r.length;n<i;n++){let i=s[n],o=r[n];0!==i&&(nG.fromBufferAttribute(o,e),a?nW.addScaledVector(nG,i):nW.addScaledVector(nG.sub(t),i))}t.add(nW)}return t}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;void 0===i||(null===n.boundingSphere&&n.computeBoundingSphere(),nk.copy(n.boundingSphere),nk.applyMatrix4(r),nz.copy(e.ray).recast(e.near),!1===nk.containsPoint(nz.origin)&&(null===nz.intersectSphere(nk,nB)||nz.origin.distanceToSquared(nB)>(e.far-e.near)**2)||(nF.copy(r).invert(),nz.copy(e.ray).applyMatrix4(nF),(null===n.boundingBox||!1!==nz.intersectsBox(n.boundingBox))&&this._computeIntersections(e,t,nz)))}_computeIntersections(e,t,n){let i,r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,c=r.attributes.normal,h=r.groups,d=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=h.length;r<o;r++){let o=h[r],p=a[o.materialIndex],f=Math.max(o.start,d.start),m=Math.min(s.count,Math.min(o.start+o.count,d.start+d.count));for(let r=f;r<m;r+=3)(i=nZ(this,p,e,n,l,u,c,s.getX(r),s.getX(r+1),s.getX(r+2)))&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,t.push(i))}else{let r=Math.max(0,d.start),o=Math.min(s.count,d.start+d.count);for(let h=r;h<o;h+=3)(i=nZ(this,a,e,n,l,u,c,s.getX(h),s.getX(h+1),s.getX(h+2)))&&(i.faceIndex=Math.floor(h/3),t.push(i))}else if(void 0!==o)if(Array.isArray(a))for(let r=0,s=h.length;r<s;r++){let s=h[r],p=a[s.materialIndex],f=Math.max(s.start,d.start),m=Math.min(o.count,Math.min(s.start+s.count,d.start+d.count));for(let r=f;r<m;r+=3)(i=nZ(this,p,e,n,l,u,c,r,r+1,r+2))&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=s.materialIndex,t.push(i))}else{let r=Math.max(0,d.start),s=Math.min(o.count,d.start+d.count);for(let o=r;o<s;o+=3)(i=nZ(this,a,e,n,l,u,c,o,o+1,o+2))&&(i.faceIndex=Math.floor(o/3),t.push(i))}}}function nZ(e,t,n,i,r,a,s,o,l,u){e.getVertexPosition(o,nV),e.getVertexPosition(l,nH),e.getVertexPosition(u,nj);let c=function(e,t,n,i,r,a,s,o){if(null===(1===t.side?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,0===t.side,o)))return null;nq.copy(o),nq.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(nq);return l<n.near||l>n.far?null:{distance:l,point:nq.clone(),object:e}}(e,t,n,i,nV,nH,nj,nX);if(c){let e=new ez;nn.getBarycoord(nX,nV,nH,nj,e),r&&(c.uv=nn.getInterpolatedAttribute(r,o,l,u,e,new eO)),a&&(c.uv1=nn.getInterpolatedAttribute(a,o,l,u,e,new eO)),s&&(c.normal=nn.getInterpolatedAttribute(s,o,l,u,e,new ez),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let t={a:o,b:l,c:u,normal:new ez,materialIndex:0};nn.getNormal(nV,nH,nj,t.normal),c.face=t,c.barycoord=e}return c}class nJ extends nO{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r);const o=[],l=[],u=[],c=[];let h=0,d=0;function p(e,t,n,i,r,a,p,f,m,g,v){let x=a/m,y=p/g,_=a/2,b=p/2,S=f/2,M=m+1,w=g+1,T=0,E=0,A=new ez;for(let a=0;a<w;a++){let s=a*y-b;for(let o=0;o<M;o++){let h=o*x-_;A[e]=h*i,A[t]=s*r,A[n]=S,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[n]=f>0?1:-1,u.push(A.x,A.y,A.z),c.push(o/m),c.push(1-a/g),T+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){let n=h+t+M*e,i=h+t+M*(e+1),r=h+(t+1)+M*(e+1),a=h+(t+1)+M*e;o.push(n,i,a),o.push(i,r,a),E+=6}s.addGroup(d,E,v),d+=E,h+=T}p("z","y","x",-1,-1,n,t,e,a=Math.floor(a),r,0),p("z","y","x",1,-1,n,t,-e,a,r,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new nC(l,3)),this.setAttribute("normal",new nC(u,3)),this.setAttribute("uv",new nC(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nJ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function n$(e){let t={};for(let n in e)for(let i in t[n]={},e[n]){let r=e[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(eb("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null):t[n][i]=r.clone():Array.isArray(r)?t[n][i]=r.slice():t[n][i]=r}return t}function nK(e){let t={};for(let n=0;n<e.length;n++){let i=n$(e[n]);for(let e in i)t[e]=i[e]}return t}function nQ(e){let t=e.getRenderTarget();return null===t?e.outputColorSpace:!0===t.isXRRenderTarget?t.texture.colorSpace:eW.workingColorSpace}let n0={clone:n$,merge:nK};class n1 extends nc{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",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,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=n$(e.uniforms),this.uniformsGroups=function(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(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);for(let n in t.glslVersion=this.glslVersion,t.uniforms={},this.uniforms){let i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}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 n={};for(let e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class n2 extends tK{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tT,this.projectionMatrix=new tT,this.projectionMatrixInverse=new tT,this.coordinateSystem=2e3,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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}let n3=new ez,n4=new eO,n5=new eO;class n6 extends n2{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*eC*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*eA*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*eC*Math.atan(Math.tan(.5*eA*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,n){n3.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(n3.x,n3.y).multiplyScalar(-e/n3.z),n3.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(n3.x,n3.y).multiplyScalar(-e/n3.z)}getViewSize(e,t){return this.getViewBounds(e,n4,n5),t.subVectors(n5,n4)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*eA*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}let s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class n8 extends tK{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new n6(-90,1,e,t);i.layers=this.layers,this.add(i);const r=new n6(-90,1,e,t);r.layers=this.layers,this.add(r);const a=new n6(-90,1,e,t);a.layers=this.layers,this.add(a);const s=new n6(-90,1,e,t);s.layers=this.layers,this.add(s);const o=new n6(-90,1,e,t);o.layers=this.layers,this.add(o);const l=new n6(-90,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(let e of t)this.remove(e);if(2e3===e)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(2001===e)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,s,o,l,u]=this.children,c=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(c,h,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class n9 extends e0{constructor(e=[],t=301,n,i,r,a,s,o,l,u){super(e,t,n,i,r,a,s,o,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class n7 extends e3{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1};this.texture=new n9([n,n,n,n,n,n]),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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
2
+
3
+ varying vec3 vWorldDirection;
4
+
5
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
6
+
7
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
8
+
9
+ }
10
+
11
+ void main() {
12
+
13
+ vWorldDirection = transformDirection( position, modelMatrix );
14
+
15
+ #include <begin_vertex>
16
+ #include <project_vertex>
17
+
18
+ }
19
+ `,fragmentShader:`
20
+
21
+ uniform sampler2D tEquirect;
22
+
23
+ varying vec3 vWorldDirection;
24
+
25
+ #include <common>
26
+
27
+ void main() {
28
+
29
+ vec3 direction = normalize( vWorldDirection );
30
+
31
+ vec2 sampleUV = equirectUv( direction );
32
+
33
+ gl_FragColor = texture2D( tEquirect, sampleUV );
34
+
35
+ }
36
+ `},i=new nJ(5,5,5),r=new n1({name:"CubemapFromEquirect",uniforms:n$(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;let a=new nY(i,r),s=t.minFilter;return 1008===t.minFilter&&(t.minFilter=1006),new n8(1,10,this).update(e,a),t.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}class ie extends tK{constructor(){super(),this.isGroup=!0,this.type="Group"}}let it={type:"move"};class ii{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new ie,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new ie,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ez,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ez),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new ie,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ez,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ez),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null,s=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){for(let i of(a=!0,e.hand.values())){let e=t.getJointPose(i,n),r=this._getHandJoint(l,i);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}let i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=i.position.distanceTo(r.position);l.inputState.pinching&&s>.025?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,n))&&(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);null!==s&&(null===(i=t.getPose(e.targetRaySpace,n))&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(it)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let n=new ie;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class ir{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new no(e),this.density=t}clone(){return new ir(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class ia{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new no(e),this.near=t,this.far=n}clone(){return new ia(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class is extends tK{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 tU,this.environmentIntensity=1,this.environmentRotation=new tU,this.overrideMaterial=null,"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(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),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class io{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=eR()}onUploadCallback(){}set needsUpdate(e){!0===e&&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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=eR()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=eR()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}let il=new ez;class iu{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)il.fromBufferAttribute(this,t),il.applyMatrix4(e),this.setXYZ(t,il.x,il.y,il.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)il.fromBufferAttribute(this,t),il.applyNormalMatrix(e),this.setXYZ(t,il.x,il.y,il.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)il.fromBufferAttribute(this,t),il.transformDirection(e),this.setXYZ(t,il.x,il.y,il.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=eN(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=eD(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=eD(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=eD(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=eD(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=eD(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=eN(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=eN(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=eN(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=eN(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array),i=eD(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=eD(t,this.array),n=eD(n,this.array),i=eD(i,this.array),r=eD(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(void 0!==e)return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new iu(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized);{e_("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new ny(new this.array.constructor(e),this.itemSize,this.normalized)}}toJSON(e){if(void 0!==e)return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized};{e_("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}}}class ic extends nc{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new no(0xffffff),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ih=new ez,id=new ez,ip=new ez,im=new eO,ig=new eO,iv=new tT,ix=new ez,iy=new ez,i_=new ez,ib=new eO,iS=new eO,iM=new eO;class iw extends tK{constructor(e=new ic){if(super(),this.isSprite=!0,this.type="Sprite",void 0===n){n=new nO;const e=new io(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);n.setIndex([0,1,2,0,2,3]),n.setAttribute("position",new iu(e,3,0,!1)),n.setAttribute("uv",new iu(e,2,3,!1))}this.geometry=n,this.material=e,this.center=new eO(.5,.5),this.count=1}raycast(e,t){let n,i;null===e.camera&&eS('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),id.setFromMatrixScale(this.matrixWorld),iv.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ip.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&id.multiplyScalar(-ip.z);let r=this.material.rotation;0!==r&&(i=Math.cos(r),n=Math.sin(r));let a=this.center;iT(ix.set(-.5,-.5,0),ip,a,id,n,i),iT(iy.set(.5,-.5,0),ip,a,id,n,i),iT(i_.set(.5,.5,0),ip,a,id,n,i),ib.set(0,0),iS.set(1,0),iM.set(1,1);let s=e.ray.intersectTriangle(ix,iy,i_,!1,ih);if(null===s&&(iT(iy.set(-.5,.5,0),ip,a,id,n,i),iS.set(0,1),null===(s=e.ray.intersectTriangle(ix,i_,iy,!1,ih))))return;let o=e.ray.origin.distanceTo(ih);o<e.near||o>e.far||t.push({distance:o,point:ih.clone(),uv:nn.getInterpolation(ih,ix,iy,i_,ib,iS,iM,new eO),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function iT(e,t,n,i,r,a){im.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(ig.x=a*im.x-r*im.y,ig.y=r*im.x+a*im.y):ig.copy(im),e.copy(t),e.x+=ig.x,e.y+=ig.y,e.applyMatrix4(iv)}let iE=new ez,iA=new ez;class iC extends tK{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){let i;t=Math.abs(t);let r=this.levels;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let e=t.splice(n,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let i=t[n].distance;if(t[n].object.visible&&(i-=i*t[n].hysteresis),e<i)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){iE.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(iE);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){let n,i;iE.setFromMatrixPosition(e.matrixWorld),iA.setFromMatrixPosition(this.matrixWorld);let r=iE.distanceTo(iA)/e.zoom;for(n=1,t[0].object.visible=!0,i=t.length;n<i;n++){let e=t[n].distance;if(t[n].object.visible&&(e-=e*t[n].hysteresis),r>=e)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n<i;n++)t[n].object.visible=!1}}toJSON(e){let t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let e=0,i=n.length;e<i;e++){let i=n[e];t.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return t}}let iR=new ez,iP=new e1,iI=new e1,iL=new ez,iN=new tT,iD=new ez,iU=new tg,iO=new tT,iF=new tw;class iz extends nY{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ee,this.bindMatrix=new tT,this.bindMatrixInverse=new tT,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;null===this.boundingBox&&(this.boundingBox=new e9),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,iD),this.boundingBox.expandByPoint(iD)}computeBoundingSphere(){let e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new tg),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,iD),this.boundingSphere.expandByPoint(iD)}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,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,i=this.matrixWorld;void 0===n||(null===this.boundingSphere&&this.computeBoundingSphere(),iU.copy(this.boundingSphere),iU.applyMatrix4(i),!1===e.ray.intersectsSphere(iU)||(iO.copy(i).invert(),iF.copy(e.ray).applyMatrix4(iO),(null===this.boundingBox||!1!==iF.intersectsBox(this.boundingBox))&&this._computeIntersections(e,t,iF)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(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 e1,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ee?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===et?this.bindMatrixInverse.copy(this.bindMatrix).invert():eb("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;iP.fromBufferAttribute(i.attributes.skinIndex,e),iI.fromBufferAttribute(i.attributes.skinWeight,e),iR.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let i=iI.getComponent(e);if(0!==i){let r=iP.getComponent(e);iN.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),t.addScaledVector(iL.copy(iR).applyMatrix4(iN),i)}}return t.applyMatrix4(this.bindMatrixInverse)}}class ik extends tK{constructor(){super(),this.isBone=!0,this.type="Bone"}}class iB extends e0{constructor(e=null,t=1,n=1,i,r,a,s,o,l=1003,u=1003,c,h){super(null,a,s,o,l,u,i,r,c,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}let iV=new tT,iH=new tT;class ij{constructor(e=[],t=[]){this.uuid=eR(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){eb("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new tT)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new tT;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=e.length;i<r;i++){let r=e[i]?e[i].matrixWorld:iH;iV.multiplyMatrices(r,t[i]),iV.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new ij(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length),t=new Float32Array((e=Math.max(e=4*Math.ceil(e/4),4))*e*4);t.set(this.boneMatrices);let n=new iB(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let i=e.bones[n],r=t[i];void 0===r&&(eb("Skeleton: No bone found with UUID:",i),r=new ik),this.bones.push(r),this.boneInverses.push(new tT().fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let r=t[i];e.bones.push(r.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}}class iG extends ny{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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}}let iW=new tT,iX=new tT,iq=[],iY=new e9,iZ=new tT,iJ=new nY,i$=new tg;class iK extends nY{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new iG(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,iZ)}computeBoundingBox(){let e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new e9),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,iW),iY.copy(e.boundingBox).applyMatrix4(iW),this.boundingBox.union(iY)}computeBoundingSphere(){let e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new tg),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,iW),i$.copy(e.boundingSphere).applyMatrix4(iW),this.boundingSphere.union(i$)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.morphTexture&&(this.morphTexture=e.morphTexture.clone()),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=i[r+e]}raycast(e,t){let n=this.matrixWorld,i=this.count;if((iJ.geometry=this.geometry,iJ.material=this.material,void 0!==iJ.material)&&(null===this.boundingSphere&&this.computeBoundingSphere(),i$.copy(this.boundingSphere),i$.applyMatrix4(n),!1!==e.ray.intersectsSphere(i$)))for(let r=0;r<i;r++){this.getMatrixAt(r,iW),iX.multiplyMatrices(n,iW),iJ.matrixWorld=iX,iJ.raycast(e,iq);for(let e=0,n=iq.length;e<n;e++){let n=iq[e];n.instanceId=r,n.object=this,t.push(n)}iq.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new iG(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new iB(new Float32Array(i*this.count),i,this.count,1028,1015));let r=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let s=this.geometry.morphTargetsRelative?1:1-a,o=i*e;r[o]=s,r.set(n,o+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}let iQ=new ez,i0=new ez,i1=new eV;class i2{constructor(e=new ez(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,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=iQ.subVectors(n,t).cross(i0.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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){let n=e.delta(iQ),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||i1.getNormalMatrix(e),i=this.coplanarPoint(iQ).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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)}}let i3=new tg,i4=new eO(.5,.5),i5=new ez;class i6{constructor(e=new i2,t=new i2,n=new i2,i=new i2,r=new i2,a=new i2){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3,n=!1){let i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],u=r[4],c=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],x=r[13],y=r[14],_=r[15];if(i[0].setComponents(l-a,d-u,g-p,_-v).normalize(),i[1].setComponents(l+a,d+u,g+p,_+v).normalize(),i[2].setComponents(l+s,d+c,g+f,_+x).normalize(),i[3].setComponents(l-s,d-c,g-f,_-x).normalize(),n)i[4].setComponents(o,h,m,y).normalize(),i[5].setComponents(l-o,d-h,g-m,_-y).normalize();else if(i[4].setComponents(l-o,d-h,g-m,_-y).normalize(),2e3===t)i[5].setComponents(l+o,d+h,g+m,_+y).normalize();else if(2001===t)i[5].setComponents(o,h,m,y).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),i3.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),i3.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(i3)}intersectsSprite(e){return i3.center.set(0,0,0),i3.radius=.7071067811865476+i4.distanceTo(e.center),i3.applyMatrix4(e.matrixWorld),this.intersectsSphere(i3)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(i5.x=i.normal.x>0?e.max.x:e.min.x,i5.y=i.normal.y>0?e.max.y:e.min.y,i5.z=i.normal.z>0?e.max.z:e.min.z,0>i.distanceToPoint(i5))return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(0>t[n].distanceToPoint(e))return!1;return!0}clone(){return new this.constructor().copy(this)}}let i8=new tT,i9=new i6;class i7{constructor(){this.coordinateSystem=2e3}intersectsObject(e,t){if(!t.isArrayCamera||0===t.cameras.length)return!1;for(let n=0;n<t.cameras.length;n++){let i=t.cameras[n];if(i8.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),i9.setFromProjectionMatrix(i8,i.coordinateSystem,i.reversedDepth),i9.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let n=0;n<t.cameras.length;n++){let i=t.cameras[n];if(i8.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),i9.setFromProjectionMatrix(i8,i.coordinateSystem,i.reversedDepth),i9.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let n=0;n<t.cameras.length;n++){let i=t.cameras[n];if(i8.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),i9.setFromProjectionMatrix(i8,i.coordinateSystem,i.reversedDepth),i9.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let n=0;n<t.cameras.length;n++){let i=t.cameras[n];if(i8.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),i9.setFromProjectionMatrix(i8,i.coordinateSystem,i.reversedDepth),i9.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||0===t.cameras.length)return!1;for(let n=0;n<t.cameras.length;n++){let i=t.cameras[n];if(i8.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),i9.setFromProjectionMatrix(i8,i.coordinateSystem,i.reversedDepth),i9.containsPoint(e))return!0}return!1}clone(){return new i7}}function re(e,t){return e-t}function rt(e,t){return e.z-t.z}function rn(e,t){return t.z-e.z}let ri=new tT,rr=new no(1,1,1),ra=new i6,rs=new i7,ro=new e9,rl=new tg,ru=new ez,rc=new ez,rh=new ez,rd=new class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){let r=this.pool,a=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let s=r[this.index];a.push(s),this.index++,s.start=e,s.count=t,s.z=n,s.index=i}reset(){this.list.length=0,this.index=0}},rp=new nY,rf=[];function rm(e,t){if(e.constructor!==t.constructor){let n=Math.min(e.length,t.length);for(let i=0;i<n;i++)t[i]=e[i]}else{let n=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,n))}}class rg extends nY{constructor(e,t,n=2*t,i){super(new nO,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(4*this._maxInstanceCount),t=new iB(new Float32Array((e=Math.max(e=4*Math.ceil(e/4),4))*e*4),e,e,1023,1015);this._matricesTexture=t}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount),t=new iB(new Uint32Array((e=Math.ceil(e))*e),e,e,1029,1014);this._indirectTexture=t}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount),t=new iB(new Float32Array((e=Math.ceil(e))*e*4).fill(1),e,e,1023,1015);t.colorSpace=eW.workingColorSpace,this._colorsTexture=t}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(let i in e.attributes){let{array:r,itemSize:a,normalized:s}=e.getAttribute(i),o=new ny(new r.constructor(n*a),a,s);t.setAttribute(i,o)}if(null!==e.getIndex()){let e=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new ny(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||!1===t[e].active)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||!1===t[e].active)throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new e9);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(!1===t[n].active)continue;let i=t[n].geometryIndex;this.getMatrixAt(n,ri),this.getBoundingBoxAt(i,ro).applyMatrix4(ri),e.union(ro)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new tg);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(!1===t[n].active)continue;let i=t[n].geometryIndex;this.getMatrixAt(n,ri),this.getBoundingSphereAt(i,rl).applyMatrix4(ri),e.union(rl)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw Error("THREE.BatchedMesh: Maximum item count reached.");let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(re),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let i=this._matricesTexture;ri.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;let r=this._colorsTexture;return r&&(rr.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){let i;this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},a=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=-1===t?e.getAttribute("position").count:t;let s=e.getIndex();if(null!==s&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=-1===n?s.count:n),-1!==r.indexStart&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(re),a[i=this._availableGeometryIds.shift()]=r):(i=this._geometryCount,this._geometryCount++,a.push(r)),this.setGeometryAt(i,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,i}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),a=t.getIndex(),s=this._geometryInfo[e];if(i&&a.count>s.reservedIndexCount||t.attributes.position.count>s.reservedVertexCount)throw Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let o=s.vertexStart,l=s.reservedVertexCount;for(let e in s.vertexCount=t.getAttribute("position").count,n.attributes){let i=t.getAttribute(e),r=n.getAttribute(e);!function(e,t,n=0){let i=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let r=e.count;for(let a=0;a<r;a++)for(let r=0;r<i;r++)t.setComponent(a+n,r,e.getComponent(a,r))}else t.array.set(e.array,n*i);t.needsUpdate=!0}(i,r,o);let a=i.itemSize;for(let e=i.count;e<l;e++){let t=o+e;for(let e=0;e<a;e++)r.setComponent(t,e,0)}r.needsUpdate=!0,r.addUpdateRange(o*a,l*a)}if(i){let e=s.indexStart,n=s.reservedIndexCount;s.indexCount=t.getIndex().count;for(let t=0;t<a.count;t++)r.setX(e+t,o+a.getX(t));for(let t=a.count;t<n;t++)r.setX(e+t,o);r.needsUpdate=!0,r.addUpdateRange(e,s.reservedIndexCount)}return s.start=i?s.indexStart:s.vertexStart,s.count=i?s.indexCount:s.vertexCount,s.boundingBox=null,null!==t.boundingBox&&(s.boundingBox=t.boundingBox.clone()),s.boundingSphere=null,null!==t.boundingSphere&&(s.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._geometryInfo;if(e>=t.length||!1===t[e].active)return this;let n=this._instanceInfo;for(let t=0,i=n.length;t<i;t++)n[t].active&&n[t].geometryIndex===e&&this.deleteInstance(t);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0,n=this._geometryInfo,i=n.map((e,t)=>t).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),r=this.geometry;for(let a=0,s=n.length;a<s;a++){let s=n[i[a]];if(!1!==s.active){if(null!==r.index){if(s.indexStart!==t){let{indexStart:n,vertexStart:i,reservedIndexCount:a}=s,o=r.index,l=o.array,u=e-i;for(let e=n;e<n+a;e++)l[e]=l[e]+u;o.array.copyWithin(t,n,n+a),o.addUpdateRange(t,a),o.needsUpdate=!0,s.indexStart=t}t+=s.reservedIndexCount}if(s.vertexStart!==e){let{vertexStart:t,reservedVertexCount:n}=s,i=r.attributes;for(let r in i){let a=i[r],{array:s,itemSize:o}=a;s.copyWithin(e*o,t*o,(t+n)*o),a.addUpdateRange(e*o,n*o),a.needsUpdate=!0}s.vertexStart=e}e+=s.reservedVertexCount,s.start=r.index?s.indexStart:s.vertexStart,this._nextIndexStart=r.index?s.indexStart+s.reservedIndexCount:0,this._nextVertexStart=s.vertexStart+s.reservedVertexCount}}return this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingBox){let e=new e9,t=n.index,r=n.attributes.position;for(let n=i.start,a=i.start+i.count;n<a;n++){let i=n;t&&(i=t.getX(i)),e.expandByPoint(ru.fromBufferAttribute(r,i))}i.boundingBox=e}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingSphere){let t=new tg;this.getBoundingBoxAt(e,ro),ro.getCenter(t.center);let r=n.index,a=n.attributes.position,s=0;for(let e=i.start,n=i.start+i.count;e<n;e++){let n=e;r&&(n=r.getX(n)),ru.fromBufferAttribute(a,n),s=Math.max(s,t.center.distanceToSquared(ru))}t.radius=Math.sqrt(s),i.boundingSphere=t}return t.copy(i.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,16*e),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,16*e)}setColorAt(e,t){return this.validateInstanceId(e),null===this._colorsTexture&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,4*e),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,4*e)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t||(this._instanceInfo[e].visible=t,this._visibilityChanged=!0),this}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);let n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){let t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(re);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let i=new Int32Array(e),r=new Int32Array(e);rm(this._multiDrawCounts,i),rm(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=e;let a=this._indirectTexture,s=this._matricesTexture,o=this._colorsTexture;a.dispose(),this._initIndirectTexture(),rm(a.image.data,this._indirectTexture.image.data),s.dispose(),this._initMatricesTexture(),rm(s.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),rm(o.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){let n=[...this._geometryInfo].filter(e=>e.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let i=this.geometry;i.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new nO,this._initializeGeometry(i));let r=this.geometry;for(let e in i.index&&rm(i.index.array,r.index.array),i.attributes)rm(i.attributes[e].array,r.attributes[e].array)}raycast(e,t){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;rp.material=this.material,rp.geometry.index=a.index,rp.geometry.attributes=a.attributes,null===rp.geometry.boundingBox&&(rp.geometry.boundingBox=new e9),null===rp.geometry.boundingSphere&&(rp.geometry.boundingSphere=new tg);for(let a=0,s=n.length;a<s;a++){if(!n[a].visible||!n[a].active)continue;let s=n[a].geometryIndex,o=i[s];rp.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(a,rp.matrixWorld).premultiply(r),this.getBoundingBoxAt(s,rp.geometry.boundingBox),this.getBoundingSphereAt(s,rp.geometry.boundingSphere),rp.raycast(e,rf);for(let e=0,n=rf.length;e<n;e++){let n=rf[e];n.object=this,n.batchId=a,t.push(n)}rf.length=0}rp.material=null,rp.geometry.index=null,rp.geometry.attributes={},rp.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=null!==e.boundingBox?e.boundingBox.clone():null,this.boundingSphere=null!==e.boundingSphere?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(e=>({...e,boundingBox:null!==e.boundingBox?e.boundingBox.clone():null,boundingSphere:null!==e.boundingSphere?e.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=i.getIndex(),s=null===a?1:a.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,c=this._geometryInfo,h=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data,f=n.isArrayCamera?rs:ra;h&&!n.isArrayCamera&&(ri.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ra.setFromProjectionMatrix(ri,n.coordinateSystem,n.reversedDepth));let m=0;if(this.sortObjects){ri.copy(this.matrixWorld).invert(),ru.setFromMatrixPosition(n.matrixWorld).applyMatrix4(ri),rc.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(ri);for(let e=0,t=o.length;e<t;e++)if(o[e].visible&&o[e].active){let t=o[e].geometryIndex;this.getMatrixAt(e,ri),this.getBoundingSphereAt(t,rl).applyMatrix4(ri);let i=!1;if(h&&(i=!f.intersectsSphere(rl,n)),!i){let n=c[t],i=rh.subVectors(rl.center,ru).dot(rc);rd.push(n.start,n.count,i,e)}}let e=rd.list,t=this.customSort;null===t?e.sort(r.transparent?rn:rt):t.call(this,e,n);for(let t=0,n=e.length;t<n;t++){let n=e[t];l[m]=n.start*s,u[m]=n.count,p[m]=n.index,m++}rd.reset()}else for(let e=0,t=o.length;e<t;e++)if(o[e].visible&&o[e].active){let t=o[e].geometryIndex,i=!1;if(h&&(this.getMatrixAt(e,ri),this.getBoundingSphereAt(t,rl).applyMatrix4(ri),i=!f.intersectsSphere(rl,n)),!i){let n=c[t];l[m]=n.start*s,u[m]=n.count,p[m]=e,m++}}d.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,r,a){this.onBeforeRender(e,null,i,r,a)}}class rv extends nc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new no(0xffffff),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}let rx=new ez,ry=new ez,r_=new tT,rb=new tw,rS=new tg,rM=new ez,rw=new ez;class rT extends tK{constructor(e=new nO,t=new rv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,n=[0];for(let e=1,i=t.count;e<i;e++)rx.fromBufferAttribute(t,e-1),ry.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=rx.distanceTo(ry);e.setAttribute("lineDistance",new nC(n,1))}else eb("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),rS.copy(n.boundingSphere),rS.applyMatrix4(i),rS.radius+=r,!1===e.ray.intersectsSphere(rS))return;r_.copy(i).invert(),rb.copy(e.ray).applyMatrix4(r_);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=this.isLineSegments?2:1,u=n.index,c=n.attributes.position;if(null!==u){let n=Math.max(0,a.start),i=Math.min(u.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){let n=rE(this,e,rb,o,u.getX(r),u.getX(r+1),r);n&&t.push(n)}if(this.isLineLoop){let r=rE(this,e,rb,o,u.getX(i-1),u.getX(n),i-1);r&&t.push(r)}}else{let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){let n=rE(this,e,rb,o,r,r+1,r);n&&t.push(n)}if(this.isLineLoop){let r=rE(this,e,rb,o,i-1,n,i-1);r&&t.push(r)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function rE(e,t,n,i,r,a,s){let o=e.geometry.attributes.position;if(rx.fromBufferAttribute(o,r),ry.fromBufferAttribute(o,a),n.distanceSqToSegment(rx,ry,rM,rw)>i)return;rM.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(rM);if(!(l<t.near)&&!(l>t.far))return{distance:l,point:rw.clone().applyMatrix4(e.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:e}}let rA=new ez,rC=new ez;class rR extends rT{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,n=[];for(let e=0,i=t.count;e<i;e+=2)rA.fromBufferAttribute(t,e),rC.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+rA.distanceTo(rC);e.setAttribute("lineDistance",new nC(n,1))}else eb("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class rP extends rT{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class rI extends nc{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new no(0xffffff),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let rL=new tT,rN=new tw,rD=new tg,rU=new ez;class rO extends tK{constructor(e=new nO,t=new rI){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),rD.copy(n.boundingSphere),rD.applyMatrix4(i),rD.radius+=r,!1===e.ray.intersectsSphere(rD))return;rL.copy(i).invert(),rN.copy(e.ray).applyMatrix4(rL);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=n.index,u=n.attributes.position;if(null!==l){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let a=n;a<r;a++){let n=l.getX(a);rU.fromBufferAttribute(u,n),rF(rU,n,o,i,e,t,this)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let a=n;a<r;a++)rU.fromBufferAttribute(u,a),rF(rU,a,o,i,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function rF(e,t,n,i,r,a,s){let o=rN.distanceSqToPoint(e);if(o<n){let n=new ez;rN.closestPointToPoint(e,n),n.applyMatrix4(i);let l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:s})}}class rz extends e0{constructor(e,t,n,i,r=1006,a=1006,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const u=this;"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(function t(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class rk extends rz{constructor(e,t,n,i,r,a,s,o){super({},e,t,n,i,r,a,s,o),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class rB extends e0{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}class rV extends e0{constructor(e,t,n,i,r,a,s,o,l,u,c,h){super(null,a,s,o,l,u,i,r,c,h),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class rH extends rV{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=1001,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class rj extends rV{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class rG extends e0{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class rW extends e0{constructor(e,t,n=1014,i,r,a,s=1003,o=1003,l,u=1026,c=1){if(1026!==u&&1027!==u)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:c},i,r,a,s,o,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new eJ(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class rX extends rW{constructor(e,t=1014,n=301,i,r,a=1003,s=1003,o,l=1026){const u={width:e,height:e,depth:1};super(e,e,t,n,i,r,a,s,o,l),this.image=[u,u,u,u,u,u],this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class rq extends e0{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class rY extends nO{constructor(e=1,t=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:r},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i));const a=[],s=[],o=[],l=[],u=t/2,c=Math.PI/2*e,h=t,d=2*c+h,p=2*n+(r=Math.max(1,Math.floor(r))),f=i+1,m=new ez,g=new ez;for(let v=0;v<=p;v++){let x=0,y=0,_=0,b=0;if(v<=n){const t=v/n,i=t*Math.PI/2;y=-u-e*Math.cos(i),_=e*Math.sin(i),b=-e*Math.cos(i),x=t*c}else if(v<=n+r){const i=(v-n)/r;y=-u+i*t,_=e,b=0,x=c+i*h}else{const t=(v-n-r)/n,i=t*Math.PI/2;y=u+e*Math.sin(i),_=e*Math.cos(i),b=e*Math.sin(i),x=c+h+t*c}const S=Math.max(0,Math.min(1,x/d));let M=0;0===v?M=.5/i:v===p&&(M=-.5/i);for(let e=0;e<=i;e++){const t=e/i,n=t*Math.PI*2,r=Math.sin(n),a=Math.cos(n);g.x=-_*a,g.y=y,g.z=_*r,s.push(g.x,g.y,g.z),m.set(-_*a,b,_*r),m.normalize(),o.push(m.x,m.y,m.z),l.push(t+M,S)}if(v>0){const e=(v-1)*f;for(let t=0;t<i;t++){const n=e+t,i=e+t+1,r=v*f+t,s=v*f+t+1;a.push(n,i,r),a.push(i,s,r)}}}this.setIndex(a),this.setAttribute("position",new nC(s,3)),this.setAttribute("normal",new nC(o,3)),this.setAttribute("uv",new nC(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rY(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class rZ extends nO{constructor(e=1,t=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],s=[],o=[],l=new ez,u=new eO;a.push(0,0,0),s.push(0,0,1),o.push(.5,.5);for(let r=0,c=3;r<=t;r++,c+=3){const h=n+r/t*i;l.x=e*Math.cos(h),l.y=e*Math.sin(h),a.push(l.x,l.y,l.z),s.push(0,0,1),u.x=(a[c]/e+1)/2,u.y=(a[c+1]/e+1)/2,o.push(u.x,u.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new nC(a,3)),this.setAttribute("normal",new nC(s,3)),this.setAttribute("uv",new nC(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rZ(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class rJ extends nO{constructor(e=1,t=1,n=1,i=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const u=[],c=[],h=[],d=[];let p=0;const f=[],m=n/2;let g=0;function v(n){let r=p,a=new eO,f=new ez,v=0,x=!0===n?e:t,y=!0===n?1:-1;for(let e=1;e<=i;e++)c.push(0,m*y,0),h.push(0,y,0),d.push(.5,.5),p++;let _=p;for(let e=0;e<=i;e++){let t=e/i*o+s,n=Math.cos(t),r=Math.sin(t);f.x=x*r,f.y=m*y,f.z=x*n,c.push(f.x,f.y,f.z),h.push(0,y,0),a.x=.5*n+.5,a.y=.5*r*y+.5,d.push(a.x,a.y),p++}for(let e=0;e<i;e++){let t=r+e,i=_+e;!0===n?u.push(i,i+1,t):u.push(i+1,i,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}(function(){let a=new ez,v=new ez,x=0,y=(t-e)/n;for(let l=0;l<=r;l++){let u=[],g=l/r,x=g*(t-e)+e;for(let e=0;e<=i;e++){let t=e/i,r=t*o+s,l=Math.sin(r),f=Math.cos(r);v.x=x*l,v.y=-g*n+m,v.z=x*f,c.push(v.x,v.y,v.z),a.set(l,y,f).normalize(),h.push(a.x,a.y,a.z),d.push(t,1-g),u.push(p++)}f.push(u)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){let a=f[i][n],s=f[i+1][n],o=f[i+1][n+1],l=f[i][n+1];(e>0||0!==i)&&(u.push(a,s,l),x+=3),(t>0||i!==r-1)&&(u.push(s,o,l),x+=3)}l.addGroup(g,x,0),g+=x})(),!1===a&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new nC(c,3)),this.setAttribute("normal",new nC(h,3)),this.setAttribute("uv",new nC(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rJ(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class r$ extends rJ{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,e,t,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(e){return new r$(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class rK extends nO{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e){r.push(e.x,e.y,e.z)}function o(t,n){let i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function l(e,t,n,i){i<0&&1===e.x&&(a[t]=e.x-1),0===n.x&&0===n.z&&(a[t]=i/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}(function(e){let n=new ez,i=new ez,r=new ez;for(let a=0;a<t.length;a+=3)o(t[a+0],n),o(t[a+1],i),o(t[a+2],r),function(e,t,n,i){let r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];let s=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)0===e&&i===r?a[i][e]=s:a[i][e]=s.clone().lerp(o,e/l)}for(let e=0;e<r;e++)for(let t=0;t<2*(r-e)-1;t++){let n=Math.floor(t/2);t%2==0?(s(a[e][n+1]),s(a[e+1][n]),s(a[e][n])):(s(a[e][n+1]),s(a[e+1][n+1]),s(a[e+1][n]))}}(n,i,r,e)})(i),function(e){let t=new ez;for(let n=0;n<r.length;n+=3)t.x=r[n+0],t.y=r[n+1],t.z=r[n+2],t.normalize().multiplyScalar(e),r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z}(n),function(){let e=new ez;for(let n=0;n<r.length;n+=3){var t;e.x=r[n+0],e.y=r[n+1],e.z=r[n+2];let i=u(e)/2/Math.PI+.5,s=Math.atan2(-(t=e).y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5;a.push(i,1-s)}(function(){let e=new ez,t=new ez,n=new ez,i=new ez,s=new eO,o=new eO,c=new eO;for(let h=0,d=0;h<r.length;h+=9,d+=6){e.set(r[h+0],r[h+1],r[h+2]),t.set(r[h+3],r[h+4],r[h+5]),n.set(r[h+6],r[h+7],r[h+8]),s.set(a[d+0],a[d+1]),o.set(a[d+2],a[d+3]),c.set(a[d+4],a[d+5]),i.copy(e).add(t).add(n).divideScalar(3);let p=u(i);l(s,d+0,e,p),l(o,d+2,t,p),l(c,d+4,n,p)}})(),function(){for(let e=0;e<a.length;e+=6){let t=a[e+0],n=a[e+2],i=a[e+4],r=Math.max(t,n,i),s=Math.min(t,n,i);r>.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new nC(r,3)),this.setAttribute("normal",new nC(r.slice(),3)),this.setAttribute("uv",new nC(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rK(e.vertices,e.indices,e.radius,e.detail)}}class rQ extends rK{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new rQ(e.radius,e.detail)}}let r0=new ez,r1=new ez,r2=new ez,r3=new nn;class r4 extends nO{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=Math.cos(eA*t),i=e.getIndex(),r=e.getAttribute("position"),a=i?i.count:r.count,s=[0,0,0],o=["a","b","c"],l=[,,,],u={},c=[];for(let e=0;e<a;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);const{a:t,b:a,c:h}=r3;if(t.fromBufferAttribute(r,s[0]),a.fromBufferAttribute(r,s[1]),h.fromBufferAttribute(r,s[2]),r3.getNormal(r2),l[0]=`${Math.round(1e4*t.x)},${Math.round(1e4*t.y)},${Math.round(1e4*t.z)}`,l[1]=`${Math.round(1e4*a.x)},${Math.round(1e4*a.y)},${Math.round(1e4*a.z)}`,l[2]=`${Math.round(1e4*h.x)},${Math.round(1e4*h.y)},${Math.round(1e4*h.z)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let e=0;e<3;e++){const t=(e+1)%3,i=l[e],r=l[t],a=r3[o[e]],h=r3[o[t]],d=`${i}_${r}`,p=`${r}_${i}`;p in u&&u[p]?(r2.dot(u[p].normal)<=n&&(c.push(a.x,a.y,a.z),c.push(h.x,h.y,h.z)),u[p]=null):d in u||(u[d]={index0:s[e],index1:s[t],normal:r2.clone()})}}for(const e in u)if(u[e]){const{index0:t,index1:n}=u[e];r0.fromBufferAttribute(r,t),r1.fromBufferAttribute(r,n),c.push(r0.x,r0.y,r0.z),c.push(r1.x,r1.y,r1.z)}this.setAttribute("position",new nC(c,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class r5{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){eb("Curve: .getPoint() not implemented.")}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/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=[],n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)t.push(r+=(n=this.getPoint(a/e)).distanceTo(i)),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];let s=0,o=a-1,l;for(;s<=o;)if((l=i[r=Math.floor(s+(o-s)/2)]-n)<0)s=r+1;else if(l>0)o=r-1;else{o=r;break}if(i[r=o]===n)return r/(a-1);let u=i[r],c=i[r+1];return(r+(n-u)/(c-u))/(a-1)}getTangent(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);let r=this.getPoint(n),a=this.getPoint(i),s=t||(r.isVector2?new eO:new ez);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new ez,i=[],r=[],a=[],s=new ez,o=new tT;for(let t=0;t<=e;t++){let n=t/e;i[t]=this.getTangentAt(n,new ez)}r[0]=new ez,a[0]=new ez;let l=Number.MAX_VALUE,u=Math.abs(i[0].x),c=Math.abs(i[0].y),h=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),h<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(i[t-1],i[t]),s.length()>Number.EPSILON){s.normalize();let e=Math.acos(eP(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(s,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(eP(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}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}}class r6 extends r5{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t=new eO){let n=2*Math.PI,i=this.aEndAngle-this.aStartAngle,r=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=n;for(;i>n;)i-=n;i<Number.EPSILON&&(i=r?0:n),!0!==this.aClockwise||r||(i===n?i=-n:i-=n);let a=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(a),o=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,i=o-this.aY;s=n*e-i*t+this.aX,o=n*t+i*e+this.aY}return t.set(s,o)}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}}class r8 extends r6{constructor(e,t,n,i,r,a){super(e,t,n,n,i,r,a),this.isArcCurve=!0,this.type="ArcCurve"}}function r9(){let e=0,t=0,n=0,i=0;function r(r,a,s,o){e=r,t=s,n=-3*r+3*a-2*s-o,i=2*r-2*a+s+o}return{initCatmullRom:function(e,t,n,i,a){r(t,n,a*(n-e),a*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,a,s,o){let l=(t-e)/a-(n-e)/(a+s)+(n-t)/s,u=(n-t)/s-(i-t)/(s+o)+(i-n)/o;r(t,n,l*=s,u*=s)},calc:function(r){let a=r*r;return e+t*r+n*a+a*r*i}}}let r7=new ez,ae=new r9,at=new r9,an=new r9;class ai extends r5{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new ez){let n,i,r=this.points,a=r.length,s=(a-!this.closed)*e,o=Math.floor(s),l=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:0===l&&o===a-1&&(o=a-2,l=1),this.closed||o>0?n=r[(o-1)%a]:(r7.subVectors(r[0],r[1]).add(r[0]),n=r7);let u=r[o%a],c=r[(o+1)%a];if(this.closed||o+2<a?i=r[(o+2)%a]:(r7.subVectors(r[a-1],r[a-2]).add(r[a-1]),i=r7),"centripetal"===this.curveType||"chordal"===this.curveType){let e="chordal"===this.curveType?.5:.25,t=Math.pow(n.distanceToSquared(u),e),r=Math.pow(u.distanceToSquared(c),e),a=Math.pow(c.distanceToSquared(i),e);r<1e-4&&(r=1),t<1e-4&&(t=r),a<1e-4&&(a=r),ae.initNonuniformCatmullRom(n.x,u.x,c.x,i.x,t,r,a),at.initNonuniformCatmullRom(n.y,u.y,c.y,i.y,t,r,a),an.initNonuniformCatmullRom(n.z,u.z,c.z,i.z,t,r,a)}else"catmullrom"===this.curveType&&(ae.initCatmullRom(n.x,u.x,c.x,i.x,this.tension),at.initCatmullRom(n.y,u.y,c.y,i.y,this.tension),an.initCatmullRom(n.z,u.z,c.z,i.z,this.tension));return t.set(ae.calc(l),at.calc(l),an.calc(l)),t}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.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,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.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,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new ez().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function ar(e,t,n,i,r){let a=(i-t)*.5,s=(r-n)*.5,o=e*e;return e*o*(2*n-2*i+a+s)+(-3*n+3*i-2*a-s)*o+a*e+n}function aa(e,t,n,i){let r;return(r=1-e)*r*t+2*(1-e)*e*n+e*e*i}function as(e,t,n,i,r){let a,s;return(a=1-e)*a*a*t+3*(s=1-e)*s*e*n+3*(1-e)*e*e*i+e*e*e*r}class ao extends r5{constructor(e=new eO,t=new eO,n=new eO,i=new eO){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new eO){let n=this.v0,i=this.v1,r=this.v2,a=this.v3;return t.set(as(e,n.x,i.x,r.x,a.x),as(e,n.y,i.y,r.y,a.y)),t}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}}class al extends r5{constructor(e=new ez,t=new ez,n=new ez,i=new ez){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new ez){let n=this.v0,i=this.v1,r=this.v2,a=this.v3;return t.set(as(e,n.x,i.x,r.x,a.x),as(e,n.y,i.y,r.y,a.y),as(e,n.z,i.z,r.z,a.z)),t}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}}class au extends r5{constructor(e=new eO,t=new eO){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new eO){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new eO){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}}class ac extends r5{constructor(e=new ez,t=new ez){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new ez){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ez){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}}class ah extends r5{constructor(e=new eO,t=new eO,n=new eO){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new eO){let n=this.v0,i=this.v1,r=this.v2;return t.set(aa(e,n.x,i.x,r.x),aa(e,n.y,i.y,r.y)),t}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}}class ad extends r5{constructor(e=new ez,t=new ez,n=new ez){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ez){let n=this.v0,i=this.v1,r=this.v2;return t.set(aa(e,n.x,i.x,r.x),aa(e,n.y,i.y,r.y),aa(e,n.z,i.z,r.z)),t}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}}class ap extends r5{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new eO){let n=this.points,i=(n.length-1)*e,r=Math.floor(i),a=i-r,s=n[0===r?r:r-1],o=n[r],l=n[r>n.length-2?n.length-1:r+1],u=n[r>n.length-3?n.length-1:r+2];return t.set(ar(a,s.x,o.x,l.x,u.x),ar(a,s.y,o.y,l.y,u.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new eO().fromArray(n))}return this}}var af=Object.freeze({__proto__:null,ArcCurve:r8,CatmullRomCurve3:ai,CubicBezierCurve:ao,CubicBezierCurve3:al,EllipseCurve:r6,LineCurve:au,LineCurve3:ac,QuadraticBezierCurve:ah,QuadraticBezierCurve3:ad,SplineCurve:ap});class am extends r5{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 n=!0===e.isVector2?"LineCurve":"LineCurve3";this.curves.push(new af[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),r=0;for(;r<i.length;){if(i[r]>=n){let e=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-e/s;return a.getPointAt(o,t)}r++}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 n=0,i=this.curves.length;n<i;n++)e.push(t+=this.curves[n].getLength());return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t,n=[];for(let i=0,r=this.curves;i<r.length;i++){let a=r[i],s=a.isEllipseCurve?2*e:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(s);for(let e=0;e<o.length;e++){let i=o[e];t&&t.equals(i)||(n.push(i),t=i)}}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new af[n.type]().fromJSON(n))}return this}}class ag extends am{constructor(e){super(),this.type="Path",this.currentPoint=new eO,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;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 n=new au(this.currentPoint.clone(),new eO(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let r=new ah(this.currentPoint.clone(),new eO(e,t),new eO(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,a){let s=new ao(this.currentPoint.clone(),new eO(e,t),new eO(n,i),new eO(r,a));return this.curves.push(s),this.currentPoint.set(r,a),this}splineThru(e){let t=new ap([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,a){let s=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+s,t+o,n,i,r,a),this}absarc(e,t,n,i,r,a){return this.absellipse(e,t,n,n,i,r,a),this}ellipse(e,t,n,i,r,a,s,o){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,i,r,a,s,o),this}absellipse(e,t,n,i,r,a,s,o){let l=new r6(e,t,n,i,r,a,s,o);if(this.curves.length>0){let e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),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}}class av extends ag{constructor(e){super(e),this.uuid=eR(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].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,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new ag().fromJSON(n))}return this}}function ax(e,t,n,i,r){let a;if(r===function(e,t,n,i){let r=0;for(let a=t,s=n-i;a<n;a+=i)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}(e,t,n,i)>0)for(let r=t;r<n;r+=i)a=aI(r/i|0,e[r],e[r+1],a);else for(let r=n-i;r>=t;r-=i)a=aI(r/i|0,e[r],e[r+1],a);return a&&aT(a,a.next)&&(aL(a),a=a.next),a}function ay(e,t){if(!e)return e;t||(t=e);let n=e,i;do if(i=!1,!n.steiner&&(aT(n,n.next)||0===aw(n.prev,n,n.next))){if(aL(n),(n=t=n.prev)===n.next)break;i=!0}else n=n.next;while(i||n!==t)return t}function a_(e,t){let n=e.x-t.x;return 0===n&&0==(n=e.y-t.y)&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),n}function ab(e,t,n,i,r){return(e=((e=((e=((e=((e=(e-n)*r|0)|e<<8)&0xff00ff)|e<<4)&0xf0f0f0f)|e<<2)&0x33333333)|e<<1)&0x55555555)|(t=((t=((t=((t=((t=(t-i)*r|0)|t<<8)&0xff00ff)|t<<4)&0xf0f0f0f)|t<<2)&0x33333333)|t<<1)&0x55555555)<<1}function aS(e,t,n,i,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function aM(e,t,n,i,r,a,s,o){return(e!==s||t!==o)&&aS(e,t,n,i,r,a,s,o)}function aw(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function aT(e,t){return e.x===t.x&&e.y===t.y}function aE(e,t,n,i){let r=aC(aw(e,t,n)),a=aC(aw(e,t,i)),s=aC(aw(n,i,e)),o=aC(aw(n,i,t));return!!(r!==a&&s!==o||0===r&&aA(e,n,t)||0===a&&aA(e,i,t)||0===s&&aA(n,e,i)||0===o&&aA(n,t,i))}function aA(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function aC(e){return e>0?1:e<0?-1:0}function aR(e,t){return 0>aw(e.prev,e,e.next)?aw(e,t,e.next)>=0&&aw(e,e.prev,t)>=0:0>aw(e,t,e.prev)||0>aw(e,e.next,t)}function aP(e,t){let n=aN(e.i,e.x,e.y),i=aN(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function aI(e,t,n,i){let r=aN(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function aL(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function aN(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class aD{static triangulate(e,t,n=2){return function(e,t,n=2){let i,r,a,s=t&&t.length,o=s?t[0]*n:e.length,l=ax(e,0,o,n,!0),u=[];if(!l||l.next===l.prev)return u;if(s&&(l=function(e,t,n,i){let r=[];for(let n=0,a=t.length;n<a;n++){let s=t[n]*i,o=n<a-1?t[n+1]*i:e.length,l=ax(e,s,o,i,!1);l===l.next&&(l.steiner=!0),r.push(function(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e)return n}(l))}r.sort(a_);for(let e=0;e<r.length;e++)n=function(e,t){let n=function(e,t){let n,i=t,r=e.x,a=e.y,s=-1/0;if(aT(e,i))return i;do{if(aT(e,i.next))return i.next;if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,n=i.x<i.next.x?i:i.next,e===r))return n}i=i.next}while(i!==t)if(!n)return null;let o=n,l=n.x,u=n.y,c=1/0;i=n;do{if(r>=i.x&&i.x>=l&&r!==i.x&&aS(a<u?r:s,a,l,u,a<u?s:r,a,i.x,i.y)){var h,d;let t=Math.abs(a-i.y)/(r-i.x);aR(i,e)&&(t<c||t===c&&(i.x>n.x||i.x===n.x&&(h=n,d=i,0>aw(h.prev,h,d.prev)&&0>aw(d.next,h,h.next))))&&(n=i,c=t)}i=i.next}while(i!==o)return n}(e,t);if(!n)return t;let i=aP(n,e);return ay(i,i.next),ay(n,n.next)}(r[e],n);return n}(e,t,l,n)),e.length>80*n){i=e[0],r=e[1];let t=i,s=r;for(let a=n;a<o;a+=n){let n=e[a],o=e[a+1];n<i&&(i=n),o<r&&(r=o),n>t&&(t=n),o>s&&(s=o)}a=0!==(a=Math.max(t-i,s-r))?32767/a:0}return function e(t,n,i,r,a,s,o){if(!t)return;!o&&s&&function(e,t,n,i){let r=e;do 0===r.z&&(r.z=ab(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e)r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n=1;do{let i,r=e;e=null;let a=null;for(t=0;r;){t++;let s=r,o=0;for(let e=0;e<n&&(o++,s=s.nextZ);e++);let l=n;for(;o>0||l>0&&s;)0!==o&&(0===l||!s||r.z<=s.z)?(i=r,r=r.nextZ,o--):(i=s,s=s.nextZ,l--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=s}a.nextZ=null,n*=2}while(t>1)}(r)}(t,r,a,s);let l=t;for(;t.prev!==t.next;){let u=t.prev,c=t.next;if(s?function(e,t,n,i){let r=e.prev,a=e.next;if(aw(r,e,a)>=0)return!1;let s=r.x,o=e.x,l=a.x,u=r.y,c=e.y,h=a.y,d=Math.min(s,o,l),p=Math.min(u,c,h),f=Math.max(s,o,l),m=Math.max(u,c,h),g=ab(d,p,t,n,i),v=ab(f,m,t,n,i),x=e.prevZ,y=e.nextZ;for(;x&&x.z>=g&&y&&y.z<=v;){if(x.x>=d&&x.x<=f&&x.y>=p&&x.y<=m&&x!==r&&x!==a&&aM(s,u,o,c,l,h,x.x,x.y)&&aw(x.prev,x,x.next)>=0||(x=x.prevZ,y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&aM(s,u,o,c,l,h,y.x,y.y)&&aw(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;x&&x.z>=g;){if(x.x>=d&&x.x<=f&&x.y>=p&&x.y<=m&&x!==r&&x!==a&&aM(s,u,o,c,l,h,x.x,x.y)&&aw(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&aM(s,u,o,c,l,h,y.x,y.y)&&aw(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}(t,r,a,s):function(e){let t=e.prev,n=e.next;if(aw(t,e,n)>=0)return!1;let i=t.x,r=e.x,a=n.x,s=t.y,o=e.y,l=n.y,u=Math.min(i,r,a),c=Math.min(s,o,l),h=Math.max(i,r,a),d=Math.max(s,o,l),p=n.next;for(;p!==t;){if(p.x>=u&&p.x<=h&&p.y>=c&&p.y<=d&&aM(i,s,r,o,a,l,p.x,p.y)&&aw(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}(t)){n.push(u.i,t.i,c.i),aL(t),t=c.next,l=c.next;continue}if((t=c)===l){o?1===o?e(t=function(e,t){let n=e;do{let i=n.prev,r=n.next.next;!aT(i,r)&&aE(i,n,n.next,r)&&aR(i,r)&&aR(r,i)&&(t.push(i.i,n.i,r.i),aL(n),aL(n.next),n=e=r),n=n.next}while(n!==e)return ay(n)}(ay(t),n),n,i,r,a,s,2):2===o&&function(t,n,i,r,a,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){var l,u;if(o.i!==t.i&&(l=o,u=t,l.next.i!==u.i&&l.prev.i!==u.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&aE(n,n.next,e,t))return!0;n=n.next}while(n!==e)return!1}(l,u)&&(aR(l,u)&&aR(u,l)&&function(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==e)return i}(l,u)&&(aw(l.prev,l,u.prev)||aw(l,u.prev,u))||aT(l,u)&&aw(l.prev,l,l.next)>0&&aw(u.prev,u,u.next)>0))){let l=aP(o,t);o=ay(o,o.next),l=ay(l,l.next),e(o,n,i,r,a,s,0),e(l,n,i,r,a,s,0);return}t=t.next}o=o.next}while(o!==t)}(t,n,i,r,a,s):e(ay(t),n,i,r,a,s,1);break}}}(l,u,n,i,r,a,0),u}(e,t,n)}}class aU{static area(e){let t=e.length,n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return .5*n}static isClockWise(e){return 0>aU.area(e)}static triangulateShape(e,t){let n=[],i=[],r=[];aO(e),aF(n,e);let a=e.length;t.forEach(aO);for(let e=0;e<t.length;e++)i.push(a),a+=t[e].length,aF(n,t[e]);let s=aD.triangulate(n,i);for(let e=0;e<s.length;e+=3)r.push(s.slice(e,e+3));return r}}function aO(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function aF(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class az extends nO{constructor(e=new av([new eO(.5,.5),new eO(-.5,.5),new eO(-.5,-.5),new eO(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let a=0,s=e.length;a<s;a++)!function(e){let a,s,o,l,u,c=[],h=void 0!==t.curveSegments?t.curveSegments:12,d=void 0!==t.steps?t.steps:1,p=void 0!==t.depth?t.depth:1,f=void 0===t.bevelEnabled||t.bevelEnabled,m=void 0!==t.bevelThickness?t.bevelThickness:.2,g=void 0!==t.bevelSize?t.bevelSize:m-.1,v=void 0!==t.bevelOffset?t.bevelOffset:0,x=void 0!==t.bevelSegments?t.bevelSegments:3,y=t.extrudePath,_=void 0!==t.UVGenerator?t.UVGenerator:ak,b,S=!1;if(y){b=y.getSpacedPoints(d),S=!0,f=!1;let e=!!y.isCatmullRomCurve3&&y.closed;a=y.computeFrenetFrames(d,e),s=new ez,o=new ez,l=new ez}f||(x=0,m=0,g=0,v=0);let M=e.extractPoints(h),w=M.shape,T=M.holes;if(!aU.isClockWise(w)){w=w.reverse();for(let e=0,t=T.length;e<t;e++){let t=T[e];aU.isClockWise(t)&&(T[e]=t.reverse())}}function E(e){let t=1e-10*1e-10,n=e[0];for(let i=1;i<=e.length;i++){let r=i%e.length,a=e[r],s=a.x-n.x,o=a.y-n.y,l=s*s+o*o,u=Math.max(Math.abs(a.x),Math.abs(a.y),Math.abs(n.x),Math.abs(n.y));if(l<=t*u*u){e.splice(r,1),i--;continue}n=a}}E(w),T.forEach(E);let A=T.length,C=w;for(let e=0;e<A;e++){let t=T[e];w=w.concat(t)}function R(e,t,n){return t||eS("ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}let P=w.length;function I(e,t,n){let i,r,a,s=e.x-t.x,o=e.y-t.y,l=n.x-e.x,u=n.y-e.y,c=s*s+o*o;if(Math.abs(s*u-o*l)>Number.EPSILON){let h=Math.sqrt(c),d=Math.sqrt(l*l+u*u),p=t.x-o/h,f=t.y+s/h,m=((n.x-u/d-p)*u-(n.y+l/d-f)*l)/(s*u-o*l),g=(i=p+s*m-e.x)*i+(r=f+o*m-e.y)*r;if(g<=2)return new eO(i,r);a=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(u)&&(e=!0),e?(i=-o,r=s,a=Math.sqrt(c)):(i=s,r=o,a=Math.sqrt(c/2))}return new eO(i/a,r/a)}let L=[];for(let e=0,t=C.length,n=t-1,i=e+1;e<t;e++,n++,i++)n===t&&(n=0),i===t&&(i=0),L[e]=I(C[e],C[n],C[i]);let N=[],D,U=L.concat();for(let e=0;e<A;e++){let t=T[e];D=[];for(let e=0,n=t.length,i=n-1,r=e+1;e<n;e++,i++,r++)i===n&&(i=0),r===n&&(r=0),D[e]=I(t[e],t[i],t[r]);N.push(D),U=U.concat(D)}if(0===x)u=aU.triangulateShape(C,T);else{let e=[],t=[];for(let n=0;n<x;n++){let i=n/x,r=m*Math.cos(i*Math.PI/2),a=g*Math.sin(i*Math.PI/2)+v;for(let t=0,n=C.length;t<n;t++){let n=R(C[t],L[t],a);k(n.x,n.y,-r),0===i&&e.push(n)}for(let e=0;e<A;e++){let n=T[e];D=N[e];let s=[];for(let e=0,t=n.length;e<t;e++){let t=R(n[e],D[e],a);k(t.x,t.y,-r),0===i&&s.push(t)}0===i&&t.push(s)}}u=aU.triangulateShape(e,t)}let O=u.length,F=g+v;for(let e=0;e<P;e++){let t=f?R(w[e],U[e],F):w[e];S?(o.copy(a.normals[0]).multiplyScalar(t.x),s.copy(a.binormals[0]).multiplyScalar(t.y),l.copy(b[0]).add(o).add(s),k(l.x,l.y,l.z)):k(t.x,t.y,0)}for(let e=1;e<=d;e++)for(let t=0;t<P;t++){let n=f?R(w[t],U[t],F):w[t];S?(o.copy(a.normals[e]).multiplyScalar(n.x),s.copy(a.binormals[e]).multiplyScalar(n.y),l.copy(b[e]).add(o).add(s),k(l.x,l.y,l.z)):k(n.x,n.y,p/d*e)}for(let e=x-1;e>=0;e--){let t=e/x,n=m*Math.cos(t*Math.PI/2),i=g*Math.sin(t*Math.PI/2)+v;for(let e=0,t=C.length;e<t;e++){let t=R(C[e],L[e],i);k(t.x,t.y,p+n)}for(let e=0,t=T.length;e<t;e++){let t=T[e];D=N[e];for(let e=0,r=t.length;e<r;e++){let r=R(t[e],D[e],i);S?k(r.x,r.y+b[d-1].y,b[d-1].x+n):k(r.x,r.y,p+n)}}}function z(e,t){let r=e.length;for(;--r>=0;){let a=r,s=r-1;s<0&&(s=e.length-1);for(let e=0,r=d+2*x;e<r;e++){let r=P*e,o=P*(e+1);!function(e,t,r,a){V(e),V(t),V(a),V(t),V(r),V(a);let s=i.length/3,o=_.generateSideWallUV(n,i,s-6,s-3,s-2,s-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}(t+a+r,t+s+r,t+s+o,t+a+o)}}}function k(e,t,n){c.push(e),c.push(t),c.push(n)}function B(e,t,r){V(e),V(t),V(r);let a=i.length/3,s=_.generateTopUV(n,i,a-3,a-2,a-1);H(s[0]),H(s[1]),H(s[2])}function V(e){i.push(c[3*e+0]),i.push(c[3*e+1]),i.push(c[3*e+2])}function H(e){r.push(e.x),r.push(e.y)}(function(){let e=i.length/3;if(f){let e=0*P;for(let t=0;t<O;t++){let n=u[t];B(n[2]+e,n[1]+e,n[0]+e)}e=P*(d+2*x);for(let t=0;t<O;t++){let n=u[t];B(n[0]+e,n[1]+e,n[2]+e)}}else{for(let e=0;e<O;e++){let t=u[e];B(t[2],t[1],t[0])}for(let e=0;e<O;e++){let t=u[e];B(t[0]+P*d,t[1]+P*d,t[2]+P*d)}}n.addGroup(e,i.length/3-e,0)})(),function(){let e=i.length/3,t=0;z(C,0),t+=C.length;for(let e=0,n=T.length;e<n;e++){let n=T[e];z(n,t),t+=n.length}n.addGroup(e,i.length/3-e,1)}()}(e[a]);this.setAttribute("position",new nC(i,3)),this.setAttribute("uv",new nC(r,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,i=e.length;t<i;t++){let i=e[t];n.shapes.push(i.uuid)}else n.shapes.push(e.uuid);return n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON()),n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){let n=[];for(let i=0,r=e.shapes.length;i<r;i++){let r=t[e.shapes[i]];n.push(r)}let i=e.options.extrudePath;return void 0!==i&&(e.options.extrudePath=new af[i.type]().fromJSON(i)),new az(n,e.options)}}let ak={generateTopUV:function(e,t,n,i,r){let a=t[3*n],s=t[3*n+1],o=t[3*i],l=t[3*i+1],u=t[3*r],c=t[3*r+1];return[new eO(a,s),new eO(o,l),new eO(u,c)]},generateSideWallUV:function(e,t,n,i,r,a){let s=t[3*n],o=t[3*n+1],l=t[3*n+2],u=t[3*i],c=t[3*i+1],h=t[3*i+2],d=t[3*r],p=t[3*r+1],f=t[3*r+2],m=t[3*a],g=t[3*a+1],v=t[3*a+2];return Math.abs(o-c)<Math.abs(s-u)?[new eO(s,1-l),new eO(u,1-h),new eO(d,1-f),new eO(m,1-v)]:[new eO(o,1-l),new eO(c,1-h),new eO(p,1-f),new eO(g,1-v)]}};class aB extends rK{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new aB(e.radius,e.detail)}}class aV extends nO{constructor(e=[new eO(0,-.5),new eO(.5,0),new eO(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=eP(i,0,2*Math.PI);const r=[],a=[],s=[],o=[],l=[],u=1/t,c=new ez,h=new eO,d=new ez,p=new ez,f=new ez;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,d.x=+(g=e[t+1].y-e[t].y),d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[t+1].x-e[t].x,d.x=+(g=e[t+1].y-e[t].y),d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=t;r++){const d=n+r*u*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=e.length-1;n++){c.x=e[n].x*p,c.y=e[n].y,c.z=e[n].x*f,a.push(c.x,c.y,c.z),h.x=r/t,h.y=n/(e.length-1),s.push(h.x,h.y);const i=o[3*n+0]*p,u=o[3*n+1],d=o[3*n+0]*f;l.push(i,u,d)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){const i=t+n*e.length,a=i+e.length,s=i+e.length+1,o=i+1;r.push(i,a,o),r.push(s,o,a)}this.setIndex(r),this.setAttribute("position",new nC(a,3)),this.setAttribute("uv",new nC(s,2)),this.setAttribute("normal",new nC(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aV(e.points,e.segments,e.phiStart,e.phiLength)}}class aH extends rK{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new aH(e.radius,e.detail)}}class aj extends nO{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,s=Math.floor(n),o=Math.floor(i),l=s+1,u=o+1,c=e/s,h=t/o,d=[],p=[],f=[],m=[];for(let e=0;e<u;e++){const t=e*h-a;for(let n=0;n<l;n++){const i=n*c-r;p.push(i,-t,0),f.push(0,0,1),m.push(n/s),m.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<s;t++){const n=t+l*e,i=t+l*(e+1),r=t+1+l*(e+1),a=t+1+l*e;d.push(n,i,a),d.push(i,r,a)}this.setIndex(d),this.setAttribute("position",new nC(p,3)),this.setAttribute("normal",new nC(f,3)),this.setAttribute("uv",new nC(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aj(e.width,e.height,e.widthSegments,e.heightSegments)}}class aG extends nO{constructor(e=.5,t=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);const s=[],o=[],l=[],u=[];let c=e;const h=(t-e)/(i=Math.max(1,i)),d=new ez,p=new eO;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=r+e/n*a;d.x=c*Math.cos(i),d.y=c*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,u.push(p.x,p.y)}c+=h}for(let e=0;e<i;e++){const t=e*(n+1);for(let e=0;e<n;e++){const i=e+t,r=i+n+1,a=i+n+2,o=i+1;s.push(i,r,o),s.push(r,a,o)}}this.setIndex(s),this.setAttribute("position",new nC(o,3)),this.setAttribute("normal",new nC(l,3)),this.setAttribute("uv",new nC(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aG(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class aW extends nO{constructor(e=new av([new eO(0,.5),new eO(-.5,-.5),new eO(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],a=[];let s=0,o=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(s,o,t),s+=o,o=0;function l(e){let s=i.length/3,l=e.extractPoints(t),u=l.shape,c=l.holes;!1===aU.isClockWise(u)&&(u=u.reverse());for(let e=0,t=c.length;e<t;e++){let t=c[e];!0===aU.isClockWise(t)&&(c[e]=t.reverse())}let h=aU.triangulateShape(u,c);for(let e=0,t=c.length;e<t;e++){let t=c[e];u=u.concat(t)}for(let e=0,t=u.length;e<t;e++){let t=u[e];i.push(t.x,t.y,0),r.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=h.length;e<t;e++){let t=h[e],i=t[0]+s,r=t[1]+s,a=t[2]+s;n.push(i,r,a),o+=3}}this.setIndex(n),this.setAttribute("position",new nC(i,3)),this.setAttribute("normal",new nC(r,3)),this.setAttribute("uv",new nC(a,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,i=e.length;n<i;n++){let i=e[n];t.shapes.push(i.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){let n=[];for(let i=0,r=e.shapes.length;i<r;i++){let r=t[e.shapes[i]];n.push(r)}return new aW(n,e.curveSegments)}}class aX extends nO{constructor(e=1,t=32,n=16,i=0,r=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:s},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const o=Math.min(a+s,Math.PI);let l=0;const u=[],c=new ez,h=new ez,d=[],p=[],f=[],m=[];for(let d=0;d<=n;d++){const g=[],v=d/n;let x=0;0===d&&0===a?x=.5/t:d===n&&o===Math.PI&&(x=-.5/t);for(let n=0;n<=t;n++){const o=n/t;c.x=-e*Math.cos(i+o*r)*Math.sin(a+v*s),c.y=e*Math.cos(a+v*s),c.z=e*Math.sin(i+o*r)*Math.sin(a+v*s),p.push(c.x,c.y,c.z),h.copy(c).normalize(),f.push(h.x,h.y,h.z),m.push(o+x,1-v),g.push(l++)}u.push(g)}for(let e=0;e<n;e++)for(let i=0;i<t;i++){const t=u[e][i+1],r=u[e][i],s=u[e+1][i],l=u[e+1][i+1];(0!==e||a>0)&&d.push(t,r,l),(e!==n-1||o<Math.PI)&&d.push(r,s,l)}this.setIndex(d),this.setAttribute("position",new nC(p,3)),this.setAttribute("normal",new nC(f,3)),this.setAttribute("uv",new nC(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aX(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class aq extends rK{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new aq(e.radius,e.detail)}}class aY extends nO{constructor(e=1,t=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const a=[],s=[],o=[],l=[],u=new ez,c=new ez,h=new ez;for(let a=0;a<=n;a++)for(let d=0;d<=i;d++){const p=d/i*r,f=a/n*Math.PI*2;c.x=(e+t*Math.cos(f))*Math.cos(p),c.y=(e+t*Math.cos(f))*Math.sin(p),c.z=t*Math.sin(f),s.push(c.x,c.y,c.z),u.x=e*Math.cos(p),u.y=e*Math.sin(p),h.subVectors(c,u).normalize(),o.push(h.x,h.y,h.z),l.push(d/i),l.push(a/n)}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*e+t-1,r=(i+1)*(e-1)+t-1,s=(i+1)*(e-1)+t,o=(i+1)*e+t;a.push(n,r,o),a.push(r,s,o)}this.setIndex(a),this.setAttribute("position",new nC(s,3)),this.setAttribute("normal",new nC(o,3)),this.setAttribute("uv",new nC(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aY(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class aZ extends nO{constructor(e=1,t=.4,n=64,i=8,r=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:a},n=Math.floor(n),i=Math.floor(i);const s=[],o=[],l=[],u=[],c=new ez,h=new ez,d=new ez,p=new ez,f=new ez,m=new ez,g=new ez;for(let s=0;s<=n;++s){const x=s/n*r*Math.PI*2;v(x,r,a,e,d),v(x+.01,r,a,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let e=0;e<=i;++e){const r=e/i*Math.PI*2,a=-t*Math.cos(r),p=t*Math.sin(r);c.x=d.x+(a*g.x+p*f.x),c.y=d.y+(a*g.y+p*f.y),c.z=d.z+(a*g.z+p*f.z),o.push(c.x,c.y,c.z),h.subVectors(c,d).normalize(),l.push(h.x,h.y,h.z),u.push(s/n),u.push(e/i)}}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*(e-1)+(t-1),r=(i+1)*e+(t-1),a=(i+1)*e+t,o=(i+1)*(e-1)+t;s.push(n,r,o),s.push(r,a,o)}function v(e,t,n,i,r){let a=Math.cos(e),s=Math.sin(e),o=n/t*e,l=Math.cos(o);r.x=i*(2+l)*.5*a,r.y=i*(2+l)*s*.5,r.z=i*Math.sin(o)*.5}this.setIndex(s),this.setAttribute("position",new nC(o,3)),this.setAttribute("normal",new nC(l,3)),this.setAttribute("uv",new nC(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aZ(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class aJ extends nO{constructor(e=new ad(new ez(-1,-1,0),new ez(-1,1,0),new ez(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const a=e.computeFrenetFrames(t,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const s=new ez,o=new ez,l=new eO;let u=new ez;const c=[],h=[],d=[],p=[];function f(r){u=e.getPointAt(r/t,u);let l=a.normals[r],d=a.binormals[r];for(let e=0;e<=i;e++){let t=e/i*Math.PI*2,r=Math.sin(t),a=-Math.cos(t);o.x=a*l.x+r*d.x,o.y=a*l.y+r*d.y,o.z=a*l.z+r*d.z,o.normalize(),h.push(o.x,o.y,o.z),s.x=u.x+n*o.x,s.y=u.y+n*o.y,s.z=u.z+n*o.z,c.push(s.x,s.y,s.z)}}(function(){for(let e=0;e<t;e++)f(e);f(!1===r?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=i;n++)l.x=e/t,l.y=n/i,d.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=i;t++){let n=(i+1)*(e-1)+(t-1),r=(i+1)*e+(t-1),a=(i+1)*e+t,s=(i+1)*(e-1)+t;p.push(n,r,s),p.push(r,a,s)}}()})(),this.setIndex(p),this.setAttribute("position",new nC(c,3)),this.setAttribute("normal",new nC(h,3)),this.setAttribute("uv",new nC(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new aJ(new af[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class a$ extends nO{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,i=new ez,r=new ez;if(null!==e.index){const a=e.attributes.position,s=e.index;let o=e.groups;0===o.length&&(o=[{start:0,count:s.count,materialIndex:0}]);for(let e=0,l=o.length;e<l;++e){const l=o[e],u=l.start,c=l.count;for(let e=u,o=u+c;e<o;e+=3)for(let o=0;o<3;o++){const l=s.getX(e+o),u=s.getX(e+(o+1)%3);i.fromBufferAttribute(a,l),r.fromBufferAttribute(a,u),!0===aK(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{const a=e.attributes.position;for(let e=0,s=a.count/3;e<s;e++)for(let s=0;s<3;s++){const o=3*e+s,l=3*e+(s+1)%3;i.fromBufferAttribute(a,o),r.fromBufferAttribute(a,l),!0===aK(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new nC(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function aK(e,t,n){let i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var aQ=Object.freeze({__proto__:null,BoxGeometry:nJ,CapsuleGeometry:rY,CircleGeometry:rZ,ConeGeometry:r$,CylinderGeometry:rJ,DodecahedronGeometry:rQ,EdgesGeometry:r4,ExtrudeGeometry:az,IcosahedronGeometry:aB,LatheGeometry:aV,OctahedronGeometry:aH,PlaneGeometry:aj,PolyhedronGeometry:rK,RingGeometry:aG,ShapeGeometry:aW,SphereGeometry:aX,TetrahedronGeometry:aq,TorusGeometry:aY,TorusKnotGeometry:aZ,TubeGeometry:aJ,WireframeGeometry:a$});class a0 extends nc{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new no(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class a1 extends n1{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class a2 extends nc{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new no(0xffffff),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new no(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new eO(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 tU,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}}class a3 extends a2{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new eO(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return eP(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new no(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new no(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new no(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class a4 extends nc{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new no(0xffffff),this.specular=new no(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new no(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new eO(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new tU,this.combine=0,this.reflectivity=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.specular.copy(e.specular),this.shininess=e.shininess,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.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}}class a5 extends nc{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new no(0xffffff),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new no(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new eO(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class a6 extends nc{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new eO(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class a8 extends nc{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new no(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new no(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new eO(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new tU,this.combine=0,this.reflectivity=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.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}}class a9 extends nc{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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}}class a7 extends nc{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}}class se extends nc{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new no(0xffffff),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new eO(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class st extends rv{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function sn(e,t){return e&&e.constructor!==t?"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e):e}function si(e){let t=e.length,n=Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort(function(t,n){return e[t]-e[n]}),n}function sr(e,t,n){let i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){let i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function sa(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do void 0!==(s=a[i])&&(t.push(a.time),n.push(...s)),a=e[r++];while(void 0!==a)else if(void 0!==s.toArray)do void 0!==(s=a[i])&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++];while(void 0!==a)else do void 0!==(s=a[i])&&(t.push(a.time),n.push(s)),a=e[r++];while(void 0!==a)}class ss{static convertArray(e,t){return sn(e,t)}static isTypedArray(e){return ep(e)}static getKeyframeOrder(e){return si(e)}static sortedArray(e,t,n){return sr(e,t,n)}static flattenJSON(e,t,n,i){sa(e,t,n,i)}static subclip(e,t,n,i,r=30){return function(e,t,n,i,r=30){let a=e.clone();a.name=t;let s=[];for(let e=0;e<a.tracks.length;++e){let t=a.tracks[e],o=t.getValueSize(),l=[],u=[];for(let e=0;e<t.times.length;++e){let a=t.times[e]*r;if(!(a<n)&&!(a>=i)){l.push(t.times[e]);for(let n=0;n<o;++n)u.push(t.values[e*o+n])}}0!==l.length&&(t.times=sn(l,t.times.constructor),t.values=sn(u,t.values.constructor),s.push(t))}a.tracks=s;let o=1/0;for(let e=0;e<a.tracks.length;++e)o>a.tracks[e].times[0]&&(o=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*o);return a.resetDuration(),a}(e,t,n,i,r)}static makeClipAdditive(e,t=0,n=e,i=30){return function(e,t=0,n=e,i=30){i<=0&&(i=30);let r=n.tracks.length,a=t/i;for(let t=0;t<r;++t){let i,r=n.tracks[t],s=r.ValueTypeName;if("bool"===s||"string"===s)continue;let o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===s});if(void 0===o)continue;let l=0,u=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);let c=0,h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);let d=r.times.length-1;if(a<=r.times[0]){let e=l,t=u-l;i=r.values.slice(e,t)}else if(a>=r.times[d]){let e=d*u+l,t=e+u-l;i=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=l,n=u-l;e.evaluate(a),i=e.resultBuffer.slice(t,n)}"quaternion"===s&&new eF().fromArray(i).normalize().conjugate().toArray(i);let p=o.times.length;for(let e=0;e<p;++e){let t=e*h+c;if("quaternion"===s)eF.multiplyQuaternionsFlat(o.values,t,i,0,o.values,t);else{let e=h-2*c;for(let n=0;n<e;++n)o.values[t+n]-=i[n]}}}return e.blendMode=2501,e}(e,t,n,i)}}class so{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];n:{i:{let a;r:{a:if(!(e<i)){for(let a=n+2;;){if(void 0===i){if(e<r)break a;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,e<(i=t[++n]))break i}a=t.length;break r}if(!(e>=r)){let s=t[1];e<s&&(n=2,r=s);for(let a=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,e>=(r=t[--n-1]))break i}a=n,n=0;break r}break n}for(;n<a;){let i=n+a>>>1;e<t[i]?a=i:n=i+1}if(i=t[n],void 0===(r=t[n-1]))return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let e=0;e!==i;++e)t[e]=n[r+e];return t}interpolate_(){throw Error("call to abstract method")}intervalChanged_(){}}class sl extends so{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,a=e+1,s=i[r],o=i[a];if(void 0===s)switch(this.getSettings_().endingStart){case 2401:r=e,s=2*t-n;break;case 2402:r=i.length-2,s=t+i[r]-i[r+1];break;default:r=e,s=n}if(void 0===o)switch(this.getSettings_().endingEnd){case 2401:a=e,o=2*n-t;break;case 2402:a=1,o=n+i[1]-i[0];break;default:a=e-1,o=t}let l=(n-t)*.5,u=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(o-n),this._offsetPrev=r*u,this._offsetNext=a*u}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,u=this._offsetPrev,c=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),f=p*p,m=f*p,g=-h*m+2*h*f-h*p,v=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,x=(-1-d)*m+(1.5+d)*f+.5*p,y=d*m-d*f;for(let e=0;e!==s;++e)r[e]=g*a[u+e]+v*a[l+e]+x*a[o+e]+y*a[c+e];return r}}class su extends so{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,u=(n-t)/(i-t),c=1-u;for(let e=0;e!==s;++e)r[e]=a[l+e]*c+a[o+e]*u;return r}}class sc extends so{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class sh{constructor(e,t,n,i){if(void 0===e)throw Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=sn(t,this.TimeBufferType),this.values=sn(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t,n=e.constructor;if(n.toJSON!==this.toJSON)t=n.toJSON(e);else{t={name:e.name,times:sn(e.times,Array),values:sn(e.values,Array)};let n=e.getInterpolation();n!==e.DefaultInterpolation&&(t.interpolation=n)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new sc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new sl(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){let t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return eb("KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(1!==e){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;-1!==a&&n[a]>t;)--a;if(++a,0!==r||a!==i){r>=a&&(r=(a=Math.max(a,1))-1);let e=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(eS("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,r=n.length;0===r&&(eS("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){let i=n[t];if("number"==typeof i&&isNaN(i)){eS("KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){eS("KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&ep(i))for(let t=0,n=i.length;t!==n;++t){let n=i[t];if(isNaN(n)){eS("KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=2302===this.getInterpolation(),r=e.length-1,a=1;for(let s=1;s<r;++s){let r=!1,o=e[s];if(o!==e[s+1]&&(1!==s||o!==e[0]))if(i)r=!0;else{let e=s*n,i=e-n,a=e+n;for(let s=0;s!==n;++s){let n=t[e+s];if(n!==t[i+s]||n!==t[a+s]){r=!0;break}}}if(r){if(s!==a){e[a]=e[s];let i=s*n,r=a*n;for(let e=0;e!==n;++e)t[r+e]=t[i+e]}++a}}if(r>0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=new this.constructor(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}sh.prototype.ValueTypeName="",sh.prototype.TimeBufferType=Float32Array,sh.prototype.ValueBufferType=Float32Array,sh.prototype.DefaultInterpolation=2301;class sd extends sh{constructor(e,t,n){super(e,t,n)}}sd.prototype.ValueTypeName="bool",sd.prototype.ValueBufferType=Array,sd.prototype.DefaultInterpolation=2300,sd.prototype.InterpolantFactoryMethodLinear=void 0,sd.prototype.InterpolantFactoryMethodSmooth=void 0;class sp extends sh{constructor(e,t,n,i){super(e,t,n,i)}}sp.prototype.ValueTypeName="color";class sf extends sh{constructor(e,t,n,i){super(e,t,n,i)}}sf.prototype.ValueTypeName="number";class sm extends so{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t),l=e*s;for(let e=l+s;l!==e;l+=4)eF.slerpFlat(r,0,a,l-s,a,l,o);return r}}class sg extends sh{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new sm(this.times,this.values,this.getValueSize(),e)}}sg.prototype.ValueTypeName="quaternion",sg.prototype.InterpolantFactoryMethodSmooth=void 0;class sv extends sh{constructor(e,t,n){super(e,t,n)}}sv.prototype.ValueTypeName="string",sv.prototype.ValueBufferType=Array,sv.prototype.DefaultInterpolation=2300,sv.prototype.InterpolantFactoryMethodLinear=void 0,sv.prototype.InterpolantFactoryMethodSmooth=void 0;class sx extends sh{constructor(e,t,n,i){super(e,t,n,i)}}sx.prototype.ValueTypeName="vector";class sy{constructor(e="",t=-1,n=[],i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=eR(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push((function(e){if(void 0===e.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sf;case"vector":case"vector2":case"vector3":case"vector4":return sx;case"color":return sp;case"quaternion":return sg;case"bool":case"boolean":return sd;case"string":return sv}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){let t=[],n=[];sa(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)})(n[e]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,i=n.length;e!==i;++e)t.push(sh.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,a=[];for(let e=0;e<r;e++){let s=[],o=[];s.push((e+r-1)%r,e,(e+1)%r),o.push(0,1,0);let l=si(s);s=sr(s,1,l),o=sr(o,1,l),i||0!==s[0]||(s.push(r),o.push(o[0])),a.push(new sf(".morphTargetInfluences["+t[e].name+"]",s,o).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;Array.isArray(e)||(n=e.geometry&&e.geometry.animations||e.animations);for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){let n=e[t],a=n.name.match(r);if(a&&a.length>1){let e=a[1],t=i[e];t||(i[e]=t=[]),t.push(n)}}let a=[];for(let e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(eb("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return eS("AnimationClip: No animation in JSONLoader data."),null;let n=function(e,t,n,i,r){if(0!==n.length){let a=[],s=[];sa(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let e=0;e<l.length;e++){let r=l[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){let e,t={};for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(let n in t){let t=[],a=[];for(let i=0;i!==r[e].morphTargets.length;++i){let i=r[e];t.push(i.time),a.push(+(i.morphTarget===n))}i.push(new sf(".morphTargetInfluence["+n+"]",t,a))}o=t.length*a}else{let a=".bones["+t[e].name+"]";n(sx,a+".position",r,"pos",i),n(sg,a+".quaternion",r,"rot",i),n(sx,a+".scale",r,"scl",i)}}return 0===i.length?null:new this(r,o,i,s)}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let e=this.tracks[n];t=Math.max(t,e.times[e.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}let s_={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class sb{constructor(e,t,n){let i;const r=this;let a=!1,s=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,!1===a&&void 0!==r.onStart&&r.onStart(e,s,o),a=!0},this.itemEnd=function(e){s++,void 0!==r.onProgress&&r.onProgress(e,s,o),s===o&&(a=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){let t=l.indexOf(e);return -1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){let n=l[t],i=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}let sS=new sb;class sM{constructor(e){this.manager=void 0!==e?e:sS,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}sM.DEFAULT_MATERIAL_NAME="__DEFAULT";let sw={};class sT extends Error{constructor(e,t){super(e),this.response=t}}class sE extends sM{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=s_.get(`file:${e}`);if(void 0!==r)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(void 0!==sw[e])return void sw[e].push({onLoad:t,onProgress:n,onError:i});sw[e]=[],sw[e].push({onLoad:t,onProgress:n,onError:i});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),s=this.mimeType,o=this.responseType;fetch(a).then(t=>{if(200===t.status||0===t.status){if(0===t.status&&eb("FileLoader: HTTP Status 0 received."),"u"<typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;let n=sw[e],i=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),a=r?parseInt(r):0,s=0!==a,o=0;return new Response(new ReadableStream({start(e){!function t(){i.read().then(({done:i,value:r})=>{if(i)e.close();else{let i=new ProgressEvent("progress",{lengthComputable:s,loaded:o+=r.byteLength,total:a});for(let e=0,t=n.length;e<t;e++){let t=n[e];t.onProgress&&t.onProgress(i)}e.enqueue(r),t()}},t=>{e.error(t)})}()}}))}throw new sT(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>new DOMParser().parseFromString(e,s));case"json":return e.json();default:if(""===s)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(s),n=new TextDecoder(t&&t[1]?t[1].toLowerCase():void 0);return e.arrayBuffer().then(e=>n.decode(e))}}}).then(t=>{s_.add(`file:${e}`,t);let n=sw[e];delete sw[e];for(let e=0,i=n.length;e<i;e++){let i=n[e];i.onLoad&&i.onLoad(t)}}).catch(t=>{let n=sw[e];if(void 0===n)throw this.manager.itemError(e),t;delete sw[e];for(let e=0,i=n.length;e<i;e++){let i=n[e];i.onError&&i.onError(t)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class sA extends sM{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sE(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):eS(t),r.manager.itemError(e)}},n,i)}parse(e){let t=[];for(let n=0;n<e.length;n++){let i=sy.parse(e[n]);t.push(i)}return t}}class sC extends sM{constructor(e){super(e)}load(e,t,n,i){let r=this,a=[],s=new rV,o=new sE(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;if(Array.isArray(e))for(let u=0,c=e.length;u<c;++u)!function(u){o.load(e[u],function(e){let n=r.parse(e,!0);a[u]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},6===(l+=1)&&(1===n.mipmapCount&&(s.minFilter=1006),s.image=a,s.format=n.format,s.needsUpdate=!0,t&&t(s))},n,i)}(u);else o.load(e,function(e){let n=r.parse(e,!0);if(n.isCubemap){let e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){a[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)a[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),a[t].format=n.format,a[t].width=n.width,a[t].height=n.height}s.image=a}else s.image.width=n.width,s.image.height=n.height,s.mipmaps=n.mipmaps;1===n.mipmapCount&&(s.minFilter=1006),s.format=n.format,s.needsUpdate=!0,t&&t(s)},n,i);return s}}let sR=new WeakMap;class sP extends sM{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=s_.get(`image:${e}`);if(void 0!==a){if(!0===a.complete)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let e=sR.get(a);void 0===e&&(e=[],sR.set(a,e)),e.push({onLoad:t,onError:i})}return a}let s=ef("img");function o(){u(),t&&t(this);let n=sR.get(this)||[];for(let e=0;e<n.length;e++){let t=n[e];t.onLoad&&t.onLoad(this)}sR.delete(this),r.manager.itemEnd(e)}function l(t){u(),i&&i(t),s_.remove(`image:${e}`);let n=sR.get(this)||[];for(let e=0;e<n.length;e++){let i=n[e];i.onError&&i.onError(t)}sR.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),s_.add(`image:${e}`,s),r.manager.itemStart(e),s.src=e,s}}class sI extends sM{constructor(e){super(e)}load(e,t,n,i){let r=new n9;r.colorSpace=en;let a=new sP(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let s=0;for(let n=0;n<e.length;++n)!function(n){a.load(e[n],function(e){r.images[n]=e,6==++s&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}(n);return r}}class sL extends sM{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new iB,s=new sE(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,function(e){let n;try{n=r.parse(e)}catch(e){if(void 0===i)return void e(e);i(e)}void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:1001,a.wrapT=void 0!==n.wrapT?n.wrapT:1001,a.magFilter=void 0!==n.magFilter?n.magFilter:1006,a.minFilter=void 0!==n.minFilter?n.minFilter:1006,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(a.colorSpace=n.colorSpace),void 0!==n.flipY&&(a.flipY=n.flipY),void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=1008),1===n.mipmapCount&&(a.minFilter=1006),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)},n,i),a}}class sN extends sM{constructor(e){super(e)}load(e,t,n,i){let r=new e0,a=new sP(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)},n,i),r}}class sD extends tK{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new no(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}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}}class sU extends sD{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(tK.DEFAULT_UP),this.updateMatrix(),this.groundColor=new no(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}}let sO=new tT,sF=new ez,sz=new ez;class sk{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new eO(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new tT,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new i6,this._frameExtents=new eO(1,1),this._viewportCount=1,this._viewports=[new e1(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;sF.setFromMatrixPosition(e.matrixWorld),t.position.copy(sF),sz.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(sz),t.updateMatrixWorld(),sO.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sO,t.coordinateSystem,t.reversedDepth),t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(sO)}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}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),(512!==this.mapSize.x||512!==this.mapSize.y)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class sB extends sk{constructor(){super(new n6(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=2*eC*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class sV extends sD{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(tK.DEFAULT_UP),this.updateMatrix(),this.target=new tK,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new sB}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class sH extends sk{constructor(){super(new n6(90,1,.5,500)),this.isPointLightShadow=!0}}class sj extends sD{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new sH}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class sG extends n2{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,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=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(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=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,a=n+e,s=i+t,o=i-t;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}class sW extends sk{constructor(){super(new sG(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class sX extends sD{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(tK.DEFAULT_UP),this.updateMatrix(),this.target=new tK,this.shadow=new sW}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}}class sq extends sD{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sY extends sD{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class sZ{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new ez)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let n=e.x,i=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*i),t.addScaledVector(a[2],.488603*r),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*i*1.092548),t.addScaledVector(a[5],i*r*1.092548),t.addScaledVector(a[6],.315392*(3*r*r-1)),t.addScaledVector(a[7],n*r*1.092548),t.addScaledVector(a[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){let n=e.x,i=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*i),t.addScaledVector(a[2],1.023328*r),t.addScaledVector(a[3],1.023328*n),t.addScaledVector(a[4],.858086*n*i),t.addScaledVector(a[5],.858086*i*r),t.addScaledVector(a[6],.743125*r*r-.247708),t.addScaledVector(a[7],.858086*n*r),t.addScaledVector(a[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){let n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){let n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class sJ extends sD{constructor(e=new sZ,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class s$ extends sM{constructor(e){super(e),this.textures={}}load(e,t,n,i){let r=this,a=new sE(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):eS(t),r.manager.itemError(e)}},n,i)}parse(e){let t=this.textures;function n(e){return void 0===t[e]&&eb("MaterialLoader: Undefined texture",e),t[e]}let i=this.createMaterialFromType(e.type);if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=e.sheen),void 0!==e.sheenColor&&(i.sheenColor=new no().setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(i.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.specularIntensity&&(i.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.dispersion&&(i.dispersion=e.dispersion),void 0!==e.iridescence&&(i.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(i.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.thickness&&(i.thickness=e.thickness),void 0!==e.attenuationDistance&&(i.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(i.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(i.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.shadowSide&&(i.shadowSide=e.shadowSide),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(i.alphaHash=e.alphaHash),void 0!==e.depthFunc&&(i.depthFunc=e.depthFunc),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.blendSrc&&(i.blendSrc=e.blendSrc),void 0!==e.blendDst&&(i.blendDst=e.blendDst),void 0!==e.blendEquation&&(i.blendEquation=e.blendEquation),void 0!==e.blendSrcAlpha&&(i.blendSrcAlpha=e.blendSrcAlpha),void 0!==e.blendDstAlpha&&(i.blendDstAlpha=e.blendDstAlpha),void 0!==e.blendEquationAlpha&&(i.blendEquationAlpha=e.blendEquationAlpha),void 0!==e.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(e.blendColor),void 0!==e.blendAlpha&&(i.blendAlpha=e.blendAlpha),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),void 0!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.alphaToCoverage&&(i.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(i.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(i.forceSinglePass=e.forceSinglePass),void 0!==e.allowOverride&&(i.allowOverride=e.allowOverride),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(let t in e.uniforms){let r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=new no().setHex(r.value);break;case"v2":i.uniforms[t].value=new eO().fromArray(r.value);break;case"v3":i.uniforms[t].value=new ez().fromArray(r.value);break;case"v4":i.uniforms[t].value=new e1().fromArray(r.value);break;case"m3":i.uniforms[t].value=new eV().fromArray(r.value);break;case"m4":i.uniforms[t].value=new tT().fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(let t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=new eO().fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapRotation&&i.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=new eO().fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return s$.createMaterialFromType(e)}static createMaterialFromType(e){return new({ShadowMaterial:a0,SpriteMaterial:ic,RawShaderMaterial:a1,ShaderMaterial:n1,PointsMaterial:rI,MeshPhysicalMaterial:a3,MeshStandardMaterial:a2,MeshPhongMaterial:a4,MeshToonMaterial:a5,MeshNormalMaterial:a6,MeshLambertMaterial:a8,MeshDepthMaterial:a9,MeshDistanceMaterial:a7,MeshBasicMaterial:nh,MeshMatcapMaterial:se,LineDashedMaterial:st,LineBasicMaterial:rv,Material:nc})[e]}}class sK{static extractUrlBase(e){let t=e.lastIndexOf("/");return -1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e))?e:t+e}}class sQ extends nO{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class s0 extends sM{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sE(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):eS(t),r.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(e,i){if(void 0!==t[i])return t[i];let r=e.interleavedBuffers[i],a=function(e,t){if(void 0!==n[t])return n[t];let i=new Uint32Array(e.arrayBuffers[t]).buffer;return n[t]=i,i}(e,r.buffer),s=new io(ed(r.type,a),r.stride);return s.uuid=r.uuid,t[i]=s,s}let r=e.isInstancedBufferGeometry?new sQ:new nO,a=e.data.index;if(void 0!==a){let e=ed(a.type,a.array);r.setIndex(new ny(e,1))}let s=e.data.attributes;for(let t in s){let n,a=s[t];if(a.isInterleavedBufferAttribute)n=new iu(i(e.data,a.data),a.itemSize,a.offset,a.normalized);else{let e=ed(a.type,a.array);n=new(a.isInstancedBufferAttribute?iG:ny)(e,a.itemSize,a.normalized)}void 0!==a.name&&(n.name=a.name),void 0!==a.usage&&n.setUsage(a.usage),r.setAttribute(t,n)}let o=e.data.morphAttributes;if(o)for(let t in o){let n=o[t],a=[];for(let t=0,r=n.length;t<r;t++){let r,s=n[t];r=s.isInterleavedBufferAttribute?new iu(i(e.data,s.data),s.itemSize,s.offset,s.normalized):new ny(ed(s.type,s.array),s.itemSize,s.normalized),void 0!==s.name&&(r.name=s.name),a.push(r)}r.morphAttributes[t]=a}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){let t=l[e];r.addGroup(t.start,t.count,t.materialIndex)}let u=e.data.boundingSphere;return void 0!==u&&(r.boundingSphere=new tg().fromJSON(u)),e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}}class s1 extends sM{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===this.path?sK.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let s=new sE(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){let a=null;try{a=JSON.parse(n)}catch(t){void 0!==i&&i(t),t("ObjectLoader: Can't parse "+e+".",t.message);return}let s=a.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase()){void 0!==i&&i(Error("THREE.ObjectLoader: Can't load "+e)),eS("ObjectLoader: Can't load "+e);return}r.parse(a,t)},n,i)}async loadAsync(e,t){let n=""===this.path?sK.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;let i=new sE(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);let r=JSON.parse(await i.loadAsync(e,t)),a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(r)}parse(e,t){let n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),a=this.parseImages(e.images,function(){void 0!==t&&t(l)}),s=this.parseTextures(e.textures,a),o=this.parseMaterials(e.materials,s),l=this.parseObject(e.object,r,o,s,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),void 0!==t){let e=!1;for(let t in a)if(a[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,r),s=this.parseMaterials(e.materials,a),o=this.parseObject(e.object,i,s,a,t),l=this.parseSkeletons(e.skeletons,o);return this.bindSkeletons(o,l),this.bindLightTargets(o),o}parseShapes(e){let t={};if(void 0!==e)for(let n=0,i=e.length;n<i;n++){let i=new av().fromJSON(e[n]);t[i.uuid]=i}return t}parseSkeletons(e,t){let n={},i={};if(t.traverse(function(e){e.isBone&&(i[e.uuid]=e)}),void 0!==e)for(let t=0,r=e.length;t<r;t++){let r=new ij().fromJSON(e[t],i);n[r.uuid]=r}return n}parseGeometries(e,t){let n={};if(void 0!==e){let i=new s0;for(let r=0,a=e.length;r<a;r++){let a,s=e[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(s);break;default:s.type in aQ?a=aQ[s.type].fromJSON(s,t):eb(`ObjectLoader: Unsupported geometry type "${s.type}"`)}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),void 0!==s.userData&&(a.userData=s.userData),n[s.uuid]=a}}return n}parseMaterials(e,t){let n={},i={};if(void 0!==e){let r=new s$;r.setTextures(t);for(let t=0,a=e.length;t<a;t++){let a=e[t];void 0===n[a.uuid]&&(n[a.uuid]=r.parse(a)),i[a.uuid]=n[a.uuid]}}return i}parseAnimations(e){let t={};if(void 0!==e)for(let n=0;n<e.length;n++){let i=e[n],r=sy.parse(i);t[r.uuid]=r}return t}parseImages(e,t){let n,i=this,r={};function a(e){if("string"==typeof e){var t;return t=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e,i.manager.itemStart(t),n.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}return e.data?{data:ed(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){(n=new sP(new sb(t))).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){let n=e[t],i=n.url;if(Array.isArray(i)){let e=[];for(let t=0,n=i.length;t<n;t++){let n=a(i[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new iB(n.data,n.width,n.height)))}r[n.uuid]=new eJ(e)}else{let e=a(n.url);r[n.uuid]=new eJ(e)}}}return r}async parseImagesAsync(e){let t,n=this,i={};async function r(e){if("string"==typeof e){let i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:n.resourcePath+e;return await t.loadAsync(i)}return e.data?{data:ed(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){(t=new sP(this.manager)).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){let n=e[t],a=n.url;if(Array.isArray(a)){let e=[];for(let t=0,n=a.length;t<n;t++){let n=a[t],i=await r(n);null!==i&&(i instanceof HTMLImageElement?e.push(i):e.push(new iB(i.data,i.width,i.height)))}i[n.uuid]=new eJ(e)}else{let e=await r(n.url);i[n.uuid]=new eJ(e)}}}return i}parseTextures(e,t){function n(e,t){return"number"==typeof e?e:(eb("ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}let i={};if(void 0!==e)for(let r=0,a=e.length;r<a;r++){let a,s=e[r];void 0===s.image&&eb('ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&eb("ObjectLoader: Undefined image",s.image);let o=t[s.image],l=o.data;Array.isArray(l)?(a=new n9,6===l.length&&(a.needsUpdate=!0)):(a=l&&l.data?new iB:new e0,l&&(a.needsUpdate=!0)),a.source=o,a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),void 0!==s.mapping&&(a.mapping=n(s.mapping,s2)),void 0!==s.channel&&(a.channel=s.channel),void 0!==s.offset&&a.offset.fromArray(s.offset),void 0!==s.repeat&&a.repeat.fromArray(s.repeat),void 0!==s.center&&a.center.fromArray(s.center),void 0!==s.rotation&&(a.rotation=s.rotation),void 0!==s.wrap&&(a.wrapS=n(s.wrap[0],s3),a.wrapT=n(s.wrap[1],s3)),void 0!==s.format&&(a.format=s.format),void 0!==s.internalFormat&&(a.internalFormat=s.internalFormat),void 0!==s.type&&(a.type=s.type),void 0!==s.colorSpace&&(a.colorSpace=s.colorSpace),void 0!==s.minFilter&&(a.minFilter=n(s.minFilter,s4)),void 0!==s.magFilter&&(a.magFilter=n(s.magFilter,s4)),void 0!==s.anisotropy&&(a.anisotropy=s.anisotropy),void 0!==s.flipY&&(a.flipY=s.flipY),void 0!==s.generateMipmaps&&(a.generateMipmaps=s.generateMipmaps),void 0!==s.premultiplyAlpha&&(a.premultiplyAlpha=s.premultiplyAlpha),void 0!==s.unpackAlignment&&(a.unpackAlignment=s.unpackAlignment),void 0!==s.compareFunction&&(a.compareFunction=s.compareFunction),void 0!==s.userData&&(a.userData=s.userData),i[s.uuid]=a}return i}parseObject(e,t,n,i,r){let a,s,o;function l(e){return void 0===t[e]&&eb("ObjectLoader: Undefined geometry",e),t[e]}function u(e){if(void 0!==e){if(Array.isArray(e)){let t=[];for(let i=0,r=e.length;i<r;i++){let r=e[i];void 0===n[r]&&eb("ObjectLoader: Undefined material",r),t.push(n[r])}return t}return void 0===n[e]&&eb("ObjectLoader: Undefined material",e),n[e]}}function c(e){return void 0===i[e]&&eb("ObjectLoader: Undefined texture",e),i[e]}switch(e.type){case"Scene":a=new is,void 0!==e.background&&(Number.isInteger(e.background)?a.background=new no(e.background):a.background=c(e.background)),void 0!==e.environment&&(a.environment=c(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new ia(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new ir(e.fog.color,e.fog.density)),""!==e.fog.name&&(a.fog.name=e.fog.name)),void 0!==e.backgroundBlurriness&&(a.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(a.backgroundIntensity=e.backgroundIntensity),void 0!==e.backgroundRotation&&a.backgroundRotation.fromArray(e.backgroundRotation),void 0!==e.environmentIntensity&&(a.environmentIntensity=e.environmentIntensity),void 0!==e.environmentRotation&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new n6(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(a.focus=e.focus),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.filmGauge&&(a.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(a.filmOffset=e.filmOffset),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new sG(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new sq(e.color,e.intensity);break;case"DirectionalLight":(a=new sX(e.color,e.intensity)).target=e.target||"";break;case"PointLight":a=new sj(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new sY(e.color,e.intensity,e.width,e.height);break;case"SpotLight":(a=new sV(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay)).target=e.target||"";break;case"HemisphereLight":a=new sU(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new sJ(new sZ().fromArray(e.sh),e.intensity);break;case"SkinnedMesh":a=new iz(s=l(e.geometry),o=u(e.material)),void 0!==e.bindMode&&(a.bindMode=e.bindMode),void 0!==e.bindMatrix&&a.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(a.skeleton=e.skeleton);break;case"Mesh":a=new nY(s=l(e.geometry),o=u(e.material));break;case"InstancedMesh":s=l(e.geometry),o=u(e.material);let h=e.count,d=e.instanceMatrix,p=e.instanceColor;(a=new iK(s,o,h)).instanceMatrix=new iG(new Float32Array(d.array),16),void 0!==p&&(a.instanceColor=new iG(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":s=l(e.geometry),o=u(e.material),(a=new rg(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,o)).geometry=s,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(e=>{let t=null,n=null;return void 0!==e.boundingBox&&(t=new e9().fromJSON(e.boundingBox)),void 0!==e.boundingSphere&&(n=new tg().fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:n}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),void 0!==e.colorsTexture&&(a._colorsTexture=c(e.colorsTexture.uuid)),void 0!==e.boundingSphere&&(a.boundingSphere=new tg().fromJSON(e.boundingSphere)),void 0!==e.boundingBox&&(a.boundingBox=new e9().fromJSON(e.boundingBox));break;case"LOD":a=new iC;break;case"Line":a=new rT(l(e.geometry),u(e.material));break;case"LineLoop":a=new rP(l(e.geometry),u(e.material));break;case"LineSegments":a=new rR(l(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new rO(l(e.geometry),u(e.material));break;case"Sprite":a=new iw(u(e.material));break;case"Group":a=new ie;break;case"Bone":a=new ik;break;default:a=new tK}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.up&&a.up.fromArray(e.up),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(a.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(a.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children){let s=e.children;for(let e=0;e<s.length;e++)a.add(this.parseObject(s[e],t,n,i,r))}if(void 0!==e.animations){let t=e.animations;for(let e=0;e<t.length;e++){let n=t[e];a.animations.push(r[n])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(a.autoUpdate=e.autoUpdate);let t=e.levels;for(let e=0;e<t.length;e++){let n=t[e],i=a.getObjectByProperty("uuid",n.object);void 0!==i&&a.addLevel(i,n.distance,n.hysteresis)}}return a}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse(function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){let n=t[e.skeleton];void 0===n?eb("ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){let n=t.target,i=e.getObjectByProperty("uuid",n);void 0!==i?t.target=i:t.target=new tK}})}}let s2={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,CubeUVReflectionMapping:306},s3={RepeatWrapping:1e3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002},s4={NearestFilter:1003,NearestMipmapNearestFilter:1004,NearestMipmapLinearFilter:1005,LinearFilter:1006,LinearMipmapNearestFilter:1007,LinearMipmapLinearFilter:1008},s5=new WeakMap;class s6 extends sM{constructor(e){super(e),this.isImageBitmapLoader=!0,"u"<typeof createImageBitmap&&eb("ImageBitmapLoader: createImageBitmap() not supported."),"u"<typeof fetch&&eb("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=s_.get(`image-bitmap:${e}`);if(void 0!==a)return(r.manager.itemStart(e),a.then)?void a.then(n=>{if(!0!==s5.has(a))return t&&t(n),r.manager.itemEnd(e),n;i&&i(s5.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)}):(setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a);let s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,s.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,s).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(n){return s_.add(`image-bitmap:${e}`,n),t&&t(n),r.manager.itemEnd(e),n}).catch(function(t){i&&i(t),s5.set(o,t),s_.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});s_.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class s8{static getContext(){return void 0===i&&(i=new(window.AudioContext||window.webkitAudioContext)),i}static setContext(e){i=e}}class s9 extends sM{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sE(this.manager);function s(t){i?i(t):eS(t),r.manager.itemError(e)}a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(e){try{let n=e.slice(0);s8.getContext().decodeAudioData(n,function(e){t(e)}).catch(s)}catch(e){s(e)}},n,i)}}let s7=new tT,oe=new tT,ot=new tT;class on{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new n6,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new n6,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){let n,i;t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,ot.copy(e.projectionMatrix);let r=t.eyeSep/2,a=r*t.near/t.focus,s=t.near*Math.tan(eA*t.fov*.5)/t.zoom;oe.elements[12]=-r,s7.elements[12]=r,n=-s*t.aspect+a,i=s*t.aspect+a,ot.elements[0]=2*t.near/(i-n),ot.elements[8]=(i+n)/(i-n),this.cameraL.projectionMatrix.copy(ot),n=-s*t.aspect-a,i=s*t.aspect-a,ot.elements[0]=2*t.near/(i-n),ot.elements[8]=(i+n)/(i-n),this.cameraR.projectionMatrix.copy(ot)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(oe),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(s7)}}class oi extends n6{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class or{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}let oa=new ez,os=new eF,oo=new ez,ol=new ez,ou=new ez;class oc extends tK{constructor(){super(),this.type="AudioListener",this.context=s8.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new or}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(oa,os,oo),ol.set(0,0,-1).applyQuaternion(os),ou.set(0,1,0).applyQuaternion(os),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(oa.x,e),t.positionY.linearRampToValueAtTime(oa.y,e),t.positionZ.linearRampToValueAtTime(oa.z,e),t.forwardX.linearRampToValueAtTime(ol.x,e),t.forwardY.linearRampToValueAtTime(ol.y,e),t.forwardZ.linearRampToValueAtTime(ol.z,e),t.upX.linearRampToValueAtTime(ou.x,e),t.upY.linearRampToValueAtTime(ou.y,e),t.upZ.linearRampToValueAtTime(ou.z,e)}else t.setPosition(oa.x,oa.y,oa.z),t.setOrientation(ol.x,ol.y,ol.z,ou.x,ou.y,ou.z)}}class oh extends tK{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void eb("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void eb("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){return!1===this.hasPlaybackControl?void eb("Audio: this Audio has no playback control."):(!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this)}stop(e=0){return!1===this.hasPlaybackControl?void eb("Audio: this Audio has no playback control."):(this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this)}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){return!1===this.hasPlaybackControl?void eb("Audio: this Audio has no playback control."):(this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this)}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return!1===this.hasPlaybackControl?(eb("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){return!1===this.hasPlaybackControl?void eb("Audio: this Audio has no playback control."):(this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this)}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return(super.copy(e,t),"buffer"!==e.sourceType)?eb("Audio: Audio source type cannot be copied."):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice()),this}clone(e){return new this.constructor(this.listener).copy(this,e)}}let od=new ez,op=new eF,of=new ez,om=new ez;class og extends oh{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(od,op,of),om.set(0,0,1).applyQuaternion(op);let t=this.panner;if(t.positionX){let e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(od.x,e),t.positionY.linearRampToValueAtTime(od.y,e),t.positionZ.linearRampToValueAtTime(od.z,e),t.orientationX.linearRampToValueAtTime(om.x,e),t.orientationY.linearRampToValueAtTime(om.y,e),t.orientationZ.linearRampToValueAtTime(om.z,e)}else t.setPosition(od.x,od.y,od.z),t.setOrientation(om.x,om.y,om.z)}}class ov{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class ox{constructor(e,t,n){let i,r,a;switch(this.binding=e,this.valueSize=n,t){case"quaternion":i=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,a=this.cumulativeWeight;if(0===a){for(let e=0;e!==i;++e)n[r+e]=n[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(n,r,0,e,i)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let e=t*this._origIndex;this._mixBufferRegion(n,i,e,1-r,t)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){s.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n;e!==i;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){eF.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let a=this._workIndex*r;eF.multiplyQuaternionsFlat(e,a,e,t,e,n),eF.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){let a=1-i;for(let s=0;s!==r;++s){let r=t+s;e[r]=e[r]*a+e[n+s]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){let r=t+a;e[r]=e[r]+e[n+a]*i}}}let oy="\\[\\]\\.:\\/",o_=RegExp("["+oy+"]","g"),ob="[^"+oy+"]",oS="[^"+oy.replace("\\.","")+"]",oM=RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",ob)+/(WCOD+)?/.source.replace("WCOD",oS)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ob)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ob)+"$"),ow=["material","materials","bones","map"];class oT{constructor(e,t,n){this.path=t,this.parsedPath=n||oT.parseTrackName(t),this.node=oT.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new oT.Composite(e,t,n):new oT(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(o_,"")}static parseTrackName(e){let t=oM.exec(e);if(null===t)throw Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){let e=n.nodeName.substring(i+1);-1!==ow.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){let n=function(e){for(let i=0;i<e.length;i++){let r=e[i];if(r.name===t||r.uuid===t)return r;let a=n(r.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_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 n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=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,n=t.objectName,i=t.propertyName,r=t.propertyIndex;if(e||(e=oT.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void eb("PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=t.objectIndex;switch(n){case"materials":if(!e.material)return void eS("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void eS("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void eS("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===i){i=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void eS("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void eS("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[n])return void eS("PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==i){if(void 0===e[i])return void eS("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[i]}}let a=e[i];if(void 0===a)return void eS("PropertyBinding: Trying to update property for track: "+t.nodeName+"."+i+" but it wasn't found.",e);let s=this.Versioning.None;this.targetObject=e,!0===e.isMaterial?s=this.Versioning.NeedsUpdate:!0===e.isObject3D&&(s=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!e.geometry)return void eS("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void eS("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else void 0!==a.fromArray&&void 0!==a.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}oT.Composite=class{constructor(e,t,n){const i=n||oT.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},oT.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},oT.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},oT.prototype.GetterByBindingType=[oT.prototype._getValue_direct,oT.prototype._getValue_array,oT.prototype._getValue_arrayElement,oT.prototype._getValue_toArray],oT.prototype.SetterByBindingTypeAndVersioning=[[oT.prototype._setValue_direct,oT.prototype._setValue_direct_setNeedsUpdate,oT.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[oT.prototype._setValue_array,oT.prototype._setValue_array_setNeedsUpdate,oT.prototype._setValue_array_setMatrixWorldNeedsUpdate],[oT.prototype._setValue_arrayElement,oT.prototype._setValue_arrayElement_setNeedsUpdate,oT.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[oT.prototype._setValue_fromArray,oT.prototype._setValue_fromArray_setNeedsUpdate,oT.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class oE{constructor(){this.isAnimationObjectGroup=!0,this.uuid=eR(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,a=r.length,s,o=e.length,l=this.nCachedObjects_;for(let u=0,c=arguments.length;u!==c;++u){let c=arguments[u],h=c.uuid,d=t[h];if(void 0===d){d=o++,t[h]=d,e.push(c);for(let e=0;e!==a;++e)r[e].push(new oT(c,n[e],i[e]))}else if(d<l){s=e[d];let o=--l,u=e[o];t[u.uuid]=d,e[d]=u,t[h]=o,e[o]=c;for(let e=0;e!==a;++e){let t=r[e],a=t[o],s=t[d];t[d]=a,void 0===s&&(s=new oT(c,n[e],i[e])),t[o]=s}}else e[d]!==s&&eS("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_;for(let a=0,s=arguments.length;a!==s;++a){let s=arguments[a],o=s.uuid,l=t[o];if(void 0!==l&&l>=r){let a=r++,u=e[a];t[u.uuid]=l,e[l]=u,t[o]=a,e[a]=s;for(let e=0;e!==i;++e){let t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=e.length;for(let s=0,o=arguments.length;s!==o;++s){let o=arguments[s],l=o.uuid,u=t[l];if(void 0!==u)if(delete t[l],u<r){let s=--r,o=e[s],l=--a,c=e[l];t[o.uuid]=u,e[u]=o,t[c.uuid]=s,e[s]=c,e.pop();for(let e=0;e!==i;++e){let t=n[e],i=t[s],r=t[l];t[u]=i,t[s]=r,t.pop()}}else{let r=--a,s=e[r];r>0&&(t[s.uuid]=u),e[u]=s,e.pop();for(let e=0;e!==i;++e){let t=n[e];t[u]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],r=this._bindings;if(void 0!==i)return r[i];let a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,u=this.nCachedObjects_,c=Array(l);i=r.length,n[e]=i,a.push(e),s.push(t),r.push(c);for(let n=u,i=o.length;n!==i;++n){let i=o[n];c[n]=new oT(i,e,t)}return c}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){let i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];t[e[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}}class oA{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,a=r.length,s=Array(a),o={endingStart:2400,endingEnd:2400};for(let e=0;e!==a;++e){const t=r[e].createInterpolant(null);s[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),!0===n){let n=this._clip.duration,i=e._clip.duration;e.warp(1,i/n,t),this.warp(n/i,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,a=this.timeScale,s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);let o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(null!==r){let i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);let a=this._updateTime(t),s=this._updateWeight(e);if(s>0){let e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(s);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(null!==n){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,a=2202===n;if(0===e)return -1===r?i:a&&(1&r)==1?t-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));s:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break s}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){let n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);let s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&(1&r)==1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=2401,i.endingEnd=2401):(e?i.endingStart=this.zeroSlopeAtStart?2401:2400:i.endingStart=2402,t?i.endingEnd=this.zeroSlopeAtEnd?2401:2400:i.endingEnd=2402)}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=t,s[1]=r+e,o[1]=n,this}}let oC=new Float32Array(1);class oR extends ew{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,s=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName,u=l[o];void 0===u&&(u={},l[o]=u);for(let e=0;e!==r;++e){let r=i[e],l=r.name,c=u[l];if(void 0!==c)++c.referenceCount,a[e]=c;else{if(void 0!==(c=a[e])){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,l));continue}let i=t&&t._propertyBindings[e].binding.parsedPath;c=new ox(oT.create(n,l,i),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,l),a[e]=c}s[e].resultBuffer=c.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,a=r[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=a;else{let t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,a=this._actionsByClip,s=a[r],o=s.knownActions,l=o[o.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,o[u]=l,o.pop(),e._byClipCacheIndex=null;let c=s.actionByRoot,h=(e._localRoot||this._root).uuid;delete c[h],0===o.length&&delete a[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,a=i[t];void 0===a&&(a={},i[t]=a),a[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,s=a[i],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete s[r],0===Object.keys(s).length&&delete a[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return void 0===n&&((n=new su(new Float32Array(2),new Float32Array(2),1,oC)).__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,a="string"==typeof e?sy.findByName(i,e):e,s=null!==a?a.uuid:e,o=this._actionsByClip[s],l=null;if(void 0===n&&(n=null!==a?a.blendMode:2500),void 0!==o){let e=o.actionByRoot[r];if(void 0!==e&&e.blendMode===n)return e;l=o.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;let u=new oA(this,a,t,n);return this._bindAction(u,l),this._addInactiveAction(u,s,r),u}existingAction(e,t){let n=t||this._root,i=n.uuid,r="string"==typeof e?sy.findByName(n,e):e,a=r?r.uuid:e,s=this._actionsByClip[a];return void 0!==s&&s.actionByRoot[i]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let s=0;s!==n;++s)t[s]._update(i,e,r,a);let s=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)s[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){let e=r.knownActions;for(let n=0,i=e.length;n!==i;++n){let i=e[n];this._deactivateAction(i);let r=i._cacheIndex,a=t[t.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,a._cacheIndex=r,t[r]=a,t.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let e in n){let i=n[e].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}let i=this._bindingsByRootAndName[t];if(void 0!==i)for(let e in i){let t=i[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){let n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class oP extends e2{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new e6(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class oI{constructor(e){this.value=e}clone(){return new oI(void 0===this.value.clone?this.value:this.value.clone())}}let oL=0;class oN extends ew{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:oL++}),this.name="",this.usage=35044,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return -1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let e=0,n=t.length;e<n;e++){let n=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0;e<n.length;e++)this.uniforms.push(n[e].clone())}return this}clone(){return new this.constructor().copy(this)}}class oD extends io{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class oU{constructor(e,t,n,i,r,a=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.normalized=a,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}let oO=new tT;class oF{constructor(e,t,n=0,i=1/0){this.ray=new tw(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new tO,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.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):eS("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return oO.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(oO),this}intersectObject(e,t=!0,n=[]){return ok(e,this,n,t),n.sort(oz),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)ok(e[i],this,n,t);return n.sort(oz),n}}function oz(e,t){return e.distance-t.distance}function ok(e,t,n,i){let r=!0;if(e.layers.test(t.layers)&&!1===e.raycast(t,n)&&(r=!1),!0===r&&!0===i){let i=e.children;for(let e=0,r=i.length;e<r;e++)ok(i[e],t,n,!0)}}class oB{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,void 0!==e.hidden&&(this._pageVisibilityHandler=oV.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==e?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function oV(){!1===this._document.hidden&&this.reset()}class oH{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=eP(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(eP(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class oj{constructor(e=1,t=0,n=0){this.radius=e,this.theta=t,this.y=n}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class oG{constructor(e,t,n,i){oG.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==e&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}let oW=new eO;class oX{constructor(e=new eO(Infinity,Infinity),t=new eO(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=oW.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=Infinity,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}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}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))}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}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,oW).distanceTo(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}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)}}let oq=new ez,oY=new ez,oZ=new ez,oJ=new ez,o$=new ez,oK=new ez,oQ=new ez;class o0{constructor(e=new ez,t=new ez){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){oq.subVectors(e,this.start),oY.subVectors(this.end,this.start);let n=oY.dot(oY),i=oY.dot(oq)/n;return t&&(i=eP(i,0,1)),i}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=oK,n=oQ){let i,r,a=1e-8*1e-8,s=this.start,o=e.start,l=this.end,u=e.end;oZ.subVectors(l,s),oJ.subVectors(u,o),o$.subVectors(s,o);let c=oZ.dot(oZ),h=oJ.dot(oJ),d=oJ.dot(o$);if(c<=a&&h<=a)return t.copy(s),n.copy(o),t.sub(n),t.dot(t);if(c<=a)i=0,r=eP(r=d/h,0,1);else{let e=oZ.dot(o$);if(h<=a)r=0,i=eP(-e/c,0,1);else{let t=oZ.dot(oJ),n=c*h-t*t;i=0!==n?eP((t*d-e*h)/n,0,1):0,(r=(t*i+d)/h)<0?(r=0,i=eP(-e/c,0,1)):r>1&&(r=1,i=eP((t-e)/c,0,1))}}return t.copy(s).add(oZ.multiplyScalar(i)),n.copy(o).add(oJ.multiplyScalar(r)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}let o1=new ez;class o2 extends tK{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new nO,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){const n=e/32*Math.PI*2,r=t/32*Math.PI*2;i.push(Math.cos(n),Math.sin(n),1,Math.cos(r),Math.sin(r),1)}n.setAttribute("position",new nC(i,3));const r=new rv({fog:!1,toneMapped:!1});this.cone=new rR(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),o1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(o1),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}let o3=new ez,o4=new tT,o5=new tT;class o6 extends rR{constructor(e){const t=function e(t){let n=[];!0===t.isBone&&n.push(t);for(let i=0;i<t.children.length;i++)n.push(...e(t.children[i]));return n}(e),n=new nO,i=[],r=[];for(let e=0;e<t.length;e++){const n=t[e];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}n.setAttribute("position",new nC(i,3)),n.setAttribute("color",new nC(r,3)),super(n,new rv({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const a=new no(255),s=new no(65280);this.setColors(a,s)}updateMatrixWorld(e){let t=this.bones,n=this.geometry,i=n.getAttribute("position");o5.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){let r=t[e];r.parent&&r.parent.isBone&&(o4.multiplyMatrices(o5,r.matrixWorld),o3.setFromMatrixPosition(o4),i.setXYZ(n,o3.x,o3.y,o3.z),o4.multiplyMatrices(o5,r.parent.matrixWorld),o3.setFromMatrixPosition(o4),i.setXYZ(n+1,o3.x,o3.y,o3.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){let n=this.geometry.getAttribute("color");for(let i=0;i<n.count;i+=2)n.setXYZ(i,e.r,e.g,e.b),n.setXYZ(i+1,t.r,t.g,t.b);return n.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class o8 extends nY{constructor(e,t,n){super(new aX(t,4,2),new nh({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}let o9=new ez,o7=new no,le=new no;class lt extends tK{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new aH(t);i.rotateY(.5*Math.PI),this.material=new nh({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=new Float32Array(3*i.getAttribute("position").count);i.setAttribute("color",new ny(r,3)),this.add(new nY(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");o7.copy(this.light.color),le.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){let i=e<n/2?o7:le;t.setXYZ(e,i.r,i.g,i.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(o9.setFromMatrixPosition(this.light.matrixWorld).negate())}}class ln extends rR{constructor(e=10,t=10,n=4473924,i=8947848){n=new no(n),i=new no(i);const r=t/2,a=e/t,s=e/2,o=[],l=[];for(let e=0,u=0,c=-s;e<=t;e++,c+=a){o.push(-s,0,c,s,0,c),o.push(c,0,-s,c,0,s);const t=e===r?n:i;t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3,t.toArray(l,u),u+=3}const u=new nO;u.setAttribute("position",new nC(o,3)),u.setAttribute("color",new nC(l,3)),super(u,new rv({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class li extends rR{constructor(e=10,t=16,n=8,i=64,r=4473924,a=8947848){r=new no(r),a=new no(a);const s=[],o=[];if(t>1)for(let n=0;n<t;n++){const i=n/t*(2*Math.PI),l=Math.sin(i)*e,u=Math.cos(i)*e;s.push(0,0,0),s.push(l,0,u);const c=1&n?r:a;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let t=0;t<n;t++){const l=1&t?r:a,u=e-e/n*t;for(let e=0;e<i;e++){let t=e/i*(2*Math.PI),n=Math.sin(t)*u,r=Math.cos(t)*u;s.push(n,0,r),o.push(l.r,l.g,l.b),n=Math.sin(t=(e+1)/i*(2*Math.PI))*u,r=Math.cos(t)*u,s.push(n,0,r),o.push(l.r,l.g,l.b)}}const l=new nO;l.setAttribute("position",new nC(s,3)),l.setAttribute("color",new nC(o,3)),super(l,new rv({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}let lr=new ez,la=new ez,ls=new ez;class lo extends tK{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===t&&(t=1);let i=new nO;i.setAttribute("position",new nC([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new rv({fog:!1,toneMapped:!1});this.lightPlane=new rT(i,r),this.add(this.lightPlane),(i=new nO).setAttribute("position",new nC([0,0,0,0,0,1],3)),this.targetLine=new rT(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),lr.setFromMatrixPosition(this.light.matrixWorld),la.setFromMatrixPosition(this.light.target.matrixWorld),ls.subVectors(la,lr),this.lightPlane.lookAt(la),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(la),this.targetLine.scale.z=ls.length()}}let ll=new ez,lu=new n2;class lc extends rR{constructor(e){const t=new nO,n=new rv({color:0xffffff,vertexColors:!0,toneMapped:!1}),i=[],r=[],a={};function s(e,t){o(e),o(t)}function o(e){i.push(0,0,0),r.push(0,0,0),void 0===a[e]&&(a[e]=[]),a[e].push(i.length/3-1)}s("n1","n2"),s("n2","n4"),s("n4","n3"),s("n3","n1"),s("f1","f2"),s("f2","f4"),s("f4","f3"),s("f3","f1"),s("n1","f1"),s("n2","f2"),s("n3","f3"),s("n4","f4"),s("p","n1"),s("p","n2"),s("p","n3"),s("p","n4"),s("u1","u2"),s("u2","u3"),s("u3","u1"),s("c","t"),s("p","c"),s("cn1","cn2"),s("cn3","cn4"),s("cf1","cf2"),s("cf3","cf4"),t.setAttribute("position",new nC(i,3)),t.setAttribute("color",new nC(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const l=new no(0xffaa00),u=new no(0xff0000),c=new no(43775),h=new no(0xffffff),d=new no(3355443);this.setColors(l,u,c,h,d)}setColors(e,t,n,i,r){let a=this.geometry.getAttribute("color");return a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0,this}update(){let e,t,n=this.geometry,i=this.pointMap;if(lu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)e=1,t=0;else if(2e3===this.camera.coordinateSystem)e=-1,t=1;else if(2001===this.camera.coordinateSystem)e=0,t=1;else throw Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);lh("c",i,n,lu,0,0,e),lh("t",i,n,lu,0,0,t),lh("n1",i,n,lu,-1,-1,e),lh("n2",i,n,lu,1,-1,e),lh("n3",i,n,lu,-1,1,e),lh("n4",i,n,lu,1,1,e),lh("f1",i,n,lu,-1,-1,t),lh("f2",i,n,lu,1,-1,t),lh("f3",i,n,lu,-1,1,t),lh("f4",i,n,lu,1,1,t),lh("u1",i,n,lu,.7,1.1,e),lh("u2",i,n,lu,-.7,1.1,e),lh("u3",i,n,lu,0,2,e),lh("cf1",i,n,lu,-1,0,t),lh("cf2",i,n,lu,1,0,t),lh("cf3",i,n,lu,0,-1,t),lh("cf4",i,n,lu,0,1,t),lh("cn1",i,n,lu,-1,0,e),lh("cn2",i,n,lu,1,0,e),lh("cn3",i,n,lu,0,-1,e),lh("cn4",i,n,lu,0,1,e),n.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function lh(e,t,n,i,r,a,s){ll.set(r,a,s).unproject(i);let o=t[e];if(void 0!==o){let e=n.getAttribute("position");for(let t=0,n=o.length;t<n;t++)e.setXYZ(o[t],ll.x,ll.y,ll.z)}}let ld=new e9;class lp extends rR{constructor(e,t=0xffff00){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new nO;r.setIndex(new ny(n,1)),r.setAttribute("position",new ny(i,3)),super(r,new rv({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&ld.setFromObject(this.object),ld.isEmpty())return;let e=ld.min,t=ld.max,n=this.geometry.attributes.position,i=n.array;i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class lf extends rR{constructor(e,t=0xffff00){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new nO;i.setIndex(new ny(n,1)),i.setAttribute("position",new nC([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new rv({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class lm extends rT{constructor(e,t=1,n=0xffff00){const i=new nO;i.setAttribute("position",new nC([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),i.computeBoundingSphere(),super(i,new rv({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const r=new nO;r.setAttribute("position",new nC([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new nY(r,new nh({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}let lg=new ez;class lv extends tK{constructor(e=new ez(0,0,1),t=new ez(0,0,0),n=1,i=0xffff00,s=.2*n,o=.2*s){super(),this.type="ArrowHelper",void 0===r&&((r=new nO).setAttribute("position",new nC([0,0,0,0,1,0],3)),(a=new r$(.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new rT(r,new rv({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new nY(a,new nh({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{lg.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(lg,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class lx extends rR{constructor(e=1){const t=new nO;t.setAttribute("position",new nC([0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],3)),t.setAttribute("color",new nC([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(t,new rv({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){let i=new no,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class ly{constructor(){this.type="ShapePath",this.color=new no,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ag,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){let t,n,i,r,a,s=aU.isClockWise,o=this.subPaths;if(0===o.length)return[];let l=[];if(1===o.length)return n=o[0],(i=new av).curves=n.curves,l.push(i),l;let u=!s(o[0].getPoints());u=e?!u:u;let c=[],h=[],d=[],p=0;h[0]=void 0,d[p]=[];for(let i=0,a=o.length;i<a;i++)t=s(r=(n=o[i]).getPoints()),(t=e?!t:t)?(!u&&h[p]&&p++,h[p]={s:new av,p:r},h[p].s.curves=n.curves,u&&p++,d[p]=[]):d[p].push({h:n,p:r[0]});if(!h[0])return function(e){let t=[];for(let n=0,i=e.length;n<i;n++){let i=e[n],r=new av;r.curves=i.curves,t.push(r)}return t}(o);if(h.length>1){let e=!1,t=0;for(let e=0,t=h.length;e<t;e++)c[e]=[];for(let n=0,i=h.length;n<i;n++){let i=d[n];for(let r=0;r<i.length;r++){let a=i[r],s=!0;for(let i=0;i<h.length;i++)(function(e,t){let n=t.length,i=!1;for(let r=n-1,a=0;a<n;r=a++){let n=t[r],s=t[a],o=s.x-n.x,l=s.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[a],o=-o,s=t[r],l=-l),e.y<n.y||e.y>s.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return i})(a.p,h[i].p)&&(n!==i&&t++,s?(s=!1,c[i].push(a)):e=!0);s&&c[n].push(a)}}t>0&&!1===e&&(d=c)}for(let e=0,t=h.length;e<t;e++){i=h[e].s,l.push(i),a=d[e];for(let e=0,t=a.length;e<t;e++)i.holes.push(a[e].h)}return l}}class l_ extends ew{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){void 0===e?eb("Controls: connect() now requires an element."):(null!==this.domElement&&this.disconnect(),this.domElement=e)}disconnect(){}dispose(){}update(){}}function lb(e,t,n,i){let r=function(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`Unknown texture type ${e}.`)}(i);switch(n){case 1021:return e*t;case 1028:case 1029:return e*t/r.components*r.byteLength;case 1030:case 1031:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case 1023:case 1033:return e*t*4/r.components*r.byteLength;case 33776:case 33777:case 36196:case 37492:case 37488:case 37489:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case 33778:case 33779:case 37496:case 37490:case 37491:case 37808:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case 35841:case 35843:return Math.max(e,16)*Math.max(t,8)/4;case 35840:case 35842:return Math.max(e,8)*Math.max(t,8)/2;case 37809:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case 37810:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case 37811:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case 37812:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case 37813:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case 37814:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case 37815:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case 37816:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case 37817:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case 37818:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case 37819:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case 37820:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case 37821:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case 36492:case 36494:case 36495:case 36285:case 36286:return Math.ceil(e/4)*Math.ceil(t/4)*16;case 36283:case 36284:return Math.ceil(e/4)*Math.ceil(t/4)*8}throw Error(`Unable to determine texture byte length for ${n} format.`)}class lS{static contain(e,t){let n;return(n=e.image&&e.image.width?e.image.width/e.image.height:1)>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}static cover(e,t){let n;return(n=e.image&&e.image.width?e.image.width/e.image.height:1)>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}static fill(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}static getByteLength(e,t,n,i){return lb(e,t,n,i)}}function lM(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0===t||null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function lw(e){let t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);let i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){let e=t.get(n);(!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version});return}let r=t.get(n);if(void 0===r)t.set(n,function(t,n){let i,r=t.array,a=t.usage,s=r.byteLength,o=e.createBuffer();if(e.bindBuffer(n,o),e.bufferData(n,r,a),t.onUploadCallback(),r instanceof Float32Array)i=e.FLOAT;else if("u">typeof Float16Array&&r instanceof Float16Array)i=e.HALF_FLOAT;else if(r instanceof Uint16Array)i=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)i=e.SHORT;else if(r instanceof Uint32Array)i=e.UNSIGNED_INT;else if(r instanceof Int32Array)i=e.INT;else if(r instanceof Int8Array)i=e.BYTE;else if(r instanceof Uint8Array)i=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)i=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);return{buffer:o,type:i,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:s}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,n,i){let r=n.array,a=n.updateRanges;if(e.bindBuffer(i,t),0===a.length)e.bufferSubData(i,0,r);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){let n=a[t],i=a[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):a[++t]=i}a.length=t+1;for(let t=0,n=a.length;t<n;t++){let n=a[t];e.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"182"}})),"u">typeof window&&(window.__THREE__?eb("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="182");let lT={alphahash_fragment:"#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n const float ALPHA_HASH_SCALE = 0.05;\n float hash2D( vec2 value ) {\n return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n }\n float hash3D( vec3 value ) {\n return hash2D( vec2( hash2D( value.xy ), value.z ) );\n }\n float getAlphaHashThreshold( vec3 position ) {\n float maxDeriv = max(\n length( dFdx( position.xyz ) ),\n length( dFdy( position.xyz ) )\n );\n float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n vec2 pixScales = vec2(\n exp2( floor( log2( pixScale ) ) ),\n exp2( ceil( log2( pixScale ) ) )\n );\n vec2 alpha = vec2(\n hash3D( floor( pixScales.x * position.xyz ) ),\n hash3D( floor( pixScales.y * position.xyz ) )\n );\n float lerpFactor = fract( log2( pixScale ) );\n float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n float a = min( lerpFactor, 1.0 - lerpFactor );\n vec3 cases = vec3(\n x * x / ( 2.0 * a * ( 1.0 - a ) ),\n ( x - 0.5 * a ) / ( 1.0 - a ),\n 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n );\n float threshold = ( x < ( 1.0 - a ) )\n ? ( ( x < a ) ? cases.x : cases.y )\n : cases.z;\n return clamp( threshold , 1.0e-6, 1.0 );\n }\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n #ifdef ALPHA_TO_COVERAGE\n diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n if ( diffuseColor.a < alphaTest ) discard;\n #endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n uniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n #endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n #if ! defined( GL_ANGLE_multi_draw )\n #define gl_DrawID _gl_DrawID\n uniform int _gl_DrawID;\n #endif\n uniform highp sampler2D batchingTexture;\n uniform highp usampler2D batchingIdTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n float getIndirectIndex( const in int i ) {\n int size = textureSize( batchingIdTexture, 0 ).x;\n int x = i % size;\n int y = i / size;\n return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n }\n#endif\n#ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec3 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n }\n#endif",batching_vertex:"#ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n vPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( specularColor, 1.0, dotVH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n const mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n );\n vec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n }\n vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n }\n float IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n }\n vec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n xyz /= 1.0685e-7;\n vec3 rgb = XYZ_TO_REC709 * xyz;\n return rgb;\n }\n vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++ m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n }\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vBumpMapUv );\n vec2 dSTdy = dFdy( vBumpMapUv );\n float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#elif defined( USE_COLOR )\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR )\n varying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n vColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, dp );\n #else\n shadow = step( dp, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <logdepthbuf_fragment>\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n vWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vLineDistance = scale * lineDistance;\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include <aomap_fragment>\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_lambert_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n vViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include <transmission_fragment>\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_toon_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n #include <logdepthbuf_fragment>\n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n}"},lE={common:{diffuse:{value:new no(0xffffff)},opacity:{value:1},map:{value:null},mapTransform:{value:new eV},alphaMap:{value:null},alphaMapTransform:{value:new eV},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new eV}},envmap:{envMap:{value:null},envMapRotation:{value:new eV},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new eV}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new eV}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new eV},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new eV},normalScale:{value:new eO(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new eV},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new eV}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new eV}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new eV}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new no(0xffffff)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new no(0xffffff)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new eV},alphaTest:{value:0},uvTransform:{value:new eV}},sprite:{diffuse:{value:new no(0xffffff)},opacity:{value:1},center:{value:new eO(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new eV},alphaMap:{value:null},alphaMapTransform:{value:new eV},alphaTest:{value:0}}},lA={basic:{uniforms:nK([lE.common,lE.specularmap,lE.envmap,lE.aomap,lE.lightmap,lE.fog]),vertexShader:lT.meshbasic_vert,fragmentShader:lT.meshbasic_frag},lambert:{uniforms:nK([lE.common,lE.specularmap,lE.envmap,lE.aomap,lE.lightmap,lE.emissivemap,lE.bumpmap,lE.normalmap,lE.displacementmap,lE.fog,lE.lights,{emissive:{value:new no(0)}}]),vertexShader:lT.meshlambert_vert,fragmentShader:lT.meshlambert_frag},phong:{uniforms:nK([lE.common,lE.specularmap,lE.envmap,lE.aomap,lE.lightmap,lE.emissivemap,lE.bumpmap,lE.normalmap,lE.displacementmap,lE.fog,lE.lights,{emissive:{value:new no(0)},specular:{value:new no(1118481)},shininess:{value:30}}]),vertexShader:lT.meshphong_vert,fragmentShader:lT.meshphong_frag},standard:{uniforms:nK([lE.common,lE.envmap,lE.aomap,lE.lightmap,lE.emissivemap,lE.bumpmap,lE.normalmap,lE.displacementmap,lE.roughnessmap,lE.metalnessmap,lE.fog,lE.lights,{emissive:{value:new no(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lT.meshphysical_vert,fragmentShader:lT.meshphysical_frag},toon:{uniforms:nK([lE.common,lE.aomap,lE.lightmap,lE.emissivemap,lE.bumpmap,lE.normalmap,lE.displacementmap,lE.gradientmap,lE.fog,lE.lights,{emissive:{value:new no(0)}}]),vertexShader:lT.meshtoon_vert,fragmentShader:lT.meshtoon_frag},matcap:{uniforms:nK([lE.common,lE.bumpmap,lE.normalmap,lE.displacementmap,lE.fog,{matcap:{value:null}}]),vertexShader:lT.meshmatcap_vert,fragmentShader:lT.meshmatcap_frag},points:{uniforms:nK([lE.points,lE.fog]),vertexShader:lT.points_vert,fragmentShader:lT.points_frag},dashed:{uniforms:nK([lE.common,lE.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lT.linedashed_vert,fragmentShader:lT.linedashed_frag},depth:{uniforms:nK([lE.common,lE.displacementmap]),vertexShader:lT.depth_vert,fragmentShader:lT.depth_frag},normal:{uniforms:nK([lE.common,lE.bumpmap,lE.normalmap,lE.displacementmap,{opacity:{value:1}}]),vertexShader:lT.meshnormal_vert,fragmentShader:lT.meshnormal_frag},sprite:{uniforms:nK([lE.sprite,lE.fog]),vertexShader:lT.sprite_vert,fragmentShader:lT.sprite_frag},background:{uniforms:{uvTransform:{value:new eV},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:lT.background_vert,fragmentShader:lT.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new eV}},vertexShader:lT.backgroundCube_vert,fragmentShader:lT.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:lT.cube_vert,fragmentShader:lT.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lT.equirect_vert,fragmentShader:lT.equirect_frag},distance:{uniforms:nK([lE.common,lE.displacementmap,{referencePosition:{value:new ez},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lT.distance_vert,fragmentShader:lT.distance_frag},shadow:{uniforms:nK([lE.lights,lE.fog,{color:{value:new no(0)},opacity:{value:1}}]),vertexShader:lT.shadow_vert,fragmentShader:lT.shadow_frag}};lA.physical={uniforms:nK([lA.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new eV},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new eV},clearcoatNormalScale:{value:new eO(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new eV},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new eV},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new eV},sheen:{value:0},sheenColor:{value:new no(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new eV},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new eV},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new eV},transmissionSamplerSize:{value:new eO},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new eV},attenuationDistance:{value:0},attenuationColor:{value:new no(0)},specularColor:{value:new no(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new eV},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new eV},anisotropyVector:{value:new eO},anisotropyMap:{value:null},anisotropyMapTransform:{value:new eV}}]),vertexShader:lT.meshphysical_vert,fragmentShader:lT.meshphysical_frag};let lC={r:0,b:0,g:0},lR=new tU,lP=new tT;function lI(e,t,n,i,r,a,s){let o,l,u=new no(0),c=+(!0!==a),h=null,d=0,p=null;function f(e){let i=!0===e.isScene?e.background:null;return i&&i.isTexture&&(i=(e.backgroundBlurriness>0?n:t).get(i)),i}function m(t,n){t.getRGB(lC,nQ(e)),i.buffers.color.setClear(lC.r,lC.g,lC.b,n,s)}return{getClearColor:function(){return u},setClearColor:function(e,t=1){u.set(e),m(u,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){m(u,c=e)},render:function(t){let n=!1,r=f(t);null===r?m(u,c):r&&r.isColor&&(m(r,1),n=!0);let a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){let i=f(n);i&&(i.isCubeTexture||306===i.mapping)?(void 0===l&&((l=new nY(new nJ(1,1,1),new n1({name:"BackgroundCubeMaterial",uniforms:n$(lA.backgroundCube.uniforms),vertexShader:lA.backgroundCube.vertexShader,fragmentShader:lA.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),lR.copy(n.backgroundRotation),lR.x*=-1,lR.y*=-1,lR.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(lR.y*=-1,lR.z*=-1),l.material.uniforms.envMap.value=i,l.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(lP.makeRotationFromEuler(lR)),l.material.toneMapped=eW.getTransfer(i.colorSpace)!==ea,(h!==i||d!==i.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,h=i,d=i.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(void 0===o&&((o=new nY(new aj(2,2),new n1({name:"BackgroundMaterial",uniforms:n$(lA.background.uniforms),vertexShader:lA.background.vertexShader,fragmentShader:lA.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(o)),o.material.uniforms.t2D.value=i,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=eW.getTransfer(i.colorSpace)!==ea,!0===i.matrixAutoUpdate&&i.updateMatrix(),o.material.uniforms.uvTransform.value.copy(i.matrix),(h!==i||d!==i.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,h=i,d=i.version,p=e.toneMapping),o.layers.enableAll(),t.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function lL(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=u(null),a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function u(e){let t=[],i=[],r=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function c(){let e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function h(e){d(e,0)}function d(t,n){let i=a.newAttributes,r=a.enabledAttributes,s=a.attributeDivisors;i[t]=1,0===r[t]&&(e.enableVertexAttribArray(t),r[t]=1),s[t]!==n&&(e.vertexAttribDivisor(t,n),s[t]=n)}function p(){let t=a.newAttributes,n=a.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function f(t,n,i,r,a,s,o){!0===o?e.vertexAttribIPointer(t,n,i,a,s):e.vertexAttribPointer(t,n,i,r,a,s)}function m(){g(),s=!0,a!==r&&o((a=r).object)}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){var v,x;let y,_,b,S,M=!1,w=(v=m,x=l,y=!0===r.wireframe,void 0===(_=i[v.id])&&(_={},i[v.id]=_),void 0===(b=_[x.id])&&(b={},_[x.id]=b),void 0===(S=b[y])&&(S=u(e.createVertexArray()),b[y]=S),S);a!==w&&o((a=w).object),(M=function(e,t,n,i){let r=a.attributes,s=t.attributes,o=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=r[t],i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n||n.attribute!==i||i&&n.data!==i.data)return!0;o++}return a.attributesNum!==o||a.index!==i}(n,m,l,g))&&function(e,t,n,i){let r={},s=t.attributes,o=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));let i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(M||s)&&(s=!1,function(n,i,r,a){c();let s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(let i in o){let r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){let i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;let u=l.buffer,c=l.type,p=l.bytesPerElement,m=c===e.INT||c===e.UNSIGNED_INT||1013===o.gpuType;if(o.isInterleavedBufferAttribute){let t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)d(r.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<r.locationSize;e++)f(r.location+e,s/r.locationSize,c,i,l*p,(g+s/r.locationSize*e)*p,m)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)d(r.location+e,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)h(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<r.locationSize;e++)f(r.location+e,s/r.locationSize,c,i,s*p,s/r.locationSize*e*p,m)}}else if(void 0!==l){let t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}p()}(n,r,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){for(let e in m(),i){let t=i[e];for(let e in t){let n=t[e];for(let e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;let t=i[e.id];for(let e in t){let n=t[e];for(let e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e.id]},releaseStatesOfProgram:function(e){for(let t in i){let n=i[t];if(void 0===n[e.id])continue;let r=n[e.id];for(let e in r)l(r[e].object),delete r[e];delete n[e.id]}},initAttributes:c,enableAttribute:h,disableUnusedAttributes:p}}function lN(e,t,n){let i;function r(t,r,a){0!==a&&(e.drawArraysInstanced(i,t,r,a),n.update(r,i,a))}this.setMode=function(e){i=e},this.render=function(t,r){e.drawArrays(i,t,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(e,r,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,r,0,a);let s=0;for(let e=0;e<a;e++)s+=r[e];n.update(s,i,1)},this.renderMultiDrawInstances=function(e,a,s,o){if(0===s)return;let l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)r(e[t],a[t],o[t]);else{l.multiDrawArraysInstancedWEBGL(i,e,0,a,0,o,0,s);let t=0;for(let e=0;e<s;e++)t+=a[e]*o[e];n.update(t,i,1)}}}function lD(e,t,n,i){let r;function a(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp",o=a(s);return o!==s&&(eb("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return 1023===t||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){let r=1016===n&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return 1009===n||i.convert(n)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n||!!r},precision:s,logarithmicDepthBuffer:!0===n.logarithmicDepthBuffer,reversedDepthBuffer:!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function lU(e){let t=this,n=null,i=0,r=!1,a=!1,s=new i2,o=new eV,l={value:null,needsUpdate:!1};function u(e,n,i,r){let a=null!==e?e.length:0,u=null;if(0!==a){if(u=l.value,!0!==r||null===u){let t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===u||u.length<t)&&(u=new Float32Array(t));for(let t=0,n=i;t!==a;++t,n+=4)s.copy(e[t]).applyMatrix4(r,o),s.normal.toArray(u,n),u[n+3]=s.constant}l.value=u,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,u}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(s,o,c){let h=s.clippingPlanes,d=s.clipIntersection,p=s.clipShadows,f=e.get(s);if(r&&null!==h&&0!==h.length&&(!a||p)){let e=a?0:i,t=4*e,r=f.clippingState||null;l.value=r,r=u(h,o,t,c);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}else a?u(null):(l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0)}}function lO(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=301:304===t&&(e.mapping=302),e}function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping;if(303===a||304===a)if(t.has(r))return n(t.get(r).texture,r.mapping);else{let a=r.image;if(!a||!(a.height>0))return null;{let s=new n7(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}}}return r},dispose:function(){t=new WeakMap}}}let lF=[.125,.215,.35,.446,.526,.582],lz=new sG,lk=new no,lB=null,lV=0,lH=0,lj=!1,lG=new ez;class lW{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){let{size:a=256,position:s=lG}=r;lB=this._renderer.getRenderTarget(),lV=this._renderer.getActiveCubeFace(),lH=this._renderer.getActiveMipmapLevel(),lj=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,s),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=lZ(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=lY(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(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(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(lB,lV,lH),this._renderer.xr.enabled=lj,e.scissorTest=!1,lq(e,0,0,e.width,e.height)}_fromTexture(e,t){301===e.mapping||302===e.mapping?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),lB=this._renderer.getRenderTarget(),lV=this._renderer.getActiveCubeFace(),lH=this._renderer.getActiveMipmapLevel(),lj=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:1006,minFilter:1006,generateMipmaps:!1,type:1016,format:1023,colorSpace:ei,depthBuffer:!1},i=lX(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){var r,a;null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=lX(e,t,n);let{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){let t=[],n=[],i=[],r=e,a=e-4+1+lF.length;for(let s=0;s<a;s++){let a=Math.pow(2,r);t.push(a);let o=1/a;s>e-4?o=lF[s-e+4-1]:0===s&&(o=0),n.push(o);let l=1/(a-2),u=-l,c=1+l,h=[u,u,c,u,c,c,u,u,c,c,u,c],d=new Float32Array(108),p=new Float32Array(72),f=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];d.set(i,18*e),p.set(h,12*e);let r=[e,e,e,e,e,e];f.set(r,6*e)}let m=new nO;m.setAttribute("position",new ny(d,3)),m.setAttribute("uv",new ny(p,2)),m.setAttribute("faceIndex",new ny(f,1)),i.push(new nY(m,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}(i)),this._blurMaterial=(r=i,new n1({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:new Float32Array(20)},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:new ez(0,1,0)}},vertexShader:lJ(),fragmentShader:`
37
+
38
+ precision mediump float;
39
+ precision mediump int;
40
+
41
+ varying vec3 vOutputDirection;
42
+
43
+ uniform sampler2D envMap;
44
+ uniform int samples;
45
+ uniform float weights[ n ];
46
+ uniform bool latitudinal;
47
+ uniform float dTheta;
48
+ uniform float mipInt;
49
+ uniform vec3 poleAxis;
50
+
51
+ #define ENVMAP_TYPE_CUBE_UV
52
+ #include <cube_uv_reflection_fragment>
53
+
54
+ vec3 getSample( float theta, vec3 axis ) {
55
+
56
+ float cosTheta = cos( theta );
57
+ // Rodrigues' axis-angle rotation
58
+ vec3 sampleDirection = vOutputDirection * cosTheta
59
+ + cross( axis, vOutputDirection ) * sin( theta )
60
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
61
+
62
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
63
+
64
+ }
65
+
66
+ void main() {
67
+
68
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
69
+
70
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
71
+
72
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
73
+
74
+ }
75
+
76
+ axis = normalize( axis );
77
+
78
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
79
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
80
+
81
+ for ( int i = 1; i < n; i++ ) {
82
+
83
+ if ( i >= samples ) {
84
+
85
+ break;
86
+
87
+ }
88
+
89
+ float theta = dTheta * float( i );
90
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
91
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
92
+
93
+ }
94
+
95
+ }
96
+ `,blending:0,depthTest:!1,depthWrite:!1})),this._ggxMaterial=(a=i,new n1({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:lJ(),fragmentShader:`
97
+
98
+ precision highp float;
99
+ precision highp int;
100
+
101
+ varying vec3 vOutputDirection;
102
+
103
+ uniform sampler2D envMap;
104
+ uniform float roughness;
105
+ uniform float mipInt;
106
+
107
+ #define ENVMAP_TYPE_CUBE_UV
108
+ #include <cube_uv_reflection_fragment>
109
+
110
+ #define PI 3.14159265359
111
+
112
+ // Van der Corput radical inverse
113
+ float radicalInverse_VdC(uint bits) {
114
+ bits = (bits << 16u) | (bits >> 16u);
115
+ bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
116
+ bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
117
+ bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
118
+ bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
119
+ return float(bits) * 2.3283064365386963e-10; // / 0x100000000
120
+ }
121
+
122
+ // Hammersley sequence
123
+ vec2 hammersley(uint i, uint N) {
124
+ return vec2(float(i) / float(N), radicalInverse_VdC(i));
125
+ }
126
+
127
+ // GGX VNDF importance sampling (Eric Heitz 2018)
128
+ // "Sampling the GGX Distribution of Visible Normals"
129
+ // https://jcgt.org/published/0007/04/01/
130
+ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
131
+ float alpha = roughness * roughness;
132
+
133
+ // Section 3.2: Transform view direction to hemisphere configuration
134
+ vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
135
+
136
+ // Section 4.1: Orthonormal basis
137
+ float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
138
+ vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
139
+ vec3 T2 = cross(Vh, T1);
140
+
141
+ // Section 4.2: Parameterization of projected area
142
+ float r = sqrt(Xi.x);
143
+ float phi = 2.0 * PI * Xi.y;
144
+ float t1 = r * cos(phi);
145
+ float t2 = r * sin(phi);
146
+ float s = 0.5 * (1.0 + Vh.z);
147
+ t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
148
+
149
+ // Section 4.3: Reprojection onto hemisphere
150
+ vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
151
+
152
+ // Section 3.4: Transform back to ellipsoid configuration
153
+ return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
154
+ }
155
+
156
+ void main() {
157
+ vec3 N = normalize(vOutputDirection);
158
+ vec3 V = N; // Assume view direction equals normal for pre-filtering
159
+
160
+ vec3 prefilteredColor = vec3(0.0);
161
+ float totalWeight = 0.0;
162
+
163
+ // For very low roughness, just sample the environment directly
164
+ if (roughness < 0.001) {
165
+ gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
166
+ return;
167
+ }
168
+
169
+ // Tangent space basis for VNDF sampling
170
+ vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
171
+ vec3 tangent = normalize(cross(up, N));
172
+ vec3 bitangent = cross(N, tangent);
173
+
174
+ for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
175
+ vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
176
+
177
+ // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
178
+ vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
179
+
180
+ // Transform H back to world space
181
+ vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
182
+ vec3 L = normalize(2.0 * dot(V, H) * H - V);
183
+
184
+ float NdotL = max(dot(N, L), 0.0);
185
+
186
+ if(NdotL > 0.0) {
187
+ // Sample environment at fixed mip level
188
+ // VNDF importance sampling handles the distribution filtering
189
+ vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
190
+
191
+ // Weight by NdotL for the split-sum approximation
192
+ // VNDF PDF naturally accounts for the visible microfacet distribution
193
+ prefilteredColor += sampleColor * NdotL;
194
+ totalWeight += NdotL;
195
+ }
196
+ }
197
+
198
+ if (totalWeight > 0.0) {
199
+ prefilteredColor = prefilteredColor / totalWeight;
200
+ }
201
+
202
+ gl_FragColor = vec4(prefilteredColor, 1.0);
203
+ }
204
+ `,blending:0,depthTest:!1,depthWrite:!1}))}return i}_compileMaterial(e){let t=new nY(new nO,e);this._renderer.compile(t,lz)}_sceneToCubeUV(e,t,n,i,r){let a=new n6(90,1,t,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,u=l.autoClear,c=l.toneMapping;l.getClearColor(lk),l.toneMapping=0,l.autoClear=!1,l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new nY(new nJ,new nh({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));let h=this._backgroundBox,d=h.material,p=!1,f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,p=!0):(d.color.copy(lk),p=!0);for(let t=0;t<6;t++){let n=t%3;0===n?(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[t],r.y,r.z)):1===n?(a.up.set(0,0,s[t]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[t],r.z)):(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[t]));let u=this._cubeSize;lq(i,n*u,t>2?u:0,u,u),l.setRenderTarget(i),p&&l.render(h,a),l.render(e,a)}l.toneMapping=c,l.autoClear=u,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,i=301===e.mapping||302===e.mapping;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=lZ()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=lY());let r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r,r.uniforms.envMap.value=e;let s=this._cubeSize;lq(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,lz)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let t=1;t<i;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,s=this._lodMeshes[n];s.material=a;let o=a.uniforms,l=n/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),c=Math.sqrt(l*l-u*u),{_lodMax:h}=this,d=this._sizeLods[n],p=3*d*(n>h-4?n-h+4:0),f=4*(this._cubeSize-d);o.envMap.value=e.texture,o.roughness.value=c*(0+1.25*l),o.mipInt.value=h-t,lq(r,p,f,3*d,2*d),i.setRenderTarget(r),i.render(s,lz),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,lq(e,p,f,3*d,2*d),i.setRenderTarget(e),i.render(s,lz)}_blur(e,t,n,i,r){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,s){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&eS("blur direction must be either latitudinal or longitudinal!");let u=this._lodMeshes[i];u.material=l;let c=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*h):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):20;f>20&&eb(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);let m=[],g=0;for(let e=0;e<20;++e){let t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<f&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;c.envMap.value=e.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===a,s&&(c.poleAxis.value=s);let{_lodMax:v}=this;c.dTheta.value=d,c.mipInt.value=v-n;let x=this._sizeLods[i],y=4*(this._cubeSize-x);lq(t,3*x*(i>v-4?i-v+4:0),y,3*x,2*x),o.setRenderTarget(t),o.render(u,lz)}}function lX(e,t,n){let i=new e3(e,t,n);return i.texture.mapping=306,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function lq(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function lY(){return new n1({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:lJ(),fragmentShader:`
205
+
206
+ precision mediump float;
207
+ precision mediump int;
208
+
209
+ varying vec3 vOutputDirection;
210
+
211
+ uniform sampler2D envMap;
212
+
213
+ #include <common>
214
+
215
+ void main() {
216
+
217
+ vec3 outputDirection = normalize( vOutputDirection );
218
+ vec2 uv = equirectUv( outputDirection );
219
+
220
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
221
+
222
+ }
223
+ `,blending:0,depthTest:!1,depthWrite:!1})}function lZ(){return new n1({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:lJ(),fragmentShader:`
224
+
225
+ precision mediump float;
226
+ precision mediump int;
227
+
228
+ uniform float flipEnvMap;
229
+
230
+ varying vec3 vOutputDirection;
231
+
232
+ uniform samplerCube envMap;
233
+
234
+ void main() {
235
+
236
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
237
+
238
+ }
239
+ `,blending:0,depthTest:!1,depthWrite:!1})}function lJ(){return`
240
+
241
+ precision mediump float;
242
+ precision mediump int;
243
+
244
+ attribute float faceIndex;
245
+
246
+ varying vec3 vOutputDirection;
247
+
248
+ // RH coordinate system; PMREM face-indexing convention
249
+ vec3 getDirection( vec2 uv, float face ) {
250
+
251
+ uv = 2.0 * uv - 1.0;
252
+
253
+ vec3 direction = vec3( uv, 1.0 );
254
+
255
+ if ( face == 0.0 ) {
256
+
257
+ direction = direction.zyx; // ( 1, v, u ) pos x
258
+
259
+ } else if ( face == 1.0 ) {
260
+
261
+ direction = direction.xzy;
262
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
263
+
264
+ } else if ( face == 2.0 ) {
265
+
266
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
267
+
268
+ } else if ( face == 3.0 ) {
269
+
270
+ direction = direction.zyx;
271
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
272
+
273
+ } else if ( face == 4.0 ) {
274
+
275
+ direction = direction.xzy;
276
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
277
+
278
+ } else if ( face == 5.0 ) {
279
+
280
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
281
+
282
+ }
283
+
284
+ return direction;
285
+
286
+ }
287
+
288
+ void main() {
289
+
290
+ vOutputDirection = getDirection( uv, faceIndex );
291
+ gl_Position = vec4( position, 1.0 );
292
+
293
+ }
294
+ `}function l$(e){let t=new WeakMap,n=null;function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping,s=303===a||304===a,o=301===a||302===a;if(s||o){let a=t.get(r),l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new lW(e)),(a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a)).texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;{if(void 0!==a)return a.texture;let l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(l)?(null===n&&(n=new lW(e)),(a=s?n.fromEquirectangular(r):n.fromCubemap(r)).texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function lK(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){let t=n(e);return null===t&&eM("WebGLRenderer: "+e+" extension not supported."),t}}}function lQ(e,t,n,i){let r={},a=new WeakMap;function s(e){let o=e.target;for(let e in null!==o.index&&t.remove(o.index),o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete r[o.id];let l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){let n=[],i=e.index,r=e.attributes.position,s=0;if(null!==i){let e=i.array;s=i.version;for(let t=0,i=e.length;t<i;t+=3){let i=e[t+0],r=e[t+1],a=e[t+2];n.push(i,r,r,a,a,i)}}else{if(void 0===r)return;let e=r.array;s=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){let e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}let o=new(ec(n)?nE:nw)(n,1);o.version=s;let l=a.get(e);l&&t.remove(l),a.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",s),r[t.id]=!0,n.memory.geometries++),t},update:function(n){let i=n.attributes;for(let n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){let t=a.get(e);if(t){let n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return a.get(e)}}}function l0(e,t,n){let i,r,a;function s(t,s,o){0!==o&&(e.drawElementsInstanced(i,s,r,t*a,o),n.update(s,i,o))}this.setMode=function(e){i=e},this.setIndex=function(e){r=e.type,a=e.bytesPerElement},this.render=function(t,s){e.drawElements(i,s,r,t*a),n.update(s,i,1)},this.renderInstances=s,this.renderMultiDraw=function(e,a,s){if(0===s)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,e,0,s);let o=0;for(let e=0;e<s;e++)o+=a[e];n.update(o,i,1)},this.renderMultiDrawInstances=function(e,o,l,u){if(0===l)return;let c=t.get("WEBGL_multi_draw");if(null===c)for(let t=0;t<e.length;t++)s(e[t]/a,o[t],u[t]);else{c.multiDrawElementsInstancedWEBGL(i,o,0,r,e,0,u,0,l);let t=0;for(let e=0;e<l;e++)t+=o[e]*u[e];n.update(t,i,1)}}}function l1(e){let t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=n/3*r;break;case e.LINES:t.lines+=n/2*r;break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:eS("WebGLInfo: Unknown draw mode:",i)}}}}function l2(e,t,n){let i=new WeakMap,r=new e1;return{update:function(a,s,o){let l=a.morphTargetInfluences,u=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,c=void 0!==u?u.length:0,h=i.get(s);if(void 0===h||h.count!==c){void 0!==h&&h.texture.dispose();let e=void 0!==s.morphAttributes.position,n=void 0!==s.morphAttributes.normal,a=void 0!==s.morphAttributes.color,o=s.morphAttributes.position||[],l=s.morphAttributes.normal||[],u=s.morphAttributes.color||[],d=0;!0===e&&(d=1),!0===n&&(d=2),!0===a&&(d=3);let p=s.attributes.position.count*d,f=1;p>t.maxTextureSize&&(f=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let m=new Float32Array(p*f*4*c),g=new e4(m,p,f,c);g.type=1015,g.needsUpdate=!0;let v=4*d;for(let t=0;t<c;t++){let i=o[t],s=l[t],c=u[t],h=p*f*4*t;for(let t=0;t<i.count;t++){let o=t*v;!0===e&&(r.fromBufferAttribute(i,t),m[h+o+0]=r.x,m[h+o+1]=r.y,m[h+o+2]=r.z,m[h+o+3]=0),!0===n&&(r.fromBufferAttribute(s,t),m[h+o+4]=r.x,m[h+o+5]=r.y,m[h+o+6]=r.z,m[h+o+7]=0),!0===a&&(r.fromBufferAttribute(c,t),m[h+o+8]=r.x,m[h+o+9]=r.y,m[h+o+10]=r.z,m[h+o+11]=4===c.itemSize?r.w:1)}}h={count:c,texture:g,size:new eO(p,f)},i.set(s,h),s.addEventListener("dispose",function e(){g.dispose(),i.delete(s),s.removeEventListener("dispose",e)})}if(!0===a.isInstancedMesh&&null!==a.morphTexture)o.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let t=0;for(let e=0;e<l.length;e++)t+=l[e];let n=s.morphTargetsRelative?1:1-t;o.getUniforms().setValue(e,"morphTargetBaseInfluence",n),o.getUniforms().setValue(e,"morphTargetInfluences",l)}o.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),o.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}}}function l3(e,t,n,i){let r=new WeakMap;function a(e){let t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(s){let o=i.render.frame,l=s.geometry,u=t.get(s,l);if(r.get(u)!==o&&(t.update(u),r.set(u,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),r.get(s)!==o&&(n.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,e.ARRAY_BUFFER),r.set(s,o))),s.isSkinnedMesh){let e=s.skeleton;r.get(e)!==o&&(e.update(),r.set(e,o))}return u},dispose:function(){r=new WeakMap}}}let l4={1:"LINEAR_TONE_MAPPING",2:"REINHARD_TONE_MAPPING",3:"CINEON_TONE_MAPPING",4:"ACES_FILMIC_TONE_MAPPING",6:"AGX_TONE_MAPPING",7:"NEUTRAL_TONE_MAPPING",5:"CUSTOM_TONE_MAPPING"};function l5(e,t,n,i,r){let a,s=new e3(t,n,{type:e,depthBuffer:i,stencilBuffer:r}),o=new e3(t,n,{type:1016,depthBuffer:!1,stencilBuffer:!1}),l=new nO;l.setAttribute("position",new nC([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new nC([0,2,0,0,2,0],2));let u=new a1({uniforms:{tDiffuse:{value:null}},vertexShader:`
295
+ precision highp float;
296
+
297
+ uniform mat4 modelViewMatrix;
298
+ uniform mat4 projectionMatrix;
299
+
300
+ attribute vec3 position;
301
+ attribute vec2 uv;
302
+
303
+ varying vec2 vUv;
304
+
305
+ void main() {
306
+ vUv = uv;
307
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
308
+ }`,fragmentShader:`
309
+ precision highp float;
310
+
311
+ uniform sampler2D tDiffuse;
312
+
313
+ varying vec2 vUv;
314
+
315
+ #include <tonemapping_pars_fragment>
316
+ #include <colorspace_pars_fragment>
317
+
318
+ void main() {
319
+ gl_FragColor = texture2D( tDiffuse, vUv );
320
+
321
+ #ifdef LINEAR_TONE_MAPPING
322
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
323
+ #elif defined( REINHARD_TONE_MAPPING )
324
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
325
+ #elif defined( CINEON_TONE_MAPPING )
326
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
327
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
328
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
329
+ #elif defined( AGX_TONE_MAPPING )
330
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
331
+ #elif defined( NEUTRAL_TONE_MAPPING )
332
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
333
+ #elif defined( CUSTOM_TONE_MAPPING )
334
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
335
+ #endif
336
+
337
+ #ifdef SRGB_TRANSFER
338
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
339
+ #endif
340
+ }`,depthTest:!1,depthWrite:!1}),c=new nY(l,u),h=new sG(-1,1,1,-1,0,1),d=null,p=null,f=!1,m=null,g=[],v=!1;this.setSize=function(e,t){s.setSize(e,t),o.setSize(e,t);for(let n=0;n<g.length;n++){let i=g[n];i.setSize&&i.setSize(e,t)}},this.setEffects=function(e){v=(g=e).length>0&&!0===g[0].isRenderPass;let t=s.width,n=s.height;for(let e=0;e<g.length;e++){let i=g[e];i.setSize&&i.setSize(t,n)}},this.begin=function(e,t){if(f||0===e.toneMapping&&0===g.length)return!1;if(m=t,null!==t){let e=t.width,n=t.height;(s.width!==e||s.height!==n)&&this.setSize(e,n)}return!1===v&&e.setRenderTarget(s),a=e.toneMapping,e.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(e,t){e.toneMapping=a,f=!0;let n=s,i=o;for(let r=0;r<g.length;r++){let a=g[r];if(!1!==a.enabled&&(a.render(e,i,n,t),!1!==a.needsSwap)){let e=n;n=i,i=e}}if(d!==e.outputColorSpace||p!==e.toneMapping){d=e.outputColorSpace,p=e.toneMapping,u.defines={},eW.getTransfer(d)===ea&&(u.defines.SRGB_TRANSFER="");let t=l4[p];t&&(u.defines[t]=""),u.needsUpdate=!0}u.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(m),e.render(c,h),m=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){s.dispose(),o.dispose(),l.dispose(),u.dispose()}}let l6=new e0,l8=new rW(1,1),l9=new e4,l7=new e6,ue=new n9,ut=[],un=[],ui=new Float32Array(16),ur=new Float32Array(9),ua=new Float32Array(4);function us(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,a=ut[r];if(void 0===a&&(a=new Float32Array(r),ut[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function uo(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function ul(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function uu(e,t){let n=un[t];void 0===n&&(n=new Int32Array(t),un[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function uc(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function uh(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(uo(n,t))return;e.uniform2fv(this.addr,t),ul(n,t)}}function ud(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(uo(n,t))return;e.uniform3fv(this.addr,t),ul(n,t)}}function up(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(uo(n,t))return;e.uniform4fv(this.addr,t),ul(n,t)}}function uf(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(uo(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),ul(n,t)}else{if(uo(n,i))return;ua.set(i),e.uniformMatrix2fv(this.addr,!1,ua),ul(n,i)}}function um(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(uo(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),ul(n,t)}else{if(uo(n,i))return;ur.set(i),e.uniformMatrix3fv(this.addr,!1,ur),ul(n,i)}}function ug(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(uo(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),ul(n,t)}else{if(uo(n,i))return;ui.set(i),e.uniformMatrix4fv(this.addr,!1,ui),ul(n,i)}}function uv(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function ux(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(uo(n,t))return;e.uniform2iv(this.addr,t),ul(n,t)}}function uy(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(uo(n,t))return;e.uniform3iv(this.addr,t),ul(n,t)}}function u_(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(uo(n,t))return;e.uniform4iv(this.addr,t),ul(n,t)}}function ub(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function uS(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(uo(n,t))return;e.uniform2uiv(this.addr,t),ul(n,t)}}function uM(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(uo(n,t))return;e.uniform3uiv(this.addr,t),ul(n,t)}}function uw(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(uo(n,t))return;e.uniform4uiv(this.addr,t),ul(n,t)}}function uT(e,t,n){let i,r=this.cache,a=n.allocateTextureUnit();r[0]!==a&&(e.uniform1i(this.addr,a),r[0]=a),this.type===e.SAMPLER_2D_SHADOW?(l8.compareFunction=n.isReversedDepthBuffer()?518:515,i=l8):i=l6,n.setTexture2D(t||i,a)}function uE(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||l7,r)}function uA(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||ue,r)}function uC(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||l9,r)}function uR(e,t){e.uniform1fv(this.addr,t)}function uP(e,t){let n=us(t,this.size,2);e.uniform2fv(this.addr,n)}function uI(e,t){let n=us(t,this.size,3);e.uniform3fv(this.addr,n)}function uL(e,t){let n=us(t,this.size,4);e.uniform4fv(this.addr,n)}function uN(e,t){let n=us(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function uD(e,t){let n=us(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function uU(e,t){let n=us(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function uO(e,t){e.uniform1iv(this.addr,t)}function uF(e,t){e.uniform2iv(this.addr,t)}function uz(e,t){e.uniform3iv(this.addr,t)}function uk(e,t){e.uniform4iv(this.addr,t)}function uB(e,t){e.uniform1uiv(this.addr,t)}function uV(e,t){e.uniform2uiv(this.addr,t)}function uH(e,t){e.uniform3uiv(this.addr,t)}function uj(e,t){e.uniform4uiv(this.addr,t)}function uG(e,t,n){let i,r=this.cache,a=t.length,s=uu(n,a);uo(r,s)||(e.uniform1iv(this.addr,s),ul(r,s)),i=this.type===e.SAMPLER_2D_SHADOW?l8:l6;for(let e=0;e!==a;++e)n.setTexture2D(t[e]||i,s[e])}function uW(e,t,n){let i=this.cache,r=t.length,a=uu(n,r);uo(i,a)||(e.uniform1iv(this.addr,a),ul(i,a));for(let e=0;e!==r;++e)n.setTexture3D(t[e]||l7,a[e])}function uX(e,t,n){let i=this.cache,r=t.length,a=uu(n,r);uo(i,a)||(e.uniform1iv(this.addr,a),ul(i,a));for(let e=0;e!==r;++e)n.setTextureCube(t[e]||ue,a[e])}function uq(e,t,n){let i=this.cache,r=t.length,a=uu(n,r);uo(i,a)||(e.uniform1iv(this.addr,a),ul(i,a));for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||l9,a[e])}class uY{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return uc;case 35664:return uh;case 35665:return ud;case 35666:return up;case 35674:return uf;case 35675:return um;case 35676:return ug;case 5124:case 35670:return uv;case 35667:case 35671:return ux;case 35668:case 35672:return uy;case 35669:case 35673:return u_;case 5125:return ub;case 36294:return uS;case 36295:return uM;case 36296:return uw;case 35678:case 36198:case 36298:case 36306:case 35682:return uT;case 35679:case 36299:case 36307:return uE;case 35680:case 36300:case 36308:case 36293:return uA;case 36289:case 36303:case 36311:case 36292:return uC}}(t.type)}}class uZ{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return uR;case 35664:return uP;case 35665:return uI;case 35666:return uL;case 35674:return uN;case 35675:return uD;case 35676:return uU;case 5124:case 35670:return uO;case 35667:case 35671:return uF;case 35668:case 35672:return uz;case 35669:case 35673:return uk;case 5125:return uB;case 36294:return uV;case 36295:return uH;case 36296:return uj;case 35678:case 36198:case 36298:case 36306:case 35682:return uG;case 35679:case 36299:case 36307:return uW;case 35680:case 36300:case 36308:case 36293:return uX;case 36289:case 36303:case 36311:case 36292:return uq}}(t.type)}}class uJ{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,a=i.length;r!==a;++r){let a=i[r];a.setValue(e,t[a.id],n)}}}let u$=/(\w+)(\])?(\[|\.)?/g;function uK(e,t){e.seq.push(t),e.map[t.id]=t}class uQ{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i),r=e.getUniformLocation(t,n.name);!function(e,t,n){let i=e.name,r=i.length;for(u$.lastIndex=0;;){let a=u$.exec(i),s=u$.lastIndex,o=a[1],l="]"===a[2],u=a[3];if(l&&(o|=0),void 0===u||"["===u&&s+2===r){uK(n,void 0===u?new uY(o,e,t):new uZ(o,e,t));break}{let e=n.map[o];void 0===e&&uK(n,e=new uJ(o)),n=e}}}(n,r,this)}const i=[],r=[];for(const t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(t):r.push(t);i.length>0&&(this.seq=i.concat(r))}setValue(e,t,n,i){let r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){let a=t[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let r=e[i];r.id in t&&n.push(r)}return n}}function u0(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let u1=0,u2=new eV;function u3(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";let a=/ERROR: 0:(\d+)/.exec(r);if(!a)return r;{let i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){let n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=r;e<a;e++){let r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}}let u4={1:"Linear",2:"Reinhard",3:"Cineon",4:"ACESFilmic",6:"AgX",7:"Neutral",5:"Custom"},u5=new ez;function u6(e){return""!==e}function u8(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function u9(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}let u7=/^[ \t]*#include +<([\w\d./]+)>/gm;function ce(e){return e.replace(u7,cn)}let ct=new Map;function cn(e,t){let n=lT[t];if(void 0===n){let e=ct.get(t);if(void 0!==e)n=lT[e],eb('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e);else throw Error("Can not resolve #include <"+t+">")}return ce(n)}let ci=/#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 cr(e){return e.replace(ci,ca)}function ca(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function cs(e){let t=`precision ${e.precision} float;
341
+ precision ${e.precision} int;
342
+ precision ${e.precision} sampler2D;
343
+ precision ${e.precision} samplerCube;
344
+ precision ${e.precision} sampler3D;
345
+ precision ${e.precision} sampler2DArray;
346
+ precision ${e.precision} sampler2DShadow;
347
+ precision ${e.precision} samplerCubeShadow;
348
+ precision ${e.precision} sampler2DArrayShadow;
349
+ precision ${e.precision} isampler2D;
350
+ precision ${e.precision} isampler3D;
351
+ precision ${e.precision} isamplerCube;
352
+ precision ${e.precision} isampler2DArray;
353
+ precision ${e.precision} usampler2D;
354
+ precision ${e.precision} usampler3D;
355
+ precision ${e.precision} usamplerCube;
356
+ precision ${e.precision} usampler2DArray;
357
+ `;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}let co={1:"SHADOWMAP_TYPE_PCF",3:"SHADOWMAP_TYPE_VSM"},cl={301:"ENVMAP_TYPE_CUBE",302:"ENVMAP_TYPE_CUBE",306:"ENVMAP_TYPE_CUBE_UV"},cu={302:"ENVMAP_MODE_REFRACTION"},cc={0:"ENVMAP_BLENDING_MULTIPLY",1:"ENVMAP_BLENDING_MIX",2:"ENVMAP_BLENDING_ADD"};function ch(e,t,n,i){var r,a;let s,o,l,u,c=e.getContext(),h=n.defines,d=n.vertexShader,p=n.fragmentShader,f=co[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC",m=!1===n.envMap?"ENVMAP_TYPE_CUBE":cl[n.envMapMode]||"ENVMAP_TYPE_CUBE",g=!1===n.envMap?"ENVMAP_MODE_REFLECTION":cu[n.envMapMode]||"ENVMAP_MODE_REFLECTION",v=!1===n.envMap?"ENVMAP_BLENDING_NONE":cc[n.combine]||"ENVMAP_BLENDING_NONE",x=function(e){let t=e.envMapCubeUVHeight;if(null===t)return null;let n=Math.log2(t)-2;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:1/t,maxMip:n}}(n),y=[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(u6).join("\n"),_=function(e){let t=[];for(let n in e){let i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(h),b=c.createProgram(),S=n.glslVersion?"#version "+n.glslVersion+"\n":"";if(n.isRawShaderMaterial)(s=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(u6).join("\n")).length>0&&(s+="\n"),(o=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(u6).join("\n")).length>0&&(o+="\n");else{let e,t,i,l,u;s=[cs(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+g:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+f:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.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","\n"].filter(u6).join("\n"),o=[cs(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+m:"",n.envMap?"#define "+g:"",n.envMap?"#define "+v:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+f:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?lT.tonemapping_pars_fragment:"",0!==n.toneMapping?(r="toneMapping",void 0===(e=u4[a=n.toneMapping])?(eb("WebGLProgram: Unsupported toneMapping:",a),"vec3 "+r+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+r+"( vec3 color ) { return "+e+"ToneMapping( color ); }"):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",lT.colorspace_pars_fragment,(t=function(e){eW._getMatrix(u2,eW.workingColorSpace,e);let t=`mat3( ${u2.elements.map(e=>e.toFixed(4))} )`;switch(eW.getTransfer(e)){case er:return[t,"LinearTransferOETF"];case ea:return[t,"sRGBTransferOETF"];default:return eb("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(n.outputColorSpace),`vec4 linearToOutputTexel( vec4 value ) {
358
+ return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );
359
+ }`),(eW.getLuminanceCoefficients(u5),i=u5.x.toFixed(4),l=u5.y.toFixed(4),u=u5.z.toFixed(4),`float luminance( const in vec3 rgb ) {
360
+ const vec3 weights = vec3( ${i}, ${l}, ${u} );
361
+ return dot( weights, rgb );
362
+ }`),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(u6).join("\n")}d=u9(d=u8(d=ce(d),n),n),p=u9(p=u8(p=ce(p),n),n),d=cr(d),p=cr(p),!0!==n.isRawShaderMaterial&&(S="#version 300 es\n",s=[y,"#define attribute in\n#define varying out\n#define texture2D texture"].join("\n")+"\n"+s,o=["#define varying in",n.glslVersion===es?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===es?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+o);let M=S+s+d,w=S+o+p,T=u0(c,c.VERTEX_SHADER,M),E=u0(c,c.FRAGMENT_SHADER,w);function A(t){if(e.debug.checkShaderErrors){let n=c.getProgramInfoLog(b)||"",i=c.getShaderInfoLog(T)||"",r=c.getShaderInfoLog(E)||"",a=n.trim(),l=i.trim(),u=r.trim(),h=!0,d=!0;if(!1===c.getProgramParameter(b,c.LINK_STATUS))if(h=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(c,b,T,E);else{let e=u3(c,T,"vertex"),n=u3(c,E,"fragment");eS("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(b,c.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+a+"\n"+e+"\n"+n)}else""!==a?eb("WebGLProgram: Program Info Log:",a):(""===l||""===u)&&(d=!1);d&&(t.diagnostics={runnable:h,programLog:a,vertexShader:{log:l,prefix:s},fragmentShader:{log:u,prefix:o}})}c.deleteShader(T),c.deleteShader(E),l=new uQ(c,b),u=function(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let i=e.getActiveAttrib(t,r),a=i.name,s=1;i.type===e.FLOAT_MAT2&&(s=2),i.type===e.FLOAT_MAT3&&(s=3),i.type===e.FLOAT_MAT4&&(s=4),n[a]={type:i.type,location:e.getAttribLocation(t,a),locationSize:s}}return n}(c,b)}c.attachShader(b,T),c.attachShader(b,E),void 0!==n.index0AttributeName?c.bindAttribLocation(b,0,n.index0AttributeName):!0===n.morphTargets&&c.bindAttribLocation(b,0,"position"),c.linkProgram(b),this.getUniforms=function(){return void 0===l&&A(this),l},this.getAttributes=function(){return void 0===u&&A(this),u};let C=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===C&&(C=c.getProgramParameter(b,37297)),C},this.destroy=function(){i.releaseStatesOfProgram(this),c.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=u1++,this.cacheKey=t,this.usedTimes=1,this.program=b,this.vertexShader=T,this.fragmentShader=E,this}let cd=0;class cp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){for(let t of this.materialCache.get(e))t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return void 0===n&&(n=new cf(e),t.set(e,n)),n}}class cf{constructor(e){this.id=cd++,this.code=e,this.usedTimes=0}}function cm(e,t,n,i,r,a,s){let o=new tO,l=new cp,u=new Set,c=[],h=new Map,d=r.logarithmicDepthBuffer,p=r.precision,f={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 m(e){return(u.add(e),0===e)?"uv":`uv${e}`}return{getParameters:function(a,o,c,h,g){let v,x,y,_,b=h.fog,S=g.geometry,M=a.isMeshStandardMaterial?h.environment:null,w=(a.isMeshStandardMaterial?n:t).get(a.envMap||M),T=w&&306===w.mapping?w.image.height:null,E=f[a.type];null!==a.precision&&(p=r.getMaxPrecision(a.precision))!==a.precision&&eb("WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead.");let A=S.morphAttributes.position||S.morphAttributes.normal||S.morphAttributes.color,C=void 0!==A?A.length:0,R=0;if(void 0!==S.morphAttributes.position&&(R=1),void 0!==S.morphAttributes.normal&&(R=2),void 0!==S.morphAttributes.color&&(R=3),E){let e=lA[E];v=e.vertexShader,x=e.fragmentShader}else v=a.vertexShader,x=a.fragmentShader,l.update(a),y=l.getVertexShaderID(a),_=l.getFragmentShaderID(a);let P=e.getRenderTarget(),I=e.state.buffers.depth.getReversed(),L=!0===g.isInstancedMesh,N=!0===g.isBatchedMesh,D=!!a.map,U=!!a.matcap,O=!!w,F=!!a.aoMap,z=!!a.lightMap,k=!!a.bumpMap,B=!!a.normalMap,V=!!a.displacementMap,H=!!a.emissiveMap,j=!!a.metalnessMap,G=!!a.roughnessMap,W=a.anisotropy>0,X=a.clearcoat>0,q=a.dispersion>0,Y=a.iridescence>0,Z=a.sheen>0,J=a.transmission>0,$=W&&!!a.anisotropyMap,K=X&&!!a.clearcoatMap,Q=X&&!!a.clearcoatNormalMap,ee=X&&!!a.clearcoatRoughnessMap,et=Y&&!!a.iridescenceMap,en=Y&&!!a.iridescenceThicknessMap,er=Z&&!!a.sheenColorMap,es=Z&&!!a.sheenRoughnessMap,eo=!!a.specularMap,el=!!a.specularColorMap,eu=!!a.specularIntensityMap,ec=J&&!!a.transmissionMap,eh=J&&!!a.thicknessMap,ed=!!a.gradientMap,ep=!!a.alphaMap,ef=a.alphaTest>0,em=!!a.alphaHash,eg=!!a.extensions,ev=0;a.toneMapped&&(null===P||!0===P.isXRRenderTarget)&&(ev=e.toneMapping);let ex={shaderID:E,shaderType:a.type,shaderName:a.name,vertexShader:v,fragmentShader:x,defines:a.defines,customVertexShaderID:y,customFragmentShaderID:_,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,batching:N,batchingColor:N&&null!==g._colorsTexture,instancing:L,instancingColor:L&&null!==g.instanceColor,instancingMorph:L&&null!==g.morphTexture,outputColorSpace:null===P?e.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:ei,alphaToCoverage:!!a.alphaToCoverage,map:D,matcap:U,envMap:O,envMapMode:O&&w.mapping,envMapCubeUVHeight:T,aoMap:F,lightMap:z,bumpMap:k,normalMap:B,displacementMap:V,emissiveMap:H,normalMapObjectSpace:B&&1===a.normalMapType,normalMapTangentSpace:B&&0===a.normalMapType,metalnessMap:j,roughnessMap:G,anisotropy:W,anisotropyMap:$,clearcoat:X,clearcoatMap:K,clearcoatNormalMap:Q,clearcoatRoughnessMap:ee,dispersion:q,iridescence:Y,iridescenceMap:et,iridescenceThicknessMap:en,sheen:Z,sheenColorMap:er,sheenRoughnessMap:es,specularMap:eo,specularColorMap:el,specularIntensityMap:eu,transmission:J,transmissionMap:ec,thicknessMap:eh,gradientMap:ed,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:ep,alphaTest:ef,alphaHash:em,combine:a.combine,mapUv:D&&m(a.map.channel),aoMapUv:F&&m(a.aoMap.channel),lightMapUv:z&&m(a.lightMap.channel),bumpMapUv:k&&m(a.bumpMap.channel),normalMapUv:B&&m(a.normalMap.channel),displacementMapUv:V&&m(a.displacementMap.channel),emissiveMapUv:H&&m(a.emissiveMap.channel),metalnessMapUv:j&&m(a.metalnessMap.channel),roughnessMapUv:G&&m(a.roughnessMap.channel),anisotropyMapUv:$&&m(a.anisotropyMap.channel),clearcoatMapUv:K&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:Q&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ee&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:et&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:en&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:er&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:es&&m(a.sheenRoughnessMap.channel),specularMapUv:eo&&m(a.specularMap.channel),specularColorMapUv:el&&m(a.specularColorMap.channel),specularIntensityMapUv:eu&&m(a.specularIntensityMap.channel),transmissionMapUv:ec&&m(a.transmissionMap.channel),thicknessMapUv:eh&&m(a.thicknessMap.channel),alphaMapUv:ep&&m(a.alphaMap.channel),vertexTangents:!!S.attributes.tangent&&(B||W),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!S.attributes.color&&4===S.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!S.attributes.uv&&(D||ep),fog:!!b,useFog:!0===a.fog,fogExp2:!!b&&b.isFogExp2,flatShading:!0===a.flatShading&&!1===a.wireframe,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==S.morphAttributes.position,morphNormals:void 0!==S.morphAttributes.normal,morphColors:void 0!==S.morphAttributes.color,morphTargetsCount:C,morphTextureStride:R,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:ev,decodeVideoTexture:D&&!0===a.map.isVideoTexture&&eW.getTransfer(a.map.colorSpace)===ea,decodeVideoTextureEmissive:H&&!0===a.emissiveMap.isVideoTexture&&eW.getTransfer(a.emissiveMap.colorSpace)===ea,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:eg&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(eg&&!0===a.extensions.multiDraw||N)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ex.vertexUv1s=u.has(1),ex.vertexUv2s=u.has(2),ex.vertexUv3s=u.has(3),u.clear(),ex},getProgramCacheKey:function(t){var n,i,r,a;let s=[];if(t.shaderID?s.push(t.shaderID):(s.push(t.customVertexShaderID),s.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)s.push(e),s.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(n=s,i=t,n.push(i.precision),n.push(i.outputColorSpace),n.push(i.envMapMode),n.push(i.envMapCubeUVHeight),n.push(i.mapUv),n.push(i.alphaMapUv),n.push(i.lightMapUv),n.push(i.aoMapUv),n.push(i.bumpMapUv),n.push(i.normalMapUv),n.push(i.displacementMapUv),n.push(i.emissiveMapUv),n.push(i.metalnessMapUv),n.push(i.roughnessMapUv),n.push(i.anisotropyMapUv),n.push(i.clearcoatMapUv),n.push(i.clearcoatNormalMapUv),n.push(i.clearcoatRoughnessMapUv),n.push(i.iridescenceMapUv),n.push(i.iridescenceThicknessMapUv),n.push(i.sheenColorMapUv),n.push(i.sheenRoughnessMapUv),n.push(i.specularMapUv),n.push(i.specularColorMapUv),n.push(i.specularIntensityMapUv),n.push(i.transmissionMapUv),n.push(i.thicknessMapUv),n.push(i.combine),n.push(i.fogExp2),n.push(i.sizeAttenuation),n.push(i.morphTargetsCount),n.push(i.morphAttributeCount),n.push(i.numDirLights),n.push(i.numPointLights),n.push(i.numSpotLights),n.push(i.numSpotLightMaps),n.push(i.numHemiLights),n.push(i.numRectAreaLights),n.push(i.numDirLightShadows),n.push(i.numPointLightShadows),n.push(i.numSpotLightShadows),n.push(i.numSpotLightShadowsWithMaps),n.push(i.numLightProbes),n.push(i.shadowMapType),n.push(i.toneMapping),n.push(i.numClippingPlanes),n.push(i.numClipIntersection),n.push(i.depthPacking),r=s,a=t,o.disableAll(),a.instancing&&o.enable(0),a.instancingColor&&o.enable(1),a.instancingMorph&&o.enable(2),a.matcap&&o.enable(3),a.envMap&&o.enable(4),a.normalMapObjectSpace&&o.enable(5),a.normalMapTangentSpace&&o.enable(6),a.clearcoat&&o.enable(7),a.iridescence&&o.enable(8),a.alphaTest&&o.enable(9),a.vertexColors&&o.enable(10),a.vertexAlphas&&o.enable(11),a.vertexUv1s&&o.enable(12),a.vertexUv2s&&o.enable(13),a.vertexUv3s&&o.enable(14),a.vertexTangents&&o.enable(15),a.anisotropy&&o.enable(16),a.alphaHash&&o.enable(17),a.batching&&o.enable(18),a.dispersion&&o.enable(19),a.batchingColor&&o.enable(20),a.gradientMap&&o.enable(21),r.push(o.mask),o.disableAll(),a.fog&&o.enable(0),a.useFog&&o.enable(1),a.flatShading&&o.enable(2),a.logarithmicDepthBuffer&&o.enable(3),a.reversedDepthBuffer&&o.enable(4),a.skinning&&o.enable(5),a.morphTargets&&o.enable(6),a.morphNormals&&o.enable(7),a.morphColors&&o.enable(8),a.premultipliedAlpha&&o.enable(9),a.shadowMapEnabled&&o.enable(10),a.doubleSided&&o.enable(11),a.flipSided&&o.enable(12),a.useDepthPacking&&o.enable(13),a.dithering&&o.enable(14),a.transmission&&o.enable(15),a.sheen&&o.enable(16),a.opaque&&o.enable(17),a.pointsUvs&&o.enable(18),a.decodeVideoTexture&&o.enable(19),a.decodeVideoTextureEmissive&&o.enable(20),a.alphaToCoverage&&o.enable(21),r.push(o.mask),s.push(e.outputColorSpace)),s.push(t.customProgramCacheKey),s.join()},getUniforms:function(e){let t,n=f[e.type];if(n){let e=lA[n];t=n0.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i=h.get(n);return void 0!==i?++i.usedTimes:(i=new ch(e,n,t,a),c.push(i),h.set(n,i)),i},releaseProgram:function(e){if(0==--e.usedTimes){let t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),h.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function cg(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function cv(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function cx(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function cy(){let e=[],t=0,n=[],i=[],r=[];function a(n,i,r,a,s,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:s,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,u){let c=a(e,t,s,o,l,u);s.transmission>0?i.push(c):!0===s.transparent?r.push(c):n.push(c)},unshift:function(e,t,s,o,l,u){let c=a(e,t,s,o,l,u);s.transmission>0?i.unshift(c):!0===s.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=t,i=e.length;n<i;n++){let t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||cv),i.length>1&&i.sort(t||cx),r.length>1&&r.sort(t||cx)}}}function c_(){let e=new WeakMap;return{get:function(t,n){let i,r=e.get(t);return void 0===r?(i=new cy,e.set(t,[i])):n>=r.length?(i=new cy,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function cb(){let e={};return{get:function(t){let n;if(void 0!==e[t.id])return e[t.id];switch(t.type){case"DirectionalLight":n={direction:new ez,color:new no};break;case"SpotLight":n={position:new ez,direction:new ez,color:new no,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ez,color:new no,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ez,skyColor:new no,groundColor:new no};break;case"RectAreaLight":n={color:new no,position:new ez,halfWidth:new ez,halfHeight:new ez}}return e[t.id]=n,n}}}let cS=0;function cM(e,t){return 2*!!t.castShadow-2*!!e.castShadow+ +!!t.map-!!e.map}function cw(e){let t,n=new cb,i=(t={},{get:function(e){let n;if(void 0!==t[e.id])return t[e.id];switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new eO};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new eO,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],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 e=0;e<9;e++)r.probe.push(new ez);let a=new ez,s=new tT,o=new tT;return{setup:function(t){let a=0,s=0,o=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,c=0,h=0,d=0,p=0,f=0,m=0,g=0,v=0,x=0;t.sort(cM);for(let e=0,y=t.length;e<y;e++){let y=t[e],_=y.color,b=y.intensity,S=y.distance,M=null;if(y.shadow&&y.shadow.map&&(M=1030===y.shadow.map.texture.format?y.shadow.map.texture:y.shadow.map.depthTexture||y.shadow.map.texture),y.isAmbientLight)a+=_.r*b,s+=_.g*b,o+=_.b*b;else if(y.isLightProbe){for(let e=0;e<9;e++)r.probe[e].addScaledVector(y.sh.coefficients[e],b);x++}else if(y.isDirectionalLight){let e=n.get(y);if(e.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){let e=y.shadow,t=i.get(y);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,r.directionalShadow[l]=t,r.directionalShadowMap[l]=M,r.directionalShadowMatrix[l]=y.shadow.matrix,p++}r.directional[l]=e,l++}else if(y.isSpotLight){let e=n.get(y);e.position.setFromMatrixPosition(y.matrixWorld),e.color.copy(_).multiplyScalar(b),e.distance=S,e.coneCos=Math.cos(y.angle),e.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),e.decay=y.decay,r.spot[c]=e;let t=y.shadow;if(y.map&&(r.spotLightMap[g]=y.map,g++,t.updateMatrices(y),y.castShadow&&v++),r.spotLightMatrix[c]=t.matrix,y.castShadow){let e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,r.spotShadow[c]=e,r.spotShadowMap[c]=M,m++}c++}else if(y.isRectAreaLight){let e=n.get(y);e.color.copy(_).multiplyScalar(b),e.halfWidth.set(.5*y.width,0,0),e.halfHeight.set(0,.5*y.height,0),r.rectArea[h]=e,h++}else if(y.isPointLight){let e=n.get(y);if(e.color.copy(y.color).multiplyScalar(y.intensity),e.distance=y.distance,e.decay=y.decay,y.castShadow){let e=y.shadow,t=i.get(y);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,r.pointShadow[u]=t,r.pointShadowMap[u]=M,r.pointShadowMatrix[u]=y.shadow.matrix,f++}r.point[u]=e,u++}else if(y.isHemisphereLight){let e=n.get(y);e.skyColor.copy(y.color).multiplyScalar(b),e.groundColor.copy(y.groundColor).multiplyScalar(b),r.hemi[d]=e,d++}}h>0&&(!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=lE.LTC_FLOAT_1,r.rectAreaLTC2=lE.LTC_FLOAT_2):(r.rectAreaLTC1=lE.LTC_HALF_1,r.rectAreaLTC2=lE.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=s,r.ambient[2]=o;let y=r.hash;(y.directionalLength!==l||y.pointLength!==u||y.spotLength!==c||y.rectAreaLength!==h||y.hemiLength!==d||y.numDirectionalShadows!==p||y.numPointShadows!==f||y.numSpotShadows!==m||y.numSpotMaps!==g||y.numLightProbes!==x)&&(r.directional.length=l,r.spot.length=c,r.rectArea.length=h,r.point.length=u,r.hemi.length=d,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=f,r.pointShadowMap.length=f,r.spotShadow.length=m,r.spotShadowMap.length=m,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=f,r.spotLightMatrix.length=m+g-v,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=v,r.numLightProbes=x,y.directionalLength=l,y.pointLength=u,y.spotLength=c,y.rectAreaLength=h,y.hemiLength=d,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=x,r.version=cS++)},setupView:function(e,t){let n=0,i=0,l=0,u=0,c=0,h=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){let d=e[t];if(d.isDirectionalLight){let e=r.directional[n];e.direction.setFromMatrixPosition(d.matrixWorld),a.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(h),n++}else if(d.isSpotLight){let e=r.spot[l];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),e.direction.setFromMatrixPosition(d.matrixWorld),a.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(h),l++}else if(d.isRectAreaLight){let e=r.rectArea[u];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),o.identity(),s.copy(d.matrixWorld),s.premultiply(h),o.extractRotation(s),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),u++}else if(d.isPointLight){let e=r.point[i];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),i++}else if(d.isHemisphereLight){let e=r.hemi[c];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(h),c++}}},state:r}}function cT(e){let t=new cw(e),n=[],i=[],r={lightsArray:n,shadowsArray:i,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){r.camera=e,n.length=0,i.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)}}}function cE(e){let t=new WeakMap;return{get:function(n,i=0){let r,a=t.get(n);return void 0===a?(r=new cT(e),t.set(n,[r])):i>=a.length?(r=new cT(e),a.push(r)):r=a[i],r},dispose:function(){t=new WeakMap}}}let cA=[new ez(1,0,0),new ez(-1,0,0),new ez(0,1,0),new ez(0,-1,0),new ez(0,0,1),new ez(0,0,-1)],cC=[new ez(0,-1,0),new ez(0,-1,0),new ez(0,0,1),new ez(0,0,-1),new ez(0,-1,0),new ez(0,-1,0)],cR=new tT,cP=new ez,cI=new ez;function cL(e,t,n){let i=new i6,r=new eO,a=new eO,s=new e1,o=new a9,l=new a7,u={},c=n.maxTextureSize,h={0:1,1:0,2:2},d=new n1({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new eO},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new nO;f.setAttribute("position",new ny(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new nY(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function x(t,n,i,r){let a=null,s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){let e=a.uuid,t=n.uuid,i=u[e];void 0===i&&(i={},u[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",y)),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,3===r?a.side=null!==n.shadowSide?n.shadowSide:n.side:a.side=null!==n.shadowSide?n.shadowSide:h[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function y(e){for(let t in e.target.removeEventListener("dispose",y),u){let n=u[t],i=e.target.uuid;i in n&&(n[i].dispose(),delete n[i])}}this.render=function(n,o,l){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===n.length)return;2===n.type&&(eb("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),n.type=1);let u=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),y=e.state;y.setBlending(0),!0===y.buffers.depth.getReversed()?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 _=v!==this.type;_&&o.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let u=0,h=n.length;u<h;u++){let h=n[u],f=h.shadow;if(void 0===f){eb("WebGLShadowMap:",h,"has no shadow.");continue}if(!1===f.autoUpdate&&!1===f.needsUpdate)continue;r.copy(f.mapSize);let g=f.getFrameExtents();if(r.multiply(g),a.copy(f.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/g.x),r.x=a.x*g.x,f.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/g.y),r.y=a.y*g.y,f.mapSize.y=a.y)),null===f.map||!0===_){if(null!==f.map&&(null!==f.map.depthTexture&&(f.map.depthTexture.dispose(),f.map.depthTexture=null),f.map.dispose()),3===this.type){if(h.isPointLight){eb("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}f.map=new e3(r.x,r.y,{format:1030,type:1016,minFilter:1006,magFilter:1006,generateMipmaps:!1}),f.map.texture.name=h.name+".shadowMap",f.map.depthTexture=new rW(r.x,r.y,1015),f.map.depthTexture.name=h.name+".shadowMapDepth",f.map.depthTexture.format=1026,f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=1003,f.map.depthTexture.magFilter=1003}else{h.isPointLight?(f.map=new n7(r.x),f.map.depthTexture=new rX(r.x,1014)):(f.map=new e3(r.x,r.y),f.map.depthTexture=new rW(r.x,r.y,1014)),f.map.depthTexture.name=h.name+".shadowMap",f.map.depthTexture.format=1026;let t=e.state.buffers.depth.getReversed();1===this.type?(f.map.depthTexture.compareFunction=t?518:515,f.map.depthTexture.minFilter=1006,f.map.depthTexture.magFilter=1006):(f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=1003,f.map.depthTexture.magFilter=1003)}f.camera.updateProjectionMatrix()}let v=f.map.isWebGLCubeRenderTarget?6:1;for(let n=0;n<v;n++){if(f.map.isWebGLCubeRenderTarget)e.setRenderTarget(f.map,n),e.clear();else{0===n&&(e.setRenderTarget(f.map),e.clear());let t=f.getViewport(n);s.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),y.viewport(s)}if(h.isPointLight){let e=f.camera,t=f.matrix,i=h.distance||e.far;i!==e.far&&(e.far=i,e.updateProjectionMatrix()),cP.setFromMatrixPosition(h.matrixWorld),e.position.copy(cP),cI.copy(e.position),cI.add(cA[n]),e.up.copy(cC[n]),e.lookAt(cI),e.updateMatrixWorld(),t.makeTranslation(-cP.x,-cP.y,-cP.z),cR.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),f._frustum.setFromProjectionMatrix(cR,e.coordinateSystem,e.reversedDepth)}else f.updateMatrices(h);i=f.getFrustum(),function n(r,a,s,o,l){if(!1===r.visible)return;if(r.layers.test(a.layers)&&(r.isMesh||r.isLine||r.isPoints)&&(r.castShadow||r.receiveShadow&&3===l)&&(!r.frustumCulled||i.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,r.matrixWorld);let n=t.update(r),i=r.material;if(Array.isArray(i)){let t=n.groups;for(let u=0,c=t.length;u<c;u++){let c=t[u],h=i[c.materialIndex];if(h&&h.visible){let t=x(r,h,o,l);r.onBeforeShadow(e,r,a,s,n,t,c),e.renderBufferDirect(s,null,n,t,r,c),r.onAfterShadow(e,r,a,s,n,t,c)}}}else if(i.visible){let t=x(r,i,o,l);r.onBeforeShadow(e,r,a,s,n,t,null),e.renderBufferDirect(s,null,n,t,r,null),r.onAfterShadow(e,r,a,s,n,t,null)}}let u=r.children;for(let e=0,t=u.length;e<t;e++)n(u[e],a,s,o,l)}(o,l,f.camera,h,this.type)}!0!==f.isPointLightShadow&&3===this.type&&function(n,i){let a=t.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new e3(r.x,r.y,{format:1030,type:1016})),d.uniforms.shadow_pass.value=n.map.depthTexture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,a,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,a,p,m,null)}(f,l),f.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(u,h,f)}}let cN={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3};function cD(e,t){let n=new function(){let t=!1,n=new e1,i=null,r=new e1(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,s,o){!0===o&&(t*=s,i*=s,a*=s),n.set(t,i,a,s),!1===r.equals(n)&&(e.clearColor(t,i,a,s),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,a=null,s=null;return{setReversed:function(e){if(i!==e){let n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;let r=s;s=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(t){t?k(e.DEPTH_TEST):B(e.DEPTH_TEST)},setMask:function(t){r===t||n||(e.depthMask(t),r=t)},setFunc:function(t){if(i&&(t=cN[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){s!==t&&(i&&(t=1-t),e.clearDepth(t),s=t)},reset:function(){n=!1,r=null,a=null,s=null,i=!1}}},r=new function(){let t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,u=null;return{setTest:function(n){t||(n?k(e.STENCIL_TEST):B(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,s){(i!==t||r!==n||a!==s)&&(e.stencilFunc(t,n,s),i=t,r=n,a=s)},setOp:function(t,n,i){(s!==t||o!==n||l!==i)&&(e.stencilOp(t,n,i),s=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){u!==t&&(e.clearStencil(t),u=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,u=null}}},a=new WeakMap,s=new WeakMap,o={},l={},u=new WeakMap,c=[],h=null,d=!1,p=null,f=null,m=null,g=null,v=null,x=null,y=null,_=new no(0,0,0),b=0,S=!1,M=null,w=null,T=null,E=null,A=null,C=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),R=!1,P=e.getParameter(e.VERSION);-1!==P.indexOf("WebGL")?R=parseFloat(/^WebGL (\d)/.exec(P)[1])>=1:-1!==P.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(P)[1])>=2);let I=null,L={},N=e.getParameter(e.SCISSOR_BOX),D=e.getParameter(e.VIEWPORT),U=new e1().fromArray(N),O=new e1().fromArray(D);function F(t,n,i,r){let a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;s<i;s++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return s}let z={};function k(t){!0!==o[t]&&(e.enable(t),o[t]=!0)}function B(t){!1!==o[t]&&(e.disable(t),o[t]=!1)}z[e.TEXTURE_2D]=F(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=F(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),z[e.TEXTURE_2D_ARRAY]=F(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=F(e.TEXTURE_3D,e.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),k(e.DEPTH_TEST),i.setFunc(3),G(!1),W(1),k(e.CULL_FACE),j(0);let V={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT};V[103]=e.MIN,V[104]=e.MAX;let H={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA,211:e.CONSTANT_COLOR,212:e.ONE_MINUS_CONSTANT_COLOR,213:e.CONSTANT_ALPHA,214:e.ONE_MINUS_CONSTANT_ALPHA};function j(t,n,i,r,a,s,o,l,u,c){if(0===t){!0===d&&(B(e.BLEND),d=!1);return}if(!1===d&&(k(e.BLEND),d=!0),5!==t){if(t!==p||c!==S){if((100!==f||100!==v)&&(e.blendEquation(e.FUNC_ADD),f=100,v=100),c)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:eS("WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:eS("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:eS("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:eS("WebGLState: Invalid blending: ",t)}m=null,g=null,x=null,y=null,_.set(0,0,0),b=0,p=t,S=c}return}a=a||n,s=s||i,o=o||r,(n!==f||a!==v)&&(e.blendEquationSeparate(V[n],V[a]),f=n,v=a),(i!==m||r!==g||s!==x||o!==y)&&(e.blendFuncSeparate(H[i],H[r],H[s],H[o]),m=i,g=r,x=s,y=o),(!1===l.equals(_)||u!==b)&&(e.blendColor(l.r,l.g,l.b,u),_.copy(l),b=u),p=t,S=!1}function G(t){M!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),M=t)}function W(t){0!==t?(k(e.CULL_FACE),t!==w&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):B(e.CULL_FACE),w=t}function X(t,n,i){t?(k(e.POLYGON_OFFSET_FILL),(E!==n||A!==i)&&(e.polygonOffset(n,i),E=n,A=i)):B(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:k,disable:B,bindFramebuffer:function(t,n){return l[t]!==n&&(e.bindFramebuffer(t,n),l[t]=n,t===e.DRAW_FRAMEBUFFER&&(l[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(l[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=c,r=!1;if(t){void 0===(i=u.get(n))&&(i=[],u.set(n,i));let a=t.textures;if(i.length!==a.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=a.length,r=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,r=!0);r&&e.drawBuffers(i)},useProgram:function(t){return h!==t&&(e.useProgram(t),h=t,!0)},setBlending:j,setMaterial:function(t,a){2===t.side?B(e.CULL_FACE):k(e.CULL_FACE);let s=1===t.side;a&&(s=!s),G(s),1===t.blending&&!1===t.transparent?j(0):j(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),n.setMask(t.colorWrite);let o=t.stencilWrite;r.setTest(o),o&&(r.setMask(t.stencilWriteMask),r.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),r.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),X(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?k(e.SAMPLE_ALPHA_TO_COVERAGE):B(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:G,setCullFace:W,setLineWidth:function(t){t!==T&&(R&&e.lineWidth(t),T=t)},setPolygonOffset:X,setScissorTest:function(t){t?k(e.SCISSOR_TEST):B(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+C-1),I!==t&&(e.activeTexture(t),I=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===I?e.TEXTURE0+C-1:I);let r=L[i];void 0===r&&(r={type:void 0,texture:void 0},L[i]=r),(r.type!==t||r.texture!==n)&&(I!==i&&(e.activeTexture(i),I=i),e.bindTexture(t,n||z[t]),r.type=t,r.texture=n)},unbindTexture:function(){let t=L[I];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){eS("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){eS("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){eS("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){eS("WebGLState:",e)}},updateUBOMapping:function(t,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){let i=s.get(n).get(t);a.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),a.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){eS("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){eS("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){eS("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){eS("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){eS("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){eS("WebGLState:",e)}},scissor:function(t){!1===U.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),U.copy(t))},viewport:function(t){!1===O.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),O.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(0xffffffff),e.stencilFunc(e.ALWAYS,0,0xffffffff),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),o={},I=null,L={},l={},u=new WeakMap,c=[],h=null,d=!1,p=null,f=null,m=null,g=null,v=null,x=null,y=null,_=new no(0,0,0),b=0,S=!1,M=null,w=null,T=null,E=null,A=null,U.set(0,0,e.canvas.width,e.canvas.height),O.set(0,0,e.canvas.width,e.canvas.height),n.reset(),i.reset(),r.reset()}}}function cU(e,t,n,i,r,a,s){let o,l=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,u="u">typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new eO,h=new WeakMap,d=new WeakMap,p=!1;try{p="u">typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function f(e,t){return p?new OffscreenCanvas(e,t):ef("canvas")}function m(e,t,n){let i=1,r=H(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1)if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof VideoFrame&&e instanceof VideoFrame){let n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===o&&(o=f(n,a));let s=t?f(n,a):o;return s.width=n,s.height=a,s.getContext("2d").drawImage(e,0,0,n,a),eb("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}else"data"in e&&eb("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+").");return e}function g(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function x(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];eb("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(o=e.R11F_G11F_B10F)),i===e.RGBA){let t=s?er:eW.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===ea?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return(o===e.R16F||o===e.R32F||o===e.RG16F||o===e.RG32F||o===e.RGBA16F||o===e.RGBA32F)&&t.get("EXT_color_buffer_float"),o}function y(t,n){let i;return t?null===n||1014===n||1020===n?i=e.DEPTH24_STENCIL8:1015===n?i=e.DEPTH32F_STENCIL8:1012===n&&(i=e.DEPTH24_STENCIL8,eb("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||1014===n||1020===n?i=e.DEPTH_COMPONENT24:1015===n?i=e.DEPTH_COMPONENT32F:1012===n&&(i=e.DEPTH_COMPONENT16),i}function _(e,t){return!0===g(e)||e.isFramebufferTexture&&1003!==e.minFilter&&1006!==e.minFilter?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function b(e){let t=e.target;t.removeEventListener("dispose",b),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,r=d.get(n);if(r){let i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(r).length&&d.delete(n)}i.remove(e)}(t),t.isVideoTexture&&h.delete(t)}function S(t){let n=t.target;n.removeEventListener("dispose",S),function(t){let n=i.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let r=t.textures;for(let t=0,n=r.length;t<n;t++){let n=i.get(r[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[t])}i.remove(t)}(n)}function M(t){let n=i.get(t);e.deleteTexture(n.__webglTexture);let r=t.source,a=d.get(r);delete a[n.__cacheKey],s.memory.textures--}let w=0;function T(t,r){var a;let o,l=i.get(t);if(t.isVideoTexture&&(a=t,o=s.render.frame,h.get(a)!==o&&(h.set(a,o),a.update())),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&l.__version!==t.version){let e=t.image;if(null===e)eb("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void L(l,t,r);eb("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(l.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,l.__webglTexture,e.TEXTURE0+r)}let E={1e3:e.REPEAT,1001:e.CLAMP_TO_EDGE,1002:e.MIRRORED_REPEAT},A={1003:e.NEAREST,1004:e.NEAREST_MIPMAP_NEAREST,1005:e.NEAREST_MIPMAP_LINEAR,1006:e.LINEAR,1007:e.LINEAR_MIPMAP_NEAREST,1008:e.LINEAR_MIPMAP_LINEAR},C={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function R(n,a){if((1015===a.type&&!1===t.has("OES_texture_float_linear")&&(1006===a.magFilter||1007===a.magFilter||1005===a.magFilter||1008===a.magFilter||1006===a.minFilter||1007===a.minFilter||1005===a.minFilter||1008===a.minFilter)&&eb("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,E[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,E[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,E[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,A[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,A[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,C[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic"))&&1003!==a.magFilter&&(1005===a.minFilter||1008===a.minFilter)&&(1015!==a.type||!1!==t.has("OES_texture_float_linear"))&&(a.anisotropy>1||i.get(a).__currentAnisotropy)){let s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}function P(t,n){let i,r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",b));let a=n.source,o=d.get(a);void 0===o&&(o={},d.set(a,o));let l=((i=[]).push(n.wrapS),i.push(n.wrapT),i.push(n.wrapR||0),i.push(n.magFilter),i.push(n.minFilter),i.push(n.anisotropy),i.push(n.internalFormat),i.push(n.format),i.push(n.type),i.push(n.generateMipmaps),i.push(n.premultiplyAlpha),i.push(n.flipY),i.push(n.unpackAlignment),i.push(n.colorSpace),i.join());if(l!==t.__cacheKey){void 0===o[l]&&(o[l]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,r=!0),o[l].usedTimes++;let i=o[t.__cacheKey];void 0!==i&&(o[t.__cacheKey].usedTimes--,0===i.usedTimes&&M(n)),t.__cacheKey=l,t.__webglTexture=o[l].texture}return r}function I(e,t,n){return Math.floor(Math.floor(e/n)/t)}function L(t,s,o){let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);let u=P(t,s),c=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);let h=i.get(c);if(c.version!==h.__version||!0===u){let t;n.activeTexture(e.TEXTURE0+o);let i=eW.getPrimaries(eW.workingColorSpace),d=""===s.colorSpace?null:eW.getPrimaries(s.colorSpace),p=""===s.colorSpace||i===d?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let f=m(s.image,!1,r.maxTextureSize);f=V(s,f);let b=a.convert(s.format,s.colorSpace),S=a.convert(s.type),M=x(s.internalFormat,b,S,s.colorSpace,s.isVideoTexture);R(l,s);let w=s.mipmaps,T=!0!==s.isVideoTexture,E=void 0===h.__version||!0===u,A=c.dataReady,C=_(s,f);if(s.isDepthTexture)M=y(1027===s.format,s.type),E&&(T?n.texStorage2D(e.TEXTURE_2D,1,M,f.width,f.height):n.texImage2D(e.TEXTURE_2D,0,M,f.width,f.height,0,b,S,null));else if(s.isDataTexture)if(w.length>0){T&&E&&n.texStorage2D(e.TEXTURE_2D,C,M,w[0].width,w[0].height);for(let i=0,r=w.length;i<r;i++)t=w[i],T?A&&n.texSubImage2D(e.TEXTURE_2D,i,0,0,t.width,t.height,b,S,t.data):n.texImage2D(e.TEXTURE_2D,i,M,t.width,t.height,0,b,S,t.data);s.generateMipmaps=!1}else T?(E&&n.texStorage2D(e.TEXTURE_2D,C,M,f.width,f.height),A&&function(t,i,r,a){let s=t.updateRanges;if(0===s.length)n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,r,a,i.data);else{s.sort((e,t)=>e.start-t.start);let o=0;for(let e=1;e<s.length;e++){let t=s[o],n=s[e],r=t.start+t.count,a=I(n.start,i.width,4),l=I(t.start,i.width,4);n.start<=r+1&&a===l&&I(n.start+n.count-1,i.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):s[++o]=n}s.length=o+1;let l=e.getParameter(e.UNPACK_ROW_LENGTH),u=e.getParameter(e.UNPACK_SKIP_PIXELS),c=e.getParameter(e.UNPACK_SKIP_ROWS);e.pixelStorei(e.UNPACK_ROW_LENGTH,i.width);for(let t=0,o=s.length;t<o;t++){let o=s[t],l=Math.floor(o.start/4),u=Math.ceil(o.count/4),c=l%i.width,h=Math.floor(l/i.width);e.pixelStorei(e.UNPACK_SKIP_PIXELS,c),e.pixelStorei(e.UNPACK_SKIP_ROWS,h),n.texSubImage2D(e.TEXTURE_2D,0,c,h,u,1,r,a,i.data)}t.clearUpdateRanges(),e.pixelStorei(e.UNPACK_ROW_LENGTH,l),e.pixelStorei(e.UNPACK_SKIP_PIXELS,u),e.pixelStorei(e.UNPACK_SKIP_ROWS,c)}}(s,f,b,S)):n.texImage2D(e.TEXTURE_2D,0,M,f.width,f.height,0,b,S,f.data);else if(s.isCompressedTexture)if(s.isCompressedArrayTexture){T&&E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,C,M,w[0].width,w[0].height,f.depth);for(let i=0,r=w.length;i<r;i++)if(t=w[i],1023!==s.format)if(null!==b)if(T){if(A)if(s.layerUpdates.size>0){let r=lb(t.width,t.height,s.format,s.type);for(let a of s.layerUpdates){let s=t.data.subarray(a*r/t.data.BYTES_PER_ELEMENT,(a+1)*r/t.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,t.width,t.height,1,b,s)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,t.width,t.height,f.depth,b,t.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,M,t.width,t.height,f.depth,0,t.data,0,0);else eb("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,t.width,t.height,f.depth,b,S,t.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,M,t.width,t.height,f.depth,0,b,S,t.data)}else{T&&E&&n.texStorage2D(e.TEXTURE_2D,C,M,w[0].width,w[0].height);for(let i=0,r=w.length;i<r;i++)t=w[i],1023!==s.format?null!==b?T?A&&n.compressedTexSubImage2D(e.TEXTURE_2D,i,0,0,t.width,t.height,b,t.data):n.compressedTexImage2D(e.TEXTURE_2D,i,M,t.width,t.height,0,t.data):eb("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):T?A&&n.texSubImage2D(e.TEXTURE_2D,i,0,0,t.width,t.height,b,S,t.data):n.texImage2D(e.TEXTURE_2D,i,M,t.width,t.height,0,b,S,t.data)}else if(s.isDataArrayTexture)if(T){if(E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,C,M,f.width,f.height,f.depth),A)if(s.layerUpdates.size>0){let t=lb(f.width,f.height,s.format,s.type);for(let i of s.layerUpdates){let r=f.data.subarray(i*t/f.data.BYTES_PER_ELEMENT,(i+1)*t/f.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,f.width,f.height,1,b,S,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,f.width,f.height,f.depth,b,S,f.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,M,f.width,f.height,f.depth,0,b,S,f.data);else if(s.isData3DTexture)T?(E&&n.texStorage3D(e.TEXTURE_3D,C,M,f.width,f.height,f.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,f.width,f.height,f.depth,b,S,f.data)):n.texImage3D(e.TEXTURE_3D,0,M,f.width,f.height,f.depth,0,b,S,f.data);else if(s.isFramebufferTexture){if(E)if(T)n.texStorage2D(e.TEXTURE_2D,C,M,f.width,f.height);else{let t=f.width,i=f.height;for(let r=0;r<C;r++)n.texImage2D(e.TEXTURE_2D,r,M,t,i,0,b,S,null),t>>=1,i>>=1}}else if(w.length>0){if(T&&E){let t=H(w[0]);n.texStorage2D(e.TEXTURE_2D,C,M,t.width,t.height)}for(let i=0,r=w.length;i<r;i++)t=w[i],T?A&&n.texSubImage2D(e.TEXTURE_2D,i,0,0,b,S,t):n.texImage2D(e.TEXTURE_2D,i,M,b,S,t);s.generateMipmaps=!1}else if(T){if(E){let t=H(f);n.texStorage2D(e.TEXTURE_2D,C,M,t.width,t.height)}A&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,b,S,f)}else n.texImage2D(e.TEXTURE_2D,0,M,b,S,f);g(s)&&v(l),h.__version=c.version,s.onUpdate&&s.onUpdate(s)}t.__version=s.version}function N(t,r,s,o,u,c){let h=a.convert(s.format,s.colorSpace),d=a.convert(s.type),p=x(s.internalFormat,h,d,s.colorSpace),f=i.get(r),m=i.get(s);if(m.__renderTarget=r,!f.__hasExternalTextures){let t=Math.max(1,r.width>>c),i=Math.max(1,r.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,c,p,t,i,r.depth,0,h,d,null):n.texImage2D(u,c,p,t,i,0,h,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),B(r)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,u,m.__webglTexture,0,k(r)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,u,m.__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function D(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,s=y(n.stencilBuffer,a),o=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;B(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,k(n),s,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,k(n),s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,o,e.RENDERBUFFER,t)}else{let t=n.textures;for(let r=0;r<t.length;r++){let s=t[r],o=a.convert(s.format,s.colorSpace),u=a.convert(s.type),c=x(s.internalFormat,o,u,s.colorSpace);B(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,k(n),c,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,k(n),c,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,c,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function U(t,r,s){let o=!0===r.isWebGLCubeRenderTarget;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!(r.depthTexture&&r.depthTexture.isDepthTexture))throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let u=i.get(r.depthTexture);if(u.__renderTarget=r,u.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),o){if(void 0===u.__webglInit&&(u.__webglInit=!0,r.depthTexture.addEventListener("dispose",b)),void 0===u.__webglTexture){let t;u.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,u.__webglTexture),R(e.TEXTURE_CUBE_MAP,r.depthTexture);let i=a.convert(r.depthTexture.format),s=a.convert(r.depthTexture.type);1026===r.depthTexture.format?t=e.DEPTH_COMPONENT24:1027===r.depthTexture.format&&(t=e.DEPTH24_STENCIL8);for(let n=0;n<6;n++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,t,r.width,r.height,0,i,s,null)}}else T(r.depthTexture,0);let c=u.__webglTexture,h=k(r),d=o?e.TEXTURE_CUBE_MAP_POSITIVE_X+s:e.TEXTURE_2D,p=1027===r.depthTexture.format?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(1026===r.depthTexture.format)B(r)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,d,c,0,h):e.framebufferTexture2D(e.FRAMEBUFFER,p,d,c,0);else if(1027===r.depthTexture.format)B(r)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,d,c,0,h):e.framebufferTexture2D(e.FRAMEBUFFER,p,d,c,0);else throw Error("Unknown depthTexture format")}function O(t){let r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),e){let t=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)U(r.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?U(r.__webglFramebuffer[0],t,0):U(r.__webglFramebuffer,t,0)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),D(r.__webglDepthbuffer[i],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),D(r.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}let F=[],z=[];function k(e){return Math.min(r.maxSamples,e.samples)}function B(e){let n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function V(e,t){let n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==ei&&""!==n&&(eW.getTransfer(n)===ea?(1023!==i||1009!==r)&&eb("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):eS("WebGLTextures: Unsupported texture color space:",n)),t}function H(e){return"u">typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"u">typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){let e=w;return e>=r.maxTextures&&eb("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),w+=1,e},this.resetTextureUnits=function(){w=0},this.setTexture2D=T,this.setTexture2DArray=function(t,r){let a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?L(a,t,r):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r))},this.setTexture3D=function(t,r){let a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?L(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){let o=i.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;let l=P(t,s),u=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);let c=i.get(u);if(u.version!==c.__version||!0===l){let t;n.activeTexture(e.TEXTURE0+o);let i=eW.getPrimaries(eW.workingColorSpace),h=""===s.colorSpace?null:eW.getPrimaries(s.colorSpace),d=""===s.colorSpace||i===h?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=s.isCompressedTexture||s.image[0].isCompressedTexture,f=s.image[0]&&s.image[0].isDataTexture,y=[];for(let e=0;e<6;e++)p||f?y[e]=f?s.image[e].image:s.image[e]:y[e]=m(s.image[e],!0,r.maxCubemapSize),y[e]=V(s,y[e]);let b=y[0],S=a.convert(s.format,s.colorSpace),M=a.convert(s.type),w=x(s.internalFormat,S,M,s.colorSpace),T=!0!==s.isVideoTexture,E=void 0===c.__version||!0===l,A=u.dataReady,C=_(s,b);if(R(e.TEXTURE_CUBE_MAP,s),p){T&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,C,w,b.width,b.height);for(let i=0;i<6;i++){t=y[i].mipmaps;for(let r=0;r<t.length;r++){let a=t[r];1023!==s.format?null!==S?T?A&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r,0,0,a.width,a.height,S,a.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r,w,a.width,a.height,0,a.data):eb("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):T?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r,0,0,a.width,a.height,S,M,a.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r,w,a.width,a.height,0,S,M,a.data)}}}else{if(t=s.mipmaps,T&&E){t.length>0&&C++;let i=H(y[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,C,w,i.width,i.height)}for(let i=0;i<6;i++)if(f){T?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,0,0,y[i].width,y[i].height,S,M,y[i].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,w,y[i].width,y[i].height,0,S,M,y[i].data);for(let r=0;r<t.length;r++){let a=t[r].image[i].image;T?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r+1,0,0,a.width,a.height,S,M,a.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r+1,w,a.width,a.height,0,S,M,a.data)}}else{T?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,0,0,S,M,y[i]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,w,S,M,y[i]);for(let r=0;r<t.length;r++){let a=t[r];T?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r+1,0,0,S,M,a.image[i]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,r+1,w,S,M,a.image[i])}}}g(s)&&v(e.TEXTURE_CUBE_MAP),c.__version=u.version,s.onUpdate&&s.onUpdate(s)}t.__version=s.version}(o,t,s):n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture,e.TEXTURE0+s)},this.rebindTextures=function(t,n,r){let a=i.get(t);void 0!==n&&N(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&O(t)},this.setupRenderTarget=function(t){let r=t.texture,o=i.get(t),l=i.get(r);t.addEventListener("dispose",S);let u=t.textures,c=!0===t.isWebGLCubeRenderTarget,h=u.length>1;if(!h&&(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),c){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[t][n]=e.createFramebuffer()}else o.__webglFramebuffer[t]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let t=0;t<r.mipmaps.length;t++)o.__webglFramebuffer[t]=e.createFramebuffer()}else o.__webglFramebuffer=e.createFramebuffer();if(h)for(let t=0,n=u.length;t<n;t++){let n=i.get(u[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),s.memory.textures++)}if(t.samples>0&&!1===B(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<u.length;n++){let i=u[n];o.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,o.__webglColorRenderbuffer[n]);let r=a.convert(i.format,i.colorSpace),s=a.convert(i.type),l=x(i.internalFormat,r,s,i.colorSpace,!0===t.isXRRenderTarget),c=k(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,c,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,o.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(o.__webglDepthRenderbuffer=e.createRenderbuffer(),D(o.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(c){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),R(e.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)N(o.__webglFramebuffer[n][i],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else N(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(r)&&v(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(h){for(let r=0,a=u.length;r<a;r++){let a=u[r],s=i.get(a),l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(l,s.__webglTexture),R(l,a),N(o.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+r,l,0),g(a)&&v(l)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),R(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)N(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,i,n);else N(o.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0,i,0);g(r)&&v(i),n.unbindTexture()}t.depthBuffer&&O(t)},this.updateRenderTargetMipmap=function(t){let r=t.textures;for(let a=0,s=r.length;a<s;a++){let s=r[a];if(g(s)){let r=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D,a=i.get(s).__webglTexture;n.bindTexture(r,a),v(r),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0){if(!1===B(t)){let r=t.textures,a=t.width,s=t.height,o=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=i.get(t),h=r.length>1;if(h)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);let d=t.texture.mipmaps;d&&d.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let n=0;n<r.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),h){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,c.__webglColorRenderbuffer[n]);let t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,s,0,0,a,s,o,e.NEAREST),!0===u&&(F.length=0,z.length=0,F.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(F.push(l),z.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,z)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,F))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),h)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,c.__webglColorRenderbuffer[t]);let a=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&u){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}}},this.setupDepthRenderbuffer=O,this.setupFrameBufferTexture=N,this.useMultisampledRTT=B,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function cO(e,t){return{convert:function(n,i=""){let r,a=eW.getTransfer(i);if(1009===n)return e.UNSIGNED_BYTE;if(1017===n)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===n)return e.UNSIGNED_SHORT_5_5_5_1;if(35902===n)return e.UNSIGNED_INT_5_9_9_9_REV;if(35899===n)return e.UNSIGNED_INT_10F_11F_11F_REV;if(1010===n)return e.BYTE;if(1011===n)return e.SHORT;if(1012===n)return e.UNSIGNED_SHORT;if(1013===n)return e.INT;if(1014===n)return e.UNSIGNED_INT;if(1015===n)return e.FLOAT;if(1016===n)return e.HALF_FLOAT;if(1021===n)return e.ALPHA;if(1022===n)return e.RGB;if(1023===n)return e.RGBA;if(1026===n)return e.DEPTH_COMPONENT;if(1027===n)return e.DEPTH_STENCIL;if(1028===n)return e.RED;if(1029===n)return e.RED_INTEGER;if(1030===n)return e.RG;if(1031===n)return e.RG_INTEGER;if(1033===n)return e.RGBA_INTEGER;if(33776===n||33777===n||33778===n||33779===n)if(a===ea){if(null===(r=t.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(33776===n)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(33777===n)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(33778===n)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(33779===n)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(r=t.get("WEBGL_compressed_texture_s3tc")))return null;if(33776===n)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===n)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===n)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===n)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===n||35841===n||35842===n||35843===n){if(null===(r=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(35840===n)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===n)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===n)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===n)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===n||37492===n||37496===n||37488===n||37489===n||37490===n||37491===n){if(null===(r=t.get("WEBGL_compressed_texture_etc")))return null;if(36196===n||37492===n)return a===ea?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(37496===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(37488===n)return r.COMPRESSED_R11_EAC;if(37489===n)return r.COMPRESSED_SIGNED_R11_EAC;if(37490===n)return r.COMPRESSED_RG11_EAC;if(37491===n)return r.COMPRESSED_SIGNED_RG11_EAC}if(37808===n||37809===n||37810===n||37811===n||37812===n||37813===n||37814===n||37815===n||37816===n||37817===n||37818===n||37819===n||37820===n||37821===n){if(null===(r=t.get("WEBGL_compressed_texture_astc")))return null;if(37808===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===n)return a===ea?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(36492===n||36494===n||36495===n){if(null===(r=t.get("EXT_texture_compression_bptc")))return null;if(36492===n)return a===ea?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(36494===n)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(36495===n)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===n||36284===n||36285===n||36286===n){if(null===(r=t.get("EXT_texture_compression_rgtc")))return null;if(36283===n)return r.COMPRESSED_RED_RGTC1_EXT;if(36284===n)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===n)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===n)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return 1020===n?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}let cF=`
363
+ void main() {
364
+
365
+ gl_Position = vec4( position, 1.0 );
366
+
367
+ }`,cz=`
368
+ uniform sampler2DArray depthColor;
369
+ uniform float depthWidth;
370
+ uniform float depthHeight;
371
+
372
+ void main() {
373
+
374
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
375
+
376
+ if ( coord.x >= 1.0 ) {
377
+
378
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
379
+
380
+ } else {
381
+
382
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
383
+
384
+ }
385
+
386
+ }`;class ck{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){let n=new rq(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){let t=e.cameras[0].viewport,n=new n1({vertexShader:cF,fragmentShader:cz,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new nY(new aj(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cB extends ew{constructor(e,t){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,u=null,c=null,h=null,d=null,p=null;const f="u">typeof XRWebGLBinding,m=new ck,g={},v=t.getContextAttributes();let x=null,y=null;const _=[],b=[],S=new eO;let M=null;const w=new n6;w.viewport=new e1;const T=new n6;T.viewport=new e1;const E=[w,T],A=new oi;let C=null,R=null;function P(e){let t=b.indexOf(e.inputSource);if(-1===t)return;let n=_[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function I(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",L);for(let e=0;e<_.length;e++){let t=b[e];null!==t&&(b[e]=null,_[e].disconnect(t))}for(let e in C=null,R=null,m.reset(),g)delete g[e];e.setRenderTarget(x),d=null,h=null,c=null,i=null,y=null,F.stop(),n.isPresenting=!1,e.setPixelRatio(M),e.setSize(S.width,S.height,!1),n.dispatchEvent({type:"sessionend"})}function L(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],i=b.indexOf(n);i>=0&&(b[i]=null,_[i].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],i=b.indexOf(n);if(-1===i){for(let e=0;e<_.length;e++)if(e>=b.length){b.push(n),i=e;break}else if(null===b[e]){b[e]=n,i=e;break}if(-1===i)break}let r=_[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return void 0===t&&(t=new ii,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new ii,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new ii,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&eb("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&eb("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return null===c&&f&&(c=new XRWebGLBinding(i,t)),c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(u){if(null!==(i=u)){if(x=e.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",I),i.addEventListener("inputsourceschange",L),!0!==v.xrCompatible&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(S),f&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,a=null,s=null;v.depth&&(s=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=v.stencil?1027:1026,a=v.stencil?1020:1014);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};h=(c=this.getBinding()).createProjectionLayer(o),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),y=new e3(h.textureWidth,h.textureHeight,{format:1023,type:1009,depthTexture:new rW(h.textureWidth,h.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:4*!!v.antialias,resolveDepthBuffer:!1===h.ignoreDepthValues,resolveStencilBuffer:!1===h.ignoreDepthValues})}else{let n={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),y=new e3(d.framebufferWidth,d.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),F.setContext(i),F.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const N=new ez,D=new ez;function U(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){var t,n,r;if(null===i)return;let a=e.near,s=e.far;null!==m.texture&&(m.depthNear>0&&(a=m.depthNear),m.depthFar>0&&(s=m.depthFar)),A.near=T.near=w.near=a,A.far=T.far=w.far=s,(C!==A.near||R!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|e.layers.mask,w.layers.mask=3&A.layers.mask,T.layers.mask=5&A.layers.mask;let o=e.parent,l=A.cameras;U(A,o);for(let e=0;e<l.length;e++)U(l[e],o);2===l.length?function(e,t,n){N.setFromMatrixPosition(t.matrixWorld),D.setFromMatrixPosition(n.matrixWorld);let i=N.distanceTo(D),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],u=(r[9]-1)/r[5],c=(r[8]-1)/r[0],h=(a[8]+1)/a[0],d=i/(-c+h),p=-(d*c);if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(p),e.translateZ(d),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=s+d,n=o+d;e.projectionMatrix.makePerspective(s*c-p,s*h+(i-p),l*o/n*t,u*o/n*t,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(A,w,T):A.projectionMatrix.copy(w.projectionMatrix),t=e,n=A,null===(r=o)?t.matrix.copy(n.matrixWorld):(t.matrix.copy(r.matrixWorld),t.matrix.invert(),t.matrix.multiply(n.matrixWorld)),t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(n.projectionMatrix),t.projectionMatrixInverse.copy(n.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*eC*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==h||null!==d)return o},this.setFoveation=function(e){o=e,null!==h&&(h.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==m.texture},this.getDepthSensingMesh=function(){return m.getMesh(A)},this.getCameraTexture=function(e){return g[e]};let O=null;const F=new lM;F.setAnimationLoop(function(t,r){if(u=r.getViewerPose(l||a),p=r,null!==u){let t=u.views;null!==d&&(e.setRenderTargetFramebuffer(y,d.framebuffer),e.setRenderTarget(y));let r=!1;t.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let n=0;n<t.length;n++){let i=t[n],a=null;if(null!==d)a=d.getViewport(i);else{let t=c.getViewSubImage(h,i);a=t.viewport,0===n&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let s=E[n];void 0===s&&((s=new n6).layers.enable(n),s.viewport=new e1,E[n]=s),s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(i.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===n&&(A.matrix.copy(s.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(s)}let a=i.enabledFeatures;if(a&&a.includes("depth-sensing")&&"gpu-optimized"==i.depthUsage&&f){let e=(c=n.getBinding()).getDepthInformation(t[0]);e&&e.isValid&&e.texture&&m.init(e,i.renderState)}if(a&&a.includes("camera-access")&&f){e.state.unbindTexture(),c=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new rq,g[n]=e);let t=c.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<_.length;e++){let t=b[e],n=_[e];null!==t&&void 0!==n&&n.update(t,r,l||a)}O&&O(t,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null}),this.setAnimationLoop=function(e){O=e},this.dispose=function(){}}}let cV=new tU,cH=new tT;function cj(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);let r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,cV.copy(s),cV.x*=-1,cV.y*=-1,cV.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(cV.y*=-1,cV.z*=-1),e.envMapRotation.value.setFromMatrix4(cH.makeRotationFromEuler(cV)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,nQ(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){var l,u,c,h,d,p,f,m,g,v,x,y,_,b,S,M,w,T,E,A,C,R,P;let I;r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),l=e,(u=r).gradientMap&&(l.gradientMap.value=u.gradientMap)):r.isMeshPhongMaterial?(i(e,r),c=e,h=r,c.specular.value.copy(h.specular),c.shininess.value=Math.max(h.shininess,1e-4)):r.isMeshStandardMaterial?(i(e,r),d=e,p=r,d.metalness.value=p.metalness,p.metalnessMap&&(d.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,d.metalnessMapTransform)),d.roughness.value=p.roughness,p.roughnessMap&&(d.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,d.roughnessMapTransform)),p.envMap&&(d.envMapIntensity.value=p.envMapIntensity),r.isMeshPhysicalMaterial&&(f=e,m=r,g=o,f.ior.value=m.ior,m.sheen>0&&(f.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),f.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(f.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,f.sheenColorMapTransform)),m.sheenRoughnessMap&&(f.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,f.sheenRoughnessMapTransform))),m.clearcoat>0&&(f.clearcoat.value=m.clearcoat,f.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(f.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,f.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(f.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),1===m.side&&f.clearcoatNormalScale.value.negate())),m.dispersion>0&&(f.dispersion.value=m.dispersion),m.iridescence>0&&(f.iridescence.value=m.iridescence,f.iridescenceIOR.value=m.iridescenceIOR,f.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(f.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,f.iridescenceMapTransform)),m.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),m.transmission>0&&(f.transmission.value=m.transmission,f.transmissionSamplerMap.value=g.texture,f.transmissionSamplerSize.value.set(g.width,g.height),m.transmissionMap&&(f.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,f.transmissionMapTransform)),f.thickness.value=m.thickness,m.thicknessMap&&(f.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=m.attenuationDistance,f.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(f.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(f.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=m.specularIntensity,f.specularColor.value.copy(m.specularColor),m.specularColorMap&&(f.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,f.specularColorMapTransform)),m.specularIntensityMap&&(f.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,f.specularIntensityMapTransform)))):r.isMeshMatcapMaterial?(i(e,r),v=e,(x=r).matcap&&(v.matcap.value=x.matcap)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),y=e,_=r,I=t.get(_).light,y.referencePosition.value.setFromMatrixPosition(I.matrixWorld),y.nearDistance.value=I.shadow.camera.near,y.farDistance.value=I.shadow.camera.far):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(b=e,S=r,b.diffuse.value.copy(S.color),b.opacity.value=S.opacity,S.map&&(b.map.value=S.map,n(S.map,b.mapTransform)),r.isLineDashedMaterial&&(M=e,w=r,M.dashSize.value=w.dashSize,M.totalSize.value=w.dashSize+w.gapSize,M.scale.value=w.scale)):r.isPointsMaterial?(T=e,E=r,A=a,C=s,T.diffuse.value.copy(E.color),T.opacity.value=E.opacity,T.size.value=E.size*A,T.scale.value=.5*C,E.map&&(T.map.value=E.map,n(E.map,T.uvTransform)),E.alphaMap&&(T.alphaMap.value=E.alphaMap,n(E.alphaMap,T.alphaMapTransform)),E.alphaTest>0&&(T.alphaTest.value=E.alphaTest)):r.isSpriteMaterial?(R=e,P=r,R.diffuse.value.copy(P.color),R.opacity.value=P.opacity,R.rotation.value=P.rotation,P.map&&(R.map.value=P.map,n(P.map,R.mapTransform)),P.alphaMap&&(R.alphaMap.value=P.alphaMap,n(P.alphaMap,R.alphaMapTransform)),P.alphaTest>0&&(R.alphaTest.value=P.alphaTest)):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function cG(e,t,n,i){let r={},a={},s=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e){let t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?eb("WebGLRenderer: Texture samplers can not be part of an uniforms group."):eb("WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){let n=t.target;n.removeEventListener("dispose",u);let i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){let n=t.program;i.uniformBlockBinding(e,n)},update:function(n,c){var h;let d,p,f,m,g=r[n.id];void 0===g&&(function(e){let t=e.uniforms,n=0;for(let e=0,i=t.length;e<i;e++){let i=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=i.length;e<t;e++){let t=i[e],r=Array.isArray(t.value)?t.value:[t.value];for(let e=0,i=r.length;e<i;e++){let i=l(r[e]),a=n%16,s=a%i.boundary,o=a+s;n+=s,0!==o&&16-o<i.storage&&(n+=16-o),t.__data=new Float32Array(i.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=i.storage}}}let i=n%16;i>0&&(n+=16-i),e.__size=n,e.__cache={}}(n),(h=n).__bindingPointIndex=d=function(){for(let e=0;e<o;e++)if(-1===s.indexOf(e))return s.push(e),e;return eS("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}(),p=e.createBuffer(),f=h.__size,m=h.usage,e.bindBuffer(e.UNIFORM_BUFFER,p),e.bufferData(e.UNIFORM_BUFFER,f,m),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,d,p),g=p,r[n.id]=g,n.addEventListener("dispose",u));let v=c.program;i.updateUBOMapping(n,v);let x=t.render.frame;a[n.id]!==x&&(function(t){let n=r[t.id],i=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=i.length;t<n;t++){let n=Array.isArray(i[t])?i[t]:[i[t]];for(let i=0,r=n.length;i<r;i++){let r=n[i];if(!0===function(e,t,n,i){let r=e.value,a=t+"_"+n;if(void 0===i[a])return"number"==typeof r||"boolean"==typeof r?i[a]=r:i[a]=r.clone(),!0;{let e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}(r,t,i,a)){let t=r.__offset,n=Array.isArray(r.value)?r.value:[r.value],i=0;for(let a=0;a<n.length;a++){let s=n[a],o=l(s);"number"==typeof s||"boolean"==typeof s?(r.__data[0]=s,e.bufferSubData(e.UNIFORM_BUFFER,t+i,r.__data)):s.isMatrix3?(r.__data[0]=s.elements[0],r.__data[1]=s.elements[1],r.__data[2]=s.elements[2],r.__data[3]=0,r.__data[4]=s.elements[3],r.__data[5]=s.elements[4],r.__data[6]=s.elements[5],r.__data[7]=0,r.__data[8]=s.elements[6],r.__data[9]=s.elements[7],r.__data[10]=s.elements[8],r.__data[11]=0):(s.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,r.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=x)},dispose:function(){for(let t in r)e.deleteBuffer(r[t]);s=[],r={},a={}}}}let cW=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]),cX=null;class cq{constructor(e={}){let t,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g,v,x,y,_,b,S,M,w,T;const{canvas:E=em(),context:A=null,depth:C=!0,stencil:R=!1,alpha:P=!1,antialias:I=!1,premultipliedAlpha:L=!0,preserveDrawingBuffer:N=!1,powerPreference:D="default",failIfMajorPerformanceCaveat:U=!1,reversedDepthBuffer:O=!1,outputBufferType:F=1009}=e;if(this.isWebGLRenderer=!0,null!==A){if("u">typeof WebGLRenderingContext&&A instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");t=A.getContextAttributes().alpha}else t=P;const z=new Set([1033,1031,1029]),k=new Set([1009,1014,1012,1020,1017,1018]),B=new Uint32Array(4),V=new Int32Array(4);let H=null,j=null;const G=[],W=[];let X=null;this.domElement=E,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const q=this;let Y=!1;this._outputColorSpace=en;let Z=0,J=0,$=null,K=-1,Q=null;const ee=new e1,et=new e1;let er=null;const ea=new no(0);let es=0,eo=E.width,el=E.height,eu=1,ec=null,eh=null;const ed=new e1(0,0,eo,el),ep=new e1(0,0,eo,el);let ef=!1;const eg=new i6;let ev=!1,ex=!1;const ey=new tT,ew=new ez,eT=new e1,eE={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let eA=!1;function eC(){return null===$?eu:1}let eR=A;function eP(e,t){return E.getContext(e,t)}try{if("setAttribute"in E&&E.setAttribute("data-engine","three.js r182"),E.addEventListener("webglcontextlost",eN,!1),E.addEventListener("webglcontextrestored",eD,!1),E.addEventListener("webglcontextcreationerror",eU,!1),null===eR){const e="webgl2";if(eR=eP(e,{alpha:!0,depth:C,stencil:R,antialias:I,premultipliedAlpha:L,preserveDrawingBuffer:N,powerPreference:D,failIfMajorPerformanceCaveat:U}),null===eR)if(eP(e))throw Error("Error creating WebGL context with your selected attributes.");else throw Error("Error creating WebGL context.")}}catch(e){throw eS("WebGLRenderer: "+e.message),e}function eI(){(n=new lK(eR)).init(),M=new cO(eR,n),i=new lD(eR,n,e,M),r=new cD(eR,n),i.reversedDepthBuffer&&O&&r.buffers.depth.setReversed(!0),a=new l1(eR),s=new cg,o=new cU(eR,n,r,s,i,M,a),l=new lO(q),u=new l$(q),c=new lw(eR),w=new lL(eR,c),h=new lQ(eR,c,a,w),d=new l3(eR,h,c,a),_=new l2(eR,i,o),v=new lU(s),p=new cm(q,l,u,n,i,w,v),f=new cj(q,s),m=new c_,g=new cE(n),y=new lI(q,l,u,r,d,t,L),x=new cL(q,d,i),T=new cG(eR,a,i,r),b=new lN(eR,n,a),S=new l0(eR,n,a),a.programs=p.programs,q.capabilities=i,q.extensions=n,q.properties=s,q.renderLists=m,q.shadowMap=x,q.state=r,q.info=a}eI(),1009!==F&&(X=new l5(F,E.width,E.height,C,R));const eL=new cB(q,eR);function eN(e){e.preventDefault(),e_("WebGLRenderer: Context Lost."),Y=!0}function eD(){e_("WebGLRenderer: Context Restored."),Y=!1;let e=a.autoReset,t=x.enabled,n=x.autoUpdate,i=x.needsUpdate,r=x.type;eI(),a.autoReset=e,x.enabled=t,x.autoUpdate=n,x.needsUpdate=i,x.type=r}function eU(e){eS("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function eO(e){var t,n;let i,r=e.target;r.removeEventListener("dispose",eO),n=t=r,void 0!==(i=s.get(n).programs)&&(i.forEach(function(e){p.releaseProgram(e)}),n.isShaderMaterial&&p.releaseShaderCache(n)),s.remove(t)}function eF(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,eZ(e,t,n),e.side=0,e.needsUpdate=!0,eZ(e,t,n),e.side=2):eZ(e,t,n)}this.xr=eL,this.getContext=function(){return eR},this.getContextAttributes=function(){return eR.getContextAttributes()},this.forceContextLoss=function(){let e=n.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=n.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return eu},this.setPixelRatio=function(e){void 0!==e&&(eu=e,this.setSize(eo,el,!1))},this.getSize=function(e){return e.set(eo,el)},this.setSize=function(e,t,n=!0){eL.isPresenting?eb("WebGLRenderer: Can't change size while VR device is presenting."):(eo=e,el=t,E.width=Math.floor(e*eu),E.height=Math.floor(t*eu),!0===n&&(E.style.width=e+"px",E.style.height=t+"px"),null!==X&&X.setSize(E.width,E.height),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(eo*eu,el*eu).floor()},this.setDrawingBufferSize=function(e,t,n){eo=e,el=t,eu=n,E.width=Math.floor(e*n),E.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.setEffects=function(e){if(1009===F)return void console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");if(e){for(let t=0;t<e.length;t++)if(!0===e[t].isOutputPass){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}X.setEffects(e||[])},this.getCurrentViewport=function(e){return e.copy(ee)},this.getViewport=function(e){return e.copy(ed)},this.setViewport=function(e,t,n,i){e.isVector4?ed.set(e.x,e.y,e.z,e.w):ed.set(e,t,n,i),r.viewport(ee.copy(ed).multiplyScalar(eu).round())},this.getScissor=function(e){return e.copy(ep)},this.setScissor=function(e,t,n,i){e.isVector4?ep.set(e.x,e.y,e.z,e.w):ep.set(e,t,n,i),r.scissor(et.copy(ep).multiplyScalar(eu).round())},this.getScissorTest=function(){return ef},this.setScissorTest=function(e){r.setScissorTest(ef=e)},this.setOpaqueSort=function(e){ec=e},this.setTransparentSort=function(e){eh=e},this.getClearColor=function(e){return e.copy(y.getClearColor())},this.setClearColor=function(){y.setClearColor(...arguments)},this.getClearAlpha=function(){return y.getClearAlpha()},this.setClearAlpha=function(){y.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==$){let t=$.texture.format;e=z.has(t)}if(e){let e=$.texture.type,t=k.has(e),n=y.getClearColor(),i=y.getClearAlpha(),r=n.r,a=n.g,s=n.b;t?(B[0]=r,B[1]=a,B[2]=s,B[3]=i,eR.clearBufferuiv(eR.COLOR,0,B)):(V[0]=r,V[1]=a,V[2]=s,V[3]=i,eR.clearBufferiv(eR.COLOR,0,V))}else i|=eR.COLOR_BUFFER_BIT}t&&(i|=eR.DEPTH_BUFFER_BIT),n&&(i|=eR.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(0xffffffff)),eR.clear(i)},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.dispose=function(){E.removeEventListener("webglcontextlost",eN,!1),E.removeEventListener("webglcontextrestored",eD,!1),E.removeEventListener("webglcontextcreationerror",eU,!1),y.dispose(),m.dispose(),g.dispose(),s.dispose(),l.dispose(),u.dispose(),d.dispose(),w.dispose(),T.dispose(),p.dispose(),eL.dispose(),eL.removeEventListener("sessionstart",eB),eL.removeEventListener("sessionend",eV),eH.stop()},this.renderBufferDirect=function(e,t,a,d,p,m){let g;null===t&&(t=eE);let x=p.isMesh&&0>p.matrixWorld.determinant(),y=function(e,t,n,a,c){var h,d;!0!==t.isScene&&(t=eE),o.resetTextureUnits();let p=t.fog,m=a.isMeshStandardMaterial?t.environment:null,g=null===$?q.outputColorSpace:!0===$.isXRRenderTarget?$.texture.colorSpace:ei,x=(a.isMeshStandardMaterial?u:l).get(a.envMap||m),y=!0===a.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,b=!!n.attributes.tangent&&(!!a.normalMap||a.anisotropy>0),S=!!n.morphAttributes.position,M=!!n.morphAttributes.normal,w=!!n.morphAttributes.color,E=0;a.toneMapped&&(null===$||!0===$.isXRRenderTarget)&&(E=q.toneMapping);let A=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,C=void 0!==A?A.length:0,R=s.get(a),P=j.state.lights;if(!0===ev&&(!0===ex||e!==Q)){let t=e===Q&&a.id===K;v.setState(a,e,t)}let I=!1;a.version===R.__version?R.needsLights&&R.lightsStateVersion!==P.state.version||R.outputColorSpace!==g||c.isBatchedMesh&&!1===R.batching?I=!0:c.isBatchedMesh||!0!==R.batching?c.isBatchedMesh&&!0===R.batchingColor&&null===c.colorTexture||c.isBatchedMesh&&!1===R.batchingColor&&null!==c.colorTexture||c.isInstancedMesh&&!1===R.instancing?I=!0:c.isInstancedMesh||!0!==R.instancing?c.isSkinnedMesh&&!1===R.skinning?I=!0:c.isSkinnedMesh||!0!==R.skinning?c.isInstancedMesh&&!0===R.instancingColor&&null===c.instanceColor||c.isInstancedMesh&&!1===R.instancingColor&&null!==c.instanceColor||c.isInstancedMesh&&!0===R.instancingMorph&&null===c.morphTexture||c.isInstancedMesh&&!1===R.instancingMorph&&null!==c.morphTexture||R.envMap!==x||!0===a.fog&&R.fog!==p||void 0!==R.numClippingPlanes&&(R.numClippingPlanes!==v.numPlanes||R.numIntersection!==v.numIntersection)||R.vertexAlphas!==y||R.vertexTangents!==b||R.morphTargets!==S||R.morphNormals!==M||R.morphColors!==w||R.toneMapping!==E?I=!0:R.morphTargetsCount!==C&&(I=!0):I=!0:I=!0:I=!0:(I=!0,R.__version=a.version);let L=R.currentProgram;!0===I&&(L=eZ(a,t,c));let N=!1,D=!1,U=!1,O=L.getUniforms(),F=R.uniforms;if(r.useProgram(L.program)&&(N=!0,D=!0,U=!0),a.id!==K&&(K=a.id,D=!0),N||Q!==e){r.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(eR,"projectionMatrix",e.projectionMatrix),O.setValue(eR,"viewMatrix",e.matrixWorldInverse);let t=O.map.cameraPosition;void 0!==t&&t.setValue(eR,ew.setFromMatrixPosition(e.matrixWorld)),i.logarithmicDepthBuffer&&O.setValue(eR,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(a.isMeshPhongMaterial||a.isMeshToonMaterial||a.isMeshLambertMaterial||a.isMeshBasicMaterial||a.isMeshStandardMaterial||a.isShaderMaterial)&&O.setValue(eR,"isOrthographic",!0===e.isOrthographicCamera),Q!==e&&(Q=e,D=!0,U=!0)}if(R.needsLights&&(P.state.directionalShadowMap.length>0&&O.setValue(eR,"directionalShadowMap",P.state.directionalShadowMap,o),P.state.spotShadowMap.length>0&&O.setValue(eR,"spotShadowMap",P.state.spotShadowMap,o),P.state.pointShadowMap.length>0&&O.setValue(eR,"pointShadowMap",P.state.pointShadowMap,o)),c.isSkinnedMesh){O.setOptional(eR,c,"bindMatrix"),O.setOptional(eR,c,"bindMatrixInverse");let e=c.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),O.setValue(eR,"boneTexture",e.boneTexture,o))}c.isBatchedMesh&&(O.setOptional(eR,c,"batchingTexture"),O.setValue(eR,"batchingTexture",c._matricesTexture,o),O.setOptional(eR,c,"batchingIdTexture"),O.setValue(eR,"batchingIdTexture",c._indirectTexture,o),O.setOptional(eR,c,"batchingColorTexture"),null!==c._colorsTexture&&O.setValue(eR,"batchingColorTexture",c._colorsTexture,o));let z=n.morphAttributes;if((void 0!==z.position||void 0!==z.normal||void 0!==z.color)&&_.update(c,n,L),(D||R.receiveShadow!==c.receiveShadow)&&(R.receiveShadow=c.receiveShadow,O.setValue(eR,"receiveShadow",c.receiveShadow)),a.isMeshGouraudMaterial&&null!==a.envMap&&(F.envMap.value=x,F.flipEnvMap.value=x.isCubeTexture&&!1===x.isRenderTargetTexture?-1:1),a.isMeshStandardMaterial&&null===a.envMap&&null!==t.environment&&(F.envMapIntensity.value=t.environmentIntensity),void 0!==F.dfgLUT&&(F.dfgLUT.value=(null===cX&&((cX=new iB(cW,16,16,1030,1016)).name="DFG_LUT",cX.minFilter=1006,cX.magFilter=1006,cX.wrapS=1001,cX.wrapT=1001,cX.generateMipmaps=!1,cX.needsUpdate=!0),cX)),D&&(O.setValue(eR,"toneMappingExposure",q.toneMappingExposure),R.needsLights&&(h=F,d=U,h.ambientLightColor.needsUpdate=d,h.lightProbe.needsUpdate=d,h.directionalLights.needsUpdate=d,h.directionalLightShadows.needsUpdate=d,h.pointLights.needsUpdate=d,h.pointLightShadows.needsUpdate=d,h.spotLights.needsUpdate=d,h.spotLightShadows.needsUpdate=d,h.rectAreaLights.needsUpdate=d,h.hemisphereLights.needsUpdate=d),p&&!0===a.fog&&f.refreshFogUniforms(F,p),f.refreshMaterialUniforms(F,a,eu,el,j.state.transmissionRenderTarget[e.id]),uQ.upload(eR,eJ(R),F,o)),a.isShaderMaterial&&!0===a.uniformsNeedUpdate&&(uQ.upload(eR,eJ(R),F,o),a.uniformsNeedUpdate=!1),a.isSpriteMaterial&&O.setValue(eR,"center",c.center),O.setValue(eR,"modelViewMatrix",c.modelViewMatrix),O.setValue(eR,"normalMatrix",c.normalMatrix),O.setValue(eR,"modelMatrix",c.matrixWorld),a.isShaderMaterial||a.isRawShaderMaterial){let e=a.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];T.update(n,L),T.bind(n,L)}}return L}(e,t,a,d,p);r.setMaterial(d,x);let M=a.index,E=1;if(!0===d.wireframe){if(void 0===(M=h.getWireframeAttribute(a)))return;E=2}let A=a.drawRange,C=a.attributes.position,R=A.start*E,P=(A.start+A.count)*E;null!==m&&(R=Math.max(R,m.start*E),P=Math.min(P,(m.start+m.count)*E)),null!==M?(R=Math.max(R,0),P=Math.min(P,M.count)):null!=C&&(R=Math.max(R,0),P=Math.min(P,C.count));let I=P-R;if(I<0||I===1/0)return;w.setup(p,d,y,a,M);let L=b;if(null!==M&&(g=c.get(M),(L=S).setIndex(g)),p.isMesh)!0===d.wireframe?(r.setLineWidth(d.wireframeLinewidth*eC()),L.setMode(eR.LINES)):L.setMode(eR.TRIANGLES);else if(p.isLine){let e=d.linewidth;void 0===e&&(e=1),r.setLineWidth(e*eC()),p.isLineSegments?L.setMode(eR.LINES):p.isLineLoop?L.setMode(eR.LINE_LOOP):L.setMode(eR.LINE_STRIP)}else p.isPoints?L.setMode(eR.POINTS):p.isSprite&&L.setMode(eR.TRIANGLES);if(p.isBatchedMesh)if(null!==p._multiDrawInstances)eM("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),L.renderMultiDrawInstances(p._multiDrawStarts,p._multiDrawCounts,p._multiDrawCount,p._multiDrawInstances);else if(n.get("WEBGL_multi_draw"))L.renderMultiDraw(p._multiDrawStarts,p._multiDrawCounts,p._multiDrawCount);else{let e=p._multiDrawStarts,t=p._multiDrawCounts,n=p._multiDrawCount,i=M?c.get(M).bytesPerElement:1,r=s.get(d).currentProgram.getUniforms();for(let a=0;a<n;a++)r.setValue(eR,"_gl_DrawID",a),L.render(e[a]/i,t[a])}else if(p.isInstancedMesh)L.renderInstances(R,I,p.count);else if(a.isInstancedBufferGeometry){let e=void 0!==a._maxInstanceCount?a._maxInstanceCount:1/0,t=Math.min(a.instanceCount,e);L.renderInstances(R,I,t)}else L.render(R,I)},this.compile=function(e,t,n=null){null===n&&(n=e),(j=g.get(n)).init(t),W.push(j),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(j.pushLight(e),e.castShadow&&j.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(j.pushLight(e),e.castShadow&&j.pushShadow(e))}),j.setupLights();let i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++){let a=t[r];eF(a,n,e),i.add(a)}else eF(t,n,e),i.add(t)}),j=W.pop(),i},this.compileAsync=function(e,t,i=null){let r=this.compile(e,t,i);return new Promise(t=>{function i(){(r.forEach(function(e){s.get(e).currentProgram.isReady()&&r.delete(e)}),0===r.size)?t(e):setTimeout(i,10)}null!==n.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let ek=null;function eB(){eH.stop()}function eV(){eH.start()}const eH=new lM;function ej(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)j.pushLight(e),e.castShadow&&j.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||eg.intersectsSprite(e)){i&&eT.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ey);let t=d.update(e),r=e.material;r.visible&&H.push(e,t,r,n,eT.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||eg.intersectsObject(e))){let t=d.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),eT.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),eT.copy(t.boundingSphere.center)),eT.applyMatrix4(e.matrixWorld).applyMatrix4(ey)),Array.isArray(r)){let i=t.groups;for(let a=0,s=i.length;a<s;a++){let s=i[a],o=r[s.materialIndex];o&&o.visible&&H.push(e,t,o,n,eT.z,s)}}else r.visible&&H.push(e,t,r,n,eT.z,null)}}let r=e.children;for(let e=0,a=r.length;e<a;e++)ej(r[e],t,n,i)}function eG(e,t,n,i){let{opaque:a,transmissive:s,transparent:o}=e;j.setupLightsView(n),!0===ev&&v.setGlobalState(q.clippingPlanes,n),i&&r.viewport(ee.copy(i)),a.length>0&&eq(a,t,n),s.length>0&&eq(s,t,n),o.length>0&&eq(o,t,n),r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),r.setPolygonOffset(!1)}function eX(e,t,r,a){if(null!==(!0===r.isScene?r.overrideMaterial:null))return;if(void 0===j.state.transmissionRenderTarget[a.id]){let e=n.has("EXT_color_buffer_half_float")||n.has("EXT_color_buffer_float");j.state.transmissionRenderTarget[a.id]=new e3(1,1,{generateMipmaps:!0,type:e?1016:1009,minFilter:1008,samples:i.samples,stencilBuffer:R,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:eW.workingColorSpace})}let s=j.state.transmissionRenderTarget[a.id],l=a.viewport||ee;s.setSize(l.z*q.transmissionResolutionScale,l.w*q.transmissionResolutionScale);let u=q.getRenderTarget(),c=q.getActiveCubeFace(),h=q.getActiveMipmapLevel();q.setRenderTarget(s),q.getClearColor(ea),(es=q.getClearAlpha())<1&&q.setClearColor(0xffffff,.5),q.clear(),eA&&y.render(r);let d=q.toneMapping;q.toneMapping=0;let p=a.viewport;if(void 0!==a.viewport&&(a.viewport=void 0),j.setupLightsView(a),!0===ev&&v.setGlobalState(q.clippingPlanes,a),eq(e,r,a),o.updateMultisampleRenderTarget(s),o.updateRenderTargetMipmap(s),!1===n.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let n=0,i=t.length;n<i;n++){let{object:i,geometry:s,material:o,group:l}=t[n];if(2===o.side&&i.layers.test(a.layers)){let t=o.side;o.side=1,o.needsUpdate=!0,eY(i,r,a,s,o,l),o.side=t,o.needsUpdate=!0,e=!0}}!0===e&&(o.updateMultisampleRenderTarget(s),o.updateRenderTargetMipmap(s))}q.setRenderTarget(u,c,h),q.setClearColor(ea,es),void 0!==p&&(a.viewport=p),q.toneMapping=d}function eq(e,t,n){let i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r<a;r++){let a=e[r],{object:s,geometry:o,group:l}=a,u=a.material;!0===u.allowOverride&&null!==i&&(u=i),s.layers.test(n.layers)&&eY(s,t,n,o,u,l)}}function eY(e,t,n,i,r,a){e.onBeforeRender(q,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(q,t,n,i,e,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,q.renderBufferDirect(n,t,i,r,e,a),r.side=0,r.needsUpdate=!0,q.renderBufferDirect(n,t,i,r,e,a),r.side=2):q.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(q,t,n,i,r,a)}function eZ(e,t,n){var i;!0!==t.isScene&&(t=eE);let r=s.get(e),a=j.state.lights,o=j.state.shadowsArray,c=a.state.version,h=p.getParameters(e,a.state,o,t,n),d=p.getProgramCacheKey(h),f=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?u:l).get(e.envMap||r.environment),r.envMapRotation=null!==r.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===f&&(e.addEventListener("dispose",eO),r.programs=f=new Map);let m=f.get(d);if(void 0!==m){if(r.currentProgram===m&&r.lightsStateVersion===c)return e$(e,h),m}else h.uniforms=p.getUniforms(e),e.onBeforeCompile(h,q),m=p.acquireProgram(h,d),f.set(d,m),r.uniforms=h.uniforms;let g=r.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(g.clippingPlanes=v.uniform),e$(e,h),r.needsLights=(i=e).isMeshLambertMaterial||i.isMeshToonMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isShadowMaterial||i.isShaderMaterial&&!0===i.lights,r.lightsStateVersion=c,r.needsLights&&(g.ambientLightColor.value=a.state.ambient,g.lightProbe.value=a.state.probe,g.directionalLights.value=a.state.directional,g.directionalLightShadows.value=a.state.directionalShadow,g.spotLights.value=a.state.spot,g.spotLightShadows.value=a.state.spotShadow,g.rectAreaLights.value=a.state.rectArea,g.ltc_1.value=a.state.rectAreaLTC1,g.ltc_2.value=a.state.rectAreaLTC2,g.pointLights.value=a.state.point,g.pointLightShadows.value=a.state.pointShadow,g.hemisphereLights.value=a.state.hemi,g.directionalShadowMap.value=a.state.directionalShadowMap,g.directionalShadowMatrix.value=a.state.directionalShadowMatrix,g.spotShadowMap.value=a.state.spotShadowMap,g.spotLightMatrix.value=a.state.spotLightMatrix,g.spotLightMap.value=a.state.spotLightMap,g.pointShadowMap.value=a.state.pointShadowMap,g.pointShadowMatrix.value=a.state.pointShadowMatrix),r.currentProgram=m,r.uniformsList=null,m}function eJ(e){if(null===e.uniformsList){let t=e.currentProgram.getUniforms();e.uniformsList=uQ.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function e$(e,t){let n=s.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}eH.setAnimationLoop(function(e){ek&&ek(e)}),"u">typeof self&&eH.setContext(self),this.setAnimationLoop=function(e){ek=e,eL.setAnimationLoop(e),null===e?eH.stop():eH.start()},eL.addEventListener("sessionstart",eB),eL.addEventListener("sessionend",eV),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void eS("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===Y)return;let n=!0===eL.enabled&&!0===eL.isPresenting,i=null!==X&&(null===$||n)&&X.begin(q,$);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===eL.enabled&&!0===eL.isPresenting&&(null===X||!1===X.isCompositing())&&(!0===eL.cameraAutoUpdate&&eL.updateCamera(t),t=eL.getCamera()),!0===e.isScene&&e.onBeforeRender(q,e,t,$),(j=g.get(e,W.length)).init(t),W.push(j),ey.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),eg.setFromProjectionMatrix(ey,2e3,t.reversedDepth),ex=this.localClippingEnabled,ev=v.init(this.clippingPlanes,ex),(H=m.get(e,G.length)).init(),G.push(H),!0===eL.enabled&&!0===eL.isPresenting){let e=q.xr.getDepthSensingMesh();null!==e&&ej(e,t,-1/0,q.sortObjects)}ej(e,t,0,q.sortObjects),H.finish(),!0===q.sortObjects&&H.sort(ec,eh),(eA=!1===eL.enabled||!1===eL.isPresenting||!1===eL.hasDepthSensing())&&y.addToRenderList(H,e),this.info.render.frame++,!0===ev&&v.beginShadows();let r=j.state.shadowsArray;if(x.render(r,e,t),!0===ev&&v.endShadows(),!0===this.info.autoReset&&this.info.reset(),!1===(i&&X.hasRenderPass())){let n=H.opaque,i=H.transmissive;if(j.setupLights(),t.isArrayCamera){let r=t.cameras;if(i.length>0)for(let t=0,a=r.length;t<a;t++)eX(n,i,e,r[t]);eA&&y.render(e);for(let t=0,n=r.length;t<n;t++){let n=r[t];eG(H,e,n,n.viewport)}}else i.length>0&&eX(n,i,e,t),eA&&y.render(e),eG(H,e,t)}null!==$&&0===J&&(o.updateMultisampleRenderTarget($),o.updateRenderTargetMipmap($)),i&&X.end(q),!0===e.isScene&&e.onAfterRender(q,e,t),w.resetDefaultState(),K=-1,Q=null,W.pop(),W.length>0?(j=W[W.length-1],!0===ev&&v.setGlobalState(q.clippingPlanes,j.state.camera)):j=null,G.pop(),H=G.length>0?G[G.length-1]:null},this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return J},this.getRenderTarget=function(){return $},this.setRenderTargetTextures=function(e,t,n){let i=s.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),s.get(e.texture).__webglTexture=t,s.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=s.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const eK=eR.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){$=e,Z=t,J=n;let i=null,a=!1,l=!1;if(e){let u=s.get(e);if(void 0!==u.__useDefaultFramebuffer){r.bindFramebuffer(eR.FRAMEBUFFER,u.__webglFramebuffer),ee.copy(e.viewport),et.copy(e.scissor),er=e.scissorTest,r.viewport(ee),r.scissor(et),r.setScissorTest(er),K=-1;return}if(void 0===u.__webglFramebuffer)o.setupRenderTarget(e);else if(u.__hasExternalTextures)o.rebindTextures(e,s.get(e.texture).__webglTexture,s.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(u.__boundDepthTexture!==t){if(null!==t&&s.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");o.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(l=!0);let h=s.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(h[t])?h[t][n]:h[t],a=!0):i=e.samples>0&&!1===o.useMultisampledRTT(e)?s.get(e).__webglMultisampledFramebuffer:Array.isArray(h)?h[n]:h,ee.copy(e.viewport),et.copy(e.scissor),er=e.scissorTest}else ee.copy(ed).multiplyScalar(eu).floor(),et.copy(ep).multiplyScalar(eu).floor(),er=ef;if(0!==n&&(i=eK),r.bindFramebuffer(eR.FRAMEBUFFER,i)&&r.drawBuffers(e,i),r.viewport(ee),r.scissor(et),r.setScissorTest(er),a){let i=s.get(e.texture);eR.framebufferTexture2D(eR.FRAMEBUFFER,eR.COLOR_ATTACHMENT0,eR.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(l)for(let i=0;i<e.textures.length;i++){let r=s.get(e.textures[i]);eR.framebufferTextureLayer(eR.FRAMEBUFFER,eR.COLOR_ATTACHMENT0+i,r.__webglTexture,n,t)}else if(null!==e&&0!==n){let t=s.get(e.texture);eR.framebufferTexture2D(eR.FRAMEBUFFER,eR.COLOR_ATTACHMENT0,eR.TEXTURE_2D,t.__webglTexture,n)}K=-1},this.readRenderTargetPixels=function(e,t,n,a,o,l,u,c=0){if(!(e&&e.isWebGLRenderTarget))return void eS("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=s.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==u&&(h=h[u]),h){r.bindFramebuffer(eR.FRAMEBUFFER,h);try{let r=e.textures[c],s=r.format,u=r.type;if(!i.textureFormatReadable(s))return void eS("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!i.textureTypeReadable(u))return void eS("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-a&&n>=0&&n<=e.height-o&&(e.textures.length>1&&eR.readBuffer(eR.COLOR_ATTACHMENT0+c),eR.readPixels(t,n,a,o,M.convert(s),M.convert(u),l))}finally{let e=null!==$?s.get($).__webglFramebuffer:null;r.bindFramebuffer(eR.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,a,o,l,u,c=0){if(!(e&&e.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=s.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==u&&(h=h[u]),h)if(t>=0&&t<=e.width-a&&n>=0&&n<=e.height-o){var d;r.bindFramebuffer(eR.FRAMEBUFFER,h);let u=e.textures[c],p=u.format,f=u.type;if(!i.textureFormatReadable(p))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!i.textureTypeReadable(f))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let m=eR.createBuffer();eR.bindBuffer(eR.PIXEL_PACK_BUFFER,m),eR.bufferData(eR.PIXEL_PACK_BUFFER,l.byteLength,eR.STREAM_READ),e.textures.length>1&&eR.readBuffer(eR.COLOR_ATTACHMENT0+c),eR.readPixels(t,n,a,o,M.convert(p),M.convert(f),0);let g=null!==$?s.get($).__webglFramebuffer:null;r.bindFramebuffer(eR.FRAMEBUFFER,g);let v=eR.fenceSync(eR.SYNC_GPU_COMMANDS_COMPLETE,0);return eR.flush(),await (d=eR,new Promise(function(e,t){setTimeout(function n(){switch(d.clientWaitSync(v,d.SYNC_FLUSH_COMMANDS_BIT,0)){case d.WAIT_FAILED:t();break;case d.TIMEOUT_EXPIRED:setTimeout(n,4);break;default:e()}},4)})),eR.bindBuffer(eR.PIXEL_PACK_BUFFER,m),eR.getBufferSubData(eR.PIXEL_PACK_BUFFER,0,l),eR.deleteBuffer(m),eR.deleteSync(v),l}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(e,t=null,n=0){let i=Math.pow(2,-n),a=Math.floor(e.image.width*i),s=Math.floor(e.image.height*i),l=null!==t?t.x:0,u=null!==t?t.y:0;o.setTexture2D(e,0),eR.copyTexSubImage2D(eR.TEXTURE_2D,n,0,0,l,u,a,s),r.unbindTexture()};const eQ=eR.createFramebuffer(),e0=eR.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,a=0,l=null){let u,c,h,d,p,f,m,g,v,x;null===l&&(0!==a?(eM("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),l=a,a=0):l=0);let y=e.isCompressedTexture?e.mipmaps[l]:e.image;if(null!==n)u=n.max.x-n.min.x,c=n.max.y-n.min.y,h=n.isBox3?n.max.z-n.min.z:1,d=n.min.x,p=n.min.y,f=n.isBox3?n.min.z:0;else{let t=Math.pow(2,-a);u=Math.floor(y.width*t),c=Math.floor(y.height*t),h=e.isDataArrayTexture?y.depth:e.isData3DTexture?Math.floor(y.depth*t):1,d=0,p=0,f=0}null!==i?(m=i.x,g=i.y,v=i.z):(m=0,g=0,v=0);let _=M.convert(t.format),b=M.convert(t.type);t.isData3DTexture?(o.setTexture3D(t,0),x=eR.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(o.setTexture2DArray(t,0),x=eR.TEXTURE_2D_ARRAY):(o.setTexture2D(t,0),x=eR.TEXTURE_2D),eR.pixelStorei(eR.UNPACK_FLIP_Y_WEBGL,t.flipY),eR.pixelStorei(eR.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),eR.pixelStorei(eR.UNPACK_ALIGNMENT,t.unpackAlignment);let S=eR.getParameter(eR.UNPACK_ROW_LENGTH),w=eR.getParameter(eR.UNPACK_IMAGE_HEIGHT),T=eR.getParameter(eR.UNPACK_SKIP_PIXELS),E=eR.getParameter(eR.UNPACK_SKIP_ROWS),A=eR.getParameter(eR.UNPACK_SKIP_IMAGES);eR.pixelStorei(eR.UNPACK_ROW_LENGTH,y.width),eR.pixelStorei(eR.UNPACK_IMAGE_HEIGHT,y.height),eR.pixelStorei(eR.UNPACK_SKIP_PIXELS,d),eR.pixelStorei(eR.UNPACK_SKIP_ROWS,p),eR.pixelStorei(eR.UNPACK_SKIP_IMAGES,f);let C=e.isDataArrayTexture||e.isData3DTexture,R=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=s.get(e),i=s.get(t),o=s.get(n.__renderTarget),x=s.get(i.__renderTarget);r.bindFramebuffer(eR.READ_FRAMEBUFFER,o.__webglFramebuffer),r.bindFramebuffer(eR.DRAW_FRAMEBUFFER,x.__webglFramebuffer);for(let n=0;n<h;n++)C&&(eR.framebufferTextureLayer(eR.READ_FRAMEBUFFER,eR.COLOR_ATTACHMENT0,s.get(e).__webglTexture,a,f+n),eR.framebufferTextureLayer(eR.DRAW_FRAMEBUFFER,eR.COLOR_ATTACHMENT0,s.get(t).__webglTexture,l,v+n)),eR.blitFramebuffer(d,p,u,c,m,g,u,c,eR.DEPTH_BUFFER_BIT,eR.NEAREST);r.bindFramebuffer(eR.READ_FRAMEBUFFER,null),r.bindFramebuffer(eR.DRAW_FRAMEBUFFER,null)}else if(0!==a||e.isRenderTargetTexture||s.has(e)){let n=s.get(e),i=s.get(t);r.bindFramebuffer(eR.READ_FRAMEBUFFER,eQ),r.bindFramebuffer(eR.DRAW_FRAMEBUFFER,e0);for(let e=0;e<h;e++)C?eR.framebufferTextureLayer(eR.READ_FRAMEBUFFER,eR.COLOR_ATTACHMENT0,n.__webglTexture,a,f+e):eR.framebufferTexture2D(eR.READ_FRAMEBUFFER,eR.COLOR_ATTACHMENT0,eR.TEXTURE_2D,n.__webglTexture,a),R?eR.framebufferTextureLayer(eR.DRAW_FRAMEBUFFER,eR.COLOR_ATTACHMENT0,i.__webglTexture,l,v+e):eR.framebufferTexture2D(eR.DRAW_FRAMEBUFFER,eR.COLOR_ATTACHMENT0,eR.TEXTURE_2D,i.__webglTexture,l),0!==a?eR.blitFramebuffer(d,p,u,c,m,g,u,c,eR.COLOR_BUFFER_BIT,eR.NEAREST):R?eR.copyTexSubImage3D(x,l,m,g,v+e,d,p,u,c):eR.copyTexSubImage2D(x,l,m,g,d,p,u,c);r.bindFramebuffer(eR.READ_FRAMEBUFFER,null),r.bindFramebuffer(eR.DRAW_FRAMEBUFFER,null)}else R?e.isDataTexture||e.isData3DTexture?eR.texSubImage3D(x,l,m,g,v,u,c,h,_,b,y.data):t.isCompressedArrayTexture?eR.compressedTexSubImage3D(x,l,m,g,v,u,c,h,_,y.data):eR.texSubImage3D(x,l,m,g,v,u,c,h,_,b,y):e.isDataTexture?eR.texSubImage2D(eR.TEXTURE_2D,l,m,g,u,c,_,b,y.data):e.isCompressedTexture?eR.compressedTexSubImage2D(eR.TEXTURE_2D,l,m,g,y.width,y.height,_,y.data):eR.texSubImage2D(eR.TEXTURE_2D,l,m,g,u,c,_,b,y);eR.pixelStorei(eR.UNPACK_ROW_LENGTH,S),eR.pixelStorei(eR.UNPACK_IMAGE_HEIGHT,w),eR.pixelStorei(eR.UNPACK_SKIP_PIXELS,T),eR.pixelStorei(eR.UNPACK_SKIP_ROWS,E),eR.pixelStorei(eR.UNPACK_SKIP_IMAGES,A),0===l&&t.generateMipmaps&&eR.generateMipmap(x),r.unbindTexture()},this.initRenderTarget=function(e){void 0===s.get(e).__webglFramebuffer&&o.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?o.setTextureCube(e,0):e.isData3DTexture?o.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?o.setTexture2DArray(e,0):o.setTexture2D(e,0),r.unbindTexture()},this.resetState=function(){Z=0,J=0,$=null,r.reset(),w.reset()},"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=eW._getDrawingBufferColorSpace(e),t.unpackColorSpace=eW._getUnpackColorSpace()}}e.s(["PMREMGenerator",()=>lW,"ShaderChunk",()=>lT,"ShaderLib",()=>lA,"UniformsLib",()=>lE,"WebGLRenderer",()=>cq,"WebGLUtils",()=>cO],16577);var cY=e.i(27688),cZ=e.i(92618);let{useSyncExternalStoreWithSelector:cJ}=cY.default,c$=(e,t)=>{let n=(0,cZ.createStore)(e),i=(e,i=t)=>(function(e,t=e=>e,n){let i=cJ(e.subscribe,e.getState,e.getInitialState,t,n);return P.default.useDebugValue(i),i})(n,e,i);return Object.assign(i,n),i},cK=[];function cQ(e,t,n=(e,t)=>e===t){if(e===t)return!0;if(!e||!t)return!1;let i=e.length;if(t.length!==i)return!1;for(let r=0;r<i;r++)if(!n(e[r],t[r]))return!1;return!0}function c0(e,t=null,n=!1,i={}){for(let r of(null===t&&(t=[e]),cK))if(cQ(t,r.keys,r.equal)){if(n)return;if(Object.prototype.hasOwnProperty.call(r,"error"))throw r.error;if(Object.prototype.hasOwnProperty.call(r,"response"))return i.lifespan&&i.lifespan>0&&(r.timeout&&clearTimeout(r.timeout),r.timeout=setTimeout(r.remove,i.lifespan)),r.response;if(!n)throw r.promise}let r={keys:t,equal:i.equal,remove:()=>{let e=cK.indexOf(r);-1!==e&&cK.splice(e,1)},promise:("object"==typeof e&&"function"==typeof e.then?e:e(...t)).then(e=>{r.response=e,i.lifespan&&i.lifespan>0&&(r.timeout=setTimeout(r.remove,i.lifespan))}).catch(e=>r.error=e)};if(cK.push(r),!n)throw r.promise}var c1=e.i(66241),c2=P;function c3(e,t,n){if(!e)return;if(!0===n(e))return e;let i=t?e.return:e.child;for(;i;){let e=c3(i,t,n);if(e)return e;i=t?null:i.sibling}}function c4(e){try{return Object.defineProperties(e,{_currentRenderer:{get:()=>null,set(){}},_currentRenderer2:{get:()=>null,set(){}}})}catch(t){return e}}"u">typeof window&&((null==(M=window.document)?void 0:M.createElement)||(null==(w=window.navigator)?void 0:w.product)==="ReactNative")?c2.useLayoutEffect:c2.useEffect;let c5=c4(c2.createContext(null));class c6 extends c2.Component{render(){return c2.createElement(c5.Provider,{value:this._reactInternals},this.props.children)}}function c8(){let e=c2.useContext(c5);if(null===e)throw Error("its-fine: useFiber must be called within a <FiberProvider />!");let t=c2.useId();return c2.useMemo(()=>{for(let n of[e,null==e?void 0:e.alternate]){if(!n)continue;let e=c3(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}let c9=Symbol.for("react.context"),c7=e=>null!==e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===c9;function he(e){let t=e.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}$.act;let ht=e=>null!=e&&("string"==typeof e||"number"==typeof e||e.isColor),hn="u">typeof window&&((null==(v=window.document)?void 0:v.createElement)||(null==(x=window.navigator)?void 0:x.product)==="ReactNative")?$.useLayoutEffect:$.useEffect;function hi(e){let t=$.useRef(e);return hn(()=>void(t.current=e),[e]),t}function hr({set:e}){return hn(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}let ha=((y=class extends $.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}).getDerivedStateFromError=()=>({error:!0}),y);function hs(e){var t;let n="u">typeof window?null!=(t=window.devicePixelRatio)?t:2:1;return Array.isArray(e)?Math.min(Math.max(e[0],n),e[1]):e}function ho(e){var t;return null==(t=e.__r3f)?void 0:t.root.getState()}let hl={obj:e=>e===Object(e)&&!hl.arr(e)&&"function"!=typeof e,fun:e=>"function"==typeof e,str:e=>"string"==typeof e,num:e=>"number"==typeof e,boo:e=>"boolean"==typeof e,und:e=>void 0===e,nul:e=>null===e,arr:e=>Array.isArray(e),equ(e,t,{arrays:n="shallow",objects:i="reference",strict:r=!0}={}){let a;if(typeof e!=typeof t||!!e!=!!t)return!1;if(hl.str(e)||hl.num(e)||hl.boo(e))return e===t;let s=hl.obj(e);if(s&&"reference"===i)return e===t;let o=hl.arr(e);if(o&&"reference"===n)return e===t;if((o||s)&&e===t)return!0;for(a in e)if(!(a in t))return!1;if(s&&"shallow"===n&&"shallow"===i){for(a in r?t:e)if(!hl.equ(e[a],t[a],{strict:r,objects:"reference"}))return!1}else for(a in r?t:e)if(e[a]!==t[a])return!1;if(hl.und(a)){if(o&&0===e.length&&0===t.length||s&&0===Object.keys(e).length&&0===Object.keys(t).length)return!0;if(e!==t)return!1}return!0}},hu=["children","key","ref"];function hc(e,t,n,i){let r=null==e?void 0:e.__r3f;return!r&&(r={root:t,type:n,parent:null,children:[],props:function(e){let t={};for(let n in e)hu.includes(n)||(t[n]=e[n]);return t}(i),object:e,eventCount:0,handlers:{},isHidden:!1},e&&(e.__r3f=r)),r}function hh(e,t){if(!t.includes("-")||t in e)return{root:e,key:t,target:e[t]};let n=e,i=t.split("-");for(let r of i){if("object"!=typeof n||null===n){if(void 0!==n)return{root:n,key:i.slice(i.indexOf(r)).join("-"),target:void 0};return{root:e,key:t,target:void 0}}t=r,e=n,n=n[t]}return{root:e,key:t,target:n}}let hd=/-\d+$/;function hp(e,t){if(hl.str(t.props.attach)){if(hd.test(t.props.attach)){let n=t.props.attach.replace(hd,""),{root:i,key:r}=hh(e.object,n);Array.isArray(i[r])||(i[r]=[])}let{root:n,key:i}=hh(e.object,t.props.attach);t.previousAttach=n[i],n[i]=t.object}else hl.fun(t.props.attach)&&(t.previousAttach=t.props.attach(e.object,t.object))}function hf(e,t){if(hl.str(t.props.attach)){let{root:n,key:i}=hh(e.object,t.props.attach),r=t.previousAttach;void 0===r?delete n[i]:n[i]=r}else null==t.previousAttach||t.previousAttach(e.object,t.object);delete t.previousAttach}let hm=[...hu,"args","dispose","attach","object","onUpdate","dispose"],hg=new Map,hv=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],hx=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function hy(e,t){var n,i;let r=e.__r3f,a=r&&he(r).getState(),s=null==r?void 0:r.eventCount;for(let n in t){let s=t[n];if(hm.includes(n))continue;if(r&&hx.test(n)){"function"==typeof s?r.handlers[n]=s:delete r.handlers[n],r.eventCount=Object.keys(r.handlers).length;continue}if(void 0===s)continue;let{root:o,key:l,target:u}=hh(e,n);if(void 0===u&&("object"!=typeof o||null===o))throw Error(`R3F: Cannot set "${n}". Ensure it is an object before setting "${l}".`);u instanceof tO&&s instanceof tO?u.mask=s.mask:u instanceof no&&ht(s)?u.set(s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"function"==typeof u.copy&&null!=s&&s.constructor&&u.constructor===s.constructor?u.copy(s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&Array.isArray(s)?"function"==typeof u.fromArray?u.fromArray(s):u.set(...s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"number"==typeof s?"function"==typeof u.setScalar?u.setScalar(s):u.set(s):(o[l]=s,a&&!a.linear&&hv.includes(l)&&null!=(i=o[l])&&i.isTexture&&1023===o[l].format&&1009===o[l].type&&(o[l].colorSpace=en))}if(null!=r&&r.parent&&null!=a&&a.internal&&null!=(n=r.object)&&n.isObject3D&&s!==r.eventCount){let e=r.object,t=a.internal.interaction.indexOf(e);t>-1&&a.internal.interaction.splice(t,1),r.eventCount&&null!==e.raycast&&a.internal.interaction.push(e)}return r&&void 0===r.props.attach&&(r.object.isBufferGeometry?r.props.attach="geometry":r.object.isMaterial&&(r.props.attach="material")),r&&h_(r),e}function h_(e){var t;if(!e.parent)return;null==e.props.onUpdate||e.props.onUpdate(e.object);let n=null==(t=e.root)||null==t.getState?void 0:t.getState();n&&0===n.internal.frames&&n.invalidate()}let hb=e=>null==e?void 0:e.isObject3D;function hS(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function hM(e,t,n,i){let r=n.get(t);r&&(n.delete(t),0===n.size&&(e.delete(i),r.target.releasePointerCapture(i)))}let hw=e=>!!(null!=e&&e.render),hT=$.createContext(null);function hE(){let e=$.useContext(hT);if(!e)throw Error("R3F: Hooks can only be used within the Canvas component!");return e}function hA(e=e=>e,t){return hE()(e,t)}function hC(e,t=0){let n=hE(),i=n.getState().internal.subscribe,r=hi(e);return hn(()=>i(r,t,n),[t,i,n]),null}let hR=new WeakMap;function hP(e,t){return function(n,...i){var r;let a;return"function"==typeof n&&(null==n||null==(r=n.prototype)?void 0:r.constructor)===n?(a=hR.get(n))||(a=new n,hR.set(n,a)):a=n,e&&e(a),Promise.all(i.map(e=>new Promise((n,i)=>a.load(e,e=>{var t;let i;hb(null==e?void 0:e.scene)&&Object.assign(e,(t=e.scene,i={nodes:{},materials:{},meshes:{}},t&&t.traverse(e=>{e.name&&(i.nodes[e.name]=e),e.material&&!i.materials[e.material.name]&&(i.materials[e.material.name]=e.material),e.isMesh&&!i.meshes[e.name]&&(i.meshes[e.name]=e)}),i)),n(e)},t,t=>i(Error(`Could not load ${e}: ${null==t?void 0:t.message}`))))))}}function hI(e,t,n,i){let r=Array.isArray(t)?t:[t],a=c0(hP(n,i),[e,...r],!1,{equal:hl.equ});return Array.isArray(t)?a:a[0]}hI.preload=function(e,t,n){let i,r=Array.isArray(t)?t:[t];c0(hP(n),[e,...r],!0,i)},hI.clear=function(e,t){var n=[e,...Array.isArray(t)?t:[t]];if(void 0===n||0===n.length)cK.splice(0,cK.length);else{let e=cK.find(e=>cQ(n,e.keys,e.equal));e&&e.remove()}};var hL={exports:{}},hN={exports:{}};hN.exports;let hD=(C||(C=1,A||(A=1,hN.exports=function(e){function t(e,t,n,i){return new iJ(e,t,n,i)}function n(){}function i(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do(4098&(t=e).flags)!=0&&(n=t.return),e=t.return;while(e)}return 3===t.tag?n:null}function a(e){if(r(e)!==e)throw Error(i(188))}function s(e){var t=e.alternate;if(!t){if(null===(t=r(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,s=t;;){var o=n.return;if(null===o)break;var l=o.alternate;if(null===l){if(null!==(s=o.return)){n=s;continue}break}if(o.child===l.child){for(l=o.child;l;){if(l===n)return a(o),e;if(l===s)return a(o),t;l=l.sibling}throw Error(i(188))}if(n.return!==s.return)n=o,s=l;else{for(var u=!1,c=o.child;c;){if(c===n){u=!0,n=o,s=l;break}if(c===s){u=!0,s=o,n=l;break}c=c.sibling}if(!u){for(c=l.child;c;){if(c===n){u=!0,n=l,s=o;break}if(c===s){u=!0,s=l,n=o;break}c=c.sibling}if(!u)throw Error(i(189))}}if(n.alternate!==s)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}function o(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=r_&&e[r_]||e["@@iterator"])?e:null}function l(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===rb?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case rl:return"Fragment";case rc:return"Profiler";case ru:return"StrictMode";case rf:return"Suspense";case rm:return"SuspenseList";case rx:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case ro:return"Portal";case rd:return e.displayName||"Context";case rh:return(e._context.displayName||"Context")+".Consumer";case rp:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case rg:return null!==(t=e.displayName||null)?t:l(e.type)||"Memo";case rv:t=e._payload,e=e._init;try{return l(e(t))}catch{}}return null}function u(e){return{current:e}}function c(e){0>sw||(e.current=sM[sw],sM[sw]=null,sw--)}function h(e,t){sM[++sw]=e.current,e.current=t}function d(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 0x1000000:case 0x2000000:return 0x3c00000&e;case 0x4000000:return 0x4000000;case 0x8000000:return 0x8000000;case 0x10000000:return 0x10000000;case 0x20000000:return 0x20000000;case 0x40000000:return 0;default:return e}}function p(e,t,n){var i=e.pendingLanes;if(0===i)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var o=0x7ffffff&i;return 0!==o?0!=(i=o&~a)?r=d(i):0!=(s&=o)?r=d(s):n||0!=(n=o&~e)&&(r=d(n)):0!=(o=i&~a)?r=d(o):0!==s?r=d(s):n||0!=(n=i&~e)&&(r=d(n)),0===r?0:0!==t&&t!==r&&(t&a)==0&&((a=r&-r)>=(n=t&-t)||32===a&&(4194048&n)!=0)?t:r}function f(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)==0}function m(){var e=sI;return(0x3c00000&(sI<<=1))==0&&(sI=4194304),e}function g(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function v(e,t){e.pendingLanes|=t,0x10000000!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function x(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-sE(t);e.entangledLanes|=t,e.entanglements[i]=0x40000000|e.entanglements[i]|261930&n}function y(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-sE(n),r=1<<i;r&t|e[i]&t&&(e[i]|=t),n&=~r}}function _(e,t){var n=t&-t;return((n=(42&n)!=0?1:b(n))&(e.suspendedLanes|t))!=0?0:n}function b(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 0x1000000:case 0x2000000:e=128;break;case 0x10000000:e=0x8000000;break;default:e=0}return e}function S(e){return 2<(e&=-e)?8<e?(0x7ffffff&e)!=0?32:0x10000000:8:2}function M(e){if("function"==typeof sV&&sH(e),sG&&"function"==typeof sG.setStrictMode)try{sG.setStrictMode(sj,e)}catch{}}function w(e){if(void 0===a7)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);a7=t&&t[1]||"",se=-1<e.stack.indexOf(`
387
+ at`)?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return`
388
+ `+a7+e+se}function T(e,t){if(!e||sY)return"";sY=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var i=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){i=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){i=e}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(e){if(e&&i&&"string"==typeof e.stack)return[e.stack,i.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var a=i.DetermineComponentFrameRoot(),s=a[0],o=a[1];if(s&&o){var l=s.split(`
389
+ `),u=o.split(`
390
+ `);for(r=i=0;i<l.length&&!l[i].includes("DetermineComponentFrameRoot");)i++;for(;r<u.length&&!u[r].includes("DetermineComponentFrameRoot");)r++;if(i===l.length||r===u.length)for(i=l.length-1,r=u.length-1;1<=i&&0<=r&&l[i]!==u[r];)r--;for(;1<=i&&0<=r;i--,r--)if(l[i]!==u[r]){if(1!==i||1!==r)do if(i--,r--,0>r||l[i]!==u[r]){var c=`
391
+ `+l[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=r)break}}}finally{sY=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?w(n):""}function E(e){try{var t="",n=null;do t+=function(e,t){switch(e.tag){case 26:case 27:case 5:return w(e.type);case 16:return w("Lazy");case 13:return e.child!==t&&null!==t?w("Suspense Fallback"):w("Suspense");case 19:return w("SuspenseList");case 0:case 15:return T(e.type,!1);case 11:return T(e.type.render,!1);case 1:return T(e.type,!0);case 31:return w("Activity");default:return""}}(e,n),n=e,e=e.return;while(e)return t}catch(e){return`
392
+ Error generating stack: `+e.message+`
393
+ `+e.stack}}function A(e,t){if("object"==typeof e&&null!==e){var n=sZ.get(e);return void 0!==n?n:(t={value:e,source:t,stack:E(t)},sZ.set(e,t),t)}return{value:e,source:t,stack:E(t)}}function C(e,t){sJ[s$++]=sQ,sJ[s$++]=sK,sK=e,sQ=t}function R(e,t,n){s0[s1++]=s3,s0[s1++]=s4,s0[s1++]=s2,s2=e;var i=s3;e=s4;var r=32-sE(i)-1;i&=~(1<<r),n+=1;var a=32-sE(t)+r;if(30<a){var s=r-r%5;a=(i&(1<<s)-1).toString(32),i>>=s,r-=s,s3=1<<32-sE(t)+r|n<<r|i,s4=a+e}else s3=1<<a|n<<r|i,s4=e}function P(e){null!==e.return&&(C(e,1),R(e,1,0))}function I(e){for(;e===sK;)sK=sJ[--s$],sJ[s$]=null,sQ=sJ[--s$],sJ[s$]=null;for(;e===s2;)s2=s0[--s1],s0[s1]=null,s4=s0[--s1],s0[s1]=null,s3=s0[--s1],s0[s1]=null}function L(e,t){s0[s1++]=s3,s0[s1++]=s4,s0[s1++]=s2,s3=t.id,s4=t.overflow,s2=e}function N(e,t){h(s8,t),h(s6,e),h(s5,null),e=rC(t),c(s5),h(s5,e)}function D(){c(s5),c(s6),c(s8)}function U(e){null!==e.memoizedState&&h(s9,e);var t=s5.current,n=rR(t,e.type);t!==n&&(h(s6,e),h(s5,n))}function O(e){s6.current===e&&(c(s5),c(s6)),s9.current===e&&(c(s9),rB?r5._currentValue=r4:r5._currentValue2=r4)}function F(e){var t=Error(i(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML",""));throw j(A(t,e)),or}function z(e,t){if(!rj)throw Error(i(175));aX(e.stateNode,e.type,e.memoizedProps,t,e)||F(e,!0)}function k(e){for(s7=e.return;s7;)switch(s7.tag){case 5:case 31:case 13:oi=!1;return;case 27:case 3:oi=!0;return;default:s7=s7.return}}function B(e){if(!rj||e!==s7)return!1;if(!ot)return k(e),ot=!0,!1;var t=e.tag;if(sv?3!==t&&27!==t&&(5!==t||a9(e.type)&&!rU(e.type,e.memoizedProps))&&oe&&F(e):3!==t&&(5!==t||a9(e.type)&&!rU(e.type,e.memoizedProps))&&oe&&F(e),k(e),13===t){if(!rj)throw Error(i(316));if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));oe=a$(e)}else if(31===t){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));oe=aJ(e)}else oe=sv&&27===t?aO(e.type,oe):s7?aU(e.stateNode):null;return!0}function V(){rj&&(oe=s7=null,ot=!1)}function H(){var e=on;return null!==e&&(null===lL?lL=e:lL.push.apply(lL,e),on=null),e}function j(e){null===on?on=[e]:on.push(e)}function G(e,t,n){rB?(h(oa,t._currentValue),t._currentValue=n):(h(oa,t._currentValue2),t._currentValue2=n)}function W(e){var t=oa.current;rB?e._currentValue=t:e._currentValue2=t,c(oa)}function X(e,t,n){for(;null!==e;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==i&&(i.childLanes|=t)):null!==i&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===n)break;e=e.return}}function q(e,t,n,r){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var s=a.dependencies;if(null!==s){var o=a.child;s=s.firstContext;o:for(;null!==s;){var l=s;s=a;for(var u=0;u<t.length;u++)if(l.context===t[u]){s.lanes|=n,null!==(l=s.alternate)&&(l.lanes|=n),X(s.return,n,e),r||(o=null);break o}s=l.next}}else if(18===a.tag){if(null===(o=a.return))throw Error(i(341));o.lanes|=n,null!==(s=o.alternate)&&(s.lanes|=n),X(o,n,e),o=null}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===e){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}}function Y(e,t,n,r){e=null;for(var a=t,s=!1;null!==a;){if(!s){if((524288&a.flags)!=0)s=!0;else if((262144&a.flags)!=0)break}if(10===a.tag){var o=a.alternate;if(null===o)throw Error(i(387));if(null!==(o=o.memoizedProps)){var l=a.type;sW(a.pendingProps.value,o.value)||(null!==e?e.push(l):e=[l])}}else if(a===s9.current){if(null===(o=a.alternate))throw Error(i(387));o.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(r5):e=[r5])}a=a.return}null!==e&&q(t,e,n,r),t.flags|=262144}function Z(e){for(e=e.firstContext;null!==e;){var t=e.context;if(!sW(rB?t._currentValue:t._currentValue2,e.memoizedValue))return!0;e=e.next}return!1}function K(e){os=e,oo=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Q(e){return et(os,e)}function ee(e,t){return null===os&&K(e),et(e,t)}function et(e,t){var n=rB?t._currentValue:t._currentValue2;if(t={context:t,memoizedValue:n,next:null},null===oo){if(null===e)throw Error(i(308));oo=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else oo=oo.next=t;return n}function en(){return{controller:new ol,data:new Map,refCount:0}}function ei(e){e.refCount--,0===e.refCount&&ou(oc,function(){e.controller.abort()})}function er(){}function ea(e){e!==op&&null===e.next&&(null===op?od=op=e:op=op.next=e),om=!0,of||(of=!0,r8?r9(function(){(6&lm)!=0?sL(sF,eo):el()}):sL(sF,eo))}function es(e,t){if(!og&&om){og=!0;do for(var n=!1,i=od;null!==i;){if(!t)if(0!==e){var r=i.pendingLanes;if(0===r)var a=0;else{var s=i.suspendedLanes,o=i.pingedLanes;a=0xc000095&(a=(1<<31-sE(42|e)+1)-1&(r&~(s&~o)))?0xc000095&a|1:a?2|a:0}0!==a&&(n=!0,eh(i,a))}else a=lx,(3&(a=p(i,i===lg?a:0,null!==i.cancelPendingCommit||i.timeoutHandle!==rk)))==0||f(i,a)||(n=!0,eh(i,a));i=i.next}while(n)og=!1}}function eo(){el()}function el(){om=of=!1;var e=0;0!==ov&&rZ()&&(e=ov);for(var t=sO(),n=null,i=od;null!==i;){var r=i.next,a=eu(i,t);0===a?(i.next=null,null===n?od=r:n.next=r,null===r&&(op=n)):(n=i,(0!==e||(3&a)!=0)&&(om=!0)),i=r}0!==lk&&5!==lk||es(e,!1),0!==ov&&(ov=0)}function eu(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,a=-0x3c00001&e.pendingLanes;0<a;){var s=31-sE(a),o=1<<s,l=r[s];-1===l?((o&n)==0||(o&i)!=0)&&(r[s]=function(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return -1}}(o,t)):l<=t&&(e.expiredLanes|=o),a&=~o}if(t=lg,n=lx,n=p(e,e===t?n:0,null!==e.cancelPendingCommit||e.timeoutHandle!==rk),i=e.callbackNode,0===n||e===t&&(2===ly||9===ly)||null!==e.cancelPendingCommit)return null!==i&&null!==i&&sN(i),e.callbackNode=null,e.callbackPriority=0;if((3&n)==0||f(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==i&&sN(i),S(n)){case 2:case 8:n=sz;break;case 32:default:n=sk;break;case 0x10000000:n=sB}return n=sL(n,i=ec.bind(null,e)),e.callbackPriority=t,e.callbackNode=n,t}return null!==i&&null!==i&&sN(i),e.callbackPriority=2,e.callbackNode=null,2}function ec(e,t){if(0!==lk&&5!==lk)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(iV()&&e.callbackNode!==n)return null;var i=lx;return 0===(i=p(e,e===lg?i:0,null!==e.cancelPendingCommit||e.timeoutHandle!==rk))?null:(iy(e,i,t),eu(e,sO()),null!=e.callbackNode&&e.callbackNode===n?ec.bind(null,e):null)}function eh(e,t){if(iV())return null;iy(e,t,!0)}function ed(){if(0===ov){var e=o_;0===e&&(e=sR,(261888&(sR<<=1))==0&&(sR=256)),ov=e}return ov}function ep(){if(0==--oy&&null!==ox){null!==ob&&(ob.status="fulfilled");var e=ox;ox=null,o_=0,ob=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ef(){var e=oM.current;return null!==e?e:lg.pooledCache}function em(e,t){null===t?h(oM,oM.current):h(oM,t.pool)}function eg(){var e=ef();return null===e?null:{parent:rB?oh._currentValue:oh._currentValue2,pool:e}}function ev(e,t){if(sW(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!sq.call(t,r)||!sW(e[r],t[r]))return!1}return!0}function ex(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ey(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(er,er),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw eS(e=t.reason),e;default:if("string"==typeof t.status)t.then(er,er);else{if(null!==(e=lg)&&100<e.shellSuspendCounter)throw Error(i(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw eS(e=t.reason),e}throw oC=t,ow}}function e_(e){try{return(0,e._init)(e._payload)}catch(e){throw null!==e&&"object"==typeof e&&"function"==typeof e.then?(oC=e,ow):e}}function eb(){if(null===oC)throw Error(i(459));var e=oC;return oC=null,e}function eS(e){if(e===ow||e===oE)throw Error(i(483))}function eM(e){var t=oP;return oP+=1,null===oR&&(oR=[]),ey(oR,e,t)}function ew(e,t){e.ref=void 0!==(t=t.props.ref)?t:null}function eT(e,t){throw t.$$typeof===ra?Error(i(525)):Error(i(31,"[object Object]"===(e=Object.prototype.toString.call(t))?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function eE(e){function n(t,n){if(e){var i=t.deletions;null===i?(t.deletions=[n],t.flags|=16):i.push(n)}}function r(t,i){if(!e)return null;for(;null!==i;)n(t,i),i=i.sibling;return null}function a(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function s(e,t){return(e=iK(e,t)).index=0,e.sibling=null,e}function l(t,n,i){return t.index=i,e?null!==(i=t.alternate)?(i=i.index)<n?(t.flags|=0x4000002,n):i:(t.flags|=0x4000002,n):(t.flags|=1048576,n)}function u(t){return e&&null===t.alternate&&(t.flags|=0x4000002),t}function c(e,t,n,i){return null===t||6!==t.tag?(t=i2(n,e.mode,i)).return=e:(t=s(t,n)).return=e,t}function h(e,t,n,i){var r=n.type;return r===rl?p(e,t,n.props.children,i,n.key):(null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===rv&&e_(r)===t.type)?ew(t=s(t,n.props),n):ew(t=i0(n.type,n.key,n.props,null,e.mode,i),n),t.return=e,t)}function d(e,t,n,i){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=i4(n,e.mode,i)).return=e:(t=s(t,n.children||[])).return=e,t}function p(e,t,n,i,r){return null===t||7!==t.tag?(t=i1(n,e.mode,i,r)).return=e:(t=s(t,n)).return=e,t}function f(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=i2(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case rs:return ew(n=i0(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case ro:return(t=i4(t,e.mode,n)).return=e,t;case rv:return f(e,t=e_(t),n)}if(rS(t)||o(t))return(t=i1(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return f(e,eM(t),n);if(t.$$typeof===rd)return f(e,ee(e,t),n);eT(e,t)}return null}function m(e,t,n,i){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==r?null:c(e,t,""+n,i);if("object"==typeof n&&null!==n){switch(n.$$typeof){case rs:return n.key===r?h(e,t,n,i):null;case ro:return n.key===r?d(e,t,n,i):null;case rv:return m(e,t,n=e_(n),i)}if(rS(n)||o(n))return null!==r?null:p(e,t,n,i,null);if("function"==typeof n.then)return m(e,t,eM(n),i);if(n.$$typeof===rd)return m(e,t,ee(e,n),i);eT(e,n)}return null}function g(e,t,n,i,r){if("string"==typeof i&&""!==i||"number"==typeof i||"bigint"==typeof i)return c(t,e=e.get(n)||null,""+i,r);if("object"==typeof i&&null!==i){switch(i.$$typeof){case rs:return h(t,e=e.get(null===i.key?n:i.key)||null,i,r);case ro:return d(t,e=e.get(null===i.key?n:i.key)||null,i,r);case rv:return g(e,t,n,i=e_(i),r)}if(rS(i)||o(i))return p(t,e=e.get(n)||null,i,r,null);if("function"==typeof i.then)return g(e,t,n,eM(i),r);if(i.$$typeof===rd)return g(e,t,n,ee(t,i),r);eT(t,i)}return null}return function(c,h,d,p){try{oP=0;var v=function t(c,h,d,p){if("object"==typeof d&&null!==d&&d.type===rl&&null===d.key&&(d=d.props.children),"object"==typeof d&&null!==d){switch(d.$$typeof){case rs:o:{for(var v=d.key;null!==h;){if(h.key===v){if((v=d.type)===rl){if(7===h.tag){r(c,h.sibling),(p=s(h,d.props.children)).return=c,c=p;break o}}else if(h.elementType===v||"object"==typeof v&&null!==v&&v.$$typeof===rv&&e_(v)===h.type){r(c,h.sibling),ew(p=s(h,d.props),d),p.return=c,c=p;break o}r(c,h);break}n(c,h),h=h.sibling}d.type===rl?(p=i1(d.props.children,c.mode,p,d.key)).return=c:(ew(p=i0(d.type,d.key,d.props,null,c.mode,p),d),p.return=c),c=p}return u(c);case ro:o:{for(v=d.key;null!==h;){if(h.key===v)if(4===h.tag&&h.stateNode.containerInfo===d.containerInfo&&h.stateNode.implementation===d.implementation){r(c,h.sibling),(p=s(h,d.children||[])).return=c,c=p;break o}else{r(c,h);break}n(c,h),h=h.sibling}(p=i4(d,c.mode,p)).return=c,c=p}return u(c);case rv:return t(c,h,d=e_(d),p)}if(rS(d))return function(t,i,s,o){for(var u=null,c=null,h=i,d=i=0,p=null;null!==h&&d<s.length;d++){h.index>d?(p=h,h=null):p=h.sibling;var v=m(t,h,s[d],o);if(null===v){null===h&&(h=p);break}e&&h&&null===v.alternate&&n(t,h),i=l(v,i,d),null===c?u=v:c.sibling=v,c=v,h=p}if(d===s.length)return r(t,h),ot&&C(t,d),u;if(null===h){for(;d<s.length;d++)null!==(h=f(t,s[d],o))&&(i=l(h,i,d),null===c?u=h:c.sibling=h,c=h);return ot&&C(t,d),u}for(h=a(h);d<s.length;d++)null!==(p=g(h,t,d,s[d],o))&&(e&&null!==p.alternate&&h.delete(null===p.key?d:p.key),i=l(p,i,d),null===c?u=p:c.sibling=p,c=p);return e&&h.forEach(function(e){return n(t,e)}),ot&&C(t,d),u}(c,h,d,p);if(o(d)){if("function"!=typeof(v=o(d)))throw Error(i(150));return function(t,s,o,u){if(null==o)throw Error(i(151));for(var c=null,h=null,d=s,p=s=0,v=null,x=o.next();null!==d&&!x.done;p++,x=o.next()){d.index>p?(v=d,d=null):v=d.sibling;var y=m(t,d,x.value,u);if(null===y){null===d&&(d=v);break}e&&d&&null===y.alternate&&n(t,d),s=l(y,s,p),null===h?c=y:h.sibling=y,h=y,d=v}if(x.done)return r(t,d),ot&&C(t,p),c;if(null===d){for(;!x.done;p++,x=o.next())null!==(x=f(t,x.value,u))&&(s=l(x,s,p),null===h?c=x:h.sibling=x,h=x);return ot&&C(t,p),c}for(d=a(d);!x.done;p++,x=o.next())null!==(x=g(d,t,p,x.value,u))&&(e&&null!==x.alternate&&d.delete(null===x.key?p:x.key),s=l(x,s,p),null===h?c=x:h.sibling=x,h=x);return e&&d.forEach(function(e){return n(t,e)}),ot&&C(t,p),c}(c,h,d=v.call(d),p)}if("function"==typeof d.then)return t(c,h,eM(d),p);if(d.$$typeof===rd)return t(c,h,ee(c,d),p);eT(c,d)}return"string"==typeof d&&""!==d||"number"==typeof d||"bigint"==typeof d?(d=""+d,null!==h&&6===h.tag?(r(c,h.sibling),(p=s(h,d)).return=c):(r(c,h),(p=i2(d,c.mode,p)).return=c),u(c=p)):r(c,h)}(c,h,d,p);return oR=null,v}catch(e){if(e===ow||e===oE)throw e;var x=t(29,e,null,c.mode);return x.lanes=p,x.return=c,x}finally{}}}function eA(){for(var e=oD,t=oU=oD=0;t<e;){var n=oN[t];oN[t++]=null;var i=oN[t];oN[t++]=null;var r=oN[t];oN[t++]=null;var a=oN[t];if(oN[t++]=null,null!==i&&null!==r){var s=i.pending;null===s?r.next=r:(r.next=s.next,s.next=r),i.pending=r}0!==a&&eI(n,r,a)}}function eC(e,t,n,i){oN[oD++]=e,oN[oD++]=t,oN[oD++]=n,oN[oD++]=i,oU|=i,e.lanes|=i,null!==(e=e.alternate)&&(e.lanes|=i)}function eR(e,t,n,i){return eC(e,t,n,i),eL(e)}function eP(e,t){return eC(e,null,null,t),eL(e)}function eI(e,t,n){e.lanes|=n;var i=e.alternate;null!==i&&(i.lanes|=n);for(var r=!1,a=e.return;null!==a;)a.childLanes|=n,null!==(i=a.alternate)&&(i.childLanes|=n),22===a.tag&&(null===(e=a.stateNode)||1&e._visibility||(r=!0)),e=a,a=a.return;return 3===e.tag?(a=e.stateNode,r&&null!==t&&(r=31-sE(n),null===(i=(e=a.hiddenUpdates)[r])?e[r]=[t]:i.push(t),t.lane=0x20000000|n),a):null}function eL(e){if(50<lX)throw lX=0,lq=null,Error(i(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}function eN(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function eD(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function eU(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function eO(e,t,n){var i=e.updateQueue;if(null===i)return null;if(i=i.shared,(2&lm)!=0){var r=i.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=eL(e),eI(e,null,n),t}return eC(e,i,t,n),eL(e)}function eF(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,(4194048&n)!=0)){var i=t.lanes;i&=e.pendingLanes,n|=i,t.lanes=n,y(e,n)}}function ez(e,t){var n=e.updateQueue,i=e.alternate;if(null!==i&&n===(i=i.updateQueue)){var r=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?r=a=s:a=a.next=s,n=n.next}while(null!==n)null===a?r=a=t:a=a.next=t}else r=a=t;n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:i.shared,callbacks:i.callbacks},e.updateQueue=n;return}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ek(){if(oF){var e=ob;if(null!==e)throw e}}function eB(e,t,n,i){oF=!1;var r=e.updateQueue;oO=!1;var a=r.firstBaseUpdate,s=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var l=o,u=l.next;l.next=null,null===s?a=u:s.next=u,s=l;var c=e.alternate;null!==c&&(o=(c=c.updateQueue).lastBaseUpdate)!==s&&(null===o?c.firstBaseUpdate=u:o.next=u,c.lastBaseUpdate=l)}if(null!==a){var h=r.baseState;for(s=0,c=u=l=null,o=a;;){var d=-0x20000001&o.lane,p=d!==o.lane;if(p?(lx&d)===d:(i&d)===d){0!==d&&d===o_&&(oF=!0),null!==c&&(c=c.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});o:{var f=e,m=o;switch(d=t,m.tag){case 1:if("function"==typeof(f=m.payload)){h=f.call(n,h,d);break o}h=f;break o;case 3:f.flags=-65537&f.flags|128;case 0:if(null==(d="function"==typeof(f=m.payload)?f.call(n,h,d):f))break o;h=rr({},h,d);break o;case 2:oO=!0}}null!==(d=o.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=r.callbacks)?r.callbacks=[d]:p.push(d))}else p={lane:d,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===c?(u=c=p,l=h):c=c.next=p,s|=d;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(p=o).next,p.next=null,r.lastBaseUpdate=p,r.shared.pending=null}}null===c&&(l=h),r.baseState=l,r.firstBaseUpdate=u,r.lastBaseUpdate=c,null===a&&(r.shared.lanes=0),lE|=s,e.lanes=s,e.memoizedState=h}}function eV(e,t){if("function"!=typeof e)throw Error(i(191,e));e.call(t)}function eH(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)eV(n[e],t)}function ej(e,t){h(ok,e=lw),h(oz,t),lw=e|t.baseLanes}function eG(){h(ok,lw),h(oz,oz.current)}function eW(){lw=ok.current,c(oz),c(ok)}function eX(e){var t=e.alternate;h(oH,1&oH.current),h(oB,e),null===oV&&(null===t||null!==oz.current||null!==t.memoizedState)&&(oV=e)}function eq(e){h(oH,oH.current),h(oB,e),null===oV&&(oV=e)}function eY(e){22===e.tag?(h(oH,oH.current),h(oB,e),null===oV&&(oV=e)):eZ()}function eZ(){h(oH,oH.current),h(oB,oB.current)}function eJ(e){c(oB),oV===e&&(oV=null),c(oH)}function e$(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||aR(n)||aP(n)))return t}else if(19===t.tag&&("forwards"===t.memoizedProps.revealOrder||"backwards"===t.memoizedProps.revealOrder||"unstable_legacy-backwards"===t.memoizedProps.revealOrder||"together"===t.memoizedProps.revealOrder)){if((128&t.flags)!=0)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function eK(){throw Error(i(321))}function eQ(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!sW(e[n],t[n]))return!1;return!0}function e0(e,t,n,i,r,a){return oj=a,oG=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,rM.H=null===e||null===e.memoizedState?o1:o2,oZ=!1,a=n(i,r),oZ=!1,oY&&(a=e2(t,n,i,r)),e1(e),a}function e1(e){rM.H=o0;var t=null!==oW&&null!==oW.next;if(oj=0,oX=oW=oG=null,oq=!1,o$=0,oK=null,t)throw Error(i(300));null===e||o6||null!==(e=e.dependencies)&&Z(e)&&(o6=!0)}function e2(e,t,n,r){oG=e;var a=0;do{if(oY&&(oK=null),o$=0,oY=!1,25<=a)throw Error(i(301));if(a+=1,oX=oW=null,null!=e.updateQueue){var s=e.updateQueue;s.lastEffect=null,s.events=null,s.stores=null,null!=s.memoCache&&(s.memoCache.index=0)}rM.H=o3,s=t(n,r)}while(oY)return s}function e3(){var e=rM.H,t=e.useState()[0];return t="function"==typeof t.then?te(t):t,e=e.useState()[0],(null!==oW?oW.memoizedState:null)!==e&&(oG.flags|=1024),t}function e4(){var e=0!==oJ;return oJ=0,e}function e5(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function e6(e){if(oq){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}oq=!1}oj=0,oX=oW=oG=null,oY=!1,o$=oJ=0,oK=null}function e8(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===oX?oG.memoizedState=oX=e:oX=oX.next=e,oX}function e9(){if(null===oW){var e=oG.alternate;e=null!==e?e.memoizedState:null}else e=oW.next;var t=null===oX?oG.memoizedState:oX.next;if(null!==t)oX=t,oW=e;else{if(null===e)throw null===oG.alternate?Error(i(467)):Error(i(310));e={memoizedState:(oW=e).memoizedState,baseState:oW.baseState,baseQueue:oW.baseQueue,queue:oW.queue,next:null},null===oX?oG.memoizedState=oX=e:oX=oX.next=e}return oX}function e7(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function te(e){var t=o$;return o$+=1,null===oK&&(oK=[]),e=ey(oK,e,t),t=oG,(null===oX?t.memoizedState:oX.next)===null&&(rM.H=null===(t=t.alternate)||null===t.memoizedState?o1:o2),e}function tt(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return te(e);if(e.$$typeof===rd)return Q(e)}throw Error(i(438,String(e)))}function tn(e){var t=null,n=oG.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var i=oG.alternate;null!==i&&null!==(i=i.updateQueue)&&null!=(i=i.memoCache)&&(t={data:i.data.map(function(e){return e.slice()}),index:0})}if(null==t&&(t={data:[],index:0}),null===n&&(n=e7(),oG.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),i=0;i<e;i++)n[i]=ry;return t.index++,n}function ti(e,t){return"function"==typeof t?t(e):t}function tr(e){return ta(e9(),oW,e)}function ta(e,t,n){var r=e.queue;if(null===r)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,s=r.pending;if(null!==s){if(null!==a){var o=a.next;a.next=s.next,s.next=o}t.baseQueue=a=s,r.pending=null}if(s=e.baseState,null===a)e.memoizedState=s;else{t=a.next;var l=o=null,u=null,c=t,h=!1;do{var d=-0x20000001&c.lane;if(d!==c.lane?(lx&d)===d:(oj&d)===d){var p=c.revertLane;if(0===p)null!==u&&(u=u.next={lane:0,revertLane:0,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),d===o_&&(h=!0);else if((oj&p)===p){c=c.next,p===o_&&(h=!0);continue}else d={lane:0,revertLane:c.revertLane,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},null===u?(l=u=d,o=s):u=u.next=d,oG.lanes|=p,lE|=p;d=c.action,oZ&&n(s,d),s=c.hasEagerState?c.eagerState:n(s,d)}else p={lane:d,revertLane:c.revertLane,gesture:c.gesture,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},null===u?(l=u=p,o=s):u=u.next=p,oG.lanes|=d,lE|=d;c=c.next}while(null!==c&&c!==t)if(null===u?o=s:u.next=l,!sW(s,e.memoizedState)&&(o6=!0,h&&null!==(n=ob)))throw n;e.memoizedState=s,e.baseState=o,e.baseQueue=u,r.lastRenderedState=s}return null===a&&(r.lanes=0),[e.memoizedState,r.dispatch]}function ts(e){var t=e9(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,s=t.memoizedState;if(null!==a){n.pending=null;var o=a=a.next;do s=e(s,o.action),o=o.next;while(o!==a)sW(s,t.memoizedState)||(o6=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function to(e,t,n){var r=oG,a=e9(),s=ot;if(s){if(void 0===n)throw Error(i(407));n=n()}else n=t();var o=!sW((oW||a).memoizedState,n);if(o&&(a.memoizedState=n,o6=!0),a=a.queue,tL(tc.bind(null,r,a,e),[e]),a.getSnapshot!==t||o||null!==oX&&1&oX.memoizedState.tag){if(r.flags|=2048,tA(9,{destroy:void 0},tu.bind(null,r,a,n,t),null),null===lg)throw Error(i(349));s||(127&oj)!=0||tl(r,t,n)}return n}function tl(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=oG.updateQueue)?(t=e7(),oG.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function tu(e,t,n,i){t.value=n,t.getSnapshot=i,th(t)&&td(e)}function tc(e,t,n){return n(function(){th(t)&&td(e)})}function th(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!sW(e,n)}catch{return!0}}function td(e){var t=eP(e,2);null!==t&&ix(t,e,2)}function tp(e){var t=e8();if("function"==typeof e){var n=e;if(e=n(),oZ){M(!0);try{n()}finally{M(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ti,lastRenderedState:e},t}function tf(e,t,n,i){return e.baseState=n,ta(e,oW,"function"==typeof i?i:ti)}function tm(e,t,n,r,a){if(tQ(e))throw Error(i(485));if(null!==(e=t.action)){var s={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){s.listeners.push(e)}};null!==rM.T?n(!0):s.isTransition=!1,r(s),null===(n=t.pending)?(s.next=t.pending=s,tg(t,s)):(s.next=n.next,t.pending=n.next=s)}}function tg(e,t){var n=t.action,i=t.payload,r=e.state;if(t.isTransition){var a=rM.T,s={};rM.T=s;try{var o=n(r,i),l=rM.S;null!==l&&l(s,o),tv(e,t,o)}catch(n){ty(e,t,n)}finally{null!==a&&null!==s.types&&(a.types=s.types),rM.T=a}}else try{a=n(r,i),tv(e,t,a)}catch(n){ty(e,t,n)}}function tv(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){tx(e,t,n)},function(n){return ty(e,t,n)}):tx(e,t,n)}function tx(e,t,n){t.status="fulfilled",t.value=n,t_(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,tg(e,n)))}function ty(e,t,n){var i=e.pending;if(e.pending=null,null!==i){i=i.next;do t.status="rejected",t.reason=n,t_(t),t=t.next;while(t!==i)}e.action=null}function t_(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function tb(e,t){return t}function tS(e,t){if(ot){var n=lg.formState;if(null!==n){o:{var i=oG;if(ot){if(oe){var r=aN(oe,oi);if(r){oe=aU(r),i=aD(r);break o}}F(i)}i=!1}i&&(t=n[0])}}(n=e8()).memoizedState=n.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tb,lastRenderedState:t},n.queue=i,n=tJ.bind(null,oG,i),i.dispatch=n,i=tp(!1);var a=tK.bind(null,oG,!1,i.queue);return i=e8(),r={state:t,dispatch:null,action:e,pending:null},i.queue=r,n=tm.bind(null,oG,r,a,n),r.dispatch=n,i.memoizedState=e,[t,n,!1]}function tM(e){return tw(e9(),oW,e)}function tw(e,t,n){if(t=ta(e,t,tb)[0],e=tr(ti)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var i=te(t)}catch(e){throw e===ow?oE:e}else i=t;var r=(t=e9()).queue,a=r.dispatch;return n!==t.memoizedState&&(oG.flags|=2048,tA(9,{destroy:void 0},tT.bind(null,r,n),null)),[i,a,e]}function tT(e,t){e.action=t}function tE(e){var t=e9(),n=oW;if(null!==n)return tw(t,n,e);e9(),t=t.memoizedState;var i=(n=e9()).queue.dispatch;return n.memoizedState=e,[t,i,!1]}function tA(e,t,n,i){return e={tag:e,create:n,deps:i,inst:t,next:null},null===(t=oG.updateQueue)&&(t=e7(),oG.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(i=n.next,n.next=e,e.next=i,t.lastEffect=e),e}function tC(){return e9().memoizedState}function tR(e,t,n,i){var r=e8();oG.flags|=e,r.memoizedState=tA(1|t,{destroy:void 0},n,void 0===i?null:i)}function tP(e,t,n,i){var r=e9();i=void 0===i?null:i;var a=r.memoizedState.inst;null!==oW&&null!==i&&eQ(i,oW.memoizedState.deps)?r.memoizedState=tA(t,a,n,i):(oG.flags|=e,r.memoizedState=tA(1|t,a,n,i))}function tI(e,t){tR(8390656,8,e,t)}function tL(e,t){tP(2048,8,e,t)}function tN(e){var t=e9().memoizedState;return function(e){oG.flags|=4;var t=oG.updateQueue;if(null===t)t=e7(),oG.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if((2&lm)!=0)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function tD(e,t){return tP(4,2,e,t)}function tU(e,t){return tP(4,4,e,t)}function tO(e,t){if("function"==typeof t){var n=t(e=e());return function(){"function"==typeof n?n():t(null)}}if(null!=t)return t.current=e=e(),function(){t.current=null}}function tF(e,t,n){n=null!=n?n.concat([e]):null,tP(4,4,tO.bind(null,t,e),n)}function tz(){}function tk(e,t){var n=e9();t=void 0===t?null:t;var i=n.memoizedState;return null!==t&&eQ(t,i[1])?i[0]:(n.memoizedState=[e,t],e)}function tB(e,t){var n=e9();t=void 0===t?null:t;var i=n.memoizedState;if(null!==t&&eQ(t,i[1]))return i[0];if(i=e(),oZ){M(!0);try{e()}finally{M(!1)}}return n.memoizedState=[i,t],i}function tV(e,t,n){return void 0===n||(0x40000000&oj)!=0&&(261930&lx)==0?e.memoizedState=t:(e.memoizedState=n,e=iv(),oG.lanes|=e,lE|=e,n)}function tH(e,t,n,i){return sW(n,t)?n:null!==oz.current?(sW(e=tV(e,n,i),t)||(o6=!0),e):(42&oj)==0||(0x40000000&oj)!=0&&(261930&lx)==0?(o6=!0,e.memoizedState=n):(e=iv(),oG.lanes|=e,lE|=e,t)}function tj(e,t,n,i,r){var a=rq();rX(0!==a&&8>a?a:8);var s=rM.T,o={};rM.T=o,tK(e,!1,t,n);try{var l=r(),u=rM.S;if(null!==u&&u(o,l),null!==l&&"object"==typeof l&&"function"==typeof l.then){var c,h,d=(c=[],h={status:"pending",value:null,reason:null,then:function(e){c.push(e)}},l.then(function(){h.status="fulfilled",h.value=i;for(var e=0;e<c.length;e++)(0,c[e])(i)},function(e){for(h.status="rejected",h.reason=e,e=0;e<c.length;e++)(0,c[e])(void 0)}),h);t$(e,t,d,ig(e))}else t$(e,t,i,ig(e))}catch(n){t$(e,t,{then:function(){},status:"rejected",reason:n},ig())}finally{rX(a),null!==s&&null!==o.types&&(s.types=o.types),rM.T=s}}function tG(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:r4,baseState:r4,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ti,lastRenderedState:r4},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ti,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function tW(){return Q(r5)}function tX(){return e9().memoizedState}function tq(){return e9().memoizedState}function tY(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=ig(),i=eO(t,e=eU(n),n);null!==i&&(ix(i,t,n),eF(i,t,n)),t={cache:en()},e.payload=t;return}t=t.return}}function tZ(e,t,n){var i=ig();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},tQ(e)?t0(t,n):null!==(n=eR(e,t,n,i))&&(ix(n,e,i),t1(n,t,i))}function tJ(e,t,n){t$(e,t,n,ig())}function t$(e,t,n,i){var r={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(tQ(e))t0(t,r);else{var a=e.alternate;if(0===e.lanes&&(null===a||0===a.lanes)&&null!==(a=t.lastRenderedReducer))try{var s=t.lastRenderedState,o=a(s,n);if(r.hasEagerState=!0,r.eagerState=o,sW(o,s))return eC(e,t,r,0),null===lg&&eA(),!1}catch{}finally{}if(null!==(n=eR(e,t,r,i)))return ix(n,e,i),t1(n,t,i),!0}return!1}function tK(e,t,n,r){if(r={lane:2,revertLane:ed(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},tQ(e)){if(t)throw Error(i(479))}else null!==(t=eR(e,n,r,2))&&ix(t,e,2)}function tQ(e){var t=e.alternate;return e===oG||null!==t&&t===oG}function t0(e,t){oY=oq=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function t1(e,t,n){if((4194048&n)!=0){var i=t.lanes;i&=e.pendingLanes,t.lanes=n|=i,y(e,n)}}function t2(e,t,n,i){n=null==(n=n(i,t=e.memoizedState))?t:rr({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}function t3(e,t,n,i,r,a,s){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(i,a,s):!t.prototype||!t.prototype.isPureReactComponent||!ev(n,i)||!ev(r,a)}function t4(e,t,n,i){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,i),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,i),t.state!==e&&o4.enqueueReplaceState(t,t.state,null)}function t5(e,t){var n=t;if("ref"in t)for(var i in n={},t)"ref"!==i&&(n[i]=t[i]);if(e=e.defaultProps)for(var r in n===t&&(n=rr({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function t6(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function t8(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function t9(e,t,n){return(n=eU(n)).tag=3,n.payload={element:null},n.callback=function(){t6(e,t)},n}function t7(e){return(e=eU(e)).tag=3,e}function ne(e,t,n,i){var r=n.type.getDerivedStateFromError;if("function"==typeof r){var a=i.value;e.payload=function(){return r(a)},e.callback=function(){t8(t,n,i)}}var s=n.stateNode;null!==s&&"function"==typeof s.componentDidCatch&&(e.callback=function(){t8(t,n,i),"function"!=typeof r&&(null===lz?lz=new Set([this]):lz.add(this));var e=i.stack;this.componentDidCatch(i.value,{componentStack:null!==e?e:""})})}function nt(e,t,n,i){t.child=null===e?oL(t,null,n,i):oI(t,e.child,n,i)}function nn(e,t,n,i,r){n=n.render;var a=t.ref;if("ref"in i){var s={};for(var o in i)"ref"!==o&&(s[o]=i[o])}else s=i;return K(t),i=e0(e,t,n,s,a,r),o=e4(),null===e||o6?(ot&&o&&P(t),t.flags|=1,nt(e,t,i,r),t.child):(e5(e,t,r),nw(e,t,r))}function ni(e,t,n,i,r){if(null===e){var a=n.type;return"function"!=typeof a||i$(a)||void 0!==a.defaultProps||null!==n.compare?((e=i0(n.type,null,i,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,nr(e,t,a,i,r))}if(a=e.child,!nT(e,r)){var s=a.memoizedProps;if((n=null!==(n=n.compare)?n:ev)(s,i)&&e.ref===t.ref)return nw(e,t,r)}return t.flags|=1,(e=iK(a,i)).ref=t.ref,e.return=t,t.child=e}function nr(e,t,n,i,r){if(null!==e){var a=e.memoizedProps;if(ev(a,i)&&e.ref===t.ref)if(o6=!1,t.pendingProps=i=a,!nT(e,r))return t.lanes=e.lanes,nw(e,t,r);else(131072&e.flags)!=0&&(o6=!0)}return nh(e,t,n,i,r)}function na(e,t,n,i){var r=i.children,a=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===i.mode){if((128&t.flags)!=0){if(a=null!==a?a.baseLanes|n:n,null!==e){for(i=t.child=e.child,r=0;null!==i;)r=r|i.lanes|i.childLanes,i=i.sibling;i=r&~a}else i=0,t.child=null;return no(e,t,a,n,i)}if((0x20000000&n)==0)return i=t.lanes=0x20000000,no(e,t,null!==a?a.baseLanes|n:n,n,i);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&em(t,null!==a?a.cachePool:null),null!==a?ej(t,a):eG(),eY(t)}else null!==a?(em(t,a.cachePool),ej(t,a),eZ(),t.memoizedState=null):(null!==e&&em(t,null),eG(),eZ());return nt(e,t,r,n),t.child}function ns(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function no(e,t,n,i,r){var a=ef();return t.memoizedState={baseLanes:n,cachePool:a=null===a?null:{parent:rB?oh._currentValue:oh._currentValue2,pool:a}},null!==e&&em(t,null),eG(),eY(t),null!==e&&Y(e,t,i,!0),t.childLanes=r,null}function nl(e,t){return(t=ny({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function nu(e,t,n){return oI(t,e.child,null,n),e=nl(t,t.pendingProps),e.flags|=2,eJ(t),t.memoizedState=null,e}function nc(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(i(284));(null===e||e.ref!==n)&&(t.flags|=4194816)}}function nh(e,t,n,i,r){return K(t),n=e0(e,t,n,i,void 0,r),i=e4(),null===e||o6?(ot&&i&&P(t),t.flags|=1,nt(e,t,n,r),t.child):(e5(e,t,r),nw(e,t,r))}function nd(e,t,n,i,r,a){return K(t),t.updateQueue=null,n=e2(t,i,n,r),e1(e),i=e4(),null===e||o6?(ot&&i&&P(t),t.flags|=1,nt(e,t,n,a),t.child):(e5(e,t,a),nw(e,t,a))}function np(e,t,n,i,r){if(K(t),null===t.stateNode){var a=sT,s=n.contextType;"object"==typeof s&&null!==s&&(a=Q(s)),t.memoizedState=null!==(a=new n(i,a)).state&&void 0!==a.state?a.state:null,a.updater=o4,t.stateNode=a,a._reactInternals=t,(a=t.stateNode).props=i,a.state=t.memoizedState,a.refs={},eN(t),s=n.contextType,a.context="object"==typeof s&&null!==s?Q(s):sT,a.state=t.memoizedState,"function"==typeof(s=n.getDerivedStateFromProps)&&(t2(t,n,s,i),a.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(s=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),s!==a.state&&o4.enqueueReplaceState(a,a.state,null),eB(t,i,a,r),ek(),a.state=t.memoizedState),"function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!0}else if(null===e){a=t.stateNode;var o=t.memoizedProps,l=t5(n,o);a.props=l;var u=a.context,c=n.contextType;s=sT,"object"==typeof c&&null!==c&&(s=Q(c));var h=n.getDerivedStateFromProps;c="function"==typeof h||"function"==typeof a.getSnapshotBeforeUpdate,o=t.pendingProps!==o,c||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o||u!==s)&&t4(t,a,i,s),oO=!1;var d=t.memoizedState;a.state=d,eB(t,i,a,r),ek(),u=t.memoizedState,o||d!==u||oO?("function"==typeof h&&(t2(t,n,h,i),u=t.memoizedState),(l=oO||t3(t,n,l,i,d,u,s))?(c||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=u),a.props=i,a.state=u,a.context=s,i=l):("function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!1)}else{a=t.stateNode,eD(e,t),c=t5(n,s=t.memoizedProps),a.props=c,h=t.pendingProps,d=a.context,u=n.contextType,l=sT,"object"==typeof u&&null!==u&&(l=Q(u)),(u="function"==typeof(o=n.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(s!==h||d!==l)&&t4(t,a,i,l),oO=!1,d=t.memoizedState,a.state=d,eB(t,i,a,r),ek();var p=t.memoizedState;s!==h||d!==p||oO||null!==e&&null!==e.dependencies&&Z(e.dependencies)?("function"==typeof o&&(t2(t,n,o,i),p=t.memoizedState),(c=oO||t3(t,n,c,i,d,p,l)||null!==e&&null!==e.dependencies&&Z(e.dependencies))?(u||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(i,p,l),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(i,p,l)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=p),a.props=i,a.state=p,a.context=l,i=c):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),i=!1)}return a=i,nc(e,t),i=(128&t.flags)!=0,a||i?(a=t.stateNode,n=i&&"function"!=typeof n.getDerivedStateFromError?null:a.render(),t.flags|=1,null!==e&&i?(t.child=oI(t,e.child,null,r),t.child=oI(t,null,n,r)):nt(e,t,n,r),t.memoizedState=a.state,e=t.child):e=nw(e,t,r),e}function nf(e,t,n,i){return V(),t.flags|=256,nt(e,t,n,i),t.child}function nm(e){return{baseLanes:e,cachePool:eg()}}function ng(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=lR),e}function nv(e,t,n){var r,a=t.pendingProps,s=!1,o=(128&t.flags)!=0;if((r=o)||(r=(null===e||null!==e.memoizedState)&&(2&oH.current)!=0),r&&(s=!0,t.flags&=-129),r=(32&t.flags)!=0,t.flags&=-33,null===e){if(ot){if(s?eX(t):eZ(),(e=oe)?null!==(e=aW(e,oi))&&(t.memoizedState={dehydrated:e,treeContext:null!==s2?{id:s3,overflow:s4}:null,retryLane:0x20000000,hydrationErrors:null},(n=i3(e)).return=t,t.child=n,s7=t,oe=null):e=null,null===e)throw F(t);return aP(e)?t.lanes=32:t.lanes=0x20000000,null}var l=a.children;return a=a.fallback,s?(eZ(),l=ny({mode:"hidden",children:l},s=t.mode),a=i1(a,s,n,null),l.return=t,a.return=t,l.sibling=a,t.child=l,(a=t.child).memoizedState=nm(n),a.childLanes=ng(e,r,n),t.memoizedState=o8,ns(null,a)):(eX(t),nx(t,l))}var u=e.memoizedState;if(null!==u&&null!==(l=u.dehydrated)){if(o)256&t.flags?(eX(t),t.flags&=-257,t=n_(e,t,n)):null!==t.memoizedState?(eZ(),t.child=e.child,t.flags|=128,t=null):(eZ(),l=a.fallback,s=t.mode,a=ny({mode:"visible",children:a.children},s),l=i1(l,s,n,null),l.flags|=2,a.return=t,l.return=t,a.sibling=l,t.child=a,oI(t,e.child,null,n),(a=t.child).memoizedState=nm(n),a.childLanes=ng(e,r,n),t.memoizedState=o8,t=ns(null,a));else if(eX(t),aP(l))r=aI(l).digest,(a=Error(i(419))).stack="",a.digest=r,j({value:a,source:null,stack:null}),t=n_(e,t,n);else if(o6||Y(e,t,n,!1),r=(n&e.childLanes)!=0,o6||r){if(null!==(r=lg)&&0!==(a=_(r,n))&&a!==u.retryLane)throw u.retryLane=a,eP(e,a),ix(r,e,a),o5;aR(l)||iR(),t=n_(e,t,n)}else aR(l)?(t.flags|=192,t.child=e.child,t=null):(e=u.treeContext,rj&&(oe=aB(l),s7=t,ot=!0,on=null,oi=!1,null!==e&&L(t,e)),t=nx(t,a.children),t.flags|=4096);return t}return s?(eZ(),l=a.fallback,s=t.mode,o=(u=e.child).sibling,(a=iK(u,{mode:"hidden",children:a.children})).subtreeFlags=0x3e00000&u.subtreeFlags,null!==o?l=iK(o,l):(l=i1(l,s,n,null),l.flags|=2),l.return=t,a.return=t,a.sibling=l,t.child=a,ns(null,a),a=t.child,null===(l=e.child.memoizedState)?l=nm(n):(null!==(s=l.cachePool)?(u=rB?oh._currentValue:oh._currentValue2,s=s.parent!==u?{parent:u,pool:u}:s):s=eg(),l={baseLanes:l.baseLanes|n,cachePool:s}),a.memoizedState=l,a.childLanes=ng(e,r,n),t.memoizedState=o8,ns(e.child,a)):(eX(t),e=(n=e.child).sibling,(n=iK(n,{mode:"visible",children:a.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function nx(e,t){return(t=ny({mode:"visible",children:t},e.mode)).return=e,e.child=t}function ny(e,n){return(e=t(22,e,null,n)).lanes=0,e}function n_(e,t,n){return oI(t,e.child,null,n),e=nx(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function nb(e,t,n){e.lanes|=t;var i=e.alternate;null!==i&&(i.lanes|=t),X(e.return,t,n)}function nS(e,t,n,i,r,a){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r,treeForkCount:a}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=n,s.tailMode=r,s.treeForkCount=a)}function nM(e,t,n){var i=t.pendingProps,r=i.revealOrder,a=i.tail;i=i.children;var s=oH.current,o=(2&s)!=0;if(o?(s=1&s|2,t.flags|=128):s&=1,h(oH,s),nt(e,t,i,n),i=ot?sQ:0,!o&&null!==e&&(128&e.flags)!=0)o:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&nb(e,n,t);else if(19===e.tag)nb(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break;for(;null===e.sibling;){if(null===e.return||e.return===t)break o;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===e$(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),nS(t,!1,r,n,a,i);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===e$(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}nS(t,!0,n,null,a,i);break;case"together":nS(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function nw(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),lE|=t.lanes,(n&t.childLanes)==0){if(null===e)return null;else if(Y(e,t,n,!1),(n&t.childLanes)==0)return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=iK(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=iK(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function nT(e,t){return(e.lanes&t)!=0||!!(null!==(e=e.dependencies)&&Z(e))}function nE(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)o6=!0;else{if(!nT(e,n)&&(128&t.flags)==0)return o6=!1,function(e,t,n){switch(t.tag){case 3:N(t,t.stateNode.containerInfo),G(t,oh,e.memoizedState.cache),V();break;case 27:case 5:U(t);break;case 4:N(t,t.stateNode.containerInfo);break;case 10:G(t,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,eq(t),null;break;case 13:var i=t.memoizedState;if(null!==i)return null!==i.dehydrated?(eX(t),t.flags|=128,null):(n&t.child.childLanes)!=0?nv(e,t,n):(eX(t),null!==(e=nw(e,t,n))?e.sibling:null);eX(t);break;case 19:var r=(128&e.flags)!=0;if((i=(n&t.childLanes)!=0)||(Y(e,t,n,!1),i=(n&t.childLanes)!=0),r){if(i)return nM(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),h(oH,oH.current),i)break;return null;case 22:return t.lanes=0,na(e,t,n,t.pendingProps);case 24:G(t,oh,e.memoizedState.cache)}return nw(e,t,n)}(e,t,n);o6=(131072&e.flags)!=0}else o6=!1,ot&&(1048576&t.flags)!=0&&R(t,sQ,t.index);switch(t.lanes=0,t.tag){case 16:o:{var r=t.pendingProps;if(e=e_(t.elementType),t.type=e,"function"==typeof e)i$(e)?(r=t5(e,r),t.tag=1,t=np(null,t,e,r,n)):(t.tag=0,t=nh(null,t,e,r,n));else{if(null!=e){var a=e.$$typeof;if(a===rp){t.tag=11,t=nn(null,t,e,r,n);break o}if(a===rg){t.tag=14,t=ni(null,t,e,r,n);break o}}throw Error(i(306,t=l(e)||e,""))}}return t;case 0:return nh(e,t,t.type,t.pendingProps,n);case 1:return a=t5(r=t.type,t.pendingProps),np(e,t,r,a,n);case 3:o:{if(N(t,t.stateNode.containerInfo),null===e)throw Error(i(387));var s=t.pendingProps;r=(a=t.memoizedState).element,eD(e,t),eB(t,s,null,n);var o=t.memoizedState;if(G(t,oh,s=o.cache),s!==a.cache&&q(t,[oh],n,!0),ek(),s=o.element,rj&&a.isDehydrated)if(a={element:s,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=a,t.memoizedState=a,256&t.flags){t=nf(e,t,s,n);break o}else if(s!==r){j(r=A(Error(i(424)),t)),t=nf(e,t,s,n);break o}else for(rj&&(oe=az(t.stateNode.containerInfo),s7=t,ot=!0,on=null,oi=!0),n=oL(t,null,s,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling;else{if(V(),s===r){t=nw(e,t,n);break o}nt(e,t,s,n)}t=t.child}return t;case 26:if(si)return nc(e,t),null===e?(n=ss(t.type,null,t.pendingProps,null))?t.memoizedState=n:ot||(t.stateNode=sd(t.type,t.pendingProps,s8.current,t)):t.memoizedState=ss(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(sv)return U(t),null===e&&sv&&ot&&(r=t.stateNode=sx(t.type,t.pendingProps,s8.current,s5.current,!1),s7=t,oi=!0,oe=aV(t.type,r,oe)),nt(e,t,t.pendingProps.children,n),nc(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&ot&&(st(t.type,t.pendingProps,s5.current),(a=r=oe)&&(null!==(r=aH(r,t.type,t.pendingProps,oi))?(t.stateNode=r,s7=t,oe=aF(r),oi=!1,a=!0):a=!1),a||F(t)),U(t),a=t.type,s=t.pendingProps,o=null!==e?e.memoizedProps:null,r=s.children,rU(a,s)?r=null:null!==o&&rU(a,o)&&(t.flags|=32),null!==t.memoizedState&&(a=e0(e,t,e3,null,null,n),rB?r5._currentValue=a:r5._currentValue2=a),nc(e,t),nt(e,t,r,n),t.child;case 6:return null===e&&ot&&(sn(t.pendingProps,s5.current),(e=n=oe)&&(null!==(n=aj(n,t.pendingProps,oi))?(t.stateNode=n,s7=t,oe=null,e=!0):e=!1),e||F(t)),null;case 13:return nv(e,t,n);case 4:return N(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=oI(t,null,r,n):nt(e,t,r,n),t.child;case 11:return nn(e,t,t.type,t.pendingProps,n);case 7:return nt(e,t,t.pendingProps,n),t.child;case 8:case 12:return nt(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,G(t,t.type,r.value),nt(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,K(t),r=r(a=Q(a)),t.flags|=1,nt(e,t,r,n),t.child;case 14:return ni(e,t,t.type,t.pendingProps,n);case 15:return nr(e,t,t.type,t.pendingProps,n);case 19:return nM(e,t,n);case 31:var u=e,c=t,d=n,p=c.pendingProps,f=(128&c.flags)!=0;if(c.flags&=-129,null===u){if(ot){if("hidden"===p.mode)return u=nl(c,p),c.lanes=0x20000000,ns(null,u);if(eq(c),(u=oe)?null!==(u=aG(u,oi))&&(c.memoizedState={dehydrated:u,treeContext:null!==s2?{id:s3,overflow:s4}:null,retryLane:0x20000000,hydrationErrors:null},(d=i3(u)).return=c,c.child=d,s7=c,oe=null):u=null,null===u)throw F(c);return c.lanes=0x20000000,null}return nl(c,p)}var m=u.memoizedState;if(null!==m){var g=m.dehydrated;if(eq(c),f)if(256&c.flags)c.flags&=-257,c=nu(u,c,d);else if(null!==c.memoizedState)c.child=u.child,c.flags|=128,c=null;else throw Error(i(558));else if(o6||Y(u,c,d,!1),f=(d&u.childLanes)!=0,o6||f){if(null!==(p=lg)&&0!==(g=_(p,d))&&g!==m.retryLane)throw m.retryLane=g,eP(u,g),ix(p,u,g),o5;iR(),c=nu(u,c,d)}else u=m.treeContext,rj&&(oe=ak(g),s7=c,ot=!0,on=null,oi=!1,null!==u&&L(c,u)),c=nl(c,p),c.flags|=4096;return c}return(u=iK(u.child,{mode:p.mode,children:p.children})).ref=c.ref,c.child=u,u.return=c,u;case 22:return na(e,t,n,t.pendingProps);case 24:return K(t),r=Q(oh),null===e?(null===(a=ef())&&(a=lg,s=en(),a.pooledCache=s,s.refCount++,null!==s&&(a.pooledCacheLanes|=n),a=s),t.memoizedState={parent:r,cache:a},eN(t),G(t,oh,a)):((e.lanes&n)!=0&&(eD(e,t),eB(t,null,null,n),ek()),a=e.memoizedState,s=t.memoizedState,a.parent!==r?(a={parent:r,cache:r},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),G(t,oh,r)):(G(t,oh,r=s.cache),r!==a.cache&&q(t,[oh],n,!0))),nt(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function nA(e){e.flags|=4}function nC(e){rH&&(e.flags|=8)}function nR(e,t){if(null!==e&&e.child===t.child)return!1;if((16&t.flags)!=0)return!0;for(e=t.child;null!==e;){if((8218&e.flags)!=0||(8218&e.subtreeFlags)!=0)return!0;e=e.sibling}return!1}function nP(e,t,n,i){if(rV)for(n=t.child;null!==n;){if(5===n.tag||6===n.tag)rN(e,n.stateNode);else if(!(4===n.tag||sv&&27===n.tag)&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(rH)for(var r=t.child;null!==r;){if(5===r.tag){var a=r.stateNode;n&&i&&(a=aA(a,r.type,r.memoizedProps)),rN(e,a)}else if(6===r.tag)a=r.stateNode,n&&i&&(a=aC(a,r.memoizedProps)),rN(e,a);else if(4!==r.tag){if(22===r.tag&&null!==r.memoizedState)null!==(a=r.child)&&(a.return=r),nP(e,r,!0,!0);else if(null!==r.child){r.child.return=r,r=r.child;continue}}if(r===t)break;for(;null===r.sibling;){if(null===r.return||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}}function nI(e,t){if(rH&&nR(e,t)){var n=(e=t.stateNode).containerInfo,i=aM();(function e(t,n,i,r){var a=!1;if(rH)for(var s=n.child;null!==s;){if(5===s.tag){var o=s.stateNode;i&&r&&(o=aA(o,s.type,s.memoizedProps)),aw(t,o)}else if(6===s.tag)o=s.stateNode,i&&r&&(o=aC(o,s.memoizedProps)),aw(t,o);else if(4!==s.tag){if(22===s.tag&&null!==s.memoizedState)null!==(a=s.child)&&(a.return=s),e(t,s,!0,!0),a=!0;else if(null!==s.child){s.child.return=s,s=s.child;continue}}if(s===n)break;for(;null===s.sibling;){if(null===s.return||s.return===n)return a;s=s.return}s.sibling.return=s.return,s=s.sibling}return a})(i,t,!1,!1),e.pendingChildren=i,nA(t),aT(n,i)}}function nL(e,t,n,i){if(rV)e.memoizedProps!==i&&nA(t);else if(rH){var r=e.stateNode,a=e.memoizedProps;if((e=nR(e,t))||a!==i){var s=s5.current;(a=aS(r,n,a,i,!e,null))===r?t.stateNode=r:(nC(t),rD(a,n,i,s)&&nA(t),t.stateNode=a,e&&nP(a,t,!1,!1))}else t.stateNode=r}}function nN(e,t,n,i,r){if((32&e.mode)!=0&&(null===n?r$(t,i):rK(t,n,i))){if(e.flags|=0x1000000,(0x13ffff40&r)===r||rQ(t,i))if(r0(e.stateNode,t,i))e.flags|=8192;else if(iE())e.flags|=8192;else throw oC=oA,oT}else e.flags&=-0x1000001}function nD(e,t){if(sf(t)){if(e.flags|=0x1000000,!sm(t))if(iE())e.flags|=8192;else throw oC=oA,oT}else e.flags&=-0x1000001}function nU(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?m():0x20000000,e.lanes|=t,lP|=t)}function nO(e,t){if(!ot)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var i=null;null!==n;)null!==n.alternate&&(i=n),n=n.sibling;null===i?t||null===e.tail?e.tail=null:e.tail.sibling=null:i.sibling=null}}function nF(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,i=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=0x3e00000&r.subtreeFlags,i|=0x3e00000&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=i,e.childLanes=n,t}function nz(e,t){switch(I(t),t.tag){case 3:W(oh),D();break;case 26:case 27:case 5:O(t);break;case 4:D();break;case 31:null!==t.memoizedState&&eJ(t);break;case 13:eJ(t);break;case 19:c(oH);break;case 10:W(t.type);break;case 22:case 23:eJ(t),eW(),null!==e&&c(oM);break;case 24:W(oh)}}function nk(e,t){try{var n=t.updateQueue,i=null!==n?n.lastEffect:null;if(null!==i){var r=i.next;n=r;do{if((n.tag&e)===e){i=void 0;var a=n.create;n.inst.destroy=i=a()}n=n.next}while(n!==r)}}catch(e){iG(t,t.return,e)}}function nB(e,t,n){try{var i=t.updateQueue,r=null!==i?i.lastEffect:null;if(null!==r){var a=r.next;i=a;do{if((i.tag&e)===e){var s=i.inst,o=s.destroy;if(void 0!==o){s.destroy=void 0,r=t;try{o()}catch(e){iG(r,n,e)}}}i=i.next}while(i!==a)}}catch(e){iG(t,t.return,e)}}function nV(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{eH(t,n)}catch(t){iG(e,e.return,t)}}}function nH(e,t,n){n.props=t5(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){iG(e,t,n)}}function nj(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var i=rA(e.stateNode);break;default:i=e.stateNode}"function"==typeof n?e.refCleanup=n(i):n.current=i}}catch(n){iG(e,t,n)}}function nG(e,t){var n=e.ref,i=e.refCleanup;if(null!==n)if("function"==typeof i)try{i()}catch(n){iG(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){iG(e,t,n)}else n.current=null}function nW(e){var t=e.type,n=e.memoizedProps,i=e.stateNode;try{ac(i,t,n,e)}catch(t){iG(e,e.return,t)}}function nX(e,t,n){try{ah(e.stateNode,e.type,n,t,e)}catch(t){iG(e,e.return,t)}}function nq(e){return 5===e.tag||3===e.tag||!!si&&26===e.tag||!!sv&&27===e.tag&&sS(e.type)||4===e.tag}function nY(e){o:for(;;){for(;null===e.sibling;){if(null===e.return||nq(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(sv&&27===e.tag&&sS(e.type)||2&e.flags||null===e.child||4===e.tag)continue o;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function nZ(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?ad(n,e,t):ao(n,e);else if(4!==i&&(sv&&27===i&&sS(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(nZ(e,t,n),e=e.sibling;null!==e;)nZ(e,t,n),e=e.sibling}function nJ(e,t,n){e=e.containerInfo;try{aE(e,n)}catch(e){iG(t,t.return,e)}}function n$(e){var t=e.stateNode,n=e.memoizedProps;try{sy(e.type,n,t,e)}catch(t){iG(e,e.return,t)}}function nK(e,t,n){var i=n.flags;switch(n.tag){case 0:case 11:case 15:n8(e,n),4&i&&nk(5,n);break;case 1:if(n8(e,n),4&i)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){iG(n,n.return,e)}else{var r=t5(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){iG(n,n.return,e)}}64&i&&nV(n),512&i&&nj(n,n.return);break;case 3:if(n8(e,n),64&i&&null!==(i=n.updateQueue)){if(e=null,null!==n.child)switch(n.child.tag){case 27:case 5:e=rA(n.child.stateNode);break;case 1:e=n.child.stateNode}try{eH(i,e)}catch(e){iG(n,n.return,e)}}break;case 27:sv&&null===t&&4&i&&n$(n);case 26:case 5:if(n8(e,n),null===t){if(4&i)nW(n);else if(64&i){e=n.type,t=n.memoizedProps,r=n.stateNode;try{aK(r,e,t,n)}catch(e){iG(n,n.return,e)}}}512&i&&nj(n,n.return);break;case 12:default:n8(e,n);break;case 31:n8(e,n),4&i&&n1(e,n);break;case 13:n8(e,n),4&i&&n2(e,n),64&i&&null!==(i=n.memoizedState)&&null!==(i=i.dehydrated)&&aL(i,n=iY.bind(null,n));break;case 22:if(!(i=null!==n.memoizedState||o9)){t=null!==t&&null!==t.memoizedState||o7,r=o9;var a=o7;o9=i,(o7=t)&&!a?function e(t,n,i){for(i=i&&(8772&n.subtreeFlags)!=0,n=n.child;null!==n;){var r=n.alternate,a=t,s=n,o=s.flags;switch(s.tag){case 0:case 11:case 15:e(a,s,i),nk(4,s);break;case 1:if(e(a,s,i),"function"==typeof(a=(r=s).stateNode).componentDidMount)try{a.componentDidMount()}catch(e){iG(r,r.return,e)}if(null!==(a=(r=s).updateQueue)){var l=r.stateNode;try{var u=a.shared.hiddenCallbacks;if(null!==u)for(a.shared.hiddenCallbacks=null,a=0;a<u.length;a++)eV(u[a],l)}catch(e){iG(r,r.return,e)}}i&&64&o&&nV(s),nj(s,s.return);break;case 27:sv&&n$(s);case 26:case 5:e(a,s,i),i&&null===r&&4&o&&nW(s),nj(s,s.return);break;case 12:default:e(a,s,i);break;case 31:e(a,s,i),i&&4&o&&n1(a,s);break;case 13:e(a,s,i),i&&4&o&&n2(a,s);break;case 22:null===s.memoizedState&&e(a,s,i),nj(s,s.return);case 30:}n=n.sibling}}(e,n,(8772&n.subtreeFlags)!=0):n8(e,n),o9=r,o7=a}case 30:}}function nQ(e,t,n){for(n=n.child;null!==n;)n0(e,t,n),n=n.sibling}function n0(e,t,n){if(sG&&"function"==typeof sG.onCommitFiberUnmount)try{sG.onCommitFiberUnmount(sj,n)}catch{}switch(n.tag){case 26:if(si){o7||nG(n,t),nQ(e,t,n),n.memoizedState?sl(n.memoizedState):n.stateNode&&sh(n.stateNode);break}case 27:if(sv){o7||nG(n,t);var i=li,r=lr;sS(n.type)&&(li=n.stateNode,lr=!1),nQ(e,t,n),s_(n.stateNode),li=i,lr=r;break}case 5:o7||nG(n,t);case 6:if(rV){if(i=li,r=lr,li=null,nQ(e,t,n),li=i,lr=r,null!==li)if(lr)try{am(li,n.stateNode)}catch(e){iG(n,t,e)}else try{af(li,n.stateNode)}catch(e){iG(n,t,e)}}else nQ(e,t,n);break;case 18:rV&&null!==li&&(lr?a5(li,n.stateNode):a4(li,n.stateNode));break;case 4:rV?(i=li,r=lr,li=n.stateNode.containerInfo,lr=!0,nQ(e,t,n),li=i,lr=r):(rH&&nJ(n.stateNode,n,aM()),nQ(e,t,n));break;case 0:case 11:case 14:case 15:nB(2,n,t),o7||nB(4,n,t),nQ(e,t,n);break;case 1:o7||(nG(n,t),"function"==typeof(i=n.stateNode).componentWillUnmount&&nH(n,t,i)),nQ(e,t,n);break;case 21:default:nQ(e,t,n);break;case 22:o7=(i=o7)||null!==n.memoizedState,nQ(e,t,n),o7=i}}function n1(e,t){if(rj&&null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)){e=e.dehydrated;try{a0(e)}catch(e){iG(t,t.return,e)}}}function n2(e,t){if(rj&&null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))try{a1(e)}catch(e){iG(t,t.return,e)}}function n3(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new lt),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new lt),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var i=iZ.bind(null,e,t);t.then(i,i)}})}function n4(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var a=n[r],s=e,o=t;if(rV){var l=o;o:for(;null!==l;){switch(l.tag){case 27:if(sv){if(sS(l.type)){li=l.stateNode,lr=!1;break o}break}case 5:li=l.stateNode,lr=!1;break o;case 3:case 4:li=l.stateNode.containerInfo,lr=!0;break o}l=l.return}if(null===li)throw Error(i(160));n0(s,o,a),li=null,lr=!1}else n0(s,o,a);null!==(s=a.alternate)&&(s.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)n5(t,e),t=t.sibling}function n5(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:n4(t,e),n6(e),4&r&&(nB(3,e,e.return),nk(3,e),nB(5,e,e.return));break;case 1:n4(t,e),n6(e),512&r&&(o7||null===n||nG(n,n.return)),64&r&&o9&&null!==(e=e.updateQueue)&&null!==(r=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?r:n.concat(r));break;case 26:if(si){var a=la;if(n4(t,e),n6(e),512&r&&(o7||null===n||nG(n,n.return)),4&r){r=null!==n?n.memoizedState:null;var s=e.memoizedState;null===n?null===s?null===e.stateNode?e.stateNode=su(a,e.type,e.memoizedProps,e):sc(a,e.type,e.stateNode):e.stateNode=so(a,s,e.memoizedProps):r!==s?(null===r?null!==n.stateNode&&sh(n.stateNode):sl(r),null===s?sc(a,e.type,e.stateNode):so(a,s,e.memoizedProps)):null===s&&null!==e.stateNode&&nX(e,e.memoizedProps,n.memoizedProps)}break}case 27:if(sv){n4(t,e),n6(e),512&r&&(o7||null===n||nG(n,n.return)),null!==n&&4&r&&nX(e,e.memoizedProps,n.memoizedProps);break}case 5:if(n4(t,e),n6(e),512&r&&(o7||null===n||nG(n,n.return)),rV){if(32&e.flags){a=e.stateNode;try{ag(a)}catch(t){iG(e,e.return,t)}}4&r&&null!=e.stateNode&&(a=e.memoizedProps,nX(e,a,null!==n?n.memoizedProps:a)),1024&r&&(le=!0)}else rH&&null!==e.alternate&&(e.alternate.stateNode=e.stateNode);break;case 6:if(n4(t,e),n6(e),4&r&&rV){if(null===e.stateNode)throw Error(i(162));r=e.memoizedProps,n=null!==n?n.memoizedProps:r,a=e.stateNode;try{au(a,n,r)}catch(t){iG(e,e.return,t)}}break;case 3:if(si?(sp(),a=la,la=sa(t.containerInfo),n4(t,e),la=a):n4(t,e),n6(e),4&r){if(rV&&rj&&null!==n&&n.memoizedState.isDehydrated)try{aQ(t.containerInfo)}catch(t){iG(e,e.return,t)}if(rH){r=t.containerInfo,n=t.pendingChildren;try{aE(r,n)}catch(t){iG(e,e.return,t)}}}le&&(le=!1,function e(t){if(1024&t.subtreeFlags)for(t=t.child;null!==t;){var n=t;e(n),5===n.tag&&1024&n.flags&&r6(n.stateNode),t=t.sibling}}(e));break;case 4:si?(n=la,la=sa(e.stateNode.containerInfo),n4(t,e),n6(e),la=n):(n4(t,e),n6(e)),4&r&&rH&&nJ(e.stateNode,e,e.stateNode.pendingChildren);break;case 12:default:n4(t,e),n6(e);break;case 31:case 19:n4(t,e),n6(e),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,n3(e,r));break;case 13:n4(t,e),n6(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(lD=sO()),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,n3(e,r));break;case 22:a=null!==e.memoizedState;var o=null!==n&&null!==n.memoizedState,l=o9,u=o7;if(o9=l||a,o7=u||o,n4(t,e),o7=u,o9=l,n6(e),8192&r&&((t=e.stateNode)._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===n||o||o9||o7||function e(t){for(t=t.child;null!==t;){var n=t;switch(n.tag){case 0:case 11:case 14:case 15:nB(4,n,n.return),e(n);break;case 1:nG(n,n.return);var i=n.stateNode;"function"==typeof i.componentWillUnmount&&nH(n,n.return,i),e(n);break;case 27:sv&&s_(n.stateNode);case 26:case 5:nG(n,n.return),e(n);break;case 22:null===n.memoizedState&&e(n);break;default:e(n)}t=t.sibling}}(e)),rV)){o:if(n=null,rV)for(t=e;;){if(5===t.tag||si&&26===t.tag){if(null===n){o=n=t;try{s=o.stateNode,a?av(s):ay(o.stateNode,o.memoizedProps)}catch(e){iG(o,o.return,e)}}}else if(6===t.tag){if(null===n){o=t;try{var c=o.stateNode;a?ax(c):a_(c,o.memoizedProps)}catch(e){iG(o,o.return,e)}}}else if(18===t.tag){if(null===n){o=t;try{var h=o.stateNode;a?a6(h):a8(o.stateNode)}catch(e){iG(o,o.return,e)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break o;for(;null===t.sibling;){if(null===t.return||t.return===e)break o;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}}4&r&&null!==(r=e.updateQueue)&&null!==(n=r.retryQueue)&&(r.retryQueue=null,n3(e,n));case 30:case 21:}}function n6(e){var t=e.flags;if(2&t){try{for(var n,r=e.return;null!==r;){if(nq(r)){n=r;break}r=r.return}if(rV){if(null==n)throw Error(i(160));switch(n.tag){case 27:if(sv){var a=n.stateNode,s=nY(e);nZ(e,s,a);break}case 5:var o=n.stateNode;32&n.flags&&(ag(o),n.flags&=-33);var l=nY(e);nZ(e,l,o);break;case 3:case 4:var u=n.stateNode.containerInfo,c=nY(e);!function e(t,n,i){var r=t.tag;if(5===r||6===r)t=t.stateNode,n?ap(i,t,n):al(i,t);else if(4!==r&&(sv&&27===r&&sS(t.type)&&(i=t.stateNode,n=null),null!==(t=t.child)))for(e(t,n,i),t=t.sibling;null!==t;)e(t,n,i),t=t.sibling}(e,c,u);break;default:throw Error(i(161))}}}catch(t){iG(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function n8(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)nK(e,t.alternate,t),t=t.sibling}function n9(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&ei(n))}function n7(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&ei(e))}function ie(e,t,n,i){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)it(e,t,n,i),t=t.sibling}function it(e,t,n,i){var r=t.flags;switch(t.tag){case 0:case 11:case 15:ie(e,t,n,i),2048&r&&nk(9,t);break;case 1:case 31:case 13:default:ie(e,t,n,i);break;case 3:ie(e,t,n,i),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&ei(e)));break;case 12:if(2048&r){ie(e,t,n,i),e=t.stateNode;try{var a=t.memoizedProps,s=a.id,o=a.onPostCommit;"function"==typeof o&&o(s,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(e){iG(t,t.return,e)}}else ie(e,t,n,i);break;case 23:break;case 22:a=t.stateNode,s=t.alternate,null!==t.memoizedState?2&a._visibility?ie(e,t,n,i):ii(e,t):2&a._visibility?ie(e,t,n,i):(a._visibility|=2,function e(t,n,i,r,a){for(a=a&&(10256&n.subtreeFlags)!=0,n=n.child;null!==n;){var s=n,o=s.flags;switch(s.tag){case 0:case 11:case 15:e(t,s,i,r,a),nk(8,s);break;case 23:break;case 22:var l=s.stateNode;null!==s.memoizedState?2&l._visibility?e(t,s,i,r,a):ii(t,s):(l._visibility|=2,e(t,s,i,r,a)),a&&2048&o&&n9(s.alternate,s);break;case 24:e(t,s,i,r,a),a&&2048&o&&n7(s.alternate,s);break;default:e(t,s,i,r,a)}n=n.sibling}}(e,t,n,i,(10256&t.subtreeFlags)!=0)),2048&r&&n9(s,t);break;case 24:ie(e,t,n,i),2048&r&&n7(t.alternate,t)}}function ii(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=t,i=n.flags;switch(n.tag){case 22:ii(e,n),2048&i&&n9(n.alternate,n);break;case 24:ii(e,n),2048&i&&n7(n.alternate,n);break;default:ii(e,n)}t=t.sibling}}function ir(e,t,n){if(e.subtreeFlags&ls)for(e=e.child;null!==e;)ia(e,t,n),e=e.sibling}function ia(e,t,n){switch(e.tag){case 26:if(ir(e,t,n),e.flags&ls)if(null!==e.memoizedState)sg(n,la,e.memoizedState,e.memoizedProps);else{var i=e.stateNode,r=e.type;e=e.memoizedProps,((0x13ffff40&t)===t||rQ(r,e))&&r2(n,i,r,e)}break;case 5:ir(e,t,n),e.flags&ls&&(i=e.stateNode,r=e.type,e=e.memoizedProps,((0x13ffff40&t)===t||rQ(r,e))&&r2(n,i,r,e));break;case 3:case 4:si?(i=la,la=sa(e.stateNode.containerInfo),ir(e,t,n),la=i):ir(e,t,n);break;case 22:null===e.memoizedState&&(null!==(i=e.alternate)&&null!==i.memoizedState?(i=ls,ls=0x1000000,ir(e,t,n),ls=i):ir(e,t,n));break;default:ir(e,t,n)}}function is(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(null!==e)}}function io(e){var t=e.deletions;if((16&e.flags)!=0){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];ln=i,iu(i,e)}is(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)il(e),e=e.sibling}function il(e){switch(e.tag){case 0:case 11:case 15:io(e),2048&e.flags&&nB(9,e,e.return);break;case 3:case 12:default:io(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,function e(t){var n=t.deletions;if((16&t.flags)!=0){if(null!==n)for(var i=0;i<n.length;i++){var r=n[i];ln=r,iu(r,t)}is(t)}for(t=t.child;null!==t;){switch((n=t).tag){case 0:case 11:case 15:nB(8,n,n.return),e(n);break;case 22:2&(i=n.stateNode)._visibility&&(i._visibility&=-3,e(n));break;default:e(n)}t=t.sibling}}(e)):io(e)}}function iu(e,t){for(;null!==ln;){var n=ln;switch(n.tag){case 0:case 11:case 15:nB(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var i=n.memoizedState.cachePool.pool;null!=i&&i.refCount++}break;case 24:ei(n.memoizedState.cache)}if(null!==(i=n.child))i.return=n,ln=i;else for(n=e;null!==ln;){var r=(i=ln).sibling,a=i.return;if(function e(t){var n=t.alternate;null!==n&&(t.alternate=null,e(n)),t.child=null,t.deletions=null,t.sibling=null,5===t.tag&&null!==(n=t.stateNode)&&rJ(n),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}(i),i===n){ln=null;break}if(null!==r){r.return=a,ln=r;break}ln=a}}}function ic(e){var t=rG(e);if(null!=t){if("string"!=typeof t.memoizedProps["data-testname"])throw Error(i(364));return t}if(null===(e=ae(e)))throw Error(i(362));return e.stateNode.current}function ih(e,t){var n=e.tag;switch(t.$$typeof){case ll:if(e.type===t.value)return!0;break;case lu:o:{for(t=t.value,e=[e,0],n=0;n<e.length;){var r=e[n++],a=r.tag,s=e[n++],o=t[s];if(5!==a&&26!==a&&27!==a||!ai(r)){for(;null!=o&&ih(r,o);)o=t[++s];if(s===t.length){t=!0;break o}for(r=r.child;null!==r;)e.push(r,s),r=r.sibling}}t=!1}return t;case lc:if((5===n||26===n||27===n)&&ar(e.stateNode,t.value))return!0;break;case ld:if((5===n||6===n||26===n||27===n)&&null!==(e=an(e))&&0<=e.indexOf(t.value))return!0;break;case lh:if((5===n||26===n||27===n)&&"string"==typeof(e=e.memoizedProps["data-testname"])&&e.toLowerCase()===t.value.toLowerCase())return!0;break;default:throw Error(i(365))}return!1}function id(e){switch(e.$$typeof){case ll:return"<"+(l(e.value)||"Unknown")+">";case lu:return":has("+(id(e)||"")+")";case lc:return'[role="'+e.value+'"]';case ld:return'"'+e.value+'"';case lh:return'[data-testname="'+e.value+'"]';default:throw Error(i(365))}}function ip(e,t){var n=[];e=[e,0];for(var i=0;i<e.length;){var r=e[i++],a=r.tag,s=e[i++],o=t[s];if(5!==a&&26!==a&&27!==a||!ai(r)){for(;null!=o&&ih(r,o);)o=t[++s];if(s===t.length)n.push(r);else for(r=r.child;null!==r;)e.push(r,s),r=r.sibling}}return n}function im(e,t){if(!r7)throw Error(i(363));e=ip(e=ic(e),t),t=[],e=Array.from(e);for(var n=0;n<e.length;){var r=e[n++],a=r.tag;if(5===a||26===a||27===a)ai(r)||t.push(r.stateNode);else for(r=r.child;null!==r;)e.push(r),r=r.sibling}return t}function ig(){return(2&lm)!=0&&0!==lx?lx&-lx:null!==rM.T?ed():rY()}function iv(){if(0===lR)if((0x20000000&lx)==0||ot){var e=sP;(3932160&(sP<<=1))==0&&(sP=262144),lR=e}else lR=0x20000000;return null!==(e=oB.current)&&(e.flags|=32),lR}function ix(e,t,n){(e===lg&&(2===ly||9===ly)||null!==e.cancelPendingCommit)&&(iw(e,0),ib(e,lx,lR,!1)),v(e,n),((2&lm)==0||e!==lg)&&(e===lg&&((2&lm)==0&&(lA|=n),4===lT&&ib(e,lx,lR,!1)),ea(e))}function iy(e,t,n){if((6&lm)!=0)throw Error(i(327));for(var r=!n&&(127&t)==0&&(t&e.expiredLanes)==0||f(e,t),a=r?function(e,t){var n=lm;lm|=2;var r=iA(),a=iC();lg!==e||lx!==t?(lF=null,lO=sO()+500,iw(e,t)):lS=f(e,t);o:for(;;)try{if(0!==ly&&null!==lv){t=lv;var s=l_;l:switch(ly){case 1:ly=0,l_=null,iN(e,t,s,1);break;case 2:case 9:if(ex(s)){ly=0,l_=null,iL(t);break}t=function(){2!==ly&&9!==ly||lg!==e||(ly=7),ea(e)},s.then(t,t);break o;case 3:ly=7;break o;case 4:ly=5;break o;case 7:ex(s)?(ly=0,l_=null,iL(t)):(ly=0,l_=null,iN(e,t,s,7));break;case 5:var o=null;switch(lv.tag){case 26:o=lv.memoizedState;case 5:case 27:var l=lv,u=l.type,c=l.pendingProps;if(o?sm(o):r0(l.stateNode,u,c)){ly=0,l_=null;var h=l.sibling;if(null!==h)lv=h;else{var d=l.return;null!==d?(lv=d,iD(d)):lv=null}break l}}ly=0,l_=null,iN(e,t,s,5);break;case 6:ly=0,l_=null,iN(e,t,s,6);break;case 8:iM(),lT=6;break o;default:throw Error(i(462))}}for(;null!==lv&&!sD();)iI(lv);break}catch(t){iT(e,t)}return oo=os=null,rM.H=r,rM.A=a,lm=n,null!==lv?0:(lg=null,lx=0,eA(),lT)}(e,t):iP(e,t,!0),s=r;;){if(0===a)lS&&!r&&ib(e,t,0,!1);else{if(n=e.current.alternate,s&&!function(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&null!==(n=t.updateQueue)&&null!==(n=n.stores))for(var i=0;i<n.length;i++){var r=n[i],a=r.getSnapshot;r=r.value;try{if(!sW(a(),r))return!1}catch{return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(n)){a=iP(e,t,!1),s=!1;continue}if(2===a){if(s=t,e.errorRecoveryDisabledLanes&s)var o=0;else o=0!=(o=-0x20000001&e.pendingLanes)?o:0x20000000&o?0x20000000:0;if(0!==o){t=o;o:{a=lI;var l=rj&&e.current.memoizedState.isDehydrated;if(l&&(iw(e,o).flags|=256),2!==(o=iP(e,o,!1))){if(lM&&!l){e.errorRecoveryDisabledLanes|=s,lA|=s,a=4;break o}s=lL,lL=a,null!==s&&(null===lL?lL=s:lL.push.apply(lL,s))}a=o}if(s=!1,2!==a)continue}}if(1===a){iw(e,0),ib(e,t,0,!0);break}o:{switch(r=e,s=a){case 0:case 1:throw Error(i(345));case 4:if((4194048&t)!==t)break;case 6:ib(r,t,lR,!lb);break o;case 2:lL=null;break;case 3:case 5:break;default:throw Error(i(329))}if((0x3c00000&t)===t&&10<(a=lD+300-sO())){if(ib(r,t,lR,!lb),0!==p(r,0,!0))break o;lH=t,r.timeoutHandle=rF(i_.bind(null,r,n,lL,lF,lN,t,lR,lA,lP,lb,s,"Throttled",-0,0),a);break o}i_(r,n,lL,lF,lN,t,lR,lA,lP,lb,s,null,-0,0)}}break}ea(e)}function i_(e,t,n,i,r,a,s,o,l,u,c,h,d,p){if(e.timeoutHandle=rk,8192&(h=t.subtreeFlags)||(0x1002000&h)==0x1002000){ia(t,a,h=r1());var f=(0x3c00000&a)===a?lD-sO():(4194048&a)===a?lU-sO():0;if(null!==(f=r3(h,f))){lH=a,e.cancelPendingCommit=f(iO.bind(null,e,t,a,n,i,r,s,o,l,c,h,null,d,p)),ib(e,a,s,!u);return}}iO(e,t,a,n,i,r,s,o,l)}function ib(e,t,n,i){t&=~lC,t&=~lA,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var r=t;0<r;){var a=31-sE(r),s=1<<a;i[a]=-1,r&=~s}0!==n&&x(e,n,t)}function iS(){return(6&lm)!=0||(es(0,!1),!1)}function iM(){if(null!==lv){if(0===ly)var e=lv.return;else e=lv,oo=os=null,e6(e),oR=null,oP=0,e=lv;for(;null!==e;)nz(e.alternate,e),e=e.return;lv=null}}function iw(e,t){var n=e.timeoutHandle;n!==rk&&(e.timeoutHandle=rk,rz(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),lH=0,iM(),lg=e,lv=n=iK(e.current,null),lx=t,ly=0,l_=null,lb=!1,lS=f(e,t),lM=!1,lP=lR=lC=lA=lE=lT=0,lL=lI=null,lN=!1,(8&t)!=0&&(t|=32&t);var i=e.entangledLanes;if(0!==i)for(e=e.entanglements,i&=t;0<i;){var r=31-sE(i),a=1<<r;t|=e[r],i&=~a}return lw=t,eA(),n}function iT(e,t){oG=null,rM.H=o0,t===ow||t===oE?(t=eb(),ly=3):t===oT?(t=eb(),ly=4):ly=t===o5?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,l_=t,null===lv&&(lT=1,t6(e,A(t,e.current)))}function iE(){var e=oB.current;return null===e||((4194048&lx)===lx?null===oV:((0x3c00000&lx)===lx||(0x20000000&lx)!=0)&&e===oV)}function iA(){var e=rM.H;return rM.H=o0,null===e?o0:e}function iC(){var e=rM.A;return rM.A=lo,e}function iR(){lT=4,lb||(4194048&lx)!==lx&&null!==oB.current||(lS=!0),(0x7ffffff&lE)==0&&(0x7ffffff&lA)==0||null===lg||ib(lg,lx,lR,!1)}function iP(e,t,n){var i=lm;lm|=2;var r=iA(),a=iC();(lg!==e||lx!==t)&&(lF=null,iw(e,t)),t=!1;var s=lT;o:for(;;)try{if(0!==ly&&null!==lv){var o=lv,l=l_;switch(ly){case 8:iM(),s=6;break o;case 3:case 2:case 9:case 6:null===oB.current&&(t=!0);var u=ly;if(ly=0,l_=null,iN(e,o,l,u),n&&lS){s=0;break o}break;default:u=ly,ly=0,l_=null,iN(e,o,l,u)}}(function(){for(;null!==lv;)iI(lv)})(),s=lT;break}catch(t){iT(e,t)}return t&&e.shellSuspendCounter++,oo=os=null,lm=i,rM.H=r,rM.A=a,null===lv&&(lg=null,lx=0,eA()),s}function iI(e){var t=nE(e.alternate,e,lw);e.memoizedProps=e.pendingProps,null===t?iD(e):lv=t}function iL(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=nd(n,t,t.pendingProps,t.type,void 0,lx);break;case 11:t=nd(n,t,t.pendingProps,t.type.render,t.ref,lx);break;case 5:e6(t);default:nz(n,t),t=nE(n,t=lv=iQ(t,lw),lw)}e.memoizedProps=e.pendingProps,null===t?iD(e):lv=t}function iN(e,t,n,r){oo=os=null,e6(t),oR=null,oP=0;var a=t.return;try{if(function(e,t,n,r,a){if(n.flags|=32768,null!==r&&"object"==typeof r&&"function"==typeof r.then){if(null!==(t=n.alternate)&&Y(t,n,a,!0),null!==(n=oB.current)){switch(n.tag){case 31:case 13:return null===oV?iR():null===n.alternate&&0===lT&&(lT=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===oA?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([r]):t.add(r),iW(e,r,a)),!1;case 22:return n.flags|=65536,r===oA?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([r]):n.add(r),iW(e,r,a)),!1}throw Error(i(435,n.tag))}return iW(e,r,a),iR(),!1}if(ot)return null!==(t=oB.current)?((65536&t.flags)==0&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==or&&j(A(e=Error(i(422),{cause:r}),n))):(r!==or&&j(A(t=Error(i(423),{cause:r}),n)),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=A(r,n),a=t9(e.stateNode,r,a),ez(e,a),4!==lT&&(lT=2)),!1;var s=Error(i(520),{cause:r});if(s=A(s,n),null===lI?lI=[s]:lI.push(s),4!==lT&&(lT=2),null===t)return!0;r=A(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=t9(n.stateNode,r,e),ez(n,e),!1;case 1:if(t=n.type,s=n.stateNode,(128&n.flags)==0&&("function"==typeof t.getDerivedStateFromError||null!==s&&"function"==typeof s.componentDidCatch&&(null===lz||!lz.has(s))))return n.flags|=65536,a&=-a,n.lanes|=a,ne(a=t7(a),e,n,r),ez(n,a),!1}n=n.return}while(null!==n)return!1}(e,a,t,n,lx)){lT=1,t6(e,A(n,e.current)),lv=null;return}}catch(t){if(null!==a)throw lv=a,t;lT=1,t6(e,A(n,e.current)),lv=null;return}32768&t.flags?(ot||1===r?e=!0:lS||(0x20000000&lx)!=0?e=!1:(lb=e=!0,(2===r||9===r||3===r||6===r)&&null!==(r=oB.current)&&13===r.tag&&(r.flags|=16384)),iU(t,e)):iD(t)}function iD(e){var t=e;do{if((32768&t.flags)!=0)return void iU(t,lb);e=t.return;var n=function(e,t,n){var r=t.pendingProps;switch(I(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return nF(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),W(oh),D(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(null===e||null===e.child)&&(B(t)?nA(t):null===e||e.memoizedState.isDehydrated&&(256&t.flags)==0||(t.flags|=1024,H())),nI(e,t),nF(t),null;case 26:if(si){var a=t.type,s=t.memoizedState;return null===e?(nA(t),null!==s?(nF(t),nD(t,s)):(nF(t),nN(t,a,null,r,n))):s?s!==e.memoizedState?(nA(t),nF(t),nD(t,s)):(nF(t),t.flags&=-0x1000001):(s=e.memoizedProps,rV?s!==r&&nA(t):nL(e,t,a,r),nF(t),nN(t,a,s,r,n)),null}case 27:if(sv){if(O(t),n=s8.current,a=t.type,null!==e&&null!=t.stateNode)rV?e.memoizedProps!==r&&nA(t):nL(e,t,a,r);else{if(!r){if(null===t.stateNode)throw Error(i(166));return nF(t),null}e=s5.current,B(t)?z(t,e):(t.stateNode=e=sx(a,r,n,e,!0),nA(t))}return nF(t),null}case 5:if(O(t),a=t.type,null!==e&&null!=t.stateNode)nL(e,t,a,r);else{if(!r){if(null===t.stateNode)throw Error(i(166));return nF(t),null}if(s=s5.current,B(t))z(t,s),a2(t.stateNode,a,r,s)&&(t.flags|=64);else{var o=rL(a,r,s8.current,s,t);nC(t),nP(o,t,!1,!1),t.stateNode=o,rD(o,a,r,s)&&nA(t)}}return nF(t),nN(t,t.type,null===e?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)n=e.memoizedProps,rV?n!==r&&nA(t):rH&&(n!==r?(e=s8.current,n=s5.current,nC(t),t.stateNode=rO(r,e,n,t)):t.stateNode=e.stateNode);else{if("string"!=typeof r&&null===t.stateNode)throw Error(i(166));if(e=s8.current,n=s5.current,B(t)){if(!rj)throw Error(i(176));if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(a=s7))switch(a.tag){case 27:case 5:r=a.memoizedProps}aq(e,n,t,r)||F(t,!0)}else nC(t),t.stateNode=rO(r,e,n,t)}return nF(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=B(t),null!==n){if(null===e){if(!r)throw Error(i(318));if(!rj)throw Error(i(556));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));aY(e,t)}else V(),(128&t.flags)==0&&(t.memoizedState=null),t.flags|=4;nF(t),e=!1}else n=H(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(eJ(t),t):(eJ(t),null);if((128&t.flags)!=0)throw Error(i(558))}return nF(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=B(t),null!==r&&null!==r.dehydrated){if(null===e){if(!a)throw Error(i(318));if(!rj)throw Error(i(344));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(i(317));aZ(a,t)}else V(),(128&t.flags)==0&&(t.memoizedState=null),t.flags|=4;nF(t),a=!1}else a=H(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(eJ(t),t):(eJ(t),null)}return eJ(t),(128&t.flags)!=0?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(r=t.child,a=null,null!==r.alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(a=r.alternate.memoizedState.cachePool.pool),s=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(s=r.memoizedState.cachePool.pool),s!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),nU(t,t.updateQueue),nF(t),null);case 4:return D(),nI(e,t),null===e&&rW(t.stateNode.containerInfo),nF(t),null;case 10:return W(t.type),nF(t),null;case 19:if(c(oH),null===(r=t.memoizedState))return nF(t),null;if(a=(128&t.flags)!=0,null===(s=r.rendering))if(a)nO(r,!1);else{if(0!==lT||null!==e&&(128&e.flags)!=0)for(e=t.child;null!==e;){if(null!==(s=e$(e))){for(t.flags|=128,nO(r,!1),t.updateQueue=e=s.updateQueue,nU(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)iQ(n,e),n=n.sibling;return h(oH,1&oH.current|2),ot&&C(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&sO()>lO&&(t.flags|=128,a=!0,nO(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=e$(s))){if(t.flags|=128,a=!0,t.updateQueue=e=e.updateQueue,nU(t,e),nO(r,!0),null===r.tail&&"hidden"===r.tailMode&&!s.alternate&&!ot)return nF(t),null}else 2*sO()-r.renderingStartTime>lO&&0x20000000!==n&&(t.flags|=128,a=!0,nO(r,!1),t.lanes=4194304);r.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=r.last)?e.sibling=s:t.child=s,r.last=s)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=sO(),e.sibling=null,n=oH.current,h(oH,a?1&n|2:1&n),ot&&C(t,r.treeForkCount),e):(nF(t),null);case 22:case 23:return eJ(t),eW(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?(0x20000000&n)!=0&&(128&t.flags)==0&&(nF(t),6&t.subtreeFlags&&(t.flags|=8192)):nF(t),null!==(n=t.updateQueue)&&nU(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&c(oM),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),W(oh),nF(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}(t.alternate,t,lw);if(null!==n){lv=n;return}if(null!==(t=t.sibling)){lv=t;return}lv=t=e}while(null!==t)0===lT&&(lT=5)}function iU(e,t){do{var n=function(e,t){switch(I(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return W(oh),D(),(65536&(e=t.flags))!=0&&(128&e)==0?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return O(t),null;case 31:if(null!==t.memoizedState){if(eJ(t),null===t.alternate)throw Error(i(340));V()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(eJ(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));V()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return c(oH),null;case 4:return D(),null;case 10:return W(t.type),null;case 22:case 23:return eJ(t),eW(),null!==e&&c(oM),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return W(oh),null;default:return null}}(e.alternate,e);if(null!==n){n.flags&=32767,lv=n;return}if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling)){lv=e;return}lv=e=n}while(null!==e)lT=6,lv=null}function iO(e,t,n,r,a,s,o,l,u){e.cancelPendingCommit=null;do iV();while(0!==lk)if((6&lm)!=0)throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(function(e,t,n,i,r,a){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,u=e.hiddenUpdates;for(n=s&~n;0<n;){var c=31-sE(n),h=1<<c;o[c]=0,l[c]=-1;var d=u[c];if(null!==d)for(u[c]=null,c=0;c<d.length;c++){var p=d[c];null!==p&&(p.lane&=-0x20000001)}n&=~h}0!==i&&x(e,i,0),0!==a&&0===r&&0!==e.tag&&(e.suspendedLanes|=a&~(s&~t))}(e,n,s=t.lanes|t.childLanes|oU,o,l,u),e===lg&&(lv=lg=null,lx=0),lV=t,lB=e,lH=n,lj=s,lG=a,lW=r,(10256&t.subtreeFlags)!=0||(10256&t.flags)!=0?(e.callbackNode=null,e.callbackPriority=0,sL(sk,function(){return iH(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(13878&t.flags)!=0,(13878&t.subtreeFlags)!=0||r){r=rM.T,rM.T=null,a=rq(),rX(2),o=lm,lm|=4;try{!function(e,t){for(rP(e.containerInfo),ln=t;null!==ln;)if(t=(e=ln).child,(1028&e.subtreeFlags)!=0&&null!==t)t.return=e,ln=t;else for(;null!==ln;){var n=(e=ln).alternate;switch(t=e.flags,e.tag){case 0:if((4&t)!=0&&null!==(t=null!==(t=e.updateQueue)?t.events:null))for(var r=0;r<t.length;r++){var a=t[r];a.ref.impl=a.nextImpl}break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if((1024&t)!=0&&null!==n){t=void 0,r=e,a=n.memoizedProps,n=n.memoizedState;var s=r.stateNode;try{var o=t5(r.type,a);t=s.getSnapshotBeforeUpdate(o,n),s.__reactInternalSnapshotBeforeUpdate=t}catch(e){iG(r,r.return,e)}}break;case 3:(1024&t)!=0&&rV&&ab(e.stateNode.containerInfo);break;default:if((1024&t)!=0)throw Error(i(163))}if(null!==(t=e.sibling)){t.return=e.return,ln=t;break}ln=e.return}}(e,t,n)}finally{lm=o,rX(a),rM.T=r}}lk=1,iF(),iz(),ik()}}function iF(){if(1===lk){lk=0;var e=lB,t=lV,n=(13878&t.flags)!=0;if((13878&t.subtreeFlags)!=0||n){n=rM.T,rM.T=null;var i=rq();rX(2);var r=lm;lm|=4;try{n5(t,e),rI(e.containerInfo)}finally{lm=r,rX(i),rM.T=n}}e.current=t,lk=2}}function iz(){if(2===lk){lk=0;var e=lB,t=lV,n=(8772&t.flags)!=0;if((8772&t.subtreeFlags)!=0||n){n=rM.T,rM.T=null;var i=rq();rX(2);var r=lm;lm|=4;try{nK(e,t.alternate,t)}finally{lm=r,rX(i),rM.T=n}}lk=3}}function ik(){if(4===lk||3===lk){lk=0,sU();var e=lB,t=lV,n=lH,i=lW;(10256&t.subtreeFlags)!=0||(10256&t.flags)!=0?lk=5:(lk=0,lV=lB=null,iB(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(lz=null),S(n),t=t.stateNode,sG&&"function"==typeof sG.onCommitFiberRoot)try{sG.onCommitFiberRoot(sj,t,void 0,(128&t.current.flags)==128)}catch{}if(null!==i){t=rM.T,r=rq(),rX(2),rM.T=null;try{for(var a=e.onRecoverableError,s=0;s<i.length;s++){var o=i[s];a(o.value,{componentStack:o.stack})}}finally{rM.T=t,rX(r)}}(3&lH)!=0&&iV(),ea(e),r=e.pendingLanes,(261930&n)!=0&&(42&r)!=0?e===lq?lX++:(lX=0,lq=e):lX=0,rj&&a3(),es(0,!1)}}function iB(e,t){0==(e.pooledCacheLanes&=t)&&null!=(t=e.pooledCache)&&(e.pooledCache=null,ei(t))}function iV(){return iF(),iz(),ik(),iH()}function iH(){if(5!==lk)return!1;var e=lB,t=lj;lj=0;var n=S(lH),r=32>n?32:n;n=rM.T;var a=rq();try{rX(r),rM.T=null,r=lG,lG=null;var s=lB,o=lH;if(lk=0,lV=lB=null,lH=0,(6&lm)!=0)throw Error(i(331));var l=lm;if(lm|=4,il(s.current),it(s,s.current,o,r),lm=l,es(0,!1),sG&&"function"==typeof sG.onPostCommitFiberRoot)try{sG.onPostCommitFiberRoot(sj,s)}catch{}return!0}finally{rX(a),rM.T=n,iB(e,t)}}function ij(e,t,n){t=A(n,t),t=t9(e.stateNode,t,2),null!==(e=eO(e,t,2))&&(v(e,2),ea(e))}function iG(e,t,n){if(3===e.tag)ij(e,e,n);else for(;null!==t;){if(3===t.tag){ij(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===lz||!lz.has(i))){e=A(n,e),null!==(i=eO(t,n=t7(2),2))&&(ne(n,i,t,e),v(i,2),ea(i));break}}t=t.return}}function iW(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new lf;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(lM=!0,r.add(n),e=iX.bind(null,e,t,n),t.then(e,e))}function iX(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,lg===e&&(lx&n)===n&&(4===lT||3===lT&&(0x3c00000&lx)===lx&&300>sO()-lD?(2&lm)==0&&iw(e,0):lC|=n,lP===lx&&(lP=0)),ea(e)}function iq(e,t){0===t&&(t=m()),null!==(e=eP(e,t))&&(v(e,t),ea(e))}function iY(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),iq(e,n)}function iZ(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),iq(e,n)}function iJ(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function i$(e){return!(!(e=e.prototype)||!e.isReactComponent)}function iK(e,n){var i=e.alternate;return null===i?((i=t(e.tag,n,e.key,e.mode)).elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=0x3e00000&e.flags,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i.refCleanup=e.refCleanup,i}function iQ(e,t){e.flags&=0x3e00002;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,e.dependencies=null===(t=n.dependencies)?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function i0(e,n,r,a,s,o){var l=0;if(a=e,"function"==typeof e)i$(e)&&(l=1);else if("string"==typeof e)l=si&&sv?sr(e,r,s5.current)?26:sb(e)?27:5:si?sr(e,r,s5.current)?26:5:sv&&sb(e)?27:5;else o:switch(e){case rx:return(e=t(31,r,n,s)).elementType=rx,e.lanes=o,e;case rl:return i1(r.children,s,o,n);case ru:l=8,s|=24;break;case rc:return(e=t(12,r,n,2|s)).elementType=rc,e.lanes=o,e;case rf:return(e=t(13,r,n,s)).elementType=rf,e.lanes=o,e;case rm:return(e=t(19,r,n,s)).elementType=rm,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case rd:l=10;break o;case rh:l=9;break o;case rp:l=11;break o;case rg:l=14;break o;case rv:l=16,a=null;break o}l=29,r=Error(i(130,null===e?"null":typeof e,"")),a=null}return(n=t(l,r,n,s)).elementType=e,n.type=a,n.lanes=o,n}function i1(e,n,i,r){return(e=t(7,e,r,n)).lanes=i,e}function i2(e,n,i){return(e=t(6,e,null,n)).lanes=i,e}function i3(e){var n=t(18,null,null,0);return n.stateNode=e,n}function i4(e,n,i){return(n=t(4,null!==e.children?e.children:[],e.key,n)).lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function i5(e,t,n,i,r,a,s,o,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=rk,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=g(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=g(0),this.hiddenUpdates=g(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function i6(e,n,i,r,a,s,o,l,u,c,h,d){return e=new i5(e,n,i,o,u,c,h,d,l),n=1,!0===s&&(n|=24),s=t(3,null,null,n),e.current=s,s.stateNode=e,n=en(),n.refCount++,e.pooledCache=n,n.refCount++,s.memoizedState={element:r,isDehydrated:i,cache:n},eN(s),e}function i8(e){var t=e._reactInternals;if(void 0===t)throw"function"==typeof e.render?Error(i(188)):Error(i(268,e=Object.keys(e).join(",")));return null===(e=null!==(e=s(t))?function e(t){var n=t.tag;if(5===n||26===n||27===n||6===n)return t;for(t=t.child;null!==t;){if(null!==(n=e(t)))return n;t=t.sibling}return null}(e):null)?null:rA(e.stateNode)}function i9(e,t,n,i,r,a){r=sT,null===i.context?i.context=r:i.pendingContext=r,(i=eU(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(i.callback=a),null!==(n=eO(e,i,t))&&(ix(n,e,t),eF(n,e,t))}function i7(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function re(e,t){i7(e,t),(e=e.alternate)&&i7(e,t)}var rt={},rn=$.default,ri=c1.default,rr=Object.assign,ra=Symbol.for("react.element"),rs=Symbol.for("react.transitional.element"),ro=Symbol.for("react.portal"),rl=Symbol.for("react.fragment"),ru=Symbol.for("react.strict_mode"),rc=Symbol.for("react.profiler"),rh=Symbol.for("react.consumer"),rd=Symbol.for("react.context"),rp=Symbol.for("react.forward_ref"),rf=Symbol.for("react.suspense"),rm=Symbol.for("react.suspense_list"),rg=Symbol.for("react.memo"),rv=Symbol.for("react.lazy"),rx=Symbol.for("react.activity"),ry=Symbol.for("react.memo_cache_sentinel"),r_=Symbol.iterator,rb=Symbol.for("react.client.reference"),rS=Array.isArray,rM=rn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,rw=e.rendererVersion,rT=e.rendererPackageName,rE=e.extraDevToolsConfig,rA=e.getPublicInstance,rC=e.getRootHostContext,rR=e.getChildHostContext,rP=e.prepareForCommit,rI=e.resetAfterCommit,rL=e.createInstance;e.cloneMutableInstance;var rN=e.appendInitialChild,rD=e.finalizeInitialChildren,rU=e.shouldSetTextContent,rO=e.createTextInstance;e.cloneMutableTextInstance;var rF=e.scheduleTimeout,rz=e.cancelTimeout,rk=e.noTimeout,rB=e.isPrimaryRenderer;e.warnsIfNotActing;var rV=e.supportsMutation,rH=e.supportsPersistence,rj=e.supportsHydration,rG=e.getInstanceFromNode;e.beforeActiveInstanceBlur;var rW=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var rX=e.setCurrentUpdatePriority,rq=e.getCurrentUpdatePriority,rY=e.resolveUpdatePriority;e.trackSchedulerEvent,e.resolveEventType,e.resolveEventTimeStamp;var rZ=e.shouldAttemptEagerTransition,rJ=e.detachDeletedInstance;e.requestPostPaintCallback;var r$=e.maySuspendCommit,rK=e.maySuspendCommitOnUpdate,rQ=e.maySuspendCommitInSyncRender,r0=e.preloadInstance,r1=e.startSuspendingCommit,r2=e.suspendInstance;e.suspendOnActiveViewTransition;var r3=e.waitForCommitToBeReady;e.getSuspendedCommitReason;var r4=e.NotPendingTransition,r5=e.HostTransitionContext,r6=e.resetFormInstance;e.bindToConsole;var r8=e.supportsMicrotasks,r9=e.scheduleMicrotask,r7=e.supportsTestSelectors,ae=e.findFiberRoot,at=e.getBoundingRect,an=e.getTextContent,ai=e.isHiddenSubtree,ar=e.matchAccessibilityRole,aa=e.setFocusIfFocusable,as=e.setupIntersectionObserver,ao=e.appendChild,al=e.appendChildToContainer,au=e.commitTextUpdate,ac=e.commitMount,ah=e.commitUpdate,ad=e.insertBefore,ap=e.insertInContainerBefore,af=e.removeChild,am=e.removeChildFromContainer,ag=e.resetTextContent,av=e.hideInstance,ax=e.hideTextInstance,ay=e.unhideInstance,a_=e.unhideTextInstance;e.cancelViewTransitionName,e.cancelRootViewTransitionName,e.restoreRootViewTransitionName,e.cloneRootViewTransitionContainer,e.removeRootViewTransitionClone,e.measureClonedInstance,e.hasInstanceChanged,e.hasInstanceAffectedParent,e.startViewTransition,e.startGestureTransition,e.stopViewTransition,e.getCurrentGestureOffset,e.createViewTransitionInstance;var ab=e.clearContainer;e.createFragmentInstance,e.updateFragmentInstanceFiber,e.commitNewChildToFragmentInstance,e.deleteChildFromFragmentInstance;var aS=e.cloneInstance,aM=e.createContainerChildSet,aw=e.appendChildToContainerChildSet,aT=e.finalizeContainerChildren,aE=e.replaceContainerChildren,aA=e.cloneHiddenInstance,aC=e.cloneHiddenTextInstance,aR=e.isSuspenseInstancePending,aP=e.isSuspenseInstanceFallback,aI=e.getSuspenseInstanceFallbackErrorDetails,aL=e.registerSuspenseInstanceRetry,aN=e.canHydrateFormStateMarker,aD=e.isFormStateMarkerMatching,aU=e.getNextHydratableSibling,aO=e.getNextHydratableSiblingAfterSingleton,aF=e.getFirstHydratableChild,az=e.getFirstHydratableChildWithinContainer,ak=e.getFirstHydratableChildWithinActivityInstance,aB=e.getFirstHydratableChildWithinSuspenseInstance,aV=e.getFirstHydratableChildWithinSingleton,aH=e.canHydrateInstance,aj=e.canHydrateTextInstance,aG=e.canHydrateActivityInstance,aW=e.canHydrateSuspenseInstance,aX=e.hydrateInstance,aq=e.hydrateTextInstance,aY=e.hydrateActivityInstance,aZ=e.hydrateSuspenseInstance,aJ=e.getNextHydratableInstanceAfterActivityInstance,a$=e.getNextHydratableInstanceAfterSuspenseInstance,aK=e.commitHydratedInstance,aQ=e.commitHydratedContainer,a0=e.commitHydratedActivityInstance,a1=e.commitHydratedSuspenseInstance,a2=e.finalizeHydratedChildren,a3=e.flushHydrationEvents;e.clearActivityBoundary;var a4=e.clearSuspenseBoundary;e.clearActivityBoundaryFromContainer;var a5=e.clearSuspenseBoundaryFromContainer,a6=e.hideDehydratedBoundary,a8=e.unhideDehydratedBoundary,a9=e.shouldDeleteUnhydratedTailInstances;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var a7,se,st=e.validateHydratableInstance,sn=e.validateHydratableTextInstance,si=e.supportsResources,sr=e.isHostHoistableType,sa=e.getHoistableRoot,ss=e.getResource,so=e.acquireResource,sl=e.releaseResource,su=e.hydrateHoistable,sc=e.mountHoistable,sh=e.unmountHoistable,sd=e.createHoistableInstance,sp=e.prepareToCommitHoistables,sf=e.mayResourceSuspendCommit,sm=e.preloadResource,sg=e.suspendResource,sv=e.supportsSingletons,sx=e.resolveSingletonInstance,sy=e.acquireSingletonInstance,s_=e.releaseSingletonInstance,sb=e.isHostSingletonType,sS=e.isSingletonScope,sM=[],sw=-1,sT={},sE=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(sA(e)/sC|0)|0},sA=Math.log,sC=Math.LN2,sR=256,sP=262144,sI=4194304,sL=ri.unstable_scheduleCallback,sN=ri.unstable_cancelCallback,sD=ri.unstable_shouldYield,sU=ri.unstable_requestPaint,sO=ri.unstable_now,sF=ri.unstable_ImmediatePriority,sz=ri.unstable_UserBlockingPriority,sk=ri.unstable_NormalPriority,sB=ri.unstable_IdlePriority,sV=ri.log,sH=ri.unstable_setDisableYieldValue,sj=null,sG=null,sW="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},sX="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof J.default&&"function"==typeof J.default.emit)return void J.default.emit("uncaughtException",e);console.error(e)},sq=Object.prototype.hasOwnProperty,sY=!1,sZ=new WeakMap,sJ=[],s$=0,sK=null,sQ=0,s0=[],s1=0,s2=null,s3=1,s4="",s5=u(null),s6=u(null),s8=u(null),s9=u(null),s7=null,oe=null,ot=!1,on=null,oi=!1,or=Error(i(519)),oa=u(null),os=null,oo=null,ol="u">typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ou=ri.unstable_scheduleCallback,oc=ri.unstable_NormalPriority,oh={$$typeof:rd,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},od=null,op=null,of=!1,om=!1,og=!1,ov=0,ox=null,oy=0,o_=0,ob=null,oS=rM.S;rM.S=function(e,t){lU=sO(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===ox){var n=ox=[];oy=0,o_=ed(),ob={status:"pending",value:void 0,then:function(e){n.push(e)}}}oy++,t.then(ep,ep)}(0,t),null!==oS&&oS(e,t)};var oM=u(null),ow=Error(i(460)),oT=Error(i(474)),oE=Error(i(542)),oA={then:function(){}},oC=null,oR=null,oP=0,oI=eE(!0),oL=eE(!1),oN=[],oD=0,oU=0,oO=!1,oF=!1,oz=u(null),ok=u(0),oB=u(null),oV=null,oH=u(0),oj=0,oG=null,oW=null,oX=null,oq=!1,oY=!1,oZ=!1,oJ=0,o$=0,oK=null,oQ=0,o0={readContext:Q,use:tt,useCallback:eK,useContext:eK,useEffect:eK,useImperativeHandle:eK,useLayoutEffect:eK,useInsertionEffect:eK,useMemo:eK,useReducer:eK,useRef:eK,useState:eK,useDebugValue:eK,useDeferredValue:eK,useTransition:eK,useSyncExternalStore:eK,useId:eK,useHostTransitionStatus:eK,useFormState:eK,useActionState:eK,useOptimistic:eK,useMemoCache:eK,useCacheRefresh:eK};o0.useEffectEvent=eK;var o1={readContext:Q,use:tt,useCallback:function(e,t){return e8().memoizedState=[e,void 0===t?null:t],e},useContext:Q,useEffect:tI,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,tR(4194308,4,tO.bind(null,t,e),n)},useLayoutEffect:function(e,t){return tR(4194308,4,e,t)},useInsertionEffect:function(e,t){tR(4,2,e,t)},useMemo:function(e,t){var n=e8();t=void 0===t?null:t;var i=e();return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=e8();if(void 0!==n)var r=n(t);else r=t;return i.memoizedState=i.baseState=r,i.queue=e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},e=e.dispatch=tZ.bind(null,oG,e),[i.memoizedState,e]},useRef:function(e){return e8().memoizedState={current:e}},useState:function(e){var t=(e=tp(e)).queue,n=tJ.bind(null,oG,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:tz,useDeferredValue:function(e,t){return tV(e8(),e,t)},useTransition:function(){var e=tp(!1);return e=tj.bind(null,oG,e.queue,!0,!1),e8().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=oG,a=e8();if(ot){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===lg)throw Error(i(349));(127&lx)!=0||tl(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,tI(tc.bind(null,r,s,e),[e]),r.flags|=2048,tA(9,{destroy:void 0},tu.bind(null,r,s,n,t),null),n},useId:function(){var e=e8(),t=lg.identifierPrefix;if(ot){var n=s4,i=s3;t="_"+t+"R_"+(n=(i&~(1<<32-sE(i)-1)).toString(32)+n),0<(n=oJ++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=oQ++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:tW,useFormState:tS,useActionState:tS,useOptimistic:function(e){var t=e8();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=tK.bind(null,oG,!0,n),n.dispatch=t,[e,t]},useMemoCache:tn,useCacheRefresh:function(){return e8().memoizedState=tY.bind(null,oG)},useEffectEvent:function(e){var t=e8(),n={impl:e};return t.memoizedState=n,function(){if((2&lm)!=0)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},o2={readContext:Q,use:tt,useCallback:tk,useContext:Q,useEffect:tL,useImperativeHandle:tF,useInsertionEffect:tD,useLayoutEffect:tU,useMemo:tB,useReducer:tr,useRef:tC,useState:function(){return tr(ti)},useDebugValue:tz,useDeferredValue:function(e,t){return tH(e9(),oW.memoizedState,e,t)},useTransition:function(){var e=tr(ti)[0],t=e9().memoizedState;return["boolean"==typeof e?e:te(e),t]},useSyncExternalStore:to,useId:tX,useHostTransitionStatus:tW,useFormState:tM,useActionState:tM,useOptimistic:function(e,t){return tf(e9(),oW,e,t)},useMemoCache:tn,useCacheRefresh:tq};o2.useEffectEvent=tN;var o3={readContext:Q,use:tt,useCallback:tk,useContext:Q,useEffect:tL,useImperativeHandle:tF,useInsertionEffect:tD,useLayoutEffect:tU,useMemo:tB,useReducer:ts,useRef:tC,useState:function(){return ts(ti)},useDebugValue:tz,useDeferredValue:function(e,t){var n=e9();return null===oW?tV(n,e,t):tH(n,oW.memoizedState,e,t)},useTransition:function(){var e=ts(ti)[0],t=e9().memoizedState;return["boolean"==typeof e?e:te(e),t]},useSyncExternalStore:to,useId:tX,useHostTransitionStatus:tW,useFormState:tE,useActionState:tE,useOptimistic:function(e,t){var n=e9();return null!==oW?tf(n,oW,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:tn,useCacheRefresh:tq};o3.useEffectEvent=tN;var o4={enqueueSetState:function(e,t,n){e=e._reactInternals;var i=ig(),r=eU(i);r.payload=t,null!=n&&(r.callback=n),null!==(t=eO(e,r,i))&&(ix(t,e,i),eF(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=ig(),r=eU(i);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=eO(e,r,i))&&(ix(t,e,i),eF(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ig(),i=eU(n);i.tag=2,null!=t&&(i.callback=t),null!==(t=eO(e,i,n))&&(ix(t,e,n),eF(t,e,n))}},o5=Error(i(461)),o6=!1,o8={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},o9=!1,o7=!1,le=!1,lt="function"==typeof WeakSet?WeakSet:Set,ln=null,li=null,lr=!1,la=null,ls=8192,lo={getCacheForType:function(e){var t=Q(oh),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Q(oh).controller.signal}},ll=0,lu=1,lc=2,lh=3,ld=4;if("function"==typeof Symbol&&Symbol.for){var lp=Symbol.for;ll=lp("selector.component"),lu=lp("selector.has_pseudo_class"),lc=lp("selector.role"),lh=lp("selector.test_id"),ld=lp("selector.text")}var lf="function"==typeof WeakMap?WeakMap:Map,lm=0,lg=null,lv=null,lx=0,ly=0,l_=null,lb=!1,lS=!1,lM=!1,lw=0,lT=0,lE=0,lA=0,lC=0,lR=0,lP=0,lI=null,lL=null,lN=!1,lD=0,lU=0,lO=1/0,lF=null,lz=null,lk=0,lB=null,lV=null,lH=0,lj=0,lG=null,lW=null,lX=0,lq=null;return rt.attemptContinuousHydration=function(e){if(13===e.tag||31===e.tag){var t=eP(e,0x4000000);null!==t&&ix(t,e,0x4000000),re(e,0x4000000)}},rt.attemptHydrationAtCurrentPriority=function(e){if(13===e.tag||31===e.tag){var t=ig(),n=eP(e,t=b(t));null!==n&&ix(n,e,t),re(e,t)}},rt.attemptSynchronousHydration=function(e){switch(e.tag){case 3:if((e=e.stateNode).current.memoizedState.isDehydrated){var t=d(e.pendingLanes);if(0!==t){for(e.pendingLanes|=2,e.entangledLanes|=2;t;){var n=1<<31-sE(t);e.entanglements[1]|=n,t&=~n}ea(e),(6&lm)==0&&(lO=sO()+500,es(0,!1))}}break;case 31:case 13:null!==(t=eP(e,2))&&ix(t,e,2),iS(),re(e,2)}},rt.batchedUpdates=function(e,t){return e(t)},rt.createComponentSelector=function(e){return{$$typeof:ll,value:e}},rt.createContainer=function(e,t,n,i,r,a,s,o,l,u){return i6(e,t,!1,null,n,i,a,null,s,o,l,u)},rt.createHasPseudoClassSelector=function(e){return{$$typeof:lu,value:e}},rt.createHydrationContainer=function(e,t,n,i,r,a,s,o,l,u,c,h,d,p){var f;return(e=i6(n,i,!0,e,r,a,o,p,l,u,c,h)).context=sT,n=e.current,(r=eU(i=b(i=ig()))).callback=null!=(f=t)?f:null,eO(n,r,i),t=i,e.current.lanes=t,v(e,t),ea(e),e},rt.createPortal=function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:ro,key:null==i?null:""+i,children:e,containerInfo:t,implementation:n}},rt.createRoleSelector=function(e){return{$$typeof:lc,value:e}},rt.createTestNameSelector=function(e){return{$$typeof:lh,value:e}},rt.createTextSelector=function(e){return{$$typeof:ld,value:e}},rt.defaultOnCaughtError=function(e){console.error(e)},rt.defaultOnRecoverableError=function(e){sX(e)},rt.defaultOnUncaughtError=function(e){sX(e)},rt.deferredUpdates=function(e){var t=rM.T,n=rq();try{return rX(32),rM.T=null,e()}finally{rX(n),rM.T=t}},rt.discreteUpdates=function(e,t,n,i,r){var a=rM.T,s=rq();try{return rX(2),rM.T=null,e(t,n,i,r)}finally{rX(s),rM.T=a,0===lm&&(lO=sO()+500)}},rt.findAllNodes=im,rt.findBoundingRects=function(e,t){if(!r7)throw Error(i(363));t=im(e,t),e=[];for(var n=0;n<t.length;n++)e.push(at(t[n]));for(t=e.length-1;0<t;t--){n=e[t];for(var r=n.x,a=r+n.width,s=n.y,o=s+n.height,l=t-1;0<=l;l--)if(t!==l){var u=e[l],c=u.x,h=c+u.width,d=u.y,p=d+u.height;if(r>=c&&s>=d&&a<=h&&o<=p){e.splice(t,1);break}if(r!==c||n.width!==u.width||p<s||d>o){if(!(s!==d||n.height!==u.height||h<r||c>a)){c>r&&(u.width+=c-r,u.x=r),h<a&&(u.width=a-c),e.splice(t,1);break}}else{d>s&&(u.height+=d-s,u.y=s),p<o&&(u.height=o-d),e.splice(t,1);break}}}return e},rt.findHostInstance=i8,rt.findHostInstanceWithNoPortals=function(e){return null===(e=null!==(e=s(e))?function e(t){var n=t.tag;if(5===n||26===n||27===n||6===n)return t;for(t=t.child;null!==t;){if(4!==t.tag&&null!==(n=e(t)))return n;t=t.sibling}return null}(e):null)?null:rA(e.stateNode)},rt.findHostInstanceWithWarning=function(e){return i8(e)},rt.flushPassiveEffects=iV,rt.flushSyncFromReconciler=function(e){var t=lm;lm|=1;var n=rM.T,i=rq();try{if(rX(2),rM.T=null,e)return e()}finally{rX(i),rM.T=n,(6&(lm=t))==0&&es(0,!1)}},rt.flushSyncWork=iS,rt.focusWithin=function(e,t){if(!r7)throw Error(i(363));for(t=Array.from(t=ip(e=ic(e),t)),e=0;e<t.length;){var n=t[e++],r=n.tag;if(!ai(n)){if((5===r||26===r||27===r)&&aa(n.stateNode))return!0;for(n=n.child;null!==n;)t.push(n),n=n.sibling}}return!1},rt.getFindAllNodesFailureDescription=function(e,t){if(!r7)throw Error(i(363));var n=0,r=[];e=[ic(e),0];for(var a=0;a<e.length;){var s=e[a++],o=s.tag,l=e[a++],u=t[l];if((5!==o&&26!==o&&27!==o||!ai(s))&&(ih(s,u)&&(r.push(id(u)),++l>n&&(n=l)),l<t.length))for(s=s.child;null!==s;)e.push(s,l),s=s.sibling}if(n<t.length){for(e=[];n<t.length;n++)e.push(id(t[n]));return`findAllNodes was able to match part of the selector:
394
+ `+r.join(" > ")+`
395
+
396
+ No matching component was found for:
397
+ `+e.join(" > ")}return null},rt.getPublicRootInstance=function(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 27:case 5:return rA(e.child.stateNode);default:return e.child.stateNode}},rt.injectIntoDevTools=function(){var e={bundleType:0,version:rw,rendererPackageName:rT,currentDispatcherRef:rM,reconcilerVersion:"19.2.0"};if(null!==rE&&(e.rendererConfig=rE),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{sj=t.inject(e),sG=t}catch{}e=!!t.checkDCE}}return e},rt.isAlreadyRendering=function(){return(6&lm)!=0},rt.observeVisibleRects=function(e,t,n,r){if(!r7)throw Error(i(363));var a=as(e=im(e,t),n,r).disconnect;return{disconnect:function(){a()}}},rt.shouldError=function(){return null},rt.shouldSuspend=function(){return!1},rt.startHostTransition=function(e,t,r,a){if(5!==e.tag)throw Error(i(476));var s=tG(e).queue;tj(e,s,t,r4,null===r?n:function(){var t=tG(e);return null===t.next&&(t=e.alternate.memoizedState),t$(e,t.next.queue,{},ig()),r(a)})},rt.updateContainer=function(e,t,n,i){var r=t.current,a=ig();return i9(r,a,e,t,n,i),a},rt.updateContainerSync=function(e,t,n,i){return i9(t.current,2,e,t,n,i),2},rt},hN.exports.default=hN.exports,Object.defineProperty(hN.exports,"__esModule",{value:!0})),hL.exports=hN.exports),(T=hL.exports)&&T.__esModule&&Object.prototype.hasOwnProperty.call(T,"default"))?T.default:T,hU={},hO=/^three(?=[A-Z])/,hF=e=>`${e[0].toUpperCase()}${e.slice(1)}`,hz=0;function hk(e,t){let n=hF(e),i=hU[n];if("primitive"!==e&&!i)throw Error(`R3F: ${n} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if("primitive"===e&&!t.object)throw Error("R3F: Primitives without 'object' are invalid!");if(void 0!==t.args&&!Array.isArray(t.args))throw Error("R3F: The args prop must be an array!")}function hB(e){if(e.isHidden){var t;e.props.attach&&null!=(t=e.parent)&&t.object?hp(e.parent,e):hb(e.object)&&!1!==e.props.visible&&(e.object.visible=!0),e.isHidden=!1,h_(e)}}function hV(e,t,n){let i=t.root.getState();if(e.parent||e.object===i.scene){if(!t.object){var r,a;let e=hU[hF(t.type)];t.object=null!=(r=t.props.object)?r:new e(...null!=(a=t.props.args)?a:[]),t.object.__r3f=t}if(hy(t.object,t.props),t.props.attach)hp(e,t);else if(hb(t.object)&&hb(e.object)){let i=e.object.children.indexOf(null==n?void 0:n.object);if(n&&-1!==i){let n=e.object.children.indexOf(t.object);-1!==n?(e.object.children.splice(n,1),e.object.children.splice(n<i?i-1:i,0,t.object)):(t.object.parent=e.object,e.object.children.splice(i,0,t.object),t.object.dispatchEvent({type:"added"}),e.object.dispatchEvent({type:"childadded",child:t.object}))}else e.object.add(t.object)}for(let e of t.children)hV(t,e);h_(t)}}function hH(e,t){t&&(t.parent=e,e.children.push(t),hV(e,t))}function hj(e,t,n){if(!t||!n)return;t.parent=e;let i=e.children.indexOf(n);-1!==i?e.children.splice(i,0,t):e.children.push(t),hV(e,t,n)}function hG(e){if("function"==typeof e.dispose){let t=()=>{try{e.dispose()}catch{}};"u">typeof IS_REACT_ACT_ENVIRONMENT?t():(0,c1.unstable_scheduleCallback)(c1.unstable_IdlePriority,t)}}function hW(e,t,n){if(!t)return;t.parent=null;let i=e.children.indexOf(t);-1!==i&&e.children.splice(i,1),t.props.attach?hf(e,t):hb(t.object)&&hb(e.object)&&(e.object.remove(t.object),function(e,t){let{internal:n}=e.getState();n.interaction=n.interaction.filter(e=>e!==t),n.initialHits=n.initialHits.filter(e=>e!==t),n.hovered.forEach((e,i)=>{(e.eventObject===t||e.object===t)&&n.hovered.delete(i)}),n.capturedMap.forEach((e,i)=>{hM(n.capturedMap,t,e,i)})}(he(t),t.object));let r=null!==t.props.dispose&&!1!==n;for(let e=t.children.length-1;e>=0;e--){let n=t.children[e];hW(t,n,r)}t.children.length=0,delete t.object.__r3f,r&&"primitive"!==t.type&&"Scene"!==t.object.type&&hG(t.object),void 0===n&&h_(t)}let hX=[],hq=()=>{},hY={},hZ=0,hJ=(E={isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:function(e,t,n){var i;return hk(e=hF(e)in hU?e:e.replace(hO,""),t),"primitive"===e&&null!=(i=t.object)&&i.__r3f&&delete t.object.__r3f,hc(t.object,n,e,t)},removeChild:hW,appendChild:hH,appendInitialChild:hH,insertBefore:hj,appendChildToContainer(e,t){let n=e.getState().scene.__r3f;t&&n&&hH(n,t)},removeChildFromContainer(e,t){let n=e.getState().scene.__r3f;t&&n&&hW(n,t)},insertInContainerBefore(e,t,n){let i=e.getState().scene.__r3f;t&&n&&i&&hj(i,t,n)},getRootHostContext:()=>hY,getChildHostContext:()=>hY,commitUpdate(e,t,n,i,r){var a,s,o;hk(t,i);let l=!1;if("primitive"===e.type&&n.object!==i.object||(null==(a=i.args)?void 0:a.length)!==(null==(s=n.args)?void 0:s.length)?l=!0:null!=(o=i.args)&&o.some((e,t)=>{var i;return e!==(null==(i=n.args)?void 0:i[t])})&&(l=!0),l)hX.push([e,{...i},r]);else{let t=function(e,t){let n={};for(let i in t)if(!hm.includes(i)&&!hl.equ(t[i],e.props[i]))for(let e in n[i]=t[i],t)e.startsWith(`${i}-`)&&(n[e]=t[e]);for(let i in e.props){if(hm.includes(i)||t.hasOwnProperty(i))continue;let{root:r,key:a}=hh(e.object,i);if(r.constructor&&0===r.constructor.length){let e=function(e){let t=hg.get(e.constructor);try{t||(t=new e.constructor,hg.set(e.constructor,t))}catch(e){}return t}(r);hl.und(e)||(n[a]=e[a])}else n[a]=0}return n}(e,i);Object.keys(t).length&&(Object.assign(e.props,t),hy(e.object,t))}(null===r.sibling||(4&r.flags)==0)&&function(){for(let[e]of hX){let t=e.parent;if(t)for(let n of(e.props.attach?hf(t,e):hb(e.object)&&hb(t.object)&&t.object.remove(e.object),e.children))n.props.attach?hf(e,n):hb(n.object)&&hb(e.object)&&e.object.remove(n.object);e.isHidden&&hB(e),e.object.__r3f&&delete e.object.__r3f,"primitive"!==e.type&&hG(e.object)}for(let[i,r,a]of hX){i.props=r;let s=i.parent;if(s){let r=hU[hF(i.type)];i.object=null!=(e=i.props.object)?e:new r(...null!=(t=i.props.args)?t:[]),i.object.__r3f=i;var e,t,n=i.object;for(let e of[a,a.alternate])if(null!==e)if("function"==typeof e.ref){null==e.refCleanup||e.refCleanup();let t=e.ref(n);"function"==typeof t&&(e.refCleanup=t)}else e.ref&&(e.ref.current=n);for(let e of(hy(i.object,i.props),i.props.attach?hp(s,i):hb(i.object)&&hb(s.object)&&s.object.add(i.object),i.children))e.props.attach?hp(i,e):hb(e.object)&&hb(i.object)&&i.object.add(e.object);h_(i)}}hX.length=0}()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>null==e?void 0:e.object,prepareForCommit:()=>null,preparePortalMount:e=>hc(e.getState().scene,e,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:function(e){if(!e.isHidden){var t;e.props.attach&&null!=(t=e.parent)&&t.object?hf(e.parent,e):hb(e.object)&&(e.object.visible=!1),e.isHidden=!0,h_(e)}},unhideInstance:hB,createTextInstance:hq,hideTextInstance:hq,unhideTextInstance:hq,scheduleTimeout:"function"==typeof setTimeout?setTimeout:void 0,cancelTimeout:"function"==typeof clearTimeout?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:$.createContext(null),setCurrentUpdatePriority(e){hZ=e},getCurrentUpdatePriority:()=>hZ,resolveUpdatePriority(){var e;if(0!==hZ)return hZ;switch("u">typeof window&&(null==(e=window.event)?void 0:e.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return 2;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return 8;default:return 32}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:"9.5.0",applyViewTransitionName(e,t,n){},restoreViewTransitionName(e,t){},cancelViewTransitionName(e,t,n){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,t)=>!1,hasInstanceAffectedParent:(e,t)=>!1,suspendOnActiveViewTransition(e,t){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance:(e,t)=>e,cloneMutableTextInstance:e=>e,cloneRootViewTransitionContainer(e){throw Error("Not implemented.")},removeRootViewTransitionClone(e,t){throw Error("Not implemented.")},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,t){},commitNewChildToFragmentInstance(e,t){},deleteChildFromFragmentInstance(e,t){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,t,n)=>!1,maySuspendCommitInSyncRender:(e,t)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,t)=>null},(_=hD(E)).injectIntoDevTools(),_),h$=new Map,hK={objects:"shallow",strict:!1};function hQ({store:e,children:t,onCreated:n,rootElement:i}){return hn(()=>{let t=e.getState();t.set(e=>({internal:{...e.internal,active:!0}})),n&&n(t),e.getState().events.connected||null==t.events.connect||t.events.connect(i)},[]),(0,R.jsx)(hT.Provider,{value:e,children:t})}function h0(e,t){let n=h$.get(e),i=null==n?void 0:n.fiber;if(i){let r=null==n?void 0:n.store.getState();r&&(r.internal.active=!1),hJ.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{null==r.events.disconnect||r.events.disconnect(),null==(n=r.gl)||null==(i=n.renderLists)||null==i.dispose||i.dispose(),null==(a=r.gl)||null==a.forceContextLoss||a.forceContextLoss(),null!=(s=r.gl)&&s.xr&&r.xr.disconnect();var n,i,a,s,o=r.scene;for(let e in"Scene"!==o.type&&(null==o.dispose||o.dispose()),o){let t=o[e];(null==t?void 0:t.type)!=="Scene"&&(null==t||null==t.dispose||t.dispose())}h$.delete(e),t&&t(e)}catch(e){}},500)})}}let h1=new Set,h2=new Set,h3=new Set;function h4(e,t){if(e.size)for(let{callback:n}of e.values())n(t)}function h5(e,t){switch(e){case"before":return h4(h1,t);case"after":return h4(h2,t);case"tail":return h4(h3,t)}}function h6(e,t,n){let i=t.clock.getDelta();"never"===t.frameloop&&"number"==typeof e&&(i=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),s=t.internal.subscribers;for(let e=0;e<s.length;e++)(o=s[e]).ref.current(o.store.getState(),i,n);return!t.internal.priority&&t.gl.render&&t.gl.render(t.scene,t.camera),t.internal.frames=Math.max(0,t.internal.frames-1),"always"===t.frameloop?1:t.internal.frames}let h8=!1,h9=!1;function h7(e){for(let n of(u=requestAnimationFrame(h7),h8=!0,l=0,h5("before",e),h9=!0,h$.values())){var t;(c=n.store.getState()).internal.active&&("always"===c.frameloop||c.internal.frames>0)&&!(null!=(t=c.gl.xr)&&t.isPresenting)&&(l+=h6(e,c))}if(h9=!1,h5("after",e),0===l)return h5("tail",e),h8=!1,cancelAnimationFrame(u)}function de(e,t=1){var n;if(!e)return h$.forEach(e=>de(e.store.getState(),t));(null==(n=e.gl.xr)||!n.isPresenting)&&e.internal.active&&"never"!==e.frameloop&&(t>1?e.internal.frames=Math.min(60,e.internal.frames+t):h9?e.internal.frames=2:e.internal.frames=1,h8||(h8=!0,requestAnimationFrame(h7)))}function dt(e,t=!0,n,i){if(t&&h5("before",e),n)h6(e,n,i);else for(let t of h$.values())h6(e,t.store.getState());t&&h5("after",e)}let dn={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function di(e){let{handlePointer:t}=function(e){function t(e){return e.filter(e=>["Move","Over","Enter","Out","Leave"].some(t=>{var n;return null==(n=e.__r3f)?void 0:n.handlers["onPointer"+t]}))}function n(t){let{internal:n}=e.getState();for(let e of n.hovered.values())if(!t.length||!t.find(t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId)){let i=e.eventObject.__r3f;if(n.hovered.delete(hS(e)),null!=i&&i.eventCount){let n=i.handlers,r={...e,intersections:t};null==n.onPointerOut||n.onPointerOut(r),null==n.onPointerLeave||n.onPointerLeave(r)}}}function i(e,t){for(let n=0;n<t.length;n++){let i=t[n].__r3f;null==i||null==i.handlers.onPointerMissed||i.handlers.onPointerMissed(e)}}return{handlePointer:function(r){switch(r){case"onPointerLeave":case"onPointerCancel":return()=>n([]);case"onLostPointerCapture":return t=>{let{internal:i}=e.getState();"pointerId"in t&&i.capturedMap.has(t.pointerId)&&requestAnimationFrame(()=>{i.capturedMap.has(t.pointerId)&&(i.capturedMap.delete(t.pointerId),n([]))})}}return function(a){let{onPointerMissed:s,internal:o}=e.getState();o.lastEvent.current=a;let l="onPointerMove"===r,u="onClick"===r||"onContextMenu"===r||"onDoubleClick"===r,c=function(t,n){let i=e.getState(),r=new Set,a=[],s=n?n(i.internal.interaction):i.internal.interaction;for(let e=0;e<s.length;e++){let t=ho(s[e]);t&&(t.raycaster.camera=void 0)}i.previousRoot||null==i.events.compute||i.events.compute(t,i);let o=s.flatMap(function(e){let n=ho(e);if(!n||!n.events.enabled||null===n.raycaster.camera)return[];if(void 0===n.raycaster.camera){var i;null==n.events.compute||n.events.compute(t,n,null==(i=n.previousRoot)?void 0:i.getState()),void 0===n.raycaster.camera&&(n.raycaster.camera=null)}return n.raycaster.camera?n.raycaster.intersectObject(e,!0):[]}).sort((e,t)=>{let n=ho(e.object),i=ho(t.object);return n&&i&&i.events.priority-n.events.priority||e.distance-t.distance}).filter(e=>{let t=hS(e);return!r.has(t)&&(r.add(t),!0)});for(let e of(i.events.filter&&(o=i.events.filter(o,i)),o)){let t=e.object;for(;t;){var l;null!=(l=t.__r3f)&&l.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}if("pointerId"in t&&i.internal.capturedMap.has(t.pointerId))for(let e of i.internal.capturedMap.get(t.pointerId).values())r.has(hS(e.intersection))||a.push(e.intersection);return a}(a,l?t:void 0),h=u?function(t){let{internal:n}=e.getState(),i=t.offsetX-n.initialClick[0],r=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(i*i+r*r))}(a):0;"onPointerDown"===r&&(o.initialClick=[a.offsetX,a.offsetY],o.initialHits=c.map(e=>e.eventObject)),u&&!c.length&&h<=2&&(i(a,o.interaction),s&&s(a)),l&&n(c),!function(e,t,i,r){if(e.length){let a={stopped:!1};for(let s of e){let o=ho(s.object);if(o||s.object.traverseAncestors(e=>{let t=ho(e);if(t)return o=t,!1}),o){let{raycaster:l,pointer:u,camera:c,internal:h}=o,d=new ez(u.x,u.y,0).unproject(c),p=e=>{var t,n;return null!=(t=null==(n=h.capturedMap.get(e))?void 0:n.has(s.eventObject))&&t},f=e=>{let n={intersection:s,target:t.target};h.capturedMap.has(e)?h.capturedMap.get(e).set(s.eventObject,n):h.capturedMap.set(e,new Map([[s.eventObject,n]])),t.target.setPointerCapture(e)},m=e=>{let t=h.capturedMap.get(e);t&&hM(h.capturedMap,s.eventObject,t,e)},g={};for(let e in t){let n=t[e];"function"!=typeof n&&(g[e]=n)}let v={...s,...g,pointer:u,intersections:e,stopped:a.stopped,delta:i,unprojectedPoint:d,ray:l.ray,camera:c,stopPropagation(){let i="pointerId"in t&&h.capturedMap.get(t.pointerId);(!i||i.has(s.eventObject))&&(v.stopped=a.stopped=!0,h.hovered.size&&Array.from(h.hovered.values()).find(e=>e.eventObject===s.eventObject)&&n([...e.slice(0,e.indexOf(s)),s]))},target:{hasPointerCapture:p,setPointerCapture:f,releasePointerCapture:m},currentTarget:{hasPointerCapture:p,setPointerCapture:f,releasePointerCapture:m},nativeEvent:t};if(r(v),!0===a.stopped)break}}}}(c,a,h,function(e){let t=e.eventObject,n=t.__r3f;if(!(null!=n&&n.eventCount))return;let s=n.handlers;if(l){if(s.onPointerOver||s.onPointerEnter||s.onPointerOut||s.onPointerLeave){let t=hS(e),n=o.hovered.get(t);n?n.stopped&&e.stopPropagation():(o.hovered.set(t,e),null==s.onPointerOver||s.onPointerOver(e),null==s.onPointerEnter||s.onPointerEnter(e))}null==s.onPointerMove||s.onPointerMove(e)}else{let n=s[r];n?(!u||o.initialHits.includes(t))&&(i(a,o.interaction.filter(e=>!o.initialHits.includes(e))),n(e)):u&&o.initialHits.includes(t)&&i(a,o.interaction.filter(e=>!o.initialHits.includes(e)))}})}}}}(e);return{priority:1,enabled:!0,compute(e,t,n){t.pointer.set(e.offsetX/t.size.width*2-1,-(2*(e.offsetY/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)},connected:void 0,handlers:Object.keys(dn).reduce((e,n)=>({...e,[n]:t(n)}),{}),update:()=>{var t;let{events:n,internal:i}=e.getState();null!=(t=i.lastEvent)&&t.current&&n.handlers&&n.handlers.onPointerMove(i.lastEvent.current)},connect:t=>{let{set:n,events:i}=e.getState();if(null==i.disconnect||i.disconnect(),n(e=>({events:{...e.events,connected:t}})),i.handlers)for(let e in i.handlers){let n=i.handlers[e],[r,a]=dn[e];t.addEventListener(r,n,{passive:a})}},disconnect:()=>{let{set:t,events:n}=e.getState();if(n.connected){if(n.handlers)for(let e in n.handlers){let t=n.handlers[e],[i]=dn[e];n.connected.removeEventListener(i,t)}t(e=>({events:{...e.events,connected:void 0}}))}}}}e.i(16577),e.s(["ACESFilmicToneMapping",()=>4,"AddEquation",()=>100,"AddOperation",()=>2,"AdditiveAnimationBlendMode",()=>2501,"AdditiveBlending",()=>2,"AgXToneMapping",()=>6,"AlphaFormat",()=>1021,"AlwaysCompare",()=>519,"AlwaysDepth",()=>1,"AlwaysStencilFunc",()=>519,"AmbientLight",()=>sq,"AnimationAction",()=>oA,"AnimationClip",()=>sy,"AnimationLoader",()=>sA,"AnimationMixer",()=>oR,"AnimationObjectGroup",()=>oE,"AnimationUtils",()=>ss,"ArcCurve",()=>r8,"ArrayCamera",()=>oi,"ArrowHelper",()=>lv,"AttachedBindMode",()=>ee,"Audio",()=>oh,"AudioAnalyser",()=>ov,"AudioContext",()=>s8,"AudioListener",()=>oc,"AudioLoader",()=>s9,"AxesHelper",()=>lx,"BackSide",()=>1,"BasicDepthPacking",()=>3200,"BasicShadowMap",()=>0,"BatchedMesh",()=>rg,"Bone",()=>ik,"BooleanKeyframeTrack",()=>sd,"Box2",()=>oX,"Box3",()=>e9,"Box3Helper",()=>lf,"BoxGeometry",()=>nJ,"BoxHelper",()=>lp,"BufferAttribute",()=>ny,"BufferGeometry",()=>nO,"BufferGeometryLoader",()=>s0,"ByteType",()=>1010,"Cache",()=>s_,"Camera",()=>n2,"CameraHelper",()=>lc,"CanvasTexture",()=>rG,"CapsuleGeometry",()=>rY,"CatmullRomCurve3",()=>ai,"CineonToneMapping",()=>3,"CircleGeometry",()=>rZ,"ClampToEdgeWrapping",()=>1001,"Clock",()=>or,"Color",()=>no,"ColorKeyframeTrack",()=>sp,"ColorManagement",()=>eW,"CompressedArrayTexture",()=>rH,"CompressedCubeTexture",()=>rj,"CompressedTexture",()=>rV,"CompressedTextureLoader",()=>sC,"ConeGeometry",()=>r$,"ConstantAlphaFactor",()=>213,"ConstantColorFactor",()=>211,"Controls",()=>l_,"CubeCamera",()=>n8,"CubeDepthTexture",()=>rX,"CubeReflectionMapping",()=>301,"CubeRefractionMapping",()=>302,"CubeTexture",()=>n9,"CubeTextureLoader",()=>sI,"CubeUVReflectionMapping",()=>306,"CubicBezierCurve",()=>ao,"CubicBezierCurve3",()=>al,"CubicInterpolant",()=>sl,"CullFaceBack",()=>1,"CullFaceFront",()=>2,"CullFaceFrontBack",()=>3,"CullFaceNone",()=>0,"Curve",()=>r5,"CurvePath",()=>am,"CustomBlending",()=>5,"CustomToneMapping",()=>5,"CylinderGeometry",()=>rJ,"Cylindrical",()=>oj,"Data3DTexture",()=>e6,"DataArrayTexture",()=>e4,"DataTexture",()=>iB,"DataTextureLoader",()=>sL,"DataUtils",()=>nm,"DecrementStencilOp",()=>7683,"DecrementWrapStencilOp",()=>34056,"DefaultLoadingManager",()=>sS,"DepthFormat",()=>1026,"DepthStencilFormat",()=>1027,"DepthTexture",()=>rW,"DetachedBindMode",()=>et,"DirectionalLight",()=>sX,"DirectionalLightHelper",()=>lo,"DiscreteInterpolant",()=>sc,"DodecahedronGeometry",()=>rQ,"DoubleSide",()=>2,"DstAlphaFactor",()=>206,"DstColorFactor",()=>208,"DynamicCopyUsage",()=>35050,"DynamicDrawUsage",()=>35048,"DynamicReadUsage",()=>35049,"EdgesGeometry",()=>r4,"EllipseCurve",()=>r6,"EqualCompare",()=>514,"EqualDepth",()=>4,"EqualStencilFunc",()=>514,"EquirectangularReflectionMapping",()=>303,"EquirectangularRefractionMapping",()=>304,"Euler",()=>tU,"EventDispatcher",()=>ew,"ExternalTexture",()=>rq,"ExtrudeGeometry",()=>az,"FileLoader",()=>sE,"Float16BufferAttribute",()=>nA,"Float32BufferAttribute",()=>nC,"FloatType",()=>1015,"Fog",()=>ia,"FogExp2",()=>ir,"FramebufferTexture",()=>rB,"FrontSide",()=>0,"Frustum",()=>i6,"FrustumArray",()=>i7,"GLBufferAttribute",()=>oU,"GLSL1",()=>"100","GLSL3",()=>es,"GreaterCompare",()=>516,"GreaterDepth",()=>6,"GreaterEqualCompare",()=>518,"GreaterEqualDepth",()=>5,"GreaterEqualStencilFunc",()=>518,"GreaterStencilFunc",()=>516,"GridHelper",()=>ln,"Group",()=>ie,"HalfFloatType",()=>1016,"HemisphereLight",()=>sU,"HemisphereLightHelper",()=>lt,"IcosahedronGeometry",()=>aB,"ImageBitmapLoader",()=>s6,"ImageLoader",()=>sP,"ImageUtils",()=>eY,"IncrementStencilOp",()=>7682,"IncrementWrapStencilOp",()=>34055,"InstancedBufferAttribute",()=>iG,"InstancedBufferGeometry",()=>sQ,"InstancedInterleavedBuffer",()=>oD,"InstancedMesh",()=>iK,"Int16BufferAttribute",()=>nM,"Int32BufferAttribute",()=>nT,"Int8BufferAttribute",()=>n_,"IntType",()=>1013,"InterleavedBuffer",()=>io,"InterleavedBufferAttribute",()=>iu,"Interpolant",()=>so,"InterpolateDiscrete",()=>2300,"InterpolateLinear",()=>2301,"InterpolateSmooth",()=>2302,"InterpolationSamplingMode",()=>eu,"InterpolationSamplingType",()=>el,"InvertStencilOp",()=>5386,"KeepStencilOp",()=>7680,"KeyframeTrack",()=>sh,"LOD",()=>iC,"LatheGeometry",()=>aV,"Layers",()=>tO,"LessCompare",()=>513,"LessDepth",()=>2,"LessEqualCompare",()=>515,"LessEqualDepth",()=>3,"LessEqualStencilFunc",()=>515,"LessStencilFunc",()=>513,"Light",()=>sD,"LightProbe",()=>sJ,"Line",()=>rT,"Line3",()=>o0,"LineBasicMaterial",()=>rv,"LineCurve",()=>au,"LineCurve3",()=>ac,"LineDashedMaterial",()=>st,"LineLoop",()=>rP,"LineSegments",()=>rR,"LinearFilter",()=>1006,"LinearInterpolant",()=>su,"LinearMipMapLinearFilter",()=>1008,"LinearMipMapNearestFilter",()=>1007,"LinearMipmapLinearFilter",()=>1008,"LinearMipmapNearestFilter",()=>1007,"LinearSRGBColorSpace",()=>ei,"LinearToneMapping",()=>1,"LinearTransfer",()=>er,"Loader",()=>sM,"LoaderUtils",()=>sK,"LoadingManager",()=>sb,"LoopOnce",()=>2200,"LoopPingPong",()=>2202,"LoopRepeat",()=>2201,"MOUSE",()=>K,"Material",()=>nc,"MaterialLoader",()=>s$,"MathUtils",()=>eU,"Matrix2",()=>oG,"Matrix3",()=>eV,"Matrix4",()=>tT,"MaxEquation",()=>104,"Mesh",()=>nY,"MeshBasicMaterial",()=>nh,"MeshDepthMaterial",()=>a9,"MeshDistanceMaterial",()=>a7,"MeshLambertMaterial",()=>a8,"MeshMatcapMaterial",()=>se,"MeshNormalMaterial",()=>a6,"MeshPhongMaterial",()=>a4,"MeshPhysicalMaterial",()=>a3,"MeshStandardMaterial",()=>a2,"MeshToonMaterial",()=>a5,"MinEquation",()=>103,"MirroredRepeatWrapping",()=>1002,"MixOperation",()=>1,"MultiplyBlending",()=>4,"MultiplyOperation",()=>0,"NearestFilter",()=>1003,"NearestMipMapLinearFilter",()=>1005,"NearestMipMapNearestFilter",()=>1004,"NearestMipmapLinearFilter",()=>1005,"NearestMipmapNearestFilter",()=>1004,"NeutralToneMapping",()=>7,"NeverCompare",()=>512,"NeverDepth",()=>0,"NeverStencilFunc",()=>512,"NoBlending",()=>0,"NoColorSpace",()=>"","NoNormalPacking",()=>"","NoToneMapping",()=>0,"NormalAnimationBlendMode",()=>2500,"NormalBlending",()=>1,"NormalGAPacking",()=>"ga","NormalRGPacking",()=>"rg","NotEqualCompare",()=>517,"NotEqualDepth",()=>7,"NotEqualStencilFunc",()=>517,"NumberKeyframeTrack",()=>sf,"Object3D",()=>tK,"ObjectLoader",()=>s1,"ObjectSpaceNormalMap",()=>1,"OctahedronGeometry",()=>aH,"OneFactor",()=>201,"OneMinusConstantAlphaFactor",()=>214,"OneMinusConstantColorFactor",()=>212,"OneMinusDstAlphaFactor",()=>207,"OneMinusDstColorFactor",()=>209,"OneMinusSrcAlphaFactor",()=>205,"OneMinusSrcColorFactor",()=>203,"OrthographicCamera",()=>sG,"PCFShadowMap",()=>1,"PCFSoftShadowMap",()=>2,"PMREMGenerator",()=>lW,"Path",()=>ag,"PerspectiveCamera",()=>n6,"Plane",()=>i2,"PlaneGeometry",()=>aj,"PlaneHelper",()=>lm,"PointLight",()=>sj,"PointLightHelper",()=>o8,"Points",()=>rO,"PointsMaterial",()=>rI,"PolarGridHelper",()=>li,"PolyhedronGeometry",()=>rK,"PositionalAudio",()=>og,"PropertyBinding",()=>oT,"PropertyMixer",()=>ox,"QuadraticBezierCurve",()=>ah,"QuadraticBezierCurve3",()=>ad,"Quaternion",()=>eF,"QuaternionKeyframeTrack",()=>sg,"QuaternionLinearInterpolant",()=>sm,"R11_EAC_Format",()=>37488,"RED_GREEN_RGTC2_Format",()=>36285,"RED_RGTC1_Format",()=>36283,"REVISION",()=>"182","RG11_EAC_Format",()=>37490,"RGBADepthPacking",()=>3201,"RGBAFormat",()=>1023,"RGBAIntegerFormat",()=>1033,"RGBA_ASTC_10x10_Format",()=>37819,"RGBA_ASTC_10x5_Format",()=>37816,"RGBA_ASTC_10x6_Format",()=>37817,"RGBA_ASTC_10x8_Format",()=>37818,"RGBA_ASTC_12x10_Format",()=>37820,"RGBA_ASTC_12x12_Format",()=>37821,"RGBA_ASTC_4x4_Format",()=>37808,"RGBA_ASTC_5x4_Format",()=>37809,"RGBA_ASTC_5x5_Format",()=>37810,"RGBA_ASTC_6x5_Format",()=>37811,"RGBA_ASTC_6x6_Format",()=>37812,"RGBA_ASTC_8x5_Format",()=>37813,"RGBA_ASTC_8x6_Format",()=>37814,"RGBA_ASTC_8x8_Format",()=>37815,"RGBA_BPTC_Format",()=>36492,"RGBA_ETC2_EAC_Format",()=>37496,"RGBA_PVRTC_2BPPV1_Format",()=>35843,"RGBA_PVRTC_4BPPV1_Format",()=>35842,"RGBA_S3TC_DXT1_Format",()=>33777,"RGBA_S3TC_DXT3_Format",()=>33778,"RGBA_S3TC_DXT5_Format",()=>33779,"RGBDepthPacking",()=>3202,"RGBFormat",()=>1022,"RGBIntegerFormat",()=>1032,"RGB_BPTC_SIGNED_Format",()=>36494,"RGB_BPTC_UNSIGNED_Format",()=>36495,"RGB_ETC1_Format",()=>36196,"RGB_ETC2_Format",()=>37492,"RGB_PVRTC_2BPPV1_Format",()=>35841,"RGB_PVRTC_4BPPV1_Format",()=>35840,"RGB_S3TC_DXT1_Format",()=>33776,"RGDepthPacking",()=>3203,"RGFormat",()=>1030,"RGIntegerFormat",()=>1031,"RawShaderMaterial",()=>a1,"Ray",()=>tw,"Raycaster",()=>oF,"RectAreaLight",()=>sY,"RedFormat",()=>1028,"RedIntegerFormat",()=>1029,"ReinhardToneMapping",()=>2,"RenderTarget",()=>e2,"RenderTarget3D",()=>oP,"RepeatWrapping",()=>1e3,"ReplaceStencilOp",()=>7681,"ReverseSubtractEquation",()=>102,"RingGeometry",()=>aG,"SIGNED_R11_EAC_Format",()=>37489,"SIGNED_RED_GREEN_RGTC2_Format",()=>36286,"SIGNED_RED_RGTC1_Format",()=>36284,"SIGNED_RG11_EAC_Format",()=>37491,"SRGBColorSpace",()=>en,"SRGBTransfer",()=>ea,"Scene",()=>is,"ShaderChunk",()=>lT,"ShaderLib",()=>lA,"ShaderMaterial",()=>n1,"ShadowMaterial",()=>a0,"Shape",()=>av,"ShapeGeometry",()=>aW,"ShapePath",()=>ly,"ShapeUtils",()=>aU,"ShortType",()=>1011,"Skeleton",()=>ij,"SkeletonHelper",()=>o6,"SkinnedMesh",()=>iz,"Source",()=>eJ,"Sphere",()=>tg,"SphereGeometry",()=>aX,"Spherical",()=>oH,"SphericalHarmonics3",()=>sZ,"SplineCurve",()=>ap,"SpotLight",()=>sV,"SpotLightHelper",()=>o2,"Sprite",()=>iw,"SpriteMaterial",()=>ic,"SrcAlphaFactor",()=>204,"SrcAlphaSaturateFactor",()=>210,"SrcColorFactor",()=>202,"StaticCopyUsage",()=>35046,"StaticDrawUsage",()=>35044,"StaticReadUsage",()=>35045,"StereoCamera",()=>on,"StreamCopyUsage",()=>35042,"StreamDrawUsage",()=>35040,"StreamReadUsage",()=>35041,"StringKeyframeTrack",()=>sv,"SubtractEquation",()=>101,"SubtractiveBlending",()=>3,"TOUCH",()=>Q,"TangentSpaceNormalMap",()=>0,"TetrahedronGeometry",()=>aq,"Texture",()=>e0,"TextureLoader",()=>sN,"TextureUtils",()=>lS,"Timer",()=>oB,"TimestampQuery",()=>eo,"TorusGeometry",()=>aY,"TorusKnotGeometry",()=>aZ,"Triangle",()=>nn,"TriangleFanDrawMode",()=>2,"TriangleStripDrawMode",()=>1,"TrianglesDrawMode",()=>0,"TubeGeometry",()=>aJ,"UVMapping",()=>300,"Uint16BufferAttribute",()=>nw,"Uint32BufferAttribute",()=>nE,"Uint8BufferAttribute",()=>nb,"Uint8ClampedBufferAttribute",()=>nS,"Uniform",()=>oI,"UniformsGroup",()=>oN,"UniformsLib",()=>lE,"UniformsUtils",()=>n0,"UnsignedByteType",()=>1009,"UnsignedInt101111Type",()=>35899,"UnsignedInt248Type",()=>1020,"UnsignedInt5999Type",()=>35902,"UnsignedIntType",()=>1014,"UnsignedShort4444Type",()=>1017,"UnsignedShort5551Type",()=>1018,"UnsignedShortType",()=>1012,"VSMShadowMap",()=>3,"Vector2",()=>eO,"Vector3",()=>ez,"Vector4",()=>e1,"VectorKeyframeTrack",()=>sx,"VideoFrameTexture",()=>rk,"VideoTexture",()=>rz,"WebGL3DRenderTarget",()=>e8,"WebGLArrayRenderTarget",()=>e5,"WebGLCoordinateSystem",()=>2e3,"WebGLCubeRenderTarget",()=>n7,"WebGLRenderTarget",()=>e3,"WebGLRenderer",()=>cq,"WebGLUtils",()=>cO,"WebGPUCoordinateSystem",()=>2001,"WebXRController",()=>ii,"WireframeGeometry",()=>a$,"WrapAroundEnding",()=>2402,"ZeroCurvatureEnding",()=>2400,"ZeroFactor",()=>200,"ZeroSlopeEnding",()=>2401,"ZeroStencilOp",()=>0,"createCanvasElement",()=>em,"error",()=>eS,"getConsoleFunction",()=>ey,"log",()=>e_,"setConsoleFunction",()=>ex,"warn",()=>eb,"warnOnce",()=>eM],65105);var dr=e.i(65105);function da(e,t){let n;return(...i)=>{window.clearTimeout(n),n=window.setTimeout(()=>e(...i),t)}}let ds=["x","y","top","bottom","left","right","width","height"];function dl({ref:e,children:t,fallback:n,resize:i,style:r,gl:a,events:s=di,eventSource:o,eventPrefix:l,shadows:u,linear:c,flat:h,legacy:d,orthographic:p,frameloop:f,dpr:m,performance:g,raycaster:v,camera:x,scene:y,onPointerMissed:_,onCreated:b,...S}){let M,w,T;P.useMemo(()=>(function(e){if("function"==typeof e){let t=`${hz++}`;return hU[t]=e,t}Object.assign(hU,e)})(dr),[]);let E=(M=c8(),w=function(){let e=c8(),[t]=c2.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;c7(e)&&e!==c5&&!t.has(e)&&t.set(e,c2.use(c4(e))),n=n.return}return t}(),T=c2.useMemo(()=>Array.from(w.keys()).reduce((e,t)=>n=>c2.createElement(e,null,c2.createElement(t.Provider,{...n,value:w.get(t)})),e=>c2.createElement(c6,{...e})),[w]),$.useMemo(()=>({children:e})=>{let t=c3(M,!0,e=>e.type===$.StrictMode)?$.StrictMode:$.Fragment;return(0,R.jsx)(t,{children:(0,R.jsx)(T,{children:e})})},[M,T])),[A,C]=function({debounce:e,scroll:t,polyfill:n,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){var r,a,s;let o=n||("u"<typeof window?class{}:window.ResizeObserver);if(!o)throw Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");let[l,u]=(0,P.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),c=(0,P.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:l,orientationHandler:null}),h=e?"number"==typeof e?e:e.scroll:null,d=e?"number"==typeof e?e:e.resize:null,p=(0,P.useRef)(!1);(0,P.useEffect)(()=>(p.current=!0,()=>void(p.current=!1)));let[f,m,g]=(0,P.useMemo)(()=>{let e=()=>{let e,t;if(!c.current.element)return;let{left:n,top:r,width:a,height:s,bottom:o,right:l,x:h,y:d}=c.current.element.getBoundingClientRect(),f={left:n,top:r,width:a,height:s,bottom:o,right:l,x:h,y:d};c.current.element instanceof HTMLElement&&i&&(f.height=c.current.element.offsetHeight,f.width=c.current.element.offsetWidth),Object.freeze(f),p.current&&(e=c.current.lastBounds,t=f,!ds.every(n=>e[n]===t[n]))&&u(c.current.lastBounds=f)};return[e,d?da(e,d):e,h?da(e,h):e]},[u,i,h,d]);function v(){c.current.scrollContainers&&(c.current.scrollContainers.forEach(e=>e.removeEventListener("scroll",g,!0)),c.current.scrollContainers=null),c.current.resizeObserver&&(c.current.resizeObserver.disconnect(),c.current.resizeObserver=null),c.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",c.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",c.current.orientationHandler))}function x(){c.current.element&&(c.current.resizeObserver=new o(g),c.current.resizeObserver.observe(c.current.element),t&&c.current.scrollContainers&&c.current.scrollContainers.forEach(e=>e.addEventListener("scroll",g,{capture:!0,passive:!0})),c.current.orientationHandler=()=>{g()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",c.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",c.current.orientationHandler))}return r=g,a=!!t,(0,P.useEffect)(()=>{if(a)return window.addEventListener("scroll",r,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",r,!0)},[r,a]),s=m,(0,P.useEffect)(()=>(window.addEventListener("resize",s),()=>void window.removeEventListener("resize",s)),[s]),(0,P.useEffect)(()=>{v(),x()},[t,g,m]),(0,P.useEffect)(()=>v,[]),[e=>{e&&e!==c.current.element&&(v(),c.current.element=e,c.current.scrollContainers=function e(t){let n=[];if(!t||t===document.body)return n;let{overflow:i,overflowX:r,overflowY:a}=window.getComputedStyle(t);return[i,r,a].some(e=>"auto"===e||"scroll"===e)&&n.push(t),[...n,...e(t.parentElement)]}(e),x())},l,f]}({scroll:!0,debounce:{scroll:50,resize:0},...i}),I=P.useRef(null),L=P.useRef(null);P.useImperativeHandle(e,()=>I.current);let N=hi(_),[D,U]=P.useState(!1),[O,F]=P.useState(!1);if(D)throw D;if(O)throw O;let z=P.useRef(null);hn(()=>{let e=I.current;if(C.width>0&&C.height>0&&e){let n,i,r,_,S,M,w,T,A,I,D,O,k,B,V,H,j;z.current||(_=null==(r=h$.get(e))?void 0:r.fiber,S=null==r?void 0:r.store,r&&console.warn("R3F.createRoot should only be called once!"),M="function"==typeof reportError?reportError:console.error,B=S||(D=(I=(A=(w=(e,t)=>{let n,i=new ez,r=new ez,a=new ez;function s(e=t().camera,n=r,o=t().size){let{width:l,height:u,top:c,left:h}=o,d=l/u;n.isVector3?a.copy(n):a.set(...n);let p=e.getWorldPosition(i).distanceTo(a);if(e&&e.isOrthographicCamera)return{width:l/e.zoom,height:u/e.zoom,top:c,left:h,factor:1,distance:p,aspect:d};{let t=2*Math.tan(e.fov*Math.PI/180/2)*p,n=l/u*t;return{width:n,height:t,top:c,left:h,factor:l/n,distance:p,aspect:d}}}let o=t=>e(e=>({performance:{...e.performance,current:t}})),l=new eO;return{set:e,get:t,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(e=1)=>de(t(),e),advance:(e,n)=>dt(e,n,t()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new or,pointer:l,mouse:l,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=t();n&&clearTimeout(n),e.performance.current!==e.performance.min&&o(e.performance.min),n=setTimeout(()=>o(t().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:s},setEvents:t=>e(e=>({...e,events:{...e.events,...t}})),setSize:(n,i,a=0,o=0)=>{let l=t().camera,u={width:n,height:i,top:a,left:o};e(e=>({size:u,viewport:{...e.viewport,...s(l,r,u)}}))},setDpr:t=>e(e=>{let n=hs(t);return{viewport:{...e.viewport,dpr:n,initialDpr:e.viewport.initialDpr||n}}}),setFrameloop:(n="always")=>{let i=t().clock;i.stop(),i.elapsedTime=0,"never"!==n&&(i.start(),i.elapsedTime=0),e(()=>({frameloop:n}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:$.createRef(),active:!1,frames:0,priority:0,subscribe:(e,n,i)=>{let r=t().internal;return r.priority=r.priority+ +(n>0),r.subscribers.push({ref:e,priority:n,store:i}),r.subscribers=r.subscribers.sort((e,t)=>e.priority-t.priority),()=>{let i=t().internal;null!=i&&i.subscribers&&(i.priority=i.priority-(n>0),i.subscribers=i.subscribers.filter(t=>t.ref!==e))}}}}})?c$(w,T):c$).getState()).size,O=I.viewport.dpr,k=I.camera,A.subscribe(()=>{let{camera:e,size:t,viewport:n,gl:i,set:r}=A.getState();if(t.width!==D.width||t.height!==D.height||n.dpr!==O){D=t,O=n.dpr;!e.manual&&(e&&e.isOrthographicCamera?(e.left=-(t.width/2),e.right=t.width/2,e.top=t.height/2,e.bottom=-(t.height/2)):e.aspect=t.width/t.height,e.updateProjectionMatrix());n.dpr>0&&i.setPixelRatio(n.dpr);let r="u">typeof HTMLCanvasElement&&i.domElement instanceof HTMLCanvasElement;i.setSize(t.width,t.height,r)}e!==k&&(k=e,r(t=>({viewport:{...t.viewport,...t.viewport.getCurrentViewport(e)}})))}),A.subscribe(e=>de(e)),A),V=_||hJ.createContainer(B,1,null,!1,null,"",M,M,M,null),r||h$.set(e,{fiber:V,store:B}),H=!1,j=null,z.current={async configure(t={}){var r,a;let s;j=new Promise(e=>s=e);let{gl:o,size:l,scene:u,events:c,onCreated:h,shadows:d=!1,linear:p=!1,flat:f=!1,legacy:m=!1,orthographic:g=!1,frameloop:v="always",dpr:x=[1,2],performance:y,raycaster:_,camera:b,onPointerMissed:S}=t,M=B.getState(),w=M.gl;if(!M.gl){let t={canvas:e,powerPreference:"high-performance",antialias:!0,alpha:!0},n="function"==typeof o?await o(t):o;w=hw(n)?n:new cq({...t,...o}),M.set({gl:w})}let T=M.raycaster;T||M.set({raycaster:T=new oF});let{params:E,...A}=_||{};if(hl.equ(A,T,hK)||hy(T,{...A}),hl.equ(E,T.params,hK)||hy(T,{params:{...T.params,...E}}),!M.camera||M.camera===i&&!hl.equ(i,b,hK)){i=b;let e=null==b?void 0:b.isCamera,t=e?b:g?new sG(0,0,0,0,.1,1e3):new n6(75,0,.1,1e3);!e&&(t.position.z=5,b&&(hy(t,b),!t.manual&&("aspect"in b||"left"in b||"right"in b||"bottom"in b||"top"in b)&&(t.manual=!0,t.updateProjectionMatrix())),M.camera||null!=b&&b.rotation||t.lookAt(0,0,0)),M.set({camera:t}),T.camera=t}if(!M.scene){let e;null!=u&&u.isScene?hc(e=u,B,"",{}):(hc(e=new is,B,"",{}),u&&hy(e,u)),M.set({scene:e})}c&&!M.events.handlers&&M.set({events:c(B)});let C=function(e,t){if(!t&&"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:t,height:n,top:i,left:r}=e.parentElement.getBoundingClientRect();return{width:t,height:n,top:i,left:r}}return!t&&"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas?{width:e.width,height:e.height,top:0,left:0}:{width:0,height:0,top:0,left:0,...t}}(e,l);if(hl.equ(C,M.size,hK)||M.setSize(C.width,C.height,C.top,C.left),x&&M.viewport.dpr!==hs(x)&&M.setDpr(x),M.frameloop!==v&&M.setFrameloop(v),M.onPointerMissed||M.set({onPointerMissed:S}),y&&!hl.equ(y,M.performance,hK)&&M.set(e=>({performance:{...e.performance,...y}})),!M.xr){let e=(e,t)=>{let n=B.getState();"never"!==n.frameloop&&dt(e,!0,n,t)},t=()=>{let t=B.getState();t.gl.xr.enabled=t.gl.xr.isPresenting,t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting?e:null),t.gl.xr.isPresenting||de(t)},n={connect(){let e=B.getState().gl;e.xr.addEventListener("sessionstart",t),e.xr.addEventListener("sessionend",t)},disconnect(){let e=B.getState().gl;e.xr.removeEventListener("sessionstart",t),e.xr.removeEventListener("sessionend",t)}};"function"==typeof(null==(r=w.xr)?void 0:r.addEventListener)&&n.connect(),M.set({xr:n})}if(w.shadowMap){let e=w.shadowMap.enabled,t=w.shadowMap.type;w.shadowMap.enabled=!!d,hl.boo(d)?w.shadowMap.type=2:hl.str(d)?w.shadowMap.type=null!=(a=({basic:0,percentage:1,soft:2,variance:3})[d])?a:2:hl.obj(d)&&Object.assign(w.shadowMap,d),(e!==w.shadowMap.enabled||t!==w.shadowMap.type)&&(w.shadowMap.needsUpdate=!0)}return eW.enabled=!m,H||(w.outputColorSpace=p?ei:en,w.toneMapping=4*!f),M.legacy!==m&&M.set(()=>({legacy:m})),M.linear!==p&&M.set(()=>({linear:p})),M.flat!==f&&M.set(()=>({flat:f})),!o||hl.fun(o)||hw(o)||hl.equ(o,w,hK)||hy(w,o),n=h,H=!0,s(),this},render(t){return H||j||this.configure(),j.then(()=>{hJ.updateContainer((0,R.jsx)(hQ,{store:B,children:t,onCreated:n,rootElement:e}),V,null,()=>void 0)}),B},unmount(){h0(e)}}),async function(){await z.current.configure({gl:a,scene:y,events:s,shadows:u,linear:c,flat:h,legacy:d,orthographic:p,frameloop:f,dpr:m,performance:g,raycaster:v,camera:x,size:C,onPointerMissed:(...e)=>null==N.current?void 0:N.current(...e),onCreated:e=>{null==e.events.connect||e.events.connect(o?o&&o.hasOwnProperty("current")?o.current:o:L.current),l&&e.setEvents({compute:(e,t)=>{let n=e[l+"X"],i=e[l+"Y"];t.pointer.set(n/t.size.width*2-1,-(2*(i/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),null==b||b(e)}}),z.current.render((0,R.jsx)(E,{children:(0,R.jsx)(ha,{set:F,children:(0,R.jsx)(P.Suspense,{fallback:(0,R.jsx)(hr,{set:U}),children:null!=t?t:null})})}))}()}}),P.useEffect(()=>{let e=I.current;if(e)return()=>h0(e)},[]);let k=o?"none":"auto";return(0,R.jsx)("div",{ref:L,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:k,...r},...S,children:(0,R.jsx)("div",{ref:A,style:{width:"100%",height:"100%"},children:(0,R.jsx)("canvas",{ref:I,style:{display:"block"},children:n})})})}function du(e){return(0,R.jsx)(c6,{children:(0,R.jsx)(dl,{...e})})}function dc(){return(dc=Object.assign.bind()).apply(null,arguments)}var dh=Object.defineProperty;class dd{constructor(){((e,t,n)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?dh(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n})(this,"_listeners")}addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let n=this._listeners[e];if(void 0!==n){let e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let n=t.slice(0);for(let t=0,i=n.length;t<i;t++)n[t].call(this,e);e.target=null}}}var dp=Object.defineProperty,df=(e,t,n)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?dp(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,n};let dm=new tw,dg=new i2,dv=Math.cos(Math.PI/180*70),dx=(e,t)=>(e%t+t)%t;class dy extends dd{constructor(e,t){super(),df(this,"object"),df(this,"domElement"),df(this,"enabled",!0),df(this,"target",new ez),df(this,"minDistance",0),df(this,"maxDistance",1/0),df(this,"minZoom",0),df(this,"maxZoom",1/0),df(this,"minPolarAngle",0),df(this,"maxPolarAngle",Math.PI),df(this,"minAzimuthAngle",-1/0),df(this,"maxAzimuthAngle",1/0),df(this,"enableDamping",!1),df(this,"dampingFactor",.05),df(this,"enableZoom",!0),df(this,"zoomSpeed",1),df(this,"enableRotate",!0),df(this,"rotateSpeed",1),df(this,"enablePan",!0),df(this,"panSpeed",1),df(this,"screenSpacePanning",!0),df(this,"keyPanSpeed",7),df(this,"zoomToCursor",!1),df(this,"autoRotate",!1),df(this,"autoRotateSpeed",2),df(this,"reverseOrbit",!1),df(this,"reverseHorizontalOrbit",!1),df(this,"reverseVerticalOrbit",!1),df(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),df(this,"mouseButtons",{LEFT:K.ROTATE,MIDDLE:K.DOLLY,RIGHT:K.PAN}),df(this,"touches",{ONE:Q.ROTATE,TWO:Q.DOLLY_PAN}),df(this,"target0"),df(this,"position0"),df(this,"zoom0"),df(this,"_domElementKeyEvents",null),df(this,"getPolarAngle"),df(this,"getAzimuthalAngle"),df(this,"setPolarAngle"),df(this,"setAzimuthalAngle"),df(this,"getDistance"),df(this,"getZoomScale"),df(this,"listenToKeyEvents"),df(this,"stopListenToKeyEvents"),df(this,"saveState"),df(this,"reset"),df(this,"update"),df(this,"connect"),df(this,"dispose"),df(this,"dollyIn"),df(this,"dollyOut"),df(this,"getScale"),df(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>u.phi,this.getAzimuthalAngle=()=>u.theta,this.setPolarAngle=e=>{let t=dx(e,2*Math.PI),i=u.phi;i<0&&(i+=2*Math.PI),t<0&&(t+=2*Math.PI);let r=Math.abs(t-i);2*Math.PI-r<r&&(t<i?t+=2*Math.PI:i+=2*Math.PI),c.phi=t-i,n.update()},this.setAzimuthalAngle=e=>{let t=dx(e,2*Math.PI),i=u.theta;i<0&&(i+=2*Math.PI),t<0&&(t+=2*Math.PI);let r=Math.abs(t-i);2*Math.PI-r<r&&(t<i?t+=2*Math.PI:i+=2*Math.PI),c.theta=t-i,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=e=>{e.addEventListener("keydown",Y),this._domElementKeyEvents=e},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Y),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(i),n.update(),o=s.NONE},this.update=(()=>{let t=new ez,r=new ez(0,1,0),a=new eF().setFromUnitVectors(e.up,r),p=a.clone().invert(),f=new ez,m=new eF,g=2*Math.PI;return function(){let v=n.object.position;a.setFromUnitVectors(e.up,r),p.copy(a).invert(),t.copy(v).sub(n.target),t.applyQuaternion(a),u.setFromVector3(t),n.autoRotate&&o===s.NONE&&C(2*Math.PI/60/60*n.autoRotateSpeed),n.enableDamping?(u.theta+=c.theta*n.dampingFactor,u.phi+=c.phi*n.dampingFactor):(u.theta+=c.theta,u.phi+=c.phi);let x=n.minAzimuthAngle,y=n.maxAzimuthAngle;isFinite(x)&&isFinite(y)&&(x<-Math.PI?x+=g:x>Math.PI&&(x-=g),y<-Math.PI?y+=g:y>Math.PI&&(y-=g),x<=y?u.theta=Math.max(x,Math.min(y,u.theta)):u.theta=u.theta>(x+y)/2?Math.max(x,u.theta):Math.min(y,u.theta)),u.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,u.phi)),u.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(d,n.dampingFactor):n.target.add(d),n.zoomToCursor&&w||n.object.isOrthographicCamera?u.radius=U(u.radius):u.radius=U(u.radius*h),t.setFromSpherical(u),t.applyQuaternion(p),v.copy(n.target).add(t),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),!0===n.enableDamping?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,d.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let _=!1;if(n.zoomToCursor&&w){let i=null;if(n.object instanceof n6&&n.object.isPerspectiveCamera){let e=t.length();i=U(e*h);let r=e-i;n.object.position.addScaledVector(S,r),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){let e=new ez(M.x,M.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/h)),n.object.updateProjectionMatrix(),_=!0;let r=new ez(M.x,M.y,0);r.unproject(n.object),n.object.position.sub(r).add(e),n.object.updateMatrixWorld(),i=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==i&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(i).add(n.object.position):(dm.origin.copy(n.object.position),dm.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(dm.direction))<dv?e.lookAt(n.target):(dg.setFromNormalAndCoplanarPoint(n.object.up,n.target),dm.intersectPlane(dg,n.target))))}else n.object instanceof sG&&n.object.isOrthographicCamera&&(_=1!==h)&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/h)),n.object.updateProjectionMatrix());return h=1,w=!1,!!(_||f.distanceToSquared(n.object.position)>l||8*(1-m.dot(n.object.quaternion))>l)&&(n.dispatchEvent(i),f.copy(n.object.position),m.copy(n.object.quaternion),_=!1,!0)}})(),this.connect=e=>{n.domElement=e,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Z),n.domElement.addEventListener("pointerdown",G),n.domElement.addEventListener("pointercancel",X),n.domElement.addEventListener("wheel",q)},this.dispose=()=>{var e,t,i,r,a,s;n.domElement&&(n.domElement.style.touchAction="auto"),null==(e=n.domElement)||e.removeEventListener("contextmenu",Z),null==(t=n.domElement)||t.removeEventListener("pointerdown",G),null==(i=n.domElement)||i.removeEventListener("pointercancel",X),null==(r=n.domElement)||r.removeEventListener("wheel",q),null==(a=n.domElement)||a.ownerDocument.removeEventListener("pointermove",W),null==(s=n.domElement)||s.ownerDocument.removeEventListener("pointerup",X),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",Y)};const n=this,i={type:"change"},r={type:"start"},a={type:"end"},s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let o=s.NONE;const l=1e-6,u=new oH,c=new oH;let h=1;const d=new ez,p=new eO,f=new eO,m=new eO,g=new eO,v=new eO,x=new eO,y=new eO,_=new eO,b=new eO,S=new ez,M=new eO;let w=!1;const T=[],E={};function A(){return Math.pow(.95,n.zoomSpeed)}function C(e){n.reverseOrbit||n.reverseHorizontalOrbit?c.theta+=e:c.theta-=e}function R(e){n.reverseOrbit||n.reverseVerticalOrbit?c.phi+=e:c.phi-=e}const P=(()=>{let e=new ez;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),d.add(e)}})(),I=(()=>{let e=new ez;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),d.add(e)}})(),L=(()=>{let e=new ez;return function(t,i){let r=n.domElement;if(r&&n.object instanceof n6&&n.object.isPerspectiveCamera){let a=n.object.position;e.copy(a).sub(n.target);let s=e.length();P(2*t*(s*=Math.tan(n.object.fov/2*Math.PI/180))/r.clientHeight,n.object.matrix),I(2*i*s/r.clientHeight,n.object.matrix)}else r&&n.object instanceof sG&&n.object.isOrthographicCamera?(P(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),I(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function N(e){n.object instanceof n6&&n.object.isPerspectiveCamera||n.object instanceof sG&&n.object.isOrthographicCamera?h=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function D(e){if(!n.zoomToCursor||!n.domElement)return;w=!0;let t=n.domElement.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,a=t.width,s=t.height;M.x=i/a*2-1,M.y=-(r/s*2)+1,S.set(M.x,M.y,1).unproject(n.object).sub(n.object.position).normalize()}function U(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function O(e){p.set(e.clientX,e.clientY)}function F(e){g.set(e.clientX,e.clientY)}function z(){if(1==T.length)p.set(T[0].pageX,T[0].pageY);else{let e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);p.set(e,t)}}function k(){if(1==T.length)g.set(T[0].pageX,T[0].pageY);else{let e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);g.set(e,t)}}function B(){let e=T[0].pageX-T[1].pageX,t=T[0].pageY-T[1].pageY,n=Math.sqrt(e*e+t*t);y.set(0,n)}function V(e){if(1==T.length)f.set(e.pageX,e.pageY);else{let t=$(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);f.set(n,i)}m.subVectors(f,p).multiplyScalar(n.rotateSpeed);let t=n.domElement;t&&(C(2*Math.PI*m.x/t.clientHeight),R(2*Math.PI*m.y/t.clientHeight)),p.copy(f)}function H(e){if(1==T.length)v.set(e.pageX,e.pageY);else{let t=$(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);v.set(n,i)}x.subVectors(v,g).multiplyScalar(n.panSpeed),L(x.x,x.y),g.copy(v)}function j(e){var t;let i=$(e),r=e.pageX-i.x,a=e.pageY-i.y,s=Math.sqrt(r*r+a*a);_.set(0,s),b.set(0,Math.pow(_.y/y.y,n.zoomSpeed)),t=b.y,N(h/t),y.copy(_)}function G(e){var t,i,a;!1!==n.enabled&&(0===T.length&&(null==(t=n.domElement)||t.ownerDocument.addEventListener("pointermove",W),null==(i=n.domElement)||i.ownerDocument.addEventListener("pointerup",X)),a=e,T.push(a),"touch"===e.pointerType?function(e){switch(J(e),T.length){case 1:switch(n.touches.ONE){case Q.ROTATE:if(!1===n.enableRotate)return;z(),o=s.TOUCH_ROTATE;break;case Q.PAN:if(!1===n.enablePan)return;k(),o=s.TOUCH_PAN;break;default:o=s.NONE}break;case 2:switch(n.touches.TWO){case Q.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&k(),o=s.TOUCH_DOLLY_PAN;break;case Q.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&z(),o=s.TOUCH_DOLLY_ROTATE;break;default:o=s.NONE}break;default:o=s.NONE}o!==s.NONE&&n.dispatchEvent(r)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case K.DOLLY:if(!1===n.enableZoom)return;D(e),y.set(e.clientX,e.clientY),o=s.DOLLY;break;case K.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;F(e),o=s.PAN}else{if(!1===n.enableRotate)return;O(e),o=s.ROTATE}break;case K.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;O(e),o=s.ROTATE}else{if(!1===n.enablePan)return;F(e),o=s.PAN}break;default:o=s.NONE}o!==s.NONE&&n.dispatchEvent(r)}(e))}function W(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(J(e),o){case s.TOUCH_ROTATE:if(!1===n.enableRotate)return;V(e),n.update();break;case s.TOUCH_PAN:if(!1===n.enablePan)return;H(e),n.update();break;case s.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&j(e),n.enablePan&&H(e),n.update();break;case s.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&j(e),n.enableRotate&&V(e),n.update();break;default:o=s.NONE}}(e):function(e){if(!1!==n.enabled)switch(o){case s.ROTATE:let t;if(!1===n.enableRotate)return;f.set(e.clientX,e.clientY),m.subVectors(f,p).multiplyScalar(n.rotateSpeed),(t=n.domElement)&&(C(2*Math.PI*m.x/t.clientHeight),R(2*Math.PI*m.y/t.clientHeight)),p.copy(f),n.update();break;case s.DOLLY:var i,r;if(!1===n.enableZoom)return;(_.set(e.clientX,e.clientY),b.subVectors(_,y),b.y>0)?(i=A(),N(h/i)):b.y<0&&(r=A(),N(h*r)),y.copy(_),n.update();break;case s.PAN:if(!1===n.enablePan)return;v.set(e.clientX,e.clientY),x.subVectors(v,g).multiplyScalar(n.panSpeed),L(x.x,x.y),g.copy(v),n.update()}}(e))}function X(e){var t,i,r;(function(e){delete E[e.pointerId];for(let t=0;t<T.length;t++)if(T[t].pointerId==e.pointerId)return void T.splice(t,1)})(e),0===T.length&&(null==(t=n.domElement)||t.releasePointerCapture(e.pointerId),null==(i=n.domElement)||i.ownerDocument.removeEventListener("pointermove",W),null==(r=n.domElement)||r.ownerDocument.removeEventListener("pointerup",X)),n.dispatchEvent(a),o=s.NONE}function q(e){if(!1!==n.enabled&&!1!==n.enableZoom&&(o===s.NONE||o===s.ROTATE)){var t,i;e.preventDefault(),n.dispatchEvent(r),(D(e),e.deltaY<0)?(t=A(),N(h*t)):e.deltaY>0&&(i=A(),N(h/i)),n.update(),n.dispatchEvent(a)}}function Y(e){if(!1!==n.enabled&&!1!==n.enablePan){let t=!1;switch(e.code){case n.keys.UP:L(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:L(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:L(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:L(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}}function Z(e){!1!==n.enabled&&e.preventDefault()}function J(e){let t=E[e.pointerId];void 0===t&&(t=new eO,E[e.pointerId]=t),t.set(e.pageX,e.pageY)}function $(e){return E[(e.pointerId===T[0].pointerId?T[1]:T[0]).pointerId]}this.dollyIn=(e=A())=>{N(h*e),n.update()},this.dollyOut=(e=A())=>{N(h/e),n.update()},this.getScale=()=>h,this.setScale=e=>{N(e),n.update()},this.getZoomScale=()=>A(),void 0!==t&&this.connect(t),this.update()}}let d_=P.forwardRef(({makeDefault:e,camera:t,regress:n,domElement:i,enableDamping:r=!0,keyEvents:a=!1,onChange:s,onStart:o,onEnd:l,...u},c)=>{let h=hA(e=>e.invalidate),d=hA(e=>e.camera),p=hA(e=>e.gl),f=hA(e=>e.events),m=hA(e=>e.setEvents),g=hA(e=>e.set),v=hA(e=>e.get),x=hA(e=>e.performance),y=t||d,_=i||f.connected||p.domElement,b=P.useMemo(()=>new dy(y),[y]);return hC(()=>{b.enabled&&b.update()},-1),P.useEffect(()=>(a&&b.connect(!0===a?_:a),b.connect(_),()=>void b.dispose()),[a,_,n,b,h]),P.useEffect(()=>{let e=e=>{h(),n&&x.regress(),s&&s(e)},t=e=>{o&&o(e)},i=e=>{l&&l(e)};return b.addEventListener("change",e),b.addEventListener("start",t),b.addEventListener("end",i),()=>{b.removeEventListener("start",t),b.removeEventListener("end",i),b.removeEventListener("change",e)}},[s,o,l,b,h,m]),P.useEffect(()=>{if(e){let e=v().controls;return g({controls:b}),()=>g({controls:e})}},[e,b]),P.createElement("primitive",dc({ref:c,object:b,enableDamping:r},u))});var db=e.i(78612);let dS=new ez,dM=new ez,dw=new ez,dT=new eO;function dE(e,t,n){let i=dS.setFromMatrixPosition(e.matrixWorld);i.project(t);let r=n.width/2,a=n.height/2;return[i.x*r+r,-(i.y*a)+a]}let dA=e=>1e-10>Math.abs(e)?0:e;function dC(e,t,n=""){let i="matrix3d(";for(let n=0;16!==n;n++)i+=dA(t[n]*e.elements[n])+(15!==n?",":")");return n+i}let dR=(b=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>dC(e,b)),dP=(S=e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1],(e,t)=>dC(e,S(t),"translate(-50%,-50%)")),dI=P.forwardRef(({children:e,eps:t=.001,style:n,className:i,prepend:r,center:a,fullscreen:s,portal:o,distanceFactor:l,sprite:u=!1,transform:c=!1,occlude:h,onOcclude:d,castShadow:p,receiveShadow:f,material:m,geometry:g,zIndexRange:v=[0x1000037,0],calculatePosition:x=dE,as:y="div",wrapperClass:_,pointerEvents:b="auto",...S},M)=>{let{gl:w,camera:T,scene:E,size:A,raycaster:C,events:R,viewport:I}=hA(),[L]=P.useState(()=>document.createElement(y)),N=P.useRef(null),D=P.useRef(null),U=P.useRef(0),O=P.useRef([0,0]),F=P.useRef(null),z=P.useRef(null),k=(null==o?void 0:o.current)||R.connected||w.domElement.parentNode,B=P.useRef(null),V=P.useRef(!1),H=P.useMemo(()=>{var e;return h&&"blending"!==h||Array.isArray(h)&&h.length&&(e=h[0])&&"object"==typeof e&&"current"in e},[h]);P.useLayoutEffect(()=>{let e=w.domElement;h&&"blending"===h?(e.style.zIndex=`${Math.floor(v[0]/2)}`,e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[h]),P.useLayoutEffect(()=>{if(D.current){let e=N.current=db.createRoot(L);if(E.updateMatrixWorld(),c)L.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{let e=x(D.current,T,A);L.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return k&&(r?k.prepend(L):k.appendChild(L)),()=>{k&&k.removeChild(L),e.unmount()}}},[k,c]),P.useLayoutEffect(()=>{_&&(L.className=_)},[_]);let j=P.useMemo(()=>c?{position:"absolute",top:0,left:0,width:A.width,height:A.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:a?"translate3d(-50%,-50%,0)":"none",...s&&{top:-A.height/2,left:-A.width/2,width:A.width,height:A.height},...n},[n,a,s,A,c]),G=P.useMemo(()=>({position:"absolute",pointerEvents:b}),[b]);P.useLayoutEffect(()=>{var t,r;V.current=!1,c?null==(t=N.current)||t.render(P.createElement("div",{ref:F,style:j},P.createElement("div",{ref:z,style:G},P.createElement("div",{ref:M,className:i,style:n,children:e})))):null==(r=N.current)||r.render(P.createElement("div",{ref:M,style:j,className:i,children:e}))});let W=P.useRef(!0);hC(e=>{if(D.current){T.updateMatrixWorld(),D.current.updateWorldMatrix(!0,!1);let e=c?O.current:x(D.current,T,A);if(c||Math.abs(U.current-T.zoom)>t||Math.abs(O.current[0]-e[0])>t||Math.abs(O.current[1]-e[1])>t){var n;let t,i,r,a,s=(n=D.current,t=dS.setFromMatrixPosition(n.matrixWorld),i=dM.setFromMatrixPosition(T.matrixWorld),r=t.sub(i),a=T.getWorldDirection(dw),r.angleTo(a)>Math.PI/2),o=!1;H&&(Array.isArray(h)?o=h.map(e=>e.current):"blending"!==h&&(o=[E]));let p=W.current;o?W.current=function(e,t,n,i){let r=dS.setFromMatrixPosition(e.matrixWorld),a=r.clone();a.project(t),dT.set(a.x,a.y),n.setFromCamera(dT,t);let s=n.intersectObjects(i,!0);if(s.length){let e=s[0].distance;return r.distanceTo(n.ray.origin)<e}return!0}(D.current,T,C,o)&&!s:W.current=!s,p!==W.current&&(d?d(!W.current):L.style.display=W.current?"block":"none");let f=Math.floor(v[0]/2),m=h?H?[v[0],f]:[f-1,0]:v;if(L.style.zIndex=`${function(e,t,n){if(t instanceof n6||t instanceof sG){let i=dS.setFromMatrixPosition(e.matrixWorld),r=dM.setFromMatrixPosition(t.matrixWorld),a=i.distanceTo(r),s=(n[1]-n[0])/(t.far-t.near),o=n[1]-s*t.far;return Math.round(s*a+o)}}(D.current,T,m)}`,c){let[e,t]=[A.width/2,A.height/2],n=T.projectionMatrix.elements[5]*t,{isOrthographicCamera:i,top:r,left:a,bottom:s,right:o}=T,c=dR(T.matrixWorldInverse),h=i?`scale(${n})translate(${dA(-(o+a)/2)}px,${dA((r+s)/2)}px)`:`translateZ(${n}px)`,d=D.current.matrixWorld;u&&((d=T.matrixWorldInverse.clone().transpose().copyPosition(d).scale(D.current.scale)).elements[3]=d.elements[7]=d.elements[11]=0,d.elements[15]=1),L.style.width=A.width+"px",L.style.height=A.height+"px",L.style.perspective=i?"":`${n}px`,F.current&&z.current&&(F.current.style.transform=`${h}${c}translate(${e}px,${t}px)`,z.current.style.transform=dP(d,1/((l||10)/400)))}else{let t=void 0===l?1:function(e,t){if(t instanceof sG)return t.zoom;if(!(t instanceof n6))return 1;{let n=dS.setFromMatrixPosition(e.matrixWorld),i=dM.setFromMatrixPosition(t.matrixWorld);return 1/(2*Math.tan(t.fov*Math.PI/180/2)*n.distanceTo(i))}}(D.current,T)*l;L.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}O.current=e,U.current=T.zoom}}if(!H&&B.current&&!V.current)if(c){if(F.current){let e=F.current.children[0];if(null!=e&&e.clientWidth&&null!=e&&e.clientHeight){let{isOrthographicCamera:t}=T;if(t||g)S.scale&&(Array.isArray(S.scale)?S.scale instanceof ez?B.current.scale.copy(S.scale.clone().divideScalar(1)):B.current.scale.set(1/S.scale[0],1/S.scale[1],1/S.scale[2]):B.current.scale.setScalar(1/S.scale));else{let t=(l||10)/400,n=e.clientWidth*t,i=e.clientHeight*t;B.current.scale.set(n,i,1)}V.current=!0}}}else{let t=L.children[0];if(null!=t&&t.clientWidth&&null!=t&&t.clientHeight){let e=1/I.factor,n=t.clientWidth*e,i=t.clientHeight*e;B.current.scale.set(n,i,1),V.current=!0}B.current.lookAt(e.camera.position)}});let X=P.useMemo(()=>({vertexShader:c?void 0:`
398
+ /*
399
+ This shader is from the THREE's SpriteMaterial.
400
+ We need to turn the backing plane into a Sprite
401
+ (make it always face the camera) if "transfrom"
402
+ is false.
403
+ */
404
+ #include <common>
405
+
406
+ void main() {
407
+ vec2 center = vec2(0., 1.);
408
+ float rotation = 0.0;
409
+
410
+ // This is somewhat arbitrary, but it seems to work well
411
+ // Need to figure out how to derive this dynamically if it even matters
412
+ float size = 0.03;
413
+
414
+ vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
415
+ vec2 scale;
416
+ scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
417
+ scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
418
+
419
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
420
+ if ( isPerspective ) scale *= - mvPosition.z;
421
+
422
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
423
+ vec2 rotatedPosition;
424
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
425
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
426
+ mvPosition.xy += rotatedPosition;
427
+
428
+ gl_Position = projectionMatrix * mvPosition;
429
+ }
430
+ `,fragmentShader:`
431
+ void main() {
432
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
433
+ }
434
+ `}),[c]);return P.createElement("group",dc({},S,{ref:D}),h&&!H&&P.createElement("mesh",{castShadow:p,receiveShadow:f,ref:B},g||P.createElement("planeGeometry",null),m||P.createElement("shaderMaterial",{side:2,vertexShader:X.vertexShader,fragmentShader:X.fragmentShader})))});var dL=e.i(33368);let dN=[{label:"All",hours:null},{label:"1h",hours:1},{label:"24h",hours:24},{label:"7d",hours:168},{label:"30d",hours:720}];function dD({memories:e,onTimeRangeChange:t,colorMode:n,onColorModeChange:i}){let[r,a]=(0,P.useState)(null),s=(0,P.useMemo)(()=>{if(!e.length)return[];let t=Date.now(),n=[{label:"<1h",max:36e5,count:0},{label:"1-24h",max:864e5,count:0},{label:"1-7d",max:6048e5,count:0},{label:"7-30d",max:2592e6,count:0},{label:">30d",max:1/0,count:0}];e.forEach(e=>{let i=t-new Date(e.createdAt).getTime();for(let e of n)if(i<e.max){e.count++;break}});let i=Math.max(...n.map(e=>e.count),1);return n.map(e=>({...e,height:e.count/i*100}))},[e]),o=(0,P.useMemo)(()=>{if(!e.length)return{oldest:null,newest:null};let t=e.map(e=>new Date(e.createdAt).getTime());return{oldest:new Date(Math.min(...t)),newest:new Date(Math.max(...t))}},[e]),l=(0,P.useCallback)((e,n)=>{if(a(n),null===e)t({start:null,end:null});else{let n=new Date;t({start:new Date(n.getTime()-60*e*6e4),end:n})}},[t]);return(0,R.jsxs)("div",{className:"absolute bottom-4 right-4 bg-slate-900/90 border border-slate-700 rounded-lg p-3 backdrop-blur-sm min-w-[200px]",children:[(0,R.jsxs)("div",{className:"mb-3",children:[(0,R.jsx)("div",{className:"text-xs text-slate-400 mb-1.5",children:"Color Mode"}),(0,R.jsx)("div",{className:"flex gap-1",children:[{value:"category",label:"Category",icon:"🎨"},{value:"health",label:"Health",icon:"💚"},{value:"age",label:"Age",icon:"⏰"},{value:"holographic",label:"Holo",icon:"✨"}].map(e=>(0,R.jsxs)("button",{onClick:()=>i(e.value),className:`flex-1 px-2 py-1 text-[10px] rounded transition-colors ${n===e.value?"holographic"===e.value?"bg-amber-500 text-white":"bg-blue-600 text-white":"bg-slate-800 text-slate-400 hover:bg-slate-700"}`,children:[(0,R.jsx)("span",{className:"mr-0.5",children:e.icon}),e.label]},e.value))})]}),(0,R.jsxs)("div",{className:"mb-3",children:[(0,R.jsx)("div",{className:"text-xs text-slate-400 mb-1.5",children:"Time Filter"}),(0,R.jsx)("div",{className:"flex gap-1",children:dN.map((e,t)=>(0,R.jsx)("button",{onClick:()=>l(e.hours,t),className:`flex-1 px-2 py-1 text-[10px] rounded transition-colors ${r===t?"bg-cyan-600 text-white":"bg-slate-800 text-slate-400 hover:bg-slate-700"}`,children:e.label},e.label))})]}),(0,R.jsxs)("div",{children:[(0,R.jsx)("div",{className:"text-xs text-slate-400 mb-1.5",children:"Age Distribution"}),(0,R.jsx)("div",{className:"flex items-end gap-0.5 h-8",children:s.map(e=>(0,R.jsx)("div",{className:"flex-1 flex flex-col items-center",children:(0,R.jsx)("div",{className:"w-full bg-gradient-to-t from-cyan-600 to-cyan-400 rounded-t transition-all",style:{height:`${Math.max(e.height,4)}%`},title:`${e.label}: ${e.count} memories`})},e.label))}),(0,R.jsx)("div",{className:"flex gap-0.5 mt-0.5",children:s.map(e=>(0,R.jsx)("div",{className:"flex-1 text-[8px] text-slate-500 text-center truncate",children:e.label},e.label))})]}),o.oldest&&o.newest&&(0,R.jsxs)("div",{className:"mt-2 pt-2 border-t border-slate-700 text-[9px] text-slate-500",children:[(0,R.jsxs)("div",{className:"flex justify-between",children:[(0,R.jsx)("span",{children:"Oldest:"}),(0,R.jsx)("span",{children:o.oldest.toLocaleDateString()})]}),(0,R.jsxs)("div",{className:"flex justify-between",children:[(0,R.jsx)("span",{children:"Newest:"}),(0,R.jsx)("span",{children:o.newest.toLocaleDateString()})]})]})]})}let dU=new aX(1,16,16),dO=new aG(1,1.15,24),dF=(0,P.memo)(function({memory:e,position:t,onSelect:n,isSelected:i,colorMode:r="category",opacity:a=1}){var s;let o,l=(0,P.useRef)(null),[u,c]=(0,P.useState)(!1),{camera:h}=hA(),d=(0,P.useMemo)(()=>(0,dL.calculateDecayFactor)(e),[e]),p=(0,P.useMemo)(()=>(0,U.getCategoryColor)(e.category),[e.category]),f=(0,P.useMemo)(()=>(function(e,t){let n=e*t;if(n>.6)return"#22c55e";if(n>.35){let e=(n-.35)/.25,t=Math.round(245-11*e),i=Math.round(158+21*e);return`rgb(${t}, ${i}, 66)`}{let e=Math.round(239),t=Math.round(68+n/.35*90);return`rgb(${e}, ${t}, 68)`}})(e.salience,d),[e.salience,d]),m=(0,P.useMemo)(()=>{var t;let n;return t=e.createdAt,(n=(Date.now()-new Date(t).getTime())/36e5)<1?"#22d3ee":n<24?"#22c55e":n<168?"#eab308":n<720?"#f97316":"#ef4444"},[e.createdAt]),g=(0,P.useMemo)(()=>{var t;return(t=e.salience)>.7?"#FFD700":t>.4?"#FFB347":"#FF8C00"},[e.salience]),v=(0,P.useMemo)(()=>{switch(r){case"health":return f;case"age":return m;case"holographic":return g;default:return p}},[r,f,m,g,p]),x=(0,P.useMemo)(()=>.2+.2*e.salience,[e.salience]),y=(0,P.useMemo)(()=>new a2({color:v,emissive:v,emissiveIntensity:.3,metalness:.2,roughness:.5,transparent:a<1,opacity:a}),[v,a]);return hC(()=>{l.current&&(l.current.material.emissiveIntensity=u?.8:.3)}),(0,R.jsxs)("group",{position:t,children:[(0,R.jsx)("mesh",{ref:l,geometry:dU,material:y,scale:x,onClick:t=>{t.stopPropagation(),n(e)},onPointerOver:e=>{e.stopPropagation(),c(!0),document.body.style.cursor="pointer"},onPointerOut:()=>{c(!1),document.body.style.cursor="default"}}),i&&(0,R.jsx)("mesh",{geometry:dO,rotation:[Math.PI/2,0,0],scale:x+.15,children:(0,R.jsx)("meshBasicMaterial",{color:"#ffffff",transparent:!0,opacity:.9,side:2})}),u&&!i&&(0,R.jsx)(dI,{distanceFactor:8,style:{pointerEvents:"none",transform:"translate(-50%, -120%)"},children:(0,R.jsxs)("div",{className:"bg-slate-900/95 border border-slate-700 px-3 py-2 rounded-lg shadow-xl backdrop-blur-sm whitespace-nowrap",children:[(0,R.jsx)("div",{className:"text-white font-medium text-sm",children:e.title}),(0,R.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-xs",children:[(0,R.jsx)("span",{className:"px-1.5 py-0.5 rounded",style:{backgroundColor:p+"30",color:p},children:e.category}),(0,R.jsxs)("span",{className:"text-slate-400",children:[(100*e.salience).toFixed(0),"%"]}),"health"===r&&(0,R.jsx)("span",{className:"px-1.5 py-0.5 rounded",style:{backgroundColor:f+"30",color:f},children:e.salience*d>.6?"Healthy":e.salience*d>.35?"Moderate":"At Risk"}),"age"===r&&(0,R.jsx)("span",{className:"px-1.5 py-0.5 rounded",style:{backgroundColor:m+"30",color:m},children:(s=e.createdAt,(o=(Date.now()-new Date(s).getTime())/36e5)<1?`${Math.round(60*o)}m ago`:o<24?`${Math.round(o)}h ago`:o<168?`${Math.round(o/24)}d ago`:o<720?`${Math.round(o/168)}w ago`:`${Math.round(o/720)}mo ago`)}),"holographic"===r&&(0,R.jsx)("span",{className:"px-1.5 py-0.5 rounded",style:{backgroundColor:g+"30",color:g},children:e.salience>.7?"High":e.salience>.4?"Medium":"Low"})]})]})})]})},(e,t)=>e.memory.id===t.memory.id&&e.memory.salience===t.memory.salience&&e.memory.category===t.memory.category&&e.isSelected===t.isSelected&&e.colorMode===t.colorMode&&e.opacity===t.opacity&&e.position[0]===t.position[0]&&e.position[1]===t.position[1]&&e.position[2]===t.position[2]),dz=new e9,dk=new ez;class dB extends sQ{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new nC([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new nC([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new oD(t,6,1);return this.setAttribute("instanceStart",new iu(n,3,0)),this.setAttribute("instanceEnd",new iu(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e,t=3){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));let i=new oD(n,2*t,1);return this.setAttribute("instanceColorStart",new iu(i,t,0)),this.setAttribute("instanceColorEnd",new iu(i,t,t)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new a$(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new e9);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),dz.setFromBufferAttribute(t),this.boundingBox.union(dz))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new tg),null===this.boundingBox&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)dk.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(dk)),dk.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(dk));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}let dV=parseInt("182".replace(/\D+/g,""));class dH extends n1{constructor(e){super({type:"LineMaterial",uniforms:n0.clone(n0.merge([lE.common,lE.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new eO(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:`
435
+ #include <common>
436
+ #include <fog_pars_vertex>
437
+ #include <logdepthbuf_pars_vertex>
438
+ #include <clipping_planes_pars_vertex>
439
+
440
+ uniform float linewidth;
441
+ uniform vec2 resolution;
442
+
443
+ attribute vec3 instanceStart;
444
+ attribute vec3 instanceEnd;
445
+
446
+ #ifdef USE_COLOR
447
+ #ifdef USE_LINE_COLOR_ALPHA
448
+ varying vec4 vLineColor;
449
+ attribute vec4 instanceColorStart;
450
+ attribute vec4 instanceColorEnd;
451
+ #else
452
+ varying vec3 vLineColor;
453
+ attribute vec3 instanceColorStart;
454
+ attribute vec3 instanceColorEnd;
455
+ #endif
456
+ #endif
457
+
458
+ #ifdef WORLD_UNITS
459
+
460
+ varying vec4 worldPos;
461
+ varying vec3 worldStart;
462
+ varying vec3 worldEnd;
463
+
464
+ #ifdef USE_DASH
465
+
466
+ varying vec2 vUv;
467
+
468
+ #endif
469
+
470
+ #else
471
+
472
+ varying vec2 vUv;
473
+
474
+ #endif
475
+
476
+ #ifdef USE_DASH
477
+
478
+ uniform float dashScale;
479
+ attribute float instanceDistanceStart;
480
+ attribute float instanceDistanceEnd;
481
+ varying float vLineDistance;
482
+
483
+ #endif
484
+
485
+ void trimSegment( const in vec4 start, inout vec4 end ) {
486
+
487
+ // trim end segment so it terminates between the camera plane and the near plane
488
+
489
+ // conservative estimate of the near plane
490
+ float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
491
+ float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
492
+ float nearEstimate = - 0.5 * b / a;
493
+
494
+ float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
495
+
496
+ end.xyz = mix( start.xyz, end.xyz, alpha );
497
+
498
+ }
499
+
500
+ void main() {
501
+
502
+ #ifdef USE_COLOR
503
+
504
+ vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
505
+
506
+ #endif
507
+
508
+ #ifdef USE_DASH
509
+
510
+ vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
511
+ vUv = uv;
512
+
513
+ #endif
514
+
515
+ float aspect = resolution.x / resolution.y;
516
+
517
+ // camera space
518
+ vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
519
+ vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
520
+
521
+ #ifdef WORLD_UNITS
522
+
523
+ worldStart = start.xyz;
524
+ worldEnd = end.xyz;
525
+
526
+ #else
527
+
528
+ vUv = uv;
529
+
530
+ #endif
531
+
532
+ // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
533
+ // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
534
+ // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
535
+ // perhaps there is a more elegant solution -- WestLangley
536
+
537
+ bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
538
+
539
+ if ( perspective ) {
540
+
541
+ if ( start.z < 0.0 && end.z >= 0.0 ) {
542
+
543
+ trimSegment( start, end );
544
+
545
+ } else if ( end.z < 0.0 && start.z >= 0.0 ) {
546
+
547
+ trimSegment( end, start );
548
+
549
+ }
550
+
551
+ }
552
+
553
+ // clip space
554
+ vec4 clipStart = projectionMatrix * start;
555
+ vec4 clipEnd = projectionMatrix * end;
556
+
557
+ // ndc space
558
+ vec3 ndcStart = clipStart.xyz / clipStart.w;
559
+ vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
560
+
561
+ // direction
562
+ vec2 dir = ndcEnd.xy - ndcStart.xy;
563
+
564
+ // account for clip-space aspect ratio
565
+ dir.x *= aspect;
566
+ dir = normalize( dir );
567
+
568
+ #ifdef WORLD_UNITS
569
+
570
+ // get the offset direction as perpendicular to the view vector
571
+ vec3 worldDir = normalize( end.xyz - start.xyz );
572
+ vec3 offset;
573
+ if ( position.y < 0.5 ) {
574
+
575
+ offset = normalize( cross( start.xyz, worldDir ) );
576
+
577
+ } else {
578
+
579
+ offset = normalize( cross( end.xyz, worldDir ) );
580
+
581
+ }
582
+
583
+ // sign flip
584
+ if ( position.x < 0.0 ) offset *= - 1.0;
585
+
586
+ float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
587
+
588
+ // don't extend the line if we're rendering dashes because we
589
+ // won't be rendering the endcaps
590
+ #ifndef USE_DASH
591
+
592
+ // extend the line bounds to encompass endcaps
593
+ start.xyz += - worldDir * linewidth * 0.5;
594
+ end.xyz += worldDir * linewidth * 0.5;
595
+
596
+ // shift the position of the quad so it hugs the forward edge of the line
597
+ offset.xy -= dir * forwardOffset;
598
+ offset.z += 0.5;
599
+
600
+ #endif
601
+
602
+ // endcaps
603
+ if ( position.y > 1.0 || position.y < 0.0 ) {
604
+
605
+ offset.xy += dir * 2.0 * forwardOffset;
606
+
607
+ }
608
+
609
+ // adjust for linewidth
610
+ offset *= linewidth * 0.5;
611
+
612
+ // set the world position
613
+ worldPos = ( position.y < 0.5 ) ? start : end;
614
+ worldPos.xyz += offset;
615
+
616
+ // project the worldpos
617
+ vec4 clip = projectionMatrix * worldPos;
618
+
619
+ // shift the depth of the projected points so the line
620
+ // segments overlap neatly
621
+ vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
622
+ clip.z = clipPose.z * clip.w;
623
+
624
+ #else
625
+
626
+ vec2 offset = vec2( dir.y, - dir.x );
627
+ // undo aspect ratio adjustment
628
+ dir.x /= aspect;
629
+ offset.x /= aspect;
630
+
631
+ // sign flip
632
+ if ( position.x < 0.0 ) offset *= - 1.0;
633
+
634
+ // endcaps
635
+ if ( position.y < 0.0 ) {
636
+
637
+ offset += - dir;
638
+
639
+ } else if ( position.y > 1.0 ) {
640
+
641
+ offset += dir;
642
+
643
+ }
644
+
645
+ // adjust for linewidth
646
+ offset *= linewidth;
647
+
648
+ // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
649
+ offset /= resolution.y;
650
+
651
+ // select end
652
+ vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
653
+
654
+ // back to clip space
655
+ offset *= clip.w;
656
+
657
+ clip.xy += offset;
658
+
659
+ #endif
660
+
661
+ gl_Position = clip;
662
+
663
+ vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
664
+
665
+ #include <logdepthbuf_vertex>
666
+ #include <clipping_planes_vertex>
667
+ #include <fog_vertex>
668
+
669
+ }
670
+ `,fragmentShader:`
671
+ uniform vec3 diffuse;
672
+ uniform float opacity;
673
+ uniform float linewidth;
674
+
675
+ #ifdef USE_DASH
676
+
677
+ uniform float dashOffset;
678
+ uniform float dashSize;
679
+ uniform float gapSize;
680
+
681
+ #endif
682
+
683
+ varying float vLineDistance;
684
+
685
+ #ifdef WORLD_UNITS
686
+
687
+ varying vec4 worldPos;
688
+ varying vec3 worldStart;
689
+ varying vec3 worldEnd;
690
+
691
+ #ifdef USE_DASH
692
+
693
+ varying vec2 vUv;
694
+
695
+ #endif
696
+
697
+ #else
698
+
699
+ varying vec2 vUv;
700
+
701
+ #endif
702
+
703
+ #include <common>
704
+ #include <fog_pars_fragment>
705
+ #include <logdepthbuf_pars_fragment>
706
+ #include <clipping_planes_pars_fragment>
707
+
708
+ #ifdef USE_COLOR
709
+ #ifdef USE_LINE_COLOR_ALPHA
710
+ varying vec4 vLineColor;
711
+ #else
712
+ varying vec3 vLineColor;
713
+ #endif
714
+ #endif
715
+
716
+ vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
717
+
718
+ float mua;
719
+ float mub;
720
+
721
+ vec3 p13 = p1 - p3;
722
+ vec3 p43 = p4 - p3;
723
+
724
+ vec3 p21 = p2 - p1;
725
+
726
+ float d1343 = dot( p13, p43 );
727
+ float d4321 = dot( p43, p21 );
728
+ float d1321 = dot( p13, p21 );
729
+ float d4343 = dot( p43, p43 );
730
+ float d2121 = dot( p21, p21 );
731
+
732
+ float denom = d2121 * d4343 - d4321 * d4321;
733
+
734
+ float numer = d1343 * d4321 - d1321 * d4343;
735
+
736
+ mua = numer / denom;
737
+ mua = clamp( mua, 0.0, 1.0 );
738
+ mub = ( d1343 + d4321 * ( mua ) ) / d4343;
739
+ mub = clamp( mub, 0.0, 1.0 );
740
+
741
+ return vec2( mua, mub );
742
+
743
+ }
744
+
745
+ void main() {
746
+
747
+ #include <clipping_planes_fragment>
748
+
749
+ #ifdef USE_DASH
750
+
751
+ if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
752
+
753
+ if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
754
+
755
+ #endif
756
+
757
+ float alpha = opacity;
758
+
759
+ #ifdef WORLD_UNITS
760
+
761
+ // Find the closest points on the view ray and the line segment
762
+ vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
763
+ vec3 lineDir = worldEnd - worldStart;
764
+ vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
765
+
766
+ vec3 p1 = worldStart + lineDir * params.x;
767
+ vec3 p2 = rayEnd * params.y;
768
+ vec3 delta = p1 - p2;
769
+ float len = length( delta );
770
+ float norm = len / linewidth;
771
+
772
+ #ifndef USE_DASH
773
+
774
+ #ifdef USE_ALPHA_TO_COVERAGE
775
+
776
+ float dnorm = fwidth( norm );
777
+ alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
778
+
779
+ #else
780
+
781
+ if ( norm > 0.5 ) {
782
+
783
+ discard;
784
+
785
+ }
786
+
787
+ #endif
788
+
789
+ #endif
790
+
791
+ #else
792
+
793
+ #ifdef USE_ALPHA_TO_COVERAGE
794
+
795
+ // artifacts appear on some hardware if a derivative is taken within a conditional
796
+ float a = vUv.x;
797
+ float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
798
+ float len2 = a * a + b * b;
799
+ float dlen = fwidth( len2 );
800
+
801
+ if ( abs( vUv.y ) > 1.0 ) {
802
+
803
+ alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
804
+
805
+ }
806
+
807
+ #else
808
+
809
+ if ( abs( vUv.y ) > 1.0 ) {
810
+
811
+ float a = vUv.x;
812
+ float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
813
+ float len2 = a * a + b * b;
814
+
815
+ if ( len2 > 1.0 ) discard;
816
+
817
+ }
818
+
819
+ #endif
820
+
821
+ #endif
822
+
823
+ vec4 diffuseColor = vec4( diffuse, alpha );
824
+ #ifdef USE_COLOR
825
+ #ifdef USE_LINE_COLOR_ALPHA
826
+ diffuseColor *= vLineColor;
827
+ #else
828
+ diffuseColor.rgb *= vLineColor;
829
+ #endif
830
+ #endif
831
+
832
+ #include <logdepthbuf_fragment>
833
+
834
+ gl_FragColor = diffuseColor;
835
+
836
+ #include <tonemapping_fragment>
837
+ #include <${dV>=154?"colorspace_fragment":"encodings_fragment"}>
838
+ #include <fog_fragment>
839
+ #include <premultiplied_alpha_fragment>
840
+
841
+ }
842
+ `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){!0===e?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(e){!!e!="USE_DASH"in this.defines&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(e){!!e!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),!0===e?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}let dj=dV>=125?"uv1":"uv2",dG=new e1,dW=new ez,dX=new ez,dq=new e1,dY=new e1,dZ=new e1,dJ=new ez,d$=new tT,dK=new o0,dQ=new ez,d0=new e9,d1=new tg,d2=new e1;function d3(e,t,n){return d2.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),d2.multiplyScalar(1/d2.w),d2.x=d/n.width,d2.y=d/n.height,d2.applyMatrix4(e.projectionMatrixInverse),d2.multiplyScalar(1/d2.w),Math.abs(Math.max(d2.x,d2.y))}class d4 extends nY{constructor(e=new dB,t=new dH({color:0xffffff*Math.random()})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let e=0,r=0,a=t.count;e<a;e++,r+=2)dW.fromBufferAttribute(t,e),dX.fromBufferAttribute(n,e),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+dW.distanceTo(dX);let r=new oD(i,2,1);return e.setAttribute("instanceDistanceStart",new iu(r,1,0)),e.setAttribute("instanceDistanceEnd",new iu(r,1,1)),this}raycast(e,t){let n,i,r=this.material.worldUnits,a=e.camera;null!==a||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');let s=void 0!==e.params.Line2&&e.params.Line2.threshold||0;h=e.ray;let o=this.matrixWorld,l=this.geometry,u=this.material;if(d=u.linewidth+s,null===l.boundingSphere&&l.computeBoundingSphere(),d1.copy(l.boundingSphere).applyMatrix4(o),r)n=.5*d;else{let e=Math.max(a.near,d1.distanceToPoint(h.origin));n=d3(a,e,u.resolution)}if(d1.radius+=n,!1!==h.intersectsSphere(d1)){if(null===l.boundingBox&&l.computeBoundingBox(),d0.copy(l.boundingBox).applyMatrix4(o),r)i=.5*d;else{let e=Math.max(a.near,d0.distanceToPoint(h.origin));i=d3(a,e,u.resolution)}d0.expandByScalar(i),!1!==h.intersectsBox(d0)&&(r?function(e,t){let n=e.matrixWorld,i=e.geometry,r=i.attributes.instanceStart,a=i.attributes.instanceEnd,s=Math.min(i.instanceCount,r.count);for(let i=0;i<s;i++){dK.start.fromBufferAttribute(r,i),dK.end.fromBufferAttribute(a,i),dK.applyMatrix4(n);let s=new ez,o=new ez;h.distanceSqToSegment(dK.start,dK.end,o,s),o.distanceTo(s)<.5*d&&t.push({point:o,pointOnLine:s,distance:h.origin.distanceTo(o),object:e,face:null,faceIndex:i,uv:null,[dj]:null})}}(this,t):function(e,t,n){let i=t.projectionMatrix,r=e.material.resolution,a=e.matrixWorld,s=e.geometry,o=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,o.count),c=-t.near;h.at(1,dZ),dZ.w=1,dZ.applyMatrix4(t.matrixWorldInverse),dZ.applyMatrix4(i),dZ.multiplyScalar(1/dZ.w),dZ.x*=r.x/2,dZ.y*=r.y/2,dZ.z=0,dJ.copy(dZ),d$.multiplyMatrices(t.matrixWorldInverse,a);for(let t=0;t<u;t++){if(dq.fromBufferAttribute(o,t),dY.fromBufferAttribute(l,t),dq.w=1,dY.w=1,dq.applyMatrix4(d$),dY.applyMatrix4(d$),dq.z>c&&dY.z>c)continue;if(dq.z>c){let e=dq.z-dY.z,t=(dq.z-c)/e;dq.lerp(dY,t)}else if(dY.z>c){let e=dY.z-dq.z,t=(dY.z-c)/e;dY.lerp(dq,t)}dq.applyMatrix4(i),dY.applyMatrix4(i),dq.multiplyScalar(1/dq.w),dY.multiplyScalar(1/dY.w),dq.x*=r.x/2,dq.y*=r.y/2,dY.x*=r.x/2,dY.y*=r.y/2,dK.start.copy(dq),dK.start.z=0,dK.end.copy(dY),dK.end.z=0;let s=dK.closestPointToPointParameter(dJ,!0);dK.at(s,dQ);let u=eU.lerp(dq.z,dY.z,s),p=u>=-1&&u<=1,f=dJ.distanceTo(dQ)<.5*d;if(p&&f){dK.start.fromBufferAttribute(o,t),dK.end.fromBufferAttribute(l,t),dK.start.applyMatrix4(a),dK.end.applyMatrix4(a);let i=new ez,r=new ez;h.distanceSqToSegment(dK.start,dK.end,r,i),n.push({point:r,pointOnLine:i,distance:h.origin.distanceTo(r),object:e,face:null,faceIndex:t,uv:null,[dj]:null})}}}(this,a,t))}}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(dG),this.material.uniforms.resolution.value.set(dG.z,dG.w))}}class d5 extends dB{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setPositions(n),this}setColors(e,t=3){let n=e.length-t,i=new Float32Array(2*n);if(3===t)for(let r=0;r<n;r+=t)i[2*r]=e[r],i[2*r+1]=e[r+1],i[2*r+2]=e[r+2],i[2*r+3]=e[r+3],i[2*r+4]=e[r+4],i[2*r+5]=e[r+5];else for(let r=0;r<n;r+=t)i[2*r]=e[r],i[2*r+1]=e[r+1],i[2*r+2]=e[r+2],i[2*r+3]=e[r+3],i[2*r+4]=e[r+4],i[2*r+5]=e[r+5],i[2*r+6]=e[r+6],i[2*r+7]=e[r+7];return super.setColors(i,t),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class d6 extends d4{constructor(e=new d5,t=new dH({color:0xffffff*Math.random()})){super(e,t),this.isLine2=!0,this.type="Line2"}}let d8=P.forwardRef(function({points:e,color:t=0xffffff,vertexColors:n,linewidth:i,lineWidth:r,segments:a,dashed:s,...o},l){var u,c;let h=hA(e=>e.size),d=P.useMemo(()=>a?new d4:new d6,[a]),[p]=P.useState(()=>new dH),f=(null==n||null==(u=n[0])?void 0:u.length)===4?4:3,m=P.useMemo(()=>{let i=a?new dB:new d5,r=e.map(e=>{let t=Array.isArray(e);return e instanceof ez||e instanceof e1?[e.x,e.y,e.z]:e instanceof eO?[e.x,e.y,0]:t&&3===e.length?[e[0],e[1],e[2]]:t&&2===e.length?[e[0],e[1],0]:e});if(i.setPositions(r.flat()),n){t=0xffffff;let e=n.map(e=>e instanceof no?e.toArray():e);i.setColors(e.flat(),f)}return i},[e,a,n,f]);return P.useLayoutEffect(()=>{d.computeLineDistances()},[e,d]),P.useLayoutEffect(()=>{s?p.defines.USE_DASH="":delete p.defines.USE_DASH,p.needsUpdate=!0},[s,p]),P.useEffect(()=>()=>{m.dispose(),p.dispose()},[m]),P.createElement("primitive",dc({object:d,ref:l},o),P.createElement("primitive",{object:m,attach:"geometry"}),P.createElement("primitive",dc({object:p,attach:"material",color:t,vertexColors:!!n,resolution:[h.width,h.height],linewidth:null!=(c=null!=i?i:r)?c:1,dashed:s,transparent:4===f},o)))}),d9=P.forwardRef(function({points:e,closed:t=!1,curveType:n="centripetal",tension:i=.5,segments:r=20,vertexColors:a,...s},o){let l=P.useMemo(()=>new ai(e.map(e=>e instanceof ez?e:new ez(...e)),t,n,i),[e,t,n,i]),u=P.useMemo(()=>l.getPoints(r),[l,r]),c=P.useMemo(()=>{if(!a||a.length<2)return;if(a.length===r+1)return a;let e=a.map(e=>e instanceof no?e:new no(...e));t&&e.push(e[0].clone());let n=[e[0]],i=r/(e.length-1);for(let t=1;t<r;t++){let r=t%i/i,a=Math.floor(t/i);n.push(e[a].clone().lerp(e[a+1],r))}return n.push(e[e.length-1]),n},[a,r]);return P.createElement(d8,dc({ref:o,points:u,vertexColors:c},s))}),d7={references:{color:"#22d3ee",label:"References"},extends:{color:"#34d399",label:"Extends"},contradicts:{color:"#f87171",label:"Contradicts"},related:{color:"#a78bfa",label:"Related"}},pe=d7.related,pt="#22d3ee";function pn({curve:e,speed:t=1,delay:n=0}){let i=(0,P.useRef)(null),r=(0,P.useRef)(null),a=(0,P.useRef)(n);return hC((n,s)=>{if(!i.current)return;a.current+=s*t*1.2,a.current>1&&(a.current=0);let o=e.getPoint(a.current);i.current.position.copy(o);let l=Math.min(5*a.current,1)*Math.min((1-a.current)*5,1);i.current.material.opacity=l,r.current&&(r.current.position.copy(o),r.current.material.opacity=.25*l)}),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)("mesh",{ref:i,children:[(0,R.jsx)("sphereGeometry",{args:[.04,8,8]}),(0,R.jsx)("meshBasicMaterial",{color:pt,transparent:!0,opacity:1})]}),(0,R.jsxs)("mesh",{ref:r,children:[(0,R.jsx)("sphereGeometry",{args:[.08,6,6]}),(0,R.jsx)("meshBasicMaterial",{color:pt,transparent:!0,opacity:.2,depthWrite:!1})]})]})}function pi({link:e,sourcePos:t,targetPos:n,isHovered:i,onHover:r,onUnhover:a}){let s=d7[e.relationship]||pe,{curve:o,points:l}=(0,P.useMemo)(()=>{let i=new ez(t.x,t.y,t.z),r=new ez(n.x,n.y,n.z),a=new ez().lerpVectors(i,r,.5),s=new ez().subVectors(r,i),o=s.length(),l=new ez(-s.y,s.x,.5*s.z).normalize(),u=.15*o*(e.strength+.5),c=new ez().lerpVectors(i,a,.33);c.add(l.clone().multiplyScalar(u));let h=new ez().lerpVectors(i,a,.66);h.add(l.clone().multiplyScalar(.5*u));let d=new ez().lerpVectors(a,r,.33);d.add(l.clone().multiplyScalar(-(.5*u)));let p=new ez().lerpVectors(a,r,.66);p.add(l.clone().multiplyScalar(-u));let f=new ai([i,c,h,a,d,p,r]),m=f.getPoints(32);return{curve:f,points:m}},[t,n,e.strength]),u=s.color,c=i?4:1.5+2*e.strength;return(0,R.jsxs)("group",{children:[(0,R.jsx)(d9,{points:l,color:u,lineWidth:c,transparent:!0,opacity:i?1:.35}),(0,R.jsx)(pn,{curve:o,speed:1.2+e.strength,delay:0}),(0,R.jsx)(pn,{curve:o,speed:1.2+e.strength,delay:.5}),e.strength>.3&&(0,R.jsx)(pn,{curve:o,speed:1.5+e.strength,delay:.25}),e.strength>.6&&(0,R.jsx)(pn,{curve:o,speed:1.8+e.strength,delay:.75}),(0,R.jsxs)("mesh",{position:[(t.x+n.x)/2,(t.y+n.y)/2,(t.z+n.z)/2],onPointerEnter:r,onPointerLeave:a,children:[(0,R.jsx)("sphereGeometry",{args:[.5,8,8]}),(0,R.jsx)("meshBasicMaterial",{visible:!1})]}),i&&(0,R.jsx)(dI,{position:[(t.x+n.x)/2,(t.y+n.y)/2+.5,(t.z+n.z)/2],center:!0,style:{pointerEvents:"none"},children:(0,R.jsxs)("div",{className:"px-3 py-2 rounded-lg shadow-xl text-xs whitespace-nowrap backdrop-blur-sm",style:{backgroundColor:"rgba(15, 23, 42, 0.95)",border:`2px solid ${s.color}`,color:"white"},children:[(0,R.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,R.jsx)("span",{className:"w-2 h-2 rounded-full animate-pulse",style:{backgroundColor:s.color}}),(0,R.jsx)("span",{className:"font-semibold",style:{color:s.color},children:s.label})]}),(0,R.jsxs)("div",{className:"text-slate-300 text-[10px] space-y-0.5",children:[(0,R.jsx)("div",{className:"truncate max-w-[180px]",children:e.source_title||`Memory #${e.source_id}`}),(0,R.jsx)("div",{className:"text-slate-500",children:"↓"}),(0,R.jsx)("div",{className:"truncate max-w-[180px]",children:e.target_title||`Memory #${e.target_id}`}),(0,R.jsxs)("div",{className:"mt-1 pt-1 border-t border-slate-700",children:["Strength: ",(0,R.jsxs)("span",{style:{color:s.color},children:[(100*e.strength).toFixed(0),"%"]})]})]})]})})]})}function pr({memories:e,links:t,memoryPositions:n}){let[i,r]=(0,P.useState)(null),a=(0,P.useMemo)(()=>{let i=new Set(e.map(e=>e.id));return t.filter(e=>i.has(e.source_id)&&i.has(e.target_id)&&n.has(e.source_id)&&n.has(e.target_id))},[e,t,n]),s=(0,P.useCallback)(e=>{r(e)},[]),o=(0,P.useCallback)(()=>{r(null)},[]);return 0===a.length?null:(0,R.jsx)("group",{name:"neural-connections",children:a.map(e=>{let t=n.get(e.source_id),r=n.get(e.target_id),a=`${e.source_id}-${e.target_id}`;return(0,R.jsx)(pi,{link:e,sourcePos:t,targetPos:r,isHovered:i===a,onHover:()=>s(a),onUnhover:o},a)})})}let pa=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],ps=new Uint8Array(512),po=new Uint8Array(512);!function(e=0){let t=new Uint8Array(256);for(let e=0;e<256;e++)t[e]=e;let n=e;for(let e=255;e>0;e--){let i=(n=0x41c64e6d*n+12345&0x7fffffff)%(e+1);[t[e],t[i]]=[t[i],t[e]]}for(let e=0;e<512;e++)ps[e]=t[255&e],po[e]=ps[e]%12}(42);let pl=1/3,pu=1/6;function pc(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}function ph(e,t,n){let i,r,a,s,o,l,u=(e+t+n)*pl,c=Math.floor(e+u),h=Math.floor(t+u),d=Math.floor(n+u),p=(c+h+d)*pu,f=e-(c-p),m=t-(h-p),g=n-(d-p);f>=m?m>=g?(i=1,r=0,a=0,s=1,o=1,l=0):(f>=g?(i=1,r=0,a=0):(i=0,r=0,a=1),s=1,o=0,l=1):m<g?(i=0,r=0,a=1,s=0,o=1,l=1):f<g?(i=0,r=1,a=0,s=0,o=1,l=1):(i=0,r=1,a=0,s=1,o=1,l=0);let v=f-i+pu,x=m-r+pu,y=g-a+pu,_=f-s+2*pu,b=m-o+2*pu,S=g-l+2*pu,M=f-1+3*pu,w=m-1+3*pu,T=g-1+3*pu,E=255&c,A=255&h,C=255&d,R=0,P=0,I=0,L=0,N=.6-f*f-m*m-g*g;if(N>=0){let e=po[E+ps[A+ps[C]]];N*=N,R=N*N*pc(pa[e],f,m,g)}let D=.6-v*v-x*x-y*y;if(D>=0){let e=po[E+i+ps[A+r+ps[C+a]]];D*=D,P=D*D*pc(pa[e],v,x,y)}let U=.6-_*_-b*b-S*S;if(U>=0){let e=po[E+s+ps[A+o+ps[C+l]]];U*=U,I=U*U*pc(pa[e],_,b,S)}let O=.6-M*M-w*w-T*T;if(O>=0){let e=po[E+1+ps[A+1+ps[C+1]]];O*=O,L=O*O*pc(pa[e],M,w,T)}return 32*(R+P+I+L)}function pd(e,t,n,i=4,r=2,a=.5){let s=0,o=1,l=1,u=0;for(let c=0;c<i;c++)s+=o*ph(e*l,t*l,n*l),u+=o,o*=a,l*=r;return s/u}function pp({opacity:e=.05,showWireframe:t=!0}){let n=(0,P.useRef)(null),i=(0,P.useRef)(null),r=(0,P.useMemo)(()=>{let e=function(){let e=new aB(3.5,5),t=e.attributes.position.array,n=new Float32Array(t.length);for(let e=0;e<t.length;e+=3){let i=t[e],r=t[e+1],a=t[e+2],s=Math.sqrt(i*i+r*r+a*a),o=i/s,l=r/s,u=a/s,c=.4*pd(2*o,2*l,2*u,3,2,.5)+.15*pd(4*o,4*l,4*u,2,2,.5)+.5*(.08*function(e,t,n,i=4,r=2,a=.5){let s=0,o=1,l=1,u=1;for(let c=0;c<i;c++){let i=ph(e*l,t*l,n*l);i=1-Math.abs(i),i*=i*u,u=Math.min(1,Math.max(0,2*i)),s+=i*o,o*=a,l*=r}return s}(6*o,6*l,6*u,2,2,.5)),h=1.2+.15*Math.abs(u),d=.85+.1*Math.abs(o),p=1.1-.1*Math.abs(l),f=s*(1+c+(.1>Math.abs(o)?-.15*(1-Math.abs(o)/.1):0)+.15*(Math.abs(o)>.5&&u<0));t[e]=o*f*h,t[e+1]=l*f*d,t[e+2]=u*f*p;let m=(u+1)/2;n[e]=.1+.2*m,n[e+1]=.05+(1-m)*.15,n[e+2]=.2+(1-m)*.3}return e.computeVertexNormals(),e.setAttribute("color",new ny(n,3)),e}();return n.current=e,e},[]),a=(0,P.useMemo)(()=>{let t=new nh({color:"#333333",wireframe:!0,transparent:!0,opacity:e});return i.current=t,t},[e]);return((0,P.useEffect)(()=>()=>{n.current&&(n.current.dispose(),n.current=null),i.current&&(i.current.dispose(),i.current=null)},[]),t)?(0,R.jsx)("mesh",{geometry:r,material:a}):null}let pf=new aG(.1,.15,32),pm=new aX(.1,16,16);function pg({pulse:e,onComplete:t}){let n=(0,P.useRef)(null),i=(0,P.useRef)(null);return hC(r=>{if(!n.current)return;null===i.current&&(i.current=r.clock.elapsedTime);let a=(r.clock.elapsedTime-i.current)/(e.duration/1e3);a>=1?t():(n.current.scale.setScalar(.5+3*a),n.current.material.opacity=(1-a)*.8)}),(0,R.jsx)("mesh",{ref:n,position:e.position,rotation:[Math.PI/2,0,0],geometry:pf,children:(0,R.jsx)("meshBasicMaterial",{color:e.color,transparent:!0,opacity:.8,side:2,depthWrite:!1})})}function pv({pulse:e,onComplete:t}){let n=(0,P.useRef)(null),i=(0,P.useRef)(null);return hC(r=>{if(!n.current)return;null===i.current&&(i.current=r.clock.elapsedTime);let a=(r.clock.elapsedTime-i.current)/(e.duration/1e3);if(a>=1)return void t();let s=Math.sin(a*Math.PI);n.current.scale.setScalar(.8+.6*s),n.current.material.opacity=.9*s}),(0,R.jsx)("mesh",{ref:n,position:e.position,geometry:pm,children:(0,R.jsx)("meshBasicMaterial",{color:e.color,transparent:!0,opacity:.9,depthWrite:!1})})}function px({pulse:e,onComplete:t}){let n=(0,P.useRef)(null),i=(0,P.useRef)(null),r=(0,P.useRef)(null),a=(0,P.useMemo)(()=>{let t=[new ez(...e.position),new ez(...e.targetPosition||e.position)];return new rT(new nO().setFromPoints(t),new rv({color:e.color,transparent:!0,opacity:.8}))},[e.position,e.targetPosition,e.color]);return hC(s=>{if(!r.current){n.current&&!n.current.children.length&&(n.current.add(a),r.current=a);return}null===i.current&&(i.current=s.clock.elapsedTime);let o=(s.clock.elapsedTime-i.current)/(e.duration/1e3);if(o>=1)return void t();let l=Math.sin(o*Math.PI);r.current.material.opacity=.8*l}),(0,R.jsx)("group",{ref:n})}function py({pulses:e,onPulseComplete:t}){return(0,R.jsx)("group",{name:"activity-pulses",children:e.map(e=>{switch(e.type){case"created":return(0,R.jsx)(pg,{pulse:e,onComplete:()=>t(e.id)},e.id);case"accessed":return(0,R.jsx)(pv,{pulse:e,onComplete:()=>t(e.id)},e.id);case"linked":return(0,R.jsx)(px,{pulse:e,onComplete:()=>t(e.id)},e.id);default:return null}})})}var p_=e.i(94156);function pb({memories:e=[],links:t=[],selectedMemory:n,onSelectMemory:i,colorMode:r,pulses:a,onPulseComplete:s,memoryCategoryCounts:o,categoryFilter:l}){let u=(0,P.useMemo)(()=>e&&0!==e.length?Array.from(new Map(e.map(e=>[e.id,e])).values()).map(e=>({memory:e,position:(0,dL.calculateMemoryPosition)(e)})):[],[e]),c=(0,P.useMemo)(()=>{let e=new Map;return u.forEach(({memory:t,position:n})=>{e.set(t.id,n)}),e},[u]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)("ambientLight",{intensity:.6,color:"#ffffff"}),(0,R.jsx)("directionalLight",{position:[5,5,5],intensity:.3,color:"#ffffff"}),(0,R.jsx)(pp,{opacity:.05,showWireframe:!0,pulseIntensity:0}),(0,R.jsx)(pr,{memories:e,links:t,memoryPositions:c}),u.map(({memory:e,position:t})=>(0,R.jsx)(dF,{memory:e,position:[t.x,t.y,t.z],onSelect:i,isSelected:n?.id===e.id,colorMode:r,opacity:l&&e.category!==l?.1:1},e.id)),(0,R.jsx)(py,{pulses:a,onPulseComplete:s}),(0,R.jsx)(d_,{enablePan:!0,enableZoom:!0,enableRotate:!0,minDistance:5,maxDistance:25,autoRotate:!1,dampingFactor:.05,enableDamping:!0})]})}function pS({memories:e=[],links:t=[],selectedMemory:n,onSelectMemory:i,categoryFilter:r}){let[a,s]=(0,P.useState)("category"),[o,l]=(0,P.useState)([]),[u,c]=(0,P.useState)({start:null,end:null}),h={current:0},d=(0,P.useMemo)(()=>{let t={};return e.forEach(e=>{t[e.category]=(t[e.category]||0)+1}),t},[e]),p=(0,P.useMemo)(()=>u.start||u.end?e.filter(e=>{let t=new Date(e.createdAt).getTime();return!(u.start&&t<u.start.getTime()||u.end&&t>u.end.getTime())}):e,[e,u]),f=(0,P.useMemo)(()=>{let t=new Map;return e.forEach(e=>{t.set(e.id,(0,dL.calculateMemoryPosition)(e))}),t},[e]),m=(0,P.useCallback)((e,t,n)=>{let i=f.get(t);if(!i)return;let r=n?f.get(n):void 0,a={id:h.current++,type:e,position:[i.x,i.y,i.z],targetPosition:r?[r.x,r.y,r.z]:void 0,startTime:Date.now(),duration:"created"===e?2e3:"accessed"===e?1e3:1500,color:"created"===e?"#22c55e":"accessed"===e?"#3b82f6":"#a855f7"};l(e=>[...e,a])},[f]),g=(0,P.useCallback)(e=>{l(t=>t.filter(t=>t.id!==e))},[]);return(0,p_.useMemoryWebSocket)({onMessage:e=>{let t=e.data;switch(e.type){case"memory_created":t?.memoryId&&m("created",t.memoryId);break;case"memory_accessed":t?.memoryId&&m("accessed",t.memoryId);break;case"link_discovered":t?.sourceId&&t?.targetId&&m("linked",t.sourceId,t.targetId)}}}),(0,R.jsxs)("div",{className:"w-full h-full bg-slate-950",children:[(0,R.jsx)(du,{camera:{position:[0,2,12],fov:55},gl:{antialias:!0,alpha:!0},onPointerMissed:()=>i(null),children:(0,R.jsx)(P.Suspense,{fallback:null,children:(0,R.jsx)(pb,{memories:p,links:t,selectedMemory:n,onSelectMemory:i,colorMode:a,pulses:o,onPulseComplete:g,memoryCategoryCounts:d,categoryFilter:r})})}),(0,R.jsx)(dD,{memories:e,onTimeRangeChange:c,colorMode:a,onColorModeChange:s})]})}function pM({memories:e,links:t,stats:n,isLoading:i}){let{selectedMemory:r,setSelectedMemory:a,recentEvents:s,showLeftSidebar:o,showRightSidebar:l,toggleLeftSidebar:u,toggleRightSidebar:c,projectFilter:h}=(0,I.useDashboardStore)(),[d,p]=(0,P.useState)(null),[f,m]=(0,P.useState)(!1),{data:g}=(0,L.useContradictions)(h||void 0),{data:v}=(0,N.useQuarantine)("pending",50,h||void 0),{data:x}=(0,L.useWorkerStatus)(),y=(0,L.useConsolidate)(),_=(0,L.useBoostMemory)(),b=(0,L.useDemoteMemory)(),S=(0,L.usePromoteMemory)(),M=(0,L.useDeleteMemory)(),w=(0,L.useQuarantineMemory)(),T=(0,L.useEditMemory)(),E=g?.count??0,A=v?.total??0,C=x?.lastMediumTick??x?.lastLightTick??null,U=(0,P.useCallback)(e=>{a(e)},[a]),O=(0,P.useCallback)(t=>{let n=e.find(e=>e.id===t);n&&a(n)},[e,a]),F=(0,P.useCallback)(e=>_.mutate(e),[_]),k=(0,P.useCallback)(e=>b.mutate(e),[b]),B=(0,P.useCallback)(e=>S.mutate(e),[S]),V=(0,P.useCallback)(e=>{M.mutate(e),a(null)},[M,a]),H=(0,P.useCallback)(e=>{w.mutate({id:e,reason:"Quarantined from Brain Control Centre"}),a(null)},[w,a]),G=(0,P.useCallback)((e,t)=>{T.mutate({id:e,updates:t})},[T]),W=(0,P.useCallback)(()=>{y.mutate()},[y]),X=(0,P.useCallback)(e=>{e?.memoryId?O(e.memoryId):e?.id&&O(e.id)},[O]),q=r?t.filter(e=>e.source_id===r.id||e.target_id===r.id):[];return i?(0,R.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-slate-950",children:(0,R.jsx)("div",{className:"text-slate-400 animate-pulse",children:"Loading Brain..."})}):(0,R.jsxs)("div",{className:"w-full h-full flex flex-col bg-slate-950 relative",children:[(0,R.jsx)(D,{stats:n??{total:0,shortTerm:0,longTerm:0,episodic:0,byCategory:{},averageSalience:0},contradictionCount:E,quarantineCount:A,lastConsolidation:C,workerStatus:x}),(0,R.jsxs)("div",{className:"flex-1 flex overflow-hidden relative",children:[o&&(0,R.jsx)(z,{stats:n??{total:0,shortTerm:0,longTerm:0,episodic:0,byCategory:{},averageSalience:0},memories:e,onCategoryClick:p,activeCategory:d,onConsolidate:W,isConsolidating:y.isPending,workerStatus:x}),(0,R.jsxs)("div",{className:"flex-1 flex flex-col relative",children:[(0,R.jsx)("div",{className:"flex-1 relative",children:(0,R.jsx)(pS,{memories:e,links:t,selectedMemory:r,onSelectMemory:U,categoryFilter:d})}),(0,R.jsx)(Z,{events:s,onClickEvent:X,isCollapsed:f,onToggleCollapse:()=>m(!f)})]}),l&&(0,R.jsx)(j,{memory:r,links:q,onClose:()=>a(null),onBoost:F,onDemote:k,onPromote:B,onDelete:V,onQuarantine:H,onEdit:G,onNavigateToMemory:O})]}),(0,R.jsx)("button",{onClick:u,className:"absolute left-0 top-1/2 -translate-y-1/2 z-10 bg-slate-800/80 hover:bg-slate-700 border border-slate-700 rounded-r px-1 py-3 text-slate-400 hover:text-white transition-colors",title:o?"Hide sidebar":"Show sidebar",children:(0,R.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:(0,R.jsx)("path",{d:o?"M8 1L3 6l5 5":"M4 1l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})})}),(0,R.jsx)("button",{onClick:c,className:"absolute right-0 top-1/2 -translate-y-1/2 z-10 bg-slate-800/80 hover:bg-slate-700 border border-slate-700 rounded-l px-1 py-3 text-slate-400 hover:text-white transition-colors",title:l?"Hide inspector":"Show inspector",children:(0,R.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:(0,R.jsx)("path",{d:l?"M4 1l5 5-5 5":"M8 1L3 6l5 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})})})]})}e.s(["BrainControlCentre",()=>pM],28592)},41740,e=>{e.n(e.i(28592))}]);