@xopcai/xopc 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/extensions/feishu/xopc.extension.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/agents-C_bPhtBs.js +216 -0
  4. package/dist/gateway/static/root/assets/{agents-CiZMJZRp.js.map → agents-C_bPhtBs.js.map} +1 -1
  5. package/dist/gateway/static/root/assets/{apps-page-tZz69XM3.js → apps-page-DbzO48lg.js} +2 -2
  6. package/dist/gateway/static/root/assets/{apps-page-tZz69XM3.js.map → apps-page-DbzO48lg.js.map} +1 -1
  7. package/dist/gateway/static/root/assets/channels-settings-CeGoU9v8.js +9 -0
  8. package/dist/gateway/static/root/assets/{channels-settings-BAvk9-aK.js.map → channels-settings-CeGoU9v8.js.map} +1 -1
  9. package/dist/gateway/static/root/assets/cron-page-DpEYUvxB.js +2 -0
  10. package/dist/gateway/static/root/assets/{cron-page-CANqvhK7.js.map → cron-page-DpEYUvxB.js.map} +1 -1
  11. package/dist/gateway/static/root/assets/{cron-utils-DyOO6TdN.js → cron-utils-Cvv0F3pa.js} +2 -2
  12. package/dist/gateway/static/root/assets/{cron-utils-DyOO6TdN.js.map → cron-utils-Cvv0F3pa.js.map} +1 -1
  13. package/dist/gateway/static/root/assets/{dist-Brod9LF3.js → dist-C41N3YrO.js} +2 -2
  14. package/dist/gateway/static/root/assets/{dist-Brod9LF3.js.map → dist-C41N3YrO.js.map} +1 -1
  15. package/dist/gateway/static/root/assets/{extension-debug-page-CDD7ozsC.js → extension-debug-page-CkkYZjNP.js} +2 -2
  16. package/dist/gateway/static/root/assets/{extension-debug-page-CDD7ozsC.js.map → extension-debug-page-CkkYZjNP.js.map} +1 -1
  17. package/dist/gateway/static/root/assets/{extension-page-UUFMjoWf.js → extension-page-BjUIPVNG.js} +2 -2
  18. package/dist/gateway/static/root/assets/{extension-page-UUFMjoWf.js.map → extension-page-BjUIPVNG.js.map} +1 -1
  19. package/dist/gateway/static/root/assets/{extension-settings-page-CP9JNc4m.js → extension-settings-page-CwuFDOdk.js} +2 -2
  20. package/dist/gateway/static/root/assets/extension-settings-page-CwuFDOdk.js.map +1 -0
  21. package/dist/gateway/static/root/assets/{index-BZvlG48D.js → index-DwzwDCjW.js} +56 -56
  22. package/dist/gateway/static/root/assets/{index-BZvlG48D.js.map → index-DwzwDCjW.js.map} +1 -1
  23. package/dist/gateway/static/root/assets/index-dhtHG1nU.css +1 -0
  24. package/dist/gateway/static/root/assets/logs-page-BtwGPuw2.js +2 -0
  25. package/dist/gateway/static/root/assets/{logs-page-Cr0eCGb4.js.map → logs-page-BtwGPuw2.js.map} +1 -1
  26. package/dist/gateway/static/root/assets/sessions-page-4rKFDn2k.js +2 -0
  27. package/dist/gateway/static/root/assets/{sessions-page-DwLHN5GJ.js.map → sessions-page-4rKFDn2k.js.map} +1 -1
  28. package/dist/gateway/static/root/assets/settings-page-iYLSxQYc.js +2 -0
  29. package/dist/gateway/static/root/assets/settings-page-iYLSxQYc.js.map +1 -0
  30. package/dist/gateway/static/root/assets/skills-page-_siDuHeF.js +3 -0
  31. package/dist/gateway/static/root/assets/{skills-page-DgBYvH6B.js.map → skills-page-_siDuHeF.js.map} +1 -1
  32. package/dist/gateway/static/root/index.html +2 -2
  33. package/dist/package.js +1 -1
  34. package/dist/src/agent/memory/dreaming/config.d.ts +20 -0
  35. package/dist/src/agent/memory/dreaming/config.js +44 -0
  36. package/dist/src/agent/memory/dreaming/config.js.map +1 -0
  37. package/dist/src/agent/memory/dreaming/constants.d.ts +8 -0
  38. package/dist/src/agent/memory/dreaming/constants.js +14 -0
  39. package/dist/src/agent/memory/dreaming/constants.js.map +1 -0
  40. package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +22 -0
  41. package/dist/src/agent/memory/dreaming/deep-promotion.js +337 -0
  42. package/dist/src/agent/memory/dreaming/deep-promotion.js.map +1 -0
  43. package/dist/src/agent/memory/dreaming/preview.d.ts +26 -0
  44. package/dist/src/agent/memory/dreaming/preview.js +176 -0
  45. package/dist/src/agent/memory/dreaming/preview.js.map +1 -0
  46. package/dist/src/agent/memory/dreaming/short-term-store.d.ts +45 -0
  47. package/dist/src/agent/memory/dreaming/short-term-store.js +187 -0
  48. package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -0
  49. package/dist/src/agent/orchestration/agent-orchestrator.js +17 -0
  50. package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
  51. package/dist/src/agent/service.d.ts +6 -0
  52. package/dist/src/agent/service.js +52 -0
  53. package/dist/src/agent/service.js.map +1 -1
  54. package/dist/src/agent/tools/dreaming-tool.d.ts +7 -0
  55. package/dist/src/agent/tools/dreaming-tool.js +102 -0
  56. package/dist/src/agent/tools/dreaming-tool.js.map +1 -0
  57. package/dist/src/agent/tools/factory.js +5 -0
  58. package/dist/src/agent/tools/factory.js.map +1 -1
  59. package/dist/src/agent/tools/index.d.ts +1 -0
  60. package/dist/src/agent/tools/index.js +2 -1
  61. package/dist/src/agent/tools/memory-tool.js +9 -2
  62. package/dist/src/agent/tools/memory-tool.js.map +1 -1
  63. package/dist/src/config/schema.d.ts +39 -0
  64. package/dist/src/config/schema.js +16 -1
  65. package/dist/src/config/schema.js.map +1 -1
  66. package/dist/src/gateway/hono/lib/config-payload.d.ts +13 -0
  67. package/dist/src/gateway/hono/routes/config.js +48 -0
  68. package/dist/src/gateway/hono/routes/config.js.map +1 -1
  69. package/dist/src/gateway/hono/routes/dreaming.d.ts +3 -0
  70. package/dist/src/gateway/hono/routes/dreaming.js +198 -0
  71. package/dist/src/gateway/hono/routes/dreaming.js.map +1 -0
  72. package/dist/src/gateway/hono/routes/index.js +2 -0
  73. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  74. package/dist/src/gateway/lock.js +1 -1
  75. package/dist/src/gateway/service.js +7 -0
  76. package/dist/src/gateway/service.js.map +1 -1
  77. package/package.json +1 -1
  78. package/dist/gateway/static/root/assets/agents-CiZMJZRp.js +0 -216
  79. package/dist/gateway/static/root/assets/channels-settings-BAvk9-aK.js +0 -9
  80. package/dist/gateway/static/root/assets/cron-page-CANqvhK7.js +0 -2
  81. package/dist/gateway/static/root/assets/extension-settings-page-CP9JNc4m.js.map +0 -1
  82. package/dist/gateway/static/root/assets/index-DxkgyT8R.css +0 -1
  83. package/dist/gateway/static/root/assets/logs-page-Cr0eCGb4.js +0 -2
  84. package/dist/gateway/static/root/assets/sessions-page-DwLHN5GJ.js +0 -2
  85. package/dist/gateway/static/root/assets/settings-page-B3O3R0E4.js +0 -2
  86. package/dist/gateway/static/root/assets/settings-page-B3O3R0E4.js.map +0 -1
  87. package/dist/gateway/static/root/assets/skills-page-DgBYvH6B.js +0 -3
@@ -1,9 +0,0 @@
1
- import{i as e,t}from"./rolldown-runtime-DWdDZTNf.js";import{i as n,t as r}from"./vendor-react-DbimaAId.js";import{i}from"./vendor-swr-B5fPo7KK.js";import{t as a}from"./cn-BMCV0OMB.js";import{A as o,Gt as s,Hn as c,Jt as l,Mr as u,Nr as d,On as f,Qt as p,Ut as m,_n as h,an as g,at as _,ct as v,dn as y,dt as b,fr as x,hr as S,in as C,k as w,l as ee,lt as te,mr as ne,nn as T,on as re,ot as ie,pr as ae,qt as oe,sn as E,st as se,ut as ce,yr as le,zn as D}from"./index-BZvlG48D.js";import{a as ue,i as O,n as de,r as fe,t as pe}from"./dist-Brod9LF3.js";var k=e(n(),1);function A(e){return(e??``).trim().toLowerCase()}function me(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 he(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.botToken==`string`&&e.botToken.trim()?[`default`]:[]}function j(e){return Object.keys(e.accounts??{}).sort()}function ge(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 M(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>A(e.match?.channel)===`telegram`&&A(e.match?.accountId)===A(n)&&me(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>A(e.match?.channel)===`weixin`&&A(e.match?.accountId)===A(t)&&me(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>A(e.match?.channel)===`feishu`&&A(e.match?.accountId)===A(t)&&me(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function N(e,t,n,r,i,a){let o=new Set(n.map(A)),s=new Set(r.map(A)),c=new Set(i.map(A)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!me(e))return!0;let t=A(e.match.channel),n=A(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[A(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[A(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[A(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 _e(){return{bindingsFull:[],channelAgentRoutes:{telegram:{},weixin:{},feishu:{}},defaultAgentId:`main`,telegram:{enabled:!1,botToken:``,apiRoot:``,debug:!1,allowFrom:[],groupAllowFrom:[],dmPolicy:`pairing`,groupPolicy:`open`,replyToMode:`off`,streamMode:`partial`,historyLimit:50,textChunkLimit:4e3,proxy:``,accounts:{}},weixin:{enabled:!1,dmPolicy:`pairing`,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:`pairing`,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 ve(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=i?.accounts,l=c&&typeof c==`object`&&!Array.isArray(c)?c:{},u=(()=>{let t=(e&&typeof e==`object`?e:{}).bindings;return Array.isArray(t)?t:[]})(),d=(()=>{let t=(e&&typeof e==`object`?e:{}).agents;return t&&typeof t==`object`?t:{}})(),f=typeof d.defaultId==`string`&&d.defaultId.trim()?d.defaultId.trim().toLowerCase():`main`,p={telegram:{enabled:!!r?.enabled,botToken:typeof r?.botToken==`string`?r.botToken:``,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||`pairing`,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:{...l}},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||`pairing`,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}:{}}},m=M(u,he(p.telegram),j(p.weixin),ge(p.feishu),f);return{...p,bindingsFull:u.map(e=>({...e})),channelAgentRoutes:m,defaultAgentId:f}}async function ye(e){return(await s(m(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function be(e){return(await s(m(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function xe(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=N(e.bindingsFull,e.channelAgentRoutes,he(t),j(n),ge(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await s(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({bindings:i,channels:{telegram:{enabled:t.enabled,botToken:t.botToken,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 w(),o?ve(o):{...e,bindingsFull:i}}async function Se(e){return(await s(m(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Ce(e){return(await s(m(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function we(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function Te(){return a(C,T)}function Ee(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 Oe(e){return!!e.botToken?.trim()||Object.keys(e.accounts??{}).length>0}function ke(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function Ae(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}var P=r();function F({children:e}){return(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function I({children:e}){return(0,P.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function L({label:e,value:t,onChange:n,options:r}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:e}),(0,P.jsx)(`select`,{className:Te(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function je({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:o,ch:s}){if(e.length===0)return null;let c=r.length>0?r:[{id:n}];return(0,P.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(F,{children:s.agentRoutingTitle}),(0,P.jsx)(I,{children:s.agentRoutingHint})]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,P.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,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:s.agentRoutingAccountLabel}),(0,P.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:s.agentRoutingAgentLabel}),(0,P.jsx)(`select`,{id:`agent-route-${e}`,className:a(we(),T),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>o(e,t.target.value),children:c.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.name?.trim()?`${e.name} (${e.id})`:e.id},e.id))})]})]},e))})]})}function Me({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:o,toggleDisabled:s,onConfigure:c,onEdit:l,onRemove:u,ch:d}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-2xl border border-edge bg-surface-base px-4 py-4 dark:border-edge sm:flex-row sm:items-center sm:gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,P.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,P.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:d.hubConnectedBadge}):null]}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,P.jsxs)(O,{children:[(0,P.jsx)(ue,{asChild:!0,children:(0,P.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d.menuMoreAria,children:(0,P.jsx)(S,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,P.jsx)(fe,{children:(0,P.jsxs)(pe,{className:`z-[70] min-w-[11rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,P.jsx)(de,{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:()=>l(),children:(0,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(D,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),d.menuEditConfig]})}),(0,P.jsx)(de,{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:()=>u(),children:(0,P.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(h,{className:`size-4 shrink-0`,strokeWidth:1.75}),d.menuRemoveConfig]})})]})})]}),(0,P.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${d.enableChannelAria}`,disabled:s,className:a(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,i?`justify-end bg-accent`:`justify-start bg-surface-hover`,s&&`cursor-not-allowed opacity-50`),onClick:()=>void o(!i),children:(0,P.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,P.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,P.jsx)(E,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:c,children:d.hubConfigureButton})})]})}function Ne({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}){let f=we;return(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.apiRoot}),(0,P.jsx)(`input`,{className:f(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.proxy}),(0,P.jsx)(`input`,{className:f(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,P.jsx)(L,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,P.jsx)(L,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,P.jsx)(L,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:o}),(0,P.jsx)(L,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:s}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.allowFromGroups}),(0,P.jsx)(`textarea`,{className:a(f(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:De(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:Ee(e.target.value)})})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.historyLimit}),(0,P.jsx)(`input`,{type:`number`,min:10,max:200,className:f(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.textChunkLimit}),(0,P.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:f(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.multiAccountJson}),(0,P.jsx)(`textarea`,{className:a(f(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:c,onChange:e=>l(e.target.value),onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),u?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,P.jsx)(I,{children:n.multiAccountJsonDesc})]})]})}function Pe({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}){let h=we;return(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinAllowFrom}),(0,P.jsx)(`textarea`,{className:a(h(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`wxid_..., openid_...`,value:e.allowFrom.join(`, `),onChange:e=>t({allowFrom:e.target.value.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)})}),(0,P.jsx)(I,{children:n.weixinAllowFromDesc})]}),(0,P.jsx)(L,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,P.jsx)(L,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.historyLimit}),(0,P.jsx)(`input`,{type:`number`,min:10,max:200,className:h(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.textChunkLimit}),(0,P.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:h(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinRouteTag}),(0,P.jsx)(`input`,{className:h(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,P.jsx)(I,{children:n.weixinRouteTagDesc})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,P.jsx)(I,{children:n.weixinDebugDesc}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:n.weixinAccountsJson}),(0,P.jsx)(`textarea`,{className:a(h(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:o,onChange:e=>s(e.target.value),onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),c?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,P.jsx)(I,{children:n.weixinAccountsJsonDesc})]}),(0,P.jsx)(je,{accountIds:j(e),routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:n})]})}var Fe=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),R=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),z=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Ie=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Le=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Re=t((e=>{var t=R().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),ze=t((e=>{var t=R().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Be=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Ve=t((e=>{var t=z(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),He=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Ue=t((e=>{var t=He();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),We=t(((e,t)=>{var n=Ue();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Ge=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Ke=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
- ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),B=t((e=>{var t=Ge(),n=Ke();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),V=t((e=>{var t=R(),n=Ve(),r=z(),i=B(),a=Ge(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),qe=t((e=>{var t=R(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),H=t(((e,t)=>{var n=B();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Je=t(((e,t)=>{var n=B(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),U=t(((e,t)=>{var n=B();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Ye=t(((e,t)=>{var n=B(),r=R();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),W=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Xe=t((e=>{var t=B(),n=H(),r=Je(),i=U(),a=Ye(),o=Ke(),s=R(),c=W();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
- Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),G=t((e=>{var t=R(),n=z(),r=Ie(),i=Le(),a=Re(),o=ze(),s=Be(),c=Ve(),l=We(),u=V(),d=qe(),f=B(),p=Xe();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
- The chosen QR Code version cannot contain this amount of data.
6
- Minimum version required to store current data is: `+c+`.
7
- `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),Ze=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),K=t((e=>{var t=Ze();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Qe=t((e=>{var t=Ze();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
- `;return typeof a==`function`&&a(null,p),p}})),q=e(t((e=>{var t=Fe(),n=G(),r=K(),i=Qe();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function $e({open:e,onOpenChange:t,ch:n,onSetupSuccess:r}){let[i,o]=(0,k.useState)(!1),[s,c]=(0,k.useState)(`feishu`),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(null),[p,m]=(0,k.useState)(null),[h,g]=(0,k.useState)(null),[x,S]=(0,k.useState)(!1),[C,w]=(0,k.useState)(!0),ee=(0,k.useCallback)(async()=>{m(null),u(null),f(null),o(!0),w(!1);try{let e=await Se({domain:s});f(e.qrUrl),u(e.sessionKey)}catch(e){m(e instanceof Error?e.message:`Start failed`),w(!0)}finally{o(!1)}},[s]);(0,k.useEffect)(()=>{e||(u(null),f(null),m(null),g(null),S(!1),w(!0),o(!1))},[e]),(0,k.useEffect)(()=>{if(!l)return;let e=!1,n,i=async()=>{try{let i=await Ce(l);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),u(null),i.ok?(f(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(m(i.message),f(null),w(!0));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),m(i.message),u(null),f(null),w(!0))}catch(t){e||(n!==void 0&&window.clearInterval(n),m(t instanceof Error?t.message:`Request failed`),u(null),f(null),w(!0))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[l,t,r]),(0,k.useEffect)(()=>{if(!d){g(null),S(!1);return}let e=!1;return S(!1),q.toDataURL(d,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||g(t)}).catch(()=>{e||(S(!0),g(null))}),()=>{e=!0}},[d]);let T=!!(d&&l);return(0,P.jsx)(ce,{open:e,onOpenChange:t,children:(0,P.jsxs)(te,{children:[(0,P.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`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,P.jsx)(_,{asChild:!0,children:(0,P.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,P.jsx)(y,{className:`size-4`})})}),(0,P.jsx)(b,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,P.jsx)(se,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,P.jsxs)(`div`,{className:`text-center`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,P.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),C&&!T?(0,P.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`feishu-qr-domain`,children:n.feishuQrDomainLabel}),(0,P.jsxs)(`select`,{id:`feishu-qr-domain`,className:`w-full rounded-lg border border-edge bg-surface px-3 py-2 text-sm text-fg outline-none focus:ring-2 focus:ring-accent/40`,value:s,onChange:e=>c(e.target.value),children:[(0,P.jsx)(`option`,{value:`feishu`,children:`feishu (open.feishu.cn) — China`}),(0,P.jsx)(`option`,{value:`lark`,children:`lark (open.larksuite.com) — International`})]})]}),(0,P.jsx)(E,{type:`button`,variant:`primary`,className:`h-11 w-full rounded-full`,disabled:i,onClick:()=>void ee(),children:i?n.feishuQrStarting:n.feishuQrStartButton})]}):null,(0,P.jsxs)(`div`,{className:`mt-6 flex min-h-[200px] flex-col items-center justify-center`,children:[i&&!T?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrStarting}):null,p?(0,P.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:p}):null,T&&d&&!p?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrScanHint}),h&&!x?(0,P.jsx)(`img`,{src:h,alt:``,className:`h-52 w-52 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,!h&&!x?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,x?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`max-w-[16rem] text-center text-sm text-fg-muted`,children:n.feishuQrImageError}),(0,P.jsxs)(`a`,{href:d,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-accent underline-offset-2 hover:underline`,children:[(0,P.jsx)(ne,{className:`size-3.5 shrink-0`}),n.feishuQrOpenLink]})]}):null]}):null]}),T?(0,P.jsx)(`div`,{className:`mt-6`,children:(0,P.jsx)(E,{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:i,onClick:()=>void ee(),children:i?n.feishuQrStarting:n.feishuQrRegenerate})}):null]})]})})}function et({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:i}){let[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(null),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(null),[m,h]=(0,k.useState)(null),[g,x]=(0,k.useState)(null),[S,C]=(0,k.useState)(!1),w=(0,k.useCallback)(async()=>{p(null),h(null),l(null),s(!0);try{let e=await ye();d(e.qrcodeUrl),l(e.sessionKey)}catch(e){p(e instanceof Error?e.message:`Start failed`)}finally{s(!1)}},[]);(0,k.useEffect)(()=>{if(!e){l(null),d(null),p(null),x(null),C(!1),h(null);return}w()},[e,w]),(0,k.useEffect)(()=>{if(!c)return;let e=!1,i,a=async()=>{try{let a=await be(c);if(e)return;if(a.phase===`polling`){d(a.qrcodeUrl),a.qrStatus===`scaned`?h(n.weixinQrLoginScanned):h(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),l(null),a.ok?(d(null),t(!1),await r()):(p(a.message),d(null));return}a.phase===`unknown`&&h(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),p(t instanceof Error?t.message:`Request failed`),l(null),d(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,k.useEffect)(()=>{if(!u){x(null),C(!1);return}let e=!1;return C(!1),q.toDataURL(u,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||x(t)}).catch(()=>{e||(C(!0),x(null))}),()=>{e=!0}},[u]);let ee=!!(u&&c);return(0,P.jsx)(ce,{open:e,onOpenChange:t,children:(0,P.jsxs)(te,{children:[(0,P.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,52rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`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,P.jsx)(_,{asChild:!0,children:(0,P.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,P.jsx)(y,{className:`size-4`})})}),(0,P.jsx)(b,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,P.jsx)(se,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,P.jsxs)(`div`,{className:`text-center`,children:[(0,P.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,P.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,P.jsxs)(`div`,{className:`mt-6 flex min-h-[200px] flex-col items-center justify-center`,children:[o&&!ee?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.weixinQrLoginBusy}):null,f?(0,P.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:f}):null,m&&!f?(0,P.jsx)(`p`,{className:`mb-3 text-center text-sm text-accent`,children:m}):null,ee&&u&&!f?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[g&&!S?(0,P.jsx)(`img`,{src:g,alt:``,className:`h-52 w-52 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,!g&&!S?(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,S?(0,P.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`max-w-[16rem] text-center text-sm text-fg-muted`,children:n.weixinQrImageError}),(0,P.jsxs)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-accent underline-offset-2 hover:underline`,children:[(0,P.jsx)(ne,{className:`size-3.5 shrink-0`}),n.weixinQrOpenLink]})]}):null]}):null]}),(0,P.jsx)(`div`,{className:`mt-6`,children:(0,P.jsx)(E,{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:o,onClick:()=>void w(),children:o?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),i?(0,P.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function J(){let e=we,t=p(e=>e.language),n=re(t),r=n.channelsSettings,s=!!oe(e=>e.token),[m,h]=(0,k.useState)(null),[g,S]=(0,k.useState)(null),[C,w]=(0,k.useState)(!1),[T,D]=(0,k.useState)(null),[ue,O]=(0,k.useState)(!1),[de,fe]=(0,k.useState)(!1),[pe,A]=(0,k.useState)(!1),[me,j]=(0,k.useState)(!1),[M,N]=(0,k.useState)(null),[ye,be]=(0,k.useState)(null),[Se,Ce]=(0,k.useState)(!1),[Te,L]=(0,k.useState)(null),[Fe,R]=(0,k.useState)(!1),[z,Ie]=(0,k.useState)(!1),[Le,Re]=(0,k.useState)(!1),[ze,Be]=(0,k.useState)(!1),[Ve,He]=(0,k.useState)(!1),[Ue,We]=(0,k.useState)(!1),[Ge,Ke]=(0,k.useState)(!1),[B,V]=(0,k.useState)(``),[qe,H]=(0,k.useState)(``),[Je,U]=(0,k.useState)(``),[Ye,W]=(0,k.useState)(``),[Xe,G]=(0,k.useState)(``),[Ze,K]=(0,k.useState)(``),{data:Qe}=i(s?`gateway-chat-agents-ch`:null,ee,{revalidateOnFocus:!1}),{data:q,error:J,isLoading:tt,mutate:nt}=o(s),Y=(0,k.useMemo)(()=>q?.payload?.config===void 0?null:ve(q.payload.config),[q]),rt=(0,k.useMemo)(()=>!m||!g?!1:JSON.stringify(m)!==JSON.stringify(g),[m,g]);(0,k.useEffect)(()=>{if(!s){h(null),S(null);return}Y!==null&&(rt||(h(Y),S(structuredClone(Y)),V(JSON.stringify(Y.telegram.accounts??{},null,2)),H(``),U(JSON.stringify(Y.weixin.accounts??{},null,2)),W(``),G(JSON.stringify(Y.feishu?.accounts??{},null,2)),K(``),O(!1)))},[s,Y,rt]);let it=!!(s&&tt&&q===void 0&&!J),at=J instanceof Error?J.message:J?String(J):null,ot=(0,k.useCallback)((e,t,n)=>{h(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()}}}})},[]),X=(0,k.useCallback)(e=>{h(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),st=(0,k.useCallback)(e=>{h(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),Z=(0,k.useCallback)(e=>{h(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]),ct=(0,k.useCallback)(async()=>{if(!m||C)return!1;w(!0),D(null),O(!1);try{let e=await xe(m);h(e);let t=structuredClone(e);return S(t),V(JSON.stringify(t.telegram.accounts??{},null,2)),H(``),U(JSON.stringify(t.weixin.accounts??{},null,2)),W(``),G(JSON.stringify(t.feishu?.accounts??{},null,2)),K(``),O(!0),window.setTimeout(()=>O(!1),2500),!0}catch(e){return D(e instanceof Error?e.message:r.saveError),!1}finally{w(!1)}},[m,C,r.saveError]),lt=(0,k.useCallback)(async(e,t)=>{if(!m||C)return;let n=m,i=e===`weixin`?{...m,weixin:{...m.weixin,enabled:t}}:e===`telegram`?{...m,telegram:{...m.telegram,enabled:t}}:{...m,feishu:{...m.feishu,enabled:t}};h(i),w(!0),D(null);try{let e=await xe(i);h(e);let t=structuredClone(e);S(t),V(JSON.stringify(t.telegram.accounts??{},null,2)),U(JSON.stringify(t.weixin.accounts??{},null,2)),G(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){D(e instanceof Error?e.message:r.saveError),h(n)}finally{w(!1)}},[m,C,r.saveError]),ut=(0,k.useCallback)(async()=>{if(!m||!M||C)return;let e=_e(),t=M===`weixin`?{...m,weixin:e.weixin}:M===`telegram`?{...m,telegram:e.telegram}:{...m,feishu:e.feishu};w(!0),D(null);try{let e=await xe(t);h(e);let n=structuredClone(e);S(n),V(JSON.stringify(n.telegram.accounts??{},null,2)),U(JSON.stringify(n.weixin.accounts??{},null,2)),H(``),W(``),G(JSON.stringify(n.feishu?.accounts??{},null,2)),K(``),N(null),O(!0),window.setTimeout(()=>O(!1),2500)}catch(e){D(e instanceof Error?e.message:r.saveError)}finally{w(!1)}},[m,M,C,r.saveError]),dt=(0,k.useCallback)(async()=>{let e=m?.telegram.botToken;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),He(!0),window.setTimeout(()=>He(!1),2e3))},[m?.telegram.botToken]),ft=(0,k.useCallback)(e=>{Z({appId:e.appId,domain:e.domain,enabled:!0}),nt(),L(r.feishuQrSetupSuccess),window.setTimeout(()=>L(null),4e3)},[Z,nt,r.feishuQrSetupSuccess]),pt=(0,k.useCallback)(async()=>{let e=m?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),We(!0),window.setTimeout(()=>We(!1),2e3))},[m]),mt=(0,k.useCallback)(async()=>{let e=m?.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(()=>{}),Ke(!0),window.setTimeout(()=>Ke(!1),2e3)},[m]),ht=(0,k.useCallback)(()=>{if(!m)return;let e=B.trim();if(!e){X({accounts:{}}),H(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);X({accounts:t}),H(``)}catch(e){H(e instanceof Error?e.message:r.jsonInvalid)}},[m,B,X,r.jsonObjectAccounts,r.jsonInvalid]),gt=(0,k.useCallback)(()=>{if(!m)return;let e=Je.trim();if(!e){st({accounts:{}}),W(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);st({accounts:t}),W(``)}catch(e){W(e instanceof Error?e.message:r.jsonInvalid)}},[m,Je,st,r.jsonObjectAccounts,r.jsonInvalid]),_t=(0,k.useCallback)(()=>{if(!m)return;let e=Xe.trim();if(!e){Z({accounts:{}}),K(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);Z({accounts:t}),K(``)}catch(e){K(e instanceof Error?e.message:r.jsonInvalid)}},[m,Xe,Z,r.jsonObjectAccounts,r.jsonInvalid]),vt=(0,k.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:r.policy.dm[e]})),[r.policy.dm]),yt=(0,k.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:r.policy.group[e]})),[r.policy.group]),bt=(0,k.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:r.policy.reply[e]})),[r.policy.reply]),xt=(0,k.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:r.policy.stream[e]})),[r.policy.stream]);if(!s)return(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.channels}),(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(it)return(0,P.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,P.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,P.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,P.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.loading})]});if(!m)return(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:T??at??r.loadError}),(0,P.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>void nt(),children:r.retry})]});let Q=m.telegram,St=m.weixin,$=m.feishu,Ct=g?.telegram?.botToken??``,wt=!z&&!!String(Ct).trim()&&Q.botToken===Ct,Tt=g?.feishu?.appSecret??``,Et=!Le&&!!String(Tt).trim()&&$.appSecret===Tt,Dt=ke(St),Ot=Oe(Q),kt=Ae($),At=(0,P.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer list-none px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover [&::-webkit-details-marker]:hidden`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,P.jsx)(u,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),r.advancedShow]})}),(0,P.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,P.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:r.weixinAdvancedHint}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:St.enabled,onChange:e=>st({enabled:e.target.checked})}),(0,P.jsx)(`span`,{children:r.enableWeixinAria})]}),(0,P.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,P.jsx)(Pe,{wx:St,updateWeixin:st,ch:r,dmOpts:vt,streamOpts:xt,wxAccountsDraft:Je,setWxAccountsDraft:U,wxAccountsError:Ye,onWxAccountsBlur:gt,channelAgentRoutesWx:m.channelAgentRoutes.weixin,defaultAgentId:m.defaultAgentId,agentItems:Qe?.items??[],onAgentRouteChange:(e,t)=>ot(`weixin`,e,t),routingDisabled:C})}),(0,P.jsx)(E,{type:`button`,variant:`primary`,className:`w-full`,disabled:!rt||C,onClick:async()=>{await ct()},children:C?r.saving:r.save})]})]});return(0,P.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.channels}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,P.jsxs)(`a`,{href:l(t,`channels`),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,(0,P.jsx)(ne,{className:`size-3.5`})]})]}),rt?(0,P.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,ue?(0,P.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.saved}):null,T?(0,P.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T}):null,ye?(0,P.jsx)(`p`,{className:`text-xs text-accent`,children:ye}):null,Te?(0,P.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:Te}):null,(0,P.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,P.jsx)(Me,{icon:(0,P.jsx)(c,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.weixinTitle,subtitle:r.weixinSubtitle,configured:Dt,enabled:St.enabled,toggleDisabled:C,onToggle:e=>void lt(`weixin`,e),onConfigure:()=>fe(!0),onEdit:()=>fe(!0),onRemove:()=>N(`weixin`),ch:r}),(0,P.jsx)(Me,{icon:(0,P.jsx)(f,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.telegramTitle,subtitle:r.telegramSubtitle,configured:Ot,enabled:Q.enabled,toggleDisabled:C,onToggle:e=>void lt(`telegram`,e),onConfigure:()=>A(!0),onEdit:()=>A(!0),onRemove:()=>N(`telegram`),ch:r}),(0,P.jsx)(Me,{icon:(0,P.jsx)(c,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.feishuTitle,subtitle:r.feishuSubtitle,configured:kt,enabled:$.enabled,toggleDisabled:C,onToggle:e=>void lt(`feishu`,e),onConfigure:()=>j(!0),onEdit:()=>j(!0),onRemove:()=>N(`feishu`),ch:r})]}),(0,P.jsx)(et,{open:de,onOpenChange:fe,ch:r,onLoginSuccess:async()=>{await nt(),be(r.weixinQrLoginSuccess),window.setTimeout(()=>be(null),4e3)},moreSettings:At}),(0,P.jsx)($e,{open:Se,onOpenChange:Ce,ch:r,onSetupSuccess:ft}),(0,P.jsx)(ce,{open:pe,onOpenChange:A,children:(0,P.jsxs)(te,{children:[(0,P.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,`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,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(b,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.telegramTitle}),(0,P.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:r.telegramSubtitle})]}),(0,P.jsx)(_,{asChild:!0,children:(0,P.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":r.modalCancel,children:(0,P.jsx)(y,{className:`size-4`})})})]}),(0,P.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:Q.enabled,onChange:e=>X({enabled:e.target.checked})}),(0,P.jsx)(`span`,{children:r.enableTelegramAria})]}),(0,P.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsxs)(F,{children:[r.telegramToken,(0,P.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:z?`text`:`password`,autoComplete:`off`,readOnly:wt,value:wt?`*`.repeat(Math.max(1,Q.botToken.length)):Q.botToken,onChange:e=>{wt||X({botToken:e.target.value})},placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),Q.botToken?(0,P.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void dt(),children:[Ve?(0,P.jsx)(d,{className:`size-3.5`}):(0,P.jsx)(le,{className:`size-3.5`}),Ve?r.copied:r.copy]}):null,(0,P.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Ie(e=>!e),children:[z?(0,P.jsx)(ae,{className:`size-3.5`}):(0,P.jsx)(x,{className:`size-3.5`}),z?r.hide:r.show]})]}),(0,P.jsx)(I,{children:r.telegramTokenDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.allowFromDm}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:De(Q.allowFrom),onChange:e=>X({allowFrom:Ee(e.target.value)})}),(0,P.jsx)(I,{children:r.allowFromDmDesc})]}),m?(0,P.jsx)(je,{accountIds:he(Q),routes:m.channelAgentRoutes.telegram,defaultAgentId:m.defaultAgentId,agentItems:Qe?.items??[],disabled:C,onChange:(e,t)=>ot(`telegram`,e,t),ch:r}):null,(0,P.jsxs)(E,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:()=>R(e=>!e),children:[(0,P.jsx)(u,{className:a(`mr-1 size-4 transition-transform`,Fe&&`rotate-180`)}),Fe?r.advancedHide:r.advancedShow]}),Fe?(0,P.jsx)(Ne,{tg:Q,updateTelegram:X,ch:r,dmOpts:vt,groupOpts:yt,replyOpts:bt,streamOpts:xt,tgAccountsDraft:B,setTgAccountsDraft:V,tgAccountsError:qe,onTgAccountsBlur:ht}):null]}),(0,P.jsxs)(`div`,{className:`mt-8 flex flex-wrap justify-end gap-2 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:[(0,P.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>A(!1),children:r.modalCancel}),(0,P.jsx)(E,{type:`button`,variant:`primary`,disabled:!rt||C,onClick:async()=>{await ct()&&A(!1)},children:C?r.saving:r.save})]})]})]})}),(0,P.jsx)(ce,{open:me,onOpenChange:j,children:(0,P.jsxs)(te,{children:[(0,P.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,48rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2`,`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,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(b,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.feishuTitle}),(0,P.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:r.feishuSubtitle})]}),(0,P.jsx)(_,{asChild:!0,children:(0,P.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":r.modalCancel,children:(0,P.jsx)(y,{className:`size-4`})})})]}),(0,P.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.enabled,onChange:e=>Z({enabled:e.target.checked})}),(0,P.jsx)(`span`,{children:r.enableFeishuAria})]}),kt?null:(0,P.jsx)(`div`,{className:`mt-6 rounded-xl border border-dashed border-accent/40 bg-accent/5 px-4 py-3 dark:bg-accent/10`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.feishuQrSetupTitle}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:r.feishuQrSetupDesc})]}),(0,P.jsx)(E,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:()=>Ce(!0),children:r.feishuQrSetupButton})]})}),(0,P.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsxs)(F,{children:[r.feishuAppId,(0,P.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.appId,onChange:e=>Z({appId:e.target.value}),placeholder:`cli_xxx`}),(0,P.jsx)(I,{children:r.feishuAppIdDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsxs)(F,{children:[r.feishuAppSecret,(0,P.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:Le?`text`:`password`,autoComplete:`off`,readOnly:Et,value:Et?`*`.repeat(Math.max(1,$.appSecret.length)):$.appSecret,onChange:e=>{Et||Z({appSecret:e.target.value})},placeholder:`••••••••`}),$.appSecret?(0,P.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void pt(),children:[Ue?(0,P.jsx)(d,{className:`size-3.5`}):(0,P.jsx)(le,{className:`size-3.5`}),Ue?r.copied:r.copy]}):null,(0,P.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Re(e=>!e),children:[Le?(0,P.jsx)(ae,{className:`size-3.5`}):(0,P.jsx)(x,{className:`size-3.5`}),Le?r.hide:r.show]})]}),(0,P.jsx)(I,{children:r.feishuAppSecretDesc})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.feishuDomain}),(0,P.jsxs)(`select`,{className:e(),value:String($.domain||`feishu`),onChange:e=>Z({domain:e.target.value}),children:[(0,P.jsx)(`option`,{value:`feishu`,children:`feishu`}),(0,P.jsx)(`option`,{value:`lark`,children:`lark`})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.connectionMode}),(0,P.jsxs)(`select`,{className:e(),value:$.connectionMode,onChange:e=>Z({connectionMode:e.target.value}),children:[(0,P.jsx)(`option`,{value:`websocket`,children:`websocket`}),(0,P.jsx)(`option`,{value:`webhook`,children:`webhook`})]}),(0,P.jsx)(I,{children:r.connectionModeDesc})]})]}),$.connectionMode===`webhook`?(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.webhookTitle}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Be(e=>!e),children:[ze?(0,P.jsx)(ae,{className:`size-3.5`}):(0,P.jsx)(x,{className:`size-3.5`}),ze?r.hide:r.show]}),(0,P.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void mt(),children:[Ge?(0,P.jsx)(d,{className:`size-3.5`}):(0,P.jsx)(le,{className:`size-3.5`}),Ge?r.copied:r.copy]})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.verificationToken}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:ze?`text`:`password`,autoComplete:`off`,value:$.verificationToken??``,onChange:e=>Z({verificationToken:e.target.value})}),(0,P.jsx)(I,{children:r.verificationTokenDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.encryptKey}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:ze?`text`:`password`,autoComplete:`off`,value:$.encryptKey??``,onChange:e=>Z({encryptKey:e.target.value})}),(0,P.jsx)(I,{children:r.encryptKeyDesc})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,P.jsx)(F,{children:r.webhookHost}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.webhookHost??``,onChange:e=>Z({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.webhookPort}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String($.webhookPort??``),onChange:e=>Z({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.webhookPath}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.webhookPath??``,onChange:e=>Z({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,P.jsx)(I,{children:r.webhookPathDesc})]})]}):null,(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.renderMode}),(0,P.jsxs)(`select`,{className:e(),value:$.renderMode,onChange:e=>Z({renderMode:e.target.value}),children:[(0,P.jsx)(`option`,{value:`auto`,children:`auto`}),(0,P.jsx)(`option`,{value:`raw`,children:`raw`}),(0,P.jsx)(`option`,{value:`card`,children:`card`})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.reactionNotifications}),(0,P.jsxs)(`select`,{className:e(),value:$.reactionNotifications,onChange:e=>Z({reactionNotifications:e.target.value}),children:[(0,P.jsx)(`option`,{value:`off`,children:`off`}),(0,P.jsx)(`option`,{value:`own`,children:`own`}),(0,P.jsx)(`option`,{value:`all`,children:`all`})]})]})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.streaming,onChange:e=>Z({streaming:e.target.checked})}),r.enableStreaming]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.dmPolicy}),(0,P.jsx)(`select`,{className:e(),value:$.dmPolicy,onChange:e=>Z({dmPolicy:e.target.value}),children:vt.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.groupPolicy}),(0,P.jsx)(`select`,{className:e(),value:$.groupPolicy,onChange:e=>Z({groupPolicy:e.target.value}),children:yt.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.requireMention,onChange:e=>Z({requireMention:e.target.checked})}),r.requireMention]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.allowFromDm}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:De($.allowFrom),onChange:e=>Z({allowFrom:Ee(e.target.value)})}),(0,P.jsx)(I,{children:r.allowFromDmDesc})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.allowFromGroups}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:De($.groupAllowFrom),onChange:e=>Z({groupAllowFrom:Ee(e.target.value)})}),(0,P.jsx)(I,{children:r.allowFromGroupsDesc})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.historyLimit}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String($.historyLimit),onChange:e=>Z({historyLimit:Number(e.target.value||`0`)||0})})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.textChunkLimit}),(0,P.jsx)(`input`,{className:a(e(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String($.textChunkLimit),onChange:e=>Z({textChunkLimit:Number(e.target.value||`0`)||0})})]})]}),(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.feishuToolsTitle}),(0,P.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[`doc`,r.feishuToolDoc],[`wiki`,r.feishuToolWiki],[`drive`,r.feishuToolDrive],[`perm`,r.feishuToolPerm],[`bitable`,r.feishuToolBitable],[`scopes`,r.feishuToolScopes]].map(([e,t])=>(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!$.tools?.[e],onChange:t=>Z({tools:{...$.tools,[e]:t.target.checked}})}),t]},e))}),(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsx)(I,{children:r.feishuToolsDesc})})]}),(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.feishuActionsTitle}),(0,P.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!$.actions?.reactions,onChange:e=>Z({actions:{...$.actions,reactions:e.target.checked}})}),r.feishuActionReactions]})]}),m?(0,P.jsx)(je,{accountIds:ge($),routes:m.channelAgentRoutes.feishu,defaultAgentId:m.defaultAgentId,agentItems:Qe?.items??[],disabled:C,onChange:(e,t)=>ot(`feishu`,e,t),ch:r}):null,(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(F,{children:r.multiAccountJson}),(0,P.jsx)(`textarea`,{className:a(e(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:Xe,onChange:e=>G(e.target.value),onBlur:_t,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),Ze?(0,P.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:Ze}):(0,P.jsx)(I,{children:r.multiAccountJsonDesc})]})]}),(0,P.jsxs)(`div`,{className:`mt-8 flex flex-wrap justify-end gap-2 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:[(0,P.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>j(!1),children:r.modalCancel}),(0,P.jsx)(E,{type:`button`,variant:`primary`,disabled:!rt||C,onClick:async()=>{await ct()&&j(!1)},children:C?r.saving:r.save})]})]})]})}),(0,P.jsx)(ce,{open:M!==null,onOpenChange:e=>!e&&N(null),children:(0,P.jsxs)(te,{children:[(0,P.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[1px]`}),(0,P.jsxs)(ie,{className:a(`fixed left-1/2 top-1/2 z-[70] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,P.jsx)(b,{className:`text-base font-semibold text-fg`,children:r.removeChannelTitle}),(0,P.jsx)(se,{className:`mt-2 text-sm text-fg-muted`,children:M?r.removeChannelConfirm.replace(`{{name}}`,M===`weixin`?r.weixinTitle:M===`telegram`?r.telegramTitle:r.feishuTitle):`\xA0`}),(0,P.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,P.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>N(null),children:r.modalCancel}),(0,P.jsx)(E,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:C,onClick:()=>void ut(),children:C?r.saving:r.removeChannelAction})]})]})]})})]})})}export{J as ChannelsSettingsPanel};
9
- //# sourceMappingURL=channels-settings-BAvk9-aK.js.map
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{t as r}from"./cn-BMCV0OMB.js";import{H as i,Kn as a,Kt as o,Pn as s,Qt as c,Sr as ee,U as te,V as ne,Wr as re,Xn as ie,Zt as ae,at as l,cr as u,ct as d,d as oe,dn as se,dt as f,fr as ce,gr as le,h as ue,in as p,it as de,jn as m,l as fe,lt as h,m as pe,nn as g,nr as me,on as he,ot as ge,qt as _e,rt as ve,sn as _,tn as v,ut as ye,xn as be}from"./index-BZvlG48D.js";import{C as xe,S as Se,_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,t as ze,u as Be,v as Ve,x as He,y as Ue}from"./cron-utils-DyOO6TdN.js";import{a as We,i as Ge,n as Ke,r as qe,t as Je}from"./dist-Brod9LF3.js";var y=e(t(),1);function Ye(e,t){let n=e.templates;if(!n||typeof n!=`object`)return;let r=n[t];if(!r||typeof r!=`object`)return;let i=r.title?.trim(),a=r.prompt?.trim();if(!(!i||!a))return{title:i,description:(r.description??``).trim(),prompt:a}}var b=[`daily`,`monitoring`,`reports`,`automation`],Xe=[{templateId:`morning_briefing`,category:`daily`,defaultSchedule:`0 7 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`standup_prep`,category:`daily`,defaultSchedule:`0 8 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`end_of_day_wrap_up`,category:`daily`,defaultSchedule:`0 18 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`inbox_triage`,category:`daily`,defaultSchedule:`30 8 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`competitor_watch`,category:`monitoring`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{templateId:`trending_topics_monitor`,category:`monitoring`,defaultSchedule:`0 10 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`tech_radar_stack`,category:`monitoring`,defaultSchedule:`0 11 * * 3`,defaultSessionTarget:`isolated`},{templateId:`dependency_check_audit`,category:`monitoring`,defaultSchedule:`0 9 * * 0`,defaultSessionTarget:`isolated`},{templateId:`weekly_review`,category:`reports`,defaultSchedule:`0 17 * * 5`,defaultSessionTarget:`isolated`},{templateId:`code_quality_report`,category:`reports`,defaultSchedule:`0 14 * * 1`,defaultSessionTarget:`isolated`},{templateId:`git_activity_summary`,category:`reports`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{templateId:`user_feedback_digest`,category:`reports`,defaultSchedule:`0 16 * * 5`,defaultSessionTarget:`isolated`},{templateId:`stale_todo_or_issue_sweep`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`},{templateId:`release_notes_or_changelog_draft`,category:`automation`,defaultSchedule:`0 10 * * 4`,defaultSessionTarget:`isolated`},{templateId:`workspace_cleanup_suggestions`,category:`automation`,defaultSchedule:`30 18 * * 5`,defaultSessionTarget:`isolated`},{templateId:`smoke_or_ci_health_reminder`,category:`automation`,defaultSchedule:`0 8 * * 1`,defaultSessionTarget:`isolated`}];function Ze(e){return Xe.find(t=>t.templateId===e)}var x=n();function Qe(e){let{cron:t,localeTag:n,scheduleBadgeLabels:i,categoryFilter:a,onCategoryFilterChange:o,onSelectTemplate:s}=e,c=a===`all`?[...Xe]:Xe.filter(e=>e.category===a);return(0,x.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.fromTemplate,children:[(0,x.jsx)(_,{type:`button`,variant:a===`all`?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>o(`all`),children:t.templateFilterAll}),b.map(e=>(0,x.jsx)(_,{type:`button`,variant:a===e?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>o(e),children:t.templateCategories[e]},e))]}),c.length===0?(0,x.jsx)(`p`,{className:`text-center text-sm text-fg-muted`,children:t.templatesEmptyHint}):(0,x.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:c.map(e=>{let a=Ye(t,e.templateId);if(!a)return null;let o=Fe({schedule:e.defaultSchedule,timezone:void 0,next_run:void 0},n,i);return(0,x.jsxs)(`button`,{type:`button`,className:r(`flex flex-col gap-1.5 rounded-xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:border-accent/40 hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>s(e.templateId),"aria-label":`${t.templateCategories[e.category]} — ${a.title}`,children:[(0,x.jsx)(`span`,{className:`font-semibold text-fg`,children:a.title}),(0,x.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:a.description}),(0,x.jsx)(`span`,{className:`mt-1 flex items-center gap-1 text-xs text-fg-muted`,children:(0,x.jsx)(`span`,{className:`tabular-nums`,children:o})})]},e.templateId)})})]})}var S=Me(),C=r(p,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),w=r(`h-9 min-w-[6.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,v,`dark:bg-surface-panel`),$e=r(`h-9 min-w-[9.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,v),T=r(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,v),et=r(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,v);function tt(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function E(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`).sort((e,t)=>e-t):[]}function D(e){if(e.length<2)return null;let t=e[1]-e[0];if(t<=0)return null;for(let n=2;n<e.length;n++)if(e[n]-e[n-1]!==t)return null;return t}function nt(e){let t=[];for(let n=0;n<7;n++)e[n]&&t.push(n===6?0:n+1);return t.length===0?`1`:t.sort((e,t)=>e-t).join(`,`)}function O(e){let t=[!1,!1,!1,!1,!1,!1,!1];for(let n of e){let e=n===0||n===7?6:n-1;e>=0&&e<=6&&(t[e]=!0)}return t}function rt(e){let t=e.trim(),n={mode:`custom`,intervalKind:`minutes`,onceDate:tt(),intervalMinutes:5,intervalHours:2,minute:0,hour:9,weekDays:[!0,!0,!0,!0,!0,!1,!1],dayOfMonth:1,rawCron:t};if(!t)return{...n,mode:`interval`,rawCron:`*/5 * * * *`};try{let e=S.CronExpressionParser.parse(t).fields,r=E(e.minute.values),i=E(e.hour.values),a=E(e.dayOfMonth.values),o=E(e.month.values),s=E(e.dayOfWeek.values);if(r.length===60&&e.hour.isWildcard&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard)return{...n,mode:`interval`,intervalKind:`minutes`,intervalMinutes:1,rawCron:t};if(!e.minute.isWildcard&&e.hour.isWildcard&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard&&r.length>1){let e=D(r);if(e!=null&&e>0)return{...n,mode:`interval`,intervalKind:`minutes`,intervalMinutes:e,rawCron:t}}if(!e.minute.isWildcard&&r.length===1&&!e.hour.isWildcard&&i.length>1&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard){let e=D(i);if(e!=null&&e>0)return{...n,mode:`interval`,intervalKind:`hours`,intervalHours:e,minute:r[0],rawCron:t}}if(!e.minute.isWildcard&&r.length===1&&e.hour.isWildcard&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard&&i.length===24)return{...n,mode:`hourly`,minute:r[0],rawCron:t};if(r.length===1&&i.length===1&&a.length===1&&o.length===1&&!e.dayOfMonth.isWildcard&&!e.month.isWildcard&&e.dayOfWeek.isWildcard){let e=new Date().getFullYear(),s=o[0],c=a[0],ee=`${e}-${String(s).padStart(2,`0`)}-${String(c).padStart(2,`0`)}`;return{...n,mode:`no_repeat`,minute:r[0],hour:i[0],onceDate:ee,rawCron:t}}if(r.length===1&&i.length===1&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&e.dayOfWeek.isWildcard)return{...n,mode:`daily`,minute:r[0],hour:i[0],rawCron:t};if(r.length===1&&i.length===1&&e.dayOfMonth.isWildcard&&e.month.isWildcard&&!e.dayOfWeek.isWildcard&&s.length>0)return{...n,mode:`weekly`,minute:r[0],hour:i[0],weekDays:O(s),rawCron:t};if(r.length===1&&i.length===1&&!e.dayOfMonth.isWildcard&&a.length===1&&e.month.isWildcard&&e.dayOfWeek.isWildcard)return{...n,mode:`monthly`,minute:r[0],hour:i[0],dayOfMonth:a[0],rawCron:t}}catch{}return n}function it(e){let t=(e,t,n)=>Math.min(n,Math.max(t,e));switch(e.mode){case`custom`:return e.rawCron.trim()||`*/5 * * * *`;case`no_repeat`:{let n=e.onceDate.split(`-`);if(n.length===3){let r=t(parseInt(n[2],10),1,31),i=t(parseInt(n[1],10),1,12);return`${t(e.minute,0,59)} ${t(e.hour,0,23)} ${r} ${i} *`}return`0 9 1 1 *`}case`interval`:if(e.intervalKind===`hours`){let n=t(Math.round(e.intervalHours)||1,1,23);return`${t(e.minute,0,59)} */${n} * * *`}return`*/${t(Math.round(e.intervalMinutes)||5,1,59)} * * * *`;case`hourly`:return`${t(e.minute,0,59)} * * * *`;case`daily`:return`${t(e.minute,0,59)} ${t(e.hour,0,23)} * * *`;case`weekly`:return`${t(e.minute,0,59)} ${t(e.hour,0,23)} * * ${nt(e.weekDays)}`;case`monthly`:return`${t(e.minute,0,59)} ${t(e.hour,0,23)} ${t(Math.round(e.dayOfMonth)||1,1,31)} * *`;default:return`*/5 * * * *`}}function at({value:e,onChange:t,labels:n,disabled:i}){let a=(0,y.useMemo)(()=>rt(e),[e]),[o,s]=(0,y.useState)(a.mode),[c,ee]=(0,y.useState)(a.intervalKind),[te,ne]=(0,y.useState)(a.onceDate),[re,ie]=(0,y.useState)(a.intervalMinutes),[ae,l]=(0,y.useState)(a.intervalHours),[u,d]=(0,y.useState)(a.minute),[oe,se]=(0,y.useState)(a.hour),[f,ce]=(0,y.useState)(a.weekDays),[le,ue]=(0,y.useState)(a.dayOfMonth),[p,de]=(0,y.useState)(a.rawCron),[m,fe]=(0,y.useState)(null),[h,pe]=(0,y.useState)(null);(0,y.useEffect)(()=>{let t=rt(e);s(t.mode),ee(t.intervalKind),ne(t.onceDate),ie(t.intervalMinutes),l(t.intervalHours),d(t.minute),se(t.hour),ce(t.weekDays),ue(t.dayOfMonth),de(t.rawCron),fe(null),pe(null)},[e]);let g=(0,y.useCallback)(e=>{t(it({mode:o,intervalKind:c,onceDate:te,intervalMinutes:re,intervalHours:ae,minute:u,hour:oe,weekDays:f,dayOfMonth:le,rawCron:p,...e}))},[o,c,te,re,ae,u,oe,f,le,p,t]),me=`${String(oe).padStart(2,`0`)}:${String(u).padStart(2,`0`)}`,he=e=>{let t=e.target.value;if(!t)return;let[n,r]=t.split(`:`).map(e=>parseInt(e,10));Number.isNaN(n)||Number.isNaN(r)||g({minute:r,hour:n})},ge=(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,x.jsxs)(`select`,{className:C,disabled:i,value:o,onChange:e=>{let t=e.target.value;s(t),g({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,x.jsx)(`option`,{value:`no_repeat`,children:n.modeNoRepeat}),(0,x.jsx)(`option`,{value:`interval`,children:n.modeInterval}),(0,x.jsx)(`option`,{value:`hourly`,children:n.modeHourly}),(0,x.jsx)(`option`,{value:`daily`,children:n.modeDaily}),(0,x.jsx)(`option`,{value:`weekly`,children:n.modeWeekly}),(0,x.jsx)(`option`,{value:`monthly`,children:n.modeMonthly}),(0,x.jsx)(`option`,{value:`custom`,children:n.modeCustom})]}),o===`no_repeat`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`input`,{type:`date`,disabled:i,className:$e,value:te,onChange:e=>{let t=e.target.value;ne(t),g({onceDate:t})},"aria-label":n.modeNoRepeat}),(0,x.jsx)(`input`,{type:`time`,step:60,disabled:i,className:w,value:me,onChange:he,"aria-label":n.scheduleTimeLabel})]}),o===`interval`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`select`,{className:r(C,`w-auto min-w-[5rem]`),disabled:i,value:c,onChange:e=>{let t=e.target.value;ee(t),fe(null),pe(null),g({intervalKind:t})},"aria-label":n.modeInterval,children:[(0,x.jsx)(`option`,{value:`minutes`,children:n.intervalKindMinutes}),(0,x.jsx)(`option`,{value:`hours`,children:n.intervalKindHours})]}),c===`minutes`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`input`,{type:`number`,min:1,max:59,disabled:i,className:T,value:m??String(re),onChange:e=>{let t=e.target.value;fe(t);let n=parseInt(t,10);Number.isFinite(n)&&n>=1&&n<=59&&(ie(n),g({intervalMinutes:n}))},onBlur:()=>{if(m===null)return;let e=parseInt(m,10),t=!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e)));ie(t),g({intervalMinutes:t}),fe(null)},"aria-label":n.intervalMinutes}),(0,x.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`input`,{type:`number`,min:1,max:23,disabled:i,className:T,value:h??String(ae),onChange:e=>{let t=e.target.value;pe(t);let n=parseInt(t,10);Number.isFinite(n)&&n>=1&&n<=23&&(l(n),g({intervalHours:n}))},onBlur:()=>{if(h===null)return;let e=parseInt(h,10),t=!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e)));l(t),g({intervalHours:t}),pe(null)},"aria-label":n.intervalHours}),(0,x.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,x.jsx)(`select`,{className:r(C,`w-auto min-w-[4rem]`),disabled:i,value:u,onChange:e=>{let t=parseInt(e.target.value,10);d(t),g({minute:t})},"aria-label":n.minuteAtHour,children:Array.from({length:60},(e,t)=>(0,x.jsx)(`option`,{value:t,children:String(t).padStart(2,`0`)},t))}),(0,x.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),o===`daily`&&(0,x.jsx)(`input`,{type:`time`,step:60,disabled:i,className:w,value:me,onChange:he,"aria-label":n.scheduleTimeLabel}),o===`weekly`&&(0,x.jsx)(`input`,{type:`time`,step:60,disabled:i,className:w,value:me,onChange:he,"aria-label":n.scheduleTimeLabel}),o===`monthly`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`select`,{className:r(C,`w-auto min-w-[4.5rem]`),disabled:i,value:le,onChange:e=>{let t=parseInt(e.target.value,10);ue(t),g({dayOfMonth:t})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))}),(0,x.jsx)(`input`,{type:`time`,step:60,disabled:i,className:w,value:me,onChange:he,"aria-label":n.scheduleTimeLabel})]}),o===`hourly`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`select`,{className:r(C,`w-auto min-w-[4rem]`),disabled:i,value:u,onChange:e=>{let t=parseInt(e.target.value,10);d(t),g({minute:t})},"aria-label":n.minuteAtHour,children:Array.from({length:60},(e,t)=>(0,x.jsx)(`option`,{value:t,children:String(t).padStart(2,`0`)},t))}),(0,x.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),_e=o===`weekly`?(0,x.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=f[t];return(0,x.jsx)(`button`,{type:`button`,disabled:i,className:r(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...f];e[t]=!e[t],ce(e),g({weekDays:e})},children:e},e)})}):null,ve=o===`custom`?(0,x.jsxs)(`div`,{className:`pt-1`,children:[(0,x.jsx)(`textarea`,{disabled:i,className:et,rows:2,spellCheck:!1,value:p,placeholder:`*/5 * * * *`,onChange:e=>{let n=e.target.value;de(n),t(n.trim()||`*/5 * * * *`)},"aria-label":n.modeCustom}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,x.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}),ge,_e,ve]})}var ot=400;function st(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function ct(e){let t=st(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function lt(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}var ut=`*/5 * * * *`,dt=`xopc.recentWorkspaceDirs.v1`,k=10;function ft(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function pt(e){let t=e.trim();if(t)try{let e=localStorage.getItem(dt),n=e?JSON.parse(e):[],r=[t,...(Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.trim().length>0):[]).filter(e=>e!==t)].slice(0,k);localStorage.setItem(dt,JSON.stringify(r))}catch{}}function mt(e){return r(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,v,e&&`cursor-not-allowed opacity-60`)}function ht(){return r(p,g)}var gt=r(p,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),_t=r(p,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function vt(){let e=c(e=>e.language),t=he(e),n=t.cron,p=t.chat,g=!!_e(e=>e.token),v=ae(e=>e.resolved)===`dark`,Me=e===`zh`?`zh-CN`:`en-US`,[b,Xe]=(0,y.useState)([]),[S,C]=(0,y.useState)(`tasks`),[w,$e]=(0,y.useState)(`created_desc`),[T,et]=(0,y.useState)(`day`),[tt,E]=(0,y.useState)(``),[D,nt]=(0,y.useState)(``),[O,rt]=(0,y.useState)(!1),it=(0,y.useRef)(null),dt=(0,y.useRef)(O),k=typeof navigator<`u`&&`wakeLock`in navigator,[vt,yt]=(0,y.useState)([]),[bt,xt]=(0,y.useState)([]),[St,Ct]=(0,y.useState)(``),[wt,Tt]=(0,y.useState)([]),[Et,Dt]=(0,y.useState)([]),[Ot,kt]=(0,y.useState)(!1),[At,A]=(0,y.useState)(null),[jt,Mt]=(0,y.useState)([]),[j,Nt]=(0,y.useState)(!1),[M,Pt]=(0,y.useState)(!1),[N,Ft]=(0,y.useState)(`add`),[It,Lt]=(0,y.useState)(null),[Rt,zt]=(0,y.useState)(``),[Bt,Vt]=(0,y.useState)(ut),[P,F]=(0,y.useState)(`local`),[Ht,I]=(0,y.useState)(``),[L,R]=(0,y.useState)(``),[Ut,Wt]=(0,y.useState)(`edit`),[Gt,Kt]=(0,y.useState)(0),[z,B]=(0,y.useState)(`main`),[qt,V]=(0,y.useState)(``),[Jt,H]=(0,y.useState)(!1),[U,W]=(0,y.useState)(``),[Yt,Xt]=(0,y.useState)(!1),[Zt,G]=(0,y.useState)(``),[K,Qt]=(0,y.useState)(!1),$t=(0,y.useRef)(!1),[en,tn]=(0,y.useState)(!1),[q,nn]=(0,y.useState)(null),[rn,an]=(0,y.useState)([]),[on,sn]=(0,y.useState)(!1),[cn,ln]=(0,y.useState)(!1),[J,un]=(0,y.useState)(null),[dn,fn]=(0,y.useState)(null),[pn,mn]=(0,y.useState)(!1),[hn,gn]=(0,y.useState)(`all`),Y=(0,y.useRef)(null),_n=(0,y.useCallback)(e=>{Y.current=e,window.setTimeout(()=>{Y.current===e&&(Y.current=null)},400)},[]),X=(0,y.useCallback)(()=>St||(bt.length>0?bt[0].id:``),[St,bt]),vn=typeof window<`u`&&!!window.electronAPI?.file?.openDirectory,yn=(0,y.useCallback)(async()=>{let e=typeof window<`u`?window.electronAPI?.file?.openDirectory:void 0;return e?e():null},[]),bn=(0,y.useCallback)(async e=>{let t=e.trim();t&&(pt(t),W(t))},[]),xn=(0,y.useMemo)(()=>{let e=new Set(Et.map(e=>e.id)),t=[...Et],n=qt.trim().toLowerCase();return n&&!e.has(n)&&t.push({id:n}),t},[Et,qt]),Sn=P!==`local`&&(z===`main`||z===`isolated`&&!Jt),Cn=z===`main`||z===`isolated`&&!Jt,wn=!!Rt.trim()&&!!Bt.trim()&&!!L.trim()&&(!Sn||!!Ht.trim()),Z=(0,y.useCallback)(async()=>{Nt(!0);try{Mt(await Oe(ot))}catch{}finally{Nt(!1)}},[]),Q=(0,y.useCallback)(async()=>{kt(!0),A(null);try{Xe(await Ue())}catch(e){A(e instanceof Error?e.message:n.failedToLoadJobs)}finally{kt(!1)}},[n.failedToLoadJobs]),$=(0,y.useCallback)(async()=>{try{let[e,t,n,r]=await Promise.all([Ie(),Ce(),Ne(),fe().catch(()=>null)]);yt(e),xt(t),Ct(n.model||``),r&&Dt(r.items)}catch{}},[]);(0,y.useEffect)(()=>{g&&(Q(),$())},[g,Q,$]),(0,y.useEffect)(()=>{!g||S!==`history`||Z()},[g,S,Z]);let Tn=(0,y.useCallback)(async()=>{try{await it.current?.release()}catch{}it.current=null},[]),En=(0,y.useCallback)(async()=>{if(k)try{let e=await navigator.wakeLock.request(`screen`);it.current=e,e.addEventListener(`release`,()=>{it.current=null})}catch{A(n.wakeLockUnavailable),rt(!1)}},[n.wakeLockUnavailable,k]);dt.current=O,(0,y.useEffect)(()=>{if(!O){Tn();return}En();let e=()=>{document.visibilityState===`visible`&&dt.current&&En()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),Tn()}},[O,En,Tn]),(0,y.useEffect)(()=>{if(!M||N!==`add`||$t.current)return;let e=X();e&&G(e)},[M,N,X]),(0,y.useEffect)(()=>{!M||N!==`add`||new Set([`local`,...vt.map(e=>e.name)]).has(P)||F(`local`)},[vt,P,N,M]),(0,y.useEffect)(()=>{if(P===`local`){Tt([]);return}let e=!1;return Ve(P).then(t=>{e||Tt(t)}),()=>{e=!0}},[P,M]);let Dn=(0,y.useCallback)(e=>{if($t.current=!1,Pt(!0),Ft(e?`edit`:`add`),Lt(e?.id??null),e){zt(e.name||``),Vt(e.schedule&&String(e.schedule).trim()||ut);let t=De(e);R(t??``),B(e.sessionTarget||`main`),V((e.sessionTarget||`main`)===`isolated`&&e.agentId?.trim()?e.agentId.trim().toLowerCase():``),W((e.sessionTarget||`main`)===`isolated`&&e.workingDirectory?.trim()?e.workingDirectory.trim():``);let n=e.payload?.kind===`agentTurn`&&e.payload.model?.trim()?e.payload.model.trim():``;G(e.model?.trim()||n||X());let r=e.delivery?.channel===`local`,i=(e.sessionTarget||`main`)===`isolated`&&!r&&(!e.delivery?.to||e.delivery.mode===`none`);if(H(i),r)F(`local`),I(``);else if(e.delivery&&e.delivery.mode!==`none`&&e.delivery.to)F(e.delivery.channel||`telegram`),I(e.delivery.to||``);else if(i)F(`telegram`),I(``);else{let e=t.split(`:`);e.length>=3&&[`telegram`,`cli`,`gateway`,`local`].includes(e[0])?(F(e[0]),I(e[1]),R(e.slice(2).join(`:`))):(F(`telegram`),I(``))}}else zt(``),Vt(ut),F(`local`),I(``),R(``),B(`main`),V(``),W(``),H(!1),G(X());Wt(`edit`),Kt(e=>e+1)},[X]),On=(0,y.useCallback)(e=>{Wt(e),e===`edit`&&Kt(e=>e+1)},[]),kn=(0,y.useCallback)(e=>{let n=Ze(e),r=n?Ye(t.cron,e):void 0;!n||!r||($t.current=!1,Ft(`add`),Lt(null),zt(r.title),Vt(n.defaultSchedule),R(r.prompt),B(n.defaultSessionTarget),F(`local`),I(``),H(!1),V(``),W(``),G(X()),Wt(`edit`),Kt(e=>e+1),mn(!1),Pt(!0))},[X,t.cron]),An=(0,y.useCallback)(()=>{Pt(!1),Ft(`add`),Lt(null),zt(``),Vt(ut),F(`local`),I(``),R(``),B(`main`),V(``),W(``),Xt(!1),H(!1),G(``),Wt(`edit`),$t.current=!1},[]),jn=async()=>{if(!Rt.trim()){A(n.nameRequired);return}if(!Bt.trim()||!L.trim()){A(n.scheduleRequired);return}if(Sn&&!Ht.trim()){A(n.chatIdRequired);return}Qt(!0),A(null);try{let e=L.trim(),t;t=z===`isolated`&&Jt?{mode:`none`}:P===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:P,to:Ht.trim()};let n=z===`isolated`?{kind:`agentTurn`,message:e,...Zt.trim()?{model:Zt.trim()}:{}}:{kind:`systemEvent`,text:e},r=Zt.trim(),i=qt.trim().toLowerCase(),a=z===`main`?null:i||null,o=U.trim(),s={name:Rt.trim(),schedule:Bt.trim(),sessionTarget:z,model:z===`isolated`&&r?r:void 0,delivery:t,payload:n,...N===`edit`?{agentId:a,workingDirectory:z===`isolated`&&o||null}:{...z===`isolated`&&i?{agentId:i}:{},...z===`isolated`&&o?{workingDirectory:o}:{}}};if(N===`edit`&&It)await xe(It,s);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=s;await Be(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}An(),await Q(),await $()}catch(e){A(e instanceof Error?e.message:N===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{Qt(!1)}},Mn=async e=>{tn(!0),nn(e),sn(!0),an([]);try{let t=await ke(e.id);t&&(nn(t),an(await Ae(e.id,20)))}catch{}finally{sn(!1)}},Nn=async(e,t)=>{try{await Se(e.id,t),await Q(),await $()}catch(e){A(e instanceof Error?e.message:n.failedToToggleJob)}},Pn=async()=>{if(!dn||!J)return;let e=dn,t=J;ln(!1),fn(null),un(null);try{t===`run`?await He(e):(await Te(e),q?.id===e&&(tn(!1),nn(null))),await Q(),await $(),await Z()}catch(e){A(e instanceof Error?e.message:n.actionFailed)}};(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(M?An():en&&(tn(!1),nn(null)))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[M,en,An]);let Fn={running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled},In=(0,y.useMemo)(()=>{let e=[...b];return e.sort((e,t)=>{let n=new Date(e.created_at).getTime(),r=new Date(t.created_at).getTime();return w===`created_desc`?r-n:n-r}),e},[b,w]),Ln=(0,y.useMemo)(()=>{let e=new Date,t=T===`day`?st(e):T===`week`?ct(e):lt(e);return jt.filter(e=>!(new Date(e.startedAt)<t||tt&&e.jobId!==tt||D&&e.status!==D))},[jt,T,tt,D]),Rn=n.scheduleBadge,zn=(0,y.useCallback)(()=>{Q(),$(),Z()},[Q,$,Z]),Bn=o(e=>e.setPageHeader),Vn=o(e=>e.clearPageHeader),{pathname:Hn}=re(),Un=Hn.startsWith(`/settings/`),Wn=(0,y.useMemo)(()=>(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,x.jsx)(_,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,disabled:Ot||j,title:n.refresh,"aria-label":n.refresh,onClick:()=>void zn(),children:(0,x.jsx)(m,{className:r(`size-4`,(Ot||j)&&`animate-spin`),strokeWidth:1.75})}),(0,x.jsxs)(_,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:()=>{gn(`all`),mn(!0)},children:[(0,x.jsx)(ie,{className:`size-4`,strokeWidth:1.75}),n.fromTemplate]}),(0,x.jsxs)(_,{type:`button`,variant:`primary`,className:`gap-2`,onClick:()=>Dn(),children:[(0,x.jsx)(s,{className:`size-4`,strokeWidth:1.75}),n.addJob]})]}),[n.addJob,n.fromTemplate,n.refresh,Ot,Dn,zn,j]);return(0,y.useLayoutEffect)(()=>!g||Un?(Vn(),()=>Vn()):(Bn({startExtra:null,main:null,end:Wn}),()=>Vn()),[Vn,Wn,g,Un,Bn]),g?(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:[(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[At?(0,x.jsx)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,role:`alert`,children:At}):null,(0,x.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),(0,x.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:n.subtitle})]})}),Un?(0,x.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:Wn}):null,(0,x.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,x.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":n.title,children:[(0,x.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`tasks`,className:r(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,S===`tasks`?`text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>C(`tasks`),children:n.tabMyTasks}),(0,x.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`history`,className:r(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,S===`history`?`text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>C(`history`),children:n.tabRunHistory})]}),(0,x.jsx)(`div`,{className:r(`flex min-w-0 items-center gap-2`,S===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`),children:S===`tasks`?(0,x.jsxs)(`select`,{className:_t,value:w,onChange:e=>$e(e.target.value),"aria-label":n.sortCreatedDesc,children:[(0,x.jsx)(`option`,{value:`created_desc`,children:n.sortCreatedDesc}),(0,x.jsx)(`option`,{value:`created_asc`,children:n.sortCreatedAsc})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:r(de,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,x.jsx)(`button`,{type:`button`,className:r(ve,`px-2.5 py-1`,T===e&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,T===e&&`text-fg`),onClick:()=>et(e),children:e===`day`?n.historyRangeDay:e===`week`?n.historyRangeWeek:n.historyRangeMonth},e))}),(0,x.jsxs)(`select`,{className:_t,value:tt,onChange:e=>E(e.target.value),"aria-label":n.filterAllTasks,children:[(0,x.jsx)(`option`,{value:``,children:n.filterAllTasks}),b.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))]}),(0,x.jsxs)(`select`,{className:_t,value:D,onChange:e=>nt(e.target.value),"aria-label":n.filterAllStatuses,children:[(0,x.jsx)(`option`,{value:``,children:n.filterAllStatuses}),(0,x.jsx)(`option`,{value:`success`,children:n.execStatusSuccess}),(0,x.jsx)(`option`,{value:`failed`,children:n.execStatusFailed}),(0,x.jsx)(`option`,{value:`cancelled`,children:n.execStatusCancelled}),(0,x.jsx)(`option`,{value:`running`,children:n.execStatusRunning})]})]})})]}),S===`tasks`?(0,x.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[(0,x.jsx)(`h2`,{id:`cron-tasks-panel`,className:`sr-only`,children:n.tabMyTasks}),(0,x.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[(0,x.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,x.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[(0,x.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),(0,x.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":O,disabled:!k,title:k?void 0:n.wakeLockUnavailable,className:r(`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`,!k&&`cursor-not-allowed opacity-50`),onClick:()=>{k?rt(e=>!e):A(n.wakeLockUnavailable)},children:(0,x.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]})]}),Ot&&b.length===0?(0,x.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,x.jsx)(a,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):b.length===0?(0,x.jsxs)(`div`,{className:`flex flex-col gap-6 rounded-2xl bg-surface-base px-4 py-8 dark:bg-surface-hover/25 sm:px-6 sm:py-10`,children:[(0,x.jsx)(`div`,{className:`w-full max-w-3xl`,children:(0,x.jsx)(Qe,{cron:n,localeTag:Me,scheduleBadgeLabels:Rn,categoryFilter:hn,onCategoryFilterChange:gn,onSelectTemplate:kn})}),(0,x.jsx)(`div`,{className:`flex justify-center`,children:(0,x.jsx)(_,{type:`button`,variant:`primary`,onClick:()=>Dn(),children:n.emptyStateCta})})]}):(0,x.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:In.map(e=>(0,x.jsxs)(`article`,{role:`button`,tabIndex:0,className:r(`flex cursor-pointer flex-col rounded-xl border border-edge-subtle bg-surface-base text-left transition-colors duration-150 ease-out dark:border-edge-subtle`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>{if(Y.current===e.id){Y.current=null;return}Mn(e)},onKeyDown:t=>{if(t.key===`Enter`||t.key===` `){if(t.preventDefault(),Y.current===e.id){Y.current=null;return}Mn(e)}},children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[(0,x.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,className:r(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,e.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`),onClick:t=>{t.stopPropagation(),Nn(e,!e.enabled)},children:(0,x.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}),(0,x.jsxs)(Ge,{children:[(0,x.jsx)(We,{asChild:!0,children:(0,x.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 w-8 shrink-0 p-0`,"aria-label":n.jobCardMenuAria,onClick:e=>e.stopPropagation(),children:(0,x.jsx)(le,{className:`size-4`,strokeWidth:1.75})})}),(0,x.jsx)(qe,{children:(0,x.jsxs)(Je,{className:`z-50 min-w-[10rem] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,sideOffset:4,align:`end`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,x.jsx)(Ke,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:()=>{_n(e.id),Dn(e)},children:n.edit}),(0,x.jsx)(Ke,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:()=>{_n(e.id),un(`run`),fn(e.id),ln(!0)},children:n.runNow}),(0,x.jsx)(Ke,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-red-600 outline-none data-highlighted:bg-red-500/10 dark:text-red-400`,onSelect:()=>{_n(e.id),un(`delete`),fn(e.id),ln(!0)},children:n.delete})]})})]})]}),(0,x.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[(0,x.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:e.name||e.id}),(0,x.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:De(e),children:(0,x.jsx)(i,{content:De(e),compact:!0})})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-edge-subtle/90 px-4 py-2.5 text-xs text-fg-muted dark:border-edge-subtle`,children:[(0,x.jsx)(ee,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,x.jsx)(`span`,{className:`min-w-0 truncate`,children:Fe(e,Me,Rn)})]})]},e.id))})]}):(0,x.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h2`,{id:`cron-history-panel`,className:`sr-only`,children:n.tabRunHistory}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.runHistoryHint})]}),(0,x.jsx)(_,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,disabled:j,title:n.refresh,"aria-label":n.refresh,onClick:()=>void Z(),children:(0,x.jsx)(m,{className:r(`size-4`,j&&`animate-spin`),strokeWidth:1.75})})]}),j&&jt.length===0?(0,x.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,x.jsx)(a,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):Ln.length===0?(0,x.jsxs)(`div`,{className:`flex flex-col items-center rounded-2xl border border-dashed border-edge-subtle px-6 py-16 text-center dark:border-edge-subtle`,children:[(0,x.jsx)(ee,{className:`mb-4 size-14 text-fg-disabled`,strokeWidth:1.1,"aria-hidden":!0}),(0,x.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:jt.length===0?n.emptyHistoryTitle:n.noRunsYet}),(0,x.jsx)(`p`,{className:`mt-2 max-w-sm text-sm text-fg-muted`,children:jt.length===0?n.emptyHistoryHint:n.runHistoryHint})]}):(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:(0,x.jsxs)(`table`,{className:`w-full min-w-[700px] border-collapse text-left text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-edge text-xs font-medium text-fg-muted`,children:[(0,x.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colStarted}),(0,x.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colJob}),(0,x.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.status}),(0,x.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDuration}),(0,x.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDetail}),(0,x.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colChat})]})}),(0,x.jsx)(`tbody`,{children:Ln.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-edge/60 last:border-0`,children:[(0,x.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg`,children:(0,x.jsx)(`time`,{dateTime:e.startedAt,children:Re(e.startedAt)})}),(0,x.jsx)(`td`,{className:`max-w-[10rem] truncate px-3 py-2.5`,children:b.some(t=>t.id===e.jobId)?(0,x.jsx)(`button`,{type:`button`,className:`text-left text-accent hover:underline`,onClick:()=>{let t=b.find(t=>t.id===e.jobId);t&&Mn(t)},children:e.jobName||e.jobId}):(0,x.jsx)(`span`,{className:`text-fg-muted`,children:e.jobName||e.jobId})}),(0,x.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,x.jsx)(`span`,{className:r(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,e.status===`success`&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,e.status===`failed`&&`bg-red-500/15 text-red-800 dark:text-red-300`,e.status===`running`&&`bg-accent/15 text-accent`,e.status===`cancelled`&&`bg-surface-hover text-fg-muted`),children:ze(e.status,Fn)})}),(0,x.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:Le(e.duration)}),(0,x.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:Ee(e.summary||e.error,96)}),(0,x.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.sessionKey?.trim()?(0,x.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>ft(e.sessionKey),children:n.openChat}):(0,x.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})})]})]}),(0,x.jsx)(ye,{open:M,onOpenChange:e=>!e&&An(),children:(0,x.jsxs)(h,{children:[(0,x.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,x.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,x.jsxs)(ge,{className:`xopc-dialog-content-pane pointer-events-auto relative flex max-h-[min(90vh,800px)] w-full max-w-md flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none sm:max-w-lg lg:max-w-xl dark:border-edge`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,x.jsx)(f,{className:`text-base font-semibold text-fg`,children:N===`edit`?n.editJob:n.addJob}),(0,x.jsx)(l,{asChild:!0,children:(0,x.jsx)(_,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":n.close,children:(0,x.jsx)(se,{className:`size-5`,strokeWidth:1.75})})})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,x.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,x.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.name}),(0,x.jsx)(`input`,{type:`text`,className:mt(),value:Rt,onChange:e=>zt(e.target.value),placeholder:n.namePlaceholder})]}),(0,x.jsx)(at,{value:Bt,onChange:Vt,disabled:K,labels:n.schedulePicker}),(0,x.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.mode}),(0,x.jsxs)(`select`,{className:ht(),value:z,onChange:e=>{let t=e.target.value;B(t),t===`main`?(H(!1),V(``),W(``)):t===`isolated`&&!Zt.trim()&&G(X())},children:[(0,x.jsx)(`option`,{value:`main`,children:n.modeDirectOption}),(0,x.jsx)(`option`,{value:`isolated`,children:n.modeAgentOption})]}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:z===`main`?n.modeDirect:n.modeAgent})]}),z===`isolated`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.model}),(0,x.jsx)(oe,{value:Zt,placeholder:p.modelPlaceholder,searchPlaceholder:p.modelSearchPlaceholder,noMatches:p.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:e=>{$t.current=!0,G(e)}})]}),(0,x.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.agentProfile}),(0,x.jsxs)(`select`,{className:ht(),value:qt,disabled:K,onChange:e=>V(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:n.agentProfileDefault}),xn.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name?`${e.id} — ${e.name}`:e.id},e.id))]}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.agentProfileHint})]}),(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.workingDirectoryLabel}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`button`,{type:`button`,disabled:K,className:r(`inline-flex min-h-8 max-w-[min(16rem,48vw)] min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,ne.transition,ne.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,K&&`cursor-not-allowed opacity-60`),title:U.trim()?`${U.trim()}\n${p.workingDirectory.chooseFolder}`:`${n.workingDirectoryHint}\n${p.workingDirectory.selectWorkingDirectory}`,onClick:e=>{e.stopPropagation(),!K&&(vn?(async()=>{let e=await yn();e&&bn(e)})():Xt(!0))},children:[(0,x.jsx)(u,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,x.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:U.trim()?pe(U.trim()):p.workingDirectory.notSet})]}),U.trim()?(0,x.jsx)(`button`,{type:`button`,disabled:K,className:`text-xs font-medium text-accent hover:underline disabled:opacity-50`,onClick:()=>W(``),children:n.workingDirectoryReset}):null]}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.workingDirectoryHint})]}),(0,x.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,x.jsx)(`input`,{type:`checkbox`,className:r(`ui-checkbox`,`mt-0.5`),checked:Jt,onChange:e=>H(e.target.checked)}),(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.agentLocalOnly}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.agentLocalOnlyHint})]})]})]}):null,Cn?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.channel}),(0,x.jsxs)(`select`,{className:ht(),value:P,onChange:e=>{let t=e.target.value;F(t),t===`local`&&H(!1),I(``)},children:[(0,x.jsx)(`option`,{value:`local`,children:n.channelLocal}),vt.map(e=>(0,x.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name))]})]}),Sn?(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.recipient}),(0,x.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:n.refreshRecipientHint,onClick:()=>void Ve(P).then(Tt),children:[(0,x.jsx)(m,{className:`size-3.5`,strokeWidth:1.75}),n.refreshList]})]}),(0,x.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,x.jsx)(`input`,{type:`text`,className:r(mt(),`min-w-0 w-full sm:flex-1`),value:Ht,onChange:e=>I(e.target.value),placeholder:n.recipientPlaceholder}),(0,x.jsxs)(`select`,{className:gt,value:Ht,onChange:e=>{let t=e.target.value;t&&I(t)},children:[(0,x.jsx)(`option`,{value:``,children:n.selectRecipient}),wt.length>0?wt.map(e=>(0,x.jsx)(`option`,{value:e.chatId,children:we(e,n.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,x.jsx)(`option`,{value:``,disabled:!0,children:n.noRecentChatsOption})]})]}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:wt.length>0?n.enterManuallyOrSelect:n.noRecentChats})]}):null]}):null,(0,x.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.message}),(0,x.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[(0,x.jsxs)(`button`,{type:`button`,className:r(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Ut===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>On(`edit`),children:[(0,x.jsx)(be,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),n.messageEdit]}),(0,x.jsxs)(`button`,{type:`button`,className:r(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Ut===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>On(`preview`),children:[(0,x.jsx)(ce,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),n.messagePreview]})]})]}),(0,x.jsx)(`div`,{className:r(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,K&&`pointer-events-none opacity-60`),children:Ut===`edit`?(0,x.jsx)(te,{initialContent:L,onChange:R,isDark:v,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${It??`new`}-${Gt}`):(0,x.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:L.trim()?(0,x.jsx)(i,{content:L,compact:!0,className:`text-sm`}):(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.messagePlaceholder})})}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.messageMarkdownHint})]})]})}),(0,x.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,x.jsx)(_,{type:`button`,variant:`secondary`,onClick:An,children:n.cancel}),(0,x.jsx)(_,{type:`button`,variant:`primary`,disabled:K||!wn,onClick:()=>void jn(),children:K?n.loading:N===`edit`?n.save:n.create})]})]})})]})}),vn?null:(0,x.jsx)(ue,{open:Yt,onOpenChange:Xt,initialAbsolutePath:U.trim()||void 0,onConfirm:async e=>{await bn(e),Xt(!1)},wd:p.workingDirectory}),(0,x.jsx)(ye,{open:pn,onOpenChange:e=>{mn(e),e&&gn(`all`)},children:(0,x.jsxs)(h,{children:[(0,x.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),(0,x.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,x.jsxs)(ge,{className:`xopc-dialog-content-pane pointer-events-auto relative flex max-h-[min(90vh,840px)] w-full max-w-lg flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none sm:max-w-2xl dark:border-edge`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end border-b border-edge px-4 py-3`,children:[(0,x.jsx)(f,{className:`sr-only`,children:n.fromTemplate}),(0,x.jsx)(l,{asChild:!0,children:(0,x.jsx)(_,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":n.close,children:(0,x.jsx)(se,{className:`size-5`,strokeWidth:1.75})})})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,x.jsx)(Qe,{cron:n,localeTag:Me,scheduleBadgeLabels:Rn,categoryFilter:hn,onCategoryFilterChange:gn,onSelectTemplate:kn})})]})})]})}),(0,x.jsx)(ye,{open:en,onOpenChange:e=>{e||(tn(!1),nn(null))},children:(0,x.jsxs)(h,{children:[(0,x.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,x.jsxs)(ge,{className:r(`xopc-drawer-right fixed right-0 top-0 z-[60] flex h-full w-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,`dark:border-edge`),"aria-describedby":void 0,children:[(0,x.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,x.jsx)(f,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:q?.name?.trim()||q?.id||`—`}),(0,x.jsx)(l,{asChild:!0,children:(0,x.jsx)(_,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":n.close,children:(0,x.jsx)(se,{className:`size-5`,strokeWidth:1.75})})})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:on?(0,x.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,x.jsx)(a,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):q?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleLabel}),(0,x.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:(0,x.jsx)(`code`,{children:q.schedule})})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.messageLabel}),(0,x.jsx)(`dd`,{className:`mt-1 min-w-0 break-words text-fg`,children:(0,x.jsx)(i,{content:De(q),compact:!0,className:`text-sm`})})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.mode}),(0,x.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.sessionTarget===`isolated`?n.modeAgentOption:n.modeDirectOption})]}),q.sessionTarget===`isolated`?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.agentProfile}),(0,x.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:q.agentId?.trim()?q.agentId.trim():n.agentProfileDefault})]}):null,q.sessionTarget===`isolated`?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.workingDirectoryLabel}),(0,x.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:q.workingDirectory?.trim()?q.workingDirectory.trim():p.workingDirectory.notSet})]}):null,q.delivery?.channel===`local`||q.sessionTarget===`isolated`&&!q.delivery?.to?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.deliveryTarget}),(0,x.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.delivery?.channel===`local`?n.deliveryTargetLocalChannel:n.deliveryLocalOnly})]}):q.delivery?.to?(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.deliveryTarget}),(0,x.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,x.jsx)(`code`,{className:`text-xs`,children:q.delivery?.channel??``}),` → `,Pe(q,n.channelLocal)]})]}):null,(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.status}),(0,x.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.enabled?n.enabled:n.disabled})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.nextRun}),(0,x.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.next_run?je(q.next_run,n.timeLabels):`—`})]})]}),(0,x.jsx)(`h3`,{className:`mt-6 text-sm font-semibold text-fg`,children:n.detailRunHistory}),rn.length===0?(0,x.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:n.noRunsYet}):(0,x.jsx)(`div`,{className:`mt-2 overflow-x-auto`,children:(0,x.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,x.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.colStarted}),(0,x.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.status}),(0,x.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.colDuration}),(0,x.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.colDetail}),(0,x.jsx)(`th`,{className:`py-1.5 font-medium`,children:n.colChat})]})}),(0,x.jsx)(`tbody`,{children:rn.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-edge/60`,children:[(0,x.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-2 text-fg`,children:(0,x.jsx)(`time`,{dateTime:e.startedAt,children:Re(e.startedAt)})}),(0,x.jsx)(`td`,{className:`py-1.5 pr-2`,children:(0,x.jsx)(`span`,{className:r(`inline-flex rounded px-1.5 py-0.5 font-medium`,e.status===`success`&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,e.status===`failed`&&`bg-red-500/15 text-red-800 dark:text-red-300`),children:ze(e.status,Fn)})}),(0,x.jsx)(`td`,{className:`py-1.5 pr-2 text-fg-muted`,children:Le(e.duration)}),(0,x.jsx)(`td`,{className:`max-w-[8rem] truncate py-1.5 pr-2 text-fg-muted`,title:e.summary||e.error||``,children:Ee(e.summary||e.error,120)}),(0,x.jsx)(`td`,{className:`whitespace-nowrap py-1.5`,children:e.sessionKey?.trim()?(0,x.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>ft(e.sessionKey),children:n.openChat}):(0,x.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})})]}):null})]})]})}),(0,x.jsx)(ye,{open:cn,onOpenChange:ln,children:(0,x.jsxs)(h,{children:[(0,x.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),(0,x.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,x.jsxs)(ge,{className:`xopc-dialog-content-pane pointer-events-auto relative w-full max-w-md rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[(0,x.jsx)(f,{className:`text-base font-semibold text-fg`,children:J===`delete`?n.delete:n.runNow}),(0,x.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:J===`delete`?n.confirmDelete:n.confirmRun}),(0,x.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,x.jsx)(_,{type:`button`,variant:`secondary`,onClick:()=>{ln(!1),fn(null),un(null)},children:n.cancel}),(0,x.jsx)(_,{type:`button`,variant:`primary`,className:J===`delete`?`bg-red-600 hover:bg-red-700`:void 0,onClick:()=>void Pn(),children:J===`delete`?n.delete:n.runNow})]})]})})]})})]}):(0,x.jsx)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-16 text-center text-sm text-fg-muted sm:px-8`,children:n.needToken})}export{vt as CronPage};
2
- //# sourceMappingURL=cron-page-CANqvhK7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension-settings-page-CP9JNc4m.js","names":[],"sources":["../../../../../web/src/components/ui/schema-form.tsx","../../../../../web/src/features/extensions/extension-auto-settings.tsx","../../../../../web/src/features/extensions/extension-settings-page.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react';\n\nimport { cn } from '@/lib/cn';\n\nexport type JsonSchema = Record<string, unknown>;\n\ntype SchemaFormProps = {\n schema: JsonSchema;\n values: Record<string, unknown>;\n onChange: (values: Record<string, unknown>) => void;\n disabled?: boolean;\n className?: string;\n};\n\nfunction isRecord(x: unknown): x is Record<string, unknown> {\n return typeof x === 'object' && x !== null && !Array.isArray(x);\n}\n\ntype FieldDef = {\n key: string;\n sub: JsonSchema;\n order: number;\n group: string;\n hidden: boolean;\n};\n\nfunction getXOrder(s: JsonSchema): number {\n const v = s['x-order'];\n return typeof v === 'number' && !Number.isNaN(v) ? v : 999;\n}\n\nfunction getXGroup(s: JsonSchema): string {\n const v = s['x-group'];\n return typeof v === 'string' && v.length > 0 ? v : '';\n}\n\nfunction isHidden(s: JsonSchema): boolean {\n return s['x-hidden'] === true;\n}\n\nfunction sortedFields(schema: JsonSchema): FieldDef[] {\n const props = schema.properties;\n if (!isRecord(props)) return [];\n const out: FieldDef[] = [];\n for (const [key, sub] of Object.entries(props)) {\n if (!isRecord(sub)) continue;\n if (isHidden(sub)) continue;\n out.push({\n key,\n sub: sub as JsonSchema,\n order: getXOrder(sub as JsonSchema),\n group: getXGroup(sub as JsonSchema),\n hidden: false,\n });\n }\n out.sort((a, b) => a.order - b.order || a.key.localeCompare(b.key));\n return out;\n}\n\nfunction groupFields(fields: FieldDef[]): Map<string, FieldDef[]> {\n const m = new Map<string, FieldDef[]>();\n for (const f of fields) {\n const g = f.group;\n if (!m.has(g)) m.set(g, []);\n m.get(g)!.push(f);\n }\n return m;\n}\n\nfunction StringField({\n name,\n s,\n value,\n onChange,\n disabled,\n}: {\n name: string;\n s: JsonSchema;\n value: string;\n onChange: (v: string) => void;\n disabled: boolean;\n}) {\n const desc = typeof s.description === 'string' ? s.description : undefined;\n const placeholder =\n (typeof s['x-placeholder'] === 'string' ? s['x-placeholder'] : null) || desc;\n const fmt = s.format;\n if (Array.isArray(s.enum) && s.enum.every((x) => typeof x === 'string')) {\n return (\n <div className=\"flex flex-col gap-1.5\">\n {desc ? <label className=\"text-xs text-fg-muted\">{desc}</label> : null}\n <select\n name={name}\n className=\"ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg\"\n value={value}\n disabled={disabled}\n onChange={(e) => onChange(e.target.value)}\n >\n {(s.enum as string[]).map((op) => (\n <option key={op} value={op}>\n {op}\n </option>\n ))}\n </select>\n </div>\n );\n }\n const inputType = fmt === 'password' ? 'password' : 'text';\n return (\n <div className=\"flex flex-col gap-1.5\">\n {desc ? <label className=\"text-xs text-fg-muted\">{desc}</label> : null}\n <input\n name={name}\n type={inputType}\n className=\"ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70\"\n value={value}\n placeholder={placeholder}\n disabled={disabled}\n onChange={(e) => onChange(e.target.value)}\n />\n </div>\n );\n}\n\nfunction NumberField({\n s,\n value,\n onChange,\n disabled,\n}: {\n s: JsonSchema;\n value: number;\n onChange: (v: number) => void;\n disabled: boolean;\n}) {\n const desc = typeof s.description === 'string' ? s.description : undefined;\n return (\n <div className=\"flex flex-col gap-1.5\">\n {desc ? <label className=\"text-xs text-fg-muted\">{desc}</label> : null}\n <input\n type=\"number\"\n className=\"ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg\"\n value={Number.isFinite(value) ? value : 0}\n disabled={disabled}\n onChange={(e) => onChange(Number(e.target.value))}\n />\n </div>\n );\n}\n\nfunction BooleanField({\n s,\n value,\n onChange,\n disabled,\n}: {\n s: JsonSchema;\n value: boolean;\n onChange: (v: boolean) => void;\n disabled: boolean;\n}) {\n const desc = typeof s.description === 'string' ? s.description : undefined;\n const labelText =\n desc ?? (typeof s.title === 'string' && s.title.length > 0 ? s.title : 'Enable');\n return (\n <label className=\"flex items-center gap-2 text-sm text-fg\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4 rounded border border-edge\"\n checked={value}\n disabled={disabled}\n onChange={(e) => onChange(e.target.checked)}\n />\n <span>{labelText}</span>\n </label>\n );\n}\n\nfunction ArrayStringField({\n s,\n value,\n onChange,\n disabled,\n}: {\n s: JsonSchema;\n value: string[];\n onChange: (v: string[]) => void;\n disabled: boolean;\n}) {\n const desc = typeof s.description === 'string' ? s.description : undefined;\n const items = s.items;\n const isStringItems = isRecord(items) && items.type === 'string';\n if (!isStringItems) {\n return <p className=\"text-xs text-fg-muted\">Unsupported array type</p>;\n }\n const add = (t: string) => {\n const n = t.trim();\n if (!n || value.includes(n)) return;\n onChange([...value, n]);\n };\n return (\n <div className=\"flex flex-col gap-1.5\">\n {desc ? <label className=\"text-xs text-fg-muted\">{desc}</label> : null}\n <div className=\"flex flex-wrap gap-1\">\n {value.map((t) => (\n <span\n key={t}\n className=\"inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm\"\n >\n {t}\n <button\n type=\"button\"\n className=\"text-fg-muted hover:text-fg\"\n disabled={disabled}\n onClick={() => onChange(value.filter((x) => x !== t))}\n >\n ×\n </button>\n </span>\n ))}\n </div>\n <input\n className=\"ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm\"\n disabled={disabled}\n placeholder=\"Add and press Enter\"\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n add((e.target as HTMLInputElement).value);\n (e.target as HTMLInputElement).value = '';\n }\n }}\n />\n </div>\n );\n}\n\nfunction FieldRow({\n k,\n sub,\n value,\n onValue,\n disabled,\n}: {\n k: string;\n sub: JsonSchema;\n value: unknown;\n onValue: (next: unknown) => void;\n disabled: boolean;\n}) {\n const t = sub.type;\n const title =\n (typeof sub.title === 'string' && sub.title.length > 0 ? sub.title : null) ?? k;\n if (t === 'boolean') {\n return (\n <div className=\"space-y-1.5\">\n <p className=\"text-sm font-medium text-fg\">{title}</p>\n <BooleanField\n s={sub}\n value={value === true}\n disabled={disabled}\n onChange={(b) => onValue(b)}\n />\n </div>\n );\n }\n if (t === 'number' || t === 'integer') {\n return (\n <div className=\"space-y-1.5\">\n <p className=\"text-sm font-medium text-fg\">{title}</p>\n <NumberField\n s={sub}\n value={typeof value === 'number' ? value : 0}\n disabled={disabled}\n onChange={onValue}\n />\n </div>\n );\n }\n if (t === 'string') {\n return (\n <div className=\"space-y-1.5\">\n <p className=\"text-sm font-medium text-fg\">{title}</p>\n <StringField\n name={k}\n s={sub}\n value={typeof value === 'string' ? value : ''}\n disabled={disabled}\n onChange={onValue}\n />\n </div>\n );\n }\n if (t === 'array') {\n const items = sub.items;\n if (isRecord(items) && items.type === 'string') {\n return (\n <div className=\"space-y-1.5\">\n <p className=\"text-sm font-medium text-fg\">{title}</p>\n <ArrayStringField\n s={sub}\n value={Array.isArray(value) && value.every((x) => typeof x === 'string') ? value : []}\n disabled={disabled}\n onChange={onValue}\n />\n </div>\n );\n }\n }\n return (\n <p className=\"text-xs text-fg-muted\">\n {title}: unsupported field type\n {typeof t === 'string' ? ` (${t})` : ''}\n </p>\n );\n}\n\n/**\n * Renders a JSON Schema (type: object) as a form using Gateway Console design tokens.\n */\nexport function SchemaForm({ schema, values, onChange, disabled = false, className }: SchemaFormProps) {\n const fields = useMemo(() => {\n if (schema.type !== 'object') return [];\n return sortedFields(schema);\n }, [schema]);\n\n const grouped = useMemo(() => {\n if (fields.length === 0) return new Map<string, FieldDef[]>();\n return groupFields(fields);\n }, [fields]);\n\n const setKey = useCallback(\n (key: string, next: unknown) => {\n onChange({ ...values, [key]: next });\n },\n [onChange, values],\n );\n\n if (schema.type !== 'object' || !isRecord(schema.properties) || fields.length === 0) {\n return null;\n }\n\n const groupKeys = Array.from(grouped.keys()).sort((a, b) => {\n if (a === '') return -1;\n if (b === '') return 1;\n return a.localeCompare(b);\n });\n\n return (\n <div className={cn('flex flex-col gap-4', className)}>\n {groupKeys.map((gk) => {\n const list = grouped.get(gk) ?? [];\n const block = list.map((f) => (\n <FieldRow\n key={f.key}\n k={f.key}\n sub={f.sub}\n value={values[f.key]}\n onValue={(v) => setKey(f.key, v)}\n disabled={disabled}\n />\n ));\n if (gk === '') {\n return <div key=\"default\">{block}</div>;\n }\n return (\n <details\n key={gk}\n className=\"group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base\"\n open\n >\n <summary className=\"cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none\">\n {gk}\n </summary>\n <div className=\"space-y-4 border-t border-edge p-3\">{block}</div>\n </details>\n );\n })}\n </div>\n );\n}\n\n/** Extract per-key defaults from a JSON object schema for \"Reset\" actions. */\nexport function extractObjectDefaults(\n schema: JsonSchema,\n): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n if (schema.type !== 'object' || !isRecord(schema.properties)) {\n return out;\n }\n for (const [k, sub] of Object.entries(schema.properties)) {\n if (!isRecord(sub)) continue;\n if (Object.prototype.hasOwnProperty.call(sub, 'default')) {\n out[k] = sub.default;\n }\n }\n return out;\n}\n","import { useCallback, useEffect, useMemo, useState } from 'react';\nimport useSWR from 'swr';\n\nimport { Button } from '@/components/ui/button';\nimport { extractObjectDefaults, SchemaForm, type JsonSchema } from '@/components/ui/schema-form';\nimport { apiFetch, fetchJson } from '@/lib/fetch';\nimport { apiUrl } from '@/lib/url';\nimport { useGatewayStore } from '@/stores/gateway-store';\n\ntype ExtensionDetailResponse = {\n manifest: { configSchema?: JsonSchema };\n};\n\nexport function ExtensionAutoSettings({ extensionId }: { extensionId: string }) {\n const hasToken = useGatewayStore((s) => Boolean(s.token));\n const { data: detail, error: detailError } = useSWR(\n hasToken && extensionId ? `ext-detail-${extensionId}` : null,\n () => fetchJson<ExtensionDetailResponse>(apiUrl(`/api/extensions/${encodeURIComponent(extensionId)}`)),\n );\n\n const { data: remoteConfig, mutate: mutateConfig, error: configError } = useSWR(\n hasToken && extensionId ? `ext-cfg-${extensionId}` : null,\n () =>\n fetchJson<Record<string, unknown>>(\n apiUrl(`/api/extensions/${encodeURIComponent(extensionId)}/config`),\n ),\n );\n\n const schema = detail?.manifest?.configSchema;\n const defaults = useMemo(\n () => (schema && schema.type === 'object' ? extractObjectDefaults(schema) : {}),\n [schema],\n );\n\n const savedValues = useMemo(\n () => ({ ...defaults, ...(remoteConfig ?? {}) }),\n [defaults, remoteConfig],\n );\n\n const [localValues, setLocalValues] = useState<Record<string, unknown>>({});\n const [isDirty, setIsDirty] = useState(false);\n const [saving, setSaving] = useState(false);\n const [saveError, setSaveError] = useState<string | null>(null);\n const [saveSuccess, setSaveSuccess] = useState(false);\n\n useEffect(() => {\n if (isDirty) return;\n setLocalValues(savedValues);\n }, [isDirty, savedValues]);\n\n const onChange = useCallback((next: Record<string, unknown>) => {\n setLocalValues(next);\n setIsDirty(true);\n setSaveError(null);\n }, []);\n\n const handleDiscard = useCallback(() => {\n setLocalValues(savedValues);\n setIsDirty(false);\n setSaveError(null);\n }, [savedValues]);\n\n const handleResetDefaults = useCallback(() => {\n if (!schema || schema.type !== 'object') return;\n setLocalValues({ ...extractObjectDefaults(schema) });\n setIsDirty(true);\n setSaveError(null);\n }, [schema]);\n\n const handleSave = useCallback(async () => {\n if (!extensionId) return;\n setSaving(true);\n setSaveError(null);\n try {\n const res = await apiFetch(\n apiUrl(`/api/extensions/${encodeURIComponent(extensionId)}/config`),\n { method: 'PATCH', body: JSON.stringify(localValues) },\n );\n if (!res.ok) {\n const body = (await res.json().catch(() => ({}))) as { error?: { message?: string } };\n throw new Error(body.error?.message ?? res.statusText);\n }\n await mutateConfig(localValues, false);\n setIsDirty(false);\n setSaveSuccess(true);\n window.setTimeout(() => setSaveSuccess(false), 3000);\n } catch (e) {\n setSaveError(e instanceof Error ? e.message : String(e));\n } finally {\n setSaving(false);\n }\n }, [extensionId, localValues, mutateConfig]);\n\n if (!hasToken) {\n return null;\n }\n\n if (detailError || configError) {\n const err = (detailError ?? configError) as Error;\n return (\n <p className=\"text-sm text-fg-muted\">\n Could not load extension settings: {err instanceof Error ? err.message : String(err)}\n </p>\n );\n }\n\n if (!schema || schema.type !== 'object') {\n return null;\n }\n\n return (\n <div className=\"mb-6 flex flex-col gap-3 rounded-xl border border-edge bg-surface-base p-4\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <h2 className=\"text-sm font-semibold text-fg\">Configuration</h2>\n <div className=\"flex flex-wrap items-center gap-2\">\n {saveSuccess ? (\n <span className=\"text-xs text-emerald-600 dark:text-emerald-400\">Saved</span>\n ) : null}\n {saveError ? <span className=\"text-xs text-red-600 dark:text-red-400\">{saveError}</span> : null}\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"h-8 text-xs\"\n disabled={!isDirty}\n onClick={handleDiscard}\n >\n Discard\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"h-8 text-xs\"\n onClick={handleResetDefaults}\n >\n Reset to defaults\n </Button>\n <Button\n type=\"button\"\n variant=\"primary\"\n className=\"h-8 text-xs\"\n disabled={!isDirty || saving}\n onClick={() => void handleSave()}\n >\n {saving ? 'Saving…' : 'Save'}\n </Button>\n </div>\n </div>\n <SchemaForm schema={schema} values={localValues} onChange={onChange} disabled={saving} />\n </div>\n );\n}\n","/**\n * Extension settings: auto-generated config form (configSchema) + optional iframe (settingsPanels).\n *\n * Routes: /settings/ext/:extensionId, /settings/ext/:extensionId/:panelId\n */\n\nimport { useParams } from 'react-router-dom';\n\nimport { ExtensionAutoSettings } from './extension-auto-settings';\nimport { ExtensionIframeHost } from './extension-iframe-host';\nimport { useExtensions } from './extension-provider';\n\nexport function ExtensionSettingsPage() {\n const { extensionId, panelId } = useParams<{ extensionId: string; panelId?: string }>();\n const extensions = useExtensions();\n\n if (!extensionId) {\n return <SettingsPanelNotFound message=\"No extension ID provided.\" />;\n }\n\n const extension = extensions.find((ext) => ext.id === extensionId);\n if (!extension) {\n return (\n <SettingsPanelNotFound\n message={`Extension \"${extensionId}\" not found or is not available in this workspace.`}\n />\n );\n }\n\n const panels = extension.ui?.contributions?.settingsPanels;\n const panel = panelId\n ? panels?.find((p) => p.id === panelId || p.id === `${extensionId}.${panelId}`)\n : panels?.[0];\n\n const hasIframe = Boolean(panel && extension.ui);\n const hasAuto = Boolean(extension.hasConfigSchema);\n\n if (!hasAuto && !hasIframe) {\n return (\n <SettingsPanelNotFound\n message={`Extension \"${extensionId}\" has no settings panels or config schema.`}\n />\n );\n }\n\n const title = panel?.title ?? `${extension.name} Settings`;\n\n return (\n <div className=\"mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8\">\n <h1 className=\"text-lg font-semibold text-fg\">{title}</h1>\n <ExtensionAutoSettings extensionId={extensionId} />\n {hasIframe && panel && extension.ui ? (\n <div className=\"overflow-hidden rounded-xl border border-edge bg-surface-base\">\n <ExtensionIframeHost\n extensionId={extensionId}\n extensionName={extension.name}\n entrypoint={panel.entrypoint}\n permissions={extension.ui?.permissions}\n title={panel.title}\n className=\"w-full\"\n minHeight={120}\n maxHeight={2000}\n />\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction SettingsPanelNotFound({ message }: { message: string }) {\n return (\n <div className=\"mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8\">\n <p className=\"text-sm text-fg-muted\">{message}</p>\n </div>\n );\n}\n"],"mappings":"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"}