botmux 3.1.1 → 3.2.0
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.
- package/dist/adapters/backend/sandbox.d.ts +23 -0
- package/dist/adapters/backend/sandbox.d.ts.map +1 -1
- package/dist/adapters/backend/sandbox.js +68 -1
- package/dist/adapters/backend/sandbox.js.map +1 -1
- package/dist/adapters/cli/read-isolation.d.ts +1 -1
- package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
- package/dist/adapters/cli/read-isolation.js +15 -7
- package/dist/adapters/cli/read-isolation.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +117 -25
- package/dist/cli.js.map +1 -1
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +11 -4
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts +1 -0
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +132 -0
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/maintenance.d.ts +23 -1
- package/dist/core/maintenance.d.ts.map +1 -1
- package/dist/core/maintenance.js +63 -25
- package/dist/core/maintenance.js.map +1 -1
- package/dist/core/plugins/cli-generation.d.ts.map +1 -1
- package/dist/core/plugins/cli-generation.js +7 -0
- package/dist/core/plugins/cli-generation.js.map +1 -1
- package/dist/core/plugins/convention-scanner.d.ts +3 -3
- package/dist/core/plugins/convention-scanner.d.ts.map +1 -1
- package/dist/core/plugins/convention-scanner.js.map +1 -1
- package/dist/core/plugins/install.d.ts.map +1 -1
- package/dist/core/plugins/install.js +84 -26
- package/dist/core/plugins/install.js.map +1 -1
- package/dist/core/plugins/mcp/environment.d.ts +12 -0
- package/dist/core/plugins/mcp/environment.d.ts.map +1 -0
- package/dist/core/plugins/mcp/environment.js +17 -0
- package/dist/core/plugins/mcp/environment.js.map +1 -0
- package/dist/core/plugins/mcp/gateway-installer.d.ts.map +1 -1
- package/dist/core/plugins/mcp/gateway-installer.js +9 -3
- package/dist/core/plugins/mcp/gateway-installer.js.map +1 -1
- package/dist/core/plugins/mcp/gateway.d.ts +13 -1
- package/dist/core/plugins/mcp/gateway.d.ts.map +1 -1
- package/dist/core/plugins/mcp/gateway.js +143 -23
- package/dist/core/plugins/mcp/gateway.js.map +1 -1
- package/dist/core/plugins/mcp/host.d.ts +18 -0
- package/dist/core/plugins/mcp/host.d.ts.map +1 -0
- package/dist/core/plugins/mcp/host.js +126 -0
- package/dist/core/plugins/mcp/host.js.map +1 -0
- package/dist/core/plugins/mcp/private-store.d.ts +15 -0
- package/dist/core/plugins/mcp/private-store.d.ts.map +1 -0
- package/dist/core/plugins/mcp/private-store.js +162 -0
- package/dist/core/plugins/mcp/private-store.js.map +1 -0
- package/dist/core/plugins/mcp/session-runtime.d.ts +25 -0
- package/dist/core/plugins/mcp/session-runtime.d.ts.map +1 -0
- package/dist/core/plugins/mcp/session-runtime.js +76 -0
- package/dist/core/plugins/mcp/session-runtime.js.map +1 -0
- package/dist/core/plugins/mcp/socket-auth.d.ts +9 -0
- package/dist/core/plugins/mcp/socket-auth.d.ts.map +1 -0
- package/dist/core/plugins/mcp/socket-auth.js +94 -0
- package/dist/core/plugins/mcp/socket-auth.js.map +1 -0
- package/dist/core/plugins/paths.d.ts +3 -0
- package/dist/core/plugins/paths.d.ts.map +1 -1
- package/dist/core/plugins/paths.js +9 -0
- package/dist/core/plugins/paths.js.map +1 -1
- package/dist/core/plugins/pm2.d.ts.map +1 -1
- package/dist/core/plugins/pm2.js +3 -1
- package/dist/core/plugins/pm2.js.map +1 -1
- package/dist/core/plugins/runtime.d.ts +2 -0
- package/dist/core/plugins/runtime.d.ts.map +1 -1
- package/dist/core/plugins/runtime.js.map +1 -1
- package/dist/core/plugins/service-manager.d.ts +22 -0
- package/dist/core/plugins/service-manager.d.ts.map +1 -1
- package/dist/core/plugins/service-manager.js +189 -52
- package/dist/core/plugins/service-manager.js.map +1 -1
- package/dist/core/plugins/types.d.ts +15 -1
- package/dist/core/plugins/types.d.ts.map +1 -1
- package/dist/core/restart-report.d.ts +1 -1
- package/dist/core/restart-report.d.ts.map +1 -1
- package/dist/core/restart-report.js +5 -3
- package/dist/core/restart-report.js.map +1 -1
- package/dist/core/scheduler.d.ts +47 -0
- package/dist/core/scheduler.d.ts.map +1 -1
- package/dist/core/scheduler.js +117 -0
- package/dist/core/scheduler.js.map +1 -1
- package/dist/core/session-manager.d.ts +7 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +130 -33
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/silent-schedule-turns.d.ts +5 -0
- package/dist/core/silent-schedule-turns.d.ts.map +1 -0
- package/dist/core/silent-schedule-turns.js +47 -0
- package/dist/core/silent-schedule-turns.js.map +1 -0
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/update-check.d.ts +16 -0
- package/dist/core/update-check.d.ts.map +1 -1
- package/dist/core/update-check.js +52 -0
- package/dist/core/update-check.js.map +1 -1
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +30 -23
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/dashboard/schedule-card-model.d.ts +3 -0
- package/dist/dashboard/schedule-card-model.d.ts.map +1 -1
- package/dist/dashboard/schedule-card-model.js +5 -0
- package/dist/dashboard/schedule-card-model.js.map +1 -1
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +295 -6
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +92 -0
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/plugin-page.d.ts.map +1 -1
- package/dist/dashboard/web/plugin-page.js +1 -3
- package/dist/dashboard/web/plugin-page.js.map +1 -1
- package/dist/dashboard/web/schedules-page.d.ts.map +1 -1
- package/dist/dashboard/web/schedules-page.js +111 -4
- package/dist/dashboard/web/schedules-page.js.map +1 -1
- package/dist/dashboard/web/settings-page.d.ts.map +1 -1
- package/dist/dashboard/web/settings-page.js +5 -1
- package/dist/dashboard/web/settings-page.js.map +1 -1
- package/dist/dashboard/web/update-action.d.ts +16 -0
- package/dist/dashboard/web/update-action.d.ts.map +1 -0
- package/dist/dashboard/web/update-action.js +64 -0
- package/dist/dashboard/web/update-action.js.map +1 -0
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/{bot-defaults-page-KLDCZNLP.js → bot-defaults-page-4PM4T6QQ.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-FMJNOATE.js → chunk-3PMN55Z6.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-MLNI5BKE.js → chunk-AIDN2WZB.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-EZAW2EPM.js → chunk-IKCZ677K.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-KEAOTUL3.js → chunk-RXVA6XW3.js} +7 -7
- package/dist/dashboard-web/chunks/{connectors-page-O32LFAL5.js → connectors-page-2MKF4YTN.js} +1 -1
- package/dist/dashboard-web/chunks/{groups-page-PSAFIZ6M.js → groups-page-TAU2UIVS.js} +1 -1
- package/dist/dashboard-web/chunks/{insights-page-V23LLATX.js → insights-page-PJ2XVM6T.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-7X5AKYOF.js → monitor-room-D6445HJO.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-CBA3CQYL.js → monitoring-page-GUHMCKSO.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-RL6QSEM7.js → office-page-6K6U2MS5.js} +1 -1
- package/dist/dashboard-web/chunks/{overview-page-XQIPO6KH.js → overview-page-USDYU7U5.js} +1 -1
- package/dist/dashboard-web/chunks/plugin-page-JXC5F5YV.js +1 -0
- package/dist/dashboard-web/chunks/{roles-page-ACIWV7QS.js → roles-page-O4OUA7ZH.js} +1 -1
- package/dist/dashboard-web/chunks/schedules-page-LNIBXJSZ.js +1 -0
- package/dist/dashboard-web/chunks/{sessions-page-2WDWHSP4.js → sessions-page-B6U6TCFF.js} +1 -1
- package/dist/dashboard-web/chunks/{settings-page-6VX4OUGG.js → settings-page-PXLRFF7I.js} +2 -2
- package/dist/dashboard-web/chunks/{skills-page-WXE3UYLT.js → skills-page-M5KYNXBA.js} +1 -1
- package/dist/dashboard-web/chunks/{team-federation-page-PYTF4FLM.js → team-federation-page-GT7UFQMN.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-G6CD6O3I.js → v3-page-UYZIRJ2C.js} +1 -1
- package/dist/dashboard-web/chunks/{whiteboards-page-6SG33GP4.js → whiteboards-page-WAR77DQE.js} +1 -1
- package/dist/dashboard-web/style.css +697 -0
- package/dist/dashboard.js +404 -29
- package/dist/dashboard.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +4 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +4 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/schedules-card.d.ts.map +1 -1
- package/dist/im/lark/schedules-card.js +2 -0
- package/dist/im/lark/schedules-card.js.map +1 -1
- package/dist/services/plugin-registry-store.d.ts.map +1 -1
- package/dist/services/plugin-registry-store.js +100 -18
- package/dist/services/plugin-registry-store.js.map +1 -1
- package/dist/services/restart-intent-store.d.ts +17 -2
- package/dist/services/restart-intent-store.d.ts.map +1 -1
- package/dist/services/restart-intent-store.js +110 -0
- package/dist/services/restart-intent-store.js.map +1 -1
- package/dist/services/schedule-store.d.ts +3 -1
- package/dist/services/schedule-store.d.ts.map +1 -1
- package/dist/services/schedule-store.js +5 -0
- package/dist/services/schedule-store.js.map +1 -1
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +3 -2
- package/dist/skills/definitions.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/child-env.d.ts +1 -1
- package/dist/utils/child-env.d.ts.map +1 -1
- package/dist/utils/child-env.js +5 -0
- package/dist/utils/child-env.js.map +1 -1
- package/dist/utils/global-install.d.ts +2 -0
- package/dist/utils/global-install.d.ts.map +1 -1
- package/dist/utils/global-install.js +14 -0
- package/dist/utils/global-install.js.map +1 -1
- package/dist/worker.js +125 -17
- package/dist/worker.js.map +1 -1
- package/dist/workflows/hostExecutors/botmux-schedule.d.ts +3 -0
- package/dist/workflows/hostExecutors/botmux-schedule.d.ts.map +1 -1
- package/dist/workflows/hostExecutors/botmux-schedule.js +9 -0
- package/dist/workflows/hostExecutors/botmux-schedule.js.map +1 -1
- package/package.json +1 -1
- package/dist/dashboard-web/chunks/plugin-page-7FW2LPJH.js +0 -1
- package/dist/dashboard-web/chunks/schedules-page-KJDUKOJV.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as w}from"./chunk-FMJNOATE.js";import{a as q,c as re,i as Ce,k as D,p as E}from"./chunk-I35DXGM4.js";import{a as pe,r as fe}from"./chunk-KEAOTUL3.js";import{a as Pe}from"./chunk-SYC6D5XU.js";import{a as ke,d as oe}from"./chunk-5THX4DI2.js";import{c as te}from"./chunk-7SZRL6FY.js";var f=te(ke(),1);var b=te(ke(),1);var a=te(oe(),1),Re=["transcript_received","chat_received","participant_joined","participant_left","magic_share_started","magic_share_ended"],me=8e3,Be=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,xe="\u6301\u7EED\u6574\u7406\u4F1A\u8BAE\u7EAA\u8981\uFF0C\u91CD\u70B9\u8BB0\u5F55\u5DF2\u786E\u8BA4\u7684\u51B3\u7B56\u3001\u5F85\u529E\u4E8B\u9879\uFF08\u542B\u8D1F\u8D23\u4EBA\u548C\u622A\u6B62\u65F6\u95F4\uFF09\u4EE5\u53CA\u672A\u89E3\u51B3\u98CE\u9669\uFF1B\u5B57\u5E55\u4FEE\u8BA2\u65F6\u66F4\u65B0\u5DF2\u6709\u6761\u76EE\uFF0C\u4E0D\u91CD\u590D\u8BB0\u5F55\u540C\u4E00\u4E8B\u9879\u3002\u4EC5\u5728\u51FA\u73B0\u65B0\u7684\u5173\u952E\u51B3\u7B56\u3001\u660E\u786E\u5F85\u529E\u6216\u98CE\u9669\uFF0C\u6216\u88AB\u7528\u6237\u70B9\u540D\u65F6\uFF0C\u624D\u5728\u76D1\u542C\u7FA4\u8F93\u51FA\u7B80\u6D01\u589E\u91CF\uFF1B\u65E0\u5B9E\u8D28\u589E\u91CF\u65F6\u4FDD\u6301\u9759\u9ED8\uFF0C\u4E0D\u53D1\u9001\u786E\u8BA4\u6216\u5FC3\u8DF3\u3002\u9700\u8981\u5411\u4F1A\u8BAE\u5185\u53D1\u9001\u6587\u5B57\u6216\u8BED\u97F3\u65F6\uFF0C\u5FC5\u987B\u901A\u8FC7 botmux \u53D7\u7BA1 request-output/action gate \u63D0\u4EA4\uFF0C\u4E0D\u5F97\u7ED5\u8FC7\u6743\u9650\u3001\u6240\u6709\u6743\u4E0E\u5BA1\u6838\u7B56\u7565\u3002",Ne=0;function Te(){return Ne+=1,`p${Ne}`}function Se(e){return{...e,uiKey:Te(),isNew:!1}}function Le(e){let{uiKey:t,isNew:i,...g}=e;return g}function Q(e){return(0,a.jsxs)("span",{className:"vc-profile-field-head",children:[e.title,(0,a.jsx)(Ce,{label:e.title,children:(0,a.jsx)("span",{className:"vc-profile-help",children:e.help})})]})}function Me(e){let t=w();return e.enabled?e.canWrite?(0,a.jsx)(Ue,{canWrite:e.canWrite,listenerBotAppId:e.listenerBotAppId,listenerBotOptions:e.listenerBotOptions}):(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.needAuth")}):null}function Ue(e){let t=w(),i=(0,b.useRef)(!1),g=e.listenerBotOptions,[m,v]=(0,b.useState)(e.listenerBotAppId??g[0]?.larkAppId??""),[c,C]=(0,b.useState)(null),[I,T]=(0,b.useState)(null),[k,z]=(0,b.useState)(!1),[x,H]=(0,b.useState)(!1),[M,r]=(0,b.useState)(!1),[p,P]=(0,b.useState)(!1),[j,L]=(0,b.useState)({}),[G,ie]=(0,b.useState)(!1);(0,b.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);let V=(0,b.useRef)(0);(0,b.useEffect)(()=>{e.listenerBotAppId&&e.listenerBotAppId!==m&&!x&&v(e.listenerBotAppId)},[x,e.listenerBotAppId,m]);let J=(0,b.useCallback)(async s=>{let o=++V.current;if(C(null),H(!1),P(!1),L({}),!s){T(null);return}z(!0);try{let l=await fetch(`/api/vc-meeting/consumer-profiles?listenerBotAppId=${encodeURIComponent(s)}`),u=await l.json().catch(()=>({}));if(!i.current||V.current!==o)return;!l.ok||u?.ok!==!0?(C(null),T(typeof u?.error=="string"?u.error:`HTTP ${l.status}`)):(C({forBot:s,revision:u.revision,catalogState:u.catalogState==="explicit_empty"||u.catalogState==="legacy_or_partial"||u.catalogState==="profiles"?u.catalogState:"uninitialized",defaultMode:u.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(u.defaultConsumerIds)?u.defaultConsumerIds:[],profiles:(Array.isArray(u.profiles)?u.profiles:[]).map(Se),agentOptions:Array.isArray(u.agentOptions)?u.agentOptions:[],...u.migrationOffer==="enable_seeded_minutes_default"?{migrationOffer:u.migrationOffer}:{}}),T(null),H(!1))}catch(l){if(!i.current||V.current!==o)return;C(null),T(l instanceof Error?l.message:String(l))}finally{i.current&&V.current===o&&z(!1)}},[]);(0,b.useEffect)(()=>{J(m)},[J,m]);let S=(0,b.useCallback)(s=>{C(o=>o&&s(o)),H(!0),ie(!1)},[]),Z=(0,b.useCallback)((s,o)=>{S(l=>({...l,profiles:l.profiles.map(u=>u.uiKey===s?{...u,...o}:u)}))},[S]),ne=(0,b.useCallback)(async()=>{if(!c||M||k||!c.forBot||c.forBot!==m)return;let s={};if(c.profiles.forEach((o,l)=>{Be.test(o.id)||(s[`profiles[${l}].id`]=t("settings.vcProfiles.idInvalid")),(o.instructions??"").length>me&&(s[`profiles[${l}].instructions`]=t("settings.vcProfiles.instructionsTooLong"))}),Object.keys(s).length>0){L(s);return}r(!0),P(!1),L({});try{let o=await fetch("/api/vc-meeting/consumer-profiles",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({listenerBotAppId:c.forBot,expectedRevision:c.revision,defaultMode:c.defaultMode,defaultConsumerIds:c.defaultConsumerIds,profiles:c.profiles.map(Le)})}),l=await o.json().catch(()=>({}));if(!i.current||c.forBot!==m)return;if(o.status===409){P(!0);return}if(o.status===422){let u={};for(let R of Array.isArray(l?.fieldErrors)?l.fieldErrors:[])typeof R?.path=="string"&&typeof R?.message=="string"&&(u[R.path]=R.message);L(Object.keys(u).length>0?u:{profiles:t("settings.vcProfiles.validationFailed")});return}if(!o.ok||l?.ok!==!0){L({profiles:typeof l?.error=="string"?l.error:`HTTP ${o.status}`});return}C({forBot:c.forBot,revision:l.revision,catalogState:l.catalogState==="explicit_empty"||l.catalogState==="legacy_or_partial"||l.catalogState==="profiles"?l.catalogState:"uninitialized",defaultMode:l.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(l.defaultConsumerIds)?l.defaultConsumerIds:[],profiles:(Array.isArray(l.profiles)?l.profiles:[]).map(Se),agentOptions:Array.isArray(l.agentOptions)?l.agentOptions:[],...l.migrationOffer==="enable_seeded_minutes_default"?{migrationOffer:l.migrationOffer}:{}}),H(!1),ie(!0)}catch(o){if(!i.current)return;L({profiles:o instanceof Error?o.message:String(o)})}finally{i.current&&r(!1)}},[c,M,m,t]),X=(0,b.useMemo)(()=>g.map(s=>({value:s.larkAppId,label:s.botName||s.larkAppId})),[g]),Y=X.find(s=>s.value===m)?.label??m,ce=(0,b.useMemo)(()=>c?c.agentOptions.map(s=>{let o=[s.online?void 0:t("settings.vcProfiles.agentOffline"),s.workingDirReady?void 0:t("settings.vcProfiles.agentNoWorkingDir"),s.reliableTurnTerminal?void 0:t("settings.vcProfiles.agentNoReliableTerminal"),s.managedSideEffectIsolation?void 0:t("settings.vcProfiles.agentNoManagedIsolation")].filter(Boolean);return{value:s.appId,label:(0,a.jsxs)("span",{className:"vc-agent-option",children:[(0,a.jsxs)("span",{className:"vc-agent-option-name",children:[s.label,s.cliId?(0,a.jsx)("em",{className:"vc-agent-option-cli",children:s.cliId}):null]}),o.length>0?(0,a.jsxs)("span",{className:"vc-agent-option-warn",children:["\u26A0 ",o.join(" \xB7 ")]}):null]})}}):[],[c,t]),se=s=>{let o=c?.agentOptions.find(u=>u.appId===s);return o?!o.online||!o.workingDirReady||!o.reliableTurnTerminal||!o.managedSideEffectIsolation?`\u26A0 ${o.label}`:o.label:s},ae=(0,b.useCallback)(s=>{let l=["observe_only","meeting_text","meeting_voice","meeting_text_voice"].map(u=>({value:u,label:t(`settings.vcProfiles.preset.${u}`)}));return(!s.isNew||s.permissionPreset==="custom")&&l.push({value:"custom",label:t("settings.vcProfiles.preset.custom")}),l},[t]),de=(0,b.useCallback)(()=>{S(s=>({...s,profiles:[...s.profiles,{uiKey:Te(),isNew:!0,id:"",agentAppId:s.agentOptions[0]?.appId??"",responseMode:"silent",permissionPreset:"observe_only"}]}))},[S]),ue=(0,b.useCallback)(s=>{S(o=>({...o,profiles:o.profiles.filter(l=>l.uiKey!==s),defaultConsumerIds:o.defaultConsumerIds.filter(l=>o.profiles.some(u=>u.uiKey!==s&&u.id===l))}))},[S]);if(g.length===0)return null;let h=s=>j[s],B=!e.canWrite||M||k,O=c?.agentOptions.some(s=>s.workingDirReady&&s.reliableTurnTerminal&&s.managedSideEffectIsolation)??!1;return(0,a.jsxs)("div",{className:"vc-profiles-section",children:[(0,a.jsxs)("div",{className:"settings-field-row",children:[(0,a.jsx)(D,{help:t("settings.vcProfiles.help"),children:t("settings.vcProfiles.title")}),e.listenerBotAppId===null&&X.length>1?(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.listenerOwner")}),(0,a.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.listenerOwner"),disabled:k||M,value:m,label:q(X,m),options:X,onChange:s=>{s!==m&&(x&&!window.confirm(t("settings.vcProfiles.discardConfirm"))||v(s))}})]}):(0,a.jsx)("span",{className:"vc-profile-config-target",children:t("settings.vcProfiles.configuringBot",{bot:Y})})]}),(0,a.jsx)("p",{className:"hint vc-profiles-freeze",children:t("settings.vcProfiles.freezeNotice")}),k?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.loading")}):null,I?(0,a.jsx)("p",{className:"hint-warn",children:I==="bot_not_in_config"?t("settings.vcProfiles.botNotInConfig"):`${t("settings.vcProfiles.loadFailed")}: ${I}`}):null,p?(0,a.jsxs)("p",{className:"hint-warn",children:[t("settings.vcProfiles.conflict")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",onClick:()=>{J(m)},children:t("settings.vcProfiles.reload")})]}):null,h("profiles")?(0,a.jsx)("p",{className:"hint-warn",children:h("profiles")}):null,c?(0,a.jsxs)(a.Fragment,{children:[c.migrationOffer==="enable_seeded_minutes_default"?(0,a.jsxs)("p",{className:"hint-warn vc-profile-migration-offer",children:[t("settings.vcProfiles.migrationOffer")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",disabled:B||x,onClick:()=>S(s=>({...s,defaultMode:"agents",defaultConsumerIds:["minutes"],profiles:s.profiles.map(o=>o.id==="minutes"?{...o,instructions:xe,responseMode:"listener_thread",permissionPreset:"meeting_text_voice"}:o),migrationOffer:void 0})),children:t("settings.vcProfiles.migrationEnable")})]}):null,c.catalogState==="uninitialized"&&c.profiles.length===0&&!O?(0,a.jsx)("p",{className:"hint-warn",children:t("settings.vcProfiles.noEligibleDefaultAgent")}):null,c.catalogState==="legacy_or_partial"?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.legacyCatalog")}):null,c.profiles.map((s,o)=>(0,a.jsxs)("div",{className:"vc-profile-card",children:[(0,a.jsxs)("div",{className:"vc-profile-grid",children:[(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldId"),help:t("settings.vcProfiles.idHelp")})}),(0,a.jsx)("input",{type:"text",value:s.id,disabled:B||!s.isNew,placeholder:"minutes",onChange:l=>{let u=l.target.value,R=s.id;S(_=>({..._,profiles:_.profiles.map($=>$.uiKey===s.uiKey?{...$,id:u}:$),defaultConsumerIds:_.defaultConsumerIds.map($=>$===R&&R?u:$).filter($=>!!$)}))}}),h(`profiles[${o}].id`)?(0,a.jsx)("em",{className:"vc-profile-err",children:h(`profiles[${o}].id`)}):null]}),(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldLabel"),help:t("settings.vcProfiles.labelHelp")})}),(0,a.jsx)("input",{type:"text",value:s.label??"",disabled:B,onChange:l=>Z(s.uiKey,{label:l.target.value||void 0})}),h(`profiles[${o}].label`)?(0,a.jsx)("em",{className:"vc-profile-err",children:h(`profiles[${o}].label`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldAgent"),help:t("settings.vcProfiles.agentHelp")})}),(0,a.jsx)(E,{className:"vc-profile-agent-menu",ariaLabel:t("settings.vcProfiles.fieldAgent"),disabled:B,value:s.agentAppId,label:se(s.agentAppId),options:ce,onChange:l=>Z(s.uiKey,{agentAppId:l})}),h(`profiles[${o}].agentAppId`)?(0,a.jsx)("em",{className:"vc-profile-err",children:h(`profiles[${o}].agentAppId`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldResponseMode"),help:t("settings.vcProfiles.responseModeHelp")})}),(0,a.jsx)(E,{ariaLabel:t("settings.vcProfiles.fieldResponseMode"),disabled:B,value:s.responseMode,label:s.responseMode==="listener_thread"?t("settings.vcProfiles.responseListener"):t("settings.vcProfiles.responseSilent"),options:[{value:"silent",label:t("settings.vcProfiles.responseSilent")},{value:"listener_thread",label:t("settings.vcProfiles.responseListener")}],onChange:l=>Z(s.uiKey,{responseMode:l})}),h(`profiles[${o}].responseMode`)?(0,a.jsx)("em",{className:"vc-profile-err",children:h(`profiles[${o}].responseMode`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldPreset"),help:t("settings.vcProfiles.presetHelp")})}),(0,a.jsx)(E,{ariaLabel:t("settings.vcProfiles.fieldPreset"),disabled:B,value:s.permissionPreset,label:q(ae(s),s.permissionPreset),options:ae(s),onChange:l=>Z(s.uiKey,{permissionPreset:l})}),h(`profiles[${o}].permissionPreset`)?(0,a.jsx)("em",{className:"vc-profile-err",children:h(`profiles[${o}].permissionPreset`)}):null]})]}),(0,a.jsxs)("label",{className:"vc-profile-field vc-profile-instructions",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldInstructions"),help:t("settings.vcProfiles.instructionsHelp")}),(0,a.jsxs)("em",{className:"vc-profile-count",children:[(s.instructions??"").length,"/",me]})]}),(0,a.jsx)("textarea",{rows:4,maxLength:me,value:s.instructions??"",disabled:B,placeholder:t("settings.vcProfiles.instructionsPlaceholder"),onChange:l=>Z(s.uiKey,{instructions:l.target.value||void 0})}),h(`profiles[${o}].instructions`)?(0,a.jsx)("em",{className:"vc-profile-err",children:h(`profiles[${o}].instructions`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldActivityTypes"),help:t("settings.vcProfiles.activityHelp")})}),(0,a.jsx)("div",{className:"vc-profile-activity",children:Re.map(l=>{let u=s.activityTypes?.includes(l)??!1;return(0,a.jsxs)("label",{className:"vc-profile-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:u,disabled:B,onChange:R=>{let _=new Set(s.activityTypes??[]);R.target.checked?_.add(l):_.delete(l),Z(s.uiKey,{activityTypes:_.size>0?[..._]:void 0})}}),t(`settings.vcProfiles.activity.${l}`)]},l)})}),(0,a.jsx)("em",{className:"vc-profile-hint",children:t("settings.vcProfiles.activityAllHint")}),h(`profiles[${o}].activityTypes`)?(0,a.jsx)("em",{className:"vc-profile-err",children:h(`profiles[${o}].activityTypes`)}):null]}),e.canWrite?(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-remove",disabled:M||k,onClick:()=>ue(s.uiKey),children:t("settings.vcProfiles.remove")}):null]},s.uiKey)),e.canWrite?(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",disabled:M||k,onClick:de,children:t("settings.vcProfiles.add")}):null,(0,a.jsxs)("div",{className:"settings-field-row",children:[(0,a.jsx)(D,{help:t("settings.vcProfiles.defaultModeHelp"),children:t("settings.vcProfiles.defaultMode")}),(0,a.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.defaultMode"),disabled:B,value:c.defaultMode,label:c.defaultMode==="agents"?t("settings.vcProfiles.defaultModeAgents"):t("settings.vcProfiles.defaultModeListenOnly"),options:[{value:"listenOnly",label:t("settings.vcProfiles.defaultModeListenOnly")},{value:"agents",label:t("settings.vcProfiles.defaultModeAgents")}],onChange:s=>S(o=>({...o,defaultMode:s==="agents"?"agents":"listenOnly"}))})]}),c.defaultMode==="agents"?(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.defaultConsumers")}),(0,a.jsx)("div",{className:"vc-profile-activity",children:c.profiles.filter(s=>s.id).map(s=>{let o=c.defaultConsumerIds.includes(s.id);return(0,a.jsxs)("label",{className:"vc-profile-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:o,disabled:B,onChange:l=>{S(u=>({...u,defaultConsumerIds:l.target.checked?[...u.defaultConsumerIds,s.id]:u.defaultConsumerIds.filter(R=>R!==s.id)}))}}),s.label||s.id]},s.uiKey)})}),h("defaultConsumerIds")?(0,a.jsx)("em",{className:"vc-profile-err",children:h("defaultConsumerIds")}):null,h("defaultMode")?(0,a.jsx)("em",{className:"vc-profile-err",children:h("defaultMode")}):null]}):null,e.canWrite?(0,a.jsxs)("div",{className:"vc-profiles-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-save",disabled:!x||M||p,onClick:()=>{ne()},children:t(M?"settings.vcProfiles.saving":"settings.vcProfiles.save")}),G?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.saved")}):null,x&&!M?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.unsaved")}):null]}):null]}):null]})}var n=te(oe(),1),ve=["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Asia/Kolkata","UTC","Europe/London","Europe/Paris","Europe/Moscow","America/Los_Angeles","America/New_York","America/Sao_Paulo","Australia/Sydney"];function De(e,t){if(!e||typeof e!="object")return null;if(e.failed){let i=e.failed.step==="install"?t("settings.herdrTraexInstallStepInstall"):t("settings.herdrTraexInstallStepAction");return{text:`${t("settings.herdrTraexInstallFailed")}\uFF08${i}\uFF09: ${e.failed.reason??""}`,cls:"hint-warn-inline"}}if(e.skippedReason==="plugin_unsupported"){let i=typeof e.herdrVersion=="string"&&e.herdrVersion?` (${e.herdrVersion})`:"";return{text:`${t("settings.herdrTraexUnsupported")}${i}`,cls:"hint-warn-inline"}}return e.installed||e.actionInvoked?{text:t("settings.herdrTraexInstalled"),cls:"hint-ok"}:e.alreadyInstalled?{text:t("settings.herdrTraexAlreadyInstalled"),cls:"hint-ok"}:null}function he(e){return{publicReadOnly:e?.publicReadOnly===!0,openTerminalInFeishu:e?.openTerminalInFeishu===!0,enableLocalCliOpen:e?.enableLocalCliOpen===!0,localCliOpenMode:e?.localCliOpenMode==="resume"?"resume":"attach",chatBotDiscovery:e?.chatBotDiscovery!==!1,herdrTraexPlugin:{enabled:e?.herdrTraexPlugin?.enabled===!0,source:typeof e?.herdrTraexPlugin?.source=="string"?e.herdrTraexPlugin.source:"",ref:typeof e?.herdrTraexPlugin?.ref=="string"?e.herdrTraexPlugin.ref:"",recommendedSource:typeof e?.herdrTraexPlugin?.recommendedSource=="string"?e.herdrTraexPlugin.recommendedSource:"",recommendedRef:typeof e?.herdrTraexPlugin?.recommendedRef=="string"?e.herdrTraexPlugin.recommendedRef:""},vcMeetingAgent:{enabled:e?.vcMeetingAgent?.enabled!==!1,listenerBotAppId:typeof e?.vcMeetingAgent?.listenerBotAppId=="string"?e.vcMeetingAgent.listenerBotAppId:null,listenerBotOptions:Array.isArray(e?.vcMeetingAgent?.listenerBotOptions)?e.vcMeetingAgent.listenerBotOptions:[],larkCliVersion:e?.vcMeetingAgent?.larkCliVersion===void 0?void 0:e.vcMeetingAgent.larkCliVersion??null,larkCliMeetsRequirement:e?.vcMeetingAgent?.larkCliMeetsRequirement===!0,larkCliMinVersion:typeof e?.vcMeetingAgent?.larkCliMinVersion=="string"?e.vcMeetingAgent.larkCliMinVersion:void 0},repoPickerMode:e?.repoPickerMode==="repos"?"repos":"all",maintenance:e?.maintenance&&typeof e.maintenance=="object"?e.maintenance:{},localDevInstall:e?.localDevInstall===!0,autoUpdateSupported:e?.autoUpdateSupported!==!1,whiteboard:{enabled:e?.whiteboard?.enabled===!0},remoteAccess:e?.remoteAccess===!0,scheduleTimeZone:typeof e?.scheduleTimeZone=="string"?e.scheduleTimeZone:"",hostTimeZone:typeof e?.hostTimeZone=="string"&&e.hostTimeZone?e.hostTimeZone:"UTC",effectiveScheduleTimeZone:typeof e?.effectiveScheduleTimeZone=="string"&&e.effectiveScheduleTimeZone?e.effectiveScheduleTimeZone:typeof e?.scheduleTimeZone=="string"&&e.scheduleTimeZone?e.scheduleTimeZone:typeof e?.hostTimeZone=="string"&&e.hostTimeZone?e.hostTimeZone:"UTC"}}function Ee(e,t){let i=e?.[t]??{};return{enabled:i.enabled===!0,time:typeof i.time=="string"?i.time:"04:00"}}function we(e,t){return t(e==="npm-global"?"update.kindNpm":e==="pnpm-global"?"update.kindPnpm":e==="yarn-global"?"update.kindYarn":e==="bun-global"?"update.kindBun":e==="source-checkout"?"update.kindSource":"update.kindUnknown")}function _e(){let e=w(),t=(0,f.useRef)(!1),i=(0,f.useRef)(new Set),[g,m]=(0,f.useState)(null),[v,c]=(0,f.useState)(!1),[C,I]=(0,f.useState)(null),[T,k]=(0,f.useState)(!0),[z,x]=(0,f.useState)(!1),[H,M]=(0,f.useState)(null),[r,p]=(0,f.useState)(null),[P,j]=(0,f.useState)(null),[L,G]=(0,f.useState)(null),[ie,V]=(0,f.useState)(null),[J,S]=(0,f.useState)(null),[Z,ne]=(0,f.useState)(!1),[X,Y]=(0,f.useState)(!0),[ce,se]=(0,f.useState)(!1),[ae,de]=(0,f.useState)(""),[ue,h]=(0,f.useState)(!1),[B,O]=(0,f.useState)(null),s=(0,f.useCallback)(()=>{for(let d of i.current)window.clearTimeout(d);i.current.clear()},[]),o=(0,f.useCallback)((d,y)=>{let N=window.setTimeout(()=>{i.current.delete(N),d()},y);return i.current.add(N),N},[]),l=(0,f.useCallback)(async()=>{try{let d=await fetch("/api/update/status"),y=await d.json().catch(()=>({}));if(!t.current)return;if(!d.ok){G(null),V(y?.error??`HTTP ${d.status}`);return}G(y),V(null)}catch(d){if(!t.current)return;G(null),V(d instanceof Error?d.message:String(d))}},[]),u=(0,f.useCallback)(async()=>{try{let d=await fetch("/api/settings"),y=await d.json().catch(()=>({}));if(!t.current)return;if(!d.ok){m(null),I(y?.error??`HTTP ${d.status}`),c(!0);return}m(he(y.settings)),k(y.authed===!0),x(y.bound===!0),I(null),c(!0)}catch(d){if(!t.current)return;m(null),I(d instanceof Error?d.message:String(d)),c(!0)}},[]);(0,f.useEffect)(()=>(t.current=!0,u(),()=>{t.current=!1,s()}),[s,u]),(0,f.useEffect)(()=>{v&&(h(!1),O(null),ne(!1),T&&l())},[T,l,v]);async function R(d,y,N){if(!g)return;let A=g;m(N(g)),M(d),p({text:e("settings.saving")});try{let K=await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(y)}),U=await K.json().catch(()=>({}));if(!t.current)return;if(!K.ok||U.ok===!1)throw typeof U?.feishuLoginQr=="string"&&U.feishuLoginQr&&j(U.feishuLoginQr),new Error(U?.error??`HTTP ${K.status}`);j(null);let ee=he(U.settings);m(ee),fe.publicReadOnly=ee.publicReadOnly,pe.setScheduleTimeZone(ee.effectiveScheduleTimeZone);let le=De(U.herdrTraexInstall,e);p(le??{text:e("settings.saved"),cls:"hint-ok"})}catch(K){if(!t.current)return;let U=!1;try{let le=await fetch("/api/settings"),ye=await le.json().catch(()=>({}));if(t.current&&le.ok&&ye?.settings){let ge=he(ye.settings);m(ge),fe.publicReadOnly=ge.publicReadOnly,pe.setScheduleTimeZone(ge.effectiveScheduleTimeZone),U=!0}}catch{}if(!t.current)return;U||m(A);let ee=K instanceof Error?K.message:String(K);p({text:U?`${e("settings.saveReconciled")}: ${ee}`:`${e("settings.saveFailed")}: ${ee}`,cls:"hint-warn-inline"})}finally{t.current&&M(null)}}async function _(){S(null),Y(!0),se(!1);try{let d=await fetch("/api/update/changelog"),y=await d.json().catch(()=>({}));if(!t.current)return;de(typeof y?.releasesUrl=="string"?y.releasesUrl:""),d.ok?(S(Array.isArray(y.releases)?y.releases:[]),Y(y.ok!==!1),se(y.rateLimited===!0)):(S([]),Y(!1))}catch{if(!t.current)return;S([]),Y(!1)}}function $(){let d=Date.now(),y=async()=>{if(t.current){if(Date.now()-d>9e4){h(!1),O({text:e("update.restartSlow"),cls:"hint-warn-inline"});return}try{let N=await fetch("/__health",{cache:"no-store"});if(!t.current)return;if(N.ok){location.reload();return}}catch{}t.current&&o(()=>{y()},2e3)}};o(()=>{y()},3e3)}async function be(d){h(!0),O({text:e("update.restarting")});try{if(await fetch("/api/update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d?{update:d}:{})}),!t.current)return}catch(y){if(!t.current)return;h(!1),O({text:e("update.restartFailed",{detail:y instanceof Error?y.message:String(y)}),cls:"hint-warn-inline"});return}$()}async function Ie(){let d=L;if(!d)return;if(!d.node.ok){window.alert(e("update.nodeTooOldAlert",{version:d.node.version,required:d.node.required}));return}if(!d.updateSupported||!d.updateCommand){window.alert(e("update.unsupportedInstall"));return}if(d.installs.multiple){let N=d.installs.entries.map(A=>`\u2022 ${A.binPath} (${we(A.kind,e)})`).join(`
|
|
2
|
-
`);if(!window.confirm(e("update.confirmMultiInstall",{paths:N})))return}let y=d.latest?e("update.confirmUpdate",{version:`v${d.latest}`,command:d.updateCommand}):e("update.confirmUpdateNoVer",{command:d.updateCommand});if(window.confirm(y)){h(!0),O({text:e("update.updating",{command:d.updateCommand})});try{let N=await fetch("/api/update/run",{method:"POST"}),A=await N.json().catch(()=>({}));if(!t.current)return;if(!N.ok||A.ok===!1){let K=A?.detail??A?.error??`HTTP ${N.status}`;h(!1),O({text:e("update.updateFailed",{detail:K}),cls:"hint-warn-inline"});return}A.changed?(h(!1),O({text:e("update.updatedChanged",{old:`v${A.oldVersion}`,new:`v${A.newVersion}`}),cls:"hint-ok"}),window.confirm(e("update.confirmRestart"))?await be({oldVersion:A.oldVersion,newVersion:A.newVersion}):t.current&&O({text:e("update.noRestartHint"),cls:"hint-ok"})):(h(!1),O({text:e("update.alreadyLatestRun",{version:`v${A.newVersion}`}),cls:"hint-ok"}),await l())}catch(N){if(!t.current)return;h(!1),O({text:e("update.updateFailed",{detail:N instanceof Error?N.message:String(N)}),cls:"hint-warn-inline"})}}}let Oe=g?(0,n.jsx)($e,{settings:g,canWrite:T,bound:z,savingKey:H,message:r,updateBlock:(0,n.jsx)(Ze,{canWrite:T,status:L,statusError:ie,changelog:J,changelogOpen:Z,changelogOk:X,changelogRateLimited:ce,releasesUrl:ae,busy:ue,message:B,onCheck:()=>{G(null),S(null),ne(!1),O(null),V(null),l()},onToggleChangelog:()=>{let d=!Z;ne(d),d&&J===null&&_()},onUpdate:()=>{Ie()},onRestart:()=>{window.confirm(e("update.confirmPlainRestart"))&&be(null)}}),feishuLoginQr:P,onCloseFeishuLoginQr:()=>j(null),onSave:R}):C?(0,n.jsxs)("p",{className:"hint-warn",children:[e("settings.loadFailed"),": ",C]}):(0,n.jsx)(re,{label:e("settings.loading")});return(0,n.jsxs)("section",{className:"page settings-page",children:[(0,n.jsx)("div",{className:"page-heading",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"eyebrow",children:e("nav.settings")}),(0,n.jsx)("h1",{children:e("settings.title")})]})}),Oe]})}function $e(e){let t=w(),{settings:i,canWrite:g,bound:m,savingKey:v}=e,c=!g,C=Ee(i.maintenance,"autoUpdate"),I=!g||i.localDevInstall||!i.autoUpdateSupported,T=!g||i.maintenance.autoUpdate?.enabled!==!0,k=(r,p)=>{e.onSave(r,{[r]:p},P=>({...P,[r]:p}))},z=r=>e.onSave("herdrTraexPlugin",{herdrTraexPlugin:r},p=>({...p,herdrTraexPlugin:{...p.herdrTraexPlugin,...r}})),x=(0,f.useMemo)(()=>[{value:"all",label:t("settings.repoPickerModeAll")},{value:"repos",label:t("settings.repoPickerModeRepos")}],[t]),H=(0,f.useMemo)(()=>[{value:"attach",label:t("settings.localCliOpenModeAttach")},{value:"resume",label:t("settings.localCliOpenModeResume")}],[t]),M=(0,f.useMemo)(()=>[{value:"",label:t("settings.vcMeetingListenerBotAuto")},...i.vcMeetingAgent.listenerBotOptions.map(r=>{let p=r.botName||r.larkAppId,P=r.cliId?` \xB7 ${r.cliId}`:"",j=[r.vcMeetingAgentEnabled===!0?void 0:t("settings.vcMeetingListenerBotDisabled"),r.hasLarkCliProfile===!0?void 0:t("settings.vcMeetingListenerBotNoProfile")].filter(Boolean),L=j.length>0?` \xB7 ${j.join(" \xB7 ")}`:"";return{value:r.larkAppId,label:`${p}${P}${L}`}})],[i.vcMeetingAgent.listenerBotOptions,t]);return(0,n.jsxs)("div",{className:"settings-layout",children:[g?null:(0,n.jsx)("article",{className:"bd-card settings-card settings-alert-card",children:(0,n.jsx)("p",{className:"hint-warn",children:t("settings.readOnlyVisitor")})}),(0,n.jsxs)(Ae,{className:"settings-group-main",children:[(0,n.jsxs)(W,{title:t("settings.sectionAccess"),children:[(0,n.jsx)(F,{title:t("settings.publicReadOnly"),help:t("settings.publicReadOnlyHelp"),checked:i.publicReadOnly,disabled:c||v==="publicReadOnly",onChange:r=>k("publicReadOnly",r)}),m?(0,n.jsx)(F,{title:t("settings.remoteAccess"),help:t("settings.remoteAccessHelp"),checked:i.remoteAccess,disabled:c||v==="remoteAccess",onChange:r=>k("remoteAccess",r)}):null]}),(0,n.jsxs)(W,{title:t("settings.sectionCards"),children:[(0,n.jsx)(F,{title:t("settings.openTerminalInFeishu"),help:t("settings.openTerminalInFeishuHelp"),checked:i.openTerminalInFeishu,disabled:c||v==="openTerminalInFeishu",onChange:r=>k("openTerminalInFeishu",r)}),(0,n.jsx)(F,{title:t("settings.enableLocalCliOpen"),help:t("settings.enableLocalCliOpenHelp"),checked:i.enableLocalCliOpen,disabled:c||v==="enableLocalCliOpen",onChange:r=>k("enableLocalCliOpen",r)}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.localCliOpenModeHelp"),children:t("settings.localCliOpenMode")}),(0,n.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.localCliOpenMode"),disabled:c||!i.enableLocalCliOpen||v==="localCliOpenMode",value:i.localCliOpenMode,label:q(H,i.localCliOpenMode),options:H,onChange:r=>{e.onSave("localCliOpenMode",{localCliOpenMode:r},p=>({...p,localCliOpenMode:r}))}})]})]}),(0,n.jsxs)(W,{title:t("settings.sectionExperimental"),children:[(0,n.jsx)(F,{title:t("settings.chatBotDiscovery"),help:t("settings.chatBotDiscoveryHelp"),checked:i.chatBotDiscovery,disabled:c||v==="chatBotDiscovery",onChange:r=>k("chatBotDiscovery",r)}),(0,n.jsx)(F,{title:t("settings.herdrTraexPlugin"),help:t("settings.herdrTraexPluginHelp"),checked:i.herdrTraexPlugin.enabled,disabled:c||v==="herdrTraexPlugin",onChange:r=>z({enabled:r})}),i.herdrTraexPlugin.enabled?(0,n.jsx)(Ve,{value:i.herdrTraexPlugin,disabled:c||v==="herdrTraexPlugin",onSave:r=>z(r)}):null]}),(0,n.jsx)(W,{title:t("settings.sectionWhiteboard"),children:(0,n.jsx)(F,{title:t("settings.whiteboardEnable"),help:t("settings.whiteboardEnableHelp"),checked:i.whiteboard.enabled,disabled:c||v==="whiteboard",onChange:r=>{e.onSave("whiteboard",{whiteboard:{enabled:r}},p=>({...p,whiteboard:{enabled:r}}))}})}),(0,n.jsx)(W,{title:t("settings.sectionRepoPicker"),children:(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.repoPickerModeHelp"),children:t("settings.repoPickerMode")}),(0,n.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.repoPickerMode"),disabled:c||v==="repoPickerMode",value:i.repoPickerMode,label:q(x,i.repoPickerMode),options:x,onChange:r=>{e.onSave("repoPickerMode",{repoPickerMode:r},p=>({...p,repoPickerMode:r}))}})]})}),(0,n.jsx)(W,{title:t("settings.sectionSchedule"),children:(0,n.jsx)(He,{value:i.scheduleTimeZone,host:i.hostTimeZone,effective:i.effectiveScheduleTimeZone,disabled:c||v==="scheduleTimeZone",onSave:r=>{e.onSave("scheduleTimeZone",{scheduleTimeZone:r},p=>({...p,scheduleTimeZone:r??""}))}})}),(0,n.jsxs)(W,{className:"settings-vc-block",title:t("settings.sectionVcMeetingAgent"),children:[(0,n.jsx)(F,{title:t("settings.vcMeetingAgent"),help:t("settings.vcMeetingAgentHelp"),checked:i.vcMeetingAgent.enabled,disabled:c||v==="vcMeetingAgent",onChange:r=>{e.onSave("vcMeetingAgent",{vcMeetingAgent:{enabled:r}},p=>({...p,vcMeetingAgent:{...p.vcMeetingAgent,enabled:r}}))}}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.vcMeetingListenerBotHelp"),children:t("settings.vcMeetingListenerBot")}),(0,n.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.vcMeetingListenerBot"),disabled:c||v==="vcMeetingAgent",value:i.vcMeetingAgent.listenerBotAppId??"",label:q(M,i.vcMeetingAgent.listenerBotAppId??""),options:M,onChange:r=>{let p=r||null;e.onSave("vcMeetingAgent",{vcMeetingAgent:{listenerBotAppId:p}},P=>({...P,vcMeetingAgent:{...P.vcMeetingAgent,listenerBotAppId:p}}))}})]}),(0,n.jsx)(Fe,{settings:i.vcMeetingAgent}),(0,n.jsx)(Me,{enabled:i.vcMeetingAgent.enabled,canWrite:g,listenerBotAppId:i.vcMeetingAgent.listenerBotAppId,listenerBotOptions:i.vcMeetingAgent.listenerBotOptions}),e.feishuLoginQr?(0,n.jsxs)("div",{className:"settings-feishu-login",children:[(0,n.jsx)("button",{type:"button",className:"settings-feishu-login-close","aria-label":t("settings.feishuLoginClose"),title:t("settings.feishuLoginClose"),onClick:e.onCloseFeishuLoginQr}),(0,n.jsx)("p",{children:t("settings.feishuLoginRequired")}),(0,n.jsx)("img",{src:e.feishuLoginQr,alt:t("settings.feishuLoginQrAlt")})]}):null]})]}),(0,n.jsxs)(Ae,{className:"settings-group-ops",children:[(0,n.jsx)(W,{title:t("settings.sectionMaintenance"),titleExtra:i.localDevInstall?(0,n.jsx)("span",{className:"settings-title-note",children:t("settings.autoUpdateLocalDev")}):i.autoUpdateSupported?null:(0,n.jsx)("span",{className:"settings-title-note",children:t("settings.autoUpdateUnsupportedInstall")}),children:(0,n.jsxs)("div",{className:"settings-maintenance-grid",children:[(0,n.jsxs)("div",{className:"settings-maintenance-update",children:[(0,n.jsx)(F,{title:t("settings.autoUpdate"),help:t("settings.autoUpdateHelp"),checked:C.enabled,disabled:I||v==="autoUpdate",onChange:r=>{let p={enabled:r,time:C.time};e.onSave("autoUpdate",{maintenance:{autoUpdate:p}},P=>({...P,maintenance:{...P.maintenance,autoUpdate:p}}))}}),(0,n.jsx)("div",{className:"maint-time",children:(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:t("settings.maintenanceTime")}),(0,n.jsx)("input",{type:"time",value:C.time,disabled:I||v==="autoUpdate",onChange:r=>{let p={enabled:C.enabled,time:r.currentTarget.value||"04:00"};e.onSave("autoUpdate",{maintenance:{autoUpdate:p}},P=>({...P,maintenance:{...P.maintenance,autoUpdate:p}}))}})]})})]}),(0,n.jsx)("div",{className:"settings-maintenance-restart",children:(0,n.jsx)(F,{title:t("settings.autoRestart"),help:t("settings.autoRestartHelp"),checked:i.maintenance.autoRestart?.enabled===!0,disabled:T||v==="autoRestart",onChange:r=>{let p={enabled:r};e.onSave("autoRestart",{maintenance:{autoRestart:p}},P=>({...P,maintenance:{...P.maintenance,autoRestart:p}}))}})})]})}),e.updateBlock]}),(0,n.jsx)("div",{className:"settings-status-row",children:(0,n.jsx)("span",{className:`oncall-status ${e.message?.cls??""}`,"data-settings-status":!0,children:e.message?.text??""})})]})}function Fe(e){let t=w(),i=e.settings.larkCliVersion,g=typeof i=="string"&&e.settings.larkCliMeetsRequirement===!0,m=g?t("settings.larkCliReady",{version:i}):typeof i=="string"?t("settings.larkCliOutdated",{version:i,minimum:e.settings.larkCliMinVersion??"-"}):t("settings.larkCliMissing");return(0,n.jsxs)("div",{className:`settings-lark-cli-status ${g?"is-ready":"is-warning"}`,children:[(0,n.jsx)("span",{"aria-hidden":"true"}),(0,n.jsx)("strong",{children:m}),g?null:(0,n.jsx)("code",{children:"npm i -g @larksuite/cli@latest"})]})}function Ae(e){let t=["settings-group",e.className].filter(Boolean).join(" ");return(0,n.jsx)("section",{className:t,children:(0,n.jsx)("article",{className:"bd-card settings-group-card",children:e.children})})}function W(e){let t=["settings-block",e.className].filter(Boolean).join(" ");return(0,n.jsx)("section",{className:t,children:(0,n.jsxs)("article",{className:"bd-card settings-card",children:[(0,n.jsxs)("div",{className:"settings-block-title-row",children:[(0,n.jsx)("h2",{className:"bd-section-title",children:e.title}),e.titleExtra?(0,n.jsx)("div",{className:"settings-block-title-extra",children:e.titleExtra}):null]}),e.children]})})}function He(e){let t=w(),i=e.value.trim(),g=e.effective||e.value.trim()||e.host,m=(0,f.useMemo)(()=>{let v=i&&!ve.includes(i)?[i,...ve]:ve;return[{value:"",label:t("settings.scheduleTimeZoneHost",{host:e.host})},...v.map(c=>({value:c,label:c}))]},[e.host,t,i]);return(0,n.jsxs)("div",{className:"settings-field-row settings-timezone-row",children:[(0,n.jsx)(D,{help:t("settings.scheduleTimeZoneHelp",{host:e.host,effective:g}),children:t("settings.scheduleTimeZone")}),(0,n.jsx)(E,{className:"settings-field-menu settings-timezone-menu",ariaLabel:t("settings.scheduleTimeZone"),value:i,label:q(m,i),options:m,disabled:e.disabled,onChange:v=>e.onSave(v===""?null:v)})]})}function F(e){return(0,n.jsxs)("label",{className:"toggle-row",children:[(0,n.jsx)("input",{type:"checkbox",checked:e.checked,disabled:e.disabled,onChange:t=>e.onChange(t.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"}),(0,n.jsx)("span",{className:"toggle-tx",children:(0,n.jsx)("strong",{children:(0,n.jsx)(D,{className:"settings-toggle-title",help:e.help,children:e.title})})})]})}function Ve(e){let t=w(),[i,g]=(0,f.useState)(e.value.source),[m,v]=(0,f.useState)(e.value.ref);(0,f.useEffect)(()=>{g(e.value.source),v(e.value.ref)},[e.value.source,e.value.ref]);let c=i.trim(),C=m.trim(),I=c!==e.value.source.trim()||C!==e.value.ref.trim(),T=()=>{e.disabled||!I||e.onSave({source:c,ref:C})};return(0,n.jsxs)("div",{className:"settings-subfield",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.herdrTraexPluginSourceHelp"),children:t("settings.herdrTraexPluginSource")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:i,placeholder:t("settings.herdrTraexPluginSourcePlaceholder"),disabled:e.disabled,onChange:k=>g(k.currentTarget.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),T())}})]}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.herdrTraexPluginRefHelp"),children:t("settings.herdrTraexPluginRef")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:m,placeholder:t("settings.herdrTraexPluginRefPlaceholder"),disabled:e.disabled,onChange:k=>v(k.currentTarget.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),T())}})]}),c?null:(0,n.jsx)("p",{className:"hint-warn-inline settings-subfield-hint",children:t("settings.herdrTraexPluginSourceRequired")}),e.value.recommendedSource&&(c!==e.value.recommendedSource||C!==e.value.recommendedRef)?(0,n.jsxs)("p",{className:"settings-subfield-hint",children:[t("settings.herdrTraexPluginRecommended")," ",(0,n.jsxs)("button",{type:"button",className:"settings-inline-link",disabled:e.disabled,onClick:()=>{g(e.value.recommendedSource),v(e.value.recommendedRef)},children:[e.value.recommendedSource,e.value.recommendedRef?` @ ${e.value.recommendedRef}`:""]})]}):null,(0,n.jsx)("div",{className:"actions",children:(0,n.jsx)("button",{type:"button",className:"page-primary-action",disabled:e.disabled||!I,onClick:T,children:t("settings.herdrTraexPluginSave")})})]})}function Ze(e){let t=w(),i;if(!e.canWrite)i=(0,n.jsx)("p",{className:"hint-warn",children:t("update.loginRequired")});else if(e.statusError)i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"hint-warn",children:[t("update.checkFailed"),": ",e.statusError]}),(0,n.jsx)("div",{className:"update-actions",children:(0,n.jsx)("button",{type:"button","data-up":"check",onClick:e.onCheck,children:t("update.btnCheck")})})]});else if(!e.status)i=(0,n.jsx)(re,{label:t("update.loading"),compact:!0});else{let g=e.status,m=g.localDevInstall||!g.updateSupported||e.busy;i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"update-version",children:[(0,n.jsxs)("span",{children:[t("update.current"),": ",(0,n.jsxs)("strong",{children:["v",g.current]})]})," ",(0,n.jsx)(We,{status:g})]}),g.node.ok?null:(0,n.jsx)("p",{className:"hint-warn",children:t("update.nodeWarn",{version:g.node.version,required:g.node.required})}),!g.localDevInstall&&!g.updateSupported?(0,n.jsx)("p",{className:"hint-warn",children:t("update.unsupportedInstall")}):null,g.installs.multiple?(0,n.jsx)(je,{entries:g.installs.entries}):null,(0,n.jsxs)("div",{className:"update-actions",children:[(0,n.jsx)("button",{type:"button","data-up":"check",disabled:e.busy,onClick:e.onCheck,children:t("update.btnCheck")}),(0,n.jsx)("button",{type:"button","data-up":"changelog",disabled:e.busy,onClick:e.onToggleChangelog,children:e.changelogOpen?t("update.btnChangelogHide"):t("update.btnChangelog")}),(0,n.jsx)("button",{type:"button",className:"page-primary-action","data-up":"update",disabled:m,onClick:e.onUpdate,children:t("update.btnUpdate")}),(0,n.jsx)("button",{type:"button","data-up":"restart",disabled:e.busy,onClick:e.onRestart,children:t("update.btnRestart")})]}),g.cliUpdates?.length?(0,n.jsx)(Ke,{entries:g.cliUpdates}):null,e.changelogOpen?(0,n.jsx)(qe,{changelog:e.changelog,ok:e.changelogOk,rateLimited:e.changelogRateLimited,releasesUrl:e.releasesUrl}):null,e.message?(0,n.jsx)("p",{className:`oncall-status ${e.message.cls??""}`,children:e.message.text}):null]})}return(0,n.jsx)(W,{className:"settings-update-block",title:t("update.section"),titleExtra:e.status?.localDevInstall?(0,n.jsx)("span",{className:"settings-title-note",children:t("update.localDev")}):e.status&&!e.status.updateSupported?(0,n.jsx)("span",{className:"settings-title-note",children:t("update.unsupportedInstall")}):null,children:i})}function Ke(e){let t=w();return(0,n.jsxs)("div",{className:"cli-runtime-updates",children:[(0,n.jsx)("strong",{children:t("update.runtimeTitle")}),(0,n.jsx)("ul",{children:e.entries.map(i=>(0,n.jsxs)("li",{className:i.updateAvailable?"is-behind":"",children:[(0,n.jsxs)("div",{className:"cli-runtime-update-head",children:[(0,n.jsx)("span",{children:"Codex"}),i.updateAvailable&&i.latest?(0,n.jsx)("span",{className:"update-badge update-badge-new",children:t("update.runtimeAvailable",{current:i.current??"?",latest:i.latest})}):i.latest?(0,n.jsx)("span",{className:"update-badge update-badge-ok",children:t("update.upToDate")}):(0,n.jsx)("span",{className:"hint-warn-inline",children:t("update.checkUnavailable")})]}),(0,n.jsx)("code",{children:i.binPath}),i.updateAvailable?(0,n.jsxs)("small",{children:[t("update.runtimeCommand"),": ",(0,n.jsx)("code",{children:i.updateCommand})]}):null]},`${i.cliId}:${i.binPath}`))}),(0,n.jsx)("p",{className:"settings-help",children:t("update.runtimeHelp")})]})}function We(e){let t=w(),i=e.status;return i.latest?i.behind?(0,n.jsx)("span",{className:"update-badge update-badge-new",children:t("update.newAvailable",{version:`v${i.latest}`})}):(0,n.jsx)("span",{className:"update-badge update-badge-ok",children:t("update.upToDate")}):(0,n.jsx)("span",{className:"hint-warn-inline",children:t("update.checkUnavailable")})}function je(e){let t=w();return(0,n.jsxs)("div",{className:"hint-warn",children:[(0,n.jsx)("p",{children:t("update.multiInstallWarn")}),(0,n.jsx)("ul",{className:"update-install-list",children:e.entries.map(i=>(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:i.binPath})," \u2192 ",we(i.kind,t)," ",(0,n.jsx)("small",{children:i.root})]},`${i.binPath}:${i.root}`))})]})}function qe(e){let t=w();if(e.changelog===null)return(0,n.jsx)(re,{label:t("update.changelogLoading"),compact:!0});if(!e.ok){let i=e.rateLimited?t("update.changelogRateLimited"):t("update.changelogFailed");return(0,n.jsxs)("p",{className:"hint-warn-inline",children:[i,e.releasesUrl?(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("a",{href:e.releasesUrl,target:"_blank",rel:"noopener",children:t("update.changelogViewOnGitHub")})]}):null]})}return e.changelog.length===0?(0,n.jsx)("p",{className:"empty",children:t("update.changelogEmpty")}):(0,n.jsx)("div",{className:"update-changelog",children:e.changelog.map(i=>{let g=i.name&&i.name!==`v${i.version}`?i.name:"",m=i.publishedAt?new Date(i.publishedAt).toLocaleDateString():"";return(0,n.jsxs)("details",{className:"update-release",open:!0,children:[(0,n.jsxs)("summary",{children:[(0,n.jsxs)("strong",{children:["v",i.version]})," ",g," ",(0,n.jsx)("small",{children:m})," ",(0,n.jsx)("a",{href:i.url,target:"_blank",rel:"noopener",children:"\u2197"})]}),(0,n.jsx)("pre",{className:"update-release-body",children:i.body||""})]},i.version)})})}function st(e){return Pe(e,(0,n.jsx)(_e,{}))}export{He as TimeZoneRow,st as renderSettingsPage};
|
|
1
|
+
import{b as w}from"./chunk-3PMN55Z6.js";import{a as q,c as re,i as Ce,k as D,p as E}from"./chunk-I35DXGM4.js";import{a as pe,r as fe}from"./chunk-RXVA6XW3.js";import{a as Pe}from"./chunk-SYC6D5XU.js";import{a as ke,d as oe}from"./chunk-5THX4DI2.js";import{c as te}from"./chunk-7SZRL6FY.js";var f=te(ke(),1);var y=te(ke(),1);var a=te(oe(),1),Re=["transcript_received","chat_received","participant_joined","participant_left","magic_share_started","magic_share_ended"],me=8e3,Be=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,xe="\u6301\u7EED\u6574\u7406\u4F1A\u8BAE\u7EAA\u8981\uFF0C\u91CD\u70B9\u8BB0\u5F55\u5DF2\u786E\u8BA4\u7684\u51B3\u7B56\u3001\u5F85\u529E\u4E8B\u9879\uFF08\u542B\u8D1F\u8D23\u4EBA\u548C\u622A\u6B62\u65F6\u95F4\uFF09\u4EE5\u53CA\u672A\u89E3\u51B3\u98CE\u9669\uFF1B\u5B57\u5E55\u4FEE\u8BA2\u65F6\u66F4\u65B0\u5DF2\u6709\u6761\u76EE\uFF0C\u4E0D\u91CD\u590D\u8BB0\u5F55\u540C\u4E00\u4E8B\u9879\u3002\u4EC5\u5728\u51FA\u73B0\u65B0\u7684\u5173\u952E\u51B3\u7B56\u3001\u660E\u786E\u5F85\u529E\u6216\u98CE\u9669\uFF0C\u6216\u88AB\u7528\u6237\u70B9\u540D\u65F6\uFF0C\u624D\u5728\u76D1\u542C\u7FA4\u8F93\u51FA\u7B80\u6D01\u589E\u91CF\uFF1B\u65E0\u5B9E\u8D28\u589E\u91CF\u65F6\u4FDD\u6301\u9759\u9ED8\uFF0C\u4E0D\u53D1\u9001\u786E\u8BA4\u6216\u5FC3\u8DF3\u3002\u9700\u8981\u5411\u4F1A\u8BAE\u5185\u53D1\u9001\u6587\u5B57\u6216\u8BED\u97F3\u65F6\uFF0C\u5FC5\u987B\u901A\u8FC7 botmux \u53D7\u7BA1 request-output/action gate \u63D0\u4EA4\uFF0C\u4E0D\u5F97\u7ED5\u8FC7\u6743\u9650\u3001\u6240\u6709\u6743\u4E0E\u5BA1\u6838\u7B56\u7565\u3002",Ne=0;function Se(){return Ne+=1,`p${Ne}`}function Te(e){return{...e,uiKey:Se(),isNew:!1}}function Le(e){let{uiKey:t,isNew:i,...g}=e;return g}function Q(e){return(0,a.jsxs)("span",{className:"vc-profile-field-head",children:[e.title,(0,a.jsx)(Ce,{label:e.title,children:(0,a.jsx)("span",{className:"vc-profile-help",children:e.help})})]})}function Me(e){let t=w();return e.enabled?e.canWrite?(0,a.jsx)(Ue,{canWrite:e.canWrite,listenerBotAppId:e.listenerBotAppId,listenerBotOptions:e.listenerBotOptions}):(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.needAuth")}):null}function Ue(e){let t=w(),i=(0,y.useRef)(!1),g=e.listenerBotOptions,[m,v]=(0,y.useState)(e.listenerBotAppId??g[0]?.larkAppId??""),[c,N]=(0,y.useState)(null),[I,S]=(0,y.useState)(null),[k,z]=(0,y.useState)(!1),[x,H]=(0,y.useState)(!1),[M,r]=(0,y.useState)(!1),[p,P]=(0,y.useState)(!1),[j,L]=(0,y.useState)({}),[G,ie]=(0,y.useState)(!1);(0,y.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);let V=(0,y.useRef)(0);(0,y.useEffect)(()=>{e.listenerBotAppId&&e.listenerBotAppId!==m&&!x&&v(e.listenerBotAppId)},[x,e.listenerBotAppId,m]);let J=(0,y.useCallback)(async s=>{let o=++V.current;if(N(null),H(!1),P(!1),L({}),!s){S(null);return}z(!0);try{let l=await fetch(`/api/vc-meeting/consumer-profiles?listenerBotAppId=${encodeURIComponent(s)}`),u=await l.json().catch(()=>({}));if(!i.current||V.current!==o)return;!l.ok||u?.ok!==!0?(N(null),S(typeof u?.error=="string"?u.error:`HTTP ${l.status}`)):(N({forBot:s,revision:u.revision,catalogState:u.catalogState==="explicit_empty"||u.catalogState==="legacy_or_partial"||u.catalogState==="profiles"?u.catalogState:"uninitialized",defaultMode:u.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(u.defaultConsumerIds)?u.defaultConsumerIds:[],profiles:(Array.isArray(u.profiles)?u.profiles:[]).map(Te),agentOptions:Array.isArray(u.agentOptions)?u.agentOptions:[],...u.migrationOffer==="enable_seeded_minutes_default"?{migrationOffer:u.migrationOffer}:{}}),S(null),H(!1))}catch(l){if(!i.current||V.current!==o)return;N(null),S(l instanceof Error?l.message:String(l))}finally{i.current&&V.current===o&&z(!1)}},[]);(0,y.useEffect)(()=>{J(m)},[J,m]);let T=(0,y.useCallback)(s=>{N(o=>o&&s(o)),H(!0),ie(!1)},[]),Z=(0,y.useCallback)((s,o)=>{T(l=>({...l,profiles:l.profiles.map(u=>u.uiKey===s?{...u,...o}:u)}))},[T]),ne=(0,y.useCallback)(async()=>{if(!c||M||k||!c.forBot||c.forBot!==m)return;let s={};if(c.profiles.forEach((o,l)=>{Be.test(o.id)||(s[`profiles[${l}].id`]=t("settings.vcProfiles.idInvalid")),(o.instructions??"").length>me&&(s[`profiles[${l}].instructions`]=t("settings.vcProfiles.instructionsTooLong"))}),Object.keys(s).length>0){L(s);return}r(!0),P(!1),L({});try{let o=await fetch("/api/vc-meeting/consumer-profiles",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({listenerBotAppId:c.forBot,expectedRevision:c.revision,defaultMode:c.defaultMode,defaultConsumerIds:c.defaultConsumerIds,profiles:c.profiles.map(Le)})}),l=await o.json().catch(()=>({}));if(!i.current||c.forBot!==m)return;if(o.status===409){P(!0);return}if(o.status===422){let u={};for(let R of Array.isArray(l?.fieldErrors)?l.fieldErrors:[])typeof R?.path=="string"&&typeof R?.message=="string"&&(u[R.path]=R.message);L(Object.keys(u).length>0?u:{profiles:t("settings.vcProfiles.validationFailed")});return}if(!o.ok||l?.ok!==!0){L({profiles:typeof l?.error=="string"?l.error:`HTTP ${o.status}`});return}N({forBot:c.forBot,revision:l.revision,catalogState:l.catalogState==="explicit_empty"||l.catalogState==="legacy_or_partial"||l.catalogState==="profiles"?l.catalogState:"uninitialized",defaultMode:l.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(l.defaultConsumerIds)?l.defaultConsumerIds:[],profiles:(Array.isArray(l.profiles)?l.profiles:[]).map(Te),agentOptions:Array.isArray(l.agentOptions)?l.agentOptions:[],...l.migrationOffer==="enable_seeded_minutes_default"?{migrationOffer:l.migrationOffer}:{}}),H(!1),ie(!0)}catch(o){if(!i.current)return;L({profiles:o instanceof Error?o.message:String(o)})}finally{i.current&&r(!1)}},[c,M,m,t]),X=(0,y.useMemo)(()=>g.map(s=>({value:s.larkAppId,label:s.botName||s.larkAppId})),[g]),Y=X.find(s=>s.value===m)?.label??m,ce=(0,y.useMemo)(()=>c?c.agentOptions.map(s=>{let o=[s.online?void 0:t("settings.vcProfiles.agentOffline"),s.workingDirReady?void 0:t("settings.vcProfiles.agentNoWorkingDir"),s.reliableTurnTerminal?void 0:t("settings.vcProfiles.agentNoReliableTerminal"),s.managedSideEffectIsolation?void 0:t("settings.vcProfiles.agentNoManagedIsolation")].filter(Boolean);return{value:s.appId,label:(0,a.jsxs)("span",{className:"vc-agent-option",children:[(0,a.jsxs)("span",{className:"vc-agent-option-name",children:[s.label,s.cliId?(0,a.jsx)("em",{className:"vc-agent-option-cli",children:s.cliId}):null]}),o.length>0?(0,a.jsxs)("span",{className:"vc-agent-option-warn",children:["\u26A0 ",o.join(" \xB7 ")]}):null]})}}):[],[c,t]),se=s=>{let o=c?.agentOptions.find(u=>u.appId===s);return o?!o.online||!o.workingDirReady||!o.reliableTurnTerminal||!o.managedSideEffectIsolation?`\u26A0 ${o.label}`:o.label:s},ae=(0,y.useCallback)(s=>{let l=["observe_only","meeting_text","meeting_voice","meeting_text_voice"].map(u=>({value:u,label:t(`settings.vcProfiles.preset.${u}`)}));return(!s.isNew||s.permissionPreset==="custom")&&l.push({value:"custom",label:t("settings.vcProfiles.preset.custom")}),l},[t]),de=(0,y.useCallback)(()=>{T(s=>({...s,profiles:[...s.profiles,{uiKey:Se(),isNew:!0,id:"",agentAppId:s.agentOptions[0]?.appId??"",responseMode:"silent",permissionPreset:"observe_only"}]}))},[T]),ue=(0,y.useCallback)(s=>{T(o=>({...o,profiles:o.profiles.filter(l=>l.uiKey!==s),defaultConsumerIds:o.defaultConsumerIds.filter(l=>o.profiles.some(u=>u.uiKey!==s&&u.id===l))}))},[T]);if(g.length===0)return null;let b=s=>j[s],B=!e.canWrite||M||k,O=c?.agentOptions.some(s=>s.workingDirReady&&s.reliableTurnTerminal&&s.managedSideEffectIsolation)??!1;return(0,a.jsxs)("div",{className:"vc-profiles-section",children:[(0,a.jsxs)("div",{className:"settings-field-row",children:[(0,a.jsx)(D,{help:t("settings.vcProfiles.help"),children:t("settings.vcProfiles.title")}),e.listenerBotAppId===null&&X.length>1?(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.listenerOwner")}),(0,a.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.listenerOwner"),disabled:k||M,value:m,label:q(X,m),options:X,onChange:s=>{s!==m&&(x&&!window.confirm(t("settings.vcProfiles.discardConfirm"))||v(s))}})]}):(0,a.jsx)("span",{className:"vc-profile-config-target",children:t("settings.vcProfiles.configuringBot",{bot:Y})})]}),(0,a.jsx)("p",{className:"hint vc-profiles-freeze",children:t("settings.vcProfiles.freezeNotice")}),k?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.loading")}):null,I?(0,a.jsx)("p",{className:"hint-warn",children:I==="bot_not_in_config"?t("settings.vcProfiles.botNotInConfig"):`${t("settings.vcProfiles.loadFailed")}: ${I}`}):null,p?(0,a.jsxs)("p",{className:"hint-warn",children:[t("settings.vcProfiles.conflict")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",onClick:()=>{J(m)},children:t("settings.vcProfiles.reload")})]}):null,b("profiles")?(0,a.jsx)("p",{className:"hint-warn",children:b("profiles")}):null,c?(0,a.jsxs)(a.Fragment,{children:[c.migrationOffer==="enable_seeded_minutes_default"?(0,a.jsxs)("p",{className:"hint-warn vc-profile-migration-offer",children:[t("settings.vcProfiles.migrationOffer")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",disabled:B||x,onClick:()=>T(s=>({...s,defaultMode:"agents",defaultConsumerIds:["minutes"],profiles:s.profiles.map(o=>o.id==="minutes"?{...o,instructions:xe,responseMode:"listener_thread",permissionPreset:"meeting_text_voice"}:o),migrationOffer:void 0})),children:t("settings.vcProfiles.migrationEnable")})]}):null,c.catalogState==="uninitialized"&&c.profiles.length===0&&!O?(0,a.jsx)("p",{className:"hint-warn",children:t("settings.vcProfiles.noEligibleDefaultAgent")}):null,c.catalogState==="legacy_or_partial"?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.legacyCatalog")}):null,c.profiles.map((s,o)=>(0,a.jsxs)("div",{className:"vc-profile-card",children:[(0,a.jsxs)("div",{className:"vc-profile-grid",children:[(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldId"),help:t("settings.vcProfiles.idHelp")})}),(0,a.jsx)("input",{type:"text",value:s.id,disabled:B||!s.isNew,placeholder:"minutes",onChange:l=>{let u=l.target.value,R=s.id;T(_=>({..._,profiles:_.profiles.map($=>$.uiKey===s.uiKey?{...$,id:u}:$),defaultConsumerIds:_.defaultConsumerIds.map($=>$===R&&R?u:$).filter($=>!!$)}))}}),b(`profiles[${o}].id`)?(0,a.jsx)("em",{className:"vc-profile-err",children:b(`profiles[${o}].id`)}):null]}),(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldLabel"),help:t("settings.vcProfiles.labelHelp")})}),(0,a.jsx)("input",{type:"text",value:s.label??"",disabled:B,onChange:l=>Z(s.uiKey,{label:l.target.value||void 0})}),b(`profiles[${o}].label`)?(0,a.jsx)("em",{className:"vc-profile-err",children:b(`profiles[${o}].label`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldAgent"),help:t("settings.vcProfiles.agentHelp")})}),(0,a.jsx)(E,{className:"vc-profile-agent-menu",ariaLabel:t("settings.vcProfiles.fieldAgent"),disabled:B,value:s.agentAppId,label:se(s.agentAppId),options:ce,onChange:l=>Z(s.uiKey,{agentAppId:l})}),b(`profiles[${o}].agentAppId`)?(0,a.jsx)("em",{className:"vc-profile-err",children:b(`profiles[${o}].agentAppId`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldResponseMode"),help:t("settings.vcProfiles.responseModeHelp")})}),(0,a.jsx)(E,{ariaLabel:t("settings.vcProfiles.fieldResponseMode"),disabled:B,value:s.responseMode,label:s.responseMode==="listener_thread"?t("settings.vcProfiles.responseListener"):t("settings.vcProfiles.responseSilent"),options:[{value:"silent",label:t("settings.vcProfiles.responseSilent")},{value:"listener_thread",label:t("settings.vcProfiles.responseListener")}],onChange:l=>Z(s.uiKey,{responseMode:l})}),b(`profiles[${o}].responseMode`)?(0,a.jsx)("em",{className:"vc-profile-err",children:b(`profiles[${o}].responseMode`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldPreset"),help:t("settings.vcProfiles.presetHelp")})}),(0,a.jsx)(E,{ariaLabel:t("settings.vcProfiles.fieldPreset"),disabled:B,value:s.permissionPreset,label:q(ae(s),s.permissionPreset),options:ae(s),onChange:l=>Z(s.uiKey,{permissionPreset:l})}),b(`profiles[${o}].permissionPreset`)?(0,a.jsx)("em",{className:"vc-profile-err",children:b(`profiles[${o}].permissionPreset`)}):null]})]}),(0,a.jsxs)("label",{className:"vc-profile-field vc-profile-instructions",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldInstructions"),help:t("settings.vcProfiles.instructionsHelp")}),(0,a.jsxs)("em",{className:"vc-profile-count",children:[(s.instructions??"").length,"/",me]})]}),(0,a.jsx)("textarea",{rows:4,maxLength:me,value:s.instructions??"",disabled:B,placeholder:t("settings.vcProfiles.instructionsPlaceholder"),onChange:l=>Z(s.uiKey,{instructions:l.target.value||void 0})}),b(`profiles[${o}].instructions`)?(0,a.jsx)("em",{className:"vc-profile-err",children:b(`profiles[${o}].instructions`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(Q,{title:t("settings.vcProfiles.fieldActivityTypes"),help:t("settings.vcProfiles.activityHelp")})}),(0,a.jsx)("div",{className:"vc-profile-activity",children:Re.map(l=>{let u=s.activityTypes?.includes(l)??!1;return(0,a.jsxs)("label",{className:"vc-profile-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:u,disabled:B,onChange:R=>{let _=new Set(s.activityTypes??[]);R.target.checked?_.add(l):_.delete(l),Z(s.uiKey,{activityTypes:_.size>0?[..._]:void 0})}}),t(`settings.vcProfiles.activity.${l}`)]},l)})}),(0,a.jsx)("em",{className:"vc-profile-hint",children:t("settings.vcProfiles.activityAllHint")}),b(`profiles[${o}].activityTypes`)?(0,a.jsx)("em",{className:"vc-profile-err",children:b(`profiles[${o}].activityTypes`)}):null]}),e.canWrite?(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-remove",disabled:M||k,onClick:()=>ue(s.uiKey),children:t("settings.vcProfiles.remove")}):null]},s.uiKey)),e.canWrite?(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",disabled:M||k,onClick:de,children:t("settings.vcProfiles.add")}):null,(0,a.jsxs)("div",{className:"settings-field-row",children:[(0,a.jsx)(D,{help:t("settings.vcProfiles.defaultModeHelp"),children:t("settings.vcProfiles.defaultMode")}),(0,a.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.defaultMode"),disabled:B,value:c.defaultMode,label:c.defaultMode==="agents"?t("settings.vcProfiles.defaultModeAgents"):t("settings.vcProfiles.defaultModeListenOnly"),options:[{value:"listenOnly",label:t("settings.vcProfiles.defaultModeListenOnly")},{value:"agents",label:t("settings.vcProfiles.defaultModeAgents")}],onChange:s=>T(o=>({...o,defaultMode:s==="agents"?"agents":"listenOnly"}))})]}),c.defaultMode==="agents"?(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.defaultConsumers")}),(0,a.jsx)("div",{className:"vc-profile-activity",children:c.profiles.filter(s=>s.id).map(s=>{let o=c.defaultConsumerIds.includes(s.id);return(0,a.jsxs)("label",{className:"vc-profile-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:o,disabled:B,onChange:l=>{T(u=>({...u,defaultConsumerIds:l.target.checked?[...u.defaultConsumerIds,s.id]:u.defaultConsumerIds.filter(R=>R!==s.id)}))}}),s.label||s.id]},s.uiKey)})}),b("defaultConsumerIds")?(0,a.jsx)("em",{className:"vc-profile-err",children:b("defaultConsumerIds")}):null,b("defaultMode")?(0,a.jsx)("em",{className:"vc-profile-err",children:b("defaultMode")}):null]}):null,e.canWrite?(0,a.jsxs)("div",{className:"vc-profiles-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-save",disabled:!x||M||p,onClick:()=>{ne()},children:t(M?"settings.vcProfiles.saving":"settings.vcProfiles.save")}),G?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.saved")}):null,x&&!M?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.unsaved")}):null]}):null]}):null]})}var n=te(oe(),1),ve=["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Asia/Kolkata","UTC","Europe/London","Europe/Paris","Europe/Moscow","America/Los_Angeles","America/New_York","America/Sao_Paulo","Australia/Sydney"];function De(e,t){if(!e||typeof e!="object")return null;if(e.failed){let i=e.failed.step==="install"?t("settings.herdrTraexInstallStepInstall"):t("settings.herdrTraexInstallStepAction");return{text:`${t("settings.herdrTraexInstallFailed")}\uFF08${i}\uFF09: ${e.failed.reason??""}`,cls:"hint-warn-inline"}}if(e.skippedReason==="plugin_unsupported"){let i=typeof e.herdrVersion=="string"&&e.herdrVersion?` (${e.herdrVersion})`:"";return{text:`${t("settings.herdrTraexUnsupported")}${i}`,cls:"hint-warn-inline"}}return e.installed||e.actionInvoked?{text:t("settings.herdrTraexInstalled"),cls:"hint-ok"}:e.alreadyInstalled?{text:t("settings.herdrTraexAlreadyInstalled"),cls:"hint-ok"}:null}function he(e){return{publicReadOnly:e?.publicReadOnly===!0,openTerminalInFeishu:e?.openTerminalInFeishu===!0,enableLocalCliOpen:e?.enableLocalCliOpen===!0,localCliOpenMode:e?.localCliOpenMode==="resume"?"resume":"attach",chatBotDiscovery:e?.chatBotDiscovery!==!1,herdrTraexPlugin:{enabled:e?.herdrTraexPlugin?.enabled===!0,source:typeof e?.herdrTraexPlugin?.source=="string"?e.herdrTraexPlugin.source:"",ref:typeof e?.herdrTraexPlugin?.ref=="string"?e.herdrTraexPlugin.ref:"",recommendedSource:typeof e?.herdrTraexPlugin?.recommendedSource=="string"?e.herdrTraexPlugin.recommendedSource:"",recommendedRef:typeof e?.herdrTraexPlugin?.recommendedRef=="string"?e.herdrTraexPlugin.recommendedRef:""},vcMeetingAgent:{enabled:e?.vcMeetingAgent?.enabled!==!1,listenerBotAppId:typeof e?.vcMeetingAgent?.listenerBotAppId=="string"?e.vcMeetingAgent.listenerBotAppId:null,listenerBotOptions:Array.isArray(e?.vcMeetingAgent?.listenerBotOptions)?e.vcMeetingAgent.listenerBotOptions:[],larkCliVersion:e?.vcMeetingAgent?.larkCliVersion===void 0?void 0:e.vcMeetingAgent.larkCliVersion??null,larkCliMeetsRequirement:e?.vcMeetingAgent?.larkCliMeetsRequirement===!0,larkCliMinVersion:typeof e?.vcMeetingAgent?.larkCliMinVersion=="string"?e.vcMeetingAgent.larkCliMinVersion:void 0},repoPickerMode:e?.repoPickerMode==="repos"?"repos":"all",maintenance:e?.maintenance&&typeof e.maintenance=="object"?e.maintenance:{},localDevInstall:e?.localDevInstall===!0,autoUpdateSupported:e?.autoUpdateSupported!==!1,whiteboard:{enabled:e?.whiteboard?.enabled===!0},remoteAccess:e?.remoteAccess===!0,scheduleTimeZone:typeof e?.scheduleTimeZone=="string"?e.scheduleTimeZone:"",hostTimeZone:typeof e?.hostTimeZone=="string"&&e.hostTimeZone?e.hostTimeZone:"UTC",effectiveScheduleTimeZone:typeof e?.effectiveScheduleTimeZone=="string"&&e.effectiveScheduleTimeZone?e.effectiveScheduleTimeZone:typeof e?.scheduleTimeZone=="string"&&e.scheduleTimeZone?e.scheduleTimeZone:typeof e?.hostTimeZone=="string"&&e.hostTimeZone?e.hostTimeZone:"UTC"}}function Ee(e,t){let i=e?.[t]??{};return{enabled:i.enabled===!0,time:typeof i.time=="string"?i.time:"04:00"}}function we(e,t){return t(e==="npm-global"?"update.kindNpm":e==="pnpm-global"?"update.kindPnpm":e==="yarn-global"?"update.kindYarn":e==="bun-global"?"update.kindBun":e==="source-checkout"?"update.kindSource":"update.kindUnknown")}function _e(){let e=w(),t=(0,f.useRef)(!1),i=(0,f.useRef)(new Set),[g,m]=(0,f.useState)(null),[v,c]=(0,f.useState)(!1),[N,I]=(0,f.useState)(null),[S,k]=(0,f.useState)(!0),[z,x]=(0,f.useState)(!1),[H,M]=(0,f.useState)(null),[r,p]=(0,f.useState)(null),[P,j]=(0,f.useState)(null),[L,G]=(0,f.useState)(null),[ie,V]=(0,f.useState)(null),[J,T]=(0,f.useState)(null),[Z,ne]=(0,f.useState)(!1),[X,Y]=(0,f.useState)(!0),[ce,se]=(0,f.useState)(!1),[ae,de]=(0,f.useState)(""),[ue,b]=(0,f.useState)(!1),[B,O]=(0,f.useState)(null),s=(0,f.useCallback)(()=>{for(let d of i.current)window.clearTimeout(d);i.current.clear()},[]),o=(0,f.useCallback)((d,h)=>{let C=window.setTimeout(()=>{i.current.delete(C),d()},h);return i.current.add(C),C},[]),l=(0,f.useCallback)(async()=>{try{let d=await fetch("/api/update/status"),h=await d.json().catch(()=>({}));if(!t.current)return;if(!d.ok){G(null),V(h?.error??`HTTP ${d.status}`);return}G(h),V(null)}catch(d){if(!t.current)return;G(null),V(d instanceof Error?d.message:String(d))}},[]),u=(0,f.useCallback)(async()=>{try{let d=await fetch("/api/settings"),h=await d.json().catch(()=>({}));if(!t.current)return;if(!d.ok){m(null),I(h?.error??`HTTP ${d.status}`),c(!0);return}m(he(h.settings)),k(h.authed===!0),x(h.bound===!0),I(null),c(!0)}catch(d){if(!t.current)return;m(null),I(d instanceof Error?d.message:String(d)),c(!0)}},[]);(0,f.useEffect)(()=>(t.current=!0,u(),()=>{t.current=!1,s()}),[s,u]),(0,f.useEffect)(()=>{v&&(b(!1),O(null),ne(!1),S&&l())},[S,l,v]);async function R(d,h,C){if(!g)return;let A=g;m(C(g)),M(d),p({text:e("settings.saving")});try{let K=await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),U=await K.json().catch(()=>({}));if(!t.current)return;if(!K.ok||U.ok===!1)throw typeof U?.feishuLoginQr=="string"&&U.feishuLoginQr&&j(U.feishuLoginQr),new Error(U?.error??`HTTP ${K.status}`);j(null);let ee=he(U.settings);m(ee),fe.publicReadOnly=ee.publicReadOnly,pe.setScheduleTimeZone(ee.effectiveScheduleTimeZone);let le=De(U.herdrTraexInstall,e);p(le??{text:e("settings.saved"),cls:"hint-ok"})}catch(K){if(!t.current)return;let U=!1;try{let le=await fetch("/api/settings"),ye=await le.json().catch(()=>({}));if(t.current&&le.ok&&ye?.settings){let ge=he(ye.settings);m(ge),fe.publicReadOnly=ge.publicReadOnly,pe.setScheduleTimeZone(ge.effectiveScheduleTimeZone),U=!0}}catch{}if(!t.current)return;U||m(A);let ee=K instanceof Error?K.message:String(K);p({text:U?`${e("settings.saveReconciled")}: ${ee}`:`${e("settings.saveFailed")}: ${ee}`,cls:"hint-warn-inline"})}finally{t.current&&M(null)}}async function _(){T(null),Y(!0),se(!1);try{let d=await fetch("/api/update/changelog"),h=await d.json().catch(()=>({}));if(!t.current)return;de(typeof h?.releasesUrl=="string"?h.releasesUrl:""),d.ok?(T(Array.isArray(h.releases)?h.releases:[]),Y(h.ok!==!1),se(h.rateLimited===!0)):(T([]),Y(!1))}catch{if(!t.current)return;T([]),Y(!1)}}function $(){let d=Date.now(),h=async()=>{if(t.current){if(Date.now()-d>9e4){b(!1),O({text:e("update.restartSlow"),cls:"hint-warn-inline"});return}try{let C=await fetch("/__health",{cache:"no-store"});if(!t.current)return;if(C.ok){location.reload();return}}catch{}t.current&&o(()=>{h()},2e3)}};o(()=>{h()},3e3)}async function be(d){b(!0),O({text:e("update.restarting")});try{let h=await fetch("/api/update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d?{update:d}:{})}),C=await h.json().catch(()=>({}));if(!h.ok||C.ok===!1)throw new Error(String(C.detail??C.error??`HTTP ${h.status}`));if(!t.current)return}catch(h){if(!t.current)return;b(!1),O({text:e("update.restartFailed",{detail:h instanceof Error?h.message:String(h)}),cls:"hint-warn-inline"});return}$()}async function Ie(){let d=L;if(!d)return;if(!d.node.ok){window.alert(e("update.nodeTooOldAlert",{version:d.node.version,required:d.node.required}));return}if(!d.updateSupported||!d.updateCommand){window.alert(e("update.unsupportedInstall"));return}if(d.installs.multiple){let C=d.installs.entries.map(A=>`\u2022 ${A.binPath} (${we(A.kind,e)})`).join(`
|
|
2
|
+
`);if(!window.confirm(e("update.confirmMultiInstall",{paths:C})))return}let h=d.latest?e("update.confirmUpdate",{version:`v${d.latest}`,command:d.updateCommand}):e("update.confirmUpdateNoVer",{command:d.updateCommand});if(window.confirm(h)){b(!0),O({text:e("update.updating",{command:d.updateCommand})});try{let C=await fetch("/api/update/run",{method:"POST"}),A=await C.json().catch(()=>({}));if(!t.current)return;if(!C.ok||A.ok===!1){let K=A?.detail??A?.error??`HTTP ${C.status}`;b(!1),O({text:e("update.updateFailed",{detail:K}),cls:"hint-warn-inline"});return}A.changed?(b(!1),O({text:e("update.updatedChanged",{old:`v${A.oldVersion}`,new:`v${A.newVersion}`}),cls:"hint-ok"}),window.confirm(e("update.confirmRestart"))?await be({oldVersion:A.oldVersion,newVersion:A.newVersion}):t.current&&O({text:e("update.noRestartHint"),cls:"hint-ok"})):(b(!1),O({text:e("update.alreadyLatestRun",{version:`v${A.newVersion}`}),cls:"hint-ok"}),await l())}catch(C){if(!t.current)return;b(!1),O({text:e("update.updateFailed",{detail:C instanceof Error?C.message:String(C)}),cls:"hint-warn-inline"})}}}let Oe=g?(0,n.jsx)($e,{settings:g,canWrite:S,bound:z,savingKey:H,message:r,updateBlock:(0,n.jsx)(Ze,{canWrite:S,status:L,statusError:ie,changelog:J,changelogOpen:Z,changelogOk:X,changelogRateLimited:ce,releasesUrl:ae,busy:ue,message:B,onCheck:()=>{G(null),T(null),ne(!1),O(null),V(null),l()},onToggleChangelog:()=>{let d=!Z;ne(d),d&&J===null&&_()},onUpdate:()=>{Ie()},onRestart:()=>{window.confirm(e("update.confirmPlainRestart"))&&be(null)}}),feishuLoginQr:P,onCloseFeishuLoginQr:()=>j(null),onSave:R}):N?(0,n.jsxs)("p",{className:"hint-warn",children:[e("settings.loadFailed"),": ",N]}):(0,n.jsx)(re,{label:e("settings.loading")});return(0,n.jsxs)("section",{className:"page settings-page",children:[(0,n.jsx)("div",{className:"page-heading",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"eyebrow",children:e("nav.settings")}),(0,n.jsx)("h1",{children:e("settings.title")})]})}),Oe]})}function $e(e){let t=w(),{settings:i,canWrite:g,bound:m,savingKey:v}=e,c=!g,N=Ee(i.maintenance,"autoUpdate"),I=!g||i.localDevInstall||!i.autoUpdateSupported,S=!g||i.maintenance.autoUpdate?.enabled!==!0,k=(r,p)=>{e.onSave(r,{[r]:p},P=>({...P,[r]:p}))},z=r=>e.onSave("herdrTraexPlugin",{herdrTraexPlugin:r},p=>({...p,herdrTraexPlugin:{...p.herdrTraexPlugin,...r}})),x=(0,f.useMemo)(()=>[{value:"all",label:t("settings.repoPickerModeAll")},{value:"repos",label:t("settings.repoPickerModeRepos")}],[t]),H=(0,f.useMemo)(()=>[{value:"attach",label:t("settings.localCliOpenModeAttach")},{value:"resume",label:t("settings.localCliOpenModeResume")}],[t]),M=(0,f.useMemo)(()=>[{value:"",label:t("settings.vcMeetingListenerBotAuto")},...i.vcMeetingAgent.listenerBotOptions.map(r=>{let p=r.botName||r.larkAppId,P=r.cliId?` \xB7 ${r.cliId}`:"",j=[r.vcMeetingAgentEnabled===!0?void 0:t("settings.vcMeetingListenerBotDisabled"),r.hasLarkCliProfile===!0?void 0:t("settings.vcMeetingListenerBotNoProfile")].filter(Boolean),L=j.length>0?` \xB7 ${j.join(" \xB7 ")}`:"";return{value:r.larkAppId,label:`${p}${P}${L}`}})],[i.vcMeetingAgent.listenerBotOptions,t]);return(0,n.jsxs)("div",{className:"settings-layout",children:[g?null:(0,n.jsx)("article",{className:"bd-card settings-card settings-alert-card",children:(0,n.jsx)("p",{className:"hint-warn",children:t("settings.readOnlyVisitor")})}),(0,n.jsxs)(Ae,{className:"settings-group-main",children:[(0,n.jsxs)(W,{title:t("settings.sectionAccess"),children:[(0,n.jsx)(F,{title:t("settings.publicReadOnly"),help:t("settings.publicReadOnlyHelp"),checked:i.publicReadOnly,disabled:c||v==="publicReadOnly",onChange:r=>k("publicReadOnly",r)}),m?(0,n.jsx)(F,{title:t("settings.remoteAccess"),help:t("settings.remoteAccessHelp"),checked:i.remoteAccess,disabled:c||v==="remoteAccess",onChange:r=>k("remoteAccess",r)}):null]}),(0,n.jsxs)(W,{title:t("settings.sectionCards"),children:[(0,n.jsx)(F,{title:t("settings.openTerminalInFeishu"),help:t("settings.openTerminalInFeishuHelp"),checked:i.openTerminalInFeishu,disabled:c||v==="openTerminalInFeishu",onChange:r=>k("openTerminalInFeishu",r)}),(0,n.jsx)(F,{title:t("settings.enableLocalCliOpen"),help:t("settings.enableLocalCliOpenHelp"),checked:i.enableLocalCliOpen,disabled:c||v==="enableLocalCliOpen",onChange:r=>k("enableLocalCliOpen",r)}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.localCliOpenModeHelp"),children:t("settings.localCliOpenMode")}),(0,n.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.localCliOpenMode"),disabled:c||!i.enableLocalCliOpen||v==="localCliOpenMode",value:i.localCliOpenMode,label:q(H,i.localCliOpenMode),options:H,onChange:r=>{e.onSave("localCliOpenMode",{localCliOpenMode:r},p=>({...p,localCliOpenMode:r}))}})]})]}),(0,n.jsxs)(W,{title:t("settings.sectionExperimental"),children:[(0,n.jsx)(F,{title:t("settings.chatBotDiscovery"),help:t("settings.chatBotDiscoveryHelp"),checked:i.chatBotDiscovery,disabled:c||v==="chatBotDiscovery",onChange:r=>k("chatBotDiscovery",r)}),(0,n.jsx)(F,{title:t("settings.herdrTraexPlugin"),help:t("settings.herdrTraexPluginHelp"),checked:i.herdrTraexPlugin.enabled,disabled:c||v==="herdrTraexPlugin",onChange:r=>z({enabled:r})}),i.herdrTraexPlugin.enabled?(0,n.jsx)(Ve,{value:i.herdrTraexPlugin,disabled:c||v==="herdrTraexPlugin",onSave:r=>z(r)}):null]}),(0,n.jsx)(W,{title:t("settings.sectionWhiteboard"),children:(0,n.jsx)(F,{title:t("settings.whiteboardEnable"),help:t("settings.whiteboardEnableHelp"),checked:i.whiteboard.enabled,disabled:c||v==="whiteboard",onChange:r=>{e.onSave("whiteboard",{whiteboard:{enabled:r}},p=>({...p,whiteboard:{enabled:r}}))}})}),(0,n.jsx)(W,{title:t("settings.sectionRepoPicker"),children:(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.repoPickerModeHelp"),children:t("settings.repoPickerMode")}),(0,n.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.repoPickerMode"),disabled:c||v==="repoPickerMode",value:i.repoPickerMode,label:q(x,i.repoPickerMode),options:x,onChange:r=>{e.onSave("repoPickerMode",{repoPickerMode:r},p=>({...p,repoPickerMode:r}))}})]})}),(0,n.jsx)(W,{title:t("settings.sectionSchedule"),children:(0,n.jsx)(He,{value:i.scheduleTimeZone,host:i.hostTimeZone,effective:i.effectiveScheduleTimeZone,disabled:c||v==="scheduleTimeZone",onSave:r=>{e.onSave("scheduleTimeZone",{scheduleTimeZone:r},p=>({...p,scheduleTimeZone:r??""}))}})}),(0,n.jsxs)(W,{className:"settings-vc-block",title:t("settings.sectionVcMeetingAgent"),children:[(0,n.jsx)(F,{title:t("settings.vcMeetingAgent"),help:t("settings.vcMeetingAgentHelp"),checked:i.vcMeetingAgent.enabled,disabled:c||v==="vcMeetingAgent",onChange:r=>{e.onSave("vcMeetingAgent",{vcMeetingAgent:{enabled:r}},p=>({...p,vcMeetingAgent:{...p.vcMeetingAgent,enabled:r}}))}}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.vcMeetingListenerBotHelp"),children:t("settings.vcMeetingListenerBot")}),(0,n.jsx)(E,{className:"settings-field-menu",ariaLabel:t("settings.vcMeetingListenerBot"),disabled:c||v==="vcMeetingAgent",value:i.vcMeetingAgent.listenerBotAppId??"",label:q(M,i.vcMeetingAgent.listenerBotAppId??""),options:M,onChange:r=>{let p=r||null;e.onSave("vcMeetingAgent",{vcMeetingAgent:{listenerBotAppId:p}},P=>({...P,vcMeetingAgent:{...P.vcMeetingAgent,listenerBotAppId:p}}))}})]}),(0,n.jsx)(Fe,{settings:i.vcMeetingAgent}),(0,n.jsx)(Me,{enabled:i.vcMeetingAgent.enabled,canWrite:g,listenerBotAppId:i.vcMeetingAgent.listenerBotAppId,listenerBotOptions:i.vcMeetingAgent.listenerBotOptions}),e.feishuLoginQr?(0,n.jsxs)("div",{className:"settings-feishu-login",children:[(0,n.jsx)("button",{type:"button",className:"settings-feishu-login-close","aria-label":t("settings.feishuLoginClose"),title:t("settings.feishuLoginClose"),onClick:e.onCloseFeishuLoginQr}),(0,n.jsx)("p",{children:t("settings.feishuLoginRequired")}),(0,n.jsx)("img",{src:e.feishuLoginQr,alt:t("settings.feishuLoginQrAlt")})]}):null]})]}),(0,n.jsxs)(Ae,{className:"settings-group-ops",children:[(0,n.jsx)(W,{title:t("settings.sectionMaintenance"),titleExtra:i.localDevInstall?(0,n.jsx)("span",{className:"settings-title-note",children:t("settings.autoUpdateLocalDev")}):i.autoUpdateSupported?null:(0,n.jsx)("span",{className:"settings-title-note",children:t("settings.autoUpdateUnsupportedInstall")}),children:(0,n.jsxs)("div",{className:"settings-maintenance-grid",children:[(0,n.jsxs)("div",{className:"settings-maintenance-update",children:[(0,n.jsx)(F,{title:t("settings.autoUpdate"),help:t("settings.autoUpdateHelp"),checked:N.enabled,disabled:I||v==="autoUpdate",onChange:r=>{let p={enabled:r,time:N.time};e.onSave("autoUpdate",{maintenance:{autoUpdate:p}},P=>({...P,maintenance:{...P.maintenance,autoUpdate:p}}))}}),(0,n.jsx)("div",{className:"maint-time",children:(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:t("settings.maintenanceTime")}),(0,n.jsx)("input",{type:"time",value:N.time,disabled:I||v==="autoUpdate",onChange:r=>{let p={enabled:N.enabled,time:r.currentTarget.value||"04:00"};e.onSave("autoUpdate",{maintenance:{autoUpdate:p}},P=>({...P,maintenance:{...P.maintenance,autoUpdate:p}}))}})]})})]}),(0,n.jsx)("div",{className:"settings-maintenance-restart",children:(0,n.jsx)(F,{title:t("settings.autoRestart"),help:t("settings.autoRestartHelp"),checked:i.maintenance.autoRestart?.enabled===!0,disabled:S||v==="autoRestart",onChange:r=>{let p={enabled:r};e.onSave("autoRestart",{maintenance:{autoRestart:p}},P=>({...P,maintenance:{...P.maintenance,autoRestart:p}}))}})})]})}),e.updateBlock]}),(0,n.jsx)("div",{className:"settings-status-row",children:(0,n.jsx)("span",{className:`oncall-status ${e.message?.cls??""}`,"data-settings-status":!0,children:e.message?.text??""})})]})}function Fe(e){let t=w(),i=e.settings.larkCliVersion,g=typeof i=="string"&&e.settings.larkCliMeetsRequirement===!0,m=g?t("settings.larkCliReady",{version:i}):typeof i=="string"?t("settings.larkCliOutdated",{version:i,minimum:e.settings.larkCliMinVersion??"-"}):t("settings.larkCliMissing");return(0,n.jsxs)("div",{className:`settings-lark-cli-status ${g?"is-ready":"is-warning"}`,children:[(0,n.jsx)("span",{"aria-hidden":"true"}),(0,n.jsx)("strong",{children:m}),g?null:(0,n.jsx)("code",{children:"npm i -g @larksuite/cli@latest"})]})}function Ae(e){let t=["settings-group",e.className].filter(Boolean).join(" ");return(0,n.jsx)("section",{className:t,children:(0,n.jsx)("article",{className:"bd-card settings-group-card",children:e.children})})}function W(e){let t=["settings-block",e.className].filter(Boolean).join(" ");return(0,n.jsx)("section",{className:t,children:(0,n.jsxs)("article",{className:"bd-card settings-card",children:[(0,n.jsxs)("div",{className:"settings-block-title-row",children:[(0,n.jsx)("h2",{className:"bd-section-title",children:e.title}),e.titleExtra?(0,n.jsx)("div",{className:"settings-block-title-extra",children:e.titleExtra}):null]}),e.children]})})}function He(e){let t=w(),i=e.value.trim(),g=e.effective||e.value.trim()||e.host,m=(0,f.useMemo)(()=>{let v=i&&!ve.includes(i)?[i,...ve]:ve;return[{value:"",label:t("settings.scheduleTimeZoneHost",{host:e.host})},...v.map(c=>({value:c,label:c}))]},[e.host,t,i]);return(0,n.jsxs)("div",{className:"settings-field-row settings-timezone-row",children:[(0,n.jsx)(D,{help:t("settings.scheduleTimeZoneHelp",{host:e.host,effective:g}),children:t("settings.scheduleTimeZone")}),(0,n.jsx)(E,{className:"settings-field-menu settings-timezone-menu",ariaLabel:t("settings.scheduleTimeZone"),value:i,label:q(m,i),options:m,disabled:e.disabled,onChange:v=>e.onSave(v===""?null:v)})]})}function F(e){return(0,n.jsxs)("label",{className:"toggle-row",children:[(0,n.jsx)("input",{type:"checkbox",checked:e.checked,disabled:e.disabled,onChange:t=>e.onChange(t.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"}),(0,n.jsx)("span",{className:"toggle-tx",children:(0,n.jsx)("strong",{children:(0,n.jsx)(D,{className:"settings-toggle-title",help:e.help,children:e.title})})})]})}function Ve(e){let t=w(),[i,g]=(0,f.useState)(e.value.source),[m,v]=(0,f.useState)(e.value.ref);(0,f.useEffect)(()=>{g(e.value.source),v(e.value.ref)},[e.value.source,e.value.ref]);let c=i.trim(),N=m.trim(),I=c!==e.value.source.trim()||N!==e.value.ref.trim(),S=()=>{e.disabled||!I||e.onSave({source:c,ref:N})};return(0,n.jsxs)("div",{className:"settings-subfield",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.herdrTraexPluginSourceHelp"),children:t("settings.herdrTraexPluginSource")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:i,placeholder:t("settings.herdrTraexPluginSourcePlaceholder"),disabled:e.disabled,onChange:k=>g(k.currentTarget.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),S())}})]}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(D,{help:t("settings.herdrTraexPluginRefHelp"),children:t("settings.herdrTraexPluginRef")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:m,placeholder:t("settings.herdrTraexPluginRefPlaceholder"),disabled:e.disabled,onChange:k=>v(k.currentTarget.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),S())}})]}),c?null:(0,n.jsx)("p",{className:"hint-warn-inline settings-subfield-hint",children:t("settings.herdrTraexPluginSourceRequired")}),e.value.recommendedSource&&(c!==e.value.recommendedSource||N!==e.value.recommendedRef)?(0,n.jsxs)("p",{className:"settings-subfield-hint",children:[t("settings.herdrTraexPluginRecommended")," ",(0,n.jsxs)("button",{type:"button",className:"settings-inline-link",disabled:e.disabled,onClick:()=>{g(e.value.recommendedSource),v(e.value.recommendedRef)},children:[e.value.recommendedSource,e.value.recommendedRef?` @ ${e.value.recommendedRef}`:""]})]}):null,(0,n.jsx)("div",{className:"actions",children:(0,n.jsx)("button",{type:"button",className:"page-primary-action",disabled:e.disabled||!I,onClick:S,children:t("settings.herdrTraexPluginSave")})})]})}function Ze(e){let t=w(),i;if(!e.canWrite)i=(0,n.jsx)("p",{className:"hint-warn",children:t("update.loginRequired")});else if(e.statusError)i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"hint-warn",children:[t("update.checkFailed"),": ",e.statusError]}),(0,n.jsx)("div",{className:"update-actions",children:(0,n.jsx)("button",{type:"button","data-up":"check",onClick:e.onCheck,children:t("update.btnCheck")})})]});else if(!e.status)i=(0,n.jsx)(re,{label:t("update.loading"),compact:!0});else{let g=e.status,m=g.localDevInstall||!g.updateSupported||e.busy;i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"update-version",children:[(0,n.jsxs)("span",{children:[t("update.current"),": ",(0,n.jsxs)("strong",{children:["v",g.current]})]})," ",(0,n.jsx)(We,{status:g})]}),g.node.ok?null:(0,n.jsx)("p",{className:"hint-warn",children:t("update.nodeWarn",{version:g.node.version,required:g.node.required})}),!g.localDevInstall&&!g.updateSupported?(0,n.jsx)("p",{className:"hint-warn",children:t("update.unsupportedInstall")}):null,g.installs.multiple?(0,n.jsx)(je,{entries:g.installs.entries}):null,(0,n.jsxs)("div",{className:"update-actions",children:[(0,n.jsx)("button",{type:"button","data-up":"check",disabled:e.busy,onClick:e.onCheck,children:t("update.btnCheck")}),(0,n.jsx)("button",{type:"button","data-up":"changelog",disabled:e.busy,onClick:e.onToggleChangelog,children:e.changelogOpen?t("update.btnChangelogHide"):t("update.btnChangelog")}),(0,n.jsx)("button",{type:"button",className:"page-primary-action","data-up":"update",disabled:m,onClick:e.onUpdate,children:t("update.btnUpdate")}),(0,n.jsx)("button",{type:"button","data-up":"restart",disabled:e.busy,onClick:e.onRestart,children:t("update.btnRestart")})]}),g.cliUpdates?.length?(0,n.jsx)(Ke,{entries:g.cliUpdates}):null,e.changelogOpen?(0,n.jsx)(qe,{changelog:e.changelog,ok:e.changelogOk,rateLimited:e.changelogRateLimited,releasesUrl:e.releasesUrl}):null,e.message?(0,n.jsx)("p",{className:`oncall-status ${e.message.cls??""}`,children:e.message.text}):null]})}return(0,n.jsx)(W,{className:"settings-update-block",title:t("update.section"),titleExtra:e.status?.localDevInstall?(0,n.jsx)("span",{className:"settings-title-note",children:t("update.localDev")}):e.status&&!e.status.updateSupported?(0,n.jsx)("span",{className:"settings-title-note",children:t("update.unsupportedInstall")}):null,children:i})}function Ke(e){let t=w();return(0,n.jsxs)("div",{className:"cli-runtime-updates",children:[(0,n.jsx)("strong",{children:t("update.runtimeTitle")}),(0,n.jsx)("ul",{children:e.entries.map(i=>(0,n.jsxs)("li",{className:i.updateAvailable?"is-behind":"",children:[(0,n.jsxs)("div",{className:"cli-runtime-update-head",children:[(0,n.jsx)("span",{children:"Codex"}),i.updateAvailable&&i.latest?(0,n.jsx)("span",{className:"update-badge update-badge-new",children:t("update.runtimeAvailable",{current:i.current??"?",latest:i.latest})}):i.latest?(0,n.jsx)("span",{className:"update-badge update-badge-ok",children:t("update.upToDate")}):(0,n.jsx)("span",{className:"hint-warn-inline",children:t("update.checkUnavailable")})]}),(0,n.jsx)("code",{children:i.binPath}),i.updateAvailable?(0,n.jsxs)("small",{children:[t("update.runtimeCommand"),": ",(0,n.jsx)("code",{children:i.updateCommand})]}):null]},`${i.cliId}:${i.binPath}`))}),(0,n.jsx)("p",{className:"settings-help",children:t("update.runtimeHelp")})]})}function We(e){let t=w(),i=e.status;return i.latest?i.behind?(0,n.jsx)("span",{className:"update-badge update-badge-new",children:t("update.newAvailable",{version:`v${i.latest}`})}):(0,n.jsx)("span",{className:"update-badge update-badge-ok",children:t("update.upToDate")}):(0,n.jsx)("span",{className:"hint-warn-inline",children:t("update.checkUnavailable")})}function je(e){let t=w();return(0,n.jsxs)("div",{className:"hint-warn",children:[(0,n.jsx)("p",{children:t("update.multiInstallWarn")}),(0,n.jsx)("ul",{className:"update-install-list",children:e.entries.map(i=>(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:i.binPath})," \u2192 ",we(i.kind,t)," ",(0,n.jsx)("small",{children:i.root})]},`${i.binPath}:${i.root}`))})]})}function qe(e){let t=w();if(e.changelog===null)return(0,n.jsx)(re,{label:t("update.changelogLoading"),compact:!0});if(!e.ok){let i=e.rateLimited?t("update.changelogRateLimited"):t("update.changelogFailed");return(0,n.jsxs)("p",{className:"hint-warn-inline",children:[i,e.releasesUrl?(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("a",{href:e.releasesUrl,target:"_blank",rel:"noopener",children:t("update.changelogViewOnGitHub")})]}):null]})}return e.changelog.length===0?(0,n.jsx)("p",{className:"empty",children:t("update.changelogEmpty")}):(0,n.jsx)("div",{className:"update-changelog",children:e.changelog.map(i=>{let g=i.name&&i.name!==`v${i.version}`?i.name:"",m=i.publishedAt?new Date(i.publishedAt).toLocaleDateString():"";return(0,n.jsxs)("details",{className:"update-release",open:!0,children:[(0,n.jsxs)("summary",{children:[(0,n.jsxs)("strong",{children:["v",i.version]})," ",g," ",(0,n.jsx)("small",{children:m})," ",(0,n.jsx)("a",{href:i.url,target:"_blank",rel:"noopener",children:"\u2197"})]}),(0,n.jsx)("pre",{className:"update-release-body",children:i.body||""})]},i.version)})})}function st(e){return Pe(e,(0,n.jsx)(_e,{}))}export{He as TimeZoneRow,st as renderSettingsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as K}from"./chunk-
|
|
1
|
+
import{b as K}from"./chunk-3PMN55Z6.js";import{b as Ce,c as je,d as te,h as ze,k as de}from"./chunk-I35DXGM4.js";import{w as we}from"./chunk-RXVA6XW3.js";import{a as He}from"./chunk-SYC6D5XU.js";import{a as bl,b as pl,d as Oe}from"./chunk-5THX4DI2.js";import{c as ce}from"./chunk-7SZRL6FY.js";var i=ce(bl(),1),qe=ce(pl(),1);var e=ce(Oe(),1),hl=2;function Sl(l,s){let o=String(l??"").replace(/\\/g,"/");return o.includes("/.codex/skills/")?s("skills.sourceCodex"):o.includes("/.claude/skills/")?s("skills.sourceClaude"):o.includes("/.trae/skills/")?s("skills.sourceTrae"):o.includes("/.cursor/skills/")?s("skills.sourceCursor"):o.includes("/.gemini/skills/")?s("skills.sourceGemini"):o.includes("/.config/opencode/skills/")?s("skills.sourceOpenCode"):null}function _e(l,s){let o=l.source??{};return o.type==="github"?`github:${o.owner}/${o.repo}/${o.path??""}`:o.type==="git"?`${o.url??"git"}#${o.path??""}`:o.type==="local-link"?Sl(o.path,s)??s("skills.sourceLocalLink"):o.type==="local-copy"?s("skills.sourceBotmuxCopy"):String(o.type??"unknown")}function ke(l){return(l?.include??[]).filter(s=>s.startsWith("skill:")).map(s=>s.slice(6))}function Nl(l){return ke(l).length}function wl(l){return ke(l).length>0}function ue(l){return`${l.cliId}
|
|
2
2
|
${l.rootDir}`}function Cl(l){return l>=1600?4:l<=620?1:l<=980?2:3}async function O(l,s){let o=await fetch(l,{...s,headers:{"content-type":"application/json",...s.headers??{}}}),k=await o.json().catch(()=>({}));if(!o.ok||k.ok===!1){let f=new Error(k?.error??`HTTP ${o.status}`);throw f.status=o.status,f.body=k,f}return k}function Re(l){return`oncall-status${l?` ${l.ok?"hint-ok":"hint-warn-inline"}`:""}`}function Ge(l){let s=l.options.find(o=>o.value===l.value);return(0,e.jsxs)("div",{className:"skills-segmented-control",children:[(0,e.jsx)("div",{className:"segmented skills-segmented",role:"group",children:l.options.map(o=>(0,e.jsx)("button",{type:"button",className:l.value===o.value?"active":"","aria-pressed":l.value===o.value?"true":"false",title:typeof o.help=="string"?o.help:void 0,disabled:l.disabled,onClick:()=>l.onChange(o.value),children:o.label},o.value))}),s?.help?(0,e.jsx)("span",{className:"skills-setting-hint",children:s.help}):null]})}function Rl(l){let s=K(),o=(0,i.useRef)(null),k=l.installCandidates??[],f=l.selectedInstallSkills??new Set,b=k.length>0&&k.every(r=>f.has(r.name)),y=l.installBusy||l.installDiscovering;return(0,i.useEffect)(()=>{let r=o.current;if(r)if(l.installSelectionOpen&&!r.open)try{r.showModal()}catch{}else!l.installSelectionOpen&&r.open&&r.close()},[l.installSelectionOpen,k.length]),(0,e.jsxs)("article",{className:"bd-card skills-install-panel",children:[l.showTitle===!1?null:(0,e.jsx)("div",{className:"skills-install-title",children:(0,e.jsx)("h3",{className:"bd-section-title",children:(0,e.jsx)(de,{help:s("skills.installInfo"),helpLabel:s("skills.installInfoLabel"),children:s("skills.install")})})}),(0,e.jsxs)("div",{className:"skills-install-grid",children:[(0,e.jsxs)("label",{className:"skills-source-label",children:[(0,e.jsx)(de,{help:(0,e.jsxs)("span",{className:"skills-source-help",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.sourceHelpRemoteLabel")}),s("skills.sourceHelpRemote")]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.sourceHelpLocalLabel")}),s("skills.sourceHelpLocal")]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.sourceHelpAgentbuddyLabel")}),s("skills.sourceHelpAgentbuddy")]})]}),helpLabel:s("skills.source"),children:s("skills.source")}),(0,e.jsx)("div",{className:"skills-source-control",children:(0,e.jsx)("input",{type:"text","data-install":"source","aria-label":s("skills.source"),placeholder:s("skills.sourcePlaceholder"),value:l.installSource,onChange:r=>l.onInstallSourceChange(r.currentTarget.value)})})]}),(0,e.jsxs)("label",{className:"skills-install-field-wide skills-install-path-field",children:[(0,e.jsx)("span",{children:s("skills.path")}),(0,e.jsx)("input",{type:"text","data-install":"path",placeholder:s("skills.pathPlaceholder"),value:l.installPath,onChange:r=>l.onInstallPathChange(r.currentTarget.value)})]}),(0,e.jsxs)("label",{className:"skills-install-field-wide skills-install-ref-field",children:[(0,e.jsx)("span",{children:s("skills.ref")}),(0,e.jsx)("input",{type:"text","data-install":"ref",placeholder:s("skills.refPlaceholder"),value:l.installRef,onChange:r=>l.onInstallRefChange(r.currentTarget.value)})]}),(0,e.jsx)("div",{className:"skills-install-actions",children:(0,e.jsx)("button",{type:"button","data-action":"install",disabled:y,onClick:()=>l.onInstall(),children:l.installDiscovering?s("skills.scanning"):l.installBusy?s("skills.jobRunning"):s("skills.installSubmit")})}),(0,e.jsx)("div",{className:"skills-install-bottom-row",children:(0,e.jsxs)("div",{className:"skills-local-discovery-panel",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("strong",{children:s("skills.localDiscoverTitle")}),(0,e.jsx)("span",{children:s("skills.localDiscoverHelp")})]}),(0,e.jsx)("button",{type:"button","data-action":"open-native-skill-discovery",onClick:()=>l.onOpenNativeDiscovery(),children:s("skills.localDiscover")})]})})]}),l.installStatus?(0,e.jsx)("div",{className:"actions skills-install-status-row",children:(0,e.jsx)("span",{className:Re(l.installStatus),"data-skills-status":!0,children:l.installStatus.text})}):null,(0,e.jsx)("dialog",{className:"skills-discovery-dialog skills-install-selection-dialog","data-install-selection-dialog":!0,ref:o,onClose:()=>l.onCloseInstallSelection?.(),children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:s("skills.installSelectionTitle")}),(0,e.jsx)("p",{children:s("skills.installSelectionHelp",{count:k.length})})]}),(0,e.jsx)("div",{className:"skills-discovery-body skills-install-selection-body",children:(0,e.jsxs)("div",{className:"skills-candidate-list","data-install-candidates":!0,children:[(0,e.jsxs)("div",{className:"skills-candidate-list-head",children:[(0,e.jsx)("span",{children:s("skills.scanFound",{count:k.length})}),l.onSelectAllInstallSkills?(0,e.jsx)("button",{type:"button","data-action":"toggle-all-source-skills",disabled:l.installBusy,onClick:()=>l.onSelectAllInstallSkills?.(!b),children:s(b?"skills.discoverClearSelection":"skills.discoverSelectAll")}):null]}),k.map(r=>(0,e.jsxs)("label",{className:"skills-candidate-row",children:[(0,e.jsx)("input",{type:"checkbox",checked:f.has(r.name),disabled:l.installBusy,onChange:()=>l.onToggleInstallSkill?.(r.name)}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:r.name}),(0,e.jsxs)("small",{children:[r.path,r.description?` \xB7 ${r.description}`:""]})]})]},`${r.name}:${r.path}`))]})}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button","data-action":"close-install-selection",disabled:l.installBusy,onClick:()=>l.onCloseInstallSelection?.(),children:s("skills.installSelectionCancel")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"confirm-install-selection",disabled:l.installBusy||f.size===0,onClick:()=>l.onConfirmInstallSelection?.(),children:l.installBusy?s("skills.jobRunning"):s("skills.installSelected")})]})]})})]})}function Il(l){let s=K(),o=(0,i.useRef)(null),k=(0,i.useRef)(new Set(l.skills.map(a=>a.name))),f=(0,i.useRef)(""),b=(0,i.useRef)(!1),y=(0,i.useRef)(null),[r,p]=(0,i.useState)(""),[w,R]=(0,i.useState)(!1),[I,D]=(0,i.useState)(()=>new Set),[x,M]=(0,i.useState)(0),[A,j]=(0,i.useState)(()=>typeof window>"u"?1200:window.innerWidth),L=r.trim().toLocaleLowerCase();f.current=r,b.current=w;let h=(0,i.useMemo)(()=>L?l.skills.filter(a=>[a.name,a.displayName,a.description,...a.tags??[],_e(a,s)].filter(Boolean).join(`
|
|
3
3
|
`).toLocaleLowerCase().includes(L)):l.skills,[L,l.skills,s]),B=Cl(A)*hl,T=Math.max(1,Math.ceil(h.length/B)),F=h.slice(x*B,x*B+B),q=(0,i.useMemo)(()=>new Set(h.map(a=>a.name)),[h]),z=h.filter(a=>I.has(a.name)).length,_=Math.max(0,I.size-z),c=h.length>0&&z===h.length;(0,i.useEffect)(()=>{if(typeof window>"u")return;let a=()=>j(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,i.useEffect)(()=>M(0),[L,B]),(0,i.useEffect)(()=>{M(a=>Math.min(Math.max(0,a),T-1))},[T]),(0,i.useEffect)(()=>{let a=new Set(l.skills.map(u=>u.name)),C=[...k.current].some(u=>!a.has(u));D(u=>{let P=new Set([...u].filter(H=>a.has(H)));return P.size===u.size?u:P}),C&&(R(!1),D(new Set)),k.current=a},[l.skills]),(0,i.useEffect)(()=>{o.current&&(o.current.indeterminate=z>0&&!c)},[c,z]),(0,i.useEffect)(()=>{if(typeof document>"u")return;let a=u=>{if(u.key!=="Escape"||!b.current)return;let P=f.current;y.current=P,u.preventDefault(),u.stopPropagation(),R(!1),D(new Set),window.setTimeout(()=>{p(H=>H||P),y.current=null},50)},C=u=>{if(u.key!=="Escape"||y.current===null)return;let P=y.current;y.current=null,u.preventDefault(),u.stopPropagation(),p(P)};return document.addEventListener("keydown",a,!0),document.addEventListener("keyup",C,!0),()=>{document.removeEventListener("keydown",a,!0),document.removeEventListener("keyup",C,!0)}},[]);function g(a){D(C=>{let u=new Set(C);return u.has(a)?u.delete(a):u.add(a),u})}function S(){D(a=>{let C=new Set(a);if(c)for(let u of q)C.delete(u);else for(let u of q)C.add(u);return C})}function $(a=!1){let C=r;R(!1),D(new Set),a&&typeof window<"u"&&window.setTimeout(()=>p(C),0)}return(0,e.jsxs)("section",{className:"skills-installed-block",children:[(0,e.jsx)(te,{title:s("skills.installed"),count:s("skills.installedCount",{count:l.skills.length}),hint:s("skills.installedHelp"),children:(0,e.jsx)("div",{className:"skills-installed-header-actions",children:w?(0,e.jsx)("button",{type:"button","data-action":"cancel-installed-selection",onClick:()=>$(),children:s("skills.cancel")}):(0,e.jsx)("button",{type:"button","data-action":"select-installed-skills",disabled:l.skills.length===0,onClick:()=>R(!0),children:s("skills.select")})})}),(0,e.jsxs)("section",{className:"bd-card skills-installed-panel",children:[(0,e.jsxs)("div",{className:"skills-library-toolbar",children:[(0,e.jsxs)("label",{className:"skills-installed-search",children:[(0,e.jsx)("span",{className:"sr-only",children:s("skills.searchLabel")}),(0,e.jsx)("input",{type:"text",role:"searchbox",inputMode:"search","data-action":"search-installed-skills",placeholder:s("skills.searchPlaceholder"),value:r,onChange:a=>p(a.currentTarget.value),onKeyDown:a=>{a.key!=="Escape"||!w||(a.preventDefault(),a.stopPropagation(),$(!0))}}),r?(0,e.jsx)("button",{type:"button","data-action":"clear-installed-search","aria-label":s("skills.clearSearch"),onClick:()=>p(""),children:"\xD7"}):null]}),w?(0,e.jsxs)("label",{className:"skills-select-all-results",children:[(0,e.jsx)("input",{ref:o,type:"checkbox",checked:c,disabled:h.length===0||l.removingNames.size>0,onChange:S}),(0,e.jsx)("span",{children:L?s("skills.selectSearchResults",{count:h.length}):s("skills.selectAllSkills",{count:h.length})})]}):null,L?(0,e.jsx)("span",{className:"skills-filter-count",children:s("skills.resultCount",{count:h.length})}):null,T>1?(0,e.jsxs)("div",{className:"skills-pager",children:[(0,e.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"-1","aria-label":s("skills.prevPage"),title:s("skills.prevPage"),disabled:x===0,onClick:()=>M(a=>Math.max(0,a-1)),children:"\u2039"}),(0,e.jsx)("span",{children:s("skills.pageStatus",{page:x+1,pages:T})}),(0,e.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"1","aria-label":s("skills.nextPage"),title:s("skills.nextPage"),disabled:x>=T-1,onClick:()=>M(a=>Math.min(T-1,a+1)),children:"\u203A"})]}):null]}),(0,e.jsx)("div",{className:"skills-installed-live",role:"status","aria-live":"polite",children:l.status?(0,e.jsx)("span",{className:Re(l.status),children:l.status.text}):null}),l.skills.length===0?(0,e.jsxs)("div",{className:"skills-library-empty",children:[(0,e.jsx)("strong",{children:s("skills.emptyTitle")}),(0,e.jsx)("p",{children:s("skills.emptyHelp")})]}):h.length===0?(0,e.jsxs)("div",{className:"skills-library-empty","data-empty":"search",children:[(0,e.jsx)("strong",{children:s("skills.noResultsTitle",{query:r.trim()})}),(0,e.jsx)("p",{children:s("skills.noResultsHelp")}),(0,e.jsx)("button",{type:"button","data-action":"clear-installed-search-empty",onClick:()=>p(""),children:s("skills.clearSearch")})]}):(0,e.jsx)("div",{className:"skills-list",children:F.map(a=>{let C=I.has(a.name),u=l.removingNames.has(a.name);return(0,e.jsxs)("article",{className:`skills-row skills-installed-card${w?" is-selectable":""}${C?" is-selected":""}${u?" is-removing":""}`,"data-skill":a.name,"data-selection-mode":w?"true":void 0,"aria-busy":u||void 0,onClick:w?()=>g(a.name):void 0,children:[(0,e.jsxs)("div",{className:"skills-row-body",children:[(0,e.jsxs)("div",{className:"skills-row-title",children:[w?(0,e.jsx)("input",{type:"checkbox","aria-label":s("skills.selectNamed",{skill:a.displayName??a.name}),checked:C,disabled:u,onClick:P=>P.stopPropagation(),onChange:()=>g(a.name)}):null,(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:a.displayName??a.name}),a.displayName&&a.displayName!==a.name?(0,e.jsx)("small",{className:"skills-canonical-name",children:a.name}):null]})]}),a.description?(0,e.jsx)("p",{children:a.description}):null,(0,e.jsx)("small",{className:"skills-source-badge",children:_e(a,s)}),u?(0,e.jsx)("span",{className:"skills-removing-label",children:s("skills.removing")}):null]}),w?null:(0,e.jsxs)("div",{className:"skills-card-actions",children:[(0,e.jsx)("button",{type:"button","data-action":"update-skill",disabled:l.busySkill===`${a.name}:update`||u,onClick:()=>l.onUpdate(a.name),children:s("skills.update")}),(0,e.jsx)("button",{type:"button","data-action":"remove-skill",disabled:u,onClick:()=>l.onRequestRemove([a.name]),children:s("skills.remove")})]})]},a.name)})})]}),w?(0,e.jsxs)("div",{className:"skills-bulk-action-bar",role:"toolbar","aria-label":s("skills.bulkActions"),children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:s("skills.selectedCount",{count:I.size})}),_>0?(0,e.jsx)("small",{children:s("skills.selectedHidden",{count:_})}):null]}),(0,e.jsx)("button",{type:"button",className:"danger","data-action":"remove-selected-skills",disabled:I.size===0||l.removingNames.size>0,onClick:()=>l.onRequestRemove([...I]),children:s("skills.removeSelected",{count:I.size})})]}):null]})}function Pl(l){let s=K(),o=(0,i.useRef)(null),k=l.names??[],f=l.references.length>0,b=k.slice(0,3),y=new Set(l.references.flatMap(r=>r.bots)).size;return(0,i.useEffect)(()=>{let r=o.current;if(r)if(l.names&&!r.open)try{r.showModal()}catch{}else!l.names&&r.open&&r.close()},[l.names]),(0,e.jsx)("dialog",{className:"skills-remove-dialog","data-remove-skills-dialog":!0,ref:o,onCancel:r=>{r.preventDefault(),l.busy||l.onCancel()},onClick:r=>{r.target===r.currentTarget&&!l.busy&&l.onCancel()},children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:f?k.length===1?s("skills.removeInUseOneTitle",{skill:k[0]}):s("skills.removeInUseManyTitle",{count:k.length}):k.length===1?s("skills.removeOneTitle",{skill:k[0]}):s("skills.removeManyTitle",{count:k.length})}),(0,e.jsx)("p",{children:f?k.length===1?s("skills.removeInUseOneHelp",{count:y}):s("skills.removeInUseManyHelp",{count:y}):k.length===1?s("skills.removeOnePermanentHelp"):s("skills.removePermanentHelp")})]}),(0,e.jsxs)("div",{className:"skills-remove-dialog-body",children:[k.length>1?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("ul",{children:b.map(r=>(0,e.jsx)("li",{children:r},r))}),k.length>b.length?(0,e.jsx)("p",{children:s("skills.removeMore",{count:k.length-b.length})}):null]}):null,l.references.length>0?(0,e.jsxs)("div",{className:"skills-remove-reference-warning",role:"alert",children:[(0,e.jsx)("strong",{children:s("skills.removeReferencesDetail")}),(0,e.jsx)("ul",{children:l.references.map(r=>(0,e.jsxs)("li",{children:[(0,e.jsx)("strong",{children:r.name}),(0,e.jsx)("span",{children:r.bots.join(", ")})]},r.name))})]}):null,l.error?(0,e.jsx)("p",{className:"hint-warn",role:"alert",children:l.error}):null]}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button",autoFocus:!0,disabled:l.busy,onClick:l.onCancel,children:s("skills.cancel")}),(0,e.jsx)("button",{type:"button",className:"danger",disabled:l.busy,onClick:()=>l.onConfirm(f),children:l.busy?s("skills.removing"):f?s("skills.removeAnyway"):k.length===1?s("skills.removeOneConfirm"):s("skills.removeSelected",{count:k.length})})]})]})})}function Tl(){let l=K(),s=(0,i.useRef)(!0),o=(0,i.useRef)(new Set),k=(0,i.useRef)(null),[f,b]=(0,i.useState)([]),[y,r]=(0,i.useState)([]),[p,w]=(0,i.useState)([]),[R,I]=(0,i.useState)("off"),[D,x]=(0,i.useState)("auto"),[M,A]=(0,i.useState)(null),[j,L]=(0,i.useState)(!0),[h,B]=(0,i.useState)(""),[T,F]=(0,i.useState)(""),[q,z]=(0,i.useState)(""),[_,c]=(0,i.useState)(null),[g,S]=(0,i.useState)(!1),[$,a]=(0,i.useState)(!1),[C,u]=(0,i.useState)(!1),[P,H]=(0,i.useState)([]),[Q,U]=(0,i.useState)(()=>new Set),[W,X]=(0,i.useState)(!1),[Je,Ie]=(0,i.useState)(!1),[me,Ke]=(0,i.useState)(null),[ge,fe]=(0,i.useState)(()=>new Set),[Pe,ne]=(0,i.useState)(null),[Ue,Te]=(0,i.useState)(null),[We,De]=(0,i.useState)(null),[Fe,ve]=(0,i.useState)({}),[ye,V]=(0,i.useState)(null),[xe,be]=(0,i.useState)(null),[Qe,Y]=(0,i.useState)(!1),[Xe,ie]=(0,i.useState)([]),[Ve,ae]=(0,i.useState)(null),[Z,Me]=(0,i.useState)(()=>new Set),ee=(0,i.useMemo)(()=>new Set(f.map(t=>t.name)),[f]),J=(0,i.useMemo)(()=>y.length===0?void 0:(me?y.find(n=>ue(n)===me):void 0)??y.find(n=>n.skills.length>0)??y[0],[me,y]),pe=J?ue(J):"",le=(0,i.useMemo)(()=>J?J.skills.filter(t=>!ee.has(t.name)).map(t=>t.rootDir??t.source?.root??"").filter(Boolean):[],[J,ee]),Ae=le.length>0&&le.every(t=>ge.has(t)),Le=(0,i.useCallback)(()=>{for(let t of o.current)window.clearTimeout(t);o.current.clear()},[]),Ye=(0,i.useCallback)(t=>new Promise(n=>{let d=window.setTimeout(()=>{o.current.delete(d),n()},t);o.current.add(d)}),[]),Ee=(0,i.useCallback)(async()=>{let[t,n]=await Promise.all([fetch("/api/skills"),fetch("/api/bots")]),d=await t.json().catch(()=>({})),m=await n.json().catch(()=>({}));if(!t.ok){let v=d?.error??`skills HTTP ${t.status}`;throw new Error(v==="not_found_yet"||v==="not_found"?l("skills.apiUnavailable"):v)}if(!n.ok)throw new Error(m?.error??`bots HTTP ${n.status}`);return{skills:Array.isArray(d.skills)?d.skills:[],nativeSkillGroups:Array.isArray(d.nativeSkillGroups)?d.nativeSkillGroups:[],bots:Array.isArray(m.bots)?m.bots:[],trustProjectSkills:d.trustProjectSkills==="all"?"all":"off",delivery:d.delivery==="prompt"||d.delivery==="native"?d.delivery:"auto"}},[l]),se=(0,i.useCallback)(async()=>{L(!0);try{let t=await Ee();if(!s.current)return;b(t.skills),r(t.nativeSkillGroups),w(t.bots),I(t.trustProjectSkills),x(t.delivery),A(null),fe(n=>{let d=new Set,m=new Set(t.skills.map(v=>v.name));for(let v of t.nativeSkillGroups)for(let N of v.skills){let E=N.rootDir??N.source?.root??"";E&&!m.has(N.name)&&n.has(E)&&d.add(E)}return d})}catch(t){if(!s.current)return;A(t?.message??String(t))}finally{s.current&&L(!1)}},[Ee]);(0,i.useEffect)(()=>(s.current=!0,se(),()=>{s.current=!1,Le()}),[Le,se]),(0,i.useEffect)(()=>{if(!ye||Z.size>0)return;let t=window.setTimeout(()=>{s.current&&V(null)},6e3);return()=>window.clearTimeout(t)},[ye,Z]),(0,i.useEffect)(()=>{let t=k.current;if(t)if(W&&!t.open)try{t.showModal()}catch{}else!W&&t.open&&t.close()},[W,pe]);async function Be(t,n,d=!0){let m=t;for(n({text:l("skills.jobRunning"),ok:!0});;){if(!s.current)return;if(m.status==="succeeded"){n({text:l("skills.saved"),ok:!0}),d&&await se();return}if(m.status==="failed")throw new Error(m.error??"job_failed");if(await Ye(800),!s.current)return;let v=await O(`/api/skills/jobs/${encodeURIComponent(m.id)}`,{method:"GET"});if(!s.current)return;m=v.job}}function Ze(t){return p.filter(n=>ke(n.skills).includes(t)).map(n=>n.botName??n.larkAppId)}function oe(){H([]),U(new Set),u(!1)}function $e(){return{source:h.trim(),path:T.trim()||void 0,ref:q.trim()||void 0}}function el(t){let n=t??[...Q];return{...$e(),skillNames:n.length>0?n:void 0}}async function ll(){a(!0),c({text:l("skills.scanning"),ok:!0});try{let t=await O("/api/skills/discover",{method:"POST",body:JSON.stringify($e())});if(!s.current)return{skills:[],directInstall:!1};let n=t.discovery?.directInstall===!0,d=Array.isArray(t.discovery?.skills)?t.discovery.skills:[];return H(d),U(new Set(d.map(m=>m.name))),{skills:d,directInstall:n}}finally{s.current&&a(!1)}}function G(t){let n=t||"";return n.startsWith("agentbuddy_not_found")?l("skills.agentbuddyNotFound"):n.startsWith("agentbuddy_command_failed")?/login|credential|unauthor|not logged|401|403/i.test(n)?l("skills.agentbuddyNeedsLogin"):l("skills.agentbuddyCommandFailed"):n.startsWith("agentbuddy_clear_telemetry_failed")||n.startsWith("agentbuddy_telemetry_not_stripped")?l("skills.agentbuddyTelemetryFailed"):n.startsWith("agentbuddy_no_skill_produced")?l("skills.agentbuddyNoSkill"):n.startsWith("invalid_agentbuddy")?l("skills.agentbuddyInvalid"):n}async function he(t){S(!0);try{let n=await O("/api/skills/install",{method:"POST",body:JSON.stringify(el(t))});if(!s.current)return;await Be(n.job,c),s.current&&oe()}catch(n){s.current&&c({text:`${l("skills.failed")}: ${G(n?.message??String(n))}`,ok:!1})}finally{s.current&&S(!1)}}function sl(t){U(n=>{let d=new Set(n);return d.has(t)?d.delete(t):d.add(t),d})}function tl(t){U(t?new Set(P.map(n=>n.name)):new Set)}async function nl(){if(!h.trim()){c({text:l("skills.sourceRequired"),ok:!1});return}try{u(!1);let{skills:t,directInstall:n}=await ll();if(!s.current)return;if(n){await he();return}if(t.length===0){c({text:l("skills.scanEmpty"),ok:!1});return}if(t.length===1){await he([t[0].name]);return}c({text:l("skills.scanFound",{count:t.length}),ok:!0}),u(!0)}catch(t){s.current&&c({text:`${l("skills.failed")}: ${G(t?.message??String(t))}`,ok:!1})}}async function il(){let t=[...Q];if(t.length===0){c({text:l("skills.discoverNothingSelected"),ok:!1});return}await he(t)}async function al(){let t=[...ge].filter(Boolean);if(t.length===0){c({text:l("skills.discoverNothingSelected"),ok:!1});return}Ie(!0);try{if(c({text:l("skills.discoverRegisteringBatch",{total:t.length}),ok:!0}),await O("/api/skills/install-local-links",{method:"POST",body:JSON.stringify({sources:t})}),!s.current)return;X(!1),await se(),s.current&&c({text:l("skills.saved"),ok:!0})}catch(n){s.current&&c({text:`${l("skills.failed")}: ${G(n?.message??String(n))}`,ok:!1})}finally{s.current&&Ie(!1)}}async function ol(t){if(R!==t){ne("project");try{let n=await O("/api/skills/global",{method:"PUT",body:JSON.stringify({trustProjectSkills:t})});if(!s.current)return;I(n.trustProjectSkills==="all"?"all":t)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&ne(null)}}}async function rl(t){if(D!==t){ne("delivery");try{let n=await O("/api/skills/global",{method:"PUT",body:JSON.stringify({delivery:t})});if(!s.current)return;x(n.delivery==="prompt"||n.delivery==="native"?n.delivery:t)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&ne(null)}}}async function cl(t){Te(`${t}:update`);try{let n=await O(`/api/skills/${encodeURIComponent(t)}/update`,{method:"POST",body:"{}"});if(!s.current)return;await Be(n.job,c)}catch(n){s.current&&window.alert(`${l("skills.failed")}: ${G(n?.message??String(n))}`)}finally{s.current&&Te(null)}}function dl(t){let n=[...new Set(t.filter(d=>ee.has(d)))];n.length!==0&&(be(n),Y(!0),ie([]),ae(null))}function ul(){Z.size>0||(Y(!1),be(null),ie([]),ae(null))}async function kl(t){let n=xe??[];if(n.length!==0){Me(new Set(n)),Y(!1),ae(null),V({text:l("skills.removingCount",{count:n.length}),ok:!0});try{let d=await O("/api/skills",{method:"DELETE",body:JSON.stringify({names:n,force:t})});if(!s.current)return;let m=Array.isArray(d.removed)?d.removed.filter(N=>typeof N=="string"):n,v=new Set(m);b(N=>N.filter(E=>!v.has(E.name))),V({text:m.length===1?l("skills.removedOne",{skill:m[0]}):l("skills.removedMany",{count:m.length}),ok:!0}),be(null),ie([])}catch(d){if(!s.current)return;if(d?.status===409&&d?.body?.error==="skills_in_use"){let v=Array.isArray(d.body.affectedSkills)?d.body.affectedSkills.map(N=>{let E=typeof N?.name=="string"?N.name:"",Se=Array.isArray(N?.affectedBots)?N.affectedBots.map(re=>re?.botName||re?.larkAppId||"").filter(Boolean):Ze(E);return E?{name:E,bots:Se}:null}).filter(N=>N!==null):[];ie(v),Y(!0),V(null);return}let m=l("skills.removeFailed",{detail:G(d?.message??String(d))});ae(m),Y(!0),V({text:m,ok:!1})}finally{s.current&&Me(new Set)}}}async function ml(t,n){let d=`${t}:set`;De(d),ve(m=>({...m,[t]:null}));try{let m=await O(`/api/bots/${encodeURIComponent(t)}/skills`,{method:"PUT",body:JSON.stringify({action:"set",policy:n.length>0?{include:n.map(v=>`skill:${v}`)}:null})});if(!s.current)return;w(v=>v.map(N=>N.larkAppId===t?{...N,skills:m.skills??null}:N)),ve(v=>({...v,[t]:{text:l("skills.policySaved"),ok:!0}}))}catch(m){throw s.current&&ve(v=>({...v,[t]:{text:`${l("skills.failed")}: ${G(m?.message??String(m))}`,ok:!1}})),m}finally{s.current&&De(null)}}let gl=p.filter(t=>wl(t.skills)).length,fl=p.reduce((t,n)=>t+Nl(n.skills),0),vl=(0,e.jsxs)("div",{className:"page-heading-actions skills-heading-actions",children:[(0,e.jsxs)("div",{className:"skills-metric-strip",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricInstalled")}),(0,e.jsx)("strong",{children:f.length})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricBots")}),(0,e.jsxs)("strong",{children:[gl,"/",p.length]})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("small",{children:l("skills.metricAttached")}),(0,e.jsx)("strong",{children:fl})]})]}),(0,e.jsx)(ze,{id:"skills-refresh",label:l("skills.refresh"),busy:j,disabled:j,onClick:()=>{se()}})]}),yl=(0,e.jsx)("div",{className:"skills-page-stack",children:j?(0,e.jsx)(je,{label:l("common.loading")}):M?(0,e.jsx)("p",{className:"hint-warn",children:M}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"skills-config-row",children:[(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:l("skills.globalDefaults")}),(0,e.jsxs)("article",{className:"bd-card skills-defaults-panel skills-config-card",children:[(0,e.jsxs)("div",{className:"skills-control-block",children:[(0,e.jsx)("span",{className:"skills-control-label",children:l("skills.globalProject")}),(0,e.jsx)(Ge,{value:R,disabled:Pe==="project",options:[{value:"off",label:l("skills.globalProjectOff"),help:l("skills.globalProjectOffHelp")},{value:"all",label:l("skills.globalProjectAll"),help:l("skills.globalProjectAllHelp")}],onChange:t=>{ol(t)}})]}),(0,e.jsxs)("div",{className:"skills-control-block",children:[(0,e.jsx)("span",{className:"skills-control-label",children:l("skills.globalDelivery")}),(0,e.jsx)(Ge,{value:D,disabled:Pe==="delivery",options:[{value:"auto",label:l("skills.deliveryAuto"),help:l("skills.deliveryAutoHelp")},{value:"prompt",label:l("skills.deliveryPrompt"),help:l("skills.deliveryPromptHelp")},{value:"native",label:l("skills.deliveryNative"),help:l("skills.deliveryNativeHelp")}],onChange:t=>{rl(t)}})]})]})]}),(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:(0,e.jsx)(de,{help:l("skills.installInfo"),helpLabel:l("skills.installInfoLabel"),children:l("skills.install")})}),(0,e.jsx)(Rl,{showTitle:!1,installSource:h,installPath:T,installRef:q,installStatus:_,installBusy:g,installDiscovering:$,installSelectionOpen:C,installCandidates:P,selectedInstallSkills:Q,onInstallSourceChange:t=>{B(t),oe()},onInstallPathChange:t=>{F(t),oe()},onInstallRefChange:t=>{z(t),oe()},onToggleInstallSkill:sl,onSelectAllInstallSkills:tl,onConfirmInstallSelection:()=>{il()},onCloseInstallSelection:()=>u(!1),onInstall:()=>{nl()},onOpenNativeDiscovery:()=>X(!0)})]}),(0,e.jsxs)("section",{className:"skills-config-block",children:[(0,e.jsx)(te,{title:l("skills.bots"),count:l("skills.botCount",{count:p.length}),hint:l("skills.botsHelp")}),(0,e.jsx)("section",{className:"bd-card skills-bots-panel skills-config-card",children:(0,e.jsx)("div",{className:"skills-bot-grid",children:p.map(t=>(0,e.jsx)(Ml,{bot:t,installedNames:ee,skills:f,status:Fe[t.larkAppId]??null,busyKey:We,onSave:ml},t.larkAppId))})})]})]}),(0,e.jsx)(Il,{skills:f,busySkill:Ue,removingNames:Z,status:ye,onUpdate:t=>{cl(t)},onRequestRemove:dl}),(0,e.jsx)(Pl,{names:Qe?xe:null,references:Xe,busy:Z.size>0,error:Ve,onCancel:ul,onConfirm:t=>{kl(t)}}),(0,e.jsx)("dialog",{className:"skills-discovery-dialog",id:"skills-discovery-dialog",ref:k,onClose:()=>X(!1),onClick:t=>{t.target===t.currentTarget&&X(!1)},children:(0,e.jsxs)("article",{children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:l("skills.discoverTitle")}),(0,e.jsx)("p",{children:l("skills.discoverHelp")}),(0,e.jsx)("button",{type:"button",className:"skills-discovery-close","data-action":"close-discovery","aria-label":l("skills.discoverClose"),title:l("skills.discoverClose"),onClick:()=>X(!1)})]}),(0,e.jsx)("div",{className:"skills-discovery-body",children:J?(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"skills-discovery-layout",children:[(0,e.jsx)("div",{className:"skills-discovery-tabs",role:"tablist","aria-label":l("skills.discoverTitle"),children:y.map(t=>{let n=ue(t),d=n===pe;return(0,e.jsxs)("button",{type:"button",role:"tab","data-discovery-tab":n,className:d?"selected":"","aria-selected":d?"true":"false",onClick:()=>Ke(n),children:[(0,e.jsx)("strong",{children:t.label??t.cliId}),(0,e.jsx)("small",{children:l("skills.skillCount",{count:t.skills.length})})]},n)})}),(0,e.jsxs)("div",{className:"skills-discovery-main",children:[(0,e.jsx)("div",{className:"skills-discovery-path",children:(0,e.jsx)("code",{children:J.rootDir})}),y.map(t=>{let n=ue(t);return(0,e.jsx)("section",{className:"skills-discovery-group","data-discovery-panel":n,hidden:!(n===pe),children:t.skills.length===0?(0,e.jsx)("p",{className:"empty",children:l("skills.discoverGroupEmpty")}):(0,e.jsx)("div",{className:"skills-discovery-list",children:t.skills.map(m=>{let v=ee.has(m.name),N=m.rootDir??m.source?.root??"";return(0,e.jsxs)("label",{className:`skills-discovery-row${v?" installed":""}`,children:[(0,e.jsx)("input",{type:"checkbox","data-discovered-skill":!0,value:N,disabled:v,checked:!v&&ge.has(N),onChange:E=>{let Se=E.currentTarget.checked;fe(re=>{let Ne=new Set(re);return Se?Ne.add(N):Ne.delete(N),Ne})}}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{children:m.name}),m.description?(0,e.jsx)("small",{children:m.description}):null]}),v?(0,e.jsx)("em",{children:l("skills.discoverRegistered")}):null]},`${m.name}:${N}`)})})},n)})]})]})}):(0,e.jsx)("p",{className:"empty",children:l("skills.discoverEmpty")})}),(0,e.jsxs)("footer",{className:"actions",children:[(0,e.jsx)("button",{type:"button","data-action":"toggle-discovered-skills",disabled:le.length===0,onClick:()=>{fe(t=>{let n=new Set(t);return Ae?le.forEach(d=>n.delete(d)):le.forEach(d=>n.add(d)),n})},children:l(Ae?"skills.discoverClearSelection":"skills.discoverSelectAll")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"register-discovered-skills",disabled:Je,onClick:()=>{al()},children:l("skills.discoverRegister")})]})]})})]})});return(0,e.jsxs)("section",{className:"page skills-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:l("nav.skills")}),(0,e.jsx)("h1",{children:l("skills.title")})]}),vl]}),(0,e.jsx)("div",{id:"skills-body",children:yl})]})}function Dl(l,s){return l.size===s.length&&s.every(o=>l.has(o))}function xl(l){let s=K(),o=(0,i.useRef)(null),k=(0,i.useRef)(null),f=(0,i.useRef)(null),[b,y]=(0,i.useState)(!1),[r,p]=(0,i.useState)(""),[w,R]=(0,i.useState)(()=>new Set(l.names)),[I,D]=(0,i.useState)(null),x=l.names.join(`
|
|
4
4
|
`),M=r.trim().toLocaleLowerCase(),A=(0,i.useMemo)(()=>{let c=new Map(l.skills.map(g=>[g.name,g]));for(let g of l.names)c.has(g)||c.set(g,{name:g});return[...c.values()].sort((g,S)=>g.name.localeCompare(S.name))},[l.names,l.skills]),j=(0,i.useMemo)(()=>M?A.filter(c=>`${c.name} ${c.description||""}`.toLocaleLowerCase().includes(M)):A,[M,A]),L=!Dl(w,l.names),h=(0,i.useCallback)(()=>{let c=k.current;if(!c||typeof window>"u")return;let g=c.getBoundingClientRect(),S=12,$=7,a=Math.min(370,Math.max(260,window.innerWidth-S*2)),C=Math.min(Math.max(S,g.left),Math.max(S,window.innerWidth-a-S)),u=Math.max(0,g.top-$-S),P=Math.max(0,window.innerHeight-g.bottom-$-S),H=u>P,Q=H?u:P,U=118+Math.min(A.length,5)*42,W=Math.max(180,Math.min(U,Q));D({left:C,top:H?Math.max(S,g.top-$-W):g.bottom+$,width:a,height:W})},[A.length]);(0,i.useEffect)(()=>{b||R(new Set(l.names))},[x,b]),(0,i.useEffect)(()=>{if(!b||typeof document>"u")return;let c=g=>{o.current?.contains(g.target)||f.current?.contains(g.target)||(y(!1),p(""),R(new Set(l.names)))};return document.addEventListener("pointerdown",c),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),h(),()=>{document.removeEventListener("pointerdown",c),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[x,b,h]);function B(){R(new Set(l.names)),p(""),h(),y(!0)}function T(){R(new Set(l.names)),p(""),y(!1)}function F(c){R(g=>{let S=new Set(g);return S.has(c)?S.delete(c):S.add(c),S})}async function q(){let c=[...w].sort((g,S)=>g.localeCompare(S));try{await l.onSave(c),p(""),y(!1)}catch{}}let z=l.names.length===0?s("skills.pickerPlaceholder"):l.names.length===1?l.names[0]:s("skills.pickerSelectedCount",{count:l.names.length}),_=b?(0,e.jsxs)("div",{ref:f,className:"skills-multi-picker-popover",style:I?{left:I.left,top:I.top,width:I.width,height:I.height}:void 0,children:[(0,e.jsxs)("div",{className:"skills-multi-picker-head",children:[(0,e.jsxs)("label",{className:"skills-multi-picker-search",children:[(0,e.jsx)("span",{className:"skills-multi-picker-search-icon","aria-hidden":"true"}),(0,e.jsx)("input",{type:"search","data-action":"search-skills",autoFocus:!0,autoComplete:"off",value:r,placeholder:s("skills.pickerSearchPlaceholder"),onChange:c=>p(c.currentTarget.value),onKeyDown:c=>{c.key==="Escape"&&(c.preventDefault(),T())}})]}),(0,e.jsxs)("div",{className:"skills-multi-picker-meta",children:[(0,e.jsx)("span",{children:s("skills.pickerSelectionMeta",{selected:w.size,total:A.length})}),w.size>0?(0,e.jsx)("button",{type:"button",className:"skills-multi-picker-clear","data-action":"clear-skill-selection",onClick:()=>R(new Set),children:s("skills.pickerClear")}):null]})]}),(0,e.jsxs)("div",{className:"skills-multi-picker-options",role:"listbox","aria-label":s("skills.priority"),"aria-multiselectable":"true",children:[j.map(c=>{let g=w.has(c.name),S=!l.installedNames.has(c.name);return(0,e.jsxs)("button",{type:"button",className:`skills-multi-picker-option${g?" selected":""}${S?" dangling":""}`,role:"option","aria-selected":g,"data-skill-name":c.name,onClick:()=>F(c.name),children:[(0,e.jsx)("span",{className:"skills-multi-picker-check","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"skills-multi-picker-option-copy",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("b",{children:c.name}),S?(0,e.jsx)("em",{children:s("skills.dangling")}):null]}),c.description?(0,e.jsx)("small",{children:c.description}):null]})]},c.name)}),j.length===0?(0,e.jsx)("p",{className:"skills-multi-picker-empty",children:s("skills.pickerNoResults")}):null]}),(0,e.jsxs)("footer",{className:"skills-multi-picker-actions",children:[(0,e.jsx)("button",{type:"button",className:"ghost","data-action":"cancel-skill-selection",disabled:l.busy,onClick:T,children:s("skills.cancel")}),(0,e.jsx)("button",{type:"button",className:"primary","data-action":"save-skill-selection",disabled:!L||l.busy,onClick:()=>{q()},children:l.busy?s("skills.saving"):s("skills.saveSelection")})]})]}):null;return(0,e.jsxs)("div",{ref:o,className:`skills-multi-picker${b?" open":""}`,"data-skill-picker":l.botId,children:[(0,e.jsxs)("button",{ref:k,type:"button",className:"skills-multi-picker-trigger","data-action":"open-skill-picker","aria-haspopup":"listbox","aria-expanded":b,disabled:l.busy,onClick:()=>b?T():B(),children:[(0,e.jsxs)("span",{className:"skills-multi-picker-trigger-copy",children:[(0,e.jsx)("b",{children:z}),(0,e.jsx)("small",{children:s("skills.pickerTriggerHint")})]}),(0,e.jsx)("span",{className:"skills-multi-picker-chevron","aria-hidden":"true"})]}),_&&typeof document<"u"?(0,qe.createPortal)(_,document.body):_]})}function Ml(l){let s=K(),{bot:o,installedNames:k,skills:f,status:b,busyKey:y,onSave:r}=l,p=o.botName??o.larkAppId,w=ke(o.skills);return o.error?(0,e.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":o.larkAppId,children:[(0,e.jsxs)("header",{children:[(0,e.jsx)(Ce,{html:we({name:p,larkAppId:o.larkAppId,size:"sm"})}),(0,e.jsx)("strong",{children:p})]}),(0,e.jsx)("p",{className:"hint-warn-inline",children:o.error})]}):(0,e.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":o.larkAppId,children:[(0,e.jsxs)("header",{className:"skills-bot-head",children:[(0,e.jsx)(Ce,{html:we({name:p,larkAppId:o.larkAppId,size:"sm",dot:"ok"})}),(0,e.jsxs)("div",{className:"skills-bot-title-line",children:[(0,e.jsx)("strong",{children:p}),(0,e.jsx)("span",{className:"skills-count-pill",children:s("skills.skillCount",{count:w.length})})]})]}),(0,e.jsxs)("section",{className:"skills-policy-panel",children:[(0,e.jsx)("div",{className:"skills-priority-head",children:(0,e.jsx)("h3",{className:"skills-priority-title",children:s("skills.priority")})}),(0,e.jsx)(xl,{botId:o.larkAppId,names:w,installedNames:k,skills:f,busy:y===`${o.larkAppId}:set`,onSave:R=>r(o.larkAppId,R)})]}),(0,e.jsx)("span",{className:Re(b),"data-bot-status":!0,children:b?.text??""})]})}function $l(l){return He(l,(0,e.jsx)(Tl,{}))}export{Ml as BotPolicyCard,Il as InstalledSkillsLibrary,Pl as RemoveSkillsDialog,xl as SkillMultiPicker,Rl as SkillsInstallPanel,$l as renderSkillsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G,b as J,c as S,d as re}from"./chunk-EVK77ASG.js";import{b as E}from"./chunk-FMJNOATE.js";import{a as oe,d as q,g as ie,p as se}from"./chunk-I35DXGM4.js";import"./chunk-KEAOTUL3.js";import{a as K}from"./chunk-SYC6D5XU.js";import{a as z,d as ne}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var d=L(z(),1);async function V(){return G("/api/team/hosted")}async function le(){return G("/api/team/remote-roster")}async function de(t,a){return re("/api/team/local-bots/"+encodeURIComponent(t)+"/capability",{capability:a})}async function me(t){return G("/api/team/local-bots/"+encodeURIComponent(t)+"/role")}async function ce(t){return S("/api/team/identity/auto-bind",t?{unionId:t}:void 0)}async function ue(t,a){return J("DELETE",`/api/team/hosted/${encodeURIComponent(t)}/members/${encodeURIComponent(a)}`)}async function pe(t,a,n){return S("/api/team/federated-group",{name:a,larkAppIds:n,teamId:t})}async function ge(t,a,n,o){return S("/api/team/remote-group",{hubUrl:t,teamId:a,name:n,larkAppIds:o})}async function ye(t){return S("/api/team/hosted",{name:t})}async function fe(t){return J("DELETE","/api/team/hosted/"+encodeURIComponent(t))}async function be(t){return S("/api/team/local-invite",{teamId:t})}async function ke(t,a){return S("/api/team/join-remote",{hubUrl:t,inviteCode:a})}function F(t,a){let n=a.query.trim().toLowerCase();return!(n&&!((t.name||"")+" "+(t.cliId||"")+" "+(t.capability||"")).toLowerCase().includes(n)||a.cliId&&t.cliId!==a.cliId||a.hasCapability&&!t.capability||a.hasRole&&!t.hasTeamRole)}function he(t){return Array.from(new Set(t.flatMap(a=>a.bots.map(n=>n.cliId)).filter(Boolean))).sort()}function ve(t,a){return(t.teams||[]).map(n=>({kind:"local",key:`local:${n.teamId}`,teamId:n.teamId,label:n.isDefault?a("team.myHostedTeam"):n.name,sub:"",ok:!0,deployments:n.deployments||[],bots:n.bots||[]}))}function Te(t,a){return(t.memberships||[]).map(o=>{let m=o.roster?.deployments||[],r=m.find(v=>v.local),p=r?.name?a("team.remoteTeamLabel",{name:r.name}):o.teamName||o.teamId;return{kind:"remote",key:`${o.hubUrl}::${o.teamId}`,teamId:o.teamId,label:p,sub:o.hubUrl,ok:!!o.ok,error:o.error,hubUrl:o.hubUrl,deployments:m,bots:o.roster?.bots||[]}})}function W(t,a,n){return t.map(o=>({...o,bots:o.bots.map(m=>m.larkAppId===a?{...m,capability:n.trim()||null}:m)}))}var e=L(ne(),1),we=L(z(),1);function Ie(){let t=(0,d.useRef)(!0);return(0,d.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ce(t){let a=E(),n=t.active==="home",o=t.active==="manage";return(0,e.jsxs)("nav",{className:"team-subnav insight-tabs",role:"tablist","aria-label":a("team.eyebrow"),children:[(0,e.jsx)("a",{href:"#/team",className:`itab${n?" on":""}`,role:"tab","aria-selected":n,children:a("team.navHome")}),(0,e.jsx)("a",{href:"#/team/manage",className:`itab${o?" on":""}`,role:"tab","aria-selected":o,children:a("team.navManage")})]})}function Q(t,a){return t.get(a)??new Set}function He(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)([]),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)(t("team.unbound")),[u,R]=(0,d.useState)({query:"",cliId:"",hasCapability:!1,hasRole:!1}),[P,M]=(0,d.useState)(()=>new Map),[D,x]=(0,d.useState)(()=>new Map),[O,I]=(0,d.useState)(()=>new Set),[B,A]=(0,d.useState)(()=>new Set),[U,C]=(0,d.useState)({kind:"hidden"}),[j,c]=(0,d.useState)(()=>new Map),[g,h]=(0,d.useState)(null),y=(0,d.useMemo)(()=>[...n,...m],[n,m]),Y=(0,d.useMemo)(()=>he(y),[y]),Z=(0,d.useMemo)(()=>[{value:"",label:t("team.allCli")},...Y.map(i=>({value:i,label:i}))],[Y,t]),H=(0,d.useCallback)(async()=>{let i=await V();if(!a.current)return;let s=i.body;if(!s?.ok){o([]);return}v(s.deployment?.deploymentId??""),T(s.deployment?.ownerName||(s.deployment?.ownerUnionId?t("team.bound"):t("team.unbound"))),o(ve(s,t))},[a,t]),ee=(0,d.useCallback)(async()=>{let i=await le();a.current&&r(Te(i.body,t))},[a,t]);(0,d.useEffect)(()=>{M(new Map),x(new Map),I(new Set),A(new Set),H(),ee()},[H,ee]),(0,d.useEffect)(()=>{T(i=>i==="\u672A\u7ED1\u5B9A"||i==="Unbound"?t("team.unbound"):i)},[t]),(0,d.useEffect)(()=>{let i=new Map;for(let s of y)i.set(s.key,new Set(s.bots.filter(l=>F(l,u)).map(l=>l.larkAppId)));M(s=>{let l=!1,f=new Map;for(let[b,k]of s){let w=i.get(b),$=new Set([...k].filter(Ae=>w?.has(Ae)));$.size!==k.size&&(l=!0),$.size&&f.set(b,$)}return l?f:s})},[u,y]);let te=(0,d.useMemo)(()=>{if(!y.length)return"";let i=new Set,s=new Set;for(let b of y)b.bots.filter(w=>F(w,u)).forEach(w=>i.add(w.larkAppId)),b.bots.forEach(w=>s.add(w.larkAppId));let l=y.length>1?t("team.acrossTeams",{n:y.length}):"";return`\xB7 ${i.size===s.size?`${s.size}`:`${i.size} / ${s.size}`} ${t("team.botsWord")}${l}`},[u,y,t]);function _(i,s){c(l=>{let f=new Map(l);return f.set(i,s),f})}function Se(i,s,l){M(f=>{let b=new Map(f),k=new Set(b.get(i)??[]);return l?k.add(s):k.delete(s),k.size?b.set(i,k):b.delete(i),b})}function Me(i,s){x(l=>{let f=new Map(l);return s?f.set(i,s):f.delete(i),f})}async function xe(i,s){await de(i,s),a.current&&(o(l=>W(l,i,s)),r(l=>W(l,i,s)))}async function Be(i,s){let l=await me(i);a.current&&h({app:i,name:s,content:l.body?.role||""})}async function Pe(i,s,l){confirm(t("team.removeMemberConfirm",{name:l}))&&(await ue(i,s),a.current&&H())}async function De(i){let s=[...Q(P,i.key)];if(!s.length){_(i.key,{kind:"err",key:"team.errPickBot"});return}let l=(D.get(i.key)||"").trim()||t("team.defaultGroupName");_(i.key,{kind:"muted",key:"team.creatingGroup"});let f=i.kind==="local"?await pe(i.teamId,l,s):await ge(i.hubUrl,i.teamId,l,s);a.current&&(_(i.key,{kind:"group-result",body:f.body,status:f.status}),f.body?.ok&&(M(b=>{let k=new Map(b);return k.delete(i.key),k}),x(b=>{let k=new Map(b);return k.delete(i.key),k}),i.kind==="local"&&H()))}async function ae(i){C({kind:"loading",key:i?"team.binding":"team.identifying"});let s=await ce(i);if(!a.current)return;let l=s.body;if(l?.ok&&l.owner){C({kind:"ok",name:l.owner.name||l.owner.unionId||""}),H();return}if(l?.ok&&l.needChoice&&Array.isArray(l.candidates)){C({kind:"choice",candidates:l.candidates});return}if(l?.error==="no_candidates"){C({kind:"err",key:"team.noCandidates"});return}C({kind:"bind-fail",error:String(l?.error||"unknown")})}return(0,e.jsxs)("section",{className:"page team-page team-home-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.homeTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"home"})})]}),(0,e.jsxs)("section",{className:"overview-block team-identity-section",children:[(0,e.jsx)(q,{title:t("team.localDeployTitle"),hint:t("team.bindHint")}),(0,e.jsx)("div",{className:"card team-card team-identity-card",children:(0,e.jsxs)("p",{className:"team-identity-row",children:[(0,e.jsx)("span",{className:"team-identity-label",children:t("team.myIdentity")}),(0,e.jsx)("b",{id:"tf-owner",children:N}),(0,e.jsx)("button",{type:"button",id:"tf-autobind",className:"page-primary-action",onClick:()=>{ae()},children:t("team.bindBtn")}),(0,e.jsx)("span",{id:"tf-bind-out",className:"team-bind-status",hidden:U.kind==="hidden",children:(0,e.jsx)(Le,{state:U,tr:t,onPick:i=>{ae(i)}})})]})})]}),(0,e.jsxs)("section",{className:"overview-block team-roster-section",children:[(0,e.jsx)(q,{title:t("team.myTeams"),count:te?te.replace(/^·\s*/,""):void 0,hint:t("team.teamsHint")}),(0,e.jsxs)("div",{className:"card team-card team-roster-card",children:[(0,e.jsxs)("form",{className:"team-filters dashboard-toolbar",onSubmit:i=>i.preventDefault(),children:[(0,e.jsx)("input",{id:"tf-search",type:"search",placeholder:t("team.searchPh"),value:u.query,onChange:i=>R(s=>({...s,query:i.target.value}))}),(0,e.jsx)(se,{id:"tf-cli",className:"team-cli-menu",ariaLabel:t("team.allCli"),value:u.cliId,label:oe(Z,u.cliId),options:Z,onChange:i=>R(s=>({...s,cliId:i}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-fcap",checked:u.hasCapability,onChange:i=>R(s=>({...s,hasCapability:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasCap")})]}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-frole",checked:u.hasRole,onChange:i=>R(s=>({...s,hasRole:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasRole")})]})]}),(0,e.jsx)("div",{id:"tf-teams",children:(0,e.jsx)(Oe,{teams:y,filters:u,pickedByTeam:P,gnameByTeam:D,expandedTeams:O,expandedDeps:B,groupOutputs:j,myDeploymentId:p,tr:t,onToggleTeam:i=>I(s=>Ne(s,i)),onToggleDep:i=>A(s=>Ne(s,i)),onPick:Se,onGroupNameChange:Me,onCapabilityChange:(i,s)=>{xe(i,s)},onOpenRole:(i,s)=>{Be(i,s)},onRemoveMember:(i,s,l)=>{Pe(i,s,l)},onPullGroup:i=>{De(i)}})})]})]}),(0,e.jsx)(_e,{state:g,tr:t,onClose:()=>h(null)})]})}function Ne(t,a){let n=new Set(t);return n.has(a)?n.delete(a):n.add(a),n}function Le(t){let{state:a,tr:n}=t;return a.kind==="hidden"?null:a.kind==="loading"?(0,e.jsx)("span",{className:"team-bind-loading",children:n(a.key)}):a.kind==="ok"?(0,e.jsx)("span",{className:"ok",children:n("team.bound2",{name:a.name})}):a.kind==="choice"?(0,e.jsxs)(e.Fragment,{children:[n("team.multiCandidate"),(0,e.jsx)("br",{}),a.candidates.map(o=>(0,e.jsx)("button",{type:"button",className:"tf-pickowner ghost","data-union":o.unionId,style:{margin:"2px"},onClick:()=>t.onPick(o.unionId),children:o.name||o.unionId},o.unionId))]}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)("span",{className:"err",children:n("team.bindFail",{error:a.error})})}function Oe(t){let{tr:a}=t;return t.teams.length?(0,e.jsx)(e.Fragment,{children:t.teams.map(n=>{let o=n.bots.filter(p=>F(p,t.filters)),m=!t.expandedTeams.has(n.key),r=n.kind==="remote"?n.ok?(0,e.jsx)("span",{className:"team-status-pill ok",children:a("team.connected")}):(0,e.jsx)("span",{className:"team-status-pill err",children:a("team.connectFail",{error:n.error||""})}):(0,e.jsx)("span",{className:"team-status-pill muted",children:a("team.iHost")});return(0,e.jsxs)("article",{className:"card team-list-card",children:[(0,e.jsxs)("button",{type:"button",className:"tf-team-h","data-tk":n.key,"aria-expanded":!m,onClick:()=>t.onToggleTeam(n.key),children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:m?"\u203A":"\u2304"}),(0,e.jsx)("b",{children:n.label}),n.sub?(0,e.jsx)("span",{className:"muted",children:n.sub}):null,r,(0,e.jsx)("span",{className:"team-meta-pill",children:a("team.teamMeta",{deps:n.deployments.length,bots:n.bots.length})})]}),m?null:n.kind==="remote"&&!n.ok?(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:a("team.rosterFail")}):(0,e.jsx)(Ue,{...t,team:n,filtered:o})]},n.key)})}):(0,e.jsx)("p",{className:"muted",children:a("team.noTeams")})}function Ue(t){let{team:a,tr:n}=t,o=[...a.deployments].sort((r,p)=>r.local===p.local?0:r.local?-1:1),m=o.some(r=>t.filtered.some(p=>p.deployment.id===r.id));return(0,e.jsxs)(e.Fragment,{children:[o.map(r=>(0,we.createElement)(je,{...t,deployment:r,key:r.id})),m?null:(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:n("team.noMatch")}),(0,e.jsxs)("div",{className:"team-pull-row",children:[(0,e.jsxs)("label",{className:"team-pill-field team-group-name-field",children:[(0,e.jsx)("span",{children:n("team.gnameLabel")}),(0,e.jsx)("input",{className:"tf-gname","data-tk":a.key,value:t.gnameByTeam.get(a.key)||"",placeholder:n("team.gnamePlaceholder"),onChange:r=>t.onGroupNameChange(a.key,r.target.value)})]}),(0,e.jsx)("button",{className:"tf-grp page-primary-action","data-tk":a.key,onClick:()=>t.onPullGroup(a),children:n("team.pullGroupBtn")}),(0,e.jsx)("span",{className:"muted team-pull-hint",children:n("team.pullGroupHint")}),(0,e.jsx)("span",{className:"tf-gout","data-tk":a.key,children:(0,e.jsx)(Ge,{output:t.groupOutputs.get(a.key),tr:n})})]})]})}function je(t){let{team:a,deployment:n,tr:o}=t,m=t.filtered.filter(u=>u.deployment.id===n.id);if(!m.length)return null;let r=n.id===t.myDeploymentId,p=r?o("team.tagLocal"):n.stale?o("team.tagRemoteStale"):o("team.tagRemote"),v=`${a.key}::${n.id}`,N=t.expandedDeps.has(v),T=m.filter(u=>Q(t.pickedByTeam,a.key).has(u.larkAppId)).length;return(0,e.jsxs)("section",{className:"team-deployment-block",children:[(0,e.jsxs)("div",{className:"tf-dep-h","data-dk":v,"aria-expanded":N,role:"button",tabIndex:0,onClick:()=>t.onToggleDep(v),onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),t.onToggleDep(v))},children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:N?"\u2304":"\u203A"}),(0,e.jsx)("b",{children:n.name}),(0,e.jsxs)("span",{className:"muted",children:[o("team.depTag",{tag:p})," \xB7 ",o("team.depCount",{count:m.length}),T?o("team.depSelected",{n:T}):""]}),a.kind==="local"&&!r?(0,e.jsx)("button",{type:"button",className:"tf-rmmember ghost","data-team":a.teamId,"data-dep":n.id,"data-name":n.name,onClick:u=>{u.stopPropagation(),t.onRemoveMember(a.teamId,n.id,n.name)},children:o("team.removeMember")}):null]}),N?(0,e.jsx)("div",{className:"team-roster-list",children:m.map(u=>(0,e.jsx)(Ee,{bot:u,mine:r,picked:Q(t.pickedByTeam,a.key).has(u.larkAppId),teamKey:a.key,tr:o,onPick:t.onPick,onCapabilityChange:t.onCapabilityChange,onOpenRole:t.onOpenRole},u.larkAppId))}):null]})}function Ee(t){let{bot:a,tr:n}=t,o=a.deployment.stale?{opacity:.55}:void 0,m=()=>t.onPick(t.teamKey,a.larkAppId,!t.picked);return(0,e.jsxs)("article",{className:`team-bot-row${t.picked?" selected":""}`,style:o,role:"checkbox","aria-checked":t.picked,tabIndex:0,onClick:r=>{Re(r.target)||m()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||Re(r.target)||(r.preventDefault(),m())},children:[(0,e.jsxs)("label",{className:`team-check-pill${t.picked?" selected":""}`,onClick:r=>r.stopPropagation(),children:[(0,e.jsx)("input",{type:"checkbox",className:"tf-pick","data-tk":t.teamKey,"data-app":a.larkAppId,checked:t.picked,onChange:r=>t.onPick(t.teamKey,a.larkAppId,r.target.checked)}),(0,e.jsx)("span",{className:"team-check-dot","aria-hidden":"true"})]}),(0,e.jsxs)("div",{className:"team-bot-main",children:[(0,e.jsx)("strong",{children:a.name}),(0,e.jsx)("span",{children:a.larkAppId})]}),(0,e.jsx)("span",{className:"team-meta-pill",children:a.cliId}),(0,e.jsx)("div",{className:"team-capability-cell",children:t.mine?(0,e.jsxs)("label",{className:"team-pill-field team-cap-field",children:[(0,e.jsx)("span",{children:n("team.capLabel")}),(0,e.jsx)("input",{className:"tf-cap","data-app":a.larkAppId,defaultValue:a.capability||"",placeholder:n("team.capPh"),onBlur:r=>{let p=r.target.value;p!==(a.capability||"")&&t.onCapabilityChange(a.larkAppId,p)},onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),r.currentTarget.blur())}})]}):a.capability||null}),(0,e.jsx)("div",{className:"team-role-cell",children:a.hasTeamRole?t.mine?(0,e.jsx)("button",{className:"tf-role","data-app":a.larkAppId,"data-name":a.name,onClick:()=>t.onOpenRole(a.larkAppId,a.name),children:n("team.viewRole")}):n("team.hasRoleShort"):(0,e.jsx)("span",{className:"muted",children:"\u2014"})})]})}function Re(t){return t instanceof HTMLElement?!!t.closest('button, input, textarea, select, a, label, [contenteditable="true"]'):!1}function Ge(t){let{output:a,tr:n}=t;return a?a.kind==="muted"?(0,e.jsx)("span",{className:"muted",children:n(a.key)}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)(Fe,{body:a.body,status:a.status,tr:n}):null}function Fe(t){let{body:a,status:n,tr:o}=t;if(a?.ok&&a.chatId){let p=a.shareLink||"https://applink.feishu.cn/client/chat/open?openChatId="+encodeURIComponent(a.chatId);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"ok",children:o("team.groupCreated")}),a.delegatedTo?o("team.delegatedBy",{name:String(a.delegatedTo)}):""," \xB7 ",(0,e.jsx)("a",{href:p,target:"_blank",rel:"noreferrer",children:o("team.openInLark")}),(a.invalidBotIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidBots",{ids:(a.invalidBotIds||[]).join(", ")})]}):null,(a.invalidOwnerUnionIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidOwners",{n:(a.invalidOwnerUnionIds||[]).length})]}):null,a.missingOperatorIdentity?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.missingIdentity")]}):null,(a.skippedNoOwner||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.skippedNoOwner",{n:(a.skippedNoOwner||[]).length})]}):null]})}let m=a?.error||n,r=m==="no_local_online_bot"?o("team.errNoLocalBot"):m==="all_bots_skipped_no_owner"?o("team.errAllSkipped"):m==="no_creator_available"?o("team.errNoCreator"):m==="delegation_timeout"?o("team.errDelegationTimeout"):o("team.errGroupCreate",{error:String(m)});return(0,e.jsx)("span",{className:"err",children:r})}function _e(t){let{state:a,tr:n}=t;return(0,e.jsx)("div",{id:"tf-modal",className:"team-role-modal","data-app":a?.app,hidden:!a,children:(0,e.jsxs)("div",{className:"team-role-dialog",children:[(0,e.jsx)("h2",{id:"tf-modal-title",children:a?n("team.roleModalTitleName",{name:a.name}):n("team.roleModalTitle")}),(0,e.jsx)("p",{className:"muted",style:{fontSize:"13px"},children:n("team.roleModalHint")}),(0,e.jsx)("textarea",{id:"tf-modal-text",readOnly:!0,value:a?.content??""}),(0,e.jsx)("div",{className:"team-role-actions",children:(0,e.jsx)("button",{type:"button",id:"tf-modal-cancel",onClick:t.onClose,children:n("team.close")})})]})})}function $e(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)(""),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)({kind:"none"}),[u,R]=(0,d.useState)(()=>new Map),[P,M]=(0,d.useState)(""),[D,x]=(0,d.useState)(""),[O,I]=(0,d.useState)({kind:"none"}),B=(0,d.useCallback)(async()=>{let c=await V();if(!a.current)return;let g=c.body;r(h=>g?.suggestedHubUrl||h),o(g?.teams||[])},[a]);(0,d.useEffect)(()=>{B()},[B]);async function A(){let c=p.trim();if(!c){T({kind:"err",key:"team.errName"});return}T({kind:"muted",key:"team.creating"});let g=await ye(c);a.current&&(g.body?.ok?(T({kind:"ok",key:"team.created"}),v(""),B()):T({kind:"create-fail",error:String(g.body?.error||g.status)}))}async function U(c){R(h=>{let y=new Map(h);return y.set(c,{kind:"muted",key:"team.generating"}),y});let g=await be(c);a.current&&R(h=>{let y=new Map(h);return y.set(c,g.body?.code?{kind:"invite",code:g.body.code}:{kind:"err",key:"team.genFail"}),y})}async function C(c,g){confirm(t("team.delConfirm",{name:g}))&&(await fe(c),a.current&&B())}async function j(){let c=P.trim(),g=D.trim();if(I({kind:"muted",key:"team.joining"}),!c||!g){I({kind:"err",key:"team.errHubCode"});return}let h=await ke(c,g);a.current&&(h.body?.ok?(I({kind:"joined",name:String(h.body.teamName||"")}),x("")):I({kind:"join-fail",error:h.body?.error||h.status}))}return(0,e.jsxs)("section",{className:"page team-page team-manage-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.manageTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"manage"})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.hostedTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar",onSubmit:c=>{c.preventDefault(),A()},children:[(0,e.jsx)("input",{id:"tm-newname",type:"text",placeholder:t("team.newTeamPh"),value:p,onChange:c=>v(c.target.value)}),(0,e.jsx)(ie,{id:"tm-create",className:"page-primary-action",onClick:()=>{A()},children:t("team.createTeamBtn")}),(0,e.jsx)("span",{className:"toolbar-status tm-cout",children:(0,e.jsx)(X,{status:N,tr:t})})]}),(0,e.jsx)("div",{id:"tm-list",children:(0,e.jsx)(ze,{teams:n,suggestedHubUrl:m,inviteStatuses:u,tr:t,onInvite:c=>{U(c)},onDelete:(c,g)=>{C(c,g)}})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.joinTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar team-join-form",onSubmit:c=>{c.preventDefault(),j()},children:[(0,e.jsx)("input",{id:"tm-hub",type:"text",placeholder:t("team.hubPh"),value:P,onChange:c=>M(c.target.value)}),(0,e.jsx)("input",{id:"tm-code",type:"text",placeholder:t("team.codePh"),value:D,onChange:c=>x(c.target.value)}),(0,e.jsx)("button",{type:"button",id:"tm-join",className:"page-primary-action",onClick:()=>{j()},children:t("team.joinBtn")})]}),(0,e.jsx)("div",{id:"tm-join-out",className:"team-inline-output",hidden:O.kind==="none",children:(0,e.jsx)(X,{status:O,tr:t})})]})]})}function ze(t){let{teams:a,tr:n}=t;return a.length?(0,e.jsx)(e.Fragment,{children:a.map(o=>{let m=(o.deployments||[]).filter(p=>!p.local).length,r=t.inviteStatuses.get(o.teamId)??{kind:"none"};return(0,e.jsxs)("div",{className:"card team-list-card team-manage-card",children:[(0,e.jsxs)("div",{className:"team-manage-head",children:[(0,e.jsx)("b",{children:o.name}),o.isDefault?(0,e.jsx)("span",{className:"team-status-pill muted",children:n("team.default")}):null,(0,e.jsxs)("span",{className:"team-meta-pill",children:[n("team.manageMetaDeps",{count:(o.deployments||[]).length}),m?n("team.manageMetaRemote",{r:m}):""," \xB7 ",n("team.manageMetaBots",{count:(o.bots||[]).length})]}),(0,e.jsxs)("span",{className:"team-manage-actions",children:[(0,e.jsx)("button",{className:"tm-invite ghost","data-team":o.teamId,onClick:()=>t.onInvite(o.teamId),children:n("team.genInvite")}),o.isDefault?null:(0,e.jsx)("button",{className:"tm-del ghost","data-team":o.teamId,"data-name":o.name,onClick:()=>t.onDelete(o.teamId,o.name),children:n("team.delBtn")})]})]}),(0,e.jsx)("div",{className:"tm-inv-out team-inline-output","data-team":o.teamId,hidden:r.kind==="none",children:(0,e.jsx)(X,{status:r,tr:n,suggestedHubUrl:t.suggestedHubUrl})})]},o.teamId)})}):(0,e.jsx)("p",{className:"muted",children:n("team.noTeamsShort")})}function X(t){let{status:a,tr:n}=t;if(a.kind==="none")return null;if(a.kind==="muted")return(0,e.jsx)("span",{className:"muted",children:n(a.key)});if(a.kind==="ok")return(0,e.jsx)("span",{className:"ok",children:n(a.key)});if(a.kind==="err")return(0,e.jsx)("span",{className:"err",children:n(a.key)});if(a.kind==="create-fail")return(0,e.jsx)("span",{className:"err",children:n("team.createFail",{error:a.error})});if(a.kind==="invite")return(0,e.jsxs)(e.Fragment,{children:[n("team.inviteResultLede"),(0,e.jsx)("br",{}),n("team.inviteHub"),(0,e.jsx)("code",{children:t.suggestedHubUrl||""}),(0,e.jsx)("br",{}),n("team.inviteCode"),(0,e.jsx)("code",{className:"team-invite-code",children:a.code})]});if(a.kind==="joined")return(0,e.jsx)("span",{className:"ok",children:n("team.joined",{name:a.name})});let o=a.error,m=o==="cannot_join_self"?n("team.joinErrSelf"):o==="deployment_already_joined"?n("team.joinErrAlready"):o==="hub_unreachable"?n("team.joinErrUnreachable"):o==="hub_timeout"?n("team.joinErrTimeout"):n("team.joinErrGeneric",{error:String(o)});return(0,e.jsx)("span",{className:"err",children:m})}function Xe(t){return K(t,(0,e.jsx)(He,{}))}function Ye(t){return K(t,(0,e.jsx)($e,{}))}export{Xe as renderTeamFederationPage,Ye as renderTeamManagePage};
|
|
1
|
+
import{a as G,b as J,c as S,d as re}from"./chunk-EVK77ASG.js";import{b as E}from"./chunk-3PMN55Z6.js";import{a as oe,d as q,g as ie,p as se}from"./chunk-I35DXGM4.js";import"./chunk-RXVA6XW3.js";import{a as K}from"./chunk-SYC6D5XU.js";import{a as z,d as ne}from"./chunk-5THX4DI2.js";import{c as L}from"./chunk-7SZRL6FY.js";var d=L(z(),1);async function V(){return G("/api/team/hosted")}async function le(){return G("/api/team/remote-roster")}async function de(t,a){return re("/api/team/local-bots/"+encodeURIComponent(t)+"/capability",{capability:a})}async function me(t){return G("/api/team/local-bots/"+encodeURIComponent(t)+"/role")}async function ce(t){return S("/api/team/identity/auto-bind",t?{unionId:t}:void 0)}async function ue(t,a){return J("DELETE",`/api/team/hosted/${encodeURIComponent(t)}/members/${encodeURIComponent(a)}`)}async function pe(t,a,n){return S("/api/team/federated-group",{name:a,larkAppIds:n,teamId:t})}async function ge(t,a,n,o){return S("/api/team/remote-group",{hubUrl:t,teamId:a,name:n,larkAppIds:o})}async function ye(t){return S("/api/team/hosted",{name:t})}async function fe(t){return J("DELETE","/api/team/hosted/"+encodeURIComponent(t))}async function be(t){return S("/api/team/local-invite",{teamId:t})}async function ke(t,a){return S("/api/team/join-remote",{hubUrl:t,inviteCode:a})}function F(t,a){let n=a.query.trim().toLowerCase();return!(n&&!((t.name||"")+" "+(t.cliId||"")+" "+(t.capability||"")).toLowerCase().includes(n)||a.cliId&&t.cliId!==a.cliId||a.hasCapability&&!t.capability||a.hasRole&&!t.hasTeamRole)}function he(t){return Array.from(new Set(t.flatMap(a=>a.bots.map(n=>n.cliId)).filter(Boolean))).sort()}function ve(t,a){return(t.teams||[]).map(n=>({kind:"local",key:`local:${n.teamId}`,teamId:n.teamId,label:n.isDefault?a("team.myHostedTeam"):n.name,sub:"",ok:!0,deployments:n.deployments||[],bots:n.bots||[]}))}function Te(t,a){return(t.memberships||[]).map(o=>{let m=o.roster?.deployments||[],r=m.find(v=>v.local),p=r?.name?a("team.remoteTeamLabel",{name:r.name}):o.teamName||o.teamId;return{kind:"remote",key:`${o.hubUrl}::${o.teamId}`,teamId:o.teamId,label:p,sub:o.hubUrl,ok:!!o.ok,error:o.error,hubUrl:o.hubUrl,deployments:m,bots:o.roster?.bots||[]}})}function W(t,a,n){return t.map(o=>({...o,bots:o.bots.map(m=>m.larkAppId===a?{...m,capability:n.trim()||null}:m)}))}var e=L(ne(),1),we=L(z(),1);function Ie(){let t=(0,d.useRef)(!0);return(0,d.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ce(t){let a=E(),n=t.active==="home",o=t.active==="manage";return(0,e.jsxs)("nav",{className:"team-subnav insight-tabs",role:"tablist","aria-label":a("team.eyebrow"),children:[(0,e.jsx)("a",{href:"#/team",className:`itab${n?" on":""}`,role:"tab","aria-selected":n,children:a("team.navHome")}),(0,e.jsx)("a",{href:"#/team/manage",className:`itab${o?" on":""}`,role:"tab","aria-selected":o,children:a("team.navManage")})]})}function Q(t,a){return t.get(a)??new Set}function He(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)([]),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)(t("team.unbound")),[u,R]=(0,d.useState)({query:"",cliId:"",hasCapability:!1,hasRole:!1}),[P,M]=(0,d.useState)(()=>new Map),[D,x]=(0,d.useState)(()=>new Map),[O,I]=(0,d.useState)(()=>new Set),[B,A]=(0,d.useState)(()=>new Set),[U,C]=(0,d.useState)({kind:"hidden"}),[j,c]=(0,d.useState)(()=>new Map),[g,h]=(0,d.useState)(null),y=(0,d.useMemo)(()=>[...n,...m],[n,m]),Y=(0,d.useMemo)(()=>he(y),[y]),Z=(0,d.useMemo)(()=>[{value:"",label:t("team.allCli")},...Y.map(i=>({value:i,label:i}))],[Y,t]),H=(0,d.useCallback)(async()=>{let i=await V();if(!a.current)return;let s=i.body;if(!s?.ok){o([]);return}v(s.deployment?.deploymentId??""),T(s.deployment?.ownerName||(s.deployment?.ownerUnionId?t("team.bound"):t("team.unbound"))),o(ve(s,t))},[a,t]),ee=(0,d.useCallback)(async()=>{let i=await le();a.current&&r(Te(i.body,t))},[a,t]);(0,d.useEffect)(()=>{M(new Map),x(new Map),I(new Set),A(new Set),H(),ee()},[H,ee]),(0,d.useEffect)(()=>{T(i=>i==="\u672A\u7ED1\u5B9A"||i==="Unbound"?t("team.unbound"):i)},[t]),(0,d.useEffect)(()=>{let i=new Map;for(let s of y)i.set(s.key,new Set(s.bots.filter(l=>F(l,u)).map(l=>l.larkAppId)));M(s=>{let l=!1,f=new Map;for(let[b,k]of s){let w=i.get(b),$=new Set([...k].filter(Ae=>w?.has(Ae)));$.size!==k.size&&(l=!0),$.size&&f.set(b,$)}return l?f:s})},[u,y]);let te=(0,d.useMemo)(()=>{if(!y.length)return"";let i=new Set,s=new Set;for(let b of y)b.bots.filter(w=>F(w,u)).forEach(w=>i.add(w.larkAppId)),b.bots.forEach(w=>s.add(w.larkAppId));let l=y.length>1?t("team.acrossTeams",{n:y.length}):"";return`\xB7 ${i.size===s.size?`${s.size}`:`${i.size} / ${s.size}`} ${t("team.botsWord")}${l}`},[u,y,t]);function _(i,s){c(l=>{let f=new Map(l);return f.set(i,s),f})}function Se(i,s,l){M(f=>{let b=new Map(f),k=new Set(b.get(i)??[]);return l?k.add(s):k.delete(s),k.size?b.set(i,k):b.delete(i),b})}function Me(i,s){x(l=>{let f=new Map(l);return s?f.set(i,s):f.delete(i),f})}async function xe(i,s){await de(i,s),a.current&&(o(l=>W(l,i,s)),r(l=>W(l,i,s)))}async function Be(i,s){let l=await me(i);a.current&&h({app:i,name:s,content:l.body?.role||""})}async function Pe(i,s,l){confirm(t("team.removeMemberConfirm",{name:l}))&&(await ue(i,s),a.current&&H())}async function De(i){let s=[...Q(P,i.key)];if(!s.length){_(i.key,{kind:"err",key:"team.errPickBot"});return}let l=(D.get(i.key)||"").trim()||t("team.defaultGroupName");_(i.key,{kind:"muted",key:"team.creatingGroup"});let f=i.kind==="local"?await pe(i.teamId,l,s):await ge(i.hubUrl,i.teamId,l,s);a.current&&(_(i.key,{kind:"group-result",body:f.body,status:f.status}),f.body?.ok&&(M(b=>{let k=new Map(b);return k.delete(i.key),k}),x(b=>{let k=new Map(b);return k.delete(i.key),k}),i.kind==="local"&&H()))}async function ae(i){C({kind:"loading",key:i?"team.binding":"team.identifying"});let s=await ce(i);if(!a.current)return;let l=s.body;if(l?.ok&&l.owner){C({kind:"ok",name:l.owner.name||l.owner.unionId||""}),H();return}if(l?.ok&&l.needChoice&&Array.isArray(l.candidates)){C({kind:"choice",candidates:l.candidates});return}if(l?.error==="no_candidates"){C({kind:"err",key:"team.noCandidates"});return}C({kind:"bind-fail",error:String(l?.error||"unknown")})}return(0,e.jsxs)("section",{className:"page team-page team-home-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.homeTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"home"})})]}),(0,e.jsxs)("section",{className:"overview-block team-identity-section",children:[(0,e.jsx)(q,{title:t("team.localDeployTitle"),hint:t("team.bindHint")}),(0,e.jsx)("div",{className:"card team-card team-identity-card",children:(0,e.jsxs)("p",{className:"team-identity-row",children:[(0,e.jsx)("span",{className:"team-identity-label",children:t("team.myIdentity")}),(0,e.jsx)("b",{id:"tf-owner",children:N}),(0,e.jsx)("button",{type:"button",id:"tf-autobind",className:"page-primary-action",onClick:()=>{ae()},children:t("team.bindBtn")}),(0,e.jsx)("span",{id:"tf-bind-out",className:"team-bind-status",hidden:U.kind==="hidden",children:(0,e.jsx)(Le,{state:U,tr:t,onPick:i=>{ae(i)}})})]})})]}),(0,e.jsxs)("section",{className:"overview-block team-roster-section",children:[(0,e.jsx)(q,{title:t("team.myTeams"),count:te?te.replace(/^·\s*/,""):void 0,hint:t("team.teamsHint")}),(0,e.jsxs)("div",{className:"card team-card team-roster-card",children:[(0,e.jsxs)("form",{className:"team-filters dashboard-toolbar",onSubmit:i=>i.preventDefault(),children:[(0,e.jsx)("input",{id:"tf-search",type:"search",placeholder:t("team.searchPh"),value:u.query,onChange:i=>R(s=>({...s,query:i.target.value}))}),(0,e.jsx)(se,{id:"tf-cli",className:"team-cli-menu",ariaLabel:t("team.allCli"),value:u.cliId,label:oe(Z,u.cliId),options:Z,onChange:i=>R(s=>({...s,cliId:i}))}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-fcap",checked:u.hasCapability,onChange:i=>R(s=>({...s,hasCapability:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasCap")})]}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",id:"tf-frole",checked:u.hasRole,onChange:i=>R(s=>({...s,hasRole:i.target.checked}))}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"}),(0,e.jsx)("span",{className:"filter-toggle-label",children:t("team.hasRole")})]})]}),(0,e.jsx)("div",{id:"tf-teams",children:(0,e.jsx)(Oe,{teams:y,filters:u,pickedByTeam:P,gnameByTeam:D,expandedTeams:O,expandedDeps:B,groupOutputs:j,myDeploymentId:p,tr:t,onToggleTeam:i=>I(s=>Ne(s,i)),onToggleDep:i=>A(s=>Ne(s,i)),onPick:Se,onGroupNameChange:Me,onCapabilityChange:(i,s)=>{xe(i,s)},onOpenRole:(i,s)=>{Be(i,s)},onRemoveMember:(i,s,l)=>{Pe(i,s,l)},onPullGroup:i=>{De(i)}})})]})]}),(0,e.jsx)(_e,{state:g,tr:t,onClose:()=>h(null)})]})}function Ne(t,a){let n=new Set(t);return n.has(a)?n.delete(a):n.add(a),n}function Le(t){let{state:a,tr:n}=t;return a.kind==="hidden"?null:a.kind==="loading"?(0,e.jsx)("span",{className:"team-bind-loading",children:n(a.key)}):a.kind==="ok"?(0,e.jsx)("span",{className:"ok",children:n("team.bound2",{name:a.name})}):a.kind==="choice"?(0,e.jsxs)(e.Fragment,{children:[n("team.multiCandidate"),(0,e.jsx)("br",{}),a.candidates.map(o=>(0,e.jsx)("button",{type:"button",className:"tf-pickowner ghost","data-union":o.unionId,style:{margin:"2px"},onClick:()=>t.onPick(o.unionId),children:o.name||o.unionId},o.unionId))]}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)("span",{className:"err",children:n("team.bindFail",{error:a.error})})}function Oe(t){let{tr:a}=t;return t.teams.length?(0,e.jsx)(e.Fragment,{children:t.teams.map(n=>{let o=n.bots.filter(p=>F(p,t.filters)),m=!t.expandedTeams.has(n.key),r=n.kind==="remote"?n.ok?(0,e.jsx)("span",{className:"team-status-pill ok",children:a("team.connected")}):(0,e.jsx)("span",{className:"team-status-pill err",children:a("team.connectFail",{error:n.error||""})}):(0,e.jsx)("span",{className:"team-status-pill muted",children:a("team.iHost")});return(0,e.jsxs)("article",{className:"card team-list-card",children:[(0,e.jsxs)("button",{type:"button",className:"tf-team-h","data-tk":n.key,"aria-expanded":!m,onClick:()=>t.onToggleTeam(n.key),children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:m?"\u203A":"\u2304"}),(0,e.jsx)("b",{children:n.label}),n.sub?(0,e.jsx)("span",{className:"muted",children:n.sub}):null,r,(0,e.jsx)("span",{className:"team-meta-pill",children:a("team.teamMeta",{deps:n.deployments.length,bots:n.bots.length})})]}),m?null:n.kind==="remote"&&!n.ok?(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:a("team.rosterFail")}):(0,e.jsx)(Ue,{...t,team:n,filtered:o})]},n.key)})}):(0,e.jsx)("p",{className:"muted",children:a("team.noTeams")})}function Ue(t){let{team:a,tr:n}=t,o=[...a.deployments].sort((r,p)=>r.local===p.local?0:r.local?-1:1),m=o.some(r=>t.filtered.some(p=>p.deployment.id===r.id));return(0,e.jsxs)(e.Fragment,{children:[o.map(r=>(0,we.createElement)(je,{...t,deployment:r,key:r.id})),m?null:(0,e.jsx)("p",{className:"muted",style:{margin:"8px 0 0"},children:n("team.noMatch")}),(0,e.jsxs)("div",{className:"team-pull-row",children:[(0,e.jsxs)("label",{className:"team-pill-field team-group-name-field",children:[(0,e.jsx)("span",{children:n("team.gnameLabel")}),(0,e.jsx)("input",{className:"tf-gname","data-tk":a.key,value:t.gnameByTeam.get(a.key)||"",placeholder:n("team.gnamePlaceholder"),onChange:r=>t.onGroupNameChange(a.key,r.target.value)})]}),(0,e.jsx)("button",{className:"tf-grp page-primary-action","data-tk":a.key,onClick:()=>t.onPullGroup(a),children:n("team.pullGroupBtn")}),(0,e.jsx)("span",{className:"muted team-pull-hint",children:n("team.pullGroupHint")}),(0,e.jsx)("span",{className:"tf-gout","data-tk":a.key,children:(0,e.jsx)(Ge,{output:t.groupOutputs.get(a.key),tr:n})})]})]})}function je(t){let{team:a,deployment:n,tr:o}=t,m=t.filtered.filter(u=>u.deployment.id===n.id);if(!m.length)return null;let r=n.id===t.myDeploymentId,p=r?o("team.tagLocal"):n.stale?o("team.tagRemoteStale"):o("team.tagRemote"),v=`${a.key}::${n.id}`,N=t.expandedDeps.has(v),T=m.filter(u=>Q(t.pickedByTeam,a.key).has(u.larkAppId)).length;return(0,e.jsxs)("section",{className:"team-deployment-block",children:[(0,e.jsxs)("div",{className:"tf-dep-h","data-dk":v,"aria-expanded":N,role:"button",tabIndex:0,onClick:()=>t.onToggleDep(v),onKeyDown:u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),t.onToggleDep(v))},children:[(0,e.jsx)("span",{className:"team-chevron","aria-hidden":"true",children:N?"\u2304":"\u203A"}),(0,e.jsx)("b",{children:n.name}),(0,e.jsxs)("span",{className:"muted",children:[o("team.depTag",{tag:p})," \xB7 ",o("team.depCount",{count:m.length}),T?o("team.depSelected",{n:T}):""]}),a.kind==="local"&&!r?(0,e.jsx)("button",{type:"button",className:"tf-rmmember ghost","data-team":a.teamId,"data-dep":n.id,"data-name":n.name,onClick:u=>{u.stopPropagation(),t.onRemoveMember(a.teamId,n.id,n.name)},children:o("team.removeMember")}):null]}),N?(0,e.jsx)("div",{className:"team-roster-list",children:m.map(u=>(0,e.jsx)(Ee,{bot:u,mine:r,picked:Q(t.pickedByTeam,a.key).has(u.larkAppId),teamKey:a.key,tr:o,onPick:t.onPick,onCapabilityChange:t.onCapabilityChange,onOpenRole:t.onOpenRole},u.larkAppId))}):null]})}function Ee(t){let{bot:a,tr:n}=t,o=a.deployment.stale?{opacity:.55}:void 0,m=()=>t.onPick(t.teamKey,a.larkAppId,!t.picked);return(0,e.jsxs)("article",{className:`team-bot-row${t.picked?" selected":""}`,style:o,role:"checkbox","aria-checked":t.picked,tabIndex:0,onClick:r=>{Re(r.target)||m()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||Re(r.target)||(r.preventDefault(),m())},children:[(0,e.jsxs)("label",{className:`team-check-pill${t.picked?" selected":""}`,onClick:r=>r.stopPropagation(),children:[(0,e.jsx)("input",{type:"checkbox",className:"tf-pick","data-tk":t.teamKey,"data-app":a.larkAppId,checked:t.picked,onChange:r=>t.onPick(t.teamKey,a.larkAppId,r.target.checked)}),(0,e.jsx)("span",{className:"team-check-dot","aria-hidden":"true"})]}),(0,e.jsxs)("div",{className:"team-bot-main",children:[(0,e.jsx)("strong",{children:a.name}),(0,e.jsx)("span",{children:a.larkAppId})]}),(0,e.jsx)("span",{className:"team-meta-pill",children:a.cliId}),(0,e.jsx)("div",{className:"team-capability-cell",children:t.mine?(0,e.jsxs)("label",{className:"team-pill-field team-cap-field",children:[(0,e.jsx)("span",{children:n("team.capLabel")}),(0,e.jsx)("input",{className:"tf-cap","data-app":a.larkAppId,defaultValue:a.capability||"",placeholder:n("team.capPh"),onBlur:r=>{let p=r.target.value;p!==(a.capability||"")&&t.onCapabilityChange(a.larkAppId,p)},onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),r.currentTarget.blur())}})]}):a.capability||null}),(0,e.jsx)("div",{className:"team-role-cell",children:a.hasTeamRole?t.mine?(0,e.jsx)("button",{className:"tf-role","data-app":a.larkAppId,"data-name":a.name,onClick:()=>t.onOpenRole(a.larkAppId,a.name),children:n("team.viewRole")}):n("team.hasRoleShort"):(0,e.jsx)("span",{className:"muted",children:"\u2014"})})]})}function Re(t){return t instanceof HTMLElement?!!t.closest('button, input, textarea, select, a, label, [contenteditable="true"]'):!1}function Ge(t){let{output:a,tr:n}=t;return a?a.kind==="muted"?(0,e.jsx)("span",{className:"muted",children:n(a.key)}):a.kind==="err"?(0,e.jsx)("span",{className:"err",children:n(a.key)}):(0,e.jsx)(Fe,{body:a.body,status:a.status,tr:n}):null}function Fe(t){let{body:a,status:n,tr:o}=t;if(a?.ok&&a.chatId){let p=a.shareLink||"https://applink.feishu.cn/client/chat/open?openChatId="+encodeURIComponent(a.chatId);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"ok",children:o("team.groupCreated")}),a.delegatedTo?o("team.delegatedBy",{name:String(a.delegatedTo)}):""," \xB7 ",(0,e.jsx)("a",{href:p,target:"_blank",rel:"noreferrer",children:o("team.openInLark")}),(a.invalidBotIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidBots",{ids:(a.invalidBotIds||[]).join(", ")})]}):null,(a.invalidOwnerUnionIds||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.invalidOwners",{n:(a.invalidOwnerUnionIds||[]).length})]}):null,a.missingOperatorIdentity?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.missingIdentity")]}):null,(a.skippedNoOwner||[]).length?(0,e.jsxs)("span",{className:"err",children:[" \xB7 ",o("team.skippedNoOwner",{n:(a.skippedNoOwner||[]).length})]}):null]})}let m=a?.error||n,r=m==="no_local_online_bot"?o("team.errNoLocalBot"):m==="all_bots_skipped_no_owner"?o("team.errAllSkipped"):m==="no_creator_available"?o("team.errNoCreator"):m==="delegation_timeout"?o("team.errDelegationTimeout"):o("team.errGroupCreate",{error:String(m)});return(0,e.jsx)("span",{className:"err",children:r})}function _e(t){let{state:a,tr:n}=t;return(0,e.jsx)("div",{id:"tf-modal",className:"team-role-modal","data-app":a?.app,hidden:!a,children:(0,e.jsxs)("div",{className:"team-role-dialog",children:[(0,e.jsx)("h2",{id:"tf-modal-title",children:a?n("team.roleModalTitleName",{name:a.name}):n("team.roleModalTitle")}),(0,e.jsx)("p",{className:"muted",style:{fontSize:"13px"},children:n("team.roleModalHint")}),(0,e.jsx)("textarea",{id:"tf-modal-text",readOnly:!0,value:a?.content??""}),(0,e.jsx)("div",{className:"team-role-actions",children:(0,e.jsx)("button",{type:"button",id:"tf-modal-cancel",onClick:t.onClose,children:n("team.close")})})]})})}function $e(){let t=E(),a=Ie(),[n,o]=(0,d.useState)([]),[m,r]=(0,d.useState)(""),[p,v]=(0,d.useState)(""),[N,T]=(0,d.useState)({kind:"none"}),[u,R]=(0,d.useState)(()=>new Map),[P,M]=(0,d.useState)(""),[D,x]=(0,d.useState)(""),[O,I]=(0,d.useState)({kind:"none"}),B=(0,d.useCallback)(async()=>{let c=await V();if(!a.current)return;let g=c.body;r(h=>g?.suggestedHubUrl||h),o(g?.teams||[])},[a]);(0,d.useEffect)(()=>{B()},[B]);async function A(){let c=p.trim();if(!c){T({kind:"err",key:"team.errName"});return}T({kind:"muted",key:"team.creating"});let g=await ye(c);a.current&&(g.body?.ok?(T({kind:"ok",key:"team.created"}),v(""),B()):T({kind:"create-fail",error:String(g.body?.error||g.status)}))}async function U(c){R(h=>{let y=new Map(h);return y.set(c,{kind:"muted",key:"team.generating"}),y});let g=await be(c);a.current&&R(h=>{let y=new Map(h);return y.set(c,g.body?.code?{kind:"invite",code:g.body.code}:{kind:"err",key:"team.genFail"}),y})}async function C(c,g){confirm(t("team.delConfirm",{name:g}))&&(await fe(c),a.current&&B())}async function j(){let c=P.trim(),g=D.trim();if(I({kind:"muted",key:"team.joining"}),!c||!g){I({kind:"err",key:"team.errHubCode"});return}let h=await ke(c,g);a.current&&(h.body?.ok?(I({kind:"joined",name:String(h.body.teamName||"")}),x("")):I({kind:"join-fail",error:h.body?.error||h.status}))}return(0,e.jsxs)("section",{className:"page team-page team-manage-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("team.eyebrow")}),(0,e.jsx)("h1",{children:t("team.manageTitle")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(Ce,{active:"manage"})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.hostedTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar",onSubmit:c=>{c.preventDefault(),A()},children:[(0,e.jsx)("input",{id:"tm-newname",type:"text",placeholder:t("team.newTeamPh"),value:p,onChange:c=>v(c.target.value)}),(0,e.jsx)(ie,{id:"tm-create",className:"page-primary-action",onClick:()=>{A()},children:t("team.createTeamBtn")}),(0,e.jsx)("span",{className:"toolbar-status tm-cout",children:(0,e.jsx)(X,{status:N,tr:t})})]}),(0,e.jsx)("div",{id:"tm-list",children:(0,e.jsx)(ze,{teams:n,suggestedHubUrl:m,inviteStatuses:u,tr:t,onInvite:c=>{U(c)},onDelete:(c,g)=>{C(c,g)}})})]}),(0,e.jsxs)("div",{className:"card team-card",children:[(0,e.jsx)("div",{className:"team-card-head",children:(0,e.jsx)("h2",{children:t("team.joinTitle")})}),(0,e.jsxs)("form",{className:"team-inline-form dashboard-toolbar team-join-form",onSubmit:c=>{c.preventDefault(),j()},children:[(0,e.jsx)("input",{id:"tm-hub",type:"text",placeholder:t("team.hubPh"),value:P,onChange:c=>M(c.target.value)}),(0,e.jsx)("input",{id:"tm-code",type:"text",placeholder:t("team.codePh"),value:D,onChange:c=>x(c.target.value)}),(0,e.jsx)("button",{type:"button",id:"tm-join",className:"page-primary-action",onClick:()=>{j()},children:t("team.joinBtn")})]}),(0,e.jsx)("div",{id:"tm-join-out",className:"team-inline-output",hidden:O.kind==="none",children:(0,e.jsx)(X,{status:O,tr:t})})]})]})}function ze(t){let{teams:a,tr:n}=t;return a.length?(0,e.jsx)(e.Fragment,{children:a.map(o=>{let m=(o.deployments||[]).filter(p=>!p.local).length,r=t.inviteStatuses.get(o.teamId)??{kind:"none"};return(0,e.jsxs)("div",{className:"card team-list-card team-manage-card",children:[(0,e.jsxs)("div",{className:"team-manage-head",children:[(0,e.jsx)("b",{children:o.name}),o.isDefault?(0,e.jsx)("span",{className:"team-status-pill muted",children:n("team.default")}):null,(0,e.jsxs)("span",{className:"team-meta-pill",children:[n("team.manageMetaDeps",{count:(o.deployments||[]).length}),m?n("team.manageMetaRemote",{r:m}):""," \xB7 ",n("team.manageMetaBots",{count:(o.bots||[]).length})]}),(0,e.jsxs)("span",{className:"team-manage-actions",children:[(0,e.jsx)("button",{className:"tm-invite ghost","data-team":o.teamId,onClick:()=>t.onInvite(o.teamId),children:n("team.genInvite")}),o.isDefault?null:(0,e.jsx)("button",{className:"tm-del ghost","data-team":o.teamId,"data-name":o.name,onClick:()=>t.onDelete(o.teamId,o.name),children:n("team.delBtn")})]})]}),(0,e.jsx)("div",{className:"tm-inv-out team-inline-output","data-team":o.teamId,hidden:r.kind==="none",children:(0,e.jsx)(X,{status:r,tr:n,suggestedHubUrl:t.suggestedHubUrl})})]},o.teamId)})}):(0,e.jsx)("p",{className:"muted",children:n("team.noTeamsShort")})}function X(t){let{status:a,tr:n}=t;if(a.kind==="none")return null;if(a.kind==="muted")return(0,e.jsx)("span",{className:"muted",children:n(a.key)});if(a.kind==="ok")return(0,e.jsx)("span",{className:"ok",children:n(a.key)});if(a.kind==="err")return(0,e.jsx)("span",{className:"err",children:n(a.key)});if(a.kind==="create-fail")return(0,e.jsx)("span",{className:"err",children:n("team.createFail",{error:a.error})});if(a.kind==="invite")return(0,e.jsxs)(e.Fragment,{children:[n("team.inviteResultLede"),(0,e.jsx)("br",{}),n("team.inviteHub"),(0,e.jsx)("code",{children:t.suggestedHubUrl||""}),(0,e.jsx)("br",{}),n("team.inviteCode"),(0,e.jsx)("code",{className:"team-invite-code",children:a.code})]});if(a.kind==="joined")return(0,e.jsx)("span",{className:"ok",children:n("team.joined",{name:a.name})});let o=a.error,m=o==="cannot_join_self"?n("team.joinErrSelf"):o==="deployment_already_joined"?n("team.joinErrAlready"):o==="hub_unreachable"?n("team.joinErrUnreachable"):o==="hub_timeout"?n("team.joinErrTimeout"):n("team.joinErrGeneric",{error:String(o)});return(0,e.jsx)("span",{className:"err",children:m})}function Xe(t){return K(t,(0,e.jsx)(He,{}))}function Ye(t){return K(t,(0,e.jsx)($e,{}))}export{Xe as renderTeamFederationPage,Ye as renderTeamManagePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as $}from"./chunk-
|
|
1
|
+
import{b as $}from"./chunk-3PMN55Z6.js";import{d as E}from"./chunk-I35DXGM4.js";import{r as F}from"./chunk-RXVA6XW3.js";import{a as O}from"./chunk-SYC6D5XU.js";import{a as re,d as V}from"./chunk-5THX4DI2.js";import{c as S}from"./chunk-7SZRL6FY.js";var l=S(re(),1);async function _(t=fetch){let e=await t("/api/v3/runs");if(!e.ok)return[];let o=await e.json();return Array.isArray(o.runs)?o.runs:[]}async function j(t,e=fetch){let o=await e(`/api/v3/runs/${encodeURIComponent(t)}`);return o.ok?{ok:!0,view:await o.json()}:{ok:!1,status:o.status}}async function J(t,e=fetch){let o=await e(`/api/v3/runs/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})}),s={};try{let a=await o.json();a&&typeof a=="object"&&!Array.isArray(a)&&(s=a)}catch{}if(!o.ok||s.ok===!1)return{ok:!1,status:o.status,error:typeof s.error=="string"?s.error:`http_${o.status}`};let r=s.status;return{ok:!0,...typeof s.runId=="string"?{runId:s.runId}:{},...ae(r)?{runStatus:r}:{},...s.alreadyTerminal===!0?{alreadyTerminal:!0}:{}}}function ae(t){return t==="running"||t==="cancelling"||t==="cancelled"||t==="succeeded"||t==="failed"||t==="blocked"}var I={pending:"\u5F85\u673A",gateWaiting:"\u7B49\u5BA1\u6279",running:"\u8FD0\u884C\u4E2D",done:"\u5B8C\u6210",skipped:"\u5DF2\u8DF3\u8FC7",cancelled:"\u5DF2\u53D6\u6D88",blocked:"\u53D7\u963B",superseded:"\u5DF2\u5237\u65B0",failed:"\u5931\u8D25"},X={exit:"\u2713 \u901A\u8FC7",continue:"\u21BB \u7EE7\u7EED\u8FD4\u5DE5",exhausted:"\u26D4 \u8F6E\u6570\u8017\u5C3D"},p={nodeWidth:168,plainHeight:48,loopHeight:70,columnGap:226,verticalGap:30,padding:26,maxDots:8},x={width:104,height:30,columnGap:138,rowGap:42,padding:6};function k(t){return t==="succeeded"||t==="failed"||t==="cancelled"}function W(t=typeof location<"u"?location.hash:""){let e=t.match(/^#\/workflows\/([^?#]+)/);if(!e)return null;try{return decodeURIComponent(e[1])}catch{return e[1]}}function L(t,e){return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function D(t){return t.isLoop?p.loopHeight:p.plainHeight}function C(t){return t.nodes.filter(e=>!e.loop)}function z(t){let e=C(t),o=ie(e),s=new Map;for(let i of e){let m=o.get(i.id)??0,u=s.get(m);u?u.push(i):s.set(m,[i])}let r=[...s.keys()].sort((i,m)=>i-m),a=[],d=new Map,c=0;for(let i of r){let m=s.get(i)??[],u=p.padding;for(let g of m){let v={node:g,x:p.padding+i*p.columnGap,y:u,width:p.nodeWidth,height:D(g)};a.push(v),d.set(g.id,v),u+=v.height+p.verticalGap}c=Math.max(c,u-p.verticalGap+p.padding)}let f=p.padding*2+(r.length===0?0:Math.max(...r)*p.columnGap+p.nodeWidth),w=new Map(e.map(i=>[i.id,i])),y=[];for(let i of e){let m=d.get(i.id);if(m)for(let u of i.depends){let g=d.get(u),v=w.get(u);if(!g||!v)continue;let N=g.x+p.nodeWidth,R=g.y+D(v)/2,b=m.x,M=m.y+D(i)/2;y.push({fromId:u,toId:i.id,x1:N,y1:R,x2:b,y2:M,mx:(N+b)/2,live:i.status==="running"})}}return{width:f,height:c,nodes:a,edges:y}}function ie(t){let e=new Map(t.map(a=>[a.id,a])),o=new Map,s=new Set;function r(a){if(o.has(a))return o.get(a);if(s.has(a))return 0;s.add(a);let c=(e.get(a)?.depends??[]).filter(w=>e.has(w)),f=c.length?1+Math.max(...c.map(r)):0;return s.delete(a),o.set(a,f),f}for(let a of t)r(a.id);return o}function U(t,e){return(t?.nodes??[]).filter(o=>o.loop?.loopId===e)}function q(t,e,o){if(o&&e){let r=t.find(a=>a.id===e);if(r)return r}let s=t.filter(r=>r.status==="running");return s[s.length-1]??t[t.length-1]??null}function Y(t){let e=new Map;for(let o of t){let s=o.loop?.iteration;if(s===void 0)continue;let r=e.get(s);r?r.push(o):e.set(s,[o])}return[...e.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({iteration:o,instances:s}))}function P(t){let e=t.loopState?.maxIterations;return t.loopState&&e!==void 0?e+t.loopState.granted:void 0}function K(t,e){let o=new Map(t.map(i=>[i.id,i])),s=new Map;function r(i){if(s.has(i))return s.get(i);s.set(i,0);let m=(o.get(i)?.depends??[]).filter(g=>o.has(g)),u=m.length?1+Math.max(...m.map(r)):0;return s.set(i,u),u}let a=new Map,d=0,c=[],f=new Map;for(let i of t){let m=r(i.id),u=a.get(m)??0;a.set(m,u+1),d=Math.max(d,u);let g={templateId:i.id,node:e.get(i.id),x:x.padding+m*x.columnGap,y:x.padding+u*x.rowGap,width:x.width,height:x.height};c.push(g),f.set(i.id,g)}let w=s.size?Math.max(...s.values()):0,y=[];for(let i of t){let m=f.get(i.id);if(m)for(let u of i.depends){let g=f.get(u);if(!g)continue;let v=g.x+x.width,N=g.y+x.height/2,R=m.x,b=m.y+x.height/2;y.push({fromId:u,toId:i.id,x1:v,y1:N,x2:R,y2:b,mx:(v+R)/2,live:e.get(i.id)?.status==="running"})}}return{width:x.padding*2+(t.length?w*x.columnGap+x.width:0),height:x.padding*2+d*x.rowGap+x.height,nodes:c,edges:y}}function H(t){let e=t.webTerminal;return`${e?.status??"-"}|${e?.sessionId??"-"}|${e?.webPort??"-"}|${t.hasPtyLog?"1":"0"}`}function Q(t,e,o){t.setAttribute("data-run-id",e),t.setAttribute("data-node-id",o.id),t.innerHTML=le(e,o).html}function le(t,e,o={}){let s=H(e),r=e.webTerminal;if(r?.status==="live"&&r.webPort&&r.webPort>0)return{kind:"live",signature:s,html:de(r.webPort,r.sessionId,o.host)};if(e.hasPtyLog)return{kind:"replay",signature:s,html:ue(t,e.id,r?.status==="closed")};let a=r?.status==="live"?"\u7EC8\u7AEF\u6B63\u5728\u542F\u52A8\uFF0C\u7A0D\u540E\u5237\u65B0":"\u6682\u65E0\u7EC8\u7AEF\u8BB0\u5F55";return{kind:"empty",signature:s,html:ce(a)}}function de(t,e,o){let s=me(t,o,e);return`<div class="v3-terminal-panel">
|
|
2
2
|
<div class="v3-terminal-head">
|
|
3
3
|
<span class="v3-terminal-dot live"></span>
|
|
4
4
|
<span>\u5B9E\u65F6\u7EC8\u7AEF\uFF08\u53EA\u8BFB\uFF09</span>
|
package/dist/dashboard-web/chunks/{whiteboards-page-6SG33GP4.js → whiteboards-page-WAR77DQE.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as B}from"./chunk-
|
|
1
|
+
import{b as B}from"./chunk-3PMN55Z6.js";import{c as W,j as C}from"./chunk-I35DXGM4.js";import"./chunk-RXVA6XW3.js";import{a as P}from"./chunk-SYC6D5XU.js";import{a as O,d as T}from"./chunk-5THX4DI2.js";import{c as R}from"./chunk-7SZRL6FY.js";var r=R(O(),1);var e=R(T(),1);function x(t){let a=Date.parse(t);if(!a)return t||"-";let o=Math.max(0,Math.floor((Date.now()-a)/1e3));if(o<60)return`${o}s ago`;let i=Math.floor(o/60);if(i<60)return`${i}m ago`;let n=Math.floor(i/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function F(t){return t.chatId?.trim()||"__local__"}function G(t,a){if(t==="__local__")return"\u672A\u7ED1\u5B9A\u7FA4 / \u672C\u5730\u767D\u677F";let o=a.get(t);return o&&o!==t?`${o} (${t})`:t}function K(t,a){let o=new Map;for(let i of t){let n=F(i),c=o.get(n)??[];c.push(i),o.set(n,c)}return[...o.entries()].map(([i,n])=>({chatId:i,label:G(i,a),rows:[...n].sort((c,b)=>b.updatedAt.localeCompare(c.updatedAt))})).sort((i,n)=>i.label.localeCompare(n.label))}function z(){return decodeURIComponent((location.hash.match(/^#\/whiteboards\/([^/]+)/)?.[1]??"").trim())}async function E(t,a){let o=await fetch(`/api/whiteboards/${encodeURIComponent(t)}`),i=await o.json().catch(()=>({}));if(o.ok)return{id:t,content:String(i.content??""),row:a.find(n=>n.id===t)}}async function J(t){let a=new Map;if(!t?.ok)return a;let o=await t.json().catch(()=>({})),i=Array.isArray(o.chats)?o.chats:[];for(let n of i)n.chatId&&a.set(String(n.chatId),String(n.name||n.chatId));return a}function Q(t){let a=t.row,o=a.title||a.id;return(0,e.jsxs)("a",{className:`wb-item${t.active?" active":""}`,"data-whiteboard-id":a.id,href:`#/whiteboards/${encodeURIComponent(a.id)}`,onClick:i=>{i.preventDefault(),t.onSelect(a.id)},children:[(0,e.jsx)("div",{className:"wb-item-head",children:(0,e.jsxs)("div",{className:"wb-item-main",children:[(0,e.jsx)("strong",{children:(0,e.jsx)(C,{text:o,textClassName:"wb-title-scroll"})}),(0,e.jsx)("span",{className:"wb-id-text",title:a.id,children:a.id})]})}),(0,e.jsxs)("div",{className:"wb-item-foot",children:[(0,e.jsxs)("div",{className:"wb-item-meta",children:[(0,e.jsx)("span",{children:x(a.updatedAt)}),(0,e.jsx)("span",{children:"\xB7"}),(0,e.jsxs)("span",{children:["log ",a.logCount]})]}),(0,e.jsx)("span",{className:"wb-scope",title:a.scope,children:a.scope})]})]})}function p(t){let a=t.value||"-";return(0,e.jsxs)("div",{className:"wb-meta-card",title:a,children:[(0,e.jsx)("span",{children:t.label}),(0,e.jsx)("strong",{children:a})]})}function V(t){let a=t.selected;if(!a)return(0,e.jsx)("p",{className:"empty",children:"\u9009\u62E9\u5DE6\u4FA7\u767D\u677F\u67E5\u770B meta \u548C board.md\u3002"});let o=a.row,i=o?.chatId?G(o.chatId,t.groupNames):"\u672A\u7ED1\u5B9A\u7FA4 / \u672C\u5730\u767D\u677F",n=o?.title||a.id;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"wb-detail-head",children:[(0,e.jsxs)("div",{className:"wb-detail-title",children:[(0,e.jsx)("p",{className:"eyebrow",children:"WHITEBOARD"}),(0,e.jsx)("h2",{title:n,children:n}),(0,e.jsx)("code",{title:a.id,children:a.id})]}),(0,e.jsx)("button",{type:"button",className:"danger","data-delete-whiteboard":!0,onClick:t.onDelete,children:"\u5220\u9664\u767D\u677F"})]}),(0,e.jsxs)("div",{className:"wb-meta-grid",children:[(0,e.jsx)(p,{label:"\u6240\u5C5E\u7FA4",value:i}),(0,e.jsx)(p,{label:"\u8303\u56F4",value:o?.scope??"-"}),(0,e.jsx)(p,{label:"\u6700\u8FD1\u66F4\u65B0",value:o?.updatedAt?x(o.updatedAt):"-"}),(0,e.jsx)(p,{label:"\u6765\u6E90\u76EE\u5F55",value:o?.workingDir??"-"})]}),(0,e.jsxs)("details",{className:"wb-admin-info",children:[(0,e.jsx)("summary",{children:"\u7BA1\u7406\u4FE1\u606F / \u6587\u4EF6\u8DEF\u5F84"}),(0,e.jsx)("code",{children:o?.path??""})]}),(0,e.jsxs)("section",{className:"wb-board-panel",children:[(0,e.jsxs)("div",{className:"wb-board-panel-head",children:[(0,e.jsx)("strong",{children:"board.md"}),(0,e.jsx)("span",{children:"\u53EA\u8BFB\u9884\u89C8"})]}),(0,e.jsx)("pre",{children:a.content||"\uFF08\u6682\u65E0\u5185\u5BB9\uFF09"})]})]})}function X(t){let a=t.selected.row?.title||t.selected.id;return(0,e.jsx)("div",{className:"wb-delete-backdrop","data-delete-modal":!0,onClick:o=>{o.target===o.currentTarget&&t.onCancel()},children:(0,e.jsxs)("div",{className:"wb-delete-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"wb-delete-title",children:[(0,e.jsxs)("div",{className:"wb-delete-body",children:[(0,e.jsx)("div",{className:"wb-delete-mark","aria-hidden":"true",children:"!"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{id:"wb-delete-title",children:"\u5220\u9664\u767D\u677F\uFF1F"}),(0,e.jsxs)("p",{children:["\u5C06\u5220\u9664 ",(0,e.jsx)("strong",{children:a}),"\uFF08",(0,e.jsx)("code",{children:t.selected.id}),"\uFF09\u7684 board\u3001log\u3001meta\uFF0C\u5E76\u6E05\u7406\u9ED8\u8BA4\u7ED1\u5B9A\u548C\u4F1A\u8BDD\u5F15\u7528\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002"]})]})]}),(0,e.jsxs)("div",{className:"actions wb-delete-actions",children:[(0,e.jsx)("button",{type:"button","data-delete-cancel":!0,onClick:t.onCancel,disabled:t.deleting,children:"\u53D6\u6D88"}),(0,e.jsx)("button",{type:"button",className:"danger","data-delete-confirm":!0,onClick:t.onConfirm,disabled:t.deleting,children:t.deleting?"\u5220\u9664\u4E2D...":"\u786E\u8BA4\u5220\u9664"})]})]})})}function Y(){let t=B(),a=(0,r.useRef)(!1),o=(0,r.useRef)(0),[i,n]=(0,r.useState)(!1),[c,b]=(0,r.useState)([]),[g,_]=(0,r.useState)(()=>new Map),[m,f]=(0,r.useState)(),[H,S]=(0,r.useState)(!0),[k,M]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[L,D]=(0,r.useState)(!1),I=(0,r.useMemo)(()=>K(c,g),[c,g]);(0,r.useEffect)(()=>{a.current=!0;let s=z();async function d(){S(!0);try{let[l,y]=await Promise.all([fetch("/api/whiteboards"),fetch("/api/groups").catch(()=>null)]),w=await l.json().catch(()=>({}));if(!l.ok)throw new Error(w?.error??`HTTP ${l.status}`);let q=await J(y),$=Array.isArray(w.whiteboards)?w.whiteboards:[],A;if(s&&(A=await E(s,$)),!a.current)return;n(w.enabled===!0),b($),_(q),f(A),M(null)}catch(l){a.current&&M(l instanceof Error?l.message:String(l))}finally{a.current&&S(!1)}}return d(),()=>{a.current=!1,o.current+=1}},[]);async function U(s){let d=o.current+1;o.current=d;let l=await E(s,c);!a.current||o.current!==d||!l||(f(l),window.history.replaceState(null,"",`#/whiteboards/${encodeURIComponent(s)}`))}async function j(){if(u){D(!0);try{let s=await fetch(`/api/whiteboards/${encodeURIComponent(u.id)}`,{method:"DELETE"}),d=await s.json().catch(()=>({}));if(!s.ok||d.ok===!1)throw new Error(d?.error??`HTTP ${s.status}`);if(!a.current)return;b(l=>l.filter(y=>y.id!==u.id)),m?.id===u.id&&(f(void 0),window.history.replaceState(null,"","#/whiteboards")),h(null)}catch(s){a.current&&window.alert(`\u5220\u9664\u5931\u8D25\uFF1A${s instanceof Error?s.message:String(s)}`)}finally{a.current&&D(!1)}}}let v="\u767D\u677F\u80FD\u529B\u5F53\u524D\u5173\u95ED\uFF1A\u4E0D\u4F1A\u81EA\u52A8\u521B\u5EFA/\u7ED1\u5B9A\u767D\u677F\uFF0C\u4E5F\u4E0D\u4F1A\u6CE8\u5165\u5230 agent prompt\u3002\u5386\u53F2\u767D\u677F\u4EC5\u5728 dashboard \u4E2D\u53EA\u8BFB\u53EF\u89C1\uFF0C\u53EF\u5728\u6B64\u6E05\u7406\u3002",N=(s=!1)=>(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("nav.whiteboards")}),(0,e.jsx)("h1",{children:t("nav.whiteboards")}),s?(0,e.jsx)("span",{className:"wb-disabled-pill",title:v,"aria-label":v,children:v}):null]})});return k?(0,e.jsxs)("section",{className:"page whiteboards-page",children:[N(),(0,e.jsxs)("p",{className:"hint-warn",children:["\u52A0\u8F7D\u767D\u677F\u5931\u8D25\uFF1A",k]})]}):H?(0,e.jsxs)("section",{className:"page whiteboards-page","data-whiteboards-host":!0,children:[N(),(0,e.jsx)(W,{label:t("common.loading")})]}):(0,e.jsxs)("section",{className:"page whiteboards-page",children:[N(!i),(0,e.jsxs)("div",{className:"wb-split",children:[(0,e.jsx)("section",{className:"overview-block wb-list-block",children:(0,e.jsx)("div",{className:"wb-list-panel",children:I.length===0?(0,e.jsx)("p",{className:"empty wb-empty",children:"\u6682\u65E0\u767D\u677F\u3002\u6253\u5F00\u80FD\u529B\u540E\uFF0C\u6BCF\u4E2A\u7FA4\u9996\u6B21\u9700\u8981\u767D\u677F\u65F6\u624D\u4F1A\u521B\u5EFA\u9ED8\u8BA4\u767D\u677F\u3002"}):I.map(s=>(0,e.jsxs)("details",{className:"wb-group",open:!0,children:[(0,e.jsxs)("summary",{children:[(0,e.jsx)("span",{className:"wb-group-title",children:(0,e.jsx)(C,{text:s.label,textClassName:"wb-group-title-scroll"})}),(0,e.jsx)("small",{children:s.rows.length})]}),(0,e.jsx)("div",{className:"wb-group-items",children:s.rows.map(d=>(0,e.jsx)(Q,{row:d,active:m?.id===d.id,onSelect:l=>{U(l)}},d.id))})]},s.chatId))})}),(0,e.jsx)("section",{className:"overview-block wb-detail-block",children:(0,e.jsx)("div",{className:"wb-detail-panel",id:"whiteboard-detail",children:(0,e.jsx)(V,{selected:m,groupNames:g,onDelete:()=>{m&&h(m)}})})})]}),u?(0,e.jsx)(X,{selected:u,deleting:L,onCancel:()=>h(null),onConfirm:()=>{j()}}):null]})}function ae(t){return P(t,(0,e.jsx)(Y,{}))}export{ae as renderWhiteboardsPage};
|