crewly 1.0.11 โ†’ 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/config/constants.ts +6 -0
  2. package/config/roles/orchestrator/self-evolution.md +72 -0
  3. package/config/skills/orchestrator/read-session-logs/execute.sh +14 -0
  4. package/config/skills/orchestrator/read-session-logs/instructions.md +33 -0
  5. package/config/skills/orchestrator/read-session-logs/skill.json +20 -0
  6. package/config/skills/orchestrator/read-system-logs/execute.sh +18 -0
  7. package/config/skills/orchestrator/read-system-logs/instructions.md +30 -0
  8. package/config/skills/orchestrator/read-system-logs/skill.json +20 -0
  9. package/config/skills/orchestrator/reply-slack/execute.sh +12 -0
  10. package/config/skills/orchestrator/reply-slack/instructions.md +16 -1
  11. package/config/skills/orchestrator/report-bug/execute.sh +49 -0
  12. package/config/skills/orchestrator/report-bug/instructions.md +30 -0
  13. package/config/skills/orchestrator/report-bug/skill.json +20 -0
  14. package/dist/backend/backend/src/constants.d.ts +24 -1
  15. package/dist/backend/backend/src/constants.d.ts.map +1 -1
  16. package/dist/backend/backend/src/constants.js +25 -2
  17. package/dist/backend/backend/src/constants.js.map +1 -1
  18. package/dist/backend/backend/src/controllers/monitoring/terminal.controller.d.ts +14 -0
  19. package/dist/backend/backend/src/controllers/monitoring/terminal.controller.d.ts.map +1 -1
  20. package/dist/backend/backend/src/controllers/monitoring/terminal.controller.js +74 -0
  21. package/dist/backend/backend/src/controllers/monitoring/terminal.controller.js.map +1 -1
  22. package/dist/backend/backend/src/controllers/orchestrator/orchestrator.controller.d.ts.map +1 -1
  23. package/dist/backend/backend/src/controllers/orchestrator/orchestrator.controller.js +20 -34
  24. package/dist/backend/backend/src/controllers/orchestrator/orchestrator.controller.js.map +1 -1
  25. package/dist/backend/backend/src/index.d.ts.map +1 -1
  26. package/dist/backend/backend/src/index.js +16 -1
  27. package/dist/backend/backend/src/index.js.map +1 -1
  28. package/dist/backend/backend/src/routes/modules/terminal.routes.d.ts.map +1 -1
  29. package/dist/backend/backend/src/routes/modules/terminal.routes.js +2 -0
  30. package/dist/backend/backend/src/routes/modules/terminal.routes.js.map +1 -1
  31. package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts +24 -2
  32. package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts.map +1 -1
  33. package/dist/backend/backend/src/services/agent/agent-registration.service.js +191 -89
  34. package/dist/backend/backend/src/services/agent/agent-registration.service.js.map +1 -1
  35. package/dist/backend/backend/src/services/agent/codex-runtime.service.d.ts +5 -1
  36. package/dist/backend/backend/src/services/agent/codex-runtime.service.d.ts.map +1 -1
  37. package/dist/backend/backend/src/services/agent/codex-runtime.service.js +10 -17
  38. package/dist/backend/backend/src/services/agent/codex-runtime.service.js.map +1 -1
  39. package/dist/backend/backend/src/services/agent/context-window-monitor.service.d.ts +16 -0
  40. package/dist/backend/backend/src/services/agent/context-window-monitor.service.d.ts.map +1 -1
  41. package/dist/backend/backend/src/services/agent/context-window-monitor.service.js +111 -10
  42. package/dist/backend/backend/src/services/agent/context-window-monitor.service.js.map +1 -1
  43. package/dist/backend/backend/src/services/agent/gemini-runtime.service.d.ts +33 -2
  44. package/dist/backend/backend/src/services/agent/gemini-runtime.service.d.ts.map +1 -1
  45. package/dist/backend/backend/src/services/agent/gemini-runtime.service.js +388 -20
  46. package/dist/backend/backend/src/services/agent/gemini-runtime.service.js.map +1 -1
  47. package/dist/backend/backend/src/services/agent/runtime-agent.service.abstract.d.ts +1 -1
  48. package/dist/backend/backend/src/services/agent/runtime-agent.service.abstract.d.ts.map +1 -1
  49. package/dist/backend/backend/src/services/agent/runtime-agent.service.abstract.js +1 -1
  50. package/dist/backend/backend/src/services/agent/runtime-agent.service.abstract.js.map +1 -1
  51. package/dist/backend/backend/src/services/agent/runtime-exit-monitor.service.d.ts +17 -2
  52. package/dist/backend/backend/src/services/agent/runtime-exit-monitor.service.d.ts.map +1 -1
  53. package/dist/backend/backend/src/services/agent/runtime-exit-monitor.service.js +105 -12
  54. package/dist/backend/backend/src/services/agent/runtime-exit-monitor.service.js.map +1 -1
  55. package/dist/backend/backend/src/services/core/config.service.d.ts.map +1 -1
  56. package/dist/backend/backend/src/services/core/config.service.js +3 -2
  57. package/dist/backend/backend/src/services/core/config.service.js.map +1 -1
  58. package/dist/backend/backend/src/services/messaging/message-queue.service.d.ts.map +1 -1
  59. package/dist/backend/backend/src/services/messaging/message-queue.service.js +17 -0
  60. package/dist/backend/backend/src/services/messaging/message-queue.service.js.map +1 -1
  61. package/dist/backend/backend/src/services/orchestrator/orchestrator-restart.service.d.ts +5 -0
  62. package/dist/backend/backend/src/services/orchestrator/orchestrator-restart.service.d.ts.map +1 -1
  63. package/dist/backend/backend/src/services/orchestrator/orchestrator-restart.service.js +42 -2
  64. package/dist/backend/backend/src/services/orchestrator/orchestrator-restart.service.js.map +1 -1
  65. package/dist/backend/backend/src/services/session/pty/pty-session-backend.d.ts +39 -0
  66. package/dist/backend/backend/src/services/session/pty/pty-session-backend.d.ts.map +1 -1
  67. package/dist/backend/backend/src/services/session/pty/pty-session-backend.js +121 -1
  68. package/dist/backend/backend/src/services/session/pty/pty-session-backend.js.map +1 -1
  69. package/dist/backend/backend/src/services/settings/settings.service.d.ts.map +1 -1
  70. package/dist/backend/backend/src/services/settings/settings.service.js +6 -0
  71. package/dist/backend/backend/src/services/settings/settings.service.js.map +1 -1
  72. package/dist/backend/backend/src/services/workflow/message-scheduler.service.d.ts.map +1 -1
  73. package/dist/backend/backend/src/services/workflow/message-scheduler.service.js +8 -1
  74. package/dist/backend/backend/src/services/workflow/message-scheduler.service.js.map +1 -1
  75. package/dist/backend/backend/src/services/workflow/scheduler.service.d.ts +1 -0
  76. package/dist/backend/backend/src/services/workflow/scheduler.service.d.ts.map +1 -1
  77. package/dist/backend/backend/src/services/workflow/scheduler.service.js +28 -1
  78. package/dist/backend/backend/src/services/workflow/scheduler.service.js.map +1 -1
  79. package/dist/backend/backend/src/types/settings.types.d.ts +4 -0
  80. package/dist/backend/backend/src/types/settings.types.d.ts.map +1 -1
  81. package/dist/backend/backend/src/types/settings.types.js +9 -1
  82. package/dist/backend/backend/src/types/settings.types.js.map +1 -1
  83. package/dist/backend/config/constants.d.ts +6 -0
  84. package/dist/backend/config/constants.d.ts.map +1 -1
  85. package/dist/backend/config/constants.js +6 -0
  86. package/dist/backend/config/constants.js.map +1 -1
  87. package/dist/backend/config/index.d.ts +3 -0
  88. package/dist/backend/config/index.d.ts.map +1 -1
  89. package/dist/cli/backend/src/constants.d.ts +24 -1
  90. package/dist/cli/backend/src/constants.d.ts.map +1 -1
  91. package/dist/cli/backend/src/constants.js +25 -2
  92. package/dist/cli/backend/src/constants.js.map +1 -1
  93. package/dist/cli/backend/src/services/core/config.service.d.ts.map +1 -1
  94. package/dist/cli/backend/src/services/core/config.service.js +3 -2
  95. package/dist/cli/backend/src/services/core/config.service.js.map +1 -1
  96. package/dist/cli/backend/src/types/settings.types.d.ts +4 -0
  97. package/dist/cli/backend/src/types/settings.types.d.ts.map +1 -1
  98. package/dist/cli/backend/src/types/settings.types.js +9 -1
  99. package/dist/cli/backend/src/types/settings.types.js.map +1 -1
  100. package/dist/cli/cli/src/index.js +1 -0
  101. package/dist/cli/cli/src/index.js.map +1 -1
  102. package/dist/cli/config/constants.d.ts +6 -0
  103. package/dist/cli/config/constants.d.ts.map +1 -1
  104. package/dist/cli/config/constants.js +6 -0
  105. package/dist/cli/config/constants.js.map +1 -1
  106. package/dist/cli/config/index.d.ts +3 -0
  107. package/dist/cli/config/index.d.ts.map +1 -1
  108. package/frontend/dist/assets/{index-0a245b0d.js โ†’ index-45eeea99.js} +2 -2
  109. package/frontend/dist/index.html +1 -1
  110. package/package.json +1 -1
@@ -4910,10 +4910,10 @@ if (edgeAlpha == 0.0) {
4910
4910
  `;function kY(n){const e=Ow(n,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new Qe},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new hn(0,0,0,0)},uTroikaClipRect:{value:new hn(0,0,0,0)},uTroikaEdgeOffset:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new Qe},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new ct},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new zt},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:AY,vertexTransform:MY,fragmentDefs:EY,fragmentColorTransform:TY,customRewriter({vertexShader:t,fragmentShader:r}){let s=/\buniform\s+vec3\s+diffuse\b/;return s.test(r)&&(r=r.replace(s,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),s.test(t)||(t=t.replace(eD,`uniform vec3 diffuse;
4911
4911
  $&
4912
4912
  vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
4913
- `))),{vertexShader:t,fragmentShader:r}}});return e.transparent=!0,e.forceSinglePass=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const s2=new Zs({color:16777215,side:Tn,transparent:!0}),KR=8421504,JR=new Rt,C0=new se,US=new se,If=[],RY=new se,HS="+x+y";function qR(n){return Array.isArray(n)?n[0]:n}let oD=()=>{const n=new kn(new ta(1,1),s2);return oD=()=>n,n},aD=()=>{const n=new kn(new ta(1,1,32,1),s2);return aD=()=>n,n};const NY={type:"syncstart"},IY={type:"synccomplete"},lD=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],PY=lD.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let cD=class extends kn{constructor(){const e=new CY;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=KR,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=HS,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(NY),nD({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const r=this._queuedSyncs;r&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{r.forEach(s=>s&&s())})),this.dispatchEvent(IY),e&&e()})))}onBeforeRender(e,t,r,s,i,o){this.sync(),i.isTroikaTextMaterial&&this._prepareForRender(i)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return kY(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=s2.clone());if((!e||!e.isDerivedFrom(t))&&(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function r(){t.removeEventListener("dispose",r),e.dispose()})),this.hasOutline()){let r=e._outlineMtl;return r||(r=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),r.isTextOutlineMaterial=!0,r.depthWrite=!1,r.map=null,e.addEventListener("dispose",function s(){e.removeEventListener("dispose",s),r.dispose()})),[r,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}hasOutline(){return!!(this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY)}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return qR(this.material).getDepthMaterial()}set customDepthMaterial(e){}get customDistanceMaterial(){return qR(this.material).getDistanceMaterial()}set customDistanceMaterial(e){}_prepareForRender(e){const t=e.isTextOutlineMaterial,r=e.uniforms,s=this.textRenderInfo;if(s){const{sdfTexture:a,blockBounds:l}=s;r.uTroikaSDFTexture.value=a,r.uTroikaSDFTextureSize.value.set(a.image.width,a.image.height),r.uTroikaSDFGlyphSize.value=s.sdfGlyphSize,r.uTroikaSDFExponent.value=s.sdfExponent,r.uTroikaTotalBounds.value.fromArray(l),r.uTroikaUseGlyphColors.value=!t&&!!s.glyphColors;let u=0,d=0,h=0,f,g,y,b=0,p=0;if(t){let{outlineWidth:x,outlineOffsetX:v,outlineOffsetY:w,outlineBlur:C,outlineOpacity:M}=this;u=this._parsePercent(x)||0,d=Math.max(0,this._parsePercent(C)||0),f=M,b=this._parsePercent(v)||0,p=this._parsePercent(w)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(y=this.strokeColor,r.uTroikaStrokeColor.value.set(y??KR),g=this.strokeOpacity,g==null&&(g=1)),f=this.fillOpacity;r.uTroikaEdgeOffset.value=u,r.uTroikaPositionOffset.value.set(b,p),r.uTroikaBlurRadius.value=d,r.uTroikaStrokeWidth.value=h,r.uTroikaStrokeOpacity.value=g,r.uTroikaFillOpacity.value=f??1,r.uTroikaCurveRadius.value=this.curveRadius||0;let m=this.clipRect;if(m&&Array.isArray(m)&&m.length===4)r.uTroikaClipRect.value.fromArray(m);else{const x=(this.fontSize||.1)*100;r.uTroikaClipRect.value.set(l[0]-x,l[1]-x,l[2]+x,l[3]+x)}this.geometry.applyClipRect(r.uTroikaClipRect.value)}r.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const i=t?this.outlineColor||0:this.color;if(i==null)delete e.color;else{const a=e.hasOwnProperty("color")?e.color:e.color=new ct;(i!==a._input||typeof i=="object")&&a.set(a._input=i)}let o=this.orientation||HS;if(o!==e._orientation){let a=r.uTroikaOrient.value;o=o.replace(/[^-+xyz]/g,"");let l=o!==HS&&o.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,u,d,h,f]=l;C0.set(0,0,0)[d]=u==="-"?1:-1,US.set(0,0,0)[f]=h==="-"?-1:1,JR.lookAt(RY,C0.cross(US),US),a.setFromMatrix4(JR)}else a.identity();e._orientation=o}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),r=t?parseFloat(t[1]):NaN;e=(isNaN(r)?0:r/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new Qe){t.copy(e);const r=this.curveRadius;return r&&(t.x=Math.atan2(e.x,Math.abs(r)-Math.abs(e.z))*Math.abs(r)),t}worldPositionToTextCoords(e,t=new Qe){return C0.copy(e),this.localPositionToTextCoords(this.worldToLocal(C0),t)}raycast(e,t){const{textRenderInfo:r,curveRadius:s}=this;if(r){const i=r.blockBounds,o=s?aD():oD(),a=o.geometry,{position:l,uv:u}=a.attributes;for(let d=0;d<u.count;d++){let h=i[0]+u.getX(d)*(i[2]-i[0]);const f=i[1]+u.getY(d)*(i[3]-i[1]);let g=0;s&&(g=s-Math.cos(h/s)*s,h=Math.sin(h/s)*s),l.setXYZ(d,h,f,g)}a.boundingSphere=this.geometry.boundingSphere,a.boundingBox=this.geometry.boundingBox,o.matrixWorld=this.matrixWorld,o.material.side=this.material.side,If.length=0,o.raycast(e,If);for(let d=0;d<If.length;d++)If[d].object=this,t.push(If[d])}}copy(e){const t=this.geometry;return super.copy(e),this.geometry=t,PY.forEach(r=>{this[r]=e[r]}),this}clone(){return new this.constructor().copy(this)}};lD.forEach(n=>{const e="_private_"+n;Object.defineProperty(cD.prototype,n,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});new cr;new ct;const ap=N.forwardRef(({sdfGlyphSize:n=64,anchorX:e="center",anchorY:t="middle",font:r,fontSize:s=1,children:i,characters:o,onSync:a,...l},u)=>{const d=gs(({invalidate:y})=>y),[h]=N.useState(()=>new cD),[f,g]=N.useMemo(()=>{const y=[];let b="";return N.Children.forEach(i,p=>{typeof p=="string"||typeof p=="number"?b+=p:y.push(p)}),[y,b]},[i]);return _B(()=>new Promise(y=>vY({font:r,characters:o},y)),["troika-text",r,o]),N.useLayoutEffect(()=>void h.sync(()=>{d(),a&&a(h)})),N.useEffect(()=>()=>h.dispose(),[h]),N.createElement("primitive",Su({object:h,ref:u,font:r,text:g,anchorX:e,anchorY:t,fontSize:s,sdfGlyphSize:n},l),f)});let A0=null,uD="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function dD(n=!0,e=!0,t){return r=>{t&&t(r),n&&(A0||(A0=new L$),A0.setDecoderPath(typeof n=="string"?n:uD),r.setDRACOLoader(A0)),e&&r.setMeshoptDecoder(typeof OS=="function"?OS():OS)}}const On=(n,e,t,r)=>xm(e2,n,dD(e,t,r));On.preload=(n,e,t,r)=>xm.preload(e2,n,dD(e,t,r));On.clear=n=>xm.clear(e2,n);On.setDecoderPath=n=>{uD=n};var hD={exports:{}};(function(n,e){(function(t,r){n.exports=r()})(r4,function(){var t=function(){function r(g){return o.appendChild(g.dom),g}function s(g){for(var y=0;y<o.children.length;y++)o.children[y].style.display=y===g?"block":"none";i=g}var i=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(g){g.preventDefault(),s(++i%o.children.length)},!1);var a=(performance||Date).now(),l=a,u=0,d=r(new t.Panel("FPS","#0ff","#002")),h=r(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var f=r(new t.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:o,addPanel:r,showPanel:s,begin:function(){a=(performance||Date).now()},end:function(){u++;var g=(performance||Date).now();if(h.update(g-a,200),g>l+1e3&&(d.update(1e3*u/(g-l),100),l=g,u=0,f)){var y=performance.memory;f.update(y.usedJSHeapSize/1048576,y.jsHeapSizeLimit/1048576)}return g},update:function(){a=this.end()},domElement:o,setMode:s}};return t.Panel=function(r,s,i){var o=1/0,a=0,l=Math.round,u=l(window.devicePixelRatio||1),d=80*u,h=48*u,f=3*u,g=2*u,y=3*u,b=15*u,p=74*u,m=30*u,x=document.createElement("canvas");x.width=d,x.height=h,x.style.cssText="width:80px;height:48px";var v=x.getContext("2d");return v.font="bold "+9*u+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=i,v.fillRect(0,0,d,h),v.fillStyle=s,v.fillText(r,f,g),v.fillRect(y,b,p,m),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(y,b,p,m),{dom:x,update:function(w,C){o=Math.min(o,w),a=Math.max(a,w),v.fillStyle=i,v.globalAlpha=1,v.fillRect(0,0,d,b),v.fillStyle=s,v.fillText(l(w)+" "+r+" ("+l(o)+"-"+l(a)+")",f,g),v.drawImage(x,y+u,b,p-u,m,y,b,p-u,m),v.fillRect(y+p-u,b,u,m),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(y+p-u,b,u,l((1-w/C)*m))}}},t})})(hD);var LY=hD.exports;const jY=zw(LY);function $R(n,e){typeof n=="function"?n(e):n!=null&&(n.current=e)}function BY(n,e=[],t){const[r,s]=N.useState();return N.useLayoutEffect(()=>{const i=n();return s(i),$R(t,i),()=>$R(t,null)},e),r}function DY({showPanel:n=0,className:e,parent:t}){const r=BY(()=>new jY,[]);return N.useEffect(()=>{if(r){const s=t&&t.current||document.body;r.showPanel(n),s==null||s.appendChild(r.dom);const i=(e??"").split(" ").filter(l=>l);i.length&&r.dom.classList.add(...i);const o=Cq(()=>r.begin()),a=Aq(()=>r.end());return()=>{i.length&&r.dom.classList.remove(...i),s==null||s.removeChild(r.dom),o(),a()}}},[t,r,e,n]),null}function Zy(n,e){const t=N.useRef(),[r]=N.useState(()=>e?e instanceof on?{current:e}:e:t),[s]=N.useState(()=>new JA(void 0));N.useLayoutEffect(()=>{e&&(r.current=e instanceof on?e:e.current),s._root=r.current});const i=N.useRef({}),o=N.useMemo(()=>{const a={};return n.forEach(l=>Object.defineProperty(a,l.name,{enumerable:!0,get(){if(r.current)return i.current[l.name]||(i.current[l.name]=s.clipAction(l,r.current))},configurable:!0})),{ref:r,clips:n,actions:a,names:n.map(l=>l.name),mixer:s}},[n]);return vr((a,l)=>s.update(l)),N.useEffect(()=>{const a=r.current;return()=>{i.current={},s.stopAllAction(),Object.values(o.actions).forEach(l=>{a&&s.uncacheAction(l,a)})}},[n]),o}const Oo=1e-5;function OY(n,e,t){const r=new Xo,s=t-Oo;return r.absarc(Oo,Oo,Oo,-Math.PI/2,-Math.PI,!0),r.absarc(Oo,e-s*2,Oo,Math.PI,Math.PI/2,!0),r.absarc(n-s*2,e-s*2,Oo,Math.PI/2,0,!0),r.absarc(n-s*2,Oo,Oo,0,-Math.PI/2,!0),r}const Ov=N.forwardRef(function({args:[e=1,t=1,r=1]=[],radius:s=.05,steps:i=1,smoothness:o=4,bevelSegments:a=4,creaseAngle:l=.4,children:u,...d},h){const f=N.useMemo(()=>OY(e,t,s),[e,t,s]),g=N.useMemo(()=>({depth:r-s*2,bevelEnabled:!0,bevelSegments:a*2,steps:i,bevelSize:s-Oo,bevelThickness:s,curveSegments:o}),[r,s,o]),y=N.useRef(null);return N.useLayoutEffect(()=>{y.current&&(y.current.center(),Jq(y.current,l))},[f,g]),N.createElement("mesh",Su({ref:h},d),N.createElement("extrudeGeometry",{ref:y,args:[f,g]}),u)});function FY({all:n,scene:e,camera:t}){const r=gs(({gl:o})=>o),s=gs(({camera:o})=>o),i=gs(({scene:o})=>o);return N.useLayoutEffect(()=>{const o=[];n&&(e||i).traverse(u=>{u.visible===!1&&(o.push(u),u.visible=!0)}),r.compile(e||i,t||s);const a=new Ry(128);new yA(.01,1e5,a).update(r,e||i),a.dispose(),o.forEach(u=>u.visible=!1)},[]),null}function UY({pixelated:n}){const e=gs(o=>o.gl),t=gs(o=>o.internal.active),r=gs(o=>o.performance.current),s=gs(o=>o.viewport.initialDpr),i=gs(o=>o.setDpr);return N.useEffect(()=>{const o=e.domElement;return()=>{t&&i(s),n&&o&&(o.style.imageRendering="auto")}},[]),N.useEffect(()=>{i(r*s),n&&e.domElement&&(e.domElement.style.imageRendering=r===1?"auto":"pixelated")},[r]),null}function HY(){const n=gs(r=>r.get),e=gs(r=>r.setEvents),t=gs(r=>r.performance.current);return N.useEffect(()=>{const r=n().events.enabled;return()=>e({enabled:r})},[]),N.useEffect(()=>e({enabled:t===1}),[t]),null}const Dd=[3825546,9058911,6261306,9068346,6240906,3836511],yh={day:{background:15267068,fog:15267068,wallColor:16119287,floorColor:9079434,ambientIntensity:.7,sunIntensity:1.2},night:{background:657938,fog:657938,wallColor:1710623,floorColor:1710624,ambientIntensity:.15,sunIntensity:0}},nt={ZONE:{WIDTH:10,DEPTH:7,ZONES_PER_ROW:3,START_X:-14,START_Z:8,GAP_X:4,GAP_Z:3},WORKSTATION_POSITIONS:[{x:-3,z:1.5},{x:3,z:1.5},{x:-3,z:-1},{x:3,z:-1}],CAMERA:{DEFAULT_POSITION:{x:-28,y:22,z:-18},FOV:60,NEAR:.1,FAR:150,LOOK_SENSITIVITY:.002,MIN_PITCH:-Math.PI/2+.1,MAX_PITCH:Math.PI/2-.1,MOVE_SPEED:15,ZOOM_SPEED:.5,MOUSE_SENSITIVITY:.005,TOUCH_SENSITIVITY:.008},AGENT:{ROBOT_SCALE:.5,WORKSTATION_OFFSET:.8,ANIMATION_FADE_DURATION:.5},WALLS:{HEIGHT:12,THICKNESS:.3,BACK_X:-32,LEFT_Z:-22,RIGHT_Z:22,FRONT_X:32},BREAK_ROOM:{POSITION:{x:-26,y:0,z:-14}},POKER_TABLE:{POSITION:{x:26,y:0,z:-14}},STAGE:{POSITION:{x:26,y:0,z:4},WIDTH:8,DEPTH:5,HEIGHT:.4,ROTATION:-Math.PI/2,AUDIENCE_POSITIONS:[{x:18,z:2},{x:18,z:6},{x:20,z:0},{x:20,z:4},{x:20,z:8}]},LOUNGE:{POSITION:{x:-26,y:0,z:14},COUCH_POSITIONS:[{x:-2,z:0,rotation:Math.PI/2},{x:2,z:0,rotation:-Math.PI/2}]},KITCHEN:{POSITION:{x:-27,y:0,z:3},SEAT_POSITIONS:[{x:-1,z:1.8,rotation:Math.PI},{x:0,z:1.8,rotation:Math.PI},{x:1,z:1.8,rotation:Math.PI},{x:-.5,z:-1.8,rotation:0},{x:.5,z:-1.8,rotation:0}]},ANIMATION:{FOCUS_DURATION:1500,BOSS_MODE_INTERVAL:8e3},API:{POLL_INTERVAL:5e3,USAGE_POLL_INTERVAL:3e4},MOVEMENT:{ARRIVAL_DISTANCE:.5,STUCK_THRESHOLD:.01,STUCK_MIN_DISTANCE:2,ROTATION_LERP_SPEED:5,ANIMATION_FADE_DURATION:.3,COUCH_SEAT_HEIGHT:.35},CIRCLE_INDICATOR:{RADIUS_DEFAULT:.7,RADIUS_ACTIVE:.85,SEGMENTS:32,Y_OFFSET:.1},PICKLEBALL:{POSITION:{x:-18,y:0,z:42}},GOLF:{POSITION:{x:18,y:0,z:42}},OUTDOOR_BENCH:{POSITIONS:[{x:-4,z:30,rotation:Math.PI/2},{x:4,z:30,rotation:-Math.PI/2},{x:-4,z:36,rotation:Math.PI/2},{x:4,z:36,rotation:-Math.PI/2}]},NPC_IDS:{STEVE_JOBS:"steve-jobs-npc",SUNDAR_PICHAI:"sundar-pichai-npc",ELON_MUSK:"elon-musk-npc",MARK_ZUCKERBERG:"mark-zuckerberg-npc",JENSEN_HUANG:"jensen-huang-npc",STEVE_HUANG:"steve-huang-npc"}},bn={ROBOT:"/models/employees/robot/RobotExpressive.glb",COW:"/models/employees/cow/cow-fixed.glb?v=3",HORSE:"/models/employees/horse/horse-fixed.glb",TIGER:"/models/employees/tiger/tiger-fixed.glb",RABBIT:"/models/employees/rabbit/rabbit-fixed.glb",STEVE_JOBS:"/models/guests/stevejobs/model.glb",SUNDAR_PICHAI:"/models/guests/sundarpichai/model.glb",ELON_MUSK:"/models/guests/elonmusk/model.glb",MARK_ZUCKERBERG:"/models/guests/markzuckerberg/model.glb",JENSEN_HUANG:"/models/guests/jensenhuang/model.glb?v=2",STEVE_HUANG:"/models/guests/stevehuang/model.glb?v=2",CYBERTRUCK:"/models/objects/cybertruck/model.glb",PUPPY:"/models/pets/puppy/model.glb",ROBOTIC_DOG:"/models/pets/roboticdog/original.glb",SHIBA_INU:"/models/pets/shibainu/model.glb",BULLDOG:"/models/pets/bulldog/model.glb"},gd="/api";class zY{async getFactoryState(){try{const e=await vt.get(`${gd}/factory/state`);return typeof e.data!="object"||e.data===null||!("success"in e.data)?this.buildFactoryStateFromLegacyEndpoints():!e.data.success||!e.data.data?this.buildFactoryStateFromLegacyEndpoints():e.data.data}catch{return this.buildFactoryStateFromLegacyEndpoints()}}async buildFactoryStateFromLegacyEndpoints(){const e=[],t=new Set,r=new Set;try{((await vt.get(`${gd}/teams`)).data.data||[]).forEach(a=>{var u;const l=((u=a.projectIds)==null?void 0:u[0])||a.name||"Unassigned";t.add(l),a.members&&a.members.forEach(d=>{r.add(d.id),e.push({id:d.id,sessionName:d.sessionName,name:d.name,projectName:l,status:this.mapAgentStatus(d.agentStatus,d.workingStatus),cpuPercent:d.workingStatus==="in_progress"?50:0,activity:d.workingStatus==="in_progress"?"Working...":void 0,sessionTokens:0})})})}catch{}try{const o=(await vt.get(`${gd}/factory/claude-instances`)).data;o!=null&&o.instances&&o.instances.forEach(a=>{if(r.has(a.id))return;const l=a.projectName||"Unknown";t.add(l),e.push({id:a.id,sessionName:`claude-${a.pid}`,name:l,projectName:l,status:a.status==="active"?"active":"idle",cpuPercent:a.cpuPercent,activity:a.activity,sessionTokens:a.sessionTokens||0})})}catch{}const s={activeCount:e.filter(i=>i.status==="active").length,idleCount:e.filter(i=>i.status==="idle").length,dormantCount:e.filter(i=>i.status==="dormant").length,totalTokens:e.reduce((i,o)=>i+(o.sessionTokens||0),0)};return{agents:e,projects:Array.from(t),stats:s}}mapAgentStatus(e,t){return e==="inactive"?"dormant":t==="in_progress"?"active":"idle"}async getUsageStats(){try{return(await vt.get(`${gd}/factory/usage`)).data}catch{return{today:{messages:0,tokens:0,toolCalls:0},totals:{sessions:0,messages:0},recentDays:[]}}}async getAgent(e){const t=await vt.get(`${gd}/factory/agents/${e}`);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Agent not found");return t.data.data}async getAgentLogs(e,t=50){var r;try{return((r=(await vt.get(`${gd}/sessions/${e}/logs`,{params:{lines:t}})).data.data)==null?void 0:r.logs)||[]}catch{return[]}}subscribeToUpdates(e){return()=>{}}}const GY=new zY;function WY(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e^n.charCodeAt(t);return Math.abs(e)}const YR=["cow","horse","tiger","rabbit"];function VY(n,e){const r=WY(n)%YR.length;return YR[r]}function XY(n){const e=n??new Date().getHours();return e>=18||e<6}function KY(){const n=new se(-28,22,-18),e=new se(15,2,10),t=e.clone().sub(n),r=Math.atan2(t.x,t.z),s=Math.atan2(t.y,Math.sqrt(t.x*t.x+t.z*t.z));return{yaw:r,pitch:s,position:n,target:e,isAnimating:!1}}function zS(n,e,t){const r=Math.sin(n)*Math.cos(e),s=Math.sin(e),i=Math.cos(n)*Math.cos(e);return t?t.set(r,s,i):new se(r,s,i)}const M0=1.5,E0={minX:nt.WALLS.BACK_X+M0,maxX:nt.WALLS.FRONT_X-M0,minZ:nt.WALLS.LEFT_Z+M0,maxZ:nt.WALLS.RIGHT_Z-M0},Fv=[{minX:-8.5,maxX:8.5,minZ:-15.5,maxZ:-12.5},{minX:-29.5,maxX:-24.5,minZ:-2.5,maxZ:.5},{minX:-29.5,maxX:-24.5,minZ:1.8,maxZ:4.2},{minX:-29.5,maxX:-24.5,minZ:5.5,maxZ:8.5}];function fD(n){const e=[];return n.forEach(t=>{t.workstations.forEach(r=>{e.push({minX:r.position.x-1.8,maxX:r.position.x+1.8,minZ:r.position.z-1.5,maxZ:r.position.z+2})})}),e}function lp(n,e,t){for(const r of t)if(n>=r.minX&&n<=r.maxX&&e>=r.minZ&&e<=r.maxZ)return!0;return!1}function $c(n,e){return{x:Math.max(E0.minX,Math.min(E0.maxX,n)),z:Math.max(E0.minZ,Math.min(E0.maxZ,e))}}function Uw(n,e,t,r,s){const i=$c(n,e);if(!lp(i.x,i.z,s))return i;const o=$c(i.x,r);if(!lp(o.x,o.z,s))return o;const a=$c(t,i.z);return lp(a.x,a.z,s)?$c(t,r):a}function pD(n,e,t){const r=$c(n,e);return Math.abs(r.x-n)>.01||Math.abs(r.z-e)>.01?!1:!lp(n,e,t)}const QR=1.5;function i2(n,e,t,r){const s=QR*QR;for(const[i,o]of r){if(i===t)continue;const a=n-o.x,l=e-o.z;if(a*a+l*l<s)return!0}return!1}function JY(n,e){const t=new Map;return n.forEach((r,s)=>{const i=r.currentPosition||r.basePosition;t.set(s,{x:i.x,z:i.z})}),e.forEach((r,s)=>{t.set(s,{x:r.x,z:r.z})}),t}function lx(n,e=18,t=18,r=0,s=0,i=15){for(let o=0;o<i;o++){const a=r+(Math.random()-.5)*e*2,l=s+(Math.random()-.5)*t*2;if(pD(a,l,n))return{x:a,z:l}}return $c(r,s)}const qY=5,T0=5e3,GS=2e3,ZR=3500,$Y=500,YY=10,QY=3e4,ZY=["Hey!","Hi!","Hello!","What's up?","Hey there!","Yo!","Hi there!","Howdy!","Sup!","What's good?"],WS=[["How's your project going?","Pretty good, making progress!"],["Taking a break?","Yeah, needed one!"],["The boss seems happy today","Ha, let's hope it lasts!"],["Did you see that demo?","Yeah, it was impressive!"],["Coffee break?","Always down for coffee!"],["Any blockers?","Nah, smooth sailing!"],["Working late tonight?","Hope not!"],["Nice code review earlier","Thanks, yours too!"],["Tried the new API yet?","Yeah, it's way faster!"],["Stand-up was short today","Best kind of stand-up!"],["PR looks good to me","Thanks for reviewing!"],["Lunch plans?","Thinking tacos, you in?"]],eQ=["One more thing...","Hey, got a minute?","Think different!","You know what...","Let's talk!"],tQ=[["Is it insanely great yet?","Getting close!"],["Simplicity is the ultimate sophistication","Totally agree!"],["Focus on what truly matters","Good advice!"],["Design is how it works","So true!"],["Let's put a dent in the universe","I'm in!"],["Real artists ship","Shipping soon!"],["Innovation needs courage","You're right!"],["Stay hungry, stay foolish","Always!"],["The journey is the reward","Love that!"],["Quality over quantity, always","Agreed!"]],nQ=["Hey team!","Good to see you!","How's everything?","Quick sync?","Let's connect!"],rQ=[["AI is reshaping everything","It really is!"],["Let's think about scale","Good point!"],["User trust is our foundation","Absolutely!"],["Have you tried Gemini yet?","It's impressive!"],["Cloud-first, always","Makes sense!"],["Openness drives innovation","So true!"],["Let's make tech accessible to all","Great vision!"],["Data tells the real story","Facts!"],["10x thinking, not 10%","Love that mindset!"],["What's the user impact?","Significant!"]],sQ=["TSLA to the moon!","Hey, quick question!","First principles!","Yo, got a sec?","Let me tell you..."],iQ=[["Tesla stock is up today!","Nice, congrats!"],["SpaceX launch was amazing!","That was incredible!"],["Starship blew up again...","Oh no! Next time!"],["Rapid unscheduled disassembly","Ha, classic!"],["Full self driving, almost there","Can't wait to try it!"],["We're going to Mars!","When do we leave?"],["The Cybertruck is selling!","It's wild looking!"],["X is the everything app now","That's ambitious!"],["Need to ship this 10x faster","On it!"],["Boring tunnels under the factory?","That'd be cool!"]],oQ=["Hey, try this headset!","Is this VR or real?","Meta connect!","Quick, put on Quest!","Open source everything!"],aQ=[["Have you tried Meta Quest?","Not yet, is it good?"],["The metaverse is the future!","Interesting vision!"],["Llama 4 is crushing benchmarks","That's impressive!"],["I can't see clearly, VR blur","Maybe take the headset off?"],["Everything should be in VR","Even this meeting?"],["Wait, is this real or virtual?","It's real, Zuck!"],["Open source AI wins every time","Agreed!"],["Sweet Baby Rays is the best","Ha, you and BBQ sauce!"],["Llama beats the competition","The benchmarks look great!"],["We should do this in the metaverse","Let's stay in reality!"]],lQ=["GPU goes brrr!","Hey, need compute?","CUDA powers all!","The more you buy...","Accelerated computing!"],cQ=[["Everyone's buying our GPUs!","Business is booming!"],["NVDA stock, all time high!","Incredible run!"],["H100s are sold out again!","The demand is insane!"],["You using CUDA for this?","Of course!"],["The more you buy, more you save!","Great sales pitch!"],["AI needs more compute power","Always more GPUs!"],["Blackwell is our best chip yet","The benchmarks are wild!"],["Every data center needs us","You're not wrong!"],["Leather jacket weather today","Looking sharp, Jensen!"],["Inference at scale is everything","Totally agree!"]],uQ=["Hey, how are things?","What's going on?","Just checking in!","Hey there!","How goes it?"],dQ=[["How's everything going?","Going great, thanks!"],["I built this whole factory","It's amazing!"],["Crewly is coming along","Looks awesome!"],["Need anything from me?","We're good, thanks!"],["Just making the rounds","Good to see you!"],["The codebase is looking clean","Thanks for the review!"],["Nice weather for golf later","Sounds fun!"],["Keep up the great work","Will do!"],["Any feedback for me?","Everything's solid!"],["Love seeing the progress","Team's crushing it!"]],e3={"steve-jobs-npc":{greetings:eQ,smallTalk:tQ},"sundar-pichai-npc":{greetings:nQ,smallTalk:rQ},"elon-musk-npc":{greetings:sQ,smallTalk:iQ},"mark-zuckerberg-npc":{greetings:oQ,smallTalk:aQ},"jensen-huang-npc":{greetings:lQ,smallTalk:cQ},"steve-huang-npc":{greetings:uQ,smallTalk:dQ}},mD=N.createContext(void 0),hQ=({children:n})=>{const[e,t]=N.useState(new Map),[r,s]=N.useState(new Map),[i,o]=N.useState([]),[a,l]=N.useState(KY),[u,d]=N.useState("day"),[h,f]=N.useState({isActive:!1,mode:"auto",currentTargetIndex:0,targets:[],timeAtTarget:0,targetDuration:nt.ANIMATION.BOSS_MODE_INTERVAL,orbitAngle:0,orbitRadius:6,orbitHeight:4}),[g,y]=N.useState(!0),[b,p]=N.useState(null),m=N.useRef(new Map([["couch",new Set],["break_room",new Set],["poker_table",new Set],["kitchen",new Set]])),x=N.useRef(null),v={couch:2,break_room:4,poker_table:4,kitchen:5},[w,C]=N.useState(new Map),[M,T]=N.useState(null),[A,E]=N.useState(null),[R]=N.useState(!1),j=N.useRef(null),[L,D]=N.useState(!0),[z,q]=N.useState(!0),[X,K]=N.useState(!0),[I,B]=N.useState(new Map),F=N.useRef(new Map),O=N.useCallback((xe,Ce)=>{F.current.set(xe,Ce)},[]),W=N.useCallback(xe=>{const Ce=F.current.get(xe)??null;return Ce&&F.current.delete(xe),Ce},[]),J=N.useCallback(xe=>{j.current=xe},[]),$=N.useMemo(()=>u==="day"?!1:u==="night"?!0:XY(),[u]),ie=N.useMemo(()=>{let xe=0,Ce=0,Ze=0,he=0;const je=new Map;e.forEach($e=>{switch($e.status){case"active":xe++;break;case"idle":Ce++;break;case"dormant":Ze++;break}he+=$e.sessionTokens,je.set($e.projectName,(je.get($e.projectName)||0)+$e.sessionTokens)});const ke=Array.from(je.entries()).map(([$e,Ie],Re)=>{const Fe=r.get($e);return{projectName:$e,tokens:Ie,color:(Fe==null?void 0:Fe.color)||Dd[Re%Dd.length]}}).sort(($e,Ie)=>Ie.tokens-$e.tokens);return{activeCount:xe,idleCount:Ce,dormantCount:Ze,totalTokens:he,tokensByProject:ke}},[e,r]),oe=N.useCallback(async()=>{try{const xe=await GY.getFactoryState(),Ce=new Map,Ze=[...new Set(xe.agents.map(ke=>ke.projectName))].sort();Ze.forEach((ke,$e)=>{const Ie=nt.ZONE.ZONES_PER_ROW,Re=Math.floor($e/Ie),Fe=$e%Ie,rt=nt.ZONE.START_X+Fe*(nt.ZONE.WIDTH+nt.ZONE.GAP_X),it=nt.ZONE.START_Z-Re*(nt.ZONE.DEPTH+nt.ZONE.GAP_Z);Ce.set(ke,{projectName:ke,zoneIndex:$e,zoneX:rt,zoneZ:it,color:Dd[$e%Dd.length],workstations:nt.WORKSTATION_POSITIONS.map((ft,Qt)=>({position:{x:rt+ft.x,z:it+ft.z},index:$e*4+Qt,isActive:!1}))})});const he=new Map,je=new Map;xe.agents.forEach(ke=>{const $e=Ce.get(ke.projectName);if(!$e)return;const Ie=je.get(ke.projectName)||0;je.set(ke.projectName,Ie+1);const Re=Ie%4,Fe=$e.workstations[Re];if(!Fe)return;Fe.assignedAgentId=ke.id,Fe.isActive=ke.status==="active";const rt={id:ke.id,projectName:ke.projectName,status:ke.status,cpuPercent:ke.cpuPercent,activity:ke.activity,sessionTokens:ke.sessionTokens||0,zoneIndex:$e.zoneIndex,workstationIndex:Re,animalType:VY(ke.projectName,Ie),basePosition:new se(Fe.position.x,0,Fe.position.z+.45),sessionName:ke.sessionName,name:ke.name};he.set(ke.id,rt)}),s(Ce),t(he),o(Ze),p(null)}catch(xe){p(xe instanceof Error?xe.message:"Failed to fetch factory state")}finally{y(!1)}},[]),U=N.useCallback(xe=>{if(xe==="overview")l(Ce=>({...Ce,isAnimating:!0,animationTarget:{position:new se(-28,22,-18),lookAt:new se(15,2,10),duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:Ce.position.clone(),startLookAt:Ce.target.clone()}}));else if(xe==="birdseye")l(Ce=>({...Ce,isAnimating:!0,animationTarget:{position:new se(0,40,15),lookAt:new se(-5,0,-5),duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:Ce.position.clone(),startLookAt:Ce.target.clone()}}));else if(xe==="outdoor")l(Ce=>({...Ce,isAnimating:!0,animationTarget:{position:new se(0,18,55),lookAt:new se(0,18,22),duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:Ce.position.clone(),startLookAt:Ce.target.clone()}}));else{const Ce=r.get(xe);if(Ce){const Ze=new se(Ce.zoneX-8,8,Ce.zoneZ+8),he=new se(Ce.zoneX,.5,Ce.zoneZ);l(je=>({...je,isAnimating:!0,animationTarget:{position:Ze,lookAt:he,duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:je.position.clone(),startLookAt:je.target.clone()}}))}}},[r]),te=N.useCallback(xe=>{l(Ce=>({...Ce,...xe}))},[]),ue=N.useCallback(()=>{const xe=[];e.forEach(Re=>{const Fe=Re.currentPosition||Re.basePosition;xe.push({id:Re.id,name:Re.name||Re.sessionName||Re.id,type:"agent",position:{x:Fe.x,y:Fe.y,z:Fe.z}})});const Ce=w.get("steve-jobs-npc");xe.push({id:"steve-jobs-npc",name:"Steve Jobs",type:"npc",position:Ce?{x:Ce.x,y:Ce.y,z:Ce.z}:{x:0,y:0,z:5}});const Ze=w.get("sundar-pichai-npc");xe.push({id:"sundar-pichai-npc",name:"Sundar Pichai",type:"npc",position:Ze?{x:Ze.x,y:Ze.y,z:Ze.z}:{x:10,y:0,z:0}});const he=w.get("jensen-huang-npc");xe.push({id:"jensen-huang-npc",name:"Jensen Huang",type:"npc",position:he?{x:he.x,y:he.y,z:he.z}:{x:-5,y:0,z:5}});const je=w.get("elon-musk-npc");xe.push({id:"elon-musk-npc",name:"Elon Musk",type:"npc",position:je?{x:je.x,y:je.y,z:je.z}:{x:4,y:0,z:50}});const ke=w.get("mark-zuckerberg-npc");xe.push({id:"mark-zuckerberg-npc",name:"Mark Zuckerberg",type:"npc",position:ke?{x:ke.x,y:ke.y,z:ke.z}:{x:18,y:0,z:38}});const $e=w.get("steve-huang-npc");xe.push({id:"steve-huang-npc",name:"Steve Huang",type:"npc",position:$e?{x:$e.x,y:$e.y,z:$e.z}:{x:16,y:0,z:44}});const Ie=nt.STAGE.AUDIENCE_POSITIONS;return Ie.forEach((Re,Fe)=>{const rt=`fake-audience-${Fe}`,it=w.get(rt);xe.push({id:rt,name:`Audience ${Fe+1}`,type:"npc",position:it?{x:it.x,y:it.y,z:it.z}:{x:Ie[Fe].x,y:0,z:Ie[Fe].z}})}),xe},[e,w]);N.useCallback(xe=>{const Ze=xe.type==="npc"?{x:-7,y:7,z:7}:{x:-4,y:4,z:4},he=new se(xe.position.x+Ze.x,xe.position.y+Ze.y,xe.position.z+Ze.z),je=new se(xe.position.x,xe.position.y+1.5,xe.position.z);l(ke=>({...ke,isAnimating:!0,animationTarget:{position:he,lookAt:je,duration:1500,startTime:Date.now(),startPosition:ke.position.clone(),startLookAt:ke.target.clone()}}))},[]);const ee=N.useCallback(()=>{f(xe=>xe.isActive?(U("overview"),{...xe,isActive:!1,targets:[],orbitAngle:0}):{isActive:!0,mode:"auto",currentTargetIndex:0,targets:ue(),timeAtTarget:0,targetDuration:nt.ANIMATION.BOSS_MODE_INTERVAL,orbitAngle:0,orbitRadius:6,orbitHeight:4})},[ue,U]),pe=N.useCallback(xe=>{f(Ce=>({...Ce,mode:xe}))},[]),Z=N.useCallback(()=>{f(xe=>{if(!xe.isActive||xe.targets.length===0)return xe;const Ce=(xe.currentTargetIndex+1)%xe.targets.length;return{...xe,currentTargetIndex:Ce,orbitAngle:0,timeAtTarget:0}})},[]),be=N.useCallback(()=>{f(xe=>{if(!xe.isActive||xe.targets.length===0)return xe;const Ce=xe.currentTargetIndex===0?xe.targets.length-1:xe.currentTargetIndex-1;return{...xe,currentTargetIndex:Ce,orbitAngle:0,timeAtTarget:0}})},[]),re=N.useCallback(()=>{var xe;return!h.isActive||h.targets.length===0?"":((xe=h.targets[h.currentTargetIndex])==null?void 0:xe.name)||""},[h]),ce=N.useCallback((xe,Ce)=>{const Ze=m.current.get(xe);if(!Ze)return-1;if(Ze.has(Ce))return Array.from(Ze).indexOf(Ce);const he=v[xe]??0;return Ze.size>=he?-1:(Ze.add(Ce),Array.from(Ze).indexOf(Ce))},[]),le=N.useCallback((xe,Ce)=>{const Ze=m.current.get(xe);Ze&&Ze.delete(Ce)},[]),fe=N.useCallback(xe=>{const Ce=m.current.get(xe);return Ce?Ce.size>=(v[xe]??0):!0},[]),Q=N.useCallback((xe,Ce)=>{const Ze=m.current.get(xe);return!Ze||!Ze.has(Ce)?-1:Array.from(Ze).indexOf(Ce)},[]),Te=N.useCallback(()=>{const xe={};return m.current.forEach((Ce,Ze)=>{xe[Ze]=Ce.size}),xe},[]),we=N.useCallback(xe=>x.current!==null&&x.current!==xe?!1:(x.current=xe,!0),[]),_e=N.useCallback(xe=>{x.current===xe&&(x.current=null)},[]),Me=N.useCallback(()=>x.current!==null,[]),Y=N.useCallback(()=>x.current,[]),G=N.useCallback((xe,Ce)=>{t(Ze=>{const he=Ze.get(xe);if(!he)return Ze;const je=he.currentPosition;if(je&&Math.abs(je.x-Ce.x)<.01&&Math.abs(je.y-Ce.y)<.01&&Math.abs(je.z-Ce.z)<.01)return Ze;const ke=new Map(Ze);return ke.set(xe,{...he,currentPosition:Ce.clone()}),ke})},[]),ae=N.useCallback((xe,Ce)=>{C(Ze=>{const he=Ze.get(xe);if(he&&Math.abs(he.x-Ce.x)<.01&&Math.abs(he.y-Ce.y)<.01&&Math.abs(he.z-Ce.z)<.01)return Ze;const je=new Map(Ze);return je.set(xe,Ce.clone()),je})},[]),Se=N.useCallback(xe=>{T(xe)},[]),ge=N.useCallback(xe=>{E(xe);const Ce=ue(),Ze=Ce.findIndex(he=>he.id===xe);f({isActive:!0,mode:"manual",currentTargetIndex:Math.max(Ze,0),targets:Ce,timeAtTarget:0,targetDuration:nt.ANIMATION.BOSS_MODE_INTERVAL,orbitAngle:0,orbitRadius:6,orbitHeight:4})},[ue]),me=N.useCallback(()=>{E(null),f(xe=>({...xe,isActive:!1,targets:[],orbitAngle:0})),U("overview")},[U]);N.useEffect(()=>{oe()},[oe]),N.useEffect(()=>{const xe=setInterval(oe,nt.API.POLL_INTERVAL);return()=>clearInterval(xe)},[oe]),N.useEffect(()=>{if(u!=="auto")return;const xe=setInterval(()=>{d("auto")},6e4);return()=>clearInterval(xe)},[u]);const ze=N.useRef(e),Oe=N.useRef(w),We=N.useRef(I);ze.current=e,Oe.current=w,We.current=I;const Ge=N.useRef(new Map);Ge.current=N.useMemo(()=>JY(e,w),[e,w]),N.useEffect(()=>{if(!h.isActive||h.targets.length===0)return;const xe=.3,Ce=h.mode==="auto";let Ze=performance.now(),he;const je=()=>{const ke=performance.now(),$e=(ke-Ze)/1e3;Ze=ke,f(Ie=>{if(!Ie.isActive||Ie.targets.length===0)return Ie;const Re=Ie.targets[Ie.currentTargetIndex];if(!Re)return Ie;let Fe=Ie.orbitAngle+xe*$e,rt=Ie.currentTargetIndex;Ce&&Fe>=Math.PI*2&&(Fe=0,rt=(Ie.currentTargetIndex+1)%Ie.targets.length);const it=Ie.targets[rt]||Re;let ft=it.position;if(it.type==="npc"){const ve=Oe.current.get(it.id);ve&&(ft={x:ve.x,y:ve.y,z:ve.z})}else if(it.type==="agent"){const ve=ze.current.get(it.id);ve!=null&&ve.currentPosition&&(ft={x:ve.currentPosition.x,y:ve.currentPosition.y,z:ve.currentPosition.z})}const Qt=it.type==="npc",Mt=Qt?Ie.orbitRadius+4:Ie.orbitRadius,jt=Qt?Ie.orbitHeight+3:Ie.orbitHeight,Dt=ft.x+Mt*Math.cos(Fe),yn=ft.z+Mt*Math.sin(Fe),fn=ft.y+jt;return l(ve=>{const Je=new se(Dt,fn,yn),Ct=new se(ft.x,ft.y+2,ft.z);return{...ve,position:Je,target:Ct,isAnimating:!1}}),{...Ie,orbitAngle:Fe,currentTargetIndex:rt}}),he=requestAnimationFrame(je)};return he=requestAnimationFrame(je),()=>{he&&cancelAnimationFrame(he)}},[h.isActive,h.mode,h.targets.length]);const Le=N.useRef(new Map),Ve=N.useRef(new Map);N.useEffect(()=>{const xe=he=>he.split("").reduce((je,ke)=>je+ke.charCodeAt(0),0),Ce=()=>{const he=ze.current,je=Oe.current,ke=[];if(he.forEach(Mt=>{if(Mt.status==="active")return;const jt=Mt.currentPosition||Mt.basePosition;ke.push({id:Mt.id,x:jt.x,z:jt.z})}),je.forEach((Mt,jt)=>{ke.push({id:jt,x:Mt.x,z:Mt.z})}),ke.length<2){We.current.size>0&&(Le.current.clear(),B(new Map));return}const $e=new Map;for(let Mt=0;Mt<ke.length;Mt++){let jt=1/0,Dt="";for(let yn=0;yn<ke.length;yn++){if(Mt===yn)continue;const fn=ke[Mt].x-ke[yn].x,ve=ke[Mt].z-ke[yn].z,Je=Math.sqrt(fn*fn+ve*ve);Je<jt&&Je<qY&&(jt=Je,Dt=ke[yn].id)}Dt&&$e.set(ke[Mt].id,Dt)}const Ie=new Map,Re=new Set,Fe=Date.now(),rt=Le.current,it=new Set,ft=Ve.current;$e.forEach((Mt,jt)=>{if(Re.has(jt)||$e.get(Mt)!==jt)return;const Dt=[jt,Mt].sort().join(":"),yn=ft.get(Dt);if(yn&&Fe<yn)return;Re.add(jt),Re.add(Mt),it.add(Dt);let fn=rt.get(Dt);fn===void 0&&(fn=Fe,rt.set(Dt,fn));const ve=Fe-fn,Je=ve>=T0,Ct=Math.min(Math.ceil(T0/GS),Math.floor(ve/GS)+1),Vt=Je?Math.floor((ve-T0)/ZR)+1:0;if(Ct+Vt>YY){rt.delete(Dt),ft.set(Dt,Fe+QY),it.delete(Dt);return}const ln=[jt,Mt].sort(),Fn=ln.find(Un=>Un in e3)||null,Tr=Fn?e3[Fn]:null;if(Je){const Un=ve-T0,Wn=Math.floor(Un/ZR),Zn=Wn%2===0;if(Tr&&Fn){const Vn=Math.floor(Wn/2)%Tr.smallTalk.length,er=Tr.smallTalk[Vn],Or=ln.indexOf(Fn);Ie.set(ln[0],{partnerId:ln[1],startTime:fn,isLongDuration:!0,currentLine:Zn?Or===0?er[0]:er[1]:null}),Ie.set(ln[1],{partnerId:ln[0],startTime:fn,isLongDuration:!0,currentLine:Zn?null:Or===1?er[0]:er[1]})}else{const Vn=Math.floor(Wn/2)%WS.length;Ie.set(ln[0],{partnerId:ln[1],startTime:fn,isLongDuration:!0,currentLine:Zn?WS[Vn][0]:null}),Ie.set(ln[1],{partnerId:ln[0],startTime:fn,isLongDuration:!0,currentLine:Zn?null:WS[Vn][1]})}}else{const Un=Math.floor(ve/GS),Zn=Un%2===0?ln[0]:ln[1],Vn=Tr&&Zn===Fn?Tr.greetings:ZY,er=(xe(Zn)+Un)%Vn.length;Ie.set(ln[0],{partnerId:ln[1],startTime:fn,isLongDuration:!1,currentLine:Zn===ln[0]?Vn[er]:null}),Ie.set(ln[1],{partnerId:ln[0],startTime:fn,isLongDuration:!1,currentLine:Zn===ln[1]?Vn[er]:null})}}),rt.forEach((Mt,jt)=>{it.has(jt)||rt.delete(jt)}),ft.forEach((Mt,jt)=>{Fe>=Mt&&ft.delete(jt)});const Qt=Mt=>JSON.stringify(Array.from(Mt.entries()).map(([jt,Dt])=>[jt,Dt.currentLine,Dt.isLongDuration]));Qt(Ie)!==Qt(We.current)&&B(Ie)};Ce();const Ze=setInterval(Ce,$Y);return()=>clearInterval(Ze)},[]);const Xe=N.useMemo(()=>({agents:e,zones:r,camera:a,setCameraTarget:U,lightingMode:u,setLightingMode:d,isNightMode:$,bossModeState:h,toggleBossMode:ee,setBossModeType:pe,bossNextTarget:Z,bossPrevTarget:be,getCurrentTargetName:re,stats:ie,projects:i,isLoading:g,error:b,refreshData:oe,updateCamera:te,claimSeat:ce,releaseSeat:le,isAreaFull:fe,getSeatIndex:Q,getSeatOccupancy:Te,claimStage:we,releaseStage:_e,isStageOccupied:Me,getStagePerformerId:Y,stagePerformerRef:x,seatOccupancyRef:m,updateAgentPosition:G,updateNpcPosition:ae,npcPositions:w,hoveredEntityId:M,selectedEntityId:A,setHoveredEntity:Se,selectEntity:ge,clearSelection:me,entityConversations:I,sendEntityCommand:O,consumeEntityCommand:W,entityPositionMapRef:Ge,freestyleMode:R,setFreestyleMoveTarget:J,showNPCAgents:L,setShowNPCAgents:D,showGuestAgents:z,setShowGuestAgents:q,showObjects:X,setShowObjects:K}),[e,r,a,U,u,$,h,ee,pe,Z,be,re,ie,i,g,b,oe,te,ce,le,fe,Q,Te,we,_e,Me,Y,G,ae,w,M,A,Se,ge,me,I,O,W,R,J,L,z,X]);return c.jsx(mD.Provider,{value:Xe,children:n})},Pt=()=>{const n=N.useContext(mD);if(n===void 0)throw new Error("useFactory must be used within a FactoryProvider");return n},fQ=()=>{const{isNightMode:n}=Pt(),e=N.useRef(null),t=N.useRef(null),r=N.useMemo(()=>n?yh.night:yh.day,[n]);return vr(()=>{if(e.current){const s=r.ambientIntensity;e.current.intensity=Oa.lerp(e.current.intensity,s,.05)}if(t.current){const s=r.sunIntensity;t.current.intensity=Oa.lerp(t.current.intensity,s,.05)}}),c.jsxs(c.Fragment,{children:[c.jsx("ambientLight",{ref:e,color:n?4482730:16777215,intensity:r.ambientIntensity}),c.jsx("directionalLight",{ref:t,color:n?8952268:16777198,intensity:r.sunIntensity,position:[20,30,10],castShadow:!0,"shadow-mapSize-width":2048,"shadow-mapSize-height":2048,"shadow-camera-near":.5,"shadow-camera-far":100,"shadow-camera-left":-40,"shadow-camera-right":40,"shadow-camera-top":40,"shadow-camera-bottom":-40,"shadow-bias":-1e-4}),c.jsx("directionalLight",{color:n?2241365:11189247,intensity:n?.1:.3,position:[-15,10,-10]}),n&&c.jsxs(c.Fragment,{children:[c.jsx("directionalLight",{color:6715306,intensity:.2,position:[-10,20,15]}),c.jsx(pQ,{})]})]})},pQ=()=>{const n=N.useMemo(()=>[{x:-14,z:8},{x:0,z:8},{x:14,z:8},{x:-14,z:-2},{x:0,z:-2},{x:14,z:-2}],[]);return c.jsx(c.Fragment,{children:n.map((e,t)=>c.jsx("pointLight",{color:16777198,intensity:.8,distance:12,decay:2,position:[e.x,3.5,e.z]},t))})},mQ=()=>{const{isNightMode:n}=Pt(),e=N.useRef(null),t=N.useMemo(()=>n?yh.night.floorColor:yh.day.floorColor,[n]);return N.useEffect(()=>{e.current&&e.current.material.color.setHex(t)},[t]),c.jsxs("mesh",{ref:e,rotation:[-Math.PI/2,0,0],position:[0,0,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[70,50]}),c.jsx("meshStandardMaterial",{color:t,roughness:.9,metalness:0})]})},{WALLS:Bt}=nt,Ca=({position:n,rotation:e=[0,0,0],size:t,windows:r=[]})=>{const{isNightMode:s}=Pt(),i=N.useRef(null),o=N.useMemo(()=>s?1710623:16119287,[s]);N.useEffect(()=>{i.current&&i.current.material.color.setHex(o)},[o]);const a=N.useMemo(()=>{if(r.length===0)return new Bs(t[0],t[1],t[2]);const l=new Xo,u=t[0]/2,d=t[1]/2;l.moveTo(-u,-d),l.lineTo(u,-d),l.lineTo(u,d),l.lineTo(-u,d),l.closePath(),r.forEach(f=>{const g=new gh,y=f.x-f.width/2,b=f.y-f.height/2;g.moveTo(y,b),g.lineTo(y+f.width,b),g.lineTo(y+f.width,b+f.height),g.lineTo(y,b+f.height),g.closePath(),l.holes.push(g)});const h={depth:t[2],bevelEnabled:!1};return new Nh(l,h)},[t,r]);return c.jsx("mesh",{ref:i,position:n,rotation:e,geometry:a,castShadow:!0,receiveShadow:!0,children:c.jsx("meshStandardMaterial",{color:o,roughness:.3,metalness:0})})},Yc=({position:n,rotation:e=[0,0,0],size:t})=>{const{isNightMode:r}=Pt();return c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{children:[c.jsx("planeGeometry",{args:t}),c.jsx("meshPhysicalMaterial",{color:r?1714746:16777215,transparent:!0,opacity:r?.4:.15,roughness:0,metalness:0,transmission:.9,thickness:.1,side:Tn})]}),c.jsxs("mesh",{position:[0,0,-.01],children:[c.jsx("planeGeometry",{args:[t[0]+.05,t[1]+.05]}),c.jsx("meshStandardMaterial",{color:r?3355460:13421772,transparent:!0,opacity:.3,side:Tn})]})]})},Qc=({position:n,rotation:e=[0,0,0],width:t,height:r})=>c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{position:[-t/2,0,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.08,r,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[t/2,0,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.08,r,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,r/2,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+.08,.08,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,-r/2,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+.08,.08,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]})]}),gQ=({char:n,position:e,color:t=65535,glowColor:r=65535})=>{const s=N.useRef(null),{isNightMode:i}=Pt();vr(l=>{if(s.current){const u=s.current.material,d=Math.sin(l.clock.elapsedTime*2+e[0])*.2+1;u.emissiveIntensity=i?d*2:d*.8}});const o=l=>{const u=new Xo,d=.15;switch(l.toUpperCase()){case"A":u.moveTo(-.4,-.5),u.lineTo(-.1,.5),u.lineTo(.1,.5),u.lineTo(.4,-.5),u.lineTo(.25,-.5),u.lineTo(.15,-.15),u.lineTo(-.15,-.15),u.lineTo(-.25,-.5),u.closePath();const h=new gh;h.moveTo(-.05,0),h.lineTo(0,.2),h.lineTo(.05,0),h.closePath(),u.holes.push(h);break;case"G":u.moveTo(-.3,-.5),u.lineTo(-.3,.5),u.lineTo(.3,.5),u.lineTo(.3,.35),u.lineTo(-.15,.35),u.lineTo(-.15,-.35),u.lineTo(.15,-.35),u.lineTo(.15,-.08),u.lineTo(0,-.08),u.lineTo(0,.08),u.lineTo(.3,.08),u.lineTo(.3,-.5),u.closePath();break;case"E":u.moveTo(-.3,-.5),u.lineTo(-.3,.5),u.lineTo(.3,.5),u.lineTo(.3,.35),u.lineTo(-.15,.35),u.lineTo(-.15,.08),u.lineTo(.2,.08),u.lineTo(.2,-.08),u.lineTo(-.15,-.08),u.lineTo(-.15,-.35),u.lineTo(.3,-.35),u.lineTo(.3,-.5),u.closePath();break;case"N":u.moveTo(-.3,-.5),u.lineTo(-.3,.5),u.lineTo(-.15,.5),u.lineTo(.15,-.1),u.lineTo(.15,.5),u.lineTo(.3,.5),u.lineTo(.3,-.5),u.lineTo(.15,-.5),u.lineTo(-.15,.1),u.lineTo(-.15,-.5),u.closePath();break;case"T":u.moveTo(-.35,.35),u.lineTo(-.35,.5),u.lineTo(.35,.5),u.lineTo(.35,.35),u.lineTo(.1,.35),u.lineTo(.1,-.5),u.lineTo(-.1,-.5),u.lineTo(-.1,.35),u.closePath();break;case"M":u.moveTo(-.4,-.5),u.lineTo(-.4,.5),u.lineTo(-.25,.5),u.lineTo(0,.1),u.lineTo(.25,.5),u.lineTo(.4,.5),u.lineTo(.4,-.5),u.lineTo(.25,-.5),u.lineTo(.25,.15),u.lineTo(0,-.25),u.lineTo(-.25,.15),u.lineTo(-.25,-.5),u.closePath();break;case"U":u.moveTo(-.3,.5),u.lineTo(-.3,-.2),u.absarc(0,-.2,.3,Math.PI,0,!1),u.lineTo(.3,.5),u.lineTo(.15,.5),u.lineTo(.15,-.2),u.absarc(0,-.2,.15,0,Math.PI,!0),u.lineTo(-.15,.5),u.closePath();break;case"X":u.moveTo(-.35,.5),u.lineTo(-.15,.5),u.lineTo(0,.15),u.lineTo(.15,.5),u.lineTo(.35,.5),u.lineTo(.1,0),u.lineTo(.35,-.5),u.lineTo(.15,-.5),u.lineTo(0,-.15),u.lineTo(-.15,-.5),u.lineTo(-.35,-.5),u.lineTo(-.1,0),u.closePath();break;default:u.moveTo(-.2,-.5),u.lineTo(-.2,.5),u.lineTo(.2,.5),u.lineTo(.2,-.5),u.closePath()}return new Nh(u,{depth:d,bevelEnabled:!0,bevelThickness:.02,bevelSize:.02,bevelSegments:2})},a=N.useMemo(()=>o(n),[n]);return c.jsxs("group",{position:e,children:[c.jsx("mesh",{geometry:a,castShadow:!0,children:c.jsx("meshStandardMaterial",{color:t,emissive:r,emissiveIntensity:i?1.5:.5,metalness:.3,roughness:.2})}),c.jsx("mesh",{ref:s,geometry:a,scale:[1.1,1.1,.5],children:c.jsx("meshStandardMaterial",{color:r,emissive:r,emissiveIntensity:i?2:.8,transparent:!0,opacity:.3})})]})},xQ=({position:n,rotation:e=[0,0,0],scale:t=1})=>{const r="CREWLY",i=-(r.length-1)*1/2,o=58879;return c.jsxs("group",{position:n,rotation:e,scale:[t,t,t],children:[c.jsxs("mesh",{position:[0,0,-.3],children:[c.jsx("boxGeometry",{args:[r.length*1+1,2,.2]}),c.jsx("meshStandardMaterial",{color:1710618,roughness:.8})]}),r.split("").map((a,l)=>c.jsx(gQ,{char:a,position:[i+l*1,0,0],color:o,glowColor:o},l))]})},vQ=()=>{const{isNightMode:n}=Pt(),e=N.useRef(null),t=N.useRef(!1),r=18,s=Bt.RIGHT_Z+.5,i=12;return vr(o=>{if(!e.current)return;const a=o.camera.position.x,l=o.camera.position.z,u=a-r,d=l-s,f=Math.sqrt(u*u+d*d)<i;t.current=f;const g=e.current.material;if(f){const y=o.clock.elapsedTime,b=Math.sin(y*1.5)*.3+.3,p=Math.sin(y*2+1)*.3+.5,m=Math.sin(y*1.2+2)*.2+.7;g.color.setRGB(b,p,m),g.emissive.setRGB(b*.6,p*.6,m*.6),g.emissiveIntensity=n?2:1.2}else g.color.setHex(1118488),g.emissive.setHex(0),g.emissiveIntensity=0}),c.jsxs("group",{position:[r,6,s],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[4.2,2.7,.15]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.4,metalness:.6})]}),c.jsxs("mesh",{ref:e,position:[0,0,.08],children:[c.jsx("planeGeometry",{args:[3.8,2.3]}),c.jsx("meshStandardMaterial",{color:1118488,emissive:0,emissiveIntensity:0,roughness:.1,metalness:0})]}),c.jsxs("mesh",{position:[0,0,-.15],castShadow:!0,children:[c.jsx("boxGeometry",{args:[1,.6,.2]}),c.jsx("meshStandardMaterial",{color:3355443,roughness:.5,metalness:.7})]})]})},yQ=({baseY:n,height:e,factoryWidth:t,factoryDepth:r})=>{const s=e-1,i=0,o=N.useMemo(()=>[{x:-14,y:i,width:10,height:s},{x:0,y:i,width:10,height:s},{x:14,y:i,width:10,height:s}],[s,i]),a=N.useMemo(()=>[{x:-22,y:i,width:10,height:s},{x:-8,y:i,width:10,height:s},{x:8,y:i,width:10,height:s},{x:22,y:i,width:10,height:s}],[s,i]);return c.jsxs("group",{position:[0,n,0],children:[c.jsxs("mesh",{position:[Bt.BACK_X-.3,0,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[.6,.5,r+1]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[Bt.FRONT_X+.3,0,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[.6,.5,r+1]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[0,0,Bt.LEFT_Z-.3],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+1,.5,.6]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[0,0,Bt.RIGHT_Z+.3],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+1,.5,.6]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsx(Ca,{position:[0,e/2,Bt.LEFT_Z],size:[t,e,Bt.THICKNESS],windows:a}),c.jsx(Ca,{position:[Bt.BACK_X,e/2,0],rotation:[0,Math.PI/2,0],size:[r,e,Bt.THICKNESS],windows:o}),c.jsx(Ca,{position:[Bt.FRONT_X,e/2,0],rotation:[0,-Math.PI/2,0],size:[r,e,Bt.THICKNESS],windows:o}),c.jsx(Ca,{position:[0,e/2,Bt.RIGHT_Z],size:[t,e,Bt.THICKNESS],windows:a}),a.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[l.x,e/2,Bt.LEFT_Z+.16],size:[l.width,l.height]}),c.jsx(Qc,{position:[l.x,e/2,Bt.LEFT_Z+.2],width:l.width,height:l.height})]},`upper-back-${u}`)),o.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.BACK_X+.16,e/2,l.x],rotation:[0,Math.PI/2,0],size:[l.width,l.height]}),c.jsx(Qc,{position:[Bt.BACK_X+.2,e/2,l.x],rotation:[0,Math.PI/2,0],width:l.width,height:l.height})]},`upper-left-${u}`)),o.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.FRONT_X-.16,e/2,l.x],rotation:[0,-Math.PI/2,0],size:[l.width,l.height]}),c.jsx(Qc,{position:[Bt.FRONT_X-.2,e/2,l.x],rotation:[0,-Math.PI/2,0],width:l.width,height:l.height})]},`upper-right-${u}`)),a.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[l.x,e/2,Bt.RIGHT_Z-.16],rotation:[0,Math.PI,0],size:[l.width,l.height]}),c.jsx(Qc,{position:[l.x,e/2,Bt.RIGHT_Z-.2],rotation:[0,Math.PI,0],width:l.width,height:l.height})]},`upper-front-${u}`)),c.jsxs("mesh",{position:[0,e,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[t-.5,.3,r-.5]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.5})]})]})},_Q=()=>{const{camera:n}=gs(),e=N.useRef(null),t=N.useRef(null),r=N.useRef(null),s=Bt.FRONT_X-Bt.BACK_X,i=Bt.RIGHT_Z-Bt.LEFT_Z,o=Bt.HEIGHT,a=12,l=o+a,u=o-1,d=0;vr(()=>{const g=n.position,y=g.x>Bt.BACK_X&&g.x<Bt.FRONT_X,b=g.z>Bt.LEFT_Z&&g.z<Bt.RIGHT_Z,p=y&&b&&g.y>0&&g.y<l,m=g.y>l;e.current&&(e.current.visible=!p&&!m),t.current&&(t.current.visible=!m),r.current&&(r.current.visible=!m)});const h=N.useMemo(()=>[{x:-14,y:d,width:10,height:u},{x:0,y:d,width:10,height:u},{x:14,y:d,width:10,height:u}],[u,d]),f=N.useMemo(()=>[{x:-22,y:d,width:10,height:u},{x:-8,y:d,width:10,height:u},{x:8,y:d,width:10,height:u},{x:22,y:d,width:10,height:u}],[u,d]);return c.jsxs("group",{children:[c.jsx(Ca,{position:[0,o/2,Bt.LEFT_Z],size:[s,o,Bt.THICKNESS],windows:f}),c.jsx(Ca,{position:[Bt.BACK_X,o/2,0],rotation:[0,Math.PI/2,0],size:[i,o,Bt.THICKNESS],windows:h}),c.jsx(Ca,{position:[Bt.FRONT_X,o/2,0],rotation:[0,-Math.PI/2,0],size:[i,o,Bt.THICKNESS],windows:h}),c.jsx(Ca,{position:[-24,o/2,Bt.RIGHT_Z],size:[16,o,Bt.THICKNESS]}),c.jsx(Ca,{position:[24,o/2,Bt.RIGHT_Z],size:[16,o,Bt.THICKNESS]}),f.map((g,y)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[g.x,o/2,Bt.LEFT_Z+.16],size:[g.width,g.height]}),c.jsx(Qc,{position:[g.x,o/2,Bt.LEFT_Z+.2],width:g.width,height:g.height})]},`back-${y}`)),h.map((g,y)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.BACK_X+.16,o/2,g.x],rotation:[0,Math.PI/2,0],size:[g.width,g.height]}),c.jsx(Qc,{position:[Bt.BACK_X+.2,o/2,g.x],rotation:[0,Math.PI/2,0],width:g.width,height:g.height})]},`left-${y}`)),h.map((g,y)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.FRONT_X-.16,o/2,g.x],rotation:[0,-Math.PI/2,0],size:[g.width,g.height]}),c.jsx(Qc,{position:[Bt.FRONT_X-.2,o/2,g.x],rotation:[0,-Math.PI/2,0],width:g.width,height:g.height})]},`right-${y}`)),c.jsxs("mesh",{ref:e,position:[0,o,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[s-.5,.3,i-.5]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.5})]}),c.jsx("group",{ref:r,children:c.jsx(yQ,{baseY:o,height:a,factoryWidth:s,factoryDepth:i})}),c.jsxs("mesh",{ref:t,position:[0,l+.5,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[s+2,1,i+2]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.3,roughness:.6})]}),c.jsx(vQ,{}),c.jsx(xQ,{position:[0,l+2,Bt.RIGHT_Z+.5],rotation:[0,0,0],scale:1.5})]})},SQ=({position:n,height:e=3})=>{const{isNightMode:t}=Pt(),r=t?1719578:2984493,s=t?4007959:9127187;return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{position:[0,e*.3,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.15,.25,e*.6,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[0,e*.6,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[1.2,e*.5,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,e*.85,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[.9,e*.4,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,e*1.05,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[.6,e*.3,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]})]})},bQ=({position:n,rotation:e=0})=>{const{isNightMode:t}=Pt(),r=t?4868698:16119260,s=t?4857888:9109504,i=t?16768392:8900331;return c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,1.25,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[3,2.5,2.5]}),c.jsx("meshStandardMaterial",{color:r,roughness:.7})]}),c.jsxs("mesh",{position:[0,3,0],rotation:[0,0,Math.PI/4],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2.5,2.5,2.8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.6})]}),c.jsxs("mesh",{position:[0,1.2,1.26],children:[c.jsx("planeGeometry",{args:[.8,.8]}),c.jsx("meshStandardMaterial",{color:i,emissive:t?i:0,emissiveIntensity:t?.5:0})]}),c.jsxs("mesh",{position:[0,.6,1.26],children:[c.jsx("planeGeometry",{args:[.6,1.2]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.8})]}),c.jsxs("mesh",{position:[.8,3.5,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.4,1,.4]}),c.jsx("meshStandardMaterial",{color:6710886,roughness:.8})]})]})},wQ=({position:n,speed:e=.5})=>{const t=N.useRef(null),r=n[0],{isNightMode:s}=Pt();vr(a=>{t.current&&(t.current.position.x=r+Math.sin(a.clock.elapsedTime*e*.1)*5,t.current.position.y=n[1]+Math.sin(a.clock.elapsedTime*e*.3)*.3)});const i=s?3816010:16777215,o=s?.3:.9;return c.jsxs("group",{ref:t,position:n,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[1.5,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[1.5,.3,0],children:[c.jsx("sphereGeometry",{args:[1.2,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[-1.3,.2,0],children:[c.jsx("sphereGeometry",{args:[1,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[.5,.6,.3],children:[c.jsx("sphereGeometry",{args:[.8,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[-.5,-.3,.2],children:[c.jsx("sphereGeometry",{args:[.9,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]})]})},CQ=()=>{const{isNightMode:n}=Pt(),e=n?5592416:12303296;return c.jsxs("group",{children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,38],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[6,34]}),c.jsx("meshStandardMaterial",{color:e,roughness:.85})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,42],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[48,4]}),c.jsx("meshStandardMaterial",{color:e,roughness:.85})]})]})},AQ=()=>{const{isNightMode:n}=Pt(),e=n?1716304:2777232,t=n?1720368:2781264,r=16777215;return c.jsxs("group",{position:[-18,0,42],children:[c.jsxs("mesh",{position:[0,.04,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[16,.08,23]}),c.jsx("meshStandardMaterial",{color:t,roughness:.7})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.09,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[13,20]}),c.jsx("meshStandardMaterial",{color:e,roughness:.7})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[-6.5,.1,0],children:[c.jsx("planeGeometry",{args:[.08,20]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[6.5,.1,0],children:[c.jsx("planeGeometry",{args:[.08,20]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,-10],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,10],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,-3.5],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,3.5],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,0],children:[c.jsx("planeGeometry",{args:[.08,7]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{position:[0,.85,0],children:[c.jsx("boxGeometry",{args:[13.5,.9,.05]}),c.jsx("meshStandardMaterial",{color:2236962,transparent:!0,opacity:.7})]}),c.jsxs("mesh",{position:[-6.8,.5,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.06,.06,1,8]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[6.8,.5,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.06,.06,1,8]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.6,roughness:.3})]})]})},MQ=()=>{const{isNightMode:n}=Pt(),e=n?1722912:2787888,t=n?9075280:13943930,r=13421772,s=[[-2,0,-3],[3,0,1],[-1,0,4]];return c.jsxs("group",{position:[18,.03,42],children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],receiveShadow:!0,children:[c.jsx("circleGeometry",{args:[9,32]}),c.jsx("meshStandardMaterial",{color:e,roughness:.6})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[5,-.01,-4],children:[c.jsx("circleGeometry",{args:[3,16]}),c.jsx("meshStandardMaterial",{color:t,roughness:.95})]}),s.map(([i,o,a],l)=>c.jsxs("group",{position:[i,o,a],children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.01,0],children:[c.jsx("circleGeometry",{args:[.15,16]}),c.jsx("meshStandardMaterial",{color:1118481})]}),c.jsxs("mesh",{position:[0,.6,0],children:[c.jsx("cylinderGeometry",{args:[.03,.03,1.2,6]}),c.jsx("meshStandardMaterial",{color:r,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[.2,1.05,0],children:[c.jsx("planeGeometry",{args:[.4,.25]}),c.jsx("meshStandardMaterial",{color:16724787,side:Tn,emissive:16724787,emissiveIntensity:.2})]})]},`flag-${l}`))]})},t3=({position:n,mirror:e=!1})=>{const{isNightMode:t}=Pt(),r=t?3811866:6965802,s=[16737928,16755251,11163135,16729190,16768324],i=t?1722906:2783786,o=e?-1:1;return c.jsxs("group",{position:n,scale:[o,1,1],children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.05,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[6,4]}),c.jsx("meshStandardMaterial",{color:r,roughness:.95})]}),c.jsxs("mesh",{position:[0,.15,0],receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[6.2,.3,4.2]}),c.jsx("meshStandardMaterial",{color:9075306,roughness:.8})]}),c.jsxs("mesh",{position:[0,.15,0],children:[c.jsx("boxGeometry",{args:[5.8,.35,3.8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.95})]}),[[-2,.4,-1],[-1,.35,-1.2],[0,.4,-.8],[1,.35,-1],[2,.4,-1.1],[-1.5,.4,.5],[0,.35,.8],[1.5,.4,.3],[-.5,.4,1.2],[.8,.35,1]].map(([a,l,u],d)=>c.jsxs("mesh",{position:[a,l,u],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.18,8,8]}),c.jsx("meshStandardMaterial",{color:s[d%s.length],emissive:s[d%s.length],emissiveIntensity:t?.3:.1})]},`flower-${d}`)),c.jsxs("mesh",{position:[-2.2,.5,0],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.5,8,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.8})]}),c.jsxs("mesh",{position:[2.2,.45,.3],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.4,8,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.8})]})]})},k0=({position:n,rotation:e=0})=>{const{isNightMode:t}=Pt(),r=t?3811866:9133628,s=t?4473936:6710896;return c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.5,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.08,.6]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,.9,-.25],rotation:[.15,0,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.5,.08]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),[-.8,.8].map((i,o)=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[i,.25,.2],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.06,.5,.06]}),c.jsx("meshStandardMaterial",{color:s,metalness:.6,roughness:.4})]}),c.jsxs("mesh",{position:[i,.25,-.2],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.06,.5,.06]}),c.jsx("meshStandardMaterial",{color:s,metalness:.6,roughness:.4})]})]},`leg-${o}`))]})};On.preload(bn.CYBERTRUCK);const VS=6.5,EQ=({position:n,rotation:e=0})=>{const t=On(bn.CYBERTRUCK),r=N.useMemo(()=>{const s=t.scene.clone(!0);return s.traverse(i=>{i.isMesh&&(i.castShadow=!0,i.receiveShadow=!0)}),s},[t.scene]);return c.jsx("group",{position:n,rotation:[0,e,0],children:c.jsx("primitive",{object:r,scale:[VS,VS,VS]})})},TQ=()=>{const{isNightMode:n}=Pt(),e=N.useMemo(()=>[[-35,0,-25,4],[-28,0,-28,3.5],[-20,0,-26,4.5],[-12,0,-28,3],[-4,0,-25,4.2],[4,0,-27,3.8],[12,0,-26,4],[20,0,-28,3.5],[28,0,-25,4.5],[35,0,-27,3],[-40,0,-40,5],[-32,0,-42,4.5],[-24,0,-38,5.5],[-16,0,-44,4],[-8,0,-40,5.2],[0,0,-42,4.8],[8,0,-38,5],[16,0,-44,4.5],[24,0,-40,5.5],[32,0,-42,4],[40,0,-38,5.2],[-45,0,-55,6],[-35,0,-58,5.5],[-25,0,-52,6.5],[-15,0,-60,5],[-5,0,-55,6.2],[5,0,-58,5.8],[15,0,-52,6],[25,0,-60,5.5],[35,0,-55,6.5],[45,0,-58,5],[-50,0,-70,7],[-30,0,-75,6.5],[-10,0,-72,7.5],[10,0,-70,6],[30,0,-75,7.2],[50,0,-72,6.8],[-35,0,-15,3.5],[-38,0,-5,4],[-35,0,5,3.8],[-38,0,15,4.2],[-42,0,-20,4.5],[-45,0,-10,5],[-42,0,0,4.8],[-45,0,10,5.2],[-50,0,-15,5.5],[-50,0,5,5],[35,0,-15,4],[38,0,-5,3.5],[35,0,5,4.2],[38,0,15,3.8],[42,0,-20,4.5],[45,0,-10,5],[42,0,0,4.8],[45,0,10,5.2],[50,0,-15,5.5],[50,0,5,5],[-25,0,-32,3.8],[-10,0,-33,4.2],[10,0,-32,3.5],[25,0,-33,4],[-35,0,26,4],[-30,0,30,3.5],[-38,0,35,4.5],[-32,0,40,3.8],[-40,0,45,4.2],[35,0,26,3.8],[30,0,30,4],[38,0,35,4.5],[32,0,40,3.5],[40,0,45,4.2],[-25,0,55,5],[-10,0,52,4.5],[10,0,54,4.8],[25,0,52,5.2],[0,0,58,5]],[]),t=N.useMemo(()=>[[-32,0,-35,.2],[-15,0,-38,-.1],[5,0,-36,.3],[25,0,-38,-.2],[-40,0,-50,.4],[-20,0,-52,-.3],[0,0,-48,.1],[20,0,-52,-.1],[40,0,-50,.2],[-35,0,-65,.5],[0,0,-68,0],[35,0,-65,-.4],[-40,0,-10,Math.PI/2],[-48,0,-25,Math.PI/2+.2],[-45,0,8,Math.PI/2-.1],[40,0,0,-Math.PI/2],[48,0,-20,-Math.PI/2+.2],[45,0,12,-Math.PI/2-.1]],[]),r=N.useMemo(()=>[[-20,15,-30,.3],[10,18,-25,.5],[30,14,-35,.4],[-35,16,0,.35],[35,17,10,.45],[-50,20,-40,.25],[50,19,-50,.55],[0,22,-60,.3],[-30,21,-55,.4],[30,20,-65,.35],[-15,17,-45,.45],[15,19,-55,.3]],[]),s=n?1710638:8900331,i=n?2771503:4881487,o=n?3824191:5934175;return c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,20,-100],receiveShadow:!1,children:[c.jsx("planeGeometry",{args:[300,100]}),c.jsx("meshBasicMaterial",{color:s,side:Tn})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.01,-20],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[200,200]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[-30,2,-80],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[25,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[30,3,-85],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[30,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[0,4,-90],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[35,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[-50,2,-75],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[20,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[50,2.5,-78],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[22,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),e.map(([a,l,u,d],h)=>c.jsx(SQ,{position:[a,l,u],height:d},`tree-${h}`)),t.map(([a,l,u,d],h)=>c.jsx(bQ,{position:[a,l,u],rotation:d},`house-${h}`)),r.map(([a,l,u,d],h)=>c.jsx(wQ,{position:[a,l,u],speed:d},`cloud-${h}`)),c.jsx(CQ,{}),c.jsx(AQ,{}),c.jsx(MQ,{}),c.jsx(t3,{position:[-12,0,26]}),c.jsx(t3,{position:[12,0,26],mirror:!0}),c.jsx(k0,{position:[-4,0,30],rotation:Math.PI/2}),c.jsx(k0,{position:[4,0,30],rotation:-Math.PI/2}),c.jsx(k0,{position:[-4,0,36],rotation:Math.PI/2}),c.jsx(k0,{position:[4,0,36],rotation:-Math.PI/2}),c.jsx(EQ,{position:[0,0,50],rotation:0})]})},kQ=({workstation:n,zoneColor:e})=>{const{isNightMode:t,agents:r}=Pt(),s=N.useRef(null),i=N.useRef(null),o=N.useRef([]),a=N.useMemo(()=>n.assignedAgentId?r.get(n.assignedAgentId):null,[n.assignedAgentId,r]),l=N.useMemo(()=>{if(!a)return{color:8947848,emissive:8947848};switch(a.status){case"active":return{color:65280,emissive:65280};case"idle":return{color:16776960,emissive:16776960};case"dormant":return{color:16711680,emissive:16711680};default:return{color:8947848,emissive:8947848}}},[a]);vr(h=>{const f=h.clock.elapsedTime;if(s.current){const g=s.current.material,y=(Math.sin(f*3)+1)/2;g.emissiveIntensity=.3+y*.7}if(i.current&&(a==null?void 0:a.status)==="active"){const g=i.current.material;g.emissiveIntensity=.2+Math.sin(f*2)*.1}o.current.forEach((g,y)=>{if(g&&(a==null?void 0:a.status)==="active"){const b=g.material,p=Math.sin(f*10+y*2)*.1+.9;b.emissiveIntensity=.8*p,b.opacity=a.cpuPercent>10?.9:0}})});const{x:u,z:d}=n.position;return c.jsxs("group",{position:[u,0,d],children:[c.jsx(RQ,{}),c.jsx(NQ,{}),c.jsx(IQ,{isActive:n.isActive,displayRef:i,codeLineRefs:o}),(a==null?void 0:a.status)==="idle"&&c.jsx(PQ,{type:n.index%3===0?"soda":"coffee"}),c.jsxs("mesh",{ref:s,position:[.8,.83,0],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:l.color,emissive:l.emissive,emissiveIntensity:.5})]}),t&&n.isActive&&c.jsx("spotLight",{color:16777198,intensity:1.5,distance:8,angle:Math.PI/4,penumbra:.5,decay:1,position:[0,4,0],"target-position":[0,0,.5],castShadow:!0,"shadow-mapSize-width":512,"shadow-mapSize-height":512})]})},RQ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.05,1]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.6})]}),[[-.9,-.4],[.9,-.4],[-.9,.4],[.9,.4]].map(([n,e],t)=>c.jsxs("mesh",{position:[n,.375,e],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.03,.03,.75,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.8})]},t))]}),NQ=()=>c.jsxs("group",{position:[0,0,.8],children:[c.jsxs("mesh",{position:[0,.45,0],children:[c.jsx("boxGeometry",{args:[.5,.08,.5]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsxs("mesh",{position:[0,.7,.21],children:[c.jsx("boxGeometry",{args:[.5,.5,.08]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsxs("mesh",{position:[0,.225,0],children:[c.jsx("cylinderGeometry",{args:[.02,.02,.45,8]}),c.jsx("meshStandardMaterial",{color:6710886,metalness:.8})]}),c.jsxs("mesh",{position:[0,.02,0],rotation:[0,0,0],children:[c.jsx("cylinderGeometry",{args:[.25,.25,.02,16]}),c.jsx("meshStandardMaterial",{color:4473924,metalness:.6})]})]}),IQ=({isActive:n,displayRef:e,codeLineRefs:t})=>{const r=n?1710638:657938;return c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.79,-.1],children:[c.jsx("boxGeometry",{args:[1,.04,.7]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.5,roughness:.3})]}),c.jsxs("group",{position:[0,.79,-.45],rotation:[-Math.PI/6,0,0],children:[c.jsxs("mesh",{position:[0,.35,-.015],children:[c.jsx("boxGeometry",{args:[1,.7,.03]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{ref:e,position:[0,.35,.002],children:[c.jsx("planeGeometry",{args:[.9,.6]}),c.jsx("meshStandardMaterial",{color:r,emissive:n?1710638:0,emissiveIntensity:n?.3:0})]}),n&&c.jsx(c.Fragment,{children:[0,1,2,3,4].map(s=>c.jsxs("mesh",{ref:i=>{i&&(t.current[s]=i)},position:[-.1+Math.random()*.1,.5-s*.1,.004],children:[c.jsx("planeGeometry",{args:[.5+Math.random()*.2,.03]}),c.jsx("meshStandardMaterial",{color:65416,emissive:65416,emissiveIntensity:.8,transparent:!0,opacity:.9})]},s))})]}),c.jsxs("mesh",{position:[0,.801,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("planeGeometry",{args:[.8,.4]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.8})]})]})},PQ=({type:n})=>n==="coffee"?c.jsxs("group",{position:[.55,.78,.2],children:[c.jsxs("mesh",{position:[0,.08,0],children:[c.jsx("cylinderGeometry",{args:[.06,.05,.14,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.4})]}),c.jsxs("mesh",{position:[0,.15,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[.055,12]}),c.jsx("meshStandardMaterial",{color:4073251})]}),c.jsxs("mesh",{position:[.08,.08,0],rotation:[0,0,Math.PI/2],children:[c.jsx("torusGeometry",{args:[.03,.008,8,12,Math.PI]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.4})]})]}):c.jsxs("group",{position:[.55,.78,.2],children:[c.jsxs("mesh",{position:[0,.07,0],children:[c.jsx("cylinderGeometry",{args:[.035,.035,.12,12]}),c.jsx("meshStandardMaterial",{color:13369344,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[0,.13,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[.035,12]}),c.jsx("meshStandardMaterial",{color:13421772,metalness:.8,roughness:.2})]}),c.jsxs("mesh",{position:[0,.07,0],children:[c.jsx("cylinderGeometry",{args:[.036,.036,.04,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.4})]})]}),LQ=({zone:n})=>{const{WIDTH:e,DEPTH:t}=nt.ZONE;return c.jsxs(c.Fragment,{children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[n.zoneX,.03,n.zoneZ],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[e,t]}),c.jsx("meshStandardMaterial",{color:n.color,roughness:.8,transparent:!0,opacity:.3,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2})]}),c.jsx(jQ,{zone:n})]})},jQ=({zone:n})=>{const{WIDTH:e,DEPTH:t}=nt.ZONE,r=N.useMemo(()=>{const s=e/2,i=t/2;return[new se(-s,.05,-i),new se(s,.05,-i),new se(s,.05,i),new se(-s,.05,i),new se(-s,.05,-i)]},[]);return c.jsx("group",{position:[n.zoneX,0,n.zoneZ],children:c.jsx(F$,{points:r,color:n.color,lineWidth:2})})},BQ=({projectName:n,position:e,color:t})=>{const r=N.useMemo(()=>{const s=document.createElement("canvas");s.width=512,s.height=128;const i=s.getContext("2d");if(i){i.fillStyle=`#${t.toString(16).padStart(6,"0")}`,i.fillRect(0,0,512,128),i.fillStyle="#ffffff",i.font="bold 48px Arial",i.textAlign="center",i.textBaseline="middle";let a=n||"Project";a.length>14&&(a=a.substring(0,13)+"..."),i.fillText(a,256,64)}const o=new Aj(s);return o.needsUpdate=!0,o},[n,t]);return c.jsxs("mesh",{position:e,rotation:[-Math.PI/2,0,0],children:[c.jsx("planeGeometry",{args:[3,.75]}),c.jsx("meshStandardMaterial",{map:r,emissive:t,emissiveIntensity:.2})]})},DQ=({zone:n})=>{const{DEPTH:e}=nt.ZONE;return c.jsxs("group",{children:[c.jsx(LQ,{zone:n}),n.workstations.map((t,r)=>c.jsx(kQ,{workstation:t,zoneColor:n.color},`ws-${n.zoneIndex}-${r}`)),c.jsx(BQ,{projectName:n.projectName,position:[n.zoneX,.04,n.zoneZ+e/2-.5],color:n.color})]})},OQ=()=>{const{zones:n}=Pt(),e=N.useMemo(()=>Array.from(n.values()),[n]);return c.jsx("group",{children:e.map(t=>c.jsx(DQ,{zone:t},t.projectName))})},{WALLS:br}=nt,wr={pot:new Wi(.25,.2,.5,16),soil:new Wi(.22,.22,.05,16),leaf:new ta(.25,.4),clockFace:new wa(.4,64),clockRim:new mm(.38,.42,64),hourMarkerLarge:new wa(.02,8),hourMarkerSmall:new wa(.01,8),hourHand:new Bs(.02,.16,.01),minuteHand:new Bs(.015,.24,.01),secondHand:new Bs(.008,.28,.005),centerCap:new wa(.02,16),cord:new Wi(.02,.02,1,8),pendantDome:new xu(.4,.25,32,1,!0),floorLampDome:new xu(.25,.15,32,1,!0),lightBulb:new yu(.08,16,16),smallLightBulb:new yu(.06,16,16),lampBase:new Wi(.3,.35,.1,32),lampPole:new Wi(.025,.025,1.9,16),lampArc:new Wi(.025,.025,.8,16),logoCircle:new wa(.15,32)},ts={whiteCeramic:new An({color:16119285,roughness:.3}),soil:new An({color:4007959,roughness:.9}),aluminum:new An({color:12632256,metalness:.8,roughness:.2}),darkGray:new An({color:3355443}),clockHand:new An({color:3355443}),secondHand:new An({color:16737792}),whiteFace:new An({color:16777215,roughness:.3}),whiteShade:new An({color:16119285,side:Tn,roughness:.3}),logo:new An({color:16777215,transparent:!0,opacity:.3})},Vl={leafDay:new An({color:4889162,side:Tn,roughness:.6}),leafNight:new An({color:2972205,side:Tn,roughness:.6}),screenDay:new An({color:2763326,emissive:0,emissiveIntensity:.5}),screenNight:new An({color:1710638,emissive:1118498,emissiveIntensity:.5}),bulbDay:new An({color:16777198,emissive:16777164,emissiveIntensity:.5}),bulbNight:new An({color:16777198,emissive:16777164,emissiveIntensity:2}),smallBulbDay:new An({color:16777198,emissive:16777164,emissiveIntensity:.3}),smallBulbNight:new An({color:16777198,emissive:16777164,emissiveIntensity:1.5})},Ui=br.HEIGHT,FQ=[[br.BACK_X+2,0,br.LEFT_Z+3,1.5],[br.FRONT_X-2,0,br.LEFT_Z+3,1.3],[br.BACK_X+2,0,0,1.4],[br.FRONT_X-2,0,0,1.2],[br.BACK_X+2,0,br.RIGHT_Z-3,1.5],[br.FRONT_X-2,0,br.RIGHT_Z-3,1.3]],UQ=[[-14,Ui-1,8],[0,Ui-1,8],[14,Ui-1,8],[-14,Ui-1,-4],[0,Ui-1,-4],[14,Ui-1,-4],[-14,Ui-1,-16],[0,Ui-1,-16],[14,Ui-1,-16]],HQ=[[br.BACK_X+4,0,br.LEFT_Z+5],[br.FRONT_X-4,0,br.LEFT_Z+5],[br.BACK_X+4,0,12],[br.FRONT_X-4,0,12]],zQ=[0,72,144,216,288],GQ=zQ.map((n,e)=>({position:[Math.sin(n*Math.PI/180)*.15,.7+e*.12,Math.cos(n*Math.PI/180)*.15],rotation:[.4+e*.1,n*Math.PI/180,0]})),WQ=Array.from({length:12},(n,e)=>{const t=e*Math.PI/6;return{position:[Math.sin(t)*.32,Math.cos(t)*.32,.01],isMainHour:e%3===0}}),VQ=({position:n,size:e=1})=>{const{isNightMode:t}=Pt(),r=t?Vl.leafNight:Vl.leafDay;return c.jsxs("group",{position:n,scale:[e,e,e],children:[c.jsx("mesh",{position:[0,.25,0],geometry:wr.pot,material:ts.whiteCeramic,castShadow:!0}),c.jsx("mesh",{position:[0,.48,0],geometry:wr.soil,material:ts.soil}),GQ.map((s,i)=>c.jsx("mesh",{position:s.position,rotation:s.rotation,geometry:wr.leaf,material:r},i))]})},XQ=({position:n,rotation:e=0,width:t=3,height:r=1.8})=>{const{isNightMode:s}=Pt(),i=s?Vl.screenNight:Vl.screenDay;return c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+.1,r+.1,.03]}),c.jsx("primitive",{object:ts.aluminum,attach:"material"})]}),c.jsxs("mesh",{position:[0,0,.02],children:[c.jsx("boxGeometry",{args:[t,r,.01]}),c.jsx("primitive",{object:i,attach:"material"})]}),c.jsx("mesh",{position:[0,0,.025],geometry:wr.logoCircle,material:ts.logo})]})},n3=({position:n,rotation:e=0})=>{const t=N.useRef(null),r=N.useRef(null),s=N.useRef(null),i=N.useRef(0);if(i.current===0){const o=new Date,a=o.getHours()*36e5+o.getMinutes()*6e4+o.getSeconds()*1e3+o.getMilliseconds();i.current=a-performance.now()}return vr(()=>{const a=(performance.now()+i.current)%864e5/1e3,l=a%60,u=a/60%60,d=a/3600%12;s.current&&(s.current.rotation.z=-l*(Math.PI/30)),r.current&&(r.current.rotation.z=-u*(Math.PI/30)),t.current&&(t.current.rotation.z=-d*(Math.PI/6))}),c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsx("mesh",{geometry:wr.clockFace,material:ts.whiteFace}),c.jsx("mesh",{position:[0,0,-.01],geometry:wr.clockRim,material:ts.aluminum}),WQ.map((o,a)=>c.jsx("mesh",{position:o.position,geometry:o.isMainHour?wr.hourMarkerLarge:wr.hourMarkerSmall,material:ts.darkGray},a)),c.jsx("mesh",{ref:t,position:[0,.08,.02],geometry:wr.hourHand,material:ts.clockHand}),c.jsx("mesh",{ref:r,position:[0,.12,.02],geometry:wr.minuteHand,material:ts.clockHand}),c.jsx("mesh",{ref:s,position:[0,.12,.02],geometry:wr.secondHand,material:ts.secondHand}),c.jsx("mesh",{position:[0,0,.03],geometry:wr.centerCap,material:ts.darkGray})]})},KQ=({position:n})=>{const{isNightMode:e}=Pt(),t=e?Vl.bulbNight:Vl.bulbDay;return c.jsxs("group",{position:n,children:[c.jsx("mesh",{position:[0,.5,0],geometry:wr.cord,material:ts.darkGray}),c.jsx("mesh",{rotation:[Math.PI,0,0],geometry:wr.pendantDome,material:ts.whiteShade}),c.jsx("mesh",{position:[0,-.1,0],geometry:wr.lightBulb,material:t})]})},JQ=({position:n})=>{const{isNightMode:e}=Pt(),t=e?Vl.smallBulbNight:Vl.smallBulbDay;return c.jsxs("group",{position:n,children:[c.jsx("mesh",{position:[0,.05,0],geometry:wr.lampBase,material:ts.aluminum,castShadow:!0}),c.jsx("mesh",{position:[0,1,0],geometry:wr.lampPole,material:ts.aluminum,castShadow:!0}),c.jsx("mesh",{position:[.3,1.9,0],rotation:[0,0,Math.PI/6],geometry:wr.lampArc,material:ts.aluminum,castShadow:!0}),c.jsxs("group",{position:[.6,1.7,0],children:[c.jsx("mesh",{rotation:[Math.PI,0,0],geometry:wr.floorLampDome,material:ts.whiteShade}),c.jsx("mesh",{position:[0,-.05,0],geometry:wr.smallLightBulb,material:t})]})]})},qQ=()=>c.jsxs("group",{children:[FQ.map(([n,e,t,r],s)=>c.jsx(VQ,{position:[n,e,t],size:r},`plant-${s}`)),c.jsx(XQ,{position:[0,Ui/2,br.LEFT_Z+.2],rotation:0,width:4,height:2.5}),c.jsx(n3,{position:[br.BACK_X+.2,Ui*.6,8],rotation:Math.PI/2}),c.jsx(n3,{position:[br.FRONT_X-.2,Ui*.6,-8],rotation:-Math.PI/2}),UQ.map((n,e)=>c.jsx(KQ,{position:n},`pendant-${e}`)),HQ.map((n,e)=>c.jsx(JQ,{position:n},`lamp-${e}`))]}),ll={beltSurface:new Bs(16,.1,1.2),beltRail:new Bs(16,.05,.08),roller:new Wi(.3,.3,1.2,16),supportLeg:new Bs(.15,.5,.15),productBox:new Bs(1,1,1)},Pc={beltSurface:new An({color:3355443,metalness:.6,roughness:.4}),beltRail:new An({color:6710886,metalness:.8}),roller:new An({color:4473924,metalness:.7}),supportLeg:new An({color:5592405,metalness:.5})},$Q=2,YQ=5,QQ=2,R0=7,ZQ=.8,eZ=6710886,tZ=()=>{const{agents:n,zones:e}=Pt(),t=N.useRef([]),r=N.useRef(new Map),s=a=>{let l=r.current.get(a);return l||(l=new An({color:a,roughness:.7}),r.current.set(a,l)),l};N.useEffect(()=>()=>{r.current.forEach(a=>a.dispose()),r.current.clear()},[]);const i=N.useMemo(()=>{const a=[];return n.forEach((l,u)=>{a.push(`${u}:${l.status}`)}),a.sort().join("|")},[n]),o=N.useMemo(()=>{const a=new Map;n.forEach(d=>{if(d.status==="active"){const h=e.get(d.projectName);if(h){const f=a.get(d.projectName);f?f.count++:a.set(d.projectName,{count:1,color:h.color})}}});const l=[];let u=0;if(a.forEach(({count:d,color:h})=>{const f=Math.min(d*$Q,YQ);for(let g=0;g<f;g++)l.push({offset:-R0+(u*3.7+g*2.3)%(R0*2),color:h,size:.35+(u*7+g*3)%5*.04}),u++}),l.length===0)for(let d=0;d<QQ;d++)l.push({offset:-3+d*6,color:eZ,size:.3+d*.05});return l},[i,e]);return vr((a,l)=>{t.current.forEach(u=>{u&&(u.position.x+=l*ZQ,u.position.x>R0&&(u.position.x=-R0))})}),c.jsxs("group",{position:[0,0,-14],children:[c.jsx("mesh",{position:[0,.5,0],geometry:ll.beltSurface,material:Pc.beltSurface,receiveShadow:!0}),c.jsx("mesh",{position:[0,.55,.55],geometry:ll.beltRail,material:Pc.beltRail}),c.jsx("mesh",{position:[0,.55,-.55],geometry:ll.beltRail,material:Pc.beltRail}),c.jsx("mesh",{position:[-7.5,.5,0],rotation:[Math.PI/2,0,0],geometry:ll.roller,material:Pc.roller}),c.jsx("mesh",{position:[7.5,.5,0],rotation:[Math.PI/2,0,0],geometry:ll.roller,material:Pc.roller}),[-6,-2,2,6].map((a,l)=>c.jsxs("group",{position:[a,0,0],children:[c.jsx("mesh",{position:[0,.25,.4],geometry:ll.supportLeg,material:Pc.supportLeg}),c.jsx("mesh",{position:[0,.25,-.4],geometry:ll.supportLeg,material:Pc.supportLeg})]},l)),o.map((a,l)=>c.jsx("mesh",{ref:u=>{u&&(t.current[l]=u)},position:[a.offset,.6+a.size/2,0],scale:[a.size,a.size,a.size],geometry:ll.productBox,material:s(a.color),castShadow:!0},`${l}-${a.color}`))]})},{BREAK_ROOM:nZ}=nt,rZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[-2,0,0],children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.8,1.5,.6]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.3,0],children:[c.jsx("boxGeometry",{args:[.7,.3,.5]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.5,roughness:.1})]}),c.jsxs("mesh",{position:[0,.9,.31],children:[c.jsx("boxGeometry",{args:[.4,.2,.02]}),c.jsx("meshStandardMaterial",{color:1118481,emissive:n?65280:13056,emissiveIntensity:.3})]}),c.jsxs("mesh",{position:[0,.2,.2],children:[c.jsx("boxGeometry",{args:[.5,.05,.4]}),c.jsx("meshStandardMaterial",{color:4473924,metalness:.5})]})]})},sZ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.8,.8,.05,24]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.6})]}),c.jsxs("mesh",{position:[0,.35,0],children:[c.jsx("cylinderGeometry",{args:[.08,.1,.7,12]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("cylinderGeometry",{args:[.4,.4,.04,16]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6})]}),[0,90,180,270].map((n,e)=>{const t=n*Math.PI/180,r=Math.sin(t)*1.3,s=Math.cos(t)*1.3;return c.jsx(iZ,{position:[r,0,s],rotation:-t+Math.PI},e)})]}),iZ=({position:n,rotation:e})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.45,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.25,.25,.08,16]}),c.jsx("meshStandardMaterial",{color:16739125,roughness:.8})]}),c.jsxs("mesh",{position:[0,.75,-.2],rotation:[.2,0,0],children:[c.jsx("boxGeometry",{args:[.45,.5,.06]}),c.jsx("meshStandardMaterial",{color:16739125,roughness:.8})]}),c.jsxs("mesh",{position:[0,.2,0],children:[c.jsx("cylinderGeometry",{args:[.04,.04,.4,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("cylinderGeometry",{args:[.2,.2,.04,12]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6})]})]}),oZ=()=>(Pt(),c.jsxs("group",{position:[2,0,-.5],children:[c.jsxs("mesh",{position:[0,1,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.9,2,.7]}),c.jsx("meshStandardMaterial",{color:2245802,roughness:.4})]}),c.jsxs("mesh",{position:[0,1.2,.36],children:[c.jsx("boxGeometry",{args:[.8,1.2,.02]}),c.jsx("meshStandardMaterial",{color:8961023,transparent:!0,opacity:.4,roughness:.1})]}),[1.5,1.2,.9].map((n,e)=>c.jsx("group",{children:[-.25,0,.25].map((t,r)=>c.jsxs("mesh",{position:[t,n,.25],children:[c.jsx("boxGeometry",{args:[.15,.2,.1]}),c.jsx("meshStandardMaterial",{color:[16711680,65280,16776960][r],roughness:.3})]},`${e}-${r}`))},e)),c.jsxs("mesh",{position:[.3,.6,.36],children:[c.jsx("boxGeometry",{args:[.1,.05,.02]}),c.jsx("meshStandardMaterial",{color:1118481,metalness:.8})]}),c.jsxs("mesh",{position:[0,.15,.36],children:[c.jsx("boxGeometry",{args:[.6,.25,.02]}),c.jsx("meshStandardMaterial",{color:1118481})]})]})),aZ=()=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("circleGeometry",{args:[4,32]}),c.jsx("meshStandardMaterial",{color:9139029,roughness:.8,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),lZ=()=>{const{x:n,z:e}=nZ.POSITION;return c.jsxs("group",{position:[n,0,e],children:[c.jsx(aZ,{}),c.jsx(rZ,{}),c.jsx(sZ,{}),c.jsx(oZ,{}),c.jsxs("group",{position:[-3,0,1.5],children:[c.jsxs("mesh",{position:[0,.2,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.25,.2,.4,12]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.8})]}),c.jsxs("mesh",{position:[0,.6,0],children:[c.jsx("sphereGeometry",{args:[.35,12,12]}),c.jsx("meshStandardMaterial",{color:3050286,roughness:.8})]})]}),c.jsx("group",{position:[0,3.5,-2],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[2,.4,.1]}),c.jsx("meshStandardMaterial",{color:2245802})]})})]})},{POKER_TABLE:cZ}=nt,uZ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("cylinderGeometry",{args:[1.2,1.2,.08,8]}),c.jsx("meshStandardMaterial",{color:2263842,roughness:.9})]}),c.jsxs("mesh",{position:[0,.8,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[1.1,32]}),c.jsx("meshStandardMaterial",{color:1997598,roughness:.95})]}),c.jsxs("mesh",{position:[0,.78,0],children:[c.jsx("torusGeometry",{args:[1.15,.08,8,32]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.6})]}),[45,135,225,315].map((n,e)=>{const t=n*Math.PI/180,r=Math.sin(t)*.8,s=Math.cos(t)*.8;return c.jsxs("mesh",{position:[r,.35,s],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.06,.08,.7,8]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.7})]},e)}),c.jsx(XS,{position:[-.4,.85,-.3],colors:[16711680,255]}),c.jsx(XS,{position:[.3,.85,.4],colors:[65280,16776960]}),c.jsx(XS,{position:[.5,.85,-.2],colors:[0,16777215]}),c.jsx(dZ,{position:[0,.82,0]})]}),XS=({position:n,colors:e})=>c.jsx("group",{position:n,children:[0,1,2,3,4].map(t=>c.jsxs("mesh",{position:[0,t*.02,0],children:[c.jsx("cylinderGeometry",{args:[.05,.05,.02,16]}),c.jsx("meshStandardMaterial",{color:e[t%2],roughness:.4})]},t))}),dZ=({position:n})=>c.jsxs("group",{position:n,children:[c.jsxs("mesh",{rotation:[0,.3,0],children:[c.jsx("boxGeometry",{args:[.12,.04,.18]}),c.jsx("meshStandardMaterial",{color:2245802,roughness:.5})]}),c.jsxs("mesh",{position:[.02,.025,.01],rotation:[0,.5,0],children:[c.jsx("boxGeometry",{args:[.12,.002,.18]}),c.jsx("meshStandardMaterial",{color:2245802,roughness:.5})]})]}),hZ=({position:n,rotation:e})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.5,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.5,.12,.5]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.7})]}),c.jsxs("mesh",{position:[0,.85,-.22],children:[c.jsx("boxGeometry",{args:[.5,.6,.08]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.7})]}),[-.28,.28].map((t,r)=>c.jsxs("mesh",{position:[t,.65,0],children:[c.jsx("boxGeometry",{args:[.06,.08,.4]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.6})]},r)),c.jsxs("mesh",{position:[0,.25,0],children:[c.jsx("cylinderGeometry",{args:[.05,.05,.4,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),[0,72,144,216,288].map((t,r)=>{const s=t*Math.PI/180;return c.jsxs("mesh",{position:[Math.sin(s)*.15,.03,Math.cos(s)*.15],rotation:[0,-s,Math.PI/2],children:[c.jsx("cylinderGeometry",{args:[.02,.02,.3,6]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]},r)})]}),fZ=()=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("circleGeometry",{args:[4,32]}),c.jsx("meshStandardMaterial",{color:2763317,roughness:.8,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),pZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[0,2.5,0],children:[c.jsxs("mesh",{children:[c.jsx("coneGeometry",{args:[.6,.4,16,1,!0]}),c.jsx("meshStandardMaterial",{color:3050286,side:Tn,roughness:.6})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("coneGeometry",{args:[.58,.38,16,1,!0]}),c.jsx("meshStandardMaterial",{color:14329120,side:vs,emissive:16768392,emissiveIntensity:n?.5:.1})]}),c.jsxs("mesh",{position:[0,-.1,0],children:[c.jsx("sphereGeometry",{args:[.08,16,16]}),c.jsx("meshStandardMaterial",{color:16777198,emissive:16777198,emissiveIntensity:n?1:.3})]}),c.jsxs("mesh",{position:[0,.7,0],children:[c.jsx("cylinderGeometry",{args:[.01,.01,1.2,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.8})]}),n&&c.jsx("spotLight",{color:16777181,intensity:2,distance:5,angle:Math.PI/3,penumbra:.5,position:[0,-.2,0],"target-position":[0,-3,0],castShadow:!0})]})},mZ=()=>{const{x:n,z:e}=cZ.POSITION,t=[0,90,180,270];return c.jsxs("group",{position:[n,0,e],children:[c.jsx(fZ,{}),c.jsx(uZ,{}),t.map((r,s)=>{const i=r*Math.PI/180,o=1.8;return c.jsx(hZ,{position:[Math.sin(i)*o,0,Math.cos(i)*o],rotation:-i+Math.PI},s)}),c.jsx(pZ,{}),c.jsxs("group",{position:[3,0,0],children:[c.jsxs("mesh",{position:[0,.5,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.3,.3,.04,16]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.6})]}),c.jsxs("mesh",{position:[0,.25,0],children:[c.jsx("cylinderGeometry",{args:[.05,.08,.5,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),c.jsxs("mesh",{position:[-.1,.58,.05],children:[c.jsx("cylinderGeometry",{args:[.04,.03,.12,8]}),c.jsx("meshStandardMaterial",{color:9127187,transparent:!0,opacity:.8})]}),c.jsxs("mesh",{position:[.1,.58,-.05],children:[c.jsx("cylinderGeometry",{args:[.04,.03,.12,8]}),c.jsx("meshStandardMaterial",{color:9127187,transparent:!0,opacity:.8})]})]})]})},{STAGE:ir}=nt,KS=({position:n,color:e})=>{const{isNightMode:t}=Pt();return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.15,.2,.3,12]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.8,roughness:.3})]}),c.jsxs("mesh",{position:[0,-.15,0],children:[c.jsx("cylinderGeometry",{args:[.12,.12,.05,12]}),c.jsx("meshStandardMaterial",{color:e,emissive:t?e:0,emissiveIntensity:t?.8:.2,transparent:!0,opacity:.9})]}),t&&c.jsxs("mesh",{position:[0,-1.5,0],rotation:[0,0,0],children:[c.jsx("coneGeometry",{args:[.8,3,12,1,!0]}),c.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:.1,side:Tn})]})]})},r3=({position:n,rotation:e=0})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[.6,1.2,.5]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.8})]}),c.jsxs("mesh",{position:[0,-.1,.26],children:[c.jsx("cylinderGeometry",{args:[.2,.18,.05,16]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.3})]}),c.jsxs("mesh",{position:[0,.35,.26],children:[c.jsx("cylinderGeometry",{args:[.08,.06,.04,12]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.4})]}),c.jsxs("mesh",{position:[0,0,.251],children:[c.jsx("planeGeometry",{args:[.5,1]}),c.jsx("meshStandardMaterial",{color:1710618,roughness:.9})]})]}),gZ=()=>c.jsxs("group",{position:[0,0,1.5],children:[c.jsxs("mesh",{position:[0,.05,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.25,.3,.1,16]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.6,roughness:.4})]}),c.jsxs("mesh",{position:[0,.75,0],children:[c.jsx("cylinderGeometry",{args:[.02,.02,1.4,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.4,.1],rotation:[Math.PI/6,0,0],children:[c.jsx("cylinderGeometry",{args:[.015,.015,.3,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7,roughness:.3})]}),c.jsxs("group",{position:[0,1.5,.2],children:[c.jsxs("mesh",{rotation:[Math.PI/6,0,0],children:[c.jsx("cylinderGeometry",{args:[.025,.03,.15,12]}),c.jsx("meshStandardMaterial",{color:4473924,metalness:.5,roughness:.4})]}),c.jsxs("mesh",{position:[0,.08,.04],rotation:[Math.PI/6,0,0],children:[c.jsx("sphereGeometry",{args:[.05,12,12]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.4,roughness:.6})]})]})]}),xZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,ir.HEIGHT/2,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[ir.WIDTH,ir.HEIGHT,ir.DEPTH]}),c.jsx("meshStandardMaterial",{color:4863784,roughness:.6})]}),c.jsxs("mesh",{position:[0,ir.HEIGHT/2,ir.DEPTH/2+.05],children:[c.jsx("boxGeometry",{args:[ir.WIDTH,ir.HEIGHT,.1]}),c.jsx("meshStandardMaterial",{color:13938487,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[0,.1,ir.DEPTH/2+.5],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.2,.8]}),c.jsx("meshStandardMaterial",{color:4863784,roughness:.6})]}),c.jsxs("mesh",{position:[0,ir.HEIGHT+.01,0],rotation:[-Math.PI/2,0,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[ir.WIDTH-.4,ir.DEPTH-.4]}),c.jsx("meshStandardMaterial",{color:3811866,roughness:.5,emissive:n?2232576:0,emissiveIntensity:n?.3:0})]})]})},vZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[0,2,-ir.DEPTH/2+.1],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[ir.WIDTH+1,4,.15]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.8,emissive:n?2228224:0,emissiveIntensity:.2})]}),c.jsxs("mesh",{position:[0,2.1,0],rotation:[0,0,Math.PI/2],children:[c.jsx("cylinderGeometry",{args:[.05,.05,ir.WIDTH+1.5,12]}),c.jsx("meshStandardMaterial",{color:13938487,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,2,.1],children:[c.jsx("boxGeometry",{args:[ir.WIDTH+1.2,.5,.1]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.7})]})]})},yZ=()=>{const{x:n,z:e}=ir.POSITION,t=ir.ROTATION||0;return c.jsxs("group",{position:[n,0,e],rotation:[0,t,0],children:[c.jsx(xZ,{}),c.jsx(vZ,{}),c.jsx(KS,{position:[-3,4,1],color:16729156}),c.jsx(KS,{position:[0,4,1],color:4521796}),c.jsx(KS,{position:[3,4,1],color:4474111}),c.jsx(r3,{position:[-ir.WIDTH/2-.5,.6,0],rotation:Math.PI/8}),c.jsx(r3,{position:[ir.WIDTH/2+.5,.6,0],rotation:-Math.PI/8}),c.jsx("group",{position:[0,ir.HEIGHT,0],children:c.jsx(gZ,{})}),c.jsx("group",{position:[0,4.5,-ir.DEPTH/2],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[3,.5,.1]}),c.jsx("meshStandardMaterial",{color:2236962})]})})]})},{LOUNGE:_Z}=nt,s3=({position:n,rotation:e=0,color:t=4878245})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.4,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2.5,.3,.9]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[0,.8,-.35],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2.5,.6,.25]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[-1.15,.55,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.2,.6,.9]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[1.15,.55,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.2,.6,.9]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[0,.15,0],children:[c.jsx("boxGeometry",{args:[2.6,.2,1]}),c.jsx("meshStandardMaterial",{color:2763306,roughness:.6})]}),[[-1.1,.05,.35],[1.1,.05,.35],[-1.1,.05,-.35],[1.1,.05,-.35]].map((r,s)=>c.jsxs("mesh",{position:r,children:[c.jsx("cylinderGeometry",{args:[.05,.05,.1,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.5})]},s)),c.jsxs("mesh",{position:[-.9,.65,.1],rotation:[0,.2,.1],children:[c.jsx("boxGeometry",{args:[.35,.35,.15]}),c.jsx("meshStandardMaterial",{color:16752762,roughness:.9})]}),c.jsxs("mesh",{position:[.9,.65,.1],rotation:[0,-.2,-.1],children:[c.jsx("boxGeometry",{args:[.35,.35,.15]}),c.jsx("meshStandardMaterial",{color:10017154,roughness:.9})]})]}),SZ=()=>(Pt(),c.jsxs("group",{position:[0,0,0],children:[c.jsxs("mesh",{position:[0,.4,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[1.2,.05,.7]}),c.jsx("meshStandardMaterial",{color:6045747,roughness:.5})]}),c.jsxs("mesh",{position:[0,.43,0],children:[c.jsx("boxGeometry",{args:[1.1,.01,.6]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.3,roughness:.1})]}),c.jsxs("mesh",{position:[0,.15,0],children:[c.jsx("boxGeometry",{args:[1,.03,.5]}),c.jsx("meshStandardMaterial",{color:6045747,roughness:.6})]}),[[-.5,.2,.25],[.5,.2,.25],[-.5,.2,-.25],[.5,.2,-.25]].map((n,e)=>c.jsxs("mesh",{position:n,children:[c.jsx("boxGeometry",{args:[.05,.4,.05]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6})]},e)),c.jsxs("group",{position:[.3,.45,0],children:[c.jsxs("mesh",{rotation:[0,.3,0],children:[c.jsx("boxGeometry",{args:[.25,.02,.18]}),c.jsx("meshStandardMaterial",{color:16739179,roughness:.7})]}),c.jsxs("mesh",{position:[.05,.02,.02],rotation:[0,-.2,0],children:[c.jsx("boxGeometry",{args:[.25,.02,.18]}),c.jsx("meshStandardMaterial",{color:5164484,roughness:.7})]})]}),c.jsxs("group",{position:[-.35,.45,.1],children:[c.jsxs("mesh",{position:[0,.05,0],children:[c.jsx("cylinderGeometry",{args:[.04,.035,.1,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.3})]}),c.jsxs("mesh",{position:[.05,.05,0],rotation:[0,0,Math.PI/2],children:[c.jsx("torusGeometry",{args:[.025,.008,8,12,Math.PI]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.3})]})]})]})),i3=({position:n})=>{const{isNightMode:e}=Pt();return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{position:[0,.05,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.2,.22,.1,16]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6,roughness:.4})]}),c.jsxs("mesh",{position:[0,.9,0],children:[c.jsx("cylinderGeometry",{args:[.02,.02,1.7,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.7,0],children:[c.jsx("cylinderGeometry",{args:[.15,.25,.3,16,1,!0]}),c.jsx("meshStandardMaterial",{color:16115411,roughness:.8,side:Tn})]}),c.jsxs("mesh",{position:[0,1.65,0],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:16777198,emissive:e?16777096:4473856,emissiveIntensity:e?1:.3})]})]})},bZ=()=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[6,4]}),c.jsx("meshStandardMaterial",{color:9136404,roughness:.9,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),o3=({position:n,scale:e=1})=>c.jsxs("group",{position:n,scale:e,children:[c.jsxs("mesh",{position:[0,.15,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.15,.12,.3,12]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.7})]}),c.jsxs("mesh",{position:[0,.28,0],children:[c.jsx("cylinderGeometry",{args:[.13,.13,.04,12]}),c.jsx("meshStandardMaterial",{color:4007959,roughness:.9})]}),c.jsxs("mesh",{position:[0,.55,0],children:[c.jsx("sphereGeometry",{args:[.25,8,8]}),c.jsx("meshStandardMaterial",{color:2263842,roughness:.8})]}),c.jsxs("mesh",{position:[-.1,.7,.1],children:[c.jsx("sphereGeometry",{args:[.15,8,8]}),c.jsx("meshStandardMaterial",{color:3050286,roughness:.8})]}),c.jsxs("mesh",{position:[.1,.65,-.1],children:[c.jsx("sphereGeometry",{args:[.18,8,8]}),c.jsx("meshStandardMaterial",{color:2263842,roughness:.8})]})]}),wZ=()=>{const{x:n,z:e}=_Z.POSITION;return c.jsxs("group",{position:[n,0,e],children:[c.jsx(bZ,{}),c.jsx(s3,{position:[-2,0,0],rotation:Math.PI/2,color:4878245}),c.jsx(s3,{position:[2,0,0],rotation:-Math.PI/2,color:5930933}),c.jsx(SZ,{}),c.jsx(i3,{position:[-3.5,0,1.5]}),c.jsx(i3,{position:[3.5,0,1.5]}),c.jsx(o3,{position:[-3.5,0,-1.5],scale:1.2}),c.jsx(o3,{position:[3.5,0,-1.5],scale:1}),c.jsx("group",{position:[0,3,-2],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[2,.4,.1]}),c.jsx("meshStandardMaterial",{color:4878245})]})})]})},{KITCHEN:CZ}=nt,AZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[-4,0,-1.5],children:[c.jsxs("mesh",{position:[0,1.1,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[1.2,2.2,.8]}),c.jsx("meshStandardMaterial",{color:12632256,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.1,.41],children:[c.jsx("boxGeometry",{args:[.02,2,.01]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.5})]}),c.jsxs("mesh",{position:[-.15,1.3,.42],children:[c.jsx("boxGeometry",{args:[.03,.4,.04]}),c.jsx("meshStandardMaterial",{color:10066329,metalness:.8,roughness:.2})]}),c.jsxs("mesh",{position:[.15,1.3,.42],children:[c.jsx("boxGeometry",{args:[.03,.4,.04]}),c.jsx("meshStandardMaterial",{color:10066329,metalness:.8,roughness:.2})]}),c.jsxs("mesh",{position:[0,1.7,.41],children:[c.jsx("boxGeometry",{args:[1.1,.02,.01]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.5})]}),c.jsxs("mesh",{position:[.4,1.9,.42],children:[c.jsx("boxGeometry",{args:[.15,.08,.01]}),c.jsx("meshStandardMaterial",{color:1118481,emissive:n?43775:13141,emissiveIntensity:.4})]})]})},MZ=()=>c.jsxs("group",{position:[0,0,0],children:[c.jsxs("mesh",{position:[0,.45,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[3.5,.9,1.2]}),c.jsx("meshStandardMaterial",{color:3815994,roughness:.5})]}),c.jsxs("mesh",{position:[0,.92,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[3.7,.06,1.4]}),c.jsx("meshStandardMaterial",{color:13945272,roughness:.3,metalness:.1})]}),[-1.2,-.4,.4,1.2].map((n,e)=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[n,.45,.61],children:[c.jsx("boxGeometry",{args:[.7,.75,.02]}),c.jsx("meshStandardMaterial",{color:4473924,roughness:.4})]}),c.jsxs("mesh",{position:[n+.25,.45,.63],children:[c.jsx("sphereGeometry",{args:[.025,8,8]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.8})]})]},`door-f-${e}`)),[-1.2,-.4,.4,1.2].map((n,e)=>c.jsx("group",{children:c.jsxs("mesh",{position:[n,.45,-.61],children:[c.jsx("boxGeometry",{args:[.7,.75,.02]}),c.jsx("meshStandardMaterial",{color:4473924,roughness:.4})]})},`door-b-${e}`))]}),EZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[1.2,.95,0],children:[c.jsxs("mesh",{position:[0,.15,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.5,.3,.35]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.4,metalness:.3})]}),c.jsxs("mesh",{position:[-.05,.15,.18],children:[c.jsx("boxGeometry",{args:[.3,.2,.01]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.1,metalness:.2})]}),c.jsxs("mesh",{position:[.2,.15,.18],children:[c.jsx("boxGeometry",{args:[.08,.2,.01]}),c.jsx("meshStandardMaterial",{color:1118481,emissive:n?65280:13056,emissiveIntensity:.3})]}),c.jsxs("mesh",{position:[.12,.15,.19],children:[c.jsx("boxGeometry",{args:[.02,.15,.02]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7})]})]})},TZ=()=>c.jsxs("group",{position:[4,0,-1.5],children:[c.jsxs("mesh",{position:[0,1,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[1.2,2,.5]}),c.jsx("meshStandardMaterial",{color:6045747,roughness:.6})]}),[.4,.8,1.2,1.6].map((n,e)=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,n,.05],children:[c.jsx("boxGeometry",{args:[1.1,.04,.45]}),c.jsx("meshStandardMaterial",{color:7029286,roughness:.5})]}),[-.35,-.1,.15,.35].map((t,r)=>c.jsxs("mesh",{position:[t,n+.1,.05],children:[c.jsx("boxGeometry",{args:[.15,.14,.08]}),c.jsx("meshStandardMaterial",{color:[16729156,4500036,16755234,4491519,16737996,11197764][(e*4+r)%6],roughness:.5})]},`snack-${e}-${r}`))]},`shelf-${e}`))]}),kZ=()=>c.jsxs("group",{position:[-.5,.95,.2],children:[c.jsxs("mesh",{position:[0,.06,0],children:[c.jsx("cylinderGeometry",{args:[.22,.15,.12,16]}),c.jsx("meshStandardMaterial",{color:9136404,roughness:.7})]}),c.jsxs("mesh",{position:[-.06,.16,.02],children:[c.jsx("sphereGeometry",{args:[.06,8,8]}),c.jsx("meshStandardMaterial",{color:13378082,roughness:.6})]}),c.jsxs("mesh",{position:[.07,.15,-.04],children:[c.jsx("sphereGeometry",{args:[.065,8,8]}),c.jsx("meshStandardMaterial",{color:16747520,roughness:.7})]}),c.jsxs("mesh",{position:[0,.18,.08],children:[c.jsx("sphereGeometry",{args:[.055,8,8]}),c.jsx("meshStandardMaterial",{color:4504354,roughness:.6})]}),c.jsxs("mesh",{position:[.05,.2,0],rotation:[0,0,.4],children:[c.jsx("capsuleGeometry",{args:[.025,.1,4,8]}),c.jsx("meshStandardMaterial",{color:16769333,roughness:.5})]})]}),RZ=()=>c.jsxs("group",{position:[-1.3,.95,-.1],children:[c.jsxs("mesh",{position:[0,.04,0],rotation:[0,.1,0],children:[c.jsx("boxGeometry",{args:[.45,.06,.45]}),c.jsx("meshStandardMaterial",{color:13936490,roughness:.8})]}),c.jsxs("mesh",{position:[.02,.1,-.01],rotation:[0,-.15,0],children:[c.jsx("boxGeometry",{args:[.45,.06,.45]}),c.jsx("meshStandardMaterial",{color:13936490,roughness:.8})]}),c.jsxs("mesh",{position:[.02,.135,-.01],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[.1,16]}),c.jsx("meshStandardMaterial",{color:13382451,roughness:.6})]})]}),NZ=()=>c.jsxs("group",{position:[.4,.95,-.25],children:[c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("cylinderGeometry",{args:[.2,.2,.02,16]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.3})]}),[{x:-.06,z:.04,color:13928286},{x:.06,z:-.04,color:16738740},{x:0,z:.07,color:9127187}].map((n,e)=>c.jsxs("mesh",{position:[n.x,.06,n.z],rotation:[Math.PI/2,0,e*.5],children:[c.jsx("torusGeometry",{args:[.04,.02,8,12]}),c.jsx("meshStandardMaterial",{color:n.color,roughness:.6})]},`donut-${e}`))]}),IZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[-.1,.95,-.35],children:[c.jsxs("mesh",{position:[0,.04,0],children:[c.jsx("boxGeometry",{args:[.25,.06,.2]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.4})]}),c.jsxs("mesh",{position:[0,.14,0],children:[c.jsx("cylinderGeometry",{args:[.07,.08,.16,12]}),c.jsx("meshStandardMaterial",{color:3355443,transparent:!0,opacity:.6,roughness:.1})]}),c.jsxs("mesh",{position:[0,.1,0],children:[c.jsx("cylinderGeometry",{args:[.06,.07,.08,12]}),c.jsx("meshStandardMaterial",{color:4004866,roughness:.3})]}),c.jsxs("mesh",{position:[0,.3,-.06],children:[c.jsx("boxGeometry",{args:[.2,.25,.08]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.4})]}),c.jsxs("mesh",{position:[.08,.04,.11],children:[c.jsx("sphereGeometry",{args:[.012,8,8]}),c.jsx("meshStandardMaterial",{color:65280,emissive:n?65280:26112,emissiveIntensity:.5})]})]})},Pf=({position:n,rotation:e=0})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.2,.2,.06,16]}),c.jsx("meshStandardMaterial",{color:3355443,roughness:.7})]}),c.jsxs("mesh",{position:[0,.79,0],children:[c.jsx("cylinderGeometry",{args:[.19,.19,.03,16]}),c.jsx("meshStandardMaterial",{color:13386820,roughness:.8})]}),c.jsxs("mesh",{position:[0,.38,0],children:[c.jsx("cylinderGeometry",{args:[.03,.03,.72,8]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,.03,0],children:[c.jsx("torusGeometry",{args:[.18,.02,8,16]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,.3,0],children:[c.jsx("torusGeometry",{args:[.15,.015,8,16]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]})]}),PZ=()=>c.jsxs("group",{position:[-4,0,1],children:[c.jsxs("mesh",{position:[0,.4,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.45,.8,.4]}),c.jsx("meshStandardMaterial",{color:15658734,roughness:.3})]}),c.jsxs("mesh",{position:[0,.65,.18],children:[c.jsx("boxGeometry",{args:[.2,.15,.08]}),c.jsx("meshStandardMaterial",{color:14540253,roughness:.3})]}),c.jsxs("mesh",{position:[-.05,.65,.23],children:[c.jsx("cylinderGeometry",{args:[.015,.015,.03,8]}),c.jsx("meshStandardMaterial",{color:16724787,metalness:.5})]}),c.jsxs("mesh",{position:[.05,.65,.23],children:[c.jsx("cylinderGeometry",{args:[.015,.015,.03,8]}),c.jsx("meshStandardMaterial",{color:3355647,metalness:.5})]}),c.jsxs("mesh",{position:[0,1.1,0],children:[c.jsx("cylinderGeometry",{args:[.14,.14,.55,12]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.4,roughness:.1})]}),c.jsxs("mesh",{position:[0,1,0],children:[c.jsx("cylinderGeometry",{args:[.13,.13,.35,12]}),c.jsx("meshStandardMaterial",{color:4491468,transparent:!0,opacity:.3,roughness:.1})]}),c.jsxs("mesh",{position:[0,1.38,0],children:[c.jsx("cylinderGeometry",{args:[.05,.14,.04,12]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.5})]})]}),LZ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[10,5]}),c.jsx("meshStandardMaterial",{color:9419919,roughness:.6,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),[-4,-2,0,2,4].map(n=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[n,.025,0],children:[c.jsx("planeGeometry",{args:[.03,5]}),c.jsx("meshStandardMaterial",{color:8039034,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2})]},`tile-x-${n}`)),[-2,0,2].map(n=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.025,n],children:[c.jsx("planeGeometry",{args:[10,.03]}),c.jsx("meshStandardMaterial",{color:8039034,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2})]},`tile-z-${n}`))]}),a3=({position:n})=>{const{isNightMode:e}=Pt();return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{position:[0,.4,0],children:[c.jsx("cylinderGeometry",{args:[.008,.008,.8,6]}),c.jsx("meshStandardMaterial",{color:2236962})]}),c.jsxs("mesh",{position:[0,0,0],children:[c.jsx("cylinderGeometry",{args:[.08,.2,.15,16,1,!0]}),c.jsx("meshStandardMaterial",{color:2763306,roughness:.5,side:Tn})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:16777198,emissive:e?16768392:5587968,emissiveIntensity:e?1:.3})]}),e&&c.jsx("pointLight",{position:[0,-.1,0],color:16768392,intensity:.5,distance:5,decay:2})]})},jZ=()=>{const{x:n,z:e}=CZ.POSITION;return c.jsxs("group",{position:[n,0,e],rotation:[0,-Math.PI/2,0],children:[c.jsx(LZ,{}),c.jsx(MZ,{}),c.jsx(AZ,{}),c.jsx(TZ,{}),c.jsx(EZ,{}),c.jsx(IZ,{}),c.jsx(kZ,{}),c.jsx(RZ,{}),c.jsx(NZ,{}),c.jsx(PZ,{}),c.jsx(Pf,{position:[-1,0,1.2]}),c.jsx(Pf,{position:[0,0,1.2]}),c.jsx(Pf,{position:[1,0,1.2]}),c.jsx(Pf,{position:[-.5,0,-1.2],rotation:Math.PI}),c.jsx(Pf,{position:[.5,0,-1.2],rotation:Math.PI}),c.jsx(a3,{position:[-1,3.5,0]}),c.jsx(a3,{position:[1,3.5,0]}),c.jsx("group",{position:[0,3,-2.5],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[2.2,.4,.1]}),c.jsx("meshStandardMaterial",{color:9419919})]})})]})},l3=()=>{const{isNightMode:n}=Pt(),e=n?13421772:16777215,t=3355443,r=n?13404296:16758465;return c.jsxs("group",{scale:.6,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.5,16,16]}),c.jsx("meshStandardMaterial",{color:e,roughness:.8})]}),c.jsxs("mesh",{position:[-.2,.3,.3],rotation:[.3,.5,0],children:[c.jsx("circleGeometry",{args:[.15,8]}),c.jsx("meshStandardMaterial",{color:t,side:Tn,roughness:.9})]}),c.jsxs("mesh",{position:[.25,.2,.25],rotation:[.2,-.3,.1],children:[c.jsx("circleGeometry",{args:[.12,8]}),c.jsx("meshStandardMaterial",{color:t,side:Tn,roughness:.9})]}),c.jsx(c3,{position:[-.35,.4,0],rotation:[0,0,-.3]}),c.jsx(c3,{position:[.35,.4,0],rotation:[0,0,.3]}),c.jsx(u3,{position:[-.45,.2,.1],rotation:[0,.5,-.3]}),c.jsx(u3,{position:[.45,.2,.1],rotation:[0,-.5,.3]}),c.jsxs("mesh",{position:[0,-.15,.45],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.25,12,12]}),c.jsx("meshStandardMaterial",{color:r,roughness:.6})]}),c.jsxs("mesh",{position:[-.08,-.18,.68],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsxs("mesh",{position:[.08,-.18,.68],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsx(d3,{position:[-.18,.1,.4]}),c.jsx(d3,{position:[.18,.1,.4]})]})},c3=({position:n,rotation:e})=>{const{isNightMode:t}=Pt(),r=t?8947848:13935988;return c.jsxs("mesh",{position:n,rotation:e,castShadow:!0,children:[c.jsx("coneGeometry",{args:[.08,.3,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.5})]})},u3=({position:n,rotation:e})=>{const{isNightMode:t}=Pt(),r=t?13421772:16777215,s=t?13404296:16758465;return c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[.12,8,8,0,Math.PI]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,0,.02],scale:.7,children:[c.jsx("sphereGeometry",{args:[.1,8,8,0,Math.PI]}),c.jsx("meshStandardMaterial",{color:s,roughness:.8})]})]})},d3=({position:n})=>c.jsxs("group",{position:n,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[.08,12,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.2})]}),c.jsxs("mesh",{position:[0,0,.06],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.1})]}),c.jsxs("mesh",{position:[.02,.02,.08],children:[c.jsx("sphereGeometry",{args:[.015,6,6]}),c.jsx("meshStandardMaterial",{color:16777215,emissive:16777215,emissiveIntensity:.3})]})]}),BZ=()=>{const{isNightMode:n}=Pt(),e=n?9136404:12887118,t=n?4007959:6636321,r=n?6710886:8947848;return c.jsxs("group",{scale:.6,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.45,16,16]}),c.jsx("meshStandardMaterial",{color:e,roughness:.8})]}),c.jsxs("mesh",{position:[0,-.1,.5],rotation:[-.3,0,0],castShadow:!0,children:[c.jsx("capsuleGeometry",{args:[.2,.4,8,16]}),c.jsx("meshStandardMaterial",{color:e,roughness:.8})]}),c.jsxs("mesh",{position:[0,-.2,.85],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.18,12,12]}),c.jsx("meshStandardMaterial",{color:r,roughness:.6})]}),c.jsxs("mesh",{position:[-.06,-.22,.98],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:2236962})]}),c.jsxs("mesh",{position:[.06,-.22,.98],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:2236962})]}),c.jsx(DZ,{color:t}),c.jsx(h3,{position:[-.25,.45,0],rotation:[.3,.2,-.2]}),c.jsx(h3,{position:[.25,.45,0],rotation:[.3,-.2,.2]}),c.jsx(f3,{position:[-.25,.15,.3]}),c.jsx(f3,{position:[.25,.15,.3]}),c.jsxs("mesh",{position:[0,.2,.42],rotation:[.2,0,0],children:[c.jsx("planeGeometry",{args:[.1,.25]}),c.jsx("meshStandardMaterial",{color:16777215,side:Tn,roughness:.8})]})]})},DZ=({color:n})=>c.jsxs("group",{children:[[-.15,-.05,.05,.15].map((e,t)=>c.jsxs("mesh",{position:[0,.45-t*.05,e-.1],rotation:[.3-t*.1,0,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[.08+t*.02,.2,6]}),c.jsx("meshStandardMaterial",{color:n,roughness:.9})]},t)),c.jsxs("mesh",{position:[0,.2,-.4],rotation:[.8,0,0],children:[c.jsx("boxGeometry",{args:[.15,.4,.1]}),c.jsx("meshStandardMaterial",{color:n,roughness:.9})]})]}),h3=({position:n,rotation:e})=>{const{isNightMode:t}=Pt(),r=t?9136404:12887118,s=t?13408665:16764108;return c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("coneGeometry",{args:[.08,.25,6]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,.02,.03],scale:.6,children:[c.jsx("coneGeometry",{args:[.06,.18,6]}),c.jsx("meshStandardMaterial",{color:s,roughness:.8})]})]})},f3=({position:n})=>c.jsxs("group",{position:n,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[.07,12,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.2})]}),c.jsxs("mesh",{position:[0,0,.04],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:4863264,roughness:.3})]}),c.jsxs("mesh",{position:[0,0,.06],children:[c.jsx("sphereGeometry",{args:[.025,6,6]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.1})]}),c.jsxs("mesh",{position:[.02,.02,.07],children:[c.jsx("sphereGeometry",{args:[.012,6,6]}),c.jsx("meshStandardMaterial",{color:16777215,emissive:16777215,emissiveIntensity:.3})]})]}),OZ=({headRotation:n})=>{const e=N.useRef(null);vr(()=>{e.current&&n&&(e.current.rotation.x=Oa.lerp(e.current.rotation.x,n.x,.1),e.current.rotation.y=Oa.lerp(e.current.rotation.y,n.y,.1))});const t=15235612,r=1710618,s=16119280;return c.jsxs("group",{ref:e,position:[0,1.65,0],children:[c.jsxs("mesh",{position:[0,0,.05],scale:[.22,.2,.22],children:[c.jsx("sphereGeometry",{args:[1,16,12]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[-.12,-.02,.15],scale:[.1,.08,.08],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[.12,-.02,.15],scale:[.1,.08,.08],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.06,.2],scale:[.1,.08,.1],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.02,.28],children:[c.jsx("sphereGeometry",{args:[.035,12,12]}),c.jsx("meshStandardMaterial",{color:16737945,roughness:.5})]}),c.jsxs("group",{position:[-.14,.18,-.02],children:[c.jsxs("mesh",{rotation:[0,0,Math.PI/8],scale:[.06,.08,.03],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[.01,-.01,.015],rotation:[0,0,Math.PI/8],scale:[.035,.05,.02],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:16758465,roughness:.7})]})]}),c.jsxs("group",{position:[.14,.18,-.02],children:[c.jsxs("mesh",{rotation:[0,0,-Math.PI/8],scale:[.06,.08,.03],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[-.01,-.01,.015],rotation:[0,0,-Math.PI/8],scale:[.035,.05,.02],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:16758465,roughness:.7})]})]}),[-.06,0,.06].map((i,o)=>c.jsxs("mesh",{position:[i,.12,.12],rotation:[.3,0,0],scale:[.015,.04,.01],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:r,roughness:.9})]},o)),[1,2,3].map(i=>c.jsxs(Cn.Fragment,{children:[c.jsxs("mesh",{position:[-.18+i*.01,.02-i*.03,.08],rotation:[0,Math.PI/6,Math.PI/8],scale:[.01,.03,.01],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:r,roughness:.9})]}),c.jsxs("mesh",{position:[.18-i*.01,.02-i*.03,.08],rotation:[0,-Math.PI/6,-Math.PI/8],scale:[.01,.03,.01],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:r,roughness:.9})]})]},i)),c.jsxs("mesh",{position:[-.08,.04,.18],children:[c.jsx("sphereGeometry",{args:[.035,12,12]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[.08,.04,.18],children:[c.jsx("sphereGeometry",{args:[.035,12,12]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[-.08,.04,.21],children:[c.jsx("sphereGeometry",{args:[.018,8,8]}),c.jsx("meshStandardMaterial",{color:1710618})]}),c.jsxs("mesh",{position:[.08,.04,.21],children:[c.jsx("sphereGeometry",{args:[.018,8,8]}),c.jsx("meshStandardMaterial",{color:1710618})]}),[-1,1].map(i=>c.jsx(Cn.Fragment,{children:[0,1,2].map(o=>c.jsxs("mesh",{position:[i*(.08+o*.015),-.04-o*.015,.22],scale:[.01,.01,.01],children:[c.jsx("sphereGeometry",{args:[1,6,6]}),c.jsx("meshStandardMaterial",{color:1710618})]},o))},i))]})},FZ=({headRotation:n})=>{const e=N.useRef(null),t=N.useRef(null),r=N.useRef(null),s=N.useRef(0);vr(u=>{s.current=Math.sin(u.clock.elapsedTime*3)*.05,t.current&&(t.current.rotation.z=Math.PI/10+s.current),r.current&&(r.current.rotation.z=-Math.PI/10-s.current),e.current&&n&&(e.current.rotation.x=Oa.lerp(e.current.rotation.x,n.x,.1),e.current.rotation.y=Oa.lerp(e.current.rotation.y,n.y,.1))});const i=13943988,o=16758465,a=16751001,l=16777215;return c.jsxs("group",{ref:e,position:[0,1.65,0],children:[c.jsxs("mesh",{position:[0,0,.05],scale:[.2,.18,.2],children:[c.jsx("sphereGeometry",{args:[1,16,12]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[-.1,-.02,.12],scale:[.08,.07,.06],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[.1,-.02,.12],scale:[.08,.07,.06],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.04,.18],scale:[.08,.06,.08],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.01,.24],children:[c.jsx("sphereGeometry",{args:[.03,12,12]}),c.jsx("meshStandardMaterial",{color:a,roughness:.4})]}),c.jsxs("group",{ref:t,position:[-.08,.2,0],children:[c.jsxs("mesh",{scale:[.04,.18,.025],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,0,.015],scale:[.025,.14,.01],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:o,roughness:.7})]})]}),c.jsxs("group",{ref:r,position:[.08,.2,0],children:[c.jsxs("mesh",{scale:[.04,.18,.025],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,0,.015],scale:[.025,.14,.01],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:o,roughness:.7})]})]}),c.jsxs("mesh",{position:[-.07,.04,.16],children:[c.jsx("sphereGeometry",{args:[.04,12,12]}),c.jsx("meshStandardMaterial",{color:1710618})]}),c.jsxs("mesh",{position:[.07,.04,.16],children:[c.jsx("sphereGeometry",{args:[.04,12,12]}),c.jsx("meshStandardMaterial",{color:1710618})]}),c.jsxs("mesh",{position:[-.06,.05,.19],children:[c.jsx("sphereGeometry",{args:[.012,8,8]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[.08,.05,.19],children:[c.jsx("sphereGeometry",{args:[.012,8,8]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[-.015,-.1,.2],scale:[.02,.03,.015],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:l,roughness:.3})]}),c.jsxs("mesh",{position:[.015,-.1,.2],scale:[.02,.03,.015],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:l,roughness:.3})]}),[-1,1].map(u=>c.jsx(Cn.Fragment,{children:[-1,0,1].map(d=>c.jsxs("mesh",{position:[u*.12,-.03+d*.02,.18],rotation:[0,0,u*Math.PI/12+d*.1],scale:[.08,.003,.003],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:8947848,roughness:.5})]},d))},u))]})},Wp=({text:n,yOffset:e=3,maxChars:t=50,variant:r="work"})=>{const s=r==="conversation",i=s?16777215:1710638,o=s?13421772:4886745,a=s?"#222222":"#ffffff",l=s?4886745:4906624,u=N.useMemo(()=>{if(!n)return"";const h=n.trim().replace(/\s+/g," ");return h.length>t?h.substring(0,t-3)+"...":h},[n,t]),d=N.useMemo(()=>{const b=u.length*.12;return{width:Math.min(Math.max(b+.6,2),5),height:.7}},[u]);return n?c.jsx(r2,{follow:!0,lockX:!1,lockY:!1,lockZ:!1,children:c.jsxs("group",{position:[0,e,0],children:[c.jsx(Ov,{args:[d.width,d.height,.08],radius:.12,smoothness:4,position:[0,0,0],children:c.jsx("meshBasicMaterial",{color:i,transparent:!0,opacity:.92})}),c.jsx(Ov,{args:[d.width+.04,d.height+.04,.06],radius:.14,smoothness:4,position:[0,0,-.02],children:c.jsx("meshBasicMaterial",{color:o,transparent:!0,opacity:.3})}),c.jsxs("mesh",{position:[0,-d.height/2-.15,0],children:[c.jsx("bufferGeometry",{children:c.jsx("float32BufferAttribute",{attach:"attributes-position",args:[new Float32Array([-.15,.18,0,.15,.18,0,0,-.08,0]),3]})}),c.jsx("meshBasicMaterial",{color:i,transparent:!0,opacity:.92,side:Tn})]}),c.jsxs("mesh",{position:[0,-d.height/2-.15,-.02],children:[c.jsx("bufferGeometry",{children:c.jsx("float32BufferAttribute",{attach:"attributes-position",args:[new Float32Array([-.18,.2,0,.18,.2,0,0,-.12,0]),3]})}),c.jsx("meshBasicMaterial",{color:o,transparent:!0,opacity:.3,side:Tn})]}),c.jsxs("mesh",{position:[-d.width/2+.25,0,.05],children:[c.jsx("circleGeometry",{args:[.08,16]}),c.jsx("meshBasicMaterial",{color:l})]}),c.jsx(ap,{position:[.1,0,.05],fontSize:.18,color:a,anchorX:"center",anchorY:"middle",maxWidth:d.width-.8,outlineWidth:0,children:u})]})}):null},gD=({xOffset:n=.5,yOffset:e=1.8})=>{const t=N.useRef(null),r=N.useRef(null),s=N.useRef(null),i=N.useRef(null);return vr(o=>{const a=o.clock.elapsedTime;if(t.current&&(t.current.position.y=e+Math.sin(a*.8)*.2,t.current.rotation.y=a*.5),r.current){const l=a*.5%1;r.current.position.y=l*.6,r.current.position.x=Math.sin(l*Math.PI)*.1;const u=r.current.children[0];u!=null&&u.material&&(u.material.opacity=1-l*.5)}if(s.current){const l=(a*.5+.33)%1;s.current.position.y=.3+l*.6,s.current.position.x=.15+Math.sin(l*Math.PI)*.1;const u=s.current.children[0];u!=null&&u.material&&(u.material.opacity=1-l*.5)}if(i.current){const l=(a*.5+.66)%1;i.current.position.y=.6+l*.6,i.current.position.x=.3+Math.sin(l*Math.PI)*.1;const u=i.current.children[0];u!=null&&u.material&&(u.material.opacity=1-l*.5)}}),c.jsx(r2,{follow:!0,children:c.jsxs("group",{ref:t,position:[n,e,0],children:[c.jsx("group",{ref:r,position:[0,0,0],children:c.jsx(ap,{fontSize:.2,color:"#4466aa",anchorX:"center",anchorY:"middle","material-transparent":!0,"material-opacity":1,children:"z"})}),c.jsx("group",{ref:s,position:[.15,.3,0],children:c.jsx(ap,{fontSize:.25,color:"#4466aa",anchorX:"center",anchorY:"middle","material-transparent":!0,"material-opacity":1,children:"Z"})}),c.jsx("group",{ref:i,position:[.3,.6,0],children:c.jsx(ap,{fontSize:.3,color:"#4466aa",anchorX:"center",anchorY:"middle","material-transparent":!0,"material-opacity":1,children:"Z"})})]})})},cl=16777215,ul=14540253,o2=({thoughts:n,yOffset:e=3.5,changeInterval:t=5e3})=>{const r=N.useRef(null),[s,i]=N.useState(()=>Math.floor(Math.random()*n.length));N.useEffect(()=>{if(n.length<=1)return;const d=setInterval(()=>{i(h=>{let f=Math.floor(Math.random()*n.length);for(;f===h&&n.length>1;)f=Math.floor(Math.random()*n.length);return f})},t+Math.random()*2e3);return()=>clearInterval(d)},[n.length,t]);const o=n[s]||"",a=N.useMemo(()=>{const y=o.length*.11;return{width:Math.min(Math.max(y+.6,2),4.5),height:.6}},[o]);if(vr(d=>{if(r.current){const h=d.clock.elapsedTime;r.current.position.y=e+Math.sin(h*1.2)*.05}}),n.length===0)return null;const l=a.width/2,u=a.height/2;return c.jsx(r2,{follow:!0,lockX:!1,lockY:!1,lockZ:!1,children:c.jsxs("group",{ref:r,position:[0,e,0],children:[c.jsx(Ov,{args:[a.width+.08,a.height+.08,.04],radius:u+.02,smoothness:4,position:[0,0,-.03],children:c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.5})}),c.jsx(Ov,{args:[a.width,a.height,.06],radius:u,smoothness:4,children:c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})}),c.jsxs("mesh",{position:[-l*.45,u*.55,-.01],children:[c.jsx("circleGeometry",{args:[.28,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[-l*.1,u*.7,-.01],children:[c.jsx("circleGeometry",{args:[.32,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[l*.2,u*.75,-.01],children:[c.jsx("circleGeometry",{args:[.35,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[l*.5,u*.5,-.01],children:[c.jsx("circleGeometry",{args:[.25,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[-l*.45,u*.55,-.04],children:[c.jsx("circleGeometry",{args:[.32,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-l*.1,u*.7,-.04],children:[c.jsx("circleGeometry",{args:[.36,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[l*.2,u*.75,-.04],children:[c.jsx("circleGeometry",{args:[.39,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[l*.5,u*.5,-.04],children:[c.jsx("circleGeometry",{args:[.29,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-.1,-u-.22,0],children:[c.jsx("circleGeometry",{args:[.12,16]}),c.jsx("meshBasicMaterial",{color:cl})]}),c.jsxs("mesh",{position:[-.28,-u-.48,0],children:[c.jsx("circleGeometry",{args:[.08,16]}),c.jsx("meshBasicMaterial",{color:cl})]}),c.jsxs("mesh",{position:[-.4,-u-.66,0],children:[c.jsx("circleGeometry",{args:[.055,12]}),c.jsx("meshBasicMaterial",{color:cl})]}),c.jsxs("mesh",{position:[-.1,-u-.22,-.02],children:[c.jsx("circleGeometry",{args:[.15,16]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-.28,-u-.48,-.02],children:[c.jsx("circleGeometry",{args:[.11,16]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-.4,-u-.66,-.02],children:[c.jsx("circleGeometry",{args:[.075,12]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsx(ap,{position:[0,0,.05],fontSize:.16,color:"#222222",anchorX:"center",anchorY:"middle",maxWidth:a.width-.4,outlineWidth:0,children:o})]})})},p3={wander:["Taking a short break","Stretching my legs...","Nice day for a walk","Just wandering around","Looking around the office","Enjoying the break"],couch:["Time to relax...","The couch looks comfy","Need a quick rest","Recharging batteries...","A short nap sounds nice","So cozy..."],stage:["Time to perform!","Let me show my moves","My turn on stage!","Dance time!","Here goes nothing!","Watch this!"],break_room:["Coffee break!","Need some caffeine","Grabbing a coffee","Time for a snack","Chatting over coffee","This coffee is good"],poker_table:["All in!","Read my poker face","Feeling lucky!","Good hand...","I call!","Bluffing time!"],kitchen:["Mmm, pizza!","Grabbing a snack","Anyone want a donut?","I love fruit!","Making some coffee","Snack time!"],pickleball:["Pickleball time!","Nice serve!","Dink shot!","Game on!","Love the outdoors","Kitchen line rally!"],golf:["Putting practice!","Read the green...","Fore!","Birdie putt!","Nice chip!","Almost a hole-in-one!"],sit_outdoor:["Fresh air is nice","Enjoying the sunshine","Peaceful out here","Good to be outside","Nice breeze today","Taking in the view"]},UZ={wandering:["One more thing...","Innovation never sleeps","Think different","Stay hungry, stay foolish","Simplicity is genius"],checking_agent:["How's the project?","Show me the progress","Let's ship it!","Is it insanely great?","Focus on quality"],watching_stage:["Great performance!","Impressive work!","Bravo!","Now that is innovation!"],resting:["Creative thinking...","Recharging ideas","Next big thing...","Connecting the dots"],visiting_kitchen:["Need some fuel...","Coffee powers innovation","Mmm, smells good!","A snack break","Grabbing an apple"],walking_to_target:["On my way...","Places to be","Let's go check","Heading over"]},HZ={wandering:["Making the rounds","AI-first approach","Cloud strategy...","Organizing the world","Open source matters"],talking_to_agent:["Let's discuss this","How can I help?","Collaboration time","Great teamwork!","Keep it up!"],presenting:["Here's our vision","AI for everyone","Let me present this","Exciting updates!"],walking_circle:["Deep thinking...","Strategic planning","Processing ideas","What if we..."],visiting_kitchen:["Time for chai!","Grabbing a coffee","Snack break!","Need some energy","Mmm, looks good!"],walking_to_target:["On my way...","Let's see what's next","Heading over","Time to check in"]},zZ={wandering:["TSLA up 5% today!","Tesla stock is mooning!","Starship launch soon...","SpaceX landing failed...","Ugh, rapid unscheduled","Mars colony by 2030!","Need more Starlinks","Full self driving soon","The Cybertruck sells!","X is the everything app","First principles only","Boring tunnel progress?","Neuralink update...","TSLA to the moon!","SpaceX booster caught!","Stock looking good today"],talking_to_agent:["Ship it yesterday!","Is this 10x better?","Move faster, come on!","This needs more urgency","First principles, think!","Are we on Mars yet?","Tesla needs this done","SpaceX pace, people!"],visiting_kitchen:["Quick Diet Coke break","No time, grabbing coffee","Back to the factory","Fuel up, ship more"],watching_stage:["This could help Tesla","SpaceX could use this!","Interesting tech demo","Think bigger though!","Not disruptive enough"]},GZ={wandering:["Is this VR or real?","Where are my glasses?","The metaverse is real!","Llama 4 training soon","Meta Quest is the future","Can't see without headset","VR world looks better","Reality is overrated","Llama beats GPT now!","Open source AI wins!","Meta AI is shipping!","Need better VR lenses","The glasses are blurry","Metaverse rendering...","Is this AR or VR?","Horizon Worlds update","Llama needs more GPUs","Zuck mode: activated"],talking_to_agent:["Try the Quest headset!","Have you used Llama?","VR meeting instead?","What's the Llama score?","Build for the metaverse","Open source this!","Meta AI can help here","Put this in VR!"],visiting_kitchen:["Sweet Baby Rays time!","BBQ sauce on everything","Smoking some meats","Refueling for VR"],watching_stage:["This needs VR mode!","Put this in metaverse","Llama could do this","Ship it on Quest!","Great engagement!"]},WZ={wandering:["Everyone buys my GPUs!","NVDA up again today!","The more you buy...","...the more you save!","CUDA runs the world!","H100s sold out again!","Blackwell is crushing it","AI needs more GPUs!","Stock at all time high!","Every company needs us","Leather jacket: on","GPU shortage = demand!","Training runs need me","Inference at scale baby!","They all use my chips","NVIDIA is the platform","Data centers love us!","Cloud needs more GPUs!"],talking_to_agent:["Using CUDA, right?","Need more H100s?","GPU utilization good?","Buy more GPUs!","NVIDIA powers this!","Tensor cores maxed?","More compute = better","Accelerate everything!"],presenting:["One more GPU reveal!","NVIDIA is the future!","AI runs on our chips","Blackwell architecture!","The roadmap is amazing"],visiting_kitchen:["Even the oven has GPUs","Quick fuel, more GPUs","Cooking with CUDA cores","Kitchen break, stock up"],watching_stage:["Bet that runs on NVIDIA","Needs more GPU power!","Great demo, our chips?","Standing ovation!","I love this industry!"]},VZ={wandering:["Wow, look at Crewly go!","I created all of this...","What a beautiful creation","My vision, brought to life","Crewly is my masterpiece","This factory is incredible","Look at what we built!","Every agent, every detail...","From idea to reality","This is beyond what I imagined","Crewly changes everything","I can't believe how far we've come","This is just the beginning","What a great company"],talking_to_agent:["I made you, you know","How's my creation doing?","You make me proud!","Keep building great things","This is what I envisioned","You're the heart of Crewly","Amazing work, keep going!","Built with love, running with purpose"],visiting_kitchen:["Even creators need coffee","Quick break, then more building","Fueling the vision","Grabbing a bite"],watching_stage:["Look at them perform!","Crewly talent on display","This is what it's all about","Incredible team!"],playing_golf:["Fore!","Nice putt!","Even founders need a break","Golf clears the mind","Back to building after this","Love this putting green","Great day for golf"]};function m3(n,e){let t=0;const r=n+e.toString();for(let s=0;s<r.length;s++){const i=r.charCodeAt(s);t=(t<<5)-t+i,t=t&t}return Math.abs(t%1e3)/1e3}const g3={coffeeBreak:{min:4,max:8},idle:{min:6,max:12}},x3=["Walking","Running","Jumping"],XZ=["Dance","Salsa dancing"],KZ=["Sitting","Idle","Breathing idle"];function JZ(n,e,t){const r=N.useRef({currentAnim:"",lastChangeTime:0,currentIdleIndex:0}),s=N.useRef(null),i=N.useCallback((h,f)=>{if(h.length===0)return t.working;if(h.length===1)return h[0];const g=f?h.filter(b=>b!==f):h;if(g.length===0)return h[0];const y=Math.floor(m3(n.id,Date.now())*g.length);return g[y]},[n.id,t.working]),o=N.useCallback((h,f=.5,g=.5)=>{var b,p,m;if(!e)return;const y=r.current;if(y.currentAnim!==h)if(y.currentAnim&&e[y.currentAnim]&&((b=e[y.currentAnim])==null||b.fadeOut(g)),e[h])(p=e[h])==null||p.reset().fadeIn(f).play(),y.currentAnim=h,y.lastChangeTime=Date.now();else{const x=Object.keys(e)[0];x&&e[x]&&((m=e[x])==null||m.reset().fadeIn(f).play(),y.currentAnim=x,y.lastChangeTime=Date.now())}},[e]),a=N.useCallback((h,f)=>{s.current&&(clearTimeout(s.current),s.current=null);const g=f.min+m3(n.id,Date.now())*(f.max-f.min);s.current=setTimeout(()=>{const y=r.current,b=i(h,y.currentAnim);o(b,.8,.8),a(h,f)},g*1e3)},[n.id,i,o]);N.useEffect(()=>{if(!e||Object.keys(e).length===0)return;const h=n.status==="active"&&n.cpuPercent>10,f=n.status==="active"&&n.cpuPercent<=10,g=n.status==="idle";if(s.current&&(clearTimeout(s.current),s.current=null),h)o(t.working);else if(f){const y=i(t.coffeeBreak);o(y),a(t.coffeeBreak,g3.coffeeBreak)}else if(g){const y=i(t.idle);o(y),a(t.idle,g3.idle)}return()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,n.status,n.cpuPercent,t,o,i,a]);const l=r.current.currentAnim,u=x3.includes(l);let d="other";return x3.includes(l)?d="walking":XZ.includes(l)?d="dancing":KZ.includes(l)&&(d="resting"),{currentAnimation:l,isWalking:u,activity:d}}const e_={COW:{working:"Typing",coffeeBreak:["Idle","Walking","Breathing idle"],idle:["Sitting","Idle","Walking","Breathing idle"]},HORSE:{working:"Typing",coffeeBreak:["Breathing idle","Walking","Idle"],idle:["Sitting","Breathing idle","Walking","Idle"]},TIGER:{working:"Typing",coffeeBreak:["Breathing idle","Running","Walking"],idle:["Sitting","Breathing idle","Walking","Running"]},RABBIT:{working:"Pilot flips switches",coffeeBreak:["Sitting","Walking","Jumping"],idle:["Sitting","Breathing idle","Walking","Jumping"]}};function a2(n){const{hoveredEntityId:e,selectedEntityId:t,setHoveredEntity:r,selectEntity:s}=Pt(),i=e===n,o=t===n,a=N.useCallback(d=>{d.stopPropagation(),r(n),document.body.style.cursor="pointer"},[n,r]),l=N.useCallback(()=>{r(null),document.body.style.cursor="default"},[r]),u=N.useCallback(d=>{d.stopPropagation(),s(n)},[n,s]);return{isHovered:i,isSelected:o,handlePointerOver:a,handlePointerOut:l,handleClick:u}}function qZ(n){const e=new Map,t=new Map,r=n.clone();return xD(n,r,function(s,i){e.set(i,s),t.set(s,i)}),r.traverse(function(s){if(!s.isSkinnedMesh)return;const i=s,o=e.get(s),a=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=a.map(function(l){return t.get(l)}),i.bind(i.skeleton,i.bindMatrix)}),r}function xD(n,e,t){t(n,e);for(let r=0;r<n.children.length;r++)xD(n.children[r],e.children[r],t)}function l2(n){let e;try{e=qZ(n)}catch(r){console.warn("SkeletonUtils.clone failed, using basic clone:",r),e=n.clone(!0)}const t=r=>{if(!r||typeof r.clone!="function")return console.warn("Material without clone method encountered, using fallback"),new An({color:8947848,metalness:0,roughness:.7});try{const s=r.clone();if(s.isMeshStandardMaterial){const i=s;i.metalnessMap=null,i.roughnessMap=null,i.metalness=0,i.roughness=.7,i.needsUpdate=!0}return s}catch(s){return console.warn("Material clone failed, using fallback:",s),new An({color:8947848,metalness:0,roughness:.7})}};return e.traverse(r=>{r instanceof kn&&r.material&&(Array.isArray(r.material)?r.material=r.material.map(t):r.material=t(r.material))}),e}function c2(n){return n.map(e=>{const t=e.tracks.filter(r=>!(r.name.includes("Hips")&&r.name.endsWith(".position")));return new Wl(e.name,e.duration,t,e.blendMode)})}function u2(n){n.traverse(e=>{var t;e instanceof kn&&((t=e.geometry)==null||t.dispose(),Array.isArray(e.material)?e.material.forEach(r=>r.dispose()):e.material&&e.material.dispose())})}function $Z(n){for(;n>Math.PI;)n-=Math.PI*2;for(;n<-Math.PI;)n+=Math.PI*2;return n}function Na(n,e,t,r=3){const s=$Z(e-n.rotation.y);n.rotation.y+=s*Math.min(1,t*r)}function d2(n,e,t=4491519){return n?{color:16755200,opacity:1,emissive:16755200,emissiveIntensity:.8}:e?{color:6737151,opacity:.9,emissive:6737151,emissiveIntensity:.5}:{color:t,opacity:.6,emissive:0,emissiveIntensity:0}}const YZ={kitchen:15,couch:12,break_room:12,poker_table:12,stage:8,watch_stage:10,wander:15,pickleball:8,golf:8,sit_outdoor:8},QZ={kitchen:15,couch:10,break_room:5,poker_table:5,stage:0,watch_stage:12,wander:15,check_agent:28,pickleball:5,golf:5,sit_outdoor:5},ZZ={kitchen:15,couch:5,break_room:5,poker_table:5,stage:0,watch_stage:8,wander:15,check_agent:22,present:10,walk_circle:5,pickleball:5,golf:5,sit_outdoor:5},eee={kitchen:8,couch:5,break_room:5,poker_table:8,stage:0,watch_stage:10,wander:18,check_agent:18,pickleball:10,golf:8,sit_outdoor:10},tee={kitchen:10,couch:5,break_room:8,poker_table:5,stage:0,watch_stage:10,wander:15,check_agent:20,pickleball:8,golf:12,sit_outdoor:8},nee={kitchen:12,couch:8,break_room:8,poker_table:5,stage:0,watch_stage:12,wander:15,check_agent:25,present:8,pickleball:3,golf:3,sit_outdoor:5},ree={kitchen:10,couch:5,break_room:5,poker_table:5,stage:0,watch_stage:8,wander:12,check_agent:15,pickleball:10,golf:18,sit_outdoor:12},see={kitchen:18,couch:5,break_room:5,poker_table:5,stage:0,watch_stage:8,wander:45,pickleball:5,golf:5,sit_outdoor:5},iee={go_to_workstation:[5,10],go_to_kitchen:[6,14],go_to_couch:[10,20],go_to_break_room:[8,15],go_to_poker_table:[8,15],go_to_stage:[15,30],watch_stage:[10,20],wander:[3,8],check_agent:[3,7],present:[8,13],walk_circle:[10,15],go_to_pickleball:[10,20],go_to_golf:[10,20],sit_outdoor:[8,18]},vD={kitchen:"go_to_kitchen",couch:"go_to_couch",break_room:"go_to_break_room",poker_table:"go_to_poker_table",stage:"go_to_stage",watch_stage:"watch_stage",wander:"wander",workstation:"go_to_workstation",check_agent:"check_agent",present:"present",walk_circle:"walk_circle",pickleball:"go_to_pickleball",golf:"go_to_golf",sit_outdoor:"sit_outdoor"},yD={wander:"wander",go_to_couch:"couch",go_to_stage:"stage",go_to_break_room:"break_room",go_to_poker_table:"poker_table",go_to_kitchen:"kitchen",watch_stage:"wander",go_to_workstation:"wander",go_to_pickleball:"pickleball",go_to_golf:"golf",sit_outdoor:"sit_outdoor",check_agent:"wander",present:"wander",walk_circle:"wander"},h2=new Set(["go_to_pickleball","go_to_golf","sit_outdoor"]),oee={couch:2,break_room:4,poker_table:4,kitchen:5};function aee(n){var r;const e=n.reduce((s,[,i])=>s+i,0);if(e<=0)return null;let t=Math.random()*e;for(const[s,i]of n)if(t-=i,t<=0)return s;return((r=n[n.length-1])==null?void 0:r[0])??null}function lee(n,e,t){const r=[],s=Object.keys(n);for(const i of s){const o=n[i];if(o===void 0||o<=0)continue;const a=vD[i];a&&a!==e&&(a==="go_to_stage"&&t.stageOccupied||a==="go_to_couch"&&N0("couch",t)||a==="go_to_break_room"&&N0("break_room",t)||a==="go_to_poker_table"&&N0("poker_table",t)||a==="go_to_kitchen"&&N0("kitchen",t)||r.push([i,o]))}return r}function N0(n,e){if(!e.seatOccupancy)return!1;const t=e.seatOccupancy[n]??0,r=oee[n]??0;return t>=r}function Zc(n){const e=iee[n];return e[0]+Math.random()*(e[1]-e[0])}function cee(n,e={}){const[t,r]=e.stepCount??[2,5],s=t+Math.floor(Math.random()*(r-t+1)),i=[];let o=null;for(let a=0;a<s;a++){const l=lee(n,o,e);if(l.length===0){i.push({type:"wander",duration:Zc("wander")}),o="wander";continue}const u=aee(l);if(!u){i.push({type:"wander",duration:Zc("wander")}),o="wander";continue}const d=vD[u];d&&(i.push({type:d,duration:Zc(d)}),o=d)}return i.length===0&&i.push({type:"wander",duration:Zc("wander")}),{steps:i,currentStepIndex:0,paused:!1,arrivalTime:null}}function f2(n,e){const t=N.useRef(null),r=N.useRef(null),s=N.useRef(e);s.current=e;const[i,o]=N.useState(null),a=N.useRef(null),l=N.useCallback(x=>{x!==a.current&&(a.current=x,o(x))},[]),u=N.useCallback(x=>{const v=cee(s.current,x);t.current=v,v.steps.length>0&&l(v.steps[0].type)},[l]),d=N.useCallback(()=>{const x=t.current;return!x||x.paused||x.currentStepIndex>=x.steps.length?null:x.steps[x.currentStepIndex]},[]),h=N.useCallback(()=>{const x=t.current;if(!x){u();return}x.currentStepIndex++,x.arrivalTime=null,x.currentStepIndex>=x.steps.length?u():l(x.steps[x.currentStepIndex].type)},[u,l]),f=N.useCallback(()=>{t.current&&(t.current.paused=!0)},[]),g=N.useCallback(()=>{t.current&&(t.current.paused=!1,t.current.arrivalTime=null)},[]),y=N.useCallback(()=>{t.current&&!r.current&&(r.current={...t.current}),t.current={steps:[{type:"watch_stage",duration:1/0}],currentStepIndex:0,paused:!1,arrivalTime:null},l("watch_stage")},[l]),b=N.useCallback(()=>{var x;return((x=t.current)==null?void 0:x.paused)??!1},[]),p=N.useCallback(x=>{t.current&&(t.current.arrivalTime=x)},[]),m=N.useCallback(x=>{const v=t.current;if(!v||v.arrivalTime===null)return!1;const w=v.steps[v.currentStepIndex];return w?x-v.arrivalTime>=w.duration:!1},[]);return{planRef:t,getCurrentStep:d,advanceStep:h,newPlan:u,pause:f,resume:g,interruptForStage:y,isPaused:b,displayStepType:i,markArrival:p,isDurationElapsed:m,savedPlanRef:r}}const Lc={radiusX:12,minZ:-3,maxZ:8};function I0(n,e,t,r=.3,s=.3){if(!n||t.currentAnim===e)return;let i=n[e];!i&&e!=="Idle"&&(i=n.Idle??n["Breathing idle"]??null),i&&(Object.values(n).forEach(o=>o==null?void 0:o.fadeOut(r)),i.reset().fadeIn(s).play(),t.currentAnim=e)}const JS=nt.MOVEMENT.COUCH_SEAT_HEIGHT,uee=2,v3=2;function Hw(n,e,t,r,s){for(const i of s){if(Math.abs(i.x-t)<.1&&Math.abs(i.z-r)<.1)continue;const o=n-i.x,a=e-i.z;if(o*o+a*a<v3*v3)return!0}return!1}function y3(n,e,t,r,s,i,o){if(!Hw(n,e,s,i,o))return{x:n,z:e};const a=n-t,l=e-r,u=Math.atan2(l,a),d=[{x:t+Math.cos(u+Math.PI/2)*2,z:r+Math.sin(u+Math.PI/2)*2},{x:t+Math.cos(u-Math.PI/2)*2,z:r+Math.sin(u-Math.PI/2)*2},{x:t-a*.5,z:r-l*.5}];for(const h of d)if(!Hw(h.x,h.z,s,i,o))return h;return{x:t,z:r}}const dee=yD,t_=({agent:n,config:e})=>{var ue;const t=N.useRef(null),r=N.useRef({currentPos:{x:0,z:0},initialized:!1,wasWorking:!1,currentAnim:"",claimedSeatArea:null,arrived:!1}),s=N.useRef(!1),i=On(e.modelPath),o=N.useMemo(()=>l2(i.scene),[i.scene]),a=N.useMemo(()=>c2(i.animations),[i.animations]),{actions:l,mixer:u}=Zy(a,o);JZ(n,l,e.animationConfig);const{agents:d,zones:h,npcPositions:f,updateAgentPosition:g,entityConversations:y,claimSeat:b,releaseSeat:p,getSeatOccupancy:m,claimStage:x,releaseStage:v,isStageOccupied:w,stagePerformerRef:C,consumeEntityCommand:M,entityPositionMapRef:T}=Pt(),{isHovered:A,isSelected:E,handlePointerOver:R,handlePointerOut:j,handleClick:L}=a2(n.id),D=f2(n.id,YZ),z=nt.STAGE.POSITION,q=nt.LOUNGE.POSITION,X=nt.LOUNGE.COUCH_POSITIONS,K=nt.BREAK_ROOM.POSITION,I=nt.POKER_TABLE.POSITION,B=nt.KITCHEN.POSITION,F=nt.PICKLEBALL.POSITION,O=nt.GOLF.POSITION,W=nt.OUTDOOR_BENCH.POSITIONS,J=N.useMemo(()=>h.get(n.projectName),[h,n.projectName]),$=N.useMemo(()=>J?J.workstations[n.workstationIndex]:null,[J,n.workstationIndex]),ie=N.useMemo(()=>{const ee=[];return h.forEach(pe=>{pe.workstations.forEach(Z=>{ee.push({x:Z.position.x,z:Z.position.z})})}),ee},[h]),oe=d2(E,A,4491519);N.useEffect(()=>()=>{u2(o);const ee=r.current;ee.claimedSeatArea&&p(ee.claimedSeatArea,n.id),v(n.id)},[o,n.id,p,v]);const U=(ee,pe)=>{if(!$)return null;const Z=$.position.x,be=$.position.z;switch(ee.type){case"go_to_workstation":return{x:$.position.x,z:$.position.z+nt.AGENT.WORKSTATION_OFFSET,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Math.PI};case"go_to_stage":return x(n.id)?{x:z.x,z:z.z,arrivalY:nt.STAGE.HEIGHT,arrivalAnim:e.danceAnimation,arrivalRot:-Math.PI/2}:null;case"go_to_couch":{const re=b("couch",n.id);if(re<0||!X[re])return null;pe.claimedSeatArea="couch";const ce=X[re];return{x:q.x+ce.x,z:q.z+ce.z,arrivalY:JS,arrivalAnim:e.sitAnimation,arrivalRot:ce.rotation}}case"go_to_break_room":{const re=b("break_room",n.id);if(re<0)return null;pe.claimedSeatArea="break_room";const ce=re*Math.PI/2,le=K.x+Math.sin(ce)*1.3,fe=K.z+Math.cos(ce)*1.3,Q=Math.atan2(K.x-le,K.z-fe);return{x:le,z:fe,arrivalY:JS,arrivalAnim:e.sitAnimation,arrivalRot:Q}}case"go_to_poker_table":{const re=b("poker_table",n.id);if(re<0)return null;pe.claimedSeatArea="poker_table";const ce=re*Math.PI/2,le=I.x+Math.sin(ce)*1.8,fe=I.z+Math.cos(ce)*1.8,Q=Math.atan2(I.x-le,I.z-fe);return{x:le,z:fe,arrivalY:JS,arrivalAnim:e.sitAnimation,arrivalRot:Q}}case"go_to_kitchen":{const re=b("kitchen",n.id);if(re<0)return null;pe.claimedSeatArea="kitchen";const ce=nt.KITCHEN.SEAT_POSITIONS,le=ce[re%ce.length];return{x:B.x+le.x,z:B.z+le.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:le.rotation}}case"watch_stage":{const re=nt.STAGE.AUDIENCE_POSITIONS,ce=re[Math.floor(Math.random()*re.length)];return{x:ce.x,z:ce.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Math.PI/2}}case"go_to_pickleball":{const re=F.x+(Math.random()-.5)*6,ce=F.z+(Math.random()-.5)*8;return{x:re,z:ce,arrivalY:0,arrivalAnim:"Breathing idle"}}case"go_to_golf":{const re=O.x+(Math.random()-.5)*6,ce=O.z+(Math.random()-.5)*6;return{x:re,z:ce,arrivalY:0,arrivalAnim:"Breathing idle"}}case"sit_outdoor":{const re=W[Math.floor(Math.random()*W.length)];return{x:re.x,z:re.z,arrivalY:0,arrivalAnim:e.sitAnimation,arrivalRot:re.rotation}}case"wander":default:{const re=e.wanderRadiusX??Lc.radiusX,ce=$.position.z+(e.wanderMinZ??Lc.minZ),le=$.position.z+(e.wanderMaxZ??Lc.maxZ);for(let fe=0;fe<10;fe++){const Q=$.position.x+(Math.random()-.5)*re*2,Te=ce+Math.random()*(le-ce),we=y3(Q,Te,pe.currentPos.x,pe.currentPos.z,Z,be,ie);if(pD(we.x,we.z,Fv))return{x:we.x,z:we.z,arrivalY:0,arrivalAnim:"Breathing idle"}}return{x:Z,z:$.position.z+(e.wanderMinZ??Lc.minZ),arrivalY:0,arrivalAnim:"Breathing idle"}}}};vr((ee,pe)=>{var Te,we;if(!t.current||!$)return;u==null||u.update(pe);const Z=r.current,be=n.status==="active",re=n.status==="idle",ce=ee.clock.elapsedTime;if(A&&!E){I0(l,"Breathing idle",Z,.3,.3),g(n.id,t.current.position);return}const le=M(n.id);let fe=!1;le&&(Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),v(n.id),D.planRef.current={steps:[{type:le.stepType,duration:Zc(le.stepType)}],currentStepIndex:0,paused:!1,arrivalTime:null,commanded:!0},Z.arrived=!1,Z.wasWorking=!1,s.current=!1,fe=!0);const Q=((Te=D.planRef.current)==null?void 0:Te.commanded)??!1;if(be&&!fe&&!Q){Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),v(n.id),t.current.position.x=$.position.x,t.current.position.y=0,t.current.position.z=$.position.z+nt.AGENT.WORKSTATION_OFFSET,t.current.rotation.y=Math.PI,Z.wasWorking=!0,Z.arrived=!1,Z.currentPos.x=t.current.position.x,Z.currentPos.z=t.current.position.z;const _e=e.animationConfig.working,Me=l==null?void 0:l[_e];Me&&!Me.isRunning()&&(Object.values(l).forEach(Y=>Y==null?void 0:Y.fadeOut(.3)),Me.reset().fadeIn(.3).play()),Z.currentAnim=_e;return}if(re||fe||Q){const _e=y.has(n.id),Me=((we=D.planRef.current)==null?void 0:we.commanded)??!1;if(_e&&!D.isPaused()&&!Me?(D.pause(),s.current=!0,I0(l,"Breathing idle",Z)):!_e&&s.current&&(D.resume(),s.current=!1,Z.arrived=!1),D.isPaused()){const ge=y.get(n.id);if(ge){const me=d.get(ge.partnerId),ze=f.get(ge.partnerId),Oe=(me==null?void 0:me.currentPosition)||(me==null?void 0:me.basePosition)||ze;if(Oe){const We=Math.atan2(Oe.x-Z.currentPos.x,Oe.z-Z.currentPos.z);Na(t.current,We,pe,5)}}g(n.id,t.current.position);return}D.planRef.current||(D.newPlan({stageOccupied:w(),seatOccupancy:m()}),Z.wasWorking=!1,Z.arrived=!1);const Y=D.getCurrentStep();if(!Y){D.newPlan({stageOccupied:w(),seatOccupancy:m()}),Z.arrived=!1,g(n.id,t.current.position);return}if(!Y.target){const ge=U(Y,Z);if(!ge){Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),v(n.id),D.advanceStep(),Z.arrived=!1,g(n.id,t.current.position);return}Y.target={x:ge.x,z:ge.z},Y.arrivalY=ge.arrivalY,Y.arrivalAnimation=ge.arrivalAnim,Y.arrivalRotation=ge.arrivalRot}const G=Y.target.x-t.current.position.x,ae=Y.target.z-t.current.position.z,Se=Math.sqrt(G*G+ae*ae);if(!Z.arrived&&Se>.5){t.current.position.y=0;const ge=Se>e.runThreshold,me=ge?e.runSpeed:e.walkSpeed;I0(l,ge?"Running":"Walking",Z);const Oe=Math.min(me*pe,Se),We=t.current.position.x+G/Se*Oe,Ge=t.current.position.z+ae/Se*Oe,Le=$.position.x,Ve=$.position.z,Xe=h2.has(Y.type),xe=Hw(We,Ge,Le,Ve,ie),Ce=lp(We,Ge,Fv),Ze=$c(We,Ge),he=!Xe&&(Math.abs(Ze.x-We)>.01||Math.abs(Ze.z-Ge)>.01),je=i2(We,Ge,n.id,T.current);if(!xe&&!Ce&&!he&&!je)t.current.position.x=We,t.current.position.z=Ge;else if(Y.type==="wander"){const ke=e.wanderRadiusX??Lc.radiusX,$e=$.position.z+(e.wanderMinZ??Lc.minZ),Ie=$.position.z+(e.wanderMaxZ??Lc.maxZ),Re=$.position.x+(Math.random()-.5)*ke*2,Fe=$e+Math.random()*(Ie-$e),rt=y3(Re,Fe,t.current.position.x,t.current.position.z,Le,Ve,ie);Y.target={x:rt.x,z:rt.z}}Na(t.current,Math.atan2(G,ae),pe,5),Z.currentPos.x=t.current.position.x,Z.currentPos.z=t.current.position.z}else Z.arrived?(Y.arrivalRotation!==void 0&&Na(t.current,Y.arrivalRotation,pe,3),D.isDurationElapsed(ce)&&(Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),Y.type==="go_to_stage"&&v(n.id),t.current.position.y=0,D.advanceStep(),Z.arrived=!1)):(Z.arrived=!0,D.markArrival(ce),Y.arrivalAnimation&&I0(l,Y.arrivalAnimation,Z),Y.arrivalRotation!==void 0&&(t.current.rotation.y=Y.arrivalRotation),Y.arrivalY!==void 0&&(t.current.position.y=Y.arrivalY))}g(n.id,t.current.position)});const te=D.displayStepType?dee[D.displayStepType]??"wander":"wander";return c.jsxs("group",{ref:t,position:[n.basePosition.x,0,n.basePosition.z],rotation:[0,Math.PI,0],onPointerOver:R,onPointerOut:j,onClick:L,children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,nt.CIRCLE_INDICATOR.Y_OFFSET,0],children:[c.jsx("circleGeometry",{args:[A||E?nt.CIRCLE_INDICATOR.RADIUS_ACTIVE:nt.CIRCLE_INDICATOR.RADIUS_DEFAULT,nt.CIRCLE_INDICATOR.SEGMENTS]}),c.jsx("meshStandardMaterial",{color:oe.color,emissive:oe.emissive,emissiveIntensity:oe.emissiveIntensity,transparent:!0,opacity:oe.opacity})]}),c.jsx("primitive",{object:o,scale:uee}),(()=>{const ee=y.get(n.id);return ee!=null&&ee.currentLine?c.jsx(Wp,{text:ee.currentLine,yOffset:3.5,variant:"conversation"}):null})(),!((ue=y.get(n.id))!=null&&ue.currentLine)&&n.status==="active"&&n.cpuPercent>10&&n.activity&&c.jsx(Wp,{text:n.activity,yOffset:3.2}),!y.has(n.id)&&n.status==="idle"&&(A||E)&&c.jsx(o2,{thoughts:p3[te]||p3.wander,yOffset:3.5}),n.status==="idle"&&D.displayStepType==="go_to_couch"&&c.jsx(gD,{yOffset:4})]})};On.preload(bn.COW);const hee={modelPath:bn.COW,animationConfig:e_.COW,runSpeed:3,walkSpeed:1.2,runThreshold:2,danceAnimation:"Dance",sitAnimation:"Sitting"},fee=({agent:n})=>c.jsx(t_,{agent:n,config:hee});On.preload(bn.HORSE);const pee={modelPath:bn.HORSE,animationConfig:e_.HORSE,runSpeed:3,walkSpeed:1.2,runThreshold:2,danceAnimation:"Talking",sitAnimation:"Sitting"},mee=({agent:n})=>c.jsx(t_,{agent:n,config:pee});On.preload(bn.TIGER);const gee={modelPath:bn.TIGER,animationConfig:e_.TIGER,runSpeed:3.5,walkSpeed:1.5,runThreshold:1.5,danceAnimation:"Salsa dancing",sitAnimation:"Sitting"},xee=({agent:n})=>c.jsx(t_,{agent:n,config:gee});On.preload(bn.RABBIT);const vee={modelPath:bn.RABBIT,animationConfig:e_.RABBIT,runSpeed:2.8,walkSpeed:1,runThreshold:1.8,danceAnimation:"Silly dancing",sitAnimation:"Sitting"},yee=({agent:n})=>c.jsx(t_,{agent:n,config:vee});On.preload(bn.ROBOT);On.preload(bn.HORSE);On.preload(bn.TIGER);On.preload(bn.RABBIT);const _ee=({agent:n})=>{const e=N.useRef(null),t=N.useRef(null),{scene:r,animations:s}=On(bn.ROBOT),i=N.useMemo(()=>{const f=Qq.clone(r);return f.traverse(g=>{(g.name==="Head"||g.name.includes("head"))&&(g.visible=!1)}),f},[r]),{actions:o,mixer:a}=Zy(s,i),l=N.useRef({currentAction:"Idle",activityMode:"typing",modeStartTime:0,modeDuration:5+Math.random()*10,typingOffset:Math.random()*Math.PI*2,coffeeBreakState:{mode:"drinking",modeStartTime:0,modeDuration:8+Math.random()*12,walkAngle:0,walkRadius:1.5+Math.random()*.5}}),{zones:u}=Pt(),d=N.useMemo(()=>u.get(n.projectName),[u,n.projectName]),h=N.useMemo(()=>d?d.workstations[n.workstationIndex]:null,[d,n.workstationIndex]);return N.useEffect(()=>{o.Idle&&o.Idle.play()},[o]),N.useEffect(()=>()=>{a&&a.stopAllAction(),i.traverse(f=>{var g;f instanceof kn&&((g=f.geometry)==null||g.dispose(),Array.isArray(f.material)?f.material.forEach(y=>y.dispose()):f.material&&f.material.dispose())})},[a,i]),vr((f,g)=>{if(!e.current||!h)return;const y=f.clock.elapsedTime,b=l.current,p=n.status==="active"&&n.cpuPercent>10;a==null||a.update(g),n.status==="active"&&p?bee(e.current,t.current,h,b,y,g,o):n.status==="active"&&!p?wee(e.current,t.current,h,b,y,g,o):n.status==="idle"&&Cee(e.current,t.current,h,b,y,o)}),h?c.jsxs("group",{ref:e,position:[n.basePosition.x,0,n.basePosition.z],rotation:[0,Math.PI,0],children:[c.jsx("primitive",{object:i,scale:nt.AGENT.ROBOT_SCALE}),c.jsx("group",{ref:t,position:[0,1.4,0],scale:3.5,children:c.jsx(See,{type:n.animalType})}),n.status==="active"&&n.cpuPercent>10&&n.activity&&c.jsx(Wp,{text:n.activity}),n.status==="idle"&&c.jsx(gD,{})]}):null},See=({type:n})=>{switch(n){case"cow":return c.jsx(l3,{});case"horse":return c.jsx(BZ,{});case"tiger":return c.jsx(OZ,{});case"rabbit":return c.jsx(FZ,{});default:return c.jsx(l3,{})}};function bee(n,e,t,r,s,i,o){const a=s*4,l=s*1.5;if(s-r.modeStartTime>r.modeDuration){const h=["typing","typing","typing","thinking","reading"];r.activityMode=h[Math.floor(Math.random()*h.length)],r.modeStartTime=s,r.modeDuration=3+Math.random()*8}const u=Math.sin(l)*.01,d=r.activityMode==="typing"?Math.sin(a*2)*.005:0;if(n.position.x=t.position.x+u,n.position.y=d,n.position.z=t.position.z+nt.AGENT.WORKSTATION_OFFSET,n.rotation.y=Math.PI,e)if(r.activityMode==="typing"){const h=Math.sin(a*.8)*.15,f=Math.sin(a*1.2)*.08;e.rotation.x=-.25+f,e.rotation.y=h}else if(r.activityMode==="thinking"){const h=Math.sin(s*.6);e.rotation.x=-.1+h*.15,e.rotation.y=Math.sin(l)*.2}else e.rotation.x=-.3,e.rotation.y=Math.sin(l*.7)*.1;Uv(o,r,"Idle")}function wee(n,e,t,r,s,i,o){const a=r.coffeeBreakState;if(s-a.modeStartTime>a.modeDuration&&(a.mode=a.mode==="drinking"?"walking":"drinking",a.modeStartTime=s,a.modeDuration=8+Math.random()*12),a.mode==="drinking"){if(n.position.set(t.position.x,0,t.position.z+.5),n.rotation.set(-.08,Math.PI+.2,0),e){const l=s*.4,u=Math.sin(l*.5)*.25;e.rotation.x=-.15+Math.sin(l*.3)*.05,e.rotation.y=u}Uv(o,r,"Idle")}else{a.walkAngle+=i*.3;const l=t.position.x,u=t.position.z+2,d=l+Math.sin(a.walkAngle)*a.walkRadius,h=u+Math.abs(Math.cos(a.walkAngle))*a.walkRadius*.5;n.position.set(d,0,h);const f=Math.atan2(Math.cos(a.walkAngle)*a.walkRadius,Math.abs(Math.sin(a.walkAngle))*a.walkRadius*.5);n.rotation.set(0,f,0),e&&(e.rotation.x=-.1,e.rotation.y=Math.sin(s*.3)*.3),Uv(o,r,"Walking")}}function Cee(n,e,t,r,s,i){const o=t.position.x+1.5,a=t.position.z+1;if(n.rotation.order="YXZ",n.rotation.set(-Math.PI/2,0,0),n.position.set(o,.3,a),e){const l=Math.sin(s*.5+r.typingOffset)*.5+.5;e.rotation.x=l*.05,e.rotation.z=l*.03}Uv(i,r,"Idle"),i.Idle&&(i.Idle.timeScale=.3)}function Uv(n,e,t){if(e.currentAction!==t&&n[t]){const r=n[e.currentAction],s=n[t],i=nt.AGENT.ANIMATION_FADE_DURATION;r&&r.fadeOut(i),s&&s.reset().fadeIn(i).play(),e.currentAction=t}}const Aee=()=>{const{agents:n}=Pt(),e=N.useMemo(()=>Array.from(n.values()),[n]);return c.jsx("group",{children:e.map(t=>{const r=(()=>{switch(t.animalType){case"cow":return c.jsx(fee,{agent:t});case"horse":return c.jsx(mee,{agent:t});case"tiger":return c.jsx(xee,{agent:t});case"rabbit":return c.jsx(yee,{agent:t});default:return c.jsx(_ee,{agent:t})}})();return c.jsx(N.Suspense,{fallback:null,children:r},t.id)})})},{STAGE:Mee}=nt;On.preload(bn.COW);On.preload(bn.HORSE);const Eee=4,Tee=2,kee=yD,_3={wander:["Just looking around","Nice office!","Where is everyone?","Taking a stroll","Exploring the factory"],couch:["Time to relax...","The couch looks comfy","Need a quick rest"],kitchen:["Snack time!","I smell coffee!","Mmm, pizza!","This coffee is great","Love the donuts!"],break_room:["Coffee break!","Need some caffeine","Taking five minutes"],poker_table:["All in!","Read my poker face","Bluffing time!"],stage:["Great show!","Amazing!","Encore!","Love it!","Bravo!"]};function P0(n,e,t,r=.3,s=.3){if(!n||t.currentAnim===e)return;let i=n[e];!i&&e!=="Idle"&&(i=n.Idle??n["Breathing idle"]??null),i&&(Object.values(n).forEach(o=>o==null?void 0:o.fadeOut(r)),i.reset().fadeIn(s).play(),t.currentAnim=e)}const Ree=({audiencePosition:n,modelPath:e,index:t,allObstacles:r})=>{const s=N.useRef(null),i=On(e),o=`fake-audience-${t}`,{agents:a,npcPositions:l,updateNpcPosition:u,entityConversations:d,stagePerformerRef:h,claimSeat:f,releaseSeat:g,getSeatOccupancy:y,isStageOccupied:b,consumeEntityCommand:p,entityPositionMapRef:m}=Pt(),{isHovered:x,isSelected:v,handlePointerOver:w,handlePointerOut:C,handleClick:M}=a2(o),T=d2(v,x,8421504),A=f2(o,see),E=N.useRef({currentPos:{x:n.x-10+t*3,z:n.z+t*2},initialized:!1,claimedSeatArea:null,arrived:!1,currentAnim:""}),R=N.useRef(!1),j=N.useRef(null),L=N.useRef(0),D=N.useRef(0),z=N.useRef(!1);nt.STAGE.POSITION;const q=nt.KITCHEN.POSITION,X=nt.LOUNGE.POSITION,K=nt.LOUNGE.COUCH_POSITIONS,I=nt.BREAK_ROOM.POSITION,B=nt.POKER_TABLE.POSITION,F=nt.PICKLEBALL.POSITION,O=nt.GOLF.POSITION,W=nt.OUTDOOR_BENCH.POSITIONS,J=N.useMemo(()=>l2(i.scene),[i.scene]),$=N.useMemo(()=>c2(i.animations),[i.animations]),{actions:ie,mixer:oe}=Zy($,J);N.useEffect(()=>()=>{u2(J);const ee=E.current;ee.claimedSeatArea&&g(ee.claimedSeatArea,o)},[J,o,g]);const U=(ee,pe)=>{switch(ee.type){case"watch_stage":return{x:n.x,z:n.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Math.PI/2};case"go_to_kitchen":{const Z=f("kitchen",o);if(Z<0)return null;pe.claimedSeatArea="kitchen";const be=nt.KITCHEN.SEAT_POSITIONS,re=be[Z%be.length];return{x:q.x+re.x,z:q.z+re.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:re.rotation}}case"go_to_couch":{const Z=f("couch",o);if(Z<0||!K[Z])return null;pe.claimedSeatArea="couch";const be=K[Z];return{x:X.x+be.x,z:X.z+be.z,arrivalY:nt.MOVEMENT.COUCH_SEAT_HEIGHT,arrivalAnim:"Breathing idle",arrivalRot:be.rotation}}case"go_to_break_room":{const Z=f("break_room",o);if(Z<0)return null;pe.claimedSeatArea="break_room";const be=Z*Math.PI/2,re=I.x+Math.sin(be)*1.3,ce=I.z+Math.cos(be)*1.3,le=Math.atan2(I.x-re,I.z-ce);return{x:re,z:ce,arrivalY:nt.MOVEMENT.COUCH_SEAT_HEIGHT,arrivalAnim:"Breathing idle",arrivalRot:le}}case"go_to_poker_table":{const Z=f("poker_table",o);if(Z<0)return null;pe.claimedSeatArea="poker_table";const be=Z*Math.PI/2,re=B.x+Math.sin(be)*1.8,ce=B.z+Math.cos(be)*1.8,le=Math.atan2(B.x-re,B.z-ce);return{x:re,z:ce,arrivalY:nt.MOVEMENT.COUCH_SEAT_HEIGHT,arrivalAnim:"Breathing idle",arrivalRot:le}}case"go_to_pickleball":{const Z=F.x+(Math.random()-.5)*6,be=F.z+(Math.random()-.5)*8;return{x:Z,z:be,arrivalY:0,arrivalAnim:"Breathing idle"}}case"go_to_golf":{const Z=O.x+(Math.random()-.5)*6,be=O.z+(Math.random()-.5)*6;return{x:Z,z:be,arrivalY:0,arrivalAnim:"Breathing idle"}}case"sit_outdoor":{const Z=W[Math.floor(Math.random()*W.length)];return{x:Z.x,z:Z.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Z.rotation}}case"wander":default:{const Z=lx(r);return{x:Z.x,z:Z.z,arrivalY:0,arrivalAnim:"Breathing idle"}}}};vr((ee,pe)=>{var Y;if(!s.current)return;oe==null||oe.update(pe);const Z=E.current,be=ee.clock.elapsedTime;if(x&&!v){P0(ie,"Breathing idle",Z),s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z;return}if(!Z.initialized){const G=lx(r);Z.currentPos={x:G.x,z:G.z},s.current.position.set(G.x,0,G.z),Z.initialized=!0}const re=p(o);re&&(Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),z.current=!1,A.planRef.current={steps:[{type:re.stepType,duration:Zc(re.stepType)}],currentStepIndex:0,paused:!1,arrivalTime:null,commanded:!0},Z.arrived=!1,R.current=!1,s.current.position.y=0);const ce=((Y=A.planRef.current)==null?void 0:Y.commanded)??!1,le=h.current,fe=j.current;le&&!fe&&!ce?(L.current=t*(1+Math.random()*2),D.current=be,z.current=!0):!le&&fe&&!ce&&(z.current=!1,Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.savedPlanRef.current?(A.planRef.current=A.savedPlanRef.current,A.savedPlanRef.current=null,Z.arrived=!1):(A.newPlan({stageOccupied:b(),seatOccupancy:y()}),Z.arrived=!1)),j.current=le,z.current&&!ce&&be-D.current>=L.current&&(z.current=!1,Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.interruptForStage(),Z.arrived=!1);const Q=d.has(o);if(Q&&!A.isPaused()&&!ce?(A.pause(),R.current=!0,P0(ie,"Breathing idle",Z)):!Q&&R.current&&(A.resume(),R.current=!1,Z.arrived=!1),A.isPaused()){const G=d.get(o);if(G){const ae=a.get(G.partnerId),Se=l.get(G.partnerId),ge=(ae==null?void 0:ae.currentPosition)||(ae==null?void 0:ae.basePosition)||Se;if(ge){const me=Math.atan2(ge.x-Z.currentPos.x,ge.z-Z.currentPos.z);Na(s.current,me,pe,5)}}s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z,u(o,s.current.position);return}A.planRef.current||(A.newPlan({stageOccupied:b(),seatOccupancy:y()}),Z.arrived=!1);const Te=A.getCurrentStep();if(!Te){A.newPlan({stageOccupied:b(),seatOccupancy:y()}),Z.arrived=!1,s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z,u(o,s.current.position);return}if(!Te.target){const G=U(Te,Z);if(!G){Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.advanceStep(),Z.arrived=!1,s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z,u(o,s.current.position);return}Te.target={x:G.x,z:G.z},Te.arrivalY=G.arrivalY,Te.arrivalAnimation=G.arrivalAnim,Te.arrivalRotation=G.arrivalRot}const we=Te.target.x-Z.currentPos.x,_e=Te.target.z-Z.currentPos.z,Me=Math.sqrt(we*we+_e*_e);if(!Z.arrived&&Me>.5){const G=Te.type==="watch_stage"?2.5:1.5,ae=Math.min(G*pe,Me),Se=Z.currentPos.x+we/Me*ae,ge=Z.currentPos.z+_e/Me*ae,me=Z.currentPos.x,ze=Z.currentPos.z,Oe=h2.has(Te.type);let We,Ge;if(Oe)We=Se,Ge=ge;else{const Le=Uw(Se,ge,me,ze,r);We=Le.x,Ge=Le.z}if(i2(We,Ge,o,m.current)&&(We=me,Ge=ze),Z.currentPos.x=We,Z.currentPos.z=Ge,Math.abs(We-me)<.01&&Math.abs(Ge-ze)<.01&&Me>2)if(Te.type==="wander"){const Le=lx(r);Te.target={x:Le.x,z:Le.z}}else Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.advanceStep(),Z.arrived=!1;Na(s.current,Math.atan2(we,_e),pe,5),P0(ie,"Walking",Z),s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z}else if(!Z.arrived)Z.arrived=!0,A.markArrival(be),Te.arrivalAnimation&&P0(ie,Te.arrivalAnimation,Z),Te.arrivalRotation!==void 0&&(s.current.rotation.y=Te.arrivalRotation),Te.arrivalY!==void 0&&(s.current.position.y=Te.arrivalY),s.current.position.x=Z.currentPos.x,s.current.position.z=Z.currentPos.z;else{Te.arrivalRotation!==void 0&&Na(s.current,Te.arrivalRotation,pe,3);const G=.02;s.current.rotation.z=Math.sin(be*.5+t)*G,A.isDurationElapsed(be)&&(Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),s.current.position.y=0,A.advanceStep(),Z.arrived=!1),s.current.position.x=Z.currentPos.x,s.current.position.z=Z.currentPos.z}u(o,s.current.position)});const te=A.displayStepType?kee[A.displayStepType]??"wander":"wander",ue=_3[te]||_3.wander;return c.jsxs("group",{ref:s,position:[0,0,0],onPointerOver:w,onPointerOut:C,onClick:M,children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,nt.CIRCLE_INDICATOR.Y_OFFSET,0],children:[c.jsx("circleGeometry",{args:[x||v?nt.CIRCLE_INDICATOR.RADIUS_ACTIVE:nt.CIRCLE_INDICATOR.RADIUS_DEFAULT,nt.CIRCLE_INDICATOR.SEGMENTS]}),c.jsx("meshStandardMaterial",{color:T.color,emissive:T.emissive,emissiveIntensity:T.emissiveIntensity,transparent:!0,opacity:T.opacity})]}),c.jsx("primitive",{object:J,scale:Tee}),(()=>{const ee=d.get(o);return ee!=null&&ee.currentLine?c.jsx(Wp,{text:ee.currentLine,yOffset:3.5,variant:"conversation"}):null})(),!d.has(o)&&(x||v)&&c.jsx(o2,{thoughts:ue,yOffset:3.5})]})},Nee=()=>{const{zones:n,npcPositions:e,stagePerformerRef:t}=Pt(),r=nt.STAGE.POSITION,s=N.useRef(null);vr(()=>{if(t.current){s.current=null;return}let l=null;for(const[u,d]of e){const h=d.x-r.x,f=d.z-r.z;if(Math.sqrt(h*h+f*f)<Eee){l=u;break}}l&&!s.current?t.current=l:!l&&s.current&&t.current===s.current&&(t.current=null),s.current=l});const i=N.useMemo(()=>[...Fv,...fD(n)],[n]),o=Mee.AUDIENCE_POSITIONS,a=[bn.COW,bn.HORSE];return c.jsx("group",{children:o.map((l,u)=>c.jsx(Ree,{audiencePosition:l,modelPath:a[u%a.length],index:u,allObstacles:i},`fake-audience-${u}`))})},Iee=3.6,Pee=2,Lee=.5,S3=.3,jee=.6,Bee={wander:"wandering",check_agent:"talking_to_agent",present:"presenting",go_to_kitchen:"visiting_kitchen",go_to_couch:"wandering",go_to_break_room:"wandering",go_to_poker_table:"wandering",watch_stage:"watching_stage",go_to_pickleball:"wandering",go_to_golf:"playing_golf",sit_outdoor:"wandering"};function L0(n,e,t){if(!n||t.currentAnim===e)return;const r=n[e];r&&(Object.values(n).forEach(s=>s==null?void 0:s.fadeOut(S3)),r.reset().fadeIn(S3).play(),t.currentAnim=e)}const jh=({modelPath:n,npcId:e,walkingAnimation:t,idleAnimation:r,weights:s,thoughts:i,initialPosition:o,circleColor:a=4500036,scale:l=Iee,modelYOffset:u=0,bubbleYOffset:d=6,walkCircleAnimation:h})=>{const f=N.useRef(null),g=N.useRef({currentPos:{x:o.x,z:o.z},initialized:!1,arrived:!1,currentAnim:"",claimedSeatArea:null,lastStagePerformerId:null}),y=N.useRef(!1),b=On(n),p=N.useMemo(()=>l2(b.scene),[b.scene]),m=N.useMemo(()=>c2(b.animations),[b.animations]),x=N.useMemo(()=>{if(u===0)return[0,0,0];const Z=p.children[0];if(!Z)return[0,0,0];const be=Z.children.find(ce=>ce.name.includes("Hips"));if(!be)return[0,0,0];const re=be.position.clone().applyQuaternion(Z.quaternion);return[-re.x*l,0,-re.z*l]},[p,l,u]),{actions:v,mixer:w}=Zy(m,p);N.useEffect(()=>{const Z=v==null?void 0:v[r];Z&&Z.reset().play()},[v,r]);const{agents:C,zones:M,npcPositions:T,updateNpcPosition:A,entityConversations:E,claimSeat:R,releaseSeat:j,getSeatOccupancy:L,isStageOccupied:D,stagePerformerRef:z,consumeEntityCommand:q,entityPositionMapRef:X}=Pt(),{isHovered:K,isSelected:I,handlePointerOver:B,handlePointerOut:F,handleClick:O}=a2(e),W=f2(e,s),J=N.useMemo(()=>[...Fv,...fD(M)],[M]),$=nt.STAGE.POSITION,ie=nt.KITCHEN.POSITION,oe=nt.PICKLEBALL.POSITION,U=nt.GOLF.POSITION,te=nt.OUTDOOR_BENCH.POSITIONS,ue=d2(I,K,a);N.useEffect(()=>()=>{u2(p);const Z=g.current;Z.claimedSeatArea&&j(Z.claimedSeatArea,e)},[p,e,j]);const ee=(Z,be)=>{switch(Z.type){case"check_agent":{const re=Array.from(C.values());if(re.length===0)return null;const ce=re[Math.floor(Math.random()*re.length)],le=ce.basePosition.x+3,fe=ce.basePosition.z+3,Q=Uw(le,fe,be.currentPos.x,be.currentPos.z,J);return{x:Q.x,z:Q.z,arrivalAnim:r}}case"present":return{x:$.x-2,z:$.z,arrivalAnim:r,arrivalRot:-Math.PI/2};case"walk_circle":return{x:0,z:0,arrivalAnim:h||r};case"go_to_kitchen":{const re=R("kitchen",e);if(re<0)return null;be.claimedSeatArea="kitchen";const ce=nt.KITCHEN.SEAT_POSITIONS,le=ce[re%ce.length];return{x:ie.x+le.x,z:ie.z+le.z,arrivalAnim:r,arrivalRot:le.rotation}}case"watch_stage":{const re=nt.STAGE.AUDIENCE_POSITIONS,ce=re[Math.floor(Math.random()*re.length)];return{x:ce.x,z:ce.z,arrivalAnim:r,arrivalRot:Math.PI/2}}case"go_to_pickleball":{const re=oe.x+(Math.random()-.5)*6,ce=oe.z+(Math.random()-.5)*8;return{x:re,z:ce,arrivalAnim:r}}case"go_to_golf":{const re=U.x+(Math.random()-.5)*6,ce=U.z+(Math.random()-.5)*6;return{x:re,z:ce,arrivalAnim:r}}case"sit_outdoor":{const re=te[Math.floor(Math.random()*te.length)];return{x:re.x,z:re.z,arrivalAnim:r,arrivalRot:re.rotation}}case"go_to_couch":{const re=R("couch",e);if(re<0)return null;be.claimedSeatArea="couch";const ce=nt.LOUNGE.COUCH_POSITIONS,le=ce[re%ce.length],fe=nt.LOUNGE.POSITION;return{x:fe.x+le.x,z:fe.z+le.z,arrivalAnim:r,arrivalRot:le.rotation}}case"go_to_break_room":{const re=R("break_room",e);if(re<0)return null;be.claimedSeatArea="break_room";const ce=nt.BREAK_ROOM.POSITION,le=re*Math.PI/2,fe=ce.x+Math.sin(le)*1.3,Q=ce.z+Math.cos(le)*1.3,Te=Math.atan2(ce.x-fe,ce.z-Q);return{x:fe,z:Q,arrivalAnim:r,arrivalRot:Te}}case"go_to_poker_table":{const re=R("poker_table",e);if(re<0)return null;be.claimedSeatArea="poker_table";const ce=nt.POKER_TABLE.POSITION,le=re*Math.PI/2,fe=ce.x+Math.sin(le)*1.8,Q=ce.z+Math.cos(le)*1.8,Te=Math.atan2(ce.x-fe,ce.z-Q);return{x:fe,z:Q,arrivalAnim:r,arrivalRot:Te}}case"wander":default:{const re=lx(J);return{x:re.x,z:re.z,arrivalAnim:r}}}};vr((Z,be)=>{var G;if(!f.current)return;w==null||w.update(be);const re=g.current,ce=Z.clock.elapsedTime;if(K&&!I){L0(v,r,re),f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}re.initialized||(re.currentPos={x:o.x,z:o.z},f.current.position.set(o.x,u,o.z),re.initialized=!0);const le=q(e);le&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.planRef.current={steps:[{type:le.stepType,duration:Zc(le.stepType)}],currentStepIndex:0,paused:!1,arrivalTime:null,commanded:!0},re.arrived=!1,y.current=!1,f.current.position.y=u);const fe=((G=W.planRef.current)==null?void 0:G.commanded)??!1,Q=E.has(e);if(Q&&!W.isPaused()&&!fe?(W.pause(),y.current=!0,L0(v,r,re)):!Q&&y.current&&(W.resume(),y.current=!1,re.arrived=!1),W.isPaused()){const ae=E.get(e);if(ae){const Se=C.get(ae.partnerId),ge=T.get(ae.partnerId),me=(Se==null?void 0:Se.currentPosition)||(Se==null?void 0:Se.basePosition)||ge;if(me){const ze=Math.atan2(me.x-re.currentPos.x,me.z-re.currentPos.z);Na(f.current,ze,be,5)}}f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}const Te=z.current;if(Te!==null&&Te!==re.lastStagePerformerId&&Te!==e)re.lastStagePerformerId=Te,!fe&&Math.random()<jee&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.interruptForStage(),re.arrived=!1);else if(Te===null&&re.lastStagePerformerId!==null){re.lastStagePerformerId=null;const ae=W.getCurrentStep();!fe&&(ae==null?void 0:ae.type)==="watch_stage"&&(W.savedPlanRef.current?(W.planRef.current=W.savedPlanRef.current,W.savedPlanRef.current=null):W.newPlan({stageOccupied:D(),seatOccupancy:L()}),re.arrived=!1)}W.planRef.current||(W.newPlan({stageOccupied:D(),seatOccupancy:L()}),re.arrived=!1);const we=W.getCurrentStep();if(!we){W.newPlan({stageOccupied:D(),seatOccupancy:L()}),re.arrived=!1,f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}if(!we.target){const ae=ee(we,re);if(!ae){re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.advanceStep(),re.arrived=!1,f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}we.target={x:ae.x,z:ae.z},we.arrivalAnimation=ae.arrivalAnim,we.arrivalRotation=ae.arrivalRot}const _e=we.target.x-re.currentPos.x,Me=we.target.z-re.currentPos.z,Y=Math.sqrt(_e*_e+Me*Me);if(!re.arrived&&Y>Lee){const ae=Math.min(Pee*be,Y),Se=re.currentPos.x+_e/Y*ae,ge=re.currentPos.z+Me/Y*ae,me=re.currentPos.x,ze=re.currentPos.z,Oe=h2.has(we.type);let We,Ge;if(Oe)We=Se,Ge=ge;else{const Le=Uw(Se,ge,me,ze,J);We=Le.x,Ge=Le.z}i2(We,Ge,e,X.current)&&(We=me,Ge=ze),re.currentPos.x=We,re.currentPos.z=Ge,Math.abs(We-me)<.01&&Math.abs(Ge-ze)<.01&&Y>2&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.advanceStep(),re.arrived=!1),Na(f.current,Math.atan2(_e,Me),be,5),L0(v,t,re)}else re.arrived?(we.arrivalRotation!==void 0&&Na(f.current,we.arrivalRotation,be,3),W.isDurationElapsed(ce)&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.advanceStep(),re.arrived=!1)):(re.arrived=!0,W.markArrival(ce),we.arrivalAnimation&&L0(v,we.arrivalAnimation,re),we.arrivalRotation!==void 0&&(f.current.rotation.y=we.arrivalRotation));f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position)});const pe=W.displayStepType?Bee[W.displayStepType]??"wandering":"wandering";return c.jsxs("group",{ref:f,position:[o.x,u,o.z],onPointerOver:B,onPointerOut:F,onClick:O,children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,nt.CIRCLE_INDICATOR.Y_OFFSET-u,0],children:[c.jsx("circleGeometry",{args:[K||I?nt.CIRCLE_INDICATOR.RADIUS_ACTIVE:nt.CIRCLE_INDICATOR.RADIUS_DEFAULT,nt.CIRCLE_INDICATOR.SEGMENTS]}),c.jsx("meshStandardMaterial",{color:ue.color,emissive:ue.emissive,emissiveIntensity:ue.emissiveIntensity,transparent:!0,opacity:ue.opacity})]}),c.jsx("primitive",{object:p,scale:l,position:x}),(()=>{const Z=E.get(e);return Z!=null&&Z.currentLine?c.jsx(Wp,{text:Z.currentLine,yOffset:d,variant:"conversation"}):null})(),!E.has(e)&&(K||I)&&c.jsx(o2,{thoughts:i[pe]||i.wandering,yOffset:d})]})};On.preload(bn.STEVE_JOBS);const b3={WALKING:"Walking",IDLE:"Standing Clap"},Dee=()=>c.jsx(jh,{modelPath:bn.STEVE_JOBS,npcId:nt.NPC_IDS.STEVE_JOBS,walkingAnimation:b3.WALKING,idleAnimation:b3.IDLE,weights:QZ,thoughts:UZ,initialPosition:{x:0,z:5},circleColor:4500036});On.preload(bn.SUNDAR_PICHAI);const qS={WALKING:"Walking",IDLE:"Talking",WALK_IN_CIRCLE:"Walk In Circle"},Oee=()=>c.jsx(jh,{modelPath:bn.SUNDAR_PICHAI,npcId:nt.NPC_IDS.SUNDAR_PICHAI,walkingAnimation:qS.WALKING,idleAnimation:qS.IDLE,weights:ZZ,thoughts:HZ,initialPosition:{x:10,z:0},circleColor:4500036,walkCircleAnimation:qS.WALK_IN_CIRCLE});On.preload(bn.ELON_MUSK);const w3={WALKING:"Walking",IDLE:"Yelling"},Fee=()=>c.jsx(jh,{modelPath:bn.ELON_MUSK,npcId:nt.NPC_IDS.ELON_MUSK,walkingAnimation:w3.WALKING,idleAnimation:w3.IDLE,weights:eee,thoughts:zZ,initialPosition:{x:4,z:50},circleColor:11158596,scale:3.4,modelYOffset:2});On.preload(bn.MARK_ZUCKERBERG);const C3={WALKING:"Talking",IDLE:"Look around"},Uee=()=>c.jsx(jh,{modelPath:bn.MARK_ZUCKERBERG,npcId:nt.NPC_IDS.MARK_ZUCKERBERG,walkingAnimation:C3.WALKING,idleAnimation:C3.IDLE,weights:tee,thoughts:GZ,initialPosition:{x:18,z:38},circleColor:4474026,scale:3.6,modelYOffset:2});On.preload(bn.JENSEN_HUANG);const A3={WALKING:"Brutal to happy walking",IDLE:"Talking"},Hee=()=>c.jsx(jh,{modelPath:bn.JENSEN_HUANG,npcId:nt.NPC_IDS.JENSEN_HUANG,walkingAnimation:A3.WALKING,idleAnimation:A3.IDLE,weights:nee,thoughts:WZ,initialPosition:{x:-5,z:5},circleColor:4500036,scale:3.25,modelYOffset:0});On.preload(bn.STEVE_HUANG);const M3={WALKING:"Walking",IDLE:"Drinking"},zee=()=>c.jsx(jh,{modelPath:bn.STEVE_HUANG,npcId:nt.NPC_IDS.STEVE_HUANG,walkingAnimation:M3.WALKING,idleAnimation:M3.IDLE,weights:ree,thoughts:VZ,initialPosition:{x:16,z:44},circleColor:11184708,scale:3.5,modelYOffset:0}),{CAMERA:oo}=nt,Gee=()=>{const{camera:n,gl:e}=gs(),{camera:t,updateCamera:r,bossModeState:s,clearSelection:i}=Pt(),o=N.useRef({forward:!1,backward:!1,left:!1,right:!1,up:!1,down:!1}),a=N.useRef({isDragging:!1,lastX:0,lastY:0}),l=N.useRef(t.yaw),u=N.useRef(t.pitch),d=N.useRef(new se),h=N.useRef(new se),f=N.useRef(new se),g=N.useRef(new se),y=N.useCallback(()=>{zS(l.current,u.current,h.current),d.current.copy(n.position).add(h.current),n.lookAt(d.current)},[n]);return N.useEffect(()=>{const b=m=>{switch(m.key.toLowerCase()){case"w":case"arrowup":o.current.forward=!0;break;case"s":case"arrowdown":o.current.backward=!0;break;case"a":case"arrowleft":o.current.left=!0;break;case"d":case"arrowright":o.current.right=!0;break;case"q":case" ":o.current.up=!0;break;case"e":o.current.down=!0;break;case"escape":s.isActive&&i();break}},p=m=>{switch(m.key.toLowerCase()){case"w":case"arrowup":o.current.forward=!1;break;case"s":case"arrowdown":o.current.backward=!1;break;case"a":case"arrowleft":o.current.left=!1;break;case"d":case"arrowright":o.current.right=!1;break;case"q":case" ":o.current.up=!1;break;case"e":o.current.down=!1;break}};return window.addEventListener("keydown",b),window.addEventListener("keyup",p),()=>{window.removeEventListener("keydown",b),window.removeEventListener("keyup",p)}},[s.isActive,i]),N.useEffect(()=>{const b=e.domElement,p=w=>{a.current.isDragging=!0,a.current.lastX=w.clientX,a.current.lastY=w.clientY,b.style.cursor="grabbing"},m=()=>{a.current.isDragging=!1,b.style.cursor="default"},x=w=>{if(!a.current.isDragging)return;const C=w.clientX-a.current.lastX,M=w.clientY-a.current.lastY;l.current-=C*oo.MOUSE_SENSITIVITY,u.current=Math.max(oo.MIN_PITCH,Math.min(oo.MAX_PITCH,u.current-M*oo.MOUSE_SENSITIVITY)),y(),a.current.lastX=w.clientX,a.current.lastY=w.clientY},v=w=>{w.preventDefault(),zS(l.current,u.current,f.current);const C=w.deltaY<0?oo.ZOOM_SPEED:-oo.ZOOM_SPEED;n.position.addScaledVector(f.current,C)};return b.addEventListener("mousedown",p),document.addEventListener("mouseup",m),b.addEventListener("mousemove",x),b.addEventListener("wheel",v,{passive:!1}),()=>{b.removeEventListener("mousedown",p),document.removeEventListener("mouseup",m),b.removeEventListener("mousemove",x),b.removeEventListener("wheel",v)}},[e,n,y]),N.useEffect(()=>{const b=e.domElement;let p={isDragging:!1,lastX:0,lastY:0,isPinching:!1,initialPinchDistance:0};const m=(C,M)=>{const T=C.clientX-M.clientX,A=C.clientY-M.clientY;return Math.sqrt(T*T+A*A)},x=C=>{C.preventDefault(),C.touches.length===1?(p.isDragging=!0,p.isPinching=!1,p.lastX=C.touches[0].clientX,p.lastY=C.touches[0].clientY):C.touches.length===2&&(p.isDragging=!1,p.isPinching=!0,p.initialPinchDistance=m(C.touches[0],C.touches[1]))},v=C=>{if(C.preventDefault(),C.touches.length===1&&p.isDragging){const M=C.touches[0].clientX-p.lastX,T=C.touches[0].clientY-p.lastY;l.current+=M*oo.TOUCH_SENSITIVITY,u.current=Math.max(oo.MIN_PITCH,Math.min(oo.MAX_PITCH,u.current+T*oo.TOUCH_SENSITIVITY)),y(),p.lastX=C.touches[0].clientX,p.lastY=C.touches[0].clientY}else if(C.touches.length===2&&p.isPinching){const M=m(C.touches[0],C.touches[1]),T=M-p.initialPinchDistance;zS(l.current,u.current,f.current),n.position.addScaledVector(f.current,T*.02),p.initialPinchDistance=M}},w=C=>{C.touches.length===0?(p.isDragging=!1,p.isPinching=!1):C.touches.length===1&&(p.isDragging=!0,p.isPinching=!1,p.lastX=C.touches[0].clientX,p.lastY=C.touches[0].clientY)};return b.addEventListener("touchstart",x,{passive:!1}),b.addEventListener("touchmove",v,{passive:!1}),b.addEventListener("touchend",w),()=>{b.removeEventListener("touchstart",x),b.removeEventListener("touchmove",v),b.removeEventListener("touchend",w)}},[e,n,y]),vr((b,p)=>{const m=o.current;if(s.isActive){n.position.copy(t.position),n.lookAt(t.target),h.current.copy(t.target).sub(t.position).normalize(),l.current=Math.atan2(h.current.x,h.current.z),u.current=Math.asin(h.current.y);return}if(t.isAnimating&&t.animationTarget){const v=t.animationTarget,w=Date.now()-v.startTime,C=Math.min(w/v.duration,1),M=1-Math.pow(1-C,3);n.position.lerpVectors(v.startPosition,v.position,M),d.current.lerpVectors(v.startLookAt,v.lookAt,M),n.lookAt(d.current),h.current.copy(d.current).sub(n.position).normalize(),l.current=Math.atan2(h.current.x,h.current.z),u.current=Math.asin(h.current.y),C>=1&&r({isAnimating:!1,animationTarget:void 0});return}const x=oo.MOVE_SPEED*p;f.current.set(Math.sin(l.current),0,Math.cos(l.current)),g.current.set(Math.sin(l.current+Math.PI/2),0,Math.cos(l.current+Math.PI/2)),m.forward&&n.position.addScaledVector(f.current,x),m.backward&&n.position.addScaledVector(f.current,-x),m.left&&n.position.addScaledVector(g.current,x),m.right&&n.position.addScaledVector(g.current,-x),m.up&&(n.position.y+=x),m.down&&(n.position.y-=x)}),null},Wee=()=>{const{stats:n,isLoading:e,error:t}=Pt();return e?c.jsx("div",{className:"absolute top-4 left-4 bg-surface-dark/90 backdrop-blur-sm rounded-lg p-4 border border-border-dark",children:c.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."})}):t?c.jsx("div",{className:"absolute top-4 left-4 bg-surface-dark/90 backdrop-blur-sm rounded-lg p-4 border border-red-500/50",children:c.jsx("div",{className:"text-red-400 text-sm",children:t})}):c.jsxs("div",{className:"absolute top-16 left-4 bg-surface-dark/90 backdrop-blur-sm rounded-lg p-3 border border-border-dark min-w-[140px] shadow-lg",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx($S,{label:"Active",count:n.activeCount,color:"bg-green-500",textColor:"text-green-400"}),c.jsx($S,{label:"Idle",count:n.idleCount,color:"bg-yellow-500",textColor:"text-yellow-400"}),c.jsx($S,{label:"Dormant",count:n.dormantCount,color:"bg-red-500",textColor:"text-red-400"})]}),c.jsx("div",{className:"border-t border-border-dark my-3"}),c.jsxs("div",{className:"flex justify-between items-center",children:[c.jsx("span",{className:"text-xs text-text-muted",children:"Total Agents"}),c.jsx("span",{className:"text-sm font-bold text-text-primary",children:n.activeCount+n.idleCount+n.dormantCount})]}),n.totalTokens>0&&c.jsxs("div",{className:"flex justify-between items-center mt-1",children:[c.jsx("span",{className:"text-xs text-text-muted",children:"Session Tokens"}),c.jsx("span",{className:"text-sm text-primary",children:YS(n.totalTokens)})]}),n.tokensByProject&&n.tokensByProject.length>0&&n.totalTokens>0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-t border-border-dark my-3"}),c.jsx("div",{className:"text-[10px] text-text-muted uppercase tracking-wide mb-2",children:"Tokens by Project"}),c.jsx("div",{className:"flex h-2 rounded-full overflow-hidden mb-2",children:n.tokensByProject.map(r=>{const s=n.totalTokens>0?r.tokens/n.totalTokens*100:0,i=`#${r.color.toString(16).padStart(6,"0")}`;return c.jsx("div",{style:{width:`${s}%`,backgroundColor:i},title:`${r.projectName}: ${YS(r.tokens)}`},r.projectName)})}),c.jsx("div",{className:"space-y-1",children:n.tokensByProject.map(r=>{const s=`#${r.color.toString(16).padStart(6,"0")}`,i=n.totalTokens>0?Math.round(r.tokens/n.totalTokens*100):0;return c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:s}}),c.jsx("span",{className:"text-[10px] text-text-muted flex-1 truncate",children:r.projectName}),c.jsxs("span",{className:"text-[10px] text-text-muted",children:[i,"%"]}),c.jsx("span",{className:"text-[10px] text-text-primary font-medium",children:YS(r.tokens)})]},r.projectName)})})]})]})},$S=({label:n,count:e,color:t,textColor:r})=>c.jsxs("div",{className:"flex justify-between items-center",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:`w-2 h-2 rounded-full ${t}`}),c.jsx("span",{className:"text-xs text-text-muted",children:n})]}),c.jsx("span",{className:`text-sm font-semibold ${r}`,children:e})]});function YS(n){return n>=1e9?(n/1e9).toFixed(1)+"B":n>=1e6?(n/1e6).toFixed(1)+"M":n>=1e3?(n/1e3).toFixed(1)+"K":n.toString()}const Vee=()=>{const{projects:n,zones:e,setCameraTarget:t,bossModeState:r,toggleBossMode:s,setBossModeType:i,bossNextTarget:o,bossPrevTarget:a,getCurrentTargetName:l}=Pt(),u=N.useMemo(()=>n.map((d,h)=>{const f=e.get(d);return{projectName:d,color:(f==null?void 0:f.color)||Dd[h%Dd.length],agentCount:(f==null?void 0:f.workstations.filter(g=>g.assignedAgentId).length)||0}}),[n,e]);return c.jsxs("div",{className:"absolute top-4 right-4 flex flex-col gap-2 max-w-[180px]",children:[c.jsx("div",{className:"bg-surface-dark/90 backdrop-blur-sm rounded-lg border border-border-dark p-2 shadow-lg",children:c.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[c.jsx("button",{onClick:()=>t("overview"),className:"px-2 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Overview"}),c.jsx("button",{onClick:()=>t("birdseye"),className:"px-2 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Bird's Eye"}),c.jsx("button",{onClick:()=>t("outdoor"),className:"px-2 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Outdoor"}),c.jsx("button",{onClick:s,className:`px-2 py-1.5 rounded border transition-all text-xs font-medium ${r.isActive?"bg-primary/30 border-primary text-primary":"bg-surface-dark hover:bg-primary/20 border-transparent hover:border-primary/50 text-text-muted"}`,children:r.isActive?"Stop":"Boss Mode"})]})}),r.isActive&&c.jsxs("div",{className:"bg-surface-dark/90 backdrop-blur-sm rounded-lg border border-primary/50 p-2 shadow-lg",children:[c.jsxs("div",{className:"text-center mb-2 px-2",children:[c.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide",children:"Viewing"}),c.jsx("div",{className:"text-sm font-medium text-primary truncate",children:l()||"Loading..."}),c.jsxs("div",{className:"text-[10px] text-text-muted",children:[r.currentTargetIndex+1," / ",r.targets.length]})]}),c.jsxs("div",{className:"flex gap-1 mb-2",children:[c.jsx("button",{onClick:()=>i("auto"),className:`flex-1 px-2 py-1 rounded text-xs font-medium transition-all ${r.mode==="auto"?"bg-primary text-white":"bg-surface-dark hover:bg-primary/20 text-text-muted"}`,children:"Auto"}),c.jsx("button",{onClick:()=>i("manual"),className:`flex-1 px-2 py-1 rounded text-xs font-medium transition-all ${r.mode==="manual"?"bg-primary text-white":"bg-surface-dark hover:bg-primary/20 text-text-muted"}`,children:"Manual"})]}),c.jsxs("div",{className:"flex gap-1",children:[c.jsx("button",{onClick:a,className:"flex-1 px-3 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"โ† Prev"}),c.jsx("button",{onClick:o,className:"flex-1 px-3 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Next โ†’"})]})]}),u.length>0&&c.jsx("div",{className:"bg-surface-dark/90 backdrop-blur-sm rounded-lg border border-border-dark shadow-lg overflow-hidden",children:c.jsx("div",{className:"max-h-[280px] overflow-y-auto scrollbar-thin scrollbar-thumb-border-dark scrollbar-track-transparent p-1.5 space-y-1",children:u.map(d=>c.jsx(Xee,{projectName:d.projectName,color:d.color,agentCount:d.agentCount,onClick:()=>t(d.projectName)},d.projectName))})})]})},Xee=({projectName:n,color:e,agentCount:t,onClick:r})=>{const s=`#${e.toString(16).padStart(6,"0")}`,i=n.length>12?n.substring(0,11)+"โ€ฆ":n;return c.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-2 py-1.5 w-full bg-transparent hover:bg-primary/10 rounded border border-transparent hover:border-primary/30 transition-all text-left",title:n,children:[c.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:s}}),c.jsx("span",{className:"text-xs text-text-primary flex-1 truncate",children:i}),t>0&&c.jsx("span",{className:"text-[10px] px-1 py-0.5 rounded bg-primary/20 text-primary font-medium",children:t})]})},Kee=()=>{const{lightingMode:n,setLightingMode:e,isNightMode:t}=Pt(),r=()=>{const o=["day","night","auto"],l=(o.indexOf(n)+1)%o.length;e(o[l])},s=()=>{switch(n){case"day":return c.jsx(cU,{className:"w-4 h-4"});case"night":return c.jsx(tU,{className:"w-4 h-4"});case"auto":return c.jsx(Zo,{className:"w-4 h-4"})}},i=()=>{switch(n){case"day":return"Day";case"night":return"Night";case"auto":return t?"Auto (Night)":"Auto (Day)"}};return c.jsxs("button",{onClick:r,className:`absolute top-4 right-[200px] flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border shadow-lg transition-all z-10 ${n==="night"||n==="auto"&&t?"bg-indigo-900/90 border-indigo-500/50 text-indigo-200":"bg-amber-100/95 border-amber-400/50 text-amber-900"}`,title:"Toggle lighting mode (Day/Night/Auto)",children:[s(),c.jsx("span",{className:"text-xs font-medium",children:i()})]})},Jee=[{label:"Perform on Stage",stepType:"go_to_stage",icon:"๐ŸŽค"},{label:"Eat Food",stepType:"go_to_kitchen",icon:"๐Ÿ•"},{label:"Take a Break",stepType:"go_to_couch",icon:"๐Ÿ›‹๏ธ"},{label:"Play Poker",stepType:"go_to_poker_table",icon:"๐Ÿƒ"},{label:"Hang Out",stepType:"go_to_break_room",icon:"โ˜•"},{label:"Wander",stepType:"wander",icon:"๐Ÿšถ"},{label:"Pickleball",stepType:"go_to_pickleball",icon:"๐Ÿ“"},{label:"Golf",stepType:"go_to_golf",icon:"โ›ณ"},{label:"Sit Outside",stepType:"sit_outdoor",icon:"๐Ÿช‘"}];function qee(n,e){const t=e.get(n);if(t)return t.name||t.sessionName||n;if(n==="steve-jobs-npc")return"Steve Jobs";if(n==="sundar-pichai-npc")return"Sundar Pichai";const r=n.match(/^fake-audience-(\d+)$/);return r?`Audience Member ${Number(r[1])+1}`:n}const $ee=()=>{const{selectedEntityId:n,agents:e,bossModeState:t,sendEntityCommand:r,clearSelection:s}=Pt();if(!n||!t.isActive)return null;const i=qee(n,e);return c.jsx("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 z-10 pointer-events-auto",children:c.jsxs("div",{className:"bg-gray-900/90 backdrop-blur-sm rounded-lg border border-gray-700 shadow-xl px-4 py-3",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2 gap-4",children:[c.jsx("span",{className:"text-white text-sm font-medium truncate max-w-[200px]",children:i}),c.jsx("button",{onClick:s,className:"text-gray-400 hover:text-white transition-colors p-0.5 rounded hover:bg-gray-700/50",title:"Close",children:c.jsx(Mr,{className:"w-4 h-4"})})]}),c.jsx("div",{className:"flex gap-2",children:Jee.map(o=>c.jsxs("button",{onClick:()=>r(n,{stepType:o.stepType}),className:"flex flex-col items-center gap-1 px-3 py-2 rounded-md bg-gray-800/80 hover:bg-gray-700 border border-gray-600/50 hover:border-gray-500 transition-all text-gray-200 hover:text-white",title:o.label,children:[c.jsx("span",{className:"text-base leading-none",children:o.icon}),c.jsx("span",{className:"text-[10px] whitespace-nowrap",children:o.label})]},o.stepType))})]})})};class Yee extends N.Component{constructor(e){super(e),this.state={hasError:!1,error:null,retryCount:0}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("3D Scene Error:",e,t)}render(){return this.state.hasError?this.props.fallback||c.jsx("div",{className:"flex items-center justify-center h-full bg-gray-900 text-white",children:c.jsxs("div",{className:"text-center p-8",children:[c.jsx("h2",{className:"text-xl font-bold mb-2",children:"3D Scene Error"}),c.jsx("p",{className:"text-gray-400 mb-4",children:"Unable to load the factory visualization."}),this.state.error&&c.jsx("p",{className:"text-red-400 text-sm mb-4 max-w-md break-words",children:this.state.error.message}),c.jsx("button",{className:"px-4 py-2 bg-blue-600 rounded hover:bg-blue-700",onClick:()=>this.setState(e=>({hasError:!1,error:null,retryCount:e.retryCount+1})),children:"Retry"})]})}):c.jsx("div",{className:"w-full h-full",children:this.props.children},this.state.retryCount)}}const Qee=()=>{const{scene:n,gl:e}=gs(),{isNightMode:t}=Pt();return N.useEffect(()=>{e.shadowMap.enabled=!0,e.shadowMap.type=Xd,e.toneMapping=am,e.toneMappingExposure=1.2},[e]),N.useEffect(()=>{const r=t?yh.night:yh.day;n.background=new ct(r.background),n.fog=new dm(r.fog,30,80)},[n,t]),null},Zee=()=>{const n=N.useRef(null);return vr(e=>{n.current&&(n.current.rotation.x=e.clock.elapsedTime,n.current.rotation.y=e.clock.elapsedTime*.5)}),c.jsxs("mesh",{ref:n,position:[0,2,0],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:"#3a5f8a",wireframe:!0})]})},ete=()=>c.jsxs(c.Fragment,{children:[c.jsx(Qee,{}),c.jsx(fQ,{}),c.jsx(mQ,{}),c.jsx(_Q,{}),c.jsx(TQ,{}),c.jsx(OQ,{}),c.jsx(qQ,{}),c.jsx(tZ,{}),c.jsx(lZ,{}),c.jsx(mZ,{}),c.jsx(yZ,{}),c.jsx(wZ,{}),c.jsx(jZ,{}),c.jsx(Aee,{}),c.jsx(Nee,{}),c.jsx(Dee,{}),c.jsx(Oee,{}),c.jsx(Fee,{}),c.jsx(Uee,{}),c.jsx(Hee,{}),c.jsx(zee,{}),c.jsx(Gee,{}),c.jsx(FY,{all:!0})]}),tte=({showStats:n=!1,className:e=""})=>{const{CAMERA:t}=nt,r=N.useRef(null);return c.jsx(hQ,{children:c.jsx(Yee,{children:c.jsxs("div",{className:`relative w-full h-full ${e}`,children:[c.jsxs(Kq,{shadows:!0,dpr:[1,2],camera:{fov:t.FOV,near:t.NEAR,far:t.FAR,position:[t.DEFAULT_POSITION.x,t.DEFAULT_POSITION.y,t.DEFAULT_POSITION.z]},gl:{antialias:!0,alpha:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0},onCreated:({gl:s})=>{const i=s.domElement;i.addEventListener("webglcontextlost",o=>{o.preventDefault(),console.warn("WebGL context lost. Click Retry to restore.")}),i.addEventListener("webglcontextrestored",()=>{console.log("WebGL context restored.")})},children:[c.jsx(UY,{pixelated:!0}),c.jsx(HY,{}),c.jsx(N.Suspense,{fallback:c.jsx(Zee,{}),children:c.jsx(ete,{})}),n&&c.jsx(DY,{parent:r})]}),c.jsx("div",{className:"absolute inset-0 pointer-events-none",children:c.jsxs("div",{className:"pointer-events-auto",children:[c.jsx(Wee,{}),c.jsx(Vee,{}),c.jsx(Kee,{}),c.jsx($ee,{})]})}),n&&c.jsx("div",{ref:r,className:"absolute bottom-0 left-0 z-50"})]})})})};function nte(){const n=navigator.userAgent||navigator.vendor||window.opera,t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(n),r=window.innerWidth<768;return t||r}const rte=({onTryAnyway:n,onGoBack:e})=>c.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen bg-background-dark p-6 text-center",children:c.jsxs("div",{className:"max-w-md",children:[c.jsx("div",{className:"mb-6 flex justify-center",children:c.jsxs("div",{className:"relative",children:[c.jsx(rP,{className:"w-20 h-20 text-primary/30"}),c.jsx(fP,{className:"w-10 h-10 text-primary absolute -bottom-2 -right-2 bg-background-dark rounded-full p-1"})]})}),c.jsx("h1",{className:"text-2xl font-bold text-text-primary-dark mb-3",children:"3D Factory View"}),c.jsx("p",{className:"text-text-secondary-dark mb-6",children:"The 3D factory visualization requires significant graphics processing power and is optimized for desktop browsers."}),c.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-8",children:[c.jsxs("div",{className:"bg-surface-dark p-4 rounded-lg border border-border-dark",children:[c.jsx(si,{className:"w-6 h-6 text-primary mx-auto mb-2"}),c.jsx("p",{className:"text-xs text-text-secondary-dark",children:"Agents"})]}),c.jsxs("div",{className:"bg-surface-dark p-4 rounded-lg border border-border-dark",children:[c.jsx(XF,{className:"w-6 h-6 text-green-500 mx-auto mb-2"}),c.jsx("p",{className:"text-xs text-text-secondary-dark",children:"Active"})]}),c.jsxs("div",{className:"bg-surface-dark p-4 rounded-lg border border-border-dark",children:[c.jsx(oy,{className:"w-6 h-6 text-blue-500 mx-auto mb-2"}),c.jsx("p",{className:"text-xs text-text-secondary-dark",children:"Status"})]})]}),c.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary-dark bg-surface-dark p-3 rounded-lg mb-6",children:[c.jsx(lP,{className:"w-5 h-5 text-primary flex-shrink-0"}),c.jsx("span",{children:"For the best experience, open this page on a desktop computer."})]}),c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsx("button",{onClick:e,className:"w-full px-4 py-3 bg-primary text-white rounded-lg font-medium hover:bg-primary/90 transition-colors",children:"Back to Dashboard"}),c.jsx("button",{onClick:n,className:"w-full px-4 py-3 bg-surface-dark text-text-secondary-dark rounded-lg font-medium hover:bg-surface-dark/80 transition-colors border border-border-dark",children:"Try Loading Anyway"})]}),c.jsx("p",{className:"text-xs text-text-secondary-dark/60 mt-4",children:"Loading on mobile may cause the browser to become unresponsive"})]})}),ste=()=>{const n=za(),{collapseSidebar:e,expandSidebar:t}=zC(),r=N.useMemo(()=>nte(),[]),[s,i]=N.useState(!1);N.useEffect(()=>((!r||s)&&e(),()=>{t()}),[e,t,r,s]);const o=()=>{n("/")},a=()=>{i(!0)},l=!1;return r&&!s?c.jsx(rte,{onTryAnyway:a,onGoBack:o}):c.jsxs("div",{className:"fixed inset-0 top-14 md:top-0 md:left-16 bg-background-dark",children:[c.jsxs("button",{onClick:o,className:"hidden md:flex absolute top-4 left-4 z-10 items-center gap-2 px-3 py-2 bg-surface-dark/80 backdrop-blur-sm rounded-lg border border-border-dark hover:bg-surface-dark hover:border-primary/50 transition-all",children:[c.jsx(FF,{className:"w-4 h-4"}),c.jsx("span",{className:"text-sm font-medium",children:"Back to Dashboard"})]}),c.jsx(tte,{showStats:l,className:"w-full h-full"})]})};function ite(){const[n,e]=N.useState(null),[t,r]=N.useState(!0),[s,i]=N.useState(null),o=N.useCallback(async()=>{r(!0),i(null);try{const h=await Ff.getSettings();e(h)}catch(h){i(h instanceof Error?h.message:"Failed to load settings")}finally{r(!1)}},[]),a=N.useCallback(async h=>{const f=await Ff.updateSettings(h);return e(f),f},[]),l=N.useCallback(async()=>{const h=await Ff.resetSettings();return e(h),h},[]),u=N.useCallback(async h=>{const f=await Ff.resetSection(h);return e(f),f},[]),d=N.useCallback(async()=>{await o()},[o]);return N.useEffect(()=>{o()},[o]),{settings:n,isLoading:t,error:s,updateSettings:a,resetSettings:l,resetSection:u,refreshSettings:d}}const ote=["claude-code","gemini-cli","codex-cli"],QS={"claude-code":"Claude Code","gemini-cli":"Gemini CLI","codex-cli":"Codex CLI"},ate=()=>{const{settings:n,updateSettings:e,resetSection:t,isLoading:r,error:s}=ite(),[i,o]=N.useState(null),[a,l]=N.useState(!1),[u,d]=N.useState("idle");N.useEffect(()=>{n&&(o(n),l(!1))},[n]);const h=(b,p,m)=>{i&&(o({...i,[b]:{...i[b],[p]:m}}),l(!0),d("idle"))},f=(b,p)=>{i&&(o({...i,general:{...i.general,runtimeCommands:{...i.general.runtimeCommands,[b]:p}}}),l(!0),d("idle"))},g=async()=>{if(i){d("saving");try{await e({general:i.general,chat:i.chat}),d("saved"),l(!1),setTimeout(()=>d("idle"),2e3)}catch{d("error")}}},y=async()=>{window.confirm("Reset all general and chat settings to defaults?")&&(await t("general"),await t("chat"),l(!1),d("idle"))};return r?c.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[c.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"}),c.jsx("p",{className:"text-text-secondary-dark",children:"Loading settings..."})]}):s?c.jsxs("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center gap-2",children:[c.jsx(ih,{className:"w-5 h-5"}),"Error loading settings: ",s]}):i?c.jsxs("div",{className:"space-y-8 max-w-3xl",children:[c.jsxs("section",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Runtime Settings"}),c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"defaultRuntime",children:"Default AI Runtime"}),c.jsx(go,{id:"defaultRuntime",value:i.general.defaultRuntime,onChange:b=>h("general","defaultRuntime",b.target.value),children:Object.keys(QS).map(b=>c.jsx("option",{value:b,children:QS[b]},b))}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"The default AI runtime to use for new agents"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"autoStart",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Auto-Start Orchestrator"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Automatically start the orchestrator when Crewly launches"})]}),c.jsx("input",{type:"checkbox",id:"autoStart",checked:i.general.autoStartOrchestrator,onChange:b=>h("general","autoStartOrchestrator",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"autoResume",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Auto-Resume Sessions on Restart"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Automatically resume agent sessions when they restart"})]}),c.jsx("input",{type:"checkbox",id:"autoResume",checked:i.general.autoResumeOnRestart,onChange:b=>h("general","autoResumeOnRestart",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"checkInInterval",children:"Check-in Interval (minutes)"}),c.jsx(gr,{id:"checkInInterval",type:"number",min:1,max:60,value:i.general.checkInIntervalMinutes,onChange:b=>h("general","checkInIntervalMinutes",parseInt(b.target.value)||5)}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"How often agents should check in with the orchestrator"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"maxAgents",children:"Max Concurrent Agents"}),c.jsx(gr,{id:"maxAgents",type:"number",min:1,max:50,value:i.general.maxConcurrentAgents,onChange:b=>h("general","maxConcurrentAgents",parseInt(b.target.value)||10)}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Maximum number of agents that can run simultaneously"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"verboseLogging",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Verbose Logging"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Enable detailed logging for debugging"})]}),c.jsx("input",{type:"checkbox",id:"verboseLogging",checked:i.general.verboseLogging,onChange:b=>h("general","verboseLogging",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]})]})]}),c.jsxs("section",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Runtime Commands"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mb-4",children:"Configure the CLI command used to start each runtime. Changes take effect on next agent start."}),c.jsx("div",{className:"space-y-5",children:ote.map(b=>{var p;return c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:`runtime-cmd-${b}`,children:QS[b]}),c.jsx(gr,{id:`runtime-cmd-${b}`,type:"text",value:((p=i.general.runtimeCommands)==null?void 0:p[b])??"",onChange:m=>f(b,m.target.value)})]},b)})})]}),c.jsxs("section",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Chat Settings"}),c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"showRawOutput",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Show Raw Terminal Output"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Display raw terminal output alongside formatted messages"})]}),c.jsx("input",{type:"checkbox",id:"showRawOutput",checked:i.chat.showRawTerminalOutput,onChange:b=>h("chat","showRawTerminalOutput",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"typingIndicator",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Enable Typing Indicator"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Show typing animation when agents are processing"})]}),c.jsx("input",{type:"checkbox",id:"typingIndicator",checked:i.chat.enableTypingIndicator,onChange:b=>h("chat","enableTypingIndicator",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"maxHistory",children:"Message History Limit"}),c.jsx(gr,{id:"maxHistory",type:"number",min:10,max:1e4,value:i.chat.maxMessageHistory,onChange:b=>h("chat","maxMessageHistory",parseInt(b.target.value)||1e3)}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Maximum number of messages to keep in chat history"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"autoScroll",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Auto-Scroll to Bottom"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Automatically scroll to new messages"})]}),c.jsx("input",{type:"checkbox",id:"autoScroll",checked:i.chat.autoScrollToBottom,onChange:b=>h("chat","autoScrollToBottom",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"showTimestamps",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Show Timestamps"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Display timestamps on chat messages"})]}),c.jsx("input",{type:"checkbox",id:"showTimestamps",checked:i.chat.showTimestamps,onChange:b=>h("chat","showTimestamps",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]})]})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3 pb-4",children:[c.jsx(wt,{variant:"secondary",onClick:y,icon:dP,children:"Reset to Defaults"}),c.jsx(wt,{onClick:g,disabled:!a||u==="saving",icon:u==="saved"?Ba:FC,children:u==="saving"?"Saving...":u==="saved"?"Saved!":u==="error"?"Error - Retry":"Save Changes"})]})]}):null};function lte(n){const[e,t]=N.useState(null),[r,s]=N.useState(!1),[i,o]=N.useState(null),a=N.useCallback(async()=>{if(!n){t(null),s(!1);return}s(!0),o(null);try{const u=await _a.getRole(n);t(u)}catch(u){o(u instanceof Error?u.message:"Failed to load role"),t(null)}finally{s(!1)}},[n]),l=N.useCallback(async()=>{await a()},[a]);return N.useEffect(()=>{a()},[a]),{role:e,isLoading:r,error:i,refreshRole:l}}const cte=({roleId:n,onClose:e,onSave:t})=>{const{role:r,isLoading:s}=lte(n),{skills:i}=gy(),[o,a]=N.useState({name:"",displayName:"",description:"",category:"development",systemPromptContent:"",assignedSkills:[],isDefault:!1}),[l,u]=N.useState(!1),[d,h]=N.useState(null),f=n===null,g=(r==null?void 0:r.isBuiltin)??!1,y=(r==null?void 0:r.hasOverride)??!1;N.useEffect(()=>{r&&a({name:r.name,displayName:r.displayName,description:r.description,category:r.category,systemPromptContent:r.systemPromptContent||"",assignedSkills:r.assignedSkills,isDefault:r.isDefault})},[r]);const b=(v,w)=>{a(C=>({...C,[v]:w})),h(null)},p=v=>{a(w=>({...w,assignedSkills:w.assignedSkills.includes(v)?w.assignedSkills.filter(C=>C!==v):[...w.assignedSkills,v]}))},m=async v=>{v.preventDefault(),h(null),u(!0);try{f?await t({name:o.name,displayName:o.displayName,description:o.description,category:o.category,systemPromptContent:o.systemPromptContent,assignedSkills:o.assignedSkills,isDefault:o.isDefault}):await t({displayName:o.displayName,description:o.description,category:o.category,systemPromptContent:o.systemPromptContent,assignedSkills:o.assignedSkills,isDefault:o.isDefault}),e()}catch(w){h(w instanceof Error?w.message:"Failed to save role")}finally{u(!1)}},x=v=>{v.target===v.currentTarget&&e()};return s&&n?c.jsx("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:x,children:c.jsx("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg p-8",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"}),c.jsx("p",{className:"text-text-secondary-dark",children:"Loading role..."})]})})}):c.jsx("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:x,children:c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-2xl m-4 max-h-[90vh] overflow-hidden flex flex-col",onClick:v=>v.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark sticky top-0 bg-surface-dark z-10",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold text-text-primary-dark",children:f?"Create Role":"Edit Role"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mt-1",children:f?"Configure a new agent role":"Modify role settings and prompt"})]}),c.jsx(Ci,{icon:Mr,onClick:e,variant:"ghost","aria-label":"Close"})]}),g&&!f&&c.jsxs("div",{className:"mx-6 mt-4 bg-blue-500/10 border border-blue-500/30 text-blue-400 px-4 py-3 rounded-lg text-sm",children:[c.jsx("strong",{children:"Built-in Role:"})," Changes will be saved as a user override. You can reset to defaults anytime.",y&&c.jsx("span",{className:"ml-1",children:"(Currently has user override)"})]}),d&&c.jsx("div",{className:"mx-6 mt-4 bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg text-sm",children:d}),c.jsxs("form",{onSubmit:m,className:"flex-1 overflow-y-auto",children:[c.jsxs("div",{className:"p-6 border-b border-border-dark space-y-4",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:"Basic Information"}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"displayName",required:!0,children:"Display Name"}),c.jsx(gr,{id:"displayName",type:"text",value:o.displayName,onChange:v=>b("displayName",v.target.value),disabled:!1,required:!0,placeholder:"e.g., Senior Developer"})]}),f&&c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"name",required:!0,children:"Internal Name"}),c.jsx(gr,{id:"name",type:"text",value:o.name,onChange:v=>b("name",v.target.value.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")),pattern:"[a-z0-9-]+",required:!0,placeholder:"e.g., senior-developer"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Lowercase letters, numbers, and hyphens only"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"description",children:"Description"}),c.jsx(Da,{id:"description",value:o.description,onChange:v=>b("description",v.target.value),disabled:!1,rows:2,placeholder:"Brief description of this role's responsibilities"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"category",children:"Category"}),c.jsx(go,{id:"category",value:o.category,onChange:v=>b("category",v.target.value),disabled:!1,children:cz.map(v=>c.jsx("option",{value:v,children:eA[v]},v))})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{id:"isDefault",type:"checkbox",checked:o.isDefault,onChange:v=>b("isDefault",v.target.checked),disabled:!1,className:"w-4 h-4 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"}),c.jsx("label",{htmlFor:"isDefault",className:"text-sm text-text-primary-dark cursor-pointer",children:"Set as default role"})]})]}),c.jsxs("div",{className:"p-6 border-b border-border-dark space-y-4",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:"System Prompt"}),c.jsxs("div",{children:[c.jsx(Da,{id:"systemPrompt",value:o.systemPromptContent,onChange:v=>b("systemPromptContent",v.target.value),disabled:!1,rows:12,placeholder:`# Role Name
4913
+ `))),{vertexShader:t,fragmentShader:r}}});return e.transparent=!0,e.forceSinglePass=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const s2=new Zs({color:16777215,side:Tn,transparent:!0}),KR=8421504,JR=new Rt,C0=new se,US=new se,If=[],RY=new se,HS="+x+y";function qR(n){return Array.isArray(n)?n[0]:n}let oD=()=>{const n=new kn(new ta(1,1),s2);return oD=()=>n,n},aD=()=>{const n=new kn(new ta(1,1,32,1),s2);return aD=()=>n,n};const NY={type:"syncstart"},IY={type:"synccomplete"},lD=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],PY=lD.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let cD=class extends kn{constructor(){const e=new CY;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=KR,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=HS,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(NY),nD({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const r=this._queuedSyncs;r&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{r.forEach(s=>s&&s())})),this.dispatchEvent(IY),e&&e()})))}onBeforeRender(e,t,r,s,i,o){this.sync(),i.isTroikaTextMaterial&&this._prepareForRender(i)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return kY(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=s2.clone());if((!e||!e.isDerivedFrom(t))&&(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function r(){t.removeEventListener("dispose",r),e.dispose()})),this.hasOutline()){let r=e._outlineMtl;return r||(r=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),r.isTextOutlineMaterial=!0,r.depthWrite=!1,r.map=null,e.addEventListener("dispose",function s(){e.removeEventListener("dispose",s),r.dispose()})),[r,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}hasOutline(){return!!(this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY)}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return qR(this.material).getDepthMaterial()}set customDepthMaterial(e){}get customDistanceMaterial(){return qR(this.material).getDistanceMaterial()}set customDistanceMaterial(e){}_prepareForRender(e){const t=e.isTextOutlineMaterial,r=e.uniforms,s=this.textRenderInfo;if(s){const{sdfTexture:a,blockBounds:l}=s;r.uTroikaSDFTexture.value=a,r.uTroikaSDFTextureSize.value.set(a.image.width,a.image.height),r.uTroikaSDFGlyphSize.value=s.sdfGlyphSize,r.uTroikaSDFExponent.value=s.sdfExponent,r.uTroikaTotalBounds.value.fromArray(l),r.uTroikaUseGlyphColors.value=!t&&!!s.glyphColors;let u=0,d=0,h=0,f,g,y,b=0,p=0;if(t){let{outlineWidth:x,outlineOffsetX:v,outlineOffsetY:w,outlineBlur:C,outlineOpacity:M}=this;u=this._parsePercent(x)||0,d=Math.max(0,this._parsePercent(C)||0),f=M,b=this._parsePercent(v)||0,p=this._parsePercent(w)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(y=this.strokeColor,r.uTroikaStrokeColor.value.set(y??KR),g=this.strokeOpacity,g==null&&(g=1)),f=this.fillOpacity;r.uTroikaEdgeOffset.value=u,r.uTroikaPositionOffset.value.set(b,p),r.uTroikaBlurRadius.value=d,r.uTroikaStrokeWidth.value=h,r.uTroikaStrokeOpacity.value=g,r.uTroikaFillOpacity.value=f??1,r.uTroikaCurveRadius.value=this.curveRadius||0;let m=this.clipRect;if(m&&Array.isArray(m)&&m.length===4)r.uTroikaClipRect.value.fromArray(m);else{const x=(this.fontSize||.1)*100;r.uTroikaClipRect.value.set(l[0]-x,l[1]-x,l[2]+x,l[3]+x)}this.geometry.applyClipRect(r.uTroikaClipRect.value)}r.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const i=t?this.outlineColor||0:this.color;if(i==null)delete e.color;else{const a=e.hasOwnProperty("color")?e.color:e.color=new ct;(i!==a._input||typeof i=="object")&&a.set(a._input=i)}let o=this.orientation||HS;if(o!==e._orientation){let a=r.uTroikaOrient.value;o=o.replace(/[^-+xyz]/g,"");let l=o!==HS&&o.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,u,d,h,f]=l;C0.set(0,0,0)[d]=u==="-"?1:-1,US.set(0,0,0)[f]=h==="-"?-1:1,JR.lookAt(RY,C0.cross(US),US),a.setFromMatrix4(JR)}else a.identity();e._orientation=o}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),r=t?parseFloat(t[1]):NaN;e=(isNaN(r)?0:r/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new Qe){t.copy(e);const r=this.curveRadius;return r&&(t.x=Math.atan2(e.x,Math.abs(r)-Math.abs(e.z))*Math.abs(r)),t}worldPositionToTextCoords(e,t=new Qe){return C0.copy(e),this.localPositionToTextCoords(this.worldToLocal(C0),t)}raycast(e,t){const{textRenderInfo:r,curveRadius:s}=this;if(r){const i=r.blockBounds,o=s?aD():oD(),a=o.geometry,{position:l,uv:u}=a.attributes;for(let d=0;d<u.count;d++){let h=i[0]+u.getX(d)*(i[2]-i[0]);const f=i[1]+u.getY(d)*(i[3]-i[1]);let g=0;s&&(g=s-Math.cos(h/s)*s,h=Math.sin(h/s)*s),l.setXYZ(d,h,f,g)}a.boundingSphere=this.geometry.boundingSphere,a.boundingBox=this.geometry.boundingBox,o.matrixWorld=this.matrixWorld,o.material.side=this.material.side,If.length=0,o.raycast(e,If);for(let d=0;d<If.length;d++)If[d].object=this,t.push(If[d])}}copy(e){const t=this.geometry;return super.copy(e),this.geometry=t,PY.forEach(r=>{this[r]=e[r]}),this}clone(){return new this.constructor().copy(this)}};lD.forEach(n=>{const e="_private_"+n;Object.defineProperty(cD.prototype,n,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});new cr;new ct;const ap=N.forwardRef(({sdfGlyphSize:n=64,anchorX:e="center",anchorY:t="middle",font:r,fontSize:s=1,children:i,characters:o,onSync:a,...l},u)=>{const d=gs(({invalidate:y})=>y),[h]=N.useState(()=>new cD),[f,g]=N.useMemo(()=>{const y=[];let b="";return N.Children.forEach(i,p=>{typeof p=="string"||typeof p=="number"?b+=p:y.push(p)}),[y,b]},[i]);return _B(()=>new Promise(y=>vY({font:r,characters:o},y)),["troika-text",r,o]),N.useLayoutEffect(()=>void h.sync(()=>{d(),a&&a(h)})),N.useEffect(()=>()=>h.dispose(),[h]),N.createElement("primitive",Su({object:h,ref:u,font:r,text:g,anchorX:e,anchorY:t,fontSize:s,sdfGlyphSize:n},l),f)});let A0=null,uD="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function dD(n=!0,e=!0,t){return r=>{t&&t(r),n&&(A0||(A0=new L$),A0.setDecoderPath(typeof n=="string"?n:uD),r.setDRACOLoader(A0)),e&&r.setMeshoptDecoder(typeof OS=="function"?OS():OS)}}const On=(n,e,t,r)=>xm(e2,n,dD(e,t,r));On.preload=(n,e,t,r)=>xm.preload(e2,n,dD(e,t,r));On.clear=n=>xm.clear(e2,n);On.setDecoderPath=n=>{uD=n};var hD={exports:{}};(function(n,e){(function(t,r){n.exports=r()})(r4,function(){var t=function(){function r(g){return o.appendChild(g.dom),g}function s(g){for(var y=0;y<o.children.length;y++)o.children[y].style.display=y===g?"block":"none";i=g}var i=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(g){g.preventDefault(),s(++i%o.children.length)},!1);var a=(performance||Date).now(),l=a,u=0,d=r(new t.Panel("FPS","#0ff","#002")),h=r(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var f=r(new t.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:o,addPanel:r,showPanel:s,begin:function(){a=(performance||Date).now()},end:function(){u++;var g=(performance||Date).now();if(h.update(g-a,200),g>l+1e3&&(d.update(1e3*u/(g-l),100),l=g,u=0,f)){var y=performance.memory;f.update(y.usedJSHeapSize/1048576,y.jsHeapSizeLimit/1048576)}return g},update:function(){a=this.end()},domElement:o,setMode:s}};return t.Panel=function(r,s,i){var o=1/0,a=0,l=Math.round,u=l(window.devicePixelRatio||1),d=80*u,h=48*u,f=3*u,g=2*u,y=3*u,b=15*u,p=74*u,m=30*u,x=document.createElement("canvas");x.width=d,x.height=h,x.style.cssText="width:80px;height:48px";var v=x.getContext("2d");return v.font="bold "+9*u+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=i,v.fillRect(0,0,d,h),v.fillStyle=s,v.fillText(r,f,g),v.fillRect(y,b,p,m),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(y,b,p,m),{dom:x,update:function(w,C){o=Math.min(o,w),a=Math.max(a,w),v.fillStyle=i,v.globalAlpha=1,v.fillRect(0,0,d,b),v.fillStyle=s,v.fillText(l(w)+" "+r+" ("+l(o)+"-"+l(a)+")",f,g),v.drawImage(x,y+u,b,p-u,m,y,b,p-u,m),v.fillRect(y+p-u,b,u,m),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(y+p-u,b,u,l((1-w/C)*m))}}},t})})(hD);var LY=hD.exports;const jY=zw(LY);function $R(n,e){typeof n=="function"?n(e):n!=null&&(n.current=e)}function BY(n,e=[],t){const[r,s]=N.useState();return N.useLayoutEffect(()=>{const i=n();return s(i),$R(t,i),()=>$R(t,null)},e),r}function DY({showPanel:n=0,className:e,parent:t}){const r=BY(()=>new jY,[]);return N.useEffect(()=>{if(r){const s=t&&t.current||document.body;r.showPanel(n),s==null||s.appendChild(r.dom);const i=(e??"").split(" ").filter(l=>l);i.length&&r.dom.classList.add(...i);const o=Cq(()=>r.begin()),a=Aq(()=>r.end());return()=>{i.length&&r.dom.classList.remove(...i),s==null||s.removeChild(r.dom),o(),a()}}},[t,r,e,n]),null}function Zy(n,e){const t=N.useRef(),[r]=N.useState(()=>e?e instanceof on?{current:e}:e:t),[s]=N.useState(()=>new JA(void 0));N.useLayoutEffect(()=>{e&&(r.current=e instanceof on?e:e.current),s._root=r.current});const i=N.useRef({}),o=N.useMemo(()=>{const a={};return n.forEach(l=>Object.defineProperty(a,l.name,{enumerable:!0,get(){if(r.current)return i.current[l.name]||(i.current[l.name]=s.clipAction(l,r.current))},configurable:!0})),{ref:r,clips:n,actions:a,names:n.map(l=>l.name),mixer:s}},[n]);return vr((a,l)=>s.update(l)),N.useEffect(()=>{const a=r.current;return()=>{i.current={},s.stopAllAction(),Object.values(o.actions).forEach(l=>{a&&s.uncacheAction(l,a)})}},[n]),o}const Oo=1e-5;function OY(n,e,t){const r=new Xo,s=t-Oo;return r.absarc(Oo,Oo,Oo,-Math.PI/2,-Math.PI,!0),r.absarc(Oo,e-s*2,Oo,Math.PI,Math.PI/2,!0),r.absarc(n-s*2,e-s*2,Oo,Math.PI/2,0,!0),r.absarc(n-s*2,Oo,Oo,0,-Math.PI/2,!0),r}const Ov=N.forwardRef(function({args:[e=1,t=1,r=1]=[],radius:s=.05,steps:i=1,smoothness:o=4,bevelSegments:a=4,creaseAngle:l=.4,children:u,...d},h){const f=N.useMemo(()=>OY(e,t,s),[e,t,s]),g=N.useMemo(()=>({depth:r-s*2,bevelEnabled:!0,bevelSegments:a*2,steps:i,bevelSize:s-Oo,bevelThickness:s,curveSegments:o}),[r,s,o]),y=N.useRef(null);return N.useLayoutEffect(()=>{y.current&&(y.current.center(),Jq(y.current,l))},[f,g]),N.createElement("mesh",Su({ref:h},d),N.createElement("extrudeGeometry",{ref:y,args:[f,g]}),u)});function FY({all:n,scene:e,camera:t}){const r=gs(({gl:o})=>o),s=gs(({camera:o})=>o),i=gs(({scene:o})=>o);return N.useLayoutEffect(()=>{const o=[];n&&(e||i).traverse(u=>{u.visible===!1&&(o.push(u),u.visible=!0)}),r.compile(e||i,t||s);const a=new Ry(128);new yA(.01,1e5,a).update(r,e||i),a.dispose(),o.forEach(u=>u.visible=!1)},[]),null}function UY({pixelated:n}){const e=gs(o=>o.gl),t=gs(o=>o.internal.active),r=gs(o=>o.performance.current),s=gs(o=>o.viewport.initialDpr),i=gs(o=>o.setDpr);return N.useEffect(()=>{const o=e.domElement;return()=>{t&&i(s),n&&o&&(o.style.imageRendering="auto")}},[]),N.useEffect(()=>{i(r*s),n&&e.domElement&&(e.domElement.style.imageRendering=r===1?"auto":"pixelated")},[r]),null}function HY(){const n=gs(r=>r.get),e=gs(r=>r.setEvents),t=gs(r=>r.performance.current);return N.useEffect(()=>{const r=n().events.enabled;return()=>e({enabled:r})},[]),N.useEffect(()=>e({enabled:t===1}),[t]),null}const Dd=[3825546,9058911,6261306,9068346,6240906,3836511],yh={day:{background:15267068,fog:15267068,wallColor:16119287,floorColor:9079434,ambientIntensity:.7,sunIntensity:1.2},night:{background:657938,fog:657938,wallColor:1710623,floorColor:1710624,ambientIntensity:.15,sunIntensity:0}},nt={ZONE:{WIDTH:10,DEPTH:7,ZONES_PER_ROW:3,START_X:-14,START_Z:8,GAP_X:4,GAP_Z:3},WORKSTATION_POSITIONS:[{x:-3,z:1.5},{x:3,z:1.5},{x:-3,z:-1},{x:3,z:-1}],CAMERA:{DEFAULT_POSITION:{x:-28,y:22,z:-18},FOV:60,NEAR:.1,FAR:150,LOOK_SENSITIVITY:.002,MIN_PITCH:-Math.PI/2+.1,MAX_PITCH:Math.PI/2-.1,MOVE_SPEED:15,ZOOM_SPEED:.5,MOUSE_SENSITIVITY:.005,TOUCH_SENSITIVITY:.008},AGENT:{ROBOT_SCALE:.5,WORKSTATION_OFFSET:.8,ANIMATION_FADE_DURATION:.5},WALLS:{HEIGHT:12,THICKNESS:.3,BACK_X:-32,LEFT_Z:-22,RIGHT_Z:22,FRONT_X:32},BREAK_ROOM:{POSITION:{x:-26,y:0,z:-14}},POKER_TABLE:{POSITION:{x:26,y:0,z:-14}},STAGE:{POSITION:{x:26,y:0,z:4},WIDTH:8,DEPTH:5,HEIGHT:.4,ROTATION:-Math.PI/2,AUDIENCE_POSITIONS:[{x:18,z:2},{x:18,z:6},{x:20,z:0},{x:20,z:4},{x:20,z:8}]},LOUNGE:{POSITION:{x:-26,y:0,z:14},COUCH_POSITIONS:[{x:-2,z:0,rotation:Math.PI/2},{x:2,z:0,rotation:-Math.PI/2}]},KITCHEN:{POSITION:{x:-27,y:0,z:3},SEAT_POSITIONS:[{x:-1,z:1.8,rotation:Math.PI},{x:0,z:1.8,rotation:Math.PI},{x:1,z:1.8,rotation:Math.PI},{x:-.5,z:-1.8,rotation:0},{x:.5,z:-1.8,rotation:0}]},ANIMATION:{FOCUS_DURATION:1500,BOSS_MODE_INTERVAL:8e3},API:{POLL_INTERVAL:5e3,USAGE_POLL_INTERVAL:3e4},MOVEMENT:{ARRIVAL_DISTANCE:.5,STUCK_THRESHOLD:.01,STUCK_MIN_DISTANCE:2,ROTATION_LERP_SPEED:5,ANIMATION_FADE_DURATION:.3,COUCH_SEAT_HEIGHT:.35},CIRCLE_INDICATOR:{RADIUS_DEFAULT:.7,RADIUS_ACTIVE:.85,SEGMENTS:32,Y_OFFSET:.1},PICKLEBALL:{POSITION:{x:-18,y:0,z:42}},GOLF:{POSITION:{x:18,y:0,z:42}},OUTDOOR_BENCH:{POSITIONS:[{x:-4,z:30,rotation:Math.PI/2},{x:4,z:30,rotation:-Math.PI/2},{x:-4,z:36,rotation:Math.PI/2},{x:4,z:36,rotation:-Math.PI/2}]},NPC_IDS:{STEVE_JOBS:"steve-jobs-npc",SUNDAR_PICHAI:"sundar-pichai-npc",ELON_MUSK:"elon-musk-npc",MARK_ZUCKERBERG:"mark-zuckerberg-npc",JENSEN_HUANG:"jensen-huang-npc",STEVE_HUANG:"steve-huang-npc"}},bn={ROBOT:"/models/employees/robot/RobotExpressive.glb",COW:"/models/employees/cow/cow-fixed.glb?v=3",HORSE:"/models/employees/horse/horse-fixed.glb",TIGER:"/models/employees/tiger/tiger-fixed.glb",RABBIT:"/models/employees/rabbit/rabbit-fixed.glb",STEVE_JOBS:"/models/guests/stevejobs/model.glb",SUNDAR_PICHAI:"/models/guests/sundarpichai/model.glb",ELON_MUSK:"/models/guests/elonmusk/model.glb",MARK_ZUCKERBERG:"/models/guests/markzuckerberg/model.glb",JENSEN_HUANG:"/models/guests/jensenhuang/model.glb?v=2",STEVE_HUANG:"/models/guests/stevehuang/model.glb?v=2",CYBERTRUCK:"/models/objects/cybertruck/model.glb",PUPPY:"/models/pets/puppy/model.glb",ROBOTIC_DOG:"/models/pets/roboticdog/original.glb",SHIBA_INU:"/models/pets/shibainu/model.glb",BULLDOG:"/models/pets/bulldog/model.glb"},gd="/api";class zY{async getFactoryState(){try{const e=await vt.get(`${gd}/factory/state`);return typeof e.data!="object"||e.data===null||!("success"in e.data)?this.buildFactoryStateFromLegacyEndpoints():!e.data.success||!e.data.data?this.buildFactoryStateFromLegacyEndpoints():e.data.data}catch{return this.buildFactoryStateFromLegacyEndpoints()}}async buildFactoryStateFromLegacyEndpoints(){const e=[],t=new Set,r=new Set;try{((await vt.get(`${gd}/teams`)).data.data||[]).forEach(a=>{var u;const l=((u=a.projectIds)==null?void 0:u[0])||a.name||"Unassigned";t.add(l),a.members&&a.members.forEach(d=>{r.add(d.id),e.push({id:d.id,sessionName:d.sessionName,name:d.name,projectName:l,status:this.mapAgentStatus(d.agentStatus,d.workingStatus),cpuPercent:d.workingStatus==="in_progress"?50:0,activity:d.workingStatus==="in_progress"?"Working...":void 0,sessionTokens:0})})})}catch{}try{const o=(await vt.get(`${gd}/factory/claude-instances`)).data;o!=null&&o.instances&&o.instances.forEach(a=>{if(r.has(a.id))return;const l=a.projectName||"Unknown";t.add(l),e.push({id:a.id,sessionName:`claude-${a.pid}`,name:l,projectName:l,status:a.status==="active"?"active":"idle",cpuPercent:a.cpuPercent,activity:a.activity,sessionTokens:a.sessionTokens||0})})}catch{}const s={activeCount:e.filter(i=>i.status==="active").length,idleCount:e.filter(i=>i.status==="idle").length,dormantCount:e.filter(i=>i.status==="dormant").length,totalTokens:e.reduce((i,o)=>i+(o.sessionTokens||0),0)};return{agents:e,projects:Array.from(t),stats:s}}mapAgentStatus(e,t){return e==="inactive"?"dormant":t==="in_progress"?"active":"idle"}async getUsageStats(){try{return(await vt.get(`${gd}/factory/usage`)).data}catch{return{today:{messages:0,tokens:0,toolCalls:0},totals:{sessions:0,messages:0},recentDays:[]}}}async getAgent(e){const t=await vt.get(`${gd}/factory/agents/${e}`);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Agent not found");return t.data.data}async getAgentLogs(e,t=50){var r;try{return((r=(await vt.get(`${gd}/sessions/${e}/logs`,{params:{lines:t}})).data.data)==null?void 0:r.logs)||[]}catch{return[]}}subscribeToUpdates(e){return()=>{}}}const GY=new zY;function WY(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e^n.charCodeAt(t);return Math.abs(e)}const YR=["cow","horse","tiger","rabbit"];function VY(n,e){const r=WY(n)%YR.length;return YR[r]}function XY(n){const e=n??new Date().getHours();return e>=18||e<6}function KY(){const n=new se(-28,22,-18),e=new se(15,2,10),t=e.clone().sub(n),r=Math.atan2(t.x,t.z),s=Math.atan2(t.y,Math.sqrt(t.x*t.x+t.z*t.z));return{yaw:r,pitch:s,position:n,target:e,isAnimating:!1}}function zS(n,e,t){const r=Math.sin(n)*Math.cos(e),s=Math.sin(e),i=Math.cos(n)*Math.cos(e);return t?t.set(r,s,i):new se(r,s,i)}const M0=1.5,E0={minX:nt.WALLS.BACK_X+M0,maxX:nt.WALLS.FRONT_X-M0,minZ:nt.WALLS.LEFT_Z+M0,maxZ:nt.WALLS.RIGHT_Z-M0},Fv=[{minX:-8.5,maxX:8.5,minZ:-15.5,maxZ:-12.5},{minX:-29.5,maxX:-24.5,minZ:-2.5,maxZ:.5},{minX:-29.5,maxX:-24.5,minZ:1.8,maxZ:4.2},{minX:-29.5,maxX:-24.5,minZ:5.5,maxZ:8.5}];function fD(n){const e=[];return n.forEach(t=>{t.workstations.forEach(r=>{e.push({minX:r.position.x-1.8,maxX:r.position.x+1.8,minZ:r.position.z-1.5,maxZ:r.position.z+2})})}),e}function lp(n,e,t){for(const r of t)if(n>=r.minX&&n<=r.maxX&&e>=r.minZ&&e<=r.maxZ)return!0;return!1}function $c(n,e){return{x:Math.max(E0.minX,Math.min(E0.maxX,n)),z:Math.max(E0.minZ,Math.min(E0.maxZ,e))}}function Uw(n,e,t,r,s){const i=$c(n,e);if(!lp(i.x,i.z,s))return i;const o=$c(i.x,r);if(!lp(o.x,o.z,s))return o;const a=$c(t,i.z);return lp(a.x,a.z,s)?$c(t,r):a}function pD(n,e,t){const r=$c(n,e);return Math.abs(r.x-n)>.01||Math.abs(r.z-e)>.01?!1:!lp(n,e,t)}const QR=1.5;function i2(n,e,t,r){const s=QR*QR;for(const[i,o]of r){if(i===t)continue;const a=n-o.x,l=e-o.z;if(a*a+l*l<s)return!0}return!1}function JY(n,e){const t=new Map;return n.forEach((r,s)=>{const i=r.currentPosition||r.basePosition;t.set(s,{x:i.x,z:i.z})}),e.forEach((r,s)=>{t.set(s,{x:r.x,z:r.z})}),t}function lx(n,e=18,t=18,r=0,s=0,i=15){for(let o=0;o<i;o++){const a=r+(Math.random()-.5)*e*2,l=s+(Math.random()-.5)*t*2;if(pD(a,l,n))return{x:a,z:l}}return $c(r,s)}const qY=5,T0=5e3,GS=2e3,ZR=3500,$Y=500,YY=10,QY=3e4,ZY=["Hey!","Hi!","Hello!","What's up?","Hey there!","Yo!","Hi there!","Howdy!","Sup!","What's good?"],WS=[["How's your project going?","Pretty good, making progress!"],["Taking a break?","Yeah, needed one!"],["The boss seems happy today","Ha, let's hope it lasts!"],["Did you see that demo?","Yeah, it was impressive!"],["Coffee break?","Always down for coffee!"],["Any blockers?","Nah, smooth sailing!"],["Working late tonight?","Hope not!"],["Nice code review earlier","Thanks, yours too!"],["Tried the new API yet?","Yeah, it's way faster!"],["Stand-up was short today","Best kind of stand-up!"],["PR looks good to me","Thanks for reviewing!"],["Lunch plans?","Thinking tacos, you in?"]],eQ=["One more thing...","Hey, got a minute?","Think different!","You know what...","Let's talk!"],tQ=[["Is it insanely great yet?","Getting close!"],["Simplicity is the ultimate sophistication","Totally agree!"],["Focus on what truly matters","Good advice!"],["Design is how it works","So true!"],["Let's put a dent in the universe","I'm in!"],["Real artists ship","Shipping soon!"],["Innovation needs courage","You're right!"],["Stay hungry, stay foolish","Always!"],["The journey is the reward","Love that!"],["Quality over quantity, always","Agreed!"]],nQ=["Hey team!","Good to see you!","How's everything?","Quick sync?","Let's connect!"],rQ=[["AI is reshaping everything","It really is!"],["Let's think about scale","Good point!"],["User trust is our foundation","Absolutely!"],["Have you tried Gemini yet?","It's impressive!"],["Cloud-first, always","Makes sense!"],["Openness drives innovation","So true!"],["Let's make tech accessible to all","Great vision!"],["Data tells the real story","Facts!"],["10x thinking, not 10%","Love that mindset!"],["What's the user impact?","Significant!"]],sQ=["TSLA to the moon!","Hey, quick question!","First principles!","Yo, got a sec?","Let me tell you..."],iQ=[["Tesla stock is up today!","Nice, congrats!"],["SpaceX launch was amazing!","That was incredible!"],["Starship blew up again...","Oh no! Next time!"],["Rapid unscheduled disassembly","Ha, classic!"],["Full self driving, almost there","Can't wait to try it!"],["We're going to Mars!","When do we leave?"],["The Cybertruck is selling!","It's wild looking!"],["X is the everything app now","That's ambitious!"],["Need to ship this 10x faster","On it!"],["Boring tunnels under the factory?","That'd be cool!"]],oQ=["Hey, try this headset!","Is this VR or real?","Meta connect!","Quick, put on Quest!","Open source everything!"],aQ=[["Have you tried Meta Quest?","Not yet, is it good?"],["The metaverse is the future!","Interesting vision!"],["Llama 4 is crushing benchmarks","That's impressive!"],["I can't see clearly, VR blur","Maybe take the headset off?"],["Everything should be in VR","Even this meeting?"],["Wait, is this real or virtual?","It's real, Zuck!"],["Open source AI wins every time","Agreed!"],["Sweet Baby Rays is the best","Ha, you and BBQ sauce!"],["Llama beats the competition","The benchmarks look great!"],["We should do this in the metaverse","Let's stay in reality!"]],lQ=["GPU goes brrr!","Hey, need compute?","CUDA powers all!","The more you buy...","Accelerated computing!"],cQ=[["Everyone's buying our GPUs!","Business is booming!"],["NVDA stock, all time high!","Incredible run!"],["H100s are sold out again!","The demand is insane!"],["You using CUDA for this?","Of course!"],["The more you buy, more you save!","Great sales pitch!"],["AI needs more compute power","Always more GPUs!"],["Blackwell is our best chip yet","The benchmarks are wild!"],["Every data center needs us","You're not wrong!"],["Leather jacket weather today","Looking sharp, Jensen!"],["Inference at scale is everything","Totally agree!"]],uQ=["Hey, how are things?","What's going on?","Just checking in!","Hey there!","How goes it?"],dQ=[["How's everything going?","Going great, thanks!"],["I built this whole factory","It's amazing!"],["Crewly is coming along","Looks awesome!"],["Need anything from me?","We're good, thanks!"],["Just making the rounds","Good to see you!"],["The codebase is looking clean","Thanks for the review!"],["Nice weather for golf later","Sounds fun!"],["Keep up the great work","Will do!"],["Any feedback for me?","Everything's solid!"],["Love seeing the progress","Team's crushing it!"]],e3={"steve-jobs-npc":{greetings:eQ,smallTalk:tQ},"sundar-pichai-npc":{greetings:nQ,smallTalk:rQ},"elon-musk-npc":{greetings:sQ,smallTalk:iQ},"mark-zuckerberg-npc":{greetings:oQ,smallTalk:aQ},"jensen-huang-npc":{greetings:lQ,smallTalk:cQ},"steve-huang-npc":{greetings:uQ,smallTalk:dQ}},mD=N.createContext(void 0),hQ=({children:n})=>{const[e,t]=N.useState(new Map),[r,s]=N.useState(new Map),[i,o]=N.useState([]),[a,l]=N.useState(KY),[u,d]=N.useState("day"),[h,f]=N.useState({isActive:!1,mode:"auto",currentTargetIndex:0,targets:[],timeAtTarget:0,targetDuration:nt.ANIMATION.BOSS_MODE_INTERVAL,orbitAngle:0,orbitRadius:6,orbitHeight:4}),[g,y]=N.useState(!0),[b,p]=N.useState(null),m=N.useRef(new Map([["couch",new Set],["break_room",new Set],["poker_table",new Set],["kitchen",new Set]])),x=N.useRef(null),v={couch:2,break_room:4,poker_table:4,kitchen:5},[w,C]=N.useState(new Map),[M,T]=N.useState(null),[A,E]=N.useState(null),[R]=N.useState(!1),j=N.useRef(null),[L,D]=N.useState(!0),[z,q]=N.useState(!0),[X,K]=N.useState(!0),[I,B]=N.useState(new Map),F=N.useRef(new Map),O=N.useCallback((xe,Ce)=>{F.current.set(xe,Ce)},[]),W=N.useCallback(xe=>{const Ce=F.current.get(xe)??null;return Ce&&F.current.delete(xe),Ce},[]),J=N.useCallback(xe=>{j.current=xe},[]),$=N.useMemo(()=>u==="day"?!1:u==="night"?!0:XY(),[u]),ie=N.useMemo(()=>{let xe=0,Ce=0,Ze=0,he=0;const je=new Map;e.forEach($e=>{switch($e.status){case"active":xe++;break;case"idle":Ce++;break;case"dormant":Ze++;break}he+=$e.sessionTokens,je.set($e.projectName,(je.get($e.projectName)||0)+$e.sessionTokens)});const ke=Array.from(je.entries()).map(([$e,Ie],Re)=>{const Fe=r.get($e);return{projectName:$e,tokens:Ie,color:(Fe==null?void 0:Fe.color)||Dd[Re%Dd.length]}}).sort(($e,Ie)=>Ie.tokens-$e.tokens);return{activeCount:xe,idleCount:Ce,dormantCount:Ze,totalTokens:he,tokensByProject:ke}},[e,r]),oe=N.useCallback(async()=>{try{const xe=await GY.getFactoryState(),Ce=new Map,Ze=[...new Set(xe.agents.map(ke=>ke.projectName))].sort();Ze.forEach((ke,$e)=>{const Ie=nt.ZONE.ZONES_PER_ROW,Re=Math.floor($e/Ie),Fe=$e%Ie,rt=nt.ZONE.START_X+Fe*(nt.ZONE.WIDTH+nt.ZONE.GAP_X),it=nt.ZONE.START_Z-Re*(nt.ZONE.DEPTH+nt.ZONE.GAP_Z);Ce.set(ke,{projectName:ke,zoneIndex:$e,zoneX:rt,zoneZ:it,color:Dd[$e%Dd.length],workstations:nt.WORKSTATION_POSITIONS.map((ft,Qt)=>({position:{x:rt+ft.x,z:it+ft.z},index:$e*4+Qt,isActive:!1}))})});const he=new Map,je=new Map;xe.agents.forEach(ke=>{const $e=Ce.get(ke.projectName);if(!$e)return;const Ie=je.get(ke.projectName)||0;je.set(ke.projectName,Ie+1);const Re=Ie%4,Fe=$e.workstations[Re];if(!Fe)return;Fe.assignedAgentId=ke.id,Fe.isActive=ke.status==="active";const rt={id:ke.id,projectName:ke.projectName,status:ke.status,cpuPercent:ke.cpuPercent,activity:ke.activity,sessionTokens:ke.sessionTokens||0,zoneIndex:$e.zoneIndex,workstationIndex:Re,animalType:VY(ke.projectName,Ie),basePosition:new se(Fe.position.x,0,Fe.position.z+.45),sessionName:ke.sessionName,name:ke.name};he.set(ke.id,rt)}),s(Ce),t(he),o(Ze),p(null)}catch(xe){p(xe instanceof Error?xe.message:"Failed to fetch factory state")}finally{y(!1)}},[]),U=N.useCallback(xe=>{if(xe==="overview")l(Ce=>({...Ce,isAnimating:!0,animationTarget:{position:new se(-28,22,-18),lookAt:new se(15,2,10),duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:Ce.position.clone(),startLookAt:Ce.target.clone()}}));else if(xe==="birdseye")l(Ce=>({...Ce,isAnimating:!0,animationTarget:{position:new se(0,40,15),lookAt:new se(-5,0,-5),duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:Ce.position.clone(),startLookAt:Ce.target.clone()}}));else if(xe==="outdoor")l(Ce=>({...Ce,isAnimating:!0,animationTarget:{position:new se(0,18,55),lookAt:new se(0,18,22),duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:Ce.position.clone(),startLookAt:Ce.target.clone()}}));else{const Ce=r.get(xe);if(Ce){const Ze=new se(Ce.zoneX-8,8,Ce.zoneZ+8),he=new se(Ce.zoneX,.5,Ce.zoneZ);l(je=>({...je,isAnimating:!0,animationTarget:{position:Ze,lookAt:he,duration:nt.ANIMATION.FOCUS_DURATION,startTime:Date.now(),startPosition:je.position.clone(),startLookAt:je.target.clone()}}))}}},[r]),te=N.useCallback(xe=>{l(Ce=>({...Ce,...xe}))},[]),ue=N.useCallback(()=>{const xe=[];e.forEach(Re=>{const Fe=Re.currentPosition||Re.basePosition;xe.push({id:Re.id,name:Re.name||Re.sessionName||Re.id,type:"agent",position:{x:Fe.x,y:Fe.y,z:Fe.z}})});const Ce=w.get("steve-jobs-npc");xe.push({id:"steve-jobs-npc",name:"Steve Jobs",type:"npc",position:Ce?{x:Ce.x,y:Ce.y,z:Ce.z}:{x:0,y:0,z:5}});const Ze=w.get("sundar-pichai-npc");xe.push({id:"sundar-pichai-npc",name:"Sundar Pichai",type:"npc",position:Ze?{x:Ze.x,y:Ze.y,z:Ze.z}:{x:10,y:0,z:0}});const he=w.get("jensen-huang-npc");xe.push({id:"jensen-huang-npc",name:"Jensen Huang",type:"npc",position:he?{x:he.x,y:he.y,z:he.z}:{x:-5,y:0,z:5}});const je=w.get("elon-musk-npc");xe.push({id:"elon-musk-npc",name:"Elon Musk",type:"npc",position:je?{x:je.x,y:je.y,z:je.z}:{x:4,y:0,z:50}});const ke=w.get("mark-zuckerberg-npc");xe.push({id:"mark-zuckerberg-npc",name:"Mark Zuckerberg",type:"npc",position:ke?{x:ke.x,y:ke.y,z:ke.z}:{x:18,y:0,z:38}});const $e=w.get("steve-huang-npc");xe.push({id:"steve-huang-npc",name:"Steve Huang",type:"npc",position:$e?{x:$e.x,y:$e.y,z:$e.z}:{x:16,y:0,z:44}});const Ie=nt.STAGE.AUDIENCE_POSITIONS;return Ie.forEach((Re,Fe)=>{const rt=`fake-audience-${Fe}`,it=w.get(rt);xe.push({id:rt,name:`Audience ${Fe+1}`,type:"npc",position:it?{x:it.x,y:it.y,z:it.z}:{x:Ie[Fe].x,y:0,z:Ie[Fe].z}})}),xe},[e,w]);N.useCallback(xe=>{const Ze=xe.type==="npc"?{x:-7,y:7,z:7}:{x:-4,y:4,z:4},he=new se(xe.position.x+Ze.x,xe.position.y+Ze.y,xe.position.z+Ze.z),je=new se(xe.position.x,xe.position.y+1.5,xe.position.z);l(ke=>({...ke,isAnimating:!0,animationTarget:{position:he,lookAt:je,duration:1500,startTime:Date.now(),startPosition:ke.position.clone(),startLookAt:ke.target.clone()}}))},[]);const ee=N.useCallback(()=>{f(xe=>xe.isActive?(U("overview"),{...xe,isActive:!1,targets:[],orbitAngle:0}):{isActive:!0,mode:"auto",currentTargetIndex:0,targets:ue(),timeAtTarget:0,targetDuration:nt.ANIMATION.BOSS_MODE_INTERVAL,orbitAngle:0,orbitRadius:6,orbitHeight:4})},[ue,U]),pe=N.useCallback(xe=>{f(Ce=>({...Ce,mode:xe}))},[]),Z=N.useCallback(()=>{f(xe=>{if(!xe.isActive||xe.targets.length===0)return xe;const Ce=(xe.currentTargetIndex+1)%xe.targets.length;return{...xe,currentTargetIndex:Ce,orbitAngle:0,timeAtTarget:0}})},[]),be=N.useCallback(()=>{f(xe=>{if(!xe.isActive||xe.targets.length===0)return xe;const Ce=xe.currentTargetIndex===0?xe.targets.length-1:xe.currentTargetIndex-1;return{...xe,currentTargetIndex:Ce,orbitAngle:0,timeAtTarget:0}})},[]),re=N.useCallback(()=>{var xe;return!h.isActive||h.targets.length===0?"":((xe=h.targets[h.currentTargetIndex])==null?void 0:xe.name)||""},[h]),ce=N.useCallback((xe,Ce)=>{const Ze=m.current.get(xe);if(!Ze)return-1;if(Ze.has(Ce))return Array.from(Ze).indexOf(Ce);const he=v[xe]??0;return Ze.size>=he?-1:(Ze.add(Ce),Array.from(Ze).indexOf(Ce))},[]),le=N.useCallback((xe,Ce)=>{const Ze=m.current.get(xe);Ze&&Ze.delete(Ce)},[]),fe=N.useCallback(xe=>{const Ce=m.current.get(xe);return Ce?Ce.size>=(v[xe]??0):!0},[]),Q=N.useCallback((xe,Ce)=>{const Ze=m.current.get(xe);return!Ze||!Ze.has(Ce)?-1:Array.from(Ze).indexOf(Ce)},[]),Te=N.useCallback(()=>{const xe={};return m.current.forEach((Ce,Ze)=>{xe[Ze]=Ce.size}),xe},[]),we=N.useCallback(xe=>x.current!==null&&x.current!==xe?!1:(x.current=xe,!0),[]),_e=N.useCallback(xe=>{x.current===xe&&(x.current=null)},[]),Me=N.useCallback(()=>x.current!==null,[]),Y=N.useCallback(()=>x.current,[]),G=N.useCallback((xe,Ce)=>{t(Ze=>{const he=Ze.get(xe);if(!he)return Ze;const je=he.currentPosition;if(je&&Math.abs(je.x-Ce.x)<.01&&Math.abs(je.y-Ce.y)<.01&&Math.abs(je.z-Ce.z)<.01)return Ze;const ke=new Map(Ze);return ke.set(xe,{...he,currentPosition:Ce.clone()}),ke})},[]),ae=N.useCallback((xe,Ce)=>{C(Ze=>{const he=Ze.get(xe);if(he&&Math.abs(he.x-Ce.x)<.01&&Math.abs(he.y-Ce.y)<.01&&Math.abs(he.z-Ce.z)<.01)return Ze;const je=new Map(Ze);return je.set(xe,Ce.clone()),je})},[]),Se=N.useCallback(xe=>{T(xe)},[]),ge=N.useCallback(xe=>{E(xe);const Ce=ue(),Ze=Ce.findIndex(he=>he.id===xe);f({isActive:!0,mode:"manual",currentTargetIndex:Math.max(Ze,0),targets:Ce,timeAtTarget:0,targetDuration:nt.ANIMATION.BOSS_MODE_INTERVAL,orbitAngle:0,orbitRadius:6,orbitHeight:4})},[ue]),me=N.useCallback(()=>{E(null),f(xe=>({...xe,isActive:!1,targets:[],orbitAngle:0})),U("overview")},[U]);N.useEffect(()=>{oe()},[oe]),N.useEffect(()=>{const xe=setInterval(oe,nt.API.POLL_INTERVAL);return()=>clearInterval(xe)},[oe]),N.useEffect(()=>{if(u!=="auto")return;const xe=setInterval(()=>{d("auto")},6e4);return()=>clearInterval(xe)},[u]);const ze=N.useRef(e),Oe=N.useRef(w),We=N.useRef(I);ze.current=e,Oe.current=w,We.current=I;const Ge=N.useRef(new Map);Ge.current=N.useMemo(()=>JY(e,w),[e,w]),N.useEffect(()=>{if(!h.isActive||h.targets.length===0)return;const xe=.3,Ce=h.mode==="auto";let Ze=performance.now(),he;const je=()=>{const ke=performance.now(),$e=(ke-Ze)/1e3;Ze=ke,f(Ie=>{if(!Ie.isActive||Ie.targets.length===0)return Ie;const Re=Ie.targets[Ie.currentTargetIndex];if(!Re)return Ie;let Fe=Ie.orbitAngle+xe*$e,rt=Ie.currentTargetIndex;Ce&&Fe>=Math.PI*2&&(Fe=0,rt=(Ie.currentTargetIndex+1)%Ie.targets.length);const it=Ie.targets[rt]||Re;let ft=it.position;if(it.type==="npc"){const ve=Oe.current.get(it.id);ve&&(ft={x:ve.x,y:ve.y,z:ve.z})}else if(it.type==="agent"){const ve=ze.current.get(it.id);ve!=null&&ve.currentPosition&&(ft={x:ve.currentPosition.x,y:ve.currentPosition.y,z:ve.currentPosition.z})}const Qt=it.type==="npc",Mt=Qt?Ie.orbitRadius+4:Ie.orbitRadius,jt=Qt?Ie.orbitHeight+3:Ie.orbitHeight,Dt=ft.x+Mt*Math.cos(Fe),yn=ft.z+Mt*Math.sin(Fe),fn=ft.y+jt;return l(ve=>{const Je=new se(Dt,fn,yn),Ct=new se(ft.x,ft.y+2,ft.z);return{...ve,position:Je,target:Ct,isAnimating:!1}}),{...Ie,orbitAngle:Fe,currentTargetIndex:rt}}),he=requestAnimationFrame(je)};return he=requestAnimationFrame(je),()=>{he&&cancelAnimationFrame(he)}},[h.isActive,h.mode,h.targets.length]);const Le=N.useRef(new Map),Ve=N.useRef(new Map);N.useEffect(()=>{const xe=he=>he.split("").reduce((je,ke)=>je+ke.charCodeAt(0),0),Ce=()=>{const he=ze.current,je=Oe.current,ke=[];if(he.forEach(Mt=>{if(Mt.status==="active")return;const jt=Mt.currentPosition||Mt.basePosition;ke.push({id:Mt.id,x:jt.x,z:jt.z})}),je.forEach((Mt,jt)=>{ke.push({id:jt,x:Mt.x,z:Mt.z})}),ke.length<2){We.current.size>0&&(Le.current.clear(),B(new Map));return}const $e=new Map;for(let Mt=0;Mt<ke.length;Mt++){let jt=1/0,Dt="";for(let yn=0;yn<ke.length;yn++){if(Mt===yn)continue;const fn=ke[Mt].x-ke[yn].x,ve=ke[Mt].z-ke[yn].z,Je=Math.sqrt(fn*fn+ve*ve);Je<jt&&Je<qY&&(jt=Je,Dt=ke[yn].id)}Dt&&$e.set(ke[Mt].id,Dt)}const Ie=new Map,Re=new Set,Fe=Date.now(),rt=Le.current,it=new Set,ft=Ve.current;$e.forEach((Mt,jt)=>{if(Re.has(jt)||$e.get(Mt)!==jt)return;const Dt=[jt,Mt].sort().join(":"),yn=ft.get(Dt);if(yn&&Fe<yn)return;Re.add(jt),Re.add(Mt),it.add(Dt);let fn=rt.get(Dt);fn===void 0&&(fn=Fe,rt.set(Dt,fn));const ve=Fe-fn,Je=ve>=T0,Ct=Math.min(Math.ceil(T0/GS),Math.floor(ve/GS)+1),Vt=Je?Math.floor((ve-T0)/ZR)+1:0;if(Ct+Vt>YY){rt.delete(Dt),ft.set(Dt,Fe+QY),it.delete(Dt);return}const ln=[jt,Mt].sort(),Fn=ln.find(Un=>Un in e3)||null,Tr=Fn?e3[Fn]:null;if(Je){const Un=ve-T0,Wn=Math.floor(Un/ZR),Zn=Wn%2===0;if(Tr&&Fn){const Vn=Math.floor(Wn/2)%Tr.smallTalk.length,er=Tr.smallTalk[Vn],Or=ln.indexOf(Fn);Ie.set(ln[0],{partnerId:ln[1],startTime:fn,isLongDuration:!0,currentLine:Zn?Or===0?er[0]:er[1]:null}),Ie.set(ln[1],{partnerId:ln[0],startTime:fn,isLongDuration:!0,currentLine:Zn?null:Or===1?er[0]:er[1]})}else{const Vn=Math.floor(Wn/2)%WS.length;Ie.set(ln[0],{partnerId:ln[1],startTime:fn,isLongDuration:!0,currentLine:Zn?WS[Vn][0]:null}),Ie.set(ln[1],{partnerId:ln[0],startTime:fn,isLongDuration:!0,currentLine:Zn?null:WS[Vn][1]})}}else{const Un=Math.floor(ve/GS),Zn=Un%2===0?ln[0]:ln[1],Vn=Tr&&Zn===Fn?Tr.greetings:ZY,er=(xe(Zn)+Un)%Vn.length;Ie.set(ln[0],{partnerId:ln[1],startTime:fn,isLongDuration:!1,currentLine:Zn===ln[0]?Vn[er]:null}),Ie.set(ln[1],{partnerId:ln[0],startTime:fn,isLongDuration:!1,currentLine:Zn===ln[1]?Vn[er]:null})}}),rt.forEach((Mt,jt)=>{it.has(jt)||rt.delete(jt)}),ft.forEach((Mt,jt)=>{Fe>=Mt&&ft.delete(jt)});const Qt=Mt=>JSON.stringify(Array.from(Mt.entries()).map(([jt,Dt])=>[jt,Dt.currentLine,Dt.isLongDuration]));Qt(Ie)!==Qt(We.current)&&B(Ie)};Ce();const Ze=setInterval(Ce,$Y);return()=>clearInterval(Ze)},[]);const Xe=N.useMemo(()=>({agents:e,zones:r,camera:a,setCameraTarget:U,lightingMode:u,setLightingMode:d,isNightMode:$,bossModeState:h,toggleBossMode:ee,setBossModeType:pe,bossNextTarget:Z,bossPrevTarget:be,getCurrentTargetName:re,stats:ie,projects:i,isLoading:g,error:b,refreshData:oe,updateCamera:te,claimSeat:ce,releaseSeat:le,isAreaFull:fe,getSeatIndex:Q,getSeatOccupancy:Te,claimStage:we,releaseStage:_e,isStageOccupied:Me,getStagePerformerId:Y,stagePerformerRef:x,seatOccupancyRef:m,updateAgentPosition:G,updateNpcPosition:ae,npcPositions:w,hoveredEntityId:M,selectedEntityId:A,setHoveredEntity:Se,selectEntity:ge,clearSelection:me,entityConversations:I,sendEntityCommand:O,consumeEntityCommand:W,entityPositionMapRef:Ge,freestyleMode:R,setFreestyleMoveTarget:J,showNPCAgents:L,setShowNPCAgents:D,showGuestAgents:z,setShowGuestAgents:q,showObjects:X,setShowObjects:K}),[e,r,a,U,u,$,h,ee,pe,Z,be,re,ie,i,g,b,oe,te,ce,le,fe,Q,Te,we,_e,Me,Y,G,ae,w,M,A,Se,ge,me,I,O,W,R,J,L,z,X]);return c.jsx(mD.Provider,{value:Xe,children:n})},Pt=()=>{const n=N.useContext(mD);if(n===void 0)throw new Error("useFactory must be used within a FactoryProvider");return n},fQ=()=>{const{isNightMode:n}=Pt(),e=N.useRef(null),t=N.useRef(null),r=N.useMemo(()=>n?yh.night:yh.day,[n]);return vr(()=>{if(e.current){const s=r.ambientIntensity;e.current.intensity=Oa.lerp(e.current.intensity,s,.05)}if(t.current){const s=r.sunIntensity;t.current.intensity=Oa.lerp(t.current.intensity,s,.05)}}),c.jsxs(c.Fragment,{children:[c.jsx("ambientLight",{ref:e,color:n?4482730:16777215,intensity:r.ambientIntensity}),c.jsx("directionalLight",{ref:t,color:n?8952268:16777198,intensity:r.sunIntensity,position:[20,30,10],castShadow:!0,"shadow-mapSize-width":2048,"shadow-mapSize-height":2048,"shadow-camera-near":.5,"shadow-camera-far":100,"shadow-camera-left":-40,"shadow-camera-right":40,"shadow-camera-top":40,"shadow-camera-bottom":-40,"shadow-bias":-1e-4}),c.jsx("directionalLight",{color:n?2241365:11189247,intensity:n?.1:.3,position:[-15,10,-10]}),n&&c.jsxs(c.Fragment,{children:[c.jsx("directionalLight",{color:6715306,intensity:.2,position:[-10,20,15]}),c.jsx(pQ,{})]})]})},pQ=()=>{const n=N.useMemo(()=>[{x:-14,z:8},{x:0,z:8},{x:14,z:8},{x:-14,z:-2},{x:0,z:-2},{x:14,z:-2}],[]);return c.jsx(c.Fragment,{children:n.map((e,t)=>c.jsx("pointLight",{color:16777198,intensity:.8,distance:12,decay:2,position:[e.x,3.5,e.z]},t))})},mQ=()=>{const{isNightMode:n}=Pt(),e=N.useRef(null),t=N.useMemo(()=>n?yh.night.floorColor:yh.day.floorColor,[n]);return N.useEffect(()=>{e.current&&e.current.material.color.setHex(t)},[t]),c.jsxs("mesh",{ref:e,rotation:[-Math.PI/2,0,0],position:[0,0,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[70,50]}),c.jsx("meshStandardMaterial",{color:t,roughness:.9,metalness:0})]})},{WALLS:Bt}=nt,Ca=({position:n,rotation:e=[0,0,0],size:t,windows:r=[]})=>{const{isNightMode:s}=Pt(),i=N.useRef(null),o=N.useMemo(()=>s?1710623:16119287,[s]);N.useEffect(()=>{i.current&&i.current.material.color.setHex(o)},[o]);const a=N.useMemo(()=>{if(r.length===0)return new Bs(t[0],t[1],t[2]);const l=new Xo,u=t[0]/2,d=t[1]/2;l.moveTo(-u,-d),l.lineTo(u,-d),l.lineTo(u,d),l.lineTo(-u,d),l.closePath(),r.forEach(f=>{const g=new gh,y=f.x-f.width/2,b=f.y-f.height/2;g.moveTo(y,b),g.lineTo(y+f.width,b),g.lineTo(y+f.width,b+f.height),g.lineTo(y,b+f.height),g.closePath(),l.holes.push(g)});const h={depth:t[2],bevelEnabled:!1};return new Nh(l,h)},[t,r]);return c.jsx("mesh",{ref:i,position:n,rotation:e,geometry:a,castShadow:!0,receiveShadow:!0,children:c.jsx("meshStandardMaterial",{color:o,roughness:.3,metalness:0})})},Yc=({position:n,rotation:e=[0,0,0],size:t})=>{const{isNightMode:r}=Pt();return c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{children:[c.jsx("planeGeometry",{args:t}),c.jsx("meshPhysicalMaterial",{color:r?1714746:16777215,transparent:!0,opacity:r?.4:.15,roughness:0,metalness:0,transmission:.9,thickness:.1,side:Tn})]}),c.jsxs("mesh",{position:[0,0,-.01],children:[c.jsx("planeGeometry",{args:[t[0]+.05,t[1]+.05]}),c.jsx("meshStandardMaterial",{color:r?3355460:13421772,transparent:!0,opacity:.3,side:Tn})]})]})},Qc=({position:n,rotation:e=[0,0,0],width:t,height:r})=>c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{position:[-t/2,0,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.08,r,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[t/2,0,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.08,r,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,r/2,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+.08,.08,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,-r/2,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+.08,.08,.15]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]})]}),gQ=({char:n,position:e,color:t=65535,glowColor:r=65535})=>{const s=N.useRef(null),{isNightMode:i}=Pt();vr(l=>{if(s.current){const u=s.current.material,d=Math.sin(l.clock.elapsedTime*2+e[0])*.2+1;u.emissiveIntensity=i?d*2:d*.8}});const o=l=>{const u=new Xo,d=.15;switch(l.toUpperCase()){case"A":u.moveTo(-.4,-.5),u.lineTo(-.1,.5),u.lineTo(.1,.5),u.lineTo(.4,-.5),u.lineTo(.25,-.5),u.lineTo(.15,-.15),u.lineTo(-.15,-.15),u.lineTo(-.25,-.5),u.closePath();const h=new gh;h.moveTo(-.05,0),h.lineTo(0,.2),h.lineTo(.05,0),h.closePath(),u.holes.push(h);break;case"G":u.moveTo(-.3,-.5),u.lineTo(-.3,.5),u.lineTo(.3,.5),u.lineTo(.3,.35),u.lineTo(-.15,.35),u.lineTo(-.15,-.35),u.lineTo(.15,-.35),u.lineTo(.15,-.08),u.lineTo(0,-.08),u.lineTo(0,.08),u.lineTo(.3,.08),u.lineTo(.3,-.5),u.closePath();break;case"E":u.moveTo(-.3,-.5),u.lineTo(-.3,.5),u.lineTo(.3,.5),u.lineTo(.3,.35),u.lineTo(-.15,.35),u.lineTo(-.15,.08),u.lineTo(.2,.08),u.lineTo(.2,-.08),u.lineTo(-.15,-.08),u.lineTo(-.15,-.35),u.lineTo(.3,-.35),u.lineTo(.3,-.5),u.closePath();break;case"N":u.moveTo(-.3,-.5),u.lineTo(-.3,.5),u.lineTo(-.15,.5),u.lineTo(.15,-.1),u.lineTo(.15,.5),u.lineTo(.3,.5),u.lineTo(.3,-.5),u.lineTo(.15,-.5),u.lineTo(-.15,.1),u.lineTo(-.15,-.5),u.closePath();break;case"T":u.moveTo(-.35,.35),u.lineTo(-.35,.5),u.lineTo(.35,.5),u.lineTo(.35,.35),u.lineTo(.1,.35),u.lineTo(.1,-.5),u.lineTo(-.1,-.5),u.lineTo(-.1,.35),u.closePath();break;case"M":u.moveTo(-.4,-.5),u.lineTo(-.4,.5),u.lineTo(-.25,.5),u.lineTo(0,.1),u.lineTo(.25,.5),u.lineTo(.4,.5),u.lineTo(.4,-.5),u.lineTo(.25,-.5),u.lineTo(.25,.15),u.lineTo(0,-.25),u.lineTo(-.25,.15),u.lineTo(-.25,-.5),u.closePath();break;case"U":u.moveTo(-.3,.5),u.lineTo(-.3,-.2),u.absarc(0,-.2,.3,Math.PI,0,!1),u.lineTo(.3,.5),u.lineTo(.15,.5),u.lineTo(.15,-.2),u.absarc(0,-.2,.15,0,Math.PI,!0),u.lineTo(-.15,.5),u.closePath();break;case"X":u.moveTo(-.35,.5),u.lineTo(-.15,.5),u.lineTo(0,.15),u.lineTo(.15,.5),u.lineTo(.35,.5),u.lineTo(.1,0),u.lineTo(.35,-.5),u.lineTo(.15,-.5),u.lineTo(0,-.15),u.lineTo(-.15,-.5),u.lineTo(-.35,-.5),u.lineTo(-.1,0),u.closePath();break;default:u.moveTo(-.2,-.5),u.lineTo(-.2,.5),u.lineTo(.2,.5),u.lineTo(.2,-.5),u.closePath()}return new Nh(u,{depth:d,bevelEnabled:!0,bevelThickness:.02,bevelSize:.02,bevelSegments:2})},a=N.useMemo(()=>o(n),[n]);return c.jsxs("group",{position:e,children:[c.jsx("mesh",{geometry:a,castShadow:!0,children:c.jsx("meshStandardMaterial",{color:t,emissive:r,emissiveIntensity:i?1.5:.5,metalness:.3,roughness:.2})}),c.jsx("mesh",{ref:s,geometry:a,scale:[1.1,1.1,.5],children:c.jsx("meshStandardMaterial",{color:r,emissive:r,emissiveIntensity:i?2:.8,transparent:!0,opacity:.3})})]})},xQ=({position:n,rotation:e=[0,0,0],scale:t=1})=>{const r="CREWLY",i=-(r.length-1)*1/2,o=58879;return c.jsxs("group",{position:n,rotation:e,scale:[t,t,t],children:[c.jsxs("mesh",{position:[0,0,-.3],children:[c.jsx("boxGeometry",{args:[r.length*1+1,2,.2]}),c.jsx("meshStandardMaterial",{color:1710618,roughness:.8})]}),r.split("").map((a,l)=>c.jsx(gQ,{char:a,position:[i+l*1,0,0],color:o,glowColor:o},l))]})},vQ=()=>{const{isNightMode:n}=Pt(),e=N.useRef(null),t=N.useRef(!1),r=18,s=Bt.RIGHT_Z+.5,i=12;return vr(o=>{if(!e.current)return;const a=o.camera.position.x,l=o.camera.position.z,u=a-r,d=l-s,f=Math.sqrt(u*u+d*d)<i;t.current=f;const g=e.current.material;if(f){const y=o.clock.elapsedTime,b=Math.sin(y*1.5)*.3+.3,p=Math.sin(y*2+1)*.3+.5,m=Math.sin(y*1.2+2)*.2+.7;g.color.setRGB(b,p,m),g.emissive.setRGB(b*.6,p*.6,m*.6),g.emissiveIntensity=n?2:1.2}else g.color.setHex(1118488),g.emissive.setHex(0),g.emissiveIntensity=0}),c.jsxs("group",{position:[r,6,s],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[4.2,2.7,.15]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.4,metalness:.6})]}),c.jsxs("mesh",{ref:e,position:[0,0,.08],children:[c.jsx("planeGeometry",{args:[3.8,2.3]}),c.jsx("meshStandardMaterial",{color:1118488,emissive:0,emissiveIntensity:0,roughness:.1,metalness:0})]}),c.jsxs("mesh",{position:[0,0,-.15],castShadow:!0,children:[c.jsx("boxGeometry",{args:[1,.6,.2]}),c.jsx("meshStandardMaterial",{color:3355443,roughness:.5,metalness:.7})]})]})},yQ=({baseY:n,height:e,factoryWidth:t,factoryDepth:r})=>{const s=e-1,i=0,o=N.useMemo(()=>[{x:-14,y:i,width:10,height:s},{x:0,y:i,width:10,height:s},{x:14,y:i,width:10,height:s}],[s,i]),a=N.useMemo(()=>[{x:-22,y:i,width:10,height:s},{x:-8,y:i,width:10,height:s},{x:8,y:i,width:10,height:s},{x:22,y:i,width:10,height:s}],[s,i]);return c.jsxs("group",{position:[0,n,0],children:[c.jsxs("mesh",{position:[Bt.BACK_X-.3,0,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[.6,.5,r+1]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[Bt.FRONT_X+.3,0,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[.6,.5,r+1]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[0,0,Bt.LEFT_Z-.3],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+1,.5,.6]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[0,0,Bt.RIGHT_Z+.3],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+1,.5,.6]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.5,roughness:.3})]}),c.jsx(Ca,{position:[0,e/2,Bt.LEFT_Z],size:[t,e,Bt.THICKNESS],windows:a}),c.jsx(Ca,{position:[Bt.BACK_X,e/2,0],rotation:[0,Math.PI/2,0],size:[r,e,Bt.THICKNESS],windows:o}),c.jsx(Ca,{position:[Bt.FRONT_X,e/2,0],rotation:[0,-Math.PI/2,0],size:[r,e,Bt.THICKNESS],windows:o}),c.jsx(Ca,{position:[0,e/2,Bt.RIGHT_Z],size:[t,e,Bt.THICKNESS],windows:a}),a.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[l.x,e/2,Bt.LEFT_Z+.16],size:[l.width,l.height]}),c.jsx(Qc,{position:[l.x,e/2,Bt.LEFT_Z+.2],width:l.width,height:l.height})]},`upper-back-${u}`)),o.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.BACK_X+.16,e/2,l.x],rotation:[0,Math.PI/2,0],size:[l.width,l.height]}),c.jsx(Qc,{position:[Bt.BACK_X+.2,e/2,l.x],rotation:[0,Math.PI/2,0],width:l.width,height:l.height})]},`upper-left-${u}`)),o.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.FRONT_X-.16,e/2,l.x],rotation:[0,-Math.PI/2,0],size:[l.width,l.height]}),c.jsx(Qc,{position:[Bt.FRONT_X-.2,e/2,l.x],rotation:[0,-Math.PI/2,0],width:l.width,height:l.height})]},`upper-right-${u}`)),a.map((l,u)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[l.x,e/2,Bt.RIGHT_Z-.16],rotation:[0,Math.PI,0],size:[l.width,l.height]}),c.jsx(Qc,{position:[l.x,e/2,Bt.RIGHT_Z-.2],rotation:[0,Math.PI,0],width:l.width,height:l.height})]},`upper-front-${u}`)),c.jsxs("mesh",{position:[0,e,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[t-.5,.3,r-.5]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.5})]})]})},_Q=()=>{const{camera:n}=gs(),e=N.useRef(null),t=N.useRef(null),r=N.useRef(null),s=Bt.FRONT_X-Bt.BACK_X,i=Bt.RIGHT_Z-Bt.LEFT_Z,o=Bt.HEIGHT,a=12,l=o+a,u=o-1,d=0;vr(()=>{const g=n.position,y=g.x>Bt.BACK_X&&g.x<Bt.FRONT_X,b=g.z>Bt.LEFT_Z&&g.z<Bt.RIGHT_Z,p=y&&b&&g.y>0&&g.y<l,m=g.y>l;e.current&&(e.current.visible=!p&&!m),t.current&&(t.current.visible=!m),r.current&&(r.current.visible=!m)});const h=N.useMemo(()=>[{x:-14,y:d,width:10,height:u},{x:0,y:d,width:10,height:u},{x:14,y:d,width:10,height:u}],[u,d]),f=N.useMemo(()=>[{x:-22,y:d,width:10,height:u},{x:-8,y:d,width:10,height:u},{x:8,y:d,width:10,height:u},{x:22,y:d,width:10,height:u}],[u,d]);return c.jsxs("group",{children:[c.jsx(Ca,{position:[0,o/2,Bt.LEFT_Z],size:[s,o,Bt.THICKNESS],windows:f}),c.jsx(Ca,{position:[Bt.BACK_X,o/2,0],rotation:[0,Math.PI/2,0],size:[i,o,Bt.THICKNESS],windows:h}),c.jsx(Ca,{position:[Bt.FRONT_X,o/2,0],rotation:[0,-Math.PI/2,0],size:[i,o,Bt.THICKNESS],windows:h}),c.jsx(Ca,{position:[-24,o/2,Bt.RIGHT_Z],size:[16,o,Bt.THICKNESS]}),c.jsx(Ca,{position:[24,o/2,Bt.RIGHT_Z],size:[16,o,Bt.THICKNESS]}),f.map((g,y)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[g.x,o/2,Bt.LEFT_Z+.16],size:[g.width,g.height]}),c.jsx(Qc,{position:[g.x,o/2,Bt.LEFT_Z+.2],width:g.width,height:g.height})]},`back-${y}`)),h.map((g,y)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.BACK_X+.16,o/2,g.x],rotation:[0,Math.PI/2,0],size:[g.width,g.height]}),c.jsx(Qc,{position:[Bt.BACK_X+.2,o/2,g.x],rotation:[0,Math.PI/2,0],width:g.width,height:g.height})]},`left-${y}`)),h.map((g,y)=>c.jsxs("group",{children:[c.jsx(Yc,{position:[Bt.FRONT_X-.16,o/2,g.x],rotation:[0,-Math.PI/2,0],size:[g.width,g.height]}),c.jsx(Qc,{position:[Bt.FRONT_X-.2,o/2,g.x],rotation:[0,-Math.PI/2,0],width:g.width,height:g.height})]},`right-${y}`)),c.jsxs("mesh",{ref:e,position:[0,o,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[s-.5,.3,i-.5]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.5})]}),c.jsx("group",{ref:r,children:c.jsx(yQ,{baseY:o,height:a,factoryWidth:s,factoryDepth:i})}),c.jsxs("mesh",{ref:t,position:[0,l+.5,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[s+2,1,i+2]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.3,roughness:.6})]}),c.jsx(vQ,{}),c.jsx(xQ,{position:[0,l+2,Bt.RIGHT_Z+.5],rotation:[0,0,0],scale:1.5})]})},SQ=({position:n,height:e=3})=>{const{isNightMode:t}=Pt(),r=t?1719578:2984493,s=t?4007959:9127187;return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{position:[0,e*.3,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.15,.25,e*.6,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[0,e*.6,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[1.2,e*.5,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,e*.85,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[.9,e*.4,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,e*1.05,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[.6,e*.3,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]})]})},bQ=({position:n,rotation:e=0})=>{const{isNightMode:t}=Pt(),r=t?4868698:16119260,s=t?4857888:9109504,i=t?16768392:8900331;return c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,1.25,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[3,2.5,2.5]}),c.jsx("meshStandardMaterial",{color:r,roughness:.7})]}),c.jsxs("mesh",{position:[0,3,0],rotation:[0,0,Math.PI/4],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2.5,2.5,2.8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.6})]}),c.jsxs("mesh",{position:[0,1.2,1.26],children:[c.jsx("planeGeometry",{args:[.8,.8]}),c.jsx("meshStandardMaterial",{color:i,emissive:t?i:0,emissiveIntensity:t?.5:0})]}),c.jsxs("mesh",{position:[0,.6,1.26],children:[c.jsx("planeGeometry",{args:[.6,1.2]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.8})]}),c.jsxs("mesh",{position:[.8,3.5,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.4,1,.4]}),c.jsx("meshStandardMaterial",{color:6710886,roughness:.8})]})]})},wQ=({position:n,speed:e=.5})=>{const t=N.useRef(null),r=n[0],{isNightMode:s}=Pt();vr(a=>{t.current&&(t.current.position.x=r+Math.sin(a.clock.elapsedTime*e*.1)*5,t.current.position.y=n[1]+Math.sin(a.clock.elapsedTime*e*.3)*.3)});const i=s?3816010:16777215,o=s?.3:.9;return c.jsxs("group",{ref:t,position:n,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[1.5,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[1.5,.3,0],children:[c.jsx("sphereGeometry",{args:[1.2,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[-1.3,.2,0],children:[c.jsx("sphereGeometry",{args:[1,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[.5,.6,.3],children:[c.jsx("sphereGeometry",{args:[.8,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]}),c.jsxs("mesh",{position:[-.5,-.3,.2],children:[c.jsx("sphereGeometry",{args:[.9,16,16]}),c.jsx("meshStandardMaterial",{color:i,transparent:!0,opacity:o})]})]})},CQ=()=>{const{isNightMode:n}=Pt(),e=n?5592416:12303296;return c.jsxs("group",{children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,38],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[6,34]}),c.jsx("meshStandardMaterial",{color:e,roughness:.85})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,42],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[48,4]}),c.jsx("meshStandardMaterial",{color:e,roughness:.85})]})]})},AQ=()=>{const{isNightMode:n}=Pt(),e=n?1716304:2777232,t=n?1720368:2781264,r=16777215;return c.jsxs("group",{position:[-18,0,42],children:[c.jsxs("mesh",{position:[0,.04,0],receiveShadow:!0,castShadow:!0,children:[c.jsx("boxGeometry",{args:[16,.08,23]}),c.jsx("meshStandardMaterial",{color:t,roughness:.7})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.09,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[13,20]}),c.jsx("meshStandardMaterial",{color:e,roughness:.7})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[-6.5,.1,0],children:[c.jsx("planeGeometry",{args:[.08,20]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[6.5,.1,0],children:[c.jsx("planeGeometry",{args:[.08,20]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,-10],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,10],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,-3.5],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,3.5],children:[c.jsx("planeGeometry",{args:[13,.08]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.1,0],children:[c.jsx("planeGeometry",{args:[.08,7]}),c.jsx("meshStandardMaterial",{color:r})]}),c.jsxs("mesh",{position:[0,.85,0],children:[c.jsx("boxGeometry",{args:[13.5,.9,.05]}),c.jsx("meshStandardMaterial",{color:2236962,transparent:!0,opacity:.7})]}),c.jsxs("mesh",{position:[-6.8,.5,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.06,.06,1,8]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[6.8,.5,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.06,.06,1,8]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.6,roughness:.3})]})]})},MQ=()=>{const{isNightMode:n}=Pt(),e=n?1722912:2787888,t=n?9075280:13943930,r=13421772,s=[[-2,0,-3],[3,0,1],[-1,0,4]];return c.jsxs("group",{position:[18,.03,42],children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],receiveShadow:!0,children:[c.jsx("circleGeometry",{args:[9,32]}),c.jsx("meshStandardMaterial",{color:e,roughness:.6})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[5,-.01,-4],children:[c.jsx("circleGeometry",{args:[3,16]}),c.jsx("meshStandardMaterial",{color:t,roughness:.95})]}),s.map(([i,o,a],l)=>c.jsxs("group",{position:[i,o,a],children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.01,0],children:[c.jsx("circleGeometry",{args:[.15,16]}),c.jsx("meshStandardMaterial",{color:1118481})]}),c.jsxs("mesh",{position:[0,.6,0],children:[c.jsx("cylinderGeometry",{args:[.03,.03,1.2,6]}),c.jsx("meshStandardMaterial",{color:r,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{position:[.2,1.05,0],children:[c.jsx("planeGeometry",{args:[.4,.25]}),c.jsx("meshStandardMaterial",{color:16724787,side:Tn,emissive:16724787,emissiveIntensity:.2})]})]},`flag-${l}`))]})},t3=({position:n,mirror:e=!1})=>{const{isNightMode:t}=Pt(),r=t?3811866:6965802,s=[16737928,16755251,11163135,16729190,16768324],i=t?1722906:2783786,o=e?-1:1;return c.jsxs("group",{position:n,scale:[o,1,1],children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.05,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[6,4]}),c.jsx("meshStandardMaterial",{color:r,roughness:.95})]}),c.jsxs("mesh",{position:[0,.15,0],receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[6.2,.3,4.2]}),c.jsx("meshStandardMaterial",{color:9075306,roughness:.8})]}),c.jsxs("mesh",{position:[0,.15,0],children:[c.jsx("boxGeometry",{args:[5.8,.35,3.8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.95})]}),[[-2,.4,-1],[-1,.35,-1.2],[0,.4,-.8],[1,.35,-1],[2,.4,-1.1],[-1.5,.4,.5],[0,.35,.8],[1.5,.4,.3],[-.5,.4,1.2],[.8,.35,1]].map(([a,l,u],d)=>c.jsxs("mesh",{position:[a,l,u],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.18,8,8]}),c.jsx("meshStandardMaterial",{color:s[d%s.length],emissive:s[d%s.length],emissiveIntensity:t?.3:.1})]},`flower-${d}`)),c.jsxs("mesh",{position:[-2.2,.5,0],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.5,8,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.8})]}),c.jsxs("mesh",{position:[2.2,.45,.3],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.4,8,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.8})]})]})},k0=({position:n,rotation:e=0})=>{const{isNightMode:t}=Pt(),r=t?3811866:9133628,s=t?4473936:6710896;return c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.5,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.08,.6]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,.9,-.25],rotation:[.15,0,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.5,.08]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),[-.8,.8].map((i,o)=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[i,.25,.2],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.06,.5,.06]}),c.jsx("meshStandardMaterial",{color:s,metalness:.6,roughness:.4})]}),c.jsxs("mesh",{position:[i,.25,-.2],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.06,.5,.06]}),c.jsx("meshStandardMaterial",{color:s,metalness:.6,roughness:.4})]})]},`leg-${o}`))]})};On.preload(bn.CYBERTRUCK);const VS=6.5,EQ=({position:n,rotation:e=0})=>{const t=On(bn.CYBERTRUCK),r=N.useMemo(()=>{const s=t.scene.clone(!0);return s.traverse(i=>{i.isMesh&&(i.castShadow=!0,i.receiveShadow=!0)}),s},[t.scene]);return c.jsx("group",{position:n,rotation:[0,e,0],children:c.jsx("primitive",{object:r,scale:[VS,VS,VS]})})},TQ=()=>{const{isNightMode:n}=Pt(),e=N.useMemo(()=>[[-35,0,-25,4],[-28,0,-28,3.5],[-20,0,-26,4.5],[-12,0,-28,3],[-4,0,-25,4.2],[4,0,-27,3.8],[12,0,-26,4],[20,0,-28,3.5],[28,0,-25,4.5],[35,0,-27,3],[-40,0,-40,5],[-32,0,-42,4.5],[-24,0,-38,5.5],[-16,0,-44,4],[-8,0,-40,5.2],[0,0,-42,4.8],[8,0,-38,5],[16,0,-44,4.5],[24,0,-40,5.5],[32,0,-42,4],[40,0,-38,5.2],[-45,0,-55,6],[-35,0,-58,5.5],[-25,0,-52,6.5],[-15,0,-60,5],[-5,0,-55,6.2],[5,0,-58,5.8],[15,0,-52,6],[25,0,-60,5.5],[35,0,-55,6.5],[45,0,-58,5],[-50,0,-70,7],[-30,0,-75,6.5],[-10,0,-72,7.5],[10,0,-70,6],[30,0,-75,7.2],[50,0,-72,6.8],[-35,0,-15,3.5],[-38,0,-5,4],[-35,0,5,3.8],[-38,0,15,4.2],[-42,0,-20,4.5],[-45,0,-10,5],[-42,0,0,4.8],[-45,0,10,5.2],[-50,0,-15,5.5],[-50,0,5,5],[35,0,-15,4],[38,0,-5,3.5],[35,0,5,4.2],[38,0,15,3.8],[42,0,-20,4.5],[45,0,-10,5],[42,0,0,4.8],[45,0,10,5.2],[50,0,-15,5.5],[50,0,5,5],[-25,0,-32,3.8],[-10,0,-33,4.2],[10,0,-32,3.5],[25,0,-33,4],[-35,0,26,4],[-30,0,30,3.5],[-38,0,35,4.5],[-32,0,40,3.8],[-40,0,45,4.2],[35,0,26,3.8],[30,0,30,4],[38,0,35,4.5],[32,0,40,3.5],[40,0,45,4.2],[-25,0,55,5],[-10,0,52,4.5],[10,0,54,4.8],[25,0,52,5.2],[0,0,58,5]],[]),t=N.useMemo(()=>[[-32,0,-35,.2],[-15,0,-38,-.1],[5,0,-36,.3],[25,0,-38,-.2],[-40,0,-50,.4],[-20,0,-52,-.3],[0,0,-48,.1],[20,0,-52,-.1],[40,0,-50,.2],[-35,0,-65,.5],[0,0,-68,0],[35,0,-65,-.4],[-40,0,-10,Math.PI/2],[-48,0,-25,Math.PI/2+.2],[-45,0,8,Math.PI/2-.1],[40,0,0,-Math.PI/2],[48,0,-20,-Math.PI/2+.2],[45,0,12,-Math.PI/2-.1]],[]),r=N.useMemo(()=>[[-20,15,-30,.3],[10,18,-25,.5],[30,14,-35,.4],[-35,16,0,.35],[35,17,10,.45],[-50,20,-40,.25],[50,19,-50,.55],[0,22,-60,.3],[-30,21,-55,.4],[30,20,-65,.35],[-15,17,-45,.45],[15,19,-55,.3]],[]),s=n?1710638:8900331,i=n?2771503:4881487,o=n?3824191:5934175;return c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,20,-100],receiveShadow:!1,children:[c.jsx("planeGeometry",{args:[300,100]}),c.jsx("meshBasicMaterial",{color:s,side:Tn})]}),c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.01,-20],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[200,200]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[-30,2,-80],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[25,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[30,3,-85],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[30,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[0,4,-90],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[35,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[-50,2,-75],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[20,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),c.jsxs("mesh",{position:[50,2.5,-78],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[22,32]}),c.jsx("meshStandardMaterial",{color:o,roughness:.9})]}),e.map(([a,l,u,d],h)=>c.jsx(SQ,{position:[a,l,u],height:d},`tree-${h}`)),t.map(([a,l,u,d],h)=>c.jsx(bQ,{position:[a,l,u],rotation:d},`house-${h}`)),r.map(([a,l,u,d],h)=>c.jsx(wQ,{position:[a,l,u],speed:d},`cloud-${h}`)),c.jsx(CQ,{}),c.jsx(AQ,{}),c.jsx(MQ,{}),c.jsx(t3,{position:[-12,0,26]}),c.jsx(t3,{position:[12,0,26],mirror:!0}),c.jsx(k0,{position:[-4,0,30],rotation:Math.PI/2}),c.jsx(k0,{position:[4,0,30],rotation:-Math.PI/2}),c.jsx(k0,{position:[-4,0,36],rotation:Math.PI/2}),c.jsx(k0,{position:[4,0,36],rotation:-Math.PI/2}),c.jsx(EQ,{position:[0,0,50],rotation:0})]})},kQ=({workstation:n,zoneColor:e})=>{const{isNightMode:t,agents:r}=Pt(),s=N.useRef(null),i=N.useRef(null),o=N.useRef([]),a=N.useMemo(()=>n.assignedAgentId?r.get(n.assignedAgentId):null,[n.assignedAgentId,r]),l=N.useMemo(()=>{if(!a)return{color:8947848,emissive:8947848};switch(a.status){case"active":return{color:65280,emissive:65280};case"idle":return{color:16776960,emissive:16776960};case"dormant":return{color:16711680,emissive:16711680};default:return{color:8947848,emissive:8947848}}},[a]);vr(h=>{const f=h.clock.elapsedTime;if(s.current){const g=s.current.material,y=(Math.sin(f*3)+1)/2;g.emissiveIntensity=.3+y*.7}if(i.current&&(a==null?void 0:a.status)==="active"){const g=i.current.material;g.emissiveIntensity=.2+Math.sin(f*2)*.1}o.current.forEach((g,y)=>{if(g&&(a==null?void 0:a.status)==="active"){const b=g.material,p=Math.sin(f*10+y*2)*.1+.9;b.emissiveIntensity=.8*p,b.opacity=a.cpuPercent>10?.9:0}})});const{x:u,z:d}=n.position;return c.jsxs("group",{position:[u,0,d],children:[c.jsx(RQ,{}),c.jsx(NQ,{}),c.jsx(IQ,{isActive:n.isActive,displayRef:i,codeLineRefs:o}),(a==null?void 0:a.status)==="idle"&&c.jsx(PQ,{type:n.index%3===0?"soda":"coffee"}),c.jsxs("mesh",{ref:s,position:[.8,.83,0],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:l.color,emissive:l.emissive,emissiveIntensity:.5})]}),t&&n.isActive&&c.jsx("spotLight",{color:16777198,intensity:1.5,distance:8,angle:Math.PI/4,penumbra:.5,decay:1,position:[0,4,0],"target-position":[0,0,.5],castShadow:!0,"shadow-mapSize-width":512,"shadow-mapSize-height":512})]})},RQ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.05,1]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.6})]}),[[-.9,-.4],[.9,-.4],[-.9,.4],[.9,.4]].map(([n,e],t)=>c.jsxs("mesh",{position:[n,.375,e],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.03,.03,.75,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.8})]},t))]}),NQ=()=>c.jsxs("group",{position:[0,0,.8],children:[c.jsxs("mesh",{position:[0,.45,0],children:[c.jsx("boxGeometry",{args:[.5,.08,.5]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsxs("mesh",{position:[0,.7,.21],children:[c.jsx("boxGeometry",{args:[.5,.5,.08]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsxs("mesh",{position:[0,.225,0],children:[c.jsx("cylinderGeometry",{args:[.02,.02,.45,8]}),c.jsx("meshStandardMaterial",{color:6710886,metalness:.8})]}),c.jsxs("mesh",{position:[0,.02,0],rotation:[0,0,0],children:[c.jsx("cylinderGeometry",{args:[.25,.25,.02,16]}),c.jsx("meshStandardMaterial",{color:4473924,metalness:.6})]})]}),IQ=({isActive:n,displayRef:e,codeLineRefs:t})=>{const r=n?1710638:657938;return c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.79,-.1],children:[c.jsx("boxGeometry",{args:[1,.04,.7]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.5,roughness:.3})]}),c.jsxs("group",{position:[0,.79,-.45],rotation:[-Math.PI/6,0,0],children:[c.jsxs("mesh",{position:[0,.35,-.015],children:[c.jsx("boxGeometry",{args:[1,.7,.03]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.5,roughness:.3})]}),c.jsxs("mesh",{ref:e,position:[0,.35,.002],children:[c.jsx("planeGeometry",{args:[.9,.6]}),c.jsx("meshStandardMaterial",{color:r,emissive:n?1710638:0,emissiveIntensity:n?.3:0})]}),n&&c.jsx(c.Fragment,{children:[0,1,2,3,4].map(s=>c.jsxs("mesh",{ref:i=>{i&&(t.current[s]=i)},position:[-.1+Math.random()*.1,.5-s*.1,.004],children:[c.jsx("planeGeometry",{args:[.5+Math.random()*.2,.03]}),c.jsx("meshStandardMaterial",{color:65416,emissive:65416,emissiveIntensity:.8,transparent:!0,opacity:.9})]},s))})]}),c.jsxs("mesh",{position:[0,.801,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("planeGeometry",{args:[.8,.4]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.8})]})]})},PQ=({type:n})=>n==="coffee"?c.jsxs("group",{position:[.55,.78,.2],children:[c.jsxs("mesh",{position:[0,.08,0],children:[c.jsx("cylinderGeometry",{args:[.06,.05,.14,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.4})]}),c.jsxs("mesh",{position:[0,.15,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[.055,12]}),c.jsx("meshStandardMaterial",{color:4073251})]}),c.jsxs("mesh",{position:[.08,.08,0],rotation:[0,0,Math.PI/2],children:[c.jsx("torusGeometry",{args:[.03,.008,8,12,Math.PI]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.4})]})]}):c.jsxs("group",{position:[.55,.78,.2],children:[c.jsxs("mesh",{position:[0,.07,0],children:[c.jsx("cylinderGeometry",{args:[.035,.035,.12,12]}),c.jsx("meshStandardMaterial",{color:13369344,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[0,.13,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[.035,12]}),c.jsx("meshStandardMaterial",{color:13421772,metalness:.8,roughness:.2})]}),c.jsxs("mesh",{position:[0,.07,0],children:[c.jsx("cylinderGeometry",{args:[.036,.036,.04,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.4})]})]}),LQ=({zone:n})=>{const{WIDTH:e,DEPTH:t}=nt.ZONE;return c.jsxs(c.Fragment,{children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[n.zoneX,.03,n.zoneZ],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[e,t]}),c.jsx("meshStandardMaterial",{color:n.color,roughness:.8,transparent:!0,opacity:.3,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2})]}),c.jsx(jQ,{zone:n})]})},jQ=({zone:n})=>{const{WIDTH:e,DEPTH:t}=nt.ZONE,r=N.useMemo(()=>{const s=e/2,i=t/2;return[new se(-s,.05,-i),new se(s,.05,-i),new se(s,.05,i),new se(-s,.05,i),new se(-s,.05,-i)]},[]);return c.jsx("group",{position:[n.zoneX,0,n.zoneZ],children:c.jsx(F$,{points:r,color:n.color,lineWidth:2})})},BQ=({projectName:n,position:e,color:t})=>{const r=N.useMemo(()=>{const s=document.createElement("canvas");s.width=512,s.height=128;const i=s.getContext("2d");if(i){i.fillStyle=`#${t.toString(16).padStart(6,"0")}`,i.fillRect(0,0,512,128),i.fillStyle="#ffffff",i.font="bold 48px Arial",i.textAlign="center",i.textBaseline="middle";let a=n||"Project";a.length>14&&(a=a.substring(0,13)+"..."),i.fillText(a,256,64)}const o=new Aj(s);return o.needsUpdate=!0,o},[n,t]);return c.jsxs("mesh",{position:e,rotation:[-Math.PI/2,0,0],children:[c.jsx("planeGeometry",{args:[3,.75]}),c.jsx("meshStandardMaterial",{map:r,emissive:t,emissiveIntensity:.2})]})},DQ=({zone:n})=>{const{DEPTH:e}=nt.ZONE;return c.jsxs("group",{children:[c.jsx(LQ,{zone:n}),n.workstations.map((t,r)=>c.jsx(kQ,{workstation:t,zoneColor:n.color},`ws-${n.zoneIndex}-${r}`)),c.jsx(BQ,{projectName:n.projectName,position:[n.zoneX,.04,n.zoneZ+e/2-.5],color:n.color})]})},OQ=()=>{const{zones:n}=Pt(),e=N.useMemo(()=>Array.from(n.values()),[n]);return c.jsx("group",{children:e.map(t=>c.jsx(DQ,{zone:t},t.projectName))})},{WALLS:br}=nt,wr={pot:new Wi(.25,.2,.5,16),soil:new Wi(.22,.22,.05,16),leaf:new ta(.25,.4),clockFace:new wa(.4,64),clockRim:new mm(.38,.42,64),hourMarkerLarge:new wa(.02,8),hourMarkerSmall:new wa(.01,8),hourHand:new Bs(.02,.16,.01),minuteHand:new Bs(.015,.24,.01),secondHand:new Bs(.008,.28,.005),centerCap:new wa(.02,16),cord:new Wi(.02,.02,1,8),pendantDome:new xu(.4,.25,32,1,!0),floorLampDome:new xu(.25,.15,32,1,!0),lightBulb:new yu(.08,16,16),smallLightBulb:new yu(.06,16,16),lampBase:new Wi(.3,.35,.1,32),lampPole:new Wi(.025,.025,1.9,16),lampArc:new Wi(.025,.025,.8,16),logoCircle:new wa(.15,32)},ts={whiteCeramic:new An({color:16119285,roughness:.3}),soil:new An({color:4007959,roughness:.9}),aluminum:new An({color:12632256,metalness:.8,roughness:.2}),darkGray:new An({color:3355443}),clockHand:new An({color:3355443}),secondHand:new An({color:16737792}),whiteFace:new An({color:16777215,roughness:.3}),whiteShade:new An({color:16119285,side:Tn,roughness:.3}),logo:new An({color:16777215,transparent:!0,opacity:.3})},Vl={leafDay:new An({color:4889162,side:Tn,roughness:.6}),leafNight:new An({color:2972205,side:Tn,roughness:.6}),screenDay:new An({color:2763326,emissive:0,emissiveIntensity:.5}),screenNight:new An({color:1710638,emissive:1118498,emissiveIntensity:.5}),bulbDay:new An({color:16777198,emissive:16777164,emissiveIntensity:.5}),bulbNight:new An({color:16777198,emissive:16777164,emissiveIntensity:2}),smallBulbDay:new An({color:16777198,emissive:16777164,emissiveIntensity:.3}),smallBulbNight:new An({color:16777198,emissive:16777164,emissiveIntensity:1.5})},Ui=br.HEIGHT,FQ=[[br.BACK_X+2,0,br.LEFT_Z+3,1.5],[br.FRONT_X-2,0,br.LEFT_Z+3,1.3],[br.BACK_X+2,0,0,1.4],[br.FRONT_X-2,0,0,1.2],[br.BACK_X+2,0,br.RIGHT_Z-3,1.5],[br.FRONT_X-2,0,br.RIGHT_Z-3,1.3]],UQ=[[-14,Ui-1,8],[0,Ui-1,8],[14,Ui-1,8],[-14,Ui-1,-4],[0,Ui-1,-4],[14,Ui-1,-4],[-14,Ui-1,-16],[0,Ui-1,-16],[14,Ui-1,-16]],HQ=[[br.BACK_X+4,0,br.LEFT_Z+5],[br.FRONT_X-4,0,br.LEFT_Z+5],[br.BACK_X+4,0,12],[br.FRONT_X-4,0,12]],zQ=[0,72,144,216,288],GQ=zQ.map((n,e)=>({position:[Math.sin(n*Math.PI/180)*.15,.7+e*.12,Math.cos(n*Math.PI/180)*.15],rotation:[.4+e*.1,n*Math.PI/180,0]})),WQ=Array.from({length:12},(n,e)=>{const t=e*Math.PI/6;return{position:[Math.sin(t)*.32,Math.cos(t)*.32,.01],isMainHour:e%3===0}}),VQ=({position:n,size:e=1})=>{const{isNightMode:t}=Pt(),r=t?Vl.leafNight:Vl.leafDay;return c.jsxs("group",{position:n,scale:[e,e,e],children:[c.jsx("mesh",{position:[0,.25,0],geometry:wr.pot,material:ts.whiteCeramic,castShadow:!0}),c.jsx("mesh",{position:[0,.48,0],geometry:wr.soil,material:ts.soil}),GQ.map((s,i)=>c.jsx("mesh",{position:s.position,rotation:s.rotation,geometry:wr.leaf,material:r},i))]})},XQ=({position:n,rotation:e=0,width:t=3,height:r=1.8})=>{const{isNightMode:s}=Pt(),i=s?Vl.screenNight:Vl.screenDay;return c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[t+.1,r+.1,.03]}),c.jsx("primitive",{object:ts.aluminum,attach:"material"})]}),c.jsxs("mesh",{position:[0,0,.02],children:[c.jsx("boxGeometry",{args:[t,r,.01]}),c.jsx("primitive",{object:i,attach:"material"})]}),c.jsx("mesh",{position:[0,0,.025],geometry:wr.logoCircle,material:ts.logo})]})},n3=({position:n,rotation:e=0})=>{const t=N.useRef(null),r=N.useRef(null),s=N.useRef(null),i=N.useRef(0);if(i.current===0){const o=new Date,a=o.getHours()*36e5+o.getMinutes()*6e4+o.getSeconds()*1e3+o.getMilliseconds();i.current=a-performance.now()}return vr(()=>{const a=(performance.now()+i.current)%864e5/1e3,l=a%60,u=a/60%60,d=a/3600%12;s.current&&(s.current.rotation.z=-l*(Math.PI/30)),r.current&&(r.current.rotation.z=-u*(Math.PI/30)),t.current&&(t.current.rotation.z=-d*(Math.PI/6))}),c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsx("mesh",{geometry:wr.clockFace,material:ts.whiteFace}),c.jsx("mesh",{position:[0,0,-.01],geometry:wr.clockRim,material:ts.aluminum}),WQ.map((o,a)=>c.jsx("mesh",{position:o.position,geometry:o.isMainHour?wr.hourMarkerLarge:wr.hourMarkerSmall,material:ts.darkGray},a)),c.jsx("mesh",{ref:t,position:[0,.08,.02],geometry:wr.hourHand,material:ts.clockHand}),c.jsx("mesh",{ref:r,position:[0,.12,.02],geometry:wr.minuteHand,material:ts.clockHand}),c.jsx("mesh",{ref:s,position:[0,.12,.02],geometry:wr.secondHand,material:ts.secondHand}),c.jsx("mesh",{position:[0,0,.03],geometry:wr.centerCap,material:ts.darkGray})]})},KQ=({position:n})=>{const{isNightMode:e}=Pt(),t=e?Vl.bulbNight:Vl.bulbDay;return c.jsxs("group",{position:n,children:[c.jsx("mesh",{position:[0,.5,0],geometry:wr.cord,material:ts.darkGray}),c.jsx("mesh",{rotation:[Math.PI,0,0],geometry:wr.pendantDome,material:ts.whiteShade}),c.jsx("mesh",{position:[0,-.1,0],geometry:wr.lightBulb,material:t})]})},JQ=({position:n})=>{const{isNightMode:e}=Pt(),t=e?Vl.smallBulbNight:Vl.smallBulbDay;return c.jsxs("group",{position:n,children:[c.jsx("mesh",{position:[0,.05,0],geometry:wr.lampBase,material:ts.aluminum,castShadow:!0}),c.jsx("mesh",{position:[0,1,0],geometry:wr.lampPole,material:ts.aluminum,castShadow:!0}),c.jsx("mesh",{position:[.3,1.9,0],rotation:[0,0,Math.PI/6],geometry:wr.lampArc,material:ts.aluminum,castShadow:!0}),c.jsxs("group",{position:[.6,1.7,0],children:[c.jsx("mesh",{rotation:[Math.PI,0,0],geometry:wr.floorLampDome,material:ts.whiteShade}),c.jsx("mesh",{position:[0,-.05,0],geometry:wr.smallLightBulb,material:t})]})]})},qQ=()=>c.jsxs("group",{children:[FQ.map(([n,e,t,r],s)=>c.jsx(VQ,{position:[n,e,t],size:r},`plant-${s}`)),c.jsx(XQ,{position:[0,Ui/2,br.LEFT_Z+.2],rotation:0,width:4,height:2.5}),c.jsx(n3,{position:[br.BACK_X+.2,Ui*.6,8],rotation:Math.PI/2}),c.jsx(n3,{position:[br.FRONT_X-.2,Ui*.6,-8],rotation:-Math.PI/2}),UQ.map((n,e)=>c.jsx(KQ,{position:n},`pendant-${e}`)),HQ.map((n,e)=>c.jsx(JQ,{position:n},`lamp-${e}`))]}),ll={beltSurface:new Bs(16,.1,1.2),beltRail:new Bs(16,.05,.08),roller:new Wi(.3,.3,1.2,16),supportLeg:new Bs(.15,.5,.15),productBox:new Bs(1,1,1)},Pc={beltSurface:new An({color:3355443,metalness:.6,roughness:.4}),beltRail:new An({color:6710886,metalness:.8}),roller:new An({color:4473924,metalness:.7}),supportLeg:new An({color:5592405,metalness:.5})},$Q=2,YQ=5,QQ=2,R0=7,ZQ=.8,eZ=6710886,tZ=()=>{const{agents:n,zones:e}=Pt(),t=N.useRef([]),r=N.useRef(new Map),s=a=>{let l=r.current.get(a);return l||(l=new An({color:a,roughness:.7}),r.current.set(a,l)),l};N.useEffect(()=>()=>{r.current.forEach(a=>a.dispose()),r.current.clear()},[]);const i=N.useMemo(()=>{const a=[];return n.forEach((l,u)=>{a.push(`${u}:${l.status}`)}),a.sort().join("|")},[n]),o=N.useMemo(()=>{const a=new Map;n.forEach(d=>{if(d.status==="active"){const h=e.get(d.projectName);if(h){const f=a.get(d.projectName);f?f.count++:a.set(d.projectName,{count:1,color:h.color})}}});const l=[];let u=0;if(a.forEach(({count:d,color:h})=>{const f=Math.min(d*$Q,YQ);for(let g=0;g<f;g++)l.push({offset:-R0+(u*3.7+g*2.3)%(R0*2),color:h,size:.35+(u*7+g*3)%5*.04}),u++}),l.length===0)for(let d=0;d<QQ;d++)l.push({offset:-3+d*6,color:eZ,size:.3+d*.05});return l},[i,e]);return vr((a,l)=>{t.current.forEach(u=>{u&&(u.position.x+=l*ZQ,u.position.x>R0&&(u.position.x=-R0))})}),c.jsxs("group",{position:[0,0,-14],children:[c.jsx("mesh",{position:[0,.5,0],geometry:ll.beltSurface,material:Pc.beltSurface,receiveShadow:!0}),c.jsx("mesh",{position:[0,.55,.55],geometry:ll.beltRail,material:Pc.beltRail}),c.jsx("mesh",{position:[0,.55,-.55],geometry:ll.beltRail,material:Pc.beltRail}),c.jsx("mesh",{position:[-7.5,.5,0],rotation:[Math.PI/2,0,0],geometry:ll.roller,material:Pc.roller}),c.jsx("mesh",{position:[7.5,.5,0],rotation:[Math.PI/2,0,0],geometry:ll.roller,material:Pc.roller}),[-6,-2,2,6].map((a,l)=>c.jsxs("group",{position:[a,0,0],children:[c.jsx("mesh",{position:[0,.25,.4],geometry:ll.supportLeg,material:Pc.supportLeg}),c.jsx("mesh",{position:[0,.25,-.4],geometry:ll.supportLeg,material:Pc.supportLeg})]},l)),o.map((a,l)=>c.jsx("mesh",{ref:u=>{u&&(t.current[l]=u)},position:[a.offset,.6+a.size/2,0],scale:[a.size,a.size,a.size],geometry:ll.productBox,material:s(a.color),castShadow:!0},`${l}-${a.color}`))]})},{BREAK_ROOM:nZ}=nt,rZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[-2,0,0],children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.8,1.5,.6]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.3,0],children:[c.jsx("boxGeometry",{args:[.7,.3,.5]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.5,roughness:.1})]}),c.jsxs("mesh",{position:[0,.9,.31],children:[c.jsx("boxGeometry",{args:[.4,.2,.02]}),c.jsx("meshStandardMaterial",{color:1118481,emissive:n?65280:13056,emissiveIntensity:.3})]}),c.jsxs("mesh",{position:[0,.2,.2],children:[c.jsx("boxGeometry",{args:[.5,.05,.4]}),c.jsx("meshStandardMaterial",{color:4473924,metalness:.5})]})]})},sZ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.8,.8,.05,24]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.6})]}),c.jsxs("mesh",{position:[0,.35,0],children:[c.jsx("cylinderGeometry",{args:[.08,.1,.7,12]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("cylinderGeometry",{args:[.4,.4,.04,16]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6})]}),[0,90,180,270].map((n,e)=>{const t=n*Math.PI/180,r=Math.sin(t)*1.3,s=Math.cos(t)*1.3;return c.jsx(iZ,{position:[r,0,s],rotation:-t+Math.PI},e)})]}),iZ=({position:n,rotation:e})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.45,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.25,.25,.08,16]}),c.jsx("meshStandardMaterial",{color:16739125,roughness:.8})]}),c.jsxs("mesh",{position:[0,.75,-.2],rotation:[.2,0,0],children:[c.jsx("boxGeometry",{args:[.45,.5,.06]}),c.jsx("meshStandardMaterial",{color:16739125,roughness:.8})]}),c.jsxs("mesh",{position:[0,.2,0],children:[c.jsx("cylinderGeometry",{args:[.04,.04,.4,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("cylinderGeometry",{args:[.2,.2,.04,12]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6})]})]}),oZ=()=>(Pt(),c.jsxs("group",{position:[2,0,-.5],children:[c.jsxs("mesh",{position:[0,1,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.9,2,.7]}),c.jsx("meshStandardMaterial",{color:2245802,roughness:.4})]}),c.jsxs("mesh",{position:[0,1.2,.36],children:[c.jsx("boxGeometry",{args:[.8,1.2,.02]}),c.jsx("meshStandardMaterial",{color:8961023,transparent:!0,opacity:.4,roughness:.1})]}),[1.5,1.2,.9].map((n,e)=>c.jsx("group",{children:[-.25,0,.25].map((t,r)=>c.jsxs("mesh",{position:[t,n,.25],children:[c.jsx("boxGeometry",{args:[.15,.2,.1]}),c.jsx("meshStandardMaterial",{color:[16711680,65280,16776960][r],roughness:.3})]},`${e}-${r}`))},e)),c.jsxs("mesh",{position:[.3,.6,.36],children:[c.jsx("boxGeometry",{args:[.1,.05,.02]}),c.jsx("meshStandardMaterial",{color:1118481,metalness:.8})]}),c.jsxs("mesh",{position:[0,.15,.36],children:[c.jsx("boxGeometry",{args:[.6,.25,.02]}),c.jsx("meshStandardMaterial",{color:1118481})]})]})),aZ=()=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("circleGeometry",{args:[4,32]}),c.jsx("meshStandardMaterial",{color:9139029,roughness:.8,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),lZ=()=>{const{x:n,z:e}=nZ.POSITION;return c.jsxs("group",{position:[n,0,e],children:[c.jsx(aZ,{}),c.jsx(rZ,{}),c.jsx(sZ,{}),c.jsx(oZ,{}),c.jsxs("group",{position:[-3,0,1.5],children:[c.jsxs("mesh",{position:[0,.2,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.25,.2,.4,12]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.8})]}),c.jsxs("mesh",{position:[0,.6,0],children:[c.jsx("sphereGeometry",{args:[.35,12,12]}),c.jsx("meshStandardMaterial",{color:3050286,roughness:.8})]})]}),c.jsx("group",{position:[0,3.5,-2],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[2,.4,.1]}),c.jsx("meshStandardMaterial",{color:2245802})]})})]})},{POKER_TABLE:cZ}=nt,uZ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("cylinderGeometry",{args:[1.2,1.2,.08,8]}),c.jsx("meshStandardMaterial",{color:2263842,roughness:.9})]}),c.jsxs("mesh",{position:[0,.8,0],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[1.1,32]}),c.jsx("meshStandardMaterial",{color:1997598,roughness:.95})]}),c.jsxs("mesh",{position:[0,.78,0],children:[c.jsx("torusGeometry",{args:[1.15,.08,8,32]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.6})]}),[45,135,225,315].map((n,e)=>{const t=n*Math.PI/180,r=Math.sin(t)*.8,s=Math.cos(t)*.8;return c.jsxs("mesh",{position:[r,.35,s],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.06,.08,.7,8]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.7})]},e)}),c.jsx(XS,{position:[-.4,.85,-.3],colors:[16711680,255]}),c.jsx(XS,{position:[.3,.85,.4],colors:[65280,16776960]}),c.jsx(XS,{position:[.5,.85,-.2],colors:[0,16777215]}),c.jsx(dZ,{position:[0,.82,0]})]}),XS=({position:n,colors:e})=>c.jsx("group",{position:n,children:[0,1,2,3,4].map(t=>c.jsxs("mesh",{position:[0,t*.02,0],children:[c.jsx("cylinderGeometry",{args:[.05,.05,.02,16]}),c.jsx("meshStandardMaterial",{color:e[t%2],roughness:.4})]},t))}),dZ=({position:n})=>c.jsxs("group",{position:n,children:[c.jsxs("mesh",{rotation:[0,.3,0],children:[c.jsx("boxGeometry",{args:[.12,.04,.18]}),c.jsx("meshStandardMaterial",{color:2245802,roughness:.5})]}),c.jsxs("mesh",{position:[.02,.025,.01],rotation:[0,.5,0],children:[c.jsx("boxGeometry",{args:[.12,.002,.18]}),c.jsx("meshStandardMaterial",{color:2245802,roughness:.5})]})]}),hZ=({position:n,rotation:e})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.5,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.5,.12,.5]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.7})]}),c.jsxs("mesh",{position:[0,.85,-.22],children:[c.jsx("boxGeometry",{args:[.5,.6,.08]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.7})]}),[-.28,.28].map((t,r)=>c.jsxs("mesh",{position:[t,.65,0],children:[c.jsx("boxGeometry",{args:[.06,.08,.4]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.6})]},r)),c.jsxs("mesh",{position:[0,.25,0],children:[c.jsx("cylinderGeometry",{args:[.05,.05,.4,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),[0,72,144,216,288].map((t,r)=>{const s=t*Math.PI/180;return c.jsxs("mesh",{position:[Math.sin(s)*.15,.03,Math.cos(s)*.15],rotation:[0,-s,Math.PI/2],children:[c.jsx("cylinderGeometry",{args:[.02,.02,.3,6]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]},r)})]}),fZ=()=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("circleGeometry",{args:[4,32]}),c.jsx("meshStandardMaterial",{color:2763317,roughness:.8,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),pZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[0,2.5,0],children:[c.jsxs("mesh",{children:[c.jsx("coneGeometry",{args:[.6,.4,16,1,!0]}),c.jsx("meshStandardMaterial",{color:3050286,side:Tn,roughness:.6})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("coneGeometry",{args:[.58,.38,16,1,!0]}),c.jsx("meshStandardMaterial",{color:14329120,side:vs,emissive:16768392,emissiveIntensity:n?.5:.1})]}),c.jsxs("mesh",{position:[0,-.1,0],children:[c.jsx("sphereGeometry",{args:[.08,16,16]}),c.jsx("meshStandardMaterial",{color:16777198,emissive:16777198,emissiveIntensity:n?1:.3})]}),c.jsxs("mesh",{position:[0,.7,0],children:[c.jsx("cylinderGeometry",{args:[.01,.01,1.2,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.8})]}),n&&c.jsx("spotLight",{color:16777181,intensity:2,distance:5,angle:Math.PI/3,penumbra:.5,position:[0,-.2,0],"target-position":[0,-3,0],castShadow:!0})]})},mZ=()=>{const{x:n,z:e}=cZ.POSITION,t=[0,90,180,270];return c.jsxs("group",{position:[n,0,e],children:[c.jsx(fZ,{}),c.jsx(uZ,{}),t.map((r,s)=>{const i=r*Math.PI/180,o=1.8;return c.jsx(hZ,{position:[Math.sin(i)*o,0,Math.cos(i)*o],rotation:-i+Math.PI},s)}),c.jsx(pZ,{}),c.jsxs("group",{position:[3,0,0],children:[c.jsxs("mesh",{position:[0,.5,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.3,.3,.04,16]}),c.jsx("meshStandardMaterial",{color:6636321,roughness:.6})]}),c.jsxs("mesh",{position:[0,.25,0],children:[c.jsx("cylinderGeometry",{args:[.05,.08,.5,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7})]}),c.jsxs("mesh",{position:[-.1,.58,.05],children:[c.jsx("cylinderGeometry",{args:[.04,.03,.12,8]}),c.jsx("meshStandardMaterial",{color:9127187,transparent:!0,opacity:.8})]}),c.jsxs("mesh",{position:[.1,.58,-.05],children:[c.jsx("cylinderGeometry",{args:[.04,.03,.12,8]}),c.jsx("meshStandardMaterial",{color:9127187,transparent:!0,opacity:.8})]})]})]})},{STAGE:ir}=nt,KS=({position:n,color:e})=>{const{isNightMode:t}=Pt();return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.15,.2,.3,12]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.8,roughness:.3})]}),c.jsxs("mesh",{position:[0,-.15,0],children:[c.jsx("cylinderGeometry",{args:[.12,.12,.05,12]}),c.jsx("meshStandardMaterial",{color:e,emissive:t?e:0,emissiveIntensity:t?.8:.2,transparent:!0,opacity:.9})]}),t&&c.jsxs("mesh",{position:[0,-1.5,0],rotation:[0,0,0],children:[c.jsx("coneGeometry",{args:[.8,3,12,1,!0]}),c.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:.1,side:Tn})]})]})},r3=({position:n,rotation:e=0})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[.6,1.2,.5]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.8})]}),c.jsxs("mesh",{position:[0,-.1,.26],children:[c.jsx("cylinderGeometry",{args:[.2,.18,.05,16]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.3})]}),c.jsxs("mesh",{position:[0,.35,.26],children:[c.jsx("cylinderGeometry",{args:[.08,.06,.04,12]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.4})]}),c.jsxs("mesh",{position:[0,0,.251],children:[c.jsx("planeGeometry",{args:[.5,1]}),c.jsx("meshStandardMaterial",{color:1710618,roughness:.9})]})]}),gZ=()=>c.jsxs("group",{position:[0,0,1.5],children:[c.jsxs("mesh",{position:[0,.05,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.25,.3,.1,16]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.6,roughness:.4})]}),c.jsxs("mesh",{position:[0,.75,0],children:[c.jsx("cylinderGeometry",{args:[.02,.02,1.4,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.4,.1],rotation:[Math.PI/6,0,0],children:[c.jsx("cylinderGeometry",{args:[.015,.015,.3,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7,roughness:.3})]}),c.jsxs("group",{position:[0,1.5,.2],children:[c.jsxs("mesh",{rotation:[Math.PI/6,0,0],children:[c.jsx("cylinderGeometry",{args:[.025,.03,.15,12]}),c.jsx("meshStandardMaterial",{color:4473924,metalness:.5,roughness:.4})]}),c.jsxs("mesh",{position:[0,.08,.04],rotation:[Math.PI/6,0,0],children:[c.jsx("sphereGeometry",{args:[.05,12,12]}),c.jsx("meshStandardMaterial",{color:2236962,metalness:.4,roughness:.6})]})]})]}),xZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,ir.HEIGHT/2,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[ir.WIDTH,ir.HEIGHT,ir.DEPTH]}),c.jsx("meshStandardMaterial",{color:4863784,roughness:.6})]}),c.jsxs("mesh",{position:[0,ir.HEIGHT/2,ir.DEPTH/2+.05],children:[c.jsx("boxGeometry",{args:[ir.WIDTH,ir.HEIGHT,.1]}),c.jsx("meshStandardMaterial",{color:13938487,metalness:.6,roughness:.3})]}),c.jsxs("mesh",{position:[0,.1,ir.DEPTH/2+.5],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2,.2,.8]}),c.jsx("meshStandardMaterial",{color:4863784,roughness:.6})]}),c.jsxs("mesh",{position:[0,ir.HEIGHT+.01,0],rotation:[-Math.PI/2,0,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[ir.WIDTH-.4,ir.DEPTH-.4]}),c.jsx("meshStandardMaterial",{color:3811866,roughness:.5,emissive:n?2232576:0,emissiveIntensity:n?.3:0})]})]})},vZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[0,2,-ir.DEPTH/2+.1],children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("boxGeometry",{args:[ir.WIDTH+1,4,.15]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.8,emissive:n?2228224:0,emissiveIntensity:.2})]}),c.jsxs("mesh",{position:[0,2.1,0],rotation:[0,0,Math.PI/2],children:[c.jsx("cylinderGeometry",{args:[.05,.05,ir.WIDTH+1.5,12]}),c.jsx("meshStandardMaterial",{color:13938487,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,2,.1],children:[c.jsx("boxGeometry",{args:[ir.WIDTH+1.2,.5,.1]}),c.jsx("meshStandardMaterial",{color:9109504,roughness:.7})]})]})},yZ=()=>{const{x:n,z:e}=ir.POSITION,t=ir.ROTATION||0;return c.jsxs("group",{position:[n,0,e],rotation:[0,t,0],children:[c.jsx(xZ,{}),c.jsx(vZ,{}),c.jsx(KS,{position:[-3,4,1],color:16729156}),c.jsx(KS,{position:[0,4,1],color:4521796}),c.jsx(KS,{position:[3,4,1],color:4474111}),c.jsx(r3,{position:[-ir.WIDTH/2-.5,.6,0],rotation:Math.PI/8}),c.jsx(r3,{position:[ir.WIDTH/2+.5,.6,0],rotation:-Math.PI/8}),c.jsx("group",{position:[0,ir.HEIGHT,0],children:c.jsx(gZ,{})}),c.jsx("group",{position:[0,4.5,-ir.DEPTH/2],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[3,.5,.1]}),c.jsx("meshStandardMaterial",{color:2236962})]})})]})},{LOUNGE:_Z}=nt,s3=({position:n,rotation:e=0,color:t=4878245})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.4,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2.5,.3,.9]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[0,.8,-.35],castShadow:!0,children:[c.jsx("boxGeometry",{args:[2.5,.6,.25]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[-1.15,.55,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.2,.6,.9]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[1.15,.55,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.2,.6,.9]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[0,.15,0],children:[c.jsx("boxGeometry",{args:[2.6,.2,1]}),c.jsx("meshStandardMaterial",{color:2763306,roughness:.6})]}),[[-1.1,.05,.35],[1.1,.05,.35],[-1.1,.05,-.35],[1.1,.05,-.35]].map((r,s)=>c.jsxs("mesh",{position:r,children:[c.jsx("cylinderGeometry",{args:[.05,.05,.1,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.5})]},s)),c.jsxs("mesh",{position:[-.9,.65,.1],rotation:[0,.2,.1],children:[c.jsx("boxGeometry",{args:[.35,.35,.15]}),c.jsx("meshStandardMaterial",{color:16752762,roughness:.9})]}),c.jsxs("mesh",{position:[.9,.65,.1],rotation:[0,-.2,-.1],children:[c.jsx("boxGeometry",{args:[.35,.35,.15]}),c.jsx("meshStandardMaterial",{color:10017154,roughness:.9})]})]}),SZ=()=>(Pt(),c.jsxs("group",{position:[0,0,0],children:[c.jsxs("mesh",{position:[0,.4,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[1.2,.05,.7]}),c.jsx("meshStandardMaterial",{color:6045747,roughness:.5})]}),c.jsxs("mesh",{position:[0,.43,0],children:[c.jsx("boxGeometry",{args:[1.1,.01,.6]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.3,roughness:.1})]}),c.jsxs("mesh",{position:[0,.15,0],children:[c.jsx("boxGeometry",{args:[1,.03,.5]}),c.jsx("meshStandardMaterial",{color:6045747,roughness:.6})]}),[[-.5,.2,.25],[.5,.2,.25],[-.5,.2,-.25],[.5,.2,-.25]].map((n,e)=>c.jsxs("mesh",{position:n,children:[c.jsx("boxGeometry",{args:[.05,.4,.05]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6})]},e)),c.jsxs("group",{position:[.3,.45,0],children:[c.jsxs("mesh",{rotation:[0,.3,0],children:[c.jsx("boxGeometry",{args:[.25,.02,.18]}),c.jsx("meshStandardMaterial",{color:16739179,roughness:.7})]}),c.jsxs("mesh",{position:[.05,.02,.02],rotation:[0,-.2,0],children:[c.jsx("boxGeometry",{args:[.25,.02,.18]}),c.jsx("meshStandardMaterial",{color:5164484,roughness:.7})]})]}),c.jsxs("group",{position:[-.35,.45,.1],children:[c.jsxs("mesh",{position:[0,.05,0],children:[c.jsx("cylinderGeometry",{args:[.04,.035,.1,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.3})]}),c.jsxs("mesh",{position:[.05,.05,0],rotation:[0,0,Math.PI/2],children:[c.jsx("torusGeometry",{args:[.025,.008,8,12,Math.PI]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.3})]})]})]})),i3=({position:n})=>{const{isNightMode:e}=Pt();return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{position:[0,.05,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.2,.22,.1,16]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.6,roughness:.4})]}),c.jsxs("mesh",{position:[0,.9,0],children:[c.jsx("cylinderGeometry",{args:[.02,.02,1.7,8]}),c.jsx("meshStandardMaterial",{color:3355443,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.7,0],children:[c.jsx("cylinderGeometry",{args:[.15,.25,.3,16,1,!0]}),c.jsx("meshStandardMaterial",{color:16115411,roughness:.8,side:Tn})]}),c.jsxs("mesh",{position:[0,1.65,0],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:16777198,emissive:e?16777096:4473856,emissiveIntensity:e?1:.3})]})]})},bZ=()=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[6,4]}),c.jsx("meshStandardMaterial",{color:9136404,roughness:.9,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),o3=({position:n,scale:e=1})=>c.jsxs("group",{position:n,scale:e,children:[c.jsxs("mesh",{position:[0,.15,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.15,.12,.3,12]}),c.jsx("meshStandardMaterial",{color:9127187,roughness:.7})]}),c.jsxs("mesh",{position:[0,.28,0],children:[c.jsx("cylinderGeometry",{args:[.13,.13,.04,12]}),c.jsx("meshStandardMaterial",{color:4007959,roughness:.9})]}),c.jsxs("mesh",{position:[0,.55,0],children:[c.jsx("sphereGeometry",{args:[.25,8,8]}),c.jsx("meshStandardMaterial",{color:2263842,roughness:.8})]}),c.jsxs("mesh",{position:[-.1,.7,.1],children:[c.jsx("sphereGeometry",{args:[.15,8,8]}),c.jsx("meshStandardMaterial",{color:3050286,roughness:.8})]}),c.jsxs("mesh",{position:[.1,.65,-.1],children:[c.jsx("sphereGeometry",{args:[.18,8,8]}),c.jsx("meshStandardMaterial",{color:2263842,roughness:.8})]})]}),wZ=()=>{const{x:n,z:e}=_Z.POSITION;return c.jsxs("group",{position:[n,0,e],children:[c.jsx(bZ,{}),c.jsx(s3,{position:[-2,0,0],rotation:Math.PI/2,color:4878245}),c.jsx(s3,{position:[2,0,0],rotation:-Math.PI/2,color:5930933}),c.jsx(SZ,{}),c.jsx(i3,{position:[-3.5,0,1.5]}),c.jsx(i3,{position:[3.5,0,1.5]}),c.jsx(o3,{position:[-3.5,0,-1.5],scale:1.2}),c.jsx(o3,{position:[3.5,0,-1.5],scale:1}),c.jsx("group",{position:[0,3,-2],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[2,.4,.1]}),c.jsx("meshStandardMaterial",{color:4878245})]})})]})},{KITCHEN:CZ}=nt,AZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[-4,0,-1.5],children:[c.jsxs("mesh",{position:[0,1.1,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[1.2,2.2,.8]}),c.jsx("meshStandardMaterial",{color:12632256,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,1.1,.41],children:[c.jsx("boxGeometry",{args:[.02,2,.01]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.5})]}),c.jsxs("mesh",{position:[-.15,1.3,.42],children:[c.jsx("boxGeometry",{args:[.03,.4,.04]}),c.jsx("meshStandardMaterial",{color:10066329,metalness:.8,roughness:.2})]}),c.jsxs("mesh",{position:[.15,1.3,.42],children:[c.jsx("boxGeometry",{args:[.03,.4,.04]}),c.jsx("meshStandardMaterial",{color:10066329,metalness:.8,roughness:.2})]}),c.jsxs("mesh",{position:[0,1.7,.41],children:[c.jsx("boxGeometry",{args:[1.1,.02,.01]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.5})]}),c.jsxs("mesh",{position:[.4,1.9,.42],children:[c.jsx("boxGeometry",{args:[.15,.08,.01]}),c.jsx("meshStandardMaterial",{color:1118481,emissive:n?43775:13141,emissiveIntensity:.4})]})]})},MZ=()=>c.jsxs("group",{position:[0,0,0],children:[c.jsxs("mesh",{position:[0,.45,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[3.5,.9,1.2]}),c.jsx("meshStandardMaterial",{color:3815994,roughness:.5})]}),c.jsxs("mesh",{position:[0,.92,0],castShadow:!0,receiveShadow:!0,children:[c.jsx("boxGeometry",{args:[3.7,.06,1.4]}),c.jsx("meshStandardMaterial",{color:13945272,roughness:.3,metalness:.1})]}),[-1.2,-.4,.4,1.2].map((n,e)=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[n,.45,.61],children:[c.jsx("boxGeometry",{args:[.7,.75,.02]}),c.jsx("meshStandardMaterial",{color:4473924,roughness:.4})]}),c.jsxs("mesh",{position:[n+.25,.45,.63],children:[c.jsx("sphereGeometry",{args:[.025,8,8]}),c.jsx("meshStandardMaterial",{color:11184810,metalness:.8})]})]},`door-f-${e}`)),[-1.2,-.4,.4,1.2].map((n,e)=>c.jsx("group",{children:c.jsxs("mesh",{position:[n,.45,-.61],children:[c.jsx("boxGeometry",{args:[.7,.75,.02]}),c.jsx("meshStandardMaterial",{color:4473924,roughness:.4})]})},`door-b-${e}`))]}),EZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[1.2,.95,0],children:[c.jsxs("mesh",{position:[0,.15,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.5,.3,.35]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.4,metalness:.3})]}),c.jsxs("mesh",{position:[-.05,.15,.18],children:[c.jsx("boxGeometry",{args:[.3,.2,.01]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.1,metalness:.2})]}),c.jsxs("mesh",{position:[.2,.15,.18],children:[c.jsx("boxGeometry",{args:[.08,.2,.01]}),c.jsx("meshStandardMaterial",{color:1118481,emissive:n?65280:13056,emissiveIntensity:.3})]}),c.jsxs("mesh",{position:[.12,.15,.19],children:[c.jsx("boxGeometry",{args:[.02,.15,.02]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7})]})]})},TZ=()=>c.jsxs("group",{position:[4,0,-1.5],children:[c.jsxs("mesh",{position:[0,1,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[1.2,2,.5]}),c.jsx("meshStandardMaterial",{color:6045747,roughness:.6})]}),[.4,.8,1.2,1.6].map((n,e)=>c.jsxs("group",{children:[c.jsxs("mesh",{position:[0,n,.05],children:[c.jsx("boxGeometry",{args:[1.1,.04,.45]}),c.jsx("meshStandardMaterial",{color:7029286,roughness:.5})]}),[-.35,-.1,.15,.35].map((t,r)=>c.jsxs("mesh",{position:[t,n+.1,.05],children:[c.jsx("boxGeometry",{args:[.15,.14,.08]}),c.jsx("meshStandardMaterial",{color:[16729156,4500036,16755234,4491519,16737996,11197764][(e*4+r)%6],roughness:.5})]},`snack-${e}-${r}`))]},`shelf-${e}`))]}),kZ=()=>c.jsxs("group",{position:[-.5,.95,.2],children:[c.jsxs("mesh",{position:[0,.06,0],children:[c.jsx("cylinderGeometry",{args:[.22,.15,.12,16]}),c.jsx("meshStandardMaterial",{color:9136404,roughness:.7})]}),c.jsxs("mesh",{position:[-.06,.16,.02],children:[c.jsx("sphereGeometry",{args:[.06,8,8]}),c.jsx("meshStandardMaterial",{color:13378082,roughness:.6})]}),c.jsxs("mesh",{position:[.07,.15,-.04],children:[c.jsx("sphereGeometry",{args:[.065,8,8]}),c.jsx("meshStandardMaterial",{color:16747520,roughness:.7})]}),c.jsxs("mesh",{position:[0,.18,.08],children:[c.jsx("sphereGeometry",{args:[.055,8,8]}),c.jsx("meshStandardMaterial",{color:4504354,roughness:.6})]}),c.jsxs("mesh",{position:[.05,.2,0],rotation:[0,0,.4],children:[c.jsx("capsuleGeometry",{args:[.025,.1,4,8]}),c.jsx("meshStandardMaterial",{color:16769333,roughness:.5})]})]}),RZ=()=>c.jsxs("group",{position:[-1.3,.95,-.1],children:[c.jsxs("mesh",{position:[0,.04,0],rotation:[0,.1,0],children:[c.jsx("boxGeometry",{args:[.45,.06,.45]}),c.jsx("meshStandardMaterial",{color:13936490,roughness:.8})]}),c.jsxs("mesh",{position:[.02,.1,-.01],rotation:[0,-.15,0],children:[c.jsx("boxGeometry",{args:[.45,.06,.45]}),c.jsx("meshStandardMaterial",{color:13936490,roughness:.8})]}),c.jsxs("mesh",{position:[.02,.135,-.01],rotation:[-Math.PI/2,0,0],children:[c.jsx("circleGeometry",{args:[.1,16]}),c.jsx("meshStandardMaterial",{color:13382451,roughness:.6})]})]}),NZ=()=>c.jsxs("group",{position:[.4,.95,-.25],children:[c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("cylinderGeometry",{args:[.2,.2,.02,16]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.3})]}),[{x:-.06,z:.04,color:13928286},{x:.06,z:-.04,color:16738740},{x:0,z:.07,color:9127187}].map((n,e)=>c.jsxs("mesh",{position:[n.x,.06,n.z],rotation:[Math.PI/2,0,e*.5],children:[c.jsx("torusGeometry",{args:[.04,.02,8,12]}),c.jsx("meshStandardMaterial",{color:n.color,roughness:.6})]},`donut-${e}`))]}),IZ=()=>{const{isNightMode:n}=Pt();return c.jsxs("group",{position:[-.1,.95,-.35],children:[c.jsxs("mesh",{position:[0,.04,0],children:[c.jsx("boxGeometry",{args:[.25,.06,.2]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.4})]}),c.jsxs("mesh",{position:[0,.14,0],children:[c.jsx("cylinderGeometry",{args:[.07,.08,.16,12]}),c.jsx("meshStandardMaterial",{color:3355443,transparent:!0,opacity:.6,roughness:.1})]}),c.jsxs("mesh",{position:[0,.1,0],children:[c.jsx("cylinderGeometry",{args:[.06,.07,.08,12]}),c.jsx("meshStandardMaterial",{color:4004866,roughness:.3})]}),c.jsxs("mesh",{position:[0,.3,-.06],children:[c.jsx("boxGeometry",{args:[.2,.25,.08]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.4})]}),c.jsxs("mesh",{position:[.08,.04,.11],children:[c.jsx("sphereGeometry",{args:[.012,8,8]}),c.jsx("meshStandardMaterial",{color:65280,emissive:n?65280:26112,emissiveIntensity:.5})]})]})},Pf=({position:n,rotation:e=0})=>c.jsxs("group",{position:n,rotation:[0,e,0],children:[c.jsxs("mesh",{position:[0,.75,0],castShadow:!0,children:[c.jsx("cylinderGeometry",{args:[.2,.2,.06,16]}),c.jsx("meshStandardMaterial",{color:3355443,roughness:.7})]}),c.jsxs("mesh",{position:[0,.79,0],children:[c.jsx("cylinderGeometry",{args:[.19,.19,.03,16]}),c.jsx("meshStandardMaterial",{color:13386820,roughness:.8})]}),c.jsxs("mesh",{position:[0,.38,0],children:[c.jsx("cylinderGeometry",{args:[.03,.03,.72,8]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,.03,0],children:[c.jsx("torusGeometry",{args:[.18,.02,8,16]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]}),c.jsxs("mesh",{position:[0,.3,0],children:[c.jsx("torusGeometry",{args:[.15,.015,8,16]}),c.jsx("meshStandardMaterial",{color:8947848,metalness:.7,roughness:.3})]})]}),PZ=()=>c.jsxs("group",{position:[-4,0,1],children:[c.jsxs("mesh",{position:[0,.4,0],castShadow:!0,children:[c.jsx("boxGeometry",{args:[.45,.8,.4]}),c.jsx("meshStandardMaterial",{color:15658734,roughness:.3})]}),c.jsxs("mesh",{position:[0,.65,.18],children:[c.jsx("boxGeometry",{args:[.2,.15,.08]}),c.jsx("meshStandardMaterial",{color:14540253,roughness:.3})]}),c.jsxs("mesh",{position:[-.05,.65,.23],children:[c.jsx("cylinderGeometry",{args:[.015,.015,.03,8]}),c.jsx("meshStandardMaterial",{color:16724787,metalness:.5})]}),c.jsxs("mesh",{position:[.05,.65,.23],children:[c.jsx("cylinderGeometry",{args:[.015,.015,.03,8]}),c.jsx("meshStandardMaterial",{color:3355647,metalness:.5})]}),c.jsxs("mesh",{position:[0,1.1,0],children:[c.jsx("cylinderGeometry",{args:[.14,.14,.55,12]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.4,roughness:.1})]}),c.jsxs("mesh",{position:[0,1,0],children:[c.jsx("cylinderGeometry",{args:[.13,.13,.35,12]}),c.jsx("meshStandardMaterial",{color:4491468,transparent:!0,opacity:.3,roughness:.1})]}),c.jsxs("mesh",{position:[0,1.38,0],children:[c.jsx("cylinderGeometry",{args:[.05,.14,.04,12]}),c.jsx("meshStandardMaterial",{color:8965375,transparent:!0,opacity:.5})]})]}),LZ=()=>c.jsxs("group",{children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.02,0],receiveShadow:!0,children:[c.jsx("planeGeometry",{args:[10,5]}),c.jsx("meshStandardMaterial",{color:9419919,roughness:.6,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1})]}),[-4,-2,0,2,4].map(n=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[n,.025,0],children:[c.jsx("planeGeometry",{args:[.03,5]}),c.jsx("meshStandardMaterial",{color:8039034,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2})]},`tile-x-${n}`)),[-2,0,2].map(n=>c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.025,n],children:[c.jsx("planeGeometry",{args:[10,.03]}),c.jsx("meshStandardMaterial",{color:8039034,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2})]},`tile-z-${n}`))]}),a3=({position:n})=>{const{isNightMode:e}=Pt();return c.jsxs("group",{position:n,children:[c.jsxs("mesh",{position:[0,.4,0],children:[c.jsx("cylinderGeometry",{args:[.008,.008,.8,6]}),c.jsx("meshStandardMaterial",{color:2236962})]}),c.jsxs("mesh",{position:[0,0,0],children:[c.jsx("cylinderGeometry",{args:[.08,.2,.15,16,1,!0]}),c.jsx("meshStandardMaterial",{color:2763306,roughness:.5,side:Tn})]}),c.jsxs("mesh",{position:[0,.02,0],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:16777198,emissive:e?16768392:5587968,emissiveIntensity:e?1:.3})]}),e&&c.jsx("pointLight",{position:[0,-.1,0],color:16768392,intensity:.5,distance:5,decay:2})]})},jZ=()=>{const{x:n,z:e}=CZ.POSITION;return c.jsxs("group",{position:[n,0,e],rotation:[0,-Math.PI/2,0],children:[c.jsx(LZ,{}),c.jsx(MZ,{}),c.jsx(AZ,{}),c.jsx(TZ,{}),c.jsx(EZ,{}),c.jsx(IZ,{}),c.jsx(kZ,{}),c.jsx(RZ,{}),c.jsx(NZ,{}),c.jsx(PZ,{}),c.jsx(Pf,{position:[-1,0,1.2]}),c.jsx(Pf,{position:[0,0,1.2]}),c.jsx(Pf,{position:[1,0,1.2]}),c.jsx(Pf,{position:[-.5,0,-1.2],rotation:Math.PI}),c.jsx(Pf,{position:[.5,0,-1.2],rotation:Math.PI}),c.jsx(a3,{position:[-1,3.5,0]}),c.jsx(a3,{position:[1,3.5,0]}),c.jsx("group",{position:[0,3,-2.5],children:c.jsxs("mesh",{children:[c.jsx("boxGeometry",{args:[2.2,.4,.1]}),c.jsx("meshStandardMaterial",{color:9419919})]})})]})},l3=()=>{const{isNightMode:n}=Pt(),e=n?13421772:16777215,t=3355443,r=n?13404296:16758465;return c.jsxs("group",{scale:.6,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.5,16,16]}),c.jsx("meshStandardMaterial",{color:e,roughness:.8})]}),c.jsxs("mesh",{position:[-.2,.3,.3],rotation:[.3,.5,0],children:[c.jsx("circleGeometry",{args:[.15,8]}),c.jsx("meshStandardMaterial",{color:t,side:Tn,roughness:.9})]}),c.jsxs("mesh",{position:[.25,.2,.25],rotation:[.2,-.3,.1],children:[c.jsx("circleGeometry",{args:[.12,8]}),c.jsx("meshStandardMaterial",{color:t,side:Tn,roughness:.9})]}),c.jsx(c3,{position:[-.35,.4,0],rotation:[0,0,-.3]}),c.jsx(c3,{position:[.35,.4,0],rotation:[0,0,.3]}),c.jsx(u3,{position:[-.45,.2,.1],rotation:[0,.5,-.3]}),c.jsx(u3,{position:[.45,.2,.1],rotation:[0,-.5,.3]}),c.jsxs("mesh",{position:[0,-.15,.45],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.25,12,12]}),c.jsx("meshStandardMaterial",{color:r,roughness:.6})]}),c.jsxs("mesh",{position:[-.08,-.18,.68],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsxs("mesh",{position:[.08,-.18,.68],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:3355443})]}),c.jsx(d3,{position:[-.18,.1,.4]}),c.jsx(d3,{position:[.18,.1,.4]})]})},c3=({position:n,rotation:e})=>{const{isNightMode:t}=Pt(),r=t?8947848:13935988;return c.jsxs("mesh",{position:n,rotation:e,castShadow:!0,children:[c.jsx("coneGeometry",{args:[.08,.3,8]}),c.jsx("meshStandardMaterial",{color:r,roughness:.5})]})},u3=({position:n,rotation:e})=>{const{isNightMode:t}=Pt(),r=t?13421772:16777215,s=t?13404296:16758465;return c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[.12,8,8,0,Math.PI]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,0,.02],scale:.7,children:[c.jsx("sphereGeometry",{args:[.1,8,8,0,Math.PI]}),c.jsx("meshStandardMaterial",{color:s,roughness:.8})]})]})},d3=({position:n})=>c.jsxs("group",{position:n,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[.08,12,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.2})]}),c.jsxs("mesh",{position:[0,0,.06],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:2236962,roughness:.1})]}),c.jsxs("mesh",{position:[.02,.02,.08],children:[c.jsx("sphereGeometry",{args:[.015,6,6]}),c.jsx("meshStandardMaterial",{color:16777215,emissive:16777215,emissiveIntensity:.3})]})]}),BZ=()=>{const{isNightMode:n}=Pt(),e=n?9136404:12887118,t=n?4007959:6636321,r=n?6710886:8947848;return c.jsxs("group",{scale:.6,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.45,16,16]}),c.jsx("meshStandardMaterial",{color:e,roughness:.8})]}),c.jsxs("mesh",{position:[0,-.1,.5],rotation:[-.3,0,0],castShadow:!0,children:[c.jsx("capsuleGeometry",{args:[.2,.4,8,16]}),c.jsx("meshStandardMaterial",{color:e,roughness:.8})]}),c.jsxs("mesh",{position:[0,-.2,.85],castShadow:!0,children:[c.jsx("sphereGeometry",{args:[.18,12,12]}),c.jsx("meshStandardMaterial",{color:r,roughness:.6})]}),c.jsxs("mesh",{position:[-.06,-.22,.98],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:2236962})]}),c.jsxs("mesh",{position:[.06,-.22,.98],children:[c.jsx("sphereGeometry",{args:[.04,8,8]}),c.jsx("meshStandardMaterial",{color:2236962})]}),c.jsx(DZ,{color:t}),c.jsx(h3,{position:[-.25,.45,0],rotation:[.3,.2,-.2]}),c.jsx(h3,{position:[.25,.45,0],rotation:[.3,-.2,.2]}),c.jsx(f3,{position:[-.25,.15,.3]}),c.jsx(f3,{position:[.25,.15,.3]}),c.jsxs("mesh",{position:[0,.2,.42],rotation:[.2,0,0],children:[c.jsx("planeGeometry",{args:[.1,.25]}),c.jsx("meshStandardMaterial",{color:16777215,side:Tn,roughness:.8})]})]})},DZ=({color:n})=>c.jsxs("group",{children:[[-.15,-.05,.05,.15].map((e,t)=>c.jsxs("mesh",{position:[0,.45-t*.05,e-.1],rotation:[.3-t*.1,0,0],castShadow:!0,children:[c.jsx("coneGeometry",{args:[.08+t*.02,.2,6]}),c.jsx("meshStandardMaterial",{color:n,roughness:.9})]},t)),c.jsxs("mesh",{position:[0,.2,-.4],rotation:[.8,0,0],children:[c.jsx("boxGeometry",{args:[.15,.4,.1]}),c.jsx("meshStandardMaterial",{color:n,roughness:.9})]})]}),h3=({position:n,rotation:e})=>{const{isNightMode:t}=Pt(),r=t?9136404:12887118,s=t?13408665:16764108;return c.jsxs("group",{position:n,rotation:e,children:[c.jsxs("mesh",{castShadow:!0,children:[c.jsx("coneGeometry",{args:[.08,.25,6]}),c.jsx("meshStandardMaterial",{color:r,roughness:.8})]}),c.jsxs("mesh",{position:[0,.02,.03],scale:.6,children:[c.jsx("coneGeometry",{args:[.06,.18,6]}),c.jsx("meshStandardMaterial",{color:s,roughness:.8})]})]})},f3=({position:n})=>c.jsxs("group",{position:n,children:[c.jsxs("mesh",{children:[c.jsx("sphereGeometry",{args:[.07,12,12]}),c.jsx("meshStandardMaterial",{color:16777215,roughness:.2})]}),c.jsxs("mesh",{position:[0,0,.04],children:[c.jsx("sphereGeometry",{args:[.05,8,8]}),c.jsx("meshStandardMaterial",{color:4863264,roughness:.3})]}),c.jsxs("mesh",{position:[0,0,.06],children:[c.jsx("sphereGeometry",{args:[.025,6,6]}),c.jsx("meshStandardMaterial",{color:1118481,roughness:.1})]}),c.jsxs("mesh",{position:[.02,.02,.07],children:[c.jsx("sphereGeometry",{args:[.012,6,6]}),c.jsx("meshStandardMaterial",{color:16777215,emissive:16777215,emissiveIntensity:.3})]})]}),OZ=({headRotation:n})=>{const e=N.useRef(null);vr(()=>{e.current&&n&&(e.current.rotation.x=Oa.lerp(e.current.rotation.x,n.x,.1),e.current.rotation.y=Oa.lerp(e.current.rotation.y,n.y,.1))});const t=15235612,r=1710618,s=16119280;return c.jsxs("group",{ref:e,position:[0,1.65,0],children:[c.jsxs("mesh",{position:[0,0,.05],scale:[.22,.2,.22],children:[c.jsx("sphereGeometry",{args:[1,16,12]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[-.12,-.02,.15],scale:[.1,.08,.08],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[.12,-.02,.15],scale:[.1,.08,.08],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.06,.2],scale:[.1,.08,.1],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:s,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.02,.28],children:[c.jsx("sphereGeometry",{args:[.035,12,12]}),c.jsx("meshStandardMaterial",{color:16737945,roughness:.5})]}),c.jsxs("group",{position:[-.14,.18,-.02],children:[c.jsxs("mesh",{rotation:[0,0,Math.PI/8],scale:[.06,.08,.03],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[.01,-.01,.015],rotation:[0,0,Math.PI/8],scale:[.035,.05,.02],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:16758465,roughness:.7})]})]}),c.jsxs("group",{position:[.14,.18,-.02],children:[c.jsxs("mesh",{rotation:[0,0,-Math.PI/8],scale:[.06,.08,.03],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:t,roughness:.8})]}),c.jsxs("mesh",{position:[-.01,-.01,.015],rotation:[0,0,-Math.PI/8],scale:[.035,.05,.02],children:[c.jsx("coneGeometry",{args:[1,1,4]}),c.jsx("meshStandardMaterial",{color:16758465,roughness:.7})]})]}),[-.06,0,.06].map((i,o)=>c.jsxs("mesh",{position:[i,.12,.12],rotation:[.3,0,0],scale:[.015,.04,.01],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:r,roughness:.9})]},o)),[1,2,3].map(i=>c.jsxs(Cn.Fragment,{children:[c.jsxs("mesh",{position:[-.18+i*.01,.02-i*.03,.08],rotation:[0,Math.PI/6,Math.PI/8],scale:[.01,.03,.01],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:r,roughness:.9})]}),c.jsxs("mesh",{position:[.18-i*.01,.02-i*.03,.08],rotation:[0,-Math.PI/6,-Math.PI/8],scale:[.01,.03,.01],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:r,roughness:.9})]})]},i)),c.jsxs("mesh",{position:[-.08,.04,.18],children:[c.jsx("sphereGeometry",{args:[.035,12,12]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[.08,.04,.18],children:[c.jsx("sphereGeometry",{args:[.035,12,12]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[-.08,.04,.21],children:[c.jsx("sphereGeometry",{args:[.018,8,8]}),c.jsx("meshStandardMaterial",{color:1710618})]}),c.jsxs("mesh",{position:[.08,.04,.21],children:[c.jsx("sphereGeometry",{args:[.018,8,8]}),c.jsx("meshStandardMaterial",{color:1710618})]}),[-1,1].map(i=>c.jsx(Cn.Fragment,{children:[0,1,2].map(o=>c.jsxs("mesh",{position:[i*(.08+o*.015),-.04-o*.015,.22],scale:[.01,.01,.01],children:[c.jsx("sphereGeometry",{args:[1,6,6]}),c.jsx("meshStandardMaterial",{color:1710618})]},o))},i))]})},FZ=({headRotation:n})=>{const e=N.useRef(null),t=N.useRef(null),r=N.useRef(null),s=N.useRef(0);vr(u=>{s.current=Math.sin(u.clock.elapsedTime*3)*.05,t.current&&(t.current.rotation.z=Math.PI/10+s.current),r.current&&(r.current.rotation.z=-Math.PI/10-s.current),e.current&&n&&(e.current.rotation.x=Oa.lerp(e.current.rotation.x,n.x,.1),e.current.rotation.y=Oa.lerp(e.current.rotation.y,n.y,.1))});const i=13943988,o=16758465,a=16751001,l=16777215;return c.jsxs("group",{ref:e,position:[0,1.65,0],children:[c.jsxs("mesh",{position:[0,0,.05],scale:[.2,.18,.2],children:[c.jsx("sphereGeometry",{args:[1,16,12]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[-.1,-.02,.12],scale:[.08,.07,.06],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[.1,-.02,.12],scale:[.08,.07,.06],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.04,.18],scale:[.08,.06,.08],children:[c.jsx("sphereGeometry",{args:[1,12,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,-.01,.24],children:[c.jsx("sphereGeometry",{args:[.03,12,12]}),c.jsx("meshStandardMaterial",{color:a,roughness:.4})]}),c.jsxs("group",{ref:t,position:[-.08,.2,0],children:[c.jsxs("mesh",{scale:[.04,.18,.025],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,0,.015],scale:[.025,.14,.01],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:o,roughness:.7})]})]}),c.jsxs("group",{ref:r,position:[.08,.2,0],children:[c.jsxs("mesh",{scale:[.04,.18,.025],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:i,roughness:.9})]}),c.jsxs("mesh",{position:[0,0,.015],scale:[.025,.14,.01],children:[c.jsx("capsuleGeometry",{args:[1,1,4,8]}),c.jsx("meshStandardMaterial",{color:o,roughness:.7})]})]}),c.jsxs("mesh",{position:[-.07,.04,.16],children:[c.jsx("sphereGeometry",{args:[.04,12,12]}),c.jsx("meshStandardMaterial",{color:1710618})]}),c.jsxs("mesh",{position:[.07,.04,.16],children:[c.jsx("sphereGeometry",{args:[.04,12,12]}),c.jsx("meshStandardMaterial",{color:1710618})]}),c.jsxs("mesh",{position:[-.06,.05,.19],children:[c.jsx("sphereGeometry",{args:[.012,8,8]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[.08,.05,.19],children:[c.jsx("sphereGeometry",{args:[.012,8,8]}),c.jsx("meshStandardMaterial",{color:16777215})]}),c.jsxs("mesh",{position:[-.015,-.1,.2],scale:[.02,.03,.015],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:l,roughness:.3})]}),c.jsxs("mesh",{position:[.015,-.1,.2],scale:[.02,.03,.015],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:l,roughness:.3})]}),[-1,1].map(u=>c.jsx(Cn.Fragment,{children:[-1,0,1].map(d=>c.jsxs("mesh",{position:[u*.12,-.03+d*.02,.18],rotation:[0,0,u*Math.PI/12+d*.1],scale:[.08,.003,.003],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:8947848,roughness:.5})]},d))},u))]})},Wp=({text:n,yOffset:e=3,maxChars:t=50,variant:r="work"})=>{const s=r==="conversation",i=s?16777215:1710638,o=s?13421772:4886745,a=s?"#222222":"#ffffff",l=s?4886745:4906624,u=N.useMemo(()=>{if(!n)return"";const h=n.trim().replace(/\s+/g," ");return h.length>t?h.substring(0,t-3)+"...":h},[n,t]),d=N.useMemo(()=>{const b=u.length*.12;return{width:Math.min(Math.max(b+.6,2),5),height:.7}},[u]);return n?c.jsx(r2,{follow:!0,lockX:!1,lockY:!1,lockZ:!1,children:c.jsxs("group",{position:[0,e,0],children:[c.jsx(Ov,{args:[d.width,d.height,.08],radius:.12,smoothness:4,position:[0,0,0],children:c.jsx("meshBasicMaterial",{color:i,transparent:!0,opacity:.92})}),c.jsx(Ov,{args:[d.width+.04,d.height+.04,.06],radius:.14,smoothness:4,position:[0,0,-.02],children:c.jsx("meshBasicMaterial",{color:o,transparent:!0,opacity:.3})}),c.jsxs("mesh",{position:[0,-d.height/2-.15,0],children:[c.jsx("bufferGeometry",{children:c.jsx("float32BufferAttribute",{attach:"attributes-position",args:[new Float32Array([-.15,.18,0,.15,.18,0,0,-.08,0]),3]})}),c.jsx("meshBasicMaterial",{color:i,transparent:!0,opacity:.92,side:Tn})]}),c.jsxs("mesh",{position:[0,-d.height/2-.15,-.02],children:[c.jsx("bufferGeometry",{children:c.jsx("float32BufferAttribute",{attach:"attributes-position",args:[new Float32Array([-.18,.2,0,.18,.2,0,0,-.12,0]),3]})}),c.jsx("meshBasicMaterial",{color:o,transparent:!0,opacity:.3,side:Tn})]}),c.jsxs("mesh",{position:[-d.width/2+.25,0,.05],children:[c.jsx("circleGeometry",{args:[.08,16]}),c.jsx("meshBasicMaterial",{color:l})]}),c.jsx(ap,{position:[.1,0,.05],fontSize:.18,color:a,anchorX:"center",anchorY:"middle",maxWidth:d.width-.8,outlineWidth:0,children:u})]})}):null},gD=({xOffset:n=.5,yOffset:e=1.8})=>{const t=N.useRef(null),r=N.useRef(null),s=N.useRef(null),i=N.useRef(null);return vr(o=>{const a=o.clock.elapsedTime;if(t.current&&(t.current.position.y=e+Math.sin(a*.8)*.2,t.current.rotation.y=a*.5),r.current){const l=a*.5%1;r.current.position.y=l*.6,r.current.position.x=Math.sin(l*Math.PI)*.1;const u=r.current.children[0];u!=null&&u.material&&(u.material.opacity=1-l*.5)}if(s.current){const l=(a*.5+.33)%1;s.current.position.y=.3+l*.6,s.current.position.x=.15+Math.sin(l*Math.PI)*.1;const u=s.current.children[0];u!=null&&u.material&&(u.material.opacity=1-l*.5)}if(i.current){const l=(a*.5+.66)%1;i.current.position.y=.6+l*.6,i.current.position.x=.3+Math.sin(l*Math.PI)*.1;const u=i.current.children[0];u!=null&&u.material&&(u.material.opacity=1-l*.5)}}),c.jsx(r2,{follow:!0,children:c.jsxs("group",{ref:t,position:[n,e,0],children:[c.jsx("group",{ref:r,position:[0,0,0],children:c.jsx(ap,{fontSize:.2,color:"#4466aa",anchorX:"center",anchorY:"middle","material-transparent":!0,"material-opacity":1,children:"z"})}),c.jsx("group",{ref:s,position:[.15,.3,0],children:c.jsx(ap,{fontSize:.25,color:"#4466aa",anchorX:"center",anchorY:"middle","material-transparent":!0,"material-opacity":1,children:"Z"})}),c.jsx("group",{ref:i,position:[.3,.6,0],children:c.jsx(ap,{fontSize:.3,color:"#4466aa",anchorX:"center",anchorY:"middle","material-transparent":!0,"material-opacity":1,children:"Z"})})]})})},cl=16777215,ul=14540253,o2=({thoughts:n,yOffset:e=3.5,changeInterval:t=5e3})=>{const r=N.useRef(null),[s,i]=N.useState(()=>Math.floor(Math.random()*n.length));N.useEffect(()=>{if(n.length<=1)return;const d=setInterval(()=>{i(h=>{let f=Math.floor(Math.random()*n.length);for(;f===h&&n.length>1;)f=Math.floor(Math.random()*n.length);return f})},t+Math.random()*2e3);return()=>clearInterval(d)},[n.length,t]);const o=n[s]||"",a=N.useMemo(()=>{const y=o.length*.11;return{width:Math.min(Math.max(y+.6,2),4.5),height:.6}},[o]);if(vr(d=>{if(r.current){const h=d.clock.elapsedTime;r.current.position.y=e+Math.sin(h*1.2)*.05}}),n.length===0)return null;const l=a.width/2,u=a.height/2;return c.jsx(r2,{follow:!0,lockX:!1,lockY:!1,lockZ:!1,children:c.jsxs("group",{ref:r,position:[0,e,0],children:[c.jsx(Ov,{args:[a.width+.08,a.height+.08,.04],radius:u+.02,smoothness:4,position:[0,0,-.03],children:c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.5})}),c.jsx(Ov,{args:[a.width,a.height,.06],radius:u,smoothness:4,children:c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})}),c.jsxs("mesh",{position:[-l*.45,u*.55,-.01],children:[c.jsx("circleGeometry",{args:[.28,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[-l*.1,u*.7,-.01],children:[c.jsx("circleGeometry",{args:[.32,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[l*.2,u*.75,-.01],children:[c.jsx("circleGeometry",{args:[.35,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[l*.5,u*.5,-.01],children:[c.jsx("circleGeometry",{args:[.25,24]}),c.jsx("meshBasicMaterial",{color:cl,transparent:!0,opacity:.95})]}),c.jsxs("mesh",{position:[-l*.45,u*.55,-.04],children:[c.jsx("circleGeometry",{args:[.32,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-l*.1,u*.7,-.04],children:[c.jsx("circleGeometry",{args:[.36,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[l*.2,u*.75,-.04],children:[c.jsx("circleGeometry",{args:[.39,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[l*.5,u*.5,-.04],children:[c.jsx("circleGeometry",{args:[.29,24]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-.1,-u-.22,0],children:[c.jsx("circleGeometry",{args:[.12,16]}),c.jsx("meshBasicMaterial",{color:cl})]}),c.jsxs("mesh",{position:[-.28,-u-.48,0],children:[c.jsx("circleGeometry",{args:[.08,16]}),c.jsx("meshBasicMaterial",{color:cl})]}),c.jsxs("mesh",{position:[-.4,-u-.66,0],children:[c.jsx("circleGeometry",{args:[.055,12]}),c.jsx("meshBasicMaterial",{color:cl})]}),c.jsxs("mesh",{position:[-.1,-u-.22,-.02],children:[c.jsx("circleGeometry",{args:[.15,16]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-.28,-u-.48,-.02],children:[c.jsx("circleGeometry",{args:[.11,16]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsxs("mesh",{position:[-.4,-u-.66,-.02],children:[c.jsx("circleGeometry",{args:[.075,12]}),c.jsx("meshBasicMaterial",{color:ul,transparent:!0,opacity:.4})]}),c.jsx(ap,{position:[0,0,.05],fontSize:.16,color:"#222222",anchorX:"center",anchorY:"middle",maxWidth:a.width-.4,outlineWidth:0,children:o})]})})},p3={wander:["Taking a short break","Stretching my legs...","Nice day for a walk","Just wandering around","Looking around the office","Enjoying the break"],couch:["Time to relax...","The couch looks comfy","Need a quick rest","Recharging batteries...","A short nap sounds nice","So cozy..."],stage:["Time to perform!","Let me show my moves","My turn on stage!","Dance time!","Here goes nothing!","Watch this!"],break_room:["Coffee break!","Need some caffeine","Grabbing a coffee","Time for a snack","Chatting over coffee","This coffee is good"],poker_table:["All in!","Read my poker face","Feeling lucky!","Good hand...","I call!","Bluffing time!"],kitchen:["Mmm, pizza!","Grabbing a snack","Anyone want a donut?","I love fruit!","Making some coffee","Snack time!"],pickleball:["Pickleball time!","Nice serve!","Dink shot!","Game on!","Love the outdoors","Kitchen line rally!"],golf:["Putting practice!","Read the green...","Fore!","Birdie putt!","Nice chip!","Almost a hole-in-one!"],sit_outdoor:["Fresh air is nice","Enjoying the sunshine","Peaceful out here","Good to be outside","Nice breeze today","Taking in the view"]},UZ={wandering:["One more thing...","Innovation never sleeps","Think different","Stay hungry, stay foolish","Simplicity is genius"],checking_agent:["How's the project?","Show me the progress","Let's ship it!","Is it insanely great?","Focus on quality"],watching_stage:["Great performance!","Impressive work!","Bravo!","Now that is innovation!"],resting:["Creative thinking...","Recharging ideas","Next big thing...","Connecting the dots"],visiting_kitchen:["Need some fuel...","Coffee powers innovation","Mmm, smells good!","A snack break","Grabbing an apple"],walking_to_target:["On my way...","Places to be","Let's go check","Heading over"]},HZ={wandering:["Making the rounds","AI-first approach","Cloud strategy...","Organizing the world","Open source matters"],talking_to_agent:["Let's discuss this","How can I help?","Collaboration time","Great teamwork!","Keep it up!"],presenting:["Here's our vision","AI for everyone","Let me present this","Exciting updates!"],walking_circle:["Deep thinking...","Strategic planning","Processing ideas","What if we..."],visiting_kitchen:["Time for chai!","Grabbing a coffee","Snack break!","Need some energy","Mmm, looks good!"],walking_to_target:["On my way...","Let's see what's next","Heading over","Time to check in"]},zZ={wandering:["TSLA up 5% today!","Tesla stock is mooning!","Starship launch soon...","SpaceX landing failed...","Ugh, rapid unscheduled","Mars colony by 2030!","Need more Starlinks","Full self driving soon","The Cybertruck sells!","X is the everything app","First principles only","Boring tunnel progress?","Neuralink update...","TSLA to the moon!","SpaceX booster caught!","Stock looking good today"],talking_to_agent:["Ship it yesterday!","Is this 10x better?","Move faster, come on!","This needs more urgency","First principles, think!","Are we on Mars yet?","Tesla needs this done","SpaceX pace, people!"],visiting_kitchen:["Quick Diet Coke break","No time, grabbing coffee","Back to the factory","Fuel up, ship more"],watching_stage:["This could help Tesla","SpaceX could use this!","Interesting tech demo","Think bigger though!","Not disruptive enough"]},GZ={wandering:["Is this VR or real?","Where are my glasses?","The metaverse is real!","Llama 4 training soon","Meta Quest is the future","Can't see without headset","VR world looks better","Reality is overrated","Llama beats GPT now!","Open source AI wins!","Meta AI is shipping!","Need better VR lenses","The glasses are blurry","Metaverse rendering...","Is this AR or VR?","Horizon Worlds update","Llama needs more GPUs","Zuck mode: activated"],talking_to_agent:["Try the Quest headset!","Have you used Llama?","VR meeting instead?","What's the Llama score?","Build for the metaverse","Open source this!","Meta AI can help here","Put this in VR!"],visiting_kitchen:["Sweet Baby Rays time!","BBQ sauce on everything","Smoking some meats","Refueling for VR"],watching_stage:["This needs VR mode!","Put this in metaverse","Llama could do this","Ship it on Quest!","Great engagement!"]},WZ={wandering:["Everyone buys my GPUs!","NVDA up again today!","The more you buy...","...the more you save!","CUDA runs the world!","H100s sold out again!","Blackwell is crushing it","AI needs more GPUs!","Stock at all time high!","Every company needs us","Leather jacket: on","GPU shortage = demand!","Training runs need me","Inference at scale baby!","They all use my chips","NVIDIA is the platform","Data centers love us!","Cloud needs more GPUs!"],talking_to_agent:["Using CUDA, right?","Need more H100s?","GPU utilization good?","Buy more GPUs!","NVIDIA powers this!","Tensor cores maxed?","More compute = better","Accelerate everything!"],presenting:["One more GPU reveal!","NVIDIA is the future!","AI runs on our chips","Blackwell architecture!","The roadmap is amazing"],visiting_kitchen:["Even the oven has GPUs","Quick fuel, more GPUs","Cooking with CUDA cores","Kitchen break, stock up"],watching_stage:["Bet that runs on NVIDIA","Needs more GPU power!","Great demo, our chips?","Standing ovation!","I love this industry!"]},VZ={wandering:["Wow, look at Crewly go!","I created all of this...","What a beautiful creation","My vision, brought to life","Crewly is my masterpiece","This factory is incredible","Look at what we built!","Every agent, every detail...","From idea to reality","This is beyond what I imagined","Crewly changes everything","I can't believe how far we've come","This is just the beginning","What a great company"],talking_to_agent:["I made you, you know","How's my creation doing?","You make me proud!","Keep building great things","This is what I envisioned","You're the heart of Crewly","Amazing work, keep going!","Built with love, running with purpose"],visiting_kitchen:["Even creators need coffee","Quick break, then more building","Fueling the vision","Grabbing a bite"],watching_stage:["Look at them perform!","Crewly talent on display","This is what it's all about","Incredible team!"],playing_golf:["Fore!","Nice putt!","Even founders need a break","Golf clears the mind","Back to building after this","Love this putting green","Great day for golf"]};function m3(n,e){let t=0;const r=n+e.toString();for(let s=0;s<r.length;s++){const i=r.charCodeAt(s);t=(t<<5)-t+i,t=t&t}return Math.abs(t%1e3)/1e3}const g3={coffeeBreak:{min:4,max:8},idle:{min:6,max:12}},x3=["Walking","Running","Jumping"],XZ=["Dance","Salsa dancing"],KZ=["Sitting","Idle","Breathing idle"];function JZ(n,e,t){const r=N.useRef({currentAnim:"",lastChangeTime:0,currentIdleIndex:0}),s=N.useRef(null),i=N.useCallback((h,f)=>{if(h.length===0)return t.working;if(h.length===1)return h[0];const g=f?h.filter(b=>b!==f):h;if(g.length===0)return h[0];const y=Math.floor(m3(n.id,Date.now())*g.length);return g[y]},[n.id,t.working]),o=N.useCallback((h,f=.5,g=.5)=>{var b,p,m;if(!e)return;const y=r.current;if(y.currentAnim!==h)if(y.currentAnim&&e[y.currentAnim]&&((b=e[y.currentAnim])==null||b.fadeOut(g)),e[h])(p=e[h])==null||p.reset().fadeIn(f).play(),y.currentAnim=h,y.lastChangeTime=Date.now();else{const x=Object.keys(e)[0];x&&e[x]&&((m=e[x])==null||m.reset().fadeIn(f).play(),y.currentAnim=x,y.lastChangeTime=Date.now())}},[e]),a=N.useCallback((h,f)=>{s.current&&(clearTimeout(s.current),s.current=null);const g=f.min+m3(n.id,Date.now())*(f.max-f.min);s.current=setTimeout(()=>{const y=r.current,b=i(h,y.currentAnim);o(b,.8,.8),a(h,f)},g*1e3)},[n.id,i,o]);N.useEffect(()=>{if(!e||Object.keys(e).length===0)return;const h=n.status==="active"&&n.cpuPercent>10,f=n.status==="active"&&n.cpuPercent<=10,g=n.status==="idle";if(s.current&&(clearTimeout(s.current),s.current=null),h)o(t.working);else if(f){const y=i(t.coffeeBreak);o(y),a(t.coffeeBreak,g3.coffeeBreak)}else if(g){const y=i(t.idle);o(y),a(t.idle,g3.idle)}return()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,n.status,n.cpuPercent,t,o,i,a]);const l=r.current.currentAnim,u=x3.includes(l);let d="other";return x3.includes(l)?d="walking":XZ.includes(l)?d="dancing":KZ.includes(l)&&(d="resting"),{currentAnimation:l,isWalking:u,activity:d}}const e_={COW:{working:"Typing",coffeeBreak:["Idle","Walking","Breathing idle"],idle:["Sitting","Idle","Walking","Breathing idle"]},HORSE:{working:"Typing",coffeeBreak:["Breathing idle","Walking","Idle"],idle:["Sitting","Breathing idle","Walking","Idle"]},TIGER:{working:"Typing",coffeeBreak:["Breathing idle","Running","Walking"],idle:["Sitting","Breathing idle","Walking","Running"]},RABBIT:{working:"Pilot flips switches",coffeeBreak:["Sitting","Walking","Jumping"],idle:["Sitting","Breathing idle","Walking","Jumping"]}};function a2(n){const{hoveredEntityId:e,selectedEntityId:t,setHoveredEntity:r,selectEntity:s}=Pt(),i=e===n,o=t===n,a=N.useCallback(d=>{d.stopPropagation(),r(n),document.body.style.cursor="pointer"},[n,r]),l=N.useCallback(()=>{r(null),document.body.style.cursor="default"},[r]),u=N.useCallback(d=>{d.stopPropagation(),s(n)},[n,s]);return{isHovered:i,isSelected:o,handlePointerOver:a,handlePointerOut:l,handleClick:u}}function qZ(n){const e=new Map,t=new Map,r=n.clone();return xD(n,r,function(s,i){e.set(i,s),t.set(s,i)}),r.traverse(function(s){if(!s.isSkinnedMesh)return;const i=s,o=e.get(s),a=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=a.map(function(l){return t.get(l)}),i.bind(i.skeleton,i.bindMatrix)}),r}function xD(n,e,t){t(n,e);for(let r=0;r<n.children.length;r++)xD(n.children[r],e.children[r],t)}function l2(n){let e;try{e=qZ(n)}catch(r){console.warn("SkeletonUtils.clone failed, using basic clone:",r),e=n.clone(!0)}const t=r=>{if(!r||typeof r.clone!="function")return console.warn("Material without clone method encountered, using fallback"),new An({color:8947848,metalness:0,roughness:.7});try{const s=r.clone();if(s.isMeshStandardMaterial){const i=s;i.metalnessMap=null,i.roughnessMap=null,i.metalness=0,i.roughness=.7,i.needsUpdate=!0}return s}catch(s){return console.warn("Material clone failed, using fallback:",s),new An({color:8947848,metalness:0,roughness:.7})}};return e.traverse(r=>{r instanceof kn&&r.material&&(Array.isArray(r.material)?r.material=r.material.map(t):r.material=t(r.material))}),e}function c2(n){return n.map(e=>{const t=e.tracks.filter(r=>!(r.name.includes("Hips")&&r.name.endsWith(".position")));return new Wl(e.name,e.duration,t,e.blendMode)})}function u2(n){n.traverse(e=>{var t;e instanceof kn&&((t=e.geometry)==null||t.dispose(),Array.isArray(e.material)?e.material.forEach(r=>r.dispose()):e.material&&e.material.dispose())})}function $Z(n){for(;n>Math.PI;)n-=Math.PI*2;for(;n<-Math.PI;)n+=Math.PI*2;return n}function Na(n,e,t,r=3){const s=$Z(e-n.rotation.y);n.rotation.y+=s*Math.min(1,t*r)}function d2(n,e,t=4491519){return n?{color:16755200,opacity:1,emissive:16755200,emissiveIntensity:.8}:e?{color:6737151,opacity:.9,emissive:6737151,emissiveIntensity:.5}:{color:t,opacity:.6,emissive:0,emissiveIntensity:0}}const YZ={kitchen:15,couch:12,break_room:12,poker_table:12,stage:8,watch_stage:10,wander:15,pickleball:8,golf:8,sit_outdoor:8},QZ={kitchen:15,couch:10,break_room:5,poker_table:5,stage:0,watch_stage:12,wander:15,check_agent:28,pickleball:5,golf:5,sit_outdoor:5},ZZ={kitchen:15,couch:5,break_room:5,poker_table:5,stage:0,watch_stage:8,wander:15,check_agent:22,present:10,walk_circle:5,pickleball:5,golf:5,sit_outdoor:5},eee={kitchen:8,couch:5,break_room:5,poker_table:8,stage:0,watch_stage:10,wander:18,check_agent:18,pickleball:10,golf:8,sit_outdoor:10},tee={kitchen:10,couch:5,break_room:8,poker_table:5,stage:0,watch_stage:10,wander:15,check_agent:20,pickleball:8,golf:12,sit_outdoor:8},nee={kitchen:12,couch:8,break_room:8,poker_table:5,stage:0,watch_stage:12,wander:15,check_agent:25,present:8,pickleball:3,golf:3,sit_outdoor:5},ree={kitchen:10,couch:5,break_room:5,poker_table:5,stage:0,watch_stage:8,wander:12,check_agent:15,pickleball:10,golf:18,sit_outdoor:12},see={kitchen:18,couch:5,break_room:5,poker_table:5,stage:0,watch_stage:8,wander:45,pickleball:5,golf:5,sit_outdoor:5},iee={go_to_workstation:[5,10],go_to_kitchen:[6,14],go_to_couch:[10,20],go_to_break_room:[8,15],go_to_poker_table:[8,15],go_to_stage:[15,30],watch_stage:[10,20],wander:[3,8],check_agent:[3,7],present:[8,13],walk_circle:[10,15],go_to_pickleball:[10,20],go_to_golf:[10,20],sit_outdoor:[8,18]},vD={kitchen:"go_to_kitchen",couch:"go_to_couch",break_room:"go_to_break_room",poker_table:"go_to_poker_table",stage:"go_to_stage",watch_stage:"watch_stage",wander:"wander",workstation:"go_to_workstation",check_agent:"check_agent",present:"present",walk_circle:"walk_circle",pickleball:"go_to_pickleball",golf:"go_to_golf",sit_outdoor:"sit_outdoor"},yD={wander:"wander",go_to_couch:"couch",go_to_stage:"stage",go_to_break_room:"break_room",go_to_poker_table:"poker_table",go_to_kitchen:"kitchen",watch_stage:"wander",go_to_workstation:"wander",go_to_pickleball:"pickleball",go_to_golf:"golf",sit_outdoor:"sit_outdoor",check_agent:"wander",present:"wander",walk_circle:"wander"},h2=new Set(["go_to_pickleball","go_to_golf","sit_outdoor"]),oee={couch:2,break_room:4,poker_table:4,kitchen:5};function aee(n){var r;const e=n.reduce((s,[,i])=>s+i,0);if(e<=0)return null;let t=Math.random()*e;for(const[s,i]of n)if(t-=i,t<=0)return s;return((r=n[n.length-1])==null?void 0:r[0])??null}function lee(n,e,t){const r=[],s=Object.keys(n);for(const i of s){const o=n[i];if(o===void 0||o<=0)continue;const a=vD[i];a&&a!==e&&(a==="go_to_stage"&&t.stageOccupied||a==="go_to_couch"&&N0("couch",t)||a==="go_to_break_room"&&N0("break_room",t)||a==="go_to_poker_table"&&N0("poker_table",t)||a==="go_to_kitchen"&&N0("kitchen",t)||r.push([i,o]))}return r}function N0(n,e){if(!e.seatOccupancy)return!1;const t=e.seatOccupancy[n]??0,r=oee[n]??0;return t>=r}function Zc(n){const e=iee[n];return e[0]+Math.random()*(e[1]-e[0])}function cee(n,e={}){const[t,r]=e.stepCount??[2,5],s=t+Math.floor(Math.random()*(r-t+1)),i=[];let o=null;for(let a=0;a<s;a++){const l=lee(n,o,e);if(l.length===0){i.push({type:"wander",duration:Zc("wander")}),o="wander";continue}const u=aee(l);if(!u){i.push({type:"wander",duration:Zc("wander")}),o="wander";continue}const d=vD[u];d&&(i.push({type:d,duration:Zc(d)}),o=d)}return i.length===0&&i.push({type:"wander",duration:Zc("wander")}),{steps:i,currentStepIndex:0,paused:!1,arrivalTime:null}}function f2(n,e){const t=N.useRef(null),r=N.useRef(null),s=N.useRef(e);s.current=e;const[i,o]=N.useState(null),a=N.useRef(null),l=N.useCallback(x=>{x!==a.current&&(a.current=x,o(x))},[]),u=N.useCallback(x=>{const v=cee(s.current,x);t.current=v,v.steps.length>0&&l(v.steps[0].type)},[l]),d=N.useCallback(()=>{const x=t.current;return!x||x.paused||x.currentStepIndex>=x.steps.length?null:x.steps[x.currentStepIndex]},[]),h=N.useCallback(()=>{const x=t.current;if(!x){u();return}x.currentStepIndex++,x.arrivalTime=null,x.currentStepIndex>=x.steps.length?u():l(x.steps[x.currentStepIndex].type)},[u,l]),f=N.useCallback(()=>{t.current&&(t.current.paused=!0)},[]),g=N.useCallback(()=>{t.current&&(t.current.paused=!1,t.current.arrivalTime=null)},[]),y=N.useCallback(()=>{t.current&&!r.current&&(r.current={...t.current}),t.current={steps:[{type:"watch_stage",duration:1/0}],currentStepIndex:0,paused:!1,arrivalTime:null},l("watch_stage")},[l]),b=N.useCallback(()=>{var x;return((x=t.current)==null?void 0:x.paused)??!1},[]),p=N.useCallback(x=>{t.current&&(t.current.arrivalTime=x)},[]),m=N.useCallback(x=>{const v=t.current;if(!v||v.arrivalTime===null)return!1;const w=v.steps[v.currentStepIndex];return w?x-v.arrivalTime>=w.duration:!1},[]);return{planRef:t,getCurrentStep:d,advanceStep:h,newPlan:u,pause:f,resume:g,interruptForStage:y,isPaused:b,displayStepType:i,markArrival:p,isDurationElapsed:m,savedPlanRef:r}}const Lc={radiusX:12,minZ:-3,maxZ:8};function I0(n,e,t,r=.3,s=.3){if(!n||t.currentAnim===e)return;let i=n[e];!i&&e!=="Idle"&&(i=n.Idle??n["Breathing idle"]??null),i&&(Object.values(n).forEach(o=>o==null?void 0:o.fadeOut(r)),i.reset().fadeIn(s).play(),t.currentAnim=e)}const JS=nt.MOVEMENT.COUCH_SEAT_HEIGHT,uee=2,v3=2;function Hw(n,e,t,r,s){for(const i of s){if(Math.abs(i.x-t)<.1&&Math.abs(i.z-r)<.1)continue;const o=n-i.x,a=e-i.z;if(o*o+a*a<v3*v3)return!0}return!1}function y3(n,e,t,r,s,i,o){if(!Hw(n,e,s,i,o))return{x:n,z:e};const a=n-t,l=e-r,u=Math.atan2(l,a),d=[{x:t+Math.cos(u+Math.PI/2)*2,z:r+Math.sin(u+Math.PI/2)*2},{x:t+Math.cos(u-Math.PI/2)*2,z:r+Math.sin(u-Math.PI/2)*2},{x:t-a*.5,z:r-l*.5}];for(const h of d)if(!Hw(h.x,h.z,s,i,o))return h;return{x:t,z:r}}const dee=yD,t_=({agent:n,config:e})=>{var ue;const t=N.useRef(null),r=N.useRef({currentPos:{x:0,z:0},initialized:!1,wasWorking:!1,currentAnim:"",claimedSeatArea:null,arrived:!1}),s=N.useRef(!1),i=On(e.modelPath),o=N.useMemo(()=>l2(i.scene),[i.scene]),a=N.useMemo(()=>c2(i.animations),[i.animations]),{actions:l,mixer:u}=Zy(a,o);JZ(n,l,e.animationConfig);const{agents:d,zones:h,npcPositions:f,updateAgentPosition:g,entityConversations:y,claimSeat:b,releaseSeat:p,getSeatOccupancy:m,claimStage:x,releaseStage:v,isStageOccupied:w,stagePerformerRef:C,consumeEntityCommand:M,entityPositionMapRef:T}=Pt(),{isHovered:A,isSelected:E,handlePointerOver:R,handlePointerOut:j,handleClick:L}=a2(n.id),D=f2(n.id,YZ),z=nt.STAGE.POSITION,q=nt.LOUNGE.POSITION,X=nt.LOUNGE.COUCH_POSITIONS,K=nt.BREAK_ROOM.POSITION,I=nt.POKER_TABLE.POSITION,B=nt.KITCHEN.POSITION,F=nt.PICKLEBALL.POSITION,O=nt.GOLF.POSITION,W=nt.OUTDOOR_BENCH.POSITIONS,J=N.useMemo(()=>h.get(n.projectName),[h,n.projectName]),$=N.useMemo(()=>J?J.workstations[n.workstationIndex]:null,[J,n.workstationIndex]),ie=N.useMemo(()=>{const ee=[];return h.forEach(pe=>{pe.workstations.forEach(Z=>{ee.push({x:Z.position.x,z:Z.position.z})})}),ee},[h]),oe=d2(E,A,4491519);N.useEffect(()=>()=>{u2(o);const ee=r.current;ee.claimedSeatArea&&p(ee.claimedSeatArea,n.id),v(n.id)},[o,n.id,p,v]);const U=(ee,pe)=>{if(!$)return null;const Z=$.position.x,be=$.position.z;switch(ee.type){case"go_to_workstation":return{x:$.position.x,z:$.position.z+nt.AGENT.WORKSTATION_OFFSET,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Math.PI};case"go_to_stage":return x(n.id)?{x:z.x,z:z.z,arrivalY:nt.STAGE.HEIGHT,arrivalAnim:e.danceAnimation,arrivalRot:-Math.PI/2}:null;case"go_to_couch":{const re=b("couch",n.id);if(re<0||!X[re])return null;pe.claimedSeatArea="couch";const ce=X[re];return{x:q.x+ce.x,z:q.z+ce.z,arrivalY:JS,arrivalAnim:e.sitAnimation,arrivalRot:ce.rotation}}case"go_to_break_room":{const re=b("break_room",n.id);if(re<0)return null;pe.claimedSeatArea="break_room";const ce=re*Math.PI/2,le=K.x+Math.sin(ce)*1.3,fe=K.z+Math.cos(ce)*1.3,Q=Math.atan2(K.x-le,K.z-fe);return{x:le,z:fe,arrivalY:JS,arrivalAnim:e.sitAnimation,arrivalRot:Q}}case"go_to_poker_table":{const re=b("poker_table",n.id);if(re<0)return null;pe.claimedSeatArea="poker_table";const ce=re*Math.PI/2,le=I.x+Math.sin(ce)*1.8,fe=I.z+Math.cos(ce)*1.8,Q=Math.atan2(I.x-le,I.z-fe);return{x:le,z:fe,arrivalY:JS,arrivalAnim:e.sitAnimation,arrivalRot:Q}}case"go_to_kitchen":{const re=b("kitchen",n.id);if(re<0)return null;pe.claimedSeatArea="kitchen";const ce=nt.KITCHEN.SEAT_POSITIONS,le=ce[re%ce.length];return{x:B.x+le.x,z:B.z+le.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:le.rotation}}case"watch_stage":{const re=nt.STAGE.AUDIENCE_POSITIONS,ce=re[Math.floor(Math.random()*re.length)];return{x:ce.x,z:ce.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Math.PI/2}}case"go_to_pickleball":{const re=F.x+(Math.random()-.5)*6,ce=F.z+(Math.random()-.5)*8;return{x:re,z:ce,arrivalY:0,arrivalAnim:"Breathing idle"}}case"go_to_golf":{const re=O.x+(Math.random()-.5)*6,ce=O.z+(Math.random()-.5)*6;return{x:re,z:ce,arrivalY:0,arrivalAnim:"Breathing idle"}}case"sit_outdoor":{const re=W[Math.floor(Math.random()*W.length)];return{x:re.x,z:re.z,arrivalY:0,arrivalAnim:e.sitAnimation,arrivalRot:re.rotation}}case"wander":default:{const re=e.wanderRadiusX??Lc.radiusX,ce=$.position.z+(e.wanderMinZ??Lc.minZ),le=$.position.z+(e.wanderMaxZ??Lc.maxZ);for(let fe=0;fe<10;fe++){const Q=$.position.x+(Math.random()-.5)*re*2,Te=ce+Math.random()*(le-ce),we=y3(Q,Te,pe.currentPos.x,pe.currentPos.z,Z,be,ie);if(pD(we.x,we.z,Fv))return{x:we.x,z:we.z,arrivalY:0,arrivalAnim:"Breathing idle"}}return{x:Z,z:$.position.z+(e.wanderMinZ??Lc.minZ),arrivalY:0,arrivalAnim:"Breathing idle"}}}};vr((ee,pe)=>{var Te,we;if(!t.current||!$)return;u==null||u.update(pe);const Z=r.current,be=n.status==="active",re=n.status==="idle",ce=ee.clock.elapsedTime;if(A&&!E){I0(l,"Breathing idle",Z,.3,.3),g(n.id,t.current.position);return}const le=M(n.id);let fe=!1;le&&(Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),v(n.id),D.planRef.current={steps:[{type:le.stepType,duration:Zc(le.stepType)}],currentStepIndex:0,paused:!1,arrivalTime:null,commanded:!0},Z.arrived=!1,Z.wasWorking=!1,s.current=!1,fe=!0);const Q=((Te=D.planRef.current)==null?void 0:Te.commanded)??!1;if(be&&!fe&&!Q){Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),v(n.id),t.current.position.x=$.position.x,t.current.position.y=0,t.current.position.z=$.position.z+nt.AGENT.WORKSTATION_OFFSET,t.current.rotation.y=Math.PI,Z.wasWorking=!0,Z.arrived=!1,Z.currentPos.x=t.current.position.x,Z.currentPos.z=t.current.position.z;const _e=e.animationConfig.working,Me=l==null?void 0:l[_e];Me&&!Me.isRunning()&&(Object.values(l).forEach(Y=>Y==null?void 0:Y.fadeOut(.3)),Me.reset().fadeIn(.3).play()),Z.currentAnim=_e;return}if(re||fe||Q){const _e=y.has(n.id),Me=((we=D.planRef.current)==null?void 0:we.commanded)??!1;if(_e&&!D.isPaused()&&!Me?(D.pause(),s.current=!0,I0(l,"Breathing idle",Z)):!_e&&s.current&&(D.resume(),s.current=!1,Z.arrived=!1),D.isPaused()){const ge=y.get(n.id);if(ge){const me=d.get(ge.partnerId),ze=f.get(ge.partnerId),Oe=(me==null?void 0:me.currentPosition)||(me==null?void 0:me.basePosition)||ze;if(Oe){const We=Math.atan2(Oe.x-Z.currentPos.x,Oe.z-Z.currentPos.z);Na(t.current,We,pe,5)}}g(n.id,t.current.position);return}D.planRef.current||(D.newPlan({stageOccupied:w(),seatOccupancy:m()}),Z.wasWorking=!1,Z.arrived=!1);const Y=D.getCurrentStep();if(!Y){D.newPlan({stageOccupied:w(),seatOccupancy:m()}),Z.arrived=!1,g(n.id,t.current.position);return}if(!Y.target){const ge=U(Y,Z);if(!ge){Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),v(n.id),D.advanceStep(),Z.arrived=!1,g(n.id,t.current.position);return}Y.target={x:ge.x,z:ge.z},Y.arrivalY=ge.arrivalY,Y.arrivalAnimation=ge.arrivalAnim,Y.arrivalRotation=ge.arrivalRot}const G=Y.target.x-t.current.position.x,ae=Y.target.z-t.current.position.z,Se=Math.sqrt(G*G+ae*ae);if(!Z.arrived&&Se>.5){t.current.position.y=0;const ge=Se>e.runThreshold,me=ge?e.runSpeed:e.walkSpeed;I0(l,ge?"Running":"Walking",Z);const Oe=Math.min(me*pe,Se),We=t.current.position.x+G/Se*Oe,Ge=t.current.position.z+ae/Se*Oe,Le=$.position.x,Ve=$.position.z,Xe=h2.has(Y.type),xe=Hw(We,Ge,Le,Ve,ie),Ce=lp(We,Ge,Fv),Ze=$c(We,Ge),he=!Xe&&(Math.abs(Ze.x-We)>.01||Math.abs(Ze.z-Ge)>.01),je=i2(We,Ge,n.id,T.current);if(!xe&&!Ce&&!he&&!je)t.current.position.x=We,t.current.position.z=Ge;else if(Y.type==="wander"){const ke=e.wanderRadiusX??Lc.radiusX,$e=$.position.z+(e.wanderMinZ??Lc.minZ),Ie=$.position.z+(e.wanderMaxZ??Lc.maxZ),Re=$.position.x+(Math.random()-.5)*ke*2,Fe=$e+Math.random()*(Ie-$e),rt=y3(Re,Fe,t.current.position.x,t.current.position.z,Le,Ve,ie);Y.target={x:rt.x,z:rt.z}}Na(t.current,Math.atan2(G,ae),pe,5),Z.currentPos.x=t.current.position.x,Z.currentPos.z=t.current.position.z}else Z.arrived?(Y.arrivalRotation!==void 0&&Na(t.current,Y.arrivalRotation,pe,3),D.isDurationElapsed(ce)&&(Z.claimedSeatArea&&(p(Z.claimedSeatArea,n.id),Z.claimedSeatArea=null),Y.type==="go_to_stage"&&v(n.id),t.current.position.y=0,D.advanceStep(),Z.arrived=!1)):(Z.arrived=!0,D.markArrival(ce),Y.arrivalAnimation&&I0(l,Y.arrivalAnimation,Z),Y.arrivalRotation!==void 0&&(t.current.rotation.y=Y.arrivalRotation),Y.arrivalY!==void 0&&(t.current.position.y=Y.arrivalY))}g(n.id,t.current.position)});const te=D.displayStepType?dee[D.displayStepType]??"wander":"wander";return c.jsxs("group",{ref:t,position:[n.basePosition.x,0,n.basePosition.z],rotation:[0,Math.PI,0],onPointerOver:R,onPointerOut:j,onClick:L,children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,nt.CIRCLE_INDICATOR.Y_OFFSET,0],children:[c.jsx("circleGeometry",{args:[A||E?nt.CIRCLE_INDICATOR.RADIUS_ACTIVE:nt.CIRCLE_INDICATOR.RADIUS_DEFAULT,nt.CIRCLE_INDICATOR.SEGMENTS]}),c.jsx("meshStandardMaterial",{color:oe.color,emissive:oe.emissive,emissiveIntensity:oe.emissiveIntensity,transparent:!0,opacity:oe.opacity})]}),c.jsx("primitive",{object:o,scale:uee}),(()=>{const ee=y.get(n.id);return ee!=null&&ee.currentLine?c.jsx(Wp,{text:ee.currentLine,yOffset:3.5,variant:"conversation"}):null})(),!((ue=y.get(n.id))!=null&&ue.currentLine)&&n.status==="active"&&n.cpuPercent>10&&n.activity&&c.jsx(Wp,{text:n.activity,yOffset:3.2}),!y.has(n.id)&&n.status==="idle"&&(A||E)&&c.jsx(o2,{thoughts:p3[te]||p3.wander,yOffset:3.5}),n.status==="idle"&&D.displayStepType==="go_to_couch"&&c.jsx(gD,{yOffset:4})]})};On.preload(bn.COW);const hee={modelPath:bn.COW,animationConfig:e_.COW,runSpeed:3,walkSpeed:1.2,runThreshold:2,danceAnimation:"Dance",sitAnimation:"Sitting"},fee=({agent:n})=>c.jsx(t_,{agent:n,config:hee});On.preload(bn.HORSE);const pee={modelPath:bn.HORSE,animationConfig:e_.HORSE,runSpeed:3,walkSpeed:1.2,runThreshold:2,danceAnimation:"Talking",sitAnimation:"Sitting"},mee=({agent:n})=>c.jsx(t_,{agent:n,config:pee});On.preload(bn.TIGER);const gee={modelPath:bn.TIGER,animationConfig:e_.TIGER,runSpeed:3.5,walkSpeed:1.5,runThreshold:1.5,danceAnimation:"Salsa dancing",sitAnimation:"Sitting"},xee=({agent:n})=>c.jsx(t_,{agent:n,config:gee});On.preload(bn.RABBIT);const vee={modelPath:bn.RABBIT,animationConfig:e_.RABBIT,runSpeed:2.8,walkSpeed:1,runThreshold:1.8,danceAnimation:"Silly dancing",sitAnimation:"Sitting"},yee=({agent:n})=>c.jsx(t_,{agent:n,config:vee});On.preload(bn.ROBOT);On.preload(bn.HORSE);On.preload(bn.TIGER);On.preload(bn.RABBIT);const _ee=({agent:n})=>{const e=N.useRef(null),t=N.useRef(null),{scene:r,animations:s}=On(bn.ROBOT),i=N.useMemo(()=>{const f=Qq.clone(r);return f.traverse(g=>{(g.name==="Head"||g.name.includes("head"))&&(g.visible=!1)}),f},[r]),{actions:o,mixer:a}=Zy(s,i),l=N.useRef({currentAction:"Idle",activityMode:"typing",modeStartTime:0,modeDuration:5+Math.random()*10,typingOffset:Math.random()*Math.PI*2,coffeeBreakState:{mode:"drinking",modeStartTime:0,modeDuration:8+Math.random()*12,walkAngle:0,walkRadius:1.5+Math.random()*.5}}),{zones:u}=Pt(),d=N.useMemo(()=>u.get(n.projectName),[u,n.projectName]),h=N.useMemo(()=>d?d.workstations[n.workstationIndex]:null,[d,n.workstationIndex]);return N.useEffect(()=>{o.Idle&&o.Idle.play()},[o]),N.useEffect(()=>()=>{a&&a.stopAllAction(),i.traverse(f=>{var g;f instanceof kn&&((g=f.geometry)==null||g.dispose(),Array.isArray(f.material)?f.material.forEach(y=>y.dispose()):f.material&&f.material.dispose())})},[a,i]),vr((f,g)=>{if(!e.current||!h)return;const y=f.clock.elapsedTime,b=l.current,p=n.status==="active"&&n.cpuPercent>10;a==null||a.update(g),n.status==="active"&&p?bee(e.current,t.current,h,b,y,g,o):n.status==="active"&&!p?wee(e.current,t.current,h,b,y,g,o):n.status==="idle"&&Cee(e.current,t.current,h,b,y,o)}),h?c.jsxs("group",{ref:e,position:[n.basePosition.x,0,n.basePosition.z],rotation:[0,Math.PI,0],children:[c.jsx("primitive",{object:i,scale:nt.AGENT.ROBOT_SCALE}),c.jsx("group",{ref:t,position:[0,1.4,0],scale:3.5,children:c.jsx(See,{type:n.animalType})}),n.status==="active"&&n.cpuPercent>10&&n.activity&&c.jsx(Wp,{text:n.activity}),n.status==="idle"&&c.jsx(gD,{})]}):null},See=({type:n})=>{switch(n){case"cow":return c.jsx(l3,{});case"horse":return c.jsx(BZ,{});case"tiger":return c.jsx(OZ,{});case"rabbit":return c.jsx(FZ,{});default:return c.jsx(l3,{})}};function bee(n,e,t,r,s,i,o){const a=s*4,l=s*1.5;if(s-r.modeStartTime>r.modeDuration){const h=["typing","typing","typing","thinking","reading"];r.activityMode=h[Math.floor(Math.random()*h.length)],r.modeStartTime=s,r.modeDuration=3+Math.random()*8}const u=Math.sin(l)*.01,d=r.activityMode==="typing"?Math.sin(a*2)*.005:0;if(n.position.x=t.position.x+u,n.position.y=d,n.position.z=t.position.z+nt.AGENT.WORKSTATION_OFFSET,n.rotation.y=Math.PI,e)if(r.activityMode==="typing"){const h=Math.sin(a*.8)*.15,f=Math.sin(a*1.2)*.08;e.rotation.x=-.25+f,e.rotation.y=h}else if(r.activityMode==="thinking"){const h=Math.sin(s*.6);e.rotation.x=-.1+h*.15,e.rotation.y=Math.sin(l)*.2}else e.rotation.x=-.3,e.rotation.y=Math.sin(l*.7)*.1;Uv(o,r,"Idle")}function wee(n,e,t,r,s,i,o){const a=r.coffeeBreakState;if(s-a.modeStartTime>a.modeDuration&&(a.mode=a.mode==="drinking"?"walking":"drinking",a.modeStartTime=s,a.modeDuration=8+Math.random()*12),a.mode==="drinking"){if(n.position.set(t.position.x,0,t.position.z+.5),n.rotation.set(-.08,Math.PI+.2,0),e){const l=s*.4,u=Math.sin(l*.5)*.25;e.rotation.x=-.15+Math.sin(l*.3)*.05,e.rotation.y=u}Uv(o,r,"Idle")}else{a.walkAngle+=i*.3;const l=t.position.x,u=t.position.z+2,d=l+Math.sin(a.walkAngle)*a.walkRadius,h=u+Math.abs(Math.cos(a.walkAngle))*a.walkRadius*.5;n.position.set(d,0,h);const f=Math.atan2(Math.cos(a.walkAngle)*a.walkRadius,Math.abs(Math.sin(a.walkAngle))*a.walkRadius*.5);n.rotation.set(0,f,0),e&&(e.rotation.x=-.1,e.rotation.y=Math.sin(s*.3)*.3),Uv(o,r,"Walking")}}function Cee(n,e,t,r,s,i){const o=t.position.x+1.5,a=t.position.z+1;if(n.rotation.order="YXZ",n.rotation.set(-Math.PI/2,0,0),n.position.set(o,.3,a),e){const l=Math.sin(s*.5+r.typingOffset)*.5+.5;e.rotation.x=l*.05,e.rotation.z=l*.03}Uv(i,r,"Idle"),i.Idle&&(i.Idle.timeScale=.3)}function Uv(n,e,t){if(e.currentAction!==t&&n[t]){const r=n[e.currentAction],s=n[t],i=nt.AGENT.ANIMATION_FADE_DURATION;r&&r.fadeOut(i),s&&s.reset().fadeIn(i).play(),e.currentAction=t}}const Aee=()=>{const{agents:n}=Pt(),e=N.useMemo(()=>Array.from(n.values()),[n]);return c.jsx("group",{children:e.map(t=>{const r=(()=>{switch(t.animalType){case"cow":return c.jsx(fee,{agent:t});case"horse":return c.jsx(mee,{agent:t});case"tiger":return c.jsx(xee,{agent:t});case"rabbit":return c.jsx(yee,{agent:t});default:return c.jsx(_ee,{agent:t})}})();return c.jsx(N.Suspense,{fallback:null,children:r},t.id)})})},{STAGE:Mee}=nt;On.preload(bn.COW);On.preload(bn.HORSE);const Eee=4,Tee=2,kee=yD,_3={wander:["Just looking around","Nice office!","Where is everyone?","Taking a stroll","Exploring the factory"],couch:["Time to relax...","The couch looks comfy","Need a quick rest"],kitchen:["Snack time!","I smell coffee!","Mmm, pizza!","This coffee is great","Love the donuts!"],break_room:["Coffee break!","Need some caffeine","Taking five minutes"],poker_table:["All in!","Read my poker face","Bluffing time!"],stage:["Great show!","Amazing!","Encore!","Love it!","Bravo!"]};function P0(n,e,t,r=.3,s=.3){if(!n||t.currentAnim===e)return;let i=n[e];!i&&e!=="Idle"&&(i=n.Idle??n["Breathing idle"]??null),i&&(Object.values(n).forEach(o=>o==null?void 0:o.fadeOut(r)),i.reset().fadeIn(s).play(),t.currentAnim=e)}const Ree=({audiencePosition:n,modelPath:e,index:t,allObstacles:r})=>{const s=N.useRef(null),i=On(e),o=`fake-audience-${t}`,{agents:a,npcPositions:l,updateNpcPosition:u,entityConversations:d,stagePerformerRef:h,claimSeat:f,releaseSeat:g,getSeatOccupancy:y,isStageOccupied:b,consumeEntityCommand:p,entityPositionMapRef:m}=Pt(),{isHovered:x,isSelected:v,handlePointerOver:w,handlePointerOut:C,handleClick:M}=a2(o),T=d2(v,x,8421504),A=f2(o,see),E=N.useRef({currentPos:{x:n.x-10+t*3,z:n.z+t*2},initialized:!1,claimedSeatArea:null,arrived:!1,currentAnim:""}),R=N.useRef(!1),j=N.useRef(null),L=N.useRef(0),D=N.useRef(0),z=N.useRef(!1);nt.STAGE.POSITION;const q=nt.KITCHEN.POSITION,X=nt.LOUNGE.POSITION,K=nt.LOUNGE.COUCH_POSITIONS,I=nt.BREAK_ROOM.POSITION,B=nt.POKER_TABLE.POSITION,F=nt.PICKLEBALL.POSITION,O=nt.GOLF.POSITION,W=nt.OUTDOOR_BENCH.POSITIONS,J=N.useMemo(()=>l2(i.scene),[i.scene]),$=N.useMemo(()=>c2(i.animations),[i.animations]),{actions:ie,mixer:oe}=Zy($,J);N.useEffect(()=>()=>{u2(J);const ee=E.current;ee.claimedSeatArea&&g(ee.claimedSeatArea,o)},[J,o,g]);const U=(ee,pe)=>{switch(ee.type){case"watch_stage":return{x:n.x,z:n.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Math.PI/2};case"go_to_kitchen":{const Z=f("kitchen",o);if(Z<0)return null;pe.claimedSeatArea="kitchen";const be=nt.KITCHEN.SEAT_POSITIONS,re=be[Z%be.length];return{x:q.x+re.x,z:q.z+re.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:re.rotation}}case"go_to_couch":{const Z=f("couch",o);if(Z<0||!K[Z])return null;pe.claimedSeatArea="couch";const be=K[Z];return{x:X.x+be.x,z:X.z+be.z,arrivalY:nt.MOVEMENT.COUCH_SEAT_HEIGHT,arrivalAnim:"Breathing idle",arrivalRot:be.rotation}}case"go_to_break_room":{const Z=f("break_room",o);if(Z<0)return null;pe.claimedSeatArea="break_room";const be=Z*Math.PI/2,re=I.x+Math.sin(be)*1.3,ce=I.z+Math.cos(be)*1.3,le=Math.atan2(I.x-re,I.z-ce);return{x:re,z:ce,arrivalY:nt.MOVEMENT.COUCH_SEAT_HEIGHT,arrivalAnim:"Breathing idle",arrivalRot:le}}case"go_to_poker_table":{const Z=f("poker_table",o);if(Z<0)return null;pe.claimedSeatArea="poker_table";const be=Z*Math.PI/2,re=B.x+Math.sin(be)*1.8,ce=B.z+Math.cos(be)*1.8,le=Math.atan2(B.x-re,B.z-ce);return{x:re,z:ce,arrivalY:nt.MOVEMENT.COUCH_SEAT_HEIGHT,arrivalAnim:"Breathing idle",arrivalRot:le}}case"go_to_pickleball":{const Z=F.x+(Math.random()-.5)*6,be=F.z+(Math.random()-.5)*8;return{x:Z,z:be,arrivalY:0,arrivalAnim:"Breathing idle"}}case"go_to_golf":{const Z=O.x+(Math.random()-.5)*6,be=O.z+(Math.random()-.5)*6;return{x:Z,z:be,arrivalY:0,arrivalAnim:"Breathing idle"}}case"sit_outdoor":{const Z=W[Math.floor(Math.random()*W.length)];return{x:Z.x,z:Z.z,arrivalY:0,arrivalAnim:"Breathing idle",arrivalRot:Z.rotation}}case"wander":default:{const Z=lx(r);return{x:Z.x,z:Z.z,arrivalY:0,arrivalAnim:"Breathing idle"}}}};vr((ee,pe)=>{var Y;if(!s.current)return;oe==null||oe.update(pe);const Z=E.current,be=ee.clock.elapsedTime;if(x&&!v){P0(ie,"Breathing idle",Z),s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z;return}if(!Z.initialized){const G=lx(r);Z.currentPos={x:G.x,z:G.z},s.current.position.set(G.x,0,G.z),Z.initialized=!0}const re=p(o);re&&(Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),z.current=!1,A.planRef.current={steps:[{type:re.stepType,duration:Zc(re.stepType)}],currentStepIndex:0,paused:!1,arrivalTime:null,commanded:!0},Z.arrived=!1,R.current=!1,s.current.position.y=0);const ce=((Y=A.planRef.current)==null?void 0:Y.commanded)??!1,le=h.current,fe=j.current;le&&!fe&&!ce?(L.current=t*(1+Math.random()*2),D.current=be,z.current=!0):!le&&fe&&!ce&&(z.current=!1,Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.savedPlanRef.current?(A.planRef.current=A.savedPlanRef.current,A.savedPlanRef.current=null,Z.arrived=!1):(A.newPlan({stageOccupied:b(),seatOccupancy:y()}),Z.arrived=!1)),j.current=le,z.current&&!ce&&be-D.current>=L.current&&(z.current=!1,Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.interruptForStage(),Z.arrived=!1);const Q=d.has(o);if(Q&&!A.isPaused()&&!ce?(A.pause(),R.current=!0,P0(ie,"Breathing idle",Z)):!Q&&R.current&&(A.resume(),R.current=!1,Z.arrived=!1),A.isPaused()){const G=d.get(o);if(G){const ae=a.get(G.partnerId),Se=l.get(G.partnerId),ge=(ae==null?void 0:ae.currentPosition)||(ae==null?void 0:ae.basePosition)||Se;if(ge){const me=Math.atan2(ge.x-Z.currentPos.x,ge.z-Z.currentPos.z);Na(s.current,me,pe,5)}}s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z,u(o,s.current.position);return}A.planRef.current||(A.newPlan({stageOccupied:b(),seatOccupancy:y()}),Z.arrived=!1);const Te=A.getCurrentStep();if(!Te){A.newPlan({stageOccupied:b(),seatOccupancy:y()}),Z.arrived=!1,s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z,u(o,s.current.position);return}if(!Te.target){const G=U(Te,Z);if(!G){Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.advanceStep(),Z.arrived=!1,s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z,u(o,s.current.position);return}Te.target={x:G.x,z:G.z},Te.arrivalY=G.arrivalY,Te.arrivalAnimation=G.arrivalAnim,Te.arrivalRotation=G.arrivalRot}const we=Te.target.x-Z.currentPos.x,_e=Te.target.z-Z.currentPos.z,Me=Math.sqrt(we*we+_e*_e);if(!Z.arrived&&Me>.5){const G=Te.type==="watch_stage"?2.5:1.5,ae=Math.min(G*pe,Me),Se=Z.currentPos.x+we/Me*ae,ge=Z.currentPos.z+_e/Me*ae,me=Z.currentPos.x,ze=Z.currentPos.z,Oe=h2.has(Te.type);let We,Ge;if(Oe)We=Se,Ge=ge;else{const Le=Uw(Se,ge,me,ze,r);We=Le.x,Ge=Le.z}if(i2(We,Ge,o,m.current)&&(We=me,Ge=ze),Z.currentPos.x=We,Z.currentPos.z=Ge,Math.abs(We-me)<.01&&Math.abs(Ge-ze)<.01&&Me>2)if(Te.type==="wander"){const Le=lx(r);Te.target={x:Le.x,z:Le.z}}else Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),A.advanceStep(),Z.arrived=!1;Na(s.current,Math.atan2(we,_e),pe,5),P0(ie,"Walking",Z),s.current.position.x=Z.currentPos.x,s.current.position.y=0,s.current.position.z=Z.currentPos.z}else if(!Z.arrived)Z.arrived=!0,A.markArrival(be),Te.arrivalAnimation&&P0(ie,Te.arrivalAnimation,Z),Te.arrivalRotation!==void 0&&(s.current.rotation.y=Te.arrivalRotation),Te.arrivalY!==void 0&&(s.current.position.y=Te.arrivalY),s.current.position.x=Z.currentPos.x,s.current.position.z=Z.currentPos.z;else{Te.arrivalRotation!==void 0&&Na(s.current,Te.arrivalRotation,pe,3);const G=.02;s.current.rotation.z=Math.sin(be*.5+t)*G,A.isDurationElapsed(be)&&(Z.claimedSeatArea&&(g(Z.claimedSeatArea,o),Z.claimedSeatArea=null),s.current.position.y=0,A.advanceStep(),Z.arrived=!1),s.current.position.x=Z.currentPos.x,s.current.position.z=Z.currentPos.z}u(o,s.current.position)});const te=A.displayStepType?kee[A.displayStepType]??"wander":"wander",ue=_3[te]||_3.wander;return c.jsxs("group",{ref:s,position:[0,0,0],onPointerOver:w,onPointerOut:C,onClick:M,children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,nt.CIRCLE_INDICATOR.Y_OFFSET,0],children:[c.jsx("circleGeometry",{args:[x||v?nt.CIRCLE_INDICATOR.RADIUS_ACTIVE:nt.CIRCLE_INDICATOR.RADIUS_DEFAULT,nt.CIRCLE_INDICATOR.SEGMENTS]}),c.jsx("meshStandardMaterial",{color:T.color,emissive:T.emissive,emissiveIntensity:T.emissiveIntensity,transparent:!0,opacity:T.opacity})]}),c.jsx("primitive",{object:J,scale:Tee}),(()=>{const ee=d.get(o);return ee!=null&&ee.currentLine?c.jsx(Wp,{text:ee.currentLine,yOffset:3.5,variant:"conversation"}):null})(),!d.has(o)&&(x||v)&&c.jsx(o2,{thoughts:ue,yOffset:3.5})]})},Nee=()=>{const{zones:n,npcPositions:e,stagePerformerRef:t}=Pt(),r=nt.STAGE.POSITION,s=N.useRef(null);vr(()=>{if(t.current){s.current=null;return}let l=null;for(const[u,d]of e){const h=d.x-r.x,f=d.z-r.z;if(Math.sqrt(h*h+f*f)<Eee){l=u;break}}l&&!s.current?t.current=l:!l&&s.current&&t.current===s.current&&(t.current=null),s.current=l});const i=N.useMemo(()=>[...Fv,...fD(n)],[n]),o=Mee.AUDIENCE_POSITIONS,a=[bn.COW,bn.HORSE];return c.jsx("group",{children:o.map((l,u)=>c.jsx(Ree,{audiencePosition:l,modelPath:a[u%a.length],index:u,allObstacles:i},`fake-audience-${u}`))})},Iee=3.6,Pee=2,Lee=.5,S3=.3,jee=.6,Bee={wander:"wandering",check_agent:"talking_to_agent",present:"presenting",go_to_kitchen:"visiting_kitchen",go_to_couch:"wandering",go_to_break_room:"wandering",go_to_poker_table:"wandering",watch_stage:"watching_stage",go_to_pickleball:"wandering",go_to_golf:"playing_golf",sit_outdoor:"wandering"};function L0(n,e,t){if(!n||t.currentAnim===e)return;const r=n[e];r&&(Object.values(n).forEach(s=>s==null?void 0:s.fadeOut(S3)),r.reset().fadeIn(S3).play(),t.currentAnim=e)}const jh=({modelPath:n,npcId:e,walkingAnimation:t,idleAnimation:r,weights:s,thoughts:i,initialPosition:o,circleColor:a=4500036,scale:l=Iee,modelYOffset:u=0,bubbleYOffset:d=6,walkCircleAnimation:h})=>{const f=N.useRef(null),g=N.useRef({currentPos:{x:o.x,z:o.z},initialized:!1,arrived:!1,currentAnim:"",claimedSeatArea:null,lastStagePerformerId:null}),y=N.useRef(!1),b=On(n),p=N.useMemo(()=>l2(b.scene),[b.scene]),m=N.useMemo(()=>c2(b.animations),[b.animations]),x=N.useMemo(()=>{if(u===0)return[0,0,0];const Z=p.children[0];if(!Z)return[0,0,0];const be=Z.children.find(ce=>ce.name.includes("Hips"));if(!be)return[0,0,0];const re=be.position.clone().applyQuaternion(Z.quaternion);return[-re.x*l,0,-re.z*l]},[p,l,u]),{actions:v,mixer:w}=Zy(m,p);N.useEffect(()=>{const Z=v==null?void 0:v[r];Z&&Z.reset().play()},[v,r]);const{agents:C,zones:M,npcPositions:T,updateNpcPosition:A,entityConversations:E,claimSeat:R,releaseSeat:j,getSeatOccupancy:L,isStageOccupied:D,stagePerformerRef:z,consumeEntityCommand:q,entityPositionMapRef:X}=Pt(),{isHovered:K,isSelected:I,handlePointerOver:B,handlePointerOut:F,handleClick:O}=a2(e),W=f2(e,s),J=N.useMemo(()=>[...Fv,...fD(M)],[M]),$=nt.STAGE.POSITION,ie=nt.KITCHEN.POSITION,oe=nt.PICKLEBALL.POSITION,U=nt.GOLF.POSITION,te=nt.OUTDOOR_BENCH.POSITIONS,ue=d2(I,K,a);N.useEffect(()=>()=>{u2(p);const Z=g.current;Z.claimedSeatArea&&j(Z.claimedSeatArea,e)},[p,e,j]);const ee=(Z,be)=>{switch(Z.type){case"check_agent":{const re=Array.from(C.values());if(re.length===0)return null;const ce=re[Math.floor(Math.random()*re.length)],le=ce.basePosition.x+3,fe=ce.basePosition.z+3,Q=Uw(le,fe,be.currentPos.x,be.currentPos.z,J);return{x:Q.x,z:Q.z,arrivalAnim:r}}case"present":return{x:$.x-2,z:$.z,arrivalAnim:r,arrivalRot:-Math.PI/2};case"walk_circle":return{x:0,z:0,arrivalAnim:h||r};case"go_to_kitchen":{const re=R("kitchen",e);if(re<0)return null;be.claimedSeatArea="kitchen";const ce=nt.KITCHEN.SEAT_POSITIONS,le=ce[re%ce.length];return{x:ie.x+le.x,z:ie.z+le.z,arrivalAnim:r,arrivalRot:le.rotation}}case"watch_stage":{const re=nt.STAGE.AUDIENCE_POSITIONS,ce=re[Math.floor(Math.random()*re.length)];return{x:ce.x,z:ce.z,arrivalAnim:r,arrivalRot:Math.PI/2}}case"go_to_pickleball":{const re=oe.x+(Math.random()-.5)*6,ce=oe.z+(Math.random()-.5)*8;return{x:re,z:ce,arrivalAnim:r}}case"go_to_golf":{const re=U.x+(Math.random()-.5)*6,ce=U.z+(Math.random()-.5)*6;return{x:re,z:ce,arrivalAnim:r}}case"sit_outdoor":{const re=te[Math.floor(Math.random()*te.length)];return{x:re.x,z:re.z,arrivalAnim:r,arrivalRot:re.rotation}}case"go_to_couch":{const re=R("couch",e);if(re<0)return null;be.claimedSeatArea="couch";const ce=nt.LOUNGE.COUCH_POSITIONS,le=ce[re%ce.length],fe=nt.LOUNGE.POSITION;return{x:fe.x+le.x,z:fe.z+le.z,arrivalAnim:r,arrivalRot:le.rotation}}case"go_to_break_room":{const re=R("break_room",e);if(re<0)return null;be.claimedSeatArea="break_room";const ce=nt.BREAK_ROOM.POSITION,le=re*Math.PI/2,fe=ce.x+Math.sin(le)*1.3,Q=ce.z+Math.cos(le)*1.3,Te=Math.atan2(ce.x-fe,ce.z-Q);return{x:fe,z:Q,arrivalAnim:r,arrivalRot:Te}}case"go_to_poker_table":{const re=R("poker_table",e);if(re<0)return null;be.claimedSeatArea="poker_table";const ce=nt.POKER_TABLE.POSITION,le=re*Math.PI/2,fe=ce.x+Math.sin(le)*1.8,Q=ce.z+Math.cos(le)*1.8,Te=Math.atan2(ce.x-fe,ce.z-Q);return{x:fe,z:Q,arrivalAnim:r,arrivalRot:Te}}case"wander":default:{const re=lx(J);return{x:re.x,z:re.z,arrivalAnim:r}}}};vr((Z,be)=>{var G;if(!f.current)return;w==null||w.update(be);const re=g.current,ce=Z.clock.elapsedTime;if(K&&!I){L0(v,r,re),f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}re.initialized||(re.currentPos={x:o.x,z:o.z},f.current.position.set(o.x,u,o.z),re.initialized=!0);const le=q(e);le&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.planRef.current={steps:[{type:le.stepType,duration:Zc(le.stepType)}],currentStepIndex:0,paused:!1,arrivalTime:null,commanded:!0},re.arrived=!1,y.current=!1,f.current.position.y=u);const fe=((G=W.planRef.current)==null?void 0:G.commanded)??!1,Q=E.has(e);if(Q&&!W.isPaused()&&!fe?(W.pause(),y.current=!0,L0(v,r,re)):!Q&&y.current&&(W.resume(),y.current=!1,re.arrived=!1),W.isPaused()){const ae=E.get(e);if(ae){const Se=C.get(ae.partnerId),ge=T.get(ae.partnerId),me=(Se==null?void 0:Se.currentPosition)||(Se==null?void 0:Se.basePosition)||ge;if(me){const ze=Math.atan2(me.x-re.currentPos.x,me.z-re.currentPos.z);Na(f.current,ze,be,5)}}f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}const Te=z.current;if(Te!==null&&Te!==re.lastStagePerformerId&&Te!==e)re.lastStagePerformerId=Te,!fe&&Math.random()<jee&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.interruptForStage(),re.arrived=!1);else if(Te===null&&re.lastStagePerformerId!==null){re.lastStagePerformerId=null;const ae=W.getCurrentStep();!fe&&(ae==null?void 0:ae.type)==="watch_stage"&&(W.savedPlanRef.current?(W.planRef.current=W.savedPlanRef.current,W.savedPlanRef.current=null):W.newPlan({stageOccupied:D(),seatOccupancy:L()}),re.arrived=!1)}W.planRef.current||(W.newPlan({stageOccupied:D(),seatOccupancy:L()}),re.arrived=!1);const we=W.getCurrentStep();if(!we){W.newPlan({stageOccupied:D(),seatOccupancy:L()}),re.arrived=!1,f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}if(!we.target){const ae=ee(we,re);if(!ae){re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.advanceStep(),re.arrived=!1,f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position);return}we.target={x:ae.x,z:ae.z},we.arrivalAnimation=ae.arrivalAnim,we.arrivalRotation=ae.arrivalRot}const _e=we.target.x-re.currentPos.x,Me=we.target.z-re.currentPos.z,Y=Math.sqrt(_e*_e+Me*Me);if(!re.arrived&&Y>Lee){const ae=Math.min(Pee*be,Y),Se=re.currentPos.x+_e/Y*ae,ge=re.currentPos.z+Me/Y*ae,me=re.currentPos.x,ze=re.currentPos.z,Oe=h2.has(we.type);let We,Ge;if(Oe)We=Se,Ge=ge;else{const Le=Uw(Se,ge,me,ze,J);We=Le.x,Ge=Le.z}i2(We,Ge,e,X.current)&&(We=me,Ge=ze),re.currentPos.x=We,re.currentPos.z=Ge,Math.abs(We-me)<.01&&Math.abs(Ge-ze)<.01&&Y>2&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.advanceStep(),re.arrived=!1),Na(f.current,Math.atan2(_e,Me),be,5),L0(v,t,re)}else re.arrived?(we.arrivalRotation!==void 0&&Na(f.current,we.arrivalRotation,be,3),W.isDurationElapsed(ce)&&(re.claimedSeatArea&&(j(re.claimedSeatArea,e),re.claimedSeatArea=null),W.advanceStep(),re.arrived=!1)):(re.arrived=!0,W.markArrival(ce),we.arrivalAnimation&&L0(v,we.arrivalAnimation,re),we.arrivalRotation!==void 0&&(f.current.rotation.y=we.arrivalRotation));f.current.position.x=re.currentPos.x,f.current.position.y=u,f.current.position.z=re.currentPos.z,A(e,f.current.position)});const pe=W.displayStepType?Bee[W.displayStepType]??"wandering":"wandering";return c.jsxs("group",{ref:f,position:[o.x,u,o.z],onPointerOver:B,onPointerOut:F,onClick:O,children:[c.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,nt.CIRCLE_INDICATOR.Y_OFFSET-u,0],children:[c.jsx("circleGeometry",{args:[K||I?nt.CIRCLE_INDICATOR.RADIUS_ACTIVE:nt.CIRCLE_INDICATOR.RADIUS_DEFAULT,nt.CIRCLE_INDICATOR.SEGMENTS]}),c.jsx("meshStandardMaterial",{color:ue.color,emissive:ue.emissive,emissiveIntensity:ue.emissiveIntensity,transparent:!0,opacity:ue.opacity})]}),c.jsx("primitive",{object:p,scale:l,position:x}),(()=>{const Z=E.get(e);return Z!=null&&Z.currentLine?c.jsx(Wp,{text:Z.currentLine,yOffset:d,variant:"conversation"}):null})(),!E.has(e)&&(K||I)&&c.jsx(o2,{thoughts:i[pe]||i.wandering,yOffset:d})]})};On.preload(bn.STEVE_JOBS);const b3={WALKING:"Walking",IDLE:"Standing Clap"},Dee=()=>c.jsx(jh,{modelPath:bn.STEVE_JOBS,npcId:nt.NPC_IDS.STEVE_JOBS,walkingAnimation:b3.WALKING,idleAnimation:b3.IDLE,weights:QZ,thoughts:UZ,initialPosition:{x:0,z:5},circleColor:4500036});On.preload(bn.SUNDAR_PICHAI);const qS={WALKING:"Walking",IDLE:"Talking",WALK_IN_CIRCLE:"Walk In Circle"},Oee=()=>c.jsx(jh,{modelPath:bn.SUNDAR_PICHAI,npcId:nt.NPC_IDS.SUNDAR_PICHAI,walkingAnimation:qS.WALKING,idleAnimation:qS.IDLE,weights:ZZ,thoughts:HZ,initialPosition:{x:10,z:0},circleColor:4500036,walkCircleAnimation:qS.WALK_IN_CIRCLE});On.preload(bn.ELON_MUSK);const w3={WALKING:"Walking",IDLE:"Yelling"},Fee=()=>c.jsx(jh,{modelPath:bn.ELON_MUSK,npcId:nt.NPC_IDS.ELON_MUSK,walkingAnimation:w3.WALKING,idleAnimation:w3.IDLE,weights:eee,thoughts:zZ,initialPosition:{x:4,z:50},circleColor:11158596,scale:3.4,modelYOffset:2});On.preload(bn.MARK_ZUCKERBERG);const C3={WALKING:"Talking",IDLE:"Look around"},Uee=()=>c.jsx(jh,{modelPath:bn.MARK_ZUCKERBERG,npcId:nt.NPC_IDS.MARK_ZUCKERBERG,walkingAnimation:C3.WALKING,idleAnimation:C3.IDLE,weights:tee,thoughts:GZ,initialPosition:{x:18,z:38},circleColor:4474026,scale:3.6,modelYOffset:2});On.preload(bn.JENSEN_HUANG);const A3={WALKING:"Brutal to happy walking",IDLE:"Talking"},Hee=()=>c.jsx(jh,{modelPath:bn.JENSEN_HUANG,npcId:nt.NPC_IDS.JENSEN_HUANG,walkingAnimation:A3.WALKING,idleAnimation:A3.IDLE,weights:nee,thoughts:WZ,initialPosition:{x:-5,z:5},circleColor:4500036,scale:3.25,modelYOffset:0});On.preload(bn.STEVE_HUANG);const M3={WALKING:"Walking",IDLE:"Drinking"},zee=()=>c.jsx(jh,{modelPath:bn.STEVE_HUANG,npcId:nt.NPC_IDS.STEVE_HUANG,walkingAnimation:M3.WALKING,idleAnimation:M3.IDLE,weights:ree,thoughts:VZ,initialPosition:{x:16,z:44},circleColor:11184708,scale:3.5,modelYOffset:0}),{CAMERA:oo}=nt,Gee=()=>{const{camera:n,gl:e}=gs(),{camera:t,updateCamera:r,bossModeState:s,clearSelection:i}=Pt(),o=N.useRef({forward:!1,backward:!1,left:!1,right:!1,up:!1,down:!1}),a=N.useRef({isDragging:!1,lastX:0,lastY:0}),l=N.useRef(t.yaw),u=N.useRef(t.pitch),d=N.useRef(new se),h=N.useRef(new se),f=N.useRef(new se),g=N.useRef(new se),y=N.useCallback(()=>{zS(l.current,u.current,h.current),d.current.copy(n.position).add(h.current),n.lookAt(d.current)},[n]);return N.useEffect(()=>{const b=m=>{switch(m.key.toLowerCase()){case"w":case"arrowup":o.current.forward=!0;break;case"s":case"arrowdown":o.current.backward=!0;break;case"a":case"arrowleft":o.current.left=!0;break;case"d":case"arrowright":o.current.right=!0;break;case"q":case" ":o.current.up=!0;break;case"e":o.current.down=!0;break;case"escape":s.isActive&&i();break}},p=m=>{switch(m.key.toLowerCase()){case"w":case"arrowup":o.current.forward=!1;break;case"s":case"arrowdown":o.current.backward=!1;break;case"a":case"arrowleft":o.current.left=!1;break;case"d":case"arrowright":o.current.right=!1;break;case"q":case" ":o.current.up=!1;break;case"e":o.current.down=!1;break}};return window.addEventListener("keydown",b),window.addEventListener("keyup",p),()=>{window.removeEventListener("keydown",b),window.removeEventListener("keyup",p)}},[s.isActive,i]),N.useEffect(()=>{const b=e.domElement,p=w=>{a.current.isDragging=!0,a.current.lastX=w.clientX,a.current.lastY=w.clientY,b.style.cursor="grabbing"},m=()=>{a.current.isDragging=!1,b.style.cursor="default"},x=w=>{if(!a.current.isDragging)return;const C=w.clientX-a.current.lastX,M=w.clientY-a.current.lastY;l.current-=C*oo.MOUSE_SENSITIVITY,u.current=Math.max(oo.MIN_PITCH,Math.min(oo.MAX_PITCH,u.current-M*oo.MOUSE_SENSITIVITY)),y(),a.current.lastX=w.clientX,a.current.lastY=w.clientY},v=w=>{w.preventDefault(),zS(l.current,u.current,f.current);const C=w.deltaY<0?oo.ZOOM_SPEED:-oo.ZOOM_SPEED;n.position.addScaledVector(f.current,C)};return b.addEventListener("mousedown",p),document.addEventListener("mouseup",m),b.addEventListener("mousemove",x),b.addEventListener("wheel",v,{passive:!1}),()=>{b.removeEventListener("mousedown",p),document.removeEventListener("mouseup",m),b.removeEventListener("mousemove",x),b.removeEventListener("wheel",v)}},[e,n,y]),N.useEffect(()=>{const b=e.domElement;let p={isDragging:!1,lastX:0,lastY:0,isPinching:!1,initialPinchDistance:0};const m=(C,M)=>{const T=C.clientX-M.clientX,A=C.clientY-M.clientY;return Math.sqrt(T*T+A*A)},x=C=>{C.preventDefault(),C.touches.length===1?(p.isDragging=!0,p.isPinching=!1,p.lastX=C.touches[0].clientX,p.lastY=C.touches[0].clientY):C.touches.length===2&&(p.isDragging=!1,p.isPinching=!0,p.initialPinchDistance=m(C.touches[0],C.touches[1]))},v=C=>{if(C.preventDefault(),C.touches.length===1&&p.isDragging){const M=C.touches[0].clientX-p.lastX,T=C.touches[0].clientY-p.lastY;l.current+=M*oo.TOUCH_SENSITIVITY,u.current=Math.max(oo.MIN_PITCH,Math.min(oo.MAX_PITCH,u.current+T*oo.TOUCH_SENSITIVITY)),y(),p.lastX=C.touches[0].clientX,p.lastY=C.touches[0].clientY}else if(C.touches.length===2&&p.isPinching){const M=m(C.touches[0],C.touches[1]),T=M-p.initialPinchDistance;zS(l.current,u.current,f.current),n.position.addScaledVector(f.current,T*.02),p.initialPinchDistance=M}},w=C=>{C.touches.length===0?(p.isDragging=!1,p.isPinching=!1):C.touches.length===1&&(p.isDragging=!0,p.isPinching=!1,p.lastX=C.touches[0].clientX,p.lastY=C.touches[0].clientY)};return b.addEventListener("touchstart",x,{passive:!1}),b.addEventListener("touchmove",v,{passive:!1}),b.addEventListener("touchend",w),()=>{b.removeEventListener("touchstart",x),b.removeEventListener("touchmove",v),b.removeEventListener("touchend",w)}},[e,n,y]),vr((b,p)=>{const m=o.current;if(s.isActive){n.position.copy(t.position),n.lookAt(t.target),h.current.copy(t.target).sub(t.position).normalize(),l.current=Math.atan2(h.current.x,h.current.z),u.current=Math.asin(h.current.y);return}if(t.isAnimating&&t.animationTarget){const v=t.animationTarget,w=Date.now()-v.startTime,C=Math.min(w/v.duration,1),M=1-Math.pow(1-C,3);n.position.lerpVectors(v.startPosition,v.position,M),d.current.lerpVectors(v.startLookAt,v.lookAt,M),n.lookAt(d.current),h.current.copy(d.current).sub(n.position).normalize(),l.current=Math.atan2(h.current.x,h.current.z),u.current=Math.asin(h.current.y),C>=1&&r({isAnimating:!1,animationTarget:void 0});return}const x=oo.MOVE_SPEED*p;f.current.set(Math.sin(l.current),0,Math.cos(l.current)),g.current.set(Math.sin(l.current+Math.PI/2),0,Math.cos(l.current+Math.PI/2)),m.forward&&n.position.addScaledVector(f.current,x),m.backward&&n.position.addScaledVector(f.current,-x),m.left&&n.position.addScaledVector(g.current,x),m.right&&n.position.addScaledVector(g.current,-x),m.up&&(n.position.y+=x),m.down&&(n.position.y-=x)}),null},Wee=()=>{const{stats:n,isLoading:e,error:t}=Pt();return e?c.jsx("div",{className:"absolute top-4 left-4 bg-surface-dark/90 backdrop-blur-sm rounded-lg p-4 border border-border-dark",children:c.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."})}):t?c.jsx("div",{className:"absolute top-4 left-4 bg-surface-dark/90 backdrop-blur-sm rounded-lg p-4 border border-red-500/50",children:c.jsx("div",{className:"text-red-400 text-sm",children:t})}):c.jsxs("div",{className:"absolute top-16 left-4 bg-surface-dark/90 backdrop-blur-sm rounded-lg p-3 border border-border-dark min-w-[140px] shadow-lg",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx($S,{label:"Active",count:n.activeCount,color:"bg-green-500",textColor:"text-green-400"}),c.jsx($S,{label:"Idle",count:n.idleCount,color:"bg-yellow-500",textColor:"text-yellow-400"}),c.jsx($S,{label:"Dormant",count:n.dormantCount,color:"bg-red-500",textColor:"text-red-400"})]}),c.jsx("div",{className:"border-t border-border-dark my-3"}),c.jsxs("div",{className:"flex justify-between items-center",children:[c.jsx("span",{className:"text-xs text-text-muted",children:"Total Agents"}),c.jsx("span",{className:"text-sm font-bold text-text-primary",children:n.activeCount+n.idleCount+n.dormantCount})]}),n.totalTokens>0&&c.jsxs("div",{className:"flex justify-between items-center mt-1",children:[c.jsx("span",{className:"text-xs text-text-muted",children:"Session Tokens"}),c.jsx("span",{className:"text-sm text-primary",children:YS(n.totalTokens)})]}),n.tokensByProject&&n.tokensByProject.length>0&&n.totalTokens>0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-t border-border-dark my-3"}),c.jsx("div",{className:"text-[10px] text-text-muted uppercase tracking-wide mb-2",children:"Tokens by Project"}),c.jsx("div",{className:"flex h-2 rounded-full overflow-hidden mb-2",children:n.tokensByProject.map(r=>{const s=n.totalTokens>0?r.tokens/n.totalTokens*100:0,i=`#${r.color.toString(16).padStart(6,"0")}`;return c.jsx("div",{style:{width:`${s}%`,backgroundColor:i},title:`${r.projectName}: ${YS(r.tokens)}`},r.projectName)})}),c.jsx("div",{className:"space-y-1",children:n.tokensByProject.map(r=>{const s=`#${r.color.toString(16).padStart(6,"0")}`,i=n.totalTokens>0?Math.round(r.tokens/n.totalTokens*100):0;return c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:s}}),c.jsx("span",{className:"text-[10px] text-text-muted flex-1 truncate",children:r.projectName}),c.jsxs("span",{className:"text-[10px] text-text-muted",children:[i,"%"]}),c.jsx("span",{className:"text-[10px] text-text-primary font-medium",children:YS(r.tokens)})]},r.projectName)})})]})]})},$S=({label:n,count:e,color:t,textColor:r})=>c.jsxs("div",{className:"flex justify-between items-center",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:`w-2 h-2 rounded-full ${t}`}),c.jsx("span",{className:"text-xs text-text-muted",children:n})]}),c.jsx("span",{className:`text-sm font-semibold ${r}`,children:e})]});function YS(n){return n>=1e9?(n/1e9).toFixed(1)+"B":n>=1e6?(n/1e6).toFixed(1)+"M":n>=1e3?(n/1e3).toFixed(1)+"K":n.toString()}const Vee=()=>{const{projects:n,zones:e,setCameraTarget:t,bossModeState:r,toggleBossMode:s,setBossModeType:i,bossNextTarget:o,bossPrevTarget:a,getCurrentTargetName:l}=Pt(),u=N.useMemo(()=>n.map((d,h)=>{const f=e.get(d);return{projectName:d,color:(f==null?void 0:f.color)||Dd[h%Dd.length],agentCount:(f==null?void 0:f.workstations.filter(g=>g.assignedAgentId).length)||0}}),[n,e]);return c.jsxs("div",{className:"absolute top-4 right-4 flex flex-col gap-2 max-w-[180px]",children:[c.jsx("div",{className:"bg-surface-dark/90 backdrop-blur-sm rounded-lg border border-border-dark p-2 shadow-lg",children:c.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[c.jsx("button",{onClick:()=>t("overview"),className:"px-2 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Overview"}),c.jsx("button",{onClick:()=>t("birdseye"),className:"px-2 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Bird's Eye"}),c.jsx("button",{onClick:()=>t("outdoor"),className:"px-2 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Outdoor"}),c.jsx("button",{onClick:s,className:`px-2 py-1.5 rounded border transition-all text-xs font-medium ${r.isActive?"bg-primary/30 border-primary text-primary":"bg-surface-dark hover:bg-primary/20 border-transparent hover:border-primary/50 text-text-muted"}`,children:r.isActive?"Stop":"Boss Mode"})]})}),r.isActive&&c.jsxs("div",{className:"bg-surface-dark/90 backdrop-blur-sm rounded-lg border border-primary/50 p-2 shadow-lg",children:[c.jsxs("div",{className:"text-center mb-2 px-2",children:[c.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide",children:"Viewing"}),c.jsx("div",{className:"text-sm font-medium text-primary truncate",children:l()||"Loading..."}),c.jsxs("div",{className:"text-[10px] text-text-muted",children:[r.currentTargetIndex+1," / ",r.targets.length]})]}),c.jsxs("div",{className:"flex gap-1 mb-2",children:[c.jsx("button",{onClick:()=>i("auto"),className:`flex-1 px-2 py-1 rounded text-xs font-medium transition-all ${r.mode==="auto"?"bg-primary text-white":"bg-surface-dark hover:bg-primary/20 text-text-muted"}`,children:"Auto"}),c.jsx("button",{onClick:()=>i("manual"),className:`flex-1 px-2 py-1 rounded text-xs font-medium transition-all ${r.mode==="manual"?"bg-primary text-white":"bg-surface-dark hover:bg-primary/20 text-text-muted"}`,children:"Manual"})]}),c.jsxs("div",{className:"flex gap-1",children:[c.jsx("button",{onClick:a,className:"flex-1 px-3 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"โ† Prev"}),c.jsx("button",{onClick:o,className:"flex-1 px-3 py-1.5 bg-surface-dark hover:bg-primary/20 rounded border border-transparent hover:border-primary/50 transition-all text-xs font-medium text-text-primary",children:"Next โ†’"})]})]}),u.length>0&&c.jsx("div",{className:"bg-surface-dark/90 backdrop-blur-sm rounded-lg border border-border-dark shadow-lg overflow-hidden",children:c.jsx("div",{className:"max-h-[280px] overflow-y-auto scrollbar-thin scrollbar-thumb-border-dark scrollbar-track-transparent p-1.5 space-y-1",children:u.map(d=>c.jsx(Xee,{projectName:d.projectName,color:d.color,agentCount:d.agentCount,onClick:()=>t(d.projectName)},d.projectName))})})]})},Xee=({projectName:n,color:e,agentCount:t,onClick:r})=>{const s=`#${e.toString(16).padStart(6,"0")}`,i=n.length>12?n.substring(0,11)+"โ€ฆ":n;return c.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-2 py-1.5 w-full bg-transparent hover:bg-primary/10 rounded border border-transparent hover:border-primary/30 transition-all text-left",title:n,children:[c.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:s}}),c.jsx("span",{className:"text-xs text-text-primary flex-1 truncate",children:i}),t>0&&c.jsx("span",{className:"text-[10px] px-1 py-0.5 rounded bg-primary/20 text-primary font-medium",children:t})]})},Kee=()=>{const{lightingMode:n,setLightingMode:e,isNightMode:t}=Pt(),r=()=>{const o=["day","night","auto"],l=(o.indexOf(n)+1)%o.length;e(o[l])},s=()=>{switch(n){case"day":return c.jsx(cU,{className:"w-4 h-4"});case"night":return c.jsx(tU,{className:"w-4 h-4"});case"auto":return c.jsx(Zo,{className:"w-4 h-4"})}},i=()=>{switch(n){case"day":return"Day";case"night":return"Night";case"auto":return t?"Auto (Night)":"Auto (Day)"}};return c.jsxs("button",{onClick:r,className:`absolute top-4 right-[200px] flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border shadow-lg transition-all z-10 ${n==="night"||n==="auto"&&t?"bg-indigo-900/90 border-indigo-500/50 text-indigo-200":"bg-amber-100/95 border-amber-400/50 text-amber-900"}`,title:"Toggle lighting mode (Day/Night/Auto)",children:[s(),c.jsx("span",{className:"text-xs font-medium",children:i()})]})},Jee=[{label:"Perform on Stage",stepType:"go_to_stage",icon:"๐ŸŽค"},{label:"Eat Food",stepType:"go_to_kitchen",icon:"๐Ÿ•"},{label:"Take a Break",stepType:"go_to_couch",icon:"๐Ÿ›‹๏ธ"},{label:"Play Poker",stepType:"go_to_poker_table",icon:"๐Ÿƒ"},{label:"Hang Out",stepType:"go_to_break_room",icon:"โ˜•"},{label:"Wander",stepType:"wander",icon:"๐Ÿšถ"},{label:"Pickleball",stepType:"go_to_pickleball",icon:"๐Ÿ“"},{label:"Golf",stepType:"go_to_golf",icon:"โ›ณ"},{label:"Sit Outside",stepType:"sit_outdoor",icon:"๐Ÿช‘"}];function qee(n,e){const t=e.get(n);if(t)return t.name||t.sessionName||n;if(n==="steve-jobs-npc")return"Steve Jobs";if(n==="sundar-pichai-npc")return"Sundar Pichai";const r=n.match(/^fake-audience-(\d+)$/);return r?`Audience Member ${Number(r[1])+1}`:n}const $ee=()=>{const{selectedEntityId:n,agents:e,bossModeState:t,sendEntityCommand:r,clearSelection:s}=Pt();if(!n||!t.isActive)return null;const i=qee(n,e);return c.jsx("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 z-10 pointer-events-auto",children:c.jsxs("div",{className:"bg-gray-900/90 backdrop-blur-sm rounded-lg border border-gray-700 shadow-xl px-4 py-3",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2 gap-4",children:[c.jsx("span",{className:"text-white text-sm font-medium truncate max-w-[200px]",children:i}),c.jsx("button",{onClick:s,className:"text-gray-400 hover:text-white transition-colors p-0.5 rounded hover:bg-gray-700/50",title:"Close",children:c.jsx(Mr,{className:"w-4 h-4"})})]}),c.jsx("div",{className:"flex gap-2",children:Jee.map(o=>c.jsxs("button",{onClick:()=>r(n,{stepType:o.stepType}),className:"flex flex-col items-center gap-1 px-3 py-2 rounded-md bg-gray-800/80 hover:bg-gray-700 border border-gray-600/50 hover:border-gray-500 transition-all text-gray-200 hover:text-white",title:o.label,children:[c.jsx("span",{className:"text-base leading-none",children:o.icon}),c.jsx("span",{className:"text-[10px] whitespace-nowrap",children:o.label})]},o.stepType))})]})})};class Yee extends N.Component{constructor(e){super(e),this.state={hasError:!1,error:null,retryCount:0}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("3D Scene Error:",e,t)}render(){return this.state.hasError?this.props.fallback||c.jsx("div",{className:"flex items-center justify-center h-full bg-gray-900 text-white",children:c.jsxs("div",{className:"text-center p-8",children:[c.jsx("h2",{className:"text-xl font-bold mb-2",children:"3D Scene Error"}),c.jsx("p",{className:"text-gray-400 mb-4",children:"Unable to load the factory visualization."}),this.state.error&&c.jsx("p",{className:"text-red-400 text-sm mb-4 max-w-md break-words",children:this.state.error.message}),c.jsx("button",{className:"px-4 py-2 bg-blue-600 rounded hover:bg-blue-700",onClick:()=>this.setState(e=>({hasError:!1,error:null,retryCount:e.retryCount+1})),children:"Retry"})]})}):c.jsx("div",{className:"w-full h-full",children:this.props.children},this.state.retryCount)}}const Qee=()=>{const{scene:n,gl:e}=gs(),{isNightMode:t}=Pt();return N.useEffect(()=>{e.shadowMap.enabled=!0,e.shadowMap.type=Xd,e.toneMapping=am,e.toneMappingExposure=1.2},[e]),N.useEffect(()=>{const r=t?yh.night:yh.day;n.background=new ct(r.background),n.fog=new dm(r.fog,30,80)},[n,t]),null},Zee=()=>{const n=N.useRef(null);return vr(e=>{n.current&&(n.current.rotation.x=e.clock.elapsedTime,n.current.rotation.y=e.clock.elapsedTime*.5)}),c.jsxs("mesh",{ref:n,position:[0,2,0],children:[c.jsx("boxGeometry",{args:[1,1,1]}),c.jsx("meshStandardMaterial",{color:"#3a5f8a",wireframe:!0})]})},ete=()=>c.jsxs(c.Fragment,{children:[c.jsx(Qee,{}),c.jsx(fQ,{}),c.jsx(mQ,{}),c.jsx(_Q,{}),c.jsx(TQ,{}),c.jsx(OQ,{}),c.jsx(qQ,{}),c.jsx(tZ,{}),c.jsx(lZ,{}),c.jsx(mZ,{}),c.jsx(yZ,{}),c.jsx(wZ,{}),c.jsx(jZ,{}),c.jsx(Aee,{}),c.jsx(Nee,{}),c.jsx(Dee,{}),c.jsx(Oee,{}),c.jsx(Fee,{}),c.jsx(Uee,{}),c.jsx(Hee,{}),c.jsx(zee,{}),c.jsx(Gee,{}),c.jsx(FY,{all:!0})]}),tte=({showStats:n=!1,className:e=""})=>{const{CAMERA:t}=nt,r=N.useRef(null);return c.jsx(hQ,{children:c.jsx(Yee,{children:c.jsxs("div",{className:`relative w-full h-full ${e}`,children:[c.jsxs(Kq,{shadows:!0,dpr:[1,2],camera:{fov:t.FOV,near:t.NEAR,far:t.FAR,position:[t.DEFAULT_POSITION.x,t.DEFAULT_POSITION.y,t.DEFAULT_POSITION.z]},gl:{antialias:!0,alpha:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0},onCreated:({gl:s})=>{const i=s.domElement;i.addEventListener("webglcontextlost",o=>{o.preventDefault(),console.warn("WebGL context lost. Click Retry to restore.")}),i.addEventListener("webglcontextrestored",()=>{console.log("WebGL context restored.")})},children:[c.jsx(UY,{pixelated:!0}),c.jsx(HY,{}),c.jsx(N.Suspense,{fallback:c.jsx(Zee,{}),children:c.jsx(ete,{})}),n&&c.jsx(DY,{parent:r})]}),c.jsx("div",{className:"absolute inset-0 pointer-events-none",children:c.jsxs("div",{className:"pointer-events-auto",children:[c.jsx(Wee,{}),c.jsx(Vee,{}),c.jsx(Kee,{}),c.jsx($ee,{})]})}),n&&c.jsx("div",{ref:r,className:"absolute bottom-0 left-0 z-50"})]})})})};function nte(){const n=navigator.userAgent||navigator.vendor||window.opera,t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(n),r=window.innerWidth<768;return t||r}const rte=({onTryAnyway:n,onGoBack:e})=>c.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen bg-background-dark p-6 text-center",children:c.jsxs("div",{className:"max-w-md",children:[c.jsx("div",{className:"mb-6 flex justify-center",children:c.jsxs("div",{className:"relative",children:[c.jsx(rP,{className:"w-20 h-20 text-primary/30"}),c.jsx(fP,{className:"w-10 h-10 text-primary absolute -bottom-2 -right-2 bg-background-dark rounded-full p-1"})]})}),c.jsx("h1",{className:"text-2xl font-bold text-text-primary-dark mb-3",children:"3D Factory View"}),c.jsx("p",{className:"text-text-secondary-dark mb-6",children:"The 3D factory visualization requires significant graphics processing power and is optimized for desktop browsers."}),c.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-8",children:[c.jsxs("div",{className:"bg-surface-dark p-4 rounded-lg border border-border-dark",children:[c.jsx(si,{className:"w-6 h-6 text-primary mx-auto mb-2"}),c.jsx("p",{className:"text-xs text-text-secondary-dark",children:"Agents"})]}),c.jsxs("div",{className:"bg-surface-dark p-4 rounded-lg border border-border-dark",children:[c.jsx(XF,{className:"w-6 h-6 text-green-500 mx-auto mb-2"}),c.jsx("p",{className:"text-xs text-text-secondary-dark",children:"Active"})]}),c.jsxs("div",{className:"bg-surface-dark p-4 rounded-lg border border-border-dark",children:[c.jsx(oy,{className:"w-6 h-6 text-blue-500 mx-auto mb-2"}),c.jsx("p",{className:"text-xs text-text-secondary-dark",children:"Status"})]})]}),c.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary-dark bg-surface-dark p-3 rounded-lg mb-6",children:[c.jsx(lP,{className:"w-5 h-5 text-primary flex-shrink-0"}),c.jsx("span",{children:"For the best experience, open this page on a desktop computer."})]}),c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsx("button",{onClick:e,className:"w-full px-4 py-3 bg-primary text-white rounded-lg font-medium hover:bg-primary/90 transition-colors",children:"Back to Dashboard"}),c.jsx("button",{onClick:n,className:"w-full px-4 py-3 bg-surface-dark text-text-secondary-dark rounded-lg font-medium hover:bg-surface-dark/80 transition-colors border border-border-dark",children:"Try Loading Anyway"})]}),c.jsx("p",{className:"text-xs text-text-secondary-dark/60 mt-4",children:"Loading on mobile may cause the browser to become unresponsive"})]})}),ste=()=>{const n=za(),{collapseSidebar:e,expandSidebar:t}=zC(),r=N.useMemo(()=>nte(),[]),[s,i]=N.useState(!1);N.useEffect(()=>((!r||s)&&e(),()=>{t()}),[e,t,r,s]);const o=()=>{n("/")},a=()=>{i(!0)},l=!1;return r&&!s?c.jsx(rte,{onTryAnyway:a,onGoBack:o}):c.jsxs("div",{className:"fixed inset-0 top-14 md:top-0 md:left-16 bg-background-dark",children:[c.jsxs("button",{onClick:o,className:"hidden md:flex absolute top-4 left-4 z-10 items-center gap-2 px-3 py-2 bg-surface-dark/80 backdrop-blur-sm rounded-lg border border-border-dark hover:bg-surface-dark hover:border-primary/50 transition-all",children:[c.jsx(FF,{className:"w-4 h-4"}),c.jsx("span",{className:"text-sm font-medium",children:"Back to Dashboard"})]}),c.jsx(tte,{showStats:l,className:"w-full h-full"})]})};function ite(){const[n,e]=N.useState(null),[t,r]=N.useState(!0),[s,i]=N.useState(null),o=N.useCallback(async()=>{r(!0),i(null);try{const h=await Ff.getSettings();e(h)}catch(h){i(h instanceof Error?h.message:"Failed to load settings")}finally{r(!1)}},[]),a=N.useCallback(async h=>{const f=await Ff.updateSettings(h);return e(f),f},[]),l=N.useCallback(async()=>{const h=await Ff.resetSettings();return e(h),h},[]),u=N.useCallback(async h=>{const f=await Ff.resetSection(h);return e(f),f},[]),d=N.useCallback(async()=>{await o()},[o]);return N.useEffect(()=>{o()},[o]),{settings:n,isLoading:t,error:s,updateSettings:a,resetSettings:l,resetSection:u,refreshSettings:d}}const ote=["claude-code","gemini-cli","codex-cli"],QS={"claude-code":"Claude Code","gemini-cli":"Gemini CLI","codex-cli":"Codex CLI"},ate=()=>{const{settings:n,updateSettings:e,resetSection:t,isLoading:r,error:s}=ite(),[i,o]=N.useState(null),[a,l]=N.useState(!1),[u,d]=N.useState("idle");N.useEffect(()=>{n&&(o(n),l(!1))},[n]);const h=(b,p,m)=>{i&&(o({...i,[b]:{...i[b],[p]:m}}),l(!0),d("idle"))},f=(b,p)=>{i&&(o({...i,general:{...i.general,runtimeCommands:{...i.general.runtimeCommands,[b]:p}}}),l(!0),d("idle"))},g=async()=>{if(i){d("saving");try{await e({general:i.general,chat:i.chat}),d("saved"),l(!1),setTimeout(()=>d("idle"),2e3)}catch{d("error")}}},y=async()=>{window.confirm("Reset all general and chat settings to defaults?")&&(await t("general"),await t("chat"),l(!1),d("idle"))};return r?c.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[c.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"}),c.jsx("p",{className:"text-text-secondary-dark",children:"Loading settings..."})]}):s?c.jsxs("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center gap-2",children:[c.jsx(ih,{className:"w-5 h-5"}),"Error loading settings: ",s]}):i?c.jsxs("div",{className:"space-y-8 max-w-3xl",children:[c.jsxs("section",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Runtime Settings"}),c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"defaultRuntime",children:"Default AI Runtime"}),c.jsx(go,{id:"defaultRuntime",value:i.general.defaultRuntime,onChange:b=>h("general","defaultRuntime",b.target.value),children:Object.keys(QS).map(b=>c.jsx("option",{value:b,children:QS[b]},b))}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"The default AI runtime to use for new agents"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"autoStart",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Auto-Start Orchestrator"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Automatically start the orchestrator when Crewly launches"})]}),c.jsx("input",{type:"checkbox",id:"autoStart",checked:i.general.autoStartOrchestrator,onChange:b=>h("general","autoStartOrchestrator",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"autoResume",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Auto-Resume Sessions on Restart"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Automatically resume agent sessions when they restart"})]}),c.jsx("input",{type:"checkbox",id:"autoResume",checked:i.general.autoResumeOnRestart,onChange:b=>h("general","autoResumeOnRestart",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"checkInInterval",children:"Check-in Interval (minutes)"}),c.jsx(gr,{id:"checkInInterval",type:"number",min:1,max:60,value:i.general.checkInIntervalMinutes,onChange:b=>h("general","checkInIntervalMinutes",parseInt(b.target.value)||5)}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"How often agents should check in with the orchestrator"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"maxAgents",children:"Max Concurrent Agents"}),c.jsx(gr,{id:"maxAgents",type:"number",min:1,max:50,value:i.general.maxConcurrentAgents,onChange:b=>h("general","maxConcurrentAgents",parseInt(b.target.value)||10)}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Maximum number of agents that can run simultaneously"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"verboseLogging",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Verbose Logging"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Enable detailed logging for debugging"})]}),c.jsx("input",{type:"checkbox",id:"verboseLogging",checked:i.general.verboseLogging,onChange:b=>h("general","verboseLogging",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"enableProactiveCompact",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Proactive Context Compaction"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Automatically run runtime compact/compress when output volume grows large"})]}),c.jsx("input",{type:"checkbox",id:"enableProactiveCompact",checked:i.general.enableProactiveCompact,onChange:b=>h("general","enableProactiveCompact",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"enableSelfEvolution",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Self Evolution Mode"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Orchestrator monitors for errors, triages issues, and reports bugs. When enabled, the orchestrator will proactively read system and session logs to diagnose problems."})]}),c.jsx("input",{type:"checkbox",id:"enableSelfEvolution",checked:i.general.enableSelfEvolution,onChange:b=>h("general","enableSelfEvolution",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]})]})]}),c.jsxs("section",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Runtime Commands"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mb-4",children:"Configure the CLI command used to start each runtime. Changes take effect on next agent start."}),c.jsx("div",{className:"space-y-5",children:ote.map(b=>{var p;return c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:`runtime-cmd-${b}`,children:QS[b]}),c.jsx(gr,{id:`runtime-cmd-${b}`,type:"text",value:((p=i.general.runtimeCommands)==null?void 0:p[b])??"",onChange:m=>f(b,m.target.value)})]},b)})})]}),c.jsxs("section",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Chat Settings"}),c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"showRawOutput",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Show Raw Terminal Output"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Display raw terminal output alongside formatted messages"})]}),c.jsx("input",{type:"checkbox",id:"showRawOutput",checked:i.chat.showRawTerminalOutput,onChange:b=>h("chat","showRawTerminalOutput",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"typingIndicator",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Enable Typing Indicator"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Show typing animation when agents are processing"})]}),c.jsx("input",{type:"checkbox",id:"typingIndicator",checked:i.chat.enableTypingIndicator,onChange:b=>h("chat","enableTypingIndicator",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"maxHistory",children:"Message History Limit"}),c.jsx(gr,{id:"maxHistory",type:"number",min:10,max:1e4,value:i.chat.maxMessageHistory,onChange:b=>h("chat","maxMessageHistory",parseInt(b.target.value)||1e3)}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Maximum number of messages to keep in chat history"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"autoScroll",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Auto-Scroll to Bottom"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Automatically scroll to new messages"})]}),c.jsx("input",{type:"checkbox",id:"autoScroll",checked:i.chat.autoScrollToBottom,onChange:b=>h("chat","autoScrollToBottom",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"showTimestamps",className:"text-sm font-medium text-text-primary-dark cursor-pointer",children:"Show Timestamps"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-0.5",children:"Display timestamps on chat messages"})]}),c.jsx("input",{type:"checkbox",id:"showTimestamps",checked:i.chat.showTimestamps,onChange:b=>h("chat","showTimestamps",b.target.checked),className:"w-5 h-5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"})]})]})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3 pb-4",children:[c.jsx(wt,{variant:"secondary",onClick:y,icon:dP,children:"Reset to Defaults"}),c.jsx(wt,{onClick:g,disabled:!a||u==="saving",icon:u==="saved"?Ba:FC,children:u==="saving"?"Saving...":u==="saved"?"Saved!":u==="error"?"Error - Retry":"Save Changes"})]})]}):null};function lte(n){const[e,t]=N.useState(null),[r,s]=N.useState(!1),[i,o]=N.useState(null),a=N.useCallback(async()=>{if(!n){t(null),s(!1);return}s(!0),o(null);try{const u=await _a.getRole(n);t(u)}catch(u){o(u instanceof Error?u.message:"Failed to load role"),t(null)}finally{s(!1)}},[n]),l=N.useCallback(async()=>{await a()},[a]);return N.useEffect(()=>{a()},[a]),{role:e,isLoading:r,error:i,refreshRole:l}}const cte=({roleId:n,onClose:e,onSave:t})=>{const{role:r,isLoading:s}=lte(n),{skills:i}=gy(),[o,a]=N.useState({name:"",displayName:"",description:"",category:"development",systemPromptContent:"",assignedSkills:[],isDefault:!1}),[l,u]=N.useState(!1),[d,h]=N.useState(null),f=n===null,g=(r==null?void 0:r.isBuiltin)??!1,y=(r==null?void 0:r.hasOverride)??!1;N.useEffect(()=>{r&&a({name:r.name,displayName:r.displayName,description:r.description,category:r.category,systemPromptContent:r.systemPromptContent||"",assignedSkills:r.assignedSkills,isDefault:r.isDefault})},[r]);const b=(v,w)=>{a(C=>({...C,[v]:w})),h(null)},p=v=>{a(w=>({...w,assignedSkills:w.assignedSkills.includes(v)?w.assignedSkills.filter(C=>C!==v):[...w.assignedSkills,v]}))},m=async v=>{v.preventDefault(),h(null),u(!0);try{f?await t({name:o.name,displayName:o.displayName,description:o.description,category:o.category,systemPromptContent:o.systemPromptContent,assignedSkills:o.assignedSkills,isDefault:o.isDefault}):await t({displayName:o.displayName,description:o.description,category:o.category,systemPromptContent:o.systemPromptContent,assignedSkills:o.assignedSkills,isDefault:o.isDefault}),e()}catch(w){h(w instanceof Error?w.message:"Failed to save role")}finally{u(!1)}},x=v=>{v.target===v.currentTarget&&e()};return s&&n?c.jsx("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:x,children:c.jsx("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg p-8",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"}),c.jsx("p",{className:"text-text-secondary-dark",children:"Loading role..."})]})})}):c.jsx("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:x,children:c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-2xl m-4 max-h-[90vh] overflow-hidden flex flex-col",onClick:v=>v.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark sticky top-0 bg-surface-dark z-10",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold text-text-primary-dark",children:f?"Create Role":"Edit Role"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mt-1",children:f?"Configure a new agent role":"Modify role settings and prompt"})]}),c.jsx(Ci,{icon:Mr,onClick:e,variant:"ghost","aria-label":"Close"})]}),g&&!f&&c.jsxs("div",{className:"mx-6 mt-4 bg-blue-500/10 border border-blue-500/30 text-blue-400 px-4 py-3 rounded-lg text-sm",children:[c.jsx("strong",{children:"Built-in Role:"})," Changes will be saved as a user override. You can reset to defaults anytime.",y&&c.jsx("span",{className:"ml-1",children:"(Currently has user override)"})]}),d&&c.jsx("div",{className:"mx-6 mt-4 bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg text-sm",children:d}),c.jsxs("form",{onSubmit:m,className:"flex-1 overflow-y-auto",children:[c.jsxs("div",{className:"p-6 border-b border-border-dark space-y-4",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:"Basic Information"}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"displayName",required:!0,children:"Display Name"}),c.jsx(gr,{id:"displayName",type:"text",value:o.displayName,onChange:v=>b("displayName",v.target.value),disabled:!1,required:!0,placeholder:"e.g., Senior Developer"})]}),f&&c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"name",required:!0,children:"Internal Name"}),c.jsx(gr,{id:"name",type:"text",value:o.name,onChange:v=>b("name",v.target.value.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")),pattern:"[a-z0-9-]+",required:!0,placeholder:"e.g., senior-developer"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Lowercase letters, numbers, and hyphens only"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"description",children:"Description"}),c.jsx(Da,{id:"description",value:o.description,onChange:v=>b("description",v.target.value),disabled:!1,rows:2,placeholder:"Brief description of this role's responsibilities"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"category",children:"Category"}),c.jsx(go,{id:"category",value:o.category,onChange:v=>b("category",v.target.value),disabled:!1,children:cz.map(v=>c.jsx("option",{value:v,children:eA[v]},v))})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{id:"isDefault",type:"checkbox",checked:o.isDefault,onChange:v=>b("isDefault",v.target.checked),disabled:!1,className:"w-4 h-4 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"}),c.jsx("label",{htmlFor:"isDefault",className:"text-sm text-text-primary-dark cursor-pointer",children:"Set as default role"})]})]}),c.jsxs("div",{className:"p-6 border-b border-border-dark space-y-4",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:"System Prompt"}),c.jsxs("div",{children:[c.jsx(Da,{id:"systemPrompt",value:o.systemPromptContent,onChange:v=>b("systemPromptContent",v.target.value),disabled:!1,rows:12,placeholder:`# Role Name
4914
4914
 
4915
4915
  You are a...`,className:"font-mono text-sm"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Markdown supported. This prompt defines the agent's behavior."})]})]}),c.jsxs("div",{className:"p-6 space-y-4",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:"Assigned Skills"}),c.jsxs("div",{className:"space-y-2",children:[i==null?void 0:i.map(v=>c.jsxs("label",{className:`flex items-start gap-3 p-3 bg-background-dark border border-border-dark rounded-lg cursor-pointer hover:border-primary/50 transition-colors ${o.assignedSkills.includes(v.id)?"border-primary/50 bg-primary/5":""}`,children:[c.jsx("input",{type:"checkbox",checked:o.assignedSkills.includes(v.id),onChange:()=>p(v.id),disabled:!1,className:"w-4 h-4 mt-0.5 rounded border-border-dark bg-background-dark text-primary focus:ring-primary focus:ring-offset-0 cursor-pointer"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"text-sm font-medium text-text-primary-dark block",children:v.name}),c.jsx("span",{className:"text-xs text-text-secondary-dark block mt-0.5",children:v.description})]}),o.assignedSkills.includes(v.id)&&c.jsx(Ba,{className:"w-4 h-4 text-primary flex-shrink-0"})]},v.id)),(!i||i.length===0)&&c.jsx("p",{className:"text-sm text-text-secondary-dark text-center py-6",children:"No skills available. Create skills in the Skills tab."})]})]})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-dark bg-background-dark sticky bottom-0",children:[c.jsx(wt,{variant:"secondary",onClick:e,type:"button",children:"Cancel"}),c.jsx(wt,{type:"submit",onClick:m,disabled:l,loading:l,children:l?"Saving...":f?"Create Role":"Save Changes"})]})]})})},ute={development:"bg-blue-500/15 text-blue-400",management:"bg-amber-500/15 text-amber-400",quality:"bg-emerald-500/15 text-emerald-400",design:"bg-pink-500/15 text-pink-400",sales:"bg-purple-500/15 text-purple-400",support:"bg-cyan-500/15 text-cyan-400",automation:"bg-orange-500/15 text-orange-400"},dte=[{value:"",label:"All Categories"},{value:"development",label:"Development"},{value:"management",label:"Management"},{value:"quality",label:"Quality"},{value:"design",label:"Design"},{value:"sales",label:"Sales"},{value:"support",label:"Support"},{value:"automation",label:"Automation"}],hte=()=>{const{roles:n,isLoading:e,error:t,createRole:r,updateRole:s,deleteRole:i,refreshFromDisk:o}=TL(),[a,l]=N.useState(null),[u,d]=N.useState(!1),[h,f]=N.useState(!1),[g,y]=N.useState(""),[b,p]=N.useState(""),[m,x]=N.useState(!1),v=N.useMemo(()=>n?n.filter(E=>{if(b&&E.category!==b)return!1;if(g){const R=g.toLowerCase();return E.displayName.toLowerCase().includes(R)||E.description.toLowerCase().includes(R)||E.category.toLowerCase().includes(R)}return!0}):[],[n,g,b]),w=()=>{l(null),f(!0),d(!0)},C=E=>{l(E),f(!1),d(!0)},M=async(E,R)=>{if(R){window.alert("Built-in roles cannot be deleted");return}window.confirm("Are you sure you want to delete this role?")&&await i(E)},T=()=>{d(!1),l(null),f(!1)},A=async()=>{x(!0);try{await o()}finally{x(!1)}};return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold",children:"Roles Management"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Create and manage AI agent roles"})]}),c.jsx(wt,{onClick:w,icon:Ps,children:"New Role"})]}),c.jsxs("div",{className:"flex flex-col md:flex-row items-end gap-4",children:[c.jsxs("div",{className:"flex-1 w-full md:w-auto",children:[c.jsx(Ht,{htmlFor:"category-filter",children:"Category"}),c.jsx(go,{id:"category-filter",value:b,onChange:E=>p(E.target.value),children:dte.map(E=>c.jsx("option",{value:E.value,children:E.label},E.value))})]}),c.jsxs("div",{className:"flex-1 w-full md:w-auto",children:[c.jsx(Ht,{htmlFor:"search-filter",children:"Search"}),c.jsx(gr,{id:"search-filter",type:"text",placeholder:"Search roles...",value:g,onChange:E=>y(E.target.value)})]}),c.jsx(wt,{variant:"secondary",onClick:A,disabled:e||m,icon:Cu,className:m?"animate-spin":"",children:m?"Refreshing...":"Refresh"})]}),t&&c.jsxs("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center justify-between",children:[c.jsxs("span",{children:["Error: ",t]}),c.jsx(wt,{variant:"outline",size:"sm",onClick:A,children:"Retry"})]}),e&&v.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[c.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"}),c.jsx("p",{className:"text-text-secondary-dark",children:"Loading roles..."})]}),!e&&v.length===0&&!t&&c.jsxs("div",{className:"text-center py-16",children:[c.jsx("div",{className:"flex justify-center mb-4",children:c.jsx(Qp,{className:"w-12 h-12 text-text-secondary-dark"})}),c.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Roles Found"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mb-6",children:g||b?"Try adjusting your filters":"Create your first role to get started"}),!g&&!b&&c.jsx(wt,{onClick:w,icon:Ps,children:"Create Role"})]}),v.length>0&&c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:v.map(E=>c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-4 hover:border-primary/50 transition-colors flex flex-col",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[c.jsx("h3",{className:"font-medium text-text-primary-dark",children:E.displayName}),c.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${ute[E.category]}`,children:eA[E.category]})]}),c.jsx("p",{className:"text-sm text-text-secondary-dark flex-grow mb-3 line-clamp-2",children:E.description}),c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsxs("span",{className:"text-xs text-text-secondary-dark",children:[E.skillCount," skills assigned"]}),E.isDefault&&c.jsx("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full bg-primary/15 text-primary",children:"Default"})]}),c.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-border-dark mt-auto",children:[E.isBuiltin&&c.jsx("span",{className:"text-xs text-text-secondary-dark italic",children:"Built-in"}),!E.isBuiltin&&c.jsx("span",{}),c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(wt,{variant:"secondary",size:"sm",onClick:()=>C(E.id),children:"Edit"}),!E.isBuiltin&&c.jsx(wt,{variant:"outline",size:"sm",onClick:()=>M(E.id,E.isBuiltin),className:"text-rose-400 hover:text-rose-300 hover:border-rose-400",icon:Yp,children:"Delete"})]})]})]},E.id))}),u&&c.jsx(cte,{roleId:h?null:a,onClose:T,onSave:async E=>{h?await r(E):a&&await s(a,E)}})]})},fte=["development","design","communication","research","content-creation","automation","analysis","integration","management","monitoring","memory","system","task-management","quality"];function _D(n){return{development:"Development",design:"Design",communication:"Communication",research:"Research","content-creation":"Content Creation",automation:"Automation",analysis:"Analysis",integration:"Integration",management:"Management",monitoring:"Monitoring",memory:"Memory",system:"System","task-management":"Task Management",quality:"Quality"}[n]||n}function pte(n){return{"claude-skill":"Claude Skill","web-page":"Web Page"}[n]||n}const mte=()=>[{value:"",label:"All Categories"},...fte.map(n=>({value:n,label:_D(n)}))],SD=mte(),gte={development:"bg-blue-500/15 text-blue-400",design:"bg-pink-500/15 text-pink-400",communication:"bg-emerald-500/15 text-emerald-400",research:"bg-indigo-500/15 text-indigo-400","content-creation":"bg-amber-500/15 text-amber-400",automation:"bg-purple-500/15 text-purple-400",analysis:"bg-cyan-500/15 text-cyan-400",integration:"bg-rose-500/15 text-rose-400",management:"bg-orange-500/15 text-orange-400",monitoring:"bg-teal-500/15 text-teal-400",memory:"bg-violet-500/15 text-violet-400",system:"bg-slate-500/15 text-slate-400","task-management":"bg-sky-500/15 text-sky-400",quality:"bg-lime-500/15 text-lime-400"},xte={"claude-skill":"bg-purple-500/15 text-purple-400","web-page":"bg-blue-500/15 text-blue-400"},vte=()=>{var E;const[n,e]=N.useState(""),[t,r]=N.useState(""),[s,i]=N.useState(!1),[o,a]=N.useState(null),[l,u]=N.useState(null),d=N.useMemo(()=>({category:n||void 0,search:t||void 0}),[n,t]),{skills:h,loading:f,error:g,refresh:y,create:b,update:p,remove:m,selectSkill:x,selectedSkill:v,clearSelection:w}=gy(d),C=N.useCallback(()=>{a(null),i(!0)},[]),M=N.useCallback(async R=>{a(R),await x(R.id),i(!0)},[x]),T=N.useCallback(async R=>{try{o!=null&&o.id?await p(o.id,R):await b(R),i(!1),a(null)}catch(j){console.error("Failed to save skill:",j)}},[o,p,b]),A=N.useCallback(async R=>{try{await m(R),u(null)}catch(j){console.error("Failed to delete skill:",j)}},[m]);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold",children:"Skills Management"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Create and manage AI agent skills"})]}),c.jsx(wt,{onClick:C,icon:Ps,children:"New Skill"})]}),c.jsxs("div",{className:"flex flex-col md:flex-row items-end gap-4",children:[c.jsxs("div",{className:"flex-1 w-full md:w-auto",children:[c.jsx(Ht,{htmlFor:"category-filter",children:"Category"}),c.jsx(go,{id:"category-filter",value:n,onChange:R=>e(R.target.value),children:SD.map(R=>c.jsx("option",{value:R.value,children:R.label},R.value))})]}),c.jsxs("div",{className:"flex-1 w-full md:w-auto",children:[c.jsx(Ht,{htmlFor:"search-filter",children:"Search"}),c.jsx(gr,{id:"search-filter",type:"text",placeholder:"Search skills...",value:t,onChange:R=>r(R.target.value)})]}),c.jsx(wt,{variant:"secondary",onClick:y,disabled:f,icon:Cu,className:f?"animate-spin":"",children:f?"Refreshing...":"Refresh"})]}),g&&c.jsxs("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center justify-between",children:[c.jsxs("span",{children:["Error: ",g]}),c.jsx(wt,{variant:"outline",size:"sm",onClick:y,children:"Retry"})]}),f&&h.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[c.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"}),c.jsx("p",{className:"text-text-secondary-dark",children:"Loading skills..."})]}),!f&&h.length===0&&!g&&c.jsxs("div",{className:"text-center py-16",children:[c.jsx("div",{className:"flex justify-center mb-4",children:c.jsx(uU,{className:"w-12 h-12 text-text-secondary-dark"})}),c.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Skills Found"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mb-6",children:t||n?"Try adjusting your filters":"Create your first skill to get started"}),!t&&!n&&c.jsx(wt,{onClick:C,icon:Ps,children:"Create Skill"})]}),h.length>0&&c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(R=>c.jsx(bte,{skill:R,onEdit:()=>M(R),onDelete:()=>u(R.id)},R.id))}),s&&c.jsx(wte,{skill:v||o,onSave:T,onClose:()=>{i(!1),a(null),w()}}),l&&c.jsx(Cte,{skillId:l,skillName:((E=h.find(R=>R.id===l))==null?void 0:E.name)||"",onConfirm:()=>A(l),onCancel:()=>u(null)})]})},yte=n=>{switch(n){case"claude-skill":return c.jsx(sT,{className:"w-3.5 h-3.5"});case"web-page":return c.jsx(iP,{className:"w-3.5 h-3.5"});default:return c.jsx(sT,{className:"w-3.5 h-3.5"})}},_te=n=>{switch(n){case"warning":return c.jsx(Tp,{className:"w-4 h-4"});case"requirement":return c.jsx(ih,{className:"w-4 h-4"});case"info":default:return c.jsx(Dx,{className:"w-4 h-4"})}},Ste={info:{bg:"bg-blue-500/10",border:"border-blue-500/20",icon:"text-blue-400"},warning:{bg:"bg-amber-500/10",border:"border-amber-500/20",icon:"text-amber-400"},requirement:{bg:"bg-rose-500/10",border:"border-rose-500/20",icon:"text-rose-400"}},bte=({skill:n,onEdit:e,onDelete:t})=>{const r=n.skillType||"claude-skill";return c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-4 hover:border-primary/50 transition-colors flex flex-col",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[c.jsx("h3",{className:"font-medium text-text-primary-dark",children:n.name}),c.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${gte[n.category]}`,children:_D(n.category)})]}),c.jsx("p",{className:"text-sm text-text-secondary-dark flex-grow mb-3 line-clamp-2",children:n.description}),c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsxs("span",{className:`inline-flex items-center gap-1 text-xs font-medium px-2 py-0.5 rounded ${xte[r]}`,children:[yte(r),c.jsx("span",{children:pte(r)})]}),c.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${n.isEnabled?"bg-emerald-500/10 text-emerald-400":"bg-gray-500/10 text-gray-400"}`,children:n.isEnabled?"Enabled":"Disabled"})]}),n.notices&&n.notices.length>0&&c.jsx("div",{className:"space-y-2 mb-3",children:n.notices.map((s,i)=>{const o=Ste[s.type];return c.jsxs("div",{className:`flex gap-2 p-2 rounded ${o.bg} border ${o.border}`,children:[c.jsx("div",{className:`flex-shrink-0 ${o.icon}`,children:_te(s.type)}),c.jsxs("div",{className:"text-xs space-y-0.5",children:[c.jsx("span",{className:"font-medium text-text-primary-dark block",children:s.title}),c.jsx("span",{className:"text-text-secondary-dark block",children:s.message}),s.link&&c.jsxs("a",{href:s.link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:[s.linkText||"Learn more",c.jsx(OC,{className:"w-3 h-3"})]})]})]},i)})}),c.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-border-dark mt-auto",children:[n.isBuiltin&&c.jsx("span",{className:"text-xs text-text-secondary-dark italic",children:"Built-in"}),c.jsxs("div",{className:"flex gap-1 ml-auto",children:[c.jsx(Ci,{icon:oU,onClick:e,variant:"ghost",size:"sm","aria-label":"Edit skill"}),!n.isBuiltin&&c.jsx(Ci,{icon:Yp,onClick:t,variant:"danger-ghost",size:"sm","aria-label":"Delete skill"})]})]})]})},wte=({skill:n,onSave:e,onClose:t})=>{const r=(n==null?void 0:n.isBuiltin)??!1,[s,i]=N.useState({name:(n==null?void 0:n.name)||"",displayName:(n==null?void 0:n.name)||"",description:(n==null?void 0:n.description)||"",category:(n==null?void 0:n.category)||"development",promptContent:(n==null?void 0:n.promptContent)||"",triggers:[],tags:[]}),[o,a]=N.useState(!1),[l,u]=N.useState(null),d=async f=>{if(f.preventDefault(),u(null),!s.displayName.trim()){u("Display Name is required");return}if(!s.name.trim()){u("ID is required");return}if(!s.description.trim()){u("Description is required");return}a(!0);try{await e(s)}catch(g){u(g instanceof Error?g.message:"Failed to save skill")}finally{a(!1)}},h=f=>{f.target===f.currentTarget&&t()};return c.jsx("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:h,children:c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-lg m-4 max-h-[90vh] overflow-hidden flex flex-col",onClick:f=>f.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold text-text-primary-dark",children:n?"Edit Skill":"Create Skill"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mt-1",children:n?"Modify skill configuration":"Configure a new skill for your agents"})]}),c.jsx(Ci,{icon:Mr,onClick:t,variant:"ghost","aria-label":"Close"})]}),r&&n&&c.jsxs("div",{className:"mx-6 mt-4 bg-blue-500/10 border border-blue-500/30 text-blue-400 px-4 py-3 rounded-lg text-sm",children:[c.jsx("strong",{children:"Built-in Skill:"})," Changes will be saved as a user override. You can reset to defaults anytime."]}),l&&c.jsx("div",{className:"mx-6 mt-4 bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg text-sm",children:l}),c.jsxs("form",{onSubmit:d,className:"flex-1 overflow-y-auto p-6 space-y-4",children:[c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"skill-display-name",required:!0,children:"Display Name"}),c.jsx(gr,{id:"skill-display-name",type:"text",value:s.displayName,onChange:f=>i({...s,displayName:f.target.value}),placeholder:"Code Review",required:!0})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"skill-name",required:!0,children:"ID"}),c.jsx(gr,{id:"skill-name",type:"text",value:s.name,onChange:f=>i({...s,name:f.target.value}),placeholder:"code-review",required:!0,disabled:!!n}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Lowercase letters, numbers, and hyphens only"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"skill-description",required:!0,children:"Description"}),c.jsx(Da,{id:"skill-description",value:s.description,onChange:f=>i({...s,description:f.target.value}),placeholder:"Describe what this skill does...",rows:3,required:!0})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"skill-category",children:"Category"}),c.jsx(go,{id:"skill-category",value:s.category,onChange:f=>i({...s,category:f.target.value}),children:SD.filter(f=>f.value).map(f=>c.jsx("option",{value:f.value,children:f.label},f.value))})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"skill-prompt",children:"Instructions (Markdown)"}),c.jsx(Da,{id:"skill-prompt",value:s.promptContent,onChange:f=>i({...s,promptContent:f.target.value}),placeholder:`# Skill Instructions
4916
4916
 
4917
4917
  Provide detailed instructions for this skill...`,rows:8,className:"font-mono text-sm"})]})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-dark bg-background-dark",children:[c.jsx(wt,{variant:"secondary",onClick:t,type:"button",children:"Cancel"}),c.jsx(wt,{type:"submit",onClick:d,disabled:o,loading:o,children:o?"Saving...":"Save Skill"})]})]})})},Cte=({skillName:n,onConfirm:e,onCancel:t})=>{const r=s=>{s.target===s.currentTarget&&t()};return c.jsx("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:r,children:c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-md m-4",onClick:s=>s.stopPropagation(),children:[c.jsx("div",{className:"p-6 border-b border-border-dark",children:c.jsx("h2",{className:"text-xl font-semibold text-text-primary-dark",children:"Delete Skill"})}),c.jsx("div",{className:"p-6",children:c.jsxs("p",{className:"text-text-secondary-dark",children:["Are you sure you want to delete ",c.jsx("strong",{className:"text-text-primary-dark",children:n}),"? This action cannot be undone."]})}),c.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-dark bg-background-dark rounded-b-xl",children:[c.jsx(wt,{variant:"secondary",onClick:t,children:"Cancel"}),c.jsx(wt,{variant:"danger",onClick:e,children:"Delete"})]})]})})},Ate=()=>{const[n,e]=N.useState({connected:!1}),[t,r]=N.useState(!0),[s,i]=N.useState(!1),[o,a]=N.useState(null),[l,u]=N.useState({botToken:"",appToken:"",signingSecret:"",defaultChannel:""}),d=N.useCallback(async()=>{var y,b,p,m,x,v,w;try{a(null);const M=await(await fetch("/api/slack/status")).json();M.success?e({connected:((y=M.data)==null?void 0:y.isConfigured)||!1,workspaceName:(b=M.data)==null?void 0:b.workspaceName,botName:(p=M.data)==null?void 0:p.botName,channels:(m=M.data)==null?void 0:m.channels,lastMessageAt:(x=M.data)==null?void 0:x.lastMessageAt,messagesSent:(v=M.data)==null?void 0:v.messagesSent,messagesReceived:(w=M.data)==null?void 0:w.messagesReceived}):e({connected:!1,error:M.error})}catch{e({connected:!1,error:"Failed to fetch status"})}finally{r(!1)}},[]);N.useEffect(()=>{d()},[d]);const h=y=>{const{name:b,value:p}=y.target;u(m=>({...m,[b]:p}))},f=async y=>{y.preventDefault(),i(!0),a(null);try{const b=await fetch("/api/slack/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:l.botToken,appToken:l.appToken,signingSecret:l.signingSecret,defaultChannelId:l.defaultChannel||void 0})}),p=await b.json();if(!b.ok||!p.success)throw new Error(p.error||"Connection failed");u({botToken:"",appToken:"",signingSecret:"",defaultChannel:""}),await d()}catch(b){a(b instanceof Error?b.message:"Failed to connect to Slack")}finally{i(!1)}},g=async()=>{if(window.confirm("Are you sure you want to disconnect from Slack?"))try{a(null);const y=await fetch("/api/slack/disconnect",{method:"POST"}),b=await y.json();if(!y.ok||!b.success)throw new Error(b.error||"Disconnect failed");await d()}catch(y){a(y instanceof Error?y.message:"Failed to disconnect")}};return t?c.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[c.jsx("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"}),c.jsx("p",{className:"text-text-secondary-dark",children:"Loading Slack status..."})]}):c.jsxs("div",{className:"space-y-6 max-w-3xl",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold",children:"Slack Integration"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Connect Slack to communicate with the orchestrator from your phone or desktop Slack app."})]}),o&&c.jsxs("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Tp,{className:"w-5 h-5"}),c.jsx("span",{children:o})]}),c.jsx("button",{onClick:()=>a(null),className:"text-rose-400 hover:text-rose-300 p-1",children:c.jsx(Mr,{className:"w-4 h-4"})})]}),n.connected?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/30 rounded-lg p-4 flex items-center gap-3",children:[c.jsx(Ko,{className:"w-5 h-5 text-emerald-400"}),c.jsx("span",{className:"text-emerald-400 font-medium",children:"Connected to Slack"})]}),c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide mb-4",children:"Connection Details"}),c.jsxs("div",{className:"space-y-3",children:[n.workspaceName&&c.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[c.jsx("span",{className:"text-sm text-text-secondary-dark",children:"Workspace"}),c.jsx("span",{className:"text-sm font-medium",children:n.workspaceName})]}),n.botName&&c.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[c.jsx("span",{className:"text-sm text-text-secondary-dark",children:"Bot Name"}),c.jsx("span",{className:"text-sm font-medium",children:n.botName})]}),n.channels&&n.channels.length>0&&c.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[c.jsx("span",{className:"text-sm text-text-secondary-dark",children:"Channels"}),c.jsx("span",{className:"text-sm font-medium",children:n.channels.join(", ")})]}),n.messagesSent!==void 0&&c.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[c.jsx("span",{className:"text-sm text-text-secondary-dark",children:"Messages Sent"}),c.jsx("span",{className:"text-sm font-medium",children:n.messagesSent})]}),n.messagesReceived!==void 0&&c.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[c.jsx("span",{className:"text-sm text-text-secondary-dark",children:"Messages Received"}),c.jsx("span",{className:"text-sm font-medium",children:n.messagesReceived})]}),n.lastMessageAt&&c.jsxs("div",{className:"flex items-center justify-between py-2",children:[c.jsx("span",{className:"text-sm text-text-secondary-dark",children:"Last Activity"}),c.jsx("span",{className:"text-sm font-medium",children:new Date(n.lastMessageAt).toLocaleString()})]})]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(wt,{variant:"secondary",onClick:d,icon:Cu,children:"Refresh Status"}),c.jsx(wt,{variant:"danger",onClick:g,icon:hU,children:"Disconnect"})]})]}):c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4 flex items-center gap-3",children:[c.jsx(Tp,{className:"w-5 h-5 text-amber-400"}),c.jsx("span",{className:"text-amber-400 font-medium",children:"Not connected to Slack"})]}),c.jsxs("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide mb-4",children:"Setup Instructions"}),c.jsxs("ol",{className:"list-decimal list-inside space-y-3 text-sm text-text-secondary-dark",children:[c.jsxs("li",{children:["Create a Slack App at"," ",c.jsxs("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["api.slack.com/apps",c.jsx(OC,{className:"w-3 h-3"})]})]}),c.jsx("li",{children:"Enable Socket Mode in your app settings and create an App Token (starts with xapp-)"}),c.jsxs("li",{children:["Add Bot Token Scopes under OAuth & Permissions:",c.jsxs("ul",{className:"list-disc list-inside ml-4 mt-1.5 space-y-1",children:[c.jsxs("li",{children:[c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"chat:write"})," - Send messages"]}),c.jsxs("li",{children:[c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"channels:read"})," - View channels"]}),c.jsxs("li",{children:[c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"app_mentions:read"})," - Respond to mentions"]}),c.jsxs("li",{children:[c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"im:read"}),", ",c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"im:write"})," - Direct messages"]}),c.jsxs("li",{children:[c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"files:read"})," - Receive images from Slack"]}),c.jsxs("li",{children:[c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"files:write"})," - Upload images to Slack"]}),c.jsxs("li",{children:[c.jsx("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"reactions:write"})," - Typing/completion indicators (optional)"]})]}),c.jsxs("p",{className:"text-xs text-amber-400/80 mt-1.5 ml-4",children:["Note: Adding ",c.jsx("code",{className:"text-xs bg-background-dark px-1 py-0.5 rounded",children:"files:read"})," and ",c.jsx("code",{className:"text-xs bg-background-dark px-1 py-0.5 rounded",children:"files:write"})," scopes requires reinstalling the app to your workspace."]})]}),c.jsx("li",{children:"Install the app to your workspace"}),c.jsx("li",{children:"Copy the Bot Token (xoxb-...), App Token (xapp-...), and Signing Secret"})]})]}),c.jsxs("form",{onSubmit:f,className:"bg-surface-dark border border-border-dark rounded-lg p-6 space-y-4",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide mb-4",children:"Connect to Slack"}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"botToken",required:!0,children:"Bot Token (xoxb-...)"}),c.jsx(gr,{id:"botToken",name:"botToken",type:"password",value:l.botToken,onChange:h,placeholder:"xoxb-your-bot-token",required:!0,autoComplete:"off"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"appToken",required:!0,children:"App Token (xapp-...)"}),c.jsx(gr,{id:"appToken",name:"appToken",type:"password",value:l.appToken,onChange:h,placeholder:"xapp-your-app-token",required:!0,autoComplete:"off"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"signingSecret",required:!0,children:"Signing Secret"}),c.jsx(gr,{id:"signingSecret",name:"signingSecret",type:"password",value:l.signingSecret,onChange:h,placeholder:"Your signing secret",required:!0,autoComplete:"off"})]}),c.jsxs("div",{children:[c.jsx(Ht,{htmlFor:"defaultChannel",children:"Default Channel (optional)"}),c.jsx(gr,{id:"defaultChannel",name:"defaultChannel",type:"text",value:l.defaultChannel,onChange:h,placeholder:"C1234567890 or #crewly"}),c.jsx("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Channel ID or name where notifications will be sent by default"})]}),c.jsx("div",{className:"pt-2",children:c.jsx(wt,{type:"submit",disabled:s||!l.botToken||!l.appToken||!l.signingSecret,loading:s,fullWidth:!0,children:s?"Connecting...":"Connect to Slack"})})]})]})]})},Mte=()=>{const[n,e]=N.useState("general"),t=[{id:"general",label:"General",icon:hP},{id:"roles",label:"Roles",icon:Qp},{id:"skills",label:"Skills",icon:xP},{id:"slack",label:"Slack",icon:aP}],r=()=>{switch(n){case"general":return c.jsx(ate,{});case"roles":return c.jsx(hte,{});case"skills":return c.jsx(vte,{});case"slack":return c.jsx(Ate,{});default:return null}};return c.jsxs("div",{className:"max-w-7xl mx-auto",children:[c.jsxs("div",{className:"mb-8",children:[c.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Settings"}),c.jsx("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Configure Crewly behavior and manage roles and skills"})]}),c.jsx("nav",{className:"flex gap-1 border-b border-border-dark mb-6",role:"tablist",children:t.map(s=>c.jsxs("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors -mb-px ${n===s.id?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark hover:bg-surface-dark"}`,onClick:()=>e(s.id),"aria-selected":n===s.id,role:"tab",id:`tab-${s.id}`,"aria-controls":`panel-${s.id}`,children:[c.jsx(s.icon,{className:"w-4 h-4"}),c.jsx("span",{children:s.label})]},s.id))}),c.jsx("main",{role:"tabpanel",id:`panel-${n}`,"aria-labelledby":`tab-${n}`,children:r()})]})},ga="/api/chat";class Ete{async parseResponse(e,t){const r=await e.text();if(!r)throw new Error(t);try{return JSON.parse(r)}catch{throw new Error(t)}}async sendMessage(e){const t=await fetch(`${ga}/send`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await this.parseResponse(t,"Failed to send message");if(!r.success)throw new Error(r.error||"Failed to send message");return r.data}async getMessages(e,t,r){const s=new URLSearchParams({conversationId:e});t&&s.set("limit",t.toString()),r&&s.set("before",r);const i=await fetch(`${ga}/messages?${s.toString()}`),o=await this.parseResponse(i,"Failed to load messages");if(!o.success)throw new Error(o.error||"Failed to load messages");return o.data}async getConversations(e=!1){const r=await fetch(`${ga}/conversations${e?"?includeArchived=true":""}`),s=await this.parseResponse(r,"Failed to load conversations");if(!s.success)throw new Error(s.error||"Failed to load conversations");return s.data}async getCurrentConversation(){const e=await fetch(`${ga}/conversations/current`),t=await this.parseResponse(e,"Failed to load current conversation");if(!t.success)throw new Error(t.error||"Failed to load current conversation");return t.data}async createConversation(e){const t=await fetch(`${ga}/conversations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to create conversation");return r.data}async updateConversation(e,t){const r=await fetch(`${ga}/conversations/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await this.parseResponse(r,"Request failed");if(!s.success)throw new Error(s.error||"Failed to update conversation");return s.data}async deleteConversation(e){const t=await fetch(`${ga}/conversations/${e}`,{method:"DELETE"}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to delete conversation")}async archiveConversation(e){const t=await fetch(`${ga}/conversations/${e}/archive`,{method:"PUT"}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to archive conversation")}async clearConversation(e){const t=await fetch(`${ga}/conversations/${e}/clear`,{method:"POST"}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to clear conversation")}}const Do=new Ete,bD=N.createContext(null),Tte=({children:n})=>{const[e,t]=N.useState([]),[r,s]=N.useState(null),[i,o]=N.useState([]),[a,l]=N.useState(!0),[u,d]=N.useState(!1),[h,f]=N.useState(null),[g,y]=N.useState(!1),b=N.useRef(null);N.useEffect(()=>{b.current=r},[r]);const p=N.useCallback(L=>{let D;const z=L;if(z&&typeof z=="object"&&("data"in z&&z.data&&typeof z.data=="object"?D=z.data:"id"in z&&(D=z)),!D||!D.id)return;const q=b.current;D.conversationId===(q==null?void 0:q.id)&&(o(X=>X.some(K=>K.id===D.id)?X:[...X,D]),y(!1)),t(X=>X.map(K=>K.id===D.conversationId?{...K,lastMessage:{content:D.content.slice(0,100),timestamp:D.timestamp,from:D.from},messageCount:K.messageCount+1,updatedAt:D.timestamp}:K))},[]),m=N.useCallback(L=>{const D=L,z=D.data||D,q=b.current;z.conversationId===(q==null?void 0:q.id)&&y(z.isTyping??!1)},[]),x=N.useCallback(L=>{let D;const z=L;if(z&&typeof z=="object"&&("data"in z&&z.data&&typeof z.data=="object"?D=z.data:"id"in z&&(D=z)),!D||!D.id)return;t(X=>{const K=X.findIndex(I=>I.id===D.id);if(K>=0){const I=[...X];return I[K]=D,I}return[D,...X]});const q=b.current;(q==null?void 0:q.id)===D.id&&s(D)},[]);N.useEffect(()=>(ut.on("chat_message",p),ut.on("chat_typing",m),ut.on("conversation_updated",x),ut.subscribeToChat(),()=>{ut.off("chat_message",p),ut.off("chat_typing",m),ut.off("conversation_updated",x),ut.unsubscribeFromChat()}),[p,m,x]),N.useEffect(()=>{(async()=>{l(!0);try{const[D,z]=await Promise.all([Do.getConversations(),Do.getCurrentConversation()]);if(t(D),z){s(z);const q=await Do.getMessages(z.id);o(q)}}catch(D){f(D instanceof Error?D.message:"Failed to load chat")}finally{l(!1)}})()},[]);const v=N.useCallback(async L=>{if(!(!L.trim()||u)){d(!0),f(null);try{const D=await Do.sendMessage({content:L,conversationId:r==null?void 0:r.id});o(z=>z.some(q=>q.id===D.message.id)?z:[...z,D.message]),r||(s(D.conversation),t(z=>[D.conversation,...z])),D.orchestrator&&!D.orchestrator.forwarded&&D.orchestrator.error&&f(D.orchestrator.error)}catch(D){f(D instanceof Error?D.message:"Failed to send message")}finally{d(!1)}}},[u,r]),w=N.useCallback(async L=>{const D=e.find(z=>z.id===L);if(D){s(D),l(!0),f(null);try{const z=await Do.getMessages(L);o(z)}catch(z){f(z instanceof Error?z.message:"Failed to load messages")}finally{l(!1)}}},[e]),C=N.useCallback(async L=>{const D=await Do.createConversation(L);return t(z=>[D,...z]),s(D),o([]),D},[]),M=N.useCallback(async L=>{if(await Do.deleteConversation(L),t(D=>D.filter(z=>z.id!==L)),(r==null?void 0:r.id)===L){const D=e.filter(z=>z.id!==L);D.length>0?await w(D[0].id):(s(null),o([]))}},[r,e,w]),T=N.useCallback(async L=>{if(await Do.archiveConversation(L),t(D=>D.filter(z=>z.id!==L)),(r==null?void 0:r.id)===L){const D=e.filter(z=>z.id!==L);D.length>0?await w(D[0].id):(s(null),o([]))}},[r,e,w]),A=N.useCallback(async L=>{await Do.clearConversation(L),(r==null?void 0:r.id)===L&&o([])},[r]),E=N.useCallback(async()=>{if(!r)return;const L=await Do.getMessages(r.id);o(L)},[r]),R=N.useCallback(()=>{f(null)},[]),j={conversations:e,currentConversation:r,messages:i,isLoading:a,isSending:u,error:h,isTyping:g,sendMessage:v,selectConversation:w,createConversation:C,deleteConversation:M,archiveConversation:T,clearConversation:A,refreshMessages:E,clearError:R};return c.jsx(bD.Provider,{value:j,children:n})},wD=()=>{const n=N.useContext(bD);if(!n)throw new Error("useChat must be used within a ChatProvider");return n},Nr={MINUTE:60*1e3,HOUR:60*60*1e3,DAY:24*60*60*1e3,WEEK:7*24*60*60*1e3,MONTH:30*24*60*60*1e3,YEAR:365*24*60*60*1e3};function kte(n,e=new Date){const t=typeof n=="string"?new Date(n):n,r=e.getTime()-t.getTime();if(r<0)return Rte(Math.abs(r));if(r<Nr.MINUTE)return"just now";if(r<Nr.HOUR){const s=Math.floor(r/Nr.MINUTE);return`${s} ${s===1?"minute":"minutes"} ago`}if(r<Nr.DAY){const s=Math.floor(r/Nr.HOUR);return`${s} ${s===1?"hour":"hours"} ago`}if(r<Nr.DAY*2)return"Yesterday";if(r<Nr.WEEK)return`${Math.floor(r/Nr.DAY)} days ago`;if(r<Nr.MONTH){const s=Math.floor(r/Nr.WEEK);return`${s} ${s===1?"week":"weeks"} ago`}if(r<Nr.YEAR){const s=Math.floor(r/Nr.MONTH);return`${s} ${s===1?"month":"months"} ago`}return Nte(t)}function Rte(n){if(n<Nr.MINUTE)return"in a moment";if(n<Nr.HOUR){const t=Math.floor(n/Nr.MINUTE);return`in ${t} ${t===1?"minute":"minutes"}`}if(n<Nr.DAY){const t=Math.floor(n/Nr.HOUR);return`in ${t} ${t===1?"hour":"hours"}`}return n<Nr.DAY*2?"Tomorrow":`in ${Math.floor(n/Nr.DAY)} days`}function Nte(n,e={}){const t={month:"short",day:"numeric",year:"numeric",...e};return n.toLocaleDateString(void 0,t)}function Ite(n){if(n.from.name)return n.from.name;switch(n.from.type){case"user":return"You";case"orchestrator":return"Orchestrator";case"agent":return n.from.role??"Agent";case"system":return"System";default:return"Unknown"}}function Pte(n){switch(n.from.type){case"user":return"๐Ÿ‘ค";case"orchestrator":return"๐Ÿค–";case"agent":return"๐Ÿ”ง";case"system":return"โ„น๏ธ";default:return"๐Ÿ’ฌ"}}function Lte(n){return n.split(/(```[\s\S]*?```)/g).map((t,r)=>{if(t.startsWith("```")&&t.endsWith("```")){const s=t.slice(3,-3),i=s.indexOf(`
4918
4918
  `),o=i>0?s.slice(0,i).trim():"",a=i>0?s.slice(i+1):s;return c.jsx("pre",{className:"code-block","data-language":o,children:c.jsx("code",{children:a})},r)}return c.jsx("span",{children:jte(t)},r)})}function jte(n){return n.split(/(`[^`]+`)/g).map((t,r)=>{if(t.startsWith("`")&&t.endsWith("`"))return c.jsx("code",{className:"inline-code",children:t.slice(1,-1)},r);let s=t;const i=/\*\*([^*]+)\*\*/g,o=t.split(i);return o.length>1&&(s=o.map((a,l)=>l%2===1?c.jsx("strong",{children:a},`bold-${r}-${l}`):a)),c.jsx(Cn.Fragment,{children:s},r)})}const Bte=({message:n})=>{var l,u,d;const[e,t]=N.useState(!1),r=n.from.type==="user",s=n.from.type==="system",i=!!((l=n.metadata)!=null&&l.rawOutput),o=()=>{var h;return e&&((h=n.metadata)!=null&&h.rawOutput)?c.jsx("pre",{className:"raw-output","data-testid":"raw-output",children:n.metadata.rawOutput}):n.contentType==="code"||n.contentType==="markdown"||n.contentType==="text"?c.jsx("div",{className:"formatted-content",children:Lte(n.content)}):c.jsx("p",{children:n.content})},a=["chat-message",n.from.type,r?"user-message":"",s?"system-message":"",n.status==="error"?"error-status":""].filter(Boolean).join(" ");return c.jsxs("div",{className:a,"data-testid":"chat-message",children:[c.jsxs("div",{className:"message-header",children:[c.jsx("span",{className:"sender-icon","aria-hidden":"true",children:Pte(n)}),c.jsx("span",{className:"sender-name",children:Ite(n)}),c.jsx("span",{className:"message-time",children:kte(n.timestamp)}),i&&c.jsx("button",{className:"toggle-raw-btn",onClick:()=>t(!e),title:e?"Show formatted":"Show raw output","aria-label":e?"Show formatted":"Show raw output","data-testid":"toggle-raw-button",children:e?"๐Ÿ“":"๐Ÿ”"})]}),c.jsx("div",{className:"message-content",children:o()}),((u=n.metadata)==null?void 0:u.skillUsed)&&c.jsx("div",{className:"message-metadata",children:c.jsxs("span",{className:"skill-badge",children:["Skill: ",n.metadata.skillUsed]})}),((d=n.metadata)==null?void 0:d.taskCreated)&&c.jsx("div",{className:"message-metadata",children:c.jsxs("span",{className:"task-badge",children:["Task created: ",n.metadata.taskCreated]})}),n.status==="error"&&c.jsx("div",{className:"message-error",role:"alert",children:"Failed to deliver"})]})};const Dte=({disabled:n=!1,disabledPlaceholder:e})=>{const{sendMessage:t,isSending:r,error:s,clearError:i}=wD(),[o,a]=N.useState(""),l=N.useRef(null);N.useEffect(()=>{const g=l.current;g&&(g.style.height="auto",g.style.height=`${Math.min(g.scrollHeight,200)}px`)},[o]);const u=n||r,d=async()=>{if(!o.trim()||u)return;const g=o.trim();a(""),i(),l.current&&(l.current.style.height="auto"),await t(g)},h=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),d())},f=g=>{a(g.target.value),s&&i()};return c.jsxs("div",{className:"chat-input-container","data-testid":"chat-input-container",children:[s&&c.jsxs("div",{className:"input-error",role:"alert","data-testid":"chat-input-error",children:[c.jsxs("span",{children:["Error: ",s]}),c.jsx("button",{className:"dismiss-error",onClick:i,"aria-label":"Dismiss error",children:"ร—"})]}),c.jsxs("div",{className:"input-wrapper",children:[c.jsx("textarea",{ref:l,value:o,onChange:f,onKeyDown:h,placeholder:n&&e?e:"Type a message... (Enter to send, Shift+Enter for new line)",disabled:u,rows:1,className:`message-input ${n?"disabled-offline":""}`,"data-testid":"chat-message-input","aria-label":"Message input"}),c.jsx("button",{onClick:d,disabled:!o.trim()||u,className:"send-button",title:n?"Orchestrator offline":"Send message","data-testid":"chat-send-button","aria-label":r?"Sending message":n?"Orchestrator offline":"Send message",children:r?c.jsx("span",{className:"sending-indicator","aria-hidden":"true",children:"โณ"}):c.jsx("span",{className:"send-icon","aria-hidden":"true",children:"โžค"})})]}),c.jsxs("div",{className:"input-hints",children:[c.jsxs("span",{children:["Press ",c.jsx("kbd",{children:"Enter"})," to send"]}),c.jsxs("span",{children:[c.jsx("kbd",{children:"Shift"})," + ",c.jsx("kbd",{children:"Enter"})," for new line"]})]})]})};const Ote=()=>c.jsxs("div",{className:"typing-indicator","data-testid":"typing-indicator",children:[c.jsx("span",{className:"sender-icon","aria-hidden":"true",children:"๐Ÿค–"}),c.jsx("span",{className:"sender-name",children:"Orchestrator"}),c.jsxs("div",{className:"typing-dots","aria-label":"Orchestrator is typing",children:[c.jsx("span",{className:"dot"}),c.jsx("span",{className:"dot"}),c.jsx("span",{className:"dot"})]})]});const Fte=60;function Ute(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function Hte(n){const e=Date.now()-new Date(n).getTime(),t=Math.floor(e/1e3);if(t<60)return"just now";const r=Math.floor(t/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}const zte=()=>{const[n,e]=N.useState(null),[t,r]=N.useState([]),[s,i]=N.useState(!1),[o,a]=N.useState(new Set);N.useEffect(()=>{let M=!1;async function T(){try{const[A,E]=await Promise.all([sn.getQueueStatus(),sn.getPendingMessages()]);M||(e(A),r(E))}catch{}}return T(),()=>{M=!0}},[]);const l=N.useCallback(M=>{e(M)},[]),u=N.useCallback(M=>{r(T=>T.some(A=>A.id===M.id)?T:[...T,M])},[]),d=N.useCallback(M=>{r(T=>T.map(A=>A.id===M.id?{...A,status:"processing",processingStartedAt:M.processingStartedAt}:A))},[]),h=N.useCallback(M=>{r(T=>T.filter(A=>A.id!==M.id))},[]),f=N.useCallback(M=>{r(T=>T.filter(A=>A.id!==M.id))},[]),g=N.useCallback(M=>{r(T=>T.filter(A=>A.id!==M.id)),a(T=>{const A=new Set(T);return A.delete(M.id),A})},[]);N.useEffect(()=>(ut.on("queue:status_update",l),ut.on("queue:message_enqueued",u),ut.on("queue:message_processing",d),ut.on("queue:message_completed",h),ut.on("queue:message_failed",f),ut.on("queue:message_cancelled",g),()=>{ut.off("queue:status_update",l),ut.off("queue:message_enqueued",u),ut.off("queue:message_processing",d),ut.off("queue:message_completed",h),ut.off("queue:message_failed",f),ut.off("queue:message_cancelled",g)}),[l,u,d,h,f,g]);const y=async M=>{a(T=>new Set(T).add(M));try{await sn.cancelQueueMessage(M)}catch{a(T=>{const A=new Set(T);return A.delete(M),A})}},[b,p]=N.useState(!1),m=async()=>{p(!0);try{await sn.clearQueue(),r([]),e(null)}catch{}finally{p(!1)}},x=(n==null?void 0:n.pendingCount)??t.filter(M=>M.status==="pending").length,v=(n==null?void 0:n.isProcessing)??t.some(M=>M.status==="processing");if(x===0&&!v&&t.length===0)return null;const w=[];x>0&&w.push(`${x} queued`),v&&w.push("1 processing");const C=w.join(" ยท ");return c.jsxs("div",{className:"queue-status-bar","data-testid":"queue-status-bar",children:[c.jsxs("div",{className:"queue-status-summary",onClick:()=>i(!s),"data-testid":"queue-status-summary",role:"button",tabIndex:0,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),i(!s))},children:[v&&c.jsx("div",{className:"queue-spinner","data-testid":"queue-spinner"}),c.jsx("span",{className:"queue-status-text",children:C}),c.jsx("button",{className:"queue-clear-all-btn",onClick:M=>{M.stopPropagation(),m()},disabled:b,"data-testid":"queue-clear-all-btn",title:"Clear all queued messages",children:b?"Clearing...":"Clear All"}),c.jsx("button",{className:`queue-toggle-btn${s?" expanded":""}`,"aria-label":s?"Collapse queue":"Expand queue",tabIndex:-1,children:"โ–ผ"})]}),c.jsx("div",{className:`queue-message-list${s?" expanded":""}`,"data-testid":"queue-message-list",children:t.map(M=>c.jsxs("div",{className:`queue-message-item${M.status==="processing"?" processing":""}`,"data-testid":"queue-message-item",children:[c.jsx("div",{className:"queue-item-status",children:M.status==="processing"?c.jsx("div",{className:"queue-spinner"}):c.jsx("span",{"aria-label":"pending",children:"๐Ÿ•‘"})}),c.jsxs("div",{className:"queue-item-content",children:[c.jsx("p",{className:"queue-item-preview",children:Ute(M.content,Fte)}),c.jsxs("div",{className:"queue-item-meta",children:[c.jsx("span",{className:"queue-source-badge",children:M.source==="slack"?"slack":"web"}),c.jsx("span",{className:"queue-item-time",children:Hte(M.enqueuedAt)})]})]}),c.jsx("button",{className:"queue-cancel-btn",onClick:()=>M.status==="processing"?m():y(M.id),disabled:o.has(M.id)||b,"data-testid":"queue-cancel-btn",children:o.has(M.id)||b?"Cancelling...":"Cancel"})]},M.id))})]})};const Gte=()=>{const{messages:n,isLoading:e,error:t,isTyping:r,currentConversation:s}=wD(),{status:i,isLoading:o}=bL(),a=N.useRef(null);if(N.useEffect(()=>{a.current&&(a.current.scrollTop=a.current.scrollHeight)},[n,r]),e&&n.length===0)return c.jsx("div",{className:"chat-panel loading","data-testid":"chat-panel-loading",children:c.jsxs("div",{className:"loading-spinner",children:[c.jsx("div",{className:"spinner"}),c.jsx("span",{children:"Loading conversation..."})]})});if(t&&n.length===0)return c.jsx("div",{className:"chat-panel error","data-testid":"chat-panel-error",children:c.jsxs("div",{className:"error-message",children:[c.jsx("span",{className:"error-icon",children:"โš ๏ธ"}),c.jsxs("p",{children:["Error: ",t]}),c.jsx("button",{onClick:()=>window.location.reload(),className:"retry-button",children:"Retry"})]})});const l=!o&&i&&!i.isActive;return c.jsxs("div",{className:"chat-panel","data-testid":"chat-panel",children:[c.jsxs("header",{className:"chat-header",children:[c.jsx("h2",{children:(s==null?void 0:s.title)??"Chat with Orchestrator"}),c.jsxs("span",{className:"message-count",children:[n.length," ",n.length===1?"message":"messages"]})]}),c.jsx(zte,{}),l&&c.jsxs("div",{className:"orchestrator-offline-banner","data-testid":"orchestrator-offline-banner",children:[c.jsx("span",{className:"offline-icon","aria-hidden":"true",children:"โš ๏ธ"}),c.jsxs("div",{className:"offline-content",children:[c.jsx("strong",{children:"Orchestrator Offline"}),c.jsx("p",{children:(i==null?void 0:i.offlineMessage)||(i==null?void 0:i.message)})]}),c.jsx(sh,{to:"/",className:"dashboard-link",children:"Go to Dashboard"})]}),c.jsxs("div",{className:"messages-container",ref:a,"data-testid":"messages-container",children:[n.length===0?c.jsx("div",{className:"empty-chat","data-testid":"empty-chat",children:c.jsxs("div",{className:"welcome-message",children:[c.jsx("h3",{children:"Welcome to Crewly"}),c.jsx("p",{children:"Start a conversation with the Orchestrator."}),c.jsx("p",{children:"Try asking to:"}),c.jsxs("ul",{children:[c.jsx("li",{children:"Create a new project"}),c.jsx("li",{children:"Assign a task to an agent"}),c.jsx("li",{children:"Check project status"}),c.jsx("li",{children:"Configure a team"})]})]})}):c.jsx(c.Fragment,{children:n.map(u=>c.jsx(Bte,{message:u},u.id))}),r&&c.jsx(Ote,{}),c.jsx("div",{className:"messages-end"})]}),c.jsx(Dte,{disabled:l,disabledPlaceholder:"Orchestrator is offline. Start it from the Dashboard to chat."})]})};const Wte=()=>c.jsxs("div",{className:"chat-page messenger-style",children:[c.jsxs("header",{className:"chat-page-header",children:[c.jsx("h1",{children:"Chat with Orchestrator"}),c.jsx("p",{children:"Communicate with the Crewly orchestrator to manage projects and teams"})]}),c.jsx("div",{className:"chat-page-content",children:c.jsx("main",{className:"chat-page-main",children:c.jsx(Gte,{})})})]}),ku="/api/marketplace";async function Vte(n){const e=new URLSearchParams;n!=null&&n.type&&e.set("type",n.type),n!=null&&n.search&&e.set("search",n.search),n!=null&&n.sort&&e.set("sort",n.sort);const t=e.toString(),r=`${ku}${t?`?${t}`:""}`;return(await vt.get(r)).data.data}async function Xte(n){return(await vt.post(`${ku}/${n}/install`)).data}async function Kte(n){return(await vt.post(`${ku}/${n}/uninstall`)).data}async function Jte(n){return(await vt.post(`${ku}/${n}/update`)).data}async function E3(){await vt.post(`${ku}/refresh`)}async function qte(n){const e=n?`?status=${n}`:"";return(await vt.get(`${ku}/submissions${e}`)).data.data}async function $te(n,e,t){return(await vt.post(`${ku}/submissions/${n}/review`,{action:e,notes:t})).data}const Yte=4e3;function Qte(){const[n,e]=N.useState([]),t=N.useRef(0),r=N.useCallback((i,o="info")=>{const a=`toast-${++t.current}`,l={id:a,message:i,type:o};e(u=>[...u,l]),setTimeout(()=>{e(u=>u.filter(d=>d.id!==a))},Yte)},[]),s=N.useCallback(i=>{e(o=>o.filter(a=>a.id!==i))},[]);return{toasts:n,addToast:r,dismissToast:s}}const Zte={success:"border-green-500 bg-green-500/10 text-green-300",error:"border-red-500 bg-red-500/10 text-red-300",info:"border-blue-500 bg-blue-500/10 text-blue-300"};function ene({toasts:n,onDismiss:e}){return n.length===0?null:c.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm",role:"log","aria-live":"polite",children:n.map(t=>c.jsxs("div",{"data-testid":`toast-${t.type}`,className:`flex items-center gap-3 px-4 py-3 rounded-lg border text-sm shadow-lg backdrop-blur-sm ${Zte[t.type]}`,children:[c.jsx("span",{className:"flex-1",children:t.message}),c.jsx("button",{onClick:()=>e(t.id),className:"text-gray-400 hover:text-white transition-colors shrink-0","aria-label":"Dismiss notification",children:c.jsx(Mr,{className:"w-3.5 h-3.5"})})]},t.id))})}const tne=[{label:"All",value:"all"},{label:"Skills",value:"skill"},{label:"3D Models",value:"model"},{label:"Roles",value:"role"}],nne=[{label:"Popular",value:"popular"},{label:"Highest Rated",value:"rating"},{label:"Newest",value:"newest"}];function rne(n){return n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}const sne={skill:"bg-blue-500/20 text-blue-400",model:"bg-purple-500/20 text-purple-400",role:"bg-emerald-500/20 text-emerald-400"};function ine(){const[n,e]=N.useState("browse"),[t,r]=N.useState([]),[s,i]=N.useState([]),[o,a]=N.useState(!0),[l,u]=N.useState("all"),[d,h]=N.useState(""),[f,g]=N.useState("popular"),[y,b]=N.useState(null),[p,m]=N.useState(null),{toasts:x,addToast:v,dismissToast:w}=Qte(),C=N.useCallback(async()=>{try{a(!0),m(null);const L=await Vte({type:l==="all"?void 0:l,search:d||void 0,sort:f});r(L)}catch{m("Failed to load marketplace items")}finally{a(!1)}},[l,d,f]);N.useEffect(()=>{C()},[C]);const M=async L=>{b(L);try{const D=await Xte(L);v(D.message||`Installed ${L}`,D.success?"success":"error"),await C()}catch(D){const z=D instanceof Error?D.message:"Install failed";v(z,"error")}b(null)},T=async L=>{b(L);try{const D=await Kte(L);v(D.message||`Uninstalled ${L}`,D.success?"success":"error"),await C()}catch(D){const z=D instanceof Error?D.message:"Uninstall failed";v(z,"error")}b(null)},A=async L=>{b(L);try{const D=await Jte(L);v(D.message||`Updated ${L}`,D.success?"success":"error"),await C()}catch(D){const z=D instanceof Error?D.message:"Update failed";v(z,"error")}b(null)},E=async()=>{try{await E3(),v("Registry refreshed","success"),await C()}catch{v("Failed to refresh registry","error")}},R=N.useCallback(async()=>{try{a(!0),m(null);const L=await qte();i(L)}catch{m("Failed to load submissions")}finally{a(!1)}},[]);N.useEffect(()=>{n==="submissions"&&R()},[n,R]);const j=async(L,D)=>{b(L);try{const z=await $te(L,D);v(z.message||`${D==="approve"?"Approved":"Rejected"}`,z.success?"success":"error"),await R(),D==="approve"&&await E3()}catch(z){const q=z instanceof Error?z.message:"Review failed";v(q,"error")}b(null)};return c.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[c.jsxs("div",{className:"flex items-center justify-between mb-6",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(pP,{className:"w-6 h-6 text-indigo-400"}),c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Marketplace"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"flex gap-1 bg-gray-900 rounded-lg p-1",role:"tablist","aria-label":"View mode",children:[c.jsxs("button",{onClick:()=>e("browse"),role:"tab","aria-selected":n==="browse",className:`flex items-center gap-1 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="browse"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[c.jsx(iT,{className:"w-3.5 h-3.5"}),"Browse"]}),c.jsxs("button",{onClick:()=>e("submissions"),role:"tab","aria-selected":n==="submissions",className:`flex items-center gap-1 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="submissions"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[c.jsx(fU,{className:"w-3.5 h-3.5"}),"Submissions"]})]}),c.jsxs("button",{onClick:E,className:"flex items-center gap-2 px-3 py-1.5 text-sm bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg transition-colors","aria-label":"Refresh marketplace",children:[c.jsx(Cu,{className:"w-4 h-4"}),"Refresh"]})]})]}),n==="browse"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6",children:[c.jsx("div",{className:"flex gap-1 bg-gray-900 rounded-lg p-1",role:"tablist","aria-label":"Filter by type",children:tne.map(L=>c.jsx("button",{onClick:()=>u(L.value),role:"tab","aria-selected":l===L.value,className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${l===L.value?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:L.label},L.value))}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"relative",children:[c.jsx(UC,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),c.jsx("input",{type:"text",placeholder:"Search...",value:d,onChange:L=>h(L.target.value),"aria-label":"Search marketplace",className:"bg-gray-900 border border-gray-700 rounded-lg pl-9 pr-3 py-1.5 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500 w-48"})]}),c.jsx("select",{value:f,onChange:L=>g(L.target.value),"aria-label":"Sort by",className:"bg-gray-900 border border-gray-700 rounded-lg px-3 py-1.5 text-sm text-gray-200 focus:outline-none focus:border-indigo-500",children:nne.map(L=>c.jsx("option",{value:L.value,children:L.label},L.value))})]})]}),o?c.jsx("div",{className:"text-center py-16 text-gray-400",role:"status",children:"Loading marketplace..."}):p?c.jsx("div",{className:"text-center py-16 text-red-400",role:"alert",children:p}):t.length===0?c.jsx("div",{className:"text-center py-16 text-gray-400",children:"No items found."}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:t.map(L=>c.jsxs("div",{className:"bg-gray-900 border border-gray-800 rounded-xl p-5 hover:border-gray-700 transition-colors","data-testid":`marketplace-item-${L.id}`,children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${sne[L.type]}`,children:L.type}),c.jsxs("span",{className:"text-xs text-gray-500",children:["v",L.version]})]}),L.installStatus==="installed"&&c.jsx(Ba,{className:"w-4 h-4 text-green-400","aria-label":"Installed"}),L.installStatus==="update_available"&&c.jsx(rT,{className:"w-4 h-4 text-yellow-400","aria-label":"Update available"})]}),c.jsx("h3",{className:"text-base font-semibold text-white mb-1",children:L.name}),c.jsx("p",{className:"text-sm text-gray-400 mb-3 line-clamp-2",children:L.description}),c.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 mb-4",children:[c.jsxs("span",{children:["by ",L.author]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(lU,{className:"w-3 h-3 text-yellow-500"}),L.rating.toFixed(1)]}),c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(KF,{className:"w-3 h-3"}),rne(L.downloads)]})]})]}),c.jsxs("div",{className:"flex gap-2",children:[L.installStatus==="not_installed"&&c.jsxs("button",{onClick:()=>M(L.id),disabled:y===L.id,className:"flex-1 flex items-center justify-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[c.jsx(iT,{className:"w-3 h-3"}),y===L.id?"Installing...":"Install"]}),L.installStatus==="installed"&&c.jsx("button",{onClick:()=>T(L.id),disabled:y===L.id,className:"flex-1 px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg disabled:opacity-50 transition-colors",children:y===L.id?"Removing...":"Uninstall"}),L.installStatus==="update_available"&&c.jsxs(c.Fragment,{children:[c.jsxs("button",{onClick:()=>A(L.id),disabled:y===L.id,className:"flex-1 flex items-center justify-center gap-1 px-3 py-1.5 text-sm bg-yellow-600 hover:bg-yellow-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[c.jsx(rT,{className:"w-3 h-3"}),y===L.id?"Updating...":"Update"]}),c.jsx("button",{onClick:()=>T(L.id),disabled:y===L.id,className:"px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg disabled:opacity-50 transition-colors",children:"Remove"})]})]})]},L.id))})]}),n==="submissions"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mb-6",children:c.jsxs("p",{className:"text-sm text-gray-400",children:["Submit skills via CLI: ",c.jsx("code",{className:"bg-gray-800 px-2 py-0.5 rounded text-xs text-gray-300",children:"crewly publish path/to/skill --submit"})]})}),o?c.jsx("div",{className:"text-center py-16 text-gray-400",role:"status",children:"Loading submissions..."}):p?c.jsx("div",{className:"text-center py-16 text-red-400",role:"alert",children:p}):s.length===0?c.jsx("div",{className:"text-center py-16 text-gray-400",children:"No submissions yet."}):c.jsx("div",{className:"space-y-3",children:s.map(L=>c.jsx("div",{className:"bg-gray-900 border border-gray-800 rounded-xl p-5 hover:border-gray-700 transition-colors","data-testid":`submission-${L.id}`,children:c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("h3",{className:"text-base font-semibold text-white",children:L.name}),c.jsxs("span",{className:"text-xs text-gray-500",children:["v",L.version]}),c.jsxs("span",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${L.status==="pending"?"bg-yellow-500/20 text-yellow-400":L.status==="approved"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[L.status==="pending"&&c.jsx(Zo,{className:"w-3 h-3"}),L.status==="approved"&&c.jsx(Ko,{className:"w-3 h-3"}),L.status==="rejected"&&c.jsx(vP,{className:"w-3 h-3"}),L.status]})]}),c.jsx("p",{className:"text-sm text-gray-400 mb-2",children:L.description}),c.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[c.jsxs("span",{children:["by ",L.author]}),c.jsx("span",{children:L.category}),c.jsx("span",{children:new Date(L.submittedAt).toLocaleDateString()})]}),L.reviewNotes&&c.jsxs("p",{className:"mt-2 text-xs text-gray-400 italic",children:["Review: ",L.reviewNotes]})]}),L.status==="pending"&&c.jsxs("div",{className:"flex gap-2 ml-4",children:[c.jsxs("button",{onClick:()=>j(L.id,"approve"),disabled:y===L.id,className:"flex items-center gap-1 px-3 py-1.5 text-sm bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[c.jsx(Ko,{className:"w-3 h-3"}),y===L.id?"...":"Approve"]}),c.jsx("button",{onClick:()=>j(L.id,"reject"),disabled:y===L.id,className:"px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg disabled:opacity-50 transition-colors",children:"Reject"})]})]})},L.id))})]}),c.jsx(ene,{toasts:x,onDismiss:w})]})}function one({scope:n,onScopeChange:e,projects:t,selectedProjectPath:r,onProjectChange:s}){return c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex gap-1 bg-gray-900 rounded-lg p-1",role:"tablist","aria-label":"Document scope",children:[c.jsxs("button",{role:"tab","aria-selected":n==="global",onClick:()=>e("global"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="global"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[c.jsx(iP,{className:"w-3.5 h-3.5"}),"Global"]}),c.jsxs("button",{role:"tab","aria-selected":n==="project",onClick:()=>e("project"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="project"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[c.jsx(Os,{className:"w-3.5 h-3.5"}),"Project"]})]}),n==="project"&&c.jsxs("select",{value:r||"",onChange:i=>s(i.target.value),"aria-label":"Select project",className:"bg-gray-900 border border-gray-700 rounded-lg px-3 py-1.5 text-sm text-gray-200 focus:outline-none focus:border-indigo-500",children:[c.jsx("option",{value:"",disabled:!0,children:"Select a project..."}),t.map(i=>c.jsx("option",{value:i.path,children:i.name},i.id))]})]})}function ane({categories:n,selectedCategory:e,onCategoryChange:t}){return c.jsxs("div",{className:"space-y-1",role:"listbox","aria-label":"Filter by category",children:[c.jsx("button",{role:"option","aria-selected":e==="",onClick:()=>t(""),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${e===""?"bg-indigo-600/20 text-indigo-400 font-medium":"text-gray-400 hover:bg-gray-800 hover:text-gray-200"}`,children:"All"}),n.map(r=>c.jsx("button",{role:"option","aria-selected":e===r,onClick:()=>t(r),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${e===r?"bg-indigo-600/20 text-indigo-400 font-medium":"text-gray-400 hover:bg-gray-800 hover:text-gray-200"}`,children:r},r))]})}function lne(n){try{return new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return n}}function cne({documents:n,loading:e,searchQuery:t,onSearchChange:r,selectedDocId:s,onSelectDocument:i}){return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"relative mb-4",children:[c.jsx(UC,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),c.jsx("input",{type:"text",placeholder:"Search documents...",value:t,onChange:o=>r(o.target.value),"aria-label":"Search documents",className:"w-full bg-gray-900 border border-gray-700 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500"})]}),e?c.jsx("div",{className:"text-center py-8 text-gray-400",role:"status",children:"Loading documents..."}):n.length===0?c.jsxs("div",{className:"text-center py-8 text-gray-500",children:[c.jsx(Pd,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),c.jsx("p",{children:"No documents found"})]}):c.jsx("div",{className:"space-y-1 overflow-y-auto flex-1",children:n.map(o=>c.jsxs("button",{onClick:()=>i(o.id),className:`w-full text-left px-3 py-3 rounded-lg transition-colors ${s===o.id?"bg-indigo-600/20 border border-indigo-500/30":"hover:bg-gray-800 border border-transparent"}`,children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("h4",{className:"text-sm font-medium text-gray-200 truncate",children:o.title}),c.jsx("p",{className:"text-xs text-gray-500 mt-0.5 line-clamp-1",children:o.preview})]}),c.jsxs("div",{className:"flex flex-col items-end flex-shrink-0",children:[c.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-800 text-gray-400",children:o.category}),c.jsx("span",{className:"text-xs text-gray-600 mt-1",children:lne(o.updatedAt)})]})]}),o.tags.length>0&&c.jsxs("div",{className:"flex gap-1 mt-1.5 flex-wrap",children:[o.tags.slice(0,3).map(a=>c.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-900 text-gray-500",children:a},a)),o.tags.length>3&&c.jsxs("span",{className:"text-xs text-gray-600",children:["+",o.tags.length-3]})]})]},o.id))})]})}function une(n){try{return new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return n}}function dne({document:n,onEdit:e,onDelete:t}){return c.jsxs("div",{className:"h-full overflow-y-auto",children:[c.jsxs("div",{className:"flex items-start justify-between mb-4",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-xl font-bold text-white mb-2",children:n.title}),c.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[c.jsx("span",{className:"px-2 py-0.5 rounded bg-gray-800 text-gray-300",children:n.category}),c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Qp,{className:"w-3 h-3"}),n.createdBy]}),c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Zo,{className:"w-3 h-3"}),une(n.updatedAt)]})]}),n.tags.length>0&&c.jsx("div",{className:"flex gap-1.5 mt-2 flex-wrap",children:n.tags.map(r=>c.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-indigo-500/10 text-indigo-400",children:r},r))})]}),c.jsxs("div",{className:"flex gap-2 ml-4",children:[c.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg transition-colors","aria-label":"Edit document",children:[c.jsx(cP,{className:"w-3.5 h-3.5"}),"Edit"]}),c.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg transition-colors","aria-label":"Delete document",children:[c.jsx(Yp,{className:"w-3.5 h-3.5"}),"Delete"]})]})]}),c.jsx("div",{className:"border-t border-gray-800 pt-4",children:c.jsx("div",{className:"prose prose-invert prose-sm max-w-none whitespace-pre-wrap text-gray-300 leading-relaxed",children:n.content})})]})}const hne=["SOPs","Team Norms","Architecture","Onboarding","Runbooks","General"];function T3({document:n,categories:e,saving:t,onSave:r,onCancel:s}){const[i,o]=N.useState((n==null?void 0:n.title)||""),[a,l]=N.useState((n==null?void 0:n.content)||""),[u,d]=N.useState((n==null?void 0:n.category)||"General"),[h,f]=N.useState((n==null?void 0:n.tags.join(", "))||""),g=[...new Set([...hne,...e])].sort(),y=p=>{p.preventDefault();const m=h.split(",").map(x=>x.trim()).filter(Boolean);r({title:i,content:a,category:u,tags:m})},b=i.trim().length>0&&a.trim().length>0;return c.jsxs("form",{onSubmit:y,className:"h-full flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("h2",{className:"text-lg font-bold text-white",children:n?"Edit Document":"New Document"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg transition-colors",children:[c.jsx(Mr,{className:"w-3.5 h-3.5"}),"Cancel"]}),c.jsxs("button",{type:"submit",disabled:!b||t,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[c.jsx(FC,{className:"w-3.5 h-3.5"}),t?"Saving...":"Save"]})]})]}),c.jsxs("div",{className:"space-y-4 flex-1 flex flex-col",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"doc-title",className:"block text-sm font-medium text-gray-300 mb-1",children:"Title"}),c.jsx("input",{id:"doc-title",type:"text",value:i,onChange:p=>o(p.target.value),placeholder:"Document title",className:"w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500",maxLength:200})]}),c.jsxs("div",{className:"flex gap-4",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"doc-category",className:"block text-sm font-medium text-gray-300 mb-1",children:"Category"}),c.jsx("select",{id:"doc-category",value:u,onChange:p=>d(p.target.value),className:"w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-indigo-500",children:g.map(p=>c.jsx("option",{value:p,children:p},p))})]}),c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"doc-tags",className:"block text-sm font-medium text-gray-300 mb-1",children:"Tags (comma-separated)"}),c.jsx("input",{id:"doc-tags",type:"text",value:h,onChange:p=>f(p.target.value),placeholder:"api, backend, auth",className:"w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500"})]})]}),c.jsxs("div",{className:"flex-1 flex flex-col",children:[c.jsx("label",{htmlFor:"doc-content",className:"block text-sm font-medium text-gray-300 mb-1",children:"Content (Markdown)"}),c.jsx("textarea",{id:"doc-content",value:a,onChange:p=>l(p.target.value),placeholder:"Write your document content in Markdown...",className:"flex-1 min-h-[200px] w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500 font-mono resize-none"})]})]})]})}function fne(){const[n,e]=tP(),[t,r]=N.useState(n.get("project")?"project":"global"),[s,i]=N.useState([]),[o,a]=N.useState(""),[l,u]=N.useState([]),[d,h]=N.useState([]),[f,g]=N.useState(""),[y,b]=N.useState(""),[p,m]=N.useState(!0),[x,v]=N.useState("list"),[w,C]=N.useState(),[M,T]=N.useState(null),[A,E]=N.useState(!1),[R,j]=N.useState(null);N.useEffect(()=>{sn.getProjects().then(i).catch(()=>{})},[]),N.useEffect(()=>{const B=n.get("project");if(B&&s.length>0){const F=s.find(O=>O.id===B);F&&(r("project"),a(F.path))}},[n,s]);const L=N.useCallback(async()=>{try{if(m(!0),j(null),t==="project"&&!o){u([]),h([]),m(!1);return}const[B,F]=await Promise.all([sn.getKnowledgeDocuments(t,o||void 0,f||void 0,y||void 0),sn.getKnowledgeCategories(t,o||void 0)]);u(B),h(F)}catch{j("Failed to load documents")}finally{m(!1)}},[t,o,f,y]);N.useEffect(()=>{L()},[L]);const D=B=>{r(B),C(void 0),T(null),v("list"),B==="global"&&(a(""),e({}))},z=B=>{a(B),C(void 0),T(null),v("list");const F=s.find(O=>O.path===B);F&&e({project:F.id})},q=async B=>{C(B);try{const F=await sn.getKnowledgeDocument(B,t,o||void 0);T(F),v("view")}catch{j("Failed to load document")}},X=()=>{C(void 0),T(null),v("create")},K=async B=>{E(!0);try{if(x==="create"){const F=await sn.createKnowledgeDocument({...B,scope:t,projectPath:o||void 0});await L(),await q(F)}else M&&(await sn.updateKnowledgeDocument(M.id,{...B,scope:t,projectPath:o||void 0}),await L(),await q(M.id))}catch{j("Failed to save document")}finally{E(!1)}},I=async()=>{if(M)try{await sn.deleteKnowledgeDocument(M.id,t,o||void 0),T(null),C(void 0),v("list"),await L()}catch{j("Failed to delete document")}};return c.jsxs("div",{className:"p-6 max-w-7xl mx-auto h-full flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between mb-6",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx($b,{className:"w-6 h-6 text-indigo-400"}),c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Knowledge"})]}),c.jsx(one,{scope:t,onScopeChange:D,projects:s,selectedProjectPath:o,onProjectChange:z})]}),R&&c.jsxs("div",{className:"mb-4 px-4 py-2 bg-red-900/20 border border-red-500/30 rounded-lg text-sm text-red-400",role:"alert",children:[R,c.jsx("button",{onClick:()=>j(null),className:"ml-2 underline",children:"dismiss"})]}),c.jsxs("div",{className:"flex gap-6 flex-1 min-h-0",children:[c.jsxs("div",{className:"w-44 flex-shrink-0",children:[c.jsx("div",{className:"mb-4",children:c.jsxs("button",{onClick:X,className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg transition-colors",children:[c.jsx(Ps,{className:"w-4 h-4"}),"New Document"]})}),c.jsx(ane,{categories:d,selectedCategory:f,onCategoryChange:g})]}),c.jsxs("div",{className:"flex-1 min-w-0 flex gap-6",children:[c.jsx("div",{className:`w-80 flex-shrink-0 ${x==="create"||x==="edit"?"hidden lg:block":""}`,children:c.jsx(cne,{documents:l,loading:p,searchQuery:y,onSearchChange:b,selectedDocId:w,onSelectDocument:q})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[x==="view"&&M&&c.jsx(dne,{document:M,onEdit:()=>v("edit"),onDelete:I}),x==="edit"&&M&&c.jsx(T3,{document:M,categories:d,saving:A,onSave:K,onCancel:()=>v("view")}),x==="create"&&c.jsx(T3,{document:null,categories:d,saving:A,onSave:K,onCancel:()=>v("list")}),x==="list"&&!p&&c.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:c.jsxs("div",{className:"text-center",children:[c.jsx($b,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{children:"Select a document to view"}),c.jsx("p",{className:"text-sm mt-1",children:"or create a new one"})]})})]})]})]})]})}function pne(){return c.jsx(w8,{children:c.jsx(mU,{children:c.jsx(RF,{children:c.jsx(SF,{children:c.jsxs(Ks,{path:"/",element:c.jsx(NH,{}),children:[c.jsx(Ks,{index:!0,element:c.jsx(LH,{})}),c.jsx(Ks,{path:"projects",element:c.jsx(DH,{})}),c.jsx(Ks,{path:"projects/:id",element:c.jsx(XH,{})}),c.jsx(Ks,{path:"teams",element:c.jsx(rz,{})}),c.jsx(Ks,{path:"teams/:id",element:c.jsx(dz,{})}),c.jsx(Ks,{path:"assignments",element:c.jsx(vz,{})}),c.jsx(Ks,{path:"scheduled-checkins",element:c.jsx(Cz,{})}),c.jsx(Ks,{path:"factory",element:c.jsx(ste,{})}),c.jsx(Ks,{path:"marketplace",element:c.jsx(ine,{})}),c.jsx(Ks,{path:"knowledge",element:c.jsx(fne,{})}),c.jsx(Ks,{path:"settings",element:c.jsx(Mte,{})}),c.jsx(Ks,{path:"chat",element:c.jsx(Tte,{children:c.jsx(Wte,{})})})]})})})})})}ZS.createRoot(document.getElementById("root")).render(c.jsx(Cn.StrictMode,{children:c.jsx(pne,{})}));
4919
- //# sourceMappingURL=index-0a245b0d.js.map
4919
+ //# sourceMappingURL=index-45eeea99.js.map