@vxnus/siduri 2.0.31 → 2.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin-manifests.js +1 -1
- package/dist/doctor.js +7 -2
- package/dist/generator.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/web-dist/404/index.html +1 -1
- package/dist/web-dist/404.html +1 -1
- package/dist/web-dist/__next.__PAGE__.txt +27 -28
- package/dist/web-dist/__next._full.txt +21 -23
- package/dist/web-dist/__next._tree.txt +2 -2
- package/dist/web-dist/_next/static/Tq3UpxBQzNTBn_z7F5dip/_buildManifest.js +1 -0
- package/dist/web-dist/_next/static/chunks/136-1d10af93b770a1c8.js +52 -0
- package/dist/web-dist/_next/static/chunks/426-9f7f6e7fffd4c3c3.js +1 -0
- package/dist/web-dist/_next/static/chunks/563b947f-8e2871a2ab7cd91e.js +1 -0
- package/dist/web-dist/_next/static/chunks/app/_global-error/page-bce6d30fb2b1a3b0.js +1 -0
- package/dist/web-dist/_next/static/chunks/app/_not-found/page-74658f4988eabcc7.js +1 -0
- package/dist/web-dist/_next/static/chunks/app/chat/page-26bbc63b0653d064.js +30 -0
- package/dist/web-dist/_next/static/chunks/app/layout-14f1a3f31e58be17.js +1 -0
- package/dist/web-dist/_next/static/chunks/app/operator/page-6b2d0ba884183ad7.js +1 -0
- package/dist/web-dist/_next/static/chunks/app/page-fc4bf56cf33ae27b.js +1 -0
- package/dist/web-dist/_next/static/chunks/framework-7afb7035d9872ea0.js +1 -0
- package/dist/web-dist/_next/static/chunks/main-8553b996986f1210.js +5 -0
- package/dist/web-dist/_next/static/chunks/main-app-9e6a144626e5a5b9.js +1 -0
- package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/app-error-bce6d30fb2b1a3b0.js +1 -0
- package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/forbidden-bce6d30fb2b1a3b0.js +1 -0
- package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/global-error-68ea4ac05dcaf701.js +1 -0
- package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/not-found-bce6d30fb2b1a3b0.js +1 -0
- package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/unauthorized-bce6d30fb2b1a3b0.js +1 -0
- package/dist/web-dist/_next/static/chunks/webpack-f73cedc256be153e.js +1 -0
- package/dist/web-dist/_next/static/css/8ef96fc81e2b580f.css +1 -0
- package/dist/web-dist/_not-found/__next._full.txt +10 -10
- package/dist/web-dist/_not-found/__next._not-found.__PAGE__.txt +8 -8
- package/dist/web-dist/_not-found/__next._tree.txt +2 -2
- package/dist/web-dist/_not-found/index.html +1 -1
- package/dist/web-dist/_not-found/index.txt +10 -10
- package/dist/web-dist/chat/__next._full.txt +11 -11
- package/dist/web-dist/chat/__next._tree.txt +2 -2
- package/dist/web-dist/chat/__next.chat.__PAGE__.txt +9 -9
- package/dist/web-dist/chat/index.html +1 -1
- package/dist/web-dist/chat/index.txt +11 -11
- package/dist/web-dist/index.html +1 -1
- package/dist/web-dist/index.txt +21 -23
- package/dist/web-dist/operator/__next._full.txt +11 -11
- package/dist/web-dist/operator/__next._tree.txt +2 -2
- package/dist/web-dist/operator/__next.operator.__PAGE__.txt +9 -9
- package/dist/web-dist/operator/index.html +1 -1
- package/dist/web-dist/operator/index.txt +11 -11
- package/package.json +1 -1
- package/dist/web-dist/_next/static/chunks/0aclfte9ml9y1.js +0 -30
- package/dist/web-dist/_next/static/chunks/0jgw-jf26m0ui.js +0 -22
- package/dist/web-dist/_next/static/chunks/0tdcnq1-n6kof.js +0 -31
- package/dist/web-dist/_next/static/chunks/12vwhiuvdy_i7.js +0 -1
- package/dist/web-dist/_next/static/chunks/1k_g9cde5dbqy.js +0 -1
- package/dist/web-dist/_next/static/chunks/2dsfgoa225hpl.js +0 -1
- package/dist/web-dist/_next/static/chunks/2mno6yfdoee0x.js +0 -1
- package/dist/web-dist/_next/static/chunks/2q2no9qgn-9ba.css +0 -1
- package/dist/web-dist/_next/static/chunks/30a48dk5bjyhj.js +0 -1
- package/dist/web-dist/_next/static/chunks/43-dh-y1t0_u-.js +0 -1
- package/dist/web-dist/_next/static/chunks/turbopack-2hpygfb68u21h.js +0 -1
- package/dist/web-dist/_next/static/d3tXXCuzeKIyxHVR7piDR/_buildManifest.js +0 -11
- package/dist/web-dist/_next/static/d3tXXCuzeKIyxHVR7piDR/_clientMiddlewareManifest.js +0 -1
- package/dist/web-dist/_next/static/media/apple-icon.2g7-yefdphkmy.png +0 -0
- package/dist/web-dist/_next/static/media/favicon.3rlors1ui1gw9.ico +0 -0
- package/dist/web-dist/_next/static/media/icon.0580nb9h-ugue.svg +0 -4
- /package/dist/web-dist/_next/static/{d3tXXCuzeKIyxHVR7piDR → Tq3UpxBQzNTBn_z7F5dip}/_ssgManifest.js +0 -0
- /package/dist/web-dist/_next/static/chunks/{0cz1d0mv5g_q7.js → polyfills-42372ed130431b0a.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[457],{2186:(e,t,s)=>{"use strict";s.d(t,{default:()=>k});var i=s(2184),r=s(276),a=s(3265);function n({onSelectPrompt:e,className:t=""}){return(0,i.jsxs)("div",{className:`chat-empty-state ${t}`,"data-testid":"preferences-starter",children:[(0,i.jsx)("div",{className:"siduri-orb",children:"✦"}),(0,i.jsx)("h2",{children:"Teach Siduri your preferences."}),(0,i.jsx)("p",{children:"Choose a starting point, replace the blanks, and send it. Nothing becomes memory until you approve the receipt."}),(0,i.jsxs)("div",{className:"starter-prompts onboarding-prompts",children:[(0,i.jsxs)("button",{type:"button",onClick:()=>e("Call me [preferred name]."),children:[(0,i.jsx)("span",{children:"Identity"}),"Preferred name or title"]}),(0,i.jsxs)("button",{type:"button",onClick:()=>e("My timezone is [timezone] and my preferred language is [language]."),children:[(0,i.jsx)("span",{children:"Localization"}),"Timezone and language"]}),(0,i.jsxs)("button",{type:"button",onClick:()=>e("My preferred response style is [concise / detailed / technical]."),children:[(0,i.jsx)("span",{children:"Response style"}),"Tone and verbosity"]}),(0,i.jsxs)("button",{type:"button",onClick:()=>e("I am interested in [topics or domains of interest]."),children:[(0,i.jsx)("span",{children:"Knowledge"}),"Topics of interest"]})]}),(0,i.jsx)("p",{className:"onboarding-privacy",children:"Teach Siduri preferences explicitly. Information is stored in private memory only after you approve the receipt."})]})}function l(e){return"number"!=typeof e||isNaN(e)||e<0?0:e>1?1:e}class o{constructor(e){this.expression="neutral",this.action="idle",this.state="idle",this.lipSyncValue=0,this.reducedMotion=!1,this.actionStartTime=0,this.stateStartTime=0,this.lastUpdateTime=Date.now(),e&&this.updateConfig(e)}updateConfig(e){e.expression&&e.expression!==this.expression&&(this.expression=e.expression),e.action&&e.action!==this.action&&(this.action=e.action,this.actionStartTime=Date.now()),e.state&&e.state!==this.state&&(this.state=e.state,this.stateStartTime=Date.now()),void 0!==e.speechId&&(this.speechId=e.speechId),void 0!==e.lipSyncValue&&(this.lipSyncValue=l(e.lipSyncValue)),void 0!==e.reducedMotion&&(this.reducedMotion=e.reducedMotion)}setReducedMotion(e){this.reducedMotion=e}setExpression(e){this.expression=e}setAction(e){this.action=e,this.actionStartTime=Date.now()}setState(e){this.state=e,this.stateStartTime=Date.now()}setLipSync(e){this.lipSyncValue=l(e)}calculateFrameParameters(e=Date.now()){this.lastUpdateTime,this.lastUpdateTime=e;let t=this.reducedMotion?.2:(Math.sin(e/1800)+1)*.5,s=this.reducedMotion?0:2.5*Math.sin(e/2400),i=this.reducedMotion?0:1.8*Math.cos(e/3200),r=this.reducedMotion?0:1.2*Math.sin(e/4e3),a=function(e){if(!e)return{angleX:0,angleY:0,angleZ:0,bodyAngleX:0,eyeBallX:0,eyeBallY:0,speed:1};switch(e.toLowerCase().trim()){case"nod":return{angleX:0,angleY:-12,angleZ:2,bodyAngleX:0,eyeBallX:0,eyeBallY:-.2,speed:2.5};case"wave":return{angleX:8,angleY:4,angleZ:-5,bodyAngleX:5,eyeBallX:.2,eyeBallY:.1,speed:1.8};case"listen":return{angleX:-5,angleY:2,angleZ:4,bodyAngleX:-2,eyeBallX:.1,eyeBallY:.1,speed:1};case"talk":return{angleX:2,angleY:-2,angleZ:0,bodyAngleX:0,eyeBallX:0,eyeBallY:0,speed:1.5};default:return{angleX:0,angleY:0,angleZ:0,bodyAngleX:0,eyeBallX:0,eyeBallY:0,speed:1}}}(this.action),n=(e-this.actionStartTime)/1e3,o=0,c=0,d=0,m=0;this.reducedMotion?"nod"===this.action?c=.5*a.angleY:"wave"===this.action?(o=.5*a.angleX,m=.5*a.bodyAngleX):"listen"===this.action&&(d=.5*a.angleZ,o=.5*a.angleX):"nod"===this.action?c=Math.sin(n*Math.PI*3)*a.angleY:"wave"===this.action?(d=Math.sin(n*Math.PI*2.4)*a.angleZ,o=a.angleX,m=a.bodyAngleX):"listen"===this.action?(d=a.angleZ,o=a.angleX):"talk"===this.action&&(c=2*Math.sin(4*n));let u=0;if("speaking"===this.state){let t=function(e,t){if("number"==typeof t&&!isNaN(t)&&t>0)return l(t);let s=e/1e3;return l(Math.max(0,.45*Math.sin(14*s)+.25*Math.sin(22*s)+.2*Math.sin(8*s)+.1))}(e,this.lipSyncValue);u=this.reducedMotion?.6*t:t}let h=e%4e3/4e3,p=1;return h>.95&&(p=Math.abs(Math.sin((h-.95)/.05*Math.PI-Math.PI/2))),{mouthOpenY:u,angleX:s+o,angleY:i+c,angleZ:r+d,bodyAngleX:m,breath:t,eyeOpenL:p,eyeOpenR:p}}reset(){this.expression="neutral",this.action="idle",this.state="idle",this.lipSyncValue=0,this.speechId=void 0}}async function c(e="/live2d/live2dcubismcore.min.js"){return window.Live2DCubismCore?window.Live2DCubismCore:new Promise((t,s)=>{let i=document.querySelector(`script[src="${e}"]`);if(i)return window.Live2DCubismCore?t(window.Live2DCubismCore):(i.addEventListener("load",()=>t(window.Live2DCubismCore)),void i.addEventListener("error",t=>s(Error(`Failed to load Cubism Core from ${e}: ${t}`))));let r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>{window.Live2DCubismCore?t(window.Live2DCubismCore):s(Error("Live2DCubismCore global not found after script load"))},r.onerror=()=>{let e="https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js";console.warn(`[Live2D] Failed to load local Cubism Core, attempting fallback: ${e}`);let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{window.Live2DCubismCore?t(window.Live2DCubismCore):s(Error("Live2DCubismCore global not found after fallback load"))},i.onerror=e=>s(Error(`Failed to load Cubism Core from both local and remote sources: ${e}`)),document.head.appendChild(i)},document.head.appendChild(r)})}async function d(e){let t=e.lastIndexOf("/"),s=-1!==t?e.slice(0,t+1):"",i=await fetch(e);if(!i.ok)throw Error(`Failed to fetch model manifest from ${e} (${i.status})`);let r=await i.json();if(!r.FileReferences||!r.FileReferences.Moc)throw Error(`Invalid model3.json: missing Moc file reference in ${e}`);let a=s+r.FileReferences.Moc,n=await fetch(a);if(!n.ok)throw Error(`Failed to fetch .moc3 file from ${a} (${n.status})`);let l=await n.arrayBuffer(),o=(r.FileReferences.Textures||[]).map(e=>s+e),c=await Promise.all(o.map(e=>new Promise((t,s)=>{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=t=>s(Error(`Failed to load texture from ${e}`)),i.src=e}))),d=new Map;return r.FileReferences.Expressions&&r.FileReferences.Expressions.length>0&&await Promise.all(r.FileReferences.Expressions.map(async e=>{try{let t=s+e.File,i=await fetch(t);if(i.ok){let t=await i.json();d.set(e.File,t),e.Name&&d.set(e.Name,t)}}catch{}})),{model3:r,mocBuffer:l,textures:c,expressions:d,basePath:s}}let m=`
|
|
2
|
+
attribute vec2 a_position;
|
|
3
|
+
attribute vec2 a_texCoord;
|
|
4
|
+
uniform mat4 u_matrix;
|
|
5
|
+
varying vec2 v_texCoord;
|
|
6
|
+
void main() {
|
|
7
|
+
gl_Position = u_matrix * vec4(a_position.x, a_position.y, 0.0, 1.0);
|
|
8
|
+
v_texCoord = vec2(a_texCoord.x, 1.0 - a_texCoord.y);
|
|
9
|
+
}
|
|
10
|
+
`,u=`
|
|
11
|
+
precision mediump float;
|
|
12
|
+
uniform sampler2D u_texture;
|
|
13
|
+
uniform float u_opacity;
|
|
14
|
+
varying vec2 v_texCoord;
|
|
15
|
+
void main() {
|
|
16
|
+
vec4 color = texture2D(u_texture, v_texCoord);
|
|
17
|
+
gl_FragColor = color * u_opacity;
|
|
18
|
+
}
|
|
19
|
+
`,h=`
|
|
20
|
+
precision mediump float;
|
|
21
|
+
uniform sampler2D u_texture;
|
|
22
|
+
varying vec2 v_texCoord;
|
|
23
|
+
void main() {
|
|
24
|
+
vec4 color = texture2D(u_texture, v_texCoord);
|
|
25
|
+
if (color.a < 0.1) {
|
|
26
|
+
discard;
|
|
27
|
+
}
|
|
28
|
+
gl_FragColor = vec4(1.0);
|
|
29
|
+
}
|
|
30
|
+
`;function p(e,t,s){let i=e.createShader(t);if(!i)throw Error("Failed to create shader");if(e.shaderSource(i,s),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(i);throw e.deleteShader(i),Error(`Shader compilation error: ${t}`)}return i}class x{constructor(e){this.gl=null,this.program=null,this.maskProgram=null,this.vertexBuffer=null,this.uvBuffer=null,this.indexBuffer=null,this.aPositionLocation=-1,this.aTexCoordLocation=-1,this.uMatrixLocation=null,this.uTextureLocation=null,this.uOpacityLocation=null,this.maskAPositionLocation=-1,this.maskATexCoordLocation=-1,this.maskUMatrixLocation=null,this.maskUTextureLocation=null,this.textures=[],this.moc=null,this.model=null,this.core=null,this.paramIndices=new Map,this.isDisposed=!1,this.modelBounds={minX:-.39,maxX:.4,minY:-.98,maxY:.18,width:.79,height:1.16,centerX:.006,centerY:-.4},this.canvas=e}initialize(e,t){this.core=e;let s={alpha:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,antialias:!0,stencil:!0},i=this.canvas.getContext("webgl",s)||this.canvas.getContext("experimental-webgl",s)||this.canvas.getContext("webgl2",s);if(!i)throw Error("WebGL is not supported in this browser environment");this.gl=i;let r=p(i,i.VERTEX_SHADER,m),a=p(i,i.FRAGMENT_SHADER,u),n=i.createProgram();if(!n)throw Error("Failed to create WebGL program");if(i.attachShader(n,r),i.attachShader(n,a),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw Error(`Program link error: ${i.getProgramInfoLog(n)}`);this.program=n,this.aPositionLocation=i.getAttribLocation(n,"a_position"),this.aTexCoordLocation=i.getAttribLocation(n,"a_texCoord"),this.uMatrixLocation=i.getUniformLocation(n,"u_matrix"),this.uTextureLocation=i.getUniformLocation(n,"u_texture"),this.uOpacityLocation=i.getUniformLocation(n,"u_opacity");let l=p(i,i.FRAGMENT_SHADER,h),o=i.createProgram();if(!o)throw Error("Failed to create Mask WebGL program");if(i.attachShader(o,r),i.attachShader(o,l),i.linkProgram(o),!i.getProgramParameter(o,i.LINK_STATUS))throw Error(`Mask Program link error: ${i.getProgramInfoLog(o)}`);if(this.maskProgram=o,this.maskAPositionLocation=i.getAttribLocation(o,"a_position"),this.maskATexCoordLocation=i.getAttribLocation(o,"a_texCoord"),this.maskUMatrixLocation=i.getUniformLocation(o,"u_matrix"),this.maskUTextureLocation=i.getUniformLocation(o,"u_texture"),this.vertexBuffer=i.createBuffer(),this.uvBuffer=i.createBuffer(),this.indexBuffer=i.createBuffer(),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),this.textures=t.textures.map(e=>{let t=i.createTexture();if(!t)throw Error("Failed to create WebGL texture");return i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e),i.generateMipmap(i.TEXTURE_2D),t}),this.moc=e.Moc.fromArrayBuffer(t.mocBuffer),!this.moc)throw Error("Failed to create Live2D Moc from ArrayBuffer");if(this.model=e.Model.fromMoc(this.moc),!this.model)throw Error("Failed to create Live2D Model from Moc");let c=this.model.parameters.ids;for(let e=0;e<c.length;e++)this.paramIndices.set(c[e],e);this.initializeNeutralMouth(),this.model.update(),this.calculateModelBounds()}initializeNeutralMouth(){this.model&&(this.setParamDirect("ParamMouthOpenY",0),this.setParamDirect("ParamMouthForm",0))}setParamDirect(e,t){let s=this.paramIndices.get(e);if(void 0!==s&&this.model){let e=this.model.parameters.minimumValues[s],i=this.model.parameters.maximumValues[s];this.model.parameters.values[s]=Math.max(e,Math.min(i,t))}}calculateModelBounds(){if(!this.model)return;let e=this.model.drawables,t=e.count,s=1/0,i=-1/0,r=1/0,a=-1/0;for(let n=0;n<t;n++){let t=e.vertexPositions[n];if(t&&0!==t.length)for(let e=0;e<t.length;e+=2){let n=t[e],l=t[e+1];n<s&&(s=n),n>i&&(i=n),l<r&&(r=l),l>a&&(a=l)}}s!==1/0&&i!==-1/0&&r!==1/0&&a!==-1/0&&(this.modelBounds={minX:s,maxX:i,minY:r,maxY:a,width:i-s,height:a-r,centerX:(s+i)/2,centerY:(r+a)/2})}getModelBounds(){return{...this.modelBounds}}setParam(e,t,s=1){let i=this.paramIndices.get(e);if(void 0!==i&&this.model){let e=this.model.parameters.values[i],r=Math.max(this.model.parameters.minimumValues[i],Math.min(this.model.parameters.maximumValues[i],t));this.model.parameters.values[i]=e+(r-e)*s}}render(e,t=Date.now()){let s;if(this.isDisposed||!this.gl||!this.model||!this.program)return;let i=this.gl,r=this.canvas.width,a=this.canvas.height;if(0===r||0===a)return;let n=e.calculateFrameParameters(t);this.setParam("ParamAngleX",n.angleX,.2),this.setParam("ParamAngleY",n.angleY,.2),this.setParam("ParamAngleZ",n.angleZ,.2),this.setParam("ParamBodyAngleX",n.bodyAngleX,.15),this.setParam("ParamBreath",n.breath,.3),this.setParam("ParamEyeLOpen",n.eyeOpenL,.4),this.setParam("ParamEyeROpen",n.eyeOpenR,.4),this.setParam("ParamMouthOpenY",n.mouthOpenY,.35);let l=function(e){if(!e)return"neutral";switch(e.toLowerCase().trim()){case"surprised":return"face_aozame.exp3.json";case"concerned":case"thinking":return"eyes_zetubou.exp3.json";case"happy":return"hair_open.exp3.json";default:return"neutral"}}(e.expression);"face_aozame.exp3.json"===l?(this.setParam("Param10",1,.2),this.setParam("Param9",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)):"eyes_zetubou.exp3.json"===l?(this.setParam("Param9",1,.2),this.setParam("Param10",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)):"hair_open.exp3.json"===l?(this.setParam("Param11",1,.2),this.setParam("Param10",0,.15),this.setParam("Param9",0,.15),this.setParam("Param12",0,.15)):"eye_color.exp3.json"===l?(this.setParam("Param12",1,.2),this.setParam("Param10",0,.15),this.setParam("Param9",0,.15),this.setParam("Param11",0,.15)):(this.setParam("Param10",0,.15),this.setParam("Param9",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)),this.model.update(),i.viewport(0,0,r,a),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),i.enable(i.BLEND),i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),i.useProgram(this.program);let o=r/a,c=this.modelBounds.width,d=this.modelBounds.height,m=this.modelBounds.centerX,u=this.modelBounds.centerY,h=(s=o>=c/d?1.84/d:1.84/c*o)/o,p=new Float32Array([h,0,0,0,0,s,0,0,0,0,1,0,-m*h,-u*s,0,1]);i.uniformMatrix4fv(this.uMatrixLocation,!1,p),i.uniform1i(this.uTextureLocation,0);let x=this.model.drawables,f=x.count,b=x.renderOrders,v=[];for(let e=0;e<f;e++)v.push(e);v.sort((e,t)=>b[e]-b[t]),i.enableVertexAttribArray(this.aPositionLocation),i.enableVertexAttribArray(this.aTexCoordLocation);let g=(e,t)=>{let s=void 0!==t?t:x.opacities[e];if(s<=.001)return;let r=x.textureIndices[e],a=this.textures[r];if(!a)return;i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a),i.uniform1f(this.uOpacityLocation,s);let n=x.vertexPositions[e];i.bindBuffer(i.ARRAY_BUFFER,this.vertexBuffer),i.bufferData(i.ARRAY_BUFFER,n,i.DYNAMIC_DRAW),i.vertexAttribPointer(this.aPositionLocation,2,i.FLOAT,!1,0,0);let l=x.vertexUvs[e];i.bindBuffer(i.ARRAY_BUFFER,this.uvBuffer),i.bufferData(i.ARRAY_BUFFER,l,i.DYNAMIC_DRAW),i.vertexAttribPointer(this.aTexCoordLocation,2,i.FLOAT,!1,0,0);let o=x.indices[e];i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this.indexBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,o,i.DYNAMIC_DRAW),i.drawElements(i.TRIANGLES,o.length,i.UNSIGNED_SHORT,0)},j=e=>{if(!this.maskProgram)return;i.useProgram(this.maskProgram),i.uniformMatrix4fv(this.maskUMatrixLocation,!1,p),i.uniform1i(this.maskUTextureLocation,0),i.enableVertexAttribArray(this.maskAPositionLocation),i.enableVertexAttribArray(this.maskATexCoordLocation);let t=x.textureIndices[e],s=this.textures[t];if(!s)return;i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,s);let r=x.vertexPositions[e];i.bindBuffer(i.ARRAY_BUFFER,this.vertexBuffer),i.bufferData(i.ARRAY_BUFFER,r,i.DYNAMIC_DRAW),i.vertexAttribPointer(this.maskAPositionLocation,2,i.FLOAT,!1,0,0);let a=x.vertexUvs[e];i.bindBuffer(i.ARRAY_BUFFER,this.uvBuffer),i.bufferData(i.ARRAY_BUFFER,a,i.DYNAMIC_DRAW),i.vertexAttribPointer(this.maskATexCoordLocation,2,i.FLOAT,!1,0,0);let n=x.indices[e];i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this.indexBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,n,i.DYNAMIC_DRAW),i.drawElements(i.TRIANGLES,n.length,i.UNSIGNED_SHORT,0),i.useProgram(this.program),i.enableVertexAttribArray(this.aPositionLocation),i.enableVertexAttribArray(this.aTexCoordLocation)},y=-1;for(let e of v)if(!(x.opacities[e]<=.001))if(x.maskCounts[e]>0){let t=x.masks[e][0];t!==y&&(y=t,i.enable(i.STENCIL_TEST),i.stencilMask(255),i.clear(i.STENCIL_BUFFER_BIT),i.stencilFunc(i.ALWAYS,1,255),i.stencilOp(i.KEEP,i.KEEP,i.REPLACE),i.colorMask(!1,!1,!1,!1),j(t),i.colorMask(!0,!0,!0,!0)),i.stencilFunc(i.EQUAL,1,255),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),g(e)}else -1!==y&&(i.disable(i.STENCIL_TEST),y=-1),g(e);-1!==y&&i.disable(i.STENCIL_TEST)}dispose(){if(this.isDisposed=!0,this.gl){for(let e of this.textures)this.gl.deleteTexture(e);this.textures=[],this.vertexBuffer&&this.gl.deleteBuffer(this.vertexBuffer),this.uvBuffer&&this.gl.deleteBuffer(this.uvBuffer),this.indexBuffer&&this.gl.deleteBuffer(this.indexBuffer),this.program&&this.gl.deleteProgram(this.program)}this.model&&"function"==typeof this.model.release&&this.model.release(),this.moc&&"function"==typeof this.moc.release&&this.moc.release(),this.model=null,this.moc=null,this.gl=null}}function f({modelUrl:e,expression:t="neutral",action:s="idle",state:a="idle",speechId:n,lipSyncValue:l,durationMs:m,className:u="",onStatusChange:h}){let p=(0,r.useRef)(null),b=(0,r.useRef)(null),v=(0,r.useRef)(new o({expression:t,action:s,state:a,speechId:n,lipSyncValue:l,durationMs:m})),g=(0,r.useRef)(null),j=(0,r.useRef)(null),[y,N]=(0,r.useState)("loading"),[w,k]=(0,r.useState)(null),[C,E]=(0,r.useState)(0);return(0,r.useEffect)(()=>{if(!window.matchMedia)return;let e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>{v.current.setReducedMotion(e.matches)};return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,r.useEffect)(()=>{v.current.updateConfig({expression:t,action:s,state:a,speechId:n,lipSyncValue:l,durationMs:m})},[t,s,a,n,l,m]),(0,r.useEffect)(()=>{let t=!1,s=null;async function i(){if(b.current&&p.current){if(!e){N("error"),k("No Live2D model configured. Place model in assets/body/<name>/"),h?.("error","No Live2D model URL specified");return}N("loading"),h?.("loading"),k(null);try{let i=await c();if(t)return;let r=await d(e);if(t)return;let a=b.current;if(!a)return;let n=new x(a);n.initialize(i,r),g.current=n;let l=()=>{if(!p.current||!b.current)return;let e=p.current.getBoundingClientRect();if(e.width<=0||e.height<=0)return;let t=Math.min(window.devicePixelRatio||1,2),s=Math.max(1,Math.floor(e.width*t)),i=Math.max(1,Math.floor(e.height*t));(b.current.width!==s||b.current.height!==i)&&(b.current.width=s,b.current.height=i)};l(),(s=new ResizeObserver(l)).observe(p.current);let o=()=>{t||(g.current&&g.current.render(v.current,performance.now()),j.current=requestAnimationFrame(o))};j.current=requestAnimationFrame(o),N("ready"),h?.("ready")}catch(s){if(t)return;let e=s?.message||"Failed to initialize Live2D avatar";console.warn("[AvatarCanvas] Initialization error:",s),N("error"),k("Avatar model unavailable or failed to load."),h?.("error",e)}}}i();let r=b.current,a=e=>{e.preventDefault(),console.warn("[AvatarCanvas] WebGL context lost"),j.current&&cancelAnimationFrame(j.current),N("error"),k("WebGL context lost.")},n=()=>{console.log("[AvatarCanvas] WebGL context restored, re-initializing..."),i()};return r&&(r.addEventListener("webglcontextlost",a,!1),r.addEventListener("webglcontextrestored",n,!1)),()=>{t=!0,j.current&&(cancelAnimationFrame(j.current),j.current=null),s&&s.disconnect(),r&&(r.removeEventListener("webglcontextlost",a),r.removeEventListener("webglcontextrestored",n)),g.current&&(g.current.dispose(),g.current=null)}},[e,C,h]),(0,i.jsxs)("div",{ref:p,"data-testid":"avatar-canvas-container",className:`relative w-full h-full min-h-0 flex items-center justify-center overflow-hidden bg-transparent ${u}`,"aria-label":"Live2D Companion Presence",children:[(0,i.jsx)("canvas",{ref:b,role:"img","data-testid":"avatar-webgl-canvas","aria-label":"Live2D companion presence",style:{width:"100%",height:"100%",display:"block"},className:`absolute inset-0 w-full h-full block transition-opacity duration-500 ${"ready"===y?"opacity-100":"opacity-0"}`}),"loading"===y&&(0,i.jsxs)("div",{role:"status","aria-live":"polite",className:"absolute inset-0 flex flex-col items-center justify-center gap-3 bg-[#0b0b0e]/90 text-[var(--siduri-text-muted)]",children:[(0,i.jsx)("div",{className:"siduri-glyph w-10 h-10 text-base animate-pulse motion-reduce:animate-none",children:"✦"}),(0,i.jsx)("span",{className:"text-[11px] font-mono tracking-widest uppercase text-[var(--siduri-ember-light)]",children:"Initializing Presence..."})]}),"error"===y&&(0,i.jsxs)("div",{role:"alert","aria-live":"polite",className:"absolute inset-0 flex flex-col items-center justify-center p-6 text-center bg-[#0b0b0e]/95 text-[var(--siduri-text-muted)]",children:[(0,i.jsx)("div",{className:"w-8 h-8 rounded-full border border-[var(--siduri-border-subtle)] grid place-items-center text-xs text-[var(--siduri-text-dim)] mb-2 font-mono",children:"!"}),(0,i.jsx)("p",{className:"text-xs font-sans text-[var(--siduri-text-secondary)] mb-1",children:w||"Avatar unavailable in this browser."}),(0,i.jsx)("span",{className:"text-[10px] font-mono text-[var(--siduri-text-dim)] mb-3",children:"Conversational text mode remains active"}),(0,i.jsx)("button",{type:"button",onClick:()=>E(e=>e+1),className:"px-3 py-1 text-[11px] font-mono tracking-wider uppercase rounded border border-[var(--siduri-border-subtle)] hover:border-[var(--siduri-border-ember)] text-[var(--siduri-text-secondary)] hover:text-[var(--siduri-text-primary)] transition-colors focus-visible:ring-1 focus-visible:ring-[var(--siduri-border-ember)] outline-none","aria-label":"Retry avatar initialization",children:"Retry"})]})]})}var b=s(2914),v=s(8839);let g="siduri.chat.conversations.v1";function j(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function y(e){return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(e)}function N(e){if("[interrupted]"===e.content)return{...e,content:"",interrupted:!0,interruptionReason:"interrupted"};if(e.content&&e.content.endsWith(" [interrupted]"))return{...e,content:e.content.slice(0,-14).trim(),interrupted:!0,interruptionReason:"interrupted"};if(e.content&&e.content.startsWith("I couldn’t reach the orchestrator. ")){let t=e.content.slice(35);return{...e,content:"",error:t}}return e}function w(e){switch(e){case"client_disconnect":return{label:"Disconnected",text:"Response stopped due to connection close.",hint:"The connection to the companion service closed prematurely."};case"user_stop":return{label:"Stopped",text:"Response stopped by user.",hint:"Generation was manually cancelled via the stop control."};case"user_barge_in":return{label:"Interrupted",text:"Response interrupted by new message.",hint:"Generation was cancelled because a new prompt was submitted."};case"timeout":return{label:"Timed Out",text:"Response timed out.",hint:"The request exceeded the allotted time limit before finishing."};default:return{label:"Interrupted",text:"Response was interrupted.",hint:e&&"interrupted"!==e?`Reason: ${e}`:void 0}}}function k(){let e,t,s,l,o,c,d,m,[u,h]=(0,r.useState)([]),[p,x]=(0,r.useState)(null),[k,C]=(0,r.useState)(""),[E,A]=(0,r.useState)("connecting"),[P,L]=(0,r.useState)(!1),[S,_]=(0,r.useState)(!1),[R,T]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),[M,B]=(0,r.useState)(!1),[F,U]=(0,r.useState)(!1),[$,z]=(0,r.useState)(null),[O,X]=(0,r.useState)(void 0),[Y,W]=(0,r.useState)("hybrid"),[G,V]=(0,r.useState)("hybrid"),[q,Z]=(0,r.useState)("off"),[H,K]=(0,r.useState)(null),[J,Q]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(null),[es,ei]=(0,r.useState)({}),[er,ea]=(0,r.useState)(!1),[en,el]=(0,r.useState)(null),eo=(0,r.useRef)(null),[ec,ed]=(0,r.useState)({}),[em,eu]=(0,r.useState)({}),[eh,ep]=(0,r.useState)(null),ex=(0,r.useRef)(null),ef=(0,r.useRef)(null),eb=(0,r.useRef)(null),ev=(0,r.useMemo)(()=>u.find(e=>e.id===p)??null,[p,u]);function eg(){return{id:j(),title:"New conversation",messages:[],updatedAt:Date.now()}}function ej(e,t){h(s=>s.map(s=>s.id===e?t(s):s))}async function ey(e){e.preventDefault();let t=k.trim();if(!t)return;if(/\[[^\]]+\]/.test(t))return void A("replace the blanks first");P&&eb.current&&(eb.current.abort("user_barge_in"),eb.current=null,(0,v.Uo)("default","user_barge_in"));let s=ev;s||(s=eg(),h(e=>[s,...e]),x(s.id));let i=s.messages.filter(e=>!("assistant"===e.role&&!e.content.trim()&&!e.error&&!e.interrupted)),r={id:j(),role:"user",content:t,createdAt:Date.now()},a=j(),n=[...i,r,{id:a,role:"assistant",content:"",createdAt:Date.now()}],l=0===s.messages.length?t.slice(0,42):s.title;ej(s.id,e=>({...e,title:l,messages:n,updatedAt:Date.now()})),C(""),L(!0),A("streaming");let o=new AbortController;eb.current=o;try{await (0,v.ZB)("/chat/stream",{id:"default",message:t,medium:"web",mode:Y,subtitleLanguage:"off"!==q?q:void 0,history:s.messages.slice(-20).map(e=>({role:e.role,content:e.content}))},{onStaged:e=>{e?.mode&&("casual"===e.mode||"teach"===e.mode||"hybrid"===e.mode)&&V(e.mode)},onAvatar:e=>{let t=e.speech_id;ef.current&&clearTimeout(ef.current),z({eventId:e.event_id,expression:e.expression||"neutral",action:e.action||"talk",state:"speaking",speechId:t,durationMs:e.durationMs});let s=e.durationMs||4500;ef.current=setTimeout(()=>{z(e=>e?{...e,state:"idle",action:"idle"}:null)},s)},onChunk:e=>{e.deltaText&&ej(s.id,t=>({...t,messages:t.messages.map(t=>t.id===a?{...t,content:t.content+e.deltaText}:t)})),(e.expression||e.action)&&z(t=>t?{...t,expression:e.expression||t.expression,action:e.action||t.action}:null)},onDone:e=>{e?.metadata?.mode&&("casual"===e.metadata.mode||"teach"===e.metadata.mode||"hybrid"===e.metadata.mode)&&V(e.metadata.mode);let t=e.response||{},i=e.metadata?.memory_proposals,r=e.metadata?.behavioral_proposals,n=t.citations||e.metadata?.citations||[],l=t.gate||e.metadata?.gate;ej(s.id,e=>({...e,messages:e.messages.map(e=>e.id===a?{...e,content:e.content||t.subtitle_en||t.subtitle_ja||"",subtitle:t.subtitle,subtitleLanguage:t.subtitle_language||("off"!==q?q:void 0),subtitles:t.subtitles,spokenJa:t.spoken_ja,evidenceIds:t.evidence_ids||(n.length>0?n.map(e=>e.evidence_id||e.evidenceId).filter(Boolean):void 0),citations:n.length>0?n:void 0,gate:l,memoryProposals:i,behavioralProposals:r}:e),updatedAt:Date.now()})),A("online")},onInterrupted:e=>{let t=e?.reason||o.signal.reason||"interrupted";ej(s.id,e=>{let s=e.messages.find(e=>e.id===a);return"user_barge_in"!==t||s&&s.content.trim()?{...e,messages:e.messages.map(e=>e.id===a?{...e,interrupted:!0,interruptionReason:"string"==typeof t?t:"interrupted"}:e),updatedAt:Date.now()}:{...e,messages:e.messages.filter(e=>e.id!==a),updatedAt:Date.now()}}),A("online")},onError:e=>{let t=e?.message||String(e)||"Unknown error";ej(s.id,e=>({...e,messages:e.messages.map(e=>e.id===a?{...e,error:t}:e),updatedAt:Date.now()})),A("offline")}},o.signal)}catch(e){if(!o.signal.aborted){let t=e?.message||String(e)||"Connection error";ej(s.id,e=>({...e,messages:e.messages.map(e=>e.id===a?{...e,error:t}:e),updatedAt:Date.now()})),A("offline")}}finally{eb.current===o&&(eb.current=null),L(!1)}}(0,r.useEffect)(()=>()=>{ef.current&&clearTimeout(ef.current),eb.current&&eb.current.abort("unmounted")},[]),(0,r.useEffect)(()=>{let e=function(){try{let e=JSON.parse(window.localStorage.getItem(g)??"[]");if(!Array.isArray(e))return[];return e.map(e=>({...e,messages:(e.messages||[]).map(N)}))}catch{return[]}}();h(e),x(e[0]?.id??null);try{let e=localStorage.getItem("siduri.chat.subtitleLanguage");e&&Z(e)}catch{}_(!0),(0,v.Zq)("/health").then(async e=>{if(e.ok){let t=await e.json().catch(()=>({}));A("online"),t.organs?.body?.modelUrl?X(t.organs.body.modelUrl):(0,v.Zq)("/api/models/body").then(async e=>{if(e.ok){let t=(await e.json().catch(()=>({}))).models||[],s=t.find(e=>"default"!==e);s?X(`/assets/body/${s}/model.model3.json`):t.length>0&&"default"!==t[0]&&X(`/assets/body/${t[0]}/model.model3.json`)}}).catch(()=>{})}else A("online")}).catch(()=>A("offline")),(0,v.Zq)("/teach/detected-self").then(async e=>{if(e.ok){let t=await e.json().catch(()=>null);t&&t.detected&&(sessionStorage.getItem(`siduri.dismissedSelf:${t.filename}`)||K(t))}}).catch(()=>{})},[]),(0,r.useEffect)(()=>{S&&window.localStorage.setItem(g,JSON.stringify(u))},[u,S]),(0,r.useEffect)(()=>{ex.current?.scrollTo({top:ex.current.scrollHeight,behavior:"smooth"})},[p,ev?.messages.length,P]);let eN=ev?.messages??[],ew=eN.at(-1)?.evidenceIds?.length??0;async function ek(e,t,s){if(ev)try{let i=await (0,v.B2)(`/memory/proposals/${s}`,{id:t,companionId:"default"}),r=i?.status||("approve"===s?"approved":"rejected");ej(ev.id,s=>({...s,messages:s.messages.map(s=>s.id===e&&s.memoryProposals?{...s,memoryProposals:s.memoryProposals.map(e=>(e.proposal_id||e.id)===t?{...e,status:r}:e)}:s)}))}catch(e){console.error("Failed to update memory proposal:",e)}}async function eC(e,t,s){if(ev)try{let i=await (0,v.B2)(`/memory/behavioral/${s}`,{id:t,companionId:"default"}),r=i?.status||("approve"===s?"active":"rejected");ej(ev.id,s=>({...s,messages:s.messages.map(s=>s.id===e&&s.behavioralProposals?{...s,behavioralProposals:s.behavioralProposals.map(e=>(e.directive_id||e.id)===t?{...e,status:r}:e)}:s)}))}catch(e){console.error("Failed to update behavioral proposal:",e)}}function eE(e){if(!e||!e.manifest)return;let t={};Array.isArray(e.scannedDirectives)?e.scannedDirectives.forEach(e=>{t[e.id]=e.approvedByDefault??e.scanResult?.safe??!0}):Array.isArray(e.manifest?.directives)&&e.manifest.directives.forEach(e=>{t[e.id]=!0}),ei(t),et({manifest:e.manifest,scannedDirectives:e.scannedDirectives||e.manifest.directives||[]})}async function eA(e){let t=e.target.files?.[0];if(t)try{let e=await t.text(),s=await (0,v.B2)("/teach/upload-self",{content:e});s&&s.isValid&&s.manifest?eE(s):alert(s?.errors?.join("\n")||"Invalid .self package format")}catch(e){alert(`Failed to parse .self file: ${e.message}`)}finally{e.target&&(e.target.value="")}}async function eP(){if(ee?.manifest){ea(!0);try{let e=Object.entries(es).filter(([,e])=>e).map(([e])=>e),t=await (0,v.B2)("/teach/install-self",{companionId:"default",manifest:ee.manifest,approvedDirectiveIds:e});t&&t.success?(el(`Installed '${ee.manifest.name}' ethos (${e.length} directives active).`),setTimeout(()=>el(null),6e3),et(null),Q(!0),H?.filename&&sessionStorage.setItem(`siduri.dismissedSelf:${H.filename}`,"true")):alert(t?.error||"Failed to install .self package")}catch(e){alert(`Install error: ${e.message}`)}finally{ea(!1)}}}return(0,i.jsxs)("div",{className:`chat-app ${R?"sidebar-collapsed":""} ${I?"mobile-drawer-open":""}`,children:[I&&(0,i.jsx)("div",{className:"chat-backdrop",onClick:()=>D(!1),"aria-hidden":"true"}),(0,i.jsxs)("aside",{className:"chat-sidebar","aria-label":"Conversation history",children:[(0,i.jsxs)("div",{className:"chat-sidebar-top",children:[(0,i.jsxs)("a",{className:"chat-brand",href:"/chat",children:[(0,i.jsx)("span",{className:"chat-brand-mark",children:"S"}),(0,i.jsx)("span",{children:"SIDURI"})]}),(0,i.jsx)("button",{className:"sidebar-collapse",type:"button",onClick:()=>T(e=>!e),"aria-label":R?"Expand sidebar":"Collapse sidebar",children:R?(0,i.jsx)(b.fl,{size:14}):(0,i.jsx)(b.A6,{size:14})}),(0,i.jsx)("button",{className:"mobile-drawer-close flex items-center justify-center",type:"button",onClick:()=>D(!1),"aria-label":"Close conversation drawer",children:(0,i.jsx)(b.US,{size:14})})]}),(0,i.jsxs)("button",{className:"new-chat-button flex items-center gap-1.5",type:"button",onClick:()=>{let e;e=eg(),h(t=>[e,...t]),x(e.id),C(""),A("online"),D(!1)},children:[(0,i.jsx)(b.c1,{size:13,className:"shrink-0"}),(0,i.jsx)("span",{children:"New conversation"})]}),(0,i.jsxs)("div",{className:"history-heading",children:[(0,i.jsx)("span",{children:"Recent conversations"}),(0,i.jsx)("span",{children:u.length})]}),(0,i.jsx)("div",{className:"conversation-list",children:S?0===u.length?(0,i.jsx)("p",{className:"history-empty",children:"Your private conversations will appear here."}):u.slice().sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>(0,i.jsxs)("div",{className:`conversation-row ${e.id===p?"selected":""}`,children:[(0,i.jsxs)("button",{type:"button",className:"conversation-select",onClick:()=>{x(e.id),D(!1)},children:[(0,i.jsx)("span",{className:"conversation-title",children:e.title}),(0,i.jsx)("span",{className:"conversation-date",children:y(e.updatedAt)})]}),(0,i.jsx)("button",{type:"button",className:"conversation-delete flex items-center justify-center",onClick:t=>{t.stopPropagation();var s=e.id;if(h(e=>e.filter(e=>e.id!==s)),p===s){let e=u.find(e=>e.id!==s);x(e?.id??null)}},"aria-label":`Delete ${e.title}`,children:(0,i.jsx)(b.US,{size:12})})]},e.id)):(0,i.jsx)("p",{className:"history-empty",children:"Loading history…"})}),(0,i.jsxs)("div",{className:"sidebar-footer",children:[(0,i.jsxs)("button",{type:"button",onClick:()=>{D(!1),B(!0)},className:"sidebar-settings-btn md:hidden flex items-center gap-1.5",children:[(0,i.jsx)(b.Ze,{size:14,className:"shrink-0"}),(0,i.jsxs)("span",{className:"truncate",children:["Preferences (",Y,"off"!==q?` \xb7 ${q.toUpperCase()}`:"",")"]})]}),(0,i.jsxs)("a",{className:"sidebar-console",href:"/operator",children:[(0,i.jsx)(b.t$,{size:13,className:"shrink-0"}),(0,i.jsx)("span",{children:"Operator console"}),(0,i.jsx)("b",{children:(0,i.jsx)(b.pT,{size:12})})]})]})]}),(0,i.jsxs)("main",{className:"chat-workspace",children:[(0,i.jsxs)("header",{className:"chat-header",children:[(0,i.jsxs)("div",{className:"chat-header-brand-group",children:[(0,i.jsx)("button",{type:"button",className:"mobile-menu-toggle flex items-center justify-center",onClick:()=>D(!0),"aria-label":"Open conversation menu",children:(0,i.jsx)(b.ZB,{size:16})}),(0,i.jsxs)("a",{href:"/chat",className:"chat-header-title",children:[(0,i.jsx)("span",{className:"chat-brand-mark",children:"S"}),(0,i.jsx)("span",{className:"font-bold tracking-widest text-xs hidden xs:inline",children:"SIDURI"})]})]}),(0,i.jsxs)("div",{className:"chat-header-actions flex items-center gap-1.5 sm:gap-2.5",children:[(0,i.jsxs)("button",{type:"button",onClick:()=>U(e=>!e),className:`connection-pill cursor-pointer transition-all focus-visible:ring-1 focus-visible:ring-[var(--siduri-border-ember)] outline-none ${F?"border-[var(--siduri-border-ember)] bg-[var(--siduri-tint-med)] text-[var(--siduri-ember-highlight)]":"hover:border-[var(--siduri-border-ember)] text-[var(--siduri-text-secondary)]"}`,"aria-label":"Toggle avatar presence","aria-expanded":F,title:F?"Disable Avatar Presence":"Enable Avatar Presence",children:[(0,i.jsx)("span",{className:`status-light ${F?"online":""}`}),(0,i.jsx)("span",{className:"text-xs",children:"Presence"})]}),(0,i.jsxs)("button",{type:"button",onClick:()=>B(!0),className:`connection-pill cursor-pointer transition-all md:hidden flex items-center gap-1.5 ${"off"!==q||"hybrid"!==Y?"border-[var(--siduri-border-ember)] bg-[var(--siduri-tint-med)] text-[var(--siduri-ember-highlight)]":"hover:border-[var(--siduri-border-ember)] text-[var(--siduri-text-secondary)]"}`,"aria-label":"Open chat preferences",title:"Preferences & Subtitles",children:[(0,i.jsx)(b.Ze,{size:12,className:"shrink-0"}),(0,i.jsx)("span",{className:"text-xs font-mono font-medium tracking-wide",children:"hybrid"!==Y&&"off"!==q?`${Y.slice(0,4)}\xb7${q.slice(0,2).toUpperCase()}`:"hybrid"!==Y?Y:"off"!==q?`CC:${q.slice(0,2).toUpperCase()}`:"Options"})]}),(0,i.jsxs)("div",{className:`connection-pill hidden md:flex items-center gap-1 sm:gap-1.5 transition-all focus-within:ring-1 focus-within:ring-[var(--siduri-border-ember)] ${"off"!==q?"border-[var(--siduri-border-ember)] bg-[var(--siduri-tint-med)] text-[var(--siduri-ember-highlight)]":"hover:border-[var(--siduri-border-ember)] text-[var(--siduri-text-secondary)]"}`,title:"Subtitle translation language",children:[(0,i.jsx)("span",{className:`status-light ${"off"!==q?"online":""}`}),(0,i.jsx)("span",{className:"text-[10px] uppercase font-mono tracking-wider opacity-60",children:"Subtitles:"}),(0,i.jsxs)("select",{value:["off","en","ja","id","es","zh","ko","fr","de"].includes(q)?q:"custom-selected",onChange:e=>{let t=e.target.value;if("custom"===t){let e=prompt("Enter subtitle language code or name (e.g. it, ru, de, pt, vi):");if(e&&e.trim()){let t=e.trim().toLowerCase();Z(t);try{localStorage.setItem("siduri.chat.subtitleLanguage",t)}catch{}}}else if("custom-selected"!==t){Z(t);try{localStorage.setItem("siduri.chat.subtitleLanguage",t)}catch{}}},className:"bg-transparent text-xs text-[var(--siduri-text-primary)] font-medium outline-none cursor-pointer border-none p-0","aria-label":"Select subtitle language",children:[(0,i.jsx)("option",{value:"off",className:"bg-[#121214] text-white",children:"Subtitles: Off"}),(0,i.jsx)("option",{value:"en",className:"bg-[#121214] text-white",children:"English (EN)"}),(0,i.jsx)("option",{value:"ja",className:"bg-[#121214] text-white",children:"Japanese (JA)"}),(0,i.jsx)("option",{value:"id",className:"bg-[#121214] text-white",children:"Indonesian (ID)"}),(0,i.jsx)("option",{value:"es",className:"bg-[#121214] text-white",children:"Spanish (ES)"}),(0,i.jsx)("option",{value:"zh",className:"bg-[#121214] text-white",children:"Chinese (ZH)"}),(0,i.jsx)("option",{value:"ko",className:"bg-[#121214] text-white",children:"Korean (KO)"}),(0,i.jsx)("option",{value:"fr",className:"bg-[#121214] text-white",children:"French (FR)"}),(0,i.jsx)("option",{value:"de",className:"bg-[#121214] text-white",children:"German (DE)"}),!["off","en","ja","id","es","zh","ko","fr","de"].includes(q)&&(0,i.jsx)("option",{value:"custom-selected",className:"bg-[#121214] text-white",children:q.toUpperCase()}),(0,i.jsx)("option",{value:"custom",className:"bg-[#121214] text-white",children:"Other..."})]})]}),(0,i.jsxs)("span",{className:"connection-pill hidden lg:inline-flex",title:`Status: ${E}`,children:[(0,i.jsx)("span",{className:`status-light ${"online"===E?"online":""}`}),(0,i.jsx)("span",{className:"text-xs",children:E})]}),(0,i.jsxs)("div",{className:"connection-pill hidden md:flex items-center gap-1 sm:gap-1.5",title:"Operating interaction mode",children:[(0,i.jsx)("span",{className:"text-[10px] uppercase font-mono tracking-wider opacity-60",children:"Mode:"}),(0,i.jsxs)("select",{value:Y,onChange:e=>W(e.target.value),className:"bg-transparent text-xs text-[var(--siduri-text-primary)] font-medium outline-none cursor-pointer border-none p-0","aria-label":"Select interaction mode",children:[(0,i.jsx)("option",{value:"hybrid",className:"bg-[#121214] text-white",children:"Hybrid (Default)"}),(0,i.jsx)("option",{value:"teach",className:"bg-[#121214] text-white",children:"Teach"}),(0,i.jsx)("option",{value:"casual",className:"bg-[#121214] text-white",children:"Casual"})]})]})]})]}),H&&!J&&(0,i.jsxs)("div",{"data-testid":"detected-self-banner",className:"bg-[#1c1814] border-b border-[var(--siduri-border-ember)] px-4 py-2.5 flex flex-wrap items-center justify-between gap-3 text-xs text-[#f1e6d0] z-20 shadow-md animate-fade-in",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,i.jsx)(b.qD,{size:18,className:"text-[var(--siduri-ember-highlight)] shrink-0"}),(0,i.jsxs)("span",{children:[(0,i.jsx)("strong",{children:".self file detected on path:"})," ",(0,i.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-black/50 text-[var(--siduri-ember-highlight)] font-mono font-medium border border-[var(--siduri-border-subtle)]",children:H.filename}),H.alreadyInstalled?(0,i.jsx)("span",{className:"ml-1.5 text-[var(--siduri-text-muted)] text-[11px]",children:"(already imported)"}):null," — Import to companion ethos & directives?"]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[(0,i.jsx)("button",{type:"button",onClick:()=>{Q(!0),H.filename&&sessionStorage.setItem(`siduri.dismissedSelf:${H.filename}`,"true")},className:"px-2.5 py-1 rounded text-[var(--siduri-text-muted)] hover:text-white hover:bg-white/5 transition-colors cursor-pointer",children:"Dismiss"}),(0,i.jsx)("button",{type:"button",onClick:function(){H?.parsed&&("teach"!==Y&&(W("teach"),V("teach")),eE(H.parsed))},className:"px-3.5 py-1 rounded bg-[var(--siduri-ember)] text-[#151214] font-semibold hover:brightness-110 shadow-sm transition-all cursor-pointer",children:"Import"})]})]}),en&&(0,i.jsxs)("div",{className:"bg-[#132218] border-b border-[#3e8555] px-4 py-2 text-xs text-[#a9dfbf] flex items-center justify-between z-20",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(b.Sr,{size:14,className:"shrink-0 text-[#a9dfbf]"}),(0,i.jsx)("span",{children:en})]}),(0,i.jsx)("button",{type:"button",onClick:()=>el(null),className:"text-[#a9dfbf] hover:text-white cursor-pointer",children:(0,i.jsx)(b.US,{size:13})})]}),ee&&(0,i.jsx)("div",{"data-testid":"staged-self-modal",className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4 bg-black/75 backdrop-blur-sm animate-fade-in",role:"dialog","aria-modal":"true","aria-label":"Review and install .self package",children:(0,i.jsxs)("div",{className:"relative w-full max-w-2xl max-h-[90vh] bg-[#141418] border border-[var(--siduri-border-ember)] rounded-2xl shadow-2xl flex flex-col overflow-hidden text-[#eee8df]",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between p-4 sm:p-5 border-b border-[var(--siduri-border-subtle)] bg-[#19191e]/90",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[var(--siduri-tint-med)] border border-[var(--siduri-border-ember)] flex items-center justify-center",children:(0,i.jsx)(b.qD,{size:20,className:"text-[var(--siduri-ember-highlight)]"})}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("h3",{className:"text-sm sm:text-base font-bold text-white tracking-wide",children:ee.manifest?.name||"Self Ethos Package"}),(0,i.jsxs)("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-[var(--siduri-tint-low)] text-[var(--siduri-ember-highlight)] border border-[var(--siduri-border-ember)]/40",children:["v",ee.manifest?.version||"1.0.0"]})]}),(0,i.jsxs)("p",{className:"text-[11px] text-[var(--siduri-text-muted)] mt-0.5 font-mono",children:["Author: ",ee.manifest?.author?.name||"Unknown"," \xb7 ID: ",ee.manifest?.id||"custom"]})]})]}),(0,i.jsx)("button",{type:"button",onClick:()=>et(null),className:"w-8 h-8 rounded-lg flex items-center justify-center text-[var(--siduri-text-muted)] hover:text-white hover:bg-white/5 cursor-pointer transition-colors","aria-label":"Close review",children:(0,i.jsx)(b.US,{size:16})})]}),(0,i.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 sm:p-5 space-y-4",children:[(0,i.jsxs)("div",{className:"p-3.5 rounded-xl bg-[#1a1a20] border border-[var(--siduri-border-subtle)] space-y-1.5",children:[(0,i.jsx)("span",{className:"text-[10px] font-mono uppercase tracking-wider text-[var(--siduri-ember-highlight)] font-semibold",children:"Identity Nucleus"}),(0,i.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2",children:[(0,i.jsx)("span",{className:"text-sm font-bold text-white",children:ee.manifest?.identity?.name}),ee.manifest?.identity?.archetype&&(0,i.jsxs)("span",{className:"text-xs text-[var(--siduri-text-secondary)]",children:["\xb7 ",ee.manifest.identity.archetype]})]}),ee.manifest?.identity?.ethos&&(0,i.jsxs)("p",{className:"text-xs text-[var(--siduri-text-secondary)] italic leading-relaxed pt-1",children:['"',ee.manifest.identity.ethos,'"']})]}),Array.isArray(ee.manifest?.relationships)&&ee.manifest.relationships.length>0&&(0,i.jsxs)("div",{className:"p-3.5 rounded-xl bg-[#1a1a20] border border-[var(--siduri-border-subtle)] space-y-2",children:[(0,i.jsx)("span",{className:"text-[10px] font-mono uppercase tracking-wider text-[var(--siduri-ember-highlight)] font-semibold",children:"Relational Stances"}),(0,i.jsx)("div",{className:"space-y-2",children:ee.manifest.relationships.map((e,t)=>(0,i.jsxs)("div",{className:"text-xs space-y-1 p-2 rounded-lg bg-black/30 border border-white/5",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:"font-semibold text-white font-mono",children:e.entityId}),(0,i.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/5 text-[var(--siduri-text-secondary)]",children:e.role||"user"}),(0,i.jsxs)("span",{className:"text-[10px] text-[var(--siduri-ember-highlight)] font-mono",children:["stance: ",e.stance]})]}),Array.isArray(e.conventions)&&e.conventions.length>0&&(0,i.jsx)("ul",{className:"list-disc list-inside text-[11px] text-[var(--siduri-text-secondary)] space-y-0.5 pl-1",children:e.conventions.map((e,t)=>(0,i.jsx)("li",{children:e},t))})]},t))})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("span",{className:"text-[10px] font-mono uppercase tracking-wider text-[var(--siduri-ember-highlight)] font-semibold",children:["Directives Review (",Object.values(es).filter(Boolean).length," of ",ee.scannedDirectives.length," selected)"]}),(0,i.jsxs)("div",{className:"flex gap-2 text-[11px]",children:[(0,i.jsx)("button",{type:"button",onClick:()=>{let e={};ee.scannedDirectives.forEach(t=>{e[t.id]=!0}),ei(e)},className:"text-[var(--siduri-ember-highlight)] hover:underline cursor-pointer",children:"Select All"}),(0,i.jsx)("span",{className:"text-[var(--siduri-text-muted)]",children:"\xb7"}),(0,i.jsx)("button",{type:"button",onClick:()=>ei({}),className:"text-[var(--siduri-text-muted)] hover:underline cursor-pointer",children:"Deselect All"})]})]}),(0,i.jsx)("div",{className:"space-y-2 max-h-64 overflow-y-auto pr-1",children:ee.scannedDirectives.map((e,t)=>{let s=!!es[e.id],r=e.scanResult?.safe!==!1;return(0,i.jsxs)("div",{onClick:()=>ei(t=>({...t,[e.id]:!t[e.id]})),className:`p-3 rounded-xl border transition-all cursor-pointer flex items-start gap-3 ${s?"bg-[#1f1d1b] border-[var(--siduri-border-ember)]/60":"bg-[#16161a]/60 border-[var(--siduri-border-subtle)] opacity-70"}`,children:[(0,i.jsx)("input",{type:"checkbox",checked:s,onChange:()=>{},className:"mt-0.5 rounded cursor-pointer accent-[var(--siduri-ember)]"}),(0,i.jsxs)("div",{className:"flex-1 min-w-0 space-y-1",children:[(0,i.jsxs)("div",{className:"flex items-center flex-wrap gap-1.5 text-[10px] font-mono",children:[(0,i.jsx)("span",{className:"text-[var(--siduri-text-muted)]",children:e.id}),(0,i.jsx)("span",{className:"px-1.5 py-0.2 rounded bg-white/5 text-[var(--siduri-text-secondary)]",children:e.category||"behavioral"}),e.priority&&(0,i.jsxs)("span",{className:"text-[var(--siduri-text-dim)]",children:["P",e.priority]}),r?(0,i.jsxs)("span",{className:"text-[var(--siduri-online)] text-[10px] font-sans inline-flex items-center gap-1",children:[(0,i.jsx)(b.Sr,{size:12,className:"shrink-0"}),(0,i.jsx)("span",{children:"Safe"})]}):(0,i.jsxs)("span",{className:"text-[var(--siduri-danger)] text-[10px] font-sans font-semibold inline-flex items-center gap-1",children:[(0,i.jsx)(b.eq,{size:12,className:"shrink-0"}),(0,i.jsxs)("span",{children:["Blocked: ",e.scanResult?.reason||"Flagged"]})]})]}),(0,i.jsx)("p",{className:"text-xs text-white leading-relaxed",children:e.directive})]})]},e.id||t)})})]})]}),(0,i.jsxs)("div",{className:"p-4 border-t border-[var(--siduri-border-subtle)] bg-[#19191e]/90 flex items-center justify-between gap-3",children:[(0,i.jsx)("button",{type:"button",onClick:()=>et(null),disabled:er,className:"px-4 py-2 rounded-xl text-xs text-[var(--siduri-text-secondary)] hover:text-white hover:bg-white/5 transition-all cursor-pointer font-medium",children:"Cancel"}),(0,i.jsx)("button",{type:"button",onClick:eP,disabled:er||0===Object.values(es).filter(Boolean).length,className:"px-5 py-2 rounded-xl text-xs font-semibold bg-[var(--siduri-ember)] text-[#151214] hover:brightness-110 shadow disabled:opacity-50 disabled:cursor-not-allowed transition-all cursor-pointer flex items-center gap-2",children:er?(0,i.jsx)(i.Fragment,{children:(0,i.jsx)("span",{children:"Installing…"})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{children:"Install Selected Self"}),(0,i.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-black/20 text-[10px] font-mono",children:Object.values(es).filter(Boolean).length})]})})]})]})}),(0,i.jsx)("div",{className:"flex flex-col flex-1 min-h-0 w-full overflow-hidden relative",children:(0,i.jsxs)("section",{className:"conversation-surface","aria-label":"Private chat",children:[(0,i.jsxs)("div",{ref:ex,className:`conversation-scroll ${F?"presence-active":""}`,"aria-live":"polite",children:[F?(0,i.jsx)("div",{className:"avatar-presence-area","data-testid":"avatar-presence-area",children:(0,i.jsx)(f,{modelUrl:O,expression:$?.expression||"neutral",action:$?.action||"idle",state:$?.state||"idle",speechId:$?.speechId,lipSyncValue:$?.lipSyncValue,durationMs:$?.durationMs,className:"w-full h-full"})}):0===eN.length?(0,i.jsx)(n,{onSelectPrompt:e=>C(e)}):eN.map(e=>{let t,s,r,n,l,o,c,d,m;return(0,i.jsxs)("article",{id:`msg-${e.id}`,className:`platform-message ${e.role}`,children:[(0,i.jsx)("div",{className:"message-avatar",children:"user"===e.role?"U":"S"}),(0,i.jsxs)("div",{className:"message-body",children:[(0,i.jsxs)("div",{className:"message-meta",children:[(0,i.jsx)("span",{children:"user"===e.role?"You":"Siduri"}),"assistant"!==e.role||e.content||e.error||e.interrupted||!P?(0,i.jsx)("time",{children:y(e.createdAt)}):(0,i.jsx)("span",{className:"thinking-label",children:"thinking"}),e.interrupted&&(t=w(e.interruptionReason),(0,i.jsx)("span",{className:"interrupted-pill",title:t.hint||t.text,children:t.label})),e.error&&(0,i.jsx)("span",{className:"error-pill",title:"An error occurred during response",children:"error"})]}),e.error?(s=function(e){if(!e)return{title:"Connection or service issue"};let t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("invalid api key")||t.includes("api_key")?{title:"LLM Provider Authentication Failed",hint:"Your API key is invalid or missing. Please check your API key in your .env file or environment variables."}:t.includes("402")||t.includes("insufficient")||t.includes("balance")||t.includes("credits")||t.includes("quota")?{title:"LLM Credits / Quota Exhausted",hint:"Your LLM provider account has run out of credits or reached its usage quota."}:t.includes("429")||t.includes("rate limit")||t.includes("too many requests")?{title:"LLM Rate Limit Reached",hint:"The LLM provider received too many requests. Please wait a moment before trying again."}:t.includes("404")||t.includes("model")&&t.includes("not found")?{title:"LLM Model Not Found",hint:"The configured model could not be found or is unavailable on this provider."}:t.includes("context length")||t.includes("maximum context")||t.includes("token limit")?{title:"Context Window Exceeded",hint:"The conversation exceeded the model's token limit. Consider starting a new chat."}:t.includes("timeout")||t.includes("timed out")||t.includes("deadline")?{title:"LLM Request Timed Out",hint:"The AI provider took too long to generate a response (wall-clock deadline exceeded)."}:t.includes("500")||t.includes("502")||t.includes("503")||t.includes("504")||t.includes("bad gateway")?{title:"LLM Provider Service Outage",hint:"The AI provider is temporarily unavailable or overloaded."}:{title:"Connection or service issue",hint:void 0}}(e.error),(0,i.jsxs)("div",{className:"message-error-container",children:[e.content?(0,i.jsx)("p",{className:"message-primary",children:e.content}):(0,i.jsx)("p",{className:"message-primary text-[var(--siduri-text-muted)] italic",children:"I couldn't complete the response."}),(0,i.jsxs)("div",{className:"message-error-callout",children:[(0,i.jsxs)("div",{className:"error-callout-header flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"error-icon flex items-center justify-center text-[var(--siduri-warning)]","aria-hidden":"true",children:(0,i.jsx)(b.eq,{size:14})}),(0,i.jsx)("span",{className:"error-text",children:s.title})]}),s.hint&&(0,i.jsx)("p",{className:"error-hint text-xs text-[var(--siduri-text-secondary)] mt-1 mb-1",children:s.hint}),(0,i.jsxs)("details",{className:"error-details",children:[(0,i.jsx)("summary",{children:"View technical details"}),(0,i.jsx)("pre",{className:"error-trace",children:e.error})]})]})]})):e.interrupted&&!e.content?(r=w(e.interruptionReason),(0,i.jsxs)("div",{className:"message-cancelled-container",children:[(0,i.jsx)("p",{className:"message-cancelled",children:r.text}),r.hint&&(0,i.jsx)("p",{className:"message-cancelled-hint text-xs text-[var(--siduri-text-dim)] mt-0.5",children:r.hint})]})):"assistant"===e.role&&!e.content&&P?(0,i.jsxs)("div",{className:"thinking-dots",children:[(0,i.jsx)("i",{}),(0,i.jsx)("i",{}),(0,i.jsx)("i",{})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{className:"message-primary",children:e.content}),e.interrupted&&(0,i.jsxs)("p",{className:"message-interrupted-footnote text-xs text-[var(--siduri-text-dim)] italic mt-1",children:["— ",w(e.interruptionReason).text.toLowerCase()]})]}),"off"!==q&&"assistant"===e.role&&((n=e.subtitles?.[q]||(e.subtitleLanguage===q?e.subtitle:void 0)||("ja"===q&&e.spokenJa&&e.spokenJa!==e.content?e.spokenJa:void 0)||(e.subtitle&&e.subtitle!==e.content?e.subtitle:void 0))&&n.trim()!==e.content.trim()?(0,i.jsxs)("p",{className:"message-translation",title:`Subtitle: ${q.toUpperCase()}`,children:[(0,i.jsxs)("span",{className:"text-[10px] font-mono uppercase tracking-wider opacity-60 mr-1.5 not-italic",children:["[",q,"]:"]}),n]}):null),"assistant"===e.role&&(e.gate?.requires_approval||em[e.id])&&(o="requires_approval"===(l=em[e.id]||(e.gate?.requires_approval?"requires_approval":e.gate?.status?.toLowerCase()||"approved")),c="approved"===l,(0,i.jsxs)("div",{className:`truth-gate-card gate-${l}`,children:[(0,i.jsxs)("div",{className:"truth-gate-header",children:[(0,i.jsx)("span",{className:"truth-gate-badge flex items-center gap-1.5",children:c?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b.Sr,{size:12,className:"shrink-0"}),(0,i.jsx)("span",{children:"TRUTH GATE: AUTHORIZED"})]}):o?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b.eq,{size:12,className:"shrink-0"}),(0,i.jsx)("span",{children:"TRUTH GATE: REQUIRES APPROVAL"})]}):(0,i.jsxs)("span",{children:["TRUTH GATE: ",l.toUpperCase()]})}),e.gate?.confidence&&(0,i.jsxs)("span",{className:"truth-gate-metric",children:["Confidence: ",e.gate.confidence]}),e.gate?.uncertainty&&(0,i.jsxs)("span",{className:"truth-gate-metric",children:["Uncertainty: ",e.gate.uncertainty]})]}),o&&(0,i.jsxs)("div",{className:"truth-gate-actions",children:[(0,i.jsx)("span",{className:"truth-gate-prompt",children:"This response contains unverified claims or side-effects that require manual confirmation."}),(0,i.jsxs)("div",{className:"receipt-actions",children:[(0,i.jsx)("button",{type:"button",onClick:()=>eu(t=>({...t,[e.id]:"approved"})),children:"Authorize Response"}),(0,i.jsx)("button",{type:"button",onClick:()=>eu(t=>({...t,[e.id]:"rejected"})),children:"Reject / Block"})]})]})]})),(e.evidenceIds&&e.evidenceIds.length>0||e.citations&&e.citations.length>0)&&(d=!!ec[e.id],m=e.citations?.length||e.evidenceIds?.length||0,(0,i.jsxs)("div",{className:"evidence-trace-card",children:[(0,i.jsx)("button",{type:"button",className:"evidence-toggle-btn",onClick:()=>ed(t=>({...t,[e.id]:!t[e.id]})),title:d?"Collapse grounded evidence trace":"Click to view grounded sources and evidence",children:(0,i.jsxs)("span",{className:"evidence-chip",children:[(0,i.jsx)(b.WI,{size:12,className:"shrink-0"}),(0,i.jsxs)("span",{children:["Grounded in DB (",m," source",1===m?"":"s",")"]}),d?(0,i.jsxs)("span",{className:"inline-flex items-center gap-0.5 opacity-80 font-sans text-[10px]",children:[(0,i.jsx)(b.Mt,{size:11})," Hide"]}):(0,i.jsxs)("span",{className:"inline-flex items-center gap-0.5 opacity-80 font-sans text-[10px]",children:[(0,i.jsx)(b.D3,{size:11})," Show"]})]})}),d&&(0,i.jsx)("div",{className:"evidence-details-tray",children:e.citations&&e.citations.length>0?e.citations.map((e,t)=>{let s=e.evidence_id||e.evidenceId||`ev-${t}`,r=e.provenance||e.source_id||e.sourceId||"grounded-db",a=e.locator&&(e.locator.startsWith("http://")||e.locator.startsWith("https://"));return(0,i.jsxs)("div",{className:"evidence-source-card",children:[(0,i.jsxs)("div",{className:"evidence-source-meta",children:[(0,i.jsxs)("span",{className:"evidence-provenance",children:["[",r,"]"]}),(0,i.jsxs)("span",{className:"evidence-id",children:["ID: ",s]}),e.revision&&(0,i.jsxs)("span",{className:"evidence-rev",children:["rev: ",e.revision]}),(0,i.jsxs)("div",{className:"evidence-actions",children:[a&&(0,i.jsxs)("a",{href:e.locator,target:"_blank",rel:"noopener noreferrer",className:"evidence-action-link",title:`Open external source: ${e.locator}`,children:["Open Source ",(0,i.jsx)(b.pT,{size:12,className:"inline ml-0.5"})]}),e.locator&&e.locator.startsWith("lifedb:")&&(0,i.jsxs)("a",{href:"/operator",className:"evidence-action-link",title:"View record in Operator Console",children:["Operator ",(0,i.jsx)(b.pT,{size:12,className:"inline ml-0.5"})]}),(0,i.jsxs)("button",{type:"button",className:"evidence-inspect-btn flex items-center gap-1",onClick:()=>ep(e),title:"Inspect complete cryptographic evidence payload",children:[(0,i.jsx)(b.WI,{size:10,className:"shrink-0"}),(0,i.jsx)("span",{children:"Inspect"})]})]})]}),e.preview&&(0,i.jsxs)("div",{className:"evidence-source-preview cursor-pointer",onClick:()=>ep(e),title:"Click to view full preview and metadata",children:["“",e.preview,"”"]})]},s||t)}):e.evidenceIds?.map((e,t)=>{let s=e.startsWith("ev-mem"),r=e.startsWith("ev-know"),a=e.startsWith("ev-life"),n=r?"knowledge":s?"memory":a?"life":"grounded-record",l=r?`External lore from configured Knowledge Pack (ID: ${e})`:s?`Episodic conversation claim stored in SQLite memory (ID: ${e})`:`Grounded database record (ID: ${e})`;return(0,i.jsx)("div",{className:"evidence-source-card",children:(0,i.jsxs)("div",{className:"evidence-source-meta",children:[(0,i.jsxs)("span",{className:"evidence-provenance",children:["[",n,"]"]}),(0,i.jsxs)("span",{className:"evidence-id",children:["ID: ",e]}),(0,i.jsx)("div",{className:"evidence-actions",children:(0,i.jsxs)("button",{type:"button",className:"evidence-inspect-btn flex items-center gap-1",onClick:()=>ep({evidence_id:e,provenance:n,preview:l}),title:"Click to inspect evidence details",children:[(0,i.jsx)(b.WI,{size:10,className:"shrink-0"}),(0,i.jsx)("span",{children:"Inspect"})]})})]})},e||t)})})]})),e.memoryProposals&&e.memoryProposals.length>0&&(0,i.jsx)("div",{className:"memory-receipts",children:e.memoryProposals.map((t,s)=>{let r=t.proposal_id||t.id||`mprop-${s}`,n=(t.status||"pending").toLowerCase().replace(/_/g,"-"),l="pending"===n;return(0,i.jsxs)("div",{className:`memory-receipt status-${n}`,children:[(0,i.jsxs)("strong",{children:["Remember",t.claim_type?` (${t.claim_type.toLowerCase()})`:"",":"]})," ",(0,a.I)(t),(0,i.jsx)("div",{className:"receipt-actions",children:l?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{type:"button",onClick:()=>ek(e.id,r,"approve"),children:"Approve"}),(0,i.jsx)("button",{type:"button",onClick:()=>ek(e.id,r,"reject"),children:"Reject"})]}):(0,i.jsx)("span",{children:n.toUpperCase()})})]},r)})}),e.behavioralProposals&&e.behavioralProposals.length>0&&(0,i.jsx)("div",{className:"memory-receipts",children:e.behavioralProposals.map((t,s)=>{let r=t.directive_id||t.id||`bprop-${s}`,n=(t.status||"pending").toLowerCase().replace(/_/g,"-"),l="pending"===n;return(0,i.jsxs)("div",{className:`memory-receipt status-${n}`,children:[(0,i.jsxs)("strong",{children:["Runtime effect [",((t.knowledge_domain??t.domain)||"").toLowerCase()," ",(0,i.jsx)(b.fl,{size:11,className:"inline mx-0.5"})," ",((t.runtime_effect??t.memory_class)||"").toLowerCase(),"]:"]})," ",(0,a.P)(t),(0,i.jsx)("div",{className:"receipt-actions",children:l?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{type:"button",onClick:()=>eC(e.id,r,"approve"),children:"Approve"}),(0,i.jsx)("button",{type:"button",onClick:()=>eC(e.id,r,"reject"),children:"Reject"})]}):(0,i.jsx)("span",{children:n.toUpperCase()})})]},r)})})]})]},e.id)}),P&&!F&&(!eN.length||eN[eN.length-1]?.role!=="assistant")&&(0,i.jsxs)("div",{className:"platform-message assistant thinking-message",children:[(0,i.jsx)("div",{className:"message-avatar",children:"S"}),(0,i.jsxs)("div",{className:"message-body",children:[(0,i.jsxs)("div",{className:"message-meta",children:[(0,i.jsx)("span",{children:"Siduri"}),(0,i.jsx)("span",{className:"thinking-label",children:"thinking"})]}),(0,i.jsxs)("div",{className:"thinking-dots",children:[(0,i.jsx)("i",{}),(0,i.jsx)("i",{}),(0,i.jsx)("i",{})]})]})]})]}),(0,i.jsxs)("form",{className:"platform-composer",onSubmit:ey,children:[(0,i.jsx)("textarea",{value:k,onChange:e=>C(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:"Message Siduri…",rows:1,maxLength:4e3,"aria-label":"Message Siduri"}),(0,i.jsxs)("div",{className:"composer-bottom",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,i.jsxs)("span",{className:"composer-session-info inline-flex items-center gap-1.5",children:["Private local session \xb7"," ",ew>0?(0,i.jsxs)("button",{type:"button",onClick:()=>{let e=[...eN].reverse().find(e=>"assistant"===e.role&&(e.evidenceIds&&e.evidenceIds.length>0||e.citations&&e.citations.length>0));if(e){ed(t=>({...t,[e.id]:!0}));let t=document.getElementById(`msg-${e.id}`);t&&t.scrollIntoView({behavior:"smooth",block:"center"})}},className:"composer-evidence-link-btn",title:"Click to view and inspect grounded evidence in the latest response",children:[(0,i.jsx)(b.WI,{size:12,className:"shrink-0"}),(0,i.jsxs)("span",{children:[ew," evidence link",1===ew?"":"s"]})]}):"No evidence attached"]}),"teach"===Y&&(0,i.jsxs)("div",{className:"flex items-center",children:[(0,i.jsx)("input",{type:"file",ref:eo,accept:".self,.yaml,.yml,.json",className:"hidden",onChange:eA,"aria-label":"Upload .self file"}),(0,i.jsxs)("button",{type:"button",onClick:()=>eo.current?.click(),className:"composer-attach-btn",title:"Attach .self file for Teach Mode review",children:[(0,i.jsx)("svg",{viewBox:"0 0 24 24",children:(0,i.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})}),(0,i.jsx)("span",{children:"Attach .self"})]})]})]}),P&&!k.trim()?(0,i.jsx)("button",{type:"button",onClick:function(){eb.current&&(eb.current.abort("user_stop"),eb.current=null),(0,v.Uo)("default","user_stop"),L(!1),A("online")},"aria-label":"Stop generation",title:"Stop generation",className:"composer-action-btn flex items-center justify-center",children:(0,i.jsx)(b.wF,{size:12})}):(0,i.jsx)("button",{type:"submit",disabled:!k.trim(),"aria-label":"Send message",className:"composer-action-btn flex items-center justify-center",children:(0,i.jsx)(b.qx,{size:14})})]})]})]})}),(0,i.jsx)("p",{className:"chat-disclaimer",children:"Siduri can be uncertain. Verify important details against the evidence."})]}),M&&(0,i.jsxs)("div",{className:"mobile-settings-overlay fixed inset-0 z-50 flex items-end sm:items-center justify-center p-0 sm:p-4 md:hidden",children:[(0,i.jsx)("div",{className:"mobile-settings-backdrop absolute inset-0 bg-black/70 backdrop-blur-sm transition-opacity",onClick:()=>B(!1),"aria-hidden":"true"}),(0,i.jsxs)("div",{className:"mobile-settings-sheet relative z-10 w-full max-w-lg bg-[#141418] border border-[var(--siduri-border-subtle)] rounded-t-2xl sm:rounded-2xl p-5 sm:p-6 shadow-2xl animate-slide-up flex flex-col gap-5 text-[#eee8df]",role:"dialog","aria-modal":"true","aria-label":"Chat preferences",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between pb-3 border-b border-[var(--siduri-border-subtle)]",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:"text-base font-semibold tracking-wide text-[#eee8df]",children:"Chat Preferences"}),(0,i.jsx)("span",{className:"text-[10px] font-mono uppercase px-2 py-0.5 rounded-full bg-[var(--siduri-tint-med)] text-[var(--siduri-ember-highlight)] border border-[var(--siduri-border-ember)]",children:"Mobile"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>B(!1),className:"w-8 h-8 rounded-lg flex items-center justify-center text-sm text-[var(--siduri-text-muted)] hover:text-[var(--siduri-text-primary)] hover:bg-white/5 transition-all cursor-pointer border border-transparent hover:border-[var(--siduri-border-subtle)]","aria-label":"Close preferences",children:(0,i.jsx)(b.US,{size:16})})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsx)("span",{className:"text-xs font-mono uppercase tracking-wider text-[var(--siduri-text-secondary)]",children:"Interaction Mode"}),(0,i.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{id:"hybrid",label:"Hybrid",desc:"Balanced (Default)"},{id:"teach",label:"Teach",desc:"Establishing teaching"},{id:"casual",label:"Casual",desc:"Zero drift chat"}].map(e=>{let t=Y===e.id;return(0,i.jsxs)("button",{type:"button",onClick:()=>W(e.id),className:`flex flex-col text-left p-2.5 rounded-xl border transition-all cursor-pointer ${t?"border-[var(--siduri-border-ember)] bg-[var(--siduri-tint-med)] text-[var(--siduri-ember-highlight)] ring-1 ring-[var(--siduri-border-ember)]":"border-[var(--siduri-border-subtle)] bg-[#19191e]/60 text-[var(--siduri-text-secondary)] hover:border-[var(--siduri-border-ember)]/50 hover:text-[var(--siduri-text-primary)]"}`,children:[(0,i.jsx)("span",{className:"text-xs font-bold",children:e.label}),(0,i.jsx)("span",{className:"text-[10px] opacity-75 mt-0.5 line-clamp-1",children:e.desc})]},e.id)})})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsx)("span",{className:"text-xs font-mono uppercase tracking-wider text-[var(--siduri-text-secondary)]",children:"Subtitle Translation"}),"off"!==q&&(0,i.jsxs)("span",{className:"text-[10px] font-mono uppercase text-[var(--siduri-ember-highlight)]",children:["Active: ",q.toUpperCase()]})]}),(0,i.jsxs)("div",{className:"flex flex-wrap gap-1.5 max-h-36 overflow-y-auto p-1 bg-[#101014] rounded-xl border border-[var(--siduri-border-subtle)]",children:[[{code:"off",label:"Off"},{code:"en",label:"English (EN)"},{code:"ja",label:"Japanese (JA)"},{code:"id",label:"Indonesian (ID)"},{code:"es",label:"Spanish (ES)"},{code:"zh",label:"Chinese (ZH)"},{code:"ko",label:"Korean (KO)"},{code:"fr",label:"French (FR)"},{code:"de",label:"German (DE)"}].map(e=>{let t=q===e.code;return(0,i.jsx)("button",{type:"button",onClick:()=>{Z(e.code);try{localStorage.setItem("siduri.chat.subtitleLanguage",e.code)}catch{}},className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-all cursor-pointer ${t?"bg-[var(--siduri-ember)] text-[#19151a] font-semibold shadow":"bg-[#18181d] text-[var(--siduri-text-secondary)] hover:text-[var(--siduri-text-primary)] hover:bg-[#222228]"}`,children:e.label},e.code)}),(0,i.jsx)("button",{type:"button",onClick:()=>{let e=prompt("Enter subtitle language code (e.g. it, ru, pt, vi):");if(e&&e.trim()){let t=e.trim().toLowerCase();Z(t);try{localStorage.setItem("siduri.chat.subtitleLanguage",t)}catch{}}},className:"px-3 py-1.5 rounded-lg text-xs font-medium bg-[#18181d] text-[var(--siduri-text-secondary)] hover:text-[var(--siduri-text-primary)] hover:bg-[#222228] cursor-pointer",children:"Custom..."})]})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between pt-1",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"text-xs font-semibold text-[#eee8df] block",children:"Live2D Avatar Presence"}),(0,i.jsx)("span",{className:"text-[11px] text-[var(--siduri-text-muted)]",children:"Render animated companion in chat"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>U(e=>!e),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors cursor-pointer ${F?"bg-[var(--siduri-ember)]":"bg-[#282830]"}`,role:"switch","aria-checked":F,children:(0,i.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${F?"translate-x-6":"translate-x-1"}`})})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-[var(--siduri-border-subtle)]",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:`status-light ${"online"===E?"online":""}`}),(0,i.jsx)("span",{className:"text-xs text-[var(--siduri-text-muted)] capitalize",children:E})]}),(0,i.jsx)("button",{type:"button",onClick:()=>B(!1),className:"px-4 py-2 rounded-xl bg-[var(--siduri-tint-med)] border border-[var(--siduri-border-ember)] text-[var(--siduri-ember-highlight)] text-xs font-semibold hover:bg-[var(--siduri-border-ember)] hover:text-[#19151a] transition-all cursor-pointer",children:"Done"})]})]})]}),eh&&(0,i.jsx)("div",{className:"evidence-modal-overlay",onClick:()=>ep(null),role:"dialog","aria-modal":"true",children:(0,i.jsx)("div",{className:"evidence-modal-content",onClick:e=>e.stopPropagation(),children:(e=eh.evidence_id||eh.evidenceId,t=eh.source_id||eh.sourceId,s=eh.document_id||eh.documentId,l=eh.chunk_id||eh.chunkId,c=(o=eh.provenance||t||"grounded-record").includes("knowledge")||o.includes("hub")||o.startsWith("@"),d=o.includes("memory")||e&&e.startsWith("ev-mem"),m=c?`Cryptographically verifiable citation from Knowledge Pack (${o}).`:d?"Episodic verifiable claim from local SQLite memory store.":"Cryptographically verifiable ground truth record.",(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"evidence-modal-header",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsxs)("span",{className:"evidence-chip",children:["[",o,"]"]}),(0,i.jsx)("span",{className:"text-sm font-semibold tracking-wide text-[#eee8df]",children:"Evidence Inspector"})]}),(0,i.jsx)("button",{type:"button",className:"evidence-modal-close flex items-center justify-center",onClick:()=>ep(null),"aria-label":"Close evidence details",children:(0,i.jsx)(b.US,{size:14})})]}),(0,i.jsxs)("div",{className:"evidence-modal-body",children:[e&&(0,i.jsxs)("div",{className:"evidence-field-group",children:[(0,i.jsx)("label",{children:"Evidence ID"}),(0,i.jsx)("div",{className:"evidence-code-box",children:e})]}),t&&(0,i.jsxs)("div",{className:"evidence-field-group",children:[(0,i.jsx)("label",{children:"Source / Provenance"}),(0,i.jsx)("div",{className:"evidence-code-box",children:t})]}),s&&(0,i.jsxs)("div",{className:"evidence-field-group",children:[(0,i.jsx)("label",{children:"Document ID"}),(0,i.jsx)("div",{className:"evidence-code-box",children:s})]}),l&&(0,i.jsxs)("div",{className:"evidence-field-group",children:[(0,i.jsx)("label",{children:"Chunk ID"}),(0,i.jsx)("div",{className:"evidence-code-box",children:l})]}),eh.revision&&(0,i.jsxs)("div",{className:"evidence-field-group",children:[(0,i.jsx)("label",{children:"Revision"}),(0,i.jsx)("div",{className:"evidence-code-box",children:eh.revision})]}),eh.locator&&(0,i.jsxs)("div",{className:"evidence-field-group",children:[(0,i.jsx)("label",{children:"Locator / Source URL"}),(0,i.jsxs)("div",{className:"evidence-locator-row",children:[(0,i.jsx)("code",{className:"evidence-code-box evidence-locator-code",children:eh.locator}),eh.locator.startsWith("http://")||eh.locator.startsWith("https://")?(0,i.jsxs)("a",{href:eh.locator,target:"_blank",rel:"noopener noreferrer",className:"evidence-modal-open-btn",children:["Open Source URL ",(0,i.jsx)(b.pT,{size:12,className:"inline ml-1"})]}):eh.locator.startsWith("lifedb:")?(0,i.jsxs)("a",{href:"/operator",className:"evidence-modal-open-btn",children:["Operator Console ",(0,i.jsx)(b.pT,{size:12,className:"inline ml-1"})]}):null]})]}),(0,i.jsxs)("div",{className:"evidence-field-group",children:[(0,i.jsx)("label",{children:"Grounded Excerpt / Content"}),(0,i.jsx)("div",{className:"evidence-quote-box",children:eh.preview||"No preview excerpt available for this evidence entry."})]})]}),(0,i.jsxs)("div",{className:"evidence-modal-footer",children:[(0,i.jsx)("span",{className:"text-[10px] font-mono text-[var(--siduri-text-muted)]",children:m}),(0,i.jsx)("button",{type:"button",className:"evidence-close-btn",onClick:()=>ep(null),children:"Close"})]})]}))})})]})}},7264:(e,t,s)=>{Promise.resolve().then(s.bind(s,2186))}},e=>{e.O(0,[426,461,136,358],()=>e(e.s=7264)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{2735:()=>{},3883:(e,s,_)=>{Promise.resolve().then(_.t.bind(_,2735,23))}},e=>{e.O(0,[290,461,136,358],()=>e(e.s=3883)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[939],{3449:(e,s,t)=>{"use strict";t.d(s,{default:()=>h});var a=t(2184),l=t(276),n=t(2914);function i({title:e,detail:s}){return(0,a.jsxs)("div",{className:"empty-state",children:[(0,a.jsx)("span",{className:"flex items-center justify-center","aria-hidden":"true",children:(0,a.jsx)(n.kN,{size:24})}),(0,a.jsx)("strong",{children:e}),(0,a.jsx)("p",{children:s})]})}var r=t(8839),c=t(3265);function o(e){return e?e.length>19?`${e.slice(0,9)}…${e.slice(-7)}`:e:"—"}function d(e){if(!e)return"—";let s=new Date(e);return Number.isNaN(s.valueOf())?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function h(){let[e,s]=(0,l.useState)("overview"),[t,i]=(0,l.useState)({label:"Orchestrator",value:"Checking",tone:"warn"}),[c,o]=(0,l.useState)({label:"Voice",value:"Checking",tone:"warn"}),[d,h]=(0,l.useState)({label:"OBS capture",value:"Checking",tone:"warn"}),[m,x]=(0,l.useState)(""),[j,p]=(0,l.useState)([]),[f,w]=(0,l.useState)([]),[k,S]=(0,l.useState)([]),[C,T]=(0,l.useState)([]),[O,D]=(0,l.useState)([]),[E,R]=(0,l.useState)([]),[$,A]=(0,l.useState)([]),[L,I]=(0,l.useState)([]),[P,_]=(0,l.useState)([]),[z,B]=(0,l.useState)([]),[M,U]=(0,l.useState)([]),[F,J]=(0,l.useState)("all"),[q,V]=(0,l.useState)("all"),[G,Q]=(0,l.useState)(""),[H,Y]=(0,l.useState)(!0),[Z,K]=(0,l.useState)(new Set),[W,X]=(0,l.useState)("{}"),[ee,es]=(0,l.useState)(""),[et,ea]=(0,l.useState)(null),[el,en]=(0,l.useState)(null),[ei,er]=(0,l.useState)(!1);async function ec(){try{let e=new URLSearchParams;"all"!==F&&e.set("level",F),"all"!==q&&e.set("subsystem",q),G.trim()&&e.set("q",G.trim()),e.set("limit","150");let s=await (0,r.Tt)(`/system/logs?${e.toString()}`);U(s.logs||[])}catch(e){console.error("Failed to load system logs:",e)}}async function eo(){if(window.confirm("Are you sure you want to clear all system logs?"))try{await (0,r.B2)("/system/logs/clear",{}),U([]),es("Logs cleared.")}catch(e){es(`Failed to clear logs: ${e.message}`)}}async function ed(){try{let[e,s,t]=await Promise.all([(0,r.Tt)("/health"),(0,r.Tt)("/version"),(0,r.Tt)("/ready")]);i({label:"Orchestrator",value:"ok"===e.status?"Online":e.status,detail:`v${s.version}`,tone:"ok"===e.status?"good":"warn"}),x(s.version),t.dependencies?.model_provider?.ready===!1&&i(e=>({...e,detail:"Model provider degraded",tone:"warn"}))}catch{i({label:"Orchestrator",value:"Offline",detail:"Start the Python API",tone:"bad"})}try{let e=await (0,r.Tt)("/voice/health");o({label:"Voice",value:e.healthy?"Ready":"Fallback",detail:e.provider,tone:e.healthy?"good":"warn"})}catch{o({label:"Voice",value:"Unavailable",detail:"Subtitle fallback",tone:"warn"})}try{let e=await (0,r.Tt)("/obs/health");h({label:"OBS capture",value:e.connected?"Connected":e.configured?"Disconnected":"Disabled",detail:e.source_name?`Source: ${e.source_name}`:"No source configured",tone:e.connected?"good":"warn"})}catch{h({label:"OBS capture",value:"Unavailable",tone:"bad"})}}async function eh(){try{let[e,s,t,a]=await Promise.all([(0,r.Tt)("/memory/proposals"),(0,r.Tt)("/memory"),(0,r.Tt)("/memory/claims"),(0,r.Tt)("/memory/behavioral")]);p((e.proposals??[]).filter(e=>"pending"===(e.status||"").toLowerCase().replace(/_/g,"-"))),S(s.items??[]),w(t.claims??[]),T(a.directives??[])}catch{p([]),S([]),w([]),T([])}}async function em(){try{let[e,s]=await Promise.all([(0,r.Tt)("/evidence"),(0,r.Tt)("/observations")]);D(e.results??[]),R(s.observations??[])}catch{D([]),R([])}}async function ex(){try{X(JSON.stringify(await (0,r.Tt)("/me"),null,2))}catch{X("Unable to load profile.")}}async function ej(){try{let[e,s,t,a]=await Promise.all([(0,r.Tt)("/knowledge/entities").catch(()=>({entities:[]})),(0,r.Tt)("/knowledge/events").catch(()=>({events:[]})),(0,r.Tt)("/knowledge/tasks").catch(()=>({tasks:[]})),(0,r.Tt)("/knowledge/schedule").catch(()=>({items:[]}))]);A(e?.entities||[]),I(s?.events||[]),_(t?.tasks||[]),B(a?.items||[])}catch{}}async function eu(e){er(!0);try{await (0,r.B2)("/knowledge/entities",e),es(`Saved entity "${e.name}"`),await ej()}catch(e){es(`Error saving entity: ${e.message}`)}finally{er(!1)}}async function ep(e){er(!0);try{await (0,r.B2)("/knowledge/entities/delete",{id:e}),es("Entity deleted"),await ej()}catch(e){es(`Error deleting entity: ${e.message}`)}finally{er(!1)}}async function ev(e){er(!0);try{await (0,r.B2)("/knowledge/tasks",e),es(`Saved task "${e.title}"`),await ej()}catch(e){es(`Error saving task: ${e.message}`)}finally{er(!1)}}async function eb(e){let s="completed"===e.status?"todo":"completed";await ev({...e,status:s})}async function eg(e){er(!0);try{await (0,r.B2)("/knowledge/tasks/delete",{id:e}),es("Task deleted"),await ej()}catch(e){es(`Error deleting task: ${e.message}`)}finally{er(!1)}}async function eN(e){er(!0);try{await (0,r.B2)("/knowledge/events",e),es(`Logged event on stream "${e.stream}"`),await ej()}catch(e){es(`Error logging event: ${e.message}`)}finally{er(!1)}}async function ey(e){er(!0);try{await (0,r.B2)("/knowledge/schedule",e),es(`Saved schedule item "${e.title}"`),await ej()}catch(e){es(`Error saving schedule: ${e.message}`)}finally{er(!1)}}async function ef(e){er(!0);try{await (0,r.B2)("/knowledge/schedule/delete",{id:e}),es("Schedule item deleted"),await ej()}catch(e){es(`Error deleting schedule item: ${e.message}`)}finally{er(!1)}}async function ew(){er(!0);try{ea(await (0,r.B2)("/dev/mock-response"))}finally{er(!1)}}async function ek(){er(!0);try{let e=await (0,r.B2)("/dev/observe-and-respond");ea(e);let s="string"==typeof e?.metadata?.correlation_id?e.metadata.correlation_id:null;en(s)}finally{er(!1)}}async function eS(){if(el){er(!0);try{ea(await (0,r.B2)("/dev/approve-response",{correlation_id:el})),en(null)}finally{er(!1)}}}async function eC(e,s,t){await (0,r.vd)(e,{id:s.id||s.proposal_id,companionId:"default",...void 0===t?{}:{content:t}}),await eh()}async function eT(){await (0,r.vd)("/dev/mock-observation"),await em()}async function eO(){if(window.confirm("Are you sure you want to completely reset all memory? This action cannot be undone.")){er(!0);try{await (0,r.B2)("/dev/memory/reset"),await eh(),es("Memory has been completely reset.")}catch(e){es(String(e))}finally{er(!1)}}}return(0,l.useEffect)(()=>{ed(),eh(),ej(),em(),ex()},[]),(0,a.jsxs)("main",{className:"console-app",children:[(0,a.jsxs)("aside",{className:"console-sidebar",children:[(0,a.jsxs)("div",{className:"console-sidebar-header flex items-center justify-between w-full",children:[(0,a.jsxs)("a",{className:"console-brand",href:"/chat",children:[(0,a.jsx)("span",{className:"console-brand-mark",children:"S"}),(0,a.jsx)("span",{children:"SIDURI"})]}),(0,a.jsxs)("a",{href:"/chat",className:"console-mobile-back inline-flex items-center gap-1","aria-label":"Back to chat",children:[(0,a.jsx)(n.A6,{size:12}),"Chat"]})]}),(0,a.jsxs)("div",{className:"console-context",children:[(0,a.jsx)("span",{className:"console-context-dot"}),"Operator workspace"]}),(0,a.jsx)("nav",{className:"console-nav","aria-label":"Console sections",children:["overview","memory","lifedb","evidence","logs","settings"].map(t=>(0,a.jsxs)("button",{className:e===t?"active":"",onClick:()=>s(t),children:[(0,a.jsx)("span",{className:`nav-glyph nav-${t}`}),"lifedb"===t?"Life DB":t[0].toUpperCase()+t.slice(1)]},t))}),(0,a.jsxs)("div",{className:"console-sidebar-bottom",children:[(0,a.jsxs)("a",{href:"/chat",className:"inline-flex items-center gap-1",children:[(0,a.jsx)(n.A6,{size:12}),"Private chat"]}),(0,a.jsx)("span",{children:"Local operator surface"})]})]}),(0,a.jsxs)("section",{className:"console-main",children:[(0,a.jsxs)("header",{className:"console-topbar",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"console-eyebrow",children:"SIDURI / OPERATOR"}),(0,a.jsx)("h1",{children:"overview"===e?"Control room":"lifedb"===e?"Life Database (Sovereign Reality)":"logs"===e?"System Logs & Diagnostics":e[0].toUpperCase()+e.slice(1)})]}),(0,a.jsxs)("div",{className:"console-top-actions",children:[(0,a.jsxs)("a",{href:"/chat",className:"console-back-link inline-flex items-center gap-1",title:"Return to Private Chat",children:[(0,a.jsx)(n.A6,{size:12}),"Chat"]}),(0,a.jsxs)("span",{className:"console-version",children:["v",m||"—"]}),(0,a.jsx)("button",{type:"button",className:"console-refresh",onClick:()=>{ed(),eh(),ej(),em(),"logs"===e&&ec()},"aria-label":"Refresh dashboard",children:(0,a.jsx)(n.fN,{size:14})})]})]}),ee&&(0,a.jsx)("div",{className:"console-notice",children:ee}),"overview"===e&&(0,a.jsx)(b,{health:t,voice:c,obs:d,proposals:j,responseJson:et,pendingCorrelationId:el,busy:ei,onTrigger:ew,onObserve:ek,onApprove:eS,onNavigate:s}),"memory"===e&&(0,a.jsx)(u,{proposals:j,claims:f,items:k,directives:C,onAction:eC,onRefresh:eh}),"lifedb"===e&&(0,a.jsx)(g,{entities:$,events:L,tasks:P,schedule:z,busy:ei,onSaveEntity:eu,onDeleteEntity:ep,onSaveTask:ev,onToggleTask:eb,onDeleteTask:eg,onAddEvent:eN,onSaveSchedule:ey,onDeleteSchedule:ef,onRefresh:ej}),"evidence"===e&&(0,a.jsx)(v,{results:O,observations:E,onCreate:eT,onRefresh:em}),"logs"===e&&(0,a.jsx)(N,{logs:M,filterLevel:F,filterSubsystem:q,searchQuery:G,autoRefresh:H,expandedIds:Z,onToggleExpand:function(e){K(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onChangeLevel:J,onChangeSubsystem:V,onChangeSearch:Q,onToggleAutoRefresh:()=>Y(e=>!e),onRefresh:ec,onClear:eo,onExport:function(){try{let e=new Blob([JSON.stringify(M,null,2)],{type:"application/json"}),s=URL.createObjectURL(e),t=document.createElement("a");t.href=s,t.download=`siduri-logs-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,t.click(),URL.revokeObjectURL(s)}catch(e){es(`Export failed: ${e.message}`)}}}),"settings"===e&&(0,a.jsx)(y,{onResetMemory:eO,disabled:ei})]})]})}function m({status:e}){return(0,a.jsxs)("article",{className:"status-card",children:[(0,a.jsxs)("div",{className:"status-card-top",children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("i",{className:`status-dot ${e.tone??"warn"}`})]}),(0,a.jsx)("strong",{children:e.value}),(0,a.jsx)("small",{children:e.detail??"—"})]})}function x({title:e,action:s,onClick:t}){return(0,a.jsxs)("div",{className:"panel-header",children:[(0,a.jsx)("h2",{children:e}),s&&(0,a.jsxs)("button",{onClick:t,className:"inline-flex items-center gap-1",children:[s," ",(0,a.jsx)(n.fl,{size:12})]})]})}function j({label:e,count:s,tone:t}){return(0,a.jsxs)("div",{className:"queue-row",children:[(0,a.jsx)("span",{children:e}),(0,a.jsx)("b",{className:`queue-count ${t}`,children:s})]})}function u({proposals:e,claims:s,items:t,directives:l,onAction:n,onRefresh:h}){async function m(e,s){await (0,r.B2)(e,{id:s,companionId:"default"}),await h()}return(0,a.jsxs)("div",{className:"console-view",children:[(0,a.jsxs)("div",{className:"view-intro",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"console-eyebrow",children:"COMPANION MEMORY"}),(0,a.jsx)("h2",{children:"Review candidates before they become facts."}),(0,a.jsx)("p",{children:"Every candidate stays isolated until you explicitly approve it."})]}),(0,a.jsxs)("span",{className:"count-badge",children:[e.length," pending"]})]}),(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Pending memory"}),(0,a.jsx)("span",{children:"Local approval queue"})]}),e.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Candidate"}),(0,a.jsx)("th",{children:"Provenance"}),(0,a.jsx)("th",{children:"Sensitivity"}),(0,a.jsx)("th",{children:"Action"})]})}),(0,a.jsx)("tbody",{children:e.map(e=>(0,a.jsx)(p,{item:e,onAction:n},e.id||e.proposal_id))})]})}):(0,a.jsx)(i,{title:"No pending candidates",detail:"Siduri memory suggestions will appear here for review."})]}),(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Behavioral Directives"}),(0,a.jsx)("span",{children:"Active behaviors and learned relationships"})]}),l.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Directive"}),(0,a.jsx)("th",{children:"Scope & Activation"}),(0,a.jsx)("th",{children:"Class"}),(0,a.jsx)("th",{children:"Status"}),(0,a.jsx)("th",{children:"Actions"})]})}),(0,a.jsx)("tbody",{children:l.map(e=>{let s=e.id||e.directive_id||"";return(0,a.jsxs)("tr",{children:[(0,a.jsxs)("td",{children:[(0,a.jsx)("strong",{children:(0,c.P)(e)}),(0,a.jsxs)("details",{className:"row-details",children:[(0,a.jsx)("summary",{children:o(s)}),(0,a.jsx)("pre",{children:JSON.stringify(e,null,2)})]})]}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag",children:e.activation||"active"})}),(0,a.jsx)("td",{children:(0,a.jsxs)("span",{className:"tag",children:[e.domain||e.category||"general"," / ",e.memory_class||e.category||"directive"]})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:`tag status-${(e.status||"").toLowerCase().replace(/_/g,"-")}`,children:e.status})}),(0,a.jsx)("td",{children:(0,a.jsxs)("div",{className:"table-actions",children:["pending"===(e.status||"").toLowerCase()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"tiny-button approve-button",onClick:()=>void m("/memory/behavioral/approve",s),children:"Approve"}),(0,a.jsx)("button",{className:"tiny-button danger-button",onClick:()=>void m("/memory/behavioral/reject",s),children:"Reject"})]}),("active"===(e.status||"").toLowerCase()||"confirmed"===(e.status||"").toLowerCase())&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"tiny-button danger-button",onClick:()=>void m("/memory/behavioral/revoke",s),children:"Revoke"}),"disabled"!==e.activation&&(0,a.jsx)("button",{className:"tiny-button",onClick:()=>void m("/memory/behavioral/disable",s),children:"Disable"})]})]})})]},s)})})]})}):(0,a.jsx)(i,{title:"No behavioral directives",detail:"Behavioral rules taught in private chat will appear here."})]}),(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Structured Claims"}),(0,a.jsx)("span",{children:"Queryable personal and game knowledge"})]}),s.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Subject"}),(0,a.jsx)("th",{children:"Predicate"}),(0,a.jsx)("th",{children:"Value"}),(0,a.jsx)("th",{children:"Status"})]})}),(0,a.jsx)("tbody",{children:s.slice().reverse().map(e=>{let s=e.id||e.claim_id||"";return(0,a.jsxs)("tr",{children:[(0,a.jsxs)("td",{children:[(0,a.jsx)("strong",{children:e.subject}),(0,a.jsxs)("details",{className:"row-details",children:[(0,a.jsx)("summary",{children:o(s)}),(0,a.jsx)("pre",{children:JSON.stringify(e,null,2)})]})]}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag",children:e.predicate})}),(0,a.jsx)("td",{children:e.value}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:`tag status-${(e.status||"").toLowerCase().replace(/_/g,"-")}`,children:e.status})})]},s)})})]})}):(0,a.jsx)(i,{title:"No structured claims",detail:"Approved teachings will become queryable claims here."})]}),(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Compatibility Memory Items"}),(0,a.jsx)("span",{children:"Legacy text projection"})]}),t.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Fact"}),(0,a.jsx)("th",{children:"Provenance"}),(0,a.jsx)("th",{children:"Sensitivity"}),(0,a.jsx)("th",{children:"Created"})]})}),(0,a.jsx)("tbody",{children:t.slice().reverse().map(e=>{let s=e.id||e.memory_id||"",t=e.content||(e.subject&&e.predicate?`${e.subject} ${e.predicate} ${e.value}`:e.value||"—");return(0,a.jsxs)("tr",{children:[(0,a.jsxs)("td",{children:[(0,a.jsx)("strong",{children:t}),(0,a.jsxs)("details",{className:"row-details",children:[(0,a.jsx)("summary",{children:o(s)}),(0,a.jsx)("pre",{children:JSON.stringify(e,null,2)})]})]}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag",children:e.provenance||"conversation"})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag",children:e.sensitivity||"normal"})}),(0,a.jsx)("td",{children:d(e.created_at||e.assertedAt)})]},s)})})]})}):(0,a.jsx)(i,{title:"No compatibility items",detail:"Legacy approved memory text will appear here."})]})]})}function p({item:e,onAction:s}){let t=e.id||e.proposal_id||"",[n,i]=(0,l.useState)(e.content||"");return(0,a.jsxs)("tr",{children:[(0,a.jsxs)("td",{children:[(0,a.jsx)("strong",{children:(0,c.I)(e)}),(0,a.jsxs)("details",{className:"row-details",children:[(0,a.jsxs)("summary",{children:["Edit raw record \xb7 ",o(t)]}),(0,a.jsx)("textarea",{className:"table-editor",value:n,onChange:e=>i(e.target.value),"aria-label":`Memory candidate ${t}`}),(0,a.jsx)("pre",{children:JSON.stringify(e,null,2)})]})]}),(0,a.jsx)("td",{children:e.provenance||"conversation"}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag",children:e.sensitivity||"normal"})}),(0,a.jsx)("td",{children:(0,a.jsxs)("div",{className:"table-actions",children:[(0,a.jsx)("button",{className:"tiny-button",onClick:()=>void s("/memory/proposals/update",e,n),children:"Save"}),(0,a.jsx)("button",{className:"tiny-button approve-button",onClick:()=>void s("/memory/proposals/approve",e),children:"Approve"}),(0,a.jsx)("button",{className:"tiny-button danger-button",onClick:()=>void s("/memory/proposals/reject",e),children:"Reject"})]})})]})}function v({results:e,observations:s,onCreate:t,onRefresh:l}){return(0,a.jsxs)("div",{className:"console-view",children:[(0,a.jsxs)("div",{className:"view-intro",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"console-eyebrow",children:"GROUNDING"}),(0,a.jsx)("h2",{children:"Evidence, with uncertainty intact."}),(0,a.jsx)("p",{children:"Inspect bounded citations and short-lived observations without exposing raw captures."})]}),(0,a.jsxs)("div",{className:"button-row",children:[(0,a.jsx)("button",{onClick:()=>void t(),children:"Create fixture"}),(0,a.jsx)("button",{className:"soft-button",onClick:()=>void l(),children:"Refresh"})]})]}),(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Knowledge Base Citations"}),(0,a.jsxs)("span",{children:[e.length," results"]})]}),e.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Source"}),(0,a.jsx)("th",{children:"Revision"}),(0,a.jsx)("th",{children:"Preview"}),(0,a.jsx)("th",{children:"Link"})]})}),(0,a.jsx)("tbody",{children:e.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsxs)("td",{children:[(0,a.jsx)("strong",{children:e.title}),(0,a.jsx)("small",{children:e.endpoint})]}),(0,a.jsx)("td",{children:e.revision||"—"}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag",children:e.preview?"Preview":"Published"})}),(0,a.jsx)("td",{children:(0,a.jsxs)("a",{className:"table-link inline-flex items-center gap-1",href:e.url,target:"_blank",rel:"noreferrer",children:["Open ",(0,a.jsx)(n.pT,{size:12})]})})]},e.url))})]})}):(0,a.jsx)(i,{title:"No evidence loaded",detail:"Create a fixture observation or refresh the source."})]}),(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Current observations"}),(0,a.jsx)("span",{children:"Raw frames are never shown here"})]}),s.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Observation"}),(0,a.jsx)("th",{children:"Captured"}),(0,a.jsx)("th",{children:"Expires"}),(0,a.jsx)("th",{children:"Readings"})]})}),(0,a.jsx)("tbody",{children:s.map((e,s)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:o(e.observation_id??"observation")}),(0,a.jsx)("td",{children:d(e.observed_at)}),(0,a.jsx)("td",{children:d(e.expires_at)}),(0,a.jsx)("td",{children:Array.isArray(e.readings)?e.readings.length:0})]},e.observation_id??s))})]})}):(0,a.jsx)(i,{title:"No active observations",detail:"Observations are bounded and expire automatically."})]})]})}function b({health:e,voice:s,obs:t,proposals:l,responseJson:i,pendingCorrelationId:r,busy:c,onTrigger:o,onObserve:d,onApprove:h,onNavigate:u}){return(0,a.jsxs)("div",{className:"console-view",children:[(0,a.jsxs)("div",{className:"status-grid",children:[(0,a.jsx)(m,{status:e}),(0,a.jsx)(m,{status:s}),(0,a.jsx)(m,{status:t})]}),(0,a.jsxs)("div",{className:"console-columns",children:[(0,a.jsxs)("section",{className:"console-panel approval-panel",children:[(0,a.jsx)(x,{title:"Response gate",action:"Review policy",onClick:()=>u("settings")}),(0,a.jsxs)("div",{className:"gate-row",children:[(0,a.jsx)("span",{className:`gate-icon flex items-center justify-center ${r?"pending":"ready"}`,children:r?"!":(0,a.jsx)(n.Sr,{size:14,className:"shrink-0"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:r?"Grounded response awaiting approval":"No response awaiting approval"}),(0,a.jsx)("p",{children:r?"Public output is held until you approve it.":"Local mock responses remain private."})]})]}),(0,a.jsxs)("div",{className:"button-row",children:[(0,a.jsx)("button",{onClick:()=>void o(),disabled:c,children:"Trigger mock response"}),(0,a.jsx)("button",{className:"soft-button",onClick:()=>void d(),disabled:c,children:"Observe and respond"}),r&&(0,a.jsx)("button",{className:"approve-button",onClick:()=>void h(),children:"Approve response"})]}),null!==i&&(0,a.jsxs)("details",{className:"technical-details",children:[(0,a.jsx)("summary",{children:"Technical details"}),(0,a.jsx)("pre",{children:JSON.stringify(i,null,2)})]})]}),(0,a.jsxs)("section",{className:"console-panel queue-panel",children:[(0,a.jsx)(x,{title:"Needs attention",action:"View memory",onClick:()=>u("memory")}),(0,a.jsx)(j,{label:"Memory proposals",count:l.length,tone:l.length?"warn":"quiet"})]})]}),(0,a.jsxs)("section",{className:"console-panel quick-panel",children:[(0,a.jsx)(x,{title:"Quick actions"}),(0,a.jsxs)("div",{className:"quick-actions",children:[(0,a.jsxs)("button",{onClick:()=>u("memory"),className:"inline-flex items-center justify-between",children:["Review memory ",(0,a.jsx)("span",{children:(0,a.jsx)(n.fl,{size:12})})]}),(0,a.jsxs)("button",{onClick:()=>u("lifedb"),className:"inline-flex items-center justify-between",children:["Inspect Life DB ",(0,a.jsx)("span",{children:(0,a.jsx)(n.fl,{size:12})})]}),(0,a.jsxs)("button",{onClick:()=>u("evidence"),className:"inline-flex items-center justify-between",children:["Inspect evidence ",(0,a.jsx)("span",{children:(0,a.jsx)(n.fl,{size:12})})]}),(0,a.jsxs)("button",{onClick:()=>u("settings"),className:"inline-flex items-center justify-between",children:["Identity & Directives ",(0,a.jsx)("span",{children:(0,a.jsx)(n.fl,{size:12})})]})]})]})]})}function g({entities:e,events:s,tasks:t,schedule:r,busy:c,onSaveEntity:o,onDeleteEntity:h,onSaveTask:m,onToggleTask:x,onDeleteTask:j,onAddEvent:u,onSaveSchedule:p,onDeleteSchedule:v,onRefresh:b}){let[N,y]=(0,l.useState)("tasks"),[f,w]=(0,l.useState)("all"),[k,S]=(0,l.useState)(!1),[C,T]=(0,l.useState)(!1),[O,D]=(0,l.useState)(!1),[E,R]=(0,l.useState)(!1),[$,A]=(0,l.useState)(""),[L,I]=(0,l.useState)("1"),[P,_]=(0,l.useState)("todo"),[z,B]=(0,l.useState)(""),[M,U]=(0,l.useState)(""),[F,J]=(0,l.useState)("item"),[q,V]=(0,l.useState)("general"),[G,Q]=(0,l.useState)("{}"),[H,Y]=(0,l.useState)("finance:expense"),[Z,K]=(0,l.useState)(""),[W,X]=(0,l.useState)("{}"),[ee,es]=(0,l.useState)(""),[et,ea]=(0,l.useState)(""),[el,en]=(0,l.useState)(""),ei=t.filter(e=>"all"===f||("active"===f?"completed"!==e.status&&"cancelled"!==e.status:e.status===f));return(0,a.jsxs)("div",{className:"console-view",children:[(0,a.jsxs)("div",{className:"view-intro",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"console-eyebrow",children:"LIFE DATABASE"}),(0,a.jsx)("h2",{children:"Sovereign Reality & Structured Primitives"}),(0,a.jsx)("p",{children:"Inspect and mutate your concrete user reality: actionable tasks, static entities, telemetry events, and temporal schedules."})]}),(0,a.jsx)("div",{className:"button-row",children:(0,a.jsx)("button",{className:"soft-button",onClick:()=>void b(),disabled:c,children:"Refresh"})})]}),(0,a.jsxs)("div",{className:"lifedb-nav",children:[(0,a.jsxs)("button",{className:`lifedb-tab-btn flex items-center gap-1.5 ${"tasks"===N?"active":""}`,onClick:()=>y("tasks"),children:[(0,a.jsx)(n.Sr,{size:13,className:"shrink-0"}),(0,a.jsxs)("span",{children:["Tasks & Goals (",t.length,")"]})]}),(0,a.jsxs)("button",{className:`lifedb-tab-btn flex items-center gap-1.5 ${"entities"===N?"active":""}`,onClick:()=>y("entities"),children:[(0,a.jsx)(n.qD,{size:13,className:"shrink-0"}),(0,a.jsxs)("span",{children:["Entities & Items (",e.length,")"]})]}),(0,a.jsxs)("button",{className:`lifedb-tab-btn flex items-center gap-1.5 ${"events"===N?"active":""}`,onClick:()=>y("events"),children:[(0,a.jsx)(n.O4,{size:13,className:"shrink-0"}),(0,a.jsxs)("span",{children:["Telemetry & Events (",s.length,")"]})]}),(0,a.jsxs)("button",{className:`lifedb-tab-btn flex items-center gap-1.5 ${"schedule"===N?"active":""}`,onClick:()=>y("schedule"),children:[(0,a.jsx)(n.CT,{size:13,className:"shrink-0"}),(0,a.jsxs)("span",{children:["Schedule & Calendar (",r.length,")"]})]})]}),"tasks"===N&&(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("strong",{children:"Actionable Tasks"}),(0,a.jsx)("div",{className:"flex gap-1",children:["all","active","todo","in_progress","completed"].map(e=>(0,a.jsx)("button",{className:`px-2 py-0.5 rounded text-[10px] ${f===e?"bg-amber-500/20 text-amber-300 font-semibold":"text-gray-400 hover:text-gray-200"}`,onClick:()=>w(e),children:e.toUpperCase()},e))})]}),(0,a.jsx)("button",{className:"tiny-button flex items-center gap-1",onClick:()=>S(!k),children:k?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.US,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"Close"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.c1,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"New Task"})]})})]}),k&&(0,a.jsxs)("div",{className:"lifedb-form-card m-4",children:[(0,a.jsx)("h4",{className:"text-xs font-semibold text-amber-300 mb-2",children:"Create New Task"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3 mb-3",children:[(0,a.jsx)("input",{type:"text",placeholder:"Task title (e.g. Order fresh coffee)",value:$,onChange:e=>A(e.target.value),className:"lifedb-input md:col-span-2"}),(0,a.jsxs)("select",{value:P,onChange:e=>_(e.target.value),className:"lifedb-input",children:[(0,a.jsx)("option",{value:"todo",children:"To-Do"}),(0,a.jsx)("option",{value:"in_progress",children:"In Progress"}),(0,a.jsx)("option",{value:"completed",children:"Completed"}),(0,a.jsx)("option",{value:"cancelled",children:"Cancelled"})]}),(0,a.jsx)("input",{type:"number",placeholder:"Priority (1-5)",value:L,onChange:e=>I(e.target.value),className:"lifedb-input"})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)("button",{className:"tiny-button",onClick:()=>S(!1),children:"Cancel"}),(0,a.jsx)("button",{className:"tiny-button approve-button",disabled:!$.trim()||c,onClick:async()=>{await m({title:$.trim(),status:P,priority:Number(L)||1,targetDate:z||void 0}),A(""),S(!1)},children:"Save Task"})]})]}),ei.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{style:{width:"40px"},children:"Done"}),(0,a.jsx)("th",{children:"Title"}),(0,a.jsx)("th",{children:"Status"}),(0,a.jsx)("th",{children:"Priority"}),(0,a.jsx)("th",{children:"Target Date"}),(0,a.jsx)("th",{children:"Updated"}),(0,a.jsx)("th",{children:"Actions"})]})}),(0,a.jsx)("tbody",{children:ei.map(e=>{let s="completed"===e.status;return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:(0,a.jsx)("input",{type:"checkbox",checked:s,onChange:()=>void x(e),className:"cursor-pointer accent-amber-500"})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:s?"line-through text-gray-500":"font-medium text-gray-200",children:e.title})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:`lifedb-pill lifedb-pill-${e.status||"todo"}`,children:e.status||"todo"})}),(0,a.jsx)("td",{children:(0,a.jsxs)("span",{className:"tag font-mono",children:["P",e.priority??1]})}),(0,a.jsx)("td",{children:d(e.targetDate)}),(0,a.jsx)("td",{children:d(e.updatedAt)}),(0,a.jsx)("td",{children:(0,a.jsxs)("div",{className:"table-actions",children:[(0,a.jsx)("button",{className:"tiny-button",onClick:()=>void x(e),children:s?"Reopen":"Complete"}),(0,a.jsx)("button",{className:"tiny-button danger-button",onClick:()=>void j(e.id),children:"Delete"})]})})]},e.id)})})]})}):(0,a.jsx)(i,{title:"No tasks match filter",detail:"Tasks learned through conversation or created above will appear here."})]}),"entities"===N&&(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Static Entities & Inventory"}),(0,a.jsx)("span",{children:"Nouns, devices, gaming items, and contacts"})]}),(0,a.jsx)("button",{className:"tiny-button flex items-center gap-1",onClick:()=>T(!C),children:C?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.US,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"Close"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.c1,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"New Entity"})]})})]}),C&&(0,a.jsxs)("div",{className:"lifedb-form-card m-4",children:[(0,a.jsx)("h4",{className:"text-xs font-semibold text-amber-300 mb-2",children:"Create New Entity"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 mb-3",children:[(0,a.jsx)("input",{type:"text",placeholder:"Entity Name (e.g. MacBook Pro M3)",value:M,onChange:e=>U(e.target.value),className:"lifedb-input"}),(0,a.jsx)("input",{type:"text",placeholder:"Type (e.g. hardware, contact, item)",value:F,onChange:e=>J(e.target.value),className:"lifedb-input"}),(0,a.jsx)("input",{type:"text",placeholder:"Domain (e.g. workstation, gaming, home)",value:q,onChange:e=>V(e.target.value),className:"lifedb-input"})]}),(0,a.jsx)("div",{className:"mb-3",children:(0,a.jsx)("textarea",{placeholder:'Properties JSON (e.g. {"model": "16-inch", "ram": "36GB"})',value:G,onChange:e=>Q(e.target.value),className:"lifedb-input w-full font-mono text-xs",rows:2})}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)("button",{className:"tiny-button",onClick:()=>T(!1),children:"Cancel"}),(0,a.jsx)("button",{className:"tiny-button approve-button",disabled:!M.trim()||c,onClick:async()=>{let e={};try{e=JSON.parse(G||"{}")}catch{}await o({name:M.trim(),entityType:F.trim()||"item",domain:q.trim()||"general",properties:e}),U(""),T(!1)},children:"Save Entity"})]})]}),e.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Name"}),(0,a.jsx)("th",{children:"Type"}),(0,a.jsx)("th",{children:"Domain"}),(0,a.jsx)("th",{children:"Properties"}),(0,a.jsx)("th",{children:"Updated"}),(0,a.jsx)("th",{children:"Actions"})]})}),(0,a.jsx)("tbody",{children:e.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-medium text-gray-200",children:e.name}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag font-mono",children:e.entityType})}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag",children:e.domain})}),(0,a.jsx)("td",{children:(0,a.jsx)("pre",{className:"text-[10px] text-gray-400 font-mono max-w-xs overflow-hidden text-ellipsis whitespace-nowrap",children:JSON.stringify(e.properties||{})})}),(0,a.jsx)("td",{children:d(e.updatedAt)}),(0,a.jsx)("td",{children:(0,a.jsx)("button",{className:"tiny-button danger-button",onClick:()=>void h(e.id),children:"Delete"})})]},e.id))})]})}):(0,a.jsx)(i,{title:"No entities recorded",detail:"Hardware, game characters, contacts, and items stored in Life DB will appear here."})]}),"events"===N&&(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Time-Series Events & Telemetry"}),(0,a.jsx)("span",{children:"Biometrics, finances, workout telemetry, and logs"})]}),(0,a.jsx)("button",{className:"tiny-button flex items-center gap-1",onClick:()=>D(!O),children:O?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.US,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"Close"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.c1,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"Log Event"})]})})]}),O&&(0,a.jsxs)("div",{className:"lifedb-form-card m-4",children:[(0,a.jsx)("h4",{className:"text-xs font-semibold text-amber-300 mb-2",children:"Log New Event"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-3",children:[(0,a.jsx)("input",{type:"text",placeholder:"Stream (e.g. finance:expense, health:heartrate)",value:H,onChange:e=>Y(e.target.value),className:"lifedb-input"}),(0,a.jsx)("input",{type:"number",step:"any",placeholder:"Metric Value (optional, e.g. 25.5)",value:Z,onChange:e=>K(e.target.value),className:"lifedb-input"})]}),(0,a.jsx)("div",{className:"mb-3",children:(0,a.jsx)("textarea",{placeholder:'Metadata JSON (optional, e.g. {"category": "coffee", "currency": "USD"})',value:W,onChange:e=>X(e.target.value),className:"lifedb-input w-full font-mono text-xs",rows:2})}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)("button",{className:"tiny-button",onClick:()=>D(!1),children:"Cancel"}),(0,a.jsx)("button",{className:"tiny-button approve-button",disabled:!H.trim()||c,onClick:async()=>{let e={};try{e=JSON.parse(W||"{}")}catch{}await u({stream:H.trim(),metricValue:""!==Z?Number(Z):void 0,metadata:e}),K(""),D(!1)},children:"Log Event"})]})]}),s.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Stream"}),(0,a.jsx)("th",{children:"Metric Value"}),(0,a.jsx)("th",{children:"Timestamp"}),(0,a.jsx)("th",{children:"Metadata"})]})}),(0,a.jsx)("tbody",{children:s.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-mono text-amber-400 text-xs",children:e.stream}),(0,a.jsx)("td",{className:"font-mono text-xs",children:void 0!==e.metricValue&&null!==e.metricValue?(0,a.jsx)("strong",{children:e.metricValue}):"—"}),(0,a.jsx)("td",{children:d(e.timestamp)}),(0,a.jsx)("td",{children:(0,a.jsx)("pre",{className:"text-[10px] text-gray-400 font-mono max-w-xs overflow-hidden text-ellipsis whitespace-nowrap",children:JSON.stringify(e.metadata||{})})})]},e.id))})]})}):(0,a.jsx)(i,{title:"No events logged",detail:"Telemetry and time-series events will be displayed here."})]}),"schedule"===N&&(0,a.jsxs)("section",{className:"console-panel table-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Calendar Commitments & Routines"}),(0,a.jsx)("span",{children:"Upcoming time intervals and schedule items"})]}),(0,a.jsx)("button",{className:"tiny-button flex items-center gap-1",onClick:()=>R(!E),children:E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.US,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"Close"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.c1,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"New Schedule Item"})]})})]}),E&&(0,a.jsxs)("div",{className:"lifedb-form-card m-4",children:[(0,a.jsx)("h4",{className:"text-xs font-semibold text-amber-300 mb-2",children:"Create Schedule Item"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 mb-3",children:[(0,a.jsx)("input",{type:"text",placeholder:"Title (e.g. Flight to Tokyo)",value:ee,onChange:e=>es(e.target.value),className:"lifedb-input"}),(0,a.jsx)("input",{type:"text",placeholder:"Start Time (e.g. 2026-09-20T14:00:00Z)",value:et,onChange:e=>ea(e.target.value),className:"lifedb-input"}),(0,a.jsx)("input",{type:"text",placeholder:"End Time (optional)",value:el,onChange:e=>en(e.target.value),className:"lifedb-input"})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)("button",{className:"tiny-button",onClick:()=>R(!1),children:"Cancel"}),(0,a.jsx)("button",{className:"tiny-button approve-button",disabled:!ee.trim()||!et.trim()||c,onClick:async()=>{await p({title:ee.trim(),startTime:et.trim(),endTime:el.trim()||void 0,status:"active"}),es(""),ea(""),en(""),R(!1)},children:"Save Schedule"})]})]}),r.length?(0,a.jsx)("div",{className:"data-table-wrap",children:(0,a.jsxs)("table",{className:"data-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Title"}),(0,a.jsx)("th",{children:"Start Time"}),(0,a.jsx)("th",{children:"End Time"}),(0,a.jsx)("th",{children:"Status"}),(0,a.jsx)("th",{children:"Actions"})]})}),(0,a.jsx)("tbody",{children:r.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-medium text-gray-200",children:e.title}),(0,a.jsx)("td",{children:d(e.startTime)}),(0,a.jsx)("td",{children:d(e.endTime)}),(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"tag font-mono",children:e.status||"active"})}),(0,a.jsx)("td",{children:(0,a.jsx)("button",{className:"tiny-button danger-button",onClick:()=>void v(e.id),children:"Delete"})})]},e.id))})]})}):(0,a.jsx)(i,{title:"No upcoming schedule items",detail:"Calendar commitments and schedule intervals will appear here."})]})]})}function N({logs:e,filterLevel:s,filterSubsystem:t,searchQuery:r,autoRefresh:c,expandedIds:o,onToggleExpand:d,onChangeLevel:h,onChangeSubsystem:m,onChangeSearch:x,onToggleAutoRefresh:j,onRefresh:u,onClear:p,onExport:v}){let b=(0,l.useMemo)(()=>e.filter(e=>"error"===e.level).length,[e]),g=(0,l.useMemo)(()=>e.filter(e=>"warn"===e.level).length,[e]);return(0,a.jsxs)("div",{className:"console-view",children:[(0,a.jsxs)("div",{className:"view-intro",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"console-eyebrow",children:"DIAGNOSTICS & AUDIT"}),(0,a.jsx)("h2",{children:"System Logs & Diagnostics"}),(0,a.jsx)("p",{children:"Real-time audit trail of perception cycles, LLM calls, Truth Gate decisions, and tool executions."})]}),(0,a.jsxs)("div",{className:"flex gap-2 items-center flex-wrap",children:[(0,a.jsxs)("button",{className:"tiny-button flex items-center gap-1",onClick:v,title:"Download current logs as JSON",children:[(0,a.jsx)(n.s3,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"Export JSON"})]}),(0,a.jsxs)("button",{className:"tiny-button danger-button flex items-center gap-1",onClick:p,title:"Purge stored logs",children:[(0,a.jsx)(n.uc,{size:12,className:"shrink-0"}),(0,a.jsx)("span",{children:"Clear Logs"})]})]})]}),(0,a.jsxs)("section",{className:"console-panel",children:[(0,a.jsxs)("div",{className:"logs-toolbar",children:[(0,a.jsxs)("div",{className:"logs-toolbar-left",children:[(0,a.jsx)("input",{type:"text",placeholder:"Search logs, metadata...",value:r,onChange:e=>x(e.target.value),className:"logs-search-input"}),(0,a.jsxs)("select",{value:t,onChange:e=>m(e.target.value),className:"logs-select",children:[(0,a.jsx)("option",{value:"all",children:"All Subsystems"}),(0,a.jsx)("option",{value:"perception",children:"Perception"}),(0,a.jsx)("option",{value:"brain",children:"Brain / LLM"}),(0,a.jsx)("option",{value:"truth_gate",children:"Truth Gate"}),(0,a.jsx)("option",{value:"memory",children:"Memory"}),(0,a.jsx)("option",{value:"hands",children:"Hands / Tools"}),(0,a.jsx)("option",{value:"server",children:"Server"})]})]}),(0,a.jsxs)("div",{className:"logs-toolbar-right",children:[(0,a.jsx)("div",{className:"logs-level-pills",children:["all","error","warn","info","debug"].map(e=>(0,a.jsxs)("button",{type:"button",className:`log-pill ${s===e?"active":""} ${"error"===e&&b>0?"has-errors":""}`,onClick:()=>h(e),children:[e.toUpperCase(),"error"===e&&b>0&&(0,a.jsx)("span",{className:"pill-badge",children:b}),"warn"===e&&g>0&&(0,a.jsx)("span",{className:"pill-badge",children:g})]},e))}),(0,a.jsxs)("label",{className:"logs-live-toggle",children:[(0,a.jsx)("input",{type:"checkbox",checked:c,onChange:j}),(0,a.jsx)("span",{className:`live-indicator ${c?"active":""}`}),"Live (3s)"]}),(0,a.jsx)("button",{type:"button",className:"tiny-button inline-flex items-center justify-center",onClick:u,title:"Fetch latest logs",children:(0,a.jsx)(n.fN,{size:12})})]})]}),e.length>0?(0,a.jsx)("div",{className:"logs-container",children:e.map(e=>{let s=o.has(e.id),t=!!(e.metadata&&Object.keys(e.metadata).length>0),l=new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3});return(0,a.jsxs)("div",{className:`log-entry log-entry-${e.level} ${s?"expanded":""}`,children:[(0,a.jsxs)("div",{className:"log-header",onClick:()=>t&&d(e.id),style:{cursor:t?"pointer":"default"},children:[(0,a.jsx)("span",{className:"log-time",title:e.createdAt,children:l}),(0,a.jsx)("span",{className:`log-badge log-badge-${e.level}`,children:e.level.toUpperCase()}),(0,a.jsxs)("span",{className:"log-subsystem",children:["[",e.subsystem,"]"]}),(0,a.jsx)("span",{className:"log-message",children:e.message}),t&&(0,a.jsx)("span",{className:"log-expand-icon flex items-center justify-center",title:"Toggle JSON metadata",children:s?(0,a.jsx)(n.Mt,{size:12}):(0,a.jsx)(n.D3,{size:12})})]}),s&&t&&(0,a.jsxs)("div",{className:"log-metadata-card",children:[!!e.metadata?.stack&&(0,a.jsxs)("div",{className:"log-stack-trace",children:[(0,a.jsx)("strong",{children:"Stack trace:"}),(0,a.jsx)("pre",{children:String(e.metadata?.stack)})]}),(0,a.jsxs)("div",{className:"log-json-block",children:[(0,a.jsx)("strong",{children:"Payload / Metadata:"}),(0,a.jsx)("pre",{children:JSON.stringify(e.metadata,null,2)})]})]})]},e.id)})}):(0,a.jsx)(i,{title:"No system logs found",detail:r||"all"!==s||"all"!==t?"No logs match the current filters. Try resetting the search or level filter.":"No logs have been recorded yet. New perception cycles, Truth Gate decisions, and model queries will appear here."})]})]})}function y({onResetMemory:e,disabled:s}){return(0,a.jsxs)("div",{className:"console-view",children:[(0,a.jsx)("div",{className:"view-intro",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"console-eyebrow",children:"RUNTIME IDENTITY"}),(0,a.jsx)("h2",{children:"Companion Identity & Directives"}),(0,a.jsx)("p",{children:"Identity and behavioral preferences are governed dynamically through conversational teaching and reviewed in the Memory tab."})]})}),(0,a.jsxs)("section",{className:"console-panel profile-panel",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Identity Directives"}),(0,a.jsx)("span",{children:"Governed Memory Model"})]}),(0,a.jsx)(i,{title:"Dynamic identity active",detail:"Siduri establishes preferences and boundaries dynamically through conversation. Use the Private Chat to teach preferences, and the Memory tab to approve or revoke directives."})]}),(0,a.jsxs)("section",{className:"console-panel profile-panel mt-6",children:[(0,a.jsxs)("div",{className:"table-toolbar",children:[(0,a.jsx)("strong",{children:"Danger Zone"}),(0,a.jsx)("span",{children:"Irreversible actions"})]}),(0,a.jsxs)("div",{className:"p-6 bg-red-900/20 border border-red-500/20 rounded-lg",children:[(0,a.jsx)("h3",{className:"text-red-400 font-medium mb-2",children:"Reset All Memory"}),(0,a.jsx)("p",{className:"text-sm text-gray-400 mb-4",children:"This will permanently delete all memory items, proposals, revisions, and claims from the database. The companion will forget all approved claims, directives, and proposals."}),(0,a.jsx)("button",{className:"bg-red-500/10 text-red-400 border border-red-500/50 hover:bg-red-500/20 px-4 py-2 rounded-md font-medium transition-colors",onClick:()=>void e(),disabled:s,children:"Reset Memory"})]})]})]})}},5064:(e,s,t)=>{Promise.resolve().then(t.bind(t,3449))}},e=>{e.O(0,[426,461,136,358],()=>e(e.s=5064)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1872:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={DecodeError:function(){return g},MiddlewareNotFoundError:function(){return _},MissingStaticPage:function(){return v},NormalizeError:function(){return m},PageNotFoundError:function(){return b},SP:function(){return h},ST:function(){return y},WEB_VITALS:function(){return o},execOnce:function(){return u},getDisplayName:function(){return s},getLocationOrigin:function(){return l},getURL:function(){return c},isAbsoluteUrl:function(){return i},isResSent:function(){return f},loadGetInitialProps:function(){return d},normalizeRepeatedSlashes:function(){return p},stringifyError:function(){return P}};for(var n in r)Object.defineProperty(t,n,{enumerable:!0,get:r[n]});let o=["CLS","FCP","FID","INP","LCP","TTFB"];function u(e){let t,r=!1;return(...n)=>(r||(r=!0,t=e(...n)),t)}let a=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,i=e=>{let t=e.charCodeAt(0);return!!(t>=65&&t<=90||t>=97&&t<=122)&&a.test(e)};function l(){let{protocol:e,hostname:t,port:r}=window.location;return`${e}//${t}${r?":"+r:""}`}function c(){let{href:e}=window.location,t=l();return e.substring(t.length)}function s(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function f(e){return e.finished||e.headersSent}function p(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function d(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await d(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&f(r))return n;if(!n)throw Object.defineProperty(Error(`"${s(e)}.getInitialProps()" should resolve to an object. But found "${n}" instead.`),"__NEXT_ERROR_CODE",{value:"E1025",enumerable:!1,configurable:!0});return n}let h="u">typeof performance,y=h&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class g extends Error{}class m extends Error{}class b extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class v extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class _ extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function P(e){return JSON.stringify({message:e.message,stack:e.stack})}},2926:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={assign:function(){return i},searchParamsToUrlQuery:function(){return o},urlQueryToSearchParams:function(){return a}};for(var n in r)Object.defineProperty(t,n,{enumerable:!0,get:r[n]});function o(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function u(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function a(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))if(Array.isArray(n))for(let e of n)t.append(r,u(e));else t.set(r,u(n));return t}function i(e,...t){for(let r of t){for(let t of r.keys())e.delete(t);for(let[t,n]of r.entries())e.append(t,n)}return e}},4103:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isLocalURL",{enumerable:!0,get:function(){return u}});let n=r(1872),o=r(4233);function u(e){if(!(0,n.isAbsoluteUrl)(e))return!0;try{let t=(0,n.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,o.hasBasePath)(r.pathname)}catch(e){return!1}}},6571:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useMergedRef",{enumerable:!0,get:function(){return o}});let n=r(276);function o(e,t){let r=(0,n.useRef)(null),o=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=o.current;t&&(o.current=null,t())}else e&&(r.current=u(e,n)),t&&(o.current=u(t,n))},[e,t])}function u(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7443:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={default:function(){return m},useLinkStatus:function(){return v}};for(var o in n)Object.defineProperty(t,o,{enumerable:!0,get:n[o]});let u=r(9588),a=r(2184),i=u._(r(276)),l=r(7982),c=r(6280),s=r(6571),f=r(1872),p=r(706),d=r(351),h=r(1459),y=r(4103),g=r(6502);function m(e){var t;let n,o,u,[m,v]=(0,i.useOptimistic)(h.IDLE_LINK_STATUS),_=(0,i.useRef)(null),{href:P,as:E,children:O,prefetch:S=null,passHref:j,replace:C,shallow:N,scroll:T,onClick:R,onMouseEnter:L,onTouchStart:k,legacyBehavior:x=!1,onNavigate:w,transitionTypes:A,ref:M,unstable_dynamicOnHover:$,...I}=e;n=O,x&&("string"==typeof n||"number"==typeof n)&&(n=(0,a.jsx)("a",{children:n}));let U=i.default.useContext(c.AppRouterContext),F=!1!==S,D=!1===S?"none":!0===S?"full":"auto",B="none"!==D?"auto"===D?g.FetchStrategy.PPR:g.FetchStrategy.Full:g.FetchStrategy.PPR,K="string"==typeof(t=E||P)?t:(0,l.formatUrl)(t);if(x){if(n?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});o=i.default.Children.only(n)}let z=x?o&&"object"==typeof o&&o.ref:M,Q,W=i.default.useCallback(e=>(null!==U&&(_.current=(0,h.mountLinkInstance)(e,K,U,B,F,v,Q)),()=>{_.current&&((0,h.unmountLinkForCurrentNavigation)(_.current),_.current=null),(0,h.unmountPrefetchableInstance)(e)}),[F,K,U,B,v,Q]),X={ref:(0,s.useMergedRef)(W,z),onClick(e){x||"function"!=typeof R||R(e),x&&o.props&&"function"==typeof o.props.onClick&&o.props.onClick(e),!U||e.defaultPrevented||function(e,t,n,o,u,a,l,c="none"){{let s,{nodeName:f}=e.currentTarget;if("A"===f.toUpperCase()&&((s=e.currentTarget.getAttribute("target"))&&"_self"!==s||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which)||e.currentTarget.hasAttribute("download"))return;if(!(0,y.isLocalURL)(t)){o&&(e.preventDefault(),location.replace(t));return}if(e.preventDefault(),a){let e=!1;if(a({preventDefault:()=>{e=!0}}),e)return}let{dispatchNavigateAction:p}=r(2359);i.default.startTransition(()=>{p(t,o?"replace":"push",!1===u?d.ScrollBehavior.NoScroll:d.ScrollBehavior.Default,n.current,l,c)})}}(e,K,_,C,T,w,A,D)},onMouseEnter(e){x||"function"!=typeof L||L(e),x&&o.props&&"function"==typeof o.props.onMouseEnter&&o.props.onMouseEnter(e),U&&F&&(0,h.onNavigationIntent)(e.currentTarget,!0===$)},onTouchStart:function(e){x||"function"!=typeof k||k(e),x&&o.props&&"function"==typeof o.props.onTouchStart&&o.props.onTouchStart(e),U&&F&&(0,h.onNavigationIntent)(e.currentTarget,!0===$)}};return(0,f.isAbsoluteUrl)(K)?X.href=K:x&&!j&&("a"!==o.type||"href"in o.props)||(X.href=(0,p.addBasePath)(K)),u=x?i.default.cloneElement(o,X):(0,a.jsx)("a",{...I,...X,children:n}),(0,a.jsx)(b.Provider,{value:m,children:u})}let b=(0,i.createContext)(h.IDLE_LINK_STATUS),v=()=>(0,i.useContext)(b);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7982:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={formatUrl:function(){return i},formatWithValidation:function(){return c},urlObjectKeys:function(){return l}};for(var o in n)Object.defineProperty(t,o,{enumerable:!0,get:n[o]});let u=r(9588)._(r(2926)),a=/https?|ftp|gopher|file/;function i(e){let{auth:t,hostname:r}=e,n=e.protocol||"",o=e.pathname||"",i=e.hash||"",l=e.query||"",c=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?c=t+e.host:r&&(c=t+(~r.indexOf(":")?`[${r}]`:r),e.port&&(c+=":"+e.port)),l&&"object"==typeof l&&(l=String(u.urlQueryToSearchParams(l)));let s=e.search||l&&`?${l}`||"";return n&&!n.endsWith(":")&&(n+=":"),e.slashes||(!n||a.test(n))&&!1!==c?(c="//"+(c||""),o&&"/"!==o[0]&&(o="/"+o)):c||(c=""),i&&"#"!==i[0]&&(i="#"+i),s&&"?"!==s[0]&&(s="?"+s),o=o.replace(/[?#]/g,encodeURIComponent),s=s.replace("#","%23"),`${n}${c}${o}${s}${i}`}let l=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function c(e){return i(e)}},8831:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,7443,23))}},e=>{e.O(0,[461,136,358],()=>e(e.s=8831)),_N_E=e.O()}]);
|