@minimalcorp/tsunagi 0.1.24 → 0.1.25

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 (57) hide show
  1. package/.next/standalone/apps/web/.next/BUILD_ID +1 -1
  2. package/.next/standalone/apps/web/.next/build-manifest.json +3 -3
  3. package/.next/standalone/apps/web/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/apps/web/.next/server/app/_global-error.html +1 -1
  5. package/.next/standalone/apps/web/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/standalone/apps/web/.next/server/app/_not-found.html +1 -1
  12. package/.next/standalone/apps/web/.next/server/app/_not-found.rsc +1 -1
  13. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  14. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  15. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  16. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  17. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  18. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  19. package/.next/standalone/apps/web/.next/server/app/index.html +1 -1
  20. package/.next/standalone/apps/web/.next/server/app/index.rsc +2 -2
  21. package/.next/standalone/apps/web/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  22. package/.next/standalone/apps/web/.next/server/app/index.segments/_full.segment.rsc +2 -2
  23. package/.next/standalone/apps/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  24. package/.next/standalone/apps/web/.next/server/app/index.segments/_index.segment.rsc +1 -1
  25. package/.next/standalone/apps/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  26. package/.next/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  27. package/.next/standalone/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  28. package/.next/standalone/apps/web/.next/server/app/settings.html +1 -1
  29. package/.next/standalone/apps/web/.next/server/app/settings.rsc +2 -2
  30. package/.next/standalone/apps/web/.next/server/app/settings.segments/_full.segment.rsc +2 -2
  31. package/.next/standalone/apps/web/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  32. package/.next/standalone/apps/web/.next/server/app/settings.segments/_index.segment.rsc +1 -1
  33. package/.next/standalone/apps/web/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  34. package/.next/standalone/apps/web/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  35. package/.next/standalone/apps/web/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  36. package/.next/standalone/apps/web/.next/server/app/tasks/[id]/page_client-reference-manifest.js +1 -1
  37. package/.next/standalone/apps/web/.next/server/chunks/ssr/_03hz06e._.js +1 -1
  38. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0836rl_._.js +1 -1
  39. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0amxree._.js +1 -1
  40. package/.next/standalone/apps/web/.next/server/chunks/ssr/apps_web_src_app_settings_page_tsx_0i6itlb._.js +1 -1
  41. package/.next/standalone/apps/web/.next/server/middleware-build-manifest.js +3 -3
  42. package/.next/standalone/apps/web/.next/server/pages/404.html +1 -1
  43. package/.next/standalone/apps/web/.next/server/pages/500.html +1 -1
  44. package/.next/standalone/apps/web/.next/server/server-reference-manifest.js +1 -1
  45. package/.next/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
  46. package/.next/standalone/apps/web/.next/static/chunks/0592-patkjl3_.js +1 -0
  47. package/.next/standalone/apps/web/.next/static/chunks/0915n6rwhsagp.js +1 -0
  48. package/.next/standalone/apps/web/.next/static/chunks/0922av8h192l7.js +1 -0
  49. package/.next/standalone/apps/web/.next/static/chunks/{0y9ehkcn04ljq.js → 0xxgdzi2vipaj.js} +2 -2
  50. package/npm-shrinkwrap.json +2 -2
  51. package/package.json +1 -1
  52. package/.next/standalone/apps/web/.next/static/chunks/0~0s04z6h.rs..js +0 -1
  53. package/.next/standalone/apps/web/.next/static/chunks/12dmkv54xstku.js +0 -1
  54. package/.next/standalone/apps/web/.next/static/chunks/13ohhwsmmfexn.js +0 -1
  55. /package/.next/standalone/apps/web/.next/static/{gWwRKXTSig4Dz-gNeqxJy → qMzGt_O2oG-7wQXWYfQUB}/_buildManifest.js +0 -0
  56. /package/.next/standalone/apps/web/.next/static/{gWwRKXTSig4Dz-gNeqxJy → qMzGt_O2oG-7wQXWYfQUB}/_clientMiddlewareManifest.js +0 -0
  57. /package/.next/standalone/apps/web/.next/static/{gWwRKXTSig4Dz-gNeqxJy → qMzGt_O2oG-7wQXWYfQUB}/_ssgManifest.js +0 -0
@@ -1,5 +1,5 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,82341,e=>{"use strict";var t=e.i(18050),s=e.i(71645),a=e.i(18566),r=e.i(471),l=e.i(70935),n=e.i(75254);let o=(0,n.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),i=(0,n.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var c=e.i(55716),d=e.i(46349),d=d;let u=(0,n.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var x=e.i(85902);function m({node:e,isSelected:s,isExpanded:a,depth:r,onSelect:l,onToggle:n}){let h=e.children&&e.children.length>0;return(0,t.jsxs)("div",{onClick:()=>{l(),h&&n&&!a&&n()},className:`
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,82341,e=>{"use strict";var t=e.i(18050),s=e.i(71645),a=e.i(18566),r=e.i(471),l=e.i(70935),n=e.i(75254);let o=(0,n.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),i=(0,n.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var c=e.i(55716),d=e.i(46349),d=d;let u=(0,n.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var x=e.i(85902);function m({node:e,isSelected:s,isExpanded:a,depth:r,onSelect:l,onToggle:n}){let p=e.children&&e.children.length>0;return(0,t.jsxs)("div",{onClick:()=>{l(),p&&n&&!a&&n()},className:`
2
2
  flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer
3
3
  transition-colors
4
4
  ${s?"bg-accent":"hover:bg-accent"}
5
- `,style:{paddingLeft:`${16*r+8}px`},children:[h&&(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-xs",onClick:e=>{e.stopPropagation(),n&&n()},className:"size-4",children:a?(0,t.jsx)(u,{className:"w-3 h-3 text-muted-foreground"}):(0,t.jsx)(d.default,{className:"w-3 h-3 text-muted-foreground"})}),!h&&(0,t.jsx)("div",{className:"w-3"}),(0,t.jsx)("div",{className:"text-foreground",children:(()=>{switch(e.type){case"global":return(0,t.jsx)(o,{className:"w-4 h-4"});case"owner":return(0,t.jsx)(i,{className:"w-4 h-4"});case"repo":return(0,t.jsx)(c.GitBranch,{className:"w-4 h-4"})}})()}),(0,t.jsx)("span",{className:"text-sm text-foreground truncate",children:e.label})]})}function h({selectedNode:e,onNodeSelect:a,refreshKey:r}){let[n,o]=(0,s.useState)([]),[i,c]=(0,s.useState)(new Set),[d,u]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let e=localStorage.getItem("tsunagi:env-tree-expanded");if(e)try{let t=JSON.parse(e);c(new Set(t))}catch(e){console.error("Failed to parse expanded owners:",e)}},[]),(0,s.useEffect)(()=>{localStorage.setItem("tsunagi:env-tree-expanded",JSON.stringify([...i]))},[i]),(0,s.useEffect)(()=>{(async()=>{u(!0);try{let e=await fetch((0,l.apiUrl)("/api/owners"));if(!e.ok)throw Error("Failed to fetch owners");let t=((await e.json()).data.owners||[]).map(e=>({id:`owner:${e.name}`,type:"owner",label:e.name,scope:"owner",owner:e.name,children:e.repositories.map(e=>({id:`repo:${e.owner}/${e.repo}`,type:"repo",label:e.repo,scope:"repo",owner:e.owner,repo:e.repo}))}));o([{id:"global",type:"global",label:"Global",scope:"global"},...t])}catch(e){console.error("Failed to load tree:",e)}finally{u(!1)}})()},[r]);let x=(s,r=0)=>{let l=e?.scope===s.scope&&e?.owner===s.owner&&e?.repo===s.repo,n=i.has(s.id);return(0,t.jsxs)("div",{children:[(0,t.jsx)(m,{node:s,isSelected:l,isExpanded:n,depth:r,onSelect:()=>{a({scope:s.scope,owner:s.owner,repo:s.repo,label:s.label})},onToggle:()=>{var e;return e=s.id,void c(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}}),n&&s.children?.map(e=>x(e,r+1))]},s.id)};return d?(0,t.jsx)("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."}):0===n.length?(0,t.jsx)("div",{className:"p-4 text-muted-foreground text-sm",children:"No repositories found"}):(0,t.jsx)("div",{className:"h-full overflow-y-auto",children:(0,t.jsx)("div",{className:"p-2",children:n.map(e=>x(e))})})}var p=e.i(7233),f=e.i(37727),v=e.i(43531),j=e.i(86536);let g=(0,n.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var w=e.i(27612),y=e.i(88699),N=e.i(10012);function b({variable:e,onToggle:a,onDelete:r,onUpdate:l,isDeletable:n=!0}){let[o,i]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)(e.value),k=async t=>{d(!0);try{await a(e.key,t.target.checked)}finally{d(!1)}},C=async()=>{await r(e.key)},S=async()=>{try{await l(e.key,h),m(!1)}catch(e){console.error("Failed to update variable:",e),alert("Failed to update variable")}};return(0,t.jsxs)("div",{className:"border border-border rounded p-3 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-mono text-foreground",children:e.key}),!u&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:k,disabled:c,className:"w-4 h-4 cursor-pointer"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Enabled"})]}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>i(!o),title:o?"Hide value":"Show value",children:o?(0,t.jsx)(g,{className:"w-4 h-4 text-muted-foreground"}):(0,t.jsx)(j.Eye,{className:"w-4 h-4 text-muted-foreground"})}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>{m(!0),p(e.value)},title:"Edit",children:(0,t.jsx)(y.Pencil,{className:"w-4 h-4 text-muted-foreground"})}),n&&(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:C,title:"Delete",children:(0,t.jsx)(w.Trash2,{className:"w-4 h-4 text-destructive"})})]})]}),u?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(N.Input,{type:"password",value:h,onChange:e=>p(e.target.value),className:"w-full font-mono",autoFocus:!0}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{m(!1),p(e.value)},className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:S,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]}):(0,t.jsx)("div",{children:(0,t.jsx)(N.Input,{type:o?"text":"password",value:e.value,readOnly:!0,className:"w-full font-mono"})})]})}var k=e.i(37870);let C=["ANTHROPIC_API_KEY","CLAUDE_CODE_OAUTH_TOKEN"];function S({selectedNode:e}){let[a,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(!0),[i,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!1),[m,h]=(0,s.useState)(""),[j,g]=(0,s.useState)(""),[w,y]=(0,s.useState)("");(0,s.useEffect)(()=>{(async()=>{o(!0),c(null);try{let t=new URLSearchParams({scope:e.scope});e.owner&&t.set("owner",e.owner),e.repo&&t.set("repo",e.repo);let s=await fetch((0,l.apiUrl)(`/api/env/list?${t}`));if(!s.ok)throw Error("Failed to fetch environment variables");let a=((await s.json()).data.envVars||[]).filter(e=>!C.includes(e.key));r(a)}catch(e){console.error("Failed to load environment variables:",e),c("Failed to load environment variables")}finally{o(!1)}})()},[e]);let E=async(t,s)=>{if("global"===e.scope&&!s&&("ANTHROPIC_API_KEY"===t||"CLAUDE_CODE_OAUTH_TOKEN"===t)&&!a.find(e=>e.key!==t&&("ANTHROPIC_API_KEY"===e.key||"CLAUDE_CODE_OAUTH_TOKEN"===e.key)&&e.enabled))return void alert("Cannot disable the last enabled Claude Token. Please add or enable another Claude Token first.");try{if(!(await fetch((0,l.apiUrl)("/api/env/toggle"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,scope:e.scope,owner:e.owner,repo:e.repo,enabled:s})})).ok)throw Error("Failed to toggle environment variable");r(e=>e.map(e=>e.key===t?{...e,enabled:s}:e))}catch(e){console.error("Failed to toggle environment variable:",e),r(e=>e.map(e=>e.key===t?{...e,enabled:!s}:e))}},T=async t=>{if(confirm(`Delete ${t}?`))try{let s=new URLSearchParams({key:t,scope:e.scope});if(e.owner&&s.set("owner",e.owner),e.repo&&s.set("repo",e.repo),!(await fetch((0,l.apiUrl)(`/api/env?${s}`),{method:"DELETE"})).ok)throw Error("Failed to delete environment variable");r(e=>e.filter(e=>e.key!==t))}catch(e){console.error("Failed to delete environment variable:",e),alert("Failed to delete environment variable")}},O=async(t,s)=>{try{if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,value:s,scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to update environment variable");r(e=>e.map(e=>e.key===t?{...e,value:s}:e))}catch(e){throw console.error("Failed to update environment variable:",e),e}},F=async()=>{var t;if(y(""),!m.trim())return void y("Key is required");if(!j.trim())return void y("Value is required");if(t=m.trim(),/^[A-Z0-9_]+$/.test(t)?C.includes(t)?(y("Claude tokens should be added in the Tokens section"),!1):!a.some(e=>e.key===t)||(y(`Key "${t}" already exists in this scope`),!1):(y("Key must contain only uppercase letters, numbers, and underscores"),!1))try{if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:m.trim(),value:j.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to add environment variable");let t=new URLSearchParams({scope:e.scope});e.owner&&t.set("owner",e.owner),e.repo&&t.set("repo",e.repo);let s=await fetch((0,l.apiUrl)(`/api/env/list?${t}`));if(s.ok){let e=((await s.json()).data.envVars||[]).filter(e=>!C.includes(e.key));r(e)}u(!1),h(""),g("")}catch(e){console.error("Failed to add environment variable:",e),y("Failed to add environment variable")}};return n?(0,t.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,t.jsx)(k.LoadingSpinner,{size:"md",message:"Loading variables..."})}):i?(0,t.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,t.jsx)("div",{className:"text-destructive text-sm",children:i})}):(0,t.jsxs)("div",{className:"h-full flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"Environment Variables"}),!d&&(0,t.jsxs)(x.Button,{size:"sm",onClick:()=>u(!0),className:"active:scale-95",children:[(0,t.jsx)(p.Plus,{className:"w-4 h-4"}),"Add Variable"]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-3",children:[d&&(0,t.jsxs)("div",{className:"border border-border rounded p-3 bg-accent space-y-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"New Variable"}),(0,t.jsx)(N.Input,{type:"text",value:m,onChange:e=>h(e.target.value.toUpperCase()),placeholder:"VARIABLE_NAME",className:"w-full font-mono",autoFocus:!0}),(0,t.jsx)(N.Input,{type:"password",value:j,onChange:e=>g(e.target.value),placeholder:"value",className:"w-full font-mono"}),w&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:w}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{u(!1),h(""),g(""),y("")},className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:F,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]}),0!==a.length||d?a.map(e=>(0,t.jsx)(b,{variable:e,onToggle:E,onDelete:T,onUpdate:O,isDeletable:!0},e.key)):(0,t.jsx)("div",{className:"text-center text-muted-foreground text-sm py-4",children:"No environment variables"})]})]})}var E=e.i(63209);let T=["ANTHROPIC_API_KEY","CLAUDE_CODE_OAUTH_TOKEN"],O={ANTHROPIC_API_KEY:"API Key",CLAUDE_CODE_OAUTH_TOKEN:"OAuth Token"};function F(e){return e.startsWith("sk-ant-api")?"ANTHROPIC_API_KEY":e.startsWith("sk-ant-oat")?"CLAUDE_CODE_OAUTH_TOKEN":null}function _({selectedNode:e,onboardingStatus:a,onSwitchToGlobal:r}){let[n,o]=(0,s.useState)([]),[i,c]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),[m,h]=(0,s.useState)(null),[b,C]=(0,s.useState)(""),[S,P]=(0,s.useState)(""),[U,B]=(0,s.useState)(null),[A,D]=(0,s.useState)({}),[L,z]=(0,s.useState)(!1),[I,$]=(0,s.useState)(""),[R,H]=(0,s.useState)(""),[M,K]=(0,s.useState)(null);(0,s.useEffect)(()=>{G()},[e]);let G=async()=>{c(!0),u(null);try{let t=new URLSearchParams({scope:e.scope});e.owner&&t.set("owner",e.owner),e.repo&&t.set("repo",e.repo);let s=await fetch((0,l.apiUrl)(`/api/env/list?${t}`));if(!s.ok)throw Error("Failed to fetch tokens");let a=((await s.json()).data.envVars||[]).filter(e=>T.includes(e.key)).map(e=>({key:e.key,value:e.value,label:O[e.key]||e.key}));o(a)}catch(e){console.error("Failed to load tokens:",e),u("Failed to load tokens")}finally{c(!1)}},W=()=>{h(null),C(""),P(""),B(null)},J=async t=>{if(!b.trim())return void P("Token value is required");let s=F(b);if(!s)return void P("Invalid token format");try{if(s!==t){let a=new URLSearchParams({key:t,scope:e.scope});e.owner&&a.set("owner",e.owner),e.repo&&a.set("repo",e.repo),await fetch((0,l.apiUrl)(`/api/env?${a}`),{method:"DELETE"}),await fetch((0,l.apiUrl)("/api/env"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:s,value:b.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})}else if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,value:b.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to update token");await G(),h(null),C(""),P(""),B(null)}catch(e){console.error("Failed to update token:",e),P("Failed to update token")}},V=async()=>{if(!I.trim())return void H("Token value is required");let t=F(I);if(!t)return void H("Invalid token format");if(n.length>0)return void H("Only one Claude token is allowed per scope. Please edit the existing token.");try{if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,value:I.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to add token");await G(),z(!1),$(""),K(null)}catch(e){console.error("Failed to add token:",e),H("Failed to add token")}},Y=async t=>{if(confirm("Are you sure you want to delete this token?"))try{let s=new URLSearchParams({key:t,scope:e.scope});if(e.owner&&s.set("owner",e.owner),e.repo&&s.set("repo",e.repo),!(await fetch((0,l.apiUrl)(`/api/env?${s}`),{method:"DELETE"})).ok)throw Error("Failed to delete token");await G()}catch(e){console.error("Failed to delete token:",e),alert("Failed to delete token")}};if(i)return(0,t.jsxs)("div",{className:"border-2 border-primary rounded-xl p-4 bg-card",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground mb-4",children:"Claude Tokens"}),(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(k.LoadingSpinner,{size:"sm",message:"Loading tokens..."})})]});if(d)return(0,t.jsxs)("div",{className:"border-2 border-primary rounded-xl p-4 bg-card",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground mb-4",children:"Claude Tokens"}),(0,t.jsx)("div",{className:"text-destructive text-sm",children:d})]});let q=a&&!a.completed&&"global"!==e.scope;return(0,t.jsxs)("div",{className:"border-2 border-primary rounded-xl p-4 bg-card",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"Claude Tokens"}),!L&&0===n.length&&(0,t.jsxs)(x.Button,{size:"sm",onClick:()=>z(!0),className:"active:scale-95",children:[(0,t.jsx)(p.Plus,{className:"w-4 h-4"}),"Add Token"]})]}),q&&(0,t.jsxs)("div",{className:"mb-4 border-2 border-warning bg-warning/10 rounded-xl p-3 flex items-start gap-3",children:[(0,t.jsx)(E.AlertCircle,{className:"w-5 h-5 text-warning flex-shrink-0 mt-0.5"}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("p",{className:"text-sm text-warning",children:"オンボーディングを完了するには、Globalスコープにトークンを追加してください"})}),r&&(0,t.jsx)(x.Button,{size:"sm",onClick:r,className:"bg-warning text-white hover:bg-warning/80 active:scale-95 whitespace-nowrap",children:"Switch to Global"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[L&&(0,t.jsxs)("div",{className:"border border-border rounded p-3 bg-accent",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:"New Token"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(N.Input,{type:"password",value:I,onChange:e=>{var t;let s;return $(t=e.target.value),H(""),void(K(s=F(t)),t&&!s&&H("Invalid token format. Must start with sk-ant-api or sk-ant-oat"))},placeholder:"sk-ant-api... or sk-ant-oat...",className:"w-full font-mono",autoFocus:!0}),M&&!R&&(0,t.jsxs)("div",{className:"text-xs text-success",children:["→ Detected: ",O[M]]}),R&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:R}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{z(!1),$(""),H(""),K(null)},className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:V,disabled:!M||!!R,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]})]}),0!==n.length||L?n.map(s=>(0,t.jsx)("div",{className:"border border-border rounded p-3 space-y-2",children:m===s.key?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:"Edit Token"}),(0,t.jsx)(N.Input,{type:"password",value:b,onChange:e=>{var t;let s;return C(t=e.target.value),P(""),void(B(s=F(t)),t&&!s&&P("Invalid token format. Must start with sk-ant-api or sk-ant-oat"))},placeholder:"sk-ant-api... or sk-ant-oat...",className:"w-full font-mono",autoFocus:!0}),U&&!S&&(0,t.jsxs)("div",{className:"text-xs text-success",children:["→ Detected: ",O[U]]}),S&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:S}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:W,className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:()=>J(s.key),disabled:!U||!!S,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>D(e=>({...e,[s.key]:!e[s.key]})),title:A[s.key]?"Hide value":"Show value",children:A[s.key]?(0,t.jsx)(g,{className:"w-4 h-4 text-muted-foreground"}):(0,t.jsx)(j.Eye,{className:"w-4 h-4 text-muted-foreground"})}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>{h(s.key),C(""),P(""),B(null)},title:"Edit",children:(0,t.jsx)(y.Pencil,{className:"w-4 h-4 text-muted-foreground"})}),"global"!==e.scope&&(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>Y(s.key),className:"hover:bg-destructive/10",title:"Delete",children:(0,t.jsx)(w.Trash2,{className:"w-4 h-4 text-destructive"})})]})]}),(0,t.jsx)(N.Input,{type:A[s.key]?"text":"password",value:s.value,readOnly:!0,className:"w-full font-mono"})]})},s.key)):(0,t.jsx)("div",{className:"text-center text-muted-foreground text-sm py-4",children:"No Claude tokens configured"})]})]})}var P=e.i(5352),U=e.i(68995);function B(){let[e,a]=(0,s.useState)([]),[r,n]=(0,s.useState)({}),[o,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),u=(0,s.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch((0,l.apiUrl)("/api/repos")).then(e=>e.json()),fetch((0,l.apiUrl)("/api/tasks")).then(e=>e.json())]);a(e.data?.repos??[]);let s={};for(let e of t.data?.tasks??[]){let t=`${e.owner}/${e.repo}`;s[t]=(s[t]??0)+1}n(s)}catch(e){console.error("Failed to load repositories:",e)}},[]);(0,s.useEffect)(()=>{u()},[u]);let m=async()=>{if(o){d(!0);try{if(!(await fetch((0,l.apiUrl)(`/api/repos/${o.owner}/${o.repo}`),{method:"DELETE"})).ok)throw Error("Failed to delete repository");await u()}catch(e){console.error("Failed to delete repository:",e)}finally{d(!1),i(null)}}};return 0===e.length?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"No repositories cloned yet."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.ConfirmDialog,{open:null!==o,onOpenChange:e=>{e.open||i(null)},title:"Delete Repository",message:o?`Delete ${o.owner}/${o.repo}? This will also delete ${r[`${o.owner}/${o.repo}`]??0} associated task(s), all worktrees, and the bare repository. This action cannot be undone.`:"",confirmLabel:c?"Deleting...":"Delete",cancelLabel:"Cancel",onConfirm:m,variant:"danger"}),(0,t.jsx)("div",{className:"space-y-2",children:e.map(e=>{let s=`${e.owner}/${e.repo}`,a=(0,P.getRepoColor)(e.owner,e.repo),l=r[s]??0;return(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${a.bg} ${a.text}`,children:s}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l," task",1!==l?"s":""]})]}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon",onClick:()=>i(e),className:"text-muted-foreground hover:text-destructive",children:(0,t.jsx)(w.Trash2,{className:"size-4"})})]},e.id)})})]})}var A=e.i(69068);function D({owner:e,repo:a,onDeleted:r}){let[n,o]=(0,s.useState)(!1),[i,c]=(0,s.useState)(""),[d,u]=(0,s.useState)(!1),m=`${e}/${a}`,h=i===m,p=async()=>{if(h){u(!0);try{if(!(await fetch((0,l.apiUrl)(`/api/repos/${e}/${a}`),{method:"DELETE"})).ok)throw Error("Failed to delete repository");r()}catch(e){console.error("Failed to delete repository:",e)}finally{u(!1),o(!1),c("")}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"rounded-md border border-destructive/30 p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-destructive",children:"Remove Repository"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Remove this repository and all associated data including tasks, worktrees, and environment variables. This action cannot be undone."})]}),(0,t.jsxs)(x.Button,{variant:"destructive",size:"sm",onClick:()=>o(!0),children:[(0,t.jsx)(w.Trash2,{className:"size-4"}),"Remove Repository"]})]}),(0,t.jsx)(A.Dialog,{open:n,onOpenChange:o,children:(0,t.jsxs)(A.DialogContent,{showCloseButton:!1,children:[(0,t.jsxs)(A.DialogHeader,{children:[(0,t.jsx)(A.DialogTitle,{children:"Remove Repository"}),(0,t.jsxs)(A.DialogDescription,{children:["This will permanently delete ",(0,t.jsx)("strong",{children:m})," and all associated tasks, worktrees, and environment variables."]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("label",{className:"text-xs text-muted-foreground",children:["Type ",(0,t.jsx)("strong",{children:m})," to confirm"]}),(0,t.jsx)(N.Input,{value:i,onChange:e=>c(e.target.value),placeholder:m,autoComplete:"off"})]}),(0,t.jsxs)(A.DialogFooter,{children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{o(!1),c("")},disabled:d,children:"Cancel"}),(0,t.jsx)(x.Button,{variant:"destructive",size:"sm",onClick:p,disabled:!h||d,children:d?"Removing...":"Remove"})]})]})})]})}var L=e.i(95468),z=e.i(58e3),I=e.i(31278),$=e.i(87951),R=e.i(52044),H=e.i(64036),M=e.i(77814),K=e.i(41247),G=e.i(57024),W=e.i(31449);let J="tsunagi:voice-input-enabled",V={not_running:"停止中",installing_deps:"依存関係をインストール中...",downloading_model:"モデルをダウンロード中...",starting_server:"サーバーを起動中...",running:"実行中",running_external:"実行中 (tsunagi外で起動)",error:"エラー"},Y=["installing_deps","downloading_model","starting_server"],q=["running","running_external"];function X(e){let t=e/0x40000000;return t>=.1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(0)} MB`}function Z(){let[e,a]=(0,s.useState)(!1),[r,n]=(0,s.useState)(!1),[o,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(""),u=(0,s.useRef)(null),m=(0,s.useCallback)(e=>{a(e),localStorage.setItem(J,String(e))},[]),h=(0,s.useCallback)(e=>{d(e),localStorage.setItem(W.WHISPER_PROMPT_STORAGE_KEY,e)},[]),p=(0,s.useCallback)(async()=>{let e=await fetch((0,l.apiUrl)("/api/whisper/server/status")),t=await e.json();return i(t),t},[]);(0,s.useEffect)(()=>{a("true"===localStorage.getItem(J)),d(localStorage.getItem(W.WHISPER_PROMPT_STORAGE_KEY)??""),p()},[p]),(0,s.useEffect)(()=>{o&&q.includes(o.step)&&!e&&(m(!0),G.toaster.create({type:"success",title:"音声入力が有効化されました"}))},[o,e,m]),(0,s.useEffect)(()=>(o&&Y.includes(o.step)&&!u.current&&(u.current=setInterval(()=>{p().then(e=>{!Y.includes(e.step)&&u.current&&(clearInterval(u.current),u.current=null)})},1e3)),()=>{u.current&&(clearInterval(u.current),u.current=null)}),[o,p]);let f=(0,s.useCallback)(()=>{p(),n(!0)},[p]),v=(0,s.useCallback)(async()=>{try{let e=await fetch((0,l.apiUrl)("/api/whisper/server/start"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}i(await e.json())}catch(e){G.toaster.create({type:"error",title:"サーバーの起動に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),j=(0,s.useCallback)(async()=>{try{let e=await fetch((0,l.apiUrl)("/api/whisper/server/stop"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}i(await e.json())}catch(e){G.toaster.create({type:"error",title:"サーバーの停止に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),g=(0,s.useCallback)(()=>{m(!1),o&&q.includes(o.step)&&j()},[m,j,o]),w=o?.serverDir,y=o?.downloadProgress,N=y?y.downloadedBytes/y.totalBytes*100:0;return(0,t.jsxs)(H.Card,{children:[(0,t.jsxs)(H.CardHeader,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(H.CardTitle,{children:"音声入力 (実験的機能)"}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-sm",onClick:f,title:"音声入力について",children:(0,t.jsx)(z.CircleHelp,{})})]}),(0,t.jsx)(H.CardDescription,{children:"ローカルで動作するWhisperを使って音声入力を行います。下記のローカルLLMも有効にすると、 文字起こし結果がLLMで自動整形されます(無効時は文字起こし結果をそのまま使用)。"})]}),(0,t.jsx)(H.CardContent,{className:"flex flex-col gap-3",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(L.CheckCircle2,{className:"size-4"}),"音声入力: 有効"]}),o&&(0,t.jsxs)("span",{className:"text-xs/relaxed text-muted-foreground",children:["(",V[o.step],")"]}),(0,t.jsx)(x.Button,{size:"default",variant:"outline",onClick:g,children:"無効にする"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-1 block text-xs font-medium text-muted-foreground",children:"文字起こしプロンプト (任意)"}),(0,t.jsx)(K.Textarea,{value:c,onChange:e=>h(e.target.value),placeholder:"例: 句読点を適切に打ってください。固有名詞は正確に表記してください。",className:"min-h-16 text-xs"}),(0,t.jsx)("p",{className:"mt-1 text-[0.65rem] text-muted-foreground",children:"Whisperの文字起こしスタイル(表記ゆれ・句読点・固有名詞など)を誘導するヒントです。空でも構いません。"})]})]}):(0,t.jsxs)(x.Button,{size:"default",onClick:f,children:[(0,t.jsx)($.Mic,{}),"音声入力を有効化する"]})}),(0,t.jsx)(U.Dialog,{open:r,onOpenChange:({open:e})=>n(e),title:"音声入力について",maxWidth:"2xl",children:(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"実験的機能です"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"音声入力はローカルで動作するWhisper (mlx-whisper) を利用します。精度・速度は環境に依存し、今後変更される可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"対応環境"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Apple Silicon Mac (M1/M2/M3/M4) のみ対応。Windows/Linuxでは利用できません。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"必要なもの(事前に手動でインストール)"}),(0,t.jsx)("ul",{className:"list-disc pl-5 text-muted-foreground",children:(0,t.jsx)("li",{children:"Python 3.9以降(Xcode Command Line Tools または Homebrew経由で入手可能)"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"セットアップ・起動"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"下のボタンから、依存関係のインストール・モデルのダウンロード・サーバー起動まで自動で行われます(初回は数分かかります)。"}),o&&!w&&(0,t.jsx)("p",{className:"mt-1 text-destructive",children:"whisper-serverが見つかりませんでした。インストールが壊れている可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"アンインストール"}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:["音声入力のためにダウンロードされるもの(Pythonの依存関係・Whisperモデル、合計約2.6GB)は全て",(0,t.jsx)("code",{className:"rounded bg-muted px-1",children:"~/.tsunagi/whisper"}),"に保存されます。不要になった場合はこのディレクトリを削除するだけで、関連リソースを完全に削除できます。"]})]}),(0,t.jsxs)("div",{className:"border-t border-border pt-4",children:[(!o||"not_running"===o.step||"error"===o.step)&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)(x.Button,{size:"default",onClick:()=>void v(),disabled:!o,children:[o?(0,t.jsx)($.Mic,{}):(0,t.jsx)(I.Loader2,{className:"animate-spin"}),"Whisperサーバーを起動"]}),o?.step==="error"&&o.error&&(0,t.jsx)("p",{className:"text-xs/relaxed text-destructive",children:o.error})]}),o?.step==="installing_deps"&&(0,t.jsxs)(x.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(I.Loader2,{className:"animate-spin"}),"依存関係をインストール中... (数分かかる場合があります)"]}),o?.step==="downloading_model"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs/relaxed text-muted-foreground",children:[(0,t.jsx)(I.Loader2,{className:"size-4 animate-spin"}),"モデルをダウンロード中..."]}),y&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M.Progress,{value:N}),(0,t.jsxs)("p",{className:"text-xs/relaxed text-muted-foreground",children:[X(y.downloadedBytes)," / ",X(y.totalBytes)," (",N.toFixed(0),"%) ・ ",function(e){if(null===e)return"残り時間を計算中...";if(e<60)return`残り約${e}秒`;let t=Math.floor(e/60);return`残り約${t}分${e%60}秒`}(y.etaSeconds)]})]})]}),o?.step==="starting_server"&&(0,t.jsxs)(x.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(I.Loader2,{className:"animate-spin"}),"サーバーを起動中..."]}),o&&q.includes(o.step)&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(L.CheckCircle2,{className:"size-4"}),"サーバーは起動しています"]}),(0,t.jsxs)(x.Button,{size:"default",variant:"outline",onClick:()=>void j(),children:[(0,t.jsx)(R.Square,{}),"サーバーを停止"]})]})]})]})})]})}var Q=e.i(66961),ee=e.i(51846);e.s(["default",0,function(){let e=(0,a.useRouter)();(0,ee.useDocumentTitle)("settings");let n=()=>{{let e=localStorage.getItem("tsunagi:env-selected-node");if(e)try{return JSON.parse(e)}catch(e){console.error("Failed to parse selected node:",e)}}return{scope:"global",label:"Global"}},[o,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(0),[u,m]=(0,s.useState)({completed:!0,hasGlobalToken:!0});return(0,s.useEffect)(()=>{fetch((0,l.apiUrl)("/api/onboarding/status")).then(e=>e.json()).then(e=>{let t=e.data;m(t),t.completed||t.hasGlobalToken?i(n()):i({scope:"global",label:"Global"})}).catch(e=>{console.error("Failed to fetch onboarding status:",e),i(n())})},[]),(0,s.useEffect)(()=>{o&&localStorage.setItem("tsunagi:env-selected-node",JSON.stringify(o))},[o]),(0,t.jsxs)("div",{className:"h-screen flex flex-col bg-background",children:[(0,t.jsx)("div",{className:"sticky top-0 z-50 p-4 border-b border-border bg-card",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)(x.Button,{variant:"ghost",onClick:()=>e.push("/"),className:"text-primary font-medium hover:bg-primary/10 hover:text-foreground",children:[(0,t.jsx)(r.ArrowLeft,{className:"w-4 h-4"}),"Back to Board"]}),(0,t.jsx)("h1",{className:"text-xl font-bold text-foreground absolute left-1/2 -translate-x-1/2",children:"Settings"})]})}),(0,t.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,t.jsx)("div",{className:"w-64 border-r border-border bg-card",children:(0,t.jsx)(h,{selectedNode:o,onNodeSelect:e=>{i(e)},refreshKey:c})}),(0,t.jsx)("div",{className:"flex-1 bg-card p-4 overflow-y-auto",children:o?(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(_,{selectedNode:o,onboardingStatus:u,onSwitchToGlobal:()=>{i({scope:"global",label:"Global"})}}),(0,t.jsx)(S,{selectedNode:o}),"global"===o.scope&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Repositories"}),(0,t.jsx)(B,{})]}),"global"===o.scope&&(0,t.jsx)(Z,{}),"global"===o.scope&&(0,t.jsx)(Q.LocalLlmSection,{}),"repo"===o.scope&&o.owner&&o.repo&&(0,t.jsx)(D,{owner:o.owner,repo:o.repo,onDeleted:()=>{i({scope:"global",label:"Global"}),d(e=>e+1)}})]}):(0,t.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Select a node from the left panel"})})]})]})}],82341)}]);
5
+ `,style:{paddingLeft:`${16*r+8}px`},children:[p&&(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-xs",onClick:e=>{e.stopPropagation(),n&&n()},className:"size-4",children:a?(0,t.jsx)(u,{className:"w-3 h-3 text-muted-foreground"}):(0,t.jsx)(d.default,{className:"w-3 h-3 text-muted-foreground"})}),!p&&(0,t.jsx)("div",{className:"w-3"}),(0,t.jsx)("div",{className:"text-foreground",children:(()=>{switch(e.type){case"global":return(0,t.jsx)(o,{className:"w-4 h-4"});case"owner":return(0,t.jsx)(i,{className:"w-4 h-4"});case"repo":return(0,t.jsx)(c.GitBranch,{className:"w-4 h-4"})}})()}),(0,t.jsx)("span",{className:"text-sm text-foreground truncate",children:e.label})]})}function p({selectedNode:e,onNodeSelect:a,refreshKey:r}){let[n,o]=(0,s.useState)([]),[i,c]=(0,s.useState)(new Set),[d,u]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let e=localStorage.getItem("tsunagi:env-tree-expanded");if(e)try{let t=JSON.parse(e);c(new Set(t))}catch(e){console.error("Failed to parse expanded owners:",e)}},[]),(0,s.useEffect)(()=>{localStorage.setItem("tsunagi:env-tree-expanded",JSON.stringify([...i]))},[i]),(0,s.useEffect)(()=>{(async()=>{u(!0);try{let e=await fetch((0,l.apiUrl)("/api/owners"));if(!e.ok)throw Error("Failed to fetch owners");let t=((await e.json()).data.owners||[]).map(e=>({id:`owner:${e.name}`,type:"owner",label:e.name,scope:"owner",owner:e.name,children:e.repositories.map(e=>({id:`repo:${e.owner}/${e.repo}`,type:"repo",label:e.repo,scope:"repo",owner:e.owner,repo:e.repo}))}));o([{id:"global",type:"global",label:"Global",scope:"global"},...t])}catch(e){console.error("Failed to load tree:",e)}finally{u(!1)}})()},[r]);let x=(s,r=0)=>{let l=e?.scope===s.scope&&e?.owner===s.owner&&e?.repo===s.repo,n=i.has(s.id);return(0,t.jsxs)("div",{children:[(0,t.jsx)(m,{node:s,isSelected:l,isExpanded:n,depth:r,onSelect:()=>{a({scope:s.scope,owner:s.owner,repo:s.repo,label:s.label})},onToggle:()=>{var e;return e=s.id,void c(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}}),n&&s.children?.map(e=>x(e,r+1))]},s.id)};return d?(0,t.jsx)("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."}):0===n.length?(0,t.jsx)("div",{className:"p-4 text-muted-foreground text-sm",children:"No repositories found"}):(0,t.jsx)("div",{className:"h-full overflow-y-auto",children:(0,t.jsx)("div",{className:"p-2",children:n.map(e=>x(e))})})}var h=e.i(7233),f=e.i(37727),v=e.i(43531),j=e.i(86536);let g=(0,n.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var w=e.i(27612),y=e.i(88699),N=e.i(10012);function b({variable:e,onToggle:a,onDelete:r,onUpdate:l,isDeletable:n=!0}){let[o,i]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.useState)(e.value),k=async t=>{d(!0);try{await a(e.key,t.target.checked)}finally{d(!1)}},C=async()=>{await r(e.key)},S=async()=>{try{await l(e.key,p),m(!1)}catch(e){console.error("Failed to update variable:",e),alert("Failed to update variable")}};return(0,t.jsxs)("div",{className:"border border-border rounded p-3 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-mono text-foreground",children:e.key}),!u&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:k,disabled:c,className:"w-4 h-4 cursor-pointer"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Enabled"})]}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>i(!o),title:o?"Hide value":"Show value",children:o?(0,t.jsx)(g,{className:"w-4 h-4 text-muted-foreground"}):(0,t.jsx)(j.Eye,{className:"w-4 h-4 text-muted-foreground"})}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>{m(!0),h(e.value)},title:"Edit",children:(0,t.jsx)(y.Pencil,{className:"w-4 h-4 text-muted-foreground"})}),n&&(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:C,title:"Delete",children:(0,t.jsx)(w.Trash2,{className:"w-4 h-4 text-destructive"})})]})]}),u?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(N.Input,{type:"password",value:p,onChange:e=>h(e.target.value),className:"w-full font-mono",autoFocus:!0}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{m(!1),h(e.value)},className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:S,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]}):(0,t.jsx)("div",{children:(0,t.jsx)(N.Input,{type:o?"text":"password",value:e.value,readOnly:!0,className:"w-full font-mono"})})]})}var k=e.i(37870);let C=["ANTHROPIC_API_KEY","CLAUDE_CODE_OAUTH_TOKEN"];function S({selectedNode:e}){let[a,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(!0),[i,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(""),[j,g]=(0,s.useState)(""),[w,y]=(0,s.useState)("");(0,s.useEffect)(()=>{(async()=>{o(!0),c(null);try{let t=new URLSearchParams({scope:e.scope});e.owner&&t.set("owner",e.owner),e.repo&&t.set("repo",e.repo);let s=await fetch((0,l.apiUrl)(`/api/env/list?${t}`));if(!s.ok)throw Error("Failed to fetch environment variables");let a=((await s.json()).data.envVars||[]).filter(e=>!C.includes(e.key));r(a)}catch(e){console.error("Failed to load environment variables:",e),c("Failed to load environment variables")}finally{o(!1)}})()},[e]);let E=async(t,s)=>{if("global"===e.scope&&!s&&("ANTHROPIC_API_KEY"===t||"CLAUDE_CODE_OAUTH_TOKEN"===t)&&!a.find(e=>e.key!==t&&("ANTHROPIC_API_KEY"===e.key||"CLAUDE_CODE_OAUTH_TOKEN"===e.key)&&e.enabled))return void alert("Cannot disable the last enabled Claude Token. Please add or enable another Claude Token first.");try{if(!(await fetch((0,l.apiUrl)("/api/env/toggle"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,scope:e.scope,owner:e.owner,repo:e.repo,enabled:s})})).ok)throw Error("Failed to toggle environment variable");r(e=>e.map(e=>e.key===t?{...e,enabled:s}:e))}catch(e){console.error("Failed to toggle environment variable:",e),r(e=>e.map(e=>e.key===t?{...e,enabled:!s}:e))}},T=async t=>{if(confirm(`Delete ${t}?`))try{let s=new URLSearchParams({key:t,scope:e.scope});if(e.owner&&s.set("owner",e.owner),e.repo&&s.set("repo",e.repo),!(await fetch((0,l.apiUrl)(`/api/env?${s}`),{method:"DELETE"})).ok)throw Error("Failed to delete environment variable");r(e=>e.filter(e=>e.key!==t))}catch(e){console.error("Failed to delete environment variable:",e),alert("Failed to delete environment variable")}},O=async(t,s)=>{try{if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,value:s,scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to update environment variable");r(e=>e.map(e=>e.key===t?{...e,value:s}:e))}catch(e){throw console.error("Failed to update environment variable:",e),e}},F=async()=>{var t;if(y(""),!m.trim())return void y("Key is required");if(!j.trim())return void y("Value is required");if(t=m.trim(),/^[A-Z0-9_]+$/.test(t)?C.includes(t)?(y("Claude tokens should be added in the Tokens section"),!1):!a.some(e=>e.key===t)||(y(`Key "${t}" already exists in this scope`),!1):(y("Key must contain only uppercase letters, numbers, and underscores"),!1))try{if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:m.trim(),value:j.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to add environment variable");let t=new URLSearchParams({scope:e.scope});e.owner&&t.set("owner",e.owner),e.repo&&t.set("repo",e.repo);let s=await fetch((0,l.apiUrl)(`/api/env/list?${t}`));if(s.ok){let e=((await s.json()).data.envVars||[]).filter(e=>!C.includes(e.key));r(e)}u(!1),p(""),g("")}catch(e){console.error("Failed to add environment variable:",e),y("Failed to add environment variable")}};return n?(0,t.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,t.jsx)(k.LoadingSpinner,{size:"md",message:"Loading variables..."})}):i?(0,t.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,t.jsx)("div",{className:"text-destructive text-sm",children:i})}):(0,t.jsxs)("div",{className:"h-full flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"Environment Variables"}),!d&&(0,t.jsxs)(x.Button,{size:"sm",onClick:()=>u(!0),className:"active:scale-95",children:[(0,t.jsx)(h.Plus,{className:"w-4 h-4"}),"Add Variable"]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-3",children:[d&&(0,t.jsxs)("div",{className:"border border-border rounded p-3 bg-accent space-y-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"New Variable"}),(0,t.jsx)(N.Input,{type:"text",value:m,onChange:e=>p(e.target.value.toUpperCase()),placeholder:"VARIABLE_NAME",className:"w-full font-mono",autoFocus:!0}),(0,t.jsx)(N.Input,{type:"password",value:j,onChange:e=>g(e.target.value),placeholder:"value",className:"w-full font-mono"}),w&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:w}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{u(!1),p(""),g(""),y("")},className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:F,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]}),0!==a.length||d?a.map(e=>(0,t.jsx)(b,{variable:e,onToggle:E,onDelete:T,onUpdate:O,isDeletable:!0},e.key)):(0,t.jsx)("div",{className:"text-center text-muted-foreground text-sm py-4",children:"No environment variables"})]})]})}var E=e.i(63209);let T=["ANTHROPIC_API_KEY","CLAUDE_CODE_OAUTH_TOKEN"],O={ANTHROPIC_API_KEY:"API Key",CLAUDE_CODE_OAUTH_TOKEN:"OAuth Token"};function F(e){return e.startsWith("sk-ant-api")?"ANTHROPIC_API_KEY":e.startsWith("sk-ant-oat")?"CLAUDE_CODE_OAUTH_TOKEN":null}function _({selectedNode:e,onboardingStatus:a,onSwitchToGlobal:r}){let[n,o]=(0,s.useState)([]),[i,c]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)(null),[b,C]=(0,s.useState)(""),[S,P]=(0,s.useState)(""),[B,U]=(0,s.useState)(null),[A,z]=(0,s.useState)({}),[D,L]=(0,s.useState)(!1),[I,$]=(0,s.useState)(""),[R,H]=(0,s.useState)(""),[M,K]=(0,s.useState)(null);(0,s.useEffect)(()=>{G()},[e]);let G=async()=>{c(!0),u(null);try{let t=new URLSearchParams({scope:e.scope});e.owner&&t.set("owner",e.owner),e.repo&&t.set("repo",e.repo);let s=await fetch((0,l.apiUrl)(`/api/env/list?${t}`));if(!s.ok)throw Error("Failed to fetch tokens");let a=((await s.json()).data.envVars||[]).filter(e=>T.includes(e.key)).map(e=>({key:e.key,value:e.value,label:O[e.key]||e.key}));o(a)}catch(e){console.error("Failed to load tokens:",e),u("Failed to load tokens")}finally{c(!1)}},W=()=>{p(null),C(""),P(""),U(null)},J=async t=>{if(!b.trim())return void P("Token value is required");let s=F(b);if(!s)return void P("Invalid token format");try{if(s!==t){let a=new URLSearchParams({key:t,scope:e.scope});e.owner&&a.set("owner",e.owner),e.repo&&a.set("repo",e.repo),await fetch((0,l.apiUrl)(`/api/env?${a}`),{method:"DELETE"}),await fetch((0,l.apiUrl)("/api/env"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:s,value:b.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})}else if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,value:b.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to update token");await G(),p(null),C(""),P(""),U(null)}catch(e){console.error("Failed to update token:",e),P("Failed to update token")}},V=async()=>{if(!I.trim())return void H("Token value is required");let t=F(I);if(!t)return void H("Invalid token format");if(n.length>0)return void H("Only one Claude token is allowed per scope. Please edit the existing token.");try{if(!(await fetch((0,l.apiUrl)("/api/env"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t,value:I.trim(),scope:e.scope,owner:e.owner,repo:e.repo})})).ok)throw Error("Failed to add token");await G(),L(!1),$(""),K(null)}catch(e){console.error("Failed to add token:",e),H("Failed to add token")}},Y=async t=>{if(confirm("Are you sure you want to delete this token?"))try{let s=new URLSearchParams({key:t,scope:e.scope});if(e.owner&&s.set("owner",e.owner),e.repo&&s.set("repo",e.repo),!(await fetch((0,l.apiUrl)(`/api/env?${s}`),{method:"DELETE"})).ok)throw Error("Failed to delete token");await G()}catch(e){console.error("Failed to delete token:",e),alert("Failed to delete token")}};if(i)return(0,t.jsxs)("div",{className:"border-2 border-primary rounded-xl p-4 bg-card",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground mb-4",children:"Claude Tokens"}),(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(k.LoadingSpinner,{size:"sm",message:"Loading tokens..."})})]});if(d)return(0,t.jsxs)("div",{className:"border-2 border-primary rounded-xl p-4 bg-card",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground mb-4",children:"Claude Tokens"}),(0,t.jsx)("div",{className:"text-destructive text-sm",children:d})]});let q=a&&!a.completed&&"global"!==e.scope;return(0,t.jsxs)("div",{className:"border-2 border-primary rounded-xl p-4 bg-card",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"Claude Tokens"}),!D&&0===n.length&&(0,t.jsxs)(x.Button,{size:"sm",onClick:()=>L(!0),className:"active:scale-95",children:[(0,t.jsx)(h.Plus,{className:"w-4 h-4"}),"Add Token"]})]}),q&&(0,t.jsxs)("div",{className:"mb-4 border-2 border-warning bg-warning/10 rounded-xl p-3 flex items-start gap-3",children:[(0,t.jsx)(E.AlertCircle,{className:"w-5 h-5 text-warning flex-shrink-0 mt-0.5"}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("p",{className:"text-sm text-warning",children:"オンボーディングを完了するには、Globalスコープにトークンを追加してください"})}),r&&(0,t.jsx)(x.Button,{size:"sm",onClick:r,className:"bg-warning text-white hover:bg-warning/80 active:scale-95 whitespace-nowrap",children:"Switch to Global"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[D&&(0,t.jsxs)("div",{className:"border border-border rounded p-3 bg-accent",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:"New Token"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(N.Input,{type:"password",value:I,onChange:e=>{var t;let s;return $(t=e.target.value),H(""),void(K(s=F(t)),t&&!s&&H("Invalid token format. Must start with sk-ant-api or sk-ant-oat"))},placeholder:"sk-ant-api... or sk-ant-oat...",className:"w-full font-mono",autoFocus:!0}),M&&!R&&(0,t.jsxs)("div",{className:"text-xs text-success",children:["→ Detected: ",O[M]]}),R&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:R}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{L(!1),$(""),H(""),K(null)},className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:V,disabled:!M||!!R,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]})]}),0!==n.length||D?n.map(s=>(0,t.jsx)("div",{className:"border border-border rounded p-3 space-y-2",children:m===s.key?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:"Edit Token"}),(0,t.jsx)(N.Input,{type:"password",value:b,onChange:e=>{var t;let s;return C(t=e.target.value),P(""),void(U(s=F(t)),t&&!s&&P("Invalid token format. Must start with sk-ant-api or sk-ant-oat"))},placeholder:"sk-ant-api... or sk-ant-oat...",className:"w-full font-mono",autoFocus:!0}),B&&!S&&(0,t.jsxs)("div",{className:"text-xs text-success",children:["→ Detected: ",O[B]]}),S&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:S}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:W,className:"active:scale-95",children:(0,t.jsx)(f.X,{className:"w-4 h-4"})}),(0,t.jsx)(x.Button,{size:"sm",onClick:()=>J(s.key),disabled:!B||!!S,className:"active:scale-95",children:(0,t.jsx)(v.Check,{className:"w-4 h-4"})})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>z(e=>({...e,[s.key]:!e[s.key]})),title:A[s.key]?"Hide value":"Show value",children:A[s.key]?(0,t.jsx)(g,{className:"w-4 h-4 text-muted-foreground"}):(0,t.jsx)(j.Eye,{className:"w-4 h-4 text-muted-foreground"})}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>{p(s.key),C(""),P(""),U(null)},title:"Edit",children:(0,t.jsx)(y.Pencil,{className:"w-4 h-4 text-muted-foreground"})}),"global"!==e.scope&&(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-lg",onClick:()=>Y(s.key),className:"hover:bg-destructive/10",title:"Delete",children:(0,t.jsx)(w.Trash2,{className:"w-4 h-4 text-destructive"})})]})]}),(0,t.jsx)(N.Input,{type:A[s.key]?"text":"password",value:s.value,readOnly:!0,className:"w-full font-mono"})]})},s.key)):(0,t.jsx)("div",{className:"text-center text-muted-foreground text-sm py-4",children:"No Claude tokens configured"})]})]})}var P=e.i(5352),B=e.i(68995);function U(){let[e,a]=(0,s.useState)([]),[r,n]=(0,s.useState)({}),[o,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),u=(0,s.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch((0,l.apiUrl)("/api/repos")).then(e=>e.json()),fetch((0,l.apiUrl)("/api/tasks")).then(e=>e.json())]);a(e.data?.repos??[]);let s={};for(let e of t.data?.tasks??[]){let t=`${e.owner}/${e.repo}`;s[t]=(s[t]??0)+1}n(s)}catch(e){console.error("Failed to load repositories:",e)}},[]);(0,s.useEffect)(()=>{u()},[u]);let m=async()=>{if(o){d(!0);try{if(!(await fetch((0,l.apiUrl)(`/api/repos/${o.owner}/${o.repo}`),{method:"DELETE"})).ok)throw Error("Failed to delete repository");await u()}catch(e){console.error("Failed to delete repository:",e)}finally{d(!1),i(null)}}};return 0===e.length?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"No repositories cloned yet."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(B.ConfirmDialog,{open:null!==o,onOpenChange:e=>{e.open||i(null)},title:"Delete Repository",message:o?`Delete ${o.owner}/${o.repo}? This will also delete ${r[`${o.owner}/${o.repo}`]??0} associated task(s), all worktrees, and the bare repository. This action cannot be undone.`:"",confirmLabel:c?"Deleting...":"Delete",cancelLabel:"Cancel",onConfirm:m,variant:"danger"}),(0,t.jsx)("div",{className:"space-y-2",children:e.map(e=>{let s=`${e.owner}/${e.repo}`,a=(0,P.getRepoColor)(e.owner,e.repo),l=r[s]??0;return(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${a.bg} ${a.text}`,children:s}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[l," task",1!==l?"s":""]})]}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon",onClick:()=>i(e),className:"text-muted-foreground hover:text-destructive",children:(0,t.jsx)(w.Trash2,{className:"size-4"})})]},e.id)})})]})}var A=e.i(69068);function z({owner:e,repo:a,onDeleted:r}){let[n,o]=(0,s.useState)(!1),[i,c]=(0,s.useState)(""),[d,u]=(0,s.useState)(!1),m=`${e}/${a}`,p=i===m,h=async()=>{if(p){u(!0);try{if(!(await fetch((0,l.apiUrl)(`/api/repos/${e}/${a}`),{method:"DELETE"})).ok)throw Error("Failed to delete repository");r()}catch(e){console.error("Failed to delete repository:",e)}finally{u(!1),o(!1),c("")}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"rounded-md border border-destructive/30 p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-destructive",children:"Remove Repository"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Remove this repository and all associated data including tasks, worktrees, and environment variables. This action cannot be undone."})]}),(0,t.jsxs)(x.Button,{variant:"destructive",size:"sm",onClick:()=>o(!0),children:[(0,t.jsx)(w.Trash2,{className:"size-4"}),"Remove Repository"]})]}),(0,t.jsx)(A.Dialog,{open:n,onOpenChange:o,children:(0,t.jsxs)(A.DialogContent,{showCloseButton:!1,children:[(0,t.jsxs)(A.DialogHeader,{children:[(0,t.jsx)(A.DialogTitle,{children:"Remove Repository"}),(0,t.jsxs)(A.DialogDescription,{children:["This will permanently delete ",(0,t.jsx)("strong",{children:m})," and all associated tasks, worktrees, and environment variables."]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("label",{className:"text-xs text-muted-foreground",children:["Type ",(0,t.jsx)("strong",{children:m})," to confirm"]}),(0,t.jsx)(N.Input,{value:i,onChange:e=>c(e.target.value),placeholder:m,autoComplete:"off"})]}),(0,t.jsxs)(A.DialogFooter,{children:[(0,t.jsx)(x.Button,{variant:"outline",size:"sm",onClick:()=>{o(!1),c("")},disabled:d,children:"Cancel"}),(0,t.jsx)(x.Button,{variant:"destructive",size:"sm",onClick:h,disabled:!p||d,children:d?"Removing...":"Remove"})]})]})})]})}var D=e.i(95468),L=e.i(58e3),I=e.i(31278),$=e.i(87951),R=e.i(52044),H=e.i(64036),M=e.i(77814),K=e.i(41247),G=e.i(57024),W=e.i(31449);let J="tsunagi:voice-input-enabled",V={not_running:"停止中",installing_deps:"依存関係をインストール中...",downloading_model:"モデルをダウンロード中...",starting_server:"サーバーを起動中...",running:"実行中",running_external:"実行中 (tsunagi外で起動)",error:"エラー"},Y=["installing_deps","downloading_model","starting_server"],q=["running","running_external"];function X(e){let t=e/0x40000000;return t>=.1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(0)} MB`}function Z(){let[e,a]=(0,s.useState)(!1),[r,n]=(0,s.useState)(!1),[o,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(""),u=(0,s.useRef)(null),m=(0,s.useCallback)(e=>{a(e),localStorage.setItem(J,String(e))},[]),p=(0,s.useCallback)(e=>{d(e),localStorage.setItem(W.WHISPER_PROMPT_STORAGE_KEY,e)},[]),h=(0,s.useCallback)(async()=>{let e=await fetch((0,l.apiUrl)("/api/whisper/server/status")),t=await e.json();return i(t),t},[]);(0,s.useEffect)(()=>{a("true"===localStorage.getItem(J)),d(localStorage.getItem(W.WHISPER_PROMPT_STORAGE_KEY)??""),h()},[h]),(0,s.useEffect)(()=>{o&&q.includes(o.step)&&!e&&(m(!0),G.toaster.create({type:"success",title:"音声入力が有効化されました"}))},[o,e,m]),(0,s.useEffect)(()=>(o&&Y.includes(o.step)&&!u.current&&(u.current=setInterval(()=>{h().then(e=>{!Y.includes(e.step)&&u.current&&(clearInterval(u.current),u.current=null)})},1e3)),()=>{u.current&&(clearInterval(u.current),u.current=null)}),[o,h]);let f=(0,s.useCallback)(()=>{h(),n(!0)},[h]),v=(0,s.useCallback)(async()=>{try{let e=await fetch((0,l.apiUrl)("/api/whisper/server/start"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}i(await e.json())}catch(e){G.toaster.create({type:"error",title:"サーバーの起動に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),j=(0,s.useCallback)(async()=>{try{let e=await fetch((0,l.apiUrl)("/api/whisper/server/stop"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}i(await e.json())}catch(e){G.toaster.create({type:"error",title:"サーバーの停止に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),g=(0,s.useCallback)(()=>{m(!1),o&&q.includes(o.step)&&j()},[m,j,o]),w=o?.serverDir,y=o?.downloadProgress,N=y?y.downloadedBytes/y.totalBytes*100:0,b=null!==o,k=b&&q.includes(o.step);return(0,t.jsxs)(H.Card,{children:[(0,t.jsxs)(H.CardHeader,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(H.CardTitle,{children:"音声入力 (実験的機能)"}),(0,t.jsx)(x.Button,{variant:"ghost",size:"icon-sm",onClick:f,title:"音声入力について",children:(0,t.jsx)(L.CircleHelp,{})})]}),(0,t.jsx)(H.CardDescription,{children:"ローカルで動作するWhisperを使って音声入力を行います。下記のローカルLLMも有効にすると、 文字起こし結果がLLMで自動整形されます(無効時は文字起こし結果をそのまま使用)。"})]}),(0,t.jsx)(H.CardContent,{className:"flex flex-col gap-3",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[b?k?(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(D.CheckCircle2,{className:"size-4"}),"音声入力: 有効"]}):(0,t.jsxs)("span",{className:"flex items-center gap-2 text-warning",children:[(0,t.jsx)(E.AlertCircle,{className:"size-4"}),"音声入力: 有効化済み(サーバー停止中)"]}):(0,t.jsxs)("span",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,t.jsx)(I.Loader2,{className:"size-4 animate-spin"}),"状態を確認中..."]}),o&&(0,t.jsxs)("span",{className:"text-xs/relaxed text-muted-foreground",children:["(",V[o.step],")"]}),b&&!k&&(0,t.jsxs)(x.Button,{size:"default",onClick:f,children:[(0,t.jsx)($.Mic,{}),"サーバーを起動"]}),(0,t.jsx)(x.Button,{size:"default",variant:"outline",onClick:g,children:"無効にする"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-1 block text-xs font-medium text-muted-foreground",children:"文字起こしプロンプト (任意)"}),(0,t.jsx)(K.Textarea,{value:c,onChange:e=>p(e.target.value),placeholder:"例: 句読点を適切に打ってください。固有名詞は正確に表記してください。",className:"min-h-16 text-xs"}),(0,t.jsx)("p",{className:"mt-1 text-[0.65rem] text-muted-foreground",children:"Whisperの文字起こしスタイル(表記ゆれ・句読点・固有名詞など)を誘導するヒントです。空でも構いません。"})]})]}):(0,t.jsxs)(x.Button,{size:"default",onClick:f,children:[(0,t.jsx)($.Mic,{}),"音声入力を有効化する"]})}),(0,t.jsx)(B.Dialog,{open:r,onOpenChange:({open:e})=>n(e),title:"音声入力について",maxWidth:"2xl",children:(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"実験的機能です"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"音声入力はローカルで動作するWhisper (mlx-whisper) を利用します。精度・速度は環境に依存し、今後変更される可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"対応環境"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Apple Silicon Mac (M1/M2/M3/M4) のみ対応。Windows/Linuxでは利用できません。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"必要なもの(事前に手動でインストール)"}),(0,t.jsx)("ul",{className:"list-disc pl-5 text-muted-foreground",children:(0,t.jsx)("li",{children:"Python 3.9以降(Xcode Command Line Tools または Homebrew経由で入手可能)"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"セットアップ・起動"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"下のボタンから、依存関係のインストール・モデルのダウンロード・サーバー起動まで自動で行われます(初回は数分かかります)。"}),o&&!w&&(0,t.jsx)("p",{className:"mt-1 text-destructive",children:"whisper-serverが見つかりませんでした。インストールが壊れている可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"アンインストール"}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:["音声入力のためにダウンロードされるもの(Pythonの依存関係・Whisperモデル、合計約2.6GB)は全て",(0,t.jsx)("code",{className:"rounded bg-muted px-1",children:"~/.tsunagi/whisper"}),"に保存されます。不要になった場合はこのディレクトリを削除するだけで、関連リソースを完全に削除できます。"]})]}),(0,t.jsxs)("div",{className:"border-t border-border pt-4",children:[(!o||"not_running"===o.step||"error"===o.step)&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)(x.Button,{size:"default",onClick:()=>void v(),disabled:!o,children:[o?(0,t.jsx)($.Mic,{}):(0,t.jsx)(I.Loader2,{className:"animate-spin"}),"Whisperサーバーを起動"]}),o?.step==="error"&&o.error&&(0,t.jsx)("p",{className:"text-xs/relaxed text-destructive",children:o.error})]}),o?.step==="installing_deps"&&(0,t.jsxs)(x.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(I.Loader2,{className:"animate-spin"}),"依存関係をインストール中... (数分かかる場合があります)"]}),o?.step==="downloading_model"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs/relaxed text-muted-foreground",children:[(0,t.jsx)(I.Loader2,{className:"size-4 animate-spin"}),"モデルをダウンロード中..."]}),y&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M.Progress,{value:N}),(0,t.jsxs)("p",{className:"text-xs/relaxed text-muted-foreground",children:[X(y.downloadedBytes)," / ",X(y.totalBytes)," (",N.toFixed(0),"%) ・ ",function(e){if(null===e)return"残り時間を計算中...";if(e<60)return`残り約${e}秒`;let t=Math.floor(e/60);return`残り約${t}分${e%60}秒`}(y.etaSeconds)]})]})]}),o?.step==="starting_server"&&(0,t.jsxs)(x.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(I.Loader2,{className:"animate-spin"}),"サーバーを起動中..."]}),o&&q.includes(o.step)&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(D.CheckCircle2,{className:"size-4"}),"サーバーは起動しています"]}),(0,t.jsxs)(x.Button,{size:"default",variant:"outline",onClick:()=>void j(),children:[(0,t.jsx)(R.Square,{}),"サーバーを停止"]})]})]})]})})]})}var Q=e.i(66961),ee=e.i(51846);e.s(["default",0,function(){let e=(0,a.useRouter)();(0,ee.useDocumentTitle)("settings");let n=()=>{{let e=localStorage.getItem("tsunagi:env-selected-node");if(e)try{return JSON.parse(e)}catch(e){console.error("Failed to parse selected node:",e)}}return{scope:"global",label:"Global"}},[o,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(0),[u,m]=(0,s.useState)({completed:!0,hasGlobalToken:!0});return(0,s.useEffect)(()=>{fetch((0,l.apiUrl)("/api/onboarding/status")).then(e=>e.json()).then(e=>{let t=e.data;m(t),t.completed||t.hasGlobalToken?i(n()):i({scope:"global",label:"Global"})}).catch(e=>{console.error("Failed to fetch onboarding status:",e),i(n())})},[]),(0,s.useEffect)(()=>{o&&localStorage.setItem("tsunagi:env-selected-node",JSON.stringify(o))},[o]),(0,t.jsxs)("div",{className:"h-screen flex flex-col bg-background",children:[(0,t.jsx)("div",{className:"sticky top-0 z-50 p-4 border-b border-border bg-card",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)(x.Button,{variant:"ghost",onClick:()=>e.push("/"),className:"text-primary font-medium hover:bg-primary/10 hover:text-foreground",children:[(0,t.jsx)(r.ArrowLeft,{className:"w-4 h-4"}),"Back to Board"]}),(0,t.jsx)("h1",{className:"text-xl font-bold text-foreground absolute left-1/2 -translate-x-1/2",children:"Settings"})]})}),(0,t.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,t.jsx)("div",{className:"w-64 border-r border-border bg-card",children:(0,t.jsx)(p,{selectedNode:o,onNodeSelect:e=>{i(e)},refreshKey:c})}),(0,t.jsx)("div",{className:"flex-1 bg-card p-4 overflow-y-auto",children:o?(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(_,{selectedNode:o,onboardingStatus:u,onSwitchToGlobal:()=>{i({scope:"global",label:"Global"})}}),(0,t.jsx)(S,{selectedNode:o}),"global"===o.scope&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Repositories"}),(0,t.jsx)(U,{})]}),"global"===o.scope&&(0,t.jsx)(Z,{}),"global"===o.scope&&(0,t.jsx)(Q.LocalLlmSection,{}),"repo"===o.scope&&o.owner&&o.repo&&(0,t.jsx)(z,{owner:o.owner,repo:o.repo,onDeleted:()=>{i({scope:"global",label:"Global"}),d(e=>e+1)}})]}):(0,t.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Select a node from the left panel"})})]})]})}],82341)}]);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@minimalcorp/tsunagi",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@minimalcorp/tsunagi",
9
- "version": "0.1.24",
9
+ "version": "0.1.25",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "os": [
12
12
  "darwin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimalcorp/tsunagi",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "Multi-repo GitHub project management with Claude AI integration, designed for visualizing and controlling AI-driven development locally.",
5
5
  "keywords": [
6
6
  "tsunagi",
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,t,r)=>{t.exports=e.r(76562)},27612,e=>{"use strict";let t=(0,e.i(75254).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",0,t],27612)},43531,78745,e=>{"use strict";let t=(0,e.i(75254).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["default",0,t],78745),e.s(["Check",0,t],43531)},37870,31278,e=>{"use strict";var t=e.i(18050),r=e.i(17521);e.s(["Loader2",()=>r.default],31278);var r=r;e.s(["LoadingSpinner",0,function({size:e="md",message:a}){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3",children:[(0,t.jsx)(r.default,{className:`${{sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"}[e]} text-primary animate-spin`}),a&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:a})]})}],37870)},10012,24564,94349,e=>{"use strict";var t,r=e.i(18050);e.i(47167);var a=e.i(71645);e.s([],19485),e.i(19485);var i=e.i(76477),n=e.i(67805),l=e.i(17514);let s=((t={}).disabled="data-disabled",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t),o={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},d={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},u={disabled:!1,...d},c={valid:e=>null===e?null:e?{[s.valid]:""}:{[s.invalid]:""}},f=a.createContext({invalid:void 0,name:void 0,validityData:{state:o,errors:[],error:"",value:"",initialValue:null},setValidityData:l.NOOP,disabled:void 0,touched:d.touched,setTouched:l.NOOP,dirty:d.dirty,setDirty:l.NOOP,filled:d.filled,setFilled:l.NOOP,focused:d.focused,setFocused:l.NOOP,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:u,markedDirtyRef:{current:!1},validation:{getValidationProps:(e=l.EMPTY_OBJECT)=>e,getInputValidationProps:(e=l.EMPTY_OBJECT)=>e,inputRef:{current:null},commit:async()=>{}}});function m(e=!0){let t=a.useContext(f);if(t.setValidityData===l.NOOP&&!e)throw Error((0,n.default)(28));return t}let p=a.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0}),v=a.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:l.NOOP,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function g(){return a.useContext(v)}var x=e.i(30628),h=e.i(19805),b=e.i(89879);let y=a.createContext({controlId:void 0,registerControlId:l.NOOP,labelId:void 0,setLabelId:l.NOOP,messageIds:[],setMessageIds:l.NOOP,getDescriptionProps:e=>e});function j(){return a.useContext(y)}let w=function(e){let t=(0,b.useBaseUiId)(),n=void 0===e.controlId?t:e.controlId,[l,s]=a.useState(n),[o,d]=a.useState(e.labelId),[u,c]=a.useState([]),f=(0,x.useRefWithInit)(()=>new Map),{messageIds:m}=j(),p=(0,i.useStableCallback)((e,t)=>{let r=f.current;void 0===t?r.delete(e):(r.set(e,t),s(e=>{let t;if(0!==r.size){for(let a of r.values()){if(void 0!==e&&a===e)return e;void 0===t&&(t=a)}return t}}))}),v=a.useCallback(e=>(0,h.mergeProps)({"aria-describedby":m.concat(u).join(" ")||void 0},e),[m,u]),g=a.useMemo(()=>({controlId:l,registerControlId:p,labelId:o,setLabelId:d,messageIds:u,setMessageIds:c,getDescriptionProps:v}),[l,p,o,d,u,c,v]);return(0,r.jsx)(y.Provider,{value:g,children:e.children})};var M=e.i(27601),C=e.i(66745);function k(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}let N=Object.keys(o),S=a.forwardRef(function(e,t){let{errors:s,validationMode:d,submitAttemptedRef:u}=g(),{render:m,className:v,validate:x,validationDebounceTime:b=0,validationMode:y=d,name:w,disabled:S=!1,invalid:E,dirty:R,touched:L,actionsRef:I,...O}=e,{disabled:P}=function(e=!1){let t=a.useContext(p);if(!t&&!e)throw Error((0,n.default)(86));return t}(),T=(0,i.useStableCallback)(x||(()=>null)),B=P||S,[A,V]=a.useState(!1),[D,_]=a.useState(!1),[z,F]=a.useState(!1),[U,H]=a.useState(!1),$=R??D,q=L??A,G=a.useRef(!1),J=(0,i.useStableCallback)(e=>{void 0===R&&(e&&(G.current=!0),_(e))}),W=(0,i.useStableCallback)(e=>{void 0===L&&V(e)}),K=(0,i.useStableCallback)(()=>"onChange"===y||"onSubmit"===y&&u.current),Y=!!w&&Object.hasOwn(s,w)&&void 0!==s[w],Q=!0===E||Y,[X,Z]=a.useState({state:o,error:"",errors:[],value:null,initialValue:null}),ee=!Q&&X.state.valid,et=a.useMemo(()=>({disabled:B,touched:q,dirty:$,valid:ee,filled:z,focused:U}),[B,q,$,ee,z,U]),er=function(e){let{formRef:t,clearErrors:r}=g(),{setValidityData:n,validate:s,validityData:d,validationDebounceTime:u,invalid:c,markedDirtyRef:f,state:m,name:p,shouldValidateOnChange:v}=e,{controlId:x,getDescriptionProps:b}=j(),y=(0,C.useTimeout)(),w=a.useRef(null),M=(0,i.useStableCallback)(async(e,r=!1)=>{let a,i=w.current;if(!i)return;if(r){if(!1!==m.valid)return;let r=i.validity;if(!r.valueMissing){let r={value:e,state:{...o,valid:!0},error:"",errors:[],initialValue:d.initialValue};if(i.setCustomValidity(""),x){let e=t.current.fields.get(x);e&&t.current.fields.set(x,{...e,...k(r,!1)})}n(r);return}let a=N.reduce((e,t)=>(e[t]=r[t],e),{});if(!a.valid&&!function(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(let r of N)"valid"!==r&&("valueMissing"===r&&(t=e[r]),e[r]&&(t=!1));return t}(a))return}y.clear();let l=null,u=[],p=function(e){let t=N.reduce((t,r)=>(t[r]=e.validity[r],t),{}),r=!1;for(let e of N)if("valid"!==e){if("valueMissing"===e&&t[e])r=!0;else if(t[e])return t}return r&&!f.current&&(t.valid=!0,t.valueMissing=!1),t}(i),g=v();if(i.validationMessage&&!g)a=i.validationMessage,u=[i.validationMessage];else{let r=s(e,Array.from(t.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}));null!==(l="object"==typeof r&&null!==r&&"then"in r?await r:r)?(p.valid=!1,p.customError=!0,Array.isArray(l)?(u=l,i.setCustomValidity(l.join("\n"))):l&&(u=[l],i.setCustomValidity(l))):g&&(i.setCustomValidity(""),p.customError=!1,i.validationMessage?(a=i.validationMessage,u=[i.validationMessage]):i.validity.valid&&!p.valid&&(p.valid=!0))}let h={value:e,state:p,error:a??(Array.isArray(l)?l[0]:l??""),errors:u,initialValue:d.initialValue};if(x){let e=t.current.fields.get(x);e&&t.current.fields.set(x,{...e,...k(h,c)})}n(h)}),S=a.useCallback((e={})=>(0,h.mergeProps)(b,!1===m.valid?{"aria-invalid":!0}:l.EMPTY_OBJECT,e),[b,m.valid]),E=a.useCallback((e={})=>(0,h.mergeProps)({onChange(e){if(e.nativeEvent.defaultPrevented)return;if(r(p),!v())return void M(e.currentTarget.value,!0);let t=e.currentTarget;""===t.value?M(t.value):(y.clear(),u?y.start(u,()=>{M(t.value)}):M(t.value))}},S(e)),[S,r,p,y,M,u,v]);return a.useMemo(()=>({getValidationProps:S,getInputValidationProps:E,inputRef:w,commit:M}),[S,E,M])}({setValidityData:Z,validate:T,validityData:X,validationDebounceTime:b,invalid:Q,markedDirtyRef:G,state:et,name:w,shouldValidateOnChange:K}),ea=a.useCallback(()=>{G.current=!0,er.commit(X.value)},[er,X]);a.useImperativeHandle(I,()=>({validate:ea}),[ea]);let ei=a.useMemo(()=>({invalid:Q,name:w,validityData:X,setValidityData:Z,disabled:B,touched:q,setTouched:W,dirty:$,setDirty:J,filled:z,setFilled:F,focused:U,setFocused:H,validate:T,validationMode:y,validationDebounceTime:b,shouldValidateOnChange:K,state:et,markedDirtyRef:G,validation:er}),[Q,w,X,B,q,W,$,J,z,F,U,H,T,y,b,K,et,er]),en=(0,M.useRenderElement)("div",e,{ref:t,state:et,props:O,stateAttributesMapping:c});return(0,r.jsx)(f.Provider,{value:ei,children:en})}),E=a.forwardRef(function(e,t){return(0,r.jsx)(w,{children:(0,r.jsx)(S,{...e,ref:t})})});var R=e.i(29315),L=e.i(90219),I=e.i(47857),O=e.i(977);function P(e,t){let r=(0,b.useBaseUiId)(e);return(0,O.useIsoLayoutEffect)(()=>(t(r),()=>{t(void 0)}),[r,t]),r}e.s(["useRegisteredLabelId",0,P],24564);let T=a.forwardRef(function(e,t){let{render:r,className:n,id:l,nativeLabel:s=!0,...o}=e,d=m(!1),{labelId:u}=j(),f=a.useRef(null),p=function(e={}){let{id:t,fallbackControlId:r,native:a=!1,setLabelId:n,focusControl:l}=e,{controlId:s,setLabelId:o}=j(),d=P(t,(0,i.useStableCallback)(e=>{o(e),n?.(e)})),u=s??r;function c(e){let t=(0,I.getTarget)(e.nativeEvent);t?.closest("button,input,select,textarea")||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),a||function(e){if(l)return l(e,u);if(!u)return;let t=(0,L.ownerDocument)(e.currentTarget).getElementById(u);(0,R.isHTMLElement)(t)&&t.focus({focusVisible:!0})}(e))}return a?{id:d,htmlFor:u??void 0,onMouseDown:c}:{id:d,onClick:c,onPointerDown(e){e.preventDefault()}}}({id:u??l,native:s});return(0,M.useRenderElement)("label",e,{ref:[t,f],state:d.state,props:[p,o],stateAttributesMapping:c})});var B=e.i(89269),A=e.i(84759),V=e.i(88841);let D={...c,...A.transitionStatusMapping},_=a.forwardRef(function(e,t){let{render:i,id:n,className:l,match:s,...o}=e,d=(0,b.useBaseUiId)(n),{validityData:u,state:c,name:f}=m(!1),{setMessageIds:p}=j(),{errors:v}=g(),x=f?v[f]:null,h=!1;h=!!x||!0===s||(s?!!u.state[s]:!1===u.state.valid);let{mounted:y,transitionStatus:w,setMounted:C}=(0,V.useTransitionStatus)(h);(0,O.useIsoLayoutEffect)(()=>{if(h&&d)return p(e=>e.concat(d)),()=>{p(e=>e.filter(e=>e!==d))}},[h,d,p]);let k=a.useRef(null),[N,S]=a.useState(null),[E,R]=a.useState(null),L=x||(u.errors.length>1?(0,r.jsx)("ul",{children:u.errors.map(e=>(0,r.jsx)("li",{children:e},e))}):u.error),I=u.error;null!=x?I=Array.isArray(x)?JSON.stringify(x):x:u.errors.length>1&&(I=JSON.stringify(u.errors)),h&&I!==E&&(R(I),S(L)),(0,B.useOpenChangeComplete)({open:h,ref:k,onComplete(){h||C(!1)}});let P={...c,transitionStatus:w},T=(0,M.useRenderElement)("div",e,{ref:[t,k],state:P,props:[{id:d,children:h?L:N},o],stateAttributesMapping:D,enabled:y});return y?T:null}),z=a.forwardRef(function(e,t){let{render:r,id:a,className:i,...n}=e,l=(0,b.useBaseUiId)(a),s=m(!1),{setMessageIds:o}=j();return(0,O.useIsoLayoutEffect)(()=>{if(l)return o(e=>e.concat(l)),()=>{o(e=>e.filter(e=>e!==l))}},[l,o]),(0,M.useRenderElement)("p",e,{ref:t,state:s.state,props:[{id:l},n],stateAttributesMapping:c})});function F({controlled:e,default:t,name:r,state:i="value"}){let{current:n}=a.useRef(void 0!==e),[l,s]=a.useState(t),o=a.useCallback(e=>{n||s(e)},[]);return[n?e:l,o]}e.s(["useControlled",0,F],94349);var U=e.i(74080),H=e.i(5963),$=e.i(3404);let q=a.forwardRef(function(e,t){let{render:r,className:n,id:s,name:o,value:d,disabled:u=!1,onValueChange:f,defaultValue:p,autoFocus:v=!1,...h}=e,{state:y,name:w,disabled:C,setTouched:N,setDirty:S,validityData:E,setFocused:P,setFilled:T,validationMode:B,validation:A}=m(),V=C||u,D=w??o,_={...y,disabled:V},{labelId:z}=j(),q=function(e={}){let{id:t,implicit:r=!1,controlRef:n}=e,{controlId:s,registerControlId:o}=j(),d=(0,b.useBaseUiId)(t),u=r?s:void 0,c=(0,x.useRefWithInit)(()=>Symbol("labelable-control")),f=a.useRef(!1),m=a.useRef(null!=t),p=(0,i.useStableCallback)(()=>{f.current&&o!==l.NOOP&&(f.current=!1,o(c.current,void 0))});return(0,O.useIsoLayoutEffect)(()=>{let e;if(o!==l.NOOP){if(r){let r=n?.current;e=(0,R.isElement)(r)&&null!=r.closest("label")?t??null:u??d}else if(null!=t)m.current=!0,e=t;else{if(!m.current)return void p();e=d}if(void 0===e)return void p();f.current=!0,o(c.current,e)}},[t,n,u,o,r,d,c,p]),a.useEffect(()=>p,[p]),s??d}({id:s});(0,O.useIsoLayoutEffect)(()=>{let e=null!=d;A.inputRef.current?.value||e&&""!==d?T(!0):e&&""===d&&T(!1)},[A.inputRef,T,d]);let G=a.useRef(null);(0,O.useIsoLayoutEffect)(()=>{v&&G.current===(0,I.activeElement)((0,L.ownerDocument)(G.current))&&P(!0)},[v,P]);let[J]=F({controlled:d,default:p,name:"FieldControl",state:"value"}),W=void 0!==d,K=W?J:void 0;return!function(e){let{enabled:t=!0,value:r,id:a,name:n,controlRef:l,commit:s}=e,{formRef:o}=g(),{invalid:d,markedDirtyRef:u,validityData:c,setValidityData:f}=m(),p=(0,i.useStableCallback)(e.getValue);(0,O.useIsoLayoutEffect)(()=>{if(!t)return;let e=r;void 0===e&&(e=p()),null===c.initialValue&&null!==e&&f(t=>({...t,initialValue:e}))},[t,f,r,c.initialValue,p]),(0,O.useIsoLayoutEffect)(()=>{t&&a&&o.current.fields.set(a,{getValue:p,name:n,controlRef:l,validityData:k(c,d),validate(e=!0){let t=r;void 0===t&&(t=p()),u.current=!0,e?U.flushSync(()=>s(t)):s(t)}})},[s,l,t,o,p,a,d,u,n,c,r]),(0,O.useIsoLayoutEffect)(()=>{let e=o.current.fields;return()=>{a&&e.delete(a)}},[o,a])}({id:q,name:D,commit:A.commit,value:K,getValue:()=>A.inputRef.current?.value,controlRef:A.inputRef}),(0,M.useRenderElement)("input",e,{ref:[t,G],state:_,props:[{id:q,disabled:V,name:D,ref:A.inputRef,"aria-labelledby":z,autoFocus:v,...W?{value:K}:{defaultValue:p},onChange(e){let t=e.currentTarget.value;f?.(t,(0,H.createChangeEventDetails)($.REASONS.none,e.nativeEvent)),S(t!==E.initialValue),T(""!==t)},onFocus(){P(!0)},onBlur(e){N(!0),P(!1),"onBlur"===B&&A.commit(e.currentTarget.value)},onKeyDown(e){"INPUT"===e.currentTarget.tagName&&"Enter"===e.key&&(N(!0),A.commit(e.currentTarget.value))}},A.getInputValidationProps(),h],stateAttributesMapping:c})}),G=a.createContext({disabled:!1}),J=a.createContext(void 0),W=a.forwardRef(function(e,t){let{render:i,className:l,disabled:s=!1,...o}=e,{state:d,disabled:u}=m(!1),f=u||s,p=function(e=!0){let t=a.useContext(J);if(void 0===t&&!e)throw Error((0,n.default)(3));return t}(),v=p?.parent.id,g=p?.allValues!==void 0,x=a.useMemo(()=>({disabled:f}),[f]),h=(0,M.useRenderElement)("div",e,{ref:t,state:d,props:o,stateAttributesMapping:c});return(0,r.jsx)(w,{controlId:g?v:void 0,children:(0,r.jsx)(G.Provider,{value:x,children:h})})});e.s(["Control",0,q,"Description",0,z,"Error",0,_,"Item",0,W,"Label",0,T,"Root",0,E,"Validity",0,function(e){let{children:t}=e,{validityData:i,invalid:n}=m(!1),l=a.useMemo(()=>k(i,n),[i,n]),s=!1===l.state.valid,{transitionStatus:o}=(0,V.useTransitionStatus)(s),d=a.useMemo(()=>({...l,validity:l.state,transitionStatus:o}),[l,o]);return(0,r.jsx)(a.Fragment,{children:t(d)})}],71975);var K=e.i(71975),K=K;let Y=a.forwardRef(function(e,t){return(0,r.jsx)(K.Control,{ref:t,...e})});var Q=e.i(52088);e.s(["Input",0,function({className:e,type:t,...a}){return(0,r.jsx)(Y,{type:t,"data-slot":"input",className:(0,Q.cn)("h-9 w-full min-w-0 rounded-md border border-input bg-input/20 px-3 py-1 text-sm transition-colors outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}],10012)},41247,e=>{"use strict";var t=e.i(18050),r=e.i(52088);e.s(["Textarea",0,function({className:e,...a}){return(0,t.jsx)("textarea",{"data-slot":"textarea",className:(0,r.cn)("flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-input/20 px-2 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}])},86536,e=>{"use strict";let t=(0,e.i(75254).default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Eye",0,t],86536)},51846,e=>{"use strict";var t=e.i(71645);e.s(["useDocumentTitle",0,function(e){(0,t.useEffect)(()=>{let t=e?`繋 | ${e}`:"繋",r=document.title;return document.title=t,()=>{document.title=r}},[e])}])},31245,e=>{"use strict";let t=(0,e.i(75254).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);e.s(["Bot",0,t],31245)},63209,e=>{"use strict";let t=(0,e.i(75254).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",0,t],63209)},95468,e=>{"use strict";var t=e.i(23287);e.s(["CheckCircle2",()=>t.default])},87951,52044,e=>{"use strict";var t=e.i(75254);let r=(0,t.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);e.s(["Mic",0,r],87951);let a=(0,t.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);e.s(["Square",0,a],52044)},57024,e=>{"use strict";var t=e.i(85699);function r(e){let{type:r,title:a,description:i,duration:n}=e,l=e.id??crypto.randomUUID(),s={id:l,description:i,duration:n};switch(r){case"loading":t.toast.loading(a,s);break;case"success":t.toast.success(a,s);break;case"error":t.toast.error(a,s);break;case"warning":t.toast.warning(a,s);break;case"info":t.toast.info(a,s);break;default:(0,t.toast)(a,s)}return l}e.s(["toaster",0,{create:e=>r(e),update:(e,t)=>{r({...t,id:e})},dismiss:e=>{t.toast.dismiss(e)}}])},58e3,e=>{"use strict";let t=(0,e.i(75254).default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["CircleHelp",0,t],58e3)},64036,e=>{"use strict";var t=e.i(18050),r=e.i(52088);e.s(["Card",0,function({className:e,size:a="default",...i}){return(0,t.jsx)("div",{"data-slot":"card","data-size":a,className:(0,r.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-lg bg-card py-4 text-xs/relaxed text-card-foreground ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg",e),...i})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-4 group-data-[size=sm]/card:px-3",e),...a})},"CardDescription",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,r.cn)("text-xs/relaxed text-muted-foreground",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("font-heading text-sm font-medium",e),...a})}])},77814,e=>{"use strict";var t,r=e.i(18050);e.s([],33847),e.i(33847),e.i(47167);var a=e.i(71645),i=e.i(231),n=e.i(62372);let l=new Map;function s(e,t,r){return null==e?"":(function(e,t){let r=JSON.stringify({locale:e,options:t}),a=l.get(r);if(a)return a;let i=new Intl.NumberFormat(e,t);return l.set(r,i),i})(t,r).format(e)}var o=e.i(27601),d=e.i(67805);let u=a.createContext(void 0);function c(){let e=a.useContext(u);if(void 0===e)throw Error((0,d.default)(51));return e}let f=((t={}).complete="data-complete",t.indeterminate="data-indeterminate",t.progressing="data-progressing",t),m={status:e=>"progressing"===e?{[f.progressing]:""}:"complete"===e?{[f.complete]:""}:"indeterminate"===e?{[f.indeterminate]:""}:null};function p(e,t){return null==t?"indeterminate progress":e||`${t}%`}let v=a.forwardRef(function(e,t){var l;let{format:d,getAriaValueText:c=p,locale:f,max:v=100,min:g=0,value:x,render:h,className:b,children:y,...j}=e,[w,M]=a.useState(),C=(0,i.useValueAsRef)(d),k="indeterminate";Number.isFinite(x)&&(k=x===v?"complete":"progressing");let N=(l=C.current,null==x?"":l?s(x,f,l):s(x/100,f,{style:"percent"})),S=a.useMemo(()=>({status:k}),[k]),E={"aria-labelledby":w,"aria-valuemax":v,"aria-valuemin":g,"aria-valuenow":x??void 0,"aria-valuetext":c(N,x),role:"progressbar",children:(0,r.jsxs)(a.Fragment,{children:[y,(0,r.jsx)("span",{role:"presentation",style:n.visuallyHidden,children:"x"})]})},R=a.useMemo(()=>({formattedValue:N,max:v,min:g,setLabelId:M,state:S,status:k,value:x}),[N,v,g,M,S,k,x]),L=(0,o.useRenderElement)("div",e,{state:S,ref:t,props:[E,j],stateAttributesMapping:m});return(0,r.jsx)(u.Provider,{value:R,children:L})}),g=a.forwardRef(function(e,t){let{render:r,className:a,...i}=e,{state:n}=c();return(0,o.useRenderElement)("div",e,{state:n,ref:t,props:i,stateAttributesMapping:m})}),x=a.forwardRef(function(e,t){let{render:r,className:i,...n}=e,{max:l,min:s,value:d,state:u}=c(),f=Number.isFinite(d)&&null!==d?(d-s)*100/(l-s):null,p=a.useCallback(()=>null==f?{}:{insetInlineStart:0,height:"inherit",width:`${f}%`},[f]);return(0,o.useRenderElement)("div",e,{state:u,ref:t,props:[{style:p()},n],stateAttributesMapping:m})}),h=a.forwardRef(function(e,t){let{className:r,render:a,children:i,...n}=e,{value:l,formattedValue:s,state:d}=c(),u=null==l?"indeterminate":s,f=null==l?null:s;return(0,o.useRenderElement)("span",e,{state:d,ref:t,props:[{"aria-hidden":!0,children:"function"==typeof i?i(u,l):f},n],stateAttributesMapping:m})});var b=e.i(24564);let y=a.forwardRef(function(e,t){let{render:r,className:a,id:i,...n}=e,{setLabelId:l,state:s}=c(),d=(0,b.useRegisteredLabelId)(i,l);return(0,o.useRenderElement)("span",e,{state:s,ref:t,props:[{id:d,role:"presentation"},n],stateAttributesMapping:m})});e.s(["Indicator",0,x,"Label",0,y,"Root",0,v,"Track",0,g,"Value",0,h],45929);var j=e.i(45929),j=j,w=e.i(52088);function M({className:e,...t}){return(0,r.jsx)(j.Track,{className:(0,w.cn)("relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted",e),"data-slot":"progress-track",...t})}function C({className:e,...t}){return(0,r.jsx)(j.Indicator,{"data-slot":"progress-indicator",className:(0,w.cn)("h-full bg-primary",e),style:{transition:"width 500ms ease-in-out"},...t})}e.s(["Progress",0,function({className:e,children:t,value:a,...i}){return(0,r.jsxs)(j.Root,{value:a,"data-slot":"progress",className:(0,w.cn)("flex flex-wrap gap-3",e),...i,children:[t,(0,r.jsx)(M,{children:(0,r.jsx)(C,{})})]})}],77814)},31449,66961,e=>{"use strict";var t=e.i(18050),r=e.i(71645),a=e.i(31278),i=e.i(87951),n=e.i(52044),l=e.i(85902),s=e.i(70935),o=e.i(57024),d=e.i(31245),u=e.i(95468),c=e.i(58e3),f=e.i(64036),m=e.i(68995),p=e.i(77814);let v="tsunagi:local-llm-enabled",g={not_running:"停止中",installing_deps:"依存関係をインストール中...",downloading_model:"モデルをダウンロード中...",starting_server:"サーバーを起動中... (モデルのロードに数十秒かかる場合があります)",running:"実行中",running_external:"実行中 (tsunagi外で起動)",error:"エラー"},x=["installing_deps","downloading_model","starting_server"],h=["running","running_external"];function b(e){let t=e/0x40000000;return t>=.1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(0)} MB`}e.s(["LOCAL_LLM_ENABLED_STORAGE_KEY",0,v,"LocalLlmSection",0,function(){let[e,i]=(0,r.useState)(!1),[y,j]=(0,r.useState)(!1),[w,M]=(0,r.useState)(null),C=(0,r.useRef)(null),k=(0,r.useCallback)(e=>{i(e),localStorage.setItem(v,String(e))},[]),N=(0,r.useCallback)(async()=>{let e=await fetch((0,s.apiUrl)("/api/llm/server/status")),t=await e.json();return M(t),t},[]);(0,r.useEffect)(()=>{i("true"===localStorage.getItem(v)),N()},[N]),(0,r.useEffect)(()=>{w&&h.includes(w.step)&&!e&&(k(!0),o.toaster.create({type:"success",title:"ローカルLLMが有効化されました"}))},[w,e,k]),(0,r.useEffect)(()=>(w&&x.includes(w.step)&&!C.current&&(C.current=setInterval(()=>{N().then(e=>{!x.includes(e.step)&&C.current&&(clearInterval(C.current),C.current=null)})},1e3)),()=>{C.current&&(clearInterval(C.current),C.current=null)}),[w,N]);let S=(0,r.useCallback)(()=>{N(),j(!0)},[N]),E=(0,r.useCallback)(async()=>{try{let e=await fetch((0,s.apiUrl)("/api/llm/server/start"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}M(await e.json())}catch(e){o.toaster.create({type:"error",title:"サーバーの起動に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),R=(0,r.useCallback)(async()=>{try{let e=await fetch((0,s.apiUrl)("/api/llm/server/stop"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}M(await e.json())}catch(e){o.toaster.create({type:"error",title:"サーバーの停止に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),L=(0,r.useCallback)(()=>{k(!1),w&&h.includes(w.step)&&R()},[k,R,w]),I=w?.serverDir,O=w?.downloadProgress,P=O?O.downloadedBytes/O.totalBytes*100:0;return(0,t.jsxs)(f.Card,{children:[(0,t.jsxs)(f.CardHeader,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(f.CardTitle,{children:"ローカルLLM (実験的機能)"}),(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:S,title:"ローカルLLMについて",children:(0,t.jsx)(c.CircleHelp,{})})]}),(0,t.jsxs)(f.CardDescription,{children:["ローカルで動作するLLM(Qwen3-30B-A3B, MoE)を利用します。",(0,t.jsx)("strong",{className:"font-medium text-foreground",children:"有効にすると、音声入力の文字起こし結果がこのLLMで自動整形されるようになります"}),"(無効時は文字起こし結果をそのまま使用)。"]})]}),(0,t.jsx)(f.CardContent,{className:"flex flex-col gap-3",children:e?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(u.CheckCircle2,{className:"size-4"}),"ローカルLLM: 有効"]}),w&&(0,t.jsxs)("span",{className:"text-xs/relaxed text-muted-foreground",children:["(",g[w.step],")"]}),(0,t.jsx)(l.Button,{size:"default",variant:"outline",onClick:L,children:"無効にする"})]}):(0,t.jsxs)(l.Button,{size:"default",onClick:S,children:[(0,t.jsx)(d.Bot,{}),"ローカルLLMを有効化する"]})}),(0,t.jsx)(m.Dialog,{open:y,onOpenChange:({open:e})=>j(e),title:"ローカルLLMについて",maxWidth:"2xl",children:(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"実験的機能です"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"音声入力の文字起こし結果を、ローカルで動作するLLM(mlx-lm / Qwen3-30B-A3B, MoE構成)で整形します。MoE構成のため実計算に使うアクティブパラメータは約3Bで、denseな同規模モデルより高速に動作します。精度・速度は環境に依存し、今後変更される可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"対応環境"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Apple Silicon Mac (M1/M2/M3/M4) のみ対応。Windows/Linuxでは利用できません。メモリ32GB以上を推奨します。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"必要なもの(事前に手動でインストール)"}),(0,t.jsx)("ul",{className:"list-disc pl-5 text-muted-foreground",children:(0,t.jsx)("li",{children:"Python 3.9以降(Xcode Command Line Tools または Homebrew経由で入手可能)"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"セットアップ・起動"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"下のボタンから、依存関係のインストール・モデルのダウンロード・サーバー起動まで自動で行われます(初回はモデルサイズが大きく数分〜数十分かかります)。"}),w&&!I&&(0,t.jsx)("p",{className:"mt-1 text-destructive",children:"llm-serverが見つかりませんでした。インストールが壊れている可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"アンインストール"}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:["ローカルLLMのためにダウンロードされるもの(Pythonの依存関係・LLMモデル、合計約17GB)は全て",(0,t.jsx)("code",{className:"rounded bg-muted px-1",children:"~/.tsunagi/llm"}),"に保存されます。不要になった場合はこのディレクトリを削除するだけで、関連リソースを完全に削除できます。"]})]}),(0,t.jsxs)("div",{className:"border-t border-border pt-4",children:[(!w||"not_running"===w.step||"error"===w.step)&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)(l.Button,{size:"default",onClick:()=>void E(),disabled:!w,children:[w?(0,t.jsx)(d.Bot,{}):(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"LLMサーバーを起動"]}),w?.step==="error"&&w.error&&(0,t.jsx)("p",{className:"text-xs/relaxed text-destructive",children:w.error})]}),w?.step==="installing_deps"&&(0,t.jsxs)(l.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"依存関係をインストール中... (数分かかる場合があります)"]}),w?.step==="downloading_model"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs/relaxed text-muted-foreground",children:[(0,t.jsx)(a.Loader2,{className:"size-4 animate-spin"}),"モデルをダウンロード中... (約17GB)"]}),O&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.Progress,{value:P}),(0,t.jsxs)("p",{className:"text-xs/relaxed text-muted-foreground",children:[b(O.downloadedBytes)," / ",b(O.totalBytes)," (",P.toFixed(0),"%) ・ ",function(e){if(null===e)return"残り時間を計算中...";if(e<60)return`残り約${e}秒`;let t=Math.floor(e/60);return`残り約${t}分${e%60}秒`}(O.etaSeconds)]})]})]}),w?.step==="starting_server"&&(0,t.jsxs)(l.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"サーバーを起動中... (モデルのロードに数十秒かかる場合があります)"]}),w&&h.includes(w.step)&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(u.CheckCircle2,{className:"size-4"}),"サーバーは起動しています"]}),(0,t.jsxs)(l.Button,{size:"default",variant:"outline",onClick:()=>void R(),children:[(0,t.jsx)(n.Square,{}),"サーバーを停止"]})]})]})]})})]})}],66961);let y="tsunagi:whisper-prompt",j=["running","running_external"];e.s(["VoiceInputButton",0,function({onTranscribed:e}){let[d,u]=(0,r.useState)(!1),[c,f]=(0,r.useState)("idle"),[m,p]=(0,r.useState)(0),[g,x]=(0,r.useState)(null),h=(0,r.useRef)(null),b=(0,r.useRef)([]),w=(0,r.useRef)(null),M=(0,r.useRef)(null),C=(0,r.useRef)(null),k=(0,r.useRef)(0),N=(0,r.useRef)(0);(0,r.useEffect)(()=>{u("true"===localStorage.getItem("tsunagi:voice-input-enabled"))},[]),(0,r.useEffect)(()=>{if(!d)return;let e=!1,t=async()=>{try{let t=await fetch((0,s.apiUrl)("/api/whisper/server/status")),r=await t.json();e||x(r.step)}catch{e||x("not_running")}};t();let r=setInterval(t,5e3);return()=>{e=!0,clearInterval(r)}},[d]);let S=(0,r.useCallback)(()=>{C.current&&(clearInterval(C.current),C.current=null),M.current?.close(),M.current=null,p(0)},[]);(0,r.useEffect)(()=>()=>{S()},[S]);let E=(0,r.useCallback)(e=>{let t=new AudioContext,r=t.createMediaStreamSource(e),a=t.createAnalyser();a.fftSize=2048,r.connect(a),M.current=t,k.current=0,N.current=0;let i=new Float32Array(a.fftSize);C.current=setInterval(()=>{a.getFloatTimeDomainData(i);let e=0;for(let t=0;t<i.length;t++)e+=i[t]*i[t];let t=Math.sqrt(e/i.length),r=Math.min(1,Math.max(0,((t>0?20*Math.log10(t):-60)- -60)/50));N.current=Math.max(N.current,r),k.current=.3*k.current+.7*r,p(k.current)},50)},[]),R=(0,r.useCallback)(async t=>{f("transcribing");try{let r=new FormData,a=localStorage.getItem(y);a&&r.append("prompt",a);let i="true"===localStorage.getItem(v);r.append("useLlm",String(i)),r.append("file",t,"recording.webm");let n=await fetch((0,s.apiUrl)("/api/whisper/transcribe"),{method:"POST",body:r});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`HTTPエラー: ${n.status}`)}let l=await n.json();l.warning&&o.toaster.create({type:"error",title:"LLM整形をスキップしました",description:l.warning}),l.text&&e(l.text)}catch(e){o.toaster.create({type:"error",title:"文字起こしに失敗しました",description:e instanceof Error?e.message:String(e)})}finally{f("idle")}},[e]),L=(0,r.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});w.current=e,b.current=[],E(e);let t=new MediaRecorder(e,{audioBitsPerSecond:128e3});t.ondataavailable=e=>{e.data.size>0&&b.current.push(e.data)},t.onstop=()=>{w.current?.getTracks().forEach(e=>e.stop()),w.current=null;let e=N.current;if(S(),e<.15){o.toaster.create({type:"error",title:"音声が検出されませんでした",description:"マイクに向かって話してから、もう一度お試しください。"}),f("idle");return}let t=new Blob(b.current,{type:"audio/webm"});R(t)},h.current=t,t.start(),f("recording")}catch(e){o.toaster.create({type:"error",title:"マイクにアクセスできませんでした",description:e instanceof Error?e.message:String(e)})}},[R,E,S]),I=(0,r.useCallback)(()=>{h.current?.stop()},[]);if(!d)return null;let O=null!==g&&j.includes(g);return(0,t.jsxs)("div",{className:"recording"===c?"inline-flex items-center gap-2 rounded-md bg-destructive/10 p-1":"inline-flex",children:[(0,t.jsx)(l.Button,{size:"icon",variant:"recording"===c?"destructive":"default",onClick:"recording"===c?I:()=>void L(),disabled:"transcribing"===c||"idle"===c&&!O,title:"recording"===c?"停止して入力":"idle"!==c||O?"音声入力":"Whisperサーバーが起動していません(Settingsから起動してください)",children:"transcribing"===c?(0,t.jsx)(a.Loader2,{className:"w-4 h-4 animate-spin"}):"recording"===c?(0,t.jsx)(n.Square,{className:"w-4 h-4"}):(0,t.jsx)(i.Mic,{className:"w-4 h-4"})}),"recording"===c&&(0,t.jsx)("div",{"aria-hidden":!0,className:"h-1.5 w-16 overflow-hidden rounded-full bg-background/60",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-destructive",style:{width:`${Math.round(100*m)}%`}})})]})},"WHISPER_PROMPT_STORAGE_KEY",0,y],31449)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,t,r)=>{t.exports=e.r(76562)},43531,78745,e=>{"use strict";let t=(0,e.i(75254).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["default",0,t],78745),e.s(["Check",0,t],43531)},37870,31278,e=>{"use strict";var t=e.i(18050),r=e.i(17521);e.s(["Loader2",()=>r.default],31278);var r=r;e.s(["LoadingSpinner",0,function({size:e="md",message:a}){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3",children:[(0,t.jsx)(r.default,{className:`${{sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"}[e]} text-primary animate-spin`}),a&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:a})]})}],37870)},10012,24564,94349,e=>{"use strict";var t,r=e.i(18050);e.i(47167);var a=e.i(71645);e.s([],19485),e.i(19485);var i=e.i(76477),n=e.i(67805),l=e.i(17514);let s=((t={}).disabled="data-disabled",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t),o={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},d={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},u={disabled:!1,...d},c={valid:e=>null===e?null:e?{[s.valid]:""}:{[s.invalid]:""}},f=a.createContext({invalid:void 0,name:void 0,validityData:{state:o,errors:[],error:"",value:"",initialValue:null},setValidityData:l.NOOP,disabled:void 0,touched:d.touched,setTouched:l.NOOP,dirty:d.dirty,setDirty:l.NOOP,filled:d.filled,setFilled:l.NOOP,focused:d.focused,setFocused:l.NOOP,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:u,markedDirtyRef:{current:!1},validation:{getValidationProps:(e=l.EMPTY_OBJECT)=>e,getInputValidationProps:(e=l.EMPTY_OBJECT)=>e,inputRef:{current:null},commit:async()=>{}}});function m(e=!0){let t=a.useContext(f);if(t.setValidityData===l.NOOP&&!e)throw Error((0,n.default)(28));return t}let p=a.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0}),v=a.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:l.NOOP,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function g(){return a.useContext(v)}var x=e.i(30628),h=e.i(19805),b=e.i(89879);let y=a.createContext({controlId:void 0,registerControlId:l.NOOP,labelId:void 0,setLabelId:l.NOOP,messageIds:[],setMessageIds:l.NOOP,getDescriptionProps:e=>e});function j(){return a.useContext(y)}let w=function(e){let t=(0,b.useBaseUiId)(),n=void 0===e.controlId?t:e.controlId,[l,s]=a.useState(n),[o,d]=a.useState(e.labelId),[u,c]=a.useState([]),f=(0,x.useRefWithInit)(()=>new Map),{messageIds:m}=j(),p=(0,i.useStableCallback)((e,t)=>{let r=f.current;void 0===t?r.delete(e):(r.set(e,t),s(e=>{let t;if(0!==r.size){for(let a of r.values()){if(void 0!==e&&a===e)return e;void 0===t&&(t=a)}return t}}))}),v=a.useCallback(e=>(0,h.mergeProps)({"aria-describedby":m.concat(u).join(" ")||void 0},e),[m,u]),g=a.useMemo(()=>({controlId:l,registerControlId:p,labelId:o,setLabelId:d,messageIds:u,setMessageIds:c,getDescriptionProps:v}),[l,p,o,d,u,c,v]);return(0,r.jsx)(y.Provider,{value:g,children:e.children})};var M=e.i(27601),C=e.i(66745);function k(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}let N=Object.keys(o),S=a.forwardRef(function(e,t){let{errors:s,validationMode:d,submitAttemptedRef:u}=g(),{render:m,className:v,validate:x,validationDebounceTime:b=0,validationMode:y=d,name:w,disabled:S=!1,invalid:E,dirty:R,touched:L,actionsRef:I,...O}=e,{disabled:P}=function(e=!1){let t=a.useContext(p);if(!t&&!e)throw Error((0,n.default)(86));return t}(),T=(0,i.useStableCallback)(x||(()=>null)),B=P||S,[A,V]=a.useState(!1),[D,_]=a.useState(!1),[z,F]=a.useState(!1),[U,H]=a.useState(!1),$=R??D,q=L??A,G=a.useRef(!1),J=(0,i.useStableCallback)(e=>{void 0===R&&(e&&(G.current=!0),_(e))}),W=(0,i.useStableCallback)(e=>{void 0===L&&V(e)}),K=(0,i.useStableCallback)(()=>"onChange"===y||"onSubmit"===y&&u.current),Y=!!w&&Object.hasOwn(s,w)&&void 0!==s[w],Q=!0===E||Y,[X,Z]=a.useState({state:o,error:"",errors:[],value:null,initialValue:null}),ee=!Q&&X.state.valid,et=a.useMemo(()=>({disabled:B,touched:q,dirty:$,valid:ee,filled:z,focused:U}),[B,q,$,ee,z,U]),er=function(e){let{formRef:t,clearErrors:r}=g(),{setValidityData:n,validate:s,validityData:d,validationDebounceTime:u,invalid:c,markedDirtyRef:f,state:m,name:p,shouldValidateOnChange:v}=e,{controlId:x,getDescriptionProps:b}=j(),y=(0,C.useTimeout)(),w=a.useRef(null),M=(0,i.useStableCallback)(async(e,r=!1)=>{let a,i=w.current;if(!i)return;if(r){if(!1!==m.valid)return;let r=i.validity;if(!r.valueMissing){let r={value:e,state:{...o,valid:!0},error:"",errors:[],initialValue:d.initialValue};if(i.setCustomValidity(""),x){let e=t.current.fields.get(x);e&&t.current.fields.set(x,{...e,...k(r,!1)})}n(r);return}let a=N.reduce((e,t)=>(e[t]=r[t],e),{});if(!a.valid&&!function(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(let r of N)"valid"!==r&&("valueMissing"===r&&(t=e[r]),e[r]&&(t=!1));return t}(a))return}y.clear();let l=null,u=[],p=function(e){let t=N.reduce((t,r)=>(t[r]=e.validity[r],t),{}),r=!1;for(let e of N)if("valid"!==e){if("valueMissing"===e&&t[e])r=!0;else if(t[e])return t}return r&&!f.current&&(t.valid=!0,t.valueMissing=!1),t}(i),g=v();if(i.validationMessage&&!g)a=i.validationMessage,u=[i.validationMessage];else{let r=s(e,Array.from(t.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}));null!==(l="object"==typeof r&&null!==r&&"then"in r?await r:r)?(p.valid=!1,p.customError=!0,Array.isArray(l)?(u=l,i.setCustomValidity(l.join("\n"))):l&&(u=[l],i.setCustomValidity(l))):g&&(i.setCustomValidity(""),p.customError=!1,i.validationMessage?(a=i.validationMessage,u=[i.validationMessage]):i.validity.valid&&!p.valid&&(p.valid=!0))}let h={value:e,state:p,error:a??(Array.isArray(l)?l[0]:l??""),errors:u,initialValue:d.initialValue};if(x){let e=t.current.fields.get(x);e&&t.current.fields.set(x,{...e,...k(h,c)})}n(h)}),S=a.useCallback((e={})=>(0,h.mergeProps)(b,!1===m.valid?{"aria-invalid":!0}:l.EMPTY_OBJECT,e),[b,m.valid]),E=a.useCallback((e={})=>(0,h.mergeProps)({onChange(e){if(e.nativeEvent.defaultPrevented)return;if(r(p),!v())return void M(e.currentTarget.value,!0);let t=e.currentTarget;""===t.value?M(t.value):(y.clear(),u?y.start(u,()=>{M(t.value)}):M(t.value))}},S(e)),[S,r,p,y,M,u,v]);return a.useMemo(()=>({getValidationProps:S,getInputValidationProps:E,inputRef:w,commit:M}),[S,E,M])}({setValidityData:Z,validate:T,validityData:X,validationDebounceTime:b,invalid:Q,markedDirtyRef:G,state:et,name:w,shouldValidateOnChange:K}),ea=a.useCallback(()=>{G.current=!0,er.commit(X.value)},[er,X]);a.useImperativeHandle(I,()=>({validate:ea}),[ea]);let ei=a.useMemo(()=>({invalid:Q,name:w,validityData:X,setValidityData:Z,disabled:B,touched:q,setTouched:W,dirty:$,setDirty:J,filled:z,setFilled:F,focused:U,setFocused:H,validate:T,validationMode:y,validationDebounceTime:b,shouldValidateOnChange:K,state:et,markedDirtyRef:G,validation:er}),[Q,w,X,B,q,W,$,J,z,F,U,H,T,y,b,K,et,er]),en=(0,M.useRenderElement)("div",e,{ref:t,state:et,props:O,stateAttributesMapping:c});return(0,r.jsx)(f.Provider,{value:ei,children:en})}),E=a.forwardRef(function(e,t){return(0,r.jsx)(w,{children:(0,r.jsx)(S,{...e,ref:t})})});var R=e.i(29315),L=e.i(90219),I=e.i(47857),O=e.i(977);function P(e,t){let r=(0,b.useBaseUiId)(e);return(0,O.useIsoLayoutEffect)(()=>(t(r),()=>{t(void 0)}),[r,t]),r}e.s(["useRegisteredLabelId",0,P],24564);let T=a.forwardRef(function(e,t){let{render:r,className:n,id:l,nativeLabel:s=!0,...o}=e,d=m(!1),{labelId:u}=j(),f=a.useRef(null),p=function(e={}){let{id:t,fallbackControlId:r,native:a=!1,setLabelId:n,focusControl:l}=e,{controlId:s,setLabelId:o}=j(),d=P(t,(0,i.useStableCallback)(e=>{o(e),n?.(e)})),u=s??r;function c(e){let t=(0,I.getTarget)(e.nativeEvent);t?.closest("button,input,select,textarea")||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),a||function(e){if(l)return l(e,u);if(!u)return;let t=(0,L.ownerDocument)(e.currentTarget).getElementById(u);(0,R.isHTMLElement)(t)&&t.focus({focusVisible:!0})}(e))}return a?{id:d,htmlFor:u??void 0,onMouseDown:c}:{id:d,onClick:c,onPointerDown(e){e.preventDefault()}}}({id:u??l,native:s});return(0,M.useRenderElement)("label",e,{ref:[t,f],state:d.state,props:[p,o],stateAttributesMapping:c})});var B=e.i(89269),A=e.i(84759),V=e.i(88841);let D={...c,...A.transitionStatusMapping},_=a.forwardRef(function(e,t){let{render:i,id:n,className:l,match:s,...o}=e,d=(0,b.useBaseUiId)(n),{validityData:u,state:c,name:f}=m(!1),{setMessageIds:p}=j(),{errors:v}=g(),x=f?v[f]:null,h=!1;h=!!x||!0===s||(s?!!u.state[s]:!1===u.state.valid);let{mounted:y,transitionStatus:w,setMounted:C}=(0,V.useTransitionStatus)(h);(0,O.useIsoLayoutEffect)(()=>{if(h&&d)return p(e=>e.concat(d)),()=>{p(e=>e.filter(e=>e!==d))}},[h,d,p]);let k=a.useRef(null),[N,S]=a.useState(null),[E,R]=a.useState(null),L=x||(u.errors.length>1?(0,r.jsx)("ul",{children:u.errors.map(e=>(0,r.jsx)("li",{children:e},e))}):u.error),I=u.error;null!=x?I=Array.isArray(x)?JSON.stringify(x):x:u.errors.length>1&&(I=JSON.stringify(u.errors)),h&&I!==E&&(R(I),S(L)),(0,B.useOpenChangeComplete)({open:h,ref:k,onComplete(){h||C(!1)}});let P={...c,transitionStatus:w},T=(0,M.useRenderElement)("div",e,{ref:[t,k],state:P,props:[{id:d,children:h?L:N},o],stateAttributesMapping:D,enabled:y});return y?T:null}),z=a.forwardRef(function(e,t){let{render:r,id:a,className:i,...n}=e,l=(0,b.useBaseUiId)(a),s=m(!1),{setMessageIds:o}=j();return(0,O.useIsoLayoutEffect)(()=>{if(l)return o(e=>e.concat(l)),()=>{o(e=>e.filter(e=>e!==l))}},[l,o]),(0,M.useRenderElement)("p",e,{ref:t,state:s.state,props:[{id:l},n],stateAttributesMapping:c})});function F({controlled:e,default:t,name:r,state:i="value"}){let{current:n}=a.useRef(void 0!==e),[l,s]=a.useState(t),o=a.useCallback(e=>{n||s(e)},[]);return[n?e:l,o]}e.s(["useControlled",0,F],94349);var U=e.i(74080),H=e.i(5963),$=e.i(3404);let q=a.forwardRef(function(e,t){let{render:r,className:n,id:s,name:o,value:d,disabled:u=!1,onValueChange:f,defaultValue:p,autoFocus:v=!1,...h}=e,{state:y,name:w,disabled:C,setTouched:N,setDirty:S,validityData:E,setFocused:P,setFilled:T,validationMode:B,validation:A}=m(),V=C||u,D=w??o,_={...y,disabled:V},{labelId:z}=j(),q=function(e={}){let{id:t,implicit:r=!1,controlRef:n}=e,{controlId:s,registerControlId:o}=j(),d=(0,b.useBaseUiId)(t),u=r?s:void 0,c=(0,x.useRefWithInit)(()=>Symbol("labelable-control")),f=a.useRef(!1),m=a.useRef(null!=t),p=(0,i.useStableCallback)(()=>{f.current&&o!==l.NOOP&&(f.current=!1,o(c.current,void 0))});return(0,O.useIsoLayoutEffect)(()=>{let e;if(o!==l.NOOP){if(r){let r=n?.current;e=(0,R.isElement)(r)&&null!=r.closest("label")?t??null:u??d}else if(null!=t)m.current=!0,e=t;else{if(!m.current)return void p();e=d}if(void 0===e)return void p();f.current=!0,o(c.current,e)}},[t,n,u,o,r,d,c,p]),a.useEffect(()=>p,[p]),s??d}({id:s});(0,O.useIsoLayoutEffect)(()=>{let e=null!=d;A.inputRef.current?.value||e&&""!==d?T(!0):e&&""===d&&T(!1)},[A.inputRef,T,d]);let G=a.useRef(null);(0,O.useIsoLayoutEffect)(()=>{v&&G.current===(0,I.activeElement)((0,L.ownerDocument)(G.current))&&P(!0)},[v,P]);let[J]=F({controlled:d,default:p,name:"FieldControl",state:"value"}),W=void 0!==d,K=W?J:void 0;return!function(e){let{enabled:t=!0,value:r,id:a,name:n,controlRef:l,commit:s}=e,{formRef:o}=g(),{invalid:d,markedDirtyRef:u,validityData:c,setValidityData:f}=m(),p=(0,i.useStableCallback)(e.getValue);(0,O.useIsoLayoutEffect)(()=>{if(!t)return;let e=r;void 0===e&&(e=p()),null===c.initialValue&&null!==e&&f(t=>({...t,initialValue:e}))},[t,f,r,c.initialValue,p]),(0,O.useIsoLayoutEffect)(()=>{t&&a&&o.current.fields.set(a,{getValue:p,name:n,controlRef:l,validityData:k(c,d),validate(e=!0){let t=r;void 0===t&&(t=p()),u.current=!0,e?U.flushSync(()=>s(t)):s(t)}})},[s,l,t,o,p,a,d,u,n,c,r]),(0,O.useIsoLayoutEffect)(()=>{let e=o.current.fields;return()=>{a&&e.delete(a)}},[o,a])}({id:q,name:D,commit:A.commit,value:K,getValue:()=>A.inputRef.current?.value,controlRef:A.inputRef}),(0,M.useRenderElement)("input",e,{ref:[t,G],state:_,props:[{id:q,disabled:V,name:D,ref:A.inputRef,"aria-labelledby":z,autoFocus:v,...W?{value:K}:{defaultValue:p},onChange(e){let t=e.currentTarget.value;f?.(t,(0,H.createChangeEventDetails)($.REASONS.none,e.nativeEvent)),S(t!==E.initialValue),T(""!==t)},onFocus(){P(!0)},onBlur(e){N(!0),P(!1),"onBlur"===B&&A.commit(e.currentTarget.value)},onKeyDown(e){"INPUT"===e.currentTarget.tagName&&"Enter"===e.key&&(N(!0),A.commit(e.currentTarget.value))}},A.getInputValidationProps(),h],stateAttributesMapping:c})}),G=a.createContext({disabled:!1}),J=a.createContext(void 0),W=a.forwardRef(function(e,t){let{render:i,className:l,disabled:s=!1,...o}=e,{state:d,disabled:u}=m(!1),f=u||s,p=function(e=!0){let t=a.useContext(J);if(void 0===t&&!e)throw Error((0,n.default)(3));return t}(),v=p?.parent.id,g=p?.allValues!==void 0,x=a.useMemo(()=>({disabled:f}),[f]),h=(0,M.useRenderElement)("div",e,{ref:t,state:d,props:o,stateAttributesMapping:c});return(0,r.jsx)(w,{controlId:g?v:void 0,children:(0,r.jsx)(G.Provider,{value:x,children:h})})});e.s(["Control",0,q,"Description",0,z,"Error",0,_,"Item",0,W,"Label",0,T,"Root",0,E,"Validity",0,function(e){let{children:t}=e,{validityData:i,invalid:n}=m(!1),l=a.useMemo(()=>k(i,n),[i,n]),s=!1===l.state.valid,{transitionStatus:o}=(0,V.useTransitionStatus)(s),d=a.useMemo(()=>({...l,validity:l.state,transitionStatus:o}),[l,o]);return(0,r.jsx)(a.Fragment,{children:t(d)})}],71975);var K=e.i(71975),K=K;let Y=a.forwardRef(function(e,t){return(0,r.jsx)(K.Control,{ref:t,...e})});var Q=e.i(52088);e.s(["Input",0,function({className:e,type:t,...a}){return(0,r.jsx)(Y,{type:t,"data-slot":"input",className:(0,Q.cn)("h-9 w-full min-w-0 rounded-md border border-input bg-input/20 px-3 py-1 text-sm transition-colors outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}],10012)},41247,e=>{"use strict";var t=e.i(18050),r=e.i(52088);e.s(["Textarea",0,function({className:e,...a}){return(0,t.jsx)("textarea",{"data-slot":"textarea",className:(0,r.cn)("flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-input/20 px-2 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}])},86536,e=>{"use strict";let t=(0,e.i(75254).default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Eye",0,t],86536)},27612,e=>{"use strict";let t=(0,e.i(75254).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",0,t],27612)},95468,e=>{"use strict";var t=e.i(23287);e.s(["CheckCircle2",()=>t.default])},77814,e=>{"use strict";var t,r=e.i(18050);e.s([],33847),e.i(33847),e.i(47167);var a=e.i(71645),i=e.i(231),n=e.i(62372);let l=new Map;function s(e,t,r){return null==e?"":(function(e,t){let r=JSON.stringify({locale:e,options:t}),a=l.get(r);if(a)return a;let i=new Intl.NumberFormat(e,t);return l.set(r,i),i})(t,r).format(e)}var o=e.i(27601),d=e.i(67805);let u=a.createContext(void 0);function c(){let e=a.useContext(u);if(void 0===e)throw Error((0,d.default)(51));return e}let f=((t={}).complete="data-complete",t.indeterminate="data-indeterminate",t.progressing="data-progressing",t),m={status:e=>"progressing"===e?{[f.progressing]:""}:"complete"===e?{[f.complete]:""}:"indeterminate"===e?{[f.indeterminate]:""}:null};function p(e,t){return null==t?"indeterminate progress":e||`${t}%`}let v=a.forwardRef(function(e,t){var l;let{format:d,getAriaValueText:c=p,locale:f,max:v=100,min:g=0,value:x,render:h,className:b,children:y,...j}=e,[w,M]=a.useState(),C=(0,i.useValueAsRef)(d),k="indeterminate";Number.isFinite(x)&&(k=x===v?"complete":"progressing");let N=(l=C.current,null==x?"":l?s(x,f,l):s(x/100,f,{style:"percent"})),S=a.useMemo(()=>({status:k}),[k]),E={"aria-labelledby":w,"aria-valuemax":v,"aria-valuemin":g,"aria-valuenow":x??void 0,"aria-valuetext":c(N,x),role:"progressbar",children:(0,r.jsxs)(a.Fragment,{children:[y,(0,r.jsx)("span",{role:"presentation",style:n.visuallyHidden,children:"x"})]})},R=a.useMemo(()=>({formattedValue:N,max:v,min:g,setLabelId:M,state:S,status:k,value:x}),[N,v,g,M,S,k,x]),L=(0,o.useRenderElement)("div",e,{state:S,ref:t,props:[E,j],stateAttributesMapping:m});return(0,r.jsx)(u.Provider,{value:R,children:L})}),g=a.forwardRef(function(e,t){let{render:r,className:a,...i}=e,{state:n}=c();return(0,o.useRenderElement)("div",e,{state:n,ref:t,props:i,stateAttributesMapping:m})}),x=a.forwardRef(function(e,t){let{render:r,className:i,...n}=e,{max:l,min:s,value:d,state:u}=c(),f=Number.isFinite(d)&&null!==d?(d-s)*100/(l-s):null,p=a.useCallback(()=>null==f?{}:{insetInlineStart:0,height:"inherit",width:`${f}%`},[f]);return(0,o.useRenderElement)("div",e,{state:u,ref:t,props:[{style:p()},n],stateAttributesMapping:m})}),h=a.forwardRef(function(e,t){let{className:r,render:a,children:i,...n}=e,{value:l,formattedValue:s,state:d}=c(),u=null==l?"indeterminate":s,f=null==l?null:s;return(0,o.useRenderElement)("span",e,{state:d,ref:t,props:[{"aria-hidden":!0,children:"function"==typeof i?i(u,l):f},n],stateAttributesMapping:m})});var b=e.i(24564);let y=a.forwardRef(function(e,t){let{render:r,className:a,id:i,...n}=e,{setLabelId:l,state:s}=c(),d=(0,b.useRegisteredLabelId)(i,l);return(0,o.useRenderElement)("span",e,{state:s,ref:t,props:[{id:d,role:"presentation"},n],stateAttributesMapping:m})});e.s(["Indicator",0,x,"Label",0,y,"Root",0,v,"Track",0,g,"Value",0,h],45929);var j=e.i(45929),j=j,w=e.i(52088);function M({className:e,...t}){return(0,r.jsx)(j.Track,{className:(0,w.cn)("relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted",e),"data-slot":"progress-track",...t})}function C({className:e,...t}){return(0,r.jsx)(j.Indicator,{"data-slot":"progress-indicator",className:(0,w.cn)("h-full bg-primary",e),style:{transition:"width 500ms ease-in-out"},...t})}e.s(["Progress",0,function({className:e,children:t,value:a,...i}){return(0,r.jsxs)(j.Root,{value:a,"data-slot":"progress",className:(0,w.cn)("flex flex-wrap gap-3",e),...i,children:[t,(0,r.jsx)(M,{children:(0,r.jsx)(C,{})})]})}],77814)},31245,e=>{"use strict";let t=(0,e.i(75254).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);e.s(["Bot",0,t],31245)},63209,e=>{"use strict";let t=(0,e.i(75254).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",0,t],63209)},87951,52044,e=>{"use strict";var t=e.i(75254);let r=(0,t.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);e.s(["Mic",0,r],87951);let a=(0,t.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);e.s(["Square",0,a],52044)},57024,e=>{"use strict";var t=e.i(85699);function r(e){let{type:r,title:a,description:i,duration:n}=e,l=e.id??crypto.randomUUID(),s={id:l,description:i,duration:n};switch(r){case"loading":t.toast.loading(a,s);break;case"success":t.toast.success(a,s);break;case"error":t.toast.error(a,s);break;case"warning":t.toast.warning(a,s);break;case"info":t.toast.info(a,s);break;default:(0,t.toast)(a,s)}return l}e.s(["toaster",0,{create:e=>r(e),update:(e,t)=>{r({...t,id:e})},dismiss:e=>{t.toast.dismiss(e)}}])},58e3,e=>{"use strict";let t=(0,e.i(75254).default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["CircleHelp",0,t],58e3)},64036,e=>{"use strict";var t=e.i(18050),r=e.i(52088);e.s(["Card",0,function({className:e,size:a="default",...i}){return(0,t.jsx)("div",{"data-slot":"card","data-size":a,className:(0,r.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-lg bg-card py-4 text-xs/relaxed text-card-foreground ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg",e),...i})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-4 group-data-[size=sm]/card:px-3",e),...a})},"CardDescription",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,r.cn)("text-xs/relaxed text-muted-foreground",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("font-heading text-sm font-medium",e),...a})}])},31449,66961,e=>{"use strict";var t=e.i(18050),r=e.i(71645),a=e.i(31278),i=e.i(87951),n=e.i(52044),l=e.i(85902),s=e.i(70935),o=e.i(57024),d=e.i(31245),u=e.i(95468),c=e.i(58e3),f=e.i(64036),m=e.i(68995),p=e.i(77814);let v="tsunagi:local-llm-enabled",g={not_running:"停止中",installing_deps:"依存関係をインストール中...",downloading_model:"モデルをダウンロード中...",starting_server:"サーバーを起動中... (モデルのロードに数十秒かかる場合があります)",running:"実行中",running_external:"実行中 (tsunagi外で起動)",error:"エラー"},x=["installing_deps","downloading_model","starting_server"],h=["running","running_external"];function b(e){let t=e/0x40000000;return t>=.1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(0)} MB`}e.s(["LOCAL_LLM_ENABLED_STORAGE_KEY",0,v,"LocalLlmSection",0,function(){let[e,i]=(0,r.useState)(!1),[y,j]=(0,r.useState)(!1),[w,M]=(0,r.useState)(null),C=(0,r.useRef)(null),k=(0,r.useCallback)(e=>{i(e),localStorage.setItem(v,String(e))},[]),N=(0,r.useCallback)(async()=>{let e=await fetch((0,s.apiUrl)("/api/llm/server/status")),t=await e.json();return M(t),t},[]);(0,r.useEffect)(()=>{i("true"===localStorage.getItem(v)),N()},[N]),(0,r.useEffect)(()=>{w&&h.includes(w.step)&&!e&&(k(!0),o.toaster.create({type:"success",title:"ローカルLLMが有効化されました"}))},[w,e,k]),(0,r.useEffect)(()=>(w&&x.includes(w.step)&&!C.current&&(C.current=setInterval(()=>{N().then(e=>{!x.includes(e.step)&&C.current&&(clearInterval(C.current),C.current=null)})},1e3)),()=>{C.current&&(clearInterval(C.current),C.current=null)}),[w,N]);let S=(0,r.useCallback)(()=>{N(),j(!0)},[N]),E=(0,r.useCallback)(async()=>{try{let e=await fetch((0,s.apiUrl)("/api/llm/server/start"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}M(await e.json())}catch(e){o.toaster.create({type:"error",title:"サーバーの起動に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),R=(0,r.useCallback)(async()=>{try{let e=await fetch((0,s.apiUrl)("/api/llm/server/stop"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}M(await e.json())}catch(e){o.toaster.create({type:"error",title:"サーバーの停止に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),L=(0,r.useCallback)(()=>{k(!1),w&&h.includes(w.step)&&R()},[k,R,w]),I=w?.serverDir,O=w?.downloadProgress,P=O?O.downloadedBytes/O.totalBytes*100:0;return(0,t.jsxs)(f.Card,{children:[(0,t.jsxs)(f.CardHeader,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(f.CardTitle,{children:"ローカルLLM (実験的機能)"}),(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:S,title:"ローカルLLMについて",children:(0,t.jsx)(c.CircleHelp,{})})]}),(0,t.jsxs)(f.CardDescription,{children:["ローカルで動作するLLM(Qwen3-30B-A3B, MoE)を利用します。",(0,t.jsx)("strong",{className:"font-medium text-foreground",children:"有効にすると、音声入力の文字起こし結果がこのLLMで自動整形されるようになります"}),"(無効時は文字起こし結果をそのまま使用)。"]})]}),(0,t.jsx)(f.CardContent,{className:"flex flex-col gap-3",children:e?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(u.CheckCircle2,{className:"size-4"}),"ローカルLLM: 有効"]}),w&&(0,t.jsxs)("span",{className:"text-xs/relaxed text-muted-foreground",children:["(",g[w.step],")"]}),(0,t.jsx)(l.Button,{size:"default",variant:"outline",onClick:L,children:"無効にする"})]}):(0,t.jsxs)(l.Button,{size:"default",onClick:S,children:[(0,t.jsx)(d.Bot,{}),"ローカルLLMを有効化する"]})}),(0,t.jsx)(m.Dialog,{open:y,onOpenChange:({open:e})=>j(e),title:"ローカルLLMについて",maxWidth:"2xl",children:(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"実験的機能です"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"音声入力の文字起こし結果を、ローカルで動作するLLM(mlx-lm / Qwen3-30B-A3B, MoE構成)で整形します。MoE構成のため実計算に使うアクティブパラメータは約3Bで、denseな同規模モデルより高速に動作します。精度・速度は環境に依存し、今後変更される可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"対応環境"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Apple Silicon Mac (M1/M2/M3/M4) のみ対応。Windows/Linuxでは利用できません。メモリ32GB以上を推奨します。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"必要なもの(事前に手動でインストール)"}),(0,t.jsx)("ul",{className:"list-disc pl-5 text-muted-foreground",children:(0,t.jsx)("li",{children:"Python 3.9以降(Xcode Command Line Tools または Homebrew経由で入手可能)"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"セットアップ・起動"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"下のボタンから、依存関係のインストール・モデルのダウンロード・サーバー起動まで自動で行われます(初回はモデルサイズが大きく数分〜数十分かかります)。"}),w&&!I&&(0,t.jsx)("p",{className:"mt-1 text-destructive",children:"llm-serverが見つかりませんでした。インストールが壊れている可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"アンインストール"}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:["ローカルLLMのためにダウンロードされるもの(Pythonの依存関係・LLMモデル、合計約17GB)は全て",(0,t.jsx)("code",{className:"rounded bg-muted px-1",children:"~/.tsunagi/llm"}),"に保存されます。不要になった場合はこのディレクトリを削除するだけで、関連リソースを完全に削除できます。"]})]}),(0,t.jsxs)("div",{className:"border-t border-border pt-4",children:[(!w||"not_running"===w.step||"error"===w.step)&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)(l.Button,{size:"default",onClick:()=>void E(),disabled:!w,children:[w?(0,t.jsx)(d.Bot,{}):(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"LLMサーバーを起動"]}),w?.step==="error"&&w.error&&(0,t.jsx)("p",{className:"text-xs/relaxed text-destructive",children:w.error})]}),w?.step==="installing_deps"&&(0,t.jsxs)(l.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"依存関係をインストール中... (数分かかる場合があります)"]}),w?.step==="downloading_model"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs/relaxed text-muted-foreground",children:[(0,t.jsx)(a.Loader2,{className:"size-4 animate-spin"}),"モデルをダウンロード中... (約17GB)"]}),O&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.Progress,{value:P}),(0,t.jsxs)("p",{className:"text-xs/relaxed text-muted-foreground",children:[b(O.downloadedBytes)," / ",b(O.totalBytes)," (",P.toFixed(0),"%) ・ ",function(e){if(null===e)return"残り時間を計算中...";if(e<60)return`残り約${e}秒`;let t=Math.floor(e/60);return`残り約${t}分${e%60}秒`}(O.etaSeconds)]})]})]}),w?.step==="starting_server"&&(0,t.jsxs)(l.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"サーバーを起動中... (モデルのロードに数十秒かかる場合があります)"]}),w&&h.includes(w.step)&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(u.CheckCircle2,{className:"size-4"}),"サーバーは起動しています"]}),(0,t.jsxs)(l.Button,{size:"default",variant:"outline",onClick:()=>void R(),children:[(0,t.jsx)(n.Square,{}),"サーバーを停止"]})]})]})]})})]})}],66961);let y="tsunagi:whisper-prompt",j=["running","running_external"];e.s(["VoiceInputButton",0,function({onTranscribed:e}){let[d,u]=(0,r.useState)(!1),[c,f]=(0,r.useState)("idle"),[m,p]=(0,r.useState)(0),[g,x]=(0,r.useState)(null),h=(0,r.useRef)(null),b=(0,r.useRef)([]),w=(0,r.useRef)(null),M=(0,r.useRef)(null),C=(0,r.useRef)(null),k=(0,r.useRef)(0),N=(0,r.useRef)(0);(0,r.useEffect)(()=>{u("true"===localStorage.getItem("tsunagi:voice-input-enabled"))},[]),(0,r.useEffect)(()=>{if(!d)return;let e=!1,t=async()=>{try{let t=await fetch((0,s.apiUrl)("/api/whisper/server/status")),r=await t.json();e||x(r.step)}catch{e||x("not_running")}};t();let r=setInterval(t,5e3);return()=>{e=!0,clearInterval(r)}},[d]);let S=(0,r.useCallback)(()=>{C.current&&(clearInterval(C.current),C.current=null),M.current?.close(),M.current=null,p(0)},[]);(0,r.useEffect)(()=>()=>{S()},[S]);let E=(0,r.useCallback)(e=>{let t=new AudioContext,r=t.createMediaStreamSource(e),a=t.createAnalyser();a.fftSize=2048,r.connect(a),M.current=t,k.current=0,N.current=0;let i=new Float32Array(a.fftSize);C.current=setInterval(()=>{a.getFloatTimeDomainData(i);let e=0;for(let t=0;t<i.length;t++)e+=i[t]*i[t];let t=Math.sqrt(e/i.length),r=Math.min(1,Math.max(0,((t>0?20*Math.log10(t):-60)- -60)/50));N.current=Math.max(N.current,r),k.current=.3*k.current+.7*r,p(k.current)},50)},[]),R=(0,r.useCallback)(async t=>{f("transcribing");try{let r=new FormData,a=localStorage.getItem(y);a&&r.append("prompt",a);let i="true"===localStorage.getItem(v);r.append("useLlm",String(i)),r.append("file",t,"recording.webm");let n=await fetch((0,s.apiUrl)("/api/whisper/transcribe"),{method:"POST",body:r});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`HTTPエラー: ${n.status}`)}let l=await n.json();l.warning&&o.toaster.create({type:"error",title:"LLM整形をスキップしました",description:l.warning}),l.text&&e(l.text)}catch(e){o.toaster.create({type:"error",title:"文字起こしに失敗しました",description:e instanceof Error?e.message:String(e)})}finally{f("idle")}},[e]),L=(0,r.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});w.current=e,b.current=[],E(e);let t=new MediaRecorder(e,{audioBitsPerSecond:128e3});t.ondataavailable=e=>{e.data.size>0&&b.current.push(e.data)},t.onstop=()=>{w.current?.getTracks().forEach(e=>e.stop()),w.current=null;let e=N.current;if(S(),e<.15){o.toaster.create({type:"error",title:"音声が検出されませんでした",description:"マイクに向かって話してから、もう一度お試しください。"}),f("idle");return}let t=new Blob(b.current,{type:"audio/webm"});R(t)},h.current=t,t.start(),f("recording")}catch(e){o.toaster.create({type:"error",title:"マイクにアクセスできませんでした",description:e instanceof Error?e.message:String(e)})}},[R,E,S]),I=(0,r.useCallback)(()=>{h.current?.stop()},[]);if(!d)return null;let O=null!==g&&j.includes(g);return(0,t.jsxs)("div",{className:"recording"===c?"inline-flex items-center gap-2 rounded-md bg-destructive/10 p-1":"inline-flex",children:[(0,t.jsx)(l.Button,{size:"icon",variant:"recording"===c?"destructive":"default",onClick:"recording"===c?I:()=>void L(),disabled:"transcribing"===c||"idle"===c&&!O,title:"recording"===c?"停止して入力":"idle"!==c||O?"音声入力":"Whisperサーバーが起動していません(Settingsから起動してください)",children:"transcribing"===c?(0,t.jsx)(a.Loader2,{className:"w-4 h-4 animate-spin"}):"recording"===c?(0,t.jsx)(n.Square,{className:"w-4 h-4"}):(0,t.jsx)(i.Mic,{className:"w-4 h-4"})}),"recording"===c&&(0,t.jsx)("div",{"aria-hidden":!0,className:"h-1.5 w-16 overflow-hidden rounded-full bg-background/60",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-destructive",style:{width:`${Math.round(100*m)}%`}})})]})},"WHISPER_PROMPT_STORAGE_KEY",0,y],31449)},51846,e=>{"use strict";var t=e.i(71645);e.s(["useDocumentTitle",0,function(e){(0,t.useEffect)(()=>{let t=e?`繋 | ${e}`:"繋",r=document.title;return document.title=t,()=>{document.title=r}},[e])}])}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,t,r)=>{t.exports=e.r(76562)},43531,78745,e=>{"use strict";let t=(0,e.i(75254).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["default",0,t],78745),e.s(["Check",0,t],43531)},86536,e=>{"use strict";let t=(0,e.i(75254).default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Eye",0,t],86536)},27612,e=>{"use strict";let t=(0,e.i(75254).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",0,t],27612)},10012,24564,94349,e=>{"use strict";var t,r=e.i(18050);e.i(47167);var a=e.i(71645);e.s([],19485),e.i(19485);var i=e.i(76477),n=e.i(67805),l=e.i(17514);let s=((t={}).disabled="data-disabled",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t),o={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},d={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},u={disabled:!1,...d},c={valid:e=>null===e?null:e?{[s.valid]:""}:{[s.invalid]:""}},f=a.createContext({invalid:void 0,name:void 0,validityData:{state:o,errors:[],error:"",value:"",initialValue:null},setValidityData:l.NOOP,disabled:void 0,touched:d.touched,setTouched:l.NOOP,dirty:d.dirty,setDirty:l.NOOP,filled:d.filled,setFilled:l.NOOP,focused:d.focused,setFocused:l.NOOP,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:u,markedDirtyRef:{current:!1},validation:{getValidationProps:(e=l.EMPTY_OBJECT)=>e,getInputValidationProps:(e=l.EMPTY_OBJECT)=>e,inputRef:{current:null},commit:async()=>{}}});function m(e=!0){let t=a.useContext(f);if(t.setValidityData===l.NOOP&&!e)throw Error((0,n.default)(28));return t}let p=a.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0}),v=a.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:l.NOOP,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function g(){return a.useContext(v)}var x=e.i(30628),h=e.i(19805),b=e.i(89879);let y=a.createContext({controlId:void 0,registerControlId:l.NOOP,labelId:void 0,setLabelId:l.NOOP,messageIds:[],setMessageIds:l.NOOP,getDescriptionProps:e=>e});function j(){return a.useContext(y)}let w=function(e){let t=(0,b.useBaseUiId)(),n=void 0===e.controlId?t:e.controlId,[l,s]=a.useState(n),[o,d]=a.useState(e.labelId),[u,c]=a.useState([]),f=(0,x.useRefWithInit)(()=>new Map),{messageIds:m}=j(),p=(0,i.useStableCallback)((e,t)=>{let r=f.current;void 0===t?r.delete(e):(r.set(e,t),s(e=>{let t;if(0!==r.size){for(let a of r.values()){if(void 0!==e&&a===e)return e;void 0===t&&(t=a)}return t}}))}),v=a.useCallback(e=>(0,h.mergeProps)({"aria-describedby":m.concat(u).join(" ")||void 0},e),[m,u]),g=a.useMemo(()=>({controlId:l,registerControlId:p,labelId:o,setLabelId:d,messageIds:u,setMessageIds:c,getDescriptionProps:v}),[l,p,o,d,u,c,v]);return(0,r.jsx)(y.Provider,{value:g,children:e.children})};var M=e.i(27601),C=e.i(66745);function k(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}let N=Object.keys(o),S=a.forwardRef(function(e,t){let{errors:s,validationMode:d,submitAttemptedRef:u}=g(),{render:m,className:v,validate:x,validationDebounceTime:b=0,validationMode:y=d,name:w,disabled:S=!1,invalid:E,dirty:R,touched:L,actionsRef:I,...O}=e,{disabled:P}=function(e=!1){let t=a.useContext(p);if(!t&&!e)throw Error((0,n.default)(86));return t}(),T=(0,i.useStableCallback)(x||(()=>null)),B=P||S,[A,V]=a.useState(!1),[D,_]=a.useState(!1),[z,F]=a.useState(!1),[U,H]=a.useState(!1),$=R??D,q=L??A,G=a.useRef(!1),J=(0,i.useStableCallback)(e=>{void 0===R&&(e&&(G.current=!0),_(e))}),W=(0,i.useStableCallback)(e=>{void 0===L&&V(e)}),K=(0,i.useStableCallback)(()=>"onChange"===y||"onSubmit"===y&&u.current),Y=!!w&&Object.hasOwn(s,w)&&void 0!==s[w],Q=!0===E||Y,[X,Z]=a.useState({state:o,error:"",errors:[],value:null,initialValue:null}),ee=!Q&&X.state.valid,et=a.useMemo(()=>({disabled:B,touched:q,dirty:$,valid:ee,filled:z,focused:U}),[B,q,$,ee,z,U]),er=function(e){let{formRef:t,clearErrors:r}=g(),{setValidityData:n,validate:s,validityData:d,validationDebounceTime:u,invalid:c,markedDirtyRef:f,state:m,name:p,shouldValidateOnChange:v}=e,{controlId:x,getDescriptionProps:b}=j(),y=(0,C.useTimeout)(),w=a.useRef(null),M=(0,i.useStableCallback)(async(e,r=!1)=>{let a,i=w.current;if(!i)return;if(r){if(!1!==m.valid)return;let r=i.validity;if(!r.valueMissing){let r={value:e,state:{...o,valid:!0},error:"",errors:[],initialValue:d.initialValue};if(i.setCustomValidity(""),x){let e=t.current.fields.get(x);e&&t.current.fields.set(x,{...e,...k(r,!1)})}n(r);return}let a=N.reduce((e,t)=>(e[t]=r[t],e),{});if(!a.valid&&!function(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(let r of N)"valid"!==r&&("valueMissing"===r&&(t=e[r]),e[r]&&(t=!1));return t}(a))return}y.clear();let l=null,u=[],p=function(e){let t=N.reduce((t,r)=>(t[r]=e.validity[r],t),{}),r=!1;for(let e of N)if("valid"!==e){if("valueMissing"===e&&t[e])r=!0;else if(t[e])return t}return r&&!f.current&&(t.valid=!0,t.valueMissing=!1),t}(i),g=v();if(i.validationMessage&&!g)a=i.validationMessage,u=[i.validationMessage];else{let r=s(e,Array.from(t.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}));null!==(l="object"==typeof r&&null!==r&&"then"in r?await r:r)?(p.valid=!1,p.customError=!0,Array.isArray(l)?(u=l,i.setCustomValidity(l.join("\n"))):l&&(u=[l],i.setCustomValidity(l))):g&&(i.setCustomValidity(""),p.customError=!1,i.validationMessage?(a=i.validationMessage,u=[i.validationMessage]):i.validity.valid&&!p.valid&&(p.valid=!0))}let h={value:e,state:p,error:a??(Array.isArray(l)?l[0]:l??""),errors:u,initialValue:d.initialValue};if(x){let e=t.current.fields.get(x);e&&t.current.fields.set(x,{...e,...k(h,c)})}n(h)}),S=a.useCallback((e={})=>(0,h.mergeProps)(b,!1===m.valid?{"aria-invalid":!0}:l.EMPTY_OBJECT,e),[b,m.valid]),E=a.useCallback((e={})=>(0,h.mergeProps)({onChange(e){if(e.nativeEvent.defaultPrevented)return;if(r(p),!v())return void M(e.currentTarget.value,!0);let t=e.currentTarget;""===t.value?M(t.value):(y.clear(),u?y.start(u,()=>{M(t.value)}):M(t.value))}},S(e)),[S,r,p,y,M,u,v]);return a.useMemo(()=>({getValidationProps:S,getInputValidationProps:E,inputRef:w,commit:M}),[S,E,M])}({setValidityData:Z,validate:T,validityData:X,validationDebounceTime:b,invalid:Q,markedDirtyRef:G,state:et,name:w,shouldValidateOnChange:K}),ea=a.useCallback(()=>{G.current=!0,er.commit(X.value)},[er,X]);a.useImperativeHandle(I,()=>({validate:ea}),[ea]);let ei=a.useMemo(()=>({invalid:Q,name:w,validityData:X,setValidityData:Z,disabled:B,touched:q,setTouched:W,dirty:$,setDirty:J,filled:z,setFilled:F,focused:U,setFocused:H,validate:T,validationMode:y,validationDebounceTime:b,shouldValidateOnChange:K,state:et,markedDirtyRef:G,validation:er}),[Q,w,X,B,q,W,$,J,z,F,U,H,T,y,b,K,et,er]),en=(0,M.useRenderElement)("div",e,{ref:t,state:et,props:O,stateAttributesMapping:c});return(0,r.jsx)(f.Provider,{value:ei,children:en})}),E=a.forwardRef(function(e,t){return(0,r.jsx)(w,{children:(0,r.jsx)(S,{...e,ref:t})})});var R=e.i(29315),L=e.i(90219),I=e.i(47857),O=e.i(977);function P(e,t){let r=(0,b.useBaseUiId)(e);return(0,O.useIsoLayoutEffect)(()=>(t(r),()=>{t(void 0)}),[r,t]),r}e.s(["useRegisteredLabelId",0,P],24564);let T=a.forwardRef(function(e,t){let{render:r,className:n,id:l,nativeLabel:s=!0,...o}=e,d=m(!1),{labelId:u}=j(),f=a.useRef(null),p=function(e={}){let{id:t,fallbackControlId:r,native:a=!1,setLabelId:n,focusControl:l}=e,{controlId:s,setLabelId:o}=j(),d=P(t,(0,i.useStableCallback)(e=>{o(e),n?.(e)})),u=s??r;function c(e){let t=(0,I.getTarget)(e.nativeEvent);t?.closest("button,input,select,textarea")||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),a||function(e){if(l)return l(e,u);if(!u)return;let t=(0,L.ownerDocument)(e.currentTarget).getElementById(u);(0,R.isHTMLElement)(t)&&t.focus({focusVisible:!0})}(e))}return a?{id:d,htmlFor:u??void 0,onMouseDown:c}:{id:d,onClick:c,onPointerDown(e){e.preventDefault()}}}({id:u??l,native:s});return(0,M.useRenderElement)("label",e,{ref:[t,f],state:d.state,props:[p,o],stateAttributesMapping:c})});var B=e.i(89269),A=e.i(84759),V=e.i(88841);let D={...c,...A.transitionStatusMapping},_=a.forwardRef(function(e,t){let{render:i,id:n,className:l,match:s,...o}=e,d=(0,b.useBaseUiId)(n),{validityData:u,state:c,name:f}=m(!1),{setMessageIds:p}=j(),{errors:v}=g(),x=f?v[f]:null,h=!1;h=!!x||!0===s||(s?!!u.state[s]:!1===u.state.valid);let{mounted:y,transitionStatus:w,setMounted:C}=(0,V.useTransitionStatus)(h);(0,O.useIsoLayoutEffect)(()=>{if(h&&d)return p(e=>e.concat(d)),()=>{p(e=>e.filter(e=>e!==d))}},[h,d,p]);let k=a.useRef(null),[N,S]=a.useState(null),[E,R]=a.useState(null),L=x||(u.errors.length>1?(0,r.jsx)("ul",{children:u.errors.map(e=>(0,r.jsx)("li",{children:e},e))}):u.error),I=u.error;null!=x?I=Array.isArray(x)?JSON.stringify(x):x:u.errors.length>1&&(I=JSON.stringify(u.errors)),h&&I!==E&&(R(I),S(L)),(0,B.useOpenChangeComplete)({open:h,ref:k,onComplete(){h||C(!1)}});let P={...c,transitionStatus:w},T=(0,M.useRenderElement)("div",e,{ref:[t,k],state:P,props:[{id:d,children:h?L:N},o],stateAttributesMapping:D,enabled:y});return y?T:null}),z=a.forwardRef(function(e,t){let{render:r,id:a,className:i,...n}=e,l=(0,b.useBaseUiId)(a),s=m(!1),{setMessageIds:o}=j();return(0,O.useIsoLayoutEffect)(()=>{if(l)return o(e=>e.concat(l)),()=>{o(e=>e.filter(e=>e!==l))}},[l,o]),(0,M.useRenderElement)("p",e,{ref:t,state:s.state,props:[{id:l},n],stateAttributesMapping:c})});function F({controlled:e,default:t,name:r,state:i="value"}){let{current:n}=a.useRef(void 0!==e),[l,s]=a.useState(t),o=a.useCallback(e=>{n||s(e)},[]);return[n?e:l,o]}e.s(["useControlled",0,F],94349);var U=e.i(74080),H=e.i(5963),$=e.i(3404);let q=a.forwardRef(function(e,t){let{render:r,className:n,id:s,name:o,value:d,disabled:u=!1,onValueChange:f,defaultValue:p,autoFocus:v=!1,...h}=e,{state:y,name:w,disabled:C,setTouched:N,setDirty:S,validityData:E,setFocused:P,setFilled:T,validationMode:B,validation:A}=m(),V=C||u,D=w??o,_={...y,disabled:V},{labelId:z}=j(),q=function(e={}){let{id:t,implicit:r=!1,controlRef:n}=e,{controlId:s,registerControlId:o}=j(),d=(0,b.useBaseUiId)(t),u=r?s:void 0,c=(0,x.useRefWithInit)(()=>Symbol("labelable-control")),f=a.useRef(!1),m=a.useRef(null!=t),p=(0,i.useStableCallback)(()=>{f.current&&o!==l.NOOP&&(f.current=!1,o(c.current,void 0))});return(0,O.useIsoLayoutEffect)(()=>{let e;if(o!==l.NOOP){if(r){let r=n?.current;e=(0,R.isElement)(r)&&null!=r.closest("label")?t??null:u??d}else if(null!=t)m.current=!0,e=t;else{if(!m.current)return void p();e=d}if(void 0===e)return void p();f.current=!0,o(c.current,e)}},[t,n,u,o,r,d,c,p]),a.useEffect(()=>p,[p]),s??d}({id:s});(0,O.useIsoLayoutEffect)(()=>{let e=null!=d;A.inputRef.current?.value||e&&""!==d?T(!0):e&&""===d&&T(!1)},[A.inputRef,T,d]);let G=a.useRef(null);(0,O.useIsoLayoutEffect)(()=>{v&&G.current===(0,I.activeElement)((0,L.ownerDocument)(G.current))&&P(!0)},[v,P]);let[J]=F({controlled:d,default:p,name:"FieldControl",state:"value"}),W=void 0!==d,K=W?J:void 0;return!function(e){let{enabled:t=!0,value:r,id:a,name:n,controlRef:l,commit:s}=e,{formRef:o}=g(),{invalid:d,markedDirtyRef:u,validityData:c,setValidityData:f}=m(),p=(0,i.useStableCallback)(e.getValue);(0,O.useIsoLayoutEffect)(()=>{if(!t)return;let e=r;void 0===e&&(e=p()),null===c.initialValue&&null!==e&&f(t=>({...t,initialValue:e}))},[t,f,r,c.initialValue,p]),(0,O.useIsoLayoutEffect)(()=>{t&&a&&o.current.fields.set(a,{getValue:p,name:n,controlRef:l,validityData:k(c,d),validate(e=!0){let t=r;void 0===t&&(t=p()),u.current=!0,e?U.flushSync(()=>s(t)):s(t)}})},[s,l,t,o,p,a,d,u,n,c,r]),(0,O.useIsoLayoutEffect)(()=>{let e=o.current.fields;return()=>{a&&e.delete(a)}},[o,a])}({id:q,name:D,commit:A.commit,value:K,getValue:()=>A.inputRef.current?.value,controlRef:A.inputRef}),(0,M.useRenderElement)("input",e,{ref:[t,G],state:_,props:[{id:q,disabled:V,name:D,ref:A.inputRef,"aria-labelledby":z,autoFocus:v,...W?{value:K}:{defaultValue:p},onChange(e){let t=e.currentTarget.value;f?.(t,(0,H.createChangeEventDetails)($.REASONS.none,e.nativeEvent)),S(t!==E.initialValue),T(""!==t)},onFocus(){P(!0)},onBlur(e){N(!0),P(!1),"onBlur"===B&&A.commit(e.currentTarget.value)},onKeyDown(e){"INPUT"===e.currentTarget.tagName&&"Enter"===e.key&&(N(!0),A.commit(e.currentTarget.value))}},A.getInputValidationProps(),h],stateAttributesMapping:c})}),G=a.createContext({disabled:!1}),J=a.createContext(void 0),W=a.forwardRef(function(e,t){let{render:i,className:l,disabled:s=!1,...o}=e,{state:d,disabled:u}=m(!1),f=u||s,p=function(e=!0){let t=a.useContext(J);if(void 0===t&&!e)throw Error((0,n.default)(3));return t}(),v=p?.parent.id,g=p?.allValues!==void 0,x=a.useMemo(()=>({disabled:f}),[f]),h=(0,M.useRenderElement)("div",e,{ref:t,state:d,props:o,stateAttributesMapping:c});return(0,r.jsx)(w,{controlId:g?v:void 0,children:(0,r.jsx)(G.Provider,{value:x,children:h})})});e.s(["Control",0,q,"Description",0,z,"Error",0,_,"Item",0,W,"Label",0,T,"Root",0,E,"Validity",0,function(e){let{children:t}=e,{validityData:i,invalid:n}=m(!1),l=a.useMemo(()=>k(i,n),[i,n]),s=!1===l.state.valid,{transitionStatus:o}=(0,V.useTransitionStatus)(s),d=a.useMemo(()=>({...l,validity:l.state,transitionStatus:o}),[l,o]);return(0,r.jsx)(a.Fragment,{children:t(d)})}],71975);var K=e.i(71975),K=K;let Y=a.forwardRef(function(e,t){return(0,r.jsx)(K.Control,{ref:t,...e})});var Q=e.i(52088);e.s(["Input",0,function({className:e,type:t,...a}){return(0,r.jsx)(Y,{type:t,"data-slot":"input",className:(0,Q.cn)("h-9 w-full min-w-0 rounded-md border border-input bg-input/20 px-3 py-1 text-sm transition-colors outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}],10012)},37870,31278,e=>{"use strict";var t=e.i(18050),r=e.i(17521);e.s(["Loader2",()=>r.default],31278);var r=r;e.s(["LoadingSpinner",0,function({size:e="md",message:a}){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3",children:[(0,t.jsx)(r.default,{className:`${{sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"}[e]} text-primary animate-spin`}),a&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:a})]})}],37870)},63209,e=>{"use strict";let t=(0,e.i(75254).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",0,t],63209)},95468,e=>{"use strict";var t=e.i(23287);e.s(["CheckCircle2",()=>t.default])},58e3,e=>{"use strict";let t=(0,e.i(75254).default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["CircleHelp",0,t],58e3)},87951,52044,e=>{"use strict";var t=e.i(75254);let r=(0,t.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);e.s(["Mic",0,r],87951);let a=(0,t.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);e.s(["Square",0,a],52044)},64036,e=>{"use strict";var t=e.i(18050),r=e.i(52088);e.s(["Card",0,function({className:e,size:a="default",...i}){return(0,t.jsx)("div",{"data-slot":"card","data-size":a,className:(0,r.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-lg bg-card py-4 text-xs/relaxed text-card-foreground ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg",e),...i})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-4 group-data-[size=sm]/card:px-3",e),...a})},"CardDescription",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,r.cn)("text-xs/relaxed text-muted-foreground",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("font-heading text-sm font-medium",e),...a})}])},77814,e=>{"use strict";var t,r=e.i(18050);e.s([],33847),e.i(33847),e.i(47167);var a=e.i(71645),i=e.i(231),n=e.i(62372);let l=new Map;function s(e,t,r){return null==e?"":(function(e,t){let r=JSON.stringify({locale:e,options:t}),a=l.get(r);if(a)return a;let i=new Intl.NumberFormat(e,t);return l.set(r,i),i})(t,r).format(e)}var o=e.i(27601),d=e.i(67805);let u=a.createContext(void 0);function c(){let e=a.useContext(u);if(void 0===e)throw Error((0,d.default)(51));return e}let f=((t={}).complete="data-complete",t.indeterminate="data-indeterminate",t.progressing="data-progressing",t),m={status:e=>"progressing"===e?{[f.progressing]:""}:"complete"===e?{[f.complete]:""}:"indeterminate"===e?{[f.indeterminate]:""}:null};function p(e,t){return null==t?"indeterminate progress":e||`${t}%`}let v=a.forwardRef(function(e,t){var l;let{format:d,getAriaValueText:c=p,locale:f,max:v=100,min:g=0,value:x,render:h,className:b,children:y,...j}=e,[w,M]=a.useState(),C=(0,i.useValueAsRef)(d),k="indeterminate";Number.isFinite(x)&&(k=x===v?"complete":"progressing");let N=(l=C.current,null==x?"":l?s(x,f,l):s(x/100,f,{style:"percent"})),S=a.useMemo(()=>({status:k}),[k]),E={"aria-labelledby":w,"aria-valuemax":v,"aria-valuemin":g,"aria-valuenow":x??void 0,"aria-valuetext":c(N,x),role:"progressbar",children:(0,r.jsxs)(a.Fragment,{children:[y,(0,r.jsx)("span",{role:"presentation",style:n.visuallyHidden,children:"x"})]})},R=a.useMemo(()=>({formattedValue:N,max:v,min:g,setLabelId:M,state:S,status:k,value:x}),[N,v,g,M,S,k,x]),L=(0,o.useRenderElement)("div",e,{state:S,ref:t,props:[E,j],stateAttributesMapping:m});return(0,r.jsx)(u.Provider,{value:R,children:L})}),g=a.forwardRef(function(e,t){let{render:r,className:a,...i}=e,{state:n}=c();return(0,o.useRenderElement)("div",e,{state:n,ref:t,props:i,stateAttributesMapping:m})}),x=a.forwardRef(function(e,t){let{render:r,className:i,...n}=e,{max:l,min:s,value:d,state:u}=c(),f=Number.isFinite(d)&&null!==d?(d-s)*100/(l-s):null,p=a.useCallback(()=>null==f?{}:{insetInlineStart:0,height:"inherit",width:`${f}%`},[f]);return(0,o.useRenderElement)("div",e,{state:u,ref:t,props:[{style:p()},n],stateAttributesMapping:m})}),h=a.forwardRef(function(e,t){let{className:r,render:a,children:i,...n}=e,{value:l,formattedValue:s,state:d}=c(),u=null==l?"indeterminate":s,f=null==l?null:s;return(0,o.useRenderElement)("span",e,{state:d,ref:t,props:[{"aria-hidden":!0,children:"function"==typeof i?i(u,l):f},n],stateAttributesMapping:m})});var b=e.i(24564);let y=a.forwardRef(function(e,t){let{render:r,className:a,id:i,...n}=e,{setLabelId:l,state:s}=c(),d=(0,b.useRegisteredLabelId)(i,l);return(0,o.useRenderElement)("span",e,{state:s,ref:t,props:[{id:d,role:"presentation"},n],stateAttributesMapping:m})});e.s(["Indicator",0,x,"Label",0,y,"Root",0,v,"Track",0,g,"Value",0,h],45929);var j=e.i(45929),j=j,w=e.i(52088);function M({className:e,...t}){return(0,r.jsx)(j.Track,{className:(0,w.cn)("relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted",e),"data-slot":"progress-track",...t})}function C({className:e,...t}){return(0,r.jsx)(j.Indicator,{"data-slot":"progress-indicator",className:(0,w.cn)("h-full bg-primary",e),style:{transition:"width 500ms ease-in-out"},...t})}e.s(["Progress",0,function({className:e,children:t,value:a,...i}){return(0,r.jsxs)(j.Root,{value:a,"data-slot":"progress",className:(0,w.cn)("flex flex-wrap gap-3",e),...i,children:[t,(0,r.jsx)(M,{children:(0,r.jsx)(C,{})})]})}],77814)},41247,e=>{"use strict";var t=e.i(18050),r=e.i(52088);e.s(["Textarea",0,function({className:e,...a}){return(0,t.jsx)("textarea",{"data-slot":"textarea",className:(0,r.cn)("flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-input/20 px-2 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}])},57024,e=>{"use strict";var t=e.i(85699);function r(e){let{type:r,title:a,description:i,duration:n}=e,l=e.id??crypto.randomUUID(),s={id:l,description:i,duration:n};switch(r){case"loading":t.toast.loading(a,s);break;case"success":t.toast.success(a,s);break;case"error":t.toast.error(a,s);break;case"warning":t.toast.warning(a,s);break;case"info":t.toast.info(a,s);break;default:(0,t.toast)(a,s)}return l}e.s(["toaster",0,{create:e=>r(e),update:(e,t)=>{r({...t,id:e})},dismiss:e=>{t.toast.dismiss(e)}}])},31245,e=>{"use strict";let t=(0,e.i(75254).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);e.s(["Bot",0,t],31245)},31449,66961,e=>{"use strict";var t=e.i(18050),r=e.i(71645),a=e.i(31278),i=e.i(87951),n=e.i(52044),l=e.i(85902),s=e.i(70935),o=e.i(57024),d=e.i(31245),u=e.i(95468),c=e.i(58e3),f=e.i(64036),m=e.i(68995),p=e.i(77814);let v="tsunagi:local-llm-enabled",g={not_running:"停止中",installing_deps:"依存関係をインストール中...",downloading_model:"モデルをダウンロード中...",starting_server:"サーバーを起動中... (モデルのロードに数十秒かかる場合があります)",running:"実行中",running_external:"実行中 (tsunagi外で起動)",error:"エラー"},x=["installing_deps","downloading_model","starting_server"],h=["running","running_external"];function b(e){let t=e/0x40000000;return t>=.1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(0)} MB`}e.s(["LOCAL_LLM_ENABLED_STORAGE_KEY",0,v,"LocalLlmSection",0,function(){let[e,i]=(0,r.useState)(!1),[y,j]=(0,r.useState)(!1),[w,M]=(0,r.useState)(null),C=(0,r.useRef)(null),k=(0,r.useCallback)(e=>{i(e),localStorage.setItem(v,String(e))},[]),N=(0,r.useCallback)(async()=>{let e=await fetch((0,s.apiUrl)("/api/llm/server/status")),t=await e.json();return M(t),t},[]);(0,r.useEffect)(()=>{i("true"===localStorage.getItem(v)),N()},[N]),(0,r.useEffect)(()=>{w&&h.includes(w.step)&&!e&&(k(!0),o.toaster.create({type:"success",title:"ローカルLLMが有効化されました"}))},[w,e,k]),(0,r.useEffect)(()=>(w&&x.includes(w.step)&&!C.current&&(C.current=setInterval(()=>{N().then(e=>{!x.includes(e.step)&&C.current&&(clearInterval(C.current),C.current=null)})},1e3)),()=>{C.current&&(clearInterval(C.current),C.current=null)}),[w,N]);let S=(0,r.useCallback)(()=>{N(),j(!0)},[N]),E=(0,r.useCallback)(async()=>{try{let e=await fetch((0,s.apiUrl)("/api/llm/server/start"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}M(await e.json())}catch(e){o.toaster.create({type:"error",title:"サーバーの起動に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),R=(0,r.useCallback)(async()=>{try{let e=await fetch((0,s.apiUrl)("/api/llm/server/stop"),{method:"POST"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`HTTPエラー: ${e.status}`)}M(await e.json())}catch(e){o.toaster.create({type:"error",title:"サーバーの停止に失敗しました",description:e instanceof Error?e.message:String(e)})}},[]),L=(0,r.useCallback)(()=>{k(!1),w&&h.includes(w.step)&&R()},[k,R,w]),I=w?.serverDir,O=w?.downloadProgress,P=O?O.downloadedBytes/O.totalBytes*100:0;return(0,t.jsxs)(f.Card,{children:[(0,t.jsxs)(f.CardHeader,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(f.CardTitle,{children:"ローカルLLM (実験的機能)"}),(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:S,title:"ローカルLLMについて",children:(0,t.jsx)(c.CircleHelp,{})})]}),(0,t.jsxs)(f.CardDescription,{children:["ローカルで動作するLLM(Qwen3-30B-A3B, MoE)を利用します。",(0,t.jsx)("strong",{className:"font-medium text-foreground",children:"有効にすると、音声入力の文字起こし結果がこのLLMで自動整形されるようになります"}),"(無効時は文字起こし結果をそのまま使用)。"]})]}),(0,t.jsx)(f.CardContent,{className:"flex flex-col gap-3",children:e?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(u.CheckCircle2,{className:"size-4"}),"ローカルLLM: 有効"]}),w&&(0,t.jsxs)("span",{className:"text-xs/relaxed text-muted-foreground",children:["(",g[w.step],")"]}),(0,t.jsx)(l.Button,{size:"default",variant:"outline",onClick:L,children:"無効にする"})]}):(0,t.jsxs)(l.Button,{size:"default",onClick:S,children:[(0,t.jsx)(d.Bot,{}),"ローカルLLMを有効化する"]})}),(0,t.jsx)(m.Dialog,{open:y,onOpenChange:({open:e})=>j(e),title:"ローカルLLMについて",maxWidth:"2xl",children:(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"実験的機能です"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"音声入力の文字起こし結果を、ローカルで動作するLLM(mlx-lm / Qwen3-30B-A3B, MoE構成)で整形します。MoE構成のため実計算に使うアクティブパラメータは約3Bで、denseな同規模モデルより高速に動作します。精度・速度は環境に依存し、今後変更される可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"対応環境"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Apple Silicon Mac (M1/M2/M3/M4) のみ対応。Windows/Linuxでは利用できません。メモリ32GB以上を推奨します。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"必要なもの(事前に手動でインストール)"}),(0,t.jsx)("ul",{className:"list-disc pl-5 text-muted-foreground",children:(0,t.jsx)("li",{children:"Python 3.9以降(Xcode Command Line Tools または Homebrew経由で入手可能)"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"セットアップ・起動"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"下のボタンから、依存関係のインストール・モデルのダウンロード・サーバー起動まで自動で行われます(初回はモデルサイズが大きく数分〜数十分かかります)。"}),w&&!I&&(0,t.jsx)("p",{className:"mt-1 text-destructive",children:"llm-serverが見つかりませんでした。インストールが壊れている可能性があります。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1 font-medium text-foreground",children:"アンインストール"}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:["ローカルLLMのためにダウンロードされるもの(Pythonの依存関係・LLMモデル、合計約17GB)は全て",(0,t.jsx)("code",{className:"rounded bg-muted px-1",children:"~/.tsunagi/llm"}),"に保存されます。不要になった場合はこのディレクトリを削除するだけで、関連リソースを完全に削除できます。"]})]}),(0,t.jsxs)("div",{className:"border-t border-border pt-4",children:[(!w||"not_running"===w.step||"error"===w.step)&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)(l.Button,{size:"default",onClick:()=>void E(),disabled:!w,children:[w?(0,t.jsx)(d.Bot,{}):(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"LLMサーバーを起動"]}),w?.step==="error"&&w.error&&(0,t.jsx)("p",{className:"text-xs/relaxed text-destructive",children:w.error})]}),w?.step==="installing_deps"&&(0,t.jsxs)(l.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"依存関係をインストール中... (数分かかる場合があります)"]}),w?.step==="downloading_model"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs/relaxed text-muted-foreground",children:[(0,t.jsx)(a.Loader2,{className:"size-4 animate-spin"}),"モデルをダウンロード中... (約17GB)"]}),O&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.Progress,{value:P}),(0,t.jsxs)("p",{className:"text-xs/relaxed text-muted-foreground",children:[b(O.downloadedBytes)," / ",b(O.totalBytes)," (",P.toFixed(0),"%) ・ ",function(e){if(null===e)return"残り時間を計算中...";if(e<60)return`残り約${e}秒`;let t=Math.floor(e/60);return`残り約${t}分${e%60}秒`}(O.etaSeconds)]})]})]}),w?.step==="starting_server"&&(0,t.jsxs)(l.Button,{size:"default",disabled:!0,children:[(0,t.jsx)(a.Loader2,{className:"animate-spin"}),"サーバーを起動中... (モデルのロードに数十秒かかる場合があります)"]}),w&&h.includes(w.step)&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-success",children:[(0,t.jsx)(u.CheckCircle2,{className:"size-4"}),"サーバーは起動しています"]}),(0,t.jsxs)(l.Button,{size:"default",variant:"outline",onClick:()=>void R(),children:[(0,t.jsx)(n.Square,{}),"サーバーを停止"]})]})]})]})})]})}],66961);let y="tsunagi:whisper-prompt",j=["running","running_external"];e.s(["VoiceInputButton",0,function({onTranscribed:e}){let[d,u]=(0,r.useState)(!1),[c,f]=(0,r.useState)("idle"),[m,p]=(0,r.useState)(0),[g,x]=(0,r.useState)(null),h=(0,r.useRef)(null),b=(0,r.useRef)([]),w=(0,r.useRef)(null),M=(0,r.useRef)(null),C=(0,r.useRef)(null),k=(0,r.useRef)(0),N=(0,r.useRef)(0);(0,r.useEffect)(()=>{u("true"===localStorage.getItem("tsunagi:voice-input-enabled"))},[]),(0,r.useEffect)(()=>{if(!d)return;let e=!1,t=async()=>{try{let t=await fetch((0,s.apiUrl)("/api/whisper/server/status")),r=await t.json();e||x(r.step)}catch{e||x("not_running")}};t();let r=setInterval(t,5e3);return()=>{e=!0,clearInterval(r)}},[d]);let S=(0,r.useCallback)(()=>{C.current&&(clearInterval(C.current),C.current=null),M.current?.close(),M.current=null,p(0)},[]);(0,r.useEffect)(()=>()=>{S()},[S]);let E=(0,r.useCallback)(e=>{let t=new AudioContext,r=t.createMediaStreamSource(e),a=t.createAnalyser();a.fftSize=2048,r.connect(a),M.current=t,k.current=0,N.current=0;let i=new Float32Array(a.fftSize);C.current=setInterval(()=>{a.getFloatTimeDomainData(i);let e=0;for(let t=0;t<i.length;t++)e+=i[t]*i[t];let t=Math.sqrt(e/i.length),r=Math.min(1,Math.max(0,((t>0?20*Math.log10(t):-60)- -60)/50));N.current=Math.max(N.current,r),k.current=.3*k.current+.7*r,p(k.current)},50)},[]),R=(0,r.useCallback)(async t=>{f("transcribing");try{let r=new FormData,a=localStorage.getItem(y);a&&r.append("prompt",a);let i="true"===localStorage.getItem(v);r.append("useLlm",String(i)),r.append("file",t,"recording.webm");let n=await fetch((0,s.apiUrl)("/api/whisper/transcribe"),{method:"POST",body:r});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`HTTPエラー: ${n.status}`)}let l=await n.json();l.warning&&o.toaster.create({type:"error",title:"LLM整形をスキップしました",description:l.warning}),l.text&&e(l.text)}catch(e){o.toaster.create({type:"error",title:"文字起こしに失敗しました",description:e instanceof Error?e.message:String(e)})}finally{f("idle")}},[e]),L=(0,r.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});w.current=e,b.current=[],E(e);let t=new MediaRecorder(e,{audioBitsPerSecond:128e3});t.ondataavailable=e=>{e.data.size>0&&b.current.push(e.data)},t.onstop=()=>{w.current?.getTracks().forEach(e=>e.stop()),w.current=null;let e=N.current;if(S(),e<.15){o.toaster.create({type:"error",title:"音声が検出されませんでした",description:"マイクに向かって話してから、もう一度お試しください。"}),f("idle");return}let t=new Blob(b.current,{type:"audio/webm"});R(t)},h.current=t,t.start(),f("recording")}catch(e){o.toaster.create({type:"error",title:"マイクにアクセスできませんでした",description:e instanceof Error?e.message:String(e)})}},[R,E,S]),I=(0,r.useCallback)(()=>{h.current?.stop()},[]);if(!d)return null;let O=null!==g&&j.includes(g);return(0,t.jsxs)("div",{className:"recording"===c?"inline-flex items-center gap-2 rounded-md bg-destructive/10 p-1":"inline-flex",children:[(0,t.jsx)(l.Button,{size:"icon",variant:"recording"===c?"destructive":"default",onClick:"recording"===c?I:()=>void L(),disabled:"transcribing"===c||"idle"===c&&!O,title:"recording"===c?"停止して入力":"idle"!==c||O?"音声入力":"Whisperサーバーが起動していません(Settingsから起動してください)",children:"transcribing"===c?(0,t.jsx)(a.Loader2,{className:"w-4 h-4 animate-spin"}):"recording"===c?(0,t.jsx)(n.Square,{className:"w-4 h-4"}):(0,t.jsx)(i.Mic,{className:"w-4 h-4"})}),"recording"===c&&(0,t.jsx)("div",{"aria-hidden":!0,className:"h-1.5 w-16 overflow-hidden rounded-full bg-background/60",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-destructive",style:{width:`${Math.round(100*m)}%`}})})]})},"WHISPER_PROMPT_STORAGE_KEY",0,y],31449)},51846,e=>{"use strict";var t=e.i(71645);e.s(["useDocumentTitle",0,function(e){(0,t.useEffect)(()=>{let t=e?`繋 | ${e}`:"繋",r=document.title;return document.title=t,()=>{document.title=r}},[e])}])}]);