@vxnus/siduri 2.0.28 → 2.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/builtin-manifests.js +2 -2
  2. package/dist/clean-machine-smoke.test.js +0 -1
  3. package/dist/discovery.test.js +2 -3
  4. package/dist/generator.js +2 -2
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/release-check.js +0 -1
  8. package/dist/web-dist/404/index.html +1 -1
  9. package/dist/web-dist/404.html +1 -1
  10. package/dist/web-dist/__next.__PAGE__.txt +29 -30
  11. package/dist/web-dist/__next._full.txt +23 -25
  12. package/dist/web-dist/__next._tree.txt +2 -2
  13. package/dist/web-dist/_next/static/LZCqJ-mUh49-lAiKiCill/_buildManifest.js +1 -0
  14. package/dist/web-dist/_next/static/chunks/136-1d10af93b770a1c8.js +52 -0
  15. package/dist/web-dist/_next/static/chunks/426-9f7f6e7fffd4c3c3.js +1 -0
  16. package/dist/web-dist/_next/static/chunks/563b947f-8e2871a2ab7cd91e.js +1 -0
  17. package/dist/web-dist/_next/static/chunks/app/_global-error/page-bce6d30fb2b1a3b0.js +1 -0
  18. package/dist/web-dist/_next/static/chunks/app/_not-found/page-34af109a364a684f.js +1 -0
  19. package/dist/web-dist/_next/static/chunks/app/chat/page-952ffd2ca033d626.js +30 -0
  20. package/dist/web-dist/_next/static/chunks/app/layout-c2b7ec35aaa926ae.js +1 -0
  21. package/dist/web-dist/_next/static/chunks/app/operator/page-03e3e0286b6acd25.js +1 -0
  22. package/dist/web-dist/_next/static/chunks/app/page-0ea61d6527029893.js +1 -0
  23. package/dist/web-dist/_next/static/chunks/framework-7afb7035d9872ea0.js +1 -0
  24. package/dist/web-dist/_next/static/chunks/main-8553b996986f1210.js +5 -0
  25. package/dist/web-dist/_next/static/chunks/main-app-600dfd311d48a1fb.js +1 -0
  26. package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/app-error-bce6d30fb2b1a3b0.js +1 -0
  27. package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/forbidden-bce6d30fb2b1a3b0.js +1 -0
  28. package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/global-error-777c8f036c92d838.js +1 -0
  29. package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/not-found-bce6d30fb2b1a3b0.js +1 -0
  30. package/dist/web-dist/_next/static/chunks/next/dist/client/components/builtin/unauthorized-bce6d30fb2b1a3b0.js +1 -0
  31. package/dist/web-dist/_next/static/chunks/webpack-f73cedc256be153e.js +1 -0
  32. package/dist/web-dist/_next/static/css/8ef96fc81e2b580f.css +1 -0
  33. package/dist/web-dist/_not-found/__next._full.txt +10 -10
  34. package/dist/web-dist/_not-found/__next._not-found.__PAGE__.txt +8 -8
  35. package/dist/web-dist/_not-found/__next._tree.txt +2 -2
  36. package/dist/web-dist/_not-found/index.html +1 -1
  37. package/dist/web-dist/_not-found/index.txt +10 -10
  38. package/dist/web-dist/chat/__next._full.txt +11 -11
  39. package/dist/web-dist/chat/__next._tree.txt +2 -2
  40. package/dist/web-dist/chat/__next.chat.__PAGE__.txt +9 -9
  41. package/dist/web-dist/chat/index.html +1 -1
  42. package/dist/web-dist/chat/index.txt +11 -11
  43. package/dist/web-dist/index.html +1 -1
  44. package/dist/web-dist/index.txt +23 -25
  45. package/dist/web-dist/operator/__next._full.txt +11 -11
  46. package/dist/web-dist/operator/__next._tree.txt +2 -2
  47. package/dist/web-dist/operator/__next.operator.__PAGE__.txt +9 -9
  48. package/dist/web-dist/operator/index.html +1 -1
  49. package/dist/web-dist/operator/index.txt +11 -11
  50. package/package.json +7 -7
  51. package/dist/clean-machine-e2e.test.d.ts +0 -1
  52. package/dist/clean-machine-e2e.test.js +0 -160
  53. package/dist/web-dist/_next/static/chunks/0jgw-jf26m0ui.js +0 -22
  54. package/dist/web-dist/_next/static/chunks/0kjm0c2yc9e9v.js +0 -30
  55. package/dist/web-dist/_next/static/chunks/0tdcnq1-n6kof.js +0 -31
  56. package/dist/web-dist/_next/static/chunks/12vwhiuvdy_i7.js +0 -1
  57. package/dist/web-dist/_next/static/chunks/189iv-jqs5v33.css +0 -1
  58. package/dist/web-dist/_next/static/chunks/2cm4q7l3sbg8o.js +0 -1
  59. package/dist/web-dist/_next/static/chunks/2dsfgoa225hpl.js +0 -1
  60. package/dist/web-dist/_next/static/chunks/2mno6yfdoee0x.js +0 -1
  61. package/dist/web-dist/_next/static/chunks/2t-xpv4so_9r5.js +0 -1
  62. package/dist/web-dist/_next/static/chunks/30a48dk5bjyhj.js +0 -1
  63. package/dist/web-dist/_next/static/chunks/turbopack-2hpygfb68u21h.js +0 -1
  64. package/dist/web-dist/_next/static/m2RsxdwRsuiacNYeJpYdw/_buildManifest.js +0 -11
  65. package/dist/web-dist/_next/static/m2RsxdwRsuiacNYeJpYdw/_clientMiddlewareManifest.js +0 -1
  66. package/dist/web-dist/_next/static/media/apple-icon.2g7-yefdphkmy.png +0 -0
  67. package/dist/web-dist/_next/static/media/favicon.3rlors1ui1gw9.ico +0 -0
  68. package/dist/web-dist/_next/static/media/icon.0580nb9h-ugue.svg +0 -4
  69. /package/dist/web-dist/_next/static/{m2RsxdwRsuiacNYeJpYdw → LZCqJ-mUh49-lAiKiCill}/_ssgManifest.js +0 -0
  70. /package/dist/web-dist/_next/static/chunks/{0cz1d0mv5g_q7.js → polyfills-42372ed130431b0a.js} +0 -0
@@ -1,30 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,12650,e=>{"use strict";var t=e.i(30696),r=e.i(64249),s=e.i(51523);function a({onSelectPrompt:e,className:r=""}){return(0,t.jsxs)("div",{className:`chat-empty-state ${r}`,"data-testid":"preferences-starter",children:[(0,t.jsx)("div",{className:"siduri-orb",children:"✦"}),(0,t.jsx)("h2",{children:"Teach Siduri your preferences."}),(0,t.jsx)("p",{children:"Choose a starting point, replace the blanks, and send it. Nothing becomes memory until you approve the receipt."}),(0,t.jsxs)("div",{className:"starter-prompts onboarding-prompts",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>e("Call me [preferred name]."),children:[(0,t.jsx)("span",{children:"Identity"}),"Preferred name or title"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>e("My timezone is [timezone] and my preferred language is [language]."),children:[(0,t.jsx)("span",{children:"Localization"}),"Timezone and language"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>e("My preferred response style is [concise / detailed / technical]."),children:[(0,t.jsx)("span",{children:"Response style"}),"Tone and verbosity"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>e("I am interested in [topics or domains of interest]."),children:[(0,t.jsx)("span",{children:"Knowledge"}),"Topics of interest"]})]}),(0,t.jsx)("p",{className:"onboarding-privacy",children:"Teach Siduri preferences explicitly. Information is stored in private memory only after you approve the receipt."})]})}function i(e){return"number"!=typeof e||isNaN(e)||e<0?0:e>1?1:e}class n{expression="neutral";action="idle";state="idle";speechId;lipSyncValue=0;reducedMotion=!1;actionStartTime=0;stateStartTime=0;lastUpdateTime=Date.now();constructor(e){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=i(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=i(e)}calculateFrameParameters(e=Date.now()){this.lastUpdateTime,this.lastUpdateTime=e;let t=this.reducedMotion?.2:(Math.sin(e/1800)+1)*.5,r=this.reducedMotion?0:2.5*Math.sin(e/2400),s=this.reducedMotion?0:1.8*Math.cos(e/3200),a=this.reducedMotion?0:1.2*Math.sin(e/4e3),n=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),o=(e-this.actionStartTime)/1e3,l=0,d=0,c=0,u=0;this.reducedMotion?"nod"===this.action?d=.5*n.angleY:"wave"===this.action?(l=.5*n.angleX,u=.5*n.bodyAngleX):"listen"===this.action&&(c=.5*n.angleZ,l=.5*n.angleX):"nod"===this.action?d=Math.sin(o*Math.PI*3)*n.angleY:"wave"===this.action?(c=Math.sin(o*Math.PI*2.4)*n.angleZ,l=n.angleX,u=n.bodyAngleX):"listen"===this.action?(c=n.angleZ,l=n.angleX):"talk"===this.action&&(d=2*Math.sin(4*o));let m=0;if("speaking"===this.state){let t=function(e,t){if("number"==typeof t&&!isNaN(t)&&t>0)return i(t);let r=e/1e3;return i(Math.max(0,.45*Math.sin(14*r)+.25*Math.sin(22*r)+.2*Math.sin(8*r)+.1))}(e,this.lipSyncValue);m=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:m,angleX:r+l,angleY:s+d,angleZ:a+c,bodyAngleX:u,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 o(e="/live2d/live2dcubismcore.min.js"){return window.Live2DCubismCore?window.Live2DCubismCore:new Promise((t,r)=>{let s=document.querySelector(`script[src="${e}"]`);if(s)return window.Live2DCubismCore?t(window.Live2DCubismCore):(s.addEventListener("load",()=>t(window.Live2DCubismCore)),void s.addEventListener("error",t=>r(Error(`Failed to load Cubism Core from ${e}: ${t}`))));let a=document.createElement("script");a.src=e,a.async=!0,a.onload=()=>{window.Live2DCubismCore?t(window.Live2DCubismCore):r(Error("Live2DCubismCore global not found after script load"))},a.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 s=document.createElement("script");s.src=e,s.async=!0,s.onload=()=>{window.Live2DCubismCore?t(window.Live2DCubismCore):r(Error("Live2DCubismCore global not found after fallback load"))},s.onerror=e=>r(Error(`Failed to load Cubism Core from both local and remote sources: ${e}`)),document.head.appendChild(s)},document.head.appendChild(a)})}async function l(e){let t=e.lastIndexOf("/"),r=-1!==t?e.slice(0,t+1):"",s=await fetch(e);if(!s.ok)throw Error(`Failed to fetch model manifest from ${e} (${s.status})`);let a=await s.json();if(!a.FileReferences||!a.FileReferences.Moc)throw Error(`Invalid model3.json: missing Moc file reference in ${e}`);let i=r+a.FileReferences.Moc,n=await fetch(i);if(!n.ok)throw Error(`Failed to fetch .moc3 file from ${i} (${n.status})`);let o=await n.arrayBuffer(),l=(a.FileReferences.Textures||[]).map(e=>r+e),d=await Promise.all(l.map(e=>new Promise((t,r)=>{let s=new Image;s.crossOrigin="anonymous",s.onload=()=>t(s),s.onerror=t=>r(Error(`Failed to load texture from ${e}`)),s.src=e}))),c=new Map;return a.FileReferences.Expressions&&a.FileReferences.Expressions.length>0&&await Promise.all(a.FileReferences.Expressions.map(async e=>{try{let t=r+e.File,s=await fetch(t);if(s.ok){let t=await s.json();c.set(e.File,t),e.Name&&c.set(e.Name,t)}}catch{}})),{model3:a,mocBuffer:o,textures:d,expressions:c,basePath:r}}let d=`
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
- `,c=`
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
- `,u=`
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 m(e,t,r){let s=e.createShader(t);if(!s)throw Error("Failed to create shader");if(e.shaderSource(s,r),e.compileShader(s),!e.getShaderParameter(s,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(s);throw e.deleteShader(s),Error(`Shader compilation error: ${t}`)}return s}class h{canvas;gl=null;program=null;maskProgram=null;vertexBuffer=null;uvBuffer=null;indexBuffer=null;aPositionLocation=-1;aTexCoordLocation=-1;uMatrixLocation=null;uTextureLocation=null;uOpacityLocation=null;maskAPositionLocation=-1;maskATexCoordLocation=-1;maskUMatrixLocation=null;maskUTextureLocation=null;textures=[];moc=null;model=null;core=null;paramIndices=new Map;isDisposed=!1;constructor(e){this.canvas=e}modelBounds={minX:-.39,maxX:.4,minY:-.98,maxY:.18,width:.79,height:1.16,centerX:.006,centerY:-.4};initialize(e,t){this.core=e;let r={alpha:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,antialias:!0,stencil:!0},s=this.canvas.getContext("webgl",r)||this.canvas.getContext("experimental-webgl",r)||this.canvas.getContext("webgl2",r);if(!s)throw Error("WebGL is not supported in this browser environment");this.gl=s;let a=m(s,s.VERTEX_SHADER,d),i=m(s,s.FRAGMENT_SHADER,c),n=s.createProgram();if(!n)throw Error("Failed to create WebGL program");if(s.attachShader(n,a),s.attachShader(n,i),s.linkProgram(n),!s.getProgramParameter(n,s.LINK_STATUS))throw Error(`Program link error: ${s.getProgramInfoLog(n)}`);this.program=n,this.aPositionLocation=s.getAttribLocation(n,"a_position"),this.aTexCoordLocation=s.getAttribLocation(n,"a_texCoord"),this.uMatrixLocation=s.getUniformLocation(n,"u_matrix"),this.uTextureLocation=s.getUniformLocation(n,"u_texture"),this.uOpacityLocation=s.getUniformLocation(n,"u_opacity");let o=m(s,s.FRAGMENT_SHADER,u),l=s.createProgram();if(!l)throw Error("Failed to create Mask WebGL program");if(s.attachShader(l,a),s.attachShader(l,o),s.linkProgram(l),!s.getProgramParameter(l,s.LINK_STATUS))throw Error(`Mask Program link error: ${s.getProgramInfoLog(l)}`);if(this.maskProgram=l,this.maskAPositionLocation=s.getAttribLocation(l,"a_position"),this.maskATexCoordLocation=s.getAttribLocation(l,"a_texCoord"),this.maskUMatrixLocation=s.getUniformLocation(l,"u_matrix"),this.maskUTextureLocation=s.getUniformLocation(l,"u_texture"),this.vertexBuffer=s.createBuffer(),this.uvBuffer=s.createBuffer(),this.indexBuffer=s.createBuffer(),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),this.textures=t.textures.map(e=>{let t=s.createTexture();if(!t)throw Error("Failed to create WebGL texture");return s.bindTexture(s.TEXTURE_2D,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.generateMipmap(s.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 h=this.model.parameters.ids;for(let e=0;e<h.length;e++)this.paramIndices.set(h[e],e);this.initializeNeutralMouth(),this.model.update(),this.calculateModelBounds()}initializeNeutralMouth(){this.model&&(this.setParamDirect("ParamMouthOpenY",0),this.setParamDirect("ParamMouthForm",0))}setParamDirect(e,t){let r=this.paramIndices.get(e);if(void 0!==r&&this.model){let e=this.model.parameters.minimumValues[r],s=this.model.parameters.maximumValues[r];this.model.parameters.values[r]=Math.max(e,Math.min(s,t))}}calculateModelBounds(){if(!this.model)return;let e=this.model.drawables,t=e.count,r=1/0,s=-1/0,a=1/0,i=-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],o=t[e+1];n<r&&(r=n),n>s&&(s=n),o<a&&(a=o),o>i&&(i=o)}}r!==1/0&&s!==-1/0&&a!==1/0&&i!==-1/0&&(this.modelBounds={minX:r,maxX:s,minY:a,maxY:i,width:s-r,height:i-a,centerX:(r+s)/2,centerY:(a+i)/2})}getModelBounds(){return{...this.modelBounds}}setParam(e,t,r=1){let s=this.paramIndices.get(e);if(void 0!==s&&this.model){let e=this.model.parameters.values[s],a=Math.max(this.model.parameters.minimumValues[s],Math.min(this.model.parameters.maximumValues[s],t));this.model.parameters.values[s]=e+(a-e)*r}}render(e,t=Date.now()){let r;if(this.isDisposed||!this.gl||!this.model||!this.program)return;let s=this.gl,a=this.canvas.width,i=this.canvas.height;if(0===a||0===i)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 o=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"===o?(this.setParam("Param10",1,.2),this.setParam("Param9",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)):"eyes_zetubou.exp3.json"===o?(this.setParam("Param9",1,.2),this.setParam("Param10",0,.15),this.setParam("Param11",0,.15),this.setParam("Param12",0,.15)):"hair_open.exp3.json"===o?(this.setParam("Param11",1,.2),this.setParam("Param10",0,.15),this.setParam("Param9",0,.15),this.setParam("Param12",0,.15)):"eye_color.exp3.json"===o?(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(),s.viewport(0,0,a,i),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),s.useProgram(this.program);let l=a/i,d=this.modelBounds.width,c=this.modelBounds.height,u=this.modelBounds.centerX,m=this.modelBounds.centerY,h=(r=l>=d/c?1.84/c:1.84/d*l)/l,p=new Float32Array([h,0,0,0,0,r,0,0,0,0,1,0,-u*h,-m*r,0,1]);s.uniformMatrix4fv(this.uMatrixLocation,!1,p),s.uniform1i(this.uTextureLocation,0);let x=this.model.drawables,f=x.count,b=x.renderOrders,g=[];for(let e=0;e<f;e++)g.push(e);g.sort((e,t)=>b[e]-b[t]),s.enableVertexAttribArray(this.aPositionLocation),s.enableVertexAttribArray(this.aTexCoordLocation);let v=(e,t)=>{let r=void 0!==t?t:x.opacities[e];if(r<=.001)return;let a=x.textureIndices[e],i=this.textures[a];if(!i)return;s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,i),s.uniform1f(this.uOpacityLocation,r);let n=x.vertexPositions[e];s.bindBuffer(s.ARRAY_BUFFER,this.vertexBuffer),s.bufferData(s.ARRAY_BUFFER,n,s.DYNAMIC_DRAW),s.vertexAttribPointer(this.aPositionLocation,2,s.FLOAT,!1,0,0);let o=x.vertexUvs[e];s.bindBuffer(s.ARRAY_BUFFER,this.uvBuffer),s.bufferData(s.ARRAY_BUFFER,o,s.DYNAMIC_DRAW),s.vertexAttribPointer(this.aTexCoordLocation,2,s.FLOAT,!1,0,0);let l=x.indices[e];s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.indexBuffer),s.bufferData(s.ELEMENT_ARRAY_BUFFER,l,s.DYNAMIC_DRAW),s.drawElements(s.TRIANGLES,l.length,s.UNSIGNED_SHORT,0)},y=e=>{if(!this.maskProgram)return;s.useProgram(this.maskProgram),s.uniformMatrix4fv(this.maskUMatrixLocation,!1,p),s.uniform1i(this.maskUTextureLocation,0),s.enableVertexAttribArray(this.maskAPositionLocation),s.enableVertexAttribArray(this.maskATexCoordLocation);let t=x.textureIndices[e],r=this.textures[t];if(!r)return;s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,r);let a=x.vertexPositions[e];s.bindBuffer(s.ARRAY_BUFFER,this.vertexBuffer),s.bufferData(s.ARRAY_BUFFER,a,s.DYNAMIC_DRAW),s.vertexAttribPointer(this.maskAPositionLocation,2,s.FLOAT,!1,0,0);let i=x.vertexUvs[e];s.bindBuffer(s.ARRAY_BUFFER,this.uvBuffer),s.bufferData(s.ARRAY_BUFFER,i,s.DYNAMIC_DRAW),s.vertexAttribPointer(this.maskATexCoordLocation,2,s.FLOAT,!1,0,0);let n=x.indices[e];s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.indexBuffer),s.bufferData(s.ELEMENT_ARRAY_BUFFER,n,s.DYNAMIC_DRAW),s.drawElements(s.TRIANGLES,n.length,s.UNSIGNED_SHORT,0),s.useProgram(this.program),s.enableVertexAttribArray(this.aPositionLocation),s.enableVertexAttribArray(this.aTexCoordLocation)},j=-1;for(let e of g)if(!(x.opacities[e]<=.001))if(x.maskCounts[e]>0){let t=x.masks[e][0];t!==j&&(j=t,s.enable(s.STENCIL_TEST),s.stencilMask(255),s.clear(s.STENCIL_BUFFER_BIT),s.stencilFunc(s.ALWAYS,1,255),s.stencilOp(s.KEEP,s.KEEP,s.REPLACE),s.colorMask(!1,!1,!1,!1),y(t),s.colorMask(!0,!0,!0,!0)),s.stencilFunc(s.EQUAL,1,255),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),v(e)}else -1!==j&&(s.disable(s.STENCIL_TEST),j=-1),v(e);-1!==j&&s.disable(s.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 p({modelUrl:e,expression:s="neutral",action:a="idle",state:i="idle",speechId:d,lipSyncValue:c,durationMs:u,className:m="",onStatusChange:x}){let f=(0,r.useRef)(null),b=(0,r.useRef)(null),g=(0,r.useRef)(new n({expression:s,action:a,state:i,speechId:d,lipSyncValue:c,durationMs:u})),v=(0,r.useRef)(null),y=(0,r.useRef)(null),[j,N]=(0,r.useState)("loading"),[w,A]=(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=()=>{g.current.setReducedMotion(e.matches)};return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,r.useEffect)(()=>{g.current.updateConfig({expression:s,action:a,state:i,speechId:d,lipSyncValue:c,durationMs:u})},[s,a,i,d,c,u]),(0,r.useEffect)(()=>{let t=!1,r=null;async function s(){if(b.current&&f.current){if(!e){N("error"),A("No Live2D model configured. Place model in assets/body/<name>/"),x?.("error","No Live2D model URL specified");return}N("loading"),x?.("loading"),A(null);try{let s=await o();if(t)return;let a=await l(e);if(t)return;let i=b.current;if(!i)return;let n=new h(i);n.initialize(s,a),v.current=n;let d=()=>{if(!f.current||!b.current)return;let e=f.current.getBoundingClientRect();if(e.width<=0||e.height<=0)return;let t=Math.min(window.devicePixelRatio||1,2),r=Math.max(1,Math.floor(e.width*t)),s=Math.max(1,Math.floor(e.height*t));(b.current.width!==r||b.current.height!==s)&&(b.current.width=r,b.current.height=s)};d(),(r=new ResizeObserver(d)).observe(f.current);let c=()=>{t||(v.current&&v.current.render(g.current,performance.now()),y.current=requestAnimationFrame(c))};y.current=requestAnimationFrame(c),N("ready"),x?.("ready")}catch(r){if(t)return;let e=r?.message||"Failed to initialize Live2D avatar";console.warn("[AvatarCanvas] Initialization error:",r),N("error"),A("Avatar model unavailable or failed to load."),x?.("error",e)}}}s();let a=b.current,i=e=>{e.preventDefault(),console.warn("[AvatarCanvas] WebGL context lost"),y.current&&cancelAnimationFrame(y.current),N("error"),A("WebGL context lost.")},n=()=>{console.log("[AvatarCanvas] WebGL context restored, re-initializing..."),s()};return a&&(a.addEventListener("webglcontextlost",i,!1),a.addEventListener("webglcontextrestored",n,!1)),()=>{t=!0,y.current&&(cancelAnimationFrame(y.current),y.current=null),r&&r.disconnect(),a&&(a.removeEventListener("webglcontextlost",i),a.removeEventListener("webglcontextrestored",n)),v.current&&(v.current.dispose(),v.current=null)}},[e,C,x]),(0,t.jsxs)("div",{ref:f,"data-testid":"avatar-canvas-container",className:`relative w-full h-full min-h-0 flex items-center justify-center overflow-hidden bg-transparent ${m}`,"aria-label":"Live2D Companion Presence",children:[(0,t.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"===j?"opacity-100":"opacity-0"}`}),"loading"===j&&(0,t.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,t.jsx)("div",{className:"siduri-glyph w-10 h-10 text-base animate-pulse motion-reduce:animate-none",children:"✦"}),(0,t.jsx)("span",{className:"text-[11px] font-mono tracking-widest uppercase text-[var(--siduri-ember-light)]",children:"Initializing Presence..."})]}),"error"===j&&(0,t.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,t.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,t.jsx)("p",{className:"text-xs font-sans text-[var(--siduri-text-secondary)] mb-1",children:w||"Avatar unavailable in this browser."}),(0,t.jsx)("span",{className:"text-[10px] font-mono text-[var(--siduri-text-dim)] mb-3",children:"Conversational text mode remains active"}),(0,t.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 x=e.i(94108);let f="siduri.chat.conversations.v1";function b(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function g(e){return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(e)}function v(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 y(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}}function j(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}}}e.s(["default",0,function(){let[e,i]=(0,r.useState)([]),[n,o]=(0,r.useState)(null),[l,d]=(0,r.useState)(""),[c,u]=(0,r.useState)("connecting"),[m,h]=(0,r.useState)(!1),[N,w]=(0,r.useState)(!1),[A,C]=(0,r.useState)(!1),[E,P]=(0,r.useState)(!1),[L,k]=(0,r.useState)(!1),[R,S]=(0,r.useState)(!1),[_,T]=(0,r.useState)(null),[M,D]=(0,r.useState)(void 0),[I,B]=(0,r.useState)("hybrid"),[F,U]=(0,r.useState)("hybrid"),[$,O]=(0,r.useState)("off"),[X,Y]=(0,r.useState)(null),[z,G]=(0,r.useState)(!1),[V,W]=(0,r.useState)(null),[K,Z]=(0,r.useState)({}),[J,H]=(0,r.useState)(!1),[q,Q]=(0,r.useState)(null),ee=(0,r.useRef)(null),et=(0,r.useRef)(null),er=(0,r.useRef)(null),es=(0,r.useRef)(null),ea=(0,r.useMemo)(()=>e.find(e=>e.id===n)??null,[n,e]);function ei(){return{id:b(),title:"New conversation",messages:[],updatedAt:Date.now()}}function en(e,t){i(r=>r.map(r=>r.id===e?t(r):r))}async function eo(e){e.preventDefault();let t=l.trim();if(!t)return;if(/\[[^\]]+\]/.test(t))return void u("replace the blanks first");m&&es.current&&(es.current.abort("user_barge_in"),es.current=null,(0,x.interruptChat)("default","user_barge_in"));let r=ea;r||(r=ei(),i(e=>[r,...e]),o(r.id));let s=r.messages.filter(e=>!("assistant"===e.role&&!e.content.trim()&&!e.error&&!e.interrupted)),a={id:b(),role:"user",content:t,createdAt:Date.now()},n=b(),c=[...s,a,{id:n,role:"assistant",content:"",createdAt:Date.now()}],p=0===r.messages.length?t.slice(0,42):r.title;en(r.id,e=>({...e,title:p,messages:c,updatedAt:Date.now()})),d(""),h(!0),u("streaming");let f=new AbortController;es.current=f;try{await (0,x.postStream)("/chat/stream",{id:"default",message:t,medium:"web",mode:I,subtitleLanguage:"off"!==$?$:void 0,history:r.messages.slice(-20).map(e=>({role:e.role,content:e.content}))},{onStaged:e=>{e?.mode&&("casual"===e.mode||"teach"===e.mode||"hybrid"===e.mode)&&U(e.mode)},onAvatar:e=>{let t=e.speech_id;er.current&&clearTimeout(er.current),T({eventId:e.event_id,expression:e.expression||"neutral",action:e.action||"talk",state:"speaking",speechId:t,durationMs:e.durationMs});let r=e.durationMs||4500;er.current=setTimeout(()=>{T(e=>e?{...e,state:"idle",action:"idle"}:null)},r)},onChunk:e=>{e.deltaText&&en(r.id,t=>({...t,messages:t.messages.map(t=>t.id===n?{...t,content:t.content+e.deltaText}:t)})),(e.expression||e.action)&&T(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)&&U(e.metadata.mode);let t=e.response||{},s=e.metadata?.memory_proposals,a=e.metadata?.behavioral_proposals;en(r.id,e=>({...e,messages:e.messages.map(e=>e.id===n?{...e,content:e.content||t.subtitle_en||t.subtitle_ja||"",subtitle:t.subtitle,subtitleLanguage:t.subtitle_language||("off"!==$?$:void 0),subtitles:t.subtitles,spokenJa:t.spoken_ja,evidenceIds:t.evidence_ids,memoryProposals:s,behavioralProposals:a}:e),updatedAt:Date.now()})),u("online")},onInterrupted:e=>{let t=e?.reason||f.signal.reason||"interrupted";en(r.id,e=>{let r=e.messages.find(e=>e.id===n);return"user_barge_in"!==t||r&&r.content.trim()?{...e,messages:e.messages.map(e=>e.id===n?{...e,interrupted:!0,interruptionReason:"string"==typeof t?t:"interrupted"}:e),updatedAt:Date.now()}:{...e,messages:e.messages.filter(e=>e.id!==n),updatedAt:Date.now()}}),u("online")},onError:e=>{let t=e?.message||String(e)||"Unknown error";en(r.id,e=>({...e,messages:e.messages.map(e=>e.id===n?{...e,error:t}:e),updatedAt:Date.now()})),u("offline")}},f.signal)}catch(e){if(!f.signal.aborted){let t=e?.message||String(e)||"Connection error";en(r.id,e=>({...e,messages:e.messages.map(e=>e.id===n?{...e,error:t}:e),updatedAt:Date.now()})),u("offline")}}finally{es.current===f&&(es.current=null),h(!1)}}(0,r.useEffect)(()=>()=>{er.current&&clearTimeout(er.current),es.current&&es.current.abort("unmounted")},[]),(0,r.useEffect)(()=>{let e=function(){try{let e=JSON.parse(window.localStorage.getItem(f)??"[]");if(!Array.isArray(e))return[];return e.map(e=>({...e,messages:(e.messages||[]).map(v)}))}catch{return[]}}();i(e),o(e[0]?.id??null);try{let e=localStorage.getItem("siduri.chat.subtitleLanguage");e&&O(e)}catch{}w(!0),(0,x.fetchApi)("/health").then(async e=>{if(e.ok){let t=await e.json().catch(()=>({}));u("online"),t.organs?.body?.modelUrl?D(t.organs.body.modelUrl):(0,x.fetchApi)("/api/models/body").then(async e=>{if(e.ok){let t=(await e.json().catch(()=>({}))).models||[],r=t.find(e=>"default"!==e);r?D(`/assets/body/${r}/model.model3.json`):t.length>0&&"default"!==t[0]&&D(`/assets/body/${t[0]}/model.model3.json`)}}).catch(()=>{})}else u("online")}).catch(()=>u("offline")),(0,x.fetchApi)("/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}`)||Y(t))}}).catch(()=>{})},[]),(0,r.useEffect)(()=>{N&&window.localStorage.setItem(f,JSON.stringify(e))},[e,N]),(0,r.useEffect)(()=>{et.current?.scrollTo({top:et.current.scrollHeight,behavior:"smooth"})},[n,ea?.messages.length,m]);let el=ea?.messages??[],ed=el.at(-1)?.evidenceIds?.length??0;async function ec(e,t,r){if(ea)try{let s=await (0,x.postJson)(`/memory/proposals/${r}`,{id:t,companionId:"default"}),a=s?.status||("approve"===r?"approved":"rejected");en(ea.id,r=>({...r,messages:r.messages.map(r=>r.id===e&&r.memoryProposals?{...r,memoryProposals:r.memoryProposals.map(e=>(e.proposal_id||e.id)===t?{...e,status:a}:e)}:r)}))}catch(e){console.error("Failed to update memory proposal:",e)}}async function eu(e,t,r){if(ea)try{let s=await (0,x.postJson)(`/memory/behavioral/${r}`,{id:t,companionId:"default"}),a=s?.status||("approve"===r?"active":"rejected");en(ea.id,r=>({...r,messages:r.messages.map(r=>r.id===e&&r.behavioralProposals?{...r,behavioralProposals:r.behavioralProposals.map(e=>(e.directive_id||e.id)===t?{...e,status:a}:e)}:r)}))}catch(e){console.error("Failed to update behavioral proposal:",e)}}function em(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}),Z(t),W({manifest:e.manifest,scannedDirectives:e.scannedDirectives||e.manifest.directives||[]})}async function eh(e){let t=e.target.files?.[0];if(t)try{let e=await t.text(),r=await (0,x.postJson)("/teach/upload-self",{content:e});r&&r.isValid&&r.manifest?em(r):alert(r?.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(V?.manifest){H(!0);try{let e=Object.entries(K).filter(([,e])=>e).map(([e])=>e),t=await (0,x.postJson)("/teach/install-self",{companionId:"default",manifest:V.manifest,approvedDirectiveIds:e});t&&t.success?(Q(`Installed '${V.manifest.name}' ethos (${e.length} directives active).`),setTimeout(()=>Q(null),6e3),W(null),G(!0),X?.filename&&sessionStorage.setItem(`siduri.dismissedSelf:${X.filename}`,"true")):alert(t?.error||"Failed to install .self package")}catch(e){alert(`Install error: ${e.message}`)}finally{H(!1)}}}return(0,t.jsxs)("div",{className:`chat-app ${A?"sidebar-collapsed":""} ${E?"mobile-drawer-open":""}`,children:[E&&(0,t.jsx)("div",{className:"chat-backdrop",onClick:()=>P(!1),"aria-hidden":"true"}),(0,t.jsxs)("aside",{className:"chat-sidebar","aria-label":"Conversation history",children:[(0,t.jsxs)("div",{className:"chat-sidebar-top",children:[(0,t.jsxs)("a",{className:"chat-brand",href:"/chat",children:[(0,t.jsx)("span",{className:"chat-brand-mark",children:"S"}),(0,t.jsx)("span",{children:"SIDURI"})]}),(0,t.jsx)("button",{className:"sidebar-collapse",type:"button",onClick:()=>C(e=>!e),"aria-label":A?"Expand sidebar":"Collapse sidebar",children:A?"→":"←"}),(0,t.jsx)("button",{className:"mobile-drawer-close",type:"button",onClick:()=>P(!1),"aria-label":"Close conversation drawer",children:"✕"})]}),(0,t.jsxs)("button",{className:"new-chat-button",type:"button",onClick:()=>{let e;e=ei(),i(t=>[e,...t]),o(e.id),d(""),u("online"),P(!1)},children:[(0,t.jsx)("span",{children:"+"})," New conversation"]}),(0,t.jsxs)("div",{className:"history-heading",children:[(0,t.jsx)("span",{children:"Recent conversations"}),(0,t.jsx)("span",{children:e.length})]}),(0,t.jsx)("div",{className:"conversation-list",children:N?0===e.length?(0,t.jsx)("p",{className:"history-empty",children:"Your private conversations will appear here."}):e.slice().sort((e,t)=>t.updatedAt-e.updatedAt).map(r=>(0,t.jsxs)("div",{className:`conversation-row ${r.id===n?"selected":""}`,children:[(0,t.jsxs)("button",{type:"button",className:"conversation-select",onClick:()=>{o(r.id),P(!1)},children:[(0,t.jsx)("span",{className:"conversation-title",children:r.title}),(0,t.jsx)("span",{className:"conversation-date",children:g(r.updatedAt)})]}),(0,t.jsx)("button",{type:"button",className:"conversation-delete",onClick:t=>{t.stopPropagation();var s=r.id;if(i(e=>e.filter(e=>e.id!==s)),n===s){let t=e.find(e=>e.id!==s);o(t?.id??null)}},"aria-label":`Delete ${r.title}`,children:"×"})]},r.id)):(0,t.jsx)("p",{className:"history-empty",children:"Loading history…"})}),(0,t.jsxs)("div",{className:"sidebar-footer",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{P(!1),k(!0)},className:"sidebar-settings-btn md:hidden",children:[(0,t.jsx)("span",{children:"⚙"}),(0,t.jsxs)("span",{className:"truncate",children:["Preferences (",I,"off"!==$?` \xb7 ${$.toUpperCase()}`:"",")"]})]}),(0,t.jsxs)("a",{className:"sidebar-console",href:"/operator",children:[(0,t.jsx)("span",{children:"⌘"}),(0,t.jsx)("span",{children:"Operator console"}),(0,t.jsx)("b",{children:"↗"})]})]})]}),(0,t.jsxs)("main",{className:"chat-workspace",children:[(0,t.jsxs)("header",{className:"chat-header",children:[(0,t.jsxs)("div",{className:"chat-header-brand-group",children:[(0,t.jsx)("button",{type:"button",className:"mobile-menu-toggle",onClick:()=>P(!0),"aria-label":"Open conversation menu",children:(0,t.jsx)("span",{className:"hamburger-icon",children:"☰"})}),(0,t.jsxs)("a",{href:"/chat",className:"chat-header-title",children:[(0,t.jsx)("span",{className:"chat-brand-mark",children:"S"}),(0,t.jsx)("span",{className:"font-bold tracking-widest text-xs hidden xs:inline",children:"SIDURI"})]})]}),(0,t.jsxs)("div",{className:"chat-header-actions flex items-center gap-1.5 sm:gap-2.5",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>S(e=>!e),className:`connection-pill cursor-pointer transition-all focus-visible:ring-1 focus-visible:ring-[var(--siduri-border-ember)] outline-none ${R?"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":R,title:R?"Disable Avatar Presence":"Enable Avatar Presence",children:[(0,t.jsx)("span",{className:`status-light ${R?"online":""}`}),(0,t.jsx)("span",{className:"text-xs",children:"Presence"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>k(!0),className:`connection-pill cursor-pointer transition-all md:hidden flex items-center gap-1.5 ${"off"!==$||"hybrid"!==I?"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,t.jsx)("span",{className:"text-xs",children:"⚙"}),(0,t.jsx)("span",{className:"text-xs font-mono font-medium tracking-wide",children:"hybrid"!==I&&"off"!==$?`${I.slice(0,4)}\xb7${$.slice(0,2).toUpperCase()}`:"hybrid"!==I?I:"off"!==$?`CC:${$.slice(0,2).toUpperCase()}`:"Options"})]}),(0,t.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"!==$?"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,t.jsx)("span",{className:`status-light ${"off"!==$?"online":""}`}),(0,t.jsx)("span",{className:"text-[10px] uppercase font-mono tracking-wider opacity-60",children:"Subtitles:"}),(0,t.jsxs)("select",{value:["off","en","ja","id","es","zh","ko","fr","de"].includes($)?$:"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();O(t);try{localStorage.setItem("siduri.chat.subtitleLanguage",t)}catch{}}}else if("custom-selected"!==t){O(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,t.jsx)("option",{value:"off",className:"bg-[#121214] text-white",children:"Subtitles: Off"}),(0,t.jsx)("option",{value:"en",className:"bg-[#121214] text-white",children:"English (EN)"}),(0,t.jsx)("option",{value:"ja",className:"bg-[#121214] text-white",children:"Japanese (JA)"}),(0,t.jsx)("option",{value:"id",className:"bg-[#121214] text-white",children:"Indonesian (ID)"}),(0,t.jsx)("option",{value:"es",className:"bg-[#121214] text-white",children:"Spanish (ES)"}),(0,t.jsx)("option",{value:"zh",className:"bg-[#121214] text-white",children:"Chinese (ZH)"}),(0,t.jsx)("option",{value:"ko",className:"bg-[#121214] text-white",children:"Korean (KO)"}),(0,t.jsx)("option",{value:"fr",className:"bg-[#121214] text-white",children:"French (FR)"}),(0,t.jsx)("option",{value:"de",className:"bg-[#121214] text-white",children:"German (DE)"}),!["off","en","ja","id","es","zh","ko","fr","de"].includes($)&&(0,t.jsx)("option",{value:"custom-selected",className:"bg-[#121214] text-white",children:$.toUpperCase()}),(0,t.jsx)("option",{value:"custom",className:"bg-[#121214] text-white",children:"Other..."})]})]}),(0,t.jsxs)("span",{className:"connection-pill hidden lg:inline-flex",title:`Status: ${c}`,children:[(0,t.jsx)("span",{className:`status-light ${"online"===c?"online":""}`}),(0,t.jsx)("span",{className:"text-xs",children:c})]}),(0,t.jsxs)("div",{className:"connection-pill hidden md:flex items-center gap-1 sm:gap-1.5",title:"Operating interaction mode",children:[(0,t.jsx)("span",{className:"text-[10px] uppercase font-mono tracking-wider opacity-60",children:"Mode:"}),(0,t.jsxs)("select",{value:I,onChange:e=>B(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,t.jsx)("option",{value:"hybrid",className:"bg-[#121214] text-white",children:"Hybrid (Default)"}),(0,t.jsx)("option",{value:"teach",className:"bg-[#121214] text-white",children:"Teach"}),(0,t.jsx)("option",{value:"casual",className:"bg-[#121214] text-white",children:"Casual"})]})]})]})]}),X&&!z&&(0,t.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,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"text-base",children:"📦"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:".self file detected on path:"})," ",(0,t.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:X.filename}),X.alreadyInstalled?(0,t.jsx)("span",{className:"ml-1.5 text-[var(--siduri-text-muted)] text-[11px]",children:"(already imported)"}):null," — Import to companion ethos & directives?"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{G(!0),X.filename&&sessionStorage.setItem(`siduri.dismissedSelf:${X.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,t.jsx)("button",{type:"button",onClick:function(){X?.parsed&&("teach"!==I&&(B("teach"),U("teach")),em(X.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"})]})]}),q&&(0,t.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,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{children:"✓"}),(0,t.jsx)("span",{children:q})]}),(0,t.jsx)("button",{type:"button",onClick:()=>Q(null),className:"text-[#a9dfbf] hover:text-white cursor-pointer",children:"✕"})]}),V&&(0,t.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,t.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,t.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,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.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 text-lg",children:"📦"}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-sm sm:text-base font-bold text-white tracking-wide",children:V.manifest?.name||"Self Ethos Package"}),(0,t.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",V.manifest?.version||"1.0.0"]})]}),(0,t.jsxs)("p",{className:"text-[11px] text-[var(--siduri-text-muted)] mt-0.5 font-mono",children:["Author: ",V.manifest?.author?.name||"Unknown"," · ID: ",V.manifest?.id||"custom"]})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>W(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,t.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 sm:p-5 space-y-4",children:[(0,t.jsxs)("div",{className:"p-3.5 rounded-xl bg-[#1a1a20] border border-[var(--siduri-border-subtle)] space-y-1.5",children:[(0,t.jsx)("span",{className:"text-[10px] font-mono uppercase tracking-wider text-[var(--siduri-ember-highlight)] font-semibold",children:"Identity Nucleus"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-bold text-white",children:V.manifest?.identity?.name}),V.manifest?.identity?.archetype&&(0,t.jsxs)("span",{className:"text-xs text-[var(--siduri-text-secondary)]",children:["· ",V.manifest.identity.archetype]})]}),V.manifest?.identity?.ethos&&(0,t.jsxs)("p",{className:"text-xs text-[var(--siduri-text-secondary)] italic leading-relaxed pt-1",children:['"',V.manifest.identity.ethos,'"']})]}),Array.isArray(V.manifest?.relationships)&&V.manifest.relationships.length>0&&(0,t.jsxs)("div",{className:"p-3.5 rounded-xl bg-[#1a1a20] border border-[var(--siduri-border-subtle)] space-y-2",children:[(0,t.jsx)("span",{className:"text-[10px] font-mono uppercase tracking-wider text-[var(--siduri-ember-highlight)] font-semibold",children:"Relational Stances"}),(0,t.jsx)("div",{className:"space-y-2",children:V.manifest.relationships.map((e,r)=>(0,t.jsxs)("div",{className:"text-xs space-y-1 p-2 rounded-lg bg-black/30 border border-white/5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-semibold text-white font-mono",children:e.entityId}),(0,t.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,t.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,t.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,r)=>(0,t.jsx)("li",{children:e},r))})]},r))})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"text-[10px] font-mono uppercase tracking-wider text-[var(--siduri-ember-highlight)] font-semibold",children:["Directives Review (",Object.values(K).filter(Boolean).length," of ",V.scannedDirectives.length," selected)"]}),(0,t.jsxs)("div",{className:"flex gap-2 text-[11px]",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{let e={};V.scannedDirectives.forEach(t=>{e[t.id]=!0}),Z(e)},className:"text-[var(--siduri-ember-highlight)] hover:underline cursor-pointer",children:"Select All"}),(0,t.jsx)("span",{className:"text-[var(--siduri-text-muted)]",children:"·"}),(0,t.jsx)("button",{type:"button",onClick:()=>Z({}),className:"text-[var(--siduri-text-muted)] hover:underline cursor-pointer",children:"Deselect All"})]})]}),(0,t.jsx)("div",{className:"space-y-2 max-h-64 overflow-y-auto pr-1",children:V.scannedDirectives.map((e,r)=>{let s=!!K[e.id],a=e.scanResult?.safe!==!1;return(0,t.jsxs)("div",{onClick:()=>Z(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,t.jsx)("input",{type:"checkbox",checked:s,onChange:()=>{},className:"mt-0.5 rounded cursor-pointer accent-[var(--siduri-ember)]"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center flex-wrap gap-1.5 text-[10px] font-mono",children:[(0,t.jsx)("span",{className:"text-[var(--siduri-text-muted)]",children:e.id}),(0,t.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,t.jsxs)("span",{className:"text-[var(--siduri-text-dim)]",children:["P",e.priority]}),a?(0,t.jsx)("span",{className:"text-[var(--siduri-online)] text-[10px] font-sans",children:"✓ Safe"}):(0,t.jsxs)("span",{className:"text-[var(--siduri-danger)] text-[10px] font-sans font-semibold",children:["⚠️ Blocked: ",e.scanResult?.reason||"Flagged"]})]}),(0,t.jsx)("p",{className:"text-xs text-white leading-relaxed",children:e.directive})]})]},e.id||r)})})]})]}),(0,t.jsxs)("div",{className:"p-4 border-t border-[var(--siduri-border-subtle)] bg-[#19191e]/90 flex items-center justify-between gap-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>W(null),disabled:J,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,t.jsx)("button",{type:"button",onClick:ep,disabled:J||0===Object.values(K).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:J?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("span",{children:"Installing…"})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"Install Selected Self"}),(0,t.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-black/20 text-[10px] font-mono",children:Object.values(K).filter(Boolean).length})]})})]})]})}),(0,t.jsx)("div",{className:"flex flex-col flex-1 min-h-0 w-full overflow-hidden relative",children:(0,t.jsxs)("section",{className:"conversation-surface","aria-label":"Private chat",children:[(0,t.jsxs)("div",{ref:et,className:`conversation-scroll ${R?"presence-active":""}`,"aria-live":"polite",children:[R?(0,t.jsx)("div",{className:"avatar-presence-area","data-testid":"avatar-presence-area",children:(0,t.jsx)(p,{modelUrl:M,expression:_?.expression||"neutral",action:_?.action||"idle",state:_?.state||"idle",speechId:_?.speechId,lipSyncValue:_?.lipSyncValue,durationMs:_?.durationMs,className:"w-full h-full"})}):0===el.length?(0,t.jsx)(a,{onSelectPrompt:e=>d(e)}):el.map(e=>{let r,a,i,n;return(0,t.jsxs)("article",{className:`platform-message ${e.role}`,children:[(0,t.jsx)("div",{className:"message-avatar",children:"user"===e.role?"U":"S"}),(0,t.jsxs)("div",{className:"message-body",children:[(0,t.jsxs)("div",{className:"message-meta",children:[(0,t.jsx)("span",{children:"user"===e.role?"You":"Siduri"}),"assistant"!==e.role||e.content||e.error||e.interrupted||!m?(0,t.jsx)("time",{children:g(e.createdAt)}):(0,t.jsx)("span",{className:"thinking-label",children:"thinking"}),e.interrupted&&(r=j(e.interruptionReason),(0,t.jsx)("span",{className:"interrupted-pill",title:r.hint||r.text,children:r.label})),e.error&&(0,t.jsx)("span",{className:"error-pill",title:"An error occurred during response",children:"error"})]}),e.error?(a=y(e.error),(0,t.jsxs)("div",{className:"message-error-container",children:[e.content?(0,t.jsx)("p",{className:"message-primary",children:e.content}):(0,t.jsx)("p",{className:"message-primary text-[var(--siduri-text-muted)] italic",children:"I couldn't complete the response."}),(0,t.jsxs)("div",{className:"message-error-callout",children:[(0,t.jsxs)("div",{className:"error-callout-header",children:[(0,t.jsx)("span",{className:"error-icon","aria-hidden":"true",children:"⚠️"}),(0,t.jsx)("span",{className:"error-text",children:a.title})]}),a.hint&&(0,t.jsx)("p",{className:"error-hint text-xs text-[var(--siduri-text-secondary)] mt-1 mb-1",children:a.hint}),(0,t.jsxs)("details",{className:"error-details",children:[(0,t.jsx)("summary",{children:"View technical details"}),(0,t.jsx)("pre",{className:"error-trace",children:e.error})]})]})]})):e.interrupted&&!e.content?(i=j(e.interruptionReason),(0,t.jsxs)("div",{className:"message-cancelled-container",children:[(0,t.jsx)("p",{className:"message-cancelled",children:i.text}),i.hint&&(0,t.jsx)("p",{className:"message-cancelled-hint text-xs text-[var(--siduri-text-dim)] mt-0.5",children:i.hint})]})):"assistant"===e.role&&!e.content&&m?(0,t.jsxs)("div",{className:"thinking-dots",children:[(0,t.jsx)("i",{}),(0,t.jsx)("i",{}),(0,t.jsx)("i",{})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"message-primary",children:e.content}),e.interrupted&&(0,t.jsxs)("p",{className:"message-interrupted-footnote text-xs text-[var(--siduri-text-dim)] italic mt-1",children:["— ",j(e.interruptionReason).text.toLowerCase()]})]}),"off"!==$&&"assistant"===e.role&&((n=e.subtitles?.[$]||(e.subtitleLanguage===$?e.subtitle:void 0)||("ja"===$&&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,t.jsxs)("p",{className:"message-translation",title:`Subtitle: ${$.toUpperCase()}`,children:[(0,t.jsxs)("span",{className:"text-[10px] font-mono uppercase tracking-wider opacity-60 mr-1.5 not-italic",children:["[",$,"]:"]}),n]}):null),e.evidenceIds&&e.evidenceIds.length>0&&(0,t.jsxs)("span",{className:"evidence-chip",children:[e.evidenceIds.length," evidence link",1===e.evidenceIds.length?"":"s"]}),e.memoryProposals&&e.memoryProposals.length>0&&(0,t.jsx)("div",{className:"memory-receipts",children:e.memoryProposals.map((r,a)=>{let i=r.proposal_id||r.id||`mprop-${a}`,n=(r.status||"pending").toLowerCase().replace(/_/g,"-"),o="pending"===n;return(0,t.jsxs)("div",{className:`memory-receipt status-${n}`,children:[(0,t.jsxs)("strong",{children:["Remember",r.claim_type?` (${r.claim_type.toLowerCase()})`:"",":"]})," ",(0,s.formatClaimReceipt)(r),(0,t.jsx)("div",{className:"receipt-actions",children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>ec(e.id,i,"approve"),children:"Approve"}),(0,t.jsx)("button",{type:"button",onClick:()=>ec(e.id,i,"reject"),children:"Reject"})]}):(0,t.jsx)("span",{children:n.toUpperCase()})})]},i)})}),e.behavioralProposals&&e.behavioralProposals.length>0&&(0,t.jsx)("div",{className:"memory-receipts",children:e.behavioralProposals.map((r,a)=>{let i=r.directive_id||r.id||`bprop-${a}`,n=(r.status||"pending").toLowerCase().replace(/_/g,"-"),o="pending"===n;return(0,t.jsxs)("div",{className:`memory-receipt status-${n}`,children:[(0,t.jsxs)("strong",{children:["Runtime effect [",((r.knowledge_domain??r.domain)||"").toLowerCase()," ","→ ",((r.runtime_effect??r.memory_class)||"").toLowerCase(),"]:"]})," ",(0,s.formatRuntimeEffect)(r),(0,t.jsx)("div",{className:"receipt-actions",children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>eu(e.id,i,"approve"),children:"Approve"}),(0,t.jsx)("button",{type:"button",onClick:()=>eu(e.id,i,"reject"),children:"Reject"})]}):(0,t.jsx)("span",{children:n.toUpperCase()})})]},i)})})]})]},e.id)}),m&&!R&&(!el.length||el[el.length-1]?.role!=="assistant")&&(0,t.jsxs)("div",{className:"platform-message assistant thinking-message",children:[(0,t.jsx)("div",{className:"message-avatar",children:"S"}),(0,t.jsxs)("div",{className:"message-body",children:[(0,t.jsxs)("div",{className:"message-meta",children:[(0,t.jsx)("span",{children:"Siduri"}),(0,t.jsx)("span",{className:"thinking-label",children:"thinking"})]}),(0,t.jsxs)("div",{className:"thinking-dots",children:[(0,t.jsx)("i",{}),(0,t.jsx)("i",{}),(0,t.jsx)("i",{})]})]})]})]}),(0,t.jsxs)("form",{className:"platform-composer",onSubmit:eo,children:[(0,t.jsx)("textarea",{value:l,onChange:e=>d(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,t.jsxs)("div",{className:"composer-bottom",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,t.jsxs)("span",{children:["Private local session ·"," ",ed?`${ed} evidence link${1===ed?"":"s"}`:"No evidence attached"]}),"teach"===I&&(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("input",{type:"file",ref:ee,accept:".self,.yaml,.yml,.json",className:"hidden",onChange:eh,"aria-label":"Upload .self file"}),(0,t.jsxs)("button",{type:"button",onClick:()=>ee.current?.click(),className:"composer-attach-btn",title:"Attach .self file for Teach Mode review",children:[(0,t.jsx)("svg",{viewBox:"0 0 24 24",children:(0,t.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,t.jsx)("span",{children:"Attach .self"})]})]})]}),m&&!l.trim()?(0,t.jsx)("button",{type:"button",onClick:function(){es.current&&(es.current.abort("user_stop"),es.current=null),(0,x.interruptChat)("default","user_stop"),h(!1),u("online")},"aria-label":"Stop generation",title:"Stop generation",className:"composer-action-btn",children:"■"}):(0,t.jsx)("button",{type:"submit",disabled:!l.trim(),"aria-label":"Send message",className:"composer-action-btn",children:"↑"})]})]})]})}),(0,t.jsx)("p",{className:"chat-disclaimer",children:"Siduri can be uncertain. Verify important details against the evidence."})]}),L&&(0,t.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,t.jsx)("div",{className:"mobile-settings-backdrop absolute inset-0 bg-black/70 backdrop-blur-sm transition-opacity",onClick:()=>k(!1),"aria-hidden":"true"}),(0,t.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,t.jsxs)("div",{className:"flex items-center justify-between pb-3 border-b border-[var(--siduri-border-subtle)]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-base font-semibold tracking-wide text-[#eee8df]",children:"Chat Preferences"}),(0,t.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,t.jsx)("button",{type:"button",onClick:()=>k(!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,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-mono uppercase tracking-wider text-[var(--siduri-text-secondary)]",children:"Interaction Mode"}),(0,t.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 r=I===e.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>B(e.id),className:`flex flex-col text-left p-2.5 rounded-xl border transition-all cursor-pointer ${r?"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,t.jsx)("span",{className:"text-xs font-bold",children:e.label}),(0,t.jsx)("span",{className:"text-[10px] opacity-75 mt-0.5 line-clamp-1",children:e.desc})]},e.id)})})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-xs font-mono uppercase tracking-wider text-[var(--siduri-text-secondary)]",children:"Subtitle Translation"}),"off"!==$&&(0,t.jsxs)("span",{className:"text-[10px] font-mono uppercase text-[var(--siduri-ember-highlight)]",children:["Active: ",$.toUpperCase()]})]}),(0,t.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 r=$===e.code;return(0,t.jsx)("button",{type:"button",onClick:()=>{O(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 ${r?"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,t.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();O(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,t.jsxs)("div",{className:"flex items-center justify-between pt-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-[#eee8df] block",children:"Live2D Avatar Presence"}),(0,t.jsx)("span",{className:"text-[11px] text-[var(--siduri-text-muted)]",children:"Render animated companion in chat"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>S(e=>!e),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors cursor-pointer ${R?"bg-[var(--siduri-ember)]":"bg-[#282830]"}`,role:"switch","aria-checked":R,children:(0,t.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${R?"translate-x-6":"translate-x-1"}`})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-[var(--siduri-border-subtle)]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`status-light ${"online"===c?"online":""}`}),(0,t.jsx)("span",{className:"text-xs text-[var(--siduri-text-muted)] capitalize",children:c})]}),(0,t.jsx)("button",{type:"button",onClick:()=>k(!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"})]})]})]})]})},"getErrorDiagnosis",0,y,"getInterruptionExplanation",0,j],12650)}]);
@@ -1,31 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,34189,(e,r,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o={WarningIcon:function(){return d},errorStyles:function(){return l},errorThemeCss:function(){return a}};for(var n in o)Object.defineProperty(t,n,{enumerable:!0,get:o[n]});e.r(36437);let i=e.r(30696);e.r(64249);let l={container:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},card:{marginTop:"-32px",maxWidth:"325px",padding:"32px 28px",textAlign:"left"},icon:{marginBottom:"24px"},title:{fontSize:"24px",fontWeight:500,letterSpacing:"-0.02em",lineHeight:"32px",margin:"0 0 12px 0",color:"var(--next-error-title)"},message:{fontSize:"14px",fontWeight:400,lineHeight:"21px",margin:"0 0 20px 0",color:"var(--next-error-message)"},form:{margin:0},buttonGroup:{display:"flex",gap:"8px",alignItems:"center"},button:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"32px",padding:"0 12px",fontSize:"14px",fontWeight:500,lineHeight:"20px",borderRadius:"6px",cursor:"pointer",color:"var(--next-error-btn-text)",background:"var(--next-error-btn-bg)",border:"var(--next-error-btn-border)"},buttonSecondary:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:"32px",padding:"0 12px",fontSize:"14px",fontWeight:500,lineHeight:"20px",borderRadius:"6px",cursor:"pointer",color:"var(--next-error-btn-secondary-text)",background:"var(--next-error-btn-secondary-bg)",border:"var(--next-error-btn-secondary-border)"},digestFooter:{position:"fixed",bottom:"32px",left:"0",right:"0",textAlign:"center",fontFamily:'ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace',fontSize:"12px",lineHeight:"18px",fontWeight:400,margin:"0",color:"var(--next-error-digest)"}},a=`
2
- :root {
3
- --next-error-bg: #fff;
4
- --next-error-text: #171717;
5
- --next-error-title: #171717;
6
- --next-error-message: #171717;
7
- --next-error-digest: #666666;
8
- --next-error-btn-text: #fff;
9
- --next-error-btn-bg: #171717;
10
- --next-error-btn-border: none;
11
- --next-error-btn-secondary-text: #171717;
12
- --next-error-btn-secondary-bg: transparent;
13
- --next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);
14
- }
15
- @media (prefers-color-scheme: dark) {
16
- :root {
17
- --next-error-bg: #0a0a0a;
18
- --next-error-text: #ededed;
19
- --next-error-title: #ededed;
20
- --next-error-message: #ededed;
21
- --next-error-digest: #a0a0a0;
22
- --next-error-btn-text: #0a0a0a;
23
- --next-error-btn-bg: #ededed;
24
- --next-error-btn-border: none;
25
- --next-error-btn-secondary-text: #ededed;
26
- --next-error-btn-secondary-bg: transparent;
27
- --next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);
28
- }
29
- }
30
- body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }
31
- `.replace(/\n\s*/g,"");function d(){return(0,i.jsx)("svg",{width:"32",height:"32",viewBox:"-0.2 -1.5 32 32",fill:"none",style:l.icon,children:(0,i.jsx)("path",{d:"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z",fill:"var(--next-error-title)"})})}("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),r.exports=t.default)},58484,(e,r,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return l}}),e.r(36437);let o=e.r(30696);e.r(64249);let n=e.r(5983),i=e.r(34189),l=function({error:e}){let r=e?.digest,t=!!r;return(0,n.handleISRError)({error:e}),(0,o.jsxs)("html",{id:"__next_error__",children:[(0,o.jsx)("head",{children:(0,o.jsx)("style",{dangerouslySetInnerHTML:{__html:i.errorThemeCss}})}),(0,o.jsxs)("body",{children:[(0,o.jsx)("div",{style:i.errorStyles.container,children:(0,o.jsxs)("div",{style:i.errorStyles.card,children:[(0,o.jsx)(i.WarningIcon,{}),(0,o.jsx)("h1",{style:i.errorStyles.title,children:"This page couldn’t load"}),(0,o.jsx)("p",{style:i.errorStyles.message,children:t?"A server error occurred. Reload to try again.":"Reload to try again, or go back."}),(0,o.jsxs)("div",{style:i.errorStyles.buttonGroup,children:[(0,o.jsx)("form",{style:i.errorStyles.form,children:(0,o.jsx)("button",{type:"submit",style:i.errorStyles.button,children:"Reload"})}),!t&&(0,o.jsx)("button",{type:"button",style:i.errorStyles.buttonSecondary,onClick:()=>{window.history.length>1?window.history.back():window.location.href="/"},children:"Back"})]})]})}),r&&(0,o.jsxs)("p",{style:i.errorStyles.digestFooter,children:["ERROR ",r]})]})]})};("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),r.exports=t.default)}]);