@xopcai/xopc 0.0.158 → 0.0.159

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 (105) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/dashscope/src/image-generation-provider.js +1 -1
  3. package/dist/extensions/fal/src/image-generation-provider.js +1 -1
  4. package/dist/extensions/google/src/image-generation-provider.js +1 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/{action-boundary-settings-panel-2p1f4-KA.js → action-boundary-settings-panel-CaRK2vIy.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BIl6X2b_.js → agent-avatar-dicebear-BeVf03hx.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agents-bnkKH9EI.js → agents-P05C4A-3.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-CZxw161D.js → app-management-settings-panel-BG2ulMYw.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-CRXNlDhH.js → appearance-settings-0Kjenr2T.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-l4ripRNG.js → apps-page-DANGrBpN.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-CpVshjXu.js → archive-plugin-ChiNnH1e.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-M9WqqJnQ.js → attachment-load-pbBlQR-g.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automation-suggestion-card-CYMsAsYf.js → automation-suggestion-card-CTZDOyDy.js} +1 -1
  15. package/dist/gateway/static/root/assets/{automations-page-Kny7tLiF.js → automations-page-BXfGL_cm.js} +1 -1
  16. package/dist/gateway/static/root/assets/{binary-plugins-Cjn3zb4u.js → binary-plugins-BeZGzpGF.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-BPKdquaV.js → block-editor-BnDmhN5Z.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-settings-page-vr1tXAab.js → browser-settings-page-534luV0B.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-presets-api-Bzkcsyzn.js → capability-presets-api-Ii36j_7v.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-D4rH4Dax.js → capability-presets-settings-panel-Cl3dw4yh.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-Tlhbi5eh.js → channels-settings-M91zFJVi.js} +1 -1
  22. package/dist/gateway/static/root/assets/{connector-logo-ljPKdYKh.js → connector-logo-CiLxuZ8S.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-_XfvjXoY.js → connectors-page-CV5UulW6.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-DKUlAgm7.js → desktop-pet-Cil2eSpW.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-aWWzjdza.js → desktop-pet-settings-DwsC6l5F.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-Dmy1035j.js → directory-picker-path-field-CC2VL5Mc.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-tT4WkBkd.js → dreaming-settings-KY7ZfVsy.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-CL79q8AH.js → extension-debug-page-C8KBeucs.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-hq80wkFI.js → extension-page-CV-5Kcyk.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-BV-9GDfT.js → extension-settings-page-DvUtDrAu.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-CFqoN2NW.js → gateway-config-api-DXfVeJLc.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-DzR-kM91.js → gateway-settings-BpJ0v56l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{goal-create-dialog-BLjHRtqe.js → goal-create-dialog-lMHD-2CX.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-detail-page-BRxeujXh.js → goal-detail-page-yPmF-G7b.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goals-config-api--qJ4qlRq.js → goals-config-api-P8VhLqYF.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-page-BaZ3aw4u.js → goals-page-BHTCKobG.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goals-settings-h7x9h5lb.js → goals-settings-DHXyaH_O.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-settings-71IhhM3s.js → heartbeat-settings-CNckP_Dv.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-BgZhEOkN.css +1 -0
  40. package/dist/gateway/static/root/assets/{index-EXa_i6BT.js → index-BuqGh2SW.js} +65 -65
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BZGmHvLu.js → keyboard-shortcuts-settings-jXmv1RVX.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-app-workbench-page-lUpd6lSo.js → local-app-workbench-page-zpp_wciE.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-apps-page-CiLqrMIh.js → local-apps-page-Cs5LKjtc.js} +1 -1
  44. package/dist/gateway/static/root/assets/{logs-page-FPDTmcWe.js → logs-page-B4CRYqYR.js} +1 -1
  45. package/dist/gateway/static/root/assets/{markdown-split-r1HPWfCU.js → markdown-split-BFqeSNte.js} +1 -1
  46. package/dist/gateway/static/root/assets/{media-plugins-D74kd3hn.js → media-plugins-Cc8379gq.js} +1 -1
  47. package/dist/gateway/static/root/assets/{models-hub-panel-BXrdePhv.js → models-hub-panel-1hdoAoB_.js} +1 -1
  48. package/dist/gateway/static/root/assets/{notes-page-Dgu02514.js → notes-page-DlGU4ipo.js} +1 -1
  49. package/dist/gateway/static/root/assets/{notes-workbench-D-EAhXv1.js → notes-workbench-DQEAZTA5.js} +2 -2
  50. package/dist/gateway/static/root/assets/{page-tabs-hinRdDy3.js → page-tabs-kFOswGlG.js} +1 -1
  51. package/dist/gateway/static/root/assets/{preview-open-alternatives-C7fw3oGy.js → preview-open-alternatives-CvjuvABg.js} +1 -1
  52. package/dist/gateway/static/root/assets/{project-detail-page-BjpB1wrp.js → project-detail-page-Bp9bC7A6.js} +1 -1
  53. package/dist/gateway/static/root/assets/{projects-page-BxyjqOfC.js → projects-page-RNorFXTw.js} +1 -1
  54. package/dist/gateway/static/root/assets/{remote-access-hub-BFv6Upke.js → remote-access-hub-BqRTcM_6.js} +1 -1
  55. package/dist/gateway/static/root/assets/{save-bar-controls-C3aU8-vO.js → save-bar-controls-DwrD7ODx.js} +1 -1
  56. package/dist/gateway/static/root/assets/{schedule-field-DjegExFD.js → schedule-field-Ba4WzTmE.js} +1 -1
  57. package/dist/gateway/static/root/assets/{schema-form-DLubnsql.js → schema-form-DvydL8eF.js} +1 -1
  58. package/dist/gateway/static/root/assets/{sessions-page-BX4DH8J7.js → sessions-page-B2EfW1cm.js} +1 -1
  59. package/dist/gateway/static/root/assets/settings-advanced-gate-CklL85T4.js +1 -0
  60. package/dist/gateway/static/root/assets/{settings-collapsible-section-3syQHsNR.js → settings-collapsible-section-LaQqGGej.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-form-section-D4DCZzKg.js → settings-form-section-DruI__qO.js} +1 -1
  62. package/dist/gateway/static/root/assets/{settings-loading-skeleton-c5K85ylS.js → settings-loading-skeleton-UvA-eDhF.js} +1 -1
  63. package/dist/gateway/static/root/assets/{settings-page-DNiDlaRq.js → settings-page-5oCGSebm.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-page-layout-iTRY1Hy-.js → settings-page-layout-DG-XMIPu.js} +1 -1
  65. package/dist/gateway/static/root/assets/{setup-status-panel-BH4xQKM9.js → setup-status-panel-D3my1HgB.js} +1 -1
  66. package/dist/gateway/static/root/assets/{share-preview-page-B88Afrhe.js → share-preview-page-FLVeTrRt.js} +1 -1
  67. package/dist/gateway/static/root/assets/{shares-settings-B6kKkvOb.js → shares-settings-DVxgjrsP.js} +1 -1
  68. package/dist/gateway/static/root/assets/{skill-reload-api-DtjS-nUK.js → skill-reload-api-Bcu58ZaF.js} +1 -1
  69. package/dist/gateway/static/root/assets/{skills-page-CQEoPv0u.js → skills-page-CDd-84FE.js} +1 -1
  70. package/dist/gateway/static/root/assets/{system-settings-panel-DtpTq837.js → system-settings-panel-CeK93xVi.js} +1 -1
  71. package/dist/gateway/static/root/assets/{typed-models-lib-ndEnUP3b.js → typed-models-lib-D1Lr2gG0.js} +1 -1
  72. package/dist/gateway/static/root/assets/{user-context-page-Dn2T3itn.js → user-context-page-1OyJnTyR.js} +1 -1
  73. package/dist/gateway/static/root/assets/{voice-api-key-field-wtWc3SfN.js → voice-api-key-field-B2ncRwHS.js} +1 -1
  74. package/dist/gateway/static/root/assets/{work-discovery-page-Ckxhj66e.js → work-discovery-page-BZlY4PZL.js} +1 -1
  75. package/dist/gateway/static/root/assets/{work-item-detail-page-_1QgGPNw.js → work-item-detail-page-DPXMrneY.js} +1 -1
  76. package/dist/gateway/static/root/assets/{work-page-BPdf2iuv.js → work-page-CTERoqyv.js} +1 -1
  77. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ukmpkj66.js → workflow-run-setup-panel-Bynqe4kV.js} +1 -1
  78. package/dist/gateway/static/root/assets/{workflows-page-DdKTx0Hs.js → workflows-page-CLgsnqFQ.js} +1 -1
  79. package/dist/gateway/static/root/index.html +2 -2
  80. package/dist/package.js +1 -1
  81. package/dist/src/agent/embedded/session-tool-result-guard.js +14 -0
  82. package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -1
  83. package/dist/src/agent/service/process-direct-streaming.js +1 -1
  84. package/dist/src/agent/tools/image-generate-tool.js +10 -3
  85. package/dist/src/agent/tools/send-media.js +20 -70
  86. package/dist/src/agent/tools/tool-media.d.ts +9 -0
  87. package/dist/src/agent/tools/tool-media.js +58 -0
  88. package/dist/src/config/agent-profile.js +1 -1
  89. package/dist/src/gateway/agent-run-relay.d.ts +2 -0
  90. package/dist/src/gateway/agent-run-relay.js +114 -14
  91. package/dist/src/gateway/agents-admin.js +1 -1
  92. package/dist/src/gateway/chat-stream/mapper.d.ts +1 -1
  93. package/dist/src/gateway/chat-stream/mapper.js +27 -42
  94. package/dist/src/gateway/chat-stream/thinking-delta-coalescer.d.ts +7 -0
  95. package/dist/src/gateway/chat-stream/thinking-delta-coalescer.js +103 -0
  96. package/dist/src/gateway/hono/sse.d.ts +1 -1
  97. package/dist/src/gateway/hono/sse.js +1 -1
  98. package/dist/src/gateway/service/run-gateway-agent.js +5 -1
  99. package/dist/src/media/session-references.js +9 -6
  100. package/dist/src/session/client-history.d.ts +1 -0
  101. package/dist/src/session/client-history.js +56 -12
  102. package/dist/src/session/types.d.ts +1 -0
  103. package/package.json +1 -1
  104. package/dist/gateway/static/root/assets/index-gpwk8Nro.css +0 -1
  105. package/dist/gateway/static/root/assets/settings-advanced-gate-CJ9MbRP8.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-BuT0SR1R.js";import{n as l}from"./locale-store-C_M71MK9.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$t as d,Ao as f,Cn as p,Ds as m,Fo as h,Fs as g,Gl as _,Go as v,Gs as y,Io as b,Jc as x,Ml as S,Mo as C,No as w,Os as T,Po as E,Ql as D,Ro as O,Ys as k,_n as A,an as j,ao as M,cn as N,cs as P,dn as F,en as I,et as L,fn as R,gn as z,hc as B,hn as V,in as ee,iu as te,jl as ne,jo as H,js as U,ko as W,ll as re,ln as ie,lu as ae,mn as oe,ms as G,nn as se,on as K,pn as ce,qo as q,rn as le,rr as ue,sl as de,sn as fe,tn as pe,un as me,vn as he,vs as ge,wn as _e,xc as ve,xn as ye}from"./index-EXa_i6BT.js";import{t as be}from"./page-tabs-hinRdDy3.js";import{t as xe}from"./connector-logo-ljPKdYKh.js";var J=n(),Y=e(t(),1),X=r();function Se(e){let t=(0,J.c)(104),{value:n,onChange:r,labels:i,language:a,inputClassName:s}=e,c;t[0]===n.timezone?c=t[1]:(c=()=>p.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=c);let[l,u]=(0,Y.useState)(c),d;t[2]===n.timezone?d=t[3]:(d=()=>!!n.timezone&&!p.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=d);let[f,m]=(0,Y.useState)(d),h;t[4]===n.pronouns?h=t[5]:(h=()=>!!n.pronouns&&!ye.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=h);let[g,_]=(0,Y.useState)(h),y;bb0:{if(f){y=`__custom__`;break bb0}y=p.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let b=y,x;t[6]!==r||t[7]!==n?(x=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=x):x=t[8];let S=x,C;t[9]===a?C=t[10]:(C=(e,t)=>a===`zh`?t:e,t[9]=a,t[10]=C);let w=C,T;t[11]===i.callName?T=t[12]:(T=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.callName}),t[11]=i.callName,t[12]=T);let E;t[13]===S?E=t[14]:(E=e=>S({callName:e.target.value}),t[13]=S,t[14]=E);let D;t[15]!==s||t[16]!==i.callNamePlaceholder||t[17]!==E||t[18]!==n.callName?(D=(0,X.jsx)(`input`,{className:s,value:n.callName,onChange:E,placeholder:i.callNamePlaceholder,autoComplete:`off`}),t[15]=s,t[16]=i.callNamePlaceholder,t[17]=E,t[18]=n.callName,t[19]=D):D=t[19];let O;t[20]!==T||t[21]!==D?(O=(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[T,D]}),t[20]=T,t[21]=D,t[22]=O):O=t[22];let k;t[23]===i.pronouns?k=t[24]:(k=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.pronouns}),t[23]=i.pronouns,t[24]=k);let A=g?`__custom__`:n.pronouns,j;t[25]!==S||t[26]!==n.pronouns?(j=e=>{if(e.target.value===`__custom__`){_(!0),ye.some(e=>e.value===n.pronouns)&&S({pronouns:``});return}_(!1),S({pronouns:e.target.value})},t[25]=S,t[26]=n.pronouns,t[27]=j):j=t[27];let M;t[28]===i.pronounsPlaceholder?M=t[29]:(M=(0,X.jsx)(q,{value:``,children:i.pronounsPlaceholder}),t[28]=i.pronounsPlaceholder,t[29]=M);let N;t[30]===w?N=t[31]:(N=ye.map(e=>(0,X.jsx)(q,{value:e.value,children:w(e.labelEn,e.labelZh)},e.value)),t[30]=w,t[31]=N);let F;t[32]===i.custom?F=t[33]:(F=(0,X.jsx)(q,{value:`__custom__`,children:i.custom}),t[32]=i.custom,t[33]=F);let I;t[34]!==s||t[35]!==A||t[36]!==j||t[37]!==M||t[38]!==N||t[39]!==F?(I=(0,X.jsxs)(v,{className:s,value:A,onChange:j,children:[M,N,F]}),t[34]=s,t[35]=A,t[36]=j,t[37]=M,t[38]=N,t[39]=F,t[40]=I):I=t[40];let L;t[41]!==s||t[42]!==i.pronounsPlaceholder||t[43]!==g||t[44]!==S||t[45]!==n.pronouns?(L=g?(0,X.jsx)(`input`,{className:o(s,`mt-1 text-xs`),value:n.pronouns,onChange:e=>S({pronouns:e.target.value}),placeholder:i.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=s,t[42]=i.pronounsPlaceholder,t[43]=g,t[44]=S,t[45]=n.pronouns,t[46]=L):L=t[46];let R;t[47]!==k||t[48]!==I||t[49]!==L?(R=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[k,I,L]}),t[47]=k,t[48]=I,t[49]=L,t[50]=R):R=t[50];let z;t[51]===i.timezone?z=t[52]:(z=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.timezone}),t[51]=i.timezone,t[52]=z);let B;t[53]===s?B=t[54]:(B=o(s,`min-w-0 flex-1`),t[53]=s,t[54]=B);let V;t[55]===S?V=t[56]:(V=e=>{if(e.target.value===`__custom__`){m(!0);return}m(!1),u(``),S({timezone:e.target.value})},t[55]=S,t[56]=V);let ee;t[57]===w?ee=t[58]:(ee=p.map(e=>(0,X.jsx)(q,{value:e.value,children:w(e.labelEn,e.labelZh)},e.value)),t[57]=w,t[58]=ee);let te;t[59]===i.timezoneCustom?te=t[60]:(te=(0,X.jsx)(q,{value:`__custom__`,children:i.timezoneCustom}),t[59]=i.timezoneCustom,t[60]=te);let ne;t[61]!==B||t[62]!==V||t[63]!==ee||t[64]!==te||t[65]!==b?(ne=(0,X.jsxs)(v,{className:B,value:b,onChange:V,children:[ee,te]}),t[61]=B,t[62]=V,t[63]=ee,t[64]=te,t[65]=b,t[66]=ne):ne=t[66];let H;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(H=o(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,P.press),t[67]=H):H=t[67];let U;t[68]===S?U=t[69]:(U=()=>{let e=_e();if(!e)return;let t=p.some(t=>t.value===e);m(!t),u(t?``:e),S({timezone:e})},t[68]=S,t[69]=U);let W;t[70]!==i.timezoneDetect||t[71]!==U?(W=(0,X.jsx)(`button`,{type:`button`,className:H,onClick:U,children:i.timezoneDetect}),t[70]=i.timezoneDetect,t[71]=U,t[72]=W):W=t[72];let re;t[73]!==ne||t[74]!==W?(re=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[ne,W]}),t[73]=ne,t[74]=W,t[75]=re):re=t[75];let ie;t[76]!==l||t[77]!==s||t[78]!==f||t[79]!==S?(ie=f?(0,X.jsx)(`input`,{className:o(s,`mt-1 font-mono text-xs`),value:l,onChange:e=>{u(e.target.value),S({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=l,t[77]=s,t[78]=f,t[79]=S,t[80]=ie):ie=t[80];let ae;t[81]!==z||t[82]!==re||t[83]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[z,re,ie]}),t[81]=z,t[82]=re,t[83]=ie,t[84]=ae):ae=t[84];let oe;t[85]===i.notes?oe=t[86]:(oe=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.notes}),t[85]=i.notes,t[86]=oe);let G;t[87]===s?G=t[88]:(G=o(s,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=s,t[88]=G);let se;t[89]===S?se=t[90]:(se=e=>S({notes:e.target.value}),t[89]=S,t[90]=se);let K;t[91]!==i.notesPlaceholder||t[92]!==G||t[93]!==se||t[94]!==n.notes?(K=(0,X.jsx)(`textarea`,{className:G,value:n.notes,onChange:se,placeholder:i.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=i.notesPlaceholder,t[92]=G,t[93]=se,t[94]=n.notes,t[95]=K):K=t[95];let ce;t[96]!==oe||t[97]!==K?(ce=(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[oe,K]}),t[96]=oe,t[97]=K,t[98]=ce):ce=t[98];let le;return t[99]!==O||t[100]!==R||t[101]!==ae||t[102]!==ce?(le=(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[O,R,ae,ce]}),t[99]=O,t[100]=R,t[101]=ae,t[102]=ce,t[103]=le):le=t[103],le}var Ce={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function we(e){if(e.branding?.logoUrl)return e.branding;let t=Ce[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}function Te(e){let t=(0,J.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:s}=e,l=c(r).you,[u,d]=(0,Y.useState)(!1),p=n?.accountLabel??(n?.accountCount&&n.accountCount>1&&n.accountOrdinal?l.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),m,g;t[0]===n?(m=t[1],g=t[2]):(m=()=>{n&&d(!1)},g=[n],t[0]=n,t[1]=m,t[2]=g),(0,Y.useEffect)(m,g);let _;t[3]!==i||t[4]!==a?(_=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=_):_=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=v):v=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,X.jsx)(ge,{className:`size-4`,"aria-hidden":!0}),t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>d(!1),t[8]=b):b=t[8];let x=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,D;t[9]===x?D=t[10]:(D=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,x),t[9]=x,t[10]=D);let O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,X.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=O):O=t[11];let k;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>d(!0),t[12]=k):k=t[12];let A=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,j;t[13]===A?j=t[14]:(j=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,A),t[13]=A,t[14]=j);let M;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(U,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=M):M=t[15];let N=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),P;t[16]===N?P=t[17]:(P=(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:N}),t[16]=N,t[17]=P);let F;t[18]!==i||t[19]!==l.cancel?(F=(0,X.jsx)(f,{asChild:!0,children:(0,X.jsx)(G,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=F):F=t[20];let I=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,L;t[21]!==u||t[22]!==s?(L=()=>s(u),t[21]=u,t[22]=s,t[23]=L):L=t[23];let R;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,X.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t[24]=R):R=t[24];let z=i?l.disconnecting:l.disconnectAction,B;t[25]!==i||t[26]!==I||t[27]!==L||t[28]!==z?(B=(0,X.jsxs)(G,{type:`button`,variant:`secondary`,className:I,disabled:i,onClick:L,children:[R,z]}),t[25]=i,t[26]=I,t[27]=L,t[28]=z,t[29]=B):B=t[29];let V;return t[30]!==F||t[31]!==B?(V=(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[F,B]}),t[30]=F,t[31]=B,t[32]=V):V=t[32],(0,X.jsx)(W,{open:n!==null,onOpenChange:_,children:(0,X.jsxs)(E,{children:[v,(0,X.jsxs)(H,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(h,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,X.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,X.jsx)(f,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:y})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[p?(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,p)}):null,(0,X.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:b,className:D,children:[O,(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:k,disabled:!n?.derivedUnderstandingCount,className:j,children:[M,(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),P]})]})]}),V]})]})})}var Ee=new Set([`overview`,`profile`,`understanding`,`sources`,`controls`]),De=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],Oe=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function ke(e,t){return e.replace(`{{count}}`,String(t))}function Ae(e,t){let n=Date.parse(e);return Number.isFinite(n)?L(n,t):e}function je(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Ee.has(e)?e:`overview`}function Me(){let e=(0,J.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(M,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,X.jsx)(M,{className:`h-64 rounded-2xl`}),(0,X.jsx)(M,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Ne(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Pe(e){let t=(0,J.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(n.statement),[g,_]=(0,Y.useState)(null),[v,b]=(0,Y.useState)(!1),x=n.status!==`active`,S=x?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===S?C=t[1]:(C=o(`rounded-xl border p-3.5`,S),t[0]=S,t[1]=C);let w;t[2]!==a||t[3]!==m||t[4]!==f||t[5]!==g||t[6]!==v||t[7]!==n||t[8]!==r||t[9]!==x||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(w=f?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{className:o(Oe,`min-h-20 resize-y`),value:m,onChange:e=>h(e.target.value),placeholder:i.updatePlaceholder}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{h(n.statement),p(!1)},children:i.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!m.trim(),onClick:()=>{u(m.trim()),p(!1)},children:i.save})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(y,{className:`size-3 text-accent`,"aria-hidden":!0}),Ne(n,i)]}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,X.jsx)(`span`,{children:ke(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,X.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,Ae(n.latestEvidenceAt,r))}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[x?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,X.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,X.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,X.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:v,onClick:()=>{if(g){_(null);return}b(!0),K(n.id).then(e=>_(e.history)).finally(()=>b(!1))},children:[(0,X.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,X.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,X.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,X.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Ae(n.updatedAt,r)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:ke(i.evidenceCount,n.evidenceCount)})]})]})]}),g?(0,X.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),g.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,X.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,X.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:Ae(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=m,t[4]=f,t[5]=g,t[6]=v,t[7]=n,t[8]=r,t[9]=x,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let T;return t[16]!==C||t[17]!==w?(T=(0,X.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=T):T=t[18],T}function Fe(e){let t=(0,J.c)(84),{source:n,language:r,t:i,onConfigure:a,onDisconnect:s}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.accountCount||t[1]!==n.accountLabel||t[2]!==n.accountOrdinal||t[3]!==i.sourceAccountFallback?(l=n.accountLabel??(n.accountCount&&n.accountCount>1&&n.accountOrdinal?i.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),t[0]=n.accountCount,t[1]=n.accountLabel,t[2]=n.accountOrdinal,t[3]=i.sourceAccountFallback,t[4]=l):l=t[4];let u=l,d;t[5]!==n.lastHealthStatus||t[6]!==i.healthIssue||t[7]!==i.healthOk||t[8]!==i.sourceHealth?(d=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[5]=n.lastHealthStatus,t[6]=i.healthIssue,t[7]=i.healthOk,t[8]=i.sourceHealth,t[9]=d):d=t[9];let f=d,p=`${i.manageSources}: ${n.displayName}`,m;t[10]===a?m=t[11]:(m=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[10]=a,t[11]=m);let h=n.displayName,g;t[12]===n?g=t[13]:(g=we(n),t[12]=n,t[13]=g);let _;t[14]!==n.displayName||t[15]!==g?(_=(0,X.jsx)(xe,{connector:{displayName:h,branding:g},size:`sm`}),t[14]=n.displayName,t[15]=g,t[16]=_):_=t[16];let v;t[17]===n.displayName?v=t[18]:(v=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[17]=n.displayName,t[18]=v);let y;t[19]===u?y=t[20]:(y=u?(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:u}):null,t[19]=u,t[20]=y);let b;t[21]===n.description?b=t[22]:(b=(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[21]=n.description,t[22]=b);let x;t[23]!==b||t[24]!==v||t[25]!==y?(x=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[v,y,b]}),t[23]=b,t[24]=v,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==_?(S=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[_,x]}),t[27]=x,t[28]=_,t[29]=S):S=t[29];let C=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,w;t[30]===C?w=t[31]:(w=o(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,C),t[30]=C,t[31]=w);let T;t[32]!==c||t[33]!==w?(T=(0,X.jsx)(`span`,{className:w,children:c}),t[32]=c,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==S||t[36]!==T?(E=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,T]}),t[35]=S,t[36]=T,t[37]=E):E=t[37];let D;t[38]!==n.access.context||t[39]!==i.sourceContext?(D=n.access.context?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[38]=n.access.context,t[39]=i.sourceContext,t[40]=D):D=t[40];let O;t[41]!==n.access.memory||t[42]!==i.sourceMemory?(O=n.access.memory?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[41]=n.access.memory,t[42]=i.sourceMemory,t[43]=O):O=t[43];let k;t[44]!==n.access.read||t[45]!==i.sourceRead?(k=n.access.read?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[44]=n.access.read,t[45]=i.sourceRead,t[46]=k):k=t[46];let A;t[47]!==n.access.write||t[48]!==i.sourceWrite?(A=n.access.write?(0,X.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[47]=n.access.write,t[48]=i.sourceWrite,t[49]=A):A=t[49];let j;t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A?(j=(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[D,O,k,A]}),t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=j):j=t[54];let M;t[55]!==f||t[56]!==r||t[57]!==n.derivedUnderstandingCount||t[58]!==n.installed||t[59]!==n.knowledgeItemCount||t[60]!==n.lastActivityAt||t[61]!==n.lastSyncAt||t[62]!==n.lastSyncError||t[63]!==n.lastSyncStatus||t[64]!==i.sourceDerivedCount||t[65]!==i.sourceKnowledgeCount||t[66]!==i.sourceLastSync||t[67]!==i.sourceLastUsed||t[68]!==i.sourceNeverUsed||t[69]!==i.sourceSyncFailed?(M=n.installed?(0,X.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[f?(0,X.jsx)(`p`,{children:f}):null,(0,X.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,Ae(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,X.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,Ae(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,X.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,X.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,X.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[55]=f,t[56]=r,t[57]=n.derivedUnderstandingCount,t[58]=n.installed,t[59]=n.knowledgeItemCount,t[60]=n.lastActivityAt,t[61]=n.lastSyncAt,t[62]=n.lastSyncError,t[63]=n.lastSyncStatus,t[64]=i.sourceDerivedCount,t[65]=i.sourceKnowledgeCount,t[66]=i.sourceLastSync,t[67]=i.sourceLastUsed,t[68]=i.sourceNeverUsed,t[69]=i.sourceSyncFailed,t[70]=M):M=t[70];let N;t[71]!==s||t[72]!==n.installed||t[73]!==n.instanceId||t[74]!==i.disconnect?(N=n.installed&&n.instanceId?(0,X.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),s()},children:i.disconnect})}):null,t[71]=s,t[72]=n.installed,t[73]=n.instanceId,t[74]=i.disconnect,t[75]=N):N=t[75];let P;return t[76]!==a||t[77]!==E||t[78]!==j||t[79]!==M||t[80]!==N||t[81]!==p||t[82]!==m?(P=(0,X.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":p,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:m,children:[E,j,M,N]}),t[76]=a,t[77]=E,t[78]=j,t[79]=M,t[80]=N,t[81]=p,t[82]=m,t[83]=P):P=t[83],P}function Ie(e){let t=(0,J.c)(58),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:s,onUpdate:c,onDelete:l}=e,[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),g=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,_;t[0]===g?_=t[1]:(_=o(`rounded-xl border p-4`,g),t[0]=g,t[1]=_);let v=i.playbookNames[n.id],y;t[2]===v?y=t[3]:(y=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:v}),t[2]=v,t[3]=y);let b;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(b=ke(i.playbookRuleCount,n.rules.filter(Le).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=b):b=t[6];let x;t[7]===b?x=t[8]:(x=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:b}),t[7]=b,t[8]=x);let S;t[9]!==y||t[10]!==x?(S=(0,X.jsxs)(`div`,{children:[y,x]}),t[9]=y,t[10]=x,t[11]=S):S=t[11];let C=n.enabled?i.pausePlaybook:i.resumePlaybook,w;t[12]!==r||t[13]!==a||t[14]!==C?(w=(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:C}),t[12]=r,t[13]=a,t[14]=C,t[15]=w):w=t[15];let T;t[16]!==S||t[17]!==w?(T=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,w]}),t[16]=S,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==r||t[20]!==f||t[21]!==m||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(E=n.rules.map((e,t)=>(0,X.jsx)(`li`,{className:o(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{className:o(Oe,`min-h-16 resize-y`),value:m,onChange:e=>h(e.target.value)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!m.trim(),onClick:()=>{c(e.id,{statement:m.trim()}),p(null)},children:i.save})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),h(e.statement)},children:[(0,X.jsx)(ve,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,X.jsx)(U,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=m,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=E):E=t[33];let D;t[34]===E?D=t[35]:(D=(0,X.jsx)(`ul`,{className:`mt-3 space-y-2`,children:E}),t[34]=E,t[35]=D);let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>d(e.target.value),t[36]=O):O=t[36];let k;t[37]!==u||t[38]!==i.newRulePlaceholder?(k=(0,X.jsx)(`input`,{className:Oe,value:u,onChange:O,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=k):k=t[39];let A;t[40]!==r||t[41]!==u?(A=r||!u.trim(),t[40]=r,t[41]=u,t[42]=A):A=t[42];let j;t[43]!==u||t[44]!==s?(j=()=>{s(u.trim()),d(``)},t[43]=u,t[44]=s,t[45]=j):j=t[45];let M;t[46]!==i.addRule||t[47]!==A||t[48]!==j?(M=(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:A,onClick:j,children:i.addRule}),t[46]=i.addRule,t[47]=A,t[48]=j,t[49]=M):M=t[49];let N;t[50]!==k||t[51]!==M?(N=(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[k,M]}),t[50]=k,t[51]=M,t[52]=N):N=t[52];let P;return t[53]!==T||t[54]!==D||t[55]!==N||t[56]!==_?(P=(0,X.jsxs)(`article`,{className:_,children:[T,D,N]}),t[53]=T,t[54]=D,t[55]=N,t[56]=_,t[57]=P):P=t[57],P}function Le(e){return e.enabled}function Re(e){let t=(0,J.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:s,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=d);let f=n?l.meetSuggestedBody:l.meetBody,p;t[6]===f?p=t[7]:(p=(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:f}),t[6]=f,t[7]=p);let m;t[8]===l.callName?m=t[9]:(m=(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=m);let h;t[10]===a?h=t[11]:(h=e=>a(e.target.value),t[10]=a,t[11]=h);let g;t[12]!==i||t[13]!==r||t[14]!==s?(g=e=>{e.key===`Enter`&&r.trim()&&!i&&s()},t[12]=i,t[13]=r,t[14]=s,t[15]=g):g=t[15];let _=l.meetPlaceholder,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(Oe,`h-10 flex-1 bg-surface-base/90`),t[16]=v):v=t[16];let y;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==h||t[20]!==g?(y=(0,X.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,onChange:h,onKeyDown:g,placeholder:_,className:v}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=h,t[20]=g,t[21]=y):y=t[21];let b;t[22]!==i||t[23]!==r?(b=i||!r.trim(),t[22]=i,t[23]=r,t[24]=b):b=t[24];let x=i?l.meetSaving:l.meetSave,S;t[25]!==s||t[26]!==b||t[27]!==x?(S=(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:b,onClick:s,children:x}),t[25]=s,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==y||t[30]!==S||t[31]!==m?(C=(0,X.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[m,y,S]}),t[29]=y,t[30]=S,t[31]=m,t[32]=C):C=t[32];let w;t[33]!==n||t[34]!==l.meetSource?(w=n?(0,X.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,X.jsx)(k,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=w):w=t[35];let T;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(T=(0,X.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=T):T=t[39];let E;return t[40]!==C||t[41]!==w||t[42]!==T||t[43]!==d||t[44]!==p?(E=(0,X.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,X.jsxs)(`div`,{className:`relative max-w-2xl`,children:[d,p,C,w,T]})}),t[40]=C,t[41]=w,t[42]=T,t[43]=d,t[44]=p,t[45]=E):E=t[45],E}function ze(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,f]=i(),p=je(r.get(`tab`)),h=b(e=>e.setPageHeader),y=b(e=>e.clearPageHeader),{data:C,error:w,isLoading:T,mutate:E}=u(`/api/you`,fe),[M,P]=(0,Y.useState)(null),[L,H]=(0,Y.useState)(!1),[U,W]=(0,Y.useState)(``),[K,de]=(0,Y.useState)(`preference`),[ge,ye]=(0,Y.useState)(null),[xe,J]=(0,Y.useState)(!1),[Ce,we]=(0,Y.useState)(null),[Ee,Le]=(0,Y.useState)(!1),[ze,Be]=(0,Y.useState)(``),[Ve,He]=(0,Y.useState)(!1),[Ue,We]=(0,Y.useState)(null),[Ge,Ke]=(0,Y.useState)(!1),[qe,Je]=(0,Y.useState)(null),[Ye,Xe]=(0,Y.useState)(!1),[Ze,Qe]=(0,Y.useState)(null),$e=(0,Y.useRef)(null),et=(0,Y.useRef)(null),Z=C?.profile??{callName:``,pronouns:``,timezone:``,notes:``},tt=(0,Y.useMemo)(()=>C?.understanding.filter(e=>e.status===`active`)??[],[C]),Q=(0,Y.useMemo)(()=>C?.understanding.filter(e=>e.status!==`active`)??[],[C]),nt=(0,Y.useMemo)(()=>new Map(De.map(e=>[e,tt.filter(t=>t.facet===e)])),[tt]),rt=Ue??C?.controls??null,it=C?.sources.filter(e=>e.installed&&e.enabled)??[],at=it.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),f(n,{replace:!0})},ot=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,Y.useLayoutEffect)(()=>(h({startExtra:null,main:(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,X.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>y()),[y,h,t.subtitle,t.title]),(0,Y.useEffect)(()=>{!C||C.profile.callName||Be(C.profileSetup.callNameSuggestion?.value??``)},[C,C?.profile.callName,C?.profileSetup.callNameSuggestion?.id]);async function st(e,n,r){P(e.id);try{let t=await V(e.id,{action:n,content:r});await E(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),E()}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}async function ct(e,n){P(`consent:${e}`);try{await se(e,n),await E(),O({type:`success`,title:t.title,message:t.saved})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}async function lt(){let e=U.trim();if(e){P(`understanding:new`);try{await pe({content:e,kind:K}),W(``),H(!1),await E(),O({type:`success`,title:t.understandingTitle,message:t.saved})}catch{O({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{P(null)}}}async function ut(){if(Q.length){P(`understanding:batch`);try{await d(Q.map(e=>e.id),`confirm`),await E()}catch{O({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{P(null)}}}async function dt(e,n){P(`conflict:${e}`);try{await me(e,n),await E()}catch{O({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{P(null)}}async function ft(e){P(`grant:${e}`);try{await F(e),await E()}catch{O({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{P(null)}}async function pt(r,i){P(`insight:${r.id}`);try{let t=await ce(r.id,{action:i,uiLocale:e});await E(),i===`apply`&&t.href&&n(t.href)}catch{O({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{P(null)}}async function mt(e){P(`playbook:${e.id}`);try{await R(e.id,!e.enabled),await E()}catch{O({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{P(null)}}async function ht(e,n){P(`playbook:${e}`);try{await n(),await E()}catch{O({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{P(null)}}async function gt(){if(ge){P(ge.id);try{await N(ge.id);let e=ge.id;ye(null),await E(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),E()}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}}async function _t(){if(Ce){Le(!0);try{let e=await A(Ce);J(!1),we(null),await E(t=>t&&{...t,...e},{revalidate:!1})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{Le(!1)}}}async function vt(){let e=ze.trim();if(!(!e||Ve)){He(!0);try{let t=await A({callName:e,timezone:Z.timezone||_e()});await E(e=>e&&{...e,...t},{revalidate:!1})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{He(!1)}}}async function yt(){if(!Ve){He(!0);try{let e=await he(`snooze`);await E(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{He(!1)}}}function bt(){we(Z),J(!0),$(`profile`),requestAnimationFrame(()=>$e.current?.scrollIntoView({behavior:`smooth`,block:`start`}))}function xt(e){de(e),H(!0),$(`understanding`)}async function St(){if(rt){Ke(!0);try{We(await z(rt)),await E(),O({type:`success`,title:t.title,message:t.saved})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{Ke(!1)}}}async function Ct(e){if(!(!qe?.instanceId||Ye)){Xe(!0);try{let n=await ee(qe.instanceId,e);Je(null),await E(),O({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{O({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{Xe(!1)}}}async function wt(){if(!Ze){Qe(`export`);try{let e=await j(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{O({type:`error`,title:t.transferTitle,message:t.saveError})}finally{Qe(null)}}}async function Tt(e){if(!(!e||Ze)){Qe(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await ie(JSON.parse(await e.text()));await E(),$(`understanding`,`review`),O({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{O({type:`error`,title:t.transferTitle,message:t.importError})}finally{et.current&&(et.current.value=``),Qe(null)}}}return(0,X.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(be,{items:[{id:`overview`,label:t.tabs.overview,icon:re},{id:`profile`,label:t.tabs.profile,icon:_},{id:`understanding`,label:t.tabs.understanding,icon:te,count:Q.length||void 0},{id:`sources`,label:t.tabs.sources,icon:S},{id:`controls`,label:t.tabs.controls,icon:k}],activeTab:p,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`,className:`pr-8 sm:pr-1`,buttonClassName:`px-2.5 sm:px-3`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 w-8 bg-gradient-to-l from-surface-panel to-transparent sm:hidden`,"aria-hidden":!0})]}),T?(0,X.jsx)(Me,{}):w||!C?(0,X.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,C&&p===`overview`?(0,X.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Z.callName&&C.profileSetup.shouldPrompt?(0,X.jsx)(Re,{suggestion:C.profileSetup.callNameSuggestion,draft:ze,busy:Ve,onDraftChange:Be,onSave:()=>void vt(),onLater:()=>void yt(),t}):null,Q.length>0||at.length>0||!Z.callName?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[Q.length>0?(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[ke(t.reviewCount,Q.length),(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):null,at.length>0?(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[ke(t.sourceIssues,at.length),(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):null,Z.callName?null:(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:bt,children:[t.completeProfile,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:tt.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:it.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`,`review`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:Q.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.waitingReview})]})]})]}),C.insights.length>0?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(x,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,X.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:C.insights.map(e=>(0,X.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?ke(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,X.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:M===`insight:${e.id}`,onClick:()=>void pt(e,`dismiss`),children:t.notNow}),(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:M===`insight:${e.id}`,onClick:()=>void pt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`profile`),children:(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.callName||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.timezone||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.pronouns||`—`})]}),Z.notes?(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,X.jsx)(`dd`,{className:`mt-1 line-clamp-2 text-sm leading-6 text-fg`,children:Z.notes})]}):null]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(te,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[tt.slice(0,4).map(e=>(0,X.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),tt.length===0?(0,X.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]})]}):null,C&&p===`profile`?(0,X.jsxs)(`div`,{id:`you-panel-profile`,role:`tabpanel`,"aria-labelledby":`you-tab-profile`,className:`space-y-5`,children:[(0,X.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:t.profileOwnershipHint}),(0,X.jsxs)(`section`,{ref:$e,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,X.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.profileHint})]}),xe?null:(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:bt,children:[(0,X.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),xe&&Ce?(0,X.jsxs)(`div`,{className:`mt-5`,children:[(0,X.jsx)(Se,{value:Ce,onChange:we,language:e,inputClassName:Oe,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>{J(!1),we(null)},children:t.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:Ee,onClick:()=>void _t(),children:Ee?t.saving:t.save})]})]}):(0,X.jsxs)(`dl`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.callName||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.timezone||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.pronouns||`—`})]}),(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,X.jsx)(`dd`,{className:`mt-1 whitespace-pre-wrap text-sm leading-6 text-fg`,children:Z.notes||`—`})]})]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.structuredContextTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.structuredContextHint}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`preference`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addPreference}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addPreferenceHint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`boundary`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addBoundary}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addBoundaryHint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`current_state`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addCurrentFocus}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addCurrentFocusHint})]})]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,X.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.playbooksHint}),C.playbooks.length>0?(0,X.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:C.playbooks.map(e=>(0,X.jsx)(Ie,{playbook:e,busy:M===`playbook:${e.id}`,t,onToggleGroup:()=>void mt(e),onCreate:t=>void ht(e.id,()=>I(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void ht(e.id,()=>oe(e.id,t,n)),onDelete:t=>void ht(e.id,()=>le(e.id,t))},e.id))}):(0,X.jsx)(`p`,{className:`mt-4 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.emptyPlaybooks})]})]}):null,C&&p===`understanding`?(0,X.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,X.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,X.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),L?null:(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>H(!0),children:[(0,X.jsx)(B,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),L?(0,X.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,X.jsx)(`textarea`,{className:o(Oe,`min-h-24 resize-y`),value:U,onChange:e=>W(e.target.value),placeholder:t.understandingPlaceholder}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,X.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,X.jsx)(v,{value:K,onChange:e=>de(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,X.jsx)(q,{value:e,children:t},e))})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>{H(!1),W(``)},children:t.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:!U.trim()||M===`understanding:new`,onClick:()=>void lt(),children:t.add})]})]})]}):null]}),C.conflictGroups.some(e=>e.unresolved)?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,X.jsx)(`div`,{className:`mt-3 space-y-3`,children:C.conflictGroups.filter(e=>e.unresolved).map(n=>(0,X.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Ne(r,t),` · `,Ae(r.updatedAt,e)]})]}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:M===`conflict:${n.id}`,onClick:()=>void dt(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,C.consentRequests.length>0?(0,X.jsxs)(`section`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),C.consentRequests.map(e=>(0,X.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`deny`),children:t.consentDeny}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`once`),children:t.consentOnce}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`session`),children:t.consentSession}),(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,Q.length>0?(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:M===`understanding:batch`,onClick:()=>void ut(),children:t.reviewAll})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:Q.map(n=>(0,X.jsx)(Pe,{item:n,language:e,t,busy:M===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ye(n)},n.id))})]}):tt.length>0?(0,X.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,X.jsx)(s,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,X.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,De.map(n=>{let r=nt.get(n)??[];return r.length===0?null:(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,X.jsx)(Pe,{item:n,language:e,t,busy:M===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ye(n)},n.id))})]},n)}),C.understanding.length===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,C&&p===`sources`?(0,X.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,X.jsxs)(G,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]})]}),C.sourceRecommendations.length>0?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:C.sourceRecommendations.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ot({id:e.sourceId}),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:C.sources.map(n=>(0,X.jsx)(Fe,{source:n,language:e,t,onConfigure:()=>ot(n),onDisconnect:()=>Je(n)},`${n.id}:${n.instanceId??`catalog`}`))}),C.sources.length===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,C&&p===`controls`&&rt?(0,X.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.controlHint}),(0,X.jsxs)(`div`,{className:`mt-4 max-w-2xl space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,X.jsx)(v,{value:rt.mode,onChange:e=>We({...rt,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,X.jsx)(q,{value:e,children:t},e))})]}),(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,X.jsx)(v,{value:rt.sensitiveWritePolicy,onChange:e=>We({...rt,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,X.jsx)(q,{value:e,children:t},e))})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,X.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:t.transientPromise})]}),(0,X.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:Ge,onClick:()=>void St(),children:Ge?t.saving:t.save})})]})]}),(0,X.jsxs)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.actionBoundaryMovedTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.actionBoundaryMovedHint})]}),(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>n(`/settings/action-boundary`),children:[t.manageActionBoundary,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),C.referenceGrants.length>0?(0,X.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:C.referenceGrants.map(n=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${Ae(n.expiresAt,e)}`:``]})]}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:M===`grant:${n.id}`,onClick:()=>void ft(n.id),children:t.revoke})]},n.id))}):(0,X.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsxs)(G,{type:`button`,variant:`secondary`,disabled:Ze!==null,onClick:()=>void wt(),children:[(0,X.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),Ze===`export`?t.exporting:t.exportAction]}),(0,X.jsxs)(G,{type:`button`,variant:`secondary`,disabled:Ze!==null,onClick:()=>et.current?.click(),children:[(0,X.jsx)(m,{className:`size-4`,"aria-hidden":!0}),Ze===`import`?t.importing:t.importAction]}),(0,X.jsx)(`input`,{ref:et,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void Tt(e.target.files?.[0])})]}),(0,X.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,X.jsx)(ue,{open:ge!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void gt(),onCancel:()=>ye(null)}),(0,X.jsx)(Te,{source:qe,language:e,busy:Ye,onOpenChange:e=>{e||Je(null)},onConfirm:e=>void Ct(e)})]})}export{ze as UserContextPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-BuT0SR1R.js";import{n as l}from"./locale-store-C_M71MK9.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$t as d,Ao as f,Cn as p,Ds as m,Fo as h,Fs as g,Gl as _,Go as v,Gs as y,Io as b,Jc as x,Ml as S,Mo as C,No as w,Os as T,Po as E,Ql as D,Ro as O,Ys as k,_n as A,an as j,ao as M,cn as N,cs as P,dn as F,en as I,et as L,fn as R,gn as z,hc as B,hn as V,in as ee,iu as te,jl as ne,jo as H,js as U,ko as W,ll as re,ln as ie,lu as ae,mn as oe,ms as G,nn as se,on as K,pn as ce,qo as q,rn as le,rr as ue,sl as de,sn as fe,tn as pe,un as me,vn as he,vs as ge,wn as _e,xc as ve,xn as ye}from"./index-BuqGh2SW.js";import{t as be}from"./page-tabs-kFOswGlG.js";import{t as xe}from"./connector-logo-CiLxuZ8S.js";var J=n(),Y=e(t(),1),X=r();function Se(e){let t=(0,J.c)(104),{value:n,onChange:r,labels:i,language:a,inputClassName:s}=e,c;t[0]===n.timezone?c=t[1]:(c=()=>p.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=c);let[l,u]=(0,Y.useState)(c),d;t[2]===n.timezone?d=t[3]:(d=()=>!!n.timezone&&!p.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=d);let[f,m]=(0,Y.useState)(d),h;t[4]===n.pronouns?h=t[5]:(h=()=>!!n.pronouns&&!ye.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=h);let[g,_]=(0,Y.useState)(h),y;bb0:{if(f){y=`__custom__`;break bb0}y=p.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let b=y,x;t[6]!==r||t[7]!==n?(x=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=x):x=t[8];let S=x,C;t[9]===a?C=t[10]:(C=(e,t)=>a===`zh`?t:e,t[9]=a,t[10]=C);let w=C,T;t[11]===i.callName?T=t[12]:(T=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.callName}),t[11]=i.callName,t[12]=T);let E;t[13]===S?E=t[14]:(E=e=>S({callName:e.target.value}),t[13]=S,t[14]=E);let D;t[15]!==s||t[16]!==i.callNamePlaceholder||t[17]!==E||t[18]!==n.callName?(D=(0,X.jsx)(`input`,{className:s,value:n.callName,onChange:E,placeholder:i.callNamePlaceholder,autoComplete:`off`}),t[15]=s,t[16]=i.callNamePlaceholder,t[17]=E,t[18]=n.callName,t[19]=D):D=t[19];let O;t[20]!==T||t[21]!==D?(O=(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[T,D]}),t[20]=T,t[21]=D,t[22]=O):O=t[22];let k;t[23]===i.pronouns?k=t[24]:(k=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.pronouns}),t[23]=i.pronouns,t[24]=k);let A=g?`__custom__`:n.pronouns,j;t[25]!==S||t[26]!==n.pronouns?(j=e=>{if(e.target.value===`__custom__`){_(!0),ye.some(e=>e.value===n.pronouns)&&S({pronouns:``});return}_(!1),S({pronouns:e.target.value})},t[25]=S,t[26]=n.pronouns,t[27]=j):j=t[27];let M;t[28]===i.pronounsPlaceholder?M=t[29]:(M=(0,X.jsx)(q,{value:``,children:i.pronounsPlaceholder}),t[28]=i.pronounsPlaceholder,t[29]=M);let N;t[30]===w?N=t[31]:(N=ye.map(e=>(0,X.jsx)(q,{value:e.value,children:w(e.labelEn,e.labelZh)},e.value)),t[30]=w,t[31]=N);let F;t[32]===i.custom?F=t[33]:(F=(0,X.jsx)(q,{value:`__custom__`,children:i.custom}),t[32]=i.custom,t[33]=F);let I;t[34]!==s||t[35]!==A||t[36]!==j||t[37]!==M||t[38]!==N||t[39]!==F?(I=(0,X.jsxs)(v,{className:s,value:A,onChange:j,children:[M,N,F]}),t[34]=s,t[35]=A,t[36]=j,t[37]=M,t[38]=N,t[39]=F,t[40]=I):I=t[40];let L;t[41]!==s||t[42]!==i.pronounsPlaceholder||t[43]!==g||t[44]!==S||t[45]!==n.pronouns?(L=g?(0,X.jsx)(`input`,{className:o(s,`mt-1 text-xs`),value:n.pronouns,onChange:e=>S({pronouns:e.target.value}),placeholder:i.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=s,t[42]=i.pronounsPlaceholder,t[43]=g,t[44]=S,t[45]=n.pronouns,t[46]=L):L=t[46];let R;t[47]!==k||t[48]!==I||t[49]!==L?(R=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[k,I,L]}),t[47]=k,t[48]=I,t[49]=L,t[50]=R):R=t[50];let z;t[51]===i.timezone?z=t[52]:(z=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.timezone}),t[51]=i.timezone,t[52]=z);let B;t[53]===s?B=t[54]:(B=o(s,`min-w-0 flex-1`),t[53]=s,t[54]=B);let V;t[55]===S?V=t[56]:(V=e=>{if(e.target.value===`__custom__`){m(!0);return}m(!1),u(``),S({timezone:e.target.value})},t[55]=S,t[56]=V);let ee;t[57]===w?ee=t[58]:(ee=p.map(e=>(0,X.jsx)(q,{value:e.value,children:w(e.labelEn,e.labelZh)},e.value)),t[57]=w,t[58]=ee);let te;t[59]===i.timezoneCustom?te=t[60]:(te=(0,X.jsx)(q,{value:`__custom__`,children:i.timezoneCustom}),t[59]=i.timezoneCustom,t[60]=te);let ne;t[61]!==B||t[62]!==V||t[63]!==ee||t[64]!==te||t[65]!==b?(ne=(0,X.jsxs)(v,{className:B,value:b,onChange:V,children:[ee,te]}),t[61]=B,t[62]=V,t[63]=ee,t[64]=te,t[65]=b,t[66]=ne):ne=t[66];let H;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(H=o(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,P.press),t[67]=H):H=t[67];let U;t[68]===S?U=t[69]:(U=()=>{let e=_e();if(!e)return;let t=p.some(t=>t.value===e);m(!t),u(t?``:e),S({timezone:e})},t[68]=S,t[69]=U);let W;t[70]!==i.timezoneDetect||t[71]!==U?(W=(0,X.jsx)(`button`,{type:`button`,className:H,onClick:U,children:i.timezoneDetect}),t[70]=i.timezoneDetect,t[71]=U,t[72]=W):W=t[72];let re;t[73]!==ne||t[74]!==W?(re=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[ne,W]}),t[73]=ne,t[74]=W,t[75]=re):re=t[75];let ie;t[76]!==l||t[77]!==s||t[78]!==f||t[79]!==S?(ie=f?(0,X.jsx)(`input`,{className:o(s,`mt-1 font-mono text-xs`),value:l,onChange:e=>{u(e.target.value),S({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=l,t[77]=s,t[78]=f,t[79]=S,t[80]=ie):ie=t[80];let ae;t[81]!==z||t[82]!==re||t[83]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[z,re,ie]}),t[81]=z,t[82]=re,t[83]=ie,t[84]=ae):ae=t[84];let oe;t[85]===i.notes?oe=t[86]:(oe=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.notes}),t[85]=i.notes,t[86]=oe);let G;t[87]===s?G=t[88]:(G=o(s,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=s,t[88]=G);let se;t[89]===S?se=t[90]:(se=e=>S({notes:e.target.value}),t[89]=S,t[90]=se);let K;t[91]!==i.notesPlaceholder||t[92]!==G||t[93]!==se||t[94]!==n.notes?(K=(0,X.jsx)(`textarea`,{className:G,value:n.notes,onChange:se,placeholder:i.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=i.notesPlaceholder,t[92]=G,t[93]=se,t[94]=n.notes,t[95]=K):K=t[95];let ce;t[96]!==oe||t[97]!==K?(ce=(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[oe,K]}),t[96]=oe,t[97]=K,t[98]=ce):ce=t[98];let le;return t[99]!==O||t[100]!==R||t[101]!==ae||t[102]!==ce?(le=(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[O,R,ae,ce]}),t[99]=O,t[100]=R,t[101]=ae,t[102]=ce,t[103]=le):le=t[103],le}var Ce={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function we(e){if(e.branding?.logoUrl)return e.branding;let t=Ce[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}function Te(e){let t=(0,J.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:s}=e,l=c(r).you,[u,d]=(0,Y.useState)(!1),p=n?.accountLabel??(n?.accountCount&&n.accountCount>1&&n.accountOrdinal?l.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),m,g;t[0]===n?(m=t[1],g=t[2]):(m=()=>{n&&d(!1)},g=[n],t[0]=n,t[1]=m,t[2]=g),(0,Y.useEffect)(m,g);let _;t[3]!==i||t[4]!==a?(_=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=_):_=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=v):v=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,X.jsx)(ge,{className:`size-4`,"aria-hidden":!0}),t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>d(!1),t[8]=b):b=t[8];let x=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,D;t[9]===x?D=t[10]:(D=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,x),t[9]=x,t[10]=D);let O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,X.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=O):O=t[11];let k;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>d(!0),t[12]=k):k=t[12];let A=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,j;t[13]===A?j=t[14]:(j=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,A),t[13]=A,t[14]=j);let M;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(U,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=M):M=t[15];let N=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),P;t[16]===N?P=t[17]:(P=(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:N}),t[16]=N,t[17]=P);let F;t[18]!==i||t[19]!==l.cancel?(F=(0,X.jsx)(f,{asChild:!0,children:(0,X.jsx)(G,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=F):F=t[20];let I=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,L;t[21]!==u||t[22]!==s?(L=()=>s(u),t[21]=u,t[22]=s,t[23]=L):L=t[23];let R;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,X.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t[24]=R):R=t[24];let z=i?l.disconnecting:l.disconnectAction,B;t[25]!==i||t[26]!==I||t[27]!==L||t[28]!==z?(B=(0,X.jsxs)(G,{type:`button`,variant:`secondary`,className:I,disabled:i,onClick:L,children:[R,z]}),t[25]=i,t[26]=I,t[27]=L,t[28]=z,t[29]=B):B=t[29];let V;return t[30]!==F||t[31]!==B?(V=(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[F,B]}),t[30]=F,t[31]=B,t[32]=V):V=t[32],(0,X.jsx)(W,{open:n!==null,onOpenChange:_,children:(0,X.jsxs)(E,{children:[v,(0,X.jsxs)(H,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(h,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,X.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,X.jsx)(f,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:y})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[p?(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,p)}):null,(0,X.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:b,className:D,children:[O,(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:k,disabled:!n?.derivedUnderstandingCount,className:j,children:[M,(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),P]})]})]}),V]})]})})}var Ee=new Set([`overview`,`profile`,`understanding`,`sources`,`controls`]),De=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],Oe=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function ke(e,t){return e.replace(`{{count}}`,String(t))}function Ae(e,t){let n=Date.parse(e);return Number.isFinite(n)?L(n,t):e}function je(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Ee.has(e)?e:`overview`}function Me(){let e=(0,J.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(M,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,X.jsx)(M,{className:`h-64 rounded-2xl`}),(0,X.jsx)(M,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Ne(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Pe(e){let t=(0,J.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(n.statement),[g,_]=(0,Y.useState)(null),[v,b]=(0,Y.useState)(!1),x=n.status!==`active`,S=x?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===S?C=t[1]:(C=o(`rounded-xl border p-3.5`,S),t[0]=S,t[1]=C);let w;t[2]!==a||t[3]!==m||t[4]!==f||t[5]!==g||t[6]!==v||t[7]!==n||t[8]!==r||t[9]!==x||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(w=f?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{className:o(Oe,`min-h-20 resize-y`),value:m,onChange:e=>h(e.target.value),placeholder:i.updatePlaceholder}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{h(n.statement),p(!1)},children:i.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!m.trim(),onClick:()=>{u(m.trim()),p(!1)},children:i.save})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(y,{className:`size-3 text-accent`,"aria-hidden":!0}),Ne(n,i)]}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,X.jsx)(`span`,{children:ke(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,X.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,Ae(n.latestEvidenceAt,r))}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[x?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,X.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,X.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,X.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:v,onClick:()=>{if(g){_(null);return}b(!0),K(n.id).then(e=>_(e.history)).finally(()=>b(!1))},children:[(0,X.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,X.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,X.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,X.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Ae(n.updatedAt,r)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:ke(i.evidenceCount,n.evidenceCount)})]})]})]}),g?(0,X.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),g.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,X.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,X.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:Ae(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=m,t[4]=f,t[5]=g,t[6]=v,t[7]=n,t[8]=r,t[9]=x,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let T;return t[16]!==C||t[17]!==w?(T=(0,X.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=T):T=t[18],T}function Fe(e){let t=(0,J.c)(84),{source:n,language:r,t:i,onConfigure:a,onDisconnect:s}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.accountCount||t[1]!==n.accountLabel||t[2]!==n.accountOrdinal||t[3]!==i.sourceAccountFallback?(l=n.accountLabel??(n.accountCount&&n.accountCount>1&&n.accountOrdinal?i.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),t[0]=n.accountCount,t[1]=n.accountLabel,t[2]=n.accountOrdinal,t[3]=i.sourceAccountFallback,t[4]=l):l=t[4];let u=l,d;t[5]!==n.lastHealthStatus||t[6]!==i.healthIssue||t[7]!==i.healthOk||t[8]!==i.sourceHealth?(d=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[5]=n.lastHealthStatus,t[6]=i.healthIssue,t[7]=i.healthOk,t[8]=i.sourceHealth,t[9]=d):d=t[9];let f=d,p=`${i.manageSources}: ${n.displayName}`,m;t[10]===a?m=t[11]:(m=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[10]=a,t[11]=m);let h=n.displayName,g;t[12]===n?g=t[13]:(g=we(n),t[12]=n,t[13]=g);let _;t[14]!==n.displayName||t[15]!==g?(_=(0,X.jsx)(xe,{connector:{displayName:h,branding:g},size:`sm`}),t[14]=n.displayName,t[15]=g,t[16]=_):_=t[16];let v;t[17]===n.displayName?v=t[18]:(v=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[17]=n.displayName,t[18]=v);let y;t[19]===u?y=t[20]:(y=u?(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:u}):null,t[19]=u,t[20]=y);let b;t[21]===n.description?b=t[22]:(b=(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[21]=n.description,t[22]=b);let x;t[23]!==b||t[24]!==v||t[25]!==y?(x=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[v,y,b]}),t[23]=b,t[24]=v,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==_?(S=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[_,x]}),t[27]=x,t[28]=_,t[29]=S):S=t[29];let C=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,w;t[30]===C?w=t[31]:(w=o(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,C),t[30]=C,t[31]=w);let T;t[32]!==c||t[33]!==w?(T=(0,X.jsx)(`span`,{className:w,children:c}),t[32]=c,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==S||t[36]!==T?(E=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,T]}),t[35]=S,t[36]=T,t[37]=E):E=t[37];let D;t[38]!==n.access.context||t[39]!==i.sourceContext?(D=n.access.context?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[38]=n.access.context,t[39]=i.sourceContext,t[40]=D):D=t[40];let O;t[41]!==n.access.memory||t[42]!==i.sourceMemory?(O=n.access.memory?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[41]=n.access.memory,t[42]=i.sourceMemory,t[43]=O):O=t[43];let k;t[44]!==n.access.read||t[45]!==i.sourceRead?(k=n.access.read?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[44]=n.access.read,t[45]=i.sourceRead,t[46]=k):k=t[46];let A;t[47]!==n.access.write||t[48]!==i.sourceWrite?(A=n.access.write?(0,X.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[47]=n.access.write,t[48]=i.sourceWrite,t[49]=A):A=t[49];let j;t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A?(j=(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[D,O,k,A]}),t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=j):j=t[54];let M;t[55]!==f||t[56]!==r||t[57]!==n.derivedUnderstandingCount||t[58]!==n.installed||t[59]!==n.knowledgeItemCount||t[60]!==n.lastActivityAt||t[61]!==n.lastSyncAt||t[62]!==n.lastSyncError||t[63]!==n.lastSyncStatus||t[64]!==i.sourceDerivedCount||t[65]!==i.sourceKnowledgeCount||t[66]!==i.sourceLastSync||t[67]!==i.sourceLastUsed||t[68]!==i.sourceNeverUsed||t[69]!==i.sourceSyncFailed?(M=n.installed?(0,X.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[f?(0,X.jsx)(`p`,{children:f}):null,(0,X.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,Ae(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,X.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,Ae(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,X.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,X.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,X.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[55]=f,t[56]=r,t[57]=n.derivedUnderstandingCount,t[58]=n.installed,t[59]=n.knowledgeItemCount,t[60]=n.lastActivityAt,t[61]=n.lastSyncAt,t[62]=n.lastSyncError,t[63]=n.lastSyncStatus,t[64]=i.sourceDerivedCount,t[65]=i.sourceKnowledgeCount,t[66]=i.sourceLastSync,t[67]=i.sourceLastUsed,t[68]=i.sourceNeverUsed,t[69]=i.sourceSyncFailed,t[70]=M):M=t[70];let N;t[71]!==s||t[72]!==n.installed||t[73]!==n.instanceId||t[74]!==i.disconnect?(N=n.installed&&n.instanceId?(0,X.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),s()},children:i.disconnect})}):null,t[71]=s,t[72]=n.installed,t[73]=n.instanceId,t[74]=i.disconnect,t[75]=N):N=t[75];let P;return t[76]!==a||t[77]!==E||t[78]!==j||t[79]!==M||t[80]!==N||t[81]!==p||t[82]!==m?(P=(0,X.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":p,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:m,children:[E,j,M,N]}),t[76]=a,t[77]=E,t[78]=j,t[79]=M,t[80]=N,t[81]=p,t[82]=m,t[83]=P):P=t[83],P}function Ie(e){let t=(0,J.c)(58),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:s,onUpdate:c,onDelete:l}=e,[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),g=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,_;t[0]===g?_=t[1]:(_=o(`rounded-xl border p-4`,g),t[0]=g,t[1]=_);let v=i.playbookNames[n.id],y;t[2]===v?y=t[3]:(y=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:v}),t[2]=v,t[3]=y);let b;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(b=ke(i.playbookRuleCount,n.rules.filter(Le).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=b):b=t[6];let x;t[7]===b?x=t[8]:(x=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:b}),t[7]=b,t[8]=x);let S;t[9]!==y||t[10]!==x?(S=(0,X.jsxs)(`div`,{children:[y,x]}),t[9]=y,t[10]=x,t[11]=S):S=t[11];let C=n.enabled?i.pausePlaybook:i.resumePlaybook,w;t[12]!==r||t[13]!==a||t[14]!==C?(w=(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:C}),t[12]=r,t[13]=a,t[14]=C,t[15]=w):w=t[15];let T;t[16]!==S||t[17]!==w?(T=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,w]}),t[16]=S,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==r||t[20]!==f||t[21]!==m||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(E=n.rules.map((e,t)=>(0,X.jsx)(`li`,{className:o(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{className:o(Oe,`min-h-16 resize-y`),value:m,onChange:e=>h(e.target.value)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!m.trim(),onClick:()=>{c(e.id,{statement:m.trim()}),p(null)},children:i.save})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),h(e.statement)},children:[(0,X.jsx)(ve,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,X.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,X.jsx)(U,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=m,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=E):E=t[33];let D;t[34]===E?D=t[35]:(D=(0,X.jsx)(`ul`,{className:`mt-3 space-y-2`,children:E}),t[34]=E,t[35]=D);let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>d(e.target.value),t[36]=O):O=t[36];let k;t[37]!==u||t[38]!==i.newRulePlaceholder?(k=(0,X.jsx)(`input`,{className:Oe,value:u,onChange:O,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=k):k=t[39];let A;t[40]!==r||t[41]!==u?(A=r||!u.trim(),t[40]=r,t[41]=u,t[42]=A):A=t[42];let j;t[43]!==u||t[44]!==s?(j=()=>{s(u.trim()),d(``)},t[43]=u,t[44]=s,t[45]=j):j=t[45];let M;t[46]!==i.addRule||t[47]!==A||t[48]!==j?(M=(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:A,onClick:j,children:i.addRule}),t[46]=i.addRule,t[47]=A,t[48]=j,t[49]=M):M=t[49];let N;t[50]!==k||t[51]!==M?(N=(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[k,M]}),t[50]=k,t[51]=M,t[52]=N):N=t[52];let P;return t[53]!==T||t[54]!==D||t[55]!==N||t[56]!==_?(P=(0,X.jsxs)(`article`,{className:_,children:[T,D,N]}),t[53]=T,t[54]=D,t[55]=N,t[56]=_,t[57]=P):P=t[57],P}function Le(e){return e.enabled}function Re(e){let t=(0,J.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:s,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=d);let f=n?l.meetSuggestedBody:l.meetBody,p;t[6]===f?p=t[7]:(p=(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:f}),t[6]=f,t[7]=p);let m;t[8]===l.callName?m=t[9]:(m=(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=m);let h;t[10]===a?h=t[11]:(h=e=>a(e.target.value),t[10]=a,t[11]=h);let g;t[12]!==i||t[13]!==r||t[14]!==s?(g=e=>{e.key===`Enter`&&r.trim()&&!i&&s()},t[12]=i,t[13]=r,t[14]=s,t[15]=g):g=t[15];let _=l.meetPlaceholder,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(Oe,`h-10 flex-1 bg-surface-base/90`),t[16]=v):v=t[16];let y;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==h||t[20]!==g?(y=(0,X.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,onChange:h,onKeyDown:g,placeholder:_,className:v}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=h,t[20]=g,t[21]=y):y=t[21];let b;t[22]!==i||t[23]!==r?(b=i||!r.trim(),t[22]=i,t[23]=r,t[24]=b):b=t[24];let x=i?l.meetSaving:l.meetSave,S;t[25]!==s||t[26]!==b||t[27]!==x?(S=(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:b,onClick:s,children:x}),t[25]=s,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==y||t[30]!==S||t[31]!==m?(C=(0,X.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[m,y,S]}),t[29]=y,t[30]=S,t[31]=m,t[32]=C):C=t[32];let w;t[33]!==n||t[34]!==l.meetSource?(w=n?(0,X.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,X.jsx)(k,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=w):w=t[35];let T;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(T=(0,X.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=T):T=t[39];let E;return t[40]!==C||t[41]!==w||t[42]!==T||t[43]!==d||t[44]!==p?(E=(0,X.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,X.jsxs)(`div`,{className:`relative max-w-2xl`,children:[d,p,C,w,T]})}),t[40]=C,t[41]=w,t[42]=T,t[43]=d,t[44]=p,t[45]=E):E=t[45],E}function ze(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,f]=i(),p=je(r.get(`tab`)),h=b(e=>e.setPageHeader),y=b(e=>e.clearPageHeader),{data:C,error:w,isLoading:T,mutate:E}=u(`/api/you`,fe),[M,P]=(0,Y.useState)(null),[L,H]=(0,Y.useState)(!1),[U,W]=(0,Y.useState)(``),[K,de]=(0,Y.useState)(`preference`),[ge,ye]=(0,Y.useState)(null),[xe,J]=(0,Y.useState)(!1),[Ce,we]=(0,Y.useState)(null),[Ee,Le]=(0,Y.useState)(!1),[ze,Be]=(0,Y.useState)(``),[Ve,He]=(0,Y.useState)(!1),[Ue,We]=(0,Y.useState)(null),[Ge,Ke]=(0,Y.useState)(!1),[qe,Je]=(0,Y.useState)(null),[Ye,Xe]=(0,Y.useState)(!1),[Ze,Qe]=(0,Y.useState)(null),$e=(0,Y.useRef)(null),et=(0,Y.useRef)(null),Z=C?.profile??{callName:``,pronouns:``,timezone:``,notes:``},tt=(0,Y.useMemo)(()=>C?.understanding.filter(e=>e.status===`active`)??[],[C]),Q=(0,Y.useMemo)(()=>C?.understanding.filter(e=>e.status!==`active`)??[],[C]),nt=(0,Y.useMemo)(()=>new Map(De.map(e=>[e,tt.filter(t=>t.facet===e)])),[tt]),rt=Ue??C?.controls??null,it=C?.sources.filter(e=>e.installed&&e.enabled)??[],at=it.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),f(n,{replace:!0})},ot=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,Y.useLayoutEffect)(()=>(h({startExtra:null,main:(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,X.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>y()),[y,h,t.subtitle,t.title]),(0,Y.useEffect)(()=>{!C||C.profile.callName||Be(C.profileSetup.callNameSuggestion?.value??``)},[C,C?.profile.callName,C?.profileSetup.callNameSuggestion?.id]);async function st(e,n,r){P(e.id);try{let t=await V(e.id,{action:n,content:r});await E(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),E()}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}async function ct(e,n){P(`consent:${e}`);try{await se(e,n),await E(),O({type:`success`,title:t.title,message:t.saved})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}async function lt(){let e=U.trim();if(e){P(`understanding:new`);try{await pe({content:e,kind:K}),W(``),H(!1),await E(),O({type:`success`,title:t.understandingTitle,message:t.saved})}catch{O({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{P(null)}}}async function ut(){if(Q.length){P(`understanding:batch`);try{await d(Q.map(e=>e.id),`confirm`),await E()}catch{O({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{P(null)}}}async function dt(e,n){P(`conflict:${e}`);try{await me(e,n),await E()}catch{O({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{P(null)}}async function ft(e){P(`grant:${e}`);try{await F(e),await E()}catch{O({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{P(null)}}async function pt(r,i){P(`insight:${r.id}`);try{let t=await ce(r.id,{action:i,uiLocale:e});await E(),i===`apply`&&t.href&&n(t.href)}catch{O({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{P(null)}}async function mt(e){P(`playbook:${e.id}`);try{await R(e.id,!e.enabled),await E()}catch{O({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{P(null)}}async function ht(e,n){P(`playbook:${e}`);try{await n(),await E()}catch{O({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{P(null)}}async function gt(){if(ge){P(ge.id);try{await N(ge.id);let e=ge.id;ye(null),await E(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),E()}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}}async function _t(){if(Ce){Le(!0);try{let e=await A(Ce);J(!1),we(null),await E(t=>t&&{...t,...e},{revalidate:!1})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{Le(!1)}}}async function vt(){let e=ze.trim();if(!(!e||Ve)){He(!0);try{let t=await A({callName:e,timezone:Z.timezone||_e()});await E(e=>e&&{...e,...t},{revalidate:!1})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{He(!1)}}}async function yt(){if(!Ve){He(!0);try{let e=await he(`snooze`);await E(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{He(!1)}}}function bt(){we(Z),J(!0),$(`profile`),requestAnimationFrame(()=>$e.current?.scrollIntoView({behavior:`smooth`,block:`start`}))}function xt(e){de(e),H(!0),$(`understanding`)}async function St(){if(rt){Ke(!0);try{We(await z(rt)),await E(),O({type:`success`,title:t.title,message:t.saved})}catch{O({type:`error`,title:t.title,message:t.saveError})}finally{Ke(!1)}}}async function Ct(e){if(!(!qe?.instanceId||Ye)){Xe(!0);try{let n=await ee(qe.instanceId,e);Je(null),await E(),O({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{O({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{Xe(!1)}}}async function wt(){if(!Ze){Qe(`export`);try{let e=await j(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{O({type:`error`,title:t.transferTitle,message:t.saveError})}finally{Qe(null)}}}async function Tt(e){if(!(!e||Ze)){Qe(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await ie(JSON.parse(await e.text()));await E(),$(`understanding`,`review`),O({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{O({type:`error`,title:t.transferTitle,message:t.importError})}finally{et.current&&(et.current.value=``),Qe(null)}}}return(0,X.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(be,{items:[{id:`overview`,label:t.tabs.overview,icon:re},{id:`profile`,label:t.tabs.profile,icon:_},{id:`understanding`,label:t.tabs.understanding,icon:te,count:Q.length||void 0},{id:`sources`,label:t.tabs.sources,icon:S},{id:`controls`,label:t.tabs.controls,icon:k}],activeTab:p,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`,className:`pr-8 sm:pr-1`,buttonClassName:`px-2.5 sm:px-3`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 w-8 bg-gradient-to-l from-surface-panel to-transparent sm:hidden`,"aria-hidden":!0})]}),T?(0,X.jsx)(Me,{}):w||!C?(0,X.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,C&&p===`overview`?(0,X.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Z.callName&&C.profileSetup.shouldPrompt?(0,X.jsx)(Re,{suggestion:C.profileSetup.callNameSuggestion,draft:ze,busy:Ve,onDraftChange:Be,onSave:()=>void vt(),onLater:()=>void yt(),t}):null,Q.length>0||at.length>0||!Z.callName?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[Q.length>0?(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[ke(t.reviewCount,Q.length),(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):null,at.length>0?(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[ke(t.sourceIssues,at.length),(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):null,Z.callName?null:(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:bt,children:[t.completeProfile,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:tt.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:it.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`,`review`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:Q.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.waitingReview})]})]})]}),C.insights.length>0?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(x,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,X.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:C.insights.map(e=>(0,X.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?ke(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,X.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:M===`insight:${e.id}`,onClick:()=>void pt(e,`dismiss`),children:t.notNow}),(0,X.jsx)(G,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:M===`insight:${e.id}`,onClick:()=>void pt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`profile`),children:(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.callName||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.timezone||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.pronouns||`—`})]}),Z.notes?(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,X.jsx)(`dd`,{className:`mt-1 line-clamp-2 text-sm leading-6 text-fg`,children:Z.notes})]}):null]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(te,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[tt.slice(0,4).map(e=>(0,X.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),tt.length===0?(0,X.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]})]}):null,C&&p===`profile`?(0,X.jsxs)(`div`,{id:`you-panel-profile`,role:`tabpanel`,"aria-labelledby":`you-tab-profile`,className:`space-y-5`,children:[(0,X.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:t.profileOwnershipHint}),(0,X.jsxs)(`section`,{ref:$e,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,X.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.profileHint})]}),xe?null:(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:bt,children:[(0,X.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),xe&&Ce?(0,X.jsxs)(`div`,{className:`mt-5`,children:[(0,X.jsx)(Se,{value:Ce,onChange:we,language:e,inputClassName:Oe,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>{J(!1),we(null)},children:t.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:Ee,onClick:()=>void _t(),children:Ee?t.saving:t.save})]})]}):(0,X.jsxs)(`dl`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.callName||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.timezone||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Z.pronouns||`—`})]}),(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,X.jsx)(`dd`,{className:`mt-1 whitespace-pre-wrap text-sm leading-6 text-fg`,children:Z.notes||`—`})]})]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.structuredContextTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.structuredContextHint}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`preference`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addPreference}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addPreferenceHint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`boundary`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addBoundary}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addBoundaryHint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`current_state`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addCurrentFocus}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addCurrentFocusHint})]})]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,X.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.playbooksHint}),C.playbooks.length>0?(0,X.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:C.playbooks.map(e=>(0,X.jsx)(Ie,{playbook:e,busy:M===`playbook:${e.id}`,t,onToggleGroup:()=>void mt(e),onCreate:t=>void ht(e.id,()=>I(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void ht(e.id,()=>oe(e.id,t,n)),onDelete:t=>void ht(e.id,()=>le(e.id,t))},e.id))}):(0,X.jsx)(`p`,{className:`mt-4 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.emptyPlaybooks})]})]}):null,C&&p===`understanding`?(0,X.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,X.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,X.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),L?null:(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>H(!0),children:[(0,X.jsx)(B,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),L?(0,X.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,X.jsx)(`textarea`,{className:o(Oe,`min-h-24 resize-y`),value:U,onChange:e=>W(e.target.value),placeholder:t.understandingPlaceholder}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,X.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,X.jsx)(v,{value:K,onChange:e=>de(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,X.jsx)(q,{value:e,children:t},e))})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>{H(!1),W(``)},children:t.cancel}),(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:!U.trim()||M===`understanding:new`,onClick:()=>void lt(),children:t.add})]})]})]}):null]}),C.conflictGroups.some(e=>e.unresolved)?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,X.jsx)(`div`,{className:`mt-3 space-y-3`,children:C.conflictGroups.filter(e=>e.unresolved).map(n=>(0,X.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Ne(r,t),` · `,Ae(r.updatedAt,e)]})]}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:M===`conflict:${n.id}`,onClick:()=>void dt(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,C.consentRequests.length>0?(0,X.jsxs)(`section`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),C.consentRequests.map(e=>(0,X.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`deny`),children:t.consentDeny}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`once`),children:t.consentOnce}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`session`),children:t.consentSession}),(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:M===`consent:${e.id}`,onClick:()=>void ct(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,Q.length>0?(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,X.jsx)(G,{type:`button`,variant:`secondary`,disabled:M===`understanding:batch`,onClick:()=>void ut(),children:t.reviewAll})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:Q.map(n=>(0,X.jsx)(Pe,{item:n,language:e,t,busy:M===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ye(n)},n.id))})]}):tt.length>0?(0,X.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,X.jsx)(s,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,X.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,De.map(n=>{let r=nt.get(n)??[];return r.length===0?null:(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,X.jsx)(Pe,{item:n,language:e,t,busy:M===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ye(n)},n.id))})]},n)}),C.understanding.length===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,C&&p===`sources`?(0,X.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,X.jsxs)(G,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]})]}),C.sourceRecommendations.length>0?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:C.sourceRecommendations.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ot({id:e.sourceId}),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:C.sources.map(n=>(0,X.jsx)(Fe,{source:n,language:e,t,onConfigure:()=>ot(n),onDisconnect:()=>Je(n)},`${n.id}:${n.instanceId??`catalog`}`))}),C.sources.length===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,C&&p===`controls`&&rt?(0,X.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.controlHint}),(0,X.jsxs)(`div`,{className:`mt-4 max-w-2xl space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,X.jsx)(v,{value:rt.mode,onChange:e=>We({...rt,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,X.jsx)(q,{value:e,children:t},e))})]}),(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,X.jsx)(v,{value:rt.sensitiveWritePolicy,onChange:e=>We({...rt,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,X.jsx)(q,{value:e,children:t},e))})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,X.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:t.transientPromise})]}),(0,X.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,X.jsx)(G,{type:`button`,variant:`primary`,disabled:Ge,onClick:()=>void St(),children:Ge?t.saving:t.save})})]})]}),(0,X.jsxs)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.actionBoundaryMovedTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.actionBoundaryMovedHint})]}),(0,X.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>n(`/settings/action-boundary`),children:[t.manageActionBoundary,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),C.referenceGrants.length>0?(0,X.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:C.referenceGrants.map(n=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${Ae(n.expiresAt,e)}`:``]})]}),(0,X.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:M===`grant:${n.id}`,onClick:()=>void ft(n.id),children:t.revoke})]},n.id))}):(0,X.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsxs)(G,{type:`button`,variant:`secondary`,disabled:Ze!==null,onClick:()=>void wt(),children:[(0,X.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),Ze===`export`?t.exporting:t.exportAction]}),(0,X.jsxs)(G,{type:`button`,variant:`secondary`,disabled:Ze!==null,onClick:()=>et.current?.click(),children:[(0,X.jsx)(m,{className:`size-4`,"aria-hidden":!0}),Ze===`import`?t.importing:t.importAction]}),(0,X.jsx)(`input`,{ref:et,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void Tt(e.target.files?.[0])})]}),(0,X.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,X.jsx)(ue,{open:ge!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void gt(),onCancel:()=>ye(null)}),(0,X.jsx)(Te,{source:qe,language:e,busy:Ye,onOpenChange:e=>{e||Je(null)},onConfirm:e=>void Ct(e)})]})}export{ze as UserContextPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-BQ_8x0bT.js";import{l as o,r as s,s as c}from"./locale-store-C_M71MK9.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{Gn as u,Go as d,Ol as f,Xt as p,Yt as m,as as h,eu as g,ic as _,io as v,ms as y,ps as b,qo as x,ro as S,zc as ee}from"./index-EXa_i6BT.js";var C=`/api/image/providers`;async function te(){return(await c(s(`/api/image/providers`)))?.payload?.providers??[]}var w=e(t(),1),ne=n();function T(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function re(e){return e?.apiKey?`••••••••••••`:``}function E(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:re(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function D(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function O(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(u(n)&&u(r)))return n||(r?null:void 0)}function ie(e,t,n){let r={};for(let i of e){let e=t[i]??T(),a=n[i]??T();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=O(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=D(e,a,`region`);c!==void 0&&(o.region=c);let l=D(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=D(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function k(e){let t=await c(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ae(e){Object.keys(e).length!==0&&(await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await S())}var A=r();function oe(e){let t=(0,ne.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>k(n).then(j),t[0]=n,t[1]=c);let l=c,u=`img-cred-key-${n}`,d;t[2]!==a.apiKeyLabel||t[3]!==u?(d=(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:u,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=u,t[4]=d):d=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,A.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[p(e.kind,s),(0,A.jsx)(f,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=t[7];let g=`img-cred-key-${n}`,_;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==g||t[12]!==r?(_=(0,A.jsx)(h,{id:g,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=g,t[12]=r,t[13]=_):_=t[13];let v;return t[14]!==d||t[15]!==m||t[16]!==_?(v=(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[d,m,_]}),t[14]=d,t[15]=m,t[16]=_,t[17]=v):v=t[17],v}function j(e){return e.apiKey??null}function M(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b)}function se(){return a(M(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var N=`__custom__`;function ce(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:N}function le(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:N}function ue(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function de(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function fe(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function pe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function me(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function P(e){let t=(0,ne.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:u,credNoopFlash:p,updateCredRow:h,onDiscardCredentials:v,onSaveCredentials:b,extensionIds:S,showExtensionLinks:C,showImageModelsLink:te,hideActions:re,language:E,apiKeyLinkLabels:D,messages:O}=e,ie=re===void 0?!1:re,k;t[0]===n?k=t[1]:(k=n.some(ye),t[0]=n,t[1]=k);let ae=k,j;t[2]===n?j=t[3]:(j=n.some(ve),t[2]=n,t[3]=j);let P=j,[F,be]=(0,w.useState)(_e),[I,L]=(0,w.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)pe(r[e.id]??T(),o[e.id]??T())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===O.credentialsIntro?W=t[15]:(W=(0,A.jsx)(`p`,{children:O.credentialsIntro}),t[14]=O.credentialsIntro,t[15]=W);let G;t[16]!==ae||t[17]!==O.regionHint?(G=ae?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.regionHint}):null,t[16]=ae,t[17]=O.regionHint,t[18]=G):G=t[18];let K;t[19]!==P||t[20]!==O.endpointPresetsHint?(K=P?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.endpointPresetsHint}):null,t[19]=P,t[20]=O.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==te||t[23]!==O.imageModelsLinkTitle||t[24]!==O.openImageModelsPage?(q=te?(0,A.jsx)(`p`,{children:(0,A.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:O.imageModelsLinkTitle,children:O.openImageModelsPage})}):null,t[22]=te,t[23]=O.imageModelsLinkTitle,t[24]=O.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,A.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===l?Y=t[32]:(Y=l?(0,A.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==p||t[35]!==u||t[36]!==c||t[37]!==ie||t[38]!==v||t[39]!==b||t[40]!==O.credentialsNothingToSave||t[41]!==O.credentialsSaved||t[42]!==O.discardCredentials||t[43]!==O.saveCredentials||t[44]!==O.savingCredentials?(X=ie?null:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[u?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsSaved}):null,p?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsNothingToSave}):null,(0,A.jsx)(y,{type:`button`,variant:`secondary`,onClick:v,disabled:!s||c,children:O.discardCredentials}),(0,A.jsx)(y,{type:`button`,variant:`primary`,onClick:b,disabled:!s||c,children:c?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ee,{className:`size-3.5 animate-spin`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.savingCredentials})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{className:`size-3.5`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.saveCredentials})]})})]}),t[33]=s,t[34]=p,t[35]=u,t[36]=c,t[37]=ie,t[38]=v,t[39]=b,t[40]=O.credentialsNothingToSave,t[41]=O.credentialsSaved,t[42]=O.discardCredentials,t[43]=O.saveCredentials,t[44]=O.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==D||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==E||t[52]!==C||t[53]!==n||t[54]!==O||t[55]!==U||t[56]!==h){let e;t[58]!==D||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==E||t[64]!==C||t[65]!==O||t[66]!==U||t[67]!==h?(e=e=>{let t=r[e.id]??T(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=pe(t,o[e.id]??T()),l=V(e.id),u=e.label??e.id,p=me(O,e.models.length);return(0,A.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:u}),(0,A.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.unsavedChanges}):null,e.configured?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.configured}):(0,A.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:O.missingKey})]}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,A.jsx)(`span`,{children:p}),e.defaultModel?(0,A.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,A.jsx)(g,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`sr-only`,children:l?O.collapseProvider:O.expandProvider})]}),l?(0,A.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 p-4`,children:[s?(0,A.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:O.extensionSettingsLinkTitle,children:[(0,A.jsx)(f,{className:`size-3`}),O.openExtensionSettings]}):null,e.models.length>0?(0,A.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,A.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,A.jsx)(oe,{providerId:e.id,value:t.apiKey,onChange:t=>h(e.id,{apiKey:t}),apiKeyLinks:m(e.id,E),apiKeyLinkLabels:D,labels:{apiKeyLabel:O.apiKeyLabel,optionalPlaceholder:O.optionalPlaceholder,maskedHelp:O.apiKeyMaskedHelp,copy:O.apiKeyCopy,copied:O.apiKeyCopied,show:O.apiKeyShow,hide:O.apiKeyHide,notInConfigFile:O.apiKeyNotInConfigFile,loadFailed:O.apiKeyRevealFailed}}),n?.regions?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:O.regionLabel}),(0,A.jsxs)(d,{id:`img-cred-region-preset-${e.id}`,className:se(),value:ce(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){h(e.id,{region:``,imageBaseUrl:``});return}if(r===N){h(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&h(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,A.jsx)(x,{value:``,children:O.regionPresetDefault}),n.regions.map(e=>(0,A.jsx)(x,{value:e.value,children:ue(O,e.value,e.label)},e.value)),(0,A.jsx)(x,{value:N,children:O.regionPresetCustom})]}),ce(t,n.regions)===N?(0,A.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,A.jsx)(`input`,{type:`text`,className:M(),value:t.region,placeholder:`region`,onChange:t=>h(e.id,{region:t.target.value})}),(0,A.jsx)(`input`,{type:`url`,className:M(),value:t.imageBaseUrl,placeholder:O.imageBaseUrlLabel,onChange:t=>h(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:de(O,n.baseUrlPresetKind)}),fe(O,n.baseUrlPresetKind)?(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:fe(O,n.baseUrlPresetKind)}):null,(0,A.jsxs)(d,{id:`img-cred-base-preset-${e.id}`,className:se(),value:le(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){h(e.id,{baseUrl:``});return}if(n===N){h(e.id,{baseUrl:``});return}h(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,A.jsx)(x,{value:``,children:O.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,A.jsx)(x,{value:N,children:O.baseUrlPresetCustom})]}),le(t,n.baseUrlPresets)===N?(0,A.jsx)(`input`,{type:`url`,className:a(M(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>h(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&ce(t,n.regions)!==N?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:O.imageBaseUrlLabel}),(0,A.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(M(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:O.imageBaseUrlPresetHint}),(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:O.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=D,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=E,t[64]=C,t[65]=O,t[66]=U,t[67]=h,t[68]=e):e=t[68],Z=n.map(e),t[46]=D,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=E,t[52]=C,t[53]=n,t[54]=O,t[55]=U,t[56]=h,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,A.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function he(e){return(0,A.jsx)(x,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=v(o(e=>!!e.token)),n=t.data,r=(0,w.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,w.useRef)(!1),[a,c]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(!1),[g,_]=(0,w.useState)(!1),y=(0,w.useMemo)(()=>E(n?.payload?.config,r),[n?.payload?.config,r]),b=a??y,x=y;return{gwSwr:t,credDraft:b,credBaseline:x,credDirty:(0,w.useMemo)(()=>JSON.stringify(b)!==JSON.stringify(x),[b,x]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,w.useCallback)((e,t)=>{i.current=!0,c(n=>{let r=n??y,i=r[e]??T();return{...r,[e]:{...i,...t}}})},[y]),onDiscardCredentials:(0,w.useCallback)(()=>{i.current=!1,c(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,w.useCallback)(async e=>{let n=ie(r,b,x);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ae(n),await t.mutate?.(),l(s(C)),i.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,b,x,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=be();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=I();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function K(){return G((await c(s(`/api/config`))).payload?.config??{})}async function q(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await c(s(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),S()}async function J(){let e=await c(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await c(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await c(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(){let e=await c(s(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(e){let t=await c(s(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Se(e){let t=await c(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function Ce(e){let t=(0,ne.c)(15),{kind:n,providerId:r,fieldId:i,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let g;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(g=(0,A.jsx)(h,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=g):g=t[11];let _;return t[12]!==m||t[13]!==g?(_=(0,A.jsx)(`div`,{className:m,children:g}),t[12]=m,t[13]=g,t[14]=_):_=t[14],_}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,te as m,Z as n,X as o,P as p,J as r,Q as s,Ce as t,$ as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-BQ_8x0bT.js";import{l as o,r as s,s as c}from"./locale-store-C_M71MK9.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{Gn as u,Go as d,Ol as f,Xt as p,Yt as m,as as h,eu as g,ic as _,io as v,ms as y,ps as b,qo as x,ro as S,zc as ee}from"./index-BuqGh2SW.js";var C=`/api/image/providers`;async function te(){return(await c(s(`/api/image/providers`)))?.payload?.providers??[]}var w=e(t(),1),ne=n();function T(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function re(e){return e?.apiKey?`••••••••••••`:``}function E(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:re(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function D(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function O(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(u(n)&&u(r)))return n||(r?null:void 0)}function ie(e,t,n){let r={};for(let i of e){let e=t[i]??T(),a=n[i]??T();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=O(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=D(e,a,`region`);c!==void 0&&(o.region=c);let l=D(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=D(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function k(e){let t=await c(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ae(e){Object.keys(e).length!==0&&(await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await S())}var A=r();function oe(e){let t=(0,ne.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>k(n).then(j),t[0]=n,t[1]=c);let l=c,u=`img-cred-key-${n}`,d;t[2]!==a.apiKeyLabel||t[3]!==u?(d=(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:u,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=u,t[4]=d):d=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,A.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[p(e.kind,s),(0,A.jsx)(f,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=t[7];let g=`img-cred-key-${n}`,_;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==g||t[12]!==r?(_=(0,A.jsx)(h,{id:g,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=g,t[12]=r,t[13]=_):_=t[13];let v;return t[14]!==d||t[15]!==m||t[16]!==_?(v=(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[d,m,_]}),t[14]=d,t[15]=m,t[16]=_,t[17]=v):v=t[17],v}function j(e){return e.apiKey??null}function M(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b)}function se(){return a(M(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var N=`__custom__`;function ce(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:N}function le(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:N}function ue(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function de(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function fe(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function pe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function me(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function P(e){let t=(0,ne.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:u,credNoopFlash:p,updateCredRow:h,onDiscardCredentials:v,onSaveCredentials:b,extensionIds:S,showExtensionLinks:C,showImageModelsLink:te,hideActions:re,language:E,apiKeyLinkLabels:D,messages:O}=e,ie=re===void 0?!1:re,k;t[0]===n?k=t[1]:(k=n.some(ye),t[0]=n,t[1]=k);let ae=k,j;t[2]===n?j=t[3]:(j=n.some(ve),t[2]=n,t[3]=j);let P=j,[F,be]=(0,w.useState)(_e),[I,L]=(0,w.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)pe(r[e.id]??T(),o[e.id]??T())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===O.credentialsIntro?W=t[15]:(W=(0,A.jsx)(`p`,{children:O.credentialsIntro}),t[14]=O.credentialsIntro,t[15]=W);let G;t[16]!==ae||t[17]!==O.regionHint?(G=ae?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.regionHint}):null,t[16]=ae,t[17]=O.regionHint,t[18]=G):G=t[18];let K;t[19]!==P||t[20]!==O.endpointPresetsHint?(K=P?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.endpointPresetsHint}):null,t[19]=P,t[20]=O.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==te||t[23]!==O.imageModelsLinkTitle||t[24]!==O.openImageModelsPage?(q=te?(0,A.jsx)(`p`,{children:(0,A.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:O.imageModelsLinkTitle,children:O.openImageModelsPage})}):null,t[22]=te,t[23]=O.imageModelsLinkTitle,t[24]=O.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,A.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===l?Y=t[32]:(Y=l?(0,A.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==p||t[35]!==u||t[36]!==c||t[37]!==ie||t[38]!==v||t[39]!==b||t[40]!==O.credentialsNothingToSave||t[41]!==O.credentialsSaved||t[42]!==O.discardCredentials||t[43]!==O.saveCredentials||t[44]!==O.savingCredentials?(X=ie?null:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[u?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsSaved}):null,p?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsNothingToSave}):null,(0,A.jsx)(y,{type:`button`,variant:`secondary`,onClick:v,disabled:!s||c,children:O.discardCredentials}),(0,A.jsx)(y,{type:`button`,variant:`primary`,onClick:b,disabled:!s||c,children:c?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ee,{className:`size-3.5 animate-spin`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.savingCredentials})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{className:`size-3.5`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.saveCredentials})]})})]}),t[33]=s,t[34]=p,t[35]=u,t[36]=c,t[37]=ie,t[38]=v,t[39]=b,t[40]=O.credentialsNothingToSave,t[41]=O.credentialsSaved,t[42]=O.discardCredentials,t[43]=O.saveCredentials,t[44]=O.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==D||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==E||t[52]!==C||t[53]!==n||t[54]!==O||t[55]!==U||t[56]!==h){let e;t[58]!==D||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==E||t[64]!==C||t[65]!==O||t[66]!==U||t[67]!==h?(e=e=>{let t=r[e.id]??T(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=pe(t,o[e.id]??T()),l=V(e.id),u=e.label??e.id,p=me(O,e.models.length);return(0,A.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:u}),(0,A.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.unsavedChanges}):null,e.configured?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.configured}):(0,A.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:O.missingKey})]}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,A.jsx)(`span`,{children:p}),e.defaultModel?(0,A.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,A.jsx)(g,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`sr-only`,children:l?O.collapseProvider:O.expandProvider})]}),l?(0,A.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 p-4`,children:[s?(0,A.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:O.extensionSettingsLinkTitle,children:[(0,A.jsx)(f,{className:`size-3`}),O.openExtensionSettings]}):null,e.models.length>0?(0,A.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,A.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,A.jsx)(oe,{providerId:e.id,value:t.apiKey,onChange:t=>h(e.id,{apiKey:t}),apiKeyLinks:m(e.id,E),apiKeyLinkLabels:D,labels:{apiKeyLabel:O.apiKeyLabel,optionalPlaceholder:O.optionalPlaceholder,maskedHelp:O.apiKeyMaskedHelp,copy:O.apiKeyCopy,copied:O.apiKeyCopied,show:O.apiKeyShow,hide:O.apiKeyHide,notInConfigFile:O.apiKeyNotInConfigFile,loadFailed:O.apiKeyRevealFailed}}),n?.regions?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:O.regionLabel}),(0,A.jsxs)(d,{id:`img-cred-region-preset-${e.id}`,className:se(),value:ce(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){h(e.id,{region:``,imageBaseUrl:``});return}if(r===N){h(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&h(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,A.jsx)(x,{value:``,children:O.regionPresetDefault}),n.regions.map(e=>(0,A.jsx)(x,{value:e.value,children:ue(O,e.value,e.label)},e.value)),(0,A.jsx)(x,{value:N,children:O.regionPresetCustom})]}),ce(t,n.regions)===N?(0,A.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,A.jsx)(`input`,{type:`text`,className:M(),value:t.region,placeholder:`region`,onChange:t=>h(e.id,{region:t.target.value})}),(0,A.jsx)(`input`,{type:`url`,className:M(),value:t.imageBaseUrl,placeholder:O.imageBaseUrlLabel,onChange:t=>h(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:de(O,n.baseUrlPresetKind)}),fe(O,n.baseUrlPresetKind)?(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:fe(O,n.baseUrlPresetKind)}):null,(0,A.jsxs)(d,{id:`img-cred-base-preset-${e.id}`,className:se(),value:le(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){h(e.id,{baseUrl:``});return}if(n===N){h(e.id,{baseUrl:``});return}h(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,A.jsx)(x,{value:``,children:O.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,A.jsx)(x,{value:N,children:O.baseUrlPresetCustom})]}),le(t,n.baseUrlPresets)===N?(0,A.jsx)(`input`,{type:`url`,className:a(M(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>h(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&ce(t,n.regions)!==N?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:O.imageBaseUrlLabel}),(0,A.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(M(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:O.imageBaseUrlPresetHint}),(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:O.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=D,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=E,t[64]=C,t[65]=O,t[66]=U,t[67]=h,t[68]=e):e=t[68],Z=n.map(e),t[46]=D,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=E,t[52]=C,t[53]=n,t[54]=O,t[55]=U,t[56]=h,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,A.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function he(e){return(0,A.jsx)(x,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=v(o(e=>!!e.token)),n=t.data,r=(0,w.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,w.useRef)(!1),[a,c]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(!1),[g,_]=(0,w.useState)(!1),y=(0,w.useMemo)(()=>E(n?.payload?.config,r),[n?.payload?.config,r]),b=a??y,x=y;return{gwSwr:t,credDraft:b,credBaseline:x,credDirty:(0,w.useMemo)(()=>JSON.stringify(b)!==JSON.stringify(x),[b,x]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,w.useCallback)((e,t)=>{i.current=!0,c(n=>{let r=n??y,i=r[e]??T();return{...r,[e]:{...i,...t}}})},[y]),onDiscardCredentials:(0,w.useCallback)(()=>{i.current=!1,c(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,w.useCallback)(async e=>{let n=ie(r,b,x);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ae(n),await t.mutate?.(),l(s(C)),i.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,b,x,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=be();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=I();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function K(){return G((await c(s(`/api/config`))).payload?.config??{})}async function q(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await c(s(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),S()}async function J(){let e=await c(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await c(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await c(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(){let e=await c(s(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(e){let t=await c(s(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Se(e){let t=await c(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function Ce(e){let t=(0,ne.c)(15),{kind:n,providerId:r,fieldId:i,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let g;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(g=(0,A.jsx)(h,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=g):g=t[11];let _;return t[12]!==m||t[13]!==g?(_=(0,A.jsx)(`div`,{className:m,children:g}),t[12]=m,t[13]=g,t[14]=_):_=t[14],_}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,te as m,Z as n,X as o,P as p,J as r,Q as s,Ce as t,$ as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./check-BODqo66o.js";import{t as o}from"./messages-BuT0SR1R.js";import{n as ee}from"./locale-store-C_M71MK9.js";import{At as s,Bl as te,Bt as c,Gt as l,Ht as u,Kt as d,Pt as ne,Ql as f,Sl as re,Ut as p,Vt as m,Wt as h,Ys as g,ao as _,eu as ie,hs as ae,ml as oe,ms as v,qt as y,vl as b,vs as x,zc as S,zt as C}from"./index-EXa_i6BT.js";var w=e(t(),1),T=n(),E=[`folder_structure`,`recent_progress`,`next_steps`];function D(e){return e instanceof Error?e.message:String(e)}function O(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,O=i(),[se]=r(),k=se.get(`new`)===`1`,[A,j]=(0,w.useState)(`loading`),[M,N]=(0,w.useState)(null),[P,F]=(0,w.useState)(null),[I,L]=(0,w.useState)(!1),[R,z]=(0,w.useState)(null),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(``),[W,G]=(0,w.useState)(!1),K=(0,w.useCallback)(e=>{F(e),e.status===`completed`?j(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?j(`error`):j(`running`)},[]),q=ne({onPicked:(0,w.useCallback)(async e=>{L(!0),z(null);try{N(await p(e)),j(`consent`)}catch(e){z(D(e)),j(`intro`)}finally{L(!1)}},[])});(0,w.useEffect)(()=>{let e=!1;return m().then(async({enabled:t,state:n})=>{if(!e){if(!t){O(`/chat`,{replace:!0});return}if(!k&&n.activeRunId)try{let t=await u(n.activeRunId);e||K(t);return}catch{}e||j(`intro`)}}).catch(t=>{e||(z(D(t)),j(`intro`))}),()=>{e=!0}},[K,O,k]),(0,w.useEffect)(()=>{if(!P||A!==`running`)return;let e=!1,t=async()=>{try{let t=await u(P.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===P.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[K,A,P]);let J=async()=>{L(!0);try{await c()}finally{O(`/chat`,{replace:!0})}},ce=async()=>{if(M){L(!0),z(null);try{K(await d(M.canonicalRootPath))}catch(e){z(D(e)),j(`consent`)}finally{L(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;O(`/chat/${encodeURIComponent(e)}${n}`)},X=async(t,n)=>{if(!P)return;await l(P.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(P.sessionKey,r)},le=async()=>{if(P){L(!0),z(null);try{F(await y(P.id,`confirmed`)),j(`recommendation`)}catch(e){z(D(e))}finally{L(!1)}}},Z=async e=>{if(!(!P||!H.trim())){L(!0),z(null);try{let t=await y(P.id,e,H.trim());F(t),Y(t.sessionKey,H.trim())}catch(e){z(D(e)),L(!1)}}},ue=async()=>{if(P){L(!0);try{Y((await y(P.id,`dismissed`)).sessionKey)}catch(e){z(D(e)),L(!1)}}},Q=P?.result?.suggestions.find(e=>e.id===P.result?.primarySuggestionId)??P?.result?.suggestions[0],$=P?.result?.suggestions.filter(e=>e.id!==Q?.id)??[];return(0,T.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,T.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,T.jsx)(ae,{className:`size-11`})}),A===`loading`?(0,T.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,T.jsx)(_,{className:`mx-auto h-8 w-64`}),(0,T.jsx)(_,{className:`mx-auto h-4 w-full max-w-lg`}),(0,T.jsx)(_,{className:`mx-auto size-4/5 max-w-md`}),(0,T.jsx)(_,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,A===`intro`?(0,T.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,T.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,T.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,T.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,T.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,T.jsxs)(v,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:q.pick,disabled:I||q.picking,children:[I||q.picking?(0,T.jsx)(S,{className:`size-4 animate-spin`}):(0,T.jsx)(b,{className:`size-4`}),t.chooseFolder]}),(0,T.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,T.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,T.jsx)(`span`,{children:t.readOnlyNote})]}),R?(0,T.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null]}),(0,T.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:I,children:t.skip})]}):null,A===`consent`&&M?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,T.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,T.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,T.jsx)(b,{className:`size-5 shrink-0 text-accent-fg`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:M.displayName}),(0,T.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:M.canonicalRootPath})]}),(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:M.projectKind===`coding`?t.codingProject:M.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,T.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:M.fingerprint.branch?t.branchValue.replace(`{{branch}}`,M.fingerprint.branch):t.noGitBranch})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(M.fingerprint.changedFileCount))})]}),M.fingerprint.recentAreas.length>0?(0,T.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,T.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:M.fingerprint.recentAreas.map(e=>(0,T.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,T.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,T.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,T.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,T.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,T.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,T.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,T.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,T.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,T.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:M.remoteModel?t.providerDisclosure.replace(`{{provider}}`,M.provider):t.localDisclosure})]})]})]}),R?(0,T.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,T.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,T.jsxs)(v,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void ce(),children:[I?(0,T.jsx)(S,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,T.jsx)(v,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:q.pick,children:t.changeFolder})]}),(0,T.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,A===`running`&&P?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,T.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle})]}),(0,T.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:E.map((e,n)=>{let r=Math.max(0,E.indexOf(P.stage??`folder_structure`)),i=n<r,o=n===r;return(0,T.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,T.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,T.jsx)(a,{className:`size-4`}):o?(0,T.jsx)(S,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,T.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,T.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,T.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:P.rootPath}),(0,T.jsx)(`button`,{type:`button`,className:`mx-auto mt-7 block text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void C(P.id).then(K),children:t.cancelAnalysis})]}):null,A===`recognition`&&P?.result?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,T.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:P.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),(0,T.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,T.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:P.result.projectSummary}),(0,T.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:P.result.currentState}),!P.result.lowConfidence&&Q?.evidence.length?(0,T.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,T.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,T.jsx)(oe,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,T.jsxs)(`span`,{children:[e.path?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),P.result.lowConfidence?(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:P.result.contextQuestion}),(0,T.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,T.jsx)(v,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,T.jsxs)(v,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void le(),children:[I?(0,T.jsx)(S,{className:`size-4 animate-spin`}):(0,T.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,T.jsx)(v,{variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:()=>V(e=>!e),children:t.notQuiteRight})]}),B?(0,T.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,T.jsx)(`textarea`,{id:`work-discovery-correction`,value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,T.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,T.jsx)(v,{variant:`ghost`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,T.jsx)(v,{variant:`primary`,disabled:I||!H.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),R?(0,T.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,T.jsx)(`button`,{type:`button`,disabled:I,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void ue(),children:t.openConversation})]}):null,A===`recommendation`&&P?.result&&Q?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,T.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),(0,T.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,T.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,T.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,T.jsx)(f,{className:`size-5`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,T.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,T.jsx)(te,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:(e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis)(Q.risk)})]}),(0,T.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,T.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,T.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,T.jsx)(v,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,T.jsx)(v,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),$.length>0?(0,T.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>G(e=>!e),children:[t.otherDirections,(0,T.jsx)(ie,{className:`size-4 transition-transform ${W?`rotate-180`:``}`})]}),W?(0,T.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:$.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,T.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,T.jsxs)(`span`,{children:[(0,T.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,T.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,T.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,T.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.doSomethingElse}),(0,T.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{V(!0),j(`recognition`)},children:t.correctUnderstanding})]})]}):null,A===`error`&&P?(0,T.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,T.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,T.jsx)(x,{className:`size-5`})}),(0,T.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,T.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:P.errorMessage}),(0,T.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,T.jsx)(v,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void h(P.id).then(K),children:t.retry}),(0,T.jsx)(v,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{F(null),N(null),j(`intro`)},children:t.chooseDifferent})]}),(0,T.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,T.jsx)(s,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:M?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{O as WorkDiscoveryPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./check-BODqo66o.js";import{t as o}from"./messages-BuT0SR1R.js";import{n as ee}from"./locale-store-C_M71MK9.js";import{At as s,Bl as te,Bt as c,Gt as l,Ht as u,Kt as d,Pt as ne,Ql as f,Sl as re,Ut as p,Vt as m,Wt as h,Ys as g,ao as _,eu as ie,hs as ae,ml as oe,ms as v,qt as y,vl as b,vs as x,zc as S,zt as C}from"./index-BuqGh2SW.js";var w=e(t(),1),T=n(),E=[`folder_structure`,`recent_progress`,`next_steps`];function D(e){return e instanceof Error?e.message:String(e)}function O(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,O=i(),[se]=r(),k=se.get(`new`)===`1`,[A,j]=(0,w.useState)(`loading`),[M,N]=(0,w.useState)(null),[P,F]=(0,w.useState)(null),[I,L]=(0,w.useState)(!1),[R,z]=(0,w.useState)(null),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(``),[W,G]=(0,w.useState)(!1),K=(0,w.useCallback)(e=>{F(e),e.status===`completed`?j(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?j(`error`):j(`running`)},[]),q=ne({onPicked:(0,w.useCallback)(async e=>{L(!0),z(null);try{N(await p(e)),j(`consent`)}catch(e){z(D(e)),j(`intro`)}finally{L(!1)}},[])});(0,w.useEffect)(()=>{let e=!1;return m().then(async({enabled:t,state:n})=>{if(!e){if(!t){O(`/chat`,{replace:!0});return}if(!k&&n.activeRunId)try{let t=await u(n.activeRunId);e||K(t);return}catch{}e||j(`intro`)}}).catch(t=>{e||(z(D(t)),j(`intro`))}),()=>{e=!0}},[K,O,k]),(0,w.useEffect)(()=>{if(!P||A!==`running`)return;let e=!1,t=async()=>{try{let t=await u(P.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===P.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[K,A,P]);let J=async()=>{L(!0);try{await c()}finally{O(`/chat`,{replace:!0})}},ce=async()=>{if(M){L(!0),z(null);try{K(await d(M.canonicalRootPath))}catch(e){z(D(e)),j(`consent`)}finally{L(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;O(`/chat/${encodeURIComponent(e)}${n}`)},X=async(t,n)=>{if(!P)return;await l(P.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(P.sessionKey,r)},le=async()=>{if(P){L(!0),z(null);try{F(await y(P.id,`confirmed`)),j(`recommendation`)}catch(e){z(D(e))}finally{L(!1)}}},Z=async e=>{if(!(!P||!H.trim())){L(!0),z(null);try{let t=await y(P.id,e,H.trim());F(t),Y(t.sessionKey,H.trim())}catch(e){z(D(e)),L(!1)}}},ue=async()=>{if(P){L(!0);try{Y((await y(P.id,`dismissed`)).sessionKey)}catch(e){z(D(e)),L(!1)}}},Q=P?.result?.suggestions.find(e=>e.id===P.result?.primarySuggestionId)??P?.result?.suggestions[0],$=P?.result?.suggestions.filter(e=>e.id!==Q?.id)??[];return(0,T.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,T.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,T.jsx)(ae,{className:`size-11`})}),A===`loading`?(0,T.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,T.jsx)(_,{className:`mx-auto h-8 w-64`}),(0,T.jsx)(_,{className:`mx-auto h-4 w-full max-w-lg`}),(0,T.jsx)(_,{className:`mx-auto size-4/5 max-w-md`}),(0,T.jsx)(_,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,A===`intro`?(0,T.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,T.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,T.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,T.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,T.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,T.jsxs)(v,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:q.pick,disabled:I||q.picking,children:[I||q.picking?(0,T.jsx)(S,{className:`size-4 animate-spin`}):(0,T.jsx)(b,{className:`size-4`}),t.chooseFolder]}),(0,T.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,T.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,T.jsx)(`span`,{children:t.readOnlyNote})]}),R?(0,T.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null]}),(0,T.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:I,children:t.skip})]}):null,A===`consent`&&M?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,T.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,T.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,T.jsx)(b,{className:`size-5 shrink-0 text-accent-fg`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:M.displayName}),(0,T.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:M.canonicalRootPath})]}),(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:M.projectKind===`coding`?t.codingProject:M.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,T.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:M.fingerprint.branch?t.branchValue.replace(`{{branch}}`,M.fingerprint.branch):t.noGitBranch})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(M.fingerprint.changedFileCount))})]}),M.fingerprint.recentAreas.length>0?(0,T.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,T.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:M.fingerprint.recentAreas.map(e=>(0,T.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,T.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,T.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,T.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,T.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,T.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,T.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,T.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,T.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,T.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:M.remoteModel?t.providerDisclosure.replace(`{{provider}}`,M.provider):t.localDisclosure})]})]})]}),R?(0,T.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,T.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,T.jsxs)(v,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void ce(),children:[I?(0,T.jsx)(S,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,T.jsx)(v,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:q.pick,children:t.changeFolder})]}),(0,T.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,A===`running`&&P?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,T.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle})]}),(0,T.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:E.map((e,n)=>{let r=Math.max(0,E.indexOf(P.stage??`folder_structure`)),i=n<r,o=n===r;return(0,T.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,T.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,T.jsx)(a,{className:`size-4`}):o?(0,T.jsx)(S,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,T.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,T.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,T.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:P.rootPath}),(0,T.jsx)(`button`,{type:`button`,className:`mx-auto mt-7 block text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void C(P.id).then(K),children:t.cancelAnalysis})]}):null,A===`recognition`&&P?.result?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,T.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:P.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),(0,T.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,T.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:P.result.projectSummary}),(0,T.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:P.result.currentState}),!P.result.lowConfidence&&Q?.evidence.length?(0,T.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,T.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,T.jsx)(oe,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,T.jsxs)(`span`,{children:[e.path?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),P.result.lowConfidence?(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:P.result.contextQuestion}),(0,T.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,T.jsx)(v,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,T.jsxs)(v,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void le(),children:[I?(0,T.jsx)(S,{className:`size-4 animate-spin`}):(0,T.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,T.jsx)(v,{variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:()=>V(e=>!e),children:t.notQuiteRight})]}),B?(0,T.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,T.jsx)(`textarea`,{id:`work-discovery-correction`,value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,T.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,T.jsx)(v,{variant:`ghost`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,T.jsx)(v,{variant:`primary`,disabled:I||!H.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),R?(0,T.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,T.jsx)(`button`,{type:`button`,disabled:I,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void ue(),children:t.openConversation})]}):null,A===`recommendation`&&P?.result&&Q?(0,T.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,T.jsxs)(`div`,{className:`text-center`,children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,T.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),(0,T.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,T.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,T.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,T.jsx)(f,{className:`size-5`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,T.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,T.jsx)(te,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:(e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis)(Q.risk)})]}),(0,T.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,T.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,T.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,T.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,T.jsx)(v,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,T.jsx)(v,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),$.length>0?(0,T.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>G(e=>!e),children:[t.otherDirections,(0,T.jsx)(ie,{className:`size-4 transition-transform ${W?`rotate-180`:``}`})]}),W?(0,T.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:$.map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,T.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,T.jsxs)(`span`,{children:[(0,T.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,T.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,T.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,T.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.doSomethingElse}),(0,T.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{V(!0),j(`recognition`)},children:t.correctUnderstanding})]})]}):null,A===`error`&&P?(0,T.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,T.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,T.jsx)(x,{className:`size-5`})}),(0,T.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,T.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:P.errorMessage}),(0,T.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,T.jsx)(v,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void h(P.id).then(K),children:t.retry}),(0,T.jsx)(v,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{F(null),N(null),j(`intro`)},children:t.chooseDifferent})]}),(0,T.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,T.jsx)(s,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:M?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{O as WorkDiscoveryPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as s}from"./cn-BQ_8x0bT.js";import{t as c}from"./messages-BuT0SR1R.js";import{n as ee}from"./locale-store-C_M71MK9.js";import{Fs as l,Go as te,Io as u,La as ne,Ol as re,Pc as d,Sl as f,Xl as ie,a as ae,cc as oe,et as p,f as se,hc as ce,hu as m,jl as h,js as le,l as g,m as ue,ml as de,ms as _,o as fe,p as pe,qo as v,ru as y,s as me,sc as he,u as b,wc as x,yt as S}from"./index-EXa_i6BT.js";var C=n(),w=e(t(),1),T=r();function ge(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function E(e){return e?p(new Date(e)):``}function _e(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function ve(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,T.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=O(i),s=0;for(let e of O(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=o(),t=i(),n=c(ee(e=>e.language)).projectDetailPage.workItems,[r,p]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=u(e=>e.setPageHeader),K=u(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([g(e),b(e).catch(()=>({events:[]}))]);p(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([ne(t.item.projectId).catch(()=>null),S().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await se(r.id);p(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await ae(r.id);p(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{M((await b(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await pe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});p(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await ue(r.id,e);p(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await fe(r.id,e.id);p(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await me(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(G({startExtra:(0,T.jsx)(a,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(y,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(y,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(de,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(te,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(v,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(v,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,T.jsxs)(_,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(x,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base p-2 text-sm`,children:[(0,T.jsx)(f,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(e.size)]})]}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,T.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,T.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(a,{to:ve(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.jsxs)(a,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(ie,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as s}from"./cn-BQ_8x0bT.js";import{t as c}from"./messages-BuT0SR1R.js";import{n as ee}from"./locale-store-C_M71MK9.js";import{Fs as l,Go as te,Io as u,La as ne,Ol as re,Pc as d,Sl as f,Xl as ie,a as ae,cc as oe,et as p,f as se,hc as ce,hu as m,jl as h,js as le,l as g,m as ue,ml as de,ms as _,o as fe,p as pe,qo as v,ru as y,s as me,sc as he,u as b,wc as x,yt as S}from"./index-BuqGh2SW.js";var C=n(),w=e(t(),1),T=r();function ge(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function E(e){return e?p(new Date(e)):``}function _e(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function ve(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,T.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=O(i),s=0;for(let e of O(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=o(),t=i(),n=c(ee(e=>e.language)).projectDetailPage.workItems,[r,p]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=u(e=>e.setPageHeader),K=u(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([g(e),b(e).catch(()=>({events:[]}))]);p(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([ne(t.item.projectId).catch(()=>null),S().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await se(r.id);p(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await ae(r.id);p(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{M((await b(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await pe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});p(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await ue(r.id,e);p(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await fe(r.id,e.id);p(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await me(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(G({startExtra:(0,T.jsx)(a,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(y,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(y,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(de,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(te,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(v,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(v,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,T.jsxs)(_,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(x,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base p-2 text-sm`,children:[(0,T.jsx)(f,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(e.size)]})]}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,T.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,T.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(a,{to:ve(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.jsxs)(a,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(ie,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};