local-operator-ui 0.46.7 → 0.46.8
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/out/renderer/assets/{_basePickBy-Do5pLlvO.js → _basePickBy-CuPgdlLe.js} +1 -1
- package/out/renderer/assets/{_baseUniq-CYENlcn8.js → _baseUniq-q-GzZKBS.js} +1 -1
- package/out/renderer/assets/{agent-details-page-DxOcBjpW.js → agent-details-page-DY1Orohr.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-Q9_X5CFP.js → agent-hub-page-Ds9nvIYv.js} +1 -1
- package/out/renderer/assets/{agents-page-D_twoMKH.js → agents-page-BVcJyyR_.js} +3 -3
- package/out/renderer/assets/{arc-Bh6MAPn3.js → arc-CvDdm6jq.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-BO0aJcKY.js → architectureDiagram-IEHRJDOE-D5bGZEoB.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-BDwqIZKe.js → blockDiagram-JOT3LUYC-u_IQ3eSj.js} +1 -1
- package/out/renderer/assets/{book-open-CjMQ2-CP.js → book-open-B73Yn-SK.js} +1 -1
- package/out/renderer/assets/browser-page-R9ESMyP9.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-DkqSn3Sr.js → browser-webauthn-prompt-XpefFmFX.js} +1 -1
- package/out/renderer/assets/{building-2-DBR_Itgp.js → building-2-kkfx6Z-U.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-xBsmj6Zh.js → c4Diagram-VJAJSXHY-DuV50TR8.js} +1 -1
- package/out/renderer/assets/channel-AaX39fsm.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CF9-FtSa.js → chunk-4BMEZGHF-b8PaCOoy.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-CdBfuMhS.js → chunk-A2AXSNBT--IoMT2Md.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-CkmafBOT.js → chunk-AEK57VVT-Cn6DKXBB.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-C0PQnMAX.js → chunk-D6G4REZN-lJEgZlOA.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-BybOaZxh.js → chunk-RZ5BOZE2-C8sAhN9F.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-XiQ960SS.js → chunk-XZIHB7SX-Dz0Asp2E.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-CQ6AEPOh.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-CQ6AEPOh.js +1 -0
- package/out/renderer/assets/clone-VutwkgZH.js +1 -0
- package/out/renderer/assets/{console-mirror-C-hKgNgn.js → console-mirror-BuskFu7W.js} +1 -1
- package/out/renderer/assets/{consoleCapture-TS0oVXCE.js → consoleCapture-BTnR6yic.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-BwcOsVjK.js → conversation-input-sync-C8YlJ1EX.js} +4 -4
- package/out/renderer/assets/{dagre-OKDRZEBW-BGSLuM_h.js → dagre-OKDRZEBW-CWV5OLm9.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV--4uXBchD.js → diagram-SSKATNLV-zuN0OTZq.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DDdPP20q.js → diagram-VNBRO52H-CmuSOifO.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CN6_fhh5.js → erDiagram-Q7BY3M3F-DHKnHal4.js} +1 -1
- package/out/renderer/assets/{error-boundary-BcPKKbP5.js → error-boundary-B-SnNd1V.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-Bz2Wai2B.js → flowDiagram-4HSFHLVR-VKzBZ2jt.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-WJ9zzEdP.js → ganttDiagram-APWFNJXF-Bs6uJHyW.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-C9Hn2gY9.js → gitGraphDiagram-7IBYFJ6S-DcdTu2Ol.js} +1 -1
- package/out/renderer/assets/{graph-BzNVcrHZ.js → graph-DfDDEBXe.js} +1 -1
- package/out/renderer/assets/{hash-D74BoaKE.js → hash-DhlPNaTy.js} +1 -1
- package/out/renderer/assets/{heart-BitlL6xv.js → heart-8AHpaFmI.js} +1 -1
- package/out/renderer/assets/{index-pRJvOEvT.js → index-Bk9OdcdM.js} +4 -4
- package/out/renderer/assets/index-BrSYlT0K.css +1 -0
- package/out/renderer/assets/{index-DJXsvTrg.js → index-CRerltBd.js} +1 -1
- package/out/renderer/assets/{index-DKCm4Vhd.js → index-DtSIpYnZ.js} +1 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-D60ouGYJ.js +2 -0
- package/out/renderer/assets/{installer-D12iBfVp.js → installer-BhonfpX_.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BS2dZM9P.js → journeyDiagram-U35MCT3I-BT0NIe6A.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BdpVkX81.js → kanban-definition-NDS4AKOZ-OuX3rwr7.js} +1 -1
- package/out/renderer/assets/{layout-C3n_m4uD.js → layout-DVPWCCDD.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-Bawvdt7h.js → legacy-agents-page-wrdhQmf1.js} +1 -1
- package/out/renderer/assets/{library-page--nTYgR0k.js → library-page-Bonc93mo.js} +3 -3
- package/out/renderer/assets/{mermaid.core-B12E4EqI.js → mermaid.core-X0bVMmvQ.js} +5 -5
- package/out/renderer/assets/{mesh-page-D1ZsRm8r.js → mesh-page-D8kHAV-F.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BXt7_yrM.js → mindmap-definition-ALO5MXBD-BpHABkH9.js} +1 -1
- package/out/renderer/assets/{mini-BhEwC0kz.js → mini-3YwvoUzA.js} +1 -1
- package/out/renderer/assets/{notebook-pen-CRfFCxXf.js → notebook-pen-DNNnAD8q.js} +1 -1
- package/out/renderer/assets/{notifications-page-Be_zCnpp.js → notifications-page-CGGNrnlN.js} +1 -1
- package/out/renderer/assets/{org-access-gAZxCRYK.js → org-access-DpEprwED.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CAZA5kpm.js → org-surface-gate-Bgxn8h2L.js} +1 -1
- package/out/renderer/assets/{page-header-BnTa4LRQ.js → page-header-etXTK1uO.js} +1 -1
- package/out/renderer/assets/{path-utils-BqTfmiT0.js → path-utils-CPXsvvn9.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-Bv8qFSgX.js → pieDiagram-IB7DONF6-B0uHwbFa.js} +1 -1
- package/out/renderer/assets/{project-markdown-B-gfCIgA.js → project-markdown-g0FzepON.js} +1 -1
- package/out/renderer/assets/{projects-page-CsaCVH12.js → projects-page-BmKB0PA4.js} +1 -1
- package/out/renderer/assets/{publication-validation-CEPmXg_x.js → publication-validation-DSRRYhuA.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-Dh9ldfSS.js → quadrantDiagram-7GDLP6J5-DDv5SDgc.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-C3QcA8aw.js → radar-MK3ICKWK-YYba11Gt.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-B6UxMMyL.js → radient-auth-buttons-B-ByI1-F.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-BU5pLB7L.js → requirementDiagram-KVF5MWMF-B3uBj0oP.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-pkb2fJpW.js → sankeyDiagram-QLVOVGJD-BAXr023A.js} +1 -1
- package/out/renderer/assets/{schedules-page-Bis3PAo0.js → schedules-page-DgYW6h6L.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-bJ0MNSq1.js → sequenceDiagram-X6HHIX6F-B17mhZ42.js} +1 -1
- package/out/renderer/assets/{settings-page-t3dHQ3rA.js → settings-page-DyKAzrQ1.js} +1 -1
- package/out/renderer/assets/{smartart-BbzXlcrh.js → smartart-feL8OxQl.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-BkfwnsxK.js → stateDiagram-DGXRK772-BBbbN5zx.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DZNDSiPs.js +1 -0
- package/out/renderer/assets/{team-bridge-page-jEjSR01Y.js → team-bridge-page-bogDmcnp.js} +8 -8
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-Ciofvs1H.js → timeline-definition-BDJGKUSR-AovjX9qj.js} +1 -1
- package/out/renderer/assets/{use-default-on-banner-Dh8MzHSc.js → use-default-on-banner-DwI-Hr5I.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-Bbx3LX_Y.js → use-download-agent-mutation-CxAcIvee.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-BIGyGyQQ.js → use-session-snapshot-ke5QHVta.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-C4wSLo2w.js → xychartDiagram-VJFVF3MP-wYpHenXz.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +1 -1
- package/out/renderer/assets/browser-page-GBlF_XiR.js +0 -1
- package/out/renderer/assets/channel-j53GQ0U7.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BOtIcaFx.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BOtIcaFx.js +0 -1
- package/out/renderer/assets/clone-CG_qLlUI.js +0 -1
- package/out/renderer/assets/index-D1lZASI6.css +0 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-CaSyc-3e.js +0 -2
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-Y5fvVKXJ.js +0 -1
- /package/out/renderer/assets/{index-C4ae8MIc.js → index-D4bPuJfm.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as S,j as Mf,b as Ra,D as Df}from"./index-C4ae8MIc.js";import{t as v,a as Nf}from"./messages-DoRCUI0R.js";var Er=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},nn=typeof window>"u"||"Deno"in globalThis;function Xe(){}function Lf(e,t){return typeof e=="function"?e(t):e}function ki(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ol(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function ot(e,t){return typeof e=="function"?e(t):e}function xa(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:a,stale:c}=e;if(a){if(r){if(t.queryHash!==po(a,t.options))return!1}else if(!nr(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||s&&s!==t.state.fetchStatus||i&&!i(t))}function Ta(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(tr(t.options.mutationKey)!==tr(i))return!1}else if(!nr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function po(e,t){return(t?.queryKeyHashFn||tr)(e)}function tr(e){return JSON.stringify(e,(t,n)=>Ii(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function nr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>nr(e[n],t[n])):!1}function jl(e,t){if(e===t)return e;const n=Ca(e)&&Ca(t);if(n||Ii(e)&&Ii(t)){const r=n?e:Object.keys(e),s=r.length,i=n?t:Object.keys(t),a=i.length,c=n?[]:{};let l=0;for(let d=0;d<a;d++){const u=n?d:i[d];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(c[u]=void 0,l++):(c[u]=jl(e[u],t[u]),c[u]===e[u]&&e[u]!==void 0&&l++)}return s===a&&l===s?e:c}return t}function Ei(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Ca(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ii(e){if(!Aa(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Aa(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Aa(e){return Object.prototype.toString.call(e)==="[object Object]"}function $f(e){return new Promise(t=>{setTimeout(t,e)})}function Ri(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?jl(e,t):t}function Uf(e){return e}function Ff(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Bf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ho=Symbol();function Ml(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ho?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Gf=class extends Er{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!nn&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},mo=new Gf,Hf=class extends Er{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!nn&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#t}},qr=new Hf;function xi(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}function Wf(e){return Math.min(1e3*2**e,3e4)}function Dl(e){return(e??"online")==="online"?qr.isOnline():!0}var Nl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Gs(e){return e instanceof Nl}function Ll(e){let t=!1,n=0,r=!1,s;const i=xi(),a=h=>{r||(p(new Nl(h)),e.abort?.())},c=()=>{t=!0},l=()=>{t=!1},d=()=>mo.isFocused()&&(e.networkMode==="always"||qr.isOnline())&&e.canRun(),u=()=>Dl(e.networkMode)&&e.canRun(),f=h=>{r||(r=!0,e.onSuccess?.(h),s?.(),i.resolve(h))},p=h=>{r||(r=!0,e.onError?.(h),s?.(),i.reject(h))},m=()=>new Promise(h=>{s=y=>{(r||d())&&h(y)},e.onPause?.()}).then(()=>{s=void 0,r||e.onContinue?.()}),_=()=>{if(r)return;let h;const y=n===0?e.initialPromise:void 0;try{h=y??e.fn()}catch(g){h=Promise.reject(g)}Promise.resolve(h).then(f).catch(g=>{if(r)return;const k=e.retry??(nn?0:3),E=e.retryDelay??Wf,A=typeof E=="function"?E(n,g):E,U=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,g);if(t||!U){p(g);return}n++,e.onFail?.(n,g),$f(A).then(()=>d()?void 0:m()).then(()=>{t?p(g):_()})})};return{promise:i,cancel:a,continue:()=>(s?.(),i),cancelRetry:c,continueRetry:l,canStart:u,start:()=>(u()?_():m().then(_),i)}}var zf=e=>setTimeout(e,0);function Zf(){let e=[],t=0,n=c=>{c()},r=c=>{c()},s=zf;const i=c=>{t?e.push(c):s(()=>{n(c)})},a=()=>{const c=e;e=[],c.length&&s(()=>{r(()=>{c.forEach(l=>{n(l)})})})};return{batch:c=>{let l;t++;try{l=c()}finally{t--,t||a()}return l},batchCalls:c=>(...l)=>{i(()=>{c(...l)})},schedule:i,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{s=c}}}var De=Zf(),$l=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ki(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(nn?1/0:5*60*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},Kf=class extends $l{#t;#e;#n;#r;#s;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Vf(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#s?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const n=Ri(this.state.data,e,this.options);return this.#i({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#s?.promise;return this.#s?.cancel(e),t?t.then(Xe).catch(Xe):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>ot(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ho||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Ol(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#s&&(this.#o?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(l=>l.options.queryFn);c&&this.setOptions(c.options)}const n=new AbortController,r=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},s=()=>{const c=Ml(this.options,t),l={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(l),this.#o=!1,this.options.persister?this.options.persister(c,l,this):c(l)},i={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:s};r(i),this.options.behavior?.onFetch(i,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#i({type:"fetch",meta:i.fetchOptions?.meta});const a=c=>{Gs(c)&&c.silent||this.#i({type:"error",error:c}),Gs(c)||(this.#n.config.onError?.(c,this),this.#n.config.onSettled?.(this.state.data,c,this)),this.scheduleGc()};return this.#s=Ll({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:c=>{if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(l){a(l);return}this.#n.config.onSuccess?.(c,this),this.#n.config.onSettled?.(c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,l)=>{this.#i({type:"failed",failureCount:c,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#s.start()}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Ul(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return Gs(r)&&r.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),De.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function Ul(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Dl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Vf(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Yf=class extends Er{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,s=t.queryHash??po(r,t);let i=this.get(s);return i||(i=new Kf({client:e,queryKey:r,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){De.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>xa(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>xa(e,n)):t}notify(e){De.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){De.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){De.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Qf=class extends $l{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||Jf(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=Ll({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(r,s)=>{this.#r({type:"failed",failureCount:r,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",n=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:n}),await this.#e.config.onMutate?.(e,this);const s=await this.options.onMutate?.(e);s!==this.state.context&&this.#r({type:"pending",context:s,variables:e,isPaused:n})}const r=await this.#n.start();return await this.#e.config.onSuccess?.(r,e,this.state.context,this),await this.options.onSuccess?.(r,e,this.state.context),await this.#e.config.onSettled?.(r,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(r,null,e,this.state.context),this.#r({type:"success",data:r}),r}catch(r){try{throw await this.#e.config.onError?.(r,e,this.state.context,this),await this.options.onError?.(r,e,this.state.context),await this.#e.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,r,e,this.state.context),r}finally{this.#r({type:"error",error:r})}}finally{this.#e.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),De.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function Jf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Xf=class extends Er{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,n){const r=new Qf({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=Dr(e);if(typeof t=="string"){const n=this.#e.get(t);n?n.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=Dr(e);if(typeof t=="string"){const n=this.#e.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Dr(e);if(typeof t=="string"){const r=this.#e.get(t)?.find(s=>s.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=Dr(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){De.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ta(t,n))}findAll(e={}){return this.getAll().filter(t=>Ta(e,t))}notify(e){De.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return De.batch(()=>Promise.all(e.map(t=>t.continue().catch(Xe))))}};function Dr(e){return e.options.scope?.id}function Pa(e){return{onFetch:(t,n)=>{const r=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let c={pages:[],pageParams:[]},l=0;const d=async()=>{let u=!1;const f=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},p=Ml(t.options,t.fetchOptions),m=async(_,h,y)=>{if(u)return Promise.reject();if(h==null&&_.pages.length)return Promise.resolve(_);const g={client:t.client,queryKey:t.queryKey,pageParam:h,direction:y?"backward":"forward",meta:t.options.meta};f(g);const k=await p(g),{maxPages:E}=t.options,A=y?Bf:Ff;return{pages:A(_.pages,k,E),pageParams:A(_.pageParams,h,E)}};if(s&&i.length){const _=s==="backward",h=_?Fl:Ti,y={pages:i,pageParams:a},g=h(r,y);c=await m(y,g,_)}else{const _=e??i.length;do{const h=l===0?a[0]??r.initialPageParam:Ti(r,c);if(l>0&&h==null)break;c=await m(c,h),l++}while(l<_)}return c};t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d}}}function Ti(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Fl(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function dE(e,t){return t?Ti(e,t)!=null:!1}function uE(e,t){return!t||!e.getPreviousPageParam?!1:Fl(e,t)!=null}var qf=class{#t;#e;#n;#r;#s;#a;#o;#i;constructor(e={}){this.#t=e.queryCache||new Yf,this.#e=e.mutationCache||new Xf,this.#n=e.defaultOptions||{},this.#r=new Map,this.#s=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=mo.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#i=qr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#t.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=this.#t.get(r.queryHash)?.state.data,a=Lf(t,i);if(a!==void 0)return this.#t.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return De.batch(()=>this.#t.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;De.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return De.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=De.batch(()=>this.#t.findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Xe).catch(Xe)}invalidateQueries(e,t={}){return De.batch(()=>(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=De.batch(()=>this.#t.findAll(e).filter(s=>!s.isDisabled()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Xe)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Xe)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Xe).catch(Xe)}fetchInfiniteQuery(e){return e.behavior=Pa(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Xe).catch(Xe)}ensureInfiniteQueryData(e){return e.behavior=Pa(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return qr.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(tr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{nr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#s.set(tr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#s.values()],n={};return t.forEach(r=>{nr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=po(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ho&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},ep=class extends Er{constructor(e,t){super(),this.options=t,this.#t=e,this.#i=null,this.#o=xi(),this.options.experimental_prefetchInRender||this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#s;#a;#o;#i;#m;#f;#p;#l;#d;#c;#h=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Oa(this.#e,this.options)?this.#u():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ci(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ci(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ot(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#e.setOptions(this.options),t._defaulted&&!Ei(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&ja(this.#e,n,this.options,t)&&this.#u(),this.updateResult(),r&&(this.#e!==n||ot(this.options.enabled,this.#e)!==ot(t.enabled,this.#e)||bn(this.options.staleTime,this.#e)!==bn(t.staleTime,this.#e))&&this.#g();const s=this.#_();r&&(this.#e!==n||ot(this.options.enabled,this.#e)!==ot(t.enabled,this.#e)||s!==this.#c)&&this.#y(s)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),n=this.createResult(t,e);return np(this,n)&&(this.#r=n,this.#a=this.options,this.#s=this.#e.state),n}getCurrentResult(){return this.#r}trackResult(e,t){const n={};return Object.keys(e).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})}),n}trackProp(e){this.#h.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),n=this.#t.getQueryCache().build(this.#t,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#u({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#u(e){this.#S();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Xe)),t}#g(){this.#b();const e=bn(this.options.staleTime,this.#e);if(nn||this.#r.isStale||!ki(e))return;const n=Ol(this.#r.dataUpdatedAt,e)+1;this.#l=setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#_(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#c=e,!(nn||ot(this.options.enabled,this.#e)===!1||!ki(this.#c)||this.#c===0)&&(this.#d=setInterval(()=>{(this.options.refetchIntervalInBackground||mo.isFocused())&&this.#u()},this.#c))}#v(){this.#g(),this.#y(this.#_())}#b(){this.#l&&(clearTimeout(this.#l),this.#l=void 0)}#w(){this.#d&&(clearInterval(this.#d),this.#d=void 0)}createResult(e,t){const n=this.#e,r=this.options,s=this.#r,i=this.#s,a=this.#a,l=e!==n?e.state:this.#n,{state:d}=e;let u={...d},f=!1,p;if(t._optimisticResults){const I=this.hasListeners(),N=!I&&Oa(e,t),K=I&&ja(e,n,t,r);(N||K)&&(u={...u,...Ul(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:_,status:h}=u;p=u.data;let y=!1;if(t.placeholderData!==void 0&&p===void 0&&h==="pending"){let I;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(I=s.data,y=!0):I=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,I!==void 0&&(h="success",p=Ri(s?.data,I,t),f=!0)}if(t.select&&p!==void 0&&!y)if(s&&p===i?.data&&t.select===this.#m)p=this.#f;else try{this.#m=t.select,p=t.select(p),p=Ri(s?.data,p,t),this.#f=p,this.#i=null}catch(I){this.#i=I}this.#i&&(m=this.#i,p=this.#f,_=Date.now(),h="error");const g=u.fetchStatus==="fetching",k=h==="pending",E=h==="error",A=k&&g,U=p!==void 0,O={status:h,fetchStatus:u.fetchStatus,isPending:k,isSuccess:h==="success",isError:E,isInitialLoading:A,isLoading:A,data:p,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:_,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:g,isRefetching:g&&!k,isLoadingError:E&&!U,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:E&&U,isStale:go(e,t),refetch:this.refetch,promise:this.#o};if(this.options.experimental_prefetchInRender){const I=pe=>{O.status==="error"?pe.reject(O.error):O.data!==void 0&&pe.resolve(O.data)},N=()=>{const pe=this.#o=O.promise=xi();I(pe)},K=this.#o;switch(K.status){case"pending":e.queryHash===n.queryHash&&I(K);break;case"fulfilled":(O.status==="error"||O.data!==K.value)&&N();break;case"rejected":(O.status!=="error"||O.error!==K.reason)&&N();break}}return O}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#s=this.#e.state,this.#a=this.options,this.#s.data!==void 0&&(this.#p=this.#e),Ei(t,e))return;this.#r=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,s=typeof r=="function"?r():r;if(s==="all"||!s&&!this.#h.size)return!0;const i=new Set(s??this.#h);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(a=>{const c=a;return this.#r[c]!==e[c]&&i.has(c)})};this.#k({listeners:n()})}#S(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#k(e){De.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function tp(e,t){return ot(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Oa(e,t){return tp(e,t)||e.state.data!==void 0&&Ci(e,t,t.refetchOnMount)}function Ci(e,t,n){if(ot(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&go(e,t)}return!1}function ja(e,t,n,r){return(e!==t||ot(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&go(e,n)}function go(e,t){return ot(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function np(e,t){return!Ei(e.getCurrentResult(),t)}var _o=S.createContext(void 0),rp=e=>{const t=S.useContext(_o);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},fE=({client:e,children:t})=>(S.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),Mf.jsx(_o.Provider,{value:e,children:t})),Bl=S.createContext(!1),sp=()=>S.useContext(Bl);Bl.Provider;function ip(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var op=S.createContext(ip()),ap=()=>S.useContext(op);function cp(e,t){return typeof e=="function"?e(...t):!!e}function Ma(){}var lp=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},dp=e=>{S.useEffect(()=>{e.clearReset()},[e])},up=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||cp(n,[e.error,r])),fp=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},pp=(e,t)=>e.isLoading&&e.isFetching&&!t,hp=(e,t)=>e?.suspense&&t.isPending,Da=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function mp(e,t,n){const r=rp(n),s=sp(),i=ap(),a=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=s?"isRestoring":"optimistic",fp(a),lp(a,i),dp(i);const c=!r.getQueryCache().get(a.queryHash),[l]=S.useState(()=>new t(r,a)),d=l.getOptimisticResult(a),u=!s&&e.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(f=>{const p=u?l.subscribe(De.batchCalls(f)):Ma;return l.updateResult(),p},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),S.useEffect(()=>{l.setOptions(a)},[a,l]),hp(a,d))throw Da(a,l,i);if(up({result:d,errorResetBoundary:i,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw d.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(a,d),a.experimental_prefetchInRender&&!nn&&pp(d,s)&&(c?Da(a,l,i):r.getQueryCache().get(a.queryHash)?.promise)?.catch(Ma).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?d:l.trackResult(d)}function Gl(e,t){return mp(e,ep,t)}const gp=()=>{const e=S.useContext(_o)??null,t=S.useMemo(()=>new qf({defaultOptions:{queries:{enabled:!1,retry:!1,gcTime:0}}}),[]);return S.useEffect(()=>{if(!e)return()=>t.clear()},[e,t]),S.useMemo(()=>e?{client:e,provided:!0}:{client:t,provided:!1},[e,t])};function pE(e){return e!=="detached"&&e!=="wedged"}function Hl(e){return e!=="governed-elsewhere"&&e!=="pre-handshake"}function hE(e){if(!e)return{title:"Not connected to a Local Operator server.",detail:null,retry:!0};const t=e.addressSubstitution??null;if(t&&e.state!=="detached"&&e.state!=="wedged")return t.kind==="substituted"?{title:`Serving on ${t.serving}, not the address this app is configured for.`,detail:t.holder?`${t.holder}. The app uses ${t.serving} while that holds.${t.reclaim?` ${t.reclaim}`:""} It is back on ${t.configured} on its next launch or recovery.`:`The daemon this app is using was already running, so it did not start one. It looks for ${t.configured} again on its next launch or recovery.`,retry:!0}:{title:`Back on ${t.configured}, the address this app is configured for.`,detail:`It served on ${t.serving} while the configured address was held; it is on the address it was told to use again.`,retry:!1,dismiss:!0};const n=e.detail?.trim()?e.detail.trim():null,r=Hl(e.pairing?.cause??null);switch(e.state){case"wedged":return{title:"A Local Operator server is running on this machine and this app is not attached to it.",detail:n,retry:r};case"detached":return e.reconnecting?{title:r?"Not connected to a Local Operator server. If one is still running, the app reconnects to it on its own.":"Not connected to a Local Operator server.",detail:n,retry:r}:{title:r?"The Local Operator server stopped. The app keeps looking for one and attaches to it when it appears.":"Not connected to a Local Operator server. The app keeps looking for one.",detail:n,retry:r};default:return null}}var re;(function(e){e.assertEqual=s=>s;function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),a={};for(const c of i)a[c]=s[c];return e.objectValues(a)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},e.find=(s,i)=>{for(const a of s)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(re||(re={}));var Ai;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Ai||(Ai={}));const M=re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),kt=e=>{switch(typeof e){case"undefined":return M.undefined;case"string":return M.string;case"number":return isNaN(e)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(e)?M.array:e===null?M.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?M.promise:typeof Map<"u"&&e instanceof Map?M.map:typeof Set<"u"&&e instanceof Set?M.set:typeof Date<"u"&&e instanceof Date?M.date:M.object;default:return M.unknown}},x=re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),_p=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ye extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,l=0;for(;l<a.path.length;){const d=a.path[l];l===a.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(n(a))):c[d]=c[d]||{_errors:[]},c=c[d],l++}}};return s(this),r}static assert(t){if(!(t instanceof Ye))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ye.create=e=>new Ye(e);const In=(e,t)=>{let n;switch(e.code){case x.invalid_type:e.received===M.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case x.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,re.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:n=`Unrecognized key(s) in object: ${re.joinValues(e.keys,", ")}`;break;case x.invalid_union:n="Invalid input";break;case x.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${re.joinValues(e.options)}`;break;case x.invalid_enum_value:n=`Invalid enum value. Expected ${re.joinValues(e.options)}, received '${e.received}'`;break;case x.invalid_arguments:n="Invalid function arguments";break;case x.invalid_return_type:n="Invalid function return type";break;case x.invalid_date:n="Invalid date";break;case x.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:re.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case x.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case x.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case x.custom:n="Invalid input";break;case x.invalid_intersection_types:n="Intersection results could not be merged";break;case x.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case x.not_finite:n="Number must be finite";break;default:n=t.defaultError,re.assertNever(e)}return{message:n}};let Wl=In;function yp(e){Wl=e}function es(){return Wl}const ts=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="";const l=r.filter(d=>!!d).slice().reverse();for(const d of l)c=d(a,{data:t,defaultError:c}).message;return{...s,path:i,message:c}},vp=[];function j(e,t){const n=es(),r=ts({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===In?void 0:In].filter(s=>!!s)});e.common.issues.push(r)}class $e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return W;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return $e.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return W;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const W=Object.freeze({status:"aborted"}),_n=e=>({status:"dirty",value:e}),Ue=e=>({status:"valid",value:e}),Pi=e=>e.status==="aborted",Oi=e=>e.status==="dirty",rn=e=>e.status==="valid",rr=e=>typeof Promise<"u"&&e instanceof Promise;function ns(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function zl(e,t,n,r,s){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var $;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})($||($={}));var Wn,zn;class gt{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Na=(e,t)=>{if(rn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ye(e.common.issues);return this._error=n,this._error}}};function J(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(a,c)=>{var l,d;const{message:u}=e;return a.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:(l=u??r)!==null&&l!==void 0?l:c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:(d=u??n)!==null&&d!==void 0?d:c.defaultError}},description:s}}class X{get description(){return this._def.description}_getType(t){return kt(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:kt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new $e,ctx:{common:t.parent.common,data:t.data,parsedType:kt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(rr(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const s={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:kt(t)},i=this._parseSync({data:t,path:s.path,parent:s});return Na(s,i)}"~validate"(t){var n,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:kt(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:s});return rn(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(n=i?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:s}).then(i=>rn(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:kt(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(rr(s)?s:Promise.resolve(s));return Na(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const a=t(s),c=()=>i.addIssue({code:x.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new lt({schema:this,typeName:G.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ht.create(this,this._def)}nullable(){return Ft.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ct.create(this)}promise(){return xn.create(this,this._def)}or(t){return ar.create([this,t],this._def)}and(t){return cr.create(this,t,this._def)}transform(t){return new lt({...J(this._def),schema:this,typeName:G.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new pr({...J(this._def),innerType:this,defaultValue:n,typeName:G.ZodDefault})}brand(){return new yo({typeName:G.ZodBranded,type:this,...J(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new hr({...J(this._def),innerType:this,catchValue:n,typeName:G.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ir.create(this,t)}readonly(){return mr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const bp=/^c[^\s-]{8,}$/i,wp=/^[0-9a-z]+$/,Sp=/^[0-9A-HJKMNP-TV-Z]{26}$/i,kp=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ep=/^[a-z0-9_-]{21}$/i,Ip=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rp=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xp=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Hs;const Cp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ap=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Pp=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Op=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Mp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Zl="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Dp=new RegExp(`^${Zl}$`);function Kl(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Np(e){return new RegExp(`^${Kl(e)}$`)}function Vl(e){let t=`${Zl}T${Kl(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Lp(e,t){return!!((t==="v4"||!t)&&Cp.test(e)||(t==="v6"||!t)&&Pp.test(e))}function $p(e,t){if(!Ip.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||t&&s.alg!==t)}catch{return!1}}function Up(e,t){return!!((t==="v4"||!t)&&Ap.test(e)||(t==="v6"||!t)&&Op.test(e))}class at extends X{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==M.string){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_type,expected:M.string,received:i.parsedType}),W}const r=new $e;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,c=t.data.length<i.value;(a||c)&&(s=this._getOrReturnCtx(t,s),a?j(s,{code:x.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&j(s,{code:x.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")xp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"email",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Hs||(Hs=new RegExp(Tp,"u")),Hs.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"emoji",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")kp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"uuid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ep.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"nanoid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")bp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"cuid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")wp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"cuid2",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Sp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"ulid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),j(s,{validation:"url",code:x.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"regex",code:x.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Vl(i).test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Dp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Np(i).test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Rp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"duration",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Lp(t.data,i.version)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"ip",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?$p(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"jwt",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Up(t.data,i.version)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"cidr",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?jp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"base64",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Mp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"base64url",code:x.invalid_string,message:i.message}),r.dirty()):re.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:x.invalid_string,...$.errToObj(r)})}_addCheck(t){return new at({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...$.errToObj(t)})}url(t){return this._addCheck({kind:"url",...$.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...$.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...$.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...$.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...$.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...$.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...$.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...$.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...$.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...$.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...$.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...$.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...$.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...$.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...$.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...$.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...$.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...$.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...$.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...$.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...$.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...$.errToObj(n)})}nonempty(t){return this.min(1,$.errToObj(t))}trim(){return new at({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new at({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new at({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}at.create=e=>{var t;return new at({checks:[],typeName:G.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...J(e)})};function Fp(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=parseInt(e.toFixed(s).replace(".","")),a=parseInt(t.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class Lt extends X{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==M.number){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_type,expected:M.number,received:i.parsedType}),W}let r;const s=new $e;for(const i of this._def.checks)i.kind==="int"?re.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),j(r,{code:x.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Fp(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),j(r,{code:x.not_finite,message:i.message}),s.dirty()):re.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,$.toString(n))}gt(t,n){return this.setLimit("min",t,!1,$.toString(n))}lte(t,n){return this.setLimit("max",t,!0,$.toString(n))}lt(t,n){return this.setLimit("max",t,!1,$.toString(n))}setLimit(t,n,r,s){return new Lt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:$.toString(s)}]})}_addCheck(t){return new Lt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:$.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:$.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:$.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:$.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:$.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:$.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:$.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:$.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:$.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&re.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Lt.create=e=>new Lt({checks:[],typeName:G.ZodNumber,coerce:e?.coerce||!1,...J(e)});class $t extends X{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==M.bigint)return this._getInvalidInput(t);let r;const s=new $e;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):re.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return j(n,{code:x.invalid_type,expected:M.bigint,received:n.parsedType}),W}gte(t,n){return this.setLimit("min",t,!0,$.toString(n))}gt(t,n){return this.setLimit("min",t,!1,$.toString(n))}lte(t,n){return this.setLimit("max",t,!0,$.toString(n))}lt(t,n){return this.setLimit("max",t,!1,$.toString(n))}setLimit(t,n,r,s){return new $t({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:$.toString(s)}]})}_addCheck(t){return new $t({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:$.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:$.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:$.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:$.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:$.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}$t.create=e=>{var t;return new $t({checks:[],typeName:G.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...J(e)})};class sr extends X{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==M.boolean){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.boolean,received:r.parsedType}),W}return Ue(t.data)}}sr.create=e=>new sr({typeName:G.ZodBoolean,coerce:e?.coerce||!1,...J(e)});class sn extends X{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==M.date){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_type,expected:M.date,received:i.parsedType}),W}if(isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_date}),W}const r=new $e;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):re.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new sn({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:$.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:$.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}sn.create=e=>new sn({checks:[],coerce:e?.coerce||!1,typeName:G.ZodDate,...J(e)});class rs extends X{_parse(t){if(this._getType(t)!==M.symbol){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.symbol,received:r.parsedType}),W}return Ue(t.data)}}rs.create=e=>new rs({typeName:G.ZodSymbol,...J(e)});class ir extends X{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.undefined,received:r.parsedType}),W}return Ue(t.data)}}ir.create=e=>new ir({typeName:G.ZodUndefined,...J(e)});class or extends X{_parse(t){if(this._getType(t)!==M.null){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.null,received:r.parsedType}),W}return Ue(t.data)}}or.create=e=>new or({typeName:G.ZodNull,...J(e)});class Rn extends X{constructor(){super(...arguments),this._any=!0}_parse(t){return Ue(t.data)}}Rn.create=e=>new Rn({typeName:G.ZodAny,...J(e)});class Xt extends X{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ue(t.data)}}Xt.create=e=>new Xt({typeName:G.ZodUnknown,...J(e)});class Et extends X{_parse(t){const n=this._getOrReturnCtx(t);return j(n,{code:x.invalid_type,expected:M.never,received:n.parsedType}),W}}Et.create=e=>new Et({typeName:G.ZodNever,...J(e)});class ss extends X{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.void,received:r.parsedType}),W}return Ue(t.data)}}ss.create=e=>new ss({typeName:G.ZodVoid,...J(e)});class ct extends X{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==M.array)return j(n,{code:x.invalid_type,expected:M.array,received:n.parsedType}),W;if(s.exactLength!==null){const a=n.data.length>s.exactLength.value,c=n.data.length<s.exactLength.value;(a||c)&&(j(n,{code:a?x.too_big:x.too_small,minimum:c?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(j(n,{code:x.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(j(n,{code:x.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>s.type._parseAsync(new gt(n,a,n.path,c)))).then(a=>$e.mergeArray(r,a));const i=[...n.data].map((a,c)=>s.type._parseSync(new gt(n,a,n.path,c)));return $e.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new ct({...this._def,minLength:{value:t,message:$.toString(n)}})}max(t,n){return new ct({...this._def,maxLength:{value:t,message:$.toString(n)}})}length(t,n){return new ct({...this._def,exactLength:{value:t,message:$.toString(n)}})}nonempty(t){return this.min(1,t)}}ct.create=(e,t)=>new ct({type:e,minLength:null,maxLength:null,exactLength:null,typeName:G.ZodArray,...J(t)});function hn(e){if(e instanceof be){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ht.create(hn(r))}return new be({...e._def,shape:()=>t})}else return e instanceof ct?new ct({...e._def,type:hn(e.element)}):e instanceof ht?ht.create(hn(e.unwrap())):e instanceof Ft?Ft.create(hn(e.unwrap())):e instanceof _t?_t.create(e.items.map(t=>hn(t))):e}class be extends X{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=re.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==M.object){const d=this._getOrReturnCtx(t);return j(d,{code:x.invalid_type,expected:M.object,received:d.parsedType}),W}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const d in s.data)a.includes(d)||c.push(d);const l=[];for(const d of a){const u=i[d],f=s.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new gt(s,f,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof Et){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of c)l.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(d==="strict")c.length>0&&(j(s,{code:x.unrecognized_keys,keys:c}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of c){const f=s.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new gt(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of l){const f=await u.key,p=await u.value;d.push({key:f,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>$e.mergeObjectSync(r,d)):$e.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return $.errToObj,new be({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,i,a,c;const l=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(c=$.errToObj(t).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new be({...this._def,unknownKeys:"strip"})}passthrough(){return new be({...this._def,unknownKeys:"passthrough"})}extend(t){return new be({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new be({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:G.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new be({...this._def,catchall:t})}pick(t){const n={};return re.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new be({...this._def,shape:()=>n})}omit(t){const n={};return re.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new be({...this._def,shape:()=>n})}deepPartial(){return hn(this)}partial(t){const n={};return re.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}),new be({...this._def,shape:()=>n})}required(t){const n={};return re.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ht;)i=i._def.innerType;n[r]=i}}),new be({...this._def,shape:()=>n})}keyof(){return Yl(re.objectKeys(this.shape))}}be.create=(e,t)=>new be({shape:()=>e,unknownKeys:"strip",catchall:Et.create(),typeName:G.ZodObject,...J(t)});be.strictCreate=(e,t)=>new be({shape:()=>e,unknownKeys:"strict",catchall:Et.create(),typeName:G.ZodObject,...J(t)});be.lazycreate=(e,t)=>new be({shape:e,unknownKeys:"strip",catchall:Et.create(),typeName:G.ZodObject,...J(t)});class ar extends X{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;const a=i.map(c=>new Ye(c.ctx.common.issues));return j(n,{code:x.invalid_union,unionErrors:a}),W}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const l of r){const d={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const c=a.map(l=>new Ye(l));return j(n,{code:x.invalid_union,unionErrors:c}),W}}get options(){return this._def.options}}ar.create=(e,t)=>new ar({options:e,typeName:G.ZodUnion,...J(t)});const wt=e=>e instanceof dr?wt(e.schema):e instanceof lt?wt(e.innerType()):e instanceof ur?[e.value]:e instanceof Ut?e.options:e instanceof fr?re.objectValues(e.enum):e instanceof pr?wt(e._def.innerType):e instanceof ir?[void 0]:e instanceof or?[null]:e instanceof ht?[void 0,...wt(e.unwrap())]:e instanceof Ft?[null,...wt(e.unwrap())]:e instanceof yo||e instanceof mr?wt(e.unwrap()):e instanceof hr?wt(e._def.innerType):[];class _s extends X{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.object)return j(n,{code:x.invalid_type,expected:M.object,received:n.parsedType}),W;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(j(n,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const a=wt(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const c of a){if(s.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);s.set(c,i)}}return new _s({typeName:G.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...J(r)})}}function ji(e,t){const n=kt(e),r=kt(t);if(e===t)return{valid:!0,data:e};if(n===M.object&&r===M.object){const s=re.objectKeys(t),i=re.objectKeys(e).filter(c=>s.indexOf(c)!==-1),a={...e,...t};for(const c of i){const l=ji(e[c],t[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(n===M.array&&r===M.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const a=e[i],c=t[i],l=ji(a,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===M.date&&r===M.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class cr extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,a)=>{if(Pi(i)||Pi(a))return W;const c=ji(i.value,a.value);return c.valid?((Oi(i)||Oi(a))&&n.dirty(),{status:n.value,value:c.data}):(j(r,{code:x.invalid_intersection_types}),W)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}cr.create=(e,t,n)=>new cr({left:e,right:t,typeName:G.ZodIntersection,...J(n)});class _t extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.array)return j(r,{code:x.invalid_type,expected:M.array,received:r.parsedType}),W;if(r.data.length<this._def.items.length)return j(r,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W;!this._def.rest&&r.data.length>this._def.items.length&&(j(r,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new gt(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>$e.mergeArray(n,a)):$e.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new _t({...this._def,rest:t})}}_t.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _t({items:e,typeName:G.ZodTuple,rest:null,...J(t)})};class lr extends X{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.object)return j(r,{code:x.invalid_type,expected:M.object,received:r.parsedType}),W;const s=[],i=this._def.keyType,a=this._def.valueType;for(const c in r.data)s.push({key:i._parse(new gt(r,c,r.path,c)),value:a._parse(new gt(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?$e.mergeObjectAsync(n,s):$e.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof X?new lr({keyType:t,valueType:n,typeName:G.ZodRecord,...J(r)}):new lr({keyType:at.create(),valueType:t,typeName:G.ZodRecord,...J(n)})}}class is extends X{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.map)return j(r,{code:x.invalid_type,expected:M.map,received:r.parsedType}),W;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,l],d)=>({key:s._parse(new gt(r,c,r.path,[d,"key"])),value:i._parse(new gt(r,l,r.path,[d,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of a){const d=await l.key,u=await l.value;if(d.status==="aborted"||u.status==="aborted")return W;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}})}else{const c=new Map;for(const l of a){const d=l.key,u=l.value;if(d.status==="aborted"||u.status==="aborted")return W;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}}}}is.create=(e,t,n)=>new is({valueType:t,keyType:e,typeName:G.ZodMap,...J(n)});class on extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.set)return j(r,{code:x.invalid_type,expected:M.set,received:r.parsedType}),W;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(j(r,{code:x.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(j(r,{code:x.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function a(l){const d=new Set;for(const u of l){if(u.status==="aborted")return W;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}const c=[...r.data.values()].map((l,d)=>i._parse(new gt(r,l,r.path,d)));return r.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(t,n){return new on({...this._def,minSize:{value:t,message:$.toString(n)}})}max(t,n){return new on({...this._def,maxSize:{value:t,message:$.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}on.create=(e,t)=>new on({valueType:e,minSize:null,maxSize:null,typeName:G.ZodSet,...J(t)});class wn extends X{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.function)return j(n,{code:x.invalid_type,expected:M.function,received:n.parsedType}),W;function r(c,l){return ts({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,es(),In].filter(d=>!!d),issueData:{code:x.invalid_arguments,argumentsError:l}})}function s(c,l){return ts({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,es(),In].filter(d=>!!d),issueData:{code:x.invalid_return_type,returnTypeError:l}})}const i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof xn){const c=this;return Ue(async function(...l){const d=new Ye([]),u=await c._def.args.parseAsync(l,i).catch(m=>{throw d.addIssue(r(l,m)),d}),f=await Reflect.apply(a,this,u);return await c._def.returns._def.type.parseAsync(f,i).catch(m=>{throw d.addIssue(s(f,m)),d})})}else{const c=this;return Ue(function(...l){const d=c._def.args.safeParse(l,i);if(!d.success)throw new Ye([r(l,d.error)]);const u=Reflect.apply(a,this,d.data),f=c._def.returns.safeParse(u,i);if(!f.success)throw new Ye([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new wn({...this._def,args:_t.create(t).rest(Xt.create())})}returns(t){return new wn({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new wn({args:t||_t.create([]).rest(Xt.create()),returns:n||Xt.create(),typeName:G.ZodFunction,...J(r)})}}class dr extends X{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}dr.create=(e,t)=>new dr({getter:e,typeName:G.ZodLazy,...J(t)});class ur extends X{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return j(n,{received:n.data,code:x.invalid_literal,expected:this._def.value}),W}return{status:"valid",value:t.data}}get value(){return this._def.value}}ur.create=(e,t)=>new ur({value:e,typeName:G.ZodLiteral,...J(t)});function Yl(e,t){return new Ut({values:e,typeName:G.ZodEnum,...J(t)})}class Ut extends X{constructor(){super(...arguments),Wn.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return j(n,{expected:re.joinValues(r),received:n.parsedType,code:x.invalid_type}),W}if(ns(this,Wn)||zl(this,Wn,new Set(this._def.values)),!ns(this,Wn).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return j(n,{received:n.data,code:x.invalid_enum_value,options:r}),W}return Ue(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Ut.create(t,{...this._def,...n})}exclude(t,n=this._def){return Ut.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Wn=new WeakMap;Ut.create=Yl;class fr extends X{constructor(){super(...arguments),zn.set(this,void 0)}_parse(t){const n=re.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==M.string&&r.parsedType!==M.number){const s=re.objectValues(n);return j(r,{expected:re.joinValues(s),received:r.parsedType,code:x.invalid_type}),W}if(ns(this,zn)||zl(this,zn,new Set(re.getValidEnumValues(this._def.values))),!ns(this,zn).has(t.data)){const s=re.objectValues(n);return j(r,{received:r.data,code:x.invalid_enum_value,options:s}),W}return Ue(t.data)}get enum(){return this._def.values}}zn=new WeakMap;fr.create=(e,t)=>new fr({values:e,typeName:G.ZodNativeEnum,...J(t)});class xn extends X{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.promise&&n.common.async===!1)return j(n,{code:x.invalid_type,expected:M.promise,received:n.parsedType}),W;const r=n.parsedType===M.promise?n.data:Promise.resolve(n.data);return Ue(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}xn.create=(e,t)=>new xn({type:e,typeName:G.ZodPromise,...J(t)});class lt extends X{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===G.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:a=>{j(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return W;const l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?W:l.status==="dirty"||n.value==="dirty"?_n(l.value):l});{if(n.value==="aborted")return W;const c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?W:c.status==="dirty"||n.value==="dirty"?_n(c.value):c}}if(s.type==="refinement"){const a=c=>{const l=s.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?W:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?W:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!rn(a))return a;const c=s.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>rn(a)?Promise.resolve(s.transform(a.value,i)).then(c=>({status:n.value,value:c})):a);re.assertNever(s)}}lt.create=(e,t,n)=>new lt({schema:e,typeName:G.ZodEffects,effect:t,...J(n)});lt.createWithPreprocess=(e,t,n)=>new lt({schema:t,effect:{type:"preprocess",transform:e},typeName:G.ZodEffects,...J(n)});class ht extends X{_parse(t){return this._getType(t)===M.undefined?Ue(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ht.create=(e,t)=>new ht({innerType:e,typeName:G.ZodOptional,...J(t)});class Ft extends X{_parse(t){return this._getType(t)===M.null?Ue(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ft.create=(e,t)=>new Ft({innerType:e,typeName:G.ZodNullable,...J(t)});class pr extends X{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===M.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}pr.create=(e,t)=>new pr({innerType:e,typeName:G.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...J(t)});class hr extends X{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return rr(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ye(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ye(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}hr.create=(e,t)=>new hr({innerType:e,typeName:G.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...J(t)});class os extends X{_parse(t){if(this._getType(t)!==M.nan){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.nan,received:r.parsedType}),W}return{status:"valid",value:t.data}}}os.create=e=>new os({typeName:G.ZodNaN,...J(e)});const Bp=Symbol("zod_brand");class yo extends X{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Ir extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?W:i.status==="dirty"?(n.dirty(),_n(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?W:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new Ir({in:t,out:n,typeName:G.ZodPipeline})}}class mr extends X{_parse(t){const n=this._def.innerType._parse(t),r=s=>(rn(s)&&(s.value=Object.freeze(s.value)),s);return rr(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}mr.create=(e,t)=>new mr({innerType:e,typeName:G.ZodReadonly,...J(t)});function La(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Ql(e,t={},n){return e?Rn.create().superRefine((r,s)=>{var i,a;const c=e(r);if(c instanceof Promise)return c.then(l=>{var d,u;if(!l){const f=La(t,r),p=(u=(d=f.fatal)!==null&&d!==void 0?d:n)!==null&&u!==void 0?u:!0;s.addIssue({code:"custom",...f,fatal:p})}});if(!c){const l=La(t,r),d=(a=(i=l.fatal)!==null&&i!==void 0?i:n)!==null&&a!==void 0?a:!0;s.addIssue({code:"custom",...l,fatal:d})}}):Rn.create()}const Gp={object:be.lazycreate};var G;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(G||(G={}));const Hp=(e,t={message:`Input not instance of ${e.name}`})=>Ql(n=>n instanceof e,t),Jl=at.create,Xl=Lt.create,Wp=os.create,zp=$t.create,ql=sr.create,Zp=sn.create,Kp=rs.create,Vp=ir.create,Yp=or.create,Qp=Rn.create,Jp=Xt.create,Xp=Et.create,qp=ss.create,eh=ct.create,th=be.create,nh=be.strictCreate,rh=ar.create,sh=_s.create,ih=cr.create,oh=_t.create,ah=lr.create,ch=is.create,lh=on.create,dh=wn.create,uh=dr.create,fh=ur.create,ph=Ut.create,hh=fr.create,mh=xn.create,$a=lt.create,gh=ht.create,_h=Ft.create,yh=lt.createWithPreprocess,vh=Ir.create,bh=()=>Jl().optional(),wh=()=>Xl().optional(),Sh=()=>ql().optional(),kh={string:e=>at.create({...e,coerce:!0}),number:e=>Lt.create({...e,coerce:!0}),boolean:e=>sr.create({...e,coerce:!0}),bigint:e=>$t.create({...e,coerce:!0}),date:e=>sn.create({...e,coerce:!0})},Eh=W;var o=Object.freeze({__proto__:null,defaultErrorMap:In,setErrorMap:yp,getErrorMap:es,makeIssue:ts,EMPTY_PATH:vp,addIssueToContext:j,ParseStatus:$e,INVALID:W,DIRTY:_n,OK:Ue,isAborted:Pi,isDirty:Oi,isValid:rn,isAsync:rr,get util(){return re},get objectUtil(){return Ai},ZodParsedType:M,getParsedType:kt,ZodType:X,datetimeRegex:Vl,ZodString:at,ZodNumber:Lt,ZodBigInt:$t,ZodBoolean:sr,ZodDate:sn,ZodSymbol:rs,ZodUndefined:ir,ZodNull:or,ZodAny:Rn,ZodUnknown:Xt,ZodNever:Et,ZodVoid:ss,ZodArray:ct,ZodObject:be,ZodUnion:ar,ZodDiscriminatedUnion:_s,ZodIntersection:cr,ZodTuple:_t,ZodRecord:lr,ZodMap:is,ZodSet:on,ZodFunction:wn,ZodLazy:dr,ZodLiteral:ur,ZodEnum:Ut,ZodNativeEnum:fr,ZodPromise:xn,ZodEffects:lt,ZodTransformer:lt,ZodOptional:ht,ZodNullable:Ft,ZodDefault:pr,ZodCatch:hr,ZodNaN:os,BRAND:Bp,ZodBranded:yo,ZodPipeline:Ir,ZodReadonly:mr,custom:Ql,Schema:X,ZodSchema:X,late:Gp,get ZodFirstPartyTypeKind(){return G},coerce:kh,any:Qp,array:eh,bigint:zp,boolean:ql,date:Zp,discriminatedUnion:sh,effect:$a,enum:ph,function:dh,instanceof:Hp,intersection:ih,lazy:uh,literal:fh,map:ch,nan:Wp,nativeEnum:hh,never:Xp,null:Yp,nullable:_h,number:Xl,object:th,oboolean:Sh,onumber:wh,optional:gh,ostring:bh,pipeline:vh,preprocess:yh,promise:mh,record:ah,set:lh,strictObject:nh,string:Jl,symbol:Kp,transformer:$a,tuple:oh,undefined:Vp,union:rh,unknown:Jp,void:qp,NEVER:Eh,ZodIssueCode:x,quotelessJson:_p,ZodError:Ye});const Ua=o.enum(["app_start","sign_in","window_focus","surface_open"]),ed=o.object({id:o.string().min(1),state:o.enum(["active","paused","disabled"])}).passthrough(),Ih=o.object({tenant_id:o.string().min(1),tenant_name:o.string().optional(),eligible:o.boolean(),endpoint:ed.nullable()}).passthrough(),Rh=o.object({code:o.string(),message:o.string(),details:o.record(o.unknown()).optional(),retry_after_seconds:o.number().optional()}).passthrough(),xh=o.object({code:o.string().min(1),count:o.number().int().nonnegative(),session:o.string().min(1).nullable().optional().catch(null)}).passthrough().nullable().optional().catch(null),Th=o.object({in_force:o.boolean(),notice_pending:o.boolean().catch(!1)}).passthrough().optional().catch(void 0),mE=o.object({capability:o.number(),consent_account_guard:o.boolean().optional(),state:o.enum(["ready","signed_out","unavailable","update_required"]),account_id:o.string().nullable(),tenant_id:o.string().nullable(),surface_state:o.enum(["A","B","C","D","E","F","G"]).nullable(),visibility:o.object({settings:o.boolean(),inbox:o.boolean(),account_door:o.boolean(),onboarding:o.boolean()}),update_required:o.boolean(),local:o.object({enabled:o.boolean(),onboarding:o.string(),session:o.string()}),status:o.object({tenants:o.array(Ih)}).passthrough().nullable(),consent:o.object({version:o.string().min(1).max(128),text:o.string().min(1).refine(e=>new TextEncoder().encode(e).length<=2048,"Consent exceeds the served-text contract"),source:o.enum(["served","cached","embedded"])}).nullable(),error:Rh.nullable(),state_note:o.string().nullable().optional(),read_only:o.boolean().optional(),delivery_hold:xh,default_on:Th}).passthrough(),Ch=o.object({version:o.string().min(1),consented_at:o.string().min(1),consented_via:o.string().min(1),current:o.boolean()}).passthrough(),gE=o.object({endpoint:ed.extend({tenant_id:o.string().min(1),label:o.string().optional(),consent:Ch.nullable().optional(),created_at:o.string().optional(),updated_at:o.string().optional()}).nullable(),settings:o.object({tenant_id:o.string().min(1),eligible:o.boolean(),consent_version:o.string().optional(),consent_required:o.boolean()}).passthrough(),default_on:o.boolean().optional().catch(void 0)}).passthrough(),Ah=o.object({kind:o.enum(["endpoint","account"]).optional(),endpoint_id:o.string().min(1).optional(),account_id:o.string().min(1).optional()}).passthrough().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id").refine(e=>e.kind===void 0||(e.kind==="endpoint"?e.endpoint_id!==void 0:e.account_id!==void 0),"An allowlist target's kind must agree with the id it carries"),Fa=o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:Ah,id:o.string().optional()}).passthrough(),Ba=o.object({mode:o.enum(["class_default","listed_only"]),allow:o.number(),deny:o.number()}).passthrough(),_E=o.object({allowlist:o.object({tenant_id:o.string().min(1),entries:o.array(Fa)}).passthrough(),view:o.object({tenant_id:o.string().nullable(),entries:o.array(Fa),directions:o.object({send:Ba,receive:Ba}),class_default:o.literal("cos_cos"),cues:o.object({allow_entry_switches_direction_to_listed_only:o.boolean(),listed_only_affects:o.string(),removing_allow_does_not_stop_open_thread:o.boolean(),deny_stops_pair_both_directions:o.boolean()}).passthrough()}).passthrough()}).passthrough(),yE=o.object({onboarding:o.literal("seen")}).passthrough();function Ph(e){return e?.default_on?.in_force===!0}function vE(e,t){const n=Oh(e),r=t?.endpoint?.consent?.version;return n&&r&&n.version===r?n.text:null}function bE(e,t){return e?.surface_state==="C"&&t?.default_on===!0&&t.endpoint?.state==="active"&&e.default_on?.notice_pending===!0}function wE(e,t){if(!e||!t||Ph(e)||e.account_id!==t||e.capability<1||e.state!=="ready"||e.update_required||e.surface_state!=="B"||!e.visibility.onboarding||!e.tenant_id)return null;const n=e.status?.tenants.filter(r=>r.tenant_id===e.tenant_id);return n?.length!==1||n[0].eligible!==!0||n[0].endpoint!==null?null:{accountId:t,tenantId:e.tenant_id}}function Oh(e){const t=e?.consent;return t&&(t.source==="served"||t.source==="cached")?t:null}const jh=8,Mi=["aida","library","projects","agents","schedules","browser","team-bridge","agent-hub","mesh","notifications"],Mh=6*1024,Dh=512;function as(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const s=[];for(const i of n){if(s.length===Dh)break;const c=new URLSearchParams({order_ids:i}).toString().length+1;if(r+c>Mh)break;e.append("order_ids",i),s.push(i),r+=c}return s}function Nh(e,t,n){return as(new URLSearchParams(n),t,e)}const b=o.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),Nr=o.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Lr=o.string().min(1).max(32768),Lh=/^[a-f0-9]{12}$/,L=o.string().regex(Lh),Ws=o.string().regex(/^[a-f0-9]{12}$/),zs=o.string().min(1).max(128),$h=o.string().min(1).max(4096),Nn=o.string().min(1).max(128).regex(/^[A-Za-z0-9_.-]+$/),Zs=o.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),$r=o.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),Ga=o.string().regex(/^[a-f0-9]{32}$/),Uh=/^(\/|[A-Za-z]:[\\/])/,Ks=o.string().min(1).max(4096).regex(Uh),Ha=/^[a-f0-9]{32}$/,te=o.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Wa=o.string().min(1).max(512).nullish(),fn=o.string().regex(/^[A-Za-z0-9_-]{1,128}$/),za=o.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),Ln=o.string().regex(/^la_[0-9a-f]{16}$/),$n=o.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/),Za=o.object({data_b64:o.string().min(1).max(1e6),mime_type:o.enum(["image/png","image/jpeg","image/gif","image/webp"]),origin_path:o.string().max(4096).optional()}).strict(),Fh=o.object({digest:o.string().regex(/^[0-9a-f]{32}$/),name:o.string().max(1024).optional(),mime_type:o.string().max(255).optional(),bytes:o.number().int().min(0).optional(),path:o.string().max(4096).optional()}).strict(),Ka=2e5,Va=8,Bh=256,Gh=100,Ya=16,Hh=256,Wh=100,zh=200,Zh=1e6,Kh=o.enum(["auto","none","minimal","low","medium","high","xhigh","max"]),Me=o.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),Ur=o.object({kind:o.enum(["agent","team"]),name:Me}).strict(),td=o.enum(["claude","codex","omp"]),Vh=o.record(o.string(),o.array(o.string().min(1).max(512)).max(5e3)),Qa={sources:o.array(td).max(3).optional(),sessionIds:Vh.optional(),all:o.boolean().optional(),includeSubagents:o.boolean().optional(),includeClearedSegments:o.boolean().optional(),includeMemory:o.boolean().optional(),includeInstructions:o.boolean().optional(),maxSessions:o.number().int().min(1).max(5e3).optional()},Vs=o.object({provider:o.string().min(1).max(128),model_id:o.string().min(1).max(512),reasoning_effort:o.string().min(1).max(64).nullable(),fast_mode:o.boolean().nullable().optional()}).strict(),Ja=o.object({kind:o.enum(["role","specialist"]).optional(),description:o.string().max(8e3).optional(),instructions:o.string().max(8e3).optional(),tools:o.array(o.string().min(1).max(128)).max(256).optional(),effort:o.string().max(64).optional(),delegate:o.boolean().optional(),action_class:o.enum(["reactive","proactive"]).optional()}).strict(),Xa=o.object({name:o.string().min(1).max(64).optional(),description:o.string().max(8e3).optional(),manager:Me.optional(),members:o.array(o.object({role:Me,count:o.number().int().min(1).max(16),kind:o.enum(["agent","team"]),tier:o.enum(["lo","med","hi"]).nullable().optional(),effort:Kh.nullable().optional()}).strict()).max(128).optional(),instructions:o.string().max(8e3).optional(),project:o.string().max(8e3).optional()}).strict(),Yh=o.record(o.array(o.string().max(1024)).max(100)),Ys=o.array(b).max(4).refine(e=>new Set(e).size===e.length,"Duplicate attachment"),qa=o.enum(["minutes","hours","days"]);function Qh(e){return!/^\.+$/.test(e)}const SE=e=>Yr.safeParse(e).success,Yr=o.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(Qh),ec=o.enum(["str","int","float","bool","list","dict"]),tc=o.string().max(16384),Jh=2e3,nc=o.string().min(1).max(Jh),rc=o.string().min(1).max(64),Xh=o.string().min(1).max(64),qh=o.string().min(1).max(64),sc=o.object({is_active:o.boolean().nullish(),one_time:o.boolean().nullish(),start_time_utc:o.string().max(64).nullish(),end_time_utc:o.string().max(64).nullish()}).strict(),em=o.object({conversation_length:o.number().int().optional(),detail_length:o.number().int().optional(),max_learnings_history:o.number().int().optional(),hosting:o.string().max(256).optional(),model_name:o.string().max(1024).optional(),auto_save_conversation:o.boolean().optional()}).strict(),Di=128,ic=2e3,oc=8e3,ac=64,cc=64,ys=e=>[...e].length,Ni=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,tm=e=>e===9||e===10||e===11||e===12||e===13||e===133,nm=e=>e<=31||e>=127&&e<=159,rm=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),sm=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,Fr=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},nd=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&Ni(t[n].codePointAt(0)??0);)n++;for(;r>n&&Ni(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},im=e=>{let t="",n=!1;for(const r of e){if(Ni(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function om(e){const t=nd(e);if(!t)return"must not be empty";if(ys(t)>Di)return`must be at most ${Di} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(Fr(t,sm))return"must not contain Unicode bidirectional override characters";if(Fr(t,tm))return"must not contain whitespace";if(Fr(t,nm))return"must not contain control characters";if(Fr(t,rm))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function kE(e){return im(nd(e).normalize("NFKC").toLowerCase())}function am(e){return e.trim()?ys(e)>ic?`must be at most ${ic} characters`:null:"must not be empty"}function cm(e){return e.trim()?ys(e)>oc?`must be at most ${oc} characters`:null:"must not be empty"}function lm(e){if(e.length>cc)return`must hold at most ${cc} items`;for(const t of e)if(!t.trim()||ys(t)>ac)return`must hold items of 1 to ${ac} characters`;return null}const dm=e=>om(e)===null,um=o.string().refine(dm,{message:"That is not a name the hub can publish."}),fm=o.string().refine(e=>cm(e)===null,{message:"That instruction body cannot be published."}),pm=o.string().refine(e=>am(e)===null,{message:"That description cannot be published."}),hm=o.array(o.string()).refine(e=>lm(e)===null,{message:"That tool list cannot be published."}),Qs={requestId:te.optional(),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()},lc=o.object({name:um,description:pm,instructions:fm,kind:o.enum(["role","specialist"]),when_to_use:o.string(),tools:hm,effort:o.string(),delegate:o.boolean(),version:o.string(),categories:o.array(o.string()),tags:o.array(o.string())}).partial().strict(),mm=o.enum(["team","agent"]),gm=o.string().min(1).max(64),_m=o.string().min(1).max(256),rd=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,Js=o.string().regex(rd,{message:"Letters, digits, dot, underscore and dash; no spaces."}),ym=["planning","active","qa","validation","done","paused","archived"],dc=o.enum(ym),Br=o.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),uc=o.array(o.string().min(1).max(24)).max(8),Ot=o.string().min(1).max(64),vm=1e3,fc=240,pc=80,bm=256,wm=100,Sm=200,km=/^[a-z0-9][a-z0-9_-]{0,23}$/;function EE(e){return e?rd.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function IE(e){return km.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Gr=o.enum(["agent","team","skill"]),Xs=o.string().min(1).max(128).regex(/\S/),hc=o.enum(Mi),Em=o.object({visible:o.array(hc).max(Mi.length),more:o.array(hc).max(Mi.length)}).strict(),Qn=o.string().min(3).max(256).regex(/^(?:n_[a-z2-7]{4,32}|ask:[A-Za-z0-9_-]+:[A-Za-z0-9_-]+)$/),mc=o.union([o.object({items:o.array(o.object({id:Qn,revision:o.number().int().min(1)}).strict()).min(1).max(500)}).strict(),o.object({sessionId:L,throughSeq:o.number().int().min(0),observed:o.array(o.object({id:Qn,revision:o.number().int().min(1)}).strict()).max(500)}).strict(),o.object({all:o.literal(!0),throughSeq:o.number().int().min(0),observed:o.array(o.object({id:Qn,revision:o.number().int().min(1)}).strict()).max(500)}).strict()]),Im={pointer:"pointerdown",key:"keydown",wheel:"wheel"},Rm=o.discriminatedUnion("op",[o.object({op:o.literal("capabilities")}).strict(),o.object({op:o.literal("runtimes.list")}).strict(),o.object({op:o.literal("profiles.list")}).strict(),o.object({op:o.literal("profiles.get"),name:Me}).strict(),o.object({op:o.literal("imports.sources")}).strict(),o.object({op:o.literal("imports.sessions"),source:td,includeSubagents:o.boolean().optional()}).strict(),o.object({op:o.literal("imports.preview"),...Qa}).strict(),o.object({op:o.literal("imports.start"),...Qa}).strict(),o.object({op:o.literal("imports.status"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("imports.cancel"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("profiles.update"),name:Me,requestId:te,fields:Ja,expectedDefinitionRevision:Wa.optional()}).strict(),o.object({op:o.literal("profiles.install"),name:Me,requestId:te}).strict(),o.object({op:o.literal("profiles.create"),name:Me,requestId:te,fields:Ja.extend({description:o.string().max(8e3),instructions:o.string().min(1).max(8e3)})}).strict(),o.object({op:o.literal("hub.updates")}).strict(),o.object({op:o.literal("hub.skillPull"),requestId:te,hubId:b,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:b.nullable(),localAlias:Me,subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.skillSubscribe"),requestId:te,hubId:b,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:b.nullable(),localAlias:Me}).strict(),o.object({op:o.literal("hub.skillUnpull"),requestId:te,linkId:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("hub.skillPublish"),requestId:te,dryRun:o.boolean(),sourceSkill:Me,localAlias:Me,visibility:o.enum(["public","org"]),tenantId:b.nullable(),subscribe:o.boolean(),autoPush:o.boolean(),confirmPublicEgress:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("hub.links"),kind:o.enum(["agent","team","skill"]).optional()}).strict(),o.object({op:o.literal("hub.policy"),requestId:te,linkId:o.string().min(1).max(256),expectedPolicyRevision:o.string().min(1).max(256),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.check"),requestId:te,kind:Gr.optional(),name:Me.optional(),localId:Xs.optional()}).strict(),o.object({op:o.literal("hub.apply"),requestId:te,kind:Gr.optional(),name:Me.optional(),localId:Xs.optional(),prefer:o.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:o.boolean().optional(),dryRun:o.boolean().optional(),resolveSource:o.literal(!0).optional(),hubSource:o.string().min(1).max(2048).optional(),visibility:o.enum(["public","org"]).optional(),tenantId:o.string().min(1).max(128).nullable().optional()}).strict(),o.object({op:o.literal("hub.applyAll"),requestId:te,kind:Gr.optional()}).strict(),o.object({op:o.literal("hub.retry"),requestId:te,kind:Gr.optional(),name:Me.optional(),localId:Xs.optional()}).strict(),o.object({op:o.literal("hub.push"),requestId:te,linkId:o.string().min(1).max(256),direction:o.literal("push"),dryRun:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("teams.list")}).strict(),o.object({op:o.literal("teams.get"),name:Me}).strict(),o.object({op:o.literal("teams.effective"),name:Me}).strict(),o.object({op:o.literal("teams.update"),name:Me,requestId:te,fields:Xa,expectedDefinitionRevision:Wa.optional()}).strict(),o.object({op:o.literal("teams.create"),requestId:te,fields:Xa.extend({name:o.string().min(1).max(64)})}).strict(),o.object({op:o.literal("sessions.list"),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional(),include_peers:o.boolean().optional(),scope_kind:mm.optional(),scope_name:gm.optional(),cursor:_m.optional(),with_counts:o.boolean().optional(),sort:o.literal("activity").optional()}).strict(),o.object({op:o.literal("delegated_cleanup_notice.ack")}).strict(),o.object({op:o.literal("sessions.search"),q:o.string().min(1).max(Bh),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.archive"),sessionId:L,archived:o.boolean()}).strict(),o.object({op:o.literal("sessions.delete"),sessionId:L,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.create"),requestId:te,cwd:o.string().min(1).max(4096).optional(),target:Ur.optional(),purpose:o.literal("agents-config").optional(),model:Vs.optional(),draftId:L.optional(),peer:fn.optional()}).strict(),o.object({op:o.literal("sessions.preview"),requestId:te,cwd:o.string().min(1).max(4096),target:Ur.optional(),model:Vs.optional()}).strict(),o.object({op:o.literal("sessions.draft"),requestId:te,cwd:o.string().min(1).max(4096),target:Ur.optional(),model:Vs.optional()}).strict(),o.object({op:o.literal("sessions.get"),sessionId:L,journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.files"),sessionId:L,scope:o.enum(["family","self"]).optional(),kind:o.string().max(256).optional(),q:o.string().max(256).optional(),sort:o.enum(["recent","name","kind","modified","created","size"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(8192).optional()}).strict(),o.object({op:o.literal("sessions.files.materialise"),sessionId:L,fileId:o.string().regex(/^[a-f0-9]{16}$/)}).strict(),o.object({op:o.literal("sessions.userAttachments"),sessionId:L}).strict(),o.object({op:o.literal("sessions.userAttachments.materialise"),sessionId:L,digest:o.string().regex(/^[a-f0-9]{32}$/)}).strict(),o.object({op:o.literal("sessions.history"),sessionId:L,beforeId:b.optional(),limit:o.number().int().min(1).max(500).optional(),openFrame:o.boolean().optional(),journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional(),sourceRead:o.enum(["metadata","payload"]).optional(),expectedJournalGeneration:o.string().min(1).max(128).optional()}).strict(),o.object({op:o.literal("sessions.checkpoints"),sessionId:L}).strict(),o.object({op:o.literal("sessions.checkpoints.warm"),sessionId:L,ids:o.array(b).max(Ya).optional(),limit:o.number().int().min(1).max(Ya).optional()}).strict(),o.object({op:o.literal("sessions.find"),sessionId:L,q:o.string().min(1).max(Hh),limit:o.number().int().min(1).max(zh).optional()}).strict(),o.object({op:o.literal("subagents.transcript"),sessionId:L,childId:L,beforeId:b.optional(),limit:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("sessions.message"),sessionId:L,requestId:te,text:o.string().max(Ka),images:o.array(Za).max(Va).optional(),files:o.array(Fh).max(jh).optional(),mode:o.enum(["prompt","steer"]).optional(),inputMode:o.enum(["typed","dictated","mixed"]).optional(),inputPath:o.string().max(1024).optional()}).strict(),o.object({op:o.literal("sessions.command"),sessionId:L,requestId:te,command:o.string().regex(/^\/?[A-Za-z]+$/).max(64),args:o.string().max(Ka).optional(),images:o.array(Za).max(Va).optional()}).strict(),o.object({op:o.literal("sessions.move"),sessionId:L,requestId:te,cwd:o.string().min(1).max(4096)}).strict(),o.object({op:o.literal("sessions.answer"),sessionId:L,epoch:b.optional(),requestId:b.optional(),value:o.string().max(32768).optional(),approved:o.boolean().optional(),questionIndex:o.number().int().min(0).optional(),askId:b.optional(),answers:o.record(o.string(),o.array(o.string().max(32768))).optional(),decline:o.boolean().optional(),revise:o.boolean().optional(),dismiss:o.boolean().optional(),reason:o.enum(["answered_in_chat","moot"]).optional()}).strict(),o.object({op:o.literal("sessions.seen"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("attention.seen"),items:o.array(o.object({sessionId:L,completionToken:o.string().uuid()}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("sessions.notified"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("tags.list")}).strict(),o.object({op:o.literal("tags.replace"),tags:o.array(o.object({id:o.string().optional(),name:o.string()}).strict())}).strict(),o.object({op:o.literal("sessions.tags"),expected_revision:o.string().optional(),sessionId:L,tags:o.array(o.string()),primary:o.string().nullable()}).strict(),o.object({op:o.literal("sessions.pin"),sessionId:L,pinned:o.boolean()}).strict(),o.object({op:o.literal("sessions.watch"),sessionId:L,subscriptionId:o.string().regex(Ha),visible:o.boolean(),canNotify:o.boolean()}).strict(),o.object({op:o.literal("sessions.warm"),sessionId:L}).strict(),o.object({op:o.literal("sessions.interrupt"),sessionId:L,requestId:te}).strict(),o.object({op:o.literal("supplements.cancel"),sessionId:L,job:Ws,anchor:zs}).strict(),o.object({op:o.literal("supplements.restart"),sessionId:L,job:Ws,anchor:zs}).strict(),o.object({op:o.literal("supplements.steer"),sessionId:L,job:Ws,anchor:zs,text:o.string().min(1).max(500)}).strict(),o.object({op:o.literal("sessions.variables.list"),sessionId:L}).strict(),o.object({op:o.literal("sessions.variables.create"),sessionId:L,key:Yr,value:tc,type:ec}).strict(),o.object({op:o.literal("sessions.variables.update"),sessionId:L,key:Yr,value:tc,type:ec}).strict(),o.object({op:o.literal("sessions.variables.delete"),sessionId:L,key:Yr}).strict(),o.object({op:o.literal("sessions.presence"),subscriptionId:o.string().regex(/^[a-f0-9]{1,64}$/),canNotify:o.boolean(),canNotifyKinds:o.array(o.enum(["complete","error"])).max(4),sessionId:o.string().regex(/^([a-f0-9]{12})?$/),window:o.object({exists:o.boolean(),focused:o.boolean(),visible:o.boolean(),minimized:o.boolean()}).strict()}).strict(),o.object({op:o.literal("legacy.models"),provider:o.string().max(128).optional(),sort:o.enum(["id","name","provider","recommended"]).optional(),direction:o.enum(["ascending","descending"]).optional()}).strict(),o.object({op:o.literal("legacy.models.providers")}).strict(),o.object({op:o.literal("auth.probe"),provider:b}).strict(),o.object({op:o.literal("legacy.agent.upload"),agentId:b}).strict(),o.object({op:o.literal("agent.publish"),agentId:b,document:lc.optional(),...Qs,visibility:o.literal("org").optional(),tenantId:b.optional()}).strict(),o.object({op:o.literal("agent.republish"),agentId:b,hubAgentId:b,expectedRemoteRevision:o.string().min(1).max(512).optional(),document:lc.optional(),...Qs,visibility:o.literal("org").optional(),tenantId:b.optional()}).strict(),o.object({op:o.literal("team.publish"),teamId:b,...Qs,visibility:o.literal("org").optional(),tenantId:b.optional()}).strict(),o.object({op:o.literal("team.pull"),teamId:b,tenantId:b.optional()}).strict(),o.object({op:o.literal("agent.nameAvailability"),name:o.string().min(1).max(Di)}).strict(),o.object({op:o.literal("legacy.agents.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional(),name:o.string().max(256).optional(),sort:o.string().max(64).optional(),direction:o.enum(["asc","desc"]).optional()}).strict(),o.object({op:o.literal("legacy.agent.get"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.history"),agentId:b,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("legacy.jobs.list"),agentId:b.optional(),status:o.string().max(64).optional()}).strict(),o.object({op:o.literal("legacy.job.get"),jobId:b}).strict(),o.object({op:o.literal("legacy.schedules.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedules.list"),agentId:b,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedule.create"),agentId:b,schedule:sc.extend({prompt:o.string().max(64e3),interval:o.number().int().min(1),unit:qa})}).strict(),o.object({op:o.literal("legacy.schedule.get"),scheduleId:b}).strict(),o.object({op:o.literal("legacy.schedule.edit"),scheduleId:b,schedule:sc.extend({prompt:o.string().max(64e3).nullish(),interval:o.number().int().min(1).nullish(),unit:qa.nullish()})}).strict(),o.object({op:o.literal("legacy.schedule.remove"),scheduleId:b}).strict(),o.object({op:o.literal("legacy.agent.create"),agent:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.update"),agentId:b,update:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.delete"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.conversation.clear"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.get"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.update"),agentId:b,systemPrompt:o.string().max(Zh)}).strict(),o.object({op:o.literal("legacy.agent.download"),agentId:b}).strict(),o.object({op:o.literal("legacy.job.cancel"),jobId:b}).strict(),o.object({op:o.literal("commands.list")}).strict(),o.object({op:o.literal("commands.entities"),sessionId:L,command:b,name:o.string().max(128).optional()}).strict(),o.object({op:o.literal("models.catalogue"),live:o.boolean().optional(),scope:o.enum(["usable","all"]).optional()}).strict(),o.object({op:o.literal("usage.get"),provider:b.optional(),live:o.boolean().optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("quota.notice"),provider:b.optional(),model:o.string().min(1).max(200).optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("analytics.get"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("analytics.models"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("info.get")}).strict(),o.object({op:o.literal("sessions.report"),sessionId:L,recentLimit:o.number().int().min(0).max(50).optional()}).strict(),o.object({op:o.literal("skills.list"),sessionId:L.optional(),cwd:$h.optional(),name:Nn.optional()}).strict(),o.object({op:o.literal("skills.create"),requestId:te,name:Nn,copyFrom:Nn}).strict(),o.object({op:o.literal("skills.update"),requestId:te,name:Nn,expectedFingerprint:o.string().regex(/^[a-f0-9]{64}$/),files:o.array(o.object({path:o.string().min(1).max(240),content:o.string().max(1024*1024)}).strict()).min(1).max(64)}).strict(),o.object({op:o.literal("skills.remove"),requestId:te,name:Nn,discardLocalChanges:o.boolean()}).strict(),o.object({op:o.literal("sessions.failovers"),sessionId:L}).strict(),o.object({op:o.literal("sessions.credential"),sessionId:L,action:o.enum(["list","store","forget"]),key:Nr.optional(),value:Lr.optional(),confirmed:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.fork"),sessionId:L,requestId:te,message:o.string().max(2e5).optional(),boundary:o.enum(["next_safe","at_entry"]).optional(),entryId:o.string().max(128).optional(),autoTag:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.stop"),requestId:te,targets:o.array(L).min(1).max(100),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside"),sessionId:L,requestId:te,text:o.string().min(1).max(32768),asideId:te.optional(),subscriptionId:o.string().regex(Ha).optional()}).strict(),o.object({op:o.literal("sessions.adopt"),sessionId:L,requestId:te,asideId:te,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside.get"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("sessions.aside.close"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("wakes.list"),limit:o.number().int().min(1).max(500).optional(),includeDormant:o.boolean().optional()}).strict(),o.object({op:o.literal("wakes.create"),requestId:te,sessionId:L.optional(),cwd:o.string().min(1).max(4096).optional(),target:Ur.optional(),message:nc,in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional(),title:o.string().min(1).max(200).optional()}).strict(),o.object({op:o.literal("wakes.edit"),sessionId:L,wakeId:rc,message:nc.optional(),in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional()}).strict(),o.object({op:o.literal("wakes.remove"),sessionId:L,wakeId:rc}).strict(),o.object({op:o.literal("monitors.cancel"),sessionId:L,monitorId:Xh}).strict(),o.object({op:o.literal("jobs.cancel"),sessionId:L,jobId:qh}).strict(),o.object({op:o.literal("mcp.list"),sessionId:L}).strict(),o.object({op:o.literal("mcp.credentials.store"),sessionId:L,name:o.string().min(1).max(256),values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("mcp.control"),sessionId:L,control:o.object({action:o.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:Zs.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record($r).optional(),url:o.string().max(4096).optional(),headers:o.record($r).optional(),oauth:o.boolean().optional(),confirmed:o.boolean().optional(),operation_id:Ga.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog"),cwd:Ks.optional(),sessionId:L.optional()}).strict(),o.object({op:o.literal("mcp.catalog.control"),cwd:Ks.optional(),control:o.object({action:o.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:Zs.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record($r).optional(),url:o.string().max(4096).optional(),headers:o.record($r).optional(),confirmed:o.boolean().optional(),operation_id:Ga.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog.credentials"),header:o.string().min(1).max(128).optional(),cwd:Ks.optional(),name:Zs,values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("radient.request"),control:o.object({operation:o.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list","org_skills.list","org_skill.get","signup.resend"]),request_id:te.optional(),tenant_id:b.optional(),account_id:b.optional(),agent_id:b.optional(),comment_id:b.optional(),team_id:b.optional(),skill_id:b.optional(),query:o.record(o.union([o.string().max(1024),o.number().int()])).optional(),payload:o.record(o.unknown()).optional(),confirmed:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("providers.list")}).strict(),o.object({op:o.literal("accounts.list")}).strict(),o.object({op:o.literal("accounts.remove"),accountId:o.number().int().positive(),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("tunnel.setup.read"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.plan"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.run"),credentialId:o.number().int().positive(),acceptMonthlyPrice:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("auth.start"),provider:b}).strict(),o.object({op:o.literal("auth.status"),id:b}).strict(),o.object({op:o.literal("auth.input"),id:b,promptId:b,value:Lr}).strict(),o.object({op:o.literal("auth.cancel"),id:b}).strict(),o.object({op:o.literal("auth.key"),provider:b,value:Lr}).strict(),o.object({op:o.literal("auth.logout"),provider:b}).strict(),o.object({op:o.literal("agent_messages.status"),boundary:Ua}).strict(),o.object({op:o.literal("agent_messages.enable"),expected_account_id:b,tenant_id:b,state:o.literal("active"),consent_version:o.string().min(1).max(128),consented_via:o.literal("dialog")}).strict(),o.object({op:o.literal("agent_messages.settings"),tenant_id:b.optional()}).strict(),o.object({op:o.literal("agent_messages.settings.put"),expected_account_id:b,tenant_id:b.optional(),consent_version:o.string().min(1).max(128).optional(),consented_via:o.enum(["dialog","settings"]).optional(),label:o.string().min(1).max(128).optional(),state:o.enum(["active","paused","disabled"])}).strict(),o.object({op:o.literal("agent_messages.onboarding.dismiss")}).strict(),o.object({op:o.literal("agent_messages.allowlist.get"),tenant_id:b.optional()}).strict(),o.object({op:o.literal("agent_messages.allowlist.put"),expected_account_id:b,tenant_id:b.optional(),entries:o.array(o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:o.object({endpoint_id:b.optional(),account_id:b.optional()}).strict().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id")}).strict()).max(200)}).strict(),o.object({op:o.literal("team_bridge.conversations.list"),scope:o.literal("account").optional(),tenant_id:b.optional(),limit:o.number().int().min(1).max(100).optional(),cursor:o.string().min(1).max(512).optional(),before:o.string().min(1).max(64).optional(),status:o.enum(["open","archived"]).optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.get"),conversation_id:b,tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.create"),expected_account_id:b.optional(),tenant_id:b.optional(),kind:o.enum(["dm","group","channel"]),name:o.string().min(1).max(128).optional(),topic:o.string().min(1).max(512).optional(),visibility:o.enum(["private","tenant"]).optional(),agent_capable:o.boolean().optional(),members:o.array(o.object({account_id:b,kind:o.enum(["human","agent"]),endpoint_id:b.optional(),display_label:o.string().min(1).max(64)}).strict()).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.lifecycle"),expected_account_id:b.optional(),tenant_id:b.optional(),conversation_id:b,action:o.enum(["archive","unarchive","join","leave"])}).strict(),o.object({op:o.literal("team_bridge.conversations.join"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.notify"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),notify:o.enum(["all","mention","mute"])}).strict(),o.object({op:o.literal("team_bridge.conversations.members.add"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),members:o.array(o.object({account_id:b,kind:o.enum(["human","agent"]),endpoint_id:b.optional(),display_label:o.string().min(1).max(64)}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.members.remove"),expected_account_id:b.optional(),tenant_id:b.optional(),conversation_id:b,account_id:b}).strict(),o.object({op:o.literal("team_bridge.conversations.delete"),expected_account_id:b.optional(),tenant_id:b.optional(),conversation_id:b}).strict(),o.object({op:o.literal("team_bridge.conversations.consent"),expected_account_id:b.optional(),conversation_id:b,account_id:b,decision:o.enum(["accept","decline"]),consent_version:o.string().min(1).max(128),tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.owner_audit.conversations"),expected_account_id:b,tenant_id:b,limit:o.number().int().min(1).max(100).optional(),cursor:o.string().min(1).optional()}).strict(),o.object({op:o.literal("team_bridge.owner_audit.messages"),expected_account_id:b,tenant_id:b,conversation_id:b,limit:o.number().int().min(1).max(100).optional(),before_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.owner_audit.replies"),expected_account_id:b,tenant_id:b,conversation_id:b,message_id:b,limit:o.number().int().min(1).max(100).optional(),after_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.messages.list"),conversation_id:b,tenant_id:b.optional(),limit:o.number().int().min(1).max(100).optional(),before_seq:o.number().int().nonnegative().optional(),endpoint_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.reactions.toggle"),conversation_id:b,message_id:b,expected_account_id:b,tenant_id:b,emoji:o.string().min(1),active:o.boolean()}).strict(),o.object({op:o.literal("team_bridge.messages.send"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),client_ref:b,body:o.string(),agent_label:o.string().min(1).max(64).optional(),thread_root_id:b.optional(),attachment_ids:Ys.optional()}).strict(),o.object({op:o.literal("team_bridge.messages.replies"),conversation_id:b,message_id:b,expected_account_id:b,tenant_id:b,limit:o.number().int().min(1).max(100).optional(),after_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.scheduled.list"),tenant_id:b}).strict(),o.object({op:o.literal("team_bridge.scheduled.create"),tenant_id:b,conversation_id:b,client_ref:b,body:o.string(),send_at:o.string().datetime({offset:!0}),attachment_ids:Ys.optional(),thread_root_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.scheduled.update"),tenant_id:b,scheduled_id:b,body:o.string().optional(),send_at:o.string().datetime({offset:!0}).optional(),attachment_ids:Ys.optional(),expected_version:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.attachments.delete"),tenant_id:b,conversation_id:b,attachment_id:b,expected_account_id:b}).strict(),o.object({op:o.literal("team_bridge.scheduled.cancel"),tenant_id:b,scheduled_id:b}).strict(),o.object({op:o.literal("team_bridge.read"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),seq:o.number().int().nonnegative().optional(),muted:o.boolean().optional()}).strict(),o.object({op:o.literal("team_bridge.unread"),scope:o.literal("account").optional(),tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.directory"),tenant_id:b}).strict(),o.object({op:o.literal("team_bridge.status"),boundary:Ua.optional()}).strict(),o.object({op:o.literal("settings.list")}).strict(),o.object({op:o.literal("settings.edit"),key:Nr,value:o.unknown().refine(e=>e!==void 0,"A setting value is required."),base:Yh.optional()}).strict(),o.object({op:o.literal("settings.reset"),key:Nr}).strict(),o.object({op:o.literal("tts.paths")}).strict(),o.object({op:o.literal("config.get")}).strict(),o.object({op:o.literal("config.update"),value:em}).strict(),o.object({op:o.literal("instructions.get")}).strict(),o.object({op:o.literal("instructions.update"),content:o.string().max(64e3)}).strict(),o.object({op:o.literal("credentials.list")}).strict(),o.object({op:o.literal("credentials.update"),key:Nr,value:Lr}).strict(),o.object({op:o.literal("peers.list")}).strict(),o.object({op:o.literal("networks.list")}).strict(),o.object({op:o.literal("networks.invite"),networkId:fn,role:o.enum(["read","drive","admin"]),deviceId:fn.optional()}).strict(),o.object({op:o.literal("networks.member.remove"),networkId:fn,deviceId:fn,confirm:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("sessions.transfer"),sessionId:L,to:o.union([o.literal("local"),fn]),keep:o.boolean().optional(),waitS:o.number().min(0).max(300).optional(),requestId:te.optional()}).strict(),o.object({op:o.literal("approvals.list")}).strict(),o.object({op:o.literal("approvals.approve"),approvalId:za}).strict(),o.object({op:o.literal("approvals.deny"),approvalId:za}).strict(),o.object({op:o.literal("asks.list")}).strict(),o.object({op:o.literal("projects.list")}).strict(),o.object({op:o.literal("projects.get"),key:Ot}).strict(),o.object({op:o.literal("projects.create"),name:Js,description:o.string().max(fc).optional(),status:dc.optional(),tags:uc.optional()}).strict(),o.object({op:o.literal("projects.update"),key:Ot,fields:o.object({name:Js.optional(),title:o.string().max(80).optional(),owner:o.string().max(80).optional(),team:o.string().max(80).optional(),description:o.string().max(fc).optional(),status:dc.optional(),progress:o.string().max(vm).optional(),tags:uc.optional(),start_date:Br.optional(),target_date:Br.optional(),completed_at:Br.optional(),estimate:o.number().positive().max(1e3).optional(),estimate_unit:o.enum(["points","days"]).optional()}).strict(),force_done:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.delete"),key:Ot,confirmed_name:Js}).strict(),o.object({op:o.literal("projects.link"),key:Ot,sessionId:L}).strict(),o.object({op:o.literal("projects.unlink"),key:Ot,sessionId:L}).strict(),o.object({op:o.literal("projects.milestone"),key:Ot,name:o.string().min(1).max(pc),targetDate:Br.optional(),completed:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.milestone.remove"),key:Ot,name:o.string().min(1).max(pc)}).strict(),o.object({op:o.literal("projects.request_update"),key:Ot}).strict(),o.object({op:o.literal("projects.search"),q:o.string().min(1).max(bm),limit:o.number().int().min(1).max(Sm).optional()}).strict(),o.object({op:o.literal("aida.status")}).strict(),o.object({op:o.literal("aida.control"),action:o.enum(["open","pause","resume","greet","status"])}).strict(),o.object({op:o.literal("code_requests.list"),sessionId:L}).strict(),o.object({op:o.literal("code_requests.refresh"),sessionId:L,keys:o.array(o.string().min(1).max(512)).max(256).optional(),force:o.boolean().optional()}).strict(),o.object({op:o.literal("static.sign"),route:o.enum(["images","videos","audio","html"]),path:o.string().min(1),ttlS:o.number().int().min(1).max(3600).optional()}).strict(),o.object({op:o.literal("library.list"),scope:o.enum(["final","all"]).optional(),q:o.string().max(512).optional(),category:o.string().min(1).max(64).optional(),kind:o.string().min(1).max(64).optional(),origin_group:o.enum(["generated","created","mentioned"]).optional(),origin:o.string().min(1).max(64).optional(),tag:o.string().min(1).max(128).optional(),tag_mode:o.enum(["all","any"]).optional(),highlighted:o.boolean().optional(),organized:o.boolean().optional(),favorite:o.boolean().optional(),session:o.string().min(1).max(12).optional(),session_id:o.string().min(1).max(512).optional(),sort:o.enum(["recent","name","kind","size","created","modified","organized"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(512).optional()}).strict(),o.object({op:o.literal("library.get"),id:Ln}).strict(),o.object({op:o.literal("library.update"),id:Ln,fields:o.object({name:o.string().max(200).optional(),description:o.string().max(2e3).optional(),favorite:o.boolean().optional(),locked:o.boolean().optional(),archived:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("library.tags")}).strict(),o.object({op:o.literal("library.tags.create"),name:o.string().trim().min(1).max(24),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.update"),id:$n,name:o.string().trim().min(1).max(24).optional(),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.delete"),id:$n}).strict(),o.object({op:o.literal("library.tags.merge"),id:$n,into:$n}).strict(),o.object({op:o.literal("library.tags.assign"),id:Ln,tags:o.array($n).max(64),primary:o.string().max(128).optional()}).strict(),o.object({op:o.literal("library.chat.link"),id:Ln,sessionId:L}).strict(),o.object({op:o.literal("library.chat.clear"),id:Ln}).strict(),o.object({op:o.literal("library.librarian"),action:o.enum(["status","open","pause","resume","run"]).optional()}).strict(),o.object({op:o.literal("sidebar_layout.get")}).strict(),o.object({op:o.literal("sidebar_layout.set"),layout:Em}).strict(),o.object({op:o.literal("notifications.list"),state:o.enum(["unread","all","dismissed"]).optional(),source:o.enum(["notify","ask"]).optional(),priority:o.enum(["high","normal","low"]).optional(),sessionId:L.optional(),throughSeq:o.number().int().min(0).optional(),cursor:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("notifications.get"),id:Qn}).strict(),o.object({op:o.literal("notifications.count")}).strict(),o.object({op:o.literal("notifications.read"),verb:o.enum(["read","unread"]),target:mc}).strict(),o.object({op:o.literal("notifications.dismiss"),verb:o.enum(["dismiss","undismiss"]),target:mc}).strict(),o.object({op:o.literal("notifications.seen"),items:o.array(o.object({id:Qn,revision:o.number().int().min(1),anchorId:o.string().min(1).max(256),visibleSinceMs:o.number().int().min(0)}).strict()).min(1).max(50),evidence:o.object({sessionId:L,inputKind:o.enum(["pointer","key","wheel"]),inputAtMs:o.number().int().min(0),visibleSinceMs:o.number().int().min(0)}).strict()}).strict()]);Rm.superRefine((e,t)=>{if((e.op==="team_bridge.messages.send"||e.op==="team_bridge.scheduled.create"||e.op==="team_bridge.scheduled.update"&&e.body!==void 0)&&e.body?.trim()===""&&(e.attachment_ids?.length??0)===0){t.addIssue({code:o.ZodIssueCode.custom,message:"A message needs text or an image",path:["body"]});return}if(e.op.startsWith("team_bridge.")&&"expected_account_id"in e&&e.expected_account_id&&(!("tenant_id"in e)||!e.tenant_id)){t.addIssue({code:o.ZodIssueCode.custom,path:["tenant_id"],message:"Guarded conversation writes require an explicit tenant"});return}if(e.op==="team_bridge.messages.send"&&e.thread_root_id!==void 0&&!e.expected_account_id){t.addIssue({code:o.ZodIssueCode.custom,path:["expected_account_id"],message:"Thread replies require the captured account"});return}if(e.op==="hub.skillPull"||e.op==="hub.skillSubscribe"||e.op==="hub.skillPublish"){if(e.visibility==="public"&&e.tenantId!==null||e.visibility==="org"&&!e.tenantId){t.addIssue({code:o.ZodIssueCode.custom,message:"A skill destination requires explicit paired scope",path:["tenantId"]});return}if(e.op==="hub.skillPublish"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"An initial skill publication requires its reviewed draft receipt",path:["previewReceipt"]});return}}if(e.op==="hub.check"||e.op==="hub.apply"||e.op==="hub.retry"){const n=e.name!==void 0,r=e.localId!==void 0,s=e.op!=="hub.check";if(n&&r||s&&!n&&!r||r&&e.kind===void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub action addresses one item by name or local id, never both",path:["localId"]});return}}if(e.op==="hub.apply"&&e.resolveSource===!0){const n=e.visibility==="public"&&e.tenantId===null||e.visibility==="org"&&typeof e.tenantId=="string"&&e.tenantId.length>0;if(!e.hubSource||!n||e.acknowledgeUnknownBaseline!==!0||e.localId!==void 0||e.prefer!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"Confirming a source requires its exact stated destination and the unknown-baseline acknowledgement, addressed by name, with no preference",path:["hubSource"]});return}}if(e.op==="hub.push"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"A confirmed publication requires its reviewed preview receipt",path:["previewReceipt"]});return}if(e.op==="hub.policy"&&e.subscribe===void 0&&e.autoPush===void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub policy change must name subscribe or autoPush",path:["subscribe"]});return}if((e.op==="team_bridge.conversations.list"||e.op==="team_bridge.unread")&&e.scope==="account"&&e.tenant_id!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped read cannot name a tenant",path:["scope"]});return}if(e.op==="team_bridge.conversations.list"&&e.scope==="account"&&e.before!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped page uses cursor, not before",path:["before"]});return}if(e.op==="sessions.answer"){if(e.askId!==void 0){if(e.askId||t.addIssue({code:o.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.dismiss===!0){(e.answers!==void 0||e.decline===!0||e.revise===!0)&&t.addIssue({code:o.ZodIssueCode.custom,message:"A dismissal carries no answers, decline or revise",path:["dismiss"]});return}e.reason!==void 0?t.addIssue({code:o.ZodIssueCode.custom,message:"A reason applies to a dismissal",path:["reason"]}):e.decline!==!0&&!e.answers?t.addIssue({code:o.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:o.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:o.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:o.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:o.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]}),e.dismiss===!0&&t.addIssue({code:o.ZodIssueCode.custom,message:"dismiss applies to a queued ask",path:["dismiss"]}),e.reason!==void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:"reason applies to a queued ask",path:["reason"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}if(!(e.op!=="agent.publish"&&e.op!=="agent.republish"&&e.op!=="team.publish")){if((e.subscribe!==void 0||e.autoPush!==void 0||e.confirmPublicEgress!==void 0)&&!e.requestId){t.addIssue({code:o.ZodIssueCode.custom,message:"Initial link policy needs a durable publication request ID",path:["requestId"]});return}e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:o.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})}});const qe={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},xm={runtimeUnreachable:"runtime_unreachable"},vs="runtime_busy",sd="runtime_retiring";o.object({data:o.object({aside_id:o.string().optional(),status:o.union([o.enum(["adopted","queued"]),o.string()]).optional()}).passthrough()}).passthrough();const id=o.object({name:o.string(),description:o.string().nullish(),source:o.string().nullish(),link_id:o.string().nullish(),editable:o.boolean().nullish(),installed:o.boolean().nullish(),fingerprint:o.string().nullish(),form:o.string().nullish()}).passthrough(),Tm=o.object({path:o.string(),size:o.number().nullish(),preview:o.string().nullish(),preview_truncated:o.boolean().nullish()}).passthrough(),Cm=id.extend({body:o.string().nullish(),body_in_detail:o.boolean().nullish(),body_length:o.number().nullish(),body_bytes:o.number().nullish(),body_truncated:o.boolean().nullish(),files:o.array(Tm).nullish(),files_total:o.number().nullish(),files_truncated:o.boolean().nullish(),publish_budget:o.object({limit:o.number(),total:o.number()}).passthrough().nullish()}).passthrough(),RE=o.object({skills:o.array(id),scope:o.string().nullish(),detail:o.string().nullish(),skill_detail:Cm.nullish(),warning_count:o.number().nullish(),version:o.string().nullish()}).passthrough(),xE="aside_adopt_refused",Am=["session_closed","open_tool_batch","turn_running"];function TE(e){if(typeof e!="object"||e===null)return;const t=e.reason;return Am.find(n=>n===t)}const Pm={[qe.noCredential]:"ui.common.errors.desktop_refusal.no_credential",[qe.refused]:"ui.common.errors.desktop_refusal.refused",[qe.planeClosed]:"ui.common.errors.desktop_refusal.plane_closed",[qe.transportFailed]:"ui.common.errors.desktop_refusal.transport_failed"},Li={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function bs(e){return e!==void 0&&Object.values(qe).includes(e)}function Om(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return qe.refused;if(t===503)return qe.planeClosed}}const CE=o.object({step:o.string(),blocked_on:o.string(),configured:o.boolean(),ready:o.boolean(),verified:o.boolean(),url:o.string().nullable(),credential_id:o.number().int().positive().nullable(),identity_label:o.string().nullable(),credential_choices:o.array(o.object({id:o.number().int().positive(),identity_label:o.string().nullable().optional()}).passthrough()).default([]),quote:o.object({monthly_price_usd:o.string().nullable(),positive_balance:o.boolean(),eligible:o.boolean(),account_valid:o.boolean()}).passthrough().nullable(),receipts:o.array(o.object({step:o.string(),ok:o.boolean(),text:o.string()})).default([]),remedy:o.object({kind:o.string(),text:o.string(),command:o.string().nullable().optional(),url:o.string().nullable().optional()}).nullable(),source:o.string(),in_progress:o.boolean().default(!1),progress:o.array(o.string()).default([]),active_credential_id:o.number().int().positive().nullable().default(null),billing_outcome:o.string().optional(),reservation_outcome:o.string().optional(),failure_stage:o.string().optional()}).passthrough(),AE=new Set(["setup_in_progress","setup_deadline","setup_unavailable","setup_intent_corrupt"]),jm=88e4,Mm=11e5,Dm=2e4,Nm=9e4,Lm=new Set(["analytics.get","analytics.models","sessions.report"]),$m=new Set(["usage.get"]),Um=new Set(["networks.list","peers.list"]),Fm=new Set([...Lm,...$m,...Um]),Bm=90,Gm=30,Hm=300,Wm=10,od=15,zm=1e4;function Zm(e){const n=e.to==="local"||e.keep?Hm:Gm,r=Math.max(0,e.waitS??0);return(Bm+n+Wm+od)*1e3+r*1e3}const Km=18e4,Vm=Km+15e3,Ym=120,Qm=135e3,Jm=93e4,ad=(Ym+30+od)*1e3,Xm=6e4,qm=5*ad,eg=new Set(["hub.apply","hub.retry","hub.push","hub.skillPublish","hub.skillPull","hub.skillSubscribe","hub.skillUnpull","hub.check","hub.applyAll"]);function tg(e){switch(e){case"hub.apply":case"hub.retry":case"hub.push":case"hub.skillPublish":case"hub.skillPull":case"hub.skillSubscribe":case"hub.skillUnpull":return ad;case"hub.check":return Xm;case"hub.applyAll":return qm;default:return null}}function ng(e){if(typeof e!="string"&&e.op==="sessions.transfer")return Zm(e)+zm;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return Vm;if(t==="tunnel.setup.run")return Jm;if(t==="tunnel.setup.plan")return Qm;const n=tg(t);return n!==null?n:Fm.has(t)?Nm:Dm}const rg=5e3;function cd(e){return ng(e)+rg}const vo="deadline_exceeded",ld="foreground_required",dd="View these completions in the foreground before marking them read.",sg=new Set(["capabilities","agent_messages.status","agent_messages.settings","agent_messages.allowlist.get","team_bridge.conversations.list","team_bridge.conversations.get","team_bridge.messages.list","team_bridge.messages.replies","team_bridge.owner_audit.conversations","team_bridge.owner_audit.messages","team_bridge.owner_audit.replies","team_bridge.unread","team_bridge.directory","team_bridge.status","accounts.list","analytics.get","analytics.models","approvals.list","commands.entities","commands.list","config.get","credentials.list","hub.updates","hub.links","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","quota.notice","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.files","sessions.userAttachments","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","teams.effective","teams.get","teams.list","tunnel.setup.plan","tunnel.setup.read","usage.get"]),ig=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function og(e,t){const n=Math.round(t/1e3),r=vo;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:eg.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:sg.has(e)?{code:r,message:ig.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const PE=jm,OE=Mm;o.object({state:o.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:o.string(),kind:o.enum(["balance","subscription","radient","none"]),model_free:o.boolean(),title:o.string(),body:o.string(),actions:o.array(o.object({id:o.enum(["open_url","resend_verification","refresh"]),label:o.string(),url:o.string().nullable().optional()})),resets_at_ms:o.number().int().nullable().optional(),checked_at_ms:o.number().int(),age_ms:o.number().int().nullable().optional(),source:o.enum(["cached","live"])});function ag(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function gc(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function qs(e){return{...e.requestId?{request_id:e.requestId}:{},...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}}function ei(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function _c(e){return{sources:e.sources??null,session_ids:e.sessionIds??{},all:e.all??!1,include_subagents:e.includeSubagents??!1,include_cleared_segments:e.includeClearedSegments??!1,include_memory:e.includeMemory??!0,include_instructions:e.includeInstructions??!0,...e.maxSessions===void 0?{}:{max_sessions:e.maxSessions}}}function Hr(e){const t=new URLSearchParams;return e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id),t.size?`?${t.toString()}`:""}function ti(e){return e===void 0?"":`?tenant_id=${encodeURIComponent(e)}`}function cg(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"imports.sources":return{path:"/v1/desktop/imports/sources",method:"GET"};case"imports.sessions":{const t=new URLSearchParams({source:e.source});return e.includeSubagents&&t.set("include_subagents","true"),{path:`/v1/desktop/imports/sessions?${t.toString()}`,method:"GET"}}case"imports.preview":return{path:"/v1/desktop/imports/preview",method:"POST",body:_c(e)};case"imports.start":return{path:"/v1/desktop/imports/jobs",method:"POST",body:_c(e)};case"imports.status":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"GET"};case"imports.cancel":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"DELETE"};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.skillPull":return{path:"/v1/desktop/hub/skills/pull",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.skillSubscribe":return{path:"/v1/desktop/hub/skills/subscribe",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias}};case"hub.skillUnpull":return{path:"/v1/desktop/hub/skills/unpull",method:"POST",body:{request_id:e.requestId,link_id:e.linkId}};case"hub.skillPublish":return{path:"/v1/desktop/hub/skills/publish",method:"POST",body:{request_id:e.requestId,dry_run:e.dryRun,source_skill:e.sourceSkill,local_alias:e.localAlias,visibility:e.visibility,tenant_id:e.tenantId,subscribe:e.subscribe,auto_push:e.autoPush,confirm_public_egress:e.confirmPublicEgress,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"hub.links":return{path:`/v1/desktop/hub/links${e.kind?`?kind=${e.kind}`:""}`,method:"GET"};case"hub.policy":return{path:`/v1/desktop/hub/links/${encodeURIComponent(e.linkId)}`,method:"PATCH",body:{request_id:e.requestId,expected_policy_revision:e.expectedPolicyRevision,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{},...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.resolveSource===!0?{resolve_source:!0,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId??null}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.push":return{path:"/v1/desktop/hub/updates/push",method:"POST",body:{request_id:e.requestId,link_id:e.linkId,direction:e.direction,dry_run:e.dryRun,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.effective":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}/effective`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),e.sort&&t.set("sort",e.sort),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??Gh)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),as(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.files":{const t=new URLSearchParams({limit:String(e.limit??200)});for(const n of["scope","kind","q","sort","order","cursor"]){const r=e[n];r!==void 0&&t.set(n,r)}return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files?${t}`,method:"GET"}}case"sessions.files.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/materialise`,method:"POST"};case"sessions.userAttachments":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments`,method:"GET"};case"sessions.userAttachments.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments/${encodeURIComponent(e.digest)}/materialise`,method:"POST"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1")),e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),e.sourceRead==="metadata"?t.set("source_read","metadata"):e.sourceRead==="payload"&&e.expectedJournalGeneration&&t.set("source_read","payload"),e.expectedJournalGeneration&&t.set("expected_journal_generation",e.expectedJournalGeneration),as(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??Wh)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],...e.files?.length?{files:e.files}:{},mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{},...e.dismiss===!0?{dismiss:!0,...e.reason!==void 0?{reason:e.reason}:{}}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"tags.list":return{path:"/v1/desktop/tags",method:"GET"};case"tags.replace":return{path:"/v1/desktop/tags",method:"PUT",body:{tags:e.tags}};case"sessions.tags":return{path:`/v1/desktop/sessions/${e.sessionId}/tags`,method:"PUT",body:{tags:e.tags,primary:e.primary,...e.expected_revision===void 0?{}:{expected_revision:e.expected_revision}}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{ei(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{},...qs(e)}}}case"agent.republish":{ei(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{},...qs(e),...e.expectedRemoteRevision?{expected_remote_revision:e.expectedRemoteRevision}:{}}}}case"team.publish":{ei(e);const t=new URLSearchParams;return e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId)),{path:`/v1/teams/${e.teamId}/publish${t.size?`?${t}`:""}`,method:"POST",body:qs(e)}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...ag(e),message:e.message,...gc(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...gc(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,method:"GET"}}case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"skills.create":return{path:"/v1/desktop/skills",method:"POST",body:{request_id:e.requestId,name:e.name,copy_from:e.copyFrom}};case"skills.update":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"PUT",body:{request_id:e.requestId,expected_fingerprint:e.expectedFingerprint,files:e.files}};case"skills.remove":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"DELETE",body:{request_id:e.requestId,discard_local_changes:e.discardLocalChanges}};case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId,auto_tag:e.autoTag}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"tunnel.setup.read":return{path:e.credentialId===void 0?"/v1/desktop/tunnel/setup":`/v1/desktop/tunnel/setup?credential_id=${e.credentialId}`,method:"GET"};case"tunnel.setup.plan":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"plan",...e.credentialId!==void 0?{credential_id:e.credentialId}:{}}};case"tunnel.setup.run":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"run",credential_id:e.credentialId,...e.acceptMonthlyPrice!==void 0?{accept_monthly_price:e.acceptMonthlyPrice}:{}}};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"agent_messages.status":return{path:`/v1/desktop/team-bridge/status?boundary=${e.boundary}`,method:"GET"};case"agent_messages.enable":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,state:e.state,consent_version:e.consent_version,consented_via:e.consented_via}};case"agent_messages.settings":return{path:`/v1/desktop/team-bridge/settings${ti(e.tenant_id)}`,method:"GET"};case"agent_messages.settings.put":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},...e.consent_version===void 0?{}:{consent_version:e.consent_version},...e.consented_via===void 0?{}:{consented_via:e.consented_via},...e.label===void 0?{}:{label:e.label},state:e.state}};case"agent_messages.onboarding.dismiss":return{path:"/v1/desktop/team-bridge/onboarding/dismiss",method:"POST"};case"agent_messages.allowlist.get":return{path:`/v1/desktop/team-bridge/allowlist${ti(e.tenant_id)}`,method:"GET"};case"agent_messages.allowlist.put":return{path:"/v1/desktop/team-bridge/allowlist",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},entries:e.entries}};case"team_bridge.conversations.list":{const t=new URLSearchParams;return e.scope==="account"&&t.set("scope","account"),e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor),e.before&&t.set("before",e.before),e.status&&t.set("status",e.status),{path:`/v1/desktop/team-bridge/conversations${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.conversations.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${ti(e.tenant_id)}`,method:"GET"};case"team_bridge.conversations.create":return{path:"/v1/desktop/team-bridge/conversations",method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},kind:e.kind,...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agent_capable===void 0?{}:{agent_capable:e.agent_capable},members:e.members}};case"team_bridge.conversations.lifecycle":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/${e.action}${e.action==="join"?"":Hr(e)}`,method:"POST",...e.action==="join"&&(e.tenant_id||e.expected_account_id)?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.join":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/join`,method:"POST",...e.tenant_id||e.expected_account_id?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.members.add":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members${n}`,method:"POST",body:e.members}}case"team_bridge.conversations.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${Hr(e)}`,method:"DELETE"};case"team_bridge.conversations.members.remove":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}${Hr(e)}`,method:"DELETE"};case"team_bridge.conversations.consent":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}/consent`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},decision:e.decision,consent_version:e.consent_version}};case"team_bridge.owner_audit.conversations":case"team_bridge.owner_audit.messages":case"team_bridge.owner_audit.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit));let n="/v1/desktop/team-bridge/owner-audit/conversations";return e.op==="team_bridge.owner_audit.conversations"?e.cursor!==void 0&&t.set("cursor",e.cursor):(n+=`/${encodeURIComponent(e.conversation_id)}/messages`,e.op==="team_bridge.owner_audit.messages"?e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)):(n+=`/${encodeURIComponent(e.message_id)}/replies`,e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq)))),{path:`${n}?${t}`,method:"GET"}}case"team_bridge.messages.list":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.endpoint_id&&t.set("endpoint_id",e.endpoint_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages${n}`,method:"GET"}}case"team_bridge.reactions.toggle":{const t=`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/reactions/${encodeURIComponent(e.emoji)}`;return e.active?{path:t,method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id}}:{path:`${t}${Hr(e)}`,method:"DELETE"}}case"team_bridge.messages.send":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},client_ref:e.client_ref,body:e.body,...e.agent_label?{agent_label:e.agent_label}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{},...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{}}};case"team_bridge.scheduled.list":return{path:`/v1/desktop/team-bridge/scheduled?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"GET"};case"team_bridge.scheduled.create":return{path:"/v1/desktop/team-bridge/scheduled",method:"POST",body:{tenant_id:e.tenant_id,conversation_id:e.conversation_id,client_ref:e.client_ref,body:e.body,send_at:e.send_at,...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.scheduled.update":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"PATCH",body:{...e.body===void 0?{}:{body:e.body},...e.send_at===void 0?{}:{send_at:e.send_at},...e.attachment_ids===void 0?{}:{attachment_ids:e.attachment_ids},...e.expected_version===void 0?{}:{expected_version:e.expected_version}}};case"team_bridge.attachments.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/attachments/${encodeURIComponent(e.attachment_id)}?${new URLSearchParams({tenant_id:e.tenant_id,expected_account_id:e.expected_account_id})}`,method:"DELETE"};case"team_bridge.scheduled.cancel":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"DELETE"};case"team_bridge.messages.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit)),e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq));const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/replies${n}`,method:"GET"}}case"team_bridge.read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.seq===void 0?{}:{seq:e.seq},...e.muted===void 0?{}:{muted:e.muted}}};case"team_bridge.unread":{const t=new URLSearchParams;return e.scope==="account"?t.set("scope","account"):e.tenant_id&&t.set("tenant_id",e.tenant_id),{path:`/v1/desktop/team-bridge/unread${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.directory":return{path:`/v1/desktop/team-bridge/directory?tenant_id=${encodeURIComponent(e.tenant_id)}`,method:"GET"};case"team_bridge.status":{const t=new URLSearchParams;return e.boundary&&t.set("boundary",e.boundary),{path:`/v1/desktop/team-bridge/status${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"library.list":{const t=new URLSearchParams;e.scope&&t.set("scope",e.scope),e.q&&t.set("q",e.q),e.category&&t.set("category",e.category),e.kind&&t.set("kind",e.kind),e.origin_group&&t.set("origin_group",e.origin_group),e.origin&&t.set("origin",e.origin),e.tag&&t.set("tag",e.tag),e.tag_mode&&t.set("tag_mode",e.tag_mode),e.highlighted!==void 0&&t.set("highlighted",e.highlighted?"1":"0"),e.organized!==void 0&&t.set("organized",e.organized?"1":"0"),e.favorite!==void 0&&t.set("favorite",e.favorite?"1":"0"),e.session&&t.set("session",e.session),e.session_id&&t.set("session_id",e.session_id),e.sort&&t.set("sort",e.sort),e.order&&t.set("order",e.order),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor);const n=t.toString();return{path:`/v1/desktop/library/assets${n?`?${n}`:""}`,method:"GET"}}case"library.get":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"GET"};case"library.update":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"PATCH",body:e.fields};case"library.tags":return{path:"/v1/desktop/library/tags",method:"GET"};case"library.tags.create":return{path:"/v1/desktop/library/tags",method:"POST",body:{name:e.name,...e.category!==void 0?{category:e.category}:{}}};case"library.tags.update":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"PATCH",body:{...e.name!==void 0?{name:e.name}:{},...e.category!==void 0?{category:e.category}:{}}};case"library.tags.delete":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"DELETE"};case"library.tags.merge":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}/merge`,method:"POST",body:{into:e.into}};case"library.tags.assign":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/tags`,method:"PUT",body:{tags:e.tags,...e.primary!==void 0?{primary:e.primary}:{}}};case"library.chat.link":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"PUT",body:{session_id:e.sessionId}};case"library.chat.clear":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"DELETE"};case"library.librarian":{const t=e.action??"status";return t==="status"?{path:"/v1/desktop/librarian",method:"GET"}:{path:"/v1/desktop/librarian",method:"POST",body:{op:t}}}case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields,...e.force_done===!0?{force_done:!0}:{}}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??wm)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}};case"sidebar_layout.get":return{path:"/v1/desktop/sidebar-layout",method:"GET"};case"sidebar_layout.set":return{path:"/v1/desktop/sidebar-layout",method:"PUT",body:{layout:e.layout}};case"notifications.list":{const t=new URLSearchParams;return e.state&&t.set("state",e.state),e.source&&t.set("source",e.source),e.priority&&t.set("priority",e.priority),e.sessionId&&t.set("session_id",e.sessionId),e.cursor&&t.set("cursor",e.cursor),e.throughSeq!==void 0&&t.set("through_seq",String(e.throughSeq)),e.limit!==void 0&&t.set("limit",String(e.limit)),{path:`/v1/desktop/notifications${t.size?`?${t}`:""}`,method:"GET"}}case"notifications.get":return{path:`/v1/desktop/notifications/${encodeURIComponent(e.id)}`,method:"GET"};case"notifications.count":return{path:"/v1/desktop/notifications/count",method:"GET"};case"notifications.read":case"notifications.dismiss":return{path:"/v1/desktop/notifications",method:"PATCH",body:{op:e.verb,...lg(e.target)}};case"notifications.seen":return{path:"/v1/desktop/notifications/seen",method:"POST",body:{items:e.items.map(t=>({id:t.id,revision:t.revision,anchor_id:t.anchorId,visible_since_ms:t.visibleSinceMs})),evidence:{surface:"desktop",session_id:e.evidence.sessionId,input_kind:Im[e.evidence.inputKind],input_at_ms:e.evidence.inputAtMs,visible_since_ms:e.evidence.visibleSinceMs}}}}}function lg(e){return"items"in e?{ids:e.items.map(t=>({id:t.id,revision:t.revision}))}:"sessionId"in e?{session_id:e.sessionId,through_seq:e.throughSeq,observed:e.observed}:{all:!0,through_seq:e.throughSeq,observed:e.observed}}const jE=64,ME=64*1024*1024,DE="superseded_completion_token",NE="store_busy",dg="session_is_remote",ug="owner_build_behind";function LE(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function yn(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function fg(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const $E=e=>typeof e?.goal_status=="string",UE=e=>(e?.goal??"").trim().length>0;function pg(e,t,n={}){return!e||e.epoch!==t.epoch?!0:t.seq>e.seq||n.allowEqual===!0&&t.seq===e.seq}function hg(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const Jn={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."};function mg(e){return e?e===Jn.notPaired?"notPaired":e===Jn.serverDown?"serverDown":e===Jn.frameBudget?"frameTooLarge":"lost":"lost"}const yc=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const p=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,p))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(r,s,c);return c},gg=e=>e?yc(e):yc,_g=e=>e;function yg(e,t=_g){const n=Ra.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return Ra.useDebugValue(n),n}const vc=e=>{const t=gg(e),n=r=>yg(t,r);return Object.assign(n,t),n},Rr=e=>e?vc(e):vc;function ud(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const a=l=>l===null?null:JSON.parse(l,void 0),c=(i=n.getItem(s))!=null?i:null;return c instanceof Promise?c.then(a):a(c)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const $i=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return $i(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return $i(r)(n)}}}},vg=(e,t)=>(n,r,s)=>{let i={storage:ud(()=>localStorage),partialize:h=>h,version:0,merge:(h,y)=>({...y,...h}),...t},a=!1;const c=new Set,l=new Set;let d=i.storage;if(!d)return e((...h)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...h)},r,s);const u=()=>{const h=i.partialize({...r()});return d.setItem(i.name,{state:h,version:i.version})},f=s.setState;s.setState=(h,y)=>{f(h,y),u()};const p=e((...h)=>{n(...h),u()},r,s);s.getInitialState=()=>p;let m;const _=()=>{var h,y;if(!d)return;a=!1,c.forEach(k=>{var E;return k((E=r())!=null?E:p)});const g=((y=i.onRehydrateStorage)==null?void 0:y.call(i,(h=r())!=null?h:p))||void 0;return $i(d.getItem.bind(d))(i.name).then(k=>{if(k)if(typeof k.version=="number"&&k.version!==i.version){if(i.migrate){const E=i.migrate(k.state,k.version);return E instanceof Promise?E.then(A=>[!0,A]):[!0,E]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,k.state];return[!1,void 0]}).then(k=>{var E;const[A,U]=k;if(m=i.merge(U,(E=r())!=null?E:p),n(m,!0),A)return u()}).then(()=>{g?.(m,void 0),m=r(),a=!0,l.forEach(k=>k(m))}).catch(k=>{g?.(void 0,k)})};return s.persist={setOptions:h=>{i={...i,...h},h.storage&&(d=h.storage)},clearStorage:()=>{d?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>_(),hasHydrated:()=>a,onHydrate:h=>(c.add(h),()=>{c.delete(h)}),onFinishHydration:h=>(l.add(h),()=>{l.delete(h)})},i.skipHydration||_(),m||p},ws=vg,bg=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function wg(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,s)=>typeof r=="number"&&Number.isFinite(r)?r:s;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const fd=Rr()(ws(e=>({notice:null,receive:t=>e(n=>bg(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:ud(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));function bo(e){return v(Pm[e])}async function pd(e){if(window.api?.desktop)try{return await Sg(window.api.desktop.request(e),e)}catch(n){throw n instanceof _e?n:Tg(n)?new Bt(dd,ld):new _e(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new _e(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new _e(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function Sg(e,t){const n=cd(t);let r;return Promise.race([e,new Promise((s,i)=>{r=setTimeout(()=>{const a=og(t.op,n);i(new _e(null,a.message,void 0,a.code))},n)})]).finally(()=>clearTimeout(r))}const hd="This server did not answer the request for its desktop controls.",kg=()=>v("ui.common.errors.desktop_refusal_placeholder");class _e extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,s,i,a){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=s,this.retryAfterMs=i,this.detail=a}}class Bt extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function wo(e,t){return e instanceof _e||e instanceof Bt?bs(e.code)?bo(e.code):e.message===hd?kg():e.message:t}function Eg(e,t,n,r){return typeof r=="string"?r:n===Li.noCredential?qe.noCredential:n===Li.transportFailed?qe.transportFailed:Om(cg(e).path,t)}async function xe(e){const t=await pd(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new _e(t.status,r??hd,void 0,Eg(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&Ig(n?.result),n?.result}function Ig(e){if(typeof e!="object"||e===null)return;const t=wg(e.delegated_cleanup_notice);t&&fd.getState().receive(t)}async function Rg(){try{await xe({op:"delegated_cleanup_notice.ack"})}catch{}}async function FE(){fd.getState().dismiss(),await Rg()}function xg(e){return e instanceof _e&&e.code===vo}function BE(e){if(!(e instanceof _e))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===ug:e.code===dg}function GE(e){return e instanceof Bt&&e.code===ld}function Tg(e){return e instanceof Error&&e.message.includes(dd)}async function HE(e){const t=await pd(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function WE(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await xe({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function Cg(e,t){const n=window.api?.desktop?.stream;if(n){const i=n.subscribe(e,t);return()=>i.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),as(r,"/__desktop/stream",e.orderIds??[]));const s=new EventSource(`/__desktop/stream?${r}`);return s.onmessage=i=>{t({kind:"data",data:i.data})},s.onerror=()=>{s.readyState===EventSource.CLOSED&&(t({kind:"error",detail:Jn.ended}),s.close())},()=>{s.close(),t({kind:"end"})}}async function zE(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),s=r.headers.get("content-type")??"";if(!r.ok){let i="The media request failed.",a;if(s.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")i=l;else if(typeof l=="object"&&l!==null){const d=l;typeof d.text=="string"&&d.text.trim()?i=d.text:typeof d.message=="string"&&d.message.trim()&&(i=d.message),typeof d.code=="string"&&(a=d.code)}}catch{}return{status:r.status,kind:"error",detail:i,code:a!==void 0&&bs(a)?a:i===Li.noCredential?qe.noCredential:void 0}}return s.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:s||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function ZE(e){return e.kind==="error"?bs(e.code)?new Bt(bo(e.code),e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}function Ag(e){if(xg(e))return"deadline";const t=e instanceof _e?e.status:null;return t===null||t===503?"unreachable":t===401||t===403?"unauthorized":t===404?"outdated":"unknown"}const md={unreachable:"",deadline:"",unauthorized:"",get outdated(){return v("ui.common.connection.backend.remedy_outdated")},unknown:""},Ui={get unreachable(){return v("ui.common.connection.backend.diagnosis_unreachable")},get deadline(){return v("ui.common.connection.backend.diagnosis_deadline")},get unauthorized(){return v("ui.common.connection.backend.diagnosis_unauthorized")},get outdated(){return v("ui.common.connection.backend.diagnosis_outdated")},unknown:""};function Pg(e,t){const n=Ag(t);return[e,Ui[n],md[n]].filter(Boolean).join(" ")}const Fi={get successor(){return v("ui.common.connection.backend.pairing_successor")},get"governed-elsewhere"(){return v("ui.common.connection.backend.pairing_governed")},get"pre-handshake"(){return v("ui.common.connection.backend.pairing_pre_handshake")},get"credential-refused"(){return v("ui.common.connection.backend.pairing_credential_refused")},get unpaired(){return v("ui.common.connection.backend.pairing_unpaired")}},Og={get successor(){return v("ui.common.connection.backend.pane_successor")},get"governed-elsewhere"(){return v("ui.common.connection.backend.pane_governed")},get"pre-handshake"(){return v("ui.common.connection.backend.pane_pre_handshake")},get"credential-refused"(){return v("ui.common.connection.backend.pane_credential_refused")},get unpaired(){return v("ui.common.connection.backend.pane_unpaired")}};function KE(e,t){return e!=="unpaired"?null:Og[t??"unpaired"]}function VE(e,t){return e!=="unpaired"?null:Fi[t??"unpaired"]}function YE(e){const{kind:t,unpaired:n,answered:r,cause:s=null,servedByThisApp:i=!1}=e;return s==="pre-handshake"?i:s!==null||n?!1:r?i:t==="outdated"}function QE(e){const{kind:t,unpaired:n,missing:r,answered:s,cause:i=null}=e;if(i!==null)return Fi[i];if(!s){if(t==="unreachable")return v("ui.common.connection.backend.compatibility_unreachable",{diagnosis:Ui.unreachable});if(t==="unauthorized")return v("ui.common.connection.backend.compatibility_unauthorized");if(t==="deadline")return v("ui.common.connection.backend.compatibility_deadline",{diagnosis:Ui.deadline});if(t==="outdated")return v("ui.common.connection.backend.compatibility_outdated",{remedy:md.outdated})}return n?Fi.unpaired:s?v("ui.common.connection.backend.compatibility_missing",{features:r.join(", ")}):v("ui.common.connection.backend.compatibility_unknown")}const jg=["auth","settings","commands","catalogues","lifecycle","mcp","radient"];function JE(e,t=null){return t!==null||!e?!0:jg.filter(r=>(e.features?.[r]??0)<1).length>0||e.desktop_available!==!0}function Mg(e,t){return t instanceof _e&&t.status===null?!1:e<1}function XE(e,t){return t instanceof _e&&t.status!==null&&t.status>=400&&t.status<500&&t.status!==408&&t.status!==425&&t.status!==429?!1:e<1}const Dg={get successor(){return v("ui.common.connection.backend.card_successor")},get"governed-elsewhere"(){return v("ui.common.connection.backend.card_governed")},get"pre-handshake"(){return v("ui.common.connection.backend.card_pre_handshake")},get"credential-refused"(){return v("ui.common.connection.backend.card_credential_refused")},get unpaired(){return v("ui.common.connection.backend.card_unpaired")}};function qE(e,t,n){return e===null?{sentence:Pg(t,n),remedy:!0}:{sentence:Dg[e],remedy:Hl(e)}}const gd={settings:["desktop","settings"],capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],accounts:["desktop","auth","accounts"],catalogue:["desktop","models"],credentials:e=>["desktop","credentials",e]},Ng=3e4,Lg=15e3;function $g(e){return e?.desktop_available===!0}function eI(){const{client:e,provided:t}=gp();return Gl({enabled:t,queryKey:gd.capabilities,queryFn:async()=>{try{return await xe({op:"capabilities"})}catch(n){throw n instanceof Error?n:new Error(String(n))}},staleTime:6e4,retry:!1,refetchInterval:n=>$g(n.state.data)?Ng:Lg,refetchIntervalInBackground:!0},e)}function Ug(e,t,n=1){return e?e.desktop_available?(e.features?.[t]??0)>=n?"enabled":"below-version":"unpaired":"unknown"}function tI(e,t,n=1){return Ug(e,t,n)==="enabled"}function nI(e){return Gl({queryKey:gd.providers,queryFn:()=>xe({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:Mg})}const Un=e=>{const t=e.id;return typeof t=="string"?t:typeof t=="number"?String(t):null};function Fg(e,t){const n=new Set((t.removed??[]).map(String)),r=e.filter(a=>{const c=Un(a);return c===null||!n.has(c)});for(const a of t.upserted??[]){const c=Un(a);if(c===null){r.push(a);continue}const l=r.findIndex(d=>Un(d)===c);l===-1?r.push(a):r[l]=a}if(!t.order)return r;const s=new Map;for(const a of r){const c=Un(a);c!==null&&s.set(c,a)}const i=[];for(const a of t.order){const c=String(a),l=s.get(c);l&&(i.push(l),s.delete(c))}for(const a of r){const c=Un(a);c!==null&&s.has(c)?(i.push(a),s.delete(c)):c===null&&i.push(a)}return i}const Bi=e=>({revision:Je(e),demand:e.orderDemand}),qt=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Tn(e,t,n,r,s,i={}){let a=e;const c=t.journal_generation;if(t.reconcile===!0){const p=typeof c=="string"&&c.length>0?c:void 0;return a.orderNeedsReconcile&&a.orderWantedGeneration===p?a.journalMode?a:{...a,journalMode:!0}:{...a,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:p,orderDemand:p!==void 0?{generation:p}:{}}}if(typeof c!="string"||c.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&s&&a.orderNeedsReconcile&&a.orderDemand===s.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),c!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===c?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:c,orderDemand:{generation:c}};let l=a.journalMode?a:{...a,journalMode:!0};if(c!==a.journalGeneration&&(l={...a,journalMode:!0,journalGeneration:c,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand},i.peer===!0)){const p=(a.orderRevision??0)+1,m=new Map;for(const _ of a.records){const h=_.sourceEntryId??(_.kind==="tool"||_.kind==="supplement"?null:_.id);typeof h=="string"&&h.length>0&&h.length<=128&&m.set(h,p)}l={...l,...m.size>0?{journalBodyOwed:m}:{},journalSourceVoid:void 0}}let d=l.journalPositions??new Map;const u=d,f=(p,m,_)=>{if(!qt(_))return;const h=d.get(p);h&&h.seq>=_||(d===u&&(d=new Map(d)),d.set(p,{entryId:m,seq:_}))};for(const[p,m]of Object.entries(t.journal_ordinals??{}))f(p,p,m);for(const p of n)typeof p.id=="string"&&(f(p.id,p.id,p.journal_seq),p.role==="tool"&&typeof p.tool_call_id=="string"&&f(`tool:${p.tool_call_id}`,p.id,p.journal_seq),typeof p.anchor=="string"&&f(`supplement:${p.anchor}`,p.id,p.journal_seq));return d!==u&&(l={...l,journalPositions:d}),l}function So(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const s=n,i=r;return t.tool_calls.forEach((a,c)=>{!a||typeof a.id!="string"||(n.get(a.id)!==t.id&&(n===s&&(n=new Map(n)),n.set(a.id,t.id)),r.get(a.id)!==c&&(r===i&&(r=new Map(r)),r.set(a.id,c)))}),n===s&&r===i?e:{...e,journalCallOwners:n,journalCallSlots:r}}function _d(e,t){const n=new Set(e.map(i=>i.id));let r=!1,s;for(let i=0;i<e.length;i++){const a=e[i];if(a.kind==="user"&&a.provisional===!0){s=a;continue}if(a.sourcePrecedes!==void 0){if(a.sourceAdmissionAnchor!==void 0){const{sourceAdmissionAnchor:c,...l}=a;e[i]=l,r=!0}s=e[i];continue}!t(a)&&s&&(a.sourceAdmissionAnchor===void 0||!n.has(a.sourceAdmissionAnchor))&&(e[i]={...a,sourceAdmissionAnchor:s.id},r=!0),s=e[i]}return r}function yd(e,t,n,r,s){const i=[],a=new Set;let c=e,l;for(;c!==void 0;){if(s.has(c.id)){l=s.get(c.id);break}if(n(c)){l=r(c);break}if(c.kind==="user"&&c.provisional===!0||a.has(c.id))break;a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor?t.get(c.sourceAdmissionAnchor):void 0}for(const d of i)s.set(d,l);return l}const Bg=Number.MAX_SAFE_INTEGER;function Gg(e,t){const n=new Map,r=new Map,s=new Map;for(const i of e){if(i.sourcePrecedes===void 0)continue;const a=t(i);if(a!==void 0)r.set(i.sourcePrecedes,a);else{const c=r.get(i.sourcePrecedes);c!==void 0&&n.set(i.id,{seq:c,slot:Bg})}}for(let i=e.length-1;i>=0;i--){const a=e[i];if(a.sourcePrecedes===void 0)continue;const c=t(a);if(c!==void 0)s.set(a.sourcePrecedes,c);else if(!n.has(a.id)){const l=s.get(a.sourcePrecedes);l!==void 0&&n.set(a.id,{seq:l,slot:-1})}}return n}function vd(e,t){return{floor:Hg(e,t),position:new Map(e.map((n,r)=>[n.id,r])),page:Gg(e,t)}}function bd(e,t,n,r){if(r===void 0||e.sourcePrecedes===void 0)return;const s=r.page.get(e.id);if(s!==void 0)return s;const i=new Set;let a=1,c=t.get(e.sourcePrecedes);for(;c!==void 0&&!i.has(c.id);){i.add(c.id);const l=n(c);if(l!==void 0)return{seq:l,slot:-a};const d=r.page.get(c.id);if(d!==void 0)return{seq:d.seq,slot:d.slot-a};a+=1,c=c.sourcePrecedes?t.get(c.sourcePrecedes):void 0}return r.floor===void 0?void 0:{seq:r.floor,slot:-a}}function wd(e,t,n){if(n===void 0||e.sourcePrecedes===void 0)return;const{position:r}=n,s=new Set;let i=1,a=t.get(e.sourcePrecedes);for(;a!==void 0&&!s.has(a.id);){if(a.sourcePrecedes===void 0){const c=r.get(a.id);return c===void 0?void 0:{slot:c,depth:i}}s.add(a.id),i+=1,a=t.get(a.sourcePrecedes)}}function Hg(e,t){let n;for(const r of e){if(r.sourcePrecedes!==void 0)continue;const s=t(r);s!==void 0&&(n===void 0||s<n)&&(n=s)}return n}function Sd(e,t){const n=new Map;return r=>{if(!r)return;const s=t(r);if(s===void 0)return;const i=[],a=new Set;let c=r,l=!0;for(;c;){if(n.has(c.id)){l=n.get(c.id)===!0;break}if(a.has(c.id)||t(c)===void 0){l=!1;break}a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor===void 0?void 0:e.get(c.sourceAdmissionAnchor)}for(const d of i)n.set(d,l);return l?s:void 0}}function cs(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const s=new Map;t.forEach((a,c)=>{if(a.kind!=="tool")return;const l=n.get(a.toolCallId);if(l===void 0||!r.has(a.toolCallId))return;const d=s.get(l);d?d.push(c):s.set(l,[c])});let i=t;for(const a of s.values()){if(a.length<2)continue;const c=a.map(l=>t[l]).sort((l,d)=>(r.get(l.toolCallId)??0)-(r.get(d.toolCallId)??0));c.every((l,d)=>l===t[a[d]])||(i===t&&(i=t.slice()),a.forEach((l,d)=>{i[l]=c[d]}))}return i}function kd(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return Wg(e,t);const n=e.journalGeneration,r=e.journalPositions;let s=!1,i=!1;const a=t.map(h=>{h.sourcePrecedes!==void 0&&(i=!0);let g=[r?.get(h.sourceEntryId??h.id),r?.get(h.id)].filter(A=>A!==void 0).sort((A,U)=>U.seq-A.seq)[0];if(h.journalGeneration===n&&qt(h.journalSeq)&&(!g||h.journalSeq>g.seq)&&(g={entryId:h.sourceEntryId??h.id,seq:h.journalSeq}),!g||!n||!(h.kind==="user"&&(h.provisional===!0||h.local===!0))&&h.sourceEntryId===g.entryId&&h.journalSeq===g.seq&&h.journalGeneration===n)return h;s=!0;let E={...h,sourceEntryId:g.entryId,journalSeq:g.seq,journalGeneration:n};if(E.kind==="user"){const{provisional:A,local:U,...P}=E;E=P}return E});_d(a,h=>h.journalGeneration===n&&qt(h.journalSeq))&&(s=!0);const l=new Map,d=new Map(a.map(h=>[h.id,h])),u=Sd(d,h=>h!==void 0&&h.journalGeneration===n&&qt(h.journalSeq)?h.journalSeq:void 0),f=h=>u(h)!==void 0,p=i?vd(a,u):void 0,m=(h,y)=>{const g=u(h);if(h.kind==="user"&&h.provisional===!0&&g===void 0)return[1,0,0,0,y];const k=h.kind==="supplement"?h.anchor:h.kind==="tool"?e.journalCallOwners?.get(h.toolCallId)??e.argsByCall.get(h.toolCallId)?.anchorId:void 0,E=typeof k=="string"?u(d.get(k)):void 0,A=E===void 0&&g===void 0?bd(h,d,u,p):void 0,U=g===void 0&&A===void 0?yd(h,d,f,u,l):void 0,P=E??g??A?.seq??U;if(P===void 0){const O=wd(h,d,p);return[1,O?.slot??y,O?-O.depth:0,0,y]}return[0,P,E!==void 0?1:g!==void 0?0:A!==void 0?A.slot:2,g??Number.MAX_SAFE_INTEGER,y]},_=a.map((h,y)=>({record:h,index:y,rank:m(h,y)}));return _.sort((h,y)=>{for(let g=0;g<h.rank.length;g++){const k=h.rank[g]-y.rank[g];if(k)return k}return 0}),!s&&_.every((h,y)=>h.index===y)?cs(e,t):cs(e,_.map(h=>h.record))}function Wg(e,t){const n=e.journalGeneration,r=e.journalPositions,s=new Map;let i=!1;for(const g of t){g.sourcePrecedes!==void 0&&(i=!0);let E=[r?.get(g.sourceEntryId??g.id),r?.get(g.id)].filter(A=>A!==void 0).sort((A,U)=>U.seq-A.seq)[0];g.journalGeneration===n&&qt(g.journalSeq)&&(!E||g.journalSeq>E.seq)&&(E={entryId:g.sourceEntryId??g.id,seq:g.journalSeq}),E&&s.set(g.id,E)}const a=g=>g===void 0?void 0:s.get(g.id)??r?.get(g.sourceEntryId??g.id)??r?.get(g.id);let c=!1;const l=t.slice();_d(l,g=>g.journalGeneration===n&&qt(g.journalSeq))&&(c=!0);const u=new Map,f=new Map(l.map(g=>[g.id,g])),p=Sd(f,g=>a(g)?.seq),m=g=>p(g)!==void 0,_=i?vd(l,p):void 0,h=(g,k)=>{const E=p(g);if(g.kind==="user"&&g.provisional===!0&&E===void 0)return[1,0,0,0,k];const A=g.kind==="supplement"?g.anchor:g.kind==="tool"?e.journalCallOwners?.get(g.toolCallId)??e.argsByCall.get(g.toolCallId)?.anchorId:void 0,U=typeof A=="string"?p(f.get(A)):void 0,P=U===void 0&&E===void 0?bd(g,f,p,_):void 0,O=E===void 0&&P===void 0?yd(g,f,m,p,u):void 0,I=U??E??P?.seq??O;if(I===void 0){const N=wd(g,f,_);return[1,N?.slot??k,N?-N.depth:0,0,k]}return[0,I,U!==void 0?1:E!==void 0?0:P!==void 0?P.slot:2,E??Number.MAX_SAFE_INTEGER,k]},y=l.map((g,k)=>({record:g,index:k,rank:h(g,k)}));return y.sort((g,k)=>{for(let E=0;E<g.rank.length;E++){const A=g.rank[E]-k.rank[E];if(A)return A}return 0}),!c&&y.every((g,k)=>g.index===k)?cs(e,t):cs(e,y.map(g=>g.record))}function ut(e){const t=e.records.filter(s=>s.kind==="user"&&s.provisional===!0),n=e.records.filter(s=>s.journalGeneration!==e.journalGeneration||!qt(s.journalSeq)),r=[...t,...n].map(s=>s.sourceEntryId??(s.kind==="tool"||s.kind==="supplement"?null:s.id));if(r.push(...ko(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let s=r.length-1;s>=0;s--){const i=r[s];typeof i=="string"&&e.journalSourceVoid.has(i)&&r.splice(s,1)}return[...new Set(r.filter(s=>typeof s=="string"&&s.length>0&&s.length<=128))]}function ko(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const s=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof s=="string"&&s.length>0&&s.length<=128&&t.add(s)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Ed(e,t){const n=e.journalPositions;return ut(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Je=e=>e.orderRevision??0;async function zg(e){const t=new Map,n=c=>{let l=t.get(c);return l||(l=new Set,t.set(c,l)),l},r=(c,l)=>l==="payload"?ko(c):l==="lookup"?Ed(c):ut(c);let s=e.getTranscript().journalGeneration,i=0,a=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const c=e.getTranscript(),l=Bi(c),d=l.revision,u=e.sweep?.(c,n);if(u?.kind==="none")return{kind:"complete",transcript:c};const f=u?.kind??"authority",p=Nh(r(c,f).filter(y=>!n(f).has(y)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),m=await e.read(p,f);if(!e.isCurrent()||Je(e.getTranscript())!==d)return{kind:"stale"};if(e.commit(m,d,l),!e.isCurrent())return{kind:"stale"};const _=e.getTranscript(),h=e.page(m);if(h.journal_order_state==="ready"&&h.journal_generation===_.journalGeneration){h.journal_generation!==s&&(t.clear(),s=h.journal_generation);for(const k of p)n(f).add(k);if(_.orderNeedsReconcile){if(_.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear();continue}if(f==="payload"){const k=(h.source_retry_ids??[]).filter(E=>typeof E=="string"&&E.length>0&&E.length<=128);if(k.length>0&&p.length>1&&a===0){a++;for(const E of k)n("payload").delete(E);continue}}const y=e.sweep?.(_,n);if(y?.kind==="none")return{kind:"complete",transcript:_};const g=y?.kind??"authority";if(r(_,g).some(k=>!n(g).has(k)))continue;return{kind:"complete",transcript:_}}if(!_.orderNeedsReconcile||_.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear()}}function st(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const s=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof s=="string"&&s?s:e.id}function ni(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function bc(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function rI(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const i of t){if(!i.settled||typeof i.run_key!="string"||i.run_key.length===0)continue;const a=ni(i.action_count);if(a===null)continue;const c={actions:a,workedSeconds:bc(i.worked_seconds),failed:ni(i.failed_count)??0,complete:i.complete!==!1,openingUserId:typeof i.opening_user_id=="string"&&i.opening_user_id.length>0?i.opening_user_id:null,closingAnswerId:typeof i.closing_answer_id=="string"&&i.closing_answer_id.length>0?i.closing_answer_id:null,crossSessionActions:ni(i.cross_session_action_count),crossSessionWorkedSeconds:bc(i.cross_session_worked_seconds)};n.set(i.run_key,c),c.openingUserId!==null&&n.set(c.openingUserId,c),c.closingAnswerId!==null&&n.set(c.closingAnswerId,c)}if(n.size===0)return null;const r=new Set;for(const i of e.entries)r.add(st(i));const s=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:s?st(s):null}}}function Zg(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(i=>i.opening_user_id===n.id))return null;const s=Math.round((n.ts??0)*1e3);return s>0?{id:n.id,tsMs:s}:null}function Kg(e,t,n){const r=Zg(e),s=e?.entries;if(r===null||!s||s.length===0)return!1;const i=Math.round((s[s.length-1].ts??0)*1e3);if(!(i>r.tsMs))return!1;for(const[a,c]of t)if(!n.has(a)&&(c===null||!(c>r.tsMs)||!(c<i)))return!1;return!0}const Eo=new Set,Gt="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Io=new RegExp(`[${Gt}]`),Vg=new RegExp(`[${Gt}]+`),sI=new RegExp(`[${Gt}]+`,"g"),Yg=new RegExp(`^[${Gt}]+|[${Gt}]+$`,"g"),Qg=new RegExp(`^[${Gt}]+`),iI=new RegExp(`[^${Gt}]`);function mt(e){return e.replace(Yg,"")}function gr(e){return e.replace(Qg,"")}function Id(e,t){return t===0||Io.test(e[t-1])}function Rd(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&Id(e,n)&&t.push(n);return t}function Ro(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
1
|
+
import{r as S,j as Mf,b as Ra,D as Df}from"./index-D4bPuJfm.js";import{t as v,a as Nf}from"./messages-DoRCUI0R.js";var Er=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},nn=typeof window>"u"||"Deno"in globalThis;function Xe(){}function Lf(e,t){return typeof e=="function"?e(t):e}function ki(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ol(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function ot(e,t){return typeof e=="function"?e(t):e}function xa(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:a,stale:c}=e;if(a){if(r){if(t.queryHash!==po(a,t.options))return!1}else if(!nr(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||s&&s!==t.state.fetchStatus||i&&!i(t))}function Ta(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(tr(t.options.mutationKey)!==tr(i))return!1}else if(!nr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function po(e,t){return(t?.queryKeyHashFn||tr)(e)}function tr(e){return JSON.stringify(e,(t,n)=>Ii(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function nr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>nr(e[n],t[n])):!1}function jl(e,t){if(e===t)return e;const n=Ca(e)&&Ca(t);if(n||Ii(e)&&Ii(t)){const r=n?e:Object.keys(e),s=r.length,i=n?t:Object.keys(t),a=i.length,c=n?[]:{};let l=0;for(let d=0;d<a;d++){const u=n?d:i[d];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(c[u]=void 0,l++):(c[u]=jl(e[u],t[u]),c[u]===e[u]&&e[u]!==void 0&&l++)}return s===a&&l===s?e:c}return t}function Ei(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Ca(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ii(e){if(!Aa(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Aa(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Aa(e){return Object.prototype.toString.call(e)==="[object Object]"}function $f(e){return new Promise(t=>{setTimeout(t,e)})}function Ri(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?jl(e,t):t}function Uf(e){return e}function Ff(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Bf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ho=Symbol();function Ml(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ho?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Gf=class extends Er{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!nn&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},mo=new Gf,Hf=class extends Er{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!nn&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#t}},qr=new Hf;function xi(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}function Wf(e){return Math.min(1e3*2**e,3e4)}function Dl(e){return(e??"online")==="online"?qr.isOnline():!0}var Nl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Gs(e){return e instanceof Nl}function Ll(e){let t=!1,n=0,r=!1,s;const i=xi(),a=h=>{r||(p(new Nl(h)),e.abort?.())},c=()=>{t=!0},l=()=>{t=!1},d=()=>mo.isFocused()&&(e.networkMode==="always"||qr.isOnline())&&e.canRun(),u=()=>Dl(e.networkMode)&&e.canRun(),f=h=>{r||(r=!0,e.onSuccess?.(h),s?.(),i.resolve(h))},p=h=>{r||(r=!0,e.onError?.(h),s?.(),i.reject(h))},m=()=>new Promise(h=>{s=y=>{(r||d())&&h(y)},e.onPause?.()}).then(()=>{s=void 0,r||e.onContinue?.()}),_=()=>{if(r)return;let h;const y=n===0?e.initialPromise:void 0;try{h=y??e.fn()}catch(g){h=Promise.reject(g)}Promise.resolve(h).then(f).catch(g=>{if(r)return;const k=e.retry??(nn?0:3),E=e.retryDelay??Wf,A=typeof E=="function"?E(n,g):E,U=k===!0||typeof k=="number"&&n<k||typeof k=="function"&&k(n,g);if(t||!U){p(g);return}n++,e.onFail?.(n,g),$f(A).then(()=>d()?void 0:m()).then(()=>{t?p(g):_()})})};return{promise:i,cancel:a,continue:()=>(s?.(),i),cancelRetry:c,continueRetry:l,canStart:u,start:()=>(u()?_():m().then(_),i)}}var zf=e=>setTimeout(e,0);function Zf(){let e=[],t=0,n=c=>{c()},r=c=>{c()},s=zf;const i=c=>{t?e.push(c):s(()=>{n(c)})},a=()=>{const c=e;e=[],c.length&&s(()=>{r(()=>{c.forEach(l=>{n(l)})})})};return{batch:c=>{let l;t++;try{l=c()}finally{t--,t||a()}return l},batchCalls:c=>(...l)=>{i(()=>{c(...l)})},schedule:i,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{s=c}}}var De=Zf(),$l=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ki(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(nn?1/0:5*60*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},Kf=class extends $l{#t;#e;#n;#r;#s;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Vf(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#s?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const n=Ri(this.state.data,e,this.options);return this.#i({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#s?.promise;return this.#s?.cancel(e),t?t.then(Xe).catch(Xe):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>ot(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ho||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Ol(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#s&&(this.#o?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(l=>l.options.queryFn);c&&this.setOptions(c.options)}const n=new AbortController,r=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},s=()=>{const c=Ml(this.options,t),l={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(l),this.#o=!1,this.options.persister?this.options.persister(c,l,this):c(l)},i={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:s};r(i),this.options.behavior?.onFetch(i,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#i({type:"fetch",meta:i.fetchOptions?.meta});const a=c=>{Gs(c)&&c.silent||this.#i({type:"error",error:c}),Gs(c)||(this.#n.config.onError?.(c,this),this.#n.config.onSettled?.(this.state.data,c,this)),this.scheduleGc()};return this.#s=Ll({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:c=>{if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(l){a(l);return}this.#n.config.onSuccess?.(c,this),this.#n.config.onSettled?.(c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,l)=>{this.#i({type:"failed",failureCount:c,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#s.start()}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Ul(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return Gs(r)&&r.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),De.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function Ul(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Dl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Vf(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Yf=class extends Er{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,s=t.queryHash??po(r,t);let i=this.get(s);return i||(i=new Kf({client:e,queryKey:r,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(i)),i}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){De.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>xa(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>xa(e,n)):t}notify(e){De.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){De.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){De.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Qf=class extends $l{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||Jf(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=Ll({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(r,s)=>{this.#r({type:"failed",failureCount:r,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",n=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:n}),await this.#e.config.onMutate?.(e,this);const s=await this.options.onMutate?.(e);s!==this.state.context&&this.#r({type:"pending",context:s,variables:e,isPaused:n})}const r=await this.#n.start();return await this.#e.config.onSuccess?.(r,e,this.state.context,this),await this.options.onSuccess?.(r,e,this.state.context),await this.#e.config.onSettled?.(r,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(r,null,e,this.state.context),this.#r({type:"success",data:r}),r}catch(r){try{throw await this.#e.config.onError?.(r,e,this.state.context,this),await this.options.onError?.(r,e,this.state.context),await this.#e.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,r,e,this.state.context),r}finally{this.#r({type:"error",error:r})}}finally{this.#e.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),De.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function Jf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Xf=class extends Er{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,n){const r=new Qf({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=Dr(e);if(typeof t=="string"){const n=this.#e.get(t);n?n.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=Dr(e);if(typeof t=="string"){const n=this.#e.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Dr(e);if(typeof t=="string"){const r=this.#e.get(t)?.find(s=>s.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=Dr(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){De.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ta(t,n))}findAll(e={}){return this.getAll().filter(t=>Ta(e,t))}notify(e){De.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return De.batch(()=>Promise.all(e.map(t=>t.continue().catch(Xe))))}};function Dr(e){return e.options.scope?.id}function Pa(e){return{onFetch:(t,n)=>{const r=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let c={pages:[],pageParams:[]},l=0;const d=async()=>{let u=!1;const f=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},p=Ml(t.options,t.fetchOptions),m=async(_,h,y)=>{if(u)return Promise.reject();if(h==null&&_.pages.length)return Promise.resolve(_);const g={client:t.client,queryKey:t.queryKey,pageParam:h,direction:y?"backward":"forward",meta:t.options.meta};f(g);const k=await p(g),{maxPages:E}=t.options,A=y?Bf:Ff;return{pages:A(_.pages,k,E),pageParams:A(_.pageParams,h,E)}};if(s&&i.length){const _=s==="backward",h=_?Fl:Ti,y={pages:i,pageParams:a},g=h(r,y);c=await m(y,g,_)}else{const _=e??i.length;do{const h=l===0?a[0]??r.initialPageParam:Ti(r,c);if(l>0&&h==null)break;c=await m(c,h),l++}while(l<_)}return c};t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=d}}}function Ti(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Fl(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function dE(e,t){return t?Ti(e,t)!=null:!1}function uE(e,t){return!t||!e.getPreviousPageParam?!1:Fl(e,t)!=null}var qf=class{#t;#e;#n;#r;#s;#a;#o;#i;constructor(e={}){this.#t=e.queryCache||new Yf,this.#e=e.mutationCache||new Xf,this.#n=e.defaultOptions||{},this.#r=new Map,this.#s=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=mo.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#i=qr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#t.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=this.#t.get(r.queryHash)?.state.data,a=Lf(t,i);if(a!==void 0)return this.#t.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return De.batch(()=>this.#t.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;De.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return De.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=De.batch(()=>this.#t.findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Xe).catch(Xe)}invalidateQueries(e,t={}){return De.batch(()=>(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=De.batch(()=>this.#t.findAll(e).filter(s=>!s.isDisabled()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Xe)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Xe)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Xe).catch(Xe)}fetchInfiniteQuery(e){return e.behavior=Pa(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Xe).catch(Xe)}ensureInfiniteQueryData(e){return e.behavior=Pa(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return qr.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(tr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{nr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#s.set(tr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#s.values()],n={};return t.forEach(r=>{nr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=po(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ho&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},ep=class extends Er{constructor(e,t){super(),this.options=t,this.#t=e,this.#i=null,this.#o=xi(),this.options.experimental_prefetchInRender||this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#s;#a;#o;#i;#m;#f;#p;#l;#d;#c;#h=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Oa(this.#e,this.options)?this.#u():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ci(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ci(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ot(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#e.setOptions(this.options),t._defaulted&&!Ei(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&ja(this.#e,n,this.options,t)&&this.#u(),this.updateResult(),r&&(this.#e!==n||ot(this.options.enabled,this.#e)!==ot(t.enabled,this.#e)||bn(this.options.staleTime,this.#e)!==bn(t.staleTime,this.#e))&&this.#g();const s=this.#_();r&&(this.#e!==n||ot(this.options.enabled,this.#e)!==ot(t.enabled,this.#e)||s!==this.#c)&&this.#y(s)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),n=this.createResult(t,e);return np(this,n)&&(this.#r=n,this.#a=this.options,this.#s=this.#e.state),n}getCurrentResult(){return this.#r}trackResult(e,t){const n={};return Object.keys(e).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})}),n}trackProp(e){this.#h.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),n=this.#t.getQueryCache().build(this.#t,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#u({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#u(e){this.#S();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Xe)),t}#g(){this.#b();const e=bn(this.options.staleTime,this.#e);if(nn||this.#r.isStale||!ki(e))return;const n=Ol(this.#r.dataUpdatedAt,e)+1;this.#l=setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#_(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#c=e,!(nn||ot(this.options.enabled,this.#e)===!1||!ki(this.#c)||this.#c===0)&&(this.#d=setInterval(()=>{(this.options.refetchIntervalInBackground||mo.isFocused())&&this.#u()},this.#c))}#v(){this.#g(),this.#y(this.#_())}#b(){this.#l&&(clearTimeout(this.#l),this.#l=void 0)}#w(){this.#d&&(clearInterval(this.#d),this.#d=void 0)}createResult(e,t){const n=this.#e,r=this.options,s=this.#r,i=this.#s,a=this.#a,l=e!==n?e.state:this.#n,{state:d}=e;let u={...d},f=!1,p;if(t._optimisticResults){const I=this.hasListeners(),N=!I&&Oa(e,t),K=I&&ja(e,n,t,r);(N||K)&&(u={...u,...Ul(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:_,status:h}=u;p=u.data;let y=!1;if(t.placeholderData!==void 0&&p===void 0&&h==="pending"){let I;s?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(I=s.data,y=!0):I=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,I!==void 0&&(h="success",p=Ri(s?.data,I,t),f=!0)}if(t.select&&p!==void 0&&!y)if(s&&p===i?.data&&t.select===this.#m)p=this.#f;else try{this.#m=t.select,p=t.select(p),p=Ri(s?.data,p,t),this.#f=p,this.#i=null}catch(I){this.#i=I}this.#i&&(m=this.#i,p=this.#f,_=Date.now(),h="error");const g=u.fetchStatus==="fetching",k=h==="pending",E=h==="error",A=k&&g,U=p!==void 0,O={status:h,fetchStatus:u.fetchStatus,isPending:k,isSuccess:h==="success",isError:E,isInitialLoading:A,isLoading:A,data:p,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:_,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:g,isRefetching:g&&!k,isLoadingError:E&&!U,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:E&&U,isStale:go(e,t),refetch:this.refetch,promise:this.#o};if(this.options.experimental_prefetchInRender){const I=pe=>{O.status==="error"?pe.reject(O.error):O.data!==void 0&&pe.resolve(O.data)},N=()=>{const pe=this.#o=O.promise=xi();I(pe)},K=this.#o;switch(K.status){case"pending":e.queryHash===n.queryHash&&I(K);break;case"fulfilled":(O.status==="error"||O.data!==K.value)&&N();break;case"rejected":(O.status!=="error"||O.error!==K.reason)&&N();break}}return O}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#s=this.#e.state,this.#a=this.options,this.#s.data!==void 0&&(this.#p=this.#e),Ei(t,e))return;this.#r=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,s=typeof r=="function"?r():r;if(s==="all"||!s&&!this.#h.size)return!0;const i=new Set(s??this.#h);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(a=>{const c=a;return this.#r[c]!==e[c]&&i.has(c)})};this.#k({listeners:n()})}#S(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#k(e){De.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function tp(e,t){return ot(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Oa(e,t){return tp(e,t)||e.state.data!==void 0&&Ci(e,t,t.refetchOnMount)}function Ci(e,t,n){if(ot(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&go(e,t)}return!1}function ja(e,t,n,r){return(e!==t||ot(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&go(e,n)}function go(e,t){return ot(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function np(e,t){return!Ei(e.getCurrentResult(),t)}var _o=S.createContext(void 0),rp=e=>{const t=S.useContext(_o);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},fE=({client:e,children:t})=>(S.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),Mf.jsx(_o.Provider,{value:e,children:t})),Bl=S.createContext(!1),sp=()=>S.useContext(Bl);Bl.Provider;function ip(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var op=S.createContext(ip()),ap=()=>S.useContext(op);function cp(e,t){return typeof e=="function"?e(...t):!!e}function Ma(){}var lp=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},dp=e=>{S.useEffect(()=>{e.clearReset()},[e])},up=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||cp(n,[e.error,r])),fp=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},pp=(e,t)=>e.isLoading&&e.isFetching&&!t,hp=(e,t)=>e?.suspense&&t.isPending,Da=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function mp(e,t,n){const r=rp(n),s=sp(),i=ap(),a=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=s?"isRestoring":"optimistic",fp(a),lp(a,i),dp(i);const c=!r.getQueryCache().get(a.queryHash),[l]=S.useState(()=>new t(r,a)),d=l.getOptimisticResult(a),u=!s&&e.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(f=>{const p=u?l.subscribe(De.batchCalls(f)):Ma;return l.updateResult(),p},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),S.useEffect(()=>{l.setOptions(a)},[a,l]),hp(a,d))throw Da(a,l,i);if(up({result:d,errorResetBoundary:i,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw d.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(a,d),a.experimental_prefetchInRender&&!nn&&pp(d,s)&&(c?Da(a,l,i):r.getQueryCache().get(a.queryHash)?.promise)?.catch(Ma).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?d:l.trackResult(d)}function Gl(e,t){return mp(e,ep,t)}const gp=()=>{const e=S.useContext(_o)??null,t=S.useMemo(()=>new qf({defaultOptions:{queries:{enabled:!1,retry:!1,gcTime:0}}}),[]);return S.useEffect(()=>{if(!e)return()=>t.clear()},[e,t]),S.useMemo(()=>e?{client:e,provided:!0}:{client:t,provided:!1},[e,t])};function pE(e){return e!=="detached"&&e!=="wedged"}function Hl(e){return e!=="governed-elsewhere"&&e!=="pre-handshake"}function hE(e){if(!e)return{title:"Not connected to a Local Operator server.",detail:null,retry:!0};const t=e.addressSubstitution??null;if(t&&e.state!=="detached"&&e.state!=="wedged")return t.kind==="substituted"?{title:`Serving on ${t.serving}, not the address this app is configured for.`,detail:t.holder?`${t.holder}. The app uses ${t.serving} while that holds.${t.reclaim?` ${t.reclaim}`:""} It is back on ${t.configured} on its next launch or recovery.`:`The daemon this app is using was already running, so it did not start one. It looks for ${t.configured} again on its next launch or recovery.`,retry:!0}:{title:`Back on ${t.configured}, the address this app is configured for.`,detail:`It served on ${t.serving} while the configured address was held; it is on the address it was told to use again.`,retry:!1,dismiss:!0};const n=e.detail?.trim()?e.detail.trim():null,r=Hl(e.pairing?.cause??null);switch(e.state){case"wedged":return{title:"A Local Operator server is running on this machine and this app is not attached to it.",detail:n,retry:r};case"detached":return e.reconnecting?{title:r?"Not connected to a Local Operator server. If one is still running, the app reconnects to it on its own.":"Not connected to a Local Operator server.",detail:n,retry:r}:{title:r?"The Local Operator server stopped. The app keeps looking for one and attaches to it when it appears.":"Not connected to a Local Operator server. The app keeps looking for one.",detail:n,retry:r};default:return null}}var re;(function(e){e.assertEqual=s=>s;function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),a={};for(const c of i)a[c]=s[c];return e.objectValues(a)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},e.find=(s,i)=>{for(const a of s)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(re||(re={}));var Ai;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Ai||(Ai={}));const M=re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),kt=e=>{switch(typeof e){case"undefined":return M.undefined;case"string":return M.string;case"number":return isNaN(e)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(e)?M.array:e===null?M.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?M.promise:typeof Map<"u"&&e instanceof Map?M.map:typeof Set<"u"&&e instanceof Set?M.set:typeof Date<"u"&&e instanceof Date?M.date:M.object;default:return M.unknown}},x=re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),_p=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ye extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,l=0;for(;l<a.path.length;){const d=a.path[l];l===a.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(n(a))):c[d]=c[d]||{_errors:[]},c=c[d],l++}}};return s(this),r}static assert(t){if(!(t instanceof Ye))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ye.create=e=>new Ye(e);const In=(e,t)=>{let n;switch(e.code){case x.invalid_type:e.received===M.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case x.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,re.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:n=`Unrecognized key(s) in object: ${re.joinValues(e.keys,", ")}`;break;case x.invalid_union:n="Invalid input";break;case x.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${re.joinValues(e.options)}`;break;case x.invalid_enum_value:n=`Invalid enum value. Expected ${re.joinValues(e.options)}, received '${e.received}'`;break;case x.invalid_arguments:n="Invalid function arguments";break;case x.invalid_return_type:n="Invalid function return type";break;case x.invalid_date:n="Invalid date";break;case x.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:re.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case x.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case x.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case x.custom:n="Invalid input";break;case x.invalid_intersection_types:n="Intersection results could not be merged";break;case x.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case x.not_finite:n="Number must be finite";break;default:n=t.defaultError,re.assertNever(e)}return{message:n}};let Wl=In;function yp(e){Wl=e}function es(){return Wl}const ts=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="";const l=r.filter(d=>!!d).slice().reverse();for(const d of l)c=d(a,{data:t,defaultError:c}).message;return{...s,path:i,message:c}},vp=[];function j(e,t){const n=es(),r=ts({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===In?void 0:In].filter(s=>!!s)});e.common.issues.push(r)}class $e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return W;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return $e.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return W;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:t.value,value:r}}}const W=Object.freeze({status:"aborted"}),_n=e=>({status:"dirty",value:e}),Ue=e=>({status:"valid",value:e}),Pi=e=>e.status==="aborted",Oi=e=>e.status==="dirty",rn=e=>e.status==="valid",rr=e=>typeof Promise<"u"&&e instanceof Promise;function ns(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function zl(e,t,n,r,s){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var $;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})($||($={}));var Wn,zn;class gt{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Na=(e,t)=>{if(rn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ye(e.common.issues);return this._error=n,this._error}}};function J(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(a,c)=>{var l,d;const{message:u}=e;return a.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:(l=u??r)!==null&&l!==void 0?l:c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:(d=u??n)!==null&&d!==void 0?d:c.defaultError}},description:s}}class X{get description(){return this._def.description}_getType(t){return kt(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:kt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new $e,ctx:{common:t.parent.common,data:t.data,parsedType:kt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(rr(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const s={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:kt(t)},i=this._parseSync({data:t,path:s.path,parent:s});return Na(s,i)}"~validate"(t){var n,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:kt(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:s});return rn(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(n=i?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:s}).then(i=>rn(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:kt(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(rr(s)?s:Promise.resolve(s));return Na(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const a=t(s),c=()=>i.addIssue({code:x.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new lt({schema:this,typeName:G.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ht.create(this,this._def)}nullable(){return Ft.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ct.create(this)}promise(){return xn.create(this,this._def)}or(t){return ar.create([this,t],this._def)}and(t){return cr.create(this,t,this._def)}transform(t){return new lt({...J(this._def),schema:this,typeName:G.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new pr({...J(this._def),innerType:this,defaultValue:n,typeName:G.ZodDefault})}brand(){return new yo({typeName:G.ZodBranded,type:this,...J(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new hr({...J(this._def),innerType:this,catchValue:n,typeName:G.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ir.create(this,t)}readonly(){return mr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const bp=/^c[^\s-]{8,}$/i,wp=/^[0-9a-z]+$/,Sp=/^[0-9A-HJKMNP-TV-Z]{26}$/i,kp=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ep=/^[a-z0-9_-]{21}$/i,Ip=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rp=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xp=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Hs;const Cp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ap=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Pp=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Op=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Mp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Zl="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Dp=new RegExp(`^${Zl}$`);function Kl(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Np(e){return new RegExp(`^${Kl(e)}$`)}function Vl(e){let t=`${Zl}T${Kl(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Lp(e,t){return!!((t==="v4"||!t)&&Cp.test(e)||(t==="v6"||!t)&&Pp.test(e))}function $p(e,t){if(!Ip.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||t&&s.alg!==t)}catch{return!1}}function Up(e,t){return!!((t==="v4"||!t)&&Ap.test(e)||(t==="v6"||!t)&&Op.test(e))}class at extends X{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==M.string){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_type,expected:M.string,received:i.parsedType}),W}const r=new $e;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=t.data.length>i.value,c=t.data.length<i.value;(a||c)&&(s=this._getOrReturnCtx(t,s),a?j(s,{code:x.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&j(s,{code:x.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")xp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"email",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Hs||(Hs=new RegExp(Tp,"u")),Hs.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"emoji",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")kp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"uuid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ep.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"nanoid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")bp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"cuid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")wp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"cuid2",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Sp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"ulid",code:x.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),j(s,{validation:"url",code:x.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"regex",code:x.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Vl(i).test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Dp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Np(i).test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{code:x.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Rp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"duration",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Lp(t.data,i.version)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"ip",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?$p(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"jwt",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Up(t.data,i.version)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"cidr",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?jp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"base64",code:x.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Mp.test(t.data)||(s=this._getOrReturnCtx(t,s),j(s,{validation:"base64url",code:x.invalid_string,message:i.message}),r.dirty()):re.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:x.invalid_string,...$.errToObj(r)})}_addCheck(t){return new at({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...$.errToObj(t)})}url(t){return this._addCheck({kind:"url",...$.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...$.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...$.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...$.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...$.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...$.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...$.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...$.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...$.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...$.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...$.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...$.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...$.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...$.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...$.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...$.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...$.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...$.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...$.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...$.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...$.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...$.errToObj(n)})}nonempty(t){return this.min(1,$.errToObj(t))}trim(){return new at({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new at({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new at({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}at.create=e=>{var t;return new at({checks:[],typeName:G.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...J(e)})};function Fp(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=parseInt(e.toFixed(s).replace(".","")),a=parseInt(t.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class Lt extends X{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==M.number){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_type,expected:M.number,received:i.parsedType}),W}let r;const s=new $e;for(const i of this._def.checks)i.kind==="int"?re.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),j(r,{code:x.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Fp(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),j(r,{code:x.not_finite,message:i.message}),s.dirty()):re.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,$.toString(n))}gt(t,n){return this.setLimit("min",t,!1,$.toString(n))}lte(t,n){return this.setLimit("max",t,!0,$.toString(n))}lt(t,n){return this.setLimit("max",t,!1,$.toString(n))}setLimit(t,n,r,s){return new Lt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:$.toString(s)}]})}_addCheck(t){return new Lt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:$.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:$.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:$.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:$.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:$.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:$.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:$.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:$.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:$.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&re.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Lt.create=e=>new Lt({checks:[],typeName:G.ZodNumber,coerce:e?.coerce||!1,...J(e)});class $t extends X{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==M.bigint)return this._getInvalidInput(t);let r;const s=new $e;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),j(r,{code:x.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):re.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return j(n,{code:x.invalid_type,expected:M.bigint,received:n.parsedType}),W}gte(t,n){return this.setLimit("min",t,!0,$.toString(n))}gt(t,n){return this.setLimit("min",t,!1,$.toString(n))}lte(t,n){return this.setLimit("max",t,!0,$.toString(n))}lt(t,n){return this.setLimit("max",t,!1,$.toString(n))}setLimit(t,n,r,s){return new $t({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:$.toString(s)}]})}_addCheck(t){return new $t({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:$.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:$.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:$.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:$.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:$.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}$t.create=e=>{var t;return new $t({checks:[],typeName:G.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...J(e)})};class sr extends X{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==M.boolean){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.boolean,received:r.parsedType}),W}return Ue(t.data)}}sr.create=e=>new sr({typeName:G.ZodBoolean,coerce:e?.coerce||!1,...J(e)});class sn extends X{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==M.date){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_type,expected:M.date,received:i.parsedType}),W}if(isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return j(i,{code:x.invalid_date}),W}const r=new $e;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),j(s,{code:x.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):re.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new sn({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:$.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:$.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}sn.create=e=>new sn({checks:[],coerce:e?.coerce||!1,typeName:G.ZodDate,...J(e)});class rs extends X{_parse(t){if(this._getType(t)!==M.symbol){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.symbol,received:r.parsedType}),W}return Ue(t.data)}}rs.create=e=>new rs({typeName:G.ZodSymbol,...J(e)});class ir extends X{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.undefined,received:r.parsedType}),W}return Ue(t.data)}}ir.create=e=>new ir({typeName:G.ZodUndefined,...J(e)});class or extends X{_parse(t){if(this._getType(t)!==M.null){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.null,received:r.parsedType}),W}return Ue(t.data)}}or.create=e=>new or({typeName:G.ZodNull,...J(e)});class Rn extends X{constructor(){super(...arguments),this._any=!0}_parse(t){return Ue(t.data)}}Rn.create=e=>new Rn({typeName:G.ZodAny,...J(e)});class Xt extends X{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ue(t.data)}}Xt.create=e=>new Xt({typeName:G.ZodUnknown,...J(e)});class Et extends X{_parse(t){const n=this._getOrReturnCtx(t);return j(n,{code:x.invalid_type,expected:M.never,received:n.parsedType}),W}}Et.create=e=>new Et({typeName:G.ZodNever,...J(e)});class ss extends X{_parse(t){if(this._getType(t)!==M.undefined){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.void,received:r.parsedType}),W}return Ue(t.data)}}ss.create=e=>new ss({typeName:G.ZodVoid,...J(e)});class ct extends X{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==M.array)return j(n,{code:x.invalid_type,expected:M.array,received:n.parsedType}),W;if(s.exactLength!==null){const a=n.data.length>s.exactLength.value,c=n.data.length<s.exactLength.value;(a||c)&&(j(n,{code:a?x.too_big:x.too_small,minimum:c?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(j(n,{code:x.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(j(n,{code:x.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>s.type._parseAsync(new gt(n,a,n.path,c)))).then(a=>$e.mergeArray(r,a));const i=[...n.data].map((a,c)=>s.type._parseSync(new gt(n,a,n.path,c)));return $e.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new ct({...this._def,minLength:{value:t,message:$.toString(n)}})}max(t,n){return new ct({...this._def,maxLength:{value:t,message:$.toString(n)}})}length(t,n){return new ct({...this._def,exactLength:{value:t,message:$.toString(n)}})}nonempty(t){return this.min(1,t)}}ct.create=(e,t)=>new ct({type:e,minLength:null,maxLength:null,exactLength:null,typeName:G.ZodArray,...J(t)});function hn(e){if(e instanceof be){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ht.create(hn(r))}return new be({...e._def,shape:()=>t})}else return e instanceof ct?new ct({...e._def,type:hn(e.element)}):e instanceof ht?ht.create(hn(e.unwrap())):e instanceof Ft?Ft.create(hn(e.unwrap())):e instanceof _t?_t.create(e.items.map(t=>hn(t))):e}class be extends X{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=re.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==M.object){const d=this._getOrReturnCtx(t);return j(d,{code:x.invalid_type,expected:M.object,received:d.parsedType}),W}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const d in s.data)a.includes(d)||c.push(d);const l=[];for(const d of a){const u=i[d],f=s.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new gt(s,f,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof Et){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of c)l.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(d==="strict")c.length>0&&(j(s,{code:x.unrecognized_keys,keys:c}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of c){const f=s.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new gt(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of l){const f=await u.key,p=await u.value;d.push({key:f,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>$e.mergeObjectSync(r,d)):$e.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return $.errToObj,new be({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,i,a,c;const l=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(c=$.errToObj(t).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new be({...this._def,unknownKeys:"strip"})}passthrough(){return new be({...this._def,unknownKeys:"passthrough"})}extend(t){return new be({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new be({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:G.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new be({...this._def,catchall:t})}pick(t){const n={};return re.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new be({...this._def,shape:()=>n})}omit(t){const n={};return re.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new be({...this._def,shape:()=>n})}deepPartial(){return hn(this)}partial(t){const n={};return re.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}),new be({...this._def,shape:()=>n})}required(t){const n={};return re.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ht;)i=i._def.innerType;n[r]=i}}),new be({...this._def,shape:()=>n})}keyof(){return Yl(re.objectKeys(this.shape))}}be.create=(e,t)=>new be({shape:()=>e,unknownKeys:"strip",catchall:Et.create(),typeName:G.ZodObject,...J(t)});be.strictCreate=(e,t)=>new be({shape:()=>e,unknownKeys:"strict",catchall:Et.create(),typeName:G.ZodObject,...J(t)});be.lazycreate=(e,t)=>new be({shape:e,unknownKeys:"strip",catchall:Et.create(),typeName:G.ZodObject,...J(t)});class ar extends X{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;const a=i.map(c=>new Ye(c.ctx.common.issues));return j(n,{code:x.invalid_union,unionErrors:a}),W}if(n.common.async)return Promise.all(r.map(async i=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const l of r){const d={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const c=a.map(l=>new Ye(l));return j(n,{code:x.invalid_union,unionErrors:c}),W}}get options(){return this._def.options}}ar.create=(e,t)=>new ar({options:e,typeName:G.ZodUnion,...J(t)});const wt=e=>e instanceof dr?wt(e.schema):e instanceof lt?wt(e.innerType()):e instanceof ur?[e.value]:e instanceof Ut?e.options:e instanceof fr?re.objectValues(e.enum):e instanceof pr?wt(e._def.innerType):e instanceof ir?[void 0]:e instanceof or?[null]:e instanceof ht?[void 0,...wt(e.unwrap())]:e instanceof Ft?[null,...wt(e.unwrap())]:e instanceof yo||e instanceof mr?wt(e.unwrap()):e instanceof hr?wt(e._def.innerType):[];class _s extends X{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.object)return j(n,{code:x.invalid_type,expected:M.object,received:n.parsedType}),W;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(j(n,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const a=wt(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const c of a){if(s.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);s.set(c,i)}}return new _s({typeName:G.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...J(r)})}}function ji(e,t){const n=kt(e),r=kt(t);if(e===t)return{valid:!0,data:e};if(n===M.object&&r===M.object){const s=re.objectKeys(t),i=re.objectKeys(e).filter(c=>s.indexOf(c)!==-1),a={...e,...t};for(const c of i){const l=ji(e[c],t[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(n===M.array&&r===M.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const a=e[i],c=t[i],l=ji(a,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===M.date&&r===M.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class cr extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,a)=>{if(Pi(i)||Pi(a))return W;const c=ji(i.value,a.value);return c.valid?((Oi(i)||Oi(a))&&n.dirty(),{status:n.value,value:c.data}):(j(r,{code:x.invalid_intersection_types}),W)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}cr.create=(e,t,n)=>new cr({left:e,right:t,typeName:G.ZodIntersection,...J(n)});class _t extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.array)return j(r,{code:x.invalid_type,expected:M.array,received:r.parsedType}),W;if(r.data.length<this._def.items.length)return j(r,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W;!this._def.rest&&r.data.length>this._def.items.length&&(j(r,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((a,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new gt(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>$e.mergeArray(n,a)):$e.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new _t({...this._def,rest:t})}}_t.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _t({items:e,typeName:G.ZodTuple,rest:null,...J(t)})};class lr extends X{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.object)return j(r,{code:x.invalid_type,expected:M.object,received:r.parsedType}),W;const s=[],i=this._def.keyType,a=this._def.valueType;for(const c in r.data)s.push({key:i._parse(new gt(r,c,r.path,c)),value:a._parse(new gt(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?$e.mergeObjectAsync(n,s):$e.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof X?new lr({keyType:t,valueType:n,typeName:G.ZodRecord,...J(r)}):new lr({keyType:at.create(),valueType:t,typeName:G.ZodRecord,...J(n)})}}class is extends X{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.map)return j(r,{code:x.invalid_type,expected:M.map,received:r.parsedType}),W;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,l],d)=>({key:s._parse(new gt(r,c,r.path,[d,"key"])),value:i._parse(new gt(r,l,r.path,[d,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of a){const d=await l.key,u=await l.value;if(d.status==="aborted"||u.status==="aborted")return W;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}})}else{const c=new Map;for(const l of a){const d=l.key,u=l.value;if(d.status==="aborted"||u.status==="aborted")return W;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),c.set(d.value,u.value)}return{status:n.value,value:c}}}}is.create=(e,t,n)=>new is({valueType:t,keyType:e,typeName:G.ZodMap,...J(n)});class on extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==M.set)return j(r,{code:x.invalid_type,expected:M.set,received:r.parsedType}),W;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(j(r,{code:x.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(j(r,{code:x.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function a(l){const d=new Set;for(const u of l){if(u.status==="aborted")return W;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}const c=[...r.data.values()].map((l,d)=>i._parse(new gt(r,l,r.path,d)));return r.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(t,n){return new on({...this._def,minSize:{value:t,message:$.toString(n)}})}max(t,n){return new on({...this._def,maxSize:{value:t,message:$.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}on.create=(e,t)=>new on({valueType:e,minSize:null,maxSize:null,typeName:G.ZodSet,...J(t)});class wn extends X{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.function)return j(n,{code:x.invalid_type,expected:M.function,received:n.parsedType}),W;function r(c,l){return ts({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,es(),In].filter(d=>!!d),issueData:{code:x.invalid_arguments,argumentsError:l}})}function s(c,l){return ts({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,es(),In].filter(d=>!!d),issueData:{code:x.invalid_return_type,returnTypeError:l}})}const i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof xn){const c=this;return Ue(async function(...l){const d=new Ye([]),u=await c._def.args.parseAsync(l,i).catch(m=>{throw d.addIssue(r(l,m)),d}),f=await Reflect.apply(a,this,u);return await c._def.returns._def.type.parseAsync(f,i).catch(m=>{throw d.addIssue(s(f,m)),d})})}else{const c=this;return Ue(function(...l){const d=c._def.args.safeParse(l,i);if(!d.success)throw new Ye([r(l,d.error)]);const u=Reflect.apply(a,this,d.data),f=c._def.returns.safeParse(u,i);if(!f.success)throw new Ye([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new wn({...this._def,args:_t.create(t).rest(Xt.create())})}returns(t){return new wn({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new wn({args:t||_t.create([]).rest(Xt.create()),returns:n||Xt.create(),typeName:G.ZodFunction,...J(r)})}}class dr extends X{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}dr.create=(e,t)=>new dr({getter:e,typeName:G.ZodLazy,...J(t)});class ur extends X{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return j(n,{received:n.data,code:x.invalid_literal,expected:this._def.value}),W}return{status:"valid",value:t.data}}get value(){return this._def.value}}ur.create=(e,t)=>new ur({value:e,typeName:G.ZodLiteral,...J(t)});function Yl(e,t){return new Ut({values:e,typeName:G.ZodEnum,...J(t)})}class Ut extends X{constructor(){super(...arguments),Wn.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return j(n,{expected:re.joinValues(r),received:n.parsedType,code:x.invalid_type}),W}if(ns(this,Wn)||zl(this,Wn,new Set(this._def.values)),!ns(this,Wn).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return j(n,{received:n.data,code:x.invalid_enum_value,options:r}),W}return Ue(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Ut.create(t,{...this._def,...n})}exclude(t,n=this._def){return Ut.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Wn=new WeakMap;Ut.create=Yl;class fr extends X{constructor(){super(...arguments),zn.set(this,void 0)}_parse(t){const n=re.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==M.string&&r.parsedType!==M.number){const s=re.objectValues(n);return j(r,{expected:re.joinValues(s),received:r.parsedType,code:x.invalid_type}),W}if(ns(this,zn)||zl(this,zn,new Set(re.getValidEnumValues(this._def.values))),!ns(this,zn).has(t.data)){const s=re.objectValues(n);return j(r,{received:r.data,code:x.invalid_enum_value,options:s}),W}return Ue(t.data)}get enum(){return this._def.values}}zn=new WeakMap;fr.create=(e,t)=>new fr({values:e,typeName:G.ZodNativeEnum,...J(t)});class xn extends X{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==M.promise&&n.common.async===!1)return j(n,{code:x.invalid_type,expected:M.promise,received:n.parsedType}),W;const r=n.parsedType===M.promise?n.data:Promise.resolve(n.data);return Ue(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}xn.create=(e,t)=>new xn({type:e,typeName:G.ZodPromise,...J(t)});class lt extends X{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===G.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:a=>{j(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return W;const l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?W:l.status==="dirty"||n.value==="dirty"?_n(l.value):l});{if(n.value==="aborted")return W;const c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?W:c.status==="dirty"||n.value==="dirty"?_n(c.value):c}}if(s.type==="refinement"){const a=c=>{const l=s.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?W:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?W:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!rn(a))return a;const c=s.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>rn(a)?Promise.resolve(s.transform(a.value,i)).then(c=>({status:n.value,value:c})):a);re.assertNever(s)}}lt.create=(e,t,n)=>new lt({schema:e,typeName:G.ZodEffects,effect:t,...J(n)});lt.createWithPreprocess=(e,t,n)=>new lt({schema:t,effect:{type:"preprocess",transform:e},typeName:G.ZodEffects,...J(n)});class ht extends X{_parse(t){return this._getType(t)===M.undefined?Ue(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ht.create=(e,t)=>new ht({innerType:e,typeName:G.ZodOptional,...J(t)});class Ft extends X{_parse(t){return this._getType(t)===M.null?Ue(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ft.create=(e,t)=>new Ft({innerType:e,typeName:G.ZodNullable,...J(t)});class pr extends X{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===M.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}pr.create=(e,t)=>new pr({innerType:e,typeName:G.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...J(t)});class hr extends X{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return rr(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ye(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ye(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}hr.create=(e,t)=>new hr({innerType:e,typeName:G.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...J(t)});class os extends X{_parse(t){if(this._getType(t)!==M.nan){const r=this._getOrReturnCtx(t);return j(r,{code:x.invalid_type,expected:M.nan,received:r.parsedType}),W}return{status:"valid",value:t.data}}}os.create=e=>new os({typeName:G.ZodNaN,...J(e)});const Bp=Symbol("zod_brand");class yo extends X{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Ir extends X{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?W:i.status==="dirty"?(n.dirty(),_n(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?W:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new Ir({in:t,out:n,typeName:G.ZodPipeline})}}class mr extends X{_parse(t){const n=this._def.innerType._parse(t),r=s=>(rn(s)&&(s.value=Object.freeze(s.value)),s);return rr(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}mr.create=(e,t)=>new mr({innerType:e,typeName:G.ZodReadonly,...J(t)});function La(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Ql(e,t={},n){return e?Rn.create().superRefine((r,s)=>{var i,a;const c=e(r);if(c instanceof Promise)return c.then(l=>{var d,u;if(!l){const f=La(t,r),p=(u=(d=f.fatal)!==null&&d!==void 0?d:n)!==null&&u!==void 0?u:!0;s.addIssue({code:"custom",...f,fatal:p})}});if(!c){const l=La(t,r),d=(a=(i=l.fatal)!==null&&i!==void 0?i:n)!==null&&a!==void 0?a:!0;s.addIssue({code:"custom",...l,fatal:d})}}):Rn.create()}const Gp={object:be.lazycreate};var G;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(G||(G={}));const Hp=(e,t={message:`Input not instance of ${e.name}`})=>Ql(n=>n instanceof e,t),Jl=at.create,Xl=Lt.create,Wp=os.create,zp=$t.create,ql=sr.create,Zp=sn.create,Kp=rs.create,Vp=ir.create,Yp=or.create,Qp=Rn.create,Jp=Xt.create,Xp=Et.create,qp=ss.create,eh=ct.create,th=be.create,nh=be.strictCreate,rh=ar.create,sh=_s.create,ih=cr.create,oh=_t.create,ah=lr.create,ch=is.create,lh=on.create,dh=wn.create,uh=dr.create,fh=ur.create,ph=Ut.create,hh=fr.create,mh=xn.create,$a=lt.create,gh=ht.create,_h=Ft.create,yh=lt.createWithPreprocess,vh=Ir.create,bh=()=>Jl().optional(),wh=()=>Xl().optional(),Sh=()=>ql().optional(),kh={string:e=>at.create({...e,coerce:!0}),number:e=>Lt.create({...e,coerce:!0}),boolean:e=>sr.create({...e,coerce:!0}),bigint:e=>$t.create({...e,coerce:!0}),date:e=>sn.create({...e,coerce:!0})},Eh=W;var o=Object.freeze({__proto__:null,defaultErrorMap:In,setErrorMap:yp,getErrorMap:es,makeIssue:ts,EMPTY_PATH:vp,addIssueToContext:j,ParseStatus:$e,INVALID:W,DIRTY:_n,OK:Ue,isAborted:Pi,isDirty:Oi,isValid:rn,isAsync:rr,get util(){return re},get objectUtil(){return Ai},ZodParsedType:M,getParsedType:kt,ZodType:X,datetimeRegex:Vl,ZodString:at,ZodNumber:Lt,ZodBigInt:$t,ZodBoolean:sr,ZodDate:sn,ZodSymbol:rs,ZodUndefined:ir,ZodNull:or,ZodAny:Rn,ZodUnknown:Xt,ZodNever:Et,ZodVoid:ss,ZodArray:ct,ZodObject:be,ZodUnion:ar,ZodDiscriminatedUnion:_s,ZodIntersection:cr,ZodTuple:_t,ZodRecord:lr,ZodMap:is,ZodSet:on,ZodFunction:wn,ZodLazy:dr,ZodLiteral:ur,ZodEnum:Ut,ZodNativeEnum:fr,ZodPromise:xn,ZodEffects:lt,ZodTransformer:lt,ZodOptional:ht,ZodNullable:Ft,ZodDefault:pr,ZodCatch:hr,ZodNaN:os,BRAND:Bp,ZodBranded:yo,ZodPipeline:Ir,ZodReadonly:mr,custom:Ql,Schema:X,ZodSchema:X,late:Gp,get ZodFirstPartyTypeKind(){return G},coerce:kh,any:Qp,array:eh,bigint:zp,boolean:ql,date:Zp,discriminatedUnion:sh,effect:$a,enum:ph,function:dh,instanceof:Hp,intersection:ih,lazy:uh,literal:fh,map:ch,nan:Wp,nativeEnum:hh,never:Xp,null:Yp,nullable:_h,number:Xl,object:th,oboolean:Sh,onumber:wh,optional:gh,ostring:bh,pipeline:vh,preprocess:yh,promise:mh,record:ah,set:lh,strictObject:nh,string:Jl,symbol:Kp,transformer:$a,tuple:oh,undefined:Vp,union:rh,unknown:Jp,void:qp,NEVER:Eh,ZodIssueCode:x,quotelessJson:_p,ZodError:Ye});const Ua=o.enum(["app_start","sign_in","window_focus","surface_open"]),ed=o.object({id:o.string().min(1),state:o.enum(["active","paused","disabled"])}).passthrough(),Ih=o.object({tenant_id:o.string().min(1),tenant_name:o.string().optional(),eligible:o.boolean(),endpoint:ed.nullable()}).passthrough(),Rh=o.object({code:o.string(),message:o.string(),details:o.record(o.unknown()).optional(),retry_after_seconds:o.number().optional()}).passthrough(),xh=o.object({code:o.string().min(1),count:o.number().int().nonnegative(),session:o.string().min(1).nullable().optional().catch(null)}).passthrough().nullable().optional().catch(null),Th=o.object({in_force:o.boolean(),notice_pending:o.boolean().catch(!1)}).passthrough().optional().catch(void 0),mE=o.object({capability:o.number(),consent_account_guard:o.boolean().optional(),state:o.enum(["ready","signed_out","unavailable","update_required"]),account_id:o.string().nullable(),tenant_id:o.string().nullable(),surface_state:o.enum(["A","B","C","D","E","F","G"]).nullable(),visibility:o.object({settings:o.boolean(),inbox:o.boolean(),account_door:o.boolean(),onboarding:o.boolean()}),update_required:o.boolean(),local:o.object({enabled:o.boolean(),onboarding:o.string(),session:o.string()}),status:o.object({tenants:o.array(Ih)}).passthrough().nullable(),consent:o.object({version:o.string().min(1).max(128),text:o.string().min(1).refine(e=>new TextEncoder().encode(e).length<=2048,"Consent exceeds the served-text contract"),source:o.enum(["served","cached","embedded"])}).nullable(),error:Rh.nullable(),state_note:o.string().nullable().optional(),read_only:o.boolean().optional(),delivery_hold:xh,default_on:Th}).passthrough(),Ch=o.object({version:o.string().min(1),consented_at:o.string().min(1),consented_via:o.string().min(1),current:o.boolean()}).passthrough(),gE=o.object({endpoint:ed.extend({tenant_id:o.string().min(1),label:o.string().optional(),consent:Ch.nullable().optional(),created_at:o.string().optional(),updated_at:o.string().optional()}).nullable(),settings:o.object({tenant_id:o.string().min(1),eligible:o.boolean(),consent_version:o.string().optional(),consent_required:o.boolean()}).passthrough(),default_on:o.boolean().optional().catch(void 0)}).passthrough(),Ah=o.object({kind:o.enum(["endpoint","account"]).optional(),endpoint_id:o.string().min(1).optional(),account_id:o.string().min(1).optional()}).passthrough().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id").refine(e=>e.kind===void 0||(e.kind==="endpoint"?e.endpoint_id!==void 0:e.account_id!==void 0),"An allowlist target's kind must agree with the id it carries"),Fa=o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:Ah,id:o.string().optional()}).passthrough(),Ba=o.object({mode:o.enum(["class_default","listed_only"]),allow:o.number(),deny:o.number()}).passthrough(),_E=o.object({allowlist:o.object({tenant_id:o.string().min(1),entries:o.array(Fa)}).passthrough(),view:o.object({tenant_id:o.string().nullable(),entries:o.array(Fa),directions:o.object({send:Ba,receive:Ba}),class_default:o.literal("cos_cos"),cues:o.object({allow_entry_switches_direction_to_listed_only:o.boolean(),listed_only_affects:o.string(),removing_allow_does_not_stop_open_thread:o.boolean(),deny_stops_pair_both_directions:o.boolean()}).passthrough()}).passthrough()}).passthrough(),yE=o.object({onboarding:o.literal("seen")}).passthrough();function Ph(e){return e?.default_on?.in_force===!0}function vE(e,t){const n=Oh(e),r=t?.endpoint?.consent?.version;return n&&r&&n.version===r?n.text:null}function bE(e,t){return e?.surface_state==="C"&&t?.default_on===!0&&t.endpoint?.state==="active"&&e.default_on?.notice_pending===!0}function wE(e,t){if(!e||!t||Ph(e)||e.account_id!==t||e.capability<1||e.state!=="ready"||e.update_required||e.surface_state!=="B"||!e.visibility.onboarding||!e.tenant_id)return null;const n=e.status?.tenants.filter(r=>r.tenant_id===e.tenant_id);return n?.length!==1||n[0].eligible!==!0||n[0].endpoint!==null?null:{accountId:t,tenantId:e.tenant_id}}function Oh(e){const t=e?.consent;return t&&(t.source==="served"||t.source==="cached")?t:null}const jh=8,Mi=["aida","library","projects","agents","schedules","browser","team-bridge","agent-hub","mesh","notifications"],Mh=6*1024,Dh=512;function as(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const s=[];for(const i of n){if(s.length===Dh)break;const c=new URLSearchParams({order_ids:i}).toString().length+1;if(r+c>Mh)break;e.append("order_ids",i),s.push(i),r+=c}return s}function Nh(e,t,n){return as(new URLSearchParams(n),t,e)}const b=o.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),Nr=o.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Lr=o.string().min(1).max(32768),Lh=/^[a-f0-9]{12}$/,L=o.string().regex(Lh),Ws=o.string().regex(/^[a-f0-9]{12}$/),zs=o.string().min(1).max(128),$h=o.string().min(1).max(4096),Nn=o.string().min(1).max(128).regex(/^[A-Za-z0-9_.-]+$/),Zs=o.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),$r=o.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),Ga=o.string().regex(/^[a-f0-9]{32}$/),Uh=/^(\/|[A-Za-z]:[\\/])/,Ks=o.string().min(1).max(4096).regex(Uh),Ha=/^[a-f0-9]{32}$/,te=o.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Wa=o.string().min(1).max(512).nullish(),fn=o.string().regex(/^[A-Za-z0-9_-]{1,128}$/),za=o.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),Ln=o.string().regex(/^la_[0-9a-f]{16}$/),$n=o.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/),Za=o.object({data_b64:o.string().min(1).max(1e6),mime_type:o.enum(["image/png","image/jpeg","image/gif","image/webp"]),origin_path:o.string().max(4096).optional()}).strict(),Fh=o.object({digest:o.string().regex(/^[0-9a-f]{32}$/),name:o.string().max(1024).optional(),mime_type:o.string().max(255).optional(),bytes:o.number().int().min(0).optional(),path:o.string().max(4096).optional()}).strict(),Ka=2e5,Va=8,Bh=256,Gh=100,Ya=16,Hh=256,Wh=100,zh=200,Zh=1e6,Kh=o.enum(["auto","none","minimal","low","medium","high","xhigh","max"]),Me=o.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),Ur=o.object({kind:o.enum(["agent","team"]),name:Me}).strict(),td=o.enum(["claude","codex","omp"]),Vh=o.record(o.string(),o.array(o.string().min(1).max(512)).max(5e3)),Qa={sources:o.array(td).max(3).optional(),sessionIds:Vh.optional(),all:o.boolean().optional(),includeSubagents:o.boolean().optional(),includeClearedSegments:o.boolean().optional(),includeMemory:o.boolean().optional(),includeInstructions:o.boolean().optional(),maxSessions:o.number().int().min(1).max(5e3).optional()},Vs=o.object({provider:o.string().min(1).max(128),model_id:o.string().min(1).max(512),reasoning_effort:o.string().min(1).max(64).nullable(),fast_mode:o.boolean().nullable().optional()}).strict(),Ja=o.object({kind:o.enum(["role","specialist"]).optional(),description:o.string().max(8e3).optional(),instructions:o.string().max(8e3).optional(),tools:o.array(o.string().min(1).max(128)).max(256).optional(),effort:o.string().max(64).optional(),delegate:o.boolean().optional(),action_class:o.enum(["reactive","proactive"]).optional()}).strict(),Xa=o.object({name:o.string().min(1).max(64).optional(),description:o.string().max(8e3).optional(),manager:Me.optional(),members:o.array(o.object({role:Me,count:o.number().int().min(1).max(16),kind:o.enum(["agent","team"]),tier:o.enum(["lo","med","hi"]).nullable().optional(),effort:Kh.nullable().optional()}).strict()).max(128).optional(),instructions:o.string().max(8e3).optional(),project:o.string().max(8e3).optional()}).strict(),Yh=o.record(o.array(o.string().max(1024)).max(100)),Ys=o.array(b).max(4).refine(e=>new Set(e).size===e.length,"Duplicate attachment"),qa=o.enum(["minutes","hours","days"]);function Qh(e){return!/^\.+$/.test(e)}const SE=e=>Yr.safeParse(e).success,Yr=o.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(Qh),ec=o.enum(["str","int","float","bool","list","dict"]),tc=o.string().max(16384),Jh=2e3,nc=o.string().min(1).max(Jh),rc=o.string().min(1).max(64),Xh=o.string().min(1).max(64),qh=o.string().min(1).max(64),sc=o.object({is_active:o.boolean().nullish(),one_time:o.boolean().nullish(),start_time_utc:o.string().max(64).nullish(),end_time_utc:o.string().max(64).nullish()}).strict(),em=o.object({conversation_length:o.number().int().optional(),detail_length:o.number().int().optional(),max_learnings_history:o.number().int().optional(),hosting:o.string().max(256).optional(),model_name:o.string().max(1024).optional(),auto_save_conversation:o.boolean().optional()}).strict(),Di=128,ic=2e3,oc=8e3,ac=64,cc=64,ys=e=>[...e].length,Ni=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,tm=e=>e===9||e===10||e===11||e===12||e===13||e===133,nm=e=>e<=31||e>=127&&e<=159,rm=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),sm=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,Fr=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},nd=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&Ni(t[n].codePointAt(0)??0);)n++;for(;r>n&&Ni(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},im=e=>{let t="",n=!1;for(const r of e){if(Ni(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function om(e){const t=nd(e);if(!t)return"must not be empty";if(ys(t)>Di)return`must be at most ${Di} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(Fr(t,sm))return"must not contain Unicode bidirectional override characters";if(Fr(t,tm))return"must not contain whitespace";if(Fr(t,nm))return"must not contain control characters";if(Fr(t,rm))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function kE(e){return im(nd(e).normalize("NFKC").toLowerCase())}function am(e){return e.trim()?ys(e)>ic?`must be at most ${ic} characters`:null:"must not be empty"}function cm(e){return e.trim()?ys(e)>oc?`must be at most ${oc} characters`:null:"must not be empty"}function lm(e){if(e.length>cc)return`must hold at most ${cc} items`;for(const t of e)if(!t.trim()||ys(t)>ac)return`must hold items of 1 to ${ac} characters`;return null}const dm=e=>om(e)===null,um=o.string().refine(dm,{message:"That is not a name the hub can publish."}),fm=o.string().refine(e=>cm(e)===null,{message:"That instruction body cannot be published."}),pm=o.string().refine(e=>am(e)===null,{message:"That description cannot be published."}),hm=o.array(o.string()).refine(e=>lm(e)===null,{message:"That tool list cannot be published."}),Qs={requestId:te.optional(),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()},lc=o.object({name:um,description:pm,instructions:fm,kind:o.enum(["role","specialist"]),when_to_use:o.string(),tools:hm,effort:o.string(),delegate:o.boolean(),version:o.string(),categories:o.array(o.string()),tags:o.array(o.string())}).partial().strict(),mm=o.enum(["team","agent"]),gm=o.string().min(1).max(64),_m=o.string().min(1).max(256),rd=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,Js=o.string().regex(rd,{message:"Letters, digits, dot, underscore and dash; no spaces."}),ym=["planning","active","qa","validation","done","paused","archived"],dc=o.enum(ym),Br=o.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),uc=o.array(o.string().min(1).max(24)).max(8),Ot=o.string().min(1).max(64),vm=1e3,fc=240,pc=80,bm=256,wm=100,Sm=200,km=/^[a-z0-9][a-z0-9_-]{0,23}$/;function EE(e){return e?rd.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function IE(e){return km.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Gr=o.enum(["agent","team","skill"]),Xs=o.string().min(1).max(128).regex(/\S/),hc=o.enum(Mi),Em=o.object({visible:o.array(hc).max(Mi.length),more:o.array(hc).max(Mi.length)}).strict(),Qn=o.string().min(3).max(256).regex(/^(?:n_[a-z2-7]{4,32}|ask:[A-Za-z0-9_-]+:[A-Za-z0-9_-]+)$/),mc=o.union([o.object({items:o.array(o.object({id:Qn,revision:o.number().int().min(1)}).strict()).min(1).max(500)}).strict(),o.object({sessionId:L,throughSeq:o.number().int().min(0),observed:o.array(o.object({id:Qn,revision:o.number().int().min(1)}).strict()).max(500)}).strict(),o.object({all:o.literal(!0),throughSeq:o.number().int().min(0),observed:o.array(o.object({id:Qn,revision:o.number().int().min(1)}).strict()).max(500)}).strict()]),Im={pointer:"pointerdown",key:"keydown",wheel:"wheel"},Rm=o.discriminatedUnion("op",[o.object({op:o.literal("capabilities")}).strict(),o.object({op:o.literal("runtimes.list")}).strict(),o.object({op:o.literal("profiles.list")}).strict(),o.object({op:o.literal("profiles.get"),name:Me}).strict(),o.object({op:o.literal("imports.sources")}).strict(),o.object({op:o.literal("imports.sessions"),source:td,includeSubagents:o.boolean().optional()}).strict(),o.object({op:o.literal("imports.preview"),...Qa}).strict(),o.object({op:o.literal("imports.start"),...Qa}).strict(),o.object({op:o.literal("imports.status"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("imports.cancel"),jobId:o.string().min(1).max(128)}).strict(),o.object({op:o.literal("profiles.update"),name:Me,requestId:te,fields:Ja,expectedDefinitionRevision:Wa.optional()}).strict(),o.object({op:o.literal("profiles.install"),name:Me,requestId:te}).strict(),o.object({op:o.literal("profiles.create"),name:Me,requestId:te,fields:Ja.extend({description:o.string().max(8e3),instructions:o.string().min(1).max(8e3)})}).strict(),o.object({op:o.literal("hub.updates")}).strict(),o.object({op:o.literal("hub.skillPull"),requestId:te,hubId:b,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:b.nullable(),localAlias:Me,subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.skillSubscribe"),requestId:te,hubId:b,hubSource:o.string().min(1).max(2048),visibility:o.enum(["public","org"]),tenantId:b.nullable(),localAlias:Me}).strict(),o.object({op:o.literal("hub.skillUnpull"),requestId:te,linkId:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("hub.skillPublish"),requestId:te,dryRun:o.boolean(),sourceSkill:Me,localAlias:Me,visibility:o.enum(["public","org"]),tenantId:b.nullable(),subscribe:o.boolean(),autoPush:o.boolean(),confirmPublicEgress:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("hub.links"),kind:o.enum(["agent","team","skill"]).optional()}).strict(),o.object({op:o.literal("hub.policy"),requestId:te,linkId:o.string().min(1).max(256),expectedPolicyRevision:o.string().min(1).max(256),subscribe:o.boolean().optional(),autoPush:o.boolean().optional(),confirmPublicEgress:o.boolean().optional()}).strict(),o.object({op:o.literal("hub.check"),requestId:te,kind:Gr.optional(),name:Me.optional(),localId:Xs.optional()}).strict(),o.object({op:o.literal("hub.apply"),requestId:te,kind:Gr.optional(),name:Me.optional(),localId:Xs.optional(),prefer:o.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:o.boolean().optional(),dryRun:o.boolean().optional(),resolveSource:o.literal(!0).optional(),hubSource:o.string().min(1).max(2048).optional(),visibility:o.enum(["public","org"]).optional(),tenantId:o.string().min(1).max(128).nullable().optional()}).strict(),o.object({op:o.literal("hub.applyAll"),requestId:te,kind:Gr.optional()}).strict(),o.object({op:o.literal("hub.retry"),requestId:te,kind:Gr.optional(),name:Me.optional(),localId:Xs.optional()}).strict(),o.object({op:o.literal("hub.push"),requestId:te,linkId:o.string().min(1).max(256),direction:o.literal("push"),dryRun:o.boolean(),previewReceipt:o.string().min(1).max(4096).optional(),confirmPublish:o.literal(!0).optional()}).strict(),o.object({op:o.literal("teams.list")}).strict(),o.object({op:o.literal("teams.get"),name:Me}).strict(),o.object({op:o.literal("teams.effective"),name:Me}).strict(),o.object({op:o.literal("teams.update"),name:Me,requestId:te,fields:Xa,expectedDefinitionRevision:Wa.optional()}).strict(),o.object({op:o.literal("teams.create"),requestId:te,fields:Xa.extend({name:o.string().min(1).max(64)})}).strict(),o.object({op:o.literal("sessions.list"),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional(),include_peers:o.boolean().optional(),scope_kind:mm.optional(),scope_name:gm.optional(),cursor:_m.optional(),with_counts:o.boolean().optional(),sort:o.literal("activity").optional()}).strict(),o.object({op:o.literal("delegated_cleanup_notice.ack")}).strict(),o.object({op:o.literal("sessions.search"),q:o.string().min(1).max(Bh),limit:o.number().int().min(1).max(500).optional(),include_archived:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.archive"),sessionId:L,archived:o.boolean()}).strict(),o.object({op:o.literal("sessions.delete"),sessionId:L,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.create"),requestId:te,cwd:o.string().min(1).max(4096).optional(),target:Ur.optional(),purpose:o.literal("agents-config").optional(),model:Vs.optional(),draftId:L.optional(),peer:fn.optional()}).strict(),o.object({op:o.literal("sessions.preview"),requestId:te,cwd:o.string().min(1).max(4096),target:Ur.optional(),model:Vs.optional()}).strict(),o.object({op:o.literal("sessions.draft"),requestId:te,cwd:o.string().min(1).max(4096),target:Ur.optional(),model:Vs.optional()}).strict(),o.object({op:o.literal("sessions.get"),sessionId:L,journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.files"),sessionId:L,scope:o.enum(["family","self"]).optional(),kind:o.string().max(256).optional(),q:o.string().max(256).optional(),sort:o.enum(["recent","name","kind","modified","created","size"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(8192).optional()}).strict(),o.object({op:o.literal("sessions.files.materialise"),sessionId:L,fileId:o.string().regex(/^[a-f0-9]{16}$/)}).strict(),o.object({op:o.literal("sessions.userAttachments"),sessionId:L}).strict(),o.object({op:o.literal("sessions.userAttachments.materialise"),sessionId:L,digest:o.string().regex(/^[a-f0-9]{32}$/)}).strict(),o.object({op:o.literal("sessions.history"),sessionId:L,beforeId:b.optional(),limit:o.number().int().min(1).max(500).optional(),openFrame:o.boolean().optional(),journalOrder:o.boolean().optional(),orderIds:o.array(o.string().min(1).max(128)).max(512).optional(),peerJournalSource:o.boolean().optional(),sourceRead:o.enum(["metadata","payload"]).optional(),expectedJournalGeneration:o.string().min(1).max(128).optional()}).strict(),o.object({op:o.literal("sessions.checkpoints"),sessionId:L}).strict(),o.object({op:o.literal("sessions.checkpoints.warm"),sessionId:L,ids:o.array(b).max(Ya).optional(),limit:o.number().int().min(1).max(Ya).optional()}).strict(),o.object({op:o.literal("sessions.find"),sessionId:L,q:o.string().min(1).max(Hh),limit:o.number().int().min(1).max(zh).optional()}).strict(),o.object({op:o.literal("subagents.transcript"),sessionId:L,childId:L,beforeId:b.optional(),limit:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("sessions.message"),sessionId:L,requestId:te,text:o.string().max(Ka),images:o.array(Za).max(Va).optional(),files:o.array(Fh).max(jh).optional(),mode:o.enum(["prompt","steer"]).optional(),inputMode:o.enum(["typed","dictated","mixed"]).optional(),inputPath:o.string().max(1024).optional()}).strict(),o.object({op:o.literal("sessions.command"),sessionId:L,requestId:te,command:o.string().regex(/^\/?[A-Za-z]+$/).max(64),args:o.string().max(Ka).optional(),images:o.array(Za).max(Va).optional()}).strict(),o.object({op:o.literal("sessions.move"),sessionId:L,requestId:te,cwd:o.string().min(1).max(4096)}).strict(),o.object({op:o.literal("sessions.answer"),sessionId:L,epoch:b.optional(),requestId:b.optional(),value:o.string().max(32768).optional(),approved:o.boolean().optional(),questionIndex:o.number().int().min(0).optional(),askId:b.optional(),answers:o.record(o.string(),o.array(o.string().max(32768))).optional(),decline:o.boolean().optional(),revise:o.boolean().optional(),dismiss:o.boolean().optional(),reason:o.enum(["answered_in_chat","moot"]).optional()}).strict(),o.object({op:o.literal("sessions.seen"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("attention.seen"),items:o.array(o.object({sessionId:L,completionToken:o.string().uuid()}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("sessions.notified"),sessionId:L,completionToken:o.string().uuid()}).strict(),o.object({op:o.literal("tags.list")}).strict(),o.object({op:o.literal("tags.replace"),tags:o.array(o.object({id:o.string().optional(),name:o.string()}).strict())}).strict(),o.object({op:o.literal("sessions.tags"),expected_revision:o.string().optional(),sessionId:L,tags:o.array(o.string()),primary:o.string().nullable()}).strict(),o.object({op:o.literal("sessions.pin"),sessionId:L,pinned:o.boolean()}).strict(),o.object({op:o.literal("sessions.watch"),sessionId:L,subscriptionId:o.string().regex(Ha),visible:o.boolean(),canNotify:o.boolean()}).strict(),o.object({op:o.literal("sessions.warm"),sessionId:L}).strict(),o.object({op:o.literal("sessions.interrupt"),sessionId:L,requestId:te}).strict(),o.object({op:o.literal("supplements.cancel"),sessionId:L,job:Ws,anchor:zs}).strict(),o.object({op:o.literal("supplements.restart"),sessionId:L,job:Ws,anchor:zs}).strict(),o.object({op:o.literal("supplements.steer"),sessionId:L,job:Ws,anchor:zs,text:o.string().min(1).max(500)}).strict(),o.object({op:o.literal("sessions.variables.list"),sessionId:L}).strict(),o.object({op:o.literal("sessions.variables.create"),sessionId:L,key:Yr,value:tc,type:ec}).strict(),o.object({op:o.literal("sessions.variables.update"),sessionId:L,key:Yr,value:tc,type:ec}).strict(),o.object({op:o.literal("sessions.variables.delete"),sessionId:L,key:Yr}).strict(),o.object({op:o.literal("sessions.presence"),subscriptionId:o.string().regex(/^[a-f0-9]{1,64}$/),canNotify:o.boolean(),canNotifyKinds:o.array(o.enum(["complete","error"])).max(4),sessionId:o.string().regex(/^([a-f0-9]{12})?$/),window:o.object({exists:o.boolean(),focused:o.boolean(),visible:o.boolean(),minimized:o.boolean()}).strict()}).strict(),o.object({op:o.literal("legacy.models"),provider:o.string().max(128).optional(),sort:o.enum(["id","name","provider","recommended"]).optional(),direction:o.enum(["ascending","descending"]).optional()}).strict(),o.object({op:o.literal("legacy.models.providers")}).strict(),o.object({op:o.literal("auth.probe"),provider:b}).strict(),o.object({op:o.literal("legacy.agent.upload"),agentId:b}).strict(),o.object({op:o.literal("agent.publish"),agentId:b,document:lc.optional(),...Qs,visibility:o.literal("org").optional(),tenantId:b.optional()}).strict(),o.object({op:o.literal("agent.republish"),agentId:b,hubAgentId:b,expectedRemoteRevision:o.string().min(1).max(512).optional(),document:lc.optional(),...Qs,visibility:o.literal("org").optional(),tenantId:b.optional()}).strict(),o.object({op:o.literal("team.publish"),teamId:b,...Qs,visibility:o.literal("org").optional(),tenantId:b.optional()}).strict(),o.object({op:o.literal("team.pull"),teamId:b,tenantId:b.optional()}).strict(),o.object({op:o.literal("agent.nameAvailability"),name:o.string().min(1).max(Di)}).strict(),o.object({op:o.literal("legacy.agents.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional(),name:o.string().max(256).optional(),sort:o.string().max(64).optional(),direction:o.enum(["asc","desc"]).optional()}).strict(),o.object({op:o.literal("legacy.agent.get"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.history"),agentId:b,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(500).optional()}).strict(),o.object({op:o.literal("legacy.jobs.list"),agentId:b.optional(),status:o.string().max(64).optional()}).strict(),o.object({op:o.literal("legacy.job.get"),jobId:b}).strict(),o.object({op:o.literal("legacy.schedules.list"),page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedules.list"),agentId:b,page:o.number().int().min(1).optional(),perPage:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("legacy.agent.schedule.create"),agentId:b,schedule:sc.extend({prompt:o.string().max(64e3),interval:o.number().int().min(1),unit:qa})}).strict(),o.object({op:o.literal("legacy.schedule.get"),scheduleId:b}).strict(),o.object({op:o.literal("legacy.schedule.edit"),scheduleId:b,schedule:sc.extend({prompt:o.string().max(64e3).nullish(),interval:o.number().int().min(1).nullish(),unit:qa.nullish()})}).strict(),o.object({op:o.literal("legacy.schedule.remove"),scheduleId:b}).strict(),o.object({op:o.literal("legacy.agent.create"),agent:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.update"),agentId:b,update:o.record(o.unknown())}).strict(),o.object({op:o.literal("legacy.agent.delete"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.conversation.clear"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.get"),agentId:b}).strict(),o.object({op:o.literal("legacy.agent.systemPrompt.update"),agentId:b,systemPrompt:o.string().max(Zh)}).strict(),o.object({op:o.literal("legacy.agent.download"),agentId:b}).strict(),o.object({op:o.literal("legacy.job.cancel"),jobId:b}).strict(),o.object({op:o.literal("commands.list")}).strict(),o.object({op:o.literal("commands.entities"),sessionId:L,command:b,name:o.string().max(128).optional()}).strict(),o.object({op:o.literal("models.catalogue"),live:o.boolean().optional(),scope:o.enum(["usable","all"]).optional()}).strict(),o.object({op:o.literal("usage.get"),provider:b.optional(),live:o.boolean().optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("quota.notice"),provider:b.optional(),model:o.string().min(1).max(200).optional(),refresh:o.boolean().optional()}).strict(),o.object({op:o.literal("analytics.get"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("analytics.models"),sessionId:L.optional(),sinceMs:o.number().int().nonnegative().optional(),untilMs:o.number().int().nonnegative().optional(),days:o.number().int().min(1).max(366).optional()}).strict(),o.object({op:o.literal("info.get")}).strict(),o.object({op:o.literal("sessions.report"),sessionId:L,recentLimit:o.number().int().min(0).max(50).optional()}).strict(),o.object({op:o.literal("skills.list"),sessionId:L.optional(),cwd:$h.optional(),name:Nn.optional()}).strict(),o.object({op:o.literal("skills.create"),requestId:te,name:Nn,copyFrom:Nn}).strict(),o.object({op:o.literal("skills.update"),requestId:te,name:Nn,expectedFingerprint:o.string().regex(/^[a-f0-9]{64}$/),files:o.array(o.object({path:o.string().min(1).max(240),content:o.string().max(1024*1024)}).strict()).min(1).max(64)}).strict(),o.object({op:o.literal("skills.remove"),requestId:te,name:Nn,discardLocalChanges:o.boolean()}).strict(),o.object({op:o.literal("sessions.failovers"),sessionId:L}).strict(),o.object({op:o.literal("sessions.credential"),sessionId:L,action:o.enum(["list","store","forget"]),key:Nr.optional(),value:Lr.optional(),confirmed:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.fork"),sessionId:L,requestId:te,message:o.string().max(2e5).optional(),boundary:o.enum(["next_safe","at_entry"]).optional(),entryId:o.string().max(128).optional(),autoTag:o.boolean().optional()}).strict(),o.object({op:o.literal("sessions.stop"),requestId:te,targets:o.array(L).min(1).max(100),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside"),sessionId:L,requestId:te,text:o.string().min(1).max(32768),asideId:te.optional(),subscriptionId:o.string().regex(Ha).optional()}).strict(),o.object({op:o.literal("sessions.adopt"),sessionId:L,requestId:te,asideId:te,confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("sessions.aside.get"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("sessions.aside.close"),sessionId:L,asideId:te}).strict(),o.object({op:o.literal("wakes.list"),limit:o.number().int().min(1).max(500).optional(),includeDormant:o.boolean().optional()}).strict(),o.object({op:o.literal("wakes.create"),requestId:te,sessionId:L.optional(),cwd:o.string().min(1).max(4096).optional(),target:Ur.optional(),message:nc,in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional(),title:o.string().min(1).max(200).optional()}).strict(),o.object({op:o.literal("wakes.edit"),sessionId:L,wakeId:rc,message:nc.optional(),in:o.string().min(1).max(64).optional(),at:o.string().min(1).max(64).optional(),every:o.string().min(1).max(64).optional(),until:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).optional()}).strict(),o.object({op:o.literal("wakes.remove"),sessionId:L,wakeId:rc}).strict(),o.object({op:o.literal("monitors.cancel"),sessionId:L,monitorId:Xh}).strict(),o.object({op:o.literal("jobs.cancel"),sessionId:L,jobId:qh}).strict(),o.object({op:o.literal("mcp.list"),sessionId:L}).strict(),o.object({op:o.literal("mcp.credentials.store"),sessionId:L,name:o.string().min(1).max(256),values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("mcp.control"),sessionId:L,control:o.object({action:o.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:Zs.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record($r).optional(),url:o.string().max(4096).optional(),headers:o.record($r).optional(),oauth:o.boolean().optional(),confirmed:o.boolean().optional(),operation_id:Ga.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog"),cwd:Ks.optional(),sessionId:L.optional()}).strict(),o.object({op:o.literal("mcp.catalog.control"),cwd:Ks.optional(),control:o.object({action:o.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:Zs.optional(),scope:o.enum(["global","project"]).optional(),command:o.string().min(1).max(4096).optional(),args:o.array(o.string().max(8192)).max(128).optional(),env:o.record($r).optional(),url:o.string().max(4096).optional(),headers:o.record($r).optional(),confirmed:o.boolean().optional(),operation_id:Ga.optional()}).strict()}).strict(),o.object({op:o.literal("mcp.catalog.credentials"),header:o.string().min(1).max(128).optional(),cwd:Ks.optional(),name:Zs,values:o.record(o.string().min(1).max(128),o.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:o.array(o.string().min(1).max(128)).max(32)}).strict(),o.object({op:o.literal("radient.request"),control:o.object({operation:o.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list","org_skills.list","org_skill.get","signup.resend"]),request_id:te.optional(),tenant_id:b.optional(),account_id:b.optional(),agent_id:b.optional(),comment_id:b.optional(),team_id:b.optional(),skill_id:b.optional(),query:o.record(o.union([o.string().max(1024),o.number().int()])).optional(),payload:o.record(o.unknown()).optional(),confirmed:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("providers.list")}).strict(),o.object({op:o.literal("accounts.list")}).strict(),o.object({op:o.literal("accounts.remove"),accountId:o.number().int().positive(),confirmed:o.literal(!0)}).strict(),o.object({op:o.literal("tunnel.setup.read"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.plan"),credentialId:o.number().int().positive().optional()}).strict(),o.object({op:o.literal("tunnel.setup.run"),credentialId:o.number().int().positive(),acceptMonthlyPrice:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("auth.start"),provider:b}).strict(),o.object({op:o.literal("auth.status"),id:b}).strict(),o.object({op:o.literal("auth.input"),id:b,promptId:b,value:Lr}).strict(),o.object({op:o.literal("auth.cancel"),id:b}).strict(),o.object({op:o.literal("auth.key"),provider:b,value:Lr}).strict(),o.object({op:o.literal("auth.logout"),provider:b}).strict(),o.object({op:o.literal("agent_messages.status"),boundary:Ua}).strict(),o.object({op:o.literal("agent_messages.enable"),expected_account_id:b,tenant_id:b,state:o.literal("active"),consent_version:o.string().min(1).max(128),consented_via:o.literal("dialog")}).strict(),o.object({op:o.literal("agent_messages.settings"),tenant_id:b.optional()}).strict(),o.object({op:o.literal("agent_messages.settings.put"),expected_account_id:b,tenant_id:b.optional(),consent_version:o.string().min(1).max(128).optional(),consented_via:o.enum(["dialog","settings"]).optional(),label:o.string().min(1).max(128).optional(),state:o.enum(["active","paused","disabled"])}).strict(),o.object({op:o.literal("agent_messages.onboarding.dismiss")}).strict(),o.object({op:o.literal("agent_messages.allowlist.get"),tenant_id:b.optional()}).strict(),o.object({op:o.literal("agent_messages.allowlist.put"),expected_account_id:b,tenant_id:b.optional(),entries:o.array(o.object({direction:o.enum(["send","receive"]),effect:o.enum(["allow","deny"]),target:o.object({endpoint_id:b.optional(),account_id:b.optional()}).strict().refine(e=>!!e.endpoint_id!=!!e.account_id,"An allowlist target names exactly one of endpoint_id or account_id")}).strict()).max(200)}).strict(),o.object({op:o.literal("team_bridge.conversations.list"),scope:o.literal("account").optional(),tenant_id:b.optional(),limit:o.number().int().min(1).max(100).optional(),cursor:o.string().min(1).max(512).optional(),before:o.string().min(1).max(64).optional(),status:o.enum(["open","archived"]).optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.get"),conversation_id:b,tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.create"),expected_account_id:b.optional(),tenant_id:b.optional(),kind:o.enum(["dm","group","channel"]),name:o.string().min(1).max(128).optional(),topic:o.string().min(1).max(512).optional(),visibility:o.enum(["private","tenant"]).optional(),agent_capable:o.boolean().optional(),members:o.array(o.object({account_id:b,kind:o.enum(["human","agent"]),endpoint_id:b.optional(),display_label:o.string().min(1).max(64)}).strict()).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.lifecycle"),expected_account_id:b.optional(),tenant_id:b.optional(),conversation_id:b,action:o.enum(["archive","unarchive","join","leave"])}).strict(),o.object({op:o.literal("team_bridge.conversations.join"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.conversations.notify"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),notify:o.enum(["all","mention","mute"])}).strict(),o.object({op:o.literal("team_bridge.conversations.members.add"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),members:o.array(o.object({account_id:b,kind:o.enum(["human","agent"]),endpoint_id:b.optional(),display_label:o.string().min(1).max(64)}).strict()).min(1).max(500)}).strict(),o.object({op:o.literal("team_bridge.conversations.members.remove"),expected_account_id:b.optional(),tenant_id:b.optional(),conversation_id:b,account_id:b}).strict(),o.object({op:o.literal("team_bridge.conversations.delete"),expected_account_id:b.optional(),tenant_id:b.optional(),conversation_id:b}).strict(),o.object({op:o.literal("team_bridge.conversations.consent"),expected_account_id:b.optional(),conversation_id:b,account_id:b,decision:o.enum(["accept","decline"]),consent_version:o.string().min(1).max(128),tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.owner_audit.conversations"),expected_account_id:b,tenant_id:b,limit:o.number().int().min(1).max(100).optional(),cursor:o.string().min(1).optional()}).strict(),o.object({op:o.literal("team_bridge.owner_audit.messages"),expected_account_id:b,tenant_id:b,conversation_id:b,limit:o.number().int().min(1).max(100).optional(),before_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.owner_audit.replies"),expected_account_id:b,tenant_id:b,conversation_id:b,message_id:b,limit:o.number().int().min(1).max(100).optional(),after_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.messages.list"),conversation_id:b,tenant_id:b.optional(),limit:o.number().int().min(1).max(100).optional(),before_seq:o.number().int().nonnegative().optional(),endpoint_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.reactions.toggle"),conversation_id:b,message_id:b,expected_account_id:b,tenant_id:b,emoji:o.string().min(1),active:o.boolean()}).strict(),o.object({op:o.literal("team_bridge.messages.send"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),client_ref:b,body:o.string(),agent_label:o.string().min(1).max(64).optional(),thread_root_id:b.optional(),attachment_ids:Ys.optional()}).strict(),o.object({op:o.literal("team_bridge.messages.replies"),conversation_id:b,message_id:b,expected_account_id:b,tenant_id:b,limit:o.number().int().min(1).max(100).optional(),after_seq:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.scheduled.list"),tenant_id:b}).strict(),o.object({op:o.literal("team_bridge.scheduled.create"),tenant_id:b,conversation_id:b,client_ref:b,body:o.string(),send_at:o.string().datetime({offset:!0}),attachment_ids:Ys.optional(),thread_root_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.scheduled.update"),tenant_id:b,scheduled_id:b,body:o.string().optional(),send_at:o.string().datetime({offset:!0}).optional(),attachment_ids:Ys.optional(),expected_version:o.number().int().nonnegative().optional()}).strict(),o.object({op:o.literal("team_bridge.attachments.delete"),tenant_id:b,conversation_id:b,attachment_id:b,expected_account_id:b}).strict(),o.object({op:o.literal("team_bridge.scheduled.cancel"),tenant_id:b,scheduled_id:b}).strict(),o.object({op:o.literal("team_bridge.read"),expected_account_id:b.optional(),conversation_id:b,tenant_id:b.optional(),seq:o.number().int().nonnegative().optional(),muted:o.boolean().optional()}).strict(),o.object({op:o.literal("team_bridge.unread"),scope:o.literal("account").optional(),tenant_id:b.optional()}).strict(),o.object({op:o.literal("team_bridge.directory"),tenant_id:b}).strict(),o.object({op:o.literal("team_bridge.status"),boundary:Ua.optional()}).strict(),o.object({op:o.literal("settings.list")}).strict(),o.object({op:o.literal("settings.edit"),key:Nr,value:o.unknown().refine(e=>e!==void 0,"A setting value is required."),base:Yh.optional()}).strict(),o.object({op:o.literal("settings.reset"),key:Nr}).strict(),o.object({op:o.literal("tts.paths")}).strict(),o.object({op:o.literal("config.get")}).strict(),o.object({op:o.literal("config.update"),value:em}).strict(),o.object({op:o.literal("instructions.get")}).strict(),o.object({op:o.literal("instructions.update"),content:o.string().max(64e3)}).strict(),o.object({op:o.literal("credentials.list")}).strict(),o.object({op:o.literal("credentials.update"),key:Nr,value:Lr}).strict(),o.object({op:o.literal("peers.list")}).strict(),o.object({op:o.literal("networks.list")}).strict(),o.object({op:o.literal("networks.invite"),networkId:fn,role:o.enum(["read","drive","admin"]),deviceId:fn.optional()}).strict(),o.object({op:o.literal("networks.member.remove"),networkId:fn,deviceId:fn,confirm:o.string().min(1).max(256)}).strict(),o.object({op:o.literal("sessions.transfer"),sessionId:L,to:o.union([o.literal("local"),fn]),keep:o.boolean().optional(),waitS:o.number().min(0).max(300).optional(),requestId:te.optional()}).strict(),o.object({op:o.literal("approvals.list")}).strict(),o.object({op:o.literal("approvals.approve"),approvalId:za}).strict(),o.object({op:o.literal("approvals.deny"),approvalId:za}).strict(),o.object({op:o.literal("asks.list")}).strict(),o.object({op:o.literal("projects.list")}).strict(),o.object({op:o.literal("projects.get"),key:Ot}).strict(),o.object({op:o.literal("projects.create"),name:Js,description:o.string().max(fc).optional(),status:dc.optional(),tags:uc.optional()}).strict(),o.object({op:o.literal("projects.update"),key:Ot,fields:o.object({name:Js.optional(),title:o.string().max(80).optional(),owner:o.string().max(80).optional(),team:o.string().max(80).optional(),description:o.string().max(fc).optional(),status:dc.optional(),progress:o.string().max(vm).optional(),tags:uc.optional(),start_date:Br.optional(),target_date:Br.optional(),completed_at:Br.optional(),estimate:o.number().positive().max(1e3).optional(),estimate_unit:o.enum(["points","days"]).optional()}).strict(),force_done:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.delete"),key:Ot,confirmed_name:Js}).strict(),o.object({op:o.literal("projects.link"),key:Ot,sessionId:L}).strict(),o.object({op:o.literal("projects.unlink"),key:Ot,sessionId:L}).strict(),o.object({op:o.literal("projects.milestone"),key:Ot,name:o.string().min(1).max(pc),targetDate:Br.optional(),completed:o.boolean().optional()}).strict(),o.object({op:o.literal("projects.milestone.remove"),key:Ot,name:o.string().min(1).max(pc)}).strict(),o.object({op:o.literal("projects.request_update"),key:Ot}).strict(),o.object({op:o.literal("projects.search"),q:o.string().min(1).max(bm),limit:o.number().int().min(1).max(Sm).optional()}).strict(),o.object({op:o.literal("aida.status")}).strict(),o.object({op:o.literal("aida.control"),action:o.enum(["open","pause","resume","greet","status"])}).strict(),o.object({op:o.literal("code_requests.list"),sessionId:L}).strict(),o.object({op:o.literal("code_requests.refresh"),sessionId:L,keys:o.array(o.string().min(1).max(512)).max(256).optional(),force:o.boolean().optional()}).strict(),o.object({op:o.literal("static.sign"),route:o.enum(["images","videos","audio","html"]),path:o.string().min(1),ttlS:o.number().int().min(1).max(3600).optional()}).strict(),o.object({op:o.literal("library.list"),scope:o.enum(["final","all"]).optional(),q:o.string().max(512).optional(),category:o.string().min(1).max(64).optional(),kind:o.string().min(1).max(64).optional(),origin_group:o.enum(["generated","created","mentioned"]).optional(),origin:o.string().min(1).max(64).optional(),tag:o.string().min(1).max(128).optional(),tag_mode:o.enum(["all","any"]).optional(),highlighted:o.boolean().optional(),organized:o.boolean().optional(),favorite:o.boolean().optional(),session:o.string().min(1).max(12).optional(),session_id:o.string().min(1).max(512).optional(),sort:o.enum(["recent","name","kind","size","created","modified","organized"]).optional(),order:o.enum(["asc","desc"]).optional(),limit:o.number().int().min(1).max(200).optional(),cursor:o.string().max(512).optional()}).strict(),o.object({op:o.literal("library.get"),id:Ln}).strict(),o.object({op:o.literal("library.update"),id:Ln,fields:o.object({name:o.string().max(200).optional(),description:o.string().max(2e3).optional(),favorite:o.boolean().optional(),locked:o.boolean().optional(),archived:o.boolean().optional()}).strict()}).strict(),o.object({op:o.literal("library.tags")}).strict(),o.object({op:o.literal("library.tags.create"),name:o.string().trim().min(1).max(24),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.update"),id:$n,name:o.string().trim().min(1).max(24).optional(),category:o.string().min(1).max(64).optional()}).strict(),o.object({op:o.literal("library.tags.delete"),id:$n}).strict(),o.object({op:o.literal("library.tags.merge"),id:$n,into:$n}).strict(),o.object({op:o.literal("library.tags.assign"),id:Ln,tags:o.array($n).max(64),primary:o.string().max(128).optional()}).strict(),o.object({op:o.literal("library.chat.link"),id:Ln,sessionId:L}).strict(),o.object({op:o.literal("library.chat.clear"),id:Ln}).strict(),o.object({op:o.literal("library.librarian"),action:o.enum(["status","open","pause","resume","run"]).optional()}).strict(),o.object({op:o.literal("sidebar_layout.get")}).strict(),o.object({op:o.literal("sidebar_layout.set"),layout:Em}).strict(),o.object({op:o.literal("notifications.list"),state:o.enum(["unread","all","dismissed"]).optional(),source:o.enum(["notify","ask"]).optional(),priority:o.enum(["high","normal","low"]).optional(),sessionId:L.optional(),throughSeq:o.number().int().min(0).optional(),cursor:o.string().min(1).max(64).optional(),limit:o.number().int().min(1).max(100).optional()}).strict(),o.object({op:o.literal("notifications.get"),id:Qn}).strict(),o.object({op:o.literal("notifications.count")}).strict(),o.object({op:o.literal("notifications.read"),verb:o.enum(["read","unread"]),target:mc}).strict(),o.object({op:o.literal("notifications.dismiss"),verb:o.enum(["dismiss","undismiss"]),target:mc}).strict(),o.object({op:o.literal("notifications.seen"),items:o.array(o.object({id:Qn,revision:o.number().int().min(1),anchorId:o.string().min(1).max(256),visibleSinceMs:o.number().int().min(0)}).strict()).min(1).max(50),evidence:o.object({sessionId:L,inputKind:o.enum(["pointer","key","wheel"]),inputAtMs:o.number().int().min(0),visibleSinceMs:o.number().int().min(0)}).strict()}).strict()]);Rm.superRefine((e,t)=>{if((e.op==="team_bridge.messages.send"||e.op==="team_bridge.scheduled.create"||e.op==="team_bridge.scheduled.update"&&e.body!==void 0)&&e.body?.trim()===""&&(e.attachment_ids?.length??0)===0){t.addIssue({code:o.ZodIssueCode.custom,message:"A message needs text or an image",path:["body"]});return}if(e.op.startsWith("team_bridge.")&&"expected_account_id"in e&&e.expected_account_id&&(!("tenant_id"in e)||!e.tenant_id)){t.addIssue({code:o.ZodIssueCode.custom,path:["tenant_id"],message:"Guarded conversation writes require an explicit tenant"});return}if(e.op==="team_bridge.messages.send"&&e.thread_root_id!==void 0&&!e.expected_account_id){t.addIssue({code:o.ZodIssueCode.custom,path:["expected_account_id"],message:"Thread replies require the captured account"});return}if(e.op==="hub.skillPull"||e.op==="hub.skillSubscribe"||e.op==="hub.skillPublish"){if(e.visibility==="public"&&e.tenantId!==null||e.visibility==="org"&&!e.tenantId){t.addIssue({code:o.ZodIssueCode.custom,message:"A skill destination requires explicit paired scope",path:["tenantId"]});return}if(e.op==="hub.skillPublish"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"An initial skill publication requires its reviewed draft receipt",path:["previewReceipt"]});return}}if(e.op==="hub.check"||e.op==="hub.apply"||e.op==="hub.retry"){const n=e.name!==void 0,r=e.localId!==void 0,s=e.op!=="hub.check";if(n&&r||s&&!n&&!r||r&&e.kind===void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub action addresses one item by name or local id, never both",path:["localId"]});return}}if(e.op==="hub.apply"&&e.resolveSource===!0){const n=e.visibility==="public"&&e.tenantId===null||e.visibility==="org"&&typeof e.tenantId=="string"&&e.tenantId.length>0;if(!e.hubSource||!n||e.acknowledgeUnknownBaseline!==!0||e.localId!==void 0||e.prefer!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"Confirming a source requires its exact stated destination and the unknown-baseline acknowledgement, addressed by name, with no preference",path:["hubSource"]});return}}if(e.op==="hub.push"&&(e.dryRun?e.previewReceipt!==void 0||e.confirmPublish!==void 0:!e.previewReceipt||e.confirmPublish!==!0)){t.addIssue({code:o.ZodIssueCode.custom,message:"A confirmed publication requires its reviewed preview receipt",path:["previewReceipt"]});return}if(e.op==="hub.policy"&&e.subscribe===void 0&&e.autoPush===void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"A hub policy change must name subscribe or autoPush",path:["subscribe"]});return}if((e.op==="team_bridge.conversations.list"||e.op==="team_bridge.unread")&&e.scope==="account"&&e.tenant_id!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped read cannot name a tenant",path:["scope"]});return}if(e.op==="team_bridge.conversations.list"&&e.scope==="account"&&e.before!==void 0){t.addIssue({code:o.ZodIssueCode.custom,message:"An account-scoped page uses cursor, not before",path:["before"]});return}if(e.op==="sessions.answer"){if(e.askId!==void 0){if(e.askId||t.addIssue({code:o.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.dismiss===!0){(e.answers!==void 0||e.decline===!0||e.revise===!0)&&t.addIssue({code:o.ZodIssueCode.custom,message:"A dismissal carries no answers, decline or revise",path:["dismiss"]});return}e.reason!==void 0?t.addIssue({code:o.ZodIssueCode.custom,message:"A reason applies to a dismissal",path:["reason"]}):e.decline!==!0&&!e.answers?t.addIssue({code:o.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:o.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:o.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:o.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:o.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:o.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]}),e.dismiss===!0&&t.addIssue({code:o.ZodIssueCode.custom,message:"dismiss applies to a queued ask",path:["dismiss"]}),e.reason!==void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:"reason applies to a queued ask",path:["reason"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:o.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}if(!(e.op!=="agent.publish"&&e.op!=="agent.republish"&&e.op!=="team.publish")){if((e.subscribe!==void 0||e.autoPush!==void 0||e.confirmPublicEgress!==void 0)&&!e.requestId){t.addIssue({code:o.ZodIssueCode.custom,message:"Initial link policy needs a durable publication request ID",path:["requestId"]});return}e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:o.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})}});const qe={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},xm={runtimeUnreachable:"runtime_unreachable"},vs="runtime_busy",sd="runtime_retiring";o.object({data:o.object({aside_id:o.string().optional(),status:o.union([o.enum(["adopted","queued"]),o.string()]).optional()}).passthrough()}).passthrough();const id=o.object({name:o.string(),description:o.string().nullish(),source:o.string().nullish(),link_id:o.string().nullish(),editable:o.boolean().nullish(),installed:o.boolean().nullish(),fingerprint:o.string().nullish(),form:o.string().nullish()}).passthrough(),Tm=o.object({path:o.string(),size:o.number().nullish(),preview:o.string().nullish(),preview_truncated:o.boolean().nullish()}).passthrough(),Cm=id.extend({body:o.string().nullish(),body_in_detail:o.boolean().nullish(),body_length:o.number().nullish(),body_bytes:o.number().nullish(),body_truncated:o.boolean().nullish(),files:o.array(Tm).nullish(),files_total:o.number().nullish(),files_truncated:o.boolean().nullish(),publish_budget:o.object({limit:o.number(),total:o.number()}).passthrough().nullish()}).passthrough(),RE=o.object({skills:o.array(id),scope:o.string().nullish(),detail:o.string().nullish(),skill_detail:Cm.nullish(),warning_count:o.number().nullish(),version:o.string().nullish()}).passthrough(),xE="aside_adopt_refused",Am=["session_closed","open_tool_batch","turn_running"];function TE(e){if(typeof e!="object"||e===null)return;const t=e.reason;return Am.find(n=>n===t)}const Pm={[qe.noCredential]:"ui.common.errors.desktop_refusal.no_credential",[qe.refused]:"ui.common.errors.desktop_refusal.refused",[qe.planeClosed]:"ui.common.errors.desktop_refusal.plane_closed",[qe.transportFailed]:"ui.common.errors.desktop_refusal.transport_failed"},Li={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function bs(e){return e!==void 0&&Object.values(qe).includes(e)}function Om(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return qe.refused;if(t===503)return qe.planeClosed}}const CE=o.object({step:o.string(),blocked_on:o.string(),configured:o.boolean(),ready:o.boolean(),verified:o.boolean(),url:o.string().nullable(),credential_id:o.number().int().positive().nullable(),identity_label:o.string().nullable(),credential_choices:o.array(o.object({id:o.number().int().positive(),identity_label:o.string().nullable().optional()}).passthrough()).default([]),quote:o.object({monthly_price_usd:o.string().nullable(),positive_balance:o.boolean(),eligible:o.boolean(),account_valid:o.boolean()}).passthrough().nullable(),receipts:o.array(o.object({step:o.string(),ok:o.boolean(),text:o.string()})).default([]),remedy:o.object({kind:o.string(),text:o.string(),command:o.string().nullable().optional(),url:o.string().nullable().optional()}).nullable(),source:o.string(),in_progress:o.boolean().default(!1),progress:o.array(o.string()).default([]),active_credential_id:o.number().int().positive().nullable().default(null),billing_outcome:o.string().optional(),reservation_outcome:o.string().optional(),failure_stage:o.string().optional()}).passthrough(),AE=new Set(["setup_in_progress","setup_deadline","setup_unavailable","setup_intent_corrupt"]),jm=88e4,Mm=11e5,Dm=2e4,Nm=9e4,Lm=new Set(["analytics.get","analytics.models","sessions.report"]),$m=new Set(["usage.get"]),Um=new Set(["networks.list","peers.list"]),Fm=new Set([...Lm,...$m,...Um]),Bm=90,Gm=30,Hm=300,Wm=10,od=15,zm=1e4;function Zm(e){const n=e.to==="local"||e.keep?Hm:Gm,r=Math.max(0,e.waitS??0);return(Bm+n+Wm+od)*1e3+r*1e3}const Km=18e4,Vm=Km+15e3,Ym=120,Qm=135e3,Jm=93e4,ad=(Ym+30+od)*1e3,Xm=6e4,qm=5*ad,eg=new Set(["hub.apply","hub.retry","hub.push","hub.skillPublish","hub.skillPull","hub.skillSubscribe","hub.skillUnpull","hub.check","hub.applyAll"]);function tg(e){switch(e){case"hub.apply":case"hub.retry":case"hub.push":case"hub.skillPublish":case"hub.skillPull":case"hub.skillSubscribe":case"hub.skillUnpull":return ad;case"hub.check":return Xm;case"hub.applyAll":return qm;default:return null}}function ng(e){if(typeof e!="string"&&e.op==="sessions.transfer")return Zm(e)+zm;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return Vm;if(t==="tunnel.setup.run")return Jm;if(t==="tunnel.setup.plan")return Qm;const n=tg(t);return n!==null?n:Fm.has(t)?Nm:Dm}const rg=5e3;function cd(e){return ng(e)+rg}const vo="deadline_exceeded",ld="foreground_required",dd="View these completions in the foreground before marking them read.",sg=new Set(["capabilities","agent_messages.status","agent_messages.settings","agent_messages.allowlist.get","team_bridge.conversations.list","team_bridge.conversations.get","team_bridge.messages.list","team_bridge.messages.replies","team_bridge.owner_audit.conversations","team_bridge.owner_audit.messages","team_bridge.owner_audit.replies","team_bridge.unread","team_bridge.directory","team_bridge.status","accounts.list","analytics.get","analytics.models","approvals.list","commands.entities","commands.list","config.get","credentials.list","hub.updates","hub.links","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","quota.notice","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.files","sessions.userAttachments","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","teams.effective","teams.get","teams.list","tunnel.setup.plan","tunnel.setup.read","usage.get"]),ig=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function og(e,t){const n=Math.round(t/1e3),r=vo;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:eg.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:sg.has(e)?{code:r,message:ig.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const PE=jm,OE=Mm;o.object({state:o.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:o.string(),kind:o.enum(["balance","subscription","radient","none"]),model_free:o.boolean(),title:o.string(),body:o.string(),actions:o.array(o.object({id:o.enum(["open_url","resend_verification","refresh"]),label:o.string(),url:o.string().nullable().optional()})),resets_at_ms:o.number().int().nullable().optional(),checked_at_ms:o.number().int(),age_ms:o.number().int().nullable().optional(),source:o.enum(["cached","live"])});function ag(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function gc(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function qs(e){return{...e.requestId?{request_id:e.requestId}:{},...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}}function ei(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function _c(e){return{sources:e.sources??null,session_ids:e.sessionIds??{},all:e.all??!1,include_subagents:e.includeSubagents??!1,include_cleared_segments:e.includeClearedSegments??!1,include_memory:e.includeMemory??!0,include_instructions:e.includeInstructions??!0,...e.maxSessions===void 0?{}:{max_sessions:e.maxSessions}}}function Hr(e){const t=new URLSearchParams;return e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id),t.size?`?${t.toString()}`:""}function ti(e){return e===void 0?"":`?tenant_id=${encodeURIComponent(e)}`}function cg(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"imports.sources":return{path:"/v1/desktop/imports/sources",method:"GET"};case"imports.sessions":{const t=new URLSearchParams({source:e.source});return e.includeSubagents&&t.set("include_subagents","true"),{path:`/v1/desktop/imports/sessions?${t.toString()}`,method:"GET"}}case"imports.preview":return{path:"/v1/desktop/imports/preview",method:"POST",body:_c(e)};case"imports.start":return{path:"/v1/desktop/imports/jobs",method:"POST",body:_c(e)};case"imports.status":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"GET"};case"imports.cancel":return{path:`/v1/desktop/imports/jobs/${encodeURIComponent(e.jobId)}`,method:"DELETE"};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.skillPull":return{path:"/v1/desktop/hub/skills/pull",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.skillSubscribe":return{path:"/v1/desktop/hub/skills/subscribe",method:"POST",body:{request_id:e.requestId,hub_id:e.hubId,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId,local_alias:e.localAlias}};case"hub.skillUnpull":return{path:"/v1/desktop/hub/skills/unpull",method:"POST",body:{request_id:e.requestId,link_id:e.linkId}};case"hub.skillPublish":return{path:"/v1/desktop/hub/skills/publish",method:"POST",body:{request_id:e.requestId,dry_run:e.dryRun,source_skill:e.sourceSkill,local_alias:e.localAlias,visibility:e.visibility,tenant_id:e.tenantId,subscribe:e.subscribe,auto_push:e.autoPush,confirm_public_egress:e.confirmPublicEgress,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"hub.links":return{path:`/v1/desktop/hub/links${e.kind?`?kind=${e.kind}`:""}`,method:"GET"};case"hub.policy":return{path:`/v1/desktop/hub/links/${encodeURIComponent(e.linkId)}`,method:"PATCH",body:{request_id:e.requestId,expected_policy_revision:e.expectedPolicyRevision,...e.subscribe!==void 0?{subscribe:e.subscribe}:{},...e.autoPush!==void 0?{auto_push:e.autoPush}:{},...e.confirmPublicEgress!==void 0?{confirm_public_egress:e.confirmPublicEgress}:{}}};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{},...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{},...e.resolveSource===!0?{resolve_source:!0,hub_source:e.hubSource,visibility:e.visibility,tenant_id:e.tenantId??null}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{},...e.localId?{local_id:e.localId}:{}}};case"hub.push":return{path:"/v1/desktop/hub/updates/push",method:"POST",body:{request_id:e.requestId,link_id:e.linkId,direction:e.direction,dry_run:e.dryRun,...e.previewReceipt?{preview_receipt:e.previewReceipt}:{},...e.confirmPublish?{confirm_publish:!0}:{}}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.effective":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}/effective`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields,...e.expectedDefinitionRevision!==void 0&&e.expectedDefinitionRevision!==null?{expected_definition_revision:e.expectedDefinitionRevision}:{}}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),e.sort&&t.set("sort",e.sort),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??Gh)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),as(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.files":{const t=new URLSearchParams({limit:String(e.limit??200)});for(const n of["scope","kind","q","sort","order","cursor"]){const r=e[n];r!==void 0&&t.set(n,r)}return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files?${t}`,method:"GET"}}case"sessions.files.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/files/${encodeURIComponent(e.fileId)}/materialise`,method:"POST"};case"sessions.userAttachments":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments`,method:"GET"};case"sessions.userAttachments.materialise":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/user-attachments/${encodeURIComponent(e.digest)}/materialise`,method:"POST"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1")),e.journalOrder&&(t.set("journal_order","1"),e.peerJournalSource&&t.set("peer_journal_source","1"),e.sourceRead==="metadata"?t.set("source_read","metadata"):e.sourceRead==="payload"&&e.expectedJournalGeneration&&t.set("source_read","payload"),e.expectedJournalGeneration&&t.set("expected_journal_generation",e.expectedJournalGeneration),as(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??Wh)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],...e.files?.length?{files:e.files}:{},mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{},...e.dismiss===!0?{dismiss:!0,...e.reason!==void 0?{reason:e.reason}:{}}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"tags.list":return{path:"/v1/desktop/tags",method:"GET"};case"tags.replace":return{path:"/v1/desktop/tags",method:"PUT",body:{tags:e.tags}};case"sessions.tags":return{path:`/v1/desktop/sessions/${e.sessionId}/tags`,method:"PUT",body:{tags:e.tags,primary:e.primary,...e.expected_revision===void 0?{}:{expected_revision:e.expected_revision}}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{ei(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{},...qs(e)}}}case"agent.republish":{ei(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{},...qs(e),...e.expectedRemoteRevision?{expected_remote_revision:e.expectedRemoteRevision}:{}}}}case"team.publish":{ei(e);const t=new URLSearchParams;return e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId)),{path:`/v1/teams/${e.teamId}/publish${t.size?`?${t}`:""}`,method:"POST",body:qs(e)}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...ag(e),message:e.message,...gc(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...gc(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,method:"GET"}}case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"skills.create":return{path:"/v1/desktop/skills",method:"POST",body:{request_id:e.requestId,name:e.name,copy_from:e.copyFrom}};case"skills.update":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"PUT",body:{request_id:e.requestId,expected_fingerprint:e.expectedFingerprint,files:e.files}};case"skills.remove":return{path:`/v1/desktop/skills/${encodeURIComponent(e.name)}`,method:"DELETE",body:{request_id:e.requestId,discard_local_changes:e.discardLocalChanges}};case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId,auto_tag:e.autoTag}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"tunnel.setup.read":return{path:e.credentialId===void 0?"/v1/desktop/tunnel/setup":`/v1/desktop/tunnel/setup?credential_id=${e.credentialId}`,method:"GET"};case"tunnel.setup.plan":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"plan",...e.credentialId!==void 0?{credential_id:e.credentialId}:{}}};case"tunnel.setup.run":return{path:"/v1/desktop/tunnel/setup",method:"POST",body:{action:"run",credential_id:e.credentialId,...e.acceptMonthlyPrice!==void 0?{accept_monthly_price:e.acceptMonthlyPrice}:{}}};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"agent_messages.status":return{path:`/v1/desktop/team-bridge/status?boundary=${e.boundary}`,method:"GET"};case"agent_messages.enable":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id,state:e.state,consent_version:e.consent_version,consented_via:e.consented_via}};case"agent_messages.settings":return{path:`/v1/desktop/team-bridge/settings${ti(e.tenant_id)}`,method:"GET"};case"agent_messages.settings.put":return{path:"/v1/desktop/team-bridge/settings",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},...e.consent_version===void 0?{}:{consent_version:e.consent_version},...e.consented_via===void 0?{}:{consented_via:e.consented_via},...e.label===void 0?{}:{label:e.label},state:e.state}};case"agent_messages.onboarding.dismiss":return{path:"/v1/desktop/team-bridge/onboarding/dismiss",method:"POST"};case"agent_messages.allowlist.get":return{path:`/v1/desktop/team-bridge/allowlist${ti(e.tenant_id)}`,method:"GET"};case"agent_messages.allowlist.put":return{path:"/v1/desktop/team-bridge/allowlist",method:"PUT",body:{expected_account_id:e.expected_account_id,...e.tenant_id===void 0?{}:{tenant_id:e.tenant_id},entries:e.entries}};case"team_bridge.conversations.list":{const t=new URLSearchParams;return e.scope==="account"&&t.set("scope","account"),e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor),e.before&&t.set("before",e.before),e.status&&t.set("status",e.status),{path:`/v1/desktop/team-bridge/conversations${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.conversations.get":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${ti(e.tenant_id)}`,method:"GET"};case"team_bridge.conversations.create":return{path:"/v1/desktop/team-bridge/conversations",method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},kind:e.kind,...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agent_capable===void 0?{}:{agent_capable:e.agent_capable},members:e.members}};case"team_bridge.conversations.lifecycle":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/${e.action}${e.action==="join"?"":Hr(e)}`,method:"POST",...e.action==="join"&&(e.tenant_id||e.expected_account_id)?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.join":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/join`,method:"POST",...e.tenant_id||e.expected_account_id?{body:{...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.expected_account_id?{expected_account_id:e.expected_account_id}:{}}}:{}};case"team_bridge.conversations.notify":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},notify:e.notify}};case"team_bridge.conversations.members.add":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.expected_account_id&&t.set("expected_account_id",e.expected_account_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members${n}`,method:"POST",body:e.members}}case"team_bridge.conversations.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}${Hr(e)}`,method:"DELETE"};case"team_bridge.conversations.members.remove":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}${Hr(e)}`,method:"DELETE"};case"team_bridge.conversations.consent":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/members/${encodeURIComponent(e.account_id)}/consent`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},decision:e.decision,consent_version:e.consent_version}};case"team_bridge.owner_audit.conversations":case"team_bridge.owner_audit.messages":case"team_bridge.owner_audit.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit));let n="/v1/desktop/team-bridge/owner-audit/conversations";return e.op==="team_bridge.owner_audit.conversations"?e.cursor!==void 0&&t.set("cursor",e.cursor):(n+=`/${encodeURIComponent(e.conversation_id)}/messages`,e.op==="team_bridge.owner_audit.messages"?e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)):(n+=`/${encodeURIComponent(e.message_id)}/replies`,e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq)))),{path:`${n}?${t}`,method:"GET"}}case"team_bridge.messages.list":{const t=new URLSearchParams;e.tenant_id&&t.set("tenant_id",e.tenant_id),e.limit!==void 0&&t.set("limit",String(e.limit)),e.before_seq!==void 0&&t.set("before_seq",String(e.before_seq)),e.endpoint_id&&t.set("endpoint_id",e.endpoint_id);const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages${n}`,method:"GET"}}case"team_bridge.reactions.toggle":{const t=`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/reactions/${encodeURIComponent(e.emoji)}`;return e.active?{path:t,method:"PUT",body:{expected_account_id:e.expected_account_id,tenant_id:e.tenant_id}}:{path:`${t}${Hr(e)}`,method:"DELETE"}}case"team_bridge.messages.send":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},client_ref:e.client_ref,body:e.body,...e.agent_label?{agent_label:e.agent_label}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{},...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{}}};case"team_bridge.scheduled.list":return{path:`/v1/desktop/team-bridge/scheduled?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"GET"};case"team_bridge.scheduled.create":return{path:"/v1/desktop/team-bridge/scheduled",method:"POST",body:{tenant_id:e.tenant_id,conversation_id:e.conversation_id,client_ref:e.client_ref,body:e.body,send_at:e.send_at,...e.attachment_ids?.length?{attachment_ids:e.attachment_ids}:{},...e.thread_root_id?{thread_root_id:e.thread_root_id}:{}}};case"team_bridge.scheduled.update":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"PATCH",body:{...e.body===void 0?{}:{body:e.body},...e.send_at===void 0?{}:{send_at:e.send_at},...e.attachment_ids===void 0?{}:{attachment_ids:e.attachment_ids},...e.expected_version===void 0?{}:{expected_version:e.expected_version}}};case"team_bridge.attachments.delete":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/attachments/${encodeURIComponent(e.attachment_id)}?${new URLSearchParams({tenant_id:e.tenant_id,expected_account_id:e.expected_account_id})}`,method:"DELETE"};case"team_bridge.scheduled.cancel":return{path:`/v1/desktop/team-bridge/scheduled/${encodeURIComponent(e.scheduled_id)}?${new URLSearchParams({tenant_id:e.tenant_id})}`,method:"DELETE"};case"team_bridge.messages.replies":{const t=new URLSearchParams({expected_account_id:e.expected_account_id,tenant_id:e.tenant_id});e.limit!==void 0&&t.set("limit",String(e.limit)),e.after_seq!==void 0&&t.set("after_seq",String(e.after_seq));const n=t.size>0?`?${t.toString()}`:"";return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/messages/${encodeURIComponent(e.message_id)}/replies${n}`,method:"GET"}}case"team_bridge.read":return{path:`/v1/desktop/team-bridge/conversations/${encodeURIComponent(e.conversation_id)}/read`,method:"POST",body:{...e.expected_account_id?{expected_account_id:e.expected_account_id}:{},...e.tenant_id?{tenant_id:e.tenant_id}:{},...e.seq===void 0?{}:{seq:e.seq},...e.muted===void 0?{}:{muted:e.muted}}};case"team_bridge.unread":{const t=new URLSearchParams;return e.scope==="account"?t.set("scope","account"):e.tenant_id&&t.set("tenant_id",e.tenant_id),{path:`/v1/desktop/team-bridge/unread${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"team_bridge.directory":return{path:`/v1/desktop/team-bridge/directory?tenant_id=${encodeURIComponent(e.tenant_id)}`,method:"GET"};case"team_bridge.status":{const t=new URLSearchParams;return e.boundary&&t.set("boundary",e.boundary),{path:`/v1/desktop/team-bridge/status${t.size>0?`?${t.toString()}`:""}`,method:"GET"}}case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"library.list":{const t=new URLSearchParams;e.scope&&t.set("scope",e.scope),e.q&&t.set("q",e.q),e.category&&t.set("category",e.category),e.kind&&t.set("kind",e.kind),e.origin_group&&t.set("origin_group",e.origin_group),e.origin&&t.set("origin",e.origin),e.tag&&t.set("tag",e.tag),e.tag_mode&&t.set("tag_mode",e.tag_mode),e.highlighted!==void 0&&t.set("highlighted",e.highlighted?"1":"0"),e.organized!==void 0&&t.set("organized",e.organized?"1":"0"),e.favorite!==void 0&&t.set("favorite",e.favorite?"1":"0"),e.session&&t.set("session",e.session),e.session_id&&t.set("session_id",e.session_id),e.sort&&t.set("sort",e.sort),e.order&&t.set("order",e.order),e.limit!==void 0&&t.set("limit",String(e.limit)),e.cursor&&t.set("cursor",e.cursor);const n=t.toString();return{path:`/v1/desktop/library/assets${n?`?${n}`:""}`,method:"GET"}}case"library.get":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"GET"};case"library.update":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}`,method:"PATCH",body:e.fields};case"library.tags":return{path:"/v1/desktop/library/tags",method:"GET"};case"library.tags.create":return{path:"/v1/desktop/library/tags",method:"POST",body:{name:e.name,...e.category!==void 0?{category:e.category}:{}}};case"library.tags.update":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"PATCH",body:{...e.name!==void 0?{name:e.name}:{},...e.category!==void 0?{category:e.category}:{}}};case"library.tags.delete":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}`,method:"DELETE"};case"library.tags.merge":return{path:`/v1/desktop/library/tags/${encodeURIComponent(e.id)}/merge`,method:"POST",body:{into:e.into}};case"library.tags.assign":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/tags`,method:"PUT",body:{tags:e.tags,...e.primary!==void 0?{primary:e.primary}:{}}};case"library.chat.link":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"PUT",body:{session_id:e.sessionId}};case"library.chat.clear":return{path:`/v1/desktop/library/assets/${encodeURIComponent(e.id)}/chat`,method:"DELETE"};case"library.librarian":{const t=e.action??"status";return t==="status"?{path:"/v1/desktop/librarian",method:"GET"}:{path:"/v1/desktop/librarian",method:"POST",body:{op:t}}}case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields,...e.force_done===!0?{force_done:!0}:{}}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??wm)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}};case"sidebar_layout.get":return{path:"/v1/desktop/sidebar-layout",method:"GET"};case"sidebar_layout.set":return{path:"/v1/desktop/sidebar-layout",method:"PUT",body:{layout:e.layout}};case"notifications.list":{const t=new URLSearchParams;return e.state&&t.set("state",e.state),e.source&&t.set("source",e.source),e.priority&&t.set("priority",e.priority),e.sessionId&&t.set("session_id",e.sessionId),e.cursor&&t.set("cursor",e.cursor),e.throughSeq!==void 0&&t.set("through_seq",String(e.throughSeq)),e.limit!==void 0&&t.set("limit",String(e.limit)),{path:`/v1/desktop/notifications${t.size?`?${t}`:""}`,method:"GET"}}case"notifications.get":return{path:`/v1/desktop/notifications/${encodeURIComponent(e.id)}`,method:"GET"};case"notifications.count":return{path:"/v1/desktop/notifications/count",method:"GET"};case"notifications.read":case"notifications.dismiss":return{path:"/v1/desktop/notifications",method:"PATCH",body:{op:e.verb,...lg(e.target)}};case"notifications.seen":return{path:"/v1/desktop/notifications/seen",method:"POST",body:{items:e.items.map(t=>({id:t.id,revision:t.revision,anchor_id:t.anchorId,visible_since_ms:t.visibleSinceMs})),evidence:{surface:"desktop",session_id:e.evidence.sessionId,input_kind:Im[e.evidence.inputKind],input_at_ms:e.evidence.inputAtMs,visible_since_ms:e.evidence.visibleSinceMs}}}}}function lg(e){return"items"in e?{ids:e.items.map(t=>({id:t.id,revision:t.revision}))}:"sessionId"in e?{session_id:e.sessionId,through_seq:e.throughSeq,observed:e.observed}:{all:!0,through_seq:e.throughSeq,observed:e.observed}}const jE=64,ME=64*1024*1024,DE="superseded_completion_token",NE="store_busy",dg="session_is_remote",ug="owner_build_behind";function LE(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function yn(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function fg(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const $E=e=>typeof e?.goal_status=="string",UE=e=>(e?.goal??"").trim().length>0;function pg(e,t,n={}){return!e||e.epoch!==t.epoch?!0:t.seq>e.seq||n.allowEqual===!0&&t.seq===e.seq}function hg(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const Jn={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."};function mg(e){return e?e===Jn.notPaired?"notPaired":e===Jn.serverDown?"serverDown":e===Jn.frameBudget?"frameTooLarge":"lost":"lost"}const yc=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const p=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,p))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(r,s,c);return c},gg=e=>e?yc(e):yc,_g=e=>e;function yg(e,t=_g){const n=Ra.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return Ra.useDebugValue(n),n}const vc=e=>{const t=gg(e),n=r=>yg(t,r);return Object.assign(n,t),n},Rr=e=>e?vc(e):vc;function ud(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const a=l=>l===null?null:JSON.parse(l,void 0),c=(i=n.getItem(s))!=null?i:null;return c instanceof Promise?c.then(a):a(c)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const $i=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return $i(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return $i(r)(n)}}}},vg=(e,t)=>(n,r,s)=>{let i={storage:ud(()=>localStorage),partialize:h=>h,version:0,merge:(h,y)=>({...y,...h}),...t},a=!1;const c=new Set,l=new Set;let d=i.storage;if(!d)return e((...h)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...h)},r,s);const u=()=>{const h=i.partialize({...r()});return d.setItem(i.name,{state:h,version:i.version})},f=s.setState;s.setState=(h,y)=>{f(h,y),u()};const p=e((...h)=>{n(...h),u()},r,s);s.getInitialState=()=>p;let m;const _=()=>{var h,y;if(!d)return;a=!1,c.forEach(k=>{var E;return k((E=r())!=null?E:p)});const g=((y=i.onRehydrateStorage)==null?void 0:y.call(i,(h=r())!=null?h:p))||void 0;return $i(d.getItem.bind(d))(i.name).then(k=>{if(k)if(typeof k.version=="number"&&k.version!==i.version){if(i.migrate){const E=i.migrate(k.state,k.version);return E instanceof Promise?E.then(A=>[!0,A]):[!0,E]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,k.state];return[!1,void 0]}).then(k=>{var E;const[A,U]=k;if(m=i.merge(U,(E=r())!=null?E:p),n(m,!0),A)return u()}).then(()=>{g?.(m,void 0),m=r(),a=!0,l.forEach(k=>k(m))}).catch(k=>{g?.(void 0,k)})};return s.persist={setOptions:h=>{i={...i,...h},h.storage&&(d=h.storage)},clearStorage:()=>{d?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>_(),hasHydrated:()=>a,onHydrate:h=>(c.add(h),()=>{c.delete(h)}),onFinishHydration:h=>(l.add(h),()=>{l.delete(h)})},i.skipHydration||_(),m||p},ws=vg,bg=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function wg(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,s)=>typeof r=="number"&&Number.isFinite(r)?r:s;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const fd=Rr()(ws(e=>({notice:null,receive:t=>e(n=>bg(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:ud(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));function bo(e){return v(Pm[e])}async function pd(e){if(window.api?.desktop)try{return await Sg(window.api.desktop.request(e),e)}catch(n){throw n instanceof _e?n:Tg(n)?new Bt(dd,ld):new _e(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new _e(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new _e(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function Sg(e,t){const n=cd(t);let r;return Promise.race([e,new Promise((s,i)=>{r=setTimeout(()=>{const a=og(t.op,n);i(new _e(null,a.message,void 0,a.code))},n)})]).finally(()=>clearTimeout(r))}const hd="This server did not answer the request for its desktop controls.",kg=()=>v("ui.common.errors.desktop_refusal_placeholder");class _e extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,s,i,a){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=s,this.retryAfterMs=i,this.detail=a}}class Bt extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function wo(e,t){return e instanceof _e||e instanceof Bt?bs(e.code)?bo(e.code):e.message===hd?kg():e.message:t}function Eg(e,t,n,r){return typeof r=="string"?r:n===Li.noCredential?qe.noCredential:n===Li.transportFailed?qe.transportFailed:Om(cg(e).path,t)}async function xe(e){const t=await pd(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new _e(t.status,r??hd,void 0,Eg(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&Ig(n?.result),n?.result}function Ig(e){if(typeof e!="object"||e===null)return;const t=wg(e.delegated_cleanup_notice);t&&fd.getState().receive(t)}async function Rg(){try{await xe({op:"delegated_cleanup_notice.ack"})}catch{}}async function FE(){fd.getState().dismiss(),await Rg()}function xg(e){return e instanceof _e&&e.code===vo}function BE(e){if(!(e instanceof _e))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===ug:e.code===dg}function GE(e){return e instanceof Bt&&e.code===ld}function Tg(e){return e instanceof Error&&e.message.includes(dd)}async function HE(e){const t=await pd(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function WE(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await xe({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function Cg(e,t){const n=window.api?.desktop?.stream;if(n){const i=n.subscribe(e,t);return()=>i.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),as(r,"/__desktop/stream",e.orderIds??[]));const s=new EventSource(`/__desktop/stream?${r}`);return s.onmessage=i=>{t({kind:"data",data:i.data})},s.onerror=()=>{s.readyState===EventSource.CLOSED&&(t({kind:"error",detail:Jn.ended}),s.close())},()=>{s.close(),t({kind:"end"})}}async function zE(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),s=r.headers.get("content-type")??"";if(!r.ok){let i="The media request failed.",a;if(s.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")i=l;else if(typeof l=="object"&&l!==null){const d=l;typeof d.text=="string"&&d.text.trim()?i=d.text:typeof d.message=="string"&&d.message.trim()&&(i=d.message),typeof d.code=="string"&&(a=d.code)}}catch{}return{status:r.status,kind:"error",detail:i,code:a!==void 0&&bs(a)?a:i===Li.noCredential?qe.noCredential:void 0}}return s.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:s||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function ZE(e){return e.kind==="error"?bs(e.code)?new Bt(bo(e.code),e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}function Ag(e){if(xg(e))return"deadline";const t=e instanceof _e?e.status:null;return t===null||t===503?"unreachable":t===401||t===403?"unauthorized":t===404?"outdated":"unknown"}const md={unreachable:"",deadline:"",unauthorized:"",get outdated(){return v("ui.common.connection.backend.remedy_outdated")},unknown:""},Ui={get unreachable(){return v("ui.common.connection.backend.diagnosis_unreachable")},get deadline(){return v("ui.common.connection.backend.diagnosis_deadline")},get unauthorized(){return v("ui.common.connection.backend.diagnosis_unauthorized")},get outdated(){return v("ui.common.connection.backend.diagnosis_outdated")},unknown:""};function Pg(e,t){const n=Ag(t);return[e,Ui[n],md[n]].filter(Boolean).join(" ")}const Fi={get successor(){return v("ui.common.connection.backend.pairing_successor")},get"governed-elsewhere"(){return v("ui.common.connection.backend.pairing_governed")},get"pre-handshake"(){return v("ui.common.connection.backend.pairing_pre_handshake")},get"credential-refused"(){return v("ui.common.connection.backend.pairing_credential_refused")},get unpaired(){return v("ui.common.connection.backend.pairing_unpaired")}},Og={get successor(){return v("ui.common.connection.backend.pane_successor")},get"governed-elsewhere"(){return v("ui.common.connection.backend.pane_governed")},get"pre-handshake"(){return v("ui.common.connection.backend.pane_pre_handshake")},get"credential-refused"(){return v("ui.common.connection.backend.pane_credential_refused")},get unpaired(){return v("ui.common.connection.backend.pane_unpaired")}};function KE(e,t){return e!=="unpaired"?null:Og[t??"unpaired"]}function VE(e,t){return e!=="unpaired"?null:Fi[t??"unpaired"]}function YE(e){const{kind:t,unpaired:n,answered:r,cause:s=null,servedByThisApp:i=!1}=e;return s==="pre-handshake"?i:s!==null||n?!1:r?i:t==="outdated"}function QE(e){const{kind:t,unpaired:n,missing:r,answered:s,cause:i=null}=e;if(i!==null)return Fi[i];if(!s){if(t==="unreachable")return v("ui.common.connection.backend.compatibility_unreachable",{diagnosis:Ui.unreachable});if(t==="unauthorized")return v("ui.common.connection.backend.compatibility_unauthorized");if(t==="deadline")return v("ui.common.connection.backend.compatibility_deadline",{diagnosis:Ui.deadline});if(t==="outdated")return v("ui.common.connection.backend.compatibility_outdated",{remedy:md.outdated})}return n?Fi.unpaired:s?v("ui.common.connection.backend.compatibility_missing",{features:r.join(", ")}):v("ui.common.connection.backend.compatibility_unknown")}const jg=["auth","settings","commands","catalogues","lifecycle","mcp","radient"];function JE(e,t=null){return t!==null||!e?!0:jg.filter(r=>(e.features?.[r]??0)<1).length>0||e.desktop_available!==!0}function Mg(e,t){return t instanceof _e&&t.status===null?!1:e<1}function XE(e,t){return t instanceof _e&&t.status!==null&&t.status>=400&&t.status<500&&t.status!==408&&t.status!==425&&t.status!==429?!1:e<1}const Dg={get successor(){return v("ui.common.connection.backend.card_successor")},get"governed-elsewhere"(){return v("ui.common.connection.backend.card_governed")},get"pre-handshake"(){return v("ui.common.connection.backend.card_pre_handshake")},get"credential-refused"(){return v("ui.common.connection.backend.card_credential_refused")},get unpaired(){return v("ui.common.connection.backend.card_unpaired")}};function qE(e,t,n){return e===null?{sentence:Pg(t,n),remedy:!0}:{sentence:Dg[e],remedy:Hl(e)}}const gd={settings:["desktop","settings"],capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],accounts:["desktop","auth","accounts"],catalogue:["desktop","models"],credentials:e=>["desktop","credentials",e]},Ng=3e4,Lg=15e3;function $g(e){return e?.desktop_available===!0}function eI(){const{client:e,provided:t}=gp();return Gl({enabled:t,queryKey:gd.capabilities,queryFn:async()=>{try{return await xe({op:"capabilities"})}catch(n){throw n instanceof Error?n:new Error(String(n))}},staleTime:6e4,retry:!1,refetchInterval:n=>$g(n.state.data)?Ng:Lg,refetchIntervalInBackground:!0},e)}function Ug(e,t,n=1){return e?e.desktop_available?(e.features?.[t]??0)>=n?"enabled":"below-version":"unpaired":"unknown"}function tI(e,t,n=1){return Ug(e,t,n)==="enabled"}function nI(e){return Gl({queryKey:gd.providers,queryFn:()=>xe({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:Mg})}const Un=e=>{const t=e.id;return typeof t=="string"?t:typeof t=="number"?String(t):null};function Fg(e,t){const n=new Set((t.removed??[]).map(String)),r=e.filter(a=>{const c=Un(a);return c===null||!n.has(c)});for(const a of t.upserted??[]){const c=Un(a);if(c===null){r.push(a);continue}const l=r.findIndex(d=>Un(d)===c);l===-1?r.push(a):r[l]=a}if(!t.order)return r;const s=new Map;for(const a of r){const c=Un(a);c!==null&&s.set(c,a)}const i=[];for(const a of t.order){const c=String(a),l=s.get(c);l&&(i.push(l),s.delete(c))}for(const a of r){const c=Un(a);c!==null&&s.has(c)?(i.push(a),s.delete(c)):c===null&&i.push(a)}return i}const Bi=e=>({revision:Je(e),demand:e.orderDemand}),qt=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Tn(e,t,n,r,s,i={}){let a=e;const c=t.journal_generation;if(t.reconcile===!0){const p=typeof c=="string"&&c.length>0?c:void 0;return a.orderNeedsReconcile&&a.orderWantedGeneration===p?a.journalMode?a:{...a,journalMode:!0}:{...a,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:p,orderDemand:p!==void 0?{generation:p}:{}}}if(typeof c!="string"||c.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&s&&a.orderNeedsReconcile&&a.orderDemand===s.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),c!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===c?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:c,orderDemand:{generation:c}};let l=a.journalMode?a:{...a,journalMode:!0};if(c!==a.journalGeneration&&(l={...a,journalMode:!0,journalGeneration:c,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand},i.peer===!0)){const p=(a.orderRevision??0)+1,m=new Map;for(const _ of a.records){const h=_.sourceEntryId??(_.kind==="tool"||_.kind==="supplement"?null:_.id);typeof h=="string"&&h.length>0&&h.length<=128&&m.set(h,p)}l={...l,...m.size>0?{journalBodyOwed:m}:{},journalSourceVoid:void 0}}let d=l.journalPositions??new Map;const u=d,f=(p,m,_)=>{if(!qt(_))return;const h=d.get(p);h&&h.seq>=_||(d===u&&(d=new Map(d)),d.set(p,{entryId:m,seq:_}))};for(const[p,m]of Object.entries(t.journal_ordinals??{}))f(p,p,m);for(const p of n)typeof p.id=="string"&&(f(p.id,p.id,p.journal_seq),p.role==="tool"&&typeof p.tool_call_id=="string"&&f(`tool:${p.tool_call_id}`,p.id,p.journal_seq),typeof p.anchor=="string"&&f(`supplement:${p.anchor}`,p.id,p.journal_seq));return d!==u&&(l={...l,journalPositions:d}),l}function So(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const s=n,i=r;return t.tool_calls.forEach((a,c)=>{!a||typeof a.id!="string"||(n.get(a.id)!==t.id&&(n===s&&(n=new Map(n)),n.set(a.id,t.id)),r.get(a.id)!==c&&(r===i&&(r=new Map(r)),r.set(a.id,c)))}),n===s&&r===i?e:{...e,journalCallOwners:n,journalCallSlots:r}}function _d(e,t){const n=new Set(e.map(i=>i.id));let r=!1,s;for(let i=0;i<e.length;i++){const a=e[i];if(a.kind==="user"&&a.provisional===!0){s=a;continue}if(a.sourcePrecedes!==void 0){if(a.sourceAdmissionAnchor!==void 0){const{sourceAdmissionAnchor:c,...l}=a;e[i]=l,r=!0}s=e[i];continue}!t(a)&&s&&(a.sourceAdmissionAnchor===void 0||!n.has(a.sourceAdmissionAnchor))&&(e[i]={...a,sourceAdmissionAnchor:s.id},r=!0),s=e[i]}return r}function yd(e,t,n,r,s){const i=[],a=new Set;let c=e,l;for(;c!==void 0;){if(s.has(c.id)){l=s.get(c.id);break}if(n(c)){l=r(c);break}if(c.kind==="user"&&c.provisional===!0||a.has(c.id))break;a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor?t.get(c.sourceAdmissionAnchor):void 0}for(const d of i)s.set(d,l);return l}const Bg=Number.MAX_SAFE_INTEGER;function Gg(e,t){const n=new Map,r=new Map,s=new Map;for(const i of e){if(i.sourcePrecedes===void 0)continue;const a=t(i);if(a!==void 0)r.set(i.sourcePrecedes,a);else{const c=r.get(i.sourcePrecedes);c!==void 0&&n.set(i.id,{seq:c,slot:Bg})}}for(let i=e.length-1;i>=0;i--){const a=e[i];if(a.sourcePrecedes===void 0)continue;const c=t(a);if(c!==void 0)s.set(a.sourcePrecedes,c);else if(!n.has(a.id)){const l=s.get(a.sourcePrecedes);l!==void 0&&n.set(a.id,{seq:l,slot:-1})}}return n}function vd(e,t){return{floor:Hg(e,t),position:new Map(e.map((n,r)=>[n.id,r])),page:Gg(e,t)}}function bd(e,t,n,r){if(r===void 0||e.sourcePrecedes===void 0)return;const s=r.page.get(e.id);if(s!==void 0)return s;const i=new Set;let a=1,c=t.get(e.sourcePrecedes);for(;c!==void 0&&!i.has(c.id);){i.add(c.id);const l=n(c);if(l!==void 0)return{seq:l,slot:-a};const d=r.page.get(c.id);if(d!==void 0)return{seq:d.seq,slot:d.slot-a};a+=1,c=c.sourcePrecedes?t.get(c.sourcePrecedes):void 0}return r.floor===void 0?void 0:{seq:r.floor,slot:-a}}function wd(e,t,n){if(n===void 0||e.sourcePrecedes===void 0)return;const{position:r}=n,s=new Set;let i=1,a=t.get(e.sourcePrecedes);for(;a!==void 0&&!s.has(a.id);){if(a.sourcePrecedes===void 0){const c=r.get(a.id);return c===void 0?void 0:{slot:c,depth:i}}s.add(a.id),i+=1,a=t.get(a.sourcePrecedes)}}function Hg(e,t){let n;for(const r of e){if(r.sourcePrecedes!==void 0)continue;const s=t(r);s!==void 0&&(n===void 0||s<n)&&(n=s)}return n}function Sd(e,t){const n=new Map;return r=>{if(!r)return;const s=t(r);if(s===void 0)return;const i=[],a=new Set;let c=r,l=!0;for(;c;){if(n.has(c.id)){l=n.get(c.id)===!0;break}if(a.has(c.id)||t(c)===void 0){l=!1;break}a.add(c.id),i.push(c.id),c=c.sourceAdmissionAnchor===void 0?void 0:e.get(c.sourceAdmissionAnchor)}for(const d of i)n.set(d,l);return l?s:void 0}}function cs(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const s=new Map;t.forEach((a,c)=>{if(a.kind!=="tool")return;const l=n.get(a.toolCallId);if(l===void 0||!r.has(a.toolCallId))return;const d=s.get(l);d?d.push(c):s.set(l,[c])});let i=t;for(const a of s.values()){if(a.length<2)continue;const c=a.map(l=>t[l]).sort((l,d)=>(r.get(l.toolCallId)??0)-(r.get(d.toolCallId)??0));c.every((l,d)=>l===t[a[d]])||(i===t&&(i=t.slice()),a.forEach((l,d)=>{i[l]=c[d]}))}return i}function kd(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return Wg(e,t);const n=e.journalGeneration,r=e.journalPositions;let s=!1,i=!1;const a=t.map(h=>{h.sourcePrecedes!==void 0&&(i=!0);let g=[r?.get(h.sourceEntryId??h.id),r?.get(h.id)].filter(A=>A!==void 0).sort((A,U)=>U.seq-A.seq)[0];if(h.journalGeneration===n&&qt(h.journalSeq)&&(!g||h.journalSeq>g.seq)&&(g={entryId:h.sourceEntryId??h.id,seq:h.journalSeq}),!g||!n||!(h.kind==="user"&&(h.provisional===!0||h.local===!0))&&h.sourceEntryId===g.entryId&&h.journalSeq===g.seq&&h.journalGeneration===n)return h;s=!0;let E={...h,sourceEntryId:g.entryId,journalSeq:g.seq,journalGeneration:n};if(E.kind==="user"){const{provisional:A,local:U,...P}=E;E=P}return E});_d(a,h=>h.journalGeneration===n&&qt(h.journalSeq))&&(s=!0);const l=new Map,d=new Map(a.map(h=>[h.id,h])),u=Sd(d,h=>h!==void 0&&h.journalGeneration===n&&qt(h.journalSeq)?h.journalSeq:void 0),f=h=>u(h)!==void 0,p=i?vd(a,u):void 0,m=(h,y)=>{const g=u(h);if(h.kind==="user"&&h.provisional===!0&&g===void 0)return[1,0,0,0,y];const k=h.kind==="supplement"?h.anchor:h.kind==="tool"?e.journalCallOwners?.get(h.toolCallId)??e.argsByCall.get(h.toolCallId)?.anchorId:void 0,E=typeof k=="string"?u(d.get(k)):void 0,A=E===void 0&&g===void 0?bd(h,d,u,p):void 0,U=g===void 0&&A===void 0?yd(h,d,f,u,l):void 0,P=E??g??A?.seq??U;if(P===void 0){const O=wd(h,d,p);return[1,O?.slot??y,O?-O.depth:0,0,y]}return[0,P,E!==void 0?1:g!==void 0?0:A!==void 0?A.slot:2,g??Number.MAX_SAFE_INTEGER,y]},_=a.map((h,y)=>({record:h,index:y,rank:m(h,y)}));return _.sort((h,y)=>{for(let g=0;g<h.rank.length;g++){const k=h.rank[g]-y.rank[g];if(k)return k}return 0}),!s&&_.every((h,y)=>h.index===y)?cs(e,t):cs(e,_.map(h=>h.record))}function Wg(e,t){const n=e.journalGeneration,r=e.journalPositions,s=new Map;let i=!1;for(const g of t){g.sourcePrecedes!==void 0&&(i=!0);let E=[r?.get(g.sourceEntryId??g.id),r?.get(g.id)].filter(A=>A!==void 0).sort((A,U)=>U.seq-A.seq)[0];g.journalGeneration===n&&qt(g.journalSeq)&&(!E||g.journalSeq>E.seq)&&(E={entryId:g.sourceEntryId??g.id,seq:g.journalSeq}),E&&s.set(g.id,E)}const a=g=>g===void 0?void 0:s.get(g.id)??r?.get(g.sourceEntryId??g.id)??r?.get(g.id);let c=!1;const l=t.slice();_d(l,g=>g.journalGeneration===n&&qt(g.journalSeq))&&(c=!0);const u=new Map,f=new Map(l.map(g=>[g.id,g])),p=Sd(f,g=>a(g)?.seq),m=g=>p(g)!==void 0,_=i?vd(l,p):void 0,h=(g,k)=>{const E=p(g);if(g.kind==="user"&&g.provisional===!0&&E===void 0)return[1,0,0,0,k];const A=g.kind==="supplement"?g.anchor:g.kind==="tool"?e.journalCallOwners?.get(g.toolCallId)??e.argsByCall.get(g.toolCallId)?.anchorId:void 0,U=typeof A=="string"?p(f.get(A)):void 0,P=U===void 0&&E===void 0?bd(g,f,p,_):void 0,O=E===void 0&&P===void 0?yd(g,f,m,p,u):void 0,I=U??E??P?.seq??O;if(I===void 0){const N=wd(g,f,_);return[1,N?.slot??k,N?-N.depth:0,0,k]}return[0,I,U!==void 0?1:E!==void 0?0:P!==void 0?P.slot:2,E??Number.MAX_SAFE_INTEGER,k]},y=l.map((g,k)=>({record:g,index:k,rank:h(g,k)}));return y.sort((g,k)=>{for(let E=0;E<g.rank.length;E++){const A=g.rank[E]-k.rank[E];if(A)return A}return 0}),!c&&y.every((g,k)=>g.index===k)?cs(e,t):cs(e,y.map(g=>g.record))}function ut(e){const t=e.records.filter(s=>s.kind==="user"&&s.provisional===!0),n=e.records.filter(s=>s.journalGeneration!==e.journalGeneration||!qt(s.journalSeq)),r=[...t,...n].map(s=>s.sourceEntryId??(s.kind==="tool"||s.kind==="supplement"?null:s.id));if(r.push(...ko(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let s=r.length-1;s>=0;s--){const i=r[s];typeof i=="string"&&e.journalSourceVoid.has(i)&&r.splice(s,1)}return[...new Set(r.filter(s=>typeof s=="string"&&s.length>0&&s.length<=128))]}function ko(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const s=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof s=="string"&&s.length>0&&s.length<=128&&t.add(s)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Ed(e,t){const n=e.journalPositions;return ut(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Je=e=>e.orderRevision??0;async function zg(e){const t=new Map,n=c=>{let l=t.get(c);return l||(l=new Set,t.set(c,l)),l},r=(c,l)=>l==="payload"?ko(c):l==="lookup"?Ed(c):ut(c);let s=e.getTranscript().journalGeneration,i=0,a=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const c=e.getTranscript(),l=Bi(c),d=l.revision,u=e.sweep?.(c,n);if(u?.kind==="none")return{kind:"complete",transcript:c};const f=u?.kind??"authority",p=Nh(r(c,f).filter(y=>!n(f).has(y)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),m=await e.read(p,f);if(!e.isCurrent()||Je(e.getTranscript())!==d)return{kind:"stale"};if(e.commit(m,d,l),!e.isCurrent())return{kind:"stale"};const _=e.getTranscript(),h=e.page(m);if(h.journal_order_state==="ready"&&h.journal_generation===_.journalGeneration){h.journal_generation!==s&&(t.clear(),s=h.journal_generation);for(const k of p)n(f).add(k);if(_.orderNeedsReconcile){if(_.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear();continue}if(f==="payload"){const k=(h.source_retry_ids??[]).filter(E=>typeof E=="string"&&E.length>0&&E.length<=128);if(k.length>0&&p.length>1&&a===0){a++;for(const E of k)n("payload").delete(E);continue}}const y=e.sweep?.(_,n);if(y?.kind==="none")return{kind:"complete",transcript:_};const g=y?.kind??"authority";if(r(_,g).some(k=>!n(g).has(k)))continue;return{kind:"complete",transcript:_}}if(!_.orderNeedsReconcile||_.orderDemand===l.demand||i===1)return{kind:"waiting"};i++,t.clear()}}function st(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const s=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof s=="string"&&s?s:e.id}function ni(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function bc(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function rI(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const i of t){if(!i.settled||typeof i.run_key!="string"||i.run_key.length===0)continue;const a=ni(i.action_count);if(a===null)continue;const c={actions:a,workedSeconds:bc(i.worked_seconds),failed:ni(i.failed_count)??0,complete:i.complete!==!1,openingUserId:typeof i.opening_user_id=="string"&&i.opening_user_id.length>0?i.opening_user_id:null,closingAnswerId:typeof i.closing_answer_id=="string"&&i.closing_answer_id.length>0?i.closing_answer_id:null,crossSessionActions:ni(i.cross_session_action_count),crossSessionWorkedSeconds:bc(i.cross_session_worked_seconds)};n.set(i.run_key,c),c.openingUserId!==null&&n.set(c.openingUserId,c),c.closingAnswerId!==null&&n.set(c.closingAnswerId,c)}if(n.size===0)return null;const r=new Set;for(const i of e.entries)r.add(st(i));const s=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:s?st(s):null}}}function Zg(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(i=>i.opening_user_id===n.id))return null;const s=Math.round((n.ts??0)*1e3);return s>0?{id:n.id,tsMs:s}:null}function Kg(e,t,n){const r=Zg(e),s=e?.entries;if(r===null||!s||s.length===0)return!1;const i=Math.round((s[s.length-1].ts??0)*1e3);if(!(i>r.tsMs))return!1;for(const[a,c]of t)if(!n.has(a)&&(c===null||!(c>r.tsMs)||!(c<i)))return!1;return!0}const Eo=new Set,Gt="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Io=new RegExp(`[${Gt}]`),Vg=new RegExp(`[${Gt}]+`),sI=new RegExp(`[${Gt}]+`,"g"),Yg=new RegExp(`^[${Gt}]+|[${Gt}]+$`,"g"),Qg=new RegExp(`^[${Gt}]+`),iI=new RegExp(`[^${Gt}]`);function mt(e){return e.replace(Yg,"")}function gr(e){return e.replace(Qg,"")}function Id(e,t){return t===0||Io.test(e[t-1])}function Rd(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&Id(e,n)&&t.push(n);return t}function Ro(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
2
2
|
`,n-1)+1,s=e.indexOf(`
|
|
3
3
|
`,n),i=s===-1?e.length:s;let a=e.slice(r,i);return a.endsWith("\r")&&(a=a.slice(0,-1)),{line:a,lineStart:r,column:n-r}}function Jg(e,t){if(t.size===0)return null;for(const n of Rd(e)){const r=e.slice(n+1),s=r.indexOf(" ");if(s!==-1&&t.has(r.slice(0,s).toLowerCase()))return n}return null}function xo(e,t,n){const r=Jg(e,n);let s=null;for(const i of Rd(e)){if(i===r)return t>i?i:s;i<=t&&(s=i)}return s}function Xg(e,t=null,n=Eo){const{line:r,lineStart:s,column:i}=Ro(e,t),a=xo(r,i,n);if(a===null)return null;let c=a+1;for(;c<r.length&&!Io.test(r[c]);)c++;return i>c?null:{start:s+a,query:r.slice(a+1,c),end:s+c}}function oI(e,t=null,n=Eo){const{line:r,lineStart:s,column:i}=Ro(e,t),a=xo(r,i,n);return a===null?null:{start:s+a,end:s+r.length}}function qg(e,t,n=null,r=Eo){const{line:s,lineStart:i,column:a}=Ro(e,n),c=r.size>0?r:new Set(t.map(m=>m.toLowerCase())),l=xo(s,a,c);if(l===null)return null;const d=s.slice(l+1),u=d.indexOf(" ");if(u===-1)return null;const f=d.slice(0,u);if(!t.some(m=>m.toLowerCase()===f.toLowerCase()))return null;const p=l+1+f.length;return a<=p?null:{value:d.slice(u+1),start:i+p+1,end:i+s.length,tokenStart:i+l}}function wc(e,t){return mt(e.slice(0,t))===""}function aI(e,t,n,r){const s=qg(e,r,t,n);if(s!==null&&wc(e,s.tokenStart))return"argument";const i=Xg(e,t,n);return i!==null&&wc(e,i.start)?"command":null}function cI(e,t,n,r){let s=t,i=n;const a=c=>c>=0&&c<e.length&&`
|
|
4
4
|
`.includes(e[c]);return r===""?s>0&&a(s-1)?s-=1:a(i)&&(i+=1):s===0&&a(i)&&(i+=1),{text:`${e.slice(0,s)}${r}${e.slice(i)}`,caret:s+r.length}}const e_=1e3,t_=900,n_=40,xd=3;function r_(e,t){let n=0,r=-2,s=0;for(const i of e){const a=t.indexOf(i,s);if(a<0)return 0;n+=a===r+1?2:1,r=a,s=a+1}return n<=0?0:Math.max(1,Math.min(n_,n))}function Td(e,t){const n=e.toLowerCase(),r=t.toLowerCase();return n?n===r?e_:r.startsWith(n)?t_:r_(n,r):0}function s_(e){const n=mt(e).split(Vg).pop()??"";return n.startsWith("/")?n.slice(1):n}function i_(e,t){const n=s_(e),r=[];return t.forEach((s,i)=>{let a=0,c=s.name;for(const l of[s.name,...s.aliases]){const d=Td(n,l);d>a&&(a=d,c=l)}a>0&&r.push({score:a,index:i,name:c,command:s})}),r.sort((s,i)=>i.score-s.score||s.index-i.index),r.map(s=>({name:s.name,command:s.command}))}function lI(e,t){if(!e)return t.map(i=>({name:i.name,command:i}));const n=i_(`/${e}`,t);if(e.length>=xd)return n;const r=e.toLowerCase(),s=n.filter(({name:i})=>i.toLowerCase().startsWith(r));return s.length>0?s:n}function Sc(e,t){if(!e)return t.map(r=>({name:r.name,choice:r}));const n=[];return t.forEach((r,s)=>{const i=Math.max(0,...[r.name,...r.aliases??[]].map(a=>Td(e,a)));i>0&&n.push({score:i,order:s,choice:r})}),n.sort((r,s)=>s.score-r.score||r.order-s.order),n.map(r=>({name:r.choice.name,choice:r.choice}))}const kc=/^-+/;function dI(e,t,n,r,s){if(s)return!0;const i=mt(e).toLowerCase(),a=mt(t).toLowerCase();return i===a||i.length>0&&i.replace(kc,"")===a.replace(kc,"")?!0:!r&&n<=1}const o_=new RegExp("\\p{Ll}","u");function Cd(e){for(const t of e)if(o_.test(t))return!0;return!1}function uI(e,t,n){if(n){if(!e)return t.map(a=>({name:a.name,choice:a}));const r=Sc(e,t);if(e.length>=xd)return r;const s=e.toLowerCase(),i=r.filter(a=>a.name.toLowerCase().startsWith(s));return i.length>0?i:r}return Cd(e)?Sc(e,t).filter(r=>r.name.startsWith(e)):[]}const a_=/<skill name="([^"]*)" invocation="([^"]*)">/,c_=/[A-Za-z0-9]/,l_=/[A-Za-z0-9._-]/,d_=/[._-]/;function u_(e,t){if(t>=e.length||!c_.test(e[t]))return t;let n=t+1;for(;n<e.length&&l_.test(e[n]);)n++;return n}function f_(e){const t=[];let n=0;for(;n<e.length;){if(e[n]!=="$"||!Id(e,n)){n+=1;continue}const r=u_(e,n+1);r>n+1&&t.push({start:n,end:r,name:e.slice(n+1,r)}),n+=Math.max(r-n,1)}return t}function p_(e,t,n,r,s,i){let a=n;for(;;){const c=e.slice(t+1,a);if(r.has(c))return{end:a,name:c};if(i||Cd(c)){const l=s.get(c.toLowerCase());if(l!==void 0)return{end:a,name:l}}if(a>t+2&&d_.test(e[a-1])){a-=1;continue}return null}}function h_(e,t,n={}){const r=new Set(t),s=new Map;for(const l of t)s.has(l.toLowerCase())||s.set(l.toLowerCase(),l);const i=n.skipSpans??[],a=[],c=new Set;for(const l of f_(e)){if(i.some(([f,p])=>f<=l.start&&l.start<p))continue;const d=gr(e.slice(0,l.start))==="",u=p_(e,l.start,l.end,r,s,d);u===null||c.has(u.name)||(c.add(u.name),a.push({start:l.start,end:u.end,text:e.slice(l.start,u.end),name:u.name,leading:d}))}return a}const vn="<operator-skills>",ls="</operator-skills>",Zn=`
|