@xopcai/xopc 0.0.66 → 0.0.67

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 (78) hide show
  1. package/dist/extensions/telegram/xopc.extension.json +1 -1
  2. package/dist/gateway/static/root/assets/{agents-JiJR38n1.js → agents-CmhOU0fB.js} +2 -2
  3. package/dist/gateway/static/root/assets/{agents-JiJR38n1.js.map → agents-CmhOU0fB.js.map} +1 -1
  4. package/dist/gateway/static/root/assets/{apps-page-aBDyr7Im.js → apps-page-CzS9A_6L.js} +2 -2
  5. package/dist/gateway/static/root/assets/{apps-page-aBDyr7Im.js.map → apps-page-CzS9A_6L.js.map} +1 -1
  6. package/dist/gateway/static/root/assets/{channels-settings-DXxfgG4N.js → channels-settings-Bn0YSztA.js} +2 -2
  7. package/dist/gateway/static/root/assets/{channels-settings-DXxfgG4N.js.map → channels-settings-Bn0YSztA.js.map} +1 -1
  8. package/dist/gateway/static/root/assets/{cron-dreaming-jobs-3--QJSP5.js → cron-dreaming-jobs-bAYsiHdF.js} +2 -2
  9. package/dist/gateway/static/root/assets/{cron-dreaming-jobs-3--QJSP5.js.map → cron-dreaming-jobs-bAYsiHdF.js.map} +1 -1
  10. package/dist/gateway/static/root/assets/{cron-page-CCn-JwBy.js → cron-page-CKqDtScu.js} +2 -2
  11. package/dist/gateway/static/root/assets/{cron-page-CCn-JwBy.js.map → cron-page-CKqDtScu.js.map} +1 -1
  12. package/dist/gateway/static/root/assets/{dist-BS-cwfHQ.js → dist-CUMhnSuX.js} +2 -2
  13. package/dist/gateway/static/root/assets/{dist-BS-cwfHQ.js.map → dist-CUMhnSuX.js.map} +1 -1
  14. package/dist/gateway/static/root/assets/{extension-debug-page-M8JS4Jid.js → extension-debug-page-BDls5xp3.js} +2 -2
  15. package/dist/gateway/static/root/assets/{extension-debug-page-M8JS4Jid.js.map → extension-debug-page-BDls5xp3.js.map} +1 -1
  16. package/dist/gateway/static/root/assets/{extension-page-C8gjVE_t.js → extension-page-BSfv53OO.js} +2 -2
  17. package/dist/gateway/static/root/assets/{extension-page-C8gjVE_t.js.map → extension-page-BSfv53OO.js.map} +1 -1
  18. package/dist/gateway/static/root/assets/{extension-settings-page-DeY2M2di.js → extension-settings-page-B0nkVsLi.js} +2 -2
  19. package/dist/gateway/static/root/assets/{extension-settings-page-DeY2M2di.js.map → extension-settings-page-B0nkVsLi.js.map} +1 -1
  20. package/dist/gateway/static/root/assets/{heartbeat-config-api-DWmeyjyR.js → heartbeat-config-api-P5zdbIBw.js} +2 -2
  21. package/dist/gateway/static/root/assets/{heartbeat-config-api-DWmeyjyR.js.map → heartbeat-config-api-P5zdbIBw.js.map} +1 -1
  22. package/dist/gateway/static/root/assets/{index-Cc57jhuG.js → index-DAglRwh4.js} +5 -5
  23. package/dist/gateway/static/root/assets/{index-Cc57jhuG.js.map → index-DAglRwh4.js.map} +1 -1
  24. package/dist/gateway/static/root/assets/index-DHj3Cf9B.css +1 -0
  25. package/dist/gateway/static/root/assets/{logs-page-kIsSDMqb.js → logs-page-CfGDv4k7.js} +2 -2
  26. package/dist/gateway/static/root/assets/{logs-page-kIsSDMqb.js.map → logs-page-CfGDv4k7.js.map} +1 -1
  27. package/dist/gateway/static/root/assets/{sessions-page-Da9gjMh7.js → sessions-page-DoGE8N-O.js} +2 -2
  28. package/dist/gateway/static/root/assets/{sessions-page-Da9gjMh7.js.map → sessions-page-DoGE8N-O.js.map} +1 -1
  29. package/dist/gateway/static/root/assets/settings-page-C5VrwDoO.js +3 -0
  30. package/dist/gateway/static/root/assets/settings-page-C5VrwDoO.js.map +1 -0
  31. package/dist/gateway/static/root/assets/{skills-page-B_msZcLx.js → skills-page-ADUi69Fa.js} +2 -2
  32. package/dist/gateway/static/root/assets/{skills-page-B_msZcLx.js.map → skills-page-ADUi69Fa.js.map} +1 -1
  33. package/dist/gateway/static/root/assets/{use-image-provider-credentials-Bs8xl2E3.js → use-image-provider-credentials-C4x4dNv2.js} +2 -2
  34. package/dist/gateway/static/root/assets/{use-image-provider-credentials-Bs8xl2E3.js.map → use-image-provider-credentials-C4x4dNv2.js.map} +1 -1
  35. package/dist/gateway/static/root/index.html +2 -2
  36. package/dist/package.js +1 -1
  37. package/dist/src/cli/commands/tunnel.js +69 -8
  38. package/dist/src/cli/commands/tunnel.js.map +1 -1
  39. package/dist/src/config/schema.d.ts +2 -0
  40. package/dist/src/config/schema.js +2 -0
  41. package/dist/src/config/schema.js.map +1 -1
  42. package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -5
  43. package/dist/src/gateway/hono/lib/config-payload.js +3 -5
  44. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  45. package/dist/src/gateway/hono/routes/tunnel.js +12 -10
  46. package/dist/src/gateway/hono/routes/tunnel.js.map +1 -1
  47. package/dist/src/tunnel/acme-client.d.ts +11 -0
  48. package/dist/src/tunnel/acme-client.js +54 -10
  49. package/dist/src/tunnel/acme-client.js.map +1 -1
  50. package/dist/src/tunnel/env.d.ts +14 -3
  51. package/dist/src/tunnel/env.js +34 -5
  52. package/dist/src/tunnel/env.js.map +1 -1
  53. package/dist/src/tunnel/frpc-binary.d.ts +6 -1
  54. package/dist/src/tunnel/frpc-binary.js +66 -40
  55. package/dist/src/tunnel/frpc-binary.js.map +1 -1
  56. package/dist/src/tunnel/frpc-extract.d.ts +10 -0
  57. package/dist/src/tunnel/frpc-extract.js +129 -0
  58. package/dist/src/tunnel/frpc-extract.js.map +1 -0
  59. package/dist/src/tunnel/gateway-lifecycle.d.ts +3 -1
  60. package/dist/src/tunnel/gateway-lifecycle.js +6 -4
  61. package/dist/src/tunnel/gateway-lifecycle.js.map +1 -1
  62. package/dist/src/tunnel/index.d.ts +3 -1
  63. package/dist/src/tunnel/index.js +2 -2
  64. package/dist/src/tunnel/tls-server.js +5 -0
  65. package/dist/src/tunnel/tls-server.js.map +1 -1
  66. package/dist/src/tunnel/tunnel-config.js +11 -1
  67. package/dist/src/tunnel/tunnel-config.js.map +1 -1
  68. package/dist/src/tunnel/tunnel-e2e-config.d.ts +4 -1
  69. package/dist/src/tunnel/tunnel-e2e-config.js +10 -3
  70. package/dist/src/tunnel/tunnel-e2e-config.js.map +1 -1
  71. package/dist/src/tunnel/tunnel-service.d.ts +4 -0
  72. package/dist/src/tunnel/tunnel-service.js +66 -5
  73. package/dist/src/tunnel/tunnel-service.js.map +1 -1
  74. package/dist/src/tunnel/tunnel-types.d.ts +16 -0
  75. package/package.json +3 -3
  76. package/dist/gateway/static/root/assets/index-B5gp15_q.css +0 -1
  77. package/dist/gateway/static/root/assets/settings-page-B0spIRVS.js +0 -3
  78. package/dist/gateway/static/root/assets/settings-page-B0spIRVS.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{a as t,n,t as r}from"./vendor-react-vzx_MT5D.js";import{i}from"./vendor-swr-CQnUjdeQ.js";import{At as a,Bn as o,Bt as s,E as c,En as l,Hn as u,Ht as d,Ir as f,Ln as p,Mr as m,Mt as h,Nn as g,Nt as _,Oi as v,On as y,Rt as b,Ut as x,Vn as S,Vt as C,Wt as w,Yn as T,_r as E,ci as D,ki as O,kn as k,l as A,li as ee,mi as j,qn as M,rr as N,s as P,si as te,u as F,ui as ne,xn as I,zn as L,zt as R}from"./index-Cc57jhuG.js";import{a as re,i as ie,n as ae,r as z,t as oe}from"./dist-BS-cwfHQ.js";import{t as B}from"./browser-DNXWYwzc.js";var se=n(),V=r();function H(e){let t=(0,se.c)(35),{icon:n,title:r,subtitle:i,configured:a,enabled:o,onToggle:s,toggleDisabled:c,onConfigure:l,onEdit:d,onRemove:f,ch:p}=e,h;t[0]===n?h=t[1]:(h=(0,V.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=h);let g;t[2]===r?g=t[3]:(g=(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=g);let _;t[4]!==p.hubConnectedBadge||t[5]!==a?(_=a?(0,V.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:p.hubConnectedBadge}):null,t[4]=p.hubConnectedBadge,t[5]=a,t[6]=_):_=t[6];let v;t[7]!==g||t[8]!==_?(v=(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[g,_]}),t[7]=g,t[8]=_,t[9]=v):v=t[9];let y;t[10]===i?y=t[11]:(y=(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i}),t[10]=i,t[11]=y);let b;t[12]!==v||t[13]!==y?(b=(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,y]}),t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;t[15]!==h||t[16]!==b?(x=(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[h,b]}),t[15]=h,t[16]=b,t[17]=x):x=t[17];let S;t[18]!==p.enableChannelAria||t[19]!==p.hubConfigureButton||t[20]!==p.menuEditConfig||t[21]!==p.menuMoreAria||t[22]!==p.menuRemoveConfig||t[23]!==a||t[24]!==o||t[25]!==l||t[26]!==d||t[27]!==f||t[28]!==s||t[29]!==r||t[30]!==c?(S=a?(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,V.jsxs)(ie,{children:[(0,V.jsx)(re,{asChild:!0,children:(0,V.jsx)(u,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.menuMoreAria,children:(0,V.jsx)(ne,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,V.jsx)(z,{children:(0,V.jsxs)(oe,{className:M(`min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,F),sideOffset:6,align:`end`,children:[(0,V.jsx)(ae,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>d(),children:(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(m,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),p.menuEditConfig]})}),(0,V.jsx)(ae,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>f(),children:(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(N,{className:`size-4 shrink-0`,strokeWidth:1.75}),p.menuRemoveConfig]})})]})})]}),(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":o,"aria-label":`${r} — ${p.enableChannelAria}`,disabled:c,className:M(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,o?`justify-end bg-accent`:`justify-start bg-surface-hover`,c&&`cursor-not-allowed opacity-50`),onClick:()=>void s(!o),children:(0,V.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,V.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,V.jsx)(u,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:l,children:p.hubConfigureButton})}),t[18]=p.enableChannelAria,t[19]=p.hubConfigureButton,t[20]=p.menuEditConfig,t[21]=p.menuMoreAria,t[22]=p.menuRemoveConfig,t[23]=a,t[24]=o,t[25]=l,t[26]=d,t[27]=f,t[28]=s,t[29]=r,t[30]=c,t[31]=S):S=t[31];let C;return t[32]!==x||t[33]!==S?(C=(0,V.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-2xl border border-edge bg-surface-base p-4 dark:border-edge sm:flex-row sm:items-center sm:gap-4`,children:[x,S]}),t[32]=x,t[33]=S,t[34]=C):C=t[34],C}function U(e){let t=(0,se.c)(30),{open:n,onOpenChange:r,ch:i,removeTarget:a,onCancel:o,saving:c,onConfirmRemove:l}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=M(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,P,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[1]=p):p=t[1];let m;t[2]===i.removeChannelTitle?m=t[3]:(m=(0,V.jsx)(w,{className:`text-base font-semibold text-fg`,children:i.removeChannelTitle}),t[2]=i.removeChannelTitle,t[3]=m);let h;t[4]!==i.feishuTitle||t[5]!==i.removeChannelConfirm||t[6]!==i.telegramTitle||t[7]!==i.weixinTitle||t[8]!==a?(h=a?i.removeChannelConfirm.replace(`{{name}}`,a===`weixin`?i.weixinTitle:a===`telegram`?i.telegramTitle:i.feishuTitle):`\xA0`,t[4]=i.feishuTitle,t[5]=i.removeChannelConfirm,t[6]=i.telegramTitle,t[7]=i.weixinTitle,t[8]=a,t[9]=h):h=t[9];let g;t[10]===h?g=t[11]:(g=(0,V.jsx)(s,{className:`mt-2 text-sm text-fg-muted`,children:h}),t[10]=h,t[11]=g);let _;t[12]!==i.modalCancel||t[13]!==o?(_=(0,V.jsx)(u,{type:`button`,variant:`secondary`,onClick:o,children:i.modalCancel}),t[12]=i.modalCancel,t[13]=o,t[14]=_):_=t[14];let v=c?i.saving:i.removeChannelAction,y;t[15]!==l||t[16]!==c||t[17]!==v?(y=(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:c,onClick:l,children:v}),t[15]=l,t[16]=c,t[17]=v,t[18]=y):y=t[18];let b;t[19]!==_||t[20]!==y?(b=(0,V.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[_,y]}),t[19]=_,t[20]=y,t[21]=b):b=t[21];let S;t[22]!==m||t[23]!==g||t[24]!==b?(S=(0,V.jsxs)(d,{children:[f,(0,V.jsxs)(R,{className:p,onOpenAutoFocus:ce,children:[m,g,b]})]}),t[22]=m,t[23]=g,t[24]=b,t[25]=S):S=t[25];let T;return t[26]!==r||t[27]!==n||t[28]!==S?(T=(0,V.jsx)(x,{open:n,onOpenChange:r,children:S}),t[26]=r,t[27]=n,t[28]=S,t[29]=T):T=t[29],T}function ce(e){return e.preventDefault()}function W(e){return(e??``).trim().toLowerCase()}function G(e){let t=e.match;return!(!t?.channel||!t.accountId||t.peerId||t.peerKind||t.guildId||t.teamId||t.memberRoleIds&&t.memberRoleIds.length>0)}function K(e){return Object.keys(e.accounts??{}).sort()}function le(e){return Object.keys(e.accounts??{}).sort()}function q(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.appId==`string`&&e.appId.trim()&&typeof e.appSecret==`string`&&e.appSecret.trim()?[`default`]:[]}function J(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>W(e.match?.channel)===`telegram`&&W(e.match?.accountId)===W(n)&&G(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>W(e.match?.channel)===`weixin`&&W(e.match?.accountId)===W(t)&&G(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>W(e.match?.channel)===`feishu`&&W(e.match?.accountId)===W(t)&&G(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function Y(e,t,n,r,i,a){let o=new Set(n.map(W)),s=new Set(r.map(W)),c=new Set(i.map(W)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!G(e))return!0;let t=W(e.match.channel),n=W(e.match.accountId);return!n||n===`*`?!0:!(t===`telegram`&&o.has(n)||t===`weixin`&&s.has(n)||t===`feishu`&&c.has(n))}),u=[];for(let e of n){let n=(t.telegram[e]??t.telegram[W(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:telegram:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`telegram`,accountId:e}})}for(let e of r){let n=(t.weixin[e]??t.weixin[W(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:weixin:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`weixin`,accountId:e}})}for(let e of i){let n=(t.feishu[e]??t.feishu[W(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:feishu:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`feishu`,accountId:e}})}return[...l,...u]}function X(){return M(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,o,`dark:border-edge`)}function Z(){return M(L,p)}function ue(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function de(e){return e.map(String).join(`, `)}function fe(e){let t=e.accounts?.default?.botToken;return typeof t==`string`?t:``}function pe(e){return Object.values(e.accounts??{}).some(e=>typeof e.botToken==`string`&&e.botToken.trim().length>0)}function me(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function he(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}function Q(e){let t=(0,se.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function ge(e){let t=(0,se.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:n}),t[0]=n,t[1]=r),r}function _e(e){let t=(0,se.c)(14),{label:n,value:r,onChange:i,options:a}=e,o;t[0]===n?o=t[1]:(o=(0,V.jsx)(Q,{children:n}),t[0]=n,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=Z(),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=e=>i(e.target.value),t[3]=i,t[4]=c);let l;t[5]===a?l=t[6]:(l=a.map(ve),t[5]=a,t[6]=l);let u;t[7]!==c||t[8]!==l||t[9]!==r?(u=(0,V.jsx)(`select`,{className:s,value:r,onChange:c,children:l}),t[7]=c,t[8]=l,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==o||t[12]!==u?(d=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[o,u]}),t[11]=o,t[12]=u,t[13]=d):d=t[13],d}function ve(e){return(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value)}function ye(e){let t=(0,se.c)(27),{accountIds:n,routes:r,defaultAgentId:i,agentItems:a,disabled:o,onChange:s,ch:l}=e,u=g(be),d,f,m,h,_;if(t[0]!==n||t[1]!==a||t[2]!==l||t[3]!==i||t[4]!==o||t[5]!==u||t[6]!==s||t[7]!==r){_=Symbol.for(`react.early_return_sentinel`);bb0:{let e=S(u).agentsSettings;if(n.length===0){_=null;break bb0}let g=a.length>0?a:[{id:i}];m=`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`;let v;t[13]===l.agentRoutingTitle?v=t[14]:(v=(0,V.jsx)(Q,{children:l.agentRoutingTitle}),t[13]=l.agentRoutingTitle,t[14]=v);let y;t[15]===l.agentRoutingHint?y=t[16]:(y=(0,V.jsx)(ge,{children:l.agentRoutingHint}),t[15]=l.agentRoutingHint,t[16]=y),t[17]!==v||t[18]!==y?(h=(0,V.jsxs)(`div`,{children:[v,y]}),t[17]=v,t[18]=y,t[19]=h):h=t[19],d=`space-y-2`,f=n.map(t=>(0,V.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.agentRoutingAccountLabel}),(0,V.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:t,children:t})]}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${t}`,children:l.agentRoutingAgentLabel}),(0,V.jsx)(`select`,{id:`agent-route-${t}`,className:M(X(),p),disabled:o,value:(r[t]??i).toLowerCase(),onChange:e=>s(t,e.target.value),children:g.map(t=>(0,V.jsx)(`option`,{value:t.id,children:`${c(t,e)} (${t.id})`},t.id))})]})]},t))}t[0]=n,t[1]=a,t[2]=l,t[3]=i,t[4]=o,t[5]=u,t[6]=s,t[7]=r,t[8]=d,t[9]=f,t[10]=m,t[11]=h,t[12]=_}else d=t[8],f=t[9],m=t[10],h=t[11],_=t[12];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let v;t[20]!==d||t[21]!==f?(v=(0,V.jsx)(`div`,{className:d,children:f}),t[20]=d,t[21]=f,t[22]=v):v=t[22];let y;return t[23]!==m||t[24]!==h||t[25]!==v?(y=(0,V.jsxs)(`div`,{className:m,children:[h,v]}),t[23]=m,t[24]=h,t[25]=v,t[26]=y):y=t[26],y}function be(e){return e.language}function xe(e){let t=(0,se.c)(377),{ch:n,form:r,baseline:i,showFeishuSecret:a,setShowFeishuSecret:o,showFeishuWebhookSecrets:s,setShowFeishuWebhookSecrets:c,feishuCopied:l,feishuWebhookCopied:d,copyFeishuSecret:f,copyFeishuWebhookConfig:p,updateFeishu:m,updateChannelAgentRoute:h,feishuAccountsDraft:g,setFeishuAccountsDraft:_,feishuAccountsError:y,onFeishuAccountsBlur:b,dmOpts:x,groupOpts:S,chatAgents:C,saving:w,dirty:T,save:E,discard:k}=e,A=r.feishu,ee=i?.feishu?.appSecret??``,N;t[0]!==ee||t[1]!==A.appSecret||t[2]!==a?(N=!a&&!!String(ee).trim()&&A.appSecret===ee,t[0]=ee,t[1]=A.appSecret,t[2]=a,t[3]=N):N=t[3];let P=N,F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,V.jsx)(v,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[4]=F):F=t[4];let ne;t[5]===n.advancedShow?ne=t[6]:(ne=(0,V.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[F,n.advancedShow]})}),t[5]=n.advancedShow,t[6]=ne);let I;t[7]===n.feishuAdvancedHint?I=t[8]:(I=(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.feishuAdvancedHint}),t[7]=n.feishuAdvancedHint,t[8]=I);let L;t[9]===m?L=t[10]:(L=e=>m({enabled:e.target.checked}),t[9]=m,t[10]=L);let R;t[11]!==A.enabled||t[12]!==L?(R=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:A.enabled,onChange:L}),t[11]=A.enabled,t[12]=L,t[13]=R):R=t[13];let re;t[14]===n.enableFeishuAria?re=t[15]:(re=(0,V.jsx)(`span`,{children:n.enableFeishuAria}),t[14]=n.enableFeishuAria,t[15]=re);let ie;t[16]!==R||t[17]!==re?(ie=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[R,re]}),t[16]=R,t[17]=re,t[18]=ie):ie=t[18];let ae;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,V.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[19]=ae):ae=t[19];let z;t[20]===n.feishuAppId?z=t[21]:(z=(0,V.jsxs)(Q,{children:[n.feishuAppId,ae]}),t[20]=n.feishuAppId,t[21]=z);let oe;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(oe=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[22]=oe):oe=t[22];let B;t[23]===m?B=t[24]:(B=e=>m({appId:e.target.value}),t[23]=m,t[24]=B);let H;t[25]!==A.appId||t[26]!==B?(H=(0,V.jsx)(`input`,{className:oe,value:A.appId,onChange:B,placeholder:`cli_xxx`}),t[25]=A.appId,t[26]=B,t[27]=H):H=t[27];let U;t[28]===n.feishuAppIdDesc?U=t[29]:(U=(0,V.jsx)(ge,{children:n.feishuAppIdDesc}),t[28]=n.feishuAppIdDesc,t[29]=U);let ce;t[30]!==z||t[31]!==H||t[32]!==U?(ce=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[z,H,U]}),t[30]=z,t[31]=H,t[32]=U,t[33]=ce):ce=t[33];let W;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,V.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=W):W=t[34];let G;t[35]===n.feishuAppSecret?G=t[36]:(G=(0,V.jsxs)(Q,{children:[n.feishuAppSecret,W]}),t[35]=n.feishuAppSecret,t[36]=G);let K;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(K=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[37]=K):K=t[37];let le=a?`text`:`password`,J;t[38]!==P||t[39]!==A.appSecret?(J=P?`*`.repeat(Math.max(1,A.appSecret.length)):A.appSecret,t[38]=P,t[39]=A.appSecret,t[40]=J):J=t[40];let Y;t[41]!==P||t[42]!==m?(Y=e=>{P||m({appSecret:e.target.value})},t[41]=P,t[42]=m,t[43]=Y):Y=t[43];let Z;t[44]!==P||t[45]!==le||t[46]!==J||t[47]!==Y?(Z=(0,V.jsx)(`input`,{className:K,type:le,autoComplete:`off`,readOnly:P,value:J,onChange:Y,placeholder:`••••••••`}),t[44]=P,t[45]=le,t[46]=J,t[47]=Y,t[48]=Z):Z=t[48];let fe;t[49]!==n.copied||t[50]!==n.copy||t[51]!==f||t[52]!==l||t[53]!==A.appSecret?(fe=A.appSecret?(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void f(),children:[l?(0,V.jsx)(O,{className:`size-3.5`}):(0,V.jsx)(j,{className:`size-3.5`}),l?n.copied:n.copy]}):null,t[49]=n.copied,t[50]=n.copy,t[51]=f,t[52]=l,t[53]=A.appSecret,t[54]=fe):fe=t[54];let pe;t[55]===o?pe=t[56]:(pe=()=>o(Te),t[55]=o,t[56]=pe);let me;t[57]===a?me=t[58]:(me=a?(0,V.jsx)(D,{className:`size-3.5`}):(0,V.jsx)(te,{className:`size-3.5`}),t[57]=a,t[58]=me);let he=a?n.hide:n.show,_e;t[59]!==pe||t[60]!==me||t[61]!==he?(_e=(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:pe,children:[me,he]}),t[59]=pe,t[60]=me,t[61]=he,t[62]=_e):_e=t[62];let ve;t[63]!==Z||t[64]!==fe||t[65]!==_e?(ve=(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Z,fe,_e]}),t[63]=Z,t[64]=fe,t[65]=_e,t[66]=ve):ve=t[66];let be;t[67]===n.feishuAppSecretDesc?be=t[68]:(be=(0,V.jsx)(ge,{children:n.feishuAppSecretDesc}),t[67]=n.feishuAppSecretDesc,t[68]=be);let xe;t[69]!==G||t[70]!==ve||t[71]!==be?(xe=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[G,ve,be]}),t[69]=G,t[70]=ve,t[71]=be,t[72]=xe):xe=t[72];let $;t[73]===n.feishuDomain?$=t[74]:($=(0,V.jsx)(Q,{children:n.feishuDomain}),t[73]=n.feishuDomain,t[74]=$);let Ee;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=X(),t[75]=Ee):Ee=t[75];let De=String(A.domain||`feishu`),Oe;t[76]===m?Oe=t[77]:(Oe=e=>m({domain:e.target.value}),t[76]=m,t[77]=Oe);let ke,Ae;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,V.jsx)(`option`,{value:`feishu`,children:`feishu`}),Ae=(0,V.jsx)(`option`,{value:`lark`,children:`lark`}),t[78]=ke,t[79]=Ae):(ke=t[78],Ae=t[79]);let je;t[80]!==De||t[81]!==Oe?(je=(0,V.jsxs)(`select`,{className:Ee,value:De,onChange:Oe,children:[ke,Ae]}),t[80]=De,t[81]=Oe,t[82]=je):je=t[82];let Me;t[83]!==$||t[84]!==je?(Me=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[$,je]}),t[83]=$,t[84]=je,t[85]=Me):Me=t[85];let Ne;t[86]===n.connectionMode?Ne=t[87]:(Ne=(0,V.jsx)(Q,{children:n.connectionMode}),t[86]=n.connectionMode,t[87]=Ne);let Pe;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=X(),t[88]=Pe):Pe=t[88];let Fe;t[89]===m?Fe=t[90]:(Fe=e=>m({connectionMode:e.target.value}),t[89]=m,t[90]=Fe);let Ie,Le;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,V.jsx)(`option`,{value:`websocket`,children:`websocket`}),Le=(0,V.jsx)(`option`,{value:`webhook`,children:`webhook`}),t[91]=Ie,t[92]=Le):(Ie=t[91],Le=t[92]);let Re;t[93]!==A.connectionMode||t[94]!==Fe?(Re=(0,V.jsxs)(`select`,{className:Pe,value:A.connectionMode,onChange:Fe,children:[Ie,Le]}),t[93]=A.connectionMode,t[94]=Fe,t[95]=Re):Re=t[95];let ze;t[96]===n.connectionModeDesc?ze=t[97]:(ze=(0,V.jsx)(ge,{children:n.connectionModeDesc}),t[96]=n.connectionModeDesc,t[97]=ze);let Be;t[98]!==Ne||t[99]!==Re||t[100]!==ze?(Be=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ne,Re,ze]}),t[98]=Ne,t[99]=Re,t[100]=ze,t[101]=Be):Be=t[101];let Ve;t[102]!==Me||t[103]!==Be?(Ve=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Me,Be]}),t[102]=Me,t[103]=Be,t[104]=Ve):Ve=t[104];let He;t[105]!==n.copied||t[106]!==n.copy||t[107]!==n.encryptKey||t[108]!==n.encryptKeyDesc||t[109]!==n.hide||t[110]!==n.show||t[111]!==n.verificationToken||t[112]!==n.verificationTokenDesc||t[113]!==n.webhookHost||t[114]!==n.webhookPath||t[115]!==n.webhookPathDesc||t[116]!==n.webhookPort||t[117]!==n.webhookTitle||t[118]!==p||t[119]!==d||t[120]!==A.connectionMode||t[121]!==A.encryptKey||t[122]!==A.verificationToken||t[123]!==A.webhookHost||t[124]!==A.webhookPath||t[125]!==A.webhookPort||t[126]!==c||t[127]!==s||t[128]!==m?(He=A.connectionMode===`webhook`?(0,V.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.webhookTitle}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>c(we),children:[s?(0,V.jsx)(D,{className:`size-3.5`}):(0,V.jsx)(te,{className:`size-3.5`}),s?n.hide:n.show]}),(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void p(),children:[d?(0,V.jsx)(O,{className:`size-3.5`}):(0,V.jsx)(j,{className:`size-3.5`}),d?n.copied:n.copy]})]})]}),(0,V.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.verificationToken}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),type:s?`text`:`password`,autoComplete:`off`,value:A.verificationToken??``,onChange:e=>m({verificationToken:e.target.value})}),(0,V.jsx)(ge,{children:n.verificationTokenDesc})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.encryptKey}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),type:s?`text`:`password`,autoComplete:`off`,value:A.encryptKey??``,onChange:e=>m({encryptKey:e.target.value})}),(0,V.jsx)(ge,{children:n.encryptKeyDesc})]})]}),(0,V.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,V.jsx)(Q,{children:n.webhookHost}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),value:A.webhookHost??``,onChange:e=>m({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.webhookPort}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(A.webhookPort??``),onChange:e=>m({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.webhookPath}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),value:A.webhookPath??``,onChange:e=>m({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,V.jsx)(ge,{children:n.webhookPathDesc})]})]}):null,t[105]=n.copied,t[106]=n.copy,t[107]=n.encryptKey,t[108]=n.encryptKeyDesc,t[109]=n.hide,t[110]=n.show,t[111]=n.verificationToken,t[112]=n.verificationTokenDesc,t[113]=n.webhookHost,t[114]=n.webhookPath,t[115]=n.webhookPathDesc,t[116]=n.webhookPort,t[117]=n.webhookTitle,t[118]=p,t[119]=d,t[120]=A.connectionMode,t[121]=A.encryptKey,t[122]=A.verificationToken,t[123]=A.webhookHost,t[124]=A.webhookPath,t[125]=A.webhookPort,t[126]=c,t[127]=s,t[128]=m,t[129]=He):He=t[129];let Ue;t[130]===n.renderMode?Ue=t[131]:(Ue=(0,V.jsx)(Q,{children:n.renderMode}),t[130]=n.renderMode,t[131]=Ue);let We;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(We=X(),t[132]=We):We=t[132];let Ge;t[133]===m?Ge=t[134]:(Ge=e=>m({renderMode:e.target.value}),t[133]=m,t[134]=Ge);let Ke,qe,Je;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,V.jsx)(`option`,{value:`auto`,children:`auto`}),qe=(0,V.jsx)(`option`,{value:`raw`,children:`raw`}),Je=(0,V.jsx)(`option`,{value:`card`,children:`card`}),t[135]=Ke,t[136]=qe,t[137]=Je):(Ke=t[135],qe=t[136],Je=t[137]);let Ye;t[138]!==A.renderMode||t[139]!==Ge?(Ye=(0,V.jsxs)(`select`,{className:We,value:A.renderMode,onChange:Ge,children:[Ke,qe,Je]}),t[138]=A.renderMode,t[139]=Ge,t[140]=Ye):Ye=t[140];let Xe;t[141]!==Ue||t[142]!==Ye?(Xe=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ue,Ye]}),t[141]=Ue,t[142]=Ye,t[143]=Xe):Xe=t[143];let Ze;t[144]===n.reactionNotifications?Ze=t[145]:(Ze=(0,V.jsx)(Q,{children:n.reactionNotifications}),t[144]=n.reactionNotifications,t[145]=Ze);let Qe;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=X(),t[146]=Qe):Qe=t[146];let $e;t[147]===m?$e=t[148]:($e=e=>m({reactionNotifications:e.target.value}),t[147]=m,t[148]=$e);let et,tt,nt;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,V.jsx)(`option`,{value:`off`,children:`off`}),tt=(0,V.jsx)(`option`,{value:`own`,children:`own`}),nt=(0,V.jsx)(`option`,{value:`all`,children:`all`}),t[149]=et,t[150]=tt,t[151]=nt):(et=t[149],tt=t[150],nt=t[151]);let rt;t[152]!==A.reactionNotifications||t[153]!==$e?(rt=(0,V.jsxs)(`select`,{className:Qe,value:A.reactionNotifications,onChange:$e,children:[et,tt,nt]}),t[152]=A.reactionNotifications,t[153]=$e,t[154]=rt):rt=t[154];let it;t[155]!==Ze||t[156]!==rt?(it=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ze,rt]}),t[155]=Ze,t[156]=rt,t[157]=it):it=t[157];let at;t[158]!==Xe||t[159]!==it?(at=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Xe,it]}),t[158]=Xe,t[159]=it,t[160]=at):at=t[160];let ot;t[161]===m?ot=t[162]:(ot=e=>m({streaming:e.target.checked}),t[161]=m,t[162]=ot);let st;t[163]!==A.streaming||t[164]!==ot?(st=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:A.streaming,onChange:ot}),t[163]=A.streaming,t[164]=ot,t[165]=st):st=t[165];let ct;t[166]!==n.enableStreaming||t[167]!==st?(ct=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[st,n.enableStreaming]}),t[166]=n.enableStreaming,t[167]=st,t[168]=ct):ct=t[168];let lt;t[169]===n.dmPolicy?lt=t[170]:(lt=(0,V.jsx)(Q,{children:n.dmPolicy}),t[169]=n.dmPolicy,t[170]=lt);let ut;t[171]===Symbol.for(`react.memo_cache_sentinel`)?(ut=X(),t[171]=ut):ut=t[171];let dt=A.dmPolicy,ft;t[172]===m?ft=t[173]:(ft=e=>m({dmPolicy:e.target.value}),t[172]=m,t[173]=ft);let pt;t[174]===x?pt=t[175]:(pt=x.map(Ce),t[174]=x,t[175]=pt);let mt;t[176]!==A.dmPolicy||t[177]!==ft||t[178]!==pt?(mt=(0,V.jsx)(`select`,{className:ut,value:dt,onChange:ft,children:pt}),t[176]=A.dmPolicy,t[177]=ft,t[178]=pt,t[179]=mt):mt=t[179];let ht;t[180]!==lt||t[181]!==mt?(ht=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[lt,mt]}),t[180]=lt,t[181]=mt,t[182]=ht):ht=t[182];let gt;t[183]===n.groupPolicy?gt=t[184]:(gt=(0,V.jsx)(Q,{children:n.groupPolicy}),t[183]=n.groupPolicy,t[184]=gt);let _t;t[185]===Symbol.for(`react.memo_cache_sentinel`)?(_t=X(),t[185]=_t):_t=t[185];let vt=A.groupPolicy,yt;t[186]===m?yt=t[187]:(yt=e=>m({groupPolicy:e.target.value}),t[186]=m,t[187]=yt);let bt;t[188]===S?bt=t[189]:(bt=S.map(Se),t[188]=S,t[189]=bt);let xt;t[190]!==A.groupPolicy||t[191]!==yt||t[192]!==bt?(xt=(0,V.jsx)(`select`,{className:_t,value:vt,onChange:yt,children:bt}),t[190]=A.groupPolicy,t[191]=yt,t[192]=bt,t[193]=xt):xt=t[193];let St;t[194]!==gt||t[195]!==xt?(St=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[gt,xt]}),t[194]=gt,t[195]=xt,t[196]=St):St=t[196];let Ct;t[197]!==ht||t[198]!==St?(Ct=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ht,St]}),t[197]=ht,t[198]=St,t[199]=Ct):Ct=t[199];let wt;t[200]===m?wt=t[201]:(wt=e=>m({requireMention:e.target.checked}),t[200]=m,t[201]=wt);let Tt;t[202]!==A.requireMention||t[203]!==wt?(Tt=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:A.requireMention,onChange:wt}),t[202]=A.requireMention,t[203]=wt,t[204]=Tt):Tt=t[204];let Et;t[205]!==n.requireMention||t[206]!==Tt?(Et=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[Tt,n.requireMention]}),t[205]=n.requireMention,t[206]=Tt,t[207]=Et):Et=t[207];let Dt;t[208]===n.allowFromDm?Dt=t[209]:(Dt=(0,V.jsx)(Q,{children:n.allowFromDm}),t[208]=n.allowFromDm,t[209]=Dt);let Ot;t[210]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[210]=Ot):Ot=t[210];let kt;t[211]===A.allowFrom?kt=t[212]:(kt=de(A.allowFrom),t[211]=A.allowFrom,t[212]=kt);let At;t[213]===m?At=t[214]:(At=e=>m({allowFrom:ue(e.target.value)}),t[213]=m,t[214]=At);let jt;t[215]!==kt||t[216]!==At?(jt=(0,V.jsx)(`textarea`,{className:Ot,rows:2,placeholder:`ou_xxx, on_xxx`,value:kt,onChange:At}),t[215]=kt,t[216]=At,t[217]=jt):jt=t[217];let Mt;t[218]===n.allowFromDmDesc?Mt=t[219]:(Mt=(0,V.jsx)(ge,{children:n.allowFromDmDesc}),t[218]=n.allowFromDmDesc,t[219]=Mt);let Nt;t[220]!==Dt||t[221]!==jt||t[222]!==Mt?(Nt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Dt,jt,Mt]}),t[220]=Dt,t[221]=jt,t[222]=Mt,t[223]=Nt):Nt=t[223];let Pt;t[224]===n.allowFromGroups?Pt=t[225]:(Pt=(0,V.jsx)(Q,{children:n.allowFromGroups}),t[224]=n.allowFromGroups,t[225]=Pt);let Ft;t[226]===Symbol.for(`react.memo_cache_sentinel`)?(Ft=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[226]=Ft):Ft=t[226];let It;t[227]===A.groupAllowFrom?It=t[228]:(It=de(A.groupAllowFrom),t[227]=A.groupAllowFrom,t[228]=It);let Lt;t[229]===m?Lt=t[230]:(Lt=e=>m({groupAllowFrom:ue(e.target.value)}),t[229]=m,t[230]=Lt);let Rt;t[231]!==It||t[232]!==Lt?(Rt=(0,V.jsx)(`textarea`,{className:Ft,rows:2,placeholder:`oc_xxx, oc_yyy`,value:It,onChange:Lt}),t[231]=It,t[232]=Lt,t[233]=Rt):Rt=t[233];let zt;t[234]===n.allowFromGroupsDesc?zt=t[235]:(zt=(0,V.jsx)(ge,{children:n.allowFromGroupsDesc}),t[234]=n.allowFromGroupsDesc,t[235]=zt);let Bt;t[236]!==Pt||t[237]!==Rt||t[238]!==zt?(Bt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Pt,Rt,zt]}),t[236]=Pt,t[237]=Rt,t[238]=zt,t[239]=Bt):Bt=t[239];let Vt;t[240]===n.historyLimit?Vt=t[241]:(Vt=(0,V.jsx)(Q,{children:n.historyLimit}),t[240]=n.historyLimit,t[241]=Vt);let Ht;t[242]===Symbol.for(`react.memo_cache_sentinel`)?(Ht=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[242]=Ht):Ht=t[242];let Ut=String(A.historyLimit),Wt;t[243]===m?Wt=t[244]:(Wt=e=>m({historyLimit:Number(e.target.value||`0`)||0}),t[243]=m,t[244]=Wt);let Gt;t[245]!==Ut||t[246]!==Wt?(Gt=(0,V.jsx)(`input`,{className:Ht,type:`number`,inputMode:`numeric`,value:Ut,onChange:Wt}),t[245]=Ut,t[246]=Wt,t[247]=Gt):Gt=t[247];let Kt;t[248]!==Vt||t[249]!==Gt?(Kt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Vt,Gt]}),t[248]=Vt,t[249]=Gt,t[250]=Kt):Kt=t[250];let qt;t[251]===n.textChunkLimit?qt=t[252]:(qt=(0,V.jsx)(Q,{children:n.textChunkLimit}),t[251]=n.textChunkLimit,t[252]=qt);let Jt;t[253]===Symbol.for(`react.memo_cache_sentinel`)?(Jt=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[253]=Jt):Jt=t[253];let Yt=String(A.textChunkLimit),Xt;t[254]===m?Xt=t[255]:(Xt=e=>m({textChunkLimit:Number(e.target.value||`0`)||0}),t[254]=m,t[255]=Xt);let Zt;t[256]!==Yt||t[257]!==Xt?(Zt=(0,V.jsx)(`input`,{className:Jt,type:`number`,inputMode:`numeric`,value:Yt,onChange:Xt}),t[256]=Yt,t[257]=Xt,t[258]=Zt):Zt=t[258];let Qt;t[259]!==qt||t[260]!==Zt?(Qt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[qt,Zt]}),t[259]=qt,t[260]=Zt,t[261]=Qt):Qt=t[261];let $t;t[262]!==Kt||t[263]!==Qt?($t=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Kt,Qt]}),t[262]=Kt,t[263]=Qt,t[264]=$t):$t=t[264];let en;t[265]===n.feishuToolsTitle?en=t[266]:(en=(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuToolsTitle}),t[265]=n.feishuToolsTitle,t[266]=en);let tn;t[267]===n.feishuToolDoc?tn=t[268]:(tn=[`doc`,n.feishuToolDoc],t[267]=n.feishuToolDoc,t[268]=tn);let nn;t[269]===n.feishuToolWiki?nn=t[270]:(nn=[`wiki`,n.feishuToolWiki],t[269]=n.feishuToolWiki,t[270]=nn);let rn;t[271]===n.feishuToolDrive?rn=t[272]:(rn=[`drive`,n.feishuToolDrive],t[271]=n.feishuToolDrive,t[272]=rn);let an;t[273]===n.feishuToolPerm?an=t[274]:(an=[`perm`,n.feishuToolPerm],t[273]=n.feishuToolPerm,t[274]=an);let on;t[275]===n.feishuToolBitable?on=t[276]:(on=[`bitable`,n.feishuToolBitable],t[275]=n.feishuToolBitable,t[276]=on);let sn;t[277]===n.feishuToolScopes?sn=t[278]:(sn=[`scopes`,n.feishuToolScopes],t[277]=n.feishuToolScopes,t[278]=sn);let cn;t[279]!==tn||t[280]!==nn||t[281]!==rn||t[282]!==an||t[283]!==on||t[284]!==sn?(cn=[tn,nn,rn,an,on,sn],t[279]=tn,t[280]=nn,t[281]=rn,t[282]=an,t[283]=on,t[284]=sn,t[285]=cn):cn=t[285];let ln=cn,un;t[286]!==A.tools||t[287]!==ln||t[288]!==m?(un=(0,V.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:ln.map(e=>{let[t,n]=e;return(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!A.tools?.[t],onChange:e=>m({tools:{...A.tools,[t]:e.target.checked}})}),n]},t)})}),t[286]=A.tools,t[287]=ln,t[288]=m,t[289]=un):un=t[289];let dn;t[290]===n.feishuToolsDesc?dn=t[291]:(dn=(0,V.jsx)(`div`,{className:`mt-2`,children:(0,V.jsx)(ge,{children:n.feishuToolsDesc})}),t[290]=n.feishuToolsDesc,t[291]=dn);let fn;t[292]!==en||t[293]!==un||t[294]!==dn?(fn=(0,V.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[en,un,dn]}),t[292]=en,t[293]=un,t[294]=dn,t[295]=fn):fn=t[295];let pn;t[296]===n.feishuActionsTitle?pn=t[297]:(pn=(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuActionsTitle}),t[296]=n.feishuActionsTitle,t[297]=pn);let mn=!!A.actions?.reactions,hn;t[298]!==A.actions||t[299]!==m?(hn=e=>m({actions:{...A.actions,reactions:e.target.checked}}),t[298]=A.actions,t[299]=m,t[300]=hn):hn=t[300];let gn;t[301]!==mn||t[302]!==hn?(gn=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:mn,onChange:hn}),t[301]=mn,t[302]=hn,t[303]=gn):gn=t[303];let _n;t[304]!==n.feishuActionReactions||t[305]!==gn?(_n=(0,V.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[gn,n.feishuActionReactions]}),t[304]=n.feishuActionReactions,t[305]=gn,t[306]=_n):_n=t[306];let vn;t[307]!==pn||t[308]!==_n?(vn=(0,V.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[pn,_n]}),t[307]=pn,t[308]=_n,t[309]=vn):vn=t[309];let yn;t[310]===A?yn=t[311]:(yn=q(A),t[310]=A,t[311]=yn);let bn;t[312]===C?.items?bn=t[313]:(bn=C?.items??[],t[312]=C?.items,t[313]=bn);let xn;t[314]===h?xn=t[315]:(xn=(e,t)=>h(`feishu`,e,t),t[314]=h,t[315]=xn);let Sn;t[316]!==n||t[317]!==r.channelAgentRoutes.feishu||t[318]!==r.defaultAgentId||t[319]!==w||t[320]!==yn||t[321]!==bn||t[322]!==xn?(Sn=(0,V.jsx)(ye,{accountIds:yn,routes:r.channelAgentRoutes.feishu,defaultAgentId:r.defaultAgentId,agentItems:bn,disabled:w,onChange:xn,ch:n}),t[316]=n,t[317]=r.channelAgentRoutes.feishu,t[318]=r.defaultAgentId,t[319]=w,t[320]=yn,t[321]=bn,t[322]=xn,t[323]=Sn):Sn=t[323];let Cn;t[324]===n.multiAccountJson?Cn=t[325]:(Cn=(0,V.jsx)(Q,{children:n.multiAccountJson}),t[324]=n.multiAccountJson,t[325]=Cn);let wn;t[326]===Symbol.for(`react.memo_cache_sentinel`)?(wn=M(X(),`min-h-[140px] resize-y font-mono text-xs`),t[326]=wn):wn=t[326];let Tn;t[327]===_?Tn=t[328]:(Tn=e=>_(e.target.value),t[327]=_,t[328]=Tn);let En;t[329]!==g||t[330]!==b||t[331]!==Tn?(En=(0,V.jsx)(`textarea`,{className:wn,spellCheck:!1,value:g,onChange:Tn,onBlur:b,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),t[329]=g,t[330]=b,t[331]=Tn,t[332]=En):En=t[332];let Dn;t[333]!==n.multiAccountJsonDesc||t[334]!==y?(Dn=y?(0,V.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:y}):(0,V.jsx)(ge,{children:n.multiAccountJsonDesc}),t[333]=n.multiAccountJsonDesc,t[334]=y,t[335]=Dn):Dn=t[335];let On;t[336]!==Cn||t[337]!==En||t[338]!==Dn?(On=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Cn,En,Dn]}),t[336]=Cn,t[337]=En,t[338]=Dn,t[339]=On):On=t[339];let kn;t[340]!==Bt||t[341]!==$t||t[342]!==fn||t[343]!==vn||t[344]!==Sn||t[345]!==On||t[346]!==ce||t[347]!==xe||t[348]!==Ve||t[349]!==He||t[350]!==at||t[351]!==ct||t[352]!==Ct||t[353]!==Et||t[354]!==Nt?(kn=(0,V.jsxs)(`div`,{className:`space-y-4`,children:[ce,xe,Ve,He,at,ct,Ct,Et,Nt,Bt,$t,fn,vn,Sn,On]}),t[340]=Bt,t[341]=$t,t[342]=fn,t[343]=vn,t[344]=Sn,t[345]=On,t[346]=ce,t[347]=xe,t[348]=Ve,t[349]=He,t[350]=at,t[351]=ct,t[352]=Ct,t[353]=Et,t[354]=Nt,t[355]=kn):kn=t[355];let An=!T||w,jn;t[356]!==n.discard||t[357]!==k||t[358]!==An?(jn=(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:An,onClick:k,children:n.discard}),t[356]=n.discard,t[357]=k,t[358]=An,t[359]=jn):jn=t[359];let Mn=!T||w,Nn;t[360]===E?Nn=t[361]:(Nn=async()=>{await E()},t[360]=E,t[361]=Nn);let Pn=w?n.saving:n.save,Fn;t[362]!==Mn||t[363]!==Nn||t[364]!==Pn?(Fn=(0,V.jsx)(u,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:Mn,onClick:Nn,children:Pn}),t[362]=Mn,t[363]=Nn,t[364]=Pn,t[365]=Fn):Fn=t[365];let In;t[366]!==jn||t[367]!==Fn?(In=(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[jn,Fn]}),t[366]=jn,t[367]=Fn,t[368]=In):In=t[368];let Ln;t[369]!==kn||t[370]!==In||t[371]!==I||t[372]!==ie?(Ln=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[I,ie,kn,In]}),t[369]=kn,t[370]=In,t[371]=I,t[372]=ie,t[373]=Ln):Ln=t[373];let Rn;return t[374]!==Ln||t[375]!==ne?(Rn=(0,V.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[ne,Ln]}),t[374]=Ln,t[375]=ne,t[376]=Rn):Rn=t[376],Rn}function Se(e){return(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value)}function Ce(e){return(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value)}function we(e){return!e}function Te(e){return!e}var $=e(t(),1),Ee=e(B(),1);function De(e){return{accountId:e,name:``,enabled:!0,botToken:``,allowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,apiRoot:``,proxy:``,historyLimit:50,textChunkLimit:4e3,streamMode:`partial`}}function Oe(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{}},defaultAgentId:`main`,telegram:{enabled:!1,apiRoot:``,debug:!1,allowFrom:[],groupAllowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,proxy:``,accounts:{default:De(`default`)}},weixin:{enabled:!1,dmPolicy:`open`,allowFrom:[],debug:!1,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,routeTag:``,accounts:{}},feishu:{enabled:!1,defaultAccount:``,appId:``,appSecret:``,domain:`feishu`,connectionMode:`websocket`,verificationToken:``,encryptKey:``,webhookHost:`127.0.0.1`,webhookPort:3e3,webhookPath:`/feishu/events`,dmPolicy:`open`,groupPolicy:`allowlist`,allowFrom:[],groupAllowFrom:[],requireMention:!0,historyLimit:50,textChunkLimit:4e3,renderMode:`auto`,streaming:!1,reactionNotifications:`own`,tools:{doc:!0,wiki:!0,drive:!0,scopes:!0,bitable:!0,perm:!1},actions:{reactions:!0},accounts:{}}}}function ke(e){let t=e&&typeof e==`object`?e.channels:void 0,n=t&&typeof t==`object`?t:{},r=n.telegram,i=n.weixin,a=n.feishu,o=r?.accounts,s=o&&typeof o==`object`&&!Array.isArray(o)?{...o}:{},c=typeof r?.botToken==`string`?r.botToken.trim():``,l=s.default?.botToken?.trim()??``;c&&!l&&(s={...s,default:{...s.default??De(`default`),accountId:`default`,botToken:c}}),s.default||(s={...s,default:De(`default`)});let u=i?.accounts,d=u&&typeof u==`object`&&!Array.isArray(u)?u:{},f=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),p=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),m=typeof p.defaultId==`string`&&p.defaultId.trim()?p.defaultId.trim().toLowerCase():`main`,h={telegram:{enabled:!!r?.enabled,apiRoot:typeof r?.apiRoot==`string`?r.apiRoot:``,debug:!!r?.debug,allowFrom:Array.isArray(r?.allowFrom)?[...r.allowFrom]:[],groupAllowFrom:Array.isArray(r?.groupAllowFrom)?[...r.groupAllowFrom]:[],dmPolicy:r?.dmPolicy||`pairing`,groupPolicy:r?.groupPolicy||`open`,replyToMode:r?.replyToMode||`off`,streamMode:r?.streamMode??`partial`,historyLimit:typeof r?.historyLimit==`number`?r.historyLimit:50,textChunkLimit:typeof r?.textChunkLimit==`number`?r.textChunkLimit:4e3,proxy:typeof r?.proxy==`string`?r.proxy:``,accounts:{...s}},weixin:{enabled:!!i?.enabled,dmPolicy:i?.dmPolicy||`open`,allowFrom:Array.isArray(i?.allowFrom)?[...i.allowFrom]:[],debug:!!i?.debug,streamMode:i?.streamMode??`partial`,historyLimit:typeof i?.historyLimit==`number`?i.historyLimit:50,textChunkLimit:typeof i?.textChunkLimit==`number`?i.textChunkLimit:4e3,routeTag:i?.routeTag==null?``:String(i.routeTag),accounts:{...d}},feishu:{enabled:!!a?.enabled,defaultAccount:typeof a?.defaultAccount==`string`?a.defaultAccount:``,appId:typeof a?.appId==`string`?a.appId:``,appSecret:typeof a?.appSecret==`string`?a.appSecret:``,domain:typeof a?.domain==`string`&&a.domain||`feishu`,connectionMode:a?.connectionMode||`websocket`,verificationToken:typeof a?.verificationToken==`string`?a.verificationToken:``,encryptKey:typeof a?.encryptKey==`string`?a.encryptKey:``,webhookHost:typeof a?.webhookHost==`string`?a.webhookHost:`127.0.0.1`,webhookPort:typeof a?.webhookPort==`number`?a.webhookPort:3e3,webhookPath:typeof a?.webhookPath==`string`?a.webhookPath:`/feishu/events`,dmPolicy:a?.dmPolicy||`open`,groupPolicy:a?.groupPolicy||`allowlist`,allowFrom:Array.isArray(a?.allowFrom)?[...a.allowFrom]:[],groupAllowFrom:Array.isArray(a?.groupAllowFrom)?[...a.groupAllowFrom]:[],requireMention:a?.requireMention===void 0?!0:!!a.requireMention,historyLimit:typeof a?.historyLimit==`number`?a.historyLimit:50,textChunkLimit:typeof a?.textChunkLimit==`number`?a.textChunkLimit:4e3,renderMode:a?.renderMode||`auto`,streaming:a?.streaming===void 0?!1:!!a.streaming,reactionNotifications:a?.reactionNotifications||`own`,tools:a?.tools&&typeof a.tools==`object`&&!Array.isArray(a.tools)?{...a.tools}:void 0,actions:a?.actions&&typeof a.actions==`object`&&!Array.isArray(a.actions)?{...a.actions}:void 0,accounts:a?.accounts&&typeof a.accounts==`object`&&!Array.isArray(a.accounts)?{...a.accounts}:{}}},g=J(f,K(h.telegram),le(h.weixin),q(h.feishu),m);return{...h,bindingsFull:f.map(e=>({...e})),channelAgentRoutes:g,defaultAgentId:m}}async function Ae(e){return(await l(I(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function je(e){return(await l(I(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function Me(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=Y(e.bindingsFull,e.channelAgentRoutes,K(t),le(n),q(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await l(I(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:i,channels:{telegram:{enabled:t.enabled,apiRoot:t.apiRoot||void 0,debug:t.debug,allowFrom:t.allowFrom,groupAllowFrom:t.groupAllowFrom.length?t.groupAllowFrom:void 0,dmPolicy:t.dmPolicy,groupPolicy:t.groupPolicy,replyToMode:t.replyToMode,streamMode:t.streamMode,historyLimit:t.historyLimit,textChunkLimit:t.textChunkLimit,proxy:t.proxy||void 0,accounts:t.accounts},weixin:{enabled:n.enabled,dmPolicy:n.dmPolicy,allowFrom:n.allowFrom,debug:n.debug,streamMode:n.streamMode,historyLimit:n.historyLimit,textChunkLimit:n.textChunkLimit,routeTag:a,accounts:n.accounts},feishu:{enabled:r.enabled,defaultAccount:r.defaultAccount||void 0,appId:r.appId,appSecret:r.appSecret||void 0,domain:r.domain||void 0,connectionMode:r.connectionMode,verificationToken:r.verificationToken?.trim()?r.verificationToken:void 0,encryptKey:r.encryptKey?.trim()?r.encryptKey:void 0,webhookHost:r.webhookHost?.trim()?r.webhookHost:void 0,webhookPort:typeof r.webhookPort==`number`?r.webhookPort:void 0,webhookPath:r.webhookPath?.trim()?r.webhookPath:void 0,dmPolicy:r.dmPolicy,groupPolicy:r.groupPolicy,allowFrom:r.allowFrom,groupAllowFrom:r.groupAllowFrom.length?r.groupAllowFrom:void 0,requireMention:r.requireMention,historyLimit:r.historyLimit,textChunkLimit:r.textChunkLimit,renderMode:r.renderMode,streaming:r.streaming,reactionNotifications:r.reactionNotifications,tools:r.tools,actions:r.actions,accounts:r.accounts}}})})).payload?.config;return h(),o?ke(o):{...e,bindingsFull:i}}async function Ne(e){return(await l(I(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Pe(e){return(await l(I(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function Fe({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:i}){let[a,o]=(0,$.useState)(!1),[c,l]=(0,$.useState)(`feishu`),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),[g,_]=(0,$.useState)(null),[v,y]=(0,$.useState)(null),[S,E]=(0,$.useState)(!1),D=(0,$.useCallback)(async e=>{l(e),_(null),p(null),h(null),o(!0);try{let t=await Ne({domain:e});h(t.qrUrl),p(t.sessionKey)}catch(e){_(e instanceof Error?e.message:`Start failed`)}finally{o(!1)}},[]);(0,$.useEffect)(()=>{if(!e){p(null),h(null),_(null),y(null),E(!1),l(`feishu`),o(!1);return}D(`feishu`)},[e,D]),(0,$.useEffect)(()=>{if(!f)return;let e=!1,n,i=async()=>{try{let i=await Pe(f);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),p(null),i.ok?(h(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(_(i.message),h(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),_(i.message),p(null),h(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),_(t instanceof Error?t.message:`Request failed`),p(null),h(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[f,t,r]),(0,$.useEffect)(()=>{if(!m){y(null),E(!1);return}let e=!1;return E(!1),Ee.toDataURL(m,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||y(t)}).catch(()=>{e||(E(!0),y(null))}),()=>{e=!0}},[m]);let O=!!(m&&f),k=e,j=e&&!g&&!O;return(0,V.jsx)(x,{open:e,onOpenChange:t,children:(0,V.jsxs)(d,{children:[(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),(0,V.jsxs)(R,{className:M(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,P,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,V.jsx)(b,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.feishuQrCloseAria,children:(0,V.jsx)(T,{className:`size-4`})})}),(0,V.jsx)(w,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,V.jsx)(s,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,V.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[g?(0,V.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:g}):null,!g&&(O||j)?(0,V.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:j?n.feishuQrStarting:n.feishuQrScanHint}),(0,V.jsxs)(`div`,{className:M(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,j&&`bg-surface-muted/40 dark:bg-surface-base`),children:[j?(0,V.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,O&&m&&!g&&v&&!S?(0,V.jsx)(`img`,{src:v,alt:``,className:`relative z-[1] size-full object-contain`}):null,O&&m&&!g&&!v&&!S&&!j?(0,V.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,O&&m&&!g&&S?(0,V.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,V.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.feishuQrImageError}),(0,V.jsxs)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,V.jsx)(ee,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),k?(0,V.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":n.feishuRegionSwitchAria,children:(0,V.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:a,className:M(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void D(`feishu`),children:n.feishuRegionChina}),(0,V.jsx)(`button`,{type:`button`,disabled:a,className:M(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void D(`lark`),children:n.feishuRegionInternational})]})}):null,(0,V.jsx)(`div`,{className:`mt-6`,children:(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:a,onClick:()=>void D(c),children:a?n.feishuQrStarting:n.feishuQrRegenerate})}),i?(0,V.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function Ie(e){let t=(0,se.c)(123),{tg:n,updateTelegram:r,ch:i,dmOpts:a,groupOpts:o,replyOpts:s,streamOpts:c,tgAccountsDraft:l,setTgAccountsDraft:u,tgAccountsError:d,onTgAccountsBlur:f}=e,p;t[0]===i.apiRoot?p=t[1]:(p=(0,V.jsx)(Q,{children:i.apiRoot}),t[0]=i.apiRoot,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=X(),t[2]=m):m=t[2];let h;t[3]===r?h=t[4]:(h=e=>r({apiRoot:e.target.value}),t[3]=r,t[4]=h);let g;t[5]!==h||t[6]!==n.apiRoot?(g=(0,V.jsx)(`input`,{className:m,value:n.apiRoot,onChange:h,placeholder:`https://api.telegram.org`}),t[5]=h,t[6]=n.apiRoot,t[7]=g):g=t[7];let _;t[8]!==p||t[9]!==g?(_=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[p,g]}),t[8]=p,t[9]=g,t[10]=_):_=t[10];let v;t[11]===i.proxy?v=t[12]:(v=(0,V.jsx)(Q,{children:i.proxy}),t[11]=i.proxy,t[12]=v);let y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=X(),t[13]=y):y=t[13];let b;t[14]===r?b=t[15]:(b=e=>r({proxy:e.target.value}),t[14]=r,t[15]=b);let x;t[16]!==b||t[17]!==n.proxy?(x=(0,V.jsx)(`input`,{className:y,value:n.proxy,onChange:b,placeholder:`http://proxy.example.com:8080`}),t[16]=b,t[17]=n.proxy,t[18]=x):x=t[18];let S;t[19]!==v||t[20]!==x?(S=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[v,x]}),t[19]=v,t[20]=x,t[21]=S):S=t[21];let C;t[22]===r?C=t[23]:(C=e=>r({dmPolicy:e}),t[22]=r,t[23]=C);let w;t[24]!==i.dmPolicy||t[25]!==a||t[26]!==C||t[27]!==n.dmPolicy?(w=(0,V.jsx)(_e,{label:i.dmPolicy,value:n.dmPolicy,onChange:C,options:a}),t[24]=i.dmPolicy,t[25]=a,t[26]=C,t[27]=n.dmPolicy,t[28]=w):w=t[28];let T;t[29]===r?T=t[30]:(T=e=>r({groupPolicy:e}),t[29]=r,t[30]=T);let E;t[31]!==i.groupPolicy||t[32]!==o||t[33]!==T||t[34]!==n.groupPolicy?(E=(0,V.jsx)(_e,{label:i.groupPolicy,value:n.groupPolicy,onChange:T,options:o}),t[31]=i.groupPolicy,t[32]=o,t[33]=T,t[34]=n.groupPolicy,t[35]=E):E=t[35];let D;t[36]===r?D=t[37]:(D=e=>r({replyToMode:e}),t[36]=r,t[37]=D);let O;t[38]!==i.replyToMode||t[39]!==s||t[40]!==D||t[41]!==n.replyToMode?(O=(0,V.jsx)(_e,{label:i.replyToMode,value:n.replyToMode,onChange:D,options:s}),t[38]=i.replyToMode,t[39]=s,t[40]=D,t[41]=n.replyToMode,t[42]=O):O=t[42];let k;t[43]===r?k=t[44]:(k=e=>r({streamMode:e}),t[43]=r,t[44]=k);let A;t[45]!==i.streamMode||t[46]!==c||t[47]!==k||t[48]!==n.streamMode?(A=(0,V.jsx)(_e,{label:i.streamMode,value:n.streamMode,onChange:k,options:c}),t[45]=i.streamMode,t[46]=c,t[47]=k,t[48]=n.streamMode,t[49]=A):A=t[49];let ee;t[50]===i.allowFromGroups?ee=t[51]:(ee=(0,V.jsx)(Q,{children:i.allowFromGroups}),t[50]=i.allowFromGroups,t[51]=ee);let j;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(j=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[52]=j):j=t[52];let N;t[53]===n.groupAllowFrom?N=t[54]:(N=de(n.groupAllowFrom),t[53]=n.groupAllowFrom,t[54]=N);let P;t[55]===r?P=t[56]:(P=e=>r({groupAllowFrom:ue(e.target.value)}),t[55]=r,t[56]=P);let te;t[57]!==N||t[58]!==P?(te=(0,V.jsx)(`textarea`,{className:j,rows:2,placeholder:`-1001234567890`,value:N,onChange:P}),t[57]=N,t[58]=P,t[59]=te):te=t[59];let F;t[60]!==ee||t[61]!==te?(F=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ee,te]}),t[60]=ee,t[61]=te,t[62]=F):F=t[62];let ne;t[63]===i.historyLimit?ne=t[64]:(ne=(0,V.jsx)(Q,{children:i.historyLimit}),t[63]=i.historyLimit,t[64]=ne);let I;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(I=X(),t[65]=I):I=t[65];let L;t[66]===r?L=t[67]:(L=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[66]=r,t[67]=L);let R;t[68]!==L||t[69]!==n.historyLimit?(R=(0,V.jsx)(`input`,{type:`number`,min:10,max:200,className:I,value:n.historyLimit,onChange:L}),t[68]=L,t[69]=n.historyLimit,t[70]=R):R=t[70];let re;t[71]!==ne||t[72]!==R?(re=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ne,R]}),t[71]=ne,t[72]=R,t[73]=re):re=t[73];let ie;t[74]===i.textChunkLimit?ie=t[75]:(ie=(0,V.jsx)(Q,{children:i.textChunkLimit}),t[74]=i.textChunkLimit,t[75]=ie);let ae;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(ae=X(),t[76]=ae):ae=t[76];let z;t[77]===r?z=t[78]:(z=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[77]=r,t[78]=z);let oe;t[79]!==z||t[80]!==n.textChunkLimit?(oe=(0,V.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:ae,value:n.textChunkLimit,onChange:z}),t[79]=z,t[80]=n.textChunkLimit,t[81]=oe):oe=t[81];let B;t[82]!==ie||t[83]!==oe?(B=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ie,oe]}),t[82]=ie,t[83]=oe,t[84]=B):B=t[84];let H;t[85]!==re||t[86]!==B?(H=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[re,B]}),t[85]=re,t[86]=B,t[87]=H):H=t[87];let U;t[88]===r?U=t[89]:(U=e=>r({debug:e.target.checked}),t[88]=r,t[89]=U);let ce;t[90]!==U||t[91]!==n.debug?(ce=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:U}),t[90]=U,t[91]=n.debug,t[92]=ce):ce=t[92];let W;t[93]!==i.telegramDebug||t[94]!==ce?(W=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ce,i.telegramDebug]}),t[93]=i.telegramDebug,t[94]=ce,t[95]=W):W=t[95];let G;t[96]===i.multiAccountJson?G=t[97]:(G=(0,V.jsx)(Q,{children:i.multiAccountJson}),t[96]=i.multiAccountJson,t[97]=G);let K;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(K=M(X(),`min-h-[140px] resize-y font-mono text-xs`),t[98]=K):K=t[98];let le;t[99]===u?le=t[100]:(le=e=>u(e.target.value),t[99]=u,t[100]=le);let q;t[101]!==f||t[102]!==le||t[103]!==l?(q=(0,V.jsx)(`textarea`,{className:K,spellCheck:!1,value:l,onChange:le,onBlur:f,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),t[101]=f,t[102]=le,t[103]=l,t[104]=q):q=t[104];let J;t[105]!==i.multiAccountJsonDesc||t[106]!==d?(J=d?(0,V.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:d}):(0,V.jsx)(ge,{children:i.multiAccountJsonDesc}),t[105]=i.multiAccountJsonDesc,t[106]=d,t[107]=J):J=t[107];let Y;t[108]!==G||t[109]!==q||t[110]!==J?(Y=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[G,q,J]}),t[108]=G,t[109]=q,t[110]=J,t[111]=Y):Y=t[111];let Z;return t[112]!==S||t[113]!==w||t[114]!==E||t[115]!==O||t[116]!==A||t[117]!==F||t[118]!==H||t[119]!==W||t[120]!==Y||t[121]!==_?(Z=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[_,S,w,E,O,A,F,H,W,Y]}),t[112]=S,t[113]=w,t[114]=E,t[115]=O,t[116]=A,t[117]=F,t[118]=H,t[119]=W,t[120]=Y,t[121]=_,t[122]=Z):Z=t[122],Z}function Le(e){let t=(0,se.c)(162),{open:n,onOpenChange:r,ch:i,form:a,baseline:o,tgAdvanced:c,setTgAdvanced:l,showToken:f,setShowToken:p,copied:m,copyToken:h,updateTelegram:g,updateChannelAgentRoute:_,tgAccountsDraft:y,setTgAccountsDraft:S,tgAccountsError:E,onTgAccountsBlur:k,dmOpts:ee,groupOpts:N,replyOpts:F,streamOpts:ne,chatAgents:I,saving:L,dirty:re,save:ie,discard:ae}=e,z=a.telegram,oe;t[0]===o?oe=t[1]:(oe=o?fe(o.telegram):``,t[0]=o,t[1]=oe);let B=oe,H;t[2]===z?H=t[3]:(H=fe(z),t[2]=z,t[3]=H);let U=H,ce;t[4]!==f||t[5]!==B||t[6]!==U?(ce=!f&&!!String(B).trim()&&U===B,t[4]=f,t[5]=B,t[6]=U,t[7]=ce):ce=t[7];let W=ce,G;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),t[8]=G):G=t[8];let le;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(le=M(`fixed left-1/2 top-1/2 max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,P,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[9]=le):le=t[9];let q;t[10]===i.telegramTitle?q=t[11]:(q=(0,V.jsx)(w,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.telegramTitle}),t[10]=i.telegramTitle,t[11]=q);let J;t[12]===i.telegramSubtitle?J=t[13]:(J=(0,V.jsx)(s,{className:`mt-1 text-sm text-fg-muted`,children:i.telegramSubtitle}),t[12]=i.telegramSubtitle,t[13]=J);let Y;t[14]!==q||t[15]!==J?(Y=(0,V.jsxs)(`div`,{children:[q,J]}),t[14]=q,t[15]=J,t[16]=Y):Y=t[16];let Z;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,V.jsx)(T,{className:`size-4`}),t[17]=Z):Z=t[17];let pe;t[18]===i.modalCancel?pe=t[19]:(pe=(0,V.jsx)(b,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.modalCancel,children:Z})}),t[18]=i.modalCancel,t[19]=pe);let me;t[20]!==pe||t[21]!==Y?(me=(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[Y,pe]}),t[20]=pe,t[21]=Y,t[22]=me):me=t[22];let he;t[23]===g?he=t[24]:(he=e=>g({enabled:e.target.checked}),t[23]=g,t[24]=he);let _e;t[25]!==he||t[26]!==z.enabled?(_e=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:z.enabled,onChange:he}),t[25]=he,t[26]=z.enabled,t[27]=_e):_e=t[27];let ve;t[28]===i.enableTelegramAria?ve=t[29]:(ve=(0,V.jsx)(`span`,{children:i.enableTelegramAria}),t[28]=i.enableTelegramAria,t[29]=ve);let be;t[30]!==_e||t[31]!==ve?(be=(0,V.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[_e,ve]}),t[30]=_e,t[31]=ve,t[32]=be):be=t[32];let xe;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,V.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[33]=xe):xe=t[33];let Se;t[34]===i.telegramToken?Se=t[35]:(Se=(0,V.jsxs)(Q,{children:[i.telegramToken,xe]}),t[34]=i.telegramToken,t[35]=Se);let Ce;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[36]=Ce):Ce=t[36];let we=f?`text`:`password`,Te;t[37]!==W||t[38]!==B||t[39]!==U?(Te=W?`*`.repeat(Math.max(1,B.length)):U,t[37]=W,t[38]=B,t[39]=U,t[40]=Te):Te=t[40];let $;t[41]!==W||t[42]!==z.accounts||t[43]!==g?($=e=>{if(W)return;let t=z.accounts?.default??De(`default`);g({accounts:{...z.accounts,default:{...t,accountId:`default`,botToken:e.target.value}}})},t[41]=W,t[42]=z.accounts,t[43]=g,t[44]=$):$=t[44];let Ee;t[45]!==we||t[46]!==Te||t[47]!==$||t[48]!==W?(Ee=(0,V.jsx)(`input`,{className:Ce,type:we,autoComplete:`off`,readOnly:W,value:Te,onChange:$,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),t[45]=we,t[46]=Te,t[47]=$,t[48]=W,t[49]=Ee):Ee=t[49];let Oe;t[50]!==i.copied||t[51]!==i.copy||t[52]!==m||t[53]!==h||t[54]!==U?(Oe=U?(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void h(),children:[m?(0,V.jsx)(O,{className:`size-3.5`}):(0,V.jsx)(j,{className:`size-3.5`}),m?i.copied:i.copy]}):null,t[50]=i.copied,t[51]=i.copy,t[52]=m,t[53]=h,t[54]=U,t[55]=Oe):Oe=t[55];let ke;t[56]===p?ke=t[57]:(ke=()=>p(ze),t[56]=p,t[57]=ke);let Ae;t[58]===f?Ae=t[59]:(Ae=f?(0,V.jsx)(D,{className:`size-3.5`}):(0,V.jsx)(te,{className:`size-3.5`}),t[58]=f,t[59]=Ae);let je=f?i.hide:i.show,Me;t[60]!==ke||t[61]!==Ae||t[62]!==je?(Me=(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:ke,children:[Ae,je]}),t[60]=ke,t[61]=Ae,t[62]=je,t[63]=Me):Me=t[63];let Ne;t[64]!==Ee||t[65]!==Oe||t[66]!==Me?(Ne=(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee,Oe,Me]}),t[64]=Ee,t[65]=Oe,t[66]=Me,t[67]=Ne):Ne=t[67];let Pe;t[68]===i.telegramTokenDesc?Pe=t[69]:(Pe=(0,V.jsx)(ge,{children:i.telegramTokenDesc}),t[68]=i.telegramTokenDesc,t[69]=Pe);let Fe;t[70]!==Se||t[71]!==Ne||t[72]!==Pe?(Fe=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Se,Ne,Pe]}),t[70]=Se,t[71]=Ne,t[72]=Pe,t[73]=Fe):Fe=t[73];let Le;t[74]===i.allowFromDm?Le=t[75]:(Le=(0,V.jsx)(Q,{children:i.allowFromDm}),t[74]=i.allowFromDm,t[75]=Le);let Ve;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[76]=Ve):Ve=t[76];let He;t[77]===z.allowFrom?He=t[78]:(He=de(z.allowFrom),t[77]=z.allowFrom,t[78]=He);let Ue;t[79]===g?Ue=t[80]:(Ue=e=>g({allowFrom:ue(e.target.value)}),t[79]=g,t[80]=Ue);let We;t[81]!==He||t[82]!==Ue?(We=(0,V.jsx)(`textarea`,{className:Ve,rows:2,placeholder:`123456789, 987654321`,value:He,onChange:Ue}),t[81]=He,t[82]=Ue,t[83]=We):We=t[83];let Ge;t[84]===i.allowFromDmDesc?Ge=t[85]:(Ge=(0,V.jsx)(ge,{children:i.allowFromDmDesc}),t[84]=i.allowFromDmDesc,t[85]=Ge);let Ke;t[86]!==Le||t[87]!==We||t[88]!==Ge?(Ke=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Le,We,Ge]}),t[86]=Le,t[87]=We,t[88]=Ge,t[89]=Ke):Ke=t[89];let qe;t[90]===z?qe=t[91]:(qe=K(z),t[90]=z,t[91]=qe);let Je;t[92]===I?.items?Je=t[93]:(Je=I?.items??[],t[92]=I?.items,t[93]=Je);let Ye;t[94]===_?Ye=t[95]:(Ye=(e,t)=>_(`telegram`,e,t),t[94]=_,t[95]=Ye);let Xe;t[96]!==i||t[97]!==a.channelAgentRoutes.telegram||t[98]!==a.defaultAgentId||t[99]!==L||t[100]!==qe||t[101]!==Je||t[102]!==Ye?(Xe=(0,V.jsx)(ye,{accountIds:qe,routes:a.channelAgentRoutes.telegram,defaultAgentId:a.defaultAgentId,agentItems:Je,disabled:L,onChange:Ye,ch:i}),t[96]=i,t[97]=a.channelAgentRoutes.telegram,t[98]=a.defaultAgentId,t[99]=L,t[100]=qe,t[101]=Je,t[102]=Ye,t[103]=Xe):Xe=t[103];let Ze;t[104]===l?Ze=t[105]:(Ze=()=>l(Re),t[104]=l,t[105]=Ze);let Qe=c&&`rotate-180`,$e;t[106]===Qe?$e=t[107]:($e=M(`mr-1 size-4 transition-transform`,Qe),t[106]=Qe,t[107]=$e);let et;t[108]===$e?et=t[109]:(et=(0,V.jsx)(v,{className:$e}),t[108]=$e,t[109]=et);let tt=c?i.advancedHide:i.advancedShow,nt;t[110]!==Ze||t[111]!==et||t[112]!==tt?(nt=(0,V.jsxs)(u,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:Ze,children:[et,tt]}),t[110]=Ze,t[111]=et,t[112]=tt,t[113]=nt):nt=t[113];let rt;t[114]!==i||t[115]!==ee||t[116]!==N||t[117]!==k||t[118]!==F||t[119]!==S||t[120]!==ne||t[121]!==z||t[122]!==y||t[123]!==E||t[124]!==c||t[125]!==g?(rt=c?(0,V.jsx)(Ie,{tg:z,updateTelegram:g,ch:i,dmOpts:ee,groupOpts:N,replyOpts:F,streamOpts:ne,tgAccountsDraft:y,setTgAccountsDraft:S,tgAccountsError:E,onTgAccountsBlur:k}):null,t[114]=i,t[115]=ee,t[116]=N,t[117]=k,t[118]=F,t[119]=S,t[120]=ne,t[121]=z,t[122]=y,t[123]=E,t[124]=c,t[125]=g,t[126]=rt):rt=t[126];let it;t[127]!==Fe||t[128]!==Ke||t[129]!==Xe||t[130]!==nt||t[131]!==rt?(it=(0,V.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Fe,Ke,Xe,nt,rt]}),t[127]=Fe,t[128]=Ke,t[129]=Xe,t[130]=nt,t[131]=rt,t[132]=it):it=t[132];let at;t[133]===r?at=t[134]:(at=()=>r(!1),t[133]=r,t[134]=at);let ot;t[135]!==i.modalCancel||t[136]!==at?(ot=(0,V.jsx)(u,{type:`button`,variant:`secondary`,onClick:at,children:i.modalCancel}),t[135]=i.modalCancel,t[136]=at,t[137]=ot):ot=t[137];let st=!re||L,ct;t[138]!==i.discard||t[139]!==ae||t[140]!==st?(ct=(0,V.jsx)(u,{type:`button`,variant:`secondary`,disabled:st,onClick:ae,children:i.discard}),t[138]=i.discard,t[139]=ae,t[140]=st,t[141]=ct):ct=t[141];let lt=!re||L,ut;t[142]!==r||t[143]!==ie?(ut=async()=>{await ie()&&r(!1)},t[142]=r,t[143]=ie,t[144]=ut):ut=t[144];let dt=L?i.saving:i.save,ft;t[145]!==lt||t[146]!==ut||t[147]!==dt?(ft=(0,V.jsx)(u,{type:`button`,variant:`primary`,disabled:lt,onClick:ut,children:dt}),t[145]=lt,t[146]=ut,t[147]=dt,t[148]=ft):ft=t[148];let pt;t[149]!==ot||t[150]!==ct||t[151]!==ft?(pt=(0,V.jsxs)(`div`,{className:`mt-8 flex flex-wrap justify-end gap-2 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:[ot,ct,ft]}),t[149]=ot,t[150]=ct,t[151]=ft,t[152]=pt):pt=t[152];let mt;t[153]!==me||t[154]!==be||t[155]!==it||t[156]!==pt?(mt=(0,V.jsxs)(d,{children:[G,(0,V.jsxs)(R,{className:le,onOpenAutoFocus:Be,children:[me,be,it,pt]})]}),t[153]=me,t[154]=be,t[155]=it,t[156]=pt,t[157]=mt):mt=t[157];let ht;return t[158]!==r||t[159]!==n||t[160]!==mt?(ht=(0,V.jsx)(x,{open:n,onOpenChange:r,children:mt}),t[158]=r,t[159]=n,t[160]=mt,t[161]=ht):ht=t[161],ht}function Re(e){return!e}function ze(e){return!e}function Be(e){return e.preventDefault()}function Ve(){let e=g(e=>e.language),t=S(e),n=t.channelsSettings,r=!!y(e=>e.token),[o,s]=(0,$.useState)(null),[c,l]=(0,$.useState)(null),[u,d]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(!1),[v,b]=(0,$.useState)(!1),[x,C]=(0,$.useState)(!1),[w,T]=(0,$.useState)(!1),[E,D]=(0,$.useState)(null),[O,k]=(0,$.useState)(null),[A,ee]=(0,$.useState)(null),[j,M]=(0,$.useState)(!1),[N,P]=(0,$.useState)(!1),[te,F]=(0,$.useState)(!1),[ne,I]=(0,$.useState)(!1),[L,R]=(0,$.useState)(!1),[re,ie]=(0,$.useState)(!1),[ae,z]=(0,$.useState)(!1),[oe,B]=(0,$.useState)(``),[se,V]=(0,$.useState)(``),[H,U]=(0,$.useState)(``),[ce,W]=(0,$.useState)(``),[G,K]=(0,$.useState)(``),[le,q]=(0,$.useState)(``),{data:J}=i(r?`gateway-chat-agents-ch`:null,a,{revalidateOnFocus:!1}),{data:Y,error:X,isLoading:Z,mutate:ue}=_(r),de=(0,$.useMemo)(()=>Y?.payload?.config===void 0?null:ke(Y.payload.config),[Y]),pe=(0,$.useMemo)(()=>!o||!c?!1:JSON.stringify(o)!==JSON.stringify(c),[o,c]);(0,$.useEffect)(()=>{if(!r){s(null),l(null);return}de!==null&&(pe||(s(de),l(structuredClone(de)),B(JSON.stringify(de.telegram.accounts??{},null,2)),V(``),U(JSON.stringify(de.weixin.accounts??{},null,2)),W(``),K(JSON.stringify(de.feishu?.accounts??{},null,2)),q(``),h(!1)))},[r,de,pe]);let me=!!(r&&Z&&Y===void 0&&!X),he=X instanceof Error?X.message:X?String(X):null,Q=(0,$.useCallback)((e,t,n)=>{s(r=>{if(!r)return null;let i=e===`telegram`?`telegram`:e===`weixin`?`weixin`:`feishu`;return{...r,channelAgentRoutes:{...r.channelAgentRoutes,[i]:{...r.channelAgentRoutes[i],[t]:n.trim().toLowerCase()}}}})},[]),ge=(0,$.useCallback)(e=>{s(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),_e=(0,$.useCallback)(e=>{s(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),ve=(0,$.useCallback)(e=>{s(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]);return{language:e,m:t,ch:n,hasToken:r,loading:me,fetchError:he,mutate:ue,form:o,baseline:c,dirty:pe,saving:u,error:f,saveOk:m,weixinModalOpen:v,setWeixinModalOpen:b,telegramModalOpen:x,setTelegramModalOpen:C,feishuModalOpen:w,setFeishuModalOpen:T,removeTarget:E,setRemoveTarget:D,weixinSuccessBanner:O,setWeixinSuccessBanner:k,feishuSetupSuccessBanner:A,tgAdvanced:j,setTgAdvanced:M,showToken:N,setShowToken:P,showFeishuSecret:te,setShowFeishuSecret:F,showFeishuWebhookSecrets:ne,setShowFeishuWebhookSecrets:I,copied:L,feishuCopied:re,feishuWebhookCopied:ae,tgAccountsDraft:oe,setTgAccountsDraft:B,tgAccountsError:se,wxAccountsDraft:H,setWxAccountsDraft:U,wxAccountsError:ce,feishuAccountsDraft:G,setFeishuAccountsDraft:K,feishuAccountsError:le,chatAgents:J,updateChannelAgentRoute:Q,updateTelegram:ge,updateWeixin:_e,updateFeishu:ve,save:(0,$.useCallback)(async()=>{if(!o||u)return!1;d(!0),p(null),h(!1);try{let e=await Me(o);s(e);let t=structuredClone(e);return l(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),V(``),U(JSON.stringify(t.weixin.accounts??{},null,2)),W(``),K(JSON.stringify(t.feishu?.accounts??{},null,2)),q(``),h(!0),window.setTimeout(()=>h(!1),2500),!0}catch(e){return p(e instanceof Error?e.message:n.saveError),!1}finally{d(!1)}},[o,u,n.saveError]),discard:(0,$.useCallback)(()=>{if(!c)return;let e=structuredClone(c);s(e),B(JSON.stringify(e.telegram.accounts??{},null,2)),V(``),U(JSON.stringify(e.weixin.accounts??{},null,2)),W(``),K(JSON.stringify(e.feishu?.accounts??{},null,2)),q(``),p(null),h(!1)},[c]),toggleChannelEnabled:(0,$.useCallback)(async(e,t)=>{if(!o||u)return;let r=o,i=e===`weixin`?{...o,weixin:{...o.weixin,enabled:t}}:e===`telegram`?{...o,telegram:{...o.telegram,enabled:t}}:{...o,feishu:{...o.feishu,enabled:t}};s(i),d(!0),p(null);try{let e=await Me(i);s(e);let t=structuredClone(e);l(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),U(JSON.stringify(t.weixin.accounts??{},null,2)),K(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){p(e instanceof Error?e.message:n.saveError),s(r)}finally{d(!1)}},[o,u,n.saveError]),removeChannel:(0,$.useCallback)(async()=>{if(!o||!E||u)return;let e=Oe(),t=E===`weixin`?{...o,weixin:e.weixin}:E===`telegram`?{...o,telegram:e.telegram}:{...o,feishu:e.feishu};d(!0),p(null);try{let e=await Me(t);s(e);let n=structuredClone(e);l(n),B(JSON.stringify(n.telegram.accounts??{},null,2)),U(JSON.stringify(n.weixin.accounts??{},null,2)),V(``),W(``),K(JSON.stringify(n.feishu?.accounts??{},null,2)),q(``),D(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:n.saveError)}finally{d(!1)}},[o,E,u,n.saveError]),copyToken:(0,$.useCallback)(async()=>{let e=o?fe(o.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),R(!0),window.setTimeout(()=>R(!1),2e3))},[o]),handleFeishuQrSetupSuccess:(0,$.useCallback)(e=>{ve({appId:e.appId,domain:e.domain,enabled:!0}),ue(),ee(n.feishuQrSetupSuccess),window.setTimeout(()=>ee(null),4e3)},[ve,ue,n.feishuQrSetupSuccess]),copyFeishuSecret:(0,$.useCallback)(async()=>{let e=o?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),ie(!0),window.setTimeout(()=>ie(!1),2e3))},[o]),copyFeishuWebhookConfig:(0,$.useCallback)(async()=>{let e=o?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await navigator.clipboard.writeText(JSON.stringify(t,null,2)).catch(()=>{}),z(!0),window.setTimeout(()=>z(!1),2e3)},[o]),onTgAccountsBlur:(0,$.useCallback)(()=>{if(!o)return;let e=oe.trim();if(!e){ge({accounts:{}}),V(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);ge({accounts:t}),V(``)}catch(e){V(e instanceof Error?e.message:n.jsonInvalid)}},[o,oe,ge,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,$.useCallback)(()=>{if(!o)return;let e=H.trim();if(!e){_e({accounts:{}}),W(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);_e({accounts:t}),W(``)}catch(e){W(e instanceof Error?e.message:n.jsonInvalid)}},[o,H,_e,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,$.useCallback)(()=>{if(!o)return;let e=G.trim();if(!e){ve({accounts:{}}),q(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);ve({accounts:t}),q(``)}catch(e){q(e instanceof Error?e.message:n.jsonInvalid)}},[o,G,ve,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,$.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,$.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,$.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,$.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}function He({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:i}){let[a,o]=(0,$.useState)(!1),[c,l]=(0,$.useState)(null),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),[g,_]=(0,$.useState)(null),[v,y]=(0,$.useState)(null),[S,E]=(0,$.useState)(!1),D=(0,$.useCallback)(async()=>{h(null),_(null),l(null),o(!0);try{let e=await Ae();p(e.qrcodeUrl),l(e.sessionKey)}catch(e){h(e instanceof Error?e.message:`Start failed`)}finally{o(!1)}},[]);(0,$.useEffect)(()=>{if(!e){l(null),p(null),h(null),y(null),E(!1),_(null);return}D()},[e,D]),(0,$.useEffect)(()=>{if(!c)return;let e=!1,i,a=async()=>{try{let a=await je(c);if(e)return;if(a.phase===`polling`){p(a.qrcodeUrl),a.qrStatus===`scaned`?_(n.weixinQrLoginScanned):_(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),l(null),a.ok?(p(null),t(!1),await r()):(h(a.message),p(null));return}a.phase===`unknown`&&_(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),h(t instanceof Error?t.message:`Request failed`),l(null),p(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[c,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,$.useEffect)(()=>{if(!f){y(null),E(!1);return}let e=!1;return E(!1),Ee.toDataURL(f,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||y(t)}).catch(()=>{e||(E(!0),y(null))}),()=>{e=!0}},[f]);let O=!!(f&&c),k=e&&!m&&!O;return(0,V.jsx)(x,{open:e,onOpenChange:t,children:(0,V.jsxs)(d,{children:[(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),(0,V.jsxs)(R,{className:M(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,P,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,V.jsx)(b,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.weixinQrModalCloseAria,children:(0,V.jsx)(T,{className:`size-4`})})}),(0,V.jsx)(w,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,V.jsx)(s,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,V.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[m?(0,V.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:m}):null,!m&&(O||k)?(0,V.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,V.jsx)(`p`,{className:M(`min-h-[1.25rem] text-center text-sm`,g&&!k?`text-accent`:`text-fg-muted`),children:k?n.weixinQrLoginBusy:g??`\xA0`}),(0,V.jsxs)(`div`,{className:M(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,k&&`bg-surface-muted/40 dark:bg-surface-base`),children:[k?(0,V.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,O&&f&&!m&&v&&!S?(0,V.jsx)(`img`,{src:v,alt:``,className:`relative z-[1] size-full object-contain`}):null,O&&f&&!m&&!v&&!S&&!k?(0,V.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,O&&f&&!m&&S?(0,V.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,V.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.weixinQrImageError}),(0,V.jsxs)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,V.jsx)(ee,{className:`size-3 shrink-0`}),n.weixinQrOpenLink]})]}):null]})]}):null]}),(0,V.jsx)(`div`,{className:`mt-6`,children:(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:a,onClick:()=>void D(),children:a?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),i?(0,V.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function Ue(e){let t=(0,se.c)(116),{wx:n,updateWeixin:r,ch:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,channelAgentRoutesWx:d,defaultAgentId:f,agentItems:p,onAgentRouteChange:m,routingDisabled:h}=e,g;t[0]===i.weixinAllowFrom?g=t[1]:(g=(0,V.jsx)(Q,{children:i.weixinAllowFrom}),t[0]=i.weixinAllowFrom,t[1]=g);let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[2]=_):_=t[2];let v;t[3]===n.allowFrom?v=t[4]:(v=n.allowFrom.join(`, `),t[3]=n.allowFrom,t[4]=v);let y;t[5]===r?y=t[6]:(y=e=>r({allowFrom:e.target.value.split(/[,\n]/).map(We).filter(Boolean)}),t[5]=r,t[6]=y);let b;t[7]!==v||t[8]!==y?(b=(0,V.jsx)(`textarea`,{className:_,rows:2,placeholder:`wxid_..., openid_...`,value:v,onChange:y}),t[7]=v,t[8]=y,t[9]=b):b=t[9];let x;t[10]===i.weixinAllowFromDesc?x=t[11]:(x=(0,V.jsx)(ge,{children:i.weixinAllowFromDesc}),t[10]=i.weixinAllowFromDesc,t[11]=x);let S;t[12]!==g||t[13]!==b||t[14]!==x?(S=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[g,b,x]}),t[12]=g,t[13]=b,t[14]=x,t[15]=S):S=t[15];let C;t[16]===r?C=t[17]:(C=e=>r({dmPolicy:e}),t[16]=r,t[17]=C);let w;t[18]!==i.dmPolicy||t[19]!==a||t[20]!==C||t[21]!==n.dmPolicy?(w=(0,V.jsx)(_e,{label:i.dmPolicy,value:n.dmPolicy,onChange:C,options:a}),t[18]=i.dmPolicy,t[19]=a,t[20]=C,t[21]=n.dmPolicy,t[22]=w):w=t[22];let T;t[23]===r?T=t[24]:(T=e=>r({streamMode:e}),t[23]=r,t[24]=T);let E;t[25]!==i.streamMode||t[26]!==o||t[27]!==T||t[28]!==n.streamMode?(E=(0,V.jsx)(_e,{label:i.streamMode,value:n.streamMode,onChange:T,options:o}),t[25]=i.streamMode,t[26]=o,t[27]=T,t[28]=n.streamMode,t[29]=E):E=t[29];let D;t[30]===i.historyLimit?D=t[31]:(D=(0,V.jsx)(Q,{children:i.historyLimit}),t[30]=i.historyLimit,t[31]=D);let O;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(O=X(),t[32]=O):O=t[32];let k;t[33]===r?k=t[34]:(k=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[33]=r,t[34]=k);let A;t[35]!==k||t[36]!==n.historyLimit?(A=(0,V.jsx)(`input`,{type:`number`,min:10,max:200,className:O,value:n.historyLimit,onChange:k}),t[35]=k,t[36]=n.historyLimit,t[37]=A):A=t[37];let ee;t[38]!==D||t[39]!==A?(ee=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[D,A]}),t[38]=D,t[39]=A,t[40]=ee):ee=t[40];let j;t[41]===i.textChunkLimit?j=t[42]:(j=(0,V.jsx)(Q,{children:i.textChunkLimit}),t[41]=i.textChunkLimit,t[42]=j);let N;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(N=X(),t[43]=N):N=t[43];let P;t[44]===r?P=t[45]:(P=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[44]=r,t[45]=P);let te;t[46]!==P||t[47]!==n.textChunkLimit?(te=(0,V.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:N,value:n.textChunkLimit,onChange:P}),t[46]=P,t[47]=n.textChunkLimit,t[48]=te):te=t[48];let F;t[49]!==j||t[50]!==te?(F=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[j,te]}),t[49]=j,t[50]=te,t[51]=F):F=t[51];let ne;t[52]!==ee||t[53]!==F?(ne=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ee,F]}),t[52]=ee,t[53]=F,t[54]=ne):ne=t[54];let I;t[55]===i.weixinRouteTag?I=t[56]:(I=(0,V.jsx)(Q,{children:i.weixinRouteTag}),t[55]=i.weixinRouteTag,t[56]=I);let L;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(L=X(),t[57]=L):L=t[57];let R;t[58]===r?R=t[59]:(R=e=>r({routeTag:e.target.value}),t[58]=r,t[59]=R);let re;t[60]!==i.routeTagPlaceholder||t[61]!==R||t[62]!==n.routeTag?(re=(0,V.jsx)(`input`,{className:L,value:n.routeTag,onChange:R,placeholder:i.routeTagPlaceholder}),t[60]=i.routeTagPlaceholder,t[61]=R,t[62]=n.routeTag,t[63]=re):re=t[63];let ie;t[64]===i.weixinRouteTagDesc?ie=t[65]:(ie=(0,V.jsx)(ge,{children:i.weixinRouteTagDesc}),t[64]=i.weixinRouteTagDesc,t[65]=ie);let ae;t[66]!==I||t[67]!==re||t[68]!==ie?(ae=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[I,re,ie]}),t[66]=I,t[67]=re,t[68]=ie,t[69]=ae):ae=t[69];let z;t[70]===r?z=t[71]:(z=e=>r({debug:e.target.checked}),t[70]=r,t[71]=z);let oe;t[72]!==z||t[73]!==n.debug?(oe=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:z}),t[72]=z,t[73]=n.debug,t[74]=oe):oe=t[74];let B;t[75]!==i.weixinDebug||t[76]!==oe?(B=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[oe,i.weixinDebug]}),t[75]=i.weixinDebug,t[76]=oe,t[77]=B):B=t[77];let H;t[78]===i.weixinDebugDesc?H=t[79]:(H=(0,V.jsx)(ge,{children:i.weixinDebugDesc}),t[78]=i.weixinDebugDesc,t[79]=H);let U;t[80]===i.weixinAccountsJson?U=t[81]:(U=(0,V.jsx)(Q,{children:i.weixinAccountsJson}),t[80]=i.weixinAccountsJson,t[81]=U);let ce;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ce=M(X(),`min-h-[140px] resize-y font-mono text-xs`),t[82]=ce):ce=t[82];let W;t[83]===c?W=t[84]:(W=e=>c(e.target.value),t[83]=c,t[84]=W);let G;t[85]!==u||t[86]!==W||t[87]!==s?(G=(0,V.jsx)(`textarea`,{className:ce,spellCheck:!1,value:s,onChange:W,onBlur:u,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),t[85]=u,t[86]=W,t[87]=s,t[88]=G):G=t[88];let K;t[89]!==i.weixinAccountsJsonDesc||t[90]!==l?(K=l?(0,V.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):(0,V.jsx)(ge,{children:i.weixinAccountsJsonDesc}),t[89]=i.weixinAccountsJsonDesc,t[90]=l,t[91]=K):K=t[91];let q;t[92]!==U||t[93]!==G||t[94]!==K?(q=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[U,G,K]}),t[92]=U,t[93]=G,t[94]=K,t[95]=q):q=t[95];let J;t[96]===n?J=t[97]:(J=le(n),t[96]=n,t[97]=J);let Y;t[98]!==p||t[99]!==i||t[100]!==d||t[101]!==f||t[102]!==m||t[103]!==h||t[104]!==J?(Y=(0,V.jsx)(ye,{accountIds:J,routes:d,defaultAgentId:f,agentItems:p,disabled:h,onChange:m,ch:i}),t[98]=p,t[99]=i,t[100]=d,t[101]=f,t[102]=m,t[103]=h,t[104]=J,t[105]=Y):Y=t[105];let Z;return t[106]!==E||t[107]!==ne||t[108]!==ae||t[109]!==B||t[110]!==H||t[111]!==q||t[112]!==Y||t[113]!==S||t[114]!==w?(Z=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[S,w,E,ne,ae,B,H,q,Y]}),t[106]=E,t[107]=ne,t[108]=ae,t[109]=B,t[110]=H,t[111]=q,t[112]=Y,t[113]=S,t[114]=w,t[115]=Z):Z=t[115],Z}function We(e){return e.trim()}function Ge(e){let t=(0,se.c)(53),{ch:n,wx:r,updateWeixin:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:d,form:f,chatAgents:p,onAgentRouteChange:m,saving:h,dirty:g,save:_,discard:y}=e,b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,V.jsx)(v,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[0]=b):b=t[0];let x;t[1]===n.advancedShow?x=t[2]:(x=(0,V.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[b,n.advancedShow]})}),t[1]=n.advancedShow,t[2]=x);let S;t[3]===n.weixinAdvancedHint?S=t[4]:(S=(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.weixinAdvancedHint}),t[3]=n.weixinAdvancedHint,t[4]=S);let C;t[5]===i?C=t[6]:(C=e=>i({enabled:e.target.checked}),t[5]=i,t[6]=C);let w;t[7]!==C||t[8]!==r.enabled?(w=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.enabled,onChange:C}),t[7]=C,t[8]=r.enabled,t[9]=w):w=t[9];let T;t[10]===n.enableWeixinAria?T=t[11]:(T=(0,V.jsx)(`span`,{children:n.enableWeixinAria}),t[10]=n.enableWeixinAria,t[11]=T);let E;t[12]!==w||t[13]!==T?(E=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[w,T]}),t[12]=w,t[13]=T,t[14]=E):E=t[14];let D;t[15]===p?.items?D=t[16]:(D=p?.items??[],t[15]=p?.items,t[16]=D);let O;t[17]!==n||t[18]!==a||t[19]!==f.channelAgentRoutes.weixin||t[20]!==f.defaultAgentId||t[21]!==m||t[22]!==d||t[23]!==h||t[24]!==c||t[25]!==o||t[26]!==D||t[27]!==i||t[28]!==r||t[29]!==s||t[30]!==l?(O=(0,V.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,V.jsx)(Ue,{wx:r,updateWeixin:i,ch:n,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:d,channelAgentRoutesWx:f.channelAgentRoutes.weixin,defaultAgentId:f.defaultAgentId,agentItems:D,onAgentRouteChange:m,routingDisabled:h})}),t[17]=n,t[18]=a,t[19]=f.channelAgentRoutes.weixin,t[20]=f.defaultAgentId,t[21]=m,t[22]=d,t[23]=h,t[24]=c,t[25]=o,t[26]=D,t[27]=i,t[28]=r,t[29]=s,t[30]=l,t[31]=O):O=t[31];let k=!g||h,A;t[32]!==n.discard||t[33]!==y||t[34]!==k?(A=(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:k,onClick:y,children:n.discard}),t[32]=n.discard,t[33]=y,t[34]=k,t[35]=A):A=t[35];let ee=!g||h,j;t[36]===_?j=t[37]:(j=async()=>{await _()},t[36]=_,t[37]=j);let M=h?n.saving:n.save,N;t[38]!==ee||t[39]!==j||t[40]!==M?(N=(0,V.jsx)(u,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:ee,onClick:j,children:M}),t[38]=ee,t[39]=j,t[40]=M,t[41]=N):N=t[41];let P;t[42]!==A||t[43]!==N?(P=(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[A,N]}),t[42]=A,t[43]=N,t[44]=P):P=t[44];let te;t[45]!==P||t[46]!==S||t[47]!==E||t[48]!==O?(te=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[S,E,O,P]}),t[45]=P,t[46]=S,t[47]=E,t[48]=O,t[49]=te):te=t[49];let F;return t[50]!==te||t[51]!==x?(F=(0,V.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[x,te]}),t[50]=te,t[51]=x,t[52]=F):F=t[52],F}function Ke(){let e=(0,se.c)(221),{language:t,m:n,ch:r,hasToken:i,loading:a,fetchError:o,mutate:s,form:c,baseline:l,dirty:d,saving:p,error:m,saveOk:h,weixinModalOpen:g,setWeixinModalOpen:_,telegramModalOpen:v,setTelegramModalOpen:y,feishuModalOpen:b,setFeishuModalOpen:x,removeTarget:S,setRemoveTarget:C,weixinSuccessBanner:w,setWeixinSuccessBanner:T,feishuSetupSuccessBanner:D,tgAdvanced:O,setTgAdvanced:A,showToken:j,setShowToken:M,showFeishuSecret:N,setShowFeishuSecret:P,showFeishuWebhookSecrets:te,setShowFeishuWebhookSecrets:F,copied:ne,feishuCopied:I,feishuWebhookCopied:L,tgAccountsDraft:R,setTgAccountsDraft:re,tgAccountsError:ie,wxAccountsDraft:ae,setWxAccountsDraft:z,wxAccountsError:oe,feishuAccountsDraft:B,setFeishuAccountsDraft:ce,feishuAccountsError:W,chatAgents:G,updateChannelAgentRoute:K,updateTelegram:le,updateWeixin:q,updateFeishu:J,save:Y,discard:X,toggleChannelEnabled:Z,removeChannel:ue,copyToken:de,handleFeishuQrSetupSuccess:fe,copyFeishuSecret:Q,copyFeishuWebhookConfig:ge,onTgAccountsBlur:_e,onWxAccountsBlur:ve,onFeishuAccountsBlur:ye,dmOpts:be,groupOpts:Se,replyOpts:Ce,streamOpts:we}=Ve();if(!i){let t;e[0]===n.settingsSections.channels?t=e[1]:(t=(0,V.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.channels}),e[0]=n.settingsSections.channels,e[1]=t);let i;e[2]===r.needToken?i=e[3]:(i=(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken}),e[2]=r.needToken,e[3]=i);let a;return e[4]!==t||e[5]!==i?(a=(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[t,i]}),e[4]=t,e[5]=i,e[6]=a):a=e[6],a}if(a){let t,n;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,V.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),n=(0,V.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),e[7]=t,e[8]=n):(t=e[7],n=e[8]);let i;return e[9]===r.loading?i=e[10]:(i=(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,(0,V.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.loading})]}),e[9]=r.loading,e[10]=i),i}if(!c){let t=m??o??r.loadError,n;e[11]===t?n=e[12]:(n=(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t}),e[11]=t,e[12]=n);let i;e[13]===s?i=e[14]:(i=()=>void s(),e[13]=s,e[14]=i);let a;e[15]!==r.retry||e[16]!==i?(a=(0,V.jsx)(u,{type:`button`,variant:`secondary`,onClick:i,children:r.retry}),e[15]=r.retry,e[16]=i,e[17]=a):a=e[17];let c;return e[18]!==n||e[19]!==a?(c=(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[n,a]}),e[18]=n,e[19]=a,e[20]=c):c=e[20],c}let Te=c.weixin,$=c.telegram,Ee=c.feishu,De;e[21]===Te?De=e[22]:(De=me(Te),e[21]=Te,e[22]=De);let Oe=De,ke;e[23]===$?ke=e[24]:(ke=pe($),e[23]=$,e[24]=ke);let Ae=ke,je;e[25]===Ee?je=e[26]:(je=he(Ee),e[25]=Ee,e[26]=je);let Me=je,Ne;e[27]!==l||e[28]!==r||e[29]!==G||e[30]!==Q||e[31]!==ge||e[32]!==d||e[33]!==X||e[34]!==be||e[35]!==B||e[36]!==W||e[37]!==I||e[38]!==L||e[39]!==c||e[40]!==Se||e[41]!==ye||e[42]!==Y||e[43]!==p||e[44]!==ce||e[45]!==P||e[46]!==F||e[47]!==N||e[48]!==te||e[49]!==K||e[50]!==J?(Ne=(0,V.jsx)(xe,{ch:r,form:c,baseline:l,showFeishuSecret:N,setShowFeishuSecret:P,showFeishuWebhookSecrets:te,setShowFeishuWebhookSecrets:F,feishuCopied:I,feishuWebhookCopied:L,copyFeishuSecret:Q,copyFeishuWebhookConfig:ge,updateFeishu:J,updateChannelAgentRoute:K,feishuAccountsDraft:B,setFeishuAccountsDraft:ce,feishuAccountsError:W,onFeishuAccountsBlur:ye,dmOpts:be,groupOpts:Se,chatAgents:G,saving:p,dirty:d,save:Y,discard:X}),e[27]=l,e[28]=r,e[29]=G,e[30]=Q,e[31]=ge,e[32]=d,e[33]=X,e[34]=be,e[35]=B,e[36]=W,e[37]=I,e[38]=L,e[39]=c,e[40]=Se,e[41]=ye,e[42]=Y,e[43]=p,e[44]=ce,e[45]=P,e[46]=F,e[47]=N,e[48]=te,e[49]=K,e[50]=J,e[51]=Ne):Ne=e[51];let Pe=Ne,Ie;e[52]===K?Ie=e[53]:(Ie=(e,t)=>K(`weixin`,e,t),e[52]=K,e[53]=Ie);let Re;e[54]!==r||e[55]!==G||e[56]!==d||e[57]!==X||e[58]!==be||e[59]!==c||e[60]!==ve||e[61]!==Y||e[62]!==p||e[63]!==z||e[64]!==we||e[65]!==Ie||e[66]!==q||e[67]!==Te||e[68]!==ae||e[69]!==oe?(Re=(0,V.jsx)(Ge,{ch:r,wx:Te,updateWeixin:q,dmOpts:be,streamOpts:we,wxAccountsDraft:ae,setWxAccountsDraft:z,wxAccountsError:oe,onWxAccountsBlur:ve,form:c,chatAgents:G,onAgentRouteChange:Ie,saving:p,dirty:d,save:Y,discard:X}),e[54]=r,e[55]=G,e[56]=d,e[57]=X,e[58]=be,e[59]=c,e[60]=ve,e[61]=Y,e[62]=p,e[63]=z,e[64]=we,e[65]=Ie,e[66]=q,e[67]=Te,e[68]=ae,e[69]=oe,e[70]=Re):Re=e[70];let ze=Re,Be;e[71]===n.settingsSections.channels?Be=e[72]:(Be=(0,V.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.channels}),e[71]=n.settingsSections.channels,e[72]=Be);let Ue;e[73]===r.subtitle?Ue=e[74]:(Ue=(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[73]=r.subtitle,e[74]=Ue);let We;e[75]===t?We=e[76]:(We=k(t,`channels`),e[75]=t,e[76]=We);let Ke;e[77]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,V.jsx)(ee,{className:`size-3.5`}),e[77]=Ke):Ke=e[77];let qe;e[78]!==r.docsLink||e[79]!==We?(qe=(0,V.jsxs)(`a`,{href:We,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,Ke]}),e[78]=r.docsLink,e[79]=We,e[80]=qe):qe=e[80];let Je;e[81]!==qe||e[82]!==Be||e[83]!==Ue?(Je=(0,V.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[Be,Ue,qe]}),e[81]=qe,e[82]=Be,e[83]=Ue,e[84]=Je):Je=e[84];let Ye;e[85]!==r.unsavedHint||e[86]!==d?(Ye=d?(0,V.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,e[85]=r.unsavedHint,e[86]=d,e[87]=Ye):Ye=e[87];let Xe;e[88]!==r.saved||e[89]!==h?(Xe=h?(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.saved}):null,e[88]=r.saved,e[89]=h,e[90]=Xe):Xe=e[90];let Ze;e[91]===m?Ze=e[92]:(Ze=m?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,e[91]=m,e[92]=Ze);let Qe;e[93]===w?Qe=e[94]:(Qe=w?(0,V.jsx)(`p`,{className:`text-xs text-accent`,children:w}):null,e[93]=w,e[94]=Qe);let $e;e[95]===D?$e=e[96]:($e=D?(0,V.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:D}):null,e[95]=D,e[96]=$e);let et;e[97]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,V.jsx)(f,{className:`size-6 text-accent`,strokeWidth:1.75}),e[97]=et):et=e[97];let tt;e[98]===Z?tt=e[99]:(tt=e=>void Z(`weixin`,e),e[98]=Z,e[99]=tt);let nt,rt;e[100]===_?(nt=e[101],rt=e[102]):(nt=()=>_(!0),rt=()=>_(!0),e[100]=_,e[101]=nt,e[102]=rt);let it;e[103]===C?it=e[104]:(it=()=>C(`weixin`),e[103]=C,e[104]=it);let at;e[105]!==r||e[106]!==p||e[107]!==tt||e[108]!==nt||e[109]!==rt||e[110]!==it||e[111]!==Oe||e[112]!==Te.enabled?(at=(0,V.jsx)(H,{icon:et,title:r.weixinTitle,subtitle:r.weixinSubtitle,configured:Oe,enabled:Te.enabled,toggleDisabled:p,onToggle:tt,onConfigure:nt,onEdit:rt,onRemove:it,ch:r}),e[105]=r,e[106]=p,e[107]=tt,e[108]=nt,e[109]=rt,e[110]=it,e[111]=Oe,e[112]=Te.enabled,e[113]=at):at=e[113];let ot;e[114]===Symbol.for(`react.memo_cache_sentinel`)?(ot=(0,V.jsx)(E,{className:`size-6 text-accent`,strokeWidth:1.75}),e[114]=ot):ot=e[114];let st;e[115]===Z?st=e[116]:(st=e=>void Z(`telegram`,e),e[115]=Z,e[116]=st);let ct,lt;e[117]===y?(ct=e[118],lt=e[119]):(ct=()=>y(!0),lt=()=>y(!0),e[117]=y,e[118]=ct,e[119]=lt);let ut;e[120]===C?ut=e[121]:(ut=()=>C(`telegram`),e[120]=C,e[121]=ut);let dt;e[122]!==r||e[123]!==p||e[124]!==st||e[125]!==ct||e[126]!==lt||e[127]!==ut||e[128]!==Ae||e[129]!==$.enabled?(dt=(0,V.jsx)(H,{icon:ot,title:r.telegramTitle,subtitle:r.telegramSubtitle,configured:Ae,enabled:$.enabled,toggleDisabled:p,onToggle:st,onConfigure:ct,onEdit:lt,onRemove:ut,ch:r}),e[122]=r,e[123]=p,e[124]=st,e[125]=ct,e[126]=lt,e[127]=ut,e[128]=Ae,e[129]=$.enabled,e[130]=dt):dt=e[130];let ft;e[131]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,V.jsx)(f,{className:`size-6 text-accent`,strokeWidth:1.75}),e[131]=ft):ft=e[131];let pt;e[132]===Z?pt=e[133]:(pt=e=>void Z(`feishu`,e),e[132]=Z,e[133]=pt);let mt,ht;e[134]===x?(mt=e[135],ht=e[136]):(mt=()=>x(!0),ht=()=>x(!0),e[134]=x,e[135]=mt,e[136]=ht);let gt;e[137]===C?gt=e[138]:(gt=()=>C(`feishu`),e[137]=C,e[138]=gt);let _t;e[139]!==r||e[140]!==Me||e[141]!==Ee.enabled||e[142]!==p||e[143]!==pt||e[144]!==mt||e[145]!==ht||e[146]!==gt?(_t=(0,V.jsx)(H,{icon:ft,title:r.feishuTitle,subtitle:r.feishuSubtitle,configured:Me,enabled:Ee.enabled,toggleDisabled:p,onToggle:pt,onConfigure:mt,onEdit:ht,onRemove:gt,ch:r}),e[139]=r,e[140]=Me,e[141]=Ee.enabled,e[142]=p,e[143]=pt,e[144]=mt,e[145]=ht,e[146]=gt,e[147]=_t):_t=e[147];let vt;e[148]!==at||e[149]!==dt||e[150]!==_t?(vt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[at,dt,_t]}),e[148]=at,e[149]=dt,e[150]=_t,e[151]=vt):vt=e[151];let yt;e[152]!==r.weixinQrLoginSuccess||e[153]!==s||e[154]!==T?(yt=async()=>{await s(),T(r.weixinQrLoginSuccess),window.setTimeout(()=>T(null),4e3)},e[152]=r.weixinQrLoginSuccess,e[153]=s,e[154]=T,e[155]=yt):yt=e[155];let bt;e[156]!==r||e[157]!==_||e[158]!==yt||e[159]!==g||e[160]!==ze?(bt=(0,V.jsx)(He,{open:g,onOpenChange:_,ch:r,onLoginSuccess:yt,moreSettings:ze}),e[156]=r,e[157]=_,e[158]=yt,e[159]=g,e[160]=ze,e[161]=bt):bt=e[161];let xt;e[162]!==l||e[163]!==r||e[164]!==G||e[165]!==ne||e[166]!==de||e[167]!==d||e[168]!==X||e[169]!==be||e[170]!==c||e[171]!==Se||e[172]!==_e||e[173]!==Ce||e[174]!==Y||e[175]!==p||e[176]!==M||e[177]!==y||e[178]!==re||e[179]!==A||e[180]!==j||e[181]!==we||e[182]!==v||e[183]!==R||e[184]!==ie||e[185]!==O||e[186]!==K||e[187]!==le?(xt=(0,V.jsx)(Le,{open:v,onOpenChange:y,ch:r,form:c,baseline:l,tgAdvanced:O,setTgAdvanced:A,showToken:j,setShowToken:M,copied:ne,copyToken:de,updateTelegram:le,updateChannelAgentRoute:K,tgAccountsDraft:R,setTgAccountsDraft:re,tgAccountsError:ie,onTgAccountsBlur:_e,dmOpts:be,groupOpts:Se,replyOpts:Ce,streamOpts:we,chatAgents:G,saving:p,dirty:d,save:Y,discard:X}),e[162]=l,e[163]=r,e[164]=G,e[165]=ne,e[166]=de,e[167]=d,e[168]=X,e[169]=be,e[170]=c,e[171]=Se,e[172]=_e,e[173]=Ce,e[174]=Y,e[175]=p,e[176]=M,e[177]=y,e[178]=re,e[179]=A,e[180]=j,e[181]=we,e[182]=v,e[183]=R,e[184]=ie,e[185]=O,e[186]=K,e[187]=le,e[188]=xt):xt=e[188];let St;e[189]!==r||e[190]!==b||e[191]!==Pe||e[192]!==fe||e[193]!==x?(St=(0,V.jsx)(Fe,{open:b,onOpenChange:x,ch:r,onSetupSuccess:fe,moreSettings:Pe}),e[189]=r,e[190]=b,e[191]=Pe,e[192]=fe,e[193]=x,e[194]=St):St=e[194];let Ct=S!==null,wt;e[195]===C?wt=e[196]:(wt=e=>{e||C(null)},e[195]=C,e[196]=wt);let Tt;e[197]===C?Tt=e[198]:(Tt=()=>C(null),e[197]=C,e[198]=Tt);let Et;e[199]===ue?Et=e[200]:(Et=()=>void ue(),e[199]=ue,e[200]=Et);let Dt;e[201]!==r||e[202]!==S||e[203]!==p||e[204]!==Ct||e[205]!==wt||e[206]!==Tt||e[207]!==Et?(Dt=(0,V.jsx)(U,{open:Ct,onOpenChange:wt,ch:r,removeTarget:S,onCancel:Tt,saving:p,onConfirmRemove:Et}),e[201]=r,e[202]=S,e[203]=p,e[204]=Ct,e[205]=wt,e[206]=Tt,e[207]=Et,e[208]=Dt):Dt=e[208];let Ot;return e[209]!==Je||e[210]!==Ye||e[211]!==Xe||e[212]!==Ze||e[213]!==Qe||e[214]!==$e||e[215]!==vt||e[216]!==bt||e[217]!==xt||e[218]!==St||e[219]!==Dt?(Ot=(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[Je,Ye,Xe,Ze,Qe,$e,vt,bt,xt,St,Dt]}),e[209]=Je,e[210]=Ye,e[211]=Xe,e[212]=Ze,e[213]=Qe,e[214]=$e,e[215]=vt,e[216]=bt,e[217]=xt,e[218]=St,e[219]=Dt,e[220]=Ot):Ot=e[220],Ot}export{Ke as ChannelsSettingsPanel};
2
- //# sourceMappingURL=channels-settings-DXxfgG4N.js.map
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{a as t,n,t as r}from"./vendor-react-vzx_MT5D.js";import{i}from"./vendor-swr-CQnUjdeQ.js";import{At as a,Bn as o,Bt as s,E as c,En as l,Hn as u,Ht as d,Ir as f,Ln as p,Mr as m,Mt as h,Nn as g,Nt as _,Oi as v,On as y,Rt as b,Ut as x,Vn as S,Vt as C,Wt as w,Yn as T,_r as E,ci as D,ki as O,kn as k,l as A,li as ee,mi as j,qn as M,rr as N,s as P,si as te,u as F,ui as ne,xn as I,zn as L,zt as R}from"./index-DAglRwh4.js";import{a as re,i as ie,n as ae,r as z,t as oe}from"./dist-CUMhnSuX.js";import{t as B}from"./browser-DNXWYwzc.js";var se=n(),V=r();function H(e){let t=(0,se.c)(35),{icon:n,title:r,subtitle:i,configured:a,enabled:o,onToggle:s,toggleDisabled:c,onConfigure:l,onEdit:d,onRemove:f,ch:p}=e,h;t[0]===n?h=t[1]:(h=(0,V.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=h);let g;t[2]===r?g=t[3]:(g=(0,V.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=g);let _;t[4]!==p.hubConnectedBadge||t[5]!==a?(_=a?(0,V.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:p.hubConnectedBadge}):null,t[4]=p.hubConnectedBadge,t[5]=a,t[6]=_):_=t[6];let v;t[7]!==g||t[8]!==_?(v=(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[g,_]}),t[7]=g,t[8]=_,t[9]=v):v=t[9];let y;t[10]===i?y=t[11]:(y=(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i}),t[10]=i,t[11]=y);let b;t[12]!==v||t[13]!==y?(b=(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,y]}),t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;t[15]!==h||t[16]!==b?(x=(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[h,b]}),t[15]=h,t[16]=b,t[17]=x):x=t[17];let S;t[18]!==p.enableChannelAria||t[19]!==p.hubConfigureButton||t[20]!==p.menuEditConfig||t[21]!==p.menuMoreAria||t[22]!==p.menuRemoveConfig||t[23]!==a||t[24]!==o||t[25]!==l||t[26]!==d||t[27]!==f||t[28]!==s||t[29]!==r||t[30]!==c?(S=a?(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,V.jsxs)(ie,{children:[(0,V.jsx)(re,{asChild:!0,children:(0,V.jsx)(u,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.menuMoreAria,children:(0,V.jsx)(ne,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,V.jsx)(z,{children:(0,V.jsxs)(oe,{className:M(`min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,F),sideOffset:6,align:`end`,children:[(0,V.jsx)(ae,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>d(),children:(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(m,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),p.menuEditConfig]})}),(0,V.jsx)(ae,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>f(),children:(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(N,{className:`size-4 shrink-0`,strokeWidth:1.75}),p.menuRemoveConfig]})})]})})]}),(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":o,"aria-label":`${r} — ${p.enableChannelAria}`,disabled:c,className:M(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,o?`justify-end bg-accent`:`justify-start bg-surface-hover`,c&&`cursor-not-allowed opacity-50`),onClick:()=>void s(!o),children:(0,V.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,V.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,V.jsx)(u,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:l,children:p.hubConfigureButton})}),t[18]=p.enableChannelAria,t[19]=p.hubConfigureButton,t[20]=p.menuEditConfig,t[21]=p.menuMoreAria,t[22]=p.menuRemoveConfig,t[23]=a,t[24]=o,t[25]=l,t[26]=d,t[27]=f,t[28]=s,t[29]=r,t[30]=c,t[31]=S):S=t[31];let C;return t[32]!==x||t[33]!==S?(C=(0,V.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-2xl border border-edge bg-surface-base p-4 dark:border-edge sm:flex-row sm:items-center sm:gap-4`,children:[x,S]}),t[32]=x,t[33]=S,t[34]=C):C=t[34],C}function U(e){let t=(0,se.c)(30),{open:n,onOpenChange:r,ch:i,removeTarget:a,onCancel:o,saving:c,onConfirmRemove:l}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=M(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,P,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[1]=p):p=t[1];let m;t[2]===i.removeChannelTitle?m=t[3]:(m=(0,V.jsx)(w,{className:`text-base font-semibold text-fg`,children:i.removeChannelTitle}),t[2]=i.removeChannelTitle,t[3]=m);let h;t[4]!==i.feishuTitle||t[5]!==i.removeChannelConfirm||t[6]!==i.telegramTitle||t[7]!==i.weixinTitle||t[8]!==a?(h=a?i.removeChannelConfirm.replace(`{{name}}`,a===`weixin`?i.weixinTitle:a===`telegram`?i.telegramTitle:i.feishuTitle):`\xA0`,t[4]=i.feishuTitle,t[5]=i.removeChannelConfirm,t[6]=i.telegramTitle,t[7]=i.weixinTitle,t[8]=a,t[9]=h):h=t[9];let g;t[10]===h?g=t[11]:(g=(0,V.jsx)(s,{className:`mt-2 text-sm text-fg-muted`,children:h}),t[10]=h,t[11]=g);let _;t[12]!==i.modalCancel||t[13]!==o?(_=(0,V.jsx)(u,{type:`button`,variant:`secondary`,onClick:o,children:i.modalCancel}),t[12]=i.modalCancel,t[13]=o,t[14]=_):_=t[14];let v=c?i.saving:i.removeChannelAction,y;t[15]!==l||t[16]!==c||t[17]!==v?(y=(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:c,onClick:l,children:v}),t[15]=l,t[16]=c,t[17]=v,t[18]=y):y=t[18];let b;t[19]!==_||t[20]!==y?(b=(0,V.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[_,y]}),t[19]=_,t[20]=y,t[21]=b):b=t[21];let S;t[22]!==m||t[23]!==g||t[24]!==b?(S=(0,V.jsxs)(d,{children:[f,(0,V.jsxs)(R,{className:p,onOpenAutoFocus:ce,children:[m,g,b]})]}),t[22]=m,t[23]=g,t[24]=b,t[25]=S):S=t[25];let T;return t[26]!==r||t[27]!==n||t[28]!==S?(T=(0,V.jsx)(x,{open:n,onOpenChange:r,children:S}),t[26]=r,t[27]=n,t[28]=S,t[29]=T):T=t[29],T}function ce(e){return e.preventDefault()}function W(e){return(e??``).trim().toLowerCase()}function G(e){let t=e.match;return!(!t?.channel||!t.accountId||t.peerId||t.peerKind||t.guildId||t.teamId||t.memberRoleIds&&t.memberRoleIds.length>0)}function K(e){return Object.keys(e.accounts??{}).sort()}function le(e){return Object.keys(e.accounts??{}).sort()}function q(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.appId==`string`&&e.appId.trim()&&typeof e.appSecret==`string`&&e.appSecret.trim()?[`default`]:[]}function J(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>W(e.match?.channel)===`telegram`&&W(e.match?.accountId)===W(n)&&G(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>W(e.match?.channel)===`weixin`&&W(e.match?.accountId)===W(t)&&G(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>W(e.match?.channel)===`feishu`&&W(e.match?.accountId)===W(t)&&G(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function Y(e,t,n,r,i,a){let o=new Set(n.map(W)),s=new Set(r.map(W)),c=new Set(i.map(W)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!G(e))return!0;let t=W(e.match.channel),n=W(e.match.accountId);return!n||n===`*`?!0:!(t===`telegram`&&o.has(n)||t===`weixin`&&s.has(n)||t===`feishu`&&c.has(n))}),u=[];for(let e of n){let n=(t.telegram[e]??t.telegram[W(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:telegram:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`telegram`,accountId:e}})}for(let e of r){let n=(t.weixin[e]??t.weixin[W(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:weixin:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`weixin`,accountId:e}})}for(let e of i){let n=(t.feishu[e]??t.feishu[W(e)]??a).trim().toLowerCase();u.push({id:`ui:route:account:feishu:${e}`,agentId:n,priority:45,enabled:!0,match:{channel:`feishu`,accountId:e}})}return[...l,...u]}function X(){return M(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,o,`dark:border-edge`)}function Z(){return M(L,p)}function ue(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function de(e){return e.map(String).join(`, `)}function fe(e){let t=e.accounts?.default?.botToken;return typeof t==`string`?t:``}function pe(e){return Object.values(e.accounts??{}).some(e=>typeof e.botToken==`string`&&e.botToken.trim().length>0)}function me(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function he(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}function Q(e){let t=(0,se.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function ge(e){let t=(0,se.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:n}),t[0]=n,t[1]=r),r}function _e(e){let t=(0,se.c)(14),{label:n,value:r,onChange:i,options:a}=e,o;t[0]===n?o=t[1]:(o=(0,V.jsx)(Q,{children:n}),t[0]=n,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=Z(),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=e=>i(e.target.value),t[3]=i,t[4]=c);let l;t[5]===a?l=t[6]:(l=a.map(ve),t[5]=a,t[6]=l);let u;t[7]!==c||t[8]!==l||t[9]!==r?(u=(0,V.jsx)(`select`,{className:s,value:r,onChange:c,children:l}),t[7]=c,t[8]=l,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==o||t[12]!==u?(d=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[o,u]}),t[11]=o,t[12]=u,t[13]=d):d=t[13],d}function ve(e){return(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value)}function ye(e){let t=(0,se.c)(27),{accountIds:n,routes:r,defaultAgentId:i,agentItems:a,disabled:o,onChange:s,ch:l}=e,u=g(be),d,f,m,h,_;if(t[0]!==n||t[1]!==a||t[2]!==l||t[3]!==i||t[4]!==o||t[5]!==u||t[6]!==s||t[7]!==r){_=Symbol.for(`react.early_return_sentinel`);bb0:{let e=S(u).agentsSettings;if(n.length===0){_=null;break bb0}let g=a.length>0?a:[{id:i}];m=`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`;let v;t[13]===l.agentRoutingTitle?v=t[14]:(v=(0,V.jsx)(Q,{children:l.agentRoutingTitle}),t[13]=l.agentRoutingTitle,t[14]=v);let y;t[15]===l.agentRoutingHint?y=t[16]:(y=(0,V.jsx)(ge,{children:l.agentRoutingHint}),t[15]=l.agentRoutingHint,t[16]=y),t[17]!==v||t[18]!==y?(h=(0,V.jsxs)(`div`,{children:[v,y]}),t[17]=v,t[18]=y,t[19]=h):h=t[19],d=`space-y-2`,f=n.map(t=>(0,V.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.agentRoutingAccountLabel}),(0,V.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:t,children:t})]}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${t}`,children:l.agentRoutingAgentLabel}),(0,V.jsx)(`select`,{id:`agent-route-${t}`,className:M(X(),p),disabled:o,value:(r[t]??i).toLowerCase(),onChange:e=>s(t,e.target.value),children:g.map(t=>(0,V.jsx)(`option`,{value:t.id,children:`${c(t,e)} (${t.id})`},t.id))})]})]},t))}t[0]=n,t[1]=a,t[2]=l,t[3]=i,t[4]=o,t[5]=u,t[6]=s,t[7]=r,t[8]=d,t[9]=f,t[10]=m,t[11]=h,t[12]=_}else d=t[8],f=t[9],m=t[10],h=t[11],_=t[12];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let v;t[20]!==d||t[21]!==f?(v=(0,V.jsx)(`div`,{className:d,children:f}),t[20]=d,t[21]=f,t[22]=v):v=t[22];let y;return t[23]!==m||t[24]!==h||t[25]!==v?(y=(0,V.jsxs)(`div`,{className:m,children:[h,v]}),t[23]=m,t[24]=h,t[25]=v,t[26]=y):y=t[26],y}function be(e){return e.language}function xe(e){let t=(0,se.c)(377),{ch:n,form:r,baseline:i,showFeishuSecret:a,setShowFeishuSecret:o,showFeishuWebhookSecrets:s,setShowFeishuWebhookSecrets:c,feishuCopied:l,feishuWebhookCopied:d,copyFeishuSecret:f,copyFeishuWebhookConfig:p,updateFeishu:m,updateChannelAgentRoute:h,feishuAccountsDraft:g,setFeishuAccountsDraft:_,feishuAccountsError:y,onFeishuAccountsBlur:b,dmOpts:x,groupOpts:S,chatAgents:C,saving:w,dirty:T,save:E,discard:k}=e,A=r.feishu,ee=i?.feishu?.appSecret??``,N;t[0]!==ee||t[1]!==A.appSecret||t[2]!==a?(N=!a&&!!String(ee).trim()&&A.appSecret===ee,t[0]=ee,t[1]=A.appSecret,t[2]=a,t[3]=N):N=t[3];let P=N,F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,V.jsx)(v,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[4]=F):F=t[4];let ne;t[5]===n.advancedShow?ne=t[6]:(ne=(0,V.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[F,n.advancedShow]})}),t[5]=n.advancedShow,t[6]=ne);let I;t[7]===n.feishuAdvancedHint?I=t[8]:(I=(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.feishuAdvancedHint}),t[7]=n.feishuAdvancedHint,t[8]=I);let L;t[9]===m?L=t[10]:(L=e=>m({enabled:e.target.checked}),t[9]=m,t[10]=L);let R;t[11]!==A.enabled||t[12]!==L?(R=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:A.enabled,onChange:L}),t[11]=A.enabled,t[12]=L,t[13]=R):R=t[13];let re;t[14]===n.enableFeishuAria?re=t[15]:(re=(0,V.jsx)(`span`,{children:n.enableFeishuAria}),t[14]=n.enableFeishuAria,t[15]=re);let ie;t[16]!==R||t[17]!==re?(ie=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[R,re]}),t[16]=R,t[17]=re,t[18]=ie):ie=t[18];let ae;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,V.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[19]=ae):ae=t[19];let z;t[20]===n.feishuAppId?z=t[21]:(z=(0,V.jsxs)(Q,{children:[n.feishuAppId,ae]}),t[20]=n.feishuAppId,t[21]=z);let oe;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(oe=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[22]=oe):oe=t[22];let B;t[23]===m?B=t[24]:(B=e=>m({appId:e.target.value}),t[23]=m,t[24]=B);let H;t[25]!==A.appId||t[26]!==B?(H=(0,V.jsx)(`input`,{className:oe,value:A.appId,onChange:B,placeholder:`cli_xxx`}),t[25]=A.appId,t[26]=B,t[27]=H):H=t[27];let U;t[28]===n.feishuAppIdDesc?U=t[29]:(U=(0,V.jsx)(ge,{children:n.feishuAppIdDesc}),t[28]=n.feishuAppIdDesc,t[29]=U);let ce;t[30]!==z||t[31]!==H||t[32]!==U?(ce=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[z,H,U]}),t[30]=z,t[31]=H,t[32]=U,t[33]=ce):ce=t[33];let W;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,V.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=W):W=t[34];let G;t[35]===n.feishuAppSecret?G=t[36]:(G=(0,V.jsxs)(Q,{children:[n.feishuAppSecret,W]}),t[35]=n.feishuAppSecret,t[36]=G);let K;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(K=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[37]=K):K=t[37];let le=a?`text`:`password`,J;t[38]!==P||t[39]!==A.appSecret?(J=P?`*`.repeat(Math.max(1,A.appSecret.length)):A.appSecret,t[38]=P,t[39]=A.appSecret,t[40]=J):J=t[40];let Y;t[41]!==P||t[42]!==m?(Y=e=>{P||m({appSecret:e.target.value})},t[41]=P,t[42]=m,t[43]=Y):Y=t[43];let Z;t[44]!==P||t[45]!==le||t[46]!==J||t[47]!==Y?(Z=(0,V.jsx)(`input`,{className:K,type:le,autoComplete:`off`,readOnly:P,value:J,onChange:Y,placeholder:`••••••••`}),t[44]=P,t[45]=le,t[46]=J,t[47]=Y,t[48]=Z):Z=t[48];let fe;t[49]!==n.copied||t[50]!==n.copy||t[51]!==f||t[52]!==l||t[53]!==A.appSecret?(fe=A.appSecret?(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void f(),children:[l?(0,V.jsx)(O,{className:`size-3.5`}):(0,V.jsx)(j,{className:`size-3.5`}),l?n.copied:n.copy]}):null,t[49]=n.copied,t[50]=n.copy,t[51]=f,t[52]=l,t[53]=A.appSecret,t[54]=fe):fe=t[54];let pe;t[55]===o?pe=t[56]:(pe=()=>o(Te),t[55]=o,t[56]=pe);let me;t[57]===a?me=t[58]:(me=a?(0,V.jsx)(D,{className:`size-3.5`}):(0,V.jsx)(te,{className:`size-3.5`}),t[57]=a,t[58]=me);let he=a?n.hide:n.show,_e;t[59]!==pe||t[60]!==me||t[61]!==he?(_e=(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:pe,children:[me,he]}),t[59]=pe,t[60]=me,t[61]=he,t[62]=_e):_e=t[62];let ve;t[63]!==Z||t[64]!==fe||t[65]!==_e?(ve=(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Z,fe,_e]}),t[63]=Z,t[64]=fe,t[65]=_e,t[66]=ve):ve=t[66];let be;t[67]===n.feishuAppSecretDesc?be=t[68]:(be=(0,V.jsx)(ge,{children:n.feishuAppSecretDesc}),t[67]=n.feishuAppSecretDesc,t[68]=be);let xe;t[69]!==G||t[70]!==ve||t[71]!==be?(xe=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[G,ve,be]}),t[69]=G,t[70]=ve,t[71]=be,t[72]=xe):xe=t[72];let $;t[73]===n.feishuDomain?$=t[74]:($=(0,V.jsx)(Q,{children:n.feishuDomain}),t[73]=n.feishuDomain,t[74]=$);let Ee;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=X(),t[75]=Ee):Ee=t[75];let De=String(A.domain||`feishu`),Oe;t[76]===m?Oe=t[77]:(Oe=e=>m({domain:e.target.value}),t[76]=m,t[77]=Oe);let ke,Ae;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,V.jsx)(`option`,{value:`feishu`,children:`feishu`}),Ae=(0,V.jsx)(`option`,{value:`lark`,children:`lark`}),t[78]=ke,t[79]=Ae):(ke=t[78],Ae=t[79]);let je;t[80]!==De||t[81]!==Oe?(je=(0,V.jsxs)(`select`,{className:Ee,value:De,onChange:Oe,children:[ke,Ae]}),t[80]=De,t[81]=Oe,t[82]=je):je=t[82];let Me;t[83]!==$||t[84]!==je?(Me=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[$,je]}),t[83]=$,t[84]=je,t[85]=Me):Me=t[85];let Ne;t[86]===n.connectionMode?Ne=t[87]:(Ne=(0,V.jsx)(Q,{children:n.connectionMode}),t[86]=n.connectionMode,t[87]=Ne);let Pe;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=X(),t[88]=Pe):Pe=t[88];let Fe;t[89]===m?Fe=t[90]:(Fe=e=>m({connectionMode:e.target.value}),t[89]=m,t[90]=Fe);let Ie,Le;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,V.jsx)(`option`,{value:`websocket`,children:`websocket`}),Le=(0,V.jsx)(`option`,{value:`webhook`,children:`webhook`}),t[91]=Ie,t[92]=Le):(Ie=t[91],Le=t[92]);let Re;t[93]!==A.connectionMode||t[94]!==Fe?(Re=(0,V.jsxs)(`select`,{className:Pe,value:A.connectionMode,onChange:Fe,children:[Ie,Le]}),t[93]=A.connectionMode,t[94]=Fe,t[95]=Re):Re=t[95];let ze;t[96]===n.connectionModeDesc?ze=t[97]:(ze=(0,V.jsx)(ge,{children:n.connectionModeDesc}),t[96]=n.connectionModeDesc,t[97]=ze);let Be;t[98]!==Ne||t[99]!==Re||t[100]!==ze?(Be=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ne,Re,ze]}),t[98]=Ne,t[99]=Re,t[100]=ze,t[101]=Be):Be=t[101];let Ve;t[102]!==Me||t[103]!==Be?(Ve=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Me,Be]}),t[102]=Me,t[103]=Be,t[104]=Ve):Ve=t[104];let He;t[105]!==n.copied||t[106]!==n.copy||t[107]!==n.encryptKey||t[108]!==n.encryptKeyDesc||t[109]!==n.hide||t[110]!==n.show||t[111]!==n.verificationToken||t[112]!==n.verificationTokenDesc||t[113]!==n.webhookHost||t[114]!==n.webhookPath||t[115]!==n.webhookPathDesc||t[116]!==n.webhookPort||t[117]!==n.webhookTitle||t[118]!==p||t[119]!==d||t[120]!==A.connectionMode||t[121]!==A.encryptKey||t[122]!==A.verificationToken||t[123]!==A.webhookHost||t[124]!==A.webhookPath||t[125]!==A.webhookPort||t[126]!==c||t[127]!==s||t[128]!==m?(He=A.connectionMode===`webhook`?(0,V.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.webhookTitle}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>c(we),children:[s?(0,V.jsx)(D,{className:`size-3.5`}):(0,V.jsx)(te,{className:`size-3.5`}),s?n.hide:n.show]}),(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void p(),children:[d?(0,V.jsx)(O,{className:`size-3.5`}):(0,V.jsx)(j,{className:`size-3.5`}),d?n.copied:n.copy]})]})]}),(0,V.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.verificationToken}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),type:s?`text`:`password`,autoComplete:`off`,value:A.verificationToken??``,onChange:e=>m({verificationToken:e.target.value})}),(0,V.jsx)(ge,{children:n.verificationTokenDesc})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.encryptKey}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),type:s?`text`:`password`,autoComplete:`off`,value:A.encryptKey??``,onChange:e=>m({encryptKey:e.target.value})}),(0,V.jsx)(ge,{children:n.encryptKeyDesc})]})]}),(0,V.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,V.jsx)(Q,{children:n.webhookHost}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),value:A.webhookHost??``,onChange:e=>m({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.webhookPort}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(A.webhookPort??``),onChange:e=>m({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,V.jsx)(Q,{children:n.webhookPath}),(0,V.jsx)(`input`,{className:M(X(),`min-w-0 flex-1 font-mono text-xs`),value:A.webhookPath??``,onChange:e=>m({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,V.jsx)(ge,{children:n.webhookPathDesc})]})]}):null,t[105]=n.copied,t[106]=n.copy,t[107]=n.encryptKey,t[108]=n.encryptKeyDesc,t[109]=n.hide,t[110]=n.show,t[111]=n.verificationToken,t[112]=n.verificationTokenDesc,t[113]=n.webhookHost,t[114]=n.webhookPath,t[115]=n.webhookPathDesc,t[116]=n.webhookPort,t[117]=n.webhookTitle,t[118]=p,t[119]=d,t[120]=A.connectionMode,t[121]=A.encryptKey,t[122]=A.verificationToken,t[123]=A.webhookHost,t[124]=A.webhookPath,t[125]=A.webhookPort,t[126]=c,t[127]=s,t[128]=m,t[129]=He):He=t[129];let Ue;t[130]===n.renderMode?Ue=t[131]:(Ue=(0,V.jsx)(Q,{children:n.renderMode}),t[130]=n.renderMode,t[131]=Ue);let We;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(We=X(),t[132]=We):We=t[132];let Ge;t[133]===m?Ge=t[134]:(Ge=e=>m({renderMode:e.target.value}),t[133]=m,t[134]=Ge);let Ke,qe,Je;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,V.jsx)(`option`,{value:`auto`,children:`auto`}),qe=(0,V.jsx)(`option`,{value:`raw`,children:`raw`}),Je=(0,V.jsx)(`option`,{value:`card`,children:`card`}),t[135]=Ke,t[136]=qe,t[137]=Je):(Ke=t[135],qe=t[136],Je=t[137]);let Ye;t[138]!==A.renderMode||t[139]!==Ge?(Ye=(0,V.jsxs)(`select`,{className:We,value:A.renderMode,onChange:Ge,children:[Ke,qe,Je]}),t[138]=A.renderMode,t[139]=Ge,t[140]=Ye):Ye=t[140];let Xe;t[141]!==Ue||t[142]!==Ye?(Xe=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ue,Ye]}),t[141]=Ue,t[142]=Ye,t[143]=Xe):Xe=t[143];let Ze;t[144]===n.reactionNotifications?Ze=t[145]:(Ze=(0,V.jsx)(Q,{children:n.reactionNotifications}),t[144]=n.reactionNotifications,t[145]=Ze);let Qe;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=X(),t[146]=Qe):Qe=t[146];let $e;t[147]===m?$e=t[148]:($e=e=>m({reactionNotifications:e.target.value}),t[147]=m,t[148]=$e);let et,tt,nt;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,V.jsx)(`option`,{value:`off`,children:`off`}),tt=(0,V.jsx)(`option`,{value:`own`,children:`own`}),nt=(0,V.jsx)(`option`,{value:`all`,children:`all`}),t[149]=et,t[150]=tt,t[151]=nt):(et=t[149],tt=t[150],nt=t[151]);let rt;t[152]!==A.reactionNotifications||t[153]!==$e?(rt=(0,V.jsxs)(`select`,{className:Qe,value:A.reactionNotifications,onChange:$e,children:[et,tt,nt]}),t[152]=A.reactionNotifications,t[153]=$e,t[154]=rt):rt=t[154];let it;t[155]!==Ze||t[156]!==rt?(it=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ze,rt]}),t[155]=Ze,t[156]=rt,t[157]=it):it=t[157];let at;t[158]!==Xe||t[159]!==it?(at=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Xe,it]}),t[158]=Xe,t[159]=it,t[160]=at):at=t[160];let ot;t[161]===m?ot=t[162]:(ot=e=>m({streaming:e.target.checked}),t[161]=m,t[162]=ot);let st;t[163]!==A.streaming||t[164]!==ot?(st=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:A.streaming,onChange:ot}),t[163]=A.streaming,t[164]=ot,t[165]=st):st=t[165];let ct;t[166]!==n.enableStreaming||t[167]!==st?(ct=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[st,n.enableStreaming]}),t[166]=n.enableStreaming,t[167]=st,t[168]=ct):ct=t[168];let lt;t[169]===n.dmPolicy?lt=t[170]:(lt=(0,V.jsx)(Q,{children:n.dmPolicy}),t[169]=n.dmPolicy,t[170]=lt);let ut;t[171]===Symbol.for(`react.memo_cache_sentinel`)?(ut=X(),t[171]=ut):ut=t[171];let dt=A.dmPolicy,ft;t[172]===m?ft=t[173]:(ft=e=>m({dmPolicy:e.target.value}),t[172]=m,t[173]=ft);let pt;t[174]===x?pt=t[175]:(pt=x.map(Ce),t[174]=x,t[175]=pt);let mt;t[176]!==A.dmPolicy||t[177]!==ft||t[178]!==pt?(mt=(0,V.jsx)(`select`,{className:ut,value:dt,onChange:ft,children:pt}),t[176]=A.dmPolicy,t[177]=ft,t[178]=pt,t[179]=mt):mt=t[179];let ht;t[180]!==lt||t[181]!==mt?(ht=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[lt,mt]}),t[180]=lt,t[181]=mt,t[182]=ht):ht=t[182];let gt;t[183]===n.groupPolicy?gt=t[184]:(gt=(0,V.jsx)(Q,{children:n.groupPolicy}),t[183]=n.groupPolicy,t[184]=gt);let _t;t[185]===Symbol.for(`react.memo_cache_sentinel`)?(_t=X(),t[185]=_t):_t=t[185];let vt=A.groupPolicy,yt;t[186]===m?yt=t[187]:(yt=e=>m({groupPolicy:e.target.value}),t[186]=m,t[187]=yt);let bt;t[188]===S?bt=t[189]:(bt=S.map(Se),t[188]=S,t[189]=bt);let xt;t[190]!==A.groupPolicy||t[191]!==yt||t[192]!==bt?(xt=(0,V.jsx)(`select`,{className:_t,value:vt,onChange:yt,children:bt}),t[190]=A.groupPolicy,t[191]=yt,t[192]=bt,t[193]=xt):xt=t[193];let St;t[194]!==gt||t[195]!==xt?(St=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[gt,xt]}),t[194]=gt,t[195]=xt,t[196]=St):St=t[196];let Ct;t[197]!==ht||t[198]!==St?(Ct=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ht,St]}),t[197]=ht,t[198]=St,t[199]=Ct):Ct=t[199];let wt;t[200]===m?wt=t[201]:(wt=e=>m({requireMention:e.target.checked}),t[200]=m,t[201]=wt);let Tt;t[202]!==A.requireMention||t[203]!==wt?(Tt=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:A.requireMention,onChange:wt}),t[202]=A.requireMention,t[203]=wt,t[204]=Tt):Tt=t[204];let Et;t[205]!==n.requireMention||t[206]!==Tt?(Et=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[Tt,n.requireMention]}),t[205]=n.requireMention,t[206]=Tt,t[207]=Et):Et=t[207];let Dt;t[208]===n.allowFromDm?Dt=t[209]:(Dt=(0,V.jsx)(Q,{children:n.allowFromDm}),t[208]=n.allowFromDm,t[209]=Dt);let Ot;t[210]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[210]=Ot):Ot=t[210];let kt;t[211]===A.allowFrom?kt=t[212]:(kt=de(A.allowFrom),t[211]=A.allowFrom,t[212]=kt);let At;t[213]===m?At=t[214]:(At=e=>m({allowFrom:ue(e.target.value)}),t[213]=m,t[214]=At);let jt;t[215]!==kt||t[216]!==At?(jt=(0,V.jsx)(`textarea`,{className:Ot,rows:2,placeholder:`ou_xxx, on_xxx`,value:kt,onChange:At}),t[215]=kt,t[216]=At,t[217]=jt):jt=t[217];let Mt;t[218]===n.allowFromDmDesc?Mt=t[219]:(Mt=(0,V.jsx)(ge,{children:n.allowFromDmDesc}),t[218]=n.allowFromDmDesc,t[219]=Mt);let Nt;t[220]!==Dt||t[221]!==jt||t[222]!==Mt?(Nt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Dt,jt,Mt]}),t[220]=Dt,t[221]=jt,t[222]=Mt,t[223]=Nt):Nt=t[223];let Pt;t[224]===n.allowFromGroups?Pt=t[225]:(Pt=(0,V.jsx)(Q,{children:n.allowFromGroups}),t[224]=n.allowFromGroups,t[225]=Pt);let Ft;t[226]===Symbol.for(`react.memo_cache_sentinel`)?(Ft=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[226]=Ft):Ft=t[226];let It;t[227]===A.groupAllowFrom?It=t[228]:(It=de(A.groupAllowFrom),t[227]=A.groupAllowFrom,t[228]=It);let Lt;t[229]===m?Lt=t[230]:(Lt=e=>m({groupAllowFrom:ue(e.target.value)}),t[229]=m,t[230]=Lt);let Rt;t[231]!==It||t[232]!==Lt?(Rt=(0,V.jsx)(`textarea`,{className:Ft,rows:2,placeholder:`oc_xxx, oc_yyy`,value:It,onChange:Lt}),t[231]=It,t[232]=Lt,t[233]=Rt):Rt=t[233];let zt;t[234]===n.allowFromGroupsDesc?zt=t[235]:(zt=(0,V.jsx)(ge,{children:n.allowFromGroupsDesc}),t[234]=n.allowFromGroupsDesc,t[235]=zt);let Bt;t[236]!==Pt||t[237]!==Rt||t[238]!==zt?(Bt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Pt,Rt,zt]}),t[236]=Pt,t[237]=Rt,t[238]=zt,t[239]=Bt):Bt=t[239];let Vt;t[240]===n.historyLimit?Vt=t[241]:(Vt=(0,V.jsx)(Q,{children:n.historyLimit}),t[240]=n.historyLimit,t[241]=Vt);let Ht;t[242]===Symbol.for(`react.memo_cache_sentinel`)?(Ht=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[242]=Ht):Ht=t[242];let Ut=String(A.historyLimit),Wt;t[243]===m?Wt=t[244]:(Wt=e=>m({historyLimit:Number(e.target.value||`0`)||0}),t[243]=m,t[244]=Wt);let Gt;t[245]!==Ut||t[246]!==Wt?(Gt=(0,V.jsx)(`input`,{className:Ht,type:`number`,inputMode:`numeric`,value:Ut,onChange:Wt}),t[245]=Ut,t[246]=Wt,t[247]=Gt):Gt=t[247];let Kt;t[248]!==Vt||t[249]!==Gt?(Kt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Vt,Gt]}),t[248]=Vt,t[249]=Gt,t[250]=Kt):Kt=t[250];let qt;t[251]===n.textChunkLimit?qt=t[252]:(qt=(0,V.jsx)(Q,{children:n.textChunkLimit}),t[251]=n.textChunkLimit,t[252]=qt);let Jt;t[253]===Symbol.for(`react.memo_cache_sentinel`)?(Jt=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[253]=Jt):Jt=t[253];let Yt=String(A.textChunkLimit),Xt;t[254]===m?Xt=t[255]:(Xt=e=>m({textChunkLimit:Number(e.target.value||`0`)||0}),t[254]=m,t[255]=Xt);let Zt;t[256]!==Yt||t[257]!==Xt?(Zt=(0,V.jsx)(`input`,{className:Jt,type:`number`,inputMode:`numeric`,value:Yt,onChange:Xt}),t[256]=Yt,t[257]=Xt,t[258]=Zt):Zt=t[258];let Qt;t[259]!==qt||t[260]!==Zt?(Qt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[qt,Zt]}),t[259]=qt,t[260]=Zt,t[261]=Qt):Qt=t[261];let $t;t[262]!==Kt||t[263]!==Qt?($t=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Kt,Qt]}),t[262]=Kt,t[263]=Qt,t[264]=$t):$t=t[264];let en;t[265]===n.feishuToolsTitle?en=t[266]:(en=(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuToolsTitle}),t[265]=n.feishuToolsTitle,t[266]=en);let tn;t[267]===n.feishuToolDoc?tn=t[268]:(tn=[`doc`,n.feishuToolDoc],t[267]=n.feishuToolDoc,t[268]=tn);let nn;t[269]===n.feishuToolWiki?nn=t[270]:(nn=[`wiki`,n.feishuToolWiki],t[269]=n.feishuToolWiki,t[270]=nn);let rn;t[271]===n.feishuToolDrive?rn=t[272]:(rn=[`drive`,n.feishuToolDrive],t[271]=n.feishuToolDrive,t[272]=rn);let an;t[273]===n.feishuToolPerm?an=t[274]:(an=[`perm`,n.feishuToolPerm],t[273]=n.feishuToolPerm,t[274]=an);let on;t[275]===n.feishuToolBitable?on=t[276]:(on=[`bitable`,n.feishuToolBitable],t[275]=n.feishuToolBitable,t[276]=on);let sn;t[277]===n.feishuToolScopes?sn=t[278]:(sn=[`scopes`,n.feishuToolScopes],t[277]=n.feishuToolScopes,t[278]=sn);let cn;t[279]!==tn||t[280]!==nn||t[281]!==rn||t[282]!==an||t[283]!==on||t[284]!==sn?(cn=[tn,nn,rn,an,on,sn],t[279]=tn,t[280]=nn,t[281]=rn,t[282]=an,t[283]=on,t[284]=sn,t[285]=cn):cn=t[285];let ln=cn,un;t[286]!==A.tools||t[287]!==ln||t[288]!==m?(un=(0,V.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:ln.map(e=>{let[t,n]=e;return(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!A.tools?.[t],onChange:e=>m({tools:{...A.tools,[t]:e.target.checked}})}),n]},t)})}),t[286]=A.tools,t[287]=ln,t[288]=m,t[289]=un):un=t[289];let dn;t[290]===n.feishuToolsDesc?dn=t[291]:(dn=(0,V.jsx)(`div`,{className:`mt-2`,children:(0,V.jsx)(ge,{children:n.feishuToolsDesc})}),t[290]=n.feishuToolsDesc,t[291]=dn);let fn;t[292]!==en||t[293]!==un||t[294]!==dn?(fn=(0,V.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[en,un,dn]}),t[292]=en,t[293]=un,t[294]=dn,t[295]=fn):fn=t[295];let pn;t[296]===n.feishuActionsTitle?pn=t[297]:(pn=(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuActionsTitle}),t[296]=n.feishuActionsTitle,t[297]=pn);let mn=!!A.actions?.reactions,hn;t[298]!==A.actions||t[299]!==m?(hn=e=>m({actions:{...A.actions,reactions:e.target.checked}}),t[298]=A.actions,t[299]=m,t[300]=hn):hn=t[300];let gn;t[301]!==mn||t[302]!==hn?(gn=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:mn,onChange:hn}),t[301]=mn,t[302]=hn,t[303]=gn):gn=t[303];let _n;t[304]!==n.feishuActionReactions||t[305]!==gn?(_n=(0,V.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[gn,n.feishuActionReactions]}),t[304]=n.feishuActionReactions,t[305]=gn,t[306]=_n):_n=t[306];let vn;t[307]!==pn||t[308]!==_n?(vn=(0,V.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[pn,_n]}),t[307]=pn,t[308]=_n,t[309]=vn):vn=t[309];let yn;t[310]===A?yn=t[311]:(yn=q(A),t[310]=A,t[311]=yn);let bn;t[312]===C?.items?bn=t[313]:(bn=C?.items??[],t[312]=C?.items,t[313]=bn);let xn;t[314]===h?xn=t[315]:(xn=(e,t)=>h(`feishu`,e,t),t[314]=h,t[315]=xn);let Sn;t[316]!==n||t[317]!==r.channelAgentRoutes.feishu||t[318]!==r.defaultAgentId||t[319]!==w||t[320]!==yn||t[321]!==bn||t[322]!==xn?(Sn=(0,V.jsx)(ye,{accountIds:yn,routes:r.channelAgentRoutes.feishu,defaultAgentId:r.defaultAgentId,agentItems:bn,disabled:w,onChange:xn,ch:n}),t[316]=n,t[317]=r.channelAgentRoutes.feishu,t[318]=r.defaultAgentId,t[319]=w,t[320]=yn,t[321]=bn,t[322]=xn,t[323]=Sn):Sn=t[323];let Cn;t[324]===n.multiAccountJson?Cn=t[325]:(Cn=(0,V.jsx)(Q,{children:n.multiAccountJson}),t[324]=n.multiAccountJson,t[325]=Cn);let wn;t[326]===Symbol.for(`react.memo_cache_sentinel`)?(wn=M(X(),`min-h-[140px] resize-y font-mono text-xs`),t[326]=wn):wn=t[326];let Tn;t[327]===_?Tn=t[328]:(Tn=e=>_(e.target.value),t[327]=_,t[328]=Tn);let En;t[329]!==g||t[330]!==b||t[331]!==Tn?(En=(0,V.jsx)(`textarea`,{className:wn,spellCheck:!1,value:g,onChange:Tn,onBlur:b,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),t[329]=g,t[330]=b,t[331]=Tn,t[332]=En):En=t[332];let Dn;t[333]!==n.multiAccountJsonDesc||t[334]!==y?(Dn=y?(0,V.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:y}):(0,V.jsx)(ge,{children:n.multiAccountJsonDesc}),t[333]=n.multiAccountJsonDesc,t[334]=y,t[335]=Dn):Dn=t[335];let On;t[336]!==Cn||t[337]!==En||t[338]!==Dn?(On=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Cn,En,Dn]}),t[336]=Cn,t[337]=En,t[338]=Dn,t[339]=On):On=t[339];let kn;t[340]!==Bt||t[341]!==$t||t[342]!==fn||t[343]!==vn||t[344]!==Sn||t[345]!==On||t[346]!==ce||t[347]!==xe||t[348]!==Ve||t[349]!==He||t[350]!==at||t[351]!==ct||t[352]!==Ct||t[353]!==Et||t[354]!==Nt?(kn=(0,V.jsxs)(`div`,{className:`space-y-4`,children:[ce,xe,Ve,He,at,ct,Ct,Et,Nt,Bt,$t,fn,vn,Sn,On]}),t[340]=Bt,t[341]=$t,t[342]=fn,t[343]=vn,t[344]=Sn,t[345]=On,t[346]=ce,t[347]=xe,t[348]=Ve,t[349]=He,t[350]=at,t[351]=ct,t[352]=Ct,t[353]=Et,t[354]=Nt,t[355]=kn):kn=t[355];let An=!T||w,jn;t[356]!==n.discard||t[357]!==k||t[358]!==An?(jn=(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:An,onClick:k,children:n.discard}),t[356]=n.discard,t[357]=k,t[358]=An,t[359]=jn):jn=t[359];let Mn=!T||w,Nn;t[360]===E?Nn=t[361]:(Nn=async()=>{await E()},t[360]=E,t[361]=Nn);let Pn=w?n.saving:n.save,Fn;t[362]!==Mn||t[363]!==Nn||t[364]!==Pn?(Fn=(0,V.jsx)(u,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:Mn,onClick:Nn,children:Pn}),t[362]=Mn,t[363]=Nn,t[364]=Pn,t[365]=Fn):Fn=t[365];let In;t[366]!==jn||t[367]!==Fn?(In=(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[jn,Fn]}),t[366]=jn,t[367]=Fn,t[368]=In):In=t[368];let Ln;t[369]!==kn||t[370]!==In||t[371]!==I||t[372]!==ie?(Ln=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[I,ie,kn,In]}),t[369]=kn,t[370]=In,t[371]=I,t[372]=ie,t[373]=Ln):Ln=t[373];let Rn;return t[374]!==Ln||t[375]!==ne?(Rn=(0,V.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[ne,Ln]}),t[374]=Ln,t[375]=ne,t[376]=Rn):Rn=t[376],Rn}function Se(e){return(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value)}function Ce(e){return(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value)}function we(e){return!e}function Te(e){return!e}var $=e(t(),1),Ee=e(B(),1);function De(e){return{accountId:e,name:``,enabled:!0,botToken:``,allowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,apiRoot:``,proxy:``,historyLimit:50,textChunkLimit:4e3,streamMode:`partial`}}function Oe(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{}},defaultAgentId:`main`,telegram:{enabled:!1,apiRoot:``,debug:!1,allowFrom:[],groupAllowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,proxy:``,accounts:{default:De(`default`)}},weixin:{enabled:!1,dmPolicy:`open`,allowFrom:[],debug:!1,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,routeTag:``,accounts:{}},feishu:{enabled:!1,defaultAccount:``,appId:``,appSecret:``,domain:`feishu`,connectionMode:`websocket`,verificationToken:``,encryptKey:``,webhookHost:`127.0.0.1`,webhookPort:3e3,webhookPath:`/feishu/events`,dmPolicy:`open`,groupPolicy:`allowlist`,allowFrom:[],groupAllowFrom:[],requireMention:!0,historyLimit:50,textChunkLimit:4e3,renderMode:`auto`,streaming:!1,reactionNotifications:`own`,tools:{doc:!0,wiki:!0,drive:!0,scopes:!0,bitable:!0,perm:!1},actions:{reactions:!0},accounts:{}}}}function ke(e){let t=e&&typeof e==`object`?e.channels:void 0,n=t&&typeof t==`object`?t:{},r=n.telegram,i=n.weixin,a=n.feishu,o=r?.accounts,s=o&&typeof o==`object`&&!Array.isArray(o)?{...o}:{},c=typeof r?.botToken==`string`?r.botToken.trim():``,l=s.default?.botToken?.trim()??``;c&&!l&&(s={...s,default:{...s.default??De(`default`),accountId:`default`,botToken:c}}),s.default||(s={...s,default:De(`default`)});let u=i?.accounts,d=u&&typeof u==`object`&&!Array.isArray(u)?u:{},f=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),p=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),m=typeof p.defaultId==`string`&&p.defaultId.trim()?p.defaultId.trim().toLowerCase():`main`,h={telegram:{enabled:!!r?.enabled,apiRoot:typeof r?.apiRoot==`string`?r.apiRoot:``,debug:!!r?.debug,allowFrom:Array.isArray(r?.allowFrom)?[...r.allowFrom]:[],groupAllowFrom:Array.isArray(r?.groupAllowFrom)?[...r.groupAllowFrom]:[],dmPolicy:r?.dmPolicy||`pairing`,groupPolicy:r?.groupPolicy||`open`,replyToMode:r?.replyToMode||`off`,streamMode:r?.streamMode??`partial`,historyLimit:typeof r?.historyLimit==`number`?r.historyLimit:50,textChunkLimit:typeof r?.textChunkLimit==`number`?r.textChunkLimit:4e3,proxy:typeof r?.proxy==`string`?r.proxy:``,accounts:{...s}},weixin:{enabled:!!i?.enabled,dmPolicy:i?.dmPolicy||`open`,allowFrom:Array.isArray(i?.allowFrom)?[...i.allowFrom]:[],debug:!!i?.debug,streamMode:i?.streamMode??`partial`,historyLimit:typeof i?.historyLimit==`number`?i.historyLimit:50,textChunkLimit:typeof i?.textChunkLimit==`number`?i.textChunkLimit:4e3,routeTag:i?.routeTag==null?``:String(i.routeTag),accounts:{...d}},feishu:{enabled:!!a?.enabled,defaultAccount:typeof a?.defaultAccount==`string`?a.defaultAccount:``,appId:typeof a?.appId==`string`?a.appId:``,appSecret:typeof a?.appSecret==`string`?a.appSecret:``,domain:typeof a?.domain==`string`&&a.domain||`feishu`,connectionMode:a?.connectionMode||`websocket`,verificationToken:typeof a?.verificationToken==`string`?a.verificationToken:``,encryptKey:typeof a?.encryptKey==`string`?a.encryptKey:``,webhookHost:typeof a?.webhookHost==`string`?a.webhookHost:`127.0.0.1`,webhookPort:typeof a?.webhookPort==`number`?a.webhookPort:3e3,webhookPath:typeof a?.webhookPath==`string`?a.webhookPath:`/feishu/events`,dmPolicy:a?.dmPolicy||`open`,groupPolicy:a?.groupPolicy||`allowlist`,allowFrom:Array.isArray(a?.allowFrom)?[...a.allowFrom]:[],groupAllowFrom:Array.isArray(a?.groupAllowFrom)?[...a.groupAllowFrom]:[],requireMention:a?.requireMention===void 0?!0:!!a.requireMention,historyLimit:typeof a?.historyLimit==`number`?a.historyLimit:50,textChunkLimit:typeof a?.textChunkLimit==`number`?a.textChunkLimit:4e3,renderMode:a?.renderMode||`auto`,streaming:a?.streaming===void 0?!1:!!a.streaming,reactionNotifications:a?.reactionNotifications||`own`,tools:a?.tools&&typeof a.tools==`object`&&!Array.isArray(a.tools)?{...a.tools}:void 0,actions:a?.actions&&typeof a.actions==`object`&&!Array.isArray(a.actions)?{...a.actions}:void 0,accounts:a?.accounts&&typeof a.accounts==`object`&&!Array.isArray(a.accounts)?{...a.accounts}:{}}},g=J(f,K(h.telegram),le(h.weixin),q(h.feishu),m);return{...h,bindingsFull:f.map(e=>({...e})),channelAgentRoutes:g,defaultAgentId:m}}async function Ae(e){return(await l(I(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function je(e){return(await l(I(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function Me(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=Y(e.bindingsFull,e.channelAgentRoutes,K(t),le(n),q(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await l(I(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:i,channels:{telegram:{enabled:t.enabled,apiRoot:t.apiRoot||void 0,debug:t.debug,allowFrom:t.allowFrom,groupAllowFrom:t.groupAllowFrom.length?t.groupAllowFrom:void 0,dmPolicy:t.dmPolicy,groupPolicy:t.groupPolicy,replyToMode:t.replyToMode,streamMode:t.streamMode,historyLimit:t.historyLimit,textChunkLimit:t.textChunkLimit,proxy:t.proxy||void 0,accounts:t.accounts},weixin:{enabled:n.enabled,dmPolicy:n.dmPolicy,allowFrom:n.allowFrom,debug:n.debug,streamMode:n.streamMode,historyLimit:n.historyLimit,textChunkLimit:n.textChunkLimit,routeTag:a,accounts:n.accounts},feishu:{enabled:r.enabled,defaultAccount:r.defaultAccount||void 0,appId:r.appId,appSecret:r.appSecret||void 0,domain:r.domain||void 0,connectionMode:r.connectionMode,verificationToken:r.verificationToken?.trim()?r.verificationToken:void 0,encryptKey:r.encryptKey?.trim()?r.encryptKey:void 0,webhookHost:r.webhookHost?.trim()?r.webhookHost:void 0,webhookPort:typeof r.webhookPort==`number`?r.webhookPort:void 0,webhookPath:r.webhookPath?.trim()?r.webhookPath:void 0,dmPolicy:r.dmPolicy,groupPolicy:r.groupPolicy,allowFrom:r.allowFrom,groupAllowFrom:r.groupAllowFrom.length?r.groupAllowFrom:void 0,requireMention:r.requireMention,historyLimit:r.historyLimit,textChunkLimit:r.textChunkLimit,renderMode:r.renderMode,streaming:r.streaming,reactionNotifications:r.reactionNotifications,tools:r.tools,actions:r.actions,accounts:r.accounts}}})})).payload?.config;return h(),o?ke(o):{...e,bindingsFull:i}}async function Ne(e){return(await l(I(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Pe(e){return(await l(I(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function Fe({open:e,onOpenChange:t,ch:n,onSetupSuccess:r,moreSettings:i}){let[a,o]=(0,$.useState)(!1),[c,l]=(0,$.useState)(`feishu`),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),[g,_]=(0,$.useState)(null),[v,y]=(0,$.useState)(null),[S,E]=(0,$.useState)(!1),D=(0,$.useCallback)(async e=>{l(e),_(null),p(null),h(null),o(!0);try{let t=await Ne({domain:e});h(t.qrUrl),p(t.sessionKey)}catch(e){_(e instanceof Error?e.message:`Start failed`)}finally{o(!1)}},[]);(0,$.useEffect)(()=>{if(!e){p(null),h(null),_(null),y(null),E(!1),l(`feishu`),o(!1);return}D(`feishu`)},[e,D]),(0,$.useEffect)(()=>{if(!f)return;let e=!1,n,i=async()=>{try{let i=await Pe(f);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),p(null),i.ok?(h(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(_(i.message),h(null));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),_(i.message),p(null),h(null))}catch(t){e||(n!==void 0&&window.clearInterval(n),_(t instanceof Error?t.message:`Request failed`),p(null),h(null))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[f,t,r]),(0,$.useEffect)(()=>{if(!m){y(null),E(!1);return}let e=!1;return E(!1),Ee.toDataURL(m,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||y(t)}).catch(()=>{e||(E(!0),y(null))}),()=>{e=!0}},[m]);let O=!!(m&&f),k=e,j=e&&!g&&!O;return(0,V.jsx)(x,{open:e,onOpenChange:t,children:(0,V.jsxs)(d,{children:[(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),(0,V.jsxs)(R,{className:M(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,P,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,V.jsx)(b,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.feishuQrCloseAria,children:(0,V.jsx)(T,{className:`size-4`})})}),(0,V.jsx)(w,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,V.jsx)(s,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,V.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[g?(0,V.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:g}):null,!g&&(O||j)?(0,V.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:j?n.feishuQrStarting:n.feishuQrScanHint}),(0,V.jsxs)(`div`,{className:M(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,j&&`bg-surface-muted/40 dark:bg-surface-base`),children:[j?(0,V.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,O&&m&&!g&&v&&!S?(0,V.jsx)(`img`,{src:v,alt:``,className:`relative z-[1] size-full object-contain`}):null,O&&m&&!g&&!v&&!S&&!j?(0,V.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,O&&m&&!g&&S?(0,V.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,V.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.feishuQrImageError}),(0,V.jsxs)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,V.jsx)(ee,{className:`size-3 shrink-0`}),n.feishuQrOpenLink]})]}):null]})]}):null]}),k?(0,V.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":n.feishuRegionSwitchAria,children:(0,V.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:a,className:M(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void D(`feishu`),children:n.feishuRegionChina}),(0,V.jsx)(`button`,{type:`button`,disabled:a,className:M(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,c===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>void D(`lark`),children:n.feishuRegionInternational})]})}):null,(0,V.jsx)(`div`,{className:`mt-6`,children:(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:a,onClick:()=>void D(c),children:a?n.feishuQrStarting:n.feishuQrRegenerate})}),i?(0,V.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function Ie(e){let t=(0,se.c)(123),{tg:n,updateTelegram:r,ch:i,dmOpts:a,groupOpts:o,replyOpts:s,streamOpts:c,tgAccountsDraft:l,setTgAccountsDraft:u,tgAccountsError:d,onTgAccountsBlur:f}=e,p;t[0]===i.apiRoot?p=t[1]:(p=(0,V.jsx)(Q,{children:i.apiRoot}),t[0]=i.apiRoot,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=X(),t[2]=m):m=t[2];let h;t[3]===r?h=t[4]:(h=e=>r({apiRoot:e.target.value}),t[3]=r,t[4]=h);let g;t[5]!==h||t[6]!==n.apiRoot?(g=(0,V.jsx)(`input`,{className:m,value:n.apiRoot,onChange:h,placeholder:`https://api.telegram.org`}),t[5]=h,t[6]=n.apiRoot,t[7]=g):g=t[7];let _;t[8]!==p||t[9]!==g?(_=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[p,g]}),t[8]=p,t[9]=g,t[10]=_):_=t[10];let v;t[11]===i.proxy?v=t[12]:(v=(0,V.jsx)(Q,{children:i.proxy}),t[11]=i.proxy,t[12]=v);let y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=X(),t[13]=y):y=t[13];let b;t[14]===r?b=t[15]:(b=e=>r({proxy:e.target.value}),t[14]=r,t[15]=b);let x;t[16]!==b||t[17]!==n.proxy?(x=(0,V.jsx)(`input`,{className:y,value:n.proxy,onChange:b,placeholder:`http://proxy.example.com:8080`}),t[16]=b,t[17]=n.proxy,t[18]=x):x=t[18];let S;t[19]!==v||t[20]!==x?(S=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[v,x]}),t[19]=v,t[20]=x,t[21]=S):S=t[21];let C;t[22]===r?C=t[23]:(C=e=>r({dmPolicy:e}),t[22]=r,t[23]=C);let w;t[24]!==i.dmPolicy||t[25]!==a||t[26]!==C||t[27]!==n.dmPolicy?(w=(0,V.jsx)(_e,{label:i.dmPolicy,value:n.dmPolicy,onChange:C,options:a}),t[24]=i.dmPolicy,t[25]=a,t[26]=C,t[27]=n.dmPolicy,t[28]=w):w=t[28];let T;t[29]===r?T=t[30]:(T=e=>r({groupPolicy:e}),t[29]=r,t[30]=T);let E;t[31]!==i.groupPolicy||t[32]!==o||t[33]!==T||t[34]!==n.groupPolicy?(E=(0,V.jsx)(_e,{label:i.groupPolicy,value:n.groupPolicy,onChange:T,options:o}),t[31]=i.groupPolicy,t[32]=o,t[33]=T,t[34]=n.groupPolicy,t[35]=E):E=t[35];let D;t[36]===r?D=t[37]:(D=e=>r({replyToMode:e}),t[36]=r,t[37]=D);let O;t[38]!==i.replyToMode||t[39]!==s||t[40]!==D||t[41]!==n.replyToMode?(O=(0,V.jsx)(_e,{label:i.replyToMode,value:n.replyToMode,onChange:D,options:s}),t[38]=i.replyToMode,t[39]=s,t[40]=D,t[41]=n.replyToMode,t[42]=O):O=t[42];let k;t[43]===r?k=t[44]:(k=e=>r({streamMode:e}),t[43]=r,t[44]=k);let A;t[45]!==i.streamMode||t[46]!==c||t[47]!==k||t[48]!==n.streamMode?(A=(0,V.jsx)(_e,{label:i.streamMode,value:n.streamMode,onChange:k,options:c}),t[45]=i.streamMode,t[46]=c,t[47]=k,t[48]=n.streamMode,t[49]=A):A=t[49];let ee;t[50]===i.allowFromGroups?ee=t[51]:(ee=(0,V.jsx)(Q,{children:i.allowFromGroups}),t[50]=i.allowFromGroups,t[51]=ee);let j;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(j=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[52]=j):j=t[52];let N;t[53]===n.groupAllowFrom?N=t[54]:(N=de(n.groupAllowFrom),t[53]=n.groupAllowFrom,t[54]=N);let P;t[55]===r?P=t[56]:(P=e=>r({groupAllowFrom:ue(e.target.value)}),t[55]=r,t[56]=P);let te;t[57]!==N||t[58]!==P?(te=(0,V.jsx)(`textarea`,{className:j,rows:2,placeholder:`-1001234567890`,value:N,onChange:P}),t[57]=N,t[58]=P,t[59]=te):te=t[59];let F;t[60]!==ee||t[61]!==te?(F=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ee,te]}),t[60]=ee,t[61]=te,t[62]=F):F=t[62];let ne;t[63]===i.historyLimit?ne=t[64]:(ne=(0,V.jsx)(Q,{children:i.historyLimit}),t[63]=i.historyLimit,t[64]=ne);let I;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(I=X(),t[65]=I):I=t[65];let L;t[66]===r?L=t[67]:(L=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[66]=r,t[67]=L);let R;t[68]!==L||t[69]!==n.historyLimit?(R=(0,V.jsx)(`input`,{type:`number`,min:10,max:200,className:I,value:n.historyLimit,onChange:L}),t[68]=L,t[69]=n.historyLimit,t[70]=R):R=t[70];let re;t[71]!==ne||t[72]!==R?(re=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ne,R]}),t[71]=ne,t[72]=R,t[73]=re):re=t[73];let ie;t[74]===i.textChunkLimit?ie=t[75]:(ie=(0,V.jsx)(Q,{children:i.textChunkLimit}),t[74]=i.textChunkLimit,t[75]=ie);let ae;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(ae=X(),t[76]=ae):ae=t[76];let z;t[77]===r?z=t[78]:(z=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[77]=r,t[78]=z);let oe;t[79]!==z||t[80]!==n.textChunkLimit?(oe=(0,V.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:ae,value:n.textChunkLimit,onChange:z}),t[79]=z,t[80]=n.textChunkLimit,t[81]=oe):oe=t[81];let B;t[82]!==ie||t[83]!==oe?(B=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ie,oe]}),t[82]=ie,t[83]=oe,t[84]=B):B=t[84];let H;t[85]!==re||t[86]!==B?(H=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[re,B]}),t[85]=re,t[86]=B,t[87]=H):H=t[87];let U;t[88]===r?U=t[89]:(U=e=>r({debug:e.target.checked}),t[88]=r,t[89]=U);let ce;t[90]!==U||t[91]!==n.debug?(ce=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:U}),t[90]=U,t[91]=n.debug,t[92]=ce):ce=t[92];let W;t[93]!==i.telegramDebug||t[94]!==ce?(W=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ce,i.telegramDebug]}),t[93]=i.telegramDebug,t[94]=ce,t[95]=W):W=t[95];let G;t[96]===i.multiAccountJson?G=t[97]:(G=(0,V.jsx)(Q,{children:i.multiAccountJson}),t[96]=i.multiAccountJson,t[97]=G);let K;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(K=M(X(),`min-h-[140px] resize-y font-mono text-xs`),t[98]=K):K=t[98];let le;t[99]===u?le=t[100]:(le=e=>u(e.target.value),t[99]=u,t[100]=le);let q;t[101]!==f||t[102]!==le||t[103]!==l?(q=(0,V.jsx)(`textarea`,{className:K,spellCheck:!1,value:l,onChange:le,onBlur:f,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),t[101]=f,t[102]=le,t[103]=l,t[104]=q):q=t[104];let J;t[105]!==i.multiAccountJsonDesc||t[106]!==d?(J=d?(0,V.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:d}):(0,V.jsx)(ge,{children:i.multiAccountJsonDesc}),t[105]=i.multiAccountJsonDesc,t[106]=d,t[107]=J):J=t[107];let Y;t[108]!==G||t[109]!==q||t[110]!==J?(Y=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[G,q,J]}),t[108]=G,t[109]=q,t[110]=J,t[111]=Y):Y=t[111];let Z;return t[112]!==S||t[113]!==w||t[114]!==E||t[115]!==O||t[116]!==A||t[117]!==F||t[118]!==H||t[119]!==W||t[120]!==Y||t[121]!==_?(Z=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[_,S,w,E,O,A,F,H,W,Y]}),t[112]=S,t[113]=w,t[114]=E,t[115]=O,t[116]=A,t[117]=F,t[118]=H,t[119]=W,t[120]=Y,t[121]=_,t[122]=Z):Z=t[122],Z}function Le(e){let t=(0,se.c)(162),{open:n,onOpenChange:r,ch:i,form:a,baseline:o,tgAdvanced:c,setTgAdvanced:l,showToken:f,setShowToken:p,copied:m,copyToken:h,updateTelegram:g,updateChannelAgentRoute:_,tgAccountsDraft:y,setTgAccountsDraft:S,tgAccountsError:E,onTgAccountsBlur:k,dmOpts:ee,groupOpts:N,replyOpts:F,streamOpts:ne,chatAgents:I,saving:L,dirty:re,save:ie,discard:ae}=e,z=a.telegram,oe;t[0]===o?oe=t[1]:(oe=o?fe(o.telegram):``,t[0]=o,t[1]=oe);let B=oe,H;t[2]===z?H=t[3]:(H=fe(z),t[2]=z,t[3]=H);let U=H,ce;t[4]!==f||t[5]!==B||t[6]!==U?(ce=!f&&!!String(B).trim()&&U===B,t[4]=f,t[5]=B,t[6]=U,t[7]=ce):ce=t[7];let W=ce,G;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),t[8]=G):G=t[8];let le;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(le=M(`fixed left-1/2 top-1/2 max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,P,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[9]=le):le=t[9];let q;t[10]===i.telegramTitle?q=t[11]:(q=(0,V.jsx)(w,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.telegramTitle}),t[10]=i.telegramTitle,t[11]=q);let J;t[12]===i.telegramSubtitle?J=t[13]:(J=(0,V.jsx)(s,{className:`mt-1 text-sm text-fg-muted`,children:i.telegramSubtitle}),t[12]=i.telegramSubtitle,t[13]=J);let Y;t[14]!==q||t[15]!==J?(Y=(0,V.jsxs)(`div`,{children:[q,J]}),t[14]=q,t[15]=J,t[16]=Y):Y=t[16];let Z;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,V.jsx)(T,{className:`size-4`}),t[17]=Z):Z=t[17];let pe;t[18]===i.modalCancel?pe=t[19]:(pe=(0,V.jsx)(b,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.modalCancel,children:Z})}),t[18]=i.modalCancel,t[19]=pe);let me;t[20]!==pe||t[21]!==Y?(me=(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[Y,pe]}),t[20]=pe,t[21]=Y,t[22]=me):me=t[22];let he;t[23]===g?he=t[24]:(he=e=>g({enabled:e.target.checked}),t[23]=g,t[24]=he);let _e;t[25]!==he||t[26]!==z.enabled?(_e=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:z.enabled,onChange:he}),t[25]=he,t[26]=z.enabled,t[27]=_e):_e=t[27];let ve;t[28]===i.enableTelegramAria?ve=t[29]:(ve=(0,V.jsx)(`span`,{children:i.enableTelegramAria}),t[28]=i.enableTelegramAria,t[29]=ve);let be;t[30]!==_e||t[31]!==ve?(be=(0,V.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[_e,ve]}),t[30]=_e,t[31]=ve,t[32]=be):be=t[32];let xe;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,V.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[33]=xe):xe=t[33];let Se;t[34]===i.telegramToken?Se=t[35]:(Se=(0,V.jsxs)(Q,{children:[i.telegramToken,xe]}),t[34]=i.telegramToken,t[35]=Se);let Ce;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=M(X(),`min-w-0 flex-1 font-mono text-xs`),t[36]=Ce):Ce=t[36];let we=f?`text`:`password`,Te;t[37]!==W||t[38]!==B||t[39]!==U?(Te=W?`*`.repeat(Math.max(1,B.length)):U,t[37]=W,t[38]=B,t[39]=U,t[40]=Te):Te=t[40];let $;t[41]!==W||t[42]!==z.accounts||t[43]!==g?($=e=>{if(W)return;let t=z.accounts?.default??De(`default`);g({accounts:{...z.accounts,default:{...t,accountId:`default`,botToken:e.target.value}}})},t[41]=W,t[42]=z.accounts,t[43]=g,t[44]=$):$=t[44];let Ee;t[45]!==we||t[46]!==Te||t[47]!==$||t[48]!==W?(Ee=(0,V.jsx)(`input`,{className:Ce,type:we,autoComplete:`off`,readOnly:W,value:Te,onChange:$,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),t[45]=we,t[46]=Te,t[47]=$,t[48]=W,t[49]=Ee):Ee=t[49];let Oe;t[50]!==i.copied||t[51]!==i.copy||t[52]!==m||t[53]!==h||t[54]!==U?(Oe=U?(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void h(),children:[m?(0,V.jsx)(O,{className:`size-3.5`}):(0,V.jsx)(j,{className:`size-3.5`}),m?i.copied:i.copy]}):null,t[50]=i.copied,t[51]=i.copy,t[52]=m,t[53]=h,t[54]=U,t[55]=Oe):Oe=t[55];let ke;t[56]===p?ke=t[57]:(ke=()=>p(ze),t[56]=p,t[57]=ke);let Ae;t[58]===f?Ae=t[59]:(Ae=f?(0,V.jsx)(D,{className:`size-3.5`}):(0,V.jsx)(te,{className:`size-3.5`}),t[58]=f,t[59]=Ae);let je=f?i.hide:i.show,Me;t[60]!==ke||t[61]!==Ae||t[62]!==je?(Me=(0,V.jsxs)(u,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:ke,children:[Ae,je]}),t[60]=ke,t[61]=Ae,t[62]=je,t[63]=Me):Me=t[63];let Ne;t[64]!==Ee||t[65]!==Oe||t[66]!==Me?(Ne=(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee,Oe,Me]}),t[64]=Ee,t[65]=Oe,t[66]=Me,t[67]=Ne):Ne=t[67];let Pe;t[68]===i.telegramTokenDesc?Pe=t[69]:(Pe=(0,V.jsx)(ge,{children:i.telegramTokenDesc}),t[68]=i.telegramTokenDesc,t[69]=Pe);let Fe;t[70]!==Se||t[71]!==Ne||t[72]!==Pe?(Fe=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Se,Ne,Pe]}),t[70]=Se,t[71]=Ne,t[72]=Pe,t[73]=Fe):Fe=t[73];let Le;t[74]===i.allowFromDm?Le=t[75]:(Le=(0,V.jsx)(Q,{children:i.allowFromDm}),t[74]=i.allowFromDm,t[75]=Le);let Ve;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[76]=Ve):Ve=t[76];let He;t[77]===z.allowFrom?He=t[78]:(He=de(z.allowFrom),t[77]=z.allowFrom,t[78]=He);let Ue;t[79]===g?Ue=t[80]:(Ue=e=>g({allowFrom:ue(e.target.value)}),t[79]=g,t[80]=Ue);let We;t[81]!==He||t[82]!==Ue?(We=(0,V.jsx)(`textarea`,{className:Ve,rows:2,placeholder:`123456789, 987654321`,value:He,onChange:Ue}),t[81]=He,t[82]=Ue,t[83]=We):We=t[83];let Ge;t[84]===i.allowFromDmDesc?Ge=t[85]:(Ge=(0,V.jsx)(ge,{children:i.allowFromDmDesc}),t[84]=i.allowFromDmDesc,t[85]=Ge);let Ke;t[86]!==Le||t[87]!==We||t[88]!==Ge?(Ke=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Le,We,Ge]}),t[86]=Le,t[87]=We,t[88]=Ge,t[89]=Ke):Ke=t[89];let qe;t[90]===z?qe=t[91]:(qe=K(z),t[90]=z,t[91]=qe);let Je;t[92]===I?.items?Je=t[93]:(Je=I?.items??[],t[92]=I?.items,t[93]=Je);let Ye;t[94]===_?Ye=t[95]:(Ye=(e,t)=>_(`telegram`,e,t),t[94]=_,t[95]=Ye);let Xe;t[96]!==i||t[97]!==a.channelAgentRoutes.telegram||t[98]!==a.defaultAgentId||t[99]!==L||t[100]!==qe||t[101]!==Je||t[102]!==Ye?(Xe=(0,V.jsx)(ye,{accountIds:qe,routes:a.channelAgentRoutes.telegram,defaultAgentId:a.defaultAgentId,agentItems:Je,disabled:L,onChange:Ye,ch:i}),t[96]=i,t[97]=a.channelAgentRoutes.telegram,t[98]=a.defaultAgentId,t[99]=L,t[100]=qe,t[101]=Je,t[102]=Ye,t[103]=Xe):Xe=t[103];let Ze;t[104]===l?Ze=t[105]:(Ze=()=>l(Re),t[104]=l,t[105]=Ze);let Qe=c&&`rotate-180`,$e;t[106]===Qe?$e=t[107]:($e=M(`mr-1 size-4 transition-transform`,Qe),t[106]=Qe,t[107]=$e);let et;t[108]===$e?et=t[109]:(et=(0,V.jsx)(v,{className:$e}),t[108]=$e,t[109]=et);let tt=c?i.advancedHide:i.advancedShow,nt;t[110]!==Ze||t[111]!==et||t[112]!==tt?(nt=(0,V.jsxs)(u,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:Ze,children:[et,tt]}),t[110]=Ze,t[111]=et,t[112]=tt,t[113]=nt):nt=t[113];let rt;t[114]!==i||t[115]!==ee||t[116]!==N||t[117]!==k||t[118]!==F||t[119]!==S||t[120]!==ne||t[121]!==z||t[122]!==y||t[123]!==E||t[124]!==c||t[125]!==g?(rt=c?(0,V.jsx)(Ie,{tg:z,updateTelegram:g,ch:i,dmOpts:ee,groupOpts:N,replyOpts:F,streamOpts:ne,tgAccountsDraft:y,setTgAccountsDraft:S,tgAccountsError:E,onTgAccountsBlur:k}):null,t[114]=i,t[115]=ee,t[116]=N,t[117]=k,t[118]=F,t[119]=S,t[120]=ne,t[121]=z,t[122]=y,t[123]=E,t[124]=c,t[125]=g,t[126]=rt):rt=t[126];let it;t[127]!==Fe||t[128]!==Ke||t[129]!==Xe||t[130]!==nt||t[131]!==rt?(it=(0,V.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Fe,Ke,Xe,nt,rt]}),t[127]=Fe,t[128]=Ke,t[129]=Xe,t[130]=nt,t[131]=rt,t[132]=it):it=t[132];let at;t[133]===r?at=t[134]:(at=()=>r(!1),t[133]=r,t[134]=at);let ot;t[135]!==i.modalCancel||t[136]!==at?(ot=(0,V.jsx)(u,{type:`button`,variant:`secondary`,onClick:at,children:i.modalCancel}),t[135]=i.modalCancel,t[136]=at,t[137]=ot):ot=t[137];let st=!re||L,ct;t[138]!==i.discard||t[139]!==ae||t[140]!==st?(ct=(0,V.jsx)(u,{type:`button`,variant:`secondary`,disabled:st,onClick:ae,children:i.discard}),t[138]=i.discard,t[139]=ae,t[140]=st,t[141]=ct):ct=t[141];let lt=!re||L,ut;t[142]!==r||t[143]!==ie?(ut=async()=>{await ie()&&r(!1)},t[142]=r,t[143]=ie,t[144]=ut):ut=t[144];let dt=L?i.saving:i.save,ft;t[145]!==lt||t[146]!==ut||t[147]!==dt?(ft=(0,V.jsx)(u,{type:`button`,variant:`primary`,disabled:lt,onClick:ut,children:dt}),t[145]=lt,t[146]=ut,t[147]=dt,t[148]=ft):ft=t[148];let pt;t[149]!==ot||t[150]!==ct||t[151]!==ft?(pt=(0,V.jsxs)(`div`,{className:`mt-8 flex flex-wrap justify-end gap-2 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:[ot,ct,ft]}),t[149]=ot,t[150]=ct,t[151]=ft,t[152]=pt):pt=t[152];let mt;t[153]!==me||t[154]!==be||t[155]!==it||t[156]!==pt?(mt=(0,V.jsxs)(d,{children:[G,(0,V.jsxs)(R,{className:le,onOpenAutoFocus:Be,children:[me,be,it,pt]})]}),t[153]=me,t[154]=be,t[155]=it,t[156]=pt,t[157]=mt):mt=t[157];let ht;return t[158]!==r||t[159]!==n||t[160]!==mt?(ht=(0,V.jsx)(x,{open:n,onOpenChange:r,children:mt}),t[158]=r,t[159]=n,t[160]=mt,t[161]=ht):ht=t[161],ht}function Re(e){return!e}function ze(e){return!e}function Be(e){return e.preventDefault()}function Ve(){let e=g(e=>e.language),t=S(e),n=t.channelsSettings,r=!!y(e=>e.token),[o,s]=(0,$.useState)(null),[c,l]=(0,$.useState)(null),[u,d]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(!1),[v,b]=(0,$.useState)(!1),[x,C]=(0,$.useState)(!1),[w,T]=(0,$.useState)(!1),[E,D]=(0,$.useState)(null),[O,k]=(0,$.useState)(null),[A,ee]=(0,$.useState)(null),[j,M]=(0,$.useState)(!1),[N,P]=(0,$.useState)(!1),[te,F]=(0,$.useState)(!1),[ne,I]=(0,$.useState)(!1),[L,R]=(0,$.useState)(!1),[re,ie]=(0,$.useState)(!1),[ae,z]=(0,$.useState)(!1),[oe,B]=(0,$.useState)(``),[se,V]=(0,$.useState)(``),[H,U]=(0,$.useState)(``),[ce,W]=(0,$.useState)(``),[G,K]=(0,$.useState)(``),[le,q]=(0,$.useState)(``),{data:J}=i(r?`gateway-chat-agents-ch`:null,a,{revalidateOnFocus:!1}),{data:Y,error:X,isLoading:Z,mutate:ue}=_(r),de=(0,$.useMemo)(()=>Y?.payload?.config===void 0?null:ke(Y.payload.config),[Y]),pe=(0,$.useMemo)(()=>!o||!c?!1:JSON.stringify(o)!==JSON.stringify(c),[o,c]);(0,$.useEffect)(()=>{if(!r){s(null),l(null);return}de!==null&&(pe||(s(de),l(structuredClone(de)),B(JSON.stringify(de.telegram.accounts??{},null,2)),V(``),U(JSON.stringify(de.weixin.accounts??{},null,2)),W(``),K(JSON.stringify(de.feishu?.accounts??{},null,2)),q(``),h(!1)))},[r,de,pe]);let me=!!(r&&Z&&Y===void 0&&!X),he=X instanceof Error?X.message:X?String(X):null,Q=(0,$.useCallback)((e,t,n)=>{s(r=>{if(!r)return null;let i=e===`telegram`?`telegram`:e===`weixin`?`weixin`:`feishu`;return{...r,channelAgentRoutes:{...r.channelAgentRoutes,[i]:{...r.channelAgentRoutes[i],[t]:n.trim().toLowerCase()}}}})},[]),ge=(0,$.useCallback)(e=>{s(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),_e=(0,$.useCallback)(e=>{s(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),ve=(0,$.useCallback)(e=>{s(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]);return{language:e,m:t,ch:n,hasToken:r,loading:me,fetchError:he,mutate:ue,form:o,baseline:c,dirty:pe,saving:u,error:f,saveOk:m,weixinModalOpen:v,setWeixinModalOpen:b,telegramModalOpen:x,setTelegramModalOpen:C,feishuModalOpen:w,setFeishuModalOpen:T,removeTarget:E,setRemoveTarget:D,weixinSuccessBanner:O,setWeixinSuccessBanner:k,feishuSetupSuccessBanner:A,tgAdvanced:j,setTgAdvanced:M,showToken:N,setShowToken:P,showFeishuSecret:te,setShowFeishuSecret:F,showFeishuWebhookSecrets:ne,setShowFeishuWebhookSecrets:I,copied:L,feishuCopied:re,feishuWebhookCopied:ae,tgAccountsDraft:oe,setTgAccountsDraft:B,tgAccountsError:se,wxAccountsDraft:H,setWxAccountsDraft:U,wxAccountsError:ce,feishuAccountsDraft:G,setFeishuAccountsDraft:K,feishuAccountsError:le,chatAgents:J,updateChannelAgentRoute:Q,updateTelegram:ge,updateWeixin:_e,updateFeishu:ve,save:(0,$.useCallback)(async()=>{if(!o||u)return!1;d(!0),p(null),h(!1);try{let e=await Me(o);s(e);let t=structuredClone(e);return l(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),V(``),U(JSON.stringify(t.weixin.accounts??{},null,2)),W(``),K(JSON.stringify(t.feishu?.accounts??{},null,2)),q(``),h(!0),window.setTimeout(()=>h(!1),2500),!0}catch(e){return p(e instanceof Error?e.message:n.saveError),!1}finally{d(!1)}},[o,u,n.saveError]),discard:(0,$.useCallback)(()=>{if(!c)return;let e=structuredClone(c);s(e),B(JSON.stringify(e.telegram.accounts??{},null,2)),V(``),U(JSON.stringify(e.weixin.accounts??{},null,2)),W(``),K(JSON.stringify(e.feishu?.accounts??{},null,2)),q(``),p(null),h(!1)},[c]),toggleChannelEnabled:(0,$.useCallback)(async(e,t)=>{if(!o||u)return;let r=o,i=e===`weixin`?{...o,weixin:{...o.weixin,enabled:t}}:e===`telegram`?{...o,telegram:{...o.telegram,enabled:t}}:{...o,feishu:{...o.feishu,enabled:t}};s(i),d(!0),p(null);try{let e=await Me(i);s(e);let t=structuredClone(e);l(t),B(JSON.stringify(t.telegram.accounts??{},null,2)),U(JSON.stringify(t.weixin.accounts??{},null,2)),K(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){p(e instanceof Error?e.message:n.saveError),s(r)}finally{d(!1)}},[o,u,n.saveError]),removeChannel:(0,$.useCallback)(async()=>{if(!o||!E||u)return;let e=Oe(),t=E===`weixin`?{...o,weixin:e.weixin}:E===`telegram`?{...o,telegram:e.telegram}:{...o,feishu:e.feishu};d(!0),p(null);try{let e=await Me(t);s(e);let n=structuredClone(e);l(n),B(JSON.stringify(n.telegram.accounts??{},null,2)),U(JSON.stringify(n.weixin.accounts??{},null,2)),V(``),W(``),K(JSON.stringify(n.feishu?.accounts??{},null,2)),q(``),D(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:n.saveError)}finally{d(!1)}},[o,E,u,n.saveError]),copyToken:(0,$.useCallback)(async()=>{let e=o?fe(o.telegram):``;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),R(!0),window.setTimeout(()=>R(!1),2e3))},[o]),handleFeishuQrSetupSuccess:(0,$.useCallback)(e=>{ve({appId:e.appId,domain:e.domain,enabled:!0}),ue(),ee(n.feishuQrSetupSuccess),window.setTimeout(()=>ee(null),4e3)},[ve,ue,n.feishuQrSetupSuccess]),copyFeishuSecret:(0,$.useCallback)(async()=>{let e=o?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),ie(!0),window.setTimeout(()=>ie(!1),2e3))},[o]),copyFeishuWebhookConfig:(0,$.useCallback)(async()=>{let e=o?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await navigator.clipboard.writeText(JSON.stringify(t,null,2)).catch(()=>{}),z(!0),window.setTimeout(()=>z(!1),2e3)},[o]),onTgAccountsBlur:(0,$.useCallback)(()=>{if(!o)return;let e=oe.trim();if(!e){ge({accounts:{}}),V(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);ge({accounts:t}),V(``)}catch(e){V(e instanceof Error?e.message:n.jsonInvalid)}},[o,oe,ge,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,$.useCallback)(()=>{if(!o)return;let e=H.trim();if(!e){_e({accounts:{}}),W(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);_e({accounts:t}),W(``)}catch(e){W(e instanceof Error?e.message:n.jsonInvalid)}},[o,H,_e,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,$.useCallback)(()=>{if(!o)return;let e=G.trim();if(!e){ve({accounts:{}}),q(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);ve({accounts:t}),q(``)}catch(e){q(e instanceof Error?e.message:n.jsonInvalid)}},[o,G,ve,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,$.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,$.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,$.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,$.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}function He({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:i}){let[a,o]=(0,$.useState)(!1),[c,l]=(0,$.useState)(null),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),[g,_]=(0,$.useState)(null),[v,y]=(0,$.useState)(null),[S,E]=(0,$.useState)(!1),D=(0,$.useCallback)(async()=>{h(null),_(null),l(null),o(!0);try{let e=await Ae();p(e.qrcodeUrl),l(e.sessionKey)}catch(e){h(e instanceof Error?e.message:`Start failed`)}finally{o(!1)}},[]);(0,$.useEffect)(()=>{if(!e){l(null),p(null),h(null),y(null),E(!1),_(null);return}D()},[e,D]),(0,$.useEffect)(()=>{if(!c)return;let e=!1,i,a=async()=>{try{let a=await je(c);if(e)return;if(a.phase===`polling`){p(a.qrcodeUrl),a.qrStatus===`scaned`?_(n.weixinQrLoginScanned):_(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),l(null),a.ok?(p(null),t(!1),await r()):(h(a.message),p(null));return}a.phase===`unknown`&&_(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),h(t instanceof Error?t.message:`Request failed`),l(null),p(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[c,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,$.useEffect)(()=>{if(!f){y(null),E(!1);return}let e=!1;return E(!1),Ee.toDataURL(f,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||y(t)}).catch(()=>{e||(E(!0),y(null))}),()=>{e=!0}},[f]);let O=!!(f&&c),k=e&&!m&&!O;return(0,V.jsx)(x,{open:e,onOpenChange:t,children:(0,V.jsxs)(d,{children:[(0,V.jsx)(C,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),(0,V.jsxs)(R,{className:M(`fixed left-1/2 top-1/2 max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,P,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,V.jsx)(b,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`absolute right-3 top-3 z-20 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":n.weixinQrModalCloseAria,children:(0,V.jsx)(T,{className:`size-4`})})}),(0,V.jsx)(w,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,V.jsx)(s,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,V.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[m?(0,V.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:m}):null,!m&&(O||k)?(0,V.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,V.jsx)(`p`,{className:M(`min-h-[1.25rem] text-center text-sm`,g&&!k?`text-accent`:`text-fg-muted`),children:k?n.weixinQrLoginBusy:g??`\xA0`}),(0,V.jsxs)(`div`,{className:M(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,k&&`bg-surface-muted/40 dark:bg-surface-base`),children:[k?(0,V.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,O&&f&&!m&&v&&!S?(0,V.jsx)(`img`,{src:v,alt:``,className:`relative z-[1] size-full object-contain`}):null,O&&f&&!m&&!v&&!S&&!k?(0,V.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,O&&f&&!m&&S?(0,V.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,V.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:n.weixinQrImageError}),(0,V.jsxs)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,V.jsx)(ee,{className:`size-3 shrink-0`}),n.weixinQrOpenLink]})]}):null]})]}):null]}),(0,V.jsx)(`div`,{className:`mt-6`,children:(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:a,onClick:()=>void D(),children:a?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),i?(0,V.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function Ue(e){let t=(0,se.c)(116),{wx:n,updateWeixin:r,ch:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,channelAgentRoutesWx:d,defaultAgentId:f,agentItems:p,onAgentRouteChange:m,routingDisabled:h}=e,g;t[0]===i.weixinAllowFrom?g=t[1]:(g=(0,V.jsx)(Q,{children:i.weixinAllowFrom}),t[0]=i.weixinAllowFrom,t[1]=g);let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=M(X(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[2]=_):_=t[2];let v;t[3]===n.allowFrom?v=t[4]:(v=n.allowFrom.join(`, `),t[3]=n.allowFrom,t[4]=v);let y;t[5]===r?y=t[6]:(y=e=>r({allowFrom:e.target.value.split(/[,\n]/).map(We).filter(Boolean)}),t[5]=r,t[6]=y);let b;t[7]!==v||t[8]!==y?(b=(0,V.jsx)(`textarea`,{className:_,rows:2,placeholder:`wxid_..., openid_...`,value:v,onChange:y}),t[7]=v,t[8]=y,t[9]=b):b=t[9];let x;t[10]===i.weixinAllowFromDesc?x=t[11]:(x=(0,V.jsx)(ge,{children:i.weixinAllowFromDesc}),t[10]=i.weixinAllowFromDesc,t[11]=x);let S;t[12]!==g||t[13]!==b||t[14]!==x?(S=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[g,b,x]}),t[12]=g,t[13]=b,t[14]=x,t[15]=S):S=t[15];let C;t[16]===r?C=t[17]:(C=e=>r({dmPolicy:e}),t[16]=r,t[17]=C);let w;t[18]!==i.dmPolicy||t[19]!==a||t[20]!==C||t[21]!==n.dmPolicy?(w=(0,V.jsx)(_e,{label:i.dmPolicy,value:n.dmPolicy,onChange:C,options:a}),t[18]=i.dmPolicy,t[19]=a,t[20]=C,t[21]=n.dmPolicy,t[22]=w):w=t[22];let T;t[23]===r?T=t[24]:(T=e=>r({streamMode:e}),t[23]=r,t[24]=T);let E;t[25]!==i.streamMode||t[26]!==o||t[27]!==T||t[28]!==n.streamMode?(E=(0,V.jsx)(_e,{label:i.streamMode,value:n.streamMode,onChange:T,options:o}),t[25]=i.streamMode,t[26]=o,t[27]=T,t[28]=n.streamMode,t[29]=E):E=t[29];let D;t[30]===i.historyLimit?D=t[31]:(D=(0,V.jsx)(Q,{children:i.historyLimit}),t[30]=i.historyLimit,t[31]=D);let O;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(O=X(),t[32]=O):O=t[32];let k;t[33]===r?k=t[34]:(k=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[33]=r,t[34]=k);let A;t[35]!==k||t[36]!==n.historyLimit?(A=(0,V.jsx)(`input`,{type:`number`,min:10,max:200,className:O,value:n.historyLimit,onChange:k}),t[35]=k,t[36]=n.historyLimit,t[37]=A):A=t[37];let ee;t[38]!==D||t[39]!==A?(ee=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[D,A]}),t[38]=D,t[39]=A,t[40]=ee):ee=t[40];let j;t[41]===i.textChunkLimit?j=t[42]:(j=(0,V.jsx)(Q,{children:i.textChunkLimit}),t[41]=i.textChunkLimit,t[42]=j);let N;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(N=X(),t[43]=N):N=t[43];let P;t[44]===r?P=t[45]:(P=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[44]=r,t[45]=P);let te;t[46]!==P||t[47]!==n.textChunkLimit?(te=(0,V.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:N,value:n.textChunkLimit,onChange:P}),t[46]=P,t[47]=n.textChunkLimit,t[48]=te):te=t[48];let F;t[49]!==j||t[50]!==te?(F=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[j,te]}),t[49]=j,t[50]=te,t[51]=F):F=t[51];let ne;t[52]!==ee||t[53]!==F?(ne=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ee,F]}),t[52]=ee,t[53]=F,t[54]=ne):ne=t[54];let I;t[55]===i.weixinRouteTag?I=t[56]:(I=(0,V.jsx)(Q,{children:i.weixinRouteTag}),t[55]=i.weixinRouteTag,t[56]=I);let L;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(L=X(),t[57]=L):L=t[57];let R;t[58]===r?R=t[59]:(R=e=>r({routeTag:e.target.value}),t[58]=r,t[59]=R);let re;t[60]!==i.routeTagPlaceholder||t[61]!==R||t[62]!==n.routeTag?(re=(0,V.jsx)(`input`,{className:L,value:n.routeTag,onChange:R,placeholder:i.routeTagPlaceholder}),t[60]=i.routeTagPlaceholder,t[61]=R,t[62]=n.routeTag,t[63]=re):re=t[63];let ie;t[64]===i.weixinRouteTagDesc?ie=t[65]:(ie=(0,V.jsx)(ge,{children:i.weixinRouteTagDesc}),t[64]=i.weixinRouteTagDesc,t[65]=ie);let ae;t[66]!==I||t[67]!==re||t[68]!==ie?(ae=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[I,re,ie]}),t[66]=I,t[67]=re,t[68]=ie,t[69]=ae):ae=t[69];let z;t[70]===r?z=t[71]:(z=e=>r({debug:e.target.checked}),t[70]=r,t[71]=z);let oe;t[72]!==z||t[73]!==n.debug?(oe=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:z}),t[72]=z,t[73]=n.debug,t[74]=oe):oe=t[74];let B;t[75]!==i.weixinDebug||t[76]!==oe?(B=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[oe,i.weixinDebug]}),t[75]=i.weixinDebug,t[76]=oe,t[77]=B):B=t[77];let H;t[78]===i.weixinDebugDesc?H=t[79]:(H=(0,V.jsx)(ge,{children:i.weixinDebugDesc}),t[78]=i.weixinDebugDesc,t[79]=H);let U;t[80]===i.weixinAccountsJson?U=t[81]:(U=(0,V.jsx)(Q,{children:i.weixinAccountsJson}),t[80]=i.weixinAccountsJson,t[81]=U);let ce;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ce=M(X(),`min-h-[140px] resize-y font-mono text-xs`),t[82]=ce):ce=t[82];let W;t[83]===c?W=t[84]:(W=e=>c(e.target.value),t[83]=c,t[84]=W);let G;t[85]!==u||t[86]!==W||t[87]!==s?(G=(0,V.jsx)(`textarea`,{className:ce,spellCheck:!1,value:s,onChange:W,onBlur:u,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),t[85]=u,t[86]=W,t[87]=s,t[88]=G):G=t[88];let K;t[89]!==i.weixinAccountsJsonDesc||t[90]!==l?(K=l?(0,V.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):(0,V.jsx)(ge,{children:i.weixinAccountsJsonDesc}),t[89]=i.weixinAccountsJsonDesc,t[90]=l,t[91]=K):K=t[91];let q;t[92]!==U||t[93]!==G||t[94]!==K?(q=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[U,G,K]}),t[92]=U,t[93]=G,t[94]=K,t[95]=q):q=t[95];let J;t[96]===n?J=t[97]:(J=le(n),t[96]=n,t[97]=J);let Y;t[98]!==p||t[99]!==i||t[100]!==d||t[101]!==f||t[102]!==m||t[103]!==h||t[104]!==J?(Y=(0,V.jsx)(ye,{accountIds:J,routes:d,defaultAgentId:f,agentItems:p,disabled:h,onChange:m,ch:i}),t[98]=p,t[99]=i,t[100]=d,t[101]=f,t[102]=m,t[103]=h,t[104]=J,t[105]=Y):Y=t[105];let Z;return t[106]!==E||t[107]!==ne||t[108]!==ae||t[109]!==B||t[110]!==H||t[111]!==q||t[112]!==Y||t[113]!==S||t[114]!==w?(Z=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[S,w,E,ne,ae,B,H,q,Y]}),t[106]=E,t[107]=ne,t[108]=ae,t[109]=B,t[110]=H,t[111]=q,t[112]=Y,t[113]=S,t[114]=w,t[115]=Z):Z=t[115],Z}function We(e){return e.trim()}function Ge(e){let t=(0,se.c)(53),{ch:n,wx:r,updateWeixin:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:d,form:f,chatAgents:p,onAgentRouteChange:m,saving:h,dirty:g,save:_,discard:y}=e,b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,V.jsx)(v,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[0]=b):b=t[0];let x;t[1]===n.advancedShow?x=t[2]:(x=(0,V.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[b,n.advancedShow]})}),t[1]=n.advancedShow,t[2]=x);let S;t[3]===n.weixinAdvancedHint?S=t[4]:(S=(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.weixinAdvancedHint}),t[3]=n.weixinAdvancedHint,t[4]=S);let C;t[5]===i?C=t[6]:(C=e=>i({enabled:e.target.checked}),t[5]=i,t[6]=C);let w;t[7]!==C||t[8]!==r.enabled?(w=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.enabled,onChange:C}),t[7]=C,t[8]=r.enabled,t[9]=w):w=t[9];let T;t[10]===n.enableWeixinAria?T=t[11]:(T=(0,V.jsx)(`span`,{children:n.enableWeixinAria}),t[10]=n.enableWeixinAria,t[11]=T);let E;t[12]!==w||t[13]!==T?(E=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[w,T]}),t[12]=w,t[13]=T,t[14]=E):E=t[14];let D;t[15]===p?.items?D=t[16]:(D=p?.items??[],t[15]=p?.items,t[16]=D);let O;t[17]!==n||t[18]!==a||t[19]!==f.channelAgentRoutes.weixin||t[20]!==f.defaultAgentId||t[21]!==m||t[22]!==d||t[23]!==h||t[24]!==c||t[25]!==o||t[26]!==D||t[27]!==i||t[28]!==r||t[29]!==s||t[30]!==l?(O=(0,V.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,V.jsx)(Ue,{wx:r,updateWeixin:i,ch:n,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:d,channelAgentRoutesWx:f.channelAgentRoutes.weixin,defaultAgentId:f.defaultAgentId,agentItems:D,onAgentRouteChange:m,routingDisabled:h})}),t[17]=n,t[18]=a,t[19]=f.channelAgentRoutes.weixin,t[20]=f.defaultAgentId,t[21]=m,t[22]=d,t[23]=h,t[24]=c,t[25]=o,t[26]=D,t[27]=i,t[28]=r,t[29]=s,t[30]=l,t[31]=O):O=t[31];let k=!g||h,A;t[32]!==n.discard||t[33]!==y||t[34]!==k?(A=(0,V.jsx)(u,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,disabled:k,onClick:y,children:n.discard}),t[32]=n.discard,t[33]=y,t[34]=k,t[35]=A):A=t[35];let ee=!g||h,j;t[36]===_?j=t[37]:(j=async()=>{await _()},t[36]=_,t[37]=j);let M=h?n.saving:n.save,N;t[38]!==ee||t[39]!==j||t[40]!==M?(N=(0,V.jsx)(u,{type:`button`,variant:`primary`,className:`w-full sm:w-auto`,disabled:ee,onClick:j,children:M}),t[38]=ee,t[39]=j,t[40]=M,t[41]=N):N=t[41];let P;t[42]!==A||t[43]!==N?(P=(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-end`,children:[A,N]}),t[42]=A,t[43]=N,t[44]=P):P=t[44];let te;t[45]!==P||t[46]!==S||t[47]!==E||t[48]!==O?(te=(0,V.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[S,E,O,P]}),t[45]=P,t[46]=S,t[47]=E,t[48]=O,t[49]=te):te=t[49];let F;return t[50]!==te||t[51]!==x?(F=(0,V.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[x,te]}),t[50]=te,t[51]=x,t[52]=F):F=t[52],F}function Ke(){let e=(0,se.c)(221),{language:t,m:n,ch:r,hasToken:i,loading:a,fetchError:o,mutate:s,form:c,baseline:l,dirty:d,saving:p,error:m,saveOk:h,weixinModalOpen:g,setWeixinModalOpen:_,telegramModalOpen:v,setTelegramModalOpen:y,feishuModalOpen:b,setFeishuModalOpen:x,removeTarget:S,setRemoveTarget:C,weixinSuccessBanner:w,setWeixinSuccessBanner:T,feishuSetupSuccessBanner:D,tgAdvanced:O,setTgAdvanced:A,showToken:j,setShowToken:M,showFeishuSecret:N,setShowFeishuSecret:P,showFeishuWebhookSecrets:te,setShowFeishuWebhookSecrets:F,copied:ne,feishuCopied:I,feishuWebhookCopied:L,tgAccountsDraft:R,setTgAccountsDraft:re,tgAccountsError:ie,wxAccountsDraft:ae,setWxAccountsDraft:z,wxAccountsError:oe,feishuAccountsDraft:B,setFeishuAccountsDraft:ce,feishuAccountsError:W,chatAgents:G,updateChannelAgentRoute:K,updateTelegram:le,updateWeixin:q,updateFeishu:J,save:Y,discard:X,toggleChannelEnabled:Z,removeChannel:ue,copyToken:de,handleFeishuQrSetupSuccess:fe,copyFeishuSecret:Q,copyFeishuWebhookConfig:ge,onTgAccountsBlur:_e,onWxAccountsBlur:ve,onFeishuAccountsBlur:ye,dmOpts:be,groupOpts:Se,replyOpts:Ce,streamOpts:we}=Ve();if(!i){let t;e[0]===n.settingsSections.channels?t=e[1]:(t=(0,V.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.channels}),e[0]=n.settingsSections.channels,e[1]=t);let i;e[2]===r.needToken?i=e[3]:(i=(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken}),e[2]=r.needToken,e[3]=i);let a;return e[4]!==t||e[5]!==i?(a=(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[t,i]}),e[4]=t,e[5]=i,e[6]=a):a=e[6],a}if(a){let t,n;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,V.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),n=(0,V.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),e[7]=t,e[8]=n):(t=e[7],n=e[8]);let i;return e[9]===r.loading?i=e[10]:(i=(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,(0,V.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.loading})]}),e[9]=r.loading,e[10]=i),i}if(!c){let t=m??o??r.loadError,n;e[11]===t?n=e[12]:(n=(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t}),e[11]=t,e[12]=n);let i;e[13]===s?i=e[14]:(i=()=>void s(),e[13]=s,e[14]=i);let a;e[15]!==r.retry||e[16]!==i?(a=(0,V.jsx)(u,{type:`button`,variant:`secondary`,onClick:i,children:r.retry}),e[15]=r.retry,e[16]=i,e[17]=a):a=e[17];let c;return e[18]!==n||e[19]!==a?(c=(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[n,a]}),e[18]=n,e[19]=a,e[20]=c):c=e[20],c}let Te=c.weixin,$=c.telegram,Ee=c.feishu,De;e[21]===Te?De=e[22]:(De=me(Te),e[21]=Te,e[22]=De);let Oe=De,ke;e[23]===$?ke=e[24]:(ke=pe($),e[23]=$,e[24]=ke);let Ae=ke,je;e[25]===Ee?je=e[26]:(je=he(Ee),e[25]=Ee,e[26]=je);let Me=je,Ne;e[27]!==l||e[28]!==r||e[29]!==G||e[30]!==Q||e[31]!==ge||e[32]!==d||e[33]!==X||e[34]!==be||e[35]!==B||e[36]!==W||e[37]!==I||e[38]!==L||e[39]!==c||e[40]!==Se||e[41]!==ye||e[42]!==Y||e[43]!==p||e[44]!==ce||e[45]!==P||e[46]!==F||e[47]!==N||e[48]!==te||e[49]!==K||e[50]!==J?(Ne=(0,V.jsx)(xe,{ch:r,form:c,baseline:l,showFeishuSecret:N,setShowFeishuSecret:P,showFeishuWebhookSecrets:te,setShowFeishuWebhookSecrets:F,feishuCopied:I,feishuWebhookCopied:L,copyFeishuSecret:Q,copyFeishuWebhookConfig:ge,updateFeishu:J,updateChannelAgentRoute:K,feishuAccountsDraft:B,setFeishuAccountsDraft:ce,feishuAccountsError:W,onFeishuAccountsBlur:ye,dmOpts:be,groupOpts:Se,chatAgents:G,saving:p,dirty:d,save:Y,discard:X}),e[27]=l,e[28]=r,e[29]=G,e[30]=Q,e[31]=ge,e[32]=d,e[33]=X,e[34]=be,e[35]=B,e[36]=W,e[37]=I,e[38]=L,e[39]=c,e[40]=Se,e[41]=ye,e[42]=Y,e[43]=p,e[44]=ce,e[45]=P,e[46]=F,e[47]=N,e[48]=te,e[49]=K,e[50]=J,e[51]=Ne):Ne=e[51];let Pe=Ne,Ie;e[52]===K?Ie=e[53]:(Ie=(e,t)=>K(`weixin`,e,t),e[52]=K,e[53]=Ie);let Re;e[54]!==r||e[55]!==G||e[56]!==d||e[57]!==X||e[58]!==be||e[59]!==c||e[60]!==ve||e[61]!==Y||e[62]!==p||e[63]!==z||e[64]!==we||e[65]!==Ie||e[66]!==q||e[67]!==Te||e[68]!==ae||e[69]!==oe?(Re=(0,V.jsx)(Ge,{ch:r,wx:Te,updateWeixin:q,dmOpts:be,streamOpts:we,wxAccountsDraft:ae,setWxAccountsDraft:z,wxAccountsError:oe,onWxAccountsBlur:ve,form:c,chatAgents:G,onAgentRouteChange:Ie,saving:p,dirty:d,save:Y,discard:X}),e[54]=r,e[55]=G,e[56]=d,e[57]=X,e[58]=be,e[59]=c,e[60]=ve,e[61]=Y,e[62]=p,e[63]=z,e[64]=we,e[65]=Ie,e[66]=q,e[67]=Te,e[68]=ae,e[69]=oe,e[70]=Re):Re=e[70];let ze=Re,Be;e[71]===n.settingsSections.channels?Be=e[72]:(Be=(0,V.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.channels}),e[71]=n.settingsSections.channels,e[72]=Be);let Ue;e[73]===r.subtitle?Ue=e[74]:(Ue=(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[73]=r.subtitle,e[74]=Ue);let We;e[75]===t?We=e[76]:(We=k(t,`channels`),e[75]=t,e[76]=We);let Ke;e[77]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,V.jsx)(ee,{className:`size-3.5`}),e[77]=Ke):Ke=e[77];let qe;e[78]!==r.docsLink||e[79]!==We?(qe=(0,V.jsxs)(`a`,{href:We,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,Ke]}),e[78]=r.docsLink,e[79]=We,e[80]=qe):qe=e[80];let Je;e[81]!==qe||e[82]!==Be||e[83]!==Ue?(Je=(0,V.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[Be,Ue,qe]}),e[81]=qe,e[82]=Be,e[83]=Ue,e[84]=Je):Je=e[84];let Ye;e[85]!==r.unsavedHint||e[86]!==d?(Ye=d?(0,V.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,e[85]=r.unsavedHint,e[86]=d,e[87]=Ye):Ye=e[87];let Xe;e[88]!==r.saved||e[89]!==h?(Xe=h?(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.saved}):null,e[88]=r.saved,e[89]=h,e[90]=Xe):Xe=e[90];let Ze;e[91]===m?Ze=e[92]:(Ze=m?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,e[91]=m,e[92]=Ze);let Qe;e[93]===w?Qe=e[94]:(Qe=w?(0,V.jsx)(`p`,{className:`text-xs text-accent`,children:w}):null,e[93]=w,e[94]=Qe);let $e;e[95]===D?$e=e[96]:($e=D?(0,V.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:D}):null,e[95]=D,e[96]=$e);let et;e[97]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,V.jsx)(f,{className:`size-6 text-accent`,strokeWidth:1.75}),e[97]=et):et=e[97];let tt;e[98]===Z?tt=e[99]:(tt=e=>void Z(`weixin`,e),e[98]=Z,e[99]=tt);let nt,rt;e[100]===_?(nt=e[101],rt=e[102]):(nt=()=>_(!0),rt=()=>_(!0),e[100]=_,e[101]=nt,e[102]=rt);let it;e[103]===C?it=e[104]:(it=()=>C(`weixin`),e[103]=C,e[104]=it);let at;e[105]!==r||e[106]!==p||e[107]!==tt||e[108]!==nt||e[109]!==rt||e[110]!==it||e[111]!==Oe||e[112]!==Te.enabled?(at=(0,V.jsx)(H,{icon:et,title:r.weixinTitle,subtitle:r.weixinSubtitle,configured:Oe,enabled:Te.enabled,toggleDisabled:p,onToggle:tt,onConfigure:nt,onEdit:rt,onRemove:it,ch:r}),e[105]=r,e[106]=p,e[107]=tt,e[108]=nt,e[109]=rt,e[110]=it,e[111]=Oe,e[112]=Te.enabled,e[113]=at):at=e[113];let ot;e[114]===Symbol.for(`react.memo_cache_sentinel`)?(ot=(0,V.jsx)(E,{className:`size-6 text-accent`,strokeWidth:1.75}),e[114]=ot):ot=e[114];let st;e[115]===Z?st=e[116]:(st=e=>void Z(`telegram`,e),e[115]=Z,e[116]=st);let ct,lt;e[117]===y?(ct=e[118],lt=e[119]):(ct=()=>y(!0),lt=()=>y(!0),e[117]=y,e[118]=ct,e[119]=lt);let ut;e[120]===C?ut=e[121]:(ut=()=>C(`telegram`),e[120]=C,e[121]=ut);let dt;e[122]!==r||e[123]!==p||e[124]!==st||e[125]!==ct||e[126]!==lt||e[127]!==ut||e[128]!==Ae||e[129]!==$.enabled?(dt=(0,V.jsx)(H,{icon:ot,title:r.telegramTitle,subtitle:r.telegramSubtitle,configured:Ae,enabled:$.enabled,toggleDisabled:p,onToggle:st,onConfigure:ct,onEdit:lt,onRemove:ut,ch:r}),e[122]=r,e[123]=p,e[124]=st,e[125]=ct,e[126]=lt,e[127]=ut,e[128]=Ae,e[129]=$.enabled,e[130]=dt):dt=e[130];let ft;e[131]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,V.jsx)(f,{className:`size-6 text-accent`,strokeWidth:1.75}),e[131]=ft):ft=e[131];let pt;e[132]===Z?pt=e[133]:(pt=e=>void Z(`feishu`,e),e[132]=Z,e[133]=pt);let mt,ht;e[134]===x?(mt=e[135],ht=e[136]):(mt=()=>x(!0),ht=()=>x(!0),e[134]=x,e[135]=mt,e[136]=ht);let gt;e[137]===C?gt=e[138]:(gt=()=>C(`feishu`),e[137]=C,e[138]=gt);let _t;e[139]!==r||e[140]!==Me||e[141]!==Ee.enabled||e[142]!==p||e[143]!==pt||e[144]!==mt||e[145]!==ht||e[146]!==gt?(_t=(0,V.jsx)(H,{icon:ft,title:r.feishuTitle,subtitle:r.feishuSubtitle,configured:Me,enabled:Ee.enabled,toggleDisabled:p,onToggle:pt,onConfigure:mt,onEdit:ht,onRemove:gt,ch:r}),e[139]=r,e[140]=Me,e[141]=Ee.enabled,e[142]=p,e[143]=pt,e[144]=mt,e[145]=ht,e[146]=gt,e[147]=_t):_t=e[147];let vt;e[148]!==at||e[149]!==dt||e[150]!==_t?(vt=(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[at,dt,_t]}),e[148]=at,e[149]=dt,e[150]=_t,e[151]=vt):vt=e[151];let yt;e[152]!==r.weixinQrLoginSuccess||e[153]!==s||e[154]!==T?(yt=async()=>{await s(),T(r.weixinQrLoginSuccess),window.setTimeout(()=>T(null),4e3)},e[152]=r.weixinQrLoginSuccess,e[153]=s,e[154]=T,e[155]=yt):yt=e[155];let bt;e[156]!==r||e[157]!==_||e[158]!==yt||e[159]!==g||e[160]!==ze?(bt=(0,V.jsx)(He,{open:g,onOpenChange:_,ch:r,onLoginSuccess:yt,moreSettings:ze}),e[156]=r,e[157]=_,e[158]=yt,e[159]=g,e[160]=ze,e[161]=bt):bt=e[161];let xt;e[162]!==l||e[163]!==r||e[164]!==G||e[165]!==ne||e[166]!==de||e[167]!==d||e[168]!==X||e[169]!==be||e[170]!==c||e[171]!==Se||e[172]!==_e||e[173]!==Ce||e[174]!==Y||e[175]!==p||e[176]!==M||e[177]!==y||e[178]!==re||e[179]!==A||e[180]!==j||e[181]!==we||e[182]!==v||e[183]!==R||e[184]!==ie||e[185]!==O||e[186]!==K||e[187]!==le?(xt=(0,V.jsx)(Le,{open:v,onOpenChange:y,ch:r,form:c,baseline:l,tgAdvanced:O,setTgAdvanced:A,showToken:j,setShowToken:M,copied:ne,copyToken:de,updateTelegram:le,updateChannelAgentRoute:K,tgAccountsDraft:R,setTgAccountsDraft:re,tgAccountsError:ie,onTgAccountsBlur:_e,dmOpts:be,groupOpts:Se,replyOpts:Ce,streamOpts:we,chatAgents:G,saving:p,dirty:d,save:Y,discard:X}),e[162]=l,e[163]=r,e[164]=G,e[165]=ne,e[166]=de,e[167]=d,e[168]=X,e[169]=be,e[170]=c,e[171]=Se,e[172]=_e,e[173]=Ce,e[174]=Y,e[175]=p,e[176]=M,e[177]=y,e[178]=re,e[179]=A,e[180]=j,e[181]=we,e[182]=v,e[183]=R,e[184]=ie,e[185]=O,e[186]=K,e[187]=le,e[188]=xt):xt=e[188];let St;e[189]!==r||e[190]!==b||e[191]!==Pe||e[192]!==fe||e[193]!==x?(St=(0,V.jsx)(Fe,{open:b,onOpenChange:x,ch:r,onSetupSuccess:fe,moreSettings:Pe}),e[189]=r,e[190]=b,e[191]=Pe,e[192]=fe,e[193]=x,e[194]=St):St=e[194];let Ct=S!==null,wt;e[195]===C?wt=e[196]:(wt=e=>{e||C(null)},e[195]=C,e[196]=wt);let Tt;e[197]===C?Tt=e[198]:(Tt=()=>C(null),e[197]=C,e[198]=Tt);let Et;e[199]===ue?Et=e[200]:(Et=()=>void ue(),e[199]=ue,e[200]=Et);let Dt;e[201]!==r||e[202]!==S||e[203]!==p||e[204]!==Ct||e[205]!==wt||e[206]!==Tt||e[207]!==Et?(Dt=(0,V.jsx)(U,{open:Ct,onOpenChange:wt,ch:r,removeTarget:S,onCancel:Tt,saving:p,onConfirmRemove:Et}),e[201]=r,e[202]=S,e[203]=p,e[204]=Ct,e[205]=wt,e[206]=Tt,e[207]=Et,e[208]=Dt):Dt=e[208];let Ot;return e[209]!==Je||e[210]!==Ye||e[211]!==Xe||e[212]!==Ze||e[213]!==Qe||e[214]!==$e||e[215]!==vt||e[216]!==bt||e[217]!==xt||e[218]!==St||e[219]!==Dt?(Ot=(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[Je,Ye,Xe,Ze,Qe,$e,vt,bt,xt,St,Dt]}),e[209]=Je,e[210]=Ye,e[211]=Xe,e[212]=Ze,e[213]=Qe,e[214]=$e,e[215]=vt,e[216]=bt,e[217]=xt,e[218]=St,e[219]=Dt,e[220]=Ot):Ot=e[220],Ot}export{Ke as ChannelsSettingsPanel};
2
+ //# sourceMappingURL=channels-settings-Bn0YSztA.js.map