@undefineds.co/xpod 0.3.70 → 0.3.71-rc.13
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/config/cloud.json +3 -0
- package/config/local.json +3 -0
- package/config/resolver.json +7 -0
- package/config/xpod.base.json +20 -0
- package/dist/agents/ClaudeExecutor.js +1 -1
- package/dist/agents/ClaudeExecutor.js.map +1 -1
- package/dist/agents/types.d.ts +5 -5
- package/dist/agents/types.js.map +1 -1
- package/dist/api/ai-gateway/AiGatewayService.d.ts +5 -16
- package/dist/api/ai-gateway/AiGatewayService.js +13 -35
- package/dist/api/ai-gateway/AiGatewayService.js.map +1 -1
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.d.ts +3 -2
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js +37 -12
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js.map +1 -1
- package/dist/api/ai-gateway/auth/GatewayPrincipal.d.ts +2 -16
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js +3 -33
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js.map +1 -1
- package/dist/api/ai-gateway/auth/InvocationTokenAuthenticator.d.ts +23 -0
- package/dist/api/ai-gateway/auth/InvocationTokenAuthenticator.js +81 -0
- package/dist/api/ai-gateway/auth/InvocationTokenAuthenticator.js.map +1 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.d.ts +7 -4
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js.map +1 -1
- package/dist/api/ai-gateway/connect/index.d.ts +7 -26
- package/dist/api/ai-gateway/connect/index.js +40 -67
- package/dist/api/ai-gateway/connect/index.js.map +1 -1
- package/dist/api/ai-gateway/credentials/PlaintextCredentialPayload.d.ts +17 -0
- package/dist/api/ai-gateway/credentials/PlaintextCredentialPayload.js +65 -0
- package/dist/api/ai-gateway/credentials/PlaintextCredentialPayload.js.map +1 -0
- package/dist/api/ai-gateway/pod/HostedPodDataAccess.d.ts +24 -0
- package/dist/api/ai-gateway/pod/HostedPodDataAccess.js +149 -0
- package/dist/api/ai-gateway/pod/HostedPodDataAccess.js.map +1 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.d.ts +13 -5
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +16 -19
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js.map +1 -1
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.d.ts +1 -1
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js +0 -2
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js.map +1 -1
- package/dist/api/auth/AuthContext.d.ts +1 -12
- package/dist/api/auth/AuthContext.js +0 -11
- package/dist/api/auth/AuthContext.js.map +1 -1
- package/dist/api/auth/ClientCredentialsAuthenticator.js +4 -11
- package/dist/api/auth/ClientCredentialsAuthenticator.js.map +1 -1
- package/dist/api/chatkit/default-agent.d.ts +2 -2
- package/dist/api/chatkit/default-agent.js +4 -4
- package/dist/api/chatkit/default-agent.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js +1 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -1
- package/dist/api/container/common.js +28 -69
- package/dist/api/container/common.js.map +1 -1
- package/dist/api/container/index.js +5 -6
- package/dist/api/container/index.js.map +1 -1
- package/dist/api/container/routes.js +2 -5
- package/dist/api/container/routes.js.map +1 -1
- package/dist/api/container/types.d.ts +8 -10
- package/dist/api/container/types.js.map +1 -1
- package/dist/api/handlers/AiClientConfigurationHandler.js +3 -3
- package/dist/api/handlers/AiClientConfigurationHandler.js.map +1 -1
- package/dist/api/handlers/AiGatewayHandler.js +2 -2
- package/dist/api/handlers/AiGatewayHandler.js.map +1 -1
- package/dist/api/handlers/AiGatewayManagementHandler.d.ts +2 -10
- package/dist/api/handlers/AiGatewayManagementHandler.js +4 -154
- package/dist/api/handlers/AiGatewayManagementHandler.js.map +1 -1
- package/dist/api/handlers/NetworkSettingsHandler.js +0 -3
- package/dist/api/handlers/NetworkSettingsHandler.js.map +1 -1
- package/dist/api/handlers/PodSettingsHandler.d.ts +5 -2
- package/dist/api/handlers/PodSettingsHandler.js +3 -3
- package/dist/api/handlers/PodSettingsHandler.js.map +1 -1
- package/dist/api/runs/AgentRuntimeTypes.d.ts +3 -3
- package/dist/api/runs/AgentRuntimeTypes.js +10 -10
- package/dist/api/runs/AgentRuntimeTypes.js.map +1 -1
- package/dist/api/runs/InngestRunExecutionBackend.d.ts +15 -9
- package/dist/api/runs/InngestRunExecutionBackend.js +25 -10
- package/dist/api/runs/InngestRunExecutionBackend.js.map +1 -1
- package/dist/api/runs/PiAgentRuntimeDriver.js +2 -2
- package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
- package/dist/api/runs/RunStateCenter.js +1 -1
- package/dist/api/runs/RunStateCenter.js.map +1 -1
- package/dist/api/service/AiClientConfigurationService.d.ts +2 -2
- package/dist/api/service/AiClientConfigurationService.js +11 -11
- package/dist/api/service/AiClientConfigurationService.js.map +1 -1
- package/dist/api/tasks/InngestTaskScheduler.d.ts +16 -10
- package/dist/api/tasks/InngestTaskScheduler.js +24 -12
- package/dist/api/tasks/InngestTaskScheduler.js.map +1 -1
- package/dist/cli/commands/start.js +7 -7
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/components/components.jsonld +1 -0
- package/dist/components/context.jsonld +36 -0
- package/dist/http/InternalPodDataHttpHandler.d.ts +32 -0
- package/dist/http/InternalPodDataHttpHandler.js +258 -0
- package/dist/http/InternalPodDataHttpHandler.js.map +1 -0
- package/dist/http/InternalPodDataHttpHandler.jsonld +201 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/main.js +13 -13
- package/dist/main.js.map +1 -1
- package/dist/runtime/GatewayAdminProxyAuth.d.ts +15 -1
- package/dist/runtime/GatewayAdminProxyAuth.js +57 -2
- package/dist/runtime/GatewayAdminProxyAuth.js.map +1 -1
- package/dist/runtime/bootstrap.js +3 -0
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/css-process.d.ts +1 -1
- package/dist/runtime/css-process.js +4 -1
- package/dist/runtime/css-process.js.map +1 -1
- package/dist/runtime/runner/node/CommunitySolidServerCssRunner.d.ts +2 -0
- package/dist/runtime/runner/node/CommunitySolidServerCssRunner.js +50 -0
- package/dist/runtime/runner/node/CommunitySolidServerCssRunner.js.map +1 -1
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.d.ts +5 -5
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.js +7 -7
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.js +1 -1
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.d.ts +3 -1
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.js +74 -60
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.d.ts +0 -21
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.js +0 -41
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.js +7 -2
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.js +3 -3
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.cjs +15 -9
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.js +4 -4
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.js +3 -3
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connection/dist/controller.d.ts +2 -1
- package/node_modules/@undefineds.co/ai-connection/dist/controller.js +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.js +0 -1
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +22 -1
- package/package.json +3 -3
- package/static/app/assets/main.js +7 -7
- package/static/dashboard/assets/NetworkPage-CXjiUMR1.js +2 -0
- package/static/dashboard/assets/{PaneListHeader-57nvMwH6.js → PaneListHeader-BSipfl0W.js} +1 -1
- package/static/dashboard/assets/PodPage-Bd3Xhmp-.js +2 -0
- package/static/dashboard/assets/ServicesPage-CI3jWZGe.js +1 -0
- package/static/dashboard/assets/{card-B9Zjf_2p.js → card-z5BV5hTo.js} +1 -1
- package/static/dashboard/assets/{dashboard-8C6o666W.js → dashboard-CSrqAv2L.js} +2 -2
- package/static/dashboard/assets/{database-DPh9wDY9.js → database-Ct5ZPe6L.js} +1 -1
- package/static/dashboard/assets/{external-link-VbMQvVMz.js → external-link-B7wD1hkm.js} +1 -1
- package/static/dashboard/assets/index-tOBaUnM1.js +44 -0
- package/static/dashboard/assets/{refresh-cw-BxVxNxNr.js → refresh-cw-CFDZPaE8.js} +1 -1
- package/static/dashboard/assets/{services-status-context-DKmJ7ISr.js → services-status-context-DN1Icg4A.js} +1 -1
- package/static/dashboard/dashboard.html +1 -1
- package/static/settings/assets/ModelsPage-03NPWzoX.js +1 -0
- package/static/settings/assets/{PaneListHeader-Bgaze006.js → PaneListHeader-DMD8OJef.js} +1 -1
- package/static/settings/assets/PodPage-DT4EMYhL.js +2 -0
- package/static/settings/assets/ServicesPage-CJ0ub6IH.js +1 -0
- package/static/settings/assets/SettingsPage-BkR7ZK18.js +41 -0
- package/static/settings/assets/{card-B_bXSIn-.js → card-Cjsia0_V.js} +1 -1
- package/static/settings/assets/{services-status-context-DiX-AbrP.js → services-status-context-CkuKmH5h.js} +1 -1
- package/static/settings/assets/{settings-B30oMfZq.js → settings-Cyyv6-SD.js} +2 -2
- package/static/settings/assets/{workspace-layout-Dv1Yn9Ci.js → workspace-layout-B47luv6r.js} +1 -1
- package/static/settings/settings.html +1 -1
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.d.ts +0 -25
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js +0 -91
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js.map +0 -1
- package/dist/api/ai-gateway/auth/GatewayApiKey.d.ts +0 -28
- package/dist/api/ai-gateway/auth/GatewayApiKey.js +0 -162
- package/dist/api/ai-gateway/auth/GatewayApiKey.js.map +0 -1
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +0 -56
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +0 -143
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js.map +0 -1
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.d.ts +0 -26
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js +0 -97
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js.map +0 -1
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +0 -54
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +0 -152
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js.map +0 -1
- package/static/dashboard/assets/NetworkPage-Brt79fuQ.js +0 -2
- package/static/dashboard/assets/PodPage-CM6do1vB.js +0 -2
- package/static/dashboard/assets/ServicesPage-BUNxGJRz.js +0 -1
- package/static/dashboard/assets/index-RfiFckzb.js +0 -51
- package/static/settings/assets/ModelsPage-D_IH7AH3.js +0 -1
- package/static/settings/assets/PodPage-Cy1VNObw.js +0 -2
- package/static/settings/assets/ServicesPage-BsFaxVWC.js +0 -1
- package/static/settings/assets/SettingsPage-UafNWE_p.js +0 -48
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./dashboard-
|
|
1
|
+
import{c as e}from"./dashboard-CSrqAv2L.js";const c=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],a=e("refresh-cw",c);export{a as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i}from"./dashboard-
|
|
1
|
+
import{r as i}from"./dashboard-CSrqAv2L.js";const n="/api/admin";async function l(t={}){try{const e=await fetch(`${n}/status`,{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get admin status:",e)}return null}async function u(t={}){try{const e=await fetch(`${n}/config`,{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get admin config:",e)}return null}async function h(t,e={}){try{const a=t?"?baseUrl="+encodeURIComponent(t):"",r=await fetch(n+"/public-ip"+a,{signal:e.signal});if(r.ok)return await r.json()}catch(a){console.error("Failed to get public ip check:",a)}return null}async function $(t){try{return(await fetch(`${n}/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t})})).ok}catch(e){return console.error("Failed to update admin config:",e),!1}}async function k(){try{return(await fetch(`${n}/restart`,{method:"POST"})).ok}catch(t){return console.error("Failed to trigger restart:",t),!1}}async function g(t={}){try{const e=await fetch("/service/status",{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get gateway status:",e)}return null}async function v(t={}){try{const a=S(t).toString(),r=await fetch(`${n}/rdf/stats${a?`?${a}`:""}`);if(r.ok)return await r.json()}catch(e){console.error("Failed to get RDF stats:",e)}return null}function S(t){const e=new URLSearchParams;return c(e,"cacheScopeQuery",t.cacheScopeQuery),c(e,"cacheScopePrincipal",t.cacheScopePrincipal),c(e,"cacheScopeBasePath",t.cacheScopeBasePath),c(e,"cacheScopeMode",t.cacheScopeMode),c(e,"cacheScopeAuthorizationModel",t.cacheScopeAuthorizationModel),c(e,"cacheScopePermissionVersion",t.cacheScopePermissionVersion),c(e,"cacheScopeLimit",t.cacheScopeLimit),e}function c(t,e,a){a!==void 0&&a!==""&&t.set(e,String(a))}async function d(t){try{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&t.level!=="all"&&e.set("level",t.level),t?.source&&t.source!=="all"&&e.set("source",t.source);const a=e.toString(),r=await fetch(`${n}/logs${a?`?${a}`:""}`);if(r.ok){const s=await r.json();return Array.isArray(s)?s:s.logs??[]}}catch(e){console.error("Failed to get logs:",e)}return[]}async function m(t){try{const e=new URLSearchParams;t?.lines&&e.set("lines",t.lines.toString());const a=e.toString(),r=await fetch(`${n}/logs/file${a?`?${a}`:""}`);if(r.ok)return await r.json()}catch(e){console.error("Failed to get log file tail:",e)}return null}async function A(){const[t,e,a,r,s,o]=await Promise.all([g(),l(),u(),f(),d({limit:200}),m({lines:120})]);return{generatedAt:new Date().toISOString(),gatewayStatus:t,adminStatus:e,sanitizedConfig:{env:a?.env??{},secrets:a?.secrets??{}},ddnsStatus:r,recentLogs:s,logFile:o}}function F(t,e){const a=new EventSource(`${n}/logs/stream`);return a.onmessage=r=>{try{const s=JSON.parse(r.data);s.logs&&t(s.logs)}catch(s){console.error("Failed to parse log data:",s)}},a.onerror=r=>{console.error("Log stream error:",r),e?.(r)},()=>{a.close()}}function y(t){return t?t.startsWith("http://")||t.startsWith("https://")?t:`https://${t}/`:""}function w(t,e,a=""){return e?.baseUrl||y(e?.fqdn)||t.CSS_BASE_URL||a}async function f(t={}){try{const e=await fetch(`${n}/ddns`,{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get ddns status:",e)}return null}async function b(t={}){const[e,a,r,s]=await Promise.all([g(t),l(t),u(t),f(t)]),o=await h(w(r?.env??{},s),t);return{servicesData:e,adminData:a,configData:r,ddnsData:s,publicCheck:o,checkedAt:new Date}}const p=i.createContext(null);function C(){return i.useContext(p)}export{p as S,d as a,A as b,m as c,f as d,u as e,b as f,v as g,h,$ as i,w as r,F as s,k as t,C as u};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Xpod Dashboard</title>
|
|
7
|
-
<script type="module" crossorigin src="/dashboard/assets/dashboard-
|
|
7
|
+
<script type="module" crossorigin src="/dashboard/assets/dashboard-CSrqAv2L.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/dashboard/assets/dashboard-CSdewNeA.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as n,c as Be,B as S,I as X,e as mt}from"./settings-Cyyv6-SD.js";import{C as _e,a as De,b as Le,c as Re,d as Ue,B as Te}from"./card-Cjsia0_V.js";import{T as ht}from"./workspace-layout-B47luv6r.js";function yt(e){if(!Me(e))throw new Error("Applet layout descriptor must be an object");if(typeof e.type!="string")throw new Error("Applet layout descriptor type must be a string");switch(e.type){case"single-pane":case"two-pane":return ge(e.context),e;case"three-pane":return ge(e.context),e;default:throw new Error(`Unsupported applet layout type: ${e.type}`)}}function Me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ge(e){if(e!==void 0){if(!Me(e))throw new Error("Applet layout descriptor context must be an object");if("collapsible"in e&&typeof e.collapsible!="boolean")throw new Error("Applet layout descriptor context.collapsible must be a boolean");if("initiallyCollapsed"in e&&typeof e.initiallyCollapsed!="boolean")throw new Error("Applet layout descriptor context.initiallyCollapsed must be a boolean")}}const wt=yt;function xt(e,t){return gt(e,t)}function gt(e,t){const r=At(e),s=e.createController(t);return r.type==="single-pane"?{layout:"single-pane",controller:s,element:p.createElement(r.render,{controller:s,host:t})}:r.type==="two-pane"?{layout:"two-pane",controller:s,slots:{listHeader:p.createElement(r.slots.listHeader,{controller:s,host:t}),list:p.createElement(r.slots.list,{controller:s,host:t}),mainHeader:p.createElement(r.slots.mainHeader,{controller:s,host:t}),main:p.createElement(r.slots.main,{controller:s,host:t})}}:{layout:"three-pane",controller:s,contextConfig:r.contextConfig,slots:{listHeader:p.createElement(r.slots.listHeader,{controller:s,host:t}),list:p.createElement(r.slots.list,{controller:s,host:t}),mainHeader:p.createElement(r.slots.mainHeader,{controller:s,host:t}),main:p.createElement(r.slots.main,{controller:s,host:t}),context:p.createElement(r.slots.context,{controller:s,host:t})}}}function At(e){if("layout"in e){const t=jt(e.layout),r=wt(t.descriptor),s=r.type;if(e.manifest.layout!==s)throw new Error(`Applet manifest layout ${e.manifest.layout} does not match descriptor layout ${s}`);if(s==="single-pane"){if(!("render"in t))throw new Error("Applet descriptor single-pane render must be a function");return D(t.render,"Applet descriptor single-pane render"),{type:"single-pane",render:t.render}}if(!("slots"in t))throw new Error(`Applet descriptor declares ${s} but no slots were provided`);return s==="two-pane"?(ne(t.slots,"Applet descriptor two-pane"),{type:"two-pane",slots:t.slots}):(Ct(t.slots,"Applet descriptor three-pane"),{type:"three-pane",contextConfig:r.context,slots:t.slots})}if(e.manifest.layout==="single-pane"){if(!("render"in e))throw new Error("Applet manifest declares single-pane but no single-pane renderer was provided");return D(e.render,"Applet single-pane render"),{type:"single-pane",render:e.render}}if(e.manifest.layout==="two-pane"&&"slots"in e)return ne(e.slots,"Applet two-pane"),{type:"two-pane",slots:e.slots};throw new Error(`Applet manifest declares ${e.manifest.layout} but no supported applet layout was provided`)}function ne(e,t){bt(e,t),D(e.listHeader,`${t} slot listHeader`),D(e.list,`${t} slot list`),D(e.mainHeader,`${t} slot mainHeader`),D(e.main,`${t} slot main`)}function Ct(e,t){ne(e,t),D(e.context,`${t} slot context`)}function bt(e,t){if(typeof e!="object"||e===null)throw new Error(`${t} slots must be an object`)}function D(e,t){if(typeof e!="function")throw new Error(`${t} must be a function`)}function jt(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("Applet descriptor layout must be an object");if(!("descriptor"in e)||e.descriptor===void 0)throw new Error("Applet descriptor required");return e}const Et=p.createContext(null);function vt(e){return n.jsx("nav",{className:Be("space-y-1 p-3",e.className),...e})}function St({selected:e,className:t,onClick:r,...s}){const a=p.useContext(Et);return n.jsx("button",{type:"button","aria-current":e?"page":void 0,className:Be("flex w-full items-center rounded-md px-3 py-2 text-left text-sm hover:bg-accent aria-[current=page]:bg-accent aria-[current=page]:font-medium",t),onClick:o=>{r?.(o),a?.showMain()},...s})}const ie=["openai","anthropic","kimi","bailian","deepseek"],Oe="AI Connection request failed. Please try again.";function oe(e){const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")throw new Error("Current Pod URL must use HTTP or HTTPS");return t.origin}function Nt({webId:e,podBaseUrl:t,authenticatedFetch:r}){const s=oe(t),a=async(d,f,g,y={})=>{const b=await r(`${s}${d}`,{method:f,credentials:"omit",mode:"cors",headers:{accept:"application/json",...g?{"content-type":"application/json"}:{}},...g?{body:JSON.stringify(g)}:{}}),E=await Pt(b);if(!b.ok)throw new Error(It(E,b.status,y));return E},o=d=>(ce(d),`/api/ai/gateway/providers/${d}`),c=async(d,f,g,y)=>{const b=await a(`${o(d)}${f}`,g,y,{provider:d});return Lt(b,d)};return{webId:e,apiBase:s,getServiceAccess(){return a("/api/applets/service-access/ai-connection","GET")},async listProviders(){const d=await a("/api/ai/connections/providers","GET");return Array.isArray(d.data)?d.data.map(_t).filter(be):[]},async listModels(){const d=await a("/v1/models","GET");return Array.isArray(d.data)?d.data.map(Ft).filter(be):[]},async beginConnect(d,f){return await c(d,"/connect/begin","POST",{mode:f})},connectStatus(d,f){if(!f.attemptId)throw new Error("Connect attempt id is required");const g=new URLSearchParams({state:f.state??"",signature:f.signature??""});return c(d,`/connect/status/${encodeURIComponent(f.attemptId)}?${g}`,"GET")},completeApiKey(d,f,g,y){return c(d,"/connect/complete-api-key","POST",L({attemptId:f.attemptId,state:f.state,signature:f.signature,apiKey:g,accountLabel:y}))},pollDevice(d,f){return c(d,"/connect/poll","POST",L({attemptId:f.attemptId,state:f.state,signature:f.signature}))},async disconnect(d){const f=await a(`${o(d)}/connect`,"DELETE");return Dt(f.record)},quota(d,f=!1){return a(`${o(d)}/quota/${f?"refresh":"status"}`,f?"POST":"GET",f?{}:void 0,{provider:d})}}}function ae(e){return e instanceof Error?Ae(e.message):Ae(String(e))}function It(e,t,r={}){const s=kt(e),a=s?Q(s,r.provider):void 0;if(a)return a;const o=R(e)&&typeof e.error=="string"?e.error:void 0;if(o){const c=Q(o,r.provider);if(c)return c;if(o==="AI Connection service identity is unavailable")return o}return t===401?"Please sign in again to continue.":t===403?"AI Connection permission was denied.":t===404&&r.provider?`${re(r.provider)} connection is not configured.`:t===429?"AI Connection is rate limited. Please try again later.":t===503?"AI Connection service is unavailable.":Oe}function Ae(e){const t=Q(e);if(t)return t;const r=e.split(":",1)[0]?.trim(),s=r?Q(r):void 0;return s||(e==="AI Connection service identity is unavailable"?e:e.startsWith("invalid_")?"AI Connection returned an invalid response.":Oe)}function kt(e){if(R(e)){if(typeof e.code=="string")return e.code;if(typeof e.errorCode=="string")return e.errorCode;if(typeof e.error=="string"&&/^[a-z][a-z0-9_:-]{0,80}$/i.test(e.error))return e.error}}function Q(e,t){switch(e.trim().toLowerCase().replace(/-/g,"_")){case"not_configured":case"notconfigured":return t?`${re(t)} connection is not configured.`:"AI provider connection is not configured.";case"unsupported":return t?`${re(t)} does not support this operation.`:"This AI Connection operation is not supported.";case"service_identity_unavailable":return"AI Connection service identity is unavailable";case"unauthorized":return"Please sign in again to continue.";case"forbidden":case"permission_denied":return"AI Connection permission was denied.";case"rate_limited":return"AI Connection is rate limited. Please try again later.";case"service_unavailable":return"AI Connection service is unavailable.";default:return}}function re(e){switch(e){case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"kimi":return"Kimi";case"bailian":return"Bailian";case"deepseek":return"DeepSeek"}}async function Pt(e){const t=await e.text();if(t)try{return JSON.parse(t)}catch{throw new Error(`AI Connection returned invalid JSON (${e.status})`)}}function ce(e){if(!ie.includes(e))throw new Error(`Unsupported AI provider: ${e}`)}function Ft(e){if(!R(e)||typeof e.id!="string"||$t(e.id))return;const t=V(e.provider)??V(e.providerId)??V(e.owned_by)??Bt(e.id);if(t)return L({id:e.id,provider:t,displayName:I(e.displayName)??I(e.name),contextWindow:Ce(e.contextWindow)??Ce(e.context_window),protocols:Array.isArray(e.protocols)?e.protocols.filter(r=>typeof r=="string"):void 0})}function $t(e){const t=e.toLowerCase();return t==="linx"||t==="linx-lite"||t==="undefineds/linx"||t==="undefineds/linx-lite"}function V(e){if(typeof e!="string")return;const t=e.toLowerCase();return t==="alibaba"||t==="dashscope"?"bailian":ie.includes(t)?t:void 0}function Bt(e){const t=e.split("/",1)[0];return e.includes("/")?V(t):void 0}function Ce(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function _t(e){if(!(!R(e)||typeof e.provider!="string"||!Ut(e.status)||!R(e.connect)||!Array.isArray(e.connect.modes)||!e.connect.modes.every(Ke)||typeof e.connect.configured!="boolean"))return ce(e.provider),L({provider:e.provider,status:e.status,authMode:I(e.authMode),accountLabel:I(e.accountLabel),expiresAt:I(e.expiresAt),reauthRequired:typeof e.reauthRequired=="boolean"?e.reauthRequired:void 0,credentialIri:I(e.credentialIri),version:typeof e.version=="number"?e.version:void 0,connect:L({modes:[...e.connect.modes],configured:e.connect.configured,message:I(e.connect.message)})})}function Dt(e){if(!(!R(e)||typeof e.id!="string"||typeof e.credentialIri!="string"||typeof e.webId!="string"||typeof e.provider!="string"||typeof e.authMode!="string"||typeof e.status!="string"))return ce(e.provider),L({id:e.id,credentialIri:e.credentialIri,webId:e.webId,provider:e.provider,authMode:e.authMode,status:e.status,accountLabel:I(e.accountLabel),expiresAt:I(e.expiresAt),version:typeof e.version=="number"?e.version:void 0,reauthRequired:typeof e.reauthRequired=="boolean"?e.reauthRequired:void 0})}function Lt(e,t){if(!R(e)||!Ke(e.mode)||!Rt(e.status)||e.provider!==t)throw new Error("AI Connection returned an invalid Connect response");return L({mode:e.mode,status:e.status,provider:t,attemptId:I(e.attemptId),state:I(e.state),signature:I(e.signature),expiresAt:I(e.expiresAt),authorizationUrl:Z(e.authorizationUrl),userCode:I(e.userCode),verificationUri:Z(e.verificationUri),verificationUriComplete:Z(e.verificationUriComplete),intervalSeconds:typeof e.intervalSeconds=="number"?e.intervalSeconds:void 0,apiKeyManagementSupported:typeof e.apiKeyManagementSupported=="boolean"?e.apiKeyManagementSupported:void 0,credentialId:I(e.credentialId),message:I(e.message)})}function L(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function I(e){return typeof e=="string"?e:void 0}function Z(e){if(typeof e=="string")try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:void 0}catch{return}}function Ke(e){return e==="browserAssistedApiKey"||e==="deviceCodeOAuth"||e==="connectUnsupported"}function Rt(e){return e==="pending"||e==="authorization_pending"||e==="slow_down"||e==="completed"||e==="expired"||e==="cancelled"||e==="unsupported"}function Ut(e){return e==="connected"||e==="disconnected"||e==="reauthRequired"}function R(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function be(e){return e!==void 0}const je="co.undefineds.ai-connection",Tt=new Set(["providerCredentials","providerDefinitions","quotaSnapshots"]);function Ee(e,t){if(!J(e))throw new Error("invalid_descriptor");if(e.appletId!==je)throw new Error("invalid_applet_id");const r=e.service;if(!J(r)||typeof r.webId!="string"||typeof r.label!="string"||!Vt(r.webId))throw new Error("invalid_service");if(!Array.isArray(e.resources)||e.resources.length===0)throw new Error("invalid_empty_resources");const s=zt(t),a=new Set,o=e.resources.map(c=>Mt(c,s,a));return{appletId:je,service:{webId:r.webId,label:r.label},resources:o}}function Mt(e,t,r){if(!J(e)||typeof e.id!="string"||typeof e.url!="string"||e.mediaType!=="text/turtle"||!J(e.access))throw new Error("invalid_resource");if(!Tt.has(e.id)||r.has(e.id))throw new Error("invalid_resource");Ot(e.url);let s;try{s=new URL(e.url)}catch{throw new Error("invalid_resource")}if(!qt(s,t))throw new Error("invalid_resource");return r.add(e.id),{id:e.id,url:s.href,mediaType:"text/turtle",access:Ht(e.access)}}function Ot(e){if(/%(?![0-9a-fA-F]{2})/.test(e)||/%(?:2f|5c)/i.test(e)||e.includes("\\"))throw new Error("invalid_resource");const t=Kt(e);if(ve(t))throw new Error("invalid_resource");try{const r=decodeURIComponent(t);if(r.includes("\\")||ve(r))throw new Error("invalid_resource")}catch{throw new Error("invalid_resource")}}function Kt(e){const t=e.split("#",1)[0]??e;return(t.split("?",1)[0]??t).replace(/^[a-z][a-z0-9+.-]*:\/\/[^/\\?#]*/i,"")}function ve(e){return e.split("/").some(t=>t==="."||t==="..")}function Ht(e){if(Object.keys(e).some(r=>r!=="read"&&r!=="append"&&r!=="write")||e.read!==!0||e.append!==!0||e.write!==!0)throw new Error("invalid_resource");return{read:!0,append:!0,write:!0}}function zt(e){const t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("invalid_current_pod");return t.pathname.endsWith("/")||(t.pathname=`${t.pathname}/`),t}function qt(e,t){return(e.protocol==="http:"||e.protocol==="https:")&&e.origin===t.origin&&e.pathname.startsWith(t.pathname)}function Vt(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function J(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const _=[{id:"openai",name:"OpenAI",browserMode:"browserAssistedApiKey",browserLabel:"打开官方控制台"},{id:"anthropic",name:"Anthropic",browserMode:"browserAssistedApiKey",browserLabel:"打开官方控制台"},{id:"kimi",name:"Kimi",browserMode:"deviceCodeOAuth",browserLabel:"浏览器鉴权"},{id:"bailian",name:"百炼",browserMode:"browserAssistedApiKey",browserLabel:"打开官方控制台"},{id:"deepseek",name:"DeepSeek",browserMode:"connectUnsupported",browserLabel:"浏览器鉴权不支持"}];if(_.map(e=>e.id).join(",")!==ie.join(","))throw new Error("AI Connection provider UI is out of sync with the client catalog");function Qt(e){const t=e.solid.session.getSnapshot(),r=Jt(t),s=e.solid.pod,o=t.status==="authenticated"&&s.status==="ready"?Nt({webId:t.webId,podBaseUrl:s.current.podUrl,authenticatedFetch:e.solid.session.fetch}):null;let c="openai",d="",f={},g={},y,b=0,E,v=o?"checking":"missing",l;const A=new Set,h=()=>A.forEach(m=>m()),j={client:o,sessionStatus:r,podStatus:s.status,error:s.status==="error"?s.error:t.status==="error"&&!t.webId?t.error:void 0,login:e.solid.requireLogin,openExternal:e.navigation.openExternal,clientConfigurationBridge:e.capabilities.aiClientConfiguration,clientCredentialManager:e.capabilities.aiClientCredentials,get selectedProvider(){return c},get searchQuery(){return d},get providerStates(){return f},get providerSummaries(){return g},get providerLoadError(){return y},get serviceAccessState(){return v},selectProvider(m){c!==m&&(c=m,h())},selectFirstUnconfiguredProvider(){const m=_.find(w=>f[w.id]==="unconfigured")??_[0];m&&j.selectProvider(m.id)},setSearchQuery(m){d!==m&&(d=m,h())},setProviderState(m,w){if(f[m]===w)return;b+=1,f={...f,[m]:w};const C=Zt(m,w);C&&(g={...g,[m]:C}),h()},async ensureServiceAccess(){return l||(l=(async()=>{if(!o){v="missing",h();return}if(!e.solid.permissions){v="capabilityUnavailable",h();return}if(e.solid.pod.status!=="ready"){v="missing",h();return}v="checking",h();try{const m=Ee(await o.getServiceAccess(),e.solid.pod.current.podUrl),w=await e.solid.permissions.ensureAgentAccess(m);v=w.status==="granted"?"granted":w.status,h(),w.status==="granted"&&await j.loadProviders()}catch(m){v=m instanceof Error&&m.message.startsWith("invalid_")?"invalidDescriptor":"permissionDenied",h()}finally{l=void 0}})(),l)},async revokeServiceAccess(){if(!o){v="missing",h();return}if(!e.solid.permissions){v="capabilityUnavailable",h();return}if(e.solid.pod.status!=="ready"){v="missing",h();return}v="checking",h();try{const m=Ee(await o.getServiceAccess(),e.solid.pod.current.podUrl),w=await e.solid.permissions.revokeAgentAccess(m);v=w.status==="granted"?"granted":w.status,h()}catch(m){v=m instanceof Error&&m.message.startsWith("invalid_")?"invalidDescriptor":"permissionDenied",h()}},async loadProviders(){if(o)return E||(E=(async()=>{const m=b+1;b=m,y=void 0,h();try{const w=await o.listProviders();if(m!==b)return;g=Object.fromEntries(w.map(C=>[C.provider,C])),f=Object.fromEntries(_.map(C=>[C.id,Yt(g[C.id])])),h()}catch(w){if(m!==b)return;y=en(w),h()}finally{E=void 0}})(),E)},subscribe(m){return A.add(m),()=>A.delete(m)}};return j}function Jt(e){return e.status==="initializing"?"authenticating":e.status==="authenticated"?"authenticated":e.status==="error"&&e.webId?"expired":"anonymous"}function de(e){return p.useSyncExternalStore(e.subscribe,()=>e.selectedProvider,()=>e.selectedProvider)}function He(e){return p.useSyncExternalStore(e.subscribe,()=>e.searchQuery,()=>e.searchQuery)}function Wt(e){return p.useSyncExternalStore(e.subscribe,()=>e.providerStates,()=>e.providerStates)}function Gt(e){return p.useSyncExternalStore(e.subscribe,()=>e.providerSummaries,()=>e.providerSummaries)}function ze(e){return p.useSyncExternalStore(e.subscribe,()=>e.providerLoadError,()=>e.providerLoadError)}function Xt(e){return p.useSyncExternalStore(e.subscribe,()=>e.serviceAccessState,()=>e.serviceAccessState)}function Yt(e){return!e||e.status==="disconnected"?"unconfigured":e.status==="reauthRequired"?"attention":e.authMode==="browserAssistedApiKey"?"configured":"connected"}function Zt(e,t){if(t==="configured")return{provider:e,status:"connected",authMode:"browserAssistedApiKey",connect:{modes:["browserAssistedApiKey"],configured:!0}};if(t==="connected")return{provider:e,status:"connected",connect:{modes:["deviceCodeOAuth","browserAssistedApiKey"],configured:!0}};if(t!=="attention"&&t!=="loading")return{provider:e,status:"disconnected",connect:{modes:["browserAssistedApiKey"],configured:!1}}}function en(e){return ae(e)}function tn({controller:e}){const t=de(e),r=He(e).trim().toLocaleLowerCase(),s=Wt(e),a=ze(e),o=r?_.filter(c=>c.name.toLocaleLowerCase().includes(r)):_;return n.jsxs(vt,{"aria-label":"AI 服务",children:[o.map(c=>n.jsx(nn,{provider:c,selected:t===c.id,state:s[c.id]??"loading",onSelect:()=>e.selectProvider(c.id)},c.id)),o.length===0?n.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"没有匹配的 Provider"}):null,a?n.jsxs("p",{className:"px-3 py-2 text-xs text-destructive",children:["Provider 状态读取失败:",a]}):null]})}function nn({provider:e,selected:t,state:r,onSelect:s}){const a=`ai-connection-provider-${e.id}-status`,o=sn(r);return n.jsxs(St,{selected:t,"aria-label":e.name,"aria-describedby":a,onClick:s,className:"gap-3 py-2.5",children:[n.jsx("span",{"aria-hidden":"true",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-semibold text-muted-foreground",children:rn(e.id)}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.name}),n.jsx("span",{id:a,role:"status","aria-live":"polite",className:"shrink-0 text-[11px] font-normal text-muted-foreground",children:o})]})}function rn(e){switch(e){case"openai":return"OA";case"anthropic":return"A";case"kimi":return"K";case"bailian":return"百";case"deepseek":return"DS"}}function sn(e){switch(e){case"unconfigured":return"未设置";case"configured":return"已配置";case"connected":return"已连接";case"attention":return"需处理";default:return"读取中"}}const on=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qe=(...e)=>e.filter((t,r,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===r).join(" ").trim();var an={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const cn=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:a="",children:o,iconNode:c,...d},f)=>p.createElement("svg",{ref:f,...an,width:t,height:t,stroke:e,strokeWidth:s?Number(r)*24/Number(t):r,className:qe("lucide",a),...d},[...c.map(([g,y])=>p.createElement(g,y)),...Array.isArray(o)?o:[o]]));const P=(e,t)=>{const r=p.forwardRef(({className:s,...a},o)=>p.createElement(cn,{ref:o,iconNode:t,className:qe(`lucide-${on(e)}`,s),...a}));return r.displayName=`${e}`,r};const dn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],un=P("Check",dn);const ln=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pn=P("Copy",ln);const fn=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],mn=P("ExternalLink",fn);const hn=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],W=P("KeyRound",hn);const yn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],G=P("LoaderCircle",yn);const wn=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],xn=P("LogOut",wn);const gn=[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]],An=P("MonitorCog",gn);const Cn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],bn=P("Plus",Cn);const jn=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],En=P("RefreshCcw",jn);const vn=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Sn=P("RotateCcw",vn);const Nn=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],In=P("RotateCw",Nn);const kn=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Pn=P("Search",kn);const Fn=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],$n=P("Trash2",Fn),Se=["codex","claude-code","pi","codebuddy"],U={codex:"Codex","claude-code":"Claude Code",pi:"Pi",codebuddy:"CodeBuddy"};function Bn({bridge:e,endpoint:t,createClientCredential:r}){const[s,a]=p.useState({}),[o,c]=p.useState({}),[d,f]=p.useState({}),[g,y]=p.useState();p.useEffect(()=>{if(!e)return;let l=!0;return Promise.all(Se.map(async A=>{let h;try{h=await e.inspect(A)}catch(j){h={status:"unavailable",message:K(j)}}l&&a(j=>({...j,[A]:h}))})),()=>{l=!1}},[e]);const b=async l=>{if(e){y(l);try{const A=await e.plan({client:l,endpoint:t});c(h=>({...h,[l]:A})),f(h=>({...h,[l]:""}))}catch(A){a(h=>({...h,[l]:{status:"unavailable",message:K(A)}}))}finally{y(void 0)}}},E=async l=>{const A=o[l];if(!e||!A||!r)return;y(l);let h,j=!1;try{h=await r(l),await e.apply({client:l,planId:A.planId,apiKey:h.apiKey,...A.confirmation?.required?{confirmation:{token:A.confirmation.token,targetHash:A.confirmation.targetHash}}:{}}),j=!0;const m=await e.verify({client:l,planId:A.planId});a(w=>({...w,[l]:m})),c(w=>({...w,[l]:void 0}))}catch(m){let w=K(m);if(h&&!j)try{await h.revoke()}catch(C){w=`${w};自动撤销新建 Client Credential 失败:${K(C)}。请到 Account Developer Access 手动撤销。`}a(C=>({...C,[l]:Dn(m)?{status:"failedAndRestored",message:"配置验证失败,已自动恢复原配置。"}:{status:"unavailable",message:w}}))}finally{y(void 0)}},v=async l=>{if(e){y(l);try{const A=await e.restore(l);a(h=>({...h,[l]:A}))}catch(A){a(h=>({...h,[l]:{status:"unavailable",message:K(A)}}))}finally{y(void 0)}}};return n.jsxs(_e,{children:[n.jsxs(De,{children:[n.jsxs(Le,{className:"flex items-center gap-2 text-base",children:[n.jsx(An,{className:"h-4 w-4"}),"Developer Access"]}),n.jsxs(Re,{children:["使用 Solid Client Credentials 生成 ",n.jsx("code",{children:"sk-*"})," API Key;Provider 凭证不会离开 Pod。"]})]}),n.jsx(Ue,{className:"space-y-2",children:Se.map(l=>{const A=s[l]??{status:e?"notConfigured":"unavailable",message:e?void 0:"当前 Host 不支持修改本机客户端配置。"},h=o[l],j=h?.confirmation,m=d[l]??"",w=!j?.required||m===j.token;return n.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:U[l]}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:A.message??Ne(A.status)})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Te,{variant:"secondary",children:Ne(A.status)}),n.jsx(S,{variant:"outline",size:"sm",disabled:!e||!!g,onClick:()=>{b(l)},children:"配置"}),n.jsx(S,{variant:"ghost",size:"icon","aria-label":`恢复 ${U[l]} 配置`,disabled:!e||A.status==="notConfigured"||!!g,onClick:()=>{v(l)},children:n.jsx(Sn,{className:"h-4 w-4"})})]})]}),h?n.jsxs("div",{className:"space-y-2 rounded-md border bg-muted/20 p-3",children:[n.jsx("div",{className:"text-xs font-medium",children:"将执行以下更改"}),h.changes.map(C=>n.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:C.target})," · ",_n(C.action),C.backup?" · 创建备份":""]},`${C.target}:${C.action}`)),j?.required?n.jsxs("div",{className:"space-y-2",children:[j.message?n.jsx("div",{className:"text-xs text-muted-foreground",children:j.message}):null,n.jsx(X,{"aria-label":`输入确认码以应用 ${U[l]} 配置`,value:m,onChange:C=>f(Y=>({...Y,[l]:C.target.value}))})]}):null,n.jsxs("div",{className:"flex gap-2",children:[n.jsx(S,{size:"sm","aria-label":j?.required?`确认并应用 ${U[l]} 配置`:`应用 ${U[l]} 配置`,disabled:!r||!!g||!w,onClick:()=>{E(l)},children:j?.required?"确认并应用":"应用更改"}),n.jsx(S,{variant:"ghost",size:"sm",disabled:!!g,onClick:()=>{c(C=>({...C,[l]:void 0})),f(C=>({...C,[l]:void 0}))},children:"取消"})]})]}):null]},l)})})]})}function _n(e){switch(e){case"update":return"更新";case"delete":return"删除";default:return"创建或更新"}}function Ne(e){switch(e){case"configured":return"已配置";case"drifted":return"配置已变化";case"unverifiable":return"无法验证";case"failedAndRestored":return"已恢复";case"unavailable":return"当前不可用";default:return"未配置"}}function Dn(e){return!!(e&&typeof e=="object"&&"code"in e&&e.code==="verification_failed_restored")}function K(e){return ae(e)}function Ln({providerName:e,quota:t,busy:r,disabled:s=!1,onRefresh:a}){return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("div",{className:"text-sm font-medium",children:"剩余额度"}),n.jsxs(S,{variant:"ghost",size:"sm","aria-label":`刷新 ${e} 额度`,disabled:r||s,onClick:a,children:[n.jsx(En,{className:"mr-2 h-3.5 w-3.5"}),"刷新"]})]}),t?t.status==="unsupported"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-sm",children:"官方额度接口不支持"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["来源:",t.source]})]}):t.status==="error"?n.jsx("p",{className:"text-sm text-destructive",children:"额度查询失败"}):n.jsxs("div",{className:"space-y-1 text-sm",children:[typeof t.balance=="number"?n.jsxs("div",{children:["余额:",t.balance]}):null,t.windows.map((o,c)=>n.jsxs("div",{children:[o.name?`${o.name}:`:"",typeof o.remaining=="number"?`剩余 ${o.remaining}`:"官方数据可用"]},`${String(o.name)}-${c}`)),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["来源:",t.source,t.stale?" · 数据可能已过期":""]})]}):n.jsx("p",{className:"text-xs text-muted-foreground",children:"尚未检查"})]})}function Rn({definition:e,status:t,accountLabel:r,attempt:s,apiKey:a,busy:o,disabled:c=!1,error:d,quota:f,models:g,onApiKeyChange:y,onBeginApiKey:b,onBeginBrowser:E,onSaveApiKey:v,onDisconnect:l,onRefreshQuota:A}){const h=s?.mode==="browserAssistedApiKey"&&s.status==="pending",j=t==="configured",m=t==="connected";return n.jsxs("div",{children:[n.jsxs("header",{className:"flex items-start justify-between gap-4 pb-5",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e.name}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:Un(e.id)})]}),n.jsx(Te,{variant:m||j?"default":"secondary",children:Tn(t)})]}),n.jsxs("section",{className:"border-t border-border/60 py-5","aria-label":"当前连接",children:[n.jsxs("div",{className:"mb-4",children:[n.jsx("h3",{className:"text-sm font-medium",children:"当前连接"}),r?n.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:Mn(r)}):n.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Provider 凭证加密保存在当前 Pod。"})]}),s?.userCode?n.jsxs("div",{className:"mb-4 border-l-2 border-primary bg-muted/30 px-3 py-2 text-sm",children:["验证码:",n.jsx("strong",{className:"font-mono",children:s.userCode})]}):null,n.jsx("div",{className:"flex flex-wrap gap-2",children:m?n.jsxs(n.Fragment,{children:[n.jsxs(S,{variant:"outline",size:"sm",disabled:o||c,onClick:E,children:[o?n.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):n.jsx(In,{className:"mr-2 h-4 w-4"}),"重新连接"]}),n.jsxs(S,{variant:"ghost",size:"sm",disabled:o||c,onClick:l,children:[n.jsx(xn,{className:"mr-2 h-4 w-4"}),"断开连接"]})]}):j?n.jsxs(n.Fragment,{children:[n.jsxs(S,{variant:"outline",size:"sm","aria-label":"更新 API Key",disabled:o||c,onClick:b,children:[n.jsx(W,{className:"mr-2 h-4 w-4"}),"更新 API Key"]}),n.jsx(S,{variant:"ghost",size:"sm",disabled:o||c,onClick:l,children:"移除配置"})]}):n.jsxs(n.Fragment,{children:[n.jsxs(S,{variant:"outline",size:"sm",disabled:o||c||e.browserMode==="connectUnsupported",onClick:E,children:[o?n.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):n.jsx(mn,{className:"mr-2 h-4 w-4"}),e.browserLabel]}),n.jsxs(S,{variant:"outline",size:"sm","aria-label":`${e.name} API Key`,disabled:o||c,onClick:b,children:[n.jsx(W,{className:"mr-2 h-4 w-4"}),"配置 API Key"]})]})}),h?n.jsxs("div",{className:"mt-4 space-y-2",children:[n.jsx(X,{type:"password",autoComplete:"off","aria-label":`${e.name} API Key 输入`,placeholder:"从官方控制台复制 API Key",value:a,onChange:w=>y(w.target.value)}),n.jsx(S,{size:"sm","aria-label":`保存 ${e.name} API Key`,disabled:!a.trim()||o||c,onClick:v,children:"保存 API Key"})]}):null,d?n.jsx("p",{className:"mt-3 text-sm text-destructive",children:d}):null]}),n.jsx("section",{className:"border-t border-border/60 py-5",children:n.jsx(Ln,{providerName:e.name,quota:f,busy:o,disabled:c,onRefresh:A})}),n.jsxs("section",{className:"border-t border-border/60 py-5",children:[n.jsx("h3",{className:"text-sm font-medium",children:"可用模型"}),g.length===0?n.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"当前身份暂无可用模型"}):n.jsx("ul",{className:"mt-3 divide-y divide-border/50 text-sm",children:g.map(w=>n.jsxs("li",{className:"flex items-center justify-between gap-4 py-2.5",children:[n.jsx("span",{children:w.displayName??w.id}),w.displayName?n.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:w.id}):null]},w.id))})]})]})}function Un(e){switch(e){case"openai":return"OpenAI 模型与编码能力";case"anthropic":return"Claude 模型与编码能力";case"kimi":return"Moonshot AI 模型服务";case"bailian":return"阿里云百炼模型服务";case"deepseek":return"DeepSeek 模型服务"}}function Tn(e){switch(e){case"pending":return"连接中";case"configured":return"已配置";case"connected":return"已连接";case"disconnected":return"未设置";case"reauthRequired":return"需要重新鉴权";case"failed":return"连接失败";default:return"未检查"}}function Mn(e){const t=e.indexOf("@");if(t>0){const r=e.slice(0,t);return`${r.length>1?`${r[0]}***${r[r.length-1]}`:`${r[0]}***`}${e.slice(t)}`}return e.length<=2?`${e[0]??""}***`:`${e[0]}***${e[e.length-1]}`}const On={};function Kn({client:e,openExternal:t=qn,clientConfigurationBridge:r,clientCredentialManager:s,selectedProvider:a,providerSummaries:o=On,providerLoadError:c,serviceAccessGranted:d=!1,onProviderStateChange:f}){const[g,y]=p.useState([]),[b,E]=p.useState(!!s),[v,l]=p.useState(""),[A,h]=p.useState(!1),[j,m]=p.useState(),[w,C]=p.useState(),[Y,ue]=p.useState({}),[Ze,et]=p.useState([]),[le,M]=p.useState({}),[pe,fe]=p.useState({}),[tt,nt]=p.useState({}),[rt,st]=p.useState({}),[it,me]=p.useState({}),[he,ye]=p.useState(!1),q=p.useRef(0),$=p.useCallback((i,u)=>{ue(x=>({...x,[i]:u})),f?.(i,zn(u))},[f]);p.useEffect(()=>{ue(Object.fromEntries(Object.values(o).filter(Qn).map(i=>[i.provider,i.status==="connected"&&i.authMode==="browserAssistedApiKey"?"configured":i.status])))},[o]),p.useEffect(()=>{let i=!0;return s?(E(!0),s.list().then(u=>{i&&y(u)}).catch(u=>{i&&C(B(u))}).finally(()=>{i&&E(!1)})):(E(!1),y([])),e.listModels().then(u=>{i&&et(u)}).catch(u=>{i&&C(B(u))}),()=>{i=!1,q.current+=1}},[e,s]);const F=(i,u)=>{nt(x=>({...x,[i]:u}))},k=(i,u)=>{st(x=>({...x,[i]:u}))},we=p.useCallback(async i=>{const u=i.verificationUriComplete??i.authorizationUrl??i.verificationUri;u&&await t(u)},[t]),xe=async i=>{if(d){F(i,!0),k(i);try{const u=await e.beginConnect(i,"browserAssistedApiKey");M(N=>({...N,[i]:u}));const x=se(u.status);if($(i,x?"pending":u.status==="completed"?"configured":"failed"),!x&&u.status!=="completed"){k(i,u.message??Ie(u.status));return}await we(u)}catch(u){$(i,"failed"),k(i,B(u))}finally{F(i,!1)}}},ot=async i=>{if(!d||i.browserMode==="connectUnsupported")return;if(i.browserMode==="browserAssistedApiKey"){await xe(i.id);return}F(i.id,!0),k(i.id);const u=q.current+1;q.current=u;try{const x=await e.beginConnect(i.id,i.browserMode);if(M(N=>({...N,[i.id]:x})),!se(x.status)){const N=x.status==="completed";$(i.id,N?"connected":"failed"),N||k(i.id,x.message??Ie(x.status)),F(i.id,!1);return}$(i.id,"pending"),await we(x),Hn(e,i.id,x,u,q,{onAttempt:N=>M(O=>({...O,[i.id]:N})),onConnected:()=>$(i.id,"connected"),onFailed:N=>{$(i.id,"failed"),k(i.id,N)},onFinished:()=>F(i.id,!1)})}catch(x){$(i.id,"failed"),k(i.id,B(x)),F(i.id,!1)}},at=async i=>{if(!d)return;const u=pe[i.id]?.trim(),x=le[i.id];if(!(!u||!x)){F(i.id,!0),k(i.id);try{const N=await e.completeApiKey(i.id,x,u);M(O=>({...O,[i.id]:N})),fe(O=>({...O,[i.id]:""})),$(i.id,"configured")}catch(N){k(i.id,B(N)),$(i.id,"failed")}finally{F(i.id,!1)}}},ct=async i=>{if(d){F(i,!0),k(i);try{await e.disconnect(i),M(u=>({...u,[i]:void 0})),me(u=>({...u,[i]:void 0})),$(i,"disconnected")}catch(u){k(i,B(u))}finally{F(i,!1)}}},dt=async i=>{F(i,!0),k(i);try{const u=await e.quota(i,!0);me(x=>({...x,[i]:u}))}catch(u){k(i,B(u))}finally{F(i,!1)}},ut=async()=>{if(!(!d||!s)){h(!0),C(void 0),m(void 0);try{const i=await s.create({name:v.trim()||"AI Connection",webId:e.webId});m({clientId:i.clientId,clientSecret:i.clientSecret,apiKey:i.apiKey}),y(u=>[i,...u.filter(x=>x.resourceUrl!==i.resourceUrl)]),l("")}catch(i){C(B(i))}finally{h(!1)}}},lt=async i=>{if(!(!d||!s)){C(void 0);try{await s.revoke(i.resourceUrl),y(u=>u.filter(x=>x.resourceUrl!==i.resourceUrl))}catch(u){C(B(u))}}},pt=async()=>{j&&(await navigator.clipboard?.writeText(j.apiKey),ye(!0))},ft=p.useCallback(async i=>{if(!d)throw new Error("AI Connection service access is not granted");if(!s)throw new Error("Client Credentials are not available in this host");const u=await s.create({name:`AI Connection · ${U[i]}`,webId:e.webId});return y(x=>[u,...x.filter(N=>N.resourceUrl!==u.resourceUrl)]),{apiKey:u.apiKey,revoke:async()=>{await s.revoke(u.resourceUrl),y(x=>x.filter(N=>N.resourceUrl!==u.resourceUrl))}}},[e.webId,s,d]);return n.jsxs("div",{className:"mx-auto w-full max-w-3xl px-6 py-6",children:[n.jsxs("section",{children:[c?n.jsxs("p",{className:"mb-4 rounded-md border border-destructive/30 px-3 py-2 text-sm text-destructive",children:["Provider 状态读取失败:",c]}):null,_.filter(i=>i.id===(a??"openai")).map(i=>n.jsx(Rn,{definition:i,status:Y[i.id]??"unknown",accountLabel:o[i.id]?.accountLabel,attempt:le[i.id],apiKey:pe[i.id]??"",busy:!!tt[i.id],disabled:!d,error:rt[i.id],quota:it[i.id],models:Ze.filter(u=>u.provider===i.id),onApiKeyChange:u=>fe(x=>({...x,[i.id]:u})),onBeginApiKey:()=>{xe(i.id)},onBeginBrowser:()=>{ot(i)},onSaveApiKey:()=>{at(i)},onDisconnect:()=>{ct(i.id)},onRefreshQuota:()=>{dt(i.id)}},i.id))]}),n.jsxs("details",{className:"border-t border-border/60 py-5",children:[n.jsx("summary",{className:"cursor-pointer list-none text-sm font-medium",children:"客户端接入"}),n.jsxs("div",{className:"mt-4 space-y-6",children:[n.jsx(Bn,{bridge:r,endpoint:e.apiBase,createClientCredential:ft}),n.jsxs("details",{className:"border-t border-border/60 pt-4",children:[n.jsx("summary",{className:"cursor-pointer text-sm font-medium text-muted-foreground",children:"Client Credentials"}),n.jsx("div",{className:"mt-3",children:n.jsxs(_e,{children:[n.jsxs(De,{children:[n.jsxs(Le,{className:"flex items-center gap-2 text-base",children:[n.jsx(W,{className:"h-4 w-4"}),"Client Credentials"]}),n.jsxs(Re,{children:["为 Codex、Claude Code、Pi、CodeBuddy 创建 Solid Client Credentials。API Key 为 ",n.jsx("code",{children:"sk-base64(client_id:client_secret)"}),",只在创建后显示一次。"]})]}),n.jsxs(Ue,{className:"space-y-4",children:[s?null:n.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-muted-foreground",children:["当前 Host 没有提供 account-controls Client Credentials capability。",n.jsx("a",{className:"ml-1 underline",href:"/.account/",children:"打开 Account Developer Access"})," ","手动创建 API Key。"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(X,{"aria-label":"Client Credential 名称",placeholder:"名称,例如 Codex",value:v,onChange:i=>l(i.target.value)}),n.jsxs(S,{onClick:()=>{ut()},disabled:A||!d||!s,children:[A?n.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):n.jsx(W,{className:"mr-2 h-4 w-4"}),"创建 Client Credential"]})]}),j?n.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[n.jsx("p",{className:"text-sm font-medium",children:"请立即保存;关闭后无法再次查看。"}),n.jsxs("div",{className:"space-y-2 rounded bg-background p-3 text-xs",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Client ID: "}),n.jsx("code",{children:j.clientId})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Client Secret: "}),n.jsx("code",{children:j.clientSecret})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"API Key: "}),n.jsx("code",{children:j.apiKey})]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsxs(S,{variant:"outline",size:"sm",onClick:()=>{pt()},children:[he?n.jsx(un,{className:"mr-2 h-4 w-4"}):n.jsx(pn,{className:"mr-2 h-4 w-4"}),he?"已复制":"复制 API Key"]}),n.jsx(S,{size:"sm",onClick:()=>{m(void 0),ye(!1)},children:"我已保存,隐藏密钥"})]})]}):null,w?n.jsx("p",{className:"text-sm text-destructive",children:w}):null,b?n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx(G,{className:"h-4 w-4 animate-spin"}),"正在读取 Client Credentials"]}):g.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"尚未创建 Client Credential。"}):n.jsx("div",{className:"space-y-2",children:g.map(i=>n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"truncate text-sm font-medium",children:i.id}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:i.webId??e.webId})]}),n.jsx(S,{variant:"ghost",size:"icon","aria-label":`撤销 ${i.id}`,disabled:!d||!s,onClick:()=>{lt(i)},children:n.jsx($n,{className:"h-4 w-4"})})]},i.resourceUrl))})]})]})})]})]})]})]})}async function Hn(e,t,r,s,a,o){let c=r;try{for(;a.current===s&&se(c.status);){if(await Vn(Math.max(1,c.intervalSeconds??2)*1e3),a.current!==s)return;c=await e.pollDevice(t,c),o.onAttempt(c)}c.status==="completed"?o.onConnected():a.current===s&&o.onFailed(c.message||`连接${c.status==="expired"?"已过期":"失败"}`)}catch(d){a.current===s&&o.onFailed(B(d))}finally{a.current===s&&o.onFinished()}}function se(e){return e==="pending"||e==="authorization_pending"||e==="slow_down"}function Ie(e){return e==="expired"?"连接已过期,请重新开始":e==="cancelled"?"连接已取消":e==="unsupported"?"当前 Provider 不支持此连接方式":"连接失败"}function zn(e){return e==="configured"?"configured":e==="connected"?"connected":e==="failed"||e==="reauthRequired"?"attention":e==="pending"?"loading":"unconfigured"}function qn(e){window.open(e,"_blank","noopener,noreferrer")}function Vn(e){return new Promise(t=>window.setTimeout(t,e))}function B(e){return ae(e)}function Qn(e){return e!==void 0}function Jn({controller:e}){const t=de(e),r=Gt(e),s=ze(e),a=Xt(e),o=_.find(c=>c.id===t);if(!e.client){const c=e.sessionStatus==="expired",d=e.sessionStatus==="authenticating"||e.podStatus==="opening",f=e.error??(e.sessionStatus==="authenticated"&&e.podStatus!=="ready"?new Error("当前 Pod 尚未就绪"):void 0);return d?n.jsx("section",{"aria-label":"AI Connection",className:"space-y-3 p-6",children:n.jsx("p",{role:"status",children:"正在打开当前 Pod..."})}):f?n.jsxs("section",{"aria-label":"AI Connection",className:"space-y-3 p-6",children:[n.jsx("p",{className:"text-sm text-destructive",children:f.message}),n.jsx(S,{size:"sm",onClick:()=>{e.login()},children:"重试登录"})]}):n.jsxs("section",{"aria-label":"AI Connection",className:"space-y-3 p-6",children:[n.jsx("p",{children:c?"当前登录已过期,请重新登录后继续。":"登录后即可管理当前 Pod 的 AI 连接。"}),n.jsx(S,{size:"sm",onClick:()=>{e.login()},children:c?"重新登录":"登录"})]})}return n.jsxs("section",{role:"region","aria-label":`${o?.name??t} 详情`,children:[n.jsx("p",{className:"px-6 pt-4 text-xs text-muted-foreground",role:"status",children:Wn(a)}),n.jsx(Kn,{client:e.client,selectedProvider:t,openExternal:e.openExternal,clientConfigurationBridge:e.clientConfigurationBridge,clientCredentialManager:e.clientCredentialManager,providerSummaries:r,providerLoadError:s,serviceAccessGranted:a==="granted",onProviderStateChange:e.setProviderState})]})}function Wn(e){return e==="granted"?"服务访问已授权":e==="checking"?"服务访问检查中":"服务访问未授权"}function Gn({controller:e}){const t=He(e);return n.jsxs("div",{className:"flex h-full min-w-0 items-center gap-2 px-3",children:[n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx(Pn,{"aria-hidden":"true",className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx(X,{type:"search","aria-label":"搜索 Provider",placeholder:"搜索 Provider",value:t,onChange:r=>e.setSearchQuery(r.target.value),className:"h-8 border-transparent bg-muted/50 pl-8 text-xs focus-visible:bg-background"})]}),n.jsx(S,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":"添加 AI Connection",title:"添加 AI Connection",onClick:()=>e.selectFirstUnconfiguredProvider(),children:n.jsx(bn,{className:"h-4 w-4","aria-hidden":"true"})})]})}function Xn({controller:e}){const t=de(e),r=_.find(s=>s.id===t);return n.jsx("div",{className:"flex h-full min-w-0 items-center px-4",children:n.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:r?.name??t})})}const Yn=["navigation.openExternal","aiClientConfiguration"];function Zn(e){const t=ee(e,"Extension manifest");ke(t.extensionId,"extensionId"),T(t.name,"name"),T(t.version,"version"),T(t.sdkVersion,"sdkVersion");const r=ee(t.contributes,"contributes");if(!Array.isArray(r.applets)||r.applets.length===0)throw new Error("Extension manifest must contribute at least one Applet");const s=new Set;for(const a of r.applets){const o=ee(a,"Applet manifest"),c=ke(o.appId,"appId");if(s.has(c))throw new Error(`Extension manifest has duplicate appId: ${c}`);if(s.add(c),T(o.name,"Applet name"),T(o.entry,"Applet entry"),!Array.isArray(o.commands))throw new Error("Applet commands must be an array");if(o.layout!=="single-pane"&&o.layout!=="two-pane")throw new Error("Applet layout must be single-pane or two-pane")}if(!Array.isArray(t.dataModels))throw new Error("Extension dataModels must be an array");if(!Array.isArray(t.hostCapabilities))throw new Error("Extension hostCapabilities must be an array");for(const a of t.hostCapabilities)if(!Yn.includes(a))throw new Error(`Extension manifest requested unknown Host capability: ${String(a)}`);return e}function ee(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function T(e,t){if(typeof e!="string"||e.trim().length===0)throw new Error(`${t} must be a non-empty string`);return e}function ke(e,t){const r=T(e,t);let s;try{s=new URL(r)}catch{throw new Error(`${t} must be a valid HTTPS URL`)}if(s.protocol!=="https:")throw new Error(`${t} must be a valid HTTPS URL`);return r}const Ve=Zn({extensionId:"https://undefineds.co/extensions/ai-connection",name:"AI Connection",version:"0.1.0",sdkVersion:"1",contributes:{applets:[{appId:"https://undefineds.co/applets/ai-connection",name:"AI Connection",entry:".",commands:[],layout:"two-pane"}]},dataModels:[],hostCapabilities:["navigation.openExternal","aiClientConfiguration"]}),Qe=Ve.contributes.applets[0],er={manifest:Qe,createController:Qt,activate(e){e.ensureServiceAccess()},slots:{listHeader:Gn,list:tn,mainHeader:Xn,main:Jn}},tr={manifest:Ve,applets:{[Qe.appId]:er}};function nr(){return tr}const rr=3e4;function sr({podUrl:e,authenticatedFetch:t,now:r=()=>new Date}){const s=oe(e);let a,o;const c=async(y,b)=>{const E=await t(y,b);return a=await ar(E.clone()),E},d=async()=>{if(cr(a,r()))return a;if(o)return o;o=f();try{return await o}finally{o=void 0}},f=async()=>{if(!(await c(`${s}/api/applets/service-access/ai-connection`,{method:"GET",credentials:"include",headers:{accept:"application/json"}})).ok)throw new Error("AI Connection request failed. Please try again.");const b=a;if(!b?.token)throw new Error("AI Connection request failed. Please try again.");return b},g=async(y,b)=>{const E=await d(),v=dr(E);if(!v)throw new Error("AI Connection request failed. Please try again.");const l=new Headers(b?.headers);return l.set("Authorization",`Bearer ${v}`),t(y,{...b,credentials:"omit",headers:l})};return(async(y,b)=>{if(or(y,s))return c(y,b);const E=await g(y,b);if(E.status!==401)return Pe(E);await E.arrayBuffer(),a=void 0;const v=await g(y,b);return Pe(v)})}function ir({podUrl:e,authenticatedFetch:t,now:r}){const s=oe(e),a=sr({podUrl:e,authenticatedFetch:t,now:r});return{inspect:async o=>{const c=await a(H(s,o),{method:"GET",credentials:"omit",headers:{accept:"application/json"}});return c.status===403||c.status===404||c.status===503?(await c.arrayBuffer(),Fe()):z(c)},plan:async o=>z(await a(`${H(s,o.client)}/plan`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({endpoint:o.endpoint})})),apply:async o=>z(await a(`${H(s,o.client)}/apply`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({planId:o.planId,apiKey:o.apiKey,confirmation:o.confirmation})})),verify:async o=>z(await a(`${H(s,o.client)}/verify`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({planId:o.planId})})),restore:async o=>{const c=await a(`${H(s,o)}/restore`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({})});return c.status===403||c.status===404||c.status===503?(await c.arrayBuffer(),Fe()):z(c)}}}function or(e,t){try{return new URL(String(e),t).pathname==="/api/applets/service-access/ai-connection"}catch{return!1}}async function ar(e){if(!(!e.ok||!e.headers.get("content-type")?.includes("application/json")))try{const t=await e.json();return ur(t.invocation)}catch{return}}function cr(e,t){if(!e?.token)return!1;if(!e.expiresAt)return!0;const r=Date.parse(e.expiresAt);return Number.isFinite(r)&&r-t.getTime()>rr}function dr(e){return e?.token}function ur(e){if(!Je(e))return;const t=["gateway","Key"].join("");return{token:typeof e.token=="string"?e.token:typeof e[t]=="string"?e[t]:void 0,baseUrl:typeof e.baseUrl=="string"?e.baseUrl:void 0,expiresAt:typeof e.expiresAt=="string"?e.expiresAt:void 0}}async function Pe(e){return e.ok?e:e.headers.get("content-type")?.includes("application/json")?pr(e):(await e.arrayBuffer(),new Response(JSON.stringify({error:"internal_error"}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}))}function H(e,t){return`${e}/api/ai/client-configuration/${encodeURIComponent(t)}`}async function z(e){if(!e.ok)throw await lr(e);if(!e.headers.get("content-type")?.includes("application/json"))throw await e.arrayBuffer(),new Error("AI client configuration request failed. Please try again.");return await e.json()}async function lr(e){let t;try{t=e.headers.get("content-type")?.includes("application/json")?await e.json():void 0}catch{t=void 0}if(Je(t)){const r=typeof t.code=="string"?t.code:typeof t.error=="string"?t.error:void 0,s=typeof t.message=="string"?t.message:"AI client configuration request failed. Please try again.",a=new Error(s);return a.code=r,a.status=e.status,a.details=t.details,a}return await e.arrayBuffer().catch(()=>{}),new Error("AI client configuration request failed. Please try again.")}function Fe(){return{status:"unavailable",message:"Host does not support local client configuration. Use the manual setup instructions for your client."}}async function pr(e){let t;try{t=await e.clone().json()}catch{return e}return fr(t)?new Response(JSON.stringify({code:t.error.code,error:t.error.message}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}):e}function fr(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e.error;return!!(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.code=="string"&&typeof t.message=="string"&&typeof t.status=="number")}function Je(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}const We="css-account",mr="xpod.cssAccountToken",hr="CSS-Account-Token";function Ge(){return typeof window<"u"&&typeof document<"u"}function yr(){if(!Ge())return;const e=document.cookie.split(";");for(const t of e){const[r,...s]=t.trim().split("=");if(r===We){const a=s.join("=");try{return a?decodeURIComponent(a):void 0}catch{return}}}}function wr(e){Ge()&&(document.cookie=`${We}=${encodeURIComponent(e)}; Path=/; SameSite=Lax`)}function xr(){if(!(typeof window>"u"))try{return window.sessionStorage.getItem(mr)||void 0}catch{return}}function gr(){const e=yr();if(e)return e;const t=xr();if(t)return wr(t),t}function Ar(e,t={Accept:"application/json"}){const r={...t};return e&&!Cr(r,"Authorization")&&(r.Authorization=`${hr} ${e}`),r}function te(e={Accept:"application/json"}){return Ar(gr(),e)}function Cr(e,t){const r=t.toLowerCase();return Object.keys(e).some(s=>s.toLowerCase()===r)}function br(e,t){return`sk-${btoa(`${e}:${t}`)}`}function jr(e,t,r=fetch){if(!e||!t)return;const s=new Set;return{available:!0,accountUrl:"/.account/",async list(){const a=await r(e,{method:"GET",headers:te({Accept:"application/json"}),credentials:"include"});if(!a.ok)throw new Error("Failed to list Client Credentials");const o=await a.json(),c=Er(o.clientCredentials).filter(d=>d.webId===t);for(const d of c)s.add(d.resourceUrl);return c},async create(a){if(a.webId!==t)throw new Error("Cannot create a Client Credential for another WebID");const o=await r(e,{method:"POST",headers:te({Accept:"application/json","Content-Type":"application/json"}),credentials:"include",body:JSON.stringify({name:a.name,webId:a.webId})});if(!o.ok)throw new Error("Failed to create Client Credential");const c=await o.json(),d=vr(c,a.webId,e);return s.add(d.resourceUrl),d},async revoke(a){if(!s.has(a))throw new Error("Cannot revoke a Client Credential outside the current WebID");if(!(await r(a,{method:"DELETE",headers:te({Accept:"application/json"}),credentials:"include"})).ok)throw new Error("Failed to revoke Client Credential")}}}function Er(e){return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).map(([t,r])=>({id:Sr(t),resourceUrl:t,webId:typeof r=="string"?r:void 0}))}function vr(e,t,r){if(!e.id||!e.secret)throw new Error("Client Credential response did not include the one-time secret");const s=e.resourceUrl??new URL(`${encodeURIComponent(e.id)}/`,r).href;return{id:e.id,resourceUrl:s,webId:e.webId??t,clientId:e.id,clientSecret:e.secret,apiKey:br(e.id,e.secret)}}function Sr(e){try{const t=new URL(e).pathname.split("/").filter(Boolean);return t[t.length-1]??e}catch{return e.split("/").filter(Boolean).pop()??e}}const Xe=nr(),$e=Xe.manifest.contributes.applets[0]?.appId,Ye=$e?Xe.applets[$e]:void 0;if(!Ye)throw new Error("AI Connection extension did not contribute an applet");const Nr=Ye;function Ir(e,t=new URL("/.account/client-credentials/",window.location.origin).toString()){const r=e.currentPod?{status:"ready",current:e.currentPod}:e.state.status==="authenticated"?{status:"opening"}:e.state.status==="error"?{status:"error",error:e.state.error}:{status:"unavailable"};return{solid:{session:{getSnapshot:e.session.getSnapshot,subscribe:e.session.subscribe,fetch:e.fetch},pod:r,permissions:{inspectAgentAccess:async s=>({status:"granted",resources:s.resources}),ensureAgentAccess:async s=>({status:"granted",resources:s.resources}),revokeAgentAccess:async s=>({status:"missing",resources:s.resources})},requireLogin:async()=>e.login(window.location.origin)},navigation:{openExternal:async s=>{window.open(s,"_blank","noopener,noreferrer")}},capabilities:{aiClientConfiguration:e.currentPod&&e.aiClientConfiguration?.available===!0&&e.aiClientConfiguration.authority==="local-filesystem"?ir({podUrl:e.currentPod.podUrl,authenticatedFetch:e.fetch}):kr,aiClientCredentials:jr(t,e.webId,e.fetch)}}}const kr={inspect:async()=>({status:"unavailable",message:"Host does not support local client configuration. Use the manual setup instructions for your client."}),plan:async()=>{throw new Error("Host does not support local client configuration. Use the manual setup instructions for your client.")},apply:async()=>{throw new Error("Host does not support local client configuration. Use the manual setup instructions for your client.")},verify:async()=>({status:"unavailable",message:"Host does not support local client configuration. Use the manual setup instructions for your client."}),restore:async()=>({status:"unavailable",message:"Host does not support local client configuration. Use the manual setup instructions for your client."})};function Pr(e){const t=p.useMemo(()=>Ir(e),[e]);return p.useMemo(()=>{const r=xt(Nr,t);if(r.layout!=="two-pane")throw new Error("AI Connection applet must use a two-pane layout");return r},[t])}function _r(){const e=mt(),t=Pr(e);return p.useEffect(()=>{t.controller.ensureServiceAccess()},[t.controller]),n.jsx(ht,{listHeader:t.slots.listHeader,list:t.slots.list,mainHeader:t.slots.mainHeader,main:t.slots.main,mode:"auto"})}export{_r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,j as s}from"./settings-
|
|
1
|
+
import{b as e,j as s}from"./settings-Cyyv6-SD.js";const a=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],r=e("database",a);const o=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],n=e("refresh-cw",o);function d({title:t}){return s.jsx("div",{className:"flex h-full items-center px-4 text-sm font-semibold text-foreground",children:t})}export{r as D,d as P,n as R};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as p,e as _,r as d,j as e,B as f}from"./settings-Cyyv6-SD.js";import{P as $,D as A,R as E}from"./PaneListHeader-DMD8OJef.js";import{T as H}from"./workspace-layout-B47luv6r.js";import{C as b,a as j,b as v,c as y,d as N,B as z}from"./card-Cjsia0_V.js";const D=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],T=p("external-link",D);const K=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],V=p("log-in",K);const F=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],O=p("log-out",F);const G=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],W=p("shield-check",G);async function X({webId:t,podUrl:s,authenticatedFetch:a}){const n=new URL("/",s).origin,i=await a(`${n}/api/pod/settings/status`,{method:"GET",credentials:"include",headers:{accept:"application/json"}});if(!i.ok)throw await i.arrayBuffer(),new Error("Pod settings request failed. Please try again.");if(!i.headers.get("content-type")?.includes("application/json"))throw await i.arrayBuffer(),new Error("Pod settings request failed. Please try again.");const o=await i.json();if(o.identity?.webId!==t)throw new Error("Pod settings response does not match the current Solid session.");return o}function ne({view:t="combined"}){const s=_(),[a,n]=d.useState(),[i,o]=d.useState(),[l,c]=d.useState(!1),u=d.useRef(0),P=d.useRef(void 0),w=d.useRef(!0),m=s.state.status==="authenticated"&&!!(s.webId&&s.podUrl)?`${s.webId}
|
|
2
|
+
${s.podUrl}`:void 0;d.useEffect(()=>(w.current=!0,()=>{w.current=!1,u.current+=1}),[]);const k=d.useCallback(async()=>{const h=s.webId,B=s.podUrl,L=m;if(!h||!B||!L)return;const U=u.current+1;u.current=U;const I=()=>w.current&&u.current===U&&P.current===L;c(!0),o(void 0);try{const q=await X({webId:h,podUrl:B,authenticatedFetch:s.fetch});I()&&n(q)}catch{I()&&o("Pod settings request failed. Please try again.")}finally{I()&&c(!1)}},[m,s.fetch,s.podUrl,s.webId]);d.useEffect(()=>{let h=!1;return P.current=m,u.current+=1,queueMicrotask(()=>{h||(n(void 0),o(void 0),c(!1),m&&k())}),()=>{h=!0}},[m,k]);const x=d.useMemo(()=>({webId:s.webId??a?.identity.webId,podUrl:s.podUrl??a?.identity.podUrl,issuer:s.issuer}),[s.issuer,s.podUrl,s.webId,a]),M=()=>{x.podUrl&&window.open(x.podUrl,"_blank","noopener,noreferrer")},R=()=>{s.issuer&&s.login(s.issuer)};return e.jsx(H,{mode:"auto",listHeader:e.jsx($,{title:t==="usage"?"Usage":"Pod"}),list:e.jsxs("aside",{className:"flex h-full flex-col gap-3 border-r border-border bg-muted/30 p-4",children:[t!=="usage"?e.jsx(J,{webId:x.webId,podUrl:x.podUrl,issuer:x.issuer,sessionStatus:s.state.status,onOpenPod:M,onLogout:()=>{s.logout()},onLoginAgain:R,canLoginAgain:!!s.issuer}):null,t!=="settings"?e.jsx(Q,{storage:a?.storage,loading:l&&!a}):null]}),mainHeader:e.jsx(Z,{title:t==="usage"?"Usage":"Pod",loading:l,onRefresh:k}),main:e.jsxs("section",{className:"flex min-h-full flex-col gap-4 bg-background p-6",children:[i?e.jsx("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:i}):null,e.jsx(Y,{aiConnection:a?.aiConnection,loading:l&&!a}),e.jsxs(b,{children:[e.jsxs(j,{children:[e.jsxs(v,{className:"flex items-center gap-2 text-base",children:[e.jsx(W,{className:"h-4 w-4","aria-hidden":"true"}),"Access boundary"]}),e.jsx(y,{children:"This page reads the authenticated Solid session and current Pod only."})]}),e.jsxs(N,{className:"grid gap-3 text-sm text-muted-foreground",children:[e.jsx(r,{label:"Session",value:s.state.status}),e.jsx(r,{label:"Status generated",value:S(a?.generatedAt)})]})]})]}),className:"min-h-full"})}function J({webId:t,podUrl:s,issuer:a,sessionStatus:n,onOpenPod:i,onLogout:o,onLoginAgain:l,canLoginAgain:c}){return e.jsxs(b,{children:[e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:"Identity"}),e.jsx(y,{children:"Current Solid session"})]}),e.jsxs(N,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(r,{label:"WebID",value:t??"Not signed in"}),e.jsx(r,{label:"Pod",value:s??"Discovering"}),e.jsx(r,{label:"Issuer",value:a??"Unknown"}),e.jsx(r,{label:"Status",value:n})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:i,disabled:!s,children:[e.jsx(T,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Open Pod"]}),e.jsxs(f,{type:"button",size:"sm",variant:"subtle",onClick:o,children:[e.jsx(O,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Logout"]}),e.jsxs(f,{type:"button",size:"sm",variant:"ghost",onClick:l,disabled:!c,children:[e.jsx(V,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Login again"]})]})]})]})}function Q({storage:t,loading:s}){const a=t?.status==="available",n=a&&t.limits.storageLimitBytes?Math.min(100,Math.round(t.usage.storageBytes/t.limits.storageLimitBytes*100)):void 0;return e.jsxs(b,{children:[e.jsxs(j,{children:[e.jsxs(v,{className:"flex items-center gap-2 text-base",children:[e.jsx(A,{className:"h-4 w-4","aria-hidden":"true"}),"Storage usage"]}),e.jsx(y,{children:s?"Refreshing usage":"Current Pod quota view"})]}),e.jsx(N,{className:"space-y-4",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-semibold text-foreground",children:g(t.usage.storageBytes)}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t.limits.storageLimitBytes==null?"No storage limit":`${g(t.limits.storageLimitBytes)} limit`})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-muted","aria-label":"Storage usage meter",children:e.jsx("div",{className:"h-full bg-primary",style:{width:`${n??0}%`}})}),e.jsxs("div",{className:"grid gap-2 text-sm text-muted-foreground",children:[e.jsx(r,{label:"Ingress",value:g(t.usage.ingressBytes)}),e.jsx(r,{label:"Egress",value:g(t.usage.egressBytes)}),e.jsx(r,{label:"Bandwidth",value:t.limits.bandwidthLimitBps==null?"No limit":`${g(t.limits.bandwidthLimitBps)}/s`})]})]}):e.jsx(C,{title:t?.status==="error"?"Usage unavailable":"Usage unsupported",detail:t?.reason??"usage_not_available"})})]})}function Y({aiConnection:t,loading:s}){const a=t?.status==="available";return e.jsxs(b,{children:[e.jsx(j,{children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-base",children:"AI Connection"}),e.jsx(y,{children:"Pod-backed provider configuration status"})]}),e.jsx(z,{variant:a?"secondary":"outline",children:a?"Available":s?"Loading":"Partial"})]})}),e.jsx(N,{className:"space-y-4",children:a?e.jsxs("div",{className:"grid gap-3 text-sm",children:[e.jsx(r,{label:"Providers",value:`${t.configuredProviders} providers`}),e.jsx(r,{label:"Data container",value:t.containerUrl??"Not declared"}),e.jsx(r,{label:"Last sync",value:S(t.lastSyncAt)}),e.jsx(r,{label:"Source",value:t.source??"drizzle-solid"})]}):e.jsx(C,{title:t?.status==="error"?"AI Connection unavailable":"AI Connection unsupported",detail:t?.reason??"not_configured"})})]})}function Z({title:t,loading:s,onRefresh:a}){return e.jsxs("div",{className:"flex h-full min-w-0 items-center justify-between gap-4 px-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:t}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:"Identity, storage, and applet data status"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{className:"inline-flex h-9 items-center justify-center rounded-md border border-input bg-background px-3 text-sm font-medium text-foreground hover:bg-accent",href:t==="Usage"?"/settings/pod":"/dashboard/usage",children:t==="Usage"?"Configure Pod":"View usage"}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:a,disabled:s,children:[e.jsx(E,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Refresh"]})]})]})}function r({label:t,value:s}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:t}),e.jsx("div",{className:"break-words text-sm text-foreground",children:s??"Unknown"})]})}function C({title:t,detail:s}){return e.jsxs("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:t}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function g(t){if(!Number.isFinite(t))return"Unknown";const s=["B","KB","MB","GB","TB"];let a=Math.max(0,t),n=0;for(;a>=1024&&n<s.length-1;)a/=1024,n+=1;return`${Number.isInteger(a)?a:a.toFixed(a>=10?1:2)} ${s[n]}`}function S(t){if(!t)return"Not observed";const s=new Date(t);return Number.isNaN(s.getTime())?"Not observed":s.toLocaleString()}export{J as IdentityCard,Q as PodUsageCard,ne as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as j,r as n,j as e,O as R,u as k,d as y,S as C,N as L}from"./settings-Cyyv6-SD.js";import{f as M,S as I}from"./services-status-context-CkuKmH5h.js";import{D as P,P as D,R as _}from"./PaneListHeader-DMD8OJef.js";import{T as A,u as w}from"./workspace-layout-B47luv6r.js";const E=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],H=j("activity",E);const z=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],q=j("scroll-text",z);const $=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],V=j("settings",$),F=[{id:"runtime",label:"Runtime",path:"/services/runtime",description:"Xpod runtime, Solid server, AI Gateway, storage, and worker health.",icon:H},{id:"logs",label:"Logs",path:"/services/logs",description:"Runtime logs and sanitized diagnostics export.",icon:q},{id:"rdf",label:"RDF",path:"/services/rdf",description:"RDF indexing, storage stats, cache health, and slow query evidence.",icon:P},{id:"configuration",label:"Configuration",path:"/services/configuration",description:"Advanced local runtime configuration and restart-controlled changes.",icon:V}],S={supported:!1,reason:"capability_not_reported"};function K({mode:a="auto",product:s="legacy"}){const[r,i]=n.useState(null),[c,l]=n.useState(!0),[f,x]=n.useState(!1),[t,g]=n.useState(),o=n.useRef(0),d=n.useRef(null),u=n.useRef(!1),h=n.useCallback(async(m=!1)=>{const b=o.current+1;o.current=b,d.current?.abort();const p=new AbortController;d.current=p,m?l(!0):x(!0),g(void 0);try{const v=await M({signal:p.signal});u.current&&o.current===b&&!p.signal.aborted&&i(v)}catch(v){u.current&&o.current===b&&!p.signal.aborted&&!(v instanceof DOMException&&v.name==="AbortError")&&g("Services status request failed. Please try again.")}finally{u.current&&o.current===b&&!p.signal.aborted&&(l(!1),x(!1))}},[]);n.useEffect(()=>{u.current=!0,queueMicrotask(()=>{u.current&&h(!0)});const m=setInterval(()=>{h(!1)},1e4);return()=>{u.current=!1,o.current+=1,d.current?.abort(),d.current=null,clearInterval(m)}},[h]);const N=n.useMemo(()=>{const m=r?.adminData?.capabilities?.services;return{snapshot:r,loading:c,refreshing:f,error:t,refresh:()=>{h(!1)},restartCapability:m?.lifecycle?.restart??S,configurationWriteCapability:m?.configuration?.write??S}},[t,h,c,f,r]);return e.jsx(I.Provider,{value:N,children:e.jsx(A,{mode:a,listHeader:e.jsx(D,{title:"Services"}),list:e.jsx(W,{snapshot:r,loading:c&&!r,showSections:s==="legacy"}),mainHeader:e.jsx(T,{product:s,loading:c||f,onRefresh:N.refresh}),main:e.jsxs("section",{className:"min-h-full min-w-0 bg-background",children:[e.jsx(O,{}),t?e.jsx("div",{role:"alert",className:"mx-6 mt-6 rounded-md border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:t}):null,e.jsx(R,{})]}),className:"min-h-full"})})}function O(){const a=k(),s=w(),r=n.useRef(null),i=a.pathname.replace(/\/+$/,"")||"/services";return n.useEffect(()=>{if(r.current!==i){if(r.current=i,i==="/services"){s.openList();return}s.openMain()}},[i,s]),null}function T({product:a,loading:s,onRefresh:r}){return e.jsxs("div",{className:"flex h-full min-w-0 items-center justify-between gap-4 px-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Services"}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:"Runtime health, logs, RDF indexing, and configuration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a!=="legacy"?e.jsx("a",{className:"inline-flex h-9 items-center justify-center rounded-md border border-input bg-background px-3 text-sm font-medium text-foreground hover:bg-accent",href:a==="dashboard"?"/settings/services":"/dashboard/runtime",children:a==="dashboard"?"Configure":"View runtime"}):null,e.jsxs("button",{type:"button",onClick:r,disabled:s,className:"inline-flex h-9 items-center justify-center rounded-md border border-input bg-background px-3 text-sm font-medium text-foreground transition-colors hover:bg-accent disabled:pointer-events-none disabled:opacity-50",children:[e.jsx(_,{className:y("mr-2 h-4 w-4",s&&"animate-spin"),"aria-hidden":"true"}),"Refresh"]})]})]})}function W({snapshot:a,loading:s,showSections:r}){const i=k(),c=w(),l=a?.servicesData??[],f=l.filter(t=>t.status==="running").length,x=l.length;return e.jsxs("aside",{className:"flex h-full flex-col gap-4 border-r border-border bg-muted/30 p-4",children:[e.jsxs("div",{className:"rounded-md border border-border bg-card",children:[e.jsxs("div",{className:"px-4 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-semibold text-foreground",children:[e.jsx(C,{className:"h-4 w-4","aria-hidden":"true"}),"Service health"]}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:s?"Loading runtime status":`${f}/${x||0} services running`})]}),e.jsx("div",{className:"space-y-2 px-4 pb-4 pt-3",children:x>0?l.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"font-medium text-foreground",children:t.name}),e.jsx("span",{className:y("rounded-md px-2 py-0.5 text-xs font-medium",t.status==="running"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:t.status})]},t.name)):e.jsx("div",{className:"text-sm text-muted-foreground",children:s?"Waiting for status":"No service status reported"})})]}),r?e.jsx("nav",{"aria-label":"Services sections",className:"space-y-1",children:F.map(t=>{const g=t.icon,o=t.id==="runtime"&&i.pathname==="/services";return e.jsxs(L,{to:t.path,onClick:()=>c.openMain(),className:({isActive:d})=>y("flex gap-3 rounded-md px-3 py-2 text-sm transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",d||o?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[e.jsx(g,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:t.label}),e.jsx("span",{className:"mt-0.5 block text-xs opacity-80",children:t.description})]})]},t.id)})}):null]})}export{K as default};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var Dn=e=>{throw TypeError(e)};var Ln=(e,t,n)=>t.has(e)||Dn("Cannot "+n);var oe=(e,t,n)=>(Ln(e,t,"read from private field"),n?n.call(e):t.get(e)),jn=(e,t,n)=>t.has(e)?Dn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$t=(e,t,n,r)=>(Ln(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);import{f as Co,b as It,j as l,d as se,r as a,g as ne,h as tt,R as Dt}from"./settings-Cyyv6-SD.js";import{u as Po,g as Oo,a as Ro,b as _o,c as No,t as To}from"./services-status-context-CkuKmH5h.js";var ut=Co();const Ao=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Io=It("check",Ao);const Do=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Lo=It("chevron-down",Do);const jo=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],ko=It("key-round",jo);const Mo=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Fo=It("triangle-alert",Mo);function Fe(e){const{className:t,variant:n,children:r}=e;return l.jsx("div",{className:se("rounded-xl bg-background",n==="bordered"&&"border border-border",t),children:r})}function Ye(e){const{className:t,children:n}=e;return l.jsx("div",{className:se("px-5 pt-5",t),children:n})}function Ge(e){const{className:t,children:n}=e;return l.jsx("div",{className:se("text-base font-semibold",t),children:n})}function Ue(e){const{className:t,children:n}=e;return l.jsx("div",{className:se("px-5 pb-5 pt-4",t),children:n})}function Ze(e){const{className:t,variant:n="default",size:r="default",children:o,...s}=e,i="inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary active:translate-y-px disabled:opacity-50 disabled:pointer-events-none",c={default:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-muted text-foreground hover:bg-muted/80",ghost:"bg-transparent hover:bg-muted text-foreground"},u={default:"h-10 px-4 py-2",sm:"h-8 px-3"};return l.jsx("button",{className:se(i,c[n],u[r],t),...s,children:o})}function fr(e){const{className:t,...n}=e;return l.jsx("input",{className:se("w-full h-10 rounded-md border border-input bg-background px-3 py-2 text-sm","placeholder:text-muted-foreground","focus:outline-none focus-visible:ring-2 focus-visible:ring-primary",t),...n})}function Qe(e){const{className:t,...n}=e;return l.jsx("label",{className:se("text-sm font-medium text-foreground",t),...n})}var Uo=Object.defineProperty,Bo=(e,t)=>Uo(e,"name",{value:t,configurable:!0});function en(e,[t,n]){return Math.min(n,Math.max(t,e))}Bo(en,"clamp");var Vo=Object.defineProperty,rt=(e,t)=>Vo(e,"name",{value:t,configurable:!0}),pr=!!(typeof window<"u"&&window.document&&window.document.createElement);function J(e,t,{checkForDefaultPrevented:n=!0}={}){return rt(function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)},"handleEvent")}rt(J,"composeEventHandlers");function Ho(e){if(!pr)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}rt(Ho,"getOwnerWindow");function tn(e){if(!pr)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}rt(tn,"getOwnerDocument");function mr(e,t=!1){const{activeElement:n}=tn(e);if(!n?.nodeName)return null;if(hr(n)&&n.contentDocument)return mr(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const o=tn(n).getElementById(r);if(o)return o}}return n}rt(mr,"getActiveElement");function hr(e){return e.tagName==="IFRAME"}rt(hr,"isFrame");var $o=Object.defineProperty,he=(e,t)=>$o(e,"name",{value:t,configurable:!0});function Wo(e,t){const n=a.createContext(t);n.displayName=e+"Context";const r=he(s=>{const{children:i,...c}=s,u=a.useMemo(()=>c,Object.values(c));return l.jsx(n.Provider,{value:u,children:i})},"Provider");r.displayName=e+"Provider";function o(s,i={}){const{optional:c=!1}=i,u=a.useContext(n);if(u)return u;if(t!==void 0)return t;if(!c)throw new Error(`\`${s}\` must be used within \`${e}\``)}return he(o,"useContext"),[r,o]}he(Wo,"createContext");function dt(e,t=[]){let n=[];function r(s,i){const c=a.createContext(i);c.displayName=s+"Context";const u=n.length;n=[...n,i];const f=he(d=>{const{scope:m,children:x,...v}=d,h=m?.[e]?.[u]||c,p=a.useMemo(()=>v,Object.values(v));return l.jsx(h.Provider,{value:p,children:x})},"Provider");f.displayName=s+"Provider";function g(d,m,x={}){const{optional:v=!1}=x,h=m?.[e]?.[u]||c,p=a.useContext(h);if(p)return p;if(i!==void 0)return i;if(!v)throw new Error(`\`${d}\` must be used within \`${s}\``)}return he(g,"useContext"),[f,g]}he(r,"createContext");const o=he(()=>{const s=n.map(i=>a.createContext(i));return he(function(c){const u=c?.[e]||s;return a.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])},"useScope")},"createScope");return o.scopeName=e,[r,vr(o,...t)]}he(dt,"createContextScope");function vr(...e){const t=e[0];if(e.length===1)return t;const n=he(()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return he(function(s){const i=r.reduce((c,{useScope:u,scopeName:f})=>{const d=u(s)[`__scope${f}`];return{...c,...d}},{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}he(vr,"composeContextScopes");var Ko=Object.defineProperty,te=(e,t)=>Ko(e,"name",{value:t,configurable:!0});function gr(e){const t=e+"CollectionProvider",[n,r]=dt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=te(h=>{const{scope:p,children:w}=h,S=a.useRef(null),b=a.useRef(new Map).current;return l.jsx(o,{scope:p,itemMap:b,collectionRef:S,children:w})},"CollectionProvider");i.displayName=t;const c=e+"CollectionSlot",u=tt(c),f=a.forwardRef((h,p)=>{const{scope:w,children:S}=h,b=s(c,w),y=ne(p,b.collectionRef);return l.jsx(u,{ref:y,children:S})});f.displayName=c;const g=e+"CollectionItemSlot",d="data-radix-collection-item",m=tt(g),x=a.forwardRef((h,p)=>{const{scope:w,children:S,...b}=h,y=a.useRef(null),C=ne(p,y),P=s(g,w);return a.useEffect(()=>(P.itemMap.set(y,{ref:y,...b}),()=>{P.itemMap.delete(y)})),l.jsx(m,{[d]:"",ref:C,children:S})});x.displayName=g;function v(h){const p=s(e+"CollectionConsumer",h);return a.useCallback(()=>{const S=p.collectionRef.current;if(!S)return[];const b=Array.from(S.querySelectorAll(`[${d}]`));return Array.from(p.itemMap.values()).sort((P,O)=>b.indexOf(P.ref.current)-b.indexOf(O.ref.current))},[p.collectionRef,p.itemMap])}return te(v,"useCollection"),[{Provider:i,Slot:f,ItemSlot:x},v,r]}te(gr,"createCollection");var kn=new WeakMap,G,pe,Wt=(pe=class extends Map{constructor(n){super(n);jn(this,G);$t(this,G,[...super.keys()]),kn.set(this,!0)}set(n,r){return kn.get(this)&&(this.has(n)?oe(this,G)[oe(this,G).indexOf(n)]=n:oe(this,G).push(n)),super.set(n,r),this}insert(n,r,o){const s=this.has(r),i=oe(this,G).length,c=vn(n);let u=c>=0?c:i+c;const f=u<0||u>=i?-1:u;if(f===this.size||s&&f===this.size-1||f===-1)return this.set(r,o),this;const g=this.size+(s?0:1);c<0&&u++;const d=[...oe(this,G)];let m,x=!1;for(let v=u;v<g;v++)if(u===v){let h=d[v];d[v]===r&&(h=d[v+1]),s&&this.delete(r),m=this.get(h),this.set(r,o)}else{!x&&d[v-1]===r&&(x=!0);const h=d[x?v:v-1],p=m;m=this.get(h),this.delete(h),this.set(h,p)}return this}with(n,r,o){const s=new pe(this);return s.insert(n,r,o),s}before(n){const r=oe(this,G).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,o){const s=oe(this,G).indexOf(n);return s===-1?this:this.insert(s,r,o)}after(n){let r=oe(this,G).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,o){const s=oe(this,G).indexOf(n);return s===-1?this:this.insert(s+1,r,o)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return $t(this,G,[]),super.clear()}delete(n){const r=super.delete(n);return r&&oe(this,G).splice(oe(this,G).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=Ct(oe(this,G),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=Ct(oe(this,G),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return oe(this,G).indexOf(n)}keyAt(n){return Ct(oe(this,G),n)}from(n,r){const o=this.indexOf(n);if(o===-1)return;let s=o+r;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.at(s)}keyFrom(n,r){const o=this.indexOf(n);if(o===-1)return;let s=o+r;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.keyAt(s)}find(n,r){let o=0;for(const s of this){if(Reflect.apply(n,r,[s,o,this]))return s;o++}}findIndex(n,r){let o=0;for(const s of this){if(Reflect.apply(n,r,[s,o,this]))return o;o++}return-1}filter(n,r){const o=[];let s=0;for(const i of this)Reflect.apply(n,r,[i,s,this])&&o.push(i),s++;return new pe(o)}map(n,r){const o=[];let s=0;for(const i of this)o.push([i[0],Reflect.apply(n,r,[i,s,this])]),s++;return new pe(o)}reduce(...n){const[r,o]=n;let s=0,i=o??this.at(0);for(const c of this)s===0&&n.length===1?i=c:i=Reflect.apply(r,this,[i,c,s,this]),s++;return i}reduceRight(...n){const[r,o]=n;let s=o??this.at(-1);for(let i=this.size-1;i>=0;i--){const c=this.at(i);i===this.size-1&&n.length===1?s=c:s=Reflect.apply(r,this,[s,c,i,this])}return s}toSorted(n){const r=[...this.entries()].sort(n);return new pe(r)}toReversed(){const n=new pe;for(let r=this.size-1;r>=0;r--){const o=this.keyAt(r),s=this.get(o);n.set(o,s)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new pe(r)}slice(n,r){const o=new pe;let s=this.size-1;if(n===void 0)return o;n<0&&(n=n+this.size),r!==void 0&&r>0&&(s=r-1);for(let i=n;i<=s;i++){const c=this.keyAt(i),u=this.get(c);o.set(c,u)}return o}every(n,r){let o=0;for(const s of this){if(!Reflect.apply(n,r,[s,o,this]))return!1;o++}return!0}some(n,r){let o=0;for(const s of this){if(Reflect.apply(n,r,[s,o,this]))return!0;o++}return!1}},G=new WeakMap,te(pe,"OrderedDict"),pe);function Ct(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=xr(e,t);return n===-1?void 0:e[n]}te(Ct,"at");function xr(e,t){const n=e.length,r=vn(t),o=r>=0?r:n+r;return o<0||o>=n?-1:o}te(xr,"toSafeIndex");function vn(e){return e!==e||e===0?0:Math.trunc(e)}te(vn,"toSafeInteger");function Xo(e){const t=e+"CollectionProvider",[n,r]=dt(t),[o,s]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Wt,setItemMap:te(()=>{},"setItemMap")}),i=te(({state:b,...y})=>b?l.jsx(u,{...y,state:b}):l.jsx(c,{...y}),"CollectionProvider");i.displayName=t;const c=te(b=>{const y=p();return l.jsx(u,{...b,state:y})},"CollectionInit");c.displayName=t+"Init";const u=te(b=>{const{scope:y,children:C,state:P}=b,O=a.useRef(null),[T,N]=a.useState(null),I=ne(O,N),[F,A]=P;return a.useEffect(()=>{if(!T)return;const _=wr(()=>{});return _.observe(T,{childList:!0,subtree:!0}),()=>{_.disconnect()}},[T]),l.jsx(o,{scope:y,itemMap:F,setItemMap:A,collectionRef:I,collectionRefObject:O,collectionElement:T,children:C})},"CollectionProviderImpl");u.displayName=t+"Impl";const f=e+"CollectionSlot",g=tt(f),d=a.forwardRef((b,y)=>{const{scope:C,children:P}=b,O=s(f,C),T=ne(y,O.collectionRef);return l.jsx(g,{ref:T,children:P})});d.displayName=f;const m=e+"CollectionItemSlot",x="data-radix-collection-item",v=tt(m),h=a.forwardRef((b,y)=>{const{scope:C,children:P,...O}=b,T=a.useRef(null),[N,I]=a.useState(null),F=ne(y,T,I),A=s(m,C),{setItemMap:_}=A,L=a.useRef(O);yr(L.current,O)||(L.current=O);const H=L.current;return a.useEffect(()=>{const k=H;return _(M=>N?M.has(N)?M.set(N,{...k,element:N}).toSorted(nn):(M.set(N,{...k,element:N}),M.toSorted(nn)):M),()=>{_(M=>!N||!M.has(N)?M:(M.delete(N),new Wt(M)))}},[N,H,_]),l.jsx(v,{[x]:"",ref:F,children:P})});h.displayName=m;function p(){return a.useState(new Wt)}te(p,"useInitCollection");function w(b){const{itemMap:y}=s(e+"CollectionConsumer",b);return y}return te(w,"useCollection"),[{Provider:i,Slot:d,ItemSlot:h},{createCollectionScope:r,useCollection:w,useInitCollection:p}]}te(Xo,"createCollection");function yr(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||e[o]!==t[o])return!1;return!0}te(yr,"shallowEqual");function br(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}te(br,"isElementPreceding");function nn(e,t){return!e[1].element||!t[1].element?0:br(e[1].element,t[1].element)?-1:1}te(nn,"sortByDocumentPosition");function wr(e){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){e();return}})}te(wr,"getChildListObserver");var zo=Object.defineProperty,Yo=(e,t)=>zo(e,"name",{value:t,configurable:!0}),Go=a.createContext(void 0);function Sr(e){const t=a.useContext(Go);return e||t||"ltr"}Yo(Sr,"useDirection");var qo=Object.defineProperty,Zo=(e,t)=>qo(e,"name",{value:t,configurable:!0}),Qo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],le=Qo.reduce((e,t)=>{const n=tt(`Primitive.${t}`),r=a.forwardRef((o,s)=>{const{asChild:i,...c}=o,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(u,{...c,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Er(e,t){e&&ut.flushSync(()=>e.dispatchEvent(t))}Zo(Er,"dispatchDiscreteCustomEvent");var Jo=Object.defineProperty,es=(e,t)=>Jo(e,"name",{value:t,configurable:!0});function Se(e){const t=a.useRef(e);return a.useEffect(()=>{t.current=e}),a.useMemo(()=>((...n)=>t.current?.(...n)),[])}es(Se,"useCallbackRef");var ts=Object.defineProperty,ee=(e,t)=>ts(e,"name",{value:t,configurable:!0}),rn="dismissableLayer.update",ns="dismissableLayer.pointerDownOutside",rs="dismissableLayer.focusOutside",Mn,Cr=a.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),os=a.forwardRef(ee(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:c,onInteractOutside:u,onDismiss:f,...g}=t,d=a.useContext(Cr),[m,x]=a.useState(null),v=m?.ownerDocument??globalThis?.document,[,h]=a.useState({}),p=ne(n,x),w=Array.from(d.layers),[S]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=S?w.indexOf(S):-1,y=m?w.indexOf(m):-1,C=d.layersWithOutsidePointerEventsDisabled.size>0,P=y>=b,O=a.useRef(!1),T=Pr(A=>{i?.(A),u?.(A),A.defaultPrevented||f?.()},{ownerDocument:v,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:O,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:a.useCallback(A=>{if(!(A instanceof Node))return!1;const _=[...d.branches].some(L=>L.contains(A));return P&&!_},[d.branches,P])}),N=Or(A=>{if(o&&O.current)return;const _=A.target;[...d.branches].some(H=>H.contains(_))||(c?.(A),u?.(A),A.defaultPrevented||f?.())},v),I=m?y===w.length-1:!1,F=Se(A=>{A.key==="Escape"&&(s?.(A),!A.defaultPrevented&&f&&(A.preventDefault(),f()))});return a.useEffect(()=>{if(I)return v.addEventListener("keydown",F,{capture:!0}),()=>v.removeEventListener("keydown",F,{capture:!0})},[v,I,F]),a.useEffect(()=>{if(m)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Mn=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),on(),()=>{r&&(d.layersWithOutsidePointerEventsDisabled.delete(m),d.layersWithOutsidePointerEventsDisabled.size===0&&(v.body.style.pointerEvents=Mn))}},[m,v,r,d]),a.useEffect(()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),on())},[m,d]),a.useEffect(()=>{const A=ee(()=>h({}),"handleUpdate");return document.addEventListener(rn,A),()=>document.removeEventListener(rn,A)},[]),l.jsx(le.div,{...g,ref:p,style:{pointerEvents:C?P?"auto":"none":void 0,...t.style},onFocusCapture:J(t.onFocusCapture,N.onFocusCapture),onBlurCapture:J(t.onBlurCapture,N.onBlurCapture),onPointerDownCapture:J(t.onPointerDownCapture,T.onPointerDownCapture)})},"DismissableLayer"));function ss(){const e=a.useContext(Cr),[t,n]=a.useState(null);return a.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}ee(ss,"useDismissableLayerSurface");var is=ee(()=>!0,"IS_TRUE");function Pr(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:s,shouldHandlePointerDownOutside:i=is}=t,c=Se(e),u=a.useRef(!1),f=a.useRef(!1),g=a.useRef(new Map),d=a.useRef(()=>{});return a.useEffect(()=>{function m(){f.current=!1,o.current=!1,g.current.clear()}ee(m,"resetOutsideInteraction");function x(){return Array.from(g.current.values()).some(Boolean)}ee(x,"isOutsideInteractionIntercepted");function v(b){if(!f.current)return;const y=b.target;y instanceof Node&&[...s].some(P=>P.contains(y))||g.current.set(b.type,!0),b.type==="click"&&window.setTimeout(()=>{f.current&&d.current()},0)}ee(v,"handleInteractionCapture");function h(b){f.current&&g.current.set(b.type,!1)}ee(h,"handleInteractionBubble");const p=ee(b=>{if(b.target&&!u.current){let y=function(){n.removeEventListener("click",d.current);const P=x();m(),P||gn(ns,c,C,{discrete:!0})};if(ee(y,"handleAndDispatchPointerDownOutsideEvent"),!i(b.target)){n.removeEventListener("click",d.current),m(),u.current=!1;return}const C={originalEvent:b};f.current=!0,o.current=r&&b.button===0,g.current.clear(),!r||b.button!==0?y():(n.removeEventListener("click",d.current),d.current=y,n.addEventListener("click",d.current,{once:!0}))}else n.removeEventListener("click",d.current),m();u.current=!1},"handlePointerDown"),w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const b of w)n.addEventListener(b,v,!0),n.addEventListener(b,h);const S=window.setTimeout(()=>{n.addEventListener("pointerdown",p)},0);return()=>{window.clearTimeout(S),n.removeEventListener("pointerdown",p),n.removeEventListener("click",d.current);for(const b of w)n.removeEventListener(b,v,!0),n.removeEventListener(b,h)}},[n,c,r,o,s,i]),{onPointerDownCapture:ee(()=>u.current=!0,"onPointerDownCapture")}}ee(Pr,"usePointerDownOutside");function Or(e,t=globalThis?.document){const n=Se(e),r=a.useRef(!1);return a.useEffect(()=>{const o=ee(s=>{s.target&&!r.current&&gn(rs,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:ee(()=>r.current=!0,"onFocusCapture"),onBlurCapture:ee(()=>r.current=!1,"onBlurCapture")}}ee(Or,"useFocusOutside");function on(){const e=new CustomEvent(rn);document.dispatchEvent(e)}ee(on,"dispatchUpdate");function gn(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Er(o,s):o.dispatchEvent(s)}ee(gn,"handleAndDispatchCustomEvent");var cs=Object.defineProperty,xn=(e,t)=>cs(e,"name",{value:t,configurable:!0}),mt=0,We=null;function as(e){return yn(),e.children}xn(as,"FocusGuards");function yn(){a.useEffect(()=>{We||(We={start:sn(),end:sn()});const{start:e,end:t}=We;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),mt++,()=>{mt===1&&(We?.start.remove(),We?.end.remove(),We=null),mt=Math.max(0,mt-1)}},[])}xn(yn,"useFocusGuards");function sn(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}xn(sn,"createFocusGuard");var ls=Object.defineProperty,ce=(e,t)=>ls(e,"name",{value:t,configurable:!0}),Kt="focusScope.autoFocusOnMount",Xt="focusScope.autoFocusOnUnmount",Fn={bubbles:!1,cancelable:!0},us=a.forwardRef(ce(function(t,n){const{loop:r=!1,trapped:o=!1,onMountAutoFocus:s,onUnmountAutoFocus:i,...c}=t,[u,f]=a.useState(null),g=Se(s),d=Se(i),m=a.useRef(null),x=ne(n,f),v=a.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;a.useEffect(()=>{if(o){let p=function(y){if(v.paused||!u)return;const C=y.target;u.contains(C)?m.current=C:Pe(m.current,{select:!0})},w=function(y){if(v.paused||!u)return;const C=y.relatedTarget;C!==null&&(u.contains(C)||Pe(m.current,{select:!0}))},S=function(y){if(document.activeElement===document.body)for(const P of y)P.removedNodes.length>0&&Pe(u)};ce(p,"handleFocusIn"),ce(w,"handleFocusOut"),ce(S,"handleMutations"),document.addEventListener("focusin",p),document.addEventListener("focusout",w);const b=new MutationObserver(S);return u&&b.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",w),b.disconnect()}}},[o,u,v.paused]),a.useEffect(()=>{if(u){Un.add(v);const p=document.activeElement;if(!u.contains(p)){const S=new CustomEvent(Kt,Fn);u.addEventListener(Kt,g),u.dispatchEvent(S),S.defaultPrevented||(Rr(Ir(bn(u)),{select:!0}),document.activeElement===p&&Pe(u))}return()=>{u.removeEventListener(Kt,g),setTimeout(()=>{const S=new CustomEvent(Xt,Fn);u.addEventListener(Xt,d),u.dispatchEvent(S),S.defaultPrevented||Pe(p??document.body,{select:!0}),u.removeEventListener(Xt,d),Un.remove(v)},0)}}},[u,g,d,v]);const h=a.useCallback(p=>{if(!r&&!o||v.paused)return;const w=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,S=document.activeElement;if(w&&S){const b=p.currentTarget,[y,C]=_r(b);y&&C?!p.shiftKey&&S===C?(p.preventDefault(),r&&Pe(y,{select:!0})):p.shiftKey&&S===y&&(p.preventDefault(),r&&Pe(C,{select:!0})):S===b&&p.preventDefault()}},[r,o,v.paused]);return l.jsx(le.div,{tabIndex:-1,...c,ref:x,onKeyDown:h})},"FocusScope"));function Rr(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pe(r,{select:t}),document.activeElement!==n)return}ce(Rr,"focusFirst");function _r(e){const t=bn(e),n=cn(t,e),r=cn(t.reverse(),e);return[n,r]}ce(_r,"getTabbableEdges");function bn(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ce(r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}ce(bn,"getTabbableCandidates");function cn(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Nr(r,{upTo:t})))return r}ce(cn,"findVisible");function Nr(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}ce(Nr,"isHidden");function Tr(e){return e instanceof HTMLInputElement&&"select"in e}ce(Tr,"isSelectableInput");function Pe(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Tr(e)&&t&&e.select()}}ce(Pe,"focus");var Un=Ar();function Ar(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=an(e,t),e.unshift(t)},remove(t){e=an(e,t),e[0]?.resume()}}}ce(Ar,"createFocusScopesStack");function an(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}ce(an,"arrayRemove");function Ir(e){return e.filter(t=>t.tagName!=="A")}ce(Ir,"removeLinks");var ae=globalThis?.document?a.useLayoutEffect:()=>{},ds=Object.defineProperty,fs=(e,t)=>ds(e,"name",{value:t,configurable:!0}),ps=Dt[" useId ".trim().toString()]||(()=>{}),ms=0;function wn(e){const[t,n]=a.useState(ps());return ae(()=>{e||n(r=>r??String(ms++))},[e]),e||(t?`radix-${t}`:"")}fs(wn,"useId");const hs=["top","right","bottom","left"],De=Math.min,Oe=Math.max,_t=Math.round,ht=Math.floor,Re=e=>({x:e,y:e}),vs={left:"right",right:"left",bottom:"top",top:"bottom"};function Dr(e,t,n){return Oe(e,De(t,n))}function _e(e,t){return typeof e=="function"?e(t):e}function Le(e){return e.split("-")[0]}function ot(e){return e.split("-")[1]}function Sn(e){return e==="x"?"y":"x"}function En(e){return e==="y"?"height":"width"}function we(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Cn(e){return Sn(we(e))}function gs(e,t,n){n===void 0&&(n=!1);const r=ot(e),o=Cn(e),s=En(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Nt(i)),[i,Nt(i)]}function xs(e){const t=Nt(e);return[ln(e),t,ln(t)]}function ln(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Bn=["left","right"],Vn=["right","left"],ys=["top","bottom"],bs=["bottom","top"];function ws(e,t,n){switch(e){case"top":case"bottom":return n?t?Vn:Bn:t?Bn:Vn;case"left":case"right":return t?ys:bs;default:return[]}}function Ss(e,t,n,r){const o=ot(e);let s=ws(Le(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ln)))),s}function Nt(e){const t=Le(e);return vs[t]+e.slice(t.length)}function Es(e){var t,n,r,o;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}function Lr(e){return typeof e!="number"?Es(e):{top:e,right:e,bottom:e,left:e}}function Tt(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Hn(e,t,n){let{reference:r,floating:o}=e;const s=we(t),i=Cn(t),c=En(i),u=Le(t),f=s==="y",g=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,m=r[c]/2-o[c]/2;let x;switch(u){case"top":x={x:g,y:r.y-o.height};break;case"bottom":x={x:g,y:r.y+r.height};break;case"right":x={x:r.x+r.width,y:d};break;case"left":x={x:r.x-o.width,y:d};break;default:x={x:r.x,y:r.y}}const v=ot(t);return v&&(x[i]+=m*(v==="end"?1:-1)*(n&&f?-1:1)),x}async function Cs(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:c,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:d="floating",altBoundary:m=!1,padding:x=0}=_e(t,e),v=Lr(x),p=c[m?d==="floating"?"reference":"floating":d],w=Tt(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(p)))==null||n?p:p.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:g,strategy:u})),S=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),y=await(s.isElement==null?void 0:s.isElement(b))&&await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1},C=Tt(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:S,offsetParent:b,strategy:u}):S);return{top:(w.top-C.top+v.top)/y.y,bottom:(C.bottom-w.bottom+v.bottom)/y.y,left:(w.left-C.left+v.left)/y.x,right:(C.right-w.right+v.right)/y.x}}const Ps=50,Os=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Cs},u=await(i.isRTL==null?void 0:i.isRTL(t));let f=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:g,y:d}=Hn(f,r,u),m=r,x=0;const v={};for(let h=0;h<s.length;h++){const p=s[h];if(!p)continue;const{name:w,fn:S}=p,{x:b,y,data:C,reset:P}=await S({x:g,y:d,initialPlacement:r,placement:m,strategy:o,middlewareData:v,rects:f,platform:c,elements:{reference:e,floating:t}});g=b??g,d=y??d,v[w]={...v[w],...C},P&&x<Ps&&(x++,typeof P=="object"&&(P.placement&&(m=P.placement),P.rects&&(f=P.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):P.rects),{x:g,y:d}=Hn(f,m,u)),h=-1)}return{x:g,y:d,placement:m,strategy:o,middlewareData:v}},Rs=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:c,middlewareData:u}=t,{element:f,padding:g=0}=_e(e,t)||{};if(f==null)return{};const d=Lr(g),m={x:n,y:r},x=Cn(o),v=En(x),h=await i.getDimensions(f),p=x==="y",w=p?"top":"left",S=p?"bottom":"right",b=p?"clientHeight":"clientWidth",y=s.reference[v]+s.reference[x]-m[x]-s.floating[v],C=m[x]-s.reference[x],P=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f));let O=P?P[b]:0;(!O||!await(i.isElement==null?void 0:i.isElement(P)))&&(O=c.floating[b]||s.floating[v]);const T=y/2-C/2,N=O/2-h[v]/2-1,I=De(d[w],N),F=De(d[S],N),A=O-h[v]-F,_=O/2-h[v]/2+T,L=Dr(I,_,A),H=!u.arrow&&ot(o)!=null&&_!==L&&s.reference[v]/2-(_<I?I:F)-h[v]/2<0,k=H?_<I?_-I:_-A:0;return{[x]:m[x]+k,data:{[x]:L,centerOffset:_-L-k,...H&&{alignmentOffset:k}},reset:H}}}),_s=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:c,platform:u,elements:f}=t,{mainAxis:g=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:h=!0,...p}=_e(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=Le(o),S=we(c),b=Le(c)===c,y=await(u.isRTL==null?void 0:u.isRTL(f.floating)),C=m||(b||!h?[Nt(c)]:xs(c)),P=v!=="none";!m&&P&&C.push(...Ss(c,h,v,y));const O=[c,...C],T=await u.detectOverflow(t,p),N=[];let I=((r=s.flip)==null?void 0:r.overflows)||[];if(g&&N.push(T[w]),d){const L=gs(o,i,y);N.push(T[L[0]],T[L[1]])}if(I=[...I,{placement:o,overflows:N}],!N.every(L=>L<=0)){var F,A;const L=(((F=s.flip)==null?void 0:F.index)||0)+1,H=O[L];if(H&&(!(d==="alignment"?S!==we(H):!1)||I.every(R=>we(R.placement)===S?R.overflows[0]>0:!0)))return{data:{index:L,overflows:I},reset:{placement:H}};let k=(A=I.filter(M=>M.overflows[0]<=0).sort((M,R)=>M.overflows[1]-R.overflows[1])[0])==null?void 0:A.placement;if(!k)switch(x){case"bestFit":{var _;const M=(_=I.filter(R=>{if(P){const U=we(R.placement);return U===S||U==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(U=>U>0).reduce((U,B)=>U+B,0)]).sort((R,U)=>R[1]-U[1])[0])==null?void 0:_[0];M&&(k=M);break}case"initialPlacement":k=c;break}if(o!==k)return{reset:{placement:k}}}return{}}}};function $n(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Wn(e){return hs.some(t=>e[t]>=0)}const Ns=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=_e(e,t);switch(o){case"referenceHidden":{const i=await r.detectOverflow(t,{...s,elementContext:"reference"}),c=$n(i,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Wn(c)}}}case"escaped":{const i=await r.detectOverflow(t,{...s,altBoundary:!0}),c=$n(i,n.floating);return{data:{escapedOffsets:c,escaped:Wn(c)}}}default:return{}}}}},jr=new Set(["left","top"]);async function Ts(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Le(n),c=ot(n),u=we(n)==="y",f=jr.has(i)?-1:1,g=s&&u?-1:1,d=_e(t,e);let{mainAxis:m,crossAxis:x,alignmentAxis:v}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof v=="number"&&(x=c==="end"?v*-1:v),u?{x:x*g,y:m*f}:{x:m*f,y:x*g}}const As=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:c}=t,u=await Ts(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:s+u.y,data:{...u,placement:i}}}}},Is=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:u={fn:S=>{let{x:b,y}=S;return{x:b,y}}},...f}=_e(e,t),g={x:n,y:r},d=await s.detectOverflow(t,f),m=we(o),x=Sn(m);let v=g[x],h=g[m];const p=(S,b)=>Dr(b+d[S==="y"?"top":"left"],b,b-d[S==="y"?"bottom":"right"]);i&&(v=p(x,v)),c&&(h=p(m,h));const w=u.fn({...t,[x]:v,[m]:h});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[x]:i,[m]:c}}}}}},Ds=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:o,y:s,placement:i,rects:c,middlewareData:u}=t,{offset:f=0,mainAxis:g=!0,crossAxis:d=!0}=_e(e,t),m={x:o,y:s},x=we(i),v=Sn(x);let h=m[v],p=m[x];const w=_e(f,t),S=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:(n=w.mainAxis)!=null?n:0,crossAxis:(r=w.crossAxis)!=null?r:0};if(g){const C=v==="y"?"height":"width",P=c.reference[v]-c.floating[C]+S.mainAxis,O=c.reference[v]+c.reference[C]-S.mainAxis;h<P?h=P:h>O&&(h=O)}if(d){var b,y;const C=v==="y"?"width":"height",P=jr.has(Le(i)),O=c.reference[x]-c.floating[C]+(P&&((b=u.offset)==null?void 0:b[x])||0)+(P?0:S.crossAxis),T=c.reference[x]+c.reference[C]+(P?0:((y=u.offset)==null?void 0:y[x])||0)-(P?S.crossAxis:0);p<O?p=O:p>T&&(p=T)}return{[v]:h,[x]:p}}}},Ls=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:s}=t,{apply:i=()=>{},...c}=_e(e,t),u=await o.detectOverflow(t,c),f=Le(n),g=ot(n),d=we(n)==="y",{width:m,height:x}=r.floating;let v,h;f==="top"||f==="bottom"?(v=f,h=g===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(h=f,v=g==="end"?"top":"bottom");const p=x-u.top-u.bottom,w=m-u.left-u.right,S=De(x-u[v],p),b=De(m-u[h],w),y=t.middlewareData.shift,C=!y;let P=S,O=b;y!=null&&y.enabled.x&&(O=w),y!=null&&y.enabled.y&&(P=p),C&&!g&&(d?O=m-2*Oe(u.left,u.right):P=x-2*Oe(u.top,u.bottom)),await i({...t,availableWidth:O,availableHeight:P});const T=await o.getDimensions(s.floating);return m!==T.width||x!==T.height?{reset:{rects:!0}}:{}}}};function Lt(){return typeof window<"u"}function st(e){return kr(e)?(e.nodeName||"").toLowerCase():"#document"}function fe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Te(e){var t;return(t=(kr(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function kr(e){return Lt()?e instanceof Node||e instanceof fe(e).Node:!1}function Ee(e){return Lt()?e instanceof Element||e instanceof fe(e).Element:!1}function je(e){return Lt()?e instanceof HTMLElement||e instanceof fe(e).HTMLElement:!1}function Kn(e){return!Lt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fe(e).ShadowRoot}function jt(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ce(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function js(e){return/^(table|td|th)$/.test(st(e))}function kt(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const ks=/transform|translate|scale|rotate|perspective|filter/,Ms=/paint|layout|strict|content/,Me=e=>!!e&&e!=="none";let zt;function Pn(e){const t=Ee(e)?Ce(e):e;return Me(t.transform)||Me(t.translate)||Me(t.scale)||Me(t.rotate)||Me(t.perspective)||!On()&&(Me(t.backdropFilter)||Me(t.filter))||ks.test(t.willChange||"")||Ms.test(t.contain||"")}function Fs(e){let t=Be(e);for(;je(t)&&!at(t);){if(Pn(t))return t;if(kt(t))return null;t=Be(t)}return null}function On(){return zt==null&&(zt=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),zt}function at(e){return/^(html|body|#document)$/.test(st(e))}function Ce(e){return fe(e).getComputedStyle(e)}function Mt(e){return Ee(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Be(e){if(st(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Kn(e)&&e.host||Te(e);return Kn(t)?t.host:t}function Mr(e){const t=Be(e);return at(t)?(e.ownerDocument||e).body:je(t)&&jt(t)?t:Mr(t)}function lt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Mr(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=fe(o);if(s){const c=un(i);return t.concat(i,i.visualViewport||[],jt(o)?o:[],c&&n?lt(c):[])}else return t.concat(o,lt(o,[],n))}function un(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fr(e){const t=Ce(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=je(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,c=_t(n)!==s||_t(r)!==i;return c&&(n=s,r=i),{width:n,height:r,$:c}}function Rn(e){return Ee(e)?e:e.contextElement}function Je(e){const t=Rn(e);if(!je(t))return Re(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Fr(t);let i=(s?_t(n.width):n.width)/r,c=(s?_t(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Us=Re(0);function Ur(e){const t=fe(e);return!On()||!t.visualViewport?Us:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bs(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===fe(e)}function Ve(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Rn(e);let i=Re(1);t&&(r?Ee(r)&&(i=Je(r)):i=Je(e));const c=Bs(s,n,r)?Ur(s):Re(0);let u=(o.left+c.x)/i.x,f=(o.top+c.y)/i.y,g=o.width/i.x,d=o.height/i.y;if(s&&r){const m=fe(s),x=Ee(r)?fe(r):r;let v=m,h=un(v);for(;h&&x!==v;){const p=Je(h),w=h.getBoundingClientRect(),S=Ce(h),b=w.left+(h.clientLeft+parseFloat(S.paddingLeft))*p.x,y=w.top+(h.clientTop+parseFloat(S.paddingTop))*p.y;u*=p.x,f*=p.y,g*=p.x,d*=p.y,u+=b,f+=y,v=fe(h),h=un(v)}}return Tt({width:g,height:d,x:u,y:f})}function Ft(e,t){const n=Mt(e).scrollLeft;return t?t.left+n:Ve(Te(e)).left+n}function Br(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ft(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Vs(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Te(r),c=t?kt(t.floating):!1;if(r===i||c&&s)return n;let u={scrollLeft:0,scrollTop:0},f=Re(1);const g=Re(0),d=je(r);if((d||!s)&&((st(r)!=="body"||jt(i))&&(u=Mt(r)),d)){const x=Ve(r);f=Je(r),g.x=x.x+r.clientLeft,g.y=x.y+r.clientTop}const m=i&&!d&&!s?Br(i,u):Re(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+g.x+m.x,y:n.y*f.y-u.scrollTop*f.y+g.y+m.y}}function Hs(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function $s(e){const t=Mt(e),n=e.ownerDocument.body,r=Oe(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=Oe(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+Ft(e);const i=-t.scrollTop;return Ce(n).direction==="rtl"&&(s+=Oe(e.clientWidth,n.clientWidth)-r),{width:r,height:o,x:s,y:i}}const Ws=25;function Ks(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",o=fe(e),s=Te(e),i=o.visualViewport;let c=s.clientWidth,u=s.clientHeight,f=0,g=0;if(i){const m=!On()||t==="fixed";r?m||(f=-i.offsetLeft,g=-i.offsetTop):(c=i.width,u=i.height,m&&(f=i.offsetLeft,g=i.offsetTop))}if(Ft(s)<=0){const m=s.ownerDocument,x=m.body,v=getComputedStyle(x),h=m.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,p=Math.abs(s.clientWidth-x.clientWidth-h),w=getComputedStyle(s).scrollbarGutter==="stable both-edges"?p/2:p;w<=Ws&&(c-=w)}return{width:c,height:u,x:f,y:g}}function Xs(e,t){const n=Ve(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Je(e),i=e.clientWidth*s.x,c=e.clientHeight*s.y,u=o*s.x,f=r*s.y;return{width:i,height:c,x:u,y:f}}function Xn(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Ks(e,n,t);else if(t==="document")r=$s(Te(e));else if(Ee(t))r=Xs(t,n);else{const o=Ur(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Tt(r)}function zs(e,t){const n=t.get(e);if(n)return n;let r=lt(e,[],!1).filter(c=>Ee(c)&&st(c)!=="body"),o=null;const s=Ce(e).position==="fixed";let i=s?Be(e):e;for(;Ee(i)&&!at(i);){const c=Ce(i),u=Pn(i),f=o?o.position:s?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&c.position==="static")?r=r.filter(d=>d!==i):o=c,i=Be(i)}return t.set(e,r),r}function Ys(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?kt(t)?[]:zs(t,this._c):[].concat(n),r],c=Xn(t,i[0],o);let u=c.top,f=c.right,g=c.bottom,d=c.left;for(let m=1;m<i.length;m++){const x=Xn(t,i[m],o);u=Oe(x.top,u),f=De(x.right,f),g=De(x.bottom,g),d=Oe(x.left,d)}return{width:f-d,height:g-u,x:d,y:u}}function Gs(e){const{width:t,height:n}=Fr(e);return{width:t,height:n}}function qs(e,t,n){const r=je(t),o=Te(t),s=n==="fixed",i=Ve(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const u=Re(0);if((r||!s)&&((st(t)!=="body"||jt(o))&&(c=Mt(t)),r)){const m=Ve(t,!0,s,t);u.x=m.x+t.clientLeft,u.y=m.y+t.clientTop}!r&&o&&(u.x=Ft(o));const f=o&&!r&&!s?Br(o,c):Re(0),g=i.left+c.scrollLeft-u.x-f.x,d=i.top+c.scrollTop-u.y-f.y;return{x:g,y:d,width:i.width,height:i.height}}function Yt(e){return Ce(e).position==="static"}function zn(e,t){if(!je(e)||Ce(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Te(e)===n&&(n=n.ownerDocument.body),n}function Vr(e,t){const n=fe(e);if(kt(e))return n;if(!je(e)){let o=Be(e);for(;o&&!at(o);){if(Ee(o)&&!Yt(o))return o;o=Be(o)}return n}let r=zn(e,t);for(;r&&js(r)&&Yt(r);)r=zn(r,t);return r&&at(r)&&Yt(r)&&!Pn(r)?n:r||Fs(e)||n}const Zs=async function(e){const t=this.getOffsetParent||Vr,n=this.getDimensions,r=await n(e.floating);return{reference:qs(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Qs(e){return Ce(e).direction==="rtl"}const Js={convertOffsetParentRelativeRectToViewportRelativeRect:Vs,getDocumentElement:Te,getClippingRect:Ys,getOffsetParent:Vr,getElementRects:Zs,getClientRects:Hs,getDimensions:Gs,getScale:Je,isElement:Ee,isRTL:Qs};function Hr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ei(e,t,n){let r=null,o;const s=Te(e);function i(){var g;clearTimeout(o),(g=r)==null||g.disconnect(),r=null}function c(g,d){g===void 0&&(g=!1),d===void 0&&(d=1),i();const m=e.getBoundingClientRect(),{left:x,top:v,width:h,height:p}=m;if(g||t(),!h||!p)return;const w=ht(v),S=ht(s.clientWidth-(x+h)),b=ht(s.clientHeight-(v+p)),y=ht(x),P={rootMargin:-w+"px "+-S+"px "+-b+"px "+-y+"px",threshold:Oe(0,De(1,d))||1};let O=!0;function T(N){const I=N[0].intersectionRatio;if(!Hr(m,e.getBoundingClientRect()))return c();if(I!==d){if(!O)return c();I?c(!1,I):o=setTimeout(()=>{c(!1,1e-7)},1e3)}O=!1}try{r=new IntersectionObserver(T,{...P,root:s.ownerDocument})}catch{r=new IntersectionObserver(T,P)}r.observe(e)}const u=fe(e),f=()=>c(n);return u.addEventListener("resize",f),c(!0),()=>{u.removeEventListener("resize",f),i()}}function ti(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=Rn(e),g=o||s?[...f?lt(f):[],...t?lt(t):[]]:[];g.forEach(w=>{o&&w.addEventListener("scroll",n),s&&w.addEventListener("resize",n)});const d=f&&c?ei(f,n,s):null;let m=-1,x=null;i&&(x=new ResizeObserver(w=>{let[S]=w;S&&S.target===f&&x&&t&&(x.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var b;(b=x)==null||b.observe(t)})),n()}),f&&!u&&x.observe(f),t&&x.observe(t));let v,h=u?Ve(e):null;u&&p();function p(){const w=Ve(e);h&&!Hr(h,w)&&n(),h=w,v=requestAnimationFrame(p)}return n(),()=>{var w;g.forEach(S=>{o&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),d?.(),(w=x)==null||w.disconnect(),x=null,u&&cancelAnimationFrame(v)}}const ni=As,ri=Is,oi=_s,si=Ls,ii=Ns,Yn=Rs,ci=Ds,ai=(e,t,n)=>{const r=new Map,o=n??{},s={...Js,...o.platform,_c:r};return Os(e,t,{...o,platform:s})};var li=typeof document<"u",ui=function(){},Pt=li?a.useLayoutEffect:ui;function At(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!At(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!At(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function $r(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Gn(e,t){const n=$r(e);return Math.round(t*n)/n}function Gt(e){const t=a.useRef(e);return Pt(()=>{t.current=e}),t}function di(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:c=!0,whileElementsMounted:u,open:f}=e,[g,d]=a.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,x]=a.useState(r);At(m,r)||x(r);const[v,h]=a.useState(null),[p,w]=a.useState(null),S=a.useCallback(R=>{R!==P.current&&(P.current=R,h(R))},[]),b=a.useCallback(R=>{R!==O.current&&(O.current=R,w(R))},[]),y=s||v,C=i||p,P=a.useRef(null),O=a.useRef(null),T=a.useRef(g),N=u!=null,I=Gt(u),F=Gt(o),A=Gt(f),_=a.useCallback(()=>{if(!P.current||!O.current)return;const R={placement:t,strategy:n,middleware:m};F.current&&(R.platform=F.current),ai(P.current,O.current,R).then(U=>{const B={...U,isPositioned:A.current!==!1};L.current&&!At(T.current,B)&&(T.current=B,ut.flushSync(()=>{d(B)}))})},[m,t,n,F,A]);Pt(()=>{f===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(R=>({...R,isPositioned:!1})))},[f]);const L=a.useRef(!1);Pt(()=>(L.current=!0,()=>{L.current=!1}),[]),Pt(()=>{if(y&&(P.current=y),C&&(O.current=C),y&&C){if(I.current)return I.current(y,C,_);_()}},[y,C,_,I,N]);const H=a.useMemo(()=>({reference:P,floating:O,setReference:S,setFloating:b}),[S,b]),k=a.useMemo(()=>({reference:y,floating:C}),[y,C]),M=a.useMemo(()=>{const R={position:n,left:0,top:0};if(!k.floating)return R;const U=Gn(k.floating,g.x),B=Gn(k.floating,g.y);return c?{...R,transform:"translate("+U+"px, "+B+"px)",...$r(k.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:B}},[n,c,k.floating,g.x,g.y]);return a.useMemo(()=>({...g,update:_,refs:H,elements:k,floatingStyles:M}),[g,_,H,k,M])}const fi=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Yn({element:r.current,padding:o}).fn(n):{}:r?Yn({element:r,padding:o}).fn(n):{}}}},pi=(e,t)=>{const n=ni(e);return{name:n.name,fn:n.fn,options:[e,t]}},mi=(e,t)=>{const n=ri(e);return{name:n.name,fn:n.fn,options:[e,t]}},hi=(e,t)=>({fn:ci(e).fn,options:[e,t]}),vi=(e,t)=>{const n=oi(e);return{name:n.name,fn:n.fn,options:[e,t]}},gi=(e,t)=>{const n=si(e);return{name:n.name,fn:n.fn,options:[e,t]}},xi=(e,t)=>{const n=ii(e);return{name:n.name,fn:n.fn,options:[e,t]}},yi=(e,t)=>{const n=fi(e);return{name:n.name,fn:n.fn,options:[e,t]}};var bi=Object.defineProperty,wi=(e,t)=>bi(e,"name",{value:t,configurable:!0});function Wr(e){const[t,n]=a.useState(void 0);return ae(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,c;if("borderBoxSize"in s){const u=s.borderBoxSize,f=Array.isArray(u)?u[0]:u;i=f.inlineSize,c=f.blockSize}else i=e.offsetWidth,c=e.offsetHeight;n({width:i,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}wi(Wr,"useSize");var Si=Object.defineProperty,Ie=(e,t)=>Si(e,"name",{value:t,configurable:!0}),Kr="Popper",[Xr,zr]=dt(Kr),[Ei,Yr]=Xr(Kr),Ci=Ie(e=>{const{__scopePopper:t,children:n}=e,[r,o]=a.useState(null),[s,i]=a.useState(void 0);return l.jsx(Ei,{scope:t,anchor:r,onAnchorChange:o,placementState:s,setPlacementState:i,children:n})},"Popper"),Pi="PopperAnchor",Oi=a.forwardRef(Ie(function(t,n){const{__scopePopper:r,virtualRef:o,...s}=t,i=Yr(Pi,r),c=a.useRef(null),u=i.onAnchorChange,f=a.useCallback(h=>{c.current=h,h&&u(h)},[u]),g=ne(n,f),d=a.useRef(null);a.useEffect(()=>{if(!o)return;const h=d.current;d.current=o.current,h!==d.current&&u(d.current)});const m=i.placementState&&Ut(i.placementState),x=m?.[0],v=m?.[1];return o?null:l.jsx(le.div,{"data-radix-popper-side":x,"data-radix-popper-align":v,...s,ref:g})},"PopperAnchor")),Gr="PopperContent",[Ri,wa]=Xr(Gr),_i=a.forwardRef(Ie(function(t,n){const{__scopePopper:r,side:o="bottom",sideOffset:s=0,align:i="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:f=!0,collisionBoundary:g=[],collisionPadding:d=0,sticky:m="partial",hideWhenDetached:x=!1,updatePositionStrategy:v="optimized",onPlaced:h,...p}=t,w=Yr(Gr,r),[S,b]=a.useState(null),y=ne(n,b),[C,P]=a.useState(null),O=Wr(C),T=O?.width??0,N=O?.height??0,I=o+(i!=="center"?"-"+i:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},A=Array.isArray(g)?g:[g],_=A.length>0,L={padding:F,boundary:A.filter(qr),altBoundary:_},{refs:H,floatingStyles:k,placement:M,isPositioned:R,middlewareData:U}=di({strategy:"fixed",placement:I,whileElementsMounted:Ie((...V)=>ti(...V,{animationFrame:v==="always"}),"whileElementsMounted"),elements:{reference:w.anchor},middleware:[pi({mainAxis:s+N,alignmentAxis:c}),f&&mi({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?hi():void 0,...L}),f&&vi({...L}),gi({...L,apply:Ie(({elements:V,rects:Q,availableWidth:W,availableHeight:K})=>{const{width:Y,height:ve}=Q.reference,de=V.floating.style;de.setProperty("--radix-popper-available-width",`${W}px`),de.setProperty("--radix-popper-available-height",`${K}px`),de.setProperty("--radix-popper-anchor-width",`${Y}px`),de.setProperty("--radix-popper-anchor-height",`${ve}px`)},"apply")}),C&&yi({element:C,padding:u}),Ni({arrowWidth:T,arrowHeight:N}),x&&xi({strategy:"referenceHidden",...L,boundary:_?L.boundary:void 0})]}),B=w.setPlacementState;ae(()=>(B(M),()=>{B(void 0)}),[M,B]);const[ue,X]=Ut(M),Z=Se(h);ae(()=>{R&&Z?.()},[R,Z]);const ie=U.arrow?.x,re=U.arrow?.y,q=U.arrow?.centerOffset!==0,[xe,D]=a.useState();return ae(()=>{S&&D(window.getComputedStyle(S).zIndex)},[S]),l.jsx("div",{ref:H.setFloating,"data-radix-popper-content-wrapper":"",style:{...k,transform:R?k.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:xe,"--radix-popper-transform-origin":[U.transformOrigin?.x,U.transformOrigin?.y].join(" "),...U.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:l.jsx(Ri,{scope:r,placedSide:ue,placedAlign:X,onArrowChange:P,arrowX:ie,arrowY:re,shouldHideArrow:q,children:l.jsx(le.div,{"data-side":ue,"data-align":X,...p,ref:y,style:{...p.style,animation:R?p.style?.animation:"none"}})})})},"PopperContent"));function qr(e){return e!==null}Ie(qr,"isNotNull");var Ni=Ie(e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[f,g]=Ut(n),d={start:"0%",center:"50%",end:"100%"}[g],m=(o.arrow?.x??0)+c/2,x=(o.arrow?.y??0)+u/2;let v="",h="";return f==="bottom"?(v=i?d:`${m}px`,h=`${-u}px`):f==="top"?(v=i?d:`${m}px`,h=`${r.floating.height+u}px`):f==="right"?(v=`${-u}px`,h=i?d:`${x}px`):f==="left"&&(v=`${r.floating.width+u}px`,h=i?d:`${x}px`),{data:{x:v,y:h}}}}),"transformOrigin");function Ut(e){const[t,n="center"]=e.split("-");return[t,n]}Ie(Ut,"getSideAndAlignFromPlacement");var Ti=Ci,Ai=Oi,Ii=_i,Di=Object.defineProperty,Li=(e,t)=>Di(e,"name",{value:t,configurable:!0}),ji=a.forwardRef(Li(function(t,n){const{container:r,...o}=t,[s,i]=a.useState(!1);ae(()=>i(!0),[]);const c=r||s&&globalThis?.document?.body;return c?ut.createPortal(l.jsx(le.div,{...o,ref:n}),c):null},"Portal")),ki=Object.defineProperty,Ne=(e,t)=>ki(e,"name",{value:t,configurable:!0});function Zr(e,t){return a.useReducer((n,r)=>t[n][r]??n,e)}Ne(Zr,"useStateMachine");var Mi=Ne(e=>{const{present:t,children:n}=e,r=Qr(t),o=typeof n=="function"?n({present:r.isPresent}):a.Children.only(n),s=Jr(r.ref,eo(o));return typeof n=="function"||r.isPresent?a.cloneElement(o,{ref:s}):null},"Presence");function Qr(e){const[t,n]=a.useState(),r=a.useRef(null),o=a.useRef(e),s=a.useRef("none"),i=a.useRef(void 0),c=e?"mounted":"unmounted",[u,f]=Zr(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return a.useEffect(()=>{u==="mounted"?(s.current=i.current??qe(r.current),i.current=void 0):s.current="none"},[u]),ae(()=>{const g=r.current,d=o.current;if(d!==e){const x=s.current,v=qe(g);e?(i.current=v,f("MOUNT")):v==="none"||g?.display==="none"?f("UNMOUNT"):f(d&&x!==v?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,f]),ae(()=>{if(t){let g;const d=t.ownerDocument.defaultView??window,m=Ne(v=>{const p=qe(r.current).includes(CSS.escape(v.animationName));if(v.target===t&&p&&(f("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",g=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},"handleAnimationEnd"),x=Ne(v=>{v.target===t&&(s.current=qe(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{d.clearTimeout(g),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:a.useCallback(g=>{if(g){const d=getComputedStyle(g);r.current=d,i.current=qe(d)}else r.current=null;n(g)},[])}}Ne(Qr,"usePresence");function dn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Ne(dn,"setRef");function Jr(...e){const t=a.useRef(e);return t.current=e,a.useCallback(n=>{const r=t.current;let o=!1;const s=r.map(i=>{const c=dn(i,n);return!o&&typeof c=="function"&&(o=!0),c});if(o)return()=>{for(let i=0;i<s.length;i++){const c=s[i];typeof c=="function"?c():dn(r[i],null)}}},[])}Ne(Jr,"useStableComposedRefs");function qe(e){return e?.animationName||"none"}Ne(qe,"getAnimationName");function eo(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Ne(eo,"getElementRef");var Fi=Object.defineProperty,Ui=(e,t)=>Fi(e,"name",{value:t,configurable:!0}),qn=Dt[" useEffectEvent ".trim().toString()],Zn=Dt[" useInsertionEffect ".trim().toString()];function to(e){if(typeof qn=="function")return qn(e);const t=a.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Zn=="function"?Zn(()=>{t.current=e}):ae(()=>{t.current=e}),a.useMemo(()=>((...n)=>t.current?.(...n)),[])}Ui(to,"useEffectEvent");var Bi=Object.defineProperty,ft=(e,t)=>Bi(e,"name",{value:t,configurable:!0}),Vi=Dt[" useInsertionEffect ".trim().toString()]||ae;function fn({prop:e,defaultProp:t,onChange:n=ft(()=>{},"onChange"),caller:r}){const[o,s,i]=no({defaultProp:t,onChange:n}),c=e!==void 0,u=c?e:o,f=a.useCallback(g=>{if(c){const d=ro(g)?g(e):g;d!==e&&i.current?.(d)}else s(g)},[c,e,s,i]);return[u,f]}ft(fn,"useControllableState");function no({defaultProp:e,onChange:t}){const[n,r]=a.useState(e),o=a.useRef(n),s=a.useRef(t);return Vi(()=>{s.current=t},[t]),a.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}ft(no,"useUncontrolledState");function ro(e){return typeof e=="function"}ft(ro,"isFunction");var Qn=Symbol("RADIX:SYNC_STATE");function Hi(e,t,n,r){const{prop:o,defaultProp:s,onChange:i,caller:c}=t,u=o!==void 0,f=to(i),g=[{...n,state:s}];r&&g.push(r);const[d,m]=a.useReducer((p,w)=>{if(w.type===Qn)return{...p,state:w.state};const S=e(p,w);return u&&!Object.is(S.state,p.state)&&f(S.state),S},...g),x=d.state,v=a.useRef(x);a.useEffect(()=>{v.current!==x&&(v.current=x,u||f(x))},[x,v,u]);const h=a.useMemo(()=>o!==void 0?{...d,state:o}:d,[d,o]);return a.useEffect(()=>{u&&!Object.is(o,d.state)&&m({type:Qn,state:o})},[o,d.state,u]),[h,m]}ft(Hi,"useControllableStateReducer");var $i=Object.defineProperty,Wi=(e,t)=>$i(e,"name",{value:t,configurable:!0});function oo(e){const t=a.useRef({value:e,previous:e});return a.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}Wi(oo,"usePrevious");var Ki=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Xi=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ke=new WeakMap,vt=new WeakMap,gt={},qt=0,so=function(e){return e&&(e.host||so(e.parentNode))},zi=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=so(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Yi=function(e,t,n,r){var o=zi(t,Array.isArray(e)?e:[e]);gt[n]||(gt[n]=new WeakMap);var s=gt[n],i=[],c=new Set,u=new Set(o),f=function(d){!d||c.has(d)||(c.add(d),f(d.parentNode))};o.forEach(f);var g=function(d){!d||u.has(d)||Array.prototype.forEach.call(d.children,function(m){if(c.has(m))g(m);else try{var x=m.getAttribute(r),v=x!==null&&x!=="false",h=(Ke.get(m)||0)+1,p=(s.get(m)||0)+1;Ke.set(m,h),s.set(m,p),i.push(m),h===1&&v&&vt.set(m,!0),p===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return g(t),c.clear(),qt++,function(){i.forEach(function(d){var m=Ke.get(d)-1,x=s.get(d)-1;Ke.set(d,m),s.set(d,x),m||(vt.has(d)||d.removeAttribute(r),vt.delete(d)),x||d.removeAttribute(n)}),qt--,qt||(Ke=new WeakMap,Ke=new WeakMap,vt=new WeakMap,gt={})}},Gi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Xi(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Yi(r,o,n,"aria-hidden")):function(){return null}},be=function(){return be=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},be.apply(this,arguments)};function io(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function qi(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Ot="right-scroll-bar-position",Rt="width-before-scroll-bar",Zi="with-scroll-bars-hidden",Qi="--removed-body-scroll-bar-size";function Zt(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ji(e,t){var n=a.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var ec=typeof window<"u"?a.useLayoutEffect:a.useEffect,Jn=new WeakMap;function tc(e,t){var n=Ji(null,function(r){return e.forEach(function(o){return Zt(o,r)})});return ec(function(){var r=Jn.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(c){s.has(c)||Zt(c,null)}),s.forEach(function(c){o.has(c)||Zt(c,i)})}Jn.set(n,e)},[e]),n}function nc(e){return e}function rc(e,t){t===void 0&&(t=nc);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(c){return s(c)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(s),i=n}var u=function(){var g=i;i=[],g.forEach(s)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(g){i.push(g),f()},filter:function(g){return i=i.filter(g),n}}}};return o}function oc(e){e===void 0&&(e={});var t=rc(null);return t.options=be({async:!0,ssr:!1},e),t}var co=function(e){var t=e.sideCar,n=io(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return a.createElement(r,be({},n))};co.isSideCarExport=!0;function sc(e,t){return e.useMedium(t),co}var ao=oc(),Qt=function(){},Bt=a.forwardRef(function(e,t){var n=a.useRef(null),r=a.useState({onScrollCapture:Qt,onWheelCapture:Qt,onTouchMoveCapture:Qt}),o=r[0],s=r[1],i=e.forwardProps,c=e.children,u=e.className,f=e.removeScrollBar,g=e.enabled,d=e.shards,m=e.sideCar,x=e.noRelative,v=e.noIsolation,h=e.inert,p=e.allowPinchZoom,w=e.as,S=w===void 0?"div":w,b=e.gapMode,y=io(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,P=tc([n,t]),O=be(be({},y),o);return a.createElement(a.Fragment,null,g&&a.createElement(C,{sideCar:ao,removeScrollBar:f,shards:d,noRelative:x,noIsolation:v,inert:h,setCallbacks:s,allowPinchZoom:!!p,lockRef:n,gapMode:b}),i?a.cloneElement(a.Children.only(c),be(be({},O),{ref:P})):a.createElement(S,be({},O,{className:u,ref:P}),c))});Bt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Bt.classNames={fullWidth:Rt,zeroRight:Ot};var ic=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function cc(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ic();return t&&e.setAttribute("nonce",t),e}function ac(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function lc(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var uc=function(){var e=0,t=null;return{add:function(n){e==0&&(t=cc())&&(ac(t,n),lc(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},dc=function(){var e=uc();return function(t,n){a.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},lo=function(){var e=dc(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},fc={left:0,top:0,right:0,gap:0},Jt=function(e){return parseInt(e||"",10)||0},pc=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Jt(n),Jt(r),Jt(o)]},mc=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return fc;var t=pc(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},hc=lo(),et="data-scroll-locked",vc=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
2
|
+
.`.concat(Zi,` {
|
|
3
|
+
overflow: hidden `).concat(r,`;
|
|
4
|
+
padding-right: `).concat(c,"px ").concat(r,`;
|
|
5
|
+
}
|
|
6
|
+
body[`).concat(et,`] {
|
|
7
|
+
overflow: hidden `).concat(r,`;
|
|
8
|
+
overscroll-behavior: contain;
|
|
9
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
10
|
+
padding-left: `.concat(o,`px;
|
|
11
|
+
padding-top: `).concat(s,`px;
|
|
12
|
+
padding-right: `).concat(i,`px;
|
|
13
|
+
margin-left:0;
|
|
14
|
+
margin-top:0;
|
|
15
|
+
margin-right: `).concat(c,"px ").concat(r,`;
|
|
16
|
+
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.`).concat(Ot,` {
|
|
20
|
+
right: `).concat(c,"px ").concat(r,`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.`).concat(Rt,` {
|
|
24
|
+
margin-right: `).concat(c,"px ").concat(r,`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.`).concat(Ot," .").concat(Ot,` {
|
|
28
|
+
right: 0 `).concat(r,`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.`).concat(Rt," .").concat(Rt,` {
|
|
32
|
+
margin-right: 0 `).concat(r,`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
body[`).concat(et,`] {
|
|
36
|
+
`).concat(Qi,": ").concat(c,`px;
|
|
37
|
+
}
|
|
38
|
+
`)},er=function(){var e=parseInt(document.body.getAttribute(et)||"0",10);return isFinite(e)?e:0},gc=function(){a.useEffect(function(){return document.body.setAttribute(et,(er()+1).toString()),function(){var e=er()-1;e<=0?document.body.removeAttribute(et):document.body.setAttribute(et,e.toString())}},[])},xc=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;gc();var s=a.useMemo(function(){return mc(o)},[o]);return a.createElement(hc,{styles:vc(s,!t,o,n?"":"!important")})},pn=!1;if(typeof window<"u")try{var xt=Object.defineProperty({},"passive",{get:function(){return pn=!0,!0}});window.addEventListener("test",xt,xt),window.removeEventListener("test",xt,xt)}catch{pn=!1}var Xe=pn?{passive:!1}:!1,yc=function(e){return e.tagName==="TEXTAREA"},uo=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!yc(e)&&n[t]==="visible")},bc=function(e){return uo(e,"overflowY")},wc=function(e){return uo(e,"overflowX")},tr=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=fo(e,r);if(o){var s=po(e,r),i=s[1],c=s[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Sc=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Ec=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},fo=function(e,t){return e==="v"?bc(t):wc(t)},po=function(e,t){return e==="v"?Sc(t):Ec(t)},Cc=function(e,t){return e==="h"&&t==="rtl"?-1:1},Pc=function(e,t,n,r,o){var s=Cc(e,window.getComputedStyle(t).direction),i=s*r,c=n.target,u=t.contains(c),f=!1,g=i>0,d=0,m=0;do{if(!c)break;var x=po(e,c),v=x[0],h=x[1],p=x[2],w=h-p-s*v;(v||w)&&fo(e,c)&&(d+=w,m+=v);var S=c.parentNode;c=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(g&&Math.abs(d)<1||!g&&Math.abs(m)<1)&&(f=!0),f},yt=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},nr=function(e){return[e.deltaX,e.deltaY]},rr=function(e){return e&&"current"in e?e.current:e},Oc=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Rc=function(e){return`
|
|
39
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
40
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
41
|
+
`)},_c=0,ze=[];function Nc(e){var t=a.useRef([]),n=a.useRef([0,0]),r=a.useRef(),o=a.useState(_c++)[0],s=a.useState(lo)[0],i=a.useRef(e);a.useEffect(function(){i.current=e},[e]),a.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=qi([e.lockRef.current],(e.shards||[]).map(rr),!0).filter(Boolean);return h.forEach(function(p){return p.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(p){return p.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=a.useCallback(function(h,p){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var w=yt(h),S=n.current,b="deltaX"in h?h.deltaX:S[0]-w[0],y="deltaY"in h?h.deltaY:S[1]-w[1],C,P=h.target,O=Math.abs(b)>Math.abs(y)?"h":"v";if("touches"in h&&O==="h"&&P.type==="range")return!1;var T=window.getSelection(),N=T&&T.anchorNode,I=N?N===P||N.contains(P):!1;if(I)return!1;var F=tr(O,P);if(!F)return!0;if(F?C=O:(C=O==="v"?"h":"v",F=tr(O,P)),!F)return!1;if(!r.current&&"changedTouches"in h&&(b||y)&&(r.current=C),!C)return!0;var A=r.current||C;return Pc(A,p,h,A==="h"?b:y)},[]),u=a.useCallback(function(h){var p=h;if(!(!ze.length||ze[ze.length-1]!==s)){var w="deltaY"in p?nr(p):yt(p),S=t.current.filter(function(C){return C.name===p.type&&(C.target===p.target||p.target===C.shadowParent)&&Oc(C.delta,w)})[0];if(S&&S.should){p.cancelable&&p.preventDefault();return}if(!S){var b=(i.current.shards||[]).map(rr).filter(Boolean).filter(function(C){return C.contains(p.target)}),y=b.length>0?c(p,b[0]):!i.current.noIsolation;y&&p.cancelable&&p.preventDefault()}}},[]),f=a.useCallback(function(h,p,w,S){var b={name:h,delta:p,target:w,should:S,shadowParent:Tc(w)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(y){return y!==b})},1)},[]),g=a.useCallback(function(h){n.current=yt(h),r.current=void 0},[]),d=a.useCallback(function(h){f(h.type,nr(h),h.target,c(h,e.lockRef.current))},[]),m=a.useCallback(function(h){f(h.type,yt(h),h.target,c(h,e.lockRef.current))},[]);a.useEffect(function(){return ze.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:m}),document.addEventListener("wheel",u,Xe),document.addEventListener("touchmove",u,Xe),document.addEventListener("touchstart",g,Xe),function(){ze=ze.filter(function(h){return h!==s}),document.removeEventListener("wheel",u,Xe),document.removeEventListener("touchmove",u,Xe),document.removeEventListener("touchstart",g,Xe)}},[]);var x=e.removeScrollBar,v=e.inert;return a.createElement(a.Fragment,null,v?a.createElement(s,{styles:Rc(o)}):null,x?a.createElement(xc,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Tc(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ac=sc(ao,Nc);var mo=a.forwardRef(function(e,t){return a.createElement(Bt,be({},e,{ref:t,sideCar:Ac}))});mo.classNames=Bt.classNames;var Ic=Object.defineProperty,$=(e,t)=>Ic(e,"name",{value:t,configurable:!0}),Dc=[" ","Enter","ArrowUp","ArrowDown"],Lc=[" ","Enter"],nt="Select",[Vt,_n,jc]=gr(nt),[$e,Sa]=dt(nt,[jc,zr]),Nn=zr(),[kc,ke]=$e(nt),[Mc,Fc]=$e(nt);function ho(e){const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:c,onValueChange:u,dir:f,name:g,autoComplete:d,disabled:m,required:x,form:v,internal_do_not_use_render:h}=e,p=Nn(t),[w,S]=a.useState(null),[b,y]=a.useState(null),[C,P]=a.useState(!1),O=Sr(f),[T,N]=fn({prop:r,defaultProp:o??!1,onChange:s,caller:nt}),[I,F]=fn({prop:i,defaultProp:c,onChange:u,caller:nt}),A=a.useRef(null),_=a.useRef(I);a.useEffect(()=>{const X=v?w?.ownerDocument.getElementById(v):w?.form;if(X instanceof HTMLFormElement){const Z=$(()=>F(_.current),"reset");return X.addEventListener("reset",Z),()=>X.removeEventListener("reset",Z)}},[v,w,F]);const L=w?!!v||!!w.closest("form"):!0,[H,k]=a.useState(new Set),M=wn(),R=Array.from(H).map(X=>X.props.value).join(";"),U=a.useCallback(X=>{k(Z=>new Set(Z).add(X))},[]),B=a.useCallback(X=>{k(Z=>{const ie=new Set(Z);return ie.delete(X),ie})},[]),ue={required:x,trigger:w,onTriggerChange:S,valueNode:b,onValueNodeChange:y,valueNodeHasChildren:C,onValueNodeHasChildrenChange:P,contentId:M,value:I,onValueChange:F,open:T,onOpenChange:N,dir:O,triggerPointerDownPosRef:A,disabled:m,name:g,autoComplete:d,form:v,nativeOptions:H,nativeSelectKey:R,isFormControl:L};return l.jsx(Ti,{...p,children:l.jsx(kc,{scope:t,...ue,children:l.jsx(Vt.Provider,{scope:t,children:l.jsx(Mc,{scope:t,onNativeOptionAdd:U,onNativeOptionRemove:B,children:So(h)?h(ue):n})})})})}$(ho,"SelectProvider");var Uc=$(e=>{const{__scopeSelect:t,children:n,...r}=e;return l.jsx(ho,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:o})=>l.jsxs(l.Fragment,{children:[n,o?l.jsx(la,{__scopeSelect:t}):null]})})},"Select"),Bc="SelectTrigger",vo=a.forwardRef($(function(t,n){const{__scopeSelect:r,disabled:o=!1,...s}=t,i=Nn(r),c=ke(Bc,r),u=c.disabled||o,f=ne(n,c.onTriggerChange),g=_n(r),d=a.useRef("touch"),[m,x,v]=Tn(p=>{const w=g().filter(y=>!y.disabled),S=w.find(y=>y.value===c.value),b=An(w,p,S);b!==void 0&&c.onValueChange(b.value)}),h=$(p=>{u||(c.onOpenChange(!0),v()),p&&(c.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})},"handleOpen");return l.jsx(Ai,{asChild:!0,...i,children:l.jsx(le.button,{type:"button",role:"combobox","aria-controls":c.open?c.contentId:void 0,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":pt(c.value)?"":void 0,...s,ref:f,onClick:J(s.onClick,p=>{p.currentTarget.focus(),d.current!=="mouse"&&h(p)}),onPointerDown:J(s.onPointerDown,p=>{d.current=p.pointerType;const w=p.target;w.hasPointerCapture(p.pointerId)&&w.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(h(p),p.preventDefault())}),onKeyDown:J(s.onKeyDown,p=>{const w=m.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&x(p.key),!(w&&p.key===" ")&&Dc.includes(p.key)&&(h(),p.preventDefault())})})})},"SelectTrigger")),Vc="SelectValue",Hc=a.forwardRef($(function(t,n){const{__scopeSelect:r,className:o,style:s,children:i,placeholder:c="",...u}=t,f=ke(Vc,r),{onValueNodeHasChildrenChange:g}=f,d=i!==void 0,m=ne(n,f.onValueNodeChange);ae(()=>{g(d)},[g,d]);const x=pt(f.value);return l.jsx(le.span,{...u,asChild:x?!1:u.asChild,ref:m,style:{pointerEvents:"none"},children:l.jsx(a.Fragment,{children:x?c:i},x?"placeholder":"value")})},"SelectValue")),$c=a.forwardRef($(function(t,n){const{__scopeSelect:r,children:o,...s}=t;return l.jsx(le.span,{"aria-hidden":!0,...s,ref:n,children:o||"▼"})},"SelectIcon")),Wc="SelectPortal",[Kc,Xc]=$e(Wc,{forceMount:void 0}),zc=$(e=>{const{__scopeSelect:t,forceMount:n,...r}=e;return l.jsx(Kc,{scope:e.__scopeSelect,forceMount:n,children:l.jsx(ji,{asChild:!0,...r})})},"SelectPortal"),He="SelectContent",go=a.forwardRef($(function(t,n){const r=Xc(He,t.__scopeSelect),{forceMount:o=r.forceMount,...s}=t,i=ke(He,t.__scopeSelect),[c,u]=a.useState();return ae(()=>{u(new DocumentFragment)},[]),l.jsx(Mi,{present:o||i.open,children:({present:f})=>f?l.jsx(qc,{...s,ref:n}):l.jsx(Yc,{...s,fragment:c})})},"SelectContent")),Yc=a.forwardRef($(function(t,n){const{__scopeSelect:r,children:o,fragment:s}=t;return s?ut.createPortal(l.jsx(xo,{scope:r,children:l.jsx(Vt.Slot,{scope:r,children:l.jsx("div",{ref:n,children:o})})}),s):null},"SelectContentFragment")),ge=10,[xo,Ht]=$e(He),Gc=tt("SelectContent.RemoveScroll"),qc=a.forwardRef($(function(t,n){const{__scopeSelect:r}=t,{position:o="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:i,onPointerDownOutside:c,side:u,sideOffset:f,align:g,alignOffset:d,arrowPadding:m,collisionBoundary:x,collisionPadding:v,sticky:h,hideWhenDetached:p,avoidCollisions:w,...S}=t,b=ke(He,r),[y,C]=a.useState(null),[P,O]=a.useState(null),T=ne(n,C),[N,I]=a.useState(null),[F,A]=a.useState(null),_=_n(r),[L,H]=a.useState(!1),k=a.useRef(!1);a.useEffect(()=>{if(y)return Gi(y)},[y]),yn();const M=a.useCallback(D=>{const[V,...Q]=_().map(Y=>Y.ref.current),[W]=Q.slice(-1),K=document.activeElement;for(const Y of D)if(Y===K||(Y?.scrollIntoView({block:"nearest"}),Y===V&&P&&(P.scrollTop=0),Y===W&&P&&(P.scrollTop=P.scrollHeight),Y?.focus(),document.activeElement!==K))return},[_,P]),R=a.useCallback(()=>M([N,y]),[M,N,y]);a.useEffect(()=>{L&&R()},[L,R]);const{onOpenChange:U,triggerPointerDownPosRef:B}=b;a.useEffect(()=>{if(y){let D={x:0,y:0};const V=$(W=>{D={x:Math.abs(Math.round(W.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(W.pageY)-(B.current?.y??0))}},"handlePointerMove"),Q=$(W=>{D.x<=10&&D.y<=10?W.preventDefault():W.composedPath().includes(y)||U(!1),document.removeEventListener("pointermove",V),B.current=null},"handlePointerUp");return B.current!==null&&(document.addEventListener("pointermove",V),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",V),document.removeEventListener("pointerup",Q,{capture:!0})}}},[y,U,B]),a.useEffect(()=>{const D=$(()=>U(!1),"close");return window.addEventListener("blur",D),window.addEventListener("resize",D),()=>{window.removeEventListener("blur",D),window.removeEventListener("resize",D)}},[U]);const[ue,X]=Tn(D=>{const V=_().filter(K=>!K.disabled),Q=V.find(K=>K.ref.current===document.activeElement),W=An(V,D,Q);W&&setTimeout(()=>W.ref.current?.focus())}),Z=a.useCallback((D,V,Q)=>{const W=!k.current&&!Q;(b.value!==void 0&&b.value===V||W)&&(I(D),W&&(k.current=!0))},[b.value]),ie=a.useCallback(()=>y?.focus(),[y]),re=a.useCallback((D,V,Q)=>{const W=!k.current&&!Q;(b.value!==void 0&&b.value===V||W)&&A(D)},[b.value]),q=o==="popper"?or:Zc,xe=q===or?{side:u,sideOffset:f,align:g,alignOffset:d,arrowPadding:m,collisionBoundary:x,collisionPadding:v,sticky:h,hideWhenDetached:p,avoidCollisions:w}:{};return l.jsx(xo,{scope:r,content:y,viewport:P,onViewportChange:O,itemRefCallback:Z,selectedItem:N,onItemLeave:ie,itemTextRefCallback:re,focusSelectedItem:R,selectedItemText:F,position:o,isPositioned:L,searchRef:ue,children:l.jsx(mo,{as:Gc,allowPinchZoom:!0,children:l.jsx(us,{asChild:!0,trapped:b.open,onMountAutoFocus:D=>{D.preventDefault()},onUnmountAutoFocus:J(s,D=>{b.trigger?.focus({preventScroll:!0}),D.preventDefault()}),children:l.jsx(os,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:D=>D.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:l.jsx(q,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:D=>D.preventDefault(),...S,...xe,onPlaced:()=>H(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:J(S.onKeyDown,D=>{const V=D.ctrlKey||D.altKey||D.metaKey;if(D.key==="Tab"&&D.preventDefault(),!V&&D.key.length===1&&X(D.key),["ArrowUp","ArrowDown","Home","End"].includes(D.key)){let W=_().filter(K=>!K.disabled).map(K=>K.ref.current);if(["ArrowUp","End"].includes(D.key)&&(W=W.slice().reverse()),["ArrowUp","ArrowDown"].includes(D.key)){const K=D.target,Y=W.indexOf(K);W=W.slice(Y+1)}setTimeout(()=>M(W)),D.preventDefault()}})})})})})})},"SelectContentImpl")),Zc=a.forwardRef($(function(t,n){const{__scopeSelect:r,onPlaced:o,...s}=t,i=ke(He,r),c=Ht(He,r),[u,f]=a.useState(null),[g,d]=a.useState(null),m=ne(n,d),x=_n(r),v=a.useRef(!1),h=a.useRef(!0),{viewport:p,selectedItem:w,selectedItemText:S,focusSelectedItem:b}=c,y=a.useCallback(()=>{if(i.trigger&&i.valueNode&&u&&g&&p&&w&&S){const T=i.trigger.getBoundingClientRect(),N=g.getBoundingClientRect(),I=i.valueNode.getBoundingClientRect(),F=S.getBoundingClientRect();if(i.dir!=="rtl"){const K=F.left-N.left,Y=I.left-K,ve=T.left-Y,de=T.width+ve,E=Math.max(de,N.width),j=window.innerWidth-ge,z=en(Y,[ge,Math.max(ge,j-E)]);u.style.minWidth=de+"px",u.style.left=z+"px"}else{const K=N.right-F.right,Y=window.innerWidth-I.right-K,ve=window.innerWidth-T.right-Y,de=T.width+ve,E=Math.max(de,N.width),j=window.innerWidth-ge,z=en(Y,[ge,Math.max(ge,j-E)]);u.style.minWidth=de+"px",u.style.right=z+"px"}const A=x(),_=window.innerHeight-ge*2,L=p.scrollHeight,H=window.getComputedStyle(g),k=parseInt(H.borderTopWidth,10),M=parseInt(H.paddingTop,10),R=parseInt(H.borderBottomWidth,10),U=parseInt(H.paddingBottom,10),B=k+M+L+U+R,ue=Math.min(w.offsetHeight*5,B),X=window.getComputedStyle(p),Z=parseInt(X.paddingTop,10),ie=parseInt(X.paddingBottom,10),re=T.top+T.height/2-ge,q=_-re,xe=w.offsetHeight/2,D=w.offsetTop+xe,V=k+M+D,Q=B-V;if(V<=re){const K=A.length>0&&w===A[A.length-1].ref.current;u.style.bottom="0px";const Y=g.clientHeight-p.offsetTop-p.offsetHeight,ve=Math.max(q,xe+(K?ie:0)+Y+R),de=V+ve;u.style.height=de+"px"}else{const K=A.length>0&&w===A[0].ref.current;u.style.top="0px";const ve=Math.max(re,k+p.offsetTop+(K?Z:0)+xe)+Q;u.style.height=ve+"px",p.scrollTop=V-re+p.offsetTop}u.style.margin=`${ge}px 0`,u.style.minHeight=ue+"px",u.style.maxHeight=_+"px",o?.(),requestAnimationFrame(()=>v.current=!0)}},[x,i.trigger,i.valueNode,u,g,p,w,S,i.dir,o]);ae(()=>y(),[y]);const[C,P]=a.useState();ae(()=>{g&&P(window.getComputedStyle(g).zIndex)},[g]);const O=a.useCallback(T=>{T&&h.current===!0&&(y(),b?.(),h.current=!1)},[y,b]);return l.jsx(Qc,{scope:r,contentWrapper:u,shouldExpandOnScrollRef:v,onScrollButtonChange:O,children:l.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:l.jsx(le.div,{...s,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})},"SelectItemAlignedPosition")),or=a.forwardRef($(function(t,n){const{__scopeSelect:r,align:o="start",collisionPadding:s=ge,...i}=t,c=Nn(r);return l.jsx(Ii,{...c,...i,ref:n,align:o,collisionPadding:s,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[Qc,Jc]=$e(He,{}),sr="SelectViewport",ea=a.forwardRef($(function(t,n){const{__scopeSelect:r,nonce:o,...s}=t,i=Ht(sr,r),c=Jc(sr,r),u=ne(n,i.onViewportChange),f=a.useRef(0);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),l.jsx(Vt.Slot,{scope:r,children:l.jsx(le.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:J(s.onScroll,g=>{const d=g.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:x}=c;if(x?.current&&m){const v=Math.abs(f.current-d.scrollTop);if(v>0){const h=window.innerHeight-ge*2,p=parseFloat(m.style.minHeight),w=parseFloat(m.style.height),S=Math.max(p,w);if(S<h){const b=S+v,y=Math.min(h,b),C=b-y;m.style.height=y+"px",m.style.bottom==="0px"&&(d.scrollTop=C>0?C:0,m.style.justifyContent="flex-end")}}}f.current=d.scrollTop})})})]})},"SelectViewport")),ta="SelectGroup",[Ea,na]=$e(ta),ra="SelectLabel",yo=a.forwardRef($(function(t,n){const{__scopeSelect:r,...o}=t,s=na(ra,r);return l.jsx(le.div,{id:s.id,...o,ref:n})},"SelectLabel")),mn="SelectItem",[oa,bo]=$e(mn),wo=a.forwardRef($(function(t,n){const{__scopeSelect:r,value:o,disabled:s=!1,textValue:i,...c}=t,u=ke(mn,r),f=Ht(mn,r),g=u.value===o,[d,m]=a.useState(i??""),[x,v]=a.useState(!1),h=Se(y=>f.itemRefCallback?.(y,o,s)),p=ne(n,h),w=wn(),S=a.useRef("touch"),b=$(()=>{s||(u.onValueChange(o),u.onOpenChange(!1))},"handleSelect");return l.jsx(oa,{scope:r,value:o,disabled:s,textId:w,isSelected:g,onItemTextChange:a.useCallback(y=>{m(C=>C||(y?.textContent??"").trim())},[]),children:l.jsx(Vt.ItemSlot,{scope:r,value:o,disabled:s,textValue:d,children:l.jsx(le.div,{role:"option","aria-labelledby":w,"data-highlighted":x?"":void 0,"aria-selected":g&&x,"data-state":g?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...c,ref:p,onFocus:J(c.onFocus,()=>v(!0)),onBlur:J(c.onBlur,()=>v(!1)),onClick:J(c.onClick,()=>{S.current!=="mouse"&&b()}),onPointerUp:J(c.onPointerUp,()=>{S.current==="mouse"&&b()}),onPointerDown:J(c.onPointerDown,y=>{S.current=y.pointerType}),onPointerMove:J(c.onPointerMove,y=>{S.current=y.pointerType,s?f.onItemLeave?.():S.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:J(c.onPointerLeave,y=>{y.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:J(c.onKeyDown,y=>{s||y.target!==y.currentTarget||f.searchRef?.current!==""&&y.key===" "||(Lc.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})},"SelectItem")),bt="SelectItemText",sa=a.forwardRef($(function(t,n){const{__scopeSelect:r,className:o,style:s,...i}=t,c=ke(bt,r),u=Ht(bt,r),f=bo(bt,r),g=Fc(bt,r),[d,m]=a.useState(null),x=Se(b=>u.itemTextRefCallback?.(b,f.value,f.disabled)),v=ne(n,m,f.onItemTextChange,x),h=d?.textContent,p=a.useMemo(()=>l.jsx("option",{value:f.value,disabled:f.disabled,children:h},f.value),[f.disabled,f.value,h]),{onNativeOptionAdd:w,onNativeOptionRemove:S}=g;return ae(()=>(w(p),()=>S(p)),[w,S,p]),l.jsxs(l.Fragment,{children:[l.jsx(le.span,{id:f.textId,...i,ref:v}),f.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!pt(c.value)?ut.createPortal(i.children,c.valueNode):null]})},"SelectItemText")),ia="SelectItemIndicator",ca=a.forwardRef($(function(t,n){const{__scopeSelect:r,...o}=t;return bo(ia,r).isSelected?l.jsx(le.span,{"aria-hidden":!0,...o,ref:n}):null},"SelectItemIndicator")),aa="SelectBubbleInput",la=a.forwardRef($(function({__scopeSelect:t,...n},r){const o=ke(aa,t),{value:s,onValueChange:i,required:c,disabled:u,name:f,autoComplete:g,form:d}=o,{nativeOptions:m,nativeSelectKey:x}=o,v=a.useRef(null),h=ne(r,v),p=s??"",w=oo(p),S=Array.from(m).some(b=>(b.props.value??"")==="");return a.useEffect(()=>{const b=v.current;if(!b)return;const y=window.HTMLSelectElement.prototype,P=Object.getOwnPropertyDescriptor(y,"value").set;if(w!==p&&P){const O=new Event("change",{bubbles:!0});P.call(b,p),b.dispatchEvent(O)}},[w,p]),l.jsxs(le.select,{"aria-hidden":!0,required:c,tabIndex:-1,name:f,autoComplete:g,disabled:u,form:d,onChange:b=>i(b.target.value),...n,style:{...Ki,...n.style},ref:h,defaultValue:p,children:[pt(s)&&!S?l.jsx("option",{value:""}):null,Array.from(m)]},x)},"SelectBubbleInput"));function So(e){return typeof e=="function"}$(So,"isFunction");function pt(e){return e===""||e===void 0}$(pt,"shouldShowPlaceholder");function Tn(e){const t=Se(e),n=a.useRef(""),r=a.useRef(0),o=a.useCallback(i=>{const c=n.current+i;t(c),$((function u(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>u(""),1e3))}),"updateSearch")(c)},[t]),s=a.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return a.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}$(Tn,"useTypeaheadSearch");function An(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Eo(e,Math.max(s,0));o.length===1&&(i=i.filter(f=>f!==n));const u=i.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}$(An,"findNextItem");function Eo(e,t){return e.map((n,r)=>e[(t+r)%e.length])}$(Eo,"wrapArray");const wt=Uc,St=Hc,it=a.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(vo,{ref:r,className:se("flex h-9 items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background","placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50",e),...n,children:[t,l.jsx($c,{asChild:!0,children:l.jsx(Lo,{className:"h-4 w-4 opacity-50"})})]}));it.displayName=vo.displayName;const ct=a.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(zc,{children:l.jsx(go,{ref:o,className:se("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:l.jsx(ea,{className:se("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t})})}));ct.displayName=go.displayName;const ua=a.forwardRef(({className:e,...t},n)=>l.jsx(yo,{ref:n,className:se("px-2 py-1.5 text-sm font-semibold",e),...t}));ua.displayName=yo.displayName;const me=a.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(wo,{ref:r,className:se("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(ca,{children:l.jsx(Io,{className:"h-4 w-4"})})}),l.jsx(sa,{children:t})]}));me.displayName=wo.displayName;function da(e){const{changes:t,onReset:n}=e;return l.jsxs(Fe,{variant:"bordered",className:"mb-6",children:[l.jsx(Ye,{className:"pb-2",children:l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx(Ge,{children:"待应用变更"}),l.jsx(Ze,{type:"button",variant:"ghost",size:"sm",onClick:n,disabled:t.length===0,children:"重置未保存"})]})}),l.jsx(Ue,{children:t.length===0?l.jsx("p",{className:"text-sm text-muted-foreground",children:"没有未保存的变更。"}):l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:"保存后需要重启运行时才能完全生效。"}),l.jsx("div",{className:"divide-y divide-border rounded-md border border-border",children:t.map(r=>l.jsxs("div",{className:"grid gap-1 px-3 py-2 text-sm sm:grid-cols-[180px_1fr]",children:[l.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:r.key}),l.jsxs("span",{className:"font-mono text-xs text-foreground break-all",children:[r.from||"∅"," → ",r.to||"∅"]})]},r.key))})]})})]})}function Et(e){const{id:t,label:n,configured:r,value:o,onChange:s,placeholder:i,helper:c}=e;return l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(Qe,{htmlFor:t,children:n}),l.jsxs("span",{className:se("inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs",r?"border-green-200 text-green-700 dark:border-green-900 dark:text-green-300":"border-border text-muted-foreground"),children:[l.jsx(ko,{className:"h-3.5 w-3.5"}),r?"已配置":"未配置"]})]}),l.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[l.jsx(fr,{id:t,type:"password",autoComplete:"new-password",value:o,onChange:u=>s(u.target.value),placeholder:i??"填写新 secret","aria-describedby":c?`${t}-helper`:void 0}),o?l.jsx(Ze,{type:"button",variant:"ghost",onClick:()=>s(""),className:"shrink-0",children:"清除替换值"}):null]}),c?l.jsx("p",{id:`${t}-helper`,className:"text-xs text-muted-foreground",children:c}):null]})}const ir=["XPOD_DEPLOY_MODE","CSS_ROOT_FILE_PATH","CSS_BASE_URL","XPOD_TUNNEL_PROVIDER","XPOD_TUNNEL_ACTIVE_PROFILE_ID","XPOD_TUNNEL_PROFILES","XPOD_TUNNEL_PUBLIC_URL","CLOUDFLARE_TUNNEL_URL","SAKURA_TUNNEL_URL","CLOUDFLARE_TUNNEL_TOKEN","SAKURA_TUNNEL_TOKEN","NGROK_AUTHTOKEN","NGROK_URL","FRP_TUNNEL_TOKEN","FRP_TUNNEL_URL","XPOD_HTTPS_MODE","XPOD_HTTPS_CERT_PATH","XPOD_HTTPS_KEY_PATH","XPOD_CLOUD_API_ENDPOINT","XPOD_NODE_ID","XPOD_SP_DOMAIN","XPOD_NODE_TOKEN","XPOD_SERVICE_TOKEN","CSS_PORT","CSS_SPARQL_ENDPOINT","CSS_IDENTITY_DB_URL","CSS_LOGGING_LEVEL","CSS_SHOW_STACK_TRACE"],fa=new Set(["CLOUDFLARE_TUNNEL_TOKEN","SAKURA_TUNNEL_TOKEN","NGROK_AUTHTOKEN","FRP_TUNNEL_TOKEN","XPOD_NODE_TOKEN","XPOD_SERVICE_TOKEN","CSS_IDENTITY_DB_URL"]),hn={ngrok:{publicEndpointKey:"NGROK_URL",publicEndpointLabel:"ngrok 固定入口 URL",publicEndpointPlaceholder:"https://example.ngrok-free.dev",credentialKey:"NGROK_AUTHTOKEN",credentialLabel:"ngrok authtoken"},cloudflare:{publicEndpointKey:"CLOUDFLARE_TUNNEL_URL",publicEndpointLabel:"Cloudflare Tunnel 公开入口",publicEndpointPlaceholder:"https://example.trycloudflare.com",credentialKey:"CLOUDFLARE_TUNNEL_TOKEN",credentialLabel:"Cloudflare Tunnel Token"},sakura_frp:{publicEndpointKey:"SAKURA_TUNNEL_URL",publicEndpointLabel:"Sakura FRP 公开入口 URL",publicEndpointPlaceholder:"https://example.example.com",credentialKey:"SAKURA_TUNNEL_TOKEN",credentialLabel:"Sakura FRP Token"},frp:{publicEndpointKey:"FRP_TUNNEL_URL",publicEndpointLabel:"FRP 公开入口 URL",publicEndpointPlaceholder:"https://example.example.com",credentialKey:"FRP_TUNNEL_TOKEN",credentialLabel:"FRP Token"}};function pa(e){return e==="none"?null:hn[e]}const ma=["ngrok","cloudflare","sakura_frp","frp"];function In(e){return e==="ngrok"||e==="cloudflare"||e==="sakura_frp"||e==="frp"?e:e==="sakura-frp"?"sakura_frp":"none"}function cr(e){switch(e){case"ngrok":return"ngrok";case"cloudflare":return"Cloudflare";case"sakura_frp":return"Sakura FRP";case"frp":return"FRP"}}function ha(e,t){const n=[],r=new Set;for(const o of va(e.XPOD_TUNNEL_PROFILES)){const s=hn[o.provider],i=o.credentialEnvKey||s.credentialKey,c=o.publicUrl||ar(e,o.provider,s),u=t(i);n.push({id:o.id,provider:o.provider,label:o.label||cr(o.provider),publicEndpointUrl:c,credentialConfigured:u,configured:!0,...s,credentialKey:i}),r.add(o.id)}for(const o of ma){if(r.has(o))continue;const s=hn[o],i=ar(e,o,s),c=t(s.credentialKey);n.push({id:o,provider:o,label:cr(o),publicEndpointUrl:i,credentialConfigured:c,configured:!!(i||c||In(e.XPOD_TUNNEL_PROVIDER)===o),...s})}return n}function va(e){if(!e?.trim())return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return[];const r=n,o=typeof r.id=="string"&&r.id.trim()?r.id.trim():"",s=In(typeof r.provider=="string"?r.provider:void 0);return!o||s==="none"?[]:[{id:o,provider:s,label:typeof r.label=="string"?r.label:void 0,publicUrl:typeof r.publicUrl=="string"?r.publicUrl:void 0,credentialEnvKey:typeof r.credentialEnvKey=="string"?r.credentialEnvKey:void 0}]}):[]}catch{return[]}}function ar(e,t,n){const r=(t==="cloudflare"||t==="sakura_frp")&&e.XPOD_TUNNEL_PUBLIC_URL||"";return e[n.publicEndpointKey]||r||""}function lr(e){const t=e.filter(n=>n.configured).map(n=>({id:n.id,provider:n.provider,label:n.label,publicUrl:n.publicEndpointUrl,credentialEnvKey:n.credentialKey}));return t.length>0?JSON.stringify(t):""}function ga(e,t,n){const r=e.XPOD_TUNNEL_ACTIVE_PROFILE_ID?.trim();return r||(t!=="none"?t:n.find(o=>o.configured)?.id??"none")}function ur(e){return fa.has(e)}function dr(e,t,n){return{...e,[t]:n}}function ye(e){return l.jsxs("div",{className:"space-y-2",children:[l.jsx(Qe,{htmlFor:e.id,children:e.label}),l.jsx(fr,{id:e.id,value:e.value,onChange:t=>e.onChange(t.target.value),placeholder:e.placeholder,readOnly:e.readOnly,"aria-readonly":e.readOnly||void 0}),e.helper?l.jsx("p",{className:"text-xs text-muted-foreground",children:e.helper}):null]})}function Ca(){const e=Po(),[t,n]=a.useState({}),[r,o]=a.useState({}),[s,i]=a.useState({}),[c,u]=a.useState({}),[f,g]=a.useState(null),[d,m]=a.useState(null),[x,v]=a.useState(!0),[h,p]=a.useState(!1),[w,S]=a.useState(!1),[b,y]=a.useState(""),[C,P]=a.useState(!1),O=t.XPOD_DEPLOY_MODE==="standalone"?"standalone":"local",T=In(t.XPOD_TUNNEL_PROVIDER),N=["none","acme","manual"].includes(t.XPOD_HTTPS_MODE)?t.XPOD_HTTPS_MODE:"none",I=f?.status??"unknown",F=O==="local",A=!!t.XPOD_CLOUD_API_ENDPOINT,_=F&&A,L=d?.baseUrl||t.CSS_BASE_URL||(d?.fqdn?`https://${d.fqdn}/`:""),H=a.useCallback(async()=>{try{const E=await Oo();m(E)}catch(E){console.error("Failed to load ddns status:",E),m(null)}},[]),k=a.useCallback(async()=>{try{const E=await Ro(),j={...E?.env??{}};n(j),o(j),i({}),u(E?.secrets??{})}catch(E){console.error("Failed to load config:",E)}finally{v(!1)}},[]),M=a.useCallback(async E=>{S(!0);try{const j=await _o(E);g(j)}catch(j){console.error("Failed to refresh public ip check:",j),g(null)}finally{S(!1)}},[]);a.useEffect(()=>{queueMicrotask(()=>{k()})},[k]),a.useEffect(()=>{x||queueMicrotask(()=>{M(_?L:t.CSS_BASE_URL)})},[t.CSS_BASE_URL,_,L,O,x,M]),a.useEffect(()=>{x||queueMicrotask(_?()=>{H()}:()=>{m(null)})},[_,x,H]);const R=(E,j)=>{n(z=>dr(z,E,j))},U=(E,j)=>{i(z=>dr(z,E,j))},B=a.useCallback(E=>!!c[E]?.configured,[c]),ue=a.useCallback(E=>B(E)||!!s[E],[B,s]),X=a.useMemo(()=>ha(t,ue),[t,ue]),Z=ga(t,T,X),ie=X.find(E=>E.id===Z),re=ie?.provider??"none",q=pa(re),xe=E=>{const j=X.find(z=>z.id===E);n(z=>({...z,XPOD_TUNNEL_ACTIVE_PROFILE_ID:j?j.id:"",XPOD_TUNNEL_PROVIDER:j?.provider??"none"}))},D=(E,j)=>{const z=X.map(Ae=>Ae.id===E.id?{...Ae,publicEndpointUrl:j,configured:!0}:Ae);n(Ae=>({...Ae,[E.publicEndpointKey]:j,XPOD_TUNNEL_PROFILES:lr(z)}))},V=a.useMemo(()=>{if(q){if(!(ie?.publicEndpointUrl||"").trim())return`请填写 ${q.publicEndpointLabel}`;if(!ue(q.credentialKey))return`请填写 ${q.credentialLabel}`}if(_&&d?.mode==="tunnel"&&re==="none")return"当前网络不可直连,必须启用一个隧道供应商。";const j=(t.CSS_BASE_URL||"").trim().startsWith("https://");return!_&&j&&re==="none"&&N==="none"?"独立部署使用 https:// Base URL 时,需要配置 HTTPS 或启用隧道。":""},[ie?.publicEndpointUrl,re,d?.mode,t.CSS_BASE_URL,N,_,q,ue]),Q=a.useMemo(()=>{const E=[];for(const j of ir){const z=t[j],Ae=r[j];if(ur(j)){s[j]&&E.push({key:j,from:B(j)?"[configured]":"",to:"[replace]"});continue}(z??"")!==(Ae??"")&&E.push({key:j,from:Ae??"",to:z??""})}return E},[t,r,B,s]),W=async()=>{if(V)return y(V),!1;p(!0),y("");try{const E={};for(const z of ir)ur(z)?s[z]&&(E[z]=s[z]):z in t&&(E[z]=t[z]);E.XPOD_TUNNEL_ACTIVE_PROFILE_ID=re==="none"?"":Z,E.XPOD_TUNNEL_PROVIDER=re,E.XPOD_TUNNEL_PROFILES=lr(X);const j=await No(E);return j?(y("配置已保存,需要重启服务生效"),await k()):y("保存失败"),!!j}catch{return y("保存失败"),!1}finally{p(!1)}},K=async()=>{if(e&&!e.restartCapability.supported){y("当前入口不支持重启操作。请在本机或携带管理 Token 操作。");return}y("正在重启服务..."),await To()?(y("重启信号已发送,请稍候..."),setTimeout(()=>window.location.reload(),3e3)):y("重启失败。远程访问时默认禁止重启,请在本机或携带管理 Token 操作。")},Y=async()=>{if(e&&!e.configurationWriteCapability.supported){y("当前入口不支持保存运行时配置。请在本机或携带管理 Token 操作。");return}await W()&&await K()},ve=()=>{n(r),i({}),y("未保存变更已重置")},de=a.useMemo(()=>w?"检测中...":I==="pass"?"可直连":I==="fail"?"不可直连":"未知",[w,I]);return x?l.jsxs("div",{className:"p-4 sm:p-8 max-w-4xl space-y-4",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"type-h1",children:"设置"}),l.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"正在读取运行时配置。"})]}),l.jsx(Fe,{variant:"bordered",children:l.jsxs(Ue,{className:"space-y-3 pt-5",children:[l.jsx("div",{className:"h-4 w-40 rounded bg-muted"}),l.jsx("div",{className:"h-10 rounded bg-muted"}),l.jsx("div",{className:"h-10 rounded bg-muted"})]})})]}):l.jsxs("div",{className:"p-4 sm:p-8 max-w-4xl",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"type-h1",children:"设置"}),l.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"高级运行时设置。大多数用户应在 LinX 中完成配置。"})]}),l.jsx("div",{className:"mb-6 rounded-xl border border-amber-200 bg-amber-50/70 p-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950/20 dark:text-amber-200",children:l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Fo,{className:"mt-0.5 h-4 w-4 shrink-0"}),l.jsxs("div",{children:[l.jsx("div",{className:"font-medium",children:"高级运行时设置"}),l.jsx("p",{className:"mt-1",children:"这里修改的是本地 Xpod 运行时,不是用户 Pod 资料,也不是 Cloud IDP 账号设置。"})]})]})}),l.jsxs(Fe,{variant:"bordered",className:"mb-6",children:[l.jsx(Ye,{children:l.jsx(Ge,{children:"运行时"})}),l.jsxs(Ue,{className:"space-y-4",children:[l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Qe,{children:"部署模式"}),l.jsxs(wt,{value:O,onValueChange:E=>R("XPOD_DEPLOY_MODE",E),children:[l.jsx(it,{children:l.jsx(St,{})}),l.jsxs(ct,{children:[l.jsx(me,{value:"local",children:"边缘部署"}),l.jsx(me,{value:"standalone",children:"独立部署"})]})]})]}),l.jsx(ye,{id:"storageRoot",label:"存储目录",value:t.CSS_ROOT_FILE_PATH||"./data",onChange:E=>R("CSS_ROOT_FILE_PATH",E)})]}),l.jsx(ye,{id:"baseUrl",label:"资料入口 URL",value:_?L:t.CSS_BASE_URL||"http://127.0.0.1:3000",onChange:E=>R("CSS_BASE_URL",E),readOnly:_,helper:_?"托管模式下由 Cloud 分配稳定域名,本地只上报状态和隧道入口。":"独立部署需要保证该 URL 可被目标客户端访问。"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:O==="local"?"边缘部署:Cloud IDP 和稳定域名在云端,数据/SP 保留在本地。":"独立部署:域名、身份认证和证书都由本机或用户自管。"})]})]}),l.jsxs(Fe,{variant:"bordered",className:"mb-6",children:[l.jsx(Ye,{className:"pb-2",children:l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx(Ge,{children:"网络访问"}),l.jsxs("span",{className:"text-sm",children:["外网: ",l.jsx("span",{className:se(I==="pass"?"text-green-700 dark:text-green-300":I==="fail"?"text-destructive":"text-muted-foreground"),children:de})]})]})}),l.jsxs(Ue,{className:"space-y-4",children:[_&&d?.mode==="tunnel"&&re==="none"?l.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"当前网络不可直连,请启用一个隧道供应商。"}):null,l.jsxs("div",{className:"space-y-2",children:[l.jsx(Qe,{children:"当前生效"}),l.jsxs(wt,{value:Z,onValueChange:xe,children:[l.jsx(it,{children:l.jsx(St,{})}),l.jsxs(ct,{children:[l.jsx(me,{value:"none",children:"不使用隧道"}),X.map(E=>l.jsx(me,{value:E.id,children:E.label},E.id))]})]}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"可以记录多个隧道配置,但同一时间只启用当前选择的一个。公网、局域网、本机和 P2P 由状态页判断最优接入。"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-sm font-medium",children:"已记录隧道"}),l.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:X.map(E=>{const j=E.id===Z;return l.jsxs("div",{className:se("rounded-xl border p-3",j?"border-primary bg-primary/5":"border-border"),children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-sm font-medium",children:E.label}),l.jsx(Ze,{type:"button",variant:j?"secondary":"ghost",size:"sm",onClick:()=>xe(E.id),disabled:j,children:j?"当前生效":"设为当前"})]}),l.jsx("div",{className:"mt-2 break-all font-mono text-xs text-muted-foreground",children:E.publicEndpointUrl||"未配置入口"}),l.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:E.credentialConfigured?"密钥已配置":"未配置密钥"})]},E.id)})})]}),ie&&q?l.jsxs("div",{className:"space-y-4 rounded-xl border border-border p-4",children:[l.jsx("div",{className:"text-sm font-medium",children:"编辑当前隧道"}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("div",{className:"text-xs text-muted-foreground",children:"隧道入口 URL"}),l.jsx(ye,{id:"tunnelPublicEndpoint",label:q.publicEndpointLabel,value:ie.publicEndpointUrl,onChange:E=>D(ie,E),placeholder:q.publicEndpointPlaceholder,helper:"这是实际数据面入口,不替代上方的稳定资料 URL。"})]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("div",{className:"text-xs text-muted-foreground",children:"访问密钥"}),l.jsx(Et,{id:"tunnelCredential",label:q.credentialLabel,configured:B(q.credentialKey),value:s[q.credentialKey]||"",onChange:E=>U(q.credentialKey,E)})]})]}):l.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:"不使用隧道时,不填写隧道入口 URL 或访问密钥。"})]})]}),l.jsxs(Fe,{variant:"bordered",className:"mb-6",children:[l.jsx(Ye,{children:l.jsx(Ge,{children:"Cloud 协调"})}),l.jsxs(Ue,{className:"space-y-4",children:[l.jsx(ye,{id:"cloudEndpoint",label:"Cloud API endpoint",value:t.XPOD_CLOUD_API_ENDPOINT||"",onChange:E=>R("XPOD_CLOUD_API_ENDPOINT",E)}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsx(ye,{id:"nodeId",label:"nodeId",value:t.XPOD_NODE_ID||"",onChange:E=>R("XPOD_NODE_ID",E)}),l.jsx(ye,{id:"spDomain",label:"spDomain",value:t.XPOD_SP_DOMAIN||"",onChange:E=>R("XPOD_SP_DOMAIN",E)})]}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsx(Et,{id:"nodeToken",label:"Node token",configured:B("XPOD_NODE_TOKEN"),value:s.XPOD_NODE_TOKEN||"",onChange:E=>U("XPOD_NODE_TOKEN",E)}),l.jsx(Et,{id:"serviceToken",label:"Service token",configured:B("XPOD_SERVICE_TOKEN"),value:s.XPOD_SERVICE_TOKEN||"",onChange:E=>U("XPOD_SERVICE_TOKEN",E)})]})]})]}),O==="standalone"?l.jsxs(Fe,{variant:"bordered",className:"mb-6",children:[l.jsx(Ye,{children:l.jsx(Ge,{children:"HTTPS"})}),l.jsxs(Ue,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Qe,{children:"HTTPS 模式"}),l.jsxs(wt,{value:N,onValueChange:E=>R("XPOD_HTTPS_MODE",E),children:[l.jsx(it,{children:l.jsx(St,{})}),l.jsxs(ct,{children:[l.jsx(me,{value:"none",children:"关闭"}),l.jsx(me,{value:"acme",children:"自动申请 ACME"}),l.jsx(me,{value:"manual",children:"手动证书"})]})]})]}),N==="manual"?l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsx(ye,{id:"certPath",label:"证书路径",value:t.XPOD_HTTPS_CERT_PATH||"",onChange:E=>R("XPOD_HTTPS_CERT_PATH",E)}),l.jsx(ye,{id:"keyPath",label:"私钥路径",value:t.XPOD_HTTPS_KEY_PATH||"",onChange:E=>R("XPOD_HTTPS_KEY_PATH",E)})]}):null]})]}):null,l.jsx("div",{className:"mb-6",children:l.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>P(E=>!E),children:C?"收起高级设置":"展开高级设置"})}),C?l.jsxs(Fe,{variant:"bordered",className:"mb-6",children:[l.jsx(Ye,{children:l.jsx(Ge,{children:"高级设置"})}),l.jsxs(Ue,{className:"space-y-4",children:[l.jsx(ye,{id:"cssPort",label:"端口",value:t.CSS_PORT||"3000",onChange:E=>R("CSS_PORT",E)}),l.jsx(ye,{id:"sparqlEndpoint",label:"SPARQL 存储",value:t.CSS_SPARQL_ENDPOINT||"",onChange:E=>R("CSS_SPARQL_ENDPOINT",E)}),l.jsx(Et,{id:"identityDb",label:"身份数据库 URL",configured:B("CSS_IDENTITY_DB_URL"),value:s.CSS_IDENTITY_DB_URL||"",onChange:E=>U("CSS_IDENTITY_DB_URL",E)}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Qe,{children:"日志级别"}),l.jsxs(wt,{value:t.CSS_LOGGING_LEVEL||"info",onValueChange:E=>R("CSS_LOGGING_LEVEL",E),children:[l.jsx(it,{className:"w-40",children:l.jsx(St,{})}),l.jsxs(ct,{children:[l.jsx(me,{value:"error",children:"error"}),l.jsx(me,{value:"warn",children:"warn"}),l.jsx(me,{value:"info",children:"info"}),l.jsx(me,{value:"debug",children:"debug"})]})]})]}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[l.jsx("input",{type:"checkbox",id:"showStackTrace",checked:t.CSS_SHOW_STACK_TRACE==="true",onChange:E=>R("CSS_SHOW_STACK_TRACE",E.target.checked?"true":"false"),className:"rounded border-input"}),"显示错误堆栈"]})]})]}):null,l.jsx(da,{changes:Q,onReset:ve}),e&&!e.configurationWriteCapability.supported?l.jsxs("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 text-sm text-muted-foreground",children:["Configuration changes are not supported from this host capability",e.configurationWriteCapability.reason?`: ${e.configurationWriteCapability.reason}`:"","."]}):l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx(Ze,{onClick:()=>{W()},disabled:h||!!V,children:h?"保存中...":"保存配置"}),e&&!e.restartCapability.supported?null:l.jsx(Ze,{variant:"secondary",onClick:()=>{Y()},disabled:h||!!V,children:"保存并重启"})]}),b||V?l.jsx("div",{className:se("mt-4 rounded-md border px-3 py-2 text-sm",V||b&&b.includes("失败")?"border-destructive/30 bg-destructive/10 text-destructive":"border-green-200 bg-green-50 text-green-800 dark:border-green-900 dark:bg-green-950/20 dark:text-green-200"),children:b||V}):null]})}export{Ca as SettingsPage};
|