jishushell 0.4.10 → 0.4.24-beta.2
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/Dockerfile.hermes-slim +193 -0
- package/INSTALL-NOTICE +10 -12
- package/apps/hermes-container.yaml +35 -0
- package/apps/ollama-binary.yaml +164 -0
- package/apps/ollama-cpu-container.yaml +37 -0
- package/apps/ollama-with-hollama-binary.yaml +159 -0
- package/apps/openclaw-binary.yaml +69 -0
- package/apps/openclaw-container.yaml +37 -0
- package/apps/openclaw-with-ollama-container.yaml +42 -0
- package/apps/openclaw-with-searxng-container.yaml +136 -0
- package/apps/openwebui-container.yaml +53 -0
- package/apps/playwright-container.yaml +120 -0
- package/apps/searxng-container.yaml +115 -0
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +15 -14
- package/dist/auth.js.map +1 -1
- package/dist/cli/app.d.ts +4 -0
- package/dist/cli/app.js +874 -0
- package/dist/cli/app.js.map +1 -0
- package/dist/cli/backup.d.ts +3 -0
- package/dist/cli/backup.js +434 -0
- package/dist/cli/backup.js.map +1 -0
- package/dist/{doctor.d.ts → cli/doctor.d.ts} +7 -1
- package/dist/{doctor.js → cli/doctor.js} +377 -22
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/helpers.d.ts +4 -0
- package/dist/cli/helpers.js +32 -0
- package/dist/cli/helpers.js.map +1 -0
- package/dist/cli/job.d.ts +4 -0
- package/dist/cli/job.js +198 -0
- package/dist/cli/job.js.map +1 -0
- package/dist/cli/llm.d.ts +25 -0
- package/dist/cli/llm.js +599 -0
- package/dist/cli/llm.js.map +1 -0
- package/dist/cli/managed-list.d.ts +30 -0
- package/dist/cli/managed-list.js +129 -0
- package/dist/cli/managed-list.js.map +1 -0
- package/dist/cli/panel.d.ts +26 -0
- package/dist/cli/panel.js +804 -0
- package/dist/cli/panel.js.map +1 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.js +12 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli.js +48 -776
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +69 -0
- package/dist/config.js +268 -7
- package/dist/config.js.map +1 -1
- package/dist/control.d.ts +17 -41
- package/dist/control.js +61 -1323
- package/dist/control.js.map +1 -1
- package/dist/install.d.ts +16 -0
- package/dist/install.js +75 -26
- package/dist/install.js.map +1 -1
- package/dist/routes/agent-apps.d.ts +15 -0
- package/dist/routes/agent-apps.js +78 -0
- package/dist/routes/agent-apps.js.map +1 -0
- package/dist/routes/apps.d.ts +3 -0
- package/dist/routes/apps.js +278 -0
- package/dist/routes/apps.js.map +1 -0
- package/dist/routes/backup.js +3 -3
- package/dist/routes/backup.js.map +1 -1
- package/dist/routes/instances.d.ts +6 -0
- package/dist/routes/instances.js +863 -874
- package/dist/routes/instances.js.map +1 -1
- package/dist/routes/llm.d.ts +15 -0
- package/dist/routes/llm.js +247 -0
- package/dist/routes/llm.js.map +1 -0
- package/dist/routes/runtime.d.ts +15 -0
- package/dist/routes/runtime.js +69 -0
- package/dist/routes/runtime.js.map +1 -0
- package/dist/routes/setup.js +131 -9
- package/dist/routes/setup.js.map +1 -1
- package/dist/routes/system.js +56 -9
- package/dist/routes/system.js.map +1 -1
- package/dist/server.js +107 -7
- package/dist/server.js.map +1 -1
- package/dist/services/agent-apps/catalog.d.ts +30 -0
- package/dist/services/agent-apps/catalog.js +60 -0
- package/dist/services/agent-apps/catalog.js.map +1 -0
- package/dist/services/agent-apps/index.d.ts +36 -0
- package/dist/services/agent-apps/index.js +171 -0
- package/dist/services/agent-apps/index.js.map +1 -0
- package/dist/services/agent-apps/installers/adapter-probes.d.ts +49 -0
- package/dist/services/agent-apps/installers/adapter-probes.js +223 -0
- package/dist/services/agent-apps/installers/adapter-probes.js.map +1 -0
- package/dist/services/agent-apps/installers/adapter.d.ts +30 -0
- package/dist/services/agent-apps/installers/adapter.js +171 -0
- package/dist/services/agent-apps/installers/adapter.js.map +1 -0
- package/dist/services/agent-apps/installers/registry-probe.d.ts +38 -0
- package/dist/services/agent-apps/installers/registry-probe.js +183 -0
- package/dist/services/agent-apps/installers/registry-probe.js.map +1 -0
- package/dist/services/agent-apps/installers/shell-script.d.ts +47 -0
- package/dist/services/agent-apps/installers/shell-script.js +471 -0
- package/dist/services/agent-apps/installers/shell-script.js.map +1 -0
- package/dist/services/agent-apps/types.d.ts +125 -0
- package/dist/services/agent-apps/types.js +17 -0
- package/dist/services/agent-apps/types.js.map +1 -0
- package/dist/services/app/app-compiler.d.ts +15 -0
- package/dist/services/app/app-compiler.js +172 -0
- package/dist/services/app/app-compiler.js.map +1 -0
- package/dist/services/app/app-manager.d.ts +142 -0
- package/dist/services/app/app-manager.js +2148 -0
- package/dist/services/app/app-manager.js.map +1 -0
- package/dist/services/app/custom-manager.d.ts +27 -0
- package/dist/services/app/custom-manager.js +285 -0
- package/dist/services/app/custom-manager.js.map +1 -0
- package/dist/services/app/hermes-agent-manager.d.ts +20 -0
- package/dist/services/app/hermes-agent-manager.js +289 -0
- package/dist/services/app/hermes-agent-manager.js.map +1 -0
- package/dist/services/app/id-normalizer.d.ts +27 -0
- package/dist/services/app/id-normalizer.js +77 -0
- package/dist/services/app/id-normalizer.js.map +1 -0
- package/dist/services/app/ollama-manager.d.ts +18 -0
- package/dist/services/app/ollama-manager.js +207 -0
- package/dist/services/app/ollama-manager.js.map +1 -0
- package/dist/services/app/openclaw-manager.d.ts +63 -0
- package/dist/services/app/openclaw-manager.js +1178 -0
- package/dist/services/app/openclaw-manager.js.map +1 -0
- package/dist/services/app/paths.d.ts +47 -0
- package/dist/services/app/paths.js +68 -0
- package/dist/services/app/paths.js.map +1 -0
- package/dist/services/app/registry.d.ts +17 -0
- package/dist/services/app/registry.js +31 -0
- package/dist/services/app/registry.js.map +1 -0
- package/dist/services/app/remote-spec.d.ts +14 -0
- package/dist/services/app/remote-spec.js +58 -0
- package/dist/services/app/remote-spec.js.map +1 -0
- package/dist/services/app/terminal-session-manager.d.ts +27 -0
- package/dist/services/app/terminal-session-manager.js +157 -0
- package/dist/services/app/terminal-session-manager.js.map +1 -0
- package/dist/services/app/types.d.ts +72 -0
- package/dist/services/app/types.js +16 -0
- package/dist/services/app/types.js.map +1 -0
- package/dist/services/backup-manager.js +60 -22
- package/dist/services/backup-manager.js.map +1 -1
- package/dist/services/instance-manager.d.ts +125 -34
- package/dist/services/instance-manager.js +679 -1043
- package/dist/services/instance-manager.js.map +1 -1
- package/dist/services/llm-proxy/adapters.js +5 -1
- package/dist/services/llm-proxy/adapters.js.map +1 -1
- package/dist/services/llm-proxy/circuit-breaker.js +10 -2
- package/dist/services/llm-proxy/circuit-breaker.js.map +1 -1
- package/dist/services/llm-proxy/index.d.ts +43 -0
- package/dist/services/llm-proxy/index.js +120 -5
- package/dist/services/llm-proxy/index.js.map +1 -1
- package/dist/services/llm-proxy/ssrf.js +1 -1
- package/dist/services/llm-proxy/ssrf.js.map +1 -1
- package/dist/services/nomad-manager.d.ts +260 -3
- package/dist/services/nomad-manager.js +2921 -341
- package/dist/services/nomad-manager.js.map +1 -1
- package/dist/services/panel-manager.d.ts +50 -0
- package/dist/services/panel-manager.js +443 -0
- package/dist/services/panel-manager.js.map +1 -0
- package/dist/services/plugin-installer.js +28 -2
- package/dist/services/plugin-installer.js.map +1 -1
- package/dist/services/process-manager.js +42 -7
- package/dist/services/process-manager.js.map +1 -1
- package/dist/services/runtime/adapters/custom.d.ts +20 -0
- package/dist/services/runtime/adapters/custom.js +90 -0
- package/dist/services/runtime/adapters/custom.js.map +1 -0
- package/dist/services/runtime/adapters/hermes.d.ts +174 -0
- package/dist/services/runtime/adapters/hermes.js +1316 -0
- package/dist/services/runtime/adapters/hermes.js.map +1 -0
- package/dist/services/runtime/adapters/openclaw-routes.d.ts +17 -0
- package/dist/services/runtime/adapters/openclaw-routes.js +946 -0
- package/dist/services/runtime/adapters/openclaw-routes.js.map +1 -0
- package/dist/services/runtime/adapters/openclaw.d.ts +188 -0
- package/dist/services/runtime/adapters/openclaw.js +2195 -0
- package/dist/services/runtime/adapters/openclaw.js.map +1 -0
- package/dist/services/runtime/errors.d.ts +28 -0
- package/dist/services/runtime/errors.js +31 -0
- package/dist/services/runtime/errors.js.map +1 -0
- package/dist/services/runtime/index.d.ts +34 -0
- package/dist/services/runtime/index.js +51 -0
- package/dist/services/runtime/index.js.map +1 -0
- package/dist/services/runtime/instance.d.ts +24 -0
- package/dist/services/runtime/instance.js +143 -0
- package/dist/services/runtime/instance.js.map +1 -0
- package/dist/services/runtime/migrations.d.ts +15 -0
- package/dist/services/runtime/migrations.js +25 -0
- package/dist/services/runtime/migrations.js.map +1 -0
- package/dist/services/runtime/registry.d.ts +13 -0
- package/dist/services/runtime/registry.js +32 -0
- package/dist/services/runtime/registry.js.map +1 -0
- package/dist/services/runtime/types.d.ts +545 -0
- package/dist/services/runtime/types.js +14 -0
- package/dist/services/runtime/types.js.map +1 -0
- package/dist/services/setup-manager.d.ts +70 -29
- package/dist/services/setup-manager.js +591 -625
- package/dist/services/setup-manager.js.map +1 -1
- package/dist/services/task-registry.d.ts +44 -0
- package/dist/services/task-registry.js +74 -0
- package/dist/services/task-registry.js.map +1 -0
- package/dist/services/telemetry/heartbeat.d.ts +6 -6
- package/dist/services/telemetry/heartbeat.js +29 -30
- package/dist/services/telemetry/heartbeat.js.map +1 -1
- package/dist/services/update-manager.d.ts +47 -0
- package/dist/services/update-manager.js +305 -0
- package/dist/services/update-manager.js.map +1 -0
- package/dist/types.d.ts +224 -0
- package/dist/utils/docker-host.d.ts +15 -0
- package/dist/utils/docker-host.js +64 -0
- package/dist/utils/docker-host.js.map +1 -0
- package/install/jishu-install.sh +303 -38
- package/install/post-install.sh +64 -5
- package/package.json +19 -5
- package/public/assets/Dashboard-rh9qpYRR.js +1 -0
- package/public/assets/HermesChatPanel-D6JI6lLY.js +1 -0
- package/public/assets/HermesConfigForm-DcbSemaj.js +4 -0
- package/public/assets/InitPassword-CFTKsED4.js +1 -0
- package/public/assets/InstanceDetail-BhNIKA6Z.js +91 -0
- package/public/assets/{Login-CUoEZOWR.js → Login-KB9qrtM0.js} +1 -1
- package/public/assets/NewInstance-CxkO8Hlq.js +1 -0
- package/public/assets/Settings-BVWJvOkU.js +1 -0
- package/public/assets/Setup-X-lzuaUT.js +1 -0
- package/public/assets/WeixinLoginPanel-gca0QTic.js +9 -0
- package/public/assets/index-C8B0cFJM.js +19 -0
- package/public/assets/index-CPhVFEsx.css +1 -0
- package/public/assets/input-paste-CrNVAyOy.js +1 -0
- package/public/assets/{providers-lBSOjUWy.js → providers-V-vwrExZ.js} +1 -1
- package/public/assets/registry-fVUSujib.js +2 -0
- package/public/assets/{usePolling-CK0DfI4h.js → usePolling-Do5Erqm_.js} +1 -1
- package/public/assets/vendor-i18n-ucpM0OR0.js +9 -0
- package/public/assets/{vendor-react-B1-3Yrt-.js → vendor-react-Bk1hRGiY.js} +1 -1
- package/public/favicon.png +0 -0
- package/public/index.html +9 -4
- package/public/logos/hermes.png +0 -0
- package/public/logos/ollama.png +0 -0
- package/public/logos/openclaw.svg +60 -0
- package/scripts/build-hermes-image.sh +21 -0
- package/scripts/build-local.sh +54 -0
- package/scripts/check-adapter-isolation.ts +293 -0
- package/scripts/fixtures/instances/hermes-sample/instance.json +37 -0
- package/scripts/fixtures/instances/legacy-openclaw-sample/instance.json +7 -0
- package/scripts/smoke/hermes-bootstrap.sh +195 -0
- package/templates/hermes-entrypoint.sh +154 -0
- package/dist/doctor.js.map +0 -1
- package/install/jishu-install-china.sh +0 -3092
- package/public/assets/Dashboard-DhsrzJ4F.js +0 -1
- package/public/assets/InitPassword-BjubiVdd.js +0 -1
- package/public/assets/InstanceDetail-DMcywsof.js +0 -17
- package/public/assets/NewInstance-Bk0G4EiJ.js +0 -1
- package/public/assets/Settings-D5tHL_h5.js +0 -1
- package/public/assets/Setup-4t6E3Rut.js +0 -1
- package/public/assets/index-BJ47MWpF.css +0 -1
- package/public/assets/index-DbX85irc.js +0 -16
- package/public/assets/vendor-i18n-CfW0RvgE.js +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ao as ke,ap as Ae,o as Me,E as Se,j as e,I as Z,a as T,aq as Ce,s as Ke,ar as Pe,p as ie,as as Ie,at as $e,au as Ue,av as Ee,aw as Le}from"./index-C8B0cFJM.js";import{r as d}from"./vendor-react-Bk1hRGiY.js";import{g as oe}from"./input-paste-CrNVAyOy.js";import{P as F}from"./providers-V-vwrExZ.js";import{u as ee}from"./vendor-i18n-ucpM0OR0.js";function Be({showToast:a}){var re;const{t}=ee("settings"),{t:w}=ee("instance"),[x,I]=d.useState([]),[$,U]=d.useState(!0),[c,E]=d.useState(null),[V,L]=d.useState(!1),[B,f]=d.useState(!1),[H,D]=d.useState(null),[k,j]=d.useState([]),[i,A]=d.useState(""),[r,p]=d.useState(""),[y,h]=d.useState(""),[se,J]=d.useState(!1),[te,_]=d.useState(""),[q,Y]=d.useState(""),[O,le]=d.useState(!1),[M,z]=d.useState([]),ce={name:"",baseUrl:"",api:"openai",apiKey:"",authHeader:"",selectedModelId:""},[o,g]=d.useState(ce),[ae,me]=d.useState(!1),S=d.useCallback(()=>{U(!0),Pe().then(I).catch(()=>I([])).finally(()=>U(!1))},[]);d.useEffect(()=>{S()},[S]);const v="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200",G="w-full bg-background border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200 appearance-none",ue=()=>{E(null),A(""),p(""),h(""),_(""),Y(""),J(!1),z([]),j([]),L(!0)},xe=s=>{L(!1),j([]),g({name:s.name||s.id,baseUrl:s.baseUrl,api:s.api,apiKey:"",authHeader:s.authHeader||"",selectedModelId:s.selectedModelId||""}),E(s.id)},W=()=>{L(!1),E(null),j([]),A(""),p(""),h(""),_(""),Y(""),J(!1),z([])},pe=async()=>{var ne;if(!i){a(t("llm.presetRequired"),"error");return}const s=F.find(u=>u.id===i),l=s.local===!0;if(!l&&!r.trim()){a(t("llm.apiKeyRequired"),"error");return}if(l&&!y.trim()&&!s.baseUrl){a(t("llm.baseUrlRequired"),"error");return}const m=x.map(u=>u.id),b=q.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");let N=b?`${i}-${b}`:i;if(m.includes(N)){if(b){a(t("llm.aliasConflict"),"error");return}let u=2;for(;m.includes(`${i}-${u}`);)u++;N=`${i}-${u}`}const R=q.trim()?`${s.label} (${q.trim()})`:s.label,n=M.length>0?M.map(u=>({id:u.id,name:u.id,contextWindow:0})):s.models,P=te||((ne=n[0])==null?void 0:ne.id)||"";f(!0);try{await Ie({id:N,name:R,baseUrl:(l?y.trim():void 0)||s.baseUrl,api:s.api,apiKey:r||void 0,authHeader:s.authHeader?"x-api-key":void 0,models:n,selectedModelId:P}),a(t("llm.added"),"success"),W(),S()}catch(u){a(u.message||t("llm.saveFailed"),"error")}finally{f(!1)}},Q=async(s,l={})=>{if(!i)return;const m=F.find(n=>n.id===i),b=m.authHeader?"x-api-key":"Authorization",N=m.local===!0&&y.trim()?y.trim():m.baseUrl,R=s??r;le(!0);try{const{models:n}=await ie(N,R,b);z(n),n.length>0&&_(P=>P||n[0].id),l.silentSuccess||a(t("llm.modelsFetched",{count:n.length}),"success")}catch(n){a(n.message||t("llm.modelsFetchFailed"),"error")}finally{le(!1)}},he=s=>{if(!i||O)return;const l=F.find(b=>b.id===i);if(!l||l.local===!0)return;const m=oe(r,s).trim();m&&Q(m,{silentSuccess:!0})},be=async(s,l={})=>{if(!c)return;const m=o.baseUrl.trim();if(!m)return;const b=c,N=s??o.apiKey,R=o.authHeader.trim()||"Authorization";D(b);try{const{models:n}=await ie(m,N,R);j(n),n.length>0&&g(P=>({...P,selectedModelId:P.selectedModelId||n[0].id})),l.silentSuccess||a(t("llm.modelsFetched",{count:n.length}),"success")}catch(n){a(n.message||t("llm.modelsFetchFailed"),"error")}finally{D(n=>n===b?null:n)}},ge=s=>{if(!c||H===c)return;const l=oe(o.apiKey,s).trim();l&&be(l,{silentSuccess:!0})},ve=async()=>{if(c){if(!o.baseUrl.trim()){a(t("llm.baseUrlRequired"),"error");return}f(!0);try{await $e(c,{name:o.name||c,baseUrl:o.baseUrl.trim(),api:o.api,apiKey:o.apiKey||void 0,authHeader:o.authHeader||void 0,selectedModelId:o.selectedModelId||void 0}),a(t("llm.updated"),"success"),W(),S()}catch(s){a(s.message||t("llm.saveFailed"),"error")}finally{f(!1)}}},fe=async s=>{if(window.confirm(t("llm.confirmDelete",{id:s})))try{await Le(s),a(t("llm.deleted"),"success"),S()}catch(l){a(l.message||t("llm.deleteFailed"),"error")}},je=async s=>{try{await Ue(s),a(t("llm.defaultSet",{id:s}),"success"),S()}catch(l){a(l.message,"error")}},ye=async s=>{D(s);try{const{models:l}=await Ee(s);j(l),a(t("llm.modelsFetched",{count:l.length}),"success")}catch(l){a(l.message||t("llm.modelsFetchFailed"),"error")}finally{D(null)}},Ne=[...new Set(F.map(s=>s.group))],C=F.find(s=>s.id===i),de=(C==null?void 0:C.local)===!0,X=M.length>0?M.map(s=>({id:s.id,label:s.id})):((C==null?void 0:C.models)||[]).map(s=>({id:s.id,label:`${s.name} (${Math.round(s.contextWindow/1e3)}K)`})),Fe=e.jsxs("div",{className:"mt-3 border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--input-bg)]/40",children:[e.jsx("h3",{className:"text-sm font-medium",children:t("llm.addTitle")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.presetLabel")}),e.jsxs("select",{value:i,onChange:s=>{const l=F.find(m=>m.id===s.target.value);A(s.target.value),h((l==null?void 0:l.baseUrl)||""),_(""),z([])},className:G,children:[e.jsx("option",{value:"",children:t("llm.presetPlaceholder")}),Ne.map(s=>e.jsx("optgroup",{label:w(`configForm.providerGroup.${s}`,{defaultValue:s}),children:F.filter(l=>l.group===s).map(l=>e.jsx("option",{value:l.id,children:w(`configForm.providerLabel.${l.id}`,{defaultValue:l.label})},l.id))},s))]})]}),i&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.alias")}),e.jsx("input",{value:q,onChange:s=>Y(s.target.value),placeholder:t("llm.aliasPlaceholder"),className:v}),e.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:t("llm.aliasHint")})]}),i&&!de&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.fieldApiKey")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:se?"text":"password",value:r,onChange:s=>p(s.target.value),onPaste:he,placeholder:t("llm.apiKeyPlaceholder"),className:`${v} pr-9 font-mono`}),e.jsx("button",{type:"button",onClick:()=>J(s=>!s),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors",children:se?e.jsx(Z,{className:"w-3.5 h-3.5"}):e.jsx(T,{className:"w-3.5 h-3.5"})})]}),e.jsx("button",{type:"button",onClick:()=>{Q()},disabled:O,className:"px-3 py-1.5 text-xs border border-[var(--border)] rounded-md hover:bg-[var(--input-bg)] disabled:opacity-40 transition-all whitespace-nowrap",children:t(O?"llm.fetchingModels":"llm.fetchModels")})]})]}),i&&de&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.fieldBaseUrl")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:y,onChange:s=>h(s.target.value),className:`${v} flex-1`}),e.jsx("button",{type:"button",onClick:()=>{Q()},disabled:O,className:"px-3 py-1.5 text-xs border border-[var(--border)] rounded-md hover:bg-[var(--input-bg)] disabled:opacity-40 transition-all whitespace-nowrap",children:t(O?"llm.fetchingModels":"llm.fetchModels")})]})]}),i&&X.length>0&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs text-muted mb-1",children:[t("llm.fieldModel"),M.length>0&&e.jsxs("span",{className:"ml-1 text-green-500 text-[10px]",children:["(",M.length," ",t("llm.liveModels"),")"]})]}),e.jsx("select",{value:te||((re=X[0])==null?void 0:re.id)||"",onChange:s=>_(s.target.value),className:G,children:X.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx("button",{onClick:pe,disabled:B,className:"px-4 py-1.5 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all",children:t(B?"llm.saving":"llm.save")}),e.jsx("button",{onClick:W,className:"px-4 py-1.5 border border-[var(--border)] rounded-md text-sm hover:bg-[var(--input-bg)] transition-all",children:t("llm.cancel")})]})]}),K=x.find(s=>s.id===c),we=e.jsxs("div",{className:"mt-3 border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--input-bg)]/40",children:[e.jsx("h3",{className:"text-sm font-medium",children:t("llm.editTitle",{id:c})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.fieldName")}),e.jsx("input",{value:o.name,onChange:s=>g(l=>({...l,name:s.target.value})),placeholder:t("llm.fieldNamePlaceholder"),className:v})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"block text-xs text-muted mb-1",children:[t("llm.fieldBaseUrl")," *"]}),e.jsx("input",{value:o.baseUrl,onChange:s=>g(l=>({...l,baseUrl:s.target.value})),placeholder:"https://api.openai.com",className:v})]}),e.jsxs("div",{className:"col-span-2 sm:col-span-1",children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.fieldApi")}),e.jsxs("select",{value:o.api,onChange:s=>g(l=>({...l,api:s.target.value})),className:G,children:[e.jsx("option",{value:"openai",children:"OpenAI"}),e.jsx("option",{value:"openai-completions",children:"OpenAI Completions"}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"anthropic-messages",children:"Anthropic Messages"})]})]}),e.jsxs("div",{className:"col-span-2 sm:col-span-1",children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.fieldAuthHeader")}),e.jsx("input",{value:o.authHeader,onChange:s=>g(l=>({...l,authHeader:s.target.value})),placeholder:"Authorization",className:v})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"block text-xs text-muted mb-1",children:[t("llm.fieldApiKey"),K!=null&&K.hasApiKey?` (${t("llm.apiKeyConfigured")})`:""]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:ae?"text":"password",value:o.apiKey,onChange:s=>g(l=>({...l,apiKey:s.target.value})),onPaste:ge,placeholder:K!=null&&K.hasApiKey?t("llm.apiKeyLeaveBlank"):t("llm.apiKeyPlaceholder"),className:`${v} pr-9 font-mono`}),e.jsx("button",{type:"button",onClick:()=>me(s=>!s),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors",children:ae?e.jsx(Z,{className:"w-3.5 h-3.5"}):e.jsx(T,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-xs text-muted mb-1",children:t("llm.fieldModel")}),k.length>0?e.jsxs("select",{value:o.selectedModelId,onChange:s=>g(l=>({...l,selectedModelId:s.target.value})),className:G,children:[e.jsx("option",{value:"",children:t("llm.noModel")}),k.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}):e.jsx("input",{value:o.selectedModelId,onChange:s=>g(l=>({...l,selectedModelId:s.target.value})),placeholder:"gpt-4o",className:v})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx("button",{onClick:ve,disabled:B,className:"px-4 py-1.5 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all",children:t(B?"llm.saving":"llm.save")}),e.jsx("button",{onClick:W,className:"px-4 py-1.5 border border-[var(--border)] rounded-md text-sm hover:bg-[var(--input-bg)] transition-all",children:t("llm.cancel")})]})]});return e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-medium text-foreground",children:t("llm.title")}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:t("llm.desc")})]}),!V&&!c&&e.jsxs("button",{onClick:ue,className:"px-3 py-1.5 bg-[#0066FF] text-white rounded-md text-xs font-medium hover:bg-[#0066FF]/90 transition-all",children:["+ ",t("llm.add")]})]}),V&&Fe,$?e.jsx("p",{className:"text-sm text-muted py-3",children:t("llm.loading")}):x.length===0&&!V?e.jsx("p",{className:"text-sm text-muted py-3",children:t("llm.empty")}):e.jsx("div",{className:"space-y-2 mt-2",children:x.map(s=>e.jsxs("div",{className:`border rounded-lg p-3 transition-all ${s.isDefault?"border-[#0066FF]/40 bg-[#0066FF]/5":"border-[var(--border)]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:s.name||s.id}),s.isDefault&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-[#0066FF]/15 text-[#0066FF] rounded font-medium",children:t("llm.default")}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-[var(--input-bg)] text-muted rounded",children:s.api}),s.hasApiKey&&e.jsx("span",{className:"text-[10px] text-green-500",children:"🔑"})]}),e.jsx("p",{className:"text-xs text-muted truncate mt-0.5",children:s.baseUrl}),s.selectedModelId&&e.jsxs("p",{className:"text-xs text-muted mt-0.5",children:[t("llm.model"),": ",e.jsx("span",{className:"font-mono",children:s.selectedModelId})]})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[!s.isDefault&&e.jsx("button",{onClick:()=>je(s.id),className:"px-2 py-1 text-xs border border-[var(--border)] rounded hover:bg-[var(--input-bg)] transition-all",children:t("llm.setDefault")}),e.jsx("button",{onClick:()=>{xe(s),ye(s.id)},disabled:H===s.id,className:"px-2 py-1 text-xs border border-[var(--border)] rounded hover:bg-[var(--input-bg)] transition-all disabled:opacity-40",children:H===s.id?"...":t("llm.edit")}),e.jsx("button",{onClick:()=>fe(s.id),disabled:x.length<=1,title:x.length<=1?t("llm.deleteLastForbidden"):void 0,className:"px-2 py-1 text-xs border border-red-500/30 text-red-400 rounded hover:bg-red-500/10 transition-all disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none",children:t("llm.delete")})]})]}),c===s.id&&we,H===null&&k.length>0&&c!==s.id&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--border)]",children:[e.jsxs("p",{className:"text-xs text-muted mb-1",children:[t("llm.availableModels")," (",k.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1 max-h-20 overflow-y-auto",children:k.map(l=>e.jsx("span",{className:"text-[11px] font-mono px-1.5 py-0.5 bg-[var(--input-bg)] rounded",children:l.id},l.id))})]})]},s.id))})]})}function Ve(){const{t:a}=ee("settings"),{system:t,showToast:w}=ke(),[x,I]=d.useState(""),[$,U]=d.useState(""),[c,E]=d.useState(!1),[V,L]=d.useState([]),[B,f]=d.useState(!1),[H,D]=d.useState(!1),[k,j]=d.useState(!1);d.useEffect(()=>{f(!0),Ae().then(L).catch(()=>{}).finally(()=>f(!1)),Me().then(async r=>{try{const p=await Promise.all(r.map(h=>Se(h.id).catch(()=>({enabled:!1})))),y=r.length>0&&p.every(h=>h==null?void 0:h.enabled);j(y)}catch{}}).catch(()=>{})},[]);const i=async r=>{r.preventDefault();try{const p=await Ce(x,$);p.token&&Ke(p.token),w(a("password.updated"),"success"),I(""),U("")}catch(p){w(p.message||a("password.failed"),"error")}},A="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";return e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:a("title")}),e.jsx("p",{className:"text-sm text-muted mt-0.5",children:a("subtitle")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-medium text-foreground",children:a("proxy.title")}),e.jsx("p",{className:"text-sm text-muted mt-1",children:a("proxy.desc")})]}),e.jsx("div",{className:"mt-3 bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-4 py-3",children:a("proxy.status")})]}),e.jsx(Be,{showToast:w}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground mb-3",children:a("password.title")}),e.jsxs("form",{onSubmit:i,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted mb-1.5",children:a("password.current")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:c?"text":"password",value:x,onChange:r=>I(r.target.value),placeholder:a("password.currentPlaceholder"),className:`${A} pr-9`}),e.jsx("button",{type:"button",onClick:()=>E(!c),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors",children:c?e.jsx(Z,{className:"w-3.5 h-3.5"}):e.jsx(T,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted mb-1.5",children:a("password.new")}),e.jsx("input",{type:c?"text":"password",value:$,onChange:r=>U(r.target.value),placeholder:a("password.newPlaceholder"),className:A})]}),e.jsx("button",{type:"submit",disabled:!x||$.length<8,className:"px-4 py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:a("password.submit")})]})]}),t&&e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground mb-3",children:a("system.title")}),e.jsxs("div",{className:"space-y-3",children:[[{label:a("system.cpuUsage"),value:`${t.cpu_percent}%`,percent:t.cpu_percent,warn:t.cpu_percent>90,color:"bg-[#0066FF]"},{label:a("system.memory"),value:`${t.memory.used_mb}MB / ${t.memory.total_mb}MB (${t.memory.percent}%)`,percent:t.memory.percent,warn:!1,color:"bg-[#00D4AA]"},{label:a("system.disk"),value:`${t.disk.used_gb}GB / ${t.disk.total_gb}GB (${t.disk.percent}%)`,percent:t.disk.percent,warn:t.disk.percent>90,color:"bg-[#0066FF]"}].map(r=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1.5",children:[e.jsx("span",{className:"text-muted",children:r.label}),e.jsx("span",{className:`font-medium font-mono text-[13px] ${r.warn?"text-red-400":"text-foreground"}`,children:r.value})]}),e.jsx("div",{className:"w-full bg-[var(--input-bg)] rounded-full h-1.5",children:e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-500 ${r.warn?"bg-red-500":r.color}`,style:{width:`${r.percent}%`}})})]},r.label)),t.temperature&&e.jsxs("div",{className:"flex justify-between text-sm pt-2 border-t border-[var(--border)]",children:[e.jsx("span",{className:"text-muted",children:a("system.cpuTemp")}),e.jsxs("span",{className:"font-medium font-mono text-[13px] text-foreground",children:[t.temperature,"°C"]})]})]})]}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground mb-2",children:a("about.title")}),e.jsx("div",{className:"text-sm text-muted space-y-1",children:e.jsxs("p",{children:["JishuShell ","0.4.24-beta.2"]})})]})]})]})}export{Ve as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as ne,d as we,p as Fe,j as e,L as Se,T as _e,e as ae,i as $,f as Ce,r as Ie,h as Le,u as Me}from"./index-C8B0cFJM.js";import{r as c}from"./vendor-react-Bk1hRGiY.js";import{g as Te}from"./input-paste-CrNVAyOy.js";import{P as k}from"./providers-V-vwrExZ.js";import{u as Ae}from"./registry-fVUSujib.js";import{u as ie}from"./vendor-i18n-ucpM0OR0.js";function le(l,p){var r,j;if(!l)return!1;const t=(r=l.runtimes)==null?void 0:r[p];return t?!!t.installed&&!!t.imageReady:p==="openclaw"?!!((j=l.openclaw)!=null&&j.installed)&&!!l.dockerImageReady:!1}function Re(l,p){var r;const t=(r=l==null?void 0:l.runtimes)==null?void 0:r[p];return t&&typeof t.required=="boolean"?t.required:p==="openclaw"}function de(l,p){if(!l)return!1;const t=p.filter(r=>Re(l,r.agentType));return t.length===0?!0:t.every(r=>le(l,r.agentType))}const C=[{id:"check",label:"环境检测"},{id:"node",label:"Node.js"},{id:"docker",label:"Docker"},{id:"nomad",label:"Nomad"},{id:"openclaw",label:"OpenClaw"},{id:"provider",label:"模型配置"},{id:"done",label:"完成"}];function Pe({ok:l}){return l?e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-emerald-500 shadow-[0_0_6px_rgba(16,185,129,0.7)]"}):e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-[var(--border)]"})}function D({dep:l,label:p,required:t,extra:r}){const{t:j}=ie("setup"),x=l.needsUpgrade;return e.jsxs("div",{className:"flex items-center justify-between py-2.5 border-b border-[var(--border)] last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[x?e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 shadow-[0_0_6px_rgba(251,191,36,0.6)]"}):e.jsx(Pe,{ok:l.installed}),e.jsx("span",{className:"text-sm text-foreground",children:p||l.name}),x&&e.jsx("span",{className:"text-xs text-amber-400",children:j("versionTooOld")}),t&&!l.installed&&!x&&e.jsx("span",{className:"text-xs text-red-400",children:j("required")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r,e.jsx("span",{className:"text-xs text-muted font-mono",children:l.installed?l.version||"installed":"not installed"})]})]})}function I(){return e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"})}function oe(l){return/失败|error|denied|forbidden|unauthorized/i.test(l)?"error":/完成|已就绪|已启动|已存在|成功|built|installed/i.test(l)?"success":/正在|等待|下载|安装|构建|启动|升级|progress|exporting|transferring/i.test(l)?"progress":"info"}function De(l){switch(l){case"progress":return{dot:"bg-sky-400 shadow-[0_0_8px_rgba(56,189,248,0.55)]",text:"text-sky-100"};case"success":return{dot:"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.55)]",text:"text-emerald-100"};case"error":return{dot:"bg-red-400 shadow-[0_0_8px_rgba(248,113,113,0.55)]",text:"text-red-200"};default:return{dot:"bg-slate-500 shadow-[0_0_8px_rgba(148,163,184,0.35)]",text:"text-slate-200/90"}}}function Be({onDone:l}){var ee,te,se,re;const{runtimes:p}=Ae(),{t}=ie(["setup","common","instance"]),[r,j]=c.useState(null),[x,E]=c.useState("check"),[f,w]=c.useState(null),[K,z]=c.useState([]),[L,v]=c.useState(""),[B,H]=c.useState(!1),[b,ce]=c.useState(""),[N,ue]=c.useState(""),[q,me]=c.useState(!1),[W,U]=c.useState(""),[O,V]=c.useState(!1),[F,M]=c.useState([]),[S,G]=c.useState(!1),[_,J]=c.useState(""),Q=c.useRef(new Set),X=c.useCallback((n,s)=>{if(Q.current.has(n))return;Q.current.add(n);const a=s==="openclaw-docker"?t("setup:dockerImageBuild"):s==="docker"?t("setup:dockerInstall"):s==="openclaw"?t("setup:openclawInstall"):s;w(s),h(t("setup:resumeTask",{label:a}),"progress"),Y(n,a).then(()=>{g(!0)}).catch(o=>{v(o.message||t("setup:taskFailed"))}).finally(()=>{w(null)})},[]),g=c.useCallback((n=!1)=>{ne().then(s=>{var a;if(j(s),(a=s.runningTasks)!=null&&a.length)for(const o of s.runningTasks)X(o.id,o.name);if(!n&&s.ready){E("provider");return}}).catch(()=>{})},[l,X]);c.useEffect(()=>{g()},[g]),c.useEffect(()=>{var s,a;if(x!=="nomad"||!((s=r==null?void 0:r.nomad)!=null&&s.installed)||(a=r==null?void 0:r.nomad)!=null&&a.running)return;const n=setInterval(()=>{g(!0)},3e3);return()=>clearInterval(n)},[x,(ee=r==null?void 0:r.nomad)==null?void 0:ee.installed,(te=r==null?void 0:r.nomad)==null?void 0:te.running,g]);const h=(n,s=oe(n))=>z(a=>[...a,{message:n,tone:s}].slice(-200)),xe=(n,s)=>s.type==="progress"&&typeof s.progress=="number"?`${n}: ${s.message} [${s.progress}%]`:s.type==="done"?`${n}: ${s.message}`:s.type==="error"?t("setup:taskErrorPrefix",{label:n,message:s.message}):s.message,Y=async(n,s)=>{let a=0,o=0,u=t("setup:taskCompleted",{label:s});const d=Date.now()+30*60*1e3;for(;Date.now()<d;){try{const m=await we(n);o=0;const ke=m.events.slice(a);a=m.events.length;for(const y of ke){const ye=y.type==="done"?"success":y.type==="error"?"error":y.type==="progress"?"progress":oe(y.message);h(xe(s,y),ye),y.message&&(u=y.message)}if(m.status==="done")return u;if(m.status==="error")throw new Error(u)}catch(m){if(o+=1,o>=5)throw new Error((m==null?void 0:m.message)||t("setup:taskStatusFailed",{label:s}))}const i=Math.min(1e3+a*200,3e3);await new Promise(m=>setTimeout(m,i))}throw new Error(t("setup:taskTimeout",{label:s}))},T=async(n,s,a)=>{w(n),v(""),h(t("setup:installing",{label:s}),"progress");try{const o=await a();let u=o.message||t("setup:taskStarted",{label:s});return o!=null&&o.taskId?u=await Y(o.taskId,s):h(`${s}: ${u}`,"success"),g(!0),!0}catch(o){const u=o.message||t("setup:defaultInstallFailed");return h(t("setup:installFailed",{label:s,error:u}),"error"),v(u),!1}finally{w(null)}},Z=async()=>{await T("node","Node.js",()=>Me())},pe=async()=>{await T("docker","Docker",()=>$("docker"))},[be,he]=c.useState(!1),fe=async n=>{const s=p.find(o=>o.agentType===n);if(!s)return;s.installHint&&h(s.installHint,"info");const a=await T(`runtime-${n}`,s.installLabel,()=>Le(n));n==="openclaw"&&a&&he(!0),g(!0)},ge=async()=>{var s;if(await T("nomad","Nomad",()=>$("nomad"))){h(t("setup:configuringNomadSystemd"),"progress"),w("nomad-systemd");try{await $("nomad-systemd"),h(t("setup:nomadServiceStarted"),"success")}catch{try{await Ce("nomad"),h(t("setup:nomadStarted"),"success")}catch(a){h(t("setup:nomadStartFailed",{error:a.message}),"error"),v(a.message)}}w(null),h(t("setup:waitingNomad"),"progress");for(let a=0;a<10;a++){await new Promise(u=>setTimeout(u,2e3));const o=await ne();if((s=o.nomad)!=null&&s.running){j(o),h(t("setup:nomadReady"),"success");return}}g(!0)}},A=!!((se=r==null?void 0:r.node)!=null&&se.installed)&&!((re=r==null?void 0:r.node)!=null&&re.needsUpgrade),R=async()=>{var o,u,d,i;const n=C.findIndex(m=>m.id===x);if(n>=C.length-1)return;let s=n+1;for(;s<C.length-1;){const m=C[s].id;if(m==="node"&&A){s++;continue}if(m==="docker"&&((o=r==null?void 0:r.docker)!=null&&o.installed)&&((u=r==null?void 0:r.docker)!=null&&u.running)){s++;continue}if(m==="nomad"&&((d=r==null?void 0:r.nomad)!=null&&d.installed)&&((i=r==null?void 0:r.nomad)!=null&&i.running)){s++;continue}if(m==="openclaw"&&de(r,p)){s++;continue}break}const a=C[s].id;if(v(""),z([]),a==="done"){E("done"),H(!0);try{await Ie({installNomad:!1,buildDockerImage:!1})}catch(m){v(m.message||t("setup:configWriteFailed"))}finally{H(!1)}}else E(a)},ve=n=>{if(!r)return!1;switch(n){case"check":return A;case"node":return A;case"docker":return r.docker.installed&&r.docker.running;case"nomad":return r.nomad.installed&&r.nomad.running;case"openclaw":return de(r,p)||be&&r.openclaw.installed&&p.length===1;case"provider":return!0;case"done":return!0;default:return!1}},P=c.useCallback(async n=>{if(!b)return;const s=k.find(i=>i.id===b);if(!s)return;const o=s.local===!0&&_.trim()?_.trim():s.baseUrl,u=s.authHeader?"x-api-key":"Authorization",d=n??N;G(!0),v("");try{const{models:i}=await Fe(o,d,u);M(i),i.length>0&&U(i[0].id)}catch(i){v(i.message||t("setup:provider.fetchModelsFailed"))}finally{G(!1)}},[N,_,b,t]),je=c.useCallback(n=>{if(!b||S)return;const s=k.find(o=>o.id===b);if(!s||s.local===!0)return;const a=Te(N,n).trim();a&&P(a)},[N,S,P,b]),Ne=async()=>{var d;if(!b)return!1;const n=k.find(i=>i.id===b);if(!n)return!1;const s=n.local===!0,a=s&&_.trim()?_.trim():n.baseUrl;if(s&&!a)return v(t("setup:provider.baseUrlRequired",{defaultValue:"Base URL is required"})),!1;const o=F.length>0?F.map(i=>({id:i.id,name:i.name||i.id,contextWindow:128e3})):n.models,u=W||((d=o[0])==null?void 0:d.id)||"";V(!0);try{return await ae({providerId:n.id,baseUrl:a,api:n.api,authHeader:n.authHeader?"x-api-key":void 0,models:o,selectedModelId:u,apiKey:N||""}),!0}catch(i){return v(i.message||t("setup:provider.saveFailed")),!1}finally{V(!1)}};return r?e.jsxs("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background relative overflow-hidden",children:[e.jsx("div",{className:"grid-bg absolute inset-0 pointer-events-none"}),e.jsx("div",{className:"absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[400px] rounded-full bg-[#0066FF]/[0.06] blur-[100px] pointer-events-none"}),e.jsx("div",{className:"absolute left-4 bottom-4 z-20",children:e.jsx(Se,{className:"bg-card/80 backdrop-blur-sm"})}),e.jsxs("div",{className:"w-full max-w-lg relative z-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(_e,{className:"w-48 h-48 mx-auto mb-4 object-contain"}),e.jsx("p",{className:"text-sm text-muted mt-1",children:t("setup:title")})]}),e.jsxs("div",{className:"bg-card border border-[var(--border)] rounded-xl p-6 backdrop-blur-sm",children:[x==="check"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:t("setup:check.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t("setup:check.desc")}),e.jsx("p",{className:"text-xs text-muted mb-1.5 font-medium",children:t("setup:check.requiredComponents")}),e.jsxs("div",{className:"bg-card rounded-md border border-[var(--border)] px-4",children:[e.jsx(D,{dep:r.node,label:"Node.js",required:!0,extra:r.node.needsUpgrade?e.jsx("button",{onClick:Z,disabled:!!f,className:"text-xs bg-amber-500/20 text-amber-400 border border-amber-500/30 rounded px-2 py-0.5 hover:bg-amber-500/30 disabled:opacity-40 transition-colors duration-200",children:t(f==="node"?"setup:check.upgrading":"setup:check.upgrade")}):void 0}),e.jsx(D,{dep:r.docker,label:"Docker",required:!0}),e.jsx(D,{dep:r.nomad,label:"Nomad",required:!0}),e.jsx(D,{dep:r.openclaw,label:"OpenClaw",required:!0})]})]}),x==="node"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:t("setup:node.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t("setup:node.desc")}),A?e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm rounded-md px-3 py-2.5",children:t("setup:node.ready",{version:r.node.version})}):r.hasSudo?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:t("setup:node.currentVersion",{version:r.node.version})}),e.jsx("button",{onClick:Z,disabled:!!f,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:f?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(I,{}),t("setup:node.upgrading")]}):t("setup:node.upgradeBtn")}),e.jsx("p",{className:"text-xs text-muted",children:t("setup:node.sudoRequired")})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:t("setup:node.noSudo",{version:r.node.version})}),e.jsxs("div",{className:"bg-card border border-[var(--border)] rounded-md p-3",children:[e.jsx("p",{className:"text-xs text-muted mb-1.5",children:t("setup:node.contactAdmin")}),e.jsx("code",{className:"text-xs text-foreground font-mono block whitespace-pre-wrap",children:"curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs"})]}),e.jsx("button",{onClick:()=>g(!0),className:"text-xs text-muted hover:text-foreground underline transition-colors duration-200",children:t("setup:node.refreshAfterInstall")})]})]}),x==="docker"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:t("setup:docker.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t("setup:docker.desc")}),r.docker.installed&&r.docker.running?e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm rounded-md px-3 py-2.5",children:t("setup:docker.running",{version:r.docker.version})}):r.docker.installed&&!r.docker.running?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:t("setup:docker.notRunning")}),e.jsx("div",{className:"bg-card border border-[var(--border)] rounded-md p-3",children:e.jsx("code",{className:"text-xs text-foreground font-mono block",children:"sudo systemctl start docker"})}),e.jsx("button",{onClick:()=>g(!0),className:"text-xs text-muted hover:text-foreground underline transition-colors duration-200",children:t("setup:docker.refreshAfterStart")})]}):r.hasSudo?e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:pe,disabled:!!f,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:f?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(I,{}),t("setup:docker.installing")]}):t("setup:docker.installBtn")}),e.jsx("p",{className:"text-xs text-muted",children:t("setup:docker.sudoRequired")})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:t("setup:docker.noSudo")}),e.jsxs("div",{className:"bg-card border border-[var(--border)] rounded-md p-3",children:[e.jsx("p",{className:"text-xs text-muted mb-1.5",children:t("setup:docker.contactAdmin")}),e.jsx("code",{className:"text-xs text-foreground font-mono block",children:"curl -fsSL https://get.docker.com | sh"})]}),e.jsx("button",{onClick:()=>g(!0),className:"text-xs text-muted hover:text-foreground underline transition-colors duration-200",children:t("setup:docker.refreshAfterInstall")})]})]}),x==="nomad"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:t("setup:nomad.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t("setup:nomad.desc")}),r.nomad.installed&&r.nomad.running?e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm rounded-md px-3 py-2.5",children:t("setup:nomad.running",{version:r.nomad.version})}):r.nomad.installed?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex items-center gap-2 bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-md px-3 py-2.5",children:[e.jsx(I,{}),e.jsx("span",{children:t("setup:nomad.starting")})]})}):e.jsx("button",{onClick:ge,disabled:!!f,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:f?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(I,{}),t("setup:nomad.installing")]}):t("setup:nomad.installBtn")})]}),x==="openclaw"&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:"Agent 运行时"}),e.jsx("p",{className:"text-sm text-muted mb-4",children:"安装所有已注册的 Agent 运行时 (Docker 镜像 / shim)。每次添加新 Agent 时,这里会自动出现一行。"}),e.jsx("div",{className:"space-y-4",children:p.map(n=>{const s=le(r,n.agentType),a=f===`runtime-${n.agentType}`;return e.jsxs("div",{className:"rounded-md border border-[var(--border)] bg-[var(--card)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:n.displayName}),e.jsx("div",{className:"text-xs text-muted",children:n.description})]}),s?e.jsx("span",{className:"text-xs text-emerald-400 font-mono",children:"已就绪"}):a?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-amber-400",children:[e.jsx(I,{}),"安装中"]}):e.jsx("span",{className:"text-xs text-muted",children:"未安装"})]}),!s&&!a&&e.jsxs("div",{className:"space-y-2",children:[n.installHint&&e.jsx("p",{className:"text-xs text-muted",children:n.installHint}),e.jsxs("button",{onClick:()=>fe(n.agentType),disabled:!!f,className:"bg-[#0066FF] text-white rounded-md px-4 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:["安装 ",n.displayName]})]})]},n.agentType)})})]}),x==="done"&&e.jsx("div",{className:"text-center py-4",children:B?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-2 border-white/10 border-t-[#0066FF] rounded-full animate-spin"})}),e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:t("setup:done.finalizing")}),e.jsx("p",{className:"text-sm text-muted",children:t("setup:done.finalizingDesc")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:t("setup:done.complete")}),e.jsx("p",{className:"text-sm text-muted",children:t("setup:done.completeDesc")})]})}),x==="provider"&&(()=>{var u;const n=k.find(d=>d.id===b),s=[...new Set(k.map(d=>d.group))],a=(n==null?void 0:n.local)===!0,o=F.length>0?F.map(d=>({id:d.id,label:d.name||d.id})):((n==null?void 0:n.models)||[]).map(d=>({id:d.id,label:`${d.name} (${Math.round(d.contextWindow/1e3)}K)`}));return e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-medium text-foreground mb-1",children:t("setup:provider.title")}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t("setup:provider.desc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("setup:provider.label")}),e.jsxs("select",{value:b,onChange:d=>{ce(d.target.value),U(""),M([]);const i=k.find(m=>m.id===d.target.value);J((i==null?void 0:i.baseUrl)||"")},className:"w-full bg-background border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60",children:[e.jsx("option",{value:"",children:t("setup:provider.placeholder")}),s.map(d=>e.jsx("optgroup",{label:t(`instance:configForm.providerGroup.${d}`,{defaultValue:d}),children:k.filter(i=>i.group===d).map(i=>e.jsx("option",{value:i.id,children:t(`instance:configForm.providerLabel.${i.id}`,{defaultValue:i.label})},i.id))},d))]})]}),b&&a&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("setup:provider.baseUrl")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:_,onChange:d=>{J(d.target.value),M([])},className:"flex-1 bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60"}),e.jsx("button",{type:"button",onClick:()=>{P()},disabled:S,className:"px-3 py-1.5 text-xs border border-[var(--border)] rounded-md hover:bg-[var(--input-bg)] disabled:opacity-40 transition-all whitespace-nowrap",children:t(S?"setup:provider.fetchingModels":"setup:provider.fetchModels")})]})]}),b&&!a&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("setup:provider.apiKey")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:q?"text":"password",value:N,onChange:d=>{ue(d.target.value),M([])},onPaste:je,placeholder:t("setup:provider.apiKeyPlaceholder"),className:"w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 pr-9 text-sm text-foreground font-mono placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60"}),e.jsx("button",{type:"button",onClick:()=>me(!q),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:q?e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"}):e.jsxs(e.Fragment,{children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})})]}),e.jsx("button",{type:"button",onClick:()=>{P()},disabled:S||!N.trim(),className:"px-3 py-1.5 text-xs border border-[var(--border)] rounded-md hover:bg-[var(--input-bg)] disabled:opacity-40 transition-all whitespace-nowrap",children:t(S?"setup:provider.fetchingModels":"setup:provider.fetchModels")})]})]}),n&&o.length>0&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-muted mb-1.5",children:[t("setup:provider.defaultModel"),F.length>0&&e.jsxs("span",{className:"ml-1.5 text-emerald-400 text-xs",children:["(",F.length," ",t("setup:provider.liveModels"),")"]})]}),e.jsx("select",{value:W||((u=o[0])==null?void 0:u.id)||"",onChange:d=>U(d.target.value),className:"w-full bg-background border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60",children:o.map(d=>e.jsx("option",{value:d.id,children:d.label},d.id))})]})]})]})})(),K.length>0&&x!=="done"&&e.jsxs("div",{className:"mt-4 rounded-lg border border-[var(--border)] bg-[linear-gradient(180deg,rgba(2,6,23,0.96),rgba(15,23,42,0.92))] p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] max-h-40 overflow-y-auto",children:[K.map((n,s)=>{const a=De(n.tone);return e.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[e.jsx("span",{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${a.dot}`}),e.jsx("div",{className:`min-w-0 whitespace-pre-wrap break-words text-xs font-mono leading-5 ${a.text}`,children:n.message})]},s)}),e.jsx("div",{className:"pointer-events-none sticky bottom-0 h-4 bg-gradient-to-t from-slate-950/85 to-transparent"})]}),L&&e.jsx("div",{className:"mt-4 bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-md px-3 py-2.5",children:L})]}),e.jsx("div",{className:"flex justify-between mt-6",children:x==="provider"?(()=>{var a;const n=((a=k.find(o=>o.id===b))==null?void 0:a.local)===!0,s=b&&(n||N.trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:async()=>{await ae({skipped:!0}).catch(()=>{}),R()},className:"bg-[var(--card)] border border-[var(--border)] text-foreground rounded-md px-6 py-2 text-sm font-medium hover:bg-[var(--card-hover)] transition-all duration-200",children:t("setup:provider.skip")}),e.jsx("button",{onClick:async()=>{await Ne()&&R()},disabled:!s||O,className:"bg-[#0066FF] text-white rounded-md px-6 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)]",children:t(O?"setup:provider.saving":"setup:provider.saveAndContinue")})]})})():x!=="done"?e.jsxs(e.Fragment,{children:[e.jsx("div",{}),e.jsx("button",{onClick:R,disabled:!ve(x)||!!f,className:"bg-[#0066FF] text-white rounded-md px-6 py-2 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",children:t("setup:nav.next")})]}):e.jsx("button",{onClick:L?()=>R():l,disabled:B,className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)]",children:t(L?"setup:nav.retry":"setup:nav.enterPanel")})})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border)] border-t-foreground rounded-full animate-spin"})})}export{Be as default};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{j as c,a0 as fe,az as me,I as ge,a as pe,a7 as xe,a9 as we,aA as Y,a8 as be,aa as Ee}from"./index-C8B0cFJM.js";import{e as A,r as y}from"./vendor-react-Bk1hRGiY.js";import{u as _}from"./vendor-i18n-ucpM0OR0.js";var ve=Object.defineProperty,D=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,V=(a,i,s)=>i in a?ve(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s,z=(a,i)=>{for(var s in i||(i={}))W.call(i,s)&&V(a,s,i[s]);if(D)for(var s of D(i))X.call(i,s)&&V(a,s,i[s]);return a},U=(a,i)=>{var s={};for(var d in a)W.call(a,d)&&i.indexOf(d)<0&&(s[d]=a[d]);if(a!=null&&D)for(var d of D(a))i.indexOf(d)<0&&X.call(a,d)&&(s[d]=a[d]);return s};/**
|
|
2
|
+
* @license QR Code generator library (TypeScript)
|
|
3
|
+
* Copyright (c) Project Nayuki.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/var T;(a=>{const i=class b{constructor(e,r,t,n){if(this.version=e,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],e<b.MIN_VERSION||e>b.MAX_VERSION)throw new RangeError("Version value out of range");if(n<-1||n>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let o=[];for(let u=0;u<this.size;u++)o.push(!1);for(let u=0;u<this.size;u++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();const f=this.addEccAndInterleave(t);if(this.drawCodewords(f),n==-1){let u=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const g=this.getPenaltyScore();g<u&&(n=m,u=g),this.applyMask(m)}}h(0<=n&&n<=7),this.mask=n,this.applyMask(n),this.drawFormatBits(n),this.isFunction=[]}static encodeText(e,r){const t=a.QrSegment.makeSegments(e);return b.encodeSegments(t,r)}static encodeBinary(e,r){const t=a.QrSegment.makeBytes(e);return b.encodeSegments([t],r)}static encodeSegments(e,r,t=1,n=40,o=-1,f=!0){if(!(b.MIN_VERSION<=t&&t<=n&&n<=b.MAX_VERSION)||o<-1||o>7)throw new RangeError("Invalid value");let u,m;for(u=t;;u++){const p=b.getNumDataCodewords(u,r)*8,N=E.getTotalBits(e,u);if(N<=p){m=N;break}if(u>=n)throw new RangeError("Data too long")}for(const p of[b.Ecc.MEDIUM,b.Ecc.QUARTILE,b.Ecc.HIGH])f&&m<=b.getNumDataCodewords(u,p)*8&&(r=p);let g=[];for(const p of e){s(p.mode.modeBits,4,g),s(p.numChars,p.mode.numCharCountBits(u),g);for(const N of p.getData())g.push(N)}h(g.length==m);const C=b.getNumDataCodewords(u,r)*8;h(g.length<=C),s(0,Math.min(4,C-g.length),g),s(0,(8-g.length%8)%8,g),h(g.length%8==0);for(let p=236;g.length<C;p^=253)s(p,8,g);let F=[];for(;F.length*8<g.length;)F.push(0);return g.forEach((p,N)=>F[N>>>3]|=p<<7-(N&7)),new b(u,r,F,o)}getModule(e,r){return 0<=e&&e<this.size&&0<=r&&r<this.size&&this.modules[r][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),r=e.length;for(let t=0;t<r;t++)for(let n=0;n<r;n++)t==0&&n==0||t==0&&n==r-1||t==r-1&&n==0||this.drawAlignmentPattern(e[t],e[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const r=this.errorCorrectionLevel.formatBits<<3|e;let t=r;for(let o=0;o<10;o++)t=t<<1^(t>>>9)*1335;const n=(r<<10|t)^21522;h(n>>>15==0);for(let o=0;o<=5;o++)this.setFunctionModule(8,o,d(n,o));this.setFunctionModule(8,7,d(n,6)),this.setFunctionModule(8,8,d(n,7)),this.setFunctionModule(7,8,d(n,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,d(n,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,d(n,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,d(n,o));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const r=this.version<<12|e;h(r>>>18==0);for(let t=0;t<18;t++){const n=d(r,t),o=this.size-11+t%3,f=Math.floor(t/3);this.setFunctionModule(o,f,n),this.setFunctionModule(f,o,n)}}drawFinderPattern(e,r){for(let t=-4;t<=4;t++)for(let n=-4;n<=4;n++){const o=Math.max(Math.abs(n),Math.abs(t)),f=e+n,u=r+t;0<=f&&f<this.size&&0<=u&&u<this.size&&this.setFunctionModule(f,u,o!=2&&o!=4)}}drawAlignmentPattern(e,r){for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)this.setFunctionModule(e+n,r+t,Math.max(Math.abs(n),Math.abs(t))!=1)}setFunctionModule(e,r,t){this.modules[r][e]=t,this.isFunction[r][e]=!0}addEccAndInterleave(e){const r=this.version,t=this.errorCorrectionLevel;if(e.length!=b.getNumDataCodewords(r,t))throw new RangeError("Invalid argument");const n=b.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][r],o=b.ECC_CODEWORDS_PER_BLOCK[t.ordinal][r],f=Math.floor(b.getNumRawDataModules(r)/8),u=n-f%n,m=Math.floor(f/n);let g=[];const C=b.reedSolomonComputeDivisor(o);for(let p=0,N=0;p<n;p++){let S=e.slice(N,N+m-o+(p<u?0:1));N+=S.length;const w=b.reedSolomonComputeRemainder(S,C);p<u&&S.push(0),g.push(S.concat(w))}let F=[];for(let p=0;p<g[0].length;p++)g.forEach((N,S)=>{(p!=m-o||S>=u)&&F.push(N[p])});return h(F.length==f),F}drawCodewords(e){if(e.length!=Math.floor(b.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let n=0;n<this.size;n++)for(let o=0;o<2;o++){const f=t-o,m=(t+1&2)==0?this.size-1-n:n;!this.isFunction[m][f]&&r<e.length*8&&(this.modules[m][f]=d(e[r>>>3],7-(r&7)),r++)}}h(r==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let r=0;r<this.size;r++)for(let t=0;t<this.size;t++){let n;switch(e){case 0:n=(t+r)%2==0;break;case 1:n=r%2==0;break;case 2:n=t%3==0;break;case 3:n=(t+r)%3==0;break;case 4:n=(Math.floor(t/3)+Math.floor(r/2))%2==0;break;case 5:n=t*r%2+t*r%3==0;break;case 6:n=(t*r%2+t*r%3)%2==0;break;case 7:n=((t+r)%2+t*r%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[r][t]&&n&&(this.modules[r][t]=!this.modules[r][t])}}getPenaltyScore(){let e=0;for(let o=0;o<this.size;o++){let f=!1,u=0,m=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[o][g]==f?(u++,u==5?e+=b.PENALTY_N1:u>5&&e++):(this.finderPenaltyAddHistory(u,m),f||(e+=this.finderPenaltyCountPatterns(m)*b.PENALTY_N3),f=this.modules[o][g],u=1);e+=this.finderPenaltyTerminateAndCount(f,u,m)*b.PENALTY_N3}for(let o=0;o<this.size;o++){let f=!1,u=0,m=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[g][o]==f?(u++,u==5?e+=b.PENALTY_N1:u>5&&e++):(this.finderPenaltyAddHistory(u,m),f||(e+=this.finderPenaltyCountPatterns(m)*b.PENALTY_N3),f=this.modules[g][o],u=1);e+=this.finderPenaltyTerminateAndCount(f,u,m)*b.PENALTY_N3}for(let o=0;o<this.size-1;o++)for(let f=0;f<this.size-1;f++){const u=this.modules[o][f];u==this.modules[o][f+1]&&u==this.modules[o+1][f]&&u==this.modules[o+1][f+1]&&(e+=b.PENALTY_N2)}let r=0;for(const o of this.modules)r=o.reduce((f,u)=>f+(u?1:0),r);const t=this.size*this.size,n=Math.ceil(Math.abs(r*20-t*10)/t)-1;return h(0<=n&&n<=9),e+=n*b.PENALTY_N4,h(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,r=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let n=this.size-7;t.length<e;n-=r)t.splice(1,0,n);return t}}static getNumRawDataModules(e){if(e<b.MIN_VERSION||e>b.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;r-=(25*t-10)*t-55,e>=7&&(r-=36)}return h(208<=r&&r<=29648),r}static getNumDataCodewords(e,r){return Math.floor(b.getNumRawDataModules(e)/8)-b.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*b.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let r=[];for(let n=0;n<e-1;n++)r.push(0);r.push(1);let t=1;for(let n=0;n<e;n++){for(let o=0;o<r.length;o++)r[o]=b.reedSolomonMultiply(r[o],t),o+1<r.length&&(r[o]^=r[o+1]);t=b.reedSolomonMultiply(t,2)}return r}static reedSolomonComputeRemainder(e,r){let t=r.map(n=>0);for(const n of e){const o=n^t.shift();t.push(0),r.forEach((f,u)=>t[u]^=b.reedSolomonMultiply(f,o))}return t}static reedSolomonMultiply(e,r){if(e>>>8||r>>>8)throw new RangeError("Byte out of range");let t=0;for(let n=7;n>=0;n--)t=t<<1^(t>>>7)*285,t^=(r>>>n&1)*e;return h(t>>>8==0),t}finderPenaltyCountPatterns(e){const r=e[1];h(r<=this.size*3);const t=r>0&&e[2]==r&&e[3]==r*3&&e[4]==r&&e[5]==r;return(t&&e[0]>=r*4&&e[6]>=r?1:0)+(t&&e[6]>=r*4&&e[0]>=r?1:0)}finderPenaltyTerminateAndCount(e,r,t){return e&&(this.finderPenaltyAddHistory(r,t),r=0),r+=this.size,this.finderPenaltyAddHistory(r,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,r){r[0]==0&&(e+=this.size),r.pop(),r.unshift(e)}};i.MIN_VERSION=1,i.MAX_VERSION=40,i.PENALTY_N1=3,i.PENALTY_N2=3,i.PENALTY_N3=40,i.PENALTY_N4=10,i.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],i.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],a.QrCode=i;function s(x,e,r){if(e<0||e>31||x>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)r.push(x>>>t&1)}function d(x,e){return(x>>>e&1)!=0}function h(x){if(!x)throw new Error("Assertion error")}const l=class R{constructor(e,r,t){if(this.mode=e,this.numChars=r,this.bitData=t,r<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let r=[];for(const t of e)s(t,8,r);return new R(R.Mode.BYTE,e.length,r)}static makeNumeric(e){if(!R.isNumeric(e))throw new RangeError("String contains non-numeric characters");let r=[];for(let t=0;t<e.length;){const n=Math.min(e.length-t,3);s(parseInt(e.substring(t,t+n),10),n*3+1,r),t+=n}return new R(R.Mode.NUMERIC,e.length,r)}static makeAlphanumeric(e){if(!R.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let r=[],t;for(t=0;t+2<=e.length;t+=2){let n=R.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;n+=R.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),s(n,11,r)}return t<e.length&&s(R.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,r),new R(R.Mode.ALPHANUMERIC,e.length,r)}static makeSegments(e){return e==""?[]:R.isNumeric(e)?[R.makeNumeric(e)]:R.isAlphanumeric(e)?[R.makeAlphanumeric(e)]:[R.makeBytes(R.toUtf8ByteArray(e))]}static makeEci(e){let r=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)s(e,8,r);else if(e<16384)s(2,2,r),s(e,14,r);else if(e<1e6)s(6,3,r),s(e,21,r);else throw new RangeError("ECI assignment value out of range");return new R(R.Mode.ECI,0,r)}static isNumeric(e){return R.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return R.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,r){let t=0;for(const n of e){const o=n.mode.numCharCountBits(r);if(n.numChars>=1<<o)return 1/0;t+=4+o+n.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let r=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?r.push(e.charCodeAt(t)):(r.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return r}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let E=l;a.QrSegment=l})(T||(T={}));(a=>{(i=>{const s=class{constructor(h,l){this.ordinal=h,this.formatBits=l}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),i.Ecc=s})(a.QrCode||(a.QrCode={}))})(T||(T={}));(a=>{(i=>{const s=class{constructor(h,l){this.modeBits=h,this.numBitsCharCount=l}numCharCountBits(h){return this.numBitsCharCount[Math.floor((h+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),i.Mode=s})(a.QrSegment||(a.QrSegment={}))})(T||(T={}));var O=T;/**
|
|
6
|
+
* @license qrcode.react
|
|
7
|
+
* Copyright (c) Paul O'Shannessy
|
|
8
|
+
* SPDX-License-Identifier: ISC
|
|
9
|
+
*/var Ne={L:O.QrCode.Ecc.LOW,M:O.QrCode.Ecc.MEDIUM,Q:O.QrCode.Ecc.QUARTILE,H:O.QrCode.Ecc.HIGH},Z=128,J="L",ee="#FFFFFF",te="#000000",re=!1,se=1,ye=4,Ce=0,Fe=.1;function ne(a,i=0){const s=[];return a.forEach(function(d,h){let l=null;d.forEach(function(E,x){if(!E&&l!==null){s.push(`M${l+i} ${h+i}h${x-l}v1H${l+i}z`),l=null;return}if(x===d.length-1){if(!E)return;l===null?s.push(`M${x+i},${h+i} h1v1H${x+i}z`):s.push(`M${l+i},${h+i} h${x+1-l}v1H${l+i}z`);return}E&&l===null&&(l=x)})}),s.join("")}function oe(a,i){return a.slice().map((s,d)=>d<i.y||d>=i.y+i.h?s:s.map((h,l)=>l<i.x||l>=i.x+i.w?h:!1))}function Re(a,i,s,d){if(d==null)return null;const h=a.length+s*2,l=Math.floor(i*Fe),E=h/i,x=(d.width||l)*E,e=(d.height||l)*E,r=d.x==null?a.length/2-x/2:d.x*E,t=d.y==null?a.length/2-e/2:d.y*E,n=d.opacity==null?1:d.opacity;let o=null;if(d.excavate){let u=Math.floor(r),m=Math.floor(t),g=Math.ceil(x+r-u),C=Math.ceil(e+t-m);o={x:u,y:m,w:g,h:C}}const f=d.crossOrigin;return{x:r,y:t,h:e,w:x,excavation:o,opacity:n,crossOrigin:f}}function Me(a,i){return i!=null?Math.max(Math.floor(i),0):a?ye:Ce}function ie({value:a,level:i,minVersion:s,includeMargin:d,marginSize:h,imageSettings:l,size:E,boostLevel:x}){let e=A.useMemo(()=>{const u=(Array.isArray(a)?a:[a]).reduce((m,g)=>(m.push(...O.QrSegment.makeSegments(g)),m),[]);return O.QrCode.encodeSegments(u,Ne[i],s,void 0,void 0,x)},[a,i,s,x]);const{cells:r,margin:t,numCells:n,calculatedImageSettings:o}=A.useMemo(()=>{let f=e.getModules();const u=Me(d,h),m=f.length+u*2,g=Re(f,E,u,l);return{cells:f,margin:u,numCells:m,calculatedImageSettings:g}},[e,E,l,d,h]);return{qrcode:e,margin:t,cells:r,numCells:n,calculatedImageSettings:o}}var Ae=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Se=A.forwardRef(function(i,s){const d=i,{value:h,size:l=Z,level:E=J,bgColor:x=ee,fgColor:e=te,includeMargin:r=re,minVersion:t=se,boostLevel:n,marginSize:o,imageSettings:f}=d,m=U(d,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=m,C=U(m,["style"]),F=f==null?void 0:f.src,p=A.useRef(null),N=A.useRef(null),S=A.useCallback(L=>{p.current=L,typeof s=="function"?s(L):s&&(s.current=L)},[s]),[w,M]=A.useState(!1),{margin:v,cells:I,numCells:B,calculatedImageSettings:P}=ie({value:h,level:E,minVersion:t,boostLevel:n,includeMargin:r,marginSize:o,imageSettings:f,size:l});A.useEffect(()=>{if(p.current!=null){const L=p.current,j=L.getContext("2d");if(!j)return;let $=I;const k=N.current,K=P!=null&&k!==null&&k.complete&&k.naturalHeight!==0&&k.naturalWidth!==0;K&&P.excavation!=null&&($=oe(I,P.excavation));const q=window.devicePixelRatio||1;L.height=L.width=l*q;const G=l/B*q;j.scale(G,G),j.fillStyle=x,j.fillRect(0,0,B,B),j.fillStyle=e,Ae?j.fill(new Path2D(ne($,v))):I.forEach(function(ce,ue){ce.forEach(function(de,he){de&&j.fillRect(he+v,ue+v,1,1)})}),P&&(j.globalAlpha=P.opacity),K&&j.drawImage(k,P.x+v,P.y+v,P.w,P.h)}}),A.useEffect(()=>{M(!1)},[F]);const le=z({height:l,width:l},g);let H=null;return F!=null&&(H=A.createElement("img",{src:F,key:F,style:{display:"none"},onLoad:()=>{M(!0)},ref:N,crossOrigin:P==null?void 0:P.crossOrigin})),A.createElement(A.Fragment,null,A.createElement("canvas",z({style:le,height:l,width:l,ref:S,role:"img"},C)),H)});Se.displayName="QRCodeCanvas";var Q=A.forwardRef(function(i,s){const d=i,{value:h,size:l=Z,level:E=J,bgColor:x=ee,fgColor:e=te,includeMargin:r=re,minVersion:t=se,boostLevel:n,title:o,marginSize:f,imageSettings:u}=d,m=U(d,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:g,cells:C,numCells:F,calculatedImageSettings:p}=ie({value:h,level:E,minVersion:t,boostLevel:n,includeMargin:r,marginSize:f,imageSettings:u,size:l});let N=C,S=null;u!=null&&p!=null&&(p.excavation!=null&&(N=oe(C,p.excavation)),S=A.createElement("image",{href:u.src,height:p.h,width:p.w,x:p.x+g,y:p.y+g,preserveAspectRatio:"none",opacity:p.opacity,crossOrigin:p.crossOrigin}));const w=ne(N,g);return A.createElement("svg",z({height:l,width:l,viewBox:`0 0 ${F} ${F}`,ref:s,role:"img"},m),!!o&&A.createElement("title",null,o),A.createElement("path",{fill:x,d:`M0,0 h${F}v${F}H0z`,shapeRendering:"crispEdges"}),A.createElement("path",{fill:e,d:w,shapeRendering:"crispEdges"}),S)});Q.displayName="QRCodeSVG";const De=[{id:"feishu",labelKey:"configForm.channel.feishu",fields:[],defaults:{connectionMode:"websocket"}},{id:"openclaw-weixin",labelKey:"configForm.channel.openclaw-weixin",fields:[],defaults:{}},{id:"telegram",labelKey:"configForm.channel.telegram",fields:[{key:"botToken",label:"Bot Token",type:"password",placeholder:"From @BotFather"}]},{id:"discord",labelKey:"configForm.channel.discord",fields:[{key:"token",label:"Bot Token",type:"password",placeholder:"From Discord Developer Portal"}]},{id:"slack",labelKey:"configForm.channel.slack",fields:[{key:"botToken",label:"Bot Token (xoxb-...)",type:"password",placeholder:"xoxb-..."},{key:"appToken",label:"App Token (xapp-...)",type:"password",placeholder:"xapp-..."}]},{id:"whatsapp",labelKey:"configForm.channel.whatsapp",fields:[],defaults:{}},{id:"msteams",labelKey:"configForm.channel.msteams",fields:[{key:"appId",label:"App ID",placeholder:"Azure App Registration ID"},{key:"appPassword",label:"App Password",type:"password",placeholder:"Azure App Secret"},{key:"tenantId",label:"Tenant ID",placeholder:"Azure AD Tenant ID"}]},{id:"signal",labelKey:"configForm.channel.signal",fields:[{key:"account",label:"Phone (E.164)",placeholder:"+8613800138000"}]},{id:"line",labelKey:"configForm.channel.line",fields:[{key:"channelAccessToken",label:"Channel Access Token",type:"password",placeholder:"From LINE Developers"},{key:"channelSecret",label:"Channel Secret",type:"password",placeholder:"LINE Channel Secret"}]},{id:"googlechat",labelKey:"configForm.channel.googlechat",fields:[{key:"serviceAccountFile",label:"Service Account JSON Path",placeholder:"/path/to/service-account.json"}]}];function Be(a,i,s){const d=structuredClone(a),h=i.split(".");let l=d;for(let E=0;E<h.length-1;E++)l[h[E]]===void 0&&(l[h[E]]={}),l=l[h[E]];return l[h[h.length-1]]=s,d}const ae="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200",Pe="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200 appearance-none";function ze({label:a,hint:i,children:s}){return c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:a}),s,i&&c.jsx("p",{className:"text-xs text-muted mt-1 opacity-60",children:i})]})}function Ue({value:a,saved:i,onChange:s,placeholder:d,onPaste:h}){const{t:l}=_("instance"),[E,x]=y.useState(!1),e="••••••••••••••••••••••••••••••";return i&&!E&&!a?c.jsx("div",{className:"relative",children:c.jsx("input",{type:"password",value:e,readOnly:!0,onFocus:()=>x(!0),onPaste:r=>{var n;const t=((n=r.clipboardData)==null?void 0:n.getData("text"))??"";t&&(r.preventDefault(),x(!0),s(t),h==null||h(r))},className:`${ae} cursor-text`,title:l("config.clickToEdit")})}):c.jsx(je,{value:a,onChange:s,onPaste:h,placeholder:d,type:"password",mono:!0})}function je({value:a,onChange:i,placeholder:s,type:d="text",mono:h,onPaste:l}){const[E,x]=y.useState(!1),e=d==="password";return c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:e&&!E?"password":"text",value:a||"",onChange:r=>i(r.target.value),onPaste:l,placeholder:s,className:`${ae} ${h?"font-mono text-[13px]":""} ${e?"pr-9":""}`}),e&&c.jsx("button",{type:"button",onClick:()=>x(!E),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground",children:E?c.jsx(ge,{className:"w-3.5 h-3.5"}):c.jsx(pe,{className:"w-3.5 h-3.5"})})]})}function _e({value:a,onChange:i,children:s}){return c.jsx("select",{value:a||"",onChange:d=>i(d.target.value),className:Pe,children:s})}function Qe({checked:a,onChange:i,label:s}){return c.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer",children:[c.jsx("button",{type:"button",role:"switch","aria-checked":a,onClick:()=>i(!a),className:`w-9 h-5 rounded-full relative transition-colors duration-200 ${a?"bg-[#0066FF]":"bg-[var(--input-bg)]"}`,children:c.jsx("div",{className:`w-3.5 h-3.5 bg-white rounded-full absolute top-[3px] transition-transform duration-200 ${a?"left-[18px]":"left-[3px]"}`})}),c.jsx("span",{className:"text-sm text-muted",children:s})]})}function He({title:a,defaultOpen:i=!0,id:s,children:d}){const[h,l]=y.useState(i);return c.jsxs("div",{id:s,className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden hover:border-[var(--border-hover)] transition-colors duration-200",children:[c.jsxs("button",{type:"button",onClick:()=>l(!h),className:"w-full px-4 py-3 flex items-center justify-between text-left hover:bg-[var(--card-hover)] transition-colors duration-150",children:[c.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),h?c.jsx(fe,{className:"w-4 h-4 text-muted"}):c.jsx(me,{className:"w-4 h-4 text-muted"})]}),h&&c.jsx("div",{className:"px-4 pb-4 space-y-4 border-t border-[var(--border)] pt-4",children:d})]})}function $e({instanceId:a,channelKey:i,existingAppId:s,existingDomain:d,onConfigured:h}){const{t:l}=_(["instance","common"]),[E,x]=y.useState(""),[,e]=y.useState(""),[r,t]=y.useState("idle"),[n,o]=y.useState(""),[f,u]=y.useState(""),m=y.useRef(!1),g=y.useRef(!1),C=y.useRef(0),F=6,p=async()=>{if(a){g.current=!1,t("loading"),o(""),x("");try{let w=null;for(let M=0;M<3;M++){if(g.current)return;try{if(w=await xe(a,i),w!=null&&w.qrcodeUrl)break}catch{M<2&&await new Promise(v=>setTimeout(v,1500))}}if(g.current)return;w!=null&&w.qrcodeUrl?(x(w.qrcodeUrl),e(w.sessionKey),t("waiting"),o(l("configForm.feishu.scanHint")),N(w.sessionKey)):(t("error"),o(l("qr.getFailed")))}catch{g.current||(t("error"),o(l("qr.getFailed")))}}},N=w=>{if(!a||m.current)return;m.current=!0,C.current=0;const M=async()=>{if(m.current)try{const v=await we(a,w);if(C.current=0,v.connected){m.current=!1,t("confirmed"),o(v.message||l("qr.loginSuccess")),u(v.domain||"feishu"),x(""),h==null||h();return}if(v.status==="expired"){m.current=!1,t("error"),o(v.message||l("qr.expired"));return}setTimeout(M,3e3)}catch{if(!m.current)return;if(C.current+=1,C.current>=F){m.current=!1,t("error"),o(l("qr.pollFailed",{defaultValue:"轮询失败,请刷新后重试"}));return}setTimeout(M,3e3)}};M()};if(y.useEffect(()=>()=>{m.current=!1},[]),r==="confirmed")return c.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-3 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[c.jsx("span",{className:"text-lg",children:"✓"}),c.jsx("span",{className:"font-medium",children:n})]}),c.jsx("p",{className:"text-xs text-muted mt-1",children:l("configForm.feishu.platform",{platform:l(f==="lark"?"configForm.feishu.platformLark":"configForm.feishu.platformFeishu")})})]});if(r==="idle"||r==="error")return c.jsxs("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-3 space-y-3",children:[s&&c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-muted mb-1",children:l("configForm.feishu.added")}),c.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[c.jsx("span",{className:"text-emerald-400",children:"✓"}),c.jsx("code",{className:"font-mono text-foreground/70",children:s}),c.jsx("span",{className:"text-muted opacity-60",children:d==="lark"?"Lark":l("configForm.feishu.platformFeishu")})]})]}),c.jsxs("div",{children:[c.jsx("button",{onClick:p,className:"px-4 py-2 bg-[#3370FF] text-white rounded-md text-xs font-medium hover:bg-[#3370FF]/90 transition-colors",children:l("configForm.feishu.addBot")}),c.jsx("p",{className:"text-xs text-muted mt-2",children:l("configForm.feishu.addBotHint")})]})]});const S=()=>{g.current=!0,m.current=!1,t("idle"),o(""),x(""),e("")};return c.jsx("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-4",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[E?c.jsx(Q,{value:E,size:192,className:"rounded-lg"}):c.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:c.jsx("div",{className:"w-6 h-6 border-2 border-[#3370FF]/30 border-t-[#3370FF] rounded-full animate-spin"})}),c.jsx("div",{className:"text-sm text-muted",children:r==="loading"?l("configForm.feishu.gettingQr"):n}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("button",{onClick:S,className:"px-3 py-1.5 text-xs text-white bg-red-500 rounded-md hover:bg-red-500/90 transition-colors",children:l("configForm.feishu.cancel")}),c.jsx("button",{onClick:()=>{S(),setTimeout(p,100)},className:"px-3 py-1.5 text-xs text-white bg-[#0066FF] rounded-md hover:bg-[#0066FF]/90 transition-colors",children:l("configForm.feishu.refresh")})]})]})})}function Ke({instanceId:a,onConfigured:i}){const{t:s,i18n:d}=_(["instance","common"]),[h,l]=y.useState(""),[,E]=y.useState(""),[x,e]=y.useState("idle"),[r,t]=y.useState(""),[n,o]=y.useState(""),[f,u]=y.useState([]),m=y.useRef(!1),g=y.useRef(!1),C=y.useRef(0),F=6;y.useEffect(()=>{a&&Y(a).then(w=>{var M;(M=w==null?void 0:w.accounts)!=null&&M.length&&u(w.accounts)}).catch(()=>{})},[a]);const p=async()=>{if(a){g.current=!1,e("loading"),t(""),l("");try{let w=null;for(let M=0;M<3;M++){if(g.current)return;try{if(w=await be(a),w!=null&&w.qrcodeUrl)break}catch{M<2&&await new Promise(v=>setTimeout(v,1500))}}if(g.current)return;w!=null&&w.qrcodeUrl?(l(w.qrcodeUrl),E(w.sessionKey),e("waiting"),t(s("configForm.weixin.scanHint")),N(w.sessionKey)):(e("error"),t(s("qr.getFailed")))}catch{g.current||(e("error"),t(s("qr.getFailed")))}}},N=w=>{if(!a||m.current)return;m.current=!0,C.current=0;const M=async()=>{if(m.current)try{const v=await Ee(a,w);if(C.current=0,v.connected){m.current=!1,e("confirmed"),t(v.message||s("qr.loginSuccess")),o(v.accountId||""),l(""),a&&Y(a).then(I=>{I!=null&&I.accounts&&u(I.accounts)}).catch(()=>{}),i==null||i();return}if(v.status==="scaned")e("scaned"),t(v.message||s("qr.scaned"));else if(v.status==="refreshed"&&v.qrcodeUrl)l(v.qrcodeUrl),e("waiting"),t(s("qr.refreshed"));else if(v.status==="expired"){m.current=!1,e("error"),t(v.message||s("qr.expired"));return}setTimeout(M,2e3)}catch{if(!m.current)return;if(C.current+=1,C.current>=F){m.current=!1,e("error"),t(s("qr.pollFailed",{defaultValue:"轮询失败,请刷新后重试"}));return}setTimeout(M,3e3)}};M()};if(y.useEffect(()=>()=>{m.current=!1},[]),x==="confirmed")return c.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-3 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[c.jsx("span",{className:"text-lg",children:"✓"}),c.jsx("span",{className:"font-medium",children:r})]}),n&&c.jsxs("p",{className:"text-xs text-muted mt-1",children:[s("configForm.weixin.accountId")," ",c.jsx("code",{className:"font-mono",children:n})]}),c.jsx("p",{className:"text-xs text-muted mt-1",children:s("configForm.weixin.restartHint")}),c.jsx("button",{onClick:p,className:"mt-2 px-3 py-1 text-xs border border-emerald-500/30 rounded text-emerald-400 hover:bg-emerald-500/10 transition-colors",children:s("configForm.weixin.addAnother")})]});if(x==="idle"||x==="error")return c.jsxs("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-3 space-y-3",children:[f.length>0&&c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-muted mb-1.5",children:s("configForm.weixin.added")}),f.map(w=>c.jsxs("div",{className:"flex items-center gap-2 text-xs py-1",children:[c.jsx("span",{className:"text-emerald-400",children:"✓"}),c.jsx("code",{className:"font-mono text-foreground/70",children:w.accountId}),w.savedAt&&c.jsx("span",{className:"text-muted opacity-60",children:new Date(w.savedAt).toLocaleDateString(d.language==="zh"?"zh-CN":"en-US")})]},w.accountId))]}),c.jsxs("div",{children:[c.jsx("button",{onClick:p,className:"px-4 py-2 bg-[#07C160] text-white rounded-md text-xs font-medium hover:bg-[#07C160]/90 transition-colors",children:s("configForm.weixin.addClawBot")}),c.jsx("p",{className:"text-xs text-muted mt-2",children:s("configForm.weixin.addClawBotHint",{extra:f.length>0?s("configForm.weixin.addClawBotHintRestart"):s("configForm.weixin.addClawBotHintMulti")})})]})]});const S=()=>{g.current=!0,m.current=!1,e("idle"),t(""),l(""),E("")};return c.jsx("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-4",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[h?c.jsx(Q,{value:h,size:192,className:"rounded-lg"}):c.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:c.jsx("div",{className:"w-6 h-6 border-2 border-[#07C160]/30 border-t-[#07C160] rounded-full animate-spin"})}),c.jsx("div",{className:"flex items-center gap-2 text-sm",children:x==="scaned"?c.jsxs("span",{className:"text-[#07C160] font-medium",children:["👀 ",r]}):x==="loading"?c.jsx("span",{className:"text-muted",children:s("configForm.weixin.gettingQr")}):c.jsx("span",{className:"text-muted",children:r})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("button",{onClick:S,className:"px-3 py-1.5 text-xs text-white bg-red-500 rounded-md hover:bg-red-500/90 transition-colors",children:s("configForm.weixin.cancel")}),c.jsx("button",{onClick:()=>{S(),setTimeout(p,100)},className:"px-3 py-1.5 text-xs text-white bg-[#0066FF] rounded-md hover:bg-[#0066FF]/90 transition-colors",children:s("configForm.weixin.refresh")})]})]})})}export{De as C,ze as F,je as I,Q,He as S,Qe as T,Ke as W,_e as a,Ue as b,$e as c,Be as d};
|