@kaitranntt/ccs 7.49.1 → 7.50.0-dev.10
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/README.md +101 -1
- package/config/base-iflow.settings.json +4 -4
- package/dist/api/services/index.d.ts +2 -2
- package/dist/api/services/index.d.ts.map +1 -1
- package/dist/api/services/index.js +2 -1
- package/dist/api/services/index.js.map +1 -1
- package/dist/api/services/profile-reader.d.ts.map +1 -1
- package/dist/api/services/profile-reader.js +13 -0
- package/dist/api/services/profile-reader.js.map +1 -1
- package/dist/api/services/profile-types.d.ts +9 -0
- package/dist/api/services/profile-types.d.ts.map +1 -1
- package/dist/api/services/profile-writer.d.ts +8 -2
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +83 -8
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/auth/account-context.d.ts +65 -0
- package/dist/auth/account-context.d.ts.map +1 -0
- package/dist/auth/account-context.js +158 -0
- package/dist/auth/account-context.js.map +1 -0
- package/dist/auth/auth-commands.d.ts.map +1 -1
- package/dist/auth/auth-commands.js +18 -0
- package/dist/auth/auth-commands.js.map +1 -1
- package/dist/auth/commands/create-command-env.d.ts +3 -0
- package/dist/auth/commands/create-command-env.d.ts.map +1 -0
- package/dist/auth/commands/create-command-env.js +55 -0
- package/dist/auth/commands/create-command-env.js.map +1 -0
- package/dist/auth/commands/create-command.d.ts.map +1 -1
- package/dist/auth/commands/create-command.js +162 -33
- package/dist/auth/commands/create-command.js.map +1 -1
- package/dist/auth/commands/list-command.d.ts.map +1 -1
- package/dist/auth/commands/list-command.js +12 -2
- package/dist/auth/commands/list-command.js.map +1 -1
- package/dist/auth/commands/show-command.d.ts.map +1 -1
- package/dist/auth/commands/show-command.js +6 -0
- package/dist/auth/commands/show-command.js.map +1 -1
- package/dist/auth/commands/types.d.ts +7 -0
- package/dist/auth/commands/types.d.ts.map +1 -1
- package/dist/auth/commands/types.js +51 -1
- package/dist/auth/commands/types.js.map +1 -1
- package/dist/auth/profile-detector.d.ts.map +1 -1
- package/dist/auth/profile-detector.js +10 -0
- package/dist/auth/profile-detector.js.map +1 -1
- package/dist/auth/profile-registry.d.ts +13 -5
- package/dist/auth/profile-registry.d.ts.map +1 -1
- package/dist/auth/profile-registry.js +89 -10
- package/dist/auth/profile-registry.js.map +1 -1
- package/dist/ccs.js +147 -5
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/account-safety.d.ts.map +1 -1
- package/dist/cliproxy/account-safety.js +4 -0
- package/dist/cliproxy/account-safety.js.map +1 -1
- package/dist/cliproxy/antigravity-responsibility.d.ts +36 -0
- package/dist/cliproxy/antigravity-responsibility.d.ts.map +1 -0
- package/dist/cliproxy/antigravity-responsibility.js +171 -0
- package/dist/cliproxy/antigravity-responsibility.js.map +1 -0
- package/dist/cliproxy/auth/auth-types.d.ts +2 -0
- package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +18 -0
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.js +124 -11
- package/dist/cliproxy/config/env-builder.js.map +1 -1
- package/dist/cliproxy/config/generator.d.ts +2 -1
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +18 -6
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +30 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +18 -0
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/model-config.d.ts.map +1 -1
- package/dist/cliproxy/model-config.js +3 -2
- package/dist/cliproxy/model-config.js.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.d.ts +4 -35
- package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.js +11 -34
- package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
- package/dist/cliproxy/services/variant-service.d.ts +5 -1
- package/dist/cliproxy/services/variant-service.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-service.js +19 -9
- package/dist/cliproxy/services/variant-service.js.map +1 -1
- package/dist/cliproxy/sync/profile-mapper.d.ts.map +1 -1
- package/dist/cliproxy/sync/profile-mapper.js +14 -2
- package/dist/cliproxy/sync/profile-mapper.js.map +1 -1
- package/dist/commands/api-command.d.ts +2 -0
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +45 -10
- package/dist/commands/api-command.js.map +1 -1
- package/dist/commands/cliproxy/auth-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/auth-subcommand.js +5 -2
- package/dist/commands/cliproxy/auth-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +1 -0
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts +15 -0
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +144 -15
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +20 -2
- package/dist/commands/help-command.js.map +1 -1
- package/dist/config/migration-manager.d.ts.map +1 -1
- package/dist/config/migration-manager.js +19 -0
- package/dist/config/migration-manager.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +11 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +127 -59
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +20 -0
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +8 -1
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/management/instance-manager.d.ts +3 -1
- package/dist/management/instance-manager.d.ts.map +1 -1
- package/dist/management/instance-manager.js +16 -9
- package/dist/management/instance-manager.js.map +1 -1
- package/dist/management/profile-context-sync-lock.d.ts +14 -0
- package/dist/management/profile-context-sync-lock.d.ts.map +1 -0
- package/dist/management/profile-context-sync-lock.js +174 -0
- package/dist/management/profile-context-sync-lock.js.map +1 -0
- package/dist/management/shared-manager.d.ts +39 -0
- package/dist/management/shared-manager.d.ts.map +1 -1
- package/dist/management/shared-manager.js +277 -2
- package/dist/management/shared-manager.js.map +1 -1
- package/dist/targets/droid-adapter.d.ts +2 -4
- package/dist/targets/droid-adapter.d.ts.map +1 -1
- package/dist/targets/droid-adapter.js +20 -10
- package/dist/targets/droid-adapter.js.map +1 -1
- package/dist/targets/droid-config-manager.d.ts +9 -1
- package/dist/targets/droid-config-manager.d.ts.map +1 -1
- package/dist/targets/droid-config-manager.js +134 -6
- package/dist/targets/droid-config-manager.js.map +1 -1
- package/dist/targets/droid-provider.d.ts +40 -0
- package/dist/targets/droid-provider.d.ts.map +1 -0
- package/dist/targets/droid-provider.js +140 -0
- package/dist/targets/droid-provider.js.map +1 -0
- package/dist/targets/droid-reasoning-runtime.d.ts +14 -0
- package/dist/targets/droid-reasoning-runtime.d.ts.map +1 -0
- package/dist/targets/droid-reasoning-runtime.js +42 -0
- package/dist/targets/droid-reasoning-runtime.js.map +1 -0
- package/dist/targets/index.d.ts +2 -0
- package/dist/targets/index.d.ts.map +1 -1
- package/dist/targets/index.js +4 -1
- package/dist/targets/index.js.map +1 -1
- package/dist/targets/target-adapter.d.ts +6 -0
- package/dist/targets/target-adapter.d.ts.map +1 -1
- package/dist/targets/target-resolver.d.ts.map +1 -1
- package/dist/targets/target-resolver.js +6 -3
- package/dist/targets/target-resolver.js.map +1 -1
- package/dist/types/config.d.ts +11 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/ui/assets/accounts-y2u0CVK8.js +1 -0
- package/dist/ui/assets/{alert-dialog-CFpc3HGP.js → alert-dialog-CetY4Iww.js} +1 -1
- package/dist/ui/assets/api-5q1FT1uL.js +1 -0
- package/dist/ui/assets/auth-section-CaQeee-F.js +1 -0
- package/dist/ui/assets/{backups-section-Bjxv4_pg.js → backups-section-hF88BjYJ.js} +1 -1
- package/dist/ui/assets/checkbox-Dhm5Fzkb.js +1 -0
- package/dist/ui/assets/cliproxy-BeYNWmY_.js +3 -0
- package/dist/ui/assets/cliproxy-control-panel-CJELeI80.js +1 -0
- package/dist/ui/assets/{confirm-dialog-DxtbIbqy.js → confirm-dialog-Dn3SrwNV.js} +1 -1
- package/dist/ui/assets/{copilot-DdeJ4TJs.js → copilot-vwT-4_V4.js} +2 -2
- package/dist/ui/assets/{cursor-CevrJcAp.js → cursor-CN3lIX63.js} +1 -1
- package/dist/ui/assets/droid-DBP2yCY7.js +2 -0
- package/dist/ui/assets/{form-utils-C-pVd1--.js → form-utils-Cn_Uld6y.js} +1 -1
- package/dist/ui/assets/globalenv-section-DNKAJasL.js +1 -0
- package/dist/ui/assets/{health-D-7zneJI.js → health-C7tNiLzc.js} +1 -1
- package/dist/ui/assets/icons-DrewC9c3.js +1 -0
- package/dist/ui/assets/index-C8-ef-r7.js +1 -0
- package/dist/ui/assets/{index-CcVqwkjG.js → index-MGh88HoC.js} +1 -1
- package/dist/ui/assets/{index-zwg9LfSN.js → index-QBUSDLTx.js} +1 -1
- package/dist/ui/assets/index-k-HuyjpO.js +47 -0
- package/dist/ui/assets/index-s-oTl3hW.css +1 -0
- package/dist/ui/assets/{index-euQBQnD4.js → index-uYnNU6Ut.js} +1 -1
- package/dist/ui/assets/proxy-status-widget-CIm5vKY7.js +1 -0
- package/dist/ui/assets/{radix-ui-CwcVwplj.js → radix-ui-C1Gpgz6I.js} +1 -1
- package/dist/ui/assets/separator-BLVyAGAm.js +1 -0
- package/dist/ui/assets/shared-CHH09ZNi.js +8 -0
- package/dist/ui/assets/{switch-B1VCWktQ.js → switch-CwLyB4JK.js} +1 -1
- package/dist/ui/assets/{tanstack-matWclUm.js → tanstack-DDJIhNJd.js} +1 -1
- package/dist/ui/assets/updates-VlxL3aum.js +1 -0
- package/dist/ui/index.html +6 -6
- package/dist/utils/hooks/image-analyzer-profile-hook-injector.d.ts.map +1 -1
- package/dist/utils/hooks/image-analyzer-profile-hook-injector.js +2 -1
- package/dist/utils/hooks/image-analyzer-profile-hook-injector.js.map +1 -1
- package/dist/utils/websearch/profile-hook-injector.d.ts.map +1 -1
- package/dist/utils/websearch/profile-hook-injector.js +2 -1
- package/dist/utils/websearch/profile-hook-injector.js.map +1 -1
- package/dist/web-server/model-pricing.d.ts.map +1 -1
- package/dist/web-server/model-pricing.js +114 -22
- package/dist/web-server/model-pricing.js.map +1 -1
- package/dist/web-server/routes/account-route-helpers.d.ts +20 -0
- package/dist/web-server/routes/account-route-helpers.d.ts.map +1 -0
- package/dist/web-server/routes/account-route-helpers.js +34 -0
- package/dist/web-server/routes/account-route-helpers.js.map +1 -0
- package/dist/web-server/routes/account-routes.d.ts.map +1 -1
- package/dist/web-server/routes/account-routes.js +160 -23
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +58 -24
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/config-routes.d.ts.map +1 -1
- package/dist/web-server/routes/config-routes.js +73 -0
- package/dist/web-server/routes/config-routes.js.map +1 -1
- package/dist/web-server/routes/droid-routes.d.ts +3 -0
- package/dist/web-server/routes/droid-routes.d.ts.map +1 -0
- package/dist/web-server/routes/droid-routes.js +61 -0
- package/dist/web-server/routes/droid-routes.js.map +1 -0
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +3 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/routes/profile-routes.d.ts +2 -0
- package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
- package/dist/web-server/routes/profile-routes.js +86 -6
- package/dist/web-server/routes/profile-routes.js.map +1 -1
- package/dist/web-server/routes/route-helpers.d.ts +2 -1
- package/dist/web-server/routes/route-helpers.d.ts.map +1 -1
- package/dist/web-server/routes/route-helpers.js +20 -1
- package/dist/web-server/routes/route-helpers.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +110 -12
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/dist/web-server/routes/variant-routes.d.ts +2 -0
- package/dist/web-server/routes/variant-routes.d.ts.map +1 -1
- package/dist/web-server/routes/variant-routes.js +50 -6
- package/dist/web-server/routes/variant-routes.js.map +1 -1
- package/dist/web-server/services/compatible-cli-docs-registry.d.ts +23 -0
- package/dist/web-server/services/compatible-cli-docs-registry.d.ts.map +1 -0
- package/dist/web-server/services/compatible-cli-docs-registry.js +81 -0
- package/dist/web-server/services/compatible-cli-docs-registry.js.map +1 -0
- package/dist/web-server/services/compatible-cli-json-file-service.d.ts +41 -0
- package/dist/web-server/services/compatible-cli-json-file-service.d.ts.map +1 -0
- package/dist/web-server/services/compatible-cli-json-file-service.js +205 -0
- package/dist/web-server/services/compatible-cli-json-file-service.js.map +1 -0
- package/dist/web-server/services/compatible-cli-types.d.ts +82 -0
- package/dist/web-server/services/compatible-cli-types.d.ts.map +1 -0
- package/dist/web-server/services/compatible-cli-types.js +3 -0
- package/dist/web-server/services/compatible-cli-types.js.map +1 -0
- package/dist/web-server/services/droid-dashboard-service.d.ts +29 -0
- package/dist/web-server/services/droid-dashboard-service.d.ts.map +1 -0
- package/dist/web-server/services/droid-dashboard-service.js +238 -0
- package/dist/web-server/services/droid-dashboard-service.js.map +1 -0
- package/dist/web-server/shared-routes.d.ts.map +1 -1
- package/dist/web-server/shared-routes.js +350 -52
- package/dist/web-server/shared-routes.js.map +1 -1
- package/lib/hooks/websearch-transformer.cjs +78 -52
- package/package.json +4 -2
- package/scripts/maintainability-check.js +163 -0
- package/dist/ui/assets/accounts-BKNcAuvp.js +0 -1
- package/dist/ui/assets/api-CcrDOIR7.js +0 -1
- package/dist/ui/assets/auth-section-856y9ZpH.js +0 -1
- package/dist/ui/assets/cliproxy-CgqwQWL0.js +0 -3
- package/dist/ui/assets/cliproxy-control-panel-fVNMCVo2.js +0 -1
- package/dist/ui/assets/globalenv-section-BqZQzUQ1.js +0 -1
- package/dist/ui/assets/icons-DGASzt3M.js +0 -1
- package/dist/ui/assets/index-5pyU75fR.js +0 -1
- package/dist/ui/assets/index-Bqt9Obz8.css +0 -1
- package/dist/ui/assets/index-DiWdJxAN.js +0 -47
- package/dist/ui/assets/proxy-status-widget-nDPpIwJt.js +0 -1
- package/dist/ui/assets/separator-CrJ4MtV5.js +0 -1
- package/dist/ui/assets/shared-VSWE7ipr.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-C1Gpgz6I.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as k}from"./tanstack-DDJIhNJd.js";import{W as K,aV as M}from"./index-k-HuyjpO.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as F,R as L,a2 as H,a3 as q,K as W,b as G,X as _}from"./icons-DrewC9c3.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function z({port:c=P}){const i=s.useRef(null),[$,b]=s.useState(null),[R,E]=s.useState(0),[g,m]=s.useState(null),[I,d]=s.useState(!1),[S,T]=s.useState(!0),{data:j,error:f}=k({queryKey:["cliproxy-server-config"],queryFn:()=>K.cliproxyServer.get(),staleTime:3e4}),{data:y}=k({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch(M("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{f&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",f)},[f]);const{managementUrl:n,checkUrl:u,authToken:r,isRemote:l,displayHost:x}=s.useMemo(()=>{const t=j?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",a=t.port||(o==="https"?443:P),v=o==="https"&&a===443||o==="http"&&a===80?"":`:${a}`,w=`${o}://${t.host}${v}`;return{managementUrl:`${w}/management.html`,checkUrl:`${w}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${v}`}}const h=y?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${c}/management.html`,checkUrl:`http://localhost:${c}/`,authToken:h,isRemote:!1,displayHost:`localhost:${c}`}},[j,y,c]),p=$===n,N=!p;s.useEffect(()=>{const t=new AbortController,h=async()=>{try{(await fetch(u,{signal:t.signal})).ok?(d(!0),m(null)):(d(!1),m(l?`Remote CLIProxy at ${x} returned an error`:"CLIProxy returned an error"))}catch(a){if(a instanceof Error&&a.name==="AbortError")return;d(!1),m(l?`Remote CLIProxy at ${x} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return h().finally(()=>clearTimeout(o)),()=>t.abort()},[u,l,x]);const C=s.useCallback(()=>{if(!(!p||!i.current?.contentWindow||!r))try{const t=u.replace(/\/$/,"");if(!i.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}i.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:r},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[r,u,p]);s.useEffect(()=>{C()},[C]);const U=s.useCallback(()=>{b(n)},[n]),A=()=>{b(null),E(t=>t+1),m(null),d(!1)};return!I&&g?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:A,children:[e.jsx(L,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(H,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:g}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[S&&!N&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-green-600 font-medium",children:"Remote"}),e.jsx("span",{className:"text-blue-300 dark:text-blue-700",children:"|"})]}),e.jsx(W,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:r&&r.length>4?`***${r.slice(-4)}`:r||"ccs"})]}),e.jsx("a",{href:"/settings?tab=auth",className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",title:"Manage auth tokens",children:e.jsx(G,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>T(!1),children:e.jsx(_,{className:"h-3.5 w-3.5"})})]})}),N&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(L,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`Loading Control Panel from ${x}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:i,src:n,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:U},`${n}:${R}`)]})}function te(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(z,{})})}export{te as CliproxyControlPanelPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-
|
|
1
|
+
import{j as e}from"./radix-ui-C1Gpgz6I.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-CetY4Iww.js";function f({open:i,onConfirm:l,onCancel:r,title:s,description:t,confirmText:a="Confirm",variant:o="default"}){return e.jsx(c,{open:i,onOpenChange:n=>!n&&r(),children:e.jsxs(d,{children:[e.jsxs(g,{children:[e.jsx(x,{children:s}),e.jsx(h,{children:t})]}),e.jsxs(j,{children:[e.jsx(A,{onClick:r,children:"Cancel"}),e.jsx(D,{onClick:l,className:o==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:a})]})]})})}export{f as C};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-CwcVwplj.js";import{aU as g,aV as we,B as b,b as v,X as le,Y as re,Z as ce,_ as de,ak as ye,al as be,$ as Q,M as Y,m as J,L as C,I as te,q as ue,aW as Ce,S as y,H as Se,J as ke,K as H,aX as Fe,c as W}from"./index-DiWdJxAN.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{a as Pe,u as M,b as S}from"./tanstack-matWclUm.js";import{C as Me}from"./confirm-dialog-DxtbIbqy.js";import{R as me,L as xe,ah as Ae,j as Re,a0 as Le,Z as ae,I as Te,ak as Ee,a as Oe,T as _e,a4 as qe,ao as Ie,av as ne,K as De,x as Ue,aw as Ke,q as he,r as pe}from"./icons-DGASzt3M.js";import{S as X}from"./separator-CrJ4MtV5.js";import{S as V}from"./switch-B1VCWktQ.js";import{t as A}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CFpc3HGP.js";async function Qe(){const s=await fetch(g("/copilot/status"));if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Je(){const s=await fetch(g("/copilot/config"));if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Be(){const s=await fetch(g("/copilot/models"));if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function Ge(){const s=await fetch(g("/copilot/settings/raw"));if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function ze(s){const t=await fetch(g("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update copilot config");return t.json()}async function He(s){const t=await fetch(g("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new we("Copilot raw settings changed externally");if(!t.ok)throw new Error("Failed to save copilot raw settings");return t.json()}async function Ve(){const s=await fetch(g("/copilot/auth/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function $e(){const s=await fetch(g("/copilot/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function We(){const s=await fetch(g("/copilot/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function Xe(){const s=await fetch(g("/copilot/info"));if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function Ye(s){const t=await fetch(g("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!t.ok)throw new Error("Failed to install copilot-api");return t.json()}function fe(){const s=Pe(),t=M({queryKey:["copilot-status"],queryFn:Qe,refetchInterval:5e3}),o=M({queryKey:["copilot-config"],queryFn:Je}),c=M({queryKey:["copilot-models"],queryFn:Be}),a=M({queryKey:["copilot-raw-settings"],queryFn:Ge}),d=M({queryKey:["copilot-info"],queryFn:Xe}),l=S({mutationFn:ze,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=S({mutationFn:He,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=S({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),h=S({mutationFn:$e,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),x=S({mutationFn:We,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),n=S({mutationFn:Ye,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return j.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:o.data,configLoading:o.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:l.mutate,updateConfigAsync:l.mutateAsync,isUpdating:l.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:u.mutate,startAuthAsync:u.mutateAsync,isAuthenticating:u.isPending,authResult:u.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:x.mutate,isStoppingDaemon:x.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}),[t.data,t.isLoading,t.error,t.refetch,o.data,o.isLoading,c.data,c.isLoading,a.data,a.isLoading,a.refetch,l.mutate,l.mutateAsync,l.isPending,i.mutate,i.mutateAsync,i.isPending,u.mutate,u.mutateAsync,u.isPending,u.data,h.mutate,h.isPending,x.mutate,x.isPending,d.data,d.isLoading,d.refetch,n.mutate,n.mutateAsync,n.isPending])}function Ze({rawSettings:s,rawSettingsLoading:t,isUpdating:o,isSavingRawSettings:c,hasChanges:a,isRawJsonValid:d,onRefresh:l,onSave:i}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),s&&e.jsx(b,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",s.exists?new Date(s.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:l,disabled:t,children:e.jsx(me,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:i,disabled:o||c||!a||!d,children:o||c?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const es=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],ss=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ie(s){switch(s){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ts(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function D({label:s,description:t,value:o,onChange:c,models:a,disabled:d}){const l=a.find(i=>i.id===o);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsxs(le,{value:o||"",onValueChange:c,disabled:d,children:[e.jsx(re,{className:"h-9",children:e.jsx(ce,{placeholder:"Select model",children:o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o}),l?.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(l.minPlan)}`,children:l.minPlan})]})})}),e.jsx(de,{className:"max-h-[300px]",children:e.jsxs(ye,{children:[e.jsxs(be,{className:"text-xs text-muted-foreground",children:["Available Models (",a.length,")"]}),a.map(i=>e.jsx(Q,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ts(i.multiplier)}),i.preview&&e.jsx(b,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),o===i.id&&e.jsx(Re,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function as({currentModel:s,opusModel:t,sonnetModel:o,haikuModel:c,models:a,modelsLoading:d,onApplyPreset:l,onUpdateModel:i,onUpdateOpusModel:u,onUpdateSonnetModel:h,onUpdateHaikuModel:x}){return e.jsx(Y,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:es.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(X,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:i,models:a,disabled:d}),e.jsx(D,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:t||s,onChange:u,models:a,disabled:d}),e.jsx(D,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||s,onChange:h,models:a,disabled:d}),e.jsx(D,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||s,onChange:x,models:a,disabled:d})]})]})]})})})}function ns({enabled:s,autoStart:t,port:o,accountType:c,rateLimit:a,waitOnLimit:d,onUpdateEnabled:l,onUpdateAutoStart:i,onUpdatePort:u,onUpdateAccountType:h,onUpdateRateLimit:x,onUpdateWaitOnLimit:n}){return e.jsx(Y,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"enabled",className:"text-sm font-medium",children:"Enable Copilot"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow using GitHub Copilot subscription"})]}),e.jsx(V,{id:"enabled",checked:s,onCheckedChange:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Basic Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:o,onChange:N=>u(parseInt(N.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:c,onValueChange:h,children:[e.jsx(re,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(Q,{value:"individual",children:"Individual"}),e.jsx(Q,{value:"business",children:"Business"}),e.jsx(Q,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(X,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Rate Limiting"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:a,onChange:N=>x(N.target.value),placeholder:"No limit",min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"wait-on-limit",className:"text-xs",children:"Wait on Rate Limit"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Wait instead of error when limit hit"})]}),e.jsx(V,{id:"wait-on-limit",checked:d,onCheckedChange:n})]})]}),e.jsx(X,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Daemon Settings"}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start copilot-api when using profile"})]}),e.jsx(V,{id:"auto-start",checked:t,onCheckedChange:i})]})]})]})})})}function U({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t}),e.jsx(ue,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function is({rawSettings:s}){return e.jsx(Y,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(J,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Te,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:s.path}),e.jsx(ue,{value:s.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),e.jsx(b,{variant:"outline",className:s.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:s.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const os=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function oe(s){const t=s?.env||{};return os.filter(o=>!t[o]?.trim())}function ls(){const{config:s,configLoading:t,models:o,modelsLoading:c,rawSettings:a,rawSettingsLoading:d,updateConfigAsync:l,isUpdating:i,saveRawSettingsAsync:u,isSavingRawSettings:h,refetchRawSettings:x}=fe(),[n,N]=j.useState({}),[f,k]=j.useState(null),[B,R]=j.useState(!1),L=n.enabled??s?.enabled??!1,T=n.autoStart??s?.auto_start??!1,F=n.port??s?.port??4141,E=n.accountType??s?.account_type??"individual",O=n.model??s?.model??"claude-sonnet-4-5-20250929",p=n.rateLimit??s?.rate_limit?.toString()??"",_=n.waitOnLimit??s?.wait_on_limit??!0,q=n.opusModel??s?.opus_model??"",I=n.sonnetModel??s?.sonnet_model??"",P=n.haikuModel??s?.haiku_model??"",G=(m,w)=>{N(ve=>({...ve,[m]:w}))},z=m=>{N(w=>({...w,model:m.default,opusModel:m.opus,sonnetModel:m.sonnet,haikuModel:m.haiku})),A.success(`Applied "${m.name}" preset`)},r=j.useMemo(()=>f!==null?f:a?.settings?JSON.stringify(a.settings,null,2):`{
|
|
1
|
+
import{j as e}from"./radix-ui-C1Gpgz6I.js";import{aV as g,aW as we,B as b,b as v,q as le,r as re,s as ce,t as de,al as ye,am as be,v as K,U as X,m as J,L as C,I as te,w as ue,aX as Ce,S as y,O as Se,Q as ke,R as H,aY as Fe,c as W}from"./index-k-HuyjpO.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{a as Pe,u as M,b as S}from"./tanstack-DDJIhNJd.js";import{C as Me}from"./confirm-dialog-Dn3SrwNV.js";import{R as me,L as xe,ai as Ae,k as Re,a1 as Le,Z as ae,I as Te,al as Ee,a as Oe,T as _e,a5 as qe,aq as Ie,ax as ne,K as De,y as Ue,ay as Qe,r as he,s as pe}from"./icons-DrewC9c3.js";import{S as Y}from"./separator-BLVyAGAm.js";import{S as V}from"./switch-CwLyB4JK.js";import{t as A}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CetY4Iww.js";async function Ke(){const s=await fetch(g("/copilot/status"));if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Je(){const s=await fetch(g("/copilot/config"));if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Be(){const s=await fetch(g("/copilot/models"));if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function Ge(){const s=await fetch(g("/copilot/settings/raw"));if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function ze(s){const t=await fetch(g("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update copilot config");return t.json()}async function He(s){const t=await fetch(g("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new we("Copilot raw settings changed externally");if(!t.ok)throw new Error("Failed to save copilot raw settings");return t.json()}async function Ve(){const s=await fetch(g("/copilot/auth/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function $e(){const s=await fetch(g("/copilot/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function We(){const s=await fetch(g("/copilot/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function Ye(){const s=await fetch(g("/copilot/info"));if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function Xe(s){const t=await fetch(g("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!t.ok)throw new Error("Failed to install copilot-api");return t.json()}function fe(){const s=Pe(),t=M({queryKey:["copilot-status"],queryFn:Ke,refetchInterval:5e3}),o=M({queryKey:["copilot-config"],queryFn:Je}),c=M({queryKey:["copilot-models"],queryFn:Be}),a=M({queryKey:["copilot-raw-settings"],queryFn:Ge}),d=M({queryKey:["copilot-info"],queryFn:Ye}),l=S({mutationFn:ze,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=S({mutationFn:He,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=S({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),h=S({mutationFn:$e,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),x=S({mutationFn:We,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),n=S({mutationFn:Xe,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return j.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:o.data,configLoading:o.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:l.mutate,updateConfigAsync:l.mutateAsync,isUpdating:l.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:u.mutate,startAuthAsync:u.mutateAsync,isAuthenticating:u.isPending,authResult:u.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:x.mutate,isStoppingDaemon:x.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}),[t.data,t.isLoading,t.error,t.refetch,o.data,o.isLoading,c.data,c.isLoading,a.data,a.isLoading,a.refetch,l.mutate,l.mutateAsync,l.isPending,i.mutate,i.mutateAsync,i.isPending,u.mutate,u.mutateAsync,u.isPending,u.data,h.mutate,h.isPending,x.mutate,x.isPending,d.data,d.isLoading,d.refetch,n.mutate,n.mutateAsync,n.isPending])}function Ze({rawSettings:s,rawSettingsLoading:t,isUpdating:o,isSavingRawSettings:c,hasChanges:a,isRawJsonValid:d,onRefresh:l,onSave:i}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),s&&e.jsx(b,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",s.exists?new Date(s.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:l,disabled:t,children:e.jsx(me,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:i,disabled:o||c||!a||!d,children:o||c?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const es=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],ss=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ie(s){switch(s){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ts(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function D({label:s,description:t,value:o,onChange:c,models:a,disabled:d}){const l=a.find(i=>i.id===o);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsxs(le,{value:o||"",onValueChange:c,disabled:d,children:[e.jsx(re,{className:"h-9",children:e.jsx(ce,{placeholder:"Select model",children:o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o}),l?.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(l.minPlan)}`,children:l.minPlan})]})})}),e.jsx(de,{className:"max-h-[300px]",children:e.jsxs(ye,{children:[e.jsxs(be,{className:"text-xs text-muted-foreground",children:["Available Models (",a.length,")"]}),a.map(i=>e.jsx(K,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ts(i.multiplier)}),i.preview&&e.jsx(b,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),o===i.id&&e.jsx(Re,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function as({currentModel:s,opusModel:t,sonnetModel:o,haikuModel:c,models:a,modelsLoading:d,onApplyPreset:l,onUpdateModel:i,onUpdateOpusModel:u,onUpdateSonnetModel:h,onUpdateHaikuModel:x}){return e.jsx(X,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:es.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(Y,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:i,models:a,disabled:d}),e.jsx(D,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:t||s,onChange:u,models:a,disabled:d}),e.jsx(D,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||s,onChange:h,models:a,disabled:d}),e.jsx(D,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||s,onChange:x,models:a,disabled:d})]})]})]})})})}function ns({enabled:s,autoStart:t,port:o,accountType:c,rateLimit:a,waitOnLimit:d,onUpdateEnabled:l,onUpdateAutoStart:i,onUpdatePort:u,onUpdateAccountType:h,onUpdateRateLimit:x,onUpdateWaitOnLimit:n}){return e.jsx(X,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"enabled",className:"text-sm font-medium",children:"Enable Copilot"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow using GitHub Copilot subscription"})]}),e.jsx(V,{id:"enabled",checked:s,onCheckedChange:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Basic Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:o,onChange:N=>u(parseInt(N.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:c,onValueChange:h,children:[e.jsx(re,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(K,{value:"individual",children:"Individual"}),e.jsx(K,{value:"business",children:"Business"}),e.jsx(K,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(Y,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Rate Limiting"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:a,onChange:N=>x(N.target.value),placeholder:"No limit",min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"wait-on-limit",className:"text-xs",children:"Wait on Rate Limit"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Wait instead of error when limit hit"})]}),e.jsx(V,{id:"wait-on-limit",checked:d,onCheckedChange:n})]})]}),e.jsx(Y,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Daemon Settings"}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start copilot-api when using profile"})]}),e.jsx(V,{id:"auto-start",checked:t,onCheckedChange:i})]})]})]})})})}function U({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t}),e.jsx(ue,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function is({rawSettings:s}){return e.jsx(X,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(J,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Te,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:s.path}),e.jsx(ue,{value:s.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),e.jsx(b,{variant:"outline",className:s.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:s.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const os=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function oe(s){const t=s?.env||{};return os.filter(o=>!t[o]?.trim())}function ls(){const{config:s,configLoading:t,models:o,modelsLoading:c,rawSettings:a,rawSettingsLoading:d,updateConfigAsync:l,isUpdating:i,saveRawSettingsAsync:u,isSavingRawSettings:h,refetchRawSettings:x}=fe(),[n,N]=j.useState({}),[f,k]=j.useState(null),[B,R]=j.useState(!1),L=n.enabled??s?.enabled??!1,T=n.autoStart??s?.auto_start??!1,F=n.port??s?.port??4141,E=n.accountType??s?.account_type??"individual",O=n.model??s?.model??"claude-sonnet-4-5-20250929",p=n.rateLimit??s?.rate_limit?.toString()??"",_=n.waitOnLimit??s?.wait_on_limit??!0,q=n.opusModel??s?.opus_model??"",I=n.sonnetModel??s?.sonnet_model??"",P=n.haikuModel??s?.haiku_model??"",G=(m,w)=>{N(ve=>({...ve,[m]:w}))},z=m=>{N(w=>({...w,model:m.default,opusModel:m.opus,sonnetModel:m.sonnet,haikuModel:m.haiku})),A.success(`Applied "${m.name}" preset`)},r=j.useMemo(()=>f!==null?f:a?.settings?JSON.stringify(a.settings,null,2):`{
|
|
2
2
|
"env": {}
|
|
3
|
-
}`,[f,a]),ge=j.useCallback(m=>{k(m)},[]),Z=j.useMemo(()=>{try{return JSON.parse(r),!0}catch{return!1}},[r]),je=j.useMemo(()=>{const m=Object.keys(n).length>0,w=f!==null&&f!==JSON.stringify(a?.settings,null,2);return m||w},[n,f,a]),ee=j.useMemo(()=>{if(f!==null)try{return JSON.parse(f)}catch{return a?.settings}return a?.settings},[f,a?.settings]),Ne=j.useMemo(()=>oe(ee),[ee]),se=async()=>{try{if(Object.keys(n).length>0&&await l({enabled:L,auto_start:T,port:F,account_type:E,model:O,rate_limit:p?parseInt(p,10):null,wait_on_limit:_,opus_model:q||void 0,sonnet_model:I||void 0,haiku_model:P||void 0}),f!==null&&Z){const m=JSON.parse(r),w=oe(m);await u({settings:m,expectedMtime:a?.mtime}),w.length>0?A.success("Copilot configuration saved",{description:`Missing fields will use defaults: ${w.join(", ")}`}):A.success("Copilot configuration saved")}else A.success("Copilot configuration saved");N({}),k(null)}catch(m){Ce(m)?R(!0):A.error("Failed to save settings")}};return{configLoading:t,rawSettingsLoading:d,modelsLoading:c,isUpdating:i,isSavingRawSettings:h,models:o,rawSettings:a,rawJsonContent:r,rawJsonEdits:f,enabled:L,autoStart:T,port:F,accountType:E,currentModel:O,rateLimit:p,waitOnLimit:_,opusModel:q,sonnetModel:I,haikuModel:P,isRawJsonValid:Z,hasChanges:je,conflictDialog:B,updateField:G,applyPreset:z,handleRawJsonChange:ge,handleSave:se,handleConflictResolve:async m=>{R(!1),m?(await x(),se()):k(null)},refetchRawSettings:x,missingRequiredFields:Ne}}function rs(){const{configLoading:s,rawSettingsLoading:t,modelsLoading:o,isUpdating:c,isSavingRawSettings:a,models:d,rawSettings:l,rawJsonContent:i,rawJsonEdits:u,enabled:h,autoStart:x,port:n,accountType:N,currentModel:f,rateLimit:k,waitOnLimit:B,opusModel:R,sonnetModel:L,haikuModel:T,isRawJsonValid:F,hasChanges:E,conflictDialog:O,updateField:p,applyPreset:_,handleRawJsonChange:q,handleSave:I,handleConflictResolve:P,refetchRawSettings:G,missingRequiredFields:z}=ls();return s||t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ze,{rawSettings:l,rawSettingsLoading:t,isUpdating:c,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:F,onRefresh:()=>G(),onSave:I}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Se,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ke,{className:"w-full",children:[e.jsx(H,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(H,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(H,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(as,{currentModel:f,opusModel:R,sonnetModel:L,haikuModel:T,models:d,modelsLoading:o,onApplyPreset:_,onUpdateModel:r=>p("model",r),onUpdateOpusModel:r=>p("opusModel",r),onUpdateSonnetModel:r=>p("sonnetModel",r),onUpdateHaikuModel:r=>p("haikuModel",r)}),e.jsx(ns,{enabled:h,autoStart:x,port:n,accountType:N,rateLimit:k,waitOnLimit:B,onUpdateEnabled:r=>p("enabled",r),onUpdateAutoStart:r=>p("autoStart",r),onUpdatePort:r=>p("port",r),onUpdateAccountType:r=>p("accountType",r),onUpdateRateLimit:r=>p("rateLimit",r),onUpdateWaitOnLimit:r=>p("waitOnLimit",r)}),e.jsx(is,{rawSettings:l})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ee,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Fe,{rawJsonContent:i,isRawJsonValid:F,rawJsonEdits:u,rawSettingsEnv:l?.settings?.env,onChange:q,missingRequiredFields:z})]})]}),e.jsx(Me,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>P(!0),onCancel:()=>P(!1)})]})}function $({title:s,children:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:s}),e.jsx("div",{className:"space-y-1",children:t})]})}function
|
|
3
|
+
}`,[f,a]),ge=j.useCallback(m=>{k(m)},[]),Z=j.useMemo(()=>{try{return JSON.parse(r),!0}catch{return!1}},[r]),je=j.useMemo(()=>{const m=Object.keys(n).length>0,w=f!==null&&f!==JSON.stringify(a?.settings,null,2);return m||w},[n,f,a]),ee=j.useMemo(()=>{if(f!==null)try{return JSON.parse(f)}catch{return a?.settings}return a?.settings},[f,a?.settings]),Ne=j.useMemo(()=>oe(ee),[ee]),se=async()=>{try{if(Object.keys(n).length>0&&await l({enabled:L,auto_start:T,port:F,account_type:E,model:O,rate_limit:p?parseInt(p,10):null,wait_on_limit:_,opus_model:q||void 0,sonnet_model:I||void 0,haiku_model:P||void 0}),f!==null&&Z){const m=JSON.parse(r),w=oe(m);await u({settings:m,expectedMtime:a?.mtime}),w.length>0?A.success("Copilot configuration saved",{description:`Missing fields will use defaults: ${w.join(", ")}`}):A.success("Copilot configuration saved")}else A.success("Copilot configuration saved");N({}),k(null)}catch(m){Ce(m)?R(!0):A.error("Failed to save settings")}};return{configLoading:t,rawSettingsLoading:d,modelsLoading:c,isUpdating:i,isSavingRawSettings:h,models:o,rawSettings:a,rawJsonContent:r,rawJsonEdits:f,enabled:L,autoStart:T,port:F,accountType:E,currentModel:O,rateLimit:p,waitOnLimit:_,opusModel:q,sonnetModel:I,haikuModel:P,isRawJsonValid:Z,hasChanges:je,conflictDialog:B,updateField:G,applyPreset:z,handleRawJsonChange:ge,handleSave:se,handleConflictResolve:async m=>{R(!1),m?(await x(),se()):k(null)},refetchRawSettings:x,missingRequiredFields:Ne}}function rs(){const{configLoading:s,rawSettingsLoading:t,modelsLoading:o,isUpdating:c,isSavingRawSettings:a,models:d,rawSettings:l,rawJsonContent:i,rawJsonEdits:u,enabled:h,autoStart:x,port:n,accountType:N,currentModel:f,rateLimit:k,waitOnLimit:B,opusModel:R,sonnetModel:L,haikuModel:T,isRawJsonValid:F,hasChanges:E,conflictDialog:O,updateField:p,applyPreset:_,handleRawJsonChange:q,handleSave:I,handleConflictResolve:P,refetchRawSettings:G,missingRequiredFields:z}=ls();return s||t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ze,{rawSettings:l,rawSettingsLoading:t,isUpdating:c,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:F,onRefresh:()=>G(),onSave:I}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Se,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ke,{className:"w-full",children:[e.jsx(H,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(H,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(H,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(as,{currentModel:f,opusModel:R,sonnetModel:L,haikuModel:T,models:d,modelsLoading:o,onApplyPreset:_,onUpdateModel:r=>p("model",r),onUpdateOpusModel:r=>p("opusModel",r),onUpdateSonnetModel:r=>p("sonnetModel",r),onUpdateHaikuModel:r=>p("haikuModel",r)}),e.jsx(ns,{enabled:h,autoStart:x,port:n,accountType:N,rateLimit:k,waitOnLimit:B,onUpdateEnabled:r=>p("enabled",r),onUpdateAutoStart:r=>p("autoStart",r),onUpdatePort:r=>p("port",r),onUpdateAccountType:r=>p("accountType",r),onUpdateRateLimit:r=>p("rateLimit",r),onUpdateWaitOnLimit:r=>p("waitOnLimit",r)}),e.jsx(is,{rawSettings:l})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ee,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Fe,{rawJsonContent:i,isRawJsonValid:F,rawJsonEdits:u,rawSettingsEnv:l?.settings?.env,onChange:q,missingRequiredFields:z})]})]}),e.jsx(Me,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>P(!0),onCancel:()=>P(!1)})]})}function $({title:s,children:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:s}),e.jsx("div",{className:"space-y-1",children:t})]})}function Q({icon:s,label:t,status:o,statusText:c,variant:a="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(s,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:t})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:W("w-4 h-4",a==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:W("text-xs",a==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function cs(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Cs(){const{status:s,statusLoading:t,refetchStatus:o,startAuth:c,isAuthenticating:a,startDaemon:d,isStartingDaemon:l,stopDaemon:i,isStoppingDaemon:u,install:h,isInstalling:x}=fe();return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"Copilot"})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(),disabled:t,children:e.jsx(me,{className:W("w-4 h-4",t&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"GitHub Copilot proxy"})]}),e.jsx(J,{className:"flex-1",children:t?e.jsx(cs,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:"Unofficial API - Use at Your Own Risk"})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:"Reverse-engineered API - may break anytime"}),e.jsx("li",{children:"Excessive use may trigger account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs($,{title:"Setup",children:[e.jsx(Q,{icon:qe,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:"Installed":"Missing"}),!s?.installed&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>h(void 0),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Installing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),"Install copilot-api"]})}),s?.installed&&e.jsx(Q,{icon:ne,label:"Integration",status:s?.enabled??!1,statusText:s?.enabled?"Enabled":"Disabled"})]}),s?.installed&&e.jsxs($,{title:"Auth",children:[e.jsx(Q,{icon:De,label:"GitHub",status:s?.authenticated??!1,statusText:s?.authenticated?"Connected":"Not Connected"}),!s?.authenticated&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>c(),disabled:a,children:a?"Authenticating...":"Authenticate"})]}),s?.authenticated&&e.jsxs($,{title:"Daemon",children:[e.jsx(Q,{icon:Ue,label:"Status",status:s?.daemon_running??!1,statusText:s?.daemon_running?"Running":"Stopped"}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:["Port: ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:u,children:[e.jsx(Qe,{className:"w-3.5 h-3.5 mr-1.5"}),u?"Stopping...":"Stop"]}):e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>d(),disabled:l,children:[e.jsx(ne,{className:"w-3.5 h-3.5 mr-1.5"}),l?"Starting...":"Start"]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Proxy"}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-green-500"}),"Active"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3 text-muted-foreground"}),"Inactive"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(rs,{})})]})}export{Cs as CopilotPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-CwcVwplj.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{aU as v,aV as Ze,B as D,b as f,c as ie,m as E,H as $e,J as Ye,K as W,M as ee,L as P,I as se,aX as We,a4 as es,a5 as ss,a6 as ts,a7 as as,a8 as ns,am as rs,X as is,Y as os,Z as ls,_ as cs,ak as ds,al as us,$ as be,aW as ms}from"./index-DiWdJxAN.js";import{a as hs,u as q,b as _}from"./tanstack-matWclUm.js";import{D as Ae}from"./default-ports-1QQSffYX.js";import{S as Ce}from"./switch-B1VCWktQ.js";import{S as xs}from"./separator-CrJ4MtV5.js";import{R as Se,T as fs,ax as ps,K as G,a4 as gs,aw as ke,av as js,L as M,s as ws,ah as vs,a0 as ys,Z as te,ak as Ns,q as bs,r as Cs}from"./icons-DGASzt3M.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";async function Ss(){const s=await fetch(v("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function ks(){const s=await fetch(v("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function As(){const s=await fetch(v("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ds(){const s=await fetch(v("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function _s(s){const a=await fetch(v("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function Ms(s){const a=await fetch(v("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new Ze("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Ps(){const s=await fetch(v("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Ts(s){const a=await fetch(v("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const d=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(d.error||"Manual import failed")}return a.json()}async function Fs(){const s=await fetch(v("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Rs(){const s=await fetch(v("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function Os(){const s=hs(),a=q({queryKey:["cursor-status"],queryFn:Ss,refetchInterval:5e3}),d=q({queryKey:["cursor-config"],queryFn:ks}),u=q({queryKey:["cursor-models"],queryFn:As}),m=q({queryKey:["cursor-raw-settings"],queryFn:Ds}),l=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},n=_({mutationFn:_s,onSuccess:l}),c=_({mutationFn:Ms,onSuccess:l}),h=_({mutationFn:Ps,onSuccess:l}),i=_({mutationFn:Ts,onSuccess:l}),y=_({mutationFn:Fs,onSuccess:l}),C=_({mutationFn:Rs,onSuccess:l});return p.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:d.data,configLoading:d.isLoading,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:m.data,rawSettingsLoading:m.isLoading,refetchRawSettings:m.refetch,updateConfig:n.mutate,updateConfigAsync:n.mutateAsync,isUpdatingConfig:n.isPending,saveRawSettings:c.mutate,saveRawSettingsAsync:c.mutateAsync,isSavingRawSettings:c.isPending,autoDetectAuth:h.mutate,autoDetectAuthAsync:h.mutateAsync,isAutoDetectingAuth:h.isPending,autoDetectAuthResult:h.data,importManualAuth:i.mutate,importManualAuthAsync:i.mutateAsync,isImportingManualAuth:i.isPending,manualAuthResult:i.data,startDaemon:y.mutate,startDaemonAsync:y.mutateAsync,isStartingDaemon:y.isPending,stopDaemon:C.mutate,stopDaemonAsync:C.mutateAsync,isStoppingDaemon:C.isPending}),[a.data,a.isLoading,a.error,a.refetch,d.data,d.isLoading,u.data,u.isLoading,m.data,m.isLoading,m.refetch,n.mutate,n.mutateAsync,n.isPending,c.mutate,c.mutateAsync,c.isPending,h.mutate,h.mutateAsync,h.isPending,h.data,i.mutate,i.mutateAsync,i.isPending,i.data,y.mutate,y.mutateAsync,y.isPending,C.mutate,C.mutateAsync,C.isPending])}function ae(s){return{port:String(s?.port??Ae),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function N(s,a,d){return s.find(m=>a.some(l=>l.test(m.id)))?.id??d}function ne(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,a,d){const u=new Set(a.map(ne)),m=s.find(n=>u.has(ne(n.id)));if(m)return m.id;const l=s.find(n=>u.has(ne(n.name)));return l?l.id:d}function Is(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function U({label:s,description:a,value:d,models:u,disabled:m,allowDefaultFallback:l=!1,onChange:n}){const c=d||(l?"__default":""),h=u.find(i=>i.id===d);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(P,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(is,{value:c,onValueChange:i=>{if(l&&i==="__default"){n("");return}n(i)},disabled:m,children:[e.jsx(os,{className:"h-9",children:e.jsx(ls,{placeholder:"Select model",children:c&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l&&c==="__default"?"Use Default Model":h?.name||c}),h?.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:h.provider})]})})}),e.jsx(cs,{className:"max-h-[300px]",children:e.jsxs(ds,{children:[e.jsxs(us,{className:"text-xs text-muted-foreground",children:["Available Models (",u.length,")"]}),l&&e.jsx(be,{value:"__default",children:"Use Default Model"}),u.map(i=>e.jsx(be,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})},i.id))]})})]})]})}function re({icon:s,label:a,ok:d,detail:u}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(bs,{className:"h-4 w-4 text-green-500"}):e.jsx(Cs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:ie("text-xs",d?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function Xs(){const{status:s,statusLoading:a,refetchStatus:d,config:u,updateConfigAsync:m,isUpdatingConfig:l,models:n,modelsLoading:c,currentModel:h,rawSettings:i,rawSettingsLoading:y,refetchRawSettings:C,saveRawSettingsAsync:De,isSavingRawSettings:oe,autoDetectAuthAsync:_e,isAutoDetectingAuth:le,importManualAuthAsync:Me,isImportingManualAuth:ce,startDaemonAsync:Pe,isStartingDaemon:Te,stopDaemonAsync:Fe,isStoppingDaemon:de}=Os(),[A,ue]=p.useState(()=>ae()),[g,me]=p.useState(!1),[he,Re]=p.useState("{}"),[T,z]=p.useState(!1),[Oe,O]=p.useState(!1),[B,xe]=p.useState(""),[J,fe]=p.useState(""),S=ae(u),pe=g?A.port:S.port,K=g?A.auto_start:S.auto_start,H=g?A.ghost_mode:S.ghost_mode,j=g?A.model:S.model,Q=g?A.opus_model:S.opus_model,V=g?A.sonnet_model:S.sonnet_model,X=g?A.haiku_model:S.haiku_model,Z=T?he:JSON.stringify(i?.settings??{},null,2),ge=!!i,F=p.useMemo(()=>Is(Z),[Z]),je=F.isValid,we=g||T,Ie=!T||ge&&je,I=p.useMemo(()=>{const t=new Set,r=[...n].sort((k,Y)=>k.name.localeCompare(Y.name)),x=r.filter(k=>t.has(k.id)?!1:(t.add(k.id),!0));return j&&!r.some(k=>k.id===j)?[{id:j,name:j,provider:"custom"},...x]:x},[n,j]),w=t=>{ue(r=>t(g?r:S)),me(!0)},Le=!!(s?.enabled&&s?.authenticated&&!s?.token_expired),Ee=p.useMemo(()=>s?.enabled?e.jsx(D,{children:"Enabled"}):e.jsx(D,{variant:"secondary",children:"Disabled"}),[s?.enabled]),qe=async({suppressSuccessToast:t=!1}={})=>{const r=Number(pe);if(!Number.isInteger(r)||r<1||r>65535)return o.error("Port must be an integer between 1 and 65535"),!1;if(!j.trim())return o.error("Default model is required"),!1;try{return await m({port:r,auto_start:K,ghost_mode:H,model:j,opus_model:Q||void 0,sonnet_model:V||void 0,haiku_model:X||void 0}),me(!1),ue(ae({port:r,auto_start:K,ghost_mode:H,model:j,opus_model:Q||void 0,sonnet_model:V||void 0,haiku_model:X||void 0})),t||o.success("Cursor config and model mapping saved"),!0}catch(x){return o.error(x.message||"Failed to save config"),!1}},$=t=>{if(c){o.error("Models are still loading. Please wait before applying a preset.");return}if(n.length===0){o.error("No models available yet. Start the daemon and refresh first.");return}const r=j||h||n[0]?.id||"gpt-5.3-codex",x=b(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],N(n,[/gpt[-.]?5.*codex/i],r)),k=b(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],N(n,[/gpt[-.]?5.*codex.*max/i],x)),Y=b(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],N(n,[/gpt[-.]?5.*fast/i],x)),Qe=b(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],N(n,[/gpt[-.]?5.*mini/i],Y)),ye=b(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],N(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],x)),Ne=b(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],N(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],x)),Ve=b(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],N(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ne)),L=b(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],N(n,[/gemini[-.]?3.*pro/i],x)),Xe=b(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],N(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],L));if(t==="codex53"){w(R=>({...R,model:x,opus_model:k,sonnet_model:x,haiku_model:Qe})),o.success("Applied GPT-5.3 Codex preset");return}if(t==="claude46"){w(R=>({...R,model:ye,opus_model:ye,sonnet_model:Ne,haiku_model:Ve})),o.success("Applied Claude 4.6 preset");return}w(R=>({...R,model:L,opus_model:L,sonnet_model:L,haiku_model:Xe})),o.success("Applied Gemini 3 preset")},ve=async t=>{try{await m({enabled:t}),o.success(t?"Cursor integration enabled":"Cursor integration disabled")}catch(r){o.error(r.message||"Failed to update integration state")}},Ge=async()=>{try{await _e(),o.success("Cursor credentials imported")}catch(t){o.error(t.message||"Auto-detect failed")}},Ue=async()=>{if(!B.trim()||!J.trim()){o.error("Token and machine ID are required");return}try{await Me({accessToken:B.trim(),machineId:J.trim()}),o.success("Cursor credentials imported"),O(!1),xe(""),fe("")}catch(t){o.error(t.message||"Manual import failed")}},ze=async()=>{try{const t=await Pe();if(!t.success){o.error(t.error||"Failed to start daemon");return}o.success(`Daemon started${t.pid?` (PID: ${t.pid})`:""}`)}catch(t){o.error(t.message||"Failed to start daemon")}},Be=async()=>{try{const t=await Fe();if(!t.success){o.error(t.error||"Failed to stop daemon");return}o.success("Daemon stopped")}catch(t){o.error(t.message||"Failed to stop daemon")}},Je=async({suppressSuccessToast:t=!1}={})=>{if(!ge)return o.error("Raw settings are still loading. Please wait and try again."),!1;if(!F.isValid||!F.settings)return o.error(F.error||"Invalid JSON"),!1;try{return await De({settings:F.settings,expectedMtime:i?.mtime}),z(!1),t||o.success("Raw settings saved"),!0}catch(r){return ms(r)?o.error("Raw settings changed externally. Refresh and retry."):o.error(r.message||"Failed to save raw settings"),!1}},Ke=async()=>{if(!we)return;const t=g,r=T;t&&!await qe({suppressSuccessToast:r})||r&&!await Je({suppressSuccessToast:t})||t&&r&&o.success("Cursor configuration saved")},He=()=>{z(!1),d(),C()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:"Cursor"}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:"Beta"}),Ee]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:a,children:e.jsx(Se,{className:ie("w-4 h-4",a&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dedicated Cursor integration controls"})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:"Unofficial API - Use at Your Own Risk"})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:"Reverse-engineered integration may break anytime"}),e.jsx("li",{children:"Abuse or excessive usage may risk account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{icon:ps,label:"Integration",ok:!!s?.enabled,detail:s?.enabled?"Enabled":"Disabled"}),e.jsx(re,{icon:G,label:"Authentication",ok:!!(s?.authenticated&&!s?.token_expired),detail:s?.authenticated?s?.token_expired?"Expired":s.auth_method??"Connected":"Not connected"}),e.jsx(re,{icon:gs,label:"Daemon",ok:!!s?.daemon_running,detail:s?.daemon_running?"Running":"Stopped"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Actions"}),s?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>ve(!1),disabled:l,children:[e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Disable Integration"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>ve(!0),disabled:l,children:[e.jsx(js,{className:"w-3.5 h-3.5 mr-1.5"}),"Enable Integration"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ge,disabled:le,children:[le?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Auto-detect Auth"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>O(!0),children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Manual Auth Import"]}),s?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Be,disabled:de,children:[de?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Stop Daemon"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:ze,disabled:!Le,children:[Te?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ws,{className:"w-3.5 h-3.5 mr-1.5"}),"Start Daemon"]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Port"}),e.jsx("span",{children:s?.port??u?.port??Ae})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Cursor Configuration"}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",i.exists?new Date(i.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:He,disabled:a||y,children:e.jsx(Se,{className:ie("w-4 h-4",(a||y)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Ke,disabled:l||oe||!we||!Ie,children:l||oe?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs($e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ye,{className:"w-full",children:[e.jsx(W,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(W,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(W,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("codex53"),disabled:c||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(te,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("claude46"),disabled:c||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(te,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("gemini3"),disabled:c||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(te,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(xs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(U,{label:"Default Model",description:"Used when no specific tier is requested.",value:j,models:I,disabled:c,onChange:t=>{w(r=>({...r,model:t}))}}),e.jsx(U,{label:"Opus (Most capable)",description:"Complex reasoning and highest quality responses.",value:Q,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,opus_model:t}))}}),e.jsx(U,{label:"Sonnet (Balanced)",description:"General coding and day-to-day chat workloads.",value:V,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,sonnet_model:t}))}}),e.jsx(U,{label:"Haiku (Fast)",description:"Low-latency and lightweight request paths.",value:X,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,haiku_model:t}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Runtime Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:pe,onChange:t=>{w(r=>({...r,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start Cursor daemon automatically when integration is used."})]}),e.jsx(Ce,{id:"cursor-auto-start",checked:K,onCheckedChange:t=>{w(r=>({...r,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:"Ghost Mode"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Request `x-ghost-mode` to reduce telemetry."})]}),e.jsx(Ce,{id:"cursor-ghost-mode",checked:H,onCheckedChange:t=>{w(r=>({...r,ghost_mode:t}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Available Models"}),c?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(M,{className:"w-4 h-4 animate-spin"}),"Loading models..."]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No model metadata available yet. Start daemon and refresh."}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===h&&e.jsx(D,{children:"Default"})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ns,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(We,{rawJsonContent:Z,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{z(!0),Re(t)}})]})]})]})})]}),e.jsx(es,{open:Oe,onOpenChange:O,children:e.jsxs(ss,{children:[e.jsxs(ts,{children:[e.jsx(as,{children:"Manual Cursor Auth Import"}),e.jsx(ns,{children:"Provide Cursor access token and machine ID if auto-detect is unavailable."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-token",children:"Access Token"}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:t=>xe(t.target.value),placeholder:"Paste Cursor access token"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-machine-id",children:"Machine ID"}),e.jsx(se,{id:"cursor-manual-machine-id",value:J,onChange:t=>fe(t.target.value),placeholder:"32-char hex (UUID without hyphens)"})]})]}),e.jsxs(rs,{children:[e.jsx(f,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsxs(f,{onClick:Ue,disabled:ce,children:[ce?e.jsx(M,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(G,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})]})}export{Xs as CursorPage};
|
|
1
|
+
import{j as e}from"./radix-ui-C1Gpgz6I.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{aV as v,aW as Ye,B as D,b as f,c as ie,m as E,O as Ze,Q as $e,R as W,U as ee,L as P,I as se,aY as We,a5 as es,a6 as ss,a7 as ts,a8 as as,a9 as ns,an as rs,q as is,r as os,s as ls,t as cs,al as ds,am as us,v as be,aX as ms}from"./index-k-HuyjpO.js";import{a as hs,u as q,b as _}from"./tanstack-DDJIhNJd.js";import{D as Ae}from"./default-ports-1QQSffYX.js";import{S as Ce}from"./switch-CwLyB4JK.js";import{S as xs}from"./separator-BLVyAGAm.js";import{R as Se,T as fs,az as ps,K as G,a5 as gs,ay as ke,ax as js,L as M,t as ws,ai as vs,a1 as ys,Z as te,al as Ns,r as bs,s as Cs}from"./icons-DrewC9c3.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";async function Ss(){const s=await fetch(v("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function ks(){const s=await fetch(v("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function As(){const s=await fetch(v("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ds(){const s=await fetch(v("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function _s(s){const a=await fetch(v("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function Ms(s){const a=await fetch(v("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new Ye("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Ps(){const s=await fetch(v("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Ts(s){const a=await fetch(v("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const d=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(d.error||"Manual import failed")}return a.json()}async function Fs(){const s=await fetch(v("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Rs(){const s=await fetch(v("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function Os(){const s=hs(),a=q({queryKey:["cursor-status"],queryFn:Ss,refetchInterval:5e3}),d=q({queryKey:["cursor-config"],queryFn:ks}),u=q({queryKey:["cursor-models"],queryFn:As}),m=q({queryKey:["cursor-raw-settings"],queryFn:Ds}),l=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},n=_({mutationFn:_s,onSuccess:l}),c=_({mutationFn:Ms,onSuccess:l}),h=_({mutationFn:Ps,onSuccess:l}),i=_({mutationFn:Ts,onSuccess:l}),y=_({mutationFn:Fs,onSuccess:l}),C=_({mutationFn:Rs,onSuccess:l});return p.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:d.data,configLoading:d.isLoading,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:m.data,rawSettingsLoading:m.isLoading,refetchRawSettings:m.refetch,updateConfig:n.mutate,updateConfigAsync:n.mutateAsync,isUpdatingConfig:n.isPending,saveRawSettings:c.mutate,saveRawSettingsAsync:c.mutateAsync,isSavingRawSettings:c.isPending,autoDetectAuth:h.mutate,autoDetectAuthAsync:h.mutateAsync,isAutoDetectingAuth:h.isPending,autoDetectAuthResult:h.data,importManualAuth:i.mutate,importManualAuthAsync:i.mutateAsync,isImportingManualAuth:i.isPending,manualAuthResult:i.data,startDaemon:y.mutate,startDaemonAsync:y.mutateAsync,isStartingDaemon:y.isPending,stopDaemon:C.mutate,stopDaemonAsync:C.mutateAsync,isStoppingDaemon:C.isPending}),[a.data,a.isLoading,a.error,a.refetch,d.data,d.isLoading,u.data,u.isLoading,m.data,m.isLoading,m.refetch,n.mutate,n.mutateAsync,n.isPending,c.mutate,c.mutateAsync,c.isPending,h.mutate,h.mutateAsync,h.isPending,h.data,i.mutate,i.mutateAsync,i.isPending,i.data,y.mutate,y.mutateAsync,y.isPending,C.mutate,C.mutateAsync,C.isPending])}function ae(s){return{port:String(s?.port??Ae),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function N(s,a,d){return s.find(m=>a.some(l=>l.test(m.id)))?.id??d}function ne(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,a,d){const u=new Set(a.map(ne)),m=s.find(n=>u.has(ne(n.id)));if(m)return m.id;const l=s.find(n=>u.has(ne(n.name)));return l?l.id:d}function Is(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function U({label:s,description:a,value:d,models:u,disabled:m,allowDefaultFallback:l=!1,onChange:n}){const c=d||(l?"__default":""),h=u.find(i=>i.id===d);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(P,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(is,{value:c,onValueChange:i=>{if(l&&i==="__default"){n("");return}n(i)},disabled:m,children:[e.jsx(os,{className:"h-9",children:e.jsx(ls,{placeholder:"Select model",children:c&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l&&c==="__default"?"Use Default Model":h?.name||c}),h?.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:h.provider})]})})}),e.jsx(cs,{className:"max-h-[300px]",children:e.jsxs(ds,{children:[e.jsxs(us,{className:"text-xs text-muted-foreground",children:["Available Models (",u.length,")"]}),l&&e.jsx(be,{value:"__default",children:"Use Default Model"}),u.map(i=>e.jsx(be,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})},i.id))]})})]})]})}function re({icon:s,label:a,ok:d,detail:u}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(bs,{className:"h-4 w-4 text-green-500"}):e.jsx(Cs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:ie("text-xs",d?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function Xs(){const{status:s,statusLoading:a,refetchStatus:d,config:u,updateConfigAsync:m,isUpdatingConfig:l,models:n,modelsLoading:c,currentModel:h,rawSettings:i,rawSettingsLoading:y,refetchRawSettings:C,saveRawSettingsAsync:De,isSavingRawSettings:oe,autoDetectAuthAsync:_e,isAutoDetectingAuth:le,importManualAuthAsync:Me,isImportingManualAuth:ce,startDaemonAsync:Pe,isStartingDaemon:Te,stopDaemonAsync:Fe,isStoppingDaemon:de}=Os(),[A,ue]=p.useState(()=>ae()),[g,me]=p.useState(!1),[he,Re]=p.useState("{}"),[T,z]=p.useState(!1),[Oe,O]=p.useState(!1),[B,xe]=p.useState(""),[J,fe]=p.useState(""),S=ae(u),pe=g?A.port:S.port,K=g?A.auto_start:S.auto_start,Q=g?A.ghost_mode:S.ghost_mode,j=g?A.model:S.model,H=g?A.opus_model:S.opus_model,V=g?A.sonnet_model:S.sonnet_model,X=g?A.haiku_model:S.haiku_model,Y=T?he:JSON.stringify(i?.settings??{},null,2),ge=!!i,F=p.useMemo(()=>Is(Y),[Y]),je=F.isValid,we=g||T,Ie=!T||ge&&je,I=p.useMemo(()=>{const t=new Set,r=[...n].sort((k,$)=>k.name.localeCompare($.name)),x=r.filter(k=>t.has(k.id)?!1:(t.add(k.id),!0));return j&&!r.some(k=>k.id===j)?[{id:j,name:j,provider:"custom"},...x]:x},[n,j]),w=t=>{ue(r=>t(g?r:S)),me(!0)},Le=!!(s?.enabled&&s?.authenticated&&!s?.token_expired),Ee=p.useMemo(()=>s?.enabled?e.jsx(D,{children:"Enabled"}):e.jsx(D,{variant:"secondary",children:"Disabled"}),[s?.enabled]),qe=async({suppressSuccessToast:t=!1}={})=>{const r=Number(pe);if(!Number.isInteger(r)||r<1||r>65535)return o.error("Port must be an integer between 1 and 65535"),!1;if(!j.trim())return o.error("Default model is required"),!1;try{return await m({port:r,auto_start:K,ghost_mode:Q,model:j,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:X||void 0}),me(!1),ue(ae({port:r,auto_start:K,ghost_mode:Q,model:j,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:X||void 0})),t||o.success("Cursor config and model mapping saved"),!0}catch(x){return o.error(x.message||"Failed to save config"),!1}},Z=t=>{if(c){o.error("Models are still loading. Please wait before applying a preset.");return}if(n.length===0){o.error("No models available yet. Start the daemon and refresh first.");return}const r=j||h||n[0]?.id||"gpt-5.3-codex",x=b(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],N(n,[/gpt[-.]?5.*codex/i],r)),k=b(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],N(n,[/gpt[-.]?5.*codex.*max/i],x)),$=b(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],N(n,[/gpt[-.]?5.*fast/i],x)),He=b(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],N(n,[/gpt[-.]?5.*mini/i],$)),ye=b(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],N(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],x)),Ne=b(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],N(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],x)),Ve=b(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],N(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ne)),L=b(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],N(n,[/gemini[-.]?3.*pro/i],x)),Xe=b(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],N(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],L));if(t==="codex53"){w(R=>({...R,model:x,opus_model:k,sonnet_model:x,haiku_model:He})),o.success("Applied GPT-5.3 Codex preset");return}if(t==="claude46"){w(R=>({...R,model:ye,opus_model:ye,sonnet_model:Ne,haiku_model:Ve})),o.success("Applied Claude 4.6 preset");return}w(R=>({...R,model:L,opus_model:L,sonnet_model:L,haiku_model:Xe})),o.success("Applied Gemini 3 preset")},ve=async t=>{try{await m({enabled:t}),o.success(t?"Cursor integration enabled":"Cursor integration disabled")}catch(r){o.error(r.message||"Failed to update integration state")}},Ge=async()=>{try{await _e(),o.success("Cursor credentials imported")}catch(t){o.error(t.message||"Auto-detect failed")}},Ue=async()=>{if(!B.trim()||!J.trim()){o.error("Token and machine ID are required");return}try{await Me({accessToken:B.trim(),machineId:J.trim()}),o.success("Cursor credentials imported"),O(!1),xe(""),fe("")}catch(t){o.error(t.message||"Manual import failed")}},ze=async()=>{try{const t=await Pe();if(!t.success){o.error(t.error||"Failed to start daemon");return}o.success(`Daemon started${t.pid?` (PID: ${t.pid})`:""}`)}catch(t){o.error(t.message||"Failed to start daemon")}},Be=async()=>{try{const t=await Fe();if(!t.success){o.error(t.error||"Failed to stop daemon");return}o.success("Daemon stopped")}catch(t){o.error(t.message||"Failed to stop daemon")}},Je=async({suppressSuccessToast:t=!1}={})=>{if(!ge)return o.error("Raw settings are still loading. Please wait and try again."),!1;if(!F.isValid||!F.settings)return o.error(F.error||"Invalid JSON"),!1;try{return await De({settings:F.settings,expectedMtime:i?.mtime}),z(!1),t||o.success("Raw settings saved"),!0}catch(r){return ms(r)?o.error("Raw settings changed externally. Refresh and retry."):o.error(r.message||"Failed to save raw settings"),!1}},Ke=async()=>{if(!we)return;const t=g,r=T;t&&!await qe({suppressSuccessToast:r})||r&&!await Je({suppressSuccessToast:t})||t&&r&&o.success("Cursor configuration saved")},Qe=()=>{z(!1),d(),C()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:"Cursor"}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:"Beta"}),Ee]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:a,children:e.jsx(Se,{className:ie("w-4 h-4",a&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dedicated Cursor integration controls"})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:"Unofficial API - Use at Your Own Risk"})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:"Reverse-engineered integration may break anytime"}),e.jsx("li",{children:"Abuse or excessive usage may risk account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{icon:ps,label:"Integration",ok:!!s?.enabled,detail:s?.enabled?"Enabled":"Disabled"}),e.jsx(re,{icon:G,label:"Authentication",ok:!!(s?.authenticated&&!s?.token_expired),detail:s?.authenticated?s?.token_expired?"Expired":s.auth_method??"Connected":"Not connected"}),e.jsx(re,{icon:gs,label:"Daemon",ok:!!s?.daemon_running,detail:s?.daemon_running?"Running":"Stopped"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Actions"}),s?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>ve(!1),disabled:l,children:[e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Disable Integration"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>ve(!0),disabled:l,children:[e.jsx(js,{className:"w-3.5 h-3.5 mr-1.5"}),"Enable Integration"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ge,disabled:le,children:[le?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Auto-detect Auth"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>O(!0),children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Manual Auth Import"]}),s?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Be,disabled:de,children:[de?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Stop Daemon"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:ze,disabled:!Le,children:[Te?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ws,{className:"w-3.5 h-3.5 mr-1.5"}),"Start Daemon"]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Port"}),e.jsx("span",{children:s?.port??u?.port??Ae})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Cursor Configuration"}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",i.exists?new Date(i.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:Qe,disabled:a||y,children:e.jsx(Se,{className:ie("w-4 h-4",(a||y)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Ke,disabled:l||oe||!we||!Ie,children:l||oe?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(Ze,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs($e,{className:"w-full",children:[e.jsx(W,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(W,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(W,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("codex53"),disabled:c||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(te,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("claude46"),disabled:c||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(te,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("gemini3"),disabled:c||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(te,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(xs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(U,{label:"Default Model",description:"Used when no specific tier is requested.",value:j,models:I,disabled:c,onChange:t=>{w(r=>({...r,model:t}))}}),e.jsx(U,{label:"Opus (Most capable)",description:"Complex reasoning and highest quality responses.",value:H,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,opus_model:t}))}}),e.jsx(U,{label:"Sonnet (Balanced)",description:"General coding and day-to-day chat workloads.",value:V,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,sonnet_model:t}))}}),e.jsx(U,{label:"Haiku (Fast)",description:"Low-latency and lightweight request paths.",value:X,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,haiku_model:t}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Runtime Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:pe,onChange:t=>{w(r=>({...r,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start Cursor daemon automatically when integration is used."})]}),e.jsx(Ce,{id:"cursor-auto-start",checked:K,onCheckedChange:t=>{w(r=>({...r,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:"Ghost Mode"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Request `x-ghost-mode` to reduce telemetry."})]}),e.jsx(Ce,{id:"cursor-ghost-mode",checked:Q,onCheckedChange:t=>{w(r=>({...r,ghost_mode:t}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Available Models"}),c?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(M,{className:"w-4 h-4 animate-spin"}),"Loading models..."]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No model metadata available yet. Start daemon and refresh."}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===h&&e.jsx(D,{children:"Default"})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ns,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(We,{rawJsonContent:Y,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{z(!0),Re(t)}})]})]})]})})]}),e.jsx(es,{open:Oe,onOpenChange:O,children:e.jsxs(ss,{children:[e.jsxs(ts,{children:[e.jsx(as,{children:"Manual Cursor Auth Import"}),e.jsx(ns,{children:"Provide Cursor access token and machine ID if auto-detect is unavailable."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-token",children:"Access Token"}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:t=>xe(t.target.value),placeholder:"Paste Cursor access token"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-machine-id",children:"Machine ID"}),e.jsx(se,{id:"cursor-manual-machine-id",value:J,onChange:t=>fe(t.target.value),placeholder:"32-char hex (UUID without hyphens)"})]})]}),e.jsxs(rs,{children:[e.jsx(f,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsxs(f,{onClick:Ue,disabled:ce,children:[ce?e.jsx(M,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(G,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})]})}export{Xs as CursorPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-C1Gpgz6I.js";import{r as F}from"./react-vendor-CNOkPC89.js";import{t as g}from"./notifications-B2HqRBj7.js";import{aV as ee,aW as we,B as S,b as V,c as le,aZ as ke,C as b,i as v,j as y,a as N,q as H,r as Q,s as W,t as G,v as k,I as ce,a_ as Se,a$ as ae,b0 as Ce,O as Ee,Q as Te,R as z,U as $,m as _,aX as Ae}from"./index-k-HuyjpO.js";import{a as Re,u as ie,b as Oe}from"./tanstack-DDJIhNJd.js";import{aA as De,L as X,ai as _e,m as Be,R as Me,aB as Fe,aC as Ke,v as Le,S as Pe,aD as Ie,r as Ue,s as Ve,T as ze,a5 as $e,az as Je,n as oe}from"./icons-DrewC9c3.js";import{S as B}from"./separator-BLVyAGAm.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function Ye(s){try{const t=JSON.parse(s);return!t||typeof t!="object"||Array.isArray(t)?{settings:null,parseError:"JSON root must be an object."}:{settings:t,parseError:null}}catch(t){return{settings:null,parseError:t.message}}}async function qe(){const s=await fetch(ee("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function He(){const s=await fetch(ee("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const t=await fetch(ee("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new we("Droid raw settings changed externally");if(!t.ok){const r=await t.json().catch(()=>null);throw new Error(r?.error||"Failed to save Droid raw settings")}return t.json()}function We(){const s=Re(),t=ie({queryKey:["droid-diagnostics"],queryFn:qe,refetchInterval:1e4}),r=ie({queryKey:["droid-raw-settings"],queryFn:He}),l=Oe({mutationFn:Qe,onSuccess:(i,c)=>{s.setQueryData(["droid-raw-settings"],n=>{const a=n?.path??"~/.factory/settings.json",u=n?.resolvedPath??a,m=Ye(c.rawText);return{path:a,resolvedPath:u,exists:!0,mtime:i.mtime,rawText:c.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return F.useMemo(()=>({diagnostics:t.data,diagnosticsLoading:t.isLoading,diagnosticsError:t.error,refetchDiagnostics:t.refetch,rawSettings:r.data,rawSettingsLoading:r.isLoading,rawSettingsError:r.error,refetchRawSettings:r.refetch,saveRawSettings:l.mutate,saveRawSettingsAsync:l.mutateAsync,isSavingRawSettings:l.isPending}),[t.data,t.isLoading,t.error,t.refetch,r.data,r.isLoading,r.error,r.refetch,l.mutate,l.mutateAsync,l.isPending])}function Ge({title:s,pathLabel:t,loading:r,parseWarning:l,value:i,dirty:c,saving:n,saveDisabled:a,onChange:u,onSave:m,onRefresh:T}){const[A,C]=F.useState(!1),D=async()=>{i&&(await navigator.clipboard.writeText(i),C(!0),g.success("Settings copied to clipboard"),window.setTimeout(()=>C(!1),1500))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"font-semibold flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4 text-primary"}),s,c&&e.jsx(S,{variant:"secondary",className:"text-[10px]",children:"Unsaved"})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:t})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(V,{size:"sm",onClick:m,disabled:a,children:[n?e.jsx(X,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(_e,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsxs(V,{variant:"outline",size:"sm",onClick:D,disabled:!i,children:[e.jsx(Be,{className:"h-4 w-4 mr-1"}),A?"Copied":"Copy"]}),e.jsx(V,{variant:"outline",size:"sm",onClick:T,children:e.jsx(Me,{className:le("h-4 w-4",r?"animate-spin":"")})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:r?e.jsxs("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[e.jsx(X,{className:"h-5 w-5 animate-spin mr-2"}),"Loading settings.json..."]}):e.jsxs("div",{className:"h-full flex flex-col",children:[l&&e.jsxs("div",{className:"mx-4 mt-4 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:["Parse warning: ",l]}),e.jsx("div",{className:"flex-1 p-4 pt-3",children:e.jsx("div",{className:"h-full rounded-md border overflow-hidden bg-background",children:e.jsx(ke,{value:i,onChange:u,language:"json",minHeight:"100%"})})})]})})]})}const Xe=["customModels","custom_models"],Ze={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},es=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function j(s){return typeof s=="string"&&s.trim()?s.trim():null}function K(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function Z(s){if(!s)return"unknown";const t=s.toLowerCase();return t==="anthropic"?"anthropic":t==="openai"?"openai":t==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function ss(s,t,r){return`${s}:${t}:${encodeURIComponent(String(r))}`}function ts(s){const t=s.indexOf(":"),r=s.indexOf(":",t+1);if(t<=0||r<=t+1)return null;const l=s.slice(0,t),i=s.slice(t+1,r),c=s.slice(r+1);if(l!=="customModels"&&l!=="custom_models"||i!=="array"&&i!=="object")return null;const n=decodeURIComponent(c);if(i==="array"){const a=Number.parseInt(n,10);return!Number.isInteger(a)||a<0?null:{rootKey:l,locationType:i,locationKey:a}}return{rootKey:l,locationType:i,locationKey:n}}function rs(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function ns(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function as(s){const t=[];for(const r of Xe){const l=s[r];if(Array.isArray(l)){l.forEach((i,c)=>{p(i)&&t.push({rootKey:r,locationType:"array",locationKey:c,entry:i})});continue}if(p(l))for(const[i,c]of Object.entries(l))p(c)&&t.push({rootKey:r,locationType:"object",locationKey:i,entry:c})}return t}function ue(s,t){const r=ts(t);if(!r)return null;const l=s[r.rootKey];if(r.locationType==="array"){if(!Array.isArray(l))return null;const n=l[r.locationKey];if(!p(n))return null;const a=j(n.provider);return{entry:n,providerKind:Z(a)}}if(!p(l))return null;const i=l[r.locationKey];if(!p(i))return null;const c=j(i.provider);return{entry:i,providerKind:Z(c)}}function is(s,t){const r=t.extraArgs??t.extra_args,l=p(r)?r:null;if(!l)return{effort:null,anthropicBudgetTokens:null};const i=j(l.reasoning_effort)??j(l.reasoningEffort),c=p(l.reasoning)?l.reasoning:null,n=c?j(c.effort):null,a=p(l.thinking)?l.thinking:null,u=a?j(a.type):null,m=a?K(a.budget_tokens)??K(a.budgetTokens):null;return s==="openai"?{effort:n??i,anthropicBudgetTokens:null}:s==="anthropic"?u==="enabled"?{effort:rs(m)??"high",anthropicBudgetTokens:m}:{effort:n??i,anthropicBudgetTokens:m}:{effort:i??n,anthropicBudgetTokens:null}}function os(s){if(!s)return null;const t=s.trim().toLowerCase();return!t||t==="default"||t==="unset"||t==="off"||t==="none"||t==="disabled"?null:t}function me(s){const t=ns(s),r=s[t],l=p(r)?{...r}:{};return{extraArgsKey:t,extraArgs:l}}function xe(s,t,r){if(Object.keys(r).length===0){delete s[t];return}s[t]=r}function ls(s){return as(s).map(({rootKey:t,locationType:r,locationKey:l,entry:i})=>{const c=j(i.displayName)??j(i.model_display_name)??"Unnamed model",n=j(i.model)??"",a=j(i.provider)??"unknown",u=Z(a),m=is(u,i);return{id:ss(t,r,l),rootKey:t,locationType:r,locationKey:l,displayName:c,model:n,provider:a,providerKind:u,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function cs(s,t,r){const l=de(s),i=ue(l,t);if(!i)return null;const c=os(r),{extraArgsKey:n,extraArgs:a}=me(i.entry);if(i.providerKind==="openai")if(delete a.reasoning_effort,delete a.reasoningEffort,!c)delete a.reasoning;else{const u=p(a.reasoning)?a.reasoning:{};a.reasoning={...u,effort:c}}else if(i.providerKind==="anthropic")if(delete a.reasoning_effort,delete a.reasoningEffort,delete a.reasoning,!c)delete a.thinking;else{const u=p(a.thinking)?{...a.thinking}:{},m=K(u.budget_tokens)??K(u.budgetTokens);delete u.budgetTokens,a.thinking={...u,type:"enabled",budget_tokens:m??Ze[c]??3e4}}else delete a.reasoning,delete a.reasoningEffort,c?a.reasoning_effort=c:delete a.reasoning_effort;return xe(i.entry,n,a),l}function ds(s,t,r){const l=de(s),i=ue(l,t);if(!i||i.providerKind!=="anthropic")return null;const{extraArgsKey:c,extraArgs:n}=me(i.entry),a=p(n.thinking)?{...n.thinking}:{};if(a.type="enabled",r===null)delete a.budget_tokens,delete a.budgetTokens;else{const u=Math.max(1024,Math.floor(r));a.budget_tokens=u,delete a.budgetTokens}return n.thinking=a,xe(i.entry,c,n),l}const J="__unset__";function us(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ms({models:s,disabled:t,disabledReason:r,onEffortChange:l,onAnthropicBudgetChange:i}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"}),"BYOK Reasoning / Thinking",e.jsx(S,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[r&&e.jsx("p",{className:"text-xs text-amber-600",children:r}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(c=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:c.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:c.model||"(missing model id)"})]}),e.jsx(S,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:c.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Reasoning Effort"}),e.jsxs(H,{value:c.effort??J,onValueChange:n=>l(c.id,n===J?null:n),disabled:t,children:[e.jsx(Q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(G,{children:[e.jsx(k,{value:J,children:"Use provider default"}),es.map(n=>e.jsx(k,{value:n,children:n},n))]})]})]}),c.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Thinking Budget Tokens"}),e.jsx(ce,{type:"number",min:1024,step:1024,value:c.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:t,onChange:n=>{const a=n.target.value.trim();if(!a){i(c.id,null);return}const u=Number.parseInt(a,10);Number.isFinite(u)&&i(c.id,Math.max(1024,u))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:us(c)})]},c.id))})]})]})}const O="__unset__",xs=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],fs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],hs=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ps(s){return s===!0?"true":s===!1?"false":O}function gs(s){return s==="true"?!0:s==="false"?!1:null}function js({values:s,disabled:t,disabledReason:r,onEnumSettingChange:l,onBooleanSettingChange:i,onNumberSettingChange:c}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"Quick Settings",e.jsx(S,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[r&&e.jsx("p",{className:"text-xs text-amber-600",children:r}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[xs.map(n=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n.label}),e.jsxs(H,{value:s[n.key]??O,onValueChange:a=>l(n.key,a===O?null:a),disabled:t,children:[e.jsx(Q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(G,{children:[e.jsx(k,{value:O,children:"Use default"}),n.options.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:n.description})]},n.key)),hs.map(n=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n.label}),e.jsx(ce,{type:"number",min:n.min,step:n.step,value:s[n.key]??"",onChange:a=>{const u=a.target.value.trim();if(!u){c(n.key,null);return}const m=Number.parseInt(u,10);Number.isFinite(m)&&c(n.key,Math.max(n.min,m))},className:"h-8 text-xs",disabled:t})]},n.key)),fs.map(n=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n.label}),e.jsxs(H,{value:ps(s[n.key]),onValueChange:a=>i(n.key,gs(a)),disabled:t,children:[e.jsx(Q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(G,{children:[e.jsx(k,{value:O,children:"Use default"}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},n.key))]})]})]})}const bs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],vs=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function ys(s){const t=/https?:\/\/[^\s)]+/g,r=[];let l=0,i;for(;(i=t.exec(s))!==null;){const[c]=i,n=i.index;n>l&&r.push(s.slice(l,n)),r.push(e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:c},`${c}-${n}`)),l=n+c.length}return l<s.length&&r.push(s.slice(l)),r.length>0?r:[s]}function Ns(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ws(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function ks(s){try{const t=JSON.parse(s);return!t||typeof t!="object"||Array.isArray(t)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:t}}catch(t){return{valid:!1,error:t.message}}}function Y(s){return typeof s=="string"?s:null}function q(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function M(s){return typeof s=="boolean"?s:null}function f({label:s,value:t,mono:r=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:le("text-right break-all",r&&"font-mono text-xs"),children:t})]})}function Ms(){const{diagnostics:s,diagnosticsLoading:t,diagnosticsError:r,refetchDiagnostics:l,rawSettings:i,rawSettingsLoading:c,refetchRawSettings:n,saveRawSettingsAsync:a,isSavingRawSettings:u}=We(),[m,T]=F.useState(null),A=i?.rawText??"{}",C=m??A,D=m!==null&&m!==A,d=ks(C),L=d.valid?{valid:!0}:{valid:!1,error:d.error},se=x=>{if(x===A){T(null);return}T(x)},P=x=>{se(JSON.stringify(x,null,2)+`
|
|
2
|
+
`)},I=(x,w)=>{if(!d.valid){g.error("Fix JSON syntax before using quick settings controls.");return}const E={...d.value};w==null?delete E[x]:E[x]=w,P(E)},fe=d.valid?{reasoningEffort:Y(d.value.reasoningEffort),autonomyLevel:Y(d.value.autonomyLevel),diffMode:Y(d.value.diffMode),maxTurns:q(d.value.maxTurns),maxToolCalls:q(d.value.maxToolCalls),autoCompactThreshold:q(d.value.autoCompactThreshold),todoEnabled:M(d.value.todoEnabled),todoAutoRefresh:M(d.value.todoAutoRefresh),autoCompactEnabled:M(d.value.autoCompactEnabled),soundEnabled:M(d.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},he=d.valid?ls(d.value):[],pe=async()=>{await Promise.all([l(),n()])},ge=async()=>{if(!L.valid){g.error(`Invalid JSON: ${L.error}`);return}try{await a({rawText:C,expectedMtime:i?.exists?i.mtime:void 0}),T(null),g.success("Droid settings saved")}catch(x){Ae(x)?g.error("Droid settings changed externally. Refresh and retry."):g.error(x.message||"Failed to save Droid settings")}},te=s?.byok.customModels??[],re=F.useMemo(()=>Object.entries(s?.byok.providerBreakdown??{}).sort((x,w)=>w[1]-x[1]),[s?.byok.providerBreakdown]),je=()=>{if(t)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(X,{className:"h-5 w-5 animate-spin mr-2"}),"Loading Droid diagnostics..."]});if(r||!s)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:"Failed to load Droid diagnostics."});const x=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=x.notes??[],E=x.links??[],ne=x.providerDocs??[],be=E.length>0?E:bs,ve=ne.length>0?ne:vs,ye=x.providerValues??[],Ne=x.settingsHierarchy??[],U="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Ee,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Te,{className:"grid w-full grid-cols-3",children:[e.jsx(z,{value:"overview",children:"Overview"}),e.jsx(z,{value:"byok",children:"BYOK"}),e.jsx(z,{value:"docs",children:"Docs"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx($,{value:"overview",className:U,children:e.jsx(_,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Pe,{className:"h-4 w-4"}),"Runtime & Installation"]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(S,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?"Detected":"Not Found"})]}),e.jsx(f,{label:"Detection source",value:s.binary.source,mono:!0}),e.jsx(f,{label:"Binary path",value:s.binary.path||"Not detected",mono:!0}),e.jsx(f,{label:"Install directory",value:s.binary.installDir||"N/A",mono:!0}),e.jsx(f,{label:"Version",value:s.binary.version||"Unknown",mono:!0}),e.jsx(f,{label:"Override (CCS_DROID_PATH)",value:s.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4"}),"Config Files"]})}),e.jsx(N,{className:"space-y-3",children:[s.files.settings,s.files.legacyConfig].map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:o.label}),o.exists?e.jsx(Ue,{className:"h-4 w-4 text-green-600"}):e.jsx(Ve,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(f,{label:"Path",value:o.path,mono:!0}),e.jsx(f,{label:"Resolved",value:o.resolvedPath,mono:!0}),e.jsx(f,{label:"Size",value:ws(o.sizeBytes)}),e.jsx(f,{label:"Last modified",value:Ns(o.mtimeMs)}),o.parseError&&e.jsxs("p",{className:"text-xs text-amber-600",children:["Parse warning: ",o.parseError]}),o.readError&&e.jsxs("p",{className:"text-xs text-destructive",children:["Read warning: ",o.readError]})]},o.label))})]}),s.warnings.length>0&&e.jsxs(b,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4 text-amber-600"}),"Warnings"]})}),e.jsx(N,{className:"space-y-1.5",children:s.warnings.map(o=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",o]},o))})]})]})})}),e.jsx($,{value:"byok",className:U,children:e.jsx(_,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(js,{values:fe,disabled:c||!d.valid,disabledReason:d.valid?null:`Quick settings disabled: ${d.error}`,onEnumSettingChange:(o,h)=>{I(o,h)},onBooleanSettingChange:(o,h)=>{I(o,h)},onNumberSettingChange:(o,h)=>{I(o,h)}}),e.jsx(ms,{models:he,disabled:c||!d.valid,disabledReason:d.valid?null:`BYOK reasoning controls disabled: ${d.error}`,onEffortChange:(o,h)=>{if(!d.valid){g.error("Fix JSON syntax before updating BYOK reasoning settings.");return}const R=cs(d.value,o,h);if(!R){g.error("Unable to update selected BYOK model reasoning setting.");return}P(R)},onAnthropicBudgetChange:(o,h)=>{if(!d.valid){g.error("Fix JSON syntax before updating thinking budget.");return}const R=ds(d.value,o,h);if(!R){g.error("Thinking budget is only available for Anthropic BYOK models.");return}P(R)}}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx($e,{className:"h-4 w-4"}),"BYOK Summary"]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(f,{label:"Active model selector",value:s.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(f,{label:"Custom models",value:String(s.byok.customModelCount)}),e.jsx(f,{label:"CCS-managed",value:String(s.byok.ccsManagedCount)}),e.jsx(f,{label:"User-managed",value:String(s.byok.userManagedCount)}),e.jsx(f,{label:"Malformed entries",value:String(s.byok.invalidModelEntryCount)}),e.jsx(B,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Providers"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[re.length===0&&e.jsx(S,{variant:"secondary",className:"font-mono",children:"none"}),re.map(([o,h])=>e.jsxs(S,{variant:"outline",className:"font-mono text-xs",children:[o,": ",h]},o))]})]})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(y,{className:"text-base",children:"Custom Models"})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:"Name / Model"}),e.jsx("span",{children:"Provider"}),e.jsx("span",{children:"Base URL"})]}),e.jsx(_,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[te.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:"No custom models"}),te.map(o=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:o.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:o.provider}),e.jsx("p",{className:"text-muted-foreground",children:o.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:o.baseUrl,children:o.host||o.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:o.baseUrl})]})]},`${o.displayName}-${o.model}-${o.baseUrl}`))]})})]})})]})]})})}),e.jsx($,{value:"docs",className:U,children:e.jsx(_,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"Docs-Aligned Notes"]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((o,h)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",ys(o)]},`${h}-${o}`)),e.jsx(B,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Factory Docs"}),e.jsx("div",{className:"space-y-1.5",children:be.map(o=>e.jsxs("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:o.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:o.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:o.url})]},o.id))})]}),e.jsx(B,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Provider Fact-Check Docs"}),e.jsx("div",{className:"space-y-1.5",children:ve.map(o=>e.jsxs("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:o.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",o.provider," | format: ",o.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:o.url})]},`${o.provider}-${o.url}`))})]}),e.jsx(B,{}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider values: ",ye.join(", ")]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Settings hierarchy: ",Ne.join(" -> ")]})]})]})})})})]})]})};return e.jsx("div",{className:"h-[calc(100vh-100px)] overflow-hidden",children:e.jsxs(Se,{direction:"horizontal",className:"h-full",children:[e.jsx(ae,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:je()})}),e.jsx(Ce,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Le,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ae,{defaultSize:55,minSize:35,children:e.jsx(Ge,{title:"Droid BYOK Settings",pathLabel:i?.path||"~/.factory/settings.json",loading:c,parseWarning:i?.parseError,value:C,dirty:D,saving:u,saveDisabled:!D||u||c||!L.valid,onChange:x=>{se(x)},onSave:ge,onRefresh:pe})})]})})}export{Ms as DroidPage};
|
|
@@ -17,4 +17,4 @@ import{c as P}from"./react-vendor-CNOkPC89.js";var xe=e=>e.type==="checkbox",_e=
|
|
|
17
17
|
newResult[${$}] = ${Z}.value;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
`)}O.write("payload.value = newResult;"),O.write("return payload;");const z=O.compile();return(R,Z)=>z(m,R,Z)};let s;const i=Le,a=!yr.jitless,_=a&&vn.value,y=t.catchall;let k;e._zod.parse=(m,O)=>{k??(k=n.value);const I=m.value;return i(I)?a&&_&&O?.async===!1&&O.jitless!==!0?(s||(s=o(t.shape)),m=s(m,O),y?Or([],I,m,O,k,e):m):r(m,O):(m.issues.push({expected:"object",code:"invalid_type",input:I,inst:e}),m)}});function Ht(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!ze(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>me(i,n,ge())))}),t)}const Yo=f("$ZodUnion",(e,t)=>{M.init(e,t),S(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),S(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>vt(s.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(r)return n(o,s);let i=!1;const a=[];for(const p of t.options){const _=p._zod.run({value:o.value,issues:[]},s);if(_ instanceof Promise)a.push(_),i=!0;else{if(_.issues.length===0)return _;a.push(_)}}return i?Promise.all(a).then(p=>Ht(p,o,e,s)):Ht(a,o,e,s)}}),Qo=f("$ZodIntersection",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([p,_])=>Gt(r,p,_)):Gt(r,s,i)}});function at(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Oe(e)&&Oe(t)){const r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(const s of n){const i=at(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],s=t[n],i=at(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Gt(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),ze(e))return e;const n=at(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const es=f("$ZodEnum",(e,t)=>{M.init(e,t);const r=gn(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>yn.has(typeof o)).map(o=>typeof o=="string"?We(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),ts=f("$ZodTransform",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vr(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new Ze;return r.value=o,r}});function Xt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const rs=f("$ZodOptional",(e,t)=>{M.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vt(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Xt(s,r.value)):Xt(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),ns=f("$ZodNullable",(e,t)=>{M.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vt(r.source)}|null)$`):void 0}),S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),os=f("$ZodDefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Yt(s,t)):Yt(o,t)}});function Yt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ss=f("$ZodPrefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),is=f("$ZodNonOptional",(e,t)=>{M.init(e,t),S(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Qt(s,e)):Qt(o,e)}});function Qt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const us=f("$ZodCatch",(e,t)=>{M.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>me(i,n,ge()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>me(s,n,ge()))},input:r.value}),r.issues=[]),r)}}),cs=f("$ZodPipe",(e,t)=>{M.init(e,t),S(e._zod,"values",()=>t.in._zod.values),S(e._zod,"optin",()=>t.in._zod.optin),S(e._zod,"optout",()=>t.out._zod.optout),S(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Te(i,t.in,n)):Te(s,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Te(s,t.out,n)):Te(o,t.out,n)}});function Te(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const as=f("$ZodReadonly",(e,t)=>{M.init(e,t),S(e._zod,"propValues",()=>t.innerType._zod.propValues),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"optin",()=>t.innerType?._zod?.optin),S(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(er):er(o)}});function er(e){return e.value=Object.freeze(e.value),e}const ls=f("$ZodCustom",(e,t)=>{ue.init(e,t),M.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>tr(s,r,n,e));tr(o,r,n,e)}});function tr(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ve(o))}}var rr;class fs{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ds(){return new fs}(rr=globalThis).__zod_globalRegistry??(rr.__zod_globalRegistry=ds());const Ce=globalThis.__zod_globalRegistry;function hs(e,t){return new e({type:"string",...b(t)})}function ps(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function nr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function _s(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function gs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function ms(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function vs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function ys(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function ws(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function bs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function ks(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function zs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function Zs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function $s(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function As(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function Es(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function Fs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function Ds(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function Os(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function Vs(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function xs(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function Ss(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function Is(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function Ps(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function Ts(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function Cs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function Rs(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function Us(e){return new e({type:"unknown"})}function js(e,t){return new e({type:"never",...b(t)})}function Vr(e,t){return new ao({check:"max_length",...b(t),maximum:e})}function Me(e,t){return new lo({check:"min_length",...b(t),minimum:e})}function xr(e,t){return new fo({check:"length_equals",...b(t),length:e})}function Ls(e,t){return new ho({check:"string_format",format:"regex",...b(t),pattern:e})}function Ns(e){return new po({check:"string_format",format:"lowercase",...b(e)})}function Ms(e){return new _o({check:"string_format",format:"uppercase",...b(e)})}function Bs(e,t){return new go({check:"string_format",format:"includes",...b(t),includes:e})}function Ws(e,t){return new mo({check:"string_format",format:"starts_with",...b(t),prefix:e})}function qs(e,t){return new vo({check:"string_format",format:"ends_with",...b(t),suffix:e})}function $e(e){return new yo({check:"overwrite",tx:e})}function Js(e){return $e(t=>t.normalize(e))}function Ks(){return $e(e=>e.trim())}function Hs(){return $e(e=>e.toLowerCase())}function Gs(){return $e(e=>e.toUpperCase())}function Xs(){return $e(e=>mn(e))}function Ys(e,t,r){return new e({type:"array",element:t,...b(r)})}function Qs(e,t,r){return new e({type:"custom",check:"custom",fn:t,...b(r)})}function ei(e){const t=ti(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Ve(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(Ve(o))}},e(r.value,r)));return t}function ti(e,t){const r=new ue({check:"custom",...b(t)});return r._zod.check=e,r}const ri=f("ZodISODateTime",(e,t)=>{So.init(e,t),C.init(e,t)});function ni(e){return Ps(ri,e)}const oi=f("ZodISODate",(e,t)=>{Io.init(e,t),C.init(e,t)});function si(e){return Ts(oi,e)}const ii=f("ZodISOTime",(e,t)=>{Po.init(e,t),C.init(e,t)});function ui(e){return Cs(ii,e)}const ci=f("ZodISODuration",(e,t)=>{To.init(e,t),C.init(e,t)});function ai(e){return Rs(ci,e)}const li=(e,t)=>{Zr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Dn(e,r)},flatten:{value:r=>Fn(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,ct,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,ct,2)}},isEmpty:{get(){return e.issues.length===0}}})},Q=f("ZodError",li,{Parent:Error}),fi=Je(Q),di=Ke(Q),hi=He(Q),pi=Ge(Q),_i=xn(Q),gi=Sn(Q),mi=In(Q),vi=Pn(Q),yi=Tn(Q),wi=Cn(Q),bi=Rn(Q),ki=Un(Q),W=f("ZodType",(e,t)=>(M.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(ye(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]})),e.clone=(r,n)=>he(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>fi(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>hi(e,r,n),e.parseAsync=async(r,n)=>di(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>pi(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>_i(e,r,n),e.decode=(r,n)=>gi(e,r,n),e.encodeAsync=async(r,n)=>mi(e,r,n),e.decodeAsync=async(r,n)=>vi(e,r,n),e.safeEncode=(r,n)=>yi(e,r,n),e.safeDecode=(r,n)=>wi(e,r,n),e.safeEncodeAsync=async(r,n)=>bi(e,r,n),e.safeDecodeAsync=async(r,n)=>ki(e,r,n),e.refine=(r,n)=>e.check(du(r,n)),e.superRefine=r=>e.check(hu(r)),e.overwrite=r=>e.check($e(r)),e.optional=()=>ir(e),e.nullable=()=>ur(e),e.nullish=()=>ir(ur(e)),e.nonoptional=r=>su(e,r),e.array=()=>Wi(e),e.or=r=>Ki([e,r]),e.and=r=>Gi(e,r),e.transform=r=>cr(e,Qi(r)),e.default=r=>ru(e,r),e.prefault=r=>ou(e,r),e.catch=r=>uu(e,r),e.pipe=r=>cr(e,r),e.readonly=()=>lu(e),e.describe=r=>{const n=e.clone();return Ce.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Ce.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ce.get(e);const n=e.clone();return Ce.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Sr=f("_ZodString",(e,t)=>{wt.init(e,t),W.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Ls(...n)),e.includes=(...n)=>e.check(Bs(...n)),e.startsWith=(...n)=>e.check(Ws(...n)),e.endsWith=(...n)=>e.check(qs(...n)),e.min=(...n)=>e.check(Me(...n)),e.max=(...n)=>e.check(Vr(...n)),e.length=(...n)=>e.check(xr(...n)),e.nonempty=(...n)=>e.check(Me(1,...n)),e.lowercase=n=>e.check(Ns(n)),e.uppercase=n=>e.check(Ms(n)),e.trim=()=>e.check(Ks()),e.normalize=(...n)=>e.check(Js(...n)),e.toLowerCase=()=>e.check(Hs()),e.toUpperCase=()=>e.check(Gs()),e.slugify=()=>e.check(Xs())}),zi=f("ZodString",(e,t)=>{wt.init(e,t),Sr.init(e,t),e.email=r=>e.check(ps(Zi,r)),e.url=r=>e.check(ys($i,r)),e.jwt=r=>e.check(Is(ji,r)),e.emoji=r=>e.check(ws(Ai,r)),e.guid=r=>e.check(nr(or,r)),e.uuid=r=>e.check(_s(Re,r)),e.uuidv4=r=>e.check(gs(Re,r)),e.uuidv6=r=>e.check(ms(Re,r)),e.uuidv7=r=>e.check(vs(Re,r)),e.nanoid=r=>e.check(bs(Ei,r)),e.guid=r=>e.check(nr(or,r)),e.cuid=r=>e.check(ks(Fi,r)),e.cuid2=r=>e.check(zs(Di,r)),e.ulid=r=>e.check(Zs(Oi,r)),e.base64=r=>e.check(Vs(Ci,r)),e.base64url=r=>e.check(xs(Ri,r)),e.xid=r=>e.check($s(Vi,r)),e.ksuid=r=>e.check(As(xi,r)),e.ipv4=r=>e.check(Es(Si,r)),e.ipv6=r=>e.check(Fs(Ii,r)),e.cidrv4=r=>e.check(Ds(Pi,r)),e.cidrv6=r=>e.check(Os(Ti,r)),e.e164=r=>e.check(Ss(Ui,r)),e.datetime=r=>e.check(ni(r)),e.date=r=>e.check(si(r)),e.time=r=>e.check(ui(r)),e.duration=r=>e.check(ai(r))});function bu(e){return hs(zi,e)}const C=f("ZodStringFormat",(e,t)=>{T.init(e,t),Sr.init(e,t)}),Zi=f("ZodEmail",(e,t)=>{Zo.init(e,t),C.init(e,t)}),or=f("ZodGUID",(e,t)=>{ko.init(e,t),C.init(e,t)}),Re=f("ZodUUID",(e,t)=>{zo.init(e,t),C.init(e,t)}),$i=f("ZodURL",(e,t)=>{$o.init(e,t),C.init(e,t)}),Ai=f("ZodEmoji",(e,t)=>{Ao.init(e,t),C.init(e,t)}),Ei=f("ZodNanoID",(e,t)=>{Eo.init(e,t),C.init(e,t)}),Fi=f("ZodCUID",(e,t)=>{Fo.init(e,t),C.init(e,t)}),Di=f("ZodCUID2",(e,t)=>{Do.init(e,t),C.init(e,t)}),Oi=f("ZodULID",(e,t)=>{Oo.init(e,t),C.init(e,t)}),Vi=f("ZodXID",(e,t)=>{Vo.init(e,t),C.init(e,t)}),xi=f("ZodKSUID",(e,t)=>{xo.init(e,t),C.init(e,t)}),Si=f("ZodIPv4",(e,t)=>{Co.init(e,t),C.init(e,t)}),Ii=f("ZodIPv6",(e,t)=>{Ro.init(e,t),C.init(e,t)}),Pi=f("ZodCIDRv4",(e,t)=>{Uo.init(e,t),C.init(e,t)}),Ti=f("ZodCIDRv6",(e,t)=>{jo.init(e,t),C.init(e,t)}),Ci=f("ZodBase64",(e,t)=>{Lo.init(e,t),C.init(e,t)}),Ri=f("ZodBase64URL",(e,t)=>{Mo.init(e,t),C.init(e,t)}),Ui=f("ZodE164",(e,t)=>{Bo.init(e,t),C.init(e,t)}),ji=f("ZodJWT",(e,t)=>{qo.init(e,t),C.init(e,t)}),Li=f("ZodUnknown",(e,t)=>{Jo.init(e,t),W.init(e,t)});function sr(){return Us(Li)}const Ni=f("ZodNever",(e,t)=>{Ko.init(e,t),W.init(e,t)});function Mi(e){return js(Ni,e)}const Bi=f("ZodArray",(e,t)=>{Ho.init(e,t),W.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Me(r,n)),e.nonempty=r=>e.check(Me(1,r)),e.max=(r,n)=>e.check(Vr(r,n)),e.length=(r,n)=>e.check(xr(r,n)),e.unwrap=()=>e.element});function Wi(e,t){return Ys(Bi,e,t)}const qi=f("ZodObject",(e,t)=>{Xo.init(e,t),W.init(e,t),S(e,"shape",()=>t.shape),e.keyof=()=>Xi(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:sr()}),e.loose=()=>e.clone({...e._zod.def,catchall:sr()}),e.strict=()=>e.clone({...e._zod.def,catchall:Mi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>zn(e,r),e.safeExtend=r=>Zn(e,r),e.merge=r=>$n(e,r),e.pick=r=>bn(e,r),e.omit=r=>kn(e,r),e.partial=(...r)=>An(Ir,e,r[0]),e.required=(...r)=>En(Pr,e,r[0])});function ku(e,t){const r={type:"object",shape:e??{},...b(t)};return new qi(r)}const Ji=f("ZodUnion",(e,t)=>{Yo.init(e,t),W.init(e,t),e.options=t.options});function Ki(e,t){return new Ji({type:"union",options:e,...b(t)})}const Hi=f("ZodIntersection",(e,t)=>{Qo.init(e,t),W.init(e,t)});function Gi(e,t){return new Hi({type:"intersection",left:e,right:t})}const lt=f("ZodEnum",(e,t)=>{es.init(e,t),W.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const s={};for(const i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new lt({...t,checks:[],...b(o),entries:s})},e.exclude=(n,o)=>{const s={...t.entries};for(const i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new lt({...t,checks:[],...b(o),entries:s})}});function Xi(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new lt({type:"enum",entries:r,...b(t)})}const Yi=f("ZodTransform",(e,t)=>{ts.init(e,t),W.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(Ve(s,r.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(Ve(i))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Qi(e){return new Yi({type:"transform",transform:e})}const Ir=f("ZodOptional",(e,t)=>{rs.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ir(e){return new Ir({type:"optional",innerType:e})}const eu=f("ZodNullable",(e,t)=>{ns.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ur(e){return new eu({type:"nullable",innerType:e})}const tu=f("ZodDefault",(e,t)=>{os.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ru(e,t){return new tu({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():br(t)}})}const nu=f("ZodPrefault",(e,t)=>{ss.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ou(e,t){return new nu({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():br(t)}})}const Pr=f("ZodNonOptional",(e,t)=>{is.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function su(e,t){return new Pr({type:"nonoptional",innerType:e,...b(t)})}const iu=f("ZodCatch",(e,t)=>{us.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function uu(e,t){return new iu({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const cu=f("ZodPipe",(e,t)=>{cs.init(e,t),W.init(e,t),e.in=t.in,e.out=t.out});function cr(e,t){return new cu({type:"pipe",in:e,out:t})}const au=f("ZodReadonly",(e,t)=>{as.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function lu(e){return new au({type:"readonly",innerType:e})}const fu=f("ZodCustom",(e,t)=>{ls.init(e,t),W.init(e,t)});function du(e,t={}){return Qs(fu,e,t)}function hu(e){return ei(e)}export{Zr as $,wu as a,Yr as b,ku as c,bu as d,gu as e,pn as o,yu as p,vu as s,mu as u};
|
|
20
|
+
`)}O.write("payload.value = newResult;"),O.write("return payload;");const z=O.compile();return(R,Z)=>z(m,R,Z)};let s;const i=Le,a=!yr.jitless,_=a&&vn.value,y=t.catchall;let k;e._zod.parse=(m,O)=>{k??(k=n.value);const I=m.value;return i(I)?a&&_&&O?.async===!1&&O.jitless!==!0?(s||(s=o(t.shape)),m=s(m,O),y?Or([],I,m,O,k,e):m):r(m,O):(m.issues.push({expected:"object",code:"invalid_type",input:I,inst:e}),m)}});function Ht(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!ze(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>me(i,n,ge())))}),t)}const Yo=f("$ZodUnion",(e,t)=>{M.init(e,t),S(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),S(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>vt(s.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(r)return n(o,s);let i=!1;const a=[];for(const p of t.options){const _=p._zod.run({value:o.value,issues:[]},s);if(_ instanceof Promise)a.push(_),i=!0;else{if(_.issues.length===0)return _;a.push(_)}}return i?Promise.all(a).then(p=>Ht(p,o,e,s)):Ht(a,o,e,s)}}),Qo=f("$ZodIntersection",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([p,_])=>Gt(r,p,_)):Gt(r,s,i)}});function at(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Oe(e)&&Oe(t)){const r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(const s of n){const i=at(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],s=t[n],i=at(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Gt(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),ze(e))return e;const n=at(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const es=f("$ZodEnum",(e,t)=>{M.init(e,t);const r=gn(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>yn.has(typeof o)).map(o=>typeof o=="string"?We(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),ts=f("$ZodTransform",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vr(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new Ze;return r.value=o,r}});function Xt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const rs=f("$ZodOptional",(e,t)=>{M.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vt(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Xt(s,r.value)):Xt(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),ns=f("$ZodNullable",(e,t)=>{M.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${vt(r.source)}|null)$`):void 0}),S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),os=f("$ZodDefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Yt(s,t)):Yt(o,t)}});function Yt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ss=f("$ZodPrefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),is=f("$ZodNonOptional",(e,t)=>{M.init(e,t),S(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Qt(s,e)):Qt(o,e)}});function Qt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const us=f("$ZodCatch",(e,t)=>{M.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>me(i,n,ge()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>me(s,n,ge()))},input:r.value}),r.issues=[]),r)}}),cs=f("$ZodPipe",(e,t)=>{M.init(e,t),S(e._zod,"values",()=>t.in._zod.values),S(e._zod,"optin",()=>t.in._zod.optin),S(e._zod,"optout",()=>t.out._zod.optout),S(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Te(i,t.in,n)):Te(s,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Te(s,t.out,n)):Te(o,t.out,n)}});function Te(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const as=f("$ZodReadonly",(e,t)=>{M.init(e,t),S(e._zod,"propValues",()=>t.innerType._zod.propValues),S(e._zod,"values",()=>t.innerType._zod.values),S(e._zod,"optin",()=>t.innerType?._zod?.optin),S(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(er):er(o)}});function er(e){return e.value=Object.freeze(e.value),e}const ls=f("$ZodCustom",(e,t)=>{ue.init(e,t),M.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>tr(s,r,n,e));tr(o,r,n,e)}});function tr(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ve(o))}}var rr;class fs{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ds(){return new fs}(rr=globalThis).__zod_globalRegistry??(rr.__zod_globalRegistry=ds());const Ce=globalThis.__zod_globalRegistry;function hs(e,t){return new e({type:"string",...b(t)})}function ps(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function nr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function _s(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function gs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function ms(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function vs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function ys(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function ws(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function bs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function ks(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function zs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function Zs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function $s(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function As(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function Es(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function Fs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function Ds(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function Os(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function Vs(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function xs(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function Ss(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function Is(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function Ps(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function Ts(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function Cs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function Rs(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function Us(e){return new e({type:"unknown"})}function js(e,t){return new e({type:"never",...b(t)})}function Vr(e,t){return new ao({check:"max_length",...b(t),maximum:e})}function Me(e,t){return new lo({check:"min_length",...b(t),minimum:e})}function xr(e,t){return new fo({check:"length_equals",...b(t),length:e})}function Ls(e,t){return new ho({check:"string_format",format:"regex",...b(t),pattern:e})}function Ns(e){return new po({check:"string_format",format:"lowercase",...b(e)})}function Ms(e){return new _o({check:"string_format",format:"uppercase",...b(e)})}function Bs(e,t){return new go({check:"string_format",format:"includes",...b(t),includes:e})}function Ws(e,t){return new mo({check:"string_format",format:"starts_with",...b(t),prefix:e})}function qs(e,t){return new vo({check:"string_format",format:"ends_with",...b(t),suffix:e})}function $e(e){return new yo({check:"overwrite",tx:e})}function Js(e){return $e(t=>t.normalize(e))}function Ks(){return $e(e=>e.trim())}function Hs(){return $e(e=>e.toLowerCase())}function Gs(){return $e(e=>e.toUpperCase())}function Xs(){return $e(e=>mn(e))}function Ys(e,t,r){return new e({type:"array",element:t,...b(r)})}function Qs(e,t,r){return new e({type:"custom",check:"custom",fn:t,...b(r)})}function ei(e){const t=ti(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Ve(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(Ve(o))}},e(r.value,r)));return t}function ti(e,t){const r=new ue({check:"custom",...b(t)});return r._zod.check=e,r}const ri=f("ZodISODateTime",(e,t)=>{So.init(e,t),C.init(e,t)});function ni(e){return Ps(ri,e)}const oi=f("ZodISODate",(e,t)=>{Io.init(e,t),C.init(e,t)});function si(e){return Ts(oi,e)}const ii=f("ZodISOTime",(e,t)=>{Po.init(e,t),C.init(e,t)});function ui(e){return Cs(ii,e)}const ci=f("ZodISODuration",(e,t)=>{To.init(e,t),C.init(e,t)});function ai(e){return Rs(ci,e)}const li=(e,t)=>{Zr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Dn(e,r)},flatten:{value:r=>Fn(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,ct,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,ct,2)}},isEmpty:{get(){return e.issues.length===0}}})},Q=f("ZodError",li,{Parent:Error}),fi=Je(Q),di=Ke(Q),hi=He(Q),pi=Ge(Q),_i=xn(Q),gi=Sn(Q),mi=In(Q),vi=Pn(Q),yi=Tn(Q),wi=Cn(Q),bi=Rn(Q),ki=Un(Q),W=f("ZodType",(e,t)=>(M.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(ye(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]})),e.clone=(r,n)=>he(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>fi(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>hi(e,r,n),e.parseAsync=async(r,n)=>di(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>pi(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>_i(e,r,n),e.decode=(r,n)=>gi(e,r,n),e.encodeAsync=async(r,n)=>mi(e,r,n),e.decodeAsync=async(r,n)=>vi(e,r,n),e.safeEncode=(r,n)=>yi(e,r,n),e.safeDecode=(r,n)=>wi(e,r,n),e.safeEncodeAsync=async(r,n)=>bi(e,r,n),e.safeDecodeAsync=async(r,n)=>ki(e,r,n),e.refine=(r,n)=>e.check(du(r,n)),e.superRefine=r=>e.check(hu(r)),e.overwrite=r=>e.check($e(r)),e.optional=()=>ir(e),e.nullable=()=>ur(e),e.nullish=()=>ir(ur(e)),e.nonoptional=r=>su(e,r),e.array=()=>Wi(e),e.or=r=>Ki([e,r]),e.and=r=>Gi(e,r),e.transform=r=>cr(e,Qi(r)),e.default=r=>ru(e,r),e.prefault=r=>ou(e,r),e.catch=r=>uu(e,r),e.pipe=r=>cr(e,r),e.readonly=()=>lu(e),e.describe=r=>{const n=e.clone();return Ce.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Ce.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ce.get(e);const n=e.clone();return Ce.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Sr=f("_ZodString",(e,t)=>{wt.init(e,t),W.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Ls(...n)),e.includes=(...n)=>e.check(Bs(...n)),e.startsWith=(...n)=>e.check(Ws(...n)),e.endsWith=(...n)=>e.check(qs(...n)),e.min=(...n)=>e.check(Me(...n)),e.max=(...n)=>e.check(Vr(...n)),e.length=(...n)=>e.check(xr(...n)),e.nonempty=(...n)=>e.check(Me(1,...n)),e.lowercase=n=>e.check(Ns(n)),e.uppercase=n=>e.check(Ms(n)),e.trim=()=>e.check(Ks()),e.normalize=(...n)=>e.check(Js(...n)),e.toLowerCase=()=>e.check(Hs()),e.toUpperCase=()=>e.check(Gs()),e.slugify=()=>e.check(Xs())}),zi=f("ZodString",(e,t)=>{wt.init(e,t),Sr.init(e,t),e.email=r=>e.check(ps(Zi,r)),e.url=r=>e.check(ys($i,r)),e.jwt=r=>e.check(Is(ji,r)),e.emoji=r=>e.check(ws(Ai,r)),e.guid=r=>e.check(nr(or,r)),e.uuid=r=>e.check(_s(Re,r)),e.uuidv4=r=>e.check(gs(Re,r)),e.uuidv6=r=>e.check(ms(Re,r)),e.uuidv7=r=>e.check(vs(Re,r)),e.nanoid=r=>e.check(bs(Ei,r)),e.guid=r=>e.check(nr(or,r)),e.cuid=r=>e.check(ks(Fi,r)),e.cuid2=r=>e.check(zs(Di,r)),e.ulid=r=>e.check(Zs(Oi,r)),e.base64=r=>e.check(Vs(Ci,r)),e.base64url=r=>e.check(xs(Ri,r)),e.xid=r=>e.check($s(Vi,r)),e.ksuid=r=>e.check(As(xi,r)),e.ipv4=r=>e.check(Es(Si,r)),e.ipv6=r=>e.check(Fs(Ii,r)),e.cidrv4=r=>e.check(Ds(Pi,r)),e.cidrv6=r=>e.check(Os(Ti,r)),e.e164=r=>e.check(Ss(Ui,r)),e.datetime=r=>e.check(ni(r)),e.date=r=>e.check(si(r)),e.time=r=>e.check(ui(r)),e.duration=r=>e.check(ai(r))});function bu(e){return hs(zi,e)}const C=f("ZodStringFormat",(e,t)=>{T.init(e,t),Sr.init(e,t)}),Zi=f("ZodEmail",(e,t)=>{Zo.init(e,t),C.init(e,t)}),or=f("ZodGUID",(e,t)=>{ko.init(e,t),C.init(e,t)}),Re=f("ZodUUID",(e,t)=>{zo.init(e,t),C.init(e,t)}),$i=f("ZodURL",(e,t)=>{$o.init(e,t),C.init(e,t)}),Ai=f("ZodEmoji",(e,t)=>{Ao.init(e,t),C.init(e,t)}),Ei=f("ZodNanoID",(e,t)=>{Eo.init(e,t),C.init(e,t)}),Fi=f("ZodCUID",(e,t)=>{Fo.init(e,t),C.init(e,t)}),Di=f("ZodCUID2",(e,t)=>{Do.init(e,t),C.init(e,t)}),Oi=f("ZodULID",(e,t)=>{Oo.init(e,t),C.init(e,t)}),Vi=f("ZodXID",(e,t)=>{Vo.init(e,t),C.init(e,t)}),xi=f("ZodKSUID",(e,t)=>{xo.init(e,t),C.init(e,t)}),Si=f("ZodIPv4",(e,t)=>{Co.init(e,t),C.init(e,t)}),Ii=f("ZodIPv6",(e,t)=>{Ro.init(e,t),C.init(e,t)}),Pi=f("ZodCIDRv4",(e,t)=>{Uo.init(e,t),C.init(e,t)}),Ti=f("ZodCIDRv6",(e,t)=>{jo.init(e,t),C.init(e,t)}),Ci=f("ZodBase64",(e,t)=>{Lo.init(e,t),C.init(e,t)}),Ri=f("ZodBase64URL",(e,t)=>{Mo.init(e,t),C.init(e,t)}),Ui=f("ZodE164",(e,t)=>{Bo.init(e,t),C.init(e,t)}),ji=f("ZodJWT",(e,t)=>{qo.init(e,t),C.init(e,t)}),Li=f("ZodUnknown",(e,t)=>{Jo.init(e,t),W.init(e,t)});function sr(){return Us(Li)}const Ni=f("ZodNever",(e,t)=>{Ko.init(e,t),W.init(e,t)});function Mi(e){return js(Ni,e)}const Bi=f("ZodArray",(e,t)=>{Ho.init(e,t),W.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Me(r,n)),e.nonempty=r=>e.check(Me(1,r)),e.max=(r,n)=>e.check(Vr(r,n)),e.length=(r,n)=>e.check(xr(r,n)),e.unwrap=()=>e.element});function Wi(e,t){return Ys(Bi,e,t)}const qi=f("ZodObject",(e,t)=>{Xo.init(e,t),W.init(e,t),S(e,"shape",()=>t.shape),e.keyof=()=>Xi(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:sr()}),e.loose=()=>e.clone({...e._zod.def,catchall:sr()}),e.strict=()=>e.clone({...e._zod.def,catchall:Mi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>zn(e,r),e.safeExtend=r=>Zn(e,r),e.merge=r=>$n(e,r),e.pick=r=>bn(e,r),e.omit=r=>kn(e,r),e.partial=(...r)=>An(Ir,e,r[0]),e.required=(...r)=>En(Pr,e,r[0])});function ku(e,t){const r={type:"object",shape:e??{},...b(t)};return new qi(r)}const Ji=f("ZodUnion",(e,t)=>{Yo.init(e,t),W.init(e,t),e.options=t.options});function Ki(e,t){return new Ji({type:"union",options:e,...b(t)})}const Hi=f("ZodIntersection",(e,t)=>{Qo.init(e,t),W.init(e,t)});function Gi(e,t){return new Hi({type:"intersection",left:e,right:t})}const lt=f("ZodEnum",(e,t)=>{es.init(e,t),W.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const s={};for(const i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new lt({...t,checks:[],...b(o),entries:s})},e.exclude=(n,o)=>{const s={...t.entries};for(const i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new lt({...t,checks:[],...b(o),entries:s})}});function Xi(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new lt({type:"enum",entries:r,...b(t)})}const Yi=f("ZodTransform",(e,t)=>{ts.init(e,t),W.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new vr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(Ve(s,r.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(Ve(i))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Qi(e){return new Yi({type:"transform",transform:e})}const Ir=f("ZodOptional",(e,t)=>{rs.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ir(e){return new Ir({type:"optional",innerType:e})}const eu=f("ZodNullable",(e,t)=>{ns.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ur(e){return new eu({type:"nullable",innerType:e})}const tu=f("ZodDefault",(e,t)=>{os.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ru(e,t){return new tu({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():br(t)}})}const nu=f("ZodPrefault",(e,t)=>{ss.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ou(e,t){return new nu({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():br(t)}})}const Pr=f("ZodNonOptional",(e,t)=>{is.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function su(e,t){return new Pr({type:"nonoptional",innerType:e,...b(t)})}const iu=f("ZodCatch",(e,t)=>{us.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function uu(e,t){return new iu({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const cu=f("ZodPipe",(e,t)=>{cs.init(e,t),W.init(e,t),e.in=t.in,e.out=t.out});function cr(e,t){return new cu({type:"pipe",in:e,out:t})}const au=f("ZodReadonly",(e,t)=>{as.init(e,t),W.init(e,t),e.unwrap=()=>e._zod.def.innerType});function lu(e){return new au({type:"readonly",innerType:e})}const fu=f("ZodCustom",(e,t)=>{ls.init(e,t),W.init(e,t)});function du(e,t={}){return Qs(fu,e,t)}function hu(e){return ei(e)}export{Zr as $,Xi as _,wu as a,Yr as b,ku as c,bu as d,gu as e,pn as o,yu as p,vu as s,mu as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-C1Gpgz6I.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{bb as N,bc as C,bd as w,b4 as y,b6 as G,m as S,b as x,I as p}from"./index-k-HuyjpO.js";import{S as k}from"./switch-CwLyB4JK.js";import{R as j,a2 as A,r as R,ah as L,a0 as V}from"./icons-DrewC9c3.js";import"./tanstack-DDJIhNJd.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function _(){const{state:s}=N(),a=C(),[l,d]=c.useState(""),[m,v]=c.useState(""),u=c.useCallback(async()=>{try{a.setGlobalEnvLoading(!0),a.setGlobalEnvError(null);const t=await fetch("/api/global-env");if(!t.ok)throw new Error("Failed to load Global Env config");const r=await t.json();a.setGlobalEnvConfig(r)}catch(t){a.setGlobalEnvError(t.message)}finally{a.setGlobalEnvLoading(!1)}},[a]),i=c.useCallback(async t=>{const r=s.globalEnvConfig;if(!r)return;const f={...r,...t};a.setGlobalEnvConfig(f);try{a.setGlobalEnvSaving(!0),a.setGlobalEnvError(null);const o=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!o.ok){const n=await o.json();throw new Error(n.error||"Failed to save")}const h=await o.json();a.setGlobalEnvConfig(h.config),a.setGlobalEnvSuccess(!0),setTimeout(()=>a.setGlobalEnvSuccess(!1),1500)}catch(o){a.setGlobalEnvConfig(r),a.setGlobalEnvError(o.message)}finally{a.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,a]),b=c.useCallback(()=>{if(!l.trim()||!s.globalEnvConfig)return;const t={...s.globalEnvConfig.env,[l.trim()]:m};i({env:t}),d(""),v("")},[l,m,s.globalEnvConfig,i]),g=c.useCallback(t=>{if(!s.globalEnvConfig)return;const r={...s.globalEnvConfig.env};delete r[t],i({env:r})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:l,setNewEnvKey:d,newEnvValue:m,setNewEnvValue:v,fetchConfig:u,saveConfig:i,addEnvVar:b,removeEnvVar:g}}function F(){const{config:s,loading:a,saving:l,error:d,success:m,newEnvKey:v,setNewEnvKey:u,newEnvValue:i,setNewEnvValue:b,fetchConfig:g,saveConfig:t,addEnvVar:r,removeEnvVar:f}=_(),{fetchRawConfig:o}=w();c.useEffect(()=>{g(),o()},[g,o]);const h=()=>{t({enabled:!s?.enabled})};return a?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(j,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${d||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(y,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(G,{children:d})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(R,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(S,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Environment variables injected into all non-Claude subscription profiles (gemini, codex, agy, ghcp, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s?.enabled?"Global Env enabled":"Global Env disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?.enabled?"Env vars will be injected into third-party profiles":"Env vars will not be injected"})]}),e.jsx(k,{checked:s?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Environment Variables"}),s?.env&&Object.keys(s.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(s.env).map(([n,E])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:n}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:E}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>f(n),disabled:l,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(L,{className:"w-4 h-4"})})]},n))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:"No environment variables configured"})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Add New Variable"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{value:v,onChange:n=>u(n.target.value.toUpperCase()),placeholder:"KEY_NAME",className:"flex-1 font-mono text-sm h-9",disabled:l}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(p,{value:i,onChange:n=>b(n.target.value),placeholder:"value",className:"flex-1 font-mono text-sm h-9",disabled:l}),e.jsxs(x,{size:"sm",onClick:r,disabled:l||!v.trim(),className:"h-9",children:[e.jsx(V,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Quick Add Common Variables"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:n,value:E})=>!s?.env?.[n]&&e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>{u(n),b(E)},className:"text-xs font-mono",children:["+ ",n]},n)),s?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(n=>s.env[n])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"All common variables are configured"})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>{g(),o()},disabled:a||l,className:"w-full",children:[e.jsx(j,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"Refresh"]})})]})}export{F as default};
|