@shmulikdav/solix 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/web/assets/{CrewPanel-CVTXUelp.js → CrewPanel-CCQyVXEO.js} +1 -1
- package/dist/web/assets/{GalaxyPanel-DV-kbENC.js → GalaxyPanel-YXuzkrWv.js} +1 -1
- package/dist/web/assets/{Scene-gMUGX2_a.js → Scene-NahUVf-g.js} +1 -1
- package/dist/web/assets/{TimelineDrawer-BQo9SqvU.js → TimelineDrawer-CpPhGaYI.js} +1 -1
- package/dist/web/assets/{index-P5SyOUJE.js → index-C8BeteJb.js} +2 -2
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/dist/web/workbox-0bb07689.js +1 -0
- package/package.json +1 -1
- package/dist/web/workbox-9c191d2f.js +0 -1
|
@@ -53,7 +53,7 @@ Error generating stack: `+s.message+`
|
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the MIT license found in the
|
|
55
55
|
* LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/var Cd=Ae,cE=lE;function uE(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var dE=typeof Object.is=="function"?Object.is:uE,hE=cE.useSyncExternalStore,fE=Cd.useRef,pE=Cd.useEffect,mE=Cd.useMemo,gE=Cd.useDebugValue;Q_.useSyncExternalStoreWithSelector=function(n,e,t,i,r){var s=fE(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=mE(function(){function l(p){if(!c){if(c=!0,u=p,p=i(p),r!==void 0&&o.hasValue){var m=o.value;if(r(m,p))return h=m}return h=p}if(m=h,dE(u,p))return m;var x=i(p);return r!==void 0&&r(m,x)?(u=p,m):(u=p,h=x)}var c=!1,u,h,d=t===void 0?null:t;return[function(){return l(e())},d===null?void 0:function(){return l(d())}]},[e,t,i,r]);var a=hE(n,s[0],s[1]);return pE(function(){o.hasValue=!0,o.value=a},[a]),gE(a),a};J_.exports=Q_;var xE=J_.exports;const vE=Fv(xE),nS={},{useDebugValue:yE}=Ow,{useSyncExternalStoreWithSelector:_E}=vE;let jx=!1;const SE=n=>n;function ME(n,e=SE,t){(nS?"production":void 0)!=="production"&&t&&!jx&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),jx=!0);const i=_E(n.subscribe,n.getState,n.getServerState||n.getInitialState,e,t);return yE(i),i}const Xx=n=>{(nS?"production":void 0)!=="production"&&typeof n!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof n=="function"?Jb(n):n,t=(i,r)=>ME(e,i,r);return Object.assign(t,e),t},wE=n=>n?Xx(n):Xx,bE="solix.notifications.v1";function EE(){try{return localStorage.getItem(bE)==="off"?"off":"on"}catch{return"on"}}let $x=!1;async function TE(){if(typeof Notification>"u")return"denied";if(Notification.permission!=="default"||$x)return Notification.permission;$x=!0;try{return await Notification.requestPermission()}catch{return"denied"}}async function Yx(n){if(!(EE()==="off"||typeof Notification>"u"||n.whenHidden&&typeof document<"u"&&!document.hidden||await TE()!=="granted"))try{new Notification(n.title,{body:n.body,tag:n.tag})}catch{}}const AE="solix.sound.v1";let Hh=null;function qx(){try{if(localStorage.getItem(AE)!=="on"||typeof window>"u")return;if(!Hh){const r=window.AudioContext||window.webkitAudioContext;if(!r)return;Hh=new r}const n=Hh,e=n.createOscillator(),t=n.createGain();e.connect(t),t.connect(n.destination),e.type="sine",e.frequency.value=880,t.gain.value=1e-4;const i=n.currentTime;t.gain.exponentialRampToValueAtTime(.06,i+.01),t.gain.exponentialRampToValueAtTime(1e-4,i+.35),e.start(i),e.stop(i+.4)}catch{}}function Zx(n,e,t,i){const r={},s={},a=[];for(const l of n){if(l.ts>e)break;switch(l.type){case"session_started":{const c=t[l.sessionId];if(!c)continue;r[l.sessionId]={...c,status:"idle"};break}case"session_terminated":{delete r[l.sessionId];break}case"mission_started":{if(!l.missionId)continue;const c=i[l.missionId],u=r[l.sessionId];u&&(r[l.sessionId]={...u,status:"active",currentMissionId:l.missionId}),c&&(s[l.missionId]={...c,status:"active"});break}case"mission_completed":{if(!l.missionId)continue;const c=r[l.sessionId],u=i[l.missionId];c&&c.currentMissionId===l.missionId&&(r[l.sessionId]={...c,status:"idle",currentMissionId:void 0,lastCompletedMissionId:l.missionId}),u&&(s[l.missionId]={...u,status:"completed"});break}case"tool_call":{e-l.ts<=2e3&&a.push({id:`tc-${l.ts}-${l.sessionId}`,sessionId:l.sessionId,tool:l.toolName??"tool",args:{},startedAt:l.ts,status:"ok",receivedAt:l.ts});break}}}return{derivedSessions:r,derivedMissions:s,derivedToolCalls:a}}const Kx={active:!1,loading:!1,events:[],earliestMs:0,latestMs:0,currentMs:0,playing:!1,speed:4,derivedSessions:{},derivedMissions:{},derivedToolCalls:[]},Jx=2e3,iS="solix.motion.v1",rS="solix.viewMode.v1";function CE(){try{return localStorage.getItem(iS)==="1"}catch{return!1}}function Qx(n){try{localStorage.setItem(iS,n?"1":"0")}catch{}}function RE(){try{const n=localStorage.getItem(rS);return n==="list"||n==="missions"||n==="galaxy"?n:"galaxy"}catch{return"galaxy"}}function e0(n){try{localStorage.setItem(rS,n)}catch{}}const xe=wE((n,e)=>({connected:!1,projects:{},sessions:{},missions:{},advisors:{},skills:{},schedules:{},goals:{},budgetAlerts:{},chatBySessionId:{},recentToolCalls:[],pendingPermissions:{},selectedSessionId:null,selectedAdvisorId:null,selectedSkillId:null,motionEnabled:CE(),viewMode:RE(),playback:Kx,toasts:[],setConnected:t=>n({connected:t}),applyMessage:t=>{switch(t.type){case"snapshot":{const i={};for(const u of t.projects)i[u.id]=u;const r={};for(const u of t.sessions)r[u.id]=u;const s={};for(const u of t.missions)s[u.id]=u;const o={};for(const u of t.advisors)o[u.id]=u;const a={};for(const u of t.skills)a[u.id]=u;const l={};for(const u of t.schedules)l[u.id]=u;const c={};for(const u of t.goals)c[u.id]=u;n({projects:i,sessions:r,missions:s,advisors:o,skills:a,schedules:l,goals:c});break}case"advisor_upsert":{n(i=>({advisors:{...i.advisors,[t.advisor.id]:t.advisor}}));break}case"skill_upsert":{n(i=>({skills:{...i.skills,[t.skill.id]:t.skill}}));break}case"galaxy_imported":{const i=`${Date.now()}-galaxy`;n(r=>({toasts:[...r.toasts,{id:i,level:"info",message:`Imported galaxy: ${t.manifest.name}`}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}case"session_upsert":{n(i=>({sessions:{...i.sessions,[t.session.id]:t.session}}));break}case"session_remove":{n(i=>{const r={...i.sessions};return delete r[t.sessionId],{sessions:r}});break}case"mission_upsert":{n(i=>({missions:{...i.missions,[t.mission.id]:t.mission}}));break}case"tool_call":{const i={...t.toolCall,receivedAt:Date.now()};n(r=>({recentToolCalls:[...r.recentToolCalls,i].slice(-200)})),setTimeout(()=>{n(r=>({recentToolCalls:r.recentToolCalls.filter(s=>Date.now()-s.receivedAt<Jx)}))},Jx+50);break}case"permission_request":{const i={requestId:t.requestId,sessionId:t.sessionId,tool:t.tool,args:t.args,receivedAt:Date.now()};n(a=>({pendingPermissions:{...a.pendingPermissions,[t.requestId]:i}}));const r=e().sessions[t.sessionId],s=(r==null?void 0:r.name)??t.sessionId.slice(0,8),o=(()=>{const a=Object.keys(t.args)[0];if(!a)return"";const l=t.args[a],c=typeof l=="string"?l:JSON.stringify(l);return`: ${c.length>60?c.slice(0,60)+"…":c}`})();Yx({title:`${s} needs you`,body:`${t.tool}${o}`,tag:`solix-perm-${t.sessionId}`,whenHidden:!0}),qx();break}case"context_update":{n(i=>{const r=i.sessions[t.sessionId];return r?{sessions:{...i.sessions,[t.sessionId]:{...r,contextUsagePct:t.usagePct}}}:i});break}case"cost_update":{n(i=>{const r=i.sessions[t.sessionId];return r?{sessions:{...i.sessions,[t.sessionId]:{...r,costUsd:t.costUsd,budgetUsd:t.budgetUsd??r.budgetUsd}}}:i});break}case"budget_alert":{const i={sessionId:t.sessionId,costUsd:t.costUsd,budgetUsd:t.budgetUsd,receivedAt:Date.now()};n(s=>({budgetAlerts:{...s.budgetAlerts,[t.sessionId]:i}}));const r=e().sessions[t.sessionId];Yx({title:`${(r==null?void 0:r.name)??t.sessionId.slice(0,8)} hit its budget`,body:`$${t.costUsd.toFixed(2)} / $${t.budgetUsd.toFixed(2)}`,tag:`solix-budget-${t.sessionId}`,whenHidden:!0}),qx();break}case"schedule_upsert":{n(i=>({schedules:{...i.schedules,[t.schedule.id]:t.schedule}}));break}case"schedule_remove":{n(i=>{const r={...i.schedules};return delete r[t.scheduleId],{schedules:r}});break}case"goal_upsert":{n(i=>({goals:{...i.goals,[t.goal.id]:t.goal}}));break}case"goal_remove":{n(i=>{const r={...i.goals};return delete r[t.goalId],{goals:r}});break}case"chat_delta":{const i={...t.delta,receivedAt:Date.now()};n(r=>{const a=[...(r.chatBySessionId[t.sessionId]??[]).filter(l=>l.messageId!==i.messageId),i].slice(-200);return{chatBySessionId:{...r.chatBySessionId,[t.sessionId]:a}}});break}case"toast":{const i=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;n(r=>({toasts:[...r.toasts,{id:i,level:t.level,message:t.message}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}}},selectSession:t=>n({selectedSessionId:t,selectedAdvisorId:t?null:e().selectedAdvisorId,selectedSkillId:t?null:e().selectedSkillId}),selectAdvisor:t=>n({selectedAdvisorId:t,selectedSessionId:t?null:e().selectedSessionId,selectedSkillId:t?null:e().selectedSkillId}),selectSkill:t=>n({selectedSkillId:t,selectedSessionId:t?null:e().selectedSessionId,selectedAdvisorId:t?null:e().selectedAdvisorId}),dismissToast:t=>n(i=>({toasts:i.toasts.filter(r=>r.id!==t)})),resolvePermission:(t,i)=>{const r=e().send;r({type:"permission_response",requestId:t,approved:i}),n(s=>{const o={...s.pendingPermissions};return delete o[t],{pendingPermissions:o}})},invokeAdvisor:(t,i)=>{const r=e().send,s=e().selectedSessionId??void 0;r({type:"invoke_advisor",advisorId:t,targetSessionId:s,prompt:i})},pinAdvisor:t=>{e().send({type:"pin_advisor",advisorId:t})},unpinAdvisor:t=>{e().send({type:"unpin_advisor",advisorId:t})},enableAdvisor:t=>{e().send({type:"set_advisor_enabled",advisorId:t,enabled:!0})},disableAdvisor:t=>{e().send({type:"set_advisor_enabled",advisorId:t,enabled:!1})},sendPromptTo:(t,i)=>{if(!i.trim())return;e().send({type:"send_prompt",sessionId:t,text:i});const r={messageId:`pending-${Date.now()}`,role:"user",content:i,ts:Date.now(),done:!0,receivedAt:Date.now()};n(s=>({chatBySessionId:{...s.chatBySessionId,[t]:[...s.chatBySessionId[t]??[],r].slice(-200)}}))},launchTask:(t,i,r,s)=>{e().send({type:"launch_session",cwd:t,model:i,initialPrompt:r,worktreeBranch:s==null?void 0:s.worktreeBranch,worktreeBaseRef:s==null?void 0:s.worktreeBaseRef,useAgentView:s==null?void 0:s.useAgentView,agentName:s==null?void 0:s.agentName,budgetUsd:s==null?void 0:s.budgetUsd,goalId:s==null?void 0:s.goalId})},raiseBudget:(t,i)=>{e().send({type:"raise_budget",sessionId:t,budgetUsd:i}),n(r=>{const s={...r.budgetAlerts};return delete s[t],{budgetAlerts:s}})},dismissBudgetAlert:t=>{e().send({type:"dismiss_budget_alert",sessionId:t}),n(i=>{const r={...i.budgetAlerts};return delete r[t],{budgetAlerts:r}})},selectedSessionIds:new Set,toggleSessionSelection:t=>{n(i=>{const r=new Set(i.selectedSessionIds);return r.has(t)?r.delete(t):r.add(t),{selectedSessionIds:r}})},clearSessionSelection:()=>{n({selectedSessionIds:new Set})},terminateSessions:t=>{const i=e().send;for(const r of t)i({type:"terminate_session",sessionId:r});n({selectedSessionIds:new Set})},setMotionEnabled:t=>{Qx(t),n({motionEnabled:t})},toggleMotion:()=>{const t=!e().motionEnabled;Qx(t),n({motionEnabled:t})},setViewMode:t=>{e0(t),n({viewMode:t})},toggleViewMode:()=>{const t=["galaxy","list","missions"],i=e().viewMode,r=t.indexOf(i),s=t[(r+1)%t.length]??"galaxy";e0(s),n({viewMode:s})},enterPlayback:(t,i,r)=>{const s=i;n(o=>({playback:{...o.playback,active:!0,loading:!1,events:t,earliestMs:i,latestMs:r,currentMs:s,playing:!1,...Zx(t,s,e().sessions,e().missions)}}))},exitPlayback:()=>n({playback:Kx}),setPlaybackTime:t=>{n(i=>{const r=Math.max(i.playback.earliestMs,Math.min(t,i.playback.latestMs));return{playback:{...i.playback,currentMs:r,...Zx(i.playback.events,r,e().sessions,e().missions)}}})},setPlaybackSpeed:t=>n(i=>({playback:{...i.playback,speed:t}})),setPlaybackPlaying:t=>n(i=>({playback:{...i.playback,playing:t}})),setPlaybackLoading:t=>n(i=>({playback:{...i.playback,loading:t}})),send:()=>{},attachSocket:t=>n({send:t})}));function Fm(n){return n.playback.active?n.playback.derivedSessions:n.sessions}function sS(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind!=="advisor")}function PE(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind==="advisor")}function H3(n,e){return Object.values(Fm(n)).filter(t=>t.parentSessionId===e)}function G3(n){return Object.values(n.advisors).filter(e=>e.enabled)}function W3(n){return Object.values(n.advisors).filter(e=>!e.enabled)}function j3(n){return Object.values(n.advisors).sort((e,t)=>e.enabled!==t.enabled?e.enabled?-1:1:e.codename.localeCompare(t.codename))}function X3(n){return Object.values(n.skills)}function $3(n){return Object.values(n.schedules).filter(e=>e.enabled)}function Y3(n){return Object.values(n.goals)}function IE(n){switch(n){case"opus":return"#a855f7";case"sonnet":return"#3b82f6";case"haiku":return"#06b6d4";case"default":return"#94a3b8";default:return"#94a3b8"}}function q3(n){switch(n){case"active":return{color:"#fde68a",intensity:.3};case"awaiting_permission":return{color:"#ef4444",intensity:.5};case"awaiting_input":return{color:"#f59e0b",intensity:.25};case"plan_review":return{color:"#a78bfa",intensity:.2};case"error":return{color:"#dc2626",intensity:.3};case"spawning":return{color:"#ffffff",intensity:.2};case"idle":default:return{color:"#1e293b",intensity:.05}}}function Z3(n){return n>=100?"#dc2626":n>=75?"#f59e0b":"#38bdf8"}function oS(n){switch(n){case"active":return"Active";case"awaiting_permission":return"Permission";case"awaiting_input":return"Awaiting input";case"plan_review":return"Plan review";case"error":return"Error";case"spawning":return"Spawning";case"terminated":return"Terminated";case"idle":default:return"Idle"}}function NE(n,e,t){const i=[];let r=30;switch(n.status){case"error":r=0,i.push("In error state");break;case"plan_review":case"awaiting_input":r=15,i.push(`Status: ${n.status}`);break;case"awaiting_permission":r=12,i.push("Awaiting permission");break;case"terminated":r=5,i.push("Terminated");break;default:r=30}const s=Math.max(0,30-t*15);t>0&&i.push(`${t} pending permission${t===1?"":"s"}`);const a=25*Math.max(0,1-n.contextUsagePct/100);n.contextUsagePct>=90?i.push(`Context at ${n.contextUsagePct.toFixed(0)}%`):n.contextUsagePct>=80&&i.push(`Context warm (${n.contextUsagePct.toFixed(0)}%)`);let l=0;if(e&&e.status==="active"){const u=e.metrics.toolCallCount;l=Math.min(15,u*2)}else e&&e.status==="completed"&&(l=15);return{score:Math.round(Math.max(0,Math.min(100,r+s+a+l))),reasons:i}}function LE(n){return n>=75?"#10b981":n>=50?"#fbbf24":n>=25?"#f97316":"#ef4444"}const Bm={active:"The agent is currently working — emitting tool calls or generating output.",idle:"No mission running. The agent is waiting for the next prompt or has been quiet for a while.",spawning:"The agent process just started. It will transition to active within a second or two.",awaiting_permission:"The agent paused to ask permission for a sensitive tool call. Approve or deny in the Decision Queue.",awaiting_input:"The agent finished what it could and is waiting for your next prompt.",plan_review:"The agent produced a plan and is waiting for your approval before executing.",error:"The agent crashed or hit an unrecoverable error. Look at the SidePanel transcript for details.",terminated:"The agent process exited. No more activity will come from this session.",subagent:"A child agent spawned by another session (typically via the Task tool). Rendered as a moon orbiting the parent planet.",advisor:"A long-lived specialist agent (Compass, Forge, Lumen, Argus, Sentinel, …) with its own AGENT.md describing its role.",pinned:"An advisor that's always running. Pinned advisors orbit close to the sun in the inner ring."},t0={awaiting_permission:0,awaiting_input:1,plan_review:2,error:3,active:4,spawning:5,idle:6,terminated:7};function DE(){const n=xe(sS),e=xe(PE),t=xe(_=>_.projects),i=xe(_=>_.missions),r=xe(_=>_.pendingPermissions),s=xe(_=>_.selectSession),o=xe(_=>_.selectedSessionIds),a=xe(_=>_.toggleSessionSelection),l=xe(_=>_.clearSessionSelection),c=xe(_=>_.terminateSessions),[u,h]=Ae.useState("needs"),[d,p]=Ae.useState("asc"),m=Ae.useMemo(()=>{const _=[...n,...e],C=new Set(Object.values(r).map(w=>w.sessionId));return _.map(w=>{const E=w.currentMissionId?i[w.currentMissionId]:void 0,A=Object.values(r).filter(L=>L.sessionId===w.id).length,{score:b,reasons:M}=NE(w,E,A);return{session:w,project:t[w.projectId],mission:E,needsAttention:C.has(w.id)||w.status==="awaiting_permission"||w.status==="awaiting_input"||w.status==="plan_review",health:b,healthReasons:M}})},[n,e,t,i,r]),x=Ae.useMemo(()=>{var C;const _=new Map;for(const w of m){const E=((C=w.project)==null?void 0:C.id)??"_",A=_.get(E);A?A.rows.push(w):_.set(E,{project:w.project,rows:[w]})}return[..._.values()].sort((w,E)=>{var A,b;return(((A=E.project)==null?void 0:A.lastActiveAt)??0)-(((b=w.project)==null?void 0:b.lastActiveAt)??0)})},[m]),g=(_,C)=>{var E,A;const w=d==="asc"?1:-1;switch(u){case"name":return((_.session.name??_.session.id)>(C.session.name??C.session.id)?1:-1)*w;case"status":return((t0[_.session.status]??99)-(t0[C.session.status]??99))*w;case"progress":return((((E=_.mission)==null?void 0:E.metrics.toolCallCount)??0)-(((A=C.mission)==null?void 0:A.metrics.toolCallCount)??0))*w;case"context":return(_.session.contextUsagePct-C.session.contextUsagePct)*w;case"lastActivity":return(_.session.updatedAt-C.session.updatedAt)*w;case"needs":return _.needsAttention===C.needsAttention?0:_.needsAttention?-1*w:1*w;case"health":return(_.health-C.health)*w}},f=_=>{u===_?p(d==="asc"?"desc":"asc"):(h(_),p(_==="lastActivity"?"desc":"asc"))},v=_=>u!==_?"":d==="asc"?" ▲":" ▼",y=o.size;return S.jsxs("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-20 px-6 z-0",children:[y>0&&S.jsx("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-30 pointer-events-auto",children:S.jsxs("div",{className:"rounded-full border border-solix-accent/60 bg-solix-panel/95 backdrop-blur shadow-2xl px-4 py-2 flex items-center gap-3",children:[S.jsxs("span",{className:"text-xs text-slate-200 font-mono",children:[y," selected"]}),S.jsx("button",{onClick:()=>c([...o]),className:"text-xs px-3 py-1 rounded border border-solix-danger text-solix-danger hover:bg-solix-danger/15",children:"Terminate"}),S.jsx("button",{onClick:l,className:"text-xs text-slate-400 hover:text-slate-200",children:"Clear"})]})}),S.jsxs("div",{className:"max-w-6xl mx-auto",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest mb-3",children:["List view · ",m.length," agent",m.length===1?"":"s"]}),m.length===0?S.jsxs("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:["No agents yet. Run ",S.jsx("code",{children:"claude"})," in any terminal — a row will appear here within a second."]}):x.map(({project:_,rows:C})=>{const w=[...C].sort(g),E=(_==null?void 0:_.name)??"(unassigned)";return S.jsxs("section",{className:"mb-8 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:E}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[C.length," agent",C.length===1?"":"s"]})]}),(_==null?void 0:_.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:_.cwd})]}),S.jsxs("table",{className:"w-full text-sm",children:[S.jsx("thead",{className:"bg-black/30 text-[10px] uppercase tracking-wide text-slate-500",children:S.jsxs("tr",{children:[S.jsx(Ri,{children:S.jsx("input",{type:"checkbox","aria-label":"Select all in project",checked:w.length>0&&w.every(A=>o.has(A.session.id)),onChange:A=>{A.stopPropagation();const b=w.every(M=>o.has(M.session.id));for(const M of w){const L=o.has(M.session.id);(b&&L||!b&&!L)&&a(M.session.id)}},className:"cursor-pointer"})}),S.jsxs(Ri,{onClick:()=>f("needs"),children:["● ",v("needs")]}),S.jsxs(Ri,{onClick:()=>f("name"),children:["Agent",v("name")]}),S.jsx(Ri,{children:"Advisor"}),S.jsxs(Ri,{onClick:()=>f("status"),children:["Status",v("status")]}),S.jsxs(Ri,{onClick:()=>f("health"),numeric:!0,children:["Health",v("health")]}),S.jsxs(Ri,{onClick:()=>f("progress"),children:["Mission · tools",v("progress")]}),S.jsxs(Ri,{onClick:()=>f("context"),numeric:!0,children:["Context",v("context")]}),S.jsxs(Ri,{onClick:()=>f("lastActivity"),numeric:!0,children:["Last activity",v("lastActivity")]})]})}),S.jsx("tbody",{children:w.map(A=>{var b;return S.jsxs("tr",{onClick:()=>s(A.session.id),className:`border-t border-solix-border hover:bg-solix-border/20 cursor-pointer ${A.needsAttention?"bg-solix-danger/5":""} ${o.has(A.session.id)?"bg-solix-accent/5":""}`,children:[S.jsx("td",{className:"px-3 py-2",onClick:M=>M.stopPropagation(),children:S.jsx("input",{type:"checkbox","aria-label":"Select agent",checked:o.has(A.session.id),onChange:()=>a(A.session.id),className:"cursor-pointer"})}),S.jsx("td",{className:"px-3 py-2",children:A.needsAttention?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-danger solix-pulse"}):A.session.status==="active"?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-ok"}):S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-slate-600"})}),S.jsx("td",{className:"px-3 py-2",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:IE(A.session.model)},title:String(A.session.model)}),S.jsx("span",{className:"text-slate-100 font-medium",children:A.session.name??A.session.id.slice(0,8)}),A.session.kind==="advisor"&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-amber-300",children:"advisor"}),A.session.origin==="agentview"&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-cyan-300",title:"Background session managed by Anthropic's Agent View",children:"agent"}),A.session.wrapperSocketPath&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-solix-accent",title:"Wrapped by `solix run` — UI composer is enabled",children:"wrapped"}),A.session.worktreePath&&S.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded border border-solix-accent/40 text-solix-accent",title:A.session.worktreePath,children:["⌥",UE(A.session.worktreePath)]})]})}),S.jsx("td",{className:"px-3 py-2 text-xs",children:S.jsx(OE,{session:A.session,mission:A.mission})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300",title:Bm[A.session.status]??void 0,children:oS(A.session.status)}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(FE,{score:A.health,reasons:A.healthReasons})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300 truncate max-w-xs",title:A.session.agentViewSummary??((b=A.mission)==null?void 0:b.shortName)??void 0,children:A.session.agentViewSummary?S.jsx("span",{className:"text-slate-100 italic",children:A.session.agentViewSummary}):A.mission?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"text-slate-100",children:A.mission.shortName}),S.jsxs("span",{className:"text-slate-500 ml-1",children:["· ",A.mission.metrics.toolCallCount," tools"]})]}):S.jsx("span",{className:"text-slate-500 italic",children:"idle"})}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(BE,{pct:A.session.contextUsagePct})}),S.jsx("td",{className:"px-3 py-2 text-right text-[11px] text-slate-500 font-mono",children:zE(A.session.updatedAt)})]},A.session.id)})})]})]},(_==null?void 0:_.id)??"_")})]})]})}function UE(n){const e=n.split("/").filter(Boolean);return e[e.length-1]??n}const kE=/^\[Acting as ([^\s—]+)/;function OE({session:n,mission:e}){var s;const t=xe(o=>o.advisors);let i,r=!1;if(n.advisorRole)i=Object.values(t).find(o=>o.id===n.advisorRole);else if(e!=null&&e.prompt){const o=e.prompt.match(kE),a=(s=o==null?void 0:o[1])==null?void 0:s.toLowerCase();a&&(i=Object.values(t).find(l=>l.codename.toLowerCase()===a),r=!0)}return i?S.jsxs("span",{className:`inline-flex items-center gap-1 ${r?"opacity-60":""}`,title:i.description,children:[S.jsx("span",{style:{color:i.color},children:i.glyph}),S.jsx("span",{className:"text-slate-200",children:i.codename})]}):S.jsx("span",{className:"text-slate-700",children:"—"})}function Ri({children:n,onClick:e,numeric:t}){return S.jsx("th",{onClick:e,className:`px-3 py-2 select-none ${t?"text-right":"text-left"} ${e?"cursor-pointer hover:text-slate-300":""}`,children:n})}function FE({score:n,reasons:e}){const t=LE(n);return S.jsxs("div",{className:"relative inline-flex items-center gap-2 group",children:[S.jsx("span",{className:"text-[11px] font-mono font-bold",style:{color:t},children:n}),S.jsx("div",{className:"w-16 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:"h-full",style:{width:`${Math.max(2,n)}%`,background:t}})}),S.jsxs("div",{className:"pointer-events-none absolute right-0 top-full mt-1 z-50 hidden group-hover:block w-64 rounded border border-solix-border bg-solix-panel/95 backdrop-blur p-2 text-left shadow-xl",children:[S.jsxs("div",{className:"flex items-center justify-between mb-1",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Health"}),S.jsxs("span",{className:"text-xs font-bold",style:{color:t},children:[n,"/100"]})]}),e.length===0?S.jsx("div",{className:"text-[11px] text-slate-400 italic",children:"All four bands healthy: stable status, no pending decisions, context budget, mission progress."}):S.jsx("ul",{className:"space-y-0.5",children:e.map(i=>S.jsxs("li",{className:"text-[11px] text-slate-200 leading-snug",children:["· ",i]},i))})]})]})}function BE({pct:n}){const e=n>=90?"bg-solix-danger":n>=80?"bg-solix-warn":"bg-solix-accent";return S.jsxs("div",{className:"inline-flex items-center gap-2",children:[S.jsxs("span",{className:"text-[11px] text-slate-400 font-mono",children:[n.toFixed(0),"%"]}),S.jsx("div",{className:"w-20 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:`h-full ${e}`,style:{width:`${Math.min(100,n)}%`}})})]})}function zE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const i=Math.floor(t/60);if(i<60)return`${i}m`;const r=Math.floor(i/60);return r<24?`${r}h`:new Date(n).toLocaleDateString()}function VE(){const n=xe(l=>l.missions),e=xe(l=>l.sessions),t=xe(l=>l.projects),i=xe(l=>l.selectSession),[r,s]=Ae.useState("all"),o=Ae.useMemo(()=>{const l=Object.values(n).sort((c,u)=>u.startedAt-c.startedAt);return r==="all"?l:l.filter(c=>c.status===r)},[n,r]),a=Ae.useMemo(()=>{const l=new Map;for(const c of o){const u=e[c.sessionId],h=u?t[u.projectId]:void 0,d=(h==null?void 0:h.id)??"_",p=l.get(d);p?p.missions.push(c):l.set(d,{project:h,missions:[c]})}return[...l.values()].sort((c,u)=>{var h,d;return(((h=u.missions[0])==null?void 0:h.startedAt)??0)-(((d=c.missions[0])==null?void 0:d.startedAt)??0)})},[o,e,t]);return S.jsx("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-8 px-6 z-0",children:S.jsxs("div",{className:"max-w-4xl mx-auto",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest",children:["Missions · ",o.length]}),S.jsx("div",{className:"flex items-center gap-1.5",children:["all","active","completed","failed","cancelled"].map(l=>S.jsx("button",{onClick:()=>s(l),className:`text-[10px] px-2 py-0.5 rounded border ${r===l?"bg-solix-accent/15 border-solix-accent text-solix-accent":"border-solix-border text-slate-400 hover:text-slate-200"}`,children:l},l))})]}),o.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:"No missions yet. Send a prompt to a Claude Code session and a mission card will appear here."}):a.map(({project:l,missions:c})=>{const u=(l==null?void 0:l.name)??"(unassigned)";return S.jsxs("section",{className:"mb-6 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:u}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[c.length," mission",c.length===1?"":"s"]})]}),(l==null?void 0:l.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:l.cwd})]}),S.jsx("ul",{className:"divide-y divide-solix-border",children:c.map(h=>{const d=e[h.sessionId];return S.jsx("li",{children:S.jsxs("button",{onClick:()=>i(h.sessionId),className:"w-full text-left p-4 hover:bg-solix-border/20 cursor-pointer block",children:[S.jsxs("div",{className:"flex items-start justify-between gap-3",children:[S.jsxs("div",{className:"min-w-0 flex-1",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:h.shortName}),S.jsx(HE,{status:h.status})]}),S.jsx("div",{className:"mt-1 text-xs text-slate-400 line-clamp-2",children:h.prompt}),h.longSummary&&S.jsx("div",{className:"mt-1 text-xs text-slate-300 italic",children:h.longSummary}),h.status==="failed"&&h.errorSummary&&S.jsxs("div",{className:"mt-1 text-xs text-solix-danger italic line-clamp-2",children:["error: ",h.errorSummary]})]}),S.jsxs("div",{className:"text-right text-[10px] text-slate-500 font-mono whitespace-nowrap",children:[WE(h.startedAt),h.metrics.durationMs!==void 0&&S.jsxs("div",{children:[(h.metrics.durationMs/1e3).toFixed(1),"s"]})]})]}),S.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[10px] text-slate-500",children:[d&&S.jsxs("span",{children:["agent:"," ",S.jsx("span",{className:"text-slate-300",children:d.name??d.id.slice(0,8)})]}),S.jsxs("span",{children:[h.metrics.toolCallCount," tools"]}),S.jsxs("span",{title:Bm.subagent,children:[h.metrics.subagentCount," subagents"]}),S.jsxs("span",{children:[h.filesTouched.length," files"]})]}),h.filesTouched.length>0&&S.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[h.filesTouched.slice(0,6).map(p=>S.jsx("span",{className:"text-[10px] font-mono text-slate-400 bg-black/30 border border-solix-border rounded px-1.5 py-0.5",children:GE(p)},p)),h.filesTouched.length>6&&S.jsxs("span",{className:"text-[10px] text-slate-500",children:["+",h.filesTouched.length-6]})]})]})},h.id)})})]},(l==null?void 0:l.id)??"_")})]})})}function HE({status:n}){const e=n==="active"?"border-solix-warn text-solix-warn":n==="completed"?"border-solix-ok text-solix-ok":n==="failed"?"border-solix-danger text-solix-danger":"border-solix-border text-slate-400";return S.jsx("span",{className:`text-[9px] uppercase tracking-wide px-1.5 py-0.5 rounded border ${e}`,children:n})}function GE(n){const e=n.match(/[^/\\]+\/?$/);return e?e[0].replace(/\/$/,""):n}function WE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s ago`;const i=Math.floor(t/60);if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:new Date(n).toLocaleDateString()}function jE({onOpenGalaxy:n,onNewTask:e,onOpenTimeline:t,onOpenHelp:i,onOpenCrew:r}={}){const s=xe(h=>h.connected),o=xe(sS),a=xe(h=>h.viewMode),l=xe(h=>h.playback.active),c=xe(h=>h.exitPlayback),u=o.reduce((h,d)=>(d.status==="active"?h.active+=1:d.status==="awaiting_permission"||d.status==="awaiting_input"||d.status==="plan_review"?h.attention+=1:d.status==="idle"&&(h.idle+=1),h),{active:0,idle:0,attention:0});return S.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between p-4 z-40",children:[S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3",children:[S.jsxs("div",{className:"flex items-baseline gap-1.5",children:[S.jsx("div",{className:"text-xl font-bold tracking-widest text-solix-accent",children:"SOLIX"}),S.jsxs("span",{className:"text-[10px] font-mono text-slate-500",title:"Solix v1.9.0 — built into this UI bundle",children:["v","1.9.0"]})]}),S.jsx("div",{className:"hidden md:block text-xs text-slate-400",children:"a solar-system command center"}),S.jsx("div",{className:`ml-1 sm:ml-3 px-2 py-1 rounded text-[10px] border ${s?"border-solix-ok text-solix-ok":"border-solix-danger text-solix-danger solix-pulse"}`,children:s?"CONNECTED":"OFFLINE"}),l&&S.jsxs("button",{onClick:c,className:"ml-2 px-2 py-1 rounded text-[10px] border border-solix-accent text-solix-accent solix-pulse hover:bg-solix-accent/15 cursor-pointer flex items-center gap-1.5",title:"Exit Timeline Playback (Esc)","aria-label":"Exit playback",children:[S.jsx("span",{children:"▸ PLAYBACK"}),S.jsx("span",{className:"opacity-70",children:"· exit ✕"})]})]}),S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3 text-xs",children:[S.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[S.jsx(Gh,{label:"active",value:u.active,color:"text-solix-ok"}),S.jsx(Gh,{label:"attention",value:u.attention,color:"text-solix-warn"}),S.jsx(Gh,{label:"idle",value:u.idle,color:"text-slate-400"})]}),S.jsx(XE,{viewMode:a}),t&&S.jsx("button",{onClick:t,className:"hidden sm:inline-block px-2 py-1 rounded bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30",title:"Timeline playback (T)",children:"⏱ Timeline"}),e&&S.jsx("button",{onClick:e,className:"px-2 py-1 rounded bg-solix-ok/15 border border-solix-ok/40 text-solix-ok hover:bg-solix-ok/25",title:"Launch a new Claude Code task (L)",children:"+ Task"}),r&&S.jsx("button",{onClick:r,className:"px-2 py-1 rounded bg-amber-500/15 border border-amber-400/40 text-amber-200 hover:bg-amber-500/25",title:"Crew: view and enable advisors (C)",children:"✦ Crew"}),n&&S.jsx("button",{onClick:n,className:"px-2 py-1 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent hover:bg-solix-accent/25",title:"Galaxy: export and import (G)",children:"⌬ Galaxy"}),i&&S.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30 text-sm",title:"Help (?)","aria-label":"Help",children:"?"})]})]})}function XE({viewMode:n}){const e=xe(i=>i.setViewMode),t=[{mode:"galaxy",label:"🪐"},{mode:"list",label:"☰"},{mode:"missions",label:"◎"}];return S.jsx("div",{className:"inline-flex rounded border border-solix-border bg-solix-panel overflow-hidden",children:t.map(i=>S.jsxs("button",{onClick:()=>e(i.mode),className:`px-2 py-1 text-xs ${n===i.mode?"bg-solix-border/50 text-white":"text-slate-400 hover:text-slate-100"}`,title:`${i.mode} view (V)`,children:[i.label," ",S.jsx("span",{className:"hidden sm:inline capitalize",children:i.mode})]},i.mode))})}function Gh({label:n,value:e,color:t}){return S.jsxs("div",{className:"px-2 py-1 rounded bg-solix-panel border border-solix-border",children:[S.jsx("span",{className:`font-bold ${t}`,children:e}),S.jsx("span",{className:"ml-1 opacity-60 uppercase tracking-wide",children:n})]})}function $E(){const n=xe(t=>t.toasts),e=xe(t=>t.dismissToast);return S.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex flex-col gap-2 z-30",children:n.map(t=>S.jsx("button",{onClick:()=>e(t.id),className:`pointer-events-auto px-3 py-2 rounded text-xs border max-w-md text-left ${t.level==="error"?"bg-solix-danger/10 border-solix-danger text-solix-danger":t.level==="warn"?"bg-solix-warn/10 border-solix-warn text-solix-warn":"bg-solix-panel border-solix-border text-slate-200"}`,children:t.message},t.id))})}const n0="solix.welcome.dismissed.v1";function YE({onOpenGalaxy:n,forceOpen:e=!1,onClose:t}){const[i,r]=Ae.useState(!1),s=xe(u=>u.advisors),o=xe(u=>Object.keys(u.skills).length),a=xe(u=>Object.keys(u.sessions).length);if(Ae.useEffect(()=>{try{r(localStorage.getItem(n0)==="1")}catch{}},[]),!e&&(i||a>0))return null;const l=()=>{try{localStorage.setItem(n0,"1")}catch{}r(!0),t==null||t()},c=Object.values(s).filter(u=>u.enabled).sort((u,h)=>u.codename.localeCompare(h.codename));return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center pointer-events-none",children:S.jsxs("div",{className:"pointer-events-auto max-w-xl w-full mx-4 rounded-xl border border-solix-accent/40 bg-solix-panel/95 backdrop-blur-md shadow-2xl",children:[S.jsxs("div",{className:"px-6 pt-5 pb-3 border-b border-solix-border",children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"welcome"}),S.jsx("div",{className:"text-2xl font-bold mt-1",children:"Solix — your agent solar system"}),S.jsx("div",{className:"text-sm text-slate-400 mt-1",children:"Mission control for Claude Code. Each agent orbits the sun; each click is a conversation with one of your planets."})]}),S.jsxs("div",{className:"px-6 py-4 space-y-3 text-sm text-slate-300",children:[S.jsx(ta,{n:1,title:"Run a Claude Code session",body:S.jsxs(S.Fragment,{children:["Open a terminal anywhere and run"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude"}),". A planet will appear here within a second."]})}),S.jsx(ta,{n:2,title:"Or seed the demo state",body:S.jsxs(S.Fragment,{children:["In another terminal:"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"solix demo"}),". You'll get a fully populated galaxy — ~30 sessions across 8 projects, all 14 advisors, moons, and live permission flares — without running Claude Code."]})}),S.jsx(ta,{n:3,title:"Meet the advisor crew",body:S.jsxs(S.Fragment,{children:[c.length>0?`${c.length} crew members loaded. Click any in the inner ring to read their role and invoke them on the focused planet.`:"Crew loading…",c.length>0&&S.jsx("ul",{className:"mt-2 space-y-1",children:c.map(u=>S.jsxs("li",{className:"flex items-baseline gap-2",children:[S.jsxs("span",{className:"font-mono text-xs",style:{color:u.color},children:[u.glyph," ",u.codename]}),S.jsx("span",{className:"text-slate-500 text-xs",children:"—"}),S.jsx("span",{className:"text-slate-300 text-xs",children:u.name})]},u.id))})]})}),S.jsx(ta,{n:4,title:"Browse the asteroid belt",body:S.jsxs(S.Fragment,{children:["Each asteroid is a Skill (",o," discovered). Click one to read its SKILL.md and see which advisors require it."]})}),S.jsx(ta,{n:5,title:"Share your galaxy",body:S.jsxs(S.Fragment,{children:["Press"," ",S.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px]",children:"G"})," ","or click ",S.jsx("span",{className:"text-solix-accent",children:"⌬ Galaxy"})," ","in the top bar to export, import, publish, or install a galaxy from a registry."]})})]}),S.jsxs("div",{className:"px-6 pb-3 pt-1",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-widest text-slate-500 mb-1.5",children:"Keyboard shortcuts"}),S.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-slate-400",children:[S.jsx(pi,{k:"V",children:"cycle Galaxy → List → Missions"}),S.jsx(pi,{k:"G",children:"toggle Galaxy panel"}),S.jsx(pi,{k:"L",children:"new task"}),S.jsx(pi,{k:"T",children:"timeline"}),S.jsx(pi,{k:"M",children:"jump to Missions"}),S.jsx(pi,{k:"Y",children:"approve top decision"}),S.jsx(pi,{k:"N",children:"deny top decision"}),S.jsx(pi,{k:"Space",children:"play / pause orbits"}),S.jsx(pi,{k:"?",children:"re-open this help"}),S.jsx(pi,{k:"Esc",children:"close panels / exit playback"})]}),S.jsx("div",{className:"text-[10px] text-slate-500 italic mt-2",children:"If clicks feel stuck, a third-party screen overlay (note-taker, recorder) may be intercepting. Quit it temporarily, or use the shortcuts above."})]}),S.jsxs("div",{className:"px-6 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:()=>{n(),l()},className:"px-3 py-1.5 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent text-xs hover:bg-solix-accent/25",children:"Open Galaxy panel"}),S.jsx("div",{className:"flex-1"}),S.jsxs("span",{className:"text-[10px] font-mono text-slate-500 mr-2",children:["Solix v","1.9.0"]}),S.jsx("button",{onClick:l,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Got it"})]})]})})}function pi({k:n,children:e}){return S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px] font-mono text-slate-300",children:n}),S.jsx("span",{className:"truncate",children:e})]})}function ta({n,title:e,body:t}){return S.jsxs("div",{className:"flex gap-3",children:[S.jsx("div",{className:"shrink-0 w-6 h-6 rounded-full bg-solix-accent/20 border border-solix-accent/40 text-solix-accent text-xs flex items-center justify-center",children:n}),S.jsxs("div",{children:[S.jsx("div",{className:"text-slate-100 font-medium text-sm",children:e}),S.jsx("div",{className:"text-slate-400 text-xs mt-0.5 leading-relaxed",children:t})]})]})}function qE(n,e,t,i){const r=Wh(i,"command"),s=Wh(i,"file_path"),o=Wh(i,"url");if(t==="Bash"&&r){if(/\brm\s+-rf\b/i.test(r)||/\bsudo\b/i.test(r))return{severity:"danger",text:"Destructive command. Deny unless you have already confirmed the diff."};if(/--no-verify\b/.test(r))return{severity:"warn",text:"Skipping pre-commit hooks. Investigate the failure first."};if(/git\s+push.*--force\b/.test(r))return{severity:"danger",text:"Force-push. Confirm no one else has pushed since."};if(/git\s+push/.test(r)&&/\b(main|master|prod|production)\b/.test(r))return{severity:"warn",text:"Pushing to main/prod. Confirm the diff first."};if(/git\s+reset\s+--hard\b/.test(r))return{severity:"warn",text:"Hard reset will discard uncommitted changes. Stash first if unsure."}}if((t==="Edit"||t==="Write"||t==="MultiEdit")&&s){if(/\.env(\b|\.|\/)|credentials\.json|\.pem$|\.key$/i.test(s))return{severity:"danger",text:"Editing a secrets file. Make sure the agent really needs to."};if(/(^|\/)\.git\//.test(s))return{severity:"warn",text:"Editing inside .git/. Almost certainly a mistake."}}if(t==="WebFetch"&&o){if(/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/.test(o))return null;if(/^http:\/\//.test(o))return{severity:"info",text:"Plain HTTP fetch. OK for known internal hosts."}}return n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Run /compact before continuing.`}:null}function ZE(n,e){return n.status==="error"?{severity:"danger",text:"Session is in error state. Check the chat tab and consider restarting."}:n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Compact the conversation before the next prompt.`}:n.contextUsagePct>=80?{severity:"info",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Watch out — output quality drops past 90.`}:e&&e.status==="active"&&e.metrics.toolCallCount===0&&Date.now()-e.startedAt>5*60*1e3?{severity:"info",text:"Active mission with no tool calls in 5+ minutes. Agent may be stuck."}:null}function Wh(n,e){const t=n[e];return typeof t=="string"?t:null}function KE({panelOffsetPx:n=0}={}){const e=xe(x=>x.pendingPermissions),t=xe(x=>x.budgetAlerts),i=xe(x=>x.sessions),r=xe(x=>x.missions),s=xe(x=>x.resolvePermission),o=xe(x=>x.raiseBudget),a=xe(x=>x.dismissBudgetAlert),l=xe(x=>x.selectSession),c=Object.values(e).sort((x,g)=>g.receivedAt-x.receivedAt),u=Object.values(t).sort((x,g)=>g.receivedAt-x.receivedAt),[h,d]=Ae.useState(!1),p=c.length+u.length;Ae.useEffect(()=>{p>0&&d(!1)},[p]);const m=x=>{l(x),d(!0)};return p===0?S.jsx("div",{className:"absolute top-20 z-30 pointer-events-none",style:{right:`${n+16}px`},children:S.jsxs("div",{className:"pointer-events-auto rounded-full border border-solix-border bg-solix-panel/60 backdrop-blur px-3 py-1 text-[10px] text-slate-500 flex items-center gap-2",children:[S.jsx("span",{className:"uppercase tracking-widest",children:"decisions"}),S.jsx("span",{className:"font-bold",children:"0"}),S.jsx("span",{className:"italic opacity-80",children:"— all clear"})]})}):S.jsxs("div",{className:"absolute top-20 z-30 w-80 flex flex-col gap-2 pointer-events-none",style:{right:`${n+16}px`},children:[S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-border bg-solix-panel/85 backdrop-blur px-3 py-2 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-widest text-slate-400",children:"Decisions"}),S.jsx("span",{className:"text-xs font-bold text-solix-danger",children:p})]}),S.jsx("button",{onClick:()=>d(x=>!x),className:"text-[10px] text-slate-400 hover:text-slate-100",children:h?"show":"hide"})]}),!h&&u.map(x=>{var g;return S.jsx(JE,{name:((g=i[x.sessionId])==null?void 0:g.name)??x.sessionId.slice(0,8),costUsd:x.costUsd,budgetUsd:x.budgetUsd,onRaise:()=>{const f=window.prompt(`New budget cap (USD) for this agent — current $${x.budgetUsd.toFixed(2)}, spent $${x.costUsd.toFixed(2)}:`,(x.budgetUsd*2).toFixed(2)),v=f?parseFloat(f):NaN;Number.isFinite(v)&&v>0&&o(x.sessionId,v)},onDismiss:()=>a(x.sessionId)},`budget-${x.sessionId}`)}),!h&&c.map(x=>{const g=i[x.sessionId],f=g!=null&&g.currentMissionId?r[g.currentMissionId]:void 0;return S.jsx(QE,{session:g,mission:f,tool:x.tool,args:x.args,onApprove:()=>s(x.requestId,!0),onDeny:()=>s(x.requestId,!1),onAsk:()=>m(x.sessionId)},x.requestId)})]})}function JE({name:n,costUsd:e,budgetUsd:t,onRaise:i,onDismiss:r}){return S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-danger bg-solix-danger/10 p-3 backdrop-blur shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-solix-danger",children:n}),S.jsx("div",{className:"text-[10px] uppercase tracking-widest text-solix-danger/80",children:"budget"})]}),S.jsxs("div",{className:"mt-2 text-sm text-slate-100",children:["Budget reached",S.jsxs("span",{className:"ml-1 font-mono text-xs text-slate-300",children:["$",e.toFixed(2)," / $",t.toFixed(2)]})]}),S.jsx("div",{className:"mt-1 text-[11px] text-slate-400 leading-snug",children:"Solix-launched agents won't be sent more prompts until you raise the cap."}),S.jsxs("div",{className:"mt-3 flex gap-1.5",children:[S.jsx("button",{onClick:i,className:"flex-1 py-1.5 rounded bg-solix-ok/20 border border-solix-ok text-solix-ok text-xs hover:bg-solix-ok/30",children:"Raise cap"}),S.jsx("button",{onClick:r,className:"px-2.5 py-1.5 rounded border border-solix-border text-slate-300 text-xs hover:text-white hover:bg-solix-border/30",children:"Dismiss"})]})]})}function QE({session:n,mission:e,tool:t,args:i,onApprove:r,onDeny:s,onAsk:o}){const a=(n==null?void 0:n.name)??(n==null?void 0:n.id.slice(0,8))??"unknown agent",l=n!=null&&n.cwd?iT(n.cwd):"",c=n?qE(n,e,t,i):null;return S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-danger bg-solix-danger/10 p-3 backdrop-blur shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-solix-danger",children:a}),l&&S.jsx("div",{className:"text-[10px] text-slate-500 truncate ml-2 max-w-[55%]",children:l})]}),e&&S.jsxs("div",{className:"mt-1 text-[11px] text-slate-400 italic truncate",children:["mission: ",e.shortName]}),S.jsxs("div",{className:"mt-2 text-sm text-slate-100",children:[S.jsx("span",{className:"font-semibold",children:t}),S.jsx("span",{className:"ml-1 text-slate-300 text-xs break-words",children:rT(i)})]}),S.jsx(eT,{tool:t,args:i}),c&&S.jsx(nT,{suggestion:c}),S.jsxs("div",{className:"mt-3 flex gap-1.5",children:[S.jsx("button",{onClick:r,className:"flex-1 py-1.5 rounded bg-solix-ok/20 border border-solix-ok text-solix-ok text-xs hover:bg-solix-ok/30",children:"Approve · Y"}),S.jsx("button",{onClick:s,className:"flex-1 py-1.5 rounded bg-solix-danger/20 border border-solix-danger text-solix-danger text-xs hover:bg-solix-danger/30",children:"Deny · N"}),S.jsx("button",{onClick:o,className:"px-2.5 py-1.5 rounded border border-solix-border text-slate-300 text-xs hover:text-white hover:bg-solix-border/30",title:"Open chat with this agent for context",children:"Ask"})]})]})}function eT({tool:n,args:e}){const[t,i]=Ae.useState(!1);if(n==="Bash"){const r=rr(e,"command")??"",s=rr(e,"description");return r?S.jsxs(jh,{label:"will run",children:[S.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[11px] text-slate-100",children:r}),s&&S.jsx("div",{className:"mt-1 text-[10px] text-slate-500 italic",children:s})]}):null}if(n==="Edit"||n==="NotebookEdit"){const r=rr(e,"file_path")??rr(e,"notebook_path"),s=rr(e,"old_string"),o=rr(e,"new_string");return!r&&!s&&!o?null:S.jsxs(jh,{label:"patch",children:[r&&S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(Xh,{sign:"-",text:s,expanded:t,colorClass:"text-solix-danger bg-solix-danger/10"}),o&&S.jsx(Xh,{sign:"+",text:o,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),($h(s)||$h(o))&&S.jsx("button",{onClick:()=>i(a=>!a),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]})}if(n==="Write"){const r=rr(e,"file_path"),s=rr(e,"content")??"";return r?S.jsxs(jh,{label:"will write",children:[S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(Xh,{sign:"+",text:s,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),$h(s)&&S.jsx("button",{onClick:()=>i(o=>!o),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]}):null}return null}function jh({label:n,children:e}){return S.jsxs("div",{className:"mt-2 rounded border border-solix-border bg-black/30 px-2 py-1.5",children:[S.jsx("div",{className:"text-[9px] uppercase tracking-wider text-slate-500 mb-1",children:n}),e]})}function Xh({sign:n,text:e,expanded:t,colorClass:i}){const r=t?e:tT(e,240);return S.jsxs("pre",{className:`mt-1 px-1.5 py-1 rounded text-[11px] font-mono whitespace-pre-wrap break-words ${i}`,children:[S.jsx("span",{className:"opacity-50 mr-1",children:n}),r]})}function rr(n,e){const t=n[e];return typeof t=="string"?t:void 0}function $h(n){return!!(n&&n.length>240)}function tT(n,e){if(n.length<=e)return n;const t=Math.floor((e-3)/2);return`${n.slice(0,t)}
|
|
56
|
+
*/var Cd=Ae,cE=lE;function uE(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var dE=typeof Object.is=="function"?Object.is:uE,hE=cE.useSyncExternalStore,fE=Cd.useRef,pE=Cd.useEffect,mE=Cd.useMemo,gE=Cd.useDebugValue;Q_.useSyncExternalStoreWithSelector=function(n,e,t,i,r){var s=fE(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=mE(function(){function l(p){if(!c){if(c=!0,u=p,p=i(p),r!==void 0&&o.hasValue){var m=o.value;if(r(m,p))return h=m}return h=p}if(m=h,dE(u,p))return m;var x=i(p);return r!==void 0&&r(m,x)?(u=p,m):(u=p,h=x)}var c=!1,u,h,d=t===void 0?null:t;return[function(){return l(e())},d===null?void 0:function(){return l(d())}]},[e,t,i,r]);var a=hE(n,s[0],s[1]);return pE(function(){o.hasValue=!0,o.value=a},[a]),gE(a),a};J_.exports=Q_;var xE=J_.exports;const vE=Fv(xE),nS={},{useDebugValue:yE}=Ow,{useSyncExternalStoreWithSelector:_E}=vE;let jx=!1;const SE=n=>n;function ME(n,e=SE,t){(nS?"production":void 0)!=="production"&&t&&!jx&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),jx=!0);const i=_E(n.subscribe,n.getState,n.getServerState||n.getInitialState,e,t);return yE(i),i}const Xx=n=>{(nS?"production":void 0)!=="production"&&typeof n!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof n=="function"?Jb(n):n,t=(i,r)=>ME(e,i,r);return Object.assign(t,e),t},wE=n=>n?Xx(n):Xx,bE="solix.notifications.v1";function EE(){try{return localStorage.getItem(bE)==="off"?"off":"on"}catch{return"on"}}let $x=!1;async function TE(){if(typeof Notification>"u")return"denied";if(Notification.permission!=="default"||$x)return Notification.permission;$x=!0;try{return await Notification.requestPermission()}catch{return"denied"}}async function Yx(n){if(!(EE()==="off"||typeof Notification>"u"||n.whenHidden&&typeof document<"u"&&!document.hidden||await TE()!=="granted"))try{new Notification(n.title,{body:n.body,tag:n.tag})}catch{}}const AE="solix.sound.v1";let Hh=null;function qx(){try{if(localStorage.getItem(AE)!=="on"||typeof window>"u")return;if(!Hh){const r=window.AudioContext||window.webkitAudioContext;if(!r)return;Hh=new r}const n=Hh,e=n.createOscillator(),t=n.createGain();e.connect(t),t.connect(n.destination),e.type="sine",e.frequency.value=880,t.gain.value=1e-4;const i=n.currentTime;t.gain.exponentialRampToValueAtTime(.06,i+.01),t.gain.exponentialRampToValueAtTime(1e-4,i+.35),e.start(i),e.stop(i+.4)}catch{}}function Zx(n,e,t,i){const r={},s={},a=[];for(const l of n){if(l.ts>e)break;switch(l.type){case"session_started":{const c=t[l.sessionId];if(!c)continue;r[l.sessionId]={...c,status:"idle"};break}case"session_terminated":{delete r[l.sessionId];break}case"mission_started":{if(!l.missionId)continue;const c=i[l.missionId],u=r[l.sessionId];u&&(r[l.sessionId]={...u,status:"active",currentMissionId:l.missionId}),c&&(s[l.missionId]={...c,status:"active"});break}case"mission_completed":{if(!l.missionId)continue;const c=r[l.sessionId],u=i[l.missionId];c&&c.currentMissionId===l.missionId&&(r[l.sessionId]={...c,status:"idle",currentMissionId:void 0,lastCompletedMissionId:l.missionId}),u&&(s[l.missionId]={...u,status:"completed"});break}case"tool_call":{e-l.ts<=2e3&&a.push({id:`tc-${l.ts}-${l.sessionId}`,sessionId:l.sessionId,tool:l.toolName??"tool",args:{},startedAt:l.ts,status:"ok",receivedAt:l.ts});break}}}return{derivedSessions:r,derivedMissions:s,derivedToolCalls:a}}const Kx={active:!1,loading:!1,events:[],earliestMs:0,latestMs:0,currentMs:0,playing:!1,speed:4,derivedSessions:{},derivedMissions:{},derivedToolCalls:[]},Jx=2e3,iS="solix.motion.v1",rS="solix.viewMode.v1";function CE(){try{return localStorage.getItem(iS)==="1"}catch{return!1}}function Qx(n){try{localStorage.setItem(iS,n?"1":"0")}catch{}}function RE(){try{const n=localStorage.getItem(rS);return n==="list"||n==="missions"||n==="galaxy"?n:"galaxy"}catch{return"galaxy"}}function e0(n){try{localStorage.setItem(rS,n)}catch{}}const xe=wE((n,e)=>({connected:!1,projects:{},sessions:{},missions:{},advisors:{},skills:{},schedules:{},goals:{},budgetAlerts:{},chatBySessionId:{},recentToolCalls:[],pendingPermissions:{},selectedSessionId:null,selectedAdvisorId:null,selectedSkillId:null,motionEnabled:CE(),viewMode:RE(),playback:Kx,toasts:[],setConnected:t=>n({connected:t}),applyMessage:t=>{switch(t.type){case"snapshot":{const i={};for(const u of t.projects)i[u.id]=u;const r={};for(const u of t.sessions)r[u.id]=u;const s={};for(const u of t.missions)s[u.id]=u;const o={};for(const u of t.advisors)o[u.id]=u;const a={};for(const u of t.skills)a[u.id]=u;const l={};for(const u of t.schedules)l[u.id]=u;const c={};for(const u of t.goals)c[u.id]=u;n({projects:i,sessions:r,missions:s,advisors:o,skills:a,schedules:l,goals:c});break}case"advisor_upsert":{n(i=>({advisors:{...i.advisors,[t.advisor.id]:t.advisor}}));break}case"skill_upsert":{n(i=>({skills:{...i.skills,[t.skill.id]:t.skill}}));break}case"galaxy_imported":{const i=`${Date.now()}-galaxy`;n(r=>({toasts:[...r.toasts,{id:i,level:"info",message:`Imported galaxy: ${t.manifest.name}`}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}case"session_upsert":{n(i=>({sessions:{...i.sessions,[t.session.id]:t.session}}));break}case"session_remove":{n(i=>{const r={...i.sessions};return delete r[t.sessionId],{sessions:r}});break}case"mission_upsert":{n(i=>({missions:{...i.missions,[t.mission.id]:t.mission}}));break}case"tool_call":{const i={...t.toolCall,receivedAt:Date.now()};n(r=>({recentToolCalls:[...r.recentToolCalls,i].slice(-200)})),setTimeout(()=>{n(r=>({recentToolCalls:r.recentToolCalls.filter(s=>Date.now()-s.receivedAt<Jx)}))},Jx+50);break}case"permission_request":{const i={requestId:t.requestId,sessionId:t.sessionId,tool:t.tool,args:t.args,receivedAt:Date.now()};n(a=>({pendingPermissions:{...a.pendingPermissions,[t.requestId]:i}}));const r=e().sessions[t.sessionId],s=(r==null?void 0:r.name)??t.sessionId.slice(0,8),o=(()=>{const a=Object.keys(t.args)[0];if(!a)return"";const l=t.args[a],c=typeof l=="string"?l:JSON.stringify(l);return`: ${c.length>60?c.slice(0,60)+"…":c}`})();Yx({title:`${s} needs you`,body:`${t.tool}${o}`,tag:`solix-perm-${t.sessionId}`,whenHidden:!0}),qx();break}case"context_update":{n(i=>{const r=i.sessions[t.sessionId];return r?{sessions:{...i.sessions,[t.sessionId]:{...r,contextUsagePct:t.usagePct}}}:i});break}case"cost_update":{n(i=>{const r=i.sessions[t.sessionId];return r?{sessions:{...i.sessions,[t.sessionId]:{...r,costUsd:t.costUsd,budgetUsd:t.budgetUsd??r.budgetUsd}}}:i});break}case"budget_alert":{const i={sessionId:t.sessionId,costUsd:t.costUsd,budgetUsd:t.budgetUsd,receivedAt:Date.now()};n(s=>({budgetAlerts:{...s.budgetAlerts,[t.sessionId]:i}}));const r=e().sessions[t.sessionId];Yx({title:`${(r==null?void 0:r.name)??t.sessionId.slice(0,8)} hit its budget`,body:`$${t.costUsd.toFixed(2)} / $${t.budgetUsd.toFixed(2)}`,tag:`solix-budget-${t.sessionId}`,whenHidden:!0}),qx();break}case"schedule_upsert":{n(i=>({schedules:{...i.schedules,[t.schedule.id]:t.schedule}}));break}case"schedule_remove":{n(i=>{const r={...i.schedules};return delete r[t.scheduleId],{schedules:r}});break}case"goal_upsert":{n(i=>({goals:{...i.goals,[t.goal.id]:t.goal}}));break}case"goal_remove":{n(i=>{const r={...i.goals};return delete r[t.goalId],{goals:r}});break}case"chat_delta":{const i={...t.delta,receivedAt:Date.now()};n(r=>{const a=[...(r.chatBySessionId[t.sessionId]??[]).filter(l=>l.messageId!==i.messageId),i].slice(-200);return{chatBySessionId:{...r.chatBySessionId,[t.sessionId]:a}}});break}case"toast":{const i=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;n(r=>({toasts:[...r.toasts,{id:i,level:t.level,message:t.message}].slice(-6)})),setTimeout(()=>e().dismissToast(i),5e3);break}}},selectSession:t=>n({selectedSessionId:t,selectedAdvisorId:t?null:e().selectedAdvisorId,selectedSkillId:t?null:e().selectedSkillId}),selectAdvisor:t=>n({selectedAdvisorId:t,selectedSessionId:t?null:e().selectedSessionId,selectedSkillId:t?null:e().selectedSkillId}),selectSkill:t=>n({selectedSkillId:t,selectedSessionId:t?null:e().selectedSessionId,selectedAdvisorId:t?null:e().selectedAdvisorId}),dismissToast:t=>n(i=>({toasts:i.toasts.filter(r=>r.id!==t)})),resolvePermission:(t,i)=>{const r=e().send;r({type:"permission_response",requestId:t,approved:i}),n(s=>{const o={...s.pendingPermissions};return delete o[t],{pendingPermissions:o}})},invokeAdvisor:(t,i)=>{const r=e().send,s=e().selectedSessionId??void 0;r({type:"invoke_advisor",advisorId:t,targetSessionId:s,prompt:i})},pinAdvisor:t=>{e().send({type:"pin_advisor",advisorId:t})},unpinAdvisor:t=>{e().send({type:"unpin_advisor",advisorId:t})},enableAdvisor:t=>{e().send({type:"set_advisor_enabled",advisorId:t,enabled:!0})},disableAdvisor:t=>{e().send({type:"set_advisor_enabled",advisorId:t,enabled:!1})},sendPromptTo:(t,i)=>{if(!i.trim())return;e().send({type:"send_prompt",sessionId:t,text:i});const r={messageId:`pending-${Date.now()}`,role:"user",content:i,ts:Date.now(),done:!0,receivedAt:Date.now()};n(s=>({chatBySessionId:{...s.chatBySessionId,[t]:[...s.chatBySessionId[t]??[],r].slice(-200)}}))},launchTask:(t,i,r,s)=>{e().send({type:"launch_session",cwd:t,model:i,initialPrompt:r,worktreeBranch:s==null?void 0:s.worktreeBranch,worktreeBaseRef:s==null?void 0:s.worktreeBaseRef,useAgentView:s==null?void 0:s.useAgentView,agentName:s==null?void 0:s.agentName,budgetUsd:s==null?void 0:s.budgetUsd,goalId:s==null?void 0:s.goalId})},raiseBudget:(t,i)=>{e().send({type:"raise_budget",sessionId:t,budgetUsd:i}),n(r=>{const s={...r.budgetAlerts};return delete s[t],{budgetAlerts:s}})},dismissBudgetAlert:t=>{e().send({type:"dismiss_budget_alert",sessionId:t}),n(i=>{const r={...i.budgetAlerts};return delete r[t],{budgetAlerts:r}})},selectedSessionIds:new Set,toggleSessionSelection:t=>{n(i=>{const r=new Set(i.selectedSessionIds);return r.has(t)?r.delete(t):r.add(t),{selectedSessionIds:r}})},clearSessionSelection:()=>{n({selectedSessionIds:new Set})},terminateSessions:t=>{const i=e().send;for(const r of t)i({type:"terminate_session",sessionId:r});n({selectedSessionIds:new Set})},setMotionEnabled:t=>{Qx(t),n({motionEnabled:t})},toggleMotion:()=>{const t=!e().motionEnabled;Qx(t),n({motionEnabled:t})},setViewMode:t=>{e0(t),n({viewMode:t})},toggleViewMode:()=>{const t=["galaxy","list","missions"],i=e().viewMode,r=t.indexOf(i),s=t[(r+1)%t.length]??"galaxy";e0(s),n({viewMode:s})},enterPlayback:(t,i,r)=>{const s=i;n(o=>({playback:{...o.playback,active:!0,loading:!1,events:t,earliestMs:i,latestMs:r,currentMs:s,playing:!1,...Zx(t,s,e().sessions,e().missions)}}))},exitPlayback:()=>n({playback:Kx}),setPlaybackTime:t=>{n(i=>{const r=Math.max(i.playback.earliestMs,Math.min(t,i.playback.latestMs));return{playback:{...i.playback,currentMs:r,...Zx(i.playback.events,r,e().sessions,e().missions)}}})},setPlaybackSpeed:t=>n(i=>({playback:{...i.playback,speed:t}})),setPlaybackPlaying:t=>n(i=>({playback:{...i.playback,playing:t}})),setPlaybackLoading:t=>n(i=>({playback:{...i.playback,loading:t}})),send:()=>{},attachSocket:t=>n({send:t})}));function Fm(n){return n.playback.active?n.playback.derivedSessions:n.sessions}function sS(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind!=="advisor")}function PE(n){return Object.values(Fm(n)).filter(e=>!e.parentSessionId&&e.kind==="advisor")}function H3(n,e){return Object.values(Fm(n)).filter(t=>t.parentSessionId===e)}function G3(n){return Object.values(n.advisors).filter(e=>e.enabled)}function W3(n){return Object.values(n.advisors).filter(e=>!e.enabled)}function j3(n){return Object.values(n.advisors).sort((e,t)=>e.enabled!==t.enabled?e.enabled?-1:1:e.codename.localeCompare(t.codename))}function X3(n){return Object.values(n.skills)}function $3(n){return Object.values(n.schedules).filter(e=>e.enabled)}function Y3(n){return Object.values(n.goals)}function IE(n){switch(n){case"opus":return"#a855f7";case"sonnet":return"#3b82f6";case"haiku":return"#06b6d4";case"default":return"#94a3b8";default:return"#94a3b8"}}function q3(n){switch(n){case"active":return{color:"#fde68a",intensity:.3};case"awaiting_permission":return{color:"#ef4444",intensity:.5};case"awaiting_input":return{color:"#f59e0b",intensity:.25};case"plan_review":return{color:"#a78bfa",intensity:.2};case"error":return{color:"#dc2626",intensity:.3};case"spawning":return{color:"#ffffff",intensity:.2};case"idle":default:return{color:"#1e293b",intensity:.05}}}function Z3(n){return n>=100?"#dc2626":n>=75?"#f59e0b":"#38bdf8"}function oS(n){switch(n){case"active":return"Active";case"awaiting_permission":return"Permission";case"awaiting_input":return"Awaiting input";case"plan_review":return"Plan review";case"error":return"Error";case"spawning":return"Spawning";case"terminated":return"Terminated";case"idle":default:return"Idle"}}function NE(n,e,t){const i=[];let r=30;switch(n.status){case"error":r=0,i.push("In error state");break;case"plan_review":case"awaiting_input":r=15,i.push(`Status: ${n.status}`);break;case"awaiting_permission":r=12,i.push("Awaiting permission");break;case"terminated":r=5,i.push("Terminated");break;default:r=30}const s=Math.max(0,30-t*15);t>0&&i.push(`${t} pending permission${t===1?"":"s"}`);const a=25*Math.max(0,1-n.contextUsagePct/100);n.contextUsagePct>=90?i.push(`Context at ${n.contextUsagePct.toFixed(0)}%`):n.contextUsagePct>=80&&i.push(`Context warm (${n.contextUsagePct.toFixed(0)}%)`);let l=0;if(e&&e.status==="active"){const u=e.metrics.toolCallCount;l=Math.min(15,u*2)}else e&&e.status==="completed"&&(l=15);return{score:Math.round(Math.max(0,Math.min(100,r+s+a+l))),reasons:i}}function LE(n){return n>=75?"#10b981":n>=50?"#fbbf24":n>=25?"#f97316":"#ef4444"}const Bm={active:"The agent is currently working — emitting tool calls or generating output.",idle:"No mission running. The agent is waiting for the next prompt or has been quiet for a while.",spawning:"The agent process just started. It will transition to active within a second or two.",awaiting_permission:"The agent paused to ask permission for a sensitive tool call. Approve or deny in the Decision Queue.",awaiting_input:"The agent finished what it could and is waiting for your next prompt.",plan_review:"The agent produced a plan and is waiting for your approval before executing.",error:"The agent crashed or hit an unrecoverable error. Look at the SidePanel transcript for details.",terminated:"The agent process exited. No more activity will come from this session.",subagent:"A child agent spawned by another session (typically via the Task tool). Rendered as a moon orbiting the parent planet.",advisor:"A long-lived specialist agent (Compass, Forge, Lumen, Argus, Sentinel, …) with its own AGENT.md describing its role.",pinned:"An advisor that's always running. Pinned advisors orbit close to the sun in the inner ring."},t0={awaiting_permission:0,awaiting_input:1,plan_review:2,error:3,active:4,spawning:5,idle:6,terminated:7};function DE(){const n=xe(sS),e=xe(PE),t=xe(_=>_.projects),i=xe(_=>_.missions),r=xe(_=>_.pendingPermissions),s=xe(_=>_.selectSession),o=xe(_=>_.selectedSessionIds),a=xe(_=>_.toggleSessionSelection),l=xe(_=>_.clearSessionSelection),c=xe(_=>_.terminateSessions),[u,h]=Ae.useState("needs"),[d,p]=Ae.useState("asc"),m=Ae.useMemo(()=>{const _=[...n,...e],C=new Set(Object.values(r).map(w=>w.sessionId));return _.map(w=>{const E=w.currentMissionId?i[w.currentMissionId]:void 0,A=Object.values(r).filter(L=>L.sessionId===w.id).length,{score:b,reasons:M}=NE(w,E,A);return{session:w,project:t[w.projectId],mission:E,needsAttention:C.has(w.id)||w.status==="awaiting_permission"||w.status==="awaiting_input"||w.status==="plan_review",health:b,healthReasons:M}})},[n,e,t,i,r]),x=Ae.useMemo(()=>{var C;const _=new Map;for(const w of m){const E=((C=w.project)==null?void 0:C.id)??"_",A=_.get(E);A?A.rows.push(w):_.set(E,{project:w.project,rows:[w]})}return[..._.values()].sort((w,E)=>{var A,b;return(((A=E.project)==null?void 0:A.lastActiveAt)??0)-(((b=w.project)==null?void 0:b.lastActiveAt)??0)})},[m]),g=(_,C)=>{var E,A;const w=d==="asc"?1:-1;switch(u){case"name":return((_.session.name??_.session.id)>(C.session.name??C.session.id)?1:-1)*w;case"status":return((t0[_.session.status]??99)-(t0[C.session.status]??99))*w;case"progress":return((((E=_.mission)==null?void 0:E.metrics.toolCallCount)??0)-(((A=C.mission)==null?void 0:A.metrics.toolCallCount)??0))*w;case"context":return(_.session.contextUsagePct-C.session.contextUsagePct)*w;case"lastActivity":return(_.session.updatedAt-C.session.updatedAt)*w;case"needs":return _.needsAttention===C.needsAttention?0:_.needsAttention?-1*w:1*w;case"health":return(_.health-C.health)*w}},f=_=>{u===_?p(d==="asc"?"desc":"asc"):(h(_),p(_==="lastActivity"?"desc":"asc"))},v=_=>u!==_?"":d==="asc"?" ▲":" ▼",y=o.size;return S.jsxs("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-20 px-6 z-0",children:[y>0&&S.jsx("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-30 pointer-events-auto",children:S.jsxs("div",{className:"rounded-full border border-solix-accent/60 bg-solix-panel/95 backdrop-blur shadow-2xl px-4 py-2 flex items-center gap-3",children:[S.jsxs("span",{className:"text-xs text-slate-200 font-mono",children:[y," selected"]}),S.jsx("button",{onClick:()=>c([...o]),className:"text-xs px-3 py-1 rounded border border-solix-danger text-solix-danger hover:bg-solix-danger/15",children:"Terminate"}),S.jsx("button",{onClick:l,className:"text-xs text-slate-400 hover:text-slate-200",children:"Clear"})]})}),S.jsxs("div",{className:"max-w-6xl mx-auto",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest mb-3",children:["List view · ",m.length," agent",m.length===1?"":"s"]}),m.length===0?S.jsxs("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:["No agents yet. Run ",S.jsx("code",{children:"claude"})," in any terminal — a row will appear here within a second."]}):x.map(({project:_,rows:C})=>{const w=[...C].sort(g),E=(_==null?void 0:_.name)??"(unassigned)";return S.jsxs("section",{className:"mb-8 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:E}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[C.length," agent",C.length===1?"":"s"]})]}),(_==null?void 0:_.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:_.cwd})]}),S.jsxs("table",{className:"w-full text-sm",children:[S.jsx("thead",{className:"bg-black/30 text-[10px] uppercase tracking-wide text-slate-500",children:S.jsxs("tr",{children:[S.jsx(Ri,{children:S.jsx("input",{type:"checkbox","aria-label":"Select all in project",checked:w.length>0&&w.every(A=>o.has(A.session.id)),onChange:A=>{A.stopPropagation();const b=w.every(M=>o.has(M.session.id));for(const M of w){const L=o.has(M.session.id);(b&&L||!b&&!L)&&a(M.session.id)}},className:"cursor-pointer"})}),S.jsxs(Ri,{onClick:()=>f("needs"),children:["● ",v("needs")]}),S.jsxs(Ri,{onClick:()=>f("name"),children:["Agent",v("name")]}),S.jsx(Ri,{children:"Advisor"}),S.jsxs(Ri,{onClick:()=>f("status"),children:["Status",v("status")]}),S.jsxs(Ri,{onClick:()=>f("health"),numeric:!0,children:["Health",v("health")]}),S.jsxs(Ri,{onClick:()=>f("progress"),children:["Mission · tools",v("progress")]}),S.jsxs(Ri,{onClick:()=>f("context"),numeric:!0,children:["Context",v("context")]}),S.jsxs(Ri,{onClick:()=>f("lastActivity"),numeric:!0,children:["Last activity",v("lastActivity")]})]})}),S.jsx("tbody",{children:w.map(A=>{var b;return S.jsxs("tr",{onClick:()=>s(A.session.id),className:`border-t border-solix-border hover:bg-solix-border/20 cursor-pointer ${A.needsAttention?"bg-solix-danger/5":""} ${o.has(A.session.id)?"bg-solix-accent/5":""}`,children:[S.jsx("td",{className:"px-3 py-2",onClick:M=>M.stopPropagation(),children:S.jsx("input",{type:"checkbox","aria-label":"Select agent",checked:o.has(A.session.id),onChange:()=>a(A.session.id),className:"cursor-pointer"})}),S.jsx("td",{className:"px-3 py-2",children:A.needsAttention?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-danger solix-pulse"}):A.session.status==="active"?S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-solix-ok"}):S.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-slate-600"})}),S.jsx("td",{className:"px-3 py-2",children:S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:IE(A.session.model)},title:String(A.session.model)}),S.jsx("span",{className:"text-slate-100 font-medium",children:A.session.name??A.session.id.slice(0,8)}),A.session.kind==="advisor"&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-amber-300",children:"advisor"}),A.session.origin==="agentview"&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-cyan-300",title:"Background session managed by Anthropic's Agent View",children:"agent"}),A.session.wrapperSocketPath&&S.jsx("span",{className:"text-[9px] uppercase tracking-wide text-solix-accent",title:"Wrapped by `solix run` — UI composer is enabled",children:"wrapped"}),A.session.worktreePath&&S.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded border border-solix-accent/40 text-solix-accent",title:A.session.worktreePath,children:["⌥",UE(A.session.worktreePath)]})]})}),S.jsx("td",{className:"px-3 py-2 text-xs",children:S.jsx(OE,{session:A.session,mission:A.mission})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300",title:Bm[A.session.status]??void 0,children:oS(A.session.status)}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(FE,{score:A.health,reasons:A.healthReasons})}),S.jsx("td",{className:"px-3 py-2 text-xs text-slate-300 truncate max-w-xs",title:A.session.agentViewSummary??((b=A.mission)==null?void 0:b.shortName)??void 0,children:A.session.agentViewSummary?S.jsx("span",{className:"text-slate-100 italic",children:A.session.agentViewSummary}):A.mission?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"text-slate-100",children:A.mission.shortName}),S.jsxs("span",{className:"text-slate-500 ml-1",children:["· ",A.mission.metrics.toolCallCount," tools"]})]}):S.jsx("span",{className:"text-slate-500 italic",children:"idle"})}),S.jsx("td",{className:"px-3 py-2 text-right",children:S.jsx(BE,{pct:A.session.contextUsagePct})}),S.jsx("td",{className:"px-3 py-2 text-right text-[11px] text-slate-500 font-mono",children:zE(A.session.updatedAt)})]},A.session.id)})})]})]},(_==null?void 0:_.id)??"_")})]})]})}function UE(n){const e=n.split("/").filter(Boolean);return e[e.length-1]??n}const kE=/^\[Acting as ([^\s—]+)/;function OE({session:n,mission:e}){var s;const t=xe(o=>o.advisors);let i,r=!1;if(n.advisorRole)i=Object.values(t).find(o=>o.id===n.advisorRole);else if(e!=null&&e.prompt){const o=e.prompt.match(kE),a=(s=o==null?void 0:o[1])==null?void 0:s.toLowerCase();a&&(i=Object.values(t).find(l=>l.codename.toLowerCase()===a),r=!0)}return i?S.jsxs("span",{className:`inline-flex items-center gap-1 ${r?"opacity-60":""}`,title:i.description,children:[S.jsx("span",{style:{color:i.color},children:i.glyph}),S.jsx("span",{className:"text-slate-200",children:i.codename})]}):S.jsx("span",{className:"text-slate-700",children:"—"})}function Ri({children:n,onClick:e,numeric:t}){return S.jsx("th",{onClick:e,className:`px-3 py-2 select-none ${t?"text-right":"text-left"} ${e?"cursor-pointer hover:text-slate-300":""}`,children:n})}function FE({score:n,reasons:e}){const t=LE(n);return S.jsxs("div",{className:"relative inline-flex items-center gap-2 group",children:[S.jsx("span",{className:"text-[11px] font-mono font-bold",style:{color:t},children:n}),S.jsx("div",{className:"w-16 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:"h-full",style:{width:`${Math.max(2,n)}%`,background:t}})}),S.jsxs("div",{className:"pointer-events-none absolute right-0 top-full mt-1 z-50 hidden group-hover:block w-64 rounded border border-solix-border bg-solix-panel/95 backdrop-blur p-2 text-left shadow-xl",children:[S.jsxs("div",{className:"flex items-center justify-between mb-1",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Health"}),S.jsxs("span",{className:"text-xs font-bold",style:{color:t},children:[n,"/100"]})]}),e.length===0?S.jsx("div",{className:"text-[11px] text-slate-400 italic",children:"All four bands healthy: stable status, no pending decisions, context budget, mission progress."}):S.jsx("ul",{className:"space-y-0.5",children:e.map(i=>S.jsxs("li",{className:"text-[11px] text-slate-200 leading-snug",children:["· ",i]},i))})]})]})}function BE({pct:n}){const e=n>=90?"bg-solix-danger":n>=80?"bg-solix-warn":"bg-solix-accent";return S.jsxs("div",{className:"inline-flex items-center gap-2",children:[S.jsxs("span",{className:"text-[11px] text-slate-400 font-mono",children:[n.toFixed(0),"%"]}),S.jsx("div",{className:"w-20 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:`h-full ${e}`,style:{width:`${Math.min(100,n)}%`}})})]})}function zE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const i=Math.floor(t/60);if(i<60)return`${i}m`;const r=Math.floor(i/60);return r<24?`${r}h`:new Date(n).toLocaleDateString()}function VE(){const n=xe(l=>l.missions),e=xe(l=>l.sessions),t=xe(l=>l.projects),i=xe(l=>l.selectSession),[r,s]=Ae.useState("all"),o=Ae.useMemo(()=>{const l=Object.values(n).sort((c,u)=>u.startedAt-c.startedAt);return r==="all"?l:l.filter(c=>c.status===r)},[n,r]),a=Ae.useMemo(()=>{const l=new Map;for(const c of o){const u=e[c.sessionId],h=u?t[u.projectId]:void 0,d=(h==null?void 0:h.id)??"_",p=l.get(d);p?p.missions.push(c):l.set(d,{project:h,missions:[c]})}return[...l.values()].sort((c,u)=>{var h,d;return(((h=u.missions[0])==null?void 0:h.startedAt)??0)-(((d=c.missions[0])==null?void 0:d.startedAt)??0)})},[o,e,t]);return S.jsx("div",{className:"absolute inset-0 overflow-y-auto bg-solix-bg pt-20 pb-8 px-6 z-0",children:S.jsxs("div",{className:"max-w-4xl mx-auto",children:[S.jsxs("div",{className:"flex items-center justify-between mb-3",children:[S.jsxs("div",{className:"text-xs text-slate-500 uppercase tracking-widest",children:["Missions · ",o.length]}),S.jsx("div",{className:"flex items-center gap-1.5",children:["all","active","completed","failed","cancelled"].map(l=>S.jsx("button",{onClick:()=>s(l),className:`text-[10px] px-2 py-0.5 rounded border ${r===l?"bg-solix-accent/15 border-solix-accent text-solix-accent":"border-solix-border text-slate-400 hover:text-slate-200"}`,children:l},l))})]}),o.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic py-12 text-center border border-solix-border rounded",children:"No missions yet. Send a prompt to a Claude Code session and a mission card will appear here."}):a.map(({project:l,missions:c})=>{const u=(l==null?void 0:l.name)??"(unassigned)";return S.jsxs("section",{className:"mb-6 rounded border border-solix-border overflow-hidden",children:[S.jsxs("header",{className:"bg-solix-panel/60 px-4 py-2 flex items-center justify-between",children:[S.jsxs("div",{children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:u}),S.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-slate-500",children:[c.length," mission",c.length===1?"":"s"]})]}),(l==null?void 0:l.cwd)&&S.jsx("span",{className:"text-[10px] font-mono text-slate-500 truncate max-w-[55%]",children:l.cwd})]}),S.jsx("ul",{className:"divide-y divide-solix-border",children:c.map(h=>{const d=e[h.sessionId];return S.jsx("li",{children:S.jsxs("button",{onClick:()=>i(h.sessionId),className:"w-full text-left p-4 hover:bg-solix-border/20 cursor-pointer block",children:[S.jsxs("div",{className:"flex items-start justify-between gap-3",children:[S.jsxs("div",{className:"min-w-0 flex-1",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-sm font-semibold text-slate-100",children:h.shortName}),S.jsx(HE,{status:h.status})]}),S.jsx("div",{className:"mt-1 text-xs text-slate-400 line-clamp-2",children:h.prompt}),h.longSummary&&S.jsx("div",{className:"mt-1 text-xs text-slate-300 italic",children:h.longSummary}),h.status==="failed"&&h.errorSummary&&S.jsxs("div",{className:"mt-1 text-xs text-solix-danger italic line-clamp-2",children:["error: ",h.errorSummary]})]}),S.jsxs("div",{className:"text-right text-[10px] text-slate-500 font-mono whitespace-nowrap",children:[WE(h.startedAt),h.metrics.durationMs!==void 0&&S.jsxs("div",{children:[(h.metrics.durationMs/1e3).toFixed(1),"s"]})]})]}),S.jsxs("div",{className:"mt-2 flex items-center gap-3 text-[10px] text-slate-500",children:[d&&S.jsxs("span",{children:["agent:"," ",S.jsx("span",{className:"text-slate-300",children:d.name??d.id.slice(0,8)})]}),S.jsxs("span",{children:[h.metrics.toolCallCount," tools"]}),S.jsxs("span",{title:Bm.subagent,children:[h.metrics.subagentCount," subagents"]}),S.jsxs("span",{children:[h.filesTouched.length," files"]})]}),h.filesTouched.length>0&&S.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[h.filesTouched.slice(0,6).map(p=>S.jsx("span",{className:"text-[10px] font-mono text-slate-400 bg-black/30 border border-solix-border rounded px-1.5 py-0.5",children:GE(p)},p)),h.filesTouched.length>6&&S.jsxs("span",{className:"text-[10px] text-slate-500",children:["+",h.filesTouched.length-6]})]})]})},h.id)})})]},(l==null?void 0:l.id)??"_")})]})})}function HE({status:n}){const e=n==="active"?"border-solix-warn text-solix-warn":n==="completed"?"border-solix-ok text-solix-ok":n==="failed"?"border-solix-danger text-solix-danger":"border-solix-border text-slate-400";return S.jsx("span",{className:`text-[9px] uppercase tracking-wide px-1.5 py-0.5 rounded border ${e}`,children:n})}function GE(n){const e=n.match(/[^/\\]+\/?$/);return e?e[0].replace(/\/$/,""):n}function WE(n){const e=Date.now()-n;if(e<0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s ago`;const i=Math.floor(t/60);if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:new Date(n).toLocaleDateString()}function jE({onOpenGalaxy:n,onNewTask:e,onOpenTimeline:t,onOpenHelp:i,onOpenCrew:r}={}){const s=xe(h=>h.connected),o=xe(sS),a=xe(h=>h.viewMode),l=xe(h=>h.playback.active),c=xe(h=>h.exitPlayback),u=o.reduce((h,d)=>(d.status==="active"?h.active+=1:d.status==="awaiting_permission"||d.status==="awaiting_input"||d.status==="plan_review"?h.attention+=1:d.status==="idle"&&(h.idle+=1),h),{active:0,idle:0,attention:0});return S.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between p-4 z-40",children:[S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3",children:[S.jsxs("div",{className:"flex items-baseline gap-1.5",children:[S.jsx("div",{className:"text-xl font-bold tracking-widest text-solix-accent",children:"SOLIX"}),S.jsxs("span",{className:"text-[10px] font-mono text-slate-500",title:"Solix v1.9.1 — built into this UI bundle",children:["v","1.9.1"]})]}),S.jsx("div",{className:"hidden md:block text-xs text-slate-400",children:"a solar-system command center"}),S.jsx("div",{className:`ml-1 sm:ml-3 px-2 py-1 rounded text-[10px] border ${s?"border-solix-ok text-solix-ok":"border-solix-danger text-solix-danger solix-pulse"}`,children:s?"CONNECTED":"OFFLINE"}),l&&S.jsxs("button",{onClick:c,className:"ml-2 px-2 py-1 rounded text-[10px] border border-solix-accent text-solix-accent solix-pulse hover:bg-solix-accent/15 cursor-pointer flex items-center gap-1.5",title:"Exit Timeline Playback (Esc)","aria-label":"Exit playback",children:[S.jsx("span",{children:"▸ PLAYBACK"}),S.jsx("span",{className:"opacity-70",children:"· exit ✕"})]})]}),S.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 sm:gap-3 text-xs",children:[S.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[S.jsx(Gh,{label:"active",value:u.active,color:"text-solix-ok"}),S.jsx(Gh,{label:"attention",value:u.attention,color:"text-solix-warn"}),S.jsx(Gh,{label:"idle",value:u.idle,color:"text-slate-400"})]}),S.jsx(XE,{viewMode:a}),t&&S.jsx("button",{onClick:t,className:"hidden sm:inline-block px-2 py-1 rounded bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30",title:"Timeline playback (T)",children:"⏱ Timeline"}),e&&S.jsx("button",{onClick:e,className:"px-2 py-1 rounded bg-solix-ok/15 border border-solix-ok/40 text-solix-ok hover:bg-solix-ok/25",title:"Launch a new Claude Code task (L)",children:"+ Task"}),r&&S.jsx("button",{onClick:r,className:"px-2 py-1 rounded bg-amber-500/15 border border-amber-400/40 text-amber-200 hover:bg-amber-500/25",title:"Crew: view and enable advisors (C)",children:"✦ Crew"}),n&&S.jsx("button",{onClick:n,className:"px-2 py-1 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent hover:bg-solix-accent/25",title:"Galaxy: export and import (G)",children:"⌬ Galaxy"}),i&&S.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-solix-panel border border-solix-border text-slate-300 hover:text-white hover:bg-solix-border/30 text-sm",title:"Help (?)","aria-label":"Help",children:"?"})]})]})}function XE({viewMode:n}){const e=xe(i=>i.setViewMode),t=[{mode:"galaxy",label:"🪐"},{mode:"list",label:"☰"},{mode:"missions",label:"◎"}];return S.jsx("div",{className:"inline-flex rounded border border-solix-border bg-solix-panel overflow-hidden",children:t.map(i=>S.jsxs("button",{onClick:()=>e(i.mode),className:`px-2 py-1 text-xs ${n===i.mode?"bg-solix-border/50 text-white":"text-slate-400 hover:text-slate-100"}`,title:`${i.mode} view (V)`,children:[i.label," ",S.jsx("span",{className:"hidden sm:inline capitalize",children:i.mode})]},i.mode))})}function Gh({label:n,value:e,color:t}){return S.jsxs("div",{className:"px-2 py-1 rounded bg-solix-panel border border-solix-border",children:[S.jsx("span",{className:`font-bold ${t}`,children:e}),S.jsx("span",{className:"ml-1 opacity-60 uppercase tracking-wide",children:n})]})}function $E(){const n=xe(t=>t.toasts),e=xe(t=>t.dismissToast);return S.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex flex-col gap-2 z-30",children:n.map(t=>S.jsx("button",{onClick:()=>e(t.id),className:`pointer-events-auto px-3 py-2 rounded text-xs border max-w-md text-left ${t.level==="error"?"bg-solix-danger/10 border-solix-danger text-solix-danger":t.level==="warn"?"bg-solix-warn/10 border-solix-warn text-solix-warn":"bg-solix-panel border-solix-border text-slate-200"}`,children:t.message},t.id))})}const n0="solix.welcome.dismissed.v1";function YE({onOpenGalaxy:n,forceOpen:e=!1,onClose:t}){const[i,r]=Ae.useState(!1),s=xe(u=>u.advisors),o=xe(u=>Object.keys(u.skills).length),a=xe(u=>Object.keys(u.sessions).length);if(Ae.useEffect(()=>{try{r(localStorage.getItem(n0)==="1")}catch{}},[]),!e&&(i||a>0))return null;const l=()=>{try{localStorage.setItem(n0,"1")}catch{}r(!0),t==null||t()},c=Object.values(s).filter(u=>u.enabled).sort((u,h)=>u.codename.localeCompare(h.codename));return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center pointer-events-none",children:S.jsxs("div",{className:"pointer-events-auto max-w-xl w-full mx-4 rounded-xl border border-solix-accent/40 bg-solix-panel/95 backdrop-blur-md shadow-2xl",children:[S.jsxs("div",{className:"px-6 pt-5 pb-3 border-b border-solix-border",children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"welcome"}),S.jsx("div",{className:"text-2xl font-bold mt-1",children:"Solix — your agent solar system"}),S.jsx("div",{className:"text-sm text-slate-400 mt-1",children:"Mission control for Claude Code. Each agent orbits the sun; each click is a conversation with one of your planets."})]}),S.jsxs("div",{className:"px-6 py-4 space-y-3 text-sm text-slate-300",children:[S.jsx(ta,{n:1,title:"Run a Claude Code session",body:S.jsxs(S.Fragment,{children:["Open a terminal anywhere and run"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude"}),". A planet will appear here within a second."]})}),S.jsx(ta,{n:2,title:"Or seed the demo state",body:S.jsxs(S.Fragment,{children:["In another terminal:"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"solix demo"}),". You'll get a fully populated galaxy — ~30 sessions across 8 projects, all 14 advisors, moons, and live permission flares — without running Claude Code."]})}),S.jsx(ta,{n:3,title:"Meet the advisor crew",body:S.jsxs(S.Fragment,{children:[c.length>0?`${c.length} crew members loaded. Click any in the inner ring to read their role and invoke them on the focused planet.`:"Crew loading…",c.length>0&&S.jsx("ul",{className:"mt-2 space-y-1",children:c.map(u=>S.jsxs("li",{className:"flex items-baseline gap-2",children:[S.jsxs("span",{className:"font-mono text-xs",style:{color:u.color},children:[u.glyph," ",u.codename]}),S.jsx("span",{className:"text-slate-500 text-xs",children:"—"}),S.jsx("span",{className:"text-slate-300 text-xs",children:u.name})]},u.id))})]})}),S.jsx(ta,{n:4,title:"Browse the asteroid belt",body:S.jsxs(S.Fragment,{children:["Each asteroid is a Skill (",o," discovered). Click one to read its SKILL.md and see which advisors require it."]})}),S.jsx(ta,{n:5,title:"Share your galaxy",body:S.jsxs(S.Fragment,{children:["Press"," ",S.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px]",children:"G"})," ","or click ",S.jsx("span",{className:"text-solix-accent",children:"⌬ Galaxy"})," ","in the top bar to export, import, publish, or install a galaxy from a registry."]})})]}),S.jsxs("div",{className:"px-6 pb-3 pt-1",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-widest text-slate-500 mb-1.5",children:"Keyboard shortcuts"}),S.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-slate-400",children:[S.jsx(pi,{k:"V",children:"cycle Galaxy → List → Missions"}),S.jsx(pi,{k:"G",children:"toggle Galaxy panel"}),S.jsx(pi,{k:"L",children:"new task"}),S.jsx(pi,{k:"T",children:"timeline"}),S.jsx(pi,{k:"M",children:"jump to Missions"}),S.jsx(pi,{k:"Y",children:"approve top decision"}),S.jsx(pi,{k:"N",children:"deny top decision"}),S.jsx(pi,{k:"Space",children:"play / pause orbits"}),S.jsx(pi,{k:"?",children:"re-open this help"}),S.jsx(pi,{k:"Esc",children:"close panels / exit playback"})]}),S.jsx("div",{className:"text-[10px] text-slate-500 italic mt-2",children:"If clicks feel stuck, a third-party screen overlay (note-taker, recorder) may be intercepting. Quit it temporarily, or use the shortcuts above."})]}),S.jsxs("div",{className:"px-6 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:()=>{n(),l()},className:"px-3 py-1.5 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent text-xs hover:bg-solix-accent/25",children:"Open Galaxy panel"}),S.jsx("div",{className:"flex-1"}),S.jsxs("span",{className:"text-[10px] font-mono text-slate-500 mr-2",children:["Solix v","1.9.1"]}),S.jsx("button",{onClick:l,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Got it"})]})]})})}function pi({k:n,children:e}){return S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-black/50 border border-solix-border text-[10px] font-mono text-slate-300",children:n}),S.jsx("span",{className:"truncate",children:e})]})}function ta({n,title:e,body:t}){return S.jsxs("div",{className:"flex gap-3",children:[S.jsx("div",{className:"shrink-0 w-6 h-6 rounded-full bg-solix-accent/20 border border-solix-accent/40 text-solix-accent text-xs flex items-center justify-center",children:n}),S.jsxs("div",{children:[S.jsx("div",{className:"text-slate-100 font-medium text-sm",children:e}),S.jsx("div",{className:"text-slate-400 text-xs mt-0.5 leading-relaxed",children:t})]})]})}function qE(n,e,t,i){const r=Wh(i,"command"),s=Wh(i,"file_path"),o=Wh(i,"url");if(t==="Bash"&&r){if(/\brm\s+-rf\b/i.test(r)||/\bsudo\b/i.test(r))return{severity:"danger",text:"Destructive command. Deny unless you have already confirmed the diff."};if(/--no-verify\b/.test(r))return{severity:"warn",text:"Skipping pre-commit hooks. Investigate the failure first."};if(/git\s+push.*--force\b/.test(r))return{severity:"danger",text:"Force-push. Confirm no one else has pushed since."};if(/git\s+push/.test(r)&&/\b(main|master|prod|production)\b/.test(r))return{severity:"warn",text:"Pushing to main/prod. Confirm the diff first."};if(/git\s+reset\s+--hard\b/.test(r))return{severity:"warn",text:"Hard reset will discard uncommitted changes. Stash first if unsure."}}if((t==="Edit"||t==="Write"||t==="MultiEdit")&&s){if(/\.env(\b|\.|\/)|credentials\.json|\.pem$|\.key$/i.test(s))return{severity:"danger",text:"Editing a secrets file. Make sure the agent really needs to."};if(/(^|\/)\.git\//.test(s))return{severity:"warn",text:"Editing inside .git/. Almost certainly a mistake."}}if(t==="WebFetch"&&o){if(/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/.test(o))return null;if(/^http:\/\//.test(o))return{severity:"info",text:"Plain HTTP fetch. OK for known internal hosts."}}return n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Run /compact before continuing.`}:null}function ZE(n,e){return n.status==="error"?{severity:"danger",text:"Session is in error state. Check the chat tab and consider restarting."}:n.contextUsagePct>=90?{severity:"warn",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Compact the conversation before the next prompt.`}:n.contextUsagePct>=80?{severity:"info",text:`Context at ${n.contextUsagePct.toFixed(0)}%. Watch out — output quality drops past 90.`}:e&&e.status==="active"&&e.metrics.toolCallCount===0&&Date.now()-e.startedAt>5*60*1e3?{severity:"info",text:"Active mission with no tool calls in 5+ minutes. Agent may be stuck."}:null}function Wh(n,e){const t=n[e];return typeof t=="string"?t:null}function KE({panelOffsetPx:n=0}={}){const e=xe(x=>x.pendingPermissions),t=xe(x=>x.budgetAlerts),i=xe(x=>x.sessions),r=xe(x=>x.missions),s=xe(x=>x.resolvePermission),o=xe(x=>x.raiseBudget),a=xe(x=>x.dismissBudgetAlert),l=xe(x=>x.selectSession),c=Object.values(e).sort((x,g)=>g.receivedAt-x.receivedAt),u=Object.values(t).sort((x,g)=>g.receivedAt-x.receivedAt),[h,d]=Ae.useState(!1),p=c.length+u.length;Ae.useEffect(()=>{p>0&&d(!1)},[p]);const m=x=>{l(x),d(!0)};return p===0?S.jsx("div",{className:"absolute top-20 z-30 pointer-events-none",style:{right:`${n+16}px`},children:S.jsxs("div",{className:"pointer-events-auto rounded-full border border-solix-border bg-solix-panel/60 backdrop-blur px-3 py-1 text-[10px] text-slate-500 flex items-center gap-2",children:[S.jsx("span",{className:"uppercase tracking-widest",children:"decisions"}),S.jsx("span",{className:"font-bold",children:"0"}),S.jsx("span",{className:"italic opacity-80",children:"— all clear"})]})}):S.jsxs("div",{className:"absolute top-20 z-30 w-80 flex flex-col gap-2 pointer-events-none",style:{right:`${n+16}px`},children:[S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-border bg-solix-panel/85 backdrop-blur px-3 py-2 flex items-center justify-between",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-[10px] uppercase tracking-widest text-slate-400",children:"Decisions"}),S.jsx("span",{className:"text-xs font-bold text-solix-danger",children:p})]}),S.jsx("button",{onClick:()=>d(x=>!x),className:"text-[10px] text-slate-400 hover:text-slate-100",children:h?"show":"hide"})]}),!h&&u.map(x=>{var g;return S.jsx(JE,{name:((g=i[x.sessionId])==null?void 0:g.name)??x.sessionId.slice(0,8),costUsd:x.costUsd,budgetUsd:x.budgetUsd,onRaise:()=>{const f=window.prompt(`New budget cap (USD) for this agent — current $${x.budgetUsd.toFixed(2)}, spent $${x.costUsd.toFixed(2)}:`,(x.budgetUsd*2).toFixed(2)),v=f?parseFloat(f):NaN;Number.isFinite(v)&&v>0&&o(x.sessionId,v)},onDismiss:()=>a(x.sessionId)},`budget-${x.sessionId}`)}),!h&&c.map(x=>{const g=i[x.sessionId],f=g!=null&&g.currentMissionId?r[g.currentMissionId]:void 0;return S.jsx(QE,{session:g,mission:f,tool:x.tool,args:x.args,onApprove:()=>s(x.requestId,!0),onDeny:()=>s(x.requestId,!1),onAsk:()=>m(x.sessionId)},x.requestId)})]})}function JE({name:n,costUsd:e,budgetUsd:t,onRaise:i,onDismiss:r}){return S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-danger bg-solix-danger/10 p-3 backdrop-blur shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-solix-danger",children:n}),S.jsx("div",{className:"text-[10px] uppercase tracking-widest text-solix-danger/80",children:"budget"})]}),S.jsxs("div",{className:"mt-2 text-sm text-slate-100",children:["Budget reached",S.jsxs("span",{className:"ml-1 font-mono text-xs text-slate-300",children:["$",e.toFixed(2)," / $",t.toFixed(2)]})]}),S.jsx("div",{className:"mt-1 text-[11px] text-slate-400 leading-snug",children:"Solix-launched agents won't be sent more prompts until you raise the cap."}),S.jsxs("div",{className:"mt-3 flex gap-1.5",children:[S.jsx("button",{onClick:i,className:"flex-1 py-1.5 rounded bg-solix-ok/20 border border-solix-ok text-solix-ok text-xs hover:bg-solix-ok/30",children:"Raise cap"}),S.jsx("button",{onClick:r,className:"px-2.5 py-1.5 rounded border border-solix-border text-slate-300 text-xs hover:text-white hover:bg-solix-border/30",children:"Dismiss"})]})]})}function QE({session:n,mission:e,tool:t,args:i,onApprove:r,onDeny:s,onAsk:o}){const a=(n==null?void 0:n.name)??(n==null?void 0:n.id.slice(0,8))??"unknown agent",l=n!=null&&n.cwd?iT(n.cwd):"",c=n?qE(n,e,t,i):null;return S.jsxs("div",{className:"pointer-events-auto rounded border border-solix-danger bg-solix-danger/10 p-3 backdrop-blur shadow-lg",children:[S.jsxs("div",{className:"flex items-center justify-between",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-solix-danger",children:a}),l&&S.jsx("div",{className:"text-[10px] text-slate-500 truncate ml-2 max-w-[55%]",children:l})]}),e&&S.jsxs("div",{className:"mt-1 text-[11px] text-slate-400 italic truncate",children:["mission: ",e.shortName]}),S.jsxs("div",{className:"mt-2 text-sm text-slate-100",children:[S.jsx("span",{className:"font-semibold",children:t}),S.jsx("span",{className:"ml-1 text-slate-300 text-xs break-words",children:rT(i)})]}),S.jsx(eT,{tool:t,args:i}),c&&S.jsx(nT,{suggestion:c}),S.jsxs("div",{className:"mt-3 flex gap-1.5",children:[S.jsx("button",{onClick:r,className:"flex-1 py-1.5 rounded bg-solix-ok/20 border border-solix-ok text-solix-ok text-xs hover:bg-solix-ok/30",children:"Approve · Y"}),S.jsx("button",{onClick:s,className:"flex-1 py-1.5 rounded bg-solix-danger/20 border border-solix-danger text-solix-danger text-xs hover:bg-solix-danger/30",children:"Deny · N"}),S.jsx("button",{onClick:o,className:"px-2.5 py-1.5 rounded border border-solix-border text-slate-300 text-xs hover:text-white hover:bg-solix-border/30",title:"Open chat with this agent for context",children:"Ask"})]})]})}function eT({tool:n,args:e}){const[t,i]=Ae.useState(!1);if(n==="Bash"){const r=rr(e,"command")??"",s=rr(e,"description");return r?S.jsxs(jh,{label:"will run",children:[S.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[11px] text-slate-100",children:r}),s&&S.jsx("div",{className:"mt-1 text-[10px] text-slate-500 italic",children:s})]}):null}if(n==="Edit"||n==="NotebookEdit"){const r=rr(e,"file_path")??rr(e,"notebook_path"),s=rr(e,"old_string"),o=rr(e,"new_string");return!r&&!s&&!o?null:S.jsxs(jh,{label:"patch",children:[r&&S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(Xh,{sign:"-",text:s,expanded:t,colorClass:"text-solix-danger bg-solix-danger/10"}),o&&S.jsx(Xh,{sign:"+",text:o,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),($h(s)||$h(o))&&S.jsx("button",{onClick:()=>i(a=>!a),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]})}if(n==="Write"){const r=rr(e,"file_path"),s=rr(e,"content")??"";return r?S.jsxs(jh,{label:"will write",children:[S.jsx("div",{className:"font-mono text-[11px] text-solix-accent break-all",children:r}),s&&S.jsx(Xh,{sign:"+",text:s,expanded:t,colorClass:"text-solix-ok bg-solix-ok/10"}),$h(s)&&S.jsx("button",{onClick:()=>i(o=>!o),className:"mt-1 text-[10px] text-slate-400 hover:text-slate-100",children:t?"collapse":"expand"})]}):null}return null}function jh({label:n,children:e}){return S.jsxs("div",{className:"mt-2 rounded border border-solix-border bg-black/30 px-2 py-1.5",children:[S.jsx("div",{className:"text-[9px] uppercase tracking-wider text-slate-500 mb-1",children:n}),e]})}function Xh({sign:n,text:e,expanded:t,colorClass:i}){const r=t?e:tT(e,240);return S.jsxs("pre",{className:`mt-1 px-1.5 py-1 rounded text-[11px] font-mono whitespace-pre-wrap break-words ${i}`,children:[S.jsx("span",{className:"opacity-50 mr-1",children:n}),r]})}function rr(n,e){const t=n[e];return typeof t=="string"?t:void 0}function $h(n){return!!(n&&n.length>240)}function tT(n,e){if(n.length<=e)return n;const t=Math.floor((e-3)/2);return`${n.slice(0,t)}
|
|
57
57
|
…
|
|
58
58
|
${n.slice(-t)}`}function nT({suggestion:n}){const e=n.severity==="danger"?"text-solix-danger border-solix-danger/40 bg-solix-danger/10":n.severity==="warn"?"text-solix-warn border-solix-warn/40 bg-solix-warn/10":"text-slate-300 border-solix-border bg-black/20";return S.jsxs("div",{className:`mt-2 px-2 py-1 rounded border text-[11px] leading-snug ${e}`,children:[S.jsx("span",{className:"font-semibold mr-1",children:"Suggested:"}),n.text]})}function iT(n){const e=n.match(/[^/\\]+\/?$/);return e?e[0].replace(/\/$/,""):n}function rT(n){const e=Object.keys(n);return e.length?e.slice(0,2).map(i=>{const r=n[i],s=typeof r=="string"?r:JSON.stringify(r);return`${i}=${s.length>40?s.slice(0,40)+"…":s}`}).join(" · "):""}const i0="solix.scenehint.dismissed.v1";function sT(){const n=xe(o=>o.motionEnabled),e=xe(o=>o.viewMode),t=xe(o=>o.toggleMotion),[i,r]=Ae.useState(!0);Ae.useEffect(()=>{try{r(localStorage.getItem(i0)==="1")}catch{}},[]);const s=()=>{try{localStorage.setItem(i0,"1")}catch{}r(!0)};return S.jsxs(S.Fragment,{children:[e==="galaxy"&&!i&&S.jsx("div",{className:"pointer-events-none absolute bottom-4 left-1/2 -translate-x-1/2 z-20",children:S.jsxs("div",{className:"pointer-events-auto rounded-full border border-solix-border bg-solix-panel/85 backdrop-blur px-3 py-1.5 text-[11px] text-slate-300 flex items-center gap-3",children:[S.jsxs("span",{children:[S.jsx("kbd",{className:"px-1 py-0.5 rounded bg-black/40 border border-solix-border text-[10px] mr-1",children:"drag"}),"pan"]}),S.jsxs("span",{children:[S.jsx("kbd",{className:"px-1 py-0.5 rounded bg-black/40 border border-solix-border text-[10px] mr-1",children:"scroll"}),"zoom"]}),S.jsxs("span",{children:[S.jsx("kbd",{className:"px-1 py-0.5 rounded bg-black/40 border border-solix-border text-[10px] mr-1",children:"space"}),"pause"]}),S.jsx("button",{onClick:s,className:"ml-1 text-slate-500 hover:text-slate-100","aria-label":"Dismiss hint",children:"✕"})]})}),S.jsx("div",{className:"pointer-events-none absolute bottom-4 right-4 z-20",children:S.jsx("button",{onClick:t,title:`${n?"Pause":"Play"} orbital motion (Space)`,className:`pointer-events-auto w-10 h-10 rounded-full text-base flex items-center justify-center border backdrop-blur transition-colors ${n?"bg-solix-accent/20 border-solix-accent text-solix-accent":"bg-solix-panel/80 border-solix-border text-slate-300 hover:bg-solix-border/40 hover:text-white"}`,children:n?"⏸":"▶"})})]})}/**
|
|
59
59
|
* @license
|
|
@@ -3897,4 +3897,4 @@ void main() {
|
|
|
3897
3897
|
|
|
3898
3898
|
}`;class mI{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Ct,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ci({vertexShader:fI,fragmentShader:pI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new kt(new Wo(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class gI extends Ti{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,m=null;const x=new mI,g=t.getContextAttributes();let f=null,v=null;const y=[],_=[],C=new Q;let w=null;const E=new Yt;E.layers.enable(1),E.viewport=new ct;const A=new Yt;A.layers.enable(2),A.viewport=new ct;const b=[E,A],M=new yM;M.layers.enable(1),M.layers.enable(2);let L=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let oe=y[X];return oe===void 0&&(oe=new yf,y[X]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(X){let oe=y[X];return oe===void 0&&(oe=new yf,y[X]=oe),oe.getGripSpace()},this.getHand=function(X){let oe=y[X];return oe===void 0&&(oe=new yf,y[X]=oe),oe.getHandSpace()};function B(X){const oe=_.indexOf(X.inputSource);if(oe===-1)return;const ve=y[oe];ve!==void 0&&(ve.update(X.inputSource,X.frame,c||o),ve.dispatchEvent({type:X.type,data:X.inputSource}))}function j(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",j),r.removeEventListener("inputsourceschange",U);for(let X=0;X<y.length;X++){const oe=_[X];oe!==null&&(_[X]=null,y[X].disconnect(oe))}L=null,G=null,x.reset(),e.setRenderTarget(f),p=null,d=null,h=null,r=null,v=null,qe.stop(),i.isPresenting=!1,e.setPixelRatio(w),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){a=X,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(X){if(r=X,r!==null){if(f=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",j),r.addEventListener("inputsourceschange",U),g.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(C),r.renderState.layers===void 0){const oe={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,oe),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new li(p.framebufferWidth,p.framebufferHeight,{format:dn,type:Ei,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let oe=null,ve=null,de=null;g.depth&&(de=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,oe=g.stencil?ws:ps,ve=g.stencil?Ms:Ji);const De={colorFormat:t.RGBA8,depthFormat:de,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(De),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),v=new li(d.textureWidth,d.textureHeight,{format:dn,type:Ei,depthTexture:new rg(d.textureWidth,d.textureHeight,ve,void 0,void 0,void 0,void 0,void 0,void 0,oe),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await r.requestReferenceSpace(a),qe.setContext(r),qe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function U(X){for(let oe=0;oe<X.removed.length;oe++){const ve=X.removed[oe],de=_.indexOf(ve);de>=0&&(_[de]=null,y[de].disconnect(ve))}for(let oe=0;oe<X.added.length;oe++){const ve=X.added[oe];let de=_.indexOf(ve);if(de===-1){for(let He=0;He<y.length;He++)if(He>=_.length){_.push(ve),de=He;break}else if(_[He]===null){_[He]=ve,de=He;break}if(de===-1)break}const De=y[de];De&&De.connect(ve)}}const z=new I,Z=new I;function D(X,oe,ve){z.setFromMatrixPosition(oe.matrixWorld),Z.setFromMatrixPosition(ve.matrixWorld);const de=z.distanceTo(Z),De=oe.projectionMatrix.elements,He=ve.projectionMatrix.elements,Be=De[14]/(De[10]-1),it=De[14]/(De[10]+1),P=(De[9]+1)/De[5],le=(De[9]-1)/De[5],ie=(De[8]-1)/De[0],ge=(He[8]+1)/He[0],Y=Be*ie,Ue=Be*ge,me=de/(-ie+ge),be=me*-ie;if(oe.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(be),X.translateZ(me),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),De[10]===-1)X.projectionMatrix.copy(oe.projectionMatrix),X.projectionMatrixInverse.copy(oe.projectionMatrixInverse);else{const N=Be+me,T=it+me,H=Y-be,ee=Ue+(de-be),J=P*it/T*N,ne=le*it/T*N;X.projectionMatrix.makePerspective(H,ee,J,ne,N,T),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function $(X,oe){oe===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(oe.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;let oe=X.near,ve=X.far;x.texture!==null&&(x.depthNear>0&&(oe=x.depthNear),x.depthFar>0&&(ve=x.depthFar)),M.near=A.near=E.near=oe,M.far=A.far=E.far=ve,(L!==M.near||G!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),L=M.near,G=M.far);const de=X.parent,De=M.cameras;$(M,de);for(let He=0;He<De.length;He++)$(De[He],de);De.length===2?D(M,E,A):M.projectionMatrix.copy(E.projectionMatrix),K(X,M,de)};function K(X,oe,ve){ve===null?X.matrix.copy(oe.matrixWorld):(X.matrix.copy(ve.matrixWorld),X.matrix.invert(),X.matrix.multiply(oe.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(oe.projectionMatrix),X.projectionMatrixInverse.copy(oe.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Uo*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(X){l=X,d!==null&&(d.fixedFoveation=X),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=X)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(M)};let se=null;function Te(X,oe){if(u=oe.getViewerPose(c||o),m=oe,u!==null){const ve=u.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let de=!1;ve.length!==M.cameras.length&&(M.cameras.length=0,de=!0);for(let He=0;He<ve.length;He++){const Be=ve[He];let it=null;if(p!==null)it=p.getViewport(Be);else{const le=h.getViewSubImage(d,Be);it=le.viewport,He===0&&(e.setRenderTargetTextures(v,le.colorTexture,d.ignoreDepthValues?void 0:le.depthStencilTexture),e.setRenderTarget(v))}let P=b[He];P===void 0&&(P=new Yt,P.layers.enable(He),P.viewport=new ct,b[He]=P),P.matrix.fromArray(Be.transform.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale),P.projectionMatrix.fromArray(Be.projectionMatrix),P.projectionMatrixInverse.copy(P.projectionMatrix).invert(),P.viewport.set(it.x,it.y,it.width,it.height),He===0&&(M.matrix.copy(P.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),de===!0&&M.cameras.push(P)}const De=r.enabledFeatures;if(De&&De.includes("depth-sensing")){const He=h.getDepthInformation(ve[0]);He&&He.isValid&&He.texture&&x.init(e,He,r.renderState)}}for(let ve=0;ve<y.length;ve++){const de=_[ve],De=y[ve];de!==null&&De!==void 0&&De.update(de,oe,c||o)}se&&se(X,oe),oe.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:oe}),m=null}const qe=new fM;qe.setAnimationLoop(Te),this.setAnimationLoop=function(X){se=X},this.dispose=function(){}}}const Xr=new On,xI=new ke;function vI(n,e){function t(g,f){g.matrixAutoUpdate===!0&&g.updateMatrix(),f.value.copy(g.matrix)}function i(g,f){f.color.getRGB(g.fogColor.value,cM(n)),f.isFog?(g.fogNear.value=f.near,g.fogFar.value=f.far):f.isFogExp2&&(g.fogDensity.value=f.density)}function r(g,f,v,y,_){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(g,f):f.isMeshToonMaterial?(s(g,f),h(g,f)):f.isMeshPhongMaterial?(s(g,f),u(g,f)):f.isMeshStandardMaterial?(s(g,f),d(g,f),f.isMeshPhysicalMaterial&&p(g,f,_)):f.isMeshMatcapMaterial?(s(g,f),m(g,f)):f.isMeshDepthMaterial?s(g,f):f.isMeshDistanceMaterial?(s(g,f),x(g,f)):f.isMeshNormalMaterial?s(g,f):f.isLineBasicMaterial?(o(g,f),f.isLineDashedMaterial&&a(g,f)):f.isPointsMaterial?l(g,f,v,y):f.isSpriteMaterial?c(g,f):f.isShadowMaterial?(g.color.value.copy(f.color),g.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(g,f){g.opacity.value=f.opacity,f.color&&g.diffuse.value.copy(f.color),f.emissive&&g.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.bumpMap&&(g.bumpMap.value=f.bumpMap,t(f.bumpMap,g.bumpMapTransform),g.bumpScale.value=f.bumpScale,f.side===fn&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,t(f.normalMap,g.normalMapTransform),g.normalScale.value.copy(f.normalScale),f.side===fn&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,t(f.displacementMap,g.displacementMapTransform),g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,g.emissiveMapTransform)),f.specularMap&&(g.specularMap.value=f.specularMap,t(f.specularMap,g.specularMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);const v=e.get(f),y=v.envMap,_=v.envMapRotation;y&&(g.envMap.value=y,Xr.copy(_),Xr.x*=-1,Xr.y*=-1,Xr.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Xr.y*=-1,Xr.z*=-1),g.envMapRotation.value.setFromMatrix4(xI.makeRotationFromEuler(Xr)),g.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,g.aoMapTransform))}function o(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform))}function a(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function l(g,f,v,y){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*v,g.scale.value=y*.5,f.map&&(g.map.value=f.map,t(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function c(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function u(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function h(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function d(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function p(g,f,v){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===fn&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,f){f.matcap&&(g.matcap.value=f.matcap)}function x(g,f){const v=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function yI(n,e,t,i){let r={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,y){const _=y.program;i.uniformBlockBinding(v,_)}function c(v,y){let _=r[v.id];_===void 0&&(m(v),_=u(v),r[v.id]=_,v.addEventListener("dispose",g));const C=y.program;i.updateUBOMapping(v,C);const w=e.render.frame;s[v.id]!==w&&(d(v),s[v.id]=w)}function u(v){const y=h();v.__bindingPointIndex=y;const _=n.createBuffer(),C=v.__size,w=v.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,C,w),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,_),_}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){const y=r[v.id],_=v.uniforms,C=v.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let w=0,E=_.length;w<E;w++){const A=Array.isArray(_[w])?_[w]:[_[w]];for(let b=0,M=A.length;b<M;b++){const L=A[b];if(p(L,w,b,C)===!0){const G=L.__offset,B=Array.isArray(L.value)?L.value:[L.value];let j=0;for(let U=0;U<B.length;U++){const z=B[U],Z=x(z);typeof z=="number"||typeof z=="boolean"?(L.__data[0]=z,n.bufferSubData(n.UNIFORM_BUFFER,G+j,L.__data)):z.isMatrix3?(L.__data[0]=z.elements[0],L.__data[1]=z.elements[1],L.__data[2]=z.elements[2],L.__data[3]=0,L.__data[4]=z.elements[3],L.__data[5]=z.elements[4],L.__data[6]=z.elements[5],L.__data[7]=0,L.__data[8]=z.elements[6],L.__data[9]=z.elements[7],L.__data[10]=z.elements[8],L.__data[11]=0):(z.toArray(L.__data,j),j+=Z.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,G,L.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(v,y,_,C){const w=v.value,E=y+"_"+_;if(C[E]===void 0)return typeof w=="number"||typeof w=="boolean"?C[E]=w:C[E]=w.clone(),!0;{const A=C[E];if(typeof w=="number"||typeof w=="boolean"){if(A!==w)return C[E]=w,!0}else if(A.equals(w)===!1)return A.copy(w),!0}return!1}function m(v){const y=v.uniforms;let _=0;const C=16;for(let E=0,A=y.length;E<A;E++){const b=Array.isArray(y[E])?y[E]:[y[E]];for(let M=0,L=b.length;M<L;M++){const G=b[M],B=Array.isArray(G.value)?G.value:[G.value];for(let j=0,U=B.length;j<U;j++){const z=B[j],Z=x(z),D=_%C,$=D%Z.boundary,K=D+$;_+=$,K!==0&&C-K<Z.storage&&(_+=C-K),G.__data=new Float32Array(Z.storage/Float32Array.BYTES_PER_ELEMENT),G.__offset=_,_+=Z.storage}}}const w=_%C;return w>0&&(_+=C-w),v.__size=_,v.__cache={},this}function x(v){const y={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(y.boundary=4,y.storage=4):v.isVector2?(y.boundary=8,y.storage=8):v.isVector3||v.isColor?(y.boundary=16,y.storage=12):v.isVector4?(y.boundary=16,y.storage=16):v.isMatrix3?(y.boundary=48,y.storage=48):v.isMatrix4?(y.boundary=64,y.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),y}function g(v){const y=v.target;y.removeEventListener("dispose",g);const _=o.indexOf(y.__bindingPointIndex);o.splice(_,1),n.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function f(){for(const v in r)n.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:c,dispose:f}}class _I{constructor(e={}){const{canvas:t=sM(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=o;const p=new Uint32Array(4),m=new Int32Array(4);let x=null,g=null;const f=[],v=[];this.domElement=t,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._outputColorSpace=Hn,this.toneMapping=ji,this.toneMappingExposure=1;const y=this;let _=!1,C=0,w=0,E=null,A=-1,b=null;const M=new ct,L=new ct;let G=null;const B=new _e(0);let j=0,U=t.width,z=t.height,Z=1,D=null,$=null;const K=new ct(0,0,U,z),se=new ct(0,0,U,z);let Te=!1;const qe=new Nl;let X=!1,oe=!1;const ve=new ke,de=new I,De=new ct,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Be=!1;function it(){return E===null?Z:1}let P=i;function le(R,O){return t.getContext(R,O)}try{const R={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Rd}`),t.addEventListener("webglcontextlost",q,!1),t.addEventListener("webglcontextrestored",te,!1),t.addEventListener("webglcontextcreationerror",he,!1),P===null){const O="webgl2";if(P=le(O,R),P===null)throw le(O)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(R){throw console.error("THREE.WebGLRenderer: "+R.message),R}let ie,ge,Y,Ue,me,be,N,T,H,ee,J,ne,Le,pe,Me,We,ae,Se,Je,Ve,Ee,Ge,Ze,vt;function k(){ie=new T2(P),ie.init(),Ge=new vM(P,ie),ge=new _2(P,ie,e,Ge),Y=new sI(P),Ue=new R2(P),me=new $P,be=new dI(P,ie,Y,me,ge,Ge,Ue),N=new M2(y),T=new E2(y),H=new kA(P),Ze=new v2(P,H),ee=new A2(P,H,Ue,Ze),J=new I2(P,ee,H,Ue),Je=new P2(P,ge,be),We=new S2(me),ne=new XP(y,N,T,ie,ge,Ze,We),Le=new vI(y,me),pe=new qP,Me=new tI(ie),Se=new x2(y,N,T,Y,J,d,l),ae=new rI(y,J,ge),vt=new yI(P,Ue,ge,Y),Ve=new y2(P,ie,Ue),Ee=new C2(P,ie,Ue),Ue.programs=ne.programs,y.capabilities=ge,y.extensions=ie,y.properties=me,y.renderLists=pe,y.shadowMap=ae,y.state=Y,y.info=Ue}k();const ce=new gI(y,P);this.xr=ce,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const R=ie.get("WEBGL_lose_context");R&&R.loseContext()},this.forceContextRestore=function(){const R=ie.get("WEBGL_lose_context");R&&R.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(R){R!==void 0&&(Z=R,this.setSize(U,z,!1))},this.getSize=function(R){return R.set(U,z)},this.setSize=function(R,O,V=!0){if(ce.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}U=R,z=O,t.width=Math.floor(R*Z),t.height=Math.floor(O*Z),V===!0&&(t.style.width=R+"px",t.style.height=O+"px"),this.setViewport(0,0,R,O)},this.getDrawingBufferSize=function(R){return R.set(U*Z,z*Z).floor()},this.setDrawingBufferSize=function(R,O,V){U=R,z=O,Z=V,t.width=Math.floor(R*V),t.height=Math.floor(O*V),this.setViewport(0,0,R,O)},this.getCurrentViewport=function(R){return R.copy(M)},this.getViewport=function(R){return R.copy(K)},this.setViewport=function(R,O,V,W){R.isVector4?K.set(R.x,R.y,R.z,R.w):K.set(R,O,V,W),Y.viewport(M.copy(K).multiplyScalar(Z).round())},this.getScissor=function(R){return R.copy(se)},this.setScissor=function(R,O,V,W){R.isVector4?se.set(R.x,R.y,R.z,R.w):se.set(R,O,V,W),Y.scissor(L.copy(se).multiplyScalar(Z).round())},this.getScissorTest=function(){return Te},this.setScissorTest=function(R){Y.setScissorTest(Te=R)},this.setOpaqueSort=function(R){D=R},this.setTransparentSort=function(R){$=R},this.getClearColor=function(R){return R.copy(Se.getClearColor())},this.setClearColor=function(){Se.setClearColor.apply(Se,arguments)},this.getClearAlpha=function(){return Se.getClearAlpha()},this.setClearAlpha=function(){Se.setClearAlpha.apply(Se,arguments)},this.clear=function(R=!0,O=!0,V=!0){let W=0;if(R){let F=!1;if(E!==null){const ue=E.texture.format;F=ue===kd||ue===Ud||ue===Rl}if(F){const ue=E.texture.type,ye=ue===Ei||ue===Ji||ue===Do||ue===Ms||ue===Nd||ue===Ld,Ce=Se.getClearColor(),Re=Se.getClearAlpha(),Fe=Ce.r,ze=Ce.g,Ie=Ce.b;ye?(p[0]=Fe,p[1]=ze,p[2]=Ie,p[3]=Re,P.clearBufferuiv(P.COLOR,0,p)):(m[0]=Fe,m[1]=ze,m[2]=Ie,m[3]=Re,P.clearBufferiv(P.COLOR,0,m))}else W|=P.COLOR_BUFFER_BIT}O&&(W|=P.DEPTH_BUFFER_BIT),V&&(W|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(W)},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(){t.removeEventListener("webglcontextlost",q,!1),t.removeEventListener("webglcontextrestored",te,!1),t.removeEventListener("webglcontextcreationerror",he,!1),pe.dispose(),Me.dispose(),me.dispose(),N.dispose(),T.dispose(),J.dispose(),Ze.dispose(),vt.dispose(),ne.dispose(),ce.dispose(),ce.removeEventListener("sessionstart",hi),ce.removeEventListener("sessionend",Ag),zr.stop()};function q(R){R.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function te(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const R=Ue.autoReset,O=ae.enabled,V=ae.autoUpdate,W=ae.needsUpdate,F=ae.type;k(),Ue.autoReset=R,ae.enabled=O,ae.autoUpdate=V,ae.needsUpdate=W,ae.type=F}function he(R){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function Oe(R){const O=R.target;O.removeEventListener("dispose",Oe),Qe(O)}function Qe(R){It(R),me.remove(R)}function It(R){const O=me.get(R).programs;O!==void 0&&(O.forEach(function(V){ne.releaseProgram(V)}),R.isShaderMaterial&&ne.releaseShaderCache(R))}this.renderBufferDirect=function(R,O,V,W,F,ue){O===null&&(O=He);const ye=F.isMesh&&F.matrixWorld.determinant()<0,Ce=vw(R,O,V,W,F);Y.setMaterial(W,ye);let Re=V.index,Fe=1;if(W.wireframe===!0){if(Re=ee.getWireframeAttribute(V),Re===void 0)return;Fe=2}const ze=V.drawRange,Ie=V.attributes.position;let ot=ze.start*Fe,wt=(ze.start+ze.count)*Fe;ue!==null&&(ot=Math.max(ot,ue.start*Fe),wt=Math.min(wt,(ue.start+ue.count)*Fe)),Re!==null?(ot=Math.max(ot,0),wt=Math.min(wt,Re.count)):Ie!=null&&(ot=Math.max(ot,0),wt=Math.min(wt,Ie.count));const bt=wt-ot;if(bt<0||bt===1/0)return;Ze.setup(F,W,Ce,V,Re);let An,at=Ve;if(Re!==null&&(An=H.get(Re),at=Ee,at.setIndex(An)),F.isMesh)W.wireframe===!0?(Y.setLineWidth(W.wireframeLinewidth*it()),at.setMode(P.LINES)):at.setMode(P.TRIANGLES);else if(F.isLine){let Ne=W.linewidth;Ne===void 0&&(Ne=1),Y.setLineWidth(Ne*it()),F.isLineSegments?at.setMode(P.LINES):F.isLineLoop?at.setMode(P.LINE_LOOP):at.setMode(P.LINE_STRIP)}else F.isPoints?at.setMode(P.POINTS):F.isSprite&&at.setMode(P.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)at.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(ie.get("WEBGL_multi_draw"))at.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Ne=F._multiDrawStarts,Xt=F._multiDrawCounts,lt=F._multiDrawCount,Zn=Re?H.get(Re).bytesPerElement:1,Is=me.get(W).currentProgram.getUniforms();for(let Cn=0;Cn<lt;Cn++)Is.setValue(P,"_gl_DrawID",Cn),at.render(Ne[Cn]/Zn,Xt[Cn])}else if(F.isInstancedMesh)at.renderInstances(ot,bt,F.count);else if(V.isInstancedBufferGeometry){const Ne=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Xt=Math.min(V.instanceCount,Ne);at.renderInstances(ot,bt,Xt)}else at.render(ot,bt)};function jt(R,O,V){R.transparent===!0&&R.side===vi&&R.forceSinglePass===!1?(R.side=fn,R.needsUpdate=!0,Bl(R,O,V),R.side=Zi,R.needsUpdate=!0,Bl(R,O,V),R.side=vi):Bl(R,O,V)}this.compile=function(R,O,V=null){V===null&&(V=R),g=Me.get(V),g.init(O),v.push(g),V.traverseVisible(function(F){F.isLight&&F.layers.test(O.layers)&&(g.pushLight(F),F.castShadow&&g.pushShadow(F))}),R!==V&&R.traverseVisible(function(F){F.isLight&&F.layers.test(O.layers)&&(g.pushLight(F),F.castShadow&&g.pushShadow(F))}),g.setupLights();const W=new Set;return R.traverse(function(F){const ue=F.material;if(ue)if(Array.isArray(ue))for(let ye=0;ye<ue.length;ye++){const Ce=ue[ye];jt(Ce,V,F),W.add(Ce)}else jt(ue,V,F),W.add(ue)}),v.pop(),g=null,W},this.compileAsync=function(R,O,V=null){const W=this.compile(R,O,V);return new Promise(F=>{function ue(){if(W.forEach(function(ye){me.get(ye).currentProgram.isReady()&&W.delete(ye)}),W.size===0){F(R);return}setTimeout(ue,10)}ie.get("KHR_parallel_shader_compile")!==null?ue():setTimeout(ue,10)})};let st=null;function Ci(R){st&&st(R)}function hi(){zr.stop()}function Ag(){zr.start()}const zr=new fM;zr.setAnimationLoop(Ci),typeof self<"u"&&zr.setContext(self),this.setAnimationLoop=function(R){st=R,ce.setAnimationLoop(R),R===null?zr.stop():zr.start()},ce.addEventListener("sessionstart",hi),ce.addEventListener("sessionend",Ag),this.render=function(R,O){if(O!==void 0&&O.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ce.enabled===!0&&ce.isPresenting===!0&&(ce.cameraAutoUpdate===!0&&ce.updateCamera(O),O=ce.getCamera()),R.isScene===!0&&R.onBeforeRender(y,R,O,E),g=Me.get(R,v.length),g.init(O),v.push(g),ve.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),qe.setFromProjectionMatrix(ve),oe=this.localClippingEnabled,X=We.init(this.clippingPlanes,oe),x=pe.get(R,f.length),x.init(),f.push(x),ce.enabled===!0&&ce.isPresenting===!0){const ue=y.xr.getDepthSensingMesh();ue!==null&&dh(ue,O,-1/0,y.sortObjects)}dh(R,O,0,y.sortObjects),x.finish(),y.sortObjects===!0&&x.sort(D,$),Be=ce.enabled===!1||ce.isPresenting===!1||ce.hasDepthSensing()===!1,Be&&Se.addToRenderList(x,R),this.info.render.frame++,X===!0&&We.beginShadows();const V=g.state.shadowsArray;ae.render(V,R,O),X===!0&&We.endShadows(),this.info.autoReset===!0&&this.info.reset();const W=x.opaque,F=x.transmissive;if(g.setupLights(),O.isArrayCamera){const ue=O.cameras;if(F.length>0)for(let ye=0,Ce=ue.length;ye<Ce;ye++){const Re=ue[ye];Rg(W,F,R,Re)}Be&&Se.render(R);for(let ye=0,Ce=ue.length;ye<Ce;ye++){const Re=ue[ye];Cg(x,R,Re,Re.viewport)}}else F.length>0&&Rg(W,F,R,O),Be&&Se.render(R),Cg(x,R,O);E!==null&&(be.updateMultisampleRenderTarget(E),be.updateRenderTargetMipmap(E)),R.isScene===!0&&R.onAfterRender(y,R,O),Ze.resetDefaultState(),A=-1,b=null,v.pop(),v.length>0?(g=v[v.length-1],X===!0&&We.setGlobalState(y.clippingPlanes,g.state.camera)):g=null,f.pop(),f.length>0?x=f[f.length-1]:x=null};function dh(R,O,V,W){if(R.visible===!1)return;if(R.layers.test(O.layers)){if(R.isGroup)V=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update(O);else if(R.isLight)g.pushLight(R),R.castShadow&&g.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||qe.intersectsSprite(R)){W&&De.setFromMatrixPosition(R.matrixWorld).applyMatrix4(ve);const ye=J.update(R),Ce=R.material;Ce.visible&&x.push(R,ye,Ce,V,De.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(!R.frustumCulled||qe.intersectsObject(R))){const ye=J.update(R),Ce=R.material;if(W&&(R.boundingSphere!==void 0?(R.boundingSphere===null&&R.computeBoundingSphere(),De.copy(R.boundingSphere.center)):(ye.boundingSphere===null&&ye.computeBoundingSphere(),De.copy(ye.boundingSphere.center)),De.applyMatrix4(R.matrixWorld).applyMatrix4(ve)),Array.isArray(Ce)){const Re=ye.groups;for(let Fe=0,ze=Re.length;Fe<ze;Fe++){const Ie=Re[Fe],ot=Ce[Ie.materialIndex];ot&&ot.visible&&x.push(R,ye,ot,V,De.z,Ie)}}else Ce.visible&&x.push(R,ye,Ce,V,De.z,null)}}const ue=R.children;for(let ye=0,Ce=ue.length;ye<Ce;ye++)dh(ue[ye],O,V,W)}function Cg(R,O,V,W){const F=R.opaque,ue=R.transmissive,ye=R.transparent;g.setupLightsView(V),X===!0&&We.setGlobalState(y.clippingPlanes,V),W&&Y.viewport(M.copy(W)),F.length>0&&Fl(F,O,V),ue.length>0&&Fl(ue,O,V),ye.length>0&&Fl(ye,O,V),Y.buffers.depth.setTest(!0),Y.buffers.depth.setMask(!0),Y.buffers.color.setMask(!0),Y.setPolygonOffset(!1)}function Rg(R,O,V,W){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[W.id]===void 0&&(g.state.transmissionRenderTarget[W.id]=new li(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")||ie.has("EXT_color_buffer_float")?Ho:Ei,minFilter:yi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:rt.workingColorSpace}));const ue=g.state.transmissionRenderTarget[W.id],ye=W.viewport||M;ue.setSize(ye.z,ye.w);const Ce=y.getRenderTarget();y.setRenderTarget(ue),y.getClearColor(B),j=y.getClearAlpha(),j<1&&y.setClearColor(16777215,.5),y.clear(),Be&&Se.render(V);const Re=y.toneMapping;y.toneMapping=ji;const Fe=W.viewport;if(W.viewport!==void 0&&(W.viewport=void 0),g.setupLightsView(W),X===!0&&We.setGlobalState(y.clippingPlanes,W),Fl(R,V,W),be.updateMultisampleRenderTarget(ue),be.updateRenderTargetMipmap(ue),ie.has("WEBGL_multisampled_render_to_texture")===!1){let ze=!1;for(let Ie=0,ot=O.length;Ie<ot;Ie++){const wt=O[Ie],bt=wt.object,An=wt.geometry,at=wt.material,Ne=wt.group;if(at.side===vi&&bt.layers.test(W.layers)){const Xt=at.side;at.side=fn,at.needsUpdate=!0,Pg(bt,V,W,An,at,Ne),at.side=Xt,at.needsUpdate=!0,ze=!0}}ze===!0&&(be.updateMultisampleRenderTarget(ue),be.updateRenderTargetMipmap(ue))}y.setRenderTarget(Ce),y.setClearColor(B,j),Fe!==void 0&&(W.viewport=Fe),y.toneMapping=Re}function Fl(R,O,V){const W=O.isScene===!0?O.overrideMaterial:null;for(let F=0,ue=R.length;F<ue;F++){const ye=R[F],Ce=ye.object,Re=ye.geometry,Fe=W===null?ye.material:W,ze=ye.group;Ce.layers.test(V.layers)&&Pg(Ce,O,V,Re,Fe,ze)}}function Pg(R,O,V,W,F,ue){R.onBeforeRender(y,O,V,W,F,ue),R.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),F.onBeforeRender(y,O,V,W,R,ue),F.transparent===!0&&F.side===vi&&F.forceSinglePass===!1?(F.side=fn,F.needsUpdate=!0,y.renderBufferDirect(V,O,W,F,R,ue),F.side=Zi,F.needsUpdate=!0,y.renderBufferDirect(V,O,W,F,R,ue),F.side=vi):y.renderBufferDirect(V,O,W,F,R,ue),R.onAfterRender(y,O,V,W,F,ue)}function Bl(R,O,V){O.isScene!==!0&&(O=He);const W=me.get(R),F=g.state.lights,ue=g.state.shadowsArray,ye=F.state.version,Ce=ne.getParameters(R,F.state,ue,O,V),Re=ne.getProgramCacheKey(Ce);let Fe=W.programs;W.environment=R.isMeshStandardMaterial?O.environment:null,W.fog=O.fog,W.envMap=(R.isMeshStandardMaterial?T:N).get(R.envMap||W.environment),W.envMapRotation=W.environment!==null&&R.envMap===null?O.environmentRotation:R.envMapRotation,Fe===void 0&&(R.addEventListener("dispose",Oe),Fe=new Map,W.programs=Fe);let ze=Fe.get(Re);if(ze!==void 0){if(W.currentProgram===ze&&W.lightsStateVersion===ye)return Ng(R,Ce),ze}else Ce.uniforms=ne.getUniforms(R),R.onBeforeCompile(Ce,y),ze=ne.acquireProgram(Ce,Re),Fe.set(Re,ze),W.uniforms=Ce.uniforms;const Ie=W.uniforms;return(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)&&(Ie.clippingPlanes=We.uniform),Ng(R,Ce),W.needsLights=_w(R),W.lightsStateVersion=ye,W.needsLights&&(Ie.ambientLightColor.value=F.state.ambient,Ie.lightProbe.value=F.state.probe,Ie.directionalLights.value=F.state.directional,Ie.directionalLightShadows.value=F.state.directionalShadow,Ie.spotLights.value=F.state.spot,Ie.spotLightShadows.value=F.state.spotShadow,Ie.rectAreaLights.value=F.state.rectArea,Ie.ltc_1.value=F.state.rectAreaLTC1,Ie.ltc_2.value=F.state.rectAreaLTC2,Ie.pointLights.value=F.state.point,Ie.pointLightShadows.value=F.state.pointShadow,Ie.hemisphereLights.value=F.state.hemi,Ie.directionalShadowMap.value=F.state.directionalShadowMap,Ie.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Ie.spotShadowMap.value=F.state.spotShadowMap,Ie.spotLightMatrix.value=F.state.spotLightMatrix,Ie.spotLightMap.value=F.state.spotLightMap,Ie.pointShadowMap.value=F.state.pointShadowMap,Ie.pointShadowMatrix.value=F.state.pointShadowMatrix),W.currentProgram=ze,W.uniformsList=null,ze}function Ig(R){if(R.uniformsList===null){const O=R.currentProgram.getUniforms();R.uniformsList=lu.seqWithValue(O.seq,R.uniforms)}return R.uniformsList}function Ng(R,O){const V=me.get(R);V.outputColorSpace=O.outputColorSpace,V.batching=O.batching,V.batchingColor=O.batchingColor,V.instancing=O.instancing,V.instancingColor=O.instancingColor,V.instancingMorph=O.instancingMorph,V.skinning=O.skinning,V.morphTargets=O.morphTargets,V.morphNormals=O.morphNormals,V.morphColors=O.morphColors,V.morphTargetsCount=O.morphTargetsCount,V.numClippingPlanes=O.numClippingPlanes,V.numIntersection=O.numClipIntersection,V.vertexAlphas=O.vertexAlphas,V.vertexTangents=O.vertexTangents,V.toneMapping=O.toneMapping}function vw(R,O,V,W,F){O.isScene!==!0&&(O=He),be.resetTextureUnits();const ue=O.fog,ye=W.isMeshStandardMaterial?O.environment:null,Ce=E===null?y.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:tr,Re=(W.isMeshStandardMaterial?T:N).get(W.envMap||ye),Fe=W.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,ze=!!V.attributes.tangent&&(!!W.normalMap||W.anisotropy>0),Ie=!!V.morphAttributes.position,ot=!!V.morphAttributes.normal,wt=!!V.morphAttributes.color;let bt=ji;W.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(bt=y.toneMapping);const An=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,at=An!==void 0?An.length:0,Ne=me.get(W),Xt=g.state.lights;if(X===!0&&(oe===!0||R!==b)){const zn=R===b&&W.id===A;We.setState(W,R,zn)}let lt=!1;W.version===Ne.__version?(Ne.needsLights&&Ne.lightsStateVersion!==Xt.state.version||Ne.outputColorSpace!==Ce||F.isBatchedMesh&&Ne.batching===!1||!F.isBatchedMesh&&Ne.batching===!0||F.isBatchedMesh&&Ne.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Ne.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Ne.instancing===!1||!F.isInstancedMesh&&Ne.instancing===!0||F.isSkinnedMesh&&Ne.skinning===!1||!F.isSkinnedMesh&&Ne.skinning===!0||F.isInstancedMesh&&Ne.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Ne.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Ne.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Ne.instancingMorph===!1&&F.morphTexture!==null||Ne.envMap!==Re||W.fog===!0&&Ne.fog!==ue||Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==We.numPlanes||Ne.numIntersection!==We.numIntersection)||Ne.vertexAlphas!==Fe||Ne.vertexTangents!==ze||Ne.morphTargets!==Ie||Ne.morphNormals!==ot||Ne.morphColors!==wt||Ne.toneMapping!==bt||Ne.morphTargetsCount!==at)&&(lt=!0):(lt=!0,Ne.__version=W.version);let Zn=Ne.currentProgram;lt===!0&&(Zn=Bl(W,O,F));let Is=!1,Cn=!1,hh=!1;const Nt=Zn.getUniforms(),nr=Ne.uniforms;if(Y.useProgram(Zn.program)&&(Is=!0,Cn=!0,hh=!0),W.id!==A&&(A=W.id,Cn=!0),Is||b!==R){Nt.setValue(P,"projectionMatrix",R.projectionMatrix),Nt.setValue(P,"viewMatrix",R.matrixWorldInverse);const zn=Nt.map.cameraPosition;zn!==void 0&&zn.setValue(P,de.setFromMatrixPosition(R.matrixWorld)),ge.logarithmicDepthBuffer&&Nt.setValue(P,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),(W.isMeshPhongMaterial||W.isMeshToonMaterial||W.isMeshLambertMaterial||W.isMeshBasicMaterial||W.isMeshStandardMaterial||W.isShaderMaterial)&&Nt.setValue(P,"isOrthographic",R.isOrthographicCamera===!0),b!==R&&(b=R,Cn=!0,hh=!0)}if(F.isSkinnedMesh){Nt.setOptional(P,F,"bindMatrix"),Nt.setOptional(P,F,"bindMatrixInverse");const zn=F.skeleton;zn&&(zn.boneTexture===null&&zn.computeBoneTexture(),Nt.setValue(P,"boneTexture",zn.boneTexture,be))}F.isBatchedMesh&&(Nt.setOptional(P,F,"batchingTexture"),Nt.setValue(P,"batchingTexture",F._matricesTexture,be),Nt.setOptional(P,F,"batchingIdTexture"),Nt.setValue(P,"batchingIdTexture",F._indirectTexture,be),Nt.setOptional(P,F,"batchingColorTexture"),F._colorsTexture!==null&&Nt.setValue(P,"batchingColorTexture",F._colorsTexture,be));const fh=V.morphAttributes;if((fh.position!==void 0||fh.normal!==void 0||fh.color!==void 0)&&Je.update(F,V,Zn),(Cn||Ne.receiveShadow!==F.receiveShadow)&&(Ne.receiveShadow=F.receiveShadow,Nt.setValue(P,"receiveShadow",F.receiveShadow)),W.isMeshGouraudMaterial&&W.envMap!==null&&(nr.envMap.value=Re,nr.flipEnvMap.value=Re.isCubeTexture&&Re.isRenderTargetTexture===!1?-1:1),W.isMeshStandardMaterial&&W.envMap===null&&O.environment!==null&&(nr.envMapIntensity.value=O.environmentIntensity),Cn&&(Nt.setValue(P,"toneMappingExposure",y.toneMappingExposure),Ne.needsLights&&yw(nr,hh),ue&&W.fog===!0&&Le.refreshFogUniforms(nr,ue),Le.refreshMaterialUniforms(nr,W,Z,z,g.state.transmissionRenderTarget[R.id]),lu.upload(P,Ig(Ne),nr,be)),W.isShaderMaterial&&W.uniformsNeedUpdate===!0&&(lu.upload(P,Ig(Ne),nr,be),W.uniformsNeedUpdate=!1),W.isSpriteMaterial&&Nt.setValue(P,"center",F.center),Nt.setValue(P,"modelViewMatrix",F.modelViewMatrix),Nt.setValue(P,"normalMatrix",F.normalMatrix),Nt.setValue(P,"modelMatrix",F.matrixWorld),W.isShaderMaterial||W.isRawShaderMaterial){const zn=W.uniformsGroups;for(let ph=0,Sw=zn.length;ph<Sw;ph++){const Lg=zn[ph];vt.update(Lg,Zn),vt.bind(Lg,Zn)}}return Zn}function yw(R,O){R.ambientLightColor.needsUpdate=O,R.lightProbe.needsUpdate=O,R.directionalLights.needsUpdate=O,R.directionalLightShadows.needsUpdate=O,R.pointLights.needsUpdate=O,R.pointLightShadows.needsUpdate=O,R.spotLights.needsUpdate=O,R.spotLightShadows.needsUpdate=O,R.rectAreaLights.needsUpdate=O,R.hemisphereLights.needsUpdate=O}function _w(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(R,O,V){me.get(R.texture).__webglTexture=O,me.get(R.depthTexture).__webglTexture=V;const W=me.get(R);W.__hasExternalTextures=!0,W.__autoAllocateDepthBuffer=V===void 0,W.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),W.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(R,O){const V=me.get(R);V.__webglFramebuffer=O,V.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(R,O=0,V=0){E=R,C=O,w=V;let W=!0,F=null,ue=!1,ye=!1;if(R){const Re=me.get(R);if(Re.__useDefaultFramebuffer!==void 0)Y.bindFramebuffer(P.FRAMEBUFFER,null),W=!1;else if(Re.__webglFramebuffer===void 0)be.setupRenderTarget(R);else if(Re.__hasExternalTextures)be.rebindTextures(R,me.get(R.texture).__webglTexture,me.get(R.depthTexture).__webglTexture);else if(R.depthBuffer){const Ie=R.depthTexture;if(Re.__boundDepthTexture!==Ie){if(Ie!==null&&me.has(Ie)&&(R.width!==Ie.image.width||R.height!==Ie.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");be.setupDepthRenderbuffer(R)}}const Fe=R.texture;(Fe.isData3DTexture||Fe.isDataArrayTexture||Fe.isCompressedArrayTexture)&&(ye=!0);const ze=me.get(R).__webglFramebuffer;R.isWebGLCubeRenderTarget?(Array.isArray(ze[O])?F=ze[O][V]:F=ze[O],ue=!0):R.samples>0&&be.useMultisampledRTT(R)===!1?F=me.get(R).__webglMultisampledFramebuffer:Array.isArray(ze)?F=ze[V]:F=ze,M.copy(R.viewport),L.copy(R.scissor),G=R.scissorTest}else M.copy(K).multiplyScalar(Z).floor(),L.copy(se).multiplyScalar(Z).floor(),G=Te;if(Y.bindFramebuffer(P.FRAMEBUFFER,F)&&W&&Y.drawBuffers(R,F),Y.viewport(M),Y.scissor(L),Y.setScissorTest(G),ue){const Re=me.get(R.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+O,Re.__webglTexture,V)}else if(ye){const Re=me.get(R.texture),Fe=O||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,Re.__webglTexture,V||0,Fe)}A=-1},this.readRenderTargetPixels=function(R,O,V,W,F,ue,ye){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ce=me.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&ye!==void 0&&(Ce=Ce[ye]),Ce){Y.bindFramebuffer(P.FRAMEBUFFER,Ce);try{const Re=R.texture,Fe=Re.format,ze=Re.type;if(!ge.textureFormatReadable(Fe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ge.textureTypeReadable(ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=R.width-W&&V>=0&&V<=R.height-F&&P.readPixels(O,V,W,F,Ge.convert(Fe),Ge.convert(ze),ue)}finally{const Re=E!==null?me.get(E).__webglFramebuffer:null;Y.bindFramebuffer(P.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(R,O,V,W,F,ue,ye){if(!(R&&R.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ce=me.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&ye!==void 0&&(Ce=Ce[ye]),Ce){Y.bindFramebuffer(P.FRAMEBUFFER,Ce);try{const Re=R.texture,Fe=Re.format,ze=Re.type;if(!ge.textureFormatReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ge.textureTypeReadable(ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(O>=0&&O<=R.width-W&&V>=0&&V<=R.height-F){const Ie=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,Ie),P.bufferData(P.PIXEL_PACK_BUFFER,ue.byteLength,P.STREAM_READ),P.readPixels(O,V,W,F,Ge.convert(Fe),Ge.convert(ze),0),P.flush();const ot=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);await aA(P,ot,4);try{P.bindBuffer(P.PIXEL_PACK_BUFFER,Ie),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,ue)}finally{P.deleteBuffer(Ie),P.deleteSync(ot)}return ue}}finally{const Re=E!==null?me.get(E).__webglFramebuffer:null;Y.bindFramebuffer(P.FRAMEBUFFER,Re)}}},this.copyFramebufferToTexture=function(R,O=null,V=0){R.isTexture!==!0&&(bo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),O=arguments[0]||null,R=arguments[1]);const W=Math.pow(2,-V),F=Math.floor(R.image.width*W),ue=Math.floor(R.image.height*W),ye=O!==null?O.x:0,Ce=O!==null?O.y:0;be.setTexture2D(R,0),P.copyTexSubImage2D(P.TEXTURE_2D,V,0,0,ye,Ce,F,ue),Y.unbindTexture()},this.copyTextureToTexture=function(R,O,V=null,W=null,F=0){R.isTexture!==!0&&(bo("WebGLRenderer: copyTextureToTexture function signature has changed."),W=arguments[0]||null,R=arguments[1],O=arguments[2],F=arguments[3]||0,V=null);let ue,ye,Ce,Re,Fe,ze;V!==null?(ue=V.max.x-V.min.x,ye=V.max.y-V.min.y,Ce=V.min.x,Re=V.min.y):(ue=R.image.width,ye=R.image.height,Ce=0,Re=0),W!==null?(Fe=W.x,ze=W.y):(Fe=0,ze=0);const Ie=Ge.convert(O.format),ot=Ge.convert(O.type);be.setTexture2D(O,0),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,O.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,O.unpackAlignment);const wt=P.getParameter(P.UNPACK_ROW_LENGTH),bt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),An=P.getParameter(P.UNPACK_SKIP_PIXELS),at=P.getParameter(P.UNPACK_SKIP_ROWS),Ne=P.getParameter(P.UNPACK_SKIP_IMAGES),Xt=R.isCompressedTexture?R.mipmaps[F]:R.image;P.pixelStorei(P.UNPACK_ROW_LENGTH,Xt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Xt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Ce),P.pixelStorei(P.UNPACK_SKIP_ROWS,Re),R.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,F,Fe,ze,ue,ye,Ie,ot,Xt.data):R.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,F,Fe,ze,Xt.width,Xt.height,Ie,Xt.data):P.texSubImage2D(P.TEXTURE_2D,F,Fe,ze,ue,ye,Ie,ot,Xt),P.pixelStorei(P.UNPACK_ROW_LENGTH,wt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,bt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,An),P.pixelStorei(P.UNPACK_SKIP_ROWS,at),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Ne),F===0&&O.generateMipmaps&&P.generateMipmap(P.TEXTURE_2D),Y.unbindTexture()},this.copyTextureToTexture3D=function(R,O,V=null,W=null,F=0){R.isTexture!==!0&&(bo("WebGLRenderer: copyTextureToTexture3D function signature has changed."),V=arguments[0]||null,W=arguments[1]||null,R=arguments[2],O=arguments[3],F=arguments[4]||0);let ue,ye,Ce,Re,Fe,ze,Ie,ot,wt;const bt=R.isCompressedTexture?R.mipmaps[F]:R.image;V!==null?(ue=V.max.x-V.min.x,ye=V.max.y-V.min.y,Ce=V.max.z-V.min.z,Re=V.min.x,Fe=V.min.y,ze=V.min.z):(ue=bt.width,ye=bt.height,Ce=bt.depth,Re=0,Fe=0,ze=0),W!==null?(Ie=W.x,ot=W.y,wt=W.z):(Ie=0,ot=0,wt=0);const An=Ge.convert(O.format),at=Ge.convert(O.type);let Ne;if(O.isData3DTexture)be.setTexture3D(O,0),Ne=P.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)be.setTexture2DArray(O,0),Ne=P.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,O.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,O.unpackAlignment);const Xt=P.getParameter(P.UNPACK_ROW_LENGTH),lt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Zn=P.getParameter(P.UNPACK_SKIP_PIXELS),Is=P.getParameter(P.UNPACK_SKIP_ROWS),Cn=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,bt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,bt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Re),P.pixelStorei(P.UNPACK_SKIP_ROWS,Fe),P.pixelStorei(P.UNPACK_SKIP_IMAGES,ze),R.isDataTexture||R.isData3DTexture?P.texSubImage3D(Ne,F,Ie,ot,wt,ue,ye,Ce,An,at,bt.data):O.isCompressedArrayTexture?P.compressedTexSubImage3D(Ne,F,Ie,ot,wt,ue,ye,Ce,An,bt.data):P.texSubImage3D(Ne,F,Ie,ot,wt,ue,ye,Ce,An,at,bt),P.pixelStorei(P.UNPACK_ROW_LENGTH,Xt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,lt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Zn),P.pixelStorei(P.UNPACK_SKIP_ROWS,Is),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Cn),F===0&&O.generateMipmaps&&P.generateMipmap(Ne),Y.unbindTexture()},this.initRenderTarget=function(R){me.get(R).__webglFramebuffer===void 0&&be.setupRenderTarget(R)},this.initTexture=function(R){R.isCubeTexture?be.setTextureCube(R,0):R.isData3DTexture?be.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?be.setTexture2DArray(R,0):be.setTexture2D(R,0),Y.unbindTexture()},this.resetState=function(){C=0,w=0,E=null,Y.reset(),Ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return _i}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Fd?"display-p3":"srgb",t.unpackColorSpace=rt.workingColorSpace===Pl?"display-p3":"srgb"}}class Wd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new _e(e),this.density=t}clone(){return new Wd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class jd{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new _e(e),this.near=t,this.far=i}clone(){return new jd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}let _M=class extends nt{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 On,this.environmentIntensity=1,this.environmentRotation=new On,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}};class Xd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=hl,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Un()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return bo("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}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,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Un()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Un()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(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}}}const an=new I;class bs{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}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,i=this.data.count;t<i;t++)an.fromBufferAttribute(this,t),an.applyMatrix4(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)an.fromBufferAttribute(this,t),an.applyNormalMatrix(e),this.setXYZ(t,an.x,an.y,an.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)an.fromBufferAttribute(this,t),an.transformDirection(e),this.setXYZ(t,an.x,an.y,an.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=un(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Xe(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Xe(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Xe(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Xe(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Xe(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=un(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=un(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=un(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=un(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Xe(t,this.array),i=Xe(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Xe(t,this.array),i=Xe(i,this.array),r=Xe(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Xe(t,this.array),i=Xe(i,this.array),r=Xe(r,this.array),s=Xe(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new ht(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new bs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class ag extends on{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new _e(16777215),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 qs;const aa=new I,Zs=new I,Ks=new I,Js=new Q,la=new Q,SM=new ke,bc=new I,ca=new I,Ec=new I,X0=new Q,_f=new Q,$0=new Q;class MM extends nt{constructor(e=new ag){if(super(),this.isSprite=!0,this.type="Sprite",qs===void 0){qs=new Ye;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Xd(t,5);qs.setIndex([0,1,2,0,2,3]),qs.setAttribute("position",new bs(i,3,0,!1)),qs.setAttribute("uv",new bs(i,2,3,!1))}this.geometry=qs,this.material=e,this.center=new Q(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Zs.setFromMatrixScale(this.matrixWorld),SM.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ks.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Zs.multiplyScalar(-Ks.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const o=this.center;Tc(bc.set(-.5,-.5,0),Ks,o,Zs,r,s),Tc(ca.set(.5,-.5,0),Ks,o,Zs,r,s),Tc(Ec.set(.5,.5,0),Ks,o,Zs,r,s),X0.set(0,0),_f.set(1,0),$0.set(1,1);let a=e.ray.intersectTriangle(bc,ca,Ec,!1,aa);if(a===null&&(Tc(ca.set(-.5,.5,0),Ks,o,Zs,r,s),_f.set(0,1),a=e.ray.intersectTriangle(bc,Ec,ca,!1,aa),a===null))return;const l=e.ray.origin.distanceTo(aa);l<e.near||l>e.far||t.push({distance:l,point:aa.clone(),uv:Nn.getInterpolation(aa,bc,ca,Ec,X0,_f,$0,new Q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Tc(n,e,t,i,r,s){Js.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(la.x=s*Js.x-r*Js.y,la.y=r*Js.x+s*Js.y):la.copy(Js),n.copy(e),n.x+=la.x,n.y+=la.y,n.applyMatrix4(SM)}const Ac=new I,Y0=new I;class wM extends nt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Ac.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(Ac);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ac.setFromMatrixPosition(e.matrixWorld),Y0.setFromMatrixPosition(this.matrixWorld);const i=Ac.distanceTo(Y0)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const q0=new I,Z0=new ct,K0=new ct,SI=new I,J0=new ke,Cc=new I,Sf=new rn,Q0=new ke,Mf=new Go;class bM extends kt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Np,this.bindMatrix=new ke,this.bindMatrixInverse=new ke,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new pn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Cc),this.boundingBox.expandByPoint(Cc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new rn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Cc),this.boundingSphere.expandByPoint(Cc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Sf.copy(this.boundingSphere),Sf.applyMatrix4(r),e.ray.intersectsSphere(Sf)!==!1&&(Q0.copy(r).invert(),Mf.copy(e.ray).applyMatrix4(Q0),!(this.boundingBox!==null&&Mf.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Mf)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new ct,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Np?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===WS?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;Z0.fromBufferAttribute(r.attributes.skinIndex,e),K0.fromBufferAttribute(r.attributes.skinWeight,e),q0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=K0.getComponent(s);if(o!==0){const a=Z0.getComponent(s);J0.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(SI.copy(q0).applyMatrix4(J0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class lg extends nt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class wi extends Ct{constructor(e=null,t=1,i=1,r,s,o,a,l,c=Gt,u=Gt,h,d){super(null,o,a,l,c,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const ev=new ke,MI=new ke;class $d{constructor(e=[],t=[]){this.uuid=Un(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new ke;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:MI;ev.multiplyMatrices(a,t[s]),ev.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new $d(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new wi(t,e,e,dn,Sn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new lg),this.bones.push(o),this.boneInverses.push(new ke().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const o=t[r];e.bones.push(o.uuid);const a=i[r];e.boneInverses.push(a.toArray())}return e}}class Oo extends ht{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Qs=new ke,tv=new ke,Rc=[],nv=new pn,wI=new ke,ua=new kt,da=new rn;class EM extends kt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Oo(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,wI)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new pn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qs),nv.copy(e.boundingBox).applyMatrix4(Qs),this.boundingBox.union(nv)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new rn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qs),da.copy(e.boundingSphere).applyMatrix4(Qs),this.boundingSphere.union(da)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,o=e*s+1;for(let a=0;a<i.length;a++)i[a]=r[o+a]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(ua.geometry=this.geometry,ua.material=this.material,ua.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),da.copy(this.boundingSphere),da.applyMatrix4(i),e.ray.intersectsSphere(da)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Qs),tv.multiplyMatrices(i,Qs),ua.matrixWorld=tv,ua.raycast(e,Rc);for(let o=0,a=Rc.length;o<a;o++){const l=Rc[o];l.instanceId=s,l.object=this,t.push(l)}Rc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Oo(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new wi(new Float32Array(r*this.count),r,this.count,Dd,Sn));const s=this.morphTexture.source.data.data;let o=0;for(let c=0;c<i.length;c++)o+=i[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=r*e;s[l]=a,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function bI(n,e){return n.z-e.z}function EI(n,e){return e.z-n.z}class TI{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const o=r[this.index];s.push(o),this.index++,o.start=e.start,o.count=e.count,o.z=t,o.index=i}reset(){this.list.length=0,this.index=0}}const dr=new ke,wf=new ke,AI=new ke,CI=new _e(1,1,1),iv=new ke,bf=new Nl,Pc=new pn,$r=new rn,ha=new I,rv=new I,RI=new I,Ef=new TI,tn=new kt,Ic=[];function PI(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class TM extends kt{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new Ye,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new wi(t,e,e,dn,Sn);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new wi(t,e,e,Rl,Ji);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new wi(t,e,e,dn,Sn);i.colorSpace=rt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const o=e.getAttribute(s),{array:a,itemSize:l,normalized:c}=o,u=new a.constructor(i*l),h=new ht(u,l,c);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new ht(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new pn);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,dr),this.getBoundingBoxAt(s,Pc).applyMatrix4(dr),e.union(Pc)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new rn);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,dr),this.getBoundingSphereAt(s,$r).applyMatrix4(dr),e.union($r)}}addInstance(e){if(this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");this._drawInfo.push({visible:!0,active:!0,geometryIndex:e});const t=this._drawInfo.length-1,i=this._matricesTexture,r=i.image.data;AI.toArray(r,t*16),i.needsUpdate=!0;const s=this._colorsTexture;return s&&(CI.toArray(s.image.data,t*4),s.needsUpdate=!0),t}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const o=this._reservedRanges,a=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new pn,sphereInitialized:!1,sphere:new rn}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),x=i.getAttribute(p);PI(m,x,l);const g=m.itemSize;for(let f=m.count,v=c;f<v;f++){const y=l+f;for(let _=0;_<g;_++)x.setComponent(y,_,0)}x.needsUpdate=!0,x.addUpdateRange(l*g,c*g)}if(r){const p=a.indexStart;for(let m=0;m<o.count;m++)s.setX(p+m,l+o.getX(m));for(let m=o.count,x=a.indexCount;m<x;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,a.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=r?o.count:d.count,this._visibilityChanged=!0,e}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const o=s.index,a=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let h=c;o&&(h=o.getX(h)),r.expandByPoint(ha.fromBufferAttribute(a,h))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Pc),Pc.getCenter(r.center);const o=s.index,a=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,h=l.start+l.count;u<h;u++){let d=u;o&&(d=o.getX(d)),ha.fromBufferAttribute(a,d),c=Math.max(c,r.center.distanceToSquared(ha))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,o=this.geometry;tn.material=this.material,tn.geometry.index=o.index,tn.geometry.attributes=o.attributes,tn.geometry.boundingBox===null&&(tn.geometry.boundingBox=new pn),tn.geometry.boundingSphere===null&&(tn.geometry.boundingSphere=new rn);for(let a=0,l=i.length;a<l;a++){if(!i[a].visible||!i[a].active)continue;const c=i[a].geometryIndex,u=r[c];tn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,tn.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,tn.geometry.boundingBox),this.getBoundingSphereAt(c,tn.geometry.boundingSphere),tn.raycast(e,Ic);for(let h=0,d=Ic.length;h<d;h++){const p=Ic[h];p.object=this,p.batchId=a,t.push(p)}Ic.length=0}tn.material=null,tn.geometry.index=null,tn.geometry.attributes={},tn.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=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;d&&(iv.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),bf.setFromProjectionMatrix(iv,e.coordinateSystem));let x=0;if(this.sortObjects){wf.copy(this.matrixWorld).invert(),ha.setFromMatrixPosition(i.matrixWorld).applyMatrix4(wf),rv.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(wf);for(let v=0,y=l.length;v<y;v++)if(l[v].visible&&l[v].active){const _=l[v].geometryIndex;this.getMatrixAt(v,dr),this.getBoundingSphereAt(_,$r).applyMatrix4(dr);let C=!1;if(d&&(C=!bf.intersectsSphere($r)),!C){const w=RI.subVectors($r.center,ha).dot(rv);Ef.push(h[_],w,v)}}const g=Ef.list,f=this.customSort;f===null?g.sort(s.transparent?EI:bI):f.call(this,g,i);for(let v=0,y=g.length;v<y;v++){const _=g[v];c[x]=_.start*a,u[x]=_.count,m[x]=_.index,x++}Ef.reset()}else for(let g=0,f=l.length;g<f;g++)if(l[g].visible&&l[g].active){const v=l[g].geometryIndex;let y=!1;if(d&&(this.getMatrixAt(g,dr),this.getBoundingSphereAt(v,$r).applyMatrix4(dr),y=!bf.intersectsSphere($r)),!y){const _=h[v];c[x]=_.start*a,u[x]=_.count,m[x]=g,x++}}p.needsUpdate=!0,this._multiDrawCount=x,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}}class xn extends on{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _e(16777215),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}}const ld=new I,cd=new I,sv=new ke,fa=new Go,Nc=new rn,Tf=new I,ov=new I;class Nr extends nt{constructor(e=new Ye,t=new xn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,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(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)ld.fromBufferAttribute(t,r-1),cd.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=ld.distanceTo(cd);e.setAttribute("lineDistance",new Pe(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Nc.copy(i.boundingSphere),Nc.applyMatrix4(r),Nc.radius+=s,e.ray.intersectsSphere(Nc)===!1)return;sv.copy(r).invert(),fa.copy(e.ray).applyMatrix4(sv);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=i.index,d=i.attributes.position;if(u!==null){const p=Math.max(0,o.start),m=Math.min(u.count,o.start+o.count);for(let x=p,g=m-1;x<g;x+=c){const f=u.getX(x),v=u.getX(x+1),y=Lc(this,e,fa,l,f,v);y&&t.push(y)}if(this.isLineLoop){const x=u.getX(m-1),g=u.getX(p),f=Lc(this,e,fa,l,x,g);f&&t.push(f)}}else{const p=Math.max(0,o.start),m=Math.min(d.count,o.start+o.count);for(let x=p,g=m-1;x<g;x+=c){const f=Lc(this,e,fa,l,x,x+1);f&&t.push(f)}if(this.isLineLoop){const x=Lc(this,e,fa,l,m-1,p);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function Lc(n,e,t,i,r,s){const o=n.geometry.attributes.position;if(ld.fromBufferAttribute(o,r),cd.fromBufferAttribute(o,s),t.distanceSqToSegment(ld,cd,Tf,ov)>i)return;Tf.applyMatrix4(n.matrixWorld);const l=e.ray.origin.distanceTo(Tf);if(!(l<e.near||l>e.far))return{distance:l,point:ov.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}const av=new I,lv=new I;class Ai extends Nr{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)av.fromBufferAttribute(t,r),lv.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+av.distanceTo(lv);e.setAttribute("lineDistance",new Pe(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class AM extends Nr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class cg extends on{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new _e(16777215),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}}const cv=new ke,Fp=new Go,Dc=new rn,Uc=new I;class CM extends nt{constructor(e=new Ye,t=new cg){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,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){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Dc.copy(i.boundingSphere),Dc.applyMatrix4(r),Dc.radius+=s,e.ray.intersectsSphere(Dc)===!1)return;cv.copy(r).invert(),Fp.copy(e.ray).applyMatrix4(cv);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=i.index,h=i.attributes.position;if(c!==null){const d=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let m=d,x=p;m<x;m++){const g=c.getX(m);Uc.fromBufferAttribute(h,g),uv(Uc,g,l,r,e,t,this)}}else{const d=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let m=d,x=p;m<x;m++)Uc.fromBufferAttribute(h,m),uv(Uc,m,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function uv(n,e,t,i,r,s,o){const a=Fp.distanceSqToPoint(n);if(a<t){const l=new I;Fp.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class II extends Ct{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ut,this.magFilter=s!==void 0?s:Ut,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class NI extends Ct{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Gt,this.minFilter=Gt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Yd extends Ct{constructor(e,t,i,r,s,o,a,l,c,u,h,d){super(null,o,a,l,c,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class LI extends Yd{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Xn,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class DI extends Yd{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Ki),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class UI extends Ct{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ui{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const 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;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let a=0,l=s-1,c;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),c=i[r]-o,c<0)a=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===o)return r/(s-1);const u=i[r],d=i[r+1]-u,p=(o-u)/d;return(r+p)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),l=t||(o.isVector2?new Q:new I);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new I,r=[],s=[],o=[],a=new I,l=new ke;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new I)}s[0]=new I,o[0]=new I;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(r[p-1],r[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(At(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(At(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),o[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class qd extends ui{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Q){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const a=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}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(){const 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 RM extends qd{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function ug(){let n=0,e=0,t=0,i=0;function r(s,o,a,l){n=s,e=a,t=-3*s+3*o-2*a-l,i=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){r(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let d=(o-s)/c-(a-s)/(c+u)+(a-o)/u,p=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,p*=u,r(o,a,d,p)},calc:function(s){const o=s*s,a=o*s;return n+e*s+t*o+i*a}}}const kc=new I,Af=new ug,Cf=new ug,Rf=new ug;class PM extends ui{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new I){const i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=r[(a-1)%s]:(kc.subVectors(r[0],r[1]).add(r[0]),c=kc);const h=r[a%s],d=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(kc.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=kc),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),p),x=Math.pow(h.distanceToSquared(d),p),g=Math.pow(d.distanceToSquared(u),p);x<1e-4&&(x=1),m<1e-4&&(m=x),g<1e-4&&(g=x),Af.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,x,g),Cf.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,x,g),Rf.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,x,g)}else this.curveType==="catmullrom"&&(Af.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),Cf.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),Rf.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(Af.calc(l),Cf.calc(l),Rf.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new I().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function dv(n,e,t,i,r){const s=(i-e)*.5,o=(r-t)*.5,a=n*n,l=n*a;return(2*t-2*i+s+o)*l+(-3*t+3*i-2*s-o)*a+s*n+t}function kI(n,e){const t=1-n;return t*t*e}function OI(n,e){return 2*(1-n)*n*e}function FI(n,e){return n*n*e}function Oa(n,e,t,i){return kI(n,e)+OI(n,t)+FI(n,i)}function BI(n,e){const t=1-n;return t*t*t*e}function zI(n,e){const t=1-n;return 3*t*t*n*e}function VI(n,e){return 3*(1-n)*n*n*e}function HI(n,e){return n*n*n*e}function Fa(n,e,t,i,r){return BI(n,e)+zI(n,t)+VI(n,i)+HI(n,r)}class dg extends ui{constructor(e=new Q,t=new Q,i=new Q,r=new Q){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Q){const i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Fa(e,r.x,s.x,o.x,a.x),Fa(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const 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 IM extends ui{constructor(e=new I,t=new I,i=new I,r=new I){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new I){const i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Fa(e,r.x,s.x,o.x,a.x),Fa(e,r.y,s.y,o.y,a.y),Fa(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const 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 hg extends ui{constructor(e=new Q,t=new Q){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Q){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Q){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(){const 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 NM extends ui{constructor(e=new I,t=new I){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new I){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new I){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(){const 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 fg extends ui{constructor(e=new Q,t=new Q,i=new Q){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Q){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Oa(e,r.x,s.x,o.x),Oa(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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 pg extends ui{constructor(e=new I,t=new I,i=new I){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new I){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Oa(e,r.x,s.x,o.x),Oa(e,r.y,s.y,o.y),Oa(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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 mg extends ui{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Q){const i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],c=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return i.set(dv(a,l.x,c.x,u.x,h.x),dv(a,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new Q().fromArray(r))}return this}}var ud=Object.freeze({__proto__:null,ArcCurve:RM,CatmullRomCurve3:PM,CubicBezierCurve:dg,CubicBezierCurve3:IM,EllipseCurve:qd,LineCurve:hg,LineCurve3:NM,QuadraticBezierCurve:fg,QuadraticBezierCurve3:pg,SplineCurve:mg});class LM extends ui{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ud[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const o=r[s]-i,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){const 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;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new ud[r.type]().fromJSON(r))}return this}}class ml extends LM{constructor(e){super(),this.type="Path",this.currentPoint=new Q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new hg(this.currentPoint.clone(),new Q(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new fg(this.currentPoint.clone(),new Q(e,t),new Q(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){const a=new dg(this.currentPoint.clone(),new Q(e,t),new Q(i,r),new Q(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new mg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,o,a,l),this}absellipse(e,t,i,r,s,o,a,l){const c=new qd(e,t,i,r,s,o,a,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Ll extends Ye{constructor(e=[new Q(0,-.5),new Q(.5,0),new Q(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=At(r,0,Math.PI*2);const s=[],o=[],a=[],l=[],c=[],u=1/t,h=new I,d=new Q,p=new I,m=new I,x=new I;let g=0,f=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,f=e[v+1].y-e[v].y,p.x=f*1,p.y=-g,p.z=f*0,x.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(x.x,x.y,x.z);break;default:g=e[v+1].x-e[v].x,f=e[v+1].y-e[v].y,p.x=f*1,p.y=-g,p.z=f*0,m.copy(p),p.x+=x.x,p.y+=x.y,p.z+=x.z,p.normalize(),l.push(p.x,p.y,p.z),x.copy(m)}for(let v=0;v<=t;v++){const y=i+v*u*r,_=Math.sin(y),C=Math.cos(y);for(let w=0;w<=e.length-1;w++){h.x=e[w].x*_,h.y=e[w].y,h.z=e[w].x*C,o.push(h.x,h.y,h.z),d.x=v/t,d.y=w/(e.length-1),a.push(d.x,d.y);const E=l[3*w+0]*_,A=l[3*w+1],b=l[3*w+0]*C;c.push(E,A,b)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){const _=y+v*e.length,C=_,w=_+e.length,E=_+e.length+1,A=_+1;s.push(C,w,A),s.push(E,A,w)}this.setIndex(s),this.setAttribute("position",new Pe(o,3)),this.setAttribute("uv",new Pe(a,2)),this.setAttribute("normal",new Pe(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ll(e.points,e.segments,e.phiStart,e.phiLength)}}class Zd extends Ll{constructor(e=1,t=1,i=4,r=8){const s=new ml;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new Zd(e.radius,e.length,e.capSegments,e.radialSegments)}}class Kd extends Ye{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],o=[],a=[],l=[],c=new I,u=new Q;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Pe(o,3)),this.setAttribute("normal",new Pe(a,3)),this.setAttribute("uv",new Pe(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Xo extends Ye{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let m=0;const x=[],g=i/2;let f=0;v(),o===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new Pe(h,3)),this.setAttribute("normal",new Pe(d,3)),this.setAttribute("uv",new Pe(p,2));function v(){const _=new I,C=new I;let w=0;const E=(t-e)/i;for(let A=0;A<=s;A++){const b=[],M=A/s,L=M*(t-e)+e;for(let G=0;G<=r;G++){const B=G/r,j=B*l+a,U=Math.sin(j),z=Math.cos(j);C.x=L*U,C.y=-M*i+g,C.z=L*z,h.push(C.x,C.y,C.z),_.set(U,E,z).normalize(),d.push(_.x,_.y,_.z),p.push(B,1-M),b.push(m++)}x.push(b)}for(let A=0;A<r;A++)for(let b=0;b<s;b++){const M=x[b][A],L=x[b+1][A],G=x[b+1][A+1],B=x[b][A+1];u.push(M,L,B),u.push(L,G,B),w+=6}c.addGroup(f,w,0),f+=w}function y(_){const C=m,w=new Q,E=new I;let A=0;const b=_===!0?e:t,M=_===!0?1:-1;for(let G=1;G<=r;G++)h.push(0,g*M,0),d.push(0,M,0),p.push(.5,.5),m++;const L=m;for(let G=0;G<=r;G++){const j=G/r*l+a,U=Math.cos(j),z=Math.sin(j);E.x=b*z,E.y=g*M,E.z=b*U,h.push(E.x,E.y,E.z),d.push(0,M,0),w.x=U*.5+.5,w.y=z*.5*M+.5,p.push(w.x,w.y),m++}for(let G=0;G<r;G++){const B=C+G,j=L+G;_===!0?u.push(j,j+1,B):u.push(j+1,j,B),A+=3}c.addGroup(f,A,_===!0?1:2),f+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xo(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Jd extends Xo{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new Jd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fr extends Ye{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],o=[];a(r),c(i),u(),this.setAttribute("position",new Pe(s,3)),this.setAttribute("normal",new Pe(s.slice(),3)),this.setAttribute("uv",new Pe(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){const y=new I,_=new I,C=new I;for(let w=0;w<t.length;w+=3)p(t[w+0],y),p(t[w+1],_),p(t[w+2],C),l(y,_,C,v)}function l(v,y,_,C){const w=C+1,E=[];for(let A=0;A<=w;A++){E[A]=[];const b=v.clone().lerp(_,A/w),M=y.clone().lerp(_,A/w),L=w-A;for(let G=0;G<=L;G++)G===0&&A===w?E[A][G]=b:E[A][G]=b.clone().lerp(M,G/L)}for(let A=0;A<w;A++)for(let b=0;b<2*(w-A)-1;b++){const M=Math.floor(b/2);b%2===0?(d(E[A][M+1]),d(E[A+1][M]),d(E[A][M])):(d(E[A][M+1]),d(E[A+1][M+1]),d(E[A+1][M]))}}function c(v){const y=new I;for(let _=0;_<s.length;_+=3)y.x=s[_+0],y.y=s[_+1],y.z=s[_+2],y.normalize().multiplyScalar(v),s[_+0]=y.x,s[_+1]=y.y,s[_+2]=y.z}function u(){const v=new I;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];const _=g(v)/2/Math.PI+.5,C=f(v)/Math.PI+.5;o.push(_,1-C)}m(),h()}function h(){for(let v=0;v<o.length;v+=6){const y=o[v+0],_=o[v+2],C=o[v+4],w=Math.max(y,_,C),E=Math.min(y,_,C);w>.9&&E<.1&&(y<.2&&(o[v+0]+=1),_<.2&&(o[v+2]+=1),C<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function p(v,y){const _=v*3;y.x=e[_+0],y.y=e[_+1],y.z=e[_+2]}function m(){const v=new I,y=new I,_=new I,C=new I,w=new Q,E=new Q,A=new Q;for(let b=0,M=0;b<s.length;b+=9,M+=6){v.set(s[b+0],s[b+1],s[b+2]),y.set(s[b+3],s[b+4],s[b+5]),_.set(s[b+6],s[b+7],s[b+8]),w.set(o[M+0],o[M+1]),E.set(o[M+2],o[M+3]),A.set(o[M+4],o[M+5]),C.copy(v).add(y).add(_).divideScalar(3);const L=g(C);x(w,M+0,v,L),x(E,M+2,y,L),x(A,M+4,_,L)}}function x(v,y,_,C){C<0&&v.x===1&&(o[y]=v.x-1),_.x===0&&_.z===0&&(o[y]=C/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function f(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fr(e.vertices,e.indices,e.radius,e.details)}}class Qd extends Fr{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[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];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Qd(e.radius,e.detail)}}const Oc=new I,Fc=new I,Pf=new I,Bc=new Nn;class DM extends Ye{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),s=Math.cos(ms*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],h=new Array(3),d={},p=[];for(let m=0;m<l;m+=3){o?(c[0]=o.getX(m),c[1]=o.getX(m+1),c[2]=o.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:x,b:g,c:f}=Bc;if(x.fromBufferAttribute(a,c[0]),g.fromBufferAttribute(a,c[1]),f.fromBufferAttribute(a,c[2]),Bc.getNormal(Pf),h[0]=`${Math.round(x.x*r)},${Math.round(x.y*r)},${Math.round(x.z*r)}`,h[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,h[2]=`${Math.round(f.x*r)},${Math.round(f.y*r)},${Math.round(f.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let v=0;v<3;v++){const y=(v+1)%3,_=h[v],C=h[y],w=Bc[u[v]],E=Bc[u[y]],A=`${_}_${C}`,b=`${C}_${_}`;b in d&&d[b]?(Pf.dot(d[b].normal)<=s&&(p.push(w.x,w.y,w.z),p.push(E.x,E.y,E.z)),d[b]=null):A in d||(d[A]={index0:c[v],index1:c[y],normal:Pf.clone()})}}for(const m in d)if(d[m]){const{index0:x,index1:g}=d[m];Oc.fromBufferAttribute(a,x),Fc.fromBufferAttribute(a,g),p.push(Oc.x,Oc.y,Oc.z),p.push(Fc.x,Fc.y,Fc.z)}this.setAttribute("position",new Pe(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class gs extends ml{constructor(e){super(e),this.uuid=Un(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new ml().fromJSON(r))}return this}}const GI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=UM(n,0,r,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,d,p;if(i&&(s=YI(n,e,s,t)),n.length>80*t){a=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)h=n[m],d=n[m+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-a,u-l),p=p!==0?32767/p:0}return gl(s,o,t,a,l,p,0),o}};function UM(n,e,t,i,r){let s,o;if(r===sN(n,e,t,i)>0)for(s=e;s<t;s+=i)o=hv(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=hv(s,n[s],n[s+1],o);return o&&eh(o,o.next)&&(vl(o),o=o.next),o}function Es(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(eh(t,t.next)||_t(t.prev,t,t.next)===0)){if(vl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function gl(n,e,t,i,r,s,o){if(!n)return;!o&&s&&QI(n,i,r,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?jI(n,i,r,s):WI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),vl(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=XI(Es(n),e,t),gl(n,e,t,i,r,s,2)):o===2&&$I(n,e,t,i,r,s):gl(Es(n),e,t,i,r,s,1);break}}}function WI(n){const e=n.prev,t=n,i=n.next;if(_t(e,t,i)>=0)return!1;const r=e.x,s=t.x,o=i.x,a=e.y,l=t.y,c=i.y,u=r<s?r<o?r:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,d=r>s?r>o?r:o:s>o?s:o,p=a>l?a>c?a:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=p&&xo(r,a,s,l,o,c,m.x,m.y)&&_t(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function jI(n,e,t,i){const r=n.prev,s=n,o=n.next;if(_t(r,s,o)>=0)return!1;const a=r.x,l=s.x,c=o.x,u=r.y,h=s.y,d=o.y,p=a<l?a<c?a:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,x=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,f=Bp(p,m,e,t,i),v=Bp(x,g,e,t,i);let y=n.prevZ,_=n.nextZ;for(;y&&y.z>=f&&_&&_.z<=v;){if(y.x>=p&&y.x<=x&&y.y>=m&&y.y<=g&&y!==r&&y!==o&&xo(a,u,l,h,c,d,y.x,y.y)&&_t(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=p&&_.x<=x&&_.y>=m&&_.y<=g&&_!==r&&_!==o&&xo(a,u,l,h,c,d,_.x,_.y)&&_t(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=f;){if(y.x>=p&&y.x<=x&&y.y>=m&&y.y<=g&&y!==r&&y!==o&&xo(a,u,l,h,c,d,y.x,y.y)&&_t(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=v;){if(_.x>=p&&_.x<=x&&_.y>=m&&_.y<=g&&_!==r&&_!==o&&xo(a,u,l,h,c,d,_.x,_.y)&&_t(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function XI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!eh(r,s)&&kM(r,i,i.next,s)&&xl(r,s)&&xl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),vl(i),vl(i.next),i=n=s),i=i.next}while(i!==n);return Es(i)}function $I(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&nN(o,a)){let l=OM(o,a);o=Es(o,o.next),l=Es(l,l.next),gl(o,e,t,i,r,s,0),gl(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function YI(n,e,t,i){const r=[];let s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:n.length,c=UM(n,a,l,i,!1),c===c.next&&(c.steiner=!0),r.push(tN(c));for(r.sort(qI),s=0;s<r.length;s++)t=ZI(r[s],t);return t}function qI(n,e){return n.x-e.x}function ZI(n,e){const t=KI(n,e);if(!t)return e;const i=OM(t,n);return Es(i,i.next),Es(t,t.next)}function KI(n,e){let t=e,i=-1/0,r;const s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;const a=r,l=r.x,c=r.y;let u=1/0,h;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&xo(o<c?s:i,o,l,c,o<c?i:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),xl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&JI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==a);return r}function JI(n,e){return _t(n.prev,n,e.prev)<0&&_t(e.next,n,n.next)<0}function QI(n,e,t,i){let r=n;do r.z===0&&(r.z=Bp(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,eN(r)}function eN(n){let e,t,i,r,s,o,a,l,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<c&&(a++,i=i.nextZ,!!i);e++);for(l=c;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(o>1);return n}function Bp(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function tN(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function xo(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function nN(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!iN(n,e)&&(xl(n,e)&&xl(e,n)&&rN(n,e)&&(_t(n.prev,n,e.prev)||_t(n,e.prev,e))||eh(n,e)&&_t(n.prev,n,n.next)>0&&_t(e.prev,e,e.next)>0)}function _t(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function eh(n,e){return n.x===e.x&&n.y===e.y}function kM(n,e,t,i){const r=Vc(_t(n,e,t)),s=Vc(_t(n,e,i)),o=Vc(_t(t,i,n)),a=Vc(_t(t,i,e));return!!(r!==s&&o!==a||r===0&&zc(n,t,e)||s===0&&zc(n,i,e)||o===0&&zc(t,n,i)||a===0&&zc(t,e,i))}function zc(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Vc(n){return n>0?1:n<0?-1:0}function iN(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&kM(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function xl(n,e){return _t(n.prev,n,n.next)<0?_t(n,e,n.next)>=0&&_t(n,n.prev,e)>=0:_t(n,e,n.prev)<0||_t(n,n.next,e)<0}function rN(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function OM(n,e){const t=new zp(n.i,n.x,n.y),i=new zp(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function hv(n,e,t,i){const r=new zp(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function vl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function zp(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sN(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}class bi{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return bi.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];fv(e),pv(i,e);let o=e.length;t.forEach(fv);for(let l=0;l<t.length;l++)r.push(o),o+=t[l].length,pv(i,t[l]);const a=GI.triangulate(i,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function fv(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function pv(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class th extends Ye{constructor(e=new gs([new Q(.5,.5),new Q(-.5,.5),new Q(-.5,-.5),new Q(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];o(c)}this.setAttribute("position",new Pe(r,3)),this.setAttribute("uv",new Pe(s,2)),this.computeVertexNormals();function o(a){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const f=t.extrudePath,v=t.UVGenerator!==void 0?t.UVGenerator:oN;let y,_=!1,C,w,E,A;f&&(y=f.getSpacedPoints(u),_=!0,d=!1,C=f.computeFrenetFrames(u,!1),w=new I,E=new I,A=new I),d||(g=0,p=0,m=0,x=0);const b=a.extractPoints(c);let M=b.shape;const L=b.holes;if(!bi.isClockWise(M)){M=M.reverse();for(let P=0,le=L.length;P<le;P++){const ie=L[P];bi.isClockWise(ie)&&(L[P]=ie.reverse())}}const B=bi.triangulateShape(M,L),j=M;for(let P=0,le=L.length;P<le;P++){const ie=L[P];M=M.concat(ie)}function U(P,le,ie){return le||console.error("THREE.ExtrudeGeometry: vec does not exist"),P.clone().addScaledVector(le,ie)}const z=M.length,Z=B.length;function D(P,le,ie){let ge,Y,Ue;const me=P.x-le.x,be=P.y-le.y,N=ie.x-P.x,T=ie.y-P.y,H=me*me+be*be,ee=me*T-be*N;if(Math.abs(ee)>Number.EPSILON){const J=Math.sqrt(H),ne=Math.sqrt(N*N+T*T),Le=le.x-be/J,pe=le.y+me/J,Me=ie.x-T/ne,We=ie.y+N/ne,ae=((Me-Le)*T-(We-pe)*N)/(me*T-be*N);ge=Le+me*ae-P.x,Y=pe+be*ae-P.y;const Se=ge*ge+Y*Y;if(Se<=2)return new Q(ge,Y);Ue=Math.sqrt(Se/2)}else{let J=!1;me>Number.EPSILON?N>Number.EPSILON&&(J=!0):me<-Number.EPSILON?N<-Number.EPSILON&&(J=!0):Math.sign(be)===Math.sign(T)&&(J=!0),J?(ge=-be,Y=me,Ue=Math.sqrt(H)):(ge=me,Y=be,Ue=Math.sqrt(H/2))}return new Q(ge/Ue,Y/Ue)}const $=[];for(let P=0,le=j.length,ie=le-1,ge=P+1;P<le;P++,ie++,ge++)ie===le&&(ie=0),ge===le&&(ge=0),$[P]=D(j[P],j[ie],j[ge]);const K=[];let se,Te=$.concat();for(let P=0,le=L.length;P<le;P++){const ie=L[P];se=[];for(let ge=0,Y=ie.length,Ue=Y-1,me=ge+1;ge<Y;ge++,Ue++,me++)Ue===Y&&(Ue=0),me===Y&&(me=0),se[ge]=D(ie[ge],ie[Ue],ie[me]);K.push(se),Te=Te.concat(se)}for(let P=0;P<g;P++){const le=P/g,ie=p*Math.cos(le*Math.PI/2),ge=m*Math.sin(le*Math.PI/2)+x;for(let Y=0,Ue=j.length;Y<Ue;Y++){const me=U(j[Y],$[Y],ge);de(me.x,me.y,-ie)}for(let Y=0,Ue=L.length;Y<Ue;Y++){const me=L[Y];se=K[Y];for(let be=0,N=me.length;be<N;be++){const T=U(me[be],se[be],ge);de(T.x,T.y,-ie)}}}const qe=m+x;for(let P=0;P<z;P++){const le=d?U(M[P],Te[P],qe):M[P];_?(E.copy(C.normals[0]).multiplyScalar(le.x),w.copy(C.binormals[0]).multiplyScalar(le.y),A.copy(y[0]).add(E).add(w),de(A.x,A.y,A.z)):de(le.x,le.y,0)}for(let P=1;P<=u;P++)for(let le=0;le<z;le++){const ie=d?U(M[le],Te[le],qe):M[le];_?(E.copy(C.normals[P]).multiplyScalar(ie.x),w.copy(C.binormals[P]).multiplyScalar(ie.y),A.copy(y[P]).add(E).add(w),de(A.x,A.y,A.z)):de(ie.x,ie.y,h/u*P)}for(let P=g-1;P>=0;P--){const le=P/g,ie=p*Math.cos(le*Math.PI/2),ge=m*Math.sin(le*Math.PI/2)+x;for(let Y=0,Ue=j.length;Y<Ue;Y++){const me=U(j[Y],$[Y],ge);de(me.x,me.y,h+ie)}for(let Y=0,Ue=L.length;Y<Ue;Y++){const me=L[Y];se=K[Y];for(let be=0,N=me.length;be<N;be++){const T=U(me[be],se[be],ge);_?de(T.x,T.y+y[u-1].y,y[u-1].x+ie):de(T.x,T.y,h+ie)}}}X(),oe();function X(){const P=r.length/3;if(d){let le=0,ie=z*le;for(let ge=0;ge<Z;ge++){const Y=B[ge];De(Y[2]+ie,Y[1]+ie,Y[0]+ie)}le=u+g*2,ie=z*le;for(let ge=0;ge<Z;ge++){const Y=B[ge];De(Y[0]+ie,Y[1]+ie,Y[2]+ie)}}else{for(let le=0;le<Z;le++){const ie=B[le];De(ie[2],ie[1],ie[0])}for(let le=0;le<Z;le++){const ie=B[le];De(ie[0]+z*u,ie[1]+z*u,ie[2]+z*u)}}i.addGroup(P,r.length/3-P,0)}function oe(){const P=r.length/3;let le=0;ve(j,le),le+=j.length;for(let ie=0,ge=L.length;ie<ge;ie++){const Y=L[ie];ve(Y,le),le+=Y.length}i.addGroup(P,r.length/3-P,1)}function ve(P,le){let ie=P.length;for(;--ie>=0;){const ge=ie;let Y=ie-1;Y<0&&(Y=P.length-1);for(let Ue=0,me=u+g*2;Ue<me;Ue++){const be=z*Ue,N=z*(Ue+1),T=le+ge+be,H=le+Y+be,ee=le+Y+N,J=le+ge+N;He(T,H,ee,J)}}}function de(P,le,ie){l.push(P),l.push(le),l.push(ie)}function De(P,le,ie){Be(P),Be(le),Be(ie);const ge=r.length/3,Y=v.generateTopUV(i,r,ge-3,ge-2,ge-1);it(Y[0]),it(Y[1]),it(Y[2])}function He(P,le,ie,ge){Be(P),Be(le),Be(ge),Be(le),Be(ie),Be(ge);const Y=r.length/3,Ue=v.generateSideWallUV(i,r,Y-6,Y-3,Y-2,Y-1);it(Ue[0]),it(Ue[1]),it(Ue[3]),it(Ue[1]),it(Ue[2]),it(Ue[3])}function Be(P){r.push(l[P*3+0]),r.push(l[P*3+1]),r.push(l[P*3+2])}function it(P){s.push(P.x),s.push(P.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return aN(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,o=e.shapes.length;s<o;s++){const a=t[e.shapes[s]];i.push(a)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new ud[r.type]().fromJSON(r)),new th(i,e.options)}}const oN={generateTopUV:function(n,e,t,i,r){const s=e[t*3],o=e[t*3+1],a=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new Q(s,o),new Q(a,l),new Q(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[r*3],p=e[r*3+1],m=e[r*3+2],x=e[s*3],g=e[s*3+1],f=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new Q(o,1-l),new Q(c,1-h),new Q(d,1-m),new Q(x,1-f)]:[new Q(a,1-l),new Q(u,1-h),new Q(p,1-m),new Q(g,1-f)]}};function aN(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class nh extends Fr{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[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];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nh(e.radius,e.detail)}}class Dl extends Fr{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Dl(e.radius,e.detail)}}class ih extends Ye{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);const a=[],l=[],c=[],u=[];let h=e;const d=(t-e)/r,p=new I,m=new Q;for(let x=0;x<=r;x++){for(let g=0;g<=i;g++){const f=s+g/i*o;p.x=h*Math.cos(f),p.y=h*Math.sin(f),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=d}for(let x=0;x<r;x++){const g=x*(i+1);for(let f=0;f<i;f++){const v=f+g,y=v,_=v+i+1,C=v+i+2,w=v+1;a.push(y,_,w),a.push(_,C,w)}}this.setIndex(a),this.setAttribute("position",new Pe(l,3)),this.setAttribute("normal",new Pe(c,3)),this.setAttribute("uv",new Pe(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ih(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class rh extends Ye{constructor(e=new gs([new Q(0,.5),new Q(-.5,-.5),new Q(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(i),this.setAttribute("position",new Pe(r,3)),this.setAttribute("normal",new Pe(s,3)),this.setAttribute("uv",new Pe(o,2));function c(u){const h=r.length/3,d=u.extractPoints(t);let p=d.shape;const m=d.holes;bi.isClockWise(p)===!1&&(p=p.reverse());for(let g=0,f=m.length;g<f;g++){const v=m[g];bi.isClockWise(v)===!0&&(m[g]=v.reverse())}const x=bi.triangulateShape(p,m);for(let g=0,f=m.length;g<f;g++){const v=m[g];p=p.concat(v)}for(let g=0,f=p.length;g<f;g++){const v=p[g];r.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let g=0,f=x.length;g<f;g++){const v=x[g],y=v[0]+h,_=v[1]+h,C=v[2]+h;i.push(y,_,C),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return lN(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const o=t[e.shapes[r]];i.push(o)}return new rh(i,e.curveSegments)}}function lN(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Ul extends Ye{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(o+a,Math.PI);let c=0;const u=[],h=new I,d=new I,p=[],m=[],x=[],g=[];for(let f=0;f<=i;f++){const v=[],y=f/i;let _=0;f===0&&o===0?_=.5/t:f===i&&l===Math.PI&&(_=-.5/t);for(let C=0;C<=t;C++){const w=C/t;h.x=-e*Math.cos(r+w*s)*Math.sin(o+y*a),h.y=e*Math.cos(o+y*a),h.z=e*Math.sin(r+w*s)*Math.sin(o+y*a),m.push(h.x,h.y,h.z),d.copy(h).normalize(),x.push(d.x,d.y,d.z),g.push(w+_,1-y),v.push(c++)}u.push(v)}for(let f=0;f<i;f++)for(let v=0;v<t;v++){const y=u[f][v+1],_=u[f][v],C=u[f+1][v],w=u[f+1][v+1];(f!==0||o>0)&&p.push(y,_,w),(f!==i-1||l<Math.PI)&&p.push(_,C,w)}this.setIndex(p),this.setAttribute("position",new Pe(m,3)),this.setAttribute("normal",new Pe(x,3)),this.setAttribute("uv",new Pe(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ul(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class sh extends Fr{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new sh(e.radius,e.detail)}}class oh extends Ye{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const o=[],a=[],l=[],c=[],u=new I,h=new I,d=new I;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const x=m/r*s,g=p/i*Math.PI*2;h.x=(e+t*Math.cos(g))*Math.cos(x),h.y=(e+t*Math.cos(g))*Math.sin(x),h.z=t*Math.sin(g),a.push(h.x,h.y,h.z),u.x=e*Math.cos(x),u.y=e*Math.sin(x),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const x=(r+1)*p+m-1,g=(r+1)*(p-1)+m-1,f=(r+1)*(p-1)+m,v=(r+1)*p+m;o.push(x,g,v),o.push(g,f,v)}this.setIndex(o),this.setAttribute("position",new Pe(a,3)),this.setAttribute("normal",new Pe(l,3)),this.setAttribute("uv",new Pe(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oh(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class ah extends Ye{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);const a=[],l=[],c=[],u=[],h=new I,d=new I,p=new I,m=new I,x=new I,g=new I,f=new I;for(let y=0;y<=i;++y){const _=y/i*s*Math.PI*2;v(_,s,o,e,p),v(_+.01,s,o,e,m),g.subVectors(m,p),f.addVectors(m,p),x.crossVectors(g,f),f.crossVectors(x,g),x.normalize(),f.normalize();for(let C=0;C<=r;++C){const w=C/r*Math.PI*2,E=-t*Math.cos(w),A=t*Math.sin(w);h.x=p.x+(E*f.x+A*x.x),h.y=p.y+(E*f.y+A*x.y),h.z=p.z+(E*f.z+A*x.z),l.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),c.push(d.x,d.y,d.z),u.push(y/i),u.push(C/r)}}for(let y=1;y<=i;y++)for(let _=1;_<=r;_++){const C=(r+1)*(y-1)+(_-1),w=(r+1)*y+(_-1),E=(r+1)*y+_,A=(r+1)*(y-1)+_;a.push(C,w,A),a.push(w,E,A)}this.setIndex(a),this.setAttribute("position",new Pe(l,3)),this.setAttribute("normal",new Pe(c,3)),this.setAttribute("uv",new Pe(u,2));function v(y,_,C,w,E){const A=Math.cos(y),b=Math.sin(y),M=C/_*y,L=Math.cos(M);E.x=w*(2+L)*.5*A,E.y=w*(2+L)*b*.5,E.z=w*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ah(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class lh extends Ye{constructor(e=new pg(new I(-1,-1,0),new I(-1,1,0),new I(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new I,l=new I,c=new Q;let u=new I;const h=[],d=[],p=[],m=[];x(),this.setIndex(m),this.setAttribute("position",new Pe(h,3)),this.setAttribute("normal",new Pe(d,3)),this.setAttribute("uv",new Pe(p,2));function x(){for(let y=0;y<t;y++)g(y);g(s===!1?t:0),v(),f()}function g(y){u=e.getPointAt(y/t,u);const _=o.normals[y],C=o.binormals[y];for(let w=0;w<=r;w++){const E=w/r*Math.PI*2,A=Math.sin(E),b=-Math.cos(E);l.x=b*_.x+A*C.x,l.y=b*_.y+A*C.y,l.z=b*_.z+A*C.z,l.normalize(),d.push(l.x,l.y,l.z),a.x=u.x+i*l.x,a.y=u.y+i*l.y,a.z=u.z+i*l.z,h.push(a.x,a.y,a.z)}}function f(){for(let y=1;y<=t;y++)for(let _=1;_<=r;_++){const C=(r+1)*(y-1)+(_-1),w=(r+1)*y+(_-1),E=(r+1)*y+_,A=(r+1)*(y-1)+_;m.push(C,w,A),m.push(w,E,A)}}function v(){for(let y=0;y<=t;y++)for(let _=0;_<=r;_++)c.x=y/t,c.y=_/r,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new lh(new ud[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class FM extends Ye{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new I,s=new I;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let m=d,x=d+p;m<x;m+=3)for(let g=0;g<3;g++){const f=a.getX(m+g),v=a.getX(m+(g+1)%3);r.fromBufferAttribute(o,f),s.fromBufferAttribute(o,v),mv(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,h=3*a+(c+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),mv(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Pe(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function mv(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var gv=Object.freeze({__proto__:null,BoxGeometry:Cs,CapsuleGeometry:Zd,CircleGeometry:Kd,ConeGeometry:Jd,CylinderGeometry:Xo,DodecahedronGeometry:Qd,EdgesGeometry:DM,ExtrudeGeometry:th,IcosahedronGeometry:nh,LatheGeometry:Ll,OctahedronGeometry:Dl,PlaneGeometry:Wo,PolyhedronGeometry:Fr,RingGeometry:ih,ShapeGeometry:rh,SphereGeometry:Ul,TetrahedronGeometry:sh,TorusGeometry:oh,TorusKnotGeometry:ah,TubeGeometry:lh,WireframeGeometry:FM});class BM extends on{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new _e(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 zM extends ci{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class gg extends on{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new _e(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new Q(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 On,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 VM extends gg{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 Q(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return At(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new _e(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 _e(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new _e(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 HM extends on{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _e(16777215),this.specular=new _e(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=Cl,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 GM extends on{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new _e(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new Q(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 WM extends on{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new Q(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 jM extends on{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new _e(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=Cl,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 XM extends on{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new _e(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.flatShading=e.flatShading,this.fog=e.fog,this}}class $M extends xn{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 us(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function YM(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function qM(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Vp(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=n[a+l]}return r}function xg(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function cN(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){h.push(c.times[p]);for(let x=0;x<u;++x)d.push(c.values[p*u+x])}}h.length!==0&&(c.times=us(h,c.times.constructor),c.values=us(d,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s}function uN(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){const a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(f){return f.name===a.name&&f.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const m=a.times.length-1;let x;if(s<=a.times[0]){const f=u,v=h-u;x=a.values.slice(f,v)}else if(s>=a.times[m]){const f=m*h+u,v=f+h-u;x=a.values.slice(f,v)}else{const f=a.createInterpolant(),v=u,y=h-u;f.evaluate(s),x=f.resultBuffer.slice(v,y)}l==="quaternion"&&new En().fromArray(x).normalize().conjugate().toArray(x);const g=c.times.length;for(let f=0;f<g;++f){const v=f*p+d;if(l==="quaternion")En.multiplyQuaternionsFlat(c.values,v,x,0,c.values,v);else{const y=p-d*2;for(let _=0;_<y;++_)c.values[v+_]-=x[_]}}}return n.blendMode=Km,n}const dN={convertArray:us,isTypedArray:YM,getKeyframeOrder:qM,sortedArray:Vp,flattenJSON:xg,subclip:cN,makeClipAdditive:uN};class kl{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){const a=t[1];e<a&&(i=2,s=a);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){const a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ZM extends kl{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:as,endingEnd:as}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,o=e+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case ls:s=e,a=2*t-i;break;case ll:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(l===void 0)switch(this.getSettings_().endingEnd){case ls:o=e,l=2*i-t;break;case ll:o=1,l=i+r[1]-r[0];break;default:o=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),x=m*m,g=x*m,f=-d*g+2*d*x-d*m,v=(1+d)*g+(-1.5-2*d)*x+(-.5+d)*m+1,y=(-1-p)*g+(1.5+p)*x+.5*m,_=p*g-p*x;for(let C=0;C!==a;++C)s[C]=f*o[u+C]+v*o[c+C]+y*o[l+C]+_*o[h+C];return s}}class vg extends kl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(i-t)/(r-t),h=1-u;for(let d=0;d!==a;++d)s[d]=o[c+d]*h+o[l+d]*u;return s}}class KM extends kl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class di{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=us(t,this.TimeBufferType),this.values=us(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:us(e.times,Array),values:us(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new KM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new vg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ZM(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case al:t=this.InterpolantFactoryMethodDiscrete;break;case ad:t=this.InterpolantFactoryMethodLinear;break;case au:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return al;case this.InterpolantFactoryMethodLinear:return ad;case this.InterpolantFactoryMethodSmooth:return au}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&YM(r))for(let a=0,l=r.length;a!==l;++a){const c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===au,s=e.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(r)l=!0;else{const h=a*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){const x=t[h+m];if(x!==t[d+m]||x!==t[p+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const h=a*i,d=o*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}di.prototype.TimeBufferType=Float32Array;di.prototype.ValueBufferType=Float32Array;di.prototype.DefaultInterpolation=ad;class Rs extends di{constructor(e,t,i){super(e,t,i)}}Rs.prototype.ValueTypeName="bool";Rs.prototype.ValueBufferType=Array;Rs.prototype.DefaultInterpolation=al;Rs.prototype.InterpolantFactoryMethodLinear=void 0;Rs.prototype.InterpolantFactoryMethodSmooth=void 0;class yg extends di{}yg.prototype.ValueTypeName="color";class yl extends di{}yl.prototype.ValueTypeName="number";class JM extends kl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(r-t);let c=e*a;for(let u=c+a;c!==u;c+=4)En.slerpFlat(s,0,o,c-a,o,c,l);return s}}class Ol extends di{InterpolantFactoryMethodLinear(e){return new JM(this.times,this.values,this.getValueSize(),e)}}Ol.prototype.ValueTypeName="quaternion";Ol.prototype.InterpolantFactoryMethodSmooth=void 0;class Ps extends di{constructor(e,t,i){super(e,t,i)}}Ps.prototype.ValueTypeName="string";Ps.prototype.ValueBufferType=Array;Ps.prototype.DefaultInterpolation=al;Ps.prototype.InterpolantFactoryMethodLinear=void 0;Ps.prototype.InterpolantFactoryMethodSmooth=void 0;class _l extends di{}_l.prototype.ValueTypeName="vector";class Sl{constructor(e="",t=-1,i=[],r=Od){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Un(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(fN(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(di.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const u=qM(l);l=Vp(l,1,u),c=Vp(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new yl(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let d=r[h];d||(r[h]=d=[]),d.push(c)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(h,d,p,m,x){if(p.length!==0){const g=[],f=[];xg(p,g,f,m),g.length!==0&&x.push(new h(d,g,f))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let x=0;x<d[m].morphTargets.length;x++)p[d[m].morphTargets[x]]=-1;for(const x in p){const g=[],f=[];for(let v=0;v!==d[m].morphTargets.length;++v){const y=d[m];g.push(y.time),f.push(y.morphTarget===x?1:0)}r.push(new yl(".morphTargetInfluence["+x+"]",g,f))}l=p.length*o}else{const p=".bones["+t[h].name+"]";i(_l,p+".position",d,"pos",r),i(Ol,p+".quaternion",d,"rot",r),i(_l,p+".scale",d,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.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(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function hN(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yl;case"vector":case"vector2":case"vector3":case"vector4":return _l;case"color":return yg;case"quaternion":return Ol;case"bool":case"boolean":return Rs;case"string":return Ps}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function fN(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=hN(n.type);if(n.times===void 0){const t=[],i=[];xg(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const Hi={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class _g{constructor(e,t,i){const r=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const QM=new _g;class Tn{constructor(e){this.manager=e!==void 0?e:QM,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}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}}Tn.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ui={};class pN extends Error{constructor(e,t){super(e),this.response=t}}class Qi extends Tn{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Hi.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ui[e]!==void 0){Ui[e].push({onLoad:t,onProgress:i,onError:r});return}Ui[e]=[],Ui[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Ui[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let x=0;const g=new ReadableStream({start(f){v();function v(){h.read().then(({done:y,value:_})=>{if(y)f.close();else{x+=_.byteLength;const C=new ProgressEvent("progress",{lengthComputable:m,loaded:x,total:p});for(let w=0,E=u.length;w<E;w++){const A=u[w];A.onProgress&&A.onProgress(C)}f.enqueue(_),v()}},y=>{f.error(y)})}}});return new Response(g)}else throw new pN(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{Hi.add(e,c);const u=Ui[e];delete Ui[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=Ui[e];if(u===void 0)throw this.manager.itemError(e),c;delete Ui[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class mN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Qi(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=Sl.parse(e[i]);t.push(r)}return t}}class gN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=[],a=new Yd,l=new Qi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const p=s.parse(d,!0);o[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(a.minFilter=Ut),a.image=o,a.format=p.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=s.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let m=0;m<p;m++){o[m]={mipmaps:[]};for(let x=0;x<d.mipmapCount;x++)o[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+x]),o[m].format=d.format,o[m].width=d.width,o[m].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=Ut),a.format=d.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}}class Ml extends Tn{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Hi.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=pl("img");function l(){u(),Hi.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class xN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=new Il;s.colorSpace=Hn;const o=new Ml(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class vN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new wi,a=new Qi(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:Xn,o.wrapT=c.wrapT!==void 0?c.wrapT:Xn,o.magFilter=c.magFilter!==void 0?c.magFilter:Ut,o.minFilter=c.minFilter!==void 0?c.minFilter:Ut,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=yi),c.mipmapCount===1&&(o.minFilter=Ut),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},i,r),o}}class yN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=new Ct,o=new Ml(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class Br extends nt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new _e(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class ew extends Br{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new _e(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const If=new ke,xv=new I,vv=new I;class Sg{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Q(512,512),this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Nl,this._frameExtents=new Q(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;xv.setFromMatrixPosition(e.matrixWorld),t.position.copy(xv),vv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(vv),t.updateMatrixWorld(),If.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(If),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(If)}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.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class _N extends Sg{constructor(){super(new Yt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Uo*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class tw extends Br{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.target=new nt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new _N}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}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.shadow=e.shadow.clone(),this}}const yv=new ke,pa=new I,Nf=new I;class SN extends Sg{constructor(){super(new Yt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Q(4,2),this._viewportCount=6,this._viewports=[new ct(2,1,1,1),new ct(0,1,1,1),new ct(3,1,1,1),new ct(1,1,1,1),new ct(3,0,1,1),new ct(1,0,1,1)],this._cubeDirections=[new I(1,0,0),new I(-1,0,0),new I(0,0,1),new I(0,0,-1),new I(0,1,0),new I(0,-1,0)],this._cubeUps=[new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,0,1),new I(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),pa.setFromMatrixPosition(e.matrixWorld),i.position.copy(pa),Nf.copy(i.position),Nf.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Nf),i.updateMatrixWorld(),r.makeTranslation(-pa.x,-pa.y,-pa.z),yv.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yv)}}class nw extends Br{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new SN}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}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}}class MN extends Sg{constructor(){super(new Hd(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class iw extends Br{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(nt.DEFAULT_UP),this.updateMatrix(),this.target=new nt,this.shadow=new MN}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class rw extends Br{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sw extends Br{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}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){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class ow{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new I)}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){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],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){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class aw extends Br{constructor(e=new ow,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class ch extends Tn{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,o=new Qi(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=ch.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new _e().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new _e().setHex(o.value);break;case"v2":r.uniforms[s].value=new Q().fromArray(o.value);break;case"v3":r.uniforms[s].value=new I().fromArray(o.value);break;case"v4":r.uniforms[s].value=new ct().fromArray(o.value);break;case"m3":r.uniforms[s].value=new je().fromArray(o.value);break;case"m4":r.uniforms[s].value=new ke().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Q().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Q().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:BM,SpriteMaterial:ag,RawShaderMaterial:zM,ShaderMaterial:ci,PointsMaterial:cg,MeshPhysicalMaterial:VM,MeshStandardMaterial:gg,MeshPhongMaterial:HM,MeshToonMaterial:GM,MeshNormalMaterial:WM,MeshLambertMaterial:jM,MeshDepthMaterial:sg,MeshDistanceMaterial:og,MeshBasicMaterial:Or,MeshMatcapMaterial:XM,LineDashedMaterial:$M,LineBasicMaterial:xn,Material:on};return new t[e]}}class Hp{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||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 lw extends Ye{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class cw extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Qi(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(p,m){if(t[m]!==void 0)return t[m];const g=p.interleavedBuffers[m],f=s(p,g.buffer),v=po(g.type,f),y=new Xd(v,g.stride);return y.uuid=g.uuid,t[m]=y,y}function s(p,m){if(i[m]!==void 0)return i[m];const g=p.arrayBuffers[m],f=new Uint32Array(g).buffer;return i[m]=f,f}const o=e.isInstancedBufferGeometry?new lw:new Ye,a=e.data.index;if(a!==void 0){const p=po(a.type,a.array);o.setIndex(new ht(p,1))}const l=e.data.attributes;for(const p in l){const m=l[p];let x;if(m.isInterleavedBufferAttribute){const g=r(e.data,m.data);x=new bs(g,m.itemSize,m.offset,m.normalized)}else{const g=po(m.type,m.array),f=m.isInstancedBufferAttribute?Oo:ht;x=new f(g,m.itemSize,m.normalized)}m.name!==void 0&&(x.name=m.name),m.usage!==void 0&&x.setUsage(m.usage),o.setAttribute(p,x)}const c=e.data.morphAttributes;if(c)for(const p in c){const m=c[p],x=[];for(let g=0,f=m.length;g<f;g++){const v=m[g];let y;if(v.isInterleavedBufferAttribute){const _=r(e.data,v.data);y=new bs(_,v.itemSize,v.offset,v.normalized)}else{const _=po(v.type,v.array);y=new ht(_,v.itemSize,v.normalized)}v.name!==void 0&&(y.name=v.name),x.push(y)}o.morphAttributes[p]=x}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let p=0,m=h.length;p!==m;++p){const x=h[p];o.addGroup(x.start,x.count,x.materialIndex)}const d=e.data.boundingSphere;if(d!==void 0){const p=new I;d.center!==void 0&&p.fromArray(d.center),o.boundingSphere=new rn(p,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class wN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=this.path===""?Hp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new Qi(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?Hp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Qi(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(e,t),a=JSON.parse(o),l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),a=this.parseTextures(e.textures,o),l=this.parseMaterials(e.materials,a),c=this.parseObject(e.object,s,l,a,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let h=!1;for(const d in o)if(o[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,r,a,o,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new gs().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=new $d().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new cw;for(let s=0,o=e.length;s<o;s++){let a;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(l);break;default:l.type in gv?a=gv[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),i[l.uuid]=a}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new ch;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){const l=e[o];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=Sl.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function o(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return o(u)}else return l.data?{data:po(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new _g(t);s=new Ml(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const p=[];for(let m=0,x=d.length;m<x;m++){const g=d[m],f=a(g);f!==null&&(f instanceof HTMLImageElement?p.push(f):p.push(new wi(f.data,f.width,f.height)))}r[h.uuid]=new cs(p)}else{const p=a(h.url);r[h.uuid]=new cs(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(l)}else return o.data?{data:po(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Ml(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const l=e[o],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new wi(m.data,m.width,m.height)))}i[l.uuid]=new cs(u)}else{const u=await s(l.url);i[l.uuid]=new cs(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const l=t[a.image],c=l.data;let u;Array.isArray(c)?(u=new Il,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new wi:u=new Ct,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,bN)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],_v),u.wrapT=i(a.wrap[1],_v)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,Sv)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,Sv)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let m=0,x=d.length;m<x;m++){const g=d[m];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),p.push(i[g])}return p}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function c(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":o=new _M,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new _e(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new jd(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Wd(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new Yt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Hd(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new rw(e.color,e.intensity);break;case"DirectionalLight":o=new iw(e.color,e.intensity),o.target=e.target||"";break;case"PointLight":o=new nw(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new sw(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new tw(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),o.target=e.target||"";break;case"HemisphereLight":o=new ew(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new aw().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=l(e.material),o=new bM(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=l(e.material),o=new kt(u,h);break;case"InstancedMesh":u=a(e.geometry),h=l(e.material);const d=e.count,p=e.instanceMatrix,m=e.instanceColor;o=new EM(u,h,d),o.instanceMatrix=new Oo(new Float32Array(p.array),16),m!==void 0&&(o.instanceColor=new Oo(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=l(e.material),o=new TM(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(x=>{const g=new pn;g.min.fromArray(x.boxMin),g.max.fromArray(x.boxMax);const f=new rn;return f.radius=x.sphereRadius,f.center.fromArray(x.sphereCenter),{boxInitialized:x.boxInitialized,box:g,sphereInitialized:x.sphereInitialized,sphere:f}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":o=new wM;break;case"Line":o=new Nr(a(e.geometry),l(e.material));break;case"LineLoop":o=new AM(a(e.geometry),l(e.material));break;case"LineSegments":o=new Ai(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new CM(a(e.geometry),l(e.material));break;case"Sprite":o=new MM(l(e.material));break;case"Group":o=new go;break;case"Bone":o=new lg;break;default:o=new nt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)o.add(this.parseObject(d[p],t,i,r,s))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const m=d[p];o.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const m=d[p],x=o.getObjectByProperty("uuid",m.object);x!==void 0&&o.addLevel(x,m.distance,m.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new nt}})}}const bN={UVMapping:Pd,CubeReflectionMapping:Ki,CubeRefractionMapping:Ir,EquirectangularReflectionMapping:il,EquirectangularRefractionMapping:rl,CubeUVReflectionMapping:Vo},_v={RepeatWrapping:sl,ClampToEdgeWrapping:Xn,MirroredRepeatWrapping:ol},Sv={NearestFilter:Gt,NearestMipmapNearestFilter:Vm,NearestMipmapLinearFilter:fo,LinearFilter:Ut,LinearMipmapNearestFilter:Pa,LinearMipmapLinearFilter:yi};class EN extends Tn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Hi.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Hi.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Hi.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Hi.add(e,l),s.manager.itemStart(e)}}let Hc;class Mg{static getContext(){return Hc===void 0&&(Hc=new(window.AudioContext||window.webkitAudioContext)),Hc}static setContext(e){Hc=e}}class TN extends Tn{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Qi(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);Mg.getContext().decodeAudioData(c,function(h){t(h)}).catch(a)}catch(c){a(c)}},i,r);function a(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const Mv=new ke,wv=new ke,Yr=new ke;class AN{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Yt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Yt,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){const 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){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,Yr.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(ms*t.fov*.5)/t.zoom;let a,l;wv.elements[12]=-r,Mv.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,Yr.elements[0]=2*t.near/(l-a),Yr.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Yr),a=-o*t.aspect-s,l=o*t.aspect-s,Yr.elements[0]=2*t.near/(l-a),Yr.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Yr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(wv),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Mv)}}class uw{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=bv(),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){const t=bv();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function bv(){return(typeof performance>"u"?Date:performance).now()}const qr=new I,Ev=new En,CN=new I,Zr=new I;class RN extends nt{constructor(){super(),this.type="AudioListener",this.context=Mg.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new uw}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(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 this.filter!==null?(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);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(qr,Ev,CN),Zr.set(0,0,-1).applyQuaternion(Ev),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(qr.x,r),t.positionY.linearRampToValueAtTime(qr.y,r),t.positionZ.linearRampToValueAtTime(qr.z,r),t.forwardX.linearRampToValueAtTime(Zr.x,r),t.forwardY.linearRampToValueAtTime(Zr.y,r),t.forwardZ.linearRampToValueAtTime(Zr.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(qr.x,qr.y,qr.z),t.setOrientation(Zr.x,Zr.y,Zr.z,i.x,i.y,i.z)}}class dw extends nt{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(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const 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(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),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(this._connected!==!1){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=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&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){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(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}}const Kr=new I,Tv=new En,PN=new I,Jr=new I;class IN extends dw{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}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,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Kr,Tv,PN),Jr.set(0,0,1).applyQuaternion(Tv);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Kr.x,i),t.positionY.linearRampToValueAtTime(Kr.y,i),t.positionZ.linearRampToValueAtTime(Kr.z,i),t.orientationX.linearRampToValueAtTime(Jr.x,i),t.orientationY.linearRampToValueAtTime(Jr.y,i),t.orientationZ.linearRampToValueAtTime(Jr.z,i)}else t.setPosition(Kr.x,Kr.y,Kr.z),t.setOrientation(Jr.x,Jr.y,Jr.z)}}class NN{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;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class hw{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,s=e*r+r;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){En.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const o=this._workIndex*s;En.multiplyQuaternionsFlat(e,o,e,t,e,i),En.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){const o=1-r;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[i+o]*r}}}const wg="\\[\\]\\.:\\/",LN=new RegExp("["+wg+"]","g"),bg="[^"+wg+"]",DN="[^"+wg.replace("\\.","")+"]",UN=/((?:WC+[\/:])*)/.source.replace("WC",bg),kN=/(WCOD+)?/.source.replace("WCOD",DN),ON=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",bg),FN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",bg),BN=new RegExp("^"+UN+kN+ON+FN+"$"),zN=["material","materials","bones","map"];class VN{constructor(e,t,i){const r=i||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class et{constructor(e,t,i){this.path=t,this.parsedPath=i||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new et.Composite(e,t,i):new et(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(LN,"")}static parseTrackName(e){const t=BN.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);zN.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===t||a.uuid===t)return a;const l=i(a.children);if(l)return l}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=et.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[r];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=VN;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class HN{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Un(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;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(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length;let a,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let x=0,g=o;x!==g;++x)s[x].push(new et(d,i[x],r[x]))}else if(m<c){a=e[m];const x=--c,g=e[x];t[g.uuid]=m,e[m]=g,t[p]=x,e[x]=d;for(let f=0,v=o;f!==v;++f){const y=s[f],_=y[x];let C=y[m];y[m]=_,C===void 0&&(C=new et(d,i[f],r[f])),y[x]=C}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=r;p!==m;++p){const x=i[p],g=x[h],f=x[u];x[u]=g,x[h]=f}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const d=--s,p=e[d],m=--o,x=e[m];t[p.uuid]=h,e[h]=p,t[x.uuid]=d,e[d]=x,e.pop();for(let g=0,f=r;g!==f;++g){const v=i[g],y=v[d],_=v[m];v[h]=y,v[d]=_,v.pop()}}else{const d=--o,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,x=r;m!==x;++m){const g=i[m];g[h]=g[d],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){const m=l[d];h[d]=new et(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}}class fw{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,o=s.length,a=new Array(o),l={endingStart:as,endingEnd:as};for(let c=0;c!==o;++c){const u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=XS,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&&this.timeScale!==0&&this._startTime===null&&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,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(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,i){const r=this._mixer,s=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(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,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Km:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Od:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const o=i===$S;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===jS){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){const a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=ls,r.endingEnd=ls):(e?r.endingStart=this.zeroSlopeAtStart?ls:as:r.endingStart=ll,t?r.endingEnd=this.zeroSlopeAtEnd?ls:as:r.endingEnd=ll)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=i,this}}const GN=new Float32Array(1);class WN extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const d=r[h],p=d.name;let m=u[p];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const x=t&&t._propertyBindings[h].binding.parsedPath;m=new hw(et.create(i,p,x),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,s=this._actionsByClip;let o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new vg(new Float32Array(2),new Float32Array(2),1,GN),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let o=typeof e=="string"?Sl.findByName(r,e):e;const a=o!==null?o.uuid:e,l=this._actionsByClip[a];let c=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Od),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const u=new fw(this,o,t,i);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?Sl.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){const o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const o in i){const a=i[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const o in s){const a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class Eg{constructor(e){this.value=e}clone(){return new Eg(this.value.clone===void 0?this.value:this.value.clone())}}let jN=0;class XN extends Ti{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:jN++}),this.name="",this.usage=hl,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class $N extends Xd{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class YN{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&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}}const Av=new ke;class qN{constructor(e,t,i=0,r=1/0){this.ray=new Go(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new zd,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):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Av.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Av),this}intersectObject(e,t=!0,i=[]){return Gp(e,this,i,t),i.sort(Cv),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Gp(e[r],this,i,t);return i.sort(Cv),i}}function Cv(n,e){return n.distance-e.distance}function Gp(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let o=0,a=s.length;o<a;o++)Gp(s[o],e,t,!0)}}class ZN{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(At(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class KN{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,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,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class Tg{constructor(e,t,i,r){Tg.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const Rv=new Q;class JN{constructor(e=new Q(1/0,1/0),t=new Q(-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,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Rv.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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=1/0,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,Rv).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)}}const Pv=new I,Gc=new I;class QN{constructor(e=new I,t=new I){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){Pv.subVectors(e,this.start),Gc.subVectors(this.end,this.start);const i=Gc.dot(Gc);let s=Gc.dot(Pv)/i;return t&&(s=At(s,0,1)),s}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}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)}}const Iv=new I;class e3 extends nt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Ye,r=[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 o=0,a=1,l=32;o<l;o++,a++){const c=o/l*Math.PI*2,u=a/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new Pe(r,3));const s=new xn({fog:!1,toneMapped:!1});this.cone=new Ai(i,s),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);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Iv.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Iv),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const hr=new I,Wc=new ke,Lf=new ke;class t3 extends Ai{constructor(e){const t=pw(e),i=new Ye,r=[],s=[],o=new _e(0,0,1),a=new _e(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new Pe(r,3)),i.setAttribute("color",new Pe(s,3));const l=new xn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");Lf.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){const a=t[s];a.parent&&a.parent.isBone&&(Wc.multiplyMatrices(Lf,a.matrixWorld),hr.setFromMatrixPosition(Wc),r.setXYZ(o,hr.x,hr.y,hr.z),Wc.multiplyMatrices(Lf,a.parent.matrixWorld),hr.setFromMatrixPosition(Wc),r.setXYZ(o+1,hr.x,hr.y,hr.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function pw(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,pw(n.children[t]));return e}class n3 extends kt{constructor(e,t,i){const r=new Ul(t,4,2),s=new Or({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,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),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const i3=new I,Nv=new _e,Lv=new _e;class r3 extends nt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new Dl(t);r.rotateY(Math.PI*.5),this.material=new Or({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new ht(o,3)),this.add(new kt(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Nv.copy(this.light.color),Lv.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Nv:Lv;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(i3.setFromMatrixPosition(this.light.matrixWorld).negate())}}class s3 extends Ai{constructor(e=10,t=10,i=4473924,r=8947848){i=new _e(i),r=new _e(r);const s=t/2,o=e/t,a=e/2,l=[],c=[];for(let d=0,p=0,m=-a;d<=t;d++,m+=o){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,0,a);const x=d===s?i:r;x.toArray(c,p),p+=3,x.toArray(c,p),p+=3,x.toArray(c,p),p+=3,x.toArray(c,p),p+=3}const u=new Ye;u.setAttribute("position",new Pe(l,3)),u.setAttribute("color",new Pe(c,3));const h=new xn({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class o3 extends Ai{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new _e(s),o=new _e(o);const a=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,m=Math.cos(d)*e;a.push(0,0,0),a.push(p,0,m);const x=h&1?s:o;l.push(x.r,x.g,x.b),l.push(x.r,x.g,x.b)}for(let h=0;h<i;h++){const d=h&1?s:o,p=e-e/i*h;for(let m=0;m<r;m++){let x=m/r*(Math.PI*2),g=Math.sin(x)*p,f=Math.cos(x)*p;a.push(g,0,f),l.push(d.r,d.g,d.b),x=(m+1)/r*(Math.PI*2),g=Math.sin(x)*p,f=Math.cos(x)*p,a.push(g,0,f),l.push(d.r,d.g,d.b)}}const c=new Ye;c.setAttribute("position",new Pe(a,3)),c.setAttribute("color",new Pe(l,3));const u=new xn({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Dv=new I,jc=new I,Uv=new I;class a3 extends nt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Ye;r.setAttribute("position",new Pe([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new xn({fog:!1,toneMapped:!1});this.lightPlane=new Nr(r,s),this.add(this.lightPlane),r=new Ye,r.setAttribute("position",new Pe([0,0,0,0,0,1],3)),this.targetLine=new Nr(r,s),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),Dv.setFromMatrixPosition(this.light.matrixWorld),jc.setFromMatrixPosition(this.light.target.matrixWorld),Uv.subVectors(jc,Dv),this.lightPlane.lookAt(jc),this.color!==void 0?(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(jc),this.targetLine.scale.z=Uv.length()}}const Xc=new I,Et=new Vd;class l3 extends Ai{constructor(e){const t=new Ye,i=new xn({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,x){l(m),l(x)}function l(m){r.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(r.length/3-1)}t.setAttribute("position",new Pe(r,3)),t.setAttribute("color",new Pe(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new _e(16755200),u=new _e(16711680),h=new _e(43775),d=new _e(16777215),p=new _e(3355443);this.setColors(c,u,h,d,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");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,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Et.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Rt("c",t,e,Et,0,0,-1),Rt("t",t,e,Et,0,0,1),Rt("n1",t,e,Et,-i,-r,-1),Rt("n2",t,e,Et,i,-r,-1),Rt("n3",t,e,Et,-i,r,-1),Rt("n4",t,e,Et,i,r,-1),Rt("f1",t,e,Et,-i,-r,1),Rt("f2",t,e,Et,i,-r,1),Rt("f3",t,e,Et,-i,r,1),Rt("f4",t,e,Et,i,r,1),Rt("u1",t,e,Et,i*.7,r*1.1,-1),Rt("u2",t,e,Et,-i*.7,r*1.1,-1),Rt("u3",t,e,Et,0,r*2,-1),Rt("cf1",t,e,Et,-i,0,1),Rt("cf2",t,e,Et,i,0,1),Rt("cf3",t,e,Et,0,-r,1),Rt("cf4",t,e,Et,0,r,1),Rt("cn1",t,e,Et,-i,0,-1),Rt("cn2",t,e,Et,i,0,-1),Rt("cn3",t,e,Et,0,-r,-1),Rt("cn4",t,e,Et,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Rt(n,e,t,i,r,s,o){Xc.set(r,s,o).unproject(i);const a=e[n];if(a!==void 0){const l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],Xc.x,Xc.y,Xc.z)}}const $c=new pn;class c3 extends Ai{constructor(e,t=16776960){const i=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]),r=new Float32Array(8*3),s=new Ye;s.setIndex(new ht(i,1)),s.setAttribute("position",new ht(r,3)),super(s,new xn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&$c.setFromObject(this.object),$c.isEmpty())return;const t=$c.min,i=$c.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.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 u3 extends Ai{constructor(e,t=16776960){const i=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]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ye;s.setIndex(new ht(i,1)),s.setAttribute("position",new Pe(r,3)),super(s,new xn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const 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 d3 extends Nr{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new Ye;o.setAttribute("position",new Pe(s,3)),o.computeBoundingSphere(),super(o,new xn({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Ye;l.setAttribute("position",new Pe(a,3)),l.computeBoundingSphere(),this.add(new kt(l,new Or({color:r,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()}}const kv=new I;let Yc,Df;class h3 extends nt{constructor(e=new I(0,0,1),t=new I(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",Yc===void 0&&(Yc=new Ye,Yc.setAttribute("position",new Pe([0,0,0,0,1,0],3)),Df=new Xo(0,.5,1,5,1),Df.translate(0,-.5,0)),this.position.copy(t),this.line=new Nr(Yc,new xn({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new kt(Df,new Or({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,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{kv.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(kv,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),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 f3 extends Ai{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ye;r.setAttribute("position",new Pe(t,3)),r.setAttribute("color",new Pe(i,3));const s=new xn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new _e,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class p3{constructor(){this.type="ShapePath",this.color=new _e,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ml,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(f){const v=[];for(let y=0,_=f.length;y<_;y++){const C=f[y],w=new gs;w.curves=C.curves,v.push(w)}return v}function i(f,v){const y=v.length;let _=!1;for(let C=y-1,w=0;w<y;C=w++){let E=v[C],A=v[w],b=A.x-E.x,M=A.y-E.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(E=v[w],b=-b,A=v[C],M=-M),f.y<E.y||f.y>A.y)continue;if(f.y===E.y){if(f.x===E.x)return!0}else{const L=M*(f.x-E.x)-b*(f.y-E.y);if(L===0)return!0;if(L<0)continue;_=!_}}else{if(f.y!==E.y)continue;if(A.x<=f.x&&f.x<=E.x||E.x<=f.x&&f.x<=A.x)return!0}}return _}const r=bi.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new gs,l.curves=a.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],m=0,x;d[m]=void 0,p[m]=[];for(let f=0,v=s.length;f<v;f++)a=s[f],x=a.getPoints(),o=r(x),o=e?!o:o,o?(!u&&d[m]&&m++,d[m]={s:new gs,p:x},d[m].s.curves=a.curves,u&&m++,p[m]=[]):p[m].push({h:a,p:x[0]});if(!d[0])return t(s);if(d.length>1){let f=!1,v=0;for(let y=0,_=d.length;y<_;y++)h[y]=[];for(let y=0,_=d.length;y<_;y++){const C=p[y];for(let w=0;w<C.length;w++){const E=C[w];let A=!0;for(let b=0;b<d.length;b++)i(E.p,d[b].p)&&(y!==b&&v++,A?(A=!1,h[b].push(E)):f=!0);A&&h[y].push(E)}}v>0&&f===!1&&(p=h)}let g;for(let f=0,v=d.length;f<v;f++){l=d[f].s,c.push(l),g=p[f];for(let y=0,_=g.length;y<_;y++)l.holes.push(g[y].h)}return c}}class m3 extends Ti{constructor(e,t){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(){}disconnect(){}dispose(){}update(){}}class g3 extends li{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Rd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Rd);const J3=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:zS,AddEquation:vr,AddOperation:kS,AdditiveAnimationBlendMode:Km,AdditiveBlending:Rp,AgXToneMapping:HS,AlphaFormat:jm,AlwaysCompare:iM,AlwaysDepth:RS,AlwaysStencilFunc:Lp,AmbientLight:rw,AnimationAction:fw,AnimationClip:Sl,AnimationLoader:mN,AnimationMixer:WN,AnimationObjectGroup:HN,AnimationUtils:dN,ArcCurve:RM,ArrayCamera:yM,ArrowHelper:h3,AttachedBindMode:Np,Audio:dw,AudioAnalyser:NN,AudioContext:Mg,AudioListener:RN,AudioLoader:TN,AxesHelper:f3,BackSide:fn,BasicDepthPacking:YS,BasicShadowMap:cT,BatchedMesh:TM,Bone:lg,BooleanKeyframeTrack:Rs,Box2:JN,Box3:pn,Box3Helper:u3,BoxGeometry:Cs,BoxHelper:c3,BufferAttribute:ht,BufferGeometry:Ye,BufferGeometryLoader:cw,ByteType:Hm,Cache:Hi,Camera:Vd,CameraHelper:l3,CanvasTexture:UI,CapsuleGeometry:Zd,CatmullRomCurve3:PM,CineonToneMapping:BS,CircleGeometry:Kd,ClampToEdgeWrapping:Xn,Clock:uw,Color:_e,ColorKeyframeTrack:yg,ColorManagement:rt,CompressedArrayTexture:LI,CompressedCubeTexture:DI,CompressedTexture:Yd,CompressedTextureLoader:gN,ConeGeometry:Jd,ConstantAlphaFactor:TS,ConstantColorFactor:bS,Controls:m3,CubeCamera:dM,CubeReflectionMapping:Ki,CubeRefractionMapping:Ir,CubeTexture:Il,CubeTextureLoader:xN,CubeUVReflectionMapping:Vo,CubicBezierCurve:dg,CubicBezierCurve3:IM,CubicInterpolant:ZM,CullFaceBack:Cp,CullFaceFront:lS,CullFaceFrontBack:lT,CullFaceNone:aS,Curve:ui,CurvePath:LM,CustomBlending:uS,CustomToneMapping:VS,CylinderGeometry:Xo,Cylindrical:KN,Data3DTexture:eg,DataArrayTexture:Bd,DataTexture:wi,DataTextureLoader:vN,DataUtils:MA,DecrementStencilOp:wT,DecrementWrapStencilOp:ET,DefaultLoadingManager:QM,DepthFormat:ps,DepthStencilFormat:ws,DepthTexture:rg,DetachedBindMode:WS,DirectionalLight:iw,DirectionalLightHelper:a3,DiscreteInterpolant:KM,DisplayP3ColorSpace:Fd,DodecahedronGeometry:Qd,DoubleSide:vi,DstAlphaFactor:yS,DstColorFactor:SS,DynamicCopyUsage:zT,DynamicDrawUsage:DT,DynamicReadUsage:OT,EdgesGeometry:DM,EllipseCurve:qd,EqualCompare:QS,EqualDepth:IS,EqualStencilFunc:RT,EquirectangularReflectionMapping:il,EquirectangularRefractionMapping:rl,Euler:On,EventDispatcher:Ti,ExtrudeGeometry:th,FileLoader:Qi,Float16BufferAttribute:CA,Float32BufferAttribute:Pe,FloatType:Sn,Fog:jd,FogExp2:Wd,FramebufferTexture:NI,FrontSide:Zi,Frustum:Nl,GLBufferAttribute:YN,GLSL1:HT,GLSL3:Dp,GreaterCompare:eM,GreaterDepth:LS,GreaterEqualCompare:nM,GreaterEqualDepth:NS,GreaterEqualStencilFunc:LT,GreaterStencilFunc:IT,GridHelper:s3,Group:go,HalfFloatType:Ho,HemisphereLight:ew,HemisphereLightHelper:r3,IcosahedronGeometry:nh,ImageBitmapLoader:EN,ImageLoader:Ml,ImageUtils:oM,IncrementStencilOp:MT,IncrementWrapStencilOp:bT,InstancedBufferAttribute:Oo,InstancedBufferGeometry:lw,InstancedInterleavedBuffer:$N,InstancedMesh:EM,Int16BufferAttribute:TA,Int32BufferAttribute:AA,Int8BufferAttribute:wA,IntType:Id,InterleavedBuffer:Xd,InterleavedBufferAttribute:bs,Interpolant:kl,InterpolateDiscrete:al,InterpolateLinear:ad,InterpolateSmooth:au,InvertStencilOp:TT,KeepStencilOp:ts,KeyframeTrack:di,LOD:wM,LatheGeometry:Ll,Layers:zd,LessCompare:JS,LessDepth:PS,LessEqualCompare:Jm,LessEqualDepth:nl,LessEqualStencilFunc:PT,LessStencilFunc:CT,Light:Br,LightProbe:aw,Line:Nr,Line3:QN,LineBasicMaterial:xn,LineCurve:hg,LineCurve3:NM,LineDashedMaterial:$M,LineLoop:AM,LineSegments:Ai,LinearDisplayP3ColorSpace:Pl,LinearFilter:Ut,LinearInterpolant:vg,LinearMipMapLinearFilter:fT,LinearMipMapNearestFilter:hT,LinearMipmapLinearFilter:yi,LinearMipmapNearestFilter:Pa,LinearSRGBColorSpace:tr,LinearToneMapping:OS,LinearTransfer:cl,Loader:Tn,LoaderUtils:Hp,LoadingManager:_g,LoopOnce:jS,LoopPingPong:$S,LoopRepeat:XS,LuminanceAlphaFormat:Ym,LuminanceFormat:$m,MOUSE:oT,Material:on,MaterialLoader:ch,MathUtils:sA,Matrix2:Tg,Matrix3:je,Matrix4:ke,MaxEquation:pS,Mesh:kt,MeshBasicMaterial:Or,MeshDepthMaterial:sg,MeshDistanceMaterial:og,MeshLambertMaterial:jM,MeshMatcapMaterial:XM,MeshNormalMaterial:WM,MeshPhongMaterial:HM,MeshPhysicalMaterial:VM,MeshStandardMaterial:gg,MeshToonMaterial:GM,MinEquation:fS,MirroredRepeatWrapping:ol,MixOperation:US,MultiplyBlending:Ip,MultiplyOperation:Cl,NearestFilter:Gt,NearestMipMapLinearFilter:dT,NearestMipMapNearestFilter:uT,NearestMipmapLinearFilter:fo,NearestMipmapNearestFilter:Vm,NeutralToneMapping:GS,NeverCompare:KS,NeverDepth:CS,NeverStencilFunc:AT,NoBlending:Wi,NoColorSpace:Fi,NoToneMapping:ji,NormalAnimationBlendMode:Od,NormalBlending:fs,NotEqualCompare:tM,NotEqualDepth:DS,NotEqualStencilFunc:NT,NumberKeyframeTrack:yl,Object3D:nt,ObjectLoader:wN,ObjectSpaceNormalMap:ZS,OctahedronGeometry:Dl,OneFactor:gS,OneMinusConstantAlphaFactor:AS,OneMinusConstantColorFactor:ES,OneMinusDstAlphaFactor:_S,OneMinusDstColorFactor:MS,OneMinusSrcAlphaFactor:Du,OneMinusSrcColorFactor:vS,OrthographicCamera:Hd,P3Primaries:dl,PCFShadowMap:zm,PCFSoftShadowMap:cS,PMREMGenerator:Up,Path:ml,PerspectiveCamera:Yt,Plane:mr,PlaneGeometry:Wo,PlaneHelper:d3,PointLight:nw,PointLightHelper:n3,Points:CM,PointsMaterial:cg,PolarGridHelper:o3,PolyhedronGeometry:Fr,PositionalAudio:IN,PropertyBinding:et,PropertyMixer:hw,QuadraticBezierCurve:fg,QuadraticBezierCurve3:pg,Quaternion:En,QuaternionKeyframeTrack:Ol,QuaternionLinearInterpolant:JM,RED_GREEN_RGTC2_Format:sd,RED_RGTC1_Format:Zm,REVISION:Rd,RGBADepthPacking:qS,RGBAFormat:dn,RGBAIntegerFormat:kd,RGBA_ASTC_10x10_Format:Qu,RGBA_ASTC_10x5_Format:Zu,RGBA_ASTC_10x6_Format:Ku,RGBA_ASTC_10x8_Format:Ju,RGBA_ASTC_12x10_Format:ed,RGBA_ASTC_12x12_Format:td,RGBA_ASTC_4x4_Format:Hu,RGBA_ASTC_5x4_Format:Gu,RGBA_ASTC_5x5_Format:Wu,RGBA_ASTC_6x5_Format:ju,RGBA_ASTC_6x6_Format:Xu,RGBA_ASTC_8x5_Format:$u,RGBA_ASTC_8x6_Format:Yu,RGBA_ASTC_8x8_Format:qu,RGBA_BPTC_Format:Ua,RGBA_ETC2_EAC_Format:Vu,RGBA_PVRTC_2BPPV1_Format:Fu,RGBA_PVRTC_4BPPV1_Format:Ou,RGBA_S3TC_DXT1_Format:Na,RGBA_S3TC_DXT3_Format:La,RGBA_S3TC_DXT5_Format:Da,RGBDepthPacking:vT,RGBFormat:Xm,RGBIntegerFormat:pT,RGB_BPTC_SIGNED_Format:nd,RGB_BPTC_UNSIGNED_Format:id,RGB_ETC1_Format:Bu,RGB_ETC2_Format:zu,RGB_PVRTC_2BPPV1_Format:ku,RGB_PVRTC_4BPPV1_Format:Uu,RGB_S3TC_DXT1_Format:Ia,RGDepthPacking:yT,RGFormat:qm,RGIntegerFormat:Ud,RawShaderMaterial:zM,Ray:Go,Raycaster:qN,Rec709Primaries:ul,RectAreaLight:sw,RedFormat:Dd,RedIntegerFormat:Rl,ReinhardToneMapping:FS,RenderTarget:aM,RepeatWrapping:sl,ReplaceStencilOp:ST,ReverseSubtractEquation:hS,RingGeometry:ih,SIGNED_RED_GREEN_RGTC2_Format:od,SIGNED_RED_RGTC1_Format:rd,SRGBColorSpace:Hn,SRGBTransfer:ft,Scene:_M,ShaderChunk:$e,ShaderLib:ri,ShaderMaterial:ci,ShadowMaterial:BM,Shape:gs,ShapeGeometry:rh,ShapePath:p3,ShapeUtils:bi,ShortType:Gm,Skeleton:$d,SkeletonHelper:t3,SkinnedMesh:bM,Source:cs,Sphere:rn,SphereGeometry:Ul,Spherical:ZN,SphericalHarmonics3:ow,SplineCurve:mg,SpotLight:tw,SpotLightHelper:e3,Sprite:MM,SpriteMaterial:ag,SrcAlphaFactor:Lu,SrcAlphaSaturateFactor:wS,SrcColorFactor:xS,StaticCopyUsage:BT,StaticDrawUsage:hl,StaticReadUsage:kT,StereoCamera:AN,StreamCopyUsage:VT,StreamDrawUsage:UT,StreamReadUsage:FT,StringKeyframeTrack:Ps,SubtractEquation:dS,SubtractiveBlending:Pp,TOUCH:aT,TangentSpaceNormalMap:kr,TetrahedronGeometry:sh,Texture:Ct,TextureLoader:yN,TextureUtils:uI,TorusGeometry:oh,TorusKnotGeometry:ah,Triangle:Nn,TriangleFanDrawMode:xT,TriangleStripDrawMode:gT,TrianglesDrawMode:mT,TubeGeometry:lh,UVMapping:Pd,Uint16BufferAttribute:tg,Uint32BufferAttribute:ng,Uint8BufferAttribute:bA,Uint8ClampedBufferAttribute:EA,Uniform:Eg,UniformsGroup:XN,UniformsLib:fe,UniformsUtils:uM,UnsignedByteType:Ei,UnsignedInt248Type:Ms,UnsignedInt5999Type:Wm,UnsignedIntType:Ji,UnsignedShort4444Type:Nd,UnsignedShort5551Type:Ld,UnsignedShortType:Do,VSMShadowMap:gi,Vector2:Q,Vector3:I,Vector4:ct,VectorKeyframeTrack:_l,VideoTexture:II,WebGL3DRenderTarget:hA,WebGLArrayRenderTarget:dA,WebGLCoordinateSystem:_i,WebGLCubeRenderTarget:hM,WebGLMultipleRenderTargets:g3,WebGLRenderTarget:li,WebGLRenderer:_I,WebGLUtils:vM,WebGPUCoordinateSystem:fl,WireframeGeometry:FM,WrapAroundEnding:ll,ZeroCurvatureEnding:as,ZeroFactor:mS,ZeroSlopeEnding:ls,ZeroStencilOp:_T,createCanvasElement:sM},Symbol.toStringTag,{value:"Module"})),ut={controls:null,camera:null,initialPosition:null,initialTarget:null};function Q3(n,e){ut.controls=n,ut.camera=e,e&&!ut.initialPosition&&(ut.initialPosition=e.position.clone()),n&&!ut.initialTarget&&(ut.initialTarget=n.target.clone())}function eL(){ut.controls=null,ut.camera=null}const mw=1.18,Ov=2.5;function gw(n=mw){if(!ut.controls||!ut.camera)return;const e=new I().subVectors(ut.controls.target,ut.camera.position).multiplyScalar(1-1/n);ut.camera.position.add(e),ut.controls.update()}function x3(n=mw){gw(1/n)}function uh(n,e){if(!ut.controls||!ut.camera)return;const t=ut.camera,i=new I().subVectors(ut.controls.target,t.position).normalize(),r=new I().crossVectors(i,t.up).normalize(),s=new I().crossVectors(r,i).normalize(),o=new I().addScaledVector(r,n*Ov).addScaledVector(s,e*Ov);t.position.add(o),ut.controls.target.add(o),ut.controls.update()}const v3=()=>uh(-1,0),y3=()=>uh(1,0),_3=()=>uh(0,1),S3=()=>uh(0,-1);function M3(){!ut.controls||!ut.camera||(ut.initialPosition&&ut.camera.position.copy(ut.initialPosition),ut.initialTarget&&ut.controls.target.copy(ut.initialTarget),ut.controls.update())}function w3(){const n=xe(E=>E.selectedSessionId),e=xe(E=>E.sessions),t=xe(E=>E.goals),i=xe(E=>E.missions),r=xe(E=>E.chatBySessionId),s=xe(E=>E.selectSession),o=xe(E=>E.sendPromptTo),[a,l]=Ae.useState("chat"),[c,u]=Ae.useState(""),h=Ae.useRef(null),d=n?e[n]:null,p=Ae.useMemo(()=>n?r[n]??[]:[],[r,n]),m=Ae.useMemo(()=>d?Object.values(i).filter(E=>E.sessionId===d.id).sort((E,A)=>A.startedAt-E.startedAt):[],[i,d]),x=Ae.useMemo(()=>{if(d!=null&&d.currentMissionId)return i[d.currentMissionId]},[i,d]),g=d?ZE(d,x):null;if(Ae.useEffect(()=>{if(a!=="chat")return;const E=h.current;E&&(E.scrollTop=E.scrollHeight)},[a,p.length,n]),!d)return null;const f=d.origin==="internal",v=!!d.wrapperSocketPath,y=f||v,_=d.currentGoalId?t[d.currentGoalId]:void 0,C=d.budgetUsd&&d.budgetUsd>0?Math.min(100,d.costUsd/d.budgetUsd*100):null,w=()=>{c.trim()&&(o(d.id,c),u(""))};return S.jsxs("div",{className:"absolute top-16 right-0 bottom-0 w-full sm:w-[460px] bg-solix-panel border-l border-solix-border backdrop-blur-md flex flex-col z-20",children:[S.jsxs("div",{className:"px-4 py-3 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{className:"min-w-0",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-400",children:"Planet"}),S.jsx("div",{className:"text-lg font-semibold truncate",children:d.name??d.id.slice(0,8)}),S.jsxs("div",{className:"text-xs text-slate-400 mt-0.5 truncate",title:Bm[d.status]??void 0,children:[String(d.model)," · ",oS(d.status),d.origin==="external"?" · external":d.origin==="agentview"?" · agent view":" · internal",v&&S.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide border border-solix-accent/50 text-solix-accent",title:"Wrapped by `solix run` — UI prompts go to your terminal.",children:"wrapped"}),d.agentViewId&&S.jsx("span",{className:"ml-1.5 font-mono text-[9px] text-cyan-300/80",title:`Agent View id: ${d.agentViewId}`,children:d.agentViewId.slice(0,8)})]}),d.prUrl&&S.jsxs("a",{href:d.prUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1.5 text-[11px] text-slate-300 hover:text-white border border-solix-border rounded px-2 py-0.5",title:`Open ${d.prUrl}`,children:[S.jsx("span",{children:"PR"}),S.jsx("span",{className:"text-slate-500 truncate max-w-[200px]",children:d.prUrl.replace(/^https?:\/\//,"")}),d.prCheckStatus&&S.jsx("span",{className:d.prCheckStatus==="success"?"text-solix-ok":d.prCheckStatus==="failure"?"text-solix-danger":"text-amber-300",children:d.prCheckStatus==="success"?"✓":d.prCheckStatus==="failure"?"✗":"⏳"})]}),d.agentViewSummary&&S.jsx("div",{className:"mt-1 text-[11px] text-slate-400 italic line-clamp-2",title:d.agentViewSummary,children:d.agentViewSummary}),_&&S.jsxs("div",{className:"mt-1 inline-flex items-center gap-1.5 text-[11px]",children:[S.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:_.color}}),S.jsx("span",{className:"text-slate-300",children:_.name})]}),(d.budgetUsd!=null||d.costUsd>0)&&S.jsxs("div",{className:"mt-1.5",children:[S.jsxs("div",{className:"flex items-center justify-between text-[11px] text-slate-400",children:[S.jsx("span",{children:"cost"}),S.jsxs("span",{className:"font-mono",children:["$",d.costUsd.toFixed(2),d.budgetUsd!=null&&S.jsxs("span",{className:"text-slate-500",children:[" ","/ $",d.budgetUsd.toFixed(2)]})]})]}),C!=null&&S.jsx("div",{className:"mt-1 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:"h-full",style:{width:`${C}%`,background:C>=100?"#dc2626":C>=75?"#f59e0b":"#38bdf8"}})})]})]}),S.jsx("button",{onClick:()=>s(null),className:"text-slate-400 hover:text-slate-100","aria-label":"Close",children:"✕"})]}),g&&S.jsxs("div",{className:`px-4 py-2 border-b border-solix-border text-[11px] leading-snug ${g.severity==="danger"?"text-solix-danger bg-solix-danger/10":g.severity==="warn"?"text-solix-warn bg-solix-warn/10":"text-slate-300 bg-black/20"}`,children:[S.jsx("span",{className:"font-semibold mr-1",children:"Suggested:"}),g.text]}),S.jsxs("div",{className:"px-4 py-2 border-b border-solix-border",children:[S.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[S.jsx("span",{children:"context"}),S.jsxs("span",{children:[d.contextUsagePct.toFixed(0),"%"]})]}),S.jsx("div",{className:"mt-1 h-1.5 rounded-full bg-slate-800 overflow-hidden",children:S.jsx("div",{className:`h-full ${d.contextUsagePct>=90?"bg-solix-danger":d.contextUsagePct>=80?"bg-solix-warn":"bg-solix-accent"}`,style:{width:`${Math.min(100,d.contextUsagePct)}%`}})})]}),S.jsxs("div",{className:"flex border-b border-solix-border text-xs",children:[S.jsxs(Uf,{active:a==="chat",onClick:()=>l("chat"),children:["Chat ",p.length>0&&S.jsxs("span",{className:"opacity-60",children:["(",p.length,")"]})]}),S.jsxs(Uf,{active:a==="missions",onClick:()=>l("missions"),children:["Missions ",m.length>0&&S.jsxs("span",{className:"opacity-60",children:["(",m.length,")"]})]}),S.jsx(Uf,{active:a==="files",onClick:()=>l("files"),children:"Files"})]}),S.jsxs("div",{className:"flex-1 overflow-hidden",children:[a==="chat"&&S.jsx(b3,{chat:p,scrollRef:h,session:d}),a==="missions"&&S.jsx(E3,{missions:m}),a==="files"&&S.jsx(T3,{missions:m})]}),a==="chat"&&S.jsx("div",{className:"px-3 py-3 border-t border-solix-border",children:y?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"flex gap-2",children:[S.jsx("textarea",{value:c,onChange:E=>u(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),w())},placeholder:v?"Type a prompt — it goes straight into your terminal claude (Cmd/Ctrl+Enter)":"Send a prompt to this session… (Cmd/Ctrl+Enter)",rows:2,className:"flex-1 text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"}),S.jsx("button",{onClick:w,disabled:!c.trim(),className:"px-3 py-2 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30 disabled:opacity-40",children:"Send"})]}),v&&S.jsxs("div",{className:"text-[10px] text-slate-500 italic mt-1.5",children:["Wrapped by ",S.jsx("code",{children:"solix run"}),". Don't type in the terminal while sending from here, or characters will interleave."]})]}):S.jsxs("div",{className:"text-xs text-slate-500",children:["External session — keep typing in your terminal. To send prompts from here instead, restart the session with"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"solix run"}),"."]})})]})}function Uf({active:n,onClick:e,children:t}){return S.jsx("button",{onClick:e,className:`flex-1 px-3 py-2 ${n?"text-solix-accent border-b-2 border-solix-accent":"text-slate-400 hover:text-slate-200 border-b-2 border-transparent"}`,children:t})}function b3({chat:n,scrollRef:e,session:t}){return S.jsxs("div",{ref:e,className:"h-full overflow-y-auto p-4 space-y-3",children:[n.length===0&&S.jsxs("div",{className:"text-sm text-slate-500 italic",children:["No chat yet. Type a prompt to this session in your terminal — it will stream here as it happens.",S.jsxs("div",{className:"mt-2 text-[11px] text-slate-600",children:["Watching transcript at ",S.jsxs("code",{children:["~/.claude/projects/","<encoded>","/",t.id,".jsonl"]})]})]}),n.map(i=>S.jsx("div",{className:`flex ${i.role==="user"?"justify-end":"justify-start"}`,children:S.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${i.role==="user"?"bg-solix-accent/15 border border-solix-accent/40 text-slate-100":"bg-black/40 border border-solix-border text-slate-200"}`,children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide opacity-60 mb-1",children:[i.role,S.jsx("span",{className:"ml-2 text-slate-500",children:new Date(i.ts).toLocaleTimeString()})]}),S.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed",children:i.content})]})},i.messageId))]})}function E3({missions:n}){return S.jsx("div",{className:"h-full overflow-y-auto p-4 space-y-3",children:n.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic",children:"No missions yet."}):n.map(e=>S.jsxs("div",{className:"rounded border border-solix-border p-3 bg-black/30",children:[S.jsxs("div",{className:"flex items-center justify-between text-xs",children:[S.jsx("span",{className:`font-semibold ${e.status==="active"?"text-solix-warn":e.status==="completed"?"text-solix-ok":"text-slate-300"}`,children:e.shortName}),S.jsx("span",{className:"text-slate-500",children:new Date(e.startedAt).toLocaleTimeString()})]}),S.jsx("div",{className:"mt-1 text-sm text-slate-200 line-clamp-3",children:e.prompt}),S.jsxs("div",{className:"mt-2 flex gap-3 text-[10px] text-slate-500",children:[S.jsxs("span",{children:[e.metrics.toolCallCount," tools"]}),S.jsxs("span",{children:[e.metrics.subagentCount," subagents"]}),S.jsxs("span",{children:[e.filesTouched.length," files"]}),e.metrics.durationMs!==void 0&&S.jsxs("span",{children:[(e.metrics.durationMs/1e3).toFixed(1),"s"]})]})]},e.id))})}function T3({missions:n}){const e=Array.from(new Set(n.flatMap(t=>t.filesTouched))).sort();return S.jsx("div",{className:"h-full overflow-y-auto p-4",children:e.length===0?S.jsx("div",{className:"text-sm text-slate-500 italic",children:"No files touched yet."}):S.jsx("ul",{className:"space-y-1 text-xs font-mono text-slate-300",children:e.map(t=>S.jsx("li",{className:"truncate",children:t},t))})})}function A3(){const n=xe(g=>g.selectedAdvisorId),e=xe(g=>n?g.advisors[n]:null),t=xe(g=>g.selectedSessionId?g.sessions[g.selectedSessionId]:null),i=xe(g=>g.selectAdvisor),r=xe(g=>g.invokeAdvisor),s=xe(g=>g.pinAdvisor),o=xe(g=>g.unpinAdvisor),a=xe(g=>g.enableAdvisor),l=xe(g=>g.disableAdvisor),[c,u]=Ae.useState(""),[h,d]=Ae.useState(null),[p,m]=Ae.useState(!1);if(Ae.useEffect(()=>{if(!e){d(null);return}let g=!1;const f=new URLSearchParams;t&&f.set("targetSessionId",t.id),c.trim()&&f.set("prompt",c.trim());const v=f.toString();return fetch(`/api/advisors/${encodeURIComponent(e.id)}/preview${v?`?${v}`:""}`).then(y=>y.ok?y.json():null).then(y=>{g||d(y)}).catch(()=>{g||d(null)}),()=>{g=!0}},[e==null?void 0:e.id,t==null?void 0:t.id,c]),!e)return null;const x=()=>{r(e.id,c.trim()||void 0),u("")};return S.jsxs("div",{className:"absolute top-16 right-0 bottom-0 w-[420px] bg-solix-panel border-l border-solix-border backdrop-blur-md flex flex-col z-20",children:[S.jsxs("div",{className:"px-4 py-3 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-amber-200/70",children:"Advisor"}),S.jsxs("div",{className:"text-lg font-semibold flex items-center gap-2",children:[S.jsx("span",{style:{color:e.color},children:e.glyph}),S.jsx("span",{children:e.codename}),e.pinned&&S.jsx("span",{className:"text-[10px] uppercase tracking-wider text-amber-300 border border-amber-300/40 rounded px-1.5 py-0.5",children:"pinned"}),!e.enabled&&S.jsx("span",{className:"text-[10px] uppercase tracking-wider text-cyan-300 border border-cyan-300/40 rounded px-1.5 py-0.5",children:"opt-in"})]}),S.jsxs("div",{className:"text-xs text-slate-400 mt-0.5",children:[e.name," · ",String(e.defaultModel)]})]}),S.jsx("button",{onClick:()=>i(null),className:"text-slate-400 hover:text-slate-100","aria-label":"Close",children:"✕"})]}),S.jsx("div",{className:"px-4 py-3 border-b border-solix-border text-sm text-slate-300 leading-relaxed",children:e.description}),e.requiredSkills.length>0&&S.jsxs("div",{className:"px-4 py-2 border-b border-solix-border",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500 mb-1",children:"requires skills"}),S.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.requiredSkills.map(g=>S.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-solix-accent/15 border border-solix-accent/40 text-solix-accent",children:g},g))})]}),S.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 text-sm text-slate-300",children:[S.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-400",children:"Invoke"}),S.jsx("div",{className:"text-xs text-slate-500",children:t?S.jsxs(S.Fragment,{children:["Will dispatch to"," ",S.jsx("span",{className:"text-slate-200",children:t.name??t.id.slice(0,8)})," ",S.jsxs("span",{className:"text-slate-500",children:["(",t.cwd,")"]})]}):S.jsx(S.Fragment,{children:"No planet focused. Click a user planet first to set a target."})}),S.jsx("textarea",{value:c,onChange:g=>u(g.target.value),placeholder:`Optional: hand ${e.codename} a specific brief…`,rows:4,className:"w-full text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"}),h&&S.jsxs("div",{className:"rounded border border-solix-border bg-black/30",children:[S.jsxs("button",{onClick:()=>m(g=>!g),className:"w-full text-left px-2 py-1.5 text-xs flex items-center justify-between text-slate-400 hover:text-slate-100",children:[S.jsxs("span",{children:["Context envelope · ",h.recentMissionsCount," mission(s)",h.contextUsagePct!==null&&` · target at ${h.contextUsagePct.toFixed(0)}%`]}),S.jsx("span",{children:p?"▾":"▸"})]}),p&&S.jsx("pre",{className:"text-[10.5px] text-slate-300 whitespace-pre-wrap px-3 pb-3 max-h-72 overflow-auto leading-relaxed",children:h.prompt})]})]}),e.enabled?S.jsxs("div",{className:"px-4 py-3 border-t border-solix-border flex gap-2",children:[S.jsx("button",{onClick:x,className:"flex-1 py-2 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30",children:"Invoke"}),e.pinned?S.jsx("button",{onClick:()=>o(e.id),className:"px-3 py-2 rounded bg-amber-500/15 border border-amber-400/50 text-amber-200 text-sm hover:bg-amber-500/25",children:"Unpin"}):S.jsx("button",{onClick:()=>s(e.id),className:"px-3 py-2 rounded bg-amber-500/10 border border-amber-400/30 text-amber-200/80 text-sm hover:bg-amber-500/20",title:"Spawn an always-on session for this advisor",children:"Pin"}),S.jsx("button",{onClick:()=>l(e.id),className:"px-3 py-2 rounded border border-solix-border text-slate-400 text-sm hover:text-white hover:bg-solix-border/30",title:"Remove from crew (keeps it available as opt-in)",children:"Disable"})]}):S.jsxs("div",{className:"px-4 py-3 border-t border-solix-border flex flex-col gap-2",children:[S.jsx("button",{onClick:()=>a(e.id),className:"w-full py-2 rounded bg-cyan-500/20 border border-cyan-400/60 text-cyan-100 text-sm hover:bg-cyan-500/30",title:"Add this advisor to your crew (renders in the inner ring, selectable in + Task)",children:"+ Add to crew"}),S.jsx("button",{onClick:x,className:"w-full py-1.5 rounded border border-solix-border text-slate-300 text-xs hover:text-white hover:bg-solix-border/30",children:"Invoke once without adding"})]})]})}function C3(){const n=xe(c=>c.selectedSkillId),e=xe(c=>n?c.skills[n]:null),t=xe(c=>c.selectSkill),i=xe(c=>c.advisors),[r,s]=Ae.useState(null),[o,a]=Ae.useState(!1);if(Ae.useEffect(()=>{if(!n){s(null);return}let c=!1;return a(!0),fetch(`/api/skills/${encodeURIComponent(n)}`).then(u=>u.ok?u.json():null).then(u=>{c||s(u)}).catch(()=>{c||s(null)}).finally(()=>{c||a(!1)}),()=>{c=!0}},[n]),!e)return null;const l=Object.values(i).filter(c=>c.requiredSkills.some(u=>e.id.endsWith(`:${u}`)||e.id===u));return S.jsxs("div",{className:"absolute top-16 right-0 bottom-0 w-[480px] bg-solix-panel border-l border-solix-border backdrop-blur-md flex flex-col z-20",children:[S.jsxs("div",{className:"px-4 py-3 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsxs("div",{className:"text-xs uppercase tracking-wide text-cyan-300/70",children:["Skill · ",e.source]}),S.jsx("div",{className:"text-lg font-semibold",children:e.name}),S.jsx("div",{className:"text-xs text-slate-400 mt-0.5 break-all",children:e.id})]}),S.jsx("button",{onClick:()=>t(null),className:"text-slate-400 hover:text-slate-100","aria-label":"Close",children:"✕"})]}),l.length>0&&S.jsxs("div",{className:"px-4 py-2 border-b border-solix-border",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500 mb-1",children:"required by"}),S.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(c=>S.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded border border-amber-300/40 text-amber-200",children:[S.jsx("span",{className:"mr-1",children:c.glyph}),c.codename]},c.id))})]}),S.jsx("div",{className:"px-4 py-3 border-b border-solix-border text-sm text-slate-300 leading-relaxed",children:e.description}),S.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500 mb-2",children:"manifest"}),o&&S.jsx("div",{className:"text-sm text-slate-500 italic",children:"Loading…"}),r&&S.jsx("pre",{className:"text-[11px] text-slate-300 whitespace-pre-wrap break-words bg-black/40 p-3 rounded border border-solix-border",children:r.manifest})]}),S.jsx("div",{className:"px-4 py-3 border-t border-solix-border text-xs text-slate-500",children:e.installedInProjects.length===0?"Not installed in any project yet.":`Installed in ${e.installedInProjects.length} project(s).`})]})}const R3=["default","opus","sonnet","haiku"];function P3({open:n,onClose:e}){const t=xe(U=>U.projects),i=xe(U=>U.advisors),r=xe(U=>U.goals),s=xe(U=>U.launchTask),o=Object.values(t).sort((U,z)=>z.lastActiveAt-U.lastActiveAt),a=Ae.useMemo(()=>Object.values(i).filter(U=>U.enabled).sort((U,z)=>U.codename.localeCompare(z.codename)),[i]),[l,c]=Ae.useState(""),[u,h]=Ae.useState("default"),[d,p]=Ae.useState(null),[m,x]=Ae.useState(""),[g,f]=Ae.useState(""),[v,y]=Ae.useState(""),[_,C]=Ae.useState(""),[w,E]=Ae.useState(null),A=Object.values(r),[b,M]=Ae.useState(null),[L,G]=Ae.useState(!0);if(Ae.useEffect(()=>{if(!n)return;let U=!1;return fetch("/api/system/preflight").then(z=>z.ok?z.json():null).then(z=>{U||M(z)}).catch(()=>{}),()=>{U=!0}},[n]),Ae.useEffect(()=>{if(!n||l)return;const U=o[0];U&&c(U.cwd)},[n,o,l]),!n)return null;const B=()=>{const U=l.trim(),z=m.trim();if(!U||!z)return;const Z=d?a.find(X=>X.id===d):void 0,D=Z?`[Acting as ${Z.codename} — ${Z.name}. ${Z.description}]
|
|
3899
3899
|
|
|
3900
|
-
${z}`:z,$=Z&&u==="default"?Z.defaultModel:u,K=g.trim(),se=L&&(b==null?void 0:b.agentViewAvailable)===!0,Te=parseFloat(_),qe=Number.isFinite(Te)&&Te>0?Te:void 0;s(U,$,D,{worktreeBranch:se?void 0:K||void 0,worktreeBaseRef:se?void 0:K&&v.trim()||void 0,useAgentView:se,agentName:Z==null?void 0:Z.codename.toLowerCase(),budgetUsd:qe,goalId:w??void 0}),x(""),p(null),f(""),y(""),C(""),E(null),e()},j=async()=>{const U=window.prompt("New goal name:");if(U!=null&&U.trim())try{const z=await fetch("/api/goals",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:U.trim()})});if(z.ok){const Z=await z.json();E(Z.id)}}catch{}};return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm",children:S.jsxs("div",{className:"w-[520px] max-w-[92vw] rounded-xl border border-solix-accent/40 bg-solix-panel/95 shadow-2xl",children:[S.jsxs("div",{className:"px-5 py-4 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"new task"}),S.jsx("div",{className:"text-lg font-semibold mt-0.5",children:"Launch a Claude Code session"}),S.jsx("div",{className:"text-xs text-slate-400 mt-1",children:b!=null&&b.agentViewAvailable&&L?S.jsxs(S.Fragment,{children:["Dispatches via"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude --bg"})," ","— the session shows up in both Solix and"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude agents"}),"."]}):S.jsxs(S.Fragment,{children:["Solix will spawn ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude --print"})," ","in this folder. A new planet appears the moment it starts."]})}),b&&!b.claudeAvailable&&S.jsxs("div",{className:"mt-2 text-[11px] text-solix-danger border border-solix-danger/40 bg-solix-danger/10 rounded px-2 py-1",children:[S.jsx("span",{className:"font-semibold",children:"claude"})," not found on the server's PATH. Install Claude Code, then restart the Solix server."]}),(b==null?void 0:b.claudeAvailable)&&b.version&&S.jsxs("div",{className:"mt-1 text-[10px] text-slate-500 font-mono",children:["claude detected · ",b.version,b.agentViewAvailable&&S.jsxs(S.Fragment,{children:[" ","·"," ",S.jsx("button",{onClick:()=>G(U=>!U),className:`underline decoration-dotted ${L?"text-solix-accent":"text-slate-500 hover:text-slate-300"}`,title:"Toggle dispatch through Anthropic's Agent View",children:L?"agent view: on":"agent view: off"})]})]})]}),S.jsx("button",{onClick:e,className:"text-slate-400 hover:text-slate-100",children:"✕"})]}),S.jsxs("div",{className:"px-5 py-4 space-y-4",children:[S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Working directory"}),o.length>0&&S.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:o.slice(0,6).map(U=>S.jsx("button",{onClick:()=>c(U.cwd),className:`text-[10px] px-2 py-1 rounded border ${l===U.cwd?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:U.name},U.id))}),S.jsx("input",{value:l,onChange:U=>c(U.target.value),placeholder:"/Users/you/path/to/project",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Model"}),S.jsx("div",{className:"flex gap-1.5",children:R3.map(U=>S.jsx("button",{onClick:()=>h(U),className:`text-xs px-3 py-1.5 rounded border ${u===U?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:U},U))})]}),a.length>0&&S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Advisor ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.jsx("button",{onClick:()=>p(null),className:`text-xs px-3 py-1.5 rounded border ${d===null?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:"none"}),a.map(U=>S.jsxs("button",{onClick:()=>p(U.id),title:U.description,className:`text-xs px-3 py-1.5 rounded border flex items-center gap-1.5 ${d===U.id?"border-amber-300 text-amber-100 bg-amber-500/15":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:[S.jsx("span",{style:{color:U.color},children:U.glyph}),U.codename]},U.id))]}),d&&S.jsx("div",{className:"mt-1.5 text-[10px] text-slate-500 italic",children:"The advisor's role will be prepended to your prompt."})]}),S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Worktree branch"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsx("input",{value:g,onChange:U=>f(U.target.value),placeholder:"leave empty to run in the chosen directory",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"}),g.trim()&&S.jsxs("div",{className:"mt-2 space-y-1",children:[S.jsxs("div",{className:"text-[10px] text-slate-500 italic",children:["Solix will create (or reuse) a fresh git worktree at ~/.solix/worktrees/<repo>-",g.trim()||"<branch>","and spawn Claude there. Existing branches are reused."]}),S.jsx("input",{value:v,onChange:U=>y(U.target.value),placeholder:"based on (default: HEAD)",className:"w-full text-xs font-mono bg-black/40 border border-solix-border rounded p-1.5 text-slate-200 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]})]}),S.jsxs("div",{className:"flex gap-3",children:[S.jsxs("label",{className:"block flex-1",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Budget"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(USD, optional)"})]}),S.jsx("input",{value:_,onChange:U=>C(U.target.value),inputMode:"decimal",placeholder:"e.g. 2.00",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]}),S.jsxs("label",{className:"block flex-1",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Goal"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.jsx("button",{onClick:()=>E(null),className:`text-xs px-2.5 py-1.5 rounded border ${w===null?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:"none"}),A.map(U=>S.jsxs("button",{onClick:()=>E(U.id),className:`text-xs px-2.5 py-1.5 rounded border flex items-center gap-1.5 ${w===U.id?"border-solix-accent text-slate-100 bg-solix-accent/15":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:[S.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:U.color}}),U.name]},U.id)),S.jsx("button",{onClick:j,className:"text-xs px-2.5 py-1.5 rounded border border-dashed border-solix-border text-slate-400 hover:text-slate-100",children:"+ new"})]})]})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Prompt"}),S.jsx("textarea",{value:m,onChange:U=>x(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&(U.preventDefault(),B())},placeholder:"What should this Claude Code session do?",rows:4,className:"w-full text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"})]})]}),S.jsxs("div",{className:"px-5 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:e,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Cancel"}),S.jsx("div",{className:"flex-1"}),S.jsx("span",{className:"text-[10px] text-slate-500 mr-2",children:"Cmd/Ctrl+Enter"}),S.jsx("button",{onClick:B,disabled:!l.trim()||!m.trim()||(b==null?void 0:b.claudeAvailable)===!1,className:"px-4 py-1.5 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30 disabled:opacity-40",children:"Launch"})]})]})})}const I3=1500;function N3(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`}function L3(){let n=null,e=!1;const t=r=>{n&&n.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r))};xe.getState().attachSocket(t);const i=()=>{if(e)return;n=new WebSocket(N3()),n.onopen=()=>{xe.getState().setConnected(!0)},n.onmessage=s=>{try{const o=JSON.parse(s.data);xe.getState().applyMessage(o)}catch(o){console.warn("[ws] bad message",o)}};const r=()=>{xe.getState().setConnected(!1),e||setTimeout(i,I3)};n.onclose=r,n.onerror=()=>n==null?void 0:n.close()};i(),window.addEventListener("beforeunload",()=>{e=!0,n==null||n.close()})}const D3=Ae.lazy(()=>Ad(()=>import("./Scene-gMUGX2_a.js"),[]).then(n=>({default:n.Scene}))),U3=Ae.lazy(()=>Ad(()=>import("./TimelineDrawer-BQo9SqvU.js"),[]).then(n=>({default:n.TimelineDrawer}))),k3=Ae.lazy(()=>Ad(()=>import("./GalaxyPanel-DV-kbENC.js"),[]).then(n=>({default:n.GalaxyPanel}))),O3=Ae.lazy(()=>Ad(()=>import("./CrewPanel-CVTXUelp.js"),[]).then(n=>({default:n.CrewPanel})));function F3(){const[n,e]=Ae.useState(!1),[t,i]=Ae.useState(!1),[r,s]=Ae.useState(!1),[o,a]=Ae.useState(!1),[l,c]=Ae.useState(!1),u=xe(m=>m.selectedSessionId),h=xe(m=>m.selectedAdvisorId),d=xe(m=>m.selectedSkillId),p=u?460:h?420:d||n?480:0;return Ae.useEffect(()=>{L3()},[]),Ae.useEffect(()=>{const m=x=>{const g=xe.getState(),f=x.target,v=(f==null?void 0:f.tagName)==="INPUT"||(f==null?void 0:f.tagName)==="TEXTAREA"||(f==null?void 0:f.isContentEditable)===!0,_=Object.values(g.pendingPermissions)[0];x.key==="Escape"?(g.selectSession(null),g.selectAdvisor(null),g.selectSkill(null),e(!1),i(!1),a(!1),c(!1),g.playback.active&&(g.exitPlayback(),s(!1))):!v&&x.key==="?"?a(C=>!C):!v&&(x.key==="g"||x.key==="G")?e(C=>!C):!v&&(x.key==="c"||x.key==="C")?c(C=>!C):!v&&(x.key==="l"||x.key==="L")?i(!0):!v&&(x.key==="+"||x.key==="=")?gw():!v&&x.key==="-"?x3():!v&&x.key==="0"?M3():!v&&x.key==="ArrowLeft"?v3():!v&&x.key==="ArrowRight"?y3():!v&&x.key==="ArrowUp"?_3():!v&&x.key==="ArrowDown"?S3():!v&&x.key===" "?(x.preventDefault(),g.toggleMotion()):!v&&(x.key==="v"||x.key==="V")?g.toggleViewMode():!v&&(x.key==="m"||x.key==="M")?g.setViewMode("missions"):!v&&(x.key==="t"||x.key==="T")?s(C=>!C):!v&&_&&(x.key==="y"||x.key==="Y")?g.resolvePermission(_.requestId,!0):!v&&_&&(x.key==="n"||x.key==="N")&&g.resolvePermission(_.requestId,!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[]),S.jsxs("div",{className:"relative h-full w-full",children:[S.jsx(B3,{}),S.jsx(jE,{onOpenGalaxy:()=>e(!0),onNewTask:()=>i(!0),onOpenTimeline:()=>s(!0),onOpenHelp:()=>a(!0),onOpenCrew:()=>c(!0)}),S.jsx(KE,{panelOffsetPx:p}),S.jsx(w3,{}),S.jsx(A3,{}),S.jsx(C3,{}),n&&S.jsx(Ae.Suspense,{fallback:null,children:S.jsx(k3,{open:n,onClose:()=>e(!1)})}),l&&S.jsx(Ae.Suspense,{fallback:null,children:S.jsx(O3,{open:l,onClose:()=>c(!1)})}),S.jsx(P3,{open:t,onClose:()=>i(!1)}),r&&S.jsx(Ae.Suspense,{fallback:null,children:S.jsx(U3,{open:r,onClose:()=>s(!1)})}),S.jsx(sT,{}),S.jsx(YE,{onOpenGalaxy:()=>e(!0),forceOpen:o,onClose:()=>a(!1)}),S.jsx($E,{}),S.jsx(V3,{})]})}function B3(){const n=xe(e=>e.viewMode);return n==="list"?S.jsx(DE,{}):n==="missions"?S.jsx(VE,{}):S.jsx(Ae.Suspense,{fallback:S.jsx(z3,{}),children:S.jsx(D3,{})})}function z3(){return S.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-solix-bg z-0",children:S.jsx("div",{className:"text-xs text-slate-500 uppercase tracking-widest solix-pulse",children:"loading galaxy…"})})}function V3(){const n=xe(t=>Object.keys(t.sessions).length),e=xe(t=>t.connected);return n>0?null:S.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center z-10",children:S.jsxs("div",{className:"rounded-lg border border-solix-border bg-solix-panel p-6 max-w-md text-center backdrop-blur",children:[S.jsx("div",{className:"text-sm uppercase tracking-widest text-solix-accent",children:"empty system"}),S.jsx("div",{className:"mt-2 text-slate-200",children:e?"Run `claude` in any terminal — the planet will appear here.":"Waiting for the Solix server…"}),S.jsx("div",{className:"mt-3 text-xs text-slate-500",children:"The sun is mission control. Each agent orbits it as a planet."})]})})}const xw=document.getElementById("root");if(!xw)throw new Error("#root not found");K_(xw).render(S.jsx(Ae.StrictMode,{children:S.jsx(F3,{})}));export{Ms as $,zS as A,cT as B,Vd as C,vi as D,ke as E,Pe as F,sA as G,_e as H,lw as I,Ct as J,yN as K,zd as L,oT as M,ji as N,Hd as O,Yt as P,En as Q,qN as R,_M as S,J3 as T,Ei as U,gi as V,_I as W,Rp as X,Hn as Y,rg as Z,ws as _,cS as a,Sn as a0,li as a1,Ut as a2,WM as a3,Gt as a4,YS as a5,Ti as a6,tr as a7,Fi as a8,fn as a9,$3 as aA,Y3 as aB,Q3 as aC,eL as aD,j3 as aE,Zi as aa,Wi as ab,Eg as ac,on as ad,RS as ae,Ye as af,ht as ag,Ow as ah,Ho as ai,sl as aj,UI as ak,xe as al,IE as am,q3 as an,H3 as ao,NE as ap,Z3 as aq,Bm as ar,oS as as,LE as at,G3 as au,W3 as av,X3 as aw,nt as ax,sS as ay,PE as az,zm as b,I as c,Q as d,uw as e,dn as f,Fv as g,K_ as h,Rd as i,S as j,aT as k,ZN as l,Go as m,mr as n,$N as o,bs as p,FM as q,Ae as r,pn as s,rn as t,ci as u,uM as v,fe as w,kt as x,ct as y,QN as z};
|
|
3900
|
+
${z}`:z,$=Z&&u==="default"?Z.defaultModel:u,K=g.trim(),se=L&&(b==null?void 0:b.agentViewAvailable)===!0,Te=parseFloat(_),qe=Number.isFinite(Te)&&Te>0?Te:void 0;s(U,$,D,{worktreeBranch:se?void 0:K||void 0,worktreeBaseRef:se?void 0:K&&v.trim()||void 0,useAgentView:se,agentName:Z==null?void 0:Z.codename.toLowerCase(),budgetUsd:qe,goalId:w??void 0}),x(""),p(null),f(""),y(""),C(""),E(null),e()},j=async()=>{const U=window.prompt("New goal name:");if(U!=null&&U.trim())try{const z=await fetch("/api/goals",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:U.trim()})});if(z.ok){const Z=await z.json();E(Z.id)}}catch{}};return S.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm",children:S.jsxs("div",{className:"w-[520px] max-w-[92vw] rounded-xl border border-solix-accent/40 bg-solix-panel/95 shadow-2xl",children:[S.jsxs("div",{className:"px-5 py-4 border-b border-solix-border flex items-start justify-between",children:[S.jsxs("div",{children:[S.jsx("div",{className:"text-xs uppercase tracking-widest text-solix-accent",children:"new task"}),S.jsx("div",{className:"text-lg font-semibold mt-0.5",children:"Launch a Claude Code session"}),S.jsx("div",{className:"text-xs text-slate-400 mt-1",children:b!=null&&b.agentViewAvailable&&L?S.jsxs(S.Fragment,{children:["Dispatches via"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude --bg"})," ","— the session shows up in both Solix and"," ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude agents"}),"."]}):S.jsxs(S.Fragment,{children:["Solix will spawn ",S.jsx("code",{className:"bg-black/40 px-1 rounded",children:"claude --print"})," ","in this folder. A new planet appears the moment it starts."]})}),b&&!b.claudeAvailable&&S.jsxs("div",{className:"mt-2 text-[11px] text-solix-danger border border-solix-danger/40 bg-solix-danger/10 rounded px-2 py-1",children:[S.jsx("span",{className:"font-semibold",children:"claude"})," not found on the server's PATH. Install Claude Code, then restart the Solix server."]}),(b==null?void 0:b.claudeAvailable)&&b.version&&S.jsxs("div",{className:"mt-1 text-[10px] text-slate-500 font-mono",children:["claude detected · ",b.version,b.agentViewAvailable&&S.jsxs(S.Fragment,{children:[" ","·"," ",S.jsx("button",{onClick:()=>G(U=>!U),className:`underline decoration-dotted ${L?"text-solix-accent":"text-slate-500 hover:text-slate-300"}`,title:"Toggle dispatch through Anthropic's Agent View",children:L?"agent view: on":"agent view: off"})]})]})]}),S.jsx("button",{onClick:e,className:"text-slate-400 hover:text-slate-100",children:"✕"})]}),S.jsxs("div",{className:"px-5 py-4 space-y-4",children:[S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Working directory"}),o.length>0&&S.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:o.slice(0,6).map(U=>S.jsx("button",{onClick:()=>c(U.cwd),className:`text-[10px] px-2 py-1 rounded border ${l===U.cwd?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:U.name},U.id))}),S.jsx("input",{value:l,onChange:U=>c(U.target.value),placeholder:"/Users/you/path/to/project",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Model"}),S.jsx("div",{className:"flex gap-1.5",children:R3.map(U=>S.jsx("button",{onClick:()=>h(U),className:`text-xs px-3 py-1.5 rounded border ${u===U?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:U},U))})]}),a.length>0&&S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Advisor ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.jsx("button",{onClick:()=>p(null),className:`text-xs px-3 py-1.5 rounded border ${d===null?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:"none"}),a.map(U=>S.jsxs("button",{onClick:()=>p(U.id),title:U.description,className:`text-xs px-3 py-1.5 rounded border flex items-center gap-1.5 ${d===U.id?"border-amber-300 text-amber-100 bg-amber-500/15":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:[S.jsx("span",{style:{color:U.color},children:U.glyph}),U.codename]},U.id))]}),d&&S.jsx("div",{className:"mt-1.5 text-[10px] text-slate-500 italic",children:"The advisor's role will be prepended to your prompt."})]}),S.jsxs("label",{className:"block",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Worktree branch"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsx("input",{value:g,onChange:U=>f(U.target.value),placeholder:"leave empty to run in the chosen directory",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"}),g.trim()&&S.jsxs("div",{className:"mt-2 space-y-1",children:[S.jsxs("div",{className:"text-[10px] text-slate-500 italic",children:["Solix will create (or reuse) a fresh git worktree at ~/.solix/worktrees/<repo>-",g.trim()||"<branch>","and spawn Claude there. Existing branches are reused."]}),S.jsx("input",{value:v,onChange:U=>y(U.target.value),placeholder:"based on (default: HEAD)",className:"w-full text-xs font-mono bg-black/40 border border-solix-border rounded p-1.5 text-slate-200 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]})]}),S.jsxs("div",{className:"flex gap-3",children:[S.jsxs("label",{className:"block flex-1",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Budget"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(USD, optional)"})]}),S.jsx("input",{value:_,onChange:U=>C(U.target.value),inputMode:"decimal",placeholder:"e.g. 2.00",className:"w-full text-sm font-mono bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent"})]}),S.jsxs("label",{className:"block flex-1",children:[S.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:["Goal"," ",S.jsx("span",{className:"text-slate-600 normal-case",children:"(optional)"})]}),S.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.jsx("button",{onClick:()=>E(null),className:`text-xs px-2.5 py-1.5 rounded border ${w===null?"bg-solix-accent/20 border-solix-accent text-solix-accent":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:"none"}),A.map(U=>S.jsxs("button",{onClick:()=>E(U.id),className:`text-xs px-2.5 py-1.5 rounded border flex items-center gap-1.5 ${w===U.id?"border-solix-accent text-slate-100 bg-solix-accent/15":"border-solix-border text-slate-300 hover:bg-solix-border/30"}`,children:[S.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:U.color}}),U.name]},U.id)),S.jsx("button",{onClick:j,className:"text-xs px-2.5 py-1.5 rounded border border-dashed border-solix-border text-slate-400 hover:text-slate-100",children:"+ new"})]})]})]}),S.jsxs("label",{className:"block",children:[S.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-1",children:"Prompt"}),S.jsx("textarea",{value:m,onChange:U=>x(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&(U.preventDefault(),B())},placeholder:"What should this Claude Code session do?",rows:4,className:"w-full text-sm bg-black/40 border border-solix-border rounded p-2 text-slate-100 placeholder-slate-600 focus:outline-none focus:border-solix-accent resize-none"})]})]}),S.jsxs("div",{className:"px-5 py-3 border-t border-solix-border flex items-center gap-2",children:[S.jsx("button",{onClick:e,className:"px-3 py-1.5 rounded border border-solix-border text-xs text-slate-300 hover:text-white",children:"Cancel"}),S.jsx("div",{className:"flex-1"}),S.jsx("span",{className:"text-[10px] text-slate-500 mr-2",children:"Cmd/Ctrl+Enter"}),S.jsx("button",{onClick:B,disabled:!l.trim()||!m.trim()||(b==null?void 0:b.claudeAvailable)===!1,className:"px-4 py-1.5 rounded bg-solix-accent/20 border border-solix-accent text-solix-accent text-sm hover:bg-solix-accent/30 disabled:opacity-40",children:"Launch"})]})]})})}const I3=1500;function N3(){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`}function L3(){let n=null,e=!1;const t=r=>{n&&n.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r))};xe.getState().attachSocket(t);const i=()=>{if(e)return;n=new WebSocket(N3()),n.onopen=()=>{xe.getState().setConnected(!0)},n.onmessage=s=>{try{const o=JSON.parse(s.data);xe.getState().applyMessage(o)}catch(o){console.warn("[ws] bad message",o)}};const r=()=>{xe.getState().setConnected(!1),e||setTimeout(i,I3)};n.onclose=r,n.onerror=()=>n==null?void 0:n.close()};i(),window.addEventListener("beforeunload",()=>{e=!0,n==null||n.close()})}const D3=Ae.lazy(()=>Ad(()=>import("./Scene-NahUVf-g.js"),[]).then(n=>({default:n.Scene}))),U3=Ae.lazy(()=>Ad(()=>import("./TimelineDrawer-CpPhGaYI.js"),[]).then(n=>({default:n.TimelineDrawer}))),k3=Ae.lazy(()=>Ad(()=>import("./GalaxyPanel-YXuzkrWv.js"),[]).then(n=>({default:n.GalaxyPanel}))),O3=Ae.lazy(()=>Ad(()=>import("./CrewPanel-CCQyVXEO.js"),[]).then(n=>({default:n.CrewPanel})));function F3(){const[n,e]=Ae.useState(!1),[t,i]=Ae.useState(!1),[r,s]=Ae.useState(!1),[o,a]=Ae.useState(!1),[l,c]=Ae.useState(!1),u=xe(m=>m.selectedSessionId),h=xe(m=>m.selectedAdvisorId),d=xe(m=>m.selectedSkillId),p=u?460:h?420:d||n?480:0;return Ae.useEffect(()=>{L3()},[]),Ae.useEffect(()=>{const m=x=>{const g=xe.getState(),f=x.target,v=(f==null?void 0:f.tagName)==="INPUT"||(f==null?void 0:f.tagName)==="TEXTAREA"||(f==null?void 0:f.isContentEditable)===!0,_=Object.values(g.pendingPermissions)[0];x.key==="Escape"?(g.selectSession(null),g.selectAdvisor(null),g.selectSkill(null),e(!1),i(!1),a(!1),c(!1),g.playback.active&&(g.exitPlayback(),s(!1))):!v&&x.key==="?"?a(C=>!C):!v&&(x.key==="g"||x.key==="G")?e(C=>!C):!v&&(x.key==="c"||x.key==="C")?c(C=>!C):!v&&(x.key==="l"||x.key==="L")?i(!0):!v&&(x.key==="+"||x.key==="=")?gw():!v&&x.key==="-"?x3():!v&&x.key==="0"?M3():!v&&x.key==="ArrowLeft"?v3():!v&&x.key==="ArrowRight"?y3():!v&&x.key==="ArrowUp"?_3():!v&&x.key==="ArrowDown"?S3():!v&&x.key===" "?(x.preventDefault(),g.toggleMotion()):!v&&(x.key==="v"||x.key==="V")?g.toggleViewMode():!v&&(x.key==="m"||x.key==="M")?g.setViewMode("missions"):!v&&(x.key==="t"||x.key==="T")?s(C=>!C):!v&&_&&(x.key==="y"||x.key==="Y")?g.resolvePermission(_.requestId,!0):!v&&_&&(x.key==="n"||x.key==="N")&&g.resolvePermission(_.requestId,!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[]),S.jsxs("div",{className:"relative h-full w-full",children:[S.jsx(B3,{}),S.jsx(jE,{onOpenGalaxy:()=>e(!0),onNewTask:()=>i(!0),onOpenTimeline:()=>s(!0),onOpenHelp:()=>a(!0),onOpenCrew:()=>c(!0)}),S.jsx(KE,{panelOffsetPx:p}),S.jsx(w3,{}),S.jsx(A3,{}),S.jsx(C3,{}),n&&S.jsx(Ae.Suspense,{fallback:null,children:S.jsx(k3,{open:n,onClose:()=>e(!1)})}),l&&S.jsx(Ae.Suspense,{fallback:null,children:S.jsx(O3,{open:l,onClose:()=>c(!1)})}),S.jsx(P3,{open:t,onClose:()=>i(!1)}),r&&S.jsx(Ae.Suspense,{fallback:null,children:S.jsx(U3,{open:r,onClose:()=>s(!1)})}),S.jsx(sT,{}),S.jsx(YE,{onOpenGalaxy:()=>e(!0),forceOpen:o,onClose:()=>a(!1)}),S.jsx($E,{}),S.jsx(V3,{})]})}function B3(){const n=xe(e=>e.viewMode);return n==="list"?S.jsx(DE,{}):n==="missions"?S.jsx(VE,{}):S.jsx(Ae.Suspense,{fallback:S.jsx(z3,{}),children:S.jsx(D3,{})})}function z3(){return S.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-solix-bg z-0",children:S.jsx("div",{className:"text-xs text-slate-500 uppercase tracking-widest solix-pulse",children:"loading galaxy…"})})}function V3(){const n=xe(t=>Object.keys(t.sessions).length),e=xe(t=>t.connected);return n>0?null:S.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center z-10",children:S.jsxs("div",{className:"rounded-lg border border-solix-border bg-solix-panel p-6 max-w-md text-center backdrop-blur",children:[S.jsx("div",{className:"text-sm uppercase tracking-widest text-solix-accent",children:"empty system"}),S.jsx("div",{className:"mt-2 text-slate-200",children:e?"Run `claude` in any terminal — the planet will appear here.":"Waiting for the Solix server…"}),S.jsx("div",{className:"mt-3 text-xs text-slate-500",children:"The sun is mission control. Each agent orbits it as a planet."})]})})}const xw=document.getElementById("root");if(!xw)throw new Error("#root not found");K_(xw).render(S.jsx(Ae.StrictMode,{children:S.jsx(F3,{})}));export{Ms as $,zS as A,cT as B,Vd as C,vi as D,ke as E,Pe as F,sA as G,_e as H,lw as I,Ct as J,yN as K,zd as L,oT as M,ji as N,Hd as O,Yt as P,En as Q,qN as R,_M as S,J3 as T,Ei as U,gi as V,_I as W,Rp as X,Hn as Y,rg as Z,ws as _,cS as a,Sn as a0,li as a1,Ut as a2,WM as a3,Gt as a4,YS as a5,Ti as a6,tr as a7,Fi as a8,fn as a9,$3 as aA,Y3 as aB,Q3 as aC,eL as aD,j3 as aE,Zi as aa,Wi as ab,Eg as ac,on as ad,RS as ae,Ye as af,ht as ag,Ow as ah,Ho as ai,sl as aj,UI as ak,xe as al,IE as am,q3 as an,H3 as ao,NE as ap,Z3 as aq,Bm as ar,oS as as,LE as at,G3 as au,W3 as av,X3 as aw,nt as ax,sS as ay,PE as az,zm as b,I as c,Q as d,uw as e,dn as f,Fv as g,K_ as h,Rd as i,S as j,aT as k,ZN as l,Go as m,mr as n,$N as o,bs as p,FM as q,Ae as r,pn as s,rn as t,ci as u,uM as v,fe as w,kt as x,ct as y,QN as z};
|