@xopcai/xopc 0.0.22 → 0.0.23

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 (41) hide show
  1. package/dist/extensions/telegram/xopc.extension.json +1 -1
  2. package/dist/gateway/static/root/assets/agents-BY_DaknM.js +216 -0
  3. package/dist/gateway/static/root/assets/agents-BY_DaknM.js.map +1 -0
  4. package/dist/gateway/static/root/assets/{apps-page-Bl-yxbQo.js → apps-page-BO3nQbJY.js} +2 -2
  5. package/dist/gateway/static/root/assets/{apps-page-Bl-yxbQo.js.map → apps-page-BO3nQbJY.js.map} +1 -1
  6. package/dist/gateway/static/root/assets/channels-settings-CGzrrBlT.js +9 -0
  7. package/dist/gateway/static/root/assets/{channels-settings-BGueHxMv.js.map → channels-settings-CGzrrBlT.js.map} +1 -1
  8. package/dist/gateway/static/root/assets/cron-page-BGCdDf2w.js +2 -0
  9. package/dist/gateway/static/root/assets/{cron-page-DsVZzPqv.js.map → cron-page-BGCdDf2w.js.map} +1 -1
  10. package/dist/gateway/static/root/assets/{cron-utils-zbRs2yND.js → cron-utils-Dnks4wWv.js} +2 -2
  11. package/dist/gateway/static/root/assets/{cron-utils-zbRs2yND.js.map → cron-utils-Dnks4wWv.js.map} +1 -1
  12. package/dist/gateway/static/root/assets/{dist-CDA7gR_M.js → dist-BG1ChbY9.js} +2 -2
  13. package/dist/gateway/static/root/assets/{dist-CDA7gR_M.js.map → dist-BG1ChbY9.js.map} +1 -1
  14. package/dist/gateway/static/root/assets/{extension-debug-page-CDLp4DAs.js → extension-debug-page-CRC16AbL.js} +2 -2
  15. package/dist/gateway/static/root/assets/{extension-debug-page-CDLp4DAs.js.map → extension-debug-page-CRC16AbL.js.map} +1 -1
  16. package/dist/gateway/static/root/assets/{extension-page-DwSCjzHO.js → extension-page-BagrJnbm.js} +2 -2
  17. package/dist/gateway/static/root/assets/{extension-page-DwSCjzHO.js.map → extension-page-BagrJnbm.js.map} +1 -1
  18. package/dist/gateway/static/root/assets/{extension-settings-page-Rdmxe24_.js → extension-settings-page-DEpxRKKK.js} +2 -2
  19. package/dist/gateway/static/root/assets/{extension-settings-page-Rdmxe24_.js.map → extension-settings-page-DEpxRKKK.js.map} +1 -1
  20. package/dist/gateway/static/root/assets/{index-D9Wmfh2f.css → index-CYVs9x8D.css} +1 -1
  21. package/dist/gateway/static/root/assets/{index-DG8WvMbu.js → index-KNzRh6gu.js} +24 -24
  22. package/dist/gateway/static/root/assets/{index-DG8WvMbu.js.map → index-KNzRh6gu.js.map} +1 -1
  23. package/dist/gateway/static/root/assets/logs-page-Bo9EsE_D.js +2 -0
  24. package/dist/gateway/static/root/assets/{logs-page-ChJ0nsPh.js.map → logs-page-Bo9EsE_D.js.map} +1 -1
  25. package/dist/gateway/static/root/assets/sessions-page-CDgXq8qp.js +2 -0
  26. package/dist/gateway/static/root/assets/{sessions-page-Cle4fPla.js.map → sessions-page-CDgXq8qp.js.map} +1 -1
  27. package/dist/gateway/static/root/assets/settings-page-BWMTFST6.js +2 -0
  28. package/dist/gateway/static/root/assets/{settings-page-Dyo2NYdy.js.map → settings-page-BWMTFST6.js.map} +1 -1
  29. package/dist/gateway/static/root/assets/skills-page-BRS5qYTw.js +3 -0
  30. package/dist/gateway/static/root/assets/{skills-page-B-smhcB2.js.map → skills-page-BRS5qYTw.js.map} +1 -1
  31. package/dist/gateway/static/root/index.html +2 -2
  32. package/dist/package.js +1 -1
  33. package/package.json +1 -1
  34. package/dist/gateway/static/root/assets/agents-BcLv59-r.js +0 -71
  35. package/dist/gateway/static/root/assets/agents-BcLv59-r.js.map +0 -1
  36. package/dist/gateway/static/root/assets/channels-settings-BGueHxMv.js +0 -9
  37. package/dist/gateway/static/root/assets/cron-page-DsVZzPqv.js +0 -2
  38. package/dist/gateway/static/root/assets/logs-page-ChJ0nsPh.js +0 -2
  39. package/dist/gateway/static/root/assets/sessions-page-Cle4fPla.js +0 -2
  40. package/dist/gateway/static/root/assets/settings-page-Dyo2NYdy.js +0 -2
  41. package/dist/gateway/static/root/assets/skills-page-B-smhcB2.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{r as i}from"./vendor-swr-Dp4nzp5h.js";import{$n as a,Bt as o,It as s,Jn as c,Kn as l,Kt as u,Mt as d,Ot as f,Qt as p,Rt as m,Sn as h,Vt as g,Wt as _,Yn as v,at as y,cn as b,ct as x,dr as S,dt as C,et as w,fr as T,ft as ee,kt as te,lt as ne,ot as re,qn as E,rt as D,st as ie,t as ae,tt as oe,ut as se,yn as ce,zt as O}from"./index-DG8WvMbu.js";import{a as le,i as k,n as ue,r as de,t as fe}from"./dist-CDA7gR_M.js";var A=e(n(),1);function j(e){return(e??``).trim().toLowerCase()}function pe(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 me(e){let t=Object.keys(e.accounts??{});return t.length>0?[...t].sort():typeof e.botToken==`string`&&e.botToken.trim()?[`default`]:[]}function M(e){return Object.keys(e.accounts??{}).sort()}function he(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 N(e,t,n,r,i){let a={},o={},s={};for(let n of t)a[n]=(e.find(e=>j(e.match?.channel)===`telegram`&&j(e.match?.accountId)===j(n)&&pe(e))?.agentId??i).trim().toLowerCase();for(let t of n)o[t]=(e.find(e=>j(e.match?.channel)===`weixin`&&j(e.match?.accountId)===j(t)&&pe(e))?.agentId??i).trim().toLowerCase();for(let t of r)s[t]=(e.find(e=>j(e.match?.channel)===`feishu`&&j(e.match?.accountId)===j(t)&&pe(e))?.agentId??i).trim().toLowerCase();return{telegram:a,weixin:o,feishu:s}}function P(e,t,n,r,i,a){let o=new Set(n.map(j)),s=new Set(r.map(j)),c=new Set(i.map(j)),l=e.filter(e=>{if(e.id?.startsWith(`ui:route:account:`))return!1;if(!pe(e))return!0;let t=j(e.match.channel),n=j(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[j(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[j(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[j(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 ge(){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 _e(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=N(u,me(p.telegram),M(p.weixin),he(p.feishu),f);return{...p,bindingsFull:u.map(e=>({...e})),channelAgentRoutes:m,defaultAgentId:f}}async function ve(e){return(await y(D(`/api/channels/weixin/login/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function ye(e){return(await y(D(`/api/channels/weixin/login/${encodeURIComponent(e)}`))).payload.status}async function be(e){let t=e.telegram,n=e.weixin,r=e.feishu,i=P(e.bindingsFull,e.channelAgentRoutes,me(t),M(n),he(r),e.defaultAgentId),a=(()=>{let e=n.routeTag.trim();return e?/^\d+$/.test(e)?Number(e):e:null})(),o=(await y(D(`/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?_e(o):{...e,bindingsFull:i}}async function xe(e){return(await y(D(`/api/channels/feishu/setup/start`),{method:`POST`,body:JSON.stringify(e??{})})).payload}async function Se(e){return(await y(D(`/api/channels/feishu/setup/${encodeURIComponent(e)}`))).payload.status}function Ce(){return _(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,O,`dark:border-edge`)}function we(){return _(m,s)}function Te(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).map(e=>/^-?\d+$/.test(e)?Number(e):e)}function Ee(e){return e.map(String).join(`, `)}function De(e){return!!e.botToken?.trim()||Object.keys(e.accounts??{}).length>0}function Oe(e){return Object.keys(e.accounts??{}).length>0||e.allowFrom.length>0}function ke(e){return!!(e.appId?.trim()&&e.appSecret?.trim())||Object.keys(e.accounts??{}).length>0}var F=r();function I({children:e}){return(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function L({children:e}){return(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:e})}function R({label:e,value:t,onChange:n,options:r}){return(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:e}),(0,F.jsx)(`select`,{className:we(),value:t,onChange:e=>n(e.target.value),children:r.map(e=>(0,F.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function Ae({accountIds:e,routes:t,defaultAgentId:n,agentItems:r,disabled:i,onChange:a,ch:o}){if(e.length===0)return null;let c=r.length>0?r:[{id:n}];return(0,F.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(I,{children:o.agentRoutingTitle}),(0,F.jsx)(L,{children:o.agentRoutingHint})]}),(0,F.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,F.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,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:o.agentRoutingAccountLabel}),(0,F.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:e,children:e})]}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${e}`,children:o.agentRoutingAgentLabel}),(0,F.jsx)(`select`,{id:`agent-route-${e}`,className:_(Ce(),s),disabled:i,value:(t[e]??n).toLowerCase(),onChange:t=>a(e,t.target.value),children:c.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name?.trim()?`${e.name} (${e.id})`:e.id},e.id))})]})]},e))})]})}function je({icon:e,title:t,subtitle:n,configured:r,enabled:i,onToggle:a,toggleDisabled:o,onConfigure:s,onEdit:c,onRemove:l,ch:u}){return(0,F.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,F.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-4`,children:[(0,F.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-surface-hover`,"aria-hidden":!0,children:e}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),r?(0,F.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-success-soft px-2 py-0.5 text-xs font-medium text-success`,children:u.hubConnectedBadge}):null]}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n})]})]}),r?(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 sm:gap-3`,children:[(0,F.jsxs)(k,{children:[(0,F.jsx)(le,{asChild:!0,children:(0,F.jsx)(g,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u.menuMoreAria,children:(0,F.jsx)(v,{className:`size-5 text-fg-muted`,strokeWidth:1.75})})}),(0,F.jsx)(de,{children:(0,F.jsxs)(fe,{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,F.jsx)(ue,{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:()=>c(),children:(0,F.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(ce,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75}),u.menuEditConfig]})}),(0,F.jsx)(ue,{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:()=>l(),children:(0,F.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(p,{className:`size-4 shrink-0`,strokeWidth:1.75}),u.menuRemoveConfig]})})]})})]}),(0,F.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} — ${u.enableChannelAria}`,disabled:o,className:_(`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`,o&&`cursor-not-allowed opacity-50`),onClick:()=>void a(!i),children:(0,F.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]}):(0,F.jsx)(`div`,{className:`flex shrink-0 justify-end sm:justify-end`,children:(0,F.jsx)(g,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:s,children:u.hubConfigureButton})})]})}function Me({tg:e,updateTelegram:t,ch:n,dmOpts:r,groupOpts:i,replyOpts:a,streamOpts:o,tgAccountsDraft:s,setTgAccountsDraft:c,tgAccountsError:l,onTgAccountsBlur:u}){let d=Ce;return(0,F.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.apiRoot}),(0,F.jsx)(`input`,{className:d(),value:e.apiRoot,onChange:e=>t({apiRoot:e.target.value}),placeholder:`https://api.telegram.org`})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.proxy}),(0,F.jsx)(`input`,{className:d(),value:e.proxy,onChange:e=>t({proxy:e.target.value}),placeholder:`http://proxy.example.com:8080`})]}),(0,F.jsx)(R,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,F.jsx)(R,{label:n.groupPolicy,value:e.groupPolicy,onChange:e=>t({groupPolicy:e}),options:i}),(0,F.jsx)(R,{label:n.replyToMode,value:e.replyToMode,onChange:e=>t({replyToMode:e}),options:a}),(0,F.jsx)(R,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:o}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.allowFromGroups}),(0,F.jsx)(`textarea`,{className:_(d(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`-1001234567890`,value:Ee(e.groupAllowFrom),onChange:e=>t({groupAllowFrom:Te(e.target.value)})})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.historyLimit}),(0,F.jsx)(`input`,{type:`number`,min:10,max:200,className:d(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.textChunkLimit}),(0,F.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:d(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.telegramDebug]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.multiAccountJson}),(0,F.jsx)(`textarea`,{className:_(d(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:s,onChange:e=>c(e.target.value),onBlur:u,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),l?(0,F.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):(0,F.jsx)(L,{children:n.multiAccountJsonDesc})]})]})}function Ne({wx:e,updateWeixin:t,ch:n,dmOpts:r,streamOpts:i,wxAccountsDraft:a,setWxAccountsDraft:o,wxAccountsError:s,onWxAccountsBlur:c,channelAgentRoutesWx:l,defaultAgentId:u,agentItems:d,onAgentRouteChange:f,routingDisabled:p}){let m=Ce;return(0,F.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.weixinAllowFrom}),(0,F.jsx)(`textarea`,{className:_(m(),`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,F.jsx)(L,{children:n.weixinAllowFromDesc})]}),(0,F.jsx)(R,{label:n.dmPolicy,value:e.dmPolicy,onChange:e=>t({dmPolicy:e}),options:r}),(0,F.jsx)(R,{label:n.streamMode,value:e.streamMode,onChange:e=>t({streamMode:e}),options:i}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.historyLimit}),(0,F.jsx)(`input`,{type:`number`,min:10,max:200,className:m(),value:e.historyLimit,onChange:e=>t({historyLimit:parseInt(e.target.value,10)||50})})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.textChunkLimit}),(0,F.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:m(),value:e.textChunkLimit,onChange:e=>t({textChunkLimit:parseInt(e.target.value,10)||4e3})})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.weixinRouteTag}),(0,F.jsx)(`input`,{className:m(),value:e.routeTag,onChange:e=>t({routeTag:e.target.value}),placeholder:n.routeTagPlaceholder}),(0,F.jsx)(L,{children:n.weixinRouteTagDesc})]}),(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:e.debug,onChange:e=>t({debug:e.target.checked})}),n.weixinDebug]}),(0,F.jsx)(L,{children:n.weixinDebugDesc}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:n.weixinAccountsJson}),(0,F.jsx)(`textarea`,{className:_(m(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:a,onChange:e=>o(e.target.value),onBlur:c,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),s?(0,F.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:s}):(0,F.jsx)(L,{children:n.weixinAccountsJsonDesc})]}),(0,F.jsx)(Ae,{accountIds:M(e),routes:l,defaultAgentId:u,agentItems:d,disabled:p,onChange:f,ch:n})]})}var Pe=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),z=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)}})),B=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}}})),Fe=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})),Ie=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})),Le=t((e=>{var t=z().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}})),Re=t((e=>{var t=z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),ze=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}})),Be=t((e=>{var t=B(),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}}})),Ve=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]]}})),He=t((e=>{var t=Ve();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}})),Ue=t(((e,t)=>{var n=He();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})),We=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Ge=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)}})),V=t((e=>{var t=We(),n=Ge();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}}})),H=t((e=>{var t=z(),n=Be(),r=B(),i=V(),a=We(),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}})),Ke=t((e=>{var t=z(),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}})),U=t(((e,t)=>{var n=V();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})),qe=t(((e,t)=>{var n=V(),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})),W=t(((e,t)=>{var n=V();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})),Je=t(((e,t)=>{var n=V(),r=z();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})),G=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)})),Ye=t((e=>{var t=V(),n=U(),r=qe(),i=W(),a=Je(),o=Ge(),s=z(),c=G();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()))}})),K=t((e=>{var t=z(),n=B(),r=Fe(),i=Ie(),a=Le(),o=Re(),s=ze(),c=Be(),l=Ue(),u=H(),d=Ke(),f=V(),p=Ye();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)}})),Xe=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}}})),q=t((e=>{var t=Xe();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)}})),Ze=t((e=>{var t=Xe();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}})),J=e(t((e=>{var t=Pe(),n=K(),r=q(),i=Ze();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 Qe({open:e,onOpenChange:t,ch:n,onSetupSuccess:r}){let[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(`feishu`),[l,d]=(0,A.useState)(null),[f,p]=(0,A.useState)(null),[m,h]=(0,A.useState)(null),[v,y]=(0,A.useState)(null),[b,S]=(0,A.useState)(!1),[w,T]=(0,A.useState)(!0),te=(0,A.useCallback)(async()=>{h(null),d(null),p(null),a(!0),T(!1);try{let e=await xe({domain:o});p(e.qrUrl),d(e.sessionKey)}catch(e){h(e instanceof Error?e.message:`Start failed`),T(!0)}finally{a(!1)}},[o]);(0,A.useEffect)(()=>{e||(d(null),p(null),h(null),y(null),S(!1),T(!0),a(!1))},[e]),(0,A.useEffect)(()=>{if(!l)return;let e=!1,n,i=async()=>{try{let i=await Se(l);if(e||i.phase===`polling`)return;if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),d(null),i.ok?(p(null),t(!1),r({appId:i.appId,domain:i.domain,openId:i.openId})):(h(i.message),p(null),T(!0));return}i.phase===`unknown`&&(n!==void 0&&window.clearInterval(n),h(i.message),d(null),p(null),T(!0))}catch(t){e||(n!==void 0&&window.clearInterval(n),h(t instanceof Error?t.message:`Request failed`),d(null),p(null),T(!0))}};return n=window.setInterval(()=>void i(),3e3),i(),()=>{e=!0,n!==void 0&&window.clearInterval(n)}},[l,t,r]),(0,A.useEffect)(()=>{if(!f){y(null),S(!1);return}let e=!1;return S(!1),J.toDataURL(f,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||y(t)}).catch(()=>{e||(S(!0),y(null))}),()=>{e=!0}},[f]);let E=!!(f&&l);return(0,F.jsx)(C,{open:e,onOpenChange:t,children:(0,F.jsxs)(se,{children:[(0,F.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,F.jsxs)(ie,{className:_(`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,F.jsx)(re,{asChild:!0,children:(0,F.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,F.jsx)(u,{className:`size-4`})})}),(0,F.jsx)(ee,{className:`sr-only`,children:n.feishuQrModalTitle}),(0,F.jsx)(x,{className:`sr-only`,children:n.feishuQrModalSubtitle}),(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.feishuQrModalTitle}),(0,F.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.feishuQrModalSubtitle})]}),w&&!E?(0,F.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,F.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`feishu-qr-domain`,children:n.feishuQrDomainLabel}),(0,F.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:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`feishu`,children:`feishu (open.feishu.cn) — China`}),(0,F.jsx)(`option`,{value:`lark`,children:`lark (open.larksuite.com) — International`})]})]}),(0,F.jsx)(g,{type:`button`,variant:`primary`,className:`h-11 w-full rounded-full`,disabled:i,onClick:()=>void te(),children:i?n.feishuQrStarting:n.feishuQrStartButton})]}):null,(0,F.jsxs)(`div`,{className:`mt-6 flex min-h-[200px] flex-col items-center justify-center`,children:[i&&!E?(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrStarting}):null,m?(0,F.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:m}):null,E&&f&&!m?(0,F.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrScanHint}),v&&!b?(0,F.jsx)(`img`,{src:v,alt:``,className:`h-52 w-52 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,!v&&!b?(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.feishuQrEncoding}):null,b?(0,F.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,F.jsx)(`p`,{className:`max-w-[16rem] text-center text-sm text-fg-muted`,children:n.feishuQrImageError}),(0,F.jsxs)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-accent underline-offset-2 hover:underline`,children:[(0,F.jsx)(c,{className:`size-3.5 shrink-0`}),n.feishuQrOpenLink]})]}):null]}):null]}),E?(0,F.jsx)(`div`,{className:`mt-6`,children:(0,F.jsx)(g,{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 te(),children:i?n.feishuQrStarting:n.feishuQrRegenerate})}):null]})]})})}function $e({open:e,onOpenChange:t,ch:n,onLoginSuccess:r,moreSettings:i}){let[a,o]=(0,A.useState)(!1),[s,l]=(0,A.useState)(null),[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(null),[h,v]=(0,A.useState)(null),[y,b]=(0,A.useState)(null),[S,w]=(0,A.useState)(!1),T=(0,A.useCallback)(async()=>{m(null),v(null),l(null),o(!0);try{let e=await ve();f(e.qrcodeUrl),l(e.sessionKey)}catch(e){m(e instanceof Error?e.message:`Start failed`)}finally{o(!1)}},[]);(0,A.useEffect)(()=>{if(!e){l(null),f(null),m(null),b(null),w(!1),v(null);return}T()},[e,T]),(0,A.useEffect)(()=>{if(!s)return;let e=!1,i,a=async()=>{try{let a=await ye(s);if(e)return;if(a.phase===`polling`){f(a.qrcodeUrl),a.qrStatus===`scaned`?v(n.weixinQrLoginScanned):v(null);return}if(a.phase===`done`){i!==void 0&&(window.clearInterval(i),i=void 0),l(null),a.ok?(f(null),t(!1),await r()):(m(a.message),f(null));return}a.phase===`unknown`&&v(null)}catch(t){e||(i!==void 0&&window.clearInterval(i),m(t instanceof Error?t.message:`Request failed`),l(null),f(null))}};return i=window.setInterval(()=>void a(),2e3),a(),()=>{e=!0,i!==void 0&&window.clearInterval(i)}},[s,n.weixinQrLoginScanned,n.weixinQrLoginSuccess,r,t]),(0,A.useEffect)(()=>{if(!d){b(null),w(!1);return}let e=!1;return w(!1),J.toDataURL(d,{width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}}).then(t=>{e||b(t)}).catch(()=>{e||(w(!0),b(null))}),()=>{e=!0}},[d]);let te=!!(d&&s);return(0,F.jsx)(C,{open:e,onOpenChange:t,children:(0,F.jsxs)(se,{children:[(0,F.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,F.jsxs)(ie,{className:_(`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,F.jsx)(re,{asChild:!0,children:(0,F.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,F.jsx)(u,{className:`size-4`})})}),(0,F.jsx)(ee,{className:`sr-only`,children:n.weixinQrModalTitle}),(0,F.jsx)(x,{className:`sr-only`,children:n.weixinQrModalSubtitle}),(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.weixinQrModalTitle}),(0,F.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:n.weixinQrModalSubtitle})]}),(0,F.jsxs)(`div`,{className:`mt-6 flex min-h-[200px] flex-col items-center justify-center`,children:[a&&!te?(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.weixinQrLoginBusy}):null,p?(0,F.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:p}):null,h&&!p?(0,F.jsx)(`p`,{className:`mb-3 text-center text-sm text-accent`,children:h}):null,te&&d&&!p?(0,F.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[y&&!S?(0,F.jsx)(`img`,{src:y,alt:``,className:`h-52 w-52 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,!y&&!S?(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.weixinQrEncoding}):null,S?(0,F.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,F.jsx)(`p`,{className:`max-w-[16rem] text-center text-sm text-fg-muted`,children:n.weixinQrImageError}),(0,F.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,F.jsx)(c,{className:`size-3.5 shrink-0`}),n.weixinQrOpenLink]})]}):null]}):null]}),(0,F.jsx)(`div`,{className:`mt-6`,children:(0,F.jsx)(g,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:a,onClick:()=>void T(),children:a?n.weixinQrLoginBusy:n.weixinQrRegenerate})}),i?(0,F.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})]})})}function et(){let e=Ce,t=d(e=>e.language),n=o(t),r=n.channelsSettings,s=!!f(e=>e.token),[p,m]=(0,A.useState)(null),[v,y]=(0,A.useState)(null),[w,D]=(0,A.useState)(!1),[ce,O]=(0,A.useState)(null),[le,k]=(0,A.useState)(!1),[ue,de]=(0,A.useState)(!1),[fe,j]=(0,A.useState)(!1),[pe,M]=(0,A.useState)(!1),[N,P]=(0,A.useState)(null),[ve,ye]=(0,A.useState)(null),[xe,Se]=(0,A.useState)(!1),[we,R]=(0,A.useState)(null),[Pe,z]=(0,A.useState)(!1),[B,Fe]=(0,A.useState)(!1),[Ie,Le]=(0,A.useState)(!1),[Re,ze]=(0,A.useState)(!1),[Be,Ve]=(0,A.useState)(!1),[He,Ue]=(0,A.useState)(!1),[We,Ge]=(0,A.useState)(!1),[V,H]=(0,A.useState)(``),[Ke,U]=(0,A.useState)(``),[qe,W]=(0,A.useState)(``),[Je,G]=(0,A.useState)(``),[Ye,K]=(0,A.useState)(``),[Xe,q]=(0,A.useState)(``),{data:Ze}=i(s?`gateway-chat-agents-ch`:null,ae,{revalidateOnFocus:!1}),{data:J,error:et,isLoading:tt,mutate:nt}=oe(s),Y=(0,A.useMemo)(()=>J?.payload?.config===void 0?null:_e(J.payload.config),[J]),rt=(0,A.useMemo)(()=>!p||!v?!1:JSON.stringify(p)!==JSON.stringify(v),[p,v]);(0,A.useEffect)(()=>{if(!s){m(null),y(null);return}Y!==null&&(rt||(m(Y),y(structuredClone(Y)),H(JSON.stringify(Y.telegram.accounts??{},null,2)),U(``),W(JSON.stringify(Y.weixin.accounts??{},null,2)),G(``),K(JSON.stringify(Y.feishu?.accounts??{},null,2)),q(``),k(!1)))},[s,Y,rt]);let it=!!(s&&tt&&J===void 0&&!et),at=et instanceof Error?et.message:et?String(et):null,ot=(0,A.useCallback)((e,t,n)=>{m(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,A.useCallback)(e=>{m(t=>t?{...t,telegram:{...t.telegram,...e}}:null)},[]),st=(0,A.useCallback)(e=>{m(t=>t?{...t,weixin:{...t.weixin,...e}}:null)},[]),Z=(0,A.useCallback)(e=>{m(t=>t?{...t,feishu:{...t.feishu,...e}}:null)},[]),ct=(0,A.useCallback)(async()=>{if(!p||w)return!1;D(!0),O(null),k(!1);try{let e=await be(p);m(e);let t=structuredClone(e);return y(t),H(JSON.stringify(t.telegram.accounts??{},null,2)),U(``),W(JSON.stringify(t.weixin.accounts??{},null,2)),G(``),K(JSON.stringify(t.feishu?.accounts??{},null,2)),q(``),k(!0),window.setTimeout(()=>k(!1),2500),!0}catch(e){return O(e instanceof Error?e.message:r.saveError),!1}finally{D(!1)}},[p,w,r.saveError]),lt=(0,A.useCallback)(async(e,t)=>{if(!p||w)return;let n=p,i=e===`weixin`?{...p,weixin:{...p.weixin,enabled:t}}:e===`telegram`?{...p,telegram:{...p.telegram,enabled:t}}:{...p,feishu:{...p.feishu,enabled:t}};m(i),D(!0),O(null);try{let e=await be(i);m(e);let t=structuredClone(e);y(t),H(JSON.stringify(t.telegram.accounts??{},null,2)),W(JSON.stringify(t.weixin.accounts??{},null,2)),K(JSON.stringify(t.feishu?.accounts??{},null,2))}catch(e){O(e instanceof Error?e.message:r.saveError),m(n)}finally{D(!1)}},[p,w,r.saveError]),ut=(0,A.useCallback)(async()=>{if(!p||!N||w)return;let e=ge(),t=N===`weixin`?{...p,weixin:e.weixin}:N===`telegram`?{...p,telegram:e.telegram}:{...p,feishu:e.feishu};D(!0),O(null);try{let e=await be(t);m(e);let n=structuredClone(e);y(n),H(JSON.stringify(n.telegram.accounts??{},null,2)),W(JSON.stringify(n.weixin.accounts??{},null,2)),U(``),G(``),K(JSON.stringify(n.feishu?.accounts??{},null,2)),q(``),P(null),k(!0),window.setTimeout(()=>k(!1),2500)}catch(e){O(e instanceof Error?e.message:r.saveError)}finally{D(!1)}},[p,N,w,r.saveError]),dt=(0,A.useCallback)(async()=>{let e=p?.telegram.botToken;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),Ve(!0),window.setTimeout(()=>Ve(!1),2e3))},[p?.telegram.botToken]),ft=(0,A.useCallback)(e=>{Z({appId:e.appId,domain:e.domain,enabled:!0}),nt(),R(r.feishuQrSetupSuccess),window.setTimeout(()=>R(null),4e3)},[Z,nt,r.feishuQrSetupSuccess]),pt=(0,A.useCallback)(async()=>{let e=p?.feishu?.appSecret;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),Ue(!0),window.setTimeout(()=>Ue(!1),2e3))},[p]),mt=(0,A.useCallback)(async()=>{let e=p?.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(()=>{}),Ge(!0),window.setTimeout(()=>Ge(!1),2e3)},[p]),ht=(0,A.useCallback)(()=>{if(!p)return;let e=V.trim();if(!e){X({accounts:{}}),U(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);X({accounts:t}),U(``)}catch(e){U(e instanceof Error?e.message:r.jsonInvalid)}},[p,V,X,r.jsonObjectAccounts,r.jsonInvalid]),gt=(0,A.useCallback)(()=>{if(!p)return;let e=qe.trim();if(!e){st({accounts:{}}),G(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);st({accounts:t}),G(``)}catch(e){G(e instanceof Error?e.message:r.jsonInvalid)}},[p,qe,st,r.jsonObjectAccounts,r.jsonInvalid]),_t=(0,A.useCallback)(()=>{if(!p)return;let e=Ye.trim();if(!e){Z({accounts:{}}),q(``);return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(r.jsonObjectAccounts);Z({accounts:t}),q(``)}catch(e){q(e instanceof Error?e.message:r.jsonInvalid)}},[p,Ye,Z,r.jsonObjectAccounts,r.jsonInvalid]),vt=(0,A.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:r.policy.dm[e]})),[r.policy.dm]),yt=(0,A.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:r.policy.group[e]})),[r.policy.group]),bt=(0,A.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:r.policy.reply[e]})),[r.policy.reply]),xt=(0,A.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:r.policy.stream[e]})),[r.policy.stream]);if(!s)return(0,F.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,F.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.channels}),(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(it)return(0,F.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,F.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,F.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,F.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.loading})]});if(!p)return(0,F.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ce??at??r.loadError}),(0,F.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>void nt(),children:r.retry})]});let Q=p.telegram,St=p.weixin,$=p.feishu,Ct=v?.telegram?.botToken??``,wt=!B&&!!String(Ct).trim()&&Q.botToken===Ct,Tt=v?.feishu?.appSecret??``,Et=!Ie&&!!String(Tt).trim()&&$.appSecret===Tt,Dt=Oe(St),Ot=De(Q),kt=ke($),At=(0,F.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[(0,F.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,F.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,F.jsx)(S,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),r.advancedShow]})}),(0,F.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:r.weixinAdvancedHint}),(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:St.enabled,onChange:e=>st({enabled:e.target.checked})}),(0,F.jsx)(`span`,{children:r.enableWeixinAria})]}),(0,F.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,F.jsx)(Ne,{wx:St,updateWeixin:st,ch:r,dmOpts:vt,streamOpts:xt,wxAccountsDraft:qe,setWxAccountsDraft:W,wxAccountsError:Je,onWxAccountsBlur:gt,channelAgentRoutesWx:p.channelAgentRoutes.weixin,defaultAgentId:p.defaultAgentId,agentItems:Ze?.items??[],onAgentRouteChange:(e,t)=>ot(`weixin`,e,t),routingDisabled:w})}),(0,F.jsx)(g,{type:`button`,variant:`primary`,className:`w-full`,disabled:!rt||w,onClick:async()=>{await ct()},children:w?r.saving:r.save})]})]});return(0,F.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,F.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.channels}),(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,F.jsxs)(`a`,{href:te(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,F.jsx)(c,{className:`size-3.5`})]})]}),rt?(0,F.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,le?(0,F.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.saved}):null,ce?(0,F.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ce}):null,ve?(0,F.jsx)(`p`,{className:`text-xs text-accent`,children:ve}):null,we?(0,F.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:we}):null,(0,F.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,F.jsx)(je,{icon:(0,F.jsx)(h,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.weixinTitle,subtitle:r.weixinSubtitle,configured:Dt,enabled:St.enabled,toggleDisabled:w,onToggle:e=>void lt(`weixin`,e),onConfigure:()=>de(!0),onEdit:()=>de(!0),onRemove:()=>P(`weixin`),ch:r}),(0,F.jsx)(je,{icon:(0,F.jsx)(b,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.telegramTitle,subtitle:r.telegramSubtitle,configured:Ot,enabled:Q.enabled,toggleDisabled:w,onToggle:e=>void lt(`telegram`,e),onConfigure:()=>j(!0),onEdit:()=>j(!0),onRemove:()=>P(`telegram`),ch:r}),(0,F.jsx)(je,{icon:(0,F.jsx)(h,{className:`size-6 text-accent`,strokeWidth:1.75}),title:r.feishuTitle,subtitle:r.feishuSubtitle,configured:kt,enabled:$.enabled,toggleDisabled:w,onToggle:e=>void lt(`feishu`,e),onConfigure:()=>M(!0),onEdit:()=>M(!0),onRemove:()=>P(`feishu`),ch:r})]}),(0,F.jsx)($e,{open:ue,onOpenChange:de,ch:r,onLoginSuccess:async()=>{await nt(),ye(r.weixinQrLoginSuccess),window.setTimeout(()=>ye(null),4e3)},moreSettings:At}),(0,F.jsx)(Qe,{open:xe,onOpenChange:Se,ch:r,onSetupSuccess:ft}),(0,F.jsx)(C,{open:fe,onOpenChange:j,children:(0,F.jsxs)(se,{children:[(0,F.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,F.jsxs)(ie,{className:_(`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,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(ee,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.telegramTitle}),(0,F.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:r.telegramSubtitle})]}),(0,F.jsx)(re,{asChild:!0,children:(0,F.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,F.jsx)(u,{className:`size-4`})})})]}),(0,F.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:Q.enabled,onChange:e=>X({enabled:e.target.checked})}),(0,F.jsx)(`span`,{children:r.enableTelegramAria})]}),(0,F.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsxs)(I,{children:[r.telegramToken,(0,F.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(`input`,{className:_(e(),`min-w-0 flex-1 font-mono text-xs`),type:B?`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,F.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void dt(),children:[Be?(0,F.jsx)(T,{className:`size-3.5`}):(0,F.jsx)(a,{className:`size-3.5`}),Be?r.copied:r.copy]}):null,(0,F.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Fe(e=>!e),children:[B?(0,F.jsx)(E,{className:`size-3.5`}):(0,F.jsx)(l,{className:`size-3.5`}),B?r.hide:r.show]})]}),(0,F.jsx)(L,{children:r.telegramTokenDesc})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.allowFromDm}),(0,F.jsx)(`textarea`,{className:_(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`123456789, 987654321`,value:Ee(Q.allowFrom),onChange:e=>X({allowFrom:Te(e.target.value)})}),(0,F.jsx)(L,{children:r.allowFromDmDesc})]}),p?(0,F.jsx)(Ae,{accountIds:me(Q),routes:p.channelAgentRoutes.telegram,defaultAgentId:p.defaultAgentId,agentItems:Ze?.items??[],disabled:w,onChange:(e,t)=>ot(`telegram`,e,t),ch:r}):null,(0,F.jsxs)(g,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:()=>z(e=>!e),children:[(0,F.jsx)(S,{className:_(`mr-1 size-4 transition-transform`,Pe&&`rotate-180`)}),Pe?r.advancedHide:r.advancedShow]}),Pe?(0,F.jsx)(Me,{tg:Q,updateTelegram:X,ch:r,dmOpts:vt,groupOpts:yt,replyOpts:bt,streamOpts:xt,tgAccountsDraft:V,setTgAccountsDraft:H,tgAccountsError:Ke,onTgAccountsBlur:ht}):null]}),(0,F.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,F.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>j(!1),children:r.modalCancel}),(0,F.jsx)(g,{type:`button`,variant:`primary`,disabled:!rt||w,onClick:async()=>{await ct()&&j(!1)},children:w?r.saving:r.save})]})]})]})}),(0,F.jsx)(C,{open:pe,onOpenChange:M,children:(0,F.jsxs)(se,{children:[(0,F.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,F.jsxs)(ie,{className:_(`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,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(ee,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.feishuTitle}),(0,F.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:r.feishuSubtitle})]}),(0,F.jsx)(re,{asChild:!0,children:(0,F.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,F.jsx)(u,{className:`size-4`})})})]}),(0,F.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.enabled,onChange:e=>Z({enabled:e.target.checked})}),(0,F.jsx)(`span`,{children:r.enableFeishuAria})]}),kt?null:(0,F.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,F.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.feishuQrSetupTitle}),(0,F.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:r.feishuQrSetupDesc})]}),(0,F.jsx)(g,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:()=>Se(!0),children:r.feishuQrSetupButton})]})}),(0,F.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsxs)(I,{children:[r.feishuAppId,(0,F.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,F.jsx)(`input`,{className:_(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.appId,onChange:e=>Z({appId:e.target.value}),placeholder:`cli_xxx`}),(0,F.jsx)(L,{children:r.feishuAppIdDesc})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsxs)(I,{children:[r.feishuAppSecret,(0,F.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(`input`,{className:_(e(),`min-w-0 flex-1 font-mono text-xs`),type:Ie?`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,F.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void pt(),children:[He?(0,F.jsx)(T,{className:`size-3.5`}):(0,F.jsx)(a,{className:`size-3.5`}),He?r.copied:r.copy]}):null,(0,F.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Le(e=>!e),children:[Ie?(0,F.jsx)(E,{className:`size-3.5`}):(0,F.jsx)(l,{className:`size-3.5`}),Ie?r.hide:r.show]})]}),(0,F.jsx)(L,{children:r.feishuAppSecretDesc})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.feishuDomain}),(0,F.jsxs)(`select`,{className:e(),value:String($.domain||`feishu`),onChange:e=>Z({domain:e.target.value}),children:[(0,F.jsx)(`option`,{value:`feishu`,children:`feishu`}),(0,F.jsx)(`option`,{value:`lark`,children:`lark`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.connectionMode}),(0,F.jsxs)(`select`,{className:e(),value:$.connectionMode,onChange:e=>Z({connectionMode:e.target.value}),children:[(0,F.jsx)(`option`,{value:`websocket`,children:`websocket`}),(0,F.jsx)(`option`,{value:`webhook`,children:`webhook`})]}),(0,F.jsx)(L,{children:r.connectionModeDesc})]})]}),$.connectionMode===`webhook`?(0,F.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.webhookTitle}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>ze(e=>!e),children:[Re?(0,F.jsx)(E,{className:`size-3.5`}):(0,F.jsx)(l,{className:`size-3.5`}),Re?r.hide:r.show]}),(0,F.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void mt(),children:[We?(0,F.jsx)(T,{className:`size-3.5`}):(0,F.jsx)(a,{className:`size-3.5`}),We?r.copied:r.copy]})]})]}),(0,F.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.verificationToken}),(0,F.jsx)(`input`,{className:_(e(),`min-w-0 flex-1 font-mono text-xs`),type:Re?`text`:`password`,autoComplete:`off`,value:$.verificationToken??``,onChange:e=>Z({verificationToken:e.target.value})}),(0,F.jsx)(L,{children:r.verificationTokenDesc})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.encryptKey}),(0,F.jsx)(`input`,{className:_(e(),`min-w-0 flex-1 font-mono text-xs`),type:Re?`text`:`password`,autoComplete:`off`,value:$.encryptKey??``,onChange:e=>Z({encryptKey:e.target.value})}),(0,F.jsx)(L,{children:r.encryptKeyDesc})]})]}),(0,F.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,F.jsx)(I,{children:r.webhookHost}),(0,F.jsx)(`input`,{className:_(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,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.webhookPort}),(0,F.jsx)(`input`,{className:_(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,F.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.webhookPath}),(0,F.jsx)(`input`,{className:_(e(),`min-w-0 flex-1 font-mono text-xs`),value:$.webhookPath??``,onChange:e=>Z({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,F.jsx)(L,{children:r.webhookPathDesc})]})]}):null,(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.renderMode}),(0,F.jsxs)(`select`,{className:e(),value:$.renderMode,onChange:e=>Z({renderMode:e.target.value}),children:[(0,F.jsx)(`option`,{value:`auto`,children:`auto`}),(0,F.jsx)(`option`,{value:`raw`,children:`raw`}),(0,F.jsx)(`option`,{value:`card`,children:`card`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.reactionNotifications}),(0,F.jsxs)(`select`,{className:e(),value:$.reactionNotifications,onChange:e=>Z({reactionNotifications:e.target.value}),children:[(0,F.jsx)(`option`,{value:`off`,children:`off`}),(0,F.jsx)(`option`,{value:`own`,children:`own`}),(0,F.jsx)(`option`,{value:`all`,children:`all`})]})]})]}),(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.streaming,onChange:e=>Z({streaming:e.target.checked})}),r.enableStreaming]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.dmPolicy}),(0,F.jsx)(`select`,{className:e(),value:$.dmPolicy,onChange:e=>Z({dmPolicy:e.target.value}),children:vt.map(e=>(0,F.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.groupPolicy}),(0,F.jsx)(`select`,{className:e(),value:$.groupPolicy,onChange:e=>Z({groupPolicy:e.target.value}),children:yt.map(e=>(0,F.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:$.requireMention,onChange:e=>Z({requireMention:e.target.checked})}),r.requireMention]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.allowFromDm}),(0,F.jsx)(`textarea`,{className:_(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`ou_xxx, on_xxx`,value:Ee($.allowFrom),onChange:e=>Z({allowFrom:Te(e.target.value)})}),(0,F.jsx)(L,{children:r.allowFromDmDesc})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.allowFromGroups}),(0,F.jsx)(`textarea`,{className:_(e(),`min-h-[2.75rem] resize-y font-mono text-xs`),rows:2,placeholder:`oc_xxx, oc_yyy`,value:Ee($.groupAllowFrom),onChange:e=>Z({groupAllowFrom:Te(e.target.value)})}),(0,F.jsx)(L,{children:r.allowFromGroupsDesc})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.historyLimit}),(0,F.jsx)(`input`,{className:_(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,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.textChunkLimit}),(0,F.jsx)(`input`,{className:_(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,F.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.feishuToolsTitle}),(0,F.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,F.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!$.tools?.[e],onChange:t=>Z({tools:{...$.tools,[e]:t.target.checked}})}),t]},e))}),(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(L,{children:r.feishuToolsDesc})})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.feishuActionsTitle}),(0,F.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!$.actions?.reactions,onChange:e=>Z({actions:{...$.actions,reactions:e.target.checked}})}),r.feishuActionReactions]})]}),p?(0,F.jsx)(Ae,{accountIds:he($),routes:p.channelAgentRoutes.feishu,defaultAgentId:p.defaultAgentId,agentItems:Ze?.items??[],disabled:w,onChange:(e,t)=>ot(`feishu`,e,t),ch:r}):null,(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(I,{children:r.multiAccountJson}),(0,F.jsx)(`textarea`,{className:_(e(),`min-h-[140px] resize-y font-mono text-xs`),spellCheck:!1,value:Ye,onChange:e=>K(e.target.value),onBlur:_t,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),Xe?(0,F.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:Xe}):(0,F.jsx)(L,{children:r.multiAccountJsonDesc})]})]}),(0,F.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,F.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>M(!1),children:r.modalCancel}),(0,F.jsx)(g,{type:`button`,variant:`primary`,disabled:!rt||w,onClick:async()=>{await ct()&&M(!1)},children:w?r.saving:r.save})]})]})]})}),(0,F.jsx)(C,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,F.jsxs)(se,{children:[(0,F.jsx)(ne,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[1px]`}),(0,F.jsxs)(ie,{className:_(`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,F.jsx)(ee,{className:`text-base font-semibold text-fg`,children:r.removeChannelTitle}),(0,F.jsx)(x,{className:`mt-2 text-sm text-fg-muted`,children:N?r.removeChannelConfirm.replace(`{{name}}`,N===`weixin`?r.weixinTitle:N===`telegram`?r.telegramTitle:r.feishuTitle):`\xA0`}),(0,F.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,F.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>P(null),children:r.modalCancel}),(0,F.jsx)(g,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:w,onClick:()=>void ut(),children:w?r.saving:r.removeChannelAction})]})]})]})})]})})}export{et as ChannelsSettingsPanel};
9
- //# sourceMappingURL=channels-settings-BGueHxMv.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{$ as r,An as i,Bt as a,Cr as o,En as s,F as ee,Ft as c,Hn as te,I as ne,In as re,It as l,Kn as ie,Kt as u,Mt as ae,Ot as oe,Rt as d,Vt as f,Wt as p,Xn as se,a as ce,b as le,dn as m,dt as h,ft as g,i as ue,jt as de,lt as _,mn as v,nn as fe,nr as y,ot as pe,r as me,st as he,t as ge,ut as _e,x as ve,y as ye}from"./index-DG8WvMbu.js";import{C as be,S as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,l as je,m as Me,n as Ne,o as Pe,p as Fe,r as Ie,s as Le,t as Re,u as ze,v as Be,x as Ve,y as He}from"./cron-utils-zbRs2yND.js";import{a as Ue,i as We,n as Ge,r as Ke,t as qe}from"./dist-CDA7gR_M.js";var b=e(t(),1);function Je(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 x=[`daily`,`monitoring`,`reports`,`automation`],Ye=[{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 Xe(e){return Ye.find(t=>t.templateId===e)}var S=n();function Ze(e){let{cron:t,localeTag:n,scheduleBadgeLabels:r,categoryFilter:i,onCategoryFilterChange:a,onSelectTemplate:o}=e,s=i===`all`?[...Ye]:Ye.filter(e=>e.category===i);return(0,S.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.fromTemplate,children:[(0,S.jsx)(f,{type:`button`,variant:i===`all`?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>a(`all`),children:t.templateFilterAll}),x.map(e=>(0,S.jsx)(f,{type:`button`,variant:i===e?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>a(e),children:t.templateCategories[e]},e))]}),s.length===0?(0,S.jsx)(`p`,{className:`text-center text-sm text-fg-muted`,children:t.templatesEmptyHint}):(0,S.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:s.map(e=>{let i=Je(t,e.templateId);if(!i)return null;let a=Pe({schedule:e.defaultSchedule,timezone:void 0,next_run:void 0},n,r);return(0,S.jsxs)(`button`,{type:`button`,className:p(`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:()=>o(e.templateId),"aria-label":`${t.templateCategories[e.category]} — ${i.title}`,children:[(0,S.jsx)(`span`,{className:`font-semibold text-fg`,children:i.title}),(0,S.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:i.description}),(0,S.jsx)(`span`,{className:`mt-1 flex items-center gap-1 text-xs text-fg-muted`,children:(0,S.jsx)(`span`,{className:`tabular-nums`,children:a})})]},e.templateId)})})]})}var C=je(),w=p(d,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),T=p(`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`,c,`dark:bg-surface-panel`),Qe=p(`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`,c),E=p(`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`,c),$e=p(`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`,c);function et(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function D(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`).sort((e,t)=>e-t):[]}function O(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 tt(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 k(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 nt(e){let t=e.trim(),n={mode:`custom`,intervalKind:`minutes`,onceDate:et(),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=C.CronExpressionParser.parse(t).fields,r=D(e.minute.values),i=D(e.hour.values),a=D(e.dayOfMonth.values),o=D(e.month.values),s=D(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=O(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=O(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],ee=a[0],c=`${e}-${String(s).padStart(2,`0`)}-${String(ee).padStart(2,`0`)}`;return{...n,mode:`no_repeat`,minute:r[0],hour:i[0],onceDate:c,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:k(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 rt(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)} * * ${tt(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 it({value:e,onChange:t,labels:n,disabled:r}){let i=(0,b.useMemo)(()=>nt(e),[e]),[a,o]=(0,b.useState)(i.mode),[s,ee]=(0,b.useState)(i.intervalKind),[c,te]=(0,b.useState)(i.onceDate),[ne,re]=(0,b.useState)(i.intervalMinutes),[l,ie]=(0,b.useState)(i.intervalHours),[u,ae]=(0,b.useState)(i.minute),[oe,d]=(0,b.useState)(i.hour),[f,se]=(0,b.useState)(i.weekDays),[ce,le]=(0,b.useState)(i.dayOfMonth),[m,h]=(0,b.useState)(i.rawCron),[g,ue]=(0,b.useState)(null),[de,_]=(0,b.useState)(null);(0,b.useEffect)(()=>{let t=nt(e);o(t.mode),ee(t.intervalKind),te(t.onceDate),re(t.intervalMinutes),ie(t.intervalHours),ae(t.minute),d(t.hour),se(t.weekDays),le(t.dayOfMonth),h(t.rawCron),ue(null),_(null)},[e]);let v=(0,b.useCallback)(e=>{t(rt({mode:a,intervalKind:s,onceDate:c,intervalMinutes:ne,intervalHours:l,minute:u,hour:oe,weekDays:f,dayOfMonth:ce,rawCron:m,...e}))},[a,s,c,ne,l,u,oe,f,ce,m,t]),fe=`${String(oe).padStart(2,`0`)}:${String(u).padStart(2,`0`)}`,y=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)||v({minute:r,hour:n})},pe=(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,S.jsxs)(`select`,{className:w,disabled:r,value:a,onChange:e=>{let t=e.target.value;o(t),v({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,S.jsx)(`option`,{value:`no_repeat`,children:n.modeNoRepeat}),(0,S.jsx)(`option`,{value:`interval`,children:n.modeInterval}),(0,S.jsx)(`option`,{value:`hourly`,children:n.modeHourly}),(0,S.jsx)(`option`,{value:`daily`,children:n.modeDaily}),(0,S.jsx)(`option`,{value:`weekly`,children:n.modeWeekly}),(0,S.jsx)(`option`,{value:`monthly`,children:n.modeMonthly}),(0,S.jsx)(`option`,{value:`custom`,children:n.modeCustom})]}),a===`no_repeat`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`input`,{type:`date`,disabled:r,className:Qe,value:c,onChange:e=>{let t=e.target.value;te(t),v({onceDate:t})},"aria-label":n.modeNoRepeat}),(0,S.jsx)(`input`,{type:`time`,step:60,disabled:r,className:T,value:fe,onChange:y,"aria-label":n.scheduleTimeLabel})]}),a===`interval`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`select`,{className:p(w,`w-auto min-w-[5rem]`),disabled:r,value:s,onChange:e=>{let t=e.target.value;ee(t),ue(null),_(null),v({intervalKind:t})},"aria-label":n.modeInterval,children:[(0,S.jsx)(`option`,{value:`minutes`,children:n.intervalKindMinutes}),(0,S.jsx)(`option`,{value:`hours`,children:n.intervalKindHours})]}),s===`minutes`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:E,value:g??String(ne),onChange:e=>{let t=e.target.value;ue(t);let n=parseInt(t,10);Number.isFinite(n)&&n>=1&&n<=59&&(re(n),v({intervalMinutes:n}))},onBlur:()=>{if(g===null)return;let e=parseInt(g,10),t=!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e)));re(t),v({intervalMinutes:t}),ue(null)},"aria-label":n.intervalMinutes}),(0,S.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:E,value:de??String(l),onChange:e=>{let t=e.target.value;_(t);let n=parseInt(t,10);Number.isFinite(n)&&n>=1&&n<=23&&(ie(n),v({intervalHours:n}))},onBlur:()=>{if(de===null)return;let e=parseInt(de,10),t=!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e)));ie(t),v({intervalHours:t}),_(null)},"aria-label":n.intervalHours}),(0,S.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,S.jsx)(`select`,{className:p(w,`w-auto min-w-[4rem]`),disabled:r,value:u,onChange:e=>{let t=parseInt(e.target.value,10);ae(t),v({minute:t})},"aria-label":n.minuteAtHour,children:Array.from({length:60},(e,t)=>(0,S.jsx)(`option`,{value:t,children:String(t).padStart(2,`0`)},t))}),(0,S.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),a===`daily`&&(0,S.jsx)(`input`,{type:`time`,step:60,disabled:r,className:T,value:fe,onChange:y,"aria-label":n.scheduleTimeLabel}),a===`weekly`&&(0,S.jsx)(`input`,{type:`time`,step:60,disabled:r,className:T,value:fe,onChange:y,"aria-label":n.scheduleTimeLabel}),a===`monthly`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`select`,{className:p(w,`w-auto min-w-[4.5rem]`),disabled:r,value:ce,onChange:e=>{let t=parseInt(e.target.value,10);le(t),v({dayOfMonth:t})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))}),(0,S.jsx)(`input`,{type:`time`,step:60,disabled:r,className:T,value:fe,onChange:y,"aria-label":n.scheduleTimeLabel})]}),a===`hourly`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`select`,{className:p(w,`w-auto min-w-[4rem]`),disabled:r,value:u,onChange:e=>{let t=parseInt(e.target.value,10);ae(t),v({minute:t})},"aria-label":n.minuteAtHour,children:Array.from({length:60},(e,t)=>(0,S.jsx)(`option`,{value:t,children:String(t).padStart(2,`0`)},t))}),(0,S.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),me=a===`weekly`?(0,S.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,S.jsx)(`button`,{type:`button`,disabled:r,className:p(`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],se(e),v({weekDays:e})},children:e},e)})}):null,he=a===`custom`?(0,S.jsxs)(`div`,{className:`pt-1`,children:[(0,S.jsx)(`textarea`,{disabled:r,className:$e,rows:2,spellCheck:!1,value:m,placeholder:`*/5 * * * *`,onChange:e=>{let n=e.target.value;h(n),t(n.trim()||`*/5 * * * *`)},"aria-label":n.modeCustom}),(0,S.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}),pe,me,he]})}var at=400;function ot(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function st(e){let t=ot(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function ct(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}var lt=`*/5 * * * *`,ut=`xopc.recentWorkspaceDirs.v1`,A=10;function dt(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function ft(e){let t=e.trim();if(t)try{let e=localStorage.getItem(ut),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,A);localStorage.setItem(ut,JSON.stringify(r))}catch{}}function pt(e){return p(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,c,e&&`cursor-not-allowed opacity-60`)}function mt(){return p(d,l)}var ht=p(d,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),gt=p(d,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function _t(){let e=ae(e=>e.language),t=a(e),n=t.cron,c=t.chat,l=!!oe(e=>e.token),d=de(e=>e.resolved)===`dark`,je=e===`zh`?`zh-CN`:`en-US`,[x,Ye]=(0,b.useState)([]),[C,w]=(0,b.useState)(`tasks`),[T,Qe]=(0,b.useState)(`created_desc`),[E,$e]=(0,b.useState)(`day`),[et,D]=(0,b.useState)(``),[O,tt]=(0,b.useState)(``),[k,nt]=(0,b.useState)(!1),rt=(0,b.useRef)(null),ut=(0,b.useRef)(k),A=typeof navigator<`u`&&`wakeLock`in navigator,[_t,vt]=(0,b.useState)([]),[yt,bt]=(0,b.useState)([]),[xt,St]=(0,b.useState)(``),[Ct,wt]=(0,b.useState)([]),[Tt,Et]=(0,b.useState)([]),[Dt,Ot]=(0,b.useState)(!1),[kt,j]=(0,b.useState)(null),[At,jt]=(0,b.useState)([]),[M,Mt]=(0,b.useState)(!1),[N,Nt]=(0,b.useState)(!1),[P,Pt]=(0,b.useState)(`add`),[Ft,It]=(0,b.useState)(null),[Lt,Rt]=(0,b.useState)(``),[zt,Bt]=(0,b.useState)(lt),[F,I]=(0,b.useState)(`local`),[Vt,L]=(0,b.useState)(``),[R,z]=(0,b.useState)(``),[Ht,Ut]=(0,b.useState)(`edit`),[Wt,Gt]=(0,b.useState)(0),[B,Kt]=(0,b.useState)(`main`),[qt,V]=(0,b.useState)(``),[Jt,H]=(0,b.useState)(!1),[U,W]=(0,b.useState)(``),[Yt,Xt]=(0,b.useState)(!1),[Zt,G]=(0,b.useState)(``),[K,Qt]=(0,b.useState)(!1),$t=(0,b.useRef)(!1),[en,tn]=(0,b.useState)(!1),[q,nn]=(0,b.useState)(null),[rn,an]=(0,b.useState)([]),[on,sn]=(0,b.useState)(!1),[cn,ln]=(0,b.useState)(!1),[J,un]=(0,b.useState)(null),[dn,fn]=(0,b.useState)(null),[pn,mn]=(0,b.useState)(!1),[hn,gn]=(0,b.useState)(`all`),Y=(0,b.useRef)(null),_n=(0,b.useCallback)(e=>{Y.current=e,window.setTimeout(()=>{Y.current===e&&(Y.current=null)},400)},[]),X=(0,b.useCallback)(()=>xt||(yt.length>0?yt[0].id:``),[xt,yt]),vn=typeof window<`u`&&!!window.electronAPI?.file?.openDirectory,yn=(0,b.useCallback)(async()=>{let e=typeof window<`u`?window.electronAPI?.file?.openDirectory:void 0;return e?e():null},[]),bn=(0,b.useCallback)(async e=>{let t=e.trim();t&&(ft(t),W(t))},[]),xn=(0,b.useMemo)(()=>{let e=new Set(Tt.map(e=>e.id)),t=[...Tt],n=qt.trim().toLowerCase();return n&&!e.has(n)&&t.push({id:n}),t},[Tt,qt]),Sn=F!==`local`&&(B===`main`||B===`isolated`&&!Jt),Cn=B===`main`||B===`isolated`&&!Jt,wn=!!Lt.trim()&&!!zt.trim()&&!!R.trim()&&(!Sn||!!Vt.trim()),Z=(0,b.useCallback)(async()=>{Mt(!0);try{jt(await De(at))}catch{}finally{Mt(!1)}},[]),Q=(0,b.useCallback)(async()=>{Ot(!0),j(null);try{Ye(await He())}catch(e){j(e instanceof Error?e.message:n.failedToLoadJobs)}finally{Ot(!1)}},[n.failedToLoadJobs]),$=(0,b.useCallback)(async()=>{try{let[e,t,n,r]=await Promise.all([Fe(),Se(),Me(),ge().catch(()=>null)]);vt(e),bt(t),St(n.model||``),r&&Et(r.items)}catch{}},[]);(0,b.useEffect)(()=>{l&&(Q(),$())},[l,Q,$]),(0,b.useEffect)(()=>{!l||C!==`history`||Z()},[l,C,Z]);let Tn=(0,b.useCallback)(async()=>{try{await rt.current?.release()}catch{}rt.current=null},[]),En=(0,b.useCallback)(async()=>{if(A)try{let e=await navigator.wakeLock.request(`screen`);rt.current=e,e.addEventListener(`release`,()=>{rt.current=null})}catch{j(n.wakeLockUnavailable),nt(!1)}},[n.wakeLockUnavailable,A]);ut.current=k,(0,b.useEffect)(()=>{if(!k){Tn();return}En();let e=()=>{document.visibilityState===`visible`&&ut.current&&En()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),Tn()}},[k,En,Tn]),(0,b.useEffect)(()=>{if(!N||P!==`add`||$t.current)return;let e=X();e&&G(e)},[N,P,X]),(0,b.useEffect)(()=>{!N||P!==`add`||new Set([`local`,..._t.map(e=>e.name)]).has(F)||I(`local`)},[_t,F,P,N]),(0,b.useEffect)(()=>{if(F===`local`){wt([]);return}let e=!1;return Be(F).then(t=>{e||wt(t)}),()=>{e=!0}},[F,N]);let Dn=(0,b.useCallback)(e=>{if($t.current=!1,Nt(!0),Pt(e?`edit`:`add`),It(e?.id??null),e){Rt(e.name||``),Bt(e.schedule&&String(e.schedule).trim()||lt);let t=Ee(e);z(t??``),Kt(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)I(`local`),L(``);else if(e.delivery&&e.delivery.mode!==`none`&&e.delivery.to)I(e.delivery.channel||`telegram`),L(e.delivery.to||``);else if(i)I(`telegram`),L(``);else{let e=t.split(`:`);e.length>=3&&[`telegram`,`cli`,`gateway`,`local`].includes(e[0])?(I(e[0]),L(e[1]),z(e.slice(2).join(`:`))):(I(`telegram`),L(``))}}else Rt(``),Bt(lt),I(`local`),L(``),z(``),Kt(`main`),V(``),W(``),H(!1),G(X());Ut(`edit`),Gt(e=>e+1)},[X]),On=(0,b.useCallback)(e=>{Ut(e),e===`edit`&&Gt(e=>e+1)},[]),kn=(0,b.useCallback)(e=>{let n=Xe(e),r=n?Je(t.cron,e):void 0;!n||!r||($t.current=!1,Pt(`add`),It(null),Rt(r.title),Bt(n.defaultSchedule),z(r.prompt),Kt(n.defaultSessionTarget),I(`local`),L(``),H(!1),V(``),W(``),G(X()),Ut(`edit`),Gt(e=>e+1),mn(!1),Nt(!0))},[X,t.cron]),An=(0,b.useCallback)(()=>{Nt(!1),Pt(`add`),It(null),Rt(``),Bt(lt),I(`local`),L(``),z(``),Kt(`main`),V(``),W(``),Xt(!1),H(!1),G(``),Ut(`edit`),$t.current=!1},[]),jn=async()=>{if(!Lt.trim()){j(n.nameRequired);return}if(!zt.trim()||!R.trim()){j(n.scheduleRequired);return}if(Sn&&!Vt.trim()){j(n.chatIdRequired);return}Qt(!0),j(null);try{let e=R.trim(),t;t=B===`isolated`&&Jt?{mode:`none`}:F===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:F,to:Vt.trim()};let n=B===`isolated`?{kind:`agentTurn`,message:e,...Zt.trim()?{model:Zt.trim()}:{}}:{kind:`systemEvent`,text:e},r=Zt.trim(),i=qt.trim().toLowerCase(),a=B===`main`?null:i||null,o=U.trim(),s={name:Lt.trim(),schedule:zt.trim(),sessionTarget:B,model:B===`isolated`&&r?r:void 0,delivery:t,payload:n,...P===`edit`?{agentId:a,workingDirectory:B===`isolated`&&o||null}:{...B===`isolated`&&i?{agentId:i}:{},...B===`isolated`&&o?{workingDirectory:o}:{}}};if(P===`edit`&&Ft)await be(Ft,s);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=s;await ze(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}An(),await Q(),await $()}catch(e){j(e instanceof Error?e.message:P===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{Qt(!1)}},Mn=async e=>{tn(!0),nn(e),sn(!0),an([]);try{let t=await Oe(e.id);t&&(nn(t),an(await ke(e.id,20)))}catch{}finally{sn(!1)}},Nn=async(e,t)=>{try{await xe(e.id,t),await Q(),await $()}catch(e){j(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 Ve(e):(await we(e),q?.id===e&&(tn(!1),nn(null))),await Q(),await $(),await Z()}catch(e){j(e instanceof Error?e.message:n.actionFailed)}};(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(N?An():en&&(tn(!1),nn(null)))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[N,en,An]);let Fn={running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled},In=(0,b.useMemo)(()=>{let e=[...x];return e.sort((e,t)=>{let n=new Date(e.created_at).getTime(),r=new Date(t.created_at).getTime();return T===`created_desc`?r-n:n-r}),e},[x,T]),Ln=(0,b.useMemo)(()=>{let e=new Date,t=E===`day`?ot(e):E===`week`?st(e):ct(e);return At.filter(e=>!(new Date(e.startedAt)<t||et&&e.jobId!==et||O&&e.status!==O))},[At,E,et,O]),Rn=n.scheduleBadge,zn=(0,b.useCallback)(()=>{Q(),$(),Z()},[Q,$,Z]),Bn=r(e=>e.setPageHeader),Vn=r(e=>e.clearPageHeader),{pathname:Hn}=o(),Un=Hn.startsWith(`/settings/`),Wn=(0,b.useMemo)(()=>(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,S.jsx)(f,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,disabled:Dt||M,title:n.refresh,"aria-label":n.refresh,onClick:()=>void zn(),children:(0,S.jsx)(m,{className:p(`size-4`,(Dt||M)&&`animate-spin`),strokeWidth:1.75})}),(0,S.jsxs)(f,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:()=>{gn(`all`),mn(!0)},children:[(0,S.jsx)(i,{className:`size-4`,strokeWidth:1.75}),n.fromTemplate]}),(0,S.jsxs)(f,{type:`button`,variant:`primary`,className:`gap-2`,onClick:()=>Dn(),children:[(0,S.jsx)(v,{className:`size-4`,strokeWidth:1.75}),n.addJob]})]}),[n.addJob,n.fromTemplate,n.refresh,Dt,Dn,zn,M]);return(0,b.useLayoutEffect)(()=>!l||Un?(Vn(),()=>Vn()):(Bn({startExtra:null,main:null,end:Wn}),()=>Vn()),[Vn,Wn,l,Un,Bn]),l?(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:[(0,S.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[kt?(0,S.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:kt}):null,(0,S.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:n.subtitle})]})}),Un?(0,S.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,S.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,S.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":n.title,children:[(0,S.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`tasks`,className:p(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,C===`tasks`?`text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>w(`tasks`),children:n.tabMyTasks}),(0,S.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`history`,className:p(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,C===`history`?`text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>w(`history`),children:n.tabRunHistory})]}),(0,S.jsx)(`div`,{className:p(`flex min-w-0 items-center gap-2`,C===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`),children:C===`tasks`?(0,S.jsxs)(`select`,{className:gt,value:T,onChange:e=>Qe(e.target.value),"aria-label":n.sortCreatedDesc,children:[(0,S.jsx)(`option`,{value:`created_desc`,children:n.sortCreatedDesc}),(0,S.jsx)(`option`,{value:`created_asc`,children:n.sortCreatedAsc})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:p(ne,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,S.jsx)(`button`,{type:`button`,className:p(ee,`px-2.5 py-1`,E===e&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,E===e&&`text-fg`),onClick:()=>$e(e),children:e===`day`?n.historyRangeDay:e===`week`?n.historyRangeWeek:n.historyRangeMonth},e))}),(0,S.jsxs)(`select`,{className:gt,value:et,onChange:e=>D(e.target.value),"aria-label":n.filterAllTasks,children:[(0,S.jsx)(`option`,{value:``,children:n.filterAllTasks}),x.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))]}),(0,S.jsxs)(`select`,{className:gt,value:O,onChange:e=>tt(e.target.value),"aria-label":n.filterAllStatuses,children:[(0,S.jsx)(`option`,{value:``,children:n.filterAllStatuses}),(0,S.jsx)(`option`,{value:`success`,children:n.execStatusSuccess}),(0,S.jsx)(`option`,{value:`failed`,children:n.execStatusFailed}),(0,S.jsx)(`option`,{value:`cancelled`,children:n.execStatusCancelled}),(0,S.jsx)(`option`,{value:`running`,children:n.execStatusRunning})]})]})})]}),C===`tasks`?(0,S.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[(0,S.jsx)(`h2`,{id:`cron-tasks-panel`,className:`sr-only`,children:n.tabMyTasks}),(0,S.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,S.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[(0,S.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,S.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[(0,S.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),(0,S.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":k,disabled:!A,title:A?void 0:n.wakeLockUnavailable,className:p(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,k?`justify-end bg-accent`:`justify-start bg-surface-hover`,!A&&`cursor-not-allowed opacity-50`),onClick:()=>{A?nt(e=>!e):j(n.wakeLockUnavailable)},children:(0,S.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})})]})]}),Dt&&x.length===0?(0,S.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,S.jsx)(s,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):x.length===0?(0,S.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,S.jsx)(`div`,{className:`w-full max-w-3xl`,children:(0,S.jsx)(Ze,{cron:n,localeTag:je,scheduleBadgeLabels:Rn,categoryFilter:hn,onCategoryFilterChange:gn,onSelectTemplate:kn})}),(0,S.jsx)(`div`,{className:`flex justify-center`,children:(0,S.jsx)(f,{type:`button`,variant:`primary`,onClick:()=>Dn(),children:n.emptyStateCta})})]}):(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:In.map(e=>(0,S.jsxs)(`article`,{role:`button`,tabIndex:0,className:p(`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,S.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[(0,S.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,className:p(`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,S.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}),(0,S.jsxs)(We,{children:[(0,S.jsx)(Ue,{asChild:!0,children:(0,S.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 w-8 shrink-0 p-0`,"aria-label":n.jobCardMenuAria,onClick:e=>e.stopPropagation(),children:(0,S.jsx)(se,{className:`size-4`,strokeWidth:1.75})})}),(0,S.jsx)(Ke,{children:(0,S.jsxs)(qe,{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,S.jsx)(Ge,{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,S.jsx)(Ge,{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,S.jsx)(Ge,{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,S.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[(0,S.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:e.name||e.id}),(0,S.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:Ee(e),children:(0,S.jsx)(le,{content:Ee(e),compact:!0})})]}),(0,S.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,S.jsx)(y,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,S.jsx)(`span`,{className:`min-w-0 truncate`,children:Pe(e,je,Rn)})]})]},e.id))})]}):(0,S.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{id:`cron-history-panel`,className:`sr-only`,children:n.tabRunHistory}),(0,S.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.runHistoryHint})]}),(0,S.jsx)(f,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,disabled:M,title:n.refresh,"aria-label":n.refresh,onClick:()=>void Z(),children:(0,S.jsx)(m,{className:p(`size-4`,M&&`animate-spin`),strokeWidth:1.75})})]}),M&&At.length===0?(0,S.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,S.jsx)(s,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):Ln.length===0?(0,S.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,S.jsx)(y,{className:`mb-4 size-14 text-fg-disabled`,strokeWidth:1.1,"aria-hidden":!0}),(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:At.length===0?n.emptyHistoryTitle:n.noRunsYet}),(0,S.jsx)(`p`,{className:`mt-2 max-w-sm text-sm text-fg-muted`,children:At.length===0?n.emptyHistoryHint:n.runHistoryHint})]}):(0,S.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:(0,S.jsxs)(`table`,{className:`w-full min-w-[700px] border-collapse text-left text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-edge text-xs font-medium text-fg-muted`,children:[(0,S.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colStarted}),(0,S.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colJob}),(0,S.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.status}),(0,S.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDuration}),(0,S.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDetail}),(0,S.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colChat})]})}),(0,S.jsx)(`tbody`,{children:Ln.map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-edge/60 last:border-0`,children:[(0,S.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg`,children:(0,S.jsx)(`time`,{dateTime:e.startedAt,children:Le(e.startedAt)})}),(0,S.jsx)(`td`,{className:`max-w-[10rem] truncate px-3 py-2.5`,children:x.some(t=>t.id===e.jobId)?(0,S.jsx)(`button`,{type:`button`,className:`text-left text-accent hover:underline`,onClick:()=>{let t=x.find(t=>t.id===e.jobId);t&&Mn(t)},children:e.jobName||e.jobId}):(0,S.jsx)(`span`,{className:`text-fg-muted`,children:e.jobName||e.jobId})}),(0,S.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,S.jsx)(`span`,{className:p(`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:Re(e.status,Fn)})}),(0,S.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:Ie(e.duration)}),(0,S.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:Te(e.summary||e.error,96)}),(0,S.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.sessionKey?.trim()?(0,S.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>dt(e.sessionKey),children:n.openChat}):(0,S.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})})]})]}),(0,S.jsx)(h,{open:N,onOpenChange:e=>!e&&An(),children:(0,S.jsxs)(_e,{children:[(0,S.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,S.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,S.jsxs)(he,{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,S.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,S.jsx)(g,{className:`text-base font-semibold text-fg`,children:P===`edit`?n.editJob:n.addJob}),(0,S.jsx)(pe,{asChild:!0,children:(0,S.jsx)(f,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":n.close,children:(0,S.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}),(0,S.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,S.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.name}),(0,S.jsx)(`input`,{type:`text`,className:pt(),value:Lt,onChange:e=>Rt(e.target.value),placeholder:n.namePlaceholder})]}),(0,S.jsx)(it,{value:zt,onChange:Bt,disabled:K,labels:n.schedulePicker}),(0,S.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.mode}),(0,S.jsxs)(`select`,{className:mt(),value:B,onChange:e=>{let t=e.target.value;Kt(t),t===`main`?(H(!1),V(``),W(``)):t===`isolated`&&!Zt.trim()&&G(X())},children:[(0,S.jsx)(`option`,{value:`main`,children:n.modeDirectOption}),(0,S.jsx)(`option`,{value:`isolated`,children:n.modeAgentOption})]}),(0,S.jsx)(`p`,{className:`text-xs text-fg-muted`,children:B===`main`?n.modeDirect:n.modeAgent})]}),B===`isolated`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.model}),(0,S.jsx)(me,{value:Zt,placeholder:c.modelPlaceholder,searchPlaceholder:c.modelSearchPlaceholder,noMatches:c.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:e=>{$t.current=!0,G(e)}})]}),(0,S.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.agentProfile}),(0,S.jsxs)(`select`,{className:mt(),value:qt,disabled:K,onChange:e=>V(e.target.value),children:[(0,S.jsx)(`option`,{value:``,children:n.agentProfileDefault}),xn.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.name?`${e.id} — ${e.name}`:e.id},e.id))]}),(0,S.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.agentProfileHint})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.workingDirectoryLabel}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsxs)(`button`,{type:`button`,disabled:K,className:p(`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`,ye.transition,ye.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${c.workingDirectory.chooseFolder}`:`${n.workingDirectoryHint}\n${c.workingDirectory.selectWorkingDirectory}`,onClick:e=>{e.stopPropagation(),!K&&(vn?(async()=>{let e=await yn();e&&bn(e)})():Xt(!0))},children:[(0,S.jsx)(te,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,S.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:U.trim()?ue(U.trim()):c.workingDirectory.notSet})]}),U.trim()?(0,S.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,S.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.workingDirectoryHint})]}),(0,S.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,S.jsx)(`input`,{type:`checkbox`,className:p(`ui-checkbox`,`mt-0.5`),checked:Jt,onChange:e=>H(e.target.checked)}),(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.agentLocalOnly}),(0,S.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.agentLocalOnlyHint})]})]})]}):null,Cn?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.channel}),(0,S.jsxs)(`select`,{className:mt(),value:F,onChange:e=>{let t=e.target.value;I(t),t===`local`&&H(!1),L(``)},children:[(0,S.jsx)(`option`,{value:`local`,children:n.channelLocal}),_t.map(e=>(0,S.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name))]})]}),Sn?(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.recipient}),(0,S.jsxs)(f,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:n.refreshRecipientHint,onClick:()=>void Be(F).then(wt),children:[(0,S.jsx)(m,{className:`size-3.5`,strokeWidth:1.75}),n.refreshList]})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,S.jsx)(`input`,{type:`text`,className:p(pt(),`min-w-0 w-full sm:flex-1`),value:Vt,onChange:e=>L(e.target.value),placeholder:n.recipientPlaceholder}),(0,S.jsxs)(`select`,{className:ht,value:Vt,onChange:e=>{let t=e.target.value;t&&L(t)},children:[(0,S.jsx)(`option`,{value:``,children:n.selectRecipient}),Ct.length>0?Ct.map(e=>(0,S.jsx)(`option`,{value:e.chatId,children:Ce(e,n.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,S.jsx)(`option`,{value:``,disabled:!0,children:n.noRecentChatsOption})]})]}),(0,S.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ct.length>0?n.enterManuallyOrSelect:n.noRecentChats})]}):null]}):null,(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.message}),(0,S.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[(0,S.jsxs)(`button`,{type:`button`,className:p(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Ht===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>On(`edit`),children:[(0,S.jsx)(fe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),n.messageEdit]}),(0,S.jsxs)(`button`,{type:`button`,className:p(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Ht===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>On(`preview`),children:[(0,S.jsx)(ie,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),n.messagePreview]})]})]}),(0,S.jsx)(`div`,{className:p(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,K&&`pointer-events-none opacity-60`),children:Ht===`edit`?(0,S.jsx)(ve,{initialContent:R,onChange:z,isDark:d,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${Ft??`new`}-${Wt}`):(0,S.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:R.trim()?(0,S.jsx)(le,{content:R,compact:!0,className:`text-sm`}):(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.messagePlaceholder})})}),(0,S.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.messageMarkdownHint})]})]})}),(0,S.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,S.jsx)(f,{type:`button`,variant:`secondary`,onClick:An,children:n.cancel}),(0,S.jsx)(f,{type:`button`,variant:`primary`,disabled:K||!wn,onClick:()=>void jn(),children:K?n.loading:P===`edit`?n.save:n.create})]})]})})]})}),vn?null:(0,S.jsx)(ce,{open:Yt,onOpenChange:Xt,initialAbsolutePath:U.trim()||void 0,onConfirm:async e=>{await bn(e),Xt(!1)},wd:c.workingDirectory}),(0,S.jsx)(h,{open:pn,onOpenChange:e=>{mn(e),e&&gn(`all`)},children:(0,S.jsxs)(_e,{children:[(0,S.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),(0,S.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,S.jsxs)(he,{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,S.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end border-b border-edge px-4 py-3`,children:[(0,S.jsx)(g,{className:`sr-only`,children:n.fromTemplate}),(0,S.jsx)(pe,{asChild:!0,children:(0,S.jsx)(f,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":n.close,children:(0,S.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}),(0,S.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,S.jsx)(Ze,{cron:n,localeTag:je,scheduleBadgeLabels:Rn,categoryFilter:hn,onCategoryFilterChange:gn,onSelectTemplate:kn})})]})})]})}),(0,S.jsx)(h,{open:en,onOpenChange:e=>{e||(tn(!1),nn(null))},children:(0,S.jsxs)(_e,{children:[(0,S.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,S.jsxs)(he,{className:p(`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,S.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,S.jsx)(g,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:q?.name?.trim()||q?.id||`—`}),(0,S.jsx)(pe,{asChild:!0,children:(0,S.jsx)(f,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":n.close,children:(0,S.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}),(0,S.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:on?(0,S.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,S.jsx)(s,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):q?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleLabel}),(0,S.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:(0,S.jsx)(`code`,{children:q.schedule})})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.messageLabel}),(0,S.jsx)(`dd`,{className:`mt-1 min-w-0 break-words text-fg`,children:(0,S.jsx)(le,{content:Ee(q),compact:!0,className:`text-sm`})})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.mode}),(0,S.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.sessionTarget===`isolated`?n.modeAgentOption:n.modeDirectOption})]}),q.sessionTarget===`isolated`?(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.agentProfile}),(0,S.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,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.workingDirectoryLabel}),(0,S.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:q.workingDirectory?.trim()?q.workingDirectory.trim():c.workingDirectory.notSet})]}):null,q.delivery?.channel===`local`||q.sessionTarget===`isolated`&&!q.delivery?.to?(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.deliveryTarget}),(0,S.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.delivery?.channel===`local`?n.deliveryTargetLocalChannel:n.deliveryLocalOnly})]}):q.delivery?.to?(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.deliveryTarget}),(0,S.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,S.jsx)(`code`,{className:`text-xs`,children:q.delivery?.channel??``}),` → `,Ne(q,n.channelLocal)]})]}):null,(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.status}),(0,S.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.enabled?n.enabled:n.disabled})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.nextRun}),(0,S.jsx)(`dd`,{className:`mt-1 text-fg`,children:q.next_run?Ae(q.next_run,n.timeLabels):`—`})]})]}),(0,S.jsx)(`h3`,{className:`mt-6 text-sm font-semibold text-fg`,children:n.detailRunHistory}),rn.length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:n.noRunsYet}):(0,S.jsx)(`div`,{className:`mt-2 overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,S.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.colStarted}),(0,S.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.status}),(0,S.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.colDuration}),(0,S.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:n.colDetail}),(0,S.jsx)(`th`,{className:`py-1.5 font-medium`,children:n.colChat})]})}),(0,S.jsx)(`tbody`,{children:rn.map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-edge/60`,children:[(0,S.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-2 text-fg`,children:(0,S.jsx)(`time`,{dateTime:e.startedAt,children:Le(e.startedAt)})}),(0,S.jsx)(`td`,{className:`py-1.5 pr-2`,children:(0,S.jsx)(`span`,{className:p(`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:Re(e.status,Fn)})}),(0,S.jsx)(`td`,{className:`py-1.5 pr-2 text-fg-muted`,children:Ie(e.duration)}),(0,S.jsx)(`td`,{className:`max-w-[8rem] truncate py-1.5 pr-2 text-fg-muted`,title:e.summary||e.error||``,children:Te(e.summary||e.error,120)}),(0,S.jsx)(`td`,{className:`whitespace-nowrap py-1.5`,children:e.sessionKey?.trim()?(0,S.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>dt(e.sessionKey),children:n.openChat}):(0,S.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})})]}):null})]})]})}),(0,S.jsx)(h,{open:cn,onOpenChange:ln,children:(0,S.jsxs)(_e,{children:[(0,S.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),(0,S.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,S.jsxs)(he,{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,S.jsx)(g,{className:`text-base font-semibold text-fg`,children:J===`delete`?n.delete:n.runNow}),(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:J===`delete`?n.confirmDelete:n.confirmRun}),(0,S.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,S.jsx)(f,{type:`button`,variant:`secondary`,onClick:()=>{ln(!1),fn(null),un(null)},children:n.cancel}),(0,S.jsx)(f,{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,S.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{_t as CronPage};
2
- //# sourceMappingURL=cron-page-DsVZzPqv.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{B as r,Bn as i,Bt as a,Dn as o,Er as s,H as ee,Kt as c,Mt as te,N as ne,Nt as re,Ot as ie,Rt as ae,V as oe,Vt as l,Wn as se,Wt as u,at as d,dn as ce,dr as le,dt as f,en as ue,ft as p,ln as de,lt as m,ot as h,rr as fe,rt as g,st as pe,ut as _,z as me}from"./index-DG8WvMbu.js";var v=e(t(),1);function he(e){let t=new URLSearchParams;if(!e)return``;e.level?.length&&t.set(`level`,e.level.join(`,`)),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.q&&t.set(`q`,e.q),e.module&&t.set(`module`,e.module),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return n?`?${n}`:``}async function y(e){return d(g(`/api/logs${he(e)}`))}async function b(){return(await d(g(`/api/logs/files`))).files??[]}async function ge(){return(await d(g(`/api/logs/modules`))).modules??[]}async function x(){return{byLevel:(await d(g(`/api/logs/stats`))).byLevel??{}}}async function _e(){return(await d(g(`/api/logs/dir`))).dir??``}var S=[`trace`,`debug`,`info`,`warn`,`error`,`fatal`],C=n(),w=50,ve=5e3,ye=new Set(S),be=[`error`,`fatal`],xe=[`warn`,`error`,`fatal`],T=[`info`,`warn`,`error`,`fatal`];function Se(e){if(!e)return new Set;let t=new Set;for(let n of e.split(`,`)){let e=n.trim();ye.has(e)&&t.add(e)}return t}function Ce(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function E(e,t){return e.size===t.length?t.every(t=>e.has(t)):!1}function D(e){return e.size===0?`all`:E(e,be)?`errors`:E(e,xe)?`warnPlus`:E(e,T)?`infoPlus`:e.size===S.length&&S.every(t=>e.has(t))?`verbose`:`custom`}function we(e){let t=D(e);return t===`custom`?`other`:t}function Te(e){switch(e){case`all`:return new Set;case`errors`:return new Set(be);case`warnPlus`:return new Set(xe);case`infoPlus`:return new Set(T);case`verbose`:return new Set(S)}}function Ee(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function O(e){return String(e.module||e.prefix||e.service||e.extension||`—`)}function De(e){if(typeof e.message==`string`&&e.message)return e.message;try{return JSON.stringify(e)}catch{return``}}function Oe(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{return e}}function ke(e){try{return new Date(e).toLocaleString()}catch{return e}}function Ae(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function je(e){let t=e.trim();return t.length<=10?t:`${t.slice(0,8)}…`}function Me(e){return String(e).toLowerCase()}function Ne(e,t){let n=[];for(let r of S){let i=e[r]??0;i>0&&n.push(`${t[r]} ${i}`)}return n.join(` · `)}function k(){let e=a(te(e=>e.language)).logs,t=!!ie(e=>e.token),[n,d]=s(),g=n.get(`q`)??``,he=Se(n.get(`level`)),ye=n.get(`module`)??``,be=n.get(`from`)??``,xe=n.get(`to`)??``,T=n.get(`live`)===`1`,[E,D]=(0,v.useState)([]),[k,A]=(0,v.useState)(!1),[Fe,j]=(0,v.useState)(null),[Ie,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(g),[F,I]=(0,v.useState)(g.trim()),[L,R]=(0,v.useState)(he),[z,B]=(0,v.useState)(ye),[V,H]=(0,v.useState)(be),[U,W]=(0,v.useState)(xe),[Le,Re]=(0,v.useState)([]),[G,K]=(0,v.useState)([]),[q,J]=(0,v.useState)(null),[Y,ze]=(0,v.useState)(null),[Be,Ve]=(0,v.useState)(!1),[He,X]=(0,v.useState)(!1),[Ue,We]=(0,v.useState)(null),[Z,Ge]=(0,v.useState)(T),[Q,Ke]=(0,v.useState)(null),qe=(0,v.useMemo)(()=>we(L),[L]),Je=F.length>0||L.size>0||!!z||!!V||!!U,Ye=+(F.length>0)+ +(L.size>0)+ +!!z+(V||U?1:0);(0,v.useEffect)(()=>{let e=setTimeout(()=>I(N.trim()),300);return()=>clearTimeout(e)},[N]),(0,v.useEffect)(()=>{let e=n.get(`q`)??``,t=n.get(`module`)??``,r=n.get(`from`)??``,i=n.get(`to`)??``,a=n.get(`live`)===`1`,o=Se(n.get(`level`)),s=e.trim();P(t=>t===e?t:e),I(e=>e===s?e:s),R(e=>Ce(o,e)?e:o),B(e=>e===t?e:t),H(e=>e===r?e:r),W(e=>e===i?e:i),Ge(e=>e===a?e:a)},[n]),(0,v.useEffect)(()=>{let e=new URLSearchParams(n),t=F.trim();t?e.set(`q`,t):e.delete(`q`),L.size>0?e.set(`level`,Array.from(L).sort().join(`,`)):e.delete(`level`),z?e.set(`module`,z):e.delete(`module`),V?e.set(`from`,V):e.delete(`from`),U?e.set(`to`,U):e.delete(`to`),Z?e.set(`live`,`1`):e.delete(`live`),e.toString()!==n.toString()&&d(e,{replace:!0})},[Z,V,U,F,z,n,L,d]);let $=(0,v.useMemo)(()=>({q:F||void 0,level:L.size>0?Array.from(L):void 0,module:z||void 0,from:V||void 0,to:U||void 0,limit:w}),[F,L,z,V,U]);(0,v.useEffect)(()=>{if(!t)return;let n=!1;return(async()=>{A(!0),j(null),D([]);try{let e=await y({...$,offset:0});if(n)return;D(e.logs),M(e.logs.length===w)}catch(t){n||(j(t instanceof Error?t.message:e.loadError),D([]),M(!1))}finally{n||A(!1)}})(),()=>{n=!0}},[t,$,e.loadError]),(0,v.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{try{let[t,n,r]=await Promise.all([ge(),x(),b()]);e||(Re(t),J(n),K(r))}catch{}})(),()=>{e=!0}},[t]),(0,v.useEffect)(()=>{if(!t||!Be)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([b(),_e()]);e||(K(t),We(n))}catch{e||K([])}})(),()=>{e=!0}},[t,Be]),(0,v.useEffect)(()=>{if(!Z||!t)return;let e=window.setInterval(()=>{(async()=>{try{let e=await y({...$,offset:0});D(e.logs),M(e.logs.length===w),J(await x())}catch{}})()},ve);return()=>clearInterval(e)},[Z,t,$]),(0,v.useEffect)(()=>{if(!Q)return;let e=window.setTimeout(()=>Ke(null),2e3);return()=>clearTimeout(e)},[Q]);let Xe=()=>{P(``),I(``),R(new Set),B(``),H(``),W(``)},Ze=e=>{if(e===`other`){X(!0);return}R(Te(e))},Qe=e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},$e=()=>{k||!Ie||(async()=>{A(!0),j(null);try{let e=await y({...$,offset:E.length});D(t=>[...t,...e.logs]),M(e.logs.length===w)}catch(t){j(t instanceof Error?t.message:e.loadError)}finally{A(!1)}})()},et=()=>{(async()=>{A(!0),j(null);try{let e=await y({...$,offset:0});D(e.logs),M(e.logs.length===w);let[t,n]=await Promise.all([x(),b()]);J(t),K(n)}catch(t){j(t instanceof Error?t.message:e.loadError)}finally{A(!1)}})()},tt=q?Ne(q.byLevel??{},e.levelNames):``;return t?(0,C.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,C.jsxs)(`header`,{className:`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,C.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base dark:border-edge`,"aria-hidden":!0,children:(0,C.jsx)(ue,{className:`size-5 text-fg-muted`,strokeWidth:1.75})}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:e.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-sm leading-relaxed text-fg-muted`,children:e.subtitle})]})]}),(0,C.jsxs)(`div`,{className:`flex w-full shrink-0 flex-col gap-2 sm:w-auto sm:max-w-md sm:flex-row sm:items-center sm:justify-end`,children:[(0,C.jsx)(`div`,{className:`w-full sm:w-48`,children:(0,C.jsx)(ne,{"aria-label":e.refreshModeAria,value:Z?`live`:`paused`,onChange:e=>Ge(e===`live`),options:[{value:`paused`,label:e.refreshManual},{value:`live`,label:e.refreshLive}],buttonClassName:`h-8`})}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1 self-end sm:self-center`,children:[(0,C.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,title:e.logFiles,"aria-label":e.logFiles,onClick:()=>Ve(!0),children:[(0,C.jsx)(i,{className:`size-4`,strokeWidth:1.75}),G.length>0?(0,C.jsx)(`span`,{className:`rounded-full bg-surface-hover px-1.5 text-xs text-fg-muted`,children:G.length}):null]}),(0,C.jsx)(l,{type:`button`,variant:`ghost`,className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,title:e.refresh,"aria-label":e.refresh,onClick:et,children:(0,C.jsx)(ce,{className:u(`size-4 transition-transform duration-150 ease-out motion-reduce:transition-none`,k&&`animate-spin motion-reduce:animate-none`),strokeWidth:1.75})})]})]})]}),Fe?(0,C.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg dark:border-edge`,role:`alert`,children:Fe}):null,q&&tt?(0,C.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,C.jsxs)(oe,{children:[(0,C.jsx)(ee,{asChild:!0,children:(0,C.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded-lg border border-transparent px-1 py-0.5 text-left text-xs leading-5 text-fg-subtle transition-colors duration-150 ease-out hover:border-edge-subtle hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel dark:hover:border-edge`,children:[(0,C.jsx)(`span`,{className:`font-medium text-fg-muted`,children:e.statsRegion}),(0,C.jsx)(`span`,{className:`mx-1.5 text-fg-subtle`,children:`·`}),(0,C.jsx)(`span`,{className:`tabular-nums`,children:tt})]})}),(0,C.jsx)(r,{children:(0,C.jsxs)(me,{side:`bottom`,align:`start`,sideOffset:6,className:u(`z-50 w-[min(calc(100vw-2rem),20rem)] rounded-xl border border-edge bg-surface-panel p-3 shadow-popover outline-none`,`dark:border-edge`),children:[(0,C.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:e.statsDetailTitle}),(0,C.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.statsHint}),(0,C.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1.5`,role:`list`,children:S.map(t=>{let n=q.byLevel?.[t]??0;return n===0?null:(0,C.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs dark:border-edge`,children:[(0,C.jsx)(`span`,{className:`font-medium capitalize text-fg`,children:e.levelNames[t]}),(0,C.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:n})]},t)})})]})})]})}):null,(0,C.jsxs)(`section`,{className:`flex flex-col gap-3`,"aria-label":e.filters,children:[(0,C.jsx)(`div`,{className:`overflow-x-auto pb-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:(0,C.jsx)(`div`,{className:`min-w-[min(100%,36rem)]`,children:(0,C.jsx)(ne,{"aria-label":e.levelPresetAria,value:qe,onChange:Ze,options:[{value:`all`,label:e.presetAll},{value:`errors`,label:e.presetErrors},{value:`warnPlus`,label:e.presetWarnPlus},{value:`infoPlus`,label:e.presetInfoPlus},{value:`verbose`,label:e.presetVerbose},{value:`other`,label:e.presetOther}],buttonClassName:`h-8 px-1.5 text-[11px] sm:px-2 sm:text-xs`})})}),(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,C.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:min-w-[12rem]`,children:[(0,C.jsx)(`span`,{className:`sr-only`,children:e.searchPlaceholder}),(0,C.jsx)(de,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,C.jsx)(`input`,{type:`search`,value:N,onChange:e=>P(e.target.value),placeholder:e.searchPlaceholder,autoComplete:`off`,spellCheck:!1,className:u(`h-10 w-full rounded-md border border-edge bg-surface-panel py-0 pl-10 pr-3 text-sm leading-5 text-fg placeholder:text-fg-subtle dark:border-edge`,re)})]}),(0,C.jsxs)(`select`,{id:`log-module`,value:z,onChange:e=>B(e.target.value),"aria-label":e.module,title:e.module,className:u(ae,`h-10 w-full min-w-0 rounded-md py-0 sm:w-[min(100%,14rem)] sm:shrink-0`),children:[(0,C.jsx)(`option`,{value:``,children:e.allModules}),Le.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))]}),(0,C.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-2`,children:[(0,C.jsxs)(l,{type:`button`,variant:`secondary`,className:`h-10 min-h-[44px] gap-2 rounded-md sm:min-h-10`,onClick:()=>X(!0),children:[(0,C.jsx)(o,{className:`size-4`,strokeWidth:1.75}),e.filtersMore,Ye>0?(0,C.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 text-xs tabular-nums text-fg-muted`,children:Ye}):null]}),Je?(0,C.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-10 min-h-[44px] gap-1 sm:min-h-10`,onClick:Xe,children:[(0,C.jsx)(c,{className:`size-4`,strokeWidth:1.75}),e.clear]}):null]})]}),Z?(0,C.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:e.liveHint}):null]}),k&&E.length===0?(0,C.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-panel dark:divide-edge dark:border-edge`,"aria-busy":`true`,children:Array.from({length:8}).map((e,t)=>(0,C.jsxs)(`div`,{className:`flex gap-3 px-3 py-2.5`,children:[(0,C.jsx)(`div`,{className:`h-4 w-16 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,C.jsx)(`div`,{className:`h-4 w-12 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,C.jsx)(`div`,{className:`h-4 w-20 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,C.jsx)(`div`,{className:`h-4 min-w-0 flex-1 bg-surface-hover motion-reduce:animate-none animate-pulse`})]},t))}):null,!k&&E.length===0?(0,C.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-xl border border-edge-subtle bg-surface-base py-16 text-center dark:border-edge`,children:[(0,C.jsx)(se,{className:`size-12 text-fg-subtle`,strokeWidth:1.5,"aria-hidden":!0}),(0,C.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.noLogs}),(0,C.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:e.noLogsDescription}),(0,C.jsxs)(l,{type:`button`,variant:`secondary`,className:`mt-4 gap-2`,onClick:et,children:[(0,C.jsx)(ce,{className:`size-4`,strokeWidth:1.75}),e.refresh]})]}):null,E.length>0?(0,C.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,C.jsxs)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:[Ee(e.showingCount,{count:String(E.length)}),Ie?(0,C.jsxs)(`span`,{className:`text-fg-subtle`,children:[` · `,e.moreAvailable]}):null]}),(0,C.jsx)(`ul`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-panel font-mono text-sm leading-6 dark:divide-edge dark:border-edge`,role:`list`,children:E.map((t,n)=>{let r=t.level??`info`,i=typeof t.requestId==`string`?t.requestId.trim():``;return(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>ze(t),className:u(`flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-colors duration-150 ease-out`,`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`),children:[(0,C.jsx)(`span`,{className:`w-[5.25rem] shrink-0 tabular-nums text-fg-subtle`,children:Oe(t.timestamp)}),(0,C.jsx)(`span`,{className:`w-[4.5rem] shrink-0 truncate text-fg-muted`,title:r,children:Me(r)}),(0,C.jsx)(`span`,{className:`w-[4.5rem] shrink-0 truncate text-fg-subtle sm:w-[5.25rem]`,title:i?`${e.requestId}: ${i}`:void 0,children:i?je(i):`—`}),(0,C.jsx)(`span`,{className:`hidden max-w-[7rem] shrink-0 truncate text-fg-muted lg:inline`,title:O(t),children:O(t)}),(0,C.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg`,children:De(t)})]})},`${t.timestamp}-${n}`)})}),Ie?(0,C.jsx)(`div`,{className:`flex justify-center pt-1`,children:(0,C.jsxs)(l,{type:`button`,variant:`secondary`,className:`gap-2`,disabled:k,onClick:$e,children:[k?(0,C.jsx)(ce,{className:`size-4 animate-spin motion-reduce:animate-none`,strokeWidth:1.75}):(0,C.jsx)(le,{className:`size-4`,strokeWidth:1.75}),e.loadMore]})}):null]}):null,(0,C.jsx)(f,{open:He,onOpenChange:X,children:(0,C.jsxs)(_,{children:[(0,C.jsx)(m,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim`}),(0,C.jsxs)(pe,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex max-h-[min(32rem,90vh)] w-[min(100%-2rem,22rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,`dark:border-edge`),"aria-describedby":`log-filters-desc`,children:[(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[(0,C.jsx)(p,{className:`text-base font-semibold tracking-tight text-fg`,children:e.filtersDialogTitle}),(0,C.jsx)(h,{asChild:!0,children:(0,C.jsx)(l,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":e.close,children:(0,C.jsx)(c,{className:`size-5`,strokeWidth:1.75})})})]}),(0,C.jsx)(`div`,{id:`log-filters-desc`,className:`sr-only`,children:e.filtersDialogDesc}),(0,C.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:[(0,C.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:e.timeRange}),(0,C.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`log-from-d`,className:`mb-1 block text-xs text-fg-muted`,children:e.from}),(0,C.jsx)(`input`,{id:`log-from-d`,type:`datetime-local`,value:V,onChange:e=>H(e.target.value),className:`w-full rounded-xl border border-edge bg-surface-base px-2 py-2 text-sm text-fg dark:border-edge`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`log-to-d`,className:`mb-1 block text-xs text-fg-muted`,children:e.to}),(0,C.jsx)(`input`,{id:`log-to-d`,type:`datetime-local`,value:U,onChange:e=>W(e.target.value),className:`w-full rounded-xl border border-edge bg-surface-base px-2 py-2 text-sm text-fg dark:border-edge`})]})]}),(0,C.jsx)(`p`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:e.levelCustom}),(0,C.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:e.levelCustomHint}),(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,role:`group`,"aria-label":e.level,children:S.map(t=>(0,C.jsx)(`button`,{type:`button`,className:u(`rounded-full border px-3 py-1.5 text-xs font-medium capitalize transition-[color,background-color,border-color] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,L.has(t)?`border-edge bg-surface-active text-fg dark:border-edge`:`border-edge-subtle bg-surface-base text-fg-muted hover:bg-surface-hover dark:border-edge`),onClick:()=>Qe(t),children:e.levelNames[t]},t))})]}),(0,C.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,C.jsx)(l,{type:`button`,className:`w-full rounded-xl`,onClick:()=>X(!1),children:e.filtersDone})})]})]})}),(0,C.jsx)(f,{open:Y!==null,onOpenChange:e=>!e&&ze(null),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(m,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim`}),(0,C.jsxs)(pe,{className:u(`xopc-drawer-right fixed right-0 top-0 z-50 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,C.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[(0,C.jsx)(p,{className:`text-base font-semibold tracking-tight text-fg`,children:e.details}),(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[Y?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{let e=typeof Y.message==`string`?Y.message:``;navigator.clipboard.writeText(e).then(()=>Ke(`message`))},children:[(0,C.jsx)(fe,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:Q===`message`?e.copied:e.copyMessage})]}),(0,C.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{navigator.clipboard.writeText(JSON.stringify(Y,null,2)).then(()=>Ke(`json`))},children:[(0,C.jsx)(fe,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:Q===`json`?e.copied:e.copyJson})]})]}):null,(0,C.jsx)(h,{asChild:!0,children:(0,C.jsx)(l,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":e.close,children:(0,C.jsx)(c,{className:`size-5`,strokeWidth:1.75})})})]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4 font-mono text-sm leading-relaxed`,children:Y?(0,C.jsx)(Pe,{log:Y,labels:{time:e.time,level:e.level,module:e.module,message:e.message,metadata:e.metadata,requestId:e.requestId,sessionId:e.sessionId}}):null})]})]})}),(0,C.jsx)(f,{open:Be,onOpenChange:Ve,children:(0,C.jsxs)(_,{children:[(0,C.jsx)(m,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim`}),(0,C.jsxs)(pe,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex max-h-[min(32rem,85vh)] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,`dark:border-edge`),children:[(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[(0,C.jsxs)(p,{className:`flex items-center gap-2 text-base font-semibold tracking-tight text-fg`,children:[(0,C.jsx)(i,{className:`size-4 text-fg-muted`,strokeWidth:1.75}),e.logFiles]}),(0,C.jsx)(h,{asChild:!0,children:(0,C.jsx)(l,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":e.close,children:(0,C.jsx)(c,{className:`size-5`,strokeWidth:1.75})})})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:G.length===0?(0,C.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.filesEmpty}):(0,C.jsx)(`ul`,{className:`flex flex-col gap-2`,role:`list`,children:G.map(e=>(0,C.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 dark:border-edge`,children:[(0,C.jsx)(`span`,{className:`break-all font-mono text-xs text-fg`,children:e.name}),(0,C.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-fg-subtle`,children:[(0,C.jsx)(`span`,{children:Ae(e.size)}),(0,C.jsx)(`span`,{children:ke(e.modified)})]})]},e.name))})}),Ue?(0,C.jsxs)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-2 text-xs text-fg-subtle dark:border-edge`,children:[(0,C.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[e.logDir,`: `]}),(0,C.jsx)(`code`,{className:`break-all text-fg-subtle`,children:Ue})]}):null]})]})})]}):(0,C.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,C.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-edge-subtle bg-surface-base p-6 dark:border-edge`,children:[(0,C.jsx)(ue,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h1`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.title}),(0,C.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:e.needToken})]})]})})}function Pe({log:e,labels:t}){let n=e.level??`info`,r=typeof e.requestId==`string`?e.requestId:``,i=typeof e.sessionId==`string`?e.sessionId:``;return(0,C.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:t.message}),(0,C.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,children:e.message||`—`})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-2 text-xs`,children:[(0,C.jsx)(`span`,{className:`font-sans text-fg-muted`,children:t.time}),(0,C.jsx)(`code`,{className:`break-all text-fg`,children:e.timestamp}),(0,C.jsx)(`span`,{className:`font-sans text-fg-muted`,children:t.level}),(0,C.jsx)(`span`,{className:`text-fg`,children:Me(n)}),(0,C.jsx)(`span`,{className:`font-sans text-fg-muted`,children:t.module}),(0,C.jsx)(`code`,{className:`break-all text-fg`,children:O(e)}),r?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`font-sans text-fg-muted`,children:t.requestId}),(0,C.jsx)(`code`,{className:`break-all text-fg`,children:r})]}):null,i?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`font-sans text-fg-muted`,children:t.sessionId}),(0,C.jsx)(`code`,{className:`break-all text-fg`,children:i})]}):null]}),e.meta&&Object.keys(e.meta).length>0?(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:t.metadata}),(0,C.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,children:JSON.stringify(e.meta,null,2)})]}):null]})}export{k as LogsPage};
2
- //# sourceMappingURL=logs-page-ChJ0nsPh.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{A as r,Bt as i,D as a,E as o,Er as s,F as c,Gt as l,I as ee,Kt as u,M as te,Mn as ne,Mt as re,Nn as ie,O as d,Ot as ae,Qt as f,Sn as p,T as oe,Vn as se,Vt as m,Wt as h,Zn as g,_n as _,dt as ce,ft as v,ir as le,j as ue,jn as de,k as y,ln as fe,lt as pe,ot as me,st as he,ut as ge,v as b,vn as _e,vr as ve,w as ye,y as x,yr as S}from"./index-DG8WvMbu.js";var C=e(t(),1),w=n();function T(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function E(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function be({session:e,variant:t,labels:n,onOpen:r,onAction:i}){let a=e.name?.trim()||n.unnamedSession,o=!!e.name?.trim(),s=e.status===`archived`,c=e.status===`pinned`;return(0,w.jsxs)(`div`,{role:`button`,tabIndex:0,className:h(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,t===`list`&&`sm:flex-row sm:items-center sm:gap-4`),onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},children:[(0,w.jsxs)(`div`,{className:h(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,t===`list`&&`sm:py-3`),children:[(0,w.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,w.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:e.sourceChannel})}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[c?(0,w.jsx)(_,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,w.jsx)(`span`,{children:T(e.updatedAt)})]})]}),(0,w.jsxs)(`div`,{className:h(`min-w-0 flex-1 px-3 py-2`,t===`list`&&`sm:py-3`),children:[(0,w.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:a,children:a}),o?(0,w.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:e.key,children:e.key}):null,(0,w.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,w.jsx)(p,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),e.messageCount]}),(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,w.jsx)(l,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),E(e.estimatedTokens)]})]}),e.tags.length>0?(0,w.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[e.tags.slice(0,3).map(e=>(0,w.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)),e.tags.length>3?(0,w.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,e.tags.length-3]}):null]}):null]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 px-2 py-2 dark:border-edge-subtle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,w.jsx)(`button`,{type:`button`,className:b,title:n.continueChat,"aria-label":n.continueChat,onClick:()=>i(`continue`),children:(0,w.jsx)(p,{className:`size-4`,strokeWidth:1.75})}),s?(0,w.jsx)(`button`,{type:`button`,className:b,title:n.unarchive,"aria-label":n.unarchive,onClick:()=>i(`unarchive`),children:(0,w.jsx)(S,{className:`size-4`,strokeWidth:1.75})}):(0,w.jsx)(`button`,{type:`button`,className:b,title:n.archive,"aria-label":n.archive,onClick:()=>i(`archive`),children:(0,w.jsx)(ve,{className:`size-4`,strokeWidth:1.75})}),c?(0,w.jsx)(`button`,{type:`button`,className:b,title:n.unpin,"aria-label":n.unpin,onClick:()=>i(`unpin`),children:(0,w.jsx)(_e,{className:`size-4`,strokeWidth:1.75})}):(0,w.jsx)(`button`,{type:`button`,className:b,title:n.pin,"aria-label":n.pin,onClick:()=>i(`pin`),children:(0,w.jsx)(_,{className:`size-4`,strokeWidth:1.75})}),(0,w.jsx)(`button`,{type:`button`,className:b,title:n.export,"aria-label":n.export,onClick:()=>i(`export`),children:(0,w.jsx)(g,{className:`size-4`,strokeWidth:1.75})}),(0,w.jsx)(`button`,{type:`button`,className:h(b,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),title:n.delete,"aria-label":n.delete,onClick:()=>i(`delete`),children:(0,w.jsx)(f,{className:`size-4`,strokeWidth:1.75})})]})]})}function D(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function xe({open:e,loading:t,session:n,labels:r,onClose:i,onArchive:a,onUnarchive:o,onPin:s,onUnpin:c,onExport:l,onDelete:ee}){let te=n?.status===`archived`,ne=n?.status===`pinned`;return(0,w.jsx)(ce,{open:e,onOpenChange:e=>!e&&i(),children:(0,w.jsxs)(ge,{children:[(0,w.jsx)(pe,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim`}),(0,w.jsxs)(he,{className:h(`xopc-drawer-right fixed right-0 top-0 z-50 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,w.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[(0,w.jsx)(v,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:n?.name?.trim()||r.unnamedSession}),(0,w.jsx)(me,{asChild:!0,children:(0,w.jsx)(m,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-label":r.close,children:(0,w.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:t?(0,w.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.detailLoading}):n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,w.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:n.key})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,w.jsxs)(`span`,{children:[n.messageCount,` msgs · `,n.estimatedTokens,` tok`]})})]}),(0,w.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:r.detailMessages}),(0,w.jsx)(`ul`,{className:`space-y-3`,children:n.messages.map((e,t)=>(0,w.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,w.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,w.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:D(e.content)})]},`${e.timestamp??t}-${t}`))})]}):null}),(0,w.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:r.detailExport}),te?(0,w.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:o,children:r.unarchive}):(0,w.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:a,children:r.archive}),ne?(0,w.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:c,children:r.unpin}):(0,w.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:s,children:r.pin}),(0,w.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:ee,children:r.delete})]})})]})]})})}var O=20;function k(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var A=new Set([`all`,`active`,`pinned`,`archived`]),j=new Set([`grid`,`list`]);function M(){let e=i(re(e=>e.language)),t=e.sessions,n=!!ae(e=>e.token),[l,u]=s(),f=l.get(`q`)??``,p=l.get(`status`),g=l.get(`view`),me=l.get(`channel`)??``,b=A.has(p)?p:`all`,_e=j.has(g)?g:`grid`,[S,T]=(0,C.useState)(f),[E,D]=(0,C.useState)(f.trim()),[M,N]=(0,C.useState)(b),[P,F]=(0,C.useState)(_e),[I,L]=(0,C.useState)(me.trim()),[R,z]=(0,C.useState)([]),[B,V]=(0,C.useState)(!1),[Se,H]=(0,C.useState)(null),[U,Ce]=(0,C.useState)(!1),[W,G]=(0,C.useState)(null),[we,K]=(0,C.useState)(!1),[Te,Ee]=(0,C.useState)(!1),[q,J]=(0,C.useState)(null),[De,Y]=(0,C.useState)(!1),[X,Z]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=setTimeout(()=>D(S.trim()),300);return()=>clearTimeout(e)},[S]),(0,C.useEffect)(()=>{let e=l.get(`q`)??``,t=l.get(`status`),n=l.get(`view`),r=(l.get(`channel`)??``).trim(),i=A.has(t)?t:`all`,a=j.has(n)?n:`grid`,o=e.trim();T(t=>t===e?t:e),D(e=>e===o?e:o),N(e=>e===i?e:i),F(e=>e===a?e:a),L(e=>e===r?e:r)},[l]),(0,C.useEffect)(()=>{let e=new URLSearchParams(l),t=E.trim();t?e.set(`q`,t):e.delete(`q`),M===`all`?e.delete(`status`):e.set(`status`,M),P===`grid`?e.delete(`view`):e.set(`view`,P),I?e.set(`channel`,I):e.delete(`channel`),e.toString()!==l.toString()&&u(e,{replace:!0})},[E,l,u,M,P,I]),(0,C.useEffect)(()=>{if(!n)return;let e=!1;return(async()=>{V(!0),H(null);try{let t=await y({limit:O,offset:0,...E?{search:E}:{},...M===`all`?{}:{status:M},...I?{channel:I}:{}});if(e)return;z(t.items),Ce(t.hasMore)}catch(n){e||H(n instanceof Error?n.message:t.loadError)}finally{e||V(!1)}})(),()=>{e=!0}},[n,E,M,t.loadError]),(0,C.useEffect)(()=>{n&&d().then(G).catch(()=>{})},[n]),(0,C.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||(z(e=>e.map(e=>e.key===t.key?{...e,name:t.name}:e)),J(e=>e&&e.key===t.key?{...e,name:t.name}:e))};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[n]);let Oe=(0,C.useCallback)(async()=>{if(!(!n||B||!U)){V(!0),H(null);try{let e=await y({limit:O,offset:R.length,...E?{search:E}:{},...M===`all`?{}:{status:M},...I?{channel:I}:{}});z(t=>[...t,...e.items]),Ce(e.hasMore)}catch(e){H(e instanceof Error?e.message:t.loadError)}finally{V(!1)}}},[n,B,U,R.length,E,M,I,t.loadError]),Q=(0,C.useCallback)((e,t)=>{z(n=>n.map(n=>n.key===e?{...n,status:t}:n)),J(n=>n&&n.key===e?{...n,status:t}:n)},[]),ke=(0,C.useCallback)(async e=>{K(!0),Ee(!0),J(null);try{J(await a(e))}catch{K(!1)}finally{Ee(!1)}},[]),Ae=e=>{ke(e)},$=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){Z(e),Y(!0);return}try{switch(t){case`archive`:await ye(e),Q(e,`archived`);break;case`unarchive`:await ue(e),Q(e,`active`);break;case`pin`:await r(e),Q(e,`pinned`);break;case`unpin`:await te(e),Q(e,`active`);break;case`export`:{let t=await o(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}d().then(G).catch(()=>{})}catch{}},je=async e=>{try{await oe(e),z(t=>t.filter(t=>t.key!==e)),J(t=>t?.key===e?null:t),q?.key===e&&K(!1),d().then(G).catch(()=>{})}catch{}},Me={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},Ne={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Pe=[{key:`all`,label:t.filterAll,icon:ie},{key:`active`,label:t.filterActive,icon:le},{key:`pinned`,label:t.filterPinned,icon:_},{key:`archived`,label:t.filterArchived,icon:ve}],Fe=(()=>{let e=Object.entries(W?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e);for(let t of[`telegram`,`weixin`,`feishu`])e.includes(t)||e.push(t);return e.slice(0,8)})();return n?(0,w.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto overflow-x-hidden bg-surface-panel`,children:[(0,w.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-2xl flex-col gap-4 px-4 py-6 sm:px-6 lg:max-w-app-main lg:px-8`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold tracking-tight text-fg`,children:[(0,w.jsx)(se,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t.title]}),(0,w.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors sm:max-w-md dark:bg-surface-hover/40`,children:[(0,w.jsx)(fe,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,w.jsx)(`input`,{type:`search`,value:S,onChange:e=>T(e.target.value),placeholder:t.searchPlaceholder,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Pe.map(({key:e,label:t,icon:n})=>(0,w.jsxs)(`button`,{type:`button`,"aria-pressed":M===e,onClick:()=>N(e),className:h(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,x.transition,x.focusRingPanel,M===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,w.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,w.jsx)(`button`,{type:`button`,"aria-pressed":!I,onClick:()=>L(``),className:h(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,x.transition,x.focusRingPanel,I?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Fe.map(e=>(0,w.jsxs)(`button`,{type:`button`,"aria-pressed":I===e,onClick:()=>L(e),className:h(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,x.transition,x.focusRingPanel,I===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,W?.byChannel?.[e]==null?null:(0,w.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:W.byChannel[e]})]},e))]}),W?(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[W.totalSessions,t.totalSessions],[W.activeSessions,t.activeSessions],[W.pinnedSessions,t.pinnedSessions],[W.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,w.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-3 py-3 dark:bg-surface-hover/30`,children:[(0,w.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,w.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,Se?(0,w.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:Se}):null,(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:k(t.sessionCount,{count:R.length})}),(0,w.jsxs)(`div`,{className:ee,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,w.jsx)(m,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":P===`grid`,onClick:()=>F(`grid`),className:h(c,`size-7 p-0`,P===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`grid`&&`text-accent-fg`),children:(0,w.jsx)(ne,{className:`size-3.5`,strokeWidth:1.5})}),(0,w.jsx)(m,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":P===`list`,onClick:()=>F(`list`),className:h(c,`size-9 p-0`,P===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,P===`list`&&`text-accent-fg`),children:(0,w.jsx)(de,{className:`size-3.5`,strokeWidth:1.5})})]})]}),B&&R.length===0?(0,w.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,w.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):R.length===0?(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,w.jsx)(se,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,w.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,w.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,w.jsx)(m,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:h(`grid min-w-0 gap-3`,P===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),children:R.map(e=>(0,w.jsx)(be,{session:e,variant:P,labels:Me,onOpen:()=>Ae(e.key),onAction:t=>void $(e.key,t)},e.key))}),U?(0,w.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,w.jsx)(m,{type:`button`,variant:`secondary`,disabled:B,onClick:()=>void Oe(),children:t.loadMore})}):null]})]}),(0,w.jsx)(xe,{open:we,loading:Te,session:q,labels:Ne,onClose:()=>{K(!1),J(null)},onArchive:()=>q&&void $(q.key,`archive`),onUnarchive:()=>q&&void $(q.key,`unarchive`),onPin:()=>q&&void $(q.key,`pin`),onUnpin:()=>q&&void $(q.key,`unpin`),onExport:()=>q&&void $(q.key,`export`),onDelete:()=>q&&(Z(q.key),Y(!0))}),(0,w.jsx)(ce,{open:De,onOpenChange:Y,children:(0,w.jsxs)(ge,{children:[(0,w.jsx)(pe,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,w.jsxs)(he,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[(0,w.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,w.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:X?k(t.deleteSessionMessage,{name:R.find(e=>e.key===X)?.name?.trim()||e.chat.newSession}):``}),(0,w.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,w.jsx)(m,{type:`button`,variant:`secondary`,onClick:()=>Y(!1),children:t.cancel}),(0,w.jsx)(m,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{X&&je(X),Y(!1),Z(null)},children:t.delete})]})]})]})})]}):(0,w.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 py-16 text-center text-sm text-fg-muted sm:px-8 lg:max-w-app-main`,children:t.needToken})}export{M as SessionsPage};
2
- //# sourceMappingURL=sessions-page-Cle4fPla.js.map