offsite 0.0.88 → 0.0.90

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.
@@ -0,0 +1 @@
1
+ var e=[[`path`,{d:`M9.13432 2.5C6.46805 2.56075 4.9107 2.81456 3.84664 3.87493C2.91537 4.80297 2.60406 6.10756 2.5 8.2M14.8657 2.5C17.532 2.56075 19.0893 2.81456 20.1534 3.87493C21.0846 4.80297 21.3959 6.10756 21.5 8.2M14.8657 21.5C17.532 21.4392 19.0893 21.1854 20.1534 20.1251C21.0846 19.197 21.3959 17.8924 21.5 15.8M9.13432 21.5C6.46805 21.4392 4.9107 21.1854 3.84664 20.1251C2.91537 19.197 2.60406 17.8924 2.5 15.8`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M16 12C16 14.2091 14.2091 16 12 16C9.79086 16 8 14.2091 8 12C8 9.79086 9.79086 8 12 8C14.2091 8 16 9.79086 16 12Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]];export{e as t};
@@ -9,7 +9,7 @@ import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{c as n,l as r,r as i
9
9
  font-weight: bold;
10
10
  padding: 2px 0.5em;
11
11
  `,a=`%c${[r,n].filter(Boolean).join(`:`)}`;typeof e.args[0]==`string`?t(`${a}%c ${e.args[0]}`,i,``,...e.args.slice(1)):t(a,i,...e.args)}};function Yr(e={}){return qr({reporters:e.reporters||[new Jr({})],prompt(e,t={}){return t.type===`confirm`?Promise.resolve(confirm(e)):Promise.resolve(prompt(e))},...e})}Yr();function Xr(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Zr(e,t){let n,r=()=>{if(n)return n;let r=indexedDB.open(e);return r.onupgradeneeded=()=>r.result.createObjectStore(t),n=Xr(r),n.then(e=>{e.onclose=()=>n=void 0},()=>{n=void 0}),n};return(e,n)=>r().then(r=>n(r.transaction(t,e).objectStore(t)))}var Qr;function $r(){return Qr||=Zr(`keyval-store`,`keyval`),Qr}function ei(e,t=$r()){return t(`readonly`,t=>Xr(t.get(e)))}function ti(e,t,n=$r()){return n(`readwrite`,n=>(n.put(t,e),Xr(n.transaction)))}function ni(e,t=$r()){return t(`readwrite`,t=>(t.delete(e),Xr(t.transaction)))}var ri=Zr(`offsite`,`tokens`);function ii(e){return ei(e,ri)}function ai(e,t){return ti(e,t,ri)}function oi(e){return ni(e,ri)}var si=1e3,ci=5e3,li=1e3,ui=[],di,fi=Yr({level:M.verbose,throttle:0});fi.addReporter({log:hi});var pi=fi.withTag(`app`);function mi(){window.addEventListener(`error`,e=>pi.error(`uncaught error:`,e.error??e.message)),window.addEventListener(`unhandledrejection`,e=>pi.error(`unhandled rejection:`,e.reason)),pi.info(`started on ${location.origin} in ${navigator.userAgent}`)}function hi(e){ui.push({time:e.date.getTime(),type:e.type,tag:e.tag,message:e.args.map(yi).join(` `)}),ui.length>li&&ui.splice(0,ui.length-li),gi(si)}function gi(e){di??=window.setTimeout(()=>void _i(),e)}async function _i(){let e=ui.splice(0),t;try{let n=JSON.parse(localStorage.getItem(`machines`)??`[]`).find(e=>e.addresses.includes(location.origin)),r=n===void 0?void 0:await ii(n.id);t=await fetch(`/api/logs`,{method:`POST`,headers:r===void 0?{}:{authorization:`Bearer ${r}`},body:JSON.stringify(e)})}catch{vi(e);return}t.status>=500?vi(e):(di=void 0,t.ok||console.warn(`the server refused ${e.length} log entries: ${await t.text()}`),ui.length>0&&gi(si))}function vi(e){ui.unshift(...e),ui.length>li&&ui.splice(0,ui.length-li),di=void 0,gi(ci)}function yi(e){if(typeof e==`string`)return e;if(e instanceof Error)return e.stack!==void 0&&e.stack.startsWith(String(e))?e.stack:[String(e),e.stack].join(`
12
- `);try{return JSON.stringify(e)??String(e)}catch{return String(e)}}var bi=1e3,xi=3e4,Si=1e4,Ci=1e4,wi=3e3,Ti=3e4,Ei=3e5,Di=[`sessions.send`,`sessions.rewind`,`sessions.fork`,`git.commit`,`git.push`,`git.pullRequest`,`git.createPullRequest`],Oi=fi.withTag(`connection`),ki=new Set,P=new Map,Ai=0;function ji(){window.setInterval(()=>{for(let e of P.keys())zi(e)},Si),document.addEventListener(`visibilitychange`,()=>{document.hidden||Mi()}),window.addEventListener(`online`,Mi)}function Mi(){for(let[e,t]of P)t.connected?zi(e):t.timer!==void 0&&(window.clearTimeout(t.timer),t.timer=void 0,t.failures=0,Bi(e,t,0))}function Ni(e,t){if(P.has(e))return;let n={urls:t,url:t[0],socket:null,connected:!1,ping:null,timer:void 0,failures:0,pending:new Map};P.set(e,n),Bi(e,n,0)}function Pi(e){let t=P.get(e);t!==void 0&&(P.delete(e),window.clearTimeout(t.timer),t.socket!==null&&(t.socket.onclose=null,t.socket.close()),Wi(e,t))}function Fi(e){ki.add(e)}function Ii(e){return P.get(e)?.connected===!0}function Li(e){let t=P.get(e);if(t===void 0)throw Error(`This machine is not connected`);return t.url}function F(e,t,n){let r=P.get(e);if(r===void 0||r.socket===null||!r.connected)return Promise.reject(Error(r===void 0?`That machine was removed`:`Not connected to ${new URL(r.url).host}; reconnecting`));Ai+=1;let i=Ai;r.socket.send(JSON.stringify({id:i,method:t,params:n}));let a=Di.includes(t)?Ei:Ti;return new Promise((e,n)=>{let o=window.setTimeout(()=>{r.pending.delete(i),n(Error(`${new URL(r.url).host} did not answer ${t} within ${a/1e3} seconds`))},a);r.pending.set(i,{resolve:t=>{window.clearTimeout(o),e(t)},reject:e=>{window.clearTimeout(o),n(e)}})})}function Ri(e,t,n,r){let i=P.get(e);i!==void 0&&i.socket!==null&&i.connected&&i.socket.send(Fr(t,n,r))}async function zi(e){let t=P.get(e);return t!==void 0&&(t.ping??=Gi(e,t).finally(()=>{t.ping=null}),await t.ping)}async function Bi(e,t,n){let r=t.urls[n%t.urls.length];t.url=r,Oi.debug(`connecting to ${r}, attempt ${n+1}`);let i=await Vi(e,r).catch(e=>{Oi.warn(`could not get a ticket from ${r}:`,e)});if(P.get(e)!==t)return;if(i===`unpaired`){Oi.warn(`${r} says this browser is not paired`);for(let t of ki)t.unpaired?.(e);return}if(i===void 0){Hi(e,t,n);return}let a=i===null?``:`?${new URLSearchParams({ticket:i})}`,o=new WebSocket(`${r.replace(/^http/,`ws`)}/ws${a}`);o.binaryType=`arraybuffer`;let s=window.setTimeout(()=>o.close(),wi);o.onopen=()=>{if(window.clearTimeout(s),t.socket!==o)o.close();else{t.connected=!0,t.failures=0,Oi.info(`connected to ${r}`);for(let t of ki)t.open?.(e,r)}},o.onmessage=n=>{t.socket===o&&Ki(e,t,n.data)},o.onclose=i=>{window.clearTimeout(s),t.socket===o&&(Oi.info(`the connection to ${r} closed (code ${i.code})`),t.connected?(Wi(e,t),Ui(e,t,0)):Hi(e,t,n))},t.socket=o}async function Vi(e,t){let n=await ii(e),r=await fetch(`${t}/api/ticket`,{method:`POST`,headers:n===void 0?{}:{authorization:`Bearer ${n}`},signal:AbortSignal.timeout(wi)});if(r.status===401)return`unpaired`;if(!r.ok)throw Error(await r.text());return(await r.json()).ticket}function Hi(e,t,n){if((n+1)%t.urls.length!==0)Bi(e,t,n+1);else{for(let t of ki)t.close?.(e);Ui(e,t,n+1)}}function Ui(e,t,n){let r=Math.min(xi,bi*2**t.failures)*(.8+Math.random()*.4);t.failures+=1,Oi.debug(`reconnecting to ${new URL(t.url).host} in ${Math.round(r/1e3)}s`),t.timer=window.setTimeout(()=>{t.timer=void 0,Bi(e,t,n)},r)}function Wi(e,t){for(let e of t.pending.values())e.reject(Error(`Disconnected from ${new URL(t.url).host}`));t.pending.clear(),t.connected=!1;for(let t of ki)t.close?.(e)}async function Gi(e,t){let n=t.socket;if(n===null||!t.connected)return!1;let r=await Promise.race([F(e,`ping`,void 0).then(()=>!0,()=>!1),new Promise(e=>window.setTimeout(()=>e(!1),Ci))]);return r||t.socket!==n||!t.connected?r:(Oi.warn(`${t.url} did not answer a ping, reconnecting`),n.onclose=null,n.close(),Wi(e,t),P.get(e)===t&&Ui(e,t,0),!1)}function Ki(e,t,n){if(n instanceof ArrayBuffer){let t=Ir(new Uint8Array(n));for(let n of ki)n.frame?.(e,t);return}let r=JSON.parse(String(n));if(r.type===`reply`)qi(t,r);else if(r.type===`terminal`)for(let t of ki)t.terminal?.(e,r.event);else for(let t of ki)t.event?.(e,r)}function qi(e,t){let n=e.pending.get(t.id);n!==void 0&&(e.pending.delete(t.id),`error`in t?n.reject(Error(t.error)):n.resolve(t.result))}var Ji=`claude`,Yi=`bypassPermissions`,Xi=`full-access`;function Zi(e,t){if(e.length===0)return;let n=e[0],r=-1/0;for(let i=0;i<e.length;i++){let a=e[i],o=t(a,i,e);if(Number.isNaN(o))return a;o>r&&(r=o,n=a)}return n}function Qi(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}var $i=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},ea=(e=>e?$i(e):$i),ta=e=>e;function na(e,t=ta){let n=j.useSyncExternalStore(e.subscribe,j.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return j.useDebugValue(n),n}var ra=e=>{let t=ea(e),n=e=>na(t,e);return Object.assign(n,t),n},ia=(e=>e?ra(e):ra);function aa(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var oa=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return oa(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return oa(t)(e)}}}},sa=(e,t)=>(n,r,i)=>{let a={storage:aa(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(...e)=>(f(...e),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return oa(u.getItem.bind(u))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},ca=`composerDrafts`,la={text:``,images:[],files:[],settings:null},ua=Zr(`offsite-drafts`,`drafts`),da=Zr(`offsite-draft-files`,`files`),fa=Qi(e=>void ti(ca,e,ua),300),pa={getItem:async e=>await ei(e,ua)??null,setItem:(e,t)=>fa(t),removeItem:e=>ni(e,ua)},ma={drafts:{},stash:[]},I=ia()(sa(()=>ma,{name:ca,storage:pa,skipHydration:!0,version:1,migrate:()=>ma}));window.addEventListener(`pagehide`,fa.flush);function ha(){return I.persist.rehydrate()}function ga(e){return I(t=>t.drafts[e]??la)}function _a(e,t){let n=xa(e),r=t(n),i=I.getState().stash;for(let e of n.files)!r.files.some(t=>t.id===e.id)&&!i.some(t=>t.files.some(t=>t.id===e.id))&&ni(e.id,da);I.setState(t=>{let n={...t.drafts,[e]:r};return r.text===``&&r.images.length===0&&r.files.length===0&&r.settings===null&&delete n[e],{drafts:n}})}async function va(e){let t=crypto.randomUUID();return await ti(t,e,da),t}async function ya(e){return await ei(e,da)}function ba(e){_a(e,()=>la)}function xa(e){return I.getState().drafts[e]??la}function Sa(e){return I.getState().drafts[e]?.settings??null}function Ca(e,t){_a(e,e=>({...e,settings:t}))}function wa(){return I(e=>e.stash)}function Ta(){return I.getState().stash}function Ea(e){return e.text.trim()!==``||e.images.length>0||e.files.length>0}function Da(e){let t=xa(e);I.setState(e=>({stash:[{id:crypto.randomUUID(),createdAt:Date.now(),text:t.text,images:t.images,files:t.files},...e.stash]})),_a(e,e=>({...e,text:``,images:[],files:[]}))}function Oa(e,t,n){let r=I.getState().stash.find(e=>e.id===t);if(r===void 0)throw Error(`This stashed prompt no longer exists`);Ea(xa(e))&&Da(e),I.setState(e=>({stash:e.stash.filter(e=>e.id!==t)}));let i=r.text.replace(/\[Image #(\d+)\]/g,(e,t)=>{let i=r.images.findIndex(e=>e.number===Number(t));return i===-1?e:`[Image #${n+i+1}]`});return _a(e,e=>({...e,text:i,images:r.images.map((e,t)=>({...e,number:n+t+1})),files:r.files})),i}function ka(e){let t=I.getState().stash.find(t=>t.id===e);if(t!==void 0){I.setState(t=>({stash:t.stash.filter(t=>t.id!==e)}));for(let e of t.files)ni(e.id,da)}}function Aa(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ja(e,t=`|`){return e.map(e=>to(e)).join(t)}function Ma(e,t){return typeof t==`bigint`?t.toString():t}var Na=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Pa(e){return new Na(e)}function Fa(e){return e==null}function Ia(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function La(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Ra(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function za(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ba(e){return za(e._zod.def)??e._zod.def.shape}function Va(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ra(this,t,e),e},enumerable:!0,configurable:!0})}function Ha(e,t,n){t in e?Ra(e,t,n):e[t]=n}function Ua(e,t,n,r){let i=Ba(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Va(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ha(e,a,r?r(n.value,a):n.value))}}function Wa(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Va(e,n,()=>t[n]):Ha(e,n,r.value))}}function L(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ga(e){return JSON.stringify(e)}function Ka(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var qa=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ja(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ya=Pa(()=>{if(Go.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Xa(e){if(Ja(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ja(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Za(e){return Xa(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Qa=new Set([`string`,`number`,`symbol`]);function $a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function eo(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function R(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function to(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function no(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var ro={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},io={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ao(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Ua(i,e,oo(e,t)),eo(e,L(n,{shape:i,checks:[]}))}function oo(e,t){let n=Ba(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function so(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(oo(e,t)),a={};return Ua(a,e,Reflect.ownKeys(Ba(e)).filter(e=>!i.has(e))),eo(e,L(n,{shape:a,checks:[]}))}function co(e,t){if(!Xa(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ba(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eo(e,L(e._zod.def,{shape:lo(e,t)}))}function lo(e,t){let n={};return Ua(n,e,Reflect.ownKeys(Ba(e))),Wa(n,t),n}function uo(e,t){if(!Xa(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return eo(e,L(e._zod.def,{shape:lo(e,t)}))}function fo(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Ua(n,e,Reflect.ownKeys(Ba(e))),Ua(n,t,Reflect.ownKeys(Ba(t))),eo(e,L(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function po(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(oo(t,n)):void 0,o={};return Ua(o,t,Reflect.ownKeys(Ba(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),eo(t,L(t._zod.def,{shape:o,checks:[]}))}function mo(e,t,n){let r=n?new Set(oo(t,n)):void 0,i={};return Ua(i,t,Reflect.ownKeys(Ba(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),eo(t,L(t._zod.def,{shape:i}))}function ho(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function go(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function _o(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function vo(e){return typeof e==`string`?e:e?.message}function yo(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function bo(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function xo(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:vo(e.inst?._zod.def?.error?.(e))??vo(a?.(e))??vo(t?.error?.(e))??vo(n.customError?.(e))??vo(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var So=/[\uD800-\uDBFF]/;function Co(e){let t=e.length;if(!So.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function wo(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function To(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Eo(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Do(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):jo(e,n,r.value)}}function Oo(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ko(e,t,n){return Oo(e,t,n,!1)}function Ao(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Oo(this,n,r(this))},set(e){Oo(this,n,e)}})}return t}function jo(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Oo(this,t,n.bind(this))},set(e){Oo(this,t,e)}})}function Mo(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var No,Po=!1,Fo={configurable:!0,get(){Po=!0}};function z(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&No!==e._zod?No=void 0:(No=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Fo);let e=Po;Po=!1;try{let r=n(this);return Po?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Po||=e,r}catch(n){throw delete this[t],Po||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Io(e,t,n,r){let i=Mo(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Lo=`~constantCatch`;function Ro(e){let t=()=>e;return t[Lo]=!0,t}var zo,Bo={value:void 0,enumerable:!1},Vo=`captureStackTrace`in Error?Error:null;function Ho(e){let t=Vo;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Vo=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function B(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Bo.value=new a(r);try{Object.defineProperty(n,"_zod",Bo)}finally{Bo.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Do(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ho(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Uo=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Wo=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(zo=globalThis).__zod_globalConfig??(zo.__zod_globalConfig={});var Go=globalThis.__zod_globalConfig;function Ko(e){return e&&Object.assign(Go,e),Go}function qo(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ma,2),e.message}function Jo(e){this._zod.message=e}var Yo={get:qo,set:Jo,enumerable:!0,configurable:!0},Xo={value:void 0,enumerable:!1},Zo=new WeakSet([Object.prototype,Error.prototype]),Qo=B(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Xo.value=t,Object.defineProperty(e,"issues",Xo),Xo.value=void 0,Object.defineProperty(e,"message",Yo);let n=Object.getPrototypeOf(e);Zo.has(n)||(Zo.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function $o(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function es(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?$o(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ts(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function ns(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function rs(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${ns(e.path)}`);return t.join(`
12
+ `);try{return JSON.stringify(e)??String(e)}catch{return String(e)}}var bi=1e3,xi=3e4,Si=1e4,Ci=1e4,wi=3e3,Ti=3e4,Ei=3e5,Di=[`sessions.send`,`sessions.rewind`,`sessions.fork`,`git.commit`,`git.push`,`git.pullRequest`,`git.createPullRequest`,`dictation.transcribe`],Oi=fi.withTag(`connection`),ki=new Set,P=new Map,Ai=0;function ji(){window.setInterval(()=>{for(let e of P.keys())zi(e)},Si),document.addEventListener(`visibilitychange`,()=>{document.hidden||Mi()}),window.addEventListener(`online`,Mi)}function Mi(){for(let[e,t]of P)t.connected?zi(e):t.timer!==void 0&&(window.clearTimeout(t.timer),t.timer=void 0,t.failures=0,Bi(e,t,0))}function Ni(e,t){if(P.has(e))return;let n={urls:t,url:t[0],socket:null,connected:!1,ping:null,timer:void 0,failures:0,pending:new Map};P.set(e,n),Bi(e,n,0)}function Pi(e){let t=P.get(e);t!==void 0&&(P.delete(e),window.clearTimeout(t.timer),t.socket!==null&&(t.socket.onclose=null,t.socket.close()),Wi(e,t))}function Fi(e){ki.add(e)}function Ii(e){return P.get(e)?.connected===!0}function Li(e){let t=P.get(e);if(t===void 0)throw Error(`This machine is not connected`);return t.url}function F(e,t,n){let r=P.get(e);if(r===void 0||r.socket===null||!r.connected)return Promise.reject(Error(r===void 0?`That machine was removed`:`Not connected to ${new URL(r.url).host}; reconnecting`));Ai+=1;let i=Ai;r.socket.send(JSON.stringify({id:i,method:t,params:n}));let a=Di.includes(t)?Ei:Ti;return new Promise((e,n)=>{let o=window.setTimeout(()=>{r.pending.delete(i),n(Error(`${new URL(r.url).host} did not answer ${t} within ${a/1e3} seconds`))},a);r.pending.set(i,{resolve:t=>{window.clearTimeout(o),e(t)},reject:e=>{window.clearTimeout(o),n(e)}})})}function Ri(e,t,n,r){let i=P.get(e);i!==void 0&&i.socket!==null&&i.connected&&i.socket.send(Fr(t,n,r))}async function zi(e){let t=P.get(e);return t!==void 0&&(t.ping??=Gi(e,t).finally(()=>{t.ping=null}),await t.ping)}async function Bi(e,t,n){let r=t.urls[n%t.urls.length];t.url=r,Oi.debug(`connecting to ${r}, attempt ${n+1}`);let i=await Vi(e,r).catch(e=>{Oi.warn(`could not get a ticket from ${r}:`,e)});if(P.get(e)!==t)return;if(i===`unpaired`){Oi.warn(`${r} says this browser is not paired`);for(let t of ki)t.unpaired?.(e);return}if(i===void 0){Hi(e,t,n);return}let a=i===null?``:`?${new URLSearchParams({ticket:i})}`,o=new WebSocket(`${r.replace(/^http/,`ws`)}/ws${a}`);o.binaryType=`arraybuffer`;let s=window.setTimeout(()=>o.close(),wi);o.onopen=()=>{if(window.clearTimeout(s),t.socket!==o)o.close();else{t.connected=!0,t.failures=0,Oi.info(`connected to ${r}`);for(let t of ki)t.open?.(e,r)}},o.onmessage=n=>{t.socket===o&&Ki(e,t,n.data)},o.onclose=i=>{window.clearTimeout(s),t.socket===o&&(Oi.info(`the connection to ${r} closed (code ${i.code})`),t.connected?(Wi(e,t),Ui(e,t,0)):Hi(e,t,n))},t.socket=o}async function Vi(e,t){let n=await ii(e),r=await fetch(`${t}/api/ticket`,{method:`POST`,headers:n===void 0?{}:{authorization:`Bearer ${n}`},signal:AbortSignal.timeout(wi)});if(r.status===401)return`unpaired`;if(!r.ok)throw Error(await r.text());return(await r.json()).ticket}function Hi(e,t,n){if((n+1)%t.urls.length!==0)Bi(e,t,n+1);else{for(let t of ki)t.close?.(e);Ui(e,t,n+1)}}function Ui(e,t,n){let r=Math.min(xi,bi*2**t.failures)*(.8+Math.random()*.4);t.failures+=1,Oi.debug(`reconnecting to ${new URL(t.url).host} in ${Math.round(r/1e3)}s`),t.timer=window.setTimeout(()=>{t.timer=void 0,Bi(e,t,n)},r)}function Wi(e,t){for(let e of t.pending.values())e.reject(Error(`Disconnected from ${new URL(t.url).host}`));t.pending.clear(),t.connected=!1;for(let t of ki)t.close?.(e)}async function Gi(e,t){let n=t.socket;if(n===null||!t.connected)return!1;let r=await Promise.race([F(e,`ping`,void 0).then(()=>!0,()=>!1),new Promise(e=>window.setTimeout(()=>e(!1),Ci))]);return r||t.socket!==n||!t.connected?r:(Oi.warn(`${t.url} did not answer a ping, reconnecting`),n.onclose=null,n.close(),Wi(e,t),P.get(e)===t&&Ui(e,t,0),!1)}function Ki(e,t,n){if(n instanceof ArrayBuffer){let t=Ir(new Uint8Array(n));for(let n of ki)n.frame?.(e,t);return}let r=JSON.parse(String(n));if(r.type===`reply`)qi(t,r);else if(r.type===`terminal`)for(let t of ki)t.terminal?.(e,r.event);else for(let t of ki)t.event?.(e,r)}function qi(e,t){let n=e.pending.get(t.id);n!==void 0&&(e.pending.delete(t.id),`error`in t?n.reject(Error(t.error)):n.resolve(t.result))}var Ji=`claude`,Yi=`bypassPermissions`,Xi=`full-access`;function Zi(e,t){if(e.length===0)return;let n=e[0],r=-1/0;for(let i=0;i<e.length;i++){let a=e[i],o=t(a,i,e);if(Number.isNaN(o))return a;o>r&&(r=o,n=a)}return n}function Qi(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}var $i=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},ea=(e=>e?$i(e):$i),ta=e=>e;function na(e,t=ta){let n=j.useSyncExternalStore(e.subscribe,j.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return j.useDebugValue(n),n}var ra=e=>{let t=ea(e),n=e=>na(t,e);return Object.assign(n,t),n},ia=(e=>e?ra(e):ra);function aa(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var oa=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return oa(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return oa(t)(e)}}}},sa=(e,t)=>(n,r,i)=>{let a={storage:aa(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(...e)=>(f(...e),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return oa(u.getItem.bind(u))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},ca=`composerDrafts`,la={text:``,images:[],files:[],settings:null},ua=Zr(`offsite-drafts`,`drafts`),da=Zr(`offsite-draft-files`,`files`),fa=Qi(e=>void ti(ca,e,ua),300),pa={getItem:async e=>await ei(e,ua)??null,setItem:(e,t)=>fa(t),removeItem:e=>ni(e,ua)},ma={drafts:{},stash:[]},I=ia()(sa(()=>ma,{name:ca,storage:pa,skipHydration:!0,version:1,migrate:()=>ma}));window.addEventListener(`pagehide`,fa.flush);function ha(){return I.persist.rehydrate()}function ga(e){return I(t=>t.drafts[e]??la)}function _a(e,t){let n=xa(e),r=t(n),i=I.getState().stash;for(let e of n.files)!r.files.some(t=>t.id===e.id)&&!i.some(t=>t.files.some(t=>t.id===e.id))&&ni(e.id,da);I.setState(t=>{let n={...t.drafts,[e]:r};return r.text===``&&r.images.length===0&&r.files.length===0&&r.settings===null&&delete n[e],{drafts:n}})}async function va(e){let t=crypto.randomUUID();return await ti(t,e,da),t}async function ya(e){return await ei(e,da)}function ba(e){_a(e,()=>la)}function xa(e){return I.getState().drafts[e]??la}function Sa(e){return I.getState().drafts[e]?.settings??null}function Ca(e,t){_a(e,e=>({...e,settings:t}))}function wa(){return I(e=>e.stash)}function Ta(){return I.getState().stash}function Ea(e){return e.text.trim()!==``||e.images.length>0||e.files.length>0}function Da(e){let t=xa(e);I.setState(e=>({stash:[{id:crypto.randomUUID(),createdAt:Date.now(),text:t.text,images:t.images,files:t.files},...e.stash]})),_a(e,e=>({...e,text:``,images:[],files:[]}))}function Oa(e,t,n){let r=I.getState().stash.find(e=>e.id===t);if(r===void 0)throw Error(`This stashed prompt no longer exists`);Ea(xa(e))&&Da(e),I.setState(e=>({stash:e.stash.filter(e=>e.id!==t)}));let i=r.text.replace(/\[Image #(\d+)\]/g,(e,t)=>{let i=r.images.findIndex(e=>e.number===Number(t));return i===-1?e:`[Image #${n+i+1}]`});return _a(e,e=>({...e,text:i,images:r.images.map((e,t)=>({...e,number:n+t+1})),files:r.files})),i}function ka(e){let t=I.getState().stash.find(t=>t.id===e);if(t!==void 0){I.setState(t=>({stash:t.stash.filter(t=>t.id!==e)}));for(let e of t.files)ni(e.id,da)}}function Aa(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ja(e,t=`|`){return e.map(e=>to(e)).join(t)}function Ma(e,t){return typeof t==`bigint`?t.toString():t}var Na=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Pa(e){return new Na(e)}function Fa(e){return e==null}function Ia(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function La(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Ra(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function za(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ba(e){return za(e._zod.def)??e._zod.def.shape}function Va(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ra(this,t,e),e},enumerable:!0,configurable:!0})}function Ha(e,t,n){t in e?Ra(e,t,n):e[t]=n}function Ua(e,t,n,r){let i=Ba(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Va(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ha(e,a,r?r(n.value,a):n.value))}}function Wa(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Va(e,n,()=>t[n]):Ha(e,n,r.value))}}function L(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ga(e){return JSON.stringify(e)}function Ka(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var qa=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ja(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ya=Pa(()=>{if(Go.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Xa(e){if(Ja(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ja(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Za(e){return Xa(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Qa=new Set([`string`,`number`,`symbol`]);function $a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function eo(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function R(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function to(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function no(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var ro={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},io={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ao(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Ua(i,e,oo(e,t)),eo(e,L(n,{shape:i,checks:[]}))}function oo(e,t){let n=Ba(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function so(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(oo(e,t)),a={};return Ua(a,e,Reflect.ownKeys(Ba(e)).filter(e=>!i.has(e))),eo(e,L(n,{shape:a,checks:[]}))}function co(e,t){if(!Xa(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ba(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eo(e,L(e._zod.def,{shape:lo(e,t)}))}function lo(e,t){let n={};return Ua(n,e,Reflect.ownKeys(Ba(e))),Wa(n,t),n}function uo(e,t){if(!Xa(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return eo(e,L(e._zod.def,{shape:lo(e,t)}))}function fo(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Ua(n,e,Reflect.ownKeys(Ba(e))),Ua(n,t,Reflect.ownKeys(Ba(t))),eo(e,L(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function po(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(oo(t,n)):void 0,o={};return Ua(o,t,Reflect.ownKeys(Ba(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),eo(t,L(t._zod.def,{shape:o,checks:[]}))}function mo(e,t,n){let r=n?new Set(oo(t,n)):void 0,i={};return Ua(i,t,Reflect.ownKeys(Ba(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),eo(t,L(t._zod.def,{shape:i}))}function ho(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function go(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function _o(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function vo(e){return typeof e==`string`?e:e?.message}function yo(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function bo(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function xo(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:vo(e.inst?._zod.def?.error?.(e))??vo(a?.(e))??vo(t?.error?.(e))??vo(n.customError?.(e))??vo(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var So=/[\uD800-\uDBFF]/;function Co(e){let t=e.length;if(!So.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function wo(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function To(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Eo(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Do(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):jo(e,n,r.value)}}function Oo(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ko(e,t,n){return Oo(e,t,n,!1)}function Ao(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Oo(this,n,r(this))},set(e){Oo(this,n,e)}})}return t}function jo(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Oo(this,t,n.bind(this))},set(e){Oo(this,t,e)}})}function Mo(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var No,Po=!1,Fo={configurable:!0,get(){Po=!0}};function z(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&No!==e._zod?No=void 0:(No=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Fo);let e=Po;Po=!1;try{let r=n(this);return Po?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Po||=e,r}catch(n){throw delete this[t],Po||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Io(e,t,n,r){let i=Mo(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Lo=`~constantCatch`;function Ro(e){let t=()=>e;return t[Lo]=!0,t}var zo,Bo={value:void 0,enumerable:!1},Vo=`captureStackTrace`in Error?Error:null;function Ho(e){let t=Vo;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Vo=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function B(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Bo.value=new a(r);try{Object.defineProperty(n,"_zod",Bo)}finally{Bo.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Do(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ho(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Uo=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Wo=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(zo=globalThis).__zod_globalConfig??(zo.__zod_globalConfig={});var Go=globalThis.__zod_globalConfig;function Ko(e){return e&&Object.assign(Go,e),Go}function qo(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ma,2),e.message}function Jo(e){this._zod.message=e}var Yo={get:qo,set:Jo,enumerable:!0,configurable:!0},Xo={value:void 0,enumerable:!1},Zo=new WeakSet([Object.prototype,Error.prototype]),Qo=B(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Xo.value=t,Object.defineProperty(e,"issues",Xo),Xo.value=void 0,Object.defineProperty(e,"message",Yo);let n=Object.getPrototypeOf(e);Zo.has(n)||(Zo.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function $o(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function es(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?$o(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ts(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function ns(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function rs(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${ns(e.path)}`);return t.join(`
13
13
  `)}function is(e,t){return{callee:t?.callee??e,Err:t?.Err}}var as=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Uo;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xo(e,o,Ko())));throw qa(n,a?.callee??t),n}return s.value};return t},os=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xo(e,o,Ko())));throw qa(n,a?.callee??t),n}return s.value};return t},ss=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Uo;return a.issues.length?cs(e,a.issues,i):{success:!0,data:a.value}};function cs(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>xo(e,n,Ko()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var ls=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?cs(e,a.issues,i):{success:!0,data:a.value}},us=Symbol.for(`zod.compile.invalid`),ds=Symbol.for(`zod.compile.fallback`),fs=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==us)return!0;if(r.definite===!0&&n===void 0)return!1}return ps(e,t,n)});function ps(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[ds]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Uo;return a.issues.length===0}var ms=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},hs=e=>{let t=as(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,is(n,a))};return n},gs=e=>{let t=as(e),n=(e,r,i,a)=>t(e,r,i,is(n,a));return n},_s=e=>{let t=os(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,is(n,a))};return n},vs=e=>{let t=os(e),n=async(e,r,i,a)=>await t(e,r,i,is(n,a));return n},ys=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ss(e)(t,n,i)},bs=e=>(t,n,r)=>ss(e)(t,n,r),xs=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ls(e)(t,n,i)},Ss=e=>async(t,n,r)=>ls(e)(t,n,r),Cs=/^[cC][0-9a-z]{6,}$/,ws=/^[0-9a-z]+$/,Ts=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Es=/^[0-9a-vA-V]{20}$/,Ds=/^[A-Za-z0-9]{27}$/,Os=/^[a-zA-Z0-9_-]{21}$/;function ks(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var As=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,js=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ms=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ns=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ps=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Fs(){return new RegExp(Ps,`u`)}var Is=/^(?:(?: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])$/,Ls=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,Rs=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,zs=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bs=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vs=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Hs=/^https?$/,Us=/^\+[1-9]\d{6,14}$/,Ws=`(?:(?:\\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])))`;function Gs(e){return RegExp(`^${e}$`)}var Ks=Gs(Ws);function qs(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Js(e){return RegExp(`^${qs(e)}$`)}function Ys(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${qs({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${qs({precision:e.precision})}`:n;return RegExp(`^${Ws}T(?:${r})$`)}var Xs=/^[\s\S]{0,}$/,Zs=/^-?\d+(?:\.\d+)?$/,Qs=/^(?:true|false)$/i,$s=/^[^A-Z]*$/,ec=/^[^a-z]*$/,V=B(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),tc=e=>{let t=e.value;return!Fa(t)&&t.length!==void 0},nc={number:`number`,bigint:`bigint`,object:`date`},rc=B(`$ZodCheckLessThan`,(e,t)=>{V.init(e,t);let n=nc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:nc[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ic=B(`$ZodCheckGreaterThan`,(e,t)=>{V.init(e,t);let n=nc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:nc[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ac=B(`$ZodCheckMultipleOf`,(e,t)=>{V.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):La(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),oc=B(`$ZodCheckNumberFormat`,(e,t)=>{V.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ro[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),sc=B(`$ZodCheckMaxLength`,(e,t)=>{var n;V.init(e,t),(n=e._zod.def).when??(n.when=tc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Co(r):i)<=t.maximum)return;let a=wo(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),cc=B(`$ZodCheckMinLength`,(e,t)=>{var n;V.init(e,t),(n=e._zod.def).when??(n.when=tc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Co(r):i)>=t.minimum)return;let a=wo(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lc=B(`$ZodCheckLengthEquals`,(e,t)=>{var n;V.init(e,t),(n=e._zod.def).when??(n.when=tc),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Co(r):i;if(a===t.length)return;let o=wo(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),uc=B(`$ZodCheckStringFormat`,(e,t)=>{var n,r;V.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),dc=B(`$ZodCheckRegex`,(e,t)=>{uc.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),fc=B(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=$s,uc.init(e,t)}),pc=B(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ec,uc.init(e,t)}),mc=B(`$ZodCheckIncludes`,(e,t)=>{V.init(e,t);let n=$a(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),hc=B(`$ZodCheckStartsWith`,(e,t)=>{V.init(e,t);let n=RegExp(`^${$a(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),gc=B(`$ZodCheckEndsWith`,(e,t)=>{V.init(e,t);let n=RegExp(`.*${$a(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),_c=B(`$ZodCheckOverwrite`,(e,t)=>{V.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),vc=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
14
14
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
15
15
  `)}\n};`)(...Object.values(this.closed))}},yc={major:4,minor:6,patch:7},H=B(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yc;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=ho(t),a;for(let o of n){if(o._zod.def.when){if(go(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Uo;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(bo(t.issues,n,e),i||=ho(t,n))});else{if(t.issues.length===n)continue;bo(t.issues,n,e),i||=ho(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ho(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Uo;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Uo;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return ko(this,`~standard`,Sc(this))},set"~standard"(e){Oo(this,`~standard`,e)}}),bc=(e,t)=>e.issues.length?{issues:e.issues.map(e=>xo(e,t,Ko()))}:{value:e.value};async function xc(e,t){let n={async:!0};return bc(await e._zod.run({value:t,issues:[]},n),n)}function Sc(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return bc(r,n)}catch{}return xc(e,t)},vendor:`zod`,version:1}}var Cc=B(`$ZodString`,(e,t)=>{H.init(e,t),e._zod.pattern=t.pattern??Xs,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),U=B(`$ZodStringFormat`,(e,t)=>{uc.init(e,t),Cc.init(e,t)}),wc=B(`$ZodGUID`,(e,t)=>{t.pattern??=js,U.init(e,t)}),Tc=B(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ms(e)}else t.pattern??=Ms();U.init(e,t)}),Ec=B(`$ZodEmail`,(e,t)=>{t.pattern??=Ns,U.init(e,t)});function Dc(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Oc(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Dc(e)||2:kc(e,t)}function kc(e,t){if(!t.normalize&&t.protocol?.source===Hs.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Ac=/[\t\n\r]/g;function jc(e){return e.replace(Ac,``)}function Mc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Nc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Pc=B(`$ZodURL`,(e,t)=>{U.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Oc(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=jc(r);return}t.hostname&&!Mc(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Nc(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:jc(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Fc=B(`$ZodEmoji`,(e,t)=>{t.pattern??=Fs(),U.init(e,t)}),Ic=B(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Os:ks(t.length),U.init(e,t)}),Lc=B(`$ZodCUID`,(e,t)=>{t.pattern??=Cs,U.init(e,t)}),Rc=B(`$ZodCUID2`,(e,t)=>{t.pattern??=ws,U.init(e,t)}),zc=B(`$ZodULID`,(e,t)=>{t.pattern??=Ts,U.init(e,t)}),Bc=B(`$ZodXID`,(e,t)=>{t.pattern??=Es,U.init(e,t)}),Vc=B(`$ZodKSUID`,(e,t)=>{t.pattern??=Ds,U.init(e,t)}),Hc=B(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ys(t),U.init(e,t)}),Uc=B(`$ZodISODate`,(e,t)=>{t.pattern??=Ks,U.init(e,t)}),Wc=B(`$ZodISOTime`,(e,t)=>{t.pattern??=Js(t),U.init(e,t)}),Gc=B(`$ZodISODuration`,(e,t)=>{t.pattern??=As,U.init(e,t)}),Kc=B(`$ZodIPv4`,(e,t)=>{t.pattern??=Is,U.init(e,t)}),qc=/^[0-9a-fA-F:.]+$/;function Jc(e){return qc.test(e)?Dc(`http://[${e}]`):!1}var Yc=B(`$ZodIPv6`,(e,t)=>{t.pattern??=Ls,U.init(e,t),e._zod.check=n=>{Jc(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Xc=B(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Rs,U.init(e,t)});function Zc(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Jc(n)}var Qc=B(`$ZodCIDRv6`,(e,t)=>{t.pattern??=zs,U.init(e,t),e._zod.check=n=>{Zc(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function $c(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var el=/^[0-9a-zA-Z+/]*={0,2}$/,tl=B(`$ZodBase64`,(e,t)=>{t.pattern??=el,U.init(e,t),e._zod.check=n=>{$c(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),nl=/^[A-Za-z0-9_-]*$/;function rl(e){if(!nl.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return $c(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var il=B(`$ZodBase64URL`,(e,t)=>{t.pattern??=nl,U.init(e,t),e._zod.check=n=>{rl(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),al=B(`$ZodE164`,(e,t)=>{t.pattern??=Us,U.init(e,t)});function ol(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var sl=B(`$ZodJWT`,(e,t)=>{U.init(e,t),e._zod.check=n=>{ol(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),cl=B(`$ZodNumber`,(e,t)=>{H.init(e,t),e._zod.pattern=Zs,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ll=B(`$ZodNumberFormat`,(e,t)=>{oc.init(e,t),cl.init(e,t)}),ul=B(`$ZodBoolean`,(e,t)=>{H.init(e,t),e._zod.pattern=Qs,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),dl=B(`$ZodUnknown`,(e,t)=>{H.init(e,t),e._zod.parse=e=>e}),fl=B(`$ZodNever`,(e,t)=>{H.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function pl(e,t){let n=yo(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of yo(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,bo(n.issues,t,e),n}}return i(n,a)}}var ml=e=>Array.isArray(e)?e.length:-1;function hl(e,t,n){e.issues.length&&t.issues.push(..._o(n,e.issues)),t.value[n]=e.value}var gl=B(`$ZodArray`,(e,t)=>{H.init(e,t);let n=Go.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>hl(t,r,e)));else if(hl(c,r,e),s&&c.issues.length!==0&&ho(c))break}return o.length?Promise.all(o).then(()=>r):r},pl(e,ml)});function _l(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(..._o(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var vl=[];function yl(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:vl,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=no(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function bl(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(ho(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>_l(e,n,i,t,d,f))):_l(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var xl=B(`$ZodObject`,(e,t)=>{H.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Pa(()=>yl(t));z(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Ra(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Ja,o=t.catchall,s,c=Go.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(ho(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>_l(n,t,e,r,a,o))):_l(s,t,e,r,a,o)}return o?bl(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Sl=B(`$ZodObjectJIT`,(e,t)=>{xl.init(e,t);let n=e._zod.parse,r=Pa(()=>yl(t)),i=Go.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new vc([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
@@ -64,4 +64,4 @@ import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{c as n,l as r,r as i
64
64
 
65
65
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ja,c=!Go.jitless,l=c&&Ya.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?bl([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Cl(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ho(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>xo(e,r,Ko())))}),t)}var wl=B(`$ZodUnion`,(e,t)=>{H.init(e,t),z(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),z(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),z(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),z(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Ia(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Cl(t,r,e,i)):Cl(o,r,e,i)}});function Tl(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var El=B(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,wl.init(e,t);let n=e._zod.parse;z(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Ra(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=za(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Pa(()=>Tl(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Ja(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Dl=B(`$ZodIntersection`,(e,t)=>{H.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>kl(e,t,n)):kl(e,i,a)}});function Ol(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Xa(e)&&Xa(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ol(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ol(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function kl(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ol(t.value,n.value);if(!c.valid){if(ho(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Al=B(`$ZodEnum`,(e,t)=>{H.init(e,t);let n=Aa(t.entries),r=new Set(n);e._zod.values=r,z(e,`pattern`,e=>{let t=Aa(e.def.entries).filter(e=>Qa.has(typeof e));return RegExp(t.length?`^(${t.map(e=>$a(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),jl=B(`$ZodLiteral`,(e,t)=>{H.init(e,t);let n=new Set(t.values);e._zod.values=n,z(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?$a(e):e?$a(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Ml=B(`$ZodTransform`,(e,t)=>{H.init(e,t),e._zod.optin=`optional`,Go.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Wo(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Uo;return n.value=i,n}});function Nl(e,t){return e.value=t.issues.length?void 0:t.value,e}var Pl=B(`$ZodOptional`,(e,t)=>{H.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,z(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),z(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ia(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Nl(e,t)):Nl(e,r)}return t.innerType._zod.run(e,n)}}),Fl=B(`$ZodExactOptional`,(e,t)=>{Pl.init(e,t),z(e,`values`,e=>e.def.innerType._zod.values),z(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Il=B(`$ZodNullable`,(e,t)=>{H.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin),z(e,`optout`,e=>e.def.innerType._zod.optout),z(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ia(t.source)}|null)$`):void 0}),z(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ll=B(`$ZodDefault`,(e,t)=>{H.init(e,t),e._zod.optin=`defaulted`,z(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Rl(e,t)):Rl(r,t)}});function Rl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var zl=B(`$ZodPrefault`,(e,t)=>{H.init(e,t),e._zod.optin=`defaulted`,z(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Bl=B(`$ZodNonOptional`,(e,t)=>{H.init(e,t),z(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Vl(t,e)):Vl(i,e)}});function Vl(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Hl(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>xo(e,r,Ko()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Ul=B(`$ZodCatch`,(e,t)=>{H.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),z(e,`optout`,e=>e.def.innerType._zod.optout),z(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Hl(e,r,t,n)):Hl(e,r,t,n)}}),Wl=B(`$ZodPipe`,(e,t)=>{H.init(e,t),z(e,`values`,e=>e.def.in._zod.values),z(e,`optin`,e=>e.def.in._zod.optin),z(e,`optout`,e=>e.def.out._zod.optout),z(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Gl(e,t.in,n)):Gl(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Gl(e,t.out,n)):Gl(r,t.out,n)}});function Gl(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Kl=B(`$ZodReadonly`,(e,t)=>{H.init(e,t),z(e,`propValues`,e=>e.def.innerType._zod.propValues),z(e,`values`,e=>e.def.innerType._zod.values),z(e,`optin`,e=>e.def.innerType?._zod?.optin),z(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ql):ql(r)}});function ql(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Jl=B(`$ZodCustom`,(e,t)=>{V.init(e,t),H.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Yl(t,n,r,e));Yl(i,n,r,e)}});function Yl(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Eo(e))}}var Xl=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Zl=`~memo`,Ql=[];function $l(e){return typeof e==`object`&&!!e}function eu(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var tu=new WeakMap,nu=0,ru=1,iu=2;function au(e,t,n){let r=tu.get(e);if(r!==void 0)return r?iu:nu;if(t.has(e))return iu;t.add(e);let i=nu,a=e=>{if(i!==iu&&e?._zod){let r=au(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=nu;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?ru:o.value?._zod?au(o.value,t,n):nu;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=za(c);s(e?o(e,!0):ru),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?au(r,t,!1):ru);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),ou(e,i)}function ou(e,t){return t!==ru&&tu.set(e,t===iu),t}function su(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var cu,lu=[],uu={alloc(e,t,n){let r=cu;if(!r)return n;cu=void 0;let i={value:n,issues:null};return r.set(t.value,i),lu.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&fu(n,e.value))throw new Xl;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=au(e,new Set,!1);if(i===nu)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===iu||r?n=!0:r=!0}let l=s.value;if(!$l(l))return t(s,c);let u=c[Zl];u||(u={buckets:new WeakMap,backEdges:void 0},c[Zl]=u);let d;i===c?d=a:(d=su(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...eu(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;cu=d;let p=lu.length,m=t(s,c);cu=void 0;let h=lu.length>p?lu.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?eu(e.issues):Ql),e)):(h&&(h.issues=m.issues.length?eu(m.issues):Ql),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function du(){return uu}function fu(e,t){let n=e[Zl]?.backEdges;return n!==void 0&&$l(t)&&n.has(t)}var pu=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(To(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${to(e.values[0])}`:`Invalid option: expected one of ${ja(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${ja(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function mu(){return{localeError:pu()}}var hu,gu=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function _u(){return new gu}(hu=globalThis).__zod_globalRegistry??(hu.__zod_globalRegistry=_u());var vu=globalThis.__zod_globalRegistry;function yu(e){return e.checks&&=[...e.checks],e}function bu(e,t){return new e(yu({type:`string`,...R(t)}))}function xu(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...R(t)})}function Su(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...R(t)})}function Cu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...R(t)})}function wu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...R(t)})}function Tu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...R(t)})}function Eu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...R(t)})}function Du(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...R(t)})}function Ou(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...R(t)})}function ku(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...R(t)})}function Au(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...R(t)})}function ju(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...R(t)})}function Mu(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...R(t)})}function Nu(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...R(t)})}function Pu(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...R(t)})}function Fu(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...R(t)})}function Iu(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...R(t)})}function Lu(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...R(t)})}function Ru(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...R(t)})}function zu(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...R(t)})}function Bu(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...R(t)})}function Vu(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...R(t)})}function Hu(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...R(t)})}function Uu(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...R(t)})}function Wu(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...R(t)})}function Gu(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...R(t)})}function Ku(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...R(t)})}function qu(e,t){return new e(yu({type:`number`,checks:[],...R(t)}))}function Ju(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...R(t)})}function Yu(e,t){return new e({type:`boolean`,...R(t)})}function Xu(e){return new e({type:`unknown`})}function Zu(e,t){return new e({type:`never`,...R(t)})}function Qu(e,t){return new rc({check:`less_than`,...R(t),value:e,inclusive:!1})}function $u(e,t){return new rc({check:`less_than`,...R(t),value:e,inclusive:!0})}function ed(e,t){return new ic({check:`greater_than`,...R(t),value:e,inclusive:!1})}function td(e,t){return new ic({check:`greater_than`,...R(t),value:e,inclusive:!0})}function nd(e,t){return new ac({check:`multiple_of`,...R(t),value:e})}function rd(e,t){return new sc({check:`max_length`,...R(t),maximum:e})}function id(e,t){return new cc({check:`min_length`,...R(t),minimum:e})}function ad(e,t){return new lc({check:`length_equals`,...R(t),length:e})}function od(e,t){return new dc({check:`string_format`,format:`regex`,...R(t),pattern:e})}function sd(e){return new fc({check:`string_format`,format:`lowercase`,...R(e)})}function cd(e){return new pc({check:`string_format`,format:`uppercase`,...R(e)})}function ld(e,t){return new mc({check:`string_format`,format:`includes`,...R(t),includes:e})}function ud(e,t){return new hc({check:`string_format`,format:`starts_with`,...R(t),prefix:e})}function dd(e,t){return new gc({check:`string_format`,format:`ends_with`,...R(t),suffix:e})}function fd(e){return new _c({check:`overwrite`,tx:e})}function pd(e){return fd(t=>t.normalize(e))}function md(){return fd(e=>e.trim())}function hd(){return fd(e=>e.toLowerCase())}function gd(){return fd(e=>e.toUpperCase())}function _d(){return fd(e=>Ka(e))}function vd(e,t,n){return new e({type:`array`,element:t,...R(n)})}function yd(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...R(n)})}function bd(e,t){let n=xd(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Eo(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Eo(r))}},e(t.value,t)),t);return n}function xd(e,t){let n=new V({check:`custom`,...R(t)});return n._zod.check=e,n}function Sd(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ra(e,t,n[t]);return e}function Cd(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??vu,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function wd(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function W(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,W(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Sd(o.schema,c),t.io===`input`&&G(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Td(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ed(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Td(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Td(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
66
66
 
67
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Dd(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Dd(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Od=new Set([`type`,`properties`,`required`,`additionalProperties`]),kd=[`oneOf`,`anyOf`];function Ad(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function jd(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Od.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Ad(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ra(n,r,e.length===1?e[0]:jd(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Ad(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Md(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Od)if(t in e)return;let n=t.filter(e=>kd.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=jd(t);else{let e=n[0],i=kd.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>jd([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Sd(e,r))}function Nd(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Sd(i,s),Sd(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Dd(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Md(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Sd(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ra(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Fd(t,`input`,e.processors),output:Fd(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function G(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return G(r.element,n);if(r.type===`set`)return G(r.valueType,n);if(r.type===`lazy`)return G(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return G(r.innerType,n);if(r.type===`intersection`)return G(r.left,n)||G(r.right,n);if(r.type===`record`||r.type===`map`)return G(r.keyType,n)||G(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:G(r.in,n)||G(r.out,n);if(r.type===`object`){for(let e in r.shape)if(G(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(G(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(G(e,n))return!0;return!!(r.rest&&G(r.rest,n))}return!1}var Pd=(e,t={})=>n=>{let r=Cd({...n,processors:t});return W(e,r),Ed(r,e),Nd(r,e)},Fd=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Cd({...i??{},target:a,io:t,processors:n});return W(e,o),Ed(o,e),Nd(o,e)},Id=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ld=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rd=(e,t)=>{Id(e,`minimum`,t),Ld(e,`maximum`,t)},zd=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bd=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Vd=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hd=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ud=(e,t)=>Id(e,`minimum`,t.minimum),Wd=(e,t)=>Ld(e,`maximum`,t.maximum),Gd=e=>(t,n)=>{Hd(t,n.format);let[r,i]=e[n.format];Id(t,`minimum`,r),Ld(t,`maximum`,i)},Kd={greater_than:(e,t)=>Id(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ld(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zd(e,t.value),number_format:Gd(ro),bigint_format:Gd(io),min_length:Ud,max_length:Wd,length_equals:(e,t)=>Rd(e,t.length),min_size:Ud,max_size:Wd,size_equals:(e,t)=>Rd(e,t.size),string_format:(e,t)=>{Hd(e,t.format),t.pattern&&Bd(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Vd(e,t.mime)};function qd(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Kd[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Id(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Id(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ld(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ld(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zd(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vd(t,i.mime);for(let e of i.patterns??[])Bd(t,e);return t}var Jd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yd=new Map([[el,Bs],[nl,Vs]]),Xd=e=>Yd.get(e)??e,Zd=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qd(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jd[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Xd);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Qd=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qd(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):wd(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},$d=(e,t,n,r)=>{n.type=`boolean`},ef=(e,t,n,r)=>{n.not={}},tf=(e,t,n,r)=>{let i=e._zod.def,a=Aa(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},nf=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(wd(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(wd(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},rf=(e,t,n,r)=>{wd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},af=(e,t,n,r)=>{wd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},of=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qd(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=W(a.element,t,{...r,path:[...r.path,`items`]})};function sf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?sf(t.out):t.type===`catch`?sf(t.innerType):e._zod.optin}var cf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&wd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ra(i.properties,e,W(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?sf(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=W(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},lf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>W(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},uf=(e,t,n,r)=>{let i=e._zod.def,a=W(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=W(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},df=(e,t,n,r)=>{let i=e._zod.def,a=W(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ff=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pf=Symbol();function mf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(wd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),pf):JSON.parse(o)}var hf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n.default=o)},gf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n._prefault=o)},_f=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{wd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vf=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;W(o,t,r);let s=t.seen.get(e);s.ref=o},yf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xf=new WeakSet([Object.prototype,Error.prototype]);function Sf(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var K=B(`ZodError`,(e,t)=>{Qo.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);xf.has(n)||(xf.add(n),Sf(n,`format`,e=>t=>ts(e,t)),Sf(n,`flatten`,e=>t=>es(e,t)),Sf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ma,2)}),Sf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ma,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cf=as(K),wf=os(K),Tf=ss(K),Ef=ls(K),Df=hs(K),Of=gs(K),kf=_s(K),Af=vs(K),jf=ys(K),Mf=bs(K),Nf=xs(K),Pf=Ss(K);function Ff(){Go.localeError||Ko(mu())}function If(){Go.memoizer||Ko({memoizer:du()})}var q=B(`ZodType`,(e,t)=>(Ff(),H.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(L(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(em(e,t))},superRefine(e,t){return this.check(tm(e,t))},overwrite(e){return this.check(fd(e))},optional(){return Ip(this)},exactOptional(){return Rp(this)},nullable(){return Bp(this)},nullish(){return Ip(Bp(this))},nonoptional(e){return Kp(this,e)},array(){return yp(this)},or(e){return wp([this,e])},and(e){return Op(this,e)},transform(e){return Xp(this,Pp(e))},default(e){return Hp(this,e)},prefault(e){return Wp(this,e)},catch(e){return Jp(this,e)},pipe(e){return Xp(this,e)},readonly(){return Qp(this)},describe(e){let t=this.clone();return vu.add(t,{description:e}),t},meta(...e){if(e.length===0)return vu.get(this);let t=this.clone();return vu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ko(this,`~standard`,{...Sc(this),jsonSchema:{input:Fd(this,`input`),output:Fd(this,`output`)}})},set"~standard"(e){Oo(this,`~standard`,e)},parse:function e(t,n){return Cf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wf(this,t,n,{callee:e})},safeParse(e,t){return Tf(this,e,t)},async safeParseAsync(e,t){return Ef(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Oo(this,`spa`,e)},validate(e,t){return fs(this,e,t)},validateAsync(e,t){return ms(this,e,t)},encode:function e(t,n){return Df(this,t,n,{callee:e})},decode:function e(t,n){return Of(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await kf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Af(this,t,n,{callee:e})},safeEncode(e,t){return jf(this,e,t)},safeDecode(e,t){return Mf(this,e,t)},async safeEncodeAsync(e,t){return Nf(this,e,t)},async safeDecodeAsync(e,t){return Pf(this,e,t)},toJSONSchema(e){return Pd(this,{})(e)},get description(){return vu.get(this)?.description},get _def(){return this._zod.def}}),Lf=B(`_ZodString`,(e,t)=>{Cc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zd(e,t,n,r)},Ao({format:e=>qd(e).format??null,minLength:e=>qd(e).minimum??null,maxLength:e=>qd(e).maximum??null},{regex(...e){return this.check(od(...e))},includes(...e){return this.check(ld(...e))},startsWith(...e){return this.check(ud(...e))},endsWith(...e){return this.check(dd(...e))},min(...e){return this.check(id(...e))},max(...e){return this.check(rd(...e))},length(...e){return this.check(ad(...e))},nonempty(...e){return this.check(id(1,...e))},lowercase(e){return this.check(sd(e))},uppercase(e){return this.check(cd(e))},trim(){return this.check(md())},normalize(...e){return this.check(pd(...e))},toLowerCase(){return this.check(hd())},toUpperCase(){return this.check(gd())},slugify(){return this.check(_d())}})),Rf=B(`ZodString`,(e,t)=>{Cc.init(e,t),Lf.init(e,t)},{email(e){return this.check(xu(Wf,e))},url(e){return this.check(Du(qf,e))},jwt(e){return this.check(Hu(cp,e))},emoji(e){return this.check(Ou(Jf,e))},guid(e){return this.check(Su(Gf,e))},uuid(e){return this.check(Cu(Kf,e))},uuidv4(e){return this.check(wu(Kf,e))},uuidv6(e){return this.check(Tu(Kf,e))},uuidv7(e){return this.check(Eu(Kf,e))},nanoid(e){return this.check(ku(Yf,e))},cuid(e){return this.check(Au(Xf,e))},cuid2(e){return this.check(ju(Zf,e))},ulid(e){return this.check(Mu(Qf,e))},base64(e){return this.check(zu(ap,e))},base64url(e){return this.check(Bu(op,e))},xid(e){return this.check(Nu($f,e))},ksuid(e){return this.check(Pu(ep,e))},ipv4(e){return this.check(Fu(tp,e))},ipv6(e){return this.check(Iu(np,e))},cidrv4(e){return this.check(Lu(rp,e))},cidrv6(e){return this.check(Ru(ip,e))},e164(e){return this.check(Vu(sp,e))},datetime(e){return this.check(Uu(Bf,e))},date(e){return this.check(Wu(Vf,e))},time(e){return this.check(Gu(Hf,e))},duration(e){return this.check(Ku(Uf,e))}});function zf(e){return bu(Rf,e)}var J=B(`ZodStringFormat`,(e,t)=>{U.init(e,t),Lf.init(e,t)}),Bf=B(`ZodISODateTime`,(e,t)=>{Hc.init(e,t),J.init(e,t)}),Vf=B(`ZodISODate`,(e,t)=>{Uc.init(e,t),J.init(e,t)}),Hf=B(`ZodISOTime`,(e,t)=>{Wc.init(e,t),J.init(e,t)}),Uf=B(`ZodISODuration`,(e,t)=>{Gc.init(e,t),J.init(e,t)}),Wf=B(`ZodEmail`,(e,t)=>{Ec.init(e,t),J.init(e,t)}),Gf=B(`ZodGUID`,(e,t)=>{wc.init(e,t),J.init(e,t)}),Kf=B(`ZodUUID`,(e,t)=>{Tc.init(e,t),J.init(e,t)}),qf=B(`ZodURL`,(e,t)=>{Pc.init(e,t),J.init(e,t)}),Jf=B(`ZodEmoji`,(e,t)=>{Fc.init(e,t),J.init(e,t)}),Yf=B(`ZodNanoID`,(e,t)=>{Ic.init(e,t),J.init(e,t)}),Xf=B(`ZodCUID`,(e,t)=>{Lc.init(e,t),J.init(e,t)}),Zf=B(`ZodCUID2`,(e,t)=>{Rc.init(e,t),J.init(e,t)}),Qf=B(`ZodULID`,(e,t)=>{zc.init(e,t),J.init(e,t)}),$f=B(`ZodXID`,(e,t)=>{Bc.init(e,t),J.init(e,t)}),ep=B(`ZodKSUID`,(e,t)=>{Vc.init(e,t),J.init(e,t)}),tp=B(`ZodIPv4`,(e,t)=>{Kc.init(e,t),J.init(e,t)}),np=B(`ZodIPv6`,(e,t)=>{Yc.init(e,t),J.init(e,t)}),rp=B(`ZodCIDRv4`,(e,t)=>{Xc.init(e,t),J.init(e,t)}),ip=B(`ZodCIDRv6`,(e,t)=>{Qc.init(e,t),J.init(e,t)}),ap=B(`ZodBase64`,(e,t)=>{tl.init(e,t),J.init(e,t)}),op=B(`ZodBase64URL`,(e,t)=>{il.init(e,t),J.init(e,t)}),sp=B(`ZodE164`,(e,t)=>{al.init(e,t),J.init(e,t)}),cp=B(`ZodJWT`,(e,t)=>{sl.init(e,t),J.init(e,t)}),lp=B(`ZodNumber`,(e,t)=>{cl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qd(e,t,n,r),e.isFinite=!0},Ao({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qd(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qd(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qd(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qd(e).format??null},{gt(e,t){return this.check(ed(e,t))},gte(e,t){return this.check(td(e,t))},min(e,t){return this.check(td(e,t))},lt(e,t){return this.check(Qu(e,t))},lte(e,t){return this.check($u(e,t))},max(e,t){return this.check($u(e,t))},int(e){return this.check(fp(e))},safe(e){return this.check(fp(e))},positive(e){return this.check(ed(0,e))},nonnegative(e){return this.check(td(0,e))},negative(e){return this.check(Qu(0,e))},nonpositive(e){return this.check($u(0,e))},multipleOf(e,t){return this.check(nd(e,t))},step(e,t){return this.check(nd(e,t))},finite(){return this}}));function up(e){return qu(lp,e)}var dp=B(`ZodNumberFormat`,(e,t)=>{ll.init(e,t),lp.init(e,t)});function fp(e){return Ju(dp,e)}var pp=B(`ZodBoolean`,(e,t)=>{ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$d(e,t,n,r)});function Y(e){return Yu(pp,e)}var mp=B(`ZodUnknown`,(e,t)=>{dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hp(){return Xu(mp)}var gp=B(`ZodNever`,(e,t)=>{fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ef(e,t,n,r)});function _p(e){return Zu(gp,e)}var vp=B(`ZodArray`,(e,t)=>{If(),gl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r),e.element=t.element},{min(e,t){return this.check(id(e,t))},nonempty(e){return this.check(id(1,e))},max(e,t){return this.check(rd(e,t))},length(e,t){return this.check(ad(e,t))},unwrap(){return this.element}});function yp(e,t){return vd(vp,e,t)}var bp=B(`ZodObject`,(e,t)=>{If(),Sl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r),Io(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ap(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(L(this._zod.def,{catchall:e}))},passthrough(){return this.clone(L(this._zod.def,{catchall:hp()}))},loose(){return this.clone(L(this._zod.def,{catchall:hp()}))},strict(){return this.clone(L(this._zod.def,{catchall:_p()}))},strip(){return this.clone(L(this._zod.def,{catchall:void 0}))},extend(e){return co(this,e)},safeExtend(e){return uo(this,e)},merge(e){return fo(this,e)},pick(e){return ao(this,e)},omit(e){return so(this,e)},partial(...e){return po(Fp,this,e[0])},exactPartial(...e){return po(Lp,this,e[0],`exactPartial`)},required(...e){return mo(Gp,this,e[0])}});function xp(e,t){return new bp({type:`object`,shape:e??{},...R(t)})}function Sp(e,t){return new bp({type:`object`,shape:e,catchall:_p(),...R(t)})}var Cp=B(`ZodUnion`,(e,t)=>{wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lf(e,t,n,r),e.options=t.options});function wp(e,t){return new Cp({type:`union`,options:e,...R(t)})}var Tp=B(`ZodDiscriminatedUnion`,(e,t)=>{Cp.init(e,t),El.init(e,t)});function Ep(e,t,n){return new Tp({type:`union`,options:t,discriminator:e,...R(n)})}var Dp=B(`ZodIntersection`,(e,t)=>{Dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uf(e,t,n,r)});function Op(e,t){return new Dp({type:`intersection`,left:e,right:t})}var kp=B(`ZodEnum`,(e,t)=>{Al.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new kp({...t,checks:[],...R(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new kp({...t,checks:[],...R(r),entries:i})}});function Ap(e,t){return new kp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...R(t)})}var jp=B(`ZodLiteral`,(e,t)=>{jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nf(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Mp(e,t){return new jp({type:`literal`,values:Array.isArray(e)?e:[e],...R(t)})}var Np=B(`ZodTransform`,(e,t)=>{If(),Ml.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Wo(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Eo(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Eo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Pp(e){return new Np({type:`transform`,transform:e})}var Fp=B(`ZodOptional`,(e,t)=>{Pl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new Fp({type:`optional`,innerType:e})}var Lp=B(`ZodExactOptional`,(e,t)=>{Fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rp(e){return new Lp({type:`optional`,innerType:e})}var zp=B(`ZodNullable`,(e,t)=>{Il.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>df(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bp(e){return new zp({type:`nullable`,innerType:e})}var Vp=B(`ZodDefault`,(e,t)=>{Ll.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hp(e,t){return new Vp({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Up=B(`ZodPrefault`,(e,t)=>{zl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wp(e,t){return new Up({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Gp=B(`ZodNonOptional`,(e,t)=>{Bl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kp(e,t){return new Gp({type:`nonoptional`,innerType:e,...R(t)})}var qp=B(`ZodCatch`,(e,t)=>{Ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_f(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Jp(e,t){return new qp({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ro(t)})}var Yp=B(`ZodPipe`,(e,t)=>{Wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vf(e,t,n,r),e.in=t.in,e.out=t.out});function Xp(e,t){return new Yp({type:`pipe`,in:e,out:t})}var Zp=B(`ZodReadonly`,(e,t)=>{Kl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qp(e){return new Zp({type:`readonly`,innerType:e})}var $p=B(`ZodCustom`,(e,t)=>{Jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r)});function em(e,t={}){return yd($p,e,t)}function tm(e,t){return bd(e,t)}var nm=`no-project`;function rm(){return X.parseLocation(X.history.location).search}function im(){let e=/^\/terminal\/([^/]+)$/.exec(X.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Z().machines.some(e=>e.id===t)?t:null}function am(){let e=sr({strict:!1,select:e=>e.machine??null});return Fh(t=>t.machines.some(t=>t.id===e)?e:null)}function om(){return rm().project??`global`}function sm(){return cr({strict:!1,select:e=>e.project??`global`})}function cm(e){let t=rm();return t.machine===void 0||t.project===void 0||!e.includes(t.machine)?null:{machine:t.machine,projectId:t.project,sessionId:t.session??null}}function lm(e){Em({...rm(),...e},!0,X.history.location.state.layer)}function um(e,t){Em({...rm(),...e},!1,t)}function dm(e){let t=Z();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){lm({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){lm({panel:`browser`,browse:e});return}let n=Lh(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);lm({panel:`browser`,browse:`${n.path}/${e}`})}function fm(e,t){X.history.location.state.layer===e?X.history.back():t()}var pm=[],mm=!1,hm=!1,gm=!1;function _m(){return X.history.location.state.guard===!0}function vm(){return gm}function ym(){mm||(pm.length>0&&!_m()?X.history.push(X.history.location.href,{guard:!0}):pm.length===0&&_m()&&(mm=!0,X.history.back()))}function bm(){hm=_m(),X.history.subscribe(({action:e})=>{let t=hm;hm=_m(),e.type===`PUSH`||e.type===`REPLACE`?gm=!1:(gm=t,gm&&mm?mm=!1:gm&&pm.at(-1)?.(),setTimeout(ym))}),setTimeout(ym)}function xm(e,t){let n=(0,j.useEffectEvent)(t);(0,j.useEffect)(()=>{if(!e)return;function t(){n()}return pm.push(t),setTimeout(ym),()=>{pm.splice(pm.indexOf(t),1),setTimeout(ym)}},[e])}var Sm=`terminalProjects`;function Cm(){return JSON.parse(localStorage.getItem(Sm)??`[]`)}function wm(){let e=rm();if(im()!==null||e.machine===void 0||e.project===void 0||e.session===void 0)return;let t=`${e.machine} ${e.project}`,n=Cm().filter(e=>e!==t);localStorage.setItem(Sm,JSON.stringify(e.bottom===`terminal`?[...n,t]:n))}function Tm(e=!1){let t=Z().selection;if(t===null){Em({project:im()===null?void 0:rm().project},!0,X.history.location.state.layer);return}let n=rm(),r=n.machine===t.machine&&n.project===t.projectId&&n.session===void 0&&(t.sessionId===null||Z().loaded),i=Cm().includes(`${t.machine} ${t.projectId}`),a={machine:t.machine,project:t.projectId,session:t.sessionId??void 0,bottom:r?n.bottom:t.sessionId!==null&&i?`terminal`:void 0};if(im()!==null){X.navigate({to:`/`,search:a,replace:e||_m(),state:{layer:`chat`},resetScroll:!1});return}let o=n.machine===a.machine&&n.project===a.project&&n.session===a.session,s=n.machine!==void 0&&n.session===void 0&&a.session===void 0;e||o||r||s?lm(a):um(a,`chat`)}function Em(e,t,n){let r=im(),i=_m(),a=t&&i?{layer:n,guard:i}:{layer:n};r===null?X.navigate({to:`/`,search:e,replace:t||i,state:a,resetScroll:!1}):X.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t||i,state:a,resetScroll:!1})}function Dm(e,t=null,n=!1){let r=Ih(Z(),e.machine),i=Z().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),Q({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?i?.sessionId===null&&i.machine===e.machine?Z().settings:tg(r):Sa(Uh(e))??eg(r.lastUsed,Z().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??tg(r).provider),context:null,replacing:null,paletteOpen:!1,unseen:Z().unseen.filter(t=>e.sessionId===null||t!==oh(e.machine,e.sessionId))}),Tm(n),og(e.machine),e.sessionId!==null&&r.status===`online`&&Om(e.machine,e.projectId,e.sessionId,!0,t)}function Om(e,t,n,r,i){F(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Z().sessions.some(n=>n.machine===e&&n.id===t.id)||Q({sessions:[...Z().sessions,{...t,machine:e}]})}).catch($)}function km(){Q({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),Tm()}function Am(){let e=Z().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function jm(e,t,n=!1){Dm({machine:e,projectId:Lh(Z(),e,t)?.scratch===!0?nm:t,sessionId:null},null,n)}function Mm(){let e=Z(),t=localStorage.getItem(`lastProject`),n=t===null?null:JSON.parse(t),r=e.machines.filter(e=>e.system?.scratchAvailable===!0);if(n!==null&&n.projectId===`no-project`&&r.some(e=>e.id===n.machine))return n;let i=(n===null?void 0:e.projects.find(e=>e.machine===n.machine&&e.id===n.projectId))??e.projects.find(e=>!e.scratch);return i===void 0?r.length>0?{machine:r[0].id,projectId:nm}:null:{machine:i.machine,projectId:i.id}}function Nm(e,t){let n=im();(n!==e||om()!==t)&&(X.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null||_m(),state:{layer:`chat`},resetScroll:!1}),km())}async function Pm(e,t,n,r){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),Q({sentAt:Date.now()}),await F(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t});let i=Z().replacing;n.sessionId===null&&i!==null&&i.machine===n.machine&&i.sessionId!==null&&(Q({replacing:null}),await Km(i.machine,i.sessionId,i.projectId))}function Fm(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function Im(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function Lm(){let e=Z().selection;e!==null&&e.sessionId!==null&&F(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function Rm(e,t,n){F(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function zm(e,t,n){let r=Z().selection;r!==null&&r.sessionId!==null&&F(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function Bm(e){let t=Z().selection;if(t!==null&&t.sessionId!==null)try{let n=await F(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});Dm({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function Vm(){let e=Z().selection,t=Z().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await F(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Z().selection!==e||Z().before!==t)return;Q({earlier:[...n.items,...Z().earlier],before:n.before})}catch(e){$(e)}}async function Hm(e,t){let n=Z().selection;if(n!==null&&n.sessionId!==null)try{let r=await F(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Z().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Z().items;Q({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function Um(e,t,n){let r=Z();function i(n){return n.machine===e&&n.id===t}let a=[...r.sessions,...r.inactive].find(i);if(a!==void 0){let e={...a,...n};Q({sessions:r.sessions.some(i)?r.sessions.map(t=>i(t)?e:t):e.status===`inactive`?r.sessions:[...r.sessions,e],inactive:e.status===`inactive`?r.inactive.some(i)?r.inactive.map(t=>i(t)?e:t):[e,...r.inactive]:r.inactive.filter(e=>!i(e))})}try{await F(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function Wm(e){let t=oh(e.machine,e.id);Q({generatingTitles:[...Z().generatingTitles,t]});try{await F(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{Q({generatingTitles:Z().generatingTitles.filter(e=>e!==t)})}}async function Gm(e,t,n){let r=Z().selection;if(r?.machine===e&&r.sessionId===t){let i=Z().sessions.filter(r=>(r.status===`pinned`||r.status===`active`||r.status===`snoozed`)&&(r.machine!==e||r.id!==t)&&(n===null||r.machine===n.machine&&(r.projectId===n.projectId||n.projectId===`no-project`&&Lh(Z(),r.machine,r.projectId)?.scratch===!0))).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);i===void 0?jm(r.machine,r.projectId,!0):Dm({machine:i.machine,projectId:i.projectId,sessionId:i.id},null,!0)}await Um(e,t,{status:`inactive`})}async function Km(e,t,n){Q({sessions:Z().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Z().inactive.filter(n=>n.machine!==e||n.id!==t)}),ba(oh(e,t));let r=Z().selection;r?.machine===e&&r.sessionId===t&&jm(e,r.projectId,!0);try{await F(e,`sessions.remove`,{id:t,projectId:n})}catch(e){$(e)}}var qm=xp({machine:zf().optional().catch(void 0),project:zf().optional().catch(void 0),session:zf().optional().catch(void 0),panel:Ap([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:zf().optional().catch(void 0),bottom:Mp(`terminal`).optional().catch(void 0),terminal:zf().optional().catch(void 0)}),Jm=Ar({validateSearch:qm}),Ym=Or({getParentRoute:()=>Jm,path:`/`}),Xm=Or({getParentRoute:()=>Jm,path:`/terminal`,beforeLoad:()=>{let e=Am();throw ke(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),Zm=Or({getParentRoute:()=>Jm,path:`/terminal/$machine`});if(window.history.state?.__TSR_index===void 0&&(location.pathname.startsWith(`/terminal`)||new URLSearchParams(location.search).has(`machine`))){let e=`${location.pathname}${location.search}${location.hash}`,t=Math.random().toString(36).slice(2),n=Math.random().toString(36).slice(2);window.history.replaceState({__TSR_index:0,__TSR_key:t,key:t},``,`/`),window.history.pushState({__TSR_index:1,__TSR_key:n,key:n,layer:`chat`},``,e)}var X=Mr({routeTree:Jm.addChildren([Ym,Xm,Zm]),disableGlobalCatchBoundary:!0,parseSearch:e=>qm.parse(Object.fromEntries(new URLSearchParams(e))),stringifySearch:e=>{let t=new URLSearchParams;for(let n of Object.entries(e))n[1]!==void 0&&t.set(n[0],String(n[1]));let n=t.toString();return n===``?``:`?${n}`}}),Qm=fi.withTag(`machines`),$m=`machines`,eh=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function th(){let e=localStorage.getItem($m);return e===null?[]:JSON.parse(e)}function nh(e){localStorage.setItem($m,JSON.stringify(e))}async function rh(e){if(!(`caches`in window))return;let t=e.map(e=>({id:e.id,addresses:e.addresses}));await(await caches.open(`offsite-worker`)).put(`/machines`,new Response(JSON.stringify(t)))}function ih(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));X.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:ah(t).address,code:e.get(`code`)}}function ah(e){let t=e.trim(),n=new URL(/^[a-z]+:\/\//i.test(t)?t:`http://${t}`);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`Use an http:// or https:// address`);let r=new URLSearchParams(n.hash.slice(1)),i=r.get(`machine`);return{address:i===null?n.origin:ah(i).address,code:r.get(`code`)}}function oh(e,t){return`${e} ${t}`}function sh(e){return{id:e.id,addresses:e.addresses,via:null,status:`connecting`,name:e.label??e.name,hostname:e.name,label:e.label,icon:e.icon,pairedAt:e.pairedAt??null,config:null,lastUsed:null,appIcon:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function ch(e){return e.projects.map(t=>({...t,machine:e.id}))}function lh(){let e=th(),t=Z().machines;for(let n of t)e.some(e=>e.id===n.id)||vh(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Z();Q({machines:[...e.machines,sh(n)],projects:[...e.projects,...ch(n)]}),Ni(n.id,n.addresses)}else zh(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(zh(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),gh(n.id))}let n=e.map(e=>e.id);Q({machines:[...Z().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function uh(e,t){let n=Z().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await dh(n.id,t),n.id;let r=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);return t!==null&&await ai(r,await fh(e,t)),Q({machines:[...Z().machines,sh({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),yh(),Ni(r,e),r}async function dh(e,t){await ai(e,await fh(Ih(Z(),e).addresses,t)),zh(e,{pairedAt:Date.now()}),yh(),gh(e)}async function fh(e,t){let n;for(let r of e){let e=await fetch(`${r}/api/pair`,{method:`POST`,headers:{authorization:`Bearer ${t}`}}).catch(e=>(n??=e,null));if(e!==null){if(!e.ok)throw Error(await e.text());return(await e.json()).token}}throw Error(`Could not reach the machine to pair: ${String(n)}`)}function ph(e,t){let n=Ih(Z(),e),r={...n,...t};zh(e,{...t,name:r.label??r.hostname}),yh(),r.addresses.join(` `)!==n.addresses.join(` `)&&gh(e)}function mh(e){Q({machines:[...Z().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),yh()}function hh(e){rh(e).catch(e=>Qm.error(`could not share the machines with the service worker`,e))}function gh(e){Pi(e),zh(e,{status:`connecting`,via:null}),Ni(e,Ih(Z(),e).addresses)}function _h(e){vh(e),yh(),oi(e).catch(e=>Qm.error(`could not remove the device token`,e))}function vh(e){Pi(e);let t=Z(),n=t.machines.filter(t=>t.id!==e);Q({machines:n,projects:t.projects.filter(t=>t.machine!==e),sessions:t.sessions.filter(t=>t.machine!==e),inactive:t.inactive.filter(t=>t.machine!==e),unseen:t.unseen.filter(t=>!t.startsWith(`${e} `)),...t.settingsMachine===e&&{settingsMachine:n.at(0)?.id??null},...t.selection?.machine===e&&{selection:null}}),Tm()}function yh(){let e=Z(),t=e.machines.map(t=>({id:t.id,addresses:t.addresses,name:t.hostname,label:t.label,icon:t.icon,pairedAt:t.pairedAt,projects:e.projects.filter(e=>e.machine===t.id).map(e=>({id:e.id,path:e.path,name:e.name,logo:e.logo,hidden:e.hidden,scratch:e.scratch}))}));nh(t),hh(t)}var bh=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}],xh=fi.withTag(`prefs`),Sh=Sp({theme:zf().refine(e=>bh.some(t=>t.id===e)).default(bh[0].id),terminal:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(14),lineHeight:up().default(1.35),ligatures:Y().default(!0)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),padding:Sp({top:up().default(4),right:up().default(4),bottom:up().default(0),left:up().default(4)}).prefault({}),scrollback:up().default(1e3),boldIsBright:Y().default(!0),behavior:Sp({modernizeShiftEnter:Y().default(!0),pasteBrowserImages:Y().default(!0),captureShortcuts:Y().default(!0),bellFlash:Y().default(!0),bellSound:Y().default(!0),clickToMoveCursor:Y().default(!0),optionAsMeta:Ap([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:Y().default(!0),confirmCloseBusyTab:Y().default(!0)}).prefault({})}).prefault({}),editor:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(15.3),lineHeight:up().default(1.8),ligatures:Y().default(!0),features:zf().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),tabSize:up().default(2),wordWrap:Y().default(!0),graph:Y().default(!0)}).prefault({}),diff:Sp({split:Y().default(!1),wrap:Y().default(!0),collapsed:Y().default(!1)}).prefault({}),rewind:Ap([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:Y().default(!1),toolbar:yp(Ap([`diff`,`terminal`,`tasks`,`browser`,`editor`])).default([`diff`,`terminal`,`editor`])}),Ch=`prefs`,wh=Sh.parse({});function Th(){let e=localStorage.getItem(Ch);if(e===null)return structuredClone(wh);let t=Sh.safeParse(JSON.parse(e));return t.success?t.data:(xh.warn(`invalid stored prefs, using the defaults:\n${rs(t.error)}`),structuredClone(wh))}function Eh(e){localStorage.setItem(Ch,JSON.stringify(e))}function Dh(){let e=Z().prefs.theme,t=bh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function Oh(){let e=Fh(e=>e.prefs.theme),t=bh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function kh(){let e=Dh(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}var Ah=fi.withTag(`ui`),jh={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},Mh;function Nh(e){Mh=ea()(()=>e)}function Ph(e){return Mh.subscribe(e)}function Z(){return Mh.getState()}function Fh(e){return na(Mh,e)}function Q(e){Mh.setState(e)}function Ih(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function Lh(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function Rh(e){return e.selection?.machine??e.machines.at(0)?.id??null}function zh(e,t){Q({machines:Z().machines.map(n=>n.id===e?{...n,...t}:n)})}function Bh(e,t,n){if(n!==null)return e.find(e=>e.id===t)?.activity[n]}function Vh(e){let t=e.selection;if(t!==null)return Bh(e.machines,t.machine,t.sessionId)}function Hh(e){return Vh(e)?.running===!0}function Uh(e){return e.sessionId===null?`new`:oh(e.machine,e.sessionId)}function Wh(e){Q({draft:e})}function Gh(e){Q({paletteOpen:e})}function Kh(e){Q({editor:e})}function qh(e){Q({exporting:e})}function Jh(e){Q({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:Rh(Z()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function Yh(e){Q({usageOpen:e,paletteOpen:!1})}function Xh(e){Q({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Z().settingsOpen&&{settingsMachine:Rh(Z())}})}function Zh(e){Q({prefs:e}),Eh(e),kh()}function $(e){Ah.warn(`showing an error:`,e),Q({errors:[...Z().errors,i(e)]})}function Qh(){Q({errors:[]})}var $h=null;function eg(e,t){let n=e?.find(e=>e.provider===t),r=t===`claude`?Yi:t===`codex`?Xi:null;return n===void 0?{provider:t,accountId:null,model:null,effort:null,mode:r,plan:!1}:{provider:t,accountId:n.accountId,model:n.model,effort:null,mode:r,plan:!1}}function tg(e){let t=Zi(e.lastUsed??[],e=>e.usedAt);return t===void 0?{provider:Ji,accountId:null,model:null,effort:null,mode:Yi,plan:!1}:eg(e.lastUsed,t.provider)}function ng(e,t,n,r){F(e,`lastUsed.save`,{provider:t,accountId:n,model:r}).catch($);let i=Z().machines.filter(t=>t.id!==e&&t.status===`online`);if(t===`opencode`){for(let e of i.filter(e=>e.openCode.available))F(e.id,`lastUsed.save`,{provider:t,accountId:null,model:r}).catch($);return}let a=Ih(Z(),e),o=(t===`claude`?a.claudeAccounts:a.codexAccounts).find(e=>e.id===n)?.identity;if(o!=null)for(let e of i){let n=(t===`claude`?e.claudeAccounts:e.codexAccounts).find(e=>e.enabled&&e.identity!==null&&e.identity.accountId===o.accountId&&e.identity.organizationId===o.organizationId);n!==void 0&&F(e.id,`lastUsed.save`,{provider:t,accountId:n.id,model:r}).catch($)}}function rg(e){let t={...Z().settings,...e};Q({settings:t});let n=Z().selection;n!==null&&(n.sessionId!==null&&Ca(Uh(n),t),e.accountId!==void 0&&cg(),n.sessionId!==null&&Bh(Z().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&F(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($))}function ig(e,t){if(zh(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Z().selection?.machine!==e)return;let n=Z().settings,r=[...[...t.claudeAccounts,...t.codexAccounts].filter(e=>e.valid).map(e=>({provider:e.provider,accountId:e.id})),...t.openCode.available?[{provider:`opencode`,accountId:null}]:[]];if(r.some(e=>e.provider===n.provider&&e.accountId===n.accountId))return;let i=r.find(e=>e.provider===n.provider),a=Z().selection?.sessionId===null?r.at(0):void 0;i===void 0?a===void 0?n.accountId!==null&&rg({accountId:null}):rg({...eg(Ih(Z(),e).lastUsed,a.provider),accountId:a.accountId}):rg({accountId:i.accountId})}function ag(e){let t=Z().selection;t?.machine===e&&t.sessionId===null&&(Q({settings:tg(Ih(Z(),e))}),og(e))}function og(e){let t=Ih(Z(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&ig(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),cg()}async function sg(e){try{ig(e,await F(e,`accounts.list`,void 0))}catch(e){$(e)}}async function cg(){let e=Z().selection;if(e===null)return;let{provider:t,accountId:n}=Z().settings;if(t!==`opencode`&&n===null)Q({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if($h?.key!==r){let i=F(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){$h?.result===i&&($h=null)}i.then(a,a),$h={key:r,result:i}}let i=await $h.result;if(Z().selection?.machine!==e.machine||Z().selection?.projectId!==e.projectId||Z().settings.provider!==t||Z().settings.accountId!==n)return;Q({capabilities:i});let a=Z().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&rg({effort:e});return}let o=i.models.find(e=>!e.hidden&&e.value===i.defaultModel)??i.models.find(e=>!e.hidden);if(o===void 0)return;rg({model:o.value,...o.effort===null?{}:{effort:o.effort}})}catch(e){$(e)}}var lg=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{ch as $,Da as $t,Q as A,Tm as At,eh as B,xp as Bt,$ as C,Oe as Cn,vm as Ct,Xh as D,lm as Dt,Jh as E,c as En,wm as Et,Oh as F,sm as Ft,ih as G,Sa as Gt,th as H,ka as Ht,wh as I,nm as It,lh as J,ya as Jt,yh as K,Ta as Kt,Th as L,Y as Lt,Fh as M,om as Mt,kh as N,xm as Nt,Yh as O,cm as Ot,Dh as P,am as Pt,sh as Q,Ca as Qt,bh as R,Ep as Rt,Kh as S,_t as Sn,fm as St,Gh as T,D as Tn,um as Tt,oh as U,_a as Ut,ph as V,zf as Vt,dh as W,xa as Wt,_h as X,Oa as Xt,gh as Y,ha as Yt,mh as Z,va as Zt,jh as _,cr as _n,jm as _t,cg as a,Ni as an,Bm as at,Wh as b,On as bn,Fm as bt,ig as c,Li as cn,Hm as ct,Rh as d,fi as dn,Dm as dt,ga as en,hh as et,Qh as f,mi as fn,Nm as ft,Lh as g,Pr as gn,Pm as gt,Ih as h,ti as hn,zm as ht,sg as i,F as in,Um as it,Zh as j,im as jt,Ph as k,bm as kt,Bh as l,Ri as ln,Vm as lt,Z as m,ei as mn,Km as mt,rg as n,Yi as nn,km as nt,ag as o,Ii as on,Lm as ot,Uh as p,Zr as pn,Wm as pt,ah as q,Ea as qt,eg as r,Ji as rn,Gm as rt,ng as s,Fi as sn,Mm as st,lg as t,wa as tn,X as tt,Nh as u,ji as un,Om as ut,Vh as v,tr as vn,Im as vt,qh as w,O as wn,dm as wt,zh as x,Dn as xn,rm as xt,Hh as y,An as yn,Rm as yt,uh as z,Mp as zt};
67
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Dd(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Dd(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Od=new Set([`type`,`properties`,`required`,`additionalProperties`]),kd=[`oneOf`,`anyOf`];function Ad(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function jd(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Od.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Ad(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ra(n,r,e.length===1?e[0]:jd(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Ad(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Md(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Od)if(t in e)return;let n=t.filter(e=>kd.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=jd(t);else{let e=n[0],i=kd.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>jd([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Sd(e,r))}function Nd(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Sd(i,s),Sd(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Dd(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Md(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Sd(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ra(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Fd(t,`input`,e.processors),output:Fd(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function G(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return G(r.element,n);if(r.type===`set`)return G(r.valueType,n);if(r.type===`lazy`)return G(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return G(r.innerType,n);if(r.type===`intersection`)return G(r.left,n)||G(r.right,n);if(r.type===`record`||r.type===`map`)return G(r.keyType,n)||G(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:G(r.in,n)||G(r.out,n);if(r.type===`object`){for(let e in r.shape)if(G(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(G(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(G(e,n))return!0;return!!(r.rest&&G(r.rest,n))}return!1}var Pd=(e,t={})=>n=>{let r=Cd({...n,processors:t});return W(e,r),Ed(r,e),Nd(r,e)},Fd=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Cd({...i??{},target:a,io:t,processors:n});return W(e,o),Ed(o,e),Nd(o,e)},Id=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ld=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rd=(e,t)=>{Id(e,`minimum`,t),Ld(e,`maximum`,t)},zd=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bd=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Vd=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hd=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ud=(e,t)=>Id(e,`minimum`,t.minimum),Wd=(e,t)=>Ld(e,`maximum`,t.maximum),Gd=e=>(t,n)=>{Hd(t,n.format);let[r,i]=e[n.format];Id(t,`minimum`,r),Ld(t,`maximum`,i)},Kd={greater_than:(e,t)=>Id(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ld(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zd(e,t.value),number_format:Gd(ro),bigint_format:Gd(io),min_length:Ud,max_length:Wd,length_equals:(e,t)=>Rd(e,t.length),min_size:Ud,max_size:Wd,size_equals:(e,t)=>Rd(e,t.size),string_format:(e,t)=>{Hd(e,t.format),t.pattern&&Bd(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Vd(e,t.mime)};function qd(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Kd[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Id(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Id(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ld(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ld(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zd(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vd(t,i.mime);for(let e of i.patterns??[])Bd(t,e);return t}var Jd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yd=new Map([[el,Bs],[nl,Vs]]),Xd=e=>Yd.get(e)??e,Zd=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qd(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jd[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Xd);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Qd=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qd(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):wd(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},$d=(e,t,n,r)=>{n.type=`boolean`},ef=(e,t,n,r)=>{n.not={}},tf=(e,t,n,r)=>{let i=e._zod.def,a=Aa(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},nf=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(wd(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(wd(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},rf=(e,t,n,r)=>{wd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},af=(e,t,n,r)=>{wd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},of=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qd(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=W(a.element,t,{...r,path:[...r.path,`items`]})};function sf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?sf(t.out):t.type===`catch`?sf(t.innerType):e._zod.optin}var cf=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&wd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ra(i.properties,e,W(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?sf(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=W(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},lf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>W(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},uf=(e,t,n,r)=>{let i=e._zod.def,a=W(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=W(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},df=(e,t,n,r)=>{let i=e._zod.def,a=W(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ff=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pf=Symbol();function mf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(wd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),pf):JSON.parse(o)}var hf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n.default=o)},gf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=mf(i.defaultValue,e,t,n,r);o!==pf&&(n._prefault=o)},_f=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{wd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vf=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;W(o,t,r);let s=t.seen.get(e);s.ref=o},yf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},bf=(e,t,n,r)=>{let i=e._zod.def;W(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xf=new WeakSet([Object.prototype,Error.prototype]);function Sf(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var K=B(`ZodError`,(e,t)=>{Qo.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);xf.has(n)||(xf.add(n),Sf(n,`format`,e=>t=>ts(e,t)),Sf(n,`flatten`,e=>t=>es(e,t)),Sf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ma,2)}),Sf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ma,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cf=as(K),wf=os(K),Tf=ss(K),Ef=ls(K),Df=hs(K),Of=gs(K),kf=_s(K),Af=vs(K),jf=ys(K),Mf=bs(K),Nf=xs(K),Pf=Ss(K);function Ff(){Go.localeError||Ko(mu())}function If(){Go.memoizer||Ko({memoizer:du()})}var q=B(`ZodType`,(e,t)=>(Ff(),H.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(L(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(em(e,t))},superRefine(e,t){return this.check(tm(e,t))},overwrite(e){return this.check(fd(e))},optional(){return Ip(this)},exactOptional(){return Rp(this)},nullable(){return Bp(this)},nullish(){return Ip(Bp(this))},nonoptional(e){return Kp(this,e)},array(){return yp(this)},or(e){return wp([this,e])},and(e){return Op(this,e)},transform(e){return Xp(this,Pp(e))},default(e){return Hp(this,e)},prefault(e){return Wp(this,e)},catch(e){return Jp(this,e)},pipe(e){return Xp(this,e)},readonly(){return Qp(this)},describe(e){let t=this.clone();return vu.add(t,{description:e}),t},meta(...e){if(e.length===0)return vu.get(this);let t=this.clone();return vu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ko(this,`~standard`,{...Sc(this),jsonSchema:{input:Fd(this,`input`),output:Fd(this,`output`)}})},set"~standard"(e){Oo(this,`~standard`,e)},parse:function e(t,n){return Cf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wf(this,t,n,{callee:e})},safeParse(e,t){return Tf(this,e,t)},async safeParseAsync(e,t){return Ef(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Oo(this,`spa`,e)},validate(e,t){return fs(this,e,t)},validateAsync(e,t){return ms(this,e,t)},encode:function e(t,n){return Df(this,t,n,{callee:e})},decode:function e(t,n){return Of(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await kf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Af(this,t,n,{callee:e})},safeEncode(e,t){return jf(this,e,t)},safeDecode(e,t){return Mf(this,e,t)},async safeEncodeAsync(e,t){return Nf(this,e,t)},async safeDecodeAsync(e,t){return Pf(this,e,t)},toJSONSchema(e){return Pd(this,{})(e)},get description(){return vu.get(this)?.description},get _def(){return this._zod.def}}),Lf=B(`_ZodString`,(e,t)=>{Cc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zd(e,t,n,r)},Ao({format:e=>qd(e).format??null,minLength:e=>qd(e).minimum??null,maxLength:e=>qd(e).maximum??null},{regex(...e){return this.check(od(...e))},includes(...e){return this.check(ld(...e))},startsWith(...e){return this.check(ud(...e))},endsWith(...e){return this.check(dd(...e))},min(...e){return this.check(id(...e))},max(...e){return this.check(rd(...e))},length(...e){return this.check(ad(...e))},nonempty(...e){return this.check(id(1,...e))},lowercase(e){return this.check(sd(e))},uppercase(e){return this.check(cd(e))},trim(){return this.check(md())},normalize(...e){return this.check(pd(...e))},toLowerCase(){return this.check(hd())},toUpperCase(){return this.check(gd())},slugify(){return this.check(_d())}})),Rf=B(`ZodString`,(e,t)=>{Cc.init(e,t),Lf.init(e,t)},{email(e){return this.check(xu(Wf,e))},url(e){return this.check(Du(qf,e))},jwt(e){return this.check(Hu(cp,e))},emoji(e){return this.check(Ou(Jf,e))},guid(e){return this.check(Su(Gf,e))},uuid(e){return this.check(Cu(Kf,e))},uuidv4(e){return this.check(wu(Kf,e))},uuidv6(e){return this.check(Tu(Kf,e))},uuidv7(e){return this.check(Eu(Kf,e))},nanoid(e){return this.check(ku(Yf,e))},cuid(e){return this.check(Au(Xf,e))},cuid2(e){return this.check(ju(Zf,e))},ulid(e){return this.check(Mu(Qf,e))},base64(e){return this.check(zu(ap,e))},base64url(e){return this.check(Bu(op,e))},xid(e){return this.check(Nu($f,e))},ksuid(e){return this.check(Pu(ep,e))},ipv4(e){return this.check(Fu(tp,e))},ipv6(e){return this.check(Iu(np,e))},cidrv4(e){return this.check(Lu(rp,e))},cidrv6(e){return this.check(Ru(ip,e))},e164(e){return this.check(Vu(sp,e))},datetime(e){return this.check(Uu(Bf,e))},date(e){return this.check(Wu(Vf,e))},time(e){return this.check(Gu(Hf,e))},duration(e){return this.check(Ku(Uf,e))}});function zf(e){return bu(Rf,e)}var J=B(`ZodStringFormat`,(e,t)=>{U.init(e,t),Lf.init(e,t)}),Bf=B(`ZodISODateTime`,(e,t)=>{Hc.init(e,t),J.init(e,t)}),Vf=B(`ZodISODate`,(e,t)=>{Uc.init(e,t),J.init(e,t)}),Hf=B(`ZodISOTime`,(e,t)=>{Wc.init(e,t),J.init(e,t)}),Uf=B(`ZodISODuration`,(e,t)=>{Gc.init(e,t),J.init(e,t)}),Wf=B(`ZodEmail`,(e,t)=>{Ec.init(e,t),J.init(e,t)}),Gf=B(`ZodGUID`,(e,t)=>{wc.init(e,t),J.init(e,t)}),Kf=B(`ZodUUID`,(e,t)=>{Tc.init(e,t),J.init(e,t)}),qf=B(`ZodURL`,(e,t)=>{Pc.init(e,t),J.init(e,t)}),Jf=B(`ZodEmoji`,(e,t)=>{Fc.init(e,t),J.init(e,t)}),Yf=B(`ZodNanoID`,(e,t)=>{Ic.init(e,t),J.init(e,t)}),Xf=B(`ZodCUID`,(e,t)=>{Lc.init(e,t),J.init(e,t)}),Zf=B(`ZodCUID2`,(e,t)=>{Rc.init(e,t),J.init(e,t)}),Qf=B(`ZodULID`,(e,t)=>{zc.init(e,t),J.init(e,t)}),$f=B(`ZodXID`,(e,t)=>{Bc.init(e,t),J.init(e,t)}),ep=B(`ZodKSUID`,(e,t)=>{Vc.init(e,t),J.init(e,t)}),tp=B(`ZodIPv4`,(e,t)=>{Kc.init(e,t),J.init(e,t)}),np=B(`ZodIPv6`,(e,t)=>{Yc.init(e,t),J.init(e,t)}),rp=B(`ZodCIDRv4`,(e,t)=>{Xc.init(e,t),J.init(e,t)}),ip=B(`ZodCIDRv6`,(e,t)=>{Qc.init(e,t),J.init(e,t)}),ap=B(`ZodBase64`,(e,t)=>{tl.init(e,t),J.init(e,t)}),op=B(`ZodBase64URL`,(e,t)=>{il.init(e,t),J.init(e,t)}),sp=B(`ZodE164`,(e,t)=>{al.init(e,t),J.init(e,t)}),cp=B(`ZodJWT`,(e,t)=>{sl.init(e,t),J.init(e,t)}),lp=B(`ZodNumber`,(e,t)=>{cl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qd(e,t,n,r),e.isFinite=!0},Ao({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qd(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qd(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qd(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qd(e).format??null},{gt(e,t){return this.check(ed(e,t))},gte(e,t){return this.check(td(e,t))},min(e,t){return this.check(td(e,t))},lt(e,t){return this.check(Qu(e,t))},lte(e,t){return this.check($u(e,t))},max(e,t){return this.check($u(e,t))},int(e){return this.check(fp(e))},safe(e){return this.check(fp(e))},positive(e){return this.check(ed(0,e))},nonnegative(e){return this.check(td(0,e))},negative(e){return this.check(Qu(0,e))},nonpositive(e){return this.check($u(0,e))},multipleOf(e,t){return this.check(nd(e,t))},step(e,t){return this.check(nd(e,t))},finite(){return this}}));function up(e){return qu(lp,e)}var dp=B(`ZodNumberFormat`,(e,t)=>{ll.init(e,t),lp.init(e,t)});function fp(e){return Ju(dp,e)}var pp=B(`ZodBoolean`,(e,t)=>{ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$d(e,t,n,r)});function Y(e){return Yu(pp,e)}var mp=B(`ZodUnknown`,(e,t)=>{dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hp(){return Xu(mp)}var gp=B(`ZodNever`,(e,t)=>{fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ef(e,t,n,r)});function _p(e){return Zu(gp,e)}var vp=B(`ZodArray`,(e,t)=>{If(),gl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r),e.element=t.element},{min(e,t){return this.check(id(e,t))},nonempty(e){return this.check(id(1,e))},max(e,t){return this.check(rd(e,t))},length(e,t){return this.check(ad(e,t))},unwrap(){return this.element}});function yp(e,t){return vd(vp,e,t)}var bp=B(`ZodObject`,(e,t)=>{If(),Sl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r),Io(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ap(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(L(this._zod.def,{catchall:e}))},passthrough(){return this.clone(L(this._zod.def,{catchall:hp()}))},loose(){return this.clone(L(this._zod.def,{catchall:hp()}))},strict(){return this.clone(L(this._zod.def,{catchall:_p()}))},strip(){return this.clone(L(this._zod.def,{catchall:void 0}))},extend(e){return co(this,e)},safeExtend(e){return uo(this,e)},merge(e){return fo(this,e)},pick(e){return ao(this,e)},omit(e){return so(this,e)},partial(...e){return po(Fp,this,e[0])},exactPartial(...e){return po(Lp,this,e[0],`exactPartial`)},required(...e){return mo(Gp,this,e[0])}});function xp(e,t){return new bp({type:`object`,shape:e??{},...R(t)})}function Sp(e,t){return new bp({type:`object`,shape:e,catchall:_p(),...R(t)})}var Cp=B(`ZodUnion`,(e,t)=>{wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lf(e,t,n,r),e.options=t.options});function wp(e,t){return new Cp({type:`union`,options:e,...R(t)})}var Tp=B(`ZodDiscriminatedUnion`,(e,t)=>{Cp.init(e,t),El.init(e,t)});function Ep(e,t,n){return new Tp({type:`union`,options:t,discriminator:e,...R(n)})}var Dp=B(`ZodIntersection`,(e,t)=>{Dl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uf(e,t,n,r)});function Op(e,t){return new Dp({type:`intersection`,left:e,right:t})}var kp=B(`ZodEnum`,(e,t)=>{Al.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new kp({...t,checks:[],...R(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new kp({...t,checks:[],...R(r),entries:i})}});function Ap(e,t){return new kp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...R(t)})}var jp=B(`ZodLiteral`,(e,t)=>{jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nf(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Mp(e,t){return new jp({type:`literal`,values:Array.isArray(e)?e:[e],...R(t)})}var Np=B(`ZodTransform`,(e,t)=>{If(),Ml.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Wo(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Eo(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Eo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Pp(e){return new Np({type:`transform`,transform:e})}var Fp=B(`ZodOptional`,(e,t)=>{Pl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new Fp({type:`optional`,innerType:e})}var Lp=B(`ZodExactOptional`,(e,t)=>{Fl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rp(e){return new Lp({type:`optional`,innerType:e})}var zp=B(`ZodNullable`,(e,t)=>{Il.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>df(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bp(e){return new zp({type:`nullable`,innerType:e})}var Vp=B(`ZodDefault`,(e,t)=>{Ll.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hp(e,t){return new Vp({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Up=B(`ZodPrefault`,(e,t)=>{zl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wp(e,t){return new Up({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Za(t)}})}var Gp=B(`ZodNonOptional`,(e,t)=>{Bl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kp(e,t){return new Gp({type:`nonoptional`,innerType:e,...R(t)})}var qp=B(`ZodCatch`,(e,t)=>{Ul.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_f(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Jp(e,t){return new qp({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Ro(t)})}var Yp=B(`ZodPipe`,(e,t)=>{Wl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vf(e,t,n,r),e.in=t.in,e.out=t.out});function Xp(e,t){return new Yp({type:`pipe`,in:e,out:t})}var Zp=B(`ZodReadonly`,(e,t)=>{Kl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qp(e){return new Zp({type:`readonly`,innerType:e})}var $p=B(`ZodCustom`,(e,t)=>{Jl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r)});function em(e,t={}){return yd($p,e,t)}function tm(e,t){return bd(e,t)}var nm=`no-project`;function rm(){return X.parseLocation(X.history.location).search}function im(){let e=/^\/terminal\/([^/]+)$/.exec(X.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Z().machines.some(e=>e.id===t)?t:null}function am(){let e=sr({strict:!1,select:e=>e.machine??null});return Fh(t=>t.machines.some(t=>t.id===e)?e:null)}function om(){return rm().project??`global`}function sm(){return cr({strict:!1,select:e=>e.project??`global`})}function cm(e){let t=rm();return t.machine===void 0||t.project===void 0||!e.includes(t.machine)?null:{machine:t.machine,projectId:t.project,sessionId:t.session??null}}function lm(e){Em({...rm(),...e},!0,X.history.location.state.layer)}function um(e,t){Em({...rm(),...e},!1,t)}function dm(e){let t=Z();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){lm({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){lm({panel:`browser`,browse:e});return}let n=Lh(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);lm({panel:`browser`,browse:`${n.path}/${e}`})}function fm(e,t){X.history.location.state.layer===e?X.history.back():t()}var pm=[],mm=!1,hm=!1,gm=!1;function _m(){return X.history.location.state.guard===!0}function vm(){return gm}function ym(){mm||(pm.length>0&&!_m()?X.history.push(X.history.location.href,{guard:!0}):pm.length===0&&_m()&&(mm=!0,X.history.back()))}function bm(){hm=_m(),X.history.subscribe(({action:e})=>{let t=hm;hm=_m(),e.type===`PUSH`||e.type===`REPLACE`?gm=!1:(gm=t,gm&&mm?mm=!1:gm&&pm.at(-1)?.(),setTimeout(ym))}),setTimeout(ym)}function xm(e,t){let n=(0,j.useEffectEvent)(t);(0,j.useEffect)(()=>{if(!e)return;function t(){n()}return pm.push(t),setTimeout(ym),()=>{pm.splice(pm.indexOf(t),1),setTimeout(ym)}},[e])}var Sm=`terminalProjects`;function Cm(){return JSON.parse(localStorage.getItem(Sm)??`[]`)}function wm(){let e=rm();if(im()!==null||e.machine===void 0||e.project===void 0||e.session===void 0)return;let t=`${e.machine} ${e.project}`,n=Cm().filter(e=>e!==t);localStorage.setItem(Sm,JSON.stringify(e.bottom===`terminal`?[...n,t]:n))}function Tm(e=!1){let t=Z().selection;if(t===null){Em({project:im()===null?void 0:rm().project},!0,X.history.location.state.layer);return}let n=rm(),r=n.machine===t.machine&&n.project===t.projectId&&n.session===void 0&&(t.sessionId===null||Z().loaded),i=Cm().includes(`${t.machine} ${t.projectId}`),a={machine:t.machine,project:t.projectId,session:t.sessionId??void 0,bottom:r?n.bottom:t.sessionId!==null&&i?`terminal`:void 0};if(im()!==null){X.navigate({to:`/`,search:a,replace:e||_m(),state:{layer:`chat`},resetScroll:!1});return}let o=n.machine===a.machine&&n.project===a.project&&n.session===a.session,s=n.machine!==void 0&&n.session===void 0&&a.session===void 0;e||o||r||s?lm(a):um(a,`chat`)}function Em(e,t,n){let r=im(),i=_m(),a=t&&i?{layer:n,guard:i}:{layer:n};r===null?X.navigate({to:`/`,search:e,replace:t||i,state:a,resetScroll:!1}):X.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t||i,state:a,resetScroll:!1})}function Dm(e,t=null,n=!1){let r=Ih(Z(),e.machine),i=Z().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),Q({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?i?.sessionId===null&&i.machine===e.machine?Z().settings:tg(r):Sa(Uh(e))??eg(r.lastUsed,Z().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??tg(r).provider),context:null,replacing:null,paletteOpen:!1,unseen:Z().unseen.filter(t=>e.sessionId===null||t!==oh(e.machine,e.sessionId))}),Tm(n),og(e.machine),e.sessionId!==null&&r.status===`online`&&Om(e.machine,e.projectId,e.sessionId,!0,t)}function Om(e,t,n,r,i){F(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Z().sessions.some(n=>n.machine===e&&n.id===t.id)||Q({sessions:[...Z().sessions,{...t,machine:e}]})}).catch($)}function km(){Q({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),Tm()}function Am(){let e=Z().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function jm(e,t,n=!1){Dm({machine:e,projectId:Lh(Z(),e,t)?.scratch===!0?nm:t,sessionId:null},null,n)}function Mm(){let e=Z(),t=localStorage.getItem(`lastProject`),n=t===null?null:JSON.parse(t),r=e.machines.filter(e=>e.system?.scratchAvailable===!0);if(n!==null&&n.projectId===`no-project`&&r.some(e=>e.id===n.machine))return n;let i=(n===null?void 0:e.projects.find(e=>e.machine===n.machine&&e.id===n.projectId))??e.projects.find(e=>!e.scratch);return i===void 0?r.length>0?{machine:r[0].id,projectId:nm}:null:{machine:i.machine,projectId:i.id}}function Nm(e,t){let n=im();(n!==e||om()!==t)&&(X.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null||_m(),state:{layer:`chat`},resetScroll:!1}),km())}async function Pm(e,t,n,r){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),Q({sentAt:Date.now()}),await F(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t});let i=Z().replacing;n.sessionId===null&&i!==null&&i.machine===n.machine&&i.sessionId!==null&&(Q({replacing:null}),await Km(i.machine,i.sessionId,i.projectId))}function Fm(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function Im(e){let t=Z().selection;t!==null&&t.sessionId!==null&&F(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function Lm(){let e=Z().selection;e!==null&&e.sessionId!==null&&F(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function Rm(e,t,n){F(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function zm(e,t,n){let r=Z().selection;r!==null&&r.sessionId!==null&&F(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function Bm(e){let t=Z().selection;if(t!==null&&t.sessionId!==null)try{let n=await F(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});Dm({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function Vm(){let e=Z().selection,t=Z().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await F(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Z().selection!==e||Z().before!==t)return;Q({earlier:[...n.items,...Z().earlier],before:n.before})}catch(e){$(e)}}async function Hm(e,t){let n=Z().selection;if(n!==null&&n.sessionId!==null)try{let r=await F(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Z().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Z().items;Q({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function Um(e,t,n){let r=Z();function i(n){return n.machine===e&&n.id===t}let a=[...r.sessions,...r.inactive].find(i);if(a!==void 0){let e={...a,...n};Q({sessions:r.sessions.some(i)?r.sessions.map(t=>i(t)?e:t):e.status===`inactive`?r.sessions:[...r.sessions,e],inactive:e.status===`inactive`?r.inactive.some(i)?r.inactive.map(t=>i(t)?e:t):[e,...r.inactive]:r.inactive.filter(e=>!i(e))})}try{await F(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function Wm(e){let t=oh(e.machine,e.id);Q({generatingTitles:[...Z().generatingTitles,t]});try{await F(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{Q({generatingTitles:Z().generatingTitles.filter(e=>e!==t)})}}async function Gm(e,t,n){let r=Z().selection;if(r?.machine===e&&r.sessionId===t){let i=Z().sessions.filter(r=>(r.status===`pinned`||r.status===`active`||r.status===`snoozed`)&&(r.machine!==e||r.id!==t)&&(n===null||r.machine===n.machine&&(r.projectId===n.projectId||n.projectId===`no-project`&&Lh(Z(),r.machine,r.projectId)?.scratch===!0))).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);i===void 0?jm(r.machine,r.projectId,!0):Dm({machine:i.machine,projectId:i.projectId,sessionId:i.id},null,!0)}await Um(e,t,{status:`inactive`})}async function Km(e,t,n){Q({sessions:Z().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Z().inactive.filter(n=>n.machine!==e||n.id!==t)}),ba(oh(e,t));let r=Z().selection;r?.machine===e&&r.sessionId===t&&jm(e,r.projectId,!0);try{await F(e,`sessions.remove`,{id:t,projectId:n})}catch(e){$(e)}}var qm=xp({machine:zf().optional().catch(void 0),project:zf().optional().catch(void 0),session:zf().optional().catch(void 0),panel:Ap([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:zf().optional().catch(void 0),bottom:Mp(`terminal`).optional().catch(void 0),terminal:zf().optional().catch(void 0)}),Jm=Ar({validateSearch:qm}),Ym=Or({getParentRoute:()=>Jm,path:`/`}),Xm=Or({getParentRoute:()=>Jm,path:`/terminal`,beforeLoad:()=>{let e=Am();throw ke(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),Zm=Or({getParentRoute:()=>Jm,path:`/terminal/$machine`});if(window.history.state?.__TSR_index===void 0&&(location.pathname.startsWith(`/terminal`)||new URLSearchParams(location.search).has(`machine`))){let e=`${location.pathname}${location.search}${location.hash}`,t=Math.random().toString(36).slice(2),n=Math.random().toString(36).slice(2);window.history.replaceState({__TSR_index:0,__TSR_key:t,key:t},``,`/`),window.history.pushState({__TSR_index:1,__TSR_key:n,key:n,layer:`chat`},``,e)}var X=Mr({routeTree:Jm.addChildren([Ym,Xm,Zm]),disableGlobalCatchBoundary:!0,parseSearch:e=>qm.parse(Object.fromEntries(new URLSearchParams(e))),stringifySearch:e=>{let t=new URLSearchParams;for(let n of Object.entries(e))n[1]!==void 0&&t.set(n[0],String(n[1]));let n=t.toString();return n===``?``:`?${n}`}}),Qm=fi.withTag(`machines`),$m=`machines`,eh=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function th(){let e=localStorage.getItem($m);return e===null?[]:JSON.parse(e)}function nh(e){localStorage.setItem($m,JSON.stringify(e))}async function rh(e){if(!(`caches`in window))return;let t=e.map(e=>({id:e.id,addresses:e.addresses}));await(await caches.open(`offsite-worker`)).put(`/machines`,new Response(JSON.stringify(t)))}function ih(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));X.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:ah(t).address,code:e.get(`code`)}}function ah(e){let t=e.trim(),n=new URL(/^[a-z]+:\/\//i.test(t)?t:`http://${t}`);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`Use an http:// or https:// address`);let r=new URLSearchParams(n.hash.slice(1)),i=r.get(`machine`);return{address:i===null?n.origin:ah(i).address,code:r.get(`code`)}}function oh(e,t){return`${e} ${t}`}function sh(e){return{id:e.id,addresses:e.addresses,via:null,status:`connecting`,name:e.label??e.name,hostname:e.name,label:e.label,icon:e.icon,pairedAt:e.pairedAt??null,config:null,lastUsed:null,appIcon:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function ch(e){return e.projects.map(t=>({...t,machine:e.id}))}function lh(){let e=th(),t=Z().machines;for(let n of t)e.some(e=>e.id===n.id)||vh(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Z();Q({machines:[...e.machines,sh(n)],projects:[...e.projects,...ch(n)]}),Ni(n.id,n.addresses)}else zh(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(zh(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),gh(n.id))}let n=e.map(e=>e.id);Q({machines:[...Z().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function uh(e,t){let n=Z().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await dh(n.id,t),n.id;let r=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);return t!==null&&await ai(r,await fh(e,t)),Q({machines:[...Z().machines,sh({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),yh(),Ni(r,e),r}async function dh(e,t){await ai(e,await fh(Ih(Z(),e).addresses,t)),zh(e,{pairedAt:Date.now()}),yh(),gh(e)}async function fh(e,t){let n;for(let r of e){let e=await fetch(`${r}/api/pair`,{method:`POST`,headers:{authorization:`Bearer ${t}`}}).catch(e=>(n??=e,null));if(e!==null){if(!e.ok)throw Error(await e.text());return(await e.json()).token}}throw Error(`Could not reach the machine to pair: ${String(n)}`)}function ph(e,t){let n=Ih(Z(),e),r={...n,...t};zh(e,{...t,name:r.label??r.hostname}),yh(),r.addresses.join(` `)!==n.addresses.join(` `)&&gh(e)}function mh(e){Q({machines:[...Z().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),yh()}function hh(e){rh(e).catch(e=>Qm.error(`could not share the machines with the service worker`,e))}function gh(e){Pi(e),zh(e,{status:`connecting`,via:null}),Ni(e,Ih(Z(),e).addresses)}function _h(e){vh(e),yh(),oi(e).catch(e=>Qm.error(`could not remove the device token`,e))}function vh(e){Pi(e);let t=Z(),n=t.machines.filter(t=>t.id!==e);Q({machines:n,projects:t.projects.filter(t=>t.machine!==e),sessions:t.sessions.filter(t=>t.machine!==e),inactive:t.inactive.filter(t=>t.machine!==e),unseen:t.unseen.filter(t=>!t.startsWith(`${e} `)),...t.settingsMachine===e&&{settingsMachine:n.at(0)?.id??null},...t.selection?.machine===e&&{selection:null}}),Tm()}function yh(){let e=Z(),t=e.machines.map(t=>({id:t.id,addresses:t.addresses,name:t.hostname,label:t.label,icon:t.icon,pairedAt:t.pairedAt,projects:e.projects.filter(e=>e.machine===t.id).map(e=>({id:e.id,path:e.path,name:e.name,logo:e.logo,hidden:e.hidden,scratch:e.scratch}))}));nh(t),hh(t)}var bh=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}],xh=fi.withTag(`prefs`),Sh=Sp({theme:zf().refine(e=>bh.some(t=>t.id===e)).default(bh[0].id),terminal:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(14),lineHeight:up().default(1.35),ligatures:Y().default(!0)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),padding:Sp({top:up().default(4),right:up().default(4),bottom:up().default(0),left:up().default(4)}).prefault({}),scrollback:up().default(1e3),boldIsBright:Y().default(!0),behavior:Sp({modernizeShiftEnter:Y().default(!0),pasteBrowserImages:Y().default(!0),captureShortcuts:Y().default(!0),bellFlash:Y().default(!0),bellSound:Y().default(!0),clickToMoveCursor:Y().default(!0),optionAsMeta:Ap([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:Y().default(!0),confirmCloseBusyTab:Y().default(!0)}).prefault({})}).prefault({}),editor:Sp({font:Sp({family:zf().default(`FiraCode Nerd Font`),size:up().default(15.3),lineHeight:up().default(1.8),ligatures:Y().default(!0),features:zf().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:Sp({style:Ap([`block`,`bar`,`underline`]).default(`bar`),blink:Y().default(!0)}).prefault({}),tabSize:up().default(2),wordWrap:Y().default(!0),graph:Y().default(!0)}).prefault({}),diff:Sp({split:Y().default(!1),wrap:Y().default(!0),collapsed:Y().default(!1)}).prefault({}),rewind:Ap([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:Y().default(!1),dictateButton:Sp({desktop:Y().default(!1),mobile:Y().default(!0)}).prefault({}),toolbar:yp(Ap([`diff`,`terminal`,`tasks`,`browser`,`editor`])).default([`diff`,`terminal`,`editor`])}),Ch=`prefs`,wh=Sh.parse({});function Th(){let e=localStorage.getItem(Ch);if(e===null)return structuredClone(wh);let t=Sh.safeParse(JSON.parse(e));return t.success?t.data:(xh.warn(`invalid stored prefs, using the defaults:\n${rs(t.error)}`),structuredClone(wh))}function Eh(e){localStorage.setItem(Ch,JSON.stringify(e))}function Dh(){let e=Z().prefs.theme,t=bh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function Oh(){let e=Fh(e=>e.prefs.theme),t=bh.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function kh(){let e=Dh(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}var Ah=fi.withTag(`ui`),jh={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},Mh;function Nh(e){Mh=ea()(()=>e)}function Ph(e){return Mh.subscribe(e)}function Z(){return Mh.getState()}function Fh(e){return na(Mh,e)}function Q(e){Mh.setState(e)}function Ih(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function Lh(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function Rh(e){return e.selection?.machine??e.machines.at(0)?.id??null}function zh(e,t){Q({machines:Z().machines.map(n=>n.id===e?{...n,...t}:n)})}function Bh(e,t,n){if(n!==null)return e.find(e=>e.id===t)?.activity[n]}function Vh(e){let t=e.selection;if(t!==null)return Bh(e.machines,t.machine,t.sessionId)}function Hh(e){return Vh(e)?.running===!0}function Uh(e){return e.sessionId===null?`new`:oh(e.machine,e.sessionId)}function Wh(e){Q({draft:e})}function Gh(e){Q({paletteOpen:e})}function Kh(e){Q({editor:e})}function qh(e){Q({exporting:e})}function Jh(e){Q({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:Rh(Z()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function Yh(e){Q({usageOpen:e,paletteOpen:!1})}function Xh(e){Q({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Z().settingsOpen&&{settingsMachine:Rh(Z())}})}function Zh(e){Q({prefs:e}),Eh(e),kh()}function $(e){Ah.warn(`showing an error:`,e),Q({errors:[...Z().errors,i(e)]})}function Qh(){Q({errors:[]})}var $h=null;function eg(e,t){let n=e?.find(e=>e.provider===t),r=t===`claude`?Yi:t===`codex`?Xi:null;return n===void 0?{provider:t,accountId:null,model:null,effort:null,mode:r,plan:!1}:{provider:t,accountId:n.accountId,model:n.model,effort:null,mode:r,plan:!1}}function tg(e){let t=Zi(e.lastUsed??[],e=>e.usedAt);return t===void 0?{provider:Ji,accountId:null,model:null,effort:null,mode:Yi,plan:!1}:eg(e.lastUsed,t.provider)}function ng(e,t,n,r){F(e,`lastUsed.save`,{provider:t,accountId:n,model:r}).catch($);let i=Z().machines.filter(t=>t.id!==e&&t.status===`online`);if(t===`opencode`){for(let e of i.filter(e=>e.openCode.available))F(e.id,`lastUsed.save`,{provider:t,accountId:null,model:r}).catch($);return}let a=Ih(Z(),e),o=(t===`claude`?a.claudeAccounts:a.codexAccounts).find(e=>e.id===n)?.identity;if(o!=null)for(let e of i){let n=(t===`claude`?e.claudeAccounts:e.codexAccounts).find(e=>e.enabled&&e.identity!==null&&e.identity.accountId===o.accountId&&e.identity.organizationId===o.organizationId);n!==void 0&&F(e.id,`lastUsed.save`,{provider:t,accountId:n.id,model:r}).catch($)}}function rg(e){let t={...Z().settings,...e};Q({settings:t});let n=Z().selection;n!==null&&(n.sessionId!==null&&Ca(Uh(n),t),e.accountId!==void 0&&cg(),n.sessionId!==null&&Bh(Z().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&F(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($))}function ig(e,t){if(zh(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Z().selection?.machine!==e)return;let n=Z().settings,r=[...[...t.claudeAccounts,...t.codexAccounts].filter(e=>e.valid).map(e=>({provider:e.provider,accountId:e.id})),...t.openCode.available?[{provider:`opencode`,accountId:null}]:[]];if(r.some(e=>e.provider===n.provider&&e.accountId===n.accountId))return;let i=r.find(e=>e.provider===n.provider),a=Z().selection?.sessionId===null?r.at(0):void 0;i===void 0?a===void 0?n.accountId!==null&&rg({accountId:null}):rg({...eg(Ih(Z(),e).lastUsed,a.provider),accountId:a.accountId}):rg({accountId:i.accountId})}function ag(e){let t=Z().selection;t?.machine===e&&t.sessionId===null&&(Q({settings:tg(Ih(Z(),e))}),og(e))}function og(e){let t=Ih(Z(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&ig(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),cg()}async function sg(e){try{ig(e,await F(e,`accounts.list`,void 0))}catch(e){$(e)}}async function cg(){let e=Z().selection;if(e===null)return;let{provider:t,accountId:n}=Z().settings;if(t!==`opencode`&&n===null)Q({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if($h?.key!==r){let i=F(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){$h?.result===i&&($h=null)}i.then(a,a),$h={key:r,result:i}}let i=await $h.result;if(Z().selection?.machine!==e.machine||Z().selection?.projectId!==e.projectId||Z().settings.provider!==t||Z().settings.accountId!==n)return;Q({capabilities:i});let a=Z().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&rg({effort:e});return}let o=i.models.find(e=>!e.hidden&&e.value===i.defaultModel)??i.models.find(e=>!e.hidden);if(o===void 0)return;rg({model:o.value,...o.effort===null?{}:{effort:o.effort}})}catch(e){$(e)}}var lg=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{ch as $,Da as $t,Q as A,Tm as At,eh as B,xp as Bt,$ as C,Oe as Cn,vm as Ct,Xh as D,lm as Dt,Jh as E,c as En,wm as Et,Oh as F,sm as Ft,ih as G,Sa as Gt,th as H,ka as Ht,wh as I,nm as It,lh as J,ya as Jt,yh as K,Ta as Kt,Th as L,Y as Lt,Fh as M,om as Mt,kh as N,xm as Nt,Yh as O,cm as Ot,Dh as P,am as Pt,sh as Q,Ca as Qt,bh as R,Ep as Rt,Kh as S,_t as Sn,fm as St,Gh as T,D as Tn,um as Tt,oh as U,_a as Ut,ph as V,zf as Vt,dh as W,xa as Wt,_h as X,Oa as Xt,gh as Y,ha as Yt,mh as Z,va as Zt,jh as _,cr as _n,jm as _t,cg as a,Ni as an,Bm as at,Wh as b,On as bn,Fm as bt,ig as c,Li as cn,Hm as ct,Rh as d,fi as dn,Dm as dt,ga as en,hh as et,Qh as f,mi as fn,Nm as ft,Lh as g,Pr as gn,Pm as gt,Ih as h,ti as hn,zm as ht,sg as i,F as in,Um as it,Zh as j,im as jt,Ph as k,bm as kt,Bh as l,Ri as ln,Vm as lt,Z as m,ei as mn,Km as mt,rg as n,Yi as nn,km as nt,ag as o,Ii as on,Lm as ot,Uh as p,Zr as pn,Wm as pt,ah as q,Ea as qt,eg as r,Ji as rn,Gm as rt,ng as s,Fi as sn,Mm as st,lg as t,wa as tn,X as tt,Nh as u,ji as un,Om as ut,Vh as v,tr as vn,Im as vt,qh as w,O as wn,dm as wt,zh as x,Dn as xn,rm as xt,Hh as y,An as yn,Rm as yt,uh as z,Mp as zt};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{a as t,i as n,n as r}from"./dist-D99rUXSZ.js";import{n as i,r as a,t as o}from"./TextWrapIcon-BRhMbXe9.js";import{t as s}from"./ChevronsDownUpIcon-BNVFd2te.js";import{F as c,M as l,in as u,j as d,m as f,t as p}from"./XIcon-gbQKQqpC.js";import{a as m,t as h}from"./button-CWFREsRn.js";import{An as g,Ft as _,G as v,Gn as y,N as b,P as x,W as S,Wn as C,at as w,cn as T,gt as E,ot as D,zt as O}from"./dist-Jliw2AH0.js";import{c as k,l as A,r as j}from"./utils-U6QfaJBO.js";function M(e,t){let n=0;for(let r=0;r<e.length;r++)n+=t(e[r],r);return n}var N=[[`path`,{d:`M18.2505 10.5H19.6403C21.4918 10.5 22.0421 10.7655 21.9975 12.0838C21.9237 14.2674 20.939 16.8047 17 17.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M5.94627 20.6145C2.57185 18.02 2.07468 14.3401 2.00143 10.5001C1.96979 8.8413 2.45126 8.5 4.65919 8.5H15.3408C17.5487 8.5 18.0302 8.8413 17.9986 10.5001C17.9253 14.3401 17.4281 18.02 14.0537 20.6145C13.0934 21.3528 12.2831 21.5 10.9194 21.5H9.08064C7.71686 21.5 6.90658 21.3528 5.94627 20.6145Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M11.3089 2.5C10.7622 2.83861 10.0012 4 10.0012 5.5M7.53971 4C7.53971 4 7 4.5 7 5.5M14.0012 4C13.7279 4.1693 13.5 5 13.5 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],P=[[`path`,{d:`M3.89124 3.89124C5.28249 2.5 7.52166 2.5 12 2.5C16.4783 2.5 18.7175 2.5 20.1088 3.89124C21.5 5.28249 21.5 7.52166 21.5 12C21.5 16.4783 21.5 18.7175 20.1088 20.1088C18.7175 21.5 16.4783 21.5 12 21.5C7.52166 21.5 5.28249 21.5 3.89124 20.1088C2.5 18.7175 2.5 16.4783 2.5 12C2.5 7.52166 2.5 5.28249 3.89124 3.89124Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 2.5V21.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}]],F=[[`path`,{d:`M2.49219 15.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M2.49219 8.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M2.49219 12C2.49219 7.52166 2.49219 5.28249 3.88343 3.89124C5.27467 2.5 7.51384 2.5 11.9922 2.5C16.4705 2.5 18.7097 2.5 20.1009 3.89124C21.4922 5.28249 21.4922 7.52166 21.4922 12C21.4922 16.4783 21.4922 18.7175 20.1009 20.1088C18.7097 21.5 16.4705 21.5 11.9922 21.5C7.51384 21.5 5.27467 21.5 3.88343 20.1088C2.49219 18.7175 2.49219 16.4783 2.49219 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}]],I=e(A(),1);function L(e){let t=(0,I.useRef)(e);return(0,I.useInsertionEffect)(()=>void(t.current=e)),(0,I.useCallback)((...e)=>t.current(...e),[])}var R=k(),z=(0,I.createContext)(void 0);function ee(){return(0,I.useContext)(z)}var B={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},V={display:`contents`};function H(){return null}function U({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:f=O}){let p=n?.(e),m=r?.(e),h=i?.(e),_=a?.(e);return(0,R.jsxs)(R.Fragment,{children:[p==null?(0,R.jsxs)(R.Fragment,{children:[m!=null&&(0,R.jsx)(`div`,{slot:`header-prefix`,children:m}),h!=null&&(0,R.jsx)(`div`,{slot:`header-filename-suffix`,children:h}),_!=null&&(0,R.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,R.jsx)(`div`,{slot:g,children:p}),o!=null&&l?.map((t,n)=>(0,R.jsx)(`div`,{slot:f(t),children:o(t,e)},n)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=te(t,e);return(0,R.jsx)(`div`,{slot:n,style:V,children:c(t,d)},n)}),s!=null&&(0,R.jsx)(`div`,{slot:`gutter-utility-slot`,style:B,children:s(u)})]})}function te(e,t){let n=b(e,t);return n==null?void 0:x({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var ne=(0,I.createContext)(void 0);function re(e,t){return typeof window>`u`&&t!=null?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,R.jsx)(R.Fragment,{children:e})}var ie=(0,I.createContext)(void 0);function W(){return(0,I.useContext)(ie)}function G(){let[e]=(0,I.useState)(()=>{let e=0,t;return{getSnapshot:()=>e,subscribe(e){return t=e,()=>{t=void 0}},forceUpdate(){e++,t?.()}}});return(0,I.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),e.forceUpdate}function K(e,t){"use no memo";return e.current?.__getNextRenderData(t)}var q=typeof window>`u`?I.useEffect:I.useLayoutEffect;function J({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:m,onEditComplete:h}){let g=W(),_=s!==void 0,b=(0,I.useContext)(ne),x=ee(),[C,w]=(0,I.useState)(),E=L(e=>m?.(e)),D=m==null?void 0:E,k=(0,I.useRef)(null),A=L(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(k.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),j=h==null?void 0:A,M=ae({acceptedCache:k,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),N=(0,I.useRef)(null),P=G(),F=K(N,oe(k,M,o))??{fileDiff:M,lineAnnotations:o??y},R=(0,I.useRef)(null),z=(0,I.useRef)(null),B=L(()=>{if(x==null)throw Error(`FileDiff: EditContext is not attached`);return x(`file-diff`,i??{},a)}),V=L(e=>{if(e!=null){if(N.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?N.current=new v(Z({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:D,onEditComplete:j,options:r}),f?void 0:b,P):N.current=new S(Z({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:D,onEditComplete:j,options:r}),g,l,f?void 0:b,P),N.current.hydrate({fileDiff:M,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(N.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);z.current=null,N.current.cleanUp(),N.current=null,R.current=null}});q(()=>{let{current:e}=N;if(e==null)return;let t=Z({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:D,onEditComplete:j,options:r}),n=!T(e.options,t);if(e.setOptions(t),!p&&(z.current=null,R.current!=null)){let{current:e}=R;R.current=null,e()}let i=se(M,o,k);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||R.current!=null)return;if(x==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{N.current===e&&R.current==null&&e.__canAttachEditor()&&(R.current=Q(e,B),P())};if(e.__canAttachEditor()){z.current=null,a();return}let c=e.__prepareForEditing();if(c==null){z.current=null;return}if(z.current?.promise===c)return;let l={promise:c};z.current=l,c.then(()=>{z.current===l&&(a(),z.current=null)}).catch(e=>{z.current===l&&(z.current=null,w(e))})});let H=(0,I.useCallback)(()=>N.current?.getHoveredLine(),[]),U=(0,I.useCallback)(e=>N.current?.getAnnotationSlotName(e)??O(e),[]);if(C!=null)throw C;return{...F,ref:V,getHoveredLine:H,getAnnotationSlotName:U}}function ae({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,I.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(Y(r,n,o.stale)||Y(r,n,o.installed))return o.fileDiff;a.filePair=null}return w(r??null,n??null,i)},[e,t,r,n,i])}function Y(e,t,n){return _(e??void 0,n.oldFile??void 0)&&_(t??void 0,n.newFile??void 0)}function oe(e,t,n){"use no memo";return X(t,n,e.current)}function X(e,t,n){return{fileDiff:n?.fileDiff!=null&&E(e,n.fileDiff.stale)?n.fileDiff.installed:e,lineAnnotations:n?.annotations!=null&&t===n.annotations.stale?n.annotations.installed:t}}function se(e,t,n){let{current:r}=n,i=X(e,t,r);return r==null||(r.fileDiff!=null&&!E(e,r.fileDiff.stale)&&(r.fileDiff=null),t!==r.annotations?.stale&&(r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null)),i}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return{...e,controlledSelection:t,renderCustomHeader:n?H:e?.renderCustomHeader,renderGutterUtility:r?H:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}}function Q(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function ce({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1,onEditChange:v,onEditComplete:y}){let{ref:b,getHoveredLine:x,getAnnotationSlotName:S,fileDiff:w,lineAnnotations:T}=J({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_,onEditChange:v,onEditComplete:y}),E=U({fileDiff:w,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,renderGutterUtility:h,lineAnnotations:T,getHoveredLine:x,getAnnotationSlotName:S});return(0,R.jsx)(C,{ref:b,className:s,style:c,children:re(E,l)})}var le=3e3,ue=`text-foreground hover:bg-accent aria-pressed:bg-accent inline-flex h-7 min-w-7 cursor-pointer items-center justify-center rounded-lg px-1.5 [&_svg]:opacity-80`,$=`text-muted-foreground hover:text-foreground aria-pressed:bg-background aria-pressed:text-foreground dark:aria-pressed:bg-input/72 inline-flex h-6 cursor-pointer items-center justify-center rounded-md px-2.5 aria-pressed:shadow-xs`;function de(e){let[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(null),[b,x]=(0,I.useState)(0),S=(0,I.useRef)({patch:null,count:0}),C=l(e=>e.prefs.diff),w=c(),[T,E]=r(`diffFlipped`,[]);function O(e){d({...f().prefs,diff:{...C,...e}})}(0,I.useEffect)(()=>{let t=!0,n=!1;async function r(){if(!n){n=!0;try{let n=await u(e.machine,`git.diff`,{projectId:e.projectId});if(!t||(y(null),n===S.current.patch))return;S.current={patch:n,count:S.current.count+1},_(n.trim()===``?[]:D(n,`${e.projectId}:${S.current.count}`).flatMap(e=>e.files))}catch(e){t&&y(j(e))}finally{n=!1}}}function i(){document.hidden||r()}r();let a=window.setInterval(i,le);return window.addEventListener(`focus`,i),()=>{t=!1,window.clearInterval(a),window.removeEventListener(`focus`,i)}},[e.machine,e.projectId,e.running,b]);let k=g??[],A=M(k,e=>M(e.hunks,e=>e.additionLines)),L=M(k,e=>M(e.hunks,e=>e.deletionLines));return(0,R.jsxs)(`div`,{className:`bg-background flex h-full min-h-0 min-w-0 flex-col`,children:[(0,R.jsxs)(`div`,{className:`border-border/60 bg-background flex h-(--workspace-topbar-height) shrink-0 items-center justify-between gap-2 border-b pr-3 pl-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(h,{size:`icon-sm`,variant:`ghost`,title:`Close`,"aria-label":`Close`,onClick:e.onClose,children:(0,R.jsx)(m,{icon:p,className:`size-4`})}),(0,R.jsx)(`span`,{className:`text-foreground min-w-0 truncate text-xs font-medium`,children:`Uncommitted changes`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[k.length>0&&(0,R.jsxs)(`span`,{className:`text-2xs mr-1 inline-flex items-center gap-1 font-mono tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`text-diff-addition`,children:[`+`,A]}),(0,R.jsxs)(`span`,{className:`text-diff-deletion`,children:[`-`,L]})]}),(0,R.jsx)(h,{size:`icon-sm`,variant:`ghost`,title:`Refresh diff`,"aria-label":`Refresh diff`,onClick:()=>x(b+1),children:(0,R.jsx)(m,{icon:i,className:`size-4`})}),k.length>0&&(0,R.jsx)(h,{size:`icon-sm`,variant:`ghost`,title:C.collapsed?`Expand all files`:`Collapse all files`,onClick:()=>{E([]),O({collapsed:!C.collapsed})},children:(0,R.jsx)(m,{icon:C.collapsed?n:s,className:`size-4`})}),(0,R.jsxs)(`div`,{className:`bg-input/40 flex shrink-0 items-center rounded-lg p-0.5`,children:[(0,R.jsx)(`button`,{className:$,"aria-pressed":!C.split,"aria-label":`Stacked diff view`,onClick:()=>O({split:!1}),children:(0,R.jsx)(m,{icon:F,className:`size-3.5`})}),(0,R.jsx)(`button`,{className:$,"aria-pressed":C.split,"aria-label":`Split diff view`,onClick:()=>O({split:!0}),children:(0,R.jsx)(m,{icon:P,className:`size-3.5`})})]}),(0,R.jsx)(`button`,{className:ue,"aria-pressed":C.wrap,title:C.wrap?`Disable line wrapping`:`Enable line wrapping`,onClick:()=>O({wrap:!C.wrap}),children:(0,R.jsx)(m,{icon:o,className:`size-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`diff-render-surface min-h-0 flex-1 overflow-y-auto [--code-background:var(--background)]`,children:[v!==null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:v}),v===null&&g===null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:`Loading…`}),v===null&&g?.length===0&&(0,R.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,R.jsx)(m,{icon:N,className:`text-muted-foreground/40 size-8`}),(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No uncommitted changes`}),(0,R.jsx)(`p`,{className:`text-muted-foreground/50 text-xs italic`,children:`If it works, don’t touch it.`})]})]}),v===null&&k.map(e=>{let n=C.collapsed!==T.includes(e.name);function r(){E(T.includes(e.name)?T.filter(t=>t!==e.name):[...T,e.name])}return(0,R.jsx)(`div`,{onClick:e=>{e.nativeEvent.composedPath().some(e=>e instanceof Element&&e.hasAttribute(`data-title`))&&r()},children:(0,R.jsx)(ce,{fileDiff:e,options:{theme:w,themeType:`dark`,unsafeCSS:`:host,
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{a as t,i as n,n as r}from"./dist-D99rUXSZ.js";import{n as i,r as a,t as o}from"./TextWrapIcon-BRhMbXe9.js";import{t as s}from"./ChevronsDownUpIcon-BNVFd2te.js";import{F as c,M as l,in as u,j as d,m as f,t as p}from"./XIcon-CDJz0EhT.js";import{a as m,t as h}from"./button-CWFREsRn.js";import{An as g,Ft as _,G as v,Gn as y,N as b,P as x,W as S,Wn as C,at as w,cn as T,gt as E,ot as D,zt as O}from"./dist-Jliw2AH0.js";import{c as k,l as A,r as j}from"./utils-U6QfaJBO.js";function M(e,t){let n=0;for(let r=0;r<e.length;r++)n+=t(e[r],r);return n}var N=[[`path`,{d:`M18.2505 10.5H19.6403C21.4918 10.5 22.0421 10.7655 21.9975 12.0838C21.9237 14.2674 20.939 16.8047 17 17.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M5.94627 20.6145C2.57185 18.02 2.07468 14.3401 2.00143 10.5001C1.96979 8.8413 2.45126 8.5 4.65919 8.5H15.3408C17.5487 8.5 18.0302 8.8413 17.9986 10.5001C17.9253 14.3401 17.4281 18.02 14.0537 20.6145C13.0934 21.3528 12.2831 21.5 10.9194 21.5H9.08064C7.71686 21.5 6.90658 21.3528 5.94627 20.6145Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M11.3089 2.5C10.7622 2.83861 10.0012 4 10.0012 5.5M7.53971 4C7.53971 4 7 4.5 7 5.5M14.0012 4C13.7279 4.1693 13.5 5 13.5 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],P=[[`path`,{d:`M3.89124 3.89124C5.28249 2.5 7.52166 2.5 12 2.5C16.4783 2.5 18.7175 2.5 20.1088 3.89124C21.5 5.28249 21.5 7.52166 21.5 12C21.5 16.4783 21.5 18.7175 20.1088 20.1088C18.7175 21.5 16.4783 21.5 12 21.5C7.52166 21.5 5.28249 21.5 3.89124 20.1088C2.5 18.7175 2.5 16.4783 2.5 12C2.5 7.52166 2.5 5.28249 3.89124 3.89124Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 2.5V21.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`1`}]],F=[[`path`,{d:`M2.49219 15.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M2.49219 8.5H21.4922`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M2.49219 12C2.49219 7.52166 2.49219 5.28249 3.88343 3.89124C5.27467 2.5 7.51384 2.5 11.9922 2.5C16.4705 2.5 18.7097 2.5 20.1009 3.89124C21.4922 5.28249 21.4922 7.52166 21.4922 12C21.4922 16.4783 21.4922 18.7175 20.1009 20.1088C18.7097 21.5 16.4705 21.5 11.9922 21.5C7.51384 21.5 5.27467 21.5 3.88343 20.1088C2.49219 18.7175 2.49219 16.4783 2.49219 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}]],I=e(A(),1);function L(e){let t=(0,I.useRef)(e);return(0,I.useInsertionEffect)(()=>void(t.current=e)),(0,I.useCallback)((...e)=>t.current(...e),[])}var R=k(),z=(0,I.createContext)(void 0);function ee(){return(0,I.useContext)(z)}var B={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},V={display:`contents`};function H(){return null}function U({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:f=O}){let p=n?.(e),m=r?.(e),h=i?.(e),_=a?.(e);return(0,R.jsxs)(R.Fragment,{children:[p==null?(0,R.jsxs)(R.Fragment,{children:[m!=null&&(0,R.jsx)(`div`,{slot:`header-prefix`,children:m}),h!=null&&(0,R.jsx)(`div`,{slot:`header-filename-suffix`,children:h}),_!=null&&(0,R.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,R.jsx)(`div`,{slot:g,children:p}),o!=null&&l?.map((t,n)=>(0,R.jsx)(`div`,{slot:f(t),children:o(t,e)},n)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=te(t,e);return(0,R.jsx)(`div`,{slot:n,style:V,children:c(t,d)},n)}),s!=null&&(0,R.jsx)(`div`,{slot:`gutter-utility-slot`,style:B,children:s(u)})]})}function te(e,t){let n=b(e,t);return n==null?void 0:x({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var ne=(0,I.createContext)(void 0);function re(e,t){return typeof window>`u`&&t!=null?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,R.jsx)(R.Fragment,{children:e})}var ie=(0,I.createContext)(void 0);function W(){return(0,I.useContext)(ie)}function G(){let[e]=(0,I.useState)(()=>{let e=0,t;return{getSnapshot:()=>e,subscribe(e){return t=e,()=>{t=void 0}},forceUpdate(){e++,t?.()}}});return(0,I.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),e.forceUpdate}function K(e,t){"use no memo";return e.current?.__getNextRenderData(t)}var q=typeof window>`u`?I.useEffect:I.useLayoutEffect;function J({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:m,onEditComplete:h}){let g=W(),_=s!==void 0,b=(0,I.useContext)(ne),x=ee(),[C,w]=(0,I.useState)(),E=L(e=>m?.(e)),D=m==null?void 0:E,k=(0,I.useRef)(null),A=L(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(k.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),j=h==null?void 0:A,M=ae({acceptedCache:k,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),N=(0,I.useRef)(null),P=G(),F=K(N,oe(k,M,o))??{fileDiff:M,lineAnnotations:o??y},R=(0,I.useRef)(null),z=(0,I.useRef)(null),B=L(()=>{if(x==null)throw Error(`FileDiff: EditContext is not attached`);return x(`file-diff`,i??{},a)}),V=L(e=>{if(e!=null){if(N.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?N.current=new v(Z({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:D,onEditComplete:j,options:r}),f?void 0:b,P):N.current=new S(Z({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:D,onEditComplete:j,options:r}),g,l,f?void 0:b,P),N.current.hydrate({fileDiff:M,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(N.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);z.current=null,N.current.cleanUp(),N.current=null,R.current=null}});q(()=>{let{current:e}=N;if(e==null)return;let t=Z({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:D,onEditComplete:j,options:r}),n=!T(e.options,t);if(e.setOptions(t),!p&&(z.current=null,R.current!=null)){let{current:e}=R;R.current=null,e()}let i=se(M,o,k);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||R.current!=null)return;if(x==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{N.current===e&&R.current==null&&e.__canAttachEditor()&&(R.current=Q(e,B),P())};if(e.__canAttachEditor()){z.current=null,a();return}let c=e.__prepareForEditing();if(c==null){z.current=null;return}if(z.current?.promise===c)return;let l={promise:c};z.current=l,c.then(()=>{z.current===l&&(a(),z.current=null)}).catch(e=>{z.current===l&&(z.current=null,w(e))})});let H=(0,I.useCallback)(()=>N.current?.getHoveredLine(),[]),U=(0,I.useCallback)(e=>N.current?.getAnnotationSlotName(e)??O(e),[]);if(C!=null)throw C;return{...F,ref:V,getHoveredLine:H,getAnnotationSlotName:U}}function ae({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,I.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(Y(r,n,o.stale)||Y(r,n,o.installed))return o.fileDiff;a.filePair=null}return w(r??null,n??null,i)},[e,t,r,n,i])}function Y(e,t,n){return _(e??void 0,n.oldFile??void 0)&&_(t??void 0,n.newFile??void 0)}function oe(e,t,n){"use no memo";return X(t,n,e.current)}function X(e,t,n){return{fileDiff:n?.fileDiff!=null&&E(e,n.fileDiff.stale)?n.fileDiff.installed:e,lineAnnotations:n?.annotations!=null&&t===n.annotations.stale?n.annotations.installed:t}}function se(e,t,n){let{current:r}=n,i=X(e,t,r);return r==null||(r.fileDiff!=null&&!E(e,r.fileDiff.stale)&&(r.fileDiff=null),t!==r.annotations?.stale&&(r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null)),i}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return{...e,controlledSelection:t,renderCustomHeader:n?H:e?.renderCustomHeader,renderGutterUtility:r?H:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}}function Q(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function ce({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1,onEditChange:v,onEditComplete:y}){let{ref:b,getHoveredLine:x,getAnnotationSlotName:S,fileDiff:w,lineAnnotations:T}=J({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_,onEditChange:v,onEditComplete:y}),E=U({fileDiff:w,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,renderGutterUtility:h,lineAnnotations:T,getHoveredLine:x,getAnnotationSlotName:S});return(0,R.jsx)(C,{ref:b,className:s,style:c,children:re(E,l)})}var le=3e3,ue=`text-foreground hover:bg-accent aria-pressed:bg-accent inline-flex h-7 min-w-7 cursor-pointer items-center justify-center rounded-lg px-1.5 [&_svg]:opacity-80`,$=`text-muted-foreground hover:text-foreground aria-pressed:bg-background aria-pressed:text-foreground dark:aria-pressed:bg-input/72 inline-flex h-6 cursor-pointer items-center justify-center rounded-md px-2.5 aria-pressed:shadow-xs`;function de(e){let[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(null),[b,x]=(0,I.useState)(0),S=(0,I.useRef)({patch:null,count:0}),C=l(e=>e.prefs.diff),w=c(),[T,E]=r(`diffFlipped`,[]);function O(e){d({...f().prefs,diff:{...C,...e}})}(0,I.useEffect)(()=>{let t=!0,n=!1;async function r(){if(!n){n=!0;try{let n=await u(e.machine,`git.diff`,{projectId:e.projectId});if(!t||(y(null),n===S.current.patch))return;S.current={patch:n,count:S.current.count+1},_(n.trim()===``?[]:D(n,`${e.projectId}:${S.current.count}`).flatMap(e=>e.files))}catch(e){t&&y(j(e))}finally{n=!1}}}function i(){document.hidden||r()}r();let a=window.setInterval(i,le);return window.addEventListener(`focus`,i),()=>{t=!1,window.clearInterval(a),window.removeEventListener(`focus`,i)}},[e.machine,e.projectId,e.running,b]);let k=g??[],A=M(k,e=>M(e.hunks,e=>e.additionLines)),L=M(k,e=>M(e.hunks,e=>e.deletionLines));return(0,R.jsxs)(`div`,{className:`bg-background flex h-full min-h-0 min-w-0 flex-col`,children:[(0,R.jsxs)(`div`,{className:`border-border/60 bg-background flex h-(--workspace-topbar-height) shrink-0 items-center justify-between gap-2 border-b pr-3 pl-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(h,{size:`icon-sm`,variant:`ghost`,title:`Close`,"aria-label":`Close`,onClick:e.onClose,children:(0,R.jsx)(m,{icon:p,className:`size-4`})}),(0,R.jsx)(`span`,{className:`text-foreground min-w-0 truncate text-xs font-medium`,children:`Uncommitted changes`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[k.length>0&&(0,R.jsxs)(`span`,{className:`text-2xs mr-1 inline-flex items-center gap-1 font-mono tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`text-diff-addition`,children:[`+`,A]}),(0,R.jsxs)(`span`,{className:`text-diff-deletion`,children:[`-`,L]})]}),(0,R.jsx)(h,{size:`icon-sm`,variant:`ghost`,title:`Refresh diff`,"aria-label":`Refresh diff`,onClick:()=>x(b+1),children:(0,R.jsx)(m,{icon:i,className:`size-4`})}),k.length>0&&(0,R.jsx)(h,{size:`icon-sm`,variant:`ghost`,title:C.collapsed?`Expand all files`:`Collapse all files`,onClick:()=>{E([]),O({collapsed:!C.collapsed})},children:(0,R.jsx)(m,{icon:C.collapsed?n:s,className:`size-4`})}),(0,R.jsxs)(`div`,{className:`bg-input/40 flex shrink-0 items-center rounded-lg p-0.5`,children:[(0,R.jsx)(`button`,{className:$,"aria-pressed":!C.split,"aria-label":`Stacked diff view`,onClick:()=>O({split:!1}),children:(0,R.jsx)(m,{icon:F,className:`size-3.5`})}),(0,R.jsx)(`button`,{className:$,"aria-pressed":C.split,"aria-label":`Split diff view`,onClick:()=>O({split:!0}),children:(0,R.jsx)(m,{icon:P,className:`size-3.5`})})]}),(0,R.jsx)(`button`,{className:ue,"aria-pressed":C.wrap,title:C.wrap?`Disable line wrapping`:`Enable line wrapping`,onClick:()=>O({wrap:!C.wrap}),children:(0,R.jsx)(m,{icon:o,className:`size-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`diff-render-surface min-h-0 flex-1 overflow-y-auto [--code-background:var(--background)]`,children:[v!==null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:v}),v===null&&g===null&&(0,R.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:`Loading…`}),v===null&&g?.length===0&&(0,R.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,R.jsx)(m,{icon:N,className:`text-muted-foreground/40 size-8`}),(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No uncommitted changes`}),(0,R.jsx)(`p`,{className:`text-muted-foreground/50 text-xs italic`,children:`If it works, don’t touch it.`})]})]}),v===null&&k.map(e=>{let n=C.collapsed!==T.includes(e.name);function r(){E(T.includes(e.name)?T.filter(t=>t!==e.name):[...T,e.name])}return(0,R.jsx)(`div`,{onClick:e=>{e.nativeEvent.composedPath().some(e=>e instanceof Element&&e.hasAttribute(`data-title`))&&r()},children:(0,R.jsx)(ce,{fileDiff:e,options:{theme:w,themeType:`dark`,unsafeCSS:`:host,
2
2
  [data-diffs-header],
3
3
  [data-diff],
4
4
  [data-file],