@soba-so/react 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConnectPill.d.ts +31 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +47 -15
- package/dist/styles.css +40 -8
- package/dist/useConnectButton.d.ts +10 -6
- package/package.json +9 -8
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Machine } from "./types.js";
|
|
2
|
+
export interface ConnectPillProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
/** The machine the pill is about. `useConnectButton().machine` is the one to
|
|
4
|
+
* pass; `compute.machines[0]` is not, because that list is ordered by
|
|
5
|
+
* heartbeat and a laptop that slept a minute ago outranks a desktop that has
|
|
6
|
+
* been serving for an hour. */
|
|
7
|
+
machine: Machine | null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* WHAT IS CONNECTED AND WHETHER IT IS AWAKE, AS ONE CONTROL FOR A HEADER.
|
|
11
|
+
*
|
|
12
|
+
* ```jsx
|
|
13
|
+
* const { machine } = useConnectButton()
|
|
14
|
+
*
|
|
15
|
+
* <ConnectPill machine={machine} onClick={() => setOpen(true)} />
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The reporting half of `<ConnectButton />`, which is that pill plus our
|
|
19
|
+
* popover plus the pairing flow. Reach for this one when the app has its own
|
|
20
|
+
* idea of what pressing it does — its own panel, its own sheet, its own route —
|
|
21
|
+
* and for the usual case reach for `<ConnectButton />`, which wires all three.
|
|
22
|
+
*
|
|
23
|
+
* NOTHING IN IT IS THIS PACKAGE'S. The words, the dot's tone and the accessible
|
|
24
|
+
* name are `connectSays`, the same function the button and the dashboard's bar
|
|
25
|
+
* read, so three controls on three surfaces cannot end up disagreeing about one
|
|
26
|
+
* laptop. Pressing it is the only thing left for a host to decide.
|
|
27
|
+
*
|
|
28
|
+
* IT DRAWS NOTHING WITH NOTHING PAIRED. A pill reporting "no compute" is a
|
|
29
|
+
* readout of an absence; `<ConnectButton />` draws the door instead.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ConnectPill: import("react").ForwardRefExoticComponent<ConnectPillProps & import("react").RefAttributes<HTMLButtonElement>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { ConnectButton, type ConnectButtonProps } from "./ConnectButton.js";
|
|
|
3
3
|
export { ConnectCompute, type ConnectComputeProps } from "./ConnectCompute.js";
|
|
4
4
|
export { ConnectModal, type ConnectModalProps } from "./ConnectModal.js";
|
|
5
5
|
export { ConnectNudge, type ConnectNudgeProps } from "./ConnectNudge.js";
|
|
6
|
+
export { ConnectPill, type ConnectPillProps } from "./ConnectPill.js";
|
|
6
7
|
export { type ComputeState, type ConnectReason, type ConnectState, type PlanState, type RunRequest, type SobaContextValue, useSoba, } from "./context.js";
|
|
7
8
|
export { collectText, parseEvent, readEvents } from "./events.js";
|
|
8
9
|
export { ModelPicker, type ModelPickerProps } from "./ModelPicker.js";
|
|
@@ -21,9 +22,9 @@ export { type ComputeMachine, type ComputeRuntime, type ComputeView, useCompute,
|
|
|
21
22
|
export { type ConnectButtonView, connectSays, useConnectButton } from "./useConnectButton.js";
|
|
22
23
|
export { type NudgeReason, type NudgeStalled, type NudgeStep, type NudgeView, type UseConnectNudgeOptions, useConnectNudge, } from "./useConnectNudge.js";
|
|
23
24
|
export { type AllowanceState, type CurrentPlanReward, type CurrentPlanView, useCurrentPlan, } from "./useCurrentPlan.js";
|
|
25
|
+
export { type MachineRunsOptions, type MachineRunsView, useMachineRuns } from "./useMachineRuns.js";
|
|
24
26
|
export { type ModelView, type UseModelOptions, useModel } from "./useModel.js";
|
|
25
27
|
export { useOpenSobaConnect } from "./useOpenSobaConnect.js";
|
|
26
28
|
export { type PlanCompute, type PlanConnect, type PlanCta, type PlanOffer, type PlanPrice, type PlansOptions, type PlansView, usePlans, } from "./usePlans.js";
|
|
27
29
|
export { type LimitReason, type Offer, sobaErrorCode, useRunLimit } from "./useRunLimit.js";
|
|
28
30
|
export { type RunStream, type WatchOptions, watchRun } from "./watch.js";
|
|
29
|
-
export { type MachineRunsOptions, type MachineRunsView, useMachineRuns } from "./useMachineRuns.js";
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import{useRef as ps,useState as so}from"react";var Cn=class extends Error{status;constructor(n,t){super(n),this.name="ConnectError",this.status=t}},ss=5*6e4,Ln=class{session;baseUrl;doFetch;lastMachines=null;machinesUrl=null;gatewayBackUntil=0;constructor(n){this.session=n.session,this.baseUrl=(n.baseUrl??"").replace(/\/+$/,""),this.doFetch=n.fetchImpl??fetch.bind(globalThis)}async context(){let n=await this.request("GET","/v1/connect");return this.setMachinesUrl(n.machines_url),n}setMachinesUrl(n){typeof n=="string"&&/^https?:\/\//.test(n)&&(this.machinesUrl=n)}async machines(){let n=this.lastMachines,t=n?`?v=${encodeURIComponent(n.version)}`:"",r;if(this.machinesUrl&&Date.now()>=this.gatewayBackUntil)try{r=await this.request("GET",`${this.machinesUrl}${t}`)}catch(s){if(s instanceof Cn&&s.status===401)throw s;this.gatewayBackUntil=Date.now()+ss}if(r??=await this.request("GET",`/v1/machines${t}`),r.unchanged&&n)return n.machines;let o=Array.isArray(r.machines)?r.machines:[];return this.lastMachines=typeof r.version=="string"?{version:r.version,machines:o}:null,o}async runs(){let n=await this.request("GET","/v1/machines/runs");return Array.isArray(n.runs)?n.runs:[]}async stopRun(n){let t=this.machinesUrl?.replace(/\/v1\/machines$/,"");if(!t)throw new Cn("This page can't stop runs yet: it hasn't been told where Soba's gateway is.",501);await this.request("POST",`${t}/v1/runs/${encodeURIComponent(n)}/stop`,{})}lookup(n){return this.request("GET",`/v1/device/lookup?code=${encodeURIComponent(n)}`)}approve(n){return this.request("POST","/v1/device/approve",{user_code:n})}claim(n){return this.request("POST","/v1/device/claim",{pairing_nonce:n})}deny(n){return this.request("POST","/v1/device/deny",{user_code:n})}plans(){return this.request("GET","/v1/plans")}selectPlan(n){return this.request("POST","/v1/plans/select",{plan:n})}checkoutPlan(n,t){return this.request("POST","/v1/plans/checkout",{plan:n,...t?.successUrl?{success_url:t.successUrl}:{},...t?.cancelUrl?{cancel_url:t.cancelUrl}:{}})}leavePlan(){return this.request("DELETE","/v1/plans/select")}hosted(){return this.request("GET","/v1/hosted")}startHosted(){return this.request("POST","/v1/hosted/start")}disconnectHosted(n){return this.request("DELETE",n?`/v1/hosted?provider=${encodeURIComponent(n)}`:"/v1/hosted")}approveRuntime(n,t){return this.request("POST","/v1/runtimes/approve",{machine_id:n,runtime_id:t})}preferRuntime(n,t){return this.request("POST","/v1/runtimes/prefer",{machine_id:n,runtime_id:t})}async request(n,t,r){let o=await this.doFetch(/^https?:\/\//.test(t)?t:`${this.baseUrl}${t}`,{method:n,headers:{authorization:`Bearer ${this.session}`,...r?{"content-type":"application/json"}:{}},...r?{body:JSON.stringify(r)}:{}}),s={};try{s=await o.json()}catch{}if(!o.ok){let a=typeof s.error=="string"?s.error:`Request failed (${o.status})`;throw new Cn(a,o.status)}return s}};function An(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return"#ffffff";let t=n[1].length===3?[...n[1]].map(s=>s+s).join(""):n[1],r=s=>{let a=Number.parseInt(t.slice(s*2,s*2+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4};return .2126*r(0)+.7152*r(1)+.0722*r(2)>.45?"#101012":"#ffffff"}function At(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return null;let t=n[1].length===3?[...n[1]].map(r=>r+r).join(""):n[1];return[0,1,2].map(r=>Number.parseInt(t.slice(r*2,r*2+2),16))}function kn(e,n,t){let r=At(e),o=At(n);return!r||!o?e:`#${r.map((a,c)=>Math.round(a+(o[c]-a)*t)).map(a=>a.toString(16).padStart(2,"0")).join("")}`}function an(e,n){if(!At(e))return{};let t=An(e),r=n?.trim();return{"--sc-ground":e,"--sc-shell":e,"--sc-sheet":kn(e,t,.07),"--sc-raised":kn(e,t,.13),"--sc-line":kn(e,t,.18),"--sc-line-2":kn(e,t,.28),"--sc-text":t,"--sc-text-2":kn(t,e,.15),"--sc-muted":kn(t,e,.38),...r?{"--sc-accent":r,"--sc-accent-fg":An(r)}:{"--sc-accent":t,"--sc-accent-fg":e}}}function $n(e){return e.authenticated===!0?{tone:"ok",text:"signed in"}:e.authenticated===!1?{tone:"warn",text:e.auth_hint??"signed out on that machine"}:{tone:"unknown",text:"could not tell"}}function Dn(e){let{platform:n,arch:t}=e;if(!n)return null;let r=n==="darwin"||n==="macos",o=r?"Mac":n==="win32"||n==="windows"?"Windows PC":"Linux machine";return r?`${t==="aarch64"||t==="arm64"?"Apple silicon ":""}${o}`:o}function ln(e){return e.find(n=>n.state==="offline")??null}function $t(e){return e.state==="busy"?{tone:"busy",text:`serving ${e.active} of ${e.capacity}`}:e.state==="online"?{tone:"ok",text:"connected"}:{tone:"off",text:"asleep or offline"}}function K(e){let n=e.label?.trim(),t=e.name?.trim();return n&&(!t||n!==t)?n:(t??n??"").replace(/\.(local|lan|home|internal)$/i,"").replace(/[-_]+/g," ").trim()||n||"This machine"}function ft(e,n){let t=o=>o.state==="busy"?0:o.state==="online"?1:2,r=o=>o.last_seen_at?Date.parse(o.last_seen_at):0;return t(e)-t(n)||r(n)-r(e)}function Ee(e){return[...e].sort(ft)[0]??null}function Ge(e){return e?e.state==="busy"?{tone:"busy",word:"Serving"}:e.state==="online"?{tone:"ok",word:"Connected"}:{tone:"off",word:"Asleep"}:{tone:"off",word:"No compute"}}function Dt(e){return e.state==="online"||e.state==="busy"}function Un(e){if(!e)return"never seen";let n=Date.parse(e);if(Number.isNaN(n))return"never seen";let t=Date.now()-n,r=6e4;return t<2*r?"just now":t<60*r?`${Math.floor(t/r)} min ago`:t<24*60*r?`${Math.floor(t/(60*r))} hr ago`:`${Math.floor(t/(24*60*r))} days ago`}function ye(e){return e.runtimes.filter(n=>n.id!=="shell"&&!n.quarantined&&!n.absent)}function De(e){let n=a=>a?e.runtimes.find(c=>c.id===a)??null:null;if(e.requested_runtime)return{by:"app",runtimeId:e.requested_runtime,runtime:n(e.requested_runtime)};let t=ye(e),r=t.find(a=>a.id===e.preferred_runtime);if(r)return{by:"you",runtimeId:r.id,runtime:r};let o=a=>a.id==="claude-code"?0:a.id==="codex"?1:2,s=[...t].sort((a,c)=>o(a)-o(c))[0]??null;return{by:"default",runtimeId:s?.id??null,runtime:s}}import{useEffect as eo,useRef as as}from"react";import{Fragment as cs,jsx as xe,jsxs as Ut}from"react/jsx-runtime";function Hn({anchor:e,label:n,options:t,current:r,onClose:o,onPick:s}){let a=as(null);return eo(()=>{let i=a.current,l=e.current;if(!i||!l)return;try{typeof i.showPopover=="function"&&i.showPopover()}catch{}let u=l.getBoundingClientRect(),p=i.offsetWidth,y=i.offsetHeight,f=Math.max(8,Math.min(u.right-p,window.innerWidth-p-8)),m=u.bottom+6,w=m+y>window.innerHeight-8&&u.top-6-y>8?u.top-6-y:m;i.style.left=`${Math.round(f)}px`,i.style.top=`${Math.round(w)}px`,i.querySelector('[aria-checked="true"]')?.focus()},[e]),eo(()=>{let i=l=>{let u=l.target;!u||a.current?.contains(u)||e.current?.contains(u)||o()};return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[e,o]),xe("div",{ref:a,role:"menu","aria-label":n,className:"sc-menu",popover:"manual",onKeyDown:i=>{let l=[...a.current?.querySelectorAll("[role=menuitemradio]")??[]],u=l.indexOf(document.activeElement);if(i.key==="Escape")i.stopPropagation(),i.nativeEvent.stopImmediatePropagation(),o(),e.current?.focus();else if(i.key==="ArrowDown"||i.key==="ArrowUp"){i.preventDefault();let p=i.key==="ArrowDown"?1:-1;l[(u+p+l.length)%l.length]?.focus()}else i.key==="Tab"&&o()},children:t.map(i=>xe(is,{option:i,checked:r===i.id,onClose:o,onPick:s},i.id??""))})}function is({option:e,checked:n,onClose:t,onPick:r}){return Ut(cs,{children:[e.heading?xe("div",{className:"sc-menu-head",role:"presentation",children:e.heading}):e.rule?xe("div",{className:"sc-menu-sep"}):null,Ut("button",{type:"button",role:"menuitemradio","aria-checked":n,className:"sc-menu-item",onClick:()=>n?t():r(e.id),children:[e.glyph,Ut("span",{className:"sc-menu-text",children:[xe("span",{className:"sc-menu-label",children:e.label}),e.note&&xe("span",{className:"sc-menu-note",children:e.note})]}),n&&xe(ls,{})]})]})}function ls(){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-menu-check",children:xe("path",{d:"M5 12.5l4.5 4.5L19 7.5",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Nn({open:e}){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-chev sc-chev-open":"sc-chev",children:xe("path",{d:"M9 6l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as we,jsxs as ds}from"react/jsx-runtime";function j({className:e}){return ds("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:[we("path",{d:"M18.125 7.039A8.6 8.6 0 1 0 18.125 16.961A6 6 0 0 1 18.125 7.039Z",fill:"currentColor"}),we("path",{d:"M19.925 7.039A8.6 8.6 0 0 1 19.925 16.961A6 6 0 0 0 19.925 7.039Z",fill:"currentColor"})]})}function no({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{fill:"currentColor",d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})})}function cn({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{fill:"currentColor",d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})})}function ht({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M4 5h16v11H4zM9 20h6M12 16v4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function us({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M5 7l5 5-5 5M12 18h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ht({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M5 6h14v10H5zM2.5 19.5h19",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var ze={claude:no,chatgpt:cn,local:ht},to={shell:us};var ie=[{id:"claude",costClass:"user-subscription",short:"Claude Code",label:"Continue with Claude",title:"The Claude plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Claude Code installed and signed in",hint:"Install it from claude.ai/code, then run `claude` once and sign in.",install:"https://claude.com/product/claude-code",expects:["claude-code"]},{id:"chatgpt",costClass:"user-subscription",short:"Codex",label:"Continue with ChatGPT",title:"The ChatGPT plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Codex installed and signed in",hint:"Install Codex, then run `codex` once and sign in.",install:"https://learn.chatgpt.com/codex/cli",expects:["codex"]},{id:"local",costClass:"user-hardware",short:"Local models",label:"Use a model on this machine",title:"A model on your own machine",cost:"Free. You bought the hardware",prerequisite:"Ollama running, with a model pulled",hint:"Install Ollama, then `ollama pull` a model before pairing.",install:"https://ollama.com",expects:["ollama","openai-api"]}],ro=["claude","chatgpt"];function Wt(){return ie.filter(e=>ro.includes(e.id))}function Bt(e){return ie.filter(n=>n.costClass===e)}function qt(e){return ie.find(n=>n.expects.includes(e))??null}import{Fragment as io,jsx as g,jsxs as I}from"react/jsx-runtime";function un({machines:e,hosted:n=[],onApproveRuntime:t,onPreferRuntime:r,onDisconnectHosted:o,onPair:s,onRefresh:a,refreshing:c,busy:i,appName:l,error:u,runs:p,runsOpen:y,onToggleRuns:f,markOf:m,loading:w,machineMenu:M,machineNote:R,children:_,onStopRun:U}){let P=Ee(e),T=e.filter(S=>S.id!==P?.id),E=P&&p?hs(p,P):{};return!P&&n.length===0&&!s?g("p",{className:"sc-note",children:"Nothing connected yet."}):I("div",{className:"sc-tray",children:[P&&I(xn,{title:"This machine",action:(a||M)&&I("span",{className:"sc-cap-acts",children:[a&&g("button",{type:"button",className:"sc-disc",onClick:a,disabled:c,"aria-label":"Refresh",title:"Refresh",children:g(Rs,{spinning:!!c})}),M]}),children:[g(ms,{machine:P,...f?{onToggle:f,open:!!y}:{}}),R]}),P&&f&&y&&g(gs,{machine:P,runs:p??null,...m?{markOf:m}:{},...U?{onStop:U}:{}}),P&&g(xn,{title:"Agents on it",action:g(Ns,{machine:P,appName:l,busy:i,...m?{markOf:m}:{},...r?{onPick:S=>r(P.id,S)}:{}}),children:w&&P.runtimes.length===0?g("p",{className:"sc-row-note",children:"Looking\u2026"}):P.runtimes.length>0?P.runtimes.map(S=>g(ks,{runtime:S,serving:E[S.id]??S.serving??0,...m?{mark:m(S)}:{},...t?{onApprove:()=>t(P.id,S.id)}:{}},S.id)):g("p",{className:"sc-row-note",children:"No agent advertised. Install Claude Code, Codex or Ollama on that machine."})}),n.length>0&&g(xn,{title:n.length>1?"Connected plans":"Connected plan",children:n.map(S=>g(Ss,{credential:S,appName:l,busy:i,...o?{onDisconnect:()=>o(S.provider)}:{}},S.provider))}),(T.length>0||s)&&I(xn,{title:T.length>0?"Your other machines":P?"Add a machine":"Your machines",children:[T.map(S=>g(vs,{machine:S},S.id)),s&&I("button",{type:"button",className:"sc-pair",onClick:s,children:[g("span",{className:"sc-otile","aria-hidden":"true",children:g(Ms,{})}),g("span",{className:"sc-oname",children:e.length>0?"Pair another machine":"Connect a machine"})]})]}),_,u&&g("p",{className:"sc-error sc-tray-error",children:u})]})}function xn({title:e,action:n,children:t}){return I("section",{className:"sc-group",children:[I("div",{className:"sc-group-cap",children:[g("p",{className:"sc-group-title",children:e}),n]}),g("div",{className:"sc-group-card",children:t})]})}function ms({machine:e,onToggle:n,open:t}){let r=Dt(e),o=[r?null:e.pairing_lost?"No longer connected here":"Asleep or offline",Dn(e),e.always_on?"always on":null,r&&e.capacity>0?`${e.active} of ${e.capacity} in flight`:Un(e.last_seen_at)].filter(Boolean),s=I(io,{children:[I("span",{className:"sc-mtile","aria-hidden":"true",children:[g(ao,{}),g("span",{className:`sc-mbadge sc-mbadge-${Ge(e).tone}`})]}),I("span",{className:"sc-mid",children:[g("span",{className:"sc-mname",children:K(e)}),g("span",{className:"sc-mmeta",children:o.map((a,c)=>I("span",{children:[c>0&&g("span",{className:"sc-mmeta-sep",children:"\xB7"}),a]},a))})]})]});return!n||!r?g("div",{className:"sc-mrow",children:s}):I("button",{type:"button",className:"sc-mrow sc-mrow-btn",onClick:n,"aria-expanded":!!t,title:t?"Hide what it is running":"See what it is running",children:[s,g(Nn,{open:!!t})]})}function fs(e,n){return e.filter(t=>t.machine_id===n.id||t.machine_id===null)}function hs(e,n){let t={};for(let r of e)r.machine_id!==n.id||r.status!=="running"||!r.runtime_id||(t[r.runtime_id]=(t[r.runtime_id]??0)+1);return t}function gs({machine:e,runs:n,markOf:t,onStop:r}){let o=n?fs(n,e):[],s=l=>{if(!l||!t)return null;let u=e.runtimes.find(p=>p.id===l);return u?t(u):null},[a,c]=so(new Set),i=async l=>{c(u=>new Set(u).add(l));try{await r?.(l)}catch{c(u=>{let p=new Set(u);return p.delete(l),p})}};return g(xn,{title:"Running now",children:n===null?g("p",{className:"sc-row-note",children:"Looking\u2026"}):o.length===0?g("p",{className:"sc-row-note",children:"Nothing running."}):o.map(l=>{let u=s(l.runtime_id);return g(bs,{run:l,...u?{mark:u}:{},stopping:a.has(l.id),...r?{onStop:()=>void i(l.id)}:{}},l.id)})})}function bs({run:e,mark:n,stopping:t,onStop:r}){let o=e.runtime_id?gt(e.runtime_id):null;return I("div",{className:"sc-rrow",children:[g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:n??(o&&g(o,{className:"sc-runtime-mark"}))}),I("span",{className:"sc-mid",children:[I("span",{className:"sc-rtop",children:[g("span",{className:"sc-aname",children:oo(e)}),g("span",{className:"sc-averdict",children:ws(e.started_at)})]}),g("span",{className:"sc-rstep",children:t?"Stopping\u2026":ys(e)})]}),r&&g("button",{type:"button",className:"sc-disc sc-rstop",onClick:r,disabled:t,"aria-label":`Stop ${oo(e)}`,title:"Stop",children:g(_s,{})})]})}function gt(e){let n=qt(e);return(n?ze[n.id]:null)??to[e]??null}function oo(e){if(e.label)return e.label;if(e.task){let n=e.task.replace(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}return"A run"}function ys(e){if(e.status==="queued")return"Waiting for a free slot";if(e.step)return e.step;switch(e.phase?.kind){case"thinking":return"Thinking";case"writing":return"Writing";case"tool":return e.phase.tool?`Using ${e.phase.tool}`:"Using a tool";case"approval":return e.phase.tool?`Waiting for you to allow ${e.phase.tool}`:"Waiting for your approval";default:return e.first_output_at?"Working":"Starting"}}function ws(e){let n=Math.max(0,Math.round((Date.now()-new Date(e).getTime())/1e3));if(n<60)return`${n}s`;let t=Math.floor(n/60);return t<60?`${t}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function vs({machine:e}){let n=Ge(e);return I("div",{className:"sc-orow",children:[g("span",{className:"sc-otile","aria-hidden":"true",children:g(ao,{})}),g("span",{className:"sc-oname",children:K(e)}),g("span",{className:"sc-oword",children:n.word}),g("span",{className:`sc-dot sc-dot-${n.tone}`,"aria-hidden":"true"})]})}function ks({runtime:e,serving:n=0,mark:t,onApprove:r}){let o=$n(e),s=I(io,{children:[g(Cs,{runtime:e,mark:t}),I("span",{className:e.absent?"sc-aname sc-aname-absent":"sc-aname",children:[e.display_name,e.version&&I("span",{className:"sc-aversion",children:[" ",e.version]})]}),n>0?I("span",{className:"sc-averdict",children:[g(Ps,{}),g("span",{className:"sc-aserving",children:n>1?`${n} running`:"running"})]}):e.absent?g("span",{className:"sc-averdict sc-tone-absent",children:"not offered"}):e.quarantined?r?g("button",{type:"button",className:"sc-row-act",onClick:r,children:"Let it serve"}):g("span",{className:"sc-averdict sc-tone-warn",children:"new, not serving yet"}):o.tone==="ok"?I("span",{className:"sc-averdict",children:[g("span",{className:"sc-dot sc-dot-ok","aria-hidden":"true"}),g("span",{className:"sc-sr",children:o.text})]}):g("span",{className:`sc-averdict sc-tone-${o.tone}`,children:o.text})]});return g("div",{className:"sc-arow",children:s})}function Cs({runtime:e,mark:n}){if(n)return g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:n});let t=gt(e.id);return g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:t&&g(t,{className:"sc-runtime-mark"})})}function Ns({machine:e,appName:n,busy:t,markOf:r,onPick:o}){let s=De(e),a=ye(e),[c,i]=so(!1),l=ps(null);if(s.by!=="app"&&a.length===0)return null;let u=f=>{if(!f)return null;if(r)return r(f);let m=gt(f.id);return g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:m&&g(m,{className:"sc-runtime-mark"})})},p=f=>{if(!f)return null;if(r)return g("span",{className:"sc-runs-mark",children:r(f)});let m=gt(f.id);return m?g(m,{className:"sc-runs-glyph"}):null},y;return s.by==="app"?y=I("span",{className:"sc-runs-fixed",title:`Set by ${n??"the app"}`,children:[p(s.runtime),s.runtime?.display_name??s.runtimeId]}):!o||a.length<2?y=I("span",{className:"sc-runs-fixed",children:[p(s.runtime),s.runtime?.display_name]}):y=I("button",{ref:l,type:"button",className:"sc-runs-btn","aria-haspopup":"menu","aria-expanded":c,"aria-label":`Runs go to ${s.runtime?.display_name??"the default"}. Change`,disabled:t,onClick:()=>i(f=>!f),children:[p(s.runtime),g("span",{className:"sc-runs-label",children:s.runtime?.display_name}),g(Nn,{open:!0})]}),I("span",{className:"sc-runs-to",children:[g("span",{className:"sc-runs-cap",children:s.by==="app"?`${n??"App"} uses`:"Runs on"}),y,c&&o&&g(xs,{anchor:l,machine:e,tile:u,onClose:()=>i(!1),onPick:f=>{i(!1),o(f)}})]})}function xs({anchor:e,machine:n,tile:t,onClose:r,onPick:o}){let s=De(n),a=De({...n,preferred_runtime:null}).runtime,c=s.by==="you"?s.runtimeId:null,i=[{id:null,label:"Automatic",...a?{note:`Uses ${a.display_name}`}:{},glyph:t(a)},...ye(n).map((l,u)=>({id:l.id,label:l.display_name,glyph:t(l),...u===0?{rule:!0}:{}}))];return g(Hn,{anchor:e,label:"Which agent runs go to",options:i,current:c,onClose:r,onPick:o})}function Ss({credential:e,appName:n,busy:t,onDisconnect:r}){return I("div",{className:"sc-hrow",children:[I("div",{className:"sc-orow",children:[g("span",{className:"sc-otile","aria-hidden":"true",children:g(cn,{className:"sc-omark"})}),I("span",{className:"sc-mid",children:[g("span",{className:"sc-oname",children:e.provider==="openai-chatgpt"?"ChatGPT plan":e.provider}),g("span",{className:"sc-mmeta",children:e.account_label??"signed in"})]}),r&&g("button",{type:"button",className:"sc-row-act",onClick:r,disabled:t,children:"Disconnect"})]}),r&&I("p",{className:"sc-row-note",children:[n??"This app"," stops using it. To withdraw the grant entirely, remove it in your OpenAI settings."]})]})}function ao(){return I("svg",{viewBox:"0 0 32 24","aria-hidden":"true",focusable:"false",className:"sc-mglyph",children:[g("rect",{x:"4",y:"1.5",width:"24",height:"15",rx:"2.5",fill:"var(--sc-sheet, #ffffff)",stroke:"currentColor",strokeWidth:"2"}),g("rect",{x:"1",y:"19.5",width:"30",height:"2.5",rx:"1.25",fill:"currentColor"})]})}function Ms(){return g("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-oglyph",children:g("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function Ps(){return I("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-sglyph sc-spin",children:[g("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),g("path",{d:"M12 3a9 9 0 0 1 9 9",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Rs({spinning:e}){return g("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-dglyph sc-spin":"sc-dglyph",children:g("path",{d:"M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function _s(){return g("svg",{className:"sc-dglyph",viewBox:"0 0 16 16","aria-hidden":"true",children:g("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5",fill:"currentColor"})})}import{jsx as Es}from"react/jsx-runtime";function Wn({machines:e,onApproveRuntime:n}){return Es(un,{machines:e,...n?{onApproveRuntime:n}:{}})}var Ft={ready:{arc:!0},serving:{arc:!0,slot:"stream"},paused:{arc:!1,slot:"zzz"},thinking:{arc:!1,slot:"dots"},connecting:{arc:!1,slot:"orbit"},attention:{arc:!1,slot:"bang"},gone:{arc:!1,slot:"cross"},snap:{arc:!1,slot:"snap"},listening:{arc:!1,slot:"bars"},permission:{arc:!1,slot:"ring"},ai:{arc:!1,slot:"sparks"}};var Gt="105 162 420 420",zt="M407.1 308.9 A158 158 0 1 0 407.1 491.1 A116 116 0 0 1 407.1 308.9 Z",dn="M448.5 320 A110 110 0 0 1 448.5 480";import{Fragment as qn,jsx as x,jsxs as Ve}from"react/jsx-runtime";function Vt({kind:e,size:n=44,className:t}){let r=Ft[e];return Ve("svg",{className:`bx${t?` ${t}`:""}`,"data-expression":e,viewBox:Gt,overflow:"visible",width:n,height:n,"aria-hidden":"true",children:[x("path",{d:zt,fill:"currentColor"}),x("path",{className:"bx-arc",d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),r.slot==="stream"&&x(Os,{}),r.slot==="zzz"&&x(Is,{}),r.slot==="dots"&&x(Ts,{}),r.slot==="bang"&&x(Ls,{}),r.slot==="orbit"&&x(As,{}),r.slot==="cross"&&x($s,{}),r.slot==="snap"&&x(Ds,{}),r.slot==="bars"&&x(Us,{}),r.slot==="ring"&&x(Hs,{}),r.slot==="sparks"&&x(Ws,{})]})}function Os(){return x("path",{className:"bx-st",d:"M475.3 290.3 A150 150 0 0 1 475.3 509.7",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeDasharray:"0.1 31"})}function Is(){return Ve(qn,{children:[x("g",{className:"bx-z1",children:x("path",{d:"M444 372 H496 L444 436 H496",fill:"none",stroke:"currentColor",strokeWidth:"20",strokeLinecap:"round",strokeLinejoin:"round"})}),x("g",{className:"bx-z2",children:x("path",{d:"M492 300 H522 L492 338 H522",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeLinejoin:"round"})})]})}function Ts(){return Ve(qn,{children:[x("circle",{className:"bx-th",cx:"463.1",cy:"336.9",r:"21",fill:"currentColor"}),x("circle",{className:"bx-th bx-th2",cx:"483",cy:"400",r:"21",fill:"currentColor"}),x("circle",{className:"bx-th bx-th3",cx:"463.1",cy:"463.1",r:"21",fill:"currentColor"})]})}function Ls(){return Ve("g",{className:"bx-at",children:[x("line",{x1:"490",y1:"312",x2:"490",y2:"414",stroke:"currentColor",strokeWidth:"46",strokeLinecap:"round"}),x("circle",{cx:"490",cy:"484",r:"28",fill:"currentColor"})]})}function As(){return Ve("g",{className:"bx-ob",children:[x("path",{d:dn,fill:"none",stroke:"var(--tile-bg, transparent)",strokeWidth:41,strokeLinecap:"round"}),x("path",{d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})]})}function $s(){return Ve(qn,{children:[x("path",{className:"bx-xa",d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),x("g",{className:"bx-xx",children:x("path",{d:"M442 364 L514 436 M514 364 L442 436",fill:"none",stroke:"currentColor",strokeWidth:"24",strokeLinecap:"round"})})]})}function Ds(){return x("path",{className:"bx-snap",d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})}function Us(){return Ve("g",{stroke:"currentColor",strokeWidth:"17",strokeLinecap:"round",children:[x("line",{className:"bx-vb",x1:"452",y1:"370",x2:"452",y2:"430"}),x("line",{className:"bx-vb bx-vb2",x1:"482",y1:"330",x2:"482",y2:"470"}),x("line",{className:"bx-vb bx-vb3",x1:"512",y1:"355",x2:"512",y2:"445"})]})}function Hs(){return x(qn,{children:[[450,366],[474,376],[484,400],[474,424],[450,434],[426,424],[416,400],[426,376]].map(([n,t],r)=>x("circle",{className:"bx-w",cx:n,cy:t,r:"11",fill:"currentColor",style:{animationDelay:`${-1.2+r*.15}s`}},r))})}function Ws(){return Ve(qn,{children:[x("g",{className:"bx-sp",children:x("path",{d:"M460 300 Q465.4 324.6 490 330 Q465.4 335.4 460 360 Q454.6 335.4 430 330 Q454.6 324.6 460 300 Z",fill:"currentColor"})}),x("g",{className:"bx-sp bx-sp2",children:x("path",{d:"M486 356 Q493.92 392.08 530 400 Q493.92 407.92 486 444 Q478.08 407.92 442 400 Q478.08 392.08 486 356 Z",fill:"currentColor"})}),x("g",{className:"bx-sp bx-sp3",children:x("path",{d:"M460 440 Q465.4 464.6 490 470 Q465.4 475.4 460 500 Q454.6 475.4 430 470 Q454.6 464.6 460 440 Z",fill:"currentColor"})})]})}import{useCallback as re,useEffect as le,useId as js,useMemo as Ke,useRef as Sn,useState as q}from"react";var Fn=[{slug:"mac-arm",label:"macOS, Apple silicon"},{slug:"mac-intel",label:"macOS, Intel"},{slug:"windows",label:"Windows"},{slug:"linux",label:"Linux"}];function Gn(e){if(!e)return"";try{return new URL(e).origin}catch{return""}}function uo(e,n){return n<2*6e4?e:n<10*6e4?Math.max(e,6e4):n<30*6e4?Math.max(e,3*6e4):Math.max(e,10*6e4)}var Bs=3e3,qs=2*6e4,bt=Date.now(),yt=new Set,co=!1;function Fs(){if(co||typeof window>"u")return;co=!0;let e=()=>{let t=bt;if(bt=Date.now(),bt-t>qs)for(let r of yt)r()};for(let t of["pointerdown","keydown","wheel","touchstart"])window.addEventListener(t,e,{capture:!0,passive:!0});let n=()=>{if(!document.hidden)for(let t of yt)t()};window.addEventListener("focus",n),document.addEventListener("visibilitychange",n)}function Oe(e,n,t={}){Fs();let r,o=t.immediate===!1?Date.now():0,s=!1,a=!1,c=()=>{a||(r=setTimeout(i,t.idle===!1?n:uo(n,Date.now()-bt)))},i=async()=>{if(clearTimeout(r),!(a||s)){if(typeof document>"u"||!document.hidden){s=!0,o=Date.now();try{await e()}catch{}finally{s=!1}}c()}},l=()=>{Date.now()-o>Math.min(n,Bs)&&i()};return yt.add(l),t.immediate===!1?c():i(),()=>{a=!0,clearTimeout(r),yt.delete(l)}}var Kt="soba";function po(){return`${Kt}://show`}function zn(e,n,t){let r=`${Kt}://connect?url=${encodeURIComponent(e)}`;return n&&(r+=`&nonce=${encodeURIComponent(n)}`),t&&(r+=`&want=${encodeURIComponent(t)}`),r}function Vn(){let e=globalThis.crypto;if(!e?.getRandomValues)return null;let n=e.getRandomValues(new Uint8Array(32)),t="";for(let r of n)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var Gs=1600;function jt(e={}){return Jt(e)}async function Yt(e,n={}){if(typeof window>"u"||typeof document>"u")return"unknown";let t=Jt(n);try{window.location.href=zn(e,n.nonce,n.want)}catch{return"absent"}return t}async function Zt(e={}){if(typeof window>"u"||typeof document>"u")return"unknown";let n=Jt(e);try{window.location.href=po()}catch{return"absent"}return n}async function Jt(e){if(typeof window>"u"||typeof document>"u")return"unknown";let n=e.graceMs??Gs,t=document.visibilityState==="visible"&&document.hasFocus(),r=!1,o=()=>{r=!0},s=()=>{document.visibilityState==="hidden"&&(r=!0)};return window.addEventListener("blur",o),window.addEventListener("pagehide",o),document.addEventListener("visibilitychange",s),await new Promise(a=>setTimeout(a,n)),window.removeEventListener("blur",o),window.removeEventListener("pagehide",o),document.removeEventListener("visibilitychange",s),t?r?"opened":"absent":"unknown"}var mo="soba.connect.choice",zs=180*24*60*60*1e3;function Qt(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function Xt(e,n){return e?n?`${mo}.${e}.${Qt(n)}`:`${mo}.${e}`:null}function er(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>zs)return null;let r=ie.find(o=>o.id===t.choice);return r?r.id:null}catch{return null}}function nr(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var fo="soba.connect.model",Vs=180*24*60*60*1e3;function tr(e,n){return e?n?`${fo}.${e}.${Qt(n)}`:`${fo}.${e}`:null}function wt(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>Vs)return null;let r=t.choice;return typeof r!="string"||!r||r.length>120?null:/^[\w.:@+-]+(\/[\w.:@+-]+)?$/.test(r)?r:null}catch{return null}}function rr(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var ho="soba.connect.dismissed",Ks=30*24*60*60*1e3;function or(e,n){return e?n?`${ho}.${e}.${Qt(n)}`:`${ho}.${e}`:null}function sr(e){if(!e||typeof localStorage>"u")return!1;try{let n=localStorage.getItem(e);if(!n)return!1;let t=JSON.parse(n);return Date.now()-Date.parse(t.at)<Ks}catch{return!1}}function ar(e){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({at:new Date().toISOString()}))}catch{}}import{Fragment as Ct,jsx as d,jsxs as N}from"react/jsx-runtime";var ir=2e3,Ys=1e4,Zs=9e4,Js=6e4;function lr(e,n,t,r=[],o){return e?"code":n&&(t.length>0||r.length>0)?"manage":o?"launch":"choose"}function Qs(e){let n=Math.max(0,Math.round(e/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function dr({client:e,initialCode:n,initialChoice:t,onConnected:r,showStatus:o=!0,initialContext:s=null,initialMachines:a,onClose:c,headingId:i,theme:l,reason:u,active:p=!0}){let y=!!s&&a!==void 0,[f,m]=q(y?lr(n,o,a??[],[],t):"loading"),[w,M]=q(s),[R,_]=q(a??[]),[U,P]=q(n??""),[T,E]=q(null),[S,W]=q(null),[ve,X]=q(!1),[ke,V]=q(0),[oe,We]=q(()=>Date.now()),[Y,Pe]=q(null),[Qe,ce]=q(!1),[ue,ee]=q(!1),[gn,Xe]=q("browser"),[Le,en]=q(null),[de,ne]=q([]),[Be,pe]=q(0),[Ae,qe]=q(null),se=Sn(null),[O,bn]=q(t??null),[v,F]=q(null),me=Ke(()=>{let h=w?.accent?.trim(),C=w?.background?.trim();if(!(!h&&!C))return C?{...an(C,h),background:C,borderRadius:"inherit"}:{"--sc-accent":h,"--sc-accent-fg":An(h)}},[w?.accent,w?.background]),fe=js(),te=i??fe,Fe=Sn(null);le(()=>{if(!e||y)return;let h=!0;return Promise.all([e.context(),e.machines()]).then(([C,$])=>{h&&(M(C),_($),m(lr(n,o,$)))}).catch(C=>{h&&(W(C.message),m("choose"))}),()=>{h=!1}},[e,n,o,y]),le(()=>{f!=="loading"||!y||m(lr(n,o,a??[]))},[f,y,n,o,a]),le(()=>{a&&_(a)},[a]),le(()=>{s&&M(s)},[s]);let yn=Sn(!1),wn=Sn(f);wn.current=f;let nn=Sn(de);nn.current=de;let tn=!!w?.hosted_available;le(()=>{!o&&wn.current==="manage"&&m("choose")},[o]),le(()=>{if(!e||!p||f!=="manage")return;let h=!0,C=Oe(async()=>{try{let $=await e.machines();if(!h)return;_($);let B=!tn||yn.current;$.length===0&&nn.current.length===0&&B&&wn.current==="manage"&&m("choose")}catch{}},Ys,{immediate:!1});return()=>{h=!1,C()}},[f,e,tn,p]);let rn=Xt(w?.publishable_key??null);le(()=>{F(er(rn))},[rn]),le(()=>{if(!e||!tn)return;let h=!0;return e.hosted().then(C=>{h&&(ne(C.credentials),!yn.current&&(yn.current=!0,C.credentials.length>0&&o&&wn.current==="choose"&&m("manage")))}).catch(()=>{}),()=>{h=!1}},[e,tn,o]),le(()=>{if(!e||!p||f!=="hosted")return;let h=!0,C=async()=>{try{let _e=await e.hosted();if(!h)return!1;if(ne(_e.credentials),_e.credentials.length>0)return m("hosted_connected"),qe(null),!0}catch{}return!1},$=async()=>{se.current?.closed&&(se.current=null,!await C()&&h&&m("choose"))},B=Oe(C,ir,{immediate:!1}),sn=setInterval($,400),Ne=_e=>{let Tn=_e.data;Tn?.source==="soba"&&Tn.type==="hosted_result"&&C()};return window.addEventListener("message",Ne),()=>{h=!1,B(),clearInterval(sn),window.removeEventListener("message",Ne),se.current=null}},[e,f,p]);let Ot=re(()=>{if(!e)return;let h=window.open("","soba-connect-plan","width=520,height=760,noopener=no");se.current=h,m("hosted"),pe(Date.now()),qe(null),W(null),e.startHosted().then(({url:C})=>{if(h&&!h.closed){h.location.href=C;return}qe(C)}).catch(C=>{h?.close(),se.current=null,W(C.message),m("choose")})},[e]),lt=re(async h=>{if(e){X(!0);try{await e.disconnectHosted(h),ne((await e.hosted()).credentials)}catch(C){W(C.message)}finally{X(!1)}}},[e]);le(()=>{if(!e||!p||f!=="waiting")return;let h=!0,C=Oe(async()=>{try{let $=await e.machines();if(!h)return;_($);let B=Fe.current;if(!B)return;let sn=$.filter(_e=>!B.has(_e.id)),Ne=sn.find(_e=>_e.state!=="offline")??sn[0];if(Ne){en(Ne.id),O&&nr(rn,O);let _e=ie.find(Lt=>Lt.id===O)?.expects??[],Tn=ye(Ne).find(Lt=>_e.includes(Lt.id));Tn&&e.preferRuntime(Ne.id,Tn.id).catch(()=>{}),m("connected"),r?.($)}}catch{}},ir,{immediate:!1});return()=>{h=!1,C()}},[f,e,r,O,rn,p]);let ct=re(async()=>{if(e){W(null),X(!0);try{let h=await e.lookup(U);E(h),m("confirm")}catch(h){W(h.message)}finally{X(!1)}}},[e,U]),vn=re(async()=>{if(e){W(null),X(!0);try{try{Fe.current=new Set((await e.machines()).map(h=>h.id))}catch{Fe.current=new Set(R.map(h=>h.id))}await e.approve(U),m("waiting"),V(Date.now())}catch(h){W(h.message)}finally{X(!1)}}},[e,U,R]),ut=re(async()=>{if(e){X(!0);try{await e.deny(U),Xe("browser"),m("denied")}catch(h){W(h.message)}finally{X(!1)}}},[e,U]),G=Ke(()=>w?.connect_url??null,[w]),[Re,he]=q(()=>Vn()),on=Ke(()=>G?zn(G,Re??void 0,O??void 0):null,[G,Re,O]),dt=Ke(()=>Gn(G),[G]),It=re(h=>{if(R.length===0)return null;let C=ie.find(B=>B.id===h);if(!C)return null;let $=R.flatMap(B=>B.runtimes??[]).filter(B=>C.expects.includes(B.id));return $.length===0?{tone:"dim",text:"not installed"}:$.some(B=>B.authenticated===!0)?{tone:"ok",text:"ready"}:$.every(B=>B.authenticated===!1)?{tone:"warn",text:"needs signing in"}:{tone:"dim",text:"installed"}},[R]),k=re((h=null)=>{bn(h),W(null),Pe(null),ce(!1),ee(!1),z.current=!1,he(Vn()),m("launch")},[]),z=Sn(!!t);le(()=>{f!=="launch"||!G||z.current||(z.current=!0,ce(!0),Yt(G,{...Re?{nonce:Re}:{},...O?{want:O}:{}}).then(Pe))},[f,G,Re,O]);let ae=re(()=>{ce(!0),jt().then(Pe)},[]),pt=re(h=>{if(ue){let C=Vn();ee(!1),he(C),G&&(h.preventDefault(),window.location.href=zn(G,C??void 0,O??void 0))}ae()},[ue,ae,G,O]),ge=Ke(()=>{let h=w?.runtimes;return h?ie.filter(C=>h.includes(C.id)):Wt()},[w?.runtimes]),Ce=Ke(()=>{let h=ie.find(C=>C.id===O);return h?{choice:h,Mark:ze[h.id]??null}:null},[O]),$e=Ke(()=>R.find(h=>h.id===Le),[R,Le]);le(()=>{let h=Re;if(!e||!p||f!=="launch"||!h)return;let C=!1,$=Date.now()+15e4,B=()=>{};return B=Oe(async()=>{if(Date.now()>$){B(),ee(!0);return}try{let sn=await e.claim(h);if(C)return;if(sn.declined){B(),Pe(null),Xe("machine"),m("denied");return}if(!sn.claimed)return;B();try{Fe.current=new Set((await e.machines()).map(Ne=>Ne.id))}catch{Fe.current=new Set(R.map(Ne=>Ne.id))}m("waiting"),V(Date.now())}catch{}},ir,{immediate:!1,idle:!1}),()=>{C=!0,B()}},[e,f,R,Re,p]);let be=Ke(()=>{if(!T)return null;if(T.approved||T.denied)return"answered";let h=T.expires_at?Date.parse(T.expires_at):Number.NaN;return Number.isFinite(h)&&h<=oe?"expired":"live"},[T,oe]);le(()=>{if(!(f==="confirm"&&be==="live"||f==="waiting"||f==="hosted"))return;let C=setInterval(()=>We(Date.now()),1e3);return()=>clearInterval(C)},[f,be]);let mt=re(async(h,C)=>{if(e)try{await e.approveRuntime(h,C),_(await e.machines())}catch($){W($.message)}},[e]),Tt=re(async(h,C)=>{if(e)try{await e.preferRuntime(h,C),_(await e.machines())}catch($){W($.message)}},[e]);return f==="loading"?d("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:me,children:d("div",{className:"sc-card",children:d("p",{className:"sc-note",children:"Loading\u2026"})})}):N("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:me,children:[c&&d("button",{type:"button",className:"sc-modal-close",onClick:c,"aria-label":"Close",children:"\xD7"}),f==="manage"&&N("div",{className:"sc-card",children:[d("h2",{className:"sc-title",id:te,children:"Your compute"}),N("p",{className:"sc-sub",children:[d(vt,{context:w})," ",R.length>0&&de.length>0?"runs on your connected plan, and on these machines while they are awake.":de.length>0?"runs on the plan you connected. Nothing here is charged to you.":"runs on these machines, while they are awake."]}),d(un,{machines:R,hosted:de,onApproveRuntime:mt,onPreferRuntime:(h,C)=>void Tt(h,C),onDisconnectHosted:h=>void lt(h),onPair:()=>m("choose"),busy:ve,...w?.app.name?{appName:w.app.name}:{}}),S&&d("p",{className:"sc-error",children:S})]}),f==="choose"&&N("div",{className:"sc-card",children:[d(ea,{context:w}),d("h2",{className:"sc-h",id:te,children:u==="payment_required"?"Carry on with your own AI":u==="no_compute"?"This run needs a machine":"Connect your AI"}),d("p",{className:"sc-p",children:"Use compute you already have."}),G&&ge.length>0&&N(Ct,{children:[d("div",{className:"sc-opts",children:ge.map(h=>{let C=ze[h.id];return N("button",{type:"button",className:"sc-opt",onClick:()=>k(h.id),children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:C&&d(C,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),(()=>{let $=It(h.id);return $?d("span",{className:`sc-opt-has sc-opt-has-${$.tone}`,children:$.text}):v===h.id?d("span",{className:"sc-opt-last",children:"last used"}):d(cr,{className:"sc-opt-go"})})()]},h.id)})}),N("p",{className:"sc-opt-note",children:["Your accounts stay there. ",go(w)," never sees them."]})]}),(!G||ge.length===0)&&d("p",{className:"sc-error",style:{marginTop:16},children:"This app has no publishable key yet, so there is nothing to pair against."}),S&&d("p",{className:"sc-error",children:S}),G&&w?.show_code===!0&&d("div",{className:"sc-opt-alt",children:d("button",{type:"button",className:"sc-alt-link",onClick:()=>m("code"),children:"I have a code"})})]}),f==="launch"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d(kt,{mark:Ce?.Mark??j,still:ue||!Qe&&Y===null}),d("h2",{className:"sc-h",id:te,children:ue?"No answer from this machine":Y==="absent"?"Nothing opened":Y===null?"Opening Soba App\u2026":"Approve it on this machine"}),ue?d("p",{className:"sc-p",children:"The Soba app did not answer. It may not be open, or nobody was there. Try again when you are ready."}):Y==="absent"?d("p",{className:"sc-p",children:"Nothing opened on this machine. Open it yourself below, or install it if it is not here yet."}):d("p",{className:"sc-p",children:Y===null?"Approve it there and this page does the rest.":"This page finishes on its own."}),Ce&&N("p",{className:"sc-prereq",children:[Ce.Mark&&d(Ce.Mark,{className:"sc-rt-mark"}),"Needs ",Ce.choice.prerequisite]}),N("div",{className:"sc-stack",style:{marginTop:18},children:[d("a",{className:Y==="absent"||ue?"sc-btn sc-btn-primary":"sc-btn",href:on??"#",onClick:pt,children:ue?"Try again":Y==="absent"?"Open Soba App":"Open it again"}),d("p",{className:"sc-note",children:Y===null?"Your browser will ask permission first.":"Your browser asks permission the first time."}),Ce&&Y==="absent"&&d("p",{className:"sc-note",children:d(na,{text:Ce.choice.hint})}),N("div",{className:"sc-foot-strip",children:[d("span",{children:"Not installed on this machine?"}),N("button",{type:"button",className:"sc-foot-go",onClick:()=>m("get"),children:["Get it",d(cr,{})]})]})]})]}),f==="get"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("launch")}),d("p",{className:"sc-head-title",children:"Get Soba App"})]}),d("div",{className:"sc-opts",children:Fn.map(h=>N("a",{className:"sc-opt",href:`${dt}/download/${h.slug}`,target:"_blank",rel:"noreferrer noopener",children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:d(Ht,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),d(cr,{className:"sc-opt-go"})]},h.slug))}),d("p",{className:"sc-opt-note",children:"Install it, then come back here and press the row you started with."})]}),f==="code"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-h",id:te,children:"Enter the code from that machine"}),d("p",{className:"sc-p",children:"Eight characters, shown by the Soba app once you paste the link."}),N("form",{className:"sc-stack",style:{marginTop:16},onSubmit:h=>{h.preventDefault(),ct()},children:[d("input",{className:"sc-input",value:U,onChange:h=>P(h.target.value),placeholder:"ACDE-F234",autoComplete:"off",autoFocus:!0,"aria-label":"Pairing code"}),S&&d("p",{className:"sc-error",children:S}),d("button",{type:"submit",className:"sc-btn sc-btn-primary",disabled:ve||U.length<8,children:ve?"Checking\u2026":"Continue"})]})]}),f==="confirm"&&T&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("code")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-title",children:"Attach this machine to your account?"}),N("p",{className:"sc-sub",children:[d(vt,{context:w})," may send your runs to it once you approve. It can never see the account or the keys on it."]}),N("ul",{className:"sc-facts",children:[d(Kn,{k:"Code",v:T.user_code}),d(Kn,{k:"Machine",v:T.hostname??"not stated"}),d(Kn,{k:"System",v:[T.platform,T.arch].filter(Boolean).join(" / ")||"not stated"}),d(Kn,{k:"Asked by",v:T.client??"not stated"}),T.labels.length>0&&d(Kn,{k:"Labels",v:T.labels.join(", ")})]}),d("p",{className:"sc-note",style:{marginTop:12},children:"Every line above is what that machine said about itself. If none of it looks like a computer of yours, say no."}),be==="expired"&&d("p",{className:"sc-error",children:"That code has expired. Ask the machine for a new one. It prints a fresh code each time it starts."}),be==="answered"&&d("p",{className:"sc-error",children:"That code has already been answered. If it was not you, deny the next one."}),S&&d("p",{className:"sc-error",children:S}),N("div",{className:"sc-row",style:{marginTop:16},children:[d("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:()=>void vn(),disabled:ve||be!=="live",children:"Approve"}),d("button",{type:"button",className:"sc-btn",onClick:()=>void ut(),disabled:ve||be==="answered",children:"No, deny it"})]}),be==="live"&&T.expires_at&&N("p",{className:"sc-note",style:{marginTop:10},children:["This code expires in ",Qs(Date.parse(T.expires_at)-oe),"."]})]}),f==="waiting"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:Ce?.choice.short??"Soba App"})]}),d(kt,{mark:Ce?.Mark??j}),d("h2",{className:"sc-h",id:te,children:"Approved. Waiting for it to connect"}),d("p",{className:"sc-p",children:"Nothing more to do here. This page changes when it arrives."}),ke>0&&oe-ke>Zs&&d("p",{className:"sc-note sc-tone-warn",style:{marginTop:14,textAlign:"center"},children:"Still nothing. Look at the Soba app on that machine: it says what it is doing. This keeps watching either way."})]}),f==="connected"&&N("div",{className:"sc-card",children:[d(ur,{tone:"ok"}),d("h2",{className:"sc-h",id:te,children:$e?.label?`${$e.label} is connected`:"Connected"}),N("p",{className:"sc-p",children:[d(vt,{context:w})," will use ",$e?.label?"it":"this machine"," from now on, while it is awake."]}),o&&N(Ct,{children:[d("div",{style:{marginTop:16},children:d(Wn,{machines:R,onApproveRuntime:mt})}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:14},onClick:()=>m("manage"),children:"Done"})]})]}),f==="hosted"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"ChatGPT"})]}),Ae?d(kt,{mark:cn,still:!0}):d(kt,{mark:cn}),d("h2",{className:"sc-h",id:te,children:Ae?"Your browser blocked the window":"Finish signing in to ChatGPT"}),d("p",{className:"sc-p",children:Ae?"Nothing opened. Open the sign-in yourself below. A link you click is allowed where a window we open is not.":"Approve it in the window that opened."}),N("div",{className:"sc-stack",style:{marginTop:18},children:[Ae&&d("a",{className:"sc-btn sc-btn-primary",href:Ae,target:"soba-connect-plan",rel:"noreferrer",children:"Open the ChatGPT sign-in"}),S&&d("p",{className:"sc-error",children:S}),Be>0&&oe-Be>Js&&d("p",{className:"sc-note sc-tone-warn",children:"Still nothing. The window may have been closed before it finished, or the sign-in may have been declined. This keeps watching either way."})]})]}),f==="hosted_connected"&&N("div",{className:"sc-card",children:[d(ur,{tone:"ok"}),d("h2",{className:"sc-h",id:te,children:"ChatGPT is connected"}),N("p",{className:"sc-p",children:[d(vt,{context:w})," will run on your ChatGPT plan",de[0]?.account_label?` (${de[0].account_label})`:"",". Nothing more to pay, nothing to install."]}),d("p",{className:"sc-opt-note",style:{textAlign:"center"},children:"It runs on our side, so it has no access to your files or your terminal."}),o&&N(Ct,{children:[d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>m("manage"),children:"Done"}),d("div",{className:"sc-opt-alt",children:d("button",{type:"button",className:"sc-alt-link",onClick:()=>m("choose"),children:"Connect a machine too"})})]})]}),f==="denied"&&N("div",{className:"sc-card",children:[d(ur,{tone:"off"}),d("h2",{className:"sc-h",id:te,children:"Declined"}),d("p",{className:"sc-p",children:gn==="machine"?"Nothing was connected. You can ask again whenever you like.":"That machine was not attached to your account, and the terminal has been told so."}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>m("choose"),children:"Back to the start"})]})]})}function go(e){return e?.app.name??"this app"}function Xs(e){let n=e?.app.icon_urls;if(n?.length)return n;let t=e?.app.icon_url;return t?[t]:[]}function bo(e){let n=Xs(e),[t,r]=q([]),o=re(c=>{c&&r(i=>i.includes(c)?i:[...i,c])},[]),s=re(c=>o(c.currentTarget.getAttribute("src")),[o]),a=re(c=>{c?.complete&&c.naturalWidth===0&&o(c.getAttribute("src"))},[o]);return{icon:n.find(c=>!t.includes(c)),onError:s,ref:a}}function ea({context:e}){let{icon:n,onError:t,ref:r}=bo(e);return e?.app.mark==="soba"?d(j,{className:"sc-app-mark"}):n?d("img",{className:"sc-app-mark",src:n,alt:"","aria-hidden":"true",ref:r,onError:t}):null}function vt({context:e}){let{icon:n,onError:t,ref:r}=bo(e),o=e?.app.mark==="soba";return N("span",{className:"sc-app",children:[o&&d(j,{className:"sc-app-icon"}),!o&&n&&d("img",{className:"sc-app-icon",src:n,alt:"",ref:r,onError:t}),go(e)]})}function Mn({onClick:e}){return d("button",{type:"button",className:"sc-head-back",onClick:e,"aria-label":"Back",children:d("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:d("path",{d:"M15 5 8 12l7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function cr({className:e}){return d("svg",{className:e,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:d("path",{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function kt({mark:e,still:n}){return N("span",{className:"sc-waiting","aria-hidden":"true",children:[!n&&d("svg",{className:"sc-waiting-orbit",viewBox:"0 0 100 100","aria-hidden":"true",focusable:"false",children:d("circle",{className:"sc-waiting-arc",cx:"50",cy:"50",r:"46"})}),d(e,{className:"sc-waiting-mark"})]})}function ur({tone:e}){return d("span",{className:`sc-result sc-result-${e}`,"aria-hidden":"true",children:d(Vt,{kind:e==="ok"?"snap":"gone",size:84})})}function na({text:e}){return d(Ct,{children:e.split("`").map((n,t)=>t%2===1?d("code",{className:"sc-inline-code",children:n},t):n)})}function Kn({k:e,v:n}){return N("li",{className:"sc-fact",children:[d("span",{className:"sc-fact-key",children:e}),d("span",{children:n})]})}import{useEffect as ta,useRef as mr}from"react";var Nt=0,pr=null;function yo(){if(typeof document>"u")return()=>{};Nt===0&&(pr=document.body.style.overflow,document.body.style.overflow="hidden"),Nt+=1;let e=!1;return()=>{e||(e=!0,Nt-=1,Nt===0&&(document.body.style.overflow=pr??"",pr=null))}}import{jsx as wo}from"react/jsx-runtime";function jn({open:e,onClose:n,labelledBy:t,theme:r,style:o,children:s}){let a=mr(null),c=mr(null),i=mr(null);return ta(()=>{let l=a.current;if(l){if(!e){l.open&&l.close();return}return l.open||l.showModal(),document.activeElement===l&&c.current?.focus(),yo()}},[e]),wo("dialog",{ref:a,className:"soba-connect sc-modal","aria-labelledby":t,...r?{"data-theme":r}:{},style:o,onCancel:l=>{l.preventDefault(),n()},onPointerDown:l=>{i.current=l.target},onClick:l=>{l.target===l.currentTarget&&i.current===l.currentTarget&&n()},children:wo("div",{className:"sc-modal-sheet",ref:c,tabIndex:-1,children:s})})}import{useRef as sa,useState as aa}from"react";var ra={"claude-code":{small:"haiku",large:"opus"}};function vo(e){let n=ra[e];return!!(n?.small||n?.large)}var oa={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus",fable:"Fable"};function ko(e){return oa[e]??e}function fr(e){let n=[...e].sort(ft),t=Ee([...e]),r=t?De(t):null,s=[{id:"auto",kind:"auto",label:"Automatic",model:"auto",...r?.runtime?{note:`Uses ${r.runtime.display_name}`}:{}}];n.some(u=>ye(u).some(p=>vo(p.id)))&&s.push({id:"small",kind:"size",label:"Fast",note:"quick and cheap",model:"small"},{id:"large",kind:"size",label:"Best",note:"the most capable",model:"large"});let c=new Map;for(let u of n)for(let p of ye(u))for(let y of p.models){if(!y)continue;let f=`${p.id}/${y}`,m=c.get(f);if(m){m.machines.add(K(u));continue}c.set(f,{option:{id:f,kind:"named",label:ko(y),model:y,runtime:p.id,runtimeName:p.display_name,costClass:p.cost_class},machines:new Set([K(u)])})}let i=new Set;for(let{machines:u}of c.values())for(let p of u)i.add(p);let l=i.size>1;for(let{option:u,machines:p}of c.values()){let y=l&&p.size===1?[...p][0]:void 0;s.push(y?{...u,machine:y}:u)}return s}function Yn(e){let n=[],t=[];for(let r of e){if(r.kind!=="named"){n.push(r);continue}let o=r.runtimeName??r.runtime??"",s=t.find(a=>a.heading===o);s?s.options.push(r):t.push({heading:o,options:[r]})}return n.length?[{heading:null,options:n},...t]:t}function hr(e,n){let t=e.find(o=>o.kind==="auto")??{id:"auto",kind:"auto",label:"Automatic",model:"auto"};if(!n||n==="auto")return{selected:t,unavailable:null};let r=e.find(o=>o.id===n);return r?{selected:r,unavailable:null}:{selected:t,unavailable:n}}function gr(e){return e.runtime?{model:e.model,runtime:e.runtime}:{model:e.model}}function Zn(e){return e.length>1}import{jsx as xt,jsxs as Co}from"react/jsx-runtime";function br({options:e,selected:n,onPick:t,caption:r,disabled:o,className:s}){let[a,c]=aa(!1),i=sa(null);if(!Zn(e))return null;let l=s?`sc-mp ${s}`:"sc-mp";return Co("span",{className:l,children:[r&&xt("span",{className:"sc-mp-cap",children:r}),Co("button",{ref:i,type:"button",className:"sc-mp-btn","aria-haspopup":"menu","aria-expanded":a,"aria-label":`Model: ${n.label}. Change`,disabled:o,onClick:()=>c(u=>!u),children:[xt("span",{className:"sc-mp-label",children:n.label}),xt(Nn,{open:!0})]}),a&&xt(Hn,{anchor:i,label:"Which model answers",options:ia(e),current:n.id,onClose:()=>c(!1),onPick:u=>{c(!1),u&&t(u)}})]})}function ia(e){let n=[];for(let t of Yn(e))t.options.forEach((r,o)=>{let s=la(r);n.push({id:r.id,label:r.label,...s?{note:s}:{},...t.heading&&o===0?{heading:t.heading}:{},...!t.heading&&r.kind==="size"&&o===1?{rule:!0}:{}})});return n}function la(e){return e.kind!=="named"?e.note:e.machine?`on ${e.machine}`:void 0}import{useEffect as yr,useRef as ca}from"react";import{jsx as ua}from"react/jsx-runtime";var pn=8;function wr({open:e,onClose:n,anchor:t,label:r,theme:o,style:s,children:a}){let c=ca(null);return yr(()=>{let i=c.current;if(!(!i||!(typeof i.showPopover=="function")))try{e?i.showPopover():i.hidePopover()}catch{}},[e]),yr(()=>{if(!e)return;let i=()=>{let u=c.current,p=t.current;if(!u||!p)return;let y=p.getBoundingClientRect(),f=u.offsetWidth,m=u.offsetHeight,w=window.innerWidth-f-pn,M=Math.max(pn,Math.min(y.right-f,Math.max(pn,w))),R=y.bottom+pn,_=y.top-pn-m,U=R+m>window.innerHeight-pn&&_>pn?_:R;u.style.left=`${Math.round(M)}px`,u.style.top=`${Math.round(U)}px`};i();let l=requestAnimationFrame(i);return window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{cancelAnimationFrame(l),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e,t]),yr(()=>{if(!e)return;let i=u=>{u.key==="Escape"&&n()},l=u=>{let p=u.target;p&&(c.current?.contains(p)||t.current?.contains(p)||n())};return document.addEventListener("keydown",i),document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("keydown",i),document.removeEventListener("pointerdown",l,!0)}},[e,n,t]),ua("div",{ref:c,role:"dialog","aria-label":r,className:"soba-connect sc-pop",...o?{"data-theme":o}:{},popover:"manual",hidden:!e,style:s,children:a})}var Jn=new Map,Pn=new Map,No=!1;function da(){No||typeof window>"u"||(No=!0,window.addEventListener("storage",e=>{!e.key||!Jn.has(e.key)||(Pn.set(e.key,wt(e.key)),vr(e.key))}))}function vr(e){for(let n of Jn.get(e)??[])n()}function Qn(e){return e??""}function kr(e,n){let t=Qn(e);da();let r=Jn.get(t)??new Set;return r.add(n),Jn.set(t,r),()=>{r.delete(n),r.size===0&&Jn.delete(t)}}function St(e){let n=Qn(e),t=Pn.get(n);if(t!==void 0)return t;let r=e?wt(e):null;return Pn.set(n,r),r}function Cr(){return null}function Nr(e,n){St(e)===null&&(Pn.set(Qn(e),n),vr(Qn(e)))}function xr(e,n){let t=Qn(e);Pn.get(t)!==n&&(Pn.set(t,n),rr(e,n),vr(t))}function Ue(e){let n=`${e.unit}s`;return e.reward==="unlimited"?`Unlimited ${n} on your own AI`:e.reward==="included"&&e.includedUnits!==null?`${ma(e.includedUnits)} ${n} a month once you connect`:e.reward==="credit"&&e.creditMicros>0?`${pa(e.creditMicros)} back each month you stay connected`:null}function He(e){return e==="unlimited"||e==="included"}var So=new Set(["user-hardware","user-subscription"]),xo=new Set(["open-weights","frontier"]);function Se(e){return e===null||e.length===0?!1:e.every(n=>So.has(n))}var pa=e=>(e/1e6).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),ma=e=>e.toLocaleString("en-US");function Sr(e,n){if(!(n===null||n.some(s=>xo.has(s))))return!1;let r=e.findIndex(s=>So.has(s));if(r===-1)return!1;let o=e.findIndex(s=>xo.has(s));return o===-1||r<o}import{createContext as Mo,useContext as Po}from"react";var Mr=Mo(null);function Rn(){return Po(Mr)}var Pr=Mo({context:null,machines:void 0,theme:"light"});function H(){return Po(Pr)}import{useMemo as ga}from"react";import{createContext as fa,useContext as ha}from"react";var Rr=fa(null);function D(){let e=ha(Rr);if(!e)throw new Error("useSoba() must be used inside a <SobaProvider>.");return e}function Xn(){let{compute:e}=D();return ga(()=>{let n=e.machines,t=[...n].sort((s,a)=>Ee([s,a])===s?-1:1).map(ba),r=Ee([...n]),o=ln(n);return{view:t.length?"machines":e.loading?"loading":e.error?"error":"empty",machines:t,primary:r?t.find(s=>s.machine.id===r.id)??null:null,connected:e.connected,online:e.online,stalled:e.connected&&!e.online&&o?t.find(s=>s.machine.id===o.id)??null:null,loading:e.loading,error:e.error,refresh:e.refresh}},[e])}function ba(e){let n=De(e);return{machine:e,name:K(e),state:Ge(e),status:$t(e),hardware:Dn(e),lastSeen:e.state==="offline"?Un(e.last_seen_at):null,runtimes:ye(e).map(t=>({runtime:t,name:t.display_name,auth:$n(t),quarantined:!!t.quarantined})),runsOn:{by:n.by,name:n.runtime?.display_name??null}}}import{jsx as et}from"react/jsx-runtime";function ya({className:e}){let{theme:n}=H(),t=e?`soba-connect ${e}`:"soba-connect";return et("div",{className:t,"data-theme":n,children:et(_r,{})})}function _r(){let e=Xn();return e.view==="loading"?et("p",{className:"sc-note",children:"Loading\u2026"}):e.view==="error"?et("p",{className:"sc-error",children:e.error?.message}):et(Wn,{machines:e.machines.map(n=>n.machine)})}import{useCallback as tt,useEffect as Or,useMemo as xa,useRef as Ir,useState as mn}from"react";import{useId as wa}from"react";import{jsx as _n,jsxs as Mt}from"react/jsx-runtime";function nt({open:e,onOpenChange:n,initialCode:t,onConnected:r,showStatus:o,reason:s}){let{error:a}=D(),c=Rn(),i=H(),l=()=>n(!1),u=wa(),p=i.context?.background?.trim(),y=p?an(p,i.context?.accent):void 0;return Mt(jn,{open:e,onClose:l,labelledBy:u,theme:i.theme,style:y,children:[a?Mt("div",{className:"sc-card",children:[_n("h2",{className:"sc-title",id:u,children:"Could not start"}),_n("p",{className:"sc-error",children:a.message})]}):!c&&!i.context?Mt("div",{className:"sc-card",children:[_n("h2",{className:"sc-title",id:u,children:"One moment"}),_n("p",{className:"sc-note",children:"Getting your compute\u2026"})]}):_n(dr,{client:c,active:e,onClose:l,headingId:u,theme:i.theme,initialContext:i.context,...i.machines!==void 0?{initialMachines:i.machines}:{},...t?{initialCode:t}:{},...r?{onConnected:r}:{},...o===void 0?{}:{showStatus:o},...s?{reason:s}:{}}),Mt("p",{className:"sc-modal-foot",children:[_n(j,{className:"sc-foot-mark"}),"Secured by Soba"]})]})}import{useCallback as va}from"react";function ka(){let{connect:e}=D(),n=Xn(),t=va(()=>e.open("manual"),[e]);return{...Pt(n.primary?.machine??null),machine:n.primary,open:t,canOpen:e.hasModal,loading:n.view==="loading"}}function Pt(e){let n=Ge(e);return{label:e?n.word:"Connect compute",ariaLabel:e?`${n.word} on ${K(e)}`:"Connect compute",connected:e!==null,state:n}}import{useCallback as Ro,useEffect as Ca,useState as Na}from"react";function Er({enabled:e=!0,intervalMs:n=3e3}={}){let t=Rn(),[r,o]=Na(null),s=Ro(async()=>{t&&o(await t.runs())},[t]);Ca(()=>{if(!e||!t)return;let c=!0,i=Oe(async()=>{let l=await t.runs();c&&o(l)},n);return()=>{c=!1,i()}},[e,t,n]);let a=Ro(async c=>{if(!t)throw new Error("Stopping a run needs <SobaProvider>.");await t.stopRun(c),await s().catch(()=>{})},[t,s]);return{runs:r,refresh:s,stop:a}}import{Fragment as Tr,jsx as je,jsxs as rt}from"react/jsx-runtime";function fn({children:e,variant:n,className:t,initialCode:r,onConnected:o,defaultOpen:s,open:a,onOpenChange:c,showConnected:i=!0}){let{compute:l,connect:u}=D(),p=H(),{theme:y}=p,f=Rn(),[m,w]=mn(s??!!r),M=Ir(null),R=a!==void 0,_=!R&&!s&&!r&&u.hasModal,U=R?a:_?u.isOpen:m,P=v=>{_?v?u.open("manual"):u.close():R||w(v),c?.(v)},T=Ir(U);Or(()=>{T.current&&!U&&M.current?.focus(),T.current=U},[U]);let[E,S]=mn(!1),{runs:W,stop:ve}=Er({enabled:E}),X=xa(()=>E&&W?Sa(l.machines,W):l.machines,[l.machines,E,W]),ke=Ee(X),V=Pt(ke),oe=i&&V.connected,We=V.state,Y=tt(()=>S(!1),[]),[Pe,Qe]=mn(!1),ce=tt(async()=>{Qe(!0);try{await l.refresh()}finally{Qe(!1)}},[l]),ue=Ir(ce);ue.current=ce,Or(()=>{E&&ue.current()},[E]);let[ee,gn]=mn(!1),[Xe,Le]=mn([]),en=!!p.context?.hosted_available;Or(()=>{if(!E||!f||!en)return;let v=!0;return f.hosted().then(F=>{v&&Le(F.credentials)}).catch(()=>{}),()=>{v=!1}},[E,f,en]);let[de,ne]=mn(!1),[Be,pe]=mn(null),Ae=tt(async(v,F)=>{if(f){pe(null);try{await f.approveRuntime(v,F),await l.refresh()}catch(me){pe(me.message)}}},[f,l]),qe=tt(async(v,F)=>{if(f){pe(null);try{await f.preferRuntime(v,F),await l.refresh()}catch(me){pe(me.message)}}},[f,l]),se=tt(async v=>{if(f){pe(null);try{await f.disconnectHosted(v),Le((await f.hosted()).credentials)}catch(F){pe(F.message)}}},[f]),O=p.context?.background?.trim(),bn=O?an(O,p.context?.accent):void 0;return rt(Tr,{children:[je("button",{ref:M,type:"button","data-theme":y,className:["sc-btn",oe?"sc-btn-connected":"sc-btn-icon",!oe&&n==="primary"?"sc-btn-primary":"",t].filter(Boolean).join(" "),...oe&&!e?{"aria-haspopup":"dialog","aria-expanded":E,"aria-label":V.ariaLabel}:{},onClick:()=>{if(oe&&!e&&!R&&!s&&!r){S(v=>!v);return}P(!0)},children:e??(oe?rt(Tr,{children:[je("span",{className:"sc-pill-tile","aria-hidden":"true",children:je(j,{className:We.tone==="busy"?"sc-pill-mark sc-pill-mark-busy":"sc-pill-mark"})}),rt("span",{className:"sc-btn-connected-text",children:[We.word,ke&&rt("span",{className:"sc-btn-connected-where",children:[" on ",K(ke)]})]}),je("i",{className:`sc-dot sc-dot-${We.tone}`,"aria-hidden":"true"})]}):rt(Tr,{children:[je(j,{className:"sc-btn-mark"}),"Connect compute"]}))}),je(wr,{open:E,onClose:Y,anchor:M,label:"Your compute",theme:y,...bn?{style:bn}:{},children:je(un,{machines:X,hosted:Xe,onApproveRuntime:(v,F)=>void Ae(v,F),onPreferRuntime:(v,F)=>void qe(v,F),onDisconnectHosted:v=>void se(v),onRefresh:()=>void ce(),refreshing:Pe,error:Be,runs:W,runsOpen:de,onToggleRuns:()=>ne(v=>!v),onStopRun:async v=>{pe(null);try{await ve(v)}catch(F){throw pe(F.message),F}},onPair:()=>{S(!1),_?u.open("pair"):(gn(!0),P(!0))},...p.context?.app.name?{appName:p.context.app.name}:{}})}),!_&&je(nt,{open:U,onOpenChange:v=>{v||gn(!1),P(v)},...ee?{showStatus:!1}:{},...r?{initialCode:r}:{},...o?{onConnected:o}:{}})]})}function Sa(e,n){return e.map(t=>{if(t.state==="offline")return t;let r=n.filter(o=>o.machine_id===t.id).length;return{...t,active:r,state:r>0?"busy":"online"}})}import{jsx as Lr,jsxs as Pa}from"react/jsx-runtime";function Ma({initialCode:e,onConnected:n,className:t,showStatus:r=!0}){let{theme:o}=H();return Pa("div",{className:t?`soba-connect ${t}`:"soba-connect","data-theme":o,children:[r&&Lr(_r,{}),Lr("div",{className:"sc-compute-act",children:Lr(fn,{...e?{initialCode:e}:{},...n?{onConnected:n}:{}})})]})}import{useId as Ha,useState as Wa}from"react";import{useCallback as $r,useEffect as To,useState as Lo}from"react";import{useCallback as Ra,useState as _a}from"react";function ot(){let[e,n]=_a(null);return{open:Ra(()=>{n(null),Zt().then(n)},[]),launch:e,note:e==="absent"?"Nothing opened here. That machine may be a different computer, or asleep.":null}}import{useCallback as _o,useMemo as Eo}from"react";function hn(e){if(!e)return null;if(typeof e=="string")return e;if(typeof Response<"u"&&e instanceof Response)return Oo(e.status);let n=e,t=n.error;return typeof t?.code=="string"?t.code:typeof t?.type=="string"?t.type:typeof n.code=="string"?n.code:typeof n.status=="number"?Oo(n.status):n.cause&&n.cause!==e?hn(n.cause):null}function Oo(e){return e===402?"payment_required":e===409?"no_compute":null}function Ar(...e){let[n,t]=e,{plan:r,compute:o,connect:s}=D(),a=t?.predict??e.length===0,c=Oa(Ea(n),o)??(a?Ia(r,o):null),i=r.plan,l=r.plans,u=Eo(()=>{if(c!=="payment_required")return null;let m=i?.price??0,w=i?.included_units??0;return l.find(M=>M.id!==i?.id&&M.price>m&&(M.included_units===null||M.included_units>w))??null},[c,l,i]),p=_o(async()=>{if(!u)return;if(u.selectable){await r.select(u.id);return}let m=await r.checkout(u.id);window.location.assign(m)},[u,r]),y=s.open,f=_o(()=>{c&&y(c)},[y,c]);return Eo(()=>{if(!c)return null;let m=i?Ue({unit:i.unit,reward:i.connected_reward,includedUnits:i.connected_included_units,creditMicros:i.connected_credit*1e6}):null,w=i&&He(i.connected_reward)?m:null;return{reason:c,...Ta(c,{connectOffer:w,connected:o.connected,online:o.online,machine:ln(o.machines)?.label??null,unit:i?.unit??"message",interval:i?.interval??"month",upgrade:u!==null,resets:r.current?.period_end??null}),connectOffer:w,upgradeTo:u,connect:f,upgrade:p}},[c,i,o,u,f,p,r.current?.period_end])}function Ea(e){let n=hn(e);return n==="payment_required"||n==="no_compute"?n:null}function Oa(e,n){return e==="no_compute"&&n.connected&&n.online?null:e}function Ia(e,n){let t=e.plan;return!t||n.loading?null:Se(t.route_allow)&&!n.online?"no_compute":e.remaining===0&&t.overage==="stop"?"payment_required":null}function Ta(e,n){if(e==="payment_required"){let t=`No ${n.unit}s left this ${n.interval}`;return n.connectOffer&&!n.connected?{title:t,body:`${n.connectOffer}. Connecting takes a minute and costs nothing.`}:n.connectOffer&&!n.online?{title:t,body:`${n.connectOffer}. Waking ${n.machine??"your machine"} is enough.`}:n.upgrade?{title:t,body:n.resets?`A larger plan carries on now. This one comes back on ${Io(n.resets)}.`:"A larger plan carries on now, or wait for this one to renew."}:{title:t,body:n.resets?`Your allowance comes back on ${Io(n.resets)}.`:"Your allowance comes back at the start of the next period."}}return n.connected&&!n.online?{title:`${n.machine??"Your machine"} can't be reached`,body:"This run needs it awake and connected. Open Soba App on that machine, or connect another one."}:{title:"Nothing connected yet",body:"This app runs on AI you already pay for, on a machine of your own. Connect one and this run has somewhere to go."}}function Io(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}function La(e){let{plan:n,allowance:t,connected:r,online:o,quiet:s,error:a,predict:c,at:i,waved:l}=e;if(!n)return null;let u=e.allow!==void 0?e.allow:n.route_allow;if(r){if(o)return null;let w=Se(u);return{reason:"stalled",title:`${s??"Your machine"} can\u2019t be reached`,detail:w?"The Soba app there has stopped reporting in, so runs have nowhere to go until it is back.":"The Soba app there has stopped reporting in, so nothing will run on your own AI until it is back.",meter:null,dismissible:!1,atTheWall:!1,ownCompute:w}}let p=hn(a),y=p==="payment_required"||p==="no_compute",f=n.ask_to_connect!==!1&&Sr(n.route_prefer,u);if(!c&&!y&&!f)return null;let m=Se(u)?Aa(n.unit,Se(n.route_allow)):He(n.connected_reward)?Da(t,n,i):f?$a(n.unit):null;return!m||m.dismissible&&l?null:{...m,dismissible:!!m.dismissible,ownCompute:!1,atTheWall:!m.dismissible&&(!c||m.meter!==null&&m.meter.left===0)}}function Dr(e={}){let{at:n=.25,error:t,allow:r}=e,o=e.predict??!(e.errorGiven??t!==void 0),{plan:s,compute:a,connect:c}=D(),i=or(c.publishableKey),[l,u]=Lo(!1);To(()=>{u(sr(i))},[i]);let p=$r(()=>{u(!0),ar(i)},[i]),y=$r(()=>c.open("manual"),[c]),f=$r(()=>c.open("no_compute"),[c]),m=ot(),[w,M]=Lo(!1),{refresh:R}=a,{launch:_}=m;To(()=>{if(_===null||_==="absent")return;M(!1);let S=setInterval(()=>void R(),3e3),W=setTimeout(()=>{clearInterval(S),M(!0)},2e4);return()=>{clearInterval(S),clearTimeout(W)}},[_,R]);let U=Ua(c.app?.name,Gn(c.connectUrl)),P=s.loading||a.loading,T=ln(a.machines),E=P?null:La({plan:s.plan,allowance:{remaining:s.remaining,included:s.included},connected:a.connected,online:a.online,quiet:T?K(T):null,error:t,predict:o,...r!==void 0?{allow:r}:{},at:n,waved:l});return{reason:E?.reason??null,visible:E!==null,title:E?.title??null,detail:E?.detail??null,meter:E?.meter??null,dismissible:E?.dismissible??!1,dismissed:l,dismiss:p,open:y,atTheWall:E?.atTheWall??!1,steps:U,stalled:E?.reason==="stalled"?{machine:T?K(T):null,ownCompute:E.ownCompute,wake:m.open,launch:m.launch,note:m.note,stuck:w,connectAnother:f}:null,loading:P}}function Aa(e,n){return{reason:"needed",title:n?"This plan runs on your own AI.":`These ${e}s run on your own AI.`,detail:`Connect a machine and your ${e}s run there, free, on access you already have.`,meter:null}}function $a(e){return{reason:"preferred",title:"This plan prefers your own AI.",detail:`Connect a machine and your ${e}s run there instead, on access you already have.`,meter:null,dismissible:!0}}function Da(e,n,t){let{remaining:r,included:o}=e;if(r===null||o===null||o===0||r>Math.ceil(o*t))return null;let s=Ue({unit:n.unit,reward:n.connected_reward,includedUnits:n.connected_included_units,creditMicros:n.connected_credit*1e6});return s?{reason:"running",title:r===0?`No ${n.unit}s left this month.`:`${r} ${n.unit}${r===1?"":"s"} left this month.`,detail:`${s}.`,meter:{left:r,of:o}}:null}function Ua(e,n){return[{lead:"Download Soba App",detail:"",...n?{linksLead:"Get it for"}:{},links:n?Fn.map(t=>({label:t.label,href:`${n}/download/${t.slug}`})):[]},{lead:"Connect compute",detail:"Press this, then approve the pairing when the app asks.",opens:!0,links:[]},{lead:"Let your AIs serve",detail:`It finds what is installed on that machine. Allow one, and ${e??"this app"} sends every run there.`,linksLead:"Nothing on it yet?",links:ie.map(t=>({label:t.short,href:t.install}))}]}import{Fragment as $o,jsx as L,jsxs as Ye}from"react/jsx-runtime";function Ba(e){let{className:n,fallback:t=null}=e,r=Dr({...e.at===void 0?{}:{at:e.at},...e.predict===void 0?{}:{predict:e.predict},...e.allow===void 0?{}:{allow:e.allow},error:e.error,errorGiven:"error"in e}),{connect:o}=D(),{theme:s}=H(),[a,c]=Wa(null),i=Ha(),l=L($o,{children:t});if(!r.visible)return l;if(r.stalled)return L(Ao,{className:n,theme:s,stalled:!0,children:L(qa,{title:r.title??"",detail:r.detail??"",stalled:r.stalled})});let u=a??r.atTheWall;return Ye(Ao,{className:n,theme:s,children:[Ye("div",{className:"sc-nudge-top",children:[Ye("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:r.title}),L("p",{className:"sc-nudge-detail",children:r.detail}),Ye("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more","aria-expanded":u,"aria-controls":i,onClick:()=>c(!u),children:[u?"Hide the details":"How it works",L(Ga,{})]})]}),r.dismissible?L("button",{type:"button",className:"sc-nudge-dismiss","aria-label":"Dismiss",title:"Dismiss",onClick:r.dismiss,children:L(Fa,{})}):null]}),u?L("ol",{className:"sc-nudge-steps",id:i,children:r.steps.map(p=>Ye("li",{children:[p.opens?L("button",{type:"button",className:"sc-step-lead",onClick:()=>o.open("manual"),children:p.lead}):L("strong",{children:p.lead}),p.detail?L("span",{children:p.detail}):null,p.links.length>0?Ye("span",{className:"sc-step-links",children:[p.linksLead,p.links.map(y=>L("a",{href:y.href,target:"_blank",rel:"noreferrer noopener",children:y.label},y.href))]}):null]},p.lead))}):null,L(fn,{variant:"primary"})]})}function Ao({className:e,theme:n,stalled:t,children:r}){return L("div",{className:e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill","data-theme":n,children:L("div",{className:t?"sc-nudge sc-nudge-stalled":"sc-nudge",children:r})})}function qa({title:e,detail:n,stalled:t}){return Ye($o,{children:[L("div",{className:"sc-nudge-top",children:Ye("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:e}),L("p",{className:"sc-nudge-detail",children:n}),t.note&&L("p",{className:"sc-nudge-note",children:t.note}),t.stuck&&L("p",{className:"sc-nudge-note",children:"The Soba app is open, but this machine still isn\u2019t reporting in. It may no longer be connected to this app."}),(t.launch==="absent"||t.stuck)&&L("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more",onClick:t.connectAnother,children:t.stuck?"Connect it again":"Connect another machine"})]})}),L("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:t.wake,children:"Open Soba App"})]})}function Fa(){return L("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-x",children:L("path",{d:"m4.8 4.8 6.4 6.4M11.2 4.8l-6.4 6.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function Ga(){return L("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-chev",children:L("path",{d:"M4.5 6.5 8 10l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}var za=new Set(["delta","thinking","status","done","error"]);function En(e){let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!="object")return null;let t=n,r=t.type==="event"?t.event:t;if(!r||typeof r!="object")return null;let o=r;if(typeof o.type!="string"||!za.has(o.type))return null;let s={type:o.type};return typeof o.text=="string"&&(s.text=o.text),typeof o.message=="string"&&(s.message=o.message),typeof o.tool=="string"&&(s.tool=o.tool),typeof o.tier=="string"&&(s.tier=o.tier),o.usage&&typeof o.usage=="object"&&(s.usage=o.usage),typeof o.session=="string"&&(s.session=o.session),typeof o.toolInput=="string"&&(s.toolInput=o.toolInput),o.git&&typeof o.git=="object"&&(s.git=o.git),o.turn&&typeof o.turn=="object"&&typeof o.turn.text=="string"&&(s.turn={text:o.turn.text}),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.retryable=="boolean"&&(s.retryable=o.retryable),(o.state==="interrupted"||o.state==="resumed")&&(s.state=o.state),s}async function*Ur(e){let n=e.body;if(!n)throw new Error("That run response had no body to stream.");let t=(e.headers.get("content-type")??"").includes("ndjson"),r=n.getReader(),o=new TextDecoder,s="",a=[];try{for(;;){let i=await r.read();if(i.done)break;for(s+=o.decode(i.value,{stream:!0});;){let l=s.indexOf(`
|
|
3
|
-
`);if(
|
|
4
|
-
`);if(a=[],p==="[DONE]")return;let
|
|
5
|
-
`);if(
|
|
2
|
+
import{useEffect as Ns,useRef as xs,useState as At}from"react";var yn=class extends Error{status;constructor(n,t){super(n),this.name="ConnectError",this.status=t}},hs=5*6e4,Tn=class{session;baseUrl;doFetch;lastMachines=null;machinesUrl=null;gatewayBackUntil=0;constructor(n){this.session=n.session,this.baseUrl=(n.baseUrl??"").replace(/\/+$/,""),this.doFetch=n.fetchImpl??fetch.bind(globalThis)}async context(){let n=await this.request("GET","/v1/connect");return this.setMachinesUrl(n.machines_url),n}setMachinesUrl(n){typeof n=="string"&&/^https?:\/\//.test(n)&&(this.machinesUrl=n)}async machines(){let n=this.lastMachines,t=n?`?v=${encodeURIComponent(n.version)}`:"",r;if(this.machinesUrl&&Date.now()>=this.gatewayBackUntil)try{r=await this.request("GET",`${this.machinesUrl}${t}`)}catch(s){if(s instanceof yn&&s.status===401)throw s;this.gatewayBackUntil=Date.now()+hs}if(r??=await this.request("GET",`/v1/machines${t}`),r.unchanged&&n)return n.machines;let o=Array.isArray(r.machines)?r.machines:[];return this.lastMachines=typeof r.version=="string"?{version:r.version,machines:o}:null,o}async runs(){let n=await this.request("GET","/v1/machines/runs");return Array.isArray(n.runs)?n.runs:[]}async stopRun(n){let t=this.machinesUrl?.replace(/\/v1\/machines$/,"");if(!t)throw new yn("This page can't stop runs yet: it hasn't been told where Soba's gateway is.",501);await this.request("POST",`${t}/v1/runs/${encodeURIComponent(n)}/stop`,{})}lookup(n){return this.request("GET",`/v1/device/lookup?code=${encodeURIComponent(n)}`)}approve(n){return this.request("POST","/v1/device/approve",{user_code:n})}claim(n){return this.request("POST","/v1/device/claim",{pairing_nonce:n})}deny(n){return this.request("POST","/v1/device/deny",{user_code:n})}plans(){return this.request("GET","/v1/plans")}selectPlan(n){return this.request("POST","/v1/plans/select",{plan:n})}checkoutPlan(n,t){return this.request("POST","/v1/plans/checkout",{plan:n,...t?.successUrl?{success_url:t.successUrl}:{},...t?.cancelUrl?{cancel_url:t.cancelUrl}:{}})}leavePlan(){return this.request("DELETE","/v1/plans/select")}hosted(){return this.request("GET","/v1/hosted")}startHosted(){return this.request("POST","/v1/hosted/start")}disconnectHosted(n){return this.request("DELETE",n?`/v1/hosted?provider=${encodeURIComponent(n)}`:"/v1/hosted")}approveRuntime(n,t){return this.request("POST","/v1/runtimes/approve",{machine_id:n,runtime_id:t})}preferRuntime(n,t){return this.request("POST","/v1/runtimes/prefer",{machine_id:n,runtime_id:t})}async request(n,t,r){let o=await this.doFetch(/^https?:\/\//.test(t)?t:`${this.baseUrl}${t}`,{method:n,headers:{authorization:`Bearer ${this.session}`,...r?{"content-type":"application/json"}:{}},...r?{body:JSON.stringify(r)}:{}}),s={};try{s=await o.json()}catch{}if(!o.ok){let a=typeof s.error=="string"?s.error:`Request failed (${o.status})`;throw new yn(a,o.status)}return s}};function Bn(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return"#ffffff";let t=n[1].length===3?[...n[1]].map(s=>s+s).join(""):n[1],r=s=>{let a=Number.parseInt(t.slice(s*2,s*2+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4};return .2126*r(0)+.7152*r(1)+.0722*r(2)>.45?"#101012":"#ffffff"}function Tt(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return null;let t=n[1].length===3?[...n[1]].map(r=>r+r).join(""):n[1];return[0,1,2].map(r=>Number.parseInt(t.slice(r*2,r*2+2),16))}function bn(e,n,t){let r=Tt(e),o=Tt(n);return!r||!o?e:`#${r.map((a,l)=>Math.round(a+(o[l]-a)*t)).map(a=>a.toString(16).padStart(2,"0")).join("")}`}function rn(e,n){if(!Tt(e))return{};let t=Bn(e),r=n?.trim();return{"--sc-ground":e,"--sc-shell":e,"--sc-sheet":bn(e,t,.07),"--sc-raised":bn(e,t,.13),"--sc-line":bn(e,t,.18),"--sc-line-2":bn(e,t,.28),"--sc-text":t,"--sc-text-2":bn(t,e,.15),"--sc-muted":bn(t,e,.38),...r?{"--sc-accent":r,"--sc-accent-fg":Bn(r)}:{"--sc-accent":t,"--sc-accent-fg":e}}}function Gn(e){return e.authenticated===!0?{tone:"ok",text:"signed in"}:e.authenticated===!1?{tone:"warn",text:e.auth_hint??"signed out on that machine"}:{tone:"unknown",text:"could not tell"}}function Wn(e){let{platform:n,arch:t}=e;if(!n)return null;let r=n==="darwin"||n==="macos",o=r?"Mac":n==="win32"||n==="windows"?"Windows PC":"Linux machine";return r?`${t==="aarch64"||t==="arm64"?"Apple silicon ":""}${o}`:o}function on(e){return e.find(n=>n.state==="offline")??null}function Bt(e){return e.state==="busy"?{tone:"busy",text:`serving ${e.active} of ${e.capacity}`}:e.state==="online"?{tone:"ok",text:"connected"}:{tone:"off",text:"asleep or offline"}}function _(e){let n=e.label?.trim(),t=e.name?.trim();return n&&(!t||n!==t)?n:(t??n??"").replace(/\.(local|lan|home|internal)$/i,"").replace(/[-_]+/g," ").trim()||n||"This machine"}function mt(e,n){let t=o=>o.state==="busy"?0:o.state==="online"?1:2,r=o=>o.last_seen_at?Date.parse(o.last_seen_at):0;return t(e)-t(n)||r(n)-r(e)}function Ie(e){return[...e].sort(mt)[0]??null}function sn(e){return e?e.state==="busy"?{tone:"busy",word:"Serving"}:e.state==="online"?{tone:"ok",word:"Connected"}:{tone:"off",word:"Asleep"}:{tone:"off",word:"No compute"}}function wn(e){let n=sn(e);return{label:e?n.word:"Connect compute",ariaLabel:e?`${n.word} on ${_(e)}`:"Connect compute",connected:e!==null,state:n}}function Gt(e){return e.state==="online"||e.state==="busy"}function Hn(e){if(!e)return"never seen";let n=Date.parse(e);if(Number.isNaN(n))return"never seen";let t=Date.now()-n,r=6e4;return t<2*r?"just now":t<60*r?`${Math.floor(t/r)} min ago`:t<24*60*r?`${Math.floor(t/(60*r))} hr ago`:`${Math.floor(t/(24*60*r))} days ago`}function Wt(e,n){let t=r=>r.absent?2:r.quarantined?1:0;return t(e)-t(n)||e.display_name.localeCompare(n.display_name)}function Ht(e){return e.runtimes.filter(n=>n.id!=="shell")}function ye(e){return e.runtimes.filter(n=>n.id!=="shell"&&!n.quarantined&&!n.absent)}function Ge(e){let n=a=>a?e.runtimes.find(l=>l.id===a)??null:null;if(e.requested_runtime)return{by:"app",runtimeId:e.requested_runtime,runtime:n(e.requested_runtime)};let t=ye(e),r=t.find(a=>a.id===e.preferred_runtime);if(r)return{by:"you",runtimeId:r.id,runtime:r};let o=a=>a.id==="claude-code"?0:a.id==="codex"?1:2,s=[...t].sort((a,l)=>o(a)-o(l))[0]??null;return{by:"default",runtimeId:s?.id??null,runtime:s}}var Dt={"claude-code":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAARGVYSWZNTQAqAAAACAABh2kABAAAAAEAAAAaAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAABAoAMABAAAAAEAAABAAAAAAEZRQrAAAAHLaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT4xPC9leGlmOkNvbG9yU3BhY2U+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjp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OISD4WGNKRNW+Tu6gaHxd1wUXaFFlQHMDSdgiHDyuAyyvKHmSiv/2oHbpROzC0wlv5HMEN/IKTy2aGOdWDyAOT8zJzBPMqcayXzD2PGmU2peR0hZT40CMeW4JvjFUmdhTAD9U3dsK/ATHYYo6Aa9i3D0sf9gaBxVDEFAc/kQbHvKoSuRObV/QgNkcwD5jARsuQIWyRUfHgHJWB64dFWAYnun9QnXGRshc1SRcdGGXBTYPyMyn3k5F7v/h8qtgDnL6/wjvBQNWPSchPg1GXgvCWeIr+GjXj44OIn2Oo2e4z7u9oJo1qTXeWuHGJXQ91vI+YW5NAQrbWT9czryZ/OB3LdmMDFUGiPQm85+OMP6Ul+i323zeItTiodoFLQBcWTXwGzxn0BijiYgzGcTQWguIgdoz8sWQSMR3A0hMCPb5owh4whw+YR7MJ6ktMo+EciiobYAFJqDE4zPhtDRKVwF5DSuQcnOKR2AP8Cui93e4Bz9uMXV0/FBGGZ/BaqmGMFGWMFNw7QyOZML4XaHNc3OnIDZkE7cOUzf5QfCGN8C6GkgqwSeXP8HIxHP4MmOI/a321n07gV9IjNBy7QnyZrED37ivv4/PQyO8w10e8KcphEWKSNuIPY8QfKrR4Ye+yCnB3kPeGZiJkLwBzq+EZK2GxGe7nRW12PSGeADM/EmtjG4qej4OQ90YuRN/rYcWzMU8ZPuWbyCHPgbYT3vQ4Pp0/OM7QYx6VGXgMbdGN/AVNIT3cAadkl50K7+QtmgFGBskwuuGBL+EfnaxNQFH3ihDqM12j6lTyyVn4H4E6hAx4NkYwy1G0DlAmsUN8ESX6/+H/GpiUBv4FSyLhydRRp0cAAAAASUVORK5CYII="};import{useEffect as io,useRef as gs}from"react";import{Fragment as bs,jsx as Ne,jsxs as Ut}from"react/jsx-runtime";function Dn({anchor:e,label:n,options:t,current:r,onClose:o,onPick:s}){let a=gs(null);return io(()=>{let i=a.current,c=e.current;if(!i||!c)return;try{typeof i.showPopover=="function"&&i.showPopover()}catch{}let u=c.getBoundingClientRect(),p=i.offsetWidth,f=i.offsetHeight,g=Math.max(8,Math.min(u.right-p,window.innerWidth-p-8)),m=u.bottom+6,y=m+f>window.innerHeight-8&&u.top-6-f>8?u.top-6-f:m;i.style.left=`${Math.round(g)}px`,i.style.top=`${Math.round(y)}px`,i.querySelector('[aria-checked="true"]')?.focus()},[e]),io(()=>{let i=c=>{let u=c.target;!u||a.current?.contains(u)||e.current?.contains(u)||o()};return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[e,o]),Ne("div",{ref:a,role:"menu","aria-label":n,className:"sc-menu",popover:"manual",onKeyDown:i=>{let c=[...a.current?.querySelectorAll("[role=menuitemradio]")??[]],u=c.indexOf(document.activeElement);if(i.key==="Escape")i.stopPropagation(),i.nativeEvent.stopImmediatePropagation(),o(),e.current?.focus();else if(i.key==="ArrowDown"||i.key==="ArrowUp"){i.preventDefault();let p=i.key==="ArrowDown"?1:-1;c[(u+p+c.length)%c.length]?.focus()}else i.key==="Tab"&&o()},children:t.map(i=>Ne(fs,{option:i,checked:r===i.id,onClose:o,onPick:s},i.id??""))})}function fs({option:e,checked:n,onClose:t,onPick:r}){return Ut(bs,{children:[e.heading?Ne("div",{className:"sc-menu-head",role:"presentation",children:e.heading}):e.rule?Ne("div",{className:"sc-menu-sep"}):null,Ut("button",{type:"button",role:"menuitemradio","aria-checked":n,className:"sc-menu-item",onClick:()=>n?t():r(e.id),children:[e.glyph,Ut("span",{className:"sc-menu-text",children:[Ne("span",{className:"sc-menu-label",children:e.label}),e.note&&Ne("span",{className:"sc-menu-note",children:e.note})]}),n&&Ne(As,{})]})]})}function As(){return Ne("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-menu-check",children:Ne("path",{d:"M5 12.5l4.5 4.5L19 7.5",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cn({open:e}){return Ne("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-chev sc-chev-open":"sc-chev",children:Ne("path",{d:"M9 6l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as we,jsxs as ws}from"react/jsx-runtime";function X({className:e}){return ws("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:[we("path",{d:"M18.125 7.039A8.6 8.6 0 1 0 18.125 16.961A6 6 0 0 1 18.125 7.039Z",fill:"currentColor"}),we("path",{d:"M19.925 7.039A8.6 8.6 0 0 1 19.925 16.961A6 6 0 0 0 19.925 7.039Z",fill:"currentColor"})]})}function lo({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{fill:"currentColor",d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})})}function an({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{fill:"currentColor",d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})})}function ht({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M4 5h16v11H4zM9 20h6M12 16v4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function ys({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M5 7l5 5-5 5M12 18h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ft({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M5 6h14v10H5zM2.5 19.5h19",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Ye={claude:lo,chatgpt:an,local:ht},co={shell:ys};function po(e,n){return n<2*6e4?e:n<10*6e4?Math.max(e,6e4):n<30*6e4?Math.max(e,3*6e4):Math.max(e,10*6e4)}var Cs=3e3,vs=2*6e4,gt=Date.now(),ft=new Set,uo=!1;function ks(){if(uo||typeof window>"u")return;uo=!0;let e=()=>{let t=gt;if(gt=Date.now(),gt-t>vs)for(let r of ft)r()};for(let t of["pointerdown","keydown","wheel","touchstart"])window.addEventListener(t,e,{capture:!0,passive:!0});let n=()=>{if(!document.hidden)for(let t of ft)t()};window.addEventListener("focus",n),document.addEventListener("visibilitychange",n)}function Ce(e,n,t={}){ks();let r,o=t.immediate===!1?Date.now():0,s=!1,a=!1,l=()=>{a||(r=setTimeout(i,t.idle===!1?n:po(n,Date.now()-gt)))},i=async()=>{if(clearTimeout(r),!(a||s)){if(typeof document>"u"||!document.hidden){s=!0,o=Date.now();try{await e()}catch{}finally{s=!1}}l()}},c=()=>{Date.now()-o>Math.min(n,Cs)&&i()};return ft.add(c),t.immediate===!1?l():i(),()=>{a=!0,clearTimeout(r),ft.delete(c)}}var ce=[{id:"claude",costClass:"user-subscription",short:"Claude Code",label:"Continue with Claude",title:"The Claude plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Claude Code installed and signed in",hint:"Install it from claude.ai/code, then run `claude` once and sign in.",install:"https://claude.com/product/claude-code",expects:["claude-code"]},{id:"chatgpt",costClass:"user-subscription",short:"Codex",label:"Continue with ChatGPT",title:"The ChatGPT plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Codex installed and signed in",hint:"Install Codex, then run `codex` once and sign in.",install:"https://learn.chatgpt.com/codex/cli",expects:["codex"]},{id:"local",costClass:"user-hardware",short:"Local models",label:"Use a model on this machine",title:"A model on your own machine",cost:"Free. You bought the hardware",prerequisite:"Ollama running, with a model pulled",hint:"Install Ollama, then `ollama pull` a model before pairing.",install:"https://ollama.com",expects:["ollama","openai-api"]}],mo=["claude","chatgpt"];function Qt(){return ce.filter(e=>mo.includes(e.id))}function Jt(e){return ce.filter(n=>n.costClass===e)}function Vt(e){return ce.find(n=>n.expects.includes(e))??null}import{Fragment as Ao,jsx as A,jsxs as I}from"react/jsx-runtime";function ln({machines:e,hosted:n=[],onApproveRuntime:t,onPreferRuntime:r,onDisconnectHosted:o,onPair:s,onRefresh:a,refreshing:l,busy:i,appName:c,error:u,runs:p,loadRuns:f,loading:g,machineMenu:m,machineNote:y,children:R,onStopRun:S}){let k=Ie(e),W=e.filter(M=>M.id!==k?.id),[F,O]=At(!1),[P,Q]=At(null),T=p===void 0&&!!f,K=T?P:p??null,q=p!==void 0||!!f;Ns(()=>{if(!T||!F||!f)return;let M=!0,De=Ce(async()=>{let Y=await f();M&&Q(Y)},3e3);return()=>{M=!1,De()}},[T,F,f]);let de=k&&K?Ps(K,k):{},V=k?Ht(k):[];return!k&&n.length===0&&!s?A("p",{className:"sc-note",children:"Nothing connected yet."}):I("div",{className:"sc-tray",children:[k&&I(vn,{title:"This machine",action:(a||m)&&I("span",{className:"sc-cap-acts",children:[a&&A("button",{type:"button",className:"sc-disc",onClick:a,disabled:l,"aria-label":"Refresh",title:"Refresh",children:A(Fs,{spinning:!!l})}),m]}),children:[A(Rs,{machine:k,...q?{onToggle:()=>O(M=>!M),open:F}:{}}),y]}),k&&q&&F&&A(Ms,{machine:k,runs:K,...S?{onStop:S}:{}}),k&&A(vn,{title:"Agents on it",action:A(Gs,{machine:k,appName:c,busy:i,...r?{onPick:M=>r(k.id,M)}:{}}),children:g&&V.length===0?A("p",{className:"sc-row-note",children:"Looking\u2026"}):V.length>0?[...V].sort(Wt).map(M=>A(Ts,{runtime:M,serving:de[M.id]??M.serving??0,...t?{onApprove:()=>t(k.id,M.id)}:{}},M.id)):A("p",{className:"sc-row-note",children:"No agent advertised. Install Claude Code, Codex or Ollama on that machine."})}),n.length>0&&A(vn,{title:n.length>1?"Connected plans":"Connected plan",children:n.map(M=>A(Hs,{credential:M,appName:c,busy:i,...o?{onDisconnect:()=>o(M.provider)}:{}},M.provider))}),(W.length>0||s)&&I(vn,{title:W.length>0?"Your other machines":k?"Add a machine":"Your machines",children:[W.map(M=>A(Ls,{machine:M},M.id)),s&&I("button",{type:"button",className:"sc-pair",onClick:s,children:[A("span",{className:"sc-otile","aria-hidden":"true",children:A(Ds,{})}),A("span",{className:"sc-oname",children:e.length>0?"Pair another machine":"Connect a machine"})]})]}),R,u&&A("p",{className:"sc-error sc-tray-error",children:u})]})}function vn({title:e,action:n,children:t}){return I("section",{className:"sc-group",children:[I("div",{className:"sc-group-cap",children:[A("p",{className:"sc-group-title",children:e}),n]}),A("div",{className:"sc-group-card",children:t})]})}function Rs({machine:e,onToggle:n,open:t}){let r=Gt(e),o=[r?null:e.pairing_lost?"No longer connected here":"Asleep or offline",Wn(e),e.always_on?"always on":null,r&&e.capacity>0?`${e.active} of ${e.capacity} in flight`:Hn(e.last_seen_at)].filter(Boolean),s=I(Ao,{children:[I("span",{className:"sc-mtile","aria-hidden":"true",children:[A(fo,{}),A("span",{className:`sc-mbadge sc-mbadge-${sn(e).tone}`})]}),I("span",{className:"sc-mid",children:[A("span",{className:"sc-mname",children:_(e)}),A("span",{className:"sc-mmeta",children:o.map((a,l)=>I("span",{children:[l>0&&A("span",{className:"sc-mmeta-sep",children:"\xB7"}),a]},a))})]})]});return!n||!r?A("div",{className:"sc-mrow",children:s}):I("button",{type:"button",className:"sc-mrow sc-mrow-btn",onClick:n,"aria-expanded":!!t,title:t?"Hide what it is running":"See what it is running",children:[s,A(Cn,{open:!!t})]})}function Ss(e,n){return e.filter(t=>t.machine_id===n.id||t.machine_id===null)}function Ps(e,n){let t={};for(let r of e)r.machine_id!==n.id||r.status!=="running"||!r.runtime_id||(t[r.runtime_id]=(t[r.runtime_id]??0)+1);return t}function Ms({machine:e,runs:n,onStop:t}){let r=n?Ss(n,e):[],[o,s]=At(new Set),a=async l=>{s(i=>new Set(i).add(l));try{await t?.(l)}catch{s(i=>{let c=new Set(i);return c.delete(l),c})}};return A(vn,{title:"Running now",children:n===null?A("p",{className:"sc-row-note",children:"Looking\u2026"}):r.length===0?A("p",{className:"sc-row-note",children:"Nothing running."}):r.map(l=>A(Es,{run:l,stopping:o.has(l.id),...t?{onStop:()=>void a(l.id)}:{}},l.id))})}function Es({run:e,stopping:n,onStop:t}){return I("div",{className:"sc-rrow",children:[A(Yt,{id:e.runtime_id}),I("span",{className:"sc-mid",children:[I("span",{className:"sc-rtop",children:[A("span",{className:"sc-aname",children:ho(e)}),A("span",{className:"sc-averdict",children:Os(e.started_at)})]}),A("span",{className:"sc-rstep",children:n?"Stopping\u2026":Is(e)})]}),t&&A("button",{type:"button",className:"sc-disc sc-rstop",onClick:t,disabled:n,"aria-label":`Stop ${ho(e)}`,title:"Stop",children:A(Qs,{})})]})}function go(e){let n=Vt(e);return(n?Ye[n.id]:null)??co[e]??null}function ho(e){if(e.label)return e.label;if(e.task){let n=e.task.replace(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}return"A run"}function Is(e){if(e.status==="queued")return"Waiting for a free slot";if(e.step)return e.step;switch(e.phase?.kind){case"thinking":return"Thinking";case"writing":return"Writing";case"tool":return e.phase.tool?`Using ${e.phase.tool}`:"Using a tool";case"approval":return e.phase.tool?`Waiting for you to allow ${e.phase.tool}`:"Waiting for your approval";default:return e.first_output_at?"Working":"Starting"}}function Os(e){let n=Math.max(0,Math.round((Date.now()-new Date(e).getTime())/1e3));if(n<60)return`${n}s`;let t=Math.floor(n/60);return t<60?`${t}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function Ls({machine:e}){let n=sn(e);return I("div",{className:"sc-orow",children:[A("span",{className:"sc-otile","aria-hidden":"true",children:A(fo,{})}),A("span",{className:"sc-oname",children:_(e)}),A("span",{className:"sc-oword",children:n.word}),A("span",{className:`sc-dot sc-dot-${n.tone}`,"aria-hidden":"true"})]})}function Ts({runtime:e,serving:n=0,onApprove:t}){let r=Gn(e),o=I(Ao,{children:[A(Yt,{id:e.id,name:e.display_name}),I("span",{className:e.absent?"sc-aname sc-aname-absent":"sc-aname",children:[e.display_name,e.version&&I("span",{className:"sc-aversion",children:[" ",e.version]})]}),n>0?I("span",{className:"sc-averdict",children:[A(Us,{}),A("span",{className:"sc-aserving",children:n>1?`${n} running`:"running"})]}):e.absent?A("span",{className:"sc-averdict sc-tone-absent",children:"not offered"}):e.quarantined?t?A("button",{type:"button",className:"sc-row-act",onClick:t,children:"Let it serve"}):A("span",{className:"sc-averdict sc-tone-warn",children:"new, not serving yet"}):r.tone==="ok"?I("span",{className:"sc-averdict",children:[A("span",{className:"sc-dot sc-dot-ok","aria-hidden":"true"}),A("span",{className:"sc-sr",children:r.text})]}):A("span",{className:`sc-averdict sc-tone-${r.tone}`,children:r.text})]});return A("div",{className:"sc-arow",children:o})}function Yt({id:e,name:n}){return A("span",{className:"sc-runtime-tile","aria-hidden":"true",children:A(Bs,{id:e,...n?{name:n}:{}})})}function Bs({id:e,name:n}){if(!e)return null;let t=Dt[e];if(t)return A("img",{src:t,alt:"",className:"sc-runtime-logo"});let r=go(e);return r?A(r,{className:"sc-runtime-mark"}):n?A("span",{className:"sc-runtime-letter",children:n.slice(0,1).toUpperCase()}):null}function Gs({machine:e,appName:n,busy:t,onPick:r}){let o=Ge(e),s=ye(e),[a,l]=At(!1),i=xs(null);if(o.by!=="app"&&s.length===0)return null;let c=f=>f?A(Yt,{id:f.id,name:f.display_name}):null,u=f=>{if(!f)return null;let g=Dt[f.id];if(g)return A("img",{src:g,alt:"",className:"sc-runs-logo"});let m=go(f.id);return m?A(m,{className:"sc-runs-glyph"}):null},p;return o.by==="app"?p=I("span",{className:"sc-runs-fixed",title:`Set by ${n??"the app"}`,children:[u(o.runtime),o.runtime?.display_name??o.runtimeId]}):!r||s.length<2?p=I("span",{className:"sc-runs-fixed",children:[u(o.runtime),o.runtime?.display_name]}):p=I("button",{ref:i,type:"button",className:"sc-runs-btn","aria-haspopup":"menu","aria-expanded":a,"aria-label":`Runs go to ${o.runtime?.display_name??"the default"}. Change`,disabled:t,onClick:()=>l(f=>!f),children:[u(o.runtime),A("span",{className:"sc-runs-label",children:o.runtime?.display_name}),A(Cn,{open:!0})]}),I("span",{className:"sc-runs-to",children:[A("span",{className:"sc-runs-cap",children:o.by==="app"?`${n??"App"} uses`:"Runs on"}),p,a&&r&&A(Ws,{anchor:i,machine:e,tile:c,onClose:()=>l(!1),onPick:f=>{l(!1),r(f)}})]})}function Ws({anchor:e,machine:n,tile:t,onClose:r,onPick:o}){let s=Ge(n),a=Ge({...n,preferred_runtime:null}).runtime,l=s.by==="you"?s.runtimeId:null,i=[{id:null,label:"Automatic",...a?{note:`Uses ${a.display_name}`}:{},glyph:t(a)},...ye(n).map((c,u)=>({id:c.id,label:c.display_name,glyph:t(c),...u===0?{rule:!0}:{}}))];return A(Dn,{anchor:e,label:"Which agent runs go to",options:i,current:l,onClose:r,onPick:o})}function Hs({credential:e,appName:n,busy:t,onDisconnect:r}){return I("div",{className:"sc-hrow",children:[I("div",{className:"sc-orow",children:[A("span",{className:"sc-otile","aria-hidden":"true",children:A(an,{className:"sc-omark"})}),I("span",{className:"sc-mid",children:[A("span",{className:"sc-oname",children:e.provider==="openai-chatgpt"?"ChatGPT plan":e.provider}),A("span",{className:"sc-mmeta",children:e.account_label??"signed in"})]}),r&&A("button",{type:"button",className:"sc-row-act",onClick:r,disabled:t,children:"Disconnect"})]}),r&&I("p",{className:"sc-row-note",children:[n??"This app"," stops using it. To withdraw the grant entirely, remove it in your OpenAI settings."]})]})}function fo(){return I("svg",{viewBox:"0 0 32 24","aria-hidden":"true",focusable:"false",className:"sc-mglyph",children:[A("rect",{x:"4",y:"1.5",width:"24",height:"15",rx:"2.5",fill:"var(--sc-sheet, #ffffff)",stroke:"currentColor",strokeWidth:"2"}),A("rect",{x:"1",y:"19.5",width:"30",height:"2.5",rx:"1.25",fill:"currentColor"})]})}function Ds(){return A("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-oglyph",children:A("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function Us(){return I("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-sglyph sc-spin",children:[A("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),A("path",{d:"M12 3a9 9 0 0 1 9 9",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Fs({spinning:e}){return A("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-dglyph sc-spin":"sc-dglyph",children:A("path",{d:"M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Qs(){return A("svg",{className:"sc-dglyph",viewBox:"0 0 16 16","aria-hidden":"true",children:A("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5",fill:"currentColor"})})}import{jsx as Js}from"react/jsx-runtime";function Un({machines:e,onApproveRuntime:n}){return Js(ln,{machines:e,...n?{onApproveRuntime:n}:{}})}var jt={ready:{arc:!0},serving:{arc:!0,slot:"stream"},paused:{arc:!1,slot:"zzz"},thinking:{arc:!1,slot:"dots"},connecting:{arc:!1,slot:"orbit"},attention:{arc:!1,slot:"bang"},gone:{arc:!1,slot:"cross"},snap:{arc:!1,slot:"snap"},listening:{arc:!1,slot:"bars"},permission:{arc:!1,slot:"ring"},ai:{arc:!1,slot:"sparks"}};var zt="105 162 420 420",qt="M407.1 308.9 A158 158 0 1 0 407.1 491.1 A116 116 0 0 1 407.1 308.9 Z",cn="M448.5 320 A110 110 0 0 1 448.5 480";import{Fragment as Qn,jsx as x,jsxs as je}from"react/jsx-runtime";function Zt({kind:e,size:n=44,className:t}){let r=jt[e];return je("svg",{className:`bx${t?` ${t}`:""}`,"data-expression":e,viewBox:zt,overflow:"visible",width:n,height:n,"aria-hidden":"true",children:[x("path",{d:qt,fill:"currentColor"}),x("path",{className:"bx-arc",d:cn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),r.slot==="stream"&&x(Vs,{}),r.slot==="zzz"&&x(Ys,{}),r.slot==="dots"&&x(js,{}),r.slot==="bang"&&x(zs,{}),r.slot==="orbit"&&x(qs,{}),r.slot==="cross"&&x(Zs,{}),r.slot==="snap"&&x(Xs,{}),r.slot==="bars"&&x(Ks,{}),r.slot==="ring"&&x(_s,{}),r.slot==="sparks"&&x($s,{})]})}function Vs(){return x("path",{className:"bx-st",d:"M475.3 290.3 A150 150 0 0 1 475.3 509.7",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeDasharray:"0.1 31"})}function Ys(){return je(Qn,{children:[x("g",{className:"bx-z1",children:x("path",{d:"M444 372 H496 L444 436 H496",fill:"none",stroke:"currentColor",strokeWidth:"20",strokeLinecap:"round",strokeLinejoin:"round"})}),x("g",{className:"bx-z2",children:x("path",{d:"M492 300 H522 L492 338 H522",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeLinejoin:"round"})})]})}function js(){return je(Qn,{children:[x("circle",{className:"bx-th",cx:"463.1",cy:"336.9",r:"21",fill:"currentColor"}),x("circle",{className:"bx-th bx-th2",cx:"483",cy:"400",r:"21",fill:"currentColor"}),x("circle",{className:"bx-th bx-th3",cx:"463.1",cy:"463.1",r:"21",fill:"currentColor"})]})}function zs(){return je("g",{className:"bx-at",children:[x("line",{x1:"490",y1:"312",x2:"490",y2:"414",stroke:"currentColor",strokeWidth:"46",strokeLinecap:"round"}),x("circle",{cx:"490",cy:"484",r:"28",fill:"currentColor"})]})}function qs(){return je("g",{className:"bx-ob",children:[x("path",{d:cn,fill:"none",stroke:"var(--tile-bg, transparent)",strokeWidth:41,strokeLinecap:"round"}),x("path",{d:cn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})]})}function Zs(){return je(Qn,{children:[x("path",{className:"bx-xa",d:cn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),x("g",{className:"bx-xx",children:x("path",{d:"M442 364 L514 436 M514 364 L442 436",fill:"none",stroke:"currentColor",strokeWidth:"24",strokeLinecap:"round"})})]})}function Xs(){return x("path",{className:"bx-snap",d:cn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})}function Ks(){return je("g",{stroke:"currentColor",strokeWidth:"17",strokeLinecap:"round",children:[x("line",{className:"bx-vb",x1:"452",y1:"370",x2:"452",y2:"430"}),x("line",{className:"bx-vb bx-vb2",x1:"482",y1:"330",x2:"482",y2:"470"}),x("line",{className:"bx-vb bx-vb3",x1:"512",y1:"355",x2:"512",y2:"445"})]})}function _s(){return x(Qn,{children:[[450,366],[474,376],[484,400],[474,424],[450,434],[426,424],[416,400],[426,376]].map(([n,t],r)=>x("circle",{className:"bx-w",cx:n,cy:t,r:"11",fill:"currentColor",style:{animationDelay:`${-1.2+r*.15}s`}},r))})}function $s(){return je(Qn,{children:[x("g",{className:"bx-sp",children:x("path",{d:"M460 300 Q465.4 324.6 490 330 Q465.4 335.4 460 360 Q454.6 335.4 430 330 Q454.6 324.6 460 300 Z",fill:"currentColor"})}),x("g",{className:"bx-sp bx-sp2",children:x("path",{d:"M486 356 Q493.92 392.08 530 400 Q493.92 407.92 486 444 Q478.08 407.92 442 400 Q478.08 392.08 486 356 Z",fill:"currentColor"})}),x("g",{className:"bx-sp bx-sp3",children:x("path",{d:"M460 440 Q465.4 464.6 490 470 Q465.4 475.4 460 500 Q454.6 475.4 430 470 Q454.6 464.6 460 440 Z",fill:"currentColor"})})]})}import{useCallback as ae,useEffect as ue,useId as oa,useMemo as ze,useRef as kn,useState as J}from"react";var Jn=[{slug:"mac-arm",label:"macOS, Apple silicon"},{slug:"mac-intel",label:"macOS, Intel"},{slug:"windows",label:"Windows"},{slug:"linux",label:"Linux"}];function Vn(e){if(!e)return"";try{return new URL(e).origin}catch{return""}}var Xt="soba";function yo(){return`${Xt}://show`}function Yn(e,n,t){let r=`${Xt}://connect?url=${encodeURIComponent(e)}`;return n&&(r+=`&nonce=${encodeURIComponent(n)}`),t&&(r+=`&want=${encodeURIComponent(t)}`),r}function jn(){let e=globalThis.crypto;if(!e?.getRandomValues)return null;let n=e.getRandomValues(new Uint8Array(32)),t="";for(let r of n)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var ea=1600;function Kt(e={}){return er(e)}async function _t(e,n={}){if(typeof window>"u"||typeof document>"u")return"unknown";let t=er(n);try{window.location.href=Yn(e,n.nonce,n.want)}catch{return"absent"}return t}async function $t(e={}){if(typeof window>"u"||typeof document>"u")return"unknown";let n=er(e);try{window.location.href=yo()}catch{return"absent"}return n}async function er(e){if(typeof window>"u"||typeof document>"u")return"unknown";let n=e.graceMs??ea,t=document.visibilityState==="visible"&&document.hasFocus(),r=!1,o=()=>{r=!0},s=()=>{document.visibilityState==="hidden"&&(r=!0)};return window.addEventListener("blur",o),window.addEventListener("pagehide",o),document.addEventListener("visibilitychange",s),await new Promise(a=>setTimeout(a,n)),window.removeEventListener("blur",o),window.removeEventListener("pagehide",o),document.removeEventListener("visibilitychange",s),t?r?"opened":"absent":"unknown"}var wo="soba.connect.choice",na=180*24*60*60*1e3;function nr(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function tr(e,n){return e?n?`${wo}.${e}.${nr(n)}`:`${wo}.${e}`:null}function rr(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>na)return null;let r=ce.find(o=>o.id===t.choice);return r?r.id:null}catch{return null}}function or(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var Co="soba.connect.model",ta=180*24*60*60*1e3;function sr(e,n){return e?n?`${Co}.${e}.${nr(n)}`:`${Co}.${e}`:null}function bt(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>ta)return null;let r=t.choice;return typeof r!="string"||!r||r.length>120?null:/^[\w.:@+-]+(\/[\w.:@+-]+)?$/.test(r)?r:null}catch{return null}}function ar(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var vo="soba.connect.dismissed",ra=30*24*60*60*1e3;function ir(e,n){return e?n?`${vo}.${e}.${nr(n)}`:`${vo}.${e}`:null}function lr(e){if(!e||typeof localStorage>"u")return!1;try{let n=localStorage.getItem(e);if(!n)return!1;let t=JSON.parse(n);return Date.now()-Date.parse(t.at)<ra}catch{return!1}}function cr(e){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({at:new Date().toISOString()}))}catch{}}import{Fragment as Ct,jsx as d,jsxs as N}from"react/jsx-runtime";var ur=2e3,sa=1e4,aa=9e4,ia=6e4;function dr(e,n,t,r=[],o){return e?"code":n&&(t.length>0||r.length>0)?"manage":o?"launch":"choose"}function la(e){let n=Math.max(0,Math.round(e/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function hr({client:e,initialCode:n,initialChoice:t,onConnected:r,showStatus:o=!0,initialContext:s=null,initialMachines:a,onClose:l,headingId:i,theme:c,reason:u,active:p=!0}){let f=!!s&&a!==void 0,[g,m]=J(f?dr(n,o,a??[],[],t):"loading"),[y,R]=J(s),[S,k]=J(a??[]),[W,F]=J(n??""),[O,P]=J(null),[Q,T]=J(null),[K,q]=J(!1),[de,V]=J(0),[M,De]=J(()=>Date.now()),[Y,pe]=J(null),[Ke,Se]=J(!1),[me,te]=J(!1),[mn,Ue]=J("browser"),[Fe,ie]=J(null),[he,re]=J([]),[Qe,hn]=J(0),[Pe,Te]=J(null),oe=kn(null),[w,j]=J(t??null),[E,Mt]=J(null),Je=ze(()=>{let h=y?.accent?.trim(),v=y?.background?.trim();if(!(!h&&!v))return v?{...rn(v,h),background:v,borderRadius:"inherit"}:{"--sc-accent":h,"--sc-accent-fg":Bn(h)}},[y?.accent,y?.background]),ge=oa(),se=i??ge,Ve=kn(null);ue(()=>{if(!e||f)return;let h=!0;return Promise.all([e.context(),e.machines()]).then(([v,H])=>{h&&(R(v),k(H),m(dr(n,o,H)))}).catch(v=>{h&&(T(v.message),m("choose"))}),()=>{h=!1}},[e,n,o,f]),ue(()=>{g!=="loading"||!f||m(dr(n,o,a??[]))},[g,f,n,o,a]),ue(()=>{a&&k(a)},[a]),ue(()=>{s&&R(s)},[s]);let gn=kn(!1),fn=kn(g);fn.current=g;let _e=kn(he);_e.current=he;let $e=!!y?.hosted_available;ue(()=>{!o&&fn.current==="manage"&&m("choose")},[o]),ue(()=>{if(!e||!p||g!=="manage")return;let h=!0,v=Ce(async()=>{try{let H=await e.machines();if(!h)return;k(H);let U=!$e||gn.current;H.length===0&&_e.current.length===0&&U&&fn.current==="manage"&&m("choose")}catch{}},sa,{immediate:!1});return()=>{h=!1,v()}},[g,e,$e,p]);let en=tr(y?.publishable_key??null);ue(()=>{Mt(rr(en))},[en]),ue(()=>{if(!e||!$e)return;let h=!0;return e.hosted().then(v=>{h&&(re(v.credentials),!gn.current&&(gn.current=!0,v.credentials.length>0&&o&&fn.current==="choose"&&m("manage")))}).catch(()=>{}),()=>{h=!1}},[e,$e,o]),ue(()=>{if(!e||!p||g!=="hosted")return;let h=!0,v=async()=>{try{let Ee=await e.hosted();if(!h)return!1;if(re(Ee.credentials),Ee.credentials.length>0)return m("hosted_connected"),Te(null),!0}catch{}return!1},H=async()=>{oe.current?.closed&&(oe.current=null,!await v()&&h&&m("choose"))},U=Ce(v,ur,{immediate:!1}),tn=setInterval(H,400),ke=Ee=>{let Ln=Ee.data;Ln?.source==="soba"&&Ln.type==="hosted_result"&&v()};return window.addEventListener("message",ke),()=>{h=!1,U(),clearInterval(tn),window.removeEventListener("message",ke),oe.current=null}},[e,g,p]);let Et=ae(()=>{if(!e)return;let h=window.open("","soba-connect-plan","width=520,height=760,noopener=no");oe.current=h,m("hosted"),hn(Date.now()),Te(null),T(null),e.startHosted().then(({url:v})=>{if(h&&!h.closed){h.location.href=v;return}Te(v)}).catch(v=>{h?.close(),oe.current=null,T(v.message),m("choose")})},[e]),it=ae(async h=>{if(e){q(!0);try{await e.disconnectHosted(h),re((await e.hosted()).credentials)}catch(v){T(v.message)}finally{q(!1)}}},[e]);ue(()=>{if(!e||!p||g!=="waiting")return;let h=!0,v=Ce(async()=>{try{let H=await e.machines();if(!h)return;k(H);let U=Ve.current;if(!U)return;let tn=H.filter(Ee=>!U.has(Ee.id)),ke=tn.find(Ee=>Ee.state!=="offline")??tn[0];if(ke){ie(ke.id),w&&or(en,w);let Ee=ce.find(Lt=>Lt.id===w)?.expects??[],Ln=ye(ke).find(Lt=>Ee.includes(Lt.id));Ln&&e.preferRuntime(ke.id,Ln.id).catch(()=>{}),m("connected"),r?.(H)}}catch{}},ur,{immediate:!1});return()=>{h=!1,v()}},[g,e,r,w,en,p]);let lt=ae(async()=>{if(e){T(null),q(!0);try{let h=await e.lookup(W);P(h),m("confirm")}catch(h){T(h.message)}finally{q(!1)}}},[e,W]),An=ae(async()=>{if(e){T(null),q(!0);try{try{Ve.current=new Set((await e.machines()).map(h=>h.id))}catch{Ve.current=new Set(S.map(h=>h.id))}await e.approve(W),m("waiting"),V(Date.now())}catch(h){T(h.message)}finally{q(!1)}}},[e,W,S]),ct=ae(async()=>{if(e){q(!0);try{await e.deny(W),Ue("browser"),m("denied")}catch(h){T(h.message)}finally{q(!1)}}},[e,W]),z=ze(()=>y?.connect_url??null,[y]),[Me,fe]=J(()=>jn()),nn=ze(()=>z?Yn(z,Me??void 0,w??void 0):null,[z,Me,w]),ut=ze(()=>Vn(z),[z]),It=ae(h=>{if(S.length===0)return null;let v=ce.find(U=>U.id===h);if(!v)return null;let H=S.flatMap(U=>U.runtimes??[]).filter(U=>v.expects.includes(U.id));return H.length===0?{tone:"dim",text:"not installed"}:H.some(U=>U.authenticated===!0)?{tone:"ok",text:"ready"}:H.every(U=>U.authenticated===!1)?{tone:"warn",text:"needs signing in"}:{tone:"dim",text:"installed"}},[S]),C=ae((h=null)=>{j(h),T(null),pe(null),Se(!1),te(!1),Z.current=!1,fe(jn()),m("launch")},[]),Z=kn(!!t);ue(()=>{g!=="launch"||!z||Z.current||(Z.current=!0,Se(!0),_t(z,{...Me?{nonce:Me}:{},...w?{want:w}:{}}).then(pe))},[g,z,Me,w]);let le=ae(()=>{Se(!0),Kt().then(pe)},[]),dt=ae(h=>{if(me){let v=jn();te(!1),fe(v),z&&(h.preventDefault(),window.location.href=Yn(z,v??void 0,w??void 0))}le()},[me,le,z,w]),Ae=ze(()=>{let h=y?.runtimes;return h?ce.filter(v=>h.includes(v.id)):Qt()},[y?.runtimes]),ve=ze(()=>{let h=ce.find(v=>v.id===w);return h?{choice:h,Mark:Ye[h.id]??null}:null},[w]),Be=ze(()=>S.find(h=>h.id===Fe),[S,Fe]);ue(()=>{let h=Me;if(!e||!p||g!=="launch"||!h)return;let v=!1,H=Date.now()+15e4,U=()=>{};return U=Ce(async()=>{if(Date.now()>H){U(),te(!0);return}try{let tn=await e.claim(h);if(v)return;if(tn.declined){U(),pe(null),Ue("machine"),m("denied");return}if(!tn.claimed)return;U();try{Ve.current=new Set((await e.machines()).map(ke=>ke.id))}catch{Ve.current=new Set(S.map(ke=>ke.id))}m("waiting"),V(Date.now())}catch{}},ur,{immediate:!1,idle:!1}),()=>{v=!0,U()}},[e,g,S,Me,p]);let be=ze(()=>{if(!O)return null;if(O.approved||O.denied)return"answered";let h=O.expires_at?Date.parse(O.expires_at):Number.NaN;return Number.isFinite(h)&&h<=M?"expired":"live"},[O,M]);ue(()=>{if(!(g==="confirm"&&be==="live"||g==="waiting"||g==="hosted"))return;let v=setInterval(()=>De(Date.now()),1e3);return()=>clearInterval(v)},[g,be]);let pt=ae(async(h,v)=>{if(e)try{await e.approveRuntime(h,v),k(await e.machines())}catch(H){T(H.message)}},[e]),Ot=ae(async(h,v)=>{if(e)try{await e.preferRuntime(h,v),k(await e.machines())}catch(H){T(H.message)}},[e]);return g==="loading"?d("div",{className:"soba-connect",...c?{"data-theme":c}:{},style:Je,children:d("div",{className:"sc-card",children:d("p",{className:"sc-note",children:"Loading\u2026"})})}):N("div",{className:"soba-connect",...c?{"data-theme":c}:{},style:Je,children:[l&&d("button",{type:"button",className:"sc-modal-close",onClick:l,"aria-label":"Close",children:"\xD7"}),g==="manage"&&N("div",{className:"sc-card",children:[d("h2",{className:"sc-title",id:se,children:"Your compute"}),N("p",{className:"sc-sub",children:[d(yt,{context:y})," ",S.length>0&&he.length>0?"runs on your connected plan, and on these machines while they are awake.":he.length>0?"runs on the plan you connected. Nothing here is charged to you.":"runs on these machines, while they are awake."]}),d(ln,{machines:S,hosted:he,onApproveRuntime:pt,onPreferRuntime:(h,v)=>void Ot(h,v),onDisconnectHosted:h=>void it(h),onPair:()=>m("choose"),busy:K,...y?.app.name?{appName:y.app.name}:{}}),Q&&d("p",{className:"sc-error",children:Q})]}),g==="choose"&&N("div",{className:"sc-card",children:[d(ua,{context:y}),d("h2",{className:"sc-h",id:se,children:u==="payment_required"?"Carry on with your own AI":u==="no_compute"?"This run needs a machine":"Connect your AI"}),d("p",{className:"sc-p",children:"Use compute you already have."}),z&&Ae.length>0&&N(Ct,{children:[d("div",{className:"sc-opts",children:Ae.map(h=>{let v=Ye[h.id];return N("button",{type:"button",className:"sc-opt",onClick:()=>C(h.id),children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:v&&d(v,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),(()=>{let H=It(h.id);return H?d("span",{className:`sc-opt-has sc-opt-has-${H.tone}`,children:H.text}):E===h.id?d("span",{className:"sc-opt-last",children:"last used"}):d(pr,{className:"sc-opt-go"})})()]},h.id)})}),N("p",{className:"sc-opt-note",children:["Your accounts stay there. ",ko(y)," never sees them."]})]}),(!z||Ae.length===0)&&d("p",{className:"sc-error",style:{marginTop:16},children:"This app has no publishable key yet, so there is nothing to pair against."}),Q&&d("p",{className:"sc-error",children:Q}),z&&y?.show_code===!0&&d("div",{className:"sc-opt-alt",children:d("button",{type:"button",className:"sc-alt-link",onClick:()=>m("code"),children:"I have a code"})})]}),g==="launch"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d(wt,{mark:ve?.Mark??X,still:me||!Ke&&Y===null}),d("h2",{className:"sc-h",id:se,children:me?"No answer from this machine":Y==="absent"?"Nothing opened":Y===null?"Opening Soba App\u2026":"Approve it on this machine"}),me?d("p",{className:"sc-p",children:"The Soba app did not answer. It may not be open, or nobody was there. Try again when you are ready."}):Y==="absent"?d("p",{className:"sc-p",children:"Nothing opened on this machine. Open it yourself below, or install it if it is not here yet."}):d("p",{className:"sc-p",children:Y===null?"Approve it there and this page does the rest.":"This page finishes on its own."}),ve&&N("p",{className:"sc-prereq",children:[ve.Mark&&d(ve.Mark,{className:"sc-rt-mark"}),"Needs ",ve.choice.prerequisite]}),N("div",{className:"sc-stack",style:{marginTop:18},children:[d("a",{className:Y==="absent"||me?"sc-btn sc-btn-primary":"sc-btn",href:nn??"#",onClick:dt,children:me?"Try again":Y==="absent"?"Open Soba App":"Open it again"}),d("p",{className:"sc-note",children:Y===null?"Your browser will ask permission first.":"Your browser asks permission the first time."}),ve&&Y==="absent"&&d("p",{className:"sc-note",children:d(da,{text:ve.choice.hint})}),N("div",{className:"sc-foot-strip",children:[d("span",{children:"Not installed on this machine?"}),N("button",{type:"button",className:"sc-foot-go",onClick:()=>m("get"),children:["Get it",d(pr,{})]})]})]})]}),g==="get"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("launch")}),d("p",{className:"sc-head-title",children:"Get Soba App"})]}),d("div",{className:"sc-opts",children:Jn.map(h=>N("a",{className:"sc-opt",href:`${ut}/download/${h.slug}`,target:"_blank",rel:"noreferrer noopener",children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:d(Ft,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),d(pr,{className:"sc-opt-go"})]},h.slug))}),d("p",{className:"sc-opt-note",children:"Install it, then come back here and press the row you started with."})]}),g==="code"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-h",id:se,children:"Enter the code from that machine"}),d("p",{className:"sc-p",children:"Eight characters, shown by the Soba app once you paste the link."}),N("form",{className:"sc-stack",style:{marginTop:16},onSubmit:h=>{h.preventDefault(),lt()},children:[d("input",{className:"sc-input",value:W,onChange:h=>F(h.target.value),placeholder:"ACDE-F234",autoComplete:"off",autoFocus:!0,"aria-label":"Pairing code"}),Q&&d("p",{className:"sc-error",children:Q}),d("button",{type:"submit",className:"sc-btn sc-btn-primary",disabled:K||W.length<8,children:K?"Checking\u2026":"Continue"})]})]}),g==="confirm"&&O&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("code")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-title",children:"Attach this machine to your account?"}),N("p",{className:"sc-sub",children:[d(yt,{context:y})," may send your runs to it once you approve. It can never see the account or the keys on it."]}),N("ul",{className:"sc-facts",children:[d(zn,{k:"Code",v:O.user_code}),d(zn,{k:"Machine",v:O.hostname??"not stated"}),d(zn,{k:"System",v:[O.platform,O.arch].filter(Boolean).join(" / ")||"not stated"}),d(zn,{k:"Asked by",v:O.client??"not stated"}),O.labels.length>0&&d(zn,{k:"Labels",v:O.labels.join(", ")})]}),d("p",{className:"sc-note",style:{marginTop:12},children:"Every line above is what that machine said about itself. If none of it looks like a computer of yours, say no."}),be==="expired"&&d("p",{className:"sc-error",children:"That code has expired. Ask the machine for a new one. It prints a fresh code each time it starts."}),be==="answered"&&d("p",{className:"sc-error",children:"That code has already been answered. If it was not you, deny the next one."}),Q&&d("p",{className:"sc-error",children:Q}),N("div",{className:"sc-row",style:{marginTop:16},children:[d("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:()=>void An(),disabled:K||be!=="live",children:"Approve"}),d("button",{type:"button",className:"sc-btn",onClick:()=>void ct(),disabled:K||be==="answered",children:"No, deny it"})]}),be==="live"&&O.expires_at&&N("p",{className:"sc-note",style:{marginTop:10},children:["This code expires in ",la(Date.parse(O.expires_at)-M),"."]})]}),g==="waiting"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:ve?.choice.short??"Soba App"})]}),d(wt,{mark:ve?.Mark??X}),d("h2",{className:"sc-h",id:se,children:"Approved. Waiting for it to connect"}),d("p",{className:"sc-p",children:"Nothing more to do here. This page changes when it arrives."}),de>0&&M-de>aa&&d("p",{className:"sc-note sc-tone-warn",style:{marginTop:14,textAlign:"center"},children:"Still nothing. Look at the Soba app on that machine: it says what it is doing. This keeps watching either way."})]}),g==="connected"&&N("div",{className:"sc-card",children:[d(mr,{tone:"ok"}),d("h2",{className:"sc-h",id:se,children:Be?.label?`${Be.label} is connected`:"Connected"}),N("p",{className:"sc-p",children:[d(yt,{context:y})," will use ",Be?.label?"it":"this machine"," from now on, while it is awake."]}),o&&N(Ct,{children:[d("div",{style:{marginTop:16},children:d(Un,{machines:S,onApproveRuntime:pt})}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:14},onClick:()=>m("manage"),children:"Done"})]})]}),g==="hosted"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"ChatGPT"})]}),Pe?d(wt,{mark:an,still:!0}):d(wt,{mark:an}),d("h2",{className:"sc-h",id:se,children:Pe?"Your browser blocked the window":"Finish signing in to ChatGPT"}),d("p",{className:"sc-p",children:Pe?"Nothing opened. Open the sign-in yourself below. A link you click is allowed where a window we open is not.":"Approve it in the window that opened."}),N("div",{className:"sc-stack",style:{marginTop:18},children:[Pe&&d("a",{className:"sc-btn sc-btn-primary",href:Pe,target:"soba-connect-plan",rel:"noreferrer",children:"Open the ChatGPT sign-in"}),Q&&d("p",{className:"sc-error",children:Q}),Qe>0&&M-Qe>ia&&d("p",{className:"sc-note sc-tone-warn",children:"Still nothing. The window may have been closed before it finished, or the sign-in may have been declined. This keeps watching either way."})]})]}),g==="hosted_connected"&&N("div",{className:"sc-card",children:[d(mr,{tone:"ok"}),d("h2",{className:"sc-h",id:se,children:"ChatGPT is connected"}),N("p",{className:"sc-p",children:[d(yt,{context:y})," will run on your ChatGPT plan",he[0]?.account_label?` (${he[0].account_label})`:"",". Nothing more to pay, nothing to install."]}),d("p",{className:"sc-opt-note",style:{textAlign:"center"},children:"It runs on our side, so it has no access to your files or your terminal."}),o&&N(Ct,{children:[d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>m("manage"),children:"Done"}),d("div",{className:"sc-opt-alt",children:d("button",{type:"button",className:"sc-alt-link",onClick:()=>m("choose"),children:"Connect a machine too"})})]})]}),g==="denied"&&N("div",{className:"sc-card",children:[d(mr,{tone:"off"}),d("h2",{className:"sc-h",id:se,children:"Declined"}),d("p",{className:"sc-p",children:mn==="machine"?"Nothing was connected. You can ask again whenever you like.":"That machine was not attached to your account, and the terminal has been told so."}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>m("choose"),children:"Back to the start"})]})]})}function ko(e){return e?.app.name??"this app"}function ca(e){let n=e?.app.icon_urls;if(n?.length)return n;let t=e?.app.icon_url;return t?[t]:[]}function No(e){let n=ca(e),[t,r]=J([]),o=ae(l=>{l&&r(i=>i.includes(l)?i:[...i,l])},[]),s=ae(l=>o(l.currentTarget.getAttribute("src")),[o]),a=ae(l=>{l?.complete&&l.naturalWidth===0&&o(l.getAttribute("src"))},[o]);return{icon:n.find(l=>!t.includes(l)),onError:s,ref:a}}function ua({context:e}){let{icon:n,onError:t,ref:r}=No(e);return e?.app.mark==="soba"?d(X,{className:"sc-app-mark"}):n?d("img",{className:"sc-app-mark",src:n,alt:"","aria-hidden":"true",ref:r,onError:t}):null}function yt({context:e}){let{icon:n,onError:t,ref:r}=No(e),o=e?.app.mark==="soba";return N("span",{className:"sc-app",children:[o&&d(X,{className:"sc-app-icon"}),!o&&n&&d("img",{className:"sc-app-icon",src:n,alt:"",ref:r,onError:t}),ko(e)]})}function Nn({onClick:e}){return d("button",{type:"button",className:"sc-head-back",onClick:e,"aria-label":"Back",children:d("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:d("path",{d:"M15 5 8 12l7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function pr({className:e}){return d("svg",{className:e,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:d("path",{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function wt({mark:e,still:n}){return N("span",{className:"sc-waiting","aria-hidden":"true",children:[!n&&d("svg",{className:"sc-waiting-orbit",viewBox:"0 0 100 100","aria-hidden":"true",focusable:"false",children:d("circle",{className:"sc-waiting-arc",cx:"50",cy:"50",r:"46"})}),d(e,{className:"sc-waiting-mark"})]})}function mr({tone:e}){return d("span",{className:`sc-result sc-result-${e}`,"aria-hidden":"true",children:d(Zt,{kind:e==="ok"?"snap":"gone",size:84})})}function da({text:e}){return d(Ct,{children:e.split("`").map((n,t)=>t%2===1?d("code",{className:"sc-inline-code",children:n},t):n)})}function zn({k:e,v:n}){return N("li",{className:"sc-fact",children:[d("span",{className:"sc-fact-key",children:e}),d("span",{children:n})]})}import{forwardRef as pa}from"react";import{jsx as gr,jsxs as fr}from"react/jsx-runtime";var Ar=pa(function({machine:n,className:t,...r},o){if(!n)return null;let{ariaLabel:s,state:a}=wn(n);return fr("button",{ref:o,type:"button","aria-label":s,className:["sc-btn","sc-btn-connected",t].filter(Boolean).join(" "),...r,children:[gr("span",{className:"sc-pill-tile","aria-hidden":"true",children:gr(X,{className:a.tone==="busy"?"sc-pill-mark sc-pill-mark-busy":"sc-pill-mark"})}),fr("span",{className:"sc-btn-connected-text",children:[a.word,fr("span",{className:"sc-btn-connected-where",children:[" on ",_(n)]})]}),gr("i",{className:`sc-dot sc-dot-${a.tone}`,"aria-hidden":"true"})]})});import{useEffect as ma,useRef as yr}from"react";var vt=0,br=null;function xo(){if(typeof document>"u")return()=>{};vt===0&&(br=document.body.style.overflow,document.body.style.overflow="hidden"),vt+=1;let e=!1;return()=>{e||(e=!0,vt-=1,vt===0&&(document.body.style.overflow=br??"",br=null))}}import{jsx as Ro}from"react/jsx-runtime";function qn({open:e,onClose:n,labelledBy:t,theme:r,style:o,children:s}){let a=yr(null),l=yr(null),i=yr(null);return ma(()=>{let c=a.current;if(c){if(!e){c.open&&c.close();return}return c.open||c.showModal(),document.activeElement===c&&l.current?.focus(),xo()}},[e]),Ro("dialog",{ref:a,className:"soba-connect sc-modal","aria-labelledby":t,...r?{"data-theme":r}:{},style:o,onCancel:c=>{c.preventDefault(),n()},onPointerDown:c=>{i.current=c.target},onClick:c=>{c.target===c.currentTarget&&i.current===c.currentTarget&&n()},children:Ro("div",{className:"sc-modal-sheet",ref:l,tabIndex:-1,children:s})})}import{useRef as fa,useState as Aa}from"react";var ha={"claude-code":{small:"haiku",large:"opus"}};function So(e){let n=ha[e];return!!(n?.small||n?.large)}var ga={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus",fable:"Fable"};function Po(e){return ga[e]??e}function wr(e){let n=[...e].sort(mt),t=Ie([...e]),r=t?Ge(t):null,s=[{id:"auto",kind:"auto",label:"Automatic",model:"auto",...r?.runtime?{note:`Uses ${r.runtime.display_name}`}:{}}];n.some(u=>ye(u).some(p=>So(p.id)))&&s.push({id:"small",kind:"size",label:"Fast",note:"quick and cheap",model:"small"},{id:"large",kind:"size",label:"Best",note:"the most capable",model:"large"});let l=new Map;for(let u of n)for(let p of ye(u))for(let f of p.models){if(!f)continue;let g=`${p.id}/${f}`,m=l.get(g);if(m){m.machines.add(_(u));continue}l.set(g,{option:{id:g,kind:"named",label:Po(f),model:f,runtime:p.id,runtimeName:p.display_name,costClass:p.cost_class},machines:new Set([_(u)])})}let i=new Set;for(let{machines:u}of l.values())for(let p of u)i.add(p);let c=i.size>1;for(let{option:u,machines:p}of l.values()){let f=c&&p.size===1?[...p][0]:void 0;s.push(f?{...u,machine:f}:u)}return s}function Zn(e){let n=[],t=[];for(let r of e){if(r.kind!=="named"){n.push(r);continue}let o=r.runtimeName??r.runtime??"",s=t.find(a=>a.heading===o);s?s.options.push(r):t.push({heading:o,options:[r]})}return n.length?[{heading:null,options:n},...t]:t}function Cr(e,n){let t=e.find(o=>o.kind==="auto")??{id:"auto",kind:"auto",label:"Automatic",model:"auto"};if(!n||n==="auto")return{selected:t,unavailable:null};let r=e.find(o=>o.id===n);return r?{selected:r,unavailable:null}:{selected:t,unavailable:n}}function vr(e){return e.runtime?{model:e.model,runtime:e.runtime}:{model:e.model}}function Xn(e){return e.length>1}import{jsx as kt,jsxs as Mo}from"react/jsx-runtime";function kr({options:e,selected:n,onPick:t,caption:r,disabled:o,className:s}){let[a,l]=Aa(!1),i=fa(null);if(!Xn(e))return null;let c=s?`sc-mp ${s}`:"sc-mp";return Mo("span",{className:c,children:[r&&kt("span",{className:"sc-mp-cap",children:r}),Mo("button",{ref:i,type:"button",className:"sc-mp-btn","aria-haspopup":"menu","aria-expanded":a,"aria-label":`Model: ${n.label}. Change`,disabled:o,onClick:()=>l(u=>!u),children:[kt("span",{className:"sc-mp-label",children:n.label}),kt(Cn,{open:!0})]}),a&&kt(Dn,{anchor:i,label:"Which model answers",options:ba(e),current:n.id,onClose:()=>l(!1),onPick:u=>{l(!1),u&&t(u)}})]})}function ba(e){let n=[];for(let t of Zn(e))t.options.forEach((r,o)=>{let s=ya(r);n.push({id:r.id,label:r.label,...s?{note:s}:{},...t.heading&&o===0?{heading:t.heading}:{},...!t.heading&&r.kind==="size"&&o===1?{rule:!0}:{}})});return n}function ya(e){return e.kind!=="named"?e.note:e.machine?`on ${e.machine}`:void 0}import{useEffect as Nr,useRef as wa}from"react";import{jsx as Ca}from"react/jsx-runtime";var un=8;function xr({open:e,onClose:n,anchor:t,label:r,theme:o,style:s,children:a}){let l=wa(null);return Nr(()=>{let i=l.current;if(!(!i||!(typeof i.showPopover=="function")))try{e?i.showPopover():i.hidePopover()}catch{}},[e]),Nr(()=>{if(!e)return;let i=()=>{let u=l.current,p=t.current;if(!u||!p)return;let f=p.getBoundingClientRect(),g=u.offsetWidth,m=u.offsetHeight,y=window.innerWidth-g-un,R=Math.max(un,Math.min(f.right-g,Math.max(un,y))),S=f.bottom+un,k=f.top-un-m,W=S+m>window.innerHeight-un&&k>un?k:S;u.style.left=`${Math.round(R)}px`,u.style.top=`${Math.round(W)}px`};i();let c=requestAnimationFrame(i);return window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{cancelAnimationFrame(c),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e,t]),Nr(()=>{if(!e)return;let i=u=>{u.key==="Escape"&&n()},c=u=>{let p=u.target;p&&(l.current?.contains(p)||t.current?.contains(p)||n())};return document.addEventListener("keydown",i),document.addEventListener("pointerdown",c,!0),()=>{document.removeEventListener("keydown",i),document.removeEventListener("pointerdown",c,!0)}},[e,n,t]),Ca("div",{ref:l,role:"dialog","aria-label":r,className:"soba-connect sc-pop",...o?{"data-theme":o}:{},popover:"manual",hidden:!e,style:s,children:a})}var Kn=new Map,xn=new Map,Eo=!1;function va(){Eo||typeof window>"u"||(Eo=!0,window.addEventListener("storage",e=>{!e.key||!Kn.has(e.key)||(xn.set(e.key,bt(e.key)),Rr(e.key))}))}function Rr(e){for(let n of Kn.get(e)??[])n()}function _n(e){return e??""}function Sr(e,n){let t=_n(e);va();let r=Kn.get(t)??new Set;return r.add(n),Kn.set(t,r),()=>{r.delete(n),r.size===0&&Kn.delete(t)}}function Nt(e){let n=_n(e),t=xn.get(n);if(t!==void 0)return t;let r=e?bt(e):null;return xn.set(n,r),r}function Pr(){return null}function Mr(e,n){Nt(e)===null&&(xn.set(_n(e),n),Rr(_n(e)))}function Er(e,n){let t=_n(e);xn.get(t)!==n&&(xn.set(t,n),ar(e,n),Rr(t))}function We(e){let n=`${e.unit}s`;return e.reward==="unlimited"?`Unlimited ${n} on your own AI`:e.reward==="included"&&e.includedUnits!==null?`${Na(e.includedUnits)} ${n} a month once you connect`:e.reward==="credit"&&e.creditMicros>0?`${ka(e.creditMicros)} back each month you stay connected`:null}function He(e){return e==="unlimited"||e==="included"}var Oo=new Set(["user-hardware","user-subscription"]),Io=new Set(["open-weights","frontier"]);function xe(e){return e===null||e.length===0?!1:e.every(n=>Oo.has(n))}var ka=e=>(e/1e6).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),Na=e=>e.toLocaleString("en-US");function Ir(e,n){if(!(n===null||n.some(s=>Io.has(s))))return!1;let r=e.findIndex(s=>Oo.has(s));if(r===-1)return!1;let o=e.findIndex(s=>Io.has(s));return o===-1||r<o}import{createContext as Lo,useContext as To}from"react";var Or=Lo(null);function Rn(){return To(Or)}var Lr=Lo({context:null,machines:void 0,theme:"light"});function B(){return To(Lr)}import{useMemo as Sa}from"react";import{createContext as xa,useContext as Ra}from"react";var Tr=xa(null);function D(){let e=Ra(Tr);if(!e)throw new Error("useSoba() must be used inside a <SobaProvider>.");return e}function $n(){let{compute:e}=D();return Sa(()=>{let n=e.machines,t=[...n].sort((s,a)=>Ie([s,a])===s?-1:1).map(Pa),r=Ie([...n]),o=on(n);return{view:t.length?"machines":e.loading?"loading":e.error?"error":"empty",machines:t,primary:r?t.find(s=>s.machine.id===r.id)??null:null,connected:e.connected,online:e.online,stalled:e.connected&&!e.online&&o?t.find(s=>s.machine.id===o.id)??null:null,loading:e.loading,error:e.error,refresh:e.refresh}},[e])}function Pa(e){let n=Ge(e);return{machine:e,name:_(e),state:sn(e),status:Bt(e),hardware:Wn(e),lastSeen:e.state==="offline"?Hn(e.last_seen_at):null,runtimes:ye(e).map(t=>({runtime:t,name:t.display_name,auth:Gn(t),quarantined:!!t.quarantined})),runsOn:{by:n.by,name:n.runtime?.display_name??null}}}import{jsx as et}from"react/jsx-runtime";function Ma({className:e}){let{theme:n}=B(),t=e?`soba-connect ${e}`:"soba-connect";return et("div",{className:t,"data-theme":n,children:et(Br,{})})}function Br(){let e=$n();return e.view==="loading"?et("p",{className:"sc-note",children:"Loading\u2026"}):e.view==="error"?et("p",{className:"sc-error",children:e.error?.message}):et(Un,{machines:e.machines.map(n=>n.machine)})}import{useCallback as tt,useEffect as Dr,useMemo as Wa,useRef as Ur,useState as Pn}from"react";import{useId as Ea}from"react";import{jsx as Sn,jsxs as xt}from"react/jsx-runtime";function nt({open:e,onOpenChange:n,initialCode:t,onConnected:r,showStatus:o,reason:s}){let{error:a}=D(),l=Rn(),i=B(),c=()=>n(!1),u=Ea(),p=i.context?.background?.trim(),f=p?rn(p,i.context?.accent):void 0;return xt(qn,{open:e,onClose:c,labelledBy:u,theme:i.theme,style:f,children:[a?xt("div",{className:"sc-card",children:[Sn("h2",{className:"sc-title",id:u,children:"Could not start"}),Sn("p",{className:"sc-error",children:a.message})]}):!l&&!i.context?xt("div",{className:"sc-card",children:[Sn("h2",{className:"sc-title",id:u,children:"One moment"}),Sn("p",{className:"sc-note",children:"Getting your compute\u2026"})]}):Sn(hr,{client:l,active:e,onClose:c,headingId:u,theme:i.theme,initialContext:i.context,...i.machines!==void 0?{initialMachines:i.machines}:{},...t?{initialCode:t}:{},...r?{onConnected:r}:{},...o===void 0?{}:{showStatus:o},...s?{reason:s}:{}}),xt("p",{className:"sc-modal-foot",children:[Sn(X,{className:"sc-foot-mark"}),"Secured by Soba"]})]})}import{forwardRef as Ia}from"react";import{jsx as Oa}from"react/jsx-runtime";var Gr=Ia(function(n,t){let{theme:r}=B();return Oa(Ar,{ref:t,"data-theme":r,...n})});import{useCallback as La}from"react";function Ta(){let{connect:e}=D(),n=$n(),t=La(()=>e.open("manual"),[e]);return{...wn(n.primary?.machine??null),machine:n.primary,open:t,canOpen:e.hasModal,loading:n.view==="loading"}}function Wr(e){return wn(e)}import{useCallback as Bo,useEffect as Ba,useState as Ga}from"react";function Hr({enabled:e=!0,intervalMs:n=3e3}={}){let t=Rn(),[r,o]=Ga(null),s=Bo(async()=>{t&&o(await t.runs())},[t]);Ba(()=>{if(!e||!t)return;let l=!0,i=Ce(async()=>{let c=await t.runs();l&&o(c)},n);return()=>{l=!1,i()}},[e,t,n]);let a=Bo(async l=>{if(!t)throw new Error("Stopping a run needs <SobaProvider>.");await t.stopRun(l),await s().catch(()=>{})},[t,s]);return{runs:r,refresh:s,stop:a}}import{Fragment as Go,jsx as Mn,jsxs as Wo}from"react/jsx-runtime";function dn({children:e,variant:n,className:t,initialCode:r,onConnected:o,defaultOpen:s,open:a,onOpenChange:l,showConnected:i=!0}){let{compute:c,connect:u}=D(),p=B(),{theme:f}=p,g=Rn(),[m,y]=Pn(s??!!r),R=Ur(null),S=a!==void 0,k=!S&&!s&&!r&&u.hasModal,W=S?a:k?u.isOpen:m,F=w=>{k?w?u.open("manual"):u.close():S||y(w),l?.(w)},O=Ur(W);Dr(()=>{O.current&&!W&&R.current?.focus(),O.current=W},[W]);let[P,Q]=Pn(!1),{runs:T,stop:K}=Hr({enabled:P}),q=Wa(()=>P&&T?Ha(c.machines,T):c.machines,[c.machines,P,T]),de=Ie(q),V=i&&Wr(de).connected,M=tt(()=>Q(!1),[]),[De,Y]=Pn(!1),pe=tt(async()=>{Y(!0);try{await c.refresh()}finally{Y(!1)}},[c]),Ke=Ur(pe);Ke.current=pe,Dr(()=>{P&&Ke.current()},[P]);let[Se,me]=Pn(!1),[te,mn]=Pn([]),Ue=!!p.context?.hosted_available;Dr(()=>{if(!P||!g||!Ue)return;let w=!0;return g.hosted().then(j=>{w&&mn(j.credentials)}).catch(()=>{}),()=>{w=!1}},[P,g,Ue]);let[Fe,ie]=Pn(null),he=tt(async(w,j)=>{if(g){ie(null);try{await g.approveRuntime(w,j),await c.refresh()}catch(E){ie(E.message)}}},[g,c]),re=tt(async(w,j)=>{if(g){ie(null);try{await g.preferRuntime(w,j),await c.refresh()}catch(E){ie(E.message)}}},[g,c]),Qe=tt(async w=>{if(g){ie(null);try{await g.disconnectHosted(w),mn((await g.hosted()).credentials)}catch(j){ie(j.message)}}},[g]),hn=p.context?.background?.trim(),Pe=hn?rn(hn,p.context?.accent):void 0,Te=V&&!e,oe=()=>{if(Te&&!S&&!s&&!r){Q(w=>!w);return}F(!0)};return Wo(Go,{children:[Te?Mn(Gr,{ref:R,machine:de,"aria-haspopup":"dialog","aria-expanded":P,onClick:oe,...t?{className:t}:{}}):Mn("button",{ref:R,type:"button","data-theme":f,className:["sc-btn","sc-btn-icon",n==="primary"?"sc-btn-primary":"",t].filter(Boolean).join(" "),onClick:oe,children:e??Wo(Go,{children:[Mn(X,{className:"sc-btn-mark"}),"Connect compute"]})}),Mn(xr,{open:P,onClose:M,anchor:R,label:"Your compute",theme:f,...Pe?{style:Pe}:{},children:Mn(ln,{machines:q,hosted:te,onApproveRuntime:(w,j)=>void he(w,j),onPreferRuntime:(w,j)=>void re(w,j),onDisconnectHosted:w=>void Qe(w),onRefresh:()=>void pe(),refreshing:De,error:Fe,runs:T,onStopRun:async w=>{ie(null);try{await K(w)}catch(j){throw ie(j.message),j}},onPair:()=>{Q(!1),k?u.open("pair"):(me(!0),F(!0))},...p.context?.app.name?{appName:p.context.app.name}:{}})}),!k&&Mn(nt,{open:W,onOpenChange:w=>{w||me(!1),F(w)},...Se?{showStatus:!1}:{},...r?{initialCode:r}:{},...o?{onConnected:o}:{}})]})}function Ha(e,n){return e.map(t=>{if(t.state==="offline")return t;let r=n.filter(o=>o.machine_id===t.id).length;return{...t,active:r,state:r>0?"busy":"online"}})}import{jsx as Fr,jsxs as Ua}from"react/jsx-runtime";function Da({initialCode:e,onConnected:n,className:t,showStatus:r=!0}){let{theme:o}=B();return Ua("div",{className:t?`soba-connect ${t}`:"soba-connect","data-theme":o,children:[r&&Fr(Br,{}),Fr("div",{className:"sc-compute-act",children:Fr(dn,{...e?{initialCode:e}:{},...n?{onConnected:n}:{}})})]})}import{useId as _a,useState as $a}from"react";import{useCallback as Jr,useEffect as Qo,useState as Jo}from"react";import{useCallback as Fa,useState as Qa}from"react";function rt(){let[e,n]=Qa(null);return{open:Fa(()=>{n(null),$t().then(n)},[]),launch:e,note:e==="absent"?"Nothing opened here. That machine may be a different computer, or asleep.":null}}import{useCallback as Ho,useMemo as Do}from"react";function pn(e){if(!e)return null;if(typeof e=="string")return e;if(typeof Response<"u"&&e instanceof Response)return Uo(e.status);let n=e,t=n.error;return typeof t?.code=="string"?t.code:typeof t?.type=="string"?t.type:typeof n.code=="string"?n.code:typeof n.status=="number"?Uo(n.status):n.cause&&n.cause!==e?pn(n.cause):null}function Uo(e){return e===402?"payment_required":e===409?"no_compute":null}function Qr(...e){let[n,t]=e,{plan:r,compute:o,connect:s}=D(),a=t?.predict??e.length===0,l=Va(Ja(n),o)??(a?Ya(r,o):null),i=r.plan,c=r.plans,u=Do(()=>{if(l!=="payment_required")return null;let m=i?.price??0,y=i?.included_units??0;return c.find(R=>R.id!==i?.id&&R.price>m&&(R.included_units===null||R.included_units>y))??null},[l,c,i]),p=Ho(async()=>{if(!u)return;if(u.selectable){await r.select(u.id);return}let m=await r.checkout(u.id);window.location.assign(m)},[u,r]),f=s.open,g=Ho(()=>{l&&f(l)},[f,l]);return Do(()=>{if(!l)return null;let m=i?We({unit:i.unit,reward:i.connected_reward,includedUnits:i.connected_included_units,creditMicros:i.connected_credit*1e6}):null,y=i&&He(i.connected_reward)?m:null;return{reason:l,...ja(l,{connectOffer:y,connected:o.connected,online:o.online,machine:on(o.machines)?.label??null,unit:i?.unit??"message",interval:i?.interval??"month",upgrade:u!==null,resets:r.current?.period_end??null}),connectOffer:y,upgradeTo:u,connect:g,upgrade:p}},[l,i,o,u,g,p,r.current?.period_end])}function Ja(e){let n=pn(e);return n==="payment_required"||n==="no_compute"?n:null}function Va(e,n){return e==="no_compute"&&n.connected&&n.online?null:e}function Ya(e,n){let t=e.plan;return!t||n.loading?null:xe(t.route_allow)&&!n.online?"no_compute":e.remaining===0&&t.overage==="stop"?"payment_required":null}function ja(e,n){if(e==="payment_required"){let t=`No ${n.unit}s left this ${n.interval}`;return n.connectOffer&&!n.connected?{title:t,body:`${n.connectOffer}. Connecting takes a minute and costs nothing.`}:n.connectOffer&&!n.online?{title:t,body:`${n.connectOffer}. Waking ${n.machine??"your machine"} is enough.`}:n.upgrade?{title:t,body:n.resets?`A larger plan carries on now. This one comes back on ${Fo(n.resets)}.`:"A larger plan carries on now, or wait for this one to renew."}:{title:t,body:n.resets?`Your allowance comes back on ${Fo(n.resets)}.`:"Your allowance comes back at the start of the next period."}}return n.connected&&!n.online?{title:`${n.machine??"Your machine"} can't be reached`,body:"This run needs it awake and connected. Open Soba App on that machine, or connect another one."}:{title:"Nothing connected yet",body:"This app runs on AI you already pay for, on a machine of your own. Connect one and this run has somewhere to go."}}function Fo(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}function za(e){let{plan:n,allowance:t,connected:r,online:o,quiet:s,error:a,predict:l,at:i,waved:c}=e;if(!n)return null;let u=e.allow!==void 0?e.allow:n.route_allow;if(r){if(o)return null;let y=xe(u);return{reason:"stalled",title:`${s??"Your machine"} can\u2019t be reached`,detail:y?"The Soba app there has stopped reporting in, so runs have nowhere to go until it is back.":"The Soba app there has stopped reporting in, so nothing will run on your own AI until it is back.",meter:null,dismissible:!1,atTheWall:!1,ownCompute:y}}let p=pn(a),f=p==="payment_required"||p==="no_compute",g=n.ask_to_connect!==!1&&Ir(n.route_prefer,u);if(!l&&!f&&!g)return null;let m=xe(u)?qa(n.unit,xe(n.route_allow)):He(n.connected_reward)?Xa(t,n,i):g?Za(n.unit):null;return!m||m.dismissible&&c?null:{...m,dismissible:!!m.dismissible,ownCompute:!1,atTheWall:!m.dismissible&&(!l||m.meter!==null&&m.meter.left===0)}}function Vr(e={}){let{at:n=.25,error:t,allow:r}=e,o=e.predict??!(e.errorGiven??t!==void 0),{plan:s,compute:a,connect:l}=D(),i=ir(l.publishableKey),[c,u]=Jo(!1);Qo(()=>{u(lr(i))},[i]);let p=Jr(()=>{u(!0),cr(i)},[i]),f=Jr(()=>l.open("manual"),[l]),g=Jr(()=>l.open("no_compute"),[l]),m=rt(),[y,R]=Jo(!1),{refresh:S}=a,{launch:k}=m;Qo(()=>{if(k===null||k==="absent")return;R(!1);let Q=setInterval(()=>void S(),3e3),T=setTimeout(()=>{clearInterval(Q),R(!0)},2e4);return()=>{clearInterval(Q),clearTimeout(T)}},[k,S]);let W=Ka(l.app?.name,Vn(l.connectUrl)),F=s.loading||a.loading,O=on(a.machines),P=F?null:za({plan:s.plan,allowance:{remaining:s.remaining,included:s.included},connected:a.connected,online:a.online,quiet:O?_(O):null,error:t,predict:o,...r!==void 0?{allow:r}:{},at:n,waved:c});return{reason:P?.reason??null,visible:P!==null,title:P?.title??null,detail:P?.detail??null,meter:P?.meter??null,dismissible:P?.dismissible??!1,dismissed:c,dismiss:p,open:f,atTheWall:P?.atTheWall??!1,steps:W,stalled:P?.reason==="stalled"?{machine:O?_(O):null,ownCompute:P.ownCompute,wake:m.open,launch:m.launch,note:m.note,stuck:y,connectAnother:g}:null,loading:F}}function qa(e,n){return{reason:"needed",title:n?"This plan runs on your own AI.":`These ${e}s run on your own AI.`,detail:`Connect a machine and your ${e}s run there, free, on access you already have.`,meter:null}}function Za(e){return{reason:"preferred",title:"This plan prefers your own AI.",detail:`Connect a machine and your ${e}s run there instead, on access you already have.`,meter:null,dismissible:!0}}function Xa(e,n,t){let{remaining:r,included:o}=e;if(r===null||o===null||o===0||r>Math.ceil(o*t))return null;let s=We({unit:n.unit,reward:n.connected_reward,includedUnits:n.connected_included_units,creditMicros:n.connected_credit*1e6});return s?{reason:"running",title:r===0?`No ${n.unit}s left this month.`:`${r} ${n.unit}${r===1?"":"s"} left this month.`,detail:`${s}.`,meter:{left:r,of:o}}:null}function Ka(e,n){return[{lead:"Download Soba App",detail:"",...n?{linksLead:"Get it for"}:{},links:n?Jn.map(t=>({label:t.label,href:`${n}/download/${t.slug}`})):[]},{lead:"Connect compute",detail:"Press this, then approve the pairing when the app asks.",opens:!0,links:[]},{lead:"Let your AIs serve",detail:`It finds what is installed on that machine. Allow one, and ${e??"this app"} sends every run there.`,linksLead:"Nothing on it yet?",links:ce.map(t=>({label:t.short,href:t.install}))}]}import{Fragment as Yo,jsx as L,jsxs as qe}from"react/jsx-runtime";function ei(e){let{className:n,fallback:t=null}=e,r=Vr({...e.at===void 0?{}:{at:e.at},...e.predict===void 0?{}:{predict:e.predict},...e.allow===void 0?{}:{allow:e.allow},error:e.error,errorGiven:"error"in e}),{connect:o}=D(),{theme:s}=B(),[a,l]=$a(null),i=_a(),c=L(Yo,{children:t});if(!r.visible)return c;if(r.stalled)return L(Vo,{className:n,theme:s,stalled:!0,children:L(ni,{title:r.title??"",detail:r.detail??"",stalled:r.stalled})});let u=a??r.atTheWall;return qe(Vo,{className:n,theme:s,children:[qe("div",{className:"sc-nudge-top",children:[qe("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:r.title}),L("p",{className:"sc-nudge-detail",children:r.detail}),qe("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more","aria-expanded":u,"aria-controls":i,onClick:()=>l(!u),children:[u?"Hide the details":"How it works",L(ri,{})]})]}),r.dismissible?L("button",{type:"button",className:"sc-nudge-dismiss","aria-label":"Dismiss",title:"Dismiss",onClick:r.dismiss,children:L(ti,{})}):null]}),u?L("ol",{className:"sc-nudge-steps",id:i,children:r.steps.map(p=>qe("li",{children:[p.opens?L("button",{type:"button",className:"sc-step-lead",onClick:()=>o.open("manual"),children:p.lead}):L("strong",{children:p.lead}),p.detail?L("span",{children:p.detail}):null,p.links.length>0?qe("span",{className:"sc-step-links",children:[p.linksLead,p.links.map(f=>L("a",{href:f.href,target:"_blank",rel:"noreferrer noopener",children:f.label},f.href))]}):null]},p.lead))}):null,L(dn,{variant:"primary"})]})}function Vo({className:e,theme:n,stalled:t,children:r}){return L("div",{className:e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill","data-theme":n,children:L("div",{className:t?"sc-nudge sc-nudge-stalled":"sc-nudge",children:r})})}function ni({title:e,detail:n,stalled:t}){return qe(Yo,{children:[L("div",{className:"sc-nudge-top",children:qe("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:e}),L("p",{className:"sc-nudge-detail",children:n}),t.note&&L("p",{className:"sc-nudge-note",children:t.note}),t.stuck&&L("p",{className:"sc-nudge-note",children:"The Soba app is open, but this machine still isn\u2019t reporting in. It may no longer be connected to this app."}),(t.launch==="absent"||t.stuck)&&L("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more",onClick:t.connectAnother,children:t.stuck?"Connect it again":"Connect another machine"})]})}),L("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:t.wake,children:"Open Soba App"})]})}function ti(){return L("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-x",children:L("path",{d:"m4.8 4.8 6.4 6.4M11.2 4.8l-6.4 6.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function ri(){return L("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-chev",children:L("path",{d:"M4.5 6.5 8 10l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}var oi=new Set(["delta","thinking","status","done","error"]);function En(e){let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!="object")return null;let t=n,r=t.type==="event"?t.event:t;if(!r||typeof r!="object")return null;let o=r;if(typeof o.type!="string"||!oi.has(o.type))return null;let s={type:o.type};return typeof o.text=="string"&&(s.text=o.text),typeof o.message=="string"&&(s.message=o.message),typeof o.tool=="string"&&(s.tool=o.tool),typeof o.tier=="string"&&(s.tier=o.tier),o.usage&&typeof o.usage=="object"&&(s.usage=o.usage),typeof o.session=="string"&&(s.session=o.session),typeof o.toolInput=="string"&&(s.toolInput=o.toolInput),o.git&&typeof o.git=="object"&&(s.git=o.git),o.turn&&typeof o.turn=="object"&&typeof o.turn.text=="string"&&(s.turn={text:o.turn.text}),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.retryable=="boolean"&&(s.retryable=o.retryable),(o.state==="interrupted"||o.state==="resumed")&&(s.state=o.state),s}async function*Yr(e){let n=e.body;if(!n)throw new Error("That run response had no body to stream.");let t=(e.headers.get("content-type")??"").includes("ndjson"),r=n.getReader(),o=new TextDecoder,s="",a=[];try{for(;;){let i=await r.read();if(i.done)break;for(s+=o.decode(i.value,{stream:!0});;){let c=s.indexOf(`
|
|
3
|
+
`);if(c===-1)break;let u=zo(s.slice(0,c));if(s=s.slice(c+1),t){let p=u.trim()?En(u):null;p&&(yield p);continue}if(u===""){let p=a.join(`
|
|
4
|
+
`);if(a=[],p==="[DONE]")return;let f=p?En(p):null;f&&(yield f);continue}jo(u,a)}}!t&&s&&jo(zo(s),a);let l=t?s.trim():a.join(`
|
|
5
|
+
`);if(l&&l!=="[DONE]"){let i=En(l);i&&(yield i)}}finally{r.cancel().catch(()=>{})}}function jo(e,n){if(!e||e.startsWith(":"))return;let t=e.indexOf(":");if(t===-1||e.slice(0,t)!=="data")return;let r=e.slice(t+1);n.push(r.startsWith(" ")?r.slice(1):r)}function zo(e){return e.endsWith("\r")?e.slice(0,-1):e}async function si(e){let n="";for await(let t of e)if(t.type==="delta"&&t.text&&(n+=t.text),t.type==="error")throw new Error(t.message??"The run ended with an error.");return n}import{useCallback as jr,useEffect as ai,useMemo as zr,useSyncExternalStore as ii}from"react";function qr(e={}){let{compute:n,connect:t}=D(),{value:r,onChange:o,defaultValue:s,remember:a=!0,user:l}=e,i=r!==void 0,c=a&&!i?sr(t.publishableKey,l):null,u=jr(k=>Sr(c,k),[c]),p=ii(u,jr(()=>Nt(c),[c]),Pr),f=zr(()=>wr(n.machines),[n.machines]),g=zr(()=>Zn(f),[f]);ai(()=>{i||!s||Mr(c,s)},[i,s,c]);let m=i?r:p??s??null,{selected:y,unavailable:R}=zr(()=>Cr(f,m??null),[f,m]),S=jr(k=>{i||Er(c,k),o?.(k)},[i,c,o]);return{options:f,groups:g,selected:y,select:S,run:vr(y),unavailable:R,pickable:Xn(f),loading:n.loading&&!n.machines.length}}import{jsx as qo}from"react/jsx-runtime";function li({caption:e,disabled:n,className:t,...r}){let{theme:o}=B(),{options:s,selected:a,select:l,pickable:i}=qr(r);return i?qo("span",{className:"soba-connect sc-inline","data-theme":o,children:qo(kr,{options:s,selected:a,onPick:l,...e?{caption:e}:{},...n?{disabled:n}:{},...t?{className:t}:{}})}):null}import{useEffect as ci}from"react";var Zo="data-soba-react",Xo=!1;function ot(){if(Xo||typeof document>"u"||(Xo=!0,document.querySelector(`style[${Zo}]`)))return;let e=document.createElement("style");e.setAttribute(Zo,""),e.textContent=`.soba-connect {
|
|
6
6
|
--sc-ground: #ffffff;
|
|
7
7
|
--sc-sheet: #ffffff;
|
|
8
8
|
--sc-raised: #f6f6f7;
|
|
@@ -48,9 +48,6 @@ import{useRef as ps,useState as so}from"react";var Cn=class extends Error{status
|
|
|
48
48
|
|
|
49
49
|
box-sizing: border-box;
|
|
50
50
|
|
|
51
|
-
width: 100%;
|
|
52
|
-
max-width: 560px;
|
|
53
|
-
margin: 0 auto;
|
|
54
51
|
color: var(--sc-text, #1a1a1c);
|
|
55
52
|
font-family: var(
|
|
56
53
|
--sc-font,
|
|
@@ -66,6 +63,12 @@ import{useRef as ps,useState as so}from"react";var Cn=class extends Error{status
|
|
|
66
63
|
line-height: 1.5;
|
|
67
64
|
letter-spacing: -0.005em;
|
|
68
65
|
}
|
|
66
|
+
|
|
67
|
+
:where(.soba-connect) {
|
|
68
|
+
width: 100%;
|
|
69
|
+
max-width: 560px;
|
|
70
|
+
margin: 0 auto;
|
|
71
|
+
}
|
|
69
72
|
.soba-connect *,
|
|
70
73
|
.soba-connect *::before,
|
|
71
74
|
.soba-connect *::after {
|
|
@@ -507,6 +510,28 @@ a.sc-btn {
|
|
|
507
510
|
background: var(--sc-tray-sunk, #f6f6f7);
|
|
508
511
|
}
|
|
509
512
|
|
|
513
|
+
.sc-runtime-logo {
|
|
514
|
+
width: 15px;
|
|
515
|
+
height: 15px;
|
|
516
|
+
border-radius: 3px;
|
|
517
|
+
object-fit: contain;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.sc-runtime-letter {
|
|
521
|
+
font-size: 10px;
|
|
522
|
+
font-weight: 600;
|
|
523
|
+
line-height: 1;
|
|
524
|
+
color: var(--sc-muted, #6b6b73);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.sc-runs-logo {
|
|
528
|
+
flex: none;
|
|
529
|
+
width: 14px;
|
|
530
|
+
height: 14px;
|
|
531
|
+
border-radius: 3px;
|
|
532
|
+
object-fit: contain;
|
|
533
|
+
}
|
|
534
|
+
|
|
510
535
|
.sc-runtime-mark {
|
|
511
536
|
width: 13px;
|
|
512
537
|
height: 13px;
|
|
@@ -672,7 +697,9 @@ a.sc-btn {
|
|
|
672
697
|
background: transparent;
|
|
673
698
|
font-family: inherit;
|
|
674
699
|
cursor: pointer;
|
|
675
|
-
transition:
|
|
700
|
+
transition:
|
|
701
|
+
background-color 120ms ease,
|
|
702
|
+
color 120ms ease;
|
|
676
703
|
}
|
|
677
704
|
|
|
678
705
|
.sc-runs-btn:hover:not(:disabled),
|
|
@@ -728,7 +755,9 @@ a.sc-btn {
|
|
|
728
755
|
border: 1px solid var(--sc-line, #e9e9eb);
|
|
729
756
|
border-radius: 12px;
|
|
730
757
|
background: var(--sc-tray-card, #ffffff);
|
|
731
|
-
box-shadow:
|
|
758
|
+
box-shadow:
|
|
759
|
+
0 10px 30px rgba(0, 0, 0, 0.12),
|
|
760
|
+
0 2px 6px rgba(0, 0, 0, 0.06);
|
|
732
761
|
color: var(--sc-text, #1a1a1c);
|
|
733
762
|
|
|
734
763
|
max-height: 60vh;
|
|
@@ -836,7 +865,9 @@ a.sc-btn {
|
|
|
836
865
|
font-weight: 500;
|
|
837
866
|
color: var(--sc-text-2, #3f3f46);
|
|
838
867
|
cursor: pointer;
|
|
839
|
-
transition:
|
|
868
|
+
transition:
|
|
869
|
+
background-color 120ms ease,
|
|
870
|
+
color 120ms ease;
|
|
840
871
|
}
|
|
841
872
|
|
|
842
873
|
.sc-mp-btn:hover:not(:disabled),
|
|
@@ -1938,8 +1969,9 @@ a.sc-btn {
|
|
|
1938
1969
|
border-radius: var(--sc-r-pill, 999px);
|
|
1939
1970
|
border-color: var(--sc-line, #e9e9eb);
|
|
1940
1971
|
|
|
1941
|
-
|
|
1942
|
-
|
|
1972
|
+
|
|
1973
|
+
box-shadow: var(--sc-shadow-1, 0 1px 2px rgb(0 0 0 / 5%));
|
|
1974
|
+
font-size: var(--sc-fs-small, 12.5px);
|
|
1943
1975
|
font-weight: 500;
|
|
1944
1976
|
|
|
1945
1977
|
letter-spacing: -0.005em;
|
|
@@ -3013,7 +3045,7 @@ li.sc-plan-row.sc-plan-current {
|
|
|
3013
3045
|
.sc-opt-has-warn {
|
|
3014
3046
|
color: var(--sc-warn, #b06f14);
|
|
3015
3047
|
}
|
|
3016
|
-
`,document.head.appendChild(e)}import{jsx as Ie,jsxs as at}from"react/jsx-runtime";function qo(e){if(!e)return null;let n=hn(e);if(n==="payment_required"||n==="no_compute")return null;if(typeof e=="string")return e||null;let t=e,r=t.error?.message;return typeof r=="string"&&r?r:typeof t.message=="string"&&t.message?t.message:"The run ended with an error."}function Ja(){return at("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Ie("path",{d:"M8 5v4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),Ie("circle",{cx:"8",cy:"11.6",r:"0.9",fill:"currentColor"}),Ie("circle",{cx:"8",cy:"8",r:"6.4",stroke:"currentColor",strokeWidth:"1.3"})]})}function Qa({error:e,onRetry:n,onDismiss:t,title:r,className:o}){let s=qo(e),a=H();return Za(()=>st(),[]),s?Ie("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":a.theme,role:"alert",children:at("div",{className:"sc-card sc-limit sc-run-error",children:[at("div",{className:"sc-limit-head",children:[Ie("span",{className:"sc-limit-mark sc-run-error-mark","aria-hidden":"true",children:Ie(Ja,{})}),at("div",{children:[Ie("h2",{className:"sc-limit-title",children:r??"That run did not finish"}),Ie("p",{className:"sc-limit-body sc-run-error-message",children:s})]})]}),(t||n)&&at("div",{className:"sc-limit-actions",children:[t&&Ie("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,children:"Dismiss"}),n&&Ie("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:n,children:"Try again"})]})]})}):null}import{useId as Xa,useState as Fo}from"react";import{jsx as Z,jsxs as Rt}from"react/jsx-runtime";function ei({reason:e}){return Z("span",{className:"sc-limit-mark","aria-hidden":"true",children:e==="no_compute"?Z(ht,{}):Z(j,{})})}function ni(e){let{error:n,variant:t="card",onDismiss:r,className:o}=e,s=Ar(n,{predict:e.predict??!("error"in e)}),a=Xa(),c=H();if(!s)return null;let i=Z(ti,{offer:s,headingId:a,onDismiss:r});return t==="dialog"?Z(jn,{open:!0,onClose:()=>r?.(),labelledBy:a,theme:c.theme,children:i}):Z("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":c.theme,children:i})}function ti({offer:e,headingId:n,onDismiss:t}){let{compute:r}=D(),[o,s]=Fo(!1),[a,c]=Fo(null),i=e.reason==="no_compute"&&r.connected&&!r.online,l=i||e.connectOffer!==null||!r.connected,u=ot();async function p(){s(!0),c(null);try{await e.upgrade()}catch(y){c(y.message)}finally{s(!1)}}return Rt("div",{className:"sc-card sc-limit",children:[Rt("div",{className:"sc-limit-head",children:[Z(ei,{reason:e.reason}),Rt("div",{children:[Z("h2",{className:"sc-limit-title",id:n,children:e.title}),Z("p",{className:"sc-limit-body",children:e.body})]})]}),a&&Z("p",{className:"sc-error",children:a}),i&&u.note&&Z("p",{className:"sc-limit-note",children:u.note}),Rt("div",{className:"sc-limit-actions",children:[t&&Z("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,disabled:o,children:"Not now"}),e.upgradeTo&&Z("button",{type:"button",className:l?"sc-btn":"sc-btn sc-btn-primary",onClick:()=>void p(),disabled:o,children:o?"Opening\u2026":e.upgradeTo.selectable?`Switch to ${e.upgradeTo.name}`:`${e.upgradeTo.name} for $${e.upgradeTo.price.toLocaleString()}/${e.upgradeTo.interval}`}),l&&Z("button",{type:"button",className:i?"sc-btn":"sc-btn sc-btn-primary",onClick:e.connect,disabled:o,children:i?"Connect another machine":"Connect compute"}),i&&Z("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:u.open,disabled:o,children:"Open Soba App"})]})]})}import{useMemo as ri}from"react";function it(){let{plan:e,compute:n,connect:t}=D();return ri(()=>{let r=e.plan,o=e.current,s={plan:r,assignment:o,loading:e.loading,error:e.error,periodEnd:o?.period_end?new Date(o.period_end):null};if(!r)return{...s,state:"none",trialDaysLeft:null,ceiling:null,raised:!1,uncounted:!1,used:0,remaining:null,percent:null,unlimited:!1,reward:null,summary:"Nothing is assigned to this account, so runs are bounded by whatever the app allows."};let a=ai(o?.trial_ends_at??null),c=r.connected_reward==="included"&&n.connected&&r.connected_included_units!==null,i=c?r.connected_included_units:r.included_units,l=r.connected_reward==="unlimited"&&n.connected,u=i===null,p=e.used??0,y=i===null?null:Math.max(0,i-p),f=i&&i>0?Math.min(100,Math.round(p/i*100)):null,m=i!==null&&p>=i,w=a!==null?"trial":u?"unlimited":m?r.overage==="meter"?"metered":"spent":"within";return{...s,state:w,trialDaysLeft:a,ceiling:i,raised:c,uncounted:l,used:p,remaining:y,percent:f,unlimited:u,reward:oi(r,c||l,n.connected,()=>t.open("manual")),summary:si({plan:r,assignment:o,used:p,ceiling:i,trialDaysLeft:a,raised:c,uncounted:l,state:w})}},[e,n.connected,t])}function oi(e,n,t,r){let o=Ue({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6});return o?{line:o,inForce:n,required:!1,connected:t,actionable:He(e.connected_reward)&&!t,open:r}:Se(e.route_allow)&&!t?{line:"Nothing connected yet, so nothing can run.",inForce:!1,required:!0,connected:t,actionable:!0,open:r}:null}function si(e){let{plan:n,assignment:t,used:r,ceiling:o,trialDaysLeft:s,raised:a,uncounted:c,state:i}=e,l=`${n.unit}${r===1?"":"s"}`,u=c?" Runs your own AI serves do not count toward it.":"";if(i==="trial"&&s!==null){let f=n.price===0?"it continues free":`it is $${n.price.toLocaleString()} a ${n.interval}`;return`${s} ${s===1?"day":"days"} left of your trial, then ${f}.`}if(i==="unlimited")return`${r.toLocaleString()} ${l} this period. No ceiling on this plan.`;if(i==="metered"){let f=r-(o??0);return n.overage_per_unit>0?`${f.toLocaleString()} past the allowance, billed at $${n.overage_per_unit} a ${n.unit}.${u}`:`${f.toLocaleString()} past the allowance.${u}`}if(i==="spent")return t?.period_end?`Allowance spent. It comes back on ${Go(t.period_end)}.${u}`:`Allowance spent. It comes back at the start of the next period.${u}`;let p=Math.max(0,(o??0)-r),y=a?` Raised from ${(n.included_units??0).toLocaleString()} while your own AI is connected.`:t?.period_end?` Resets ${Go(t.period_end)}.`:"";return`${p.toLocaleString()} of ${(o??0).toLocaleString()} ${n.unit}s left.${y}${u}`}function ai(e){if(!e)return null;let n=new Date(e).getTime()-Date.now();return Number.isNaN(n)||n<=0?null:Math.max(1,Math.ceil(n/864e5))}function Go(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}import{Fragment as li,jsx as J,jsxs as Me}from"react/jsx-runtime";function qr({heading:e="Current plan",showUsage:n=!0,showName:t=!0,className:r}){let o=it(),{theme:s}=H(),a=y=>J("section",{className:r?`soba-connect sc-fill ${r}`:"soba-connect sc-fill","data-theme":s,children:Me("div",{className:"sc-card sc-current",children:[e&&J("h2",{className:"sc-section-title",children:e}),y]})});if(o.error)return a(J("p",{className:"sc-error",children:o.error.message}));if(o.loading)return a(J("p",{className:"sc-note",children:"Loading\u2026"}));if(!o.plan)return a(Me("div",{className:"sc-current-main",children:[J("p",{className:"sc-current-name",children:"No plan"}),J("p",{className:"sc-sub",children:o.summary})]}));let{plan:c,trialDaysLeft:i,percent:l,unlimited:u,reward:p}=o;return a(Me(li,{children:[Me("div",{className:"sc-current-grid",children:[(t||i!==null)&&Me("div",{className:"sc-current-main",children:[t?Me("p",{className:"sc-current-name",children:[c.name,i!==null&&Me("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})]}):i!==null&&J("p",{className:"sc-current-trial",children:Me("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})}),t&&c.description&&J("p",{className:"sc-sub",children:c.description})]}),n&&Me("div",{className:"sc-usage",children:[Me("div",{className:"sc-row-between",children:[J("span",{className:"sc-fact-key",children:"Usage"}),J("span",{className:l!==null&&l>=100?"sc-usage-figure sc-usage-over":"sc-usage-figure",children:u?"Unlimited":l===null?"Metered":`${l}% used`})]}),l!==null&&J("div",{className:"sc-meter",role:"presentation",children:l>0&&J("span",{className:l>=100?"sc-meter-fill sc-meter-full":"sc-meter-fill",style:{width:`${l}%`}})}),J("p",{className:"sc-usage-line",children:o.summary})]})]}),p&&Me("div",{className:"sc-current-foot",children:[J("p",{className:p.required?"sc-plan-reward-line sc-plan-reward-need":p.inForce?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-open",children:p.required?p.line:p.inForce?`In force: ${ii(p.line)}.`:p.line}),(p.actionable||p.connected)&&J(fn,{})]})]}))}var ii=e=>e.charAt(0).toLowerCase()+e.slice(1);import{useCallback as ci,useMemo as ui,useState as zo}from"react";var di={"user-hardware":"your own machine","user-subscription":"your own AI subscription","open-weights":"open models we host",frontier:"frontier models"},pi=new Set(["user-hardware","user-subscription"]);function Fr(e={}){let{plan:n,compute:t,connect:r}=D(),[o,s]=zo(null),[a,c]=zo(null),{featured:i,onSelect:l,successUrl:u,cancelUrl:p}=e,y=ci(async m=>{s(m.id),c(null);try{if(m.selectable)await n.select(m.id);else if(l)l(m);else{let w=await n.checkout(m.id,{...u?{successUrl:u}:{},...p?{cancelUrl:p}:{}});window.location.assign(w);return}}catch(w){throw c(w.message),w}finally{(m.selectable||l)&&s(null)}},[n,l,u,p]),f=ui(()=>n.plans.map(m=>{let w=n.current?.plan_id===m.id;return{plan:m,current:w,featured:i===m.id&&!w,price:mi(m),allowance:m.included_units===null?`Unlimited ${m.unit}s`:`${m.included_units.toLocaleString()} ${m.unit}${m.included_units===1?"":"s"}`,allowanceNote:fi(m),computeLabel:m.route_allow===null?"any compute":m.route_allow.length===0?"no compute":null,compute:(m.route_allow??[]).map(M=>({costClass:M,label:di[M]??M,owned:pi.has(M),runtimes:Bt(M).map(R=>R.id)})),connect:hi(m,w,t.connected,()=>r.open("manual")),cta:{label:gi(m,w,o===m.id),disabled:w||o!==null,busy:o===m.id,take:()=>y(m)}}}),[n.plans,n.current,i,t.connected,r,o,y]);return{offers:f,current:f.find(m=>m.current)??null,loading:n.loading,error:n.error,failed:a}}function mi(e){return e.price===0?{amount:"Free",interval:null,free:!0}:{amount:`$${e.price.toLocaleString()}`,interval:e.interval,free:!1}}function fi(e){let n=[];return e.included_units===null?n.push("No ceiling on this plan"):(n.push(`Included each ${e.interval}`),e.overage==="meter"&&e.overage_per_unit>0?n.push(`then $${e.overage_per_unit} a ${e.unit}`):e.included_units>0&&n.push(`then ${e.unit}s stop`)),e.trial_days>0&&n.push(`${e.trial_days}-day trial`),n.join(" \xB7 ")}function hi(e,n,t,r){let o=Ue({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6}),s=Se(e.route_allow)&&!t;if(!o&&!s)return null;let a=He(e.connected_reward);return{key:o?"Connect your own":"To use this",line:o??(n?"Nothing connected yet, so nothing can run.":"Runs only on compute you connect."),reward:o!==null,actionable:n&&(a||s)&&!t,open:r}}function gi(e,n,t){return n?"Your plan":t?e.selectable?"Switching\u2026":"Opening\u2026":e.selectable?"Choose":`Subscribe for $${e.price.toLocaleString()}/${e.interval}`}import{jsx as b,jsxs as A}from"react/jsx-runtime";function _t(e){return e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill"}function Gr({onSelect:e,successUrl:n,cancelUrl:t,showCompute:r=!0,showConnect:o=!1,variant:s="cards",featured:a,className:c}){let{offers:i,loading:l,error:u,failed:p}=Fr({...a?{featured:a}:{},...e?{onSelect:e}:{},...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),{theme:y}=H();if(u)return b("div",{className:_t(c),"data-theme":y,children:b("div",{className:"sc-card",children:b("p",{className:"sc-error",children:u.message})})});if(l)return b("div",{className:_t(c),"data-theme":y,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"Loading plans\u2026"})})});if(i.length===0)return b("div",{className:_t(c),"data-theme":y,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"This app has no plans yet."})})});let f={showCompute:r,showConnect:o};return A("div",{className:_t(c),"data-theme":y,"data-variant":s,children:[s==="rows"?b(yi,{offers:i,shelf:f}):s==="table"?b(wi,{offers:i,shelf:f}):b(bi,{offers:i,shelf:f}),p&&b("p",{className:"sc-error",children:p})]})}function bi({offers:e,shelf:n}){return b("div",{className:"sc-plans",children:e.map(t=>A("div",{className:Vo("sc-plan",t),children:[A("div",{className:"sc-row-between",children:[b("span",{className:"sc-title",children:t.plan.name}),b(zr,{offer:t})]}),b("p",{className:"sc-sub",children:t.plan.description}),b(Vr,{price:t.price,free:"forever"}),b(Yr,{offer:t,shelf:n}),b(Ko,{offer:t}),b("div",{className:"sc-plan-band",children:n.showCompute&&b(jr,{offer:t})}),b("div",{className:"sc-plan-band",children:b(Kr,{offer:t})})]},t.plan.id))})}function yi({offers:e,shelf:n}){return b("ul",{className:"sc-plan-rows",children:e.map(t=>A("li",{className:Vo("sc-plan-row",t),children:[A("div",{className:"sc-row-main",children:[A("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:t.plan.name}),b(zr,{offer:t})]}),t.plan.description&&b("p",{className:"sc-sub",children:t.plan.description}),b(Ko,{offer:t}),n.showCompute&&b(jr,{offer:t,inline:!0}),b(Kr,{offer:t,inline:!0})]}),A("div",{className:"sc-row-side",children:[b(Vr,{price:t.price,free:"forever",small:!0}),b(Yr,{offer:t,shelf:n})]})]},t.plan.id))})}function wi({offers:e,shelf:n}){let t=e.some(a=>a.plan.overage_per_unit>0),r=e.some(a=>a.plan.trial_days>0),o=e.some(a=>a.connect!==null),s=a=>[a.current?"sc-col-current":"",a.featured?"sc-col-featured":""].filter(Boolean).join(" ")||void 0;return b("div",{className:"sc-table-scroll",children:A("table",{className:"sc-plan-table",children:[b("thead",{children:A("tr",{children:[b("td",{}),e.map(a=>A("th",{scope:"col",className:s(a),children:[A("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:a.plan.name}),b(zr,{offer:a})]}),b(Vr,{price:a.price,small:!0})]},a.plan.id))]})}),A("tbody",{children:[A("tr",{children:[b("th",{scope:"row",children:"Included"}),e.map(a=>b("td",{className:s(a),children:a.allowance},a.plan.id))]}),t&&A("tr",{children:[b("th",{scope:"row",children:"Then"}),e.map(a=>b("td",{className:s(a),children:a.plan.overage_per_unit>0?`$${a.plan.overage_per_unit} / ${a.plan.unit}`:b("span",{className:"sc-muted-cell",children:"Stops"})},a.plan.id))]}),r&&A("tr",{children:[b("th",{scope:"row",children:"Trial"}),e.map(a=>b("td",{className:s(a),children:a.plan.trial_days>0?`${a.plan.trial_days} days`:b("span",{className:"sc-muted-cell",children:"None"})},a.plan.id))]}),n.showCompute&&A("tr",{children:[b("th",{scope:"row",children:"Runs on"}),e.map(a=>b("td",{className:s(a),children:b(jr,{offer:a,bare:!0})},a.plan.id))]}),o&&A("tr",{children:[b("th",{scope:"row",children:"Connect your own"}),e.map(a=>b("td",{className:s(a),children:b(Kr,{offer:a,bare:!0})},a.plan.id))]}),A("tr",{className:"sc-table-buy",children:[b("td",{}),e.map(a=>b("td",{className:s(a),children:b(Yr,{offer:a,shelf:n})},a.plan.id))]})]})]})})}function Vo(e,n){return[e,n.current?"sc-plan-current":"",n.featured?"sc-plan-featured":""].filter(Boolean).join(" ")}function zr({offer:e}){return e.current?b("span",{className:"sc-plan-badge",children:"Current"}):e.featured?b("span",{className:"sc-plan-badge-soft",children:"Recommended"}):null}function Vr({price:e,small:n,free:t}){return A("p",{className:n?"sc-plan-price sc-plan-price-sm":"sc-plan-price",children:[b("span",{className:"sc-plan-amount",children:e.amount}),e.interval?A("span",{className:"sc-plan-interval",children:["/",e.interval]}):t&&b("span",{className:"sc-plan-interval sc-plan-after",children:t})]})}function Ko({offer:e}){return A("p",{className:"sc-plan-allowance",children:[b("span",{className:"sc-plan-figure",children:e.allowance}),b("span",{className:"sc-plan-qualifier",children:e.allowanceNote})]})}function Kr({offer:e,inline:n,bare:t}){let r=e.connect;if(!r)return t?b("span",{className:"sc-muted-cell",children:"None"}):null;let o=r.reward?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-need",s=r.actionable?A("button",{type:"button",className:`${o} sc-plan-reward-act`,"aria-label":"Connect compute",onClick:r.open,children:[b("span",{className:"sc-reward-said",children:r.line}),A("span",{className:"sc-reward-do","aria-hidden":!0,children:[b(j,{className:"sc-reward-mark"}),"Connect compute"]})]}):b("p",{className:o,children:r.line});return t?s:b("div",{className:n?"sc-plan-reward sc-plan-reward-inline":"sc-plan-reward",children:s})}function jr({offer:e,inline:n,bare:t}){let r=e.computeLabel?b("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:b("li",{children:e.computeLabel})}):b("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:e.compute.map(o=>A("li",{className:o.owned?"sc-compute-own":void 0,children:[o.label,b(vi,{runtimes:o.runtimes})]},o.costClass))});return t?r:A("div",{className:n?"sc-plan-compute sc-plan-compute-inline":"sc-plan-compute",children:[b("span",{className:"sc-fact-key",children:"Runs on"}),r]})}function Yr({offer:e,shelf:n}){let t=e.connect;return n.showConnect&&t?.actionable?A("button",{type:"button",className:"sc-btn sc-btn-primary sc-btn-icon",onClick:t.open,children:[b(j,{className:"sc-btn-mark"}),"Connect compute"]}):b("button",{type:"button",className:e.current?"sc-btn":"sc-btn sc-btn-primary",disabled:e.cta.disabled,onClick:()=>void e.cta.take().catch(()=>{}),children:e.cta.label})}function vi({runtimes:e}){return e.length===0?null:b("span",{className:"sc-compute-marks",children:e.map(n=>{let t=ze[n];return t?b(t,{className:"sc-rt-mark"},n):null})})}import{jsx as Zr,jsxs as jo}from"react/jsx-runtime";function ki({heading:e,plansHeading:n,showUsage:t=!0,showName:r=!0,className:o,...s}){let{plan:a,loading:c}=it(),{theme:i}=H(),l=n??(c?"Plans":a?"Change plan":"Choose a plan");return jo("div",{className:o?`soba-connect sc-fill sc-billing ${o}`:"soba-connect sc-fill sc-billing","data-theme":i,children:[Zr(qr,{...e===void 0?{}:{heading:e},showUsage:t,showName:r}),jo("section",{className:"sc-billing-plans",children:[l&&Zr("h2",{className:"sc-section-title",children:l}),Zr(Gr,{...s})]})]})}import{useCallback as Yo,useState as Zo}from"react";function Jr({plan:e,successUrl:n,cancelUrl:t,label:r}){let{plan:o}=D(),[s,a]=Zo(!1),[c,i]=Zo(null),l=Yo(()=>o.checkout(e.id,{...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),[o,e.id,n,t]),u=Yo(async()=>{a(!0),i(null);try{window.location.assign(await l())}catch(p){i(p.message),a(!1)}},[l]);return{label:s?"Opening\u2026":r??`Subscribe for $${e.price.toLocaleString()}/${e.interval}`,busy:s,error:c,buy:u,session:l}}import{jsx as Jo,jsxs as Ni}from"react/jsx-runtime";function Ci({plan:e,successUrl:n,cancelUrl:t,label:r,className:o}){let{theme:s}=H(),a=Jr({plan:e,...n?{successUrl:n}:{},...t?{cancelUrl:t}:{},...r?{label:r}:{}});return Ni("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":s,children:[Jo("button",{type:"button",className:"sc-btn sc-btn-primary",disabled:a.busy,onClick:()=>void a.buy(),children:a.label}),a.error&&Jo("p",{className:"sc-error",children:a.error})]})}import{useCallback as Te,useEffect as Ze,useMemo as In,useRef as Je,useState as Q}from"react";var xi="soba.session:";function Qo(e){return!e.cacheKey||!e.endpoint?null:xi+JSON.stringify([e.endpoint,e.user??null,e.cacheKey])}function Si(e){try{let n=globalThis.localStorage?.getItem(e);if(!n)return null;let t=JSON.parse(n);return typeof t.token!="string"||typeof t.expiresAt!="number"?null:{token:t.token,expiresAt:t.expiresAt}}catch{return null}}function Mi(e,n){try{n?globalThis.localStorage?.setItem(e,JSON.stringify(n)):globalThis.localStorage?.removeItem(e)}catch{}}var Xo=6e4,Pi=1e4,Et=class{#e;#n=null;#r=null;#t;#o=new Set;constructor(n){this.#t=n,this.#e=n.token??null;let t=Qo(n),r=t&&!this.#e?Si(t):null;r&&r.expiresAt-Xo>Date.now()&&(this.#e=r.token,this.#n=r.expiresAt)}get token(){return this.#e}get expiresAt(){return this.#n}get canRefresh(){return!!this.#t.endpoint}get refreshAt(){return!this.canRefresh||this.#n===null?null:Math.max(Date.now()+Pi,this.#n-Xo)}subscribe(n){return this.#o.add(n),()=>this.#o.delete(n)}async ensure(){return this.#e?this.#e:this.refresh()}async refresh(){if(this.#r)return this.#r;let n=this.#t.endpoint;if(!n)throw new Error("This Soba session cannot be refreshed. Pass `sessionEndpoint` so the provider can mint a new one.");let t=this.#t.fetchImpl??fetch.bind(globalThis);this.#r=(async()=>{let r=await t(n,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(this.#t.user?{user:this.#t.user}:{})});if(!r.ok)throw new Error(`Could not start a Soba session (${r.status} from ${n}).`);let o=await r.json(),s=o.session??o.token;if(!s)throw new Error(`${n} answered without a \`session\`. See @soba-so/react's README.`);let a=o.expires_in??o.expiresIn;this.#e=s,this.#n=typeof a=="number"?Date.now()+a*1e3:null;let c=Qo(this.#t);c&&Mi(c,this.#n===null?null:{token:s,expiresAt:this.#n});for(let i of this.#o)i();return s})();try{return await this.#r}finally{this.#r=null}}},On=new Map,es=new WeakMap,Ri=1;function _i(e){if(e.token||!e.endpoint)return null;let n=0;return e.fetchImpl&&(n=es.get(e.fetchImpl)??Ri++,es.set(e.fetchImpl,n)),JSON.stringify([e.endpoint,e.user??null,n,e.cacheKey??null])}function ns(e){let n=_i(e);if(!n)return new Et(e);let t=On.get(n)??{holder:new Et(e),users:0};return On.set(n,t),t.holder}function ts(e){for(let n of On.values())n.holder===e&&n.users++}function rs(e){for(let[n,t]of On)if(t.holder===e){setTimeout(()=>{--t.users<=0&&On.get(n)===t&&On.delete(n)},0);return}}function os(e,n=fetch.bind(globalThis)){return async(t,r)=>{let o=await n(t,r);if(o.status!==401||!e.canRefresh)return o;let s;try{s=await e.refresh()}catch{return o}return n(t,Ei(r,s))}}function Ei(e,n){let t=new Headers(e?.headers);return t.set("authorization",`Bearer ${n}`),{...e,headers:t}}import{jsx as Qr,jsxs as Li}from"react/jsx-runtime";var Oi="https://www.soba.so",Ii=3e4;function Ti(e){let{children:n,session:t,sessionEndpoint:r,user:o,sessionCacheKey:s,runEndpoint:a,theme:c,initialMachines:i,initialConnect:l=null,initialPlans:u,initialCurrentPlan:p=null,baseUrl:y=Oi,pollMs:f=Ii,injectStyles:m=!0,modal:w=!0,fetchImpl:M,onError:R}=e,[_,U]=Q(t??null),[P,T]=Q(null),[E,S]=Q(l),[W,ve]=Q(null),[X,ke]=Q(l===null),[V,oe]=Q(i??[]),[We,Y]=Q(null),[Pe,Qe]=Q(i===void 0),[ce,ue]=Q(u??[]),[ee,gn]=Q(p),[Xe,Le]=Q(null),[en,de]=Q(u===void 0),[ne,Be]=Q(null),[pe,Ae]=Q(!1),qe=Je(R);qe.current=R;let se=Te(k=>{T(k),qe.current?.(k)},[]);Ze(()=>{m&&st()},[m]);let O=In(()=>ns({...t?{token:t}:{},...r?{endpoint:r}:{},...o?{user:o}:{},...M?{fetchImpl:M}:{},...s?{cacheKey:s}:{}}),[t,r,o,M,s]);Ze(()=>{let k=!0;ts(O);let z=O.subscribe(()=>{k&&U(O.token)});return!O.token&&!O.canRefresh?se(new Error("<SobaProvider> needs a `session` or a `sessionEndpoint`. A browser cannot mint one: that takes your secret key.")):O.ensure().then(()=>k&&U(O.token),ae=>k&&se(ae)),()=>{k=!1,z(),rs(O)}},[O,se]),Ze(()=>{P&&(ke(!1),Qe(!1),de(!1),ve(k=>k??P),Y(k=>k??P),Le(k=>k??P))},[P]),Ze(()=>{let k=O.refreshAt;if(k===null)return;let z=()=>{O.refresh().catch(ge=>se(ge))},ae=()=>{document.hidden||(document.removeEventListener("visibilitychange",ae),z())},pt=setTimeout(()=>{typeof document<"u"&&document.hidden?document.addEventListener("visibilitychange",ae):z()},Math.max(0,k-Date.now()));return()=>{clearTimeout(pt),typeof document<"u"&&document.removeEventListener("visibilitychange",ae)}},[O,se,_]);let bn=Je(l?.machines_url??null),v=In(()=>{if(!_)return null;let k=new Ln({session:_,baseUrl:y,fetchImpl:os(O,M??fetch.bind(globalThis))});return k.setMachinesUrl(bn.current),k},[_,y,O,M]),F=Je(l!==null);Ze(()=>{if(!v||F.current)return;let k=!0;return ke(!0),v.context().then(z=>{k&&(S(z),ve(null),ke(!1))},z=>{k&&(ve(z),ke(!1))}),()=>{k=!1}},[v]);let me=Te(async()=>{if(v)try{let k=await v.machines();oe(Array.isArray(k)?k:[]),Y(null)}catch(k){Y(k)}finally{Qe(!1)}},[v]),fe=Te(async()=>{if(v)try{let k=await v.plans();ue(k.plans),gn(k.current),Le(null)}catch(k){Le(k)}finally{de(!1)}},[v]),te=Je(!1),[Fe,yn]=Q(!1),wn=Je(u!==void 0),nn=Je(!1),tn=Te(()=>{te.current||(te.current=!0,nn.current&&queueMicrotask(()=>{nn.current&&yn(!0)}))},[]);Ze(()=>(nn.current=!0,te.current&&yn(!0),()=>{nn.current=!1}),[]),Ze(()=>{!v||!Fe||wn.current||fe()},[v,Fe,fe]);let rn=Te(async k=>{if(!v)throw new Error("No session yet.");await v.selectPlan(k),await fe()},[v,fe]),Ot=Te(async(k,z)=>{if(!v)throw new Error("No session yet.");let ae=await v.checkoutPlan(k,z);if(!ae.url)throw new Error("Checkout could not be started.");return ae.url},[v]),lt=Te(async()=>{if(!v)throw new Error("No session yet.");await v.leavePlan(),await fe()},[v,fe]),ct=Je(i!==void 0);Ze(()=>{if(!v)return;let k=Oe(me,f,{immediate:!ct.current});return ct.current=!1,k},[v,me,f]);let vn=Te((k="manual")=>{w&&(Ae(!0),Be(k))},[w]),ut=Te(()=>Be(null),[]),G=Je(V);G.current=V;let Re=Te(async k=>{if(!a)throw new Error("Pass `runEndpoint` to <SobaProvider> to start runs from the browser. It is your own route: it holds your secret key, calls soba.run(), and forwards the stream.");let{signal:z,...ae}=k,ge=await(M??fetch.bind(globalThis))(a,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream"},credentials:"same-origin",body:JSON.stringify(ae),...z?{signal:z}:{}});if(!ge.ok){let $e=await ge.json().catch(()=>null),be=new Error($e?.error?.message??`${a} answered ${ge.status}.`);be.status=ge.status,$e?.error?.code&&(be.code=$e.error.code),$e?.error&&(be.error=$e.error);let mt=G.current.length>0&&!G.current.some(Tt=>Tt.state!=="offline");throw ge.status===409&&mt&&vn("no_compute"),be}let Ce=Ur(ge);return async function*(){try{yield*Ce}finally{te.current&&fe()}}()},[a,M,fe,vn]),he=In(()=>ee?ce.find(k=>k.id===ee.plan_id)??null:null,[ce,ee]),on=In(()=>he?he.connected_reward==="included"&&V.length>0&&he.connected_included_units!==null?he.connected_included_units:he.included_units:null,[he,V]),dt=In(()=>({plans:ce,current:ee,plan:he,used:ee?.units_used??null,included:on,remaining:on!==null&&ee?Math.max(0,on-ee.units_used):null,unlimited:he!==null&&on===null,loading:en,error:Xe,select:rn,checkout:Ot,leave:lt,refresh:fe}),[ce,ee,he,on,en,Xe,rn,Ot,lt,fe]),It=In(()=>({session:_,client:v,error:P,get plan(){return tn(),dt},compute:{machines:V,connected:V.length>0,online:V.some(k=>k.state!=="offline"),loading:Pe,error:We,refresh:me},connect:{app:E?.app??null,command:E?.command??null,connectUrl:E?.connect_url??null,publishableKey:E?.publishable_key??null,loading:X,error:W,open:vn,close:ut,isOpen:ne!==null,hasModal:w},run:Re}),[_,v,P,dt,tn,ne,vn,ut,w,V,Pe,We,me,E,X,W,Re]);return Qr(Mr.Provider,{value:v,children:Qr(Pr.Provider,{value:{context:E,machines:Pe?void 0:V,theme:c??E?.theme??"light"},children:Li(Rr.Provider,{value:It,children:[n,w&&pe&&Qr(nt,{open:ne!==null,onOpenChange:k=>Be(k?ne??"manual":null),onConnected:()=>{me()},...ne==="payment_required"||ne==="no_compute"?{reason:ne}:{},...ne==="pair"?{showStatus:!1}:{}})]})})})}function Ai(e){return e?$i[e]??e:null}var $i={"user-hardware":"your own computer","user-subscription":"your own AI plan","user-api-key":"your own API key","open-weights":"open models we host",frontier:"a frontier model we pay for"};async function Di(e,n,t){let r=n.local;if(!r?.session||n.after)return null;let o=/\/v1\/runs\/([^/]+)\/events/.exec(e.url)?.[1];if(!o)return null;let s=`http://127.0.0.1:${r.port??47321}/v1/runs/${o}/events`,a=new AbortController,c=()=>a.abort();n.signal?.addEventListener("abort",c);let i=setTimeout(()=>a.abort(),r.timeoutMs??3e3);try{let l=await t(s,{headers:{authorization:`Bearer ${r.session}`,accept:"text/event-stream"},signal:a.signal});return l.ok?{url:s,bearer:r.session,open:l}:null}catch{return null}finally{clearTimeout(i),n.signal?.removeEventListener("abort",c)}}async function*Ui(e){let n=e.body;if(!n)return;let t=n.getReader(),r=new TextDecoder,o="",s=null,a=[];try{for(;;){let c=await t.read();if(c.done)return;o+=r.decode(c.value,{stream:!0});for(let i=o.indexOf(`
|
|
3048
|
+
`,document.head.appendChild(e)}import{jsx as Oe,jsxs as st}from"react/jsx-runtime";function Ko(e){if(!e)return null;let n=pn(e);if(n==="payment_required"||n==="no_compute")return null;if(typeof e=="string")return e||null;let t=e,r=t.error?.message;return typeof r=="string"&&r?r:typeof t.message=="string"&&t.message?t.message:"The run ended with an error."}function ui(){return st("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Oe("path",{d:"M8 5v4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),Oe("circle",{cx:"8",cy:"11.6",r:"0.9",fill:"currentColor"}),Oe("circle",{cx:"8",cy:"8",r:"6.4",stroke:"currentColor",strokeWidth:"1.3"})]})}function di({error:e,onRetry:n,onDismiss:t,title:r,className:o}){let s=Ko(e),a=B();return ci(()=>ot(),[]),s?Oe("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":a.theme,role:"alert",children:st("div",{className:"sc-card sc-limit sc-run-error",children:[st("div",{className:"sc-limit-head",children:[Oe("span",{className:"sc-limit-mark sc-run-error-mark","aria-hidden":"true",children:Oe(ui,{})}),st("div",{children:[Oe("h2",{className:"sc-limit-title",children:r??"That run did not finish"}),Oe("p",{className:"sc-limit-body sc-run-error-message",children:s})]})]}),(t||n)&&st("div",{className:"sc-limit-actions",children:[t&&Oe("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,children:"Dismiss"}),n&&Oe("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:n,children:"Try again"})]})]})}):null}import{useId as pi,useState as _o}from"react";import{jsx as $,jsxs as Rt}from"react/jsx-runtime";function mi({reason:e}){return $("span",{className:"sc-limit-mark","aria-hidden":"true",children:e==="no_compute"?$(ht,{}):$(X,{})})}function hi(e){let{error:n,variant:t="card",onDismiss:r,className:o}=e,s=Qr(n,{predict:e.predict??!("error"in e)}),a=pi(),l=B();if(!s)return null;let i=$(gi,{offer:s,headingId:a,onDismiss:r});return t==="dialog"?$(qn,{open:!0,onClose:()=>r?.(),labelledBy:a,theme:l.theme,children:i}):$("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":l.theme,children:i})}function gi({offer:e,headingId:n,onDismiss:t}){let{compute:r}=D(),[o,s]=_o(!1),[a,l]=_o(null),i=e.reason==="no_compute"&&r.connected&&!r.online,c=i||e.connectOffer!==null||!r.connected,u=rt();async function p(){s(!0),l(null);try{await e.upgrade()}catch(f){l(f.message)}finally{s(!1)}}return Rt("div",{className:"sc-card sc-limit",children:[Rt("div",{className:"sc-limit-head",children:[$(mi,{reason:e.reason}),Rt("div",{children:[$("h2",{className:"sc-limit-title",id:n,children:e.title}),$("p",{className:"sc-limit-body",children:e.body})]})]}),a&&$("p",{className:"sc-error",children:a}),i&&u.note&&$("p",{className:"sc-limit-note",children:u.note}),Rt("div",{className:"sc-limit-actions",children:[t&&$("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,disabled:o,children:"Not now"}),e.upgradeTo&&$("button",{type:"button",className:c?"sc-btn":"sc-btn sc-btn-primary",onClick:()=>void p(),disabled:o,children:o?"Opening\u2026":e.upgradeTo.selectable?`Switch to ${e.upgradeTo.name}`:`${e.upgradeTo.name} for $${e.upgradeTo.price.toLocaleString()}/${e.upgradeTo.interval}`}),c&&$("button",{type:"button",className:i?"sc-btn":"sc-btn sc-btn-primary",onClick:e.connect,disabled:o,children:i?"Connect another machine":"Connect compute"}),i&&$("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:u.open,disabled:o,children:"Open Soba App"})]})]})}import{useMemo as fi}from"react";function at(){let{plan:e,compute:n,connect:t}=D();return fi(()=>{let r=e.plan,o=e.current,s={plan:r,assignment:o,loading:e.loading,error:e.error,periodEnd:o?.period_end?new Date(o.period_end):null};if(!r)return{...s,state:"none",trialDaysLeft:null,ceiling:null,raised:!1,uncounted:!1,used:0,remaining:null,percent:null,unlimited:!1,reward:null,summary:"Nothing is assigned to this account, so runs are bounded by whatever the app allows."};let a=yi(o?.trial_ends_at??null),l=r.connected_reward==="included"&&n.connected&&r.connected_included_units!==null,i=l?r.connected_included_units:r.included_units,c=r.connected_reward==="unlimited"&&n.connected,u=i===null,p=e.used??0,f=i===null?null:Math.max(0,i-p),g=i&&i>0?Math.min(100,Math.round(p/i*100)):null,m=i!==null&&p>=i,y=a!==null?"trial":u?"unlimited":m?r.overage==="meter"?"metered":"spent":"within";return{...s,state:y,trialDaysLeft:a,ceiling:i,raised:l,uncounted:c,used:p,remaining:f,percent:g,unlimited:u,reward:Ai(r,l||c,n.connected,()=>t.open("manual")),summary:bi({plan:r,assignment:o,used:p,ceiling:i,trialDaysLeft:a,raised:l,uncounted:c,state:y})}},[e,n.connected,t])}function Ai(e,n,t,r){let o=We({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6});return o?{line:o,inForce:n,required:!1,connected:t,actionable:He(e.connected_reward)&&!t,open:r}:xe(e.route_allow)&&!t?{line:"Nothing connected yet, so nothing can run.",inForce:!1,required:!0,connected:t,actionable:!0,open:r}:null}function bi(e){let{plan:n,assignment:t,used:r,ceiling:o,trialDaysLeft:s,raised:a,uncounted:l,state:i}=e,c=`${n.unit}${r===1?"":"s"}`,u=l?" Runs your own AI serves do not count toward it.":"";if(i==="trial"&&s!==null){let g=n.price===0?"it continues free":`it is $${n.price.toLocaleString()} a ${n.interval}`;return`${s} ${s===1?"day":"days"} left of your trial, then ${g}.`}if(i==="unlimited")return`${r.toLocaleString()} ${c} this period. No ceiling on this plan.`;if(i==="metered"){let g=r-(o??0);return n.overage_per_unit>0?`${g.toLocaleString()} past the allowance, billed at $${n.overage_per_unit} a ${n.unit}.${u}`:`${g.toLocaleString()} past the allowance.${u}`}if(i==="spent")return t?.period_end?`Allowance spent. It comes back on ${$o(t.period_end)}.${u}`:`Allowance spent. It comes back at the start of the next period.${u}`;let p=Math.max(0,(o??0)-r),f=a?` Raised from ${(n.included_units??0).toLocaleString()} while your own AI is connected.`:t?.period_end?` Resets ${$o(t.period_end)}.`:"";return`${p.toLocaleString()} of ${(o??0).toLocaleString()} ${n.unit}s left.${f}${u}`}function yi(e){if(!e)return null;let n=new Date(e).getTime()-Date.now();return Number.isNaN(n)||n<=0?null:Math.max(1,Math.ceil(n/864e5))}function $o(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}import{Fragment as Ci,jsx as ee,jsxs as Re}from"react/jsx-runtime";function Zr({heading:e="Current plan",showUsage:n=!0,showName:t=!0,className:r}){let o=at(),{theme:s}=B(),a=f=>ee("section",{className:r?`soba-connect sc-fill ${r}`:"soba-connect sc-fill","data-theme":s,children:Re("div",{className:"sc-card sc-current",children:[e&&ee("h2",{className:"sc-section-title",children:e}),f]})});if(o.error)return a(ee("p",{className:"sc-error",children:o.error.message}));if(o.loading)return a(ee("p",{className:"sc-note",children:"Loading\u2026"}));if(!o.plan)return a(Re("div",{className:"sc-current-main",children:[ee("p",{className:"sc-current-name",children:"No plan"}),ee("p",{className:"sc-sub",children:o.summary})]}));let{plan:l,trialDaysLeft:i,percent:c,unlimited:u,reward:p}=o;return a(Re(Ci,{children:[Re("div",{className:"sc-current-grid",children:[(t||i!==null)&&Re("div",{className:"sc-current-main",children:[t?Re("p",{className:"sc-current-name",children:[l.name,i!==null&&Re("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})]}):i!==null&&ee("p",{className:"sc-current-trial",children:Re("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})}),t&&l.description&&ee("p",{className:"sc-sub",children:l.description})]}),n&&Re("div",{className:"sc-usage",children:[Re("div",{className:"sc-row-between",children:[ee("span",{className:"sc-fact-key",children:"Usage"}),ee("span",{className:c!==null&&c>=100?"sc-usage-figure sc-usage-over":"sc-usage-figure",children:u?"Unlimited":c===null?"Metered":`${c}% used`})]}),c!==null&&ee("div",{className:"sc-meter",role:"presentation",children:c>0&&ee("span",{className:c>=100?"sc-meter-fill sc-meter-full":"sc-meter-fill",style:{width:`${c}%`}})}),ee("p",{className:"sc-usage-line",children:o.summary})]})]}),p&&Re("div",{className:"sc-current-foot",children:[ee("p",{className:p.required?"sc-plan-reward-line sc-plan-reward-need":p.inForce?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-open",children:p.required?p.line:p.inForce?`In force: ${wi(p.line)}.`:p.line}),(p.actionable||p.connected)&&ee(dn,{})]})]}))}var wi=e=>e.charAt(0).toLowerCase()+e.slice(1);import{useCallback as vi,useMemo as ki,useState as es}from"react";var Ni={"user-hardware":"your own machine","user-subscription":"your own AI subscription","open-weights":"open models we host",frontier:"frontier models"},xi=new Set(["user-hardware","user-subscription"]);function Xr(e={}){let{plan:n,compute:t,connect:r}=D(),[o,s]=es(null),[a,l]=es(null),{featured:i,onSelect:c,successUrl:u,cancelUrl:p}=e,f=vi(async m=>{s(m.id),l(null);try{if(m.selectable)await n.select(m.id);else if(c)c(m);else{let y=await n.checkout(m.id,{...u?{successUrl:u}:{},...p?{cancelUrl:p}:{}});window.location.assign(y);return}}catch(y){throw l(y.message),y}finally{(m.selectable||c)&&s(null)}},[n,c,u,p]),g=ki(()=>n.plans.map(m=>{let y=n.current?.plan_id===m.id;return{plan:m,current:y,featured:i===m.id&&!y,price:Ri(m),allowance:m.included_units===null?`Unlimited ${m.unit}s`:`${m.included_units.toLocaleString()} ${m.unit}${m.included_units===1?"":"s"}`,allowanceNote:Si(m),computeLabel:m.route_allow===null?"any compute":m.route_allow.length===0?"no compute":null,compute:(m.route_allow??[]).map(R=>({costClass:R,label:Ni[R]??R,owned:xi.has(R),runtimes:Jt(R).map(S=>S.id)})),connect:Pi(m,y,t.connected,()=>r.open("manual")),cta:{label:Mi(m,y,o===m.id),disabled:y||o!==null,busy:o===m.id,take:()=>f(m)}}}),[n.plans,n.current,i,t.connected,r,o,f]);return{offers:g,current:g.find(m=>m.current)??null,loading:n.loading,error:n.error,failed:a}}function Ri(e){return e.price===0?{amount:"Free",interval:null,free:!0}:{amount:`$${e.price.toLocaleString()}`,interval:e.interval,free:!1}}function Si(e){let n=[];return e.included_units===null?n.push("No ceiling on this plan"):(n.push(`Included each ${e.interval}`),e.overage==="meter"&&e.overage_per_unit>0?n.push(`then $${e.overage_per_unit} a ${e.unit}`):e.included_units>0&&n.push(`then ${e.unit}s stop`)),e.trial_days>0&&n.push(`${e.trial_days}-day trial`),n.join(" \xB7 ")}function Pi(e,n,t,r){let o=We({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6}),s=xe(e.route_allow)&&!t;if(!o&&!s)return null;let a=He(e.connected_reward);return{key:o?"Connect your own":"To use this",line:o??(n?"Nothing connected yet, so nothing can run.":"Runs only on compute you connect."),reward:o!==null,actionable:n&&(a||s)&&!t,open:r}}function Mi(e,n,t){return n?"Your plan":t?e.selectable?"Switching\u2026":"Opening\u2026":e.selectable?"Choose":`Subscribe for $${e.price.toLocaleString()}/${e.interval}`}import{jsx as b,jsxs as G}from"react/jsx-runtime";function St(e){return e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill"}function Kr({onSelect:e,successUrl:n,cancelUrl:t,showCompute:r=!0,showConnect:o=!1,variant:s="cards",featured:a,className:l}){let{offers:i,loading:c,error:u,failed:p}=Xr({...a?{featured:a}:{},...e?{onSelect:e}:{},...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),{theme:f}=B();if(u)return b("div",{className:St(l),"data-theme":f,children:b("div",{className:"sc-card",children:b("p",{className:"sc-error",children:u.message})})});if(c)return b("div",{className:St(l),"data-theme":f,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"Loading plans\u2026"})})});if(i.length===0)return b("div",{className:St(l),"data-theme":f,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"This app has no plans yet."})})});let g={showCompute:r,showConnect:o};return G("div",{className:St(l),"data-theme":f,"data-variant":s,children:[s==="rows"?b(Ii,{offers:i,shelf:g}):s==="table"?b(Oi,{offers:i,shelf:g}):b(Ei,{offers:i,shelf:g}),p&&b("p",{className:"sc-error",children:p})]})}function Ei({offers:e,shelf:n}){return b("div",{className:"sc-plans",children:e.map(t=>G("div",{className:ns("sc-plan",t),children:[G("div",{className:"sc-row-between",children:[b("span",{className:"sc-title",children:t.plan.name}),b(_r,{offer:t})]}),b("p",{className:"sc-sub",children:t.plan.description}),b($r,{price:t.price,free:"forever"}),b(to,{offer:t,shelf:n}),b(ts,{offer:t}),b("div",{className:"sc-plan-band",children:n.showCompute&&b(no,{offer:t})}),b("div",{className:"sc-plan-band",children:b(eo,{offer:t})})]},t.plan.id))})}function Ii({offers:e,shelf:n}){return b("ul",{className:"sc-plan-rows",children:e.map(t=>G("li",{className:ns("sc-plan-row",t),children:[G("div",{className:"sc-row-main",children:[G("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:t.plan.name}),b(_r,{offer:t})]}),t.plan.description&&b("p",{className:"sc-sub",children:t.plan.description}),b(ts,{offer:t}),n.showCompute&&b(no,{offer:t,inline:!0}),b(eo,{offer:t,inline:!0})]}),G("div",{className:"sc-row-side",children:[b($r,{price:t.price,free:"forever",small:!0}),b(to,{offer:t,shelf:n})]})]},t.plan.id))})}function Oi({offers:e,shelf:n}){let t=e.some(a=>a.plan.overage_per_unit>0),r=e.some(a=>a.plan.trial_days>0),o=e.some(a=>a.connect!==null),s=a=>[a.current?"sc-col-current":"",a.featured?"sc-col-featured":""].filter(Boolean).join(" ")||void 0;return b("div",{className:"sc-table-scroll",children:G("table",{className:"sc-plan-table",children:[b("thead",{children:G("tr",{children:[b("td",{}),e.map(a=>G("th",{scope:"col",className:s(a),children:[G("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:a.plan.name}),b(_r,{offer:a})]}),b($r,{price:a.price,small:!0})]},a.plan.id))]})}),G("tbody",{children:[G("tr",{children:[b("th",{scope:"row",children:"Included"}),e.map(a=>b("td",{className:s(a),children:a.allowance},a.plan.id))]}),t&&G("tr",{children:[b("th",{scope:"row",children:"Then"}),e.map(a=>b("td",{className:s(a),children:a.plan.overage_per_unit>0?`$${a.plan.overage_per_unit} / ${a.plan.unit}`:b("span",{className:"sc-muted-cell",children:"Stops"})},a.plan.id))]}),r&&G("tr",{children:[b("th",{scope:"row",children:"Trial"}),e.map(a=>b("td",{className:s(a),children:a.plan.trial_days>0?`${a.plan.trial_days} days`:b("span",{className:"sc-muted-cell",children:"None"})},a.plan.id))]}),n.showCompute&&G("tr",{children:[b("th",{scope:"row",children:"Runs on"}),e.map(a=>b("td",{className:s(a),children:b(no,{offer:a,bare:!0})},a.plan.id))]}),o&&G("tr",{children:[b("th",{scope:"row",children:"Connect your own"}),e.map(a=>b("td",{className:s(a),children:b(eo,{offer:a,bare:!0})},a.plan.id))]}),G("tr",{className:"sc-table-buy",children:[b("td",{}),e.map(a=>b("td",{className:s(a),children:b(to,{offer:a,shelf:n})},a.plan.id))]})]})]})})}function ns(e,n){return[e,n.current?"sc-plan-current":"",n.featured?"sc-plan-featured":""].filter(Boolean).join(" ")}function _r({offer:e}){return e.current?b("span",{className:"sc-plan-badge",children:"Current"}):e.featured?b("span",{className:"sc-plan-badge-soft",children:"Recommended"}):null}function $r({price:e,small:n,free:t}){return G("p",{className:n?"sc-plan-price sc-plan-price-sm":"sc-plan-price",children:[b("span",{className:"sc-plan-amount",children:e.amount}),e.interval?G("span",{className:"sc-plan-interval",children:["/",e.interval]}):t&&b("span",{className:"sc-plan-interval sc-plan-after",children:t})]})}function ts({offer:e}){return G("p",{className:"sc-plan-allowance",children:[b("span",{className:"sc-plan-figure",children:e.allowance}),b("span",{className:"sc-plan-qualifier",children:e.allowanceNote})]})}function eo({offer:e,inline:n,bare:t}){let r=e.connect;if(!r)return t?b("span",{className:"sc-muted-cell",children:"None"}):null;let o=r.reward?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-need",s=r.actionable?G("button",{type:"button",className:`${o} sc-plan-reward-act`,"aria-label":"Connect compute",onClick:r.open,children:[b("span",{className:"sc-reward-said",children:r.line}),G("span",{className:"sc-reward-do","aria-hidden":!0,children:[b(X,{className:"sc-reward-mark"}),"Connect compute"]})]}):b("p",{className:o,children:r.line});return t?s:b("div",{className:n?"sc-plan-reward sc-plan-reward-inline":"sc-plan-reward",children:s})}function no({offer:e,inline:n,bare:t}){let r=e.computeLabel?b("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:b("li",{children:e.computeLabel})}):b("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:e.compute.map(o=>G("li",{className:o.owned?"sc-compute-own":void 0,children:[o.label,b(Li,{runtimes:o.runtimes})]},o.costClass))});return t?r:G("div",{className:n?"sc-plan-compute sc-plan-compute-inline":"sc-plan-compute",children:[b("span",{className:"sc-fact-key",children:"Runs on"}),r]})}function to({offer:e,shelf:n}){let t=e.connect;return n.showConnect&&t?.actionable?G("button",{type:"button",className:"sc-btn sc-btn-primary sc-btn-icon",onClick:t.open,children:[b(X,{className:"sc-btn-mark"}),"Connect compute"]}):b("button",{type:"button",className:e.current?"sc-btn":"sc-btn sc-btn-primary",disabled:e.cta.disabled,onClick:()=>void e.cta.take().catch(()=>{}),children:e.cta.label})}function Li({runtimes:e}){return e.length===0?null:b("span",{className:"sc-compute-marks",children:e.map(n=>{let t=Ye[n];return t?b(t,{className:"sc-rt-mark"},n):null})})}import{jsx as ro,jsxs as rs}from"react/jsx-runtime";function Ti({heading:e,plansHeading:n,showUsage:t=!0,showName:r=!0,className:o,...s}){let{plan:a,loading:l}=at(),{theme:i}=B(),c=n??(l?"Plans":a?"Change plan":"Choose a plan");return rs("div",{className:o?`soba-connect sc-fill sc-billing ${o}`:"soba-connect sc-fill sc-billing","data-theme":i,children:[ro(Zr,{...e===void 0?{}:{heading:e},showUsage:t,showName:r}),rs("section",{className:"sc-billing-plans",children:[c&&ro("h2",{className:"sc-section-title",children:c}),ro(Kr,{...s})]})]})}import{useCallback as os,useState as ss}from"react";function oo({plan:e,successUrl:n,cancelUrl:t,label:r}){let{plan:o}=D(),[s,a]=ss(!1),[l,i]=ss(null),c=os(()=>o.checkout(e.id,{...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),[o,e.id,n,t]),u=os(async()=>{a(!0),i(null);try{window.location.assign(await c())}catch(p){i(p.message),a(!1)}},[c]);return{label:s?"Opening\u2026":r??`Subscribe for $${e.price.toLocaleString()}/${e.interval}`,busy:s,error:l,buy:u,session:c}}import{jsx as as,jsxs as Gi}from"react/jsx-runtime";function Bi({plan:e,successUrl:n,cancelUrl:t,label:r,className:o}){let{theme:s}=B(),a=oo({plan:e,...n?{successUrl:n}:{},...t?{cancelUrl:t}:{},...r?{label:r}:{}});return Gi("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":s,children:[as("button",{type:"button",className:"sc-btn sc-btn-primary",disabled:a.busy,onClick:()=>void a.buy(),children:a.label}),a.error&&as("p",{className:"sc-error",children:a.error})]})}import{useCallback as Le,useEffect as Ze,useMemo as On,useRef as Xe,useState as ne}from"react";var Wi="soba.session:";function is(e){return!e.cacheKey||!e.endpoint?null:Wi+JSON.stringify([e.endpoint,e.user??null,e.cacheKey])}function Hi(e){try{let n=globalThis.localStorage?.getItem(e);if(!n)return null;let t=JSON.parse(n);return typeof t.token!="string"||typeof t.expiresAt!="number"?null:{token:t.token,expiresAt:t.expiresAt}}catch{return null}}function Di(e,n){try{n?globalThis.localStorage?.setItem(e,JSON.stringify(n)):globalThis.localStorage?.removeItem(e)}catch{}}var ls=6e4,Ui=1e4,Pt=class{#e;#n=null;#r=null;#t;#o=new Set;constructor(n){this.#t=n,this.#e=n.token??null;let t=is(n),r=t&&!this.#e?Hi(t):null;r&&r.expiresAt-ls>Date.now()&&(this.#e=r.token,this.#n=r.expiresAt)}get token(){return this.#e}get expiresAt(){return this.#n}get canRefresh(){return!!this.#t.endpoint}get refreshAt(){return!this.canRefresh||this.#n===null?null:Math.max(Date.now()+Ui,this.#n-ls)}subscribe(n){return this.#o.add(n),()=>this.#o.delete(n)}async ensure(){return this.#e?this.#e:this.refresh()}async refresh(){if(this.#r)return this.#r;let n=this.#t.endpoint;if(!n)throw new Error("This Soba session cannot be refreshed. Pass `sessionEndpoint` so the provider can mint a new one.");let t=this.#t.fetchImpl??fetch.bind(globalThis);this.#r=(async()=>{let r=await t(n,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(this.#t.user?{user:this.#t.user}:{})});if(!r.ok)throw new Error(`Could not start a Soba session (${r.status} from ${n}).`);let o=await r.json(),s=o.session??o.token;if(!s)throw new Error(`${n} answered without a \`session\`. See @soba-so/react's README.`);let a=o.expires_in??o.expiresIn;this.#e=s,this.#n=typeof a=="number"?Date.now()+a*1e3:null;let l=is(this.#t);l&&Di(l,this.#n===null?null:{token:s,expiresAt:this.#n});for(let i of this.#o)i();return s})();try{return await this.#r}finally{this.#r=null}}},In=new Map,cs=new WeakMap,Fi=1;function Qi(e){if(e.token||!e.endpoint)return null;let n=0;return e.fetchImpl&&(n=cs.get(e.fetchImpl)??Fi++,cs.set(e.fetchImpl,n)),JSON.stringify([e.endpoint,e.user??null,n,e.cacheKey??null])}function us(e){let n=Qi(e);if(!n)return new Pt(e);let t=In.get(n)??{holder:new Pt(e),users:0};return In.set(n,t),t.holder}function ds(e){for(let n of In.values())n.holder===e&&n.users++}function ps(e){for(let[n,t]of In)if(t.holder===e){setTimeout(()=>{--t.users<=0&&In.get(n)===t&&In.delete(n)},0);return}}function ms(e,n=fetch.bind(globalThis)){return async(t,r)=>{let o=await n(t,r);if(o.status!==401||!e.canRefresh)return o;let s;try{s=await e.refresh()}catch{return o}return n(t,Ji(r,s))}}function Ji(e,n){let t=new Headers(e?.headers);return t.set("authorization",`Bearer ${n}`),{...e,headers:t}}import{jsx as so,jsxs as zi}from"react/jsx-runtime";var Vi="https://www.soba.so",Yi=3e4;function ji(e){let{children:n,session:t,sessionEndpoint:r,user:o,sessionCacheKey:s,runEndpoint:a,theme:l,initialMachines:i,initialConnect:c=null,initialPlans:u,initialCurrentPlan:p=null,baseUrl:f=Vi,pollMs:g=Yi,injectStyles:m=!0,modal:y=!0,fetchImpl:R,onError:S}=e,[k,W]=ne(t??null),[F,O]=ne(null),[P,Q]=ne(c),[T,K]=ne(null),[q,de]=ne(c===null),[V,M]=ne(i??[]),[De,Y]=ne(null),[pe,Ke]=ne(i===void 0),[Se,me]=ne(u??[]),[te,mn]=ne(p),[Ue,Fe]=ne(null),[ie,he]=ne(u===void 0),[re,Qe]=ne(null),[hn,Pe]=ne(!1),Te=Xe(S);Te.current=S;let oe=Le(C=>{O(C),Te.current?.(C)},[]);Ze(()=>{m&&ot()},[m]);let w=On(()=>us({...t?{token:t}:{},...r?{endpoint:r}:{},...o?{user:o}:{},...R?{fetchImpl:R}:{},...s?{cacheKey:s}:{}}),[t,r,o,R,s]);Ze(()=>{let C=!0;ds(w);let Z=w.subscribe(()=>{C&&W(w.token)});return!w.token&&!w.canRefresh?oe(new Error("<SobaProvider> needs a `session` or a `sessionEndpoint`. A browser cannot mint one: that takes your secret key.")):w.ensure().then(()=>C&&W(w.token),le=>C&&oe(le)),()=>{C=!1,Z(),ps(w)}},[w,oe]),Ze(()=>{F&&(de(!1),Ke(!1),he(!1),K(C=>C??F),Y(C=>C??F),Fe(C=>C??F))},[F]),Ze(()=>{let C=w.refreshAt;if(C===null)return;let Z=()=>{w.refresh().catch(Ae=>oe(Ae))},le=()=>{document.hidden||(document.removeEventListener("visibilitychange",le),Z())},dt=setTimeout(()=>{typeof document<"u"&&document.hidden?document.addEventListener("visibilitychange",le):Z()},Math.max(0,C-Date.now()));return()=>{clearTimeout(dt),typeof document<"u"&&document.removeEventListener("visibilitychange",le)}},[w,oe,k]);let j=Xe(c?.machines_url??null),E=On(()=>{if(!k)return null;let C=new Tn({session:k,baseUrl:f,fetchImpl:ms(w,R??fetch.bind(globalThis))});return C.setMachinesUrl(j.current),C},[k,f,w,R]),Mt=Xe(c!==null);Ze(()=>{if(!E||Mt.current)return;let C=!0;return de(!0),E.context().then(Z=>{C&&(Q(Z),K(null),de(!1))},Z=>{C&&(K(Z),de(!1))}),()=>{C=!1}},[E]);let Je=Le(async()=>{if(E)try{let C=await E.machines();M(Array.isArray(C)?C:[]),Y(null)}catch(C){Y(C)}finally{Ke(!1)}},[E]),ge=Le(async()=>{if(E)try{let C=await E.plans();me(C.plans),mn(C.current),Fe(null)}catch(C){Fe(C)}finally{he(!1)}},[E]),se=Xe(!1),[Ve,gn]=ne(!1),fn=Xe(u!==void 0),_e=Xe(!1),$e=Le(()=>{se.current||(se.current=!0,_e.current&&queueMicrotask(()=>{_e.current&&gn(!0)}))},[]);Ze(()=>(_e.current=!0,se.current&&gn(!0),()=>{_e.current=!1}),[]),Ze(()=>{!E||!Ve||fn.current||ge()},[E,Ve,ge]);let en=Le(async C=>{if(!E)throw new Error("No session yet.");await E.selectPlan(C),await ge()},[E,ge]),Et=Le(async(C,Z)=>{if(!E)throw new Error("No session yet.");let le=await E.checkoutPlan(C,Z);if(!le.url)throw new Error("Checkout could not be started.");return le.url},[E]),it=Le(async()=>{if(!E)throw new Error("No session yet.");await E.leavePlan(),await ge()},[E,ge]),lt=Xe(i!==void 0);Ze(()=>{if(!E)return;let C=Ce(Je,g,{immediate:!lt.current});return lt.current=!1,C},[E,Je,g]);let An=Le((C="manual")=>{y&&(Pe(!0),Qe(C))},[y]),ct=Le(()=>Qe(null),[]),z=Xe(V);z.current=V;let Me=Le(async C=>{if(!a)throw new Error("Pass `runEndpoint` to <SobaProvider> to start runs from the browser. It is your own route: it holds your secret key, calls soba.run(), and forwards the stream.");let{signal:Z,...le}=C,Ae=await(R??fetch.bind(globalThis))(a,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream"},credentials:"same-origin",body:JSON.stringify(le),...Z?{signal:Z}:{}});if(!Ae.ok){let Be=await Ae.json().catch(()=>null),be=new Error(Be?.error?.message??`${a} answered ${Ae.status}.`);be.status=Ae.status,Be?.error?.code&&(be.code=Be.error.code),Be?.error&&(be.error=Be.error);let pt=z.current.length>0&&!z.current.some(Ot=>Ot.state!=="offline");throw Ae.status===409&&pt&&An("no_compute"),be}let ve=Yr(Ae);return async function*(){try{yield*ve}finally{se.current&&ge()}}()},[a,R,ge,An]),fe=On(()=>te?Se.find(C=>C.id===te.plan_id)??null:null,[Se,te]),nn=On(()=>fe?fe.connected_reward==="included"&&V.length>0&&fe.connected_included_units!==null?fe.connected_included_units:fe.included_units:null,[fe,V]),ut=On(()=>({plans:Se,current:te,plan:fe,used:te?.units_used??null,included:nn,remaining:nn!==null&&te?Math.max(0,nn-te.units_used):null,unlimited:fe!==null&&nn===null,loading:ie,error:Ue,select:en,checkout:Et,leave:it,refresh:ge}),[Se,te,fe,nn,ie,Ue,en,Et,it,ge]),It=On(()=>({session:k,client:E,error:F,get plan(){return $e(),ut},compute:{machines:V,connected:V.length>0,online:V.some(C=>C.state!=="offline"),loading:pe,error:De,refresh:Je},connect:{app:P?.app??null,command:P?.command??null,connectUrl:P?.connect_url??null,publishableKey:P?.publishable_key??null,loading:q,error:T,open:An,close:ct,isOpen:re!==null,hasModal:y},run:Me}),[k,E,F,ut,$e,re,An,ct,y,V,pe,De,Je,P,q,T,Me]);return so(Or.Provider,{value:E,children:so(Lr.Provider,{value:{context:P,machines:pe?void 0:V,theme:l??P?.theme??"light"},children:zi(Tr.Provider,{value:It,children:[n,y&&hn&&so(nt,{open:re!==null,onOpenChange:C=>Qe(C?re??"manual":null),onConnected:()=>{Je()},...re==="payment_required"||re==="no_compute"?{reason:re}:{},...re==="pair"?{showStatus:!1}:{}})]})})})}function qi(e){return e?Zi[e]??e:null}var Zi={"user-hardware":"your own computer","user-subscription":"your own AI plan","user-api-key":"your own API key","open-weights":"open models we host",frontier:"a frontier model we pay for"};async function Xi(e,n,t){let r=n.local;if(!r?.session||n.after)return null;let o=/\/v1\/runs\/([^/]+)\/events/.exec(e.url)?.[1];if(!o)return null;let s=`http://127.0.0.1:${r.port??47321}/v1/runs/${o}/events`,a=new AbortController,l=()=>a.abort();n.signal?.addEventListener("abort",l);let i=setTimeout(()=>a.abort(),r.timeoutMs??3e3);try{let c=await t(s,{headers:{authorization:`Bearer ${r.session}`,accept:"text/event-stream"},signal:a.signal});return c.ok?{url:s,bearer:r.session,open:c}:null}catch{return null}finally{clearTimeout(i),n.signal?.removeEventListener("abort",l)}}async function*Ki(e){let n=e.body;if(!n)return;let t=n.getReader(),r=new TextDecoder,o="",s=null,a=[];try{for(;;){let l=await t.read();if(l.done)return;o+=r.decode(l.value,{stream:!0});for(let i=o.indexOf(`
|
|
3017
3049
|
`);i!==-1;i=o.indexOf(`
|
|
3018
|
-
`)){let
|
|
3019
|
-
`)}),s=null,a=[];else if(
|
|
3050
|
+
`)){let c=o.slice(0,i).replace(/\r$/,"");if(o=o.slice(i+1),c==="")a.length&&(yield{id:s,data:a.join(`
|
|
3051
|
+
`)}),s=null,a=[];else if(c.startsWith("id:")){let u=Number(c.slice(3).trim());s=Number.isFinite(u)?u:null}else if(c.startsWith("data:")){let u=c.slice(5);a.push(u.startsWith(" ")?u.slice(1):u)}}}}finally{t.cancel().catch(()=>{})}}var ao=(e,n)=>new Promise(t=>{let r=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(r),t()})});async function*_i(e,n={}){let t=n.fetchImpl??fetch.bind(globalThis),r=await Xi(e,n,t)??{url:e.url,bearer:e.token,open:null},o=n.maxRetries??6,s=n.after??0,a=0;for(;;){if(n.signal?.aborted)return;let l;try{l=r.open??await t(r.url,{headers:{authorization:`Bearer ${r.bearer}`,accept:"text/event-stream",...s?{"last-event-id":String(s)}:{}},...n.signal?{signal:n.signal}:{}}),r.open=null}catch(i){if(n.signal?.aborted)return;if(++a>o)throw i;await ao(1e3*a,n.signal);continue}if(l.status===503&&a<o){a++,await ao(Number(l.headers.get("retry-after")??3)*1e3,n.signal);continue}if(!l.ok){let i=`Could not read this run (${l.status}).`;try{let c=await l.json();c.error?.message&&(i=c.error.message)}catch{}throw new Error(i)}for await(let i of Ki(l)){i.id!==null&&(s=i.id),a=0;let c=En(i.data);if(c&&(yield c,c.type==="done"||c.type==="error"))return}if(n.signal?.aborted)return;if(++a>o)throw new Error("Lost this run's stream and could not get it back.");await ao(1e3*a,n.signal)}}export{Ma as ComputeStatus,dn as ConnectButton,Da as ConnectCompute,nt as ConnectModal,ei as ConnectNudge,Gr as ConnectPill,li as ModelPicker,di as RunError,hi as RunLimit,Ti as SobaBilling,Bi as SobaCheckout,Zr as SobaCurrentPlan,Kr as SobaPlans,ji as SobaProvider,si as collectText,Wr as connectSays,ot as injectStyles,En as parseEvent,Yr as readEvents,Ko as runErrorMessage,pn as sobaErrorCode,qi as tierLabel,oo as useCheckout,$n as useCompute,Ta as useConnectButton,Vr as useConnectNudge,at as useCurrentPlan,Hr as useMachineRuns,qr as useModel,rt as useOpenSobaConnect,Xr as usePlans,Qr as useRunLimit,D as useSoba,_i as watchRun};
|
package/dist/styles.css
CHANGED
|
@@ -44,9 +44,6 @@
|
|
|
44
44
|
|
|
45
45
|
box-sizing: border-box;
|
|
46
46
|
|
|
47
|
-
width: 100%;
|
|
48
|
-
max-width: 560px;
|
|
49
|
-
margin: 0 auto;
|
|
50
47
|
color: var(--sc-text, #1a1a1c);
|
|
51
48
|
font-family: var(
|
|
52
49
|
--sc-font,
|
|
@@ -62,6 +59,12 @@
|
|
|
62
59
|
line-height: 1.5;
|
|
63
60
|
letter-spacing: -0.005em;
|
|
64
61
|
}
|
|
62
|
+
|
|
63
|
+
:where(.soba-connect) {
|
|
64
|
+
width: 100%;
|
|
65
|
+
max-width: 560px;
|
|
66
|
+
margin: 0 auto;
|
|
67
|
+
}
|
|
65
68
|
.soba-connect *,
|
|
66
69
|
.soba-connect *::before,
|
|
67
70
|
.soba-connect *::after {
|
|
@@ -503,6 +506,28 @@ a.sc-btn {
|
|
|
503
506
|
background: var(--sc-tray-sunk, #f6f6f7);
|
|
504
507
|
}
|
|
505
508
|
|
|
509
|
+
.sc-runtime-logo {
|
|
510
|
+
width: 15px;
|
|
511
|
+
height: 15px;
|
|
512
|
+
border-radius: 3px;
|
|
513
|
+
object-fit: contain;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.sc-runtime-letter {
|
|
517
|
+
font-size: 10px;
|
|
518
|
+
font-weight: 600;
|
|
519
|
+
line-height: 1;
|
|
520
|
+
color: var(--sc-muted, #6b6b73);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.sc-runs-logo {
|
|
524
|
+
flex: none;
|
|
525
|
+
width: 14px;
|
|
526
|
+
height: 14px;
|
|
527
|
+
border-radius: 3px;
|
|
528
|
+
object-fit: contain;
|
|
529
|
+
}
|
|
530
|
+
|
|
506
531
|
.sc-runtime-mark {
|
|
507
532
|
width: 13px;
|
|
508
533
|
height: 13px;
|
|
@@ -668,7 +693,9 @@ a.sc-btn {
|
|
|
668
693
|
background: transparent;
|
|
669
694
|
font-family: inherit;
|
|
670
695
|
cursor: pointer;
|
|
671
|
-
transition:
|
|
696
|
+
transition:
|
|
697
|
+
background-color 120ms ease,
|
|
698
|
+
color 120ms ease;
|
|
672
699
|
}
|
|
673
700
|
|
|
674
701
|
.sc-runs-btn:hover:not(:disabled),
|
|
@@ -724,7 +751,9 @@ a.sc-btn {
|
|
|
724
751
|
border: 1px solid var(--sc-line, #e9e9eb);
|
|
725
752
|
border-radius: 12px;
|
|
726
753
|
background: var(--sc-tray-card, #ffffff);
|
|
727
|
-
box-shadow:
|
|
754
|
+
box-shadow:
|
|
755
|
+
0 10px 30px rgba(0, 0, 0, 0.12),
|
|
756
|
+
0 2px 6px rgba(0, 0, 0, 0.06);
|
|
728
757
|
color: var(--sc-text, #1a1a1c);
|
|
729
758
|
|
|
730
759
|
max-height: 60vh;
|
|
@@ -832,7 +861,9 @@ a.sc-btn {
|
|
|
832
861
|
font-weight: 500;
|
|
833
862
|
color: var(--sc-text-2, #3f3f46);
|
|
834
863
|
cursor: pointer;
|
|
835
|
-
transition:
|
|
864
|
+
transition:
|
|
865
|
+
background-color 120ms ease,
|
|
866
|
+
color 120ms ease;
|
|
836
867
|
}
|
|
837
868
|
|
|
838
869
|
.sc-mp-btn:hover:not(:disabled),
|
|
@@ -1934,8 +1965,9 @@ a.sc-btn {
|
|
|
1934
1965
|
border-radius: var(--sc-r-pill, 999px);
|
|
1935
1966
|
border-color: var(--sc-line, #e9e9eb);
|
|
1936
1967
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1968
|
+
|
|
1969
|
+
box-shadow: var(--sc-shadow-1, 0 1px 2px rgb(0 0 0 / 5%));
|
|
1970
|
+
font-size: var(--sc-fs-small, 12.5px);
|
|
1939
1971
|
font-weight: 500;
|
|
1940
1972
|
|
|
1941
1973
|
letter-spacing: -0.005em;
|
|
@@ -52,17 +52,21 @@ export interface ConnectButtonView {
|
|
|
52
52
|
}
|
|
53
53
|
export declare function useConnectButton(): ConnectButtonView;
|
|
54
54
|
/**
|
|
55
|
-
* WHAT
|
|
56
|
-
*
|
|
55
|
+
* WHAT A CONTROL SAYS ABOUT ONE MACHINE — the rule itself, with no hooks in it,
|
|
56
|
+
* because `<ConnectPill />` cannot read it off the hook above.
|
|
57
57
|
*
|
|
58
58
|
* While its panel is open the pill's state is THIS APP'S RUNS rather than the
|
|
59
59
|
* machine's own counters: the run list is read every three seconds and is
|
|
60
60
|
* exactly this app's, where `state` and `active` arrive by heartbeat and count
|
|
61
|
-
* every app on that laptop. So
|
|
62
|
-
* for those few seconds, and a hook reading the provider cannot.
|
|
61
|
+
* every app on that laptop. So `<ConnectButton />` substitutes its own machine
|
|
62
|
+
* list for those few seconds, and a hook reading the provider cannot.
|
|
63
63
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
64
|
+
* THE BODY IS THE KIT'S NOW. It was defined here, which put it one package
|
|
65
|
+
* above the only two functions it is made of and out of reach of the other
|
|
66
|
+
* surface that draws this pill — the dashboard's bar, which spelled the same
|
|
67
|
+
* four lines out by hand. It moved down beside `stateWord` and `machineName`;
|
|
68
|
+
* this stays as the published face of it, so the declaration a customer
|
|
69
|
+
* installs names types from this package rather than from a private one.
|
|
66
70
|
*/
|
|
67
71
|
export declare function connectSays(machine: Machine | null): {
|
|
68
72
|
label: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soba-so/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Connect the AI your users already pay for, from your own React app.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://soba.so/docs/components",
|
|
@@ -19,13 +19,18 @@
|
|
|
19
19
|
"!dist/**/*.map",
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node ../../scripts/build-react.mjs",
|
|
24
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
25
|
+
"prepublishOnly": "node ../../scripts/build-react.mjs"
|
|
26
|
+
},
|
|
22
27
|
"peerDependencies": {
|
|
23
28
|
"react": ">=18"
|
|
24
29
|
},
|
|
25
30
|
"devDependencies": {
|
|
31
|
+
"@soba-so/connect-ui": "workspace:*",
|
|
26
32
|
"@types/react": "^19.0.0",
|
|
27
|
-
"typescript": "^7.0.2"
|
|
28
|
-
"@soba-so/connect-ui": "0.1.0"
|
|
33
|
+
"typescript": "^7.0.2"
|
|
29
34
|
},
|
|
30
35
|
"engines": {
|
|
31
36
|
"node": ">=22"
|
|
@@ -39,9 +44,5 @@
|
|
|
39
44
|
],
|
|
40
45
|
"publishConfig": {
|
|
41
46
|
"access": "public"
|
|
42
|
-
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"build": "node ../../scripts/build-react.mjs",
|
|
45
|
-
"typecheck": "tsc -p tsconfig.json"
|
|
46
47
|
}
|
|
47
|
-
}
|
|
48
|
+
}
|