botmux 3.18.6 → 3.18.7
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/.runtime-build-id +1 -1
- package/dist/adapters/backend/riff-backend.d.ts +158 -0
- package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
- package/dist/adapters/backend/riff-backend.js +330 -7
- package/dist/adapters/backend/riff-backend.js.map +1 -1
- package/dist/adapters/backend/sandbox.d.ts +42 -0
- package/dist/adapters/backend/sandbox.d.ts.map +1 -1
- package/dist/adapters/backend/sandbox.js +95 -5
- package/dist/adapters/backend/sandbox.js.map +1 -1
- package/dist/adapters/cli/codex-app.d.ts.map +1 -1
- package/dist/adapters/cli/codex-app.js +2 -1
- package/dist/adapters/cli/codex-app.js.map +1 -1
- package/dist/adapters/cli/dsh.d.ts.map +1 -1
- package/dist/adapters/cli/dsh.js +2 -1
- package/dist/adapters/cli/dsh.js.map +1 -1
- package/dist/adapters/cli/mir.d.ts.map +1 -1
- package/dist/adapters/cli/mir.js +2 -1
- package/dist/adapters/cli/mir.js.map +1 -1
- package/dist/adapters/cli/mira.d.ts.map +1 -1
- package/dist/adapters/cli/mira.js +2 -1
- package/dist/adapters/cli/mira.js.map +1 -1
- package/dist/adapters/hook-command.d.ts +3 -5
- package/dist/adapters/hook-command.d.ts.map +1 -1
- package/dist/adapters/hook-command.js +59 -13
- package/dist/adapters/hook-command.js.map +1 -1
- package/dist/autostart.d.ts +76 -0
- package/dist/autostart.d.ts.map +1 -1
- package/dist/autostart.js +105 -28
- package/dist/autostart.js.map +1 -1
- package/dist/bot-registry.d.ts +12 -0
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +43 -3
- package/dist/bot-registry.js.map +1 -1
- package/dist/cli/dashboard-command.d.ts +142 -0
- package/dist/cli/dashboard-command.d.ts.map +1 -1
- package/dist/cli/dashboard-command.js +160 -0
- package/dist/cli/dashboard-command.js.map +1 -1
- package/dist/cli/dashboard-endpoint.d.ts +66 -0
- package/dist/cli/dashboard-endpoint.d.ts.map +1 -1
- package/dist/cli/dashboard-endpoint.js +144 -30
- package/dist/cli/dashboard-endpoint.js.map +1 -1
- package/dist/cli/send-dispatch.d.ts +2 -0
- package/dist/cli/send-dispatch.d.ts.map +1 -1
- package/dist/cli/send-dispatch.js +8 -2
- package/dist/cli/send-dispatch.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +270 -38
- package/dist/cli.js.map +1 -1
- package/dist/core/binary-self-update.d.ts +7 -0
- package/dist/core/binary-self-update.d.ts.map +1 -1
- package/dist/core/binary-self-update.js +17 -0
- package/dist/core/binary-self-update.js.map +1 -1
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +52 -1
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/cost-calculator.d.ts +9 -1
- package/dist/core/cost-calculator.d.ts.map +1 -1
- package/dist/core/cost-calculator.js +5 -0
- package/dist/core/cost-calculator.js.map +1 -1
- package/dist/core/passthrough-commands.d.ts.map +1 -1
- package/dist/core/passthrough-commands.js +1 -1
- package/dist/core/passthrough-commands.js.map +1 -1
- package/dist/core/self-spawn.d.ts +46 -1
- package/dist/core/self-spawn.d.ts.map +1 -1
- package/dist/core/self-spawn.js +57 -0
- package/dist/core/self-spawn.js.map +1 -1
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +81 -5
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +93 -0
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/autostart-api.d.ts.map +1 -1
- package/dist/dashboard/autostart-api.js +16 -3
- package/dist/dashboard/autostart-api.js.map +1 -1
- package/dist/dashboard/bot-onboarding.d.ts +2 -1
- package/dist/dashboard/bot-onboarding.d.ts.map +1 -1
- package/dist/dashboard/bot-onboarding.js +22 -6
- package/dist/dashboard/bot-onboarding.js.map +1 -1
- package/dist/dashboard/bot-payload.d.ts +1 -0
- package/dist/dashboard/bot-payload.d.ts.map +1 -1
- package/dist/dashboard/bot-payload.js +3 -0
- package/dist/dashboard/bot-payload.js.map +1 -1
- package/dist/dashboard/connector-api.d.ts.map +1 -1
- package/dist/dashboard/connector-api.js +28 -0
- package/dist/dashboard/connector-api.js.map +1 -1
- package/dist/dashboard/trigger-api.d.ts.map +1 -1
- package/dist/dashboard/trigger-api.js +33 -21
- package/dist/dashboard/trigger-api.js.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.js +12 -2
- package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
- package/dist/dashboard/web/bot-defaults.d.ts +2 -0
- package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults.js.map +1 -1
- package/dist/dashboard/web/bot-onboarding.d.ts +40 -1
- package/dist/dashboard/web/bot-onboarding.d.ts.map +1 -1
- package/dist/dashboard/web/bot-onboarding.js +52 -2
- package/dist/dashboard/web/bot-onboarding.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +2 -0
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/webhook-routes.d.ts.map +1 -1
- package/dist/dashboard/webhook-routes.js +272 -30
- package/dist/dashboard/webhook-routes.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/{agent-workbench-dock-page-XHJUYFGN.js → agent-workbench-dock-page-6LC422N6.js} +1 -1
- package/dist/dashboard-web/chunks/{agent-workbench-page-FLKTLIRM.js → agent-workbench-page-RSAWY7O2.js} +1 -1
- package/dist/dashboard-web/chunks/{bot-defaults-page-XMGLZZ2E.js → bot-defaults-page-67RAWCSQ.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-TLG45URB.js → chunk-IA5KMD5O.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-BU3Q6XC6.js → chunk-K232GT3M.js} +2 -2
- package/dist/dashboard-web/chunks/chunk-MMLTCXHP.js +10 -0
- package/dist/dashboard-web/chunks/{chunk-ECFC7UG2.js → chunk-R3LJUCEO.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-Z67OSM5P.js → chunk-YJA3KY3J.js} +1 -1
- package/dist/dashboard-web/chunks/{connectors-page-WDM4CEAU.js → connectors-page-DJCTHSFB.js} +1 -1
- package/dist/dashboard-web/chunks/{feedback-page-GMJ4FLJ4.js → feedback-page-O7SZRKNM.js} +1 -1
- package/dist/dashboard-web/chunks/{groups-page-L4ZJNWVR.js → groups-page-7PONUYHE.js} +1 -1
- package/dist/dashboard-web/chunks/{insights-page-7LUJU2CX.js → insights-page-J6DAAJ6D.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-7LZUJQPF.js → monitor-room-F3QNEW7N.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-AUSXMPYO.js → monitoring-page-JHDD2VS2.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-6ZU6MAZN.js → office-page-MMTN4IKD.js} +1 -1
- package/dist/dashboard-web/chunks/{overview-page-QBC5CIYH.js → overview-page-IQ2UJAJP.js} +1 -1
- package/dist/dashboard-web/chunks/{roles-page-QO3YCA7D.js → roles-page-FNI4MGX6.js} +1 -1
- package/dist/dashboard-web/chunks/{schedules-page-YNGSKDQW.js → schedules-page-6PUU63KS.js} +1 -1
- package/dist/dashboard-web/chunks/{sessions-page-BWR4UB6X.js → sessions-page-O4N72EXT.js} +4 -4
- package/dist/dashboard-web/chunks/{settings-page-2IRIS3FP.js → settings-page-G7B3STUF.js} +1 -1
- package/dist/dashboard-web/chunks/{skills-page-5RZPM6HJ.js → skills-page-CEWKQOIG.js} +1 -1
- package/dist/dashboard-web/chunks/{team-federation-page-KERG6LKC.js → team-federation-page-NUP4VK4H.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-766CBD7H.js → v3-page-M4XF6D5Z.js} +1 -1
- package/dist/dashboard-web/chunks/{whiteboards-page-2M6XZD5C.js → whiteboards-page-L755NZX6.js} +1 -1
- package/dist/dashboard-web/style.css +13 -0
- package/dist/dashboard.js +3 -0
- package/dist/dashboard.js.map +1 -1
- package/dist/global-config.d.ts +3 -0
- package/dist/global-config.d.ts.map +1 -1
- package/dist/global-config.js +10 -3
- package/dist/global-config.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +19 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +19 -1
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/api-gate.d.ts +53 -0
- package/dist/im/lark/api-gate.d.ts.map +1 -0
- package/dist/im/lark/api-gate.js +322 -0
- package/dist/im/lark/api-gate.js.map +1 -0
- package/dist/im/lark/audio-transcribe.d.ts +23 -0
- package/dist/im/lark/audio-transcribe.d.ts.map +1 -0
- package/dist/im/lark/audio-transcribe.js +126 -0
- package/dist/im/lark/audio-transcribe.js.map +1 -0
- package/dist/im/lark/card-builder.d.ts +6 -0
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +53 -1
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts +10 -0
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +68 -1
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +247 -224
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
- package/dist/im/lark/event-dispatcher.js +34 -3
- package/dist/im/lark/event-dispatcher.js.map +1 -1
- package/dist/im/lark/message-parser.d.ts +16 -0
- package/dist/im/lark/message-parser.d.ts.map +1 -1
- package/dist/im/lark/message-parser.js +31 -0
- package/dist/im/lark/message-parser.js.map +1 -1
- package/dist/services/budget-tracker.d.ts +61 -0
- package/dist/services/budget-tracker.d.ts.map +1 -0
- package/dist/services/budget-tracker.js +306 -0
- package/dist/services/budget-tracker.js.map +1 -0
- package/dist/services/connector-store.d.ts +16 -0
- package/dist/services/connector-store.d.ts.map +1 -1
- package/dist/services/connector-store.js.map +1 -1
- package/dist/services/failed-turn-retry.d.ts +43 -0
- package/dist/services/failed-turn-retry.d.ts.map +1 -0
- package/dist/services/failed-turn-retry.js +50 -0
- package/dist/services/failed-turn-retry.js.map +1 -0
- package/dist/services/model-pricing.d.ts +80 -0
- package/dist/services/model-pricing.d.ts.map +1 -0
- package/dist/services/model-pricing.js +182 -0
- package/dist/services/model-pricing.js.map +1 -0
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +13 -3
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/trigger-types.d.ts +10 -0
- package/dist/services/trigger-types.d.ts.map +1 -1
- package/dist/services/trigger-types.js.map +1 -1
- package/dist/services/usage-ledger.d.ts +10 -0
- package/dist/services/usage-ledger.d.ts.map +1 -1
- package/dist/services/usage-ledger.js +36 -0
- package/dist/services/usage-ledger.js.map +1 -1
- package/dist/services/voice/asr.d.ts +17 -0
- package/dist/services/voice/asr.d.ts.map +1 -0
- package/dist/services/voice/asr.js +64 -0
- package/dist/services/voice/asr.js.map +1 -0
- package/dist/services/voice/index.d.ts +17 -2
- package/dist/services/voice/index.d.ts.map +1 -1
- package/dist/services/voice/index.js +43 -0
- package/dist/services/voice/index.js.map +1 -1
- package/dist/services/voice/types.d.ts +15 -0
- package/dist/services/voice/types.d.ts.map +1 -1
- package/dist/services/webhook-idempotency.d.ts +134 -0
- package/dist/services/webhook-idempotency.d.ts.map +1 -0
- package/dist/services/webhook-idempotency.js +265 -0
- package/dist/services/webhook-idempotency.js.map +1 -0
- package/dist/setup/app-name.d.ts +1 -0
- package/dist/setup/app-name.d.ts.map +1 -1
- package/dist/setup/app-name.js +7 -0
- package/dist/setup/app-name.js.map +1 -1
- package/dist/setup/bot-config-editor.d.ts +28 -0
- package/dist/setup/bot-config-editor.d.ts.map +1 -1
- package/dist/setup/bot-config-editor.js +73 -0
- package/dist/setup/bot-config-editor.js.map +1 -1
- package/dist/setup/open-platform-automation.d.ts +26 -0
- package/dist/setup/open-platform-automation.d.ts.map +1 -1
- package/dist/setup/open-platform-automation.js +90 -1
- package/dist/setup/open-platform-automation.js.map +1 -1
- package/dist/setup/open-platform-outcome.d.ts.map +1 -1
- package/dist/setup/open-platform-outcome.js +8 -2
- package/dist/setup/open-platform-outcome.js.map +1 -1
- package/dist/types.d.ts +20 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/usage-limit-tracker.d.ts +29 -9
- package/dist/utils/usage-limit-tracker.d.ts.map +1 -1
- package/dist/utils/usage-limit-tracker.js +122 -14
- package/dist/utils/usage-limit-tracker.js.map +1 -1
- package/dist/worker.js +27 -6
- package/dist/worker.js.map +1 -1
- package/dist/workflows/definition.d.ts +56 -56
- package/dist/workflows/events/payloads.d.ts +2 -2
- package/dist/workflows/events/schema.d.ts +430 -430
- package/dist/workflows/migration/v2-run-archive-schema.d.ts +2 -2
- package/dist/workflows/v3/run-envelope.d.ts +56 -56
- package/package.json +9 -8
- package/scripts/postinstall-bin.mjs +25 -0
- package/dist/dashboard-web/chunks/chunk-NJCJR3U2.js +0 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Ke}from"./chunk-G5ZS2YUS.js";import{a as xe}from"./chunk-OXSVWLER.js";import{a as ye}from"./chunk-CEUCNZFJ.js";import{a as K,c as he,j as De,l as A,q as $}from"./chunk-NYY66DNC.js";import{c as Ze,d as O}from"./chunk-ECFC7UG2.js";import{a as Ae}from"./chunk-QITAMHW6.js";import{w as Ie}from"./chunk-BU3Q6XC6.js";import{c as We}from"./chunk-ARROO6TE.js";import{c as ue,d as _e,e as Te}from"./chunk-3YZFAHNK.js";var g=ue(_e(),1);var P=ue(_e(),1);var a=ue(Te(),1),tt=["transcript_received","chat_received","participant_joined","participant_left","magic_share_started","magic_share_ended"],Ee=8e3,nt=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function ze(e,t,i,s,o){return`${e?"1":"0"}|${t??""}|${i??""}|${s?"1":"0"}|${o??""}`}function it(e){return ze(e.vcEnabled,e.textOutputPolicy,e.voiceOutputPolicy,e.realtimeVoiceEnabled,e.catalogDefaultConsumerId)}function at(e){return e.map(t=>{let i=t.textOutputPolicy??null,s=t.voiceOutputPolicy??null,o=t.realtimeVoiceEnabled===!0,u=t.catalogDefaultConsumerId??null,p=t.vcEligible!==!1,h=p&&t.vcEnabled!==!1;return{appId:t.appId,label:t.label||t.appId,...t.cliId?{cliId:t.cliId}:{},online:t.online,workingDirReady:t.workingDirReady,reliableTurnTerminal:t.reliableTurnTerminal,managedSideEffectEligible:t.managedSideEffectEligible,sandboxIsolated:t.sandboxIsolated,vcEligible:p,vcEnabled:h,textOutputPolicy:i,voiceOutputPolicy:s,realtimeVoiceEnabled:o,catalogDefaultConsumerId:u,baseline:ze(h,i,s,o,u)}})}var je=0;function Le(){return je+=1,`p${je}`}function lt(e){return{...e,listenerPlacement:e.listenerPlacement??"auto",uiKey:Le(),isNew:!1}}function st(e){let{uiKey:t,isNew:i,...s}=e;return s}function ot(e){return e.workingDirReady&&e.reliableTurnTerminal&&e.managedSideEffectEligible}function ee(e){return(0,a.jsxs)("span",{className:"vc-profile-field-head",children:[e.title,(0,a.jsx)(De,{label:e.title,children:(0,a.jsx)("span",{className:"vc-profile-help",children:e.help})})]})}function qe(e){let t=O(),i=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let s=i.current;if(!(!s||s.open))try{s.showModal()}catch{s.setAttribute("open","")}},[]),(0,a.jsxs)("dialog",{ref:i,className:["vc-profile-dialog",e.className].filter(Boolean).join(" "),onClose:e.onClose,onCancel:s=>{s.preventDefault(),e.onClose()},children:[(0,a.jsxs)("header",{className:"vc-profile-dialog-head",children:[(0,a.jsxs)("div",{children:[e.eyebrow?(0,a.jsx)("span",{children:e.eyebrow}):null,(0,a.jsx)("h3",{children:e.title})]}),(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-close","aria-label":t("settings.vcProfiles.close"),onClick:e.onClose})]}),(0,a.jsx)("div",{className:"vc-profile-dialog-body",children:e.children})]})}function Ge(e){let t=O();return e.enabled?e.canWrite?(0,a.jsx)(rt,{canWrite:e.canWrite,onFeishuLoginQr:e.onFeishuLoginQr}):(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.needAuth")}):null}function rt(e){let t=O(),i=Ze(),s=(0,P.useRef)(!1),[o,u]=(0,P.useState)(null),[p,h]=(0,P.useState)(null),[N,R]=(0,P.useState)(!1),[k,b]=(0,P.useState)(!1),[C,te]=(0,P.useState)(!1),[j,Q]=(0,P.useState)(!1),[c,v]=(0,P.useState)({}),[M,ne]=(0,P.useState)(!1),[ie,Z]=(0,P.useState)(null),[ae,J]=(0,P.useState)(null),[_,ge]=(0,P.useState)(null),[fe,le]=(0,P.useState)({}),[z,Oe]=(0,P.useState)("");(0,P.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]);let X=(0,P.useRef)(0),pe=(0,P.useCallback)(async()=>{let l=++X.current;b(!1),Q(!1),v({}),Z(null),J(null),R(!0);try{let r=await fetch("/api/vc-meeting/consumer-profiles"),d=await r.json().catch(()=>({}));if(!s.current||X.current!==l)return;!r.ok||d?.ok!==!0?(u(null),h(typeof d?.error=="string"?d.error:`HTTP ${r.status}`)):(u(Qe(d)),h(null),b(!1))}catch(r){if(!s.current||X.current!==l)return;u(null),h(r instanceof Error?r.message:String(r))}finally{s.current&&X.current===l&&R(!1)}},[]);(0,P.useEffect)(()=>{pe()},[pe]);let E=(0,P.useCallback)(l=>{u(r=>r&&l(r)),b(!0),ne(!1)},[]),we=(0,P.useCallback)((l,r)=>{E(d=>({...d,profiles:d.profiles.map(m=>m.uiKey===l?{...m,...r}:m)}))},[E]),L=(0,P.useCallback)(async()=>{if(!o||C||N)return;let l={};if(o.profiles.forEach((r,d)=>{nt.test(r.id)||(l[`profiles[${d}].id`]=t("settings.vcProfiles.idInvalid")),(r.instructions??"").length>Ee&&(l[`profiles[${d}].instructions`]=t("settings.vcProfiles.instructionsTooLong"))}),Object.keys(l).length>0){v(l);return}te(!0),Q(!1),v({});try{let r=await fetch("/api/vc-meeting/consumer-profiles",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({expectedRevision:o.revision,defaultMode:o.defaultMode,defaultConsumerIds:o.defaultConsumerIds,profiles:o.profiles.map(st),botOutputPolicies:o.botPolicies.filter(m=>it(m)!==m.baseline).map(m=>({appId:m.appId,vcEnabled:m.vcEnabled,textOutputPolicy:m.textOutputPolicy,voiceOutputPolicy:m.voiceOutputPolicy,realtimeVoiceEnabled:m.realtimeVoiceEnabled,catalogDefaultConsumerId:m.catalogDefaultConsumerId}))})}),d=await r.json().catch(()=>({}));if(!s.current)return;if(r.status===409){Q(!0);return}if(r.status===422){let m={};for(let T of Array.isArray(d?.fieldErrors)?d.fieldErrors:[])typeof T?.path=="string"&&typeof T?.message=="string"&&(m[T.path]=T.message);v(Object.keys(m).length>0?m:{profiles:t("settings.vcProfiles.validationFailed")});return}if(!r.ok||d?.ok!==!0){v({profiles:typeof d?.error=="string"?d.error:`HTTP ${r.status}`});return}u(Qe(d)),b(!1),ne(!0)}catch(r){if(!s.current)return;v({profiles:r instanceof Error?r.message:String(r)})}finally{s.current&&te(!1)}},[o,N,C,t]),se=(0,P.useCallback)((l,r)=>{u(d=>d&&{...d,botPolicies:d.botPolicies.map(m=>m.appId===l?{...m,...r}:m)}),b(!0),ne(!1)},[]),D=(0,P.useCallback)(async l=>{if(!_){ge(l),le(r=>({...r,[l]:{ok:!0,text:t("settings.vcProfiles.botPolicies.preflightRunning")}}));try{let r=await fetch("/api/vc-meeting/bot-preflight",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({appId:l})}),d=await r.json().catch(()=>({}));if(!s.current)return;if(r.ok&&d?.ok===!0){e.onFeishuLoginQr?.(null),le(m=>({...m,[l]:{ok:!0,text:t("settings.vcProfiles.botPolicies.preflightOk")}}));return}typeof d?.feishuLoginQr=="string"&&d.feishuLoginQr&&e.onFeishuLoginQr?.(d.feishuLoginQr),le(m=>({...m,[l]:{ok:!1,text:typeof d?.error=="string"?d.error:`HTTP ${r.status}`}}))}catch(r){if(!s.current)return;le(d=>({...d,[l]:{ok:!1,text:r instanceof Error?r.message:String(r)}}))}finally{s.current&&ge(null)}}},[_,e,t]),me=(0,P.useCallback)(l=>{let d=["observe_only","meeting_text","meeting_voice","meeting_text_voice"].map(m=>({value:m,label:t(`settings.vcProfiles.preset.${m}`)}));return(!l.isNew||l.permissionPreset==="custom")&&d.push({value:"custom",label:t("settings.vcProfiles.preset.custom")}),d},[t]),oe=(0,P.useCallback)(()=>{let l=Le();E(r=>({...r,profiles:[...r.profiles,{uiKey:l,isNew:!0,id:"",responseMode:"silent",listenerPlacement:"auto",permissionPreset:"observe_only"}]})),Z(l)},[E]),Re=(0,P.useCallback)(l=>{let r=Le();E(d=>{let m=new Set(d.profiles.map(F=>F.id)),T=l.suggestedProfileId;for(let F=2;m.has(T);F+=1)T=`${l.suggestedProfileId.slice(0,60)}-${F}`;return{...d,profiles:[...d.profiles,{uiKey:r,isNew:!0,id:T,label:l.profileLabel[i],instructions:l.instructions[i],activityTypes:[...l.activityTypes],responseMode:l.responseMode,listenerPlacement:l.listenerPlacement,permissionPreset:l.permissionPreset}]}}),J(null),Z(r)},[i,E]),Pe=(0,P.useCallback)(l=>{E(r=>{let d=r.defaultConsumerIds.filter(m=>r.profiles.some(T=>T.uiKey!==l&&T.id===m));return{...r,profiles:r.profiles.filter(m=>m.uiKey!==l),defaultConsumerIds:d,defaultMode:d.length>0?r.defaultMode:"listenOnly"}}),Z(r=>r===l?null:r)},[E]),Ne=(0,P.useMemo)(()=>{if(!o)return[];let l=z.trim().toLowerCase();return[...l?o.botPolicies.filter(d=>d.label.toLowerCase().includes(l)||d.appId.toLowerCase().includes(l)):o.botPolicies].sort((d,m)=>d.vcEnabled!==m.vcEnabled?d.vcEnabled?-1:1:d.online!==m.online?d.online?-1:1:d.label.localeCompare(m.label))},[o,z]),W=l=>c[l],q=!e.canWrite||C||N,ke=o?.agentOptions.some(ot)??!1,ve=o?.profiles.findIndex(l=>l.uiKey===ie)??-1,H=ve>=0?o?.profiles[ve]??null:null,re=o?.templateCatalog.templates.find(l=>l.templateId===ae)??null,ce=l=>{l.id&&E(r=>{let m=r.defaultConsumerIds.length===1&&r.defaultConsumerIds[0]===l.id?[]:[l.id];return{...r,defaultMode:m.length>0?"agents":"listenOnly",defaultConsumerIds:m}})};return(0,a.jsxs)("div",{className:"vc-profiles-section",children:[(0,a.jsx)("div",{className:"settings-field-row",children:(0,a.jsx)(A,{help:t("settings.vcProfiles.help"),children:t("settings.vcProfiles.title")})}),(0,a.jsx)("p",{className:"hint vc-profiles-shared",children:t("settings.vcProfiles.sharedNotice")}),(0,a.jsx)("p",{className:"hint vc-profiles-freeze",children:t("settings.vcProfiles.freezeNotice")}),N?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.loading")}):null,p?(0,a.jsxs)("p",{className:"hint-warn",children:[t("settings.vcProfiles.loadFailed"),": ",p]}):null,j?(0,a.jsxs)("p",{className:"hint-warn",children:[t("settings.vcProfiles.conflict")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",onClick:()=>{pe()},children:t("settings.vcProfiles.reload")})]}):null,W("profiles")?(0,a.jsx)("p",{className:"hint-warn",children:W("profiles")}):null,o?(0,a.jsxs)(a.Fragment,{children:[ke?null:(0,a.jsx)("p",{className:"hint-warn",children:t("settings.vcProfiles.noEligibleDefaultAgent")}),(0,a.jsxs)("section",{className:"vc-profile-library-section",children:[(0,a.jsxs)("div",{className:"vc-profile-list-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.list.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.list.help")})]}),e.canWrite?(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-add",disabled:C||N,onClick:oe,children:t("settings.vcProfiles.add")}):null]}),o.profiles.length>0?(0,a.jsx)("div",{className:"vc-profile-card-grid",children:o.profiles.map(l=>{let r=o.defaultMode==="agents"&&o.defaultConsumerIds.includes(l.id);return(0,a.jsxs)("article",{className:"vc-profile-summary-card",role:"button",tabIndex:0,onClick:()=>Z(l.uiKey),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),Z(l.uiKey))},children:[(0,a.jsxs)("div",{className:"vc-profile-summary-top",children:[(0,a.jsx)("span",{className:"vc-profile-summary-icon","aria-hidden":"true",children:(l.label||l.id||"?").slice(0,1)}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:l.label||l.id||t("settings.vcProfiles.untitled")}),(0,a.jsx)("code",{children:l.id||t("settings.vcProfiles.newBadge")})]}),l.isNew?(0,a.jsx)("em",{children:t("settings.vcProfiles.newBadge")}):null]}),(0,a.jsx)("p",{children:(l.instructions??"").trim()||t("settings.vcProfiles.noInstructions")}),(0,a.jsxs)("div",{className:"vc-profile-summary-meta",children:[(0,a.jsx)("span",{children:l.responseMode==="listener_thread"?t("settings.vcProfiles.responseListener"):t("settings.vcProfiles.responseSilent")}),(0,a.jsx)("span",{children:t(`settings.vcProfiles.preset.${l.permissionPreset}`)})]}),(0,a.jsxs)("label",{className:"vc-profile-default-toggle",onClick:d=>d.stopPropagation(),children:[(0,a.jsx)("input",{type:"radio",name:"vc-profile-default",checked:r,disabled:q||!l.id,onChange:()=>ce(l),onClick:()=>{r&&ce(l)}}),(0,a.jsx)("span",{children:t("settings.vcProfiles.setDefault")})]})]},l.uiKey)})}):(0,a.jsx)("p",{className:"vc-profile-empty",children:t("settings.vcProfiles.list.empty")}),(0,a.jsx)("p",{className:"hint vc-profile-default-single",children:t("settings.vcProfiles.defaultSingleHint")})]}),o.templateCatalog.templates.length>0?(0,a.jsxs)("section",{className:"vc-profile-template-catalog",children:[(0,a.jsxs)("div",{className:"vc-profile-template-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.templates.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.templates.help")})]}),(0,a.jsx)("span",{children:t("settings.vcProfiles.templates.builtinBadge")})]}),(0,a.jsx)("div",{className:"vc-profile-template-grid",children:o.templateCatalog.templates.map(l=>(0,a.jsxs)("button",{type:"button",className:"vc-profile-template-card",onClick:()=>J(l.templateId),children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"\u2726"}),(0,a.jsx)("strong",{children:l.title[i]}),(0,a.jsx)("p",{children:l.description[i]}),(0,a.jsxs)("em",{children:[t("settings.vcProfiles.viewDetails")," \u2192"]})]},`${l.templateId}@${l.version}`))})]}):null,(0,a.jsxs)("section",{className:"vc-profile-library-section vc-bot-policy-section",children:[(0,a.jsxs)("div",{className:"vc-profile-list-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.botPolicies.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.botPolicies.help")})]}),(0,a.jsx)("input",{type:"search",className:"vc-bot-policy-search",placeholder:t("settings.vcProfiles.botPolicies.searchPlaceholder"),value:z,disabled:q,onChange:l=>Oe(l.target.value)})]}),(0,a.jsxs)("div",{className:"vc-bot-policy-table",style:{maxHeight:320,overflowY:"auto"},children:[Ne.length===0?(0,a.jsx)("p",{className:"vc-bot-policy-empty hint",children:t("settings.vcProfiles.botPolicies.noMatch")}):null,Ne.map(l=>{let r=l.textOutputPolicy??"allow",d=l.realtimeVoiceEnabled?l.voiceOutputPolicy??"allow":"deny",m=w=>t(`settings.vcProfiles.botPolicies.${w}`),T=[l.vcEligible?void 0:t("settings.vcProfiles.botPolicies.vcIneligible"),l.online?void 0:t("settings.vcProfiles.agentOffline"),l.workingDirReady?void 0:t("settings.vcProfiles.agentNoWorkingDir"),l.reliableTurnTerminal?void 0:t("settings.vcProfiles.agentNoReliableTerminal"),l.managedSideEffectEligible?void 0:t("settings.vcProfiles.agentNoManagedIsolation"),l.managedSideEffectEligible&&!l.sandboxIsolated?t("settings.vcProfiles.agentUnsandboxedRisk"):void 0].filter(w=>!!w),F=!e.canWrite||C||N,Ce=(w,Y)=>(0,a.jsxs)("select",{className:"vc-bot-policy-select",value:Y??"default",disabled:F||!l.vcEnabled,onChange:$e=>{let Se=$e.target.value;se(l.appId,{[w]:Se==="default"?null:Se})},children:[(0,a.jsx)("option",{value:"default",children:t("settings.vcProfiles.botPolicies.default")}),(0,a.jsx)("option",{value:"allow",children:m("allow")}),(0,a.jsx)("option",{value:"approval",children:m("approval")}),(0,a.jsx)("option",{value:"deny",children:m("deny")})]}),de=fe[l.appId];return(0,a.jsxs)("div",{className:"vc-bot-policy-row",children:[(0,a.jsxs)("span",{className:"vc-bot-policy-name",title:l.appId,children:[l.online?"":"\u26AA ",l.label,T.length>0?(0,a.jsx)(De,{className:"vc-bot-policy-warn-tip",label:T.join(" \xB7 "),trigger:(0,a.jsx)("em",{className:"vc-bot-policy-warn","aria-hidden":"true",children:"\u26A0"}),children:(0,a.jsx)("span",{className:"vc-bot-policy-warn-pop",children:T.map((w,Y)=>(0,a.jsx)("div",{children:w},Y))})}):null,de?(0,a.jsx)("em",{className:de.ok?"vc-bot-policy-preflight":"vc-bot-policy-warn",children:de.text}):null]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell vc-bot-policy-enabled",children:[(0,a.jsx)("input",{type:"checkbox",checked:l.vcEnabled,disabled:F||!l.vcEligible,onChange:w=>se(l.appId,{vcEnabled:w.target.checked})}),(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.vcEnabled")})]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.defaultProfile")}),(0,a.jsxs)("select",{className:"vc-bot-policy-select",value:l.catalogDefaultConsumerId??"",disabled:F||!l.vcEnabled,onChange:w=>{let Y=w.target.value;se(l.appId,{catalogDefaultConsumerId:Y===""?null:Y})},children:[(0,a.jsx)("option",{value:"",children:t("settings.vcProfiles.botPolicies.defaultProfileFollowGlobal")}),o.profiles.map(w=>(0,a.jsx)("option",{value:w.id,children:w.label||w.id},w.id))]})]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.text")}),Ce("textOutputPolicy",l.textOutputPolicy)]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.voice")}),Ce("voiceOutputPolicy",l.voiceOutputPolicy)]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell vc-bot-policy-rtv",children:[(0,a.jsx)("input",{type:"checkbox",checked:l.realtimeVoiceEnabled,disabled:F||!l.vcEnabled,onChange:w=>se(l.appId,{realtimeVoiceEnabled:w.target.checked})}),(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.realtimeVoice")})]}),(0,a.jsxs)("span",{className:"vc-bot-policy-effective hint",children:[t("settings.vcProfiles.botPolicies.effective")," ",l.vcEnabled?`${m(r)} / ${m(d)}`:t("settings.vcProfiles.botPolicies.vcOff")]}),(0,a.jsx)("button",{type:"button",className:"bd-btn bd-btn-ghost vc-bot-policy-preflight-btn",disabled:!e.canWrite||!l.vcEligible||_!==null,title:t("settings.vcProfiles.botPolicies.preflightHelp"),onClick:()=>{D(l.appId)},children:_===l.appId?t("settings.vcProfiles.botPolicies.preflightRunning"):t("settings.vcProfiles.botPolicies.preflight")})]},l.appId)})]})]}),(0,a.jsxs)("div",{className:"settings-field-row vc-profile-default-mode-row",children:[(0,a.jsx)(A,{help:t("settings.vcProfiles.defaultModeHelp"),children:t("settings.vcProfiles.defaultMode")}),(0,a.jsx)($,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.defaultMode"),disabled:q,value:o.defaultMode,label:o.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:l=>E(r=>({...r,defaultMode:l==="agents"?"agents":"listenOnly"}))})]}),W("defaultConsumerIds")?(0,a.jsx)("em",{className:"vc-profile-err",children:W("defaultConsumerIds")}):null,W("defaultMode")?(0,a.jsx)("em",{className:"vc-profile-err",children:W("defaultMode")}):null,e.canWrite?(0,a.jsxs)("div",{className:"vc-profiles-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-save",disabled:!k||C||j,onClick:()=>{L()},children:t(C?"settings.vcProfiles.saving":"settings.vcProfiles.save")}),M?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.saved")}):null,k&&!C?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.unsaved")}):null]}):null,H?(0,a.jsx)(ct,{profile:H,index:ve,frozen:q,canWrite:e.canWrite,presetOptions:me(H),error:W,onClose:()=>Z(null),onUpdate:l=>we(H.uiKey,l),onIdChange:l=>{let r=H.id;E(d=>{let m=d.defaultConsumerIds.map(T=>T===r&&r?l:T).filter(Boolean);return{...d,profiles:d.profiles.map(T=>T.uiKey===H.uiKey?{...T,id:l}:T),defaultConsumerIds:m,defaultMode:m.length>0?d.defaultMode:"listenOnly"}})},onRemove:()=>Pe(H.uiKey)}):null,re?(0,a.jsx)(dt,{template:re,locale:i,disabled:q,onClose:()=>J(null),onUse:()=>Re(re)}):null]}):null]})}function Qe(e){let t=Array.isArray(e.agentOptions)?e.agentOptions:[];return{revision:e.revision,catalogState:e.catalogState==="explicit_empty"||e.catalogState==="profiles"?e.catalogState:"uninitialized",defaultMode:e.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(e.defaultConsumerIds)?e.defaultConsumerIds:[],profiles:(Array.isArray(e.profiles)?e.profiles:[]).map(lt),agentOptions:t,botPolicies:at(t),templateCatalog:e.templateCatalog?.schemaVersion===1&&Array.isArray(e.templateCatalog.templates)?e.templateCatalog:{schemaVersion:1,templates:[]}}}function ct(e){let t=O(),{profile:i,index:s}=e;return(0,a.jsxs)(qe,{className:"vc-profile-editor-dialog",eyebrow:t("settings.vcProfiles.list.title"),title:i.label||i.id||t("settings.vcProfiles.untitled"),onClose:e.onClose,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)(ee,{title:t("settings.vcProfiles.fieldId"),help:t("settings.vcProfiles.idHelp")})}),(0,a.jsx)("input",{type:"text",value:i.id,disabled:e.frozen||!i.isNew,placeholder:"minutes",onChange:o=>e.onIdChange(o.currentTarget.value)}),e.error(`profiles[${s}].id`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].id`)}):null]}),(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldLabel"),help:t("settings.vcProfiles.labelHelp")})}),(0,a.jsx)("input",{type:"text",value:i.label??"",disabled:e.frozen,onChange:o=>e.onUpdate({label:o.currentTarget.value||void 0})}),e.error(`profiles[${s}].label`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].label`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldResponseMode"),help:t("settings.vcProfiles.responseModeHelp")})}),(0,a.jsx)($,{ariaLabel:t("settings.vcProfiles.fieldResponseMode"),disabled:e.frozen,value:i.responseMode,label:i.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:o=>e.onUpdate({responseMode:o})}),e.error(`profiles[${s}].responseMode`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].responseMode`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldListenerPlacement"),help:t("settings.vcProfiles.listenerPlacementHelp")})}),(0,a.jsx)($,{ariaLabel:t("settings.vcProfiles.fieldListenerPlacement"),disabled:e.frozen||i.responseMode==="silent",value:i.listenerPlacement??"auto",label:t(`settings.vcProfiles.listenerPlacement.${i.listenerPlacement??"auto"}`),options:["auto","chat","topic"].map(o=>({value:o,label:t(`settings.vcProfiles.listenerPlacement.${o}`)})),onChange:o=>e.onUpdate({listenerPlacement:o})}),e.error(`profiles[${s}].listenerPlacement`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].listenerPlacement`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldPreset"),help:t("settings.vcProfiles.presetHelp")})}),(0,a.jsx)($,{ariaLabel:t("settings.vcProfiles.fieldPreset"),disabled:e.frozen,value:i.permissionPreset,label:K(e.presetOptions,i.permissionPreset),options:e.presetOptions,onChange:o=>e.onUpdate({permissionPreset:o})}),e.error(`profiles[${s}].permissionPreset`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].permissionPreset`)}):null]})]}),(0,a.jsxs)("label",{className:"vc-profile-field vc-profile-instructions",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldInstructions"),help:t("settings.vcProfiles.instructionsHelp")}),(0,a.jsxs)("em",{className:"vc-profile-count",children:[(i.instructions??"").length,"/",Ee]})]}),(0,a.jsx)("textarea",{rows:7,maxLength:Ee,value:i.instructions??"",disabled:e.frozen,placeholder:t("settings.vcProfiles.instructionsPlaceholder"),onChange:o=>e.onUpdate({instructions:o.currentTarget.value||void 0})}),e.error(`profiles[${s}].instructions`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].instructions`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldActivityTypes"),help:t("settings.vcProfiles.activityHelp")})}),(0,a.jsx)("div",{className:"vc-profile-activity",children:tt.map(o=>{let u=i.activityTypes?.includes(o)??!1;return(0,a.jsxs)("label",{className:"vc-profile-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:u,disabled:e.frozen,onChange:p=>{let h=new Set(i.activityTypes??[]);p.currentTarget.checked?h.add(o):h.delete(o),e.onUpdate({activityTypes:h.size>0?[...h]:void 0})}}),t(`settings.vcProfiles.activity.${o}`)]},o)})}),(0,a.jsx)("em",{className:"vc-profile-hint",children:t("settings.vcProfiles.activityAllHint")}),e.error(`profiles[${s}].activityTypes`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].activityTypes`)}):null]}),e.canWrite?(0,a.jsxs)("footer",{className:"vc-profile-dialog-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-remove",disabled:e.frozen,onClick:e.onRemove,children:t("settings.vcProfiles.remove")}),(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-done",onClick:e.onClose,children:t("settings.vcProfiles.done")})]}):null]})}function dt(e){let t=O(),i=e.template;return(0,a.jsxs)(qe,{className:"vc-profile-template-dialog",eyebrow:t("settings.vcProfiles.templates.title"),title:i.title[e.locale],onClose:e.onClose,children:[(0,a.jsx)("p",{className:"vc-profile-template-description",children:i.description[e.locale]}),(0,a.jsxs)("div",{className:"vc-profile-template-facts",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldResponseMode")}),(0,a.jsx)("strong",{children:t(i.responseMode==="listener_thread"?"settings.vcProfiles.responseListener":"settings.vcProfiles.responseSilent")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldListenerPlacement")}),(0,a.jsx)("strong",{children:t(`settings.vcProfiles.listenerPlacement.${i.listenerPlacement}`)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldPreset")}),(0,a.jsx)("strong",{children:t(`settings.vcProfiles.preset.${i.permissionPreset}`)})]})]}),(0,a.jsxs)("section",{className:"vc-profile-template-prompt",children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.fieldInstructions")}),(0,a.jsx)("p",{children:i.instructions[e.locale]})]}),(0,a.jsxs)("section",{className:"vc-profile-template-events",children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.fieldActivityTypes")}),(0,a.jsx)("div",{children:i.activityTypes.map(s=>(0,a.jsx)("span",{children:t(`settings.vcProfiles.activity.${s}`)},s))})]}),(0,a.jsxs)("footer",{className:"vc-profile-dialog-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-secondary",onClick:e.onClose,children:t("settings.vcProfiles.close")}),(0,a.jsx)("button",{type:"button",className:"vc-profile-template-use",disabled:e.disabled,onClick:e.onUse,children:t("settings.vcProfiles.templates.use")})]})]})}var n=ue(Te(),1),Ue=["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 Je(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return typeof t.supported=="boolean"&&typeof t.enabled=="boolean"?{supported:t.supported,enabled:t.enabled}:null}function ut(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 Be(e){return{groupNamePrefix:typeof e?.groupNamePrefix=="string"?e.groupNamePrefix:"",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:""},codexRpcInput:e?.codexRpcInput===!0,bypassCodexHookTrust:e?.bypassCodexHookTrust!==!1,codexNotifier:{enabled:e?.codexNotifier?.enabled===!0,targetBotAppId:typeof e?.codexNotifier?.targetBotAppId=="string"?e.codexNotifier.targetBotAppId:null,notifyWhen:e?.codexNotifier?.notifyWhen==="always"?"always":"locked_only",platformSupported:e?.codexNotifier?.platformSupported===!0,hookInstalled:e?.codexNotifier?.hookInstalled===!0,botOptions:Array.isArray(e?.codexNotifier?.botOptions)?e.codexNotifier.botOptions:[],targetDaemonOnline:e?.codexNotifier?.targetDaemonOnline===!0,pendingCount:Number.isSafeInteger(e?.codexNotifier?.pendingCount)?Math.max(0,e.codexNotifier.pendingCount):0,workerOnline:e?.codexNotifier?.workerOnline===!0,lastError:e?.codexNotifier?.lastError&&typeof e.codexNotifier.lastError.message=="string"?e.codexNotifier.lastError:null},hostOverloadAlert:{enabled:e?.hostOverloadAlert?.enabled===!0,targetBotAppId:typeof e?.hostOverloadAlert?.targetBotAppId=="string"?e.hostOverloadAlert.targetBotAppId:null,enterLoadRatio:typeof e?.hostOverloadAlert?.enterLoadRatio=="number"?e.hostOverloadAlert.enterLoadRatio:1.5,enterMemUsedFrac:typeof e?.hostOverloadAlert?.enterMemUsedFrac=="number"?e.hostOverloadAlert.enterMemUsedFrac:.92,botOptions:Array.isArray(e?.hostOverloadAlert?.botOptions)?e.hostOverloadAlert.botOptions:[],targetDaemonOnline:e?.hostOverloadAlert?.targetDaemonOnline===!0},noVisibleOutputHint:e?.noVisibleOutputHint===!0,vcMeetingAgent:{enabled:e?.vcMeetingAgent?.enabled!==!1,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},workflow:{enabled:e?.workflow?.enabled===!0},remoteAccess:e?.remoteAccess===!0,oauthRedirectBase:typeof e?.oauthRedirectBase=="string"?e.oauthRedirectBase:"",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 gt(e,t){let i=e?.[t]??{};return{enabled:i.enabled===!0,time:typeof i.time=="string"?i.time:"04:00"}}function Ye(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 ft(){let e=O(),t=(0,g.useRef)(!1),i=(0,g.useRef)(new Set),[s,o]=(0,g.useState)(null),[u,p]=(0,g.useState)(!1),[h,N]=(0,g.useState)(null),[R,k]=(0,g.useState)(!0),[b,C]=(0,g.useState)(!1),[te,j]=(0,g.useState)(null),[Q,c]=(0,g.useState)(null),[v,M]=(0,g.useState)(null),[ne,ie]=(0,g.useState)(null),[Z,ae]=(0,g.useState)(null),[J,_]=(0,g.useState)(null),[ge,fe]=(0,g.useState)(!1),[le,z]=(0,g.useState)(!0),[Oe,X]=(0,g.useState)(!1),[pe,E]=(0,g.useState)(""),[we,L]=(0,g.useState)(!1),[se,D]=(0,g.useState)(null),[me,oe]=(0,g.useState)(null),[Re,Pe]=(0,g.useState)(!1),[Ne,W]=(0,g.useState)(!1),[q,ke]=(0,g.useState)(!1),[ve,H]=(0,g.useState)(null),re=(0,g.useCallback)(()=>{for(let f of i.current)window.clearTimeout(f);i.current.clear()},[]),ce=(0,g.useCallback)((f,y)=>{let x=window.setTimeout(()=>{i.current.delete(x),f()},y);return i.current.add(x),x},[]),l=(0,g.useCallback)(async()=>{try{let f=await fetch("/api/update/status"),y=await f.json().catch(()=>({}));if(!t.current)return;if(!f.ok){ie(null),ae(y?.error??`HTTP ${f.status}`);return}ie(y),ae(null)}catch(f){if(!t.current)return;ie(null),ae(f instanceof Error?f.message:String(f))}},[]),r=(0,g.useCallback)(async()=>{Pe(!0);try{let f=await fetch("/api/autostart",{cache:"no-store"}),y=await f.json().catch(()=>({})),x=f.ok?Je(y.state):null;if(!x)throw new Error("invalid_state");if(!t.current)return;oe(x),W(!1)}catch{if(!t.current)return;W(!0)}finally{t.current&&Pe(!1)}},[]),d=(0,g.useCallback)(async()=>{try{let f=await fetch("/api/settings"),y=await f.json().catch(()=>({}));if(!t.current)return;if(!f.ok){o(null),N(y?.error??`HTTP ${f.status}`),p(!0);return}o(Be(y.settings)),k(y.authed===!0),C(y.bound===!0),N(null),p(!0)}catch(f){if(!t.current)return;o(null),N(f instanceof Error?f.message:String(f)),p(!0)}},[]);(0,g.useEffect)(()=>(t.current=!0,d(),()=>{t.current=!1,re()}),[re,d]),(0,g.useEffect)(()=>{u&&(L(!1),D(null),fe(!1),H(null),R&&(l(),r()))},[R,r,l,u]);async function m(f){if(!me||q)return;let y=me;ke(!0),oe({...y,enabled:f}),H({text:e("settings.autostartSaving")});try{let x=await fetch("/api/autostart",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:f})}),U=await x.json().catch(()=>({})),S=x.ok?Je(U.state):null;if(!S)throw new Error("save_failed");if(!t.current)return;oe(S),H({text:e("settings.autostartSaved"),cls:"hint-ok"})}catch{if(!t.current)return;oe(y),H({text:e("settings.autostartSaveFailed"),cls:"hint-warn-inline"}),r()}finally{t.current&&ke(!1)}}async function T(f,y,x){if(!s)return;let U=s;o(x(s)),j(f),c({text:e("settings.saving")});try{let S=await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(y)}),V=await S.json().catch(()=>({}));if(!t.current)return;if(!S.ok||V.ok===!1)throw typeof V?.feishuLoginQr=="string"&&V.feishuLoginQr&&M(V.feishuLoginQr),new Error(V?.error??`HTTP ${S.status}`);M(null);let G=Be(V.settings);o(G),Ie.publicReadOnly=G.publicReadOnly,Ae.setScheduleTimeZone(G.effectiveScheduleTimeZone);let be=ut(V.herdrTraexInstall,e);c(be??{text:e("settings.saved"),cls:"hint-ok"}),be||ce(()=>{t.current&&c(null)},1500)}catch(S){if(!t.current)return;let V=!1;try{let be=await fetch("/api/settings"),Fe=await be.json().catch(()=>({}));if(t.current&&be.ok&&Fe?.settings){let Me=Be(Fe.settings);o(Me),Ie.publicReadOnly=Me.publicReadOnly,Ae.setScheduleTimeZone(Me.effectiveScheduleTimeZone),V=!0}}catch{}if(!t.current)return;V||o(U);let G=S instanceof Error?S.message:String(S);c({text:V?`${e("settings.saveReconciled")}: ${G}`:`${e("settings.saveFailed")}: ${G}`,cls:"hint-warn-inline"})}finally{t.current&&j(null)}}async function F(){_(null),z(!0),X(!1);try{let f=await fetch("/api/update/changelog"),y=await f.json().catch(()=>({}));if(!t.current)return;E(typeof y?.releasesUrl=="string"?y.releasesUrl:""),f.ok?(_(Array.isArray(y.releases)?y.releases:[]),z(y.ok!==!1),X(y.rateLimited===!0)):(_([]),z(!1))}catch{if(!t.current)return;_([]),z(!1)}}function Ce(){let f=Date.now(),y=async()=>{if(t.current){if(Date.now()-f>9e4){L(!1),D({text:e("update.restartSlow"),cls:"hint-warn-inline"});return}try{let x=await fetch("/__health",{cache:"no-store"});if(!t.current)return;if(x.ok){location.reload();return}}catch{}t.current&&ce(()=>{y()},2e3)}};ce(()=>{y()},3e3)}async function de(f){L(!0),D({text:e("update.restarting")});try{let y=await fetch("/api/update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(f?{update:f}:{})}),x=await y.json().catch(()=>({}));if(!y.ok||x.ok===!1){if(x.error==="update_target_unavailable"||x.error==="update_target_drifted"){if(!t.current)return;L(!1),D({text:e(`update.${x.error}`,{dir:String(x.dir??"")}),cls:"hint-warn-inline"}),l();return}throw new Error(String(x.detail??x.error??`HTTP ${y.status}`))}if(!t.current)return}catch(y){if(!t.current)return;L(!1),D({text:e("update.restartFailed",{detail:y instanceof Error?y.message:String(y)}),cls:"hint-warn-inline"});return}Ce()}async function w(){let f=ne;if(!f)return;if(!f.node.ok){xe(e("update.nodeTooOldAlert",{version:f.node.version,required:f.node.required}),{kind:"warning"});return}let y=f.localDevInstall===!0;if(y){if(!f.localDevUpdatable){xe(e("update.localDev"),{kind:"warning"});return}}else if(!f.updateSupported||!f.updateCommand){xe(e("update.unsupportedInstall"),{kind:"warning"});return}if(f.installs.multiple){let U=f.installs.entries.map(S=>`\u2022 ${S.binPath} (${Ye(S.kind,e)})`).join(`
|
|
1
|
+
import{a as Ke}from"./chunk-G5ZS2YUS.js";import{a as xe}from"./chunk-OXSVWLER.js";import{a as ye}from"./chunk-CEUCNZFJ.js";import{a as K,c as he,j as De,l as A,q as $}from"./chunk-NYY66DNC.js";import{c as Ze,d as O}from"./chunk-R3LJUCEO.js";import{a as Ae}from"./chunk-QITAMHW6.js";import{w as Ie}from"./chunk-K232GT3M.js";import{c as We}from"./chunk-ARROO6TE.js";import{c as ue,d as _e,e as Te}from"./chunk-3YZFAHNK.js";var g=ue(_e(),1);var P=ue(_e(),1);var a=ue(Te(),1),tt=["transcript_received","chat_received","participant_joined","participant_left","magic_share_started","magic_share_ended"],Ee=8e3,nt=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function ze(e,t,i,s,o){return`${e?"1":"0"}|${t??""}|${i??""}|${s?"1":"0"}|${o??""}`}function it(e){return ze(e.vcEnabled,e.textOutputPolicy,e.voiceOutputPolicy,e.realtimeVoiceEnabled,e.catalogDefaultConsumerId)}function at(e){return e.map(t=>{let i=t.textOutputPolicy??null,s=t.voiceOutputPolicy??null,o=t.realtimeVoiceEnabled===!0,u=t.catalogDefaultConsumerId??null,p=t.vcEligible!==!1,h=p&&t.vcEnabled!==!1;return{appId:t.appId,label:t.label||t.appId,...t.cliId?{cliId:t.cliId}:{},online:t.online,workingDirReady:t.workingDirReady,reliableTurnTerminal:t.reliableTurnTerminal,managedSideEffectEligible:t.managedSideEffectEligible,sandboxIsolated:t.sandboxIsolated,vcEligible:p,vcEnabled:h,textOutputPolicy:i,voiceOutputPolicy:s,realtimeVoiceEnabled:o,catalogDefaultConsumerId:u,baseline:ze(h,i,s,o,u)}})}var je=0;function Le(){return je+=1,`p${je}`}function lt(e){return{...e,listenerPlacement:e.listenerPlacement??"auto",uiKey:Le(),isNew:!1}}function st(e){let{uiKey:t,isNew:i,...s}=e;return s}function ot(e){return e.workingDirReady&&e.reliableTurnTerminal&&e.managedSideEffectEligible}function ee(e){return(0,a.jsxs)("span",{className:"vc-profile-field-head",children:[e.title,(0,a.jsx)(De,{label:e.title,children:(0,a.jsx)("span",{className:"vc-profile-help",children:e.help})})]})}function qe(e){let t=O(),i=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let s=i.current;if(!(!s||s.open))try{s.showModal()}catch{s.setAttribute("open","")}},[]),(0,a.jsxs)("dialog",{ref:i,className:["vc-profile-dialog",e.className].filter(Boolean).join(" "),onClose:e.onClose,onCancel:s=>{s.preventDefault(),e.onClose()},children:[(0,a.jsxs)("header",{className:"vc-profile-dialog-head",children:[(0,a.jsxs)("div",{children:[e.eyebrow?(0,a.jsx)("span",{children:e.eyebrow}):null,(0,a.jsx)("h3",{children:e.title})]}),(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-close","aria-label":t("settings.vcProfiles.close"),onClick:e.onClose})]}),(0,a.jsx)("div",{className:"vc-profile-dialog-body",children:e.children})]})}function Ge(e){let t=O();return e.enabled?e.canWrite?(0,a.jsx)(rt,{canWrite:e.canWrite,onFeishuLoginQr:e.onFeishuLoginQr}):(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.needAuth")}):null}function rt(e){let t=O(),i=Ze(),s=(0,P.useRef)(!1),[o,u]=(0,P.useState)(null),[p,h]=(0,P.useState)(null),[N,R]=(0,P.useState)(!1),[k,b]=(0,P.useState)(!1),[C,te]=(0,P.useState)(!1),[j,Q]=(0,P.useState)(!1),[c,v]=(0,P.useState)({}),[M,ne]=(0,P.useState)(!1),[ie,Z]=(0,P.useState)(null),[ae,J]=(0,P.useState)(null),[_,ge]=(0,P.useState)(null),[fe,le]=(0,P.useState)({}),[z,Oe]=(0,P.useState)("");(0,P.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]);let X=(0,P.useRef)(0),pe=(0,P.useCallback)(async()=>{let l=++X.current;b(!1),Q(!1),v({}),Z(null),J(null),R(!0);try{let r=await fetch("/api/vc-meeting/consumer-profiles"),d=await r.json().catch(()=>({}));if(!s.current||X.current!==l)return;!r.ok||d?.ok!==!0?(u(null),h(typeof d?.error=="string"?d.error:`HTTP ${r.status}`)):(u(Qe(d)),h(null),b(!1))}catch(r){if(!s.current||X.current!==l)return;u(null),h(r instanceof Error?r.message:String(r))}finally{s.current&&X.current===l&&R(!1)}},[]);(0,P.useEffect)(()=>{pe()},[pe]);let E=(0,P.useCallback)(l=>{u(r=>r&&l(r)),b(!0),ne(!1)},[]),we=(0,P.useCallback)((l,r)=>{E(d=>({...d,profiles:d.profiles.map(m=>m.uiKey===l?{...m,...r}:m)}))},[E]),L=(0,P.useCallback)(async()=>{if(!o||C||N)return;let l={};if(o.profiles.forEach((r,d)=>{nt.test(r.id)||(l[`profiles[${d}].id`]=t("settings.vcProfiles.idInvalid")),(r.instructions??"").length>Ee&&(l[`profiles[${d}].instructions`]=t("settings.vcProfiles.instructionsTooLong"))}),Object.keys(l).length>0){v(l);return}te(!0),Q(!1),v({});try{let r=await fetch("/api/vc-meeting/consumer-profiles",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({expectedRevision:o.revision,defaultMode:o.defaultMode,defaultConsumerIds:o.defaultConsumerIds,profiles:o.profiles.map(st),botOutputPolicies:o.botPolicies.filter(m=>it(m)!==m.baseline).map(m=>({appId:m.appId,vcEnabled:m.vcEnabled,textOutputPolicy:m.textOutputPolicy,voiceOutputPolicy:m.voiceOutputPolicy,realtimeVoiceEnabled:m.realtimeVoiceEnabled,catalogDefaultConsumerId:m.catalogDefaultConsumerId}))})}),d=await r.json().catch(()=>({}));if(!s.current)return;if(r.status===409){Q(!0);return}if(r.status===422){let m={};for(let T of Array.isArray(d?.fieldErrors)?d.fieldErrors:[])typeof T?.path=="string"&&typeof T?.message=="string"&&(m[T.path]=T.message);v(Object.keys(m).length>0?m:{profiles:t("settings.vcProfiles.validationFailed")});return}if(!r.ok||d?.ok!==!0){v({profiles:typeof d?.error=="string"?d.error:`HTTP ${r.status}`});return}u(Qe(d)),b(!1),ne(!0)}catch(r){if(!s.current)return;v({profiles:r instanceof Error?r.message:String(r)})}finally{s.current&&te(!1)}},[o,N,C,t]),se=(0,P.useCallback)((l,r)=>{u(d=>d&&{...d,botPolicies:d.botPolicies.map(m=>m.appId===l?{...m,...r}:m)}),b(!0),ne(!1)},[]),D=(0,P.useCallback)(async l=>{if(!_){ge(l),le(r=>({...r,[l]:{ok:!0,text:t("settings.vcProfiles.botPolicies.preflightRunning")}}));try{let r=await fetch("/api/vc-meeting/bot-preflight",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({appId:l})}),d=await r.json().catch(()=>({}));if(!s.current)return;if(r.ok&&d?.ok===!0){e.onFeishuLoginQr?.(null),le(m=>({...m,[l]:{ok:!0,text:t("settings.vcProfiles.botPolicies.preflightOk")}}));return}typeof d?.feishuLoginQr=="string"&&d.feishuLoginQr&&e.onFeishuLoginQr?.(d.feishuLoginQr),le(m=>({...m,[l]:{ok:!1,text:typeof d?.error=="string"?d.error:`HTTP ${r.status}`}}))}catch(r){if(!s.current)return;le(d=>({...d,[l]:{ok:!1,text:r instanceof Error?r.message:String(r)}}))}finally{s.current&&ge(null)}}},[_,e,t]),me=(0,P.useCallback)(l=>{let d=["observe_only","meeting_text","meeting_voice","meeting_text_voice"].map(m=>({value:m,label:t(`settings.vcProfiles.preset.${m}`)}));return(!l.isNew||l.permissionPreset==="custom")&&d.push({value:"custom",label:t("settings.vcProfiles.preset.custom")}),d},[t]),oe=(0,P.useCallback)(()=>{let l=Le();E(r=>({...r,profiles:[...r.profiles,{uiKey:l,isNew:!0,id:"",responseMode:"silent",listenerPlacement:"auto",permissionPreset:"observe_only"}]})),Z(l)},[E]),Re=(0,P.useCallback)(l=>{let r=Le();E(d=>{let m=new Set(d.profiles.map(F=>F.id)),T=l.suggestedProfileId;for(let F=2;m.has(T);F+=1)T=`${l.suggestedProfileId.slice(0,60)}-${F}`;return{...d,profiles:[...d.profiles,{uiKey:r,isNew:!0,id:T,label:l.profileLabel[i],instructions:l.instructions[i],activityTypes:[...l.activityTypes],responseMode:l.responseMode,listenerPlacement:l.listenerPlacement,permissionPreset:l.permissionPreset}]}}),J(null),Z(r)},[i,E]),Pe=(0,P.useCallback)(l=>{E(r=>{let d=r.defaultConsumerIds.filter(m=>r.profiles.some(T=>T.uiKey!==l&&T.id===m));return{...r,profiles:r.profiles.filter(m=>m.uiKey!==l),defaultConsumerIds:d,defaultMode:d.length>0?r.defaultMode:"listenOnly"}}),Z(r=>r===l?null:r)},[E]),Ne=(0,P.useMemo)(()=>{if(!o)return[];let l=z.trim().toLowerCase();return[...l?o.botPolicies.filter(d=>d.label.toLowerCase().includes(l)||d.appId.toLowerCase().includes(l)):o.botPolicies].sort((d,m)=>d.vcEnabled!==m.vcEnabled?d.vcEnabled?-1:1:d.online!==m.online?d.online?-1:1:d.label.localeCompare(m.label))},[o,z]),W=l=>c[l],q=!e.canWrite||C||N,ke=o?.agentOptions.some(ot)??!1,ve=o?.profiles.findIndex(l=>l.uiKey===ie)??-1,H=ve>=0?o?.profiles[ve]??null:null,re=o?.templateCatalog.templates.find(l=>l.templateId===ae)??null,ce=l=>{l.id&&E(r=>{let m=r.defaultConsumerIds.length===1&&r.defaultConsumerIds[0]===l.id?[]:[l.id];return{...r,defaultMode:m.length>0?"agents":"listenOnly",defaultConsumerIds:m}})};return(0,a.jsxs)("div",{className:"vc-profiles-section",children:[(0,a.jsx)("div",{className:"settings-field-row",children:(0,a.jsx)(A,{help:t("settings.vcProfiles.help"),children:t("settings.vcProfiles.title")})}),(0,a.jsx)("p",{className:"hint vc-profiles-shared",children:t("settings.vcProfiles.sharedNotice")}),(0,a.jsx)("p",{className:"hint vc-profiles-freeze",children:t("settings.vcProfiles.freezeNotice")}),N?(0,a.jsx)("p",{className:"hint",children:t("settings.vcProfiles.loading")}):null,p?(0,a.jsxs)("p",{className:"hint-warn",children:[t("settings.vcProfiles.loadFailed"),": ",p]}):null,j?(0,a.jsxs)("p",{className:"hint-warn",children:[t("settings.vcProfiles.conflict")," ",(0,a.jsx)("button",{type:"button",className:"vc-profiles-link",onClick:()=>{pe()},children:t("settings.vcProfiles.reload")})]}):null,W("profiles")?(0,a.jsx)("p",{className:"hint-warn",children:W("profiles")}):null,o?(0,a.jsxs)(a.Fragment,{children:[ke?null:(0,a.jsx)("p",{className:"hint-warn",children:t("settings.vcProfiles.noEligibleDefaultAgent")}),(0,a.jsxs)("section",{className:"vc-profile-library-section",children:[(0,a.jsxs)("div",{className:"vc-profile-list-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.list.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.list.help")})]}),e.canWrite?(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-add",disabled:C||N,onClick:oe,children:t("settings.vcProfiles.add")}):null]}),o.profiles.length>0?(0,a.jsx)("div",{className:"vc-profile-card-grid",children:o.profiles.map(l=>{let r=o.defaultMode==="agents"&&o.defaultConsumerIds.includes(l.id);return(0,a.jsxs)("article",{className:"vc-profile-summary-card",role:"button",tabIndex:0,onClick:()=>Z(l.uiKey),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),Z(l.uiKey))},children:[(0,a.jsxs)("div",{className:"vc-profile-summary-top",children:[(0,a.jsx)("span",{className:"vc-profile-summary-icon","aria-hidden":"true",children:(l.label||l.id||"?").slice(0,1)}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:l.label||l.id||t("settings.vcProfiles.untitled")}),(0,a.jsx)("code",{children:l.id||t("settings.vcProfiles.newBadge")})]}),l.isNew?(0,a.jsx)("em",{children:t("settings.vcProfiles.newBadge")}):null]}),(0,a.jsx)("p",{children:(l.instructions??"").trim()||t("settings.vcProfiles.noInstructions")}),(0,a.jsxs)("div",{className:"vc-profile-summary-meta",children:[(0,a.jsx)("span",{children:l.responseMode==="listener_thread"?t("settings.vcProfiles.responseListener"):t("settings.vcProfiles.responseSilent")}),(0,a.jsx)("span",{children:t(`settings.vcProfiles.preset.${l.permissionPreset}`)})]}),(0,a.jsxs)("label",{className:"vc-profile-default-toggle",onClick:d=>d.stopPropagation(),children:[(0,a.jsx)("input",{type:"radio",name:"vc-profile-default",checked:r,disabled:q||!l.id,onChange:()=>ce(l),onClick:()=>{r&&ce(l)}}),(0,a.jsx)("span",{children:t("settings.vcProfiles.setDefault")})]})]},l.uiKey)})}):(0,a.jsx)("p",{className:"vc-profile-empty",children:t("settings.vcProfiles.list.empty")}),(0,a.jsx)("p",{className:"hint vc-profile-default-single",children:t("settings.vcProfiles.defaultSingleHint")})]}),o.templateCatalog.templates.length>0?(0,a.jsxs)("section",{className:"vc-profile-template-catalog",children:[(0,a.jsxs)("div",{className:"vc-profile-template-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.templates.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.templates.help")})]}),(0,a.jsx)("span",{children:t("settings.vcProfiles.templates.builtinBadge")})]}),(0,a.jsx)("div",{className:"vc-profile-template-grid",children:o.templateCatalog.templates.map(l=>(0,a.jsxs)("button",{type:"button",className:"vc-profile-template-card",onClick:()=>J(l.templateId),children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"\u2726"}),(0,a.jsx)("strong",{children:l.title[i]}),(0,a.jsx)("p",{children:l.description[i]}),(0,a.jsxs)("em",{children:[t("settings.vcProfiles.viewDetails")," \u2192"]})]},`${l.templateId}@${l.version}`))})]}):null,(0,a.jsxs)("section",{className:"vc-profile-library-section vc-bot-policy-section",children:[(0,a.jsxs)("div",{className:"vc-profile-list-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.botPolicies.title")}),(0,a.jsx)("p",{children:t("settings.vcProfiles.botPolicies.help")})]}),(0,a.jsx)("input",{type:"search",className:"vc-bot-policy-search",placeholder:t("settings.vcProfiles.botPolicies.searchPlaceholder"),value:z,disabled:q,onChange:l=>Oe(l.target.value)})]}),(0,a.jsxs)("div",{className:"vc-bot-policy-table",style:{maxHeight:320,overflowY:"auto"},children:[Ne.length===0?(0,a.jsx)("p",{className:"vc-bot-policy-empty hint",children:t("settings.vcProfiles.botPolicies.noMatch")}):null,Ne.map(l=>{let r=l.textOutputPolicy??"allow",d=l.realtimeVoiceEnabled?l.voiceOutputPolicy??"allow":"deny",m=w=>t(`settings.vcProfiles.botPolicies.${w}`),T=[l.vcEligible?void 0:t("settings.vcProfiles.botPolicies.vcIneligible"),l.online?void 0:t("settings.vcProfiles.agentOffline"),l.workingDirReady?void 0:t("settings.vcProfiles.agentNoWorkingDir"),l.reliableTurnTerminal?void 0:t("settings.vcProfiles.agentNoReliableTerminal"),l.managedSideEffectEligible?void 0:t("settings.vcProfiles.agentNoManagedIsolation"),l.managedSideEffectEligible&&!l.sandboxIsolated?t("settings.vcProfiles.agentUnsandboxedRisk"):void 0].filter(w=>!!w),F=!e.canWrite||C||N,Ce=(w,Y)=>(0,a.jsxs)("select",{className:"vc-bot-policy-select",value:Y??"default",disabled:F||!l.vcEnabled,onChange:$e=>{let Se=$e.target.value;se(l.appId,{[w]:Se==="default"?null:Se})},children:[(0,a.jsx)("option",{value:"default",children:t("settings.vcProfiles.botPolicies.default")}),(0,a.jsx)("option",{value:"allow",children:m("allow")}),(0,a.jsx)("option",{value:"approval",children:m("approval")}),(0,a.jsx)("option",{value:"deny",children:m("deny")})]}),de=fe[l.appId];return(0,a.jsxs)("div",{className:"vc-bot-policy-row",children:[(0,a.jsxs)("span",{className:"vc-bot-policy-name",title:l.appId,children:[l.online?"":"\u26AA ",l.label,T.length>0?(0,a.jsx)(De,{className:"vc-bot-policy-warn-tip",label:T.join(" \xB7 "),trigger:(0,a.jsx)("em",{className:"vc-bot-policy-warn","aria-hidden":"true",children:"\u26A0"}),children:(0,a.jsx)("span",{className:"vc-bot-policy-warn-pop",children:T.map((w,Y)=>(0,a.jsx)("div",{children:w},Y))})}):null,de?(0,a.jsx)("em",{className:de.ok?"vc-bot-policy-preflight":"vc-bot-policy-warn",children:de.text}):null]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell vc-bot-policy-enabled",children:[(0,a.jsx)("input",{type:"checkbox",checked:l.vcEnabled,disabled:F||!l.vcEligible,onChange:w=>se(l.appId,{vcEnabled:w.target.checked})}),(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.vcEnabled")})]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.defaultProfile")}),(0,a.jsxs)("select",{className:"vc-bot-policy-select",value:l.catalogDefaultConsumerId??"",disabled:F||!l.vcEnabled,onChange:w=>{let Y=w.target.value;se(l.appId,{catalogDefaultConsumerId:Y===""?null:Y})},children:[(0,a.jsx)("option",{value:"",children:t("settings.vcProfiles.botPolicies.defaultProfileFollowGlobal")}),o.profiles.map(w=>(0,a.jsx)("option",{value:w.id,children:w.label||w.id},w.id))]})]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.text")}),Ce("textOutputPolicy",l.textOutputPolicy)]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell",children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.voice")}),Ce("voiceOutputPolicy",l.voiceOutputPolicy)]}),(0,a.jsxs)("label",{className:"vc-bot-policy-cell vc-bot-policy-rtv",children:[(0,a.jsx)("input",{type:"checkbox",checked:l.realtimeVoiceEnabled,disabled:F||!l.vcEnabled,onChange:w=>se(l.appId,{realtimeVoiceEnabled:w.target.checked})}),(0,a.jsx)("span",{children:t("settings.vcProfiles.botPolicies.realtimeVoice")})]}),(0,a.jsxs)("span",{className:"vc-bot-policy-effective hint",children:[t("settings.vcProfiles.botPolicies.effective")," ",l.vcEnabled?`${m(r)} / ${m(d)}`:t("settings.vcProfiles.botPolicies.vcOff")]}),(0,a.jsx)("button",{type:"button",className:"bd-btn bd-btn-ghost vc-bot-policy-preflight-btn",disabled:!e.canWrite||!l.vcEligible||_!==null,title:t("settings.vcProfiles.botPolicies.preflightHelp"),onClick:()=>{D(l.appId)},children:_===l.appId?t("settings.vcProfiles.botPolicies.preflightRunning"):t("settings.vcProfiles.botPolicies.preflight")})]},l.appId)})]})]}),(0,a.jsxs)("div",{className:"settings-field-row vc-profile-default-mode-row",children:[(0,a.jsx)(A,{help:t("settings.vcProfiles.defaultModeHelp"),children:t("settings.vcProfiles.defaultMode")}),(0,a.jsx)($,{className:"settings-field-menu",ariaLabel:t("settings.vcProfiles.defaultMode"),disabled:q,value:o.defaultMode,label:o.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:l=>E(r=>({...r,defaultMode:l==="agents"?"agents":"listenOnly"}))})]}),W("defaultConsumerIds")?(0,a.jsx)("em",{className:"vc-profile-err",children:W("defaultConsumerIds")}):null,W("defaultMode")?(0,a.jsx)("em",{className:"vc-profile-err",children:W("defaultMode")}):null,e.canWrite?(0,a.jsxs)("div",{className:"vc-profiles-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-save",disabled:!k||C||j,onClick:()=>{L()},children:t(C?"settings.vcProfiles.saving":"settings.vcProfiles.save")}),M?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.saved")}):null,k&&!C?(0,a.jsx)("span",{className:"vc-profile-hint",children:t("settings.vcProfiles.unsaved")}):null]}):null,H?(0,a.jsx)(ct,{profile:H,index:ve,frozen:q,canWrite:e.canWrite,presetOptions:me(H),error:W,onClose:()=>Z(null),onUpdate:l=>we(H.uiKey,l),onIdChange:l=>{let r=H.id;E(d=>{let m=d.defaultConsumerIds.map(T=>T===r&&r?l:T).filter(Boolean);return{...d,profiles:d.profiles.map(T=>T.uiKey===H.uiKey?{...T,id:l}:T),defaultConsumerIds:m,defaultMode:m.length>0?d.defaultMode:"listenOnly"}})},onRemove:()=>Pe(H.uiKey)}):null,re?(0,a.jsx)(dt,{template:re,locale:i,disabled:q,onClose:()=>J(null),onUse:()=>Re(re)}):null]}):null]})}function Qe(e){let t=Array.isArray(e.agentOptions)?e.agentOptions:[];return{revision:e.revision,catalogState:e.catalogState==="explicit_empty"||e.catalogState==="profiles"?e.catalogState:"uninitialized",defaultMode:e.defaultMode==="agents"?"agents":"listenOnly",defaultConsumerIds:Array.isArray(e.defaultConsumerIds)?e.defaultConsumerIds:[],profiles:(Array.isArray(e.profiles)?e.profiles:[]).map(lt),agentOptions:t,botPolicies:at(t),templateCatalog:e.templateCatalog?.schemaVersion===1&&Array.isArray(e.templateCatalog.templates)?e.templateCatalog:{schemaVersion:1,templates:[]}}}function ct(e){let t=O(),{profile:i,index:s}=e;return(0,a.jsxs)(qe,{className:"vc-profile-editor-dialog",eyebrow:t("settings.vcProfiles.list.title"),title:i.label||i.id||t("settings.vcProfiles.untitled"),onClose:e.onClose,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)(ee,{title:t("settings.vcProfiles.fieldId"),help:t("settings.vcProfiles.idHelp")})}),(0,a.jsx)("input",{type:"text",value:i.id,disabled:e.frozen||!i.isNew,placeholder:"minutes",onChange:o=>e.onIdChange(o.currentTarget.value)}),e.error(`profiles[${s}].id`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].id`)}):null]}),(0,a.jsxs)("label",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldLabel"),help:t("settings.vcProfiles.labelHelp")})}),(0,a.jsx)("input",{type:"text",value:i.label??"",disabled:e.frozen,onChange:o=>e.onUpdate({label:o.currentTarget.value||void 0})}),e.error(`profiles[${s}].label`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].label`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldResponseMode"),help:t("settings.vcProfiles.responseModeHelp")})}),(0,a.jsx)($,{ariaLabel:t("settings.vcProfiles.fieldResponseMode"),disabled:e.frozen,value:i.responseMode,label:i.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:o=>e.onUpdate({responseMode:o})}),e.error(`profiles[${s}].responseMode`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].responseMode`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldListenerPlacement"),help:t("settings.vcProfiles.listenerPlacementHelp")})}),(0,a.jsx)($,{ariaLabel:t("settings.vcProfiles.fieldListenerPlacement"),disabled:e.frozen||i.responseMode==="silent",value:i.listenerPlacement??"auto",label:t(`settings.vcProfiles.listenerPlacement.${i.listenerPlacement??"auto"}`),options:["auto","chat","topic"].map(o=>({value:o,label:t(`settings.vcProfiles.listenerPlacement.${o}`)})),onChange:o=>e.onUpdate({listenerPlacement:o})}),e.error(`profiles[${s}].listenerPlacement`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].listenerPlacement`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldPreset"),help:t("settings.vcProfiles.presetHelp")})}),(0,a.jsx)($,{ariaLabel:t("settings.vcProfiles.fieldPreset"),disabled:e.frozen,value:i.permissionPreset,label:K(e.presetOptions,i.permissionPreset),options:e.presetOptions,onChange:o=>e.onUpdate({permissionPreset:o})}),e.error(`profiles[${s}].permissionPreset`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].permissionPreset`)}):null]})]}),(0,a.jsxs)("label",{className:"vc-profile-field vc-profile-instructions",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldInstructions"),help:t("settings.vcProfiles.instructionsHelp")}),(0,a.jsxs)("em",{className:"vc-profile-count",children:[(i.instructions??"").length,"/",Ee]})]}),(0,a.jsx)("textarea",{rows:7,maxLength:Ee,value:i.instructions??"",disabled:e.frozen,placeholder:t("settings.vcProfiles.instructionsPlaceholder"),onChange:o=>e.onUpdate({instructions:o.currentTarget.value||void 0})}),e.error(`profiles[${s}].instructions`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].instructions`)}):null]}),(0,a.jsxs)("div",{className:"vc-profile-field",children:[(0,a.jsx)("span",{children:(0,a.jsx)(ee,{title:t("settings.vcProfiles.fieldActivityTypes"),help:t("settings.vcProfiles.activityHelp")})}),(0,a.jsx)("div",{className:"vc-profile-activity",children:tt.map(o=>{let u=i.activityTypes?.includes(o)??!1;return(0,a.jsxs)("label",{className:"vc-profile-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:u,disabled:e.frozen,onChange:p=>{let h=new Set(i.activityTypes??[]);p.currentTarget.checked?h.add(o):h.delete(o),e.onUpdate({activityTypes:h.size>0?[...h]:void 0})}}),t(`settings.vcProfiles.activity.${o}`)]},o)})}),(0,a.jsx)("em",{className:"vc-profile-hint",children:t("settings.vcProfiles.activityAllHint")}),e.error(`profiles[${s}].activityTypes`)?(0,a.jsx)("em",{className:"vc-profile-err",children:e.error(`profiles[${s}].activityTypes`)}):null]}),e.canWrite?(0,a.jsxs)("footer",{className:"vc-profile-dialog-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profiles-link vc-profile-remove",disabled:e.frozen,onClick:e.onRemove,children:t("settings.vcProfiles.remove")}),(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-done",onClick:e.onClose,children:t("settings.vcProfiles.done")})]}):null]})}function dt(e){let t=O(),i=e.template;return(0,a.jsxs)(qe,{className:"vc-profile-template-dialog",eyebrow:t("settings.vcProfiles.templates.title"),title:i.title[e.locale],onClose:e.onClose,children:[(0,a.jsx)("p",{className:"vc-profile-template-description",children:i.description[e.locale]}),(0,a.jsxs)("div",{className:"vc-profile-template-facts",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldResponseMode")}),(0,a.jsx)("strong",{children:t(i.responseMode==="listener_thread"?"settings.vcProfiles.responseListener":"settings.vcProfiles.responseSilent")})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldListenerPlacement")}),(0,a.jsx)("strong",{children:t(`settings.vcProfiles.listenerPlacement.${i.listenerPlacement}`)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:t("settings.vcProfiles.fieldPreset")}),(0,a.jsx)("strong",{children:t(`settings.vcProfiles.preset.${i.permissionPreset}`)})]})]}),(0,a.jsxs)("section",{className:"vc-profile-template-prompt",children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.fieldInstructions")}),(0,a.jsx)("p",{children:i.instructions[e.locale]})]}),(0,a.jsxs)("section",{className:"vc-profile-template-events",children:[(0,a.jsx)("strong",{children:t("settings.vcProfiles.fieldActivityTypes")}),(0,a.jsx)("div",{children:i.activityTypes.map(s=>(0,a.jsx)("span",{children:t(`settings.vcProfiles.activity.${s}`)},s))})]}),(0,a.jsxs)("footer",{className:"vc-profile-dialog-actions",children:[(0,a.jsx)("button",{type:"button",className:"vc-profile-dialog-secondary",onClick:e.onClose,children:t("settings.vcProfiles.close")}),(0,a.jsx)("button",{type:"button",className:"vc-profile-template-use",disabled:e.disabled,onClick:e.onUse,children:t("settings.vcProfiles.templates.use")})]})]})}var n=ue(Te(),1),Ue=["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 Je(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return typeof t.supported=="boolean"&&typeof t.enabled=="boolean"?{supported:t.supported,enabled:t.enabled}:null}function ut(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 Be(e){return{groupNamePrefix:typeof e?.groupNamePrefix=="string"?e.groupNamePrefix:"",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:""},codexRpcInput:e?.codexRpcInput===!0,bypassCodexHookTrust:e?.bypassCodexHookTrust!==!1,codexNotifier:{enabled:e?.codexNotifier?.enabled===!0,targetBotAppId:typeof e?.codexNotifier?.targetBotAppId=="string"?e.codexNotifier.targetBotAppId:null,notifyWhen:e?.codexNotifier?.notifyWhen==="always"?"always":"locked_only",platformSupported:e?.codexNotifier?.platformSupported===!0,hookInstalled:e?.codexNotifier?.hookInstalled===!0,botOptions:Array.isArray(e?.codexNotifier?.botOptions)?e.codexNotifier.botOptions:[],targetDaemonOnline:e?.codexNotifier?.targetDaemonOnline===!0,pendingCount:Number.isSafeInteger(e?.codexNotifier?.pendingCount)?Math.max(0,e.codexNotifier.pendingCount):0,workerOnline:e?.codexNotifier?.workerOnline===!0,lastError:e?.codexNotifier?.lastError&&typeof e.codexNotifier.lastError.message=="string"?e.codexNotifier.lastError:null},hostOverloadAlert:{enabled:e?.hostOverloadAlert?.enabled===!0,targetBotAppId:typeof e?.hostOverloadAlert?.targetBotAppId=="string"?e.hostOverloadAlert.targetBotAppId:null,enterLoadRatio:typeof e?.hostOverloadAlert?.enterLoadRatio=="number"?e.hostOverloadAlert.enterLoadRatio:1.5,enterMemUsedFrac:typeof e?.hostOverloadAlert?.enterMemUsedFrac=="number"?e.hostOverloadAlert.enterMemUsedFrac:.92,botOptions:Array.isArray(e?.hostOverloadAlert?.botOptions)?e.hostOverloadAlert.botOptions:[],targetDaemonOnline:e?.hostOverloadAlert?.targetDaemonOnline===!0},noVisibleOutputHint:e?.noVisibleOutputHint===!0,vcMeetingAgent:{enabled:e?.vcMeetingAgent?.enabled!==!1,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},workflow:{enabled:e?.workflow?.enabled===!0},remoteAccess:e?.remoteAccess===!0,oauthRedirectBase:typeof e?.oauthRedirectBase=="string"?e.oauthRedirectBase:"",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 gt(e,t){let i=e?.[t]??{};return{enabled:i.enabled===!0,time:typeof i.time=="string"?i.time:"04:00"}}function Ye(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 ft(){let e=O(),t=(0,g.useRef)(!1),i=(0,g.useRef)(new Set),[s,o]=(0,g.useState)(null),[u,p]=(0,g.useState)(!1),[h,N]=(0,g.useState)(null),[R,k]=(0,g.useState)(!0),[b,C]=(0,g.useState)(!1),[te,j]=(0,g.useState)(null),[Q,c]=(0,g.useState)(null),[v,M]=(0,g.useState)(null),[ne,ie]=(0,g.useState)(null),[Z,ae]=(0,g.useState)(null),[J,_]=(0,g.useState)(null),[ge,fe]=(0,g.useState)(!1),[le,z]=(0,g.useState)(!0),[Oe,X]=(0,g.useState)(!1),[pe,E]=(0,g.useState)(""),[we,L]=(0,g.useState)(!1),[se,D]=(0,g.useState)(null),[me,oe]=(0,g.useState)(null),[Re,Pe]=(0,g.useState)(!1),[Ne,W]=(0,g.useState)(!1),[q,ke]=(0,g.useState)(!1),[ve,H]=(0,g.useState)(null),re=(0,g.useCallback)(()=>{for(let f of i.current)window.clearTimeout(f);i.current.clear()},[]),ce=(0,g.useCallback)((f,y)=>{let x=window.setTimeout(()=>{i.current.delete(x),f()},y);return i.current.add(x),x},[]),l=(0,g.useCallback)(async()=>{try{let f=await fetch("/api/update/status"),y=await f.json().catch(()=>({}));if(!t.current)return;if(!f.ok){ie(null),ae(y?.error??`HTTP ${f.status}`);return}ie(y),ae(null)}catch(f){if(!t.current)return;ie(null),ae(f instanceof Error?f.message:String(f))}},[]),r=(0,g.useCallback)(async()=>{Pe(!0);try{let f=await fetch("/api/autostart",{cache:"no-store"}),y=await f.json().catch(()=>({})),x=f.ok?Je(y.state):null;if(!x)throw new Error("invalid_state");if(!t.current)return;oe(x),W(!1)}catch{if(!t.current)return;W(!0)}finally{t.current&&Pe(!1)}},[]),d=(0,g.useCallback)(async()=>{try{let f=await fetch("/api/settings"),y=await f.json().catch(()=>({}));if(!t.current)return;if(!f.ok){o(null),N(y?.error??`HTTP ${f.status}`),p(!0);return}o(Be(y.settings)),k(y.authed===!0),C(y.bound===!0),N(null),p(!0)}catch(f){if(!t.current)return;o(null),N(f instanceof Error?f.message:String(f)),p(!0)}},[]);(0,g.useEffect)(()=>(t.current=!0,d(),()=>{t.current=!1,re()}),[re,d]),(0,g.useEffect)(()=>{u&&(L(!1),D(null),fe(!1),H(null),R&&(l(),r()))},[R,r,l,u]);async function m(f){if(!me||q)return;let y=me;ke(!0),oe({...y,enabled:f}),H({text:e("settings.autostartSaving")});try{let x=await fetch("/api/autostart",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:f})}),U=await x.json().catch(()=>({})),S=x.ok?Je(U.state):null;if(!S)throw new Error("save_failed");if(!t.current)return;oe(S),H({text:e("settings.autostartSaved"),cls:"hint-ok"})}catch{if(!t.current)return;oe(y),H({text:e("settings.autostartSaveFailed"),cls:"hint-warn-inline"}),r()}finally{t.current&&ke(!1)}}async function T(f,y,x){if(!s)return;let U=s;o(x(s)),j(f),c({text:e("settings.saving")});try{let S=await fetch("/api/settings",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(y)}),V=await S.json().catch(()=>({}));if(!t.current)return;if(!S.ok||V.ok===!1)throw typeof V?.feishuLoginQr=="string"&&V.feishuLoginQr&&M(V.feishuLoginQr),new Error(V?.error??`HTTP ${S.status}`);M(null);let G=Be(V.settings);o(G),Ie.publicReadOnly=G.publicReadOnly,Ae.setScheduleTimeZone(G.effectiveScheduleTimeZone);let be=ut(V.herdrTraexInstall,e);c(be??{text:e("settings.saved"),cls:"hint-ok"}),be||ce(()=>{t.current&&c(null)},1500)}catch(S){if(!t.current)return;let V=!1;try{let be=await fetch("/api/settings"),Fe=await be.json().catch(()=>({}));if(t.current&&be.ok&&Fe?.settings){let Me=Be(Fe.settings);o(Me),Ie.publicReadOnly=Me.publicReadOnly,Ae.setScheduleTimeZone(Me.effectiveScheduleTimeZone),V=!0}}catch{}if(!t.current)return;V||o(U);let G=S instanceof Error?S.message:String(S);c({text:V?`${e("settings.saveReconciled")}: ${G}`:`${e("settings.saveFailed")}: ${G}`,cls:"hint-warn-inline"})}finally{t.current&&j(null)}}async function F(){_(null),z(!0),X(!1);try{let f=await fetch("/api/update/changelog"),y=await f.json().catch(()=>({}));if(!t.current)return;E(typeof y?.releasesUrl=="string"?y.releasesUrl:""),f.ok?(_(Array.isArray(y.releases)?y.releases:[]),z(y.ok!==!1),X(y.rateLimited===!0)):(_([]),z(!1))}catch{if(!t.current)return;_([]),z(!1)}}function Ce(){let f=Date.now(),y=async()=>{if(t.current){if(Date.now()-f>9e4){L(!1),D({text:e("update.restartSlow"),cls:"hint-warn-inline"});return}try{let x=await fetch("/__health",{cache:"no-store"});if(!t.current)return;if(x.ok){location.reload();return}}catch{}t.current&&ce(()=>{y()},2e3)}};ce(()=>{y()},3e3)}async function de(f){L(!0),D({text:e("update.restarting")});try{let y=await fetch("/api/update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(f?{update:f}:{})}),x=await y.json().catch(()=>({}));if(!y.ok||x.ok===!1){if(x.error==="update_target_unavailable"||x.error==="update_target_drifted"){if(!t.current)return;L(!1),D({text:e(`update.${x.error}`,{dir:String(x.dir??"")}),cls:"hint-warn-inline"}),l();return}throw new Error(String(x.detail??x.error??`HTTP ${y.status}`))}if(!t.current)return}catch(y){if(!t.current)return;L(!1),D({text:e("update.restartFailed",{detail:y instanceof Error?y.message:String(y)}),cls:"hint-warn-inline"});return}Ce()}async function w(){let f=ne;if(!f)return;if(!f.node.ok){xe(e("update.nodeTooOldAlert",{version:f.node.version,required:f.node.required}),{kind:"warning"});return}let y=f.localDevInstall===!0;if(y){if(!f.localDevUpdatable){xe(e("update.localDev"),{kind:"warning"});return}}else if(!f.updateSupported||!f.updateCommand){xe(e("update.unsupportedInstall"),{kind:"warning"});return}if(f.installs.multiple){let U=f.installs.entries.map(S=>`\u2022 ${S.binPath} (${Ye(S.kind,e)})`).join(`
|
|
2
2
|
`);if(!await ye({title:e("update.confirmMultiInstallTitle"),message:e("update.confirmMultiInstall",{paths:U}),confirmLabel:e("update.btnContinue"),cancelLabel:e("update.btnCancel")}))return}let x=y?e("update.confirmUpdateLocalDev"):f.latest?e("update.confirmUpdate",{version:`v${f.latest}`,command:f.updateCommand}):e("update.confirmUpdateNoVer",{command:f.updateCommand});if(await ye({title:e("update.confirmUpdateTitle"),message:x,confirmLabel:e("update.btnRunUpdate"),cancelLabel:e("update.btnCancel")})){L(!0),D({text:y?e("update.updatingLocalDev"):e("update.updating",{command:f.updateCommand})});try{let U=await fetch("/api/update/run",{method:"POST"}),S=await U.json().catch(()=>({}));if(!t.current)return;if(!U.ok||S.ok===!1){if(S?.error==="dirty_worktree"){L(!1),D({text:e("update.dirtyWorktree",{detail:String(S.detail??"")}),cls:"hint-warn-inline"});return}let G=S?.detail??S?.error??`HTTP ${U.status}`;L(!1),D({text:e("update.updateFailed",{detail:G}),cls:"hint-warn-inline"});return}Ke(S)?(L(!1),D({text:S.changed?e("update.updatedChanged",{old:`v${S.oldVersion}`,new:`v${S.newVersion}`}):e("update.builtNeedsRestart"),cls:"hint-ok"}),await ye({title:e("update.confirmRestartTitle"),message:e("update.confirmRestart"),confirmLabel:e("update.btnRestartNow"),cancelLabel:e("update.btnLater")})?await de({oldVersion:S.oldVersion,newVersion:S.newVersion}):t.current&&D({text:e("update.noRestartHint"),cls:"hint-ok"})):(L(!1),D({text:e("update.alreadyLatestRun",{version:`v${S.newVersion}`}),cls:"hint-ok"}),await l())}catch(U){if(!t.current)return;L(!1),D({text:e("update.updateFailed",{detail:U instanceof Error?U.message:String(U)}),cls:"hint-warn-inline"})}}}let Se=s?(0,n.jsx)(pt,{settings:s,canWrite:R,bound:b,savingKey:te,message:Q,autostartBlock:(0,n.jsx)(St,{canWrite:R,state:me,loading:Re,error:Ne,busy:q,message:ve,onChange:f=>{m(f)},onRetry:()=>{r()}}),updateBlock:(0,n.jsx)(Tt,{canWrite:R,status:ne,statusError:Z,changelog:J,changelogOpen:ge,changelogOk:le,changelogRateLimited:Oe,releasesUrl:pe,busy:we,message:se,onCheck:()=>{ie(null),_(null),fe(!1),D(null),ae(null),l()},onToggleChangelog:()=>{let f=!ge;fe(f),f&&J===null&&F()},onUpdate:()=>{w()},onRestart:()=>{(async()=>await ye({title:e("update.confirmRestartTitle"),message:e("update.confirmPlainRestart"),confirmLabel:e("update.btnRestartNow"),cancelLabel:e("update.btnCancel")})&&de(null))()}}),feishuLoginQr:v,onCloseFeishuLoginQr:()=>M(null),onFeishuLoginQr:M,onSave:T}):h?(0,n.jsxs)("p",{className:"hint-warn",children:[e("settings.loadFailed"),": ",h]}):(0,n.jsx)(he,{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")})]})}),Se]})}function pt(e){let t=O(),{settings:i,canWrite:s,bound:o,savingKey:u}=e,p=!s,h=gt(i.maintenance,"autoUpdate"),N=!s||i.localDevInstall||!i.autoUpdateSupported,R=!s||i.maintenance.autoUpdate?.enabled!==!0,k=(c,v)=>{e.onSave(c,{[c]:v},M=>({...M,[c]:v}))},b=c=>e.onSave("herdrTraexPlugin",{herdrTraexPlugin:c},v=>({...v,herdrTraexPlugin:{...v.herdrTraexPlugin,...c}})),C=c=>e.onSave("codexNotifier",{codexNotifier:c},v=>({...v,codexNotifier:{...v.codexNotifier,...c}})),te=c=>e.onSave("hostOverloadAlert",{hostOverloadAlert:c},v=>({...v,hostOverloadAlert:{...v.hostOverloadAlert,...c}})),j=(0,g.useMemo)(()=>[{value:"all",label:t("settings.repoPickerModeAll")},{value:"repos",label:t("settings.repoPickerModeRepos")}],[t]),Q=(0,g.useMemo)(()=>[{value:"attach",label:t("settings.localCliOpenModeAttach")},{value:"resume",label:t("settings.localCliOpenModeResume")}],[t]);return(0,n.jsxs)("div",{className:"settings-layout",children:[(0,n.jsx)(mt,{tr:t}),(0,n.jsxs)("div",{className:"settings-content",children:[s?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.jsx)(He,{title:t("settings.moduleGeneral"),description:t("settings.moduleGeneralHelp"),children:(0,n.jsxs)(Ve,{className:"settings-group-main",children:[(0,n.jsxs)(B,{id:"settings-access",title:t("settings.sectionAccess"),children:[(0,n.jsx)(I,{title:t("settings.publicReadOnly"),help:t("settings.publicReadOnlyHelp"),checked:i.publicReadOnly,disabled:p||u==="publicReadOnly",onChange:c=>k("publicReadOnly",c)}),o?(0,n.jsx)(I,{title:t("settings.remoteAccess"),help:t("settings.remoteAccessHelp"),checked:i.remoteAccess,disabled:p||u==="remoteAccess",onChange:c=>k("remoteAccess",c)}):null,(0,n.jsx)(kt,{value:i.oauthRedirectBase,disabled:p||u==="oauthRedirectBase",onSave:c=>e.onSave("oauthRedirectBase",{oauthRedirectBase:c},v=>({...v,oauthRedirectBase:c}))})]}),(0,n.jsxs)(B,{id:"settings-cards",title:t("settings.sectionCards"),children:[(0,n.jsx)(I,{title:t("settings.openTerminalInFeishu"),help:t("settings.openTerminalInFeishuHelp"),checked:i.openTerminalInFeishu,disabled:p||u==="openTerminalInFeishu",onChange:c=>k("openTerminalInFeishu",c)}),(0,n.jsx)(I,{title:t("settings.enableLocalCliOpen"),help:t("settings.enableLocalCliOpenHelp"),checked:i.enableLocalCliOpen,disabled:p||u==="enableLocalCliOpen",onChange:c=>k("enableLocalCliOpen",c)}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.localCliOpenModeHelp"),children:t("settings.localCliOpenMode")}),(0,n.jsx)($,{className:"settings-field-menu",ariaLabel:t("settings.localCliOpenMode"),disabled:p||!i.enableLocalCliOpen||u==="localCliOpenMode",value:i.localCliOpenMode,label:K(Q,i.localCliOpenMode),options:Q,onChange:c=>{e.onSave("localCliOpenMode",{localCliOpenMode:c},v=>({...v,localCliOpenMode:c}))}})]})]}),(0,n.jsx)(B,{id:"settings-group-creation",title:t("settings.sectionGroupCreation"),children:(0,n.jsx)(Nt,{value:i.groupNamePrefix,disabled:p||u==="groupNamePrefix",onSave:c=>e.onSave("groupNamePrefix",{groupNamePrefix:c},v=>({...v,groupNamePrefix:c}))})}),(0,n.jsxs)(B,{id:"settings-experimental",title:t("settings.sectionExperimental"),children:[(0,n.jsx)(I,{title:t("settings.chatBotDiscovery"),help:t("settings.chatBotDiscoveryHelp"),checked:i.chatBotDiscovery,disabled:p||u==="chatBotDiscovery",onChange:c=>k("chatBotDiscovery",c)}),(0,n.jsx)(I,{title:t("settings.herdrTraexPlugin"),help:t("settings.herdrTraexPluginHelp"),checked:i.herdrTraexPlugin.enabled,disabled:p||u==="herdrTraexPlugin",onChange:c=>b({enabled:c})}),i.herdrTraexPlugin.enabled?(0,n.jsx)(Ct,{value:i.herdrTraexPlugin,disabled:p||u==="herdrTraexPlugin",onSave:c=>b(c)}):null,(0,n.jsx)(I,{title:t("settings.codexRpcInput"),help:t("settings.codexRpcInputHelp"),checked:i.codexRpcInput,disabled:p||u==="codexRpcInput",onChange:c=>k("codexRpcInput",c)}),(0,n.jsx)(I,{title:t("settings.bypassCodexHookTrust"),help:t("settings.bypassCodexHookTrustHelp"),checked:i.bypassCodexHookTrust,disabled:p||u==="bypassCodexHookTrust",onChange:c=>k("bypassCodexHookTrust",c)}),(0,n.jsx)(bt,{value:i.codexNotifier,disabled:p,saving:u==="codexNotifier",onSave:C}),(0,n.jsx)(I,{title:t("settings.noVisibleOutputHint"),help:t("settings.noVisibleOutputHintHelp"),checked:i.noVisibleOutputHint,disabled:p||u==="noVisibleOutputHint",onChange:c=>k("noVisibleOutputHint",c)})]}),(0,n.jsx)(B,{id:"settings-overload",title:t("settings.sectionHostOverloadAlert"),children:(0,n.jsx)(ht,{value:i.hostOverloadAlert,disabled:p,saving:u==="hostOverloadAlert",onSave:te})}),(0,n.jsx)(B,{id:"settings-whiteboard",title:t("settings.sectionWhiteboard"),children:(0,n.jsx)(I,{title:t("settings.whiteboardEnable"),help:t("settings.whiteboardEnableHelp"),checked:i.whiteboard.enabled,disabled:p||u==="whiteboard",onChange:c=>{e.onSave("whiteboard",{whiteboard:{enabled:c}},v=>({...v,whiteboard:{enabled:c}}))}})}),(0,n.jsx)(B,{title:t("settings.sectionWorkflow"),children:(0,n.jsx)(I,{title:t("settings.workflowEnable"),help:t("settings.workflowEnableHelp"),checked:i.workflow.enabled,disabled:p||u==="workflow",onChange:c=>{e.onSave("workflow",{workflow:{enabled:c}},v=>({...v,workflow:{enabled:c}}))}})}),(0,n.jsx)(B,{id:"settings-repo-picker",title:t("settings.sectionRepoPicker"),children:(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.repoPickerModeHelp"),children:t("settings.repoPickerMode")}),(0,n.jsx)($,{className:"settings-field-menu",ariaLabel:t("settings.repoPickerMode"),disabled:p||u==="repoPickerMode",value:i.repoPickerMode,label:K(j,i.repoPickerMode),options:j,onChange:c=>{e.onSave("repoPickerMode",{repoPickerMode:c},v=>({...v,repoPickerMode:c}))}})]})}),(0,n.jsx)(B,{id:"settings-schedule",title:t("settings.sectionSchedule"),children:(0,n.jsx)(yt,{value:i.scheduleTimeZone,host:i.hostTimeZone,effective:i.effectiveScheduleTimeZone,disabled:p||u==="scheduleTimeZone",onSave:c=>{e.onSave("scheduleTimeZone",{scheduleTimeZone:c},v=>({...v,scheduleTimeZone:c??""}))}})})]})}),(0,n.jsx)(He,{className:"settings-module-meeting",title:t("settings.moduleMeeting"),description:t("settings.moduleMeetingHelp"),children:(0,n.jsx)(Ve,{className:"settings-group-meeting",children:(0,n.jsxs)(B,{id:"settings-vc",className:"settings-vc-block",title:t("settings.sectionVcMeetingAgent"),children:[(0,n.jsx)(I,{title:t("settings.vcMeetingAgent"),help:t("settings.vcMeetingAgentHelp"),checked:i.vcMeetingAgent.enabled,disabled:p||u==="vcMeetingAgent",onChange:c=>{e.onSave("vcMeetingAgent",{vcMeetingAgent:{enabled:c}},v=>({...v,vcMeetingAgent:{...v.vcMeetingAgent,enabled:c}}))}}),(0,n.jsx)(vt,{settings:i.vcMeetingAgent}),(0,n.jsx)(Ge,{enabled:i.vcMeetingAgent.enabled,canWrite:s,onFeishuLoginQr:e.onFeishuLoginQr}),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.jsx)(He,{title:t("settings.moduleSystem"),description:t("settings.moduleSystemHelp"),children:(0,n.jsxs)(Ve,{className:"settings-group-ops",children:[e.autostartBlock,(0,n.jsx)(B,{id:"settings-maintenance",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)(I,{title:t("settings.autoUpdate"),help:t("settings.autoUpdateHelp"),checked:h.enabled,disabled:N||u==="autoUpdate",onChange:c=>{let v={enabled:c,time:h.time};e.onSave("autoUpdate",{maintenance:{autoUpdate:v}},M=>({...M,maintenance:{...M.maintenance,autoUpdate:v}}))}}),(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:h.time,disabled:N||u==="autoUpdate",onChange:c=>{let v={enabled:h.enabled,time:c.currentTarget.value||"04:00"};e.onSave("autoUpdate",{maintenance:{autoUpdate:v}},M=>({...M,maintenance:{...M.maintenance,autoUpdate:v}}))}})]})})]}),(0,n.jsx)("div",{className:"settings-maintenance-restart",children:(0,n.jsx)(I,{title:t("settings.autoRestart"),help:t("settings.autoRestartHelp"),checked:i.maintenance.autoRestart?.enabled===!0,disabled:R||u==="autoRestart",onChange:c=>{let v={enabled:c};e.onSave("autoRestart",{maintenance:{autoRestart:v}},M=>({...M,maintenance:{...M.maintenance,autoRestart:v}}))}})})]})}),(0,n.jsx)("div",{id:"settings-update",children: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 mt(e){let t=e.tr,i=[{label:t("settings.moduleGeneral"),items:[{id:"settings-access",label:t("settings.sectionAccess")},{id:"settings-cards",label:t("settings.sectionCards")},{id:"settings-group-creation",label:t("settings.sectionGroupCreation")},{id:"settings-experimental",label:t("settings.sectionExperimental")},{id:"settings-overload",label:t("settings.sectionHostOverloadAlert")},{id:"settings-whiteboard",label:t("settings.sectionWhiteboard")},{id:"settings-repo-picker",label:t("settings.sectionRepoPicker")},{id:"settings-schedule",label:t("settings.sectionSchedule")}]},{label:t("settings.moduleMeeting"),items:[{id:"settings-vc",label:t("settings.sectionVcMeetingAgent")}]},{label:t("settings.moduleSystem"),items:[{id:"settings-maintenance",label:t("settings.sectionMaintenance")},{id:"settings-update",label:t("settings.sectionUpdate")}]}];return(0,n.jsx)("nav",{className:"settings-nav","aria-label":t("settings.title"),children:i.map(s=>(0,n.jsxs)("div",{className:"settings-nav-group",children:[(0,n.jsx)("p",{className:"settings-nav-group-label",children:s.label}),s.items.map(o=>(0,n.jsx)("button",{type:"button",className:"settings-nav-link",onClick:()=>{document.getElementById(o.id)?.scrollIntoView({behavior:"smooth",block:"start"})},children:o.label},o.id))]},s.label))})}function He(e){let t=["settings-module",e.className].filter(Boolean).join(" ");return(0,n.jsxs)("section",{className:t,children:[(0,n.jsxs)("header",{className:"settings-module-heading",children:[(0,n.jsx)("h2",{children:e.title}),(0,n.jsx)("p",{children:e.description})]}),e.children]})}function vt(e){let t=O(),i=e.settings.larkCliVersion,s=typeof i=="string"&&e.settings.larkCliMeetsRequirement===!0,o=s?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 ${s?"is-ready":"is-warning"}`,children:[(0,n.jsx)("span",{"aria-hidden":"true"}),(0,n.jsx)("strong",{children:o}),s?null:(0,n.jsx)("code",{children:"npm i -g @larksuite/cli@latest"})]})}function Ve(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 B(e){let t=["settings-block",e.className].filter(Boolean).join(" ");return(0,n.jsx)("section",{className:t,id:e.id,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 bt(e){let t=O(),[i,s]=(0,g.useState)(!1),o=(0,g.useRef)(!1),u=(0,g.useMemo)(()=>[{value:"",label:t("settings.codexNotifierTargetPlaceholder")},...e.value.botOptions.map(C=>({value:C.larkAppId,label:[C.botName||C.larkAppId,C.cliId].filter(Boolean).join(" \xB7 ")}))],[e.value.botOptions,t]),p=(0,g.useMemo)(()=>[{value:"locked_only",label:t("settings.codexNotifierLockedOnly")},{value:"always",label:t("settings.codexNotifierAlways")}],[t]),h=e.value.botOptions.find(C=>C.larkAppId===e.value.targetBotAppId),N=!e.value.targetBotAppId||h?.recipientConfigured!==!0||h?.recipientVerified!==!0||!e.value.targetDaemonOnline||!e.value.platformSupported&&e.value.notifyWhen==="locked_only",R=e.value.enabled||i,k=e.disabled||e.saving;(0,g.useEffect)(()=>{if(!i||e.value.enabled||N){o.current=!1;return}k||o.current||(o.current=!0,e.onSave({enabled:!0}))},[k,N,i,e.onSave,e.value.enabled]),(0,g.useEffect)(()=>{e.value.enabled&&i&&s(!1)},[i,e.value.enabled]);let b=C=>{if(!C){o.current=!1,s(!1),e.value.enabled&&e.onSave({enabled:!1});return}if(N){s(!0);return}e.onSave({enabled:!0})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(I,{title:t("settings.codexNotifier"),help:t("settings.codexNotifierHelp"),checked:e.value.enabled||i,disabled:k,onChange:b}),R?(0,n.jsxs)("div",{className:"settings-codex-notifier-details",children:[e.value.enabled?null:(0,n.jsx)("p",{className:"settings-subfield-hint",children:t("settings.codexNotifierEnablePending")}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.codexNotifierTargetHelp"),children:t("settings.codexNotifierTarget")}),(0,n.jsx)($,{className:"settings-field-menu",ariaLabel:t("settings.codexNotifierTarget"),disabled:k,searchable:!0,value:e.value.targetBotAppId??"",label:K(u,e.value.targetBotAppId??""),options:u,onChange:C=>{e.onSave({targetBotAppId:C||null})}})]}),h?.recipientHint?(0,n.jsx)("p",{className:"settings-subfield-hint",children:t("settings.codexNotifierRecipient",{recipient:h.recipientHint})}):null,(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.codexNotifierNotifyWhenHelp"),children:t("settings.codexNotifierNotifyWhen")}),(0,n.jsx)($,{className:"settings-field-menu",ariaLabel:t("settings.codexNotifierNotifyWhen"),disabled:k,value:e.value.notifyWhen,label:K(p,e.value.notifyWhen),options:p,onChange:C=>{e.onSave({notifyWhen:C})}})]}),e.value.targetBotAppId?h?.recipientConfigured!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierRecipientMissing")}):e.value.targetDaemonOnline?h?.recipientVerified!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierRecipientUnverified")}):!e.value.platformSupported&&e.value.notifyWhen==="locked_only"?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierUnsupported")}):e.value.enabled?e.value.hookInstalled?e.value.workerOnline?e.value.lastError?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierLastError",{error:e.value.lastError.message})}):e.value.pendingCount>0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierPending",{count:e.value.pendingCount})}):null:(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierWorkerPending")}):(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierHookPending")}):null:(0,n.jsx)("p",{className:"hint-warn-inline",children:t(e.value.enabled?"settings.codexNotifierDaemonOffline":"settings.codexNotifierTargetOffline")}):(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.codexNotifierTargetRequired")})]}):null]})}function ht(e){let t=O(),i=e.disabled||e.saving,s=(0,g.useMemo)(()=>[{value:"",label:t("settings.hostOverloadAlertTargetPlaceholder")},...e.value.botOptions.map(b=>({value:b.larkAppId,label:[b.botName||b.larkAppId,b.cliId].filter(Boolean).join(" \xB7 ")}))],[e.value.botOptions,t]),o=e.value.botOptions.find(b=>b.larkAppId===e.value.targetBotAppId),[u,p]=(0,g.useState)(String(e.value.enterLoadRatio)),[h,N]=(0,g.useState)(String(Math.round(e.value.enterMemUsedFrac*100)));(0,g.useEffect)(()=>{p(String(e.value.enterLoadRatio))},[e.value.enterLoadRatio]),(0,g.useEffect)(()=>{N(String(Math.round(e.value.enterMemUsedFrac*100)))},[e.value.enterMemUsedFrac]);let R=()=>{let b=Number(u);Number.isFinite(b)&&b>0&&b!==e.value.enterLoadRatio?e.onSave({enterLoadRatio:b}):p(String(e.value.enterLoadRatio))},k=()=>{let b=Number(h),C=b/100;Number.isFinite(b)&&b>0&&b<=100&&C!==e.value.enterMemUsedFrac?e.onSave({enterMemUsedFrac:C}):N(String(Math.round(e.value.enterMemUsedFrac*100)))};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(I,{title:t("settings.hostOverloadAlert"),help:t("settings.hostOverloadAlertHelp"),checked:e.value.enabled,disabled:i||!e.value.enabled&&!e.value.targetBotAppId,onChange:b=>{e.onSave({enabled:b})}}),(0,n.jsxs)("div",{className:"settings-codex-notifier-details",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.hostOverloadAlertTargetHelp"),children:t("settings.hostOverloadAlertTarget")}),(0,n.jsx)($,{className:"settings-field-menu",ariaLabel:t("settings.hostOverloadAlertTarget"),disabled:i,searchable:!0,value:e.value.targetBotAppId??"",label:K(s,e.value.targetBotAppId??""),options:s,onChange:b=>{e.onSave({targetBotAppId:b||null})}})]}),o?.recipientHint?(0,n.jsx)("p",{className:"settings-subfield-hint",children:t("settings.hostOverloadAlertRecipient",{recipient:o.recipientHint})}):null,(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.hostOverloadAlertEnterLoadHelp"),children:t("settings.hostOverloadAlertEnterLoad")}),(0,n.jsx)("input",{type:"number",min:.1,step:.1,className:"settings-text-input",value:u,disabled:i,onChange:b=>p(b.currentTarget.value),onBlur:R,onKeyDown:b=>{b.key==="Enter"&&R()}})]}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.hostOverloadAlertEnterMemHelp"),children:t("settings.hostOverloadAlertEnterMem")}),(0,n.jsx)("input",{type:"number",min:1,max:100,step:1,className:"settings-text-input",value:h,disabled:i,onChange:b=>N(b.currentTarget.value),onBlur:k,onKeyDown:b=>{b.key==="Enter"&&k()}})]}),e.value.targetBotAppId?o?.recipientConfigured!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertRecipientMissing")}):e.value.targetDaemonOnline?o?.recipientVerified!==!0?(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertRecipientUnverified")}):null:(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertTargetOffline")}):(0,n.jsx)("p",{className:"hint-warn-inline",children:t("settings.hostOverloadAlertTargetRequired")})]})]})}function yt(e){let t=O(),i=e.value.trim(),s=e.effective||e.value.trim()||e.host,o=(0,g.useMemo)(()=>{let u=i&&!Ue.includes(i)?[i,...Ue]:Ue;return[{value:"",label:t("settings.scheduleTimeZoneHost",{host:e.host})},...u.map(p=>({value:p,label:p}))]},[e.host,t,i]);return(0,n.jsxs)("div",{className:"settings-field-row settings-timezone-row",children:[(0,n.jsx)(A,{help:t("settings.scheduleTimeZoneHelp",{host:e.host,effective:s}),children:t("settings.scheduleTimeZone")}),(0,n.jsx)($,{className:"settings-field-menu settings-timezone-menu",ariaLabel:t("settings.scheduleTimeZone"),value:i,label:K(o,i),options:o,disabled:e.disabled,onChange:u=>e.onSave(u===""?null:u)})]})}function I(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)(A,{className:"settings-toggle-title",help:e.help,children:e.title})})})]})}var Pt=32;function Nt(e){let t=O(),[i,s]=(0,g.useState)(e.value);(0,g.useEffect)(()=>s(e.value),[e.value]);let o=i.trim().length>0,u=i===""||o,p=i!==e.value,h=()=>{e.disabled||!p||!u||e.onSave(i)};return(0,n.jsxs)("div",{className:"settings-subfield settings-group-prefix-editor",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.groupNamePrefixHelp"),children:t("settings.groupNamePrefix")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:i,maxLength:Pt,placeholder:t("settings.groupNamePrefixPlaceholder"),disabled:e.disabled,onChange:N=>s(N.currentTarget.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),h())}})]}),(0,n.jsx)("p",{className:"settings-subfield-hint","data-group-name-prefix-preview":!0,children:o?t("settings.groupNamePrefixPreview",{name:`${i}${t("settings.groupNamePrefixPreviewName")}`}):t("settings.groupNamePrefixDisabled")}),(0,n.jsx)("div",{className:"actions",children:(0,n.jsx)("button",{type:"button",className:"page-primary-action",disabled:e.disabled||!p||!u,onClick:h,children:t("settings.groupNamePrefixSave")})})]})}function Xe(){try{if(typeof location>"u"||!location?.href)return"";let e=new URL(location.href).origin;return et(e)?e:""}catch{return""}}function et(e){let t=e.trim();if(!/^https?:\/\//i.test(t))return!1;try{let i=new URL(t.replace(/\/+$/,""));return i.protocol!=="http:"&&i.protocol!=="https:"||!i.hostname||i.username||i.password||i.search||i.hash?!1:i.pathname===""||i.pathname==="/"}catch{return!1}}function kt(e){let t=O(),[i,s]=(0,g.useState)(e.value);(0,g.useEffect)(()=>s(e.value),[e.value]);let o=i.trim().replace(/\/+$/,""),u=o===""||et(o),p=o!==e.value.trim().replace(/\/+$/,""),h=()=>{e.disabled||!p||!u||e.onSave(o)};return(0,n.jsxs)("div",{className:"settings-subfield settings-oauth-redirect-base-editor",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.oauthRedirectBaseHelp"),children:t("settings.oauthRedirectBase")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text","data-input":"oauthRedirectBase",value:i,placeholder:t("settings.oauthRedirectBasePlaceholder"),disabled:e.disabled,onChange:N=>s(N.currentTarget.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),h())}})]}),(0,n.jsx)("p",{className:"settings-subfield-hint","data-oauth-redirect-base-preview":!0,children:o===""?t("settings.oauthRedirectBaseUnset"):u?t("settings.oauthRedirectBasePreview",{url:`${o}/oauth/callback`}):t("settings.oauthRedirectBaseInvalid")}),(0,n.jsxs)("div",{className:"actions",children:[(0,n.jsx)("button",{type:"button","data-action":"oauth-redirect-base-use-current",disabled:e.disabled||!Xe(),onClick:()=>s(Xe()),children:t("settings.oauthRedirectBaseUseCurrent")}),(0,n.jsx)("button",{type:"button",className:"page-primary-action","data-action":"oauth-redirect-base-save",disabled:e.disabled||!p||!u,onClick:h,children:t("settings.oauthRedirectBaseSave")})]})]})}function Ct(e){let t=O(),[i,s]=(0,g.useState)(e.value.source),[o,u]=(0,g.useState)(e.value.ref);(0,g.useEffect)(()=>{s(e.value.source),u(e.value.ref)},[e.value.source,e.value.ref]);let p=i.trim(),h=o.trim(),N=p!==e.value.source.trim()||h!==e.value.ref.trim(),R=()=>{e.disabled||!N||e.onSave({source:p,ref:h})};return(0,n.jsxs)("div",{className:"settings-subfield",children:[(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{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=>s(k.currentTarget.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),R())}})]}),(0,n.jsxs)("div",{className:"settings-field-row",children:[(0,n.jsx)(A,{help:t("settings.herdrTraexPluginRefHelp"),children:t("settings.herdrTraexPluginRef")}),(0,n.jsx)("input",{className:"settings-text-input",type:"text",value:o,placeholder:t("settings.herdrTraexPluginRefPlaceholder"),disabled:e.disabled,onChange:k=>u(k.currentTarget.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),R())}})]}),p?null:(0,n.jsx)("p",{className:"hint-warn-inline settings-subfield-hint",children:t("settings.herdrTraexPluginSourceRequired")}),e.value.recommendedSource&&(p!==e.value.recommendedSource||h!==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:()=>{s(e.value.recommendedSource),u(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||!N,onClick:R,children:t("settings.herdrTraexPluginSave")})})]})}function St(e){let t=O(),i;return e.canWrite?e.loading&&!e.state?i=(0,n.jsx)(he,{label:t("settings.autostartLoading"),compact:!0}):e.error&&!e.state?i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"hint-warn",children:t("settings.autostartLoadFailed")}),(0,n.jsx)("div",{className:"update-actions",children:(0,n.jsx)("button",{type:"button",onClick:e.onRetry,children:t("settings.autostartRetry")})})]}):e.state?.supported===!1?i=(0,n.jsx)("p",{className:"hint-warn",children:t("settings.autostartUnsupported")}):e.state?i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(I,{title:t("settings.autostartToggle"),help:t("settings.autostartHelp"),checked:e.state.enabled,disabled:e.busy,onChange:e.onChange}),e.message?(0,n.jsx)("p",{className:`oncall-status ${e.message.cls??""}`,role:"status","aria-live":"polite",children:e.message.text}):null]}):i=null:i=(0,n.jsx)("p",{className:"hint-warn",children:t("settings.autostartLoginRequired")}),(0,n.jsx)(B,{title:t("settings.sectionAutostart"),children:i})}function Tt(e){let t=O(),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)(he,{label:t("update.loading"),compact:!0});else{let s=e.status,o=e.busy||(s.localDevInstall?!s.localDevUpdatable:!s.updateSupported),u=s.localDevInstall?t("update.btnUpdateLocalDev"):t("update.btnUpdate");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",s.current]})]})," ",(0,n.jsx)(Ot,{status:s})]}),s.node.ok?null:(0,n.jsx)("p",{className:"hint-warn",children:t("update.nodeWarn",{version:s.node.version,required:s.node.required})}),!s.localDevInstall&&!s.updateSupported?(0,n.jsx)("p",{className:"hint-warn",children:t("update.unsupportedInstall")}):null,s.localDevInstall?(0,n.jsx)("p",{className:"hint",children:s.localDevUpdatable?t("update.localDevUpdatable"):t("update.localDev")}):null,s.installs.multiple?(0,n.jsx)(wt,{entries:s.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:o,onClick:e.onUpdate,children:u}),(0,n.jsx)("button",{type:"button","data-up":"restart",disabled:e.busy,onClick:e.onRestart,children:t("update.btnRestart")})]}),s.cliUpdates?.length?(0,n.jsx)(xt,{entries:s.cliUpdates}):null,e.changelogOpen?(0,n.jsx)(Rt,{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)(B,{className:"settings-update-block",title:t("update.section"),titleExtra:e.status?.localDevInstall?(0,n.jsx)("span",{className:"settings-title-note",children:e.status.localDevUpdatable?t("update.localDevNote"):t("update.localDev")}):e.status&&!e.status.updateSupported?(0,n.jsx)("span",{className:"settings-title-note",children:t("update.unsupportedInstall")}):null,children:i})}function xt(e){let t=O();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:i.displayName}),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.managed?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)("span",{className:"hint-warn-inline",children:t("update.runtimeUnmanaged")})]}),(0,n.jsx)("code",{children:i.binPath}),i.updateAvailable&&i.updateCommand?(0,n.jsxs)("small",{children:[t("update.runtimeCommand"),": ",(0,n.jsx)("code",{children:i.updateCommand})]}):null]},`${i.runtimeId}:${i.binPath}`))}),(0,n.jsx)("p",{className:"settings-help",children:t("update.runtimeHelp")})]})}function Ot(e){let t=O(),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 wt(e){let t=O();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 ",Ye(i.kind,t)," ",(0,n.jsx)("small",{children:i.root})]},`${i.binPath}:${i.root}`))})]})}function Rt(e){let t=O();if(e.changelog===null)return(0,n.jsx)(he,{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 s=i.name&&i.name!==`v${i.version}`?i.name:"",o=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]})," ",s," ",(0,n.jsx)("small",{children:o})," ",(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 _t(e){return We(e,(0,n.jsx)(ft,{}))}export{bt as CodexNotifierSettingsEditor,Nt as GroupNamePrefixRow,ht as HostOverloadAlertSettingsEditor,kt as OAuthRedirectBaseRow,yt as TimeZoneRow,Xe as currentBrowserOrigin,et as isValidOAuthRedirectBase,_t as renderSettingsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ie}from"./chunk-OXSVWLER.js";import{b as el,c as bl,d as ue,h as hl,l as yl}from"./chunk-NYY66DNC.js";import{d as X}from"./chunk-ECFC7UG2.js";import"./chunk-QITAMHW6.js";import{C as Ye}from"./chunk-BU3Q6XC6.js";import{a as us,c as vl}from"./chunk-ARROO6TE.js";import{c as ee,d as Be,e as de}from"./chunk-3YZFAHNK.js";var c=ee(Be(),1),xl=ee(us(),1);var J=ee(Be(),1);var k=ee(de(),1);function ks(e){return(e.missingSkills?.length??0)>0?"missing":(e.references?.length??0)===0?"unassigned":"complete"}function Sl(e){let l=X(),n=e.packs??[],m=e.skills??[],[v,p]=(0,J.useState)(!1),[g,w]=(0,J.useState)(null),[a,C]=(0,J.useState)(null),[B,b]=(0,J.useState)(null),[P,N]=(0,J.useState)(!1),h=()=>{w(null),p(!0)},x=y=>{w(y),p(!0)},[E,T]=(0,J.useState)(()=>new Set),{focusPackId:L,focusPackIds:A,onFocusConsumed:$}=e;(0,J.useEffect)(()=>{if(!(!L&&(A?.length??0)===0)){if(L){let y=n.find(f=>f.id===L);y&&(w(y),p(!0)),T(new Set([L]))}else A&&T(new Set(A));$?.()}},[L,A]);let H=()=>{p(!1),w(null),C({text:l("skills.saved"),ok:!0}),e.onRefresh()},K=async y=>{try{let f=await fetch(`/api/skill-packs/${encodeURIComponent(y.id)}`,{method:"DELETE"}),I=await f.json().catch(()=>({}));if(f.ok){C({text:l("skills.packDeleted",{name:y.name}),ok:!0}),e.onRefresh();return}if(f.status===409&&I?.error==="SKILL_PACK_IN_USE"){let d=Array.isArray(I?.references)?I.references:y.references??[];b({pack:y,references:d});return}throw new Error(I?.error??`HTTP ${f.status}`)}catch(f){C({text:`${l("skills.failed")}: ${f?.message??f}`,ok:!1})}},F=async()=>{if(B){N(!0);try{let y=await fetch(`/api/skill-packs/${encodeURIComponent(B.pack.id)}?force=1`,{method:"DELETE"}),f=await y.json().catch(()=>({}));if(!y.ok)throw new Error(f?.error??`HTTP ${y.status}`);C({text:l("skills.packDeleted",{name:B.pack.name}),ok:!0}),b(null),e.onRefresh()}catch(y){C({text:`${l("skills.failed")}: ${y?.message??y}`,ok:!1})}finally{N(!1)}}};return(0,k.jsxs)("section",{className:"skills-config-block",children:[(0,k.jsx)(ue,{title:l("skills.packs"),count:e.packsKnown===!1?"\u2014":l("skills.packCount",{count:n.length}),hint:l("skills.packsHelp")}),a&&(0,k.jsx)("p",{className:`hint-${a.ok?"ok":"warn"}`,children:a.text}),(0,k.jsx)("div",{className:"bd-card skills-config-card",children:e.packsKnown===!1&&n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state","data-packs-unknown":!0,children:[(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packsUnknown")}),(0,k.jsx)("button",{className:"bd-button",onClick:()=>e.onRefresh(),children:l("skills.refresh")})]}):n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state",children:[(0,k.jsx)("p",{children:l("skills.packsEmpty")}),(0,k.jsx)("button",{className:"bd-button primary",onClick:h,children:l("skills.packCreate")})]}):(0,k.jsxs)("div",{className:"skills-pack-grid",children:[(0,k.jsxs)("button",{className:"skills-pack-create-tile",onClick:h,children:[(0,k.jsx)("span",{className:"skills-pack-create-plus",children:"+"}),(0,k.jsx)("span",{children:l("skills.packCreate")})]}),n.map(y=>{let f=ks(y);return(0,k.jsxs)("div",{className:`skills-pack-card${E.has(y.id)?" skills-pack-card-focus":""}`,children:[(0,k.jsxs)("div",{className:"skills-pack-card-head",children:[(0,k.jsxs)("div",{className:"skills-pack-title",children:[(0,k.jsx)("strong",{children:y.name}),(0,k.jsx)("code",{className:"skills-pack-id",children:y.id})]}),(0,k.jsx)("span",{className:`skills-pack-health skills-pack-health-${f}`,children:f==="complete"?"\u2713":f==="missing"?"!":"\u25CB"})]}),y.description&&(0,k.jsx)("p",{className:"skills-pack-desc",children:y.description}),(0,k.jsxs)("div",{className:"skills-pack-meta",children:[(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.skillCount",{count:y.include.length})}),(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.packRefCount",{count:y.references?.length??0})})]}),y.tags&&y.tags.length>0&&(0,k.jsx)("div",{className:"skills-pack-tags",children:y.tags.map(I=>(0,k.jsx)("span",{className:"skills-pack-tag",children:I},I))}),(y.references?.length??0)>0&&(0,k.jsx)("div",{className:"skills-pack-refs",children:y.references.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-pack-ref-chip","data-action":"open-pack-bot",disabled:!e.onOpenBot,onClick:()=>e.onOpenBot?.(I.larkAppId),children:I.botName},I.larkAppId))}),(y.missingSkills?.length??0)>0&&(0,k.jsxs)("div",{className:"skills-pack-missing",children:[l("skills.packMissing"),":"," ",y.missingSkills.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-missing-skill-chip","data-action":"install-missing-skill",title:l("skills.installMissingHint",{skill:I}),disabled:!e.onInstallMissingSkill,onClick:()=>e.onInstallMissingSkill?.(I),children:I},I))]}),(0,k.jsxs)("div",{className:"skills-pack-actions",children:[(0,k.jsx)("button",{className:"bd-button small",onClick:()=>x(y),children:l("skills.packEdit")}),(0,k.jsx)("button",{className:"bd-button small danger",onClick:()=>{K(y)},children:l("skills.remove")})]})]},y.id)})]})}),v&&(0,k.jsx)(ms,{pack:g,skills:m,onClose:()=>{p(!1),w(null)},onSaved:H}),B&&(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-delete-confirm",open:!0,onClose:()=>!P&&b(null),children:(0,k.jsxs)("form",{method:"dialog",onSubmit:y=>{y.preventDefault(),F()},children:[(0,k.jsx)("h3",{children:l("skills.packDeleteConfirmTitle")}),(0,k.jsx)("p",{children:l("skills.packDeleteConfirmBody",{name:B.pack.name})}),B.references.length>0&&(0,k.jsxs)("div",{className:"skills-pack-delete-refs",children:[(0,k.jsx)("p",{children:(0,k.jsxs)("strong",{children:[l("skills.packDeleteAffectedBots"),":"]})}),(0,k.jsx)("ul",{children:B.references.map(y=>(0,k.jsx)("li",{children:y.botName},y.larkAppId))})]}),(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packDeleteForceWarning")}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:()=>b(null),disabled:P,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button danger",disabled:P,children:l(P?"skills.removing":"skills.removeAnyway")})]})]})})]})}function ms(e){let l=X(),n=e.skills??[],[m,v]=(0,J.useState)(e.pack?.id??""),[p,g]=(0,J.useState)(e.pack?.name??""),[w,a]=(0,J.useState)(e.pack?.description??""),[C,B]=(0,J.useState)((e.pack?.tags??[]).join(", ")),[b,P]=(0,J.useState)(()=>new Set(e.pack?.include.map(d=>d.replace("skill:",""))??[])),[N,h]=(0,J.useState)(!1),[x,E]=(0,J.useState)(null),[T,L]=(0,J.useState)(""),A=(0,J.useRef)(null),$=(0,J.useMemo)(()=>new Set(n.map(d=>d.name)),[n]),H=(0,J.useMemo)(()=>[...b].filter(d=>!$.has(d)).sort(),[$,b]);(0,J.useEffect)(()=>{let d=A.current;d&&!d.open&&d.showModal()},[]);let K=(0,J.useMemo)(()=>{let d=T.trim().toLowerCase();return d?n.filter(U=>`${U.name} ${U.description??""}`.toLowerCase().includes(d)):n},[n,T]),F=K.length>0&&K.every(d=>b.has(d.name)),y=d=>{P(U=>{let G=new Set(U);return G.has(d)?G.delete(d):G.add(d),G})},f=()=>{P(d=>{let U=new Set(d);if(F)for(let G of K)U.delete(G.name);else for(let G of K)U.add(G.name);return U})},I=async()=>{h(!0),E(null);try{let d={id:m,name:p,description:w||void 0,tags:C.split(",").map(r=>r.trim()).filter(Boolean),include:[...b].map(r=>`skill:${r}`),...e.pack?{expectedRevision:e.pack.revision}:{}},U=e.pack?`/api/skill-packs/${encodeURIComponent(e.pack.id)}`:"/api/skill-packs",G=await fetch(U,{method:e.pack?"PUT":"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)}),te=await G.json().catch(()=>({}));if(!G.ok)throw new Error(te?.error??te?.reason??`HTTP ${G.status}`);e.onSaved()}catch(d){E(d?.message??String(d))}finally{h(!1)}};return(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-editor",ref:A,onClose:e.onClose,children:(0,k.jsxs)("form",{method:"dialog",onSubmit:d=>{d.preventDefault(),I()},children:[(0,k.jsx)("h3",{children:e.pack?l("skills.packEdit"):l("skills.packCreate")}),x&&(0,k.jsx)("p",{className:"hint-warn",children:x}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packId")}),(0,k.jsx)("input",{value:m,onChange:d=>v(d.target.value),disabled:!!e.pack,placeholder:l("skills.packIdPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packName")}),(0,k.jsx)("input",{value:p,onChange:d=>g(d.target.value)})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packDescription")}),(0,k.jsx)("textarea",{value:w,onChange:d=>a(d.target.value),rows:2})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packTags")}),(0,k.jsx)("input",{value:C,onChange:d=>B(d.target.value),placeholder:l("skills.packTagsPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsxs)("div",{className:"skills-pack-include-head",children:[(0,k.jsxs)("label",{children:[l("skills.packInclude")," (",b.size,"/",n.length+H.length,")"]}),(0,k.jsx)("input",{className:"skills-pack-skill-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:T,onChange:d=>L(d.target.value)})]}),K.length>0&&(0,k.jsxs)("label",{className:"skills-pack-select-all",children:[(0,k.jsx)("input",{type:"checkbox",checked:F,onChange:f}),l(F?"skills.deselectAll":"skills.selectAll")]}),H.length>0&&(0,k.jsxs)("div",{className:"skills-pack-missing-editor",children:[(0,k.jsx)("small",{className:"muted",children:l("skills.packMissing")}),H.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item skills-pack-skill-missing","data-missing-skill":d,children:[(0,k.jsx)("input",{type:"checkbox",checked:!0,onChange:()=>y(d)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d}),(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:l("skills.packMissing")})]},d))]}),(0,k.jsxs)("div",{className:"skills-pack-skill-list",children:[K.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,k.jsx)("input",{type:"checkbox",checked:b.has(d.name),onChange:()=>y(d.name)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d.name}),d.description&&(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:d.description})]},d.name)),K.length===0&&(0,k.jsx)("p",{className:"muted",children:l("skills.noResults")})]})]}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button primary",disabled:N||b.size===0||!p.trim(),children:l(N?"skills.saving":"skills.saveSelection")})]})]})})}var oe=ee(Be(),1);var Il=new Set(["-y","--yes","-g","--global"]);function gs(e){let l=[],n="",m,v=!1;for(let p=0;p<e.length;p++){let g=e[p];if(m){if(g===m){m=void 0;continue}if(g==="\\"&&m==='"'){if(p+1>=e.length)return null;n+=e[++p];continue}n+=g;continue}if(/\s/.test(g)){v&&(l.push(n),n="",v=!1);continue}if(g==="'"||g==='"'){m=g,v=!0;continue}if(g==="\\"){if(p+1>=e.length)return null;n+=e[++p],v=!0;continue}n+=g,v=!0}return m?null:(v&&l.push(n),l)}function Nl(e){for(let l of e)if(!Il.has(l))return l.startsWith("-")?null:l||null;return null}function wl(e){let l=gs(e);if(!l)return null;let n=l.findIndex(g=>g==="skills"||g==="add-skill"||g.startsWith("skills@"));if(n<0)return null;let m=l[n],v=l.slice(n+1);if(m==="add-skill")return Nl(v);let p=0;for(;Il.has(v[p]);)p++;return v[p]!=="add"?null:Nl(v.slice(p+1))}var q=ee(de(),1);function Cl(e){let l=X(),[n,m]=(0,oe.useState)(null),v=(0,oe.useRef)(null),{navIntent:p,onNavIntentConsumed:g}=e;(0,oe.useEffect)(()=>{if(p){if(p.openInstallWizard){let a=v.current;a?.scrollIntoView?.({behavior:"smooth",block:"start"}),a?.querySelector('input[data-install="source"]')?.focus()}g?.()}},[p,g]);let w=a=>{if(!(!a||a.length===0)){if(a.length>1)m(a);else if(e.onAssignInstalledSkill){let C=a[0];Ie(l("skills.installSuccess",{skill:C}),{kind:"success",duration:5e3,action:{label:l("skills.assignToBot"),onClick:()=>e.onAssignInstalledSkill(C)}})}}};return(0,q.jsxs)("div",{className:"skills-page-stack",children:[(0,q.jsx)("div",{className:"skills-install-anchor",ref:v,children:(0,q.jsx)(e.InstallPanel,{installSource:e.installSource,installPath:e.installPath,installRef:e.installRef,installFullDepth:e.installFullDepth,installTargetSkill:e.installTargetSkill??null,installStatus:e.installStatus,installBusy:e.installBusy,installDiscovering:e.installDiscovering,installSelectionOpen:e.installSelectionOpen,installCandidates:e.installCandidates,selectedInstallSkills:e.selectedInstallSkills,onInstallSourceChange:e.onInstallSourceChange,onInstallPathChange:e.onInstallPathChange,onInstallRefChange:e.onInstallRefChange,onInstallFullDepthChange:e.onInstallFullDepthChange,onClearInstallTarget:e.onClearInstallTarget,onToggleInstallSkill:e.onToggleInstallSkill,onSelectAllInstallSkills:e.onSelectAllInstallSkills,onConfirmInstallSelection:()=>{e.onConfirmInstallSelection().then(w)},onCloseInstallSelection:e.onCloseInstallSelection,onInstall:()=>{e.onInstall().then(w)},onOpenNativeDiscovery:e.onOpenNativeDiscovery})}),n&&(0,q.jsx)(ps,{skillNames:n,onClose:()=>m(null),onCreate:async a=>{await e.onCreatePack(a),m(null)}}),(0,q.jsx)(e.InstalledLibrary,{skills:e.skills,busySkill:e.skillBusy,removingNames:e.removingNames,status:e.installedStatus,onUpdate:e.onUpdateSkill,onRequestRemove:e.onRequestRemove,externalQuery:e.navIntent?.librarySearch??null,externalFilterNames:e.navIntent?.libraryFilterSkills??null,packsKnown:e.packsKnown,onInstallMissing:e.onInstallMissing,graph:e.graph,packNames:e.packNames,onShowSkillPacks:e.onShowSkillPacks,onShowSkillBots:e.onShowSkillBots}),(0,q.jsx)(e.RemoveDialog,{names:e.removalDialogOpen?e.pendingRemoval:null,references:e.removalReferences,busy:e.removingNames.size>0,error:e.removalError,onCancel:e.onCancelRemoval,onConfirm:e.onConfirmRemoval})]})}function ps(e){let l=X(),[n,m]=(0,oe.useState)(""),[v,p]=(0,oe.useState)(""),[g,w]=(0,oe.useState)(!1),[a,C]=(0,oe.useState)(null),B=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{let P=B.current;if(P&&!P.open)try{P.showModal()}catch{}},[]);let b=async()=>{if(!(!n.trim()||!v.trim())){w(!0),C(null);try{await e.onCreate({id:n.trim(),name:v.trim(),skillNames:e.skillNames})}catch(P){C(P?.message??String(P))}finally{w(!1)}}};return(0,q.jsx)("dialog",{className:"bd-dialog skills-post-install-pack",ref:B,onClose:()=>!g&&e.onClose(),children:(0,q.jsxs)("form",{method:"dialog",onSubmit:P=>{P.preventDefault(),b()},children:[(0,q.jsx)("h3",{children:l("skills.postInstallPackTitle")}),(0,q.jsx)("p",{children:l("skills.postInstallPackHelp",{count:e.skillNames.length})}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packId")}),(0,q.jsx)("input",{autoFocus:!0,required:!0,value:n,onChange:P=>m(P.target.value)})]}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packName")}),(0,q.jsx)("input",{required:!0,value:v,onChange:P=>p(P.target.value)})]}),(0,q.jsxs)("div",{className:"skills-resolved-preview",children:[(0,q.jsx)("strong",{children:l("skills.postInstallPackSkills")}),(0,q.jsx)("ul",{children:e.skillNames.map(P=>(0,q.jsx)("li",{children:(0,q.jsx)("code",{children:P})},P))})]}),a&&(0,q.jsx)("p",{className:"hint-warn",children:a}),(0,q.jsxs)("div",{className:"skills-dialog-actions",children:[(0,q.jsx)("button",{type:"button",className:"bd-button",disabled:g,onClick:e.onClose,children:l("skills.postInstallPackSkip")}),(0,q.jsx)("button",{type:"submit",className:"bd-button primary",disabled:g||!n.trim()||!v.trim(),children:l(g?"skills.saving":"skills.postInstallPackCreate")})]})]})})}function ll(e){let l=e.trim(),n=l.toLowerCase();if(!l)return"unknown";if(/^agentbuddy:/i.test(l)||/(?:^|\s)(?:npx\s+)?agentbuddy(?:@[\w.-]+)?\s+(?:skill|plugin)\s/i.test(l))return"agentbuddy";let m=wl(l);return m?ll(m):n.startsWith("github:")?"github":n.startsWith("git+")||n.startsWith("git@")||n.startsWith("git://")?"git":n.includes("github.com")?"github":n.startsWith("http://")||n.startsWith("https://")||n.endsWith(".git")?"git":/^[/~.]/.test(l)?"local":/^[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9._-]+(?:\/[\w./-]+)?$/.test(l)?"github":l.includes("://")?"unknown":"local"}var Q=ee(Be(),1);function fs(e,l){let n=String(e??"").replace(/\\/g,"/");return n.includes("/.codex/skills/")?l("skills.sourceCodex"):n.includes("/.claude/skills/")?l("skills.sourceClaude"):n.includes("/.trae/skills/")?l("skills.sourceTrae"):n.includes("/.cursor/skills/")?l("skills.sourceCursor"):n.includes("/.gemini/skills/")?l("skills.sourceGemini"):n.includes("/.config/opencode/skills/")?l("skills.sourceOpenCode"):null}function sl(e,l){let n=e.source??{};return n.type==="github"?`github:${n.owner}/${n.repo}/${n.path??""}`:n.type==="git"?`${n.url??"git"}#${n.path??""}`:n.type==="local-link"?fs(n.path,l)??l("skills.sourceLocalLink"):n.type==="local-copy"?l("skills.sourceBotmuxCopy"):String(n.type??"unknown")}function ke(e){return(e?.include??[]).filter(l=>l.startsWith("skill:")).map(l=>l.slice(6))}function be(e){return(e?.include??[]).filter(l=>l.startsWith("pack:")).map(l=>l.slice(5))}function Pl(e,l,n){let m=(e?.include??[]).filter(g=>!g.startsWith("skill:")&&!g.startsWith("pack:")),v=[...new Set(l.map(g=>g.trim()).filter(Boolean))].map(g=>`skill:${g}`),p=[...new Set(n.map(g=>g.trim()).filter(Boolean))].map(g=>`pack:${g}`);return[...v,...p,...m]}function Rl(e){return(e?.include?.length??0)>0}function xe(e){return`${e.cliId}
|
|
1
|
+
import{a as Ie}from"./chunk-OXSVWLER.js";import{b as el,c as bl,d as ue,h as hl,l as yl}from"./chunk-NYY66DNC.js";import{d as X}from"./chunk-R3LJUCEO.js";import"./chunk-QITAMHW6.js";import{C as Ye}from"./chunk-K232GT3M.js";import{a as us,c as vl}from"./chunk-ARROO6TE.js";import{c as ee,d as Be,e as de}from"./chunk-3YZFAHNK.js";var c=ee(Be(),1),xl=ee(us(),1);var J=ee(Be(),1);var k=ee(de(),1);function ks(e){return(e.missingSkills?.length??0)>0?"missing":(e.references?.length??0)===0?"unassigned":"complete"}function Sl(e){let l=X(),n=e.packs??[],m=e.skills??[],[v,p]=(0,J.useState)(!1),[g,w]=(0,J.useState)(null),[a,C]=(0,J.useState)(null),[B,b]=(0,J.useState)(null),[P,N]=(0,J.useState)(!1),h=()=>{w(null),p(!0)},x=y=>{w(y),p(!0)},[E,T]=(0,J.useState)(()=>new Set),{focusPackId:L,focusPackIds:A,onFocusConsumed:$}=e;(0,J.useEffect)(()=>{if(!(!L&&(A?.length??0)===0)){if(L){let y=n.find(f=>f.id===L);y&&(w(y),p(!0)),T(new Set([L]))}else A&&T(new Set(A));$?.()}},[L,A]);let H=()=>{p(!1),w(null),C({text:l("skills.saved"),ok:!0}),e.onRefresh()},K=async y=>{try{let f=await fetch(`/api/skill-packs/${encodeURIComponent(y.id)}`,{method:"DELETE"}),I=await f.json().catch(()=>({}));if(f.ok){C({text:l("skills.packDeleted",{name:y.name}),ok:!0}),e.onRefresh();return}if(f.status===409&&I?.error==="SKILL_PACK_IN_USE"){let d=Array.isArray(I?.references)?I.references:y.references??[];b({pack:y,references:d});return}throw new Error(I?.error??`HTTP ${f.status}`)}catch(f){C({text:`${l("skills.failed")}: ${f?.message??f}`,ok:!1})}},F=async()=>{if(B){N(!0);try{let y=await fetch(`/api/skill-packs/${encodeURIComponent(B.pack.id)}?force=1`,{method:"DELETE"}),f=await y.json().catch(()=>({}));if(!y.ok)throw new Error(f?.error??`HTTP ${y.status}`);C({text:l("skills.packDeleted",{name:B.pack.name}),ok:!0}),b(null),e.onRefresh()}catch(y){C({text:`${l("skills.failed")}: ${y?.message??y}`,ok:!1})}finally{N(!1)}}};return(0,k.jsxs)("section",{className:"skills-config-block",children:[(0,k.jsx)(ue,{title:l("skills.packs"),count:e.packsKnown===!1?"\u2014":l("skills.packCount",{count:n.length}),hint:l("skills.packsHelp")}),a&&(0,k.jsx)("p",{className:`hint-${a.ok?"ok":"warn"}`,children:a.text}),(0,k.jsx)("div",{className:"bd-card skills-config-card",children:e.packsKnown===!1&&n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state","data-packs-unknown":!0,children:[(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packsUnknown")}),(0,k.jsx)("button",{className:"bd-button",onClick:()=>e.onRefresh(),children:l("skills.refresh")})]}):n.length===0?(0,k.jsxs)("div",{className:"skills-empty-state",children:[(0,k.jsx)("p",{children:l("skills.packsEmpty")}),(0,k.jsx)("button",{className:"bd-button primary",onClick:h,children:l("skills.packCreate")})]}):(0,k.jsxs)("div",{className:"skills-pack-grid",children:[(0,k.jsxs)("button",{className:"skills-pack-create-tile",onClick:h,children:[(0,k.jsx)("span",{className:"skills-pack-create-plus",children:"+"}),(0,k.jsx)("span",{children:l("skills.packCreate")})]}),n.map(y=>{let f=ks(y);return(0,k.jsxs)("div",{className:`skills-pack-card${E.has(y.id)?" skills-pack-card-focus":""}`,children:[(0,k.jsxs)("div",{className:"skills-pack-card-head",children:[(0,k.jsxs)("div",{className:"skills-pack-title",children:[(0,k.jsx)("strong",{children:y.name}),(0,k.jsx)("code",{className:"skills-pack-id",children:y.id})]}),(0,k.jsx)("span",{className:`skills-pack-health skills-pack-health-${f}`,children:f==="complete"?"\u2713":f==="missing"?"!":"\u25CB"})]}),y.description&&(0,k.jsx)("p",{className:"skills-pack-desc",children:y.description}),(0,k.jsxs)("div",{className:"skills-pack-meta",children:[(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.skillCount",{count:y.include.length})}),(0,k.jsx)("span",{className:"skills-pack-meta-item",children:l("skills.packRefCount",{count:y.references?.length??0})})]}),y.tags&&y.tags.length>0&&(0,k.jsx)("div",{className:"skills-pack-tags",children:y.tags.map(I=>(0,k.jsx)("span",{className:"skills-pack-tag",children:I},I))}),(y.references?.length??0)>0&&(0,k.jsx)("div",{className:"skills-pack-refs",children:y.references.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-pack-ref-chip","data-action":"open-pack-bot",disabled:!e.onOpenBot,onClick:()=>e.onOpenBot?.(I.larkAppId),children:I.botName},I.larkAppId))}),(y.missingSkills?.length??0)>0&&(0,k.jsxs)("div",{className:"skills-pack-missing",children:[l("skills.packMissing"),":"," ",y.missingSkills.map(I=>(0,k.jsx)("button",{type:"button",className:"skills-missing-skill-chip","data-action":"install-missing-skill",title:l("skills.installMissingHint",{skill:I}),disabled:!e.onInstallMissingSkill,onClick:()=>e.onInstallMissingSkill?.(I),children:I},I))]}),(0,k.jsxs)("div",{className:"skills-pack-actions",children:[(0,k.jsx)("button",{className:"bd-button small",onClick:()=>x(y),children:l("skills.packEdit")}),(0,k.jsx)("button",{className:"bd-button small danger",onClick:()=>{K(y)},children:l("skills.remove")})]})]},y.id)})]})}),v&&(0,k.jsx)(ms,{pack:g,skills:m,onClose:()=>{p(!1),w(null)},onSaved:H}),B&&(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-delete-confirm",open:!0,onClose:()=>!P&&b(null),children:(0,k.jsxs)("form",{method:"dialog",onSubmit:y=>{y.preventDefault(),F()},children:[(0,k.jsx)("h3",{children:l("skills.packDeleteConfirmTitle")}),(0,k.jsx)("p",{children:l("skills.packDeleteConfirmBody",{name:B.pack.name})}),B.references.length>0&&(0,k.jsxs)("div",{className:"skills-pack-delete-refs",children:[(0,k.jsx)("p",{children:(0,k.jsxs)("strong",{children:[l("skills.packDeleteAffectedBots"),":"]})}),(0,k.jsx)("ul",{children:B.references.map(y=>(0,k.jsx)("li",{children:y.botName},y.larkAppId))})]}),(0,k.jsx)("p",{className:"hint-warn",children:l("skills.packDeleteForceWarning")}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:()=>b(null),disabled:P,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button danger",disabled:P,children:l(P?"skills.removing":"skills.removeAnyway")})]})]})})]})}function ms(e){let l=X(),n=e.skills??[],[m,v]=(0,J.useState)(e.pack?.id??""),[p,g]=(0,J.useState)(e.pack?.name??""),[w,a]=(0,J.useState)(e.pack?.description??""),[C,B]=(0,J.useState)((e.pack?.tags??[]).join(", ")),[b,P]=(0,J.useState)(()=>new Set(e.pack?.include.map(d=>d.replace("skill:",""))??[])),[N,h]=(0,J.useState)(!1),[x,E]=(0,J.useState)(null),[T,L]=(0,J.useState)(""),A=(0,J.useRef)(null),$=(0,J.useMemo)(()=>new Set(n.map(d=>d.name)),[n]),H=(0,J.useMemo)(()=>[...b].filter(d=>!$.has(d)).sort(),[$,b]);(0,J.useEffect)(()=>{let d=A.current;d&&!d.open&&d.showModal()},[]);let K=(0,J.useMemo)(()=>{let d=T.trim().toLowerCase();return d?n.filter(U=>`${U.name} ${U.description??""}`.toLowerCase().includes(d)):n},[n,T]),F=K.length>0&&K.every(d=>b.has(d.name)),y=d=>{P(U=>{let G=new Set(U);return G.has(d)?G.delete(d):G.add(d),G})},f=()=>{P(d=>{let U=new Set(d);if(F)for(let G of K)U.delete(G.name);else for(let G of K)U.add(G.name);return U})},I=async()=>{h(!0),E(null);try{let d={id:m,name:p,description:w||void 0,tags:C.split(",").map(r=>r.trim()).filter(Boolean),include:[...b].map(r=>`skill:${r}`),...e.pack?{expectedRevision:e.pack.revision}:{}},U=e.pack?`/api/skill-packs/${encodeURIComponent(e.pack.id)}`:"/api/skill-packs",G=await fetch(U,{method:e.pack?"PUT":"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)}),te=await G.json().catch(()=>({}));if(!G.ok)throw new Error(te?.error??te?.reason??`HTTP ${G.status}`);e.onSaved()}catch(d){E(d?.message??String(d))}finally{h(!1)}};return(0,k.jsx)("dialog",{className:"bd-dialog skills-pack-editor",ref:A,onClose:e.onClose,children:(0,k.jsxs)("form",{method:"dialog",onSubmit:d=>{d.preventDefault(),I()},children:[(0,k.jsx)("h3",{children:e.pack?l("skills.packEdit"):l("skills.packCreate")}),x&&(0,k.jsx)("p",{className:"hint-warn",children:x}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packId")}),(0,k.jsx)("input",{value:m,onChange:d=>v(d.target.value),disabled:!!e.pack,placeholder:l("skills.packIdPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packName")}),(0,k.jsx)("input",{value:p,onChange:d=>g(d.target.value)})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packDescription")}),(0,k.jsx)("textarea",{value:w,onChange:d=>a(d.target.value),rows:2})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsx)("label",{children:l("skills.packTags")}),(0,k.jsx)("input",{value:C,onChange:d=>B(d.target.value),placeholder:l("skills.packTagsPlaceholder")})]}),(0,k.jsxs)("div",{className:"skills-control-block",children:[(0,k.jsxs)("div",{className:"skills-pack-include-head",children:[(0,k.jsxs)("label",{children:[l("skills.packInclude")," (",b.size,"/",n.length+H.length,")"]}),(0,k.jsx)("input",{className:"skills-pack-skill-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:T,onChange:d=>L(d.target.value)})]}),K.length>0&&(0,k.jsxs)("label",{className:"skills-pack-select-all",children:[(0,k.jsx)("input",{type:"checkbox",checked:F,onChange:f}),l(F?"skills.deselectAll":"skills.selectAll")]}),H.length>0&&(0,k.jsxs)("div",{className:"skills-pack-missing-editor",children:[(0,k.jsx)("small",{className:"muted",children:l("skills.packMissing")}),H.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item skills-pack-skill-missing","data-missing-skill":d,children:[(0,k.jsx)("input",{type:"checkbox",checked:!0,onChange:()=>y(d)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d}),(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:l("skills.packMissing")})]},d))]}),(0,k.jsxs)("div",{className:"skills-pack-skill-list",children:[K.map(d=>(0,k.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,k.jsx)("input",{type:"checkbox",checked:b.has(d.name),onChange:()=>y(d.name)}),(0,k.jsx)("span",{className:"skills-pack-skill-name",children:d.name}),d.description&&(0,k.jsx)("small",{className:"skills-pack-skill-desc",children:d.description})]},d.name)),K.length===0&&(0,k.jsx)("p",{className:"muted",children:l("skills.noResults")})]})]}),(0,k.jsxs)("div",{className:"skills-dialog-actions",children:[(0,k.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,k.jsx)("button",{type:"submit",className:"bd-button primary",disabled:N||b.size===0||!p.trim(),children:l(N?"skills.saving":"skills.saveSelection")})]})]})})}var oe=ee(Be(),1);var Il=new Set(["-y","--yes","-g","--global"]);function gs(e){let l=[],n="",m,v=!1;for(let p=0;p<e.length;p++){let g=e[p];if(m){if(g===m){m=void 0;continue}if(g==="\\"&&m==='"'){if(p+1>=e.length)return null;n+=e[++p];continue}n+=g;continue}if(/\s/.test(g)){v&&(l.push(n),n="",v=!1);continue}if(g==="'"||g==='"'){m=g,v=!0;continue}if(g==="\\"){if(p+1>=e.length)return null;n+=e[++p],v=!0;continue}n+=g,v=!0}return m?null:(v&&l.push(n),l)}function Nl(e){for(let l of e)if(!Il.has(l))return l.startsWith("-")?null:l||null;return null}function wl(e){let l=gs(e);if(!l)return null;let n=l.findIndex(g=>g==="skills"||g==="add-skill"||g.startsWith("skills@"));if(n<0)return null;let m=l[n],v=l.slice(n+1);if(m==="add-skill")return Nl(v);let p=0;for(;Il.has(v[p]);)p++;return v[p]!=="add"?null:Nl(v.slice(p+1))}var q=ee(de(),1);function Cl(e){let l=X(),[n,m]=(0,oe.useState)(null),v=(0,oe.useRef)(null),{navIntent:p,onNavIntentConsumed:g}=e;(0,oe.useEffect)(()=>{if(p){if(p.openInstallWizard){let a=v.current;a?.scrollIntoView?.({behavior:"smooth",block:"start"}),a?.querySelector('input[data-install="source"]')?.focus()}g?.()}},[p,g]);let w=a=>{if(!(!a||a.length===0)){if(a.length>1)m(a);else if(e.onAssignInstalledSkill){let C=a[0];Ie(l("skills.installSuccess",{skill:C}),{kind:"success",duration:5e3,action:{label:l("skills.assignToBot"),onClick:()=>e.onAssignInstalledSkill(C)}})}}};return(0,q.jsxs)("div",{className:"skills-page-stack",children:[(0,q.jsx)("div",{className:"skills-install-anchor",ref:v,children:(0,q.jsx)(e.InstallPanel,{installSource:e.installSource,installPath:e.installPath,installRef:e.installRef,installFullDepth:e.installFullDepth,installTargetSkill:e.installTargetSkill??null,installStatus:e.installStatus,installBusy:e.installBusy,installDiscovering:e.installDiscovering,installSelectionOpen:e.installSelectionOpen,installCandidates:e.installCandidates,selectedInstallSkills:e.selectedInstallSkills,onInstallSourceChange:e.onInstallSourceChange,onInstallPathChange:e.onInstallPathChange,onInstallRefChange:e.onInstallRefChange,onInstallFullDepthChange:e.onInstallFullDepthChange,onClearInstallTarget:e.onClearInstallTarget,onToggleInstallSkill:e.onToggleInstallSkill,onSelectAllInstallSkills:e.onSelectAllInstallSkills,onConfirmInstallSelection:()=>{e.onConfirmInstallSelection().then(w)},onCloseInstallSelection:e.onCloseInstallSelection,onInstall:()=>{e.onInstall().then(w)},onOpenNativeDiscovery:e.onOpenNativeDiscovery})}),n&&(0,q.jsx)(ps,{skillNames:n,onClose:()=>m(null),onCreate:async a=>{await e.onCreatePack(a),m(null)}}),(0,q.jsx)(e.InstalledLibrary,{skills:e.skills,busySkill:e.skillBusy,removingNames:e.removingNames,status:e.installedStatus,onUpdate:e.onUpdateSkill,onRequestRemove:e.onRequestRemove,externalQuery:e.navIntent?.librarySearch??null,externalFilterNames:e.navIntent?.libraryFilterSkills??null,packsKnown:e.packsKnown,onInstallMissing:e.onInstallMissing,graph:e.graph,packNames:e.packNames,onShowSkillPacks:e.onShowSkillPacks,onShowSkillBots:e.onShowSkillBots}),(0,q.jsx)(e.RemoveDialog,{names:e.removalDialogOpen?e.pendingRemoval:null,references:e.removalReferences,busy:e.removingNames.size>0,error:e.removalError,onCancel:e.onCancelRemoval,onConfirm:e.onConfirmRemoval})]})}function ps(e){let l=X(),[n,m]=(0,oe.useState)(""),[v,p]=(0,oe.useState)(""),[g,w]=(0,oe.useState)(!1),[a,C]=(0,oe.useState)(null),B=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{let P=B.current;if(P&&!P.open)try{P.showModal()}catch{}},[]);let b=async()=>{if(!(!n.trim()||!v.trim())){w(!0),C(null);try{await e.onCreate({id:n.trim(),name:v.trim(),skillNames:e.skillNames})}catch(P){C(P?.message??String(P))}finally{w(!1)}}};return(0,q.jsx)("dialog",{className:"bd-dialog skills-post-install-pack",ref:B,onClose:()=>!g&&e.onClose(),children:(0,q.jsxs)("form",{method:"dialog",onSubmit:P=>{P.preventDefault(),b()},children:[(0,q.jsx)("h3",{children:l("skills.postInstallPackTitle")}),(0,q.jsx)("p",{children:l("skills.postInstallPackHelp",{count:e.skillNames.length})}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packId")}),(0,q.jsx)("input",{autoFocus:!0,required:!0,value:n,onChange:P=>m(P.target.value)})]}),(0,q.jsxs)("div",{className:"skills-control-block",children:[(0,q.jsx)("label",{children:l("skills.packName")}),(0,q.jsx)("input",{required:!0,value:v,onChange:P=>p(P.target.value)})]}),(0,q.jsxs)("div",{className:"skills-resolved-preview",children:[(0,q.jsx)("strong",{children:l("skills.postInstallPackSkills")}),(0,q.jsx)("ul",{children:e.skillNames.map(P=>(0,q.jsx)("li",{children:(0,q.jsx)("code",{children:P})},P))})]}),a&&(0,q.jsx)("p",{className:"hint-warn",children:a}),(0,q.jsxs)("div",{className:"skills-dialog-actions",children:[(0,q.jsx)("button",{type:"button",className:"bd-button",disabled:g,onClick:e.onClose,children:l("skills.postInstallPackSkip")}),(0,q.jsx)("button",{type:"submit",className:"bd-button primary",disabled:g||!n.trim()||!v.trim(),children:l(g?"skills.saving":"skills.postInstallPackCreate")})]})]})})}function ll(e){let l=e.trim(),n=l.toLowerCase();if(!l)return"unknown";if(/^agentbuddy:/i.test(l)||/(?:^|\s)(?:npx\s+)?agentbuddy(?:@[\w.-]+)?\s+(?:skill|plugin)\s/i.test(l))return"agentbuddy";let m=wl(l);return m?ll(m):n.startsWith("github:")?"github":n.startsWith("git+")||n.startsWith("git@")||n.startsWith("git://")?"git":n.includes("github.com")?"github":n.startsWith("http://")||n.startsWith("https://")||n.endsWith(".git")?"git":/^[/~.]/.test(l)?"local":/^[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9._-]+(?:\/[\w./-]+)?$/.test(l)?"github":l.includes("://")?"unknown":"local"}var Q=ee(Be(),1);function fs(e,l){let n=String(e??"").replace(/\\/g,"/");return n.includes("/.codex/skills/")?l("skills.sourceCodex"):n.includes("/.claude/skills/")?l("skills.sourceClaude"):n.includes("/.trae/skills/")?l("skills.sourceTrae"):n.includes("/.cursor/skills/")?l("skills.sourceCursor"):n.includes("/.gemini/skills/")?l("skills.sourceGemini"):n.includes("/.config/opencode/skills/")?l("skills.sourceOpenCode"):null}function sl(e,l){let n=e.source??{};return n.type==="github"?`github:${n.owner}/${n.repo}/${n.path??""}`:n.type==="git"?`${n.url??"git"}#${n.path??""}`:n.type==="local-link"?fs(n.path,l)??l("skills.sourceLocalLink"):n.type==="local-copy"?l("skills.sourceBotmuxCopy"):String(n.type??"unknown")}function ke(e){return(e?.include??[]).filter(l=>l.startsWith("skill:")).map(l=>l.slice(6))}function be(e){return(e?.include??[]).filter(l=>l.startsWith("pack:")).map(l=>l.slice(5))}function Pl(e,l,n){let m=(e?.include??[]).filter(g=>!g.startsWith("skill:")&&!g.startsWith("pack:")),v=[...new Set(l.map(g=>g.trim()).filter(Boolean))].map(g=>`skill:${g}`),p=[...new Set(n.map(g=>g.trim()).filter(Boolean))].map(g=>`pack:${g}`);return[...v,...p,...m]}function Rl(e){return(e?.include?.length??0)>0}function xe(e){return`${e.cliId}
|
|
2
2
|
${e.rootDir}`}function ze(e,l,n,m){let v=m?.packsKnown!==!1,p=new Set(e.map(b=>b.name)),g=new Map,w=b=>{let P=g.get(b);return P||(P={name:b,installed:p.has(b),packIds:[],directBotIds:[],viaPackBotIds:[]},g.set(b,P)),P};for(let b of p)w(b);let a=new Map,C=new Map;for(let b of l){C.set(b.id,b);let P=[],N=[];for(let h of b.include){if(!h.startsWith("skill:"))continue;let x=h.slice(6),E=w(x);E.packIds.includes(b.id)||E.packIds.push(b.id),(p.has(x)?P:N).push(x)}a.set(b.id,{id:b.id,resolved:P,missing:N,botIds:[]})}let B=new Map;for(let b of n){let P=b.skills?.include??[],N=new Map,h=new Set,x=[],E=!1;for(let L of P)if(L.startsWith("skill:")){let A=L.slice(6),$=w(A);$.directBotIds.includes(b.larkAppId)||$.directBotIds.push(b.larkAppId),p.has(A)?N.set(A,"direct"):h.add(A)}else if(L.startsWith("pack:")){let A=L.slice(5),$=C.get(A);if(!$){v?x.push(A):E=!0;continue}let H=a.get(A);H.botIds.includes(b.larkAppId)||H.botIds.push(b.larkAppId);for(let K of $.include){if(!K.startsWith("skill:"))continue;let F=K.slice(6),y=w(F);y.viaPackBotIds.includes(b.larkAppId)||y.viaPackBotIds.push(b.larkAppId),p.has(F)?N.has(F)||N.set(F,`pack:${A}`):h.add(F)}}let T=x.length>0?"pack_missing":h.size>0?"missing":E?"unknown":P.length===0?"default":"ok";B.set(b.larkAppId,{larkAppId:b.larkAppId,resolved:[...N.entries()].map(([L,A])=>({name:L,source:A})),missingSkills:[...h],missingPacks:x,finalCount:N.size,health:T})}return{skills:g,packs:a,bots:B}}function Dl(e){return[...e.skills.values()].filter(l=>!l.installed).map(l=>l.name).sort()}function tl(e,l){if(l){let n=e.some(m=>m.name===l);return{selected:n?new Set([l]):new Set,targetMissing:!n}}return{selected:new Set(e.map(n=>n.name)),targetMissing:!1}}var u=ee(de(),1);function Tl(e){let l=X(),[n,m]=(0,Q.useState)(null),[v,p]=(0,Q.useState)(null),[g,w]=(0,Q.useState)(!1),[a,C]=(0,Q.useState)(null),[B,b]=(0,Q.useState)(null),[P,N]=(0,Q.useState)(""),[h,x]=(0,Q.useState)(null),[E,T]=(0,Q.useState)(()=>new Set),[L,A]=(0,Q.useState)(null),{focusBotIds:$,focusSkill:H,onFocusConsumed:K}=e;(0,Q.useEffect)(()=>{($?.length??0)===0&&!H||($&&$.length>0&&T(new Set($)),H&&(A(H),N(H)),K?.())},[$,H]),(0,Q.useEffect)(()=>{if(!B)return;let r=setTimeout(()=>b(null),1600);return()=>clearTimeout(r)},[B]);let F=(0,Q.useMemo)(()=>ze(e.skills,e.packs,e.bots,{packsKnown:e.packsKnown!==!1}),[e.skills,e.packs,e.bots,e.packsKnown]),y=(0,Q.useMemo)(()=>{let r=new Set;for(let i of e.skills)for(let M of i.tags??[])r.add(M);return[...r].sort()},[e.skills]),f=(0,Q.useMemo)(()=>{let r=P.trim().toLowerCase();return e.skills.filter(i=>h&&!(i.tags??[]).includes(h)?!1:r?`${i.name} ${i.description??""}`.toLowerCase().includes(r):!0)},[e.skills,P,h]),I=async r=>{if(!a||a.sourceBotId)return;p(null),C(null);let i=ke(r.skills),M=be(r.skills);if(a.type==="skill"){if(i.includes(a.id)){b({botId:r.larkAppId,itemLabel:a.id});return}e.onMutate?await e.onMutate(r.larkAppId,`skill:${a.id}`,!0):await e.onSave(r.larkAppId,[...i,a.id],M)}else{if(M.includes(a.id)){b({botId:r.larkAppId,itemLabel:e.packs.find(R=>R.id===a.id)?.name??a.id});return}e.onMutate?await e.onMutate(r.larkAppId,`pack:${a.id}`,!0):await e.onSave(r.larkAppId,i,[...M,a.id])}},d=async()=>{let r=a;if(!r?.sourceBotId)return;w(!1),p(null),C(null);let i=e.bots.find(_=>_.larkAppId===r.sourceBotId);if(!i)return;let M=ke(i.skills),R=be(i.skills);if(r.type==="skill"){if(!M.includes(r.id))return;e.onMutate?await e.onMutate(i.larkAppId,`skill:${r.id}`,!1):await e.onSave(i.larkAppId,M.filter(_=>_!==r.id),R)}else{if(!R.includes(r.id))return;e.onMutate?await e.onMutate(i.larkAppId,`pack:${r.id}`,!1):await e.onSave(i.larkAppId,M,R.filter(_=>_!==r.id))}},U=()=>{C(null),p(null),w(!1)},G=(r,i,M)=>{r.dataTransfer.effectAllowed=M,r.dataTransfer.setData("text/plain",i.id),b(null),C(i)},te=a?.sourceBotId?e.bots.find(r=>r.larkAppId===a.sourceBotId):null;return(0,u.jsxs)("section",{className:"skills-config-block",children:[(0,u.jsx)(ue,{title:l("skills.bots"),count:l("skills.botCount",{count:e.bots.length}),hint:l("skills.botsHelp")}),(0,u.jsxs)("div",{className:"skills-bot-assign-layout",children:[(0,u.jsxs)("div",{className:"skills-bot-palette",children:[(0,u.jsxs)("div",{className:"skills-bot-palette-hint",children:[(0,u.jsx)("span",{className:"skills-drag-icon",children:"\u2927"}),(0,u.jsx)("span",{children:l("skills.dragHint")})]}),a?.sourceBotId?(0,u.jsxs)("div",{className:`skills-unassign-dropzone${g?" is-active":""}`,"data-action":"unassign-dropzone","data-drag-over":g||void 0,role:"status","aria-live":"polite",onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move",w(!0)},onDragLeave:r=>{r.currentTarget.contains(r.relatedTarget)||w(!1)},onDrop:r=>{r.preventDefault(),d().catch(()=>{})},children:[(0,u.jsx)("span",{className:"skills-unassign-icon","aria-hidden":"true",children:"\u21A9"}),(0,u.jsxs)("span",{children:[(0,u.jsx)("strong",{children:l("skills.unassignDropTitle")}),(0,u.jsx)("small",{children:l("skills.unassignDropHint",{bot:te?.botName??a.sourceBotId})})]})]}):null,e.packs.length>0&&(0,u.jsxs)("div",{className:"skills-bot-palette-group",children:[(0,u.jsx)("span",{className:"skills-bot-palette-label",children:l("skills.packChips")}),(0,u.jsx)("div",{className:"skills-bot-palette-items",children:e.packs.map(r=>(0,u.jsx)("span",{className:"skills-draggable-chip skills-pack-chip",draggable:!0,"data-palette-drag-type":"pack","data-palette-drag-id":r.id,onDragStart:i=>G(i,{type:"pack",id:r.id},"copy"),onDragEnd:U,title:`${r.name} (${l("skills.skillCount",{count:r.include.length})})`,children:r.name},r.id))})]}),(0,u.jsxs)("div",{className:"skills-bot-palette-group",children:[(0,u.jsx)("span",{className:"skills-bot-palette-label",children:l("skills.individualSkills")}),(0,u.jsx)("input",{className:"skills-bot-palette-search",type:"text",placeholder:l("skills.searchPlaceholder"),value:P,onChange:r=>N(r.target.value)}),y.length>0&&(0,u.jsxs)("div",{className:"skills-bot-palette-tags",children:[(0,u.jsx)("button",{className:`skills-tag-filter${h===null?" active":""}`,onClick:()=>x(null),children:l("skills.all")}),y.map(r=>(0,u.jsx)("button",{className:`skills-tag-filter${h===r?" active":""}`,onClick:()=>x(h===r?null:r),children:r},r))]}),(0,u.jsxs)("div",{className:"skills-bot-palette-items",children:[f.map(r=>(0,u.jsx)("span",{className:"skills-draggable-chip skills-skill-chip",draggable:!0,"data-palette-drag-type":"skill","data-palette-drag-id":r.name,onDragStart:i=>G(i,{type:"skill",id:r.name},"copy"),onDragEnd:U,title:r.description??r.name,children:r.name},r.name)),f.length===0&&(0,u.jsx)("span",{className:"muted",children:l("skills.noResults")})]})]})]}),(0,u.jsx)("article",{className:"bd-card skills-config-card skills-bot-table-wrap",children:(0,u.jsx)("div",{className:"skills-bot-table",children:(0,u.jsxs)("table",{children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:l("skills.bot")}),(0,u.jsx)("th",{children:l("skills.packChips")}),(0,u.jsx)("th",{children:l("skills.individualSkills")}),(0,u.jsx)("th",{children:l("skills.finalCount")}),(0,u.jsx)("th",{children:l("skills.health")}),(0,u.jsx)("th",{})]})}),(0,u.jsx)("tbody",{children:e.bots.map(r=>{let i=ke(r.skills),M=be(r.skills),R=F.bots.get(r.larkAppId),_=R?.finalCount??0,V=vs(R,l),he=v===r.larkAppId,fe=E.has(r.larkAppId)||L!=null&&(R?.resolved.some(W=>W.name===L)??!1),ye=B?.botId===r.larkAppId?B:null,le=e.statuses[r.larkAppId]??null,se=e.busyBotIds?.has(r.larkAppId)===!0;return(0,u.jsxs)("tr",{className:`skills-bot-row${he?" drag-over":""}${fe?" skills-bot-row-focus":""}${se?" is-busy":""}`,"aria-busy":se,onDragOver:W=>{se||!a||a.sourceBotId||(W.preventDefault(),W.dataTransfer.dropEffect="copy",p(r.larkAppId))},onDragLeave:W=>{W.currentTarget.contains(W.relatedTarget)||p(Y=>Y===r.larkAppId?null:Y)},onDrop:W=>{se||!a||a.sourceBotId||(W.preventDefault(),I(r).catch(()=>{}))},children:[(0,u.jsx)("td",{children:r.botName??r.larkAppId}),(0,u.jsx)("td",{children:(0,u.jsx)("div",{className:"skills-pack-chips",children:M.length===0?(0,u.jsx)("span",{className:"muted",children:"\u2014"}):M.map(W=>{let Y=e.packs.find(Se=>Se.id===W),we=!Y&&e.packsKnown===!1,Me=!Y&&!we;return(0,u.jsx)("span",{className:`skills-assigned-draggable${a?.sourceBotId===r.larkAppId&&a.type==="pack"&&a.id===W?" is-dragging":""}`,draggable:!se,"data-assigned-drag-type":"pack","data-assigned-drag-id":W,"data-assigned-bot":r.larkAppId,title:l("skills.dragToRemove"),onDragStart:Se=>{se||G(Se,{type:"pack",id:W,sourceBotId:r.larkAppId},"move")},onDragEnd:U,children:(0,u.jsx)("button",{type:"button",className:`skills-pack-chip${Me?" skills-chip-missing":""}${we?" skills-chip-unknown":""}`,"data-action":"open-bot-pack",title:we?l("skills.healthUnknown"):void 0,disabled:!Y||!e.onOpenPack,onClick:()=>e.onOpenPack?.(W),children:Y?.name??W})},W)})})}),(0,u.jsx)("td",{children:i.length===0?(0,u.jsx)("span",{className:"muted",children:"\u2014"}):(0,u.jsxs)("span",{className:"skills-skill-chips",children:[i.slice(0,3).map(W=>(0,u.jsx)("span",{className:`skills-assigned-draggable${a?.sourceBotId===r.larkAppId&&a.type==="skill"&&a.id===W?" is-dragging":""}`,draggable:!se,"data-assigned-drag-type":"skill","data-assigned-drag-id":W,"data-assigned-bot":r.larkAppId,title:l("skills.dragToRemove"),onDragStart:Y=>{se||G(Y,{type:"skill",id:W,sourceBotId:r.larkAppId},"move")},onDragEnd:U,children:(0,u.jsx)("button",{type:"button",className:"skills-skill-chip","data-action":"open-bot-skill",disabled:!e.onOpenSkill,onClick:()=>e.onOpenSkill?.(W),children:W})},W)),i.length>3&&(0,u.jsxs)("span",{className:"muted",children:["+",i.length-3]})]})}),(0,u.jsx)("td",{children:R?.health==="unknown"?(0,u.jsx)("span",{className:"muted",title:l("skills.healthUnknown"),children:"\u2014"}):_}),(0,u.jsx)("td",{children:(0,u.jsx)("span",{className:`skills-health skills-health-${V.level}`,children:V.label})}),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"skills-bot-row-actions",children:[ye?(0,u.jsx)("span",{className:"skills-duplicate-feedback",role:"status","aria-live":"polite",children:l("skills.alreadyAssigned",{item:ye.itemLabel})}):null,le?(0,u.jsx)("span",{className:`oncall-status ${le.ok?"hint-ok":"hint-warn-inline"}`,role:"status","aria-live":"polite",children:le.text}):se?(0,u.jsx)("span",{className:"oncall-status",role:"status","aria-live":"polite",children:l("skills.saving")}):null,(0,u.jsx)("button",{className:"bd-button",disabled:se,onClick:()=>m(r),children:l("skills.select")})]})})]},r.larkAppId)})})]})})})]}),n&&(0,u.jsx)(bs,{bot:n,skills:e.skills,packs:e.packs,status:e.statuses[n.larkAppId]??null,onClose:()=>m(null),onSave:(r,i)=>e.onSave(n.larkAppId,r,i)})]})}function vs(e,l){switch(e?.health){case"pack_missing":return{level:"error",label:l("skills.healthPackMissing")};case"missing":return{level:"warn",label:l("skills.healthMissing",{count:e.missingSkills.length})};case"unknown":return{level:"unknown",label:l("skills.healthUnknown")};case"default":case void 0:return{level:"ok",label:l("skills.healthDefault")};default:return{level:"ok",label:l("skills.healthOk")}}}function bs(e){let l=X(),n=(0,Q.useMemo)(()=>ke(e.bot.skills),[e.bot.skills]),m=(0,Q.useMemo)(()=>be(e.bot.skills),[e.bot.skills]),[v,p]=(0,Q.useState)(()=>new Set(n)),[g,w]=(0,Q.useState)(()=>new Set(m)),[a,C]=(0,Q.useState)(!1),B=h=>{p(x=>{let E=new Set(x);return E.has(h)?E.delete(h):E.add(h),E})},b=h=>{w(x=>{let E=new Set(x);return E.has(h)?E.delete(h):E.add(h),E})},P=(0,Q.useMemo)(()=>{let h=new Map;for(let x of v)h.set(x,"direct");for(let x of g){let E=e.packs.find(T=>T.id===x);if(E)for(let T of E.include){let L=T.replace("skill:","");h.has(L)||h.set(L,`pack:${E.name}`)}}return[...h.entries()].map(([x,E])=>({name:x,source:E}))},[v,g,e.packs]),N=async()=>{C(!0);try{await e.onSave([...v],[...g]),e.onClose()}finally{C(!1)}};return(0,u.jsx)("dialog",{className:"bd-dialog skills-bot-editor",open:!0,onClose:e.onClose,children:(0,u.jsxs)("form",{method:"dialog","data-action":"save-bot-assignment",onSubmit:h=>{h.preventDefault(),N().catch(()=>{})},children:[(0,u.jsxs)("h3",{children:[l("skills.botEdit"),": ",e.bot.botName??e.bot.larkAppId]}),e.status&&(0,u.jsx)("p",{className:`hint-${e.status.ok?"ok":"warn"}`,children:e.status.text}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsx)("label",{children:l("skills.packChips")}),(0,u.jsxs)("div",{className:"skills-pack-skill-list",children:[e.packs.map(h=>(0,u.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,u.jsx)("input",{type:"checkbox",checked:g.has(h.id),onChange:()=>b(h.id)}),(0,u.jsx)("span",{children:h.name}),(0,u.jsx)("small",{children:l("skills.skillCount",{count:h.include.length})})]},h.id)),e.packs.length===0&&(0,u.jsx)("small",{className:"muted",children:l("skills.packsEmpty")})]})]}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsxs)("label",{children:[l("skills.individualSkills")," (",l("skills.advanced"),")"]}),(0,u.jsx)("div",{className:"skills-pack-skill-list",children:e.skills.map(h=>(0,u.jsxs)("label",{className:"skills-pack-skill-item",children:[(0,u.jsx)("input",{type:"checkbox",checked:v.has(h.name),onChange:()=>B(h.name)}),(0,u.jsx)("span",{children:h.name})]},h.name))})]}),(0,u.jsxs)("div",{className:"skills-control-block",children:[(0,u.jsxs)("label",{children:[l("skills.resolvedPreview")," (",P.length,")"]}),(0,u.jsx)("div",{className:"skills-resolved-preview",children:P.map(({name:h,source:x})=>(0,u.jsxs)("div",{className:"skills-resolved-item",children:[(0,u.jsx)("span",{children:h}),(0,u.jsx)("small",{className:"muted",children:x})]},h))})]}),(0,u.jsxs)("div",{className:"skills-dialog-actions",children:[(0,u.jsx)("button",{type:"button",className:"bd-button",onClick:e.onClose,children:l("skills.cancel")}),(0,u.jsx)("button",{type:"submit",className:"bd-button primary",disabled:a,children:l(a?"skills.saving":"skills.saveSelection")})]})]})})}var O=ee(de(),1);function Al(e){let l=X(),{SkillSegmented:n}=e;return(0,O.jsxs)("div",{className:"skills-page-stack",children:[(0,O.jsxs)("section",{className:"skills-config-block",children:[(0,O.jsx)(ue,{title:l("skills.globalDefaults")}),(0,O.jsxs)("article",{className:"bd-card skills-defaults-panel skills-config-card",children:[(0,O.jsxs)("div",{className:"skills-control-block",children:[(0,O.jsx)("span",{className:"skills-control-label",children:l("skills.globalProject")}),(0,O.jsx)(n,{value:e.trustProjectSkills,disabled:e.globalBusy==="project",options:[{value:"off",label:l("skills.globalProjectOff"),help:l("skills.globalProjectOffHelp")},{value:"all",label:l("skills.globalProjectAll"),help:l("skills.globalProjectAllHelp")}],onChange:m=>e.onUpdateProject(m)})]}),(0,O.jsxs)("div",{className:"skills-control-block",children:[(0,O.jsxs)("span",{className:"skills-control-label",children:[l("skills.globalDelivery"),(0,O.jsx)("small",{className:"skills-scope-note",children:l("skills.scopeGlobal")})]}),(0,O.jsx)(n,{value:e.delivery,disabled:e.globalBusy==="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:m=>e.onUpdateDelivery(m)})]})]})]}),(0,O.jsxs)("section",{className:"skills-config-block",children:[(0,O.jsx)(ue,{title:l("skills.botInjection"),hint:l("skills.botInjectionHelp")}),(0,O.jsxs)("article",{className:"bd-card skills-config-card",children:[(0,O.jsx)("p",{className:"skills-injection-note",children:l("skills.botInjectionNote")}),(0,O.jsx)("div",{className:"skills-bot-injection-table",children:(0,O.jsxs)("table",{children:[(0,O.jsx)("thead",{children:(0,O.jsxs)("tr",{children:[(0,O.jsx)("th",{children:l("skills.bot")}),(0,O.jsx)("th",{children:l("skills.cli")}),(0,O.jsx)("th",{children:l("skills.injection")}),(0,O.jsx)("th",{children:l("skills.status")})]})}),(0,O.jsx)("tbody",{children:e.bots.map(m=>(0,O.jsxs)("tr",{children:[(0,O.jsx)("td",{children:m.botName??m.larkAppId}),(0,O.jsx)("td",{children:(0,O.jsx)("code",{children:m.cliId??""})}),(0,O.jsx)("td",{children:(0,O.jsx)(n,{value:m.skillInjection??m.skillInjectionDefault??"prompt",options:[{value:"global",label:l("skills.injectionGlobal"),help:l("skills.injectionGlobalHelp")},{value:"prompt",label:l("skills.injectionPrompt"),help:l("skills.injectionPromptHelp")},{value:"off",label:l("skills.injectionOff"),help:l("skills.injectionOffHelp")}],onChange:v=>e.onUpdateBotInjection(m.larkAppId,v)})}),(0,O.jsx)("td",{children:e.botStatuses[m.larkAppId]?(0,O.jsx)("span",{className:`hint-${e.botStatuses[m.larkAppId].ok?"ok":"warn"}`,children:e.botStatuses[m.larkAppId].text}):null})]},m.larkAppId))})]})})]})]})]})}var Z=ee(Be(),1);function Bl(e){let l=(0,Z.useRef)(!0),[n,m]=(0,Z.useState)([]),[v,p]=(0,Z.useState)([]),[g,w]=(0,Z.useState)([]),[a,C]=(0,Z.useState)([]),[B,b]=(0,Z.useState)("off"),[P,N]=(0,Z.useState)("auto"),[h,x]=(0,Z.useState)(!0),[E,T]=(0,Z.useState)(null),[L,A]=(0,Z.useState)(null),[$,H]=(0,Z.useState)(!1),K=(0,Z.useRef)(e.apiUnavailableText);K.current=e.apiUnavailableText;let F=(0,Z.useCallback)(async()=>{x(!0);try{let[y,f,I]=await Promise.all([fetch("/api/skills"),fetch("/api/bots"),fetch("/api/skill-packs").catch(()=>null)]),d=await y.json().catch(()=>({})),U=await f.json().catch(()=>({})),G=I?await I.json().catch(()=>({})):{};if(!y.ok){let te=d?.error??`skills HTTP ${y.status}`;throw new Error(te==="not_found_yet"||te==="not_found"?K.current:te)}if(!f.ok)throw new Error(U?.error??`bots HTTP ${f.status}`);if(!l.current)return;m(Array.isArray(d.skills)?d.skills:[]),p(Array.isArray(d.nativeSkillGroups)?d.nativeSkillGroups:[]),w(Array.isArray(U.bots)?U.bots:[]),I?.ok&&Array.isArray(G.packs)?(C(G.packs),A(null),H(!0)):I?.status===404?(C([]),A(null),H(!0)):A(I?G?.error??`HTTP ${I.status}`:"network_error"),b(d.trustProjectSkills==="all"?"all":"off"),N(d.delivery==="prompt"||d.delivery==="native"?d.delivery:"auto"),T(null)}catch(y){l.current&&T(y?.message??String(y))}finally{l.current&&x(!1)}},[]);return(0,Z.useEffect)(()=>(l.current=!0,F(),()=>{l.current=!1}),[F]),{skills:n,nativeSkillGroups:v,bots:g,packs:a,trustProjectSkills:B,delivery:P,loading:h,loadError:E,packsError:L,packsKnown:$,refresh:F,setSkills:m,setBots:w,setTrustProjectSkills:b,setDelivery:N}}var s=ee(de(),1),hs=2;function ys(e){return e>=1600?4:e<=620?1:e<=980?2:3}async function re(e,l){let n=await fetch(e,{...l,headers:{"content-type":"application/json",...l.headers??{}}}),m=await n.json().catch(()=>({}));if(!n.ok||m.ok===!1){let v=new Error(m?.error??`HTTP ${n.status}`);throw v.status=n.status,v.body=m,v}return m}function nl(e){return`oncall-status${e?` ${e.ok?"hint-ok":"hint-warn-inline"}`:""}`}function Ss(e){let l=e.options.find(n=>n.value===e.value);return(0,s.jsxs)("div",{className:"skills-segmented-control",children:[(0,s.jsx)("div",{className:"segmented skills-segmented",role:"group",children:e.options.map(n=>(0,s.jsx)("button",{type:"button",className:e.value===n.value?"active":"","aria-pressed":e.value===n.value?"true":"false",title:typeof n.help=="string"?n.help:void 0,disabled:e.disabled,onClick:()=>e.onChange(n.value),children:n.label},n.value))}),l?.help?(0,s.jsx)("span",{className:"skills-setting-hint",children:l.help}):null]})}function Ns(e){let l=X(),n=(0,c.useRef)(null),m=(0,c.useRef)(null),v=(0,c.useId)(),p=`${v}-input`,g=`${v}-title`,[w,a]=(0,c.useState)(!1),C=e.installCandidates??[],B=e.selectedInstallSkills??new Set,b=C.length>0&&C.every(T=>B.has(T.name)),P=e.installBusy||e.installDiscovering,N=ll(e.installSource),h=l(N==="github"?"skills.sourceDetectedGithub":N==="git"?"skills.sourceDetectedGit":N==="agentbuddy"?"skills.sourceDetectedAgentbuddy":N==="local"?"skills.sourceDetectedLocal":"skills.sourceDetectedUnknown"),x=l(N==="agentbuddy"?"skills.sourcePreflightAgentbuddy":N==="github"||N==="git"?"skills.sourcePreflightGit":N==="local"?"skills.sourcePreflightLocal":"skills.sourcePreflightUnknown"),E=l(N==="agentbuddy"?"skills.installDiagnosticAgentbuddy":N==="github"||N==="git"?"skills.installDiagnosticGit":N==="local"?"skills.installDiagnosticLocal":"skills.installDiagnosticUnknown");return(0,c.useEffect)(()=>{let T=n.current;if(T)if(e.installSelectionOpen&&!T.open)try{T.showModal()}catch{}else!e.installSelectionOpen&&T.open&&T.close()},[e.installSelectionOpen,C.length]),(0,c.useEffect)(()=>{if(!w||typeof document>"u")return;let T=A=>{m.current?.contains(A.target)||a(!1)},L=A=>{A.key==="Escape"&&a(!1)};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",L)}},[w]),(0,s.jsxs)("article",{className:"bd-card skills-install-panel",children:[e.showTitle===!1?null:(0,s.jsx)("div",{className:"skills-install-title",children:(0,s.jsx)("h3",{className:"bd-section-title",children:(0,s.jsx)(yl,{help:l("skills.installInfo"),helpLabel:l("skills.installInfoLabel"),children:l("skills.install")})})}),e.installTargetSkill?(0,s.jsxs)("div",{className:"skills-inline-target","data-install-target":e.installTargetSkill,children:[(0,s.jsx)("span",{children:l("skills.installTargetHint",{skill:e.installTargetSkill})}),(0,s.jsx)("button",{type:"button","data-action":"clear-install-target",onClick:()=>e.onClearInstallTarget?.(),children:l("skills.clearInstallTarget")})]}):null,(0,s.jsxs)("div",{className:"skills-install-grid",children:[(0,s.jsxs)("div",{className:"skills-source-label",children:[(0,s.jsxs)("div",{className:"skills-source-heading",ref:m,onKeyDown:T=>{T.key==="Escape"&&a(!1)},children:[(0,s.jsx)("label",{htmlFor:p,children:l("skills.source")}),(0,s.jsx)("button",{type:"button",className:"skills-source-help-trigger","data-action":"toggle-source-help","aria-label":l("skills.sourceHelpOpen"),"aria-expanded":w,"aria-controls":v,"aria-haspopup":"dialog",onClick:()=>a(T=>!T),children:"?"}),w?(0,s.jsxs)("aside",{className:"skills-source-help-popover",id:v,role:"dialog","aria-labelledby":g,"data-source-help-popover":!0,children:[(0,s.jsxs)("div",{className:"skills-source-help-head",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{id:g,children:l("skills.sourceHelpTitle")}),(0,s.jsx)("span",{children:l("skills.sourceHelpIntro")})]}),(0,s.jsx)("button",{type:"button",className:"skills-source-help-close","data-action":"close-source-help","aria-label":l("skills.sourceHelpClose"),onClick:()=>a(!1),children:"\xD7"})]}),(0,s.jsxs)("div",{className:"skills-source-help-list",children:[(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpRemoteLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpRemote")}),(0,s.jsx)("code",{children:l("skills.sourceHelpRemoteExample")})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpLocalLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpLocal")}),(0,s.jsx)("code",{children:l("skills.sourceHelpLocalExample")})]}),(0,s.jsxs)("section",{children:[(0,s.jsx)("strong",{children:l("skills.sourceHelpAgentbuddyLabel")}),(0,s.jsx)("span",{children:l("skills.sourceHelpAgentbuddy")}),(0,s.jsx)("code",{children:l("skills.sourceHelpAgentbuddyExample")})]})]})]}):null]}),(0,s.jsx)("div",{className:"skills-source-control",children:(0,s.jsx)("input",{id:p,type:"text","data-install":"source","aria-label":l("skills.source"),placeholder:l("skills.sourcePlaceholder"),value:e.installSource,onChange:T=>e.onInstallSourceChange(T.currentTarget.value)})}),e.installSource.trim()?(0,s.jsxs)("div",{className:`skills-source-feedback is-${N}`,"data-source-hint":N,children:[(0,s.jsx)("strong",{children:h}),(0,s.jsx)("span",{children:x})]}):null]}),(0,s.jsxs)("details",{className:"skills-install-advanced","data-install-advanced":!0,children:[(0,s.jsx)("summary",{children:l("skills.advancedOptions")}),(0,s.jsxs)("div",{className:"skills-install-advanced-body",children:[(0,s.jsxs)("label",{className:"skills-install-field",children:[(0,s.jsx)("span",{children:l("skills.path")}),(0,s.jsx)("input",{type:"text","data-install":"path",placeholder:l("skills.pathPlaceholder"),value:e.installPath,onChange:T=>e.onInstallPathChange(T.currentTarget.value)}),(0,s.jsx)("small",{children:l("skills.pathHelpInline")})]}),(0,s.jsxs)("label",{className:"skills-install-field",children:[(0,s.jsx)("span",{children:l("skills.ref")}),(0,s.jsx)("input",{type:"text","data-install":"ref",placeholder:l("skills.refPlaceholder"),value:e.installRef,onChange:T=>e.onInstallRefChange(T.currentTarget.value)}),(0,s.jsx)("small",{children:l("skills.refHelpInline")})]}),(0,s.jsxs)("label",{className:"skills-scan-toggle",children:[(0,s.jsx)("input",{type:"checkbox","data-install":"full-depth",checked:e.installFullDepth,disabled:P,onChange:T=>e.onInstallFullDepthChange(T.currentTarget.checked)}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:l("skills.deepScan")}),(0,s.jsx)("small",{children:l("skills.deepScanHelp")}),(0,s.jsx)("small",{className:"muted",children:l("skills.autoDeepScanHint")})]})]})]})]}),(0,s.jsxs)("div",{className:"skills-install-actions",children:[(0,s.jsx)("button",{type:"button",className:"skills-local-discovery-link","data-action":"open-native-skill-discovery",title:l("skills.localDiscoverHelp"),onClick:()=>e.onOpenNativeDiscovery(),children:l("skills.localDiscover")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"install",disabled:P||!e.installSource.trim(),onClick:()=>e.onInstall(),children:e.installDiscovering?l("skills.scanning"):e.installBusy?l("skills.jobRunning"):l("skills.installSubmit")})]})]}),e.installStatus?(0,s.jsx)("div",{className:"actions skills-install-status-row",children:(0,s.jsx)("span",{className:nl(e.installStatus),"data-skills-status":!0,children:e.installStatus.text})}):null,e.installStatus&&!e.installStatus.ok?(0,s.jsxs)("div",{className:"skills-install-diagnostic","data-install-diagnostic":N,role:"alert",children:[(0,s.jsx)("strong",{children:l("skills.installDiagnosticTitle")}),(0,s.jsx)("span",{children:E})]}):null,(0,s.jsx)("dialog",{className:"skills-discovery-dialog skills-install-selection-dialog","data-install-selection-dialog":!0,ref:n,onClose:()=>e.onCloseInstallSelection?.(),children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:l("skills.installSelectionTitle")}),(0,s.jsx)("p",{children:l("skills.installSelectionHelp",{count:C.length})})]}),(0,s.jsx)("div",{className:"skills-discovery-body skills-install-selection-body",children:(0,s.jsxs)("div",{className:"skills-candidate-list","data-install-candidates":!0,children:[(0,s.jsxs)("div",{className:"skills-candidate-list-head",children:[(0,s.jsx)("span",{children:l("skills.scanFound",{count:C.length})}),e.onSelectAllInstallSkills?(0,s.jsx)("button",{type:"button","data-action":"toggle-all-source-skills",disabled:e.installBusy,onClick:()=>e.onSelectAllInstallSkills?.(!b),children:l(b?"skills.discoverClearSelection":"skills.discoverSelectAll")}):null]}),C.map(T=>(0,s.jsxs)("label",{className:"skills-candidate-row",children:[(0,s.jsx)("input",{type:"checkbox",checked:B.has(T.name),disabled:e.installBusy,onChange:()=>e.onToggleInstallSkill?.(T.name)}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:T.name}),(0,s.jsxs)("small",{children:[T.path,T.description?` \xB7 ${T.description}`:""]})]})]},`${T.name}:${T.path}`))]})}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button","data-action":"close-install-selection",disabled:e.installBusy,onClick:()=>e.onCloseInstallSelection?.(),children:l("skills.installSelectionCancel")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"confirm-install-selection",disabled:e.installBusy||B.size===0,onClick:()=>e.onConfirmInstallSelection?.(),children:e.installBusy?l("skills.jobRunning"):l("skills.installSelected")})]})]})})]})}function Is(e){let l=X(),n=(0,c.useRef)(null),m=(0,c.useRef)(new Set(e.skills.map(i=>i.name))),v=(0,c.useRef)(""),p=(0,c.useRef)(!1),g=(0,c.useRef)(null),[w,a]=(0,c.useState)(""),[C,B]=(0,c.useState)(!1),[b,P]=(0,c.useState)(()=>new Set),[N,h]=(0,c.useState)(null),[x,E]=(0,c.useState)(0),[T,L]=(0,c.useState)(()=>typeof window>"u"?1200:window.innerWidth),A=w.trim().toLocaleLowerCase();v.current=w,p.current=C;let $=(0,c.useMemo)(()=>{let i=N?e.skills.filter(M=>N.has(M.name)):e.skills;return A?i.filter(M=>[M.name,M.displayName,M.description,...M.tags??[],sl(M,l)].filter(Boolean).join(`
|
|
3
3
|
`).toLocaleLowerCase().includes(A)):i},[N,A,e.skills,l]),H=(0,c.useMemo)(()=>{if(!N)return[];let i=new Set(e.skills.map(M=>M.name));return[...N].filter(M=>!i.has(M)).sort()},[N,e.skills]),K=ys(T)*hs,F=Math.max(1,Math.ceil($.length/K)),y=$.slice(x*K,x*K+K),f=(0,c.useMemo)(()=>new Set($.map(i=>i.name)),[$]),I=$.filter(i=>b.has(i.name)).length,d=Math.max(0,b.size-I),U=$.length>0&&I===$.length;(0,c.useEffect)(()=>{if(typeof window>"u")return;let i=()=>L(window.innerWidth);return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),(0,c.useEffect)(()=>{e.externalQuery!=null&&e.externalQuery!==""&&a(e.externalQuery)},[e.externalQuery]),(0,c.useEffect)(()=>{e.externalFilterNames&&e.externalFilterNames.length>0&&h(new Set(e.externalFilterNames))},[e.externalFilterNames]),(0,c.useEffect)(()=>E(0),[A,K,N]),(0,c.useEffect)(()=>{E(i=>Math.min(Math.max(0,i),F-1))},[F]),(0,c.useEffect)(()=>{let i=new Set(e.skills.map(R=>R.name)),M=[...m.current].some(R=>!i.has(R));P(R=>{let _=new Set([...R].filter(V=>i.has(V)));return _.size===R.size?R:_}),M&&(B(!1),P(new Set)),m.current=i},[e.skills]),(0,c.useEffect)(()=>{n.current&&(n.current.indeterminate=I>0&&!U)},[U,I]),(0,c.useEffect)(()=>{if(typeof document>"u")return;let i=R=>{if(R.key!=="Escape"||!p.current)return;let _=v.current;g.current=_,R.preventDefault(),R.stopPropagation(),B(!1),P(new Set),window.setTimeout(()=>{a(V=>V||_),g.current=null},50)},M=R=>{if(R.key!=="Escape"||g.current===null)return;let _=g.current;g.current=null,R.preventDefault(),R.stopPropagation(),a(_)};return document.addEventListener("keydown",i,!0),document.addEventListener("keyup",M,!0),()=>{document.removeEventListener("keydown",i,!0),document.removeEventListener("keyup",M,!0)}},[]);function G(i){P(M=>{let R=new Set(M);return R.has(i)?R.delete(i):R.add(i),R})}function te(){P(i=>{let M=new Set(i);if(U)for(let R of f)M.delete(R);else for(let R of f)M.add(R);return M})}function r(i=!1){let M=w;B(!1),P(new Set),i&&typeof window<"u"&&window.setTimeout(()=>a(M),0)}return(0,s.jsxs)("section",{className:"skills-installed-block",children:[(0,s.jsx)(ue,{title:l("skills.installed"),count:l("skills.installedCount",{count:e.skills.length}),hint:l("skills.installedHelp"),children:(0,s.jsx)("div",{className:"skills-installed-header-actions",children:C?(0,s.jsx)("button",{type:"button","data-action":"cancel-installed-selection",onClick:()=>r(),children:l("skills.cancel")}):(0,s.jsx)("button",{type:"button","data-action":"select-installed-skills",disabled:e.skills.length===0,onClick:()=>B(!0),children:l("skills.select")})})}),(0,s.jsxs)("section",{className:"bd-card skills-installed-panel",children:[(0,s.jsxs)("div",{className:"skills-library-toolbar",children:[(0,s.jsxs)("label",{className:"skills-installed-search",children:[(0,s.jsx)("span",{className:"sr-only",children:l("skills.searchLabel")}),(0,s.jsx)("input",{type:"text",role:"searchbox",inputMode:"search","data-action":"search-installed-skills",placeholder:l("skills.searchPlaceholder"),value:w,onChange:i=>a(i.currentTarget.value),onKeyDown:i=>{i.key!=="Escape"||!C||(i.preventDefault(),i.stopPropagation(),r(!0))}}),w?(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search","aria-label":l("skills.clearSearch"),onClick:()=>a(""),children:"\xD7"}):null]}),C?(0,s.jsxs)("label",{className:"skills-select-all-results",children:[(0,s.jsx)("input",{ref:n,type:"checkbox",checked:U,disabled:$.length===0||e.removingNames.size>0,onChange:te}),(0,s.jsx)("span",{children:A?l("skills.selectSearchResults",{count:$.length}):l("skills.selectAllSkills",{count:$.length})})]}):null,N?(0,s.jsxs)("button",{type:"button",className:"skills-library-filter-chip","data-action":"clear-library-filter",title:[...N].join(", "),"aria-label":l("skills.clearFilter"),onClick:()=>h(null),children:[l("skills.libraryFilterActive",{count:N.size})," \xD7"]}):null,A?(0,s.jsx)("span",{className:"skills-filter-count",children:l("skills.resultCount",{count:$.length})}):null,F>1?(0,s.jsxs)("div",{className:"skills-pager",children:[(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"-1","aria-label":l("skills.prevPage"),title:l("skills.prevPage"),disabled:x===0,onClick:()=>E(i=>Math.max(0,i-1)),children:"\u2039"}),(0,s.jsx)("span",{children:l("skills.pageStatus",{page:x+1,pages:F})}),(0,s.jsx)("button",{type:"button",className:"skills-pager-button","data-action":"page-installed-skills","data-dir":"1","aria-label":l("skills.nextPage"),title:l("skills.nextPage"),disabled:x>=F-1,onClick:()=>E(i=>Math.min(F-1,i+1)),children:"\u203A"})]}):null]}),(0,s.jsx)("div",{className:"skills-installed-live",role:"status","aria-live":"polite",children:e.status?(0,s.jsx)("span",{className:nl(e.status),children:e.status.text}):null}),H.length>0&&(0,s.jsxs)("div",{className:"skills-missing-list","data-missing-skills":!0,children:[(0,s.jsx)("strong",{children:l("skills.missingFilteredTitle")}),H.map(i=>(0,s.jsxs)("div",{className:"skills-missing-row","data-missing-skill":i,children:[(0,s.jsx)("span",{className:"skills-missing-row-name",children:i}),(0,s.jsx)("small",{className:"muted",children:l("skills.dangling")}),(0,s.jsx)("button",{type:"button","data-action":"install-dangling-skill",disabled:!e.onInstallMissing,onClick:()=>e.onInstallMissing?.(i),children:l("skills.installNow")})]},i))]}),e.skills.length===0?(0,s.jsxs)("div",{className:"skills-library-empty",children:[(0,s.jsx)("strong",{children:l("skills.emptyTitle")}),(0,s.jsx)("p",{children:l("skills.emptyHelp")})]}):$.length===0&&H.length>0?null:$.length===0?(0,s.jsxs)("div",{className:"skills-library-empty","data-empty":"search",children:[(0,s.jsx)("strong",{children:l("skills.noResultsTitle",{query:w.trim()})}),(0,s.jsx)("p",{children:l("skills.noResultsHelp")}),(0,s.jsx)("button",{type:"button","data-action":"clear-installed-search-empty",onClick:()=>a(""),children:l("skills.clearSearch")})]}):(0,s.jsx)("div",{className:"skills-list",children:y.map(i=>{let M=b.has(i.name),R=e.removingNames.has(i.name);return(0,s.jsxs)("article",{className:`skills-row skills-installed-card${C?" is-selectable":""}${M?" is-selected":""}${R?" is-removing":""}`,"data-skill":i.name,"data-selection-mode":C?"true":void 0,"aria-busy":R||void 0,onClick:C?()=>G(i.name):void 0,children:[(0,s.jsxs)("div",{className:"skills-row-body",children:[(0,s.jsxs)("div",{className:"skills-row-title",children:[C?(0,s.jsx)("input",{type:"checkbox","aria-label":l("skills.selectNamed",{skill:i.displayName??i.name}),checked:M,disabled:R,onClick:_=>_.stopPropagation(),onChange:()=>G(i.name)}):null,(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:i.displayName??i.name}),i.displayName&&i.displayName!==i.name?(0,s.jsx)("small",{className:"skills-canonical-name",children:i.name}):null]})]}),i.description?(0,s.jsx)("p",{children:i.description}):null,(0,s.jsx)("small",{className:"skills-source-badge",children:sl(i,l)}),e.graph?(()=>{let _=e.graph.skills.get(i.name),V=e.packsKnown===!1,he=_?.packIds.length??0,fe=_?new Set([..._.directBotIds,..._.viaPackBotIds]).size:0,ye=V?l("skills.healthUnknown"):(_?.packIds??[]).map(le=>e.packNames?.find(se=>se.id===le)?.name??le).join(", ");return(0,s.jsxs)("span",{className:"skills-usage-chips",children:[(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-packs",disabled:V||he===0||!e.onShowSkillPacks,title:ye||void 0,onClick:le=>{le.stopPropagation(),e.onShowSkillPacks?.(i.name)},children:V?l("skills.usedInPacksUnknown"):l("skills.usedInPacks",{count:he})}),(0,s.jsx)("button",{type:"button",className:"skills-usage-chip","data-action":"show-skill-bots",disabled:fe===0||!e.onShowSkillBots,onClick:le=>{le.stopPropagation(),e.onShowSkillBots?.(i.name)},children:l("skills.usedByBots",{count:fe})})]})})():null,R?(0,s.jsx)("span",{className:"skills-removing-label",children:l("skills.removing")}):null]}),C?null:(0,s.jsxs)("div",{className:"skills-card-actions",children:[(0,s.jsx)("button",{type:"button","data-action":"update-skill",disabled:e.busySkill===`${i.name}:update`||R,onClick:()=>e.onUpdate(i.name),children:l("skills.update")}),(0,s.jsx)("button",{type:"button","data-action":"remove-skill",disabled:R,onClick:()=>e.onRequestRemove([i.name]),children:l("skills.remove")})]})]},i.name)})})]}),C?(0,s.jsxs)("div",{className:"skills-bulk-action-bar",role:"toolbar","aria-label":l("skills.bulkActions"),children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:l("skills.selectedCount",{count:b.size})}),d>0?(0,s.jsx)("small",{children:l("skills.selectedHidden",{count:d})}):null]}),(0,s.jsx)("button",{type:"button",className:"danger","data-action":"remove-selected-skills",disabled:b.size===0||e.removingNames.size>0,onClick:()=>e.onRequestRemove([...b]),children:l("skills.removeSelected",{count:b.size})})]}):null]})}function ws(e){let l=X(),n=(0,c.useRef)(null),m=e.names??[],v=e.references.length>0,p=m.slice(0,3),g=new Set(e.references.flatMap(a=>a.bots)).size,w=new Set(e.references.flatMap(a=>a.packs)).size;return(0,c.useEffect)(()=>{let a=n.current;if(a)if(e.names&&!a.open)try{a.showModal()}catch{}else!e.names&&a.open&&a.close()},[e.names]),(0,s.jsx)("dialog",{className:"skills-remove-dialog","data-remove-skills-dialog":!0,ref:n,onCancel:a=>{a.preventDefault(),e.busy||e.onCancel()},onClick:a=>{a.target===a.currentTarget&&!e.busy&&e.onCancel()},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:v?m.length===1?l("skills.removeInUseOneTitle",{skill:m[0]}):l("skills.removeInUseManyTitle",{count:m.length}):m.length===1?l("skills.removeOneTitle",{skill:m[0]}):l("skills.removeManyTitle",{count:m.length})}),(0,s.jsx)("p",{children:v?m.length===1?w>0?l("skills.removeInUseOneHelpWithPacks",{botCount:g,packCount:w}):l("skills.removeInUseOneHelp",{count:g}):w>0?l("skills.removeInUseManyHelpWithPacks",{botCount:g,packCount:w}):l("skills.removeInUseManyHelp",{count:g}):m.length===1?l("skills.removeOnePermanentHelp"):l("skills.removePermanentHelp")})]}),(0,s.jsxs)("div",{className:"skills-remove-dialog-body",children:[m.length>1?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("ul",{children:p.map(a=>(0,s.jsx)("li",{children:a},a))}),m.length>p.length?(0,s.jsx)("p",{children:l("skills.removeMore",{count:m.length-p.length})}):null]}):null,e.references.length>0?(0,s.jsxs)("div",{className:"skills-remove-reference-warning",role:"alert",children:[(0,s.jsx)("strong",{children:l("skills.removeReferencesDetail")}),(0,s.jsx)("ul",{children:e.references.map(a=>(0,s.jsxs)("li",{children:[(0,s.jsx)("strong",{children:a.name}),(0,s.jsxs)("span",{children:[a.bots.join(", "),a.bots.length>0&&a.packs.length>0?" \xB7 ":"",a.packs.length>0?`${l("skills.packChips")}: ${a.packs.join(", ")}`:""]})]},a.name))})]}):null,e.error?(0,s.jsx)("p",{className:"hint-warn",role:"alert",children:e.error}):null]}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,disabled:e.busy,onClick:e.onCancel,children:l("skills.cancel")}),(0,s.jsx)("button",{type:"button",className:"danger",disabled:e.busy,onClick:()=>e.onConfirm(v),children:e.busy?l("skills.removing"):v?l("skills.removeAnyway"):m.length===1?l("skills.removeOneConfirm"):l("skills.removeSelected",{count:m.length})})]})]})})}function Cs(){let e=X(),l=(0,c.useRef)(!0),n=(0,c.useRef)(new Set),m=(0,c.useRef)(null),{skills:v,nativeSkillGroups:p,bots:g,packs:w,trustProjectSkills:a,delivery:C,loading:B,loadError:b,packsError:P,packsKnown:N,refresh:h,setSkills:x,setBots:E,setTrustProjectSkills:T,setDelivery:L}=Bl({apiUnavailableText:e("skills.apiUnavailable")}),[A,$]=(0,c.useState)("library"),[H,K]=(0,c.useState)(null),[F,y]=(0,c.useState)(null),f=(0,c.useCallback)(t=>{K(t),y(t.installTargetSkill??null),$(t.tab)},[]),I=(0,c.useCallback)(()=>K(null),[]),[d,U]=(0,c.useState)(""),[G,te]=(0,c.useState)(""),[r,i]=(0,c.useState)(""),[M,R]=(0,c.useState)(null),[_,V]=(0,c.useState)(!1),[he,fe]=(0,c.useState)(!1),[ye,le]=(0,c.useState)(!1),[se,W]=(0,c.useState)([]),[Y,we]=(0,c.useState)(!1),[Me,Se]=(0,c.useState)(!1),[Ke,Ee]=(0,c.useState)(()=>new Set),[_e,Ce]=(0,c.useState)(!1),[Ml,al]=(0,c.useState)(!1),[We,El]=(0,c.useState)(null),[qe,Je]=(0,c.useState)(()=>new Set),[$l,$e]=(0,c.useState)(null),[Ll,il]=(0,c.useState)(null),[Hl,ol]=(0,c.useState)(()=>new Set),[rl,Ne]=(0,c.useState)({}),[Qe,Pe]=(0,c.useState)(null),[cl,Xe]=(0,c.useState)(null),[Ol,Re]=(0,c.useState)(!1),[jl,Le]=(0,c.useState)([]),[Fl,He]=(0,c.useState)(null),[Oe,dl]=(0,c.useState)(()=>new Set),De=(0,c.useRef)(g),je=(0,c.useRef)(new Map);(0,c.useEffect)(()=>{De.current=g},[g]);let Fe=(0,c.useMemo)(()=>new Set(v.map(t=>t.name)),[v]),ve=(0,c.useMemo)(()=>p.length===0?void 0:(We?p.find(o=>xe(o)===We):void 0)??p.find(o=>o.skills.length>0)??p[0],[We,p]),Ze=ve?xe(ve):"",Te=(0,c.useMemo)(()=>ve?ve.skills.filter(t=>!Fe.has(t.name)).map(t=>t.rootDir??t.source?.root??"").filter(Boolean):[],[ve,Fe]),ul=Te.length>0&&Te.every(t=>qe.has(t)),kl=(0,c.useCallback)(()=>{for(let t of n.current)window.clearTimeout(t);n.current.clear()},[]),Ul=(0,c.useCallback)(t=>new Promise(o=>{let S=window.setTimeout(()=>{n.current.delete(S),o()},t);n.current.add(S)}),[]);(0,c.useEffect)(()=>(l.current=!0,()=>{l.current=!1,kl()}),[kl]),(0,c.useEffect)(()=>{Je(t=>{let o=new Set,S=new Set(v.map(D=>D.name));for(let D of p)for(let z of D.skills){let j=z.rootDir??z.source?.root??"";j&&!S.has(z.name)&&t.has(j)&&o.add(j)}return o.size===t.size?t:o})},[v,p]),(0,c.useEffect)(()=>{if(!Qe||Oe.size>0)return;let t=window.setTimeout(()=>{l.current&&Pe(null)},6e3);return()=>window.clearTimeout(t)},[Qe,Oe]),(0,c.useEffect)(()=>{let t=m.current;if(t)if(_e&&!t.open)try{t.showModal()}catch{}else!_e&&t.open&&t.close()},[_e,Ze]);async function ml(t,o,S=!0){let D=t;for(o({text:e("skills.jobRunning"),ok:!0});;){if(!l.current)return null;if(D.status==="succeeded")return o({text:e("skills.saved"),ok:!0}),S&&await h(),D;if(D.status==="failed")throw new Error(D.error??"job_failed");if(await Ul(800),!l.current)return null;let z=await re(`/api/skills/jobs/${encodeURIComponent(D.id)}`,{method:"GET"});if(!l.current)return null;D=z.job}}function Gl(t){return g.filter(o=>ke(o.skills).includes(t)).map(o=>o.botName??o.larkAppId)}function Ae(){W([]),Ee(new Set),le(!1),Se(!1)}function gl(){return{source:d.trim(),path:G.trim()||void 0,ref:r.trim()||void 0,...Y?{fullDepth:!0}:{}}}function zl(t,o=Y||Me){let S=t??[...Ke];return{...gl(),skillNames:S.length>0?S:void 0,...o?{fullDepth:!0}:{}}}async function Kl(){fe(!0),R({text:e("skills.scanning"),ok:!0});try{let t=await re("/api/skills/discover",{method:"POST",body:JSON.stringify(gl())});if(!l.current)return{skills:[],directInstall:!1,fullDepth:Y};let o=t.discovery?.directInstall===!0,S=Array.isArray(t.discovery?.skills)?t.discovery.skills:[],D=t.discovery?.deepScanned===!0;return Se(D),W(S),Ee(tl(S,F).selected),{skills:S,directInstall:o,fullDepth:Y||D}}finally{l.current&&fe(!1)}}function me(t){let o=t||"";return o.startsWith("skill_git_command_failed")&&/authentication failed|could not read username|repository not found|unauthor|\b401\b|\b403\b/i.test(o)?e("skills.gitNeedsAuth"):o.startsWith("agentbuddy_not_found")?e("skills.agentbuddyNotFound"):o.startsWith("agentbuddy_login_required")?e("skills.agentbuddyNeedsLogin"):o.startsWith("agentbuddy_command_failed")?/login|credential|unauthor|not logged|401|403/i.test(o)?e("skills.agentbuddyNeedsLogin"):e("skills.agentbuddyCommandFailed"):o.startsWith("agentbuddy_clear_telemetry_failed")||o.startsWith("agentbuddy_telemetry_not_stripped")?e("skills.agentbuddyTelemetryFailed"):o.startsWith("agentbuddy_no_skill_produced")?e("skills.agentbuddyNoSkill"):o.startsWith("invalid_agentbuddy")?e("skills.agentbuddyInvalid"):o}async function Ve(t,o=Y||Me){V(!0);try{let S=await re("/api/skills/install",{method:"POST",body:JSON.stringify(zl(t,o))});if(!l.current)return null;let D=await ml(S.job,R);if(!l.current||!D)return null;let z=(D.skills??(D.skill?[D.skill]:[])).map(j=>j.name).filter(Boolean);return Ae(),y(null),[...new Set(z.length>0?z:t??[])]}catch(S){return l.current&&R({text:`${e("skills.failed")}: ${me(S?.message??String(S))}`,ok:!1}),null}finally{l.current&&V(!1)}}function _l(t){Ee(o=>{let S=new Set(o);return S.has(t)?S.delete(t):S.add(t),S})}function Wl(t){Ee(t?new Set(se.map(o=>o.name)):new Set)}async function ql(){if(!d.trim())return R({text:e("skills.sourceRequired"),ok:!1}),null;try{le(!1);let{skills:t,directInstall:o,fullDepth:S}=await Kl();if(!l.current)return null;if(o)return await Ve(void 0,S);if(t.length===0)return R({text:e("skills.scanEmpty"),ok:!1}),null;let{targetMissing:D}=tl(t,F);return t.length===1&&!D?await Ve([t[0].name],S):(R(D?{text:e("skills.installTargetNotFound",{skill:F}),ok:!1}:{text:e("skills.scanFound",{count:t.length}),ok:!0}),le(!0),null)}catch(t){return l.current&&R({text:`${e("skills.failed")}: ${me(t?.message??String(t))}`,ok:!1}),null}}async function Jl(){let t=[...Ke];return t.length===0?(R({text:e("skills.discoverNothingSelected"),ok:!1}),null):await Ve(t)}async function Ql(t){await re("/api/skill-packs",{method:"POST",body:JSON.stringify({id:t.id,name:t.name,include:t.skillNames.map(o=>`skill:${o}`)})}),l.current&&(await h(),l.current&&$("packs"))}async function Xl(){let t=[...qe].filter(Boolean);if(t.length===0){R({text:e("skills.discoverNothingSelected"),ok:!1});return}al(!0);try{if(R({text:e("skills.discoverRegisteringBatch",{total:t.length}),ok:!0}),await re("/api/skills/install-local-links",{method:"POST",body:JSON.stringify({sources:t})}),!l.current)return;Ce(!1),await h(),l.current&&R({text:e("skills.saved"),ok:!0})}catch(o){l.current&&R({text:`${e("skills.failed")}: ${me(o?.message??String(o))}`,ok:!1})}finally{l.current&&al(!1)}}async function Zl(t){if(a!==t){$e("project");try{let o=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({trustProjectSkills:t})});if(!l.current)return;T(o.trustProjectSkills==="all"?"all":t)}catch(o){l.current&&Ie(`${e("skills.failed")}: ${me(o?.message??String(o))}`,{kind:"error"})}finally{l.current&&$e(null)}}}async function Vl(t){if(C!==t){$e("delivery");try{let o=await re("/api/skills/global",{method:"PUT",body:JSON.stringify({delivery:t})});if(!l.current)return;L(o.delivery==="prompt"||o.delivery==="native"?o.delivery:t)}catch(o){l.current&&Ie(`${e("skills.failed")}: ${me(o?.message??String(o))}`,{kind:"error"})}finally{l.current&&$e(null)}}}async function Yl(t){il(`${t}:update`);try{let o=await re(`/api/skills/${encodeURIComponent(t)}/update`,{method:"POST",body:"{}"});if(!l.current)return;await ml(o.job,R)}catch(o){l.current&&Ie(`${e("skills.failed")}: ${me(o?.message??String(o))}`,{kind:"error"})}finally{l.current&&il(null)}}function es(t){let o=[...new Set(t.filter(S=>Fe.has(S)))];o.length!==0&&(Xe(o),Re(!0),Le([]),He(null))}function ls(){Oe.size>0||(Re(!1),Xe(null),Le([]),He(null))}async function ss(t){let o=cl??[];if(o.length!==0){dl(new Set(o)),Re(!1),He(null),Pe({text:e("skills.removingCount",{count:o.length}),ok:!0});try{let S=await re("/api/skills/remove",{method:"POST",body:JSON.stringify({names:o,force:t})});if(!l.current)return;let D=Array.isArray(S.removed)?S.removed.filter(j=>typeof j=="string"):o,z=new Set(D);x(j=>j.filter(ne=>!z.has(ne.name))),Pe({text:D.length===1?e("skills.removedOne",{skill:D[0]}):e("skills.removedMany",{count:D.length}),ok:!0}),Xe(null),Le([])}catch(S){if(!l.current)return;if(S?.status===409&&S?.body?.error==="skills_in_use"){let z=Array.isArray(S.body.affectedSkills)?S.body.affectedSkills.map(j=>{let ne=typeof j?.name=="string"?j.name:"",ie=Array.isArray(j?.affectedBots)?j.affectedBots.map(ae=>ae?.botName||ae?.larkAppId||"").filter(Boolean):Gl(ne),ce=Array.isArray(j?.affectedPacks)?j.affectedPacks.filter(ae=>typeof ae=="string"):[];return ne?{name:ne,bots:ie,packs:ce}:null}).filter(j=>j!==null):[];Le(z),Re(!0),Pe(null);return}let D=e("skills.removeFailed",{detail:me(S?.message??String(S))});He(D),Re(!0),Pe({text:D,ok:!1})}finally{l.current&&dl(new Set)}}}function pl(t,o){let S=je.current.get(t)??Promise.resolve();ol(z=>new Set(z).add(t));let D=S.catch(()=>{}).then(o);return je.current.set(t,D),D.finally(()=>{je.current.get(t)===D&&(je.current.delete(t),l.current&&ol(z=>{let j=new Set(z);return j.delete(t),j}))})}async function fl(t,o,S){Ne(D=>({...D,[t]:null}));try{let D=De.current.find(ie=>ie.larkAppId===t),z=Pl(D?.skills,o,S),j=await re(`/api/bots/${encodeURIComponent(t)}/skills`,{method:"PUT",body:JSON.stringify({action:"set",policy:z.length>0?{include:z}:null})});if(!l.current)return;let ne=ie=>ie.map(ce=>ce.larkAppId===t?{...ce,skills:j.skills??null}:ce);De.current=ne(De.current),E(ne),Ne(ie=>({...ie,[t]:{text:e("skills.policySaved"),ok:!0}}))}catch(D){throw l.current&&Ne(z=>({...z,[t]:{text:`${e("skills.failed")}: ${me(D?.message??String(D))}`,ok:!1}})),D}}function ts(t,o,S){return pl(t,()=>fl(t,o,S))}function ns(t,o,S){return pl(t,async()=>{let D=De.current.find(ae=>ae.larkAppId===t),z=ke(D?.skills),j=be(D?.skills),[ne,ie]=o.split(":",2),ce=ae=>S?[...new Set([...ae,ie])]:ae.filter(ds=>ds!==ie);await fl(t,ne==="skill"?ce(z):z,ne==="pack"?ce(j):j)})}async function as(t,o){Ne(S=>({...S,[t]:null}));try{if(await re(`/api/bots/${encodeURIComponent(t)}/skill-injection`,{method:"PUT",body:JSON.stringify({skillInjection:o})}),!l.current)return;E(S=>S.map(D=>D.larkAppId===t?{...D,skillInjection:o}:D)),Ne(S=>({...S,[t]:{text:e("skills.saved"),ok:!0}}))}catch(S){l.current&&Ne(D=>({...D,[t]:{text:`${e("skills.failed")}: ${S?.message??S}`,ok:!1}}))}}let is=g.filter(t=>Rl(t.skills)).length,os=g.reduce((t,o)=>t+(o.skills?.include?.length??0),0),ge=(0,c.useMemo)(()=>ze(v,w,g,{packsKnown:N}),[v,w,g,N]),pe=(0,c.useMemo)(()=>Dl(ge),[ge]),Ue=(0,c.useMemo)(()=>[...ge.packs.values()].filter(t=>t.botIds.length===0).map(t=>t.id),[ge]),Ge=(0,c.useMemo)(()=>[...ge.bots.values()].filter(t=>t.health==="missing"||t.health==="pack_missing").map(t=>t.larkAppId),[ge]),rs=(0,s.jsxs)("div",{className:"page-heading-actions skills-heading-actions",children:[(0,s.jsxs)("div",{className:"skills-metric-strip",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricInstalled")}),(0,s.jsx)("strong",{children:v.length})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricPacks")}),(0,s.jsx)("strong",{children:N?w.length:"\u2014"})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricBots")}),(0,s.jsxs)("strong",{children:[is,"/",g.length]})]}),(0,s.jsxs)("span",{children:[(0,s.jsx)("small",{children:e("skills.metricAttached")}),(0,s.jsx)("strong",{children:os})]})]}),(0,s.jsxs)("div",{className:"skills-issue-strip",role:"group","aria-label":e("skills.issuesLabel"),children:[pe.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-dangling-skills",title:pe.join(", "),onClick:()=>f(pe.length===1?{tab:"library",librarySearch:pe[0],openInstallWizard:!0,installTargetSkill:pe[0]}:{tab:"library",libraryFilterSkills:pe}),children:e("skills.issueDangling",{count:pe.length})}),Ue.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-info","data-action":"issue-unassigned-packs",onClick:()=>f({tab:"packs",focusPackIds:Ue}),children:e("skills.issueUnassignedPacks",{count:Ue.length})}),Ge.length>0&&(0,s.jsx)("button",{type:"button",className:"skills-issue-badge skills-issue-warn","data-action":"issue-bots-missing",onClick:()=>f({tab:"bots",focusBotIds:Ge}),children:e("skills.issueBotsMissing",{count:Ge.length})}),!B&&N&&pe.length===0&&Ue.length===0&&Ge.length===0&&(0,s.jsx)("span",{className:"skills-issue-badge skills-issue-ok","data-skills-healthy":!0,children:e("skills.issueNone")})]}),(0,s.jsx)(hl,{id:"skills-refresh",label:e("skills.refresh"),busy:B,disabled:B,onClick:()=>{h()}})]}),cs=(0,s.jsx)("div",{className:"skills-page-stack",children:B?(0,s.jsx)(bl,{label:e("common.loading")}):b?(0,s.jsx)("p",{className:"hint-warn",children:b}):(0,s.jsxs)(s.Fragment,{children:[P&&(0,s.jsx)("p",{className:"hint-warn","data-packs-error":!0,role:"alert",children:e(N?"skills.packsLoadError":"skills.packsLoadErrorFirst",{error:P})}),(0,s.jsxs)("div",{className:"skills-tabs",role:"tablist",children:[(0,s.jsx)("button",{role:"tab","aria-selected":A==="library",className:A==="library"?"active":"",onClick:()=>$("library"),children:e("skills.tabLibrary")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="packs",className:A==="packs"?"active":"",onClick:()=>$("packs"),children:e("skills.tabPacks")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="bots",className:A==="bots"?"active":"",onClick:()=>$("bots"),children:e("skills.tabBots")}),(0,s.jsx)("button",{role:"tab","aria-selected":A==="delivery",className:A==="delivery"?"active":"",onClick:()=>$("delivery"),children:e("skills.tabDelivery")})]}),A==="packs"&&(0,s.jsx)(Sl,{skills:v,packs:w,packsKnown:N,onRefresh:()=>{h()},focusPackId:H?.tab==="packs"?H.focusPackId??null:null,focusPackIds:H?.tab==="packs"?H.focusPackIds??null:null,onFocusConsumed:I,onOpenBot:t=>f({tab:"bots",focusBotIds:[t]}),onInstallMissingSkill:t=>f({tab:"library",librarySearch:t,openInstallWizard:!0,installTargetSkill:t})}),A==="library"&&(0,s.jsx)(Cl,{skills:v,nativeSkillGroups:p,installSource:d,installPath:G,installRef:r,installFullDepth:Y,installStatus:M,installBusy:_,installDiscovering:he,installSelectionOpen:ye,installCandidates:se,selectedInstallSkills:Ke,onInstallSourceChange:t=>{U(t),Ae()},onInstallPathChange:t=>{te(t),Ae()},onInstallRefChange:t=>{i(t),Ae()},onInstallFullDepthChange:t=>{we(t),Ae()},onToggleInstallSkill:_l,onSelectAllInstallSkills:Wl,onConfirmInstallSelection:Jl,onCloseInstallSelection:()=>le(!1),onInstall:ql,onOpenNativeDiscovery:()=>Ce(!0),onCreatePack:Ql,InstallPanel:Ns,InstalledLibrary:Is,RemoveDialog:ws,removingNames:Oe,removalDialogOpen:Ol,pendingRemoval:cl,removalReferences:jl,removalError:Fl,skillBusy:Ll,installedStatus:Qe,onUpdateSkill:t=>{Yl(t)},onRequestRemove:es,onCancelRemoval:ls,onConfirmRemoval:t=>{ss(t)},navIntent:H?.tab==="library"?H:null,onNavIntentConsumed:I,installTargetSkill:F,onClearInstallTarget:()=>y(null),packsKnown:N,onInstallMissing:t=>f({tab:"library",openInstallWizard:!0,installTargetSkill:t}),graph:ge,packNames:w.map(t=>({id:t.id,name:t.name})),onShowSkillPacks:t=>{let o=ge.skills.get(t)?.packIds??[];f(o.length===1?{tab:"packs",focusPackId:o[0]}:{tab:"packs",focusPackIds:o})},onShowSkillBots:t=>f({tab:"bots",focusSkill:t}),onAssignInstalledSkill:t=>f({tab:"bots",focusSkill:t})}),A==="bots"&&(0,s.jsx)(Tl,{bots:g,skills:v,statuses:rl,onSave:ts,onMutate:ns,busyBotIds:Hl,packs:w,packsKnown:N,focusBotIds:H?.tab==="bots"?H.focusBotIds??null:null,focusSkill:H?.tab==="bots"?H.focusSkill??null:null,onFocusConsumed:I,onOpenPack:t=>f({tab:"packs",focusPackId:t}),onOpenSkill:t=>f({tab:"library",librarySearch:t})}),A==="delivery"&&(0,s.jsx)(Al,{trustProjectSkills:a,delivery:C,globalBusy:$l,onUpdateProject:t=>{Zl(t)},onUpdateDelivery:t=>{Vl(t)},bots:g,onUpdateBotInjection:as,botStatuses:rl,SkillSegmented:Ss}),(0,s.jsx)("dialog",{className:"skills-discovery-dialog",id:"skills-discovery-dialog",ref:m,onClose:()=>Ce(!1),onClick:t=>{t.target===t.currentTarget&&Ce(!1)},children:(0,s.jsxs)("article",{children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h3",{children:e("skills.discoverTitle")}),(0,s.jsx)("p",{children:e("skills.discoverHelp")}),(0,s.jsx)("button",{type:"button",className:"skills-discovery-close","data-action":"close-discovery","aria-label":e("skills.discoverClose"),title:e("skills.discoverClose"),onClick:()=>Ce(!1)})]}),(0,s.jsx)("div",{className:"skills-discovery-body",children:ve?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"skills-discovery-layout",children:[(0,s.jsx)("div",{className:"skills-discovery-tabs",role:"tablist","aria-label":e("skills.discoverTitle"),children:p.map(t=>{let o=xe(t),S=o===Ze;return(0,s.jsxs)("button",{type:"button",role:"tab","data-discovery-tab":o,className:S?"selected":"","aria-selected":S?"true":"false",onClick:()=>El(o),children:[(0,s.jsx)("strong",{children:t.label??t.cliId}),(0,s.jsx)("small",{children:e("skills.skillCount",{count:t.skills.length})})]},o)})}),(0,s.jsxs)("div",{className:"skills-discovery-main",children:[(0,s.jsx)("div",{className:"skills-discovery-path",children:(0,s.jsx)("code",{children:ve.rootDir})}),p.map(t=>{let o=xe(t);return(0,s.jsx)("section",{className:"skills-discovery-group","data-discovery-panel":o,hidden:!(o===Ze),children:t.skills.length===0?(0,s.jsx)("p",{className:"empty",children:e("skills.discoverGroupEmpty")}):(0,s.jsx)("div",{className:"skills-discovery-list",children:t.skills.map(D=>{let z=Fe.has(D.name),j=D.rootDir??D.source?.root??"";return(0,s.jsxs)("label",{className:`skills-discovery-row${z?" installed":""}`,children:[(0,s.jsx)("input",{type:"checkbox","data-discovered-skill":!0,value:j,disabled:z,checked:!z&&qe.has(j),onChange:ne=>{let ie=ne.currentTarget.checked;Je(ce=>{let ae=new Set(ce);return ie?ae.add(j):ae.delete(j),ae})}}),(0,s.jsxs)("span",{children:[(0,s.jsx)("strong",{children:D.name}),D.description?(0,s.jsx)("small",{children:D.description}):null]}),z?(0,s.jsx)("em",{children:e("skills.discoverRegistered")}):null]},`${D.name}:${j}`)})})},o)})]})]})}):(0,s.jsx)("p",{className:"empty",children:e("skills.discoverEmpty")})}),(0,s.jsxs)("footer",{className:"actions",children:[(0,s.jsx)("button",{type:"button","data-action":"toggle-discovered-skills",disabled:Te.length===0,onClick:()=>{Je(t=>{let o=new Set(t);return ul?Te.forEach(S=>o.delete(S)):Te.forEach(S=>o.add(S)),o})},children:e(ul?"skills.discoverClearSelection":"skills.discoverSelectAll")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"register-discovered-skills",disabled:Ml,onClick:()=>{Xl()},children:e("skills.discoverRegister")})]})]})})]})});return(0,s.jsxs)("section",{className:"page skills-page",children:[(0,s.jsxs)("div",{className:"page-heading",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"eyebrow",children:e("nav.skills")}),(0,s.jsx)("h1",{children:e("skills.title")})]}),rs]}),(0,s.jsx)("div",{id:"skills-body",children:cs})]})}function Ps(e,l){return e.size===l.length&&l.every(n=>e.has(n))}function Rs(e){let l=X(),n=(0,c.useRef)(null),m=(0,c.useRef)(null),v=(0,c.useRef)(null),[p,g]=(0,c.useState)(!1),[w,a]=(0,c.useState)(""),[C,B]=(0,c.useState)(()=>new Set(e.names)),[b,P]=(0,c.useState)(null),N=e.names.join(`
|
|
4
4
|
`),h=w.trim().toLocaleLowerCase(),x=(0,c.useMemo)(()=>{let f=new Map(e.skills.map(I=>[I.name,I]));for(let I of e.names)f.has(I)||f.set(I,{name:I});return[...f.values()].sort((I,d)=>I.name.localeCompare(d.name))},[e.names,e.skills]),E=(0,c.useMemo)(()=>h?x.filter(f=>`${f.name} ${f.description||""}`.toLocaleLowerCase().includes(h)):x,[h,x]),T=!Ps(C,e.names),L=(0,c.useCallback)(()=>{let f=m.current;if(!f||typeof window>"u")return;let I=f.getBoundingClientRect(),d=12,U=7,G=Math.min(370,Math.max(260,window.innerWidth-d*2)),te=Math.min(Math.max(d,I.left),Math.max(d,window.innerWidth-G-d)),r=Math.max(0,I.top-U-d),i=Math.max(0,window.innerHeight-I.bottom-U-d),M=r>i,R=M?r:i,_=118+Math.min(x.length,5)*42,V=Math.max(180,Math.min(_,R));P({left:te,top:M?Math.max(d,I.top-U-V):I.bottom+U,width:G,height:V})},[x.length]);(0,c.useEffect)(()=>{p||B(new Set(e.names))},[N,p]),(0,c.useEffect)(()=>{if(!p||typeof document>"u")return;let f=I=>{n.current?.contains(I.target)||v.current?.contains(I.target)||(g(!1),a(""),B(new Set(e.names)))};return document.addEventListener("pointerdown",f),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),L(),()=>{document.removeEventListener("pointerdown",f),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[N,p,L]);function A(){B(new Set(e.names)),a(""),L(),g(!0)}function $(){B(new Set(e.names)),a(""),g(!1)}function H(f){B(I=>{let d=new Set(I);return d.has(f)?d.delete(f):d.add(f),d})}async function K(){let f=[...C].sort((I,d)=>I.localeCompare(d));try{await e.onSave(f),a(""),g(!1)}catch{}}let F=e.names.length===0?l("skills.pickerPlaceholder"):e.names.length===1?e.names[0]:l("skills.pickerSelectedCount",{count:e.names.length}),y=p?(0,s.jsxs)("div",{ref:v,className:"skills-multi-picker-popover",style:b?{left:b.left,top:b.top,width:b.width,height:b.height}:void 0,children:[(0,s.jsxs)("div",{className:"skills-multi-picker-head",children:[(0,s.jsxs)("label",{className:"skills-multi-picker-search",children:[(0,s.jsx)("span",{className:"skills-multi-picker-search-icon","aria-hidden":"true"}),(0,s.jsx)("input",{type:"search","data-action":"search-skills",autoFocus:!0,autoComplete:"off",value:w,placeholder:l("skills.pickerSearchPlaceholder"),onChange:f=>a(f.currentTarget.value),onKeyDown:f=>{f.key==="Escape"&&(f.preventDefault(),$())}})]}),(0,s.jsxs)("div",{className:"skills-multi-picker-meta",children:[(0,s.jsx)("span",{children:l("skills.pickerSelectionMeta",{selected:C.size,total:x.length})}),C.size>0?(0,s.jsx)("button",{type:"button",className:"skills-multi-picker-clear","data-action":"clear-skill-selection",onClick:()=>B(new Set),children:l("skills.pickerClear")}):null]})]}),(0,s.jsxs)("div",{className:"skills-multi-picker-options",role:"listbox","aria-label":l("skills.priority"),"aria-multiselectable":"true",children:[E.map(f=>{let I=C.has(f.name),d=!e.installedNames.has(f.name);return(0,s.jsxs)("button",{type:"button",className:`skills-multi-picker-option${I?" selected":""}${d?" dangling":""}`,role:"option","aria-selected":I,"data-skill-name":f.name,onClick:()=>H(f.name),children:[(0,s.jsx)("span",{className:"skills-multi-picker-check","aria-hidden":"true"}),(0,s.jsxs)("span",{className:"skills-multi-picker-option-copy",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("b",{children:f.name}),d?(0,s.jsx)("em",{children:l("skills.dangling")}):null]}),f.description?(0,s.jsx)("small",{children:f.description}):null]})]},f.name)}),E.length===0?(0,s.jsx)("p",{className:"skills-multi-picker-empty",children:l("skills.pickerNoResults")}):null]}),(0,s.jsxs)("footer",{className:"skills-multi-picker-actions",children:[(0,s.jsx)("button",{type:"button",className:"ghost","data-action":"cancel-skill-selection",disabled:e.busy,onClick:$,children:l("skills.cancel")}),(0,s.jsx)("button",{type:"button",className:"primary","data-action":"save-skill-selection",disabled:!T||e.busy,onClick:()=>{K()},children:e.busy?l("skills.saving"):l("skills.saveSelection")})]})]}):null;return(0,s.jsxs)("div",{ref:n,className:`skills-multi-picker${p?" open":""}`,"data-skill-picker":e.botId,children:[(0,s.jsxs)("button",{ref:m,type:"button",className:"skills-multi-picker-trigger","data-action":"open-skill-picker","aria-haspopup":"listbox","aria-expanded":p,disabled:e.busy,onClick:()=>p?$():A(),children:[(0,s.jsxs)("span",{className:"skills-multi-picker-trigger-copy",children:[(0,s.jsx)("b",{children:F}),(0,s.jsx)("small",{children:l("skills.pickerTriggerHint")})]}),(0,s.jsx)("span",{className:"skills-multi-picker-chevron","aria-hidden":"true"})]}),y&&typeof document<"u"?(0,xl.createPortal)(y,document.body):y]})}function st(e){let l=X(),{bot:n,installedNames:m,skills:v,status:p,busyKey:g,onSave:w}=e,a=n.botName??n.larkAppId,C=ke(n.skills);return n.error?(0,s.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":n.larkAppId,children:[(0,s.jsxs)("header",{children:[(0,s.jsx)(el,{html:Ye({name:a,larkAppId:n.larkAppId,size:"sm"})}),(0,s.jsx)("strong",{children:a})]}),(0,s.jsx)("p",{className:"hint-warn-inline",children:n.error})]}):(0,s.jsxs)("article",{className:"bd-card skills-bot-card","data-appid":n.larkAppId,children:[(0,s.jsxs)("header",{className:"skills-bot-head",children:[(0,s.jsx)(el,{html:Ye({name:a,larkAppId:n.larkAppId,size:"sm",dot:"ok"})}),(0,s.jsxs)("div",{className:"skills-bot-title-line",children:[(0,s.jsx)("strong",{children:a}),(0,s.jsx)("span",{className:"skills-count-pill",children:l("skills.skillCount",{count:C.length})})]})]}),(0,s.jsxs)("section",{className:"skills-policy-panel",children:[(0,s.jsx)("div",{className:"skills-priority-head",children:(0,s.jsx)("h3",{className:"skills-priority-title",children:l("skills.priority")})}),(0,s.jsx)(Rs,{botId:n.larkAppId,names:C,installedNames:m,skills:v,busy:g===`${n.larkAppId}:set`,onSave:B=>w(n.larkAppId,B)})]}),(0,s.jsx)("span",{className:nl(p),"data-bot-status":!0,children:p?.text??""})]})}function tt(e){return vl(e,(0,s.jsx)(Cs,{}))}export{st as BotPolicyCard,Is as InstalledSkillsLibrary,ws as RemoveSkillsDialog,Rs as SkillMultiPicker,Ss as SkillSegmented,Ns as SkillsInstallPanel,Cs as SkillsPage,tt as renderSkillsPage};
|